Commit 63963f51 authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

Renaming reference mode context calculation function.

Renames:
  vp9_get_pred_context_comp_inter_inter => vp9_get_reference_mode_context
  vp9_get_pred_prob_comp_inter_inter    => vp9_get_reference_mode_prob

Change-Id: I3bbb69481e6b0c848028667c9269f567f293d3bd
parent cf4dfdc8
......@@ -83,16 +83,14 @@ int vp9_get_intra_inter_context(const MACROBLOCKD *xd) {
else
return 0;
}
// Returns a context number for the given MB prediction signal
unsigned char vp9_get_pred_context_comp_inter_inter(const VP9_COMMON *cm,
const MACROBLOCKD *xd) {
int pred_context;
const MODE_INFO *const above_mi = get_above_mi(xd);
const MODE_INFO *const left_mi = get_left_mi(xd);
const MB_MODE_INFO *const above_mbmi = get_above_mbmi(above_mi);
const MB_MODE_INFO *const left_mbmi = get_left_mbmi(left_mi);
const int above_in_image = above_mi != NULL;
const int left_in_image = left_mi != NULL;
int vp9_get_reference_mode_context(const VP9_COMMON *cm,
const MACROBLOCKD *xd) {
int ctx;
const MB_MODE_INFO *const above_mbmi = get_above_mbmi(get_above_mi(xd));
const MB_MODE_INFO *const left_mbmi = get_left_mbmi(get_left_mi(xd));
const int above_in_image = above_mbmi != NULL;
const int left_in_image = left_mbmi != NULL;
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
......@@ -100,32 +98,32 @@ unsigned char vp9_get_pred_context_comp_inter_inter(const VP9_COMMON *cm,
if (above_in_image && left_in_image) { // both edges available
if (!has_second_ref(above_mbmi) && !has_second_ref(left_mbmi))
// neither edge uses comp pred (0/1)
pred_context = (above_mbmi->ref_frame[0] == cm->comp_fixed_ref) ^
(left_mbmi->ref_frame[0] == cm->comp_fixed_ref);
ctx = (above_mbmi->ref_frame[0] == cm->comp_fixed_ref) ^
(left_mbmi->ref_frame[0] == cm->comp_fixed_ref);
else if (!has_second_ref(above_mbmi))
// one of two edges uses comp pred (2/3)
pred_context = 2 + (above_mbmi->ref_frame[0] == cm->comp_fixed_ref ||
!is_inter_block(above_mbmi));
ctx = 2 + (above_mbmi->ref_frame[0] == cm->comp_fixed_ref ||
!is_inter_block(above_mbmi));
else if (!has_second_ref(left_mbmi))
// one of two edges uses comp pred (2/3)
pred_context = 2 + (left_mbmi->ref_frame[0] == cm->comp_fixed_ref ||
!is_inter_block(left_mbmi));
ctx = 2 + (left_mbmi->ref_frame[0] == cm->comp_fixed_ref ||
!is_inter_block(left_mbmi));
else // both edges use comp pred (4)
pred_context = 4;
ctx = 4;
} else if (above_in_image || left_in_image) { // one edge available
const MB_MODE_INFO *edge_mbmi = above_in_image ? above_mbmi : left_mbmi;
if (!has_second_ref(edge_mbmi))
// edge does not use comp pred (0/1)
pred_context = edge_mbmi->ref_frame[0] == cm->comp_fixed_ref;
ctx = edge_mbmi->ref_frame[0] == cm->comp_fixed_ref;
else
// edge uses comp pred (3)
pred_context = 3;
ctx = 3;
} else { // no edges available (1)
pred_context = 1;
ctx = 1;
}
assert(pred_context >= 0 && pred_context < COMP_INTER_CONTEXTS);
return pred_context;
assert(ctx >= 0 && ctx < COMP_INTER_CONTEXTS);
return ctx;
}
// Returns a context number for the given MB prediction signal
......
......@@ -68,15 +68,11 @@ static INLINE vp9_prob vp9_get_intra_inter_prob(const VP9_COMMON *cm,
return cm->fc.intra_inter_prob[vp9_get_intra_inter_context(xd)];
}
unsigned char vp9_get_pred_context_comp_inter_inter(const VP9_COMMON *cm,
const MACROBLOCKD *xd);
int vp9_get_reference_mode_context(const VP9_COMMON *cm, const MACROBLOCKD *xd);
static INLINE
vp9_prob vp9_get_pred_prob_comp_inter_inter(const VP9_COMMON *cm,
const MACROBLOCKD *xd) {
const int pred_context = vp9_get_pred_context_comp_inter_inter(cm, xd);
return cm->fc.comp_inter_prob[pred_context];
static INLINE vp9_prob vp9_get_reference_mode_prob(const VP9_COMMON *cm,
const MACROBLOCKD *xd) {
return cm->fc.comp_inter_prob[vp9_get_reference_mode_context(cm, xd)];
}
unsigned char vp9_get_pred_context_comp_ref_p(const VP9_COMMON *cm,
......
......@@ -258,10 +258,9 @@ static INLINE void read_mv(vp9_reader *r, MV *mv, const MV *ref,
mv->col = ref->col + diff.col;
}
static REFERENCE_MODE read_reference_mode(VP9_COMMON *cm,
const MACROBLOCKD *xd,
vp9_reader *r) {
const int ctx = vp9_get_pred_context_comp_inter_inter(cm, xd);
static REFERENCE_MODE read_reference_mode(VP9_COMMON *cm, const MACROBLOCKD *xd,
vp9_reader *r) {
const int ctx = vp9_get_reference_mode_context(cm, xd);
const int mode = vp9_read(r, cm->fc.comp_inter_prob[ctx]);
if (!cm->frame_parallel_decoding_mode)
++cm->counts.comp_inter[ctx][mode];
......
......@@ -233,10 +233,10 @@ static void encode_ref_frame(VP9_COMP *cpi, vp9_writer *bc) {
// (if not specified at the frame/segment level)
if (cm->comp_pred_mode == REFERENCE_MODE_SELECT) {
vp9_write(bc, mi->ref_frame[1] > INTRA_FRAME,
vp9_get_pred_prob_comp_inter_inter(cm, xd));
vp9_get_reference_mode_prob(cm, xd));
} else {
assert((mi->ref_frame[1] <= INTRA_FRAME) ==
(cm->comp_pred_mode == SINGLE_REFERENCE));
(cm->comp_pred_mode == SINGLE_REFERENCE));
}
if (mi->ref_frame[1] > INTRA_FRAME) {
......
......@@ -759,7 +759,7 @@ static void update_stats(VP9_COMP *cpi) {
// the reference frame counts used to work out probabilities.
if (is_inter_block(mbmi) && !seg_ref_active) {
if (cm->comp_pred_mode == REFERENCE_MODE_SELECT)
cpi->comp_inter_count[vp9_get_pred_context_comp_inter_inter(cm, xd)]
cpi->comp_inter_count[vp9_get_reference_mode_context(cm, xd)]
[has_second_ref(mbmi)]++;
if (has_second_ref(mbmi)) {
......
......@@ -2149,7 +2149,7 @@ static void estimate_ref_frame_costs(VP9_COMP *cpi, int segment_id,
vp9_prob comp_inter_p = 128;
if (cm->comp_pred_mode == REFERENCE_MODE_SELECT) {
comp_inter_p = vp9_get_pred_prob_comp_inter_inter(cm, xd);
comp_inter_p = vp9_get_reference_mode_prob(cm, xd);
*comp_mode_p = comp_inter_p;
} else {
*comp_mode_p = 128;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment