Cleaning up pack_inter_mode_mvs() function.
Change-Id: Ia60352c7173b59f3f08920ba86096864d4e8250b
This commit is contained in:
parent
0fced0bca7
commit
ba4bcee616
@ -94,13 +94,13 @@ static void write_selected_tx_size(const VP9_COMP *cpi,
|
||||
}
|
||||
}
|
||||
|
||||
static int write_skip(const VP9_COMP *cpi, int segment_id, MODE_INFO *m,
|
||||
static int write_skip(const VP9_COMP *cpi, int segment_id, const MODE_INFO *mi,
|
||||
vp9_writer *w) {
|
||||
const MACROBLOCKD *const xd = &cpi->mb.e_mbd;
|
||||
if (vp9_segfeature_active(&cpi->common.seg, segment_id, SEG_LVL_SKIP)) {
|
||||
return 1;
|
||||
} else {
|
||||
const int skip = m->mbmi.skip;
|
||||
const int skip = mi->mbmi.skip;
|
||||
vp9_write(w, skip, vp9_get_skip_prob(&cpi->common, xd));
|
||||
return skip;
|
||||
}
|
||||
@ -225,108 +225,107 @@ static void write_ref_frames(const VP9_COMP *cpi, vp9_writer *w) {
|
||||
}
|
||||
}
|
||||
|
||||
static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) {
|
||||
static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
|
||||
vp9_writer *w) {
|
||||
VP9_COMMON *const cm = &cpi->common;
|
||||
const nmv_context *nmvc = &cm->fc.nmvc;
|
||||
MACROBLOCK *const x = &cpi->mb;
|
||||
MACROBLOCKD *const xd = &x->e_mbd;
|
||||
const MACROBLOCK *const x = &cpi->mb;
|
||||
const MACROBLOCKD *const xd = &x->e_mbd;
|
||||
const struct segmentation *const seg = &cm->seg;
|
||||
const MB_MODE_INFO *const mi = &m->mbmi;
|
||||
const MV_REFERENCE_FRAME ref0 = mi->ref_frame[0];
|
||||
const MV_REFERENCE_FRAME ref1 = mi->ref_frame[1];
|
||||
const MB_PREDICTION_MODE mode = mi->mode;
|
||||
const int segment_id = mi->segment_id;
|
||||
const BLOCK_SIZE bsize = mi->sb_type;
|
||||
const MB_MODE_INFO *const mbmi = &mi->mbmi;
|
||||
const MB_PREDICTION_MODE mode = mbmi->mode;
|
||||
const int segment_id = mbmi->segment_id;
|
||||
const BLOCK_SIZE bsize = mbmi->sb_type;
|
||||
const int allow_hp = cm->allow_high_precision_mv;
|
||||
int skip;
|
||||
const int is_inter = is_inter_block(mbmi);
|
||||
const int is_compound = has_second_ref(mbmi);
|
||||
int skip, ref;
|
||||
|
||||
if (seg->update_map) {
|
||||
if (seg->temporal_update) {
|
||||
const int pred_flag = mi->seg_id_predicted;
|
||||
const int pred_flag = mbmi->seg_id_predicted;
|
||||
vp9_prob pred_prob = vp9_get_pred_prob_seg_id(seg, xd);
|
||||
vp9_write(bc, pred_flag, pred_prob);
|
||||
vp9_write(w, pred_flag, pred_prob);
|
||||
if (!pred_flag)
|
||||
write_segment_id(bc, seg, segment_id);
|
||||
write_segment_id(w, seg, segment_id);
|
||||
} else {
|
||||
write_segment_id(bc, seg, segment_id);
|
||||
write_segment_id(w, seg, segment_id);
|
||||
}
|
||||
}
|
||||
|
||||
skip = write_skip(cpi, segment_id, m, bc);
|
||||
skip = write_skip(cpi, segment_id, mi, w);
|
||||
|
||||
if (!vp9_segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME))
|
||||
vp9_write(bc, ref0 != INTRA_FRAME, vp9_get_intra_inter_prob(cm, xd));
|
||||
vp9_write(w, is_inter, vp9_get_intra_inter_prob(cm, xd));
|
||||
|
||||
if (bsize >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT &&
|
||||
!(ref0 != INTRA_FRAME &&
|
||||
!(is_inter &&
|
||||
(skip || vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP)))) {
|
||||
write_selected_tx_size(cpi, mi->tx_size, bsize, bc);
|
||||
write_selected_tx_size(cpi, mbmi->tx_size, bsize, w);
|
||||
}
|
||||
|
||||
if (ref0 == INTRA_FRAME) {
|
||||
if (!is_inter) {
|
||||
if (bsize >= BLOCK_8X8) {
|
||||
write_intra_mode(bc, mode, cm->fc.y_mode_prob[size_group_lookup[bsize]]);
|
||||
write_intra_mode(w, mode, cm->fc.y_mode_prob[size_group_lookup[bsize]]);
|
||||
} else {
|
||||
int idx, idy;
|
||||
const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize];
|
||||
const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bsize];
|
||||
for (idy = 0; idy < 2; idy += num_4x4_blocks_high) {
|
||||
for (idx = 0; idx < 2; idx += num_4x4_blocks_wide) {
|
||||
const MB_PREDICTION_MODE bm = m->bmi[idy * 2 + idx].as_mode;
|
||||
write_intra_mode(bc, bm, cm->fc.y_mode_prob[0]);
|
||||
const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
|
||||
const int num_4x4_h = num_4x4_blocks_high_lookup[bsize];
|
||||
for (idy = 0; idy < 2; idy += num_4x4_h) {
|
||||
for (idx = 0; idx < 2; idx += num_4x4_w) {
|
||||
const MB_PREDICTION_MODE b_mode = mi->bmi[idy * 2 + idx].as_mode;
|
||||
write_intra_mode(w, b_mode, cm->fc.y_mode_prob[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
write_intra_mode(bc, mi->uv_mode, cm->fc.uv_mode_prob[mode]);
|
||||
write_intra_mode(w, mbmi->uv_mode, cm->fc.uv_mode_prob[mode]);
|
||||
} else {
|
||||
vp9_prob *mv_ref_p;
|
||||
write_ref_frames(cpi, bc);
|
||||
mv_ref_p = cm->fc.inter_mode_probs[mi->mode_context[ref0]];
|
||||
const int mode_ctx = mbmi->mode_context[mbmi->ref_frame[0]];
|
||||
const vp9_prob *const inter_probs = cm->fc.inter_mode_probs[mode_ctx];
|
||||
write_ref_frames(cpi, w);
|
||||
|
||||
// If segment skip is not enabled code the mode.
|
||||
if (!vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP)) {
|
||||
if (bsize >= BLOCK_8X8) {
|
||||
write_inter_mode(bc, mode, mv_ref_p);
|
||||
++cm->counts.inter_mode[mi->mode_context[ref0]][INTER_OFFSET(mode)];
|
||||
write_inter_mode(w, mode, inter_probs);
|
||||
++cm->counts.inter_mode[mode_ctx][INTER_OFFSET(mode)];
|
||||
}
|
||||
}
|
||||
|
||||
if (cm->interp_filter == SWITCHABLE) {
|
||||
const int ctx = vp9_get_pred_context_switchable_interp(xd);
|
||||
vp9_write_token(bc, vp9_switchable_interp_tree,
|
||||
vp9_write_token(w, vp9_switchable_interp_tree,
|
||||
cm->fc.switchable_interp_prob[ctx],
|
||||
&switchable_interp_encodings[mi->interp_filter]);
|
||||
&switchable_interp_encodings[mbmi->interp_filter]);
|
||||
} else {
|
||||
assert(mi->interp_filter == cm->interp_filter);
|
||||
assert(mbmi->interp_filter == cm->interp_filter);
|
||||
}
|
||||
|
||||
if (bsize < BLOCK_8X8) {
|
||||
const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize];
|
||||
const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bsize];
|
||||
const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
|
||||
const int num_4x4_h = num_4x4_blocks_high_lookup[bsize];
|
||||
int idx, idy;
|
||||
for (idy = 0; idy < 2; idy += num_4x4_blocks_high) {
|
||||
for (idx = 0; idx < 2; idx += num_4x4_blocks_wide) {
|
||||
for (idy = 0; idy < 2; idy += num_4x4_h) {
|
||||
for (idx = 0; idx < 2; idx += num_4x4_w) {
|
||||
const int j = idy * 2 + idx;
|
||||
const MB_PREDICTION_MODE b_mode = m->bmi[j].as_mode;
|
||||
write_inter_mode(bc, b_mode, mv_ref_p);
|
||||
++cm->counts.inter_mode[mi->mode_context[ref0]][INTER_OFFSET(b_mode)];
|
||||
const MB_PREDICTION_MODE b_mode = mi->bmi[j].as_mode;
|
||||
write_inter_mode(w, b_mode, inter_probs);
|
||||
++cm->counts.inter_mode[mode_ctx][INTER_OFFSET(b_mode)];
|
||||
if (b_mode == NEWMV) {
|
||||
vp9_encode_mv(cpi, bc, &m->bmi[j].as_mv[0].as_mv,
|
||||
&mi->ref_mvs[ref0][0].as_mv, nmvc, allow_hp);
|
||||
|
||||
if (has_second_ref(mi))
|
||||
vp9_encode_mv(cpi, bc, &m->bmi[j].as_mv[1].as_mv,
|
||||
&mi->ref_mvs[ref1][0].as_mv, nmvc, allow_hp);
|
||||
for (ref = 0; ref < 1 + is_compound; ++ref)
|
||||
vp9_encode_mv(cpi, w, &mi->bmi[j].as_mv[ref].as_mv,
|
||||
&mbmi->ref_mvs[mbmi->ref_frame[ref]][0].as_mv,
|
||||
nmvc, allow_hp);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (mode == NEWMV) {
|
||||
vp9_encode_mv(cpi, bc, &mi->mv[0].as_mv,
|
||||
&mi->ref_mvs[ref0][0].as_mv, nmvc, allow_hp);
|
||||
|
||||
if (has_second_ref(mi))
|
||||
vp9_encode_mv(cpi, bc, &mi->mv[1].as_mv,
|
||||
&mi->ref_mvs[ref1][0].as_mv, nmvc, allow_hp);
|
||||
} else {
|
||||
if (mode == NEWMV) {
|
||||
for (ref = 0; ref < 1 + is_compound; ++ref)
|
||||
vp9_encode_mv(cpi, w, &mbmi->mv[ref].as_mv,
|
||||
&mbmi->ref_mvs[mbmi->ref_frame[ref]][0].as_mv, nmvc,
|
||||
allow_hp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user