summaryrefslogtreecommitdiff
path: root/libavcodec/vc1dsp.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-03-01 19:18:34 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-03-01 19:35:12 +0100
commit80c702efeb7b4d9edaae52ed5d8dd081a2ccb64b (patch)
tree9c998edebc247bf727a8b2b375c15377bbc301b0 /libavcodec/vc1dsp.c
parentaf796ba4b827a88912f9a9c59d1a57704a6fff38 (diff)
downloadffmpeg-80c702efeb7b4d9edaae52ed5d8dd081a2ccb64b.tar.gz
vc1: fix out of array reads in vc1_inv_trans_4x8_c()
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/vc1dsp.c')
-rw-r--r--libavcodec/vc1dsp.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/libavcodec/vc1dsp.c b/libavcodec/vc1dsp.c
index 636c82b8f3..d893d692b4 100644
--- a/libavcodec/vc1dsp.c
+++ b/libavcodec/vc1dsp.c
@@ -421,7 +421,6 @@ static void vc1_inv_trans_4x8_c(uint8_t *dest, int linesize, DCTELEM *block)
int i;
register int t1,t2,t3,t4,t5,t6,t7,t8;
DCTELEM *src, *dst;
- const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
src = block;
dst = block;
@@ -457,14 +456,14 @@ static void vc1_inv_trans_4x8_c(uint8_t *dest, int linesize, DCTELEM *block)
t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56];
t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56];
- dest[0*linesize] = cm[dest[0*linesize] + ((t5 + t1) >> 7)];
- dest[1*linesize] = cm[dest[1*linesize] + ((t6 + t2) >> 7)];
- dest[2*linesize] = cm[dest[2*linesize] + ((t7 + t3) >> 7)];
- dest[3*linesize] = cm[dest[3*linesize] + ((t8 + t4) >> 7)];
- dest[4*linesize] = cm[dest[4*linesize] + ((t8 - t4 + 1) >> 7)];
- dest[5*linesize] = cm[dest[5*linesize] + ((t7 - t3 + 1) >> 7)];
- dest[6*linesize] = cm[dest[6*linesize] + ((t6 - t2 + 1) >> 7)];
- dest[7*linesize] = cm[dest[7*linesize] + ((t5 - t1 + 1) >> 7)];
+ dest[0*linesize] = av_clip_uint8(dest[0*linesize] + ((t5 + t1) >> 7));
+ dest[1*linesize] = av_clip_uint8(dest[1*linesize] + ((t6 + t2) >> 7));
+ dest[2*linesize] = av_clip_uint8(dest[2*linesize] + ((t7 + t3) >> 7));
+ dest[3*linesize] = av_clip_uint8(dest[3*linesize] + ((t8 + t4) >> 7));
+ dest[4*linesize] = av_clip_uint8(dest[4*linesize] + ((t8 - t4 + 1) >> 7));
+ dest[5*linesize] = av_clip_uint8(dest[5*linesize] + ((t7 - t3 + 1) >> 7));
+ dest[6*linesize] = av_clip_uint8(dest[6*linesize] + ((t6 - t2 + 1) >> 7));
+ dest[7*linesize] = av_clip_uint8(dest[7*linesize] + ((t5 - t1 + 1) >> 7));
src ++;
dest++;