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