Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 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 | |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 12 | #include <climits> |
| 13 | #include <vector> |
Tom Finegan | 7a07ece | 2017-02-07 17:14:05 -0800 | [diff] [blame] | 14 | #include "third_party/googletest/src/googletest/include/gtest/gtest.h" |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 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 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 22 | class BordersTest |
Sebastien Alaiwan | 4322bc1 | 2017-06-05 10:18:28 +0200 | [diff] [blame] | 23 | : public ::libaom_test::CodecTestWithParam<libaom_test::TestMode>, |
| 24 | public ::libaom_test::EncoderTest { |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 25 | protected: |
| 26 | BordersTest() : EncoderTest(GET_PARAM(0)) {} |
Alex Converse | 6207a38 | 2014-03-12 14:51:42 -0700 | [diff] [blame] | 27 | virtual ~BordersTest() {} |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 28 | |
| 29 | virtual void SetUp() { |
| 30 | InitializeConfig(); |
| 31 | SetMode(GET_PARAM(1)); |
| 32 | } |
| 33 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 34 | virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video, |
| 35 | ::libaom_test::Encoder *encoder) { |
Yaowu Xu | afffa3d | 2013-09-05 08:45:56 -0700 | [diff] [blame] | 36 | if (video->frame() == 1) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 37 | 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 Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 41 | } |
| 42 | } |
| 43 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 44 | virtual void FramePktHook(const aom_codec_cx_pkt_t *pkt) { |
| 45 | if (pkt->data.frame.flags & AOM_FRAME_IS_KEY) { |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 46 | } |
| 47 | } |
| 48 | }; |
| 49 | |
| 50 | TEST_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 su | b1a3871 | 2016-03-14 16:32:41 -0700 | [diff] [blame] | 57 | cfg_.rc_2pass_vbr_maxsection_pct = 2000; |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 58 | cfg_.rc_target_bitrate = 2000; |
| 59 | cfg_.rc_max_quantizer = 10; |
| 60 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 61 | ::libaom_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0, |
Yaowu Xu | 26843a0 | 2017-05-08 14:42:45 -0700 | [diff] [blame] | 62 | 10); |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 63 | |
| 64 | ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 65 | } |
| 66 | TEST_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 Grange | 15cf596 | 2013-12-13 08:48:12 -0800 | [diff] [blame] | 73 | cfg_.rc_2pass_vbr_maxsection_pct = 2000; |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 74 | cfg_.rc_target_bitrate = 200; |
| 75 | cfg_.rc_min_quantizer = 40; |
| 76 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 77 | ::libaom_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0, |
Yaowu Xu | 26843a0 | 2017-05-08 14:42:45 -0700 | [diff] [blame] | 78 | 10); |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 79 | |
| 80 | ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 81 | } |
| 82 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 83 | AV1_INSTANTIATE_TEST_CASE(BordersTest, |
| 84 | ::testing::Values(::libaom_test::kTwoPassGood)); |
Jim Bankoski | 5a88271 | 2013-06-06 06:07:09 -0700 | [diff] [blame] | 85 | } // namespace |