diff mbox

[FFmpeg-devel,1/2] avcodec/vc1: shuffle calculation of MV predictor candidates

Message ID b7919d5b-7edd-467e-b48b-d56c57bd9eaf@carpalis.nl
State Accepted
Commit 96740ec69f272ad2364175656590a908b9e98a6c
Headers show

Commit Message

Jerome Borsboom Jan. 11, 2019, 2:36 p.m. UTC
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 patch set fixes the decoding artifacts in the niceday.wmv file
on the samples server.

 libavcodec/vc1_pred.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Carl Eugen Hoyos Jan. 12, 2019, 3:50 p.m. UTC | #1
2019-01-11 15:36 GMT+01:00, Jerome Borsboom <jerome.borsboom@carpalis.nl>:
> The B predictor for 4-MV macroblocks is only out of bounds when
> the A predictor is also out of bounds.

Patch applied.

Thank you, Carl Eugen
diff mbox

Patch

diff --git a/libavcodec/vc1_pred.c b/libavcodec/vc1_pred.c
index de736ec775..0b22d9916c 100644
--- a/libavcodec/vc1_pred.c
+++ b/libavcodec/vc1_pred.c
@@ -262,13 +262,15 @@  void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y,
         return;
     }
 
-    C = s->current_picture.motion_val[dir][xy -    1 + v->blocks_off];
-    A = s->current_picture.motion_val[dir][xy - wrap + v->blocks_off];
+    a_valid = !s->first_slice_line || (n == 2 || n == 3);
+    b_valid = a_valid;
+    c_valid = s->mb_x || (n == 1 || n == 3);
     if (mv1) {
         if (v->field_mode && mixedmv_pic)
             off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2;
         else
             off = (s->mb_x == (s->mb_width - 1)) ? -1 : 2;
+        b_valid = b_valid && s->mb_width > 1;
     } else {
         //in 4-MV mode different blocks have different B predictor position
         switch (n) {
@@ -285,11 +287,7 @@  void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y,
             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) {
         a_valid = a_valid && !is_intra[xy - wrap];
         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) {
+        A = s->current_picture.motion_val[dir][xy - wrap + v->blocks_off];
         a_f = v->mv_f[dir][xy - wrap + v->blocks_off];
         num_oppfield  += 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;
     }
     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];
         num_oppfield  += 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;
     }
     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];
         num_oppfield  += c_f;
         num_samefield += 1 - c_f;