[xiph-cvs] cvs commit: vorbis/lib vorbisfile.c

Monty xiphmont at xiph.org
Tue Oct 10 18:05:38 PDT 2000



xiphmont    00/10/10 18:05:37

  Modified:    lib      Tag: branch_postbeta2 vorbisfile.c
  Log:
  Fixed two bugs in vorbisfile:
  
  nonseekable streams dropped the initial header page/packet when
  chaining.  Fixed.
  
  seekable streams were always initializing decode witht he vorbis_info
  struct from the first link.  Fixed.
  
  Monty

Revision  Changes    Path
No                   revision

No                   revision

1.27.2.4  +24 -17    vorbis/lib/vorbisfile.c

Index: vorbisfile.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/vorbisfile.c,v
retrieving revision 1.27.2.3
retrieving revision 1.27.2.4
diff -u -r1.27.2.3 -r1.27.2.4
--- vorbisfile.c	2000/09/27 06:21:00	1.27.2.3
+++ vorbisfile.c	2000/10/11 01:05:37	1.27.2.4
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: stdio-based convenience library for opening/seeking/decoding
- last mod: $Id: vorbisfile.c,v 1.27.2.3 2000/09/27 06:21:00 jack Exp $
+ last mod: $Id: vorbisfile.c,v 1.27.2.4 2000/10/11 01:05:37 xiphmont Exp $
 
  ********************************************************************/
 
@@ -202,19 +202,22 @@
 /* uses the local ogg_stream storage in vf; this is important for
    non-streaming input sources */
 static int _fetch_headers(OggVorbis_File *vf,vorbis_info *vi,vorbis_comment *vc,
-			  long *serialno){
+			  long *serialno,ogg_page *og_ptr){
   ogg_page og;
   ogg_packet op;
   int i,ret;
-
-  ret=_get_next_page(vf,&og,CHUNKSIZE);
-  if(ret==-1){
-    fprintf(stderr,"Did not find initial header for bitstream.\n");
-    return -1;
-  }
   
-  if(serialno)*serialno=ogg_page_serialno(&og);
-  ogg_stream_init(&vf->os,ogg_page_serialno(&og));
+  if(!og_ptr){
+    ret=_get_next_page(vf,&og,CHUNKSIZE);
+    if(ret==-1){
+      fprintf(stderr,"Did not find initial header for bitstream.\n");
+      return -1;
+    }
+    og_ptr=&og;
+  }
+
+  if(serialno)*serialno=ogg_page_serialno(og_ptr);
+  ogg_stream_init(&vf->os,ogg_page_serialno(og_ptr));
   
   /* extract the initial header from the first page and verify that the
      Ogg bitstream is in fact Vorbis data */
@@ -224,7 +227,7 @@
   
   i=0;
   while(i<3){
-    ogg_stream_pagein(&vf->os,&og);
+    ogg_stream_pagein(&vf->os,og_ptr);
     while(i<3){
       int result=ogg_stream_packetout(&vf->os,&op);
       if(result==0)break;
@@ -239,7 +242,7 @@
       i++;
     }
     if(i<3)
-      if(_get_next_page(vf,&og,1)<0){
+      if(_get_next_page(vf,og_ptr,1)<0){
         fprintf(stderr,"Missing header in logical bitstream.\n");
         goto bail_header;
       }
@@ -281,7 +284,7 @@
       /* seek to the location of the initial header */
 
       _seek_helper(vf,vf->offsets[i]);
-      if(_fetch_headers(vf,vf->vi+i,vf->vc+i,NULL)==-1){
+      if(_fetch_headers(vf,vf->vi+i,vf->vc+i,NULL,NULL)==-1){
         fprintf(stderr,"Error opening logical bitstream #%d.\n\n",i+1);
             vf->dataoffsets[i]=-1;
       }else{
@@ -318,7 +321,11 @@
 
 static int _make_decode_ready(OggVorbis_File *vf){
   if(vf->decode_ready)exit(1);
-  vorbis_synthesis_init(&vf->vd,vf->vi);
+  if(vf->seekable){
+    vorbis_synthesis_init(&vf->vd,vf->vi+vf->current_link);
+  }else{
+    vorbis_synthesis_init(&vf->vd,vf->vi);
+  }    
   vorbis_block_init(&vf->vd,&vf->vb);
   vf->decode_ready=1;
   return(0);
@@ -333,7 +340,7 @@
   ogg_page og;
   
   /* is this even vorbis...? */
-  ret=_fetch_headers(vf,&initial_i,&initial_c,&serialno);
+  ret=_fetch_headers(vf,&initial_i,&initial_c,&serialno,NULL);
   dataoffset=vf->offset;
   ogg_stream_clear(&vf->os);
   if(ret==-1)return(-1);
@@ -373,7 +380,7 @@
   vf->vc=calloc(vf->links,sizeof(vorbis_info));
 
   /* Try to fetch the headers, maintaining all the storage */
-  if(_fetch_headers(vf,vf->vi,vf->vc,&vf->current_serialno)==-1)return(-1);
+  if(_fetch_headers(vf,vf->vi,vf->vc,&vf->current_serialno,NULL)==-1)return(-1);
   _make_decode_ready(vf);
 
   return 0;
@@ -515,7 +522,7 @@
         /* we're streaming */
         /* fetch the three header packets, build the info struct */
         
-	_fetch_headers(vf,vf->vi,vf->vc,&vf->current_serialno);
+	_fetch_headers(vf,vf->vi,vf->vc,&vf->current_serialno,&og);
         vf->current_link++;
         link=0;
       }

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list