Commit 9353124f authored by Jingning Han's avatar Jingning Han

Refactor supertx implementation

Replace hard coded numbers with table access. Avoid comparing
values from different enums.

Change-Id: I43216db4a9b13ee317e8e517683946f526e5ca0e
parent 443c38d3
...@@ -555,9 +555,9 @@ static const TX_TYPE intra_mode_to_tx_type_context[INTRA_MODES] = { ...@@ -555,9 +555,9 @@ static const TX_TYPE intra_mode_to_tx_type_context[INTRA_MODES] = {
#if CONFIG_SUPERTX #if CONFIG_SUPERTX
static INLINE int supertx_enabled(const MB_MODE_INFO *mbmi) { static INLINE int supertx_enabled(const MB_MODE_INFO *mbmi) {
return (int)txsize_sqr_map[mbmi->tx_size] > TX_SIZE max_tx_size = txsize_sqr_map[mbmi->tx_size];
AOMMIN(b_width_log2_lookup[mbmi->sb_type], return tx_size_wide[max_tx_size] >
b_height_log2_lookup[mbmi->sb_type]); AOMMIN(block_size_wide[mbmi->sb_type], block_size_high[mbmi->sb_type]);
} }
#endif // CONFIG_SUPERTX #endif // CONFIG_SUPERTX
...@@ -869,16 +869,16 @@ static INLINE TX_SIZE depth_to_tx_size(const int depth) { ...@@ -869,16 +869,16 @@ static INLINE TX_SIZE depth_to_tx_size(const int depth) {
static INLINE TX_SIZE get_uv_tx_size(const MB_MODE_INFO *mbmi, static INLINE TX_SIZE get_uv_tx_size(const MB_MODE_INFO *mbmi,
const struct macroblockd_plane *pd) { const struct macroblockd_plane *pd) {
TX_SIZE uv_txsize; TX_SIZE uv_txsize;
#if CONFIG_CB4X4
assert(mbmi->tx_size > TX_2X2);
#endif
#if CONFIG_SUPERTX #if CONFIG_SUPERTX
if (supertx_enabled(mbmi)) if (supertx_enabled(mbmi))
return uvsupertx_size_lookup[txsize_sqr_map[mbmi->tx_size]] return uvsupertx_size_lookup[txsize_sqr_map[mbmi->tx_size]]
[pd->subsampling_x][pd->subsampling_y]; [pd->subsampling_x][pd->subsampling_y];
#endif // CONFIG_SUPERTX #endif // CONFIG_SUPERTX
#if CONFIG_CB4X4
assert(mbmi->tx_size > TX_2X2);
#endif
uv_txsize = uv_txsize_lookup[mbmi->sb_type][mbmi->tx_size][pd->subsampling_x] uv_txsize = uv_txsize_lookup[mbmi->sb_type][mbmi->tx_size][pd->subsampling_x]
[pd->subsampling_y]; [pd->subsampling_y];
assert(uv_txsize != TX_INVALID); assert(uv_txsize != TX_INVALID);
......
...@@ -1910,7 +1910,7 @@ void av1_adapt_inter_frame_probs(AV1_COMMON *cm) { ...@@ -1910,7 +1910,7 @@ void av1_adapt_inter_frame_probs(AV1_COMMON *cm) {
#if CONFIG_SUPERTX #if CONFIG_SUPERTX
for (i = 0; i < PARTITION_SUPERTX_CONTEXTS; ++i) { for (i = 0; i < PARTITION_SUPERTX_CONTEXTS; ++i) {
for (j = 1; j < TX_SIZES; ++j) { for (j = TX_8X8; j < TX_SIZES; ++j) {
fc->supertx_prob[i][j] = av1_mode_mv_merge_probs( fc->supertx_prob[i][j] = av1_mode_mv_merge_probs(
pre_fc->supertx_prob[i][j], counts->supertx[i][j]); pre_fc->supertx_prob[i][j], counts->supertx[i][j]);
} }
......
...@@ -1043,10 +1043,10 @@ void av1_build_masked_inter_predictor_complex( ...@@ -1043,10 +1043,10 @@ void av1_build_masked_inter_predictor_complex(
const struct macroblockd_plane *pd = &xd->plane[plane]; const struct macroblockd_plane *pd = &xd->plane[plane];
const int ssx = pd->subsampling_x; const int ssx = pd->subsampling_x;
const int ssy = pd->subsampling_y; const int ssy = pd->subsampling_y;
const int top_w = (4 << b_width_log2_lookup[top_bsize]) >> ssx; const int top_w = block_size_wide[top_bsize] >> ssx;
const int top_h = (4 << b_height_log2_lookup[top_bsize]) >> ssy; const int top_h = block_size_high[top_bsize] >> ssy;
const int w = (4 << b_width_log2_lookup[bsize]) >> ssx; const int w = block_size_wide[bsize] >> ssx;
const int h = (4 << b_height_log2_lookup[bsize]) >> ssy; const int h = block_size_high[bsize] >> ssy;
const int w_offset = ((mi_col - mi_col_ori) * MI_SIZE) >> ssx; const int w_offset = ((mi_col - mi_col_ori) * MI_SIZE) >> ssx;
const int h_offset = ((mi_row - mi_row_ori) * MI_SIZE) >> ssy; const int h_offset = ((mi_row - mi_row_ori) * MI_SIZE) >> ssy;
......
...@@ -646,8 +646,8 @@ static MB_MODE_INFO *set_offsets_extend(AV1_COMMON *const cm, ...@@ -646,8 +646,8 @@ static MB_MODE_INFO *set_offsets_extend(AV1_COMMON *const cm,
// Used in supertx // Used in supertx
// (mi_row_ori, mi_col_ori): location for mv // (mi_row_ori, mi_col_ori): location for mv
// (mi_row_pred, mi_col_pred, bsize_pred): region to predict // (mi_row_pred, mi_col_pred, bsize_pred): region to predict
const int bw = num_8x8_blocks_wide_lookup[bsize_pred]; const int bw = mi_size_wide[bsize_pred];
const int bh = num_8x8_blocks_high_lookup[bsize_pred]; const int bh = mi_size_high[bsize_pred];
const int offset = mi_row_ori * cm->mi_stride + mi_col_ori; const int offset = mi_row_ori * cm->mi_stride + mi_col_ori;
xd->mi = cm->mi_grid_visible + offset; xd->mi = cm->mi_grid_visible + offset;
xd->mi[0] = cm->mi + offset; xd->mi[0] = cm->mi + offset;
...@@ -682,8 +682,8 @@ static MB_MODE_INFO *set_mb_offsets(AV1_COMMON *const cm, MACROBLOCKD *const xd, ...@@ -682,8 +682,8 @@ static MB_MODE_INFO *set_mb_offsets(AV1_COMMON *const cm, MACROBLOCKD *const xd,
static void set_offsets_topblock(AV1_COMMON *const cm, MACROBLOCKD *const xd, static void set_offsets_topblock(AV1_COMMON *const cm, MACROBLOCKD *const xd,
const TileInfo *const tile, BLOCK_SIZE bsize, const TileInfo *const tile, BLOCK_SIZE bsize,
int mi_row, int mi_col) { int mi_row, int mi_col) {
const int bw = num_8x8_blocks_wide_lookup[bsize]; const int bw = mi_size_wide[bsize];
const int bh = num_8x8_blocks_high_lookup[bsize]; const int bh = mi_size_high[bsize];
const int offset = mi_row * cm->mi_stride + mi_col; const int offset = mi_row * cm->mi_stride + mi_col;
xd->mi = cm->mi_grid_visible + offset; xd->mi = cm->mi_grid_visible + offset;
...@@ -699,8 +699,8 @@ static void set_offsets_topblock(AV1_COMMON *const cm, MACROBLOCKD *const xd, ...@@ -699,8 +699,8 @@ static void set_offsets_topblock(AV1_COMMON *const cm, MACROBLOCKD *const xd,
static void set_param_topblock(AV1_COMMON *const cm, MACROBLOCKD *const xd, static void set_param_topblock(AV1_COMMON *const cm, MACROBLOCKD *const xd,
BLOCK_SIZE bsize, int mi_row, int mi_col, BLOCK_SIZE bsize, int mi_row, int mi_col,
int txfm, int skip) { int txfm, int skip) {
const int bw = num_8x8_blocks_wide_lookup[bsize]; const int bw = mi_size_wide[bsize];
const int bh = num_8x8_blocks_high_lookup[bsize]; const int bh = mi_size_high[bsize];
const int x_mis = AOMMIN(bw, cm->mi_cols - mi_col); const int x_mis = AOMMIN(bw, cm->mi_cols - mi_col);
const int y_mis = AOMMIN(bh, cm->mi_rows - mi_row); const int y_mis = AOMMIN(bh, cm->mi_rows - mi_row);
const int offset = mi_row * cm->mi_stride + mi_col; const int offset = mi_row * cm->mi_stride + mi_col;
...@@ -749,8 +749,8 @@ static void dec_predict_b_extend( ...@@ -749,8 +749,8 @@ static void dec_predict_b_extend(
// bextend: 1: region to predict is an extension of ori; 0: not // bextend: 1: region to predict is an extension of ori; 0: not
int r = (mi_row_pred - mi_row_top) * MI_SIZE; int r = (mi_row_pred - mi_row_top) * MI_SIZE;
int c = (mi_col_pred - mi_col_top) * MI_SIZE; int c = (mi_col_pred - mi_col_top) * MI_SIZE;
const int mi_width_top = num_8x8_blocks_wide_lookup[bsize_top]; const int mi_width_top = mi_size_wide[bsize_top];
const int mi_height_top = num_8x8_blocks_high_lookup[bsize_top]; const int mi_height_top = mi_size_high[bsize_top];
MB_MODE_INFO *mbmi; MB_MODE_INFO *mbmi;
AV1_COMMON *const cm = &pbi->common; AV1_COMMON *const cm = &pbi->common;
...@@ -768,6 +768,9 @@ static void dec_predict_b_extend( ...@@ -768,6 +768,9 @@ static void dec_predict_b_extend(
if (!bextend) { if (!bextend) {
mbmi->tx_size = b_width_log2_lookup[bsize_top]; mbmi->tx_size = b_width_log2_lookup[bsize_top];
#if CONFIG_CB4X4
++mbmi->tx_size;
#endif
} }
xd->plane[0].dst.stride = dst_stride[0]; xd->plane[0].dst.stride = dst_stride[0];
...@@ -805,8 +808,8 @@ static void dec_extend_dir(AV1Decoder *const pbi, MACROBLOCKD *const xd, ...@@ -805,8 +808,8 @@ static void dec_extend_dir(AV1Decoder *const pbi, MACROBLOCKD *const xd,
uint8_t *dst_buf[3], int dst_stride[3], int dir) { uint8_t *dst_buf[3], int dst_stride[3], int dir) {
// dir: 0-lower, 1-upper, 2-left, 3-right // dir: 0-lower, 1-upper, 2-left, 3-right
// 4-lowerleft, 5-upperleft, 6-lowerright, 7-upperright // 4-lowerleft, 5-upperleft, 6-lowerright, 7-upperright
const int mi_width = num_8x8_blocks_wide_lookup[bsize]; const int mi_width = mi_size_wide[bsize];
const int mi_height = num_8x8_blocks_high_lookup[bsize]; const int mi_height = mi_size_high[bsize];
int xss = xd->plane[1].subsampling_x; int xss = xd->plane[1].subsampling_x;
int yss = xd->plane[1].subsampling_y; int yss = xd->plane[1].subsampling_y;
int b_sub8x8 = (bsize < BLOCK_8X8) ? 1 : 0; int b_sub8x8 = (bsize < BLOCK_8X8) ? 1 : 0;
...@@ -814,11 +817,12 @@ static void dec_extend_dir(AV1Decoder *const pbi, MACROBLOCKD *const xd, ...@@ -814,11 +817,12 @@ static void dec_extend_dir(AV1Decoder *const pbi, MACROBLOCKD *const xd,
int unit, mi_row_pred, mi_col_pred; int unit, mi_row_pred, mi_col_pred;
if (dir == 0 || dir == 1) { if (dir == 0 || dir == 1) {
extend_bsize = (mi_width == 1 || bsize < BLOCK_8X8 || xss < yss) extend_bsize =
? BLOCK_8X8 (mi_width == mi_size_wide[BLOCK_8X8] || bsize < BLOCK_8X8 || xss < yss)
: BLOCK_16X8; ? BLOCK_8X8
unit = num_8x8_blocks_wide_lookup[extend_bsize]; : BLOCK_16X8;
mi_row_pred = mi_row + ((dir == 0) ? mi_height : -1); unit = mi_size_wide[extend_bsize];
mi_row_pred = mi_row + ((dir == 0) ? mi_height : -mi_size_high[BLOCK_8X8]);
mi_col_pred = mi_col; mi_col_pred = mi_col;
dec_predict_b_extend(pbi, xd, tile, block, mi_row, mi_col, mi_row_pred, dec_predict_b_extend(pbi, xd, tile, block, mi_row, mi_col, mi_row_pred,
......
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