[xiph-commits] r11587 - in branches/vorbis-tahseen: include/vorbis lib

tahseen at svn.xiph.org tahseen at svn.xiph.org
Sun Jun 18 23:45:36 PDT 2006


Author: tahseen
Date: 2006-06-18 23:45:05 -0700 (Sun, 18 Jun 2006)
New Revision: 11587

Modified:
   branches/vorbis-tahseen/include/vorbis/vorbisfile.h
   branches/vorbis-tahseen/lib/vorbisfile.c
Log:
Removed codes intended to support vorbis streams in theora files using
libvorbisfile and now only supports skeleton+vorbis in a stream. It now
regains binary compatibility with the vorbis trunk.


Modified: branches/vorbis-tahseen/include/vorbis/vorbisfile.h
===================================================================
--- branches/vorbis-tahseen/include/vorbis/vorbisfile.h	2006-06-19 05:13:13 UTC (rev 11586)
+++ branches/vorbis-tahseen/include/vorbis/vorbisfile.h	2006-06-19 06:45:05 UTC (rev 11587)
@@ -49,11 +49,6 @@
 #define  STREAMSET 3
 #define  INITSET   4
 
-typedef struct OggBitstreamInfo {
-	long serialno;		/* serialno of this logical bitstream */
-	char signature[8];	/* header signature of this logical bitstream, like 0x1vorbis */
-} OggBitstreamInfo;
-
 typedef struct OggVorbis_File {
   void            *datasource; /* Pointer to a FILE *, etc. */
   int              seekable;
@@ -89,11 +84,8 @@
 
   ov_callbacks callbacks;
 
-  OggBitstreamInfo *obi; /* holds information on all logical bitstream contained in the file */
-  int obilen;		/* holds the size of OggBitstreamInfo array */
 } OggVorbis_File;
 
-
 extern int ov_clear(OggVorbis_File *vf);
 extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
 extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,

