Commit 0c9e2e9a authored by Ronald S. Bultje's avatar Ronald S. Bultje
Browse files

Split coefficient token tables intra vs. inter.

Change-Id: I5416455f8f129ca0f450d00e48358d2012605072
parent c17672a3
This diff is collapsed.
......@@ -255,19 +255,10 @@ int vp9_get_coef_context(int * recent_energy, int token) {
void vp9_default_coef_probs(VP9_COMMON *pc) {
vpx_memcpy(pc->fc.coef_probs_4x4, default_coef_probs_4x4,
sizeof(pc->fc.coef_probs_4x4));
vpx_memcpy(pc->fc.hybrid_coef_probs_4x4, default_hybrid_coef_probs_4x4,
sizeof(pc->fc.hybrid_coef_probs_4x4));
vpx_memcpy(pc->fc.coef_probs_8x8, default_coef_probs_8x8,
sizeof(pc->fc.coef_probs_8x8));
vpx_memcpy(pc->fc.hybrid_coef_probs_8x8, default_hybrid_coef_probs_8x8,
sizeof(pc->fc.hybrid_coef_probs_8x8));
vpx_memcpy(pc->fc.coef_probs_16x16, default_coef_probs_16x16,
sizeof(pc->fc.coef_probs_16x16));
vpx_memcpy(pc->fc.hybrid_coef_probs_16x16,
default_hybrid_coef_probs_16x16,
sizeof(pc->fc.hybrid_coef_probs_16x16));
vpx_memcpy(pc->fc.coef_probs_32x32, default_coef_probs_32x32,
sizeof(pc->fc.coef_probs_32x32));
}
......@@ -290,28 +281,30 @@ static void update_coef_probs(vp9_coeff_probs *dst_coef_probs,
vp9_coeff_probs *pre_coef_probs,
int block_types, vp9_coeff_count *coef_counts,
int count_sat, int update_factor) {
int t, i, j, k, count;
int t, i, j, k, l, count;
unsigned int branch_ct[ENTROPY_NODES][2];
vp9_prob coef_probs[ENTROPY_NODES];
int factor;
for (i = 0; i < block_types; ++i)
for (j = 0; j < COEF_BANDS; ++j)
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
if (k >= 3 && j == 0)
continue;
vp9_tree_probs_from_distribution(MAX_ENTROPY_TOKENS,
vp9_coef_encodings, vp9_coef_tree,
coef_probs, branch_ct,
coef_counts[i][j][k]);
for (t = 0; t < ENTROPY_NODES; ++t) {
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
dst_coef_probs[i][j][k][t] = weighted_prob(pre_coef_probs[i][j][k][t],
coef_probs[t], factor);
for (j = 0; j < REF_TYPES; ++j)
for (k = 0; k < COEF_BANDS; ++k)
for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
if (l >= 3 && k == 0)
continue;
vp9_tree_probs_from_distribution(MAX_ENTROPY_TOKENS,
vp9_coef_encodings, vp9_coef_tree,
coef_probs, branch_ct,
coef_counts[i][j][k][l]);
for (t = 0; t < ENTROPY_NODES; ++t) {
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
dst_coef_probs[i][j][k][l][t] =
weighted_prob(pre_coef_probs[i][j][k][l][t],
coef_probs[t], factor);
}
}
}
}
void vp9_adapt_coef_probs(VP9_COMMON *cm) {
......@@ -333,85 +326,14 @@ void vp9_adapt_coef_probs(VP9_COMMON *cm) {
count_sat = COEF_COUNT_SAT;
}
#ifdef COEF_COUNT_TESTING
{
printf("static const unsigned int\ncoef_counts"
"[BLOCK_TYPES] [COEF_BANDS]"
"[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {\n");
for (i = 0; i < BLOCK_TYPES; ++i) {
printf(" {\n");
for (j = 0; j < COEF_BANDS; ++j) {
printf(" {\n");
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
printf(" {");
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
printf("%d, ", cm->fc.coef_counts[i][j][k][t]);
printf("},\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
printf("static const unsigned int\ncoef_counts_8x8"
"[BLOCK_TYPES_8X8] [COEF_BANDS]"
"[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {\n");
for (i = 0; i < BLOCK_TYPES_8X8; ++i) {
printf(" {\n");
for (j = 0; j < COEF_BANDS; ++j) {
printf(" {\n");
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
printf(" {");
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
printf("%d, ", cm->fc.coef_counts_8x8[i][j][k][t]);
printf("},\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
printf("static const unsigned int\nhybrid_coef_counts"
"[BLOCK_TYPES] [COEF_BANDS]"
"[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {\n");
for (i = 0; i < BLOCK_TYPES; ++i) {
printf(" {\n");
for (j = 0; j < COEF_BANDS; ++j) {
printf(" {\n");
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
printf(" {");
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
printf("%d, ", cm->fc.hybrid_coef_counts[i][j][k][t]);
printf("},\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
}
#endif
update_coef_probs(cm->fc.coef_probs_4x4, cm->fc.pre_coef_probs_4x4,
BLOCK_TYPES_4X4, cm->fc.coef_counts_4x4,
count_sat, update_factor);
update_coef_probs(cm->fc.hybrid_coef_probs_4x4,
cm->fc.pre_hybrid_coef_probs_4x4,
BLOCK_TYPES_4X4_HYBRID, cm->fc.hybrid_coef_counts_4x4,
BLOCK_TYPES, cm->fc.coef_counts_4x4,
count_sat, update_factor);
update_coef_probs(cm->fc.coef_probs_8x8, cm->fc.pre_coef_probs_8x8,
BLOCK_TYPES_8X8, cm->fc.coef_counts_8x8,
count_sat, update_factor);
update_coef_probs(cm->fc.hybrid_coef_probs_8x8,
cm->fc.pre_hybrid_coef_probs_8x8,
BLOCK_TYPES_8X8_HYBRID, cm->fc.hybrid_coef_counts_8x8,
BLOCK_TYPES, cm->fc.coef_counts_8x8,
count_sat, update_factor);
update_coef_probs(cm->fc.coef_probs_16x16, cm->fc.pre_coef_probs_16x16,
BLOCK_TYPES_16X16, cm->fc.coef_counts_16x16,
count_sat, update_factor);
update_coef_probs(cm->fc.hybrid_coef_probs_16x16,
cm->fc.pre_hybrid_coef_probs_16x16,
BLOCK_TYPES_16X16_HYBRID, cm->fc.hybrid_coef_counts_16x16,
BLOCK_TYPES, cm->fc.coef_counts_16x16,
count_sat, update_factor);
update_coef_probs(cm->fc.coef_probs_32x32, cm->fc.pre_coef_probs_32x32,
BLOCK_TYPES_32X32, cm->fc.coef_counts_32x32,
......
......@@ -60,16 +60,9 @@ extern vp9_extra_bit_struct vp9_extra_bits[12]; /* indexed by token value */
/* Coefficients are predicted via a 3-dimensional probability table. */
/* Outside dimension. 0 = Y with DC, 1 = UV */
#define BLOCK_TYPES_4X4 2
#define BLOCK_TYPES_4X4_HYBRID 1
#define BLOCK_TYPES_8X8 2
#define BLOCK_TYPES_8X8_HYBRID 1
#define BLOCK_TYPES_16X16 2
#define BLOCK_TYPES_16X16_HYBRID 1
#define BLOCK_TYPES 2
#define BLOCK_TYPES_32X32 1
#define REF_TYPES 2 // intra=0, inter=1
/* Middle dimension reflects the coefficient position within the transform. */
#define COEF_BANDS 6
......@@ -93,11 +86,11 @@ extern vp9_extra_bit_struct vp9_extra_bits[12]; /* indexed by token value */
/*# define DC_TOKEN_CONTEXTS 3*/ /* 00, 0!0, !0!0 */
#define PREV_COEF_CONTEXTS 6
typedef unsigned int vp9_coeff_count[COEF_BANDS][PREV_COEF_CONTEXTS]
typedef unsigned int vp9_coeff_count[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS]
[MAX_ENTROPY_TOKENS];
typedef unsigned int vp9_coeff_stats[COEF_BANDS][PREV_COEF_CONTEXTS]
typedef unsigned int vp9_coeff_stats[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS]
[ENTROPY_NODES][2];
typedef vp9_prob vp9_coeff_probs[COEF_BANDS][PREV_COEF_CONTEXTS]
typedef vp9_prob vp9_coeff_probs[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS]
[ENTROPY_NODES];
#define SUBEXP_PARAM 4 /* Subexponential code parameter */
......
......@@ -54,12 +54,9 @@ typedef struct frame_contexts {
vp9_prob i8x8_mode_prob[VP9_I8X8_MODES - 1];
vp9_prob sub_mv_ref_prob[SUBMVREF_COUNT][VP9_SUBMVREFS - 1];
vp9_prob mbsplit_prob[VP9_NUMMBSPLITS - 1];
vp9_coeff_probs coef_probs_4x4[BLOCK_TYPES_4X4];
vp9_coeff_probs hybrid_coef_probs_4x4[BLOCK_TYPES_4X4_HYBRID];
vp9_coeff_probs coef_probs_8x8[BLOCK_TYPES_8X8];
vp9_coeff_probs hybrid_coef_probs_8x8[BLOCK_TYPES_8X8_HYBRID];
vp9_coeff_probs coef_probs_16x16[BLOCK_TYPES_16X16];
vp9_coeff_probs hybrid_coef_probs_16x16[BLOCK_TYPES_16X16_HYBRID];
vp9_coeff_probs coef_probs_4x4[BLOCK_TYPES];
vp9_coeff_probs coef_probs_8x8[BLOCK_TYPES];
vp9_coeff_probs coef_probs_16x16[BLOCK_TYPES];
vp9_coeff_probs coef_probs_32x32[BLOCK_TYPES_32X32];
nmv_context nmvc;
......@@ -79,20 +76,14 @@ typedef struct frame_contexts {
unsigned int sub_mv_ref_counts[SUBMVREF_COUNT][VP9_SUBMVREFS];
unsigned int mbsplit_counts[VP9_NUMMBSPLITS];
vp9_coeff_probs pre_coef_probs_4x4[BLOCK_TYPES_4X4];
vp9_coeff_probs pre_hybrid_coef_probs_4x4[BLOCK_TYPES_4X4_HYBRID];
vp9_coeff_probs pre_coef_probs_8x8[BLOCK_TYPES_8X8];
vp9_coeff_probs pre_hybrid_coef_probs_8x8[BLOCK_TYPES_8X8_HYBRID];
vp9_coeff_probs pre_coef_probs_16x16[BLOCK_TYPES_16X16];
vp9_coeff_probs pre_hybrid_coef_probs_16x16[BLOCK_TYPES_16X16_HYBRID];
vp9_coeff_probs pre_coef_probs_4x4[BLOCK_TYPES];
vp9_coeff_probs pre_coef_probs_8x8[BLOCK_TYPES];
vp9_coeff_probs pre_coef_probs_16x16[BLOCK_TYPES];
vp9_coeff_probs pre_coef_probs_32x32[BLOCK_TYPES_32X32];
vp9_coeff_count coef_counts_4x4[BLOCK_TYPES_4X4];
vp9_coeff_count hybrid_coef_counts_4x4[BLOCK_TYPES_4X4_HYBRID];
vp9_coeff_count coef_counts_8x8[BLOCK_TYPES_8X8];
vp9_coeff_count hybrid_coef_counts_8x8[BLOCK_TYPES_8X8_HYBRID];
vp9_coeff_count coef_counts_16x16[BLOCK_TYPES_16X16];
vp9_coeff_count hybrid_coef_counts_16x16[BLOCK_TYPES_16X16_HYBRID];
vp9_coeff_count coef_counts_4x4[BLOCK_TYPES];
vp9_coeff_count coef_counts_8x8[BLOCK_TYPES];
vp9_coeff_count coef_counts_16x16[BLOCK_TYPES];
vp9_coeff_count coef_counts_32x32[BLOCK_TYPES_32X32];
nmv_context_counts NMVcount;
......
......@@ -143,6 +143,8 @@ static void kfread_modes(VP9D_COMP *pbi,
int map_index = mb_row * pbi->common.mb_cols + mb_col;
MB_PREDICTION_MODE y_mode;
m->mbmi.ref_frame = INTRA_FRAME;
// Read the Macroblock segmentation map if it is being updated explicitly
// this frame (reset to 0 by default).
m->mbmi.segment_id = 0;
......
......@@ -1170,20 +1170,21 @@ static void init_frame(VP9D_COMP *pbi) {
static void read_coef_probs_common(BOOL_DECODER* const bc,
vp9_coeff_probs *coef_probs,
int block_types) {
int i, j, k, l;
int i, j, k, l, m;
if (vp9_read_bit(bc)) {
for (i = 0; i < block_types; i++) {
for (j = 0; j < COEF_BANDS; j++) {
/* NB: This j loop starts from 1 on block type i == 0 */
for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
if (k >= 3 && j == 0)
continue;
for (l = 0; l < ENTROPY_NODES; l++) {
vp9_prob *const p = coef_probs[i][j][k] + l;
if (vp9_read(bc, COEF_UPDATE_PROB)) {
*p = read_prob_diff_update(bc, *p);
for (j = 0; j < REF_TYPES; j++) {
for (k = 0; k < COEF_BANDS; k++) {
for (l = 0; l < PREV_COEF_CONTEXTS; l++) {
if (l >= 3 && k == 0)
continue;
for (m = 0; m < ENTROPY_NODES; m++) {
vp9_prob *const p = coef_probs[i][j][k][l] + m;
if (vp9_read(bc, COEF_UPDATE_PROB)) {
*p = read_prob_diff_update(bc, *p);
}
}
}
}
......@@ -1195,19 +1196,13 @@ static void read_coef_probs_common(BOOL_DECODER* const bc,
static void read_coef_probs(VP9D_COMP *pbi, BOOL_DECODER* const bc) {
VP9_COMMON *const pc = &pbi->common;
read_coef_probs_common(bc, pc->fc.coef_probs_4x4, BLOCK_TYPES_4X4);
read_coef_probs_common(bc, pc->fc.hybrid_coef_probs_4x4,
BLOCK_TYPES_4X4_HYBRID);
read_coef_probs_common(bc, pc->fc.coef_probs_4x4, BLOCK_TYPES);
if (pbi->common.txfm_mode != ONLY_4X4) {
read_coef_probs_common(bc, pc->fc.coef_probs_8x8, BLOCK_TYPES_8X8);
read_coef_probs_common(bc, pc->fc.hybrid_coef_probs_8x8,
BLOCK_TYPES_8X8_HYBRID);
read_coef_probs_common(bc, pc->fc.coef_probs_8x8, BLOCK_TYPES);
}
if (pbi->common.txfm_mode > ALLOW_8X8) {
read_coef_probs_common(bc, pc->fc.coef_probs_16x16, BLOCK_TYPES_16X16);
read_coef_probs_common(bc, pc->fc.hybrid_coef_probs_16x16,
BLOCK_TYPES_16X16_HYBRID);
read_coef_probs_common(bc, pc->fc.coef_probs_16x16, BLOCK_TYPES);
}
if (pbi->common.txfm_mode > ALLOW_16X16) {
read_coef_probs_common(bc, pc->fc.coef_probs_32x32, BLOCK_TYPES_32X32);
......@@ -1582,16 +1577,10 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
vp9_copy(pbi->common.fc.pre_coef_probs_4x4,
pbi->common.fc.coef_probs_4x4);
vp9_copy(pbi->common.fc.pre_hybrid_coef_probs_4x4,
pbi->common.fc.hybrid_coef_probs_4x4);
vp9_copy(pbi->common.fc.pre_coef_probs_8x8,
pbi->common.fc.coef_probs_8x8);
vp9_copy(pbi->common.fc.pre_hybrid_coef_probs_8x8,
pbi->common.fc.hybrid_coef_probs_8x8);
vp9_copy(pbi->common.fc.pre_coef_probs_16x16,
pbi->common.fc.coef_probs_16x16);
vp9_copy(pbi->common.fc.pre_hybrid_coef_probs_16x16,
pbi->common.fc.hybrid_coef_probs_16x16);
vp9_copy(pbi->common.fc.pre_coef_probs_32x32,
pbi->common.fc.coef_probs_32x32);
vp9_copy(pbi->common.fc.pre_ymode_prob, pbi->common.fc.ymode_prob);
......@@ -1606,11 +1595,8 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
#endif
pbi->common.fc.pre_nmvc = pbi->common.fc.nmvc;
vp9_zero(pbi->common.fc.coef_counts_4x4);
vp9_zero(pbi->common.fc.hybrid_coef_counts_4x4);
vp9_zero(pbi->common.fc.coef_counts_8x8);
vp9_zero(pbi->common.fc.hybrid_coef_counts_8x8);
vp9_zero(pbi->common.fc.coef_counts_16x16);
vp9_zero(pbi->common.fc.hybrid_coef_counts_16x16);
vp9_zero(pbi->common.fc.coef_counts_32x32);
vp9_zero(pbi->common.fc.ymode_counts);
vp9_zero(pbi->common.fc.sb_ymode_counts);
......
......@@ -65,7 +65,7 @@ static int get_signed(BOOL_DECODER *br, int value_to_sign) {
#define INCREMENT_COUNT(token) \
do { \
coef_counts[type][get_coef_band(txfm_size, c)][pt][token]++; \
coef_counts[type][ref][get_coef_band(txfm_size, c)][pt][token]++; \
pt = vp9_get_coef_context(&recent_energy, token); \
} while (0)
......@@ -99,39 +99,25 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
vp9_coeff_probs *coef_probs;
vp9_prob *prob;
vp9_coeff_count *coef_counts;
const int ref = xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME;
switch (txfm_size) {
default:
case TX_4X4:
if (tx_type == DCT_DCT) {
coef_probs = fc->coef_probs_4x4;
coef_counts = fc->coef_counts_4x4;
} else {
coef_probs = fc->hybrid_coef_probs_4x4;
coef_counts = fc->hybrid_coef_counts_4x4;
}
coef_probs = fc->coef_probs_4x4;
coef_counts = fc->coef_counts_4x4;
break;
case TX_8X8:
if (tx_type == DCT_DCT) {
coef_probs = fc->coef_probs_8x8;
coef_counts = fc->coef_counts_8x8;
} else {
coef_probs = fc->hybrid_coef_probs_8x8;
coef_counts = fc->hybrid_coef_counts_8x8;
}
coef_probs = fc->coef_probs_8x8;
coef_counts = fc->coef_counts_8x8;
#if CONFIG_CNVCONTEXT
above_ec = (A0[aidx] + A0[aidx + 1]) != 0;
left_ec = (L0[lidx] + L0[lidx + 1]) != 0;
#endif
break;
case TX_16X16:
if (tx_type == DCT_DCT) {
coef_probs = fc->coef_probs_16x16;
coef_counts = fc->coef_counts_16x16;
} else {
coef_probs = fc->hybrid_coef_probs_16x16;
coef_counts = fc->hybrid_coef_counts_16x16;
}
coef_probs = fc->coef_probs_16x16;
coef_counts = fc->coef_counts_16x16;
#if CONFIG_CNVCONTEXT
if (type == PLANE_TYPE_UV) {
ENTROPY_CONTEXT *A1 = (ENTROPY_CONTEXT *) (xd->above_context + 1);
......@@ -176,7 +162,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
int val;
const uint8_t *cat6 = cat6_prob;
if (c >= seg_eob) break;
prob = coef_probs[type][get_coef_band(txfm_size, c)][pt];
prob = coef_probs[type][ref][get_coef_band(txfm_size, c)][pt];
if (!vp9_read(br, prob[EOB_CONTEXT_NODE]))
break;
SKIP_START:
......@@ -184,7 +170,7 @@ SKIP_START:
if (!vp9_read(br, prob[ZERO_CONTEXT_NODE])) {
INCREMENT_COUNT(ZERO_TOKEN);
++c;
prob = coef_probs[type][get_coef_band(txfm_size, c)][pt];
prob = coef_probs[type][ref][get_coef_band(txfm_size, c)][pt];
goto SKIP_START;
}
// ONE_CONTEXT_NODE_0_
......@@ -248,7 +234,7 @@ SKIP_START:
}
if (c < seg_eob)
coef_counts[type][get_coef_band(txfm_size, c)][pt][DCT_EOB_TOKEN]++;
coef_counts[type][ref][get_coef_band(txfm_size, c)][pt][DCT_EOB_TOKEN]++;
A0[aidx] = L0[lidx] = (c > 0);
if (txfm_size >= TX_8X8) {
......
......@@ -42,12 +42,9 @@ unsigned __int64 Sectionbits[500];
int intra_mode_stats[VP9_KF_BINTRAMODES]
[VP9_KF_BINTRAMODES]
[VP9_KF_BINTRAMODES];
vp9_coeff_stats tree_update_hist_4x4[BLOCK_TYPES_4X4];
vp9_coeff_stats hybrid_tree_update_hist_4x4[BLOCK_TYPES_4X4_HYBRID];
vp9_coeff_stats tree_update_hist_8x8[BLOCK_TYPES_8X8];
vp9_coeff_stats hybrid_tree_update_hist_8x8[BLOCK_TYPES_8X8_HYBRID];
vp9_coeff_stats tree_update_hist_16x16[BLOCK_TYPES_16X16];
vp9_coeff_stats hybrid_tree_update_hist_16x16[BLOCK_TYPES_16X16_HYBRID];
vp9_coeff_stats tree_update_hist_4x4[BLOCK_TYPES];
vp9_coeff_stats tree_update_hist_8x8[BLOCK_TYPES];
vp9_coeff_stats tree_update_hist_16x16[BLOCK_TYPES];
vp9_coeff_stats tree_update_hist_32x32[BLOCK_TYPES_32X32];
extern unsigned int active_section;
......@@ -1145,20 +1142,23 @@ static void write_modes(VP9_COMP *cpi, vp9_writer* const bc,
/* This function is used for debugging probability trees. */
static void print_prob_tree(vp9_coeff_probs *coef_probs) {
static void print_prob_tree(vp9_coeff_probs *coef_probs, int block_types) {
/* print coef probability tree */
int i, j, k, l;
int i, j, k, l, m;
FILE *f = fopen("enc_tree_probs.txt", "a");
fprintf(f, "{\n");
for (i = 0; i < BLOCK_TYPES_4X4; i++) {
for (i = 0; i < block_types; i++) {
fprintf(f, " {\n");
for (j = 0; j < COEF_BANDS; j++) {
fprintf(f, " {\n");
for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
fprintf(f, " {");
for (l = 0; l < ENTROPY_NODES; l++) {
fprintf(f, "%3u, ",
(unsigned int)(coef_probs [i][j][k][l]));
for (j = 0; j < REF_TYPES; ++j) {
fprintf(f, " {\n");
for (k = 0; k < COEF_BANDS; k++) {
fprintf(f, " {\n");
for (l = 0; l < PREV_COEF_CONTEXTS; l++) {
fprintf(f, " {");
for (m = 0; m < ENTROPY_NODES; m++) {
fprintf(f, "%3u, ",
(unsigned int)(coef_probs[i][j][k][l][m]));
}
}
fprintf(f, " }\n");
}
......@@ -1178,26 +1178,28 @@ static void build_tree_distribution(vp9_coeff_probs *coef_probs,
#endif
vp9_coeff_stats *coef_branch_ct,
int block_types) {
int i = 0, j, k;
int i, j, k, l;
#ifdef ENTROPY_STATS
int t = 0;
#endif
for (i = 0; i < block_types; ++i) {
for (j = 0; j < COEF_BANDS; ++j) {
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
if (k >= 3 && j == 0)
continue;
vp9_tree_probs_from_distribution(MAX_ENTROPY_TOKENS,
vp9_coef_encodings, vp9_coef_tree,
coef_probs[i][j][k],
coef_branch_ct[i][j][k],
coef_counts[i][j][k]);
for (j = 0; j < REF_TYPES; ++j) {
for (k = 0; k < COEF_BANDS; ++k) {
for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
if (l >= 3 && k == 0)
continue;
vp9_tree_probs_from_distribution(MAX_ENTROPY_TOKENS,
vp9_coef_encodings, vp9_coef_tree,
coef_probs[i][j][k][l],
coef_branch_ct[i][j][k][l],
coef_counts[i][j][k][l]);
#ifdef ENTROPY_STATS
if (!cpi->dummy_packing)
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
context_counters[i][j][k][t] += coef_counts[i][j][k][t];
context_counters[i][j][k][l][t] += coef_counts[i][j][k][l][t];
#endif
}
}
}
}
......@@ -1209,40 +1211,19 @@ static void build_coeff_contexts(VP9_COMP *cpi) {
#ifdef ENTROPY_STATS
cpi, context_counters_4x4,
#endif
cpi->frame_branch_ct_4x4, BLOCK_TYPES_4X4);
build_tree_distribution(cpi->frame_hybrid_coef_probs_4x4,
cpi->hybrid_coef_counts_4x4,
#ifdef ENTROPY_STATS
cpi, hybrid_context_counters_4x4,
#endif
cpi->frame_hybrid_branch_ct_4x4,
BLOCK_TYPES_4X4_HYBRID);
cpi->frame_branch_ct_4x4, BLOCK_TYPES);
build_tree_distribution(cpi->frame_coef_probs_8x8,
cpi->coef_counts_8x8,
#ifdef ENTROPY_STATS
cpi, context_counters_8x8,
#endif
cpi->frame_branch_ct_8x8, BLOCK_TYPES_8X8);
build_tree_distribution(cpi->frame_hybrid_coef_probs_8x8,
cpi->hybrid_coef_counts_8x8,
#ifdef ENTROPY_STATS
cpi, hybrid_context_counters_8x8,
#endif
cpi->frame_hybrid_branch_ct_8x8,
BLOCK_TYPES_8X8_HYBRID);
cpi->frame_branch_ct_8x8, BLOCK_TYPES);
build_tree_distribution(cpi->frame_coef_probs_16x16,
cpi->coef_counts_16x16,
#ifdef ENTROPY_STATS
cpi, context_counters_16x16,
#endif
cpi->frame_branch_ct_16x16, BLOCK_TYPES_16X16);
build_tree_distribution(cpi->frame_hybrid_coef_probs_16x16,
cpi->hybrid_coef_counts_16x16,
#ifdef ENTROPY_STATS
cpi, hybrid_context_counters_16x16,
#endif
cpi->frame_hybrid_branch_ct_16x16,
BLOCK_TYPES_16X16_HYBRID);
cpi->frame_branch_ct_16x16, BLOCK_TYPES);
build_tree_distribution(cpi->frame_coef_probs_32x32,
cpi->coef_counts_32x32,
#ifdef ENTROPY_STATS
......@@ -1260,7 +1241,7 @@ static void update_coef_probs_common(vp9_writer* const bc,
vp9_coeff_probs *old_frame_coef_probs,
vp9_coeff_stats *frame_branch_ct,
int block_types) {
int i, j, k, t;
int i, j, k, l, t;
int update[2] = {0, 0};
int savings;
// vp9_prob bestupd = find_coef_update_prob(cpi);
......@@ -1268,39 +1249,39 @@ static void update_coef_probs_common(vp9_writer* const bc,
/* dry run to see if there is any udpate at all needed */
savings = 0;
for (i = 0; i < block_types; ++i) {
for (j = 0; j < COEF_BANDS; ++j) {
int prev_coef_savings[ENTROPY_NODES] = {0};
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
for (t = 0; t < ENTROPY_NODES; ++t) {
vp9_prob newp = new_frame_coef_probs[i][j][k][t];
const vp9_prob oldp = old_frame_coef_probs[i][j][k][t];
const vp9_prob upd = COEF_UPDATE_PROB;
int s = prev_coef_savings[t];
int u = 0;
if (k >= 3 && j == 0)
continue;
for (j = 0; j < REF_TYPES; ++j) {
for (k = 0; k < COEF_BANDS; ++k) {
int prev_coef_savings[ENTROPY_NODES] = {0};
for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
for (t = 0; t < ENTROPY_NODES; ++t) {
vp9_prob newp = new_frame_coef_probs[i][j][k][l][t];
const vp9_prob oldp = old_frame_coef_probs[i][j][k][l][t];
const vp9_prob upd = COEF_UPDATE_PROB;
int s = prev_coef_savings[t];
int u = 0;
if (l >= 3 && k == 0)
continue;
#if defined(SEARCH_NEWP)
s = prob_diff_update_savings_search(
frame_branch_ct[i][j][k][t],
oldp, &newp, upd);
if (s > 0 && newp != oldp)
u = 1;
if (u)
savings += s - (int)(vp9_cost_zero(upd));
else
savings -= (int)(vp9_cost_zero(upd));