xref: /aosp_15_r20/external/libaom/test/borders_test.cc (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
1 /*
2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 
12 #include <climits>
13 #include <vector>
14 #include "gtest/gtest.h"
15 #include "test/codec_factory.h"
16 #include "test/encode_test_driver.h"
17 #include "test/i420_video_source.h"
18 #include "test/util.h"
19 
20 namespace {
21 
22 class BordersTestLarge
23     : public ::libaom_test::CodecTestWithParam<libaom_test::TestMode>,
24       public ::libaom_test::EncoderTest {
25  protected:
BordersTestLarge()26   BordersTestLarge() : EncoderTest(GET_PARAM(0)) {}
27   ~BordersTestLarge() override = default;
28 
SetUp()29   void SetUp() override { InitializeConfig(GET_PARAM(1)); }
30 
PreEncodeFrameHook(::libaom_test::VideoSource * video,::libaom_test::Encoder * encoder)31   void PreEncodeFrameHook(::libaom_test::VideoSource *video,
32                           ::libaom_test::Encoder *encoder) override {
33     if (video->frame() == 0) {
34       encoder->Control(AOME_SET_CPUUSED, 1);
35       encoder->Control(AOME_SET_ENABLEAUTOALTREF, 1);
36       encoder->Control(AOME_SET_ARNR_MAXFRAMES, 7);
37       encoder->Control(AOME_SET_ARNR_STRENGTH, 5);
38     }
39   }
40 
FramePktHook(const aom_codec_cx_pkt_t * pkt)41   void FramePktHook(const aom_codec_cx_pkt_t *pkt) override {
42     if (pkt->data.frame.flags & AOM_FRAME_IS_KEY) {
43     }
44   }
45 };
46 
TEST_P(BordersTestLarge,TestEncodeHighBitrate)47 TEST_P(BordersTestLarge, TestEncodeHighBitrate) {
48   // Validate that this non multiple of 64 wide clip encodes and decodes
49   // without a mismatch when passing in a very low max q.  This pushes
50   // the encoder to producing lots of big partitions which will likely
51   // extend into the border and test the border condition.
52   cfg_.g_lag_in_frames = 25;
53   cfg_.rc_2pass_vbr_minsection_pct = 5;
54   cfg_.rc_2pass_vbr_maxsection_pct = 2000;
55   cfg_.rc_target_bitrate = 2000;
56   cfg_.rc_max_quantizer = 10;
57 
58   ::libaom_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0,
59                                        10);
60 
61   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
62 }
TEST_P(BordersTestLarge,TestLowBitrate)63 TEST_P(BordersTestLarge, TestLowBitrate) {
64   // Validate that this clip encodes and decodes without a mismatch
65   // when passing in a very high min q.  This pushes the encoder to producing
66   // lots of small partitions which might will test the other condition.
67 
68   cfg_.g_lag_in_frames = 25;
69   cfg_.rc_2pass_vbr_minsection_pct = 5;
70   cfg_.rc_2pass_vbr_maxsection_pct = 2000;
71   cfg_.rc_target_bitrate = 200;
72   cfg_.rc_min_quantizer = 40;
73 
74   ::libaom_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0,
75                                        10);
76 
77   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
78 }
79 
80 AV1_INSTANTIATE_TEST_SUITE(BordersTestLarge,
81                            ::testing::Values(::libaom_test::kTwoPassGood));
82 }  // namespace
83