avcodec/flacenc: fix calculation of bits required in case of custom sample rate
authorPaul B Mahol <onemda@gmail.com>
Sun, 24 Jan 2016 19:47:49 +0000 (20:47 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 1 Feb 2016 01:12:22 +0000 (02:12 +0100)
Sample rate of 11025 takes 16 bits but previous code would pick only 8.
Fixes assertion failure.

Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
(cherry picked from commit 3e7d6849120d61bb354376d52786c26f20e20835)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/flacenc.c

index 3b72888..6ad6fd2 100644 (file)
@@ -916,7 +916,7 @@ static int count_frame_header(FlacEncodeContext *s)
         count += 16;
 
     /* explicit sample rate */
-    count += ((s->sr_code[0] == 12) + (s->sr_code[0] > 12)) * 8;
+    count += ((s->sr_code[0] == 12) + (s->sr_code[0] > 12) * 2) * 8;
 
     /* frame header CRC-8 */
     count += 8;