Merge token_costs into a single table.
Change-Id: Id1ea2d543f12d4589df7038d5fb7bac1fee4da11
This commit is contained in:
parent
680af9acd5
commit
9921b55b22
@ -157,14 +157,8 @@ typedef struct {
|
||||
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;
|
||||
|
@ -423,9 +423,9 @@ static void optimize_b(MACROBLOCK *mb, int ib, int type,
|
||||
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 @@ static void optimize_b(MACROBLOCK *mb, int ib, int type,
|
||||
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 @@ static void optimize_b(MACROBLOCK *mb, int ib, int type,
|
||||
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 @@ static void optimize_b(MACROBLOCK *mb, int ib, int type,
|
||||
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 @@ void optimize_b_8x8(MACROBLOCK *mb, int i, int type,
|
||||
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 @@ void optimize_b_8x8(MACROBLOCK *mb, int i, int type,
|
||||
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 @@ void optimize_b_8x8(MACROBLOCK *mb, int i, int type,
|
||||
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 @@ void optimize_b_8x8(MACROBLOCK *mb, int i, int type,
|
||||
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 @@ void optimize_b_16x16(MACROBLOCK *mb, int i, int type,
|
||||
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 @@ void optimize_b_16x16(MACROBLOCK *mb, int i, int type,
|
||||
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 @@ void optimize_b_16x16(MACROBLOCK *mb, int i, int type,
|
||||
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 @@ void optimize_b_16x16(MACROBLOCK *mb, int i, int type,
|
||||
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;
|
||||
|
@ -353,18 +353,18 @@ void vp8_initialize_rd_consts(VP8_COMP *cpi, int QIndex) {
|
||||
}
|
||||
|
||||
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 @@ static int cost_coeffs_2x2(MACROBLOCK *mb,
|
||||
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,14 +631,15 @@ static int cost_coeffs(MACROBLOCK *mb, BLOCKD *b, int type, ENTROPY_CONTEXT *a,
|
||||
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];
|
||||
}
|
||||
# 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 @@ static int cost_coeffs_8x8(MACROBLOCK *mb,
|
||||
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 @@ static int cost_coeffs_16x16(MACROBLOCK *mb, BLOCKD *b, int type,
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user