From fe2244ae2542103b4bbab6ae13e1185aba620014 Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 12 Dec 2000 08:54:27 +0000 Subject: [PATCH 1/1] Fix a bug in the post-encode normalization; 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 | 4 ++-- lib/floor0.c | 11 +++++++---- lib/mapping0.c | 5 ++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/encoder_example.c b/examples/encoder_example.c index f9280fb..5da7422 100644 --- a/examples/encoder_example.c +++ b/examples/encoder_example.c @@ -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); diff --git a/lib/floor0.c b/lib/floor0.c index 0e454c4..e0b6842 100644 --- a/lib/floor0.c +++ b/lib/floor0.c @@ -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<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.); } diff --git a/lib/mapping0.c b/lib/mapping0.c index 64e7b48..fb2db36 100644 --- a/lib/mapping0.c +++ b/lib/mapping0.c @@ -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;ichannels;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