Merge "Moving segmentation struct from MACROBLOCKD to VP9_COMMON."
This commit is contained in:
commit
939b1e4a8c
@ -210,8 +210,6 @@ typedef struct macroblockd {
|
||||
int left_available;
|
||||
int right_available;
|
||||
|
||||
struct segmentation seg;
|
||||
|
||||
// partition contexts
|
||||
PARTITION_CONTEXT *above_seg_context;
|
||||
PARTITION_CONTEXT *left_seg_context;
|
||||
|
@ -470,14 +470,14 @@ static void set_default_lf_deltas(struct loopfilter *lf) {
|
||||
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));
|
||||
|
||||
|
@ -56,7 +56,7 @@ extern struct vp9_token vp9_switchable_interp_encodings[VP9_SWITCHABLE_FILTERS];
|
||||
|
||||
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);
|
||||
|
||||
|
@ -78,8 +78,7 @@ void vp9_loop_filter_init(VP9_COMMON *cm) {
|
||||
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 @@ void vp9_loop_filter_frame_init(VP9_COMMON *const cm, MACROBLOCKD *const xd,
|
||||
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 @@ void vp9_loop_filter_frame_init(VP9_COMMON *const cm, MACROBLOCKD *const xd,
|
||||
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 @@ void vp9_loop_filter_frame(VP9_COMMON *cm, MACROBLOCKD *xd,
|
||||
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);
|
||||
|
@ -65,9 +65,7 @@ void vp9_loop_filter_init(struct VP9Common *cm);
|
||||
// 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,
|
||||
|
@ -177,6 +177,7 @@ typedef struct VP9Common {
|
||||
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];
|
||||
|
@ -27,8 +27,9 @@ static INLINE int vp9_get_pred_context_seg_id(const MACROBLOCKD *xd) {
|
||||
(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,
|
||||
|
@ -130,12 +130,12 @@ int16_t vp9_ac_quant(int qindex, int delta) {
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -23,6 +23,6 @@ void vp9_init_quant_tables();
|
||||
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_
|
||||
|
@ -94,7 +94,7 @@ static void set_segment_id(VP9_COMMON *cm, BLOCK_SIZE_TYPE bsize,
|
||||
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 @@ static int read_inter_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col,
|
||||
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 @@ static int read_inter_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col,
|
||||
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 int read_inter_segment_id(VP9D_COMP *pbi, int mi_row, int mi_col,
|
||||
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 @@ static void read_ref_frames(VP9D_COMP *pbi, vp9_reader *r,
|
||||
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 @@ static int read_is_inter_block(VP9D_COMP *pbi, int segment_id, vp9_reader *r) {
|
||||
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 @@ static void read_inter_block_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
|
||||
|
||||
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);
|
||||
|
@ -80,7 +80,7 @@ static void read_tx_probs(struct tx_probs *tx_probs, vp9_reader *r) {
|
||||
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 @@ static int decode_tokens(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize, vp9_reader *r) {
|
||||
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 @@ static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) {
|
||||
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 @@ static size_t read_uncompressed_header(VP9D_COMP *pbi,
|
||||
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);
|
||||
|
||||
|
@ -258,10 +258,11 @@ static void decode_block(int plane, int block,
|
||||
|
||||
// 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;
|
||||
|
@ -213,7 +213,7 @@ static void write_selected_tx_size(const VP9_COMP *cpi, TX_SIZE tx_size,
|
||||
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 @@ static void encode_ref_frame(VP9_COMP *cpi, vp9_writer *bc) {
|
||||
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 @@ static void encode_ref_frame(VP9_COMP *cpi, vp9_writer *bc) {
|
||||
}
|
||||
} 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 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) {
|
||||
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 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) {
|
||||
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 @@ static void write_mb_modes_kf(const VP9_COMP *cpi, MODE_INFO *m,
|
||||
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 @@ static void encode_segmentation(VP9_COMP *cpi,
|
||||
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)
|
||||
|
@ -398,7 +398,7 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx,
|
||||
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 @@ static void set_offsets(VP9_COMP *cpi, int mi_row, int mi_col,
|
||||
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 @@ static void update_stats(VP9_COMP *cpi) {
|
||||
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 void encode_frame_internal(VP9_COMP *cpi) {
|
||||
}
|
||||
|
||||
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 @@ static void reset_skip_txfm_size_b(VP9_COMP *cpi, MODE_INFO *mi, int mis,
|
||||
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 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled,
|
||||
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 {
|
||||
|
@ -237,10 +237,9 @@ void vp9_initialize_enc() {
|
||||
}
|
||||
}
|
||||
|
||||
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 int compute_qdelta(VP9_COMP *cpi, double qstart, double qtarget) {
|
||||
|
||||
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 @@ void vp9_change_config(VP9_PTR ptr, VP9_CONFIG *oxcf) {
|
||||
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 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
|
||||
|
||||
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 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
|
||||
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 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
|
||||
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 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
|
||||
}
|
||||
|
||||
// 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 @@ int vp9_receive_raw_frame(VP9_PTR ptr, unsigned int frame_flags,
|
||||
|
||||
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 @@ static int frame_is_reference(const VP9_COMP *cpi) {
|
||||
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 @@ int vp9_set_roimap(VP9_PTR comp, unsigned char *map, unsigned int rows,
|
||||
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)
|
||||
|
@ -253,7 +253,8 @@ void vp9_mb_init_quantizer(VP9_COMP *cpi, MACROBLOCK *x) {
|
||||
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 @@ void vp9_mb_init_quantizer(VP9_COMP *cpi, MACROBLOCK *x) {
|
||||
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;
|
||||
|
@ -71,7 +71,6 @@ int vp9_bits_per_mb(FRAME_TYPE frame_type, int qindex,
|
||||
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 @@ void vp9_save_coding_context(VP9_COMP *cpi) {
|
||||
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_save_coding_context(VP9_COMP *cpi) {
|
||||
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 @@ void vp9_restore_coding_context(VP9_COMP *cpi) {
|
||||
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_restore_coding_context(VP9_COMP *cpi) {
|
||||
|
||||
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_key_frame(VP9_COMP *cpi) {
|
||||
|
||||
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];
|
||||
|
@ -1492,7 +1492,7 @@ static int cost_mv_ref(VP9_COMP *cpi, MB_PREDICTION_MODE mode,
|
||||
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 {
|
||||
@ -2226,7 +2226,7 @@ static void estimate_ref_frame_costs(VP9_COMP *cpi, int segment_id,
|
||||
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));
|
||||
@ -2759,7 +2759,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
// 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);
|
||||
@ -3148,7 +3148,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
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;
|
||||
|
@ -17,39 +17,42 @@
|
||||
|
||||
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,
|
||||
(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 @@ static void count_segs_sb(VP9_COMP *cpi, MODE_INFO *mi,
|
||||
|
||||
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;
|
||||
|
@ -191,7 +191,7 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
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;
|
||||
@ -276,7 +276,7 @@ void vp9_tokenize_sb(VP9_COMP *cpi, TOKENEXTRA **t, int dry_run,
|
||||
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};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user