| 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 |
| 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTEST_H
_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTEST_H
_ |
| 12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTEST_H
_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTEST_H
_ |
| 13 | 13 |
| 14 #include <math.h> | 14 #include <math.h> |
| 15 | 15 |
| 16 #include <memory> | 16 #include <memory> |
| 17 #include <string> | 17 #include <string> |
| 18 #include <utility> | |
| 19 | 18 |
| 20 #if defined(WEBRTC_ANDROID) | 19 #if defined(WEBRTC_ANDROID) |
| 21 #include "webrtc/modules/video_coding/codecs/test/android_test_initializer.h" | 20 #include "webrtc/modules/video_coding/codecs/test/android_test_initializer.h" |
| 22 #include "webrtc/sdk/android/src/jni/androidmediadecoder_jni.h" | 21 #include "webrtc/sdk/android/src/jni/androidmediadecoder_jni.h" |
| 23 #include "webrtc/sdk/android/src/jni/androidmediaencoder_jni.h" | 22 #include "webrtc/sdk/android/src/jni/androidmediaencoder_jni.h" |
| 24 #elif defined(WEBRTC_IOS) | 23 #elif defined(WEBRTC_IOS) |
| 25 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.h" | 24 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.h" |
| 26 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h" | 25 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h" |
| 27 #endif | 26 #endif |
| 28 | 27 |
| 29 #include "webrtc/base/checks.h" | 28 #include "webrtc/base/checks.h" |
| 30 #include "webrtc/base/file.h" | |
| 31 #include "webrtc/media/engine/webrtcvideodecoderfactory.h" | 29 #include "webrtc/media/engine/webrtcvideodecoderfactory.h" |
| 32 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" | 30 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" |
| 33 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" | 31 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" |
| 34 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h" | 32 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h" |
| 35 #include "webrtc/modules/video_coding/codecs/test/videoprocessor.h" | 33 #include "webrtc/modules/video_coding/codecs/test/videoprocessor.h" |
| 36 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" | 34 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" |
| 37 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" | 35 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" |
| 36 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" |
| 38 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" | 37 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" |
| 39 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 38 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
| 40 #include "webrtc/modules/video_coding/include/video_coding.h" | 39 #include "webrtc/modules/video_coding/include/video_coding.h" |
| 41 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" | |
| 42 #include "webrtc/test/gtest.h" | 40 #include "webrtc/test/gtest.h" |
| 43 #include "webrtc/test/testsupport/fileutils.h" | 41 #include "webrtc/test/testsupport/fileutils.h" |
| 44 #include "webrtc/test/testsupport/frame_reader.h" | 42 #include "webrtc/test/testsupport/frame_reader.h" |
| 45 #include "webrtc/test/testsupport/frame_writer.h" | 43 #include "webrtc/test/testsupport/frame_writer.h" |
| 46 #include "webrtc/test/testsupport/metrics/video_metrics.h" | 44 #include "webrtc/test/testsupport/metrics/video_metrics.h" |
| 47 #include "webrtc/test/testsupport/packet_reader.h" | 45 #include "webrtc/test/testsupport/packet_reader.h" |
| 48 #include "webrtc/typedefs.h" | 46 #include "webrtc/typedefs.h" |
| 49 | 47 |
| 50 namespace webrtc { | 48 namespace webrtc { |
| 51 namespace test { | 49 namespace test { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 struct RateControlMetrics { | 102 struct RateControlMetrics { |
| 105 int max_num_dropped_frames; | 103 int max_num_dropped_frames; |
| 106 int max_key_frame_size_mismatch; | 104 int max_key_frame_size_mismatch; |
| 107 int max_delta_frame_size_mismatch; | 105 int max_delta_frame_size_mismatch; |
| 108 int max_encoding_rate_mismatch; | 106 int max_encoding_rate_mismatch; |
| 109 int max_time_hit_target; | 107 int max_time_hit_target; |
| 110 int num_spatial_resizes; | 108 int num_spatial_resizes; |
| 111 int num_key_frames; | 109 int num_key_frames; |
| 112 }; | 110 }; |
| 113 | 111 |
| 114 // Should video files be saved persistently to disk for post-run visualization? | |
| 115 struct VisualizationParams { | |
| 116 bool save_source_y4m; | |
| 117 bool save_encoded_ivf; | |
| 118 bool save_decoded_y4m; | |
| 119 }; | |
| 120 | |
| 121 #if !defined(WEBRTC_IOS) | 112 #if !defined(WEBRTC_IOS) |
| 122 const int kNumFramesShort = 100; | 113 const int kNumFramesShort = 100; |
| 123 #endif | 114 #endif |
| 124 const int kNumFramesLong = 299; | 115 const int kNumFramesLong = 299; |
| 125 | 116 |
| 126 // Parameters from VP8 wrapper, which control target size of key frames. | 117 // Parameters from VP8 wrapper, which control target size of key frames. |
| 127 const float kInitialBufferSize = 0.5f; | 118 const float kInitialBufferSize = 0.5f; |
| 128 const float kOptimalBufferSize = 0.6f; | 119 const float kOptimalBufferSize = 0.6f; |
| 129 const float kScaleKeyFrameSize = 0.5f; | 120 const float kScaleKeyFrameSize = 0.5f; |
| 130 | 121 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 147 new webrtc_jni::MediaCodecVideoEncoderFactory()); | 138 new webrtc_jni::MediaCodecVideoEncoderFactory()); |
| 148 external_decoder_factory_.reset( | 139 external_decoder_factory_.reset( |
| 149 new webrtc_jni::MediaCodecVideoDecoderFactory()); | 140 new webrtc_jni::MediaCodecVideoDecoderFactory()); |
| 150 #endif | 141 #endif |
| 151 } | 142 } |
| 152 virtual ~VideoProcessorIntegrationTest() = default; | 143 virtual ~VideoProcessorIntegrationTest() = default; |
| 153 | 144 |
| 154 void SetUpCodecConfig(const std::string& filename, | 145 void SetUpCodecConfig(const std::string& filename, |
| 155 int width, | 146 int width, |
| 156 int height, | 147 int height, |
| 157 bool verbose_logging, | 148 bool verbose_logging) { |
| 158 const VisualizationParams* visualization_params) { | |
| 159 if (hw_codec_) { | 149 if (hw_codec_) { |
| 160 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) | 150 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) |
| 161 #if defined(WEBRTC_ANDROID) | 151 #if defined(WEBRTC_ANDROID) |
| 162 // In general, external codecs should be destroyed by the factories that | 152 // In general, external codecs should be destroyed by the factories that |
| 163 // allocated them. For the particular case of the Android | 153 // allocated them. For the particular case of the Android |
| 164 // MediaCodecVideo{En,De}coderFactory's, however, it turns out that it is | 154 // MediaCodecVideo{En,De}coderFactory's, however, it turns out that it is |
| 165 // fine for the std::unique_ptr to destroy the owned codec directly. | 155 // fine for the std::unique_ptr to destroy the owned codec directly. |
| 166 if (codec_type_ == kVideoCodecH264) { | 156 if (codec_type_ == kVideoCodecH264) { |
| 167 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( | 157 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( |
| 168 cricket::VideoCodec(cricket::kH264CodecName))); | 158 cricket::VideoCodec(cricket::kH264CodecName))); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 config_.codec_settings->VP9()->numberOfTemporalLayers = | 241 config_.codec_settings->VP9()->numberOfTemporalLayers = |
| 252 num_temporal_layers_; | 242 num_temporal_layers_; |
| 253 config_.codec_settings->VP9()->frameDroppingOn = frame_dropper_on_; | 243 config_.codec_settings->VP9()->frameDroppingOn = frame_dropper_on_; |
| 254 config_.codec_settings->VP9()->automaticResizeOn = spatial_resize_on_; | 244 config_.codec_settings->VP9()->automaticResizeOn = spatial_resize_on_; |
| 255 config_.codec_settings->VP9()->keyFrameInterval = kBaseKeyFrameInterval; | 245 config_.codec_settings->VP9()->keyFrameInterval = kBaseKeyFrameInterval; |
| 256 break; | 246 break; |
| 257 default: | 247 default: |
| 258 RTC_NOTREACHED(); | 248 RTC_NOTREACHED(); |
| 259 break; | 249 break; |
| 260 } | 250 } |
| 261 | 251 frame_reader_.reset(new test::FrameReaderImpl( |
| 262 // Create file objects for quality analysis. | |
| 263 analysis_frame_reader_.reset(new test::YuvFrameReaderImpl( | |
| 264 config_.input_filename, config_.codec_settings->width, | 252 config_.input_filename, config_.codec_settings->width, |
| 265 config_.codec_settings->height)); | 253 config_.codec_settings->height)); |
| 266 analysis_frame_writer_.reset(new test::YuvFrameWriterImpl( | 254 frame_writer_.reset(new test::FrameWriterImpl( |
| 267 config_.output_filename, config_.codec_settings->width, | 255 config_.output_filename, config_.frame_length_in_bytes)); |
| 268 config_.codec_settings->height)); | 256 RTC_CHECK(frame_reader_->Init()); |
| 269 RTC_CHECK(analysis_frame_reader_->Init()); | 257 RTC_CHECK(frame_writer_->Init()); |
| 270 RTC_CHECK(analysis_frame_writer_->Init()); | |
| 271 | |
| 272 if (visualization_params) { | |
| 273 // clang-format off | |
| 274 const std::string output_filename_base = | |
| 275 test::OutputPath() + filename + | |
| 276 "_cd-" + CodecTypeToPayloadName(codec_type_).value_or("") + | |
| 277 "_hw-" + std::to_string(hw_codec_) + | |
| 278 "_fr-" + std::to_string(start_frame_rate_) + | |
| 279 "_br-" + std::to_string(static_cast<int>(start_bitrate_)); | |
| 280 // clang-format on | |
| 281 if (visualization_params->save_source_y4m) { | |
| 282 source_frame_writer_.reset(new test::Y4mFrameWriterImpl( | |
| 283 output_filename_base + "_source.y4m", config_.codec_settings->width, | |
| 284 config_.codec_settings->height, start_frame_rate_)); | |
| 285 RTC_CHECK(source_frame_writer_->Init()); | |
| 286 } | |
| 287 if (visualization_params->save_encoded_ivf) { | |
| 288 rtc::File post_encode_file = | |
| 289 rtc::File::Create(output_filename_base + "_encoded.ivf"); | |
| 290 encoded_frame_writer_ = | |
| 291 IvfFileWriter::Wrap(std::move(post_encode_file), 0); | |
| 292 } | |
| 293 if (visualization_params->save_decoded_y4m) { | |
| 294 decoded_frame_writer_.reset(new test::Y4mFrameWriterImpl( | |
| 295 output_filename_base + "_decoded.y4m", | |
| 296 config_.codec_settings->width, config_.codec_settings->height, | |
| 297 start_frame_rate_)); | |
| 298 RTC_CHECK(decoded_frame_writer_->Init()); | |
| 299 } | |
| 300 } | |
| 301 | 258 |
| 302 packet_manipulator_.reset(new test::PacketManipulatorImpl( | 259 packet_manipulator_.reset(new test::PacketManipulatorImpl( |
| 303 &packet_reader_, config_.networking_config, config_.verbose)); | 260 &packet_reader_, config_.networking_config, config_.verbose)); |
| 304 processor_.reset(new test::VideoProcessorImpl( | 261 processor_.reset(new test::VideoProcessorImpl( |
| 305 encoder_.get(), decoder_.get(), analysis_frame_reader_.get(), | 262 encoder_.get(), decoder_.get(), frame_reader_.get(), |
| 306 analysis_frame_writer_.get(), packet_manipulator_.get(), config_, | 263 frame_writer_.get(), packet_manipulator_.get(), config_, &stats_)); |
| 307 &stats_, source_frame_writer_.get(), encoded_frame_writer_.get(), | |
| 308 decoded_frame_writer_.get())); | |
| 309 RTC_CHECK(processor_->Init()); | 264 RTC_CHECK(processor_->Init()); |
| 310 } | 265 } |
| 311 | 266 |
| 312 // Reset quantities after each encoder update, update the target | 267 // Reset quantities after each encoder update, update the target |
| 313 // per-frame bandwidth. | 268 // per-frame bandwidth. |
| 314 void ResetRateControlMetrics(int num_frames) { | 269 void ResetRateControlMetrics(int num_frames) { |
| 315 for (int i = 0; i < num_temporal_layers_; i++) { | 270 for (int i = 0; i < num_temporal_layers_; i++) { |
| 316 num_frames_per_update_[i] = 0; | 271 num_frames_per_update_[i] = 0; |
| 317 sum_frame_size_mismatch_[i] = 0.0f; | 272 sum_frame_size_mismatch_[i] = 0.0f; |
| 318 sum_encoded_frame_size_[i] = 0.0f; | 273 sum_encoded_frame_size_[i] = 0.0f; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 } | 439 } |
| 485 if (num_temporal_layers_ == 3) { | 440 if (num_temporal_layers_ == 3) { |
| 486 frame_rate_layer_[2] = frame_rate_ / 2.0f; | 441 frame_rate_layer_[2] = frame_rate_ / 2.0f; |
| 487 } | 442 } |
| 488 } | 443 } |
| 489 | 444 |
| 490 // Processes all frames in the clip and verifies the result. | 445 // Processes all frames in the clip and verifies the result. |
| 491 void ProcessFramesAndVerify(QualityMetrics quality_metrics, | 446 void ProcessFramesAndVerify(QualityMetrics quality_metrics, |
| 492 RateProfile rate_profile, | 447 RateProfile rate_profile, |
| 493 CodecConfigPars process, | 448 CodecConfigPars process, |
| 494 RateControlMetrics* rc_metrics, | 449 RateControlMetrics* rc_metrics) { |
| 495 const VisualizationParams* visualization_params) { | |
| 496 // Codec/config settings. | 450 // Codec/config settings. |
| 497 codec_type_ = process.codec_type; | 451 codec_type_ = process.codec_type; |
| 498 hw_codec_ = process.hw_codec; | 452 hw_codec_ = process.hw_codec; |
| 499 start_bitrate_ = rate_profile.target_bit_rate[0]; | 453 start_bitrate_ = rate_profile.target_bit_rate[0]; |
| 500 start_frame_rate_ = rate_profile.input_frame_rate[0]; | |
| 501 packet_loss_ = process.packet_loss; | 454 packet_loss_ = process.packet_loss; |
| 502 key_frame_interval_ = process.key_frame_interval; | 455 key_frame_interval_ = process.key_frame_interval; |
| 503 num_temporal_layers_ = process.num_temporal_layers; | 456 num_temporal_layers_ = process.num_temporal_layers; |
| 504 error_concealment_on_ = process.error_concealment_on; | 457 error_concealment_on_ = process.error_concealment_on; |
| 505 denoising_on_ = process.denoising_on; | 458 denoising_on_ = process.denoising_on; |
| 506 frame_dropper_on_ = process.frame_dropper_on; | 459 frame_dropper_on_ = process.frame_dropper_on; |
| 507 spatial_resize_on_ = process.spatial_resize_on; | 460 spatial_resize_on_ = process.spatial_resize_on; |
| 508 SetUpCodecConfig(process.filename, process.width, process.height, | 461 SetUpCodecConfig(process.filename, process.width, process.height, |
| 509 process.verbose_logging, visualization_params); | 462 process.verbose_logging); |
| 510 | |
| 511 // Update the layers and the codec with the initial rates. | 463 // Update the layers and the codec with the initial rates. |
| 512 bit_rate_ = rate_profile.target_bit_rate[0]; | 464 bit_rate_ = rate_profile.target_bit_rate[0]; |
| 513 frame_rate_ = rate_profile.input_frame_rate[0]; | 465 frame_rate_ = rate_profile.input_frame_rate[0]; |
| 514 SetLayerRates(); | 466 SetLayerRates(); |
| 515 // Set the initial target size for key frame. | 467 // Set the initial target size for key frame. |
| 516 target_size_key_frame_initial_ = | 468 target_size_key_frame_initial_ = |
| 517 0.5 * kInitialBufferSize * bit_rate_layer_[0]; | 469 0.5 * kInitialBufferSize * bit_rate_layer_[0]; |
| 518 processor_->SetRates(bit_rate_, frame_rate_); | 470 processor_->SetRates(bit_rate_, frame_rate_); |
| 519 | 471 |
| 520 // Process each frame, up to |num_frames|. | 472 // Process each frame, up to |num_frames|. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 rc_metrics[update_index].max_delta_frame_size_mismatch, | 515 rc_metrics[update_index].max_delta_frame_size_mismatch, |
| 564 rc_metrics[update_index].max_encoding_rate_mismatch, | 516 rc_metrics[update_index].max_encoding_rate_mismatch, |
| 565 rc_metrics[update_index].max_time_hit_target, | 517 rc_metrics[update_index].max_time_hit_target, |
| 566 rc_metrics[update_index].max_num_dropped_frames, | 518 rc_metrics[update_index].max_num_dropped_frames, |
| 567 rc_metrics[update_index].num_spatial_resizes, | 519 rc_metrics[update_index].num_spatial_resizes, |
| 568 rc_metrics[update_index].num_key_frames); | 520 rc_metrics[update_index].num_key_frames); |
| 569 EXPECT_EQ(num_frames, frame_number); | 521 EXPECT_EQ(num_frames, frame_number); |
| 570 EXPECT_EQ(num_frames + 1, static_cast<int>(stats_.stats_.size())); | 522 EXPECT_EQ(num_frames + 1, static_cast<int>(stats_.stats_.size())); |
| 571 | 523 |
| 572 // Release encoder and decoder to make sure they have finished processing: | 524 // Release encoder and decoder to make sure they have finished processing: |
| 573 RTC_DCHECK_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release()); | 525 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release()); |
| 574 RTC_DCHECK_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release()); | 526 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release()); |
| 575 | 527 |
| 576 // Close the analysis files before we use them for SSIM/PSNR calculations. | 528 // Close the files before we start using them for SSIM/PSNR calculations. |
| 577 analysis_frame_reader_->Close(); | 529 frame_reader_->Close(); |
| 578 analysis_frame_writer_->Close(); | 530 frame_writer_->Close(); |
| 579 | 531 |
| 580 // Close visualization files. | 532 // TODO(marpan): should compute these quality metrics per SetRates update. |
| 581 if (source_frame_writer_) { | |
| 582 source_frame_writer_->Close(); | |
| 583 } | |
| 584 if (encoded_frame_writer_) { | |
| 585 encoded_frame_writer_->Close(); | |
| 586 } | |
| 587 if (decoded_frame_writer_) { | |
| 588 decoded_frame_writer_->Close(); | |
| 589 } | |
| 590 | |
| 591 // TODO(marpan): Should compute these quality metrics per SetRates update. | |
| 592 test::QualityMetricsResult psnr_result, ssim_result; | 533 test::QualityMetricsResult psnr_result, ssim_result; |
| 593 RTC_DCHECK_EQ(0, test::I420MetricsFromFiles(config_.input_filename.c_str(), | 534 EXPECT_EQ(0, test::I420MetricsFromFiles(config_.input_filename.c_str(), |
| 594 config_.output_filename.c_str(), | 535 config_.output_filename.c_str(), |
| 595 config_.codec_settings->width, | 536 config_.codec_settings->width, |
| 596 config_.codec_settings->height, | 537 config_.codec_settings->height, |
| 597 &psnr_result, &ssim_result)); | 538 &psnr_result, &ssim_result)); |
| 598 printf("PSNR avg: %f, min: %f\nSSIM avg: %f, min: %f\n", | 539 printf("PSNR avg: %f, min: %f\nSSIM avg: %f, min: %f\n", |
| 599 psnr_result.average, psnr_result.min, ssim_result.average, | 540 psnr_result.average, psnr_result.min, ssim_result.average, |
| 600 ssim_result.min); | 541 ssim_result.min); |
| 601 stats_.PrintSummary(); | 542 stats_.PrintSummary(); |
| 602 EXPECT_GT(psnr_result.average, quality_metrics.minimum_avg_psnr); | 543 EXPECT_GT(psnr_result.average, quality_metrics.minimum_avg_psnr); |
| 603 EXPECT_GT(psnr_result.min, quality_metrics.minimum_min_psnr); | 544 EXPECT_GT(psnr_result.min, quality_metrics.minimum_min_psnr); |
| 604 EXPECT_GT(ssim_result.average, quality_metrics.minimum_avg_ssim); | 545 EXPECT_GT(ssim_result.average, quality_metrics.minimum_avg_ssim); |
| 605 EXPECT_GT(ssim_result.min, quality_metrics.minimum_min_ssim); | 546 EXPECT_GT(ssim_result.min, quality_metrics.minimum_min_ssim); |
| 606 | |
| 607 // Remove analysis file. | |
| 608 if (remove(config_.output_filename.c_str()) < 0) { | 547 if (remove(config_.output_filename.c_str()) < 0) { |
| 609 fprintf(stderr, "Failed to remove temporary file!\n"); | 548 fprintf(stderr, "Failed to remove temporary file!\n"); |
| 610 } | 549 } |
| 611 } | 550 } |
| 612 | 551 |
| 552 static void SetRateProfilePars(RateProfile* rate_profile, |
| 553 int update_index, |
| 554 int bit_rate, |
| 555 int frame_rate, |
| 556 int frame_index_rate_update) { |
| 557 rate_profile->target_bit_rate[update_index] = bit_rate; |
| 558 rate_profile->input_frame_rate[update_index] = frame_rate; |
| 559 rate_profile->frame_index_rate_update[update_index] = |
| 560 frame_index_rate_update; |
| 561 } |
| 562 |
| 613 static void SetCodecParameters(CodecConfigPars* process_settings, | 563 static void SetCodecParameters(CodecConfigPars* process_settings, |
| 614 VideoCodecType codec_type, | 564 VideoCodecType codec_type, |
| 615 bool hw_codec, | 565 bool hw_codec, |
| 616 float packet_loss, | 566 float packet_loss, |
| 617 int key_frame_interval, | 567 int key_frame_interval, |
| 618 int num_temporal_layers, | 568 int num_temporal_layers, |
| 619 bool error_concealment_on, | 569 bool error_concealment_on, |
| 620 bool denoising_on, | 570 bool denoising_on, |
| 621 bool frame_dropper_on, | 571 bool frame_dropper_on, |
| 622 bool spatial_resize_on, | 572 bool spatial_resize_on, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 double minimum_avg_psnr, | 610 double minimum_avg_psnr, |
| 661 double minimum_min_psnr, | 611 double minimum_min_psnr, |
| 662 double minimum_avg_ssim, | 612 double minimum_avg_ssim, |
| 663 double minimum_min_ssim) { | 613 double minimum_min_ssim) { |
| 664 quality_metrics->minimum_avg_psnr = minimum_avg_psnr; | 614 quality_metrics->minimum_avg_psnr = minimum_avg_psnr; |
| 665 quality_metrics->minimum_min_psnr = minimum_min_psnr; | 615 quality_metrics->minimum_min_psnr = minimum_min_psnr; |
| 666 quality_metrics->minimum_avg_ssim = minimum_avg_ssim; | 616 quality_metrics->minimum_avg_ssim = minimum_avg_ssim; |
| 667 quality_metrics->minimum_min_ssim = minimum_min_ssim; | 617 quality_metrics->minimum_min_ssim = minimum_min_ssim; |
| 668 } | 618 } |
| 669 | 619 |
| 670 static void SetRateProfilePars(RateProfile* rate_profile, | |
| 671 int update_index, | |
| 672 int bit_rate, | |
| 673 int frame_rate, | |
| 674 int frame_index_rate_update) { | |
| 675 rate_profile->target_bit_rate[update_index] = bit_rate; | |
| 676 rate_profile->input_frame_rate[update_index] = frame_rate; | |
| 677 rate_profile->frame_index_rate_update[update_index] = | |
| 678 frame_index_rate_update; | |
| 679 } | |
| 680 | |
| 681 static void SetRateControlMetrics(RateControlMetrics* rc_metrics, | 620 static void SetRateControlMetrics(RateControlMetrics* rc_metrics, |
| 682 int update_index, | 621 int update_index, |
| 683 int max_num_dropped_frames, | 622 int max_num_dropped_frames, |
| 684 int max_key_frame_size_mismatch, | 623 int max_key_frame_size_mismatch, |
| 685 int max_delta_frame_size_mismatch, | 624 int max_delta_frame_size_mismatch, |
| 686 int max_encoding_rate_mismatch, | 625 int max_encoding_rate_mismatch, |
| 687 int max_time_hit_target, | 626 int max_time_hit_target, |
| 688 int num_spatial_resizes, | 627 int num_spatial_resizes, |
| 689 int num_key_frames) { | 628 int num_key_frames) { |
| 690 rc_metrics[update_index].max_num_dropped_frames = max_num_dropped_frames; | 629 rc_metrics[update_index].max_num_dropped_frames = max_num_dropped_frames; |
| 691 rc_metrics[update_index].max_key_frame_size_mismatch = | 630 rc_metrics[update_index].max_key_frame_size_mismatch = |
| 692 max_key_frame_size_mismatch; | 631 max_key_frame_size_mismatch; |
| 693 rc_metrics[update_index].max_delta_frame_size_mismatch = | 632 rc_metrics[update_index].max_delta_frame_size_mismatch = |
| 694 max_delta_frame_size_mismatch; | 633 max_delta_frame_size_mismatch; |
| 695 rc_metrics[update_index].max_encoding_rate_mismatch = | 634 rc_metrics[update_index].max_encoding_rate_mismatch = |
| 696 max_encoding_rate_mismatch; | 635 max_encoding_rate_mismatch; |
| 697 rc_metrics[update_index].max_time_hit_target = max_time_hit_target; | 636 rc_metrics[update_index].max_time_hit_target = max_time_hit_target; |
| 698 rc_metrics[update_index].num_spatial_resizes = num_spatial_resizes; | 637 rc_metrics[update_index].num_spatial_resizes = num_spatial_resizes; |
| 699 rc_metrics[update_index].num_key_frames = num_key_frames; | 638 rc_metrics[update_index].num_key_frames = num_key_frames; |
| 700 } | 639 } |
| 701 | 640 |
| 702 // Codecs. | |
| 703 std::unique_ptr<VideoEncoder> encoder_; | 641 std::unique_ptr<VideoEncoder> encoder_; |
| 704 std::unique_ptr<cricket::WebRtcVideoEncoderFactory> external_encoder_factory_; | 642 std::unique_ptr<cricket::WebRtcVideoEncoderFactory> external_encoder_factory_; |
| 705 std::unique_ptr<VideoDecoder> decoder_; | 643 std::unique_ptr<VideoDecoder> decoder_; |
| 706 std::unique_ptr<cricket::WebRtcVideoDecoderFactory> external_decoder_factory_; | 644 std::unique_ptr<cricket::WebRtcVideoDecoderFactory> external_decoder_factory_; |
| 707 VideoCodec codec_settings_; | 645 std::unique_ptr<test::FrameReader> frame_reader_; |
| 708 | 646 std::unique_ptr<test::FrameWriter> frame_writer_; |
| 709 // Helper objects. | |
| 710 std::unique_ptr<test::FrameReader> analysis_frame_reader_; | |
| 711 std::unique_ptr<test::FrameWriter> analysis_frame_writer_; | |
| 712 test::PacketReader packet_reader_; | 647 test::PacketReader packet_reader_; |
| 713 std::unique_ptr<test::PacketManipulator> packet_manipulator_; | 648 std::unique_ptr<test::PacketManipulator> packet_manipulator_; |
| 714 test::Stats stats_; | 649 test::Stats stats_; |
| 715 test::TestConfig config_; | 650 test::TestConfig config_; |
| 651 VideoCodec codec_settings_; |
| 716 // Must be destroyed before |encoder_| and |decoder_|. | 652 // Must be destroyed before |encoder_| and |decoder_|. |
| 717 std::unique_ptr<test::VideoProcessor> processor_; | 653 std::unique_ptr<test::VideoProcessor> processor_; |
| 718 | 654 TemporalLayersFactory tl_factory_; |
| 719 // Visualization objects. | |
| 720 std::unique_ptr<test::FrameWriter> source_frame_writer_; | |
| 721 std::unique_ptr<IvfFileWriter> encoded_frame_writer_; | |
| 722 std::unique_ptr<test::FrameWriter> decoded_frame_writer_; | |
| 723 | 655 |
| 724 // Quantities defined/updated for every encoder rate update. | 656 // Quantities defined/updated for every encoder rate update. |
| 725 // Some quantities defined per temporal layer (at most 3 layers in this test). | 657 // Some quantities defined per temporal layer (at most 3 layers in this test). |
| 726 int num_frames_per_update_[3]; | 658 int num_frames_per_update_[3]; |
| 727 float sum_frame_size_mismatch_[3]; | 659 float sum_frame_size_mismatch_[3]; |
| 728 float sum_encoded_frame_size_[3]; | 660 float sum_encoded_frame_size_[3]; |
| 729 float encoding_bitrate_[3]; | 661 float encoding_bitrate_[3]; |
| 730 float per_frame_bandwidth_[3]; | 662 float per_frame_bandwidth_[3]; |
| 731 float bit_rate_layer_[3]; | 663 float bit_rate_layer_[3]; |
| 732 float frame_rate_layer_[3]; | 664 float frame_rate_layer_[3]; |
| 733 int num_frames_total_; | 665 int num_frames_total_; |
| 734 float sum_encoded_frame_size_total_; | 666 float sum_encoded_frame_size_total_; |
| 735 float encoding_bitrate_total_; | 667 float encoding_bitrate_total_; |
| 736 float perc_encoding_rate_mismatch_; | 668 float perc_encoding_rate_mismatch_; |
| 737 int num_frames_to_hit_target_; | 669 int num_frames_to_hit_target_; |
| 738 bool encoding_rate_within_target_; | 670 bool encoding_rate_within_target_; |
| 739 int bit_rate_; | 671 int bit_rate_; |
| 740 int frame_rate_; | 672 int frame_rate_; |
| 741 int layer_; | 673 int layer_; |
| 742 float target_size_key_frame_initial_; | 674 float target_size_key_frame_initial_; |
| 743 float target_size_key_frame_; | 675 float target_size_key_frame_; |
| 744 float sum_key_frame_size_mismatch_; | 676 float sum_key_frame_size_mismatch_; |
| 745 int num_key_frames_; | 677 int num_key_frames_; |
| 746 float start_bitrate_; | 678 float start_bitrate_; |
| 747 int start_frame_rate_; | |
| 748 | 679 |
| 749 // Codec and network settings. | 680 // Codec and network settings. |
| 750 VideoCodecType codec_type_; | 681 VideoCodecType codec_type_; |
| 751 bool hw_codec_; | 682 bool hw_codec_; |
| 752 float packet_loss_; | 683 float packet_loss_; |
| 753 int num_temporal_layers_; | 684 int num_temporal_layers_; |
| 754 int key_frame_interval_; | 685 int key_frame_interval_; |
| 755 bool error_concealment_on_; | 686 bool error_concealment_on_; |
| 756 bool denoising_on_; | 687 bool denoising_on_; |
| 757 bool frame_dropper_on_; | 688 bool frame_dropper_on_; |
| 758 bool spatial_resize_on_; | 689 bool spatial_resize_on_; |
| 759 }; | 690 }; |
| 760 | 691 |
| 761 } // namespace test | 692 } // namespace test |
| 762 } // namespace webrtc | 693 } // namespace webrtc |
| 763 | 694 |
| 764 #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 |