]> granicus.if.org Git - libvpx/commitdiff
Use MAX_ENTROPY_TOKENS and ENTROPY_NODES more consistently
authorJohn Koleszar <jkoleszar@google.com>
Tue, 28 Jun 2011 21:03:47 +0000 (17:03 -0400)
committerJohn Koleszar <jkoleszar@google.com>
Tue, 28 Jun 2011 21:03:55 +0000 (17:03 -0400)
There were many instances in the code of vp8_coef_tokens and
vp8_coef_tokens-1, which was a preprocessor macro despite the naming
convention. Replace these with MAX_ENTROPY_TOKENS and ENTROPY_NODES,
respectively.

Change-Id: I72c4f6c7634c94e1fa066cd511471e5592c748da

13 files changed:
vp8/common/coefupdateprobs.h
vp8/common/defaultcoefcounts.c
vp8/common/defaultcoefcounts.h
vp8/common/entropy.c
vp8/common/entropy.h
vp8/common/onyxc_int.h
vp8/decoder/decodframe.c
vp8/encoder/bitstream.c
vp8/encoder/block.h
vp8/encoder/onyx_int.h
vp8/encoder/rdopt.c
vp8/encoder/tokenize.c
vp8/encoder/tokenize.h

index 785e3ff7086bbebd9843deb4ec48ebc88e0bade7..9e194dc9a4dc829fa4564e7b9cda1c2c024df200 100644 (file)
@@ -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] =
 {
     {
         {
index ebb78164c695775c3c1f9e871510786e32f18853..b0e2e702abcfa581648de529ae359e8756095583 100644 (file)
@@ -15,7 +15,7 @@
 const unsigned int vp8_default_coef_counts[BLOCK_TYPES]
                                           [COEF_BANDS]
                                           [PREV_COEF_CONTEXTS]
-                                          [vp8_coef_tokens] =
+                                          [MAX_ENTROPY_TOKENS] =
 {
 
     {
index ebe8d7a2a2c30160dfc71523507504892dfde08d..7a1e28b7b2de095935d34e68a5d4a047cba9448f 100644 (file)
@@ -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
index b89ca92ebc3c9f0b8240d48df82ee1d77650db1f..fba7a07ffe95906ac07c448d98ec11cf8a17b106 100644 (file)
@@ -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],
index d174e45b964d51dfe72f19aaea39531fe4e92490..66d282b61e7b30bfe4c9bc276b9ded75902472c6 100644 (file)
 #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;
index d366b9b1be31eeb6987aaa276e52a7a89ce244cb..a381dfe872990d44f7e2f8fa41f24ecf5e90dab7 100644 (file)
@@ -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;
index 648fdb28855c6c1110b6005b67a026fd42ce2af7..a300bb5fd84e59e700047248a6860170da31e359 100644 (file)
@@ -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;
index ac298126314e52a38e52f620048be6fb5683bdb1..134e8488180426c863d97aa6edd476079f23d66f 100644 (file)
@@ -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];
 
index e8a5b78eb31ef9e9aae1401e3da4d50ea1cd539e..82a93cdab0b8673cbde18b1c113e03df601c98b2 100644 (file)
@@ -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;
 
index d94436bd8dee34f9356a77cd10111ce66c7323ab..b9544a1716954e8cc6ad8f99bc4953cbcf51f435 100644 (file)
@@ -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;
index e05ffdb1a757b046010506063d78f9300f9dc2ba..e0359057a1da2d7628d022eda52047bbba9a3e2f 100644 (file)
@@ -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;
index 329abac685ea2db22ba577dbc06a4ddc259cde90..e14e6fc92b3c9adddb86a7f2e887f5e47ccf92a9 100644 (file)
@@ -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, "}");
             }
index d87c1a3e7743df820d53dc569c979ca851471fd1..04a8879cfc58caaa2f363a8a23df66d6f5c9667e 100644 (file)
@@ -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;