]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/proresenc_anatoliy: Fix invalid left shift of negative number
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 8 Jan 2020 18:29:13 +0000 (19:29 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 8 Jan 2020 19:32:14 +0000 (20:32 +0100)
This fixes ticket #7997 as well as the vsynth*-prores_# FATE-tests
(where * ranges over { 1, 2, 3, _lena } and # over { , _int, _444,
_444_int }).

(Given that prev_dc is in the range -0xC000..0x3FFF, no overflow can
happen upon multiplication with 2.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/proresenc_anatoliy.c

index 0fc79fc1dead14c99a77e25cfc9aed6b3782e681..1fcb0ae913b82412a501e6dbf3ad47c056af3e58 100644 (file)
@@ -224,7 +224,7 @@ static void encode_codeword(PutBitContext *pb, int val, int codebook)
 }
 
 #define QSCALE(qmat,ind,val) ((val) / ((qmat)[ind]))
-#define TO_GOLOMB(val) (((val) << 1) ^ ((val) >> 31))
+#define TO_GOLOMB(val) (((val) * 2) ^ ((val) >> 31))
 #define DIFF_SIGN(val, sign) (((val) >> 31) ^ (sign))
 #define IS_NEGATIVE(val) ((((val) >> 31) ^ -1) + 1)
 #define TO_GOLOMB2(val,sign) ((val)==0 ? 0 : ((val) << 1) + (sign))