Segment Feature Data Access
No change to functionality or output. Updates to the segment feature data structure now all done through functions such as set_segdata() and get_segdata() in seg_common.c. The reason for this is to make changing the structures (if needed) and debug easier. In addition it provides a single location for subsequent addition of range and validity checks. For example valid combination of mode and reference frame. Change-Id: I2e866505562db4e4cb6f17a472b25b4465f01add
This commit is contained in:
parent
2bbde25003
commit
a258bba1fb
@ -227,11 +227,11 @@ void vp8_loop_filter_frame_init(VP8_COMMON *cm,
|
||||
/* Abs value */
|
||||
if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA)
|
||||
{
|
||||
lvl_seg = xd->segment_feature_data[seg][SEG_LVL_ALT_LF];
|
||||
lvl_seg = get_segdata( xd, seg, SEG_LVL_ALT_LF );
|
||||
}
|
||||
else /* Delta Value */
|
||||
{
|
||||
lvl_seg += xd->segment_feature_data[seg][SEG_LVL_ALT_LF];
|
||||
lvl_seg += get_segdata( xd, seg, SEG_LVL_ALT_LF );;
|
||||
lvl_seg = (lvl_seg > 0) ? ((lvl_seg > 63) ? 63: lvl_seg) : 0;
|
||||
}
|
||||
}
|
||||
@ -288,7 +288,7 @@ void vp8_loop_filter_frame_init(VP8_COMMON *cm,
|
||||
void vp8_loop_filter_frame
|
||||
(
|
||||
VP8_COMMON *cm,
|
||||
MACROBLOCKD *mbd
|
||||
MACROBLOCKD *xd
|
||||
)
|
||||
{
|
||||
YV12_BUFFER_CONFIG *post = cm->frame_to_show;
|
||||
@ -308,7 +308,7 @@ void vp8_loop_filter_frame
|
||||
const MODE_INFO *mode_info_context = cm->mi;
|
||||
|
||||
/* Initialize the loop filter for this frame. */
|
||||
vp8_loop_filter_frame_init(cm, mbd, cm->filter_level);
|
||||
vp8_loop_filter_frame_init(cm, xd, cm->filter_level);
|
||||
|
||||
/* Set up the buffer pointers */
|
||||
y_ptr = post->y_buffer;
|
||||
@ -396,7 +396,7 @@ void vp8_loop_filter_frame
|
||||
void vp8_loop_filter_frame_yonly
|
||||
(
|
||||
VP8_COMMON *cm,
|
||||
MACROBLOCKD *mbd,
|
||||
MACROBLOCKD *xd,
|
||||
int default_filt_lvl
|
||||
)
|
||||
{
|
||||
@ -421,7 +421,7 @@ void vp8_loop_filter_frame_yonly
|
||||
#endif
|
||||
|
||||
/* Initialize the loop filter for this frame. */
|
||||
vp8_loop_filter_frame_init( cm, mbd, default_filt_lvl);
|
||||
vp8_loop_filter_frame_init( cm, xd, default_filt_lvl);
|
||||
|
||||
/* Set up the buffer pointers */
|
||||
y_ptr = post->y_buffer;
|
||||
@ -503,7 +503,7 @@ void vp8_loop_filter_frame_yonly
|
||||
void vp8_loop_filter_partial_frame
|
||||
(
|
||||
VP8_COMMON *cm,
|
||||
MACROBLOCKD *mbd,
|
||||
MACROBLOCKD *xd,
|
||||
int default_filt_lvl
|
||||
)
|
||||
{
|
||||
@ -520,7 +520,7 @@ void vp8_loop_filter_partial_frame
|
||||
loop_filter_info lfi;
|
||||
|
||||
int filter_level;
|
||||
int alt_flt_enabled = mbd->segmentation_enabled;
|
||||
int alt_flt_enabled = xd->segmentation_enabled;
|
||||
FRAME_TYPE frame_type = cm->frame_type;
|
||||
|
||||
const MODE_INFO *mode_info_context;
|
||||
@ -545,15 +545,15 @@ void vp8_loop_filter_partial_frame
|
||||
{
|
||||
for (i = 0; i < MAX_MB_SEGMENTS; i++)
|
||||
{ /* Abs value */
|
||||
if (mbd->mb_segement_abs_delta == SEGMENT_ABSDATA)
|
||||
if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA)
|
||||
{
|
||||
lvl_seg[i] = mbd->segment_feature_data[i][SEG_LVL_ALT_LF];
|
||||
lvl_seg[i] = get_segdata( xd, i, SEG_LVL_ALT_LF );
|
||||
}
|
||||
/* Delta Value */
|
||||
else
|
||||
{
|
||||
lvl_seg[i] = default_filt_lvl
|
||||
+ mbd->segment_feature_data[i][SEG_LVL_ALT_LF];
|
||||
lvl_seg[i] = default_filt_lvl +
|
||||
get_segdata( xd, i, SEG_LVL_ALT_LF );
|
||||
lvl_seg[i] = (lvl_seg[i] > 0) ?
|
||||
((lvl_seg[i] > 63) ? 63: lvl_seg[i]) : 0;
|
||||
}
|
||||
|
@ -96,8 +96,8 @@ static void vp8_kfread_modes(VP8D_COMP *pbi, MODE_INFO *m, int mb_row, int mb_co
|
||||
if ( pbi->common.mb_no_coeff_skip &&
|
||||
( !segfeature_active( &pbi->mb,
|
||||
m->mbmi.segment_id, SEG_LVL_EOB ) ||
|
||||
(pbi->mb.segment_feature_data[m->mbmi.segment_id]
|
||||
[SEG_LVL_EOB] != 0) ) )
|
||||
( get_segdata( &pbi->mb,
|
||||
m->mbmi.segment_id, SEG_LVL_EOB ) != 0 ) ) )
|
||||
{
|
||||
m->mbmi.mb_skip_coeff = vp8_read(bc, pbi->prob_skip_false);
|
||||
}
|
||||
@ -106,8 +106,8 @@ static void vp8_kfread_modes(VP8D_COMP *pbi, MODE_INFO *m, int mb_row, int mb_co
|
||||
//#if CONFIG_SEGFEATURES
|
||||
if ( segfeature_active( &pbi->mb,
|
||||
m->mbmi.segment_id, SEG_LVL_EOB ) &&
|
||||
(pbi->mb.segment_feature_data[m->mbmi.segment_id]
|
||||
[SEG_LVL_EOB] == 0) )
|
||||
( get_segdata( &pbi->mb,
|
||||
m->mbmi.segment_id, SEG_LVL_EOB ) == 0 ) )
|
||||
{
|
||||
m->mbmi.mb_skip_coeff = 1;
|
||||
}
|
||||
@ -278,9 +278,9 @@ static MV_REFERENCE_FRAME read_ref_frame( VP8D_COMP *pbi,
|
||||
if ( check_segref( xd, segment_id, INTRA_FRAME ) )
|
||||
ref_frame = (MV_REFERENCE_FRAME) vp8_read(bc, pbi->prob_intra);
|
||||
else
|
||||
ref_frame = 1; // note this unchanged = LAST
|
||||
ref_frame = LAST_FRAME;
|
||||
|
||||
if ( ref_frame )
|
||||
if ( ref_frame == LAST_FRAME )
|
||||
{
|
||||
// Now consider last vs (golden or alt) flag....
|
||||
// If Last is not enabled
|
||||
@ -501,8 +501,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
|
||||
if ( pbi->common.mb_no_coeff_skip &&
|
||||
( !segfeature_active( xd,
|
||||
mbmi->segment_id, SEG_LVL_EOB ) ||
|
||||
(xd->segment_feature_data[mbmi->segment_id]
|
||||
[SEG_LVL_EOB] != 0) ) )
|
||||
(get_segdata( xd, mbmi->segment_id, SEG_LVL_EOB ) != 0) ) )
|
||||
{
|
||||
// Read the macroblock coeff skip flag if this feature is in use,
|
||||
// else default to 0
|
||||
@ -513,8 +512,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
|
||||
//#if CONFIG_SEGFEATURES
|
||||
if ( segfeature_active( xd,
|
||||
mbmi->segment_id, SEG_LVL_EOB ) &&
|
||||
(xd->segment_feature_data[mbmi->segment_id]
|
||||
[SEG_LVL_EOB] == 0) )
|
||||
(get_segdata( xd, mbmi->segment_id, SEG_LVL_EOB ) == 0) )
|
||||
{
|
||||
mbmi->mb_skip_coeff = 1;
|
||||
}
|
||||
@ -541,7 +539,7 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
|
||||
if ( segfeature_active( xd, mbmi->segment_id, SEG_LVL_MODE ) )
|
||||
{
|
||||
mbmi->mode =
|
||||
xd->segment_feature_data[mbmi->segment_id][SEG_LVL_MODE];
|
||||
get_segdata( xd, mbmi->segment_id, SEG_LVL_MODE );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -85,13 +85,13 @@ void mb_init_dequantizer(VP8D_COMP *pbi, MACROBLOCKD *xd)
|
||||
{
|
||||
/* Abs Value */
|
||||
if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA)
|
||||
QIndex = xd->segment_feature_data[segment_id][SEG_LVL_ALT_Q];
|
||||
QIndex = get_segdata( xd, segment_id, SEG_LVL_ALT_Q );
|
||||
|
||||
/* Delta Value */
|
||||
else
|
||||
{
|
||||
QIndex = pc->base_qindex +
|
||||
xd->segment_feature_data[segment_id][SEG_LVL_ALT_Q];
|
||||
get_segdata( xd, segment_id, SEG_LVL_ALT_Q );
|
||||
QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ) : 0; /* Clamp to valid range */
|
||||
}
|
||||
}
|
||||
@ -804,10 +804,7 @@ static void init_frame(VP8D_COMP *pbi)
|
||||
// Reset the segment feature data to the default stats:
|
||||
// Features disabled, 0, with delta coding (Default state).
|
||||
//#if CONFIG_SEGFEATURES
|
||||
vpx_memset(xd->segment_feature_mask, 0,
|
||||
sizeof(xd->segment_feature_mask));
|
||||
vpx_memset(xd->segment_feature_data, 0,
|
||||
sizeof(xd->segment_feature_data));
|
||||
clearall_segfeatures( xd );
|
||||
|
||||
xd->mb_segement_abs_delta = SEGMENT_DELTADATA;
|
||||
|
||||
|
@ -656,7 +656,7 @@ int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *xd)
|
||||
|
||||
if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
|
||||
{
|
||||
seg_eob = xd->segment_feature_data[segment_id][SEG_LVL_EOB];
|
||||
seg_eob = get_segdata( xd, segment_id, SEG_LVL_EOB );
|
||||
}
|
||||
|
||||
type = 3;
|
||||
|
@ -887,7 +887,7 @@ static void encode_ref_frame( vp8_writer *const w,
|
||||
segment_id,
|
||||
SEG_LVL_REF_FRAME );
|
||||
|
||||
// No segment features or segment reference frame featuure is disabled
|
||||
// No segment features or segment reference frame feature is disabled
|
||||
if ( !seg_ref_active )
|
||||
{
|
||||
if (rf == INTRA_FRAME)
|
||||
@ -1108,7 +1108,7 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
|
||||
//#if CONFIG_SEGFEATURES
|
||||
if ( pc->mb_no_coeff_skip &&
|
||||
( !segfeature_active( xd, segment_id, SEG_LVL_EOB ) ||
|
||||
(xd->segment_feature_data[segment_id][SEG_LVL_EOB] != 0) ) )
|
||||
( get_segdata( xd, segment_id, SEG_LVL_EOB ) != 0 ) ) )
|
||||
{
|
||||
vp8_encode_bool(w, mi->mb_skip_coeff, prob_skip_false);
|
||||
}
|
||||
@ -1320,7 +1320,7 @@ static void write_kfmodes(VP8_COMP *cpi)
|
||||
//#if CONFIG_SEGFEATURES
|
||||
if ( c->mb_no_coeff_skip &&
|
||||
( !segfeature_active( xd, segment_id, SEG_LVL_EOB ) ||
|
||||
(xd->segment_feature_data[segment_id][SEG_LVL_EOB] != 0) ) )
|
||||
(get_segdata( xd, segment_id, SEG_LVL_EOB ) != 0) ) )
|
||||
{
|
||||
vp8_encode_bool(bc, m->mbmi.mb_skip_coeff, prob_skip_false);
|
||||
}
|
||||
|
@ -336,10 +336,9 @@ static void setup_features(VP8_COMP *cpi)
|
||||
xd->update_mb_segmentation_map = 0;
|
||||
xd->update_mb_segmentation_data = 0;
|
||||
vpx_memset(xd->mb_segment_tree_probs, 255, sizeof(xd->mb_segment_tree_probs));
|
||||
vpx_memset(xd->segment_feature_data, 0, sizeof(xd->segment_feature_data));
|
||||
|
||||
//#if CONFIG_SEGFEATURES
|
||||
vpx_memset(xd->segment_feature_mask, 0, sizeof(xd->segment_feature_mask));
|
||||
clearall_segfeatures( xd );
|
||||
|
||||
xd->mode_ref_lf_delta_enabled = 0;
|
||||
xd->mode_ref_lf_delta_update = 0;
|
||||
@ -529,9 +528,8 @@ static void init_seg_features(VP8_COMP *cpi)
|
||||
xd->update_mb_segmentation_map = 1;
|
||||
xd->update_mb_segmentation_data = 1;
|
||||
|
||||
xd->segment_feature_data[1][SEG_LVL_ALT_Q] =
|
||||
-(2+(cpi->ni_av_qi >> 3));
|
||||
xd->segment_feature_data[1][SEG_LVL_ALT_LF] = -2;
|
||||
set_segdata( xd, 1, SEG_LVL_ALT_Q, -(2+(cpi->ni_av_qi >> 3)) );
|
||||
set_segdata( xd, 1, SEG_LVL_ALT_LF, -2 );
|
||||
|
||||
enable_segfeature(xd, 1, SEG_LVL_ALT_Q);
|
||||
enable_segfeature(xd, 1, SEG_LVL_ALT_LF);
|
||||
@ -554,20 +552,21 @@ static void init_seg_features(VP8_COMP *cpi)
|
||||
xd->update_mb_segmentation_data = 1;
|
||||
xd->mb_segement_abs_delta = SEGMENT_DELTADATA;
|
||||
|
||||
xd->segment_feature_data[1][SEG_LVL_ALT_Q] = 5;
|
||||
xd->segment_feature_data[1][SEG_LVL_ALT_LF] = -2;
|
||||
|
||||
set_segdata( xd, 1, SEG_LVL_ALT_Q, 5 );
|
||||
enable_segfeature(xd, 1, SEG_LVL_ALT_Q);
|
||||
|
||||
set_segdata( xd, 1, SEG_LVL_ALT_LF, -2 );
|
||||
enable_segfeature(xd, 1, SEG_LVL_ALT_LF);
|
||||
|
||||
if ( high_q )
|
||||
{
|
||||
set_segref(xd, 1, ALTREF_FRAME);
|
||||
xd->segment_feature_data[1][SEG_LVL_MODE] = ZEROMV;
|
||||
xd->segment_feature_data[1][SEG_LVL_EOB] = 0;
|
||||
|
||||
enable_segfeature(xd, 1, SEG_LVL_REF_FRAME);
|
||||
|
||||
set_segdata( xd, 1, SEG_LVL_MODE, ZEROMV );
|
||||
enable_segfeature(xd, 1, SEG_LVL_MODE);
|
||||
|
||||
set_segdata( xd, 1, SEG_LVL_EOB, 0 );
|
||||
enable_segfeature(xd, 1, SEG_LVL_EOB);
|
||||
}
|
||||
}
|
||||
@ -601,16 +600,16 @@ static void init_seg_features(VP8_COMP *cpi)
|
||||
set_segref(xd, 0, ALTREF_FRAME);
|
||||
clear_segref(xd, 1);
|
||||
set_segref(xd, 1, ALTREF_FRAME);
|
||||
xd->segment_feature_data[0][SEG_LVL_MODE] = ZEROMV;
|
||||
xd->segment_feature_data[1][SEG_LVL_MODE] = ZEROMV;
|
||||
set_segdata( xd, 0, SEG_LVL_MODE, ZEROMV );
|
||||
set_segdata( xd, 1, SEG_LVL_MODE, ZEROMV );
|
||||
|
||||
// Skip all MBs if high Q
|
||||
if ( high_q )
|
||||
{
|
||||
enable_segfeature(xd, 0, SEG_LVL_EOB);
|
||||
enable_segfeature(xd, 1, SEG_LVL_EOB);
|
||||
xd->segment_feature_data[0][SEG_LVL_EOB] = 0;
|
||||
xd->segment_feature_data[1][SEG_LVL_EOB] = 0;
|
||||
set_segdata( xd, 0, SEG_LVL_EOB, 0 );
|
||||
set_segdata( xd, 1, SEG_LVL_EOB, 0 );
|
||||
}
|
||||
|
||||
// Enable data udpate
|
||||
|
@ -536,7 +536,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
|
||||
}
|
||||
if ( segfeature_active( xd, segment_id, SEG_LVL_MODE ) &&
|
||||
( this_mode !=
|
||||
xd->segment_feature_data[segment_id][SEG_LVL_MODE]))
|
||||
get_segdata( xd, segment_id, SEG_LVL_MODE ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -1179,13 +1179,13 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
|
||||
{
|
||||
// Abs Value
|
||||
if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA)
|
||||
QIndex = xd->segment_feature_data[segment_id][SEG_LVL_ALT_Q];
|
||||
QIndex = get_segdata( xd, segment_id, SEG_LVL_ALT_Q );
|
||||
|
||||
// Delta Value
|
||||
else
|
||||
{
|
||||
QIndex = cpi->common.base_qindex +
|
||||
xd->segment_feature_data[segment_id][SEG_LVL_ALT_Q];
|
||||
get_segdata( xd, segment_id, SEG_LVL_ALT_Q );
|
||||
|
||||
// Clamp to valid range
|
||||
QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ) : 0;
|
||||
@ -1215,7 +1215,7 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
|
||||
if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
|
||||
{
|
||||
x->block[i].eob_max_offset =
|
||||
xd->segment_feature_data[segment_id][SEG_LVL_EOB];
|
||||
get_segdata( xd, segment_id, SEG_LVL_EOB );
|
||||
}
|
||||
else
|
||||
x->block[i].eob_max_offset = 16;
|
||||
@ -1242,7 +1242,7 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
|
||||
if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
|
||||
{
|
||||
x->block[i].eob_max_offset =
|
||||
xd->segment_feature_data[segment_id][SEG_LVL_EOB];
|
||||
get_segdata( xd, segment_id, SEG_LVL_EOB );
|
||||
}
|
||||
else
|
||||
x->block[i].eob_max_offset = 16;
|
||||
@ -1269,7 +1269,7 @@ void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
|
||||
if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
|
||||
{
|
||||
x->block[24].eob_max_offset =
|
||||
xd->segment_feature_data[segment_id][SEG_LVL_EOB];
|
||||
get_segdata( xd, segment_id, SEG_LVL_EOB );
|
||||
}
|
||||
else
|
||||
x->block[24].eob_max_offset = 16;
|
||||
|
@ -2138,8 +2138,8 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
|
||||
continue;
|
||||
}
|
||||
if ( segfeature_active( xd, segment_id, SEG_LVL_MODE ) &&
|
||||
( this_mode !=
|
||||
xd->segment_feature_data[segment_id][SEG_LVL_MODE]))
|
||||
( this_mode !=
|
||||
get_segdata( xd, segment_id, SEG_LVL_MODE ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ static void tokenize2nd_order_b
|
||||
|
||||
if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
|
||||
{
|
||||
seg_eob = xd->segment_feature_data[segment_id][SEG_LVL_EOB];
|
||||
seg_eob = get_segdata( xd, segment_id, SEG_LVL_EOB );
|
||||
}
|
||||
|
||||
b = xd->block + 24;
|
||||
@ -326,7 +326,7 @@ static void tokenize1st_order_b
|
||||
|
||||
if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
|
||||
{
|
||||
seg_eob = xd->segment_feature_data[segment_id][SEG_LVL_EOB];
|
||||
seg_eob = get_segdata( xd, segment_id, SEG_LVL_EOB );
|
||||
}
|
||||
|
||||
b = xd->block;
|
||||
@ -487,7 +487,7 @@ void vp8_tokenize_mb(VP8_COMP *cpi, MACROBLOCKD *x, TOKENEXTRA **t)
|
||||
int segment_id = x->mode_info_context->mbmi.segment_id;
|
||||
|
||||
if ( !segfeature_active( x, segment_id, SEG_LVL_EOB ) ||
|
||||
(x->segment_feature_data[segment_id][SEG_LVL_EOB] != 0) )
|
||||
( get_segdata( x, segment_id, SEG_LVL_EOB ) != 0) )
|
||||
{
|
||||
skip_inc = 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user