Correct the tx_type cost for lv_map exp
Change-Id: Ia5e565f910c6d0c0bc6b0dc62f72a5df1346d06e
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c
index be7eb88..68ac8bd 100644
--- a/av1/encoder/encodetxb.c
+++ b/av1/encoder/encodetxb.c
@@ -249,8 +249,9 @@
return;
}
-int av1_cost_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
+int av1_cost_coeffs_txb(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
int block, TXB_CTX *txb_ctx) {
+ const AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
const TX_SIZE tx_size = get_tx_size(plane, xd);
const PLANE_TYPE plane_type = get_plane_type(plane);
@@ -284,6 +285,8 @@
cost = av1_cost_bit(xd->fc->txb_skip[tx_size][txb_skip_ctx], 0);
+ cost += av1_tx_type_cost(cpi, xd, mbmi->sb_type, plane, tx_size, tx_type);
+
for (c = 0; c < eob; ++c) {
tran_low_t v = qcoeff[scan[c]];
int is_nz = (v != 0);
@@ -747,7 +750,7 @@
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);
+ cpi, 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;
diff --git a/av1/encoder/encodetxb.h b/av1/encoder/encodetxb.h
index 465a8dc..ca9a94e 100644
--- a/av1/encoder/encodetxb.h
+++ b/av1/encoder/encodetxb.h
@@ -24,7 +24,7 @@
#endif
void av1_alloc_txb_buf(AV1_COMP *cpi);
void av1_free_txb_buf(AV1_COMP *cpi);
-int av1_cost_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
+int av1_cost_coeffs_txb(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
int block, TXB_CTX *txb_ctx);
void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
aom_writer *w, int block, int plane,
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 7f0d00c..cbd4c73 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -1256,11 +1256,12 @@
}
#endif // !CONFIG_LV_MAP
-int av1_cost_coeffs(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
+int av1_cost_coeffs(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
int block, TX_SIZE tx_size, const SCAN_ORDER *scan_order,
const ENTROPY_CONTEXT *a, const ENTROPY_CONTEXT *l,
int use_fast_coef_costing) {
#if !CONFIG_LV_MAP
+ const AV1_COMMON *const cm = &cpi->common;
return cost_coeffs(cm, x, plane, block, tx_size, scan_order, a, l,
use_fast_coef_costing);
#else // !CONFIG_LV_MAP
@@ -1284,7 +1285,7 @@
TXB_CTX txb_ctx;
get_txb_ctx(plane_bsize, tx_size, plane, a, l, &txb_ctx);
- return av1_cost_coeffs_txb(cm, x, plane, block, &txb_ctx);
+ return av1_cost_coeffs_txb(cpi, x, plane, block, &txb_ctx);
#endif // !CONFIG_LV_MAP
}
#endif // !CONFIG_PVQ || CONFIG_VAR_TX
@@ -1593,8 +1594,9 @@
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);
+ this_rd_stats.rate =
+ av1_cost_coeffs(cpi, 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
@@ -1829,8 +1831,11 @@
}
// #TODO(angiebird): use this function whenever it's possible
-static int tx_type_cost(const AV1_COMP *cpi, const MACROBLOCKD *xd,
- BLOCK_SIZE bsize, TX_SIZE tx_size, TX_TYPE tx_type) {
+int av1_tx_type_cost(const AV1_COMP *cpi, const MACROBLOCKD *xd,
+ BLOCK_SIZE bsize, int plane, TX_SIZE tx_size,
+ TX_TYPE tx_type) {
+ if (plane > 0) return 0;
+
const MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
const int is_inter = is_inter_block(mbmi);
#if CONFIG_EXT_TX
@@ -1892,7 +1897,10 @@
txfm_rd_in_plane(x, cpi, rd_stats, ref_best_rd, 0, bs, tx_size,
cpi->sf.use_fast_coef_costing);
if (rd_stats->rate == INT_MAX) return INT64_MAX;
- rd_stats->rate += tx_type_cost(cpi, xd, bs, tx_size, tx_type);
+#if !CONFIG_LV_MAP
+ int plane = 0;
+ rd_stats->rate += av1_tx_type_cost(cpi, xd, bs, plane, tx_size, tx_type);
+#endif
if (rd_stats->skip) {
if (is_inter) {
@@ -2716,7 +2724,7 @@
#if !CONFIG_PVQ
av1_xform_quant(cm, x, 0, block, row + idy, col + idx, BLOCK_8X8,
tx_size, coeff_ctx, AV1_XFORM_QUANT_FP);
- ratey += av1_cost_coeffs(cm, x, 0, block, tx_size, scan_order,
+ ratey += av1_cost_coeffs(cpi, x, 0, block, tx_size, scan_order,
tempa + idx, templ + idy,
cpi->sf.use_fast_coef_costing);
skip = (p->eobs[block] == 0);
@@ -2761,7 +2769,7 @@
av1_xform_quant(cm, x, 0, block, row + idy, col + idx, BLOCK_8X8,
tx_size, coeff_ctx, AV1_XFORM_QUANT_FP);
av1_optimize_b(cm, x, 0, block, tx_size, coeff_ctx);
- ratey += av1_cost_coeffs(cm, x, 0, block, tx_size, scan_order,
+ ratey += av1_cost_coeffs(cpi, x, 0, block, tx_size, scan_order,
tempa + idx, templ + idy,
cpi->sf.use_fast_coef_costing);
skip = (p->eobs[block] == 0);
@@ -2918,9 +2926,9 @@
row + idy, col + idx,
#endif // CONFIG_CB4X4
BLOCK_8X8, tx_size, coeff_ctx, AV1_XFORM_QUANT_B);
- ratey +=
- av1_cost_coeffs(cm, x, 0, block, tx_size, scan_order, tempa + idx,
- templ + idy, cpi->sf.use_fast_coef_costing);
+ ratey += av1_cost_coeffs(cpi, 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;
@@ -2976,9 +2984,9 @@
#endif // CONFIG_CB4X4
BLOCK_8X8, tx_size, coeff_ctx, AV1_XFORM_QUANT_FP);
av1_optimize_b(cm, x, 0, block, tx_size, coeff_ctx);
- ratey +=
- av1_cost_coeffs(cm, x, 0, block, tx_size, scan_order, tempa + idx,
- templ + idy, cpi->sf.use_fast_coef_costing);
+ ratey += av1_cost_coeffs(cpi, 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;
@@ -3957,7 +3965,7 @@
}
rd_stats->dist += tmp * 16;
txb_coeff_cost =
- av1_cost_coeffs(cm, x, plane, block, tx_size, scan_order, a, l, 0);
+ av1_cost_coeffs(cpi, x, plane, block, tx_size, scan_order, a, l, 0);
rd_stats->rate += txb_coeff_cost;
rd_stats->skip &= (eob == 0);
@@ -5270,7 +5278,7 @@
thissse += ssz;
#if !CONFIG_PVQ
thisrate +=
- av1_cost_coeffs(cm, x, 0, block, tx_size, scan_order, (ta + (k & 1)),
+ av1_cost_coeffs(cpi, 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);
diff --git a/av1/encoder/rdopt.h b/av1/encoder/rdopt.h
index 078b9d6..41f53a5 100644
--- a/av1/encoder/rdopt.h
+++ b/av1/encoder/rdopt.h
@@ -139,7 +139,7 @@
OUTPUT_STATUS output_status);
#if !CONFIG_PVQ || CONFIG_VAR_TX
-int av1_cost_coeffs(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
+int av1_cost_coeffs(const AV1_COMP *const cpi, MACROBLOCK *x, int plane,
int block, TX_SIZE tx_size, const SCAN_ORDER *scan_order,
const ENTROPY_CONTEXT *a, const ENTROPY_CONTEXT *l,
int use_fast_coef_costing);
@@ -211,4 +211,8 @@
} // extern "C"
#endif
+int av1_tx_type_cost(const AV1_COMP *cpi, const MACROBLOCKD *xd,
+ BLOCK_SIZE bsize, int plane, TX_SIZE tx_size,
+ TX_TYPE tx_type);
+
#endif // AV1_ENCODER_RDOPT_H_
diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c
index 787e94d..a2d1818 100644
--- a/av1/encoder/tokenize.c
+++ b/av1/encoder/tokenize.c
@@ -279,7 +279,8 @@
static void cost_coeffs_b(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg) {
struct tokenize_b_args *const args = arg;
- const AV1_COMMON *cm = &args->cpi->common;
+ const AV1_COMP *const cpi = args->cpi;
+ const AV1_COMMON *cm = &cpi->common;
ThreadData *const td = args->td;
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
@@ -290,7 +291,7 @@
const int ref = is_inter_block(mbmi);
const TX_TYPE tx_type = get_tx_type(type, xd, block, tx_size);
const SCAN_ORDER *const scan_order = get_scan(cm, tx_size, tx_type, ref);
- const int rate = av1_cost_coeffs(cm, x, plane, block, tx_size, scan_order,
+ const int rate = av1_cost_coeffs(cpi, x, plane, block, tx_size, scan_order,
pd->above_context + blk_col,
pd->left_context + blk_row, 0);
args->this_rate += rate;