aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2015-03-06 21:07:54 -0500
committerMichael Niedermayer <michaelni@gmx.at>2015-03-07 10:38:07 +0100
commit1caad745333c0477edbb3ef873612165f4455026 (patch)
tree7e10ddad2bfbe849ba5bd7990ae8ce2c940c0d62
parent28950d1f8ccb2d4925004dc3f4dc5399f9fd0101 (diff)
downloadffmpeg-1caad745333c0477edbb3ef873612165f4455026.tar.gz
vp9: fix segmentation map retention with threading enabled.
Fixes ticket 4359. Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit efff3854f05d171f5ad3e4f4206533b255a6d267) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/vp9.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index c7f351bdd7..b25409f281 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -279,7 +279,8 @@ static int vp9_alloc_frame(AVCodecContext *ctx, VP9Frame *f)
// retain segmentation map if it doesn't update
if (s->segmentation.enabled && !s->segmentation.update_map &&
- !s->intraonly && !s->keyframe && !s->errorres) {
+ !s->intraonly && !s->keyframe && !s->errorres &&
+ ctx->active_thread_type != FF_THREAD_FRAME) {
memcpy(f->segmentation_map, s->frames[LAST_FRAME].segmentation_map, sz);
}
@@ -1351,9 +1352,18 @@ static void decode_mode(AVCodecContext *ctx)
if (!s->last_uses_2pass)
ff_thread_await_progress(&s->frames[LAST_FRAME].tf, row >> 3, 0);
- for (y = 0; y < h4; y++)
+ for (y = 0; y < h4; y++) {
+ int idx_base = (y + row) * 8 * s->sb_cols + col;
for (x = 0; x < w4; x++)
- pred = FFMIN(pred, refsegmap[(y + row) * 8 * s->sb_cols + x + col]);
+ pred = FFMIN(pred, refsegmap[idx_base + x]);
+ if (!s->segmentation.update_map && ctx->active_thread_type == FF_THREAD_FRAME) {
+ // FIXME maybe retain reference to previous frame as
+ // segmap reference instead of copying the whole map
+ // into a new buffer
+ memcpy(&s->frames[CUR_FRAME].segmentation_map[idx_base],
+ &refsegmap[idx_base], w4);
+ }
+ }
av_assert1(pred < 8);
b->seg_id = pred;
} else {