summaryrefslogtreecommitdiff
path: root/libavcodec/vp9block.c
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2013-11-23 10:27:18 -0500
committerAnton Khirnov <anton@khirnov.net>2016-08-11 10:53:13 +0200
commitbc6e0b64a9100652c1ce52292408d8fd79930d53 (patch)
tree819bbbfbe70acbd0196f55c10e4dc5bb57ae15aa /libavcodec/vp9block.c
parent04763c6f87690b31cfcd0d324cf36a451531dcd0 (diff)
vp9: split last/cur_frame from the reference buffers.
We need more information from last/cur_frame than from reference buffers, so we can use a simplified structure for reference buffers, and then store mvs and segmentation map information in last/cur. This prepares the decoder for frame threading support. Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavcodec/vp9block.c')
-rw-r--r--libavcodec/vp9block.c74
1 files changed, 42 insertions, 32 deletions
diff --git a/libavcodec/vp9block.c b/libavcodec/vp9block.c
index f5f7256424..c018fa0310 100644
--- a/libavcodec/vp9block.c
+++ b/libavcodec/vp9block.c
@@ -70,13 +70,14 @@ 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;
for (y = 0; y < h4; y++)
for (x = 0; x < w4; x++)
pred = FFMIN(pred,
- s->segmentation_map[(y + row) * 8 * s->sb_cols + x + col]);
+ refsegmap[(y + row) * 8 * s->sb_cols + x + col]);
b->seg_id = pred;
memset(&s->above_segpred_ctx[col], 1, w4);
@@ -89,8 +90,10 @@ static void decode_mode(VP9Context *s, VP9Block *const b)
memset(&s->left_segpred_ctx[row7], 0, h4);
}
if ((s->segmentation.enabled && s->segmentation.update_map) || s->keyframe) {
+ uint8_t *segmap = s->frames[CUR_FRAME].segmentation_map;
+
for (y = 0; y < h4; y++)
- memset(&s->segmentation_map[(y + row) * 8 * s->sb_cols + col],
+ memset(&segmap[(y + row) * 8 * s->sb_cols + col],
b->seg_id, w4);
}
@@ -684,24 +687,25 @@ static void decode_mode(VP9Context *s, VP9Block *const b)
// FIXME kinda ugly
for (y = 0; y < h4; y++) {
int x, o = (row + y) * s->sb_cols * 8 + col;
+ VP9MVRefPair *mv = &s->frames[CUR_FRAME].mv[o];
if (b->intra) {
for (x = 0; x < w4; x++) {
- s->mv[0][o + x].ref[0] =
- s->mv[0][o + x].ref[1] = -1;
+ mv[x].ref[0] =
+ mv[x].ref[1] = -1;
}
} else if (b->comp) {
for (x = 0; x < w4; x++) {
- s->mv[0][o + x].ref[0] = b->ref[0];
- s->mv[0][o + x].ref[1] = b->ref[1];
- AV_COPY32(&s->mv[0][o + x].mv[0], &b->mv[3][0]);
- AV_COPY32(&s->mv[0][o + x].mv[1], &b->mv[3][1]);
+ mv[x].ref[0] = b->ref[0];
+ mv[x].ref[1] = b->ref[1];
+ AV_COPY32(&mv[x].mv[0], &b->mv[3][0]);
+ AV_COPY32(&mv[x].mv[1], &b->mv[3][1]);
}
} else {
for (x = 0; x < w4; x++) {
- s->mv[0][o + x].ref[0] = b->ref[0];
- s->mv[0][o + x].ref[1] = -1;
- AV_COPY32(&s->mv[0][o + x].mv[0], &b->mv[3][0]);
+ mv[x].ref[0] = b->ref[0];
+ mv[x].ref[1] = -1;
+ AV_COPY32(&mv[x].mv[0], &b->mv[3][0]);
}
}
}
@@ -1071,6 +1075,7 @@ static void intra_recon(AVCodecContext *avctx, ptrdiff_t y_off, ptrdiff_t uv_off
{
VP9Context *s = avctx->priv_data;
VP9Block *const b = &s->b;
+ AVFrame *f = s->frames[CUR_FRAME].tf.f;
int row = b->row, col = b->col;
int w4 = bwh_tab[1][b->bs][0] << 1, step1d = 1 << b->tx, n;
int h4 = bwh_tab[1][b->bs][1] << 1, x, y, step = 1 << (b->tx * 2);
@@ -1078,7 +1083,7 @@ static void intra_recon(AVCodecContext *avctx, ptrdiff_t y_off, ptrdiff_t uv_off
int end_y = FFMIN(2 * (s->rows - row), h4);
int tx = 4 * s->lossless + b->tx, uvtx = b->uvtx + 4 * s->lossless;
int uvstep1d = 1 << b->uvtx, p;
- uint8_t *dst = b->dst[0], *dst_r = s->cur_frame->data[0] + y_off;
+ uint8_t *dst = b->dst[0], *dst_r = f->data[0] + y_off;
for (n = 0, y = 0; y < end_y; y += step1d) {
uint8_t *ptr = dst, *ptr_r = dst_r;
@@ -1092,7 +1097,7 @@ static void intra_recon(AVCodecContext *avctx, ptrdiff_t y_off, ptrdiff_t uv_off
int eob = b->tx > TX_8X8 ? AV_RN16A(&s->eob[n]) : s->eob[n];
mode = check_intra_mode(s, mode, &a, ptr_r,
- s->cur_frame->linesize[0],
+ f->linesize[0],
ptr, b->y_stride, l,
col, x, w4, row, y, b->tx, 0);
s->dsp.intra_pred[b->tx][mode](ptr, b->y_stride, l, a);
@@ -1100,7 +1105,7 @@ static void intra_recon(AVCodecContext *avctx, ptrdiff_t y_off, ptrdiff_t uv_off
s->dsp.itxfm_add[tx][txtp](ptr, b->y_stride,
s->block + 16 * n, eob);
}
- dst_r += 4 * s->cur_frame->linesize[0] * step1d;
+ dst_r += 4 * f->linesize[0] * step1d;
dst += 4 * b->y_stride * step1d;
}
@@ -1112,7 +1117,7 @@ static void intra_recon(AVCodecContext *avctx, ptrdiff_t y_off, ptrdiff_t uv_off
step = 1 << (b->uvtx * 2);
for (p = 0; p < 2; p++) {
dst = b->dst[1 + p];
- dst_r = s->cur_frame->data[1 + p] + uv_off;
+ dst_r = f->data[1 + p] + uv_off;
for (n = 0, y = 0; y < end_y; y += uvstep1d) {
uint8_t *ptr = dst, *ptr_r = dst_r;
for (x = 0; x < end_x;
@@ -1125,7 +1130,7 @@ static void intra_recon(AVCodecContext *avctx, ptrdiff_t y_off, ptrdiff_t uv_off
: s->uveob[p][n];
mode = check_intra_mode(s, mode, &a, ptr_r,
- s->cur_frame->linesize[1],
+ f->linesize[1],
ptr, b->uv_stride, l,
col, x, w4, row, y, b->uvtx, p + 1);
s->dsp.intra_pred[b->uvtx][mode](ptr, b->uv_stride, l, a);
@@ -1134,7 +1139,7 @@ static void intra_recon(AVCodecContext *avctx, ptrdiff_t y_off, ptrdiff_t uv_off
s->uvblock[p] + 16 * n,
eob);
}
- dst_r += 4 * uvstep1d * s->cur_frame->linesize[1];
+ dst_r += 4 * uvstep1d * f->linesize[1];
dst += 4 * uvstep1d * b->uv_stride;
}
}
@@ -1224,8 +1229,12 @@ static int inter_recon(AVCodecContext *avctx)
VP9Context *s = avctx->priv_data;
VP9Block *const b = &s->b;
int row = b->row, col = b->col;
- AVFrame *ref1 = s->refs[s->refidx[b->ref[0]]];
- AVFrame *ref2 = b->comp ? s->refs[s->refidx[b->ref[1]]] : NULL;
+
+ ThreadFrame *tref1 = &s->refs[s->refidx[b->ref[0]]];
+ ThreadFrame *tref2 = b->comp ? &s->refs[s->refidx[b->ref[1]]] : NULL;
+ AVFrame *ref1 = tref1->f;
+ AVFrame *ref2 = tref2 ? tref2->f : NULL;
+
int w = avctx->width, h = avctx->height;
ptrdiff_t ls_y = b->y_stride, ls_uv = b->uv_stride;
@@ -1547,6 +1556,7 @@ int ff_vp9_decode_block(AVCodecContext *avctx, int row, int col,
{
VP9Context *s = avctx->priv_data;
VP9Block *const b = &s->b;
+ AVFrame *f = s->frames[CUR_FRAME].tf.f;
enum BlockSize bs = bl * 3 + bp;
int ret, y, w4 = bwh_tab[1][bs][0], h4 = bwh_tab[1][bs][1], lvl;
int emu[2];
@@ -1582,25 +1592,25 @@ int ff_vp9_decode_block(AVCodecContext *avctx, int row, int col,
/* Emulated overhangs if the stride of the target buffer can't hold.
* This allows to support emu-edge and so on even if we have large
* block overhangs. */
- emu[0] = (col + w4) * 8 > s->cur_frame->linesize[0] ||
+ emu[0] = (col + w4) * 8 > f->linesize[0] ||
(row + h4) > s->rows;
- emu[1] = (col + w4) * 4 > s->cur_frame->linesize[1] ||
+ emu[1] = (col + w4) * 4 > f->linesize[1] ||
(row + h4) > s->rows;
if (emu[0]) {
b->dst[0] = s->tmp_y;
b->y_stride = 64;
} else {
- b->dst[0] = s->cur_frame->data[0] + yoff;
- b->y_stride = s->cur_frame->linesize[0];
+ b->dst[0] = f->data[0] + yoff;
+ b->y_stride = f->linesize[0];
}
if (emu[1]) {
b->dst[1] = s->tmp_uv[0];
b->dst[2] = s->tmp_uv[1];
b->uv_stride = 32;
} else {
- b->dst[1] = s->cur_frame->data[1] + uvoff;
- b->dst[2] = s->cur_frame->data[2] + uvoff;
- b->uv_stride = s->cur_frame->linesize[1];
+ b->dst[1] = f->data[1] + uvoff;
+ b->dst[2] = f->data[2] + uvoff;
+ b->uv_stride = f->linesize[1];
}
if (b->intra) {
intra_recon(avctx, yoff, uvoff);
@@ -1618,9 +1628,9 @@ int ff_vp9_decode_block(AVCodecContext *avctx, int row, int col,
av_assert2(n <= 4);
if (w & bw) {
- s->dsp.mc[n][0][0][0][0](s->cur_frame->data[0] + yoff + o,
+ s->dsp.mc[n][0][0][0][0](f->data[0] + yoff + o,
s->tmp_y + o,
- s->cur_frame->linesize[0],
+ f->linesize[0],
64, h, 0, 0);
o += bw;
}
@@ -1636,13 +1646,13 @@ int ff_vp9_decode_block(AVCodecContext *avctx, int row, int col,
av_assert2(n <= 4);
if (w & bw) {
- s->dsp.mc[n][0][0][0][0](s->cur_frame->data[1] + uvoff + o,
+ s->dsp.mc[n][0][0][0][0](f->data[1] + uvoff + o,
s->tmp_uv[0] + o,
- s->cur_frame->linesize[1],
+ f->linesize[1],
32, h, 0, 0);
- s->dsp.mc[n][0][0][0][0](s->cur_frame->data[2] + uvoff + o,
+ s->dsp.mc[n][0][0][0][0](f->data[2] + uvoff + o,
s->tmp_uv[1] + o,
- s->cur_frame->linesize[2],
+ f->linesize[2],
32, h, 0, 0);
o += bw;
}