1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

avcodec/vp9: Add tile threading support

Signed-off-by: Ilia Valiakhmetov <zakne0ne@gmail.com>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
This commit is contained in:
Ilia Valiakhmetov 2017-09-08 04:02:49 +07:00 committed by Ronald S. Bultje
parent 83c12fefd2
commit e59da0f7ff
7 changed files with 1052 additions and 756 deletions

View File

@ -36,6 +36,64 @@
#define VP9_SYNCCODE 0x498342
#if HAVE_THREADS
static void vp9_free_entries(AVCodecContext *avctx) {
VP9Context *s = avctx->priv_data;
if (avctx->active_thread_type & FF_THREAD_SLICE) {
pthread_mutex_destroy(&s->progress_mutex);
pthread_cond_destroy(&s->progress_cond);
av_freep(&s->entries);
}
}
static int vp9_alloc_entries(AVCodecContext *avctx, int n) {
VP9Context *s = avctx->priv_data;
int i;
if (avctx->active_thread_type & FF_THREAD_SLICE) {
if (s->entries)
av_freep(&s->entries);
s->entries = av_malloc_array(n, sizeof(atomic_int));
if (!s->entries) {
av_freep(&s->entries);
return AVERROR(ENOMEM);
}
for (i = 0; i < n; i++)
atomic_init(&s->entries[i], 0);
pthread_mutex_init(&s->progress_mutex, NULL);
pthread_cond_init(&s->progress_cond, NULL);
}
return 0;
}
static void vp9_report_tile_progress(VP9Context *s, int field, int n) {
pthread_mutex_lock(&s->progress_mutex);
atomic_fetch_add_explicit(&s->entries[field], n, memory_order_relaxed);
pthread_cond_signal(&s->progress_cond);
pthread_mutex_unlock(&s->progress_mutex);
}
static void vp9_await_tile_progress(VP9Context *s, int field, int n) {
if (atomic_load_explicit(&s->entries[field], memory_order_acquire) >= n)
return;
pthread_mutex_lock(&s->progress_mutex);
while (atomic_load_explicit(&s->entries[field], memory_order_relaxed) != n)
pthread_cond_wait(&s->progress_cond, &s->progress_mutex);
pthread_mutex_unlock(&s->progress_mutex);
}
#else
static void vp9_free_entries(VP9Context *s) {}
static int vp9_alloc_entries(AVCodecContext *avctx, int n) { return 0; }
static void vp9_report_tile_progress(VP9Context *s, int field, int n) {}
static void vp9_await_tile_progress(VP9Context *s, int field, int n) {}
#endif
static void vp9_frame_unref(AVCodecContext *avctx, VP9Frame *f)
{
ff_thread_release_buffer(avctx, &f->tf);
@ -118,6 +176,7 @@ static int update_size(AVCodecContext *avctx, int w, int h)
VP9Context *s = avctx->priv_data;
uint8_t *p;
int bytesperpixel = s->bytesperpixel, ret, cols, rows;
int lflvl_len, i;
av_assert0(w > 0 && h > 0);
@ -170,13 +229,14 @@ static int update_size(AVCodecContext *avctx, int w, int h)
s->sb_rows = (h + 63) >> 6;
s->cols = (w + 7) >> 3;
s->rows = (h + 7) >> 3;
lflvl_len = avctx->active_thread_type == FF_THREAD_SLICE ? s->sb_rows : 1;
#define assign(var, type, n) var = (type) p; p += s->sb_cols * (n) * sizeof(*var)
av_freep(&s->intra_pred_data[0]);
// FIXME we slightly over-allocate here for subsampled chroma, but a little
// bit of padding shouldn't affect performance...
p = av_malloc(s->sb_cols * (128 + 192 * bytesperpixel +
sizeof(*s->lflvl) + 16 * sizeof(*s->above_mv_ctx)));
lflvl_len * sizeof(*s->lflvl) + 16 * sizeof(*s->above_mv_ctx)));
if (!p)
return AVERROR(ENOMEM);
assign(s->intra_pred_data[0], uint8_t *, 64 * bytesperpixel);
@ -195,12 +255,15 @@ static int update_size(AVCodecContext *avctx, int w, int h)
assign(s->above_comp_ctx, uint8_t *, 8);
assign(s->above_ref_ctx, uint8_t *, 8);
assign(s->above_filter_ctx, uint8_t *, 8);
assign(s->lflvl, VP9Filter *, 1);
assign(s->lflvl, VP9Filter *, lflvl_len);
#undef assign
// these will be re-allocated a little later
av_freep(&s->b_base);
av_freep(&s->block_base);
if (s->td) {
for (i = 0; i < s->active_tile_cols; i++) {
av_freep(&s->td[i].b_base);
av_freep(&s->td[i].block_base);
}
}
if (s->s.h.bpp != s->last_bpp) {
ff_vp9dsp_init(&s->dsp, s->s.h.bpp, avctx->flags & AV_CODEC_FLAG_BITEXACT);
@ -213,40 +276,50 @@ 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;
VP9TileData *td = &s->td[0];
if (s->b_base && s->block_base && s->block_alloc_using_2pass == s->s.frames[CUR_FRAME].uses_2pass)
if (td->b_base && td->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);
av_free(td->b_base);
av_free(td->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) {
int sbs = s->sb_cols * s->sb_rows;
s->b_base = av_malloc_array(s->cols * s->rows, sizeof(VP9Block));
s->block_base = av_mallocz(((64 * 64 + 2 * chroma_blocks) * bytesperpixel * sizeof(int16_t) +
td->b_base = av_malloc_array(s->cols * s->rows, sizeof(VP9Block));
td->block_base = av_mallocz(((64 * 64 + 2 * chroma_blocks) * bytesperpixel * sizeof(int16_t) +
16 * 16 + 2 * chroma_eobs) * sbs);
if (!s->b_base || !s->block_base)
if (!td->b_base || !td->block_base)
return AVERROR(ENOMEM);
s->uvblock_base[0] = s->block_base + sbs * 64 * 64 * bytesperpixel;
s->uvblock_base[1] = s->uvblock_base[0] + sbs * chroma_blocks * bytesperpixel;
s->eob_base = (uint8_t *) (s->uvblock_base[1] + sbs * chroma_blocks * bytesperpixel);
s->uveob_base[0] = s->eob_base + 16 * 16 * sbs;
s->uveob_base[1] = s->uveob_base[0] + chroma_eobs * sbs;
td->uvblock_base[0] = td->block_base + sbs * 64 * 64 * bytesperpixel;
td->uvblock_base[1] = td->uvblock_base[0] + sbs * chroma_blocks * bytesperpixel;
td->eob_base = (uint8_t *) (td->uvblock_base[1] + sbs * chroma_blocks * bytesperpixel);
td->uveob_base[0] = td->eob_base + 16 * 16 * sbs;
td->uveob_base[1] = td->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 = 1; i < s->active_tile_cols; i++) {
if (s->td[i].b_base && s->td[i].block_base) {
av_free(s->td[i].b_base);
av_free(s->td[i].block_base);
}
}
for (i = 0; i < s->active_tile_cols; 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 +616,20 @@ 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++) {
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))) {
@ -662,12 +747,36 @@ static int decode_frame_header(AVCodecContext *avctx,
s->s.h.tiling.log2_tile_rows = decode012(&s->gb);
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)) {
int n_range_coders;
VP56RangeCoder *rc;
if (s->td) {
for (i = 0; i < s->active_tile_cols; i++) {
av_free(s->td[i].b_base);
av_free(s->td[i].block_base);
}
av_free(s->td);
}
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");
vp9_free_entries(avctx);
s->active_tile_cols = avctx->active_thread_type == FF_THREAD_SLICE ?
s->s.h.tiling.tile_cols : 1;
vp9_alloc_entries(avctx, s->sb_rows);
if (avctx->active_thread_type == FF_THREAD_SLICE) {
n_range_coders = 4; // max_tile_rows
} else {
n_range_coders = s->s.h.tiling.tile_cols;
}
s->td = av_mallocz_array(s->active_tile_cols, sizeof(VP9TileData) +
n_range_coders * sizeof(VP56RangeCoder));
if (!s->td)
return AVERROR(ENOMEM);
rc = (VP56RangeCoder *) &s->td[s->active_tile_cols];
for (i = 0; i < s->active_tile_cols; i++) {
s->td[i].s = s;
s->td[i].c_b = rc;
rc += n_range_coders;
}
}
@ -735,12 +844,15 @@ static int decode_frame_header(AVCodecContext *avctx,
return AVERROR_INVALIDDATA;
}
if (s->s.h.keyframe || s->s.h.intraonly) {
memset(s->counts.coef, 0, sizeof(s->counts.coef));
memset(s->counts.eob, 0, sizeof(s->counts.eob));
} else {
memset(&s->counts, 0, sizeof(s->counts));
for (i = 0; i < s->active_tile_cols; i++) {
if (s->s.h.keyframe || s->s.h.intraonly) {
memset(s->td[i].counts.coef, 0, sizeof(s->td[0].counts.coef));
memset(s->td[i].counts.eob, 0, sizeof(s->td[0].counts.eob));
} else {
memset(&s->td[i].counts, 0, sizeof(s->td[0].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)? */
@ -789,7 +901,7 @@ static int decode_frame_header(AVCodecContext *avctx,
else
p[n] = r[n];
}
p[3] = 0;
memcpy(&p[3], ff_vp9_model_pareto8[p[2]], 8);
}
} else {
for (j = 0; j < 2; j++)
@ -801,7 +913,7 @@ static int decode_frame_header(AVCodecContext *avctx,
if (m > 3 && l == 0) // dc only has 3 pt
break;
memcpy(p, r, 3);
p[3] = 0;
memcpy(&p[3], ff_vp9_model_pareto8[p[2]], 8);
}
}
if (s->s.h.txfmmode == i)
@ -929,12 +1041,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;
const 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 +1056,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;
const 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 +1132,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);
} 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);
} else if (td->b->bl == bl) {
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 +1179,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->active_tile_cols; i++) {
av_freep(&s->td[i].b_base);
av_freep(&s->td[i].block_base);
}
}
static av_cold int vp9_decode_free(AVCodecContext *avctx)
@ -1090,10 +1206,249 @@ static av_cold int vp9_decode_free(AVCodecContext *avctx)
ff_thread_release_buffer(avctx, &s->next_refs[i]);
av_frame_free(&s->next_refs[i].f);
}
free_buffers(s);
av_freep(&s->c_b);
s->c_b_size = 0;
free_buffers(s);
vp9_free_entries(avctx);
av_freep(&s->td);
return 0;
}
static int decode_tiles(AVCodecContext *avctx,
const uint8_t *data, int size)
{
VP9Context *s = avctx->priv_data;
VP9TileData *td = &s->td[0];
int row, col, tile_row, tile_col, ret;
int bytesperpixel;
int tile_row_start, tile_row_end, tile_col_start, tile_col_end;
AVFrame *f;
ptrdiff_t yoff, uvoff, ls_y, ls_uv;
f = s->s.frames[CUR_FRAME].tf.f;
ls_y = f->linesize[0];
ls_uv =f->linesize[1];
bytesperpixel = s->bytesperpixel;
yoff = uvoff = 0;
for (tile_row = 0; tile_row < s->s.h.tiling.tile_rows; tile_row++) {
set_tile_offset(&tile_row_start, &tile_row_end,
tile_row, s->s.h.tiling.log2_tile_rows, s->sb_rows);
for (tile_col = 0; tile_col < s->s.h.tiling.tile_cols; tile_col++) {
int64_t tile_size;
if (tile_col == s->s.h.tiling.tile_cols - 1 &&
tile_row == s->s.h.tiling.tile_rows - 1) {
tile_size = size;
} else {
tile_size = AV_RB32(data);
data += 4;
size -= 4;
}
if (tile_size > size) {
ff_thread_report_progress(&s->s.frames[CUR_FRAME].tf, INT_MAX, 0);
return AVERROR_INVALIDDATA;
}
ret = ff_vp56_init_range_decoder(&td->c_b[tile_col], data, tile_size);
if (ret < 0)
return ret;
if (vp56_rac_get_prob_branchy(&td->c_b[tile_col], 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;
}
for (row = tile_row_start; row < 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;
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);
td->tile_col_start = tile_col_start;
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);
td->c = &td->c_b[tile_col];
}
for (col = tile_col_start;
col < 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
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);
}
// 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);
}
}
// 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 av_always_inline
int decode_tiles_mt(AVCodecContext *avctx, void *tdata, int jobnr,
int threadnr)
{
VP9Context *s = avctx->priv_data;
VP9TileData *td = &s->td[jobnr];
ptrdiff_t uvoff, yoff, ls_y, ls_uv;
int bytesperpixel = s->bytesperpixel, row, col, tile_row;
unsigned tile_cols_len;
int tile_row_start, tile_row_end, tile_col_start, tile_col_end;
VP9Filter *lflvl_ptr_base;
AVFrame *f;
f = s->s.frames[CUR_FRAME].tf.f;
ls_y = f->linesize[0];
ls_uv =f->linesize[1];
set_tile_offset(&tile_col_start, &tile_col_end,
jobnr, s->s.h.tiling.log2_tile_cols, s->sb_cols);
td->tile_col_start = tile_col_start;
uvoff = (64 * bytesperpixel >> s->ss_h)*(tile_col_start >> 3);
yoff = (64 * bytesperpixel)*(tile_col_start >> 3);
lflvl_ptr_base = s->lflvl+(tile_col_start >> 3);
for (tile_row = 0; tile_row < s->s.h.tiling.tile_rows; tile_row++) {
set_tile_offset(&tile_row_start, &tile_row_end,
tile_row, s->s.h.tiling.log2_tile_rows, s->sb_rows);
td->c = &td->c_b[tile_row];
for (row = tile_row_start; row < tile_row_end;
row += 8, yoff += ls_y * 64, uvoff += ls_uv * 64 >> s->ss_v) {
ptrdiff_t yoff2 = yoff, uvoff2 = uvoff;
VP9Filter *lflvl_ptr = lflvl_ptr_base+s->sb_cols*(row >> 3);
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 = tile_col_start;
col < 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)
memset(lflvl_ptr->mask, 0, sizeof(lflvl_ptr->mask));
decode_sb(td, row, col, lflvl_ptr,
yoff2, uvoff2, BL_64X64);
}
// backup pre-loopfilter reconstruction data for intra
// prediction of next row of sb64s
tile_cols_len = tile_col_end - tile_col_start;
if (row + 8 < s->rows) {
memcpy(s->intra_pred_data[0] + (tile_col_start * 8 * bytesperpixel),
f->data[0] + yoff + 63 * ls_y,
8 * tile_cols_len * bytesperpixel);
memcpy(s->intra_pred_data[1] + (tile_col_start * 8 * bytesperpixel >> s->ss_h),
f->data[1] + uvoff + ((64 >> s->ss_v) - 1) * ls_uv,
8 * tile_cols_len * bytesperpixel >> s->ss_h);
memcpy(s->intra_pred_data[2] + (tile_col_start * 8 * bytesperpixel >> s->ss_h),
f->data[2] + uvoff + ((64 >> s->ss_v) - 1) * ls_uv,
8 * tile_cols_len * bytesperpixel >> s->ss_h);
}
vp9_report_tile_progress(s, row >> 3, 1);
}
}
return 0;
}
static av_always_inline
int loopfilter_proc(AVCodecContext *avctx)
{
VP9Context *s = avctx->priv_data;
ptrdiff_t uvoff, yoff, ls_y, ls_uv;
VP9Filter *lflvl_ptr;
int bytesperpixel = s->bytesperpixel, col, i;
AVFrame *f;
f = s->s.frames[CUR_FRAME].tf.f;
ls_y = f->linesize[0];
ls_uv =f->linesize[1];
for (i = 0; i < s->sb_rows; i++) {
vp9_await_tile_progress(s, i, s->s.h.tiling.tile_cols);
if (s->s.h.filter.level) {
yoff = (ls_y * 64)*i;
uvoff = (ls_uv * 64 >> s->ss_v)*i;
lflvl_ptr = s->lflvl+s->sb_cols*i;
for (col = 0; col < s->cols;
col += 8, yoff += 64 * bytesperpixel,
uvoff += 64 * bytesperpixel >> s->ss_h, lflvl_ptr++) {
ff_vp9_loopfilter_sb(avctx, lflvl_ptr, i << 3, col,
yoff, uvoff);
}
}
}
return 0;
}
@ -1104,12 +1459,10 @@ static int vp9_decode_frame(AVCodecContext *avctx, void *frame,
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, i, j, ref;
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;
if ((ret = decode_frame_header(avctx, data, size, &ref)) < 0) {
return ret;
@ -1159,8 +1512,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
f = s->s.frames[CUR_FRAME].tf.f;
f->key_frame = s->s.h.keyframe;
f->pict_type = (s->s.h.keyframe || s->s.h.intraonly) ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
ls_y = f->linesize[0];
ls_uv =f->linesize[1];
if (s->s.frames[REF_FRAME_SEGMAP].tf.f->buf[0] &&
(s->s.frames[REF_FRAME_MVPAIR].tf.f->width != s->s.frames[CUR_FRAME].tf.f->width ||
@ -1195,7 +1546,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
// main tile decode loop
bytesperpixel = s->bytesperpixel;
memset(s->above_partition_ctx, 0, s->cols);
memset(s->above_skip_ctx, 0, s->cols);
if (s->s.h.keyframe || s->s.h.intraonly) {
@ -1233,20 +1583,28 @@ FF_ENABLE_DEPRECATION_WARNINGS
ff_thread_finish_setup(avctx);
}
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];
if (avctx->active_thread_type & FF_THREAD_SLICE) {
for (i = 0; i < s->sb_rows; i++)
atomic_store(&s->entries[i], 0);
}
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,
tile_row, s->s.h.tiling.log2_tile_rows, s->sb_rows);
if (s->pass != 2) {
do {
for (i = 0; i < s->active_tile_cols; 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];
}
if (avctx->active_thread_type == FF_THREAD_SLICE) {
int tile_row, tile_col;
assert(!pass);
for (tile_row = 0; tile_row < s->s.h.tiling.tile_rows; tile_row++) {
for (tile_col = 0; tile_col < s->s.h.tiling.tile_cols; tile_col++) {
int64_t tile_size;
@ -1258,105 +1616,31 @@ FF_ENABLE_DEPRECATION_WARNINGS
data += 4;
size -= 4;
}
if (tile_size > size) {
ff_thread_report_progress(&s->s.frames[CUR_FRAME].tf, INT_MAX, 0);
if (tile_size > size)
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[tile_col].c_b[tile_row], data, tile_size);
if (ret < 0)
return ret;
if (vp56_rac_get_prob_branchy(&s->c_b[tile_col], 128)) { // marker bit
ff_thread_report_progress(&s->s.frames[CUR_FRAME].tf, INT_MAX, 0);
if (vp56_rac_get_prob_branchy(&s->td[tile_col].c_b[tile_row], 128)) // marker bit
return AVERROR_INVALIDDATA;
}
data += tile_size;
size -= tile_size;
}
}
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;
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);
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);
}
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 (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));
}
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));
}
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);
}
// 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);
}
}
// 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);
}
ff_slice_thread_execute_with_mainfunc(avctx, decode_tiles_mt, loopfilter_proc, s->td, NULL, s->s.h.tiling.tile_cols);
} else {
ret = decode_tiles(avctx, data, size);
if (ret < 0)
return ret;
}
// Sum all counts fields into td[0].counts for tile threading
if (avctx->active_thread_type == FF_THREAD_SLICE)
for (i = 1; i < s->s.h.tiling.tile_cols; i++)
for (j = 0; j < sizeof(s->td[i].counts) / sizeof(unsigned); j++)
((unsigned *)&s->td[0].counts)[j] += ((unsigned *)&s->td[i].counts)[j];
if (s->pass < 2 && s->s.h.refreshctx && !s->s.h.parallelmode) {
ff_vp9_adapt_probs(s);
ff_thread_finish_setup(avctx);
@ -1492,7 +1776,8 @@ 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,
.caps_internal = FF_CODEC_CAP_SLICE_THREAD_HAS_MF,
.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),

