Commit 44841528 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/mpegaudioenc_template: reorder operations to prevent integer overflow

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 9d66aa2c
......@@ -700,9 +700,10 @@ static void encode_frame(MpegAudioContext *s,
else
q1 = sample >> shift;
q1 = (q1 * mult) >> P;
q[m] = ((q1 + (1 << P)) * steps) >> (P + 1);
if (q[m] < 0)
q[m] = 0;
q1 += 1 << P;
if (q1 < 0)
q1 = 0;
q[m] = (unsigned)(q1 * steps) >> (P + 1);
}
#endif
if (q[m] >= steps)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment