Try out a new seek bisect optimization in vorbisfile.
authorMonty <xiphmont@xiph.org>
Mon, 26 Apr 2010 08:05:07 +0000 (08:05 +0000)
committerMonty <xiphmont@xiph.org>
Mon, 26 Apr 2010 08:05:07 +0000 (08:05 +0000)
svn path=/trunk/vorbis/; revision=17176

lib/vorbisfile.c

index c2ef280..a3569c9 100644 (file)
@@ -1427,13 +1427,14 @@ int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos){
         bisect=begin +
           (ogg_int64_t)((double)(target-begintime)*(end-begin)/(endtime-begintime))
           - CHUNKSIZE;
-        if(bisect<=begin)
-          bisect=begin+1;
+        if(bisect>begin+CHUNKSIZE){
+          result=_seek_helper(vf,bisect);
+          if(result) goto seek_error;
+        }else{
+          bisect=begin;
+        }
       }
 
-      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;