summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavcodec/vp9.c24
-rw-r--r--libavcodec/vp9.h9
-rw-r--r--libavcodec/vp9block.c8
-rw-r--r--libavcodec/vp9mvs.c4
4 files changed, 34 insertions, 11 deletions
diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 11ed00e3f9..497dcf2d15 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -152,6 +152,19 @@ static int update_size(AVCodecContext *avctx, int w, int h)
assign(s->above_mv_ctx, VP56mv(*)[2], 16);
#undef assign
+ av_freep(&s->b_base);
+ av_freep(&s->block_base);
+ s->b_base = av_malloc(sizeof(*s->b_base));
+ s->block_base = av_mallocz((64 * 64 + 128) * 3);
+ if (!s->b_base || !s->block_base)
+ return AVERROR(ENOMEM);
+
+ s->uvblock_base[0] = s->block_base + 64 * 64;
+ s->uvblock_base[1] = s->uvblock_base[0] + 32 * 32;
+ s->eob_base = (uint8_t *) (s->uvblock_base[1] + 32 * 32);
+ s->uveob_base[0] = s->eob_base + 256;
+ s->uveob_base[1] = s->uveob_base[0] + 64;
+
return 0;
}
@@ -1155,6 +1168,15 @@ static int vp9_decode_frame(AVCodecContext *avctx, AVFrame *frame,
memset(s->above_uv_nnz_ctx[0], 0, s->sb_cols * 8);
memset(s->above_uv_nnz_ctx[1], 0, s->sb_cols * 8);
memset(s->above_segpred_ctx, 0, s->cols);
+
+ s->b = s->b_base;
+ s->block = s->block_base;
+ s->uvblock[0] = s->uvblock_base[0];
+ s->uvblock[1] = s->uvblock_base[1];
+ s->eob = s->eob_base;
+ s->uveob[0] = s->uveob_base[0];
+ s->uveob[1] = s->uveob_base[1];
+
for (tile_row = 0; tile_row < s->tiling.tile_rows; tile_row++) {
set_tile_offset(&s->tiling.tile_row_start, &s->tiling.tile_row_end,
tile_row, s->tiling.log2_tile_rows, s->sb_rows);
@@ -1351,6 +1373,8 @@ static av_cold int vp9_decode_free(AVCodecContext *avctx)
av_freep(&s->c_b);
av_freep(&s->above_partition_ctx);
+ av_freep(&s->b_base);
+ av_freep(&s->block_base);
return 0;
}
diff --git a/libavcodec/vp9.h b/libavcodec/vp9.h
index 8711987b8c..e59129818c 100644
--- a/libavcodec/vp9.h
+++ b/libavcodec/vp9.h
@@ -280,7 +280,8 @@ typedef struct VP9Context {
VP56RangeCoder c;
VP56RangeCoder *c_b;
unsigned c_b_size;
- VP9Block b;
+ VP9Block *b;
+ VP9Block *b_base;
// bitstream header
uint8_t profile;
@@ -412,10 +413,8 @@ typedef struct VP9Context {
DECLARE_ALIGNED(32, uint8_t, edge_emu_buffer)[71 * 80];
// block reconstruction intermediates
- DECLARE_ALIGNED(32, int16_t, block)[4096];
- DECLARE_ALIGNED(32, int16_t, uvblock)[2][1024];
- uint8_t eob[256];
- uint8_t uveob[2][64];
+ 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];
DECLARE_ALIGNED(32, uint8_t, tmp_uv)[2][32 * 32];
diff --git a/libavcodec/vp9block.c b/libavcodec/vp9block.c
index c018fa0310..feb5e6c00f 100644
--- a/libavcodec/vp9block.c
+++ b/libavcodec/vp9block.c
@@ -823,7 +823,7 @@ skip_eob:
static int decode_coeffs(AVCodecContext *avctx)
{
VP9Context *s = avctx->priv_data;
- VP9Block *const b = &s->b;
+ VP9Block *b = s->b;
int row = b->row, col = b->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];
@@ -1074,7 +1074,7 @@ static av_always_inline int check_intra_mode(VP9Context *s, int mode,
static void intra_recon(AVCodecContext *avctx, ptrdiff_t y_off, ptrdiff_t uv_off)
{
VP9Context *s = avctx->priv_data;
- VP9Block *const b = &s->b;
+ VP9Block *b = s->b;
AVFrame *f = s->frames[CUR_FRAME].tf.f;
int row = b->row, col = b->col;
int w4 = bwh_tab[1][b->bs][0] << 1, step1d = 1 << b->tx, n;
@@ -1227,7 +1227,7 @@ static int inter_recon(AVCodecContext *avctx)
{ 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4 },
};
VP9Context *s = avctx->priv_data;
- VP9Block *const b = &s->b;
+ VP9Block *b = s->b;
int row = b->row, col = b->col;
ThreadFrame *tref1 = &s->refs[s->refidx[b->ref[0]]];
@@ -1555,7 +1555,7 @@ int ff_vp9_decode_block(AVCodecContext *avctx, int row, int col,
enum BlockLevel bl, enum BlockPartition bp)
{
VP9Context *s = avctx->priv_data;
- VP9Block *const b = &s->b;
+ VP9Block *b = s->b;
AVFrame *f = s->frames[CUR_FRAME].tf.f;
enum BlockSize bs = bl * 3 + bp;
int ret, y, w4 = bwh_tab[1][bs][0], h4 = bwh_tab[1][bs][1], lvl;
diff --git a/libavcodec/vp9mvs.c b/libavcodec/vp9mvs.c
index a4ce84c5f3..5edcb19039 100644
--- a/libavcodec/vp9mvs.c
+++ b/libavcodec/vp9mvs.c
@@ -64,7 +64,7 @@ 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 *const b = &s->b;
+ VP9Block *b = s->b;
int row = b->row, col = b->col, row7 = b->row7;
const int8_t (*p)[2] = mv_ref_blk_off[b->bs];
#define INVALID_MV 0x80008000U
@@ -279,7 +279,7 @@ static av_always_inline int read_mv_component(VP9Context *s, int idx, int hp)
void ff_vp9_fill_mv(VP9Context *s, VP56mv *mv, int mode, int sb)
{
- VP9Block *const b = &s->b;
+ VP9Block *b = s->b;
if (mode == ZEROMV) {
memset(mv, 0, sizeof(*mv) * 2);