shithub: libvpx

Download patch

ref: 0fafd0543f45321356fd4a0a2467b8e40bbffdd1
parent: b3ade15a268ffdd4eea7fcbb2c0ecaca51e64294
author: Adrian Grange <agrange@google.com>
date: Fri Dec 16 09:00:36 EST 2011

Reset segment_id to 0 when segmentation is disabled

Whilst the encoder explicitly set the segment_id to 0
when segmentation is diabled, the decoder would allow
the segment_id to persist from the previous frame.

This fix attempts to make the decoder behave the same
as the encoder by explicitly setting the segment_id to
0 in this case.

Change-Id: I65c3a05247550edb10706eb5d54d306dfb792309

--- a/vp8/decoder/decodemv.c
+++ b/vp8/decoder/decodemv.c
@@ -468,45 +468,52 @@
     mb_to_right_edge += RIGHT_BOTTOM_MARGIN;
 
     /* If required read in new segmentation data for this MB */
-    if (xd->update_mb_segmentation_map)
+    if (xd->segmentation_enabled)
     {
-        // Is temporal coding of the segment id for this mb enabled.
-        if (xd->temporal_update)
+        if (xd->update_mb_segmentation_map)
         {
-            // Work out a context for decoding seg_id_predicted.
-            pred_context = 0;
-            if (mb_col != 0)
-                pred_context += (mi-1)->mbmi.seg_id_predicted;
-            if (mb_row != 0)
-                pred_context +=
-                    (mi-pbi->common.mode_info_stride)->mbmi.seg_id_predicted;
+            // Is temporal coding of the segment id for this mb enabled.
+            if (xd->temporal_update)
+            {
+                // Work out a context for decoding seg_id_predicted.
+                pred_context = 0;
+                if (mb_col != 0)
+                    pred_context += (mi-1)->mbmi.seg_id_predicted;
+                if (mb_row != 0)
+                    pred_context +=
+                        (mi-pbi->common.mode_info_stride)->mbmi.seg_id_predicted;
 
-            mbmi->seg_id_predicted =
-                vp8_read(bc,
-                         xd->mb_segment_pred_probs[pred_context]);
+                mbmi->seg_id_predicted =
+                    vp8_read(bc,
+                             xd->mb_segment_pred_probs[pred_context]);
 
-            if ( mbmi->seg_id_predicted )
-            {
-                mbmi->segment_id = pbi->segmentation_map[index];
+                if ( mbmi->seg_id_predicted )
+                {
+                    mbmi->segment_id = pbi->segmentation_map[index];
+                }
+                // If the segment id was not predicted decode it explicitly
+                else
+                {
+                    vp8_read_mb_segid(bc, &mi->mbmi, xd);
+                    pbi->segmentation_map[index] = mbmi->segment_id;
+                }
+
             }
-            // If the segment id was not predicted decode it explicitly
+            // Normal unpredicted coding mode
             else
             {
                 vp8_read_mb_segid(bc, &mi->mbmi, xd);
                 pbi->segmentation_map[index] = mbmi->segment_id;
             }
-
+            index++;
         }
-        // Normal unpredicted coding mode
-        else
-        {
-            vp8_read_mb_segid(bc, &mi->mbmi, xd);
-            pbi->segmentation_map[index] = mbmi->segment_id;
-        }
-        index++;
-
     }
-
+    else
+    {
+        // The encoder explicitly sets the segment_id to 0
+        // when segmentation is disabled
+        mbmi->segment_id = 0;
+    }
 //#if CONFIG_SEGFEATURES
     if ( pbi->common.mb_no_coeff_skip &&
          ( !segfeature_active( xd,