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