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

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

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

Powered by Google App Engine
This is Rietveld 408576698