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 ...@@ -122,6 +122,7 @@ struct access_sys_t
/* cut marks */ /* cut marks */
input_title_t *p_marks; input_title_t *p_marks;
uint64_t *offsets;
unsigned cur_seekpoint; unsigned cur_seekpoint;
float fps; float fps;
...@@ -220,6 +221,8 @@ static void Close( vlc_object_t * p_this ) ...@@ -220,6 +221,8 @@ static void Close( vlc_object_t * p_this )
if( p_sys->p_meta ) if( p_sys->p_meta )
vlc_meta_Delete( 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 ); vlc_input_title_Delete( p_sys->p_marks );
free( p_sys ); free( p_sys );
} }
...@@ -318,7 +321,7 @@ static int Control( access_t *p_access, int i_query, va_list args ) ...@@ -318,7 +321,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
case ACCESS_SET_SEEKPOINT: case ACCESS_SET_SEEKPOINT:
i = va_arg( args, int ); 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: case ACCESS_GET_META:
if( !p_sys->p_meta ) if( !p_sys->p_meta )
...@@ -425,8 +428,7 @@ static void FindSeekpoint( access_t *p_access ) ...@@ -425,8 +428,7 @@ static void FindSeekpoint( access_t *p_access )
return; return;
int new_seekpoint = p_sys->cur_seekpoint; int new_seekpoint = p_sys->cur_seekpoint;
if( p_sys->offset < (uint64_t)p_sys->p_marks-> if( p_sys->offset < p_sys->offsets[p_sys->cur_seekpoint] )
seekpoint[p_sys->cur_seekpoint]->i_byte_offset )
{ {
/* i_pos moved backwards, start fresh */ /* i_pos moved backwards, start fresh */
new_seekpoint = 0; new_seekpoint = 0;
...@@ -434,8 +436,7 @@ static void FindSeekpoint( access_t *p_access ) ...@@ -434,8 +436,7 @@ static void FindSeekpoint( access_t *p_access )
/* only need to check the following seekpoints */ /* only need to check the following seekpoints */
while( new_seekpoint + 1 < p_sys->p_marks->i_seekpoint && while( new_seekpoint + 1 < p_sys->p_marks->i_seekpoint &&
p_sys->offset >= (uint64_t)p_sys->p_marks-> p_sys->offset >= p_sys->offsets[new_seekpoint + 1] )
seekpoint[new_seekpoint + 1]->i_byte_offset )
{ {
new_seekpoint++; new_seekpoint++;
} }
...@@ -819,6 +820,9 @@ static void ImportMarks( access_t *p_access ) ...@@ -819,6 +820,9 @@ static void ImportMarks( access_t *p_access )
p_marks->psz_name = strdup( _("VDR Cut Marks") ); p_marks->psz_name = strdup( _("VDR Cut Marks") );
p_marks->i_length = i_frame_count * (int64_t)( CLOCK_FREQ / p_sys->fps ); 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 */ /* offset for chapter positions */
int i_chapter_offset = p_sys->fps / 1000 * int i_chapter_offset = p_sys->fps / 1000 *
var_InheritInteger( p_access, "vdr-chapter-offset" ); var_InheritInteger( p_access, "vdr-chapter-offset" );
...@@ -862,31 +866,38 @@ static void ImportMarks( access_t *p_access ) ...@@ -862,31 +866,38 @@ static void ImportMarks( access_t *p_access )
if( !sp ) if( !sp )
continue; continue;
sp->i_time_offset = i_frame * (int64_t)( CLOCK_FREQ / p_sys->fps ); 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 ); sp->psz_name = strdup( line );
TAB_APPEND( p_marks->i_seekpoint, p_marks->seekpoint, sp ); 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 */ /* 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(); seekpoint_t *sp = vlc_seekpoint_New();
if( sp ) if( sp )
{ {
sp->i_byte_offset = 0;
sp->i_time_offset = 0; sp->i_time_offset = 0;
sp->psz_name = strdup( _("Start") ); sp->psz_name = strdup( _("Start") );
TAB_INSERT( p_marks->i_seekpoint, p_marks->seekpoint, sp, 0 ); 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 ) if( p_marks->i_seekpoint > 0 )
{
p_sys->p_marks = p_marks; p_sys->p_marks = p_marks;
p_sys->offsets = offsetv;
}
else else
{
vlc_input_title_Delete( p_marks ); vlc_input_title_Delete( p_marks );
TAB_CLEAN( offsetc, offsetv );
}
fclose( marksfile ); fclose( marksfile );
fclose( indexfile ); 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