@@ -213,14 +213,13 @@ static int update_size(AVCodecContext *avctx, int w, int h)
static int update_block_buffers(AVCodecContext *avctx)
{
+ int i;
VP9Context *s = avctx->priv_data;
int chroma_blocks, chroma_eobs, bytesperpixel = s->bytesperpixel;
if (s->b_base && s->block_base && s->block_alloc_using_2pass == s->s.frames[CUR_FRAME].uses_2pass)
return 0;
- av_free(s->b_base);
- av_free(s->block_base);
chroma_blocks = 64 * 64 >> (s->ss_h + s->ss_v);
chroma_eobs = 16 * 16 >> (s->ss_h + s->ss_v);
if (s->s.frames[CUR_FRAME].uses_2pass) {
@@ -237,16 +236,18 @@ static int update_block_buffers(AVCodecContext *avctx)
s->uveob_base[0] = s->eob_base + 16 * 16 * sbs;
s->uveob_base[1] = s->uveob_base[0] + chroma_eobs * sbs;
} else {
- s->b_base = av_malloc(sizeof(VP9Block));
- s->block_base = av_mallocz((64 * 64 + 2 * chroma_blocks) * bytesperpixel * sizeof(int16_t) +
- 16 * 16 + 2 * chroma_eobs);
- if (!s->b_base || !s->block_base)
- return AVERROR(ENOMEM);
- s->uvblock_base[0] = s->block_base + 64 * 64 * bytesperpixel;
- s->uvblock_base[1] = s->uvblock_base[0] + chroma_blocks * bytesperpixel;
- s->eob_base = (uint8_t *) (s->uvblock_base[1] + chroma_blocks * bytesperpixel);
- s->uveob_base[0] = s->eob_base + 16 * 16;
- s->uveob_base[1] = s->uveob_base[0] + chroma_eobs;
+ for (i = 0; i < s->s.h.tiling.tile_cols*s->s.h.tiling.tile_rows; i++) {
+ s->td[i].b_base = av_malloc(sizeof(VP9Block));
+ s->td[i].block_base = av_mallocz((64 * 64 + 2 * chroma_blocks) * bytesperpixel * sizeof(int16_t) +
+ 16 * 16 + 2 * chroma_eobs);
+ if (!s->td[i].b_base || !s->td[i].block_base)
+ return AVERROR(ENOMEM);
+ s->td[i].uvblock_base[0] = s->td[i].block_base + 64 * 64 * bytesperpixel;
+ s->td[i].uvblock_base[1] = s->td[i].uvblock_base[0] + chroma_blocks * bytesperpixel;
+ s->td[i].eob_base = (uint8_t *) (s->td[i].uvblock_base[1] + chroma_blocks * bytesperpixel);
+ s->td[i].uveob_base[0] = s->td[i].eob_base + 16 * 16;
+ s->td[i].uveob_base[1] = s->td[i].uveob_base[0] + chroma_eobs;
+ }
}
s->block_alloc_using_2pass = s->s.frames[CUR_FRAME].uses_2pass;
@@ -543,8 +544,23 @@ static int decode_frame_header(AVCodecContext *avctx,
sharp = get_bits(&s->gb, 3);
// if sharpness changed, reinit lim/mblim LUTs. if it didn't change, keep
// the old cache values since they are still valid
- if (s->s.h.filter.sharpness != sharp)
- memset(s->filter_lut.lim_lut, 0, sizeof(s->filter_lut.lim_lut));
+ if (s->s.h.filter.sharpness != sharp) {
+ for (i = 1; i <= 63; i++) {
+ if (!s->filter_lut.lim_lut[i]) {
+ int sharp = s->s.h.filter.sharpness;
+ int limit = i;
+
+ if (sharp > 0) {
+ limit >>= (sharp + 3) >> 2;
+ limit = FFMIN(limit, 9 - sharp);
+ }
+ limit = FFMAX(limit, 1);
+
+ s->filter_lut.lim_lut[i] = limit;
+ s->filter_lut.mblim_lut[i] = 2 * (i + 2) + limit;
+ }
+ }
+ }
s->s.h.filter.sharpness = sharp;
if ((s->s.h.lf_delta.enabled = get_bits1(&s->gb))) {
if ((s->s.h.lf_delta.updated = get_bits1(&s->gb))) {
@@ -663,10 +679,10 @@ static int decode_frame_header(AVCodecContext *avctx,
s->s.h.tiling.tile_rows = 1 << s->s.h.tiling.log2_tile_rows;
if (s->s.h.tiling.tile_cols != (1 << s->s.h.tiling.log2_tile_cols)) {
s->s.h.tiling.tile_cols = 1 << s->s.h.tiling.log2_tile_cols;
- s->c_b = av_fast_realloc(s->c_b, &s->c_b_size,
- sizeof(VP56RangeCoder) * s->s.h.tiling.tile_cols);
- if (!s->c_b) {
- av_log(avctx, AV_LOG_ERROR, "Ran out of memory during range coder init\n");
+ s->td = av_fast_realloc(s->td, &s->td_size,
+ sizeof(VP9TileData) * s->s.h.tiling.tile_cols*s->s.h.tiling.tile_rows);
+ if (!s->td) {
+ av_log(avctx, AV_LOG_ERROR, "Ran out of memory during tile init\n");
return AVERROR(ENOMEM);
}
}
@@ -741,6 +757,16 @@ static int decode_frame_header(AVCodecContext *avctx,
} else {
memset(&s->counts, 0, sizeof(s->counts));
}
+
+ for (i = 0; i < s->s.h.tiling.tile_cols*s->s.h.tiling.tile_rows; i++) {
+ if (s->s.h.keyframe || s->s.h.intraonly) {
+ memset(s->td[i].counts.coef, 0, sizeof(s->counts.coef));
+ memset(s->td[i].counts.eob, 0, sizeof(s->counts.eob));
+ } else {
+ memset(&s->td[i].counts, 0, sizeof(s->counts));
+ }
+ }
+
/* FIXME is it faster to not copy here, but do it down in the fw updates
* as explicit copies if the fw update is missing (and skip the copy upon
* fw update)? */
@@ -929,12 +955,12 @@ static int decode_frame_header(AVCodecContext *avctx,
return (data2 - data) + size2;
}
-static void decode_sb(AVCodecContext *avctx, int row, int col, VP9Filter *lflvl,
+static void decode_sb(VP9TileData *td, int row, int col, VP9Filter *lflvl,
ptrdiff_t yoff, ptrdiff_t uvoff, enum BlockLevel bl)
{
- VP9Context *s = avctx->priv_data;
+ VP9Context *s = td->s;
int c = ((s->above_partition_ctx[col] >> (3 - bl)) & 1) |
- (((s->left_partition_ctx[row & 0x7] >> (3 - bl)) & 1) << 1);
+ (((td->left_partition_ctx[row & 0x7] >> (3 - bl)) & 1) << 1);
const uint8_t *p = s->s.h.keyframe || s->s.h.intraonly ? ff_vp9_default_kf_partition_probs[bl][c] :
s->prob.p.partition[bl][c];
enum BlockPartition bp;
@@ -944,75 +970,75 @@ static void decode_sb(AVCodecContext *avctx, int row, int col, VP9Filter *lflvl,
int bytesperpixel = s->bytesperpixel;
if (bl == BL_8X8) {
- bp = vp8_rac_get_tree(&s->c, ff_vp9_partition_tree, p);
- ff_vp9_decode_block(avctx, row, col, lflvl, yoff, uvoff, bl, bp);
+ bp = vp8_rac_get_tree(&td->c, ff_vp9_partition_tree, p);
+ ff_vp9_decode_block(td, row, col, lflvl, yoff, uvoff, bl, bp);
} else if (col + hbs < s->cols) { // FIXME why not <=?
if (row + hbs < s->rows) { // FIXME why not <=?
- bp = vp8_rac_get_tree(&s->c, ff_vp9_partition_tree, p);
+ bp = vp8_rac_get_tree(&td->c, ff_vp9_partition_tree, p);
switch (bp) {
case PARTITION_NONE:
- ff_vp9_decode_block(avctx, row, col, lflvl, yoff, uvoff, bl, bp);
+ ff_vp9_decode_block(td, row, col, lflvl, yoff, uvoff, bl, bp);
break;
case PARTITION_H:
- ff_vp9_decode_block(avctx, row, col, lflvl, yoff, uvoff, bl, bp);
+ ff_vp9_decode_block(td, row, col, lflvl, yoff, uvoff, bl, bp);
yoff += hbs * 8 * y_stride;
uvoff += hbs * 8 * uv_stride >> s->ss_v;
- ff_vp9_decode_block(avctx, row + hbs, col, lflvl, yoff, uvoff, bl, bp);
+ ff_vp9_decode_block(td, row + hbs, col, lflvl, yoff, uvoff, bl, bp);
break;
case PARTITION_V:
- ff_vp9_decode_block(avctx, row, col, lflvl, yoff, uvoff, bl, bp);
+ ff_vp9_decode_block(td, row, col, lflvl, yoff, uvoff, bl, bp);
yoff += hbs * 8 * bytesperpixel;
uvoff += hbs * 8 * bytesperpixel >> s->ss_h;
- ff_vp9_decode_block(avctx, row, col + hbs, lflvl, yoff, uvoff, bl, bp);
+ ff_vp9_decode_block(td, row, col + hbs, lflvl, yoff, uvoff, bl, bp);
break;
case PARTITION_SPLIT:
- decode_sb(avctx, row, col, lflvl, yoff, uvoff, bl + 1);
- decode_sb(avctx, row, col + hbs, lflvl,
+ decode_sb(td, row, col, lflvl, yoff, uvoff, bl + 1);
+ decode_sb(td, row, col + hbs, lflvl,
yoff + 8 * hbs * bytesperpixel,
uvoff + (8 * hbs * bytesperpixel >> s->ss_h), bl + 1);
yoff += hbs * 8 * y_stride;
uvoff += hbs * 8 * uv_stride >> s->ss_v;
- decode_sb(avctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
- decode_sb(avctx, row + hbs, col + hbs, lflvl,
+ decode_sb(td, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
+ decode_sb(td, row + hbs, col + hbs, lflvl,
yoff + 8 * hbs * bytesperpixel,
uvoff + (8 * hbs * bytesperpixel >> s->ss_h), bl + 1);
break;
default:
av_assert0(0);
}
- } else if (vp56_rac_get_prob_branchy(&s->c, p[1])) {
+ } else if (vp56_rac_get_prob_branchy(&td->c, p[1])) {
bp = PARTITION_SPLIT;
- decode_sb(avctx, row, col, lflvl, yoff, uvoff, bl + 1);
- decode_sb(avctx, row, col + hbs, lflvl,
+ decode_sb(td, row, col, lflvl, yoff, uvoff, bl + 1);
+ decode_sb(td, row, col + hbs, lflvl,
yoff + 8 * hbs * bytesperpixel,
uvoff + (8 * hbs * bytesperpixel >> s->ss_h), bl + 1);
} else {
bp = PARTITION_H;
- ff_vp9_decode_block(avctx, row, col, lflvl, yoff, uvoff, bl, bp);
+ ff_vp9_decode_block(td, row, col, lflvl, yoff, uvoff, bl, bp);
}
} else if (row + hbs < s->rows) { // FIXME why not <=?
- if (vp56_rac_get_prob_branchy(&s->c, p[2])) {
+ if (vp56_rac_get_prob_branchy(&td->c, p[2])) {
bp = PARTITION_SPLIT;
- decode_sb(avctx, row, col, lflvl, yoff, uvoff, bl + 1);
+ decode_sb(td, row, col, lflvl, yoff, uvoff, bl + 1);
yoff += hbs * 8 * y_stride;
uvoff += hbs * 8 * uv_stride >> s->ss_v;
- decode_sb(avctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
+ decode_sb(td, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
} else {
bp = PARTITION_V;
- ff_vp9_decode_block(avctx, row, col, lflvl, yoff, uvoff, bl, bp);
+ ff_vp9_decode_block(td, row, col, lflvl, yoff, uvoff, bl, bp);
}
} else {
bp = PARTITION_SPLIT;
- decode_sb(avctx, row, col, lflvl, yoff, uvoff, bl + 1);
+ decode_sb(td, row, col, lflvl, yoff, uvoff, bl + 1);
}
- s->counts.partition[bl][c][bp]++;
+ td->counts.partition[bl][c][bp]++;
}
-static void decode_sb_mem(AVCodecContext *avctx, int row, int col, VP9Filter *lflvl,
+static void decode_sb_mem(VP9TileData *td, int row, int col, VP9Filter *lflvl,
ptrdiff_t yoff, ptrdiff_t uvoff, enum BlockLevel bl)
{
- VP9Context *s = avctx->priv_data;
- VP9Block *b = s->b;
+ VP9Context *s = td->s;
+ VP9Block *b = td->b;
ptrdiff_t hbs = 4 >> bl;
AVFrame *f = s->s.frames[CUR_FRAME].tf.f;
ptrdiff_t y_stride = f->linesize[0], uv_stride = f->linesize[1];
@@ -1020,39 +1046,39 @@ static void decode_sb_mem(AVCodecContext *avctx, int row, int col, VP9Filter *lf
if (bl == BL_8X8) {
av_assert2(b->bl == BL_8X8);
- ff_vp9_decode_block(avctx, row, col, lflvl, yoff, uvoff, b->bl, b->bp);
+ ff_vp9_decode_block(td, row, col, lflvl, yoff, uvoff, b->bl, b->bp);
} else if (s->b->bl == bl) {
- ff_vp9_decode_block(avctx, row, col, lflvl, yoff, uvoff, b->bl, b->bp);
+ ff_vp9_decode_block(td, row, col, lflvl, yoff, uvoff, b->bl, b->bp);
if (b->bp == PARTITION_H && row + hbs < s->rows) {
yoff += hbs * 8 * y_stride;
uvoff += hbs * 8 * uv_stride >> s->ss_v;
- ff_vp9_decode_block(avctx, row + hbs, col, lflvl, yoff, uvoff, b->bl, b->bp);
+ ff_vp9_decode_block(td, row + hbs, col, lflvl, yoff, uvoff, b->bl, b->bp);
} else if (b->bp == PARTITION_V && col + hbs < s->cols) {
yoff += hbs * 8 * bytesperpixel;
uvoff += hbs * 8 * bytesperpixel >> s->ss_h;
- ff_vp9_decode_block(avctx, row, col + hbs, lflvl, yoff, uvoff, b->bl, b->bp);
+ ff_vp9_decode_block(td, row, col + hbs, lflvl, yoff, uvoff, b->bl, b->bp);
}
} else {
- decode_sb_mem(avctx, row, col, lflvl, yoff, uvoff, bl + 1);
+ decode_sb_mem(td, row, col, lflvl, yoff, uvoff, bl + 1);
if (col + hbs < s->cols) { // FIXME why not <=?
if (row + hbs < s->rows) {
- decode_sb_mem(avctx, row, col + hbs, lflvl, yoff + 8 * hbs * bytesperpixel,
+ decode_sb_mem(td, row, col + hbs, lflvl, yoff + 8 * hbs * bytesperpixel,
uvoff + (8 * hbs * bytesperpixel >> s->ss_h), bl + 1);
yoff += hbs * 8 * y_stride;
uvoff += hbs * 8 * uv_stride >> s->ss_v;
- decode_sb_mem(avctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
- decode_sb_mem(avctx, row + hbs, col + hbs, lflvl,
+ decode_sb_mem(td, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
+ decode_sb_mem(td, row + hbs, col + hbs, lflvl,
yoff + 8 * hbs * bytesperpixel,
uvoff + (8 * hbs * bytesperpixel >> s->ss_h), bl + 1);
} else {
yoff += hbs * 8 * bytesperpixel;
uvoff += hbs * 8 * bytesperpixel >> s->ss_h;
- decode_sb_mem(avctx, row, col + hbs, lflvl, yoff, uvoff, bl + 1);
+ decode_sb_mem(td, row, col + hbs, lflvl, yoff, uvoff, bl + 1);
}
} else if (row + hbs < s->rows) {
yoff += hbs * 8 * y_stride;
uvoff += hbs * 8 * uv_stride >> s->ss_v;
- decode_sb_mem(avctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
+ decode_sb_mem(td, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
}
}
}
@@ -1067,9 +1093,13 @@ static void set_tile_offset(int *start, int *end, int idx, int log2_n, int n)
static void free_buffers(VP9Context *s)
{
+ int i;
+
av_freep(&s->intra_pred_data[0]);
- av_freep(&s->b_base);
- av_freep(&s->block_base);
+ for (i = 0; i < s->s.h.tiling.tile_cols*s->s.h.tiling.tile_rows; i++) {
+ av_freep(&s->td[i].b_base);
+ av_freep(&s->td[i].block_base);
+ }
}
static av_cold int vp9_decode_free(AVCodecContext *avctx)
@@ -1091,26 +1121,122 @@ static av_cold int vp9_decode_free(AVCodecContext *avctx)
av_frame_free(&s->next_refs[i].f);
}
free_buffers(s);
- av_freep(&s->c_b);
- s->c_b_size = 0;
+ av_freep(&s->td);
+ s->td_size = 0;
return 0;
}
+static av_always_inline
+int decode_tiles(AVCodecContext *avctx, void *tdata, int jobnr,
+ int threadnr)
+{
+ int row, col;
+ VP9Context *s = avctx->priv_data;
+ VP9TileData *td = &s->td[jobnr];
+ ptrdiff_t uvoff, yoff, ls_y, ls_uv;
+ AVFrame *f;
+ uvoff = td->uvoff;
+ yoff = td->yoff;
+ int bytesperpixel = s->bytesperpixel;
+
+ f = s->s.frames[CUR_FRAME].tf.f;
+ ls_y = f->linesize[0];
+ ls_uv =f->linesize[1];
+
+ for (row = td->tile_row_start; row < td->tile_row_end;
+ row += 8, yoff += ls_y * 64, uvoff += ls_uv * 64 >> s->ss_v) {
+ VP9Filter *lflvl_ptr = td->lflvl_ptr;
+ ptrdiff_t yoff2 = yoff, uvoff2 = uvoff;
+
+ if (s->pass != 2) {
+ memset(td->left_partition_ctx, 0, 8);
+ memset(td->left_skip_ctx, 0, 8);
+ if (s->s.h.keyframe || s->s.h.intraonly) {
+ memset(td->left_mode_ctx, DC_PRED, 16);
+ } else {
+ memset(td->left_mode_ctx, NEARESTMV, 8);
+ }
+ memset(td->left_y_nnz_ctx, 0, 16);
+ memset(td->left_uv_nnz_ctx, 0, 32);
+ memset(td->left_segpred_ctx, 0, 8);
+ }
+
+ for (col = td->tile_col_start;
+ col < td->tile_col_end;
+ col += 8, yoff2 += 64 * bytesperpixel,
+ uvoff2 += 64 * bytesperpixel >> s->ss_h, lflvl_ptr++) {
+ // FIXME integrate with lf code (i.e. zero after each
+ // use, similar to invtxfm coefficients, or similar)
+ if (s->pass != 1) {
+ memset(lflvl_ptr->mask, 0, sizeof(lflvl_ptr->mask));
+ }
+
+ if (s->pass == 2) {
+ decode_sb_mem(td, row, col, lflvl_ptr,
+ yoff2, uvoff2, BL_64X64);
+ } else {
+ decode_sb(td, row, col, lflvl_ptr,
+ yoff2, uvoff2, BL_64X64);
+ }
+ }
+
+ if (s->pass == 1)
+ continue;
+
+ // backup pre-loopfilter reconstruction data for intra
+ // prediction of next row of sb64s
+ unsigned tiles_cols = td->tile_col_end - td->tile_col_start;
+ if (row + 8 < s->rows) {
+ memcpy(s->intra_pred_data[0] + (td->tile_col_start * 8 * bytesperpixel),
+ f->data[0] + yoff + 63 * ls_y,
+ 8 * tiles_cols * bytesperpixel);
+ memcpy(s->intra_pred_data[1] + (td->tile_col_start * 8 * bytesperpixel >> s->ss_h),
+ f->data[1] + uvoff + ((64 >> s->ss_v) - 1) * ls_uv,
+ 8 * tiles_cols * bytesperpixel >> s->ss_h);
+ memcpy(s->intra_pred_data[2] + (td->tile_col_start * 8 * bytesperpixel >> s->ss_h),
+ f->data[2] + uvoff + ((64 >> s->ss_v) - 1) * ls_uv,
+ 8 * tiles_cols * bytesperpixel >> s->ss_h);
+ }
+
+ // loopfilter one row
+ if (s->s.h.filter.level && avctx->active_thread_type != FF_THREAD_SLICE) {
+ yoff2 = yoff;
+ uvoff2 = uvoff;
+ lflvl_ptr = s->lflvl;
+ for (col = 0; col < s->cols;
+ col += 8, yoff2 += 64 * bytesperpixel,
+ uvoff2 += 64 * bytesperpixel >> s->ss_h, lflvl_ptr++) {
+ ff_vp9_loopfilter_sb(avctx, lflvl_ptr, row, col,
+ yoff2, uvoff2);
+ }
+ }
+
+ // FIXME maybe we can make this more finegrained by running the
+ // loopfilter per-block instead of after each sbrow
+ // In fact that would also make intra pred left preparation easier?
+ ff_thread_report_progress(&s->s.frames[CUR_FRAME].tf, row >> 3, 0);
+ }
+ return 0;
+}
+
static int vp9_decode_frame(AVCodecContext *avctx, void *frame,
int *got_frame, AVPacket *pkt)
{
const uint8_t *data = pkt->data;
int size = pkt->size;
VP9Context *s = avctx->priv_data;
- int ret, tile_row, tile_col, i, ref, row, col;
+ int ret, tile_row, tile_col, i, ref, row, col, num_jobs;
+ int tile_col_start, tile_col_end, tile_row_start, tile_row_end;
+ int j, k, l, m, n, o, p;
+ int td_cnt = 0;
+ int bytesperpixel;
int retain_segmap_ref = s->s.frames[REF_FRAME_SEGMAP].segmentation_map &&
(!s->s.h.segmentation.enabled || !s->s.h.segmentation.update_map);
- ptrdiff_t yoff, uvoff, ls_y, ls_uv;
AVFrame *f;
- int bytesperpixel;
-
+ ptrdiff_t ls_y, ls_uv, yoff, uvoff;
+
if ((ret = decode_frame_header(avctx, data, size, &ref)) < 0) {
return ret;
} else if (ret == 0) {
@@ -1235,19 +1361,26 @@ FF_ENABLE_DEPRECATION_WARNINGS
do {
yoff = uvoff = 0;
- s->b = s->b_base;
- s->block = s->block_base;
- s->uvblock[0] = s->uvblock_base[0];
- s->uvblock[1] = s->uvblock_base[1];
- s->eob = s->eob_base;
- s->uveob[0] = s->uveob_base[0];
- s->uveob[1] = s->uveob_base[1];
+ for (i = 0; i < s->s.h.tiling.tile_cols*s->s.h.tiling.tile_rows; i++) {
+ s->td[i].b = s->td[i].b_base;
+ s->td[i].block = s->td[i].block_base;
+ s->td[i].uvblock[0] = s->td[i].uvblock_base[0];
+ s->td[i].uvblock[1] = s->td[i].uvblock_base[1];
+ s->td[i].eob = s->td[i].eob_base;
+ s->td[i].uveob[0] = s->td[i].uveob_base[0];
+ s->td[i].uveob[1] = s->td[i].uveob_base[1];
+ }
for (tile_row = 0; tile_row < s->s.h.tiling.tile_rows; tile_row++) {
- set_tile_offset(&s->tile_row_start, &s->tile_row_end,
+ set_tile_offset(&tile_row_start, &tile_row_end,
tile_row, s->s.h.tiling.log2_tile_rows, s->sb_rows);
+
+ ptrdiff_t yoff2 = yoff, uvoff2 = uvoff;
+ VP9Filter *lflvl_ptr = s->lflvl;
if (s->pass != 2) {
for (tile_col = 0; tile_col < s->s.h.tiling.tile_cols; tile_col++) {
+ set_tile_offset(&tile_col_start, &tile_col_end,
+ tile_col, s->s.h.tiling.log2_tile_cols, s->sb_cols);
int64_t tile_size;
if (tile_col == s->s.h.tiling.tile_cols - 1 &&
@@ -1262,98 +1395,120 @@ FF_ENABLE_DEPRECATION_WARNINGS
ff_thread_report_progress(&s->s.frames[CUR_FRAME].tf, INT_MAX, 0);
return AVERROR_INVALIDDATA;
}
- ret = ff_vp56_init_range_decoder(&s->c_b[tile_col], data, tile_size);
+ ret = ff_vp56_init_range_decoder(&s->td[td_cnt].c, data, tile_size);
if (ret < 0)
return ret;
- if (vp56_rac_get_prob_branchy(&s->c_b[tile_col], 128)) { // marker bit
+ if (vp56_rac_get_prob_branchy(&s->td[td_cnt].c, 128)) { // marker bit
ff_thread_report_progress(&s->s.frames[CUR_FRAME].tf, INT_MAX, 0);
return AVERROR_INVALIDDATA;
}
data += tile_size;
size -= tile_size;
+
+ s->td[td_cnt].tile_col_start = tile_col_start;
+ s->td[td_cnt].tile_col_end = tile_col_end;
+ s->td[td_cnt].tile_row_start = tile_row_start;
+ s->td[td_cnt].tile_row_end = tile_row_end;
+ s->td[td_cnt].yoff = yoff2;
+ s->td[td_cnt].uvoff = uvoff2;
+ s->td[td_cnt].s = s;
+ s->td[td_cnt].lflvl_ptr = lflvl_ptr;
+ td_cnt++;
+ for (col = tile_col_start; col < tile_col_end; col += 8,
+ yoff2 += 64 * bytesperpixel,
+ uvoff2 += 64 * bytesperpixel >> s->ss_h, lflvl_ptr++);
}
+ for (row = tile_row_start; row < tile_row_end;
+ row += 8, yoff += ls_y * 64, uvoff += ls_uv * 64 >> s->ss_v);
}
+ }
- for (row = s->tile_row_start; row < s->tile_row_end;
- row += 8, yoff += ls_y * 64, uvoff += ls_uv * 64 >> s->ss_v) {
- VP9Filter *lflvl_ptr = s->lflvl;
- ptrdiff_t yoff2 = yoff, uvoff2 = uvoff;
+ if (avctx->active_thread_type == FF_THREAD_FRAME)
+ num_jobs = 1;
+ else
+ num_jobs = s->s.h.tiling.tile_rows*s->s.h.tiling.tile_cols;
- for (tile_col = 0; tile_col < s->s.h.tiling.tile_cols; tile_col++) {
- set_tile_offset(&s->tile_col_start, &s->tile_col_end,
- tile_col, s->s.h.tiling.log2_tile_cols, s->sb_cols);
+ avctx->execute2(avctx, decode_tiles, s->td, NULL, num_jobs);
- if (s->pass != 2) {
- memset(s->left_partition_ctx, 0, 8);
- memset(s->left_skip_ctx, 0, 8);
- if (s->s.h.keyframe || s->s.h.intraonly) {
- memset(s->left_mode_ctx, DC_PRED, 16);
- } else {
- memset(s->left_mode_ctx, NEARESTMV, 8);
+ for (i = 0; i < s->s.h.tiling.tile_rows*s->s.h.tiling.tile_cols; i++) {
+ for (j = 0; j < 4; j++)
+ for (k = 0; k < 2; k++)
+ for (l = 0; l < 2; l++)
+ for (m = 0; m < 6; m++)
+ for (n = 0; n < 6; n++) {
+ for (o = 0; o < 3; o++)
+ s->counts.coef[j][k][l][m][n][o] += s->td[i].counts.coef[j][k][l][m][n][o];
+
+ for (p = 0; p < 2; p++)
+ s->counts.eob[j][k][l][m][n][p] += s->td[i].counts.eob[j][k][l][m][n][p];
}
- memset(s->left_y_nnz_ctx, 0, 16);
- memset(s->left_uv_nnz_ctx, 0, 32);
- memset(s->left_segpred_ctx, 0, 8);
- memcpy(&s->c, &s->c_b[tile_col], sizeof(s->c));
- }
+ for (j = 0; j < 4; j++)
+ for (k = 0; k < 4; k++)
+ for (l = 0; l < 4; l++)
+ s->counts.partition[j][k][l] += s->td[i].counts.partition[j][k][l];
+
+ for (j = 0; j < 4; j++) {
+ s->counts.mv_joint[j] += s->td[i].counts.mv_joint[j];
+ for (k = 0; k < 10; k++)
+ s->counts.y_mode[j][k] += s->td[i].counts.y_mode[j][k];
+
+ for (k = 0; k < 3; k++)
+ s->counts.filter[j][k] += s->td[i].counts.filter[j][k];
+
+ for (k = 0; k < 2; k++)
+ s->counts.intra[j][k] += s->td[i].counts.intra[j][k];
+ }
- for (col = s->tile_col_start;
- col < s->tile_col_end;
- col += 8, yoff2 += 64 * bytesperpixel,
- uvoff2 += 64 * bytesperpixel >> s->ss_h, lflvl_ptr++) {
- // FIXME integrate with lf code (i.e. zero after each
- // use, similar to invtxfm coefficients, or similar)
- if (s->pass != 1) {
- memset(lflvl_ptr->mask, 0, sizeof(lflvl_ptr->mask));
- }
+ for (j = 0; j < 2; j++) {
+ for (k = 0; k < 4; k++)
+ s->counts.tx32p[j][k] += s->td[i].counts.tx32p[j][k];
+
+ for (k = 0; k < 3; k++)
+ s->counts.tx16p[j][k] += s->td[i].counts.tx16p[j][k];
+
+ for (k = 0; k < 2; k++)
+ s->counts.tx8p[j][k] += s->td[i].counts.tx8p[j][k];
+ }
- if (s->pass == 2) {
- decode_sb_mem(avctx, row, col, lflvl_ptr,
- yoff2, uvoff2, BL_64X64);
- } else {
- decode_sb(avctx, row, col, lflvl_ptr,
- yoff2, uvoff2, BL_64X64);
- }
- }
- if (s->pass != 2)
- memcpy(&s->c_b[tile_col], &s->c, sizeof(s->c));
+ for (j = 0; j < 5; j++) {
+ for (k = 0; k < 2; k++) {
+ s->counts.comp[j][k] += s->td[i].counts.comp[j][k];
+ s->counts.comp_ref[j][k] += s->td[i].counts.comp_ref[j][k];
+
+ for (l = 0; l < 2; l++)
+ s->counts.single_ref[j][k][l] += s->td[i].counts.single_ref[j][k][l];
}
+ }
- if (s->pass == 1)
- continue;
-
- // backup pre-loopfilter reconstruction data for intra
- // prediction of next row of sb64s
- if (row + 8 < s->rows) {
- memcpy(s->intra_pred_data[0],
- f->data[0] + yoff + 63 * ls_y,
- 8 * s->cols * bytesperpixel);
- memcpy(s->intra_pred_data[1],
- f->data[1] + uvoff + ((64 >> s->ss_v) - 1) * ls_uv,
- 8 * s->cols * bytesperpixel >> s->ss_h);
- memcpy(s->intra_pred_data[2],
- f->data[2] + uvoff + ((64 >> s->ss_v) - 1) * ls_uv,
- 8 * s->cols * bytesperpixel >> s->ss_h);
- }
+ for (j = 0; j < 7; j++)
+ for (k = 0; k < 4; k++)
+ s->counts.mv_mode[j][k] += s->td[i].counts.mv_mode[j][k];
- // loopfilter one row
- if (s->s.h.filter.level) {
- yoff2 = yoff;
- uvoff2 = uvoff;
- lflvl_ptr = s->lflvl;
- for (col = 0; col < s->cols;
- col += 8, yoff2 += 64 * bytesperpixel,
- uvoff2 += 64 * bytesperpixel >> s->ss_h, lflvl_ptr++) {
- ff_vp9_loopfilter_sb(avctx, lflvl_ptr, row, col,
- yoff2, uvoff2);
+ for (j = 0; j < 3; j++)
+ for (k = 0; k < 2; k++)
+ s->counts.skip[j][k] += s->td[i].counts.skip[j][k];
+
+ for (j = 0; j < 2; j++) {
+ for (k = 0; k < 2; k++) {
+ s->counts.mv_comp[j].sign[k] += s->td[i].counts.mv_comp[j].sign[k];
+ s->counts.mv_comp[j].class0[k] += s->td[i].counts.mv_comp[j].class0[k];
+ s->counts.mv_comp[j].hp[k] += s->td[i].counts.mv_comp[j].hp[k];
+ s->counts.mv_comp[j].class0_hp[k] += s->td[i].counts.mv_comp[j].class0_hp[k];
+ for (l = 0; l < 4; l++) {
+ s->counts.mv_comp[j].class0_fp[k][l] += s->td[i].counts.mv_comp[j].class0_fp[k][l];
}
}
- // FIXME maybe we can make this more finegrained by running the
- // loopfilter per-block instead of after each sbrow
- // In fact that would also make intra pred left preparation easier?
- ff_thread_report_progress(&s->s.frames[CUR_FRAME].tf, row >> 3, 0);
+ for (k = 0; k < 4; k++)
+ s->counts.mv_comp[j].fp[k] += s->td[i].counts.mv_comp[j].fp[k];
+
+ for (k = 0; k < 11; k++)
+ s->counts.mv_comp[j].classes[k] += s->td[i].counts.mv_comp[j].classes[k];
+
+ for (k = 0; k < 10; k++)
+ for (l = 0; l < 2; l++)
+ s->counts.mv_comp[j].bits[k][l] += s->td[i].counts.mv_comp[j].bits[k][l];
}
}
@@ -1492,7 +1647,7 @@ AVCodec ff_vp9_decoder = {
.init = vp9_decode_init,
.close = vp9_decode_free,
.decode = vp9_decode_frame,
- .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
+ .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS,
.flush = vp9_decode_flush,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(vp9_decode_init_thread_copy),
.update_thread_context = ONLY_IF_THREADS_ENABLED(vp9_decode_update_thread_context),
@@ -27,19 +27,19 @@
(VP56mv) { .x = ROUNDED_DIV(a.x + b.x + c.x + d.x, 4), \
.y = ROUNDED_DIV(a.y + b.y + c.y + d.y, 4) }
-static void FN(inter_pred)(AVCodecContext *avctx)
+static void FN(inter_pred)(VP9TileData *td)
{
static const uint8_t bwlog_tab[2][N_BS_SIZES] = {
{ 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 },
{ 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4 },
};
- VP9Context *s = avctx->priv_data;
- VP9Block *b = s->b;
- int row = s->row, col = s->col;
+ VP9Context *s = td->s;
+ VP9Block *b = td->b;
+ int row = td->row, col = td->col;
ThreadFrame *tref1 = &s->s.refs[s->s.h.refidx[b->ref[0]]], *tref2;
AVFrame *ref1 = tref1->f, *ref2;
int w1 = ref1->width, h1 = ref1->height, w2, h2;
- ptrdiff_t ls_y = s->y_stride, ls_uv = s->uv_stride;
+ ptrdiff_t ls_y = td->y_stride, ls_uv = td->uv_stride;
int bytesperpixel = BYTES_PER_PIXEL;
if (b->comp) {
@@ -55,11 +55,11 @@ static void FN(inter_pred)(AVCodecContext *avctx)
#if SCALED == 0
if (b->bs == BS_8x4) {
- mc_luma_dir(s, mc[3][b->filter][0], s->dst[0], ls_y,
+ mc_luma_dir(s, mc[3][b->filter][0], td->dst[0], ls_y,
ref1->data[0], ref1->linesize[0], tref1,
row << 3, col << 3, &b->mv[0][0],,,,, 8, 4, w1, h1, 0);
mc_luma_dir(s, mc[3][b->filter][0],
- s->dst[0] + 4 * ls_y, ls_y,
+ td->dst[0] + 4 * ls_y, ls_y,
ref1->data[0], ref1->linesize[0], tref1,
(row << 3) + 4, col << 3, &b->mv[2][0],,,,, 8, 4, w1, h1, 0);
w1 = (w1 + s->ss_h) >> s->ss_h;
@@ -67,14 +67,14 @@ static void FN(inter_pred)(AVCodecContext *avctx)
h1 = (h1 + 1) >> 1;
uvmv = ROUNDED_DIV_MVx2(b->mv[0][0], b->mv[2][0]);
mc_chroma_dir(s, mc[3 + s->ss_h][b->filter][0],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
row << 2, col << (3 - s->ss_h),
&uvmv,,,,, 8 >> s->ss_h, 4, w1, h1, 0);
} else {
mc_chroma_dir(s, mc[3 + s->ss_h][b->filter][0],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
row << 3, col << (3 - s->ss_h),
@@ -88,7 +88,7 @@ static void FN(inter_pred)(AVCodecContext *avctx)
uvmv = ROUNDED_DIV_MVx2(b->mv[0][0], b->mv[2][0]);
}
mc_chroma_dir(s, mc[3 + s->ss_h][b->filter][0],
- s->dst[1] + 4 * ls_uv, s->dst[2] + 4 * ls_uv, ls_uv,
+ td->dst[1] + 4 * ls_uv, td->dst[2] + 4 * ls_uv, ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
(row << 3) + 4, col << (3 - s->ss_h),
@@ -96,11 +96,11 @@ static void FN(inter_pred)(AVCodecContext *avctx)
}
if (b->comp) {
- mc_luma_dir(s, mc[3][b->filter][1], s->dst[0], ls_y,
+ mc_luma_dir(s, mc[3][b->filter][1], td->dst[0], ls_y,
ref2->data[0], ref2->linesize[0], tref2,
row << 3, col << 3, &b->mv[0][1],,,,, 8, 4, w2, h2, 1);
mc_luma_dir(s, mc[3][b->filter][1],
- s->dst[0] + 4 * ls_y, ls_y,
+ td->dst[0] + 4 * ls_y, ls_y,
ref2->data[0], ref2->linesize[0], tref2,
(row << 3) + 4, col << 3, &b->mv[2][1],,,,, 8, 4, w2, h2, 1);
w2 = (w2 + s->ss_h) >> s->ss_h;
@@ -108,14 +108,14 @@ static void FN(inter_pred)(AVCodecContext *avctx)
h2 = (h2 + 1) >> 1;
uvmv = ROUNDED_DIV_MVx2(b->mv[0][1], b->mv[2][1]);
mc_chroma_dir(s, mc[3 + s->ss_h][b->filter][1],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
row << 2, col << (3 - s->ss_h),
&uvmv,,,,, 8 >> s->ss_h, 4, w2, h2, 1);
} else {
mc_chroma_dir(s, mc[3 + s->ss_h][b->filter][1],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
row << 3, col << (3 - s->ss_h),
@@ -129,7 +129,7 @@ static void FN(inter_pred)(AVCodecContext *avctx)
uvmv = ROUNDED_DIV_MVx2(b->mv[0][1], b->mv[2][1]);
}
mc_chroma_dir(s, mc[3 + s->ss_h][b->filter][1],
- s->dst[1] + 4 * ls_uv, s->dst[2] + 4 * ls_uv, ls_uv,
+ td->dst[1] + 4 * ls_uv, td->dst[2] + 4 * ls_uv, ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
(row << 3) + 4, col << (3 - s->ss_h),
@@ -137,10 +137,10 @@ static void FN(inter_pred)(AVCodecContext *avctx)
}
}
} else if (b->bs == BS_4x8) {
- mc_luma_dir(s, mc[4][b->filter][0], s->dst[0], ls_y,
+ mc_luma_dir(s, mc[4][b->filter][0], td->dst[0], ls_y,
ref1->data[0], ref1->linesize[0], tref1,
row << 3, col << 3, &b->mv[0][0],,,,, 4, 8, w1, h1, 0);
- mc_luma_dir(s, mc[4][b->filter][0], s->dst[0] + 4 * bytesperpixel, ls_y,
+ mc_luma_dir(s, mc[4][b->filter][0], td->dst[0] + 4 * bytesperpixel, ls_y,
ref1->data[0], ref1->linesize[0], tref1,
row << 3, (col << 3) + 4, &b->mv[1][0],,,,, 4, 8, w1, h1, 0);
h1 = (h1 + s->ss_v) >> s->ss_v;
@@ -148,21 +148,21 @@ static void FN(inter_pred)(AVCodecContext *avctx)
w1 = (w1 + 1) >> 1;
uvmv = ROUNDED_DIV_MVx2(b->mv[0][0], b->mv[1][0]);
mc_chroma_dir(s, mc[4][b->filter][0],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
row << (3 - s->ss_v), col << 2,
&uvmv,,,,, 4, 8 >> s->ss_v, w1, h1, 0);
} else {
mc_chroma_dir(s, mc[4][b->filter][0],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
row << (3 - s->ss_v), col << 3,
&b->mv[0][0],,,,, 4, 8 >> s->ss_v, w1, h1, 0);
mc_chroma_dir(s, mc[4][b->filter][0],
- s->dst[1] + 4 * bytesperpixel,
- s->dst[2] + 4 * bytesperpixel, ls_uv,
+ td->dst[1] + 4 * bytesperpixel,
+ td->dst[2] + 4 * bytesperpixel, ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
row << (3 - s->ss_v), (col << 3) + 4,
@@ -170,10 +170,10 @@ static void FN(inter_pred)(AVCodecContext *avctx)
}
if (b->comp) {
- mc_luma_dir(s, mc[4][b->filter][1], s->dst[0], ls_y,
+ mc_luma_dir(s, mc[4][b->filter][1], td->dst[0], ls_y,
ref2->data[0], ref2->linesize[0], tref2,
row << 3, col << 3, &b->mv[0][1],,,,, 4, 8, w2, h2, 1);
- mc_luma_dir(s, mc[4][b->filter][1], s->dst[0] + 4 * bytesperpixel, ls_y,
+ mc_luma_dir(s, mc[4][b->filter][1], td->dst[0] + 4 * bytesperpixel, ls_y,
ref2->data[0], ref2->linesize[0], tref2,
row << 3, (col << 3) + 4, &b->mv[1][1],,,,, 4, 8, w2, h2, 1);
h2 = (h2 + s->ss_v) >> s->ss_v;
@@ -181,21 +181,21 @@ static void FN(inter_pred)(AVCodecContext *avctx)
w2 = (w2 + 1) >> 1;
uvmv = ROUNDED_DIV_MVx2(b->mv[0][1], b->mv[1][1]);
mc_chroma_dir(s, mc[4][b->filter][1],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
row << (3 - s->ss_v), col << 2,
&uvmv,,,,, 4, 8 >> s->ss_v, w2, h2, 1);
} else {
mc_chroma_dir(s, mc[4][b->filter][1],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
row << (3 - s->ss_v), col << 3,
&b->mv[0][1],,,,, 4, 8 >> s->ss_v, w2, h2, 1);
mc_chroma_dir(s, mc[4][b->filter][1],
- s->dst[1] + 4 * bytesperpixel,
- s->dst[2] + 4 * bytesperpixel, ls_uv,
+ td->dst[1] + 4 * bytesperpixel,
+ td->dst[2] + 4 * bytesperpixel, ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
row << (3 - s->ss_v), (col << 3) + 4,
@@ -211,21 +211,21 @@ static void FN(inter_pred)(AVCodecContext *avctx)
// FIXME if two horizontally adjacent blocks have the same MV,
// do a w8 instead of a w4 call
- mc_luma_dir(s, mc[4][b->filter][0], s->dst[0], ls_y,
+ mc_luma_dir(s, mc[4][b->filter][0], td->dst[0], ls_y,
ref1->data[0], ref1->linesize[0], tref1,
row << 3, col << 3, &b->mv[0][0],
0, 0, 8, 8, 4, 4, w1, h1, 0);
- mc_luma_dir(s, mc[4][b->filter][0], s->dst[0] + 4 * bytesperpixel, ls_y,
+ mc_luma_dir(s, mc[4][b->filter][0], td->dst[0] + 4 * bytesperpixel, ls_y,
ref1->data[0], ref1->linesize[0], tref1,
row << 3, (col << 3) + 4, &b->mv[1][0],
4, 0, 8, 8, 4, 4, w1, h1, 0);
mc_luma_dir(s, mc[4][b->filter][0],
- s->dst[0] + 4 * ls_y, ls_y,
+ td->dst[0] + 4 * ls_y, ls_y,
ref1->data[0], ref1->linesize[0], tref1,
(row << 3) + 4, col << 3, &b->mv[2][0],
0, 4, 8, 8, 4, 4, w1, h1, 0);
mc_luma_dir(s, mc[4][b->filter][0],
- s->dst[0] + 4 * ls_y + 4 * bytesperpixel, ls_y,
+ td->dst[0] + 4 * ls_y + 4 * bytesperpixel, ls_y,
ref1->data[0], ref1->linesize[0], tref1,
(row << 3) + 4, (col << 3) + 4, &b->mv[3][0],
4, 4, 8, 8, 4, 4, w1, h1, 0);
@@ -236,7 +236,7 @@ static void FN(inter_pred)(AVCodecContext *avctx)
uvmv = ROUNDED_DIV_MVx4(b->mv[0][0], b->mv[1][0],
b->mv[2][0], b->mv[3][0]);
mc_chroma_dir(s, mc[4][b->filter][0],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
row << 2, col << 2,
@@ -244,15 +244,15 @@ static void FN(inter_pred)(AVCodecContext *avctx)
} else {
uvmv = ROUNDED_DIV_MVx2(b->mv[0][0], b->mv[2][0]);
mc_chroma_dir(s, mc[4][b->filter][0],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
row << 2, col << 3,
&uvmv, 0, 0, 8, 4, 4, 4, w1, h1, 0);
uvmv = ROUNDED_DIV_MVx2(b->mv[1][0], b->mv[3][0]);
mc_chroma_dir(s, mc[4][b->filter][0],
- s->dst[1] + 4 * bytesperpixel,
- s->dst[2] + 4 * bytesperpixel, ls_uv,
+ td->dst[1] + 4 * bytesperpixel,
+ td->dst[2] + 4 * bytesperpixel, ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
row << 2, (col << 3) + 4,
@@ -263,7 +263,7 @@ static void FN(inter_pred)(AVCodecContext *avctx)
w1 = (w1 + 1) >> 1;
uvmv = ROUNDED_DIV_MVx2(b->mv[0][0], b->mv[1][0]);
mc_chroma_dir(s, mc[4][b->filter][0],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
row << 3, col << 2,
@@ -273,34 +273,34 @@ static void FN(inter_pred)(AVCodecContext *avctx)
// https://code.google.com/p/webm/issues/detail?id=993
uvmv = ROUNDED_DIV_MVx2(b->mv[1][0], b->mv[2][0]);
mc_chroma_dir(s, mc[4][b->filter][0],
- s->dst[1] + 4 * ls_uv, s->dst[2] + 4 * ls_uv, ls_uv,
+ td->dst[1] + 4 * ls_uv, td->dst[2] + 4 * ls_uv, ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
(row << 3) + 4, col << 2,
&uvmv, 0, 4, 4, 8, 4, 4, w1, h1, 0);
} else {
mc_chroma_dir(s, mc[4][b->filter][0],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
row << 3, col << 3,
&b->mv[0][0], 0, 0, 8, 8, 4, 4, w1, h1, 0);
mc_chroma_dir(s, mc[4][b->filter][0],
- s->dst[1] + 4 * bytesperpixel,
- s->dst[2] + 4 * bytesperpixel, ls_uv,
+ td->dst[1] + 4 * bytesperpixel,
+ td->dst[2] + 4 * bytesperpixel, ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
row << 3, (col << 3) + 4,
&b->mv[1][0], 4, 0, 8, 8, 4, 4, w1, h1, 0);
mc_chroma_dir(s, mc[4][b->filter][0],
- s->dst[1] + 4 * ls_uv, s->dst[2] + 4 * ls_uv, ls_uv,
+ td->dst[1] + 4 * ls_uv, td->dst[2] + 4 * ls_uv, ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
(row << 3) + 4, col << 3,
&b->mv[2][0], 0, 4, 8, 8, 4, 4, w1, h1, 0);
mc_chroma_dir(s, mc[4][b->filter][0],
- s->dst[1] + 4 * ls_uv + 4 * bytesperpixel,
- s->dst[2] + 4 * ls_uv + 4 * bytesperpixel, ls_uv,
+ td->dst[1] + 4 * ls_uv + 4 * bytesperpixel,
+ td->dst[2] + 4 * ls_uv + 4 * bytesperpixel, ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
(row << 3) + 4, (col << 3) + 4,
@@ -309,18 +309,18 @@ static void FN(inter_pred)(AVCodecContext *avctx)
}
if (b->comp) {
- mc_luma_dir(s, mc[4][b->filter][1], s->dst[0], ls_y,
+ mc_luma_dir(s, mc[4][b->filter][1], td->dst[0], ls_y,
ref2->data[0], ref2->linesize[0], tref2,
row << 3, col << 3, &b->mv[0][1], 0, 0, 8, 8, 4, 4, w2, h2, 1);
- mc_luma_dir(s, mc[4][b->filter][1], s->dst[0] + 4 * bytesperpixel, ls_y,
+ mc_luma_dir(s, mc[4][b->filter][1], td->dst[0] + 4 * bytesperpixel, ls_y,
ref2->data[0], ref2->linesize[0], tref2,
row << 3, (col << 3) + 4, &b->mv[1][1], 4, 0, 8, 8, 4, 4, w2, h2, 1);
mc_luma_dir(s, mc[4][b->filter][1],
- s->dst[0] + 4 * ls_y, ls_y,
+ td->dst[0] + 4 * ls_y, ls_y,
ref2->data[0], ref2->linesize[0], tref2,
(row << 3) + 4, col << 3, &b->mv[2][1], 0, 4, 8, 8, 4, 4, w2, h2, 1);
mc_luma_dir(s, mc[4][b->filter][1],
- s->dst[0] + 4 * ls_y + 4 * bytesperpixel, ls_y,
+ td->dst[0] + 4 * ls_y + 4 * bytesperpixel, ls_y,
ref2->data[0], ref2->linesize[0], tref2,
(row << 3) + 4, (col << 3) + 4, &b->mv[3][1], 4, 4, 8, 8, 4, 4, w2, h2, 1);
if (s->ss_v) {
@@ -330,7 +330,7 @@ static void FN(inter_pred)(AVCodecContext *avctx)
uvmv = ROUNDED_DIV_MVx4(b->mv[0][1], b->mv[1][1],
b->mv[2][1], b->mv[3][1]);
mc_chroma_dir(s, mc[4][b->filter][1],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
row << 2, col << 2,
@@ -338,15 +338,15 @@ static void FN(inter_pred)(AVCodecContext *avctx)
} else {
uvmv = ROUNDED_DIV_MVx2(b->mv[0][1], b->mv[2][1]);
mc_chroma_dir(s, mc[4][b->filter][1],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
row << 2, col << 3,
&uvmv, 0, 0, 8, 4, 4, 4, w2, h2, 1);
uvmv = ROUNDED_DIV_MVx2(b->mv[1][1], b->mv[3][1]);
mc_chroma_dir(s, mc[4][b->filter][1],
- s->dst[1] + 4 * bytesperpixel,
- s->dst[2] + 4 * bytesperpixel, ls_uv,
+ td->dst[1] + 4 * bytesperpixel,
+ td->dst[2] + 4 * bytesperpixel, ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
row << 2, (col << 3) + 4,
@@ -357,7 +357,7 @@ static void FN(inter_pred)(AVCodecContext *avctx)
w2 = (w2 + 1) >> 1;
uvmv = ROUNDED_DIV_MVx2(b->mv[0][1], b->mv[1][1]);
mc_chroma_dir(s, mc[4][b->filter][1],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
row << 3, col << 2,
@@ -367,34 +367,34 @@ static void FN(inter_pred)(AVCodecContext *avctx)
// https://code.google.com/p/webm/issues/detail?id=993
uvmv = ROUNDED_DIV_MVx2(b->mv[1][1], b->mv[2][1]);
mc_chroma_dir(s, mc[4][b->filter][1],
- s->dst[1] + 4 * ls_uv, s->dst[2] + 4 * ls_uv, ls_uv,
+ td->dst[1] + 4 * ls_uv, td->dst[2] + 4 * ls_uv, ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
(row << 3) + 4, col << 2,
&uvmv, 0, 4, 4, 8, 4, 4, w2, h2, 1);
} else {
mc_chroma_dir(s, mc[4][b->filter][1],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
row << 3, col << 3,
&b->mv[0][1], 0, 0, 8, 8, 4, 4, w2, h2, 1);
mc_chroma_dir(s, mc[4][b->filter][1],
- s->dst[1] + 4 * bytesperpixel,
- s->dst[2] + 4 * bytesperpixel, ls_uv,
+ td->dst[1] + 4 * bytesperpixel,
+ td->dst[2] + 4 * bytesperpixel, ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
row << 3, (col << 3) + 4,
&b->mv[1][1], 4, 0, 8, 8, 4, 4, w2, h2, 1);
mc_chroma_dir(s, mc[4][b->filter][1],
- s->dst[1] + 4 * ls_uv, s->dst[2] + 4 * ls_uv, ls_uv,
+ td->dst[1] + 4 * ls_uv, td->dst[2] + 4 * ls_uv, ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
(row << 3) + 4, col << 3,
&b->mv[2][1], 0, 4, 8, 8, 4, 4, w2, h2, 1);
mc_chroma_dir(s, mc[4][b->filter][1],
- s->dst[1] + 4 * ls_uv + 4 * bytesperpixel,
- s->dst[2] + 4 * ls_uv + 4 * bytesperpixel, ls_uv,
+ td->dst[1] + 4 * ls_uv + 4 * bytesperpixel,
+ td->dst[2] + 4 * ls_uv + 4 * bytesperpixel, ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
(row << 3) + 4, (col << 3) + 4,
@@ -410,26 +410,26 @@ static void FN(inter_pred)(AVCodecContext *avctx)
int uvbw = ff_vp9_bwh_tab[s->ss_h][b->bs][0] * 4;
int uvbh = ff_vp9_bwh_tab[s->ss_v][b->bs][1] * 4;
- mc_luma_dir(s, mc[bwl][b->filter][0], s->dst[0], ls_y,
+ mc_luma_dir(s, mc[bwl][b->filter][0], td->dst[0], ls_y,
ref1->data[0], ref1->linesize[0], tref1,
row << 3, col << 3, &b->mv[0][0], 0, 0, bw, bh, bw, bh, w1, h1, 0);
w1 = (w1 + s->ss_h) >> s->ss_h;
h1 = (h1 + s->ss_v) >> s->ss_v;
mc_chroma_dir(s, mc[bwl + s->ss_h][b->filter][0],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref1->data[1], ref1->linesize[1],
ref1->data[2], ref1->linesize[2], tref1,
row << (3 - s->ss_v), col << (3 - s->ss_h),
&b->mv[0][0], 0, 0, uvbw, uvbh, uvbw, uvbh, w1, h1, 0);
if (b->comp) {
- mc_luma_dir(s, mc[bwl][b->filter][1], s->dst[0], ls_y,
+ mc_luma_dir(s, mc[bwl][b->filter][1], td->dst[0], ls_y,
ref2->data[0], ref2->linesize[0], tref2,
row << 3, col << 3, &b->mv[0][1], 0, 0, bw, bh, bw, bh, w2, h2, 1);
w2 = (w2 + s->ss_h) >> s->ss_h;
h2 = (h2 + s->ss_v) >> s->ss_v;
mc_chroma_dir(s, mc[bwl + s->ss_h][b->filter][1],
- s->dst[1], s->dst[2], ls_uv,
+ td->dst[1], td->dst[2], ls_uv,
ref2->data[1], ref2->linesize[1],
ref2->data[2], ref2->linesize[2], tref2,
row << (3 - s->ss_v), col << (3 - s->ss_h),
@@ -77,7 +77,7 @@ static av_always_inline void setctx_2d(uint8_t *ptr, int w, int h,
}
}
-static void decode_mode(AVCodecContext *avctx)
+static void decode_mode(VP9TileData *td)
{
static const uint8_t left_ctx[N_BS_SIZES] = {
0x0, 0x8, 0x0, 0x8, 0xc, 0x8, 0xc, 0xe, 0xc, 0xe, 0xf, 0xe, 0xf
@@ -89,25 +89,25 @@ static void decode_mode(AVCodecContext *avctx)
TX_32X32, TX_32X32, TX_32X32, TX_32X32, TX_16X16, TX_16X16,
TX_16X16, TX_8X8, TX_8X8, TX_8X8, TX_4X4, TX_4X4, TX_4X4
};
- VP9Context *s = avctx->priv_data;
- VP9Block *b = s->b;
- int row = s->row, col = s->col, row7 = s->row7;
+ VP9Context *s = td->s;
+ VP9Block *b = td->b;
+ int row = td->row, col = td->col, row7 = td->row7;
enum TxfmMode max_tx = max_tx_for_bl_bp[b->bs];
int bw4 = ff_vp9_bwh_tab[1][b->bs][0], w4 = FFMIN(s->cols - col, bw4);
int bh4 = ff_vp9_bwh_tab[1][b->bs][1], h4 = FFMIN(s->rows - row, bh4), y;
- int have_a = row > 0, have_l = col > s->tile_col_start;
+ int have_a = row > 0, have_l = col > td->tile_col_start;
int vref, filter_id;
if (!s->s.h.segmentation.enabled) {
b->seg_id = 0;
} else if (s->s.h.keyframe || s->s.h.intraonly) {
b->seg_id = !s->s.h.segmentation.update_map ? 0 :
- vp8_rac_get_tree(&s->c, ff_vp9_segmentation_tree, s->s.h.segmentation.prob);
+ vp8_rac_get_tree(&td->c, ff_vp9_segmentation_tree, s->s.h.segmentation.prob);
} else if (!s->s.h.segmentation.update_map ||
(s->s.h.segmentation.temporal &&
- vp56_rac_get_prob_branchy(&s->c,
+ vp56_rac_get_prob_branchy(&td->c,
s->s.h.segmentation.pred_prob[s->above_segpred_ctx[col] +
- s->left_segpred_ctx[row7]]))) {
+ td->left_segpred_ctx[row7]]))) {
if (!s->s.h.errorres && s->s.frames[REF_FRAME_SEGMAP].segmentation_map) {
int pred = 8, x;
uint8_t *refsegmap = s->s.frames[REF_FRAME_SEGMAP].segmentation_map;
@@ -126,13 +126,13 @@ static void decode_mode(AVCodecContext *avctx)
}
memset(&s->above_segpred_ctx[col], 1, w4);
- memset(&s->left_segpred_ctx[row7], 1, h4);
+ memset(&td->left_segpred_ctx[row7], 1, h4);
} else {
b->seg_id = vp8_rac_get_tree(&s->c, ff_vp9_segmentation_tree,
s->s.h.segmentation.prob);
memset(&s->above_segpred_ctx[col], 0, w4);
- memset(&s->left_segpred_ctx[row7], 0, h4);
+ memset(&td->left_segpred_ctx[row7], 0, h4);
}
if (s->s.h.segmentation.enabled &&
(s->s.h.segmentation.update_map || s->s.h.keyframe || s->s.h.intraonly)) {
@@ -143,9 +143,9 @@ static void decode_mode(AVCodecContext *avctx)
b->skip = s->s.h.segmentation.enabled &&
s->s.h.segmentation.feat[b->seg_id].skip_enabled;
if (!b->skip) {
- int c = s->left_skip_ctx[row7] + s->above_skip_ctx[col];
- b->skip = vp56_rac_get_prob(&s->c, s->prob.p.skip[c]);
- s->counts.skip[c][b->skip]++;
+ int c = td->left_skip_ctx[row7] + s->above_skip_ctx[col];
+ b->skip = vp56_rac_get_prob(&td->c, s->prob.p.skip[c]);
+ td->counts.skip[c][b->skip]++;
}
if (s->s.h.keyframe || s->s.h.intraonly) {
@@ -156,14 +156,14 @@ static void decode_mode(AVCodecContext *avctx)
int c, bit;
if (have_a && have_l) {
- c = s->above_intra_ctx[col] + s->left_intra_ctx[row7];
+ c = s->above_intra_ctx[col] + td->left_intra_ctx[row7];
c += (c == 2);
} else {
c = have_a ? 2 * s->above_intra_ctx[col] :
- have_l ? 2 * s->left_intra_ctx[row7] : 0;
+ have_l ? 2 * td->left_intra_ctx[row7] : 0;
}
- bit = vp56_rac_get_prob(&s->c, s->prob.p.intra[c]);
- s->counts.intra[c][bit]++;
+ bit = vp56_rac_get_prob(&td->c, s->prob.p.intra[c]);
+ td->counts.intra[c][bit]++;
b->intra = !bit;
}
@@ -173,37 +173,37 @@ static void decode_mode(AVCodecContext *avctx)
if (have_l) {
c = (s->above_skip_ctx[col] ? max_tx :
s->above_txfm_ctx[col]) +
- (s->left_skip_ctx[row7] ? max_tx :
- s->left_txfm_ctx[row7]) > max_tx;
+ (td->left_skip_ctx[row7] ? max_tx :
+ td->left_txfm_ctx[row7]) > max_tx;
} else {
c = s->above_skip_ctx[col] ? 1 :
(s->above_txfm_ctx[col] * 2 > max_tx);
}
} else if (have_l) {
- c = s->left_skip_ctx[row7] ? 1 :
- (s->left_txfm_ctx[row7] * 2 > max_tx);
+ c = td->left_skip_ctx[row7] ? 1 :
+ (td->left_txfm_ctx[row7] * 2 > max_tx);
} else {
c = 1;
}
switch (max_tx) {
case TX_32X32:
- b->tx = vp56_rac_get_prob(&s->c, s->prob.p.tx32p[c][0]);
+ b->tx = vp56_rac_get_prob(&td->c, s->prob.p.tx32p[c][0]);
if (b->tx) {
- b->tx += vp56_rac_get_prob(&s->c, s->prob.p.tx32p[c][1]);
+ b->tx += vp56_rac_get_prob(&td->c, s->prob.p.tx32p[c][1]);
if (b->tx == 2)
- b->tx += vp56_rac_get_prob(&s->c, s->prob.p.tx32p[c][2]);
+ b->tx += vp56_rac_get_prob(&td->c, s->prob.p.tx32p[c][2]);
}
- s->counts.tx32p[c][b->tx]++;
+ td->counts.tx32p[c][b->tx]++;
break;
case TX_16X16:
- b->tx = vp56_rac_get_prob(&s->c, s->prob.p.tx16p[c][0]);
+ b->tx = vp56_rac_get_prob(&td->c, s->prob.p.tx16p[c][0]);
if (b->tx)
- b->tx += vp56_rac_get_prob(&s->c, s->prob.p.tx16p[c][1]);
- s->counts.tx16p[c][b->tx]++;
+ b->tx += vp56_rac_get_prob(&td->c, s->prob.p.tx16p[c][1]);
+ td->counts.tx16p[c][b->tx]++;
break;
case TX_8X8:
- b->tx = vp56_rac_get_prob(&s->c, s->prob.p.tx8p[c]);
- s->counts.tx8p[c][b->tx]++;
+ b->tx = vp56_rac_get_prob(&td->c, s->prob.p.tx8p[c]);
+ td->counts.tx8p[c][b->tx]++;
break;
case TX_4X4:
b->tx = TX_4X4;
@@ -215,7 +215,7 @@ static void decode_mode(AVCodecContext *avctx)
if (s->s.h.keyframe || s->s.h.intraonly) {
uint8_t *a = &s->above_mode_ctx[col * 2];
- uint8_t *l = &s->left_mode_ctx[(row7) << 1];
+ uint8_t *l = &td->left_mode_ctx[(row7) << 1];
b->comp = 0;
if (b->bs > BS_8x8) {
@@ -223,10 +223,10 @@ static void decode_mode(AVCodecContext *avctx)
// necessary, they're just there to make the code slightly
// simpler for now
b->mode[0] =
- a[0] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
+ a[0] = vp8_rac_get_tree(&td->c, ff_vp9_intramode_tree,
ff_vp9_default_kf_ymode_probs[a[0]][l[0]]);
if (b->bs != BS_8x4) {
- b->mode[1] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
+ b->mode[1] = vp8_rac_get_tree(&td->c, ff_vp9_intramode_tree,
ff_vp9_default_kf_ymode_probs[a[1]][b->mode[0]]);
l[0] =
a[1] = b->mode[1];
@@ -237,10 +237,10 @@ static void decode_mode(AVCodecContext *avctx)
}
if (b->bs != BS_4x8) {
b->mode[2] =
- a[0] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
+ a[0] = vp8_rac_get_tree(&td->c, ff_vp9_intramode_tree,
ff_vp9_default_kf_ymode_probs[a[0]][l[1]]);
if (b->bs != BS_8x4) {
- b->mode[3] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
+ b->mode[3] = vp8_rac_get_tree(&td->c, ff_vp9_intramode_tree,
ff_vp9_default_kf_ymode_probs[a[1]][b->mode[2]]);
l[1] =
a[1] = b->mode[3];
@@ -256,7 +256,7 @@ static void decode_mode(AVCodecContext *avctx)
b->mode[3] = b->mode[1];
}
} else {
- b->mode[0] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
+ b->mode[0] = vp8_rac_get_tree(&td->c, ff_vp9_intramode_tree,
ff_vp9_default_kf_ymode_probs[*a][*l]);
b->mode[3] =
b->mode[2] =
@@ -265,29 +265,29 @@ static void decode_mode(AVCodecContext *avctx)
memset(a, b->mode[0], ff_vp9_bwh_tab[0][b->bs][0]);
memset(l, b->mode[0], ff_vp9_bwh_tab[0][b->bs][1]);
}
- b->uvmode = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
+ b->uvmode = vp8_rac_get_tree(&td->c, ff_vp9_intramode_tree,
ff_vp9_default_kf_uvmode_probs[b->mode[3]]);
} else if (b->intra) {
b->comp = 0;
if (b->bs > BS_8x8) {
- b->mode[0] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
+ b->mode[0] = vp8_rac_get_tree(&td->c, ff_vp9_intramode_tree,
s->prob.p.y_mode[0]);
- s->counts.y_mode[0][b->mode[0]]++;
+ td->counts.y_mode[0][b->mode[0]]++;
if (b->bs != BS_8x4) {
- b->mode[1] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
+ b->mode[1] = vp8_rac_get_tree(&td->c, ff_vp9_intramode_tree,
s->prob.p.y_mode[0]);
- s->counts.y_mode[0][b->mode[1]]++;
+ td->counts.y_mode[0][b->mode[1]]++;
} else {
b->mode[1] = b->mode[0];
}
if (b->bs != BS_4x8) {
- b->mode[2] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
+ b->mode[2] = vp8_rac_get_tree(&td->c, ff_vp9_intramode_tree,
s->prob.p.y_mode[0]);
- s->counts.y_mode[0][b->mode[2]]++;
+ td->counts.y_mode[0][b->mode[2]]++;
if (b->bs != BS_8x4) {
- b->mode[3] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
+ b->mode[3] = vp8_rac_get_tree(&td->c, ff_vp9_intramode_tree,
s->prob.p.y_mode[0]);
- s->counts.y_mode[0][b->mode[3]]++;
+ td->counts.y_mode[0][b->mode[3]]++;
} else {
b->mode[3] = b->mode[2];
}
@@ -301,16 +301,16 @@ static void decode_mode(AVCodecContext *avctx)
};
int sz = size_group[b->bs];
- b->mode[0] = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
+ b->mode[0] = vp8_rac_get_tree(&td->c, ff_vp9_intramode_tree,
s->prob.p.y_mode[sz]);
b->mode[1] =
b->mode[2] =
b->mode[3] = b->mode[0];
- s->counts.y_mode[sz][b->mode[3]]++;
+ td->counts.y_mode[sz][b->mode[3]]++;
}
- b->uvmode = vp8_rac_get_tree(&s->c, ff_vp9_intramode_tree,
+ b->uvmode = vp8_rac_get_tree(&td->c, ff_vp9_intramode_tree,
s->prob.p.uv_mode[b->mode[3]]);
- s->counts.uv_mode[b->mode[3]][b->uvmode]++;
+ td->counts.uv_mode[b->mode[3]][b->uvmode]++;
} else {
static const uint8_t inter_mode_ctx_lut[14][14] = {
{ 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
@@ -343,32 +343,32 @@ static void decode_mode(AVCodecContext *avctx)
// FIXME add intra as ref=0xff (or -1) to make these easier?
if (have_a) {
if (have_l) {
- if (s->above_comp_ctx[col] && s->left_comp_ctx[row7]) {
+ if (s->above_comp_ctx[col] && td->left_comp_ctx[row7]) {
c = 4;
} else if (s->above_comp_ctx[col]) {
- c = 2 + (s->left_intra_ctx[row7] ||
- s->left_ref_ctx[row7] == s->s.h.fixcompref);
- } else if (s->left_comp_ctx[row7]) {
+ c = 2 + (td->left_intra_ctx[row7] ||
+ td->left_ref_ctx[row7] == s->s.h.fixcompref);
+ } else if (td->left_comp_ctx[row7]) {
c = 2 + (s->above_intra_ctx[col] ||
s->above_ref_ctx[col] == s->s.h.fixcompref);
} else {
c = (!s->above_intra_ctx[col] &&
s->above_ref_ctx[col] == s->s.h.fixcompref) ^
- (!s->left_intra_ctx[row7] &&
- s->left_ref_ctx[row & 7] == s->s.h.fixcompref);
+ (!td->left_intra_ctx[row7] &&
+ td->left_ref_ctx[row & 7] == s->s.h.fixcompref);
}
} else {
c = s->above_comp_ctx[col] ? 3 :
(!s->above_intra_ctx[col] && s->above_ref_ctx[col] == s->s.h.fixcompref);
}
} else if (have_l) {
- c = s->left_comp_ctx[row7] ? 3 :
- (!s->left_intra_ctx[row7] && s->left_ref_ctx[row7] == s->s.h.fixcompref);
+ c = td->left_comp_ctx[row7] ? 3 :
+ (!td->left_intra_ctx[row7] && td->left_ref_ctx[row7] == s->s.h.fixcompref);
} else {
c = 1;
}
- b->comp = vp56_rac_get_prob(&s->c, s->prob.p.comp[c]);
- s->counts.comp[c][b->comp]++;
+ b->comp = vp56_rac_get_prob(&td->c, s->prob.p.comp[c]);
+ td->counts.comp[c][b->comp]++;
}
// read actual references
@@ -382,26 +382,26 @@ static void decode_mode(AVCodecContext *avctx)
if (have_a) {
if (have_l) {
if (s->above_intra_ctx[col]) {
- if (s->left_intra_ctx[row7]) {
+ if (td->left_intra_ctx[row7]) {
c = 2;
} else {
- c = 1 + 2 * (s->left_ref_ctx[row7] != s->s.h.varcompref[1]);
+ c = 1 + 2 * (td->left_ref_ctx[row7] != s->s.h.varcompref[1]);
}
- } else if (s->left_intra_ctx[row7]) {
+ } else if (td->left_intra_ctx[row7]) {
c = 1 + 2 * (s->above_ref_ctx[col] != s->s.h.varcompref[1]);
} else {
- int refl = s->left_ref_ctx[row7], refa = s->above_ref_ctx[col];
+ int refl = td->left_ref_ctx[row7], refa = s->above_ref_ctx[col];
if (refl == refa && refa == s->s.h.varcompref[1]) {
c = 0;
- } else if (!s->left_comp_ctx[row7] && !s->above_comp_ctx[col]) {
+ } else if (!td->left_comp_ctx[row7] && !s->above_comp_ctx[col]) {
if ((refa == s->s.h.fixcompref && refl == s->s.h.varcompref[0]) ||
(refl == s->s.h.fixcompref && refa == s->s.h.varcompref[0])) {
c = 4;
} else {
c = (refa == refl) ? 3 : 1;
}
- } else if (!s->left_comp_ctx[row7]) {
+ } else if (!td->left_comp_ctx[row7]) {
if (refa == s->s.h.varcompref[1] && refl != s->s.h.varcompref[1]) {
c = 1;
} else {
@@ -429,37 +429,37 @@ static void decode_mode(AVCodecContext *avctx)
}
}
} else if (have_l) {
- if (s->left_intra_ctx[row7]) {
+ if (td->left_intra_ctx[row7]) {
c = 2;
- } else if (s->left_comp_ctx[row7]) {
- c = 4 * (s->left_ref_ctx[row7] != s->s.h.varcompref[1]);
+ } else if (td->left_comp_ctx[row7]) {
+ c = 4 * (td->left_ref_ctx[row7] != s->s.h.varcompref[1]);
} else {
- c = 3 * (s->left_ref_ctx[row7] != s->s.h.varcompref[1]);
+ c = 3 * (td->left_ref_ctx[row7] != s->s.h.varcompref[1]);
}
} else {
c = 2;
}
- bit = vp56_rac_get_prob(&s->c, s->prob.p.comp_ref[c]);
+ bit = vp56_rac_get_prob(&td->c, s->prob.p.comp_ref[c]);
b->ref[var_idx] = s->s.h.varcompref[bit];
- s->counts.comp_ref[c][bit]++;
+ td->counts.comp_ref[c][bit]++;
} else /* single reference */ {
int bit, c;
if (have_a && !s->above_intra_ctx[col]) {
- if (have_l && !s->left_intra_ctx[row7]) {
- if (s->left_comp_ctx[row7]) {
+ if (have_l && !td->left_intra_ctx[row7]) {
+ if (td->left_comp_ctx[row7]) {
if (s->above_comp_ctx[col]) {
- c = 1 + (!s->s.h.fixcompref || !s->left_ref_ctx[row7] ||
+ c = 1 + (!s->s.h.fixcompref || !td->left_ref_ctx[row7] ||
!s->above_ref_ctx[col]);
} else {
c = (3 * !s->above_ref_ctx[col]) +
- (!s->s.h.fixcompref || !s->left_ref_ctx[row7]);
+ (!s->s.h.fixcompref || !td->left_ref_ctx[row7]);
}
} else if (s->above_comp_ctx[col]) {
- c = (3 * !s->left_ref_ctx[row7]) +
+ c = (3 * !td->left_ref_ctx[row7]) +
(!s->s.h.fixcompref || !s->above_ref_ctx[col]);
} else {
- c = 2 * !s->left_ref_ctx[row7] + 2 * !s->above_ref_ctx[col];
+ c = 2 * !td->left_ref_ctx[row7] + 2 * !s->above_ref_ctx[col];
}
} else if (s->above_intra_ctx[col]) {
c = 2;
@@ -468,26 +468,26 @@ static void decode_mode(AVCodecContext *avctx)
} else {
c = 4 * (!s->above_ref_ctx[col]);
}
- } else if (have_l && !s->left_intra_ctx[row7]) {
- if (s->left_intra_ctx[row7]) {
+ } else if (have_l && !td->left_intra_ctx[row7]) {
+ if (td->left_intra_ctx[row7]) {
c = 2;
- } else if (s->left_comp_ctx[row7]) {
- c = 1 + (!s->s.h.fixcompref || !s->left_ref_ctx[row7]);
+ } else if (td->left_comp_ctx[row7]) {
+ c = 1 + (!s->s.h.fixcompref || !td->left_ref_ctx[row7]);
} else {
- c = 4 * (!s->left_ref_ctx[row7]);
+ c = 4 * (!td->left_ref_ctx[row7]);
}
} else {
c = 2;
}
- bit = vp56_rac_get_prob(&s->c, s->prob.p.single_ref[c][0]);
- s->counts.single_ref[c][0][bit]++;
+ bit = vp56_rac_get_prob(&td->c, s->prob.p.single_ref[c][0]);
+ td->counts.single_ref[c][0][bit]++;
if (!bit) {
b->ref[0] = 0;
} else {
// FIXME can this codeblob be replaced by some sort of LUT?
if (have_a) {
if (have_l) {
- if (s->left_intra_ctx[row7]) {
+ if (td->left_intra_ctx[row7]) {
if (s->above_intra_ctx[col]) {
c = 2;
} else if (s->above_comp_ctx[col]) {
@@ -499,49 +499,49 @@ static void decode_mode(AVCodecContext *avctx)
c = 4 * (s->above_ref_ctx[col] == 1);
}
} else if (s->above_intra_ctx[col]) {
- if (s->left_intra_ctx[row7]) {
+ if (td->left_intra_ctx[row7]) {
c = 2;
- } else if (s->left_comp_ctx[row7]) {
+ } else if (td->left_comp_ctx[row7]) {
c = 1 + 2 * (s->s.h.fixcompref == 1 ||
- s->left_ref_ctx[row7] == 1);
- } else if (!s->left_ref_ctx[row7]) {
+ td->left_ref_ctx[row7] == 1);
+ } else if (!td->left_ref_ctx[row7]) {
c = 3;
} else {
- c = 4 * (s->left_ref_ctx[row7] == 1);
+ c = 4 * (td->left_ref_ctx[row7] == 1);
}
} else if (s->above_comp_ctx[col]) {
- if (s->left_comp_ctx[row7]) {
- if (s->left_ref_ctx[row7] == s->above_ref_ctx[col]) {
+ if (td->left_comp_ctx[row7]) {
+ if (td->left_ref_ctx[row7] == s->above_ref_ctx[col]) {
c = 3 * (s->s.h.fixcompref == 1 ||
- s->left_ref_ctx[row7] == 1);
+ td->left_ref_ctx[row7] == 1);
} else {
c = 2;
}
- } else if (!s->left_ref_ctx[row7]) {
+ } else if (!td->left_ref_ctx[row7]) {
c = 1 + 2 * (s->s.h.fixcompref == 1 ||
s->above_ref_ctx[col] == 1);
} else {
- c = 3 * (s->left_ref_ctx[row7] == 1) +
+ c = 3 * (td->left_ref_ctx[row7] == 1) +
(s->s.h.fixcompref == 1 || s->above_ref_ctx[col] == 1);
}
- } else if (s->left_comp_ctx[row7]) {
+ } else if (td->left_comp_ctx[row7]) {
if (!s->above_ref_ctx[col]) {
c = 1 + 2 * (s->s.h.fixcompref == 1 ||
- s->left_ref_ctx[row7] == 1);
+ td->left_ref_ctx[row7] == 1);
} else {
c = 3 * (s->above_ref_ctx[col] == 1) +
- (s->s.h.fixcompref == 1 || s->left_ref_ctx[row7] == 1);
+ (s->s.h.fixcompref == 1 || td->left_ref_ctx[row7] == 1);
}
} else if (!s->above_ref_ctx[col]) {
- if (!s->left_ref_ctx[row7]) {
+ if (!td->left_ref_ctx[row7]) {
c = 3;
} else {
- c = 4 * (s->left_ref_ctx[row7] == 1);
+ c = 4 * (td->left_ref_ctx[row7] == 1);
}
- } else if (!s->left_ref_ctx[row7]) {
+ } else if (!td->left_ref_ctx[row7]) {
c = 4 * (s->above_ref_ctx[col] == 1);
} else {
- c = 2 * (s->left_ref_ctx[row7] == 1) +
+ c = 2 * (td->left_ref_ctx[row7] == 1) +
2 * (s->above_ref_ctx[col] == 1);
}
} else {
@@ -555,19 +555,19 @@ static void decode_mode(AVCodecContext *avctx)
}
}
} else if (have_l) {
- if (s->left_intra_ctx[row7] ||
- (!s->left_comp_ctx[row7] && !s->left_ref_ctx[row7])) {
+ if (td->left_intra_ctx[row7] ||
+ (!td->left_comp_ctx[row7] && !td->left_ref_ctx[row7])) {
c = 2;
- } else if (s->left_comp_ctx[row7]) {
- c = 3 * (s->s.h.fixcompref == 1 || s->left_ref_ctx[row7] == 1);
+ } else if (td->left_comp_ctx[row7]) {
+ c = 3 * (s->s.h.fixcompref == 1 || td->left_ref_ctx[row7] == 1);
} else {
- c = 4 * (s->left_ref_ctx[row7] == 1);
+ c = 4 * (td->left_ref_ctx[row7] == 1);
}
} else {
c = 2;
}
- bit = vp56_rac_get_prob(&s->c, s->prob.p.single_ref[c][1]);
- s->counts.single_ref[c][1][bit]++;
+ bit = vp56_rac_get_prob(&td->c, s->prob.p.single_ref[c][1]);
+ td->counts.single_ref[c][1][bit]++;
b->ref[0] = 1 + bit;
}
}
@@ -587,14 +587,14 @@ static void decode_mode(AVCodecContext *avctx)
// FIXME this needs to use the LUT tables from find_ref_mvs
// because not all are -1,0/0,-1
int c = inter_mode_ctx_lut[s->above_mode_ctx[col + off[b->bs]]]
- [s->left_mode_ctx[row7 + off[b->bs]]];
+ [td->left_mode_ctx[row7 + off[b->bs]]];
- b->mode[0] = vp8_rac_get_tree(&s->c, ff_vp9_inter_mode_tree,
+ b->mode[0] = vp8_rac_get_tree(&td->c, ff_vp9_inter_mode_tree,
s->prob.p.mv_mode[c]);
b->mode[1] =
b->mode[2] =
b->mode[3] = b->mode[0];
- s->counts.mv_mode[c][b->mode[0] - 10]++;
+ td->counts.mv_mode[c][b->mode[0] - 10]++;
}
}
@@ -602,39 +602,39 @@ static void decode_mode(AVCodecContext *avctx)
int c;
if (have_a && s->above_mode_ctx[col] >= NEARESTMV) {
- if (have_l && s->left_mode_ctx[row7] >= NEARESTMV) {
- c = s->above_filter_ctx[col] == s->left_filter_ctx[row7] ?
- s->left_filter_ctx[row7] : 3;
+ if (have_l && td->left_mode_ctx[row7] >= NEARESTMV) {
+ c = s->above_filter_ctx[col] == td->left_filter_ctx[row7] ?
+ td->left_filter_ctx[row7] : 3;
} else {
c = s->above_filter_ctx[col];
}
- } else if (have_l && s->left_mode_ctx[row7] >= NEARESTMV) {
- c = s->left_filter_ctx[row7];
+ } else if (have_l && td->left_mode_ctx[row7] >= NEARESTMV) {
+ c = td->left_filter_ctx[row7];
} else {
c = 3;
}
- filter_id = vp8_rac_get_tree(&s->c, ff_vp9_filter_tree,
+ filter_id = vp8_rac_get_tree(&td->c, ff_vp9_filter_tree,
s->prob.p.filter[c]);
- s->counts.filter[c][filter_id]++;
+ td->counts.filter[c][filter_id]++;
b->filter = ff_vp9_filter_lut[filter_id];
} else {
b->filter = s->s.h.filtermode;
}
if (b->bs > BS_8x8) {
- int c = inter_mode_ctx_lut[s->above_mode_ctx[col]][s->left_mode_ctx[row7]];
+ int c = inter_mode_ctx_lut[s->above_mode_ctx[col]][td->left_mode_ctx[row7]];
- b->mode[0] = vp8_rac_get_tree(&s->c, ff_vp9_inter_mode_tree,
+ b->mode[0] = vp8_rac_get_tree(&td->c, ff_vp9_inter_mode_tree,
s->prob.p.mv_mode[c]);
- s->counts.mv_mode[c][b->mode[0] - 10]++;
- ff_vp9_fill_mv(s, b->mv[0], b->mode[0], 0);
+ td->counts.mv_mode[c][b->mode[0] - 10]++;
+ ff_vp9_fill_mv(td, b->mv[0], b->mode[0], 0);
if (b->bs != BS_8x4) {
- b->mode[1] = vp8_rac_get_tree(&s->c, ff_vp9_inter_mode_tree,
+ b->mode[1] = vp8_rac_get_tree(&td->c, ff_vp9_inter_mode_tree,
s->prob.p.mv_mode[c]);
- s->counts.mv_mode[c][b->mode[1] - 10]++;
- ff_vp9_fill_mv(s, b->mv[1], b->mode[1], 1);
+ td->counts.mv_mode[c][b->mode[1] - 10]++;
+ ff_vp9_fill_mv(td, b->mv[1], b->mode[1], 1);
} else {
b->mode[1] = b->mode[0];
AV_COPY32(&b->mv[1][0], &b->mv[0][0]);
@@ -642,16 +642,16 @@ static void decode_mode(AVCodecContext *avctx)
}
if (b->bs != BS_4x8) {
- b->mode[2] = vp8_rac_get_tree(&s->c, ff_vp9_inter_mode_tree,
+ b->mode[2] = vp8_rac_get_tree(&td->c, ff_vp9_inter_mode_tree,
s->prob.p.mv_mode[c]);
- s->counts.mv_mode[c][b->mode[2] - 10]++;
- ff_vp9_fill_mv(s, b->mv[2], b->mode[2], 2);
+ td->counts.mv_mode[c][b->mode[2] - 10]++;
+ ff_vp9_fill_mv(td, b->mv[2], b->mode[2], 2);
if (b->bs != BS_8x4) {
- b->mode[3] = vp8_rac_get_tree(&s->c, ff_vp9_inter_mode_tree,
+ b->mode[3] = vp8_rac_get_tree(&td->c, ff_vp9_inter_mode_tree,
s->prob.p.mv_mode[c]);
- s->counts.mv_mode[c][b->mode[3] - 10]++;
- ff_vp9_fill_mv(s, b->mv[3], b->mode[3], 3);
+ td->counts.mv_mode[c][b->mode[3] - 10]++;
+ ff_vp9_fill_mv(td, b->mv[3], b->mode[3], 3);
} else {
b->mode[3] = b->mode[2];
AV_COPY32(&b->mv[3][0], &b->mv[2][0]);
@@ -666,7 +666,7 @@ static void decode_mode(AVCodecContext *avctx)
AV_COPY32(&b->mv[3][1], &b->mv[1][1]);
}
} else {
- ff_vp9_fill_mv(s, b->mv[0], b->mode[0], -1);
+ ff_vp9_fill_mv(td, b->mv[0], b->mode[0], -1);
AV_COPY32(&b->mv[1][0], &b->mv[0][0]);
AV_COPY32(&b->mv[2][0], &b->mv[0][0]);
AV_COPY32(&b->mv[3][0], &b->mv[0][0]);
@@ -716,33 +716,33 @@ static void decode_mode(AVCodecContext *avctx)
#endif
switch (ff_vp9_bwh_tab[1][b->bs][0]) {
-#define SET_CTXS(dir, off, n) \
+#define SET_CTXS(perf, dir, off, n) \
do { \
- SPLAT_CTX(s->dir##_skip_ctx[off], b->skip, n); \
- SPLAT_CTX(s->dir##_txfm_ctx[off], b->tx, n); \
- SPLAT_CTX(s->dir##_partition_ctx[off], dir##_ctx[b->bs], n); \
+ SPLAT_CTX(perf->dir##_skip_ctx[off], b->skip, n); \
+ SPLAT_CTX(perf->dir##_txfm_ctx[off], b->tx, n); \
+ SPLAT_CTX(perf->dir##_partition_ctx[off], dir##_ctx[b->bs], n); \
if (!s->s.h.keyframe && !s->s.h.intraonly) { \
- SPLAT_CTX(s->dir##_intra_ctx[off], b->intra, n); \
- SPLAT_CTX(s->dir##_comp_ctx[off], b->comp, n); \
- SPLAT_CTX(s->dir##_mode_ctx[off], b->mode[3], n); \
+ SPLAT_CTX(perf->dir##_intra_ctx[off], b->intra, n); \
+ SPLAT_CTX(perf->dir##_comp_ctx[off], b->comp, n); \
+ SPLAT_CTX(perf->dir##_mode_ctx[off], b->mode[3], n); \
if (!b->intra) { \
- SPLAT_CTX(s->dir##_ref_ctx[off], vref, n); \
+ SPLAT_CTX(perf->dir##_ref_ctx[off], vref, n); \
if (s->s.h.filtermode == FILTER_SWITCHABLE) { \
- SPLAT_CTX(s->dir##_filter_ctx[off], filter_id, n); \
+ SPLAT_CTX(perf->dir##_filter_ctx[off], filter_id, n); \
} \
} \
} \
} while (0)
- case 1: SET_CTXS(above, col, 1); break;
- case 2: SET_CTXS(above, col, 2); break;
- case 4: SET_CTXS(above, col, 4); break;
- case 8: SET_CTXS(above, col, 8); break;
+ case 1: SET_CTXS(s, above, col, 1); break;
+ case 2: SET_CTXS(s, above, col, 2); break;
+ case 4: SET_CTXS(s, above, col, 4); break;
+ case 8: SET_CTXS(s, above, col, 8); break;
}
switch (ff_vp9_bwh_tab[1][b->bs][1]) {
- case 1: SET_CTXS(left, row7, 1); break;
- case 2: SET_CTXS(left, row7, 2); break;
- case 4: SET_CTXS(left, row7, 4); break;
- case 8: SET_CTXS(left, row7, 8); break;
+ case 1: SET_CTXS(td, left, row7, 1); break;
+ case 2: SET_CTXS(td, left, row7, 2); break;
+ case 4: SET_CTXS(td, left, row7, 4); break;
+ case 8: SET_CTXS(td, left, row7, 8); break;
}
#undef SPLAT_CTX
#undef SET_CTXS
@@ -751,10 +751,10 @@ static void decode_mode(AVCodecContext *avctx)
if (b->bs > BS_8x8) {
int mv0 = AV_RN32A(&b->mv[3][0]), mv1 = AV_RN32A(&b->mv[3][1]);
- AV_COPY32(&s->left_mv_ctx[row7 * 2 + 0][0], &b->mv[1][0]);
- AV_COPY32(&s->left_mv_ctx[row7 * 2 + 0][1], &b->mv[1][1]);
- AV_WN32A(&s->left_mv_ctx[row7 * 2 + 1][0], mv0);
- AV_WN32A(&s->left_mv_ctx[row7 * 2 + 1][1], mv1);
+ AV_COPY32(&td->left_mv_ctx[row7 * 2 + 0][0], &b->mv[1][0]);
+ AV_COPY32(&td->left_mv_ctx[row7 * 2 + 0][1], &b->mv[1][1]);
+ AV_WN32A(&td->left_mv_ctx[row7 * 2 + 1][0], mv0);
+ AV_WN32A(&td->left_mv_ctx[row7 * 2 + 1][1], mv1);
AV_COPY32(&s->above_mv_ctx[col * 2 + 0][0], &b->mv[2][0]);
AV_COPY32(&s->above_mv_ctx[col * 2 + 0][1], &b->mv[2][1]);
AV_WN32A(&s->above_mv_ctx[col * 2 + 1][0], mv0);
@@ -767,8 +767,8 @@ static void decode_mode(AVCodecContext *avctx)
AV_WN32A(&s->above_mv_ctx[col * 2 + n][1], mv1);
}
for (n = 0; n < h4 * 2; n++) {
- AV_WN32A(&s->left_mv_ctx[row7 * 2 + n][0], mv0);
- AV_WN32A(&s->left_mv_ctx[row7 * 2 + n][1], mv1);
+ AV_WN32A(&td->left_mv_ctx[row7 * 2 + n][0], mv0);
+ AV_WN32A(&td->left_mv_ctx[row7 * 2 + n][1], mv1);
}
}
}
@@ -925,54 +925,54 @@ skip_eob:
return i;
}
-static int decode_coeffs_b_8bpp(VP9Context *s, int16_t *coef, int n_coeffs,
+static int decode_coeffs_b_8bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
unsigned (*cnt)[6][3], unsigned (*eob)[6][2],
uint8_t (*p)[6][11], int nnz, const int16_t *scan,
const int16_t (*nb)[2], const int16_t *band_counts,
const int16_t *qmul)
{
- return decode_coeffs_b_generic(&s->c, coef, n_coeffs, 0, 1, 8, cnt, eob, p,
+ return decode_coeffs_b_generic(&td->c, coef, n_coeffs, 0, 1, 8, cnt, eob, p,
nnz, scan, nb, band_counts, qmul);
}
-static int decode_coeffs_b32_8bpp(VP9Context *s, int16_t *coef, int n_coeffs,
+static int decode_coeffs_b32_8bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
unsigned (*cnt)[6][3], unsigned (*eob)[6][2],
uint8_t (*p)[6][11], int nnz, const int16_t *scan,
const int16_t (*nb)[2], const int16_t *band_counts,
const int16_t *qmul)
{
- return decode_coeffs_b_generic(&s->c, coef, n_coeffs, 1, 1, 8, cnt, eob, p,
+ return decode_coeffs_b_generic(&td->c, coef, n_coeffs, 1, 1, 8, cnt, eob, p,
nnz, scan, nb, band_counts, qmul);
}
-static int decode_coeffs_b_16bpp(VP9Context *s, int16_t *coef, int n_coeffs,
+static int decode_coeffs_b_16bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
unsigned (*cnt)[6][3], unsigned (*eob)[6][2],
uint8_t (*p)[6][11], int nnz, const int16_t *scan,
const int16_t (*nb)[2], const int16_t *band_counts,
const int16_t *qmul)
{
- return decode_coeffs_b_generic(&s->c, coef, n_coeffs, 0, 0, s->s.h.bpp, cnt, eob, p,
+ return decode_coeffs_b_generic(&td->c, coef, n_coeffs, 0, 0, td->s->s.h.bpp, cnt, eob, p,
nnz, scan, nb, band_counts, qmul);
}
-static int decode_coeffs_b32_16bpp(VP9Context *s, int16_t *coef, int n_coeffs,
+static int decode_coeffs_b32_16bpp(VP9TileData *td, int16_t *coef, int n_coeffs,
unsigned (*cnt)[6][3], unsigned (*eob)[6][2],
uint8_t (*p)[6][11], int nnz, const int16_t *scan,
const int16_t (*nb)[2], const int16_t *band_counts,
const int16_t *qmul)
{
- return decode_coeffs_b_generic(&s->c, coef, n_coeffs, 1, 0, s->s.h.bpp, cnt, eob, p,
+ return decode_coeffs_b_generic(&td->c, coef, n_coeffs, 1, 0, td->s->s.h.bpp, cnt, eob, p,
nnz, scan, nb, band_counts, qmul);
}
-static av_always_inline int decode_coeffs(AVCodecContext *avctx, int is8bitsperpixel)
+static av_always_inline int decode_coeffs(VP9TileData *td, int is8bitsperpixel)
{
- VP9Context *s = avctx->priv_data;
- VP9Block *b = s->b;
- int row = s->row, col = s->col;
+ VP9Context *s = td->s;
+ VP9Block *b = td->b;
+ int row = td->row, col = td->col;
uint8_t (*p)[6][11] = s->prob.coef[b->tx][0 /* y */][!b->intra];
- unsigned (*c)[6][3] = s->counts.coef[b->tx][0 /* y */][!b->intra];
- unsigned (*e)[6][2] = s->counts.eob[b->tx][0 /* y */][!b->intra];
+ unsigned (*c)[6][3] = td->counts.coef[b->tx][0 /* y */][!b->intra];
+ unsigned (*e)[6][2] = td->counts.eob[b->tx][0 /* y */][!b->intra];
int w4 = ff_vp9_bwh_tab[1][b->bs][0] << 1, h4 = ff_vp9_bwh_tab[1][b->bs][1] << 1;
int end_x = FFMIN(2 * (s->cols - col), w4);
int end_y = FFMIN(2 * (s->rows - row), h4);
@@ -984,7 +984,7 @@ static av_always_inline int decode_coeffs(AVCodecContext *avctx, int is8bitsperp
const int16_t *uvscan = ff_vp9_scans[b->uvtx][DCT_DCT];
const int16_t (*uvnb)[2] = ff_vp9_scans_nb[b->uvtx][DCT_DCT];
uint8_t *a = &s->above_y_nnz_ctx[col * 2];
- uint8_t *l = &s->left_y_nnz_ctx[(row & 7) << 1];
+ uint8_t *l = &td->left_y_nnz_ctx[(row & 7) << 1];
static const int16_t band_counts[4][8] = {
{ 1, 2, 3, 4, 3, 16 - 13 },
{ 1, 2, 3, 4, 11, 64 - 21 },
@@ -1010,15 +1010,15 @@ static av_always_inline int decode_coeffs(AVCodecContext *avctx, int is8bitsperp
for (x = 0; x < end_x; x += step, n += step * step) { \
enum TxfmType txtp = ff_vp9_intra_txfm_type[b->mode[mode_index]]; \
ret = (is8bitsperpixel ? decode_coeffs_b##v##_8bpp : decode_coeffs_b##v##_16bpp) \
- (s, s->block + 16 * n * bytesperpixel, 16 * step * step, \
+ (td, td->block + 16 * n * bytesperpixel, 16 * step * step, \
c, e, p, a[x] + l[y], yscans[txtp], \
ynbs[txtp], y_band_counts, qmul[0]); \
a[x] = l[y] = !!ret; \
total_coeff |= !!ret; \
if (step >= 4) { \
- AV_WN16A(&s->eob[n], ret); \
+ AV_WN16A(&td->eob[n], ret); \
} else { \
- s->eob[n] = ret; \
+ td->eob[n] = ret; \
} \
} \
}
@@ -1084,29 +1084,29 @@ static av_always_inline int decode_coeffs(AVCodecContext *avctx, int is8bitsperp
for (n = 0, y = 0; y < end_y; y += step) { \
for (x = 0; x < end_x; x += step, n += step * step) { \
ret = (is8bitsperpixel ? decode_coeffs_b##v##_8bpp : decode_coeffs_b##v##_16bpp) \
- (s, s->uvblock[pl] + 16 * n * bytesperpixel, \
+ (td, td->uvblock[pl] + 16 * n * bytesperpixel, \
16 * step * step, c, e, p, a[x] + l[y], \
uvscan, uvnb, uv_band_counts, qmul[1]); \
a[x] = l[y] = !!ret; \
total_coeff |= !!ret; \
if (step >= 4) { \
- AV_WN16A(&s->uveob[pl][n], ret); \
+ AV_WN16A(&td->uveob[pl][n], ret); \
} else { \
- s->uveob[pl][n] = ret; \
+ td->uveob[pl][n] = ret; \
} \
} \
}
p = s->prob.coef[b->uvtx][1 /* uv */][!b->intra];
- c = s->counts.coef[b->uvtx][1 /* uv */][!b->intra];
- e = s->counts.eob[b->uvtx][1 /* uv */][!b->intra];
+ c = td->counts.coef[b->uvtx][1 /* uv */][!b->intra];
+ e = td->counts.eob[b->uvtx][1 /* uv */][!b->intra];
w4 >>= s->ss_h;
end_x >>= s->ss_h;
h4 >>= s->ss_v;
end_y >>= s->ss_v;
for (pl = 0; pl < 2; pl++) {
a = &s->above_uv_nnz_ctx[pl][col << !s->ss_h];
- l = &s->left_uv_nnz_ctx[pl][(row & 7) << !s->ss_v];
+ l = &td->left_uv_nnz_ctx[pl][(row & 7) << !s->ss_v];
switch (b->uvtx) {
case TX_4X4:
DECODE_UV_COEF_LOOP(1,);
@@ -1132,14 +1132,14 @@ static av_always_inline int decode_coeffs(AVCodecContext *avctx, int is8bitsperp
return total_coeff;
}
-static int decode_coeffs_8bpp(AVCodecContext *avctx)
+static int decode_coeffs_8bpp(VP9TileData *td)
{
- return decode_coeffs(avctx, 1);
+ return decode_coeffs(td, 1);
}
-static int decode_coeffs_16bpp(AVCodecContext *avctx)
+static int decode_coeffs_16bpp(VP9TileData *td)
{
- return decode_coeffs(avctx, 0);
+ return decode_coeffs(td, 0);
}
static av_always_inline void mask_edges(uint8_t (*mask)[8][4], int ss_h, int ss_v,
@@ -1264,33 +1264,33 @@ static av_always_inline void mask_edges(uint8_t (*mask)[8][4], int ss_h, int ss_
}
}
-void ff_vp9_decode_block(AVCodecContext *avctx, int row, int col,
+void ff_vp9_decode_block(VP9TileData *td, int row, int col,
VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff,
enum BlockLevel bl, enum BlockPartition bp)
{
- VP9Context *s = avctx->priv_data;
- VP9Block *b = s->b;
+ VP9Context *s = td->s;
+ VP9Block *b = td->b;
enum BlockSize bs = bl * 3 + bp;
int bytesperpixel = s->bytesperpixel;
int w4 = ff_vp9_bwh_tab[1][bs][0], h4 = ff_vp9_bwh_tab[1][bs][1], lvl;
int emu[2];
AVFrame *f = s->s.frames[CUR_FRAME].tf.f;
- s->row = row;
- s->row7 = row & 7;
- s->col = col;
- s->col7 = col & 7;
+ td->row = row;
+ td->row7 = row & 7;
+ td->col = col;
+ td->col7 = col & 7;
- s->min_mv.x = -(128 + col * 64);
- s->min_mv.y = -(128 + row * 64);
- s->max_mv.x = 128 + (s->cols - col - w4) * 64;
- s->max_mv.y = 128 + (s->rows - row - h4) * 64;
+ td->min_mv.x = -(128 + col * 64);
+ td->min_mv.y = -(128 + row * 64);
+ td->max_mv.x = 128 + (s->cols - col - w4) * 64;
+ td->max_mv.y = 128 + (s->rows - row - h4) * 64;
if (s->pass < 2) {
b->bs = bs;
b->bl = bl;
b->bp = bp;
- decode_mode(avctx);
+ decode_mode(td);
b->uvtx = b->tx - ((s->ss_h && w4 * 2 == (1 << b->tx)) ||
(s->ss_v && h4 * 2 == (1 << b->tx)));
@@ -1298,17 +1298,17 @@ void ff_vp9_decode_block(AVCodecContext *avctx, int row, int col,
int has_coeffs;
if (bytesperpixel == 1) {
- has_coeffs = decode_coeffs_8bpp(avctx);
+ has_coeffs = decode_coeffs_8bpp(td);
} else {
- has_coeffs = decode_coeffs_16bpp(avctx);
+ has_coeffs = decode_coeffs_16bpp(td);
}
if (!has_coeffs && b->bs <= BS_8x8 && !b->intra) {
b->skip = 1;
memset(&s->above_skip_ctx[col], 1, w4);
- memset(&s->left_skip_ctx[s->row7], 1, h4);
+ memset(&td->left_skip_ctx[td->row7], 1, h4);
}
} else {
- int row7 = s->row7;
+ int row7 = td->row7;
#define SPLAT_ZERO_CTX(v, n) \
switch (n) { \
@@ -1320,27 +1320,27 @@ void ff_vp9_decode_block(AVCodecContext *avctx, int row, int col,
}
#define SPLAT_ZERO_YUV(dir, var, off, n, dir2) \
do { \
- SPLAT_ZERO_CTX(s->dir##_y_##var[off * 2], n * 2); \
+ SPLAT_ZERO_CTX(dir##_y_##var[off * 2], n * 2); \
if (s->ss_##dir2) { \
- SPLAT_ZERO_CTX(s->dir##_uv_##var[0][off], n); \
- SPLAT_ZERO_CTX(s->dir##_uv_##var[1][off], n); \
+ SPLAT_ZERO_CTX(dir##_uv_##var[0][off], n); \
+ SPLAT_ZERO_CTX(dir##_uv_##var[1][off], n); \
} else { \
- SPLAT_ZERO_CTX(s->dir##_uv_##var[0][off * 2], n * 2); \
- SPLAT_ZERO_CTX(s->dir##_uv_##var[1][off * 2], n * 2); \
+ SPLAT_ZERO_CTX(dir##_uv_##var[0][off * 2], n * 2); \
+ SPLAT_ZERO_CTX(dir##_uv_##var[1][off * 2], n * 2); \
} \
} while (0)
switch (w4) {
- case 1: SPLAT_ZERO_YUV(above, nnz_ctx, col, 1, h); break;
- case 2: SPLAT_ZERO_YUV(above, nnz_ctx, col, 2, h); break;
- case 4: SPLAT_ZERO_YUV(above, nnz_ctx, col, 4, h); break;
- case 8: SPLAT_ZERO_YUV(above, nnz_ctx, col, 8, h); break;
+ case 1: SPLAT_ZERO_YUV(s->above, nnz_ctx, col, 1, h); break;
+ case 2: SPLAT_ZERO_YUV(s->above, nnz_ctx, col, 2, h); break;
+ case 4: SPLAT_ZERO_YUV(s->above, nnz_ctx, col, 4, h); break;
+ case 8: SPLAT_ZERO_YUV(s->above, nnz_ctx, col, 8, h); break;
}
switch (h4) {
- case 1: SPLAT_ZERO_YUV(left, nnz_ctx, row7, 1, v); break;
- case 2: SPLAT_ZERO_YUV(left, nnz_ctx, row7, 2, v); break;
- case 4: SPLAT_ZERO_YUV(left, nnz_ctx, row7, 4, v); break;
- case 8: SPLAT_ZERO_YUV(left, nnz_ctx, row7, 8, v); break;
+ case 1: SPLAT_ZERO_YUV(td->left, nnz_ctx, row7, 1, v); break;
+ case 2: SPLAT_ZERO_YUV(td->left, nnz_ctx, row7, 2, v); break;
+ case 4: SPLAT_ZERO_YUV(td->left, nnz_ctx, row7, 4, v); break;
+ case 8: SPLAT_ZERO_YUV(td->left, nnz_ctx, row7, 8, v); break;
}
}
@@ -1365,32 +1365,32 @@ void ff_vp9_decode_block(AVCodecContext *avctx, int row, int col,
emu[1] = ((col + w4) * 8 >> s->ss_h) * bytesperpixel > f->linesize[1] ||
(row + h4) > s->rows;
if (emu[0]) {
- s->dst[0] = s->tmp_y;
- s->y_stride = 128;
+ td->dst[0] = s->tmp_y;
+ td->y_stride = 128;
} else {
- s->dst[0] = f->data[0] + yoff;
- s->y_stride = f->linesize[0];
+ td->dst[0] = f->data[0] + yoff;
+ td->y_stride = f->linesize[0];
}
if (emu[1]) {
- s->dst[1] = s->tmp_uv[0];
- s->dst[2] = s->tmp_uv[1];
- s->uv_stride = 128;
+ td->dst[1] = s->tmp_uv[0];
+ td->dst[2] = s->tmp_uv[1];
+ td->uv_stride = 128;
} else {
- s->dst[1] = f->data[1] + uvoff;
- s->dst[2] = f->data[2] + uvoff;
- s->uv_stride = f->linesize[1];
+ td->dst[1] = f->data[1] + uvoff;
+ td->dst[2] = f->data[2] + uvoff;
+ td->uv_stride = f->linesize[1];
}
if (b->intra) {
if (s->s.h.bpp > 8) {
- ff_vp9_intra_recon_16bpp(avctx, yoff, uvoff);
+ ff_vp9_intra_recon_16bpp(td, yoff, uvoff);
} else {
- ff_vp9_intra_recon_8bpp(avctx, yoff, uvoff);
+ ff_vp9_intra_recon_8bpp(td, yoff, uvoff);
}
} else {
if (s->s.h.bpp > 8) {
- ff_vp9_inter_recon_16bpp(avctx);
+ ff_vp9_inter_recon_16bpp(td);
} else {
- ff_vp9_inter_recon_8bpp(avctx);
+ ff_vp9_inter_recon_8bpp(td);
}
}
if (emu[0]) {
@@ -1430,7 +1430,7 @@ void ff_vp9_decode_block(AVCodecContext *avctx, int row, int col,
(lvl = s->s.h.segmentation.feat[b->seg_id].lflvl[b->intra ? 0 : b->ref[0] + 1]
[b->mode[3] != ZEROMV]) > 0) {
int x_end = FFMIN(s->cols - col, w4), y_end = FFMIN(s->rows - row, h4);
- int skip_inter = !b->intra && b->skip, col7 = s->col7, row7 = s->row7;
+ int skip_inter = !b->intra && b->skip, col7 = td->col7, row7 = td->row7;
setctx_2d(&lflvl->level[row7 * 8 + col7], w4, h4, 8, lvl);
mask_edges(lflvl->mask[0], 0, 0, row7, col7, x_end, y_end, 0, 0, b->tx, skip_inter);
@@ -1439,20 +1439,6 @@ void ff_vp9_decode_block(AVCodecContext *avctx, int row, int col,
s->cols & 1 && col + w4 >= s->cols ? s->cols & 7 : 0,
s->rows & 1 && row + h4 >= s->rows ? s->rows & 7 : 0,
b->uvtx, skip_inter);
-
- if (!s->filter_lut.lim_lut[lvl]) {
- int sharp = s->s.h.filter.sharpness;
- int limit = lvl;
-
- if (sharp > 0) {
- limit >>= (sharp + 3) >> 2;
- limit = FFMIN(limit, 9 - sharp);
- }
- limit = FFMAX(limit, 1);
-
- s->filter_lut.lim_lut[lvl] = limit;
- s->filter_lut.mblim_lut[lvl] = 2 * (lvl + 2) + limit;
- }
}
if (s->pass == 2) {
@@ -84,20 +84,19 @@ typedef struct VP9Block {
enum BlockPartition bp;
} VP9Block;
+typedef struct VP9TileData VP9TileData;
+
typedef struct VP9Context {
+ VP9TileData *td;
VP9SharedContext s;
VP9DSPContext dsp;
VideoDSPContext vdsp;
GetBitContext gb;
VP56RangeCoder c;
- VP56RangeCoder *c_b;
- unsigned c_b_size;
+ unsigned td_size;
VP9Block *b_base, *b;
int pass;
- int row, row7, col, col7;
- uint8_t *dst[3];
- ptrdiff_t y_stride, uv_stride;
uint8_t ss_h, ss_v;
uint8_t last_bpp, bpp_index, bytesperpixel;
@@ -115,7 +114,6 @@ typedef struct VP9Context {
uint8_t lim_lut[64];
uint8_t mblim_lut[64];
} filter_lut;
- unsigned tile_row_start, tile_row_end, tile_col_start, tile_col_end;
struct {
ProbContext p;
uint8_t coef[4][2][2][6][6][3];
@@ -153,19 +151,7 @@ typedef struct VP9Context {
unsigned eob[4][2][2][6][6][2];
} counts;
- // contextual (left/above) cache
- DECLARE_ALIGNED(16, uint8_t, left_y_nnz_ctx)[16];
- DECLARE_ALIGNED(16, uint8_t, left_mode_ctx)[16];
- DECLARE_ALIGNED(16, VP56mv, left_mv_ctx)[16][2];
- DECLARE_ALIGNED(16, uint8_t, left_uv_nnz_ctx)[2][16];
- DECLARE_ALIGNED(8, uint8_t, left_partition_ctx)[8];
- DECLARE_ALIGNED(8, uint8_t, left_skip_ctx)[8];
- DECLARE_ALIGNED(8, uint8_t, left_txfm_ctx)[8];
- DECLARE_ALIGNED(8, uint8_t, left_segpred_ctx)[8];
- DECLARE_ALIGNED(8, uint8_t, left_intra_ctx)[8];
- DECLARE_ALIGNED(8, uint8_t, left_comp_ctx)[8];
- DECLARE_ALIGNED(8, uint8_t, left_ref_ctx)[8];
- DECLARE_ALIGNED(8, uint8_t, left_filter_ctx)[8];
+ // contextual (above) cache
uint8_t *above_partition_ctx;
uint8_t *above_mode_ctx;
// FIXME maybe merge some of the below in a flags field?
@@ -189,29 +175,88 @@ typedef struct VP9Context {
int block_alloc_using_2pass;
int16_t *block_base, *block, *uvblock_base[2], *uvblock[2];
uint8_t *eob_base, *uveob_base[2], *eob, *uveob[2];
- struct { int x, y; } min_mv, max_mv;
DECLARE_ALIGNED(32, uint8_t, tmp_y)[64 * 64 * 2];
DECLARE_ALIGNED(32, uint8_t, tmp_uv)[2][64 * 64 * 2];
uint16_t mvscale[3][2];
uint8_t mvstep[3][2];
} VP9Context;
-void ff_vp9_fill_mv(VP9Context *s, VP56mv *mv, int mode, int sb);
+typedef struct VP9TileData {
+ VP9Context *s;
+ VP56RangeCoder c;
+ int row, row7, col, col7;
+ uint8_t *dst[3];
+ ptrdiff_t y_stride, uv_stride, yoff, uvoff;
+ VP9Block *b_base, *b;
+ unsigned tile_row_start, tile_row_end, tile_col_start, tile_col_end;
+
+ struct {
+ unsigned y_mode[4][10];
+ unsigned uv_mode[10][10];
+ unsigned filter[4][3];
+ unsigned mv_mode[7][4];
+ unsigned intra[4][2];
+ unsigned comp[5][2];
+ unsigned single_ref[5][2][2];
+ unsigned comp_ref[5][2];
+ unsigned tx32p[2][4];
+ unsigned tx16p[2][3];
+ unsigned tx8p[2][2];
+ unsigned skip[3][2];
+ unsigned mv_joint[4];
+ struct {
+ unsigned sign[2];
+ unsigned classes[11];
+ unsigned class0[2];
+ unsigned bits[10][2];
+ unsigned class0_fp[2][4];
+ unsigned fp[4];
+ unsigned class0_hp[2];
+ unsigned hp[2];
+ } mv_comp[2];
+ unsigned partition[4][4][4];
+ unsigned coef[4][2][2][6][6][3];
+ unsigned eob[4][2][2][6][6][2];
+ } counts;
+
+ // whole-frame cache
+ VP9Filter *lflvl_ptr;
+
+ // contextual (left) cache
+ DECLARE_ALIGNED(16, uint8_t, left_y_nnz_ctx)[16];
+ DECLARE_ALIGNED(16, uint8_t, left_mode_ctx)[16];
+ DECLARE_ALIGNED(16, VP56mv, left_mv_ctx)[16][2];
+ DECLARE_ALIGNED(16, uint8_t, left_uv_nnz_ctx)[2][16];
+ DECLARE_ALIGNED(8, uint8_t, left_partition_ctx)[8];
+ DECLARE_ALIGNED(8, uint8_t, left_skip_ctx)[8];
+ DECLARE_ALIGNED(8, uint8_t, left_txfm_ctx)[8];
+ DECLARE_ALIGNED(8, uint8_t, left_segpred_ctx)[8];
+ DECLARE_ALIGNED(8, uint8_t, left_intra_ctx)[8];
+ DECLARE_ALIGNED(8, uint8_t, left_comp_ctx)[8];
+ DECLARE_ALIGNED(8, uint8_t, left_ref_ctx)[8];
+ DECLARE_ALIGNED(8, uint8_t, left_filter_ctx)[8];
+ // block reconstruction intermediates
+ struct { int x, y; } min_mv, max_mv;
+ int16_t *block_base, *block, *uvblock_base[2], *uvblock[2];
+ uint8_t *eob_base, *uveob_base[2], *eob, *uveob[2];
+} VP9TileData;
+
+void ff_vp9_fill_mv(VP9TileData *td, VP56mv *mv, int mode, int sb);
void ff_vp9_adapt_probs(VP9Context *s);
-void ff_vp9_decode_block(AVCodecContext *ctx, int row, int col,
+void ff_vp9_decode_block(VP9TileData *td, int row, int col,
VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff,
enum BlockLevel bl, enum BlockPartition bp);
void ff_vp9_loopfilter_sb(AVCodecContext *avctx, VP9Filter *lflvl,
int row, int col, ptrdiff_t yoff, ptrdiff_t uvoff);
-void ff_vp9_intra_recon_8bpp(AVCodecContext *avctx,
+void ff_vp9_intra_recon_8bpp(VP9TileData *td,
ptrdiff_t y_off, ptrdiff_t uv_off);
-void ff_vp9_intra_recon_16bpp(AVCodecContext *avctx,
+void ff_vp9_intra_recon_16bpp(VP9TileData *td,
ptrdiff_t y_off, ptrdiff_t uv_off);
-void ff_vp9_inter_recon_8bpp(AVCodecContext *avctx);
-void ff_vp9_inter_recon_16bpp(AVCodecContext *avctx);
+void ff_vp9_inter_recon_8bpp(VP9TileData *td);
+void ff_vp9_inter_recon_16bpp(VP9TileData *td);
#endif /* AVCODEC_VP9DEC_H */
@@ -28,13 +28,13 @@
#include "vp9dec.h"
static av_always_inline void clamp_mv(VP56mv *dst, const VP56mv *src,
- VP9Context *s)
+ VP9TileData *td)
{
- dst->x = av_clip(src->x, s->min_mv.x, s->max_mv.x);
- dst->y = av_clip(src->y, s->min_mv.y, s->max_mv.y);
+ dst->x = av_clip(src->x, td->min_mv.x, td->max_mv.x);
+ dst->y = av_clip(src->y, td->min_mv.y, td->max_mv.y);
}
-static void find_ref_mvs(VP9Context *s,
+static void find_ref_mvs(VP9TileData *td,
VP56mv *pmv, int ref, int z, int idx, int sb)
{
static const int8_t mv_ref_blk_off[N_BS_SIZES][8][2] = {
@@ -65,8 +65,9 @@ static void find_ref_mvs(VP9Context *s,
[BS_4x4] = { { 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
{ -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 } },
};
- VP9Block *b = s->b;
- int row = s->row, col = s->col, row7 = s->row7;
+ VP9Context *s = td->s;
+ VP9Block *b = td->b;
+ int row = td->row, col = td->col, row7 = td->row7;
const int8_t (*p)[2] = mv_ref_blk_off[b->bs];
#define INVALID_MV 0x80008000U
uint32_t mem = INVALID_MV, mem_sub8x8 = INVALID_MV;
@@ -103,7 +104,7 @@ static void find_ref_mvs(VP9Context *s,
av_assert2(idx == 1); \
av_assert2(mem != INVALID_MV); \
if (mem_sub8x8 == INVALID_MV) { \
- clamp_mv(&tmp, &mv, s); \
+ clamp_mv(&tmp, &mv, td); \
m = AV_RN32A(&tmp); \
if (m != mem) { \
AV_WN32A(pmv, m); \
@@ -111,7 +112,7 @@ static void find_ref_mvs(VP9Context *s,
} \
mem_sub8x8 = AV_RN32A(&mv); \
} else if (mem_sub8x8 != AV_RN32A(&mv)) { \
- clamp_mv(&tmp, &mv, s); \
+ clamp_mv(&tmp, &mv, td); \
m = AV_RN32A(&tmp); \
if (m != mem) { \
AV_WN32A(pmv, m); \
@@ -124,12 +125,12 @@ static void find_ref_mvs(VP9Context *s,
} else { \
uint32_t m = AV_RN32A(&mv); \
if (!idx) { \
- clamp_mv(pmv, &mv, s); \
+ clamp_mv(pmv, &mv, td); \
return; \
} else if (mem == INVALID_MV) { \
mem = m; \
} else if (m != mem) { \
- clamp_mv(pmv, &mv, s); \
+ clamp_mv(pmv, &mv, td); \
return; \
} \
} \
@@ -142,12 +143,12 @@ static void find_ref_mvs(VP9Context *s,
else if (mv->ref[1] == ref)
RETURN_MV(s->above_mv_ctx[2 * col + (sb & 1)][1]);
}
- if (col > s->tile_col_start) {
+ if (col > td->tile_col_start) {
VP9mvrefPair *mv = &s->s.frames[CUR_FRAME].mv[row * s->sb_cols * 8 + col - 1];
if (mv->ref[0] == ref)
- RETURN_MV(s->left_mv_ctx[2 * row7 + (sb >> 1)][0]);
+ RETURN_MV(td->left_mv_ctx[2 * row7 + (sb >> 1)][0]);
else if (mv->ref[1] == ref)
- RETURN_MV(s->left_mv_ctx[2 * row7 + (sb >> 1)][1]);
+ RETURN_MV(td->left_mv_ctx[2 * row7 + (sb >> 1)][1]);
}
i = 2;
} else {
@@ -158,7 +159,7 @@ static void find_ref_mvs(VP9Context *s,
for (; i < 8; i++) {
int c = p[i][0] + col, r = p[i][1] + row;
- if (c >= s->tile_col_start && c < s->cols &&
+ if (c >= td->tile_col_start && c < s->cols &&
r >= 0 && r < s->rows) {
VP9mvrefPair *mv = &s->s.frames[CUR_FRAME].mv[r * s->sb_cols * 8 + c];
@@ -195,7 +196,7 @@ static void find_ref_mvs(VP9Context *s,
for (i = 0; i < 8; i++) {
int c = p[i][0] + col, r = p[i][1] + row;
- if (c >= s->tile_col_start && c < s->cols && r >= 0 && r < s->rows) {
+ if (c >= td->tile_col_start && c < s->cols && r >= 0 && r < s->rows) {
VP9mvrefPair *mv = &s->s.frames[CUR_FRAME].mv[r * s->sb_cols * 8 + c];
if (mv->ref[0] != ref && mv->ref[0] >= 0)
@@ -226,69 +227,71 @@ static void find_ref_mvs(VP9Context *s,
}
AV_ZERO32(pmv);
- clamp_mv(pmv, pmv, s);
+ clamp_mv(pmv, pmv, td);
#undef INVALID_MV
#undef RETURN_MV
#undef RETURN_SCALE_MV
}
-static av_always_inline int read_mv_component(VP9Context *s, int idx, int hp)
+static av_always_inline int read_mv_component(VP9TileData *td, int idx, int hp)
{
- int bit, sign = vp56_rac_get_prob(&s->c, s->prob.p.mv_comp[idx].sign);
- int n, c = vp8_rac_get_tree(&s->c, ff_vp9_mv_class_tree,
+ VP9Context *s = td->s;
+ int bit, sign = vp56_rac_get_prob(&td->c, s->prob.p.mv_comp[idx].sign);
+ int n, c = vp8_rac_get_tree(&td->c, ff_vp9_mv_class_tree,
s->prob.p.mv_comp[idx].classes);
- s->counts.mv_comp[idx].sign[sign]++;
- s->counts.mv_comp[idx].classes[c]++;
+ td->counts.mv_comp[idx].sign[sign]++;
+ td->counts.mv_comp[idx].classes[c]++;
if (c) {
int m;
for (n = 0, m = 0; m < c; m++) {
- bit = vp56_rac_get_prob(&s->c, s->prob.p.mv_comp[idx].bits[m]);
+ bit = vp56_rac_get_prob(&td->c, s->prob.p.mv_comp[idx].bits[m]);
n |= bit << m;
- s->counts.mv_comp[idx].bits[m][bit]++;
+ td->counts.mv_comp[idx].bits[m][bit]++;
}
n <<= 3;
- bit = vp8_rac_get_tree(&s->c, ff_vp9_mv_fp_tree,
+ bit = vp8_rac_get_tree(&td->c, ff_vp9_mv_fp_tree,
s->prob.p.mv_comp[idx].fp);
n |= bit << 1;
- s->counts.mv_comp[idx].fp[bit]++;
+ td->counts.mv_comp[idx].fp[bit]++;
if (hp) {
- bit = vp56_rac_get_prob(&s->c, s->prob.p.mv_comp[idx].hp);
- s->counts.mv_comp[idx].hp[bit]++;
+ bit = vp56_rac_get_prob(&td->c, s->prob.p.mv_comp[idx].hp);
+ td->counts.mv_comp[idx].hp[bit]++;
n |= bit;
} else {
n |= 1;
// bug in libvpx - we count for bw entropy purposes even if the
// bit wasn't coded
- s->counts.mv_comp[idx].hp[1]++;
+ td->counts.mv_comp[idx].hp[1]++;
}
n += 8 << c;
} else {
- n = vp56_rac_get_prob(&s->c, s->prob.p.mv_comp[idx].class0);
- s->counts.mv_comp[idx].class0[n]++;
- bit = vp8_rac_get_tree(&s->c, ff_vp9_mv_fp_tree,
+ n = vp56_rac_get_prob(&td->c, s->prob.p.mv_comp[idx].class0);
+ td->counts.mv_comp[idx].class0[n]++;
+ bit = vp8_rac_get_tree(&td->c, ff_vp9_mv_fp_tree,
s->prob.p.mv_comp[idx].class0_fp[n]);
- s->counts.mv_comp[idx].class0_fp[n][bit]++;
+ td->counts.mv_comp[idx].class0_fp[n][bit]++;
n = (n << 3) | (bit << 1);
if (hp) {
- bit = vp56_rac_get_prob(&s->c, s->prob.p.mv_comp[idx].class0_hp);
- s->counts.mv_comp[idx].class0_hp[bit]++;
+ bit = vp56_rac_get_prob(&td->c, s->prob.p.mv_comp[idx].class0_hp);
+ td->counts.mv_comp[idx].class0_hp[bit]++;
n |= bit;
} else {
n |= 1;
// bug in libvpx - we count for bw entropy purposes even if the
// bit wasn't coded
- s->counts.mv_comp[idx].class0_hp[1]++;
+ td->counts.mv_comp[idx].class0_hp[1]++;
}
}
return sign ? -(n + 1) : (n + 1);
}
-void ff_vp9_fill_mv(VP9Context *s, VP56mv *mv, int mode, int sb)
+void ff_vp9_fill_mv(VP9TileData *td, VP56mv *mv, int mode, int sb)
{
- VP9Block *b = s->b;
+ VP9Context *s = td->s;
+ VP9Block *b = td->b;
if (mode == ZEROMV) {
AV_ZERO64(mv);
@@ -296,7 +299,7 @@ void ff_vp9_fill_mv(VP9Context *s, VP56mv *mv, int mode, int sb)
int hp;
// FIXME cache this value and reuse for other subblocks
- find_ref_mvs(s, &mv[0], b->ref[0], 0, mode == NEARMV,
+ find_ref_mvs(td, &mv[0], b->ref[0], 0, mode == NEARMV,
mode == NEWMV ? -1 : sb);
// FIXME maybe move this code into find_ref_mvs()
if ((mode == NEWMV || sb == -1) &&
@@ -316,19 +319,19 @@ void ff_vp9_fill_mv(VP9Context *s, VP56mv *mv, int mode, int sb)
}
}
if (mode == NEWMV) {
- enum MVJoint j = vp8_rac_get_tree(&s->c, ff_vp9_mv_joint_tree,
+ enum MVJoint j = vp8_rac_get_tree(&td->c, ff_vp9_mv_joint_tree,
s->prob.p.mv_joint);
- s->counts.mv_joint[j]++;
+ td->counts.mv_joint[j]++;
if (j >= MV_JOINT_V)
- mv[0].y += read_mv_component(s, 0, hp);
+ mv[0].y += read_mv_component(td, 0, hp);
if (j & 1)
- mv[0].x += read_mv_component(s, 1, hp);
+ mv[0].x += read_mv_component(td, 1, hp);
}
if (b->comp) {
// FIXME cache this value and reuse for other subblocks
- find_ref_mvs(s, &mv[1], b->ref[1], 1, mode == NEARMV,
+ find_ref_mvs(td, &mv[1], b->ref[1], 1, mode == NEARMV,
mode == NEWMV ? -1 : sb);
if ((mode == NEWMV || sb == -1) &&
!(hp = s->s.h.highprecisionmvs &&
@@ -347,14 +350,14 @@ void ff_vp9_fill_mv(VP9Context *s, VP56mv *mv, int mode, int sb)
}
}
if (mode == NEWMV) {
- enum MVJoint j = vp8_rac_get_tree(&s->c, ff_vp9_mv_joint_tree,
+ enum MVJoint j = vp8_rac_get_tree(&td->c, ff_vp9_mv_joint_tree,
s->prob.p.mv_joint);
- s->counts.mv_joint[j]++;
+ td->counts.mv_joint[j]++;
if (j >= MV_JOINT_V)
- mv[1].y += read_mv_component(s, 0, hp);
+ mv[1].y += read_mv_component(td, 0, hp);
if (j & 1)
- mv[1].x += read_mv_component(s, 1, hp);
+ mv[1].x += read_mv_component(td, 1, hp);
}
}
}
@@ -29,15 +29,16 @@
#include "vp9data.h"
#include "vp9dec.h"
-static av_always_inline int check_intra_mode(VP9Context *s, int mode, uint8_t **a,
+static av_always_inline int check_intra_mode(VP9TileData *td, int mode, uint8_t **a,
uint8_t *dst_edge, ptrdiff_t stride_edge,
uint8_t *dst_inner, ptrdiff_t stride_inner,
uint8_t *l, int col, int x, int w,
int row, int y, enum TxfmMode tx,
int p, int ss_h, int ss_v, int bytesperpixel)
{
+ VP9Context *s = td->s;
int have_top = row > 0 || y > 0;
- int have_left = col > s->tile_col_start || x > 0;
+ int have_left = col > td->tile_col_start || x > 0;
int have_right = x < w - 1;
int bpp = s->s.h.bpp;
static const uint8_t mode_conv[10][2 /* have_left */][2 /* have_top */] = {
@@ -214,19 +215,19 @@ static av_always_inline int check_intra_mode(VP9Context *s, int mode, uint8_t **
return mode;
}
-static av_always_inline void intra_recon(AVCodecContext *avctx, ptrdiff_t y_off,
+static av_always_inline void intra_recon(VP9TileData *td, ptrdiff_t y_off,
ptrdiff_t uv_off, int bytesperpixel)
{
- VP9Context *s = avctx->priv_data;
- VP9Block *b = s->b;
- int row = s->row, col = s->col;
+ VP9Context *s = td->s;
+ VP9Block *b = td->b;
+ int row = td->row, col = td->col;
int w4 = ff_vp9_bwh_tab[1][b->bs][0] << 1, step1d = 1 << b->tx, n;
int h4 = ff_vp9_bwh_tab[1][b->bs][1] << 1, x, y, step = 1 << (b->tx * 2);
int end_x = FFMIN(2 * (s->cols - col), w4);
int end_y = FFMIN(2 * (s->rows - row), h4);
int tx = 4 * s->s.h.lossless + b->tx, uvtx = b->uvtx + 4 * s->s.h.lossless;
int uvstep1d = 1 << b->uvtx, p;
- uint8_t *dst = s->dst[0], *dst_r = s->s.frames[CUR_FRAME].tf.f->data[0] + y_off;
+ uint8_t *dst = td->dst[0], *dst_r = s->s.frames[CUR_FRAME].tf.f->data[0] + y_off;
LOCAL_ALIGNED_32(uint8_t, a_buf, [96]);
LOCAL_ALIGNED_32(uint8_t, l, [64]);
@@ -238,19 +239,19 @@ static av_always_inline void intra_recon(AVCodecContext *avctx, ptrdiff_t y_off,
y * 2 + x : 0];
uint8_t *a = &a_buf[32];
enum TxfmType txtp = ff_vp9_intra_txfm_type[mode];
- int eob = b->skip ? 0 : b->tx > TX_8X8 ? AV_RN16A(&s->eob[n]) : s->eob[n];
+ int eob = b->skip ? 0 : b->tx > TX_8X8 ? AV_RN16A(&td->eob[n]) : td->eob[n];
- mode = check_intra_mode(s, mode, &a, ptr_r,
+ mode = check_intra_mode(td, mode, &a, ptr_r,
s->s.frames[CUR_FRAME].tf.f->linesize[0],
- ptr, s->y_stride, l,
+ ptr, td->y_stride, l,
col, x, w4, row, y, b->tx, 0, 0, 0, bytesperpixel);
- s->dsp.intra_pred[b->tx][mode](ptr, s->y_stride, l, a);
+ s->dsp.intra_pred[b->tx][mode](ptr, td->y_stride, l, a);
if (eob)
- s->dsp.itxfm_add[tx][txtp](ptr, s->y_stride,
- s->block + 16 * n * bytesperpixel, eob);
+ s->dsp.itxfm_add[tx][txtp](ptr, td->y_stride,
+ td->block + 16 * n * bytesperpixel, eob);
}
dst_r += 4 * step1d * s->s.frames[CUR_FRAME].tf.f->linesize[0];
- dst += 4 * step1d * s->y_stride;
+ dst += 4 * step1d * td->y_stride;
}
// U/V
@@ -259,7 +260,7 @@ static av_always_inline void intra_recon(AVCodecContext *avctx, ptrdiff_t y_off,
end_y >>= s->ss_v;
step = 1 << (b->uvtx * 2);
for (p = 0; p < 2; p++) {
- dst = s->dst[1 + p];
+ dst = td->dst[1 + p];
dst_r = s->s.frames[CUR_FRAME].tf.f->data[1 + p] + uv_off;
for (n = 0, y = 0; y < end_y; y += uvstep1d) {
uint8_t *ptr = dst, *ptr_r = dst_r;
@@ -267,31 +268,31 @@ static av_always_inline void intra_recon(AVCodecContext *avctx, ptrdiff_t y_off,
ptr_r += 4 * uvstep1d * bytesperpixel, n += step) {
int mode = b->uvmode;
uint8_t *a = &a_buf[32];
- int eob = b->skip ? 0 : b->uvtx > TX_8X8 ? AV_RN16A(&s->uveob[p][n]) : s->uveob[p][n];
+ int eob = b->skip ? 0 : b->uvtx > TX_8X8 ? AV_RN16A(&td->uveob[p][n]) : td->uveob[p][n];
- mode = check_intra_mode(s, mode, &a, ptr_r,
+ mode = check_intra_mode(td, mode, &a, ptr_r,
s->s.frames[CUR_FRAME].tf.f->linesize[1],
- ptr, s->uv_stride, l, col, x, w4, row, y,
+ ptr, td->uv_stride, l, col, x, w4, row, y,
b->uvtx, p + 1, s->ss_h, s->ss_v, bytesperpixel);
- s->dsp.intra_pred[b->uvtx][mode](ptr, s->uv_stride, l, a);
+ s->dsp.intra_pred[b->uvtx][mode](ptr, td->uv_stride, l, a);
if (eob)
- s->dsp.itxfm_add[uvtx][DCT_DCT](ptr, s->uv_stride,
- s->uvblock[p] + 16 * n * bytesperpixel, eob);
+ s->dsp.itxfm_add[uvtx][DCT_DCT](ptr, td->uv_stride,
+ td->uvblock[p] + 16 * n * bytesperpixel, eob);
}
dst_r += 4 * uvstep1d * s->s.frames[CUR_FRAME].tf.f->linesize[1];
- dst += 4 * uvstep1d * s->uv_stride;
+ dst += 4 * uvstep1d * td->uv_stride;
}
}
}
-void ff_vp9_intra_recon_8bpp(AVCodecContext *avctx, ptrdiff_t y_off, ptrdiff_t uv_off)
+void ff_vp9_intra_recon_8bpp(VP9TileData *td, ptrdiff_t y_off, ptrdiff_t uv_off)
{
- intra_recon(avctx, y_off, uv_off, 1);
+ intra_recon(td, y_off, uv_off, 1);
}
-void ff_vp9_intra_recon_16bpp(AVCodecContext *avctx, ptrdiff_t y_off, ptrdiff_t uv_off)
+void ff_vp9_intra_recon_16bpp(VP9TileData *td, ptrdiff_t y_off, ptrdiff_t uv_off)
{
- intra_recon(avctx, y_off, uv_off, 2);
+ intra_recon(td, y_off, uv_off, 2);
}
static av_always_inline void mc_luma_unscaled(VP9Context *s, vp9_mc_func (*mc)[2],
@@ -561,23 +562,23 @@ static av_always_inline void mc_chroma_scaled(VP9Context *s, vp9_scaled_mc_func
#undef BYTES_PER_PIXEL
#undef SCALED
-static av_always_inline void inter_recon(AVCodecContext *avctx, int bytesperpixel)
+static av_always_inline void inter_recon(VP9TileData *td, int bytesperpixel)
{
- VP9Context *s = avctx->priv_data;
- VP9Block *b = s->b;
- int row = s->row, col = s->col;
+ VP9Context *s = td->s;
+ VP9Block *b = td->b;
+ int row = td->row, col = td->col;
if (s->mvscale[b->ref[0]][0] || (b->comp && s->mvscale[b->ref[1]][0])) {
if (bytesperpixel == 1) {
- inter_pred_scaled_8bpp(avctx);
+ inter_pred_scaled_8bpp(td);
} else {
- inter_pred_scaled_16bpp(avctx);
+ inter_pred_scaled_16bpp(td);
}
} else {
if (bytesperpixel == 1) {
- inter_pred_8bpp(avctx);
+ inter_pred_8bpp(td);
} else {
- inter_pred_16bpp(avctx);
+ inter_pred_16bpp(td);
}
}
@@ -590,20 +591,20 @@ static av_always_inline void inter_recon(AVCodecContext *avctx, int bytesperpixe
int end_y = FFMIN(2 * (s->rows - row), h4);
int tx = 4 * s->s.h.lossless + b->tx, uvtx = b->uvtx + 4 * s->s.h.lossless;
int uvstep1d = 1 << b->uvtx, p;
- uint8_t *dst = s->dst[0];
+ uint8_t *dst = td->dst[0];
// y itxfm add
for (n = 0, y = 0; y < end_y; y += step1d) {
uint8_t *ptr = dst;
for (x = 0; x < end_x; x += step1d,
ptr += 4 * step1d * bytesperpixel, n += step) {
- int eob = b->tx > TX_8X8 ? AV_RN16A(&s->eob[n]) : s->eob[n];
+ int eob = b->tx > TX_8X8 ? AV_RN16A(&td->eob[n]) : td->eob[n];
if (eob)
- s->dsp.itxfm_add[tx][DCT_DCT](ptr, s->y_stride,
- s->block + 16 * n * bytesperpixel, eob);
+ s->dsp.itxfm_add[tx][DCT_DCT](ptr, td->y_stride,
+ td->block + 16 * n * bytesperpixel, eob);
}
- dst += 4 * s->y_stride * step1d;
+ dst += 4 * td->y_stride * step1d;
}
// uv itxfm add
@@ -611,29 +612,29 @@ static av_always_inline void inter_recon(AVCodecContext *avctx, int bytesperpixe
end_y >>= s->ss_v;
step = 1 << (b->uvtx * 2);
for (p = 0; p < 2; p++) {
- dst = s->dst[p + 1];
+ dst = td->dst[p + 1];
for (n = 0, y = 0; y < end_y; y += uvstep1d) {
uint8_t *ptr = dst;
for (x = 0; x < end_x; x += uvstep1d,
ptr += 4 * uvstep1d * bytesperpixel, n += step) {
- int eob = b->uvtx > TX_8X8 ? AV_RN16A(&s->uveob[p][n]) : s->uveob[p][n];
+ int eob = b->uvtx > TX_8X8 ? AV_RN16A(&td->uveob[p][n]) : td->uveob[p][n];
if (eob)
- s->dsp.itxfm_add[uvtx][DCT_DCT](ptr, s->uv_stride,
- s->uvblock[p] + 16 * n * bytesperpixel, eob);
+ s->dsp.itxfm_add[uvtx][DCT_DCT](ptr, td->uv_stride,
+ td->uvblock[p] + 16 * n * bytesperpixel, eob);
}
- dst += 4 * uvstep1d * s->uv_stride;
+ dst += 4 * uvstep1d * td->uv_stride;
}
}
}
}
-void ff_vp9_inter_recon_8bpp(AVCodecContext *avctx)
+void ff_vp9_inter_recon_8bpp(VP9TileData *td)
{
- inter_recon(avctx, 1);
+ inter_recon(td, 1);
}
-void ff_vp9_inter_recon_16bpp(AVCodecContext *avctx)
+void ff_vp9_inter_recon_16bpp(VP9TileData *td)
{
- inter_recon(avctx, 2);
+ inter_recon(td, 2);
}