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