Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: source/libvpx/test/frame_size_tests.cc

Issue 478033002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/test/fdct8x8_test.cc ('k') | source/libvpx/test/sad_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 #include <climits>
11 #include <vector>
12 #include "third_party/googletest/src/include/gtest/gtest.h" 10 #include "third_party/googletest/src/include/gtest/gtest.h"
13 #include "test/codec_factory.h" 11 #include "test/codec_factory.h"
14 #include "test/encode_test_driver.h" 12 #include "test/video_source.h"
15 #include "test/i420_video_source.h"
16 #include "test/util.h"
17 13
18 namespace { 14 namespace {
19 15
20 class VP9FrameSizeTestsLarge 16 class VP9FrameSizeTestsLarge
21 : public ::libvpx_test::EncoderTest, 17 : public ::libvpx_test::EncoderTest,
22 public ::testing::Test { 18 public ::testing::Test {
23 protected: 19 protected:
24 VP9FrameSizeTestsLarge() : EncoderTest(&::libvpx_test::kVP9), 20 VP9FrameSizeTestsLarge() : EncoderTest(&::libvpx_test::kVP9),
25 expected_res_(VPX_CODEC_OK) {} 21 expected_res_(VPX_CODEC_OK) {}
26 virtual ~VP9FrameSizeTestsLarge() {} 22 virtual ~VP9FrameSizeTestsLarge() {}
27 23
28 virtual void SetUp() { 24 virtual void SetUp() {
29 InitializeConfig(); 25 InitializeConfig();
30 SetMode(::libvpx_test::kRealTime); 26 SetMode(::libvpx_test::kRealTime);
31 } 27 }
32 28
33 virtual bool HandleDecodeResult(const vpx_codec_err_t res_dec, 29 virtual bool HandleDecodeResult(const vpx_codec_err_t res_dec,
34 const libvpx_test::VideoSource &video, 30 const libvpx_test::VideoSource &video,
35 libvpx_test::Decoder *decoder) { 31 libvpx_test::Decoder *decoder) {
36 EXPECT_EQ(expected_res_, res_dec) 32 EXPECT_EQ(expected_res_, res_dec) << decoder->DecodeError();
37 << "Expected " << expected_res_
38 << "but got " << res_dec;
39
40 return !::testing::Test::HasFailure(); 33 return !::testing::Test::HasFailure();
41 } 34 }
42 35
43 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, 36 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
44 ::libvpx_test::Encoder *encoder) { 37 ::libvpx_test::Encoder *encoder) {
45 if (video->frame() == 1) { 38 if (video->frame() == 1) {
46 encoder->Control(VP8E_SET_CPUUSED, 7); 39 encoder->Control(VP8E_SET_CPUUSED, 7);
47 encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1); 40 encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
48 encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7); 41 encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7);
49 encoder->Control(VP8E_SET_ARNR_STRENGTH, 5); 42 encoder->Control(VP8E_SET_ARNR_STRENGTH, 5);
50 encoder->Control(VP8E_SET_ARNR_TYPE, 3); 43 encoder->Control(VP8E_SET_ARNR_TYPE, 3);
51 } 44 }
52 } 45 }
53 46
54 int expected_res_; 47 int expected_res_;
55 }; 48 };
56 49
57 TEST_F(VP9FrameSizeTestsLarge, TestInvalidSizes) { 50 TEST_F(VP9FrameSizeTestsLarge, TestInvalidSizes) {
58 ::libvpx_test::RandomVideoSource video; 51 ::libvpx_test::RandomVideoSource video;
59 52
60 #if CONFIG_SIZE_LIMIT 53 #if CONFIG_SIZE_LIMIT
61 video.SetSize(DECODE_WIDTH_LIMIT + 16, DECODE_HEIGHT_LIMIT + 16); 54 video.SetSize(DECODE_WIDTH_LIMIT + 16, DECODE_HEIGHT_LIMIT + 16);
62 video.set_limit(2); 55 video.set_limit(2);
63 expected_res_ = VPX_CODEC_CORRUPT_FRAME; 56 expected_res_ = VPX_CODEC_CORRUPT_FRAME;
64 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); 57 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
65 #else
66 // If we are on a 32 bit platform we can't possibly allocate enough memory
67 // for the largest video frame size (64kx64k). This test checks that we
68 // properly return a memory error.
69 if (sizeof(size_t) == 4) {
70 video.SetSize(65535, 65535);
71 video.set_limit(2);
72 expected_res_ = VPX_CODEC_MEM_ERROR;
73 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
74 }
75 #endif 58 #endif
76 } 59 }
77 60
78 TEST_F(VP9FrameSizeTestsLarge, ValidSizes) { 61 TEST_F(VP9FrameSizeTestsLarge, ValidSizes) {
79 ::libvpx_test::RandomVideoSource video; 62 ::libvpx_test::RandomVideoSource video;
80 63
81 #if CONFIG_SIZE_LIMIT 64 #if CONFIG_SIZE_LIMIT
82 video.SetSize(DECODE_WIDTH_LIMIT, DECODE_HEIGHT_LIMIT); 65 video.SetSize(DECODE_WIDTH_LIMIT, DECODE_HEIGHT_LIMIT);
83 video.set_limit(2); 66 video.set_limit(2);
84 expected_res_ = VPX_CODEC_OK; 67 expected_res_ = VPX_CODEC_OK;
85 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); 68 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
86 #else 69 #else
87 // This test produces a pretty large single frame allocation, (roughly 70 // This test produces a pretty large single frame allocation, (roughly
88 // 25 megabits). The encoder allocates a good number of these frames 71 // 25 megabits). The encoder allocates a good number of these frames
89 // one for each lag in frames (for 2 pass), and then one for each possible 72 // one for each lag in frames (for 2 pass), and then one for each possible
90 // reference buffer (8) - we can end up with up to 30 buffers of roughly this 73 // reference buffer (8) - we can end up with up to 30 buffers of roughly this
91 // size or almost 1 gig of memory. 74 // size or almost 1 gig of memory.
92 // TODO(jzern): restore this to at least 4096x4096 after issue #828 is fixed. 75 video.SetSize(4096, 4096);
93 video.SetSize(4096, 2160);
94 video.set_limit(2); 76 video.set_limit(2);
95 expected_res_ = VPX_CODEC_OK; 77 expected_res_ = VPX_CODEC_OK;
96 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); 78 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
97 #endif 79 #endif
98 } 80 }
99 } // namespace 81 } // namespace
OLDNEW
« no previous file with comments | « source/libvpx/test/fdct8x8_test.cc ('k') | source/libvpx/test/sad_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698