OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 int mask_; | 112 int mask_; |
113 FwdTxfmFunc fwd_txfm_; | 113 FwdTxfmFunc fwd_txfm_; |
114 InvTxfmFunc inv_txfm_; | 114 InvTxfmFunc inv_txfm_; |
115 }; | 115 }; |
116 | 116 |
117 TEST_P(Trans32x32Test, AccuracyCheck) { | 117 TEST_P(Trans32x32Test, AccuracyCheck) { |
118 ACMRandom rnd(ACMRandom::DeterministicSeed()); | 118 ACMRandom rnd(ACMRandom::DeterministicSeed()); |
119 uint32_t max_error = 0; | 119 uint32_t max_error = 0; |
120 int64_t total_error = 0; | 120 int64_t total_error = 0; |
121 const int count_test_block = 10000; | 121 const int count_test_block = 10000; |
122 DECLARE_ALIGNED_ARRAY(16, int16_t, test_input_block, kNumCoeffs); | 122 DECLARE_ALIGNED(16, int16_t, test_input_block[kNumCoeffs]); |
123 DECLARE_ALIGNED_ARRAY(16, tran_low_t, test_temp_block, kNumCoeffs); | 123 DECLARE_ALIGNED(16, tran_low_t, test_temp_block[kNumCoeffs]); |
124 DECLARE_ALIGNED_ARRAY(16, uint8_t, dst, kNumCoeffs); | 124 DECLARE_ALIGNED(16, uint8_t, dst[kNumCoeffs]); |
125 DECLARE_ALIGNED_ARRAY(16, uint8_t, src, kNumCoeffs); | 125 DECLARE_ALIGNED(16, uint8_t, src[kNumCoeffs]); |
126 #if CONFIG_VP9_HIGHBITDEPTH | 126 #if CONFIG_VP9_HIGHBITDEPTH |
127 DECLARE_ALIGNED_ARRAY(16, uint16_t, dst16, kNumCoeffs); | 127 DECLARE_ALIGNED(16, uint16_t, dst16[kNumCoeffs]); |
128 DECLARE_ALIGNED_ARRAY(16, uint16_t, src16, kNumCoeffs); | 128 DECLARE_ALIGNED(16, uint16_t, src16[kNumCoeffs]); |
129 #endif | 129 #endif |
130 | 130 |
131 for (int i = 0; i < count_test_block; ++i) { | 131 for (int i = 0; i < count_test_block; ++i) { |
132 // Initialize a test block with input range [-mask_, mask_]. | 132 // Initialize a test block with input range [-mask_, mask_]. |
133 for (int j = 0; j < kNumCoeffs; ++j) { | 133 for (int j = 0; j < kNumCoeffs; ++j) { |
134 if (bit_depth_ == VPX_BITS_8) { | 134 if (bit_depth_ == VPX_BITS_8) { |
135 src[j] = rnd.Rand8(); | 135 src[j] = rnd.Rand8(); |
136 dst[j] = rnd.Rand8(); | 136 dst[j] = rnd.Rand8(); |
137 test_input_block[j] = src[j] - dst[j]; | 137 test_input_block[j] = src[j] - dst[j]; |
138 #if CONFIG_VP9_HIGHBITDEPTH | 138 #if CONFIG_VP9_HIGHBITDEPTH |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 << "Error: 32x32 FDCT/IDCT has an individual round-trip error > 1"; | 177 << "Error: 32x32 FDCT/IDCT has an individual round-trip error > 1"; |
178 | 178 |
179 EXPECT_GE(count_test_block << 2 * (bit_depth_ - 8), total_error) | 179 EXPECT_GE(count_test_block << 2 * (bit_depth_ - 8), total_error) |
180 << "Error: 32x32 FDCT/IDCT has average round-trip error > 1 per block"; | 180 << "Error: 32x32 FDCT/IDCT has average round-trip error > 1 per block"; |
181 } | 181 } |
182 | 182 |
183 TEST_P(Trans32x32Test, CoeffCheck) { | 183 TEST_P(Trans32x32Test, CoeffCheck) { |
184 ACMRandom rnd(ACMRandom::DeterministicSeed()); | 184 ACMRandom rnd(ACMRandom::DeterministicSeed()); |
185 const int count_test_block = 1000; | 185 const int count_test_block = 1000; |
186 | 186 |
187 DECLARE_ALIGNED_ARRAY(16, int16_t, input_block, kNumCoeffs); | 187 DECLARE_ALIGNED(16, int16_t, input_block[kNumCoeffs]); |
188 DECLARE_ALIGNED_ARRAY(16, tran_low_t, output_ref_block, kNumCoeffs); | 188 DECLARE_ALIGNED(16, tran_low_t, output_ref_block[kNumCoeffs]); |
189 DECLARE_ALIGNED_ARRAY(16, tran_low_t, output_block, kNumCoeffs); | 189 DECLARE_ALIGNED(16, tran_low_t, output_block[kNumCoeffs]); |
190 | 190 |
191 for (int i = 0; i < count_test_block; ++i) { | 191 for (int i = 0; i < count_test_block; ++i) { |
192 for (int j = 0; j < kNumCoeffs; ++j) | 192 for (int j = 0; j < kNumCoeffs; ++j) |
193 input_block[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_); | 193 input_block[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_); |
194 | 194 |
195 const int stride = 32; | 195 const int stride = 32; |
196 vp9_fdct32x32_c(input_block, output_ref_block, stride); | 196 vp9_fdct32x32_c(input_block, output_ref_block, stride); |
197 ASM_REGISTER_STATE_CHECK(fwd_txfm_(input_block, output_block, stride)); | 197 ASM_REGISTER_STATE_CHECK(fwd_txfm_(input_block, output_block, stride)); |
198 | 198 |
199 if (version_ == 0) { | 199 if (version_ == 0) { |
200 for (int j = 0; j < kNumCoeffs; ++j) | 200 for (int j = 0; j < kNumCoeffs; ++j) |
201 EXPECT_EQ(output_block[j], output_ref_block[j]) | 201 EXPECT_EQ(output_block[j], output_ref_block[j]) |
202 << "Error: 32x32 FDCT versions have mismatched coefficients"; | 202 << "Error: 32x32 FDCT versions have mismatched coefficients"; |
203 } else { | 203 } else { |
204 for (int j = 0; j < kNumCoeffs; ++j) | 204 for (int j = 0; j < kNumCoeffs; ++j) |
205 EXPECT_GE(6, abs(output_block[j] - output_ref_block[j])) | 205 EXPECT_GE(6, abs(output_block[j] - output_ref_block[j])) |
206 << "Error: 32x32 FDCT rd has mismatched coefficients"; | 206 << "Error: 32x32 FDCT rd has mismatched coefficients"; |
207 } | 207 } |
208 } | 208 } |
209 } | 209 } |
210 | 210 |
211 TEST_P(Trans32x32Test, MemCheck) { | 211 TEST_P(Trans32x32Test, MemCheck) { |
212 ACMRandom rnd(ACMRandom::DeterministicSeed()); | 212 ACMRandom rnd(ACMRandom::DeterministicSeed()); |
213 const int count_test_block = 2000; | 213 const int count_test_block = 2000; |
214 | 214 |
215 DECLARE_ALIGNED_ARRAY(16, int16_t, input_block, kNumCoeffs); | 215 DECLARE_ALIGNED(16, int16_t, input_extreme_block[kNumCoeffs]); |
216 DECLARE_ALIGNED_ARRAY(16, int16_t, input_extreme_block, kNumCoeffs); | 216 DECLARE_ALIGNED(16, tran_low_t, output_ref_block[kNumCoeffs]); |
217 DECLARE_ALIGNED_ARRAY(16, tran_low_t, output_ref_block, kNumCoeffs); | 217 DECLARE_ALIGNED(16, tran_low_t, output_block[kNumCoeffs]); |
218 DECLARE_ALIGNED_ARRAY(16, tran_low_t, output_block, kNumCoeffs); | |
219 | 218 |
220 for (int i = 0; i < count_test_block; ++i) { | 219 for (int i = 0; i < count_test_block; ++i) { |
221 // Initialize a test block with input range [-mask_, mask_]. | 220 // Initialize a test block with input range [-mask_, mask_]. |
222 for (int j = 0; j < kNumCoeffs; ++j) { | 221 for (int j = 0; j < kNumCoeffs; ++j) { |
223 input_block[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_); | |
224 input_extreme_block[j] = rnd.Rand8() & 1 ? mask_ : -mask_; | 222 input_extreme_block[j] = rnd.Rand8() & 1 ? mask_ : -mask_; |
225 } | 223 } |
226 if (i == 0) { | 224 if (i == 0) { |
227 for (int j = 0; j < kNumCoeffs; ++j) | 225 for (int j = 0; j < kNumCoeffs; ++j) |
228 input_extreme_block[j] = mask_; | 226 input_extreme_block[j] = mask_; |
229 } else if (i == 1) { | 227 } else if (i == 1) { |
230 for (int j = 0; j < kNumCoeffs; ++j) | 228 for (int j = 0; j < kNumCoeffs; ++j) |
231 input_extreme_block[j] = -mask_; | 229 input_extreme_block[j] = -mask_; |
232 } | 230 } |
233 | 231 |
(...skipping 16 matching lines...) Expand all Loading... |
250 EXPECT_GE(4 * DCT_MAX_VALUE << (bit_depth_ - 8), abs(output_block[j])) | 248 EXPECT_GE(4 * DCT_MAX_VALUE << (bit_depth_ - 8), abs(output_block[j])) |
251 << "Error: 32x32 FDCT has coefficient larger than " | 249 << "Error: 32x32 FDCT has coefficient larger than " |
252 << "4*DCT_MAX_VALUE"; | 250 << "4*DCT_MAX_VALUE"; |
253 } | 251 } |
254 } | 252 } |
255 } | 253 } |
256 | 254 |
257 TEST_P(Trans32x32Test, InverseAccuracy) { | 255 TEST_P(Trans32x32Test, InverseAccuracy) { |
258 ACMRandom rnd(ACMRandom::DeterministicSeed()); | 256 ACMRandom rnd(ACMRandom::DeterministicSeed()); |
259 const int count_test_block = 1000; | 257 const int count_test_block = 1000; |
260 DECLARE_ALIGNED_ARRAY(16, int16_t, in, kNumCoeffs); | 258 DECLARE_ALIGNED(16, int16_t, in[kNumCoeffs]); |
261 DECLARE_ALIGNED_ARRAY(16, tran_low_t, coeff, kNumCoeffs); | 259 DECLARE_ALIGNED(16, tran_low_t, coeff[kNumCoeffs]); |
262 DECLARE_ALIGNED_ARRAY(16, uint8_t, dst, kNumCoeffs); | 260 DECLARE_ALIGNED(16, uint8_t, dst[kNumCoeffs]); |
263 DECLARE_ALIGNED_ARRAY(16, uint8_t, src, kNumCoeffs); | 261 DECLARE_ALIGNED(16, uint8_t, src[kNumCoeffs]); |
264 #if CONFIG_VP9_HIGHBITDEPTH | 262 #if CONFIG_VP9_HIGHBITDEPTH |
265 DECLARE_ALIGNED_ARRAY(16, uint16_t, dst16, kNumCoeffs); | 263 DECLARE_ALIGNED(16, uint16_t, dst16[kNumCoeffs]); |
266 DECLARE_ALIGNED_ARRAY(16, uint16_t, src16, kNumCoeffs); | 264 DECLARE_ALIGNED(16, uint16_t, src16[kNumCoeffs]); |
267 #endif | 265 #endif |
268 | 266 |
269 for (int i = 0; i < count_test_block; ++i) { | 267 for (int i = 0; i < count_test_block; ++i) { |
270 double out_r[kNumCoeffs]; | 268 double out_r[kNumCoeffs]; |
271 | 269 |
272 // Initialize a test block with input range [-255, 255] | 270 // Initialize a test block with input range [-255, 255] |
273 for (int j = 0; j < kNumCoeffs; ++j) { | 271 for (int j = 0; j < kNumCoeffs; ++j) { |
274 if (bit_depth_ == VPX_BITS_8) { | 272 if (bit_depth_ == VPX_BITS_8) { |
275 src[j] = rnd.Rand8(); | 273 src[j] = rnd.Rand8(); |
276 dst[j] = rnd.Rand8(); | 274 dst[j] = rnd.Rand8(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 | 373 |
376 #if HAVE_AVX2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE | 374 #if HAVE_AVX2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE |
377 INSTANTIATE_TEST_CASE_P( | 375 INSTANTIATE_TEST_CASE_P( |
378 AVX2, Trans32x32Test, | 376 AVX2, Trans32x32Test, |
379 ::testing::Values( | 377 ::testing::Values( |
380 make_tuple(&vp9_fdct32x32_avx2, | 378 make_tuple(&vp9_fdct32x32_avx2, |
381 &vp9_idct32x32_1024_add_sse2, 0, VPX_BITS_8), | 379 &vp9_idct32x32_1024_add_sse2, 0, VPX_BITS_8), |
382 make_tuple(&vp9_fdct32x32_rd_avx2, | 380 make_tuple(&vp9_fdct32x32_rd_avx2, |
383 &vp9_idct32x32_1024_add_sse2, 1, VPX_BITS_8))); | 381 &vp9_idct32x32_1024_add_sse2, 1, VPX_BITS_8))); |
384 #endif // HAVE_AVX2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE | 382 #endif // HAVE_AVX2 && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE |
| 383 |
| 384 #if HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE |
| 385 INSTANTIATE_TEST_CASE_P( |
| 386 MSA, Trans32x32Test, |
| 387 ::testing::Values( |
| 388 make_tuple(&vp9_fdct32x32_c, |
| 389 &vp9_idct32x32_1024_add_msa, 0, VPX_BITS_8))); |
| 390 #endif // HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH && !CONFIG_EMULATE_HARDWARE |
385 } // namespace | 391 } // namespace |
OLD | NEW |