Change to segment_feature_data[][] structure.
authorPaul Wilkins <paulwilkins@google.com>
Tue, 13 Sep 2011 11:58:04 +0000 (12:58 +0100)
committerPaul Wilkins <paulwilkins@google.com>
Tue, 13 Sep 2011 11:58:04 +0000 (12:58 +0100)
This data structure is  now [Segment ID][Features]
rather than [Features][Segment_ID]

I propose as a separate modification to make the experimental
bit stream reflect this such that all the features for a segment
are coded together.

Change-Id: I581e4e3ca2033bdbdef3d9300977a8202f55b4fb

vp8/common/blockd.h
vp8/common/loopfilter.c
vp8/decoder/decodframe.c
vp8/encoder/bitstream.c
vp8/encoder/onyx_int.h
vp8/encoder/picklpf.c
vp8/encoder/quantize.c

index 873c674..72f848c 100644 (file)
@@ -253,7 +253,7 @@ typedef struct MacroBlockD
 #endif
 
     // Segment features
-    signed char segment_feature_data[SEG_LVL_MAX][MAX_MB_SEGMENTS];
+    signed char segment_feature_data[MAX_MB_SEGMENTS][SEG_LVL_MAX];
 
     /* mode_based Loop filter adjustment */
     unsigned char mode_ref_lf_delta_enabled;
index b745216..346a435 100644 (file)
@@ -221,11 +221,11 @@ void vp8_loop_filter_frame_init(VP8_COMMON *cm,
             /* Abs value */
             if (mbd->mb_segement_abs_delta == SEGMENT_ABSDATA)
             {
-                lvl_seg = mbd->segment_feature_data[SEG_LVL_ALT_LF][seg];
+                lvl_seg = mbd->segment_feature_data[seg][SEG_LVL_ALT_LF];
             }
             else  /* Delta Value */
             {
-                lvl_seg += mbd->segment_feature_data[SEG_LVL_ALT_LF][seg];
+                lvl_seg += mbd->segment_feature_data[seg][SEG_LVL_ALT_LF];
                 lvl_seg = (lvl_seg > 0) ? ((lvl_seg > 63) ? 63: lvl_seg) : 0;
             }
         }
@@ -541,13 +541,13 @@ void vp8_loop_filter_partial_frame
         {    /* Abs value */
             if (mbd->mb_segement_abs_delta == SEGMENT_ABSDATA)
             {
-                lvl_seg[i] = mbd->segment_feature_data[SEG_LVL_ALT_LF][i];
+                lvl_seg[i] = mbd->segment_feature_data[i][SEG_LVL_ALT_LF];
             }
             /* Delta Value */
             else
             {
                 lvl_seg[i] = default_filt_lvl
-                        + mbd->segment_feature_data[SEG_LVL_ALT_LF][i];
+                        + mbd->segment_feature_data[i][SEG_LVL_ALT_LF];
                 lvl_seg[i] = (lvl_seg[i] > 0) ?
                         ((lvl_seg[i] > 63) ? 63: lvl_seg[i]) : 0;
             }
index 02ac80a..4c98808 100644 (file)
@@ -80,12 +80,13 @@ void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd)
     {
         /* Abs Value */
         if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA)
-            QIndex = xd->segment_feature_data[SEG_LVL_ALT_Q][mbmi->segment_id];
+            QIndex = xd->segment_feature_data[mbmi->segment_id][SEG_LVL_ALT_Q];
 
         /* Delta Value */
         else
         {
-            QIndex = pc->base_qindex + xd->segment_feature_data[SEG_LVL_ALT_Q][mbmi->segment_id];
+            QIndex = pc->base_qindex +
+                xd->segment_feature_data[mbmi->segment_id][SEG_LVL_ALT_Q];
             QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ) : 0;    /* Clamp to valid range */
         }
     }
@@ -946,13 +947,13 @@ int vp8_decode_frame(VP8D_COMP *pbi)
                     /* Frame level data */
                     if (vp8_read_bit(bc))
                     {
-                        xd->segment_feature_data[i][j] = (signed char)vp8_read_literal(bc, mb_feature_data_bits[i]);
+                        xd->segment_feature_data[j][i] = (signed char)vp8_read_literal(bc, mb_feature_data_bits[i]);
 
                         if (vp8_read_bit(bc))
-                            xd->segment_feature_data[i][j] = -xd->segment_feature_data[i][j];
+                            xd->segment_feature_data[j][i] = -xd->segment_feature_data[j][i];
                     }
                     else