Modified: branches/vorbis-tahseen/lib/vorbisfile.c
===================================================================
--- branches/vorbis-tahseen/lib/vorbisfile.c	2006-06-19 05:13:13 UTC (rev 11586)
+++ branches/vorbis-tahseen/lib/vorbisfile.c	2006-06-19 06:45:05 UTC (rev 11587)
@@ -230,7 +230,7 @@
 			  long *serialno,ogg_page *og_ptr){
   ogg_page og;
   ogg_packet op;
-  int i,j,ret,skip;
+  int i,ret,skip;
   
   if(!og_ptr){
     ogg_int64_t llret=_get_next_page(vf,&og,CHUNKSIZE);
@@ -248,47 +248,23 @@
   
   vorbis_info_init(vi);
   vorbis_comment_init(vc);
-
   
   i=0;
   while(i<3){
     ogg_stream_pagein(&vf->os,og_ptr);
     while(i<3){
-      skip = 0;    
+      skip=0;    
       int result=ogg_stream_packetout(&vf->os,&op);
       if(result==0)break;
       if(result==-1){
 	ret=OV_EBADHEADER;
 	goto bail_header;
       }
-      /* trying to find OggBitstreamInfo (obi) has info on this stream. matching info on
-       * existing stream by using the serialno.
-       */
-      for(j = 0; j < vf->obilen; ++j) {
-	      if (vf->obi[j].serialno == ogg_page_serialno(og_ptr))
-		      break;
-      }
-      /* IMPORTANT: shouldn't use variable j, the value is used later. */
-      if (j == vf->obilen) {
-	     /* haven't seen this logical stream before, adding it to the OggBitstreamInfo structure */ 
-	     if (j == 0) { 
-		     vf->obi = _ogg_calloc(1, sizeof(OggBitstreamInfo)); 
-	     } else {
-		     vf->obi = _ogg_realloc(vf->obi, (j+1)*sizeof(OggBitstreamInfo));
-	     }
-	     vf->obi[j].serialno = ogg_page_serialno(og_ptr);
-	     memcpy(vf->obi[j].signature, op.packet, 8);
-	     ++vf->obilen;
-      }
-      if(memcmp(op.packet+1,"vorbis",6)){
-	skip = 1;
-      } else {
+      if(!memcmp(op.packet+1,"vorbis",6)){
+	if((ret=vorbis_synthesis_headerin(vi,vc,&op)))
+	  goto bail_header;      
 	++i;
       }
-      if(skip == 0){
-	      if((ret=vorbis_synthesis_headerin(vi,vc,&op)))
-		goto bail_header;
-      }
     }
     if(i<3)
       if(_get_next_page(vf,og_ptr,CHUNKSIZE)<0){
@@ -296,10 +272,9 @@
 	goto bail_header;
       }
     if (vf->os.serialno != ogg_page_serialno(og_ptr)) {
-	    ogg_stream_reset_serialno(&vf->os,ogg_page_serialno(og_ptr));
+      ogg_stream_reset_serialno(&vf->os,ogg_page_serialno(og_ptr));
     }
   }
-
   return 0; 
 
  bail_header:
@@ -323,7 +298,7 @@
   ogg_page og;
   int i;
   ogg_int64_t ret;
-
+  
   vf->vi=_ogg_realloc(vf->vi,vf->links*sizeof(*vf->vi));
   vf->vc=_ogg_realloc(vf->vc,vf->links*sizeof(*vf->vc));
   vf->dataoffsets=_ogg_malloc(vf->links*sizeof(*vf->dataoffsets));
@@ -492,16 +467,7 @@
 				     int readp,
 				     int spanp){
   ogg_page og;
-  int i;
 
-  /* finding the serialno of the first vorbis stream. */
-  for (i = 0; i < vf->obilen; ++i) {
-	  if (!memcmp(vf->obi[i].signature+1, "vorbis", 6))
-		  break;
-  }
-  /* set the serialno of ogg_stream_state in OggVorbis_File */
-  vf->os.serialno=vf->obi[i].serialno;
-
   /* handle one packet.  Try to fetch it from current stream state */
   /* extract packets from page */
   while(1){
@@ -594,18 +560,7 @@
       
       /* has our decoding just traversed a bitstream boundary? */
       if(vf->ready_state==INITSET){
-	if(vf->os.serialno!=ogg_page_serialno(&og)){
-	  /* We need to check if this is a vorbis packet, if so we are assuming we are 
-	   * at a bitstream boundary and need to reset the decoder. But if its a
-	   * non-vorbis packet or an packet whose serialno is not known from the header
-	   * we simply skip it.
-	   */
-	  for (i = 0; i < vf->obilen; ++i) {
-	    if (vf->obi[i].serialno==ogg_page_serialno(&og))
-	      break;
-	  }
-	  if (i<vf->obilen && memcmp(vf->obi[i].signature+1, "vorbis", 6))
-	    goto try_next_page;
+	if(vf->current_serialno!=ogg_page_serialno(&og)){
 	  if(!spanp)
 	    return(OV_EOF);
 
@@ -669,7 +624,6 @@
 	if(ret<0)return ret;
       }
     }
-    try_next_page:
     ogg_stream_pagein(&vf->os,&og);
   }
 }
@@ -685,7 +639,7 @@
 		     long ibytes, ov_callbacks callbacks){
   int offsettest=(f?callbacks.seek_func(f,0,SEEK_CUR):-1);
   int ret;
-  
+
   memset(vf,0,sizeof(*vf));
   vf->datasource=f;
   vf->callbacks = callbacks;
@@ -761,7 +715,6 @@
     if(vf->offsets)_ogg_free(vf->offsets);
     ogg_sync_clear(&vf->oy);
     if(vf->datasource)(vf->callbacks.close_func)(vf->datasource);
-    if(vf->obi)_ogg_free(vf->obi);
     memset(vf,0,sizeof(*vf));
   }
 #ifdef DEBUG_LEAKS



More information about the commits mailing list