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

Side by Side Diff: source/libvpx/test/vp9_ethread_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/vp9_end_to_end_test.cc ('k') | source/libvpx/test/vp9_quantize_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
(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
11 #include <string>
12 #include <vector>
13 #include "third_party/googletest/src/include/gtest/gtest.h"
14 #include "test/codec_factory.h"
15 #include "test/encode_test_driver.h"
16 #include "test/i420_video_source.h"
17 #include "test/util.h"
18 #include "test/md5_helper.h"
19
20 namespace {
21 class VP9EncoderThreadTest
22 : public ::libvpx_test::EncoderTest,
23 public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> {
24 protected:
25 VP9EncoderThreadTest()
26 : EncoderTest(GET_PARAM(0)),
27 tiles_(2),
28 encoding_mode_(GET_PARAM(1)),
29 set_cpu_used_(GET_PARAM(2)) {
30 init_flags_ = VPX_CODEC_USE_PSNR;
31 vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t();
32 cfg.w = 1280;
33 cfg.h = 720;
34 decoder_ = codec_->CreateDecoder(cfg, 0);
35
36 md5_.clear();
37 }
38 virtual ~VP9EncoderThreadTest() {
39 delete decoder_;
40 }
41
42 virtual void SetUp() {
43 InitializeConfig();
44 SetMode(encoding_mode_);
45
46 if (encoding_mode_ != ::libvpx_test::kRealTime) {
47 cfg_.g_lag_in_frames = 3;
48 cfg_.rc_end_usage = VPX_VBR;
49 cfg_.rc_2pass_vbr_minsection_pct = 5;
50 cfg_.rc_2pass_vbr_minsection_pct = 2000;
51 } else {
52 cfg_.g_lag_in_frames = 0;
53 cfg_.rc_end_usage = VPX_CBR;
54 cfg_.g_error_resilient = 1;
55 }
56 cfg_.rc_max_quantizer = 56;
57 cfg_.rc_min_quantizer = 0;
58 }
59
60 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
61 ::libvpx_test::Encoder *encoder) {
62 if (video->frame() == 0) {
63 // Encode 4 column tiles.
64 encoder->Control(VP9E_SET_TILE_COLUMNS, tiles_);
65 encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
66 if (encoding_mode_ != ::libvpx_test::kRealTime) {
67 encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
68 encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7);
69 encoder->Control(VP8E_SET_ARNR_STRENGTH, 5);
70 encoder->Control(VP8E_SET_ARNR_TYPE, 3);
71 } else {
72 encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 0);
73 }
74 }
75 }
76
77 virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
78 const vpx_codec_err_t res = decoder_->DecodeFrame(
79 reinterpret_cast<uint8_t*>(pkt->data.frame.buf), pkt->data.frame.sz);
80 if (res != VPX_CODEC_OK) {
81 abort_ = true;
82 ASSERT_EQ(VPX_CODEC_OK, res);
83 }
84 const vpx_image_t *img = decoder_->GetDxData().Next();
85
86 if (img) {
87 ::libvpx_test::MD5 md5_res;
88 md5_res.Add(img);
89 md5_.push_back(md5_res.Get());
90 }
91 }
92
93 int tiles_;
94 ::libvpx_test::TestMode encoding_mode_;
95 int set_cpu_used_;
96 ::libvpx_test::Decoder *decoder_;
97 std::vector<std::string> md5_;
98 };
99
100 TEST_P(VP9EncoderThreadTest, EncoderResultTest) {
101 std::vector<std::string> single_thr_md5, multi_thr_md5;
102
103 ::libvpx_test::I420VideoSource video("niklas_1280_720_30.yuv", 1280, 720,
104 50, 1, 15, 20);
105
106 cfg_.rc_target_bitrate = 1000;
107
108 // Encode using single thread.
109 cfg_.g_threads = 1;
110 init_flags_ = VPX_CODEC_USE_PSNR;
111 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
112 single_thr_md5 = md5_;
113 md5_.clear();
114
115 // Encode using multiple threads.
116 cfg_.g_threads = 4;
117 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
118 multi_thr_md5 = md5_;
119 md5_.clear();
120
121 // Compare to check if two vectors are equal.
122 ASSERT_EQ(single_thr_md5, multi_thr_md5);
123 }
124
125 VP9_INSTANTIATE_TEST_CASE(
126 VP9EncoderThreadTest,
127 ::testing::Values(::libvpx_test::kTwoPassGood, ::libvpx_test::kOnePassGood,
128 ::libvpx_test::kRealTime),
129 ::testing::Range(1, 9));
130 } // namespace
OLDNEW
« no previous file with comments | « source/libvpx/test/vp9_end_to_end_test.cc ('k') | source/libvpx/test/vp9_quantize_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698