blob: ee771707c282b67ab9a85d953466777861d46d56 [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.
10*/
11
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
clang-format3a826f12016-08-11 17:46:05 -070022class BordersTest
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:
26 BordersTest() : EncoderTest(GET_PARAM(0)) {}
Alex Converse6207a382014-03-12 14:51:42 -070027 virtual ~BordersTest() {}
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) {
Yaowu Xuafffa3d2013-09-05 08:45:56 -070036 if (video->frame() == 1) {
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
50TEST_P(BordersTest, TestEncodeHighBitrate) {
51 // 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}
66TEST_P(BordersTest, TestLowBitrate) {
67 // 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
Yaowu Xuf883b422016-08-30 14:01:10 -070083AV1_INSTANTIATE_TEST_CASE(BordersTest,
84 ::testing::Values(::libaom_test::kTwoPassGood));
Jim Bankoski5a882712013-06-06 06:07:09 -070085} // namespace