lv_map_multi: optimize_txb improvement Corrected the nz_rate which is used to estimate the cost of changing the current coeff to EOB (as part of optimize_txb). (patch suggested by Dake He) Change-Id: I60d38d86744826e5c3bbc9eaea9ba6c520145f0b
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c index 08c7135..fc1e236 100644 --- a/av1/encoder/encodetxb.c +++ b/av1/encoder/encodetxb.c
@@ -248,13 +248,19 @@ stats->rd_low = RDCOST(txb_info->rdmult, stats->rate_low, stats->dist_low); #if CONFIG_LV_MAP_MULTI - int coeff_ctx = get_nz_map_ctx(levels, scan_idx, scan, txb_info->bwl, - txb_info->height, txb_info->tx_type, is_eob); + (void)levels; if ((stats->rd_low < stats->rd) && (stats->low_qc == 0)) { - stats->nz_rate = txb_costs->base_cost[coeff_ctx][0]; + stats->nz_rate = low_qc_cost; } else { - // TODO(olah): revisit what non-zero cost should be used here - stats->nz_rate = txb_costs->base_cost[coeff_ctx][1]; + if (stats->rd_low < stats->rd) { + const int low_qc_eob_cost = + get_coeff_cost(stats->low_qc, scan_idx, 1, txb_info, txb_costs); + stats->nz_rate = low_qc_cost - low_qc_eob_cost; + } else { + const int qc_eob_cost = + get_coeff_cost(qc, scan_idx, 1, txb_info, txb_costs); + stats->nz_rate = qc_cost - qc_eob_cost; + } } #else int coeff_ctx = get_nz_map_ctx(levels, scan_idx, scan, txb_info->bwl,