View File

@ -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,26 +55,26 @@ 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(td, 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,
mc_luma_dir(td, mc[3][b->filter][0],
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;
if (s->ss_v) {
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,
mc_chroma_dir(td, mc[3 + s->ss_h][b->filter][0],
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,
mc_chroma_dir(td, mc[3 + s->ss_h][b->filter][0],
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),
@ -87,8 +87,8 @@ 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[3 + s->ss_h][b->filter][0],
s->dst[1] + 4 * ls_uv, s->dst[2] + 4 * ls_uv, ls_uv,
mc_chroma_dir(td, mc[3 + s->ss_h][b->filter][0],
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,26 +96,26 @@ 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(td, 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,
mc_luma_dir(td, mc[3][b->filter][1],
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;
if (s->ss_v) {
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,
mc_chroma_dir(td, mc[3 + s->ss_h][b->filter][1],
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,
mc_chroma_dir(td, mc[3 + s->ss_h][b->filter][1],
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),
@ -128,8 +128,8 @@ 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[3 + s->ss_h][b->filter][1],
s->dst[1] + 4 * ls_uv, s->dst[2] + 4 * ls_uv, ls_uv,
mc_chroma_dir(td, mc[3 + s->ss_h][b->filter][1],
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,32 +137,32 @@ 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(td, 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(td, 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;
if (s->ss_h) {
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,
mc_chroma_dir(td, mc[4][b->filter][0],
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,
mc_chroma_dir(td, mc[4][b->filter][0],
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,
mc_chroma_dir(td, mc[4][b->filter][0],
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,32 +170,32 @@ 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(td, 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(td, 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;
if (s->ss_h) {
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,
mc_chroma_dir(td, mc[4][b->filter][1],
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,
mc_chroma_dir(td, mc[4][b->filter][1],
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,
mc_chroma_dir(td, mc[4][b->filter][1],
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(td, 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(td, 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,
mc_luma_dir(td, mc[4][b->filter][0],
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,
mc_luma_dir(td, mc[4][b->filter][0],
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);
@ -235,24 +235,24 @@ static void FN(inter_pred)(AVCodecContext *avctx)
w1 = (w1 + 1) >> 1;
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,
mc_chroma_dir(td, mc[4][b->filter][0],
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,
&uvmv, 0, 0, 4, 4, 4, 4, w1, h1, 0);
} 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,
mc_chroma_dir(td, mc[4][b->filter][0],
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,
mc_chroma_dir(td, mc[4][b->filter][0],
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,
@ -262,8 +262,8 @@ static void FN(inter_pred)(AVCodecContext *avctx)
if (s->ss_h) {
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,
mc_chroma_dir(td, mc[4][b->filter][0],
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,
@ -272,35 +272,35 @@ static void FN(inter_pred)(AVCodecContext *avctx)
// bottom block
// 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,
mc_chroma_dir(td, mc[4][b->filter][0],
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,
mc_chroma_dir(td, mc[4][b->filter][0],
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,
mc_chroma_dir(td, mc[4][b->filter][0],
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,
mc_chroma_dir(td, mc[4][b->filter][0],
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,
mc_chroma_dir(td, mc[4][b->filter][0],
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(td, 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(td, 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,
mc_luma_dir(td, mc[4][b->filter][1],
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,
mc_luma_dir(td, mc[4][b->filter][1],
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) {
@ -329,24 +329,24 @@ static void FN(inter_pred)(AVCodecContext *avctx)
w2 = (w2 + 1) >> 1;
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,
mc_chroma_dir(td, mc[4][b->filter][1],
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,
&uvmv, 0, 0, 4, 4, 4, 4, w2, h2, 1);
} 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,
mc_chroma_dir(td, mc[4][b->filter][1],
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,
mc_chroma_dir(td, mc[4][b->filter][1],
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,
@ -356,8 +356,8 @@ static void FN(inter_pred)(AVCodecContext *avctx)
if (s->ss_h) {
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,
mc_chroma_dir(td, mc[4][b->filter][1],
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,
@ -366,35 +366,35 @@ static void FN(inter_pred)(AVCodecContext *avctx)
// bottom block
// 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,
mc_chroma_dir(td, mc[4][b->filter][1],
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,
mc_chroma_dir(td, mc[4][b->filter][1],
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,
mc_chroma_dir(td, mc[4][b->filter][1],
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,
mc_chroma_dir(td, mc[4][b->filter][1],
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,
mc_chroma_dir(td, mc[4][b->filter][1],
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(td, 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,
mc_chroma_dir(td, mc[bwl + s->ss_h][b->filter][0],
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(td, 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,
mc_chroma_dir(td, mc[bwl + s->ss_h][b->filter][1],
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),

File diff suppressed because it is too large Load Diff

View File

@ -26,8 +26,10 @@
#include <stddef.h>
#include <stdint.h>
#include <stdatomic.h>
#include "libavutil/buffer.h"
#include "libavutil/thread.h"
#include "libavutil/internal.h"
#include "vp9.h"
@ -84,20 +86,21 @@ 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;
VP9Block *b_base, *b;
int pass;
int row, row7, col, col7;
uint8_t *dst[3];
ptrdiff_t y_stride, uv_stride;
int pass, active_tile_cols;
pthread_mutex_t progress_mutex;
pthread_cond_t progress_cond;
atomic_int *entries;
uint8_t ss_h, ss_v;
uint8_t last_bpp, bpp_index, bytesperpixel;
@ -115,7 +118,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];
@ -124,6 +126,44 @@ typedef struct VP9Context {
ProbContext p;
uint8_t coef[4][2][2][6][6][11];
} prob;
// contextual (above) cache
uint8_t *above_partition_ctx;
uint8_t *above_mode_ctx;
// FIXME maybe merge some of the below in a flags field?
uint8_t *above_y_nnz_ctx;
uint8_t *above_uv_nnz_ctx[2];
uint8_t *above_skip_ctx; // 1bit
uint8_t *above_txfm_ctx; // 2bit
uint8_t *above_segpred_ctx; // 1bit
uint8_t *above_intra_ctx; // 1bit
uint8_t *above_comp_ctx; // 1bit
uint8_t *above_ref_ctx; // 2bit
uint8_t *above_filter_ctx;
VP56mv (*above_mv_ctx)[2];
// whole-frame cache
uint8_t *intra_pred_data[3];
VP9Filter *lflvl;
// block reconstruction intermediates
int block_alloc_using_2pass;
uint16_t mvscale[3][2];
uint8_t mvstep[3][2];
} VP9Context;
struct VP9TileData {
//VP9Context should be const, but because of the threading API(generates
//a lot of warnings) it's not.
VP9Context *s;
VP56RangeCoder *c_b;
VP56RangeCoder *c;
int row, row7, col, col7;
uint8_t *dst[3];
ptrdiff_t y_stride, uv_stride;
VP9Block *b_base, *b;
unsigned tile_col_start;
struct {
unsigned y_mode[4][10];
unsigned uv_mode[10][10];
@ -153,7 +193,10 @@ typedef struct VP9Context {
unsigned eob[4][2][2][6][6][2];
} counts;
// contextual (left/above) cache
// whole-frame cache
DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[135 * 144 * 2];
// 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];
@ -166,52 +209,30 @@ typedef struct VP9Context {
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];
uint8_t *above_partition_ctx;
uint8_t *above_mode_ctx;
// FIXME maybe merge some of the below in a flags field?
uint8_t *above_y_nnz_ctx;
uint8_t *above_uv_nnz_ctx[2];
uint8_t *above_skip_ctx; // 1bit
uint8_t *above_txfm_ctx; // 2bit
uint8_t *above_segpred_ctx; // 1bit
uint8_t *above_intra_ctx; // 1bit
uint8_t *above_comp_ctx; // 1bit
uint8_t *above_ref_ctx; // 2bit
uint8_t *above_filter_ctx;
VP56mv (*above_mv_ctx)[2];
// whole-frame cache
uint8_t *intra_pred_data[3];
VP9Filter *lflvl;
DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[135 * 144 * 2];
// block reconstruction intermediates
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;
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];
};
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);
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 */

View File

@ -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);
}
}
}

View File

@ -56,8 +56,8 @@ void ff_vp9_adapt_probs(VP9Context *s)
for (l = 0; l < 6; l++)
for (m = 0; m < 6; m++) {
uint8_t *pp = s->prob_ctx[s->s.h.framectxid].coef[i][j][k][l][m];
unsigned *e = s->counts.eob[i][j][k][l][m];
unsigned *c = s->counts.coef[i][j][k][l][m];
unsigned *e = s->td[0].counts.eob[i][j][k][l][m];
unsigned *c = s->td[0].counts.coef[i][j][k][l][m];
if (l == 0 && m >= 3) // dc only has 3 pt
break;
@ -77,32 +77,32 @@ void ff_vp9_adapt_probs(VP9Context *s)
// skip flag
for (i = 0; i < 3; i++)
adapt_prob(&p->skip[i], s->counts.skip[i][0],
s->counts.skip[i][1], 20, 128);
adapt_prob(&p->skip[i], s->td[0].counts.skip[i][0],
s->td[0].counts.skip[i][1], 20, 128);
// intra/inter flag
for (i = 0; i < 4; i++)
adapt_prob(&p->intra[i], s->counts.intra[i][0],
s->counts.intra[i][1], 20, 128);
adapt_prob(&p->intra[i], s->td[0].counts.intra[i][0],
s->td[0].counts.intra[i][1], 20, 128);
// comppred flag
if (s->s.h.comppredmode == PRED_SWITCHABLE) {
for (i = 0; i < 5; i++)
adapt_prob(&p->comp[i], s->counts.comp[i][0],
s->counts.comp[i][1], 20, 128);
adapt_prob(&p->comp[i], s->td[0].counts.comp[i][0],
s->td[0].counts.comp[i][1], 20, 128);
}
// reference frames
if (s->s.h.comppredmode != PRED_SINGLEREF) {
for (i = 0; i < 5; i++)
adapt_prob(&p->comp_ref[i], s->counts.comp_ref[i][0],
s->counts.comp_ref[i][1], 20, 128);
adapt_prob(&p->comp_ref[i], s->td[0].counts.comp_ref[i][0],
s->td[0].counts.comp_ref[i][1], 20, 128);
}
if (s->s.h.comppredmode != PRED_COMPREF) {
for (i = 0; i < 5; i++) {
uint8_t *pp = p->single_ref[i];
unsigned (*c)[2] = s->counts.single_ref[i];
unsigned (*c)[2] = s->td[0].counts.single_ref[i];
adapt_prob(&pp[0], c[0][0], c[0][1], 20, 128);
adapt_prob(&pp[1], c[1][0], c[1][1], 20, 128);
@ -113,7 +113,7 @@ void ff_vp9_adapt_probs(VP9Context *s)
for (i = 0; i < 4; i++)
for (j = 0; j < 4; j++) {
uint8_t *pp = p->partition[i][j];
unsigned *c = s->counts.partition[i][j];
unsigned *c = s->td[0].counts.partition[i][j];
adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
@ -123,10 +123,10 @@ void ff_vp9_adapt_probs(VP9Context *s)
// tx size
if (s->s.h.txfmmode == TX_SWITCHABLE) {
for (i = 0; i < 2; i++) {
unsigned *c16 = s->counts.tx16p[i], *c32 = s->counts.tx32p[i];
unsigned *c16 = s->td[0].counts.tx16p[i], *c32 = s->td[0].counts.tx32p[i];
adapt_prob(&p->tx8p[i], s->counts.tx8p[i][0],
s->counts.tx8p[i][1], 20, 128);
adapt_prob(&p->tx8p[i], s->td[0].counts.tx8p[i][0],
s->td[0].counts.tx8p[i][1], 20, 128);
adapt_prob(&p->tx16p[i][0], c16[0], c16[1] + c16[2], 20, 128);
adapt_prob(&p->tx16p[i][1], c16[1], c16[2], 20, 128);
adapt_prob(&p->tx32p[i][0], c32[0], c32[1] + c32[2] + c32[3], 20, 128);
@ -139,7 +139,7 @@ void ff_vp9_adapt_probs(VP9Context *s)
if (s->s.h.filtermode == FILTER_SWITCHABLE) {
for (i = 0; i < 4; i++) {
uint8_t *pp = p->filter[i];
unsigned *c = s->counts.filter[i];
unsigned *c = s->td[0].counts.filter[i];
adapt_prob(&pp[0], c[0], c[1] + c[2], 20, 128);
adapt_prob(&pp[1], c[1], c[2], 20, 128);
@ -149,7 +149,7 @@ void ff_vp9_adapt_probs(VP9Context *s)
// inter modes
for (i = 0; i < 7; i++) {
uint8_t *pp = p->mv_mode[i];
unsigned *c = s->counts.mv_mode[i];
unsigned *c = s->td[0].counts.mv_mode[i];
adapt_prob(&pp[0], c[2], c[1] + c[0] + c[3], 20, 128);
adapt_prob(&pp[1], c[0], c[1] + c[3], 20, 128);
@ -159,7 +159,7 @@ void ff_vp9_adapt_probs(VP9Context *s)
// mv joints
{
uint8_t *pp = p->mv_joint;
unsigned *c = s->counts.mv_joint;
unsigned *c = s->td[0].counts.mv_joint;
adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
@ -171,11 +171,11 @@ void ff_vp9_adapt_probs(VP9Context *s)
uint8_t *pp;
unsigned *c, (*c2)[2], sum;
adapt_prob(&p->mv_comp[i].sign, s->counts.mv_comp[i].sign[0],
s->counts.mv_comp[i].sign[1], 20, 128);
adapt_prob(&p->mv_comp[i].sign, s->td[0].counts.mv_comp[i].sign[0],
s->td[0].counts.mv_comp[i].sign[1], 20, 128);
pp = p->mv_comp[i].classes;
c = s->counts.mv_comp[i].classes;
c = s->td[0].counts.mv_comp[i].classes;
sum = c[1] + c[2] + c[3] + c[4] + c[5] +
c[6] + c[7] + c[8] + c[9] + c[10];
adapt_prob(&pp[0], c[0], sum, 20, 128);
@ -193,39 +193,39 @@ void ff_vp9_adapt_probs(VP9Context *s)
adapt_prob(&pp[8], c[7], c[8], 20, 128);
adapt_prob(&pp[9], c[9], c[10], 20, 128);
adapt_prob(&p->mv_comp[i].class0, s->counts.mv_comp[i].class0[0],
s->counts.mv_comp[i].class0[1], 20, 128);
adapt_prob(&p->mv_comp[i].class0, s->td[0].counts.mv_comp[i].class0[0],
s->td[0].counts.mv_comp[i].class0[1], 20, 128);
pp = p->mv_comp[i].bits;
c2 = s->counts.mv_comp[i].bits;
c2 = s->td[0].counts.mv_comp[i].bits;
for (j = 0; j < 10; j++)
adapt_prob(&pp[j], c2[j][0], c2[j][1], 20, 128);
for (j = 0; j < 2; j++) {
pp = p->mv_comp[i].class0_fp[j];
c = s->counts.mv_comp[i].class0_fp[j];
c = s->td[0].counts.mv_comp[i].class0_fp[j];
adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
adapt_prob(&pp[2], c[2], c[3], 20, 128);
}
pp = p->mv_comp[i].fp;
c = s->counts.mv_comp[i].fp;
c = s->td[0].counts.mv_comp[i].fp;
adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
adapt_prob(&pp[2], c[2], c[3], 20, 128);
if (s->s.h.highprecisionmvs) {
adapt_prob(&p->mv_comp[i].class0_hp,
s->counts.mv_comp[i].class0_hp[0],
s->counts.mv_comp[i].class0_hp[1], 20, 128);
adapt_prob(&p->mv_comp[i].hp, s->counts.mv_comp[i].hp[0],
s->counts.mv_comp[i].hp[1], 20, 128);
s->td[0].counts.mv_comp[i].class0_hp[0],
s->td[0].counts.mv_comp[i].class0_hp[1], 20, 128);
adapt_prob(&p->mv_comp[i].hp, s->td[0].counts.mv_comp[i].hp[0],
s->td[0].counts.mv_comp[i].hp[1], 20, 128);
}
}
// y intra modes
for (i = 0; i < 4; i++) {
uint8_t *pp = p->y_mode[i];
unsigned *c = s->counts.y_mode[i], sum, s2;
unsigned *c = s->td[0].counts.y_mode[i], sum, s2;
sum = c[0] + c[1] + c[3] + c[4] + c[5] + c[6] + c[7] + c[8] + c[9];
adapt_prob(&pp[0], c[DC_PRED], sum, 20, 128);
@ -250,7 +250,7 @@ void ff_vp9_adapt_probs(VP9Context *s)
// uv intra modes
for (i = 0; i < 10; i++) {
uint8_t *pp = p->uv_mode[i];
unsigned *c = s->counts.uv_mode[i], sum, s2;
unsigned *c = s->td[0].counts.uv_mode[i], sum, s2;
sum = c[0] + c[1] + c[3] + c[4] + c[5] + c[6] + c[7] + c[8] + c[9];
adapt_prob(&pp[0], c[DC_PRED], sum, 20, 128);

View File

@ -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,40 +268,41 @@ 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],
static av_always_inline void mc_luma_unscaled(VP9TileData *td, vp9_mc_func (*mc)[2],
uint8_t *dst, ptrdiff_t dst_stride,
const uint8_t *ref, ptrdiff_t ref_stride,
ThreadFrame *ref_frame,
ptrdiff_t y, ptrdiff_t x, const VP56mv *mv,
int bw, int bh, int w, int h, int bytesperpixel)
{
VP9Context *s = td->s;
int mx = mv->x, my = mv->y, th;
y += my >> 3;
@ -318,18 +320,18 @@ static av_always_inline void mc_luma_unscaled(VP9Context *s, vp9_mc_func (*mc)[2
// (!!my * 5) than horizontally (!!mx * 4).
if (x < !!mx * 3 || y < !!my * 3 ||
x + !!mx * 4 > w - bw || y + !!my * 5 > h - bh) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
s->vdsp.emulated_edge_mc(td->edge_emu_buffer,
ref - !!my * 3 * ref_stride - !!mx * 3 * bytesperpixel,
160, ref_stride,
bw + !!mx * 7, bh + !!my * 7,
x - !!mx * 3, y - !!my * 3, w, h);
ref = s->edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
ref = td->edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
ref_stride = 160;
}
mc[!!mx][!!my](dst, dst_stride, ref, ref_stride, bh, mx << 1, my << 1);
}
static av_always_inline void mc_chroma_unscaled(VP9Context *s, vp9_mc_func (*mc)[2],
static av_always_inline void mc_chroma_unscaled(VP9TileData *td, vp9_mc_func (*mc)[2],
uint8_t *dst_u, uint8_t *dst_v,
ptrdiff_t dst_stride,
const uint8_t *ref_u, ptrdiff_t src_stride_u,
@ -338,6 +340,7 @@ static av_always_inline void mc_chroma_unscaled(VP9Context *s, vp9_mc_func (*mc)
ptrdiff_t y, ptrdiff_t x, const VP56mv *mv,
int bw, int bh, int w, int h, int bytesperpixel)
{
VP9Context *s = td->s;
int mx = mv->x * (1 << !s->ss_h), my = mv->y * (1 << !s->ss_v), th;
y += my >> 4;
@ -356,20 +359,20 @@ static av_always_inline void mc_chroma_unscaled(VP9Context *s, vp9_mc_func (*mc)
// (!!my * 5) than horizontally (!!mx * 4).
if (x < !!mx * 3 || y < !!my * 3 ||
x + !!mx * 4 > w - bw || y + !!my * 5 > h - bh) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
s->vdsp.emulated_edge_mc(td->edge_emu_buffer,
ref_u - !!my * 3 * src_stride_u - !!mx * 3 * bytesperpixel,
160, src_stride_u,
bw + !!mx * 7, bh + !!my * 7,
x - !!mx * 3, y - !!my * 3, w, h);
ref_u = s->edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
ref_u = td->edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
mc[!!mx][!!my](dst_u, dst_stride, ref_u, 160, bh, mx, my);
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
s->vdsp.emulated_edge_mc(td->edge_emu_buffer,
ref_v - !!my * 3 * src_stride_v - !!mx * 3 * bytesperpixel,
160, src_stride_v,
bw + !!mx * 7, bh + !!my * 7,
x - !!mx * 3, y - !!my * 3, w, h);
ref_v = s->edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
ref_v = td->edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
mc[!!mx][!!my](dst_v, dst_stride, ref_v, 160, bh, mx, my);
} else {
mc[!!mx][!!my](dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my);
@ -377,13 +380,13 @@ static av_always_inline void mc_chroma_unscaled(VP9Context *s, vp9_mc_func (*mc)
}
}
#define mc_luma_dir(s, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, \
#define mc_luma_dir(td, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, \
px, py, pw, ph, bw, bh, w, h, i) \
mc_luma_unscaled(s, s->dsp.mc, dst, dst_ls, src, src_ls, tref, row, col, \
mc_luma_unscaled(td, s->dsp.mc, dst, dst_ls, src, src_ls, tref, row, col, \
mv, bw, bh, w, h, bytesperpixel)
#define mc_chroma_dir(s, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
#define mc_chroma_dir(td, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
row, col, mv, px, py, pw, ph, bw, bh, w, h, i) \
mc_chroma_unscaled(s, s->dsp.mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
mc_chroma_unscaled(td, s->dsp.mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
row, col, mv, bw, bh, w, h, bytesperpixel)
#define SCALED 0
#define FN(x) x##_8bpp
@ -400,7 +403,7 @@ static av_always_inline void mc_chroma_unscaled(VP9Context *s, vp9_mc_func (*mc)
#undef BYTES_PER_PIXEL
#undef SCALED
static av_always_inline void mc_luma_scaled(VP9Context *s, vp9_scaled_mc_func smc,
static av_always_inline void mc_luma_scaled(VP9TileData *td, vp9_scaled_mc_func smc,
vp9_mc_func (*mc)[2],
uint8_t *dst, ptrdiff_t dst_stride,
const uint8_t *ref, ptrdiff_t ref_stride,
@ -410,9 +413,10 @@ static av_always_inline void mc_luma_scaled(VP9Context *s, vp9_scaled_mc_func sm
int bw, int bh, int w, int h, int bytesperpixel,
const uint16_t *scale, const uint8_t *step)
{
VP9Context *s = td->s;
if (s->s.frames[CUR_FRAME].tf.f->width == ref_frame->f->width &&
s->s.frames[CUR_FRAME].tf.f->height == ref_frame->f->height) {
mc_luma_unscaled(s, mc, dst, dst_stride, ref, ref_stride, ref_frame,
mc_luma_unscaled(td, mc, dst, dst_stride, ref, ref_stride, ref_frame,
y, x, in_mv, bw, bh, w, h, bytesperpixel);
} else {
#define scale_mv(n, dim) (((int64_t)(n) * scale[dim]) >> 14)
@ -445,19 +449,19 @@ static av_always_inline void mc_luma_scaled(VP9Context *s, vp9_scaled_mc_func sm
// needed, so switch to emulated edge one pixel sooner vertically
// (y + 5 >= h - refbh_m1) than horizontally (x + 4 >= w - refbw_m1).
if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 5 >= h - refbh_m1) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
s->vdsp.emulated_edge_mc(td->edge_emu_buffer,
ref - 3 * ref_stride - 3 * bytesperpixel,
288, ref_stride,
refbw_m1 + 8, refbh_m1 + 8,
x - 3, y - 3, w, h);
ref = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;
ref = td->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;
ref_stride = 288;
}
smc(dst, dst_stride, ref, ref_stride, bh, mx, my, step[0], step[1]);
}
}
static av_always_inline void mc_chroma_scaled(VP9Context *s, vp9_scaled_mc_func smc,
static av_always_inline void mc_chroma_scaled(VP9TileData *td, vp9_scaled_mc_func smc,
vp9_mc_func (*mc)[2],
uint8_t *dst_u, uint8_t *dst_v,
ptrdiff_t dst_stride,
@ -469,9 +473,10 @@ static av_always_inline void mc_chroma_scaled(VP9Context *s, vp9_scaled_mc_func
int bw, int bh, int w, int h, int bytesperpixel,
const uint16_t *scale, const uint8_t *step)
{
VP9Context *s = td->s;
if (s->s.frames[CUR_FRAME].tf.f->width == ref_frame->f->width &&
s->s.frames[CUR_FRAME].tf.f->height == ref_frame->f->height) {
mc_chroma_unscaled(s, mc, dst_u, dst_v, dst_stride, ref_u, src_stride_u,
mc_chroma_unscaled(td, mc, dst_u, dst_v, dst_stride, ref_u, src_stride_u,
ref_v, src_stride_v, ref_frame,
y, x, in_mv, bw, bh, w, h, bytesperpixel);
} else {
@ -514,20 +519,20 @@ static av_always_inline void mc_chroma_scaled(VP9Context *s, vp9_scaled_mc_func
// needed, so switch to emulated edge one pixel sooner vertically
// (y + 5 >= h - refbh_m1) than horizontally (x + 4 >= w - refbw_m1).
if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 5 >= h - refbh_m1) {
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
s->vdsp.emulated_edge_mc(td->edge_emu_buffer,
ref_u - 3 * src_stride_u - 3 * bytesperpixel,
288, src_stride_u,
refbw_m1 + 8, refbh_m1 + 8,
x - 3, y - 3, w, h);
ref_u = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;
ref_u = td->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;
smc(dst_u, dst_stride, ref_u, 288, bh, mx, my, step[0], step[1]);
s->vdsp.emulated_edge_mc(s->edge_emu_buffer,
s->vdsp.emulated_edge_mc(td->edge_emu_buffer,
ref_v - 3 * src_stride_v - 3 * bytesperpixel,
288, src_stride_v,
refbw_m1 + 8, refbh_m1 + 8,
x - 3, y - 3, w, h);
ref_v = s->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;
ref_v = td->edge_emu_buffer + 3 * 288 + 3 * bytesperpixel;
smc(dst_v, dst_stride, ref_v, 288, bh, mx, my, step[0], step[1]);
} else {
smc(dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my, step[0], step[1]);
@ -536,14 +541,14 @@ static av_always_inline void mc_chroma_scaled(VP9Context *s, vp9_scaled_mc_func
}
}
#define mc_luma_dir(s, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, \
#define mc_luma_dir(td, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, \
px, py, pw, ph, bw, bh, w, h, i) \
mc_luma_scaled(s, s->dsp.s##mc, s->dsp.mc, dst, dst_ls, src, src_ls, tref, row, col, \
mc_luma_scaled(td, s->dsp.s##mc, s->dsp.mc, dst, dst_ls, src, src_ls, tref, row, col, \
mv, px, py, pw, ph, bw, bh, w, h, bytesperpixel, \
s->mvscale[b->ref[i]], s->mvstep[b->ref[i]])
#define mc_chroma_dir(s, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
#define mc_chroma_dir(td, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
row, col, mv, px, py, pw, ph, bw, bh, w, h, i) \
mc_chroma_scaled(s, s->dsp.s##mc, s->dsp.mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
mc_chroma_scaled(td, s->dsp.s##mc, s->dsp.mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
row, col, mv, px, py, pw, ph, bw, bh, w, h, bytesperpixel, \
s->mvscale[b->ref[i]], s->mvstep[b->ref[i]])
#define SCALED 1
@ -561,23 +566,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 +595,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 +616,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);
}