]> granicus.if.org Git - libvpx/commitdiff
Skip restore token_cache value
authorJingning Han <jingning@google.com>
Thu, 16 Jun 2016 22:18:46 +0000 (15:18 -0700)
committerJingning Han <jingning@google.com>
Thu, 16 Jun 2016 22:18:46 +0000 (15:18 -0700)
The trellis optimization is going backward. Hence there is no need
to restore the token_cache values that is behind the current node
in the scan order.

Change-Id: I4da8a2e3f78bf9630e6667c85d8c387c5d94de9a

vp10/encoder/encodemb.c

index 1b069b27496b122f03f4fe523902edc1ca7370c0..2ea29f108e518dc3cf24f2be2b3a2e2c0eefe743 100644 (file)
@@ -72,19 +72,6 @@ static const int plane_rd_mult[REF_TYPES][PLANE_TYPES] = {
   rd_cost1 = RDCOST(rdmult, rddiv, rate1, error1);\
 }
 
-// This function is a place holder for now but may ultimately need
-// to scan previous tokens to work out the correct context.
-static int trellis_get_coeff_context(const int16_t *scan,
-                                     const int16_t *nb,
-                                     int idx, int token,
-                                     uint8_t *token_cache) {
-  int bak = token_cache[scan[idx]], pt;
-  token_cache[scan[idx]] = vp10_pt_energy_class[token];
-  pt = get_coef_context(nb, token_cache, idx + 1);
-  token_cache[scan[idx]] = bak;
-  return pt;
-}
-
 int vp10_optimize_b(MACROBLOCK *mb, int plane, int block,
                     TX_SIZE tx_size, int ctx) {
   MACROBLOCKD *const xd = &mb->e_mbd;
@@ -161,7 +148,7 @@ int vp10_optimize_b(MACROBLOCK *mb, int plane, int block,
       /* Consider both possible successor states. */
       if (next < default_eob) {
         band = band_translate[i + 1];
-        pt = trellis_get_coeff_context(scan, nb, i, t0, token_cache);
+        pt = get_coef_context(nb, token_cache, i + 1);
         rate0 += token_costs[band][0][pt][tokens[next][0].token];
         rate1 += token_costs[band][0][pt][tokens[next][1].token];
       }
@@ -230,11 +217,13 @@ int vp10_optimize_b(MACROBLOCK *mb, int plane, int block,
       if (next < default_eob) {
         band = band_translate[i + 1];
         if (t0 != EOB_TOKEN) {
-          pt = trellis_get_coeff_context(scan, nb, i, t0, token_cache);
+          token_cache[rc] = vp10_pt_energy_class[t0];
+          pt = get_coef_context(nb, token_cache, i + 1);
           rate0 += token_costs[band][!x][pt][tokens[next][0].token];
         }
         if (t1 != EOB_TOKEN) {
-          pt = trellis_get_coeff_context(scan, nb, i, t1, token_cache);
+          token_cache[rc] = vp10_pt_energy_class[t1];
+          pt = get_coef_context(nb, token_cache, i + 1);
           rate1 += token_costs[band][!x][pt][tokens[next][1].token];
         }
       }