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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 class FwdTrans8x8TestBase { | 132 class FwdTrans8x8TestBase { |
133 public: | 133 public: |
134 virtual ~FwdTrans8x8TestBase() {} | 134 virtual ~FwdTrans8x8TestBase() {} |
135 | 135 |
136 protected: | 136 protected: |
137 virtual void RunFwdTxfm(int16_t *in, tran_low_t *out, int stride) = 0; | 137 virtual void RunFwdTxfm(int16_t *in, tran_low_t *out, int stride) = 0; |
138 virtual void RunInvTxfm(tran_low_t *out, uint8_t *dst, int stride) = 0; | 138 virtual void RunInvTxfm(tran_low_t *out, uint8_t *dst, int stride) = 0; |
139 | 139 |
140 void RunSignBiasCheck() { | 140 void RunSignBiasCheck() { |
141 ACMRandom rnd(ACMRandom::DeterministicSeed()); | 141 ACMRandom rnd(ACMRandom::DeterministicSeed()); |
142 DECLARE_ALIGNED_ARRAY(16, int16_t, test_input_block, 64); | 142 DECLARE_ALIGNED(16, int16_t, test_input_block[64]); |
143 DECLARE_ALIGNED_ARRAY(16, tran_low_t, test_output_block, 64); | 143 DECLARE_ALIGNED(16, tran_low_t, test_output_block[64]); |
144 int count_sign_block[64][2]; | 144 int count_sign_block[64][2]; |
145 const int count_test_block = 100000; | 145 const int count_test_block = 100000; |
146 | 146 |
147 memset(count_sign_block, 0, sizeof(count_sign_block)); | 147 memset(count_sign_block, 0, sizeof(count_sign_block)); |
148 | 148 |
149 for (int i = 0; i < count_test_block; ++i) { | 149 for (int i = 0; i < count_test_block; ++i) { |
150 // Initialize a test block with input range [-255, 255]. | 150 // Initialize a test block with input range [-255, 255]. |
151 for (int j = 0; j < 64; ++j) | 151 for (int j = 0; j < 64; ++j) |
152 test_input_block[j] = ((rnd.Rand16() >> (16 - bit_depth_)) & mask_) - | 152 test_input_block[j] = ((rnd.Rand16() >> (16 - bit_depth_)) & mask_) - |
153 ((rnd.Rand16() >> (16 - bit_depth_)) & mask_); | 153 ((rnd.Rand16() >> (16 - bit_depth_)) & mask_); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 << " count1: " << count_sign_block[j][1] | 203 << " count1: " << count_sign_block[j][1] |
204 << " diff: " << diff; | 204 << " diff: " << diff; |
205 } | 205 } |
206 } | 206 } |
207 | 207 |
208 void RunRoundTripErrorCheck() { | 208 void RunRoundTripErrorCheck() { |
209 ACMRandom rnd(ACMRandom::DeterministicSeed()); | 209 ACMRandom rnd(ACMRandom::DeterministicSeed()); |
210 int max_error = 0; | 210 int max_error = 0; |
211 int total_error = 0; | 211 int total_error = 0; |
212 const int count_test_block = 100000; | 212 const int count_test_block = 100000; |
213 DECLARE_ALIGNED_ARRAY(16, int16_t, test_input_block, 64); | 213 DECLARE_ALIGNED(16, int16_t, test_input_block[64]); |
214 DECLARE_ALIGNED_ARRAY(16, tran_low_t, test_temp_block, 64); | 214 DECLARE_ALIGNED(16, tran_low_t, test_temp_block[64]); |
215 DECLARE_ALIGNED_ARRAY(16, uint8_t, dst, 64); | 215 DECLARE_ALIGNED(16, uint8_t, dst[64]); |
216 DECLARE_ALIGNED_ARRAY(16, uint8_t, src, 64); | 216 DECLARE_ALIGNED(16, uint8_t, src[64]); |
217 #if CONFIG_VP9_HIGHBITDEPTH | 217 #if CONFIG_VP9_HIGHBITDEPTH |
218 DECLARE_ALIGNED_ARRAY(16, uint16_t, dst16, 64); | 218 DECLARE_ALIGNED(16, uint16_t, dst16[64]); |
219 DECLARE_ALIGNED_ARRAY(16, uint16_t, src16, 64); | 219 DECLARE_ALIGNED(16, uint16_t, src16[64]); |
220 #endif | 220 #endif |
221 | 221 |
222 for (int i = 0; i < count_test_block; ++i) { | 222 for (int i = 0; i < count_test_block; ++i) { |
223 // Initialize a test block with input range [-mask_, mask_]. | 223 // Initialize a test block with input range [-mask_, mask_]. |
224 for (int j = 0; j < 64; ++j) { | 224 for (int j = 0; j < 64; ++j) { |
225 if (bit_depth_ == VPX_BITS_8) { | 225 if (bit_depth_ == VPX_BITS_8) { |
226 src[j] = rnd.Rand8(); | 226 src[j] = rnd.Rand8(); |
227 dst[j] = rnd.Rand8(); | 227 dst[j] = rnd.Rand8(); |
228 test_input_block[j] = src[j] - dst[j]; | 228 test_input_block[j] = src[j] - dst[j]; |
229 #if CONFIG_VP9_HIGHBITDEPTH | 229 #if CONFIG_VP9_HIGHBITDEPTH |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 << "Error: 8x8 FDCT/IDCT or FHT/IHT has average roundtrip " | 280 << "Error: 8x8 FDCT/IDCT or FHT/IHT has average roundtrip " |
281 << "error > 1/5 per block"; | 281 << "error > 1/5 per block"; |
282 } | 282 } |
283 | 283 |
284 void RunExtremalCheck() { | 284 void RunExtremalCheck() { |
285 ACMRandom rnd(ACMRandom::DeterministicSeed()); | 285 ACMRandom rnd(ACMRandom::DeterministicSeed()); |
286 int max_error = 0; | 286 int max_error = 0; |
287 int total_error = 0; | 287 int total_error = 0; |
288 int total_coeff_error = 0; | 288 int total_coeff_error = 0; |
289 const int count_test_block = 100000; | 289 const int count_test_block = 100000; |
290 DECLARE_ALIGNED_ARRAY(16, int16_t, test_input_block, 64); | 290 DECLARE_ALIGNED(16, int16_t, test_input_block[64]); |
291 DECLARE_ALIGNED_ARRAY(16, tran_low_t, test_temp_block, 64); | 291 DECLARE_ALIGNED(16, tran_low_t, test_temp_block[64]); |
292 DECLARE_ALIGNED_ARRAY(16, tran_low_t, ref_temp_block, 64); | 292 DECLARE_ALIGNED(16, tran_low_t, ref_temp_block[64]); |
293 DECLARE_ALIGNED_ARRAY(16, uint8_t, dst, 64); | 293 DECLARE_ALIGNED(16, uint8_t, dst[64]); |
294 DECLARE_ALIGNED_ARRAY(16, uint8_t, src, 64); | 294 DECLARE_ALIGNED(16, uint8_t, src[64]); |
295 #if CONFIG_VP9_HIGHBITDEPTH | 295 #if CONFIG_VP9_HIGHBITDEPTH |
296 DECLARE_ALIGNED_ARRAY(16, uint16_t, dst16, 64); | 296 DECLARE_ALIGNED(16, uint16_t, dst16[64]); |
297 DECLARE_ALIGNED_ARRAY(16, uint16_t, src16, 64); | 297 DECLARE_ALIGNED(16, uint16_t, src16[64]); |
298 #endif | 298 #endif |
299 | 299 |
300 for (int i = 0; i < count_test_block; ++i) { | 300 for (int i = 0; i < count_test_block; ++i) { |
301 // Initialize a test block with input range [-mask_, mask_]. | 301 // Initialize a test block with input range [-mask_, mask_]. |
302 for (int j = 0; j < 64; ++j) { | 302 for (int j = 0; j < 64; ++j) { |
303 if (bit_depth_ == VPX_BITS_8) { | 303 if (bit_depth_ == VPX_BITS_8) { |
304 if (i == 0) { | 304 if (i == 0) { |
305 src[j] = 255; | 305 src[j] = 255; |
306 dst[j] = 0; | 306 dst[j] = 0; |
307 } else if (i == 1) { | 307 } else if (i == 1) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 | 369 |
370 EXPECT_EQ(0, total_coeff_error) | 370 EXPECT_EQ(0, total_coeff_error) |
371 << "Error: Extremal 8x8 FDCT/FHT has" | 371 << "Error: Extremal 8x8 FDCT/FHT has" |
372 << "overflow issues in the intermediate steps > 1"; | 372 << "overflow issues in the intermediate steps > 1"; |
373 } | 373 } |
374 } | 374 } |
375 | 375 |
376 void RunInvAccuracyCheck() { | 376 void RunInvAccuracyCheck() { |
377 ACMRandom rnd(ACMRandom::DeterministicSeed()); | 377 ACMRandom rnd(ACMRandom::DeterministicSeed()); |
378 const int count_test_block = 1000; | 378 const int count_test_block = 1000; |
379 DECLARE_ALIGNED_ARRAY(16, int16_t, in, kNumCoeffs); | 379 DECLARE_ALIGNED(16, int16_t, in[kNumCoeffs]); |
380 DECLARE_ALIGNED_ARRAY(16, tran_low_t, coeff, kNumCoeffs); | 380 DECLARE_ALIGNED(16, tran_low_t, coeff[kNumCoeffs]); |
381 DECLARE_ALIGNED_ARRAY(16, uint8_t, dst, kNumCoeffs); | 381 DECLARE_ALIGNED(16, uint8_t, dst[kNumCoeffs]); |
382 DECLARE_ALIGNED_ARRAY(16, uint8_t, src, kNumCoeffs); | 382 DECLARE_ALIGNED(16, uint8_t, src[kNumCoeffs]); |
383 #if CONFIG_VP9_HIGHBITDEPTH | 383 #if CONFIG_VP9_HIGHBITDEPTH |
384 DECLARE_ALIGNED_ARRAY(16, uint16_t, src16, kNumCoeffs); | 384 DECLARE_ALIGNED(16, uint16_t, src16[kNumCoeffs]); |
385 DECLARE_ALIGNED_ARRAY(16, uint16_t, dst16, kNumCoeffs); | 385 DECLARE_ALIGNED(16, uint16_t, dst16[kNumCoeffs]); |
386 #endif | 386 #endif |
387 | 387 |
388 for (int i = 0; i < count_test_block; ++i) { | 388 for (int i = 0; i < count_test_block; ++i) { |
389 double out_r[kNumCoeffs]; | 389 double out_r[kNumCoeffs]; |
390 | 390 |
391 // Initialize a test block with input range [-255, 255]. | 391 // Initialize a test block with input range [-255, 255]. |
392 for (int j = 0; j < kNumCoeffs; ++j) { | 392 for (int j = 0; j < kNumCoeffs; ++j) { |
393 if (bit_depth_ == VPX_BITS_8) { | 393 if (bit_depth_ == VPX_BITS_8) { |
394 src[j] = rnd.Rand8() % 2 ? 255 : 0; | 394 src[j] = rnd.Rand8() % 2 ? 255 : 0; |
395 dst[j] = src[j] > 0 ? 0 : 255; | 395 dst[j] = src[j] > 0 ? 0 : 255; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 EXPECT_GE(1u << 2 * (bit_depth_ - 8), error) | 427 EXPECT_GE(1u << 2 * (bit_depth_ - 8), error) |
428 << "Error: 8x8 IDCT has error " << error | 428 << "Error: 8x8 IDCT has error " << error |
429 << " at index " << j; | 429 << " at index " << j; |
430 } | 430 } |
431 } | 431 } |
432 } | 432 } |
433 | 433 |
434 void RunFwdAccuracyCheck() { | 434 void RunFwdAccuracyCheck() { |
435 ACMRandom rnd(ACMRandom::DeterministicSeed()); | 435 ACMRandom rnd(ACMRandom::DeterministicSeed()); |
436 const int count_test_block = 1000; | 436 const int count_test_block = 1000; |
437 DECLARE_ALIGNED_ARRAY(16, int16_t, in, kNumCoeffs); | 437 DECLARE_ALIGNED(16, int16_t, in[kNumCoeffs]); |
438 DECLARE_ALIGNED_ARRAY(16, tran_low_t, coeff_r, kNumCoeffs); | 438 DECLARE_ALIGNED(16, tran_low_t, coeff_r[kNumCoeffs]); |
439 DECLARE_ALIGNED_ARRAY(16, tran_low_t, coeff, kNumCoeffs); | 439 DECLARE_ALIGNED(16, tran_low_t, coeff[kNumCoeffs]); |
440 | 440 |
441 for (int i = 0; i < count_test_block; ++i) { | 441 for (int i = 0; i < count_test_block; ++i) { |
442 double out_r[kNumCoeffs]; | 442 double out_r[kNumCoeffs]; |
443 | 443 |
444 // Initialize a test block with input range [-mask_, mask_]. | 444 // Initialize a test block with input range [-mask_, mask_]. |
445 for (int j = 0; j < kNumCoeffs; ++j) | 445 for (int j = 0; j < kNumCoeffs; ++j) |
446 in[j] = rnd.Rand8() % 2 == 0 ? mask_ : -mask_; | 446 in[j] = rnd.Rand8() % 2 == 0 ? mask_ : -mask_; |
447 | 447 |
448 RunFwdTxfm(in, coeff, pitch_); | 448 RunFwdTxfm(in, coeff, pitch_); |
449 reference_8x8_dct_2d(in, out_r); | 449 reference_8x8_dct_2d(in, out_r); |
450 for (int j = 0; j < kNumCoeffs; ++j) | 450 for (int j = 0; j < kNumCoeffs; ++j) |
451 coeff_r[j] = static_cast<tran_low_t>(round(out_r[j])); | 451 coeff_r[j] = static_cast<tran_low_t>(round(out_r[j])); |
452 | 452 |
453 for (int j = 0; j < kNumCoeffs; ++j) { | 453 for (int j = 0; j < kNumCoeffs; ++j) { |
454 const uint32_t diff = coeff[j] - coeff_r[j]; | 454 const uint32_t diff = coeff[j] - coeff_r[j]; |
455 const uint32_t error = diff * diff; | 455 const uint32_t error = diff * diff; |
456 EXPECT_GE(9u << 2 * (bit_depth_ - 8), error) | 456 EXPECT_GE(9u << 2 * (bit_depth_ - 8), error) |
457 << "Error: 8x8 DCT has error " << error | 457 << "Error: 8x8 DCT has error " << error |
458 << " at index " << j; | 458 << " at index " << j; |
459 } | 459 } |
460 } | 460 } |
461 } | 461 } |
462 | 462 |
463 void CompareInvReference(IdctFunc ref_txfm, int thresh) { | 463 void CompareInvReference(IdctFunc ref_txfm, int thresh) { |
464 ACMRandom rnd(ACMRandom::DeterministicSeed()); | 464 ACMRandom rnd(ACMRandom::DeterministicSeed()); |
465 const int count_test_block = 10000; | 465 const int count_test_block = 10000; |
466 const int eob = 12; | 466 const int eob = 12; |
467 DECLARE_ALIGNED_ARRAY(16, tran_low_t, coeff, kNumCoeffs); | 467 DECLARE_ALIGNED(16, tran_low_t, coeff[kNumCoeffs]); |
468 DECLARE_ALIGNED_ARRAY(16, uint8_t, dst, kNumCoeffs); | 468 DECLARE_ALIGNED(16, uint8_t, dst[kNumCoeffs]); |
469 DECLARE_ALIGNED_ARRAY(16, uint8_t, ref, kNumCoeffs); | 469 DECLARE_ALIGNED(16, uint8_t, ref[kNumCoeffs]); |
470 #if CONFIG_VP9_HIGHBITDEPTH | 470 #if CONFIG_VP9_HIGHBITDEPTH |
471 DECLARE_ALIGNED_ARRAY(16, uint16_t, dst16, kNumCoeffs); | 471 DECLARE_ALIGNED(16, uint16_t, dst16[kNumCoeffs]); |
472 DECLARE_ALIGNED_ARRAY(16, uint16_t, ref16, kNumCoeffs); | 472 DECLARE_ALIGNED(16, uint16_t, ref16[kNumCoeffs]); |
473 #endif | 473 #endif |
474 const int16_t *scan = vp9_default_scan_orders[TX_8X8].scan; | 474 const int16_t *scan = vp9_default_scan_orders[TX_8X8].scan; |
475 | 475 |
476 for (int i = 0; i < count_test_block; ++i) { | 476 for (int i = 0; i < count_test_block; ++i) { |
477 for (int j = 0; j < kNumCoeffs; ++j) { | 477 for (int j = 0; j < kNumCoeffs; ++j) { |
478 if (j < eob) { | 478 if (j < eob) { |
479 // Random values less than the threshold, either positive or negative | 479 // Random values less than the threshold, either positive or negative |
480 coeff[scan[j]] = rnd(thresh) * (1-2*(i%2)); | 480 coeff[scan[j]] = rnd(thresh) * (1-2*(i%2)); |
481 } else { | 481 } else { |
482 coeff[scan[j]] = 0; | 482 coeff[scan[j]] = 0; |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 !CONFIG_EMULATE_HARDWARE | 771 !CONFIG_EMULATE_HARDWARE |
772 // TODO(jingning): re-enable after this handles the expanded range [0, 65535] | 772 // TODO(jingning): re-enable after this handles the expanded range [0, 65535] |
773 // returned from Rand16(). | 773 // returned from Rand16(). |
774 INSTANTIATE_TEST_CASE_P( | 774 INSTANTIATE_TEST_CASE_P( |
775 SSSE3, FwdTrans8x8DCT, | 775 SSSE3, FwdTrans8x8DCT, |
776 ::testing::Values( | 776 ::testing::Values( |
777 make_tuple(&vp9_fdct8x8_ssse3, &vp9_idct8x8_64_add_ssse3, 0, | 777 make_tuple(&vp9_fdct8x8_ssse3, &vp9_idct8x8_64_add_ssse3, 0, |
778 VPX_BITS_8))); | 778 VPX_BITS_8))); |
779 #endif | 779 #endif |
780 } // namespace | 780 } // namespace |
OLD | NEW |