blob: 31eacab12e2f9ffe454647081c86d22bc84be099 [file] [log] [blame]
Jim Bankoski5a882712013-06-06 06:07:09 -07001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Jim Bankoski5a882712013-06-06 06:07:09 -07003 *
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07004 * 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.
Johann123e8a62017-12-28 14:40:49 -080010 */
Yaowu Xu2ab7ff02016-09-02 12:04:54 -070011
Jim Bankoski5a882712013-06-06 06:07:09 -070012#include <climits>
13#include <vector>
Tom Finegan7a07ece2017-02-07 17:14:05 -080014#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
Jim Bankoski5a882712013-06-06 06:07:09 -070015#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
20namespace {
21
Debargha Mukherjee15b6ae02017-10-10 19:56:05 -070022class BordersTestLarge
Sebastien Alaiwan4322bc12017-06-05 10:18:28 +020023 : public ::libaom_test::CodecTestWithParam<libaom_test::TestMode>,
24 public ::libaom_test::EncoderTest {
Jim Bankoski5a882712013-06-06 06:07:09 -070025 protected:
Debargha Mukherjee15b6ae02017-10-10 19:56:05 -070026 BordersTestLarge() : EncoderTest(GET_PARAM(0)) {}
27 virtual ~BordersTestLarge() {}
Jim Bankoski5a882712013-06-06 06:07:09 -070028
29 virtual void SetUp() {
30 InitializeConfig();
31 SetMode(GET_PARAM(1));
32 }
33
Yaowu Xuc27fc142016-08-22 16:08:15 -070034 virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
35 ::libaom_test::Encoder *encoder) {
Yunqing Wang51b282d2018-10-01 16:25:34 -070036 if (video->frame() == 0) {
Yaowu Xuf883b422016-08-30 14:01:10 -070037 encoder->Control(AOME_SET_CPUUSED, 1);
38 encoder->Control(AOME_SET_ENABLEAUTOALTREF, 1);
39 encoder->Control(AOME_SET_ARNR_MAXFRAMES, 7);
40 encoder->Control(AOME_SET_ARNR_STRENGTH, 5);
Jim Bankoski5a882712013-06-06 06:07:09 -070041 }
42 }
43
Yaowu Xuf883b422016-08-30 14:01:10 -070044 virtual void FramePktHook(const aom_codec_cx_pkt_t *pkt) {
45 if (pkt->data.frame.flags & AOM_FRAME_IS_KEY) {
Jim Bankoski5a882712013-06-06 06:07:09 -070046 }
47 }
48};
49
Debargha Mukherjee15b6ae02017-10-10 19:56:05 -070050TEST_P(BordersTestLarge, TestEncodeHighBitrate) {
Jim Bankoski5a882712013-06-06 06:07:09 -070051 // Validate that this non multiple of 64 wide clip encodes and decodes
52 // without a mismatch when passing in a very low max q. This pushes
53 // the encoder to producing lots of big partitions which will likely
54 // extend into the border and test the border condition.
55 cfg_.g_lag_in_frames = 25;
56 cfg_.rc_2pass_vbr_minsection_pct = 5;
hui sub1a38712016-03-14 16:32:41 -070057 cfg_.rc_2pass_vbr_maxsection_pct = 2000;
Jim Bankoski5a882712013-06-06 06:07:09 -070058 cfg_.rc_target_bitrate = 2000;
59 cfg_.rc_max_quantizer = 10;
60
Yaowu Xuc27fc142016-08-22 16:08:15 -070061 ::libaom_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0,
Yaowu Xu26843a02017-05-08 14:42:45 -070062 10);
Jim Bankoski5a882712013-06-06 06:07:09 -070063
64 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
65}
Debargha Mukherjee15b6ae02017-10-10 19:56:05 -070066TEST_P(BordersTestLarge, TestLowBitrate) {
Jim Bankoski5a882712013-06-06 06:07:09 -070067 // Validate that this clip encodes and decodes without a mismatch
68 // when passing in a very high min q. This pushes the encoder to producing
69 // lots of small partitions which might will test the other condition.
70
71 cfg_.g_lag_in_frames = 25;
72 cfg_.rc_2pass_vbr_minsection_pct = 5;
Adrian Grange15cf5962013-12-13 08:48:12 -080073 cfg_.rc_2pass_vbr_maxsection_pct = 2000;
Jim Bankoski5a882712013-06-06 06:07:09 -070074 cfg_.rc_target_bitrate = 200;
75 cfg_.rc_min_quantizer = 40;
76
Yaowu Xuc27fc142016-08-22 16:08:15 -070077 ::libaom_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0,
Yaowu Xu26843a02017-05-08 14:42:45 -070078 10);
Jim Bankoski5a882712013-06-06 06:07:09 -070079
80 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
81}
82
Debargha Mukherjee15b6ae02017-10-10 19:56:05 -070083AV1_INSTANTIATE_TEST_CASE(BordersTestLarge,
Yaowu Xuf883b422016-08-30 14:01:10 -070084 ::testing::Values(::libaom_test::kTwoPassGood));
Jim Bankoski5a882712013-06-06 06:07:09 -070085} // namespace