diff options
author | Katerina Barone-Adesi <katerinab@gmail.com> | 2014-05-19 17:27:52 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-05-20 04:21:06 +0200 |
commit | e50ae60d46181814245f70b61b70394311e10373 (patch) | |
tree | 84197bc05af463440414de72ca6620299e564586 /libavcodec/jfdctint_template.c | |
parent | 7d25af1547f8d97231f1c6e4cab7ad2bbf1dd071 (diff) | |
download | ffmpeg-e50ae60d46181814245f70b61b70394311e10373.tar.gz |
avcodec/fate-idct8x8: Defined behavior: eliminate negative left-shifts.
The original code left-shifts negative values, which is undefined
in the C99 specification (the one used during normal FFmpeg compilation).
This change multiplies by (1 << shift), which is functionally equivalent,
but has defined behavior.
With this change, fate-idct8x8 compiled with --fsanitize=undefined works.
Bug-Id: 686
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
The assembly generated by gcc is unchanged by this commit
Diffstat (limited to 'libavcodec/jfdctint_template.c')
-rw-r--r-- | libavcodec/jfdctint_template.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libavcodec/jfdctint_template.c b/libavcodec/jfdctint_template.c index c6a1638107..3ea2f5dadc 100644 --- a/libavcodec/jfdctint_template.c +++ b/libavcodec/jfdctint_template.c @@ -216,8 +216,8 @@ static av_always_inline void FUNC(row_fdct)(int16_t *data) tmp11 = tmp1 + tmp2; tmp12 = tmp1 - tmp2; - dataptr[0] = (int16_t) ((tmp10 + tmp11) << PASS1_BITS); - dataptr[4] = (int16_t) ((tmp10 - tmp11) << PASS1_BITS); + dataptr[0] = (int16_t) ((tmp10 + tmp11) * (1 << PASS1_BITS)); + dataptr[4] = (int16_t) ((tmp10 - tmp11) * (1 << PASS1_BITS)); z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); dataptr[2] = (int16_t) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), |