ref: d91e9f4e369020d301804f39acc400eece894590
parent: 4144fee9e9c077c044c82392f6b40dd150ac29ad
parent: 741537f3cec0337032fc4542a69ad13d069c670c
author: Dmitry Kovalev <[email protected]>
date: Thu Aug 1 19:17:17 EDT 2013
Merge "Cleanup: replacing xd->seg with seg, and xd->lf with lf."
--- a/vp9/common/vp9_entropymode.c
+++ b/vp9/common/vp9_entropymode.c
@@ -462,22 +462,24 @@
counts->mbskip[i]);
}
-static void set_default_lf_deltas(MACROBLOCKD *xd) {
- xd->lf.mode_ref_delta_enabled = 1;
- xd->lf.mode_ref_delta_update = 1;
+static void set_default_lf_deltas(struct loopfilter *lf) {
+ lf->mode_ref_delta_enabled = 1;
+ lf->mode_ref_delta_update = 1;
- xd->lf.ref_deltas[INTRA_FRAME] = 1;
- xd->lf.ref_deltas[LAST_FRAME] = 0;
- xd->lf.ref_deltas[GOLDEN_FRAME] = -1;
- xd->lf.ref_deltas[ALTREF_FRAME] = -1;
+ lf->ref_deltas[INTRA_FRAME] = 1;
+ lf->ref_deltas[LAST_FRAME] = 0;
+ lf->ref_deltas[GOLDEN_FRAME] = -1;
+ lf->ref_deltas[ALTREF_FRAME] = -1;
- xd->lf.mode_deltas[0] = 0;
- xd->lf.mode_deltas[1] = 0;
+ lf->mode_deltas[0] = 0;
+ lf->mode_deltas[1] = 0;
}
void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
// Reset the segment feature data to the default stats:
// Features disabled, 0, with delta coding (Default state).
+ struct loopfilter *const lf = &xd->lf;
+
int i;
vp9_clearall_segfeatures(&xd->seg);
xd->seg.abs_delta = SEGMENT_DELTADATA;
@@ -485,12 +487,12 @@
vpx_memset(cm->last_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
// Reset the mode ref deltas for loop filter
- vp9_zero(xd->lf.last_ref_deltas);
- vp9_zero(xd->lf.last_mode_deltas);
- set_default_lf_deltas(xd);
+ vp9_zero(lf->last_ref_deltas);
+ vp9_zero(lf->last_mode_deltas);
+ set_default_lf_deltas(lf);
// To force update of the sharpness
- xd->lf.last_sharpness_level = -1;
+ lf->last_sharpness_level = -1;
vp9_default_coef_probs(cm);
vp9_init_mbmode_probs(cm);
--- a/vp9/common/vp9_loopfilter.c
+++ b/vp9/common/vp9_loopfilter.c
@@ -73,13 +73,14 @@
void vp9_loop_filter_frame_init(VP9_COMMON *const cm, MACROBLOCKD *const xd,
int default_filt_lvl) {
- int seg;
+ int seg_id;
// n_shift is the a multiplier for lf_deltas
// the multiplier is 1 for when filter_lvl is between 0 and 31;
// 2 when filter_lvl is between 32 and 63
const int n_shift = default_filt_lvl >> 5;
loop_filter_info_n *const lfi = &cm->lf_info;
- struct loopfilter *lf = &xd->lf;
+ struct loopfilter *const lf = &xd->lf;
+ struct segmentation *const seg = &xd->seg;
// update limits if sharpness has changed
if (lf->last_sharpness_level != lf->sharpness_level) {
@@ -87,13 +88,13 @@
lf->last_sharpness_level = lf->sharpness_level;
}
- for (seg = 0; seg < MAX_SEGMENTS; seg++) {
+ for (seg_id = 0; seg_id < MAX_SEGMENTS; seg_id++) {
int lvl_seg = default_filt_lvl, ref, mode, intra_lvl;
// Set the baseline filter values for each segment
- if (vp9_segfeature_active(&xd->seg, seg, SEG_LVL_ALT_LF)) {
- const int data = vp9_get_segdata(&xd->seg, seg, SEG_LVL_ALT_LF);
- lvl_seg = xd->seg.abs_delta == SEGMENT_ABSDATA
+ if (vp9_segfeature_active(&xd->seg, seg_id, SEG_LVL_ALT_LF)) {
+ const int data = vp9_get_segdata(seg, seg_id, SEG_LVL_ALT_LF);
+ lvl_seg = seg->abs_delta == SEGMENT_ABSDATA
? data
: clamp(default_filt_lvl + data, 0, MAX_LOOP_FILTER);
}
@@ -101,18 +102,18 @@
if (!lf->mode_ref_delta_enabled) {
// we could get rid of this if we assume that deltas are set to
// zero when not in use; encoder always uses deltas
- vpx_memset(lfi->lvl[seg][0], lvl_seg, 4 * 4);
+ vpx_memset(lfi->lvl[seg_id][0], lvl_seg, 4 * 4);
continue;
}
intra_lvl = lvl_seg + (lf->ref_deltas[INTRA_FRAME] << n_shift);
- lfi->lvl[seg][INTRA_FRAME][0] = clamp(intra_lvl, 0, MAX_LOOP_FILTER);
+ lfi->lvl[seg_id][INTRA_FRAME][0] = clamp(intra_lvl, 0, MAX_LOOP_FILTER);
for (ref = LAST_FRAME; ref < MAX_REF_FRAMES; ++ref)
for (mode = 0; mode < MAX_MODE_LF_DELTAS; ++mode) {
const int inter_lvl = lvl_seg + (lf->ref_deltas[ref] << n_shift)
+ (lf->mode_deltas[mode] << n_shift);
- lfi->lvl[seg][ref][mode] = clamp(inter_lvl, 0, MAX_LOOP_FILTER);
+ lfi->lvl[seg_id][ref][mode] = clamp(inter_lvl, 0, MAX_LOOP_FILTER);
}
}
}
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -481,6 +481,7 @@
const int mb_row = mi_row >> 1;
const int mb_col = mi_col >> 1;
const int idx_map = mb_row * cm->mb_cols + mb_col;
+ const struct segmentation *const seg = &xd->seg;
int i;
// entropy context structures
@@ -530,16 +531,16 @@
x->rdmult = cpi->RDMULT;
/* segment ID */
- if (xd->seg.enabled) {
- uint8_t *map = xd->seg.update_map ? cpi->segmentation_map
- : cm->last_frame_seg_map;
+ if (seg->enabled) {
+ uint8_t *map = seg->update_map ? cpi->segmentation_map
+ : cm->last_frame_seg_map;
mbmi->segment_id = vp9_get_segment_id(cm, map, bsize, mi_row, mi_col);
vp9_mb_init_quantizer(cpi, x);
- if (xd->seg.enabled && cpi->seg0_cnt > 0
- && !vp9_segfeature_active(&xd->seg, 0, SEG_LVL_REF_FRAME)
- && vp9_segfeature_active(&xd->seg, 1, SEG_LVL_REF_FRAME)) {
+ if (seg->enabled && cpi->seg0_cnt > 0
+ && !vp9_segfeature_active(seg, 0, SEG_LVL_REF_FRAME)
+ && vp9_segfeature_active(seg, 1, SEG_LVL_REF_FRAME)) {
cpi->seg0_progress = (cpi->seg0_idx << 16) / cpi->seg0_cnt;
} else {
const int y = mb_row & ~3;
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -243,16 +243,17 @@
static void setup_features(VP9_COMP *cpi) {
MACROBLOCKD *xd = &cpi->mb.e_mbd;
- struct loopfilter *lf = &xd->lf;
+ struct loopfilter *const lf = &xd->lf;
+ struct segmentation *const seg = &xd->seg;
// Set up default state for MB feature flags
- xd->seg.enabled = 0;
+ seg->enabled = 0;
- xd->seg.update_map = 0;
- xd->seg.update_data = 0;
- vpx_memset(xd->seg.tree_probs, 255, sizeof(xd->seg.tree_probs));
+ seg->update_map = 0;
+ seg->update_data = 0;
+ vpx_memset(seg->tree_probs, 255, sizeof(seg->tree_probs));
- vp9_clearall_segfeatures(&xd->seg);
+ vp9_clearall_segfeatures(seg);
lf->mode_ref_delta_enabled = 0;
lf->mode_ref_delta_update = 0;
@@ -324,6 +325,7 @@
static void configure_static_seg_features(VP9_COMP *cpi) {
VP9_COMMON *cm = &cpi->common;
MACROBLOCKD *xd = &cpi->mb.e_mbd;
+ struct segmentation *seg = &xd->seg;
int high_q = (int)(cpi->avg_q > 48.0);
int qi_delta;
@@ -332,8 +334,8 @@
if (cm->frame_type == KEY_FRAME) {
// Clear down the global segmentation map
vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
- xd->seg.update_map = 0;
- xd->seg.update_data = 0;
+ seg->update_map = 0;
+ seg->update_data = 0;
cpi->static_mb_pct = 0;
// Disable segmentation
@@ -340,18 +342,18 @@
vp9_disable_segmentation((VP9_PTR)cpi);
// Clear down the segment features.
- vp9_clearall_segfeatures(&xd->seg);
+ vp9_clearall_segfeatures(seg);
} else if (cpi->refresh_alt_ref_frame) {
// If this is an alt ref frame
// Clear down the global segmentation map
vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
- xd->seg.update_map = 0;
- xd->seg.update_data = 0;
+ seg->update_map = 0;
+ seg->update_data = 0;
cpi->static_mb_pct = 0;
// Disable segmentation and individual segment features by default
vp9_disable_segmentation((VP9_PTR)cpi);
- vp9_clearall_segfeatures(&xd->seg);
+ vp9_clearall_segfeatures(seg);
// Scan frames from current to arf frame.
// This function re-enables segmentation if appropriate.
@@ -359,22 +361,22 @@
// If segmentation was enabled set those features needed for the
// arf itself.
- if (xd->seg.enabled) {
- xd->seg.update_map = 1;
- xd->seg.update_data = 1;
+ if (seg->enabled) {
+ seg->update_map = 1;
+ seg->update_data = 1;
qi_delta = compute_qdelta(cpi, cpi->avg_q, (cpi->avg_q * 0.875));
- vp9_set_segdata(&xd->seg, 1, SEG_LVL_ALT_Q, (qi_delta - 2));
- vp9_set_segdata(&xd->seg, 1, SEG_LVL_ALT_LF, -2);
+ vp9_set_segdata(seg, 1, SEG_LVL_ALT_Q, (qi_delta - 2));
+ vp9_set_segdata(seg, 1, SEG_LVL_ALT_LF, -2);
- vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_ALT_Q);
- vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_ALT_LF);
+ vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_Q);
+ vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_LF);
// Where relevant assume segment data is delta data
- xd->seg.abs_delta = SEGMENT_DELTADATA;
+ seg->abs_delta = SEGMENT_DELTADATA;
}
- } else if (xd->seg.enabled) {
+ } else if (seg->enabled) {
// All other frames if segmentation has been enabled
// First normal frame in a valid gf or alt ref group
@@ -381,23 +383,23 @@
if (cpi->frames_since_golden == 0) {
// Set up segment features for normal frames in an arf group
if (cpi->source_alt_ref_active) {
- xd->seg.update_map = 0;
- xd->seg.update_data = 1;
- xd->seg.abs_delta = SEGMENT_DELTADATA;
+ seg->update_map = 0;
+ seg->update_data = 1;
+ seg->abs_delta = SEGMENT_DELTADATA;
qi_delta = compute_qdelta(cpi, cpi->avg_q,
(cpi->avg_q * 1.125));
- vp9_set_segdata(&xd->seg, 1, SEG_LVL_ALT_Q, (qi_delta + 2));
- vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_ALT_Q);
+ vp9_set_segdata(seg, 1, SEG_LVL_ALT_Q, (qi_delta + 2));
+ vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_Q);
- vp9_set_segdata(&xd->seg, 1, SEG_LVL_ALT_LF, -2);
- vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_ALT_LF);
+ vp9_set_segdata(seg, 1, SEG_LVL_ALT_LF, -2);
+ vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_LF);
// Segment coding disabled for compred testing
if (high_q || (cpi->static_mb_pct == 100)) {
- vp9_set_segdata(&xd->seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME);
- vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_REF_FRAME);
- vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_SKIP);
+ vp9_set_segdata(seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME);
+ vp9_enable_segfeature(seg, 1, SEG_LVL_REF_FRAME);
+ vp9_enable_segfeature(seg, 1, SEG_LVL_SKIP);
}
} else {
// Disable segmentation and clear down features if alt ref
@@ -407,10 +409,10 @@
vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
- xd->seg.update_map = 0;
- xd->seg.update_data = 0;
+ seg->update_map = 0;
+ seg->update_data = 0;
- vp9_clearall_segfeatures(&xd->seg);
+ vp9_clearall_segfeatures(seg);
}
} else if (cpi->is_src_frame_alt_ref) {
// Special case where we are coding over the top of a previous
@@ -418,28 +420,28 @@
// Segment coding disabled for compred testing
// Enable ref frame features for segment 0 as well
- vp9_enable_segfeature(&xd->seg, 0, SEG_LVL_REF_FRAME);
- vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_REF_FRAME);
+ vp9_enable_segfeature(seg, 0, SEG_LVL_REF_FRAME);
+ vp9_enable_segfeature(seg, 1, SEG_LVL_REF_FRAME);
// All mbs should use ALTREF_FRAME
- vp9_clear_segdata(&xd->seg, 0, SEG_LVL_REF_FRAME);
- vp9_set_segdata(&xd->seg, 0, SEG_LVL_REF_FRAME, ALTREF_FRAME);
- vp9_clear_segdata(&xd->seg, 1, SEG_LVL_REF_FRAME);
- vp9_set_segdata(&xd->seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME);
+ vp9_clear_segdata(seg, 0, SEG_LVL_REF_FRAME);
+ vp9_set_segdata(seg, 0, SEG_LVL_REF_FRAME, ALTREF_FRAME);
+ vp9_clear_segdata(seg, 1, SEG_LVL_REF_FRAME);
+ vp9_set_segdata(seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME);
// Skip all MBs if high Q (0,0 mv and skip coeffs)
if (high_q) {
- vp9_enable_segfeature(&xd->seg, 0, SEG_LVL_SKIP);
- vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_SKIP);
+ vp9_enable_segfeature(seg, 0, SEG_LVL_SKIP);
+ vp9_enable_segfeature(seg, 1, SEG_LVL_SKIP);
}
// Enable data update
- xd->seg.update_data = 1;
+ seg->update_data = 1;
} else {
// All other frames.
// No updates.. leave things as they are.
- xd->seg.update_map = 0;
- xd->seg.update_data = 0;
+ seg->update_map = 0;
+ seg->update_data = 0;
}
}
}
@@ -2415,8 +2417,9 @@
static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) {
MACROBLOCKD *xd = &cpi->mb.e_mbd;
+ struct loopfilter *lf = &xd->lf;
if (xd->lossless) {
- xd->lf.filter_level = 0;
+ lf->filter_level = 0;
} else {
struct vpx_usec_timer timer;
@@ -2430,9 +2433,9 @@
cpi->time_pick_lpf += vpx_usec_timer_elapsed(&timer);
}
- if (xd->lf.filter_level > 0) {
- vp9_set_alt_lf_level(cpi, xd->lf.filter_level);
- vp9_loop_filter_frame(cm, xd, xd->lf.filter_level, 0);
+ if (lf->filter_level > 0) {
+ vp9_set_alt_lf_level(cpi, lf->filter_level);
+ vp9_loop_filter_frame(cm, xd, lf->filter_level, 0);
}
vp9_extend_frame_inner_borders(cm->frame_to_show,
@@ -2522,6 +2525,7 @@
SPEED_FEATURES *sf = &cpi->sf;
unsigned int max_mv_def = MIN(cpi->common.width, cpi->common.height);
+ struct segmentation *seg = &xd->seg;
#if RESET_FOREACH_FILTER
int q_low0;
int q_high0;
@@ -2621,9 +2625,9 @@
setup_features(cpi);
// If segmentation is enabled force a map update for key frames
- if (xd->seg.enabled) {
- xd->seg.update_map = 1;
- xd->seg.update_data = 1;
+ if (seg->enabled) {
+ seg->update_map = 1;
+ seg->update_data = 1;
}
// The alternate reference frame cannot be active for a key frame
@@ -4002,7 +4006,7 @@
unsigned int threshold[MAX_SEGMENTS]) {
VP9_COMP *cpi = (VP9_COMP *) comp;
signed char feature_data[SEG_LVL_MAX][MAX_SEGMENTS];
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
+ struct segmentation *seg = &cpi->mb.e_mbd.seg;
int i;
if (cpi->common.mb_rows != rows || cpi->common.mb_cols != cols)
@@ -4029,14 +4033,14 @@
// Enable the loop and quant changes in the feature mask
for (i = 0; i < MAX_SEGMENTS; i++) {
if (delta_q[i])
- vp9_enable_segfeature(&xd->seg, i, SEG_LVL_ALT_Q);
+ vp9_enable_segfeature(seg, i, SEG_LVL_ALT_Q);
else
- vp9_disable_segfeature(&xd->seg, i, SEG_LVL_ALT_Q);
+ vp9_disable_segfeature(seg, i, SEG_LVL_ALT_Q);
if (delta_lf[i])
- vp9_enable_segfeature(&xd->seg, i, SEG_LVL_ALT_LF);
+ vp9_enable_segfeature(seg, i, SEG_LVL_ALT_LF);
else
- vp9_disable_segfeature(&xd->seg, i, SEG_LVL_ALT_LF);
+ vp9_disable_segfeature(seg, i, SEG_LVL_ALT_LF);
}
// Initialise the feature data structure
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -3189,6 +3189,7 @@
VP9_COMMON *cm = &cpi->common;
MACROBLOCKD *xd = &x->e_mbd;
MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
+ const struct segmentation *seg = &xd->seg;
const BLOCK_SIZE_TYPE block_size = get_plane_block_size(bsize, &xd->plane[0]);
MB_PREDICTION_MODE this_mode;
MV_REFERENCE_FRAME ref_frame, second_ref_frame;
@@ -3354,7 +3355,7 @@
// Do not allow compound prediction if the segment level reference
// frame feature is in use as in this case there can only be one reference.
if ((second_ref_frame > INTRA_FRAME) &&
- vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_REF_FRAME))
+ vp9_segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME))
continue;
// Skip some checking based on small partitions' result.
@@ -3453,19 +3454,19 @@
// If the segment reference frame feature is enabled....
// then do nothing if the current ref frame is not allowed..
- if (vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_REF_FRAME) &&
- vp9_get_segdata(&xd->seg, segment_id, SEG_LVL_REF_FRAME) !=
+ if (vp9_segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME) &&
+ vp9_get_segdata(seg, segment_id, SEG_LVL_REF_FRAME) !=
(int)ref_frame) {
continue;
// If the segment skip feature is enabled....
// then do nothing if the current mode is not allowed..
- } else if (vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_SKIP) &&
+ } else if (vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) &&
(this_mode != ZEROMV && ref_frame != INTRA_FRAME)) {
continue;
// Disable this drop out case if the ref frame
// segment level feature is enabled for this segment. This is to
// prevent the possibility that we end up unable to pick any mode.
- } else if (!vp9_segfeature_active(&xd->seg, segment_id,
+ } else if (!vp9_segfeature_active(seg, segment_id,
SEG_LVL_REF_FRAME)) {
// Only consider ZEROMV/ALTREF_FRAME for alt ref frame,
// unless ARNR filtering is enabled in which case we want
@@ -3760,7 +3761,7 @@
// necessary adjustment for rate. Ignore if skip is coded at
// segment level as the cost wont have been added in.
// Is Mb level skip allowed (i.e. not coded at segment level).
- const int mb_skip_allowed = !vp9_segfeature_active(&xd->seg, segment_id,
+ const int mb_skip_allowed = !vp9_segfeature_active(seg, segment_id,
SEG_LVL_SKIP);
if (skippable && bsize >= BLOCK_SIZE_SB8X8) {