From 0fafd0543f45321356fd4a0a2467b8e40bbffdd1 Mon Sep 17 00:00:00 2001 From: Adrian Grange <agrange@google.com> Date: Fri, 16 Dec 2011 14:00:36 -0800 Subject: [PATCH] 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 --- vp8/decoder/decodemv.c | 63 +++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/vp8/decoder/decodemv.c b/vp8/decoder/decodemv.c index b3799c78de..b33d15f88e 100644 --- a/vp8/decoder/decodemv.c +++ b/vp8/decoder/decodemv.c @@ -468,45 +468,52 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi, 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; - - mbmi->seg_id_predicted = - vp8_read(bc, - xd->mb_segment_pred_probs[pred_context]); - - if ( mbmi->seg_id_predicted ) + // Is temporal coding of the segment id for this mb enabled. + if (xd->temporal_update) { - mbmi->segment_id = pbi->segmentation_map[index]; + // 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]); + + 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; } - - } - // Normal unpredicted coding mode - else - { - vp8_read_mb_segid(bc, &mi->mbmi, xd); - pbi->segmentation_map[index] = mbmi->segment_id; + index++; } - 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, -- GitLab