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

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

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

Powered by Google App Engine
This is Rietveld 408576698