aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-07-01 12:16:37 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-07-01 12:21:56 +0200
commit56fd4705c0496bc108ac84c03465d33351d366a5 (patch)
treeae33ebeb119aab5035d8d1016aa597a83bd58923
parent2f8c81637c47a70b8e06e1bb9877d6f9c058ee2a (diff)
downloadffmpeg-56fd4705c0496bc108ac84c03465d33351d366a5.tar.gz
avcodec/motion_est_template: Fix undefined shifts in CHECK_MV_DIR()
Fixes: signal_sigsegv_2e64ee0_2762_cov_4170502227_missing_frames.avi Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/motion_est_template.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c
index ae2cbdea4d..cb8780160b 100644
--- a/libavcodec/motion_est_template.c
+++ b/libavcodec/motion_est_template.c
@@ -384,13 +384,13 @@ static int qpel_motion_search(MpegEncContext * s,
#define CHECK_MV_DIR(x,y,new_dir)\
{\
- const unsigned key = ((y)<<ME_MAP_MV_BITS) + (x) + map_generation;\
- const int index= (((y)<<ME_MAP_SHIFT) + (x))&(ME_MAP_SIZE-1);\
+ const unsigned key = ((unsigned)(y)<<ME_MAP_MV_BITS) + (x) + map_generation;\
+ const int index= (((unsigned)(y)<<ME_MAP_SHIFT) + (x))&(ME_MAP_SIZE-1);\
if(map[index]!=key){\
d= cmp(s, x, y, 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);\
map[index]= key;\
score_map[index]= d;\
- d += (mv_penalty[((x)<<shift)-pred_x] + mv_penalty[((y)<<shift)-pred_y])*penalty_factor;\
+ d += (mv_penalty[(int)((unsigned)(x)<<shift)-pred_x] + mv_penalty[(int)((unsigned)(y)<<shift)-pred_y])*penalty_factor;\
if(d<dmin){\
best[0]=x;\
best[1]=y;\