ref: b7616e387e99edc52d70b5f504090ba50c7995fc
parent: 4d73416099874351bd5199d2686862c00cece855
author: Dmitry Kovalev <[email protected]>
date: Wed Aug 14 07:20:33 EDT 2013
Moving segmentation struct from MACROBLOCKD to VP9_COMMON. VP9_COMMON is the right place to segmentatation struct because it has global segmentation parameters, not something specific to macroblock processing. Change-Id: Ib9ada0c06c253996eb3b5f6cccf6a323fbbba708
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -212,8 +212,6 @@
int left_available;
int right_available;
- struct segmentation seg;
-
// partition contexts
PARTITION_CONTEXT *above_seg_context;
PARTITION_CONTEXT *left_seg_context;
--- a/vp9/common/vp9_entropymode.c
+++ b/vp9/common/vp9_entropymode.c
@@ -470,14 +470,14 @@
lf->mode_deltas[1] = 0;
}
-void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
+void vp9_setup_past_independence(VP9_COMMON *cm) {
// Reset the segment feature data to the default stats:
// Features disabled, 0, with delta coding (Default state).
struct loopfilter *const lf = &cm->lf;
int i;
- vp9_clearall_segfeatures(&xd->seg);
- xd->seg.abs_delta = SEGMENT_DELTADATA;
+ vp9_clearall_segfeatures(&cm->seg);
+ cm->seg.abs_delta = SEGMENT_DELTADATA;
if (cm->last_frame_seg_map)
vpx_memset(cm->last_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
--- a/vp9/common/vp9_entropymode.h
+++ b/vp9/common/vp9_entropymode.h
@@ -56,7 +56,7 @@
void vp9_entropy_mode_init();
-void vp9_setup_past_independence(struct VP9Common *cm, MACROBLOCKD *xd);
+void vp9_setup_past_independence(struct VP9Common *cm);
void vp9_init_mbmode_probs(struct VP9Common *x);
--- a/vp9/common/vp9_loopfilter.c
+++ b/vp9/common/vp9_loopfilter.c
@@ -78,8 +78,7 @@
vpx_memset(lfi->hev_thr[i], i, SIMD_WIDTH);
}
-void vp9_loop_filter_frame_init(VP9_COMMON *const cm, MACROBLOCKD *const xd,
- int default_filt_lvl) {
+void vp9_loop_filter_frame_init(VP9_COMMON *const cm, int default_filt_lvl) {
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;
@@ -87,7 +86,7 @@
const int n_shift = default_filt_lvl >> 5;
loop_filter_info_n *const lfi = &cm->lf_info;
struct loopfilter *const lf = &cm->lf;
- struct segmentation *const seg = &xd->seg;
+ struct segmentation *const seg = &cm->seg;
// update limits if sharpness has changed
if (lf->last_sharpness_level != lf->sharpness_level) {
@@ -99,7 +98,7 @@
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_id, SEG_LVL_ALT_LF)) {
+ if (vp9_segfeature_active(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
@@ -391,7 +390,7 @@
mi_rows_to_filter = MAX(cm->mi_rows / 8, 8);
}
end_mi_row = start_mi_row + mi_rows_to_filter;
- vp9_loop_filter_frame_init(cm, xd, frame_filter_level);
+ vp9_loop_filter_frame_init(cm, frame_filter_level);
vp9_loop_filter_rows(cm->frame_to_show, cm, xd,
start_mi_row, end_mi_row,
y_only);
--- a/vp9/common/vp9_loopfilter.h
+++ b/vp9/common/vp9_loopfilter.h
@@ -65,9 +65,7 @@
// Update the loop filter for the current frame.
// This should be called before vp9_loop_filter_rows(), vp9_loop_filter_frame()
// calls this function directly.
-void vp9_loop_filter_frame_init(struct VP9Common *const cm,
- struct macroblockd *const xd,
- int default_filt_lvl);
+void vp9_loop_filter_frame_init(struct VP9Common *cm, int default_filt_lvl);
void vp9_loop_filter_frame(struct VP9Common *cm,
struct macroblockd *mbd,
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -177,6 +177,7 @@
int ref_frame_sign_bias[MAX_REF_FRAMES]; /* Two state 0, 1 */
struct loopfilter lf;
+ struct segmentation seg;
/* Y,U,V */
ENTROPY_CONTEXT *above_context[MAX_MB_PLANE];
--- a/vp9/common/vp9_pred_common.h
+++ b/vp9/common/vp9_pred_common.h
@@ -27,8 +27,9 @@
(xd->left_available ? left_mbmi->seg_id_predicted : 0);
}
-static INLINE vp9_prob vp9_get_pred_prob_seg_id(const MACROBLOCKD *xd) {
- return xd->seg.pred_probs[vp9_get_pred_context_seg_id(xd)];
+static INLINE vp9_prob vp9_get_pred_prob_seg_id(struct segmentation *seg,
+ const MACROBLOCKD *xd) {
+ return seg->pred_probs[vp9_get_pred_context_seg_id(xd)];
}
void vp9_set_pred_flag_seg_id(VP9_COMMON *cm, BLOCK_SIZE_TYPE bsize,
--- a/vp9/common/vp9_quant_common.c
+++ b/vp9/common/vp9_quant_common.c
@@ -130,12 +130,12 @@
}
-int vp9_get_qindex(MACROBLOCKD *xd, int segment_id, int base_qindex) {
- if (vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_ALT_Q)) {
- const int data = vp9_get_segdata(&xd->seg, segment_id, SEG_LVL_ALT_Q);
- return xd->seg.abs_delta == SEGMENT_ABSDATA ?
- data : // Abs value
- clamp(base_qindex + data, 0, MAXQ); // Delta value
+int vp9_get_qindex(struct segmentation *seg, int segment_id, int base_qindex) {
+ if (vp9_segfeature_active(seg, segment_id, SEG_LVL_ALT_Q)) {
+ const int data = vp9_get_segdata(seg, segment_id, SEG_LVL_ALT_Q);
+ return seg->abs_delta == SEGMENT_ABSDATA ?
+ data : // Abs value
+ clamp(base_qindex + data, 0, MAXQ); // Delta value
} else {
return base_qindex;
}
--- a/vp9/common/vp9_quant_common.h
+++ b/vp9/common/vp9_quant_common.h
@@ -23,6 +23,6 @@
int16_t vp9_dc_quant(int qindex, int delta);
int16_t vp9_ac_quant(int qindex, int delta);
-int vp9_get_qindex(MACROBLOCKD *mb, int segment_id, int base_qindex);
+int vp9_get_qindex(struct segmentation *seg, int segment_id, int base_qindex);
#endif // VP9_COMMON_VP9_QUANT_COMMON_H_
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -94,7 +94,7 @@
static int read_intra_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col,
vp9_reader *r) {
MACROBLOCKD *const xd = &pbi->mb;
- struct segmentation *const seg = &xd->seg;
+ struct segmentation *const seg = &pbi->common.seg;
const BLOCK_SIZE_TYPE bsize = xd->mode_info_context->mbmi.sb_type;
int segment_id;
@@ -113,7 +113,7 @@
vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
- struct segmentation *const seg = &xd->seg;
+ struct segmentation *const seg = &cm->seg;
const BLOCK_SIZE_TYPE bsize = xd->mode_info_context->mbmi.sb_type;
int pred_segment_id, segment_id;
@@ -126,7 +126,7 @@
return pred_segment_id;
if (seg->temporal_update) {
- const vp9_prob pred_prob = vp9_get_pred_prob_seg_id(xd);
+ const vp9_prob pred_prob = vp9_get_pred_prob_seg_id(seg, xd);
const int pred_flag = vp9_read(r, pred_prob);
vp9_set_pred_flag_seg_id(cm, bsize, mi_row, mi_col, pred_flag);
segment_id = pred_flag ? pred_segment_id
@@ -141,7 +141,7 @@
static uint8_t read_skip_coeff(VP9D_COMP *pbi, int segment_id, vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
- int skip_coeff = vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_SKIP);
+ int skip_coeff = vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP);
if (!skip_coeff) {
const int ctx = vp9_get_pred_context_mbskip(xd);
skip_coeff = vp9_read(r, vp9_get_pred_prob_mbskip(cm, xd));
@@ -303,8 +303,8 @@
FRAME_CONTEXT *const fc = &cm->fc;
FRAME_COUNTS *const counts = &cm->counts;
- if (vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_REF_FRAME)) {
- ref_frame[0] = vp9_get_segdata(&xd->seg, segment_id, SEG_LVL_REF_FRAME);
+ if (vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) {
+ ref_frame[0] = vp9_get_segdata(&cm->seg, segment_id, SEG_LVL_REF_FRAME);
ref_frame[1] = NONE;
} else {
const int comp_ctx = vp9_get_pred_context_comp_inter_inter(cm, xd);
@@ -420,8 +420,8 @@
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
- if (vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_REF_FRAME)) {
- return vp9_get_segdata(&xd->seg, segment_id, SEG_LVL_REF_FRAME) !=
+ if (vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) {
+ return vp9_get_segdata(&cm->seg, segment_id, SEG_LVL_REF_FRAME) !=
INTRA_FRAME;
} else {
const int ctx = vp9_get_pred_context_intra_inter(xd);
@@ -459,7 +459,7 @@
inter_mode_ctx = mbmi->mode_context[ref0];
- if (vp9_segfeature_active(&xd->seg, mbmi->segment_id, SEG_LVL_SKIP))
+ if (vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP))
mbmi->mode = ZEROMV;
else if (bsize >= BLOCK_8X8)
mbmi->mode = read_inter_mode(cm, r, inter_mode_ctx);
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -80,7 +80,7 @@
static void init_dequantizer(VP9_COMMON *cm, MACROBLOCKD *xd) {
int i;
const int segment_id = xd->mode_info_context->mbmi.segment_id;
- xd->q_index = vp9_get_qindex(xd, segment_id, cm->base_qindex);
+ xd->q_index = vp9_get_qindex(&cm->seg, segment_id, cm->base_qindex);
xd->plane[0].dequant = cm->y_dequant[xd->q_index];
for (i = 1; i < MAX_MB_PLANE; i++)
@@ -173,7 +173,7 @@
reset_skip_context(xd, bsize);
return -1;
} else {
- if (xd->seg.enabled)
+ if (pbi->common.seg.enabled)
init_dequantizer(&pbi->common, xd);
// TODO(dkovalev) if (!vp9_reader_has_error(r))
@@ -596,7 +596,7 @@
lf_data->xd = pbi->mb;
lf_data->y_only = 0;
}
- vp9_loop_filter_frame_init(pc, &pbi->mb, pc->lf.filter_level);
+ vp9_loop_filter_frame_init(pc, pc->lf.filter_level);
}
for (mi_row = pc->cur_tile_mi_row_start; mi_row < pc->cur_tile_mi_row_end;
@@ -889,11 +889,11 @@
cm->frame_context_idx = vp9_rb_read_literal(rb, NUM_FRAME_CONTEXTS_LOG2);
if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode || cm->intra_only)
- vp9_setup_past_independence(cm, xd);
+ vp9_setup_past_independence(cm);
setup_loopfilter(&cm->lf, rb);
setup_quantization(pbi, rb);
- setup_segmentation(&xd->seg, rb);
+ setup_segmentation(&cm->seg, rb);
setup_tile_info(cm, rb);
--- a/vp9/decoder/vp9_detokenize.c
+++ b/vp9/decoder/vp9_detokenize.c
@@ -258,10 +258,11 @@
// find the maximum eob for this transform size, adjusted by segment
MACROBLOCKD *xd = &arg->pbi->mb;
+ struct segmentation *seg = &arg->pbi->common.seg;
struct macroblockd_plane* pd = &xd->plane[plane];
const int segment_id = xd->mode_info_context->mbmi.segment_id;
const TX_SIZE tx_size = ss_txfrm_size >> 1;
- const int seg_eob = get_eob(&xd->seg, segment_id, 16 << ss_txfrm_size);
+ const int seg_eob = get_eob(seg, segment_id, 16 << ss_txfrm_size);
const int off = block >> ss_txfrm_size;
const int mod = bw - tx_size - pd->subsampling_x;
const int aoff = (off & ((1 << mod) - 1)) << tx_size;
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -213,7 +213,7 @@
static int write_skip_coeff(const VP9_COMP *cpi, int segment_id, MODE_INFO *m,
vp9_writer *w) {
const MACROBLOCKD *const xd = &cpi->mb.e_mbd;
- if (vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_SKIP)) {
+ if (vp9_segfeature_active(&cpi->common.seg, segment_id, SEG_LVL_SKIP)) {
return 1;
} else {
const int skip_coeff = m->mbmi.skip_coeff;
@@ -361,7 +361,7 @@
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *mi = &xd->mode_info_context->mbmi;
const int segment_id = mi->segment_id;
- int seg_ref_active = vp9_segfeature_active(&xd->seg, segment_id,
+ int seg_ref_active = vp9_segfeature_active(&pc->seg, segment_id,
SEG_LVL_REF_FRAME);
// If segment level coding of this signal is disabled...
// or the segment allows multiple reference frame options
@@ -388,7 +388,7 @@
}
} else {
assert(mi->ref_frame[1] <= INTRA_FRAME);
- assert(vp9_get_segdata(&xd->seg, segment_id, SEG_LVL_REF_FRAME) ==
+ assert(vp9_get_segdata(&pc->seg, segment_id, SEG_LVL_REF_FRAME) ==
mi->ref_frame[0]);
}
@@ -401,7 +401,7 @@
const nmv_context *nmvc = &pc->fc.nmvc;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
- struct segmentation *seg = &xd->seg;
+ struct segmentation *seg = &pc->seg;
MB_MODE_INFO *const mi = &m->mbmi;
const MV_REFERENCE_FRAME rf = mi->ref_frame[0];
const MB_PREDICTION_MODE mode = mi->mode;
@@ -419,7 +419,7 @@
if (seg->update_map) {
if (seg->temporal_update) {
const int pred_flag = mi->seg_id_predicted;
- vp9_prob pred_prob = vp9_get_pred_prob_seg_id(xd);
+ vp9_prob pred_prob = vp9_get_pred_prob_seg_id(seg, xd);
vp9_write(bc, pred_flag, pred_prob);
if (!pred_flag)
write_segment_id(bc, seg, segment_id);
@@ -535,12 +535,13 @@
vp9_writer *bc) {
const VP9_COMMON *const c = &cpi->common;
const MACROBLOCKD *const xd = &cpi->mb.e_mbd;
+ const struct segmentation *const seg = &c->seg;
const int ym = m->mbmi.mode;
const int mis = c->mode_info_stride;
const int segment_id = m->mbmi.segment_id;
- if (xd->seg.update_map)
- write_segment_id(bc, &xd->seg, m->mbmi.segment_id);
+ if (seg->update_map)
+ write_segment_id(bc, seg, m->mbmi.segment_id);
write_skip_coeff(cpi, segment_id, m, bc);
@@ -967,7 +968,7 @@
struct vp9_write_bit_buffer *wb) {
int i, j;
- struct segmentation *seg = &cpi->mb.e_mbd.seg;
+ struct segmentation *seg = &cpi->common.seg;
vp9_wb_write_bit(wb, seg->enabled);
if (!seg->enabled)
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -398,7 +398,7 @@
if (!output_enabled)
return;
- if (!vp9_segfeature_active(&xd->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
+ if (!vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) {
for (i = 0; i < TX_MODES; i++)
cpi->rd_tx_select_diff[i] += ctx->tx_rd_diff[i];
}
@@ -498,7 +498,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;
+ const struct segmentation *const seg = &cm->seg;
set_skip_context(cm, xd, mi_row, mi_col);
set_partition_seg_context(cm, xd, mi_row, mi_col);
@@ -615,7 +615,7 @@
MB_MODE_INFO *const mbmi = &mi->mbmi;
if (cm->frame_type != KEY_FRAME) {
- const int seg_ref_active = vp9_segfeature_active(&xd->seg, mbmi->segment_id,
+ const int seg_ref_active = vp9_segfeature_active(&cm->seg, mbmi->segment_id,
SEG_LVL_REF_FRAME);
if (!seg_ref_active)
@@ -2212,10 +2212,9 @@
}
static int check_dual_ref_flags(VP9_COMP *cpi) {
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
- int ref_flags = cpi->ref_frame_flags;
+ const int ref_flags = cpi->ref_frame_flags;
- if (vp9_segfeature_active(&xd->seg, 1, SEG_LVL_REF_FRAME)) {
+ if (vp9_segfeature_active(&cpi->common.seg, 1, SEG_LVL_REF_FRAME)) {
return 0;
} else {
return (!!(ref_flags & VP9_GOLD_FLAG) + !!(ref_flags & VP9_LAST_FLAG)
@@ -2262,7 +2261,7 @@
const int xmbs = MIN(bw, cm->mi_cols - mi_col);
xd->mode_info_context = mi;
- assert(vp9_segfeature_active(&xd->seg, mbmi->segment_id, SEG_LVL_SKIP) ||
+ assert(vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP) ||
get_skip_flag(mi, mis, ymbs, xmbs));
set_txfm_flag(mi, mis, ymbs, xmbs, txfm_max);
}
@@ -2690,7 +2689,7 @@
mbmi->sb_type >= BLOCK_8X8 &&
!(is_inter_block(mbmi) &&
(mbmi->skip_coeff ||
- vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_SKIP)))) {
+ vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)))) {
const uint8_t context = vp9_get_pred_context_tx_size(xd);
update_tx_counts(bsize, context, mbmi->txfm_size, &cm->counts.tx);
} else {
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -237,10 +237,9 @@
}
}
-static void setup_features(VP9_COMP *cpi) {
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
- struct loopfilter *const lf = &cpi->common.lf;
- struct segmentation *const seg = &xd->seg;
+static void setup_features(VP9_COMMON *cm) {
+ struct loopfilter *const lf = &cm->lf;
+ struct segmentation *const seg = &cm->seg;
// Set up default state for MB feature flags
seg->enabled = 0;
@@ -320,8 +319,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;
+ struct segmentation *seg = &cm->seg;
int high_q = (int)(cpi->avg_q > 48.0);
int qi_delta;
@@ -1232,7 +1230,7 @@
cm->refresh_frame_context = 1;
cm->reset_frame_context = 0;
- setup_features(cpi);
+ setup_features(cm);
cpi->mb.e_mbd.allow_high_precision_mv = 0; // Default mv precision adaptation
set_mvcost(&cpi->mb);
@@ -2531,7 +2529,7 @@
SPEED_FEATURES *sf = &cpi->sf;
unsigned int max_mv_def = MIN(cpi->common.width, cpi->common.height);
- struct segmentation *seg = &xd->seg;
+ struct segmentation *seg = &cm->seg;
#if RESET_FOREACH_FILTER
int q_low0;
int q_high0;
@@ -2628,7 +2626,7 @@
int i;
// Reset the loop filter deltas and segmentation map
- setup_features(cpi);
+ setup_features(cm);
// If segmentation is enabled force a map update for key frames
if (seg->enabled) {
@@ -3164,7 +3162,7 @@
cpi->dummy_packing = 0;
vp9_pack_bitstream(cpi, dest, size);
- if (xd->seg.update_map)
+ if (cm->seg.update_map)
update_reference_segmentation_map(cpi);
release_scaled_references(cpi);
@@ -3472,8 +3470,8 @@
}
// Clear the one shot update flags for segmentation map and mode/ref loop filter deltas.
- xd->seg.update_map = 0;
- xd->seg.update_data = 0;
+ cm->seg.update_map = 0;
+ cm->seg.update_data = 0;
cm->lf.mode_ref_delta_update = 0;
// keep track of the last coded dimensions
@@ -3574,7 +3572,6 @@
static int frame_is_reference(const VP9_COMP *cpi) {
const VP9_COMMON *cm = &cpi->common;
- const MACROBLOCKD *mb = &cpi->mb.e_mbd;
return cm->frame_type == KEY_FRAME ||
cpi->refresh_last_frame ||
@@ -3582,8 +3579,8 @@
cpi->refresh_alt_ref_frame ||
cm->refresh_frame_context ||
cm->lf.mode_ref_delta_update ||
- mb->seg.update_map ||
- mb->seg.update_data;
+ cm->seg.update_map ||
+ cm->seg.update_data;
}
#if CONFIG_MULTIPLE_ARF
@@ -4012,7 +4009,7 @@
unsigned int threshold[MAX_SEGMENTS]) {
VP9_COMP *cpi = (VP9_COMP *) comp;
signed char feature_data[SEG_LVL_MAX][MAX_SEGMENTS];
- struct segmentation *seg = &cpi->mb.e_mbd.seg;
+ struct segmentation *seg = &cpi->common.seg;
int i;
if (cpi->common.mb_rows != rows || cpi->common.mb_cols != cols)
--- a/vp9/encoder/vp9_quantize.c
+++ b/vp9/encoder/vp9_quantize.c
@@ -253,7 +253,8 @@
MACROBLOCKD *xd = &x->e_mbd;
int zbin_extra;
int segment_id = xd->mode_info_context->mbmi.segment_id;
- const int qindex = vp9_get_qindex(xd, segment_id, cpi->common.base_qindex);
+ const int qindex = vp9_get_qindex(&cpi->common.seg, segment_id,
+ cpi->common.base_qindex);
// Y
zbin_extra = (cpi->common.y_dequant[qindex][1] *
@@ -288,7 +289,8 @@
x->e_mbd.plane[3].dequant = cpi->common.a_dequant[qindex];
#endif
- x->skip_block = vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_SKIP);
+ x->skip_block = vp9_segfeature_active(&cpi->common.seg, segment_id,
+ SEG_LVL_SKIP);
/* save this macroblock QIndex for vp9_update_zbin_extra() */
x->e_mbd.q_index = qindex;
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -71,7 +71,6 @@
void vp9_save_coding_context(VP9_COMP *cpi) {
CODING_CONTEXT *const cc = &cpi->coding_context;
VP9_COMMON *cm = &cpi->common;
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
// Stores a snapshot of key state variables which can subsequently be
// restored with a call to vp9_restore_coding_context. These functions are
@@ -89,7 +88,7 @@
vp9_copy(cc->uv_mode_prob, cm->fc.uv_mode_prob);
vp9_copy(cc->partition_prob, cm->fc.partition_prob);
- vp9_copy(cc->segment_pred_probs, xd->seg.pred_probs);
+ vp9_copy(cc->segment_pred_probs, cm->seg.pred_probs);
vp9_copy(cc->intra_inter_prob, cm->fc.intra_inter_prob);
vp9_copy(cc->comp_inter_prob, cm->fc.comp_inter_prob);
@@ -111,7 +110,6 @@
void vp9_restore_coding_context(VP9_COMP *cpi) {
CODING_CONTEXT *const cc = &cpi->coding_context;
VP9_COMMON *cm = &cpi->common;
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
// Restore key state variables to the snapshot state stored in the
// previous call to vp9_save_coding_context.
@@ -127,7 +125,7 @@
vp9_copy(cm->fc.uv_mode_prob, cc->uv_mode_prob);
vp9_copy(cm->fc.partition_prob, cc->partition_prob);
- vp9_copy(xd->seg.pred_probs, cc->segment_pred_probs);
+ vp9_copy(cm->seg.pred_probs, cc->segment_pred_probs);
vp9_copy(cm->fc.intra_inter_prob, cc->intra_inter_prob);
vp9_copy(cm->fc.comp_inter_prob, cc->comp_inter_prob);
@@ -149,9 +147,8 @@
void vp9_setup_key_frame(VP9_COMP *cpi) {
VP9_COMMON *cm = &cpi->common;
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
- vp9_setup_past_independence(cm, xd);
+ vp9_setup_past_independence(cm);
// interval before next GF
cpi->frames_till_gf_update_due = cpi->baseline_gf_interval;
@@ -162,9 +159,8 @@
void vp9_setup_inter_frame(VP9_COMP *cpi) {
VP9_COMMON *cm = &cpi->common;
- MACROBLOCKD *xd = &cpi->mb.e_mbd;
if (cm->error_resilient_mode || cm->intra_only)
- vp9_setup_past_independence(cm, xd);
+ vp9_setup_past_independence(cm);
assert(cm->frame_context_idx < NUM_FRAME_CONTEXTS);
cm->fc = cm->frame_contexts[cm->frame_context_idx];
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -1478,7 +1478,7 @@
const int segment_id = xd->mode_info_context->mbmi.segment_id;
// Don't account for mode here if segment skip is enabled.
- if (!vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_SKIP)) {
+ if (!vp9_segfeature_active(&cpi->common.seg, segment_id, SEG_LVL_SKIP)) {
assert(is_inter_mode(mode));
return x->inter_mode_cost[mode_context][mode - NEARESTMV];
} else {
@@ -2212,7 +2212,7 @@
vp9_prob *comp_mode_p) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
- int seg_ref_active = vp9_segfeature_active(&xd->seg, segment_id,
+ int seg_ref_active = vp9_segfeature_active(&cm->seg, segment_id,
SEG_LVL_REF_FRAME);
if (seg_ref_active) {
vpx_memset(ref_costs_single, 0, MAX_REF_FRAMES * sizeof(*ref_costs_single));
@@ -2745,7 +2745,7 @@
// if we're near/nearest and mv == 0,0, compare to zeromv
if ((this_mode == NEARMV || this_mode == NEARESTMV || this_mode == ZEROMV) &&
frame_mv[refs[0]].as_int == 0 &&
- !vp9_segfeature_active(&xd->seg, mbmi->segment_id, SEG_LVL_SKIP) &&
+ !vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP) &&
(num_refs == 1 || frame_mv[refs[1]].as_int == 0)) {
int rfc = mbmi->mode_context[mbmi->ref_frame[0]];
int c1 = cost_mv_ref(cpi, NEARMV, rfc);
@@ -3134,7 +3134,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 struct segmentation *seg = &cm->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;
--- a/vp9/encoder/vp9_segmentation.c
+++ b/vp9/encoder/vp9_segmentation.c
@@ -17,20 +17,23 @@
void vp9_enable_segmentation(VP9_PTR ptr) {
VP9_COMP *cpi = (VP9_COMP *)ptr;
+ struct segmentation *const seg = &cpi->common.seg;
- cpi->mb.e_mbd.seg.enabled = 1;
- cpi->mb.e_mbd.seg.update_map = 1;
- cpi->mb.e_mbd.seg.update_data = 1;
+ seg->enabled = 1;
+ seg->update_map = 1;
+ seg->update_data = 1;
}
void vp9_disable_segmentation(VP9_PTR ptr) {
VP9_COMP *cpi = (VP9_COMP *)ptr;
- cpi->mb.e_mbd.seg.enabled = 0;
+ struct segmentation *const seg = &cpi->common.seg;
+ seg->enabled = 0;
}
void vp9_set_segmentation_map(VP9_PTR ptr,
unsigned char *segmentation_map) {
- VP9_COMP *cpi = (VP9_COMP *)(ptr);
+ VP9_COMP *cpi = (VP9_COMP *)ptr;
+ struct segmentation *const seg = &cpi->common.seg;
// Copy in the new segmentation map
vpx_memcpy(cpi->segmentation_map, segmentation_map,
@@ -37,19 +40,19 @@
(cpi->common.mi_rows * cpi->common.mi_cols));
// Signal that the map should be updated.
- cpi->mb.e_mbd.seg.update_map = 1;
- cpi->mb.e_mbd.seg.update_data = 1;
+ seg->update_map = 1;
+ seg->update_data = 1;
}
void vp9_set_segment_data(VP9_PTR ptr,
signed char *feature_data,
unsigned char abs_delta) {
- VP9_COMP *cpi = (VP9_COMP *)(ptr);
+ VP9_COMP *cpi = (VP9_COMP *)ptr;
+ struct segmentation *const seg = &cpi->common.seg;
- cpi->mb.e_mbd.seg.abs_delta = abs_delta;
+ seg->abs_delta = abs_delta;
- vpx_memcpy(cpi->mb.e_mbd.seg.feature_data, feature_data,
- sizeof(cpi->mb.e_mbd.seg.feature_data));
+ vpx_memcpy(seg->feature_data, feature_data, sizeof(seg->feature_data));
// TBD ?? Set the feature mask
// vpx_memcpy(cpi->mb.e_mbd.segment_feature_mask, 0,
@@ -210,7 +213,7 @@
void vp9_choose_segmap_coding_method(VP9_COMP *cpi) {
VP9_COMMON *const cm = &cpi->common;
- struct segmentation *seg = &cpi->mb.e_mbd.seg;
+ struct segmentation *seg = &cm->seg;
int no_pred_cost;
int t_pred_cost = INT_MAX;
--- a/vp9/encoder/vp9_tokenize.c
+++ b/vp9/encoder/vp9_tokenize.c
@@ -191,7 +191,7 @@
pt = combine_entropy_contexts(above_ec, left_ec);
nb = vp9_get_coef_neighbors_handle(scan);
- if (vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_SKIP))
+ if (vp9_segfeature_active(&cpi->common.seg, segment_id, SEG_LVL_SKIP))
seg_eob = 0;
c = 0;
@@ -274,7 +274,7 @@
MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi;
TOKENEXTRA *t_backup = *t;
const int mb_skip_context = vp9_get_pred_context_mbskip(xd);
- const int skip_inc = !vp9_segfeature_active(&xd->seg, mbmi->segment_id,
+ const int skip_inc = !vp9_segfeature_active(&cm->seg, mbmi->segment_id,
SEG_LVL_SKIP);
struct tokenize_b_args arg = {cpi, xd, t, mbmi->txfm_size};