Commit 26fead7e authored by Paul Wilkins's avatar Paul Wilkins

Renaming in MB_MODE_INFO

The macro block mode info context originally contained an
entry for each 16x16 macroblock. In VP9 each entry refers
to an 8x8 region not a macro block, so the naming is misleading.

This first stage clean up changes the names of 3 entries in the
structure to remove the mb_ prefix.

TODO clean up the nomenclature more widely in respect of
mbmi and bmi.

Change-Id: Ia7305c6d0cb805dfe8cdc98dad21338f502e49c6
parent 54979b43
......@@ -38,7 +38,7 @@ void vp9_update_mode_info_in_image(VP9_COMMON *cm, MODE_INFO *mi) {
for (i = 0; i < cm->mi_rows; i++) {
MODE_INFO *ptr = mi;
for (j = 0; j < cm->mi_cols; j++) {
ptr->mbmi.mb_in_image = 1;
ptr->mbmi.in_image = 1;
ptr++; // Next element in the row
}
......
......@@ -130,6 +130,7 @@ static INLINE int mi_height_log2(BLOCK_SIZE_TYPE sb_type) {
return mi_height_log2_lookup[sb_type];
}
// This structure now relates to 8x8 block regions.
typedef struct {
MB_PREDICTION_MODE mode, uv_mode;
MV_REFERENCE_FRAME ref_frame[2];
......@@ -138,18 +139,17 @@ typedef struct {
int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES];
int_mv best_mv, best_second_mv;
uint8_t mb_mode_context[MAX_REF_FRAMES];
uint8_t mode_context[MAX_REF_FRAMES];
unsigned char mb_skip_coeff; /* does this mb has coefficients at all, 1=no coefficients, 0=need decode tokens */
unsigned char segment_id; // Segment id for current frame
unsigned char skip_coeff; // 0=need to decode coeffs, 1=no coefficients
unsigned char segment_id; // Segment id for this block.
// Flags used for prediction status of various bit-stream signals
unsigned char seg_id_predicted;
// Indicates if the mb is part of the image (1) vs border (0)
// This can be useful in determining whether the MB provides
// a valid predictor
unsigned char mb_in_image;
// Indicates if the block is part of the image (1) vs border (0)
// This can be useful in determining whether it provides a valid predictor
unsigned char in_image;
INTERPOLATIONFILTERTYPE interp_filter;
......
......@@ -57,7 +57,7 @@ void vp9_print_modes_and_motion_vectors(VP9_COMMON *cm, char *file) {
print_mi_data(cm, mvs, "Partitions:", offsetof(MB_MODE_INFO, sb_type));
print_mi_data(cm, mvs, "Modes:", offsetof(MB_MODE_INFO, mode));
print_mi_data(cm, mvs, "Skips:", offsetof(MB_MODE_INFO, mb_skip_coeff));
print_mi_data(cm, mvs, "Skips:", offsetof(MB_MODE_INFO, skip_coeff));
print_mi_data(cm, mvs, "Ref frame:", offsetof(MB_MODE_INFO, ref_frame[0]));
print_mi_data(cm, mvs, "Transform:", offsetof(MB_MODE_INFO, txfm_size));
print_mi_data(cm, mvs, "UV Modes:", offsetof(MB_MODE_INFO, uv_mode));
......
......@@ -263,7 +263,7 @@ static void filter_block_plane(VP9_COMMON *const cm,
// Determine the vertical edges that need filtering
for (c = 0; c < MI_BLOCK_SIZE && mi_col + c < cm->mi_cols; c += col_step) {
const int skip_this = mi[c].mbmi.mb_skip_coeff
const int skip_this = mi[c].mbmi.skip_coeff
&& is_inter_block(&mi[c].mbmi);
// left edge of current unit is block/partition edge -> no skip
const int block_edge_left = b_width_log2(mi[c].mbmi.sb_type) ?
......
......@@ -281,7 +281,7 @@ void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
Done:
mbmi->mb_mode_context[ref_frame] = counter_to_context[context_counter];
mbmi->mode_context[ref_frame] = counter_to_context[context_counter];
// Clamp vectors
for (idx = 0; idx < MAX_MV_REF_CANDIDATES; ++idx)
......
......@@ -737,7 +737,7 @@ int vp9_post_proc_frame(struct VP9Common *oci,
char zz[4];
int dc_diff = !(mi[mb_index].mbmi.mode != I4X4_PRED &&
mi[mb_index].mbmi.mode != SPLITMV &&
mi[mb_index].mbmi.mb_skip_coeff);
mi[mb_index].mbmi.skip_coeff);
if (oci->frame_type == KEY_FRAME)
sprintf(zz, "a");
......
......@@ -21,8 +21,8 @@ unsigned char vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd) {
const MODE_INFO *const mi = xd->mode_info_context;
const MB_MODE_INFO *const above_mbmi = &mi[-xd->mode_info_stride].mbmi;
const MB_MODE_INFO *const left_mbmi = &mi[-1].mbmi;
const int left_in_image = xd->left_available && left_mbmi->mb_in_image;
const int above_in_image = xd->up_available && above_mbmi->mb_in_image;
const int left_in_image = xd->left_available && left_mbmi->in_image;
const int above_in_image = xd->up_available && above_mbmi->in_image;
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
......@@ -56,8 +56,8 @@ unsigned char vp9_get_pred_context_intra_inter(const MACROBLOCKD *xd) {
const MODE_INFO *const mi = xd->mode_info_context;
const MB_MODE_INFO *const above_mbmi = &mi[-xd->mode_info_stride].mbmi;
const MB_MODE_INFO *const left_mbmi = &mi[-1].mbmi;
const int left_in_image = xd->left_available && left_mbmi->mb_in_image;
const int above_in_image = xd->up_available && above_mbmi->mb_in_image;
const int left_in_image = xd->left_available && left_mbmi->in_image;
const int above_in_image = xd->up_available && above_mbmi->in_image;
const int left_intra = !is_inter_block(left_mbmi);
const int above_intra = !is_inter_block(above_mbmi);
......@@ -83,8 +83,8 @@ unsigned char vp9_get_pred_context_comp_inter_inter(const VP9_COMMON *cm,
const MODE_INFO *const mi = xd->mode_info_context;
const MB_MODE_INFO *const above_mbmi = &mi[-cm->mode_info_stride].mbmi;
const MB_MODE_INFO *const left_mbmi = &mi[-1].mbmi;
const int left_in_image = xd->left_available && left_mbmi->mb_in_image;
const int above_in_image = xd->up_available && above_mbmi->mb_in_image;
const int left_in_image = xd->left_available && left_mbmi->in_image;
const int above_in_image = xd->up_available && above_mbmi->in_image;
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
......@@ -128,8 +128,8 @@ unsigned char vp9_get_pred_context_comp_ref_p(const VP9_COMMON *cm,
const MODE_INFO *const mi = xd->mode_info_context;
const MB_MODE_INFO *const above_mbmi = &mi[-cm->mode_info_stride].mbmi;
const MB_MODE_INFO *const left_mbmi = &mi[-1].mbmi;
const int left_in_image = xd->left_available && left_mbmi->mb_in_image;
const int above_in_image = xd->up_available && above_mbmi->mb_in_image;
const int left_in_image = xd->left_available && left_mbmi->in_image;
const int above_in_image = xd->up_available && above_mbmi->in_image;
const int left_intra = !is_inter_block(left_mbmi);
const int above_intra = !is_inter_block(above_mbmi);
......@@ -206,8 +206,8 @@ unsigned char vp9_get_pred_context_single_ref_p1(const MACROBLOCKD *xd) {
const MODE_INFO *const mi = xd->mode_info_context;
const MB_MODE_INFO *const above_mbmi = &mi[-xd->mode_info_stride].mbmi;
const MB_MODE_INFO *const left_mbmi = &mi[-1].mbmi;
const int left_in_image = xd->left_available && left_mbmi->mb_in_image;
const int above_in_image = xd->up_available && above_mbmi->mb_in_image;
const int left_in_image = xd->left_available && left_mbmi->in_image;
const int above_in_image = xd->up_available && above_mbmi->in_image;
const int left_intra = !is_inter_block(left_mbmi);
const int above_intra = !is_inter_block(above_mbmi);
......@@ -271,8 +271,8 @@ unsigned char vp9_get_pred_context_single_ref_p2(const MACROBLOCKD *xd) {
const MODE_INFO *const mi = xd->mode_info_context;
const MB_MODE_INFO *const above_mbmi = &mi[-xd->mode_info_stride].mbmi;
const MB_MODE_INFO *const left_mbmi = &mi[-1].mbmi;
const int left_in_image = xd->left_available && left_mbmi->mb_in_image;
const int above_in_image = xd->up_available && above_mbmi->mb_in_image;
const int left_in_image = xd->left_available && left_mbmi->in_image;
const int above_in_image = xd->up_available && above_mbmi->in_image;
const int left_intra = !is_inter_block(left_mbmi);
const int above_intra = !is_inter_block(above_mbmi);
......@@ -361,18 +361,18 @@ unsigned char vp9_get_pred_context_tx_size(const MACROBLOCKD *xd) {
const MODE_INFO *const mi = xd->mode_info_context;
const MB_MODE_INFO *const above_mbmi = &mi[-xd->mode_info_stride].mbmi;
const MB_MODE_INFO *const left_mbmi = &mi[-1].mbmi;
const int left_in_image = xd->left_available && left_mbmi->mb_in_image;
const int above_in_image = xd->up_available && above_mbmi->mb_in_image;
const int left_in_image = xd->left_available && left_mbmi->in_image;
const int above_in_image = xd->up_available && above_mbmi->in_image;
const int max_tx_size = max_txsize_lookup[mi->mbmi.sb_type];
int above_context = max_tx_size;
int left_context = max_tx_size;
if (above_in_image)
above_context = above_mbmi->mb_skip_coeff ? max_tx_size
above_context = above_mbmi->skip_coeff ? max_tx_size
: above_mbmi->txfm_size;
if (left_in_image)
left_context = left_mbmi->mb_skip_coeff ? max_tx_size
left_context = left_mbmi->skip_coeff ? max_tx_size
: left_mbmi->txfm_size;
if (!left_in_image)
......@@ -409,7 +409,7 @@ void vp9_set_pred_flag_mbskip(VP9_COMMON *cm, BLOCK_SIZE_TYPE bsize,
for (y = 0; y < ymis; y++)
for (x = 0; x < xmis; x++)
mi[y * cm->mode_info_stride + x].mbmi.mb_skip_coeff = pred_flag;
mi[y * cm->mode_info_stride + x].mbmi.skip_coeff = pred_flag;
}
int vp9_get_segment_id(VP9_COMMON *cm, const uint8_t *segment_ids,
......
......@@ -39,8 +39,8 @@ static INLINE int vp9_get_pred_context_mbskip(const MACROBLOCKD *xd) {
const MB_MODE_INFO *const above_mbmi = &mi[-xd->mode_info_stride].mbmi;
const MB_MODE_INFO *const left_mbmi = &mi[-1].mbmi;
return above_mbmi->mb_skip_coeff +
(xd->left_available ? left_mbmi->mb_skip_coeff : 0);
return above_mbmi->skip_coeff +
(xd->left_available ? left_mbmi->skip_coeff : 0);
}
static INLINE vp9_prob vp9_get_pred_prob_mbskip(const VP9_COMMON *cm,
......@@ -49,7 +49,7 @@ static INLINE vp9_prob vp9_get_pred_prob_mbskip(const VP9_COMMON *cm,
}
static INLINE unsigned char vp9_get_pred_flag_mbskip(const MACROBLOCKD *xd) {
return xd->mode_info_context->mbmi.mb_skip_coeff;
return xd->mode_info_context->mbmi.skip_coeff;
}
void vp9_set_pred_flag_mbskip(VP9_COMMON *cm, BLOCK_SIZE_TYPE bsize,
......
......@@ -159,7 +159,7 @@ static void read_intra_frame_mode_info(VP9D_COMP *pbi, MODE_INFO *m,
const int mis = cm->mode_info_stride;
mbmi->segment_id = read_intra_segment_id(pbi, mi_row, mi_col, r);
mbmi->mb_skip_coeff = read_skip_coeff(pbi, mbmi->segment_id, r);
mbmi->skip_coeff = read_skip_coeff(pbi, mbmi->segment_id, r);
mbmi->txfm_size = read_tx_size(pbi, cm->tx_mode, bsize, 1, r);
mbmi->ref_frame[0] = INTRA_FRAME;
mbmi->ref_frame[1] = NONE;
......@@ -457,7 +457,7 @@ static void read_inter_block_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
ref0, mbmi->ref_mvs[ref0], cm->ref_frame_sign_bias,
mi_row, mi_col);
inter_mode_ctx = mbmi->mb_mode_context[ref0];
inter_mode_ctx = mbmi->mode_context[ref0];
if (vp9_segfeature_active(&xd->seg, mbmi->segment_id, SEG_LVL_SKIP))
mbmi->mode = ZEROMV;
......@@ -598,10 +598,10 @@ static void read_inter_frame_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
mbmi->mv[0].as_int = 0;
mbmi->mv[1].as_int = 0;
mbmi->segment_id = read_inter_segment_id(pbi, mi_row, mi_col, r);
mbmi->mb_skip_coeff = read_skip_coeff(pbi, mbmi->segment_id, r);
mbmi->skip_coeff = read_skip_coeff(pbi, mbmi->segment_id, r);
inter_block = read_is_inter_block(pbi, mbmi->segment_id, r);
mbmi->txfm_size = read_tx_size(pbi, cm->tx_mode, mbmi->sb_type,
!mbmi->mb_skip_coeff || !inter_block, r);
!mbmi->skip_coeff || !inter_block, r);
if (inter_block)
read_inter_block_mode_info(pbi, mi, mi_row, mi_col, r);
......
......@@ -157,7 +157,7 @@ static void decode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize,
dst, pd->dst.stride);
// Early exit if there are no coefficients
if (mi->mbmi.mb_skip_coeff)
if (mi->mbmi.skip_coeff)
return;
decode_block(plane, block, bsize, ss_txfrm_size, arg);
......@@ -166,7 +166,7 @@ static void decode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize,
static int decode_tokens(VP9D_COMP *pbi, BLOCK_SIZE_TYPE bsize, vp9_reader *r) {
MACROBLOCKD *const xd = &pbi->mb;
if (xd->mode_info_context->mbmi.mb_skip_coeff) {
if (xd->mode_info_context->mbmi.skip_coeff) {
reset_skip_context(xd, bsize);
return -1;
} else {
......
......@@ -216,7 +216,7 @@ static int write_skip_coeff(const VP9_COMP *cpi, int segment_id, MODE_INFO *m,
if (vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_SKIP)) {
return 1;
} else {
const int skip_coeff = m->mbmi.mb_skip_coeff;
const int skip_coeff = m->mbmi.skip_coeff;
vp9_write(w, skip_coeff, vp9_get_pred_prob_mbskip(&cpi->common, xd));
return skip_coeff;
}
......@@ -462,7 +462,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) {
} else {
vp9_prob *mv_ref_p;
encode_ref_frame(cpi, bc);
mv_ref_p = cpi->common.fc.inter_mode_probs[mi->mb_mode_context[rf]];
mv_ref_p = cpi->common.fc.inter_mode_probs[mi->mode_context[rf]];
#ifdef ENTROPY_STATS
active_section = 3;
......@@ -472,7 +472,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) {
if (!vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP)) {
if (bsize >= BLOCK_8X8) {
write_sb_mv_ref(bc, mode, mv_ref_p);
++pc->counts.inter_mode[mi->mb_mode_context[rf]]
++pc->counts.inter_mode[mi->mode_context[rf]]
[inter_mode_offset(mode)];
}
}
......@@ -499,7 +499,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) {
blockmode = x->partition_info->bmi[j].mode;
blockmv = m->bmi[j].as_mv[0];
write_sb_mv_ref(bc, blockmode, mv_ref_p);
++pc->counts.inter_mode[mi->mb_mode_context[rf]]
++pc->counts.inter_mode[mi->mode_context[rf]]
[inter_mode_offset(blockmode)];
if (blockmode == NEWMV) {
......
......@@ -1467,8 +1467,8 @@ static void rd_auto_partition_range(VP9_COMP *cpi,
const MODE_INFO *const mi = xd->mode_info_context;
const MB_MODE_INFO *const above_mbmi = &mi[-xd->mode_info_stride].mbmi;
const MB_MODE_INFO *const left_mbmi = &mi[-1].mbmi;
const int left_in_image = xd->left_available && left_mbmi->mb_in_image;
const int above_in_image = xd->up_available && above_mbmi->mb_in_image;
const int left_in_image = xd->left_available && left_mbmi->in_image;
const int above_in_image = xd->up_available && above_mbmi->in_image;
// Frequency check
if (cpi->sf.auto_min_max_partition_count <= 0) {
......@@ -2180,7 +2180,7 @@ static int get_skip_flag(MODE_INFO *mi, int mis, int ymbs, int xmbs) {
for (y = 0; y < ymbs; y++) {
for (x = 0; x < xmbs; x++) {
if (!mi[y * mis + x].mbmi.mb_skip_coeff)
if (!mi[y * mis + x].mbmi.skip_coeff)
return 0;
}
}
......@@ -2624,10 +2624,10 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled,
vp9_encode_sb(cm, x, MAX(bsize, BLOCK_8X8));
vp9_tokenize_sb(cpi, t, !output_enabled, MAX(bsize, BLOCK_8X8));
} else {
int mb_skip_context = xd->left_available ? (mi - 1)->mbmi.mb_skip_coeff : 0;
mb_skip_context += (mi - mis)->mbmi.mb_skip_coeff;
int mb_skip_context = xd->left_available ? (mi - 1)->mbmi.skip_coeff : 0;
mb_skip_context += (mi - mis)->mbmi.skip_coeff;
mbmi->mb_skip_coeff = 1;
mbmi->skip_coeff = 1;
if (output_enabled)
cm->counts.mbskip[mb_skip_context][1]++;
reset_skip_context(xd, MAX(bsize, BLOCK_8X8));
......@@ -2635,13 +2635,13 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled,
// copy skip flag on all mb_mode_info contexts in this SB
// if this was a skip at this txfm size
vp9_set_pred_flag_mbskip(cm, bsize, mi_row, mi_col, mi->mbmi.mb_skip_coeff);
vp9_set_pred_flag_mbskip(cm, bsize, mi_row, mi_col, mi->mbmi.skip_coeff);
if (output_enabled) {
if (cm->tx_mode == TX_MODE_SELECT &&
mbmi->sb_type >= BLOCK_8X8 &&
!(is_inter_block(mbmi) &&
(mbmi->mb_skip_coeff ||
(mbmi->skip_coeff ||
vp9_segfeature_active(&xd->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);
......
......@@ -1558,7 +1558,7 @@ static int labels2mode(MACROBLOCK *x, int i,
}
cost = cost_mv_ref(cpi, this_mode,
mbmi->mb_mode_context[mbmi->ref_frame[0]]);
mbmi->mode_context[mbmi->ref_frame[0]]);
mic->bmi[i].as_mv[0].as_int = this_mv->as_int;
if (mbmi->ref_frame[1] > 0)
......@@ -1791,7 +1791,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
frame_mv[this_mode][mbmi->ref_frame[0]].as_int == 0 &&
(mbmi->ref_frame[1] <= 0 ||
frame_mv[this_mode][mbmi->ref_frame[1]].as_int == 0)) {
int rfc = mbmi->mb_mode_context[mbmi->ref_frame[0]];
int rfc = mbmi->mode_context[mbmi->ref_frame[0]];
int c1 = cost_mv_ref(cpi, NEARMV, rfc);
int c2 = cost_mv_ref(cpi, NEARESTMV, rfc);
int c3 = cost_mv_ref(cpi, ZEROMV, rfc);
......@@ -2747,7 +2747,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
frame_mv[refs[0]].as_int == 0 &&
!vp9_segfeature_active(&xd->seg, mbmi->segment_id, SEG_LVL_SKIP) &&
(num_refs == 1 || frame_mv[refs[1]].as_int == 0)) {
int rfc = mbmi->mb_mode_context[mbmi->ref_frame[0]];
int rfc = mbmi->mode_context[mbmi->ref_frame[0]];
int c1 = cost_mv_ref(cpi, NEARMV, rfc);
int c2 = cost_mv_ref(cpi, NEARESTMV, rfc);
int c3 = cost_mv_ref(cpi, ZEROMV, rfc);
......@@ -2804,7 +2804,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
* words if you present them in that order, the second one is always known
* if the first is known */
*rate2 += cost_mv_ref(cpi, this_mode,
mbmi->mb_mode_context[mbmi->ref_frame[0]]);
mbmi->mode_context[mbmi->ref_frame[0]]);
if (!(*mode_excluded)) {
if (is_comp_pred) {
......
......@@ -278,8 +278,8 @@ void vp9_tokenize_sb(VP9_COMP *cpi, TOKENEXTRA **t, int dry_run,
SEG_LVL_SKIP);
struct tokenize_b_args arg = {cpi, xd, t, mbmi->txfm_size};
mbmi->mb_skip_coeff = vp9_sb_is_skippable(xd, bsize);
if (mbmi->mb_skip_coeff) {
mbmi->skip_coeff = vp9_sb_is_skippable(xd, bsize);
if (mbmi->skip_coeff) {
if (!dry_run)
cm->counts.mbskip[mb_skip_context][1] += skip_inc;
reset_skip_context(xd, bsize);
......
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