diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-03-17 01:51:59 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-03-17 01:51:59 +0100 |
commit | d24af7044d6ec0d22f1d6fac8fab41a6ab9a8211 (patch) | |
tree | 4308ca3371ac5dc1e73ce7df93a0babf7794cdfa | |
parent | b17620b81bc1c4562a760f24be83bc13a3f42bd5 (diff) | |
download | ffmpeg-d24af7044d6ec0d22f1d6fac8fab41a6ab9a8211.tar.gz |
avcodec/vc1_pred: Fix undefined shifts
Found-by: Clang -fsanitize=shift
Reported-by: Thierry Foucu <tfoucu@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/vc1_pred.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/libavcodec/vc1_pred.c b/libavcodec/vc1_pred.c index 35c75abd83..13134e5d8a 100644 --- a/libavcodec/vc1_pred.c +++ b/libavcodec/vc1_pred.c @@ -170,9 +170,9 @@ static av_always_inline int scaleforsame(VC1Context *v, int i, int n /* MV */, n >>= hpel; if (v->s.pict_type != AV_PICTURE_TYPE_B || v->second_field || !dir) { if (dim) - n = scaleforsame_y(v, i, n, dir) << hpel; + n = scaleforsame_y(v, i, n, dir) * (1 << hpel); else - n = scaleforsame_x(v, n, dir) << hpel; + n = scaleforsame_x(v, n, dir) * (1 << hpel); return n; } brfd = FFMIN(v->brfd, 3); @@ -202,7 +202,7 @@ static av_always_inline int scaleforopp(VC1Context *v, int n /* MV */, refdist = dir ? v->brfd : v->frfd; scaleopp = ff_vc1_field_mvpred_scales[dir ^ v->second_field][0][refdist]; - n = (n * scaleopp >> 8) << hpel; + n = (n * scaleopp >> 8) * (1 << hpel); return n; } @@ -697,10 +697,12 @@ void ff_vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], r_x = v->range_x; r_y = v->range_y; /* scale MV difference to be quad-pel */ - dmv_x[0] <<= 1 - s->quarter_sample; - dmv_y[0] <<= 1 - s->quarter_sample; - dmv_x[1] <<= 1 - s->quarter_sample; - dmv_y[1] <<= 1 - s->quarter_sample; + if (!s->quarter_sample) { + dmv_x[0] *= 2; + dmv_y[0] *= 2; + dmv_x[1] *= 2; + dmv_y[1] *= 2; + } wrap = s->b8_stride; xy = s->block_index[0]; |