Commit 65a39bb4 authored by Angie Chiang's avatar Angie Chiang

Calculate coeff cost in av1_search_txk_type

Change-Id: Ie388218b2202ee2f63b90c67a059cbfe54fd4a4e
parent 44bb6d06
......@@ -718,7 +718,8 @@ static INLINE int allow_txk_type(MACROBLOCKD *xd, TX_SIZE tx_size, int plane) {
int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
int coeff_ctx, RD_STATS *rd_stats) {
const ENTROPY_CONTEXT *a, const ENTROPY_CONTEXT *l,
int use_fast_coef_costing, RD_STATS *rd_stats) {
const AV1_COMMON *cm = &cpi->common;
MACROBLOCKD *xd = &x->e_mbd;
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
......@@ -727,6 +728,7 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
TX_TYPE best_tx_type = txk_start;
int64_t best_rd = INT64_MAX;
int best_eob = tx_size_2d[tx_size];
const int coeff_ctx = combine_entropy_contexts(*a, *l);
if (!allow_txk_type(xd, tx_size, plane)) txk_end = DCT_DCT;
TX_TYPE tx_type;
for (tx_type = txk_start; tx_type <= txk_end; ++tx_type) {
......@@ -739,6 +741,10 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
av1_optimize_b(cm, x, plane, block, tx_size, coeff_ctx);
av1_dist_block(cpi, x, plane, plane_bsize, block, blk_row, blk_col, tx_size,
&this_rd_stats.dist, &this_rd_stats.sse, 0);
const SCAN_ORDER *scan_order =
get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
this_rd_stats.rate = av1_cost_coeffs(
cm, x, plane, block, tx_size, scan_order, a, l, use_fast_coef_costing);
int rd = RDCOST(x->rdmult, x->rddiv, 0, this_rd_stats.dist);
if (rd < best_rd) {
best_rd = rd;
......
......@@ -42,7 +42,8 @@ void av1_write_txb_probs(AV1_COMP *cpi, aom_writer *w);
int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
int coeff_ctx, RD_STATS *rd_stats);
const ENTROPY_CONTEXT *a, const ENTROPY_CONTEXT *l,
int use_fast_coef_costing, RD_STATS *rd_stats);
#ifdef __cplusplus
}
#endif
......
......@@ -1544,12 +1544,12 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
const AV1_COMP *cpi = args->cpi;
#if !CONFIG_LV_MAP || !CONFIG_PVQ
ENTROPY_CONTEXT *a = args->t_above + blk_col;
ENTROPY_CONTEXT *l = args->t_left + blk_row;
#if !CONFIG_LV_MAP
const AV1_COMMON *cm = &cpi->common;
#endif
int64_t rd1, rd2, rd;
int coeff_ctx = combine_entropy_contexts(*(args->t_above + blk_col),
*(args->t_left + blk_row));
RD_STATS this_rd_stats;
assert(tx_size == get_tx_size(plane, xd));
......@@ -1565,6 +1565,7 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
#if !CONFIG_LV_MAP
// full forward transform and quantization
int coeff_ctx = combine_entropy_contexts(*a, *l);
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
coeff_ctx, AV1_XFORM_QUANT_FP);
if (x->plane[plane].eobs[block] && !xd->lossless[mbmi->segment_id])
......@@ -1582,32 +1583,33 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
tx_size, &this_rd_stats.dist, &this_rd_stats.sse,
OUTPUT_HAS_PREDICTED_PIXELS);
}
#else // !CONFIG_LV_MAP
av1_search_txk_type(cpi, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, coeff_ctx, &this_rd_stats);
#endif // !CONFIG_LV_MAP
rd = RDCOST(x->rdmult, x->rddiv, 0, this_rd_stats.dist);
if (args->this_rd + rd > args->best_rd) {
args->exit_early = 1;
return;
}
#if !CONFIG_PVQ
ENTROPY_CONTEXT *a = args->t_above + blk_col;
ENTROPY_CONTEXT *l = args->t_left + blk_row;
PLANE_TYPE plane_type = get_plane_type(plane);
TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size);
const SCAN_ORDER *scan_order =
get_scan(cm, tx_size, tx_type, is_inter_block(mbmi));
this_rd_stats.rate = av1_cost_coeffs(cm, x, plane, block, tx_size, scan_order,
a, l, args->use_fast_coef_costing);
#else // !CONFIG_PVQ
this_rd_stats.rate = x->rate;
#endif // !CONFIG_PVQ
#else // !CONFIG_LV_MAP
av1_search_txk_type(cpi, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, a, l, args->use_fast_coef_costing,
&this_rd_stats);
#endif // !CONFIG_LV_MAP
#if !CONFIG_PVQ
#if CONFIG_RD_DEBUG
av1_update_txb_coeff_cost(&this_rd_stats, plane, tx_size, blk_row, blk_col,
this_rd_stats.rate);
#endif // CONFIG_RD_DEBUG
av1_set_txb_context(x, plane, block, tx_size, a, l);
#else // !CONFIG_PVQ
this_rd_stats.rate = x->rate;
#endif // !CONFIG_PVQ
rd1 = RDCOST(x->rdmult, x->rddiv, this_rd_stats.rate, this_rd_stats.dist);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment