diff --git a/vp9/common/vp9_common_data.c b/vp9/common/vp9_common_data.c index dc41efde2..f858900a4 100644 --- a/vp9/common/vp9_common_data.c +++ b/vp9/common/vp9_common_data.c @@ -115,6 +115,16 @@ const TX_SIZE max_uv_txsize_lookup[BLOCK_SIZES] = { TX_16X16, TX_16X16, TX_16X16, TX_32X32 }; +const TX_SIZE tx_mode_to_biggest_tx_size[TX_MODES] = { + TX_4X4, // ONLY_4X4 + TX_8X8, // ALLOW_8X8 + TX_16X16, // ALLOW_16X16 + TX_32X32, // ALLOW_32X32 + TX_32X32, // TX_MODE_SELECT +}; + + + const BLOCK_SIZE ss_size_lookup[BLOCK_SIZES][2][2] = { // ss_x == 0 ss_x == 0 ss_x == 1 ss_x == 1 // ss_y == 0 ss_y == 1 ss_y == 0 ss_y == 1 @@ -133,3 +143,4 @@ const BLOCK_SIZE ss_size_lookup[BLOCK_SIZES][2][2] = { {{BLOCK_64X64, BLOCK_64X32}, {BLOCK_32X64, BLOCK_32X32}}, }; + diff --git a/vp9/common/vp9_common_data.h b/vp9/common/vp9_common_data.h index 2945cd203..c1f640536 100644 --- a/vp9/common/vp9_common_data.h +++ b/vp9/common/vp9_common_data.h @@ -27,6 +27,7 @@ extern const PARTITION_TYPE partition_lookup[][BLOCK_SIZES]; extern const BLOCK_SIZE subsize_lookup[PARTITION_TYPES][BLOCK_SIZES]; extern const TX_SIZE max_txsize_lookup[BLOCK_SIZES]; extern const TX_SIZE max_uv_txsize_lookup[BLOCK_SIZES]; +extern const TX_SIZE tx_mode_to_biggest_tx_size[TX_MODES]; extern const BLOCK_SIZE ss_size_lookup[BLOCK_SIZES][2][2]; #endif // VP9_COMMON_VP9_COMMON_DATA_H diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c index 6cf4f153b..5bfe7b793 100644 --- a/vp9/decoder/vp9_decodemv.c +++ b/vp9/decoder/vp9_decodemv.c @@ -78,17 +78,13 @@ static TX_SIZE read_tx_size(VP9D_COMP *pbi, TX_MODE tx_mode, vp9_reader *r) { VP9_COMMON *const cm = &pbi->common; MACROBLOCKD *const xd = &pbi->mb; - - if (allow_select && tx_mode == TX_MODE_SELECT && bsize >= BLOCK_8X8) + if (allow_select && tx_mode == TX_MODE_SELECT && bsize >= BLOCK_8X8) { return read_selected_tx_size(cm, xd, bsize, r); - else if (tx_mode >= ALLOW_32X32 && bsize >= BLOCK_32X32) - return TX_32X32; - else if (tx_mode >= ALLOW_16X16 && bsize >= BLOCK_16X16) - return TX_16X16; - else if (tx_mode >= ALLOW_8X8 && bsize >= BLOCK_8X8) - return TX_8X8; - else - return TX_4X4; + } else { + const TX_SIZE max_tx_size_block = max_txsize_lookup[bsize]; + const TX_SIZE max_tx_size_txmode = tx_mode_to_biggest_tx_size[tx_mode]; + return MIN(max_tx_size_block, max_tx_size_txmode); + } } static void set_segment_id(VP9_COMMON *cm, BLOCK_SIZE bsize, diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 20e4d71c8..081f33103 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -30,7 +30,6 @@ #include "vp9/common/vp9_reconinter.h" #include "vp9/common/vp9_seg_common.h" #include "vp9/common/vp9_tile_common.h" - #include "vp9/encoder/vp9_encodeframe.h" #include "vp9/encoder/vp9_encodeintra.h" #include "vp9/encoder/vp9_encodemb.h" @@ -46,14 +45,6 @@ #define DBG_PRNT_SEGMAP 0 -static const TX_SIZE tx_mode_to_biggest_tx_size[TX_MODES] = { - TX_4X4, // ONLY_4X4 - TX_8X8, // ONLY_8X8 - TX_16X16, // ONLY_16X16 - TX_32X32, // ONLY_32X32 - TX_32X32, // TX_MODE_SELECT -}; - // #define ENC_DEBUG #ifdef ENC_DEBUG int enc_debug = 0; diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index f19296803..3eb14c879 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -715,22 +715,12 @@ static void choose_largest_txfm_size(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) { const TX_SIZE max_tx_size = max_txsize_lookup[bs]; VP9_COMMON *const cm = &cpi->common; + const TX_SIZE largest_tx_size = tx_mode_to_biggest_tx_size[cm->tx_mode]; MACROBLOCKD *const xd = &x->e_mbd; MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi; - if (max_tx_size == TX_32X32 && - (cm->tx_mode == ALLOW_32X32 || - cm->tx_mode == TX_MODE_SELECT)) { - mbmi->tx_size = TX_32X32; - } else if (max_tx_size >= TX_16X16 && - (cm->tx_mode == ALLOW_16X16 || - cm->tx_mode == ALLOW_32X32 || - cm->tx_mode == TX_MODE_SELECT)) { - mbmi->tx_size = TX_16X16; - } else if (cm->tx_mode != ONLY_4X4) { - mbmi->tx_size = TX_8X8; - } else { - mbmi->tx_size = TX_4X4; - } + + mbmi->tx_size = MIN(max_tx_size, largest_tx_size); + txfm_rd_in_plane(x, &cpi->rdcost_stack, rate, distortion, skip, &sse[mbmi->tx_size], ref_best_rd, 0, bs, mbmi->tx_size);