2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
10 #include "third_party/googletest/src/include/gtest/gtest.h"
11 #include "test/codec_factory.h"
12 #include "test/video_source.h"
16 class VP9FrameSizeTestsLarge
17 : public ::libvpx_test::EncoderTest,
18 public ::testing::Test {
20 VP9FrameSizeTestsLarge() : EncoderTest(&::libvpx_test::kVP9),
21 expected_res_(VPX_CODEC_OK) {}
22 virtual ~VP9FrameSizeTestsLarge() {}
24 virtual void SetUp() {
26 SetMode(::libvpx_test::kRealTime);
29 virtual bool HandleDecodeResult(const vpx_codec_err_t res_dec,
30 const libvpx_test::VideoSource& /*video*/,
31 libvpx_test::Decoder *decoder) {
32 EXPECT_EQ(expected_res_, res_dec) << decoder->DecodeError();
33 return !::testing::Test::HasFailure();
36 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
37 ::libvpx_test::Encoder *encoder) {
38 if (video->frame() == 1) {
39 encoder->Control(VP8E_SET_CPUUSED, 7);
40 encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
41 encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7);
42 encoder->Control(VP8E_SET_ARNR_STRENGTH, 5);
43 encoder->Control(VP8E_SET_ARNR_TYPE, 3);
50 TEST_F(VP9FrameSizeTestsLarge, TestInvalidSizes) {
51 ::libvpx_test::RandomVideoSource video;
54 video.SetSize(DECODE_WIDTH_LIMIT + 16, DECODE_HEIGHT_LIMIT + 16);
56 expected_res_ = VPX_CODEC_CORRUPT_FRAME;
57 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
61 TEST_F(VP9FrameSizeTestsLarge, ValidSizes) {
62 ::libvpx_test::RandomVideoSource video;
65 video.SetSize(DECODE_WIDTH_LIMIT, DECODE_HEIGHT_LIMIT);
67 expected_res_ = VPX_CODEC_OK;
68 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
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.
77 #if defined(_WIN32) && !defined(_WIN64)
78 video.SetSize(4096, 3072);
80 video.SetSize(4096, 4096);
83 expected_res_ = VPX_CODEC_OK;
84 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
88 TEST_F(VP9FrameSizeTestsLarge, OneByOneVideo) {
89 ::libvpx_test::RandomVideoSource video;
93 expected_res_ = VPX_CODEC_OK;
94 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));