]> granicus.if.org Git - libvpx/commitdiff
Merge token_costs into a single table.
authorDaniel Kang <ddkang@google.com>
Mon, 6 Aug 2012 18:38:50 +0000 (11:38 -0700)
committerDaniel Kang <ddkang@google.com>
Mon, 6 Aug 2012 22:55:54 +0000 (15:55 -0700)
Change-Id: Id1ea2d543f12d4589df7038d5fb7bac1fee4da11

vp8/encoder/block.h
vp8/encoder/encodemb.c
vp8/encoder/rdopt.c

index 2c1e29cc08a03272682b3dfb51636ceefbe4d73a..dfc1d743ec585cc7fa6dc0a2ef5f7c24bb891d2b 100644 (file)
@@ -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;
index bfab4c6475b548728d76ffe70f6fbc55a54fe905..0c208d76901ee85aff5884529d3831e423e3ac08 100644 (file)
@@ -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;
index 75eb8e04439a69198612477d6f49216e4ddec995..ca49fda822d7c34f29f2a97685181ce611212cb5 100644 (file)
@@ -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;