Pass TXB_CTX to av1_cost_coeffs in search_txk_type
Pass TXB_CTX to av1_cost_coeffs in search_txk_type instead of
calling get_txb_ctx from av1_cost_coeffs repeatively.
Change-Id: I4fb7aff6c6dcc917489a9bbf05b59e81a4c90167
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 573bb05..4f3a6bd 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -2559,6 +2559,8 @@
block_sse = ROUND_POWER_OF_TWO(block_sse, (xd->bd - 8) * 2);
block_sse *= 16;
+ TXB_CTX txb_ctx;
+ get_txb_ctx(plane_bsize, tx_size, plane, a, l, &txb_ctx);
for (TX_TYPE tx_type = txk_start; tx_type <= txk_end; ++tx_type) {
if (!allowed_tx_mask[tx_type]) continue;
if (plane == 0) mbmi->txk_type[txk_type_idx] = tx_type;
@@ -2569,8 +2571,8 @@
av1_xform_quant(
cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size, tx_type,
USE_B_QUANT_NO_TRELLIS ? AV1_XFORM_QUANT_B : AV1_XFORM_QUANT_FP);
- rate_cost = av1_cost_coeffs(cm, x, plane_bsize, plane, blk_row, blk_col,
- block, tx_size, a, l, use_fast_coef_costing);
+ rate_cost = av1_cost_coeffs(cm, x, plane, blk_row, blk_col, block,
+ tx_size, &txb_ctx, use_fast_coef_costing);
} else {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, tx_type, AV1_XFORM_QUANT_FP);
@@ -2579,9 +2581,8 @@
// Calculate distortion quickly in transform domain.
dist_block_tx_domain(x, plane, block, tx_size, &this_rd_stats.dist,
&this_rd_stats.sse);
- rate_cost =
- av1_cost_coeffs(cm, x, plane_bsize, plane, blk_row, blk_col, block,
- tx_size, a, l, use_fast_coef_costing);
+ rate_cost = av1_cost_coeffs(cm, x, plane, blk_row, blk_col, block,
+ tx_size, &txb_ctx, use_fast_coef_costing);
const int64_t rd_estimate =
AOMMIN(RDCOST(x->rdmult, rate_cost, this_rd_stats.dist),
RDCOST(x->rdmult, 0, this_rd_stats.sse));
diff --git a/av1/encoder/rdopt.h b/av1/encoder/rdopt.h
index 65f50fc..5de6a53 100644
--- a/av1/encoder/rdopt.h
+++ b/av1/encoder/rdopt.h
@@ -78,20 +78,16 @@
}
static INLINE int av1_cost_coeffs(const AV1_COMMON *const cm, MACROBLOCK *x,
- BLOCK_SIZE plane_bsize, int plane,
- int blk_row, int blk_col, int block,
- TX_SIZE tx_size, const ENTROPY_CONTEXT *a,
- const ENTROPY_CONTEXT *l,
+ int plane, int blk_row, int blk_col,
+ int block, TX_SIZE tx_size, TXB_CTX *txb_ctx,
int use_fast_coef_costing) {
#if TXCOEFF_COST_TIMER
struct aom_usec_timer timer;
aom_usec_timer_start(&timer);
#endif
(void)use_fast_coef_costing;
- TXB_CTX txb_ctx;
- get_txb_ctx(plane_bsize, tx_size, plane, a, l, &txb_ctx);
const int cost = av1_cost_coeffs_txb(cm, x, plane, blk_row, blk_col, block,
- tx_size, &txb_ctx);
+ tx_size, txb_ctx);
#if TXCOEFF_COST_TIMER
AV1_COMMON *tmp_cm = (AV1_COMMON *)&cpi->common;
aom_usec_timer_mark(&timer);