Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc

Issue 1306813009: H.264 video codec support using OpenH264/FFmpeg (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Misc (WebRtcVideoChannel2::...::ConfigureVideoEncoderSettings care about H264 case) Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/codecs/interface/video_codec_interface.h" 15 #include "webrtc/modules/video_coding/codecs/interface/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/main/interface/video_coding.h" 22 #include "webrtc/modules/video_coding/main/interface/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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 151
151 VideoProcessorIntegrationTest() {} 152 VideoProcessorIntegrationTest() {}
152 virtual ~VideoProcessorIntegrationTest() {} 153 virtual ~VideoProcessorIntegrationTest() {}
153 154
154 void SetUpCodecConfig() { 155 void SetUpCodecConfig() {
155 if (codec_type_ == kVideoCodecVP8) { 156 if (codec_type_ == kVideoCodecH264) {
157 encoder_ = H264Encoder::Create();
158 decoder_ = H264Decoder::Create();
159 VideoCodingModule::Codec(kVideoCodecH264, &codec_settings_);
160 } else if (codec_type_ == kVideoCodecVP8) {
156 encoder_ = VP8Encoder::Create(); 161 encoder_ = VP8Encoder::Create();
157 decoder_ = VP8Decoder::Create(); 162 decoder_ = VP8Decoder::Create();
158 VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_); 163 VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_);
159 } else if (codec_type_ == kVideoCodecVP9) { 164 } else if (codec_type_ == kVideoCodecVP9) {
160 encoder_ = VP9Encoder::Create(); 165 encoder_ = VP9Encoder::Create();
161 decoder_ = VP9Decoder::Create(); 166 decoder_ = VP9Decoder::Create();
162 VideoCodingModule::Codec(kVideoCodecVP9, &codec_settings_); 167 VideoCodingModule::Codec(kVideoCodecVP9, &codec_settings_);
163 } 168 }
164 169
165 // CIF is currently used for all tests below. 170 // CIF is currently used for all tests below.
(...skipping 14 matching lines...) Expand all
180 config_.networking_config.packet_loss_probability = packet_loss_; 185 config_.networking_config.packet_loss_probability = packet_loss_;
181 186
182 // Configure codec settings. 187 // Configure codec settings.
183 config_.codec_settings = &codec_settings_; 188 config_.codec_settings = &codec_settings_;
184 config_.codec_settings->startBitrate = start_bitrate_; 189 config_.codec_settings->startBitrate = start_bitrate_;
185 config_.codec_settings->width = kCIFWidth; 190 config_.codec_settings->width = kCIFWidth;
186 config_.codec_settings->height = kCIFHeight; 191 config_.codec_settings->height = kCIFHeight;
187 192
188 // These features may be set depending on the test. 193 // These features may be set depending on the test.
189 switch (config_.codec_settings->codecType) { 194 switch (config_.codec_settings->codecType) {
195 case kVideoCodecH264:
196 config_.codec_settings->codecSpecific.H264.frameDroppingOn =
197 frame_dropper_on_;
198 config_.codec_settings->codecSpecific.H264.keyFrameInterval =
199 kBaseKeyFrameInterval;
200 break;
190 case kVideoCodecVP8: 201 case kVideoCodecVP8:
191 config_.codec_settings->codecSpecific.VP8.errorConcealmentOn = 202 config_.codec_settings->codecSpecific.VP8.errorConcealmentOn =
192 error_concealment_on_; 203 error_concealment_on_;
193 config_.codec_settings->codecSpecific.VP8.denoisingOn = 204 config_.codec_settings->codecSpecific.VP8.denoisingOn =
194 denoising_on_; 205 denoising_on_;
195 config_.codec_settings->codecSpecific.VP8.numberOfTemporalLayers = 206 config_.codec_settings->codecSpecific.VP8.numberOfTemporalLayers =
196 num_temporal_layers_; 207 num_temporal_layers_;
197 config_.codec_settings->codecSpecific.VP8.frameDroppingOn = 208 config_.codec_settings->codecSpecific.VP8.frameDroppingOn =
198 frame_dropper_on_; 209 frame_dropper_on_;
199 config_.codec_settings->codecSpecific.VP8.automaticResizeOn = 210 config_.codec_settings->codecSpecific.VP8.automaticResizeOn =
200 spatial_resize_on_; 211 spatial_resize_on_;
201 config_.codec_settings->codecSpecific.VP8.keyFrameInterval = 212 config_.codec_settings->codecSpecific.VP8.keyFrameInterval =
202 kBaseKeyFrameInterval; 213 kBaseKeyFrameInterval;
203 break; 214 break;
204 case kVideoCodecVP9: 215 case kVideoCodecVP9:
205 config_.codec_settings->codecSpecific.VP9.denoisingOn = 216 config_.codec_settings->codecSpecific.VP9.denoisingOn =
206 denoising_on_; 217 denoising_on_;
207 config_.codec_settings->codecSpecific.VP9.numberOfTemporalLayers = 218 config_.codec_settings->codecSpecific.VP9.numberOfTemporalLayers =
208 num_temporal_layers_; 219 num_temporal_layers_;
209 config_.codec_settings->codecSpecific.VP9.frameDroppingOn = 220 config_.codec_settings->codecSpecific.VP9.frameDroppingOn =
210 frame_dropper_on_; 221 frame_dropper_on_;
211 config_.codec_settings->codecSpecific.VP9.keyFrameInterval = 222 config_.codec_settings->codecSpecific.VP9.keyFrameInterval =
212 kBaseKeyFrameInterval; 223 kBaseKeyFrameInterval;
213 break; 224 break;
214 default: 225 default:
215 assert(false); 226 assert(false);
216 break; 227 break;
217 } 228 }
218 frame_reader_ = 229 frame_reader_ =
219 new webrtc::test::FrameReaderImpl(config_.input_filename, 230 new webrtc::test::FrameReaderImpl(config_.input_filename,
220 config_.frame_length_in_bytes); 231 config_.frame_length_in_bytes);
221 frame_writer_ = 232 frame_writer_ =
222 new webrtc::test::FrameWriterImpl(config_.output_filename, 233 new webrtc::test::FrameWriterImpl(config_.output_filename,
223 config_.frame_length_in_bytes); 234 config_.frame_length_in_bytes);
224 ASSERT_TRUE(frame_reader_->Init()); 235 ASSERT_TRUE(frame_reader_->Init());
225 ASSERT_TRUE(frame_writer_->Init()); 236 ASSERT_TRUE(frame_writer_->Init());
226 237
227 packet_manipulator_ = new webrtc::test::PacketManipulatorImpl( 238 packet_manipulator_ = new webrtc::test::PacketManipulatorImpl(
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 rc_metrics[update_index].max_key_frame_size_mismatch = 592 rc_metrics[update_index].max_key_frame_size_mismatch =
582 max_key_frame_size_mismatch; 593 max_key_frame_size_mismatch;
583 rc_metrics[update_index].max_delta_frame_size_mismatch = 594 rc_metrics[update_index].max_delta_frame_size_mismatch =
584 max_delta_frame_size_mismatch; 595 max_delta_frame_size_mismatch;
585 rc_metrics[update_index].max_encoding_rate_mismatch = 596 rc_metrics[update_index].max_encoding_rate_mismatch =
586 max_encoding_rate_mismatch; 597 max_encoding_rate_mismatch;
587 rc_metrics[update_index].max_time_hit_target = max_time_hit_target; 598 rc_metrics[update_index].max_time_hit_target = max_time_hit_target;
588 rc_metrics[update_index].num_spatial_resizes = num_spatial_resizes; 599 rc_metrics[update_index].num_spatial_resizes = num_spatial_resizes;
589 } 600 }
590 601
602 #if defined(WEBRTC_OPENH264)
603
604 // H264: Run with no packet loss and fixed bitrate. Quality should be very high.
605 // Note(hbos): The PacketManipulatorImpl code used to simulate packet loss in
606 // these unittests appears to drop "packets" in a way that is not compatible
607 // with H264. Therefore ProcessXPercentPacketLossH264, X != 0, unittests have
608 // not been added.
609 TEST_F(VideoProcessorIntegrationTest, Process0PercentPacketLossH264) {
610 // Bitrate and frame rate profile.
611 RateProfile rate_profile;
612 SetRateProfilePars(&rate_profile, 0, 500, 30, 0);
613 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1;
614 rate_profile.num_frames = kNbrFramesShort;
615 // Codec/network settings.
616 CodecConfigPars process_settings;
617 SetCodecParameters(&process_settings, kVideoCodecH264, 0.0f, -1, 1, false,
618 false, true, false);
619 // Metrics for expected quality.
620 QualityMetrics quality_metrics;
621 SetQualityMetrics(&quality_metrics, 35.0, 34.0, 0.93, 0.92);
622 // Metrics for rate control.
623 RateControlMetrics rc_metrics[1];
624 SetRateControlMetrics(rc_metrics, 0, 0, 60, 20, 10, 20, 0);
625 ProcessFramesAndVerify(quality_metrics,
626 rate_profile,
627 process_settings,
628 rc_metrics);
629 }
630
631 #endif // defined(WEBRTC_OPENH264)
632
591 // VP9: Run with no packet loss and fixed bitrate. Quality should be very high. 633 // VP9: Run with no packet loss and fixed bitrate. Quality should be very high.
592 // One key frame (first frame only) in sequence. Setting |key_frame_interval| 634 // One key frame (first frame only) in sequence. Setting |key_frame_interval|
593 // to -1 below means no periodic key frames in test. 635 // to -1 below means no periodic key frames in test.
594 TEST_F(VideoProcessorIntegrationTest, Process0PercentPacketLossVP9) { 636 TEST_F(VideoProcessorIntegrationTest, Process0PercentPacketLossVP9) {
595 // Bitrate and frame rate profile. 637 // Bitrate and frame rate profile.
596 RateProfile rate_profile; 638 RateProfile rate_profile;
597 SetRateProfilePars(&rate_profile, 0, 500, 30, 0); 639 SetRateProfilePars(&rate_profile, 0, 500, 30, 0);
598 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1; 640 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1;
599 rate_profile.num_frames = kNbrFramesShort; 641 rate_profile.num_frames = kNbrFramesShort;
600 // Codec/network settings. 642 // Codec/network settings.
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 // Metrics for rate control. 969 // Metrics for rate control.
928 RateControlMetrics rc_metrics[2]; 970 RateControlMetrics rc_metrics[2];
929 SetRateControlMetrics(rc_metrics, 0, 0, 20, 30, 10, 10, 0); 971 SetRateControlMetrics(rc_metrics, 0, 0, 20, 30, 10, 10, 0);
930 SetRateControlMetrics(rc_metrics, 1, 0, 0, 30, 15, 10, 0); 972 SetRateControlMetrics(rc_metrics, 1, 0, 0, 30, 15, 10, 0);
931 ProcessFramesAndVerify(quality_metrics, 973 ProcessFramesAndVerify(quality_metrics,
932 rate_profile, 974 rate_profile,
933 process_settings, 975 process_settings,
934 rc_metrics); 976 rc_metrics);
935 } 977 }
936 } // namespace webrtc 978 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698