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

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

Issue 375983002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 5 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/libs.mk ('k') | source/libvpx/test/datarate_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) 2012 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2012 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> 10 #include <climits>
11 #include <vector> 11 #include <vector>
12 #include "third_party/googletest/src/include/gtest/gtest.h" 12 #include "third_party/googletest/src/include/gtest/gtest.h"
13 #include "test/codec_factory.h" 13 #include "test/codec_factory.h"
14 #include "test/encode_test_driver.h" 14 #include "test/encode_test_driver.h"
15 #include "test/i420_video_source.h" 15 #include "test/i420_video_source.h"
16 #include "test/util.h" 16 #include "test/util.h"
17 #include "test/y4m_video_source.h"
17 18
18 namespace { 19 namespace {
19 20
21 const int kMaxPSNR = 100;
22
20 class CpuSpeedTest : public ::libvpx_test::EncoderTest, 23 class CpuSpeedTest : public ::libvpx_test::EncoderTest,
21 public ::libvpx_test::CodecTestWith2Params< 24 public ::libvpx_test::CodecTestWith2Params<
22 libvpx_test::TestMode, int> { 25 libvpx_test::TestMode, int> {
23 protected: 26 protected:
24 CpuSpeedTest() : EncoderTest(GET_PARAM(0)) {} 27 CpuSpeedTest()
28 : EncoderTest(GET_PARAM(0)),
29 encoding_mode_(GET_PARAM(1)),
30 set_cpu_used_(GET_PARAM(2)),
31 min_psnr_(kMaxPSNR) {}
25 virtual ~CpuSpeedTest() {} 32 virtual ~CpuSpeedTest() {}
26 33
27 virtual void SetUp() { 34 virtual void SetUp() {
28 InitializeConfig(); 35 InitializeConfig();
29 SetMode(GET_PARAM(1)); 36 SetMode(encoding_mode_);
30 set_cpu_used_ = GET_PARAM(2); 37 if (encoding_mode_ != ::libvpx_test::kRealTime) {
38 cfg_.g_lag_in_frames = 25;
39 cfg_.rc_end_usage = VPX_VBR;
40 } else {
41 cfg_.g_lag_in_frames = 0;
42 cfg_.rc_end_usage = VPX_CBR;
43 }
44 }
45
46 virtual void BeginPassHook(unsigned int /*pass*/) {
47 min_psnr_ = kMaxPSNR;
31 } 48 }
32 49
33 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, 50 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
34 ::libvpx_test::Encoder *encoder) { 51 ::libvpx_test::Encoder *encoder) {
35 if (video->frame() == 1) { 52 if (video->frame() == 1) {
36 encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_); 53 encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
37 encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1); 54 if (encoding_mode_ != ::libvpx_test::kRealTime) {
38 encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7); 55 encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
39 encoder->Control(VP8E_SET_ARNR_STRENGTH, 5); 56 encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7);
40 encoder->Control(VP8E_SET_ARNR_TYPE, 3); 57 encoder->Control(VP8E_SET_ARNR_STRENGTH, 5);
58 encoder->Control(VP8E_SET_ARNR_TYPE, 3);
59 }
41 } 60 }
42 } 61 }
43 62
44 virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) { 63 virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
45 if (pkt->data.frame.flags & VPX_FRAME_IS_KEY) { 64 if (pkt->data.frame.flags & VPX_FRAME_IS_KEY) {
46 } 65 }
47 } 66 }
67
68 virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) {
69 if (pkt->data.psnr.psnr[0] < min_psnr_)
70 min_psnr_ = pkt->data.psnr.psnr[0];
71 }
72
73 ::libvpx_test::TestMode encoding_mode_;
48 int set_cpu_used_; 74 int set_cpu_used_;
75 double min_psnr_;
49 }; 76 };
50 77
51 TEST_P(CpuSpeedTest, TestQ0) { 78 TEST_P(CpuSpeedTest, TestQ0) {
52 // Validate that this non multiple of 64 wide clip encodes and decodes 79 // Validate that this non multiple of 64 wide clip encodes and decodes
53 // without a mismatch when passing in a very low max q. This pushes 80 // without a mismatch when passing in a very low max q. This pushes
54 // the encoder to producing lots of big partitions which will likely 81 // the encoder to producing lots of big partitions which will likely
55 // extend into the border and test the border condition. 82 // extend into the border and test the border condition.
56 cfg_.g_lag_in_frames = 25;
57 cfg_.rc_2pass_vbr_minsection_pct = 5; 83 cfg_.rc_2pass_vbr_minsection_pct = 5;
58 cfg_.rc_2pass_vbr_minsection_pct = 2000; 84 cfg_.rc_2pass_vbr_minsection_pct = 2000;
59 cfg_.rc_target_bitrate = 400; 85 cfg_.rc_target_bitrate = 400;
60 cfg_.rc_max_quantizer = 0; 86 cfg_.rc_max_quantizer = 0;
61 cfg_.rc_min_quantizer = 0; 87 cfg_.rc_min_quantizer = 0;
62 88
63 ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0, 89 ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0,
64 20); 90 20);
65 91
92 init_flags_ = VPX_CODEC_USE_PSNR;
93
66 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); 94 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
95 EXPECT_GE(min_psnr_, kMaxPSNR);
67 } 96 }
68 97
98 TEST_P(CpuSpeedTest, TestScreencastQ0) {
99 ::libvpx_test::Y4mVideoSource video("screendata.y4m", 0, 25);
100 cfg_.g_timebase = video.timebase();
101 cfg_.rc_2pass_vbr_minsection_pct = 5;
102 cfg_.rc_2pass_vbr_minsection_pct = 2000;
103 cfg_.rc_target_bitrate = 400;
104 cfg_.rc_max_quantizer = 0;
105 cfg_.rc_min_quantizer = 0;
106
107 init_flags_ = VPX_CODEC_USE_PSNR;
108
109 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
110 EXPECT_GE(min_psnr_, kMaxPSNR);
111 }
69 112
70 TEST_P(CpuSpeedTest, TestEncodeHighBitrate) { 113 TEST_P(CpuSpeedTest, TestEncodeHighBitrate) {
71 // Validate that this non multiple of 64 wide clip encodes and decodes 114 // Validate that this non multiple of 64 wide clip encodes and decodes
72 // without a mismatch when passing in a very low max q. This pushes 115 // without a mismatch when passing in a very low max q. This pushes
73 // the encoder to producing lots of big partitions which will likely 116 // the encoder to producing lots of big partitions which will likely
74 // extend into the border and test the border condition. 117 // extend into the border and test the border condition.
75 cfg_.g_lag_in_frames = 25;
76 cfg_.rc_2pass_vbr_minsection_pct = 5; 118 cfg_.rc_2pass_vbr_minsection_pct = 5;
77 cfg_.rc_2pass_vbr_minsection_pct = 2000; 119 cfg_.rc_2pass_vbr_minsection_pct = 2000;
78 cfg_.rc_target_bitrate = 12000; 120 cfg_.rc_target_bitrate = 12000;
79 cfg_.rc_max_quantizer = 10; 121 cfg_.rc_max_quantizer = 10;
80 cfg_.rc_min_quantizer = 0; 122 cfg_.rc_min_quantizer = 0;
81 123
82 ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0, 124 ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0,
83 20); 125 20);
84 126
85 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); 127 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
86 } 128 }
87 TEST_P(CpuSpeedTest, TestLowBitrate) { 129 TEST_P(CpuSpeedTest, TestLowBitrate) {
88 // Validate that this clip encodes and decodes without a mismatch 130 // Validate that this clip encodes and decodes without a mismatch
89 // when passing in a very high min q. This pushes the encoder to producing 131 // when passing in a very high min q. This pushes the encoder to producing
90 // lots of small partitions which might will test the other condition. 132 // lots of small partitions which might will test the other condition.
91 133
92 cfg_.g_lag_in_frames = 25;
93 cfg_.rc_2pass_vbr_minsection_pct = 5; 134 cfg_.rc_2pass_vbr_minsection_pct = 5;
94 cfg_.rc_2pass_vbr_minsection_pct = 2000; 135 cfg_.rc_2pass_vbr_minsection_pct = 2000;
95 cfg_.rc_target_bitrate = 200; 136 cfg_.rc_target_bitrate = 200;
96 cfg_.rc_min_quantizer = 40; 137 cfg_.rc_min_quantizer = 40;
97 138
98 ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0, 139 ::libvpx_test::I420VideoSource video("hantro_odd.yuv", 208, 144, 30, 1, 0,
99 20); 140 20);
100 141
101 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); 142 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
102 } 143 }
103 144
104 using std::tr1::make_tuple; 145 using std::tr1::make_tuple;
105 146
106 #define VP9_FACTORY \ 147 #define VP9_FACTORY \
107 static_cast<const libvpx_test::CodecFactory*> (&libvpx_test::kVP9) 148 static_cast<const libvpx_test::CodecFactory*> (&libvpx_test::kVP9)
108 149
109 VP9_INSTANTIATE_TEST_CASE( 150 VP9_INSTANTIATE_TEST_CASE(
110 CpuSpeedTest, 151 CpuSpeedTest,
111 ::testing::Values(::libvpx_test::kTwoPassGood, ::libvpx_test::kOnePassGood), 152 ::testing::Values(::libvpx_test::kTwoPassGood, ::libvpx_test::kOnePassGood,
153 ::libvpx_test::kRealTime),
112 ::testing::Range(0, 8)); 154 ::testing::Range(0, 8));
113 } // namespace 155 } // namespace
OLDNEW
« no previous file with comments | « source/libvpx/libs.mk ('k') | source/libvpx/test/datarate_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698