Commit c8079494 authored by Jingning Han's avatar Jingning Han
Browse files

Prevent left_block_mode stepping into left tile

This commit uses left_available flag to decide if the left mode_info
struct is available for left_block_mode. As discussed with James
Zern (jzern@), this prevents the codec from fetching mode_info from
blocks in the left tile, which although effectively not used might
present concerns for multi-threaded tile decoding.

This is NOT a bit-stream change.

Change-Id: I1dc8cf1bcbf056688eee27c7bc5706ac4b4e0125
parent 1e05c9a7
......@@ -41,26 +41,24 @@ void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm,
int block_idx, int ref_idx,
int mi_row, int mi_col);
static MB_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mb,
const MODE_INFO *left_mb, int b) {
static MB_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mi,
const MODE_INFO *left_mi, int b) {
// FIXME(rbultje, jingning): temporary hack because jenkins doesn't
// understand this condition. This will go away soon.
const MODE_INFO *mi = cur_mb;
if (b == 0 || b == 2) {
/* On L edge, get from MB to left of us */
mi = left_mb;
if (!mi)
if (!left_mi)
return DC_PRED;
if (is_inter_block(&mi->mbmi))
if (is_inter_block(&left_mi->mbmi))
return DC_PRED;
else
return mi->mbmi.sb_type < BLOCK_8X8 ? (mi->bmi + 1 + b)->as_mode
: mi->mbmi.mode;
return left_mi->mbmi.sb_type < BLOCK_8X8 ? left_mi->bmi[b + 1].as_mode
: left_mi->mbmi.mode;
}
assert(b == 1 || b == 3);
return (mi->bmi + b - 1)->as_mode;
return cur_mi->bmi[b - 1].as_mode;
}
static MB_PREDICTION_MODE above_block_mode(const MODE_INFO *cur_mb,
......
......@@ -169,6 +169,7 @@ static void read_intra_frame_mode_info(VP9_COMMON *const cm,
MB_MODE_INFO *const mbmi = &m->mbmi;
const BLOCK_SIZE bsize = mbmi->sb_type;
const MODE_INFO *above_mi = xd->mi_8x8[-cm->mode_info_stride];
const MODE_INFO *left_mi = xd->left_available ? xd->mi_8x8[-1] : NULL;
mbmi->segment_id = read_intra_segment_id(cm, xd, mi_row, mi_col, r);
mbmi->skip_coeff = read_skip_coeff(cm, xd, mbmi->segment_id, r);
......@@ -178,9 +179,7 @@ static void read_intra_frame_mode_info(VP9_COMMON *const cm,
if (bsize >= BLOCK_8X8) {
const MB_PREDICTION_MODE A = above_block_mode(m, above_mi, 0);
const MB_PREDICTION_MODE L = xd->left_available
? left_block_mode(m, xd->mi_8x8[-1], 0)
: DC_PRED;
const MB_PREDICTION_MODE L = left_block_mode(m, left_mi, 0);
mbmi->mode = read_intra_mode(r, vp9_kf_y_mode_prob[A][L]);
} else {
// Only 4x4, 4x8, 8x4 blocks
......@@ -192,9 +191,7 @@ static void read_intra_frame_mode_info(VP9_COMMON *const cm,
for (idx = 0; idx < 2; idx += num_4x4_w) {
const int ib = idy * 2 + idx;
const MB_PREDICTION_MODE A = above_block_mode(m, above_mi, ib);
const MB_PREDICTION_MODE L = (xd->left_available || idx)
? left_block_mode(m, xd->mi_8x8[-1], ib)
: DC_PRED;
const MB_PREDICTION_MODE L = left_block_mode(m, left_mi, ib);
const MB_PREDICTION_MODE b_mode = read_intra_mode(r,
vp9_kf_y_mode_prob[A][L]);
m->bmi[ib].as_mode = b_mode;
......
......@@ -526,7 +526,7 @@ static void write_mb_modes_kf(const VP9_COMP *cpi, MODE_INFO **mi_8x8,
const int ym = m->mbmi.mode;
const int segment_id = m->mbmi.segment_id;
MODE_INFO *above_mi = mi_8x8[-xd->mode_info_stride];
MODE_INFO *left_mi = mi_8x8[-1];
MODE_INFO *left_mi = xd->left_available ? mi_8x8[-1] : NULL;
if (seg->update_map)
write_segment_id(bc, seg, m->mbmi.segment_id);
......@@ -538,8 +538,7 @@ static void write_mb_modes_kf(const VP9_COMP *cpi, MODE_INFO **mi_8x8,
if (m->mbmi.sb_type >= BLOCK_8X8) {
const MB_PREDICTION_MODE A = above_block_mode(m, above_mi, 0);
const MB_PREDICTION_MODE L = xd->left_available ?
left_block_mode(m, left_mi, 0) : DC_PRED;
const MB_PREDICTION_MODE L = left_block_mode(m, left_mi, 0);
write_intra_mode(bc, ym, vp9_kf_y_mode_prob[A][L]);
} else {
int idx, idy;
......@@ -549,8 +548,7 @@ static void write_mb_modes_kf(const VP9_COMP *cpi, MODE_INFO **mi_8x8,
for (idx = 0; idx < 2; idx += num_4x4_blocks_wide) {
int i = idy * 2 + idx;
const MB_PREDICTION_MODE A = above_block_mode(m, above_mi, i);
const MB_PREDICTION_MODE L = (xd->left_available || idx) ?
left_block_mode(m, left_mi, i) : DC_PRED;
const MB_PREDICTION_MODE L = left_block_mode(m, left_mi, i);
const int bm = m->bmi[i].as_mode;
#ifdef ENTROPY_STATS
++intra_mode_stats[A][L][bm];
......
......@@ -1150,7 +1150,7 @@ static int64_t rd_pick_intra_sub_8x8_y_mode(VP9_COMP * const cpi,
MACROBLOCKD *const xd = &mb->e_mbd;
MODE_INFO *const mic = xd->mi_8x8[0];
const MODE_INFO *above_mi = xd->mi_8x8[-xd->mode_info_stride];
const MODE_INFO *left_mi = xd->mi_8x8[-1];
const MODE_INFO *left_mi = xd->left_available ? xd->mi_8x8[-1] : NULL;
const BLOCK_SIZE bsize = xd->mi_8x8[0]->mbmi.sb_type;
const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize];
const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bsize];
......@@ -1176,9 +1176,7 @@ static int64_t rd_pick_intra_sub_8x8_y_mode(VP9_COMP * const cpi,
i = idy * 2 + idx;
if (cpi->common.frame_type == KEY_FRAME) {
const MB_PREDICTION_MODE A = above_block_mode(mic, above_mi, i);
const MB_PREDICTION_MODE L = (xd->left_available || idx) ?
left_block_mode(mic, left_mi, i) :
DC_PRED;
const MB_PREDICTION_MODE L = left_block_mode(mic, left_mi, i);
bmode_costs = mb->y_mode_costs[A][L];
}
......@@ -1237,15 +1235,14 @@ static int64_t rd_pick_intra_sby_mode(VP9_COMP *cpi, MACROBLOCK *x,
for (mode = DC_PRED; mode <= TM_PRED; mode++) {
int64_t local_tx_cache[TX_MODES];
MODE_INFO *above_mi = xd->mi_8x8[-xd->mode_info_stride];
MODE_INFO *left_mi = xd->mi_8x8[-1];
MODE_INFO *left_mi = xd->left_available ? xd->mi_8x8[-1] : NULL;
if (!(cpi->sf.intra_y_mode_mask[max_txsize_lookup[bsize]] & (1 << mode)))
continue;
if (cpi->common.frame_type == KEY_FRAME) {
const MB_PREDICTION_MODE A = above_block_mode(mic, above_mi, 0);
const MB_PREDICTION_MODE L = xd->left_available ?
left_block_mode(mic, left_mi, 0) : DC_PRED;
const MB_PREDICTION_MODE L = left_block_mode(mic, left_mi, 0);
bmode_costs = x->y_mode_costs[A][L];
}
......
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