#define DCPREDCNTTHRESH 3
#define MB_FEATURE_TREE_PROBS 3
-#define SEGMENT_PREDICTION_PROBS 3
+#define PREDICTION_PROBS 3
#define MAX_MB_SEGMENTS 4
// Probability Tree used to code Segment number
vp8_prob mb_segment_tree_probs[MB_FEATURE_TREE_PROBS];
- // Context probabilities when using predictive coding of segment id
- vp8_prob mb_segment_pred_probs[SEGMENT_PREDICTION_PROBS];
- unsigned char temporal_update;
// Segment features
signed char segment_feature_data[MAX_MB_SEGMENTS][SEG_LVL_MAX];
MODE_INFO *prev_mi; /* 'mi' from last frame (points into prev_mip) */
+ // Persistent mb segment id map used in prediction.
+ unsigned char * last_frame_seg_map;
+
INTERPOLATIONFILTERTYPE mcomp_filter_type;
LOOPFILTERTYPE filter_type;
#endif
vp8_prob i8x8_mode_prob [VP8_UV_MODES-1];
+ // Context probabilities when using predictive coding of segment id
+ vp8_prob segment_pred_probs[PREDICTION_PROBS];
+ unsigned char temporal_update;
+
FRAME_CONTEXT lfc_a; /* last alt ref entropy */
FRAME_CONTEXT lfc; /* last frame entropy */
MB_PREDICTION_MODE y_mode;
// Read the Macroblock segmentation map if it is being updated explicitly
- // this frame (reset to 0 above by default).
+ // this frame (reset to 0 by default).
m->mbmi.segment_id = 0;
if (pbi->mb.update_mb_segmentation_map)
{
vp8_read_mb_segid(bc, &m->mbmi, &pbi->mb);
- pbi->segmentation_map[map_index] = m->mbmi.segment_id;
+ pbi->common.last_frame_seg_map[map_index] = m->mbmi.segment_id;
}
//#if CONFIG_SEGFEATURES
#endif
int mb_row, int mb_col)
{
+ VP8_COMMON *const cm = & pbi->common;
vp8_reader *const bc = & pbi->bc;
MV_CONTEXT *const mvc = pbi->common.fc.mvc;
const int mis = pbi->common.mode_info_stride;
if (xd->update_mb_segmentation_map)
{
// Is temporal coding of the segment id for this mb enabled.
- if (xd->temporal_update)
+ if (cm->temporal_update)
{
// Work out a context for decoding seg_id_predicted.
pred_context = 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;
+ (mi-cm->mode_info_stride)->mbmi.seg_id_predicted;
mbmi->seg_id_predicted =
vp8_read(bc,
- xd->mb_segment_pred_probs[pred_context]);
+ cm->segment_pred_probs[pred_context]);
if ( mbmi->seg_id_predicted )
{
- mbmi->segment_id = pbi->segmentation_map[index];
+ mbmi->segment_id = cm->last_frame_seg_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;
+ cm->last_frame_seg_map[index] = mbmi->segment_id;
}
}
else
{
vp8_read_mb_segid(bc, &mi->mbmi, xd);
- pbi->segmentation_map[index] = mbmi->segment_id;
+ cm->last_frame_seg_map[index] = mbmi->segment_id;
}
index++;
}
// If so what method will be used.
if ( xd->update_mb_segmentation_map )
- xd->temporal_update = (unsigned char)vp8_read_bit(bc);
+ pc->temporal_update = (unsigned char)vp8_read_bit(bc);
// Is the segment data being updated
xd->update_mb_segmentation_data = (unsigned char)vp8_read_bit(bc);
// Which macro block level features are enabled
vpx_memset(xd->mb_segment_tree_probs, 255,
sizeof(xd->mb_segment_tree_probs));
- vpx_memset(xd->mb_segment_pred_probs, 255,
- sizeof(xd->mb_segment_pred_probs));
+ vpx_memset(pc->segment_pred_probs, 255,
+ sizeof(pc->segment_pred_probs));
// Read the probs used to decode the segment id for each macro
// block.
// If predictive coding of segment map is enabled read the
// prediction probabilities.
- if ( xd->temporal_update )
+ if ( pc->temporal_update )
{
// Read the prediction probs needed to decode the segment id
// when predictive coding enabled
- for (i = 0; i < SEGMENT_PREDICTION_PROBS; i++)
+ for (i = 0; i < PREDICTION_PROBS; i++)
{
// If not explicitly set value is defaulted to 255 by
// memset above
if (vp8_read_bit(bc))
- xd->mb_segment_pred_probs[i] =
+ pc->segment_pred_probs[i] =
(vp8_prob)vp8_read_literal(bc, 8);
}
}
vpx_memcpy(&xd->dst, &pc->yv12_fb[pc->new_fb_idx], sizeof(YV12_BUFFER_CONFIG));
// Create the encoder segmentation map and set all entries to 0
- if (!pbi->segmentation_map)
- CHECK_MEM_ERROR(pbi->segmentation_map, vpx_calloc((pc->mb_rows * pc->mb_cols), 1));
+ if (!pc->last_frame_seg_map)
+ CHECK_MEM_ERROR(pc->last_frame_seg_map,
+ vpx_calloc((pc->mb_rows * pc->mb_cols), 1));
/* set up frame new frame for intra coded blocks */
#if CONFIG_MULTITHREAD
return;
// Delete sementation map
- if (pbi->segmentation_map != 0)
- vpx_free(pbi->segmentation_map);
+ if (pbi->common.last_frame_seg_map != 0)
+ vpx_free(pbi->common.last_frame_seg_map);
#if CONFIG_MULTITHREAD
if (pbi->b_multithreaded_rd)
const unsigned char *partitions[MAX_PARTITIONS];
unsigned int partition_sizes[MAX_PARTITIONS];
unsigned int num_partitions;
- unsigned char *segmentation_map;
#if CONFIG_MULTITHREAD
/* variable for threading */
if (cpi->mb.e_mbd.update_mb_segmentation_map)
{
// Is temporal coding of the segment map enabled
- if (xd->temporal_update)
+ if (pc->temporal_update)
{
// Look at whether neighbours were successfully predicted
// to create a context for the seg_id_predicted flag.
// Code the prediction flag for this mb
vp8_write( w, m->mbmi.seg_id_predicted,
- xd->mb_segment_pred_probs[pred_context]);
+ pc->segment_pred_probs[pred_context]);
// If the mbs segment id was not predicted code explicitly
if (!m->mbmi.seg_id_predicted)
#endif
//#if CONFIG_SEGFEATURES
- // Is the segment coding of reference frame enabled
+ // Is the segment coding of mode enabled
if ( !segfeature_active( xd, segment_id, SEG_LVL_MODE ) )
{
write_mv_ref(w, mode, mv_ref_p);
// If it is, then indicate the method that will be used.
if ( xd->update_mb_segmentation_map )
- vp8_write_bit(bc, (xd->temporal_update) ? 1:0);
+ vp8_write_bit(bc, (pc->temporal_update) ? 1:0);
vp8_write_bit(bc, (xd->update_mb_segmentation_data) ? 1 : 0);
// If predictive coding of segment map is enabled send the
// prediction probabilities.
- if ( xd->temporal_update )
+ if ( pc->temporal_update )
{
- for (i = 0; i < SEGMENT_PREDICTION_PROBS; i++)
+ for (i = 0; i < PREDICTION_PROBS; i++)
{
- int Data = xd->mb_segment_pred_probs[i];
+ int Data = pc->segment_pred_probs[i];
if (Data != 255)
{
}
}
- // Code to determine whether or not to update the scan order.
+ // Encode the loop filter level and type
vp8_write_bit(bc, pc->filter_type);
vp8_write_literal(bc, pc->filter_level, 6);
vp8_write_literal(bc, pc->sharpness_level, 3);
// Delete sementation map
vpx_free(cpi->segmentation_map);
cpi->segmentation_map = 0;
- vpx_free(cpi->last_segmentation_map);
- cpi->last_segmentation_map = 0;
+ vpx_free(cpi->common.last_frame_seg_map);
+ cpi->common.last_frame_seg_map = 0;
vpx_free(cpi->active_map);
cpi->active_map = 0;
CHECK_MEM_ERROR(cpi->segmentation_map, vpx_calloc((cpi->common.mb_rows * cpi->common.mb_cols), 1));
// And a copy "last_segmentation_map" for temporal coding
- CHECK_MEM_ERROR(cpi->last_segmentation_map,
+ CHECK_MEM_ERROR(cm->last_frame_seg_map,
vpx_calloc((cpi->common.mb_rows * cpi->common.mb_cols), 1));
CHECK_MEM_ERROR(cpi->active_map, vpx_calloc(cpi->common.mb_rows * cpi->common.mb_cols, 1));
choose_segmap_coding_method( cpi );
// Take a copy of the segment map if it changed for future comparison
- vpx_memcpy( cpi->last_segmentation_map,
+ vpx_memcpy( cm->last_frame_seg_map,
cpi->segmentation_map, cm->MBs );
}
int y_uv_mode_count[VP8_YMODES][VP8_UV_MODES];
#endif
-
-
unsigned char *segmentation_map;
- unsigned char *last_segmentation_map;
// segment threashold for encode breakout
int segment_encode_breakout[MAX_MB_SEGMENTS];
int segmap_index = 0;
unsigned char segment_id;
- int temporal_predictor_count[SEGMENT_PREDICTION_PROBS][2];
+ int temporal_predictor_count[PREDICTION_PROBS][2];
int no_pred_segcounts[MAX_MB_SEGMENTS];
int t_unpred_seg_counts[MAX_MB_SEGMENTS];
vp8_prob no_pred_tree[MB_FEATURE_TREE_PROBS];
vp8_prob t_pred_tree[MB_FEATURE_TREE_PROBS];
- vp8_prob t_nopred_prob[SEGMENT_PREDICTION_PROBS];
+ vp8_prob t_nopred_prob[PREDICTION_PROBS];
// Set default state for the segment tree probabilities and the
// temporal coding probabilities
vpx_memset(xd->mb_segment_tree_probs, 255,
sizeof(xd->mb_segment_tree_probs));
- vpx_memset(xd->mb_segment_pred_probs, 255,
- sizeof(xd->mb_segment_pred_probs));
+ vpx_memset(cm->segment_pred_probs, 255,
+ sizeof(cm->segment_pred_probs));
vpx_memset(no_pred_segcounts, 0, sizeof(no_pred_segcounts));
vpx_memset(t_unpred_seg_counts, 0, sizeof(t_unpred_seg_counts));
// Test to see if the last frame segment id at the same
// 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] )
+ if ( segment_id == cm->last_frame_seg_map[segmap_index] )
{
xd->mode_info_context->mbmi.seg_id_predicted = 1;
temporal_predictor_count[pred_context][1]++;
t_pred_cost = cost_segmap( xd, t_unpred_seg_counts, t_pred_tree );
// Add in the cost of the signalling for each prediction context
- for ( i = 0; i < SEGMENT_PREDICTION_PROBS; i++ )
+ for ( i = 0; i < PREDICTION_PROBS; i++ )
{
tot_count = temporal_predictor_count[i][0] +
temporal_predictor_count[i][1];
// Now choose which coding method to use.
if ( t_pred_cost < no_pred_cost )
{
- xd->temporal_update = 1;
+ cm->temporal_update = 1;
vpx_memcpy( xd->mb_segment_tree_probs,
t_pred_tree, sizeof(t_pred_tree) );
- vpx_memcpy( &xd->mb_segment_pred_probs,
+ vpx_memcpy( &cm->segment_pred_probs,
t_nopred_prob, sizeof(t_nopred_prob) );
}
else
{
- xd->temporal_update = 0;
+ cm->temporal_update = 0;
vpx_memcpy( xd->mb_segment_tree_probs,
no_pred_tree, sizeof(no_pred_tree) );
}