Merge "Motion vector decoder cleanup." into experimental

This commit is contained in:
Dmitry Kovalev 2013-04-15 11:28:52 -07:00 committed by Gerrit Code Review
commit b800ec1772

View File

@ -272,32 +272,26 @@ static void read_nmv(vp9_reader *r, MV *mv, const MV *ref,
const nmv_context *mvctx) { const nmv_context *mvctx) {
const MV_JOINT_TYPE j = treed_read(r, vp9_mv_joint_tree, mvctx->joints); const MV_JOINT_TYPE j = treed_read(r, vp9_mv_joint_tree, mvctx->joints);
mv->row = mv->col = 0; mv->row = mv->col = 0;
if (j == MV_JOINT_HZVNZ || j == MV_JOINT_HNZVNZ) {
mv->row = read_nmv_component(r, ref->row, &mvctx->comps[0]);
}
if (j == MV_JOINT_HNZVZ || j == MV_JOINT_HNZVNZ) { if (j == MV_JOINT_HZVNZ || j == MV_JOINT_HNZVNZ)
mv->row = read_nmv_component(r, ref->row, &mvctx->comps[0]);
if (j == MV_JOINT_HNZVZ || j == MV_JOINT_HNZVNZ)
mv->col = read_nmv_component(r, ref->col, &mvctx->comps[1]); mv->col = read_nmv_component(r, ref->col, &mvctx->comps[1]);
} }
}
static void read_nmv_fp(vp9_reader *r, MV *mv, const MV *ref, static void read_nmv_fp(vp9_reader *r, MV *mv, const MV *ref,
const nmv_context *mvctx, int usehp) { const nmv_context *mvctx, int usehp) {
const MV_JOINT_TYPE j = vp9_get_mv_joint(*mv); const MV_JOINT_TYPE j = vp9_get_mv_joint(*mv);
usehp = usehp && vp9_use_nmv_hp(ref); usehp = usehp && vp9_use_nmv_hp(ref);
if (j == MV_JOINT_HZVNZ || j == MV_JOINT_HNZVNZ) { if (j == MV_JOINT_HZVNZ || j == MV_JOINT_HNZVNZ)
mv->row = read_nmv_component_fp(r, mv->row, ref->row, &mvctx->comps[0], mv->row = read_nmv_component_fp(r, mv->row, ref->row, &mvctx->comps[0],
usehp); usehp);
}
if (j == MV_JOINT_HNZVZ || j == MV_JOINT_HNZVNZ) { if (j == MV_JOINT_HNZVZ || j == MV_JOINT_HNZVNZ)
mv->col = read_nmv_component_fp(r, mv->col, ref->col, &mvctx->comps[1], mv->col = read_nmv_component_fp(r, mv->col, ref->col, &mvctx->comps[1],
usehp); usehp);
} }
/*
printf("MV: %d %d REF: %d %d\n", mv->row + ref->row, mv->col + ref->col,
ref->row, ref->col);
*/
}
static void update_nmv(vp9_reader *bc, vp9_prob *const p, static void update_nmv(vp9_reader *bc, vp9_prob *const p,
const vp9_prob upd_p) { const vp9_prob upd_p) {
@ -359,16 +353,18 @@ static MV_REFERENCE_FRAME read_ref_frame(VP9D_COMP *pbi,
MACROBLOCKD *const xd = &pbi->mb; MACROBLOCKD *const xd = &pbi->mb;
int seg_ref_count = 0; int seg_ref_count = 0;
int seg_ref_active = vp9_segfeature_active(xd, segment_id, SEG_LVL_REF_FRAME); const int seg_ref_active = vp9_segfeature_active(xd, segment_id,
SEG_LVL_REF_FRAME);
const int intra = vp9_check_segref(xd, segment_id, INTRA_FRAME);
const int last = vp9_check_segref(xd, segment_id, LAST_FRAME);
const int golden = vp9_check_segref(xd, segment_id, GOLDEN_FRAME);
const int altref = vp9_check_segref(xd, segment_id, ALTREF_FRAME);
// If segment coding enabled does the segment allow for more than one // If segment coding enabled does the segment allow for more than one
// possible reference frame // possible reference frame
if (seg_ref_active) { if (seg_ref_active)
seg_ref_count = vp9_check_segref(xd, segment_id, INTRA_FRAME) + seg_ref_count = intra + last + golden + altref;
vp9_check_segref(xd, segment_id, LAST_FRAME) +
vp9_check_segref(xd, segment_id, GOLDEN_FRAME) +
vp9_check_segref(xd, segment_id, ALTREF_FRAME);
}
// Segment reference frame features not available or allows for // Segment reference frame features not available or allows for
// multiple reference frame options // multiple reference frame options
@ -394,19 +390,15 @@ static MV_REFERENCE_FRAME read_ref_frame(VP9D_COMP *pbi,
} else { } else {
// decode the explicitly coded value // decode the explicitly coded value
vp9_prob mod_refprobs[PREDICTION_PROBS]; vp9_prob mod_refprobs[PREDICTION_PROBS];
vpx_memcpy(mod_refprobs, vpx_memcpy(mod_refprobs, cm->mod_refprobs[pred_ref],
cm->mod_refprobs[pred_ref], sizeof(mod_refprobs)); sizeof(mod_refprobs));
// If segment coding enabled blank out options that cant occur by // If segment coding enabled blank out options that cant occur by
// setting the branch probability to 0. // setting the branch probability to 0.
if (seg_ref_active) { if (seg_ref_active) {
mod_refprobs[INTRA_FRAME] *= mod_refprobs[INTRA_FRAME] *= intra;
vp9_check_segref(xd, segment_id, INTRA_FRAME); mod_refprobs[LAST_FRAME] *= last;
mod_refprobs[LAST_FRAME] *= mod_refprobs[GOLDEN_FRAME] *= golden * altref;
vp9_check_segref(xd, segment_id, LAST_FRAME);
mod_refprobs[GOLDEN_FRAME] *=
vp9_check_segref(xd, segment_id, GOLDEN_FRAME) *
vp9_check_segref(xd, segment_id, ALTREF_FRAME);
} }
// Default to INTRA_FRAME (value 0) // Default to INTRA_FRAME (value 0)
@ -430,20 +422,16 @@ static MV_REFERENCE_FRAME read_ref_frame(VP9D_COMP *pbi,
if (mod_refprobs[2]) { if (mod_refprobs[2]) {
ref_frame += vp9_read(bc, mod_refprobs[2]); ref_frame += vp9_read(bc, mod_refprobs[2]);
} else { } else {
if (seg_ref_active) { if (seg_ref_active)
ref_frame = pred_ref == GOLDEN_FRAME || ref_frame = pred_ref == GOLDEN_FRAME || !golden ? ALTREF_FRAME
!vp9_check_segref(xd, segment_id, GOLDEN_FRAME)
? ALTREF_FRAME
: GOLDEN_FRAME; : GOLDEN_FRAME;
} else { else
ref_frame = pred_ref == GOLDEN_FRAME ref_frame = pred_ref == GOLDEN_FRAME ? ALTREF_FRAME
? ALTREF_FRAME
: GOLDEN_FRAME; : GOLDEN_FRAME;
} }
} }
} }
} }
}
} else { } else {
// Segment reference frame features are enabled // Segment reference frame features are enabled
// The reference frame for the mb is considered as correclty predicted // The reference frame for the mb is considered as correclty predicted
@ -499,55 +487,55 @@ static void read_switchable_interp_probs(VP9D_COMP* const pbi,
//cm->fc.switchable_interp_prob[1]); //cm->fc.switchable_interp_prob[1]);
} }
static void mb_mode_mv_init(VP9D_COMP *pbi, vp9_reader *bc) { static INLINE COMPPREDMODE_TYPE read_comp_pred_mode(vp9_reader *r) {
COMPPREDMODE_TYPE mode = vp9_read_bit(r);
if (mode)
mode += vp9_read_bit(r);
return mode;
}
static void mb_mode_mv_init(VP9D_COMP *pbi, vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common; VP9_COMMON *const cm = &pbi->common;
nmv_context *const nmvc = &pbi->common.fc.nmvc;
MACROBLOCKD *const xd = &pbi->mb;
if (cm->frame_type == KEY_FRAME) { if (cm->frame_type == KEY_FRAME) {
if (!cm->kf_ymode_probs_update) if (!cm->kf_ymode_probs_update)
cm->kf_ymode_probs_index = vp9_read_literal(bc, 3); cm->kf_ymode_probs_index = vp9_read_literal(r, 3);
} else { } else {
int i;
if (cm->mcomp_filter_type == SWITCHABLE) if (cm->mcomp_filter_type == SWITCHABLE)
read_switchable_interp_probs(pbi, bc); read_switchable_interp_probs(pbi, r);
#if CONFIG_COMP_INTERINTRA_PRED #if CONFIG_COMP_INTERINTRA_PRED
if (cm->use_interintra) { if (cm->use_interintra) {
if (vp9_read(bc, VP9_UPD_INTERINTRA_PROB)) if (vp9_read(r, VP9_UPD_INTERINTRA_PROB))
cm->fc.interintra_prob = vp9_read_prob(bc); cm->fc.interintra_prob = vp9_read_prob(r);
} }
#endif #endif
// Decode the baseline probabilities for decoding reference frame // Baseline probabilities for decoding reference frame
cm->prob_intra_coded = vp9_read_prob(bc); cm->prob_intra_coded = vp9_read_prob(r);
cm->prob_last_coded = vp9_read_prob(bc); cm->prob_last_coded = vp9_read_prob(r);
cm->prob_gf_coded = vp9_read_prob(bc); cm->prob_gf_coded = vp9_read_prob(r);
// Computes a modified set of probabilities for use when reference // Computes a modified set of probabilities for use when reference
// frame prediction fails. // frame prediction fails.
vp9_compute_mod_refprobs(cm); vp9_compute_mod_refprobs(cm);
cm->comp_pred_mode = vp9_read_bit(bc); cm->comp_pred_mode = read_comp_pred_mode(r);
if (cm->comp_pred_mode) if (cm->comp_pred_mode == HYBRID_PREDICTION)
cm->comp_pred_mode += vp9_read_bit(bc);
if (cm->comp_pred_mode == HYBRID_PREDICTION) {
int i;
for (i = 0; i < COMP_PRED_CONTEXTS; i++) for (i = 0; i < COMP_PRED_CONTEXTS; i++)
cm->prob_comppred[i] = vp9_read_prob(bc); cm->prob_comppred[i] = vp9_read_prob(r);
}
if (vp9_read_bit(bc)) { // VP9_YMODES
int i; if (vp9_read_bit(r))
for (i = 0; i < VP9_YMODES - 1; ++i) for (i = 0; i < VP9_YMODES - 1; ++i)
cm->fc.ymode_prob[i] = vp9_read_prob(bc); cm->fc.ymode_prob[i] = vp9_read_prob(r);
}
if (vp9_read_bit(bc)) { // VP9_I32X32_MODES
int i; if (vp9_read_bit(r))
for (i = 0; i < VP9_I32X32_MODES - 1; ++i) for (i = 0; i < VP9_I32X32_MODES - 1; ++i)
cm->fc.sb_ymode_prob[i] = vp9_read_prob(bc); cm->fc.sb_ymode_prob[i] = vp9_read_prob(r);
}
read_nmvprobs(bc, nmvc, xd->allow_high_precision_mv); read_nmvprobs(r, &cm->fc.nmvc, pbi->mb.allow_high_precision_mv);
} }
} }
@ -1129,18 +1117,17 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
} }
} }
void vp9_decode_mode_mvs_init(VP9D_COMP* const pbi, BOOL_DECODER* const bc) { void vp9_decode_mode_mvs_init(VP9D_COMP* const pbi, vp9_reader *r) {
VP9_COMMON *cm = &pbi->common; VP9_COMMON *cm = &pbi->common;
vpx_memset(cm->mbskip_pred_probs, 0, sizeof(cm->mbskip_pred_probs)); vpx_memset(cm->mbskip_pred_probs, 0, sizeof(cm->mbskip_pred_probs));
if (pbi->common.mb_no_coeff_skip) { if (pbi->common.mb_no_coeff_skip) {
int k; int k;
for (k = 0; k < MBSKIP_CONTEXTS; ++k) { for (k = 0; k < MBSKIP_CONTEXTS; ++k)
cm->mbskip_pred_probs[k] = vp9_read_prob(bc); cm->mbskip_pred_probs[k] = vp9_read_prob(r);
}
} }
mb_mode_mv_init(pbi, bc); mb_mode_mv_init(pbi, r);
} }
#if CONFIG_CODE_NONZEROCOUNT #if CONFIG_CODE_NONZEROCOUNT