VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
+ struct macroblock_plane *const p = x->plane;
+ struct macroblockd_plane *const pd = xd->plane;
MODE_INFO *mi = &ctx->mic;
MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi;
MODE_INFO *mi_addr = xd->mi_8x8[0];
*mi_addr = *mi;
+ for (i = 0; i < MAX_MB_PLANE; ++i) {
+ p[i].coeff = ctx->coeff_pbuf[i][1];
+ pd[i].qcoeff = ctx->qcoeff_pbuf[i][1];
+ pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][1];
+ pd[i].eobs = ctx->eobs_pbuf[i][1];
+ }
+
// Restore the coding context of the MB to that that was in place
// when the mode was picked for it
for (y = 0; y < mi_height; y++)
VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
+ struct macroblock_plane *const p = x->plane;
+ struct macroblockd_plane *const pd = xd->plane;
+ int i;
int orig_rdmult = x->rdmult;
double rdmult_ratio;
set_offsets(cpi, tile, mi_row, mi_col, bsize);
xd->mi_8x8[0]->mbmi.sb_type = bsize;
+ for (i = 0; i < MAX_MB_PLANE; ++i) {
+ p[i].coeff = ctx->coeff_pbuf[i][1];
+ pd[i].qcoeff = ctx->qcoeff_pbuf[i][1];
+ pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][1];
+ pd[i].eobs = ctx->eobs_pbuf[i][1];
+ }
+
// Set to zero to make sure we do not use the previous encoded frame stats
xd->mi_8x8[0]->mbmi.skip_coeff = 0;
} while (++i <= MV_MAX);
}
+static void alloc_mode_context(VP9_COMMON *cm, int num_4x4_blk,
+ PICK_MODE_CONTEXT *ctx) {
+ int num_pix = num_4x4_blk << 4;
+ int i, k;
+ ctx->num_4x4_blk = num_4x4_blk;
+ CHECK_MEM_ERROR(cm, ctx->zcoeff_blk,
+ vpx_calloc(num_4x4_blk, sizeof(uint8_t)));
+ for (i = 0; i < MAX_MB_PLANE; ++i) {
+ for (k = 0; k < 2; ++k) {
+ CHECK_MEM_ERROR(cm, ctx->coeff[i][k],
+ vpx_memalign(16, num_pix * sizeof(int16_t)));
+ CHECK_MEM_ERROR(cm, ctx->qcoeff[i][k],
+ vpx_memalign(16, num_pix * sizeof(int16_t)));
+ CHECK_MEM_ERROR(cm, ctx->dqcoeff[i][k],
+ vpx_memalign(16, num_pix * sizeof(int16_t)));
+ CHECK_MEM_ERROR(cm, ctx->eobs[i][k],
+ vpx_memalign(16, num_pix * sizeof(uint16_t)));
+ ctx->coeff_pbuf[i][k] = ctx->coeff[i][k];
+ ctx->qcoeff_pbuf[i][k] = ctx->qcoeff[i][k];
+ ctx->dqcoeff_pbuf[i][k] = ctx->dqcoeff[i][k];
+ ctx->eobs_pbuf[i][k] = ctx->eobs[i][k];
+ }
+ }
+}
+
+static void free_mode_context(PICK_MODE_CONTEXT *ctx) {
+ int i, k;
+ vpx_free(ctx->zcoeff_blk);
+ ctx->zcoeff_blk = 0;
+ for (i = 0; i < MAX_MB_PLANE; ++i) {
+ for (k = 0; k < 2; ++k) {
+ vpx_free(ctx->coeff[i][k]);
+ ctx->coeff[i][k] = 0;
+ vpx_free(ctx->qcoeff[i][k]);
+ ctx->qcoeff[i][k] = 0;
+ vpx_free(ctx->dqcoeff[i][k]);
+ ctx->dqcoeff[i][k] = 0;
+ vpx_free(ctx->eobs[i][k]);
+ ctx->eobs[i][k] = 0;
+ }
+ }
+}
+
static void init_pick_mode_context(VP9_COMP *cpi) {
int i;
MACROBLOCK *x = &cpi->mb;
for (xd->mb_index = 0; xd->mb_index < 4; ++xd->mb_index) {
for (xd->b_index = 0; xd->b_index < 16 / num_4x4_blk; ++xd->b_index) {
PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
- ctx->num_4x4_blk = num_4x4_blk;
- CHECK_MEM_ERROR(cm, ctx->zcoeff_blk,
- vpx_calloc(num_4x4_blk, sizeof(uint8_t)));
+ alloc_mode_context(cm, num_4x4_blk, ctx);
}
}
}
++xd->mb_index) {
PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
ctx->num_4x4_blk = num_4x4_blk;
- CHECK_MEM_ERROR(cm, ctx->zcoeff_blk,
- vpx_calloc(num_4x4_blk, sizeof(uint8_t)));
+ alloc_mode_context(cm, num_4x4_blk, ctx);
}
}
} else if (i < BLOCK_64X64) {
for (xd->sb_index = 0; xd->sb_index < 256 / num_4x4_blk; ++xd->sb_index) {
PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
ctx->num_4x4_blk = num_4x4_blk;
- CHECK_MEM_ERROR(cm, ctx->zcoeff_blk,
- vpx_calloc(num_4x4_blk, sizeof(uint8_t)));
+ alloc_mode_context(cm, num_4x4_blk, ctx);
}
} else {
PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
ctx->num_4x4_blk = num_4x4_blk;
- CHECK_MEM_ERROR(cm, ctx->zcoeff_blk,
- vpx_calloc(num_4x4_blk, sizeof(uint8_t)));
+ alloc_mode_context(cm, num_4x4_blk, ctx);
}
}
}
for (xd->mb_index = 0; xd->mb_index < 4; ++xd->mb_index) {
for (xd->b_index = 0; xd->b_index < 16 / num_4x4_blk; ++xd->b_index) {
PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
- vpx_free(ctx->zcoeff_blk);
- ctx->zcoeff_blk = 0;
+ free_mode_context(ctx);
}
}
}
for (xd->mb_index = 0; xd->mb_index < 64 / num_4x4_blk;
++xd->mb_index) {
PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
- vpx_free(ctx->zcoeff_blk);
- ctx->zcoeff_blk = 0;
+ free_mode_context(ctx);
}
}
} else if (i < BLOCK_64X64) {
for (xd->sb_index = 0; xd->sb_index < 256 / num_4x4_blk; ++xd->sb_index) {
PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
- vpx_free(ctx->zcoeff_blk);
- ctx->zcoeff_blk = 0;
+ free_mode_context(ctx);
}
} else {
PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
- vpx_free(ctx->zcoeff_blk);
- ctx->zcoeff_blk = 0;
+ free_mode_context(ctx);
}
}
}
-static void init_macroblock(VP9_COMP *const cpi) {
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
- struct macroblockd_plane *const pd = xd->plane;
- int i;
- for (i = 0; i < MAX_MB_PLANE; ++i) {
- pd[i].qcoeff = cpi->qcoeff[i];
- pd[i].dqcoeff = cpi->dqcoeff[i];
- pd[i].eobs = cpi->eobs[i];
- }
-}
-
VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
int i, j;
volatile union {
init_pick_mode_context(cpi);
- init_macroblock(cpi);
-
cm->current_video_frame = 0;
cpi->kf_overspend_bits = 0;
cpi->kf_bitrate_adjustment = 0;