Allow the encoder to drop individual transform block coding.
Change-Id: I2c2b2985254cb92baf891f03daa33f067279373b
// Notes transform blocks where no coefficents are coded.
// Set during mode selection. Read during block encoding.
uint8_t zcoeff_blk[TX_SIZES][256];
+#if CONFIG_VAR_TX
+ uint8_t blk_skip[MAX_MB_PLANE][256];
+#endif
int skip;
CHECK_MEM_ERROR(cm, ctx->zcoeff_blk,
vpx_calloc(num_blk, sizeof(uint8_t)));
for (i = 0; i < MAX_MB_PLANE; ++i) {
+#if CONFIG_VAR_TX
+ CHECK_MEM_ERROR(cm, ctx->blk_skip[i],
+ vpx_calloc(num_blk, sizeof(uint8_t)));
+#endif
for (k = 0; k < 3; ++k) {
CHECK_MEM_ERROR(cm, ctx->coeff[i][k],
vpx_memalign(32, num_pix * sizeof(*ctx->coeff[i][k])));
vpx_free(ctx->zcoeff_blk);
ctx->zcoeff_blk = 0;
for (i = 0; i < MAX_MB_PLANE; ++i) {
+#if CONFIG_VAR_TX
+ vpx_free(ctx->blk_skip[i]);
+ ctx->blk_skip[i] = 0;
+#endif
for (k = 0; k < 3; ++k) {
vpx_free(ctx->coeff[i][k]);
ctx->coeff[i][k] = 0;
MB_MODE_INFO_EXT mbmi_ext;
uint8_t *zcoeff_blk;
uint8_t *color_index_map[2];
+#if CONFIG_VAR_TX
+ uint8_t *blk_skip[MAX_MB_PLANE];
+#endif
tran_low_t *coeff[MAX_MB_PLANE][3];
tran_low_t *qcoeff[MAX_MB_PLANE][3];
tran_low_t *dqcoeff[MAX_MB_PLANE][3];
}
x->skip = ctx->skip;
+
+#if CONFIG_VAR_TX
+ for (i = 0; i < MAX_MB_PLANE; ++i)
+ memcpy(x->blk_skip[i], ctx->blk_skip[i],
+ sizeof(uint8_t) * ctx->num_4x4_blk);
+#else
memcpy(x->zcoeff_blk[mbmi->tx_size], ctx->zcoeff_blk,
sizeof(ctx->zcoeff_blk[0]) * ctx->num_4x4_blk);
+#endif
if (!output_enabled)
return;
x->quant_fp = cpi->sf.use_quant_fp;
vp10_zero(x->skip_txfm);
+#if CONFIG_VAR_TX
+ vp10_zero(x->blk_skip);
+#endif
{
struct vpx_usec_timer emr_timer;
max_txsize_lookup[bsize]);
else
tx_size = (bsize >= BLOCK_8X8) ? mbmi->tx_size : TX_4X4;
-
mbmi->tx_size = tx_size;
set_txfm_ctx(xd->left_txfm_context, tx_size, xd->n8_h);
set_txfm_ctx(xd->above_txfm_context, tx_size, xd->n8_w);
TX_TYPE tx_type = get_tx_type(pd->plane_type, xd, block, tx_size);
#if CONFIG_VAR_TX
int i;
+ const int bwl = b_width_log2_lookup[plane_bsize];
#endif
dst = &pd->dst.buf[4 * blk_row * pd->dst.stride + 4 * blk_col];
a = &ctx->ta[plane][blk_col];
// return;
// }
+#if CONFIG_VAR_TX
+ if (!x->skip_recode &&
+ x->blk_skip[plane][(blk_row << bwl) + blk_col] == 0) {
+#else
if (!x->skip_recode) {
+#endif
if (x->quant_fp) {
// Encoding process for rtc mode
if (x->skip_txfm[0] == SKIP_TXFM_AC_DC && plane == 0) {
// skip forward transform
p->eobs[block] = 0;
*a = *l = 0;
+#if !CONFIG_VAR_TX
return;
+#endif
}
} else {
vp10_xform_quant(x, plane, block, blk_row, blk_col,
}
}
}
+#if CONFIG_VAR_TX
+ else {
+ if (!x->skip_recode)
+ p->eobs[block] = 0;
+ }
+#endif
if (x->optimize && (!x->skip_recode || !x->skip_optimize)) {
int ctx;
int sum_rate = vp10_cost_bit(cpi->common.fc->txfm_partition_prob[ctx], 1);
int all_skip = 1;
int tmp_eob = 0;
+ int zero_blk_rate;
if (ref_best_rd < 0) {
*is_cost_valid = 0;
if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide)
return;
+ zero_blk_rate =
+ x->token_costs[tx_size][pd->plane_type][1][0][0][coeff_ctx][EOB_TOKEN];
+
if (cpi->common.tx_mode == TX_MODE_SELECT || tx_size == TX_4X4) {
mbmi->inter_tx_size[tx_idx] = tx_size;
tx_block_rd_b(cpi, x, tx_size, blk_row, blk_col, plane, block,
plane_bsize, coeff_ctx, rate, dist, bsse, skip);
+
+ if (RDCOST(x->rdmult, x->rddiv, *rate, *dist) >=
+ RDCOST(x->rdmult, x->rddiv, zero_blk_rate, *bsse) && (*skip == 0) &&
+ !xd->lossless[mbmi->segment_id]) {
+ *rate = zero_blk_rate;
+ *dist = *bsse;
+ *skip = 1;
+ x->blk_skip[plane][blk_row * max_blocks_wide + blk_col] = 1;
+ p->eobs[block] = 0;
+ } else {
+ x->blk_skip[plane][blk_row * max_blocks_wide + blk_col] = 0;
+ *skip = 0;
+ }
+
if (tx_size > TX_4X4)
*rate += vp10_cost_bit(cpi->common.fc->txfm_partition_prob[ctx], 0);
this_rd = RDCOST(x->rdmult, x->rddiv, *rate, *dist);
mbmi->tx_size = tx_size;
if (this_rd == INT64_MAX)
*is_cost_valid = 0;
+ x->blk_skip[plane][blk_row * max_blocks_wide + blk_col] = *skip;
} else {
*rate = sum_rate;
*dist = sum_dist;
if (!x->select_tx_size)
swap_block_ptr(x, ctx, 1, 0, 0, max_plane);
+
+#if CONFIG_VAR_TX
+ for (i = 0; i < MAX_MB_PLANE; ++i)
+ memcpy(ctx->blk_skip[i], x->blk_skip[i],
+ sizeof(uint8_t) * ctx->num_4x4_blk);
+#else
memcpy(ctx->zcoeff_blk, x->zcoeff_blk[mbmi->tx_size],
sizeof(ctx->zcoeff_blk[0]) * ctx->num_4x4_blk);
+#endif
// TODO(debargha): enhance this test with a better distortion prediction
// based on qp, activity mask and history
best_skip2 = this_skip2;
if (!x->select_tx_size)
swap_block_ptr(x, ctx, 1, 0, 0, max_plane);
+
+#if CONFIG_VAR_TX
+ for (i = 0; i < MAX_MB_PLANE; ++i)
+ memset(ctx->blk_skip[i], 0, sizeof(uint8_t) * ctx->num_4x4_blk);
+#else
memcpy(ctx->zcoeff_blk, x->zcoeff_blk[TX_4X4],
sizeof(ctx->zcoeff_blk[0]) * ctx->num_4x4_blk);
+#endif
for (i = 0; i < 4; i++)
best_bmodes[i] = xd->mi[0]->bmi[i];