2 * Copyright (c) 2017 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
17 #include "third_party/googletest/src/include/gtest/gtest.h"
19 #include "./vpx_dsp_rtcd.h"
20 #include "test/acm_random.h"
21 #include "test/buffer.h"
22 #include "test/clear_system_state.h"
23 #include "test/register_state_check.h"
24 #include "test/util.h"
25 #include "vpx/vpx_codec.h"
26 #include "vpx/vpx_integer.h"
27 #include "vpx_dsp/vpx_dsp_common.h"
29 using libvpx_test::ACMRandom;
30 using libvpx_test::Buffer;
31 using ::testing::make_tuple;
32 using ::testing::tuple;
35 typedef void (*PartialFdctFunc)(const int16_t *in, tran_low_t *out, int stride);
37 typedef tuple<PartialFdctFunc, int /* size */, vpx_bit_depth_t>
40 tran_low_t partial_fdct_ref(const Buffer<int16_t> &in, int size) {
42 for (int y = 0; y < size; ++y) {
43 for (int x = 0; x < size; ++x) {
44 sum += in.TopLeftPixel()[y * in.stride() + x];
49 case 4: sum *= 2; break;
50 case 8: /*sum = sum;*/ break;
51 case 16: sum >>= 1; break;
52 case 32: sum >>= 3; break;
55 return static_cast<tran_low_t>(sum);
58 class PartialFdctTest : public ::testing::TestWithParam<PartialFdctParam> {
61 fwd_txfm_ = GET_PARAM(0);
63 bit_depth_ = GET_PARAM(2);
66 virtual void TearDown() { libvpx_test::ClearSystemState(); }
70 ACMRandom rnd(ACMRandom::DeterministicSeed());
71 const int16_t maxvalue =
72 clip_pixel_highbd(std::numeric_limits<int16_t>::max(), bit_depth_);
73 const int16_t minvalue = -maxvalue;
74 Buffer<int16_t> input_block =
75 Buffer<int16_t>(size_, size_, 8, size_ == 4 ? 0 : 16);
76 ASSERT_TRUE(input_block.Init());
77 Buffer<tran_low_t> output_block = Buffer<tran_low_t>(size_, size_, 0, 16);
78 ASSERT_TRUE(output_block.Init());
80 for (int i = 0; i < 100; ++i) {
82 input_block.Set(maxvalue);
84 input_block.Set(minvalue);
86 input_block.Set(&rnd, minvalue, maxvalue);
89 ASM_REGISTER_STATE_CHECK(fwd_txfm_(input_block.TopLeftPixel(),
90 output_block.TopLeftPixel(),
91 input_block.stride()));
93 EXPECT_EQ(partial_fdct_ref(input_block, size_),
94 output_block.TopLeftPixel()[0]);
98 PartialFdctFunc fwd_txfm_;
99 vpx_bit_depth_t bit_depth_;
103 TEST_P(PartialFdctTest, PartialFdctTest) { RunTest(); }
105 #if CONFIG_VP9_HIGHBITDEPTH
106 INSTANTIATE_TEST_CASE_P(
108 ::testing::Values(make_tuple(&vpx_highbd_fdct32x32_1_c, 32, VPX_BITS_12),
109 make_tuple(&vpx_highbd_fdct32x32_1_c, 32, VPX_BITS_10),
110 make_tuple(&vpx_fdct32x32_1_c, 32, VPX_BITS_8),
111 make_tuple(&vpx_highbd_fdct16x16_1_c, 16, VPX_BITS_12),
112 make_tuple(&vpx_highbd_fdct16x16_1_c, 16, VPX_BITS_10),
113 make_tuple(&vpx_fdct16x16_1_c, 16, VPX_BITS_8),
114 make_tuple(&vpx_highbd_fdct8x8_1_c, 8, VPX_BITS_12),
115 make_tuple(&vpx_highbd_fdct8x8_1_c, 8, VPX_BITS_10),
116 make_tuple(&vpx_fdct8x8_1_c, 8, VPX_BITS_8),
117 make_tuple(&vpx_fdct4x4_1_c, 4, VPX_BITS_8)));
119 INSTANTIATE_TEST_CASE_P(
121 ::testing::Values(make_tuple(&vpx_fdct32x32_1_c, 32, VPX_BITS_8),
122 make_tuple(&vpx_fdct16x16_1_c, 16, VPX_BITS_8),
123 make_tuple(&vpx_fdct8x8_1_c, 8, VPX_BITS_8),
124 make_tuple(&vpx_fdct4x4_1_c, 4, VPX_BITS_8)));
125 #endif // CONFIG_VP9_HIGHBITDEPTH
128 INSTANTIATE_TEST_CASE_P(
129 SSE2, PartialFdctTest,
130 ::testing::Values(make_tuple(&vpx_fdct32x32_1_sse2, 32, VPX_BITS_8),
131 make_tuple(&vpx_fdct16x16_1_sse2, 16, VPX_BITS_8),
132 make_tuple(&vpx_fdct8x8_1_sse2, 8, VPX_BITS_8),
133 make_tuple(&vpx_fdct4x4_1_sse2, 4, VPX_BITS_8)));
137 #if CONFIG_VP9_HIGHBITDEPTH
138 INSTANTIATE_TEST_CASE_P(
139 NEON, PartialFdctTest,
140 ::testing::Values(make_tuple(&vpx_fdct32x32_1_neon, 32, VPX_BITS_8),
141 make_tuple(&vpx_fdct16x16_1_neon, 16, VPX_BITS_8),
142 make_tuple(&vpx_fdct8x8_1_neon, 8, VPX_BITS_12),
143 make_tuple(&vpx_fdct8x8_1_neon, 8, VPX_BITS_10),
144 make_tuple(&vpx_fdct8x8_1_neon, 8, VPX_BITS_8),
145 make_tuple(&vpx_fdct4x4_1_neon, 4, VPX_BITS_8)));
147 INSTANTIATE_TEST_CASE_P(
148 NEON, PartialFdctTest,
149 ::testing::Values(make_tuple(&vpx_fdct32x32_1_neon, 32, VPX_BITS_8),
150 make_tuple(&vpx_fdct16x16_1_neon, 16, VPX_BITS_8),
151 make_tuple(&vpx_fdct8x8_1_neon, 8, VPX_BITS_8),
152 make_tuple(&vpx_fdct4x4_1_neon, 4, VPX_BITS_8)));
153 #endif // CONFIG_VP9_HIGHBITDEPTH
157 #if CONFIG_VP9_HIGHBITDEPTH
158 INSTANTIATE_TEST_CASE_P(MSA, PartialFdctTest,
159 ::testing::Values(make_tuple(&vpx_fdct8x8_1_msa, 8,
161 #else // !CONFIG_VP9_HIGHBITDEPTH
162 INSTANTIATE_TEST_CASE_P(
163 MSA, PartialFdctTest,
164 ::testing::Values(make_tuple(&vpx_fdct32x32_1_msa, 32, VPX_BITS_8),
165 make_tuple(&vpx_fdct16x16_1_msa, 16, VPX_BITS_8),
166 make_tuple(&vpx_fdct8x8_1_msa, 8, VPX_BITS_8)));
167 #endif // CONFIG_VP9_HIGHBITDEPTH