[01/23] vp9: ignore reference segmentation map if error_resilience flag is set.

Message ID 1475436610-25770-1-git-send-email-anton@khirnov.net
State Committed
Commit a451324dddf5d2ab4bcd6aa0f546596f71bdada3
Headers show

Commit Message

Anton Khirnov Oct. 2, 2016, 7:29 p.m.
From: "Ronald S. Bultje" <rsbultje@gmail.com>

Fixes ffvp9_fails_where_libvpx.succeeds.webm.

Bug-Id: ffmpeg/3849.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
---
 libavcodec/vp9.c      |  2 +-
 libavcodec/vp9block.c | 28 ++++++++++++++++------------
 2 files changed, 17 insertions(+), 13 deletions(-)

Comments

Martin Storsjö Oct. 2, 2016, 7:43 p.m. | #1
On Sun, 2 Oct 2016, Anton Khirnov wrote:

> From: "Ronald S. Bultje" <rsbultje@gmail.com>
>
> Fixes ffvp9_fails_where_libvpx.succeeds.webm.
>
> Bug-Id: ffmpeg/3849.
>
> Signed-off-by: Anton Khirnov <anton@khirnov.net>
> ---
> libavcodec/vp9.c      |  2 +-
> libavcodec/vp9block.c | 28 ++++++++++++++++------------
> 2 files changed, 17 insertions(+), 13 deletions(-)

LGTM, thanks

// Martin

Patch

diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 32d995f..9062185 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -64,7 +64,7 @@  static int vp9_frame_alloc(AVCodecContext *avctx, VP9Frame *f)
     f->mv               = (VP9MVRefPair*)f->mv_buf->data;
 
     if (s->segmentation.enabled && !s->segmentation.update_map &&
-        !s->keyframe && !s->intraonly)
+        !s->keyframe && !s->intraonly && !s->errorres)
         memcpy(f->segmentation_map, s->frames[LAST_FRAME].segmentation_map, sz);
 
     return 0;
diff --git a/libavcodec/vp9block.c b/libavcodec/vp9block.c
index 9b0d836..cd40c38 100644
--- a/libavcodec/vp9block.c
+++ b/libavcodec/vp9block.c
@@ -70,18 +70,22 @@  static void decode_mode(VP9Context *s, VP9Block *const b)
                 vp56_rac_get_prob_branchy(&s->c,
                                           s->prob.segpred[s->above_segpred_ctx[col] +
                                                           s->left_segpred_ctx[row7]]))) {
-        uint8_t *refsegmap = s->frames[LAST_FRAME].segmentation_map;
-        int pred = MAX_SEGMENT - 1;
-        int x;
-
-        if (!s->last_uses_2pass)
-            ff_thread_await_progress(&s->frames[LAST_FRAME].tf, row >> 3, 0);
-
-        for (y = 0; y < h4; y++)
-            for (x = 0; x < w4; x++)
-                pred = FFMIN(pred,
-                             refsegmap[(y + row) * 8 * s->sb_cols + x + col]);
-        b->seg_id = pred;
+        if (!s->errorres) {
+            uint8_t *refsegmap = s->frames[LAST_FRAME].segmentation_map;
+            int pred = MAX_SEGMENT - 1;
+            int x;
+
+            if (!s->last_uses_2pass)
+                ff_thread_await_progress(&s->frames[LAST_FRAME].tf, row >> 3, 0);
+
+            for (y = 0; y < h4; y++)
+                for (x = 0; x < w4; x++)
+                    pred = FFMIN(pred,
+                                 refsegmap[(y + row) * 8 * s->sb_cols + x + col]);
+            b->seg_id = pred;
+        } else {
+            b->seg_id = 0;
+        }
 
         memset(&s->above_segpred_ctx[col], 1, w4);
         memset(&s->left_segpred_ctx[row7], 1, h4);