vpx_scale_test.cc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. typedef void (*ExtendFrameBorderFunc)(YV12_BUFFER_CONFIG *ybf);
  21. typedef void (*CopyFrameFunc)(const YV12_BUFFER_CONFIG *src_ybf,
  22. YV12_BUFFER_CONFIG *dst_ybf);
  23. class ExtendBorderTest
  24. : public VpxScaleBase,
  25. public ::testing::TestWithParam<ExtendFrameBorderFunc> {
  26. public:
  27. virtual ~ExtendBorderTest() {}
  28. protected:
  29. virtual void SetUp() { extend_fn_ = GetParam(); }
  30. void ExtendBorder() { ASM_REGISTER_STATE_CHECK(extend_fn_(&img_)); }
  31. void RunTest() {
  32. #if ARCH_ARM
  33. // Some arm devices OOM when trying to allocate the largest buffers.
  34. static const int kNumSizesToTest = 6;
  35. #else
  36. static const int kNumSizesToTest = 7;
  37. #endif
  38. static const int kSizesToTest[] = { 1, 15, 33, 145, 512, 1025, 16383 };
  39. for (int h = 0; h < kNumSizesToTest; ++h) {
  40. for (int w = 0; w < kNumSizesToTest; ++w) {
  41. ASSERT_NO_FATAL_FAILURE(ResetImages(kSizesToTest[w], kSizesToTest[h]));
  42. ReferenceCopyFrame();
  43. ExtendBorder();
  44. CompareImages(img_);
  45. DeallocImages();
  46. }
  47. }
  48. }
  49. ExtendFrameBorderFunc extend_fn_;
  50. };
  51. TEST_P(ExtendBorderTest, ExtendBorder) { ASSERT_NO_FATAL_FAILURE(RunTest()); }
  52. INSTANTIATE_TEST_CASE_P(C, ExtendBorderTest,
  53. ::testing::Values(vp8_yv12_extend_frame_borders_c));
  54. class CopyFrameTest : public VpxScaleBase,
  55. public ::testing::TestWithParam<CopyFrameFunc> {
  56. public:
  57. virtual ~CopyFrameTest() {}
  58. protected:
  59. virtual void SetUp() { copy_frame_fn_ = GetParam(); }
  60. void CopyFrame() {
  61. ASM_REGISTER_STATE_CHECK(copy_frame_fn_(&img_, &dst_img_));
  62. }
  63. void RunTest() {
  64. #if ARCH_ARM
  65. // Some arm devices OOM when trying to allocate the largest buffers.
  66. static const int kNumSizesToTest = 6;
  67. #else
  68. static const int kNumSizesToTest = 7;
  69. #endif
  70. static const int kSizesToTest[] = { 1, 15, 33, 145, 512, 1025, 16383 };
  71. for (int h = 0; h < kNumSizesToTest; ++h) {
  72. for (int w = 0; w < kNumSizesToTest; ++w) {
  73. ASSERT_NO_FATAL_FAILURE(ResetImages(kSizesToTest[w], kSizesToTest[h]));
  74. ReferenceCopyFrame();
  75. CopyFrame();
  76. CompareImages(dst_img_);
  77. DeallocImages();
  78. }
  79. }
  80. }
  81. CopyFrameFunc copy_frame_fn_;
  82. };
  83. TEST_P(CopyFrameTest, CopyFrame) { ASSERT_NO_FATAL_FAILURE(RunTest()); }
  84. INSTANTIATE_TEST_CASE_P(C, CopyFrameTest,
  85. ::testing::Values(vp8_yv12_copy_frame_c));
  86. } // namespace libvpx_test