vp9[loongarch]: Optimize fdct4x4/8x8_lsx
[platform/upstream/libvpx.git] / test / vpx_scale_test.cc
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 namespace {
24
25 #if VPX_ARCH_ARM || (VPX_ARCH_MIPS && !HAVE_MIPS64) || VPX_ARCH_X86
26 // Avoid OOM failures on 32-bit platforms.
27 const int kNumSizesToTest = 7;
28 #else
29 const int kNumSizesToTest = 8;
30 #endif
31 const int kSizesToTest[] = { 1, 15, 33, 145, 512, 1025, 3840, 16383 };
32
33 typedef void (*ExtendFrameBorderFunc)(YV12_BUFFER_CONFIG *ybf);
34 typedef void (*CopyFrameFunc)(const YV12_BUFFER_CONFIG *src_ybf,
35                               YV12_BUFFER_CONFIG *dst_ybf);
36
37 class ExtendBorderTest
38     : public VpxScaleBase,
39       public ::testing::TestWithParam<ExtendFrameBorderFunc> {
40  public:
41   virtual ~ExtendBorderTest() {}
42
43  protected:
44   virtual void SetUp() { extend_fn_ = GetParam(); }
45
46   void ExtendBorder() { ASM_REGISTER_STATE_CHECK(extend_fn_(&img_)); }
47
48   void RunTest() {
49     for (int h = 0; h < kNumSizesToTest; ++h) {
50       for (int w = 0; w < kNumSizesToTest; ++w) {
51         ASSERT_NO_FATAL_FAILURE(ResetImages(kSizesToTest[w], kSizesToTest[h]));
52         ReferenceCopyFrame();
53         ExtendBorder();
54         CompareImages(img_);
55         DeallocImages();
56       }
57     }
58   }
59
60   ExtendFrameBorderFunc extend_fn_;
61 };
62
63 TEST_P(ExtendBorderTest, ExtendBorder) { ASSERT_NO_FATAL_FAILURE(RunTest()); }
64
65 INSTANTIATE_TEST_SUITE_P(C, ExtendBorderTest,
66                          ::testing::Values(vp8_yv12_extend_frame_borders_c));
67
68 class CopyFrameTest : public VpxScaleBase,
69                       public ::testing::TestWithParam<CopyFrameFunc> {
70  public:
71   virtual ~CopyFrameTest() {}
72
73  protected:
74   virtual void SetUp() { copy_frame_fn_ = GetParam(); }
75
76   void CopyFrame() {
77     ASM_REGISTER_STATE_CHECK(copy_frame_fn_(&img_, &dst_img_));
78   }
79
80   void RunTest() {
81     for (int h = 0; h < kNumSizesToTest; ++h) {
82       for (int w = 0; w < kNumSizesToTest; ++w) {
83         ASSERT_NO_FATAL_FAILURE(ResetImages(kSizesToTest[w], kSizesToTest[h]));
84         ReferenceCopyFrame();
85         CopyFrame();
86         CompareImages(dst_img_);
87         DeallocImages();
88       }
89     }
90   }
91
92   CopyFrameFunc copy_frame_fn_;
93 };
94
95 TEST_P(CopyFrameTest, CopyFrame) { ASSERT_NO_FATAL_FAILURE(RunTest()); }
96
97 INSTANTIATE_TEST_SUITE_P(C, CopyFrameTest,
98                          ::testing::Values(vp8_yv12_copy_frame_c));
99
100 }  // namespace
101 }  // namespace libvpx_test