Commit c709e1f8 authored by Jingning Han's avatar Jingning Han

Separate num_8x8 table use case from mode_info table

Separate the use cases of number of 8x8 blocks from those of
mode_info array. This allows the mode_info array processing to be
scaled to 4x4 resolution.

Change-Id: Iab78f2540355ce7658d9ea21e902a86f71148d8f
parent e9dfcc7f
......@@ -53,6 +53,21 @@ static const uint8_t mi_height_log2_lookup[BLOCK_SIZES] = {
0, 0, 0, 0, 1, 0, 1, 2, 1, 2, 3, 2, 3, IF_EXT_PARTITION(4, 3, 4)
};
static const uint8_t mi_size_wide[BLOCK_SIZES] = {
#if CONFIG_CB4X4
1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16, IF_EXT_PARTITION(16, 32, 32)
#else
1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, IF_EXT_PARTITION(8, 16, 16)
#endif
};
static const uint8_t mi_size_high[BLOCK_SIZES] = {
#if CONFIG_CB4X4
1, 1, 1, 1, 2, 1, 2, 4, 2, 4, 8, 4, 8, 16, 8, 16, IF_EXT_PARTITION(32, 16, 32)
#else
1, 1, 1, 1, 2, 1, 2, 4, 2, 4, 8, 4, 8, IF_EXT_PARTITION(16, 8, 16)
#endif
};
// Width/height lookup tables in units of various block sizes
static const uint8_t block_size_wide[BLOCK_SIZES] = {
#if CONFIG_CB4X4
......
......@@ -175,8 +175,7 @@ static uint8_t scan_row_mbmi(const AV1_COMMON *cm, const MACROBLOCKD *xd,
const MODE_INFO *const candidate_mi =
xd->mi[mi_pos.row * xd->mi_stride + mi_pos.col];
const MB_MODE_INFO *const candidate = &candidate_mi->mbmi;
int len =
AOMMIN(xd->n8_w, num_8x8_blocks_wide_lookup[candidate->sb_type]);
int len = AOMMIN(xd->n8_w, mi_size_wide[candidate->sb_type]);
if (use_step_16) len = AOMMAX(2, len);
newmv_count += add_ref_mv_candidate(
candidate_mi, candidate, rf, refmv_count, ref_mv_stack,
......@@ -211,8 +210,7 @@ static uint8_t scan_col_mbmi(const AV1_COMMON *cm, const MACROBLOCKD *xd,
const MODE_INFO *const candidate_mi =
xd->mi[mi_pos.row * xd->mi_stride + mi_pos.col];
const MB_MODE_INFO *const candidate = &candidate_mi->mbmi;
int len =
AOMMIN(xd->n8_h, num_8x8_blocks_high_lookup[candidate->sb_type]);
int len = AOMMIN(xd->n8_h, mi_size_high[candidate->sb_type]);
if (use_step_16) len = AOMMAX(2, len);
newmv_count += add_ref_mv_candidate(
candidate_mi, candidate, rf, refmv_count, ref_mv_stack,
......@@ -513,12 +511,12 @@ static void find_mv_refs_idx(const AV1_COMMON *cm, const MACROBLOCKD *xd,
? cm->prev_frame->mvs + mi_row * cm->mi_cols + mi_col
: NULL;
const TileInfo *const tile = &xd->tile;
const int bw = num_8x8_blocks_wide_lookup[mi->mbmi.sb_type] << 3;
const int bh = num_8x8_blocks_high_lookup[mi->mbmi.sb_type] << 3;
const int bw = block_size_wide[AOMMAX(mi->mbmi.sb_type, BLOCK_8X8)];
const int bh = block_size_high[AOMMAX(mi->mbmi.sb_type, BLOCK_8X8)];
#if CONFIG_REF_MV
POSITION mv_ref_search[MVREF_NEIGHBOURS];
const int num_8x8_blocks_wide = bw >> 3;
const int num_8x8_blocks_high = bh >> 3;
const int num_8x8_blocks_wide = bw >> MI_SIZE_LOG2;
const int num_8x8_blocks_high = bh >> MI_SIZE_LOG2;
mv_ref_search[0].row = num_8x8_blocks_high - 1;
mv_ref_search[0].col = -1;
mv_ref_search[1].row = -1;
......
......@@ -643,13 +643,13 @@ static INLINE void update_partition_context(MACROBLOCKD *xd, int mi_row,
xd->left_seg_context + (mi_row & MAX_MIB_MASK);
#if CONFIG_EXT_PARTITION_TYPES
const int bw = num_8x8_blocks_wide_lookup[bsize];
const int bh = num_8x8_blocks_high_lookup[bsize];
const int bw = mi_size_wide[bsize];
const int bh = mi_size_high[bsize];
memset(above_ctx, partition_context_lookup[subsize].above, bw);
memset(left_ctx, partition_context_lookup[subsize].left, bh);
#else
// num_4x4_blocks_wide_lookup[bsize] / 2
const int bs = num_8x8_blocks_wide_lookup[bsize];
const int bs = mi_size_wide[bsize];
// update the partition context at the end notes. set partition bits
// of block sizes larger than the current one to be one, and partition
......@@ -792,8 +792,8 @@ static INLINE void txfm_partition_update(TXFM_CONTEXT *above_ctx,
TXFM_CONTEXT *left_ctx,
TX_SIZE tx_size) {
BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
int bh = num_8x8_blocks_high_lookup[bsize];
int bw = num_8x8_blocks_wide_lookup[bsize];
int bh = mi_size_high[bsize];
int bw = mi_size_wide[bsize];
uint8_t txw = tx_size_wide[tx_size];
uint8_t txh = tx_size_high[tx_size];
int i;
......@@ -835,7 +835,7 @@ static INLINE PARTITION_TYPE get_partition(const AV1_COMMON *const cm,
#if !CONFIG_EXT_PARTITION_TYPES
return partition;
#else
const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2;
const int hbs = mi_size_wide[bsize] / 2;
assert(cm->mi_grid_visible[offset] == &cm->mi[offset]);
......@@ -865,11 +865,10 @@ static INLINE PARTITION_TYPE get_partition(const AV1_COMMON *const cm,
static INLINE void set_sb_size(AV1_COMMON *const cm, const BLOCK_SIZE sb_size) {
cm->sb_size = sb_size;
cm->mib_size = mi_size_wide[cm->sb_size];
#if CONFIG_CB4X4
cm->mib_size = num_4x4_blocks_wide_lookup[cm->sb_size];
cm->mib_size_log2 = b_width_log2_lookup[cm->sb_size];
#else
cm->mib_size = num_8x8_blocks_wide_lookup[cm->sb_size];
cm->mib_size_log2 = mi_width_log2_lookup[cm->sb_size];
#endif
}
......
......@@ -24,8 +24,8 @@ static INLINE int get_segment_id(const AV1_COMMON *const cm,
const uint8_t *segment_ids, BLOCK_SIZE bsize,
int mi_row, int mi_col) {
const int mi_offset = mi_row * cm->mi_cols + mi_col;
const int bw = num_8x8_blocks_wide_lookup[bsize];
const int bh = num_8x8_blocks_high_lookup[bsize];
const int bw = mi_size_wide[bsize];
const int bh = mi_size_high[bsize];
const int xmis = AOMMIN(cm->mi_cols - mi_col, bw);
const int ymis = AOMMIN(cm->mi_rows - mi_row, bh);
int x, y, segment_id = MAX_SEGMENTS;
......
......@@ -497,8 +497,8 @@ static int read_inter_segment_id(AV1_COMMON *const cm, MACROBLOCKD *const xd,
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
int predicted_segment_id, segment_id;
const int mi_offset = mi_row * cm->mi_cols + mi_col;
const int bw = num_8x8_blocks_wide_lookup[mbmi->sb_type];
const int bh = num_8x8_blocks_high_lookup[mbmi->sb_type];
const int bw = mi_size_wide[mbmi->sb_type];
const int bh = mi_size_high[mbmi->sb_type];
// TODO(slavarnway): move x_mis, y_mis into xd ?????
const int x_mis = AOMMIN(cm->mi_cols - mi_col, bw);
......
......@@ -116,8 +116,8 @@ void av1_caq_select_segment(const AV1_COMP *cpi, MACROBLOCK *mb, BLOCK_SIZE bs,
const AV1_COMMON *const cm = &cpi->common;
const int mi_offset = mi_row * cm->mi_cols + mi_col;
const int xmis = AOMMIN(cm->mi_cols - mi_col, num_8x8_blocks_wide_lookup[bs]);
const int ymis = AOMMIN(cm->mi_rows - mi_row, num_8x8_blocks_high_lookup[bs]);
const int xmis = AOMMIN(cm->mi_cols - mi_col, mi_size_wide[bs]);
const int ymis = AOMMIN(cm->mi_rows - mi_row, mi_size_high[bs]);
int x, y;
int i;
unsigned char segment;
......
......@@ -215,8 +215,8 @@ void av1_cyclic_refresh_update_segment(const AV1_COMP *cpi,
int64_t rate, int64_t dist, int skip) {
const AV1_COMMON *const cm = &cpi->common;
CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
const int bw = num_8x8_blocks_wide_lookup[bsize];
const int bh = num_8x8_blocks_high_lookup[bsize];
const int bw = mi_size_wide[bsize];
const int bh = mi_size_high[bsize];
const int xmis = AOMMIN(cm->mi_cols - mi_col, bw);
const int ymis = AOMMIN(cm->mi_rows - mi_row, bh);
const int block_index = mi_row * cm->mi_cols + mi_col;
......
......@@ -151,8 +151,8 @@ static unsigned int block_variance(const AV1_COMP *const cpi, MACROBLOCK *x,
(xd->mb_to_bottom_edge < 0) ? ((-xd->mb_to_bottom_edge) >> 3) : 0;
if (right_overflow || bottom_overflow) {
const int bw = 8 * num_8x8_blocks_wide_lookup[bs] - right_overflow;
const int bh = 8 * num_8x8_blocks_high_lookup[bs] - bottom_overflow;
const int bw = 8 * mi_size_wide[bs] - right_overflow;
const int bh = 8 * mi_size_high[bs] - bottom_overflow;
int avg;
#if CONFIG_AOM_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
......
......@@ -1811,8 +1811,8 @@ static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
assert(m->mbmi.sb_type <= cm->sb_size);
bh = num_8x8_blocks_high_lookup[m->mbmi.sb_type];
bw = num_8x8_blocks_wide_lookup[m->mbmi.sb_type];
bh = mi_size_high[m->mbmi.sb_type];
bw = mi_size_wide[m->mbmi.sb_type];
cpi->td.mb.mbmi_ext = cpi->mbmi_ext_base + (mi_row * cm->mi_cols + mi_col);
......@@ -2189,7 +2189,7 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
int mi_row, int mi_col, BLOCK_SIZE bsize) {
const AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2;
const int hbs = mi_size_wide[bsize] / 2;
const PARTITION_TYPE partition = get_partition(cm, mi_row, mi_col, bsize);
const BLOCK_SIZE subsize = get_subsize(bsize, partition);
#if CONFIG_SUPERTX
......@@ -4013,7 +4013,7 @@ static void write_uncompressed_header(AV1_COMP *cpi,
aom_wb_write_literal(wb, cm->frame_context_idx, FRAME_CONTEXTS_LOG2);
assert(cm->mib_size == num_8x8_blocks_wide_lookup[cm->sb_size]);
assert(cm->mib_size == mi_size_wide[cm->sb_size]);
assert(cm->mib_size == 1 << cm->mib_size_log2);
#if CONFIG_EXT_PARTITION
assert(cm->sb_size == BLOCK_128X128 || cm->sb_size == BLOCK_64X64);
......
......@@ -264,8 +264,8 @@ static void set_offsets_without_segment_id(const AV1_COMP *const cpi,
int mi_col, BLOCK_SIZE bsize) {
const AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
const int mi_width = num_8x8_blocks_wide_lookup[bsize];
const int mi_height = num_8x8_blocks_high_lookup[bsize];
const int mi_width = mi_size_wide[bsize];
const int mi_height = mi_size_high[bsize];
const int bwl = b_width_log2_lookup[AOMMAX(bsize, BLOCK_8X8)];
const int bhl = b_height_log2_lookup[AOMMAX(bsize, BLOCK_8X8)];
......@@ -438,8 +438,8 @@ static void set_vt_partitioning(AV1_COMP *cpi, MACROBLOCK *const x,
int mi_col, const int64_t *const threshold,
const BLOCK_SIZE *const bsize_min) {
AV1_COMMON *const cm = &cpi->common;
const int hbw = num_8x8_blocks_wide_lookup[vt->bsize] / 2;
const int hbh = num_8x8_blocks_high_lookup[vt->bsize] / 2;
const int hbw = mi_size_wide[vt->bsize] / 2;
const int hbh = mi_size_high[vt->bsize] / 2;
const int has_cols = mi_col + hbw < cm->mi_cols;
const int has_rows = mi_row + hbh < cm->mi_rows;
......@@ -827,8 +827,8 @@ static void choose_partitioning(AV1_COMP *const cpi, ThreadData *const td,
const uint8_t *ref;
int src_stride;
int ref_stride;
int pixels_wide = 8 * num_8x8_blocks_wide_lookup[cm->sb_size];
int pixels_high = 8 * num_8x8_blocks_high_lookup[cm->sb_size];
int pixels_wide = MI_SIZE * mi_size_wide[cm->sb_size];
int pixels_high = MI_SIZE * mi_size_high[cm->sb_size];
int64_t thresholds[5] = {
cpi->vbp_thresholds[0], cpi->vbp_thresholds[1], cpi->vbp_thresholds[2],
cpi->vbp_thresholds[3], cpi->vbp_thresholds[4],
......@@ -1028,16 +1028,16 @@ static void update_state(const AV1_COMP *const cpi, ThreadData *td,
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
MODE_INFO *mi_addr = xd->mi[0];
const struct segmentation *const seg = &cm->seg;
const int bw = num_8x8_blocks_wide_lookup[mi->mbmi.sb_type];
const int bh = num_8x8_blocks_high_lookup[mi->mbmi.sb_type];
const int bw = mi_size_wide[mi->mbmi.sb_type];
const int bh = mi_size_high[mi->mbmi.sb_type];
const int x_mis = AOMMIN(bw, cm->mi_cols - mi_col);
const int y_mis = AOMMIN(bh, cm->mi_rows - mi_row);
MV_REF *const frame_mvs = cm->cur_frame->mvs + mi_row * cm->mi_cols + mi_col;
int w, h;
const int mis = cm->mi_stride;
const int mi_width = num_8x8_blocks_wide_lookup[bsize];
const int mi_height = num_8x8_blocks_high_lookup[bsize];
const int mi_width = mi_size_wide[bsize];
const int mi_height = mi_size_high[bsize];
#if CONFIG_REF_MV
int8_t rf_type;
......@@ -2131,10 +2131,12 @@ static void restore_context(MACROBLOCK *x,
BLOCK_SIZE bsize) {
MACROBLOCKD *xd = &x->e_mbd;
int p;
const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize];
const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bsize];
int mi_width = num_8x8_blocks_wide_lookup[bsize];
int mi_height = num_8x8_blocks_high_lookup[bsize];
const int num_4x4_blocks_wide =
block_size_wide[bsize] >> tx_size_wide_log2[0];
const int num_4x4_blocks_high =
block_size_high[bsize] >> tx_size_high_log2[0];
int mi_width = mi_size_wide[bsize];
int mi_height = mi_size_high[bsize];
for (p = 0; p < MAX_MB_PLANE; p++) {
memcpy(xd->above_context[p] + ((mi_col * 2) >> xd->plane[p].subsampling_x),
ctx->a + num_4x4_blocks_wide * p,
......@@ -2171,10 +2173,12 @@ static void save_context(const MACROBLOCK *x, RD_SEARCH_MACROBLOCK_CONTEXT *ctx,
BLOCK_SIZE bsize) {
const MACROBLOCKD *xd = &x->e_mbd;
int p;
const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize];
const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bsize];
int mi_width = num_8x8_blocks_wide_lookup[bsize];
int mi_height = num_8x8_blocks_high_lookup[bsize];
const int num_4x4_blocks_wide =
block_size_wide[bsize] >> tx_size_wide_log2[0];
const int num_4x4_blocks_high =
block_size_high[bsize] >> tx_size_high_log2[0];
int mi_width = mi_size_wide[bsize];
int mi_height = mi_size_high[bsize];
// buffer the above/left context information of the block in search.
for (p = 0; p < MAX_MB_PLANE; ++p) {
......@@ -2238,7 +2242,7 @@ static void encode_sb(const AV1_COMP *const cpi, ThreadData *td,
MACROBLOCKD *const xd = &x->e_mbd;
const int ctx = partition_plane_context(xd, mi_row, mi_col, bsize);
const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2;
const int hbs = mi_size_wide[bsize] / 2;
const PARTITION_TYPE partition = pc_tree->partitioning;
const BLOCK_SIZE subsize = get_subsize(bsize, partition);
#if CONFIG_EXT_PARTITION_TYPES
......@@ -2450,8 +2454,8 @@ static BLOCK_SIZE find_partition_size(BLOCK_SIZE bsize, int rows_left,
return AOMMIN(bsize, BLOCK_8X8);
} else {
for (; bsize > 0; bsize -= 3) {
*bh = num_8x8_blocks_high_lookup[bsize];
*bw = num_8x8_blocks_wide_lookup[bsize];
*bh = mi_size_high[bsize];
*bw = mi_size_wide[bsize];
if ((*bh <= rows_left) && (*bw <= cols_left)) {
break;
}
......@@ -2491,8 +2495,8 @@ static void set_fixed_partitioning(AV1_COMP *cpi, const TileInfo *const tile,
const int mi_cols_remaining = tile->mi_col_end - mi_col;
int block_row, block_col;
MODE_INFO *const mi_upper_left = cm->mi + mi_row * cm->mi_stride + mi_col;
int bh = num_8x8_blocks_high_lookup[bsize];
int bw = num_8x8_blocks_wide_lookup[bsize];
int bh = mi_size_high[bsize];
int bw = mi_size_wide[bsize];
assert((mi_rows_remaining > 0) && (mi_cols_remaining > 0));
......@@ -2525,7 +2529,7 @@ static void rd_use_partition(AV1_COMP *cpi, ThreadData *td,
TileInfo *const tile_info = &tile_data->tile_info;
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
const int bs = num_8x8_blocks_wide_lookup[bsize];
const int bs = mi_size_wide[bsize];
const int hbs = bs / 2;
int i;
const int pl = partition_plane_context(xd, mi_row, mi_col, bsize);
......@@ -3077,8 +3081,8 @@ static void set_partition_range(const AV1_COMMON *const cm,
int mi_col, BLOCK_SIZE bsize,
BLOCK_SIZE *const min_bs,
BLOCK_SIZE *const max_bs) {
const int mi_width = num_8x8_blocks_wide_lookup[bsize];
const int mi_height = num_8x8_blocks_high_lookup[bsize];
const int mi_width = mi_size_wide[bsize];
const int mi_height = mi_size_high[bsize];
int idx, idy;
const int idx_str = cm->mi_stride * mi_row + mi_col;
......@@ -3424,7 +3428,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
TileInfo *const tile_info = &tile_data->tile_info;
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
const int mi_step = num_8x8_blocks_wide_lookup[bsize] / 2;
const int mi_step = mi_size_wide[bsize] / 2;
RD_SEARCH_MACROBLOCK_CONTEXT x_ctx;
const TOKENEXTRA *const tp_orig = *tp;
PICK_MODE_CONTEXT *ctx_none = &pc_tree->none;
......@@ -3506,8 +3510,7 @@ static void rd_pick_partition(const AV1_COMP *const cpi, ThreadData *td,
#endif // NDEBUG
#endif // CONFIG_VAR_TX
assert(num_8x8_blocks_wide_lookup[bsize] ==
num_8x8_blocks_high_lookup[bsize]);
assert(mi_size_wide[bsize] == mi_size_high[bsize]);
av1_rd_cost_init(&this_rdc);
av1_rd_cost_init(&sum_rdc);
......@@ -5440,8 +5443,8 @@ static void encode_superblock(const AV1_COMP *const cpi, ThreadData *td,
const int seg_skip =
segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP);
const int mis = cm->mi_stride;
const int mi_width = num_8x8_blocks_wide_lookup[bsize];
const int mi_height = num_8x8_blocks_high_lookup[bsize];
const int mi_width = mi_size_wide[bsize];
const int mi_height = mi_size_high[bsize];
const int is_inter = is_inter_block(mbmi);
x->use_lp32x32fdct = cpi->sf.use_lp32x32fdct;
......
......@@ -617,9 +617,8 @@ 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 << 1, num_8x8_blocks_high_lookup[bsize],
mb_col << 1, num_8x8_blocks_wide_lookup[bsize],
cm->mi_rows, cm->mi_cols);
set_mi_row_col(xd, &tile, mb_row << 1, mi_size_high[bsize], mb_col << 1,
mi_size_wide[bsize], cm->mi_rows, cm->mi_cols);
set_plane_n4(xd, num_8x8_blocks_wide_lookup[bsize],
num_8x8_blocks_high_lookup[bsize],
mi_width_log2_lookup[bsize], mi_height_log2_lookup[bsize]);
......
......@@ -160,7 +160,7 @@ static void count_segs_sb(const AV1_COMMON *cm, MACROBLOCKD *xd,
unsigned *t_unpred_seg_counts, int mi_row, int mi_col,
BLOCK_SIZE bsize) {
const int mis = cm->mi_stride;
const int bs = num_8x8_blocks_wide_lookup[bsize], hbs = bs / 2;
const int bs = mi_size_wide[bsize], hbs = bs / 2;
#if CONFIG_EXT_PARTITION_TYPES
PARTITION_TYPE partition;
#else
......@@ -252,8 +252,8 @@ static void count_segs_sb(const AV1_COMMON *cm, MACROBLOCKD *xd,
default: assert(0);
}
#else
bw = num_8x8_blocks_wide_lookup[mi[0]->mbmi.sb_type];
bh = num_8x8_blocks_high_lookup[mi[0]->mbmi.sb_type];
bw = mi_size_wide[mi[0]->mbmi.sb_type];
bh = mi_size_high[mi[0]->mbmi.sb_type];
if (bw == bs && bh == bs) {
count_segs(cm, xd, tile, mi, no_pred_segcounts, temporal_predictor_count,
......
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