Avoid dynamic memory allocation Change-Id: If15d35788bed9a1fcda6ebf7a8173960c7fe7e0e
diff --git a/test/av1_inv_txfm1d_test.cc b/test/av1_inv_txfm1d_test.cc index 9cf33a2..9df9506 100644 --- a/test/av1_inv_txfm1d_test.cc +++ b/test/av1_inv_txfm1d_test.cc
@@ -10,6 +10,7 @@ */ #include "test/av1_txfm_test.h" +#include "test/util.h" #include "av1/common/av1_fwd_txfm1d.h" #include "av1/common/av1_inv_txfm1d.h" @@ -44,8 +45,6 @@ const int8_t cos_bit[12] = { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 }; const int8_t range_bit[12] = { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 }; -#define ARRAY_SIZE(x) (int)(sizeof(x) / sizeof(x[0])) - TEST(av1_inv_txfm1d, round_trip) { ACMRandom rnd(ACMRandom::DeterministicSeed()); for (int si = 0; si < ARRAY_SIZE(fwd_txfm_func_ls); ++si) {
diff --git a/test/av1_inv_txfm2d_test.cc b/test/av1_inv_txfm2d_test.cc index f137699..5d59e2b 100644 --- a/test/av1_inv_txfm2d_test.cc +++ b/test/av1_inv_txfm2d_test.cc
@@ -42,16 +42,17 @@ max_avg_error_ = GET_PARAM(3); txfm1d_size_ = libaom_test::get_txfm1d_size(tx_size_); txfm2d_size_ = txfm1d_size_ * txfm1d_size_; - - input_ = reinterpret_cast<int16_t *>( - aom_memalign(16, sizeof(int16_t) * txfm2d_size_)); - ref_input_ = reinterpret_cast<uint16_t *>( - aom_memalign(16, sizeof(uint16_t) * txfm2d_size_)); - output_ = reinterpret_cast<int32_t *>( - aom_memalign(16, sizeof(int32_t) * txfm2d_size_)); } void RunRoundtripCheck() { + int16_t input_[64 * 64]; + uint16_t ref_input_[64 * 64]; + int32_t output_[64 * 64]; + + assert(txfm2d_size_ < ARRAY_SIZE(input_)); + assert(txfm2d_size_ < ARRAY_SIZE(output_)); + assert(txfm2d_size_ < ARRAY_SIZE(ref_input_)); + const Fwd_Txfm2d_Func fwd_txfm_func = libaom_test::fwd_txfm_func_ls[tx_size_]; const Inv_Txfm2d_Func inv_txfm_func = @@ -90,12 +91,6 @@ EXPECT_GE(max_avg_error_, avg_abs_error); } - virtual void TearDown() { - aom_free(input_); - aom_free(output_); - aom_free(ref_input_); - } - private: int max_error_; double max_avg_error_; @@ -103,9 +98,6 @@ TX_SIZE tx_size_; int txfm1d_size_; int txfm2d_size_; - int16_t *input_; - uint16_t *ref_input_; - int32_t *output_; }; TEST_P(AV1InvTxfm2d, RunRoundtripCheck) { RunRoundtripCheck(); }
diff --git a/test/util.h b/test/util.h index a20fab6..83d7903 100644 --- a/test/util.h +++ b/test/util.h
@@ -17,6 +17,8 @@ #include "third_party/googletest/src/googletest/include/gtest/gtest.h" #include "aom/aom_image.h" +#define ARRAY_SIZE(x) (int)(sizeof(x) / sizeof(x[0])) + // Macros #define GET_PARAM(k) std::tr1::get<k>(GetParam())