From 1741cc7ab94ebe1b608c1765da75421f6616c49e Mon Sep 17 00:00:00 2001
From: Paul Wilkins <paulwilkins@google.com>
Date: Tue, 13 Sep 2011 15:24:45 +0100
Subject: [PATCH] Reverse coding order for segment features:

Code all the features for one segment (grouped together)
then all for the next etc. etc. rather than grouping the
data by feature.

Change-Id: I2a65193b3a70aca78f92e855e35d8969d857b6dd
---
 vp8/decoder/decodframe.c | 13 ++++++++++++-
 vp8/encoder/bitstream.c  | 18 ++++++++++++++----
 vp8/encoder/picklpf.c    |  2 +-
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/vp8/decoder/decodframe.c b/vp8/decoder/decodframe.c
index 4c98808592..33102f2747 100644
--- a/vp8/decoder/decodframe.c
+++ b/vp8/decoder/decodframe.c
@@ -939,11 +939,22 @@ int vp8_decode_frame(VP8D_COMP *pbi)
 
             vpx_memset(xd->segment_feature_data, 0, sizeof(xd->segment_feature_data));
 
-            /* For each segmentation feature (Quant and loop filter level) */
+#if CONFIG_SEGFEATURES
+            // For each segmentation...
+            for (j = 0; j < MAX_MB_SEGMENTS; j++)
+            {
+                // For each of the segments features...
+                for (i = 0; i < SEG_LVL_MAX; i++)
+                {
+
+#else
+            // For each segmentation feature...
             for (i = 0; i < SEG_LVL_MAX; i++)
             {
+                // For each segmentation...
                 for (j = 0; j < MAX_MB_SEGMENTS; j++)
                 {
+#endif
                     /* Frame level data */
                     if (vp8_read_bit(bc))
                     {
diff --git a/vp8/encoder/bitstream.c b/vp8/encoder/bitstream.c
index 889f09e49e..c4901bf7ba 100644
--- a/vp8/encoder/bitstream.c
+++ b/vp8/encoder/bitstream.c
@@ -1846,11 +1846,19 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size)
 
             vp8_write_bit(bc, (xd->mb_segement_abs_delta) ? 1 : 0);
 
-            // For each segmentation codable feature
+#if CONFIG_SEGFEATURES
+            // For each segments id...
+            for (j = 0; j < MAX_MB_SEGMENTS; j++)
+            {
+                // For each segmentation codable feature...
+                for (i = 0; i < SEG_LVL_MAX; i++)
+#else
+            // For each segmentation codable feature...
             for (i = 0; i < SEG_LVL_MAX; i++)
             {
-                // For each of the segments
+                // For each of the segments id...
                 for (j = 0; j < MAX_MB_SEGMENTS; j++)
+#endif
                 {
                     Data = xd->segment_feature_data[j][i];
 
@@ -1862,12 +1870,14 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size)
                         if (Data < 0)
                         {
                             Data = - Data;
-                            vp8_write_literal(bc, Data, mb_feature_data_bits[i]);
+                            vp8_write_literal(bc, Data,
+                                              mb_feature_data_bits[i]);
                             vp8_write_bit(bc, 1);
                         }
                         else
                         {
-                            vp8_write_literal(bc, Data, mb_feature_data_bits[i]);
+                            vp8_write_literal(bc, Data,
+                                              mb_feature_data_bits[i]);
                             vp8_write_bit(bc, 0);
                         }
                     }
diff --git a/vp8/encoder/picklpf.c b/vp8/encoder/picklpf.c
index df8a2b2793..0585d66e2c 100644
--- a/vp8/encoder/picklpf.c
+++ b/vp8/encoder/picklpf.c
@@ -261,7 +261,7 @@ void vp8cx_set_alt_lf_level(VP8_COMP *cpi, int filt_val)
 
     mbd->segment_feature_data[0][SEG_LVL_ALT_LF] = cpi->segment_feature_data[0][SEG_LVL_ALT_LF];
     mbd->segment_feature_data[1][SEG_LVL_ALT_LF] = cpi->segment_feature_data[1][SEG_LVL_ALT_LF];
-    mbd->segment_feature_data[2][SEG_LVL_ALT_LF] = cpi->segment_feature_data[2[SEG_LVL_ALT_LF]];
+    mbd->segment_feature_data[2][SEG_LVL_ALT_LF] = cpi->segment_feature_data[2][SEG_LVL_ALT_LF];
     mbd->segment_feature_data[3][SEG_LVL_ALT_LF] = cpi->segment_feature_data[3][SEG_LVL_ALT_LF];
 }
 
-- 
GitLab