Commit 4a75b5a0 authored by Angie Chiang's avatar Angie Chiang Committed by Sebastien Alaiwan

Move shift from 1d_cfg to 2d_cfg

Change-Id: I22d0fac0d8e94fc02a7adf13b144ed17097ff84b
parent a4c80485
This diff is collapsed.
......@@ -245,6 +245,48 @@ static const TXFM_1D_CFG *inv_txfm_row_cfg_ls[TX_TYPES_1D][TX_SIZES_ALL] = {
},
};
static const int8_t inv_shift_4x4[2] = { 0, -4 };
static const int8_t inv_shift_8x8[2] = { 0, -5 };
static const int8_t inv_shift_16x16[2] = { -1, -5 };
static const int8_t inv_shift_32x32[2] = { -1, -5 };
#if CONFIG_TX64X64
static const int8_t inv_shift_64x64[2] = { -1, -5 };
#endif
static const int8_t inv_shift_4x8[2] = { 0, -5 };
static const int8_t inv_shift_8x4[2] = { 0, -5 };
static const int8_t inv_shift_8x16[2] = { -1, -5 };
static const int8_t inv_shift_16x8[2] = { -1, -5 };
static const int8_t inv_shift_16x32[2] = { -1, -5 };
static const int8_t inv_shift_32x16[2] = { -1, -5 };
#if CONFIG_TX64X64
static const int8_t inv_shift_32x64[2] = { -1, -5 };
static const int8_t inv_shift_64x32[2] = { -1, -5 };
#endif
static const int8_t inv_shift_4x16[2] = { -1, -5 };
static const int8_t inv_shift_16x4[2] = { -1, -5 };
static const int8_t inv_shift_8x32[2] = { -1, -5 };
static const int8_t inv_shift_32x8[2] = { -1, -5 };
#if CONFIG_TX64X64
static const int8_t inv_shift_16x64[2] = { -1, -5 };
static const int8_t inv_shift_64x16[2] = { -1, -5 };
#endif // CONFIG_TX64X64
const int8_t *inv_txfm_shift_ls[TX_SIZES_ALL] = {
inv_shift_4x4, inv_shift_8x8, inv_shift_16x16, inv_shift_32x32,
#if CONFIG_TX64X64
inv_shift_64x64,
#endif // CONFIG_TX64X64
inv_shift_4x8, inv_shift_8x4, inv_shift_8x16, inv_shift_16x8,
inv_shift_16x32, inv_shift_32x16,
#if CONFIG_TX64X64
inv_shift_32x64, inv_shift_64x32,
#endif // CONFIG_TX64X64
inv_shift_4x16, inv_shift_16x4, inv_shift_8x32, inv_shift_32x8,
#if CONFIG_TX64X64
inv_shift_16x64, inv_shift_64x16,
#endif // CONFIG_TX64X64
};
void av1_get_inv_txfm_cfg(TX_TYPE tx_type, TX_SIZE tx_size,
TXFM_2D_FLIP_CFG *cfg) {
assert(cfg != NULL);
......@@ -253,6 +295,7 @@ void av1_get_inv_txfm_cfg(TX_TYPE tx_type, TX_SIZE tx_size,
const TX_TYPE_1D tx_type_row = htx_tab[tx_type];
cfg->col_cfg = inv_txfm_col_cfg_ls[tx_type_col][tx_size];
cfg->row_cfg = inv_txfm_row_cfg_ls[tx_type_row][tx_size];
cfg->shift = inv_txfm_shift_ls[tx_size];
}
void av1_gen_inv_stage_range(int8_t *stage_range_col, int8_t *stage_range_row,
......@@ -271,8 +314,7 @@ void av1_gen_inv_stage_range(int8_t *stage_range_col, int8_t *stage_range_row,
if (txfm_size_col == txfm_size_row) assert(rect_type == 0);
int rect_type_shift = 0;
// Take the shift from the larger dimension in the rectangular case.
const int8_t *shift = (txfm_size_col > txfm_size_row) ? cfg->row_cfg->shift
: cfg->col_cfg->shift;
const int8_t *shift = cfg->shift;
int shift1 = shift[1];
if (rect_type == 1 || rect_type == -1) {
......@@ -312,8 +354,7 @@ static INLINE void inv_txfm2d_add_c(const int32_t *input, uint16_t *output,
const int txfm_size_col = cfg->row_cfg->txfm_size;
const int txfm_size_row = cfg->col_cfg->txfm_size;
// Take the shift from the larger dimension in the rectangular case.
const int8_t *shift = (txfm_size_col > txfm_size_row) ? cfg->row_cfg->shift
: cfg->col_cfg->shift;
const int8_t *shift = cfg->shift;
const int rect_type = get_rect_tx_log_ratio(txfm_size_col, txfm_size_row);
int rect_type2_shift = 0;
int rect_type1_shift = 0;
......
......@@ -115,7 +115,6 @@ typedef struct TXFM_1D_CFG {
const int txfm_size;
const int stage_num;
const int8_t *shift;
const int8_t *stage_range;
const int8_t *cos_bit;
const TXFM_TYPE txfm_type;
......@@ -124,6 +123,7 @@ typedef struct TXFM_1D_CFG {
typedef struct TXFM_2D_FLIP_CFG {
int ud_flip; // flip upside down
int lr_flip; // flip left to right
const int8_t *shift;
const TXFM_1D_CFG *col_cfg;
const TXFM_1D_CFG *row_cfg;
} TXFM_2D_FLIP_CFG;
......
......@@ -603,6 +603,7 @@ void av1_inv_txfm2d_add_32x32_avx2(const int32_t *coeff, uint16_t *output,
__m256i in[128], out[128];
const TXFM_1D_CFG *row_cfg = NULL;
const TXFM_1D_CFG *col_cfg = NULL;
const int8_t *shift = inv_txfm_shift_ls[TX_32X32];
switch (tx_type) {
case DCT_DCT:
......@@ -611,10 +612,10 @@ void av1_inv_txfm2d_add_32x32_avx2(const int32_t *coeff, uint16_t *output,
load_buffer_32x32(coeff, in);
transpose_32x32(in, out);
idct32_avx2(out, in, row_cfg->cos_bit[2]);
round_shift_32x32(in, -row_cfg->shift[0]);
round_shift_32x32(in, -shift[0]);
transpose_32x32(in, out);
idct32_avx2(out, in, col_cfg->cos_bit[2]);
write_buffer_32x32(in, output, stride, 0, 0, -row_cfg->shift[1], bd);
write_buffer_32x32(in, output, stride, 0, 0, -shift[1], bd);
break;
default: assert(0);
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -48,7 +48,7 @@ static INLINE TxfmFunc fwd_txfm_type_to_func(TXFM_TYPE txfm_type) {
void av1_gen_fwd_stage_range(int8_t *stage_range_col, int8_t *stage_range_row,
const TXFM_2D_FLIP_CFG *cfg, int bd) {
// Take the shift from the larger dimension in the rectangular case.
const int8_t *shift = cfg->row_cfg->shift;
const int8_t *shift = cfg->shift;
// i < MAX_TXFM_STAGE_NUM will mute above array bounds warning
for (int i = 0; i < cfg->col_cfg->stage_num && i < MAX_TXFM_STAGE_NUM; ++i) {
stage_range_col[i] = cfg->col_cfg->stage_range[i] + shift[0] + bd + 1;
......@@ -74,7 +74,7 @@ static INLINE void fwd_txfm2d_c(const int16_t *input, int32_t *output,
const int txfm_size_col = cfg->row_cfg->txfm_size;
const int txfm_size_row = cfg->col_cfg->txfm_size;
// Take the shift from the larger dimension in the rectangular case.
const int8_t *shift = cfg->row_cfg->shift;
const int8_t *shift = cfg->shift;
const int rect_type = get_rect_tx_log_ratio(txfm_size_col, txfm_size_row);
int8_t stage_range_col[MAX_TXFM_STAGE_NUM];
int8_t stage_range_row[MAX_TXFM_STAGE_NUM];
......@@ -616,6 +616,48 @@ static const TXFM_1D_CFG *fwd_txfm_row_cfg_ls[TX_TYPES_1D][TX_SIZES_ALL] = {
},
};
static const int8_t fwd_shift_4x4[3] = { 2, 0, 0 };
static const int8_t fwd_shift_8x8[3] = { 2, -1, 0 };
static const int8_t fwd_shift_16x16[3] = { 2, -2, 0 };
static const int8_t fwd_shift_32x32[3] = { 2, -4, 0 };
#if CONFIG_TX64X64
static const int8_t fwd_shift_64x64[3] = { 0, -2, -2 };
#endif
static const int8_t fwd_shift_4x8[3] = { 2, -1, 0 };
static const int8_t fwd_shift_8x4[3] = { 2, -1, 0 };
static const int8_t fwd_shift_8x16[3] = { 2, -2, 0 };
static const int8_t fwd_shift_16x8[3] = { 2, -2, 0 };
static const int8_t fwd_shift_16x32[3] = { 2, -4, 0 };
static const int8_t fwd_shift_32x16[3] = { 2, -4, 0 };
#if CONFIG_TX64X64
static const int8_t fwd_shift_32x64[3] = { 0, -2, -2 };
static const int8_t fwd_shift_64x32[3] = { 0, -2, -2 };
#endif
static const int8_t fwd_shift_4x16[3] = { 2, -1, 0 };
static const int8_t fwd_shift_16x4[3] = { 2, -1, 0 };
static const int8_t fwd_shift_8x32[3] = { 2, -2, 0 };
static const int8_t fwd_shift_32x8[3] = { 2, -2, 0 };
#if CONFIG_TX64X64
static const int8_t fwd_shift_16x64[3] = { 0, -2, 0 };
static const int8_t fwd_shift_64x16[3] = { 0, -2, 0 };
#endif // CONFIG_TX64X64
const int8_t *fwd_txfm_shift_ls[TX_SIZES_ALL] = {
fwd_shift_4x4, fwd_shift_8x8, fwd_shift_16x16, fwd_shift_32x32,
#if CONFIG_TX64X64
fwd_shift_64x64,
#endif // CONFIG_TX64X64
fwd_shift_4x8, fwd_shift_8x4, fwd_shift_8x16, fwd_shift_16x8,
fwd_shift_16x32, fwd_shift_32x16,
#if CONFIG_TX64X64
fwd_shift_32x64, fwd_shift_64x32,
#endif // CONFIG_TX64X64
fwd_shift_4x16, fwd_shift_16x4, fwd_shift_8x32, fwd_shift_32x8,
#if CONFIG_TX64X64
fwd_shift_16x64, fwd_shift_64x16,
#endif // CONFIG_TX64X64
};
void av1_get_fwd_txfm_cfg(TX_TYPE tx_type, TX_SIZE tx_size,
TXFM_2D_FLIP_CFG *cfg) {
assert(cfg != NULL);
......@@ -624,4 +666,5 @@ void av1_get_fwd_txfm_cfg(TX_TYPE tx_type, TX_SIZE tx_size,
const TX_TYPE_1D tx_type_row = htx_tab[tx_type];
cfg->col_cfg = fwd_txfm_col_cfg_ls[tx_type_col][tx_size];
cfg->row_cfg = fwd_txfm_row_cfg_ls[tx_type_row][tx_size];
cfg->shift = fwd_txfm_shift_ls[tx_size];
}
......@@ -47,7 +47,7 @@ static INLINE void fwd_txfm2d_sse4_1(const int16_t *input, int32_t *output,
// transforms.
assert(cfg->row_cfg->txfm_size == cfg->col_cfg->txfm_size);
const int txfm_size = cfg->row_cfg->txfm_size;
const int8_t *shift = cfg->row_cfg->shift;
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 *cos_bit_col = cfg->col_cfg->cos_bit;
......
This diff is collapsed.
......@@ -214,7 +214,7 @@ double get_amplification_factor(TX_TYPE tx_type, TX_SIZE tx_size) {
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 int8_t *shift = fwd_txfm_flip_cfg.row_cfg->shift;
const int8_t *shift = fwd_txfm_flip_cfg.shift;
const int amplify_bit = shift[0] + shift[1] + shift[2];
double amplify_factor =
amplify_bit >= 0 ? (1 << amplify_bit) : (1.0 / (1 << -amplify_bit));
......
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