MB_PREDICTION_MODE mode, uv_mode;
MV_REFERENCE_FRAME ref_frame;
int_mv mv;
-#if CONFIG_SEGMENTATION
- unsigned char segment_flag;
-#endif
unsigned char partitioning;
unsigned char mb_skip_coeff; /* does this mb has coefficients at all, 1=no coefficients, 0=need decode tokens */
unsigned char need_to_clamp_mvs;
unsigned char segment_id; /* Which set of segmentation parameters should be used for this MB */
+#if CONFIG_SEGMENTATION
+ // Flag used when temporal prediction of segment map is enabled.
+ // 1 means it is predicted 0 that it must be coded explicitly
+ unsigned char seg_id_predicted;
+#endif
} MB_MODE_INFO;
if (xd->update_mb_segmentation_map)
{
#if CONFIG_SEGMENTATION
+ // 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.segment_flag;
+ pred_context += (mi-1)->mbmi.seg_id_predicted;
if (mb_row != 0)
pred_context +=
- (mi-pbi->common.mb_cols)->mbmi.segment_flag;
+ (mi-pbi->common.mb_cols)->mbmi.seg_id_predicted;
+
+ mbmi->seg_id_predicted =
+ vp8_read(bc,
+ xd->mb_segment_pred_probs[pred_context]);
- if (vp8_read(bc,
- xd->mb_segment_pred_probs[pred_context]) == 0)
+ if ( mbmi->seg_id_predicted )
{
mbmi->segment_id = pbi->segmentation_map[index];
- mbmi->segment_flag = 0;
}
+ // If the segment id was not predicted decode it explicitly
else
{
vp8_read_mb_segid(bc, &mi->mbmi, xd);
- mbmi->segment_flag = 1;
pbi->segmentation_map[index] = mbmi->segment_id;
}
}
+ // Normal unpredicted coding mode
else
{
vp8_read_mb_segid(bc, &mi->mbmi, xd);
if (cpi->mb.e_mbd.update_mb_segmentation_map)
{
#if CONFIG_SEGMENTATION
+ // Is temporal coding of the segment map enabled
if (xd->temporal_update)
{
+ // Look at whether neighbours were successfully predicted
+ // to create a context for the seg_id_predicted flag.
pred_context = 0;
if (mb_col != 0)
- pred_context += (m-1)->mbmi.segment_flag;
+ pred_context += (m-1)->mbmi.seg_id_predicted;
if (mb_row != 0)
- pred_context += (m-pc->mb_cols)->mbmi.segment_flag;
+ pred_context += (m-pc->mb_cols)->mbmi.seg_id_predicted;
- if (m->mbmi.segment_flag == 0)
- {
- vp8_write(w,0,xd->mb_segment_pred_probs[pred_context]);
- }
- else
- {
- vp8_write(w,1,xd->mb_segment_pred_probs[pred_context]);
+ // Code the prediction flag for this mb
+ vp8_write( w, m->mbmi.seg_id_predicted,
+ xd->mb_segment_pred_probs[pred_context]);
+
+ // If the mbs segment id was not predicted code explicitly
+ if (!m->mbmi.seg_id_predicted)
write_mb_segid(w, mi, &cpi->mb.e_mbd);
- }
}
else
{
+ // Normal undpredicted coding
write_mb_segid(w, mi, &cpi->mb.e_mbd);
}
index++;
pred_context = 0;
if (mb_col != 0)
pred_context +=
- (xd->mode_info_context-1)->mbmi.segment_flag;
+ (xd->mode_info_context-1)->mbmi.seg_id_predicted;
if (mb_row != 0)
+ {
pred_context +=
- (xd->mode_info_context-cm->mb_cols)->mbmi.segment_flag;
+ (xd->mode_info_context-cm->mb_cols)->
+ mbmi.seg_id_predicted;
+ }
// Test to see if the last frame segment id at the same
- // locationcorrectly predicts the segment_id for this MB.
+ // location correctly predicts the segment_id for this MB.
// Update the prediction flag and count as appropriate;
if ( segment_id == cpi->last_segmentation_map[segmap_index] )
{
- //xd->mode_info_context->mbmi.segment_predicted = 1;
- xd->mode_info_context->mbmi.segment_flag = 0;
- temporal_predictor_count[pred_context][0]++;
+ xd->mode_info_context->mbmi.seg_id_predicted = 1;
+ temporal_predictor_count[pred_context][1]++;
}
else
{
- //xd->mode_info_context->mbmi.segment_predicted = 0;
- xd->mode_info_context->mbmi.segment_flag = 1;
- temporal_predictor_count[pred_context][1]++;
+ xd->mode_info_context->mbmi.seg_id_predicted = 0;
+ temporal_predictor_count[pred_context][0]++;
// Update the "undpredicted" segment count
t_unpred_seg_counts[segment_id]++;
xd->temporal_update = 0;
vpx_memcpy( xd->mb_segment_tree_probs,
no_pred_tree, sizeof(no_pred_tree) );
- //vpx_memcpy( &xd->mb_segment_pred_probs,
- // t_nopred_prob, sizeof(t_nopred_prob) );
}
}
#endif