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 11 #include "third_party/googletest/src/include/gtest/gtest.h" 12 13 #include "./vpx_config.h" 14 #include "./vpx_scale_rtcd.h" 15 #include "test/clear_system_state.h" 16 #include "test/register_state_check.h" 17 #include "test/vpx_scale_test.h" 18 #include "vpx_mem/vpx_mem.h" 19 #include "vpx_ports/vpx_timer.h" 20 #include "vpx_scale/yv12config.h" 21 22 namespace libvpx_test { 23 24 typedef void (*ExtendFrameBorderFunc)(YV12_BUFFER_CONFIG *ybf); 25 typedef void (*CopyFrameFunc)(const YV12_BUFFER_CONFIG *src_ybf, 26 YV12_BUFFER_CONFIG *dst_ybf); 27 28 class ExtendBorderTest 29 : public VpxScaleBase, 30 public ::testing::TestWithParam<ExtendFrameBorderFunc> { 31 public: 32 virtual ~ExtendBorderTest() {} 33 34 protected: 35 virtual void SetUp() { extend_fn_ = GetParam(); } 36 37 void ExtendBorder() { ASM_REGISTER_STATE_CHECK(extend_fn_(&img_)); } 38 39 void RunTest() { 40 #if ARCH_ARM 41 // Some arm devices OOM when trying to allocate the largest buffers. 42 static const int kNumSizesToTest = 6; 43 #else 44 static const int kNumSizesToTest = 7; 45 #endif 46 static const int kSizesToTest[] = { 1, 15, 33, 145, 512, 1025, 16383 }; 47 for (int h = 0; h < kNumSizesToTest; ++h) { 48 for (int w = 0; w < kNumSizesToTest; ++w) { 49 ASSERT_NO_FATAL_FAILURE(ResetImages(kSizesToTest[w], kSizesToTest[h])); 50 ReferenceCopyFrame(); 51 ExtendBorder(); 52 CompareImages(img_); 53 DeallocImages(); 54 } 55 } 56 } 57 58 ExtendFrameBorderFunc extend_fn_; 59 }; 60 61 TEST_P(ExtendBorderTest, ExtendBorder) { ASSERT_NO_FATAL_FAILURE(RunTest()); } 62 63 INSTANTIATE_TEST_CASE_P(C, ExtendBorderTest, 64 ::testing::Values(vp8_yv12_extend_frame_borders_c)); 65 66 class CopyFrameTest : public VpxScaleBase, 67 public ::testing::TestWithParam<CopyFrameFunc> { 68 public: 69 virtual ~CopyFrameTest() {} 70 71 protected: 72 virtual void SetUp() { copy_frame_fn_ = GetParam(); } 73 74 void CopyFrame() { 75 ASM_REGISTER_STATE_CHECK(copy_frame_fn_(&img_, &dst_img_)); 76 } 77 78 void RunTest() { 79 #if ARCH_ARM 80 // Some arm devices OOM when trying to allocate the largest buffers. 81 static const int kNumSizesToTest = 6; 82 #else 83 static const int kNumSizesToTest = 7; 84 #endif 85 static const int kSizesToTest[] = { 1, 15, 33, 145, 512, 1025, 16383 }; 86 for (int h = 0; h < kNumSizesToTest; ++h) { 87 for (int w = 0; w < kNumSizesToTest; ++w) { 88 ASSERT_NO_FATAL_FAILURE(ResetImages(kSizesToTest[w], kSizesToTest[h])); 89 ReferenceCopyFrame(); 90 CopyFrame(); 91 CompareImages(dst_img_); 92 DeallocImages(); 93 } 94 } 95 } 96 97 CopyFrameFunc copy_frame_fn_; 98 }; 99 100 TEST_P(CopyFrameTest, CopyFrame) { ASSERT_NO_FATAL_FAILURE(RunTest()); } 101 102 INSTANTIATE_TEST_CASE_P(C, CopyFrameTest, 103 ::testing::Values(vp8_yv12_copy_frame_c)); 104 105 } // namespace libvpx_test 106