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

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

Issue 554673004: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 3 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/active_map_test.cc ('k') | source/libvpx/test/dct16x16_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
1 /* 1 /*
2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 "./vpx_config.h" 10 #include "./vpx_config.h"
(...skipping 24 matching lines...) Expand all
35 last_pts_ = 0; 35 last_pts_ = 0;
36 bits_in_buffer_model_ = cfg_.rc_target_bitrate * cfg_.rc_buf_initial_sz; 36 bits_in_buffer_model_ = cfg_.rc_target_bitrate * cfg_.rc_buf_initial_sz;
37 frame_number_ = 0; 37 frame_number_ = 0;
38 first_drop_ = 0; 38 first_drop_ = 0;
39 bits_total_ = 0; 39 bits_total_ = 0;
40 duration_ = 0.0; 40 duration_ = 0.0;
41 } 41 }
42 42
43 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, 43 virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
44 ::libvpx_test::Encoder *encoder) { 44 ::libvpx_test::Encoder *encoder) {
45 if (video->frame() == 1) {
46 encoder->Control(VP8E_SET_NOISE_SENSITIVITY, denoiser_on_);
47 }
45 const vpx_rational_t tb = video->timebase(); 48 const vpx_rational_t tb = video->timebase();
46 timebase_ = static_cast<double>(tb.num) / tb.den; 49 timebase_ = static_cast<double>(tb.num) / tb.den;
47 duration_ = 0; 50 duration_ = 0;
48 } 51 }
49 52
50 virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) { 53 virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
51 // Time since last timestamp = duration. 54 // Time since last timestamp = duration.
52 vpx_codec_pts_t duration = pkt->data.frame.pts - last_pts_; 55 vpx_codec_pts_t duration = pkt->data.frame.pts - last_pts_;
53 56
54 // TODO(jimbankoski): Remove these lines when the issue: 57 // TODO(jimbankoski): Remove these lines when the issue:
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 vpx_codec_pts_t last_pts_; 116 vpx_codec_pts_t last_pts_;
114 int64_t bits_in_buffer_model_; 117 int64_t bits_in_buffer_model_;
115 double timebase_; 118 double timebase_;
116 int frame_number_; 119 int frame_number_;
117 vpx_codec_pts_t first_drop_; 120 vpx_codec_pts_t first_drop_;
118 int64_t bits_total_; 121 int64_t bits_total_;
119 double duration_; 122 double duration_;
120 double file_datarate_; 123 double file_datarate_;
121 double effective_datarate_; 124 double effective_datarate_;
122 size_t bits_in_last_frame_; 125 size_t bits_in_last_frame_;
126 int denoiser_on_;
123 }; 127 };
124 128
125 TEST_P(DatarateTestLarge, BasicBufferModel) { 129 // Check basic datarate targeting, for a single bitrate, but loop over the
130 // various denoiser settings.
131 TEST_P(DatarateTestLarge, DenoiserLevels) {
126 cfg_.rc_buf_initial_sz = 500; 132 cfg_.rc_buf_initial_sz = 500;
127 cfg_.rc_dropframe_thresh = 1; 133 cfg_.rc_dropframe_thresh = 1;
128 cfg_.rc_max_quantizer = 56; 134 cfg_.rc_max_quantizer = 56;
135 cfg_.rc_end_usage = VPX_CBR;
136 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
137 30, 1, 0, 140);
138 for (int j = 1; j < 5; ++j) {
139 // Run over the denoiser levels.
140 // For the temporal denoiser (#if CONFIG_TEMPORAL_DENOISING) the level j
141 // refers to the 4 denoiser modes: denoiserYonly, denoiserOnYUV,
142 // denoiserOnAggressive, and denoiserOnAdaptive.
143 // For the spatial denoiser (if !CONFIG_TEMPORAL_DENOISING), the level j
144 // refers to the blur thresholds: 20, 40, 60 80.
145 // The j = 0 case (denoiser off) is covered in the tests below.
146 denoiser_on_ = j;
147 cfg_.rc_target_bitrate = 300;
148 ResetModel();
149 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
150 ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
151 << " The datarate for the file exceeds the target!";
152
153 ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.3)
154 << " The datarate for the file missed the target!";
155 }
156 }
157
158 TEST_P(DatarateTestLarge, BasicBufferModel) {
159 denoiser_on_ = 0;
160 cfg_.rc_buf_initial_sz = 500;
161 cfg_.rc_dropframe_thresh = 1;
162 cfg_.rc_max_quantizer = 56;
129 cfg_.rc_end_usage = VPX_CBR; 163 cfg_.rc_end_usage = VPX_CBR;
130 // 2 pass cbr datarate control has a bug hidden by the small # of 164 // 2 pass cbr datarate control has a bug hidden by the small # of
131 // frames selected in this encode. The problem is that even if the buffer is 165 // frames selected in this encode. The problem is that even if the buffer is
132 // negative we produce a keyframe on a cutscene. Ignoring datarate 166 // negative we produce a keyframe on a cutscene. Ignoring datarate
133 // constraints 167 // constraints
134 // TODO(jimbankoski): ( Fix when issue 168 // TODO(jimbankoski): ( Fix when issue
135 // http://code.google.com/p/webm/issues/detail?id=495 is addressed. ) 169 // http://code.google.com/p/webm/issues/detail?id=495 is addressed. )
136 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, 170 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
137 30, 1, 0, 140); 171 30, 1, 0, 140);
138 172
139 // There is an issue for low bitrates in real-time mode, where the 173 // There is an issue for low bitrates in real-time mode, where the
140 // effective_datarate slightly overshoots the target bitrate. 174 // effective_datarate slightly overshoots the target bitrate.
141 // This is same the issue as noted about (#495). 175 // This is same the issue as noted about (#495).
142 // TODO(jimbankoski/marpan): Update test to run for lower bitrates (< 100), 176 // TODO(jimbankoski/marpan): Update test to run for lower bitrates (< 100),
143 // when the issue is resolved. 177 // when the issue is resolved.
144 for (int i = 100; i < 800; i += 200) { 178 for (int i = 100; i < 800; i += 200) {
145 cfg_.rc_target_bitrate = i; 179 cfg_.rc_target_bitrate = i;
146 ResetModel(); 180 ResetModel();
147 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); 181 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
148 ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95) 182 ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
149 << " The datarate for the file exceeds the target!"; 183 << " The datarate for the file exceeds the target!";
150 184
151 ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.3) 185 ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.3)
152 << " The datarate for the file missed the target!"; 186 << " The datarate for the file missed the target!";
153 } 187 }
154 } 188 }
155 189
156 TEST_P(DatarateTestLarge, ChangingDropFrameThresh) { 190 TEST_P(DatarateTestLarge, ChangingDropFrameThresh) {
191 denoiser_on_ = 0;
157 cfg_.rc_buf_initial_sz = 500; 192 cfg_.rc_buf_initial_sz = 500;
158 cfg_.rc_max_quantizer = 36; 193 cfg_.rc_max_quantizer = 36;
159 cfg_.rc_end_usage = VPX_CBR; 194 cfg_.rc_end_usage = VPX_CBR;
160 cfg_.rc_target_bitrate = 200; 195 cfg_.rc_target_bitrate = 200;
161 cfg_.kf_mode = VPX_KF_DISABLED; 196 cfg_.kf_mode = VPX_KF_DISABLED;
162 197
163 const int frame_count = 40; 198 const int frame_count = 40;
164 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, 199 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
165 30, 1, 0, frame_count); 200 30, 1, 0, frame_count);
166 201
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 ASSERT_LE(num_drops_, 130); 614 ASSERT_LE(num_drops_, 130);
580 } 615 }
581 } 616 }
582 617
583 VP8_INSTANTIATE_TEST_CASE(DatarateTestLarge, ALL_TEST_MODES); 618 VP8_INSTANTIATE_TEST_CASE(DatarateTestLarge, ALL_TEST_MODES);
584 VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9Large, 619 VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9Large,
585 ::testing::Values(::libvpx_test::kOnePassGood, 620 ::testing::Values(::libvpx_test::kOnePassGood,
586 ::libvpx_test::kRealTime), 621 ::libvpx_test::kRealTime),
587 ::testing::Range(2, 7)); 622 ::testing::Range(2, 7));
588 } // namespace 623 } // namespace
OLDNEW
« no previous file with comments | « source/libvpx/test/active_map_test.cc ('k') | source/libvpx/test/dct16x16_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698