Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGanesh Ajjanagadde <gajjanagadde@gmail.com>2015-10-09 22:59:04 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2015-10-10 15:43:22 +0300
commit979572365f2133f969f3f49ec6a99cc8739d2eba (patch)
treef88ea2f8fedeb946846af5d9219bdca8f91b4db8 /libavcodec/ac3enc.c
parentc4e23ca8537701a38427f90b2dd72eb681d011d6 (diff)
avcodec/ac3enc: fix undefined negative left shift
This should fix the undefined behavior reported in: https://trac.ffmpeg.org/ticket/4727. I can reproduce this at runtime: simply stick in an abort call in asym_quant to check if c < 0 and run FATE. I don't know ac3 so I can't confirm if negative coefficients are intentional, but at the moment they clearly are according to FATE. This resolves the undefined behavior. Tested with FATE. Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/ac3enc.c')
-rw-r--r--libavcodec/ac3enc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 35e721a964..c8a0caa194 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1183,7 +1183,7 @@ static inline int asym_quant(int c, int e, int qbits)
{
int m;
- c = (((c << e) >> (24 - qbits)) + 1) >> 1;
+ c = (((c * (1<<e)) >> (24 - qbits)) + 1) >> 1;
m = (1 << (qbits-1));
if (c >= m)
c = m - 1;