mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-22 06:46:59 +00:00
vp9: move some entries out of VP9Block into VP9Context.
They aren't really block-related variables in the sense that they are not block-coded, rather they are state trackers.
This commit is contained in:
parent
84d362f020
commit
39b244002a
118
libavcodec/vp9.c
118
libavcodec/vp9.c
@ -81,9 +81,6 @@ typedef struct VP9Block {
|
||||
enum BlockSize bs;
|
||||
enum TxfmMode tx, uvtx;
|
||||
|
||||
int row, row7, col, col7;
|
||||
uint8_t *dst[3];
|
||||
ptrdiff_t y_stride, uv_stride;
|
||||
} VP9Block;
|
||||
|
||||
typedef struct VP9Context {
|
||||
@ -94,6 +91,9 @@ typedef struct VP9Context {
|
||||
VP56RangeCoder *c_b;
|
||||
unsigned c_b_size;
|
||||
VP9Block b;
|
||||
int row, row7, col, col7;
|
||||
uint8_t *dst[3];
|
||||
ptrdiff_t y_stride, uv_stride;
|
||||
|
||||
// bitstream header
|
||||
uint8_t profile;
|
||||
@ -862,7 +862,7 @@ static void find_ref_mvs(VP9Context *s,
|
||||
{ -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 }},
|
||||
};
|
||||
VP9Block *const b = &s->b;
|
||||
int row = b->row, col = b->col, row7 = b->row7;
|
||||
int row = s->row, col = s->col, row7 = s->row7;
|
||||
const int8_t (*p)[2] = mv_ref_blk_off[b->bs];
|
||||
#define INVALID_MV 0x80008000U
|
||||
uint32_t mem = INVALID_MV;
|
||||
@ -1158,7 +1158,7 @@ static void decode_mode(AVCodecContext *ctx)
|
||||
};
|
||||
VP9Context *s = ctx->priv_data;
|
||||
VP9Block *const b = &s->b;
|
||||
int row = b->row, col = b->col, row7 = b->row7;
|
||||
int row = s->row, col = s->col, row7 = s->row7;
|
||||
enum TxfmMode max_tx = max_tx_for_bl_bp[b->bs];
|
||||
int w4 = FFMIN(s->cols - col, bwh_tab[1][b->bs][0]);
|
||||
int h4 = FFMIN(s->rows - row, bwh_tab[1][b->bs][1]), y;
|
||||
@ -1903,7 +1903,7 @@ static int decode_coeffs(AVCodecContext *ctx)
|
||||
{
|
||||
VP9Context *s = ctx->priv_data;
|
||||
VP9Block *const b = &s->b;
|
||||
int row = b->row, col = b->col;
|
||||
int row = s->row, col = s->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];
|
||||
@ -2147,14 +2147,14 @@ static void intra_recon(AVCodecContext *ctx, ptrdiff_t y_off, ptrdiff_t uv_off)
|
||||
{
|
||||
VP9Context *s = ctx->priv_data;
|
||||
VP9Block *const b = &s->b;
|
||||
int row = b->row, col = b->col;
|
||||
int row = s->row, col = s->col;
|
||||
int w4 = bwh_tab[1][b->bs][0] << 1, step1d = 1 << b->tx, n;
|
||||
int h4 = bwh_tab[1][b->bs][1] << 1, x, y, step = 1 << (b->tx * 2);
|
||||
int end_x = FFMIN(2 * (s->cols - col), w4);
|
||||
int end_y = FFMIN(2 * (s->rows - row), h4);
|
||||
int tx = 4 * s->lossless + b->tx, uvtx = b->uvtx + 4 * s->lossless;
|
||||
int uvstep1d = 1 << b->uvtx, p;
|
||||
uint8_t *dst = b->dst[0], *dst_r = s->f->data[0] + y_off;
|
||||
uint8_t *dst = s->dst[0], *dst_r = s->f->data[0] + y_off;
|
||||
|
||||
for (n = 0, y = 0; y < end_y; y += step1d) {
|
||||
uint8_t *ptr = dst, *ptr_r = dst_r;
|
||||
@ -2168,15 +2168,15 @@ static void intra_recon(AVCodecContext *ctx, ptrdiff_t y_off, ptrdiff_t uv_off)
|
||||
int eob = b->skip ? 0 : b->tx > TX_8X8 ? AV_RN16A(&s->eob[n]) : s->eob[n];
|
||||
|
||||
mode = check_intra_mode(s, mode, &a, ptr_r, s->f->linesize[0],
|
||||
ptr, b->y_stride, l,
|
||||
ptr, s->y_stride, l,
|
||||
col, x, w4, row, y, b->tx, 0);
|
||||
s->dsp.intra_pred[b->tx][mode](ptr, b->y_stride, l, a);
|
||||
s->dsp.intra_pred[b->tx][mode](ptr, s->y_stride, l, a);
|
||||
if (eob)
|
||||
s->dsp.itxfm_add[tx][txtp](ptr, b->y_stride,
|
||||
s->dsp.itxfm_add[tx][txtp](ptr, s->y_stride,
|
||||
s->block + 16 * n, eob);
|
||||
}
|
||||
dst_r += 4 * s->f->linesize[0] * step1d;
|
||||
dst += 4 * b->y_stride * step1d;
|
||||
dst += 4 * step1d * s->y_stride;
|
||||
}
|
||||
|
||||
// U/V
|
||||
@ -2186,7 +2186,7 @@ static void intra_recon(AVCodecContext *ctx, ptrdiff_t y_off, ptrdiff_t uv_off)
|
||||
end_y >>= 1;
|
||||
step = 1 << (b->uvtx * 2);
|
||||
for (p = 0; p < 2; p++) {
|
||||
dst = b->dst[1 + p];
|
||||
dst = s->dst[1 + p];
|
||||
dst_r = s->f->data[1 + p] + uv_off;
|
||||
for (n = 0, y = 0; y < end_y; y += uvstep1d) {
|
||||
uint8_t *ptr = dst, *ptr_r = dst_r;
|
||||
@ -2198,15 +2198,15 @@ static void intra_recon(AVCodecContext *ctx, ptrdiff_t y_off, ptrdiff_t uv_off)
|
||||
int eob = b->skip ? 0 : b->uvtx > TX_8X8 ? AV_RN16A(&s->uveob[p][n]) : s->uveob[p][n];
|
||||
|
||||
mode = check_intra_mode(s, mode, &a, ptr_r, s->f->linesize[1],
|
||||
ptr, b->uv_stride, l,
|
||||
ptr, s->uv_stride, l,
|
||||
col, x, w4, row, y, b->uvtx, p + 1);
|
||||
s->dsp.intra_pred[b->uvtx][mode](ptr, b->uv_stride, l, a);
|
||||
s->dsp.intra_pred[b->uvtx][mode](ptr, s->uv_stride, l, a);
|
||||
if (eob)
|
||||
s->dsp.itxfm_add[uvtx][DCT_DCT](ptr, b->uv_stride,
|
||||
s->dsp.itxfm_add[uvtx][DCT_DCT](ptr, s->uv_stride,
|
||||
s->uvblock[p] + 16 * n, eob);
|
||||
}
|
||||
dst_r += 4 * uvstep1d * s->f->linesize[1];
|
||||
dst += 4 * uvstep1d * b->uv_stride;
|
||||
dst += 4 * uvstep1d * s->uv_stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2286,45 +2286,45 @@ static void inter_recon(AVCodecContext *ctx)
|
||||
};
|
||||
VP9Context *s = ctx->priv_data;
|
||||
VP9Block *const b = &s->b;
|
||||
int row = b->row, col = b->col;
|
||||
AVFrame *ref1 = s->refs[s->refidx[b->ref[0]]];
|
||||
AVFrame *ref2 = b->comp ? s->refs[s->refidx[b->ref[1]]] : NULL;
|
||||
int row = s->row, col = s->col;
|
||||
int w = ctx->width, h = ctx->height;
|
||||
ptrdiff_t ls_y = b->y_stride, ls_uv = b->uv_stride;
|
||||
ptrdiff_t ls_y = s->y_stride, ls_uv = s->uv_stride;
|
||||
|
||||
// y inter pred
|
||||
if (b->bs > BS_8x8) {
|
||||
if (b->bs == BS_8x4) {
|
||||
mc_luma_dir(s, s->dsp.mc[3][b->filter][0], b->dst[0], ls_y,
|
||||
mc_luma_dir(s, s->dsp.mc[3][b->filter][0], s->dst[0], ls_y,
|
||||
ref1->data[0], ref1->linesize[0],
|
||||
row << 3, col << 3, &b->mv[0][0], 8, 4, w, h);
|
||||
mc_luma_dir(s, s->dsp.mc[3][b->filter][0],
|
||||
b->dst[0] + 4 * ls_y, ls_y,
|
||||
s->dst[0] + 4 * ls_y, ls_y,
|
||||
ref1->data[0], ref1->linesize[0],
|
||||
(row << 3) + 4, col << 3, &b->mv[2][0], 8, 4, w, h);
|
||||
|
||||
if (b->comp) {
|
||||
mc_luma_dir(s, s->dsp.mc[3][b->filter][1], b->dst[0], ls_y,
|
||||
mc_luma_dir(s, s->dsp.mc[3][b->filter][1], s->dst[0], ls_y,
|
||||
ref2->data[0], ref2->linesize[0],
|
||||
row << 3, col << 3, &b->mv[0][1], 8, 4, w, h);
|
||||
mc_luma_dir(s, s->dsp.mc[3][b->filter][1],
|
||||
b->dst[0] + 4 * ls_y, ls_y,
|
||||
s->dst[0] + 4 * ls_y, ls_y,
|
||||
ref2->data[0], ref2->linesize[0],
|
||||
(row << 3) + 4, col << 3, &b->mv[2][1], 8, 4, w, h);
|
||||
}
|
||||
} else if (b->bs == BS_4x8) {
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], b->dst[0], ls_y,
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], s->dst[0], ls_y,
|
||||
ref1->data[0], ref1->linesize[0],
|
||||
row << 3, col << 3, &b->mv[0][0], 4, 8, w, h);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], b->dst[0] + 4, ls_y,
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], s->dst[0] + 4, ls_y,
|
||||
ref1->data[0], ref1->linesize[0],
|
||||
row << 3, (col << 3) + 4, &b->mv[1][0], 4, 8, w, h);
|
||||
|
||||
if (b->comp) {
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], b->dst[0], ls_y,
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], s->dst[0], ls_y,
|
||||
ref2->data[0], ref2->linesize[0],
|
||||
row << 3, col << 3, &b->mv[0][1], 4, 8, w, h);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], b->dst[0] + 4, ls_y,
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], s->dst[0] + 4, ls_y,
|
||||
ref2->data[0], ref2->linesize[0],
|
||||
row << 3, (col << 3) + 4, &b->mv[1][1], 4, 8, w, h);
|
||||
}
|
||||
@ -2333,34 +2333,34 @@ static void inter_recon(AVCodecContext *ctx)
|
||||
|
||||
// FIXME if two horizontally adjacent blocks have the same MV,
|
||||
// do a w8 instead of a w4 call
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], b->dst[0], ls_y,
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], s->dst[0], ls_y,
|
||||
ref1->data[0], ref1->linesize[0],
|
||||
row << 3, col << 3, &b->mv[0][0], 4, 4, w, h);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], b->dst[0] + 4, ls_y,
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0], s->dst[0] + 4, ls_y,
|
||||
ref1->data[0], ref1->linesize[0],
|
||||
row << 3, (col << 3) + 4, &b->mv[1][0], 4, 4, w, h);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0],
|
||||
b->dst[0] + 4 * ls_y, ls_y,
|
||||
s->dst[0] + 4 * ls_y, ls_y,
|
||||
ref1->data[0], ref1->linesize[0],
|
||||
(row << 3) + 4, col << 3, &b->mv[2][0], 4, 4, w, h);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][0],
|
||||
b->dst[0] + 4 * ls_y + 4, ls_y,
|
||||
s->dst[0] + 4 * ls_y + 4, ls_y,
|
||||
ref1->data[0], ref1->linesize[0],
|
||||
(row << 3) + 4, (col << 3) + 4, &b->mv[3][0], 4, 4, w, h);
|
||||
|
||||
if (b->comp) {
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], b->dst[0], ls_y,
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], s->dst[0], ls_y,
|
||||
ref2->data[0], ref2->linesize[0],
|
||||
row << 3, col << 3, &b->mv[0][1], 4, 4, w, h);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], b->dst[0] + 4, ls_y,
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1], s->dst[0] + 4, ls_y,
|
||||
ref2->data[0], ref2->linesize[0],
|
||||
row << 3, (col << 3) + 4, &b->mv[1][1], 4, 4, w, h);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1],
|
||||
b->dst[0] + 4 * ls_y, ls_y,
|
||||
s->dst[0] + 4 * ls_y, ls_y,
|
||||
ref2->data[0], ref2->linesize[0],
|
||||
(row << 3) + 4, col << 3, &b->mv[2][1], 4, 4, w, h);
|
||||
mc_luma_dir(s, s->dsp.mc[4][b->filter][1],
|
||||
b->dst[0] + 4 * ls_y + 4, ls_y,
|
||||
s->dst[0] + 4 * ls_y + 4, ls_y,
|
||||
ref2->data[0], ref2->linesize[0],
|
||||
(row << 3) + 4, (col << 3) + 4, &b->mv[3][1], 4, 4, w, h);
|
||||
}
|
||||
@ -2369,12 +2369,12 @@ static void inter_recon(AVCodecContext *ctx)
|
||||
int bwl = bwlog_tab[0][b->bs];
|
||||
int bw = bwh_tab[0][b->bs][0] * 4, bh = bwh_tab[0][b->bs][1] * 4;
|
||||
|
||||
mc_luma_dir(s, s->dsp.mc[bwl][b->filter][0], b->dst[0], ls_y,
|
||||
mc_luma_dir(s, s->dsp.mc[bwl][b->filter][0], s->dst[0], ls_y,
|
||||
ref1->data[0], ref1->linesize[0],
|
||||
row << 3, col << 3, &b->mv[0][0],bw, bh, w, h);
|
||||
|
||||
if (b->comp)
|
||||
mc_luma_dir(s, s->dsp.mc[bwl][b->filter][1], b->dst[0], ls_y,
|
||||
mc_luma_dir(s, s->dsp.mc[bwl][b->filter][1], s->dst[0], ls_y,
|
||||
ref2->data[0], ref2->linesize[0],
|
||||
row << 3, col << 3, &b->mv[0][1], bw, bh, w, h);
|
||||
}
|
||||
@ -2395,7 +2395,7 @@ static void inter_recon(AVCodecContext *ctx)
|
||||
}
|
||||
|
||||
mc_chroma_dir(s, s->dsp.mc[bwl][b->filter][0],
|
||||
b->dst[1], b->dst[2], ls_uv,
|
||||
s->dst[1], s->dst[2], ls_uv,
|
||||
ref1->data[1], ref1->linesize[1],
|
||||
ref1->data[2], ref1->linesize[2],
|
||||
row << 2, col << 2, &mvuv, bw, bh, w, h);
|
||||
@ -2408,7 +2408,7 @@ static void inter_recon(AVCodecContext *ctx)
|
||||
mvuv = b->mv[0][1];
|
||||
}
|
||||
mc_chroma_dir(s, s->dsp.mc[bwl][b->filter][1],
|
||||
b->dst[1], b->dst[2], ls_uv,
|
||||
s->dst[1], s->dst[2], ls_uv,
|
||||
ref2->data[1], ref2->linesize[1],
|
||||
ref2->data[2], ref2->linesize[2],
|
||||
row << 2, col << 2, &mvuv, bw, bh, w, h);
|
||||
@ -2424,7 +2424,7 @@ static void inter_recon(AVCodecContext *ctx)
|
||||
int end_y = FFMIN(2 * (s->rows - row), h4);
|
||||
int tx = 4 * s->lossless + b->tx, uvtx = b->uvtx + 4 * s->lossless;
|
||||
int uvstep1d = 1 << b->uvtx, p;
|
||||
uint8_t *dst = b->dst[0];
|
||||
uint8_t *dst = s->dst[0];
|
||||
|
||||
// y itxfm add
|
||||
for (n = 0, y = 0; y < end_y; y += step1d) {
|
||||
@ -2433,10 +2433,10 @@ static void inter_recon(AVCodecContext *ctx)
|
||||
int eob = b->tx > TX_8X8 ? AV_RN16A(&s->eob[n]) : s->eob[n];
|
||||
|
||||
if (eob)
|
||||
s->dsp.itxfm_add[tx][DCT_DCT](ptr, b->y_stride,
|
||||
s->dsp.itxfm_add[tx][DCT_DCT](ptr, s->y_stride,
|
||||
s->block + 16 * n, eob);
|
||||
}
|
||||
dst += 4 * b->y_stride * step1d;
|
||||
dst += 4 * s->y_stride * step1d;
|
||||
}
|
||||
|
||||
// uv itxfm add
|
||||
@ -2446,17 +2446,17 @@ static void inter_recon(AVCodecContext *ctx)
|
||||
end_y >>= 1;
|
||||
step = 1 << (b->uvtx * 2);
|
||||
for (p = 0; p < 2; p++) {
|
||||
dst = b->dst[p + 1];
|
||||
dst = s->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, n += step) {
|
||||
int eob = b->uvtx > TX_8X8 ? AV_RN16A(&s->uveob[p][n]) : s->uveob[p][n];
|
||||
|
||||
if (eob)
|
||||
s->dsp.itxfm_add[uvtx][DCT_DCT](ptr, b->uv_stride,
|
||||
s->dsp.itxfm_add[uvtx][DCT_DCT](ptr, s->uv_stride,
|
||||
s->uvblock[p] + 16 * n, eob);
|
||||
}
|
||||
dst += 4 * uvstep1d * b->uv_stride;
|
||||
dst += 4 * uvstep1d * s->uv_stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2605,10 +2605,10 @@ static int decode_b(AVCodecContext *ctx, int row, int col,
|
||||
int res, y, w4 = bwh_tab[1][bs][0], h4 = bwh_tab[1][bs][1], lvl;
|
||||
int emu[2];
|
||||
|
||||
b->row = row;
|
||||
b->row7 = row & 7;
|
||||
b->col = col;
|
||||
b->col7 = col & 7;
|
||||
s->row = row;
|
||||
s->row7 = row & 7;
|
||||
s->col = col;
|
||||
s->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;
|
||||
@ -2639,20 +2639,20 @@ static int decode_b(AVCodecContext *ctx, int row, int col,
|
||||
emu[1] = (col + w4) * 4 > s->f->linesize[1] ||
|
||||
(row + h4) > s->rows + 2 * !(ctx->flags & CODEC_FLAG_EMU_EDGE);
|
||||
if (emu[0]) {
|
||||
b->dst[0] = s->tmp_y;
|
||||
b->y_stride = 64;
|
||||
s->dst[0] = s->tmp_y;
|
||||
s->y_stride = 64;
|
||||
} else {
|
||||
b->dst[0] = s->f->data[0] + yoff;
|
||||
b->y_stride = s->f->linesize[0];
|
||||
s->dst[0] = s->f->data[0] + yoff;
|
||||
s->y_stride = s->f->linesize[0];
|
||||
}
|
||||
if (emu[1]) {
|
||||
b->dst[1] = s->tmp_uv[0];
|
||||
b->dst[2] = s->tmp_uv[1];
|
||||
b->uv_stride = 32;
|
||||
s->dst[1] = s->tmp_uv[0];
|
||||
s->dst[2] = s->tmp_uv[1];
|
||||
s->uv_stride = 32;
|
||||
} else {
|
||||
b->dst[1] = s->f->data[1] + uvoff;
|
||||
b->dst[2] = s->f->data[2] + uvoff;
|
||||
b->uv_stride = s->f->linesize[1];
|
||||
s->dst[1] = s->f->data[1] + uvoff;
|
||||
s->dst[2] = s->f->data[2] + uvoff;
|
||||
s->uv_stride = s->f->linesize[1];
|
||||
}
|
||||
if (b->intra) {
|
||||
intra_recon(ctx, yoff, uvoff);
|
||||
|
Loading…
Reference in New Issue
Block a user