Commit 0c6244b6 authored by hui su's avatar hui su Committed by Hui Su

refactor get_tx_size() and get_uv_tx_size()

Change-Id: I802c9e41ebfed090b5ad8300917aad5e16ad026a
parent f7c4bf5c
......@@ -1431,7 +1431,7 @@ static void get_filter_level_and_masks_non420(
const int skip_this_r = skip_this && !block_edge_above;
TX_SIZE tx_size = (plane->plane_type == PLANE_TYPE_UV)
? get_uv_tx_size(mbmi, plane)
? av1_get_uv_tx_size(mbmi, plane)
: mbmi->tx_size;
const int skip_border_4x4_c =
......
......@@ -49,7 +49,7 @@ void av1_foreach_transformed_block_interleave(
const MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
const TX_SIZE tx_log2_y = mbmi->tx_size;
const TX_SIZE tx_log2_c = get_uv_tx_size(mbmi, pd_c);
const TX_SIZE tx_log2_c = av1_get_uv_tx_size(mbmi, pd_c);
const int tx_sz_y = (1 << tx_log2_y);
const int tx_sz_c = (1 << tx_log2_c);
......@@ -127,7 +127,7 @@ void av1_foreach_transformed_block_in_plane(
// block and transform sizes, in number of 4x4 blocks log 2 ("*_b")
// 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8
// transform size varies per plane, look it up in a common way.
const TX_SIZE tx_size = get_tx_size(plane, xd);
const TX_SIZE tx_size = av1_get_tx_size(plane, xd);
#if CONFIG_CHROMA_SUB8X8
const BLOCK_SIZE plane_bsize =
AOMMAX(BLOCK_4X4, get_plane_block_size(bsize, pd));
......
......@@ -1203,12 +1203,11 @@ static INLINE TX_SIZE depth_to_tx_size(int depth) {
return (TX_SIZE)(depth + TX_SIZE_LUMA_MIN);
}
static INLINE TX_SIZE get_uv_tx_size(const MB_MODE_INFO *mbmi,
static INLINE TX_SIZE av1_get_uv_tx_size(const MB_MODE_INFO *mbmi,
const struct macroblockd_plane *pd) {
TX_SIZE uv_txsize;
#if CONFIG_CHROMA_2X2
assert(mbmi->tx_size > TX_2X2);
#endif
#endif // CONFIG_CHROMA_2X2
#if CONFIG_SUPERTX
if (supertx_enabled(mbmi))
......@@ -1216,17 +1215,18 @@ static INLINE TX_SIZE get_uv_tx_size(const MB_MODE_INFO *mbmi,
[pd->subsampling_x][pd->subsampling_y];
#endif // CONFIG_SUPERTX
uv_txsize = uv_txsize_lookup[mbmi->sb_type][mbmi->tx_size][pd->subsampling_x]
const TX_SIZE uv_txsize =
uv_txsize_lookup[mbmi->sb_type][mbmi->tx_size][pd->subsampling_x]
[pd->subsampling_y];
assert(uv_txsize != TX_INVALID);
return uv_txsize;
}
static INLINE TX_SIZE get_tx_size(int plane, const MACROBLOCKD *xd) {
static INLINE TX_SIZE av1_get_tx_size(int plane, const MACROBLOCKD *xd) {
const MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
if (plane == 0) return mbmi->tx_size;
const MACROBLOCKD_PLANE *pd = &xd->plane[plane];
const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi, pd) : mbmi->tx_size;
return tx_size;
return av1_get_uv_tx_size(mbmi, pd);
}
static INLINE BLOCK_SIZE
......
......@@ -2102,7 +2102,7 @@ void av1_inverse_transform_block_facade(MACROBLOCKD *xd, int plane, int block,
struct macroblockd_plane *const pd = &xd->plane[plane];
tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
const PLANE_TYPE plane_type = get_plane_type(plane);
const TX_SIZE tx_size = get_tx_size(plane, xd);
const TX_SIZE tx_size = av1_get_tx_size(plane, xd);
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, block, tx_size);
const int dst_stride = pd->dst.stride;
uint8_t *dst =
......
......@@ -290,7 +290,7 @@ static int get_block_idx(const MACROBLOCKD *xd, int plane, int row, int col) {
get_plane_block_size(AOMMAX(BLOCK_8X8, bsize), pd);
#endif
const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
const TX_SIZE tx_size = get_tx_size(plane, xd);
const TX_SIZE tx_size = av1_get_tx_size(plane, xd);
const uint8_t txh_unit = tx_size_high_unit[tx_size];
return row * max_blocks_wide + col * txh_unit;
}
......@@ -1841,7 +1841,7 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi,
const struct macroblockd_plane *const pd_y = &xd->plane[0];
const struct macroblockd_plane *const pd_c = &xd->plane[1];
const TX_SIZE tx_log2_y = mbmi->tx_size;
const TX_SIZE tx_log2_c = get_uv_tx_size(mbmi, pd_c);
const TX_SIZE tx_log2_c = av1_get_uv_tx_size(mbmi, pd_c);
const int tx_sz_y = (1 << tx_log2_y);
const int tx_sz_c = (1 << tx_log2_c);
const int num_4x4_w_y = pd_y->n4_w;
......@@ -1963,7 +1963,7 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi,
#endif // CONFIG_PALETTE
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
const TX_SIZE tx_size = get_tx_size(plane, xd);
const TX_SIZE tx_size = av1_get_tx_size(plane, xd);
const int stepr = tx_size_high_unit[tx_size];
const int stepc = tx_size_wide_unit[tx_size];
#if CONFIG_CHROMA_SUB8X8
......@@ -2078,7 +2078,7 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi,
}
}
#else
const TX_SIZE tx_size = get_tx_size(plane, xd);
const TX_SIZE tx_size = av1_get_tx_size(plane, xd);
const int stepr = tx_size_high_unit[tx_size];
const int stepc = tx_size_wide_unit[tx_size];
for (row = 0; row < max_blocks_high; row += stepr)
......@@ -2595,7 +2595,7 @@ static void decode_partition(AV1Decoder *const pbi, MACROBLOCKD *const xd,
for (i = 0; i < MAX_MB_PLANE; ++i) {
const struct macroblockd_plane *const pd = &xd->plane[i];
int row, col;
const TX_SIZE tx_size = get_tx_size(i, xd);
const TX_SIZE tx_size = av1_get_tx_size(i, xd);
const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
const int stepr = tx_size_high_unit[tx_size];
const int stepc = tx_size_wide_unit[tx_size];
......
......@@ -2513,7 +2513,7 @@ static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile,
const struct macroblockd_plane *const pd_y = &xd->plane[0];
const struct macroblockd_plane *const pd_c = &xd->plane[1];
const TX_SIZE tx_log2_y = mbmi->tx_size;
const TX_SIZE tx_log2_c = get_uv_tx_size(mbmi, pd_c);
const TX_SIZE tx_log2_c = av1_get_uv_tx_size(mbmi, pd_c);
const int tx_sz_y = (1 << tx_log2_y);
const int tx_sz_c = (1 << tx_log2_c);
......@@ -2651,7 +2651,7 @@ static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile,
#if CONFIG_LV_MAP
av1_write_coeffs_mb(cm, x, w, plane);
#else
TX_SIZE tx = get_tx_size(plane, xd);
const TX_SIZE tx = av1_get_tx_size(plane, xd);
const int bkw = tx_size_wide_unit[tx];
const int bkh = tx_size_high_unit[tx];
for (row = 0; row < num_4x4_h; row += bkh) {
......@@ -2666,7 +2666,7 @@ static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile,
#endif // CONFIG_LV_MAP
}
#else
TX_SIZE tx = get_tx_size(plane, xd);
const TX_SIZE tx = av1_get_tx_size(plane, xd);
TOKEN_STATS token_stats;
#if !CONFIG_PVQ
init_token_stats(&token_stats);
......@@ -3044,7 +3044,7 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
int row, col;
TX_SIZE tx = get_tx_size(plane, xd);
const TX_SIZE tx = av1_get_tx_size(plane, xd);
BLOCK_SIZE txb_size = txsize_to_bsize[tx];
const int stepr = tx_size_high_unit[txb_size];
......
......@@ -6135,8 +6135,8 @@ static void encode_superblock(const AV1_COMP *const cpi, ThreadData *td,
}
++td->counts->tx_size_totals[txsize_sqr_map[tx_size]];
++td->counts
->tx_size_totals[txsize_sqr_map[get_uv_tx_size(mbmi, &xd->plane[1])]];
++td->counts->tx_size_totals[txsize_sqr_map[av1_get_uv_tx_size(
mbmi, &xd->plane[1])]];
#if !CONFIG_TXK_SEL
av1_update_tx_type_count(cm, xd, bsize, tx_size, td->counts);
#endif
......
......@@ -932,7 +932,7 @@ void av1_encode_sb(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize, int mi_row,
av1_get_entropy_contexts(bsize, 0, pd, ctx.ta[plane], ctx.tl[plane]);
#else
const struct macroblockd_plane *const pd = &xd->plane[plane];
const TX_SIZE tx_size = get_tx_size(plane, xd);
const TX_SIZE tx_size = av1_get_tx_size(plane, xd);
av1_get_entropy_contexts(bsize, tx_size, pd, ctx.ta[plane], ctx.tl[plane]);
#endif
......@@ -973,7 +973,7 @@ void av1_encode_sb_supertx(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize) {
#if CONFIG_VAR_TX
const TX_SIZE tx_size = TX_4X4;
#else
const TX_SIZE tx_size = get_tx_size(plane, xd);
const TX_SIZE tx_size = av1_get_tx_size(plane, xd);
#endif
av1_subtract_plane(x, bsize, plane);
av1_get_entropy_contexts(bsize, tx_size, pd, ctx.ta[plane], ctx.tl[plane]);
......@@ -1432,7 +1432,7 @@ void av1_encode_intra_block_plane(AV1_COMMON *cm, MACROBLOCK *x,
if (enable_optimize_b) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
const TX_SIZE tx_size = get_tx_size(plane, xd);
const TX_SIZE tx_size = av1_get_tx_size(plane, xd);
av1_get_entropy_contexts(bsize, tx_size, pd, ta, tl);
}
av1_foreach_transformed_block_in_plane(
......
......@@ -197,7 +197,7 @@ void av1_write_coeffs_mb(const AV1_COMMON *const cm, MACROBLOCK *x,
#endif
const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
TX_SIZE tx_size = get_tx_size(plane, xd);
const TX_SIZE tx_size = av1_get_tx_size(plane, xd);
const int bkw = tx_size_wide_unit[tx_size];
const int bkh = tx_size_high_unit[tx_size];
const int step = tx_size_wide_unit[tx_size] * tx_size_high_unit[tx_size];
......
......@@ -1365,7 +1365,7 @@ static int cost_coeffs(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
#if !CONFIG_VAR_TX && !CONFIG_SUPERTX
// Check for consistency of tx_size with mode info
assert(tx_size == get_tx_size(plane, xd));
assert(tx_size == av1_get_tx_size(plane, xd));
#endif // !CONFIG_VAR_TX && !CONFIG_SUPERTX
(void)cm;
......@@ -1807,7 +1807,7 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
RD_STATS this_rd_stats;
#if !CONFIG_SUPERTX && !CONFIG_VAR_TX
assert(tx_size == get_tx_size(plane, xd));
assert(tx_size == av1_get_tx_size(plane, xd));
#endif // !CONFIG_SUPERTX
av1_init_rd_stats(&this_rd_stats);
......@@ -4170,7 +4170,7 @@ static int super_block_uvrd(const AV1_COMP *const cpi, MACROBLOCK *x,
int64_t ref_best_rd) {
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
const TX_SIZE uv_tx_size = get_uv_tx_size(mbmi, &xd->plane[1]);
const TX_SIZE uv_tx_size = av1_get_uv_tx_size(mbmi, &xd->plane[1]);
int plane;
int is_cost_valid = 1;
av1_init_rd_stats(rd_stats);
......@@ -5527,7 +5527,7 @@ static int64_t rd_pick_intra_sbuv_mode(const AV1_COMP *const cpi, MACROBLOCK *x,
#if CONFIG_CFL
int cfl_alpha_rate = 0;
if (mode == DC_PRED) {
const TX_SIZE uv_tx_size = get_uv_tx_size(mbmi, &xd->plane[1]);
const TX_SIZE uv_tx_size = av1_get_uv_tx_size(mbmi, &xd->plane[1]);
cfl_alpha_rate = cfl_rd_pick_alpha(x, uv_tx_size);
}
#endif
......
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