Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -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 | 943e432 | 2014-07-17 06:31:50 -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 | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 12 | #include "third_party/googletest/src/include/gtest/gtest.h" |
| 13 | #include "test/codec_factory.h" |
James Zern | e04273f | 2014-08-01 13:18:30 -0700 | [diff] [blame] | 14 | #include "test/video_source.h" |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 15 | |
| 16 | namespace { |
| 17 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 18 | class AV1FrameSizeTestsLarge : public ::libaom_test::EncoderTest, |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 19 | public ::testing::Test { |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 20 | protected: |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 21 | AV1FrameSizeTestsLarge() |
| 22 | : EncoderTest(&::libaom_test::kAV1), expected_res_(AOM_CODEC_OK) {} |
| 23 | virtual ~AV1FrameSizeTestsLarge() {} |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 24 | |
| 25 | virtual void SetUp() { |
| 26 | InitializeConfig(); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 27 | SetMode(::libaom_test::kRealTime); |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 28 | } |
| 29 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 30 | virtual bool HandleDecodeResult(const aom_codec_err_t res_dec, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 31 | libaom_test::Decoder *decoder) { |
James Zern | e04273f | 2014-08-01 13:18:30 -0700 | [diff] [blame] | 32 | EXPECT_EQ(expected_res_, res_dec) << decoder->DecodeError(); |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 33 | return !::testing::Test::HasFailure(); |
| 34 | } |
| 35 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 36 | virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video, |
| 37 | ::libaom_test::Encoder *encoder) { |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 38 | if (video->frame() == 1) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 39 | encoder->Control(AOME_SET_CPUUSED, 7); |
| 40 | encoder->Control(AOME_SET_ENABLEAUTOALTREF, 1); |
| 41 | encoder->Control(AOME_SET_ARNR_MAXFRAMES, 7); |
| 42 | encoder->Control(AOME_SET_ARNR_STRENGTH, 5); |
| 43 | encoder->Control(AOME_SET_ARNR_TYPE, 3); |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 44 | } |
| 45 | } |
| 46 | |
| 47 | int expected_res_; |
| 48 | }; |
| 49 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 50 | TEST_F(AV1FrameSizeTestsLarge, TestInvalidSizes) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 51 | ::libaom_test::RandomVideoSource video; |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 52 | |
| 53 | #if CONFIG_SIZE_LIMIT |
| 54 | video.SetSize(DECODE_WIDTH_LIMIT + 16, DECODE_HEIGHT_LIMIT + 16); |
| 55 | video.set_limit(2); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 56 | expected_res_ = AOM_CODEC_CORRUPT_FRAME; |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 57 | ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 58 | #endif |
| 59 | } |
| 60 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 61 | TEST_F(AV1FrameSizeTestsLarge, ValidSizes) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 62 | ::libaom_test::RandomVideoSource video; |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 63 | |
| 64 | #if CONFIG_SIZE_LIMIT |
| 65 | video.SetSize(DECODE_WIDTH_LIMIT, DECODE_HEIGHT_LIMIT); |
| 66 | video.set_limit(2); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 67 | expected_res_ = AOM_CODEC_OK; |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 68 | ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 69 | #else |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 70 | // This test produces a pretty large single frame allocation, (roughly |
| 71 | // 25 megabits). The encoder allocates a good number of these frames |
| 72 | // one for each lag in frames (for 2 pass), and then one for each possible |
| 73 | // reference buffer (8) - we can end up with up to 30 buffers of roughly this |
| 74 | // size or almost 1 gig of memory. |
| 75 | // In total the allocations will exceed 2GiB which may cause a failure with |
| 76 | // mingw + wine, use a smaller size in that case. |
KO Myung-Hun | 9af8c39 | 2015-08-30 16:28:41 +0900 | [diff] [blame] | 77 | #if defined(_WIN32) && !defined(_WIN64) || defined(__OS2__) |
James Zern | d637c2b | 2014-08-15 14:39:28 -0700 | [diff] [blame] | 78 | video.SetSize(4096, 3072); |
| 79 | #else |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 80 | video.SetSize(4096, 4096); |
James Zern | d637c2b | 2014-08-15 14:39:28 -0700 | [diff] [blame] | 81 | #endif |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 82 | video.set_limit(2); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 83 | expected_res_ = AOM_CODEC_OK; |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 84 | ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 85 | #endif |
| 86 | } |
Alex Converse | 655fbd1 | 2014-10-01 11:40:34 -0700 | [diff] [blame] | 87 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 88 | TEST_F(AV1FrameSizeTestsLarge, OneByOneVideo) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 89 | ::libaom_test::RandomVideoSource video; |
Alex Converse | 655fbd1 | 2014-10-01 11:40:34 -0700 | [diff] [blame] | 90 | |
| 91 | video.SetSize(1, 1); |
| 92 | video.set_limit(2); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 93 | expected_res_ = AOM_CODEC_OK; |
Alex Converse | 655fbd1 | 2014-10-01 11:40:34 -0700 | [diff] [blame] | 94 | ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
| 95 | } |
Jim Bankoski | 943e432 | 2014-07-17 06:31:50 -0700 | [diff] [blame] | 96 | } // namespace |