set_mi_row_col: Refactor functions and their calls.

BUG=aomedia:442

Change-Id: Ic5e4bb170ab7fd68355008cc4155e1a8910f344e
This commit is contained in:
Urvang Joshi 2017-04-27 15:41:47 -07:00
Родитель 78f4d0c39d
Коммит 359dc2b9a6
6 изменённых файлов: 81 добавлений и 131 удалений

Просмотреть файл

@ -601,68 +601,32 @@ static INLINE void set_plane_n4(MACROBLOCKD *const xd, int bw, int bh) {
}
}
static INLINE void set_mi_row_col(MACROBLOCKD *xd, const TileInfo *const tile,
int mi_row, int bh, int mi_col, int bw,
#if CONFIG_DEPENDENT_HORZTILES
static INLINE void set_mi_row_col(MACROBLOCKD *xd, const TileInfo *const tile,
int mi_row, int bh, int mi_col, int bw,
int mi_rows, int mi_cols,
int dependent_horz_tile_flag) {
xd->mb_to_top_edge = -((mi_row * MI_SIZE) * 8);
xd->mb_to_bottom_edge = ((mi_rows - bh - mi_row) * MI_SIZE) * 8;
xd->mb_to_left_edge = -((mi_col * MI_SIZE) * 8);
xd->mb_to_right_edge = ((mi_cols - bw - mi_col) * MI_SIZE) * 8;
if (dependent_horz_tile_flag) {
#if CONFIG_TILE_GROUPS
xd->up_available = (mi_row > tile->mi_row_start) || !tile->tg_horz_boundary;
#else
xd->up_available = (mi_row > 0);
#endif
} else {
// Are edges available for intra prediction?
xd->up_available = (mi_row > tile->mi_row_start);
}
xd->left_available = (mi_col > tile->mi_col_start);
if (xd->up_available) {
xd->above_mi = xd->mi[-xd->mi_stride];
// above_mi may be NULL in encoder's first pass.
xd->above_mbmi = xd->above_mi ? &xd->above_mi->mbmi : NULL;
} else {
xd->above_mi = NULL;
xd->above_mbmi = NULL;
}
if (xd->left_available) {
xd->left_mi = xd->mi[-1];
// left_mi may be NULL in encoder's first pass.
xd->left_mbmi = xd->left_mi ? &xd->left_mi->mbmi : NULL;
} else {
xd->left_mi = NULL;
xd->left_mbmi = NULL;
}
xd->n8_h = bh;
xd->n8_w = bw;
#if CONFIG_REF_MV
xd->is_sec_rect = 0;
if (xd->n8_w < xd->n8_h)
if (mi_col & (xd->n8_h - 1)) xd->is_sec_rect = 1;
if (xd->n8_w > xd->n8_h)
if (mi_row & (xd->n8_w - 1)) xd->is_sec_rect = 1;
#endif
}
#else
static INLINE void set_mi_row_col(MACROBLOCKD *xd, const TileInfo *const tile,
int mi_row, int bh, int mi_col, int bw,
int dependent_horz_tile_flag,
#endif // CONFIG_DEPENDENT_HORZTILES
int mi_rows, int mi_cols) {
xd->mb_to_top_edge = -((mi_row * MI_SIZE) * 8);
xd->mb_to_bottom_edge = ((mi_rows - bh - mi_row) * MI_SIZE) * 8;
xd->mb_to_left_edge = -((mi_col * MI_SIZE) * 8);
xd->mb_to_right_edge = ((mi_cols - bw - mi_col) * MI_SIZE) * 8;
// Are edges available for intra prediction?
xd->up_available = (mi_row > tile->mi_row_start);
#if CONFIG_DEPENDENT_HORZTILES
if (dependent_horz_tile_flag) {
#if CONFIG_TILE_GROUPS
xd->up_available = (mi_row > tile->mi_row_start) || !tile->tg_horz_boundary;
#else
xd->up_available = (mi_row > 0);
#endif // CONFIG_TILE_GROUPS
} else {
#endif // CONFIG_DEPENDENT_HORZTILES
// Are edges available for intra prediction?
xd->up_available = (mi_row > tile->mi_row_start);
#if CONFIG_DEPENDENT_HORZTILES
}
#endif // CONFIG_DEPENDENT_HORZTILES
xd->left_available = (mi_col > tile->mi_col_start);
if (xd->up_available) {
xd->above_mi = xd->mi[-xd->mi_stride];
@ -691,9 +655,8 @@ static INLINE void set_mi_row_col(MACROBLOCKD *xd, const TileInfo *const tile,
if (xd->n8_w > xd->n8_h)
if (mi_row & (xd->n8_w - 1)) xd->is_sec_rect = 1;
#endif
#endif // CONFIG_REF_MV
}
#endif
static INLINE const aom_prob *get_y_mode_probs(const AV1_COMMON *cm,
const MODE_INFO *mi,

Просмотреть файл

@ -718,14 +718,13 @@ static void set_offsets(AV1_COMMON *const cm, MACROBLOCKD *const xd,
xd->max_tx_size = max_txsize_lookup[bsize];
#endif
// Distance of Mb to the various image edges. These are specified to 8th pel
// as they are always compared to values that are in 1/8th pel units
// Distance of Mb to the various image edges. These are specified to 8th pel
// as they are always compared to values that are in 1/8th pel units
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw,
#if CONFIG_DEPENDENT_HORZTILES
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols,
cm->dependent_horz_tiles);
#else
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols);
#endif
cm->dependent_horz_tiles,
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
av1_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col);
}
@ -745,13 +744,11 @@ static MB_MODE_INFO *set_offsets_extend(AV1_COMMON *const cm,
const int offset = mi_row_ori * cm->mi_stride + mi_col_ori;
xd->mi = cm->mi_grid_visible + offset;
xd->mi[0] = cm->mi + offset;
set_mi_row_col(xd, tile, mi_row_pred, bh, mi_col_pred, bw,
#if CONFIG_DEPENDENT_HORZTILES
set_mi_row_col(xd, tile, mi_row_pred, bh, mi_col_pred, bw, cm->mi_rows,
cm->mi_cols, cm->dependent_horz_tiles);
#else
set_mi_row_col(xd, tile, mi_row_pred, bh, mi_col_pred, bw, cm->mi_rows,
cm->mi_cols);
#endif
cm->dependent_horz_tiles,
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
xd->up_available = (mi_row_ori > tile->mi_row_start);
xd->left_available = (mi_col_ori > tile->mi_col_start);
@ -775,12 +772,11 @@ static MB_MODE_INFO *set_mb_offsets(AV1_COMMON *const cm, MACROBLOCKD *const xd,
for (y = 0; y < y_mis; ++y)
for (x = !y; x < x_mis; ++x) xd->mi[y * cm->mi_stride + x] = xd->mi[0];
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw,
#if CONFIG_DEPENDENT_HORZTILES
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols,
cm->dependent_horz_tiles);
#else
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols);
#endif
cm->dependent_horz_tiles,
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
return &xd->mi[0]->mbmi;
}
#endif
@ -797,12 +793,11 @@ static void set_offsets_topblock(AV1_COMMON *const cm, MACROBLOCKD *const xd,
set_plane_n4(xd, bw, bh);
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw,
#if CONFIG_DEPENDENT_HORZTILES
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols,
cm->dependent_horz_tiles);
#else
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols);
#endif
cm->dependent_horz_tiles,
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
av1_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col);
}
@ -2277,14 +2272,12 @@ static void decode_partition(AV1Decoder *const pbi, MACROBLOCKD *const xd,
xd->mi = cm->mi_grid_visible + offset;
xd->mi[0] = cm->mi + offset;
set_mi_row_col(xd, tile, mi_row, mi_size_high[bsize], mi_col,
mi_size_wide[bsize],
#if CONFIG_DEPENDENT_HORZTILES
set_mi_row_col(xd, tile, mi_row, mi_size_high[bsize], mi_col,
mi_size_wide[bsize], cm->mi_rows, cm->mi_cols,
cm->dependent_horz_tiles);
#else
set_mi_row_col(xd, tile, mi_row, mi_size_high[bsize], mi_col,
mi_size_wide[bsize], cm->mi_rows, cm->mi_cols);
#endif
cm->dependent_horz_tiles,
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
set_skip_context(xd, mi_row, mi_col);
skip = read_skip(cm, xd, xd->mi[0]->mbmi.segment_id_supertx, r);
if (skip) {

Просмотреть файл

@ -2313,12 +2313,11 @@ static void write_mbmi_b(AV1_COMP *cpi, const TileInfo *const tile,
cpi->td.mb.mbmi_ext = cpi->mbmi_ext_base + (mi_row * cm->mi_cols + mi_col);
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw,
#if CONFIG_DEPENDENT_HORZTILES
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols,
cm->dependent_horz_tiles);
#else
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols);
#endif
cm->dependent_horz_tiles,
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
if (frame_is_intra_only(cm)) {
write_mb_modes_kf(cm, xd, mi_row, mi_col, w);
@ -2389,12 +2388,11 @@ static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile,
bw = mi_size_wide[mbmi->sb_type];
cpi->td.mb.mbmi_ext = cpi->mbmi_ext_base + (mi_row * cm->mi_cols + mi_col);
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw,
#if CONFIG_DEPENDENT_HORZTILES
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols,
cm->dependent_horz_tiles);
#else
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols);
#endif
cm->dependent_horz_tiles,
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
#if CONFIG_PALETTE
for (plane = 0; plane <= 1; ++plane) {
@ -2806,14 +2804,12 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
#if CONFIG_SUPERTX
mbmi = &cm->mi_grid_visible[mi_offset]->mbmi;
xd->mi = cm->mi_grid_visible + mi_offset;
set_mi_row_col(xd, tile, mi_row, mi_size_high[bsize], mi_col,
mi_size_wide[bsize],
#if CONFIG_DEPENDENT_HORZTILES
set_mi_row_col(xd, tile, mi_row, mi_size_high[bsize], mi_col,
mi_size_wide[bsize], cm->mi_rows, cm->mi_cols,
cm->dependent_horz_tiles);
#else
set_mi_row_col(xd, tile, mi_row, mi_size_high[bsize], mi_col,
mi_size_wide[bsize], cm->mi_rows, cm->mi_cols);
#endif
cm->dependent_horz_tiles,
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
if (!supertx_enabled && !frame_is_intra_only(cm) &&
partition != PARTITION_NONE && bsize <= MAX_SUPERTX_BLOCK_SIZE &&
!xd->lossless[0]) {
@ -2903,13 +2899,11 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
xd->mi = cm->mi_grid_visible + mi_offset;
supertx_size = mbmi->tx_size;
set_mi_row_col(xd, tile, mi_row, bsh, mi_col, bsw,
#if CONFIG_DEPENDENT_HORZTILES
set_mi_row_col(xd, tile, mi_row, bsh, mi_col, bsw, cm->mi_rows, cm->mi_cols,
cm->dependent_horz_tiles);
#else
set_mi_row_col(xd, tile, mi_row, bsh, mi_col, bsw, cm->mi_rows,
cm->mi_cols);
#endif
cm->dependent_horz_tiles,
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
assert(IMPLIES(!cm->seg.enabled, mbmi->segment_id_supertx == 0));
assert(mbmi->segment_id_supertx < MAX_SEGMENTS);

Просмотреть файл

@ -299,13 +299,11 @@ static void set_offsets_without_segment_id(const AV1_COMP *const cpi,
// Set up distance of MB to edge of frame in 1/8th pel units.
assert(!(mi_col & (mi_width - 1)) && !(mi_row & (mi_height - 1)));
set_mi_row_col(xd, tile, mi_row, mi_height, mi_col, mi_width,
#if CONFIG_DEPENDENT_HORZTILES
set_mi_row_col(xd, tile, mi_row, mi_height, mi_col, mi_width, cm->mi_rows,
cm->mi_cols, cm->dependent_horz_tiles);
#else
set_mi_row_col(xd, tile, mi_row, mi_height, mi_col, mi_width, cm->mi_rows,
cm->mi_cols);
#endif
cm->dependent_horz_tiles,
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
// Set up source buffers.
av1_setup_src_planes(x, cpi->source, mi_row, mi_col);
@ -364,8 +362,11 @@ static void set_offsets_supertx(const AV1_COMP *const cpi, ThreadData *td,
// Set up distance of MB to edge of frame in 1/8th pel units.
assert(!(mi_col & (mi_width - 1)) && !(mi_row & (mi_height - 1)));
set_mi_row_col(xd, tile, mi_row, mi_height, mi_col, mi_width, cm->mi_rows,
cm->mi_cols);
set_mi_row_col(xd, tile, mi_row, mi_height, mi_col, mi_width,
#if CONFIG_DEPENDENT_HORZTILES
cm->dependent_horz_tiles,
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
}
static void set_offsets_extend(const AV1_COMP *const cpi, ThreadData *td,
@ -405,6 +406,9 @@ static void set_offsets_extend(const AV1_COMP *const cpi, ThreadData *td,
!(mi_row_pred & (mi_height - mi_size_high[BLOCK_8X8])));
#endif
set_mi_row_col(xd, tile, mi_row_pred, mi_height, mi_col_pred, mi_width,
#if CONFIG_DEPENDENT_HORZTILES
cm->dependent_horz_tiles,
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
xd->up_available = (mi_row_ori > tile->mi_row_start);
xd->left_available = (mi_col_ori > tile->mi_col_start);

Просмотреть файл

@ -642,15 +642,12 @@ void av1_first_pass(AV1_COMP *cpi, const struct lookahead_entry *source) {
xd->left_available = (mb_col != 0);
xd->mi[0]->mbmi.sb_type = bsize;
xd->mi[0]->mbmi.ref_frame[0] = INTRA_FRAME;
set_mi_row_col(xd, &tile, mb_row * mb_scale, mi_size_high[bsize],
mb_col * mb_scale, mi_size_wide[bsize],
#if CONFIG_DEPENDENT_HORZTILES
set_mi_row_col(xd, &tile, mb_row * mb_scale, mi_size_high[bsize],
mb_col * mb_scale, mi_size_wide[bsize], cm->mi_rows,
cm->mi_cols, cm->dependent_horz_tiles);
#else
set_mi_row_col(xd, &tile, mb_row * mb_scale, mi_size_high[bsize],
mb_col * mb_scale, mi_size_wide[bsize], cm->mi_rows,
cm->mi_cols);
#endif
cm->dependent_horz_tiles,
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
set_plane_n4(xd, mi_size_wide[bsize], mi_size_high[bsize]);

Просмотреть файл

@ -129,12 +129,11 @@ static void count_segs(const AV1_COMMON *cm, MACROBLOCKD *xd,
xd->mi = mi;
segment_id = xd->mi[0]->mbmi.segment_id;
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw,
#if CONFIG_DEPENDENT_HORZTILES
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols,
cm->dependent_horz_tiles);
#else
set_mi_row_col(xd, tile, mi_row, bh, mi_col, bw, cm->mi_rows, cm->mi_cols);
#endif
cm->dependent_horz_tiles,
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
// Count the number of hits on each segment with no prediction
no_pred_segcounts[segment_id]++;