vpx_scale_test.cc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
  3. *
  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.
  9. */
  10. #include "third_party/googletest/src/include/gtest/gtest.h"
  11. #include "./vpx_config.h"
  12. #include "./vpx_scale_rtcd.h"
  13. #include "test/clear_system_state.h"
  14. #include "test/register_state_check.h"
  15. #include "test/vpx_scale_test.h"
  16. #include "vpx_mem/vpx_mem.h"
  17. #include "vpx_ports/vpx_timer.h"
  18. #include "vpx_scale/yv12config.h"
  19. namespace libvpx_test {
  20. namespace {
  21. #if ARCH_ARM || (ARCH_MIPS && !HAVE_MIPS64) || ARCH_X86
  22. // Avoid OOM failures on 32-bit platforms.
  23. const int kNumSizesToTest = 7;
  24. #else
  25. const int kNumSizesToTest = 8;
  26. #endif
  27. const int kSizesToTest[] = { 1, 15, 33, 145, 512, 1025, 3840, 16383 };
  28. typedef void (*ExtendFrameBorderFunc)(YV12_BUFFER_CONFIG *ybf);
  29. typedef void (*CopyFrameFunc)(const YV12_BUFFER_CONFIG *src_ybf,
  30. YV12_BUFFER_CONFIG *dst_ybf);
  31. class ExtendBorderTest
  32. : public VpxScaleBase,
  33. public ::testing::TestWithParam<ExtendFrameBorderFunc> {
  34. public:
  35. virtual ~ExtendBorderTest() {}
  36. protected:
  37. virtual void SetUp() { extend_fn_ = GetParam(); }
  38. void ExtendBorder() { ASM_REGISTER_STATE_CHECK(extend_fn_(&img_)); }
  39. void RunTest() {
  40. for (int h = 0; h < kNumSizesToTest; ++h) {
  41. for (int w = 0; w < kNumSizesToTest; ++w) {
  42. ASSERT_NO_FATAL_FAILURE(ResetImages(kSizesToTest[w], kSizesToTest[h]));
  43. ReferenceCopyFrame();
  44. ExtendBorder();
  45. CompareImages(img_);
  46. DeallocImages();
  47. }
  48. }
  49. }
  50. ExtendFrameBorderFunc extend_fn_;
  51. };
  52. TEST_P(ExtendBorderTest, ExtendBorder) { ASSERT_NO_FATAL_FAILURE(RunTest()); }
  53. INSTANTIATE_TEST_CASE_P(C, ExtendBorderTest,
  54. ::testing::Values(vp8_yv12_extend_frame_borders_c));
  55. class CopyFrameTest : public VpxScaleBase,
  56. public ::testing::TestWithParam<CopyFrameFunc> {
  57. public:
  58. virtual ~CopyFrameTest() {}
  59. protected:
  60. virtual void SetUp() { copy_frame_fn_ = GetParam(); }
  61. void CopyFrame() {
  62. ASM_REGISTER_STATE_CHECK(copy_frame_fn_(&img_, &dst_img_));
  63. }
  64. void RunTest() {
  65. for (int h = 0; h < kNumSizesToTest; ++h) {
  66. for (int w = 0; w < kNumSizesToTest; ++w) {
  67. ASSERT_NO_FATAL_FAILURE(ResetImages(kSizesToTest[w], kSizesToTest[h]));
  68. ReferenceCopyFrame();
  69. CopyFrame();
  70. CompareImages(dst_img_);
  71. DeallocImages();
  72. }
  73. }
  74. }
  75. CopyFrameFunc copy_frame_fn_;
  76. };
  77. TEST_P(CopyFrameTest, CopyFrame) { ASSERT_NO_FATAL_FAILURE(RunTest()); }
  78. INSTANTIATE_TEST_CASE_P(C, CopyFrameTest,
  79. ::testing::Values(vp8_yv12_copy_frame_c));
  80. } // namespace
  81. } // namespace libvpx_test