]> git.sesse.net Git - ffmpeg/commitdiff
opusenc: fix coarse energy quantization with 2 bits left
authorRostislav Pehlivanov <atomnuker@gmail.com>
Wed, 15 Feb 2017 22:51:37 +0000 (22:51 +0000)
committerRostislav Pehlivanov <atomnuker@gmail.com>
Wed, 15 Feb 2017 22:51:37 +0000 (22:51 +0000)
Fixes CID1400584

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
libavcodec/opusenc.c

index 985b41ccc059ef15d0b9cf4faebf0957ce7bc8bd..1a829ed11a4927318fe6964468f07d2287e0c449 100644 (file)
@@ -667,7 +667,7 @@ static void celt_quant_coarse(OpusEncContext *s, OpusRangeCoder *rc, CeltFrame *
                 ff_opus_rc_enc_laplace(rc, &q_en, pmod[i << 1] << 7, pmod[(i << 1) + 1] << 6);
             } else if (left >= 2) {
                 q_en = av_clip(q_en, -1, 1);
-                ff_opus_rc_enc_cdf(rc, ((q_en & 1) << 1) | (q_en < 0), ff_celt_model_energy_small);
+                ff_opus_rc_enc_cdf(rc, 2*q_en + 3*(q_en < 0), ff_celt_model_energy_small);
             } else if (left >= 1) {
                 q_en = av_clip(q_en, -1, 0);
                 ff_opus_rc_enc_log(rc, (q_en & 1), 1);