Commit 1fa9ba4c authored by Jonathan Matthews's avatar Jonathan Matthews Committed by Hui Su

Revert "Reduce memory usage of inter_tx_size[] in MB_MODE_INFO"

This reverts Change-Id: Ie11dd055255d200954b704b8c2ad8ca3dff7bf5c

BUG=aomedia:1305

Change-Id: I6894928dcadc99a79417034a7096a215693a46f2
parent a78c8f5f
...@@ -1419,8 +1419,11 @@ static void get_filter_level_and_masks_non420( ...@@ -1419,8 +1419,11 @@ static void get_filter_level_and_masks_non420(
const int col_mask = 1 << c_step; const int col_mask = 1 << c_step;
if (is_inter_block(mbmi) && !mbmi->skip) { if (is_inter_block(mbmi) && !mbmi->skip) {
const TX_SIZE mb_tx_size = mbmi->inter_tx_size[av1_get_txb_size_index( const int tx_row_idx =
sb_type, blk_row, blk_col)]; (blk_row * mi_size_high[BLOCK_8X8] << TX_UNIT_HIGH_LOG2) >> 1;
const int tx_col_idx =
(blk_col * mi_size_wide[BLOCK_8X8] << TX_UNIT_WIDE_LOG2) >> 1;
const TX_SIZE mb_tx_size = mbmi->inter_tx_size[tx_row_idx][tx_col_idx];
tx_size = (plane->plane_type == PLANE_TYPE_UV) tx_size = (plane->plane_type == PLANE_TYPE_UV)
? av1_get_uv_tx_size(mbmi, ss_x, ss_y) ? av1_get_uv_tx_size(mbmi, ss_x, ss_y)
: mb_tx_size; : mb_tx_size;
...@@ -2002,8 +2005,11 @@ static TX_SIZE av1_get_transform_size( ...@@ -2002,8 +2005,11 @@ static TX_SIZE av1_get_transform_size(
const int blk_col = c & (num_8x8_blocks_wide_lookup[sb_type] - 1); const int blk_col = c & (num_8x8_blocks_wide_lookup[sb_type] - 1);
if (is_inter_block(mbmi) && !mbmi->skip) { if (is_inter_block(mbmi) && !mbmi->skip) {
const TX_SIZE mb_tx_size = const int tx_row_idx =
mbmi->inter_tx_size[av1_get_txb_size_index(sb_type, blk_row, blk_col)]; (blk_row * mi_size_high[BLOCK_8X8] << TX_UNIT_HIGH_LOG2) >> 1;
const int tx_col_idx =
(blk_col * mi_size_wide[BLOCK_8X8] << TX_UNIT_WIDE_LOG2) >> 1;
const TX_SIZE mb_tx_size = mbmi->inter_tx_size[tx_row_idx][tx_col_idx];
assert(mb_tx_size < TX_SIZES_ALL); assert(mb_tx_size < TX_SIZES_ALL);
......
...@@ -231,19 +231,16 @@ typedef struct { ...@@ -231,19 +231,16 @@ typedef struct {
COMPOUND_TYPE interinter_compound_type; COMPOUND_TYPE interinter_compound_type;
} INTERINTER_COMPOUND_DATA; } INTERINTER_COMPOUND_DATA;
#if CONFIG_TX64X64 // This structure now relates to 8x8 block regions.
#define INTER_TX_SIZE_BUF_LEN 16
#else
#define INTER_TX_SIZE_BUF_LEN 256
#endif
// This structure now relates to 4x4 block regions.
typedef struct MB_MODE_INFO { typedef struct MB_MODE_INFO {
// Common for both INTER and INTRA blocks // Common for both INTER and INTRA blocks
BLOCK_SIZE sb_type; BLOCK_SIZE sb_type;
PREDICTION_MODE mode; PREDICTION_MODE mode;
TX_SIZE tx_size; TX_SIZE tx_size;
// TODO(jingning): This effectively assigned a separate entry for each
// 8x8 block. Apparently it takes much more space than needed.
TX_SIZE inter_tx_size[MAX_MIB_SIZE][MAX_MIB_SIZE];
TX_SIZE min_tx_size; TX_SIZE min_tx_size;
uint8_t inter_tx_size[INTER_TX_SIZE_BUF_LEN];
int8_t skip; int8_t skip;
#if CONFIG_EXT_SKIP #if CONFIG_EXT_SKIP
int8_t skip_mode; int8_t skip_mode;
...@@ -892,20 +889,6 @@ get_plane_block_size(BLOCK_SIZE bsize, const struct macroblockd_plane *pd) { ...@@ -892,20 +889,6 @@ get_plane_block_size(BLOCK_SIZE bsize, const struct macroblockd_plane *pd) {
return ss_size_lookup[bsize][pd->subsampling_x][pd->subsampling_y]; return ss_size_lookup[bsize][pd->subsampling_x][pd->subsampling_y];
} }
static INLINE int av1_get_txb_size_index(BLOCK_SIZE bsize, int blk_row,
int blk_col) {
TX_SIZE txs = max_txsize_rect_lookup[1][bsize];
for (int level = 0; level < MAX_VARTX_DEPTH - 1; ++level)
txs = sub_tx_size_map[1][txs];
const int tx_w = tx_size_wide_unit[txs];
const int tx_h = tx_size_high_unit[txs];
const int bw_uint = mi_size_wide[bsize];
const int stride = bw_uint / tx_w;
const int index = (blk_row / tx_h) * stride + (blk_col / tx_w);
assert(index < INTER_TX_SIZE_BUF_LEN);
return index;
}
static INLINE TX_TYPE av1_get_tx_type(PLANE_TYPE plane_type, static INLINE TX_TYPE av1_get_tx_type(PLANE_TYPE plane_type,
const MACROBLOCKD *xd, int blk_row, const MACROBLOCKD *xd, int blk_row,
int blk_col, TX_SIZE tx_size, int blk_col, TX_SIZE tx_size,
......
...@@ -190,10 +190,11 @@ static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd, ...@@ -190,10 +190,11 @@ static void decode_reconstruct_tx(AV1_COMMON *cm, MACROBLOCKD *const xd,
(void)mi_row; (void)mi_row;
(void)mi_col; (void)mi_col;
const struct macroblockd_plane *const pd = &xd->plane[plane]; const struct macroblockd_plane *const pd = &xd->plane[plane];
const int tx_row = blk_row >> (1 - pd->subsampling_y);
const int tx_col = blk_col >> (1 - pd->subsampling_x);
const TX_SIZE plane_tx_size = const TX_SIZE plane_tx_size =
plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y) plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y)
: mbmi->inter_tx_size[av1_get_txb_size_index(plane_bsize, blk_row, : mbmi->inter_tx_size[tx_row][tx_col];
blk_col)];
// Scale to match transform block unit. // Scale to match transform block unit.
const int max_blocks_high = max_block_high(xd, plane_bsize, plane); const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane); const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
......
...@@ -353,20 +353,22 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -353,20 +353,22 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd,
FRAME_CONTEXT *ec_ctx = xd->tile_ctx; FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
(void)cm; (void)cm;
int is_split = 0; int is_split = 0;
const BLOCK_SIZE bsize = mbmi->sb_type; const int tx_row = blk_row >> 1;
const int max_blocks_high = max_block_high(xd, bsize, 0); const int tx_col = blk_col >> 1;
const int max_blocks_wide = max_block_wide(xd, bsize, 0); const int max_blocks_high = max_block_high(xd, mbmi->sb_type, 0);
const int max_blocks_wide = max_block_wide(xd, mbmi->sb_type, 0);
TX_SIZE(*const inter_tx_size)
[MAX_MIB_SIZE] =
(TX_SIZE(*)[MAX_MIB_SIZE]) & mbmi->inter_tx_size[tx_row][tx_col];
if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return; if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
assert(tx_size > TX_4X4); assert(tx_size > TX_4X4);
if (depth == MAX_VARTX_DEPTH) { if (depth == MAX_VARTX_DEPTH) {
for (int idy = 0; idy < tx_size_high_unit[tx_size]; ++idy) { int idx, idy;
for (int idx = 0; idx < tx_size_wide_unit[tx_size]; ++idx) { inter_tx_size[0][0] = tx_size;
const int index = for (idy = 0; idy < AOMMAX(1, tx_size_high_unit[tx_size] / 2); ++idy)
av1_get_txb_size_index(bsize, blk_row + idy, blk_col + idx); for (idx = 0; idx < AOMMAX(1, tx_size_wide_unit[tx_size] / 2); ++idx)
mbmi->inter_tx_size[index] = tx_size; inter_tx_size[idy][idx] = tx_size;
}
}
mbmi->tx_size = tx_size; mbmi->tx_size = tx_size;
mbmi->min_tx_size = TXSIZEMIN(mbmi->min_tx_size, tx_size); mbmi->min_tx_size = TXSIZEMIN(mbmi->min_tx_size, tx_size);
txfm_partition_update(xd->above_txfm_context + blk_col, txfm_partition_update(xd->above_txfm_context + blk_col,
...@@ -374,9 +376,9 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -374,9 +376,9 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd,
return; return;
} }
const int ctx = txfm_partition_context(xd->above_txfm_context + blk_col, int ctx = txfm_partition_context(xd->above_txfm_context + blk_col,
xd->left_txfm_context + blk_row, xd->left_txfm_context + blk_row,
mbmi->sb_type, tx_size); mbmi->sb_type, tx_size);
is_split = aom_read_symbol(r, ec_ctx->txfm_partition_cdf[ctx], 2, ACCT_STR); is_split = aom_read_symbol(r, ec_ctx->txfm_partition_cdf[ctx], 2, ACCT_STR);
if (is_split) { if (is_split) {
...@@ -385,13 +387,11 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -385,13 +387,11 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd,
const int bsh = tx_size_high_unit[sub_txs]; const int bsh = tx_size_high_unit[sub_txs];
if (sub_txs == TX_4X4) { if (sub_txs == TX_4X4) {
for (int idy = 0; idy < tx_size_high_unit[tx_size]; ++idy) { int idx, idy;
for (int idx = 0; idx < tx_size_wide_unit[tx_size]; ++idx) { inter_tx_size[0][0] = sub_txs;
const int index = for (idy = 0; idy < AOMMAX(1, tx_size_high_unit[tx_size] / 2); ++idy)
av1_get_txb_size_index(bsize, blk_row + idy, blk_col + idx); for (idx = 0; idx < AOMMAX(1, tx_size_wide_unit[tx_size] / 2); ++idx)
mbmi->inter_tx_size[index] = sub_txs; inter_tx_size[idy][idx] = inter_tx_size[0][0];
}
}
mbmi->tx_size = sub_txs; mbmi->tx_size = sub_txs;
mbmi->min_tx_size = mbmi->tx_size; mbmi->min_tx_size = mbmi->tx_size;
txfm_partition_update(xd->above_txfm_context + blk_col, txfm_partition_update(xd->above_txfm_context + blk_col,
...@@ -409,13 +409,11 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -409,13 +409,11 @@ static void read_tx_size_vartx(AV1_COMMON *cm, MACROBLOCKD *xd,
} }
} }
} else { } else {
for (int idy = 0; idy < tx_size_high_unit[tx_size]; ++idy) { int idx, idy;
for (int idx = 0; idx < tx_size_wide_unit[tx_size]; ++idx) { inter_tx_size[0][0] = tx_size;
const int index = for (idy = 0; idy < AOMMAX(1, tx_size_high_unit[tx_size] / 2); ++idy)
av1_get_txb_size_index(bsize, blk_row + idy, blk_col + idx); for (idx = 0; idx < AOMMAX(1, tx_size_wide_unit[tx_size] / 2); ++idx)
mbmi->inter_tx_size[index] = tx_size; inter_tx_size[idy][idx] = tx_size;
}
}
mbmi->tx_size = tx_size; mbmi->tx_size = tx_size;
mbmi->min_tx_size = TXSIZEMIN(mbmi->min_tx_size, tx_size); mbmi->min_tx_size = TXSIZEMIN(mbmi->min_tx_size, tx_size);
txfm_partition_update(xd->above_txfm_context + blk_col, txfm_partition_update(xd->above_txfm_context + blk_col,
...@@ -935,7 +933,9 @@ static void read_intrabc_info(AV1_COMMON *const cm, MACROBLOCKD *const xd, ...@@ -935,7 +933,9 @@ static void read_intrabc_info(AV1_COMMON *const cm, MACROBLOCKD *const xd,
} }
} else { } else {
mbmi->tx_size = read_tx_size(cm, xd, 1, !mbmi->skip, r); mbmi->tx_size = read_tx_size(cm, xd, 1, !mbmi->skip, r);
memset(mbmi->inter_tx_size, mbmi->tx_size, sizeof(mbmi->inter_tx_size)); for (int idy = 0; idy < height; ++idy)
for (int idx = 0; idx < width; ++idx)
mbmi->inter_tx_size[idy >> 1][idx >> 1] = mbmi->tx_size;
mbmi->min_tx_size = mbmi->tx_size; mbmi->min_tx_size = mbmi->tx_size;
set_txfm_ctxs(mbmi->tx_size, xd->n8_w, xd->n8_h, mbmi->skip, xd); set_txfm_ctxs(mbmi->tx_size, xd->n8_w, xd->n8_h, mbmi->skip, xd);
} }
...@@ -2188,8 +2188,14 @@ static void read_inter_frame_mode_info(AV1Decoder *const pbi, ...@@ -2188,8 +2188,14 @@ static void read_inter_frame_mode_info(AV1Decoder *const pbi,
read_tx_size_vartx(cm, xd, mbmi, max_tx_size, 0, idy, idx, r); read_tx_size_vartx(cm, xd, mbmi, max_tx_size, 0, idy, idx, r);
} else { } else {
mbmi->tx_size = read_tx_size(cm, xd, inter_block, !mbmi->skip, r); mbmi->tx_size = read_tx_size(cm, xd, inter_block, !mbmi->skip, r);
if (inter_block)
memset(mbmi->inter_tx_size, mbmi->tx_size, sizeof(mbmi->inter_tx_size)); if (inter_block) {
const int width = block_size_wide[bsize] >> tx_size_wide_log2[0];
const int height = block_size_high[bsize] >> tx_size_high_log2[0];
for (int idy = 0; idy < height; ++idy)
for (int idx = 0; idx < width; ++idx)
mbmi->inter_tx_size[idy >> 1][idx >> 1] = mbmi->tx_size;
}
mbmi->min_tx_size = mbmi->tx_size; mbmi->min_tx_size = mbmi->tx_size;
set_txfm_ctxs(mbmi->tx_size, xd->n8_w, xd->n8_h, mbmi->skip, xd); set_txfm_ctxs(mbmi->tx_size, xd->n8_w, xd->n8_h, mbmi->skip, xd);
} }
......
...@@ -177,6 +177,8 @@ static void write_tx_size_vartx(const AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -177,6 +177,8 @@ static void write_tx_size_vartx(const AV1_COMMON *cm, MACROBLOCKD *xd,
aom_writer *w) { aom_writer *w) {
FRAME_CONTEXT *ec_ctx = xd->tile_ctx; FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
(void)cm; (void)cm;
const int tx_row = blk_row >> 1;
const int tx_col = blk_col >> 1;
const int max_blocks_high = max_block_high(xd, mbmi->sb_type, 0); const int max_blocks_high = max_block_high(xd, mbmi->sb_type, 0);
const int max_blocks_wide = max_block_wide(xd, mbmi->sb_type, 0); const int max_blocks_wide = max_block_wide(xd, mbmi->sb_type, 0);
...@@ -188,13 +190,12 @@ static void write_tx_size_vartx(const AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -188,13 +190,12 @@ static void write_tx_size_vartx(const AV1_COMMON *cm, MACROBLOCKD *xd,
return; return;
} }
const int ctx = txfm_partition_context(xd->above_txfm_context + blk_col, int ctx = txfm_partition_context(xd->above_txfm_context + blk_col,
xd->left_txfm_context + blk_row, xd->left_txfm_context + blk_row,
mbmi->sb_type, tx_size); mbmi->sb_type, tx_size);
const int txb_size_index =
av1_get_txb_size_index(mbmi->sb_type, blk_row, blk_col);
const int write_txfm_partition = const int write_txfm_partition =
tx_size == mbmi->inter_tx_size[txb_size_index]; tx_size == mbmi->inter_tx_size[tx_row][tx_col];
if (write_txfm_partition) { if (write_txfm_partition) {
aom_write_symbol(w, 0, ec_ctx->txfm_partition_cdf[ctx], 2); aom_write_symbol(w, 0, ec_ctx->txfm_partition_cdf[ctx], 2);
...@@ -463,6 +464,8 @@ static void pack_txb_tokens(aom_writer *w, AV1_COMMON *cm, MACROBLOCK *const x, ...@@ -463,6 +464,8 @@ static void pack_txb_tokens(aom_writer *w, AV1_COMMON *cm, MACROBLOCK *const x,
int block, int blk_row, int blk_col, int block, int blk_row, int blk_col,
TX_SIZE tx_size, TOKEN_STATS *token_stats) { TX_SIZE tx_size, TOKEN_STATS *token_stats) {
const struct macroblockd_plane *const pd = &xd->plane[plane]; const struct macroblockd_plane *const pd = &xd->plane[plane];
const int tx_row = blk_row >> (1 - pd->subsampling_y);
const int tx_col = blk_col >> (1 - pd->subsampling_x);
const int max_blocks_high = max_block_high(xd, plane_bsize, plane); const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane); const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
...@@ -470,8 +473,7 @@ static void pack_txb_tokens(aom_writer *w, AV1_COMMON *cm, MACROBLOCK *const x, ...@@ -470,8 +473,7 @@ static void pack_txb_tokens(aom_writer *w, AV1_COMMON *cm, MACROBLOCK *const x,
const TX_SIZE plane_tx_size = const TX_SIZE plane_tx_size =
plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y) plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y)
: mbmi->inter_tx_size[av1_get_txb_size_index(plane_bsize, blk_row, : mbmi->inter_tx_size[tx_row][tx_col];
blk_col)];
if (tx_size == plane_tx_size || plane) { if (tx_size == plane_tx_size || plane) {
TOKEN_STATS tmp_token_stats; TOKEN_STATS tmp_token_stats;
......
...@@ -113,7 +113,7 @@ typedef struct { ...@@ -113,7 +113,7 @@ typedef struct {
TX_TYPE tx_type; TX_TYPE tx_type;
TX_SIZE tx_size; TX_SIZE tx_size;
TX_SIZE min_tx_size; TX_SIZE min_tx_size;
TX_SIZE inter_tx_size[INTER_TX_SIZE_BUF_LEN]; TX_SIZE inter_tx_size[MAX_MIB_SIZE][MAX_MIB_SIZE];
uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE * 8]; uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE * 8];
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
TX_TYPE txk_type[MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)]; TX_TYPE txk_type[MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)];
......
...@@ -390,7 +390,10 @@ static void reset_tx_size(MACROBLOCKD *xd, MB_MODE_INFO *mbmi, ...@@ -390,7 +390,10 @@ static void reset_tx_size(MACROBLOCKD *xd, MB_MODE_INFO *mbmi,
mbmi->tx_size = (TX_SIZE)TXSIZEMAX(mbmi->tx_size, min_tx_size); mbmi->tx_size = (TX_SIZE)TXSIZEMAX(mbmi->tx_size, min_tx_size);
} }
if (is_inter_block(mbmi)) { if (is_inter_block(mbmi)) {
memset(mbmi->inter_tx_size, mbmi->tx_size, sizeof(mbmi->inter_tx_size)); for (int idy = 0; idy < xd->n8_h; ++idy) {
for (int idx = 0; idx < xd->n8_w; ++idx)
mbmi->inter_tx_size[idy][idx] = mbmi->tx_size;
}
mbmi->min_tx_size = mbmi->tx_size; mbmi->min_tx_size = mbmi->tx_size;
} }
} }
...@@ -4713,14 +4716,14 @@ static void update_txfm_count(MACROBLOCK *x, MACROBLOCKD *xd, ...@@ -4713,14 +4716,14 @@ static void update_txfm_count(MACROBLOCK *x, MACROBLOCKD *xd,
int blk_row, int blk_col, int blk_row, int blk_col,
uint8_t allow_update_cdf) { uint8_t allow_update_cdf) {
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
const BLOCK_SIZE bsize = mbmi->sb_type; const int tx_row = blk_row >> 1;
const int max_blocks_high = max_block_high(xd, bsize, 0); const int tx_col = blk_col >> 1;
const int max_blocks_wide = max_block_wide(xd, bsize, 0); const int max_blocks_high = max_block_high(xd, mbmi->sb_type, 0);
const int max_blocks_wide = max_block_wide(xd, mbmi->sb_type, 0);
int ctx = txfm_partition_context(xd->above_txfm_context + blk_col, int ctx = txfm_partition_context(xd->above_txfm_context + blk_col,
xd->left_txfm_context + blk_row, xd->left_txfm_context + blk_row,
mbmi->sb_type, tx_size); mbmi->sb_type, tx_size);
const int txb_size_index = av1_get_txb_size_index(bsize, blk_row, blk_col); const TX_SIZE plane_tx_size = mbmi->inter_tx_size[tx_row][tx_col];
const TX_SIZE plane_tx_size = mbmi->inter_tx_size[txb_size_index];
if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return; if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
assert(tx_size > TX_4X4); assert(tx_size > TX_4X4);
...@@ -4751,7 +4754,7 @@ static void update_txfm_count(MACROBLOCK *x, MACROBLOCKD *xd, ...@@ -4751,7 +4754,7 @@ static void update_txfm_count(MACROBLOCK *x, MACROBLOCKD *xd,
++x->txb_split_count; ++x->txb_split_count;
if (sub_txs == TX_4X4) { if (sub_txs == TX_4X4) {
mbmi->inter_tx_size[txb_size_index] = TX_4X4; mbmi->inter_tx_size[tx_row][tx_col] = TX_4X4;
mbmi->tx_size = TX_4X4; mbmi->tx_size = TX_4X4;
txfm_partition_update(xd->above_txfm_context + blk_col, txfm_partition_update(xd->above_txfm_context + blk_col,
xd->left_txfm_context + blk_row, TX_4X4, tx_size); xd->left_txfm_context + blk_row, TX_4X4, tx_size);
...@@ -4796,11 +4799,11 @@ static void tx_partition_count_update(const AV1_COMMON *const cm, MACROBLOCK *x, ...@@ -4796,11 +4799,11 @@ static void tx_partition_count_update(const AV1_COMMON *const cm, MACROBLOCK *x,
static void set_txfm_context(MACROBLOCKD *xd, TX_SIZE tx_size, int blk_row, static void set_txfm_context(MACROBLOCKD *xd, TX_SIZE tx_size, int blk_row,
int blk_col) { int blk_col) {
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi; MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
const BLOCK_SIZE bsize = mbmi->sb_type; const int tx_row = blk_row >> 1;
const int max_blocks_high = max_block_high(xd, bsize, 0); const int tx_col = blk_col >> 1;
const int max_blocks_wide = max_block_wide(xd, bsize, 0); const int max_blocks_high = max_block_high(xd, mbmi->sb_type, 0);
const int txb_size_index = av1_get_txb_size_index(bsize, blk_row, blk_col); const int max_blocks_wide = max_block_wide(xd, mbmi->sb_type, 0);
const TX_SIZE plane_tx_size = mbmi->inter_tx_size[txb_size_index]; const TX_SIZE plane_tx_size = mbmi->inter_tx_size[tx_row][tx_col];
if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return; if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return;
...@@ -4811,7 +4814,7 @@ static void set_txfm_context(MACROBLOCKD *xd, TX_SIZE tx_size, int blk_row, ...@@ -4811,7 +4814,7 @@ static void set_txfm_context(MACROBLOCKD *xd, TX_SIZE tx_size, int blk_row,
} else { } else {
if (tx_size == TX_8X8) { if (tx_size == TX_8X8) {
mbmi->inter_tx_size[txb_size_index] = TX_4X4; mbmi->inter_tx_size[tx_row][tx_col] = TX_4X4;
mbmi->tx_size = TX_4X4; mbmi->tx_size = TX_4X4;
txfm_partition_update(xd->above_txfm_context + blk_col, txfm_partition_update(xd->above_txfm_context + blk_col,
xd->left_txfm_context + blk_row, TX_4X4, tx_size); xd->left_txfm_context + blk_row, TX_4X4, tx_size);
......
...@@ -612,6 +612,8 @@ static void encode_block_inter(int plane, int block, int blk_row, int blk_col, ...@@ -612,6 +612,8 @@ static void encode_block_inter(int plane, int block, int blk_row, int blk_col,
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
const struct macroblockd_plane *const pd = &xd->plane[plane]; const struct macroblockd_plane *const pd = &xd->plane[plane];
const int tx_row = blk_row >> (1 - pd->subsampling_y);
const int tx_col = blk_col >> (1 - pd->subsampling_x);
const int max_blocks_high = max_block_high(xd, plane_bsize, plane); const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane); const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
...@@ -619,8 +621,7 @@ static void encode_block_inter(int plane, int block, int blk_row, int blk_col, ...@@ -619,8 +621,7 @@ static void encode_block_inter(int plane, int block, int blk_row, int blk_col,
const TX_SIZE plane_tx_size = const TX_SIZE plane_tx_size =
plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y) plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y)
: mbmi->inter_tx_size[av1_get_txb_size_index(plane_bsize, blk_row, : mbmi->inter_tx_size[tx_row][tx_col];
blk_col)];
if (tx_size == plane_tx_size || plane) { if (tx_size == plane_tx_size || plane) {
encode_block(plane, block, blk_row, blk_col, plane_bsize, tx_size, arg, encode_block(plane, block, blk_row, blk_col, plane_bsize, tx_size, arg,
......
...@@ -3856,6 +3856,11 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row, ...@@ -3856,6 +3856,11 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
struct macroblock_plane *const p = &x->plane[plane]; struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane];
const int tx_row = blk_row >> (1 - pd->subsampling_y);
const int tx_col = blk_col >> (1 - pd->subsampling_x);
TX_SIZE(*const inter_tx_size)
[MAX_MIB_SIZE] =
(TX_SIZE(*)[MAX_MIB_SIZE]) & mbmi->inter_tx_size[tx_row][tx_col];
const int max_blocks_high = max_block_high(xd, plane_bsize, plane); const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane); const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
const int bw = block_size_wide[plane_bsize] >> tx_size_wide_log2[0]; const int bw = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
...@@ -3903,8 +3908,7 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row, ...@@ -3903,8 +3908,7 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
rd_stats->ref_rdcost = ref_best_rd; rd_stats->ref_rdcost = ref_best_rd;
rd_stats->zero_rate = zero_blk_rate; rd_stats->zero_rate = zero_blk_rate;
if (cpi->common.tx_mode == TX_MODE_SELECT || tx_size == TX_4X4) { if (cpi->common.tx_mode == TX_MODE_SELECT || tx_size == TX_4X4) {
const int index = av1_get_txb_size_index(plane_bsize, blk_row, blk_col); inter_tx_size[0][0] = tx_size;
mbmi->inter_tx_size[index] = tx_size;
av1_tx_block_rd_b( av1_tx_block_rd_b(
cpi, x, tx_size, blk_row, blk_col, plane, block, plane_bsize, pta, ptl, cpi, x, tx_size, blk_row, blk_col, plane, block, plane_bsize, pta, ptl,
rd_stats, fast, rd_stats, fast,
...@@ -4100,7 +4104,8 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row, ...@@ -4100,7 +4104,8 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
} }
if (this_rd < sum_rd) { if (this_rd < sum_rd) {
const TX_SIZE tx_size_selected = tx_size; int idx, idy;
TX_SIZE tx_size_selected = tx_size;
#if CONFIG_LV_MAP #if CONFIG_LV_MAP
p->txb_entropy_ctx[block] = tmp_eob; p->txb_entropy_ctx[block] = tmp_eob;
...@@ -4112,14 +4117,10 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row, ...@@ -4112,14 +4117,10 @@ static void select_tx_block(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
txfm_partition_update(tx_above + blk_col, tx_left + blk_row, tx_size, txfm_partition_update(tx_above + blk_col, tx_left + blk_row, tx_size,
tx_size); tx_size);
for (int idy = 0; idy < tx_size_high_unit[tx_size]; ++idy) { inter_tx_size[0][0] = tx_size_selected;
for (int idx = 0; idx < tx_size_wide_unit[tx_size]; ++idx) { for (idy = 0; idy < AOMMAX(1, tx_size_high_unit[tx_size] / 2); ++idy)
const int index = for (idx = 0; idx < AOMMAX(1, tx_size_wide_unit[tx_size] / 2); ++idx)
av1_get_txb_size_index(plane_bsize, blk_row + idy, blk_col + idx); inter_tx_size[idy][idx] = tx_size_selected;
mbmi->inter_tx_size[index] = tx_size_selected;
}
}
mbmi->tx_size = tx_size_selected; mbmi->tx_size = tx_size_selected;
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
mbmi->txk_type[txk_idx] = best_tx_type; mbmi->txk_type[txk_idx] = best_tx_type;
...@@ -4217,6 +4218,7 @@ static int64_t select_tx_size_fix_type(const AV1_COMP *cpi, MACROBLOCK *x, ...@@ -4217,6 +4218,7 @@ static int64_t select_tx_size_fix_type(const AV1_COMP *cpi, MACROBLOCK *x,
int s0 = x->skip_cost[skip_ctx][0]; int s0 = x->skip_cost[skip_ctx][0];
int s1 = x->skip_cost[skip_ctx][1]; int s1 = x->skip_cost[skip_ctx][1];
int64_t rd; int64_t rd;
int row, col;
const int max_blocks_high = max_block_high(xd, bsize, 0); const int max_blocks_high = max_block_high(xd, bsize, 0);
const int max_blocks_wide = max_block_wide(xd, bsize, 0); const int max_blocks_wide = max_block_wide(xd, bsize, 0);
...@@ -4235,14 +4237,11 @@ static int64_t select_tx_size_fix_type(const AV1_COMP *cpi, MACROBLOCK *x, ...@@ -4235,14 +4237,11 @@ static int64_t select_tx_size_fix_type(const AV1_COMP *cpi, MACROBLOCK *x,
rd_info_tree); rd_info_tree);
if (rd_stats->rate == INT_MAX) return INT64_MAX; if (rd_stats->rate == INT_MAX) return INT64_MAX;
mbmi->min_tx_size = mbmi->inter_tx_size[0]; mbmi->min_tx_size = mbmi->inter_tx_size[0][0];
for (int row = 0; row < max_blocks_high; ++row) { for (row = 0; row < max_blocks_high / 2; ++row)
for (int col = 0; col < max_blocks_wide; ++col) { for (col = 0; col < max_blocks_wide / 2; ++col)
const int index = av1_get_txb_size_index(bsize, row, col);
mbmi->min_tx_size = mbmi->min_tx_size =
TXSIZEMIN(mbmi->min_tx_size, mbmi->inter_tx_size[index]); TXSIZEMIN(mbmi->min_tx_size, mbmi->inter_tx_size[row][col]);
}
}
if (fast) { if (fast) {
// Do a better (non-fast) search with tx sizes already decided. // Do a better (non-fast) search with tx sizes already decided.
...@@ -4288,6 +4287,8 @@ static void tx_block_yrd(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row, ...@@ -4288,6 +4287,8 @@ static void tx_block_yrd(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
struct macroblockd_plane *const pd = &xd->plane[plane]; struct macroblockd_plane *const pd = &xd->plane[plane];
const int tx_row = blk_row >> (1 - pd->subsampling_y);
const int tx_col = blk_col >> (1 - pd->subsampling_x);
const int max_blocks_high = max_block_high(xd, plane_bsize, plane); const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane); const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
...@@ -4297,8 +4298,7 @@ static void tx_block_yrd(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row, ...@@ -4297,8 +4298,7 @@ static void tx_block_yrd(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
const TX_SIZE plane_tx_size = const TX_SIZE plane_tx_size =
plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y) plane ? av1_get_uv_tx_size(mbmi, pd->subsampling_x, pd->subsampling_y)
: mbmi->inter_tx_size[av1_get_txb_size_index(plane_bsize, blk_row, : mbmi->inter_tx_size[tx_row][tx_col];
blk_col)];
int ctx = txfm_partition_context(tx_above + blk_col, tx_left + blk_row, int ctx = txfm_partition_context(tx_above + blk_col, tx_left + blk_row,
mbmi->sb_type, tx_size); mbmi->sb_type, tx_size);
...@@ -4485,8 +4485,9 @@ static void save_tx_rd_info(int n4, uint32_t hash, const MACROBLOCK *const x, ...@@ -4485,8 +4485,9 @@ static void save_tx_rd_info(int n4, uint32_t hash, const MACROBLOCK *const x,
tx_rd_info->min_tx_size = mbmi->min_tx_size; tx_rd_info->min_tx_size = mbmi->min_tx_size;
memcpy(tx_rd_info->blk_skip, x->blk_skip[0], memcpy(tx_rd_info->blk_skip, x->blk_skip[0],
sizeof(tx_rd_info->blk_skip[0]) * n4); sizeof(tx_rd_info->blk_skip[0]) * n4);
av1_copy(tx_rd_info->inter_tx_size, mbmi->inter_tx_size); for (int idy = 0; idy < xd->n8_h; ++idy)
for (int idx = 0; idx < xd->n8_w; ++idx)
tx_rd_info->inter_tx_size[idy][idx] = mbmi->inter_tx_size[idy][idx];
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
av1_copy(tx_rd_info->txk_type, mbmi->txk_type); av1_copy(tx_rd_info->txk_type, mbmi->txk_type);
#endif // CONFIG_TXK_SEL #endif // CONFIG_TXK_SEL
...@@ -4502,8 +4503,9 @@ static void fetch_tx_rd_info(int n4, const TX_RD_INFO *const tx_rd_info, ...@@ -4502,8 +4503,9 @@ static void fetch_tx_rd_info(int n4, const TX_RD_INFO *const tx_rd_info,
mbmi->min_tx_size = tx_rd_info->min_tx_size; mbmi->min_tx_size = tx_rd_info->min_tx_size;
memcpy(x->blk_skip[0], tx_rd_info->blk_skip, memcpy(x->blk_skip[0], tx_rd_info->blk_skip,
sizeof(tx_rd_info->blk_skip[0]) * n4); sizeof(tx_rd_info->blk_skip[0]) * n4);
av1_copy(mbmi->inter_tx_size, tx_rd_info->inter_tx_size); for (int idy = 0; idy < xd->n8_h; ++idy)
for (int idx = 0; idx < xd->n8_w; ++idx)
mbmi->inter_tx_size[idy][idx] = tx_rd_info->inter_tx_size[idy][idx];
#if CONFIG_TXK_SEL #if CONFIG_TXK_SEL
av1_copy(mbmi->txk_type, tx_rd_info->txk_type); av1_copy(mbmi->txk_type, tx_rd_info->txk_type);
#endif // CONFIG_TXK_SEL #endif // CONFIG_TXK_SEL
...@@ -4761,7 +4763,9 @@ static void set_skip_flag(const AV1_COMP *cpi, MACROBLOCK *x, ...@@ -4761,7 +4763,9 @@ static void set_skip_flag(const AV1_COMP *cpi, MACROBLOCK *x,
sizeof(mbmi->txk_type[0]) * sizeof(mbmi->txk_type[0]) *
(MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN))); (MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)));
#endif #endif
memset(mbmi->inter_tx_size, tx_size, sizeof(mbmi->inter_tx_size)); for (int idy = 0; idy < xd->n8_h; ++idy)
for (int idx = 0; idx < xd->n8_w; ++idx)
mbmi->inter_tx_size[idy][idx] = tx_size;
mbmi->tx_size = tx_size; mbmi->tx_size = tx_size;
mbmi->min_tx_size = tx_size; mbmi->min_tx_size = tx_size;
memset(x->blk_skip[0], 1, sizeof(uint8_t) * n4); memset(x->blk_skip[0], 1, sizeof(uint8_t) * n4);
...@@ -4818,7 +4822,7 @@ static void select_tx_type_yrd(const AV1_COMP *cpi, MACROBLOCK *x, ...@@ -4818,7 +4822,7 @@ static void select_tx_type_yrd(const AV1_COMP *cpi, MACROBLOCK *x,
int64_t best_rd = INT64_MAX; int64_t best_rd = INT64_MAX;
TX_TYPE tx_type, best_tx_type = DCT_DCT; TX_TYPE tx_type, best_tx_type = DCT_DCT;
const int is_inter = is_inter_block(mbmi); const int is_inter = is_inter_block(mbmi);
TX_SIZE best_tx_size[INTER_TX_SIZE_BUF_LEN] = { 0 }; TX_SIZE best_tx_size[MAX_MIB_SIZE][MAX_MIB_SIZE] = { { 0 } };
TX_SIZE best_tx = max_txsize_rect_lookup[1][bsize]; TX_SIZE best_tx = max_txsize_rect_lookup[1][bsize];
TX_SIZE best_min_tx_size = TX_SIZES_ALL; TX_SIZE best_min_tx_size = TX_SIZES_ALL;
uint8_t best_blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE * 8]; uint8_t best_blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE * 8];
...@@ -4829,6 +4833,7 @@ static void select_tx_type_yrd(const AV1_COMP *cpi, MACROBLOCK *x, ...@@ -4829,6 +4833,7 @@ static void select_tx_type_yrd(const AV1_COMP *cpi, MACROBLOCK *x,
TX_TYPE txk_end = TX_TYPES; TX_TYPE txk_end = TX_TYPES;
#endif #endif
const int n4 = bsize_to_num_blk(bsize); const int n4 = bsize_to_num_blk(bsize);
int idx, idy;
// Get the tx_size 1 level down // Get the tx_size 1 level down
const TX_SIZE min_tx_size = const TX_SIZE min_tx_size =
sub_tx_size_map[1][max_txsize_rect_lookup[1][bsize]]; sub_tx_size_map[1][max_txsize_rect_lookup[1][bsize]];
...@@ -4938,7 +4943,9 @@ static void select_tx_type_yrd(const AV1_COMP *cpi, MACROBLOCK *x, ...@@ -4938,7 +4943,9 @@ static void select_tx_type_yrd(const AV1_COMP *cpi, MACROBLOCK *x,
best_min_tx_size = mbmi->min_tx_size; best_min_tx_size = mbmi->min_tx_size;
memcpy(best_blk_skip, x->blk_skip[0], sizeof(best_blk_skip[0]) * n4); memcpy(best_blk_skip, x->blk_skip[0], sizeof(best_blk_skip[0]) * n4);
found = 1; found = 1;
av1_copy(best_tx_size, mbmi->inter_tx_size); for (idy = 0; idy < xd->n8_h; ++idy)
for (idx = 0; idx < xd->n8_w; ++idx)
best_tx_size[idy][idx] = mbmi->inter_tx_size[idy][idx];
} }
#if !CONFIG_TXK_SEL #if !CONFIG_TXK_SEL
...@@ -4961,7 +4968,9 @@ static void select_tx_type_yrd(const AV1_COMP *cpi, MACROBLOCK *x, ...@@ -4961,7 +4968,9 @@ static void select_tx_type_yrd(const AV1_COMP *cpi, MACROBLOCK *x,
// We found a candidate transform to use. Copy our results from the "best" // We found a candidate transform to use. Copy our results from the "best"
// array into mbmi. // array into mbmi.
mbmi->tx_type = best_tx_type; mbmi->tx_type = best_tx_type;
av1_copy(mbmi->inter_tx_size, best_tx_size); for (idy = 0; idy < xd->n8_h; ++idy)
for (idx = 0; idx < xd->n8_w; ++idx)
mbmi->inter_tx_size[idy][idx] = best_tx_size[idy][idx];
mbmi->tx_size = best_tx; mbmi->tx_size = best_tx;
mbmi->min_tx_size = best_min_tx_size; mbmi->min_tx_size = best_min_tx_size;
memcpy(x->blk_skip[0], best_blk_skip, sizeof(best_blk_skip[0]) * n4); memcpy(x->blk_skip[0], best_blk_skip, sizeof(best_blk_skip[0]) * n4);
...@@ -4978,6 +4987,8 @@ static void tx_block_rd(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row, ...@@ -4978,6 +4987,8 @@ static void tx_block_rd(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;