Commit 9c7089a9 authored by Angie Chiang's avatar Angie Chiang

Add txfm config test

This test makes sure two things:
1) txfm stage range is within desired limit
    (lbd:16 bits hbd:32 bits)
2) txfm stage range + cos bits is within desired limit
    (lbd:32 bits hbd:32 bits)

Change-Id: Ie2cc3c8265810e034c1461def4717fa9d4c29945
parent ce3ad286
......@@ -21,6 +21,10 @@
#include "aom/aom_integer.h"
#include "aom_dsp/aom_dsp_common.h"
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_TXFM_STAGE_NUM 12
static const int cos_bit_min = 10;
......@@ -322,11 +326,9 @@ void av1_gen_inv_stage_range(int8_t *stage_range_col, int8_t *stage_range_row,
const TXFM_2D_FLIP_CFG *cfg, int8_t fwd_shift,
int bd);
#ifdef __cplusplus
extern "C" {
#endif
TXFM_2D_FLIP_CFG av1_get_fwd_txfm_cfg(int tx_type, int tx_size);
TXFM_2D_FLIP_CFG av1_get_fwd_txfm_64x64_cfg(int tx_type);
TXFM_2D_FLIP_CFG av1_get_inv_txfm_cfg(int tx_type, int tx_size);
#ifdef __cplusplus
}
#endif // __cplusplus
......
......@@ -177,5 +177,30 @@ const AV1FwdTxfm2dParam av1_fwd_txfm2d_param_c[] = {
INSTANTIATE_TEST_CASE_P(C, AV1FwdTxfm2d,
::testing::ValuesIn(av1_fwd_txfm2d_param_c));
TEST(AV1FwdTxfm2d, CfgTest) {
for (int bd_idx = 0; bd_idx < BD_NUM; ++bd_idx) {
int bd = libaom_test::bd_arr[bd_idx];
int8_t low_range = libaom_test::low_range_arr[bd_idx];
int8_t high_range = libaom_test::high_range_arr[bd_idx];
// TODO(angiebird): include rect txfm in this test
for (int tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (int tx_type = 0; tx_type < TX_TYPES; ++tx_type) {
TXFM_2D_FLIP_CFG cfg = av1_get_fwd_txfm_cfg(tx_type, tx_size);
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,
col_cfg->cos_bit, low_range,
high_range);
libaom_test::txfm_stage_range_check(stage_range_row, row_cfg->stage_num,
row_cfg->cos_bit, low_range,
high_range);
}
}
}
}
#endif // CONFIG_HIGHBITDEPTH
} // namespace
......@@ -185,6 +185,31 @@ const AV1InvTxfm2dParam av1_inv_txfm2d_param[] = {
INSTANTIATE_TEST_CASE_P(C, AV1InvTxfm2d,
::testing::ValuesIn(av1_inv_txfm2d_param));
TEST(AV1InvTxfm2d, CfgTest) {
for (int bd_idx = 0; bd_idx < BD_NUM; ++bd_idx) {
int bd = libaom_test::bd_arr[bd_idx];
int8_t low_range = libaom_test::low_range_arr[bd_idx];
int8_t high_range = libaom_test::high_range_arr[bd_idx];
// TODO(angiebird): include rect txfm in this test
for (int tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (int tx_type = 0; tx_type < TX_TYPES; ++tx_type) {
TXFM_2D_FLIP_CFG cfg = av1_get_inv_txfm_cfg(tx_type, tx_size);
int8_t stage_range_col[MAX_TXFM_STAGE_NUM];
int8_t stage_range_row[MAX_TXFM_STAGE_NUM];
av1_gen_inv_stage_range(stage_range_col, stage_range_row, &cfg,
fwd_shift_sum[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,
col_cfg->cos_bit, low_range,
high_range);
libaom_test::txfm_stage_range_check(stage_range_row, row_cfg->stage_num,
row_cfg->cos_bit, low_range,
high_range);
}
}
}
}
#endif // CONFIG_HIGHBITDEPTH
} // namespace
......@@ -161,4 +161,19 @@ template void fliplr<double>(double *dest, int stride, int length);
template void flipud<double>(double *dest, int stride, int length);
template void fliplrud<double>(double *dest, int stride, int length);
int bd_arr[BD_NUM] = { 8, 10, 12 };
int8_t low_range_arr[BD_NUM] = { 16, 32, 32 };
int8_t high_range_arr[BD_NUM] = { 32, 32, 32 };
void txfm_stage_range_check(const int8_t *stage_range, int stage_num,
const int8_t *cos_bit, int low_range,
int high_range) {
for (int i = 0; i < stage_num; ++i) {
EXPECT_LE(stage_range[i], low_range);
}
for (int i = 0; i < stage_num - 1; ++i) {
// make sure there is no overflow while doing half_btf()
EXPECT_LE(stage_range[i + 1] + cos_bit[i], high_range);
}
}
} // namespace libaom_test
......@@ -127,5 +127,14 @@ static const Inv_Txfm2d_Func inv_txfm_func_ls[TX_SIZES_ALL] = {
};
#endif // CONFIG_HIGHBITDEPTH
#define BD_NUM 3
extern int bd_arr[];
extern int8_t low_range_arr[];
extern int8_t high_range_arr[];
void txfm_stage_range_check(const int8_t *stage_range, int stage_num,
const int8_t *cos_bit, int low_range,
int high_range);
} // namespace libaom_test
#endif // AV1_TXFM_TEST_H_
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