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

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

Issue 812033011: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 5 years, 11 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/decode_test_driver.cc ('k') | source/libvpx/test/encode_test_driver.h » ('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 <string>
10 #include "third_party/googletest/src/include/gtest/gtest.h" 11 #include "third_party/googletest/src/include/gtest/gtest.h"
11 #include "./vpx_config.h" 12 #include "./vpx_config.h"
12 #include "./vpx_version.h" 13 #include "./vpx_version.h"
13 #include "test/codec_factory.h" 14 #include "test/codec_factory.h"
14 #include "test/encode_test_driver.h" 15 #include "test/encode_test_driver.h"
15 #include "test/i420_video_source.h" 16 #include "test/i420_video_source.h"
16 #include "test/util.h" 17 #include "test/util.h"
17 #include "test/y4m_video_source.h" 18 #include "test/y4m_video_source.h"
18 #include "vpx_ports/vpx_timer.h" 19 #include "vpx_ports/vpx_timer.h"
19 20
(...skipping 23 matching lines...) Expand all
43 EncodePerfTestVideo("macmarcomoving_640_480_30.yuv", 640, 480, 200, 987), 44 EncodePerfTestVideo("macmarcomoving_640_480_30.yuv", 640, 480, 200, 987),
44 EncodePerfTestVideo("macmarcostationary_640_480_30.yuv", 640, 480, 200, 718), 45 EncodePerfTestVideo("macmarcostationary_640_480_30.yuv", 640, 480, 200, 718),
45 EncodePerfTestVideo("niklas_640_480_30.yuv", 640, 480, 200, 471), 46 EncodePerfTestVideo("niklas_640_480_30.yuv", 640, 480, 200, 471),
46 EncodePerfTestVideo("tacomanarrows_640_480_30.yuv", 640, 480, 200, 300), 47 EncodePerfTestVideo("tacomanarrows_640_480_30.yuv", 640, 480, 200, 300),
47 EncodePerfTestVideo("tacomasmallcameramovement_640_480_30.yuv", 48 EncodePerfTestVideo("tacomasmallcameramovement_640_480_30.yuv",
48 640, 480, 200, 300), 49 640, 480, 200, 300),
49 EncodePerfTestVideo("thaloundeskmtg_640_480_30.yuv", 640, 480, 200, 300), 50 EncodePerfTestVideo("thaloundeskmtg_640_480_30.yuv", 640, 480, 200, 300),
50 EncodePerfTestVideo("niklas_1280_720_30.yuv", 1280, 720, 600, 470), 51 EncodePerfTestVideo("niklas_1280_720_30.yuv", 1280, 720, 600, 470),
51 }; 52 };
52 53
53 const int kEncodePerfTestSpeeds[] = { 5, 6, 7, 12 }; 54 const int kEncodePerfTestSpeeds[] = { 5, 6, 7, 8 };
55 const int kEncodePerfTestThreads[] = { 1, 2, 4 };
54 56
55 #define NELEMENTS(x) (sizeof((x)) / sizeof((x)[0])) 57 #define NELEMENTS(x) (sizeof((x)) / sizeof((x)[0]))
56 58
57 class VP9EncodePerfTest 59 class VP9EncodePerfTest
58 : public ::libvpx_test::EncoderTest, 60 : public ::libvpx_test::EncoderTest,
59 public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> { 61 public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> {
60 protected: 62 protected:
61 VP9EncodePerfTest() 63 VP9EncodePerfTest()
62 : EncoderTest(GET_PARAM(0)), 64 : EncoderTest(GET_PARAM(0)),
63 min_psnr_(kMaxPsnr), 65 min_psnr_(kMaxPsnr),
64 nframes_(0), 66 nframes_(0),
65 encoding_mode_(GET_PARAM(1)), 67 encoding_mode_(GET_PARAM(1)),
66 speed_(0) {} 68 speed_(0),
69 threads_(1) {}
67 70
68 virtual ~VP9EncodePerfTest() {} 71 virtual ~VP9EncodePerfTest() {}
69 72
70 virtual void SetUp() { 73 virtual void SetUp() {
71 InitializeConfig(); 74 InitializeConfig();
72 SetMode(encoding_mode_); 75 SetMode(encoding_mode_);
73 76
74 cfg_.g_lag_in_frames = 0; 77 cfg_.g_lag_in_frames = 0;
75 cfg_.rc_min_quantizer = 2; 78 cfg_.rc_min_quantizer = 2;
76 cfg_.rc_max_quantizer = 56; 79 cfg_.rc_max_quantizer = 56;
77 cfg_.rc_dropframe_thresh = 0; 80 cfg_.rc_dropframe_thresh = 0;
78 cfg_.rc_undershoot_pct = 50; 81 cfg_.rc_undershoot_pct = 50;
79 cfg_.rc_overshoot_pct = 50; 82 cfg_.rc_overshoot_pct = 50;
80 cfg_.rc_buf_sz = 1000; 83 cfg_.rc_buf_sz = 1000;
81 cfg_.rc_buf_initial_sz = 500; 84 cfg_.rc_buf_initial_sz = 500;
82 cfg_.rc_buf_optimal_sz = 600; 85 cfg_.rc_buf_optimal_sz = 600;
83 cfg_.rc_resize_allowed = 0; 86 cfg_.rc_resize_allowed = 0;
84 cfg_.rc_end_usage = VPX_CBR; 87 cfg_.rc_end_usage = VPX_CBR;
88 cfg_.g_error_resilient = 1;
89 cfg_.g_threads = threads_;
85 } 90 }
86 91
87 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, 92 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
88 ::libvpx_test::Encoder *encoder) { 93 ::libvpx_test::Encoder *encoder) {
89 if (video->frame() == 1) { 94 if (video->frame() == 0) {
95 const int log2_tile_columns = 3;
90 encoder->Control(VP8E_SET_CPUUSED, speed_); 96 encoder->Control(VP8E_SET_CPUUSED, speed_);
97 encoder->Control(VP9E_SET_TILE_COLUMNS, log2_tile_columns);
98 encoder->Control(VP9E_SET_FRAME_PARALLEL_DECODING, 1);
99 encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 0);
91 } 100 }
92 } 101 }
93 102
94 virtual void BeginPassHook(unsigned int /*pass*/) { 103 virtual void BeginPassHook(unsigned int /*pass*/) {
95 min_psnr_ = kMaxPsnr; 104 min_psnr_ = kMaxPsnr;
96 nframes_ = 0; 105 nframes_ = 0;
97 } 106 }
98 107
99 virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) { 108 virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) {
100 if (pkt->data.psnr.psnr[0] < min_psnr_) { 109 if (pkt->data.psnr.psnr[0] < min_psnr_) {
101 min_psnr_= pkt->data.psnr.psnr[0]; 110 min_psnr_= pkt->data.psnr.psnr[0];
102 } 111 }
103 } 112 }
104 113
105 // for performance reasons don't decode 114 // for performance reasons don't decode
106 virtual bool DoDecode() { return 0; } 115 virtual bool DoDecode() { return 0; }
107 116
108 double min_psnr() const { 117 double min_psnr() const {
109 return min_psnr_; 118 return min_psnr_;
110 } 119 }
111 120
112 void set_speed(unsigned int speed) { 121 void set_speed(unsigned int speed) {
113 speed_ = speed; 122 speed_ = speed;
114 } 123 }
115 124
125 void set_threads(unsigned int threads) {
126 threads_ = threads;
127 }
128
116 private: 129 private:
117 double min_psnr_; 130 double min_psnr_;
118 unsigned int nframes_; 131 unsigned int nframes_;
119 libvpx_test::TestMode encoding_mode_; 132 libvpx_test::TestMode encoding_mode_;
120 unsigned speed_; 133 unsigned speed_;
134 unsigned int threads_;
121 }; 135 };
122 136
123 TEST_P(VP9EncodePerfTest, PerfTest) { 137 TEST_P(VP9EncodePerfTest, PerfTest) {
124 for (size_t i = 0; i < NELEMENTS(kVP9EncodePerfTestVectors); ++i) { 138 for (size_t i = 0; i < NELEMENTS(kVP9EncodePerfTestVectors); ++i) {
125 for (size_t j = 0; j < NELEMENTS(kEncodePerfTestSpeeds); ++j) { 139 for (size_t j = 0; j < NELEMENTS(kEncodePerfTestSpeeds); ++j) {
126 SetUp(); 140 for (size_t k = 0; k < NELEMENTS(kEncodePerfTestThreads); ++k) {
141 if (kVP9EncodePerfTestVectors[i].width < 512 &&
142 kEncodePerfTestThreads[k] > 1)
143 continue;
144 else if (kVP9EncodePerfTestVectors[i].width < 1024 &&
145 kEncodePerfTestThreads[k] > 2)
146 continue;
127 147
128 const vpx_rational timebase = { 33333333, 1000000000 }; 148 set_threads(kEncodePerfTestThreads[k]);
129 cfg_.g_timebase = timebase; 149 SetUp();
130 cfg_.rc_target_bitrate = kVP9EncodePerfTestVectors[i].bitrate;
131 150
132 init_flags_ = VPX_CODEC_USE_PSNR; 151 const vpx_rational timebase = { 33333333, 1000000000 };
152 cfg_.g_timebase = timebase;
153 cfg_.rc_target_bitrate = kVP9EncodePerfTestVectors[i].bitrate;
133 154
134 const unsigned frames = kVP9EncodePerfTestVectors[i].frames; 155 init_flags_ = VPX_CODEC_USE_PSNR;
135 const char *video_name = kVP9EncodePerfTestVectors[i].name;
136 libvpx_test::I420VideoSource video(
137 video_name,
138 kVP9EncodePerfTestVectors[i].width,
139 kVP9EncodePerfTestVectors[i].height,
140 timebase.den, timebase.num, 0,
141 kVP9EncodePerfTestVectors[i].frames);
142 set_speed(kEncodePerfTestSpeeds[j]);
143 156
144 vpx_usec_timer t; 157 const unsigned frames = kVP9EncodePerfTestVectors[i].frames;
145 vpx_usec_timer_start(&t); 158 const char *video_name = kVP9EncodePerfTestVectors[i].name;
159 libvpx_test::I420VideoSource video(
160 video_name,
161 kVP9EncodePerfTestVectors[i].width,
162 kVP9EncodePerfTestVectors[i].height,
163 timebase.den, timebase.num, 0,
164 kVP9EncodePerfTestVectors[i].frames);
165 set_speed(kEncodePerfTestSpeeds[j]);
146 166
147 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); 167 vpx_usec_timer t;
168 vpx_usec_timer_start(&t);
148 169
149 vpx_usec_timer_mark(&t); 170 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
150 const double elapsed_secs = vpx_usec_timer_elapsed(&t) / kUsecsInSec;
151 const double fps = frames / elapsed_secs;
152 const double minimum_psnr = min_psnr();
153 171
154 printf("{\n"); 172 vpx_usec_timer_mark(&t);
155 printf("\t\"type\" : \"encode_perf_test\",\n"); 173 const double elapsed_secs = vpx_usec_timer_elapsed(&t) / kUsecsInSec;
156 printf("\t\"version\" : \"%s\",\n", VERSION_STRING_NOSP); 174 const double fps = frames / elapsed_secs;
157 printf("\t\"videoName\" : \"%s\",\n", video_name); 175 const double minimum_psnr = min_psnr();
158 printf("\t\"encodeTimeSecs\" : %f,\n", elapsed_secs); 176 std::string display_name(video_name);
159 printf("\t\"totalFrames\" : %u,\n", frames); 177 if (kEncodePerfTestThreads[k] > 1) {
160 printf("\t\"framesPerSecond\" : %f,\n", fps); 178 char thread_count[32];
161 printf("\t\"minPsnr\" : %f,\n", minimum_psnr); 179 snprintf(thread_count, sizeof(thread_count), "_t-%d",
162 printf("\t\"speed\" : %d\n", kEncodePerfTestSpeeds[j]); 180 kEncodePerfTestThreads[k]);
163 printf("}\n"); 181 display_name += thread_count;
182 }
183
184 printf("{\n");
185 printf("\t\"type\" : \"encode_perf_test\",\n");
186 printf("\t\"version\" : \"%s\",\n", VERSION_STRING_NOSP);
187 printf("\t\"videoName\" : \"%s\",\n", display_name.c_str());
188 printf("\t\"encodeTimeSecs\" : %f,\n", elapsed_secs);
189 printf("\t\"totalFrames\" : %u,\n", frames);
190 printf("\t\"framesPerSecond\" : %f,\n", fps);
191 printf("\t\"minPsnr\" : %f,\n", minimum_psnr);
192 printf("\t\"speed\" : %d,\n", kEncodePerfTestSpeeds[j]);
193 printf("\t\"threads\" : %d\n", kEncodePerfTestThreads[k]);
194 printf("}\n");
195 }
164 } 196 }
165 } 197 }
166 } 198 }
167 199
168 VP9_INSTANTIATE_TEST_CASE( 200 VP9_INSTANTIATE_TEST_CASE(
169 VP9EncodePerfTest, ::testing::Values(::libvpx_test::kRealTime)); 201 VP9EncodePerfTest, ::testing::Values(::libvpx_test::kRealTime));
170 } // namespace 202 } // namespace
OLDNEW
« no previous file with comments | « source/libvpx/test/decode_test_driver.cc ('k') | source/libvpx/test/encode_test_driver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698