Commit 8be58fad authored by Jingning Han's avatar Jingning Han
Browse files

Conditionally drop cutting tails in lv-map coeff optimization

When the optimized non-zero tail is longer that 2, the likelihood
that forcing to drop all the tail coefficients would give better
rate-distortion optimization is much lower. This commit makes the
encoder to check such conditions and speed up the lv-map/multi
encoding speed.

Local test clips at high target bit-rate / quality show 20% overall
encoding speed up. The coding performance change for lowres is
0.014%.

Change-Id: Ifcf1d18e453a83110ca8be794aee26f3e0237605
parent 23c511e7
...@@ -1764,6 +1764,7 @@ static int optimize_txb(TxbInfo *txb_info, const LV_MAP_COEFF_COST *txb_costs, ...@@ -1764,6 +1764,7 @@ static int optimize_txb(TxbInfo *txb_info, const LV_MAP_COEFF_COST *txb_costs,
int64_t accu_dist = 0; int64_t accu_dist = 0;
int64_t prev_eob_rd_cost = INT64_MAX; int64_t prev_eob_rd_cost = INT64_MAX;
int64_t cur_eob_rd_cost = 0; int64_t cur_eob_rd_cost = 0;
int8_t has_nz_tail = 0;
for (int si = init_eob - 1; si >= 0; --si) { for (int si = init_eob - 1; si >= 0; --si) {
const int coeff_idx = scan[si]; const int coeff_idx = scan[si];
...@@ -1779,28 +1780,33 @@ static int optimize_txb(TxbInfo *txb_info, const LV_MAP_COEFF_COST *txb_costs, ...@@ -1779,28 +1780,33 @@ static int optimize_txb(TxbInfo *txb_info, const LV_MAP_COEFF_COST *txb_costs,
if (qc == 0) { if (qc == 0) {
accu_rate += stats.rate; accu_rate += stats.rate;
} else { } else {
// check if it is better to make this the last significant coefficient if (has_nz_tail < 2) {
int cur_eob_rate = // check if it is better to make this the last significant coefficient
get_eob_cost(si + 1, seg_eob, txb_costs, txb_info->tx_type); int cur_eob_rate =
cur_eob_rd_cost = RDCOST(txb_info->rdmult, cur_eob_rate, 0); get_eob_cost(si + 1, seg_eob, txb_costs, txb_info->tx_type);
prev_eob_rd_cost = cur_eob_rd_cost = RDCOST(txb_info->rdmult, cur_eob_rate, 0);
RDCOST(txb_info->rdmult, accu_rate + stats.nz_rate, accu_dist); prev_eob_rd_cost =
if (cur_eob_rd_cost <= prev_eob_rd_cost) { RDCOST(txb_info->rdmult, accu_rate + stats.nz_rate, accu_dist);
update = 1; if (cur_eob_rd_cost <= prev_eob_rd_cost) {
for (int j = si + 1; j < txb_info->eob; j++) { update = 1;
const int coeff_pos_j = scan[j]; for (int j = si + 1; j < txb_info->eob; j++) {
update_coeff(coeff_pos_j, 0, txb_info); const int coeff_pos_j = scan[j];
} update_coeff(coeff_pos_j, 0, txb_info);
txb_info->eob = si + 1; }
txb_info->eob = si + 1;
// rerun cost calculation due to change of eob // rerun cost calculation due to change of eob
accu_rate = cur_eob_rate; accu_rate = cur_eob_rate;
accu_dist = 0; accu_dist = 0;
get_dist_cost_stats(&stats, si, get_dist_cost_stats(&stats, si,
#if CONFIG_LV_MAP_MULTI #if CONFIG_LV_MAP_MULTI
1, 1,
#endif #endif
txb_costs, txb_info); txb_costs, txb_info);
accu_rate += stats.rate;
accu_dist += stats.dist;
continue;
}
} }
int bUpdCoeff = 0; int bUpdCoeff = 0;
...@@ -1809,6 +1815,8 @@ static int optimize_txb(TxbInfo *txb_info, const LV_MAP_COEFF_COST *txb_costs, ...@@ -1809,6 +1815,8 @@ static int optimize_txb(TxbInfo *txb_info, const LV_MAP_COEFF_COST *txb_costs,
bUpdCoeff = 1; bUpdCoeff = 1;
update = 1; update = 1;
} }
} else {
++has_nz_tail;
} }
if (bUpdCoeff) { if (bUpdCoeff) {
......
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