blob: 0b8200fc89609b781da134e90c190628b7857a5e [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>
14#include "third_party/googletest/src/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
20namespace {
21
clang-format3a826f12016-08-11 17:46:05 -070022class BordersTest
Yaowu Xuc27fc142016-08-22 16:08:15 -070023 : public ::libaom_test::EncoderTest,
24 public ::libaom_test::CodecTestWithParam<libaom_test::TestMode> {
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);
41 encoder->Control(AOME_SET_ARNR_TYPE, 3);
Jim Bankoski5a882712013-06-06 06:07:09 -070042 }
43 }
44
Yaowu Xuf883b422016-08-30 14:01:10 -070045 virtual void FramePktHook(const aom_codec_cx_pkt_t *pkt) {
46 if (pkt->data.frame.flags & AOM_FRAME_IS_KEY) {
Jim Bankoski5a882712013-06-06 06:07:09 -070047 }
48 }
49};
50
51TEST_P(BordersTest, TestEncodeHighBitrate) {
52 // Validate that this non multiple of 64 wide clip encodes and decodes
53 // without a mismatch when passing in a very low max q. This pushes
54 // the encoder to producing lots of big partitions which will likely
55 // extend into the border and test the border condition.
56 cfg_.g_lag_in_frames = 25;
57 cfg_.rc_2pass_vbr_minsection_pct = 5;
hui sub1a38712016-03-14 16:32:41 -070058 cfg_.rc_2pass_vbr_maxsection_pct = 2000;
Jim Bankoski5a882712013-06-06 06:07:09 -070059 cfg_.rc_target_bitrate = 2000;
60 cfg_.rc_max_quantizer = 10;
61
Yaowu Xuc27fc142016-08-22 16:08:15 -070062 ::libaom_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0,
Jim Bankoski5a882712013-06-06 06:07:09 -070063 40);
64
65 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
66}
67TEST_P(BordersTest, TestLowBitrate) {
68 // Validate that this clip encodes and decodes without a mismatch
69 // when passing in a very high min q. This pushes the encoder to producing
70 // lots of small partitions which might will test the other condition.
71
72 cfg_.g_lag_in_frames = 25;
73 cfg_.rc_2pass_vbr_minsection_pct = 5;
Adrian Grange15cf5962013-12-13 08:48:12 -080074 cfg_.rc_2pass_vbr_maxsection_pct = 2000;
Jim Bankoski5a882712013-06-06 06:07:09 -070075 cfg_.rc_target_bitrate = 200;
76 cfg_.rc_min_quantizer = 40;
77
Yaowu Xuc27fc142016-08-22 16:08:15 -070078 ::libaom_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0,
Jim Bankoski5a882712013-06-06 06:07:09 -070079 40);
80
81 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
82}
83
Yaowu Xuf883b422016-08-30 14:01:10 -070084AV1_INSTANTIATE_TEST_CASE(BordersTest,
85 ::testing::Values(::libaom_test::kTwoPassGood));
Jim Bankoski5a882712013-06-06 06:07:09 -070086} // namespace