vp9: fix mvref finding to adhere to bug in libvpx.
authorRonald S. Bultje <rsbultje@gmail.com>
Sat, 9 Nov 2013 15:52:49 +0000 (10:52 -0500)
committerClément Bœsch <u@pkh.me>
Sat, 9 Nov 2013 20:31:06 +0000 (21:31 +0100)
Fixes a particular youtube video that I unfortunately can't share.

libavcodec/vp9.c

index 3539a54..d26f122 100644 (file)
@@ -984,7 +984,10 @@ static void find_ref_mvs(VP9Context *s,
             if (mv->ref[0] != ref && mv->ref[0] >= 0) {
                 RETURN_SCALE_MV(mv->mv[0], s->signbias[mv->ref[0]] != s->signbias[ref]);
             }
-            if (mv->ref[1] != ref && mv->ref[1] >= 0) {
+            if (mv->ref[1] != ref && mv->ref[1] >= 0 &&
+                // BUG - libvpx has this condition regardless of whether
+                // we used the first ref MV and pre-scaling
+                AV_RN32A(&mv->mv[0]) != AV_RN32A(&mv->mv[1])) {
                 RETURN_SCALE_MV(mv->mv[1], s->signbias[mv->ref[1]] != s->signbias[ref]);
             }
         }
@@ -997,7 +1000,10 @@ static void find_ref_mvs(VP9Context *s,
         if (mv->ref[0] != ref && mv->ref[0] >= 0) {
             RETURN_SCALE_MV(mv->mv[0], s->signbias[mv->ref[0]] != s->signbias[ref]);
         }
-        if (mv->ref[1] != ref && mv->ref[1] >= 0) {
+        if (mv->ref[1] != ref && mv->ref[1] >= 0 &&
+            // BUG - libvpx has this condition regardless of whether
+            // we used the first ref MV and pre-scaling
+            AV_RN32A(&mv->mv[0]) != AV_RN32A(&mv->mv[1])) {
             RETURN_SCALE_MV(mv->mv[1], s->signbias[mv->ref[1]] != s->signbias[ref]);
         }
     }