vp9[loongarch]: Optimize fdct4x4/8x8_lsx
[platform/upstream/libvpx.git] / test / alt_ref_aq_segment_test.cc
1 /*
2  *  Copyright (c) 2012 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 "test/codec_factory.h"
12 #include "test/encode_test_driver.h"
13 #include "test/i420_video_source.h"
14 #include "test/util.h"
15
16 namespace {
17
18 class AltRefAqSegmentTest
19     : public ::libvpx_test::EncoderTest,
20       public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> {
21  protected:
22   AltRefAqSegmentTest() : EncoderTest(GET_PARAM(0)) {}
23   virtual ~AltRefAqSegmentTest() {}
24
25   virtual void SetUp() {
26     InitializeConfig();
27     SetMode(GET_PARAM(1));
28     set_cpu_used_ = GET_PARAM(2);
29     aq_mode_ = 0;
30     alt_ref_aq_mode_ = 0;
31   }
32
33   virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
34                                   ::libvpx_test::Encoder *encoder) {
35     if (video->frame() == 0) {
36       encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
37       encoder->Control(VP9E_SET_ALT_REF_AQ, alt_ref_aq_mode_);
38       encoder->Control(VP9E_SET_AQ_MODE, aq_mode_);
39       encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 100);
40     }
41   }
42
43   int set_cpu_used_;
44   int aq_mode_;
45   int alt_ref_aq_mode_;
46 };
47
48 // Validate that this ALT_REF_AQ/AQ segmentation mode
49 // (ALT_REF_AQ=0, AQ=0/no_aq)
50 // encodes and decodes without a mismatch.
51 TEST_P(AltRefAqSegmentTest, TestNoMisMatchAltRefAQ0) {
52   cfg_.rc_min_quantizer = 8;
53   cfg_.rc_max_quantizer = 56;
54   cfg_.rc_end_usage = VPX_VBR;
55   cfg_.rc_buf_initial_sz = 500;
56   cfg_.rc_buf_optimal_sz = 500;
57   cfg_.rc_buf_sz = 1000;
58   cfg_.rc_target_bitrate = 300;
59
60   aq_mode_ = 0;
61   alt_ref_aq_mode_ = 1;
62
63   ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
64                                        30, 1, 0, 100);
65
66   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
67 }
68
69 // Validate that this ALT_REF_AQ/AQ segmentation mode
70 // (ALT_REF_AQ=0, AQ=1/variance_aq)
71 // encodes and decodes without a mismatch.
72 TEST_P(AltRefAqSegmentTest, TestNoMisMatchAltRefAQ1) {
73   cfg_.rc_min_quantizer = 8;
74   cfg_.rc_max_quantizer = 56;
75   cfg_.rc_end_usage = VPX_VBR;
76   cfg_.rc_buf_initial_sz = 500;
77   cfg_.rc_buf_optimal_sz = 500;
78   cfg_.rc_buf_sz = 1000;
79   cfg_.rc_target_bitrate = 300;
80
81   aq_mode_ = 1;
82   alt_ref_aq_mode_ = 1;
83
84   ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
85                                        30, 1, 0, 100);
86
87   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
88 }
89
90 // Validate that this ALT_REF_AQ/AQ segmentation mode
91 // (ALT_REF_AQ=0, AQ=2/complexity_aq)
92 // encodes and decodes without a mismatch.
93 TEST_P(AltRefAqSegmentTest, TestNoMisMatchAltRefAQ2) {
94   cfg_.rc_min_quantizer = 8;
95   cfg_.rc_max_quantizer = 56;
96   cfg_.rc_end_usage = VPX_VBR;
97   cfg_.rc_buf_initial_sz = 500;
98   cfg_.rc_buf_optimal_sz = 500;
99   cfg_.rc_buf_sz = 1000;
100   cfg_.rc_target_bitrate = 300;
101
102   aq_mode_ = 2;
103   alt_ref_aq_mode_ = 1;
104
105   ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
106                                        30, 1, 0, 100);
107
108   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
109 }
110
111 // Validate that this ALT_REF_AQ/AQ segmentation mode
112 // (ALT_REF_AQ=0, AQ=3/cyclicrefresh_aq)
113 // encodes and decodes without a mismatch.
114 TEST_P(AltRefAqSegmentTest, TestNoMisMatchAltRefAQ3) {
115   cfg_.rc_min_quantizer = 8;
116   cfg_.rc_max_quantizer = 56;
117   cfg_.rc_end_usage = VPX_VBR;
118   cfg_.rc_buf_initial_sz = 500;
119   cfg_.rc_buf_optimal_sz = 500;
120   cfg_.rc_buf_sz = 1000;
121   cfg_.rc_target_bitrate = 300;
122
123   aq_mode_ = 3;
124   alt_ref_aq_mode_ = 1;
125
126   ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
127                                        30, 1, 0, 100);
128
129   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
130 }
131
132 // Validate that this ALT_REF_AQ/AQ segmentation mode
133 // (ALT_REF_AQ=0, AQ=4/equator360_aq)
134 // encodes and decodes without a mismatch.
135 TEST_P(AltRefAqSegmentTest, TestNoMisMatchAltRefAQ4) {
136   cfg_.rc_min_quantizer = 8;
137   cfg_.rc_max_quantizer = 56;
138   cfg_.rc_end_usage = VPX_VBR;
139   cfg_.rc_buf_initial_sz = 500;
140   cfg_.rc_buf_optimal_sz = 500;
141   cfg_.rc_buf_sz = 1000;
142   cfg_.rc_target_bitrate = 300;
143
144   aq_mode_ = 4;
145   alt_ref_aq_mode_ = 1;
146
147   ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
148                                        30, 1, 0, 100);
149
150   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
151 }
152
153 VP9_INSTANTIATE_TEST_SUITE(AltRefAqSegmentTest,
154                            ::testing::Values(::libvpx_test::kOnePassGood,
155                                              ::libvpx_test::kTwoPassGood),
156                            ::testing::Range(2, 5));
157 }  // namespace