refactor out golomb_cost
Change-Id: I6f205d6fddfc56cc97df4285ef3aff3e38d976bc
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c
index 157ac4f..7f73bc0 100644
--- a/av1/encoder/encodetxb.c
+++ b/av1/encoder/encodetxb.c
@@ -284,11 +284,6 @@
return av1_cost_literal(1);
}
-static INLINE int get_br_cost(tran_low_t level, const int *coeff_lps) {
- const int base_range = AOMMIN(level - 1 - NUM_BASE_LEVELS, COEFF_BASE_RANGE);
- return coeff_lps[base_range];
-}
-
static INLINE int get_golomb_cost(int abs_qc) {
if (abs_qc >= 1 + NUM_BASE_LEVELS + COEFF_BASE_RANGE) {
const int r = abs_qc - COEFF_BASE_RANGE - NUM_BASE_LEVELS;
@@ -298,6 +293,11 @@
return 0;
}
+static INLINE int get_br_cost(tran_low_t level, const int *coeff_lps) {
+ const int base_range = AOMMIN(level - 1 - NUM_BASE_LEVELS, COEFF_BASE_RANGE);
+ return coeff_lps[base_range] + get_golomb_cost(level);
+}
+
static int get_coeff_cost(const tran_low_t qc, const int scan_idx,
const int is_eob, const TxbInfo *const txb_info,
const LV_MAP_COEFF_COST *const txb_costs,
@@ -322,7 +322,6 @@
const int ctx =
get_br_ctx(txb_info->levels, pos, txb_info->bwl, tx_class);
cost += get_br_cost(abs_qc, txb_costs->lps_cost[ctx]);
- cost += get_golomb_cost(abs_qc);
}
}
return cost;
@@ -748,7 +747,6 @@
if (level > NUM_BASE_LEVELS) {
const int ctx = get_br_ctx_eob(pos, bwl, tx_class);
cost += get_br_cost(level, lps_cost[ctx]);
- cost += get_golomb_cost(level);
}
if (c) {
cost += av1_cost_literal(1);
@@ -773,7 +771,6 @@
if (level > NUM_BASE_LEVELS) {
const int ctx = get_br_ctx(levels, pos, bwl, tx_class);
cost += get_br_cost(level, lps_cost[ctx]);
- cost += get_golomb_cost(level);
}
}
cost += cost0;
@@ -794,7 +791,6 @@
if (level > NUM_BASE_LEVELS) {
const int ctx = get_br_ctx(levels, pos, bwl, tx_class);
cost += get_br_cost(level, lps_cost[ctx]);
- cost += get_golomb_cost(level);
}
}
}
@@ -1279,7 +1275,6 @@
if (abs_qc > NUM_BASE_LEVELS) {
const int br_ctx = get_br_ctx(levels, ci, bwl, tx_class);
cost += get_br_cost(abs_qc, txb_costs->lps_cost[br_ctx]);
- cost += get_golomb_cost(abs_qc);
}
}
return cost;
@@ -1301,7 +1296,6 @@
int br_ctx;
br_ctx = get_br_ctx_eob(ci, bwl, tx_class);
cost += get_br_cost(abs_qc, txb_costs->lps_cost[br_ctx]);
- cost += get_golomb_cost(abs_qc);
}
}
return cost;
@@ -1332,7 +1326,6 @@
else
br_ctx = get_br_ctx(levels, ci, bwl, tx_class);
cost += get_br_cost(abs_qc, txb_costs->lps_cost[br_ctx]);
- cost += get_golomb_cost(abs_qc);
}
}
return cost;