Add max_tx_size to MB_MODE_INFO
Refactor the recursive transform block partition to reduce repeated computation maximum transform block size per block. Change-Id: Ib408c78dc6923fe7d337dc937e74f2701ac63859
This commit is contained in:
parent
2aa2ef4094
commit
0a42a1efd4
@ -116,6 +116,7 @@ typedef struct {
|
||||
PREDICTION_MODE mode;
|
||||
TX_SIZE tx_size;
|
||||
TX_SIZE inter_tx_size[64]; // Assume maximum of 64x64 block size.
|
||||
TX_SIZE max_tx_size; // Maximum tx size allowed in current block.
|
||||
int8_t skip;
|
||||
int8_t segment_id;
|
||||
int8_t seg_id_predicted; // valid only when temporal_update is enabled
|
||||
@ -129,7 +130,6 @@ typedef struct {
|
||||
int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES];
|
||||
uint8_t mode_context[MAX_REF_FRAMES];
|
||||
INTERP_FILTER interp_filter;
|
||||
|
||||
} MB_MODE_INFO;
|
||||
|
||||
typedef struct MODE_INFO {
|
||||
|
@ -423,6 +423,7 @@ static MB_MODE_INFO *set_offsets(VP9_COMMON *const cm, MACROBLOCKD *const xd,
|
||||
xd->mi = cm->mi + offset;
|
||||
xd->mi[0].src_mi = &xd->mi[0]; // Point to self.
|
||||
xd->mi[0].mbmi.sb_type = bsize;
|
||||
xd->mi[0].mbmi.max_tx_size = max_txsize_lookup[bsize];
|
||||
|
||||
for (y = 0; y < y_mis; ++y)
|
||||
for (x = !y; x < x_mis; ++x) {
|
||||
|
@ -636,14 +636,14 @@ static void read_inter_frame_mode_info(VP9Decoder *const pbi,
|
||||
|
||||
if (mbmi->sb_type >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT &&
|
||||
!mbmi->skip && inter_block) {
|
||||
BLOCK_SIZE txb_size = txsize_to_bsize[max_txsize_lookup[bsize]];
|
||||
BLOCK_SIZE txb_size = txsize_to_bsize[mbmi->max_tx_size];
|
||||
int bh = num_4x4_blocks_wide_lookup[txb_size];
|
||||
int width = num_4x4_blocks_wide_lookup[bsize];
|
||||
int height = num_4x4_blocks_high_lookup[bsize];
|
||||
int idx, idy;
|
||||
for (idy = 0; idy < height; idy += bh)
|
||||
for (idx = 0; idx < width; idx += bh)
|
||||
read_tx_size_inter(cm, xd, counts, max_txsize_lookup[mbmi->sb_type],
|
||||
read_tx_size_inter(cm, xd, counts, mbmi->max_tx_size,
|
||||
idy, idx, r);
|
||||
} else {
|
||||
int i;
|
||||
@ -659,8 +659,7 @@ static void read_inter_frame_mode_info(VP9Decoder *const pbi,
|
||||
|
||||
if (inter_block) {
|
||||
if (bsize >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT && mbmi->skip) {
|
||||
TX_SIZE max_tx_size = max_txsize_lookup[bsize];
|
||||
BLOCK_SIZE txb_size = txsize_to_bsize[max_tx_size];
|
||||
BLOCK_SIZE txb_size = txsize_to_bsize[mbmi->max_tx_size];
|
||||
int bh = num_4x4_blocks_wide_lookup[txb_size];
|
||||
int width = num_4x4_blocks_wide_lookup[bsize];
|
||||
int height = num_4x4_blocks_high_lookup[bsize];
|
||||
@ -669,11 +668,10 @@ static void read_inter_frame_mode_info(VP9Decoder *const pbi,
|
||||
for (idx = 0; idx < width; idx += bh)
|
||||
txfm_partition_update(xd->above_txfm_context + (idx / 2),
|
||||
xd->left_txfm_context + (idy / 2),
|
||||
max_tx_size);
|
||||
mbmi->max_tx_size);
|
||||
}
|
||||
} else {
|
||||
TX_SIZE max_tx_size = max_txsize_lookup[bsize];
|
||||
BLOCK_SIZE txb_size = txsize_to_bsize[max_tx_size];
|
||||
BLOCK_SIZE txb_size = txsize_to_bsize[mbmi->max_tx_size];
|
||||
int bh = num_4x4_blocks_wide_lookup[txb_size];
|
||||
int width = num_4x4_blocks_wide_lookup[bsize];
|
||||
int height = num_4x4_blocks_high_lookup[bsize];
|
||||
|
@ -325,14 +325,14 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
|
||||
if (!is_inter) {
|
||||
write_selected_tx_size(cm, xd, w);
|
||||
} else {
|
||||
BLOCK_SIZE txb_size = txsize_to_bsize[max_txsize_lookup[bsize]];
|
||||
BLOCK_SIZE txb_size = txsize_to_bsize[mbmi->max_tx_size];
|
||||
int bh = num_4x4_blocks_wide_lookup[txb_size];
|
||||
int width = num_4x4_blocks_wide_lookup[bsize];
|
||||
int height = num_4x4_blocks_high_lookup[bsize];
|
||||
int idx, idy;
|
||||
for (idy = 0; idy < height; idy += bh)
|
||||
for (idx = 0; idx < width; idx += bh)
|
||||
write_tx_size_inter(cm, xd, max_txsize_lookup[bsize], idy, idx, w);
|
||||
write_tx_size_inter(cm, xd, mbmi->max_tx_size, idy, idx, w);
|
||||
}
|
||||
}
|
||||
|
||||
@ -342,8 +342,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
|
||||
|
||||
if (is_inter) {
|
||||
if (bsize >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT && skip) {
|
||||
TX_SIZE max_tx_size = max_txsize_lookup[bsize];
|
||||
BLOCK_SIZE txb_size = txsize_to_bsize[max_tx_size];
|
||||
BLOCK_SIZE txb_size = txsize_to_bsize[mbmi->max_tx_size];
|
||||
int bh = num_4x4_blocks_wide_lookup[txb_size];
|
||||
int width = num_4x4_blocks_wide_lookup[bsize];
|
||||
int height = num_4x4_blocks_high_lookup[bsize];
|
||||
@ -352,11 +351,10 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, const MODE_INFO *mi,
|
||||
for (idx = 0; idx < width; idx += bh)
|
||||
txfm_partition_update(xd->above_txfm_context + (idx / 2),
|
||||
xd->left_txfm_context + (idy / 2),
|
||||
max_tx_size);
|
||||
mbmi->max_tx_size);
|
||||
}
|
||||
} else {
|
||||
TX_SIZE max_tx_size = max_txsize_lookup[bsize];
|
||||
BLOCK_SIZE txb_size = txsize_to_bsize[max_tx_size];
|
||||
BLOCK_SIZE txb_size = txsize_to_bsize[mbmi->max_tx_size];
|
||||
int bh = num_4x4_blocks_wide_lookup[txb_size];
|
||||
int width = num_4x4_blocks_wide_lookup[bsize];
|
||||
int height = num_4x4_blocks_high_lookup[bsize];
|
||||
|
@ -987,6 +987,7 @@ static void set_mode_info_seg_skip(MACROBLOCK *x, TX_MODE tx_mode,
|
||||
mbmi->mode = ZEROMV;
|
||||
mbmi->tx_size = MIN(max_txsize_lookup[bsize],
|
||||
tx_mode_to_biggest_tx_size[tx_mode]);
|
||||
mbmi->max_tx_size = max_txsize_lookup[bsize];
|
||||
mbmi->skip = 1;
|
||||
mbmi->uv_mode = DC_PRED;
|
||||
mbmi->ref_frame[0] = LAST_FRAME;
|
||||
@ -1035,6 +1036,7 @@ static void rd_pick_sb_modes(VP9_COMP *cpi,
|
||||
set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize);
|
||||
mbmi = &xd->mi[0].src_mi->mbmi;
|
||||
mbmi->sb_type = bsize;
|
||||
mbmi->max_tx_size = max_txsize_lookup[bsize];
|
||||
|
||||
for (i = 0; i < MAX_MB_PLANE; ++i) {
|
||||
p[i].coeff = ctx->coeff_pbuf[i][0];
|
||||
@ -1414,6 +1416,7 @@ static void set_fixed_partitioning(VP9_COMP *cpi, const TileInfo *const tile,
|
||||
int index = block_row * mis + block_col;
|
||||
mi_8x8[index].src_mi = mi_upper_left + index;
|
||||
mi_8x8[index].src_mi->mbmi.sb_type = bsize;
|
||||
mi_8x8[index].src_mi->mbmi.max_tx_size = max_txsize_lookup[bsize];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -1479,6 +1482,7 @@ static void set_source_var_based_partition(VP9_COMP *cpi,
|
||||
index = b_mi_row * mis + b_mi_col;
|
||||
mi_8x8[index].src_mi = mi_upper_left + index;
|
||||
mi_8x8[index].src_mi->mbmi.sb_type = BLOCK_16X16;
|
||||
mi_8x8[index].src_mi->mbmi.max_tx_size = max_txsize_lookup[BLOCK_16X16];
|
||||
|
||||
// TODO(yunqingwang): If d16[j].var is very large, use 8x8 partition
|
||||
// size to further improve quality.
|
||||
@ -1501,6 +1505,7 @@ static void set_source_var_based_partition(VP9_COMP *cpi,
|
||||
index = coord_lookup[i*4].row * mis + coord_lookup[i*4].col;
|
||||
mi_8x8[index].src_mi = mi_upper_left + index;
|
||||
mi_8x8[index].src_mi->mbmi.sb_type = BLOCK_32X32;
|
||||
mi_8x8[index].src_mi->mbmi.max_tx_size = max_txsize_lookup[BLOCK_32X32];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1513,6 +1518,7 @@ static void set_source_var_based_partition(VP9_COMP *cpi,
|
||||
if (is_larger_better) {
|
||||
mi_8x8[0].src_mi = mi_upper_left;
|
||||
mi_8x8[0].src_mi->mbmi.sb_type = BLOCK_64X64;
|
||||
mi_8x8[0].src_mi->mbmi.max_tx_size = max_txsize_lookup[BLOCK_64X64];
|
||||
}
|
||||
}
|
||||
} else { // partial in-image SB64
|
||||
@ -2896,6 +2902,7 @@ static void nonrd_pick_sb_modes(VP9_COMP *cpi,
|
||||
set_offsets(cpi, tile_info, x, mi_row, mi_col, bsize);
|
||||
mbmi = &xd->mi[0].src_mi->mbmi;
|
||||
mbmi->sb_type = bsize;
|
||||
mbmi->max_tx_size = max_txsize_lookup[bsize];
|
||||
|
||||
if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled)
|
||||
if (cyclic_refresh_segment_id_boosted(mbmi->segment_id))
|
||||
|
@ -1454,14 +1454,14 @@ static void inter_block_yrd(const VP9_COMP *cpi, MACROBLOCK *x,
|
||||
|
||||
if (is_cost_valid) {
|
||||
const struct macroblockd_plane *const pd = &xd->plane[0];
|
||||
const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd);
|
||||
const int mi_width = num_4x4_blocks_wide_lookup[plane_bsize];
|
||||
const int mi_height = num_4x4_blocks_high_lookup[plane_bsize];
|
||||
BLOCK_SIZE txb_size = txsize_to_bsize[max_txsize_lookup[plane_bsize]];
|
||||
const int mi_width = num_4x4_blocks_wide_lookup[bsize];
|
||||
const int mi_height = num_4x4_blocks_high_lookup[bsize];
|
||||
TX_SIZE max_tx_size = xd->mi[0].mbmi.max_tx_size;
|
||||
BLOCK_SIZE txb_size = txsize_to_bsize[max_tx_size];
|
||||
int bh = num_4x4_blocks_wide_lookup[txb_size];
|
||||
int idx, idy;
|
||||
int block = 0;
|
||||
int step = 1 << (max_txsize_lookup[plane_bsize] * 2);
|
||||
int step = 1 << (max_tx_size * 2);
|
||||
ENTROPY_CONTEXT ctxa[16], ctxl[16];
|
||||
TXFM_CONTEXT txa[8], txl[8];
|
||||
|
||||
@ -1471,14 +1471,14 @@ static void inter_block_yrd(const VP9_COMP *cpi, MACROBLOCK *x,
|
||||
vp9_get_entropy_contexts(bsize, TX_4X4, pd, ctxa, ctxl);
|
||||
|
||||
vpx_memcpy(txa, xd->above_txfm_context,
|
||||
sizeof(TXFM_CONTEXT) * num_8x8_blocks_wide_lookup[plane_bsize]);
|
||||
sizeof(TXFM_CONTEXT) * num_8x8_blocks_wide_lookup[bsize]);
|
||||
vpx_memcpy(txl, xd->left_txfm_context,
|
||||
sizeof(TXFM_CONTEXT) * num_8x8_blocks_high_lookup[plane_bsize]);
|
||||
sizeof(TXFM_CONTEXT) * num_8x8_blocks_high_lookup[bsize]);
|
||||
|
||||
for (idy = 0; idy < mi_height; idy += bh) {
|
||||
for (idx = 0; idx < mi_width; idx += bh) {
|
||||
select_tx_block(cpi, x, idy, idx, 0, block,
|
||||
max_txsize_lookup[plane_bsize], plane_bsize, txb_size,
|
||||
max_tx_size, bsize, txb_size,
|
||||
ctxa, ctxl, txa, txl,
|
||||
&pnrate, &pndist, &pnsse, &pnskip);
|
||||
*rate += pnrate;
|
||||
|
Loading…
x
Reference in New Issue
Block a user