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

Side by Side Diff: source/libvpx/test/encode_perf_test.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/decode_to_md5.sh ('k') | source/libvpx/test/examples.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
3 *
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.
9 */
10 #include "third_party/googletest/src/include/gtest/gtest.h"
11 #include "./vpx_config.h"
12 #include "./vpx_version.h"
13 #include "test/codec_factory.h"
14 #include "test/encode_test_driver.h"
15 #include "test/i420_video_source.h"
16 #include "test/util.h"
17 #include "test/y4m_video_source.h"
18 #include "vpx_ports/vpx_timer.h"
19
20 namespace {
21
22 const int kMaxPsnr = 100;
23 const double kUsecsInSec = 1000000.0;
24
25 struct EncodePerfTestVideo {
26 EncodePerfTestVideo(const char *name_, uint32_t width_, uint32_t height_,
27 uint32_t bitrate_, int frames_)
28 : name(name_),
29 width(width_),
30 height(height_),
31 bitrate(bitrate_),
32 frames(frames_) {}
33 const char *name;
34 uint32_t width;
35 uint32_t height;
36 uint32_t bitrate;
37 int frames;
38 };
39
40 const EncodePerfTestVideo kVP9EncodePerfTestVectors[] = {
41 EncodePerfTestVideo("desktop_640_360_30.yuv", 640, 360, 200, 2484),
42 EncodePerfTestVideo("kirland_640_480_30.yuv", 640, 480, 200, 300),
43 EncodePerfTestVideo("macmarcomoving_640_480_30.yuv", 640, 480, 200, 987),
44 EncodePerfTestVideo("macmarcostationary_640_480_30.yuv", 640, 480, 200, 718),
45 EncodePerfTestVideo("niklas_640_480_30.yuv", 640, 480, 200, 471),
46 EncodePerfTestVideo("tacomanarrows_640_480_30.yuv", 640, 480, 200, 300),
47 EncodePerfTestVideo("tacomasmallcameramovement_640_480_30.yuv",
48 640, 480, 200, 300),
49 EncodePerfTestVideo("thaloundeskmtg_640_480_30.yuv", 640, 480, 200, 300),
50 EncodePerfTestVideo("niklas_1280_720_30.yuv", 1280, 720, 600, 470),
51 };
52
53 const int kEncodePerfTestSpeeds[] = { 5, 6, 7, 12 };
54
55 #define NELEMENTS(x) (sizeof((x)) / sizeof((x)[0]))
56
57 class VP9EncodePerfTest
58 : public ::libvpx_test::EncoderTest,
59 public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> {
60 protected:
61 VP9EncodePerfTest()
62 : EncoderTest(GET_PARAM(0)),
63 min_psnr_(kMaxPsnr),
64 nframes_(0),
65 encoding_mode_(GET_PARAM(1)),
66 speed_(0) {}
67
68 virtual ~VP9EncodePerfTest() {}
69
70 virtual void SetUp() {
71 InitializeConfig();
72 SetMode(encoding_mode_);
73
74 cfg_.g_lag_in_frames = 0;
75 cfg_.rc_min_quantizer = 2;
76 cfg_.rc_max_quantizer = 56;
77 cfg_.rc_dropframe_thresh = 0;
78 cfg_.rc_undershoot_pct = 50;
79 cfg_.rc_overshoot_pct = 50;
80 cfg_.rc_buf_sz = 1000;
81 cfg_.rc_buf_initial_sz = 500;
82 cfg_.rc_buf_optimal_sz = 600;
83 cfg_.rc_resize_allowed = 0;
84 cfg_.rc_end_usage = VPX_CBR;
85 }
86
87 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
88 ::libvpx_test::Encoder *encoder) {
89 if (video->frame() == 1) {
90 encoder->Control(VP8E_SET_CPUUSED, speed_);
91 }
92 }
93
94 virtual void BeginPassHook(unsigned int /*pass*/) {
95 min_psnr_ = kMaxPsnr;
96 nframes_ = 0;
97 }
98
99 virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) {
100 if (pkt->data.psnr.psnr[0] < min_psnr_) {
101 min_psnr_= pkt->data.psnr.psnr[0];
102 }
103 }
104
105 // for performance reasons don't decode
106 virtual bool DoDecode() { return 0; }
107
108 double min_psnr() const {
109 return min_psnr_;
110 }
111
112 void set_speed(unsigned int speed) {
113 speed_ = speed;
114 }
115
116 private:
117 double min_psnr_;
118 unsigned int nframes_;
119 libvpx_test::TestMode encoding_mode_;
120 unsigned speed_;
121 };
122
123 TEST_P(VP9EncodePerfTest, PerfTest) {
124 for (size_t i = 0; i < NELEMENTS(kVP9EncodePerfTestVectors); ++i) {
125 for (size_t j = 0; j < NELEMENTS(kEncodePerfTestSpeeds); ++j) {
126 SetUp();
127
128 const vpx_rational timebase = { 33333333, 1000000000 };
129 cfg_.g_timebase = timebase;
130 cfg_.rc_target_bitrate = kVP9EncodePerfTestVectors[i].bitrate;
131
132 init_flags_ = VPX_CODEC_USE_PSNR;
133
134 const unsigned frames = kVP9EncodePerfTestVectors[i].frames;
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
144 vpx_usec_timer t;
145 vpx_usec_timer_start(&t);
146
147 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
148
149 vpx_usec_timer_mark(&t);
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
154 printf("{\n");
155 printf("\t\"type\" : \"encode_perf_test\",\n");
156 printf("\t\"version\" : \"%s\",\n", VERSION_STRING_NOSP);
157 printf("\t\"videoName\" : \"%s\",\n", video_name);
158 printf("\t\"encodeTimeSecs\" : %f,\n", elapsed_secs);
159 printf("\t\"totalFrames\" : %u,\n", frames);
160 printf("\t\"framesPerSecond\" : %f,\n", fps);
161 printf("\t\"minPsnr\" : %f,\n", minimum_psnr);
162 printf("\t\"speed\" : %d\n", kEncodePerfTestSpeeds[j]);
163 printf("}\n");
164 }
165 }
166 }
167
168 VP9_INSTANTIATE_TEST_CASE(
169 VP9EncodePerfTest, ::testing::Values(::libvpx_test::kRealTime));
170 } // namespace
OLDNEW
« no previous file with comments | « source/libvpx/test/decode_to_md5.sh ('k') | source/libvpx/test/examples.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698