[vlc-commits] demux: ogg: fix seeking bounds search

Francois Cartegnie git at videolan.org
Thu Mar 6 23:32:37 CET 2014


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Mar  3 22:28:03 2014 +0100| [899f379572c792e9a691a591fbfc2193ff328b20] | committer: Francois Cartegnie

demux: ogg: fix seeking bounds search

Might not have found lowest granule for vorbis/opus like codecs.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=899f379572c792e9a691a591fbfc2193ff328b20
---

 modules/demux/oggseek.c |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/modules/demux/oggseek.c b/modules/demux/oggseek.c
index 91c24e4..b44545c 100644
--- a/modules/demux/oggseek.c
+++ b/modules/demux/oggseek.c
@@ -859,7 +859,8 @@ static int64_t OggBisectSearchByTime( demux_t *p_demux, logical_stream_t *p_stre
         int64_t i_timestamp;
         int64_t i_granule;
     } bestlower = { p_stream->i_data_start, -1, -1 },
-      current = { -1, -1, -1 };
+      current = { -1, -1, -1 },
+      lowestupper = { -1, -1, -1 };
 
     demux_sys_t *p_sys  = p_demux->p_sys;
 
@@ -905,6 +906,10 @@ static int64_t OggBisectSearchByTime( demux_t *p_demux, logical_stream_t *p_stre
             msg_Err( p_demux, "Unmatched granule. New codec ?" );
             return -1;
         }
+        else if ( current.i_timestamp < -1 )  /* due to preskip with some codecs */
+        {
+            current.i_timestamp = 0;
+        }
 
         if ( current.i_pos != -1 && current.i_granule != -1 )
         {
@@ -919,6 +924,8 @@ static int64_t OggBisectSearchByTime( demux_t *p_demux, logical_stream_t *p_stre
             }
             else if ( current.i_timestamp > i_targettime )
             {
+                if ( lowestupper.i_timestamp == -1 || current.i_timestamp < lowestupper.i_timestamp )
+                    lowestupper = current;
                 /* check lower half of segment */
                 i_start_pos -= i_segsize;
                 i_end_pos -= i_segsize;
@@ -931,15 +938,22 @@ static int64_t OggBisectSearchByTime( demux_t *p_demux, logical_stream_t *p_stre
             i_start_pos -= i_segsize;
         }
 
-        OggDebug( msg_Dbg(p_demux, "Bisect restart i_segsize=%"PRId64" between %"PRId64" and %"PRId64,
-                i_segsize, i_start_pos, i_end_pos ) );
+        OggDebug( msg_Dbg(p_demux, "Bisect restart i_segsize=%"PRId64" between %"PRId64
+                                   " and %"PRId64 " bl %"PRId64" lu %"PRId64,
+                i_segsize, i_start_pos, i_end_pos, bestlower.i_granule, lowestupper.i_granule  ) );
 
         i_segsize = ( i_end_pos - i_start_pos + 1 ) >> 1;
         i_start_pos += i_segsize;
 
     } while ( i_segsize > 64 );
 
-    if ( bestlower.i_granule == -1 ) return -1;
+    if ( bestlower.i_granule == -1 )
+    {
+        if ( lowestupper.i_granule == -1 )
+            return -1;
+        else
+            bestlower = lowestupper;
+    }
 
     if ( p_stream->b_oggds )
     {



More information about the vlc-commits mailing list