avcodec/vc1: shuffle calculation of MV predictor candidates

The B predictor for 4-MV macroblocks is only out of bounds when
the A predictor is also out of bounds.

Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
This commit is contained in:
Jerome Borsboom 2019-01-11 15:36:47 +01:00 committed by Carl Eugen Hoyos
parent f4fd8ef725
commit 96740ec69f
1 changed files with 7 additions and 6 deletions

View File

@ -262,13 +262,15 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y,
return; return;
} }
C = s->current_picture.motion_val[dir][xy - 1 + v->blocks_off]; a_valid = !s->first_slice_line || (n == 2 || n == 3);
A = s->current_picture.motion_val[dir][xy - wrap + v->blocks_off]; b_valid = a_valid;
c_valid = s->mb_x || (n == 1 || n == 3);
if (mv1) { if (mv1) {
if (v->field_mode && mixedmv_pic) if (v->field_mode && mixedmv_pic)
off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2; off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2;
else else
off = (s->mb_x == (s->mb_width - 1)) ? -1 : 2; off = (s->mb_x == (s->mb_width - 1)) ? -1 : 2;
b_valid = b_valid && s->mb_width > 1;
} else { } else {
//in 4-MV mode different blocks have different B predictor position //in 4-MV mode different blocks have different B predictor position
switch (n) { switch (n) {
@ -285,11 +287,7 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y,
off = -1; off = -1;
} }
} }
B = s->current_picture.motion_val[dir][xy - wrap + off + v->blocks_off];
a_valid = !s->first_slice_line || (n == 2 || n == 3);
b_valid = a_valid && (s->mb_width > 1);
c_valid = s->mb_x || (n == 1 || n == 3);
if (v->field_mode) { if (v->field_mode) {
a_valid = a_valid && !is_intra[xy - wrap]; a_valid = a_valid && !is_intra[xy - wrap];
b_valid = b_valid && !is_intra[xy - wrap + off]; b_valid = b_valid && !is_intra[xy - wrap + off];
@ -297,6 +295,7 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y,
} }
if (a_valid) { if (a_valid) {
A = s->current_picture.motion_val[dir][xy - wrap + v->blocks_off];
a_f = v->mv_f[dir][xy - wrap + v->blocks_off]; a_f = v->mv_f[dir][xy - wrap + v->blocks_off];
num_oppfield += a_f; num_oppfield += a_f;
num_samefield += 1 - a_f; num_samefield += 1 - a_f;
@ -307,6 +306,7 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y,
a_f = 0; a_f = 0;
} }
if (b_valid) { if (b_valid) {
B = s->current_picture.motion_val[dir][xy - wrap + off + v->blocks_off];
b_f = v->mv_f[dir][xy - wrap + off + v->blocks_off]; b_f = v->mv_f[dir][xy - wrap + off + v->blocks_off];
num_oppfield += b_f; num_oppfield += b_f;
num_samefield += 1 - b_f; num_samefield += 1 - b_f;
@ -317,6 +317,7 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y,
b_f = 0; b_f = 0;
} }
if (c_valid) { if (c_valid) {
C = s->current_picture.motion_val[dir][xy - 1 + v->blocks_off];
c_f = v->mv_f[dir][xy - 1 + v->blocks_off]; c_f = v->mv_f[dir][xy - 1 + v->blocks_off];
num_oppfield += c_f; num_oppfield += c_f;
num_samefield += 1 - c_f; num_samefield += 1 - c_f;