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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 // Default sequence is foreman (CIF): may be better to use VGA for resize test. | 57 // Default sequence is foreman (CIF): may be better to use VGA for resize test. |
58 const int kCifWidth = 352; | 58 const int kCifWidth = 352; |
59 const int kCifHeight = 288; | 59 const int kCifHeight = 288; |
60 const char kFilenameForemanCif[] = "foreman_cif"; | 60 const char kFilenameForemanCif[] = "foreman_cif"; |
61 | 61 |
62 // Codec and network settings. | 62 // Codec and network settings. |
63 struct CodecConfigPars { | 63 struct CodecConfigPars { |
64 VideoCodecType codec_type; | 64 VideoCodecType codec_type; |
65 bool hw_codec; | 65 bool hw_codec; |
| 66 bool use_single_core; |
66 float packet_loss; | 67 float packet_loss; |
67 int num_temporal_layers; | 68 int num_temporal_layers; |
68 int key_frame_interval; | 69 int key_frame_interval; |
69 bool error_concealment_on; | 70 bool error_concealment_on; |
70 bool denoising_on; | 71 bool denoising_on; |
71 bool frame_dropper_on; | 72 bool frame_dropper_on; |
72 bool spatial_resize_on; | 73 bool spatial_resize_on; |
73 int width; | 74 int width; |
74 int height; | 75 int height; |
75 std::string filename; | 76 std::string filename; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 InitializeAndroidObjects(); | 136 InitializeAndroidObjects(); |
136 | 137 |
137 external_encoder_factory_.reset( | 138 external_encoder_factory_.reset( |
138 new webrtc_jni::MediaCodecVideoEncoderFactory()); | 139 new webrtc_jni::MediaCodecVideoEncoderFactory()); |
139 external_decoder_factory_.reset( | 140 external_decoder_factory_.reset( |
140 new webrtc_jni::MediaCodecVideoDecoderFactory()); | 141 new webrtc_jni::MediaCodecVideoDecoderFactory()); |
141 #endif | 142 #endif |
142 } | 143 } |
143 virtual ~VideoProcessorIntegrationTest() = default; | 144 virtual ~VideoProcessorIntegrationTest() = default; |
144 | 145 |
145 void SetUpCodecConfig(const std::string& filename, | 146 void SetUpCodecConfig(const CodecConfigPars& process) { |
146 int width, | |
147 int height, | |
148 bool verbose_logging) { | |
149 if (hw_codec_) { | 147 if (hw_codec_) { |
150 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) | 148 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) |
151 #if defined(WEBRTC_ANDROID) | 149 #if defined(WEBRTC_ANDROID) |
152 // In general, external codecs should be destroyed by the factories that | 150 // In general, external codecs should be destroyed by the factories that |
153 // allocated them. For the particular case of the Android | 151 // allocated them. For the particular case of the Android |
154 // 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 |
155 // 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. |
156 if (codec_type_ == kVideoCodecH264) { | 154 if (codec_type_ == kVideoCodecH264) { |
157 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( | 155 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( |
158 cricket::VideoCodec(cricket::kH264CodecName))); | 156 cricket::VideoCodec(cricket::kH264CodecName))); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 decoder_.reset(VP8Decoder::Create()); | 190 decoder_.reset(VP8Decoder::Create()); |
193 } else if (codec_type_ == kVideoCodecVP9) { | 191 } else if (codec_type_ == kVideoCodecVP9) { |
194 encoder_.reset(VP9Encoder::Create()); | 192 encoder_.reset(VP9Encoder::Create()); |
195 decoder_.reset(VP9Decoder::Create()); | 193 decoder_.reset(VP9Decoder::Create()); |
196 } | 194 } |
197 } | 195 } |
198 | 196 |
199 VideoCodingModule::Codec(codec_type_, &codec_settings_); | 197 VideoCodingModule::Codec(codec_type_, &codec_settings_); |
200 | 198 |
201 // Configure input filename. | 199 // Configure input filename. |
202 config_.input_filename = test::ResourcePath(filename, "yuv"); | 200 config_.input_filename = test::ResourcePath(process.filename, "yuv"); |
203 if (verbose_logging) | 201 if (process.verbose_logging) |
204 printf("Filename: %s\n", filename.c_str()); | 202 printf("Filename: %s\n", process.filename.c_str()); |
205 // Generate an output filename in a safe way. | 203 // Generate an output filename in a safe way. |
206 config_.output_filename = test::TempFilename( | 204 config_.output_filename = test::TempFilename( |
207 test::OutputPath(), "videoprocessor_integrationtest"); | 205 test::OutputPath(), "videoprocessor_integrationtest"); |
208 config_.frame_length_in_bytes = CalcBufferSize(kI420, width, height); | 206 config_.frame_length_in_bytes = |
209 config_.verbose = verbose_logging; | 207 CalcBufferSize(kI420, process.width, process.height); |
210 // Only allow encoder/decoder to use single core, for predictability. | 208 config_.verbose = process.verbose_logging; |
211 config_.use_single_core = true; | 209 config_.use_single_core = process.use_single_core; |
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 = 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 = frame_dropper_on_; |
226 config_.codec_settings->H264()->keyFrameInterval = | 224 config_.codec_settings->H264()->keyFrameInterval = |
227 kBaseKeyFrameInterval; | 225 kBaseKeyFrameInterval; |
228 break; | 226 break; |
229 case kVideoCodecVP8: | 227 case kVideoCodecVP8: |
230 config_.codec_settings->VP8()->errorConcealmentOn = | 228 config_.codec_settings->VP8()->errorConcealmentOn = |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 codec_type_ = process.codec_type; | 449 codec_type_ = process.codec_type; |
452 hw_codec_ = process.hw_codec; | 450 hw_codec_ = process.hw_codec; |
453 start_bitrate_ = rate_profile.target_bit_rate[0]; | 451 start_bitrate_ = rate_profile.target_bit_rate[0]; |
454 packet_loss_ = process.packet_loss; | 452 packet_loss_ = process.packet_loss; |
455 key_frame_interval_ = process.key_frame_interval; | 453 key_frame_interval_ = process.key_frame_interval; |
456 num_temporal_layers_ = process.num_temporal_layers; | 454 num_temporal_layers_ = process.num_temporal_layers; |
457 error_concealment_on_ = process.error_concealment_on; | 455 error_concealment_on_ = process.error_concealment_on; |
458 denoising_on_ = process.denoising_on; | 456 denoising_on_ = process.denoising_on; |
459 frame_dropper_on_ = process.frame_dropper_on; | 457 frame_dropper_on_ = process.frame_dropper_on; |
460 spatial_resize_on_ = process.spatial_resize_on; | 458 spatial_resize_on_ = process.spatial_resize_on; |
461 SetUpCodecConfig(process.filename, process.width, process.height, | 459 SetUpCodecConfig(process); |
462 process.verbose_logging); | |
463 // Update the layers and the codec with the initial rates. | 460 // Update the layers and the codec with the initial rates. |
464 bit_rate_ = rate_profile.target_bit_rate[0]; | 461 bit_rate_ = rate_profile.target_bit_rate[0]; |
465 frame_rate_ = rate_profile.input_frame_rate[0]; | 462 frame_rate_ = rate_profile.input_frame_rate[0]; |
466 SetLayerRates(); | 463 SetLayerRates(); |
467 // Set the initial target size for key frame. | 464 // Set the initial target size for key frame. |
468 target_size_key_frame_initial_ = | 465 target_size_key_frame_initial_ = |
469 0.5 * kInitialBufferSize * bit_rate_layer_[0]; | 466 0.5 * kInitialBufferSize * bit_rate_layer_[0]; |
470 processor_->SetRates(bit_rate_, frame_rate_); | 467 processor_->SetRates(bit_rate_, frame_rate_); |
471 | 468 |
472 // Process each frame, up to |num_frames|. | 469 // Process each frame, up to |num_frames|. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 int frame_index_rate_update) { | 553 int frame_index_rate_update) { |
557 rate_profile->target_bit_rate[update_index] = bit_rate; | 554 rate_profile->target_bit_rate[update_index] = bit_rate; |
558 rate_profile->input_frame_rate[update_index] = frame_rate; | 555 rate_profile->input_frame_rate[update_index] = frame_rate; |
559 rate_profile->frame_index_rate_update[update_index] = | 556 rate_profile->frame_index_rate_update[update_index] = |
560 frame_index_rate_update; | 557 frame_index_rate_update; |
561 } | 558 } |
562 | 559 |
563 static void SetCodecParameters(CodecConfigPars* process_settings, | 560 static void SetCodecParameters(CodecConfigPars* process_settings, |
564 VideoCodecType codec_type, | 561 VideoCodecType codec_type, |
565 bool hw_codec, | 562 bool hw_codec, |
| 563 bool use_single_core, |
566 float packet_loss, | 564 float packet_loss, |
567 int key_frame_interval, | 565 int key_frame_interval, |
568 int num_temporal_layers, | 566 int num_temporal_layers, |
569 bool error_concealment_on, | 567 bool error_concealment_on, |
570 bool denoising_on, | 568 bool denoising_on, |
571 bool frame_dropper_on, | 569 bool frame_dropper_on, |
572 bool spatial_resize_on, | 570 bool spatial_resize_on, |
573 int width, | 571 int width, |
574 int height, | 572 int height, |
575 const std::string& filename, | 573 const std::string& filename, |
576 bool verbose_logging) { | 574 bool verbose_logging) { |
577 process_settings->codec_type = codec_type; | 575 process_settings->codec_type = codec_type; |
578 process_settings->hw_codec = hw_codec; | 576 process_settings->hw_codec = hw_codec; |
| 577 process_settings->use_single_core = use_single_core; |
579 process_settings->packet_loss = packet_loss; | 578 process_settings->packet_loss = packet_loss; |
580 process_settings->key_frame_interval = key_frame_interval; | 579 process_settings->key_frame_interval = key_frame_interval; |
581 process_settings->num_temporal_layers = num_temporal_layers, | 580 process_settings->num_temporal_layers = num_temporal_layers, |
582 process_settings->error_concealment_on = error_concealment_on; | 581 process_settings->error_concealment_on = error_concealment_on; |
583 process_settings->denoising_on = denoising_on; | 582 process_settings->denoising_on = denoising_on; |
584 process_settings->frame_dropper_on = frame_dropper_on; | 583 process_settings->frame_dropper_on = frame_dropper_on; |
585 process_settings->spatial_resize_on = spatial_resize_on; | 584 process_settings->spatial_resize_on = spatial_resize_on; |
586 process_settings->width = width; | 585 process_settings->width = width; |
587 process_settings->height = height; | 586 process_settings->height = height; |
588 process_settings->filename = filename; | 587 process_settings->filename = filename; |
589 process_settings->verbose_logging = verbose_logging; | 588 process_settings->verbose_logging = verbose_logging; |
590 } | 589 } |
591 | 590 |
592 static void SetCodecParameters(CodecConfigPars* process_settings, | 591 static void SetCodecParameters(CodecConfigPars* process_settings, |
593 VideoCodecType codec_type, | 592 VideoCodecType codec_type, |
594 bool hw_codec, | 593 bool hw_codec, |
| 594 bool use_single_core, |
595 float packet_loss, | 595 float packet_loss, |
596 int key_frame_interval, | 596 int key_frame_interval, |
597 int num_temporal_layers, | 597 int num_temporal_layers, |
598 bool error_concealment_on, | 598 bool error_concealment_on, |
599 bool denoising_on, | 599 bool denoising_on, |
600 bool frame_dropper_on, | 600 bool frame_dropper_on, |
601 bool spatial_resize_on) { | 601 bool spatial_resize_on) { |
602 SetCodecParameters(process_settings, codec_type, hw_codec, packet_loss, | 602 SetCodecParameters(process_settings, codec_type, hw_codec, use_single_core, |
603 key_frame_interval, num_temporal_layers, | 603 packet_loss, key_frame_interval, num_temporal_layers, |
604 error_concealment_on, denoising_on, frame_dropper_on, | 604 error_concealment_on, denoising_on, frame_dropper_on, |
605 spatial_resize_on, kCifWidth, kCifHeight, | 605 spatial_resize_on, kCifWidth, kCifHeight, |
606 kFilenameForemanCif, false /* verbose_logging */); | 606 kFilenameForemanCif, false /* verbose_logging */); |
607 } | 607 } |
608 | 608 |
609 static void SetQualityMetrics(QualityMetrics* quality_metrics, | 609 static void SetQualityMetrics(QualityMetrics* quality_metrics, |
610 double minimum_avg_psnr, | 610 double minimum_avg_psnr, |
611 double minimum_min_psnr, | 611 double minimum_min_psnr, |
612 double minimum_avg_ssim, | 612 double minimum_avg_ssim, |
613 double minimum_min_ssim) { | 613 double minimum_min_ssim) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 bool error_concealment_on_; | 686 bool error_concealment_on_; |
687 bool denoising_on_; | 687 bool denoising_on_; |
688 bool frame_dropper_on_; | 688 bool frame_dropper_on_; |
689 bool spatial_resize_on_; | 689 bool spatial_resize_on_; |
690 }; | 690 }; |
691 | 691 |
692 } // namespace test | 692 } // namespace test |
693 } // namespace webrtc | 693 } // namespace webrtc |
694 | 694 |
695 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES
T_H_ | 695 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES
T_H_ |
OLD | NEW |