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
diff --git a/av1/common/common_data.h b/av1/common/common_data.h
index 10f8c42..0de9a71 100644
--- a/av1/common/common_data.h
+++ b/av1/common/common_data.h
@@ -53,6 +53,21 @@
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
diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c
index abf3c87..6697708 100644
--- a/av1/common/mvref_common.c
+++ b/av1/common/mvref_common.c
@@ -175,8 +175,7 @@
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 @@
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 @@
? 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;
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index b194786..5c32c39 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -643,13 +643,13 @@
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 @@
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 @@
#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 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
}
diff --git a/av1/common/pred_common.h b/av1/common/pred_common.h
index 6b47ed2..71865f2 100644
--- a/av1/common/pred_common.h
+++ b/av1/common/pred_common.h
@@ -24,8 +24,8 @@
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;
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index 838c9af..c01a4ce 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -497,8 +497,8 @@
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);
diff --git a/av1/encoder/aq_complexity.c b/av1/encoder/aq_complexity.c
index 5c4a5e3..cb15ff8 100644
--- a/av1/encoder/aq_complexity.c
+++ b/av1/encoder/aq_complexity.c
@@ -116,8 +116,8 @@
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;
diff --git a/av1/encoder/aq_cyclicrefresh.c b/av1/encoder/aq_cyclicrefresh.c
index bcf11a7..e41c608 100644
--- a/av1/encoder/aq_cyclicrefresh.c
+++ b/av1/encoder/aq_cyclicrefresh.c
@@ -215,8 +215,8 @@
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;
diff --git a/av1/encoder/aq_variance.c b/av1/encoder/aq_variance.c
index 01528ec..2048940 100644
--- a/av1/encoder/aq_variance.c
+++ b/av1/encoder/aq_variance.c
@@ -151,8 +151,8 @@
(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) {
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index e64414d..92afa69 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -1811,8 +1811,8 @@
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 @@
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 @@
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);
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 7e39cc5..a274f72 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -264,8 +264,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
#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 @@
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;
diff --git a/av1/encoder/firstpass.c b/av1/encoder/firstpass.c
index f066b46..968677d 100644
--- a/av1/encoder/firstpass.c
+++ b/av1/encoder/firstpass.c
@@ -617,9 +617,8 @@
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]);
diff --git a/av1/encoder/segmentation.c b/av1/encoder/segmentation.c
index 828b31c..b291b29 100644
--- a/av1/encoder/segmentation.c
+++ b/av1/encoder/segmentation.c
@@ -160,7 +160,7 @@
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 @@
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,