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
diff --git a/av1/common/av1_txfm.h b/av1/common/av1_txfm.h
index ce6a410..891d9ab 100644
--- a/av1/common/av1_txfm.h
+++ b/av1/common/av1_txfm.h
@@ -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 @@
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
diff --git a/test/av1_fwd_txfm2d_test.cc b/test/av1_fwd_txfm2d_test.cc
index af3c8ff..74557e9 100644
--- a/test/av1_fwd_txfm2d_test.cc
+++ b/test/av1_fwd_txfm2d_test.cc
@@ -177,5 +177,30 @@
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
diff --git a/test/av1_inv_txfm2d_test.cc b/test/av1_inv_txfm2d_test.cc
index ac78640..f8d8e87 100644
--- a/test/av1_inv_txfm2d_test.cc
+++ b/test/av1_inv_txfm2d_test.cc
@@ -185,6 +185,31 @@
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
diff --git a/test/av1_txfm_test.cc b/test/av1_txfm_test.cc
index 1e473b3..191223c 100644
--- a/test/av1_txfm_test.cc
+++ b/test/av1_txfm_test.cc
@@ -161,4 +161,19 @@
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
diff --git a/test/av1_txfm_test.h b/test/av1_txfm_test.h
index 25f9cfb..35ef347 100644
--- a/test/av1_txfm_test.h
+++ b/test/av1_txfm_test.h
@@ -127,5 +127,14 @@
};
#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_