Merge CONFIGURE_SEGMENTATION experiment.

Removal of CONFIGURE_SEGMENTATION ifdefs.

Removal of legacy support code fo the old coding mechanism.

Use local reference "xd" for MACROBLOCKD structure in
encode_frame_to_data_rate()

Moved call to choose_segmap_coding_method() out of encode
loop as the cost of segmentation is not properly accounted
in the loop anyway. If this is desirable in the future it
can be moved back. The use of this function to do all the
analysis and set the probabilities also removes the need
to track segment useage in threading code.

Change-Id: I85bc8fd63440e7176c73d26cb742698f9b70cade
This commit is contained in:
Paul Wilkins
2011-11-15 16:15:23 +00:00
parent 6394ef28d7
commit 3cdfdb55e4
12 changed files with 93 additions and 175 deletions

View File

@@ -374,9 +374,6 @@ static void mb_mode_mv_init(VP8D_COMP *pbi)
{
vp8_reader *const bc = & pbi->bc;
MV_CONTEXT *const mvc = pbi->common.fc.mvc;
#if CONFIG_SEGMENTATION
MACROBLOCKD *const xd = & pbi->mb;
#endif
#if CONFIG_ERROR_CONCEALMENT
/* Default is that no macroblock is corrupt, therefore we initialize
@@ -429,10 +426,8 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
const int mis = pbi->common.mode_info_stride;
MACROBLOCKD *const xd = & pbi->mb;
#if CONFIG_SEGMENTATION
int pred_context;
int index = mb_row * pbi->common.mb_cols + mb_col;
#endif
int_mv *const mv = & mbmi->mv;
int mb_to_left_edge;
int mb_to_right_edge;
@@ -457,46 +452,43 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
/* If required read in new segmentation data for this MB */
if (xd->update_mb_segmentation_map)
{
// 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.mb_cols)->mbmi.seg_id_predicted;
mbmi->seg_id_predicted =
vp8_read(bc,
xd->mb_segment_pred_probs[pred_context]);
if ( mbmi->seg_id_predicted )
{
#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.seg_id_predicted;
if (mb_row != 0)
pred_context +=
(mi-pbi->common.mb_cols)->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;
}
}
// Normal unpredicted coding mode
else
{
vp8_read_mb_segid(bc, &mi->mbmi, xd);
pbi->segmentation_map[index] = mbmi->segment_id;
}
index++;
#else
vp8_read_mb_segid(bc, &mi->mbmi, xd);
#endif
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;
}
}
// Normal unpredicted coding mode
else
{
vp8_read_mb_segid(bc, &mi->mbmi, xd);
pbi->segmentation_map[index] = mbmi->segment_id;
}
index++;
}
//#if CONFIG_SEGFEATURES
if ( pbi->common.mb_no_coeff_skip &&

View File

@@ -1008,11 +1008,9 @@ int vp8_decode_frame(VP8D_COMP *pbi)
// updated this frame.
xd->update_mb_segmentation_map = (unsigned char)vp8_read_bit(bc);
#if CONFIG_SEGMENTATION
// If so what method will be used.
if ( xd->update_mb_segmentation_map )
xd->temporal_update = (unsigned char)vp8_read_bit(bc);
#endif
// Is the segment data being updated
xd->update_mb_segmentation_data = (unsigned char)vp8_read_bit(bc);
@@ -1060,7 +1058,7 @@ int vp8_decode_frame(VP8D_COMP *pbi)
if (xd->update_mb_segmentation_map)
{
/* Which macro block level features are enabled */
// 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,
@@ -1076,7 +1074,7 @@ int vp8_decode_frame(VP8D_COMP *pbi)
xd->mb_segment_tree_probs[i] =
(vp8_prob)vp8_read_literal(bc, 8);
}
#if CONFIG_SEGMENTATION
// If predictive coding of segment map is enabled read the
// prediction probabilities.
if ( xd->temporal_update )
@@ -1092,7 +1090,6 @@ int vp8_decode_frame(VP8D_COMP *pbi)
(vp8_prob)vp8_read_literal(bc, 8);
}
}
#endif
}
}
@@ -1282,11 +1279,9 @@ int vp8_decode_frame(VP8D_COMP *pbi)
vpx_memcpy(&xd->pre, &pc->yv12_fb[pc->lst_fb_idx], sizeof(YV12_BUFFER_CONFIG));
vpx_memcpy(&xd->dst, &pc->yv12_fb[pc->new_fb_idx], sizeof(YV12_BUFFER_CONFIG));
#if CONFIG_SEGMENTATION
// 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));
#endif
/* set up frame new frame for intra coded blocks */
#if CONFIG_MULTITHREAD

View File

@@ -161,11 +161,10 @@ void vp8dx_remove_decompressor(VP8D_PTR ptr)
if (!pbi)
return;
#if CONFIG_SEGMENTATION
// Delete sementation map
// Delete sementation map
if (pbi->segmentation_map != 0)
vpx_free(pbi->segmentation_map);
#endif
#if CONFIG_MULTITHREAD
if (pbi->b_multithreaded_rd)

View File

@@ -89,9 +89,8 @@ typedef struct VP8Decompressor
const unsigned char *partitions[MAX_PARTITIONS];
unsigned int partition_sizes[MAX_PARTITIONS];
unsigned int num_partitions;
#if CONFIG_SEGMENTATION
unsigned char *segmentation_map;
#endif
#if CONFIG_MULTITHREAD
/* variable for threading */