Commit 0c7b8d84 authored by Angie Chiang's avatar Angie Chiang Committed by Sebastien Alaiwan

Simplify txfm table

Instead of listing all possible stage_range,
we use set_fwd_txfm_non_scale_range() to generate 2d stage_range
from 1d stage_range.

This will reduce the complexity of txfm table significantly.

This is a lossless change.
The coding performance isn't changed.
The txfm config is exactly the same as it was before.

Change-Id: Ibd1d9e53772bb928faaeecc98d81cbc8f38b27ed
parent 0822557b
This diff is collapsed.
This diff is collapsed.
......@@ -28,3 +28,29 @@ void av1_round_shift_array_c(int32_t *arr, int size, int bit) {
}
}
}
const TXFM_TYPE av1_txfm_type_ls[5][TX_TYPES_1D] = {
{ TXFM_TYPE_DCT4, TXFM_TYPE_ADST4, TXFM_TYPE_ADST4, TXFM_TYPE_IDENTITY4 },
{ TXFM_TYPE_DCT8, TXFM_TYPE_ADST8, TXFM_TYPE_ADST8, TXFM_TYPE_IDENTITY8 },
{ TXFM_TYPE_DCT16, TXFM_TYPE_ADST16, TXFM_TYPE_ADST16, TXFM_TYPE_IDENTITY16 },
{ TXFM_TYPE_DCT32, TXFM_TYPE_ADST32, TXFM_TYPE_ADST32, TXFM_TYPE_IDENTITY32 },
{ TXFM_TYPE_DCT64, TXFM_TYPE_INVALID, TXFM_TYPE_INVALID,
TXFM_TYPE_IDENTITY64 }
};
const int8_t av1_txfm_stage_num_list[TXFM_TYPES] = {
4, // TXFM_TYPE_DCT4
6, // TXFM_TYPE_DCT8
8, // TXFM_TYPE_DCT16
10, // TXFM_TYPE_DCT32
12, // TXFM_TYPE_DCT64
6, // TXFM_TYPE_ADST4
8, // TXFM_TYPE_ADST8
10, // TXFM_TYPE_ADST16
12, // TXFM_TYPE_ADST32
1, // TXFM_TYPE_IDENTITY4
1, // TXFM_TYPE_IDENTITY8
1, // TXFM_TYPE_IDENTITY16
1, // TXFM_TYPE_IDENTITY32
1, // TXFM_TYPE_IDENTITY64
};
......@@ -122,24 +122,23 @@ typedef enum TXFM_TYPE {
TXFM_TYPE_IDENTITY16,
TXFM_TYPE_IDENTITY32,
TXFM_TYPE_IDENTITY64,
TXFM_TYPES,
TXFM_TYPE_INVALID,
} TXFM_TYPE;
typedef struct TXFM_1D_CFG {
const int txfm_size;
const int stage_num;
const int8_t *stage_range;
const TXFM_TYPE txfm_type;
} TXFM_1D_CFG;
typedef struct TXFM_2D_FLIP_CFG {
TX_SIZE tx_size;
int ud_flip; // flip upside down
int lr_flip; // flip left to right
const int8_t *shift;
int8_t cos_bit_col;
int8_t cos_bit_row;
const TXFM_1D_CFG *col_cfg;
const TXFM_1D_CFG *row_cfg;
int8_t stage_range_col[MAX_TXFM_STAGE_NUM];
int8_t stage_range_row[MAX_TXFM_STAGE_NUM];
TXFM_TYPE txfm_type_col;
TXFM_TYPE txfm_type_row;
int stage_num_col;
int stage_num_row;
} TXFM_2D_FLIP_CFG;
static INLINE void set_flip_cfg(TX_TYPE tx_type, TXFM_2D_FLIP_CFG *cfg) {
......@@ -260,6 +259,8 @@ void av1_get_fwd_txfm_cfg(TX_TYPE tx_type, TX_SIZE tx_size,
TXFM_2D_FLIP_CFG *cfg);
void av1_get_inv_txfm_cfg(TX_TYPE tx_type, TX_SIZE tx_size,
TXFM_2D_FLIP_CFG *cfg);
extern const TXFM_TYPE av1_txfm_type_ls[5][TX_TYPES_1D];
extern const int8_t av1_txfm_stage_num_list[TXFM_TYPES];
#ifdef __cplusplus
}
#endif // __cplusplus
......
......@@ -86,6 +86,10 @@ static void ihalfright32_c(const tran_low_t *input, tran_low_t *output) {
}
#if CONFIG_TX64X64 && (!CONFIG_DAALA_TX32 || !CONFIG_DAALA_TX64)
static const int8_t inv_stage_range_col_dct_64[12] = { 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0 };
static const int8_t inv_stage_range_row_dct_64[12] = { 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0 };
static void idct64_col_c(const tran_low_t *input, tran_low_t *output) {
int32_t in[64], out[64];
const int txw_idx = tx_size_wide_log2[TX_64X64] - tx_size_wide_log2[0];
......
This diff is collapsed.
This diff is collapsed.
......@@ -2281,7 +2281,11 @@ static void fhalfright64(const tran_low_t *input, tran_low_t *output) {
fdct32(inputhalf, output);
// Note overall scaling factor is 2 times unitary
}
// stage range
static const int8_t fwd_stage_range_col_dct_64[12] = { 0, 1, 2, 3, 4, 5,
6, 6, 6, 6, 6, 6 };
static const int8_t fwd_stage_range_row_dct_64[12] = { 6, 7, 8, 9, 10, 11,
11, 11, 11, 11, 11, 11 };
static void fdct64_col(const tran_low_t *input, tran_low_t *output) {
int32_t in[64], out[64];
int i;
......
......@@ -45,17 +45,15 @@ static INLINE void fwd_txfm2d_sse4_1(const int16_t *input, int32_t *output,
// Rectangular transforms use c code only, so it should be ok for now.
// It will be corrected when there are sse implementations for rectangular
// transforms.
assert(cfg->row_cfg->txfm_size == cfg->col_cfg->txfm_size);
const int txfm_size = cfg->row_cfg->txfm_size;
assert(cfg->tx_size < TX_SIZES);
const int txfm_size = tx_size_wide[cfg->tx_size];
const int8_t *shift = cfg->shift;
const int8_t *stage_range_col = cfg->col_cfg->stage_range;
const int8_t *stage_range_row = cfg->row_cfg->stage_range;
const int8_t *stage_range_col = cfg->stage_range_col;
const int8_t *stage_range_row = cfg->stage_range_row;
const int8_t cos_bit_col = cfg->cos_bit_col;
const int8_t cos_bit_row = cfg->cos_bit_row;
const TxfmFuncSSE2 txfm_func_col =
fwd_txfm_type_to_func(cfg->col_cfg->txfm_type);
const TxfmFuncSSE2 txfm_func_row =
fwd_txfm_type_to_func(cfg->row_cfg->txfm_type);
const TxfmFuncSSE2 txfm_func_col = fwd_txfm_type_to_func(cfg->txfm_type_col);
const TxfmFuncSSE2 txfm_func_row = fwd_txfm_type_to_func(cfg->txfm_type_row);
__m128i *buf_128 = (__m128i *)txfm_buf;
__m128i *out_128 = (__m128i *)output;
......
......@@ -44,8 +44,8 @@ class AV1FwdTxfm2d : public ::testing::TestWithParam<AV1FwdTxfm2dParam> {
TXFM_2D_FLIP_CFG fwd_txfm_flip_cfg;
av1_get_fwd_txfm_cfg(tx_type_, tx_size_, &fwd_txfm_flip_cfg);
amplify_factor_ = libaom_test::get_amplification_factor(tx_type_, tx_size_);
tx_width_ = fwd_txfm_flip_cfg.row_cfg->txfm_size;
tx_height_ = fwd_txfm_flip_cfg.col_cfg->txfm_size;
tx_width_ = tx_size_wide[fwd_txfm_flip_cfg.tx_size];
tx_height_ = tx_size_high[fwd_txfm_flip_cfg.tx_size];
ud_flip_ = fwd_txfm_flip_cfg.ud_flip;
lr_flip_ = fwd_txfm_flip_cfg.lr_flip;
......@@ -196,12 +196,10 @@ TEST(AV1FwdTxfm2d, CfgTest) {
int8_t stage_range_col[MAX_TXFM_STAGE_NUM];
int8_t stage_range_row[MAX_TXFM_STAGE_NUM];
av1_gen_fwd_stage_range(stage_range_col, stage_range_row, &cfg, bd);
const TXFM_1D_CFG *col_cfg = cfg.col_cfg;
const TXFM_1D_CFG *row_cfg = cfg.row_cfg;
libaom_test::txfm_stage_range_check(stage_range_col, col_cfg->stage_num,
libaom_test::txfm_stage_range_check(stage_range_col, cfg.stage_num_col,
cfg.cos_bit_col, low_range,
high_range);
libaom_test::txfm_stage_range_check(stage_range_row, row_cfg->stage_num,
libaom_test::txfm_stage_range_check(stage_range_row, cfg.stage_num_row,
cfg.cos_bit_row, low_range,
high_range);
}
......
......@@ -203,12 +203,10 @@ TEST(AV1InvTxfm2d, CfgTest) {
int8_t stage_range_row[MAX_TXFM_STAGE_NUM];
av1_gen_inv_stage_range(stage_range_col, stage_range_row, &cfg,
(TX_SIZE)tx_size, bd);
const TXFM_1D_CFG *col_cfg = cfg.col_cfg;
const TXFM_1D_CFG *row_cfg = cfg.row_cfg;
libaom_test::txfm_stage_range_check(stage_range_col, col_cfg->stage_num,
libaom_test::txfm_stage_range_check(stage_range_col, cfg.stage_num_col,
cfg.cos_bit_col, low_range,
high_range);
libaom_test::txfm_stage_range_check(stage_range_row, row_cfg->stage_num,
libaom_test::txfm_stage_range_check(stage_range_row, cfg.stage_num_row,
cfg.cos_bit_row, low_range,
high_range);
}
......
......@@ -212,8 +212,8 @@ void reference_hybrid_1d(double *in, double *out, int size, int type) {
double get_amplification_factor(TX_TYPE tx_type, TX_SIZE tx_size) {
TXFM_2D_FLIP_CFG fwd_txfm_flip_cfg;
av1_get_fwd_txfm_cfg(tx_type, tx_size, &fwd_txfm_flip_cfg);
const int tx_width = fwd_txfm_flip_cfg.row_cfg->txfm_size;
const int tx_height = fwd_txfm_flip_cfg.col_cfg->txfm_size;
const int tx_width = tx_size_wide[fwd_txfm_flip_cfg.tx_size];
const int tx_height = tx_size_high[fwd_txfm_flip_cfg.tx_size];
const int8_t *shift = fwd_txfm_flip_cfg.shift;
const int amplify_bit = shift[0] + shift[1] + shift[2];
double amplify_factor =
......
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