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 #include <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 const int half = block_size_ / 2; | 207 const int half = block_size_ / 2; |
208 memset(ref_, 255, half); | 208 memset(ref_, 255, half); |
209 memset(ref_ + half, 0, half); | 209 memset(ref_ + half, 0, half); |
210 unsigned int sse; | 210 unsigned int sse; |
211 unsigned int var; | 211 unsigned int var; |
212 ASM_REGISTER_STATE_CHECK(var = variance_(src_, width_, ref_, width_, &sse)); | 212 ASM_REGISTER_STATE_CHECK(var = variance_(src_, width_, ref_, width_, &sse)); |
213 const unsigned int expected = block_size_ * 255 * 255 / 4; | 213 const unsigned int expected = block_size_ * 255 * 255 / 4; |
214 EXPECT_EQ(expected, var); | 214 EXPECT_EQ(expected, var); |
215 } | 215 } |
216 | 216 |
| 217 #if CONFIG_VP8_ENCODER |
| 218 template<typename MseFunctionType> |
| 219 class MseTest |
| 220 : public ::testing::TestWithParam<tuple<int, int, MseFunctionType> > { |
| 221 public: |
| 222 virtual void SetUp() { |
| 223 const tuple<int, int, MseFunctionType>& params = this->GetParam(); |
| 224 log2width_ = get<0>(params); |
| 225 width_ = 1 << log2width_; |
| 226 log2height_ = get<1>(params); |
| 227 height_ = 1 << log2height_; |
| 228 mse_ = get<2>(params); |
| 229 |
| 230 rnd(ACMRandom::DeterministicSeed()); |
| 231 block_size_ = width_ * height_; |
| 232 src_ = reinterpret_cast<uint8_t *>(vpx_memalign(16, block_size_)); |
| 233 ref_ = new uint8_t[block_size_]; |
| 234 ASSERT_TRUE(src_ != NULL); |
| 235 ASSERT_TRUE(ref_ != NULL); |
| 236 } |
| 237 |
| 238 virtual void TearDown() { |
| 239 vpx_free(src_); |
| 240 delete[] ref_; |
| 241 libvpx_test::ClearSystemState(); |
| 242 } |
| 243 |
| 244 protected: |
| 245 void RefTest_mse(); |
| 246 void RefTest_sse(); |
| 247 void MaxTest_mse(); |
| 248 void MaxTest_sse(); |
| 249 |
| 250 ACMRandom rnd; |
| 251 uint8_t* src_; |
| 252 uint8_t* ref_; |
| 253 int width_, log2width_; |
| 254 int height_, log2height_; |
| 255 int block_size_; |
| 256 MseFunctionType mse_; |
| 257 }; |
| 258 |
| 259 template<typename MseFunctionType> |
| 260 void MseTest<MseFunctionType>::RefTest_mse() { |
| 261 for (int i = 0; i < 10; ++i) { |
| 262 for (int j = 0; j < block_size_; j++) { |
| 263 src_[j] = rnd.Rand8(); |
| 264 ref_[j] = rnd.Rand8(); |
| 265 } |
| 266 unsigned int sse1, sse2; |
| 267 ASM_REGISTER_STATE_CHECK(mse_(src_, width_, ref_, width_, &sse1)); |
| 268 variance_ref(src_, ref_, log2width_, log2height_, &sse2); |
| 269 EXPECT_EQ(sse1, sse2); |
| 270 } |
| 271 } |
| 272 |
| 273 template<typename MseFunctionType> |
| 274 void MseTest<MseFunctionType>::RefTest_sse() { |
| 275 for (int i = 0; i < 10; ++i) { |
| 276 for (int j = 0; j < block_size_; j++) { |
| 277 src_[j] = rnd.Rand8(); |
| 278 ref_[j] = rnd.Rand8(); |
| 279 } |
| 280 unsigned int sse2; |
| 281 unsigned int var1; |
| 282 ASM_REGISTER_STATE_CHECK( |
| 283 var1 = mse_(src_, width_, ref_, width_)); |
| 284 variance_ref(src_, ref_, log2width_, log2height_, &sse2); |
| 285 EXPECT_EQ(var1, sse2); |
| 286 } |
| 287 } |
| 288 |
| 289 template<typename MseFunctionType> |
| 290 void MseTest<MseFunctionType>::MaxTest_mse() { |
| 291 memset(src_, 255, block_size_); |
| 292 memset(ref_, 0, block_size_); |
| 293 unsigned int sse; |
| 294 ASM_REGISTER_STATE_CHECK(mse_(src_, width_, ref_, width_, &sse)); |
| 295 const unsigned int expected = block_size_ * 255 * 255; |
| 296 EXPECT_EQ(expected, sse); |
| 297 } |
| 298 |
| 299 template<typename MseFunctionType> |
| 300 void MseTest<MseFunctionType>::MaxTest_sse() { |
| 301 memset(src_, 255, block_size_); |
| 302 memset(ref_, 0, block_size_); |
| 303 unsigned int var; |
| 304 ASM_REGISTER_STATE_CHECK(var = mse_(src_, width_, ref_, width_)); |
| 305 const unsigned int expected = block_size_ * 255 * 255; |
| 306 EXPECT_EQ(expected, var); |
| 307 } |
| 308 #endif |
| 309 |
217 #if CONFIG_VP9_ENCODER | 310 #if CONFIG_VP9_ENCODER |
218 | 311 |
219 unsigned int subpel_avg_variance_ref(const uint8_t *ref, | 312 unsigned int subpel_avg_variance_ref(const uint8_t *ref, |
220 const uint8_t *src, | 313 const uint8_t *src, |
221 const uint8_t *second_pred, | 314 const uint8_t *second_pred, |
222 int l2w, int l2h, | 315 int l2w, int l2h, |
223 int xoff, int yoff, | 316 int xoff, int yoff, |
224 unsigned int *sse_ptr) { | 317 unsigned int *sse_ptr) { |
225 int se = 0; | 318 int se = 0; |
226 unsigned int sse = 0; | 319 unsigned int sse = 0; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 } | 429 } |
337 | 430 |
338 #endif // CONFIG_VP9_ENCODER | 431 #endif // CONFIG_VP9_ENCODER |
339 | 432 |
340 // ----------------------------------------------------------------------------- | 433 // ----------------------------------------------------------------------------- |
341 // VP8 test cases. | 434 // VP8 test cases. |
342 | 435 |
343 namespace vp8 { | 436 namespace vp8 { |
344 | 437 |
345 #if CONFIG_VP8_ENCODER | 438 #if CONFIG_VP8_ENCODER |
| 439 typedef unsigned int (*vp8_sse_fn_t)(const unsigned char *src_ptr, |
| 440 int source_stride, const unsigned char *ref_ptr, int ref_stride); |
| 441 |
| 442 typedef MseTest<vp8_sse_fn_t> VP8SseTest; |
| 443 typedef MseTest<vp8_variance_fn_t> VP8MseTest; |
346 typedef VarianceTest<vp8_variance_fn_t> VP8VarianceTest; | 444 typedef VarianceTest<vp8_variance_fn_t> VP8VarianceTest; |
347 | 445 |
| 446 TEST_P(VP8SseTest, Ref_sse) { RefTest_sse(); } |
| 447 TEST_P(VP8SseTest, Max_sse) { MaxTest_sse(); } |
| 448 TEST_P(VP8MseTest, Ref_mse) { RefTest_mse(); } |
| 449 TEST_P(VP8MseTest, Max_mse) { MaxTest_mse(); } |
348 TEST_P(VP8VarianceTest, Zero) { ZeroTest(); } | 450 TEST_P(VP8VarianceTest, Zero) { ZeroTest(); } |
349 TEST_P(VP8VarianceTest, Ref) { RefTest(); } | 451 TEST_P(VP8VarianceTest, Ref) { RefTest(); } |
350 TEST_P(VP8VarianceTest, OneQuarter) { OneQuarterTest(); } | 452 TEST_P(VP8VarianceTest, OneQuarter) { OneQuarterTest(); } |
351 | 453 |
| 454 const vp8_sse_fn_t get4x4sse_cs_c = vp8_get4x4sse_cs_c; |
| 455 INSTANTIATE_TEST_CASE_P( |
| 456 C, VP8SseTest, |
| 457 ::testing::Values(make_tuple(2, 2, get4x4sse_cs_c))); |
| 458 |
| 459 const vp8_variance_fn_t mse16x16_c = vp8_mse16x16_c; |
| 460 INSTANTIATE_TEST_CASE_P( |
| 461 C, VP8MseTest, |
| 462 ::testing::Values(make_tuple(4, 4, mse16x16_c))); |
| 463 |
352 const vp8_variance_fn_t variance4x4_c = vp8_variance4x4_c; | 464 const vp8_variance_fn_t variance4x4_c = vp8_variance4x4_c; |
353 const vp8_variance_fn_t variance8x8_c = vp8_variance8x8_c; | 465 const vp8_variance_fn_t variance8x8_c = vp8_variance8x8_c; |
354 const vp8_variance_fn_t variance8x16_c = vp8_variance8x16_c; | 466 const vp8_variance_fn_t variance8x16_c = vp8_variance8x16_c; |
355 const vp8_variance_fn_t variance16x8_c = vp8_variance16x8_c; | 467 const vp8_variance_fn_t variance16x8_c = vp8_variance16x8_c; |
356 const vp8_variance_fn_t variance16x16_c = vp8_variance16x16_c; | 468 const vp8_variance_fn_t variance16x16_c = vp8_variance16x16_c; |
357 INSTANTIATE_TEST_CASE_P( | 469 INSTANTIATE_TEST_CASE_P( |
358 C, VP8VarianceTest, | 470 C, VP8VarianceTest, |
359 ::testing::Values(make_tuple(2, 2, variance4x4_c), | 471 ::testing::Values(make_tuple(2, 2, variance4x4_c), |
360 make_tuple(3, 3, variance8x8_c), | 472 make_tuple(3, 3, variance8x8_c), |
361 make_tuple(3, 4, variance8x16_c), | 473 make_tuple(3, 4, variance8x16_c), |
362 make_tuple(4, 3, variance16x8_c), | 474 make_tuple(4, 3, variance16x8_c), |
363 make_tuple(4, 4, variance16x16_c))); | 475 make_tuple(4, 4, variance16x16_c))); |
364 | 476 |
365 #if HAVE_NEON | 477 #if HAVE_NEON |
| 478 const vp8_sse_fn_t get4x4sse_cs_neon = vp8_get4x4sse_cs_neon; |
| 479 INSTANTIATE_TEST_CASE_P( |
| 480 NEON, VP8SseTest, |
| 481 ::testing::Values(make_tuple(2, 2, get4x4sse_cs_neon))); |
| 482 |
| 483 const vp8_variance_fn_t mse16x16_neon = vp8_mse16x16_neon; |
| 484 INSTANTIATE_TEST_CASE_P( |
| 485 NEON, VP8MseTest, |
| 486 ::testing::Values(make_tuple(4, 4, mse16x16_neon))); |
| 487 |
366 const vp8_variance_fn_t variance8x8_neon = vp8_variance8x8_neon; | 488 const vp8_variance_fn_t variance8x8_neon = vp8_variance8x8_neon; |
367 const vp8_variance_fn_t variance8x16_neon = vp8_variance8x16_neon; | 489 const vp8_variance_fn_t variance8x16_neon = vp8_variance8x16_neon; |
368 const vp8_variance_fn_t variance16x8_neon = vp8_variance16x8_neon; | 490 const vp8_variance_fn_t variance16x8_neon = vp8_variance16x8_neon; |
369 const vp8_variance_fn_t variance16x16_neon = vp8_variance16x16_neon; | 491 const vp8_variance_fn_t variance16x16_neon = vp8_variance16x16_neon; |
370 INSTANTIATE_TEST_CASE_P( | 492 INSTANTIATE_TEST_CASE_P( |
371 NEON, VP8VarianceTest, | 493 NEON, VP8VarianceTest, |
372 ::testing::Values(make_tuple(3, 3, variance8x8_neon), | 494 ::testing::Values(make_tuple(3, 3, variance8x8_neon), |
373 make_tuple(3, 4, variance8x16_neon), | 495 make_tuple(3, 4, variance8x16_neon), |
374 make_tuple(4, 3, variance16x8_neon), | 496 make_tuple(4, 3, variance16x8_neon), |
375 make_tuple(4, 4, variance16x16_neon))); | 497 make_tuple(4, 4, variance16x16_neon))); |
376 #endif | 498 #endif |
377 | 499 |
| 500 |
378 #if HAVE_MMX | 501 #if HAVE_MMX |
379 const vp8_variance_fn_t variance4x4_mmx = vp8_variance4x4_mmx; | 502 const vp8_variance_fn_t variance4x4_mmx = vp8_variance4x4_mmx; |
380 const vp8_variance_fn_t variance8x8_mmx = vp8_variance8x8_mmx; | 503 const vp8_variance_fn_t variance8x8_mmx = vp8_variance8x8_mmx; |
381 const vp8_variance_fn_t variance8x16_mmx = vp8_variance8x16_mmx; | 504 const vp8_variance_fn_t variance8x16_mmx = vp8_variance8x16_mmx; |
382 const vp8_variance_fn_t variance16x8_mmx = vp8_variance16x8_mmx; | 505 const vp8_variance_fn_t variance16x8_mmx = vp8_variance16x8_mmx; |
383 const vp8_variance_fn_t variance16x16_mmx = vp8_variance16x16_mmx; | 506 const vp8_variance_fn_t variance16x16_mmx = vp8_variance16x16_mmx; |
384 INSTANTIATE_TEST_CASE_P( | 507 INSTANTIATE_TEST_CASE_P( |
385 MMX, VP8VarianceTest, | 508 MMX, VP8VarianceTest, |
386 ::testing::Values(make_tuple(2, 2, variance4x4_mmx), | 509 ::testing::Values(make_tuple(2, 2, variance4x4_mmx), |
387 make_tuple(3, 3, variance8x8_mmx), | 510 make_tuple(3, 3, variance8x8_mmx), |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 NEON, VP9SubpelVarianceTest, | 930 NEON, VP9SubpelVarianceTest, |
808 ::testing::Values(make_tuple(3, 3, subpel_variance8x8_neon), | 931 ::testing::Values(make_tuple(3, 3, subpel_variance8x8_neon), |
809 make_tuple(4, 4, subpel_variance16x16_neon), | 932 make_tuple(4, 4, subpel_variance16x16_neon), |
810 make_tuple(5, 5, subpel_variance32x32_neon))); | 933 make_tuple(5, 5, subpel_variance32x32_neon))); |
811 #endif // HAVE_NEON | 934 #endif // HAVE_NEON |
812 #endif // CONFIG_VP9_ENCODER | 935 #endif // CONFIG_VP9_ENCODER |
813 | 936 |
814 } // namespace vp9 | 937 } // namespace vp9 |
815 | 938 |
816 } // namespace | 939 } // namespace |
OLD | NEW |