Fix the initial frame bug triggered by vcut; if the first block of a
authorMonty <xiphmont@xiph.org>
Mon, 26 Mar 2001 23:27:43 +0000 (23:27 +0000)
committerMonty <xiphmont@xiph.org>
Mon, 26 Mar 2001 23:27:43 +0000 (23:27 +0000)
stream was long, libvorbis would accidentally output audio for the
very forst audio packet.  Second packet was handled correctly.

Monty

svn path=/trunk/vorbis/; revision=1406

doc/v-comment.html
examples/decoder_example.c
lib/block.c
lib/codec_internal.h

index 4089d81..99876df 100644 (file)
@@ -7,7 +7,7 @@
 Ogg Vorbis comment field specification
 </font></h1>
 
-<em>Last update to this document: January 19, 2001</em><p>
+<em>Last update to this document: February 9, 2001</em><p>
 
 The text comment header is the second (of three) header packets that
 begin a Vorbis bitstream. It is meant for short, text comments,
@@ -188,7 +188,7 @@ software under other licenses.<p>
 
 OggSquish, Vorbis, Xiphophorus and their logos are trademarks (tm) of
 <a href="http://www.xiph.org/">Xiphophorus</a>.  These pages are
-copyright (C) 1994-2000 Xiphophorus. All rights reserved.<p>
+copyright (C) 1994-2001 Xiphophorus. All rights reserved.<p>
 
 </body>
 
index 29d16f2..735da5b 100644 (file)
@@ -7,11 +7,11 @@
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001             *
  * by the XIPHOPHORUS Company http://www.xiph.org/                  *
-
+ *                                                                  *
  ********************************************************************
 
  function: simple example decoder
- last mod: $Id: decoder_example.c,v 1.18 2001/02/26 03:50:38 xiphmont Exp $
+ last mod: $Id: decoder_example.c,v 1.19 2001/03/26 23:27:42 xiphmont Exp $
 
  ********************************************************************/
 
index e57af6e..3e72029 100644 (file)
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: PCM data vector blocking, windowing and dis/reassembly
- last mod: $Id: block.c,v 1.46 2001/02/26 03:50:41 xiphmont Exp $
+ last mod: $Id: block.c,v 1.47 2001/03/26 23:27:42 xiphmont Exp $
 
  Handle windowing, overlap-add, etc of the PCM vectors.  This is made
  more amusing by Vorbis' current two allowed block sizes.
@@ -617,9 +617,7 @@ int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){
   codec_setup_info *ci=vi->codec_setup;
   _vds_shared_init(v,vi,0);
 
-  /* Adjust centerW to allow an easier mechanism for determining output */
-  v->pcm_returned=v->centerW;
-  v->centerW-= ci->blocksizes[v->W]/4+ci->blocksizes[v->lW]/4;
+  v->pcm_returned=-1;
   v->granulepos=-1;
   v->sequence=-1;
 
@@ -725,6 +723,12 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
     
     }
 
+    /* deal with initial packet state; we do this using the explicit
+       pcm_returned==-1 flag otherwise we're sensitive to first block
+       being short or long */
+
+    if(v->pcm_returned==-1)
+      v->pcm_returned=centerW;
 
     /* track the frame number... This is for convenience, but also
        making sure our last packet doesn't end with added padding.  If
@@ -754,6 +758,9 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){
            /* partial last frame.  Strip the extra samples off */
            centerW-=extra;
          }else if(vb->sequence == 1){
+           /* ^^^ argh, this can be 1 from seeking! */
+
+
            /* partial first frame.  Discard extra leading samples */
            v->pcm_returned+=extra;
            if(v->pcm_returned>centerW)v->pcm_returned=centerW;
index 38a8048..3b33368 100644 (file)
@@ -7,11 +7,10 @@
  *                                                                  *
  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001             *
  * by the XIPHOPHORUS Company http://www.xiph.org/                  *
-
  ********************************************************************
 
  function: libvorbis codec headers
- last mod: $Id: codec_internal.h,v 1.7 2001/02/26 03:50:41 xiphmont Exp $
+ last mod: $Id: codec_internal.h,v 1.8 2001/03/26 23:27:43 xiphmont Exp $
 
  ********************************************************************/