Commit da1ce99b authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vdr: privatize seekpoint byte offsets

parent 3d83596e
......@@ -122,6 +122,7 @@ struct access_sys_t
/* cut marks */
input_title_t *p_marks;
uint64_t *offsets;
unsigned cur_seekpoint;
float fps;
......@@ -220,6 +221,8 @@ static void Close( vlc_object_t * p_this )
if( p_sys->p_meta )
vlc_meta_Delete( p_sys->p_meta );
size_t count = p_sys->p_marks->i_seekpoint;
TAB_CLEAN( count, p_sys->offsets );
vlc_input_title_Delete( p_sys->p_marks );
free( p_sys );
}
......@@ -318,7 +321,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
case ACCESS_SET_SEEKPOINT:
i = va_arg( args, int );
return Seek( p_access, p_sys->p_marks->seekpoint[i]->i_byte_offset );
return Seek( p_access, p_sys->offsets[i] );
case ACCESS_GET_META:
if( !p_sys->p_meta )
......@@ -425,8 +428,7 @@ static void FindSeekpoint( access_t *p_access )
return;
int new_seekpoint = p_sys->cur_seekpoint;
if( p_sys->offset < (uint64_t)p_sys->p_marks->
seekpoint[p_sys->cur_seekpoint]->i_byte_offset )
if( p_sys->offset < p_sys->offsets[p_sys->cur_seekpoint] )
{
/* i_pos moved backwards, start fresh */
new_seekpoint = 0;
......@@ -434,8 +436,7 @@ static void FindSeekpoint( access_t *p_access )
/* only need to check the following seekpoints */
while( new_seekpoint + 1 < p_sys->p_marks->i_seekpoint &&
p_sys->offset >= (uint64_t)p_sys->p_marks->
seekpoint[new_seekpoint + 1]->i_byte_offset )
p_sys->offset >= p_sys->offsets[new_seekpoint + 1] )
{
new_seekpoint++;
}
......@@ -819,6 +820,9 @@ static void ImportMarks( access_t *p_access )
p_marks->psz_name = strdup( _("VDR Cut Marks") );
p_marks->i_length = i_frame_count * (int64_t)( CLOCK_FREQ / p_sys->fps );
uint64_t *offsetv = NULL;
size_t offsetc = 0;
/* offset for chapter positions */
int i_chapter_offset = p_sys->fps / 1000 *
var_InheritInteger( p_access, "vdr-chapter-offset" );
......@@ -862,31 +866,38 @@ static void ImportMarks( access_t *p_access )
if( !sp )
continue;
sp->i_time_offset = i_frame * (int64_t)( CLOCK_FREQ / p_sys->fps );
sp->i_byte_offset = i_offset;
for( int i = 0; i + 1 < i_file_number; ++i )
sp->i_byte_offset += FILE_SIZE( i );
sp->psz_name = strdup( line );
TAB_APPEND( p_marks->i_seekpoint, p_marks->seekpoint, sp );
TAB_APPEND( offsetc, offsetv, i_offset );
for( int i = 0; i + 1 < i_file_number; ++i )
offsetv[offsetc - 1] += FILE_SIZE( i );
}
/* add a chapter at the beginning if missing */
if( p_marks->i_seekpoint > 0 && p_marks->seekpoint[0]->i_byte_offset > 0 )
if( p_marks->i_seekpoint > 0 && offsetv[0] > 0 )
{
seekpoint_t *sp = vlc_seekpoint_New();
if( sp )
{
sp->i_byte_offset = 0;
sp->i_time_offset = 0;
sp->psz_name = strdup( _("Start") );
TAB_INSERT( p_marks->i_seekpoint, p_marks->seekpoint, sp, 0 );
TAB_INSERT( offsetc, offsetv, UINT64_C(0), 0 );
}
}
if( p_marks->i_seekpoint > 0 )
{
p_sys->p_marks = p_marks;
p_sys->offsets = offsetv;
}
else
{
vlc_input_title_Delete( p_marks );
TAB_CLEAN( offsetc, offsetv );
}
fclose( marksfile );
fclose( indexfile );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment