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

Side by Side Diff: webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.h

Issue 2707763005: Remove codec setting members in VideoProcessorIntegrationTest. Use settings in CodecConfigPars dire… (Closed)
Patch Set: rebase Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | 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 WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC 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
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 InitializeAndroidObjects(); 135 InitializeAndroidObjects();
136 136
137 external_encoder_factory_.reset( 137 external_encoder_factory_.reset(
138 new webrtc_jni::MediaCodecVideoEncoderFactory()); 138 new webrtc_jni::MediaCodecVideoEncoderFactory());
139 external_decoder_factory_.reset( 139 external_decoder_factory_.reset(
140 new webrtc_jni::MediaCodecVideoDecoderFactory()); 140 new webrtc_jni::MediaCodecVideoDecoderFactory());
141 #endif 141 #endif
142 } 142 }
143 virtual ~VideoProcessorIntegrationTest() = default; 143 virtual ~VideoProcessorIntegrationTest() = default;
144 144
145 void SetUpCodecConfig(const std::string& filename, 145 void SetUpCodecConfig(const CodecConfigPars& process) {
146 int width, 146 if (process.hw_codec) {
147 int height,
148 bool verbose_logging) {
149 if (hw_codec_) {
150 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) 147 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED)
151 #if defined(WEBRTC_ANDROID) 148 #if defined(WEBRTC_ANDROID)
152 // In general, external codecs should be destroyed by the factories that 149 // In general, external codecs should be destroyed by the factories that
153 // allocated them. For the particular case of the Android 150 // allocated them. For the particular case of the Android
154 // MediaCodecVideo{En,De}coderFactory's, however, it turns out that it is 151 // MediaCodecVideo{En,De}coderFactory's, however, it turns out that it is
155 // fine for the std::unique_ptr to destroy the owned codec directly. 152 // fine for the std::unique_ptr to destroy the owned codec directly.
156 if (codec_type_ == kVideoCodecH264) { 153 if (process.codec_type == kVideoCodecH264) {
sprang_webrtc 2017/02/21 15:21:35 While you're here, can you switch (ehm) this to a
åsapersson 2017/02/21 15:49:33 Done.
157 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( 154 encoder_.reset(external_encoder_factory_->CreateVideoEncoder(
158 cricket::VideoCodec(cricket::kH264CodecName))); 155 cricket::VideoCodec(cricket::kH264CodecName)));
159 decoder_.reset( 156 decoder_.reset(
160 external_decoder_factory_->CreateVideoDecoder(kVideoCodecH264)); 157 external_decoder_factory_->CreateVideoDecoder(kVideoCodecH264));
161 } else if (codec_type_ == kVideoCodecVP8) { 158 } else if (process.codec_type == kVideoCodecVP8) {
162 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( 159 encoder_.reset(external_encoder_factory_->CreateVideoEncoder(
163 cricket::VideoCodec(cricket::kVp8CodecName))); 160 cricket::VideoCodec(cricket::kVp8CodecName)));
164 decoder_.reset( 161 decoder_.reset(
165 external_decoder_factory_->CreateVideoDecoder(kVideoCodecVP8)); 162 external_decoder_factory_->CreateVideoDecoder(kVideoCodecVP8));
166 } else if (codec_type_ == kVideoCodecVP9) { 163 } else if (process.codec_type == kVideoCodecVP9) {
167 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( 164 encoder_.reset(external_encoder_factory_->CreateVideoEncoder(
168 cricket::VideoCodec(cricket::kVp9CodecName))); 165 cricket::VideoCodec(cricket::kVp9CodecName)));
169 decoder_.reset( 166 decoder_.reset(
170 external_decoder_factory_->CreateVideoDecoder(kVideoCodecVP9)); 167 external_decoder_factory_->CreateVideoDecoder(kVideoCodecVP9));
171 } 168 }
172 #elif defined(WEBRTC_IOS) 169 #elif defined(WEBRTC_IOS)
173 RTC_DCHECK_EQ(kVideoCodecH264, codec_type_) 170 RTC_DCHECK_EQ(kVideoCodecH264, process.codec_type)
174 << "iOS HW codecs only support H264."; 171 << "iOS HW codecs only support H264.";
175 encoder_.reset(new H264VideoToolboxEncoder( 172 encoder_.reset(new H264VideoToolboxEncoder(
176 cricket::VideoCodec(cricket::kH264CodecName))); 173 cricket::VideoCodec(cricket::kH264CodecName)));
177 decoder_.reset(new H264VideoToolboxDecoder()); 174 decoder_.reset(new H264VideoToolboxDecoder());
178 #else 175 #else
179 RTC_NOTREACHED() << "Only support HW codecs on Android and iOS."; 176 RTC_NOTREACHED() << "Only support HW codecs on Android and iOS.";
180 #endif 177 #endif
181 #endif // WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED 178 #endif // WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED
182 RTC_DCHECK(encoder_) << "HW encoder not successfully created."; 179 RTC_DCHECK(encoder_) << "HW encoder not successfully created.";
183 RTC_DCHECK(decoder_) << "HW decoder not successfully created."; 180 RTC_DCHECK(decoder_) << "HW decoder not successfully created.";
184 } else { 181 } else {
185 // SW codecs. 182 // SW codecs.
186 if (codec_type_ == kVideoCodecH264) { 183 if (process.codec_type == kVideoCodecH264) {
sprang_webrtc 2017/02/21 15:21:35 dito
åsapersson 2017/02/21 15:49:33 Done.
187 encoder_.reset( 184 encoder_.reset(
188 H264Encoder::Create(cricket::VideoCodec(cricket::kH264CodecName))); 185 H264Encoder::Create(cricket::VideoCodec(cricket::kH264CodecName)));
189 decoder_.reset(H264Decoder::Create()); 186 decoder_.reset(H264Decoder::Create());
190 } else if (codec_type_ == kVideoCodecVP8) { 187 } else if (process.codec_type == kVideoCodecVP8) {
191 encoder_.reset(VP8Encoder::Create()); 188 encoder_.reset(VP8Encoder::Create());
192 decoder_.reset(VP8Decoder::Create()); 189 decoder_.reset(VP8Decoder::Create());
193 } else if (codec_type_ == kVideoCodecVP9) { 190 } else if (process.codec_type == kVideoCodecVP9) {
194 encoder_.reset(VP9Encoder::Create()); 191 encoder_.reset(VP9Encoder::Create());
195 decoder_.reset(VP9Decoder::Create()); 192 decoder_.reset(VP9Decoder::Create());
196 } 193 }
197 } 194 }
198 195
199 VideoCodingModule::Codec(codec_type_, &codec_settings_); 196 VideoCodingModule::Codec(process.codec_type, &codec_settings_);
200 197
201 // Configure input filename. 198 // Configure input filename.
202 config_.input_filename = test::ResourcePath(filename, "yuv"); 199 config_.input_filename = test::ResourcePath(process.filename, "yuv");
203 if (verbose_logging) 200 if (process.verbose_logging)
204 printf("Filename: %s\n", filename.c_str()); 201 printf("Filename: %s\n", process.filename.c_str());
205 // Generate an output filename in a safe way. 202 // Generate an output filename in a safe way.
206 config_.output_filename = test::TempFilename( 203 config_.output_filename = test::TempFilename(
207 test::OutputPath(), "videoprocessor_integrationtest"); 204 test::OutputPath(), "videoprocessor_integrationtest");
208 config_.frame_length_in_bytes = CalcBufferSize(kI420, width, height); 205 config_.frame_length_in_bytes =
209 config_.verbose = verbose_logging; 206 CalcBufferSize(kI420, process.width, process.height);
207 config_.verbose = process.verbose_logging;
210 // Only allow encoder/decoder to use single core, for predictability. 208 // Only allow encoder/decoder to use single core, for predictability.
211 config_.use_single_core = true; 209 config_.use_single_core = true;
212 // Key frame interval and packet loss are set for each test. 210 // Key frame interval and packet loss are set for each test.
213 config_.keyframe_interval = key_frame_interval_; 211 config_.keyframe_interval = process.key_frame_interval;
214 config_.networking_config.packet_loss_probability = packet_loss_; 212 config_.networking_config.packet_loss_probability = packet_loss_;
215 213
216 // Configure codec settings. 214 // Configure codec settings.
217 config_.codec_settings = &codec_settings_; 215 config_.codec_settings = &codec_settings_;
218 config_.codec_settings->startBitrate = start_bitrate_; 216 config_.codec_settings->startBitrate = start_bitrate_;
219 config_.codec_settings->width = width; 217 config_.codec_settings->width = process.width;
220 config_.codec_settings->height = height; 218 config_.codec_settings->height = process.height;
221 219
222 // These features may be set depending on the test. 220 // These features may be set depending on the test.
223 switch (config_.codec_settings->codecType) { 221 switch (config_.codec_settings->codecType) {
224 case kVideoCodecH264: 222 case kVideoCodecH264:
225 config_.codec_settings->H264()->frameDroppingOn = frame_dropper_on_; 223 config_.codec_settings->H264()->frameDroppingOn =
224 process.frame_dropper_on;
226 config_.codec_settings->H264()->keyFrameInterval = 225 config_.codec_settings->H264()->keyFrameInterval =
227 kBaseKeyFrameInterval; 226 kBaseKeyFrameInterval;
228 break; 227 break;
229 case kVideoCodecVP8: 228 case kVideoCodecVP8:
230 config_.codec_settings->VP8()->errorConcealmentOn = 229 config_.codec_settings->VP8()->errorConcealmentOn =
231 error_concealment_on_; 230 process.error_concealment_on;
232 config_.codec_settings->VP8()->denoisingOn = denoising_on_; 231 config_.codec_settings->VP8()->denoisingOn = process.denoising_on;
233 config_.codec_settings->VP8()->numberOfTemporalLayers = 232 config_.codec_settings->VP8()->numberOfTemporalLayers =
234 num_temporal_layers_; 233 num_temporal_layers_;
235 config_.codec_settings->VP8()->frameDroppingOn = frame_dropper_on_; 234 config_.codec_settings->VP8()->frameDroppingOn =
236 config_.codec_settings->VP8()->automaticResizeOn = spatial_resize_on_; 235 process.frame_dropper_on;
236 config_.codec_settings->VP8()->automaticResizeOn =
237 process.spatial_resize_on;
237 config_.codec_settings->VP8()->keyFrameInterval = kBaseKeyFrameInterval; 238 config_.codec_settings->VP8()->keyFrameInterval = kBaseKeyFrameInterval;
238 break; 239 break;
239 case kVideoCodecVP9: 240 case kVideoCodecVP9:
240 config_.codec_settings->VP9()->denoisingOn = denoising_on_; 241 config_.codec_settings->VP9()->denoisingOn = process.denoising_on;
241 config_.codec_settings->VP9()->numberOfTemporalLayers = 242 config_.codec_settings->VP9()->numberOfTemporalLayers =
242 num_temporal_layers_; 243 num_temporal_layers_;
243 config_.codec_settings->VP9()->frameDroppingOn = frame_dropper_on_; 244 config_.codec_settings->VP9()->frameDroppingOn =
244 config_.codec_settings->VP9()->automaticResizeOn = spatial_resize_on_; 245 process.frame_dropper_on;
246 config_.codec_settings->VP9()->automaticResizeOn =
247 process.spatial_resize_on;
245 config_.codec_settings->VP9()->keyFrameInterval = kBaseKeyFrameInterval; 248 config_.codec_settings->VP9()->keyFrameInterval = kBaseKeyFrameInterval;
246 break; 249 break;
247 default: 250 default:
248 RTC_NOTREACHED(); 251 RTC_NOTREACHED();
249 break; 252 break;
250 } 253 }
251 frame_reader_.reset(new test::FrameReaderImpl( 254 frame_reader_.reset(new test::FrameReaderImpl(
252 config_.input_filename, config_.codec_settings->width, 255 config_.input_filename, config_.codec_settings->width,
253 config_.codec_settings->height)); 256 config_.codec_settings->height));
254 frame_writer_.reset(new test::FrameWriterImpl( 257 frame_writer_.reset(new test::FrameWriterImpl(
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 frame_rate_layer_[2] = frame_rate_ / 2.0f; 444 frame_rate_layer_[2] = frame_rate_ / 2.0f;
442 } 445 }
443 } 446 }
444 447
445 // Processes all frames in the clip and verifies the result. 448 // Processes all frames in the clip and verifies the result.
446 void ProcessFramesAndVerify(QualityMetrics quality_metrics, 449 void ProcessFramesAndVerify(QualityMetrics quality_metrics,
447 RateProfile rate_profile, 450 RateProfile rate_profile,
448 CodecConfigPars process, 451 CodecConfigPars process,
449 RateControlMetrics* rc_metrics) { 452 RateControlMetrics* rc_metrics) {
450 // Codec/config settings. 453 // Codec/config settings.
451 codec_type_ = process.codec_type;
452 hw_codec_ = process.hw_codec;
453 start_bitrate_ = rate_profile.target_bit_rate[0]; 454 start_bitrate_ = rate_profile.target_bit_rate[0];
454 packet_loss_ = process.packet_loss; 455 packet_loss_ = process.packet_loss;
455 key_frame_interval_ = process.key_frame_interval;
456 num_temporal_layers_ = process.num_temporal_layers; 456 num_temporal_layers_ = process.num_temporal_layers;
457 error_concealment_on_ = process.error_concealment_on; 457 SetUpCodecConfig(process);
458 denoising_on_ = process.denoising_on;
459 frame_dropper_on_ = process.frame_dropper_on;
460 spatial_resize_on_ = process.spatial_resize_on;
461 SetUpCodecConfig(process.filename, process.width, process.height,
462 process.verbose_logging);
463 // Update the layers and the codec with the initial rates. 458 // Update the layers and the codec with the initial rates.
464 bit_rate_ = rate_profile.target_bit_rate[0]; 459 bit_rate_ = rate_profile.target_bit_rate[0];
465 frame_rate_ = rate_profile.input_frame_rate[0]; 460 frame_rate_ = rate_profile.input_frame_rate[0];
466 SetLayerRates(); 461 SetLayerRates();
467 // Set the initial target size for key frame. 462 // Set the initial target size for key frame.
468 target_size_key_frame_initial_ = 463 target_size_key_frame_initial_ =
469 0.5 * kInitialBufferSize * bit_rate_layer_[0]; 464 0.5 * kInitialBufferSize * bit_rate_layer_[0];
470 processor_->SetRates(bit_rate_, frame_rate_); 465 processor_->SetRates(bit_rate_, frame_rate_);
471 466
472 // Process each frame, up to |num_frames|. 467 // Process each frame, up to |num_frames|.
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 int bit_rate_; 666 int bit_rate_;
672 int frame_rate_; 667 int frame_rate_;
673 int layer_; 668 int layer_;
674 float target_size_key_frame_initial_; 669 float target_size_key_frame_initial_;
675 float target_size_key_frame_; 670 float target_size_key_frame_;
676 float sum_key_frame_size_mismatch_; 671 float sum_key_frame_size_mismatch_;
677 int num_key_frames_; 672 int num_key_frames_;
678 float start_bitrate_; 673 float start_bitrate_;
679 674
680 // Codec and network settings. 675 // Codec and network settings.
681 VideoCodecType codec_type_;
682 bool hw_codec_;
683 float packet_loss_; 676 float packet_loss_;
684 int num_temporal_layers_; 677 int num_temporal_layers_;
685 int key_frame_interval_;
686 bool error_concealment_on_;
687 bool denoising_on_;
688 bool frame_dropper_on_;
689 bool spatial_resize_on_;
690 }; 678 };
691 679
692 } // namespace test 680 } // namespace test
693 } // namespace webrtc 681 } // namespace webrtc
694 682
695 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES T_H_ 683 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES T_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698