[vlc-commits] demux: ogg: don't use arbitrary granule as lower search bound
Francois Cartegnie
git at videolan.org
Tue Oct 22 09:43:56 CEST 2013
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Oct 16 12:35:15 2013 +0200| [5c15aa3de2401e625a132550d3e08420ccb08647] | committer: Francois Cartegnie
demux: ogg: don't use arbitrary granule as lower search bound
Should fix seeking case on time 0
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5c15aa3de2401e625a132550d3e08420ccb08647
---
modules/demux/oggseek.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/modules/demux/oggseek.c b/modules/demux/oggseek.c
index d304f1a..0f69d71 100644
--- a/modules/demux/oggseek.c
+++ b/modules/demux/oggseek.c
@@ -1154,7 +1154,7 @@ static int64_t OggBisectSearchByTime( demux_t *p_demux, logical_stream_t *p_stre
int64_t i_pos;
int64_t i_timestamp;
int64_t i_granule;
- } bestlower = { p_stream->i_data_start, 0, p_stream->i_keyframe_offset },
+ } bestlower = { p_stream->i_data_start, -1, -1 },
current = { -1, -1, -1 };
demux_sys_t *p_sys = p_demux->p_sys;
@@ -1233,8 +1233,9 @@ static int64_t OggBisectSearchByTime( demux_t *p_demux, logical_stream_t *p_stre
i_segsize = ( i_end_pos - i_start_pos + 1 ) >> 1;
i_start_pos += i_segsize;
- } while ( i_segsize > 64 && current.i_granule != -1 );
+ } while ( i_segsize > 64 );
+ if ( bestlower.i_granule == -1 ) return -1;
if ( p_stream->b_oggds )
{
@@ -1253,7 +1254,7 @@ static int64_t OggBisectSearchByTime( demux_t *p_demux, logical_stream_t *p_stre
i_keyframegranule >> p_stream->i_granule_shift,
bestlower.i_granule,
i_pos_upper,
- Oggseek_GranuleToAbsTimestamp( p_stream, i_keyframegranule, true ) ) );
+ Oggseek_GranuleToAbsTimestamp( p_stream, i_keyframegranule, false ) ) );
OggDebug( msg_Dbg( p_demux, "Seeking back to %"PRId64, __MAX ( bestlower.i_pos - OGGSEEK_BYTES_TO_READ, p_stream->i_data_start ) ) );
@@ -1275,16 +1276,16 @@ int Oggseek_BlindSeektoAbsoluteTime( demux_t *p_demux, logical_stream_t *p_strea
int64_t i_time, bool b_fastseek )
{
demux_sys_t *p_sys = p_demux->p_sys;
- int64_t i_pos = -1;
- int64_t i_unusedpos = -1;
+ int64_t i_lowerpos = -1;
+ int64_t i_upperpos = -1;
bool b_found = false;
/* Search in skeleton */
- Ogg_GetBoundsUsingSkeletonIndex( p_stream, i_time, &i_pos, &i_unusedpos );
- if ( i_pos != -1 ) b_found = true;
+ Ogg_GetBoundsUsingSkeletonIndex( p_stream, i_time, &i_lowerpos, &i_upperpos );
+ if ( i_lowerpos != -1 ) b_found = true;
/* And also search in our own index */
- if ( !b_found && OggSeekIndexFind( p_stream, i_time, &i_pos, &i_unusedpos ) )
+ if ( !b_found && OggSeekIndexFind( p_stream, i_time, &i_lowerpos, &i_upperpos ) )
{
b_found = true;
}
@@ -1295,29 +1296,29 @@ int Oggseek_BlindSeektoAbsoluteTime( demux_t *p_demux, logical_stream_t *p_strea
{
/* But only if there's no keyframe/preload requirements */
/* FIXME: add function to get preload time by codec, ex: opus */
- i_pos = i_time * p_sys->i_bitrate / INT64_C(8000000);
+ i_lowerpos = i_time * p_sys->i_bitrate / INT64_C(8000000);
b_found = true;
}
/* or search */
if ( !b_found && b_fastseek )
{
- i_pos = OggBisectSearchByTime( p_demux, p_stream, i_time,
- p_stream->i_data_start, p_sys->i_total_length );
- b_found = ( i_pos != -1 );
+ i_lowerpos = OggBisectSearchByTime( p_demux, p_stream, i_time,
+ p_stream->i_data_start, p_sys->i_total_length );
+ b_found = ( i_lowerpos != -1 );
}
if ( !b_found ) return -1;
- if ( i_pos < p_stream->i_data_start || i_unusedpos > p_sys->i_total_length )
+ if ( i_lowerpos < p_stream->i_data_start || i_upperpos > p_sys->i_total_length )
return -1;
/* And really do seek */
- p_sys->i_input_position = i_pos;
+ p_sys->i_input_position = i_lowerpos;
seek_byte( p_demux, p_sys->i_input_position );
ogg_stream_reset( &p_stream->os );
- return i_pos;
+ return i_lowerpos;
}
int Oggseek_BlindSeektoPosition( demux_t *p_demux, logical_stream_t *p_stream,
More information about the vlc-commits
mailing list