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

giles at svn.xiph.org giles at svn.xiph.org
Sun Jun 26 11:37:00 PDT 2005


Author: giles
Date: 2005-06-26 11:36:49 -0700 (Sun, 26 Jun 2005)
New Revision: 9513

Modified:
   trunk/vorbis/lib/block.c
   trunk/vorbis/lib/info.c
Log:
Properly initialize the packetno field when returning header packets,
and start counting data packet sequence numbers with 3 instead of zero
so that all the ogg packets come out of the encoder with the same
packetno fields they would have in coming out of an Ogg file (as read by
libogg, anyway).

Previously data packets started counting from zero, and the packetno
field of the returned header packets was uninitialized.

We had two choices in resolving this. One was just to add 3 to the
vorbis_dsp_state and/or vorbis_block sequence field when writing it to
the ogg_packet packetno field. The other is to actually keep the
packetno in the internal sequence fields. I chose the later based on the
fact that this same field gets set directly from the ogg_packet packetno
on decode, so things are consistent.



Modified: trunk/vorbis/lib/block.c
===================================================================
--- trunk/vorbis/lib/block.c	2005-06-25 12:27:10 UTC (rev 9512)
+++ trunk/vorbis/lib/block.c	2005-06-26 18:36:49 UTC (rev 9513)
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: PCM data vector blocking, windowing and dis/reassembly
- last mod: $Id: block.c,v 1.76 2003/12/30 11:02:22 xiphmont Exp $
+ last mod: $Id$
 
  Handle windowing, overlap-add, etc of the PCM vectors.  This is made
  more amusing by Vorbis' current two allowed block sizes.
@@ -106,7 +106,7 @@
       oggpack_writeinit(vbi->packetblob[i]);
     }    
   }
-  
+
   return(0);
 }
 
@@ -293,6 +293,10 @@
 
   vorbis_bitrate_init(vi,&b->bms);
 
+  /* compressed audio packets start after the headers
+     with sequence number 3 */
+  v->sequence=3;
+
   return(0);
 }
 

Modified: trunk/vorbis/lib/info.c
===================================================================
--- trunk/vorbis/lib/info.c	2005-06-25 12:27:10 UTC (rev 9512)
+++ trunk/vorbis/lib/info.c	2005-06-26 18:36:49 UTC (rev 9513)
@@ -517,6 +517,7 @@
   op->b_o_s=0;
   op->e_o_s=0;
   op->granulepos=0;
+  op->packetno=1;
 
   return 0;
 }
@@ -550,6 +551,7 @@
   op->b_o_s=1;
   op->e_o_s=0;
   op->granulepos=0;
+  op->packetno=0;
 
   /* second header packet (comments) **********************************/
 
@@ -564,6 +566,7 @@
   op_comm->b_o_s=0;
   op_comm->e_o_s=0;
   op_comm->granulepos=0;
+  op_comm->packetno=1;
 
   /* third header packet (modes/codebooks) ****************************/
 
@@ -578,6 +581,7 @@
   op_code->b_o_s=0;
   op_code->e_o_s=0;
   op_code->granulepos=0;
+  op_code->packetno=2;
 
   oggpack_writeclear(&opb);
   return(0);



More information about the commits mailing list