Change the interface of av1_cost_coeffs This is to simplify the integration of lv_map experiment Change-Id: I13742b38fdadaf9d9f609de19e9dff4cce5268af
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c index e6d778a..d2b93f9 100644 --- a/av1/encoder/rdopt.c +++ b/av1/encoder/rdopt.c
@@ -1119,8 +1119,8 @@ * 16th coefficient in a 4x4 block or the 64th coefficient in a 8x8 block, * were non-zero). */ int av1_cost_coeffs(const AV1_COMMON *const cm, MACROBLOCK *x, int plane, - int block, int coeff_ctx, TX_SIZE tx_size, - const int16_t *scan, const int16_t *nb, + int block, TX_SIZE tx_size, const SCAN_ORDER *scan_order, + const ENTROPY_CONTEXT *a, const ENTROPY_CONTEXT *l, int use_fast_coef_costing) { MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; @@ -1134,8 +1134,10 @@ unsigned int(*token_costs)[2][COEFF_CONTEXTS][ENTROPY_TOKENS] = x->token_costs[tx_size_ctx][type][is_inter_block(mbmi)]; uint8_t token_cache[MAX_TX_SQUARE]; - int pt = coeff_ctx; + int pt = combine_entropy_contexts(*a, *l); int c, cost; + const int16_t *scan = scan_order->scan; + const int16_t *nb = scan_order->neighbors; #if CONFIG_NEW_TOKENSET const int ref = is_inter_block(mbmi); aom_prob *blockz_probs = @@ -1396,12 +1398,11 @@ } #if !CONFIG_PVQ -static int rate_block(int plane, int block, int coeff_ctx, TX_SIZE tx_size, +static int rate_block(int plane, int block, const ENTROPY_CONTEXT *a, + const ENTROPY_CONTEXT *l, TX_SIZE tx_size, struct rdcost_block_args *args) { - return av1_cost_coeffs(&args->cpi->common, args->x, plane, block, coeff_ctx, - tx_size, args->scan_order->scan, - args->scan_order->neighbors, - args->use_fast_coef_costing); + return av1_cost_coeffs(&args->cpi->common, args->x, plane, block, tx_size, + args->scan_order, a, l, args->use_fast_coef_costing); } #endif // !CONFIG_PVQ @@ -1464,6 +1465,8 @@ use_activity_masking = x->daala_enc.use_activity_masking; #endif // CONFIG_PVQ #endif // CONFIG_DAALA_DIST + ENTROPY_CONTEXT *a = args->t_above + blk_col; + ENTROPY_CONTEXT *l = args->t_left + blk_row; av1_init_rd_stats(&this_rd_stats); @@ -1572,7 +1575,7 @@ return; } #if !CONFIG_PVQ - this_rd_stats.rate = rate_block(plane, block, coeff_ctx, tx_size, args); + this_rd_stats.rate = rate_block(plane, block, a, l, tx_size, args); #if CONFIG_RD_DEBUG av1_update_txb_coeff_cost(&this_rd_stats, plane, tx_size, blk_row, blk_col, this_rd_stats.rate); @@ -1581,8 +1584,7 @@ #else this_rd_stats.rate = x->rate; #endif // !CONFIG_PVQ - av1_set_txb_context(x, plane, block, tx_size, args->t_above + blk_col, - args->t_left + blk_row); + av1_set_txb_context(x, plane, block, tx_size, a, l); rd1 = RDCOST(x->rdmult, x->rddiv, this_rd_stats.rate, this_rd_stats.dist); rd2 = RDCOST(x->rdmult, x->rddiv, 0, this_rd_stats.sse); @@ -2726,8 +2728,8 @@ av1_xform_quant(cm, x, 0, block, row + idy, col + idx, BLOCK_8X8, tx_size, coeff_ctx, AV1_XFORM_QUANT_FP); #endif // CONFIG_NEW_QUANT - ratey += av1_cost_coeffs(cm, x, 0, block, coeff_ctx, tx_size, - scan_order->scan, scan_order->neighbors, + ratey += av1_cost_coeffs(cm, x, 0, block, tx_size, scan_order, + tempa + idx, templ + idy, cpi->sf.use_fast_coef_costing); skip = (p->eobs[block] == 0); can_skip &= skip; @@ -2788,8 +2790,8 @@ tx_size, coeff_ctx, AV1_XFORM_QUANT_FP); #endif // CONFIG_NEW_QUANT av1_optimize_b(cm, x, 0, block, tx_size, coeff_ctx); - ratey += av1_cost_coeffs(cm, x, 0, block, coeff_ctx, tx_size, - scan_order->scan, scan_order->neighbors, + ratey += av1_cost_coeffs(cm, x, 0, block, tx_size, scan_order, + tempa + idx, templ + idy, cpi->sf.use_fast_coef_costing); skip = (p->eobs[block] == 0); can_skip &= skip; @@ -2964,9 +2966,9 @@ #endif // CONFIG_CB4X4 BLOCK_8X8, tx_size, coeff_ctx, AV1_XFORM_QUANT_B); #endif // CONFIG_NEW_QUANT - ratey += av1_cost_coeffs(cm, x, 0, block, coeff_ctx, tx_size, - scan_order->scan, scan_order->neighbors, - cpi->sf.use_fast_coef_costing); + ratey += + av1_cost_coeffs(cm, x, 0, block, tx_size, scan_order, tempa + idx, + templ + idy, cpi->sf.use_fast_coef_costing); skip = (p->eobs[block] == 0); can_skip &= skip; tempa[idx] = !skip; @@ -3032,9 +3034,9 @@ BLOCK_8X8, tx_size, coeff_ctx, AV1_XFORM_QUANT_FP); #endif // CONFIG_NEW_QUANT av1_optimize_b(cm, x, 0, block, tx_size, coeff_ctx); - ratey += av1_cost_coeffs(cm, x, 0, block, coeff_ctx, tx_size, - scan_order->scan, scan_order->neighbors, - cpi->sf.use_fast_coef_costing); + ratey += + av1_cost_coeffs(cm, x, 0, block, tx_size, scan_order, tempa + idx, + templ + idy, cpi->sf.use_fast_coef_costing); skip = (p->eobs[block] == 0); can_skip &= skip; tempa[idx] = !skip; @@ -3888,7 +3890,8 @@ #if CONFIG_VAR_TX void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size, int blk_row, int blk_col, int plane, int block, - int plane_bsize, int coeff_ctx, RD_STATS *rd_stats) { + int plane_bsize, const ENTROPY_CONTEXT *a, + const ENTROPY_CONTEXT *l, RD_STATS *rd_stats) { const AV1_COMMON *const cm = &cpi->common; MACROBLOCKD *xd = &x->e_mbd; const struct macroblock_plane *const p = &x->plane[plane]; @@ -3934,6 +3937,8 @@ max_blocks_high >>= tx_size_wide_log2[0]; max_blocks_wide >>= tx_size_wide_log2[0]; + int coeff_ctx = get_entropy_context(tx_size, a, l); + #if CONFIG_NEW_QUANT av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, coeff_ctx, AV1_XFORM_QUANT_FP_NUQ); @@ -4027,8 +4032,8 @@ } } rd_stats->dist += tmp * 16; - txb_coeff_cost = av1_cost_coeffs(cm, x, plane, block, coeff_ctx, tx_size, - scan_order->scan, scan_order->neighbors, 0); + txb_coeff_cost = + av1_cost_coeffs(cm, x, plane, block, tx_size, scan_order, a, l, 0); rd_stats->rate += txb_coeff_cost; rd_stats->skip &= (p->eobs[block] == 0); @@ -4098,7 +4103,7 @@ x->blk_skip[plane][blk_row * bw + blk_col] = rd_stats->skip; } else { av1_tx_block_rd_b(cpi, x, tx_size, blk_row, blk_col, plane, block, - plane_bsize, coeff_ctx, rd_stats); + plane_bsize, pta, ptl, rd_stats); if (tx_size == TX_32X32) { rd_stats_stack[block32] = *rd_stats; } @@ -4427,12 +4432,11 @@ : mbmi->inter_tx_size[tx_row][tx_col]; if (tx_size == plane_tx_size) { - int coeff_ctx, i; + int i; ENTROPY_CONTEXT *ta = above_ctx + blk_col; ENTROPY_CONTEXT *tl = left_ctx + blk_row; - coeff_ctx = get_entropy_context(tx_size, ta, tl); av1_tx_block_rd_b(cpi, x, tx_size, blk_row, blk_col, plane, block, - plane_bsize, coeff_ctx, rd_stats); + plane_bsize, ta, tl, rd_stats); for (i = 0; i < tx_size_wide_unit[tx_size]; ++i) ta[i] = !(p->eobs[block] == 0); @@ -5378,8 +5382,8 @@ thissse += ssz; #if !CONFIG_PVQ thisrate += - av1_cost_coeffs(cm, x, 0, block, coeff_ctx, tx_size, scan_order->scan, - scan_order->neighbors, cpi->sf.use_fast_coef_costing); + av1_cost_coeffs(cm, x, 0, block, tx_size, scan_order, (ta + (k & 1)), + (tl + (k >> 1)), cpi->sf.use_fast_coef_costing); *(ta + (k & 1)) = !(p->eobs[block] == 0); *(tl + (k >> 1)) = !(p->eobs[block] == 0); #else
diff --git a/av1/encoder/rdopt.h b/av1/encoder/rdopt.h index f8cd10f..1d21862 100644 --- a/av1/encoder/rdopt.h +++ b/av1/encoder/rdopt.h
@@ -129,8 +129,8 @@ } #if !CONFIG_PVQ || CONFIG_VAR_TX int av1_cost_coeffs(const AV1_COMMON *const cm, MACROBLOCK *x, int plane, - int block, int coeff_ctx, TX_SIZE tx_size, - const int16_t *scan, const int16_t *nb, + int block, TX_SIZE tx_size, const SCAN_ORDER *scan_order, + const ENTROPY_CONTEXT *a, const ENTROPY_CONTEXT *l, int use_fast_coef_costing); #endif void av1_rd_pick_intra_mode_sb(const struct AV1_COMP *cpi, struct macroblock *x,
diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c index 4577d7f..2291721 100644 --- a/av1/encoder/tokenize.c +++ b/av1/encoder/tokenize.c
@@ -274,10 +274,9 @@ const int block_raster_idx = av1_block_index_to_raster_order(tx_size, block); const TX_TYPE tx_type = get_tx_type(type, xd, block_raster_idx, tx_size); const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, ref); - int pt = get_entropy_context(tx_size, pd->above_context + blk_col, - pd->left_context + blk_row); - int rate = av1_cost_coeffs(cm, x, plane, block, pt, tx_size, scan_order->scan, - scan_order->neighbors, 0); + int rate = av1_cost_coeffs(cm, x, plane, block, tx_size, scan_order, + pd->above_context + blk_col, + pd->left_context + blk_row, 0); args->this_rate += rate; (void)plane_bsize; av1_set_contexts(xd, pd, plane, tx_size, p->eobs[block] > 0, blk_col,