ref: 9921b55b22df4e2e1053395844903d9f4800014e
parent: 680af9acd555e439cc62b49302529dc7641a1670
author: Daniel Kang <ddkang@google.com>
date: Mon Aug 6 07:38:50 EDT 2012
Merge token_costs into a single table. Change-Id: Id1ea2d543f12d4589df7038d5fb7bac1fee4da11
--- a/vp8/encoder/block.h
+++ b/vp8/encoder/block.h
@@ -157,14 +157,8 @@
MV_CONTEXT *mvc;
MV_CONTEXT_HP *mvc_hp;
- unsigned int token_costs[BLOCK_TYPES] [COEF_BANDS]
+ unsigned int token_costs[TX_SIZE_MAX][BLOCK_TYPES][COEF_BANDS]
[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS];
- unsigned int token_costs_8x8[BLOCK_TYPES_8X8] [COEF_BANDS]
- [PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS];
-#if CONFIG_TX16X16
- unsigned int token_costs_16x16[BLOCK_TYPES_16X16] [COEF_BANDS]
- [PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS];
-#endif
int optimize;
int q_index;
--- a/vp8/encoder/encodemb.c
+++ b/vp8/encoder/encodemb.c
@@ -423,9 +423,9 @@
band = vp8_coef_bands[i + 1];
pt = vp8_prev_token_class[t0];
rate0 +=
- mb->token_costs[type][band][pt][tokens[next][0].token];
+ mb->token_costs[TX_4X4][type][band][pt][tokens[next][0].token];
rate1 +=
- mb->token_costs[type][band][pt][tokens[next][1].token];
+ mb->token_costs[TX_4X4][type][band][pt][tokens[next][1].token];
}
rd_cost0 = RDCOST(rdmult, rddiv, rate0, error0);
rd_cost1 = RDCOST(rdmult, rddiv, rate1, error1);
@@ -475,13 +475,13 @@
band = vp8_coef_bands[i + 1];
if (t0 != DCT_EOB_TOKEN) {
pt = vp8_prev_token_class[t0];
- rate0 += mb->token_costs[type][band][pt][
- tokens[next][0].token];
+ rate0 += mb->token_costs[TX_4X4][type][band][pt]
+ [tokens[next][0].token];
}
if (t1 != DCT_EOB_TOKEN) {
pt = vp8_prev_token_class[t1];
- rate1 += mb->token_costs[type][band][pt][
- tokens[next][1].token];
+ rate1 += mb->token_costs[TX_4X4][type][band][pt]
+ [tokens[next][1].token];
}
}
@@ -517,11 +517,11 @@
t1 = tokens[next][1].token;
/* Update the cost of each path if we're past the EOB token. */
if (t0 != DCT_EOB_TOKEN) {
- tokens[next][0].rate += mb->token_costs[type][band][0][t0];
+ tokens[next][0].rate += mb->token_costs[TX_4X4][type][band][0][t0];
tokens[next][0].token = ZERO_TOKEN;
}
if (t1 != DCT_EOB_TOKEN) {
- tokens[next][1].rate += mb->token_costs[type][band][0][t1];
+ tokens[next][1].rate += mb->token_costs[TX_4X4][type][band][0][t1];
tokens[next][1].token = ZERO_TOKEN;
}
/* Don't update next, because we didn't add a new node. */
@@ -537,8 +537,8 @@
error1 = tokens[next][1].error;
t0 = tokens[next][0].token;
t1 = tokens[next][1].token;
- rate0 += mb->token_costs[type][band][pt][t0];
- rate1 += mb->token_costs[type][band][pt][t1];
+ rate0 += mb->token_costs[TX_4X4][type][band][pt][t0];
+ rate1 += mb->token_costs[TX_4X4][type][band][pt][t1];
rd_cost0 = RDCOST(rdmult, rddiv, rate0, error0);
rd_cost1 = RDCOST(rdmult, rddiv, rate1, error1);
if (rd_cost0 == rd_cost1) {
@@ -813,9 +813,9 @@
band = vp8_coef_bands_8x8[i + 1];
pt = vp8_prev_token_class[t0];
rate0 +=
- mb->token_costs_8x8[type][band][pt][tokens[next][0].token];
+ mb->token_costs[TX_8X8][type][band][pt][tokens[next][0].token];
rate1 +=
- mb->token_costs_8x8[type][band][pt][tokens[next][1].token];
+ mb->token_costs[TX_8X8][type][band][pt][tokens[next][1].token];
}
rd_cost0 = RDCOST_8x8(rdmult, rddiv, rate0, error0);
rd_cost1 = RDCOST_8x8(rdmult, rddiv, rate1, error1);
@@ -865,13 +865,13 @@
band = vp8_coef_bands_8x8[i + 1];
if (t0 != DCT_EOB_TOKEN) {
pt = vp8_prev_token_class[t0];
- rate0 += mb->token_costs_8x8[type][band][pt][
- tokens[next][0].token];
+ rate0 += mb->token_costs[TX_8X8][type][band][pt][
+ tokens[next][0].token];
}
if (t1 != DCT_EOB_TOKEN) {
pt = vp8_prev_token_class[t1];
- rate1 += mb->token_costs_8x8[type][band][pt][
- tokens[next][1].token];
+ rate1 += mb->token_costs[TX_8X8][type][band][pt][
+ tokens[next][1].token];
}
}
@@ -907,11 +907,11 @@
t1 = tokens[next][1].token;
/* Update the cost of each path if we're past the EOB token. */
if (t0 != DCT_EOB_TOKEN) {
- tokens[next][0].rate += mb->token_costs_8x8[type][band][0][t0];
+ tokens[next][0].rate += mb->token_costs[TX_8X8][type][band][0][t0];
tokens[next][0].token = ZERO_TOKEN;
}
if (t1 != DCT_EOB_TOKEN) {
- tokens[next][1].rate += mb->token_costs_8x8[type][band][0][t1];
+ tokens[next][1].rate += mb->token_costs[TX_8X8][type][band][0][t1];
tokens[next][1].token = ZERO_TOKEN;
}
/* Don't update next, because we didn't add a new node. */
@@ -927,8 +927,8 @@
error1 = tokens[next][1].error;
t0 = tokens[next][0].token;
t1 = tokens[next][1].token;
- rate0 += mb->token_costs_8x8[type][band][pt][t0];
- rate1 += mb->token_costs_8x8[type][band][pt][t1];
+ rate0 += mb->token_costs[TX_8X8][type][band][pt][t0];
+ rate1 += mb->token_costs[TX_8X8][type][band][pt][t1];
rd_cost0 = RDCOST_8x8(rdmult, rddiv, rate0, error0);
rd_cost1 = RDCOST_8x8(rdmult, rddiv, rate1, error1);
if (rd_cost0 == rd_cost1) {
@@ -1115,8 +1115,8 @@
if (next < 256) {
band = vp8_coef_bands_16x16[i + 1];
pt = vp8_prev_token_class[t0];
- rate0 += mb->token_costs_16x16[type][band][pt][tokens[next][0].token];
- rate1 += mb->token_costs_16x16[type][band][pt][tokens[next][1].token];
+ rate0 += mb->token_costs[TX_16X16][type][band][pt][tokens[next][0].token];
+ rate1 += mb->token_costs[TX_16X16][type][band][pt][tokens[next][1].token];
}
UPDATE_RD_COST();
/* And pick the best. */
@@ -1161,12 +1161,12 @@
band = vp8_coef_bands_16x16[i + 1];
if (t0 != DCT_EOB_TOKEN) {
pt = vp8_prev_token_class[t0];
- rate0 += mb->token_costs_16x16[type][band][pt]
+ rate0 += mb->token_costs[TX_16X16][type][band][pt]
[tokens[next][0].token];
}
if (t1!=DCT_EOB_TOKEN) {
pt = vp8_prev_token_class[t1];
- rate1 += mb->token_costs_16x16[type][band][pt]
+ rate1 += mb->token_costs[TX_16X16][type][band][pt]
[tokens[next][1].token];
}
}
@@ -1197,11 +1197,11 @@
t1 = tokens[next][1].token;
/* Update the cost of each path if we're past the EOB token. */
if (t0 != DCT_EOB_TOKEN) {
- tokens[next][0].rate += mb->token_costs_16x16[type][band][0][t0];
+ tokens[next][0].rate += mb->token_costs[TX_16X16][type][band][0][t0];
tokens[next][0].token = ZERO_TOKEN;
}
if (t1 != DCT_EOB_TOKEN) {
- tokens[next][1].rate += mb->token_costs_16x16[type][band][0][t1];
+ tokens[next][1].rate += mb->token_costs[TX_16X16][type][band][0][t1];
tokens[next][1].token = ZERO_TOKEN;
}
/* Don't update next, because we didn't add a new node. */
@@ -1217,8 +1217,8 @@
error1 = tokens[next][1].error;
t0 = tokens[next][0].token;
t1 = tokens[next][1].token;
- rate0 += mb->token_costs_16x16[type][band][pt][t0];
- rate1 += mb->token_costs_16x16[type][band][pt][t1];
+ rate0 += mb->token_costs[TX_16X16][type][band][pt][t0];
+ rate1 += mb->token_costs[TX_16X16][type][band][pt][t1];
UPDATE_RD_COST();
best = rd_cost1 < rd_cost0;
final_eob = -1;
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -353,18 +353,18 @@
}
fill_token_costs(
- cpi->mb.token_costs,
+ cpi->mb.token_costs[TX_4X4],
(const vp8_prob( *)[8][PREV_COEF_CONTEXTS][11]) cpi->common.fc.coef_probs,
BLOCK_TYPES);
fill_token_costs(
- cpi->mb.token_costs_8x8,
+ cpi->mb.token_costs[TX_8X8],
(const vp8_prob( *)[8][PREV_COEF_CONTEXTS][11]) cpi->common.fc.coef_probs_8x8,
BLOCK_TYPES_8X8);
#if CONFIG_TX16X16
fill_token_costs(
- cpi->mb.token_costs_16x16,
+ cpi->mb.token_costs[TX_16X16],
(const vp8_prob(*)[8][PREV_COEF_CONTEXTS][11]) cpi->common.fc.coef_probs_16x16,
BLOCK_TYPES_16X16);
#endif
@@ -575,13 +575,13 @@
for (; c < eob; c++) {
int v = qcoeff_ptr[vp8_default_zig_zag1d[c]];
int t = vp8_dct_value_tokens_ptr[v].Token;
- cost += mb->token_costs_8x8[type] [vp8_coef_bands[c]] [pt] [t];
+ cost += mb->token_costs[TX_8X8][type][vp8_coef_bands[c]][pt][t];
cost += vp8_dct_value_cost_ptr[v];
pt = vp8_prev_token_class[t];
}
if (c < 4)
- cost += mb->token_costs_8x8 [type][vp8_coef_bands[c]]
+ cost += mb->token_costs[TX_8X8][type][vp8_coef_bands[c]]
[pt] [DCT_EOB_TOKEN];
pt = (c != !type); // is eob first coefficient;
@@ -631,7 +631,7 @@
for (; c < eob; c++) {
int v = QC(c);
int t = vp8_dct_value_tokens_ptr[v].Token;
- cost += mb->token_costs [type] [vp8_coef_bands[c]] [pt] [t];
+ cost += mb->token_costs[TX_4X4][type][vp8_coef_bands[c]][pt][t];
cost += vp8_dct_value_cost_ptr[v];
pt = vp8_prev_token_class[t];
}
@@ -638,7 +638,8 @@
# undef QC
if (c < 16)
- cost += mb->token_costs [type] [vp8_coef_bands[c]] [pt] [DCT_EOB_TOKEN];
+ cost += mb->token_costs[TX_4X4][type][vp8_coef_bands[c]]
+ [pt][DCT_EOB_TOKEN];
pt = (c != !type); // is eob first coefficient;
*a = *l = pt;
@@ -660,14 +661,14 @@
for (; c < eob; c++) {
int v = qcoeff_ptr[vp8_default_zig_zag1d_8x8[c]];
int t = vp8_dct_value_tokens_ptr[v].Token;
- cost += mb->token_costs_8x8[type] [vp8_coef_bands_8x8[c]] [pt] [t];
+ cost += mb->token_costs[TX_8X8][type][vp8_coef_bands_8x8[c]][pt][t];
cost += vp8_dct_value_cost_ptr[v];
pt = vp8_prev_token_class[t];
}
if (c < 64)
- cost += mb->token_costs_8x8 [type][vp8_coef_bands_8x8[c]]
- [pt] [DCT_EOB_TOKEN];
+ cost += mb->token_costs[TX_8X8][type][vp8_coef_bands_8x8[c]]
+ [pt][DCT_EOB_TOKEN];
pt = (c != !type); // is eob first coefficient;
*a = *l = pt;
@@ -688,13 +689,13 @@
for (; c < eob; c++) {
int v = qcoeff_ptr[vp8_default_zig_zag1d_16x16[c]];
int t = vp8_dct_value_tokens_ptr[v].Token;
- cost += mb->token_costs_16x16[type][vp8_coef_bands_16x16[c]][pt][t];
+ cost += mb->token_costs[TX_16X16][type][vp8_coef_bands_16x16[c]][pt][t];
cost += vp8_dct_value_cost_ptr[v];
pt = vp8_prev_token_class[t];
}
if (c < 256)
- cost += mb->token_costs_16x16[type][vp8_coef_bands_16x16[c]]
+ cost += mb->token_costs[TX_16X16][type][vp8_coef_bands_16x16[c]]
[pt][DCT_EOB_TOKEN];
pt = (c != !type); // is eob first coefficient;
--
⑨