diff --git a/vp8/common/coefupdateprobs.h b/vp8/common/coefupdateprobs.h index 785e3ff70..9e194dc9a 100644 --- a/vp8/common/coefupdateprobs.h +++ b/vp8/common/coefupdateprobs.h @@ -12,7 +12,7 @@ /* Update probabilities for the nodes in the token entropy tree. Generated file included by entropy.c */ -const vp8_prob vp8_coef_update_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens-1] = +const vp8_prob vp8_coef_update_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES] = { { { diff --git a/vp8/common/defaultcoefcounts.c b/vp8/common/defaultcoefcounts.c index ebb78164c..b0e2e702a 100644 --- a/vp8/common/defaultcoefcounts.c +++ b/vp8/common/defaultcoefcounts.c @@ -15,7 +15,7 @@ const unsigned int vp8_default_coef_counts[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] - [vp8_coef_tokens] = + [MAX_ENTROPY_TOKENS] = { { diff --git a/vp8/common/defaultcoefcounts.h b/vp8/common/defaultcoefcounts.h index ebe8d7a2a..7a1e28b7b 100644 --- a/vp8/common/defaultcoefcounts.h +++ b/vp8/common/defaultcoefcounts.h @@ -16,6 +16,6 @@ extern const unsigned int vp8_default_coef_counts[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] - [vp8_coef_tokens]; + [MAX_ENTROPY_TOKENS]; #endif //__DEFAULTCOEFCOUNTS_H diff --git a/vp8/common/entropy.c b/vp8/common/entropy.c index b89ca92eb..fba7a07ff 100644 --- a/vp8/common/entropy.c +++ b/vp8/common/entropy.c @@ -65,7 +65,7 @@ const vp8_tree_index vp8_coef_tree[ 22] = /* corresponding _CONTEXT_NODEs */ -DCT_VAL_CATEGORY5, -DCT_VAL_CATEGORY6 /* 10 = CAT_FIVE */ }; -struct vp8_token_struct vp8_coef_encodings[vp8_coef_tokens]; +struct vp8_token_struct vp8_coef_encodings[MAX_ENTROPY_TOKENS]; /* Trees for extra bits. Probabilities are constant and do not depend on previously encoded bits */ @@ -145,9 +145,9 @@ void vp8_default_coef_probs(VP8_COMMON *pc) do { - unsigned int branch_ct [vp8_coef_tokens-1] [2]; + unsigned int branch_ct [ENTROPY_NODES] [2]; vp8_tree_probs_from_distribution( - vp8_coef_tokens, vp8_coef_encodings, vp8_coef_tree, + MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree, pc->fc.coef_probs[h][i][k], branch_ct, vp8_default_coef_counts[h][i][k], diff --git a/vp8/common/entropy.h b/vp8/common/entropy.h index d174e45b9..66d282b61 100644 --- a/vp8/common/entropy.h +++ b/vp8/common/entropy.h @@ -30,13 +30,12 @@ #define DCT_VAL_CATEGORY6 10 /* 67+ Extra Bits 11+1 */ #define DCT_EOB_TOKEN 11 /* EOB Extra Bits 0+0 */ -#define vp8_coef_tokens 12 -#define MAX_ENTROPY_TOKENS vp8_coef_tokens +#define MAX_ENTROPY_TOKENS 12 #define ENTROPY_NODES 11 extern const vp8_tree_index vp8_coef_tree[]; -extern struct vp8_token_struct vp8_coef_encodings[vp8_coef_tokens]; +extern struct vp8_token_struct vp8_coef_encodings[MAX_ENTROPY_TOKENS]; typedef struct { @@ -85,9 +84,9 @@ extern DECLARE_ALIGNED(16, const unsigned char, vp8_coef_bands[16]); /*# define DC_TOKEN_CONTEXTS 3*/ /* 00, 0!0, !0!0 */ # define PREV_COEF_CONTEXTS 3 -extern DECLARE_ALIGNED(16, const unsigned char, vp8_prev_token_class[vp8_coef_tokens]); +extern DECLARE_ALIGNED(16, const unsigned char, vp8_prev_token_class[MAX_ENTROPY_TOKENS]); -extern const vp8_prob vp8_coef_update_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens-1]; +extern const vp8_prob vp8_coef_update_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; struct VP8Common; diff --git a/vp8/common/onyxc_int.h b/vp8/common/onyxc_int.h index d366b9b1b..a381dfe87 100644 --- a/vp8/common/onyxc_int.h +++ b/vp8/common/onyxc_int.h @@ -43,7 +43,7 @@ typedef struct frame_contexts vp8_prob ymode_prob [VP8_YMODES-1]; /* interframe intra mode probs */ vp8_prob uv_mode_prob [VP8_UV_MODES-1]; vp8_prob sub_mv_ref_prob [VP8_SUBMVREFS-1]; - vp8_prob coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens-1]; + vp8_prob coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; MV_CONTEXT mvc[2]; MV_CONTEXT pre_mvc[2]; /* not to caculate the mvcost for the frame if mvc doesn't change. */ } FRAME_CONTEXT; diff --git a/vp8/decoder/decodframe.c b/vp8/decoder/decodframe.c index 648fdb288..a300bb5fd 100644 --- a/vp8/decoder/decodframe.c +++ b/vp8/decoder/decodframe.c @@ -979,7 +979,7 @@ int vp8_decode_frame(VP8D_COMP *pbi) for (i = 0; i < BLOCK_TYPES; i++) for (j = 0; j < COEF_BANDS; j++) for (k = 0; k < PREV_COEF_CONTEXTS; k++) - for (l = 0; l < MAX_ENTROPY_TOKENS - 1; l++) + for (l = 0; l < ENTROPY_NODES; l++) { vp8_prob *const p = pc->fc.coef_probs [i][j][k] + l; diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c index ac2981263..134e84881 100644 --- a/vp8/encoder/bitstream.c +++ b/vp8/encoder/bitstream.c @@ -50,7 +50,7 @@ unsigned __int64 Sectionbits[500]; #ifdef ENTROPY_STATS int intra_mode_stats[10][10][10]; -static unsigned int tree_update_hist [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens-1] [2]; +static unsigned int tree_update_hist [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES] [2]; extern unsigned int active_section; #endif @@ -1133,7 +1133,7 @@ static void write_kfmodes(VP8_COMP *cpi) /* This function is used for debugging probability trees. */ static void print_prob_tree(vp8_prob - coef_probs[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][vp8_coef_tokens-1]) + coef_probs[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES]) { /* print coef probability tree */ int i,j,k,l; @@ -1148,7 +1148,7 @@ static void print_prob_tree(vp8_prob for (k = 0; k < PREV_COEF_CONTEXTS; k++) { fprintf(f, " {"); - for (l = 0; l < MAX_ENTROPY_TOKENS - 1; l++) + for (l = 0; l < ENTROPY_NODES; l++) { fprintf(f, "%3u, ", (unsigned int)(coef_probs [i][j][k][l])); @@ -1164,11 +1164,11 @@ static void print_prob_tree(vp8_prob } static void sum_probs_over_prev_coef_context( - const unsigned int probs[PREV_COEF_CONTEXTS][vp8_coef_tokens], + const unsigned int probs[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS], unsigned int* out) { int i, j; - for (i=0; i < vp8_coef_tokens; ++i) + for (i=0; i < MAX_ENTROPY_TOKENS; ++i) { for (j=0; j < PREV_COEF_CONTEXTS; ++j) { @@ -1203,8 +1203,8 @@ static int independent_coef_context_savings(VP8_COMP *cpi) do { int k = 0; - unsigned int prev_coef_count_sum[vp8_coef_tokens] = {0}; - int prev_coef_savings[vp8_coef_tokens] = {0}; + unsigned int prev_coef_count_sum[MAX_ENTROPY_TOKENS] = {0}; + int prev_coef_savings[MAX_ENTROPY_TOKENS] = {0}; /* Calculate new probabilities given the constraint that * they must be equal over the prev coef contexts */ @@ -1224,13 +1224,13 @@ static int independent_coef_context_savings(VP8_COMP *cpi) /* at every context */ /* calc probs and branch cts for this frame only */ - //vp8_prob new_p [vp8_coef_tokens-1]; - //unsigned int branch_ct [vp8_coef_tokens-1] [2]; + //vp8_prob new_p [ENTROPY_NODES]; + //unsigned int branch_ct [ENTROPY_NODES] [2]; int t = 0; /* token/prob index */ vp8_tree_probs_from_distribution( - vp8_coef_tokens, vp8_coef_encodings, vp8_coef_tree, + MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree, cpi->frame_coef_probs[i][j][k], cpi->frame_branch_ct [i][j][k], prev_coef_count_sum, @@ -1248,7 +1248,7 @@ static int independent_coef_context_savings(VP8_COMP *cpi) (cpi->common.frame_type == KEY_FRAME && newp != oldp)) prev_coef_savings[t] += s; } - while (++t < vp8_coef_tokens - 1); + while (++t < ENTROPY_NODES); } while (++k < PREV_COEF_CONTEXTS); k = 0; @@ -1263,7 +1263,7 @@ static int independent_coef_context_savings(VP8_COMP *cpi) cpi->common.frame_type == KEY_FRAME) savings += prev_coef_savings[k]; } - while (++k < vp8_coef_tokens - 1); + while (++k < ENTROPY_NODES); } while (++j < COEF_BANDS); } @@ -1286,14 +1286,14 @@ static int default_coef_context_savings(VP8_COMP *cpi) /* at every context */ /* calc probs and branch cts for this frame only */ - //vp8_prob new_p [vp8_coef_tokens-1]; - //unsigned int branch_ct [vp8_coef_tokens-1] [2]; + //vp8_prob new_p [ENTROPY_NODES]; + //unsigned int branch_ct [ENTROPY_NODES] [2]; int t = 0; /* token/prob index */ vp8_tree_probs_from_distribution( - vp8_coef_tokens, vp8_coef_encodings, vp8_coef_tree, + MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree, cpi->frame_coef_probs [i][j][k], cpi->frame_branch_ct [i][j][k], cpi->coef_counts [i][j][k], @@ -1313,7 +1313,7 @@ static int default_coef_context_savings(VP8_COMP *cpi) savings += s; } } - while (++t < vp8_coef_tokens - 1); + while (++t < ENTROPY_NODES); } while (++k < PREV_COEF_CONTEXTS); } @@ -1408,13 +1408,13 @@ static void update_coef_probs(VP8_COMP *cpi) do { int k = 0; - int prev_coef_savings[vp8_coef_tokens - 1] = {0}; + int prev_coef_savings[ENTROPY_NODES] = {0}; if (cpi->oxcf.error_resilient_mode & VPX_ERROR_RESILIENT_PARTITIONS) { for (k = 0; k < PREV_COEF_CONTEXTS; ++k) { int t; /* token/prob index */ - for (t = 0; t < vp8_coef_tokens - 1; ++t) + for (t = 0; t < ENTROPY_NODES; ++t) { const unsigned int *ct = cpi->frame_branch_ct [i][j] [k][t]; @@ -1435,13 +1435,13 @@ static void update_coef_probs(VP8_COMP *cpi) /* at every context */ /* calc probs and branch cts for this frame only */ - //vp8_prob new_p [vp8_coef_tokens-1]; - //unsigned int branch_ct [vp8_coef_tokens-1] [2]; + //vp8_prob new_p [ENTROPY_NODES]; + //unsigned int branch_ct [ENTROPY_NODES] [2]; int t = 0; /* token/prob index */ //vp8_tree_probs_from_distribution( - // vp8_coef_tokens, vp8_coef_encodings, vp8_coef_tree, + // MAX_ENTROPY_TOKENS, vp8_coef_encodings, vp8_coef_tree, // new_p, branch_ct, (unsigned int *)cpi->coef_counts [i][j][k], // 256, 1 // ); @@ -1495,7 +1495,7 @@ static void update_coef_probs(VP8_COMP *cpi) } } - while (++t < vp8_coef_tokens - 1); + while (++t < ENTROPY_NODES); /* Accum token counts for generation of default statistics */ #ifdef ENTROPY_STATS @@ -1505,7 +1505,7 @@ static void update_coef_probs(VP8_COMP *cpi) { context_counters [i][j][k][t] += cpi->coef_counts [i][j][k][t]; } - while (++t < vp8_coef_tokens); + while (++t < MAX_ENTROPY_TOKENS); #endif @@ -1881,7 +1881,7 @@ void print_tree_update_probs() FILE *f = fopen("context.c", "a"); int Sum; fprintf(f, "\n/* Update probabilities for token entropy tree. */\n\n"); - fprintf(f, "const vp8_prob tree_update_probs[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens-1] = {\n"); + fprintf(f, "const vp8_prob tree_update_probs[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES] = {\n"); for (i = 0; i < BLOCK_TYPES; i++) { @@ -1895,7 +1895,7 @@ void print_tree_update_probs() { fprintf(f, " {"); - for (l = 0; l < MAX_ENTROPY_TOKENS - 1; l++) + for (l = 0; l < ENTROPY_NODES; l++) { Sum = tree_update_hist[i][j][k][l][0] + tree_update_hist[i][j][k][l][1]; diff --git a/vp8/encoder/block.h b/vp8/encoder/block.h index e8a5b78eb..82a93cdab 100644 --- a/vp8/encoder/block.h +++ b/vp8/encoder/block.h @@ -115,7 +115,7 @@ typedef struct unsigned char *active_ptr; MV_CONTEXT *mvc; - unsigned int token_costs[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens]; + unsigned int token_costs[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; int optimize; int q_index; diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h index d94436bd8..b9544a171 100644 --- a/vp8/encoder/onyx_int.h +++ b/vp8/encoder/onyx_int.h @@ -401,11 +401,11 @@ typedef struct VP8_COMP unsigned int MVcount [2] [MVvals]; /* (row,col) MV cts this frame */ - unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens]; /* for this frame */ - //DECLARE_ALIGNED(16, int, coef_counts_backup [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens]); //not used any more + unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */ + //DECLARE_ALIGNED(16, int, coef_counts_backup [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]); //not used any more //save vp8_tree_probs_from_distribution result for each frame to avoid repeat calculation - vp8_prob frame_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens-1]; - unsigned int frame_branch_ct [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens-1][2]; + vp8_prob frame_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; + unsigned int frame_branch_ct [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2]; int gfu_boost; int kf_boost; diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index e05ffdb1a..e0359057a 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -134,8 +134,8 @@ const MV_REFERENCE_FRAME vp8_ref_frame_order[MAX_MODES] = }; static void fill_token_costs( - unsigned int c [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens], - const vp8_prob p [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens-1] + unsigned int c [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS], + const vp8_prob p [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES] ) { int i, j, k; diff --git a/vp8/encoder/tokenize.c b/vp8/encoder/tokenize.c index 329abac68..e14e6fc92 100644 --- a/vp8/encoder/tokenize.c +++ b/vp8/encoder/tokenize.c @@ -21,7 +21,7 @@ compressions, then generating context.c = initial stats. */ #ifdef ENTROPY_STATS -_int64 context_counters[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens]; +_int64 context_counters[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; #endif void vp8_stuff_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t) ; void vp8_fix_contexts(MACROBLOCKD *x); @@ -282,9 +282,9 @@ void print_context_counters() fprintf(f, "\n/* *** GENERATED FILE: DO NOT EDIT *** */\n\n"); - fprintf(f, "int Contexts[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens];\n\n"); + fprintf(f, "int Contexts[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];\n\n"); - fprintf(f, "const int default_contexts[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens] = {"); + fprintf(f, "const int default_contexts[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {"); # define Comma( X) (X? ",":"") @@ -317,7 +317,7 @@ void print_context_counters() fprintf(f, "%s %d", Comma(t), y); } - while (++t < vp8_coef_tokens); + while (++t < MAX_ENTROPY_TOKENS); fprintf(f, "}"); } diff --git a/vp8/encoder/tokenize.h b/vp8/encoder/tokenize.h index d87c1a3e7..04a8879cf 100644 --- a/vp8/encoder/tokenize.h +++ b/vp8/encoder/tokenize.h @@ -37,7 +37,7 @@ int rd_cost_mby(MACROBLOCKD *); void init_context_counters(); void print_context_counters(); -extern _int64 context_counters[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens]; +extern _int64 context_counters[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; #endif extern const int *vp8_dct_value_cost_ptr;