Fix mix-up in pt token indexing.
authorRonald S. Bultje <rbultje@google.com>
Thu, 28 Mar 2013 16:24:29 +0000 (09:24 -0700)
committerRonald S. Bultje <rbultje@google.com>
Thu, 28 Mar 2013 16:24:29 +0000 (09:24 -0700)
This fixes uninitialized reads in the trellis, and probably makes the
trellis do something again.

Change-Id: Ifac8dae9aa77574bde0954a71d4571c5c556df3c

vp9/common/vp9_entropy.c
vp9/decoder/vp9_detokenize.c
vp9/encoder/vp9_rdopt.c
vp9/encoder/vp9_tokenize.c

index a1dbd3e..d05be99 100644 (file)
@@ -2105,11 +2105,10 @@ int vp9_get_coef_context(const int *scan, const int *neighbors,
                          int nb_pad, uint8_t *token_cache, int c, int l) {
   int eob = l;
   assert(nb_pad == MAX_NEIGHBORS);
-  if (c == eob - 1) {
+  if (c == eob) {
     return 0;
   } else {
     int ctx;
-    c++;
     assert(neighbors[MAX_NEIGHBORS * c + 0] >= 0);
     if (neighbors[MAX_NEIGHBORS * c + 1] >= 0) {
       ctx = (1 + token_cache[neighbors[MAX_NEIGHBORS * c + 0]] +
index b6eec37..a744050 100644 (file)
@@ -69,7 +69,7 @@ static int get_signed(BOOL_DECODER *br, int value_to_sign) {
                [pt][token]++;     \
     token_cache[c] = token; \
     pt = vp9_get_coef_context(scan, nb, pad, token_cache,     \
-                              c, default_eob); \
+                              c + 1, default_eob); \
   } while (0)
 
 #if CONFIG_CODE_NONZEROCOUNT
index ad9b960..0083e8a 100644 (file)
@@ -595,7 +595,7 @@ static INLINE int cost_coeffs(VP9_COMMON *const cm, MACROBLOCK *mb,
                                        [get_coef_band(scan, tx_size, c)]
                                        [pt][0], 1);
 #endif
-      pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
+      pt = vp9_get_coef_context(scan, nb, pad, token_cache, c + 1, default_eob);
     }
 #if CONFIG_CODE_NONZEROCOUNT
     cost += nzc_cost[nzc];
index 6e2b847..21401d1 100644 (file)
@@ -291,7 +291,7 @@ static void tokenize_b(VP9_COMP *cpi,
 #endif
     token_cache[c] = token;
 
-    pt = vp9_get_coef_context(scan, nb, pad, token_cache, c, default_eob);
+    pt = vp9_get_coef_context(scan, nb, pad, token_cache, c + 1, default_eob);
     ++t;
   } while (c < eob && ++c < seg_eob);
 #if CONFIG_CODE_NONZEROCOUNT