Fix a bug in the post-encode normalization;
authorMonty <xiphmont@xiph.org>
Tue, 12 Dec 2000 08:54:27 +0000 (08:54 +0000)
committerMonty <xiphmont@xiph.org>
Tue, 12 Dec 2000 08:54:27 +0000 (08:54 +0000)
a zero amplitude was not being written by the normalizer, which causes
a problem is one channel is digital silence but the other contains
even a single nonzero bit (the whole frame is shifted/corrupt)

Monty

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

examples/encoder_example.c
lib/floor0.c
lib/mapping0.c

index f9280fb..5da7422 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: simple example encoder
- last mod: $Id: encoder_example.c,v 1.15 2000/11/06 00:06:53 xiphmont Exp $
+ last mod: $Id: encoder_example.c,v 1.16 2000/12/12 08:54:26 xiphmont Exp $
 
  ********************************************************************/
 
@@ -80,7 +80,7 @@ int main(){
   /* choose an encoding mode */
   /* (mode 0: 44kHz stereo uncoupled, roughly 128kbps VBR) */
   vorbis_info_init(&vi);
-  vorbis_encode_init(&vi,2,44100, -1, 128000, -1);
+  vorbis_encode_init(&vi,2,44100, -1, 160000, -1);
 
   /* add a comment */
   vorbis_comment_init(&vc);
index 0e454c4..e0b6842 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: floor backend 0 implementation
- last mod: $Id: floor0.c,v 1.32 2000/12/12 04:18:54 xiphmont Exp $
+ last mod: $Id: floor0.c,v 1.33 2000/12/12 08:54:27 xiphmont Exp $
 
  ********************************************************************/
 
@@ -373,9 +373,9 @@ static float floor0_forward2(vorbis_block *vb,vorbis_look_floor *i,
                          long amp,float error,
                          vorbis_bitbuffer *vbb){
 
+  vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
+  vorbis_info_floor0 *info=look->vi;
   if(amp){
-    vorbis_look_floor0 *look=(vorbis_look_floor0 *)i;
-    vorbis_info_floor0 *info=look->vi;
     long maxval=(1L<<info->ampbits)-1;
     long adj=rint(todB(error)/info->ampdB*maxval/2);
     
@@ -385,7 +385,10 @@ static float floor0_forward2(vorbis_block *vb,vorbis_look_floor *i,
     oggpack_write(&vb->opb,amp,info->ampbits);
     bitbuf_pack(&vb->opb,vbb);
     return(fromdB((float)adj/maxval*info->ampdB));
-  }
+  }else{
+    oggpack_write(&vb->opb,0,info->ampbits);
+    bitbuf_pack(&vb->opb,vbb);
+  }    
   return(0.);
 }
 
index 64e7b48..fb2db36 100644 (file)
@@ -12,7 +12,7 @@
  ********************************************************************
 
  function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.20 2000/11/17 11:47:18 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.21 2000/12/12 08:54:27 xiphmont Exp $
 
  ********************************************************************/
 
@@ -332,7 +332,6 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
        massaging things before we write out the final version. */
 
     {
-      static int seq=0;
       for(i=0;i<vi->channels;i++){
        float *pcm=vb->pcm[i];
        float *pcmori=vb->pcm[i]+n/2;
@@ -342,7 +341,7 @@ static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
        int submap=info->chmuxlist[i];
        
        if(nonzero[i]){
-         
+
          for(j=0;j<n/2;j++)
            pcm[j]=pcmori[j]-pcm[j]*quant[j];