[xiph-commits] r17178 - trunk/vorbis/lib

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Mon Apr 26 07:25:55 PDT 2010


Author: xiphmont
Date: 2010-04-26 07:25:54 -0700 (Mon, 26 Apr 2010)
New Revision: 17178

Modified:
   trunk/vorbis/lib/vorbisfile.c
Log:
Fix a chaining bug in raw_seeks where seeking out of the current link 
would fail due to not reinitializing the decode machinery.

Also correct a minor and a moderate inefficiency that reduces the 
necessary number of seek callback in a search operation by about 2/3.



Modified: trunk/vorbis/lib/vorbisfile.c
===================================================================
--- trunk/vorbis/lib/vorbisfile.c	2010-04-26 14:24:08 UTC (rev 17177)
+++ trunk/vorbis/lib/vorbisfile.c	2010-04-26 14:25:54 UTC (rev 17178)
@@ -533,8 +533,10 @@
         bisect=(searched+endsearched)/2;
       }
 
-      ret=_seek_helper(vf,bisect);
-      if(ret)return(ret);
+      if(bisect != vf->offset){
+        ret=_seek_helper(vf,bisect);
+        if(ret)return(ret);
+      }
 
       last=_get_next_page(vf,&og,-1);
       if(last==OV_EREAD)return(OV_EREAD);
@@ -542,7 +544,7 @@
         endsearched=bisect;
         if(last>=0)next=last;
       }else{
-        searched=last+og.header_len+og.body_len;
+        searched=vf->offset;
       }
     }
 
@@ -1226,6 +1228,12 @@
 
   if(pos<0 || pos>vf->end)return(OV_EINVAL);
 
+  /* is the seek position outside our current link [if any]? */
+  if(vf->ready_state>=STREAMSET){
+    if(pos<vf->offsets[vf->current_link] || pos>=vf->offsets[vf->current_link+1])
+      _decode_clear(vf); /* clear out stream state */
+  }
+
   /* don't yet clear out decoding machine (if it's initialized), in
      the case we're in the same link.  Restart the decode lapping, and
      let _fetch_and_process_packet deal with a potential bitstream
@@ -1427,14 +1435,15 @@
         bisect=begin +
           (ogg_int64_t)((double)(target-begintime)*(end-begin)/(endtime-begintime))
           - CHUNKSIZE;
-        if(bisect>begin+CHUNKSIZE){
-          result=_seek_helper(vf,bisect);
-          if(result) goto seek_error;
-        }else{
+        if(bisect<begin+CHUNKSIZE)
           bisect=begin;
-        }
       }
 
+      if(bisect!=vf->offset){
+        result=_seek_helper(vf,bisect);
+        if(result) goto seek_error;
+      }
+
       while(begin<end){
         result=_get_next_page(vf,&og,end-vf->offset);
         if(result==OV_EREAD) goto seek_error;



More information about the commits mailing list