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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 | 55 |
56 const int kPercTargetvsActualMismatch = 20; | 56 const int kPercTargetvsActualMismatch = 20; |
57 const int kBaseKeyFrameInterval = 3000; | 57 const int kBaseKeyFrameInterval = 3000; |
58 | 58 |
59 // Default sequence is foreman (CIF): may be better to use VGA for resize test. | 59 // Default sequence is foreman (CIF): may be better to use VGA for resize test. |
60 const int kCifWidth = 352; | 60 const int kCifWidth = 352; |
61 const int kCifHeight = 288; | 61 const int kCifHeight = 288; |
62 const char kFilenameForemanCif[] = "foreman_cif"; | 62 const char kFilenameForemanCif[] = "foreman_cif"; |
63 | 63 |
64 // Codec and network settings. | 64 // Codec and network settings. |
65 struct CodecConfigPars { | 65 struct CodecParams { |
66 VideoCodecType codec_type; | 66 VideoCodecType codec_type; |
67 bool hw_codec; | 67 bool hw_codec; |
68 bool use_single_core; | 68 bool use_single_core; |
69 float packet_loss; | 69 |
70 int width; | |
71 int height; | |
72 | |
70 int num_temporal_layers; | 73 int num_temporal_layers; |
71 int key_frame_interval; | 74 int key_frame_interval; |
72 bool error_concealment_on; | 75 bool error_concealment_on; |
73 bool denoising_on; | 76 bool denoising_on; |
74 bool frame_dropper_on; | 77 bool frame_dropper_on; |
75 bool spatial_resize_on; | 78 bool spatial_resize_on; |
76 int width; | 79 |
77 int height; | 80 float packet_loss; |
sprang_webrtc
2017/02/22 16:39:31
packet_loss_perecent? or fraction?
brandtr
2017/02/23 08:16:45
Fixed :)
| |
81 | |
78 std::string filename; | 82 std::string filename; |
79 bool verbose_logging; | 83 bool verbose_logging; |
80 }; | 84 }; |
81 | 85 |
82 // Quality metrics. | 86 // Thresholds for the quality metrics. |
83 struct QualityMetrics { | 87 struct QualityThresholds { |
84 double minimum_avg_psnr; | 88 double min_avg_psnr; |
85 double minimum_min_psnr; | 89 double min_min_psnr; |
86 double minimum_avg_ssim; | 90 double min_avg_ssim; |
87 double minimum_min_ssim; | 91 double min_min_ssim; |
88 }; | 92 }; |
89 | 93 |
90 // The sequence of bitrate and frame rate changes for the encoder, the frame | 94 // The sequence of bit rate and frame rate changes for the encoder, the frame |
91 // number where the changes are made, and the total number of frames for the | 95 // number where the changes are made, and the total number of frames for the |
92 // test. | 96 // test. |
93 struct RateProfile { | 97 struct RateProfile { |
94 int target_bit_rate[kMaxNumRateUpdates]; | 98 int target_bit_rate[kMaxNumRateUpdates]; |
95 int input_frame_rate[kMaxNumRateUpdates]; | 99 int input_frame_rate[kMaxNumRateUpdates]; |
96 int frame_index_rate_update[kMaxNumRateUpdates + 1]; | 100 int frame_index_rate_update[kMaxNumRateUpdates + 1]; |
97 int num_frames; | 101 int num_frames; |
98 }; | 102 }; |
99 | 103 |
100 // Metrics for the rate control. The rate mismatch metrics are defined as | 104 // Thresholds for the rate control metrics. The rate mismatch thresholds are |
101 // percentages.|max_time_hit_target| is defined as number of frames, after a | 105 // defined as percentages. |max_time_hit_target| is defined as number of frames, |
102 // rate update is made to the encoder, for the encoder to reach within | 106 // after a rate update is made to the encoder, for the encoder to reach within |
103 // |kPercTargetvsActualMismatch| of new target rate. The metrics are defined for | 107 // |kPercTargetvsActualMismatch| of new target rate. The thresholds are defined |
104 // each rate update sequence. | 108 // for each rate update sequence. |
105 struct RateControlMetrics { | 109 struct RateControlThresholds { |
106 int max_num_dropped_frames; | 110 int max_num_dropped_frames; |
107 int max_key_frame_size_mismatch; | 111 int max_key_frame_size_mismatch; |
108 int max_delta_frame_size_mismatch; | 112 int max_delta_frame_size_mismatch; |
109 int max_encoding_rate_mismatch; | 113 int max_encoding_rate_mismatch; |
110 int max_time_hit_target; | 114 int max_time_hit_target; |
111 int num_spatial_resizes; | 115 int num_spatial_resizes; |
112 int num_key_frames; | 116 int num_key_frames; |
113 }; | 117 }; |
114 | 118 |
115 // Should video files be saved persistently to disk for post-run visualization? | 119 // Should video files be saved persistently to disk for post-run visualization? |
116 struct VisualizationParams { | 120 struct VisualizationParams { |
117 bool save_source_y4m; | 121 bool save_source_y4m; |
118 bool save_encoded_ivf; | 122 bool save_encoded_ivf; |
119 bool save_decoded_y4m; | 123 bool save_decoded_y4m; |
120 }; | 124 }; |
121 | 125 |
122 #if !defined(WEBRTC_IOS) | 126 #if !defined(WEBRTC_IOS) |
123 const int kNumFramesShort = 100; | 127 const int kNumFramesShort = 100; |
124 #endif | 128 #endif |
125 const int kNumFramesLong = 299; | 129 const int kNumFramesLong = 299; |
126 | 130 |
127 // Parameters from VP8 wrapper, which control target size of key frames. | 131 // Parameters from VP8 wrapper, which control target size of key frames. |
128 const float kInitialBufferSize = 0.5f; | 132 const float kInitialBufferSize = 0.5f; |
129 const float kOptimalBufferSize = 0.6f; | 133 const float kOptimalBufferSize = 0.6f; |
130 const float kScaleKeyFrameSize = 0.5f; | 134 const float kScaleKeyFrameSize = 0.5f; |
131 | 135 |
132 // Integration test for video processor. Encodes+decodes a clip and | 136 // Integration test for video processor. Encodes+decodes a clip and |
133 // writes it to the output directory. After completion, quality metrics | 137 // writes it to the output directory. After completion, quality metrics |
134 // (PSNR and SSIM) and rate control metrics are computed to verify that the | 138 // (PSNR and SSIM) and rate control metrics are computed and compared to given |
135 // quality and encoder response is acceptable. The rate control tests allow us | 139 // thresholds, to verify that the quality and encoder response is acceptable. |
136 // to verify the behavior for changing bitrate, changing frame rate, frame | 140 // The rate control tests allow us to verify the behavior for changing bit rate, |
137 // dropping/spatial resize, and temporal layers. The limits for the rate | 141 // changing frame rate, frame dropping/spatial resize, and temporal layers. |
138 // control metrics are set to be fairly conservative, so failure should only | 142 // The thresholds for the rate control metrics are set to be fairly |
139 // happen when some significant regression or breakdown occurs. | 143 // conservative, so failure should only happen when some significant regression |
144 // or breakdown occurs. | |
140 class VideoProcessorIntegrationTest : public testing::Test { | 145 class VideoProcessorIntegrationTest : public testing::Test { |
141 protected: | 146 protected: |
142 VideoProcessorIntegrationTest() { | 147 VideoProcessorIntegrationTest() { |
143 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) && \ | 148 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) && \ |
144 defined(WEBRTC_ANDROID) | 149 defined(WEBRTC_ANDROID) |
145 InitializeAndroidObjects(); | 150 InitializeAndroidObjects(); |
146 | 151 |
147 external_encoder_factory_.reset( | 152 external_encoder_factory_.reset( |
148 new webrtc_jni::MediaCodecVideoEncoderFactory()); | 153 new webrtc_jni::MediaCodecVideoEncoderFactory()); |
149 external_decoder_factory_.reset( | 154 external_decoder_factory_.reset( |
150 new webrtc_jni::MediaCodecVideoDecoderFactory()); | 155 new webrtc_jni::MediaCodecVideoDecoderFactory()); |
151 #endif | 156 #endif |
152 } | 157 } |
153 virtual ~VideoProcessorIntegrationTest() = default; | 158 virtual ~VideoProcessorIntegrationTest() = default; |
154 | 159 |
155 void SetUpCodecConfig(const CodecConfigPars& process, | 160 void SetUpCodecConfig(const CodecParams& process, |
156 const VisualizationParams* visualization_params) { | 161 const VisualizationParams* visualization_params) { |
157 if (process.hw_codec) { | 162 if (process.hw_codec) { |
158 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) | 163 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) |
159 #if defined(WEBRTC_ANDROID) | 164 #if defined(WEBRTC_ANDROID) |
160 // In general, external codecs should be destroyed by the factories that | 165 // In general, external codecs should be destroyed by the factories that |
161 // allocated them. For the particular case of the Android | 166 // allocated them. For the particular case of the Android |
162 // MediaCodecVideo{En,De}coderFactory's, however, it turns out that it is | 167 // MediaCodecVideo{En,De}coderFactory's, however, it turns out that it is |
163 // fine for the std::unique_ptr to destroy the owned codec directly. | 168 // fine for the std::unique_ptr to destroy the owned codec directly. |
164 switch (process.codec_type) { | 169 switch (process.codec_type) { |
165 case kVideoCodecH264: | 170 case kVideoCodecH264: |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 perc_encoding_rate_mismatch_ = | 391 perc_encoding_rate_mismatch_ = |
387 100 * fabs(encoding_bitrate_total_ - bit_rate_) / bit_rate_; | 392 100 * fabs(encoding_bitrate_total_ - bit_rate_) / bit_rate_; |
388 if (perc_encoding_rate_mismatch_ < kPercTargetvsActualMismatch && | 393 if (perc_encoding_rate_mismatch_ < kPercTargetvsActualMismatch && |
389 !encoding_rate_within_target_) { | 394 !encoding_rate_within_target_) { |
390 num_frames_to_hit_target_ = num_frames_total_; | 395 num_frames_to_hit_target_ = num_frames_total_; |
391 encoding_rate_within_target_ = true; | 396 encoding_rate_within_target_ = true; |
392 } | 397 } |
393 } | 398 } |
394 | 399 |
395 // Verify expected behavior of rate control and print out data. | 400 // Verify expected behavior of rate control and print out data. |
396 void VerifyRateControl(int update_index, | 401 void VerifyRateControlMetrics(int update_index, |
397 int max_key_frame_size_mismatch, | 402 int max_key_frame_size_mismatch, |
398 int max_delta_frame_size_mismatch, | 403 int max_delta_frame_size_mismatch, |
399 int max_encoding_rate_mismatch, | 404 int max_encoding_rate_mismatch, |
400 int max_time_hit_target, | 405 int max_time_hit_target, |
401 int max_num_dropped_frames, | 406 int max_num_dropped_frames, |
402 int num_spatial_resizes, | 407 int num_spatial_resizes, |
403 int num_key_frames) { | 408 int num_key_frames) { |
404 int num_dropped_frames = processor_->NumberDroppedFrames(); | 409 int num_dropped_frames = processor_->NumberDroppedFrames(); |
405 int num_resize_actions = processor_->NumberSpatialResizes(); | 410 int num_resize_actions = processor_->NumberSpatialResizes(); |
406 printf( | 411 printf( |
407 "For update #: %d,\n" | 412 "For update #: %d,\n" |
408 " Target Bitrate: %d,\n" | 413 " Target Bitrate: %d,\n" |
409 " Encoding bitrate: %f,\n" | 414 " Encoding bitrate: %f,\n" |
410 " Frame rate: %d \n", | 415 " Frame rate: %d \n", |
411 update_index, bit_rate_, encoding_bitrate_total_, frame_rate_); | 416 update_index, bit_rate_, encoding_bitrate_total_, frame_rate_); |
412 printf( | 417 printf( |
413 " Number of frames to approach target rate: %d, \n" | 418 " Number of frames to approach target rate: %d, \n" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 EXPECT_LE(perc_frame_size_mismatch, max_delta_frame_size_mismatch); | 452 EXPECT_LE(perc_frame_size_mismatch, max_delta_frame_size_mismatch); |
448 EXPECT_LE(perc_encoding_rate_mismatch, max_encoding_rate_mismatch); | 453 EXPECT_LE(perc_encoding_rate_mismatch, max_encoding_rate_mismatch); |
449 } | 454 } |
450 printf("\n"); | 455 printf("\n"); |
451 EXPECT_LE(num_frames_to_hit_target_, max_time_hit_target); | 456 EXPECT_LE(num_frames_to_hit_target_, max_time_hit_target); |
452 EXPECT_LE(num_dropped_frames, max_num_dropped_frames); | 457 EXPECT_LE(num_dropped_frames, max_num_dropped_frames); |
453 EXPECT_EQ(num_resize_actions, num_spatial_resizes); | 458 EXPECT_EQ(num_resize_actions, num_spatial_resizes); |
454 EXPECT_EQ(num_key_frames_, num_key_frames); | 459 EXPECT_EQ(num_key_frames_, num_key_frames); |
455 } | 460 } |
456 | 461 |
462 void VerifyQuality(const test::QualityMetricsResult& psnr_result, | |
463 const test::QualityMetricsResult& ssim_result, | |
464 const QualityThresholds& quality_thresholds) { | |
465 EXPECT_GT(psnr_result.average, quality_thresholds.min_avg_psnr); | |
466 EXPECT_GT(psnr_result.min, quality_thresholds.min_min_psnr); | |
467 EXPECT_GT(ssim_result.average, quality_thresholds.min_avg_ssim); | |
468 EXPECT_GT(ssim_result.min, quality_thresholds.min_min_ssim); | |
469 } | |
470 | |
457 // Layer index corresponding to frame number, for up to 3 layers. | 471 // Layer index corresponding to frame number, for up to 3 layers. |
458 void LayerIndexForFrame(int frame_number) { | 472 void LayerIndexForFrame(int frame_number) { |
459 if (num_temporal_layers_ == 1) { | 473 if (num_temporal_layers_ == 1) { |
460 layer_ = 0; | 474 layer_ = 0; |
461 } else if (num_temporal_layers_ == 2) { | 475 } else if (num_temporal_layers_ == 2) { |
462 // layer 0: 0 2 4 ... | 476 // layer 0: 0 2 4 ... |
463 // layer 1: 1 3 | 477 // layer 1: 1 3 |
464 if (frame_number % 2 == 0) { | 478 if (frame_number % 2 == 0) { |
465 layer_ = 0; | 479 layer_ = 0; |
466 } else { | 480 } else { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 } | 512 } |
499 frame_rate_layer_[i] = | 513 frame_rate_layer_[i] = |
500 frame_rate_ / static_cast<float>(1 << (num_temporal_layers_ - 1)); | 514 frame_rate_ / static_cast<float>(1 << (num_temporal_layers_ - 1)); |
501 } | 515 } |
502 if (num_temporal_layers_ == 3) { | 516 if (num_temporal_layers_ == 3) { |
503 frame_rate_layer_[2] = frame_rate_ / 2.0f; | 517 frame_rate_layer_[2] = frame_rate_ / 2.0f; |
504 } | 518 } |
505 } | 519 } |
506 | 520 |
507 // Processes all frames in the clip and verifies the result. | 521 // Processes all frames in the clip and verifies the result. |
508 void ProcessFramesAndVerify(QualityMetrics quality_metrics, | 522 void ProcessFramesAndVerify(QualityThresholds quality_thresholds, |
509 RateProfile rate_profile, | 523 RateProfile rate_profile, |
510 CodecConfigPars process, | 524 CodecParams process, |
511 RateControlMetrics* rc_metrics, | 525 RateControlThresholds* rc_thresholds, |
512 const VisualizationParams* visualization_params) { | 526 const VisualizationParams* visualization_params) { |
513 // Codec/config settings. | 527 // Codec/config settings. |
514 start_bitrate_ = rate_profile.target_bit_rate[0]; | 528 start_bitrate_ = rate_profile.target_bit_rate[0]; |
515 start_frame_rate_ = rate_profile.input_frame_rate[0]; | 529 start_frame_rate_ = rate_profile.input_frame_rate[0]; |
516 packet_loss_ = process.packet_loss; | 530 packet_loss_ = process.packet_loss; |
517 num_temporal_layers_ = process.num_temporal_layers; | 531 num_temporal_layers_ = process.num_temporal_layers; |
518 SetUpCodecConfig(process, visualization_params); | 532 SetUpCodecConfig(process, visualization_params); |
519 // Update the layers and the codec with the initial rates. | 533 // Update the layers and the codec with the initial rates. |
520 bit_rate_ = rate_profile.target_bit_rate[0]; | 534 bit_rate_ = rate_profile.target_bit_rate[0]; |
521 frame_rate_ = rate_profile.input_frame_rate[0]; | 535 frame_rate_ = rate_profile.input_frame_rate[0]; |
(...skipping 19 matching lines...) Expand all Loading... | |
541 // Counter for whole sequence run. | 555 // Counter for whole sequence run. |
542 ++frame_number; | 556 ++frame_number; |
543 // Counters for each rate update. | 557 // Counters for each rate update. |
544 ++num_frames_per_update_[layer_]; | 558 ++num_frames_per_update_[layer_]; |
545 ++num_frames_total_; | 559 ++num_frames_total_; |
546 UpdateRateControlMetrics(frame_number, frame_type); | 560 UpdateRateControlMetrics(frame_number, frame_type); |
547 // If we hit another/next update, verify stats for current state and | 561 // If we hit another/next update, verify stats for current state and |
548 // update layers and codec with new rates. | 562 // update layers and codec with new rates. |
549 if (frame_number == | 563 if (frame_number == |
550 rate_profile.frame_index_rate_update[update_index + 1]) { | 564 rate_profile.frame_index_rate_update[update_index + 1]) { |
551 VerifyRateControl( | 565 VerifyRateControlMetrics( |
552 update_index, rc_metrics[update_index].max_key_frame_size_mismatch, | 566 update_index, |
553 rc_metrics[update_index].max_delta_frame_size_mismatch, | 567 rc_thresholds[update_index].max_key_frame_size_mismatch, |
554 rc_metrics[update_index].max_encoding_rate_mismatch, | 568 rc_thresholds[update_index].max_delta_frame_size_mismatch, |
555 rc_metrics[update_index].max_time_hit_target, | 569 rc_thresholds[update_index].max_encoding_rate_mismatch, |
556 rc_metrics[update_index].max_num_dropped_frames, | 570 rc_thresholds[update_index].max_time_hit_target, |
557 rc_metrics[update_index].num_spatial_resizes, | 571 rc_thresholds[update_index].max_num_dropped_frames, |
558 rc_metrics[update_index].num_key_frames); | 572 rc_thresholds[update_index].num_spatial_resizes, |
573 rc_thresholds[update_index].num_key_frames); | |
559 // Update layer rates and the codec with new rates. | 574 // Update layer rates and the codec with new rates. |
560 ++update_index; | 575 ++update_index; |
561 bit_rate_ = rate_profile.target_bit_rate[update_index]; | 576 bit_rate_ = rate_profile.target_bit_rate[update_index]; |
562 frame_rate_ = rate_profile.input_frame_rate[update_index]; | 577 frame_rate_ = rate_profile.input_frame_rate[update_index]; |
563 SetLayerRates(); | 578 SetLayerRates(); |
564 ResetRateControlMetrics( | 579 ResetRateControlMetrics( |
565 rate_profile.frame_index_rate_update[update_index + 1]); | 580 rate_profile.frame_index_rate_update[update_index + 1]); |
566 processor_->SetRates(bit_rate_, frame_rate_); | 581 processor_->SetRates(bit_rate_, frame_rate_); |
567 } | 582 } |
568 } | 583 } |
569 VerifyRateControl(update_index, | 584 VerifyRateControlMetrics( |
570 rc_metrics[update_index].max_key_frame_size_mismatch, | 585 update_index, rc_thresholds[update_index].max_key_frame_size_mismatch, |
571 rc_metrics[update_index].max_delta_frame_size_mismatch, | 586 rc_thresholds[update_index].max_delta_frame_size_mismatch, |
572 rc_metrics[update_index].max_encoding_rate_mismatch, | 587 rc_thresholds[update_index].max_encoding_rate_mismatch, |
573 rc_metrics[update_index].max_time_hit_target, | 588 rc_thresholds[update_index].max_time_hit_target, |
574 rc_metrics[update_index].max_num_dropped_frames, | 589 rc_thresholds[update_index].max_num_dropped_frames, |
575 rc_metrics[update_index].num_spatial_resizes, | 590 rc_thresholds[update_index].num_spatial_resizes, |
576 rc_metrics[update_index].num_key_frames); | 591 rc_thresholds[update_index].num_key_frames); |
577 EXPECT_EQ(num_frames, frame_number); | 592 EXPECT_EQ(num_frames, frame_number); |
578 EXPECT_EQ(num_frames + 1, static_cast<int>(stats_.stats_.size())); | 593 EXPECT_EQ(num_frames + 1, static_cast<int>(stats_.stats_.size())); |
579 | 594 |
580 // Release encoder and decoder to make sure they have finished processing: | 595 // Release encoder and decoder to make sure they have finished processing: |
581 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release()); | 596 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release()); |
582 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release()); | 597 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release()); |
583 | 598 |
584 // Close the analysis files before we use them for SSIM/PSNR calculations. | 599 // Close the analysis files before we use them for SSIM/PSNR calculations. |
585 analysis_frame_reader_->Close(); | 600 analysis_frame_reader_->Close(); |
586 analysis_frame_writer_->Close(); | 601 analysis_frame_writer_->Close(); |
(...skipping 13 matching lines...) Expand all Loading... | |
600 test::QualityMetricsResult psnr_result, ssim_result; | 615 test::QualityMetricsResult psnr_result, ssim_result; |
601 EXPECT_EQ(0, test::I420MetricsFromFiles(config_.input_filename.c_str(), | 616 EXPECT_EQ(0, test::I420MetricsFromFiles(config_.input_filename.c_str(), |
602 config_.output_filename.c_str(), | 617 config_.output_filename.c_str(), |
603 config_.codec_settings->width, | 618 config_.codec_settings->width, |
604 config_.codec_settings->height, | 619 config_.codec_settings->height, |
605 &psnr_result, &ssim_result)); | 620 &psnr_result, &ssim_result)); |
606 printf("PSNR avg: %f, min: %f\nSSIM avg: %f, min: %f\n", | 621 printf("PSNR avg: %f, min: %f\nSSIM avg: %f, min: %f\n", |
607 psnr_result.average, psnr_result.min, ssim_result.average, | 622 psnr_result.average, psnr_result.min, ssim_result.average, |
608 ssim_result.min); | 623 ssim_result.min); |
609 stats_.PrintSummary(); | 624 stats_.PrintSummary(); |
610 EXPECT_GT(psnr_result.average, quality_metrics.minimum_avg_psnr); | 625 VerifyQuality(psnr_result, ssim_result, quality_thresholds); |
611 EXPECT_GT(psnr_result.min, quality_metrics.minimum_min_psnr); | |
612 EXPECT_GT(ssim_result.average, quality_metrics.minimum_avg_ssim); | |
613 EXPECT_GT(ssim_result.min, quality_metrics.minimum_min_ssim); | |
614 | 626 |
615 // Remove analysis file. | 627 // Remove analysis file. |
616 if (remove(config_.output_filename.c_str()) < 0) { | 628 if (remove(config_.output_filename.c_str()) < 0) { |
617 fprintf(stderr, "Failed to remove temporary file!\n"); | 629 fprintf(stderr, "Failed to remove temporary file!\n"); |
618 } | 630 } |
619 } | 631 } |
620 | 632 |
621 static void SetCodecParameters(CodecConfigPars* process_settings, | 633 static void SetCodecParams(CodecParams* process_settings, |
622 VideoCodecType codec_type, | 634 VideoCodecType codec_type, |
623 bool hw_codec, | 635 bool hw_codec, |
624 bool use_single_core, | 636 bool use_single_core, |
625 float packet_loss, | 637 float packet_loss, |
626 int key_frame_interval, | 638 int key_frame_interval, |
627 int num_temporal_layers, | 639 int num_temporal_layers, |
628 bool error_concealment_on, | 640 bool error_concealment_on, |
629 bool denoising_on, | 641 bool denoising_on, |
630 bool frame_dropper_on, | 642 bool frame_dropper_on, |
631 bool spatial_resize_on, | 643 bool spatial_resize_on, |
632 int width, | 644 int width, |
633 int height, | 645 int height, |
634 const std::string& filename, | 646 const std::string& filename, |
635 bool verbose_logging) { | 647 bool verbose_logging) { |
636 process_settings->codec_type = codec_type; | 648 process_settings->codec_type = codec_type; |
637 process_settings->hw_codec = hw_codec; | 649 process_settings->hw_codec = hw_codec; |
638 process_settings->use_single_core = use_single_core; | 650 process_settings->use_single_core = use_single_core; |
639 process_settings->packet_loss = packet_loss; | 651 process_settings->packet_loss = packet_loss; |
640 process_settings->key_frame_interval = key_frame_interval; | 652 process_settings->key_frame_interval = key_frame_interval; |
641 process_settings->num_temporal_layers = num_temporal_layers, | 653 process_settings->num_temporal_layers = num_temporal_layers, |
642 process_settings->error_concealment_on = error_concealment_on; | 654 process_settings->error_concealment_on = error_concealment_on; |
643 process_settings->denoising_on = denoising_on; | 655 process_settings->denoising_on = denoising_on; |
644 process_settings->frame_dropper_on = frame_dropper_on; | 656 process_settings->frame_dropper_on = frame_dropper_on; |
645 process_settings->spatial_resize_on = spatial_resize_on; | 657 process_settings->spatial_resize_on = spatial_resize_on; |
646 process_settings->width = width; | 658 process_settings->width = width; |
647 process_settings->height = height; | 659 process_settings->height = height; |
648 process_settings->filename = filename; | 660 process_settings->filename = filename; |
649 process_settings->verbose_logging = verbose_logging; | 661 process_settings->verbose_logging = verbose_logging; |
650 } | 662 } |
651 | 663 |
652 static void SetCodecParameters(CodecConfigPars* process_settings, | 664 static void SetCodecParams(CodecParams* process_settings, |
653 VideoCodecType codec_type, | 665 VideoCodecType codec_type, |
654 bool hw_codec, | 666 bool hw_codec, |
655 bool use_single_core, | 667 bool use_single_core, |
656 float packet_loss, | 668 float packet_loss, |
657 int key_frame_interval, | 669 int key_frame_interval, |
658 int num_temporal_layers, | 670 int num_temporal_layers, |
659 bool error_concealment_on, | 671 bool error_concealment_on, |
660 bool denoising_on, | 672 bool denoising_on, |
661 bool frame_dropper_on, | 673 bool frame_dropper_on, |
662 bool spatial_resize_on) { | 674 bool spatial_resize_on) { |
663 SetCodecParameters(process_settings, codec_type, hw_codec, use_single_core, | 675 SetCodecParams(process_settings, codec_type, hw_codec, use_single_core, |
664 packet_loss, key_frame_interval, num_temporal_layers, | 676 packet_loss, key_frame_interval, num_temporal_layers, |
665 error_concealment_on, denoising_on, frame_dropper_on, | 677 error_concealment_on, denoising_on, frame_dropper_on, |
666 spatial_resize_on, kCifWidth, kCifHeight, | 678 spatial_resize_on, kCifWidth, kCifHeight, |
667 kFilenameForemanCif, false /* verbose_logging */); | 679 kFilenameForemanCif, false /* verbose_logging */); |
668 } | 680 } |
669 | 681 |
670 static void SetQualityMetrics(QualityMetrics* quality_metrics, | 682 static void SetQualityThresholds(QualityThresholds* quality_thresholds, |
671 double minimum_avg_psnr, | 683 double min_avg_psnr, |
672 double minimum_min_psnr, | 684 double min_min_psnr, |
673 double minimum_avg_ssim, | 685 double min_avg_ssim, |
674 double minimum_min_ssim) { | 686 double min_min_ssim) { |
675 quality_metrics->minimum_avg_psnr = minimum_avg_psnr; | 687 quality_thresholds->min_avg_psnr = min_avg_psnr; |
676 quality_metrics->minimum_min_psnr = minimum_min_psnr; | 688 quality_thresholds->min_min_psnr = min_min_psnr; |
677 quality_metrics->minimum_avg_ssim = minimum_avg_ssim; | 689 quality_thresholds->min_avg_ssim = min_avg_ssim; |
678 quality_metrics->minimum_min_ssim = minimum_min_ssim; | 690 quality_thresholds->min_min_ssim = min_min_ssim; |
679 } | 691 } |
680 | 692 |
681 static void SetRateProfilePars(RateProfile* rate_profile, | 693 static void SetRateProfile(RateProfile* rate_profile, |
682 int update_index, | 694 int update_index, |
683 int bit_rate, | 695 int bit_rate, |
684 int frame_rate, | 696 int frame_rate, |
685 int frame_index_rate_update) { | 697 int frame_index_rate_update) { |
686 rate_profile->target_bit_rate[update_index] = bit_rate; | 698 rate_profile->target_bit_rate[update_index] = bit_rate; |
687 rate_profile->input_frame_rate[update_index] = frame_rate; | 699 rate_profile->input_frame_rate[update_index] = frame_rate; |
688 rate_profile->frame_index_rate_update[update_index] = | 700 rate_profile->frame_index_rate_update[update_index] = |
689 frame_index_rate_update; | 701 frame_index_rate_update; |
690 } | 702 } |
691 | 703 |
692 static void SetRateControlMetrics(RateControlMetrics* rc_metrics, | 704 static void SetRateControlThresholds(RateControlThresholds* rc_thresholds, |
693 int update_index, | 705 int update_index, |
694 int max_num_dropped_frames, | 706 int max_num_dropped_frames, |
695 int max_key_frame_size_mismatch, | 707 int max_key_frame_size_mismatch, |
696 int max_delta_frame_size_mismatch, | 708 int max_delta_frame_size_mismatch, |
697 int max_encoding_rate_mismatch, | 709 int max_encoding_rate_mismatch, |
698 int max_time_hit_target, | 710 int max_time_hit_target, |
699 int num_spatial_resizes, | 711 int num_spatial_resizes, |
700 int num_key_frames) { | 712 int num_key_frames) { |
701 rc_metrics[update_index].max_num_dropped_frames = max_num_dropped_frames; | 713 rc_thresholds[update_index].max_num_dropped_frames = max_num_dropped_frames; |
702 rc_metrics[update_index].max_key_frame_size_mismatch = | 714 rc_thresholds[update_index].max_key_frame_size_mismatch = |
703 max_key_frame_size_mismatch; | 715 max_key_frame_size_mismatch; |
704 rc_metrics[update_index].max_delta_frame_size_mismatch = | 716 rc_thresholds[update_index].max_delta_frame_size_mismatch = |
705 max_delta_frame_size_mismatch; | 717 max_delta_frame_size_mismatch; |
706 rc_metrics[update_index].max_encoding_rate_mismatch = | 718 rc_thresholds[update_index].max_encoding_rate_mismatch = |
707 max_encoding_rate_mismatch; | 719 max_encoding_rate_mismatch; |
708 rc_metrics[update_index].max_time_hit_target = max_time_hit_target; | 720 rc_thresholds[update_index].max_time_hit_target = max_time_hit_target; |
709 rc_metrics[update_index].num_spatial_resizes = num_spatial_resizes; | 721 rc_thresholds[update_index].num_spatial_resizes = num_spatial_resizes; |
710 rc_metrics[update_index].num_key_frames = num_key_frames; | 722 rc_thresholds[update_index].num_key_frames = num_key_frames; |
711 } | 723 } |
712 | 724 |
713 // Codecs. | 725 // Codecs. |
714 std::unique_ptr<VideoEncoder> encoder_; | 726 std::unique_ptr<VideoEncoder> encoder_; |
715 std::unique_ptr<cricket::WebRtcVideoEncoderFactory> external_encoder_factory_; | 727 std::unique_ptr<cricket::WebRtcVideoEncoderFactory> external_encoder_factory_; |
716 std::unique_ptr<VideoDecoder> decoder_; | 728 std::unique_ptr<VideoDecoder> decoder_; |
717 std::unique_ptr<cricket::WebRtcVideoDecoderFactory> external_decoder_factory_; | 729 std::unique_ptr<cricket::WebRtcVideoDecoderFactory> external_decoder_factory_; |
718 VideoCodec codec_settings_; | 730 VideoCodec codec_settings_; |
719 | 731 |
720 // Helper objects. | 732 // Helper objects. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
759 | 771 |
760 // Codec and network settings. | 772 // Codec and network settings. |
761 float packet_loss_; | 773 float packet_loss_; |
762 int num_temporal_layers_; | 774 int num_temporal_layers_; |
763 }; | 775 }; |
764 | 776 |
765 } // namespace test | 777 } // namespace test |
766 } // namespace webrtc | 778 } // namespace webrtc |
767 | 779 |
768 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES T_H_ | 780 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES T_H_ |
OLD | NEW |