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 std::make_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 if (in.TopLeftPixel() != NULL) {
43 for (int y = 0; y < size; ++y) {
44 for (int x = 0; x < size; ++x) {
45 sum += in.TopLeftPixel()[y * in.stride() + x];
53 case 4: sum *= 2; break;
54 case 8: /*sum = sum;*/ break;
55 case 16: sum >>= 1; break;
56 case 32: sum >>= 3; break;
59 return static_cast<tran_low_t>(sum);
62 class PartialFdctTest : public ::testing::TestWithParam<PartialFdctParam> {
65 fwd_txfm_ = GET_PARAM(0);
67 bit_depth_ = GET_PARAM(2);
70 virtual void TearDown() { libvpx_test::ClearSystemState(); }
74 ACMRandom rnd(ACMRandom::DeterministicSeed());
75 const int16_t maxvalue =
76 clip_pixel_highbd(std::numeric_limits<int16_t>::max(), bit_depth_);
77 const int16_t minvalue = -maxvalue;
78 Buffer<int16_t> input_block =
79 Buffer<int16_t>(size_, size_, 8, size_ == 4 ? 0 : 16);
80 ASSERT_TRUE(input_block.Init());
81 Buffer<tran_low_t> output_block = Buffer<tran_low_t>(size_, size_, 0, 16);
82 ASSERT_TRUE(output_block.Init());
84 if (output_block.TopLeftPixel() != NULL) {
85 for (int i = 0; i < 100; ++i) {
87 input_block.Set(maxvalue);
89 input_block.Set(minvalue);
91 input_block.Set(&rnd, minvalue, maxvalue);
94 ASM_REGISTER_STATE_CHECK(fwd_txfm_(input_block.TopLeftPixel(),
95 output_block.TopLeftPixel(),
96 input_block.stride()));
98 EXPECT_EQ(partial_fdct_ref(input_block, size_),
99 output_block.TopLeftPixel()[0]);
106 PartialFdctFunc fwd_txfm_;
107 vpx_bit_depth_t bit_depth_;
111 TEST_P(PartialFdctTest, PartialFdctTest) { RunTest(); }
113 #if CONFIG_VP9_HIGHBITDEPTH
114 INSTANTIATE_TEST_CASE_P(
116 ::testing::Values(make_tuple(&vpx_highbd_fdct32x32_1_c, 32, VPX_BITS_12),
117 make_tuple(&vpx_highbd_fdct32x32_1_c, 32, VPX_BITS_10),
118 make_tuple(&vpx_fdct32x32_1_c, 32, VPX_BITS_8),
119 make_tuple(&vpx_highbd_fdct16x16_1_c, 16, VPX_BITS_12),
120 make_tuple(&vpx_highbd_fdct16x16_1_c, 16, VPX_BITS_10),
121 make_tuple(&vpx_fdct16x16_1_c, 16, VPX_BITS_8),
122 make_tuple(&vpx_highbd_fdct8x8_1_c, 8, VPX_BITS_12),
123 make_tuple(&vpx_highbd_fdct8x8_1_c, 8, VPX_BITS_10),
124 make_tuple(&vpx_fdct8x8_1_c, 8, VPX_BITS_8),
125 make_tuple(&vpx_fdct4x4_1_c, 4, VPX_BITS_8)));
127 INSTANTIATE_TEST_CASE_P(
129 ::testing::Values(make_tuple(&vpx_fdct32x32_1_c, 32, VPX_BITS_8),
130 make_tuple(&vpx_fdct16x16_1_c, 16, VPX_BITS_8),
131 make_tuple(&vpx_fdct8x8_1_c, 8, VPX_BITS_8),
132 make_tuple(&vpx_fdct4x4_1_c, 4, VPX_BITS_8)));
133 #endif // CONFIG_VP9_HIGHBITDEPTH
136 INSTANTIATE_TEST_CASE_P(
137 SSE2, PartialFdctTest,
138 ::testing::Values(make_tuple(&vpx_fdct32x32_1_sse2, 32, VPX_BITS_8),
139 make_tuple(&vpx_fdct16x16_1_sse2, 16, VPX_BITS_8),
140 make_tuple(&vpx_fdct8x8_1_sse2, 8, VPX_BITS_8),
141 make_tuple(&vpx_fdct4x4_1_sse2, 4, VPX_BITS_8)));
145 #if CONFIG_VP9_HIGHBITDEPTH
146 INSTANTIATE_TEST_CASE_P(
147 NEON, PartialFdctTest,
148 ::testing::Values(make_tuple(&vpx_fdct32x32_1_neon, 32, VPX_BITS_8),
149 make_tuple(&vpx_fdct16x16_1_neon, 16, VPX_BITS_8),
150 make_tuple(&vpx_fdct8x8_1_neon, 8, VPX_BITS_12),
151 make_tuple(&vpx_fdct8x8_1_neon, 8, VPX_BITS_10),
152 make_tuple(&vpx_fdct8x8_1_neon, 8, VPX_BITS_8),
153 make_tuple(&vpx_fdct4x4_1_neon, 4, VPX_BITS_8)));
155 INSTANTIATE_TEST_CASE_P(
156 NEON, PartialFdctTest,
157 ::testing::Values(make_tuple(&vpx_fdct32x32_1_neon, 32, VPX_BITS_8),
158 make_tuple(&vpx_fdct16x16_1_neon, 16, VPX_BITS_8),
159 make_tuple(&vpx_fdct8x8_1_neon, 8, VPX_BITS_8),
160 make_tuple(&vpx_fdct4x4_1_neon, 4, VPX_BITS_8)));
161 #endif // CONFIG_VP9_HIGHBITDEPTH
165 #if CONFIG_VP9_HIGHBITDEPTH
166 INSTANTIATE_TEST_CASE_P(MSA, PartialFdctTest,
167 ::testing::Values(make_tuple(&vpx_fdct8x8_1_msa, 8,
169 #else // !CONFIG_VP9_HIGHBITDEPTH
170 INSTANTIATE_TEST_CASE_P(
171 MSA, PartialFdctTest,
172 ::testing::Values(make_tuple(&vpx_fdct32x32_1_msa, 32, VPX_BITS_8),
173 make_tuple(&vpx_fdct16x16_1_msa, 16, VPX_BITS_8),
174 make_tuple(&vpx_fdct8x8_1_msa, 8, VPX_BITS_8)));
175 #endif // CONFIG_VP9_HIGHBITDEPTH