| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 struct RateControlMetrics { | 105 struct RateControlMetrics { |
| 104 int max_num_dropped_frames; | 106 int max_num_dropped_frames; |
| 105 int max_key_frame_size_mismatch; | 107 int max_key_frame_size_mismatch; |
| 106 int max_delta_frame_size_mismatch; | 108 int max_delta_frame_size_mismatch; |
| 107 int max_encoding_rate_mismatch; | 109 int max_encoding_rate_mismatch; |
| 108 int max_time_hit_target; | 110 int max_time_hit_target; |
| 109 int num_spatial_resizes; | 111 int num_spatial_resizes; |
| 110 int num_key_frames; | 112 int num_key_frames; |
| 111 }; | 113 }; |
| 112 | 114 |
| 115 // Should video files be saved persistently to disk for post-run visualization? |
| 116 struct VisualizationParams { |
| 117 bool save_source_y4m; |
| 118 bool save_encoded_ivf; |
| 119 bool save_decoded_y4m; |
| 120 }; |
| 121 |
| 113 #if !defined(WEBRTC_IOS) | 122 #if !defined(WEBRTC_IOS) |
| 114 const int kNumFramesShort = 100; | 123 const int kNumFramesShort = 100; |
| 115 #endif | 124 #endif |
| 116 const int kNumFramesLong = 299; | 125 const int kNumFramesLong = 299; |
| 117 | 126 |
| 118 // Parameters from VP8 wrapper, which control target size of key frames. | 127 // Parameters from VP8 wrapper, which control target size of key frames. |
| 119 const float kInitialBufferSize = 0.5f; | 128 const float kInitialBufferSize = 0.5f; |
| 120 const float kOptimalBufferSize = 0.6f; | 129 const float kOptimalBufferSize = 0.6f; |
| 121 const float kScaleKeyFrameSize = 0.5f; | 130 const float kScaleKeyFrameSize = 0.5f; |
| 122 | 131 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 136 InitializeAndroidObjects(); | 145 InitializeAndroidObjects(); |
| 137 | 146 |
| 138 external_encoder_factory_.reset( | 147 external_encoder_factory_.reset( |
| 139 new webrtc_jni::MediaCodecVideoEncoderFactory()); | 148 new webrtc_jni::MediaCodecVideoEncoderFactory()); |
| 140 external_decoder_factory_.reset( | 149 external_decoder_factory_.reset( |
| 141 new webrtc_jni::MediaCodecVideoDecoderFactory()); | 150 new webrtc_jni::MediaCodecVideoDecoderFactory()); |
| 142 #endif | 151 #endif |
| 143 } | 152 } |
| 144 virtual ~VideoProcessorIntegrationTest() = default; | 153 virtual ~VideoProcessorIntegrationTest() = default; |
| 145 | 154 |
| 146 void SetUpCodecConfig(const CodecConfigPars& process) { | 155 void SetUpCodecConfig(const CodecConfigPars& process, |
| 156 const VisualizationParams* visualization_params) { |
| 147 if (process.hw_codec) { | 157 if (process.hw_codec) { |
| 148 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) | 158 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) |
| 149 #if defined(WEBRTC_ANDROID) | 159 #if defined(WEBRTC_ANDROID) |
| 150 // In general, external codecs should be destroyed by the factories that | 160 // In general, external codecs should be destroyed by the factories that |
| 151 // allocated them. For the particular case of the Android | 161 // allocated them. For the particular case of the Android |
| 152 // MediaCodecVideo{En,De}coderFactory's, however, it turns out that it is | 162 // 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. | 163 // fine for the std::unique_ptr to destroy the owned codec directly. |
| 154 switch (process.codec_type) { | 164 switch (process.codec_type) { |
| 155 case kVideoCodecH264: | 165 case kVideoCodecH264: |
| 156 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( | 166 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 168 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( | 178 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( |
| 169 cricket::VideoCodec(cricket::kVp9CodecName))); | 179 cricket::VideoCodec(cricket::kVp9CodecName))); |
| 170 decoder_.reset( | 180 decoder_.reset( |
| 171 external_decoder_factory_->CreateVideoDecoder(kVideoCodecVP9)); | 181 external_decoder_factory_->CreateVideoDecoder(kVideoCodecVP9)); |
| 172 break; | 182 break; |
| 173 default: | 183 default: |
| 174 RTC_NOTREACHED(); | 184 RTC_NOTREACHED(); |
| 175 break; | 185 break; |
| 176 } | 186 } |
| 177 #elif defined(WEBRTC_IOS) | 187 #elif defined(WEBRTC_IOS) |
| 178 RTC_DCHECK_EQ(kVideoCodecH264, process.codec_type) | 188 ASSERT_EQ(kVideoCodecH264, process.codec_type) |
| 179 << "iOS HW codecs only support H264."; | 189 << "iOS HW codecs only support H264."; |
| 180 encoder_.reset(new H264VideoToolboxEncoder( | 190 encoder_.reset(new H264VideoToolboxEncoder( |
| 181 cricket::VideoCodec(cricket::kH264CodecName))); | 191 cricket::VideoCodec(cricket::kH264CodecName))); |
| 182 decoder_.reset(new H264VideoToolboxDecoder()); | 192 decoder_.reset(new H264VideoToolboxDecoder()); |
| 183 #else | 193 #else |
| 184 RTC_NOTREACHED() << "Only support HW codecs on Android and iOS."; | 194 RTC_NOTREACHED() << "Only support HW codecs on Android and iOS."; |
| 185 #endif | 195 #endif |
| 186 #endif // WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED | 196 #endif // WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED |
| 187 RTC_DCHECK(encoder_) << "HW encoder not successfully created."; | 197 RTC_CHECK(encoder_) << "HW encoder not successfully created."; |
| 188 RTC_DCHECK(decoder_) << "HW decoder not successfully created."; | 198 RTC_CHECK(decoder_) << "HW decoder not successfully created."; |
| 189 } else { | 199 } else { |
| 190 // SW codecs. | 200 // SW codecs. |
| 191 switch (process.codec_type) { | 201 switch (process.codec_type) { |
| 192 case kVideoCodecH264: | 202 case kVideoCodecH264: |
| 193 encoder_.reset(H264Encoder::Create( | 203 encoder_.reset(H264Encoder::Create( |
| 194 cricket::VideoCodec(cricket::kH264CodecName))); | 204 cricket::VideoCodec(cricket::kH264CodecName))); |
| 195 decoder_.reset(H264Decoder::Create()); | 205 decoder_.reset(H264Decoder::Create()); |
| 196 break; | 206 break; |
| 197 case kVideoCodecVP8: | 207 case kVideoCodecVP8: |
| 198 encoder_.reset(VP8Encoder::Create()); | 208 encoder_.reset(VP8Encoder::Create()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 config_.codec_settings->VP9()->frameDroppingOn = | 268 config_.codec_settings->VP9()->frameDroppingOn = |
| 259 process.frame_dropper_on; | 269 process.frame_dropper_on; |
| 260 config_.codec_settings->VP9()->automaticResizeOn = | 270 config_.codec_settings->VP9()->automaticResizeOn = |
| 261 process.spatial_resize_on; | 271 process.spatial_resize_on; |
| 262 config_.codec_settings->VP9()->keyFrameInterval = kBaseKeyFrameInterval; | 272 config_.codec_settings->VP9()->keyFrameInterval = kBaseKeyFrameInterval; |
| 263 break; | 273 break; |
| 264 default: | 274 default: |
| 265 RTC_NOTREACHED(); | 275 RTC_NOTREACHED(); |
| 266 break; | 276 break; |
| 267 } | 277 } |
| 268 frame_reader_.reset(new test::FrameReaderImpl( | 278 |
| 279 // Create file objects for quality analysis. |
| 280 analysis_frame_reader_.reset(new test::YuvFrameReaderImpl( |
| 269 config_.input_filename, config_.codec_settings->width, | 281 config_.input_filename, config_.codec_settings->width, |
| 270 config_.codec_settings->height)); | 282 config_.codec_settings->height)); |
| 271 frame_writer_.reset(new test::FrameWriterImpl( | 283 analysis_frame_writer_.reset(new test::YuvFrameWriterImpl( |
| 272 config_.output_filename, config_.frame_length_in_bytes)); | 284 config_.output_filename, config_.codec_settings->width, |
| 273 RTC_CHECK(frame_reader_->Init()); | 285 config_.codec_settings->height)); |
| 274 RTC_CHECK(frame_writer_->Init()); | 286 RTC_CHECK(analysis_frame_reader_->Init()); |
| 287 RTC_CHECK(analysis_frame_writer_->Init()); |
| 288 |
| 289 if (visualization_params) { |
| 290 // clang-format off |
| 291 const std::string output_filename_base = |
| 292 test::OutputPath() + process.filename + |
| 293 "_cd-" + CodecTypeToPayloadName(process.codec_type).value_or("") + |
| 294 "_hw-" + std::to_string(process.hw_codec) + |
| 295 "_fr-" + std::to_string(start_frame_rate_) + |
| 296 "_br-" + std::to_string(static_cast<int>(start_bitrate_)); |
| 297 // clang-format on |
| 298 if (visualization_params->save_source_y4m) { |
| 299 source_frame_writer_.reset(new test::Y4mFrameWriterImpl( |
| 300 output_filename_base + "_source.y4m", config_.codec_settings->width, |
| 301 config_.codec_settings->height, start_frame_rate_)); |
| 302 RTC_CHECK(source_frame_writer_->Init()); |
| 303 } |
| 304 if (visualization_params->save_encoded_ivf) { |
| 305 rtc::File post_encode_file = |
| 306 rtc::File::Create(output_filename_base + "_encoded.ivf"); |
| 307 encoded_frame_writer_ = |
| 308 IvfFileWriter::Wrap(std::move(post_encode_file), 0); |
| 309 } |
| 310 if (visualization_params->save_decoded_y4m) { |
| 311 decoded_frame_writer_.reset(new test::Y4mFrameWriterImpl( |
| 312 output_filename_base + "_decoded.y4m", |
| 313 config_.codec_settings->width, config_.codec_settings->height, |
| 314 start_frame_rate_)); |
| 315 RTC_CHECK(decoded_frame_writer_->Init()); |
| 316 } |
| 317 } |
| 275 | 318 |
| 276 packet_manipulator_.reset(new test::PacketManipulatorImpl( | 319 packet_manipulator_.reset(new test::PacketManipulatorImpl( |
| 277 &packet_reader_, config_.networking_config, config_.verbose)); | 320 &packet_reader_, config_.networking_config, config_.verbose)); |
| 278 processor_.reset(new test::VideoProcessorImpl( | 321 processor_.reset(new test::VideoProcessorImpl( |
| 279 encoder_.get(), decoder_.get(), frame_reader_.get(), | 322 encoder_.get(), decoder_.get(), analysis_frame_reader_.get(), |
| 280 frame_writer_.get(), packet_manipulator_.get(), config_, &stats_)); | 323 analysis_frame_writer_.get(), packet_manipulator_.get(), config_, |
| 324 &stats_, source_frame_writer_.get(), encoded_frame_writer_.get(), |
| 325 decoded_frame_writer_.get())); |
| 281 RTC_CHECK(processor_->Init()); | 326 RTC_CHECK(processor_->Init()); |
| 282 } | 327 } |
| 283 | 328 |
| 284 // Reset quantities after each encoder update, update the target | 329 // Reset quantities after each encoder update, update the target |
| 285 // per-frame bandwidth. | 330 // per-frame bandwidth. |
| 286 void ResetRateControlMetrics(int num_frames) { | 331 void ResetRateControlMetrics(int num_frames) { |
| 287 for (int i = 0; i < num_temporal_layers_; i++) { | 332 for (int i = 0; i < num_temporal_layers_; i++) { |
| 288 num_frames_per_update_[i] = 0; | 333 num_frames_per_update_[i] = 0; |
| 289 sum_frame_size_mismatch_[i] = 0.0f; | 334 sum_frame_size_mismatch_[i] = 0.0f; |
| 290 sum_encoded_frame_size_[i] = 0.0f; | 335 sum_encoded_frame_size_[i] = 0.0f; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 } | 501 } |
| 457 if (num_temporal_layers_ == 3) { | 502 if (num_temporal_layers_ == 3) { |
| 458 frame_rate_layer_[2] = frame_rate_ / 2.0f; | 503 frame_rate_layer_[2] = frame_rate_ / 2.0f; |
| 459 } | 504 } |
| 460 } | 505 } |
| 461 | 506 |
| 462 // Processes all frames in the clip and verifies the result. | 507 // Processes all frames in the clip and verifies the result. |
| 463 void ProcessFramesAndVerify(QualityMetrics quality_metrics, | 508 void ProcessFramesAndVerify(QualityMetrics quality_metrics, |
| 464 RateProfile rate_profile, | 509 RateProfile rate_profile, |
| 465 CodecConfigPars process, | 510 CodecConfigPars process, |
| 466 RateControlMetrics* rc_metrics) { | 511 RateControlMetrics* rc_metrics, |
| 512 const VisualizationParams* visualization_params) { |
| 467 // Codec/config settings. | 513 // Codec/config settings. |
| 468 start_bitrate_ = rate_profile.target_bit_rate[0]; | 514 start_bitrate_ = rate_profile.target_bit_rate[0]; |
| 515 start_frame_rate_ = rate_profile.input_frame_rate[0]; |
| 469 packet_loss_ = process.packet_loss; | 516 packet_loss_ = process.packet_loss; |
| 470 num_temporal_layers_ = process.num_temporal_layers; | 517 num_temporal_layers_ = process.num_temporal_layers; |
| 471 SetUpCodecConfig(process); | 518 SetUpCodecConfig(process, visualization_params); |
| 472 // Update the layers and the codec with the initial rates. | 519 // Update the layers and the codec with the initial rates. |
| 473 bit_rate_ = rate_profile.target_bit_rate[0]; | 520 bit_rate_ = rate_profile.target_bit_rate[0]; |
| 474 frame_rate_ = rate_profile.input_frame_rate[0]; | 521 frame_rate_ = rate_profile.input_frame_rate[0]; |
| 475 SetLayerRates(); | 522 SetLayerRates(); |
| 476 // Set the initial target size for key frame. | 523 // Set the initial target size for key frame. |
| 477 target_size_key_frame_initial_ = | 524 target_size_key_frame_initial_ = |
| 478 0.5 * kInitialBufferSize * bit_rate_layer_[0]; | 525 0.5 * kInitialBufferSize * bit_rate_layer_[0]; |
| 479 processor_->SetRates(bit_rate_, frame_rate_); | 526 processor_->SetRates(bit_rate_, frame_rate_); |
| 480 | 527 |
| 481 // Process each frame, up to |num_frames|. | 528 // Process each frame, up to |num_frames|. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 rc_metrics[update_index].max_num_dropped_frames, | 574 rc_metrics[update_index].max_num_dropped_frames, |
| 528 rc_metrics[update_index].num_spatial_resizes, | 575 rc_metrics[update_index].num_spatial_resizes, |
| 529 rc_metrics[update_index].num_key_frames); | 576 rc_metrics[update_index].num_key_frames); |
| 530 EXPECT_EQ(num_frames, frame_number); | 577 EXPECT_EQ(num_frames, frame_number); |
| 531 EXPECT_EQ(num_frames + 1, static_cast<int>(stats_.stats_.size())); | 578 EXPECT_EQ(num_frames + 1, static_cast<int>(stats_.stats_.size())); |
| 532 | 579 |
| 533 // Release encoder and decoder to make sure they have finished processing: | 580 // Release encoder and decoder to make sure they have finished processing: |
| 534 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release()); | 581 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release()); |
| 535 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release()); | 582 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release()); |
| 536 | 583 |
| 537 // Close the files before we start using them for SSIM/PSNR calculations. | 584 // Close the analysis files before we use them for SSIM/PSNR calculations. |
| 538 frame_reader_->Close(); | 585 analysis_frame_reader_->Close(); |
| 539 frame_writer_->Close(); | 586 analysis_frame_writer_->Close(); |
| 540 | 587 |
| 541 // TODO(marpan): should compute these quality metrics per SetRates update. | 588 // Close visualization files. |
| 589 if (source_frame_writer_) { |
| 590 source_frame_writer_->Close(); |
| 591 } |
| 592 if (encoded_frame_writer_) { |
| 593 encoded_frame_writer_->Close(); |
| 594 } |
| 595 if (decoded_frame_writer_) { |
| 596 decoded_frame_writer_->Close(); |
| 597 } |
| 598 |
| 599 // TODO(marpan): Should compute these quality metrics per SetRates update. |
| 542 test::QualityMetricsResult psnr_result, ssim_result; | 600 test::QualityMetricsResult psnr_result, ssim_result; |
| 543 EXPECT_EQ(0, test::I420MetricsFromFiles(config_.input_filename.c_str(), | 601 EXPECT_EQ(0, test::I420MetricsFromFiles(config_.input_filename.c_str(), |
| 544 config_.output_filename.c_str(), | 602 config_.output_filename.c_str(), |
| 545 config_.codec_settings->width, | 603 config_.codec_settings->width, |
| 546 config_.codec_settings->height, | 604 config_.codec_settings->height, |
| 547 &psnr_result, &ssim_result)); | 605 &psnr_result, &ssim_result)); |
| 548 printf("PSNR avg: %f, min: %f\nSSIM avg: %f, min: %f\n", | 606 printf("PSNR avg: %f, min: %f\nSSIM avg: %f, min: %f\n", |
| 549 psnr_result.average, psnr_result.min, ssim_result.average, | 607 psnr_result.average, psnr_result.min, ssim_result.average, |
| 550 ssim_result.min); | 608 ssim_result.min); |
| 551 stats_.PrintSummary(); | 609 stats_.PrintSummary(); |
| 552 EXPECT_GT(psnr_result.average, quality_metrics.minimum_avg_psnr); | 610 EXPECT_GT(psnr_result.average, quality_metrics.minimum_avg_psnr); |
| 553 EXPECT_GT(psnr_result.min, quality_metrics.minimum_min_psnr); | 611 EXPECT_GT(psnr_result.min, quality_metrics.minimum_min_psnr); |
| 554 EXPECT_GT(ssim_result.average, quality_metrics.minimum_avg_ssim); | 612 EXPECT_GT(ssim_result.average, quality_metrics.minimum_avg_ssim); |
| 555 EXPECT_GT(ssim_result.min, quality_metrics.minimum_min_ssim); | 613 EXPECT_GT(ssim_result.min, quality_metrics.minimum_min_ssim); |
| 614 |
| 615 // Remove analysis file. |
| 556 if (remove(config_.output_filename.c_str()) < 0) { | 616 if (remove(config_.output_filename.c_str()) < 0) { |
| 557 fprintf(stderr, "Failed to remove temporary file!\n"); | 617 fprintf(stderr, "Failed to remove temporary file!\n"); |
| 558 } | 618 } |
| 559 } | 619 } |
| 560 | 620 |
| 561 static void SetRateProfilePars(RateProfile* rate_profile, | |
| 562 int update_index, | |
| 563 int bit_rate, | |
| 564 int frame_rate, | |
| 565 int frame_index_rate_update) { | |
| 566 rate_profile->target_bit_rate[update_index] = bit_rate; | |
| 567 rate_profile->input_frame_rate[update_index] = frame_rate; | |
| 568 rate_profile->frame_index_rate_update[update_index] = | |
| 569 frame_index_rate_update; | |
| 570 } | |
| 571 | |
| 572 static void SetCodecParameters(CodecConfigPars* process_settings, | 621 static void SetCodecParameters(CodecConfigPars* process_settings, |
| 573 VideoCodecType codec_type, | 622 VideoCodecType codec_type, |
| 574 bool hw_codec, | 623 bool hw_codec, |
| 575 bool use_single_core, | 624 bool use_single_core, |
| 576 float packet_loss, | 625 float packet_loss, |
| 577 int key_frame_interval, | 626 int key_frame_interval, |
| 578 int num_temporal_layers, | 627 int num_temporal_layers, |
| 579 bool error_concealment_on, | 628 bool error_concealment_on, |
| 580 bool denoising_on, | 629 bool denoising_on, |
| 581 bool frame_dropper_on, | 630 bool frame_dropper_on, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 double minimum_avg_psnr, | 671 double minimum_avg_psnr, |
| 623 double minimum_min_psnr, | 672 double minimum_min_psnr, |
| 624 double minimum_avg_ssim, | 673 double minimum_avg_ssim, |
| 625 double minimum_min_ssim) { | 674 double minimum_min_ssim) { |
| 626 quality_metrics->minimum_avg_psnr = minimum_avg_psnr; | 675 quality_metrics->minimum_avg_psnr = minimum_avg_psnr; |
| 627 quality_metrics->minimum_min_psnr = minimum_min_psnr; | 676 quality_metrics->minimum_min_psnr = minimum_min_psnr; |
| 628 quality_metrics->minimum_avg_ssim = minimum_avg_ssim; | 677 quality_metrics->minimum_avg_ssim = minimum_avg_ssim; |
| 629 quality_metrics->minimum_min_ssim = minimum_min_ssim; | 678 quality_metrics->minimum_min_ssim = minimum_min_ssim; |
| 630 } | 679 } |
| 631 | 680 |
| 681 static void SetRateProfilePars(RateProfile* rate_profile, |
| 682 int update_index, |
| 683 int bit_rate, |
| 684 int frame_rate, |
| 685 int frame_index_rate_update) { |
| 686 rate_profile->target_bit_rate[update_index] = bit_rate; |
| 687 rate_profile->input_frame_rate[update_index] = frame_rate; |
| 688 rate_profile->frame_index_rate_update[update_index] = |
| 689 frame_index_rate_update; |
| 690 } |
| 691 |
| 632 static void SetRateControlMetrics(RateControlMetrics* rc_metrics, | 692 static void SetRateControlMetrics(RateControlMetrics* rc_metrics, |
| 633 int update_index, | 693 int update_index, |
| 634 int max_num_dropped_frames, | 694 int max_num_dropped_frames, |
| 635 int max_key_frame_size_mismatch, | 695 int max_key_frame_size_mismatch, |
| 636 int max_delta_frame_size_mismatch, | 696 int max_delta_frame_size_mismatch, |
| 637 int max_encoding_rate_mismatch, | 697 int max_encoding_rate_mismatch, |
| 638 int max_time_hit_target, | 698 int max_time_hit_target, |
| 639 int num_spatial_resizes, | 699 int num_spatial_resizes, |
| 640 int num_key_frames) { | 700 int num_key_frames) { |
| 641 rc_metrics[update_index].max_num_dropped_frames = max_num_dropped_frames; | 701 rc_metrics[update_index].max_num_dropped_frames = max_num_dropped_frames; |
| 642 rc_metrics[update_index].max_key_frame_size_mismatch = | 702 rc_metrics[update_index].max_key_frame_size_mismatch = |
| 643 max_key_frame_size_mismatch; | 703 max_key_frame_size_mismatch; |
| 644 rc_metrics[update_index].max_delta_frame_size_mismatch = | 704 rc_metrics[update_index].max_delta_frame_size_mismatch = |
| 645 max_delta_frame_size_mismatch; | 705 max_delta_frame_size_mismatch; |
| 646 rc_metrics[update_index].max_encoding_rate_mismatch = | 706 rc_metrics[update_index].max_encoding_rate_mismatch = |
| 647 max_encoding_rate_mismatch; | 707 max_encoding_rate_mismatch; |
| 648 rc_metrics[update_index].max_time_hit_target = max_time_hit_target; | 708 rc_metrics[update_index].max_time_hit_target = max_time_hit_target; |
| 649 rc_metrics[update_index].num_spatial_resizes = num_spatial_resizes; | 709 rc_metrics[update_index].num_spatial_resizes = num_spatial_resizes; |
| 650 rc_metrics[update_index].num_key_frames = num_key_frames; | 710 rc_metrics[update_index].num_key_frames = num_key_frames; |
| 651 } | 711 } |
| 652 | 712 |
| 713 // Codecs. |
| 653 std::unique_ptr<VideoEncoder> encoder_; | 714 std::unique_ptr<VideoEncoder> encoder_; |
| 654 std::unique_ptr<cricket::WebRtcVideoEncoderFactory> external_encoder_factory_; | 715 std::unique_ptr<cricket::WebRtcVideoEncoderFactory> external_encoder_factory_; |
| 655 std::unique_ptr<VideoDecoder> decoder_; | 716 std::unique_ptr<VideoDecoder> decoder_; |
| 656 std::unique_ptr<cricket::WebRtcVideoDecoderFactory> external_decoder_factory_; | 717 std::unique_ptr<cricket::WebRtcVideoDecoderFactory> external_decoder_factory_; |
| 657 std::unique_ptr<test::FrameReader> frame_reader_; | 718 VideoCodec codec_settings_; |
| 658 std::unique_ptr<test::FrameWriter> frame_writer_; | 719 |
| 720 // Helper objects. |
| 721 std::unique_ptr<test::FrameReader> analysis_frame_reader_; |
| 722 std::unique_ptr<test::FrameWriter> analysis_frame_writer_; |
| 659 test::PacketReader packet_reader_; | 723 test::PacketReader packet_reader_; |
| 660 std::unique_ptr<test::PacketManipulator> packet_manipulator_; | 724 std::unique_ptr<test::PacketManipulator> packet_manipulator_; |
| 661 test::Stats stats_; | 725 test::Stats stats_; |
| 662 test::TestConfig config_; | 726 test::TestConfig config_; |
| 663 VideoCodec codec_settings_; | |
| 664 // Must be destroyed before |encoder_| and |decoder_|. | 727 // Must be destroyed before |encoder_| and |decoder_|. |
| 665 std::unique_ptr<test::VideoProcessor> processor_; | 728 std::unique_ptr<test::VideoProcessor> processor_; |
| 666 TemporalLayersFactory tl_factory_; | 729 |
| 730 // Visualization objects. |
| 731 std::unique_ptr<test::FrameWriter> source_frame_writer_; |
| 732 std::unique_ptr<IvfFileWriter> encoded_frame_writer_; |
| 733 std::unique_ptr<test::FrameWriter> decoded_frame_writer_; |
| 667 | 734 |
| 668 // Quantities defined/updated for every encoder rate update. | 735 // Quantities defined/updated for every encoder rate update. |
| 669 // Some quantities defined per temporal layer (at most 3 layers in this test). | 736 // Some quantities defined per temporal layer (at most 3 layers in this test). |
| 670 int num_frames_per_update_[3]; | 737 int num_frames_per_update_[3]; |
| 671 float sum_frame_size_mismatch_[3]; | 738 float sum_frame_size_mismatch_[3]; |
| 672 float sum_encoded_frame_size_[3]; | 739 float sum_encoded_frame_size_[3]; |
| 673 float encoding_bitrate_[3]; | 740 float encoding_bitrate_[3]; |
| 674 float per_frame_bandwidth_[3]; | 741 float per_frame_bandwidth_[3]; |
| 675 float bit_rate_layer_[3]; | 742 float bit_rate_layer_[3]; |
| 676 float frame_rate_layer_[3]; | 743 float frame_rate_layer_[3]; |
| 677 int num_frames_total_; | 744 int num_frames_total_; |
| 678 float sum_encoded_frame_size_total_; | 745 float sum_encoded_frame_size_total_; |
| 679 float encoding_bitrate_total_; | 746 float encoding_bitrate_total_; |
| 680 float perc_encoding_rate_mismatch_; | 747 float perc_encoding_rate_mismatch_; |
| 681 int num_frames_to_hit_target_; | 748 int num_frames_to_hit_target_; |
| 682 bool encoding_rate_within_target_; | 749 bool encoding_rate_within_target_; |
| 683 int bit_rate_; | 750 int bit_rate_; |
| 684 int frame_rate_; | 751 int frame_rate_; |
| 685 int layer_; | 752 int layer_; |
| 686 float target_size_key_frame_initial_; | 753 float target_size_key_frame_initial_; |
| 687 float target_size_key_frame_; | 754 float target_size_key_frame_; |
| 688 float sum_key_frame_size_mismatch_; | 755 float sum_key_frame_size_mismatch_; |
| 689 int num_key_frames_; | 756 int num_key_frames_; |
| 690 float start_bitrate_; | 757 float start_bitrate_; |
| 758 int start_frame_rate_; |
| 691 | 759 |
| 692 // Codec and network settings. | 760 // Codec and network settings. |
| 693 float packet_loss_; | 761 float packet_loss_; |
| 694 int num_temporal_layers_; | 762 int num_temporal_layers_; |
| 695 }; | 763 }; |
| 696 | 764 |
| 697 } // namespace test | 765 } // namespace test |
| 698 } // namespace webrtc | 766 } // namespace webrtc |
| 699 | 767 |
| 700 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES
T_H_ | 768 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES
T_H_ |
| OLD | NEW |