avcodec/mpegaudioenc: prevent overflow in fixed point code
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 17 Nov 2013 20:14:15 +0000 (21:14 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 17 Nov 2013 20:14:15 +0000 (21:14 +0100)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/mpegaudioenc.c

index 0054019..133c9dc 100644 (file)
@@ -704,6 +704,8 @@ static void encode_frame(MpegAudioContext *s,
                                     q1 = sample >> shift;
                                 q1 = (q1 * mult) >> P;
                                 q[m] = ((q1 + (1 << P)) * steps) >> (P + 1);
+                                if (q[m] < 0)
+                                    q[m] = 0;
                             }
 #endif
                             if (q[m] >= steps)