blob: 25b87180b5306e984824816fdd2c57a0e9b34cdd [file] [log] [blame]
Jim Bankoski943e4322014-07-17 06:31:50 -07001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Jim Bankoski943e4322014-07-17 06:31:50 -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 Bankoski943e4322014-07-17 06:31:50 -070012#include "third_party/googletest/src/include/gtest/gtest.h"
13#include "test/codec_factory.h"
James Zerne04273f2014-08-01 13:18:30 -070014#include "test/video_source.h"
Jim Bankoski943e4322014-07-17 06:31:50 -070015
16namespace {
17
Yaowu Xuf883b422016-08-30 14:01:10 -070018class AV1FrameSizeTestsLarge : public ::libaom_test::EncoderTest,
clang-format3a826f12016-08-11 17:46:05 -070019 public ::testing::Test {
Jim Bankoski943e4322014-07-17 06:31:50 -070020 protected:
Yaowu Xuf883b422016-08-30 14:01:10 -070021 AV1FrameSizeTestsLarge()
22 : EncoderTest(&::libaom_test::kAV1), expected_res_(AOM_CODEC_OK) {}
23 virtual ~AV1FrameSizeTestsLarge() {}
Jim Bankoski943e4322014-07-17 06:31:50 -070024
25 virtual void SetUp() {
26 InitializeConfig();
Yaowu Xuc27fc142016-08-22 16:08:15 -070027 SetMode(::libaom_test::kRealTime);
Jim Bankoski943e4322014-07-17 06:31:50 -070028 }
29
Yaowu Xuf883b422016-08-30 14:01:10 -070030 virtual bool HandleDecodeResult(const aom_codec_err_t res_dec,
Yaowu Xuc27fc142016-08-22 16:08:15 -070031 libaom_test::Decoder *decoder) {
James Zerne04273f2014-08-01 13:18:30 -070032 EXPECT_EQ(expected_res_, res_dec) << decoder->DecodeError();
Jim Bankoski943e4322014-07-17 06:31:50 -070033 return !::testing::Test::HasFailure();
34 }
35
Yaowu Xuc27fc142016-08-22 16:08:15 -070036 virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
37 ::libaom_test::Encoder *encoder) {
Jim Bankoski943e4322014-07-17 06:31:50 -070038 if (video->frame() == 1) {
Yaowu Xuf883b422016-08-30 14:01:10 -070039 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 Bankoski943e4322014-07-17 06:31:50 -070044 }
45 }
46
47 int expected_res_;
48};
49
Yaowu Xuf883b422016-08-30 14:01:10 -070050TEST_F(AV1FrameSizeTestsLarge, TestInvalidSizes) {
Yaowu Xuc27fc142016-08-22 16:08:15 -070051 ::libaom_test::RandomVideoSource video;
Jim Bankoski943e4322014-07-17 06:31:50 -070052
53#if CONFIG_SIZE_LIMIT
54 video.SetSize(DECODE_WIDTH_LIMIT + 16, DECODE_HEIGHT_LIMIT + 16);
55 video.set_limit(2);
Yaowu Xuf883b422016-08-30 14:01:10 -070056 expected_res_ = AOM_CODEC_CORRUPT_FRAME;
Jim Bankoski943e4322014-07-17 06:31:50 -070057 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
Jim Bankoski943e4322014-07-17 06:31:50 -070058#endif
59}
60
Yaowu Xuf883b422016-08-30 14:01:10 -070061TEST_F(AV1FrameSizeTestsLarge, ValidSizes) {
Yaowu Xuc27fc142016-08-22 16:08:15 -070062 ::libaom_test::RandomVideoSource video;
Jim Bankoski943e4322014-07-17 06:31:50 -070063
64#if CONFIG_SIZE_LIMIT
65 video.SetSize(DECODE_WIDTH_LIMIT, DECODE_HEIGHT_LIMIT);
66 video.set_limit(2);
Yaowu Xuf883b422016-08-30 14:01:10 -070067 expected_res_ = AOM_CODEC_OK;
Jim Bankoski943e4322014-07-17 06:31:50 -070068 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
69#else
clang-format3a826f12016-08-11 17:46:05 -070070// 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-Hun9af8c392015-08-30 16:28:41 +090077#if defined(_WIN32) && !defined(_WIN64) || defined(__OS2__)
James Zernd637c2b2014-08-15 14:39:28 -070078 video.SetSize(4096, 3072);
79#else
Jim Bankoski943e4322014-07-17 06:31:50 -070080 video.SetSize(4096, 4096);
James Zernd637c2b2014-08-15 14:39:28 -070081#endif
Jim Bankoski943e4322014-07-17 06:31:50 -070082 video.set_limit(2);
Yaowu Xuf883b422016-08-30 14:01:10 -070083 expected_res_ = AOM_CODEC_OK;
Jim Bankoski943e4322014-07-17 06:31:50 -070084 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
85#endif
86}
Alex Converse655fbd12014-10-01 11:40:34 -070087
Yaowu Xuf883b422016-08-30 14:01:10 -070088TEST_F(AV1FrameSizeTestsLarge, OneByOneVideo) {
Yaowu Xuc27fc142016-08-22 16:08:15 -070089 ::libaom_test::RandomVideoSource video;
Alex Converse655fbd12014-10-01 11:40:34 -070090
91 video.SetSize(1, 1);
92 video.set_limit(2);
Yaowu Xuf883b422016-08-30 14:01:10 -070093 expected_res_ = AOM_CODEC_OK;
Alex Converse655fbd12014-10-01 11:40:34 -070094 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
95}
Jim Bankoski943e4322014-07-17 06:31:50 -070096} // namespace