Commit 5b7706a7 authored by Jingning Han's avatar Jingning Han

Clean up supertx functions

Avoid comparing values from different enums.

Change-Id: I405f87942a64e86bda899b84a142c4d64414dd81
parent 415ba93b
......@@ -840,12 +840,13 @@ static void dec_extend_dir(AV1Decoder *const pbi, MACROBLOCKD *const xd,
}
}
} else if (dir == 2 || dir == 3) {
extend_bsize = (mi_height == 1 || bsize < BLOCK_8X8 || yss < xss)
? BLOCK_8X8
: BLOCK_8X16;
unit = num_8x8_blocks_high_lookup[extend_bsize];
extend_bsize =
(mi_height == mi_size_high[BLOCK_8X8] || bsize < BLOCK_8X8 || yss < xss)
? BLOCK_8X8
: BLOCK_8X16;
unit = mi_size_high[extend_bsize];
mi_row_pred = mi_row;
mi_col_pred = mi_col + ((dir == 3) ? mi_width : -1);
mi_col_pred = mi_col + ((dir == 3) ? mi_width : -mi_size_wide[BLOCK_8X8]);
dec_predict_b_extend(pbi, xd, tile, block, mi_row, mi_col, mi_row_pred,
mi_col_pred, mi_row_top, mi_col_top, dst_buf,
......@@ -862,8 +863,10 @@ static void dec_extend_dir(AV1Decoder *const pbi, MACROBLOCKD *const xd,
}
} else {
extend_bsize = BLOCK_8X8;
mi_row_pred = mi_row + ((dir == 4 || dir == 6) ? mi_height : -1);
mi_col_pred = mi_col + ((dir == 6 || dir == 7) ? mi_width : -1);
mi_row_pred = mi_row + ((dir == 4 || dir == 6) ? mi_height
: -mi_size_high[BLOCK_8X8]);
mi_col_pred =
mi_col + ((dir == 6 || dir == 7) ? mi_width : -mi_size_wide[BLOCK_8X8]);
dec_predict_b_extend(pbi, xd, tile, block, mi_row, mi_col, mi_row_pred,
mi_col_pred, mi_row_top, mi_col_top, dst_buf,
dst_stride, top_bsize, extend_bsize, b_sub8x8, 1);
......@@ -899,7 +902,7 @@ static void dec_predict_sb_complex(AV1Decoder *const pbi, MACROBLOCKD *const xd,
BLOCK_SIZE bsize, BLOCK_SIZE top_bsize,
uint8_t *dst_buf[3], int dst_stride[3]) {
const AV1_COMMON *const cm = &pbi->common;
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_EXT_PARTITION_TYPES
......@@ -1327,10 +1330,8 @@ static void dec_predict_sb_complex(AV1Decoder *const pbi, MACROBLOCKD *const xd,
static void set_segment_id_supertx(const AV1_COMMON *const cm, const int mi_row,
const int mi_col, const BLOCK_SIZE bsize) {
const struct segmentation *seg = &cm->seg;
const int miw =
AOMMIN(num_8x8_blocks_wide_lookup[bsize], cm->mi_cols - mi_col);
const int mih =
AOMMIN(num_8x8_blocks_high_lookup[bsize], cm->mi_rows - mi_row);
const int miw = AOMMIN(mi_size_wide[bsize], cm->mi_cols - mi_col);
const int mih = AOMMIN(mi_size_high[bsize], cm->mi_rows - mi_row);
const int mi_offset = mi_row * cm->mi_stride + mi_col;
MODE_INFO **const mip = cm->mi_grid_visible + mi_offset;
int r, c;
......@@ -1761,7 +1762,7 @@ static void decode_partition(AV1Decoder *const pbi, MACROBLOCKD *const xd,
#if CONFIG_SUPERTX
const int read_token = !supertx_enabled;
int skip = 0;
TX_SIZE supertx_size = b_width_log2_lookup[bsize];
TX_SIZE supertx_size = b_width_log2_lookup[bsize] + CONFIG_CB4X4;
const TileInfo *const tile = &xd->tile;
int txfm = DCT_DCT;
#endif // CONFIG_SUPERTX
......@@ -1964,8 +1965,8 @@ 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, num_8x8_blocks_high_lookup[bsize], mi_col,
num_8x8_blocks_wide_lookup[bsize], cm->mi_rows, cm->mi_cols);
set_mi_row_col(xd, tile, mi_row, mi_size_high[bsize], mi_col,
mi_size_wide[bsize], 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) {
......@@ -2009,19 +2010,11 @@ static void decode_partition(AV1Decoder *const pbi, MACROBLOCKD *const xd,
const struct macroblockd_plane *const pd = &xd->plane[i];
int row, col;
const TX_SIZE tx_size = i ? get_uv_tx_size(mbmi, pd) : mbmi->tx_size;
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];
int max_blocks_wide =
pd->width + (xd->mb_to_right_edge >= 0
? 0
: xd->mb_to_right_edge >> (3 + pd->subsampling_x));
int max_blocks_high =
pd->height +
(xd->mb_to_bottom_edge >= 0 ? 0 : xd->mb_to_bottom_edge >>
(3 + pd->subsampling_y));
max_blocks_wide >>= tx_size_wide_log2[0];
max_blocks_high >>= tx_size_wide_log2[0];
const int max_blocks_wide = max_block_wide(xd, plane_bsize, i);
const int max_blocks_high = max_block_high(xd, plane_bsize, i);
for (row = 0; row < max_blocks_high; row += stepr)
for (col = 0; col < max_blocks_wide; col += stepc)
......
......@@ -734,7 +734,7 @@ static void update_supertx_probs(AV1_COMMON *cm, int probwt, aom_writer *w) {
int savings = 0;
int do_update = 0;
for (i = 0; i < PARTITION_SUPERTX_CONTEXTS; ++i) {
for (j = 1; j < TX_SIZES; ++j) {
for (j = TX_8X8; j < TX_SIZES; ++j) {
savings += av1_cond_prob_diff_update_savings(
&cm->fc->supertx_prob[i][j], cm->counts.supertx[i][j], probwt);
}
......@@ -743,7 +743,7 @@ static void update_supertx_probs(AV1_COMMON *cm, int probwt, aom_writer *w) {
aom_write(w, do_update, GROUP_DIFF_UPDATE_PROB);
if (do_update) {
for (i = 0; i < PARTITION_SUPERTX_CONTEXTS; ++i) {
for (j = 1; j < TX_SIZES; ++j) {
for (j = TX_8X8; j < TX_SIZES; ++j) {
av1_cond_prob_diff_update(w, &cm->fc->supertx_prob[i][j],
cm->counts.supertx[i][j], probwt);
}
......@@ -2246,8 +2246,8 @@ 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, num_8x8_blocks_high_lookup[bsize], mi_col,
num_8x8_blocks_wide_lookup[bsize], cm->mi_rows, cm->mi_cols);
set_mi_row_col(xd, tile, mi_row, mi_size_high[bsize], mi_col,
mi_size_wide[bsize], 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]) {
......@@ -2332,8 +2332,8 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
#if CONFIG_SUPERTX
if (partition != PARTITION_NONE && supertx_enabled && pack_token) {
int skip;
const int bsw = num_8x8_blocks_wide_lookup[bsize];
const int bsh = num_8x8_blocks_high_lookup[bsize];
const int bsw = mi_size_wide[bsize];
const int bsh = mi_size_high[bsize];
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, cm->mi_rows,
......@@ -2363,19 +2363,25 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
if (!skip) {
assert(*tok < tok_end);
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
const int mbmi_txb_size = txsize_to_bsize[mbmi->tx_size];
const int num_4x4_w = num_4x4_blocks_wide_lookup[mbmi_txb_size];
const int num_4x4_h = num_4x4_blocks_high_lookup[mbmi_txb_size];
const BLOCK_SIZE plane_bsize = get_plane_block_size(mbmi_txb_size, pd);
const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
int row, col;
TX_SIZE tx =
plane ? get_uv_tx_size(mbmi, &xd->plane[plane]) : mbmi->tx_size;
BLOCK_SIZE txb_size = txsize_to_bsize[tx];
int bw = num_4x4_blocks_wide_lookup[txb_size];
const int stepr = tx_size_high_unit[txb_size];
const int stepc = tx_size_wide_unit[txb_size];
TOKEN_STATS token_stats;
token_stats.cost = 0;
for (row = 0; row < num_4x4_h; row += bw)
for (col = 0; col < num_4x4_w; col += bw)
for (row = 0; row < max_blocks_high; row += stepr)
for (col = 0; col < max_blocks_wide; col += stepc)
pack_mb_tokens(w, tok, tok_end, cm->bit_depth, tx, &token_stats);
assert(*tok < tok_end && (*tok)->token == EOSB_TOKEN);
(*tok)++;
......
......@@ -343,8 +343,8 @@ static void set_offsets_supertx(const AV1_COMP *const cpi, ThreadData *td,
MACROBLOCK *const x = &td->mb;
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];
set_mode_info_offsets(cpi, x, xd, mi_row, mi_col);
......@@ -364,8 +364,8 @@ static void set_offsets_extend(const AV1_COMP *const cpi, ThreadData *td,
MACROBLOCK *const x = &td->mb;
const AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
const int mi_width = num_8x8_blocks_wide_lookup[bsize_pred];
const int mi_height = num_8x8_blocks_high_lookup[bsize_pred];
const int mi_width = mi_size_wide[bsize_pred];
const int mi_height = mi_size_high[bsize_pred];
set_mode_info_offsets(cpi, x, xd, mi_row_ori, mi_col_ori);
......@@ -377,7 +377,8 @@ static void set_offsets_extend(const AV1_COMP *const cpi, ThreadData *td,
x->mv_col_max = (cm->mi_cols - mi_col_pred) * MI_SIZE + AOM_INTERP_EXTEND;
// Set up distance of MB to edge of frame in 1/8th pel units.
assert(!(mi_col_pred & (mi_width - 1)) && !(mi_row_pred & (mi_height - 1)));
assert(!(mi_col_pred & (mi_width - mi_size_wide[BLOCK_8X8])) &&
!(mi_row_pred & (mi_height - mi_size_high[BLOCK_8X8])));
set_mi_row_col(xd, tile, mi_row_pred, mi_height, mi_col_pred, mi_width,
cm->mi_rows, cm->mi_cols);
xd->up_available = (mi_row_ori > tile->mi_row_start);
......@@ -393,10 +394,8 @@ static void set_segment_id_supertx(const AV1_COMP *const cpi,
const int mi_col, const BLOCK_SIZE bsize) {
const AV1_COMMON *cm = &cpi->common;
const struct segmentation *seg = &cm->seg;
const int miw =
AOMMIN(num_8x8_blocks_wide_lookup[bsize], cm->mi_cols - mi_col);
const int mih =
AOMMIN(num_8x8_blocks_high_lookup[bsize], cm->mi_rows - mi_row);
const int miw = AOMMIN(mi_size_wide[bsize], cm->mi_cols - mi_col);
const int mih = AOMMIN(mi_size_high[bsize], cm->mi_rows - mi_row);
const int mi_offset = mi_row * cm->mi_stride + mi_col;
MODE_INFO **const mip = cm->mi_grid_visible + mi_offset;
int r, c;
......@@ -1240,8 +1239,8 @@ static void update_state_supertx(const AV1_COMP *const cpi, ThreadData *td,
MODE_INFO *mi_addr = xd->mi[0];
const struct segmentation *const seg = &cm->seg;
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 x_mis = AOMMIN(mi_width, cm->mi_cols - mi_col);
const int y_mis = AOMMIN(mi_height, cm->mi_rows - mi_row);
MV_REF *const frame_mvs = cm->cur_frame->mvs + mi_row * cm->mi_cols + mi_col;
......@@ -1403,7 +1402,7 @@ static void update_state_sb_supertx(const AV1_COMP *const cpi, ThreadData *td,
MACROBLOCKD *const xd = &x->e_mbd;
struct macroblock_plane *const p = x->plane;
struct macroblockd_plane *const pd = xd->plane;
int bsl = b_width_log2_lookup[bsize], hbs = (1 << bsl) / 4;
int hbs = mi_size_wide[bsize] / 2;
PARTITION_TYPE partition = pc_tree->partitioning;
BLOCK_SIZE subsize = get_subsize(bsize, partition);
int i;
......@@ -1556,7 +1555,7 @@ static void update_supertx_param_sb(const AV1_COMP *const cpi, ThreadData *td,
int best_tx, TX_SIZE supertx_size,
PC_TREE *pc_tree) {
const AV1_COMMON *const cm = &cpi->common;
int bsl = b_width_log2_lookup[bsize], hbs = (1 << bsl) / 4;
const int hbs = mi_size_wide[bsize] / 2;
PARTITION_TYPE partition = pc_tree->partitioning;
BLOCK_SIZE subsize = get_subsize(bsize, partition);
#if CONFIG_EXT_PARTITION_TYPES
......@@ -2281,8 +2280,8 @@ static void encode_sb(const AV1_COMP *const cpi, ThreadData *td,
TX_SIZE supertx_size = max_txsize_lookup[bsize];
supertx_enabled = check_supertx_sb(bsize, supertx_size, pc_tree);
if (supertx_enabled) {
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 x_idx, y_idx, i;
uint8_t *dst_buf[3];
int dst_stride[3];
......
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