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