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

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Wed Apr 8 22:52:38 PDT 2009


Author: xiphmont
Date: 2009-04-08 22:52:38 -0700 (Wed, 08 Apr 2009)
New Revision: 15925

Modified:
   trunk/vorbis/lib/vorbisfile.c
Log:
Add an optimization case to _get_prev_page that avoids a redundant seek/resync/reread in the common seek case.



Modified: trunk/vorbis/lib/vorbisfile.c
===================================================================
--- trunk/vorbis/lib/vorbisfile.c	2009-04-08 11:16:18 UTC (rev 15924)
+++ trunk/vorbis/lib/vorbisfile.c	2009-04-09 05:52:38 UTC (rev 15925)
@@ -154,6 +154,7 @@
     if(ret)return(ret);
 
     while(vf->offset<end){
+      memset(og,0,sizeof(*og));
       ret=_get_next_page(vf,og,end-vf->offset);
       if(ret==OV_EREAD)return(OV_EREAD);
       if(ret<0){
@@ -164,14 +165,18 @@
     }
   }
 
-  /* we have the offset.  Actually snork and hold the page now */
-  ret=_seek_helper(vf,offset);
-  if(ret)return(ret);
+  /* In a fully compliant, non-multiplexed stream, we'll still be
+     holding the last page.  In multiplexed (or noncompliant streams),
+     we may need to re-read the last page we saw */
+  if(og->header_len==0){
+    ret=_seek_helper(vf,offset);
+    if(ret)return(ret);
 
-  ret=_get_next_page(vf,og,CHUNKSIZE);
-  if(ret<0)
-    /* this shouldn't be possible */
-    return(OV_EFAULT);
+    ret=_get_next_page(vf,og,CHUNKSIZE);
+    if(ret<0)
+      /* this shouldn't be possible */
+      return(OV_EFAULT);
+  }
 
   return(offset);
 }



More information about the commits mailing list