| 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 #include <math.h> | 11 #include <math.h> |
| 12 | 12 |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 15 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
| 16 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h" | 16 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h" |
| 17 #include "webrtc/modules/video_coding/codecs/test/videoprocessor.h" | 17 #include "webrtc/modules/video_coding/codecs/test/videoprocessor.h" |
| 18 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" |
| 18 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" | 19 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" |
| 20 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" |
| 19 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" | 21 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" |
| 20 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" | |
| 21 #include "webrtc/modules/video_coding/include/video_coding.h" | 22 #include "webrtc/modules/video_coding/include/video_coding.h" |
| 22 #include "webrtc/test/testsupport/fileutils.h" | 23 #include "webrtc/test/testsupport/fileutils.h" |
| 23 #include "webrtc/test/testsupport/frame_reader.h" | 24 #include "webrtc/test/testsupport/frame_reader.h" |
| 24 #include "webrtc/test/testsupport/frame_writer.h" | 25 #include "webrtc/test/testsupport/frame_writer.h" |
| 25 #include "webrtc/test/testsupport/metrics/video_metrics.h" | 26 #include "webrtc/test/testsupport/metrics/video_metrics.h" |
| 26 #include "webrtc/test/testsupport/packet_reader.h" | 27 #include "webrtc/test/testsupport/packet_reader.h" |
| 27 #include "webrtc/typedefs.h" | 28 #include "webrtc/typedefs.h" |
| 28 | 29 |
| 29 namespace webrtc { | 30 namespace webrtc { |
| 30 | 31 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 int key_frame_interval_; | 144 int key_frame_interval_; |
| 144 bool error_concealment_on_; | 145 bool error_concealment_on_; |
| 145 bool denoising_on_; | 146 bool denoising_on_; |
| 146 bool frame_dropper_on_; | 147 bool frame_dropper_on_; |
| 147 bool spatial_resize_on_; | 148 bool spatial_resize_on_; |
| 148 | 149 |
| 149 VideoProcessorIntegrationTest() {} | 150 VideoProcessorIntegrationTest() {} |
| 150 virtual ~VideoProcessorIntegrationTest() {} | 151 virtual ~VideoProcessorIntegrationTest() {} |
| 151 | 152 |
| 152 void SetUpCodecConfig() { | 153 void SetUpCodecConfig() { |
| 153 if (codec_type_ == kVideoCodecVP8) { | 154 if (codec_type_ == kVideoCodecH264) { |
| 155 encoder_ = H264Encoder::Create(); |
| 156 decoder_ = H264Decoder::Create(); |
| 157 VideoCodingModule::Codec(kVideoCodecH264, &codec_settings_); |
| 158 } else if (codec_type_ == kVideoCodecVP8) { |
| 154 encoder_ = VP8Encoder::Create(); | 159 encoder_ = VP8Encoder::Create(); |
| 155 decoder_ = VP8Decoder::Create(); | 160 decoder_ = VP8Decoder::Create(); |
| 156 VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_); | 161 VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_); |
| 157 } else if (codec_type_ == kVideoCodecVP9) { | 162 } else if (codec_type_ == kVideoCodecVP9) { |
| 158 encoder_ = VP9Encoder::Create(); | 163 encoder_ = VP9Encoder::Create(); |
| 159 decoder_ = VP9Decoder::Create(); | 164 decoder_ = VP9Decoder::Create(); |
| 160 VideoCodingModule::Codec(kVideoCodecVP9, &codec_settings_); | 165 VideoCodingModule::Codec(kVideoCodecVP9, &codec_settings_); |
| 161 } | 166 } |
| 162 | 167 |
| 163 // CIF is currently used for all tests below. | 168 // CIF is currently used for all tests below. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 177 config_.networking_config.packet_loss_probability = packet_loss_; | 182 config_.networking_config.packet_loss_probability = packet_loss_; |
| 178 | 183 |
| 179 // Configure codec settings. | 184 // Configure codec settings. |
| 180 config_.codec_settings = &codec_settings_; | 185 config_.codec_settings = &codec_settings_; |
| 181 config_.codec_settings->startBitrate = start_bitrate_; | 186 config_.codec_settings->startBitrate = start_bitrate_; |
| 182 config_.codec_settings->width = kCIFWidth; | 187 config_.codec_settings->width = kCIFWidth; |
| 183 config_.codec_settings->height = kCIFHeight; | 188 config_.codec_settings->height = kCIFHeight; |
| 184 | 189 |
| 185 // These features may be set depending on the test. | 190 // These features may be set depending on the test. |
| 186 switch (config_.codec_settings->codecType) { | 191 switch (config_.codec_settings->codecType) { |
| 192 case kVideoCodecH264: |
| 193 config_.codec_settings->codecSpecific.H264.frameDroppingOn = |
| 194 frame_dropper_on_; |
| 195 config_.codec_settings->codecSpecific.H264.keyFrameInterval = |
| 196 kBaseKeyFrameInterval; |
| 197 break; |
| 187 case kVideoCodecVP8: | 198 case kVideoCodecVP8: |
| 188 config_.codec_settings->codecSpecific.VP8.errorConcealmentOn = | 199 config_.codec_settings->codecSpecific.VP8.errorConcealmentOn = |
| 189 error_concealment_on_; | 200 error_concealment_on_; |
| 190 config_.codec_settings->codecSpecific.VP8.denoisingOn = denoising_on_; | 201 config_.codec_settings->codecSpecific.VP8.denoisingOn = denoising_on_; |
| 191 config_.codec_settings->codecSpecific.VP8.numberOfTemporalLayers = | 202 config_.codec_settings->codecSpecific.VP8.numberOfTemporalLayers = |
| 192 num_temporal_layers_; | 203 num_temporal_layers_; |
| 193 config_.codec_settings->codecSpecific.VP8.frameDroppingOn = | 204 config_.codec_settings->codecSpecific.VP8.frameDroppingOn = |
| 194 frame_dropper_on_; | 205 frame_dropper_on_; |
| 195 config_.codec_settings->codecSpecific.VP8.automaticResizeOn = | 206 config_.codec_settings->codecSpecific.VP8.automaticResizeOn = |
| 196 spatial_resize_on_; | 207 spatial_resize_on_; |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 max_key_frame_size_mismatch; | 583 max_key_frame_size_mismatch; |
| 573 rc_metrics[update_index].max_delta_frame_size_mismatch = | 584 rc_metrics[update_index].max_delta_frame_size_mismatch = |
| 574 max_delta_frame_size_mismatch; | 585 max_delta_frame_size_mismatch; |
| 575 rc_metrics[update_index].max_encoding_rate_mismatch = | 586 rc_metrics[update_index].max_encoding_rate_mismatch = |
| 576 max_encoding_rate_mismatch; | 587 max_encoding_rate_mismatch; |
| 577 rc_metrics[update_index].max_time_hit_target = max_time_hit_target; | 588 rc_metrics[update_index].max_time_hit_target = max_time_hit_target; |
| 578 rc_metrics[update_index].num_spatial_resizes = num_spatial_resizes; | 589 rc_metrics[update_index].num_spatial_resizes = num_spatial_resizes; |
| 579 rc_metrics[update_index].num_key_frames = num_key_frames; | 590 rc_metrics[update_index].num_key_frames = num_key_frames; |
| 580 } | 591 } |
| 581 | 592 |
| 593 #if defined(WEBRTC_VIDEOPROCESSOR_H264_TESTS) |
| 594 |
| 595 // H264: Run with no packet loss and fixed bitrate. Quality should be very high. |
| 596 // Note(hbos): The PacketManipulatorImpl code used to simulate packet loss in |
| 597 // these unittests appears to drop "packets" in a way that is not compatible |
| 598 // with H264. Therefore ProcessXPercentPacketLossH264, X != 0, unittests have |
| 599 // not been added. |
| 600 TEST_F(VideoProcessorIntegrationTest, Process0PercentPacketLossH264) { |
| 601 // Bitrate and frame rate profile. |
| 602 RateProfile rate_profile; |
| 603 SetRateProfilePars(&rate_profile, 0, 500, 30, 0); |
| 604 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1; |
| 605 rate_profile.num_frames = kNbrFramesShort; |
| 606 // Codec/network settings. |
| 607 CodecConfigPars process_settings; |
| 608 SetCodecParameters(&process_settings, kVideoCodecH264, 0.0f, -1, 1, false, |
| 609 false, true, false); |
| 610 // Metrics for expected quality. |
| 611 QualityMetrics quality_metrics; |
| 612 SetQualityMetrics(&quality_metrics, 35.0, 25.0, 0.93, 0.70); |
| 613 // Metrics for rate control. |
| 614 RateControlMetrics rc_metrics[1]; |
| 615 SetRateControlMetrics(rc_metrics, 0, 2, 60, 20, 10, 20, 0, 1); |
| 616 ProcessFramesAndVerify(quality_metrics, |
| 617 rate_profile, |
| 618 process_settings, |
| 619 rc_metrics); |
| 620 } |
| 621 |
| 622 #endif // defined(WEBRTC_VIDEOPROCESSOR_H264_TESTS) |
| 623 |
| 582 // VP9: Run with no packet loss and fixed bitrate. Quality should be very high. | 624 // VP9: Run with no packet loss and fixed bitrate. Quality should be very high. |
| 583 // One key frame (first frame only) in sequence. Setting |key_frame_interval| | 625 // One key frame (first frame only) in sequence. Setting |key_frame_interval| |
| 584 // to -1 below means no periodic key frames in test. | 626 // to -1 below means no periodic key frames in test. |
| 585 TEST_F(VideoProcessorIntegrationTest, Process0PercentPacketLossVP9) { | 627 TEST_F(VideoProcessorIntegrationTest, Process0PercentPacketLossVP9) { |
| 586 // Bitrate and frame rate profile. | 628 // Bitrate and frame rate profile. |
| 587 RateProfile rate_profile; | 629 RateProfile rate_profile; |
| 588 SetRateProfilePars(&rate_profile, 0, 500, 30, 0); | 630 SetRateProfilePars(&rate_profile, 0, 500, 30, 0); |
| 589 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1; | 631 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1; |
| 590 rate_profile.num_frames = kNbrFramesShort; | 632 rate_profile.num_frames = kNbrFramesShort; |
| 591 // Codec/network settings. | 633 // Codec/network settings. |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 QualityMetrics quality_metrics; | 983 QualityMetrics quality_metrics; |
| 942 SetQualityMetrics(&quality_metrics, 32.5, 30.0, 0.85, 0.80); | 984 SetQualityMetrics(&quality_metrics, 32.5, 30.0, 0.85, 0.80); |
| 943 // Metrics for rate control. | 985 // Metrics for rate control. |
| 944 RateControlMetrics rc_metrics[2]; | 986 RateControlMetrics rc_metrics[2]; |
| 945 SetRateControlMetrics(rc_metrics, 0, 0, 20, 30, 10, 10, 0, 1); | 987 SetRateControlMetrics(rc_metrics, 0, 0, 20, 30, 10, 10, 0, 1); |
| 946 SetRateControlMetrics(rc_metrics, 1, 0, 0, 30, 15, 10, 0, 0); | 988 SetRateControlMetrics(rc_metrics, 1, 0, 0, 30, 15, 10, 0, 0); |
| 947 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, | 989 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings, |
| 948 rc_metrics); | 990 rc_metrics); |
| 949 } | 991 } |
| 950 } // namespace webrtc | 992 } // namespace webrtc |
| OLD | NEW |