[FFmpeg-cvslog] avcodec/h264dsp_template: Fix undefined shift in biweight_h264_pixels and weight_h264_pixels

Michael Niedermayer git at videolan.org
Wed Mar 11 18:59:05 CET 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Mar 11 18:49:57 2015 +0100| [c756b3fca240df75ffa28e75f2eb34834c10294d] | committer: Michael Niedermayer

avcodec/h264dsp_template: Fix undefined shift in biweight_h264_pixels and weight_h264_pixels

Found-by: Clang -fsanitize=shift
Reported-by: Thierry Foucu <tfoucu at google.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c756b3fca240df75ffa28e75f2eb34834c10294d
---

 libavcodec/h264dsp_template.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/h264dsp_template.c b/libavcodec/h264dsp_template.c
index 4d5faf0..4b42af7 100644
--- a/libavcodec/h264dsp_template.c
+++ b/libavcodec/h264dsp_template.c
@@ -36,7 +36,7 @@ static void FUNCC(weight_h264_pixels ## W)(uint8_t *_block, int stride, int heig
     int y; \
     pixel *block = (pixel*)_block; \
     stride >>= sizeof(pixel)-1; \
-    offset <<= (log2_denom + (BIT_DEPTH-8)); \
+    offset = (unsigned)offset << (log2_denom + (BIT_DEPTH-8)); \
     if(log2_denom) offset += 1<<(log2_denom-1); \
     for (y = 0; y < height; y++, block += stride) { \
         op_scale1(0); \
@@ -67,8 +67,8 @@ static void FUNCC(biweight_h264_pixels ## W)(uint8_t *_dst, uint8_t *_src, int s
     pixel *dst = (pixel*)_dst; \
     pixel *src = (pixel*)_src; \
     stride >>= sizeof(pixel)-1; \
-    offset <<= (BIT_DEPTH-8); \
-    offset = ((offset + 1) | 1) << log2_denom; \
+    offset = (unsigned)offset << (BIT_DEPTH-8); \
+    offset = (unsigned)((offset + 1) | 1) << log2_denom; \
     for (y = 0; y < height; y++, dst += stride, src += stride) { \
         op_scale2(0); \
         op_scale2(1); \



More information about the ffmpeg-cvslog mailing list