wmaenc: fix m/s stereo encoding for the first frame
authorJustin Ruggles <justin.ruggles@gmail.com>
Fri, 2 Mar 2012 22:11:25 +0000 (17:11 -0500)
committerJustin Ruggles <justin.ruggles@gmail.com>
Sat, 3 Mar 2012 23:20:10 +0000 (18:20 -0500)
We need to set ms_stereo in encode_init() in order to avoid incorrectly
encoding the first frame as non-m/s while flagging it as m/s. Fixes an
uncomfortable pop in the left channel at the start of playback.

CC:libav-stable@libav.org

libavcodec/wmaenc.c
tests/ref/acodec/wmav1
tests/ref/acodec/wmav2

index 789f112..6fd3494 100644 (file)
@@ -70,6 +70,8 @@ static int encode_init(AVCodecContext * avctx){
     s->use_exp_vlc = flags2 & 0x0001;
     s->use_bit_reservoir = flags2 & 0x0002;
     s->use_variable_block_len = flags2 & 0x0004;
+    if (avctx->channels == 2)
+        s->ms_stereo = 1;
 
     ff_wma_init(avctx, flags2);
 
@@ -191,7 +193,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
     }
 
     if (s->nb_channels == 2) {
-        put_bits(&s->pb, 1, s->ms_stereo= 1);
+        put_bits(&s->pb, 1, !!s->ms_stereo);
     }
 
     for(ch = 0; ch < s->nb_channels; ch++) {
index 916e4a8..117aa12 100644 (file)
@@ -1,4 +1,4 @@
-26a7f6b0f0b7181df8df3fa589f6bf81 *./tests/data/acodec/wmav1.asf
+0260385b8a54df11ad349f9ba8240fd8 *./tests/data/acodec/wmav1.asf
 106004 ./tests/data/acodec/wmav1.asf
-stddev:12245.52 PSNR: 14.57 MAXDIFF:65521 bytes:  1064960/  1058400
-stddev: 2095.89 PSNR: 29.90 MAXDIFF:27658 bytes:  1056768/  1058400
+stddev:12241.90 PSNR: 14.57 MAXDIFF:65521 bytes:  1064960/  1058400
+stddev: 2074.79 PSNR: 29.99 MAXDIFF:27658 bytes:  1056768/  1058400
index 622b6fc..43b19b7 100644 (file)
@@ -1,4 +1,4 @@
-7c6c0cb692af01b312ae345723674b5f *./tests/data/acodec/wmav2.asf
+bdb4c312fb109f990be83a70f8ec9bdc *./tests/data/acodec/wmav2.asf
 106044 ./tests/data/acodec/wmav2.asf
-stddev:12249.93 PSNR: 14.57 MAXDIFF:65521 bytes:  1064960/  1058400
-stddev: 2089.21 PSNR: 29.93 MAXDIFF:27650 bytes:  1056768/  1058400
+stddev:12246.35 PSNR: 14.57 MAXDIFF:65521 bytes:  1064960/  1058400
+stddev: 2068.08 PSNR: 30.02 MAXDIFF:27650 bytes:  1056768/  1058400