-                        xd->segment_feature_data[i][j] = 0;
+                        xd->segment_feature_data[j][i] = 0;
                 }
             }
         }
index 7c4ec9a..889f09e 100644 (file)
@@ -1852,7 +1852,7 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size)
                 // For each of the segments
                 for (j = 0; j < MAX_MB_SEGMENTS; j++)
                 {
-                    Data = xd->segment_feature_data[i][j];
+                    Data = xd->segment_feature_data[j][i];
 
                     // Frame level data
                     if (Data)
index 403508b..b01392c 100644 (file)
@@ -478,7 +478,7 @@ typedef struct VP8_COMP
     unsigned char *segmentation_map;
 
     // Segment data (can be deltas or absolute values)
-    signed char segment_feature_data[SEG_LVL_MAX][MAX_MB_SEGMENTS];
+    signed char segment_feature_data[MAX_MB_SEGMENTS][SEG_LVL_MAX];
 
     // segment threashold for encode breakout
     int  segment_encode_breakout[MAX_MB_SEGMENTS];
index 3a6117f..df8a2b2 100644 (file)
@@ -259,10 +259,10 @@ void vp8cx_set_alt_lf_level(VP8_COMP *cpi, int filt_val)
     MACROBLOCKD *mbd = &cpi->mb.e_mbd;
     (void) filt_val;
 
-    mbd->segment_feature_data[SEG_LVL_ALT_LF][0] = cpi->segment_feature_data[SEG_LVL_ALT_LF][0];
-    mbd->segment_feature_data[SEG_LVL_ALT_LF][1] = cpi->segment_feature_data[SEG_LVL_ALT_LF][1];
-    mbd->segment_feature_data[SEG_LVL_ALT_LF][2] = cpi->segment_feature_data[SEG_LVL_ALT_LF][2];
-    mbd->segment_feature_data[SEG_LVL_ALT_LF][3] = cpi->segment_feature_data[SEG_LVL_ALT_LF][3];
+    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[3][SEG_LVL_ALT_LF] = cpi->segment_feature_data[3][SEG_LVL_ALT_LF];
 }
 
 void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
index 200d1ae..13009bb 100644 (file)
@@ -1174,11 +1174,11 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
         // Abs Value
         if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA)
 
-            QIndex = xd->segment_feature_data[SEG_LVL_ALT_Q][xd->mode_info_context->mbmi.segment_id];
+            QIndex = xd->segment_feature_data[xd->mode_info_context->mbmi.segment_id][SEG_LVL_ALT_Q];
         // Delta Value
         else
         {
-            QIndex = cpi->common.base_qindex + xd->segment_feature_data[SEG_LVL_ALT_Q][xd->mode_info_context->mbmi.segment_id];
+            QIndex = cpi->common.base_qindex + xd->segment_feature_data[xd->mode_info_context->mbmi.segment_id][SEG_LVL_ALT_Q];
             QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ) : 0;    // Clamp to valid range
         }
     }
@@ -1316,10 +1316,10 @@ void vp8_set_quantizer(struct VP8_COMP *cpi, int Q)
 
 
     // Set Segment specific quatizers
-    mbd->segment_feature_data[SEG_LVL_ALT_Q][0] = cpi->segment_feature_data[SEG_LVL_ALT_Q][0];
-    mbd->segment_feature_data[SEG_LVL_ALT_Q][1] = cpi->segment_feature_data[SEG_LVL_ALT_Q][1];
-    mbd->segment_feature_data[SEG_LVL_ALT_Q][2] = cpi->segment_feature_data[SEG_LVL_ALT_Q][2];
-    mbd->segment_feature_data[SEG_LVL_ALT_Q][3] = cpi->segment_feature_data[SEG_LVL_ALT_Q][3];
+    mbd->segment_feature_data[0][SEG_LVL_ALT_Q] = cpi->segment_feature_data[0][SEG_LVL_ALT_Q];
+    mbd->segment_feature_data[1][SEG_LVL_ALT_Q] = cpi->segment_feature_data[1][SEG_LVL_ALT_Q];
+    mbd->segment_feature_data[2][SEG_LVL_ALT_Q] = cpi->segment_feature_data[2][SEG_LVL_ALT_Q];
+    mbd->segment_feature_data[3][SEG_LVL_ALT_Q] = cpi->segment_feature_data[3][SEG_LVL_ALT_Q];
 
     /* quantizer has to be reinitialized for any delta_q changes */
     if(update)