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

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

Issue 2643853002: Add script for plotting statistics from webrtc integration test logs. (Closed)
Patch Set: Created 3 years, 10 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 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTEST_H _
12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTEST_H _
13
11 #include <math.h> 14 #include <math.h>
12 15
13 #include <memory> 16 #include <memory>
17 #include <string>
14 18
15 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" 19 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
16 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h" 20 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h"
17 #include "webrtc/modules/video_coding/codecs/test/videoprocessor.h" 21 #include "webrtc/modules/video_coding/codecs/test/videoprocessor.h"
18 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" 22 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
19 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" 23 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h"
20 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" 24 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
21 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" 25 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
22 #include "webrtc/modules/video_coding/include/video_codec_interface.h" 26 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
23 #include "webrtc/modules/video_coding/include/video_coding.h" 27 #include "webrtc/modules/video_coding/include/video_coding.h"
24 #include "webrtc/test/gtest.h" 28 #include "webrtc/test/gtest.h"
25 #include "webrtc/test/testsupport/fileutils.h" 29 #include "webrtc/test/testsupport/fileutils.h"
26 #include "webrtc/test/testsupport/frame_reader.h" 30 #include "webrtc/test/testsupport/frame_reader.h"
27 #include "webrtc/test/testsupport/frame_writer.h" 31 #include "webrtc/test/testsupport/frame_writer.h"
28 #include "webrtc/test/testsupport/metrics/video_metrics.h" 32 #include "webrtc/test/testsupport/metrics/video_metrics.h"
29 #include "webrtc/test/testsupport/packet_reader.h" 33 #include "webrtc/test/testsupport/packet_reader.h"
30 #include "webrtc/typedefs.h" 34 #include "webrtc/typedefs.h"
31 35
32 namespace webrtc { 36 namespace webrtc {
33 namespace { 37 namespace test {
34 // Maximum number of rate updates (i.e., calls to encoder to change bitrate 38 // Maximum number of rate updates (i.e., calls to encoder to change bitrate
35 // and/or frame rate) for the current tests. 39 // and/or frame rate) for the current tests.
36 const int kMaxNumRateUpdates = 3; 40 const int kMaxNumRateUpdates = 3;
37 41
38 const int kPercTargetvsActualMismatch = 20; 42 const int kPercTargetvsActualMismatch = 20;
39 const int kBaseKeyFrameInterval = 3000; 43 const int kBaseKeyFrameInterval = 3000;
40 44
45 // Default sequence is foreman (CIF): may be better to use VGA for resize test.
46 const int kCifWidth = 352;
47 const int kCifHeight = 288;
48 const char kFilenameForemanCif[] = "foreman_cif";
49
41 // Codec and network settings. 50 // Codec and network settings.
42 struct CodecConfigPars { 51 struct CodecConfigPars {
43 VideoCodecType codec_type; 52 VideoCodecType codec_type;
44 float packet_loss; 53 float packet_loss;
45 int num_temporal_layers; 54 int num_temporal_layers;
46 int key_frame_interval; 55 int key_frame_interval;
47 bool error_concealment_on; 56 bool error_concealment_on;
48 bool denoising_on; 57 bool denoising_on;
49 bool frame_dropper_on; 58 bool frame_dropper_on;
50 bool spatial_resize_on; 59 bool spatial_resize_on;
60 int width;
61 int height;
62 std::string filename;
63 bool verbose_logging;
51 }; 64 };
52 65
53 // Quality metrics. 66 // Quality metrics.
54 struct QualityMetrics { 67 struct QualityMetrics {
55 double minimum_avg_psnr; 68 double minimum_avg_psnr;
56 double minimum_min_psnr; 69 double minimum_min_psnr;
57 double minimum_avg_ssim; 70 double minimum_avg_ssim;
58 double minimum_min_ssim; 71 double minimum_min_ssim;
59 }; 72 };
60 73
(...skipping 15 matching lines...) Expand all
76 struct RateControlMetrics { 89 struct RateControlMetrics {
77 int max_num_dropped_frames; 90 int max_num_dropped_frames;
78 int max_key_frame_size_mismatch; 91 int max_key_frame_size_mismatch;
79 int max_delta_frame_size_mismatch; 92 int max_delta_frame_size_mismatch;
80 int max_encoding_rate_mismatch; 93 int max_encoding_rate_mismatch;
81 int max_time_hit_target; 94 int max_time_hit_target;
82 int num_spatial_resizes; 95 int num_spatial_resizes;
83 int num_key_frames; 96 int num_key_frames;
84 }; 97 };
85 98
86 // Sequence used is foreman (CIF): may be better to use VGA for resize test.
87 const int kCIFWidth = 352;
88 const int kCIFHeight = 288;
89 #if !defined(WEBRTC_IOS) 99 #if !defined(WEBRTC_IOS)
90 const int kNbrFramesShort = 100; // Some tests are run for shorter sequence. 100 const int kNbrFramesShort = 100; // Some tests are run for shorter sequence.
91 #endif 101 #endif
92 const int kNbrFramesLong = 299; 102 const int kNbrFramesLong = 299;
93 103
94 // Parameters from VP8 wrapper, which control target size of key frames. 104 // Parameters from VP8 wrapper, which control target size of key frames.
95 const float kInitialBufferSize = 0.5f; 105 const float kInitialBufferSize = 0.5f;
96 const float kOptimalBufferSize = 0.6f; 106 const float kOptimalBufferSize = 0.6f;
97 const float kScaleKeyFrameSize = 0.5f; 107 const float kScaleKeyFrameSize = 0.5f;
98 108
99 void SetRateProfilePars(RateProfile* rate_profile,
100 int update_index,
101 int bit_rate,
102 int frame_rate,
103 int frame_index_rate_update) {
104 rate_profile->target_bit_rate[update_index] = bit_rate;
105 rate_profile->input_frame_rate[update_index] = frame_rate;
106 rate_profile->frame_index_rate_update[update_index] = frame_index_rate_update;
107 }
108
109 void SetCodecParameters(CodecConfigPars* process_settings,
110 VideoCodecType codec_type,
111 float packet_loss,
112 int key_frame_interval,
113 int num_temporal_layers,
114 bool error_concealment_on,
115 bool denoising_on,
116 bool frame_dropper_on,
117 bool spatial_resize_on) {
118 process_settings->codec_type = codec_type;
119 process_settings->packet_loss = packet_loss;
120 process_settings->key_frame_interval = key_frame_interval;
121 process_settings->num_temporal_layers = num_temporal_layers,
122 process_settings->error_concealment_on = error_concealment_on;
123 process_settings->denoising_on = denoising_on;
124 process_settings->frame_dropper_on = frame_dropper_on;
125 process_settings->spatial_resize_on = spatial_resize_on;
126 }
127
128 void SetQualityMetrics(QualityMetrics* quality_metrics,
129 double minimum_avg_psnr,
130 double minimum_min_psnr,
131 double minimum_avg_ssim,
132 double minimum_min_ssim) {
133 quality_metrics->minimum_avg_psnr = minimum_avg_psnr;
134 quality_metrics->minimum_min_psnr = minimum_min_psnr;
135 quality_metrics->minimum_avg_ssim = minimum_avg_ssim;
136 quality_metrics->minimum_min_ssim = minimum_min_ssim;
137 }
138
139 void SetRateControlMetrics(RateControlMetrics* rc_metrics,
140 int update_index,
141 int max_num_dropped_frames,
142 int max_key_frame_size_mismatch,
143 int max_delta_frame_size_mismatch,
144 int max_encoding_rate_mismatch,
145 int max_time_hit_target,
146 int num_spatial_resizes,
147 int num_key_frames) {
148 rc_metrics[update_index].max_num_dropped_frames = max_num_dropped_frames;
149 rc_metrics[update_index].max_key_frame_size_mismatch =
150 max_key_frame_size_mismatch;
151 rc_metrics[update_index].max_delta_frame_size_mismatch =
152 max_delta_frame_size_mismatch;
153 rc_metrics[update_index].max_encoding_rate_mismatch =
154 max_encoding_rate_mismatch;
155 rc_metrics[update_index].max_time_hit_target = max_time_hit_target;
156 rc_metrics[update_index].num_spatial_resizes = num_spatial_resizes;
157 rc_metrics[update_index].num_key_frames = num_key_frames;
158 }
159 } // namespace
160
161 // Integration test for video processor. Encodes+decodes a clip and 109 // Integration test for video processor. Encodes+decodes a clip and
162 // writes it to the output directory. After completion, quality metrics 110 // writes it to the output directory. After completion, quality metrics
163 // (PSNR and SSIM) and rate control metrics are computed to verify that the 111 // (PSNR and SSIM) and rate control metrics are computed to verify that the
164 // quality and encoder response is acceptable. The rate control tests allow us 112 // quality and encoder response is acceptable. The rate control tests allow us
165 // to verify the behavior for changing bitrate, changing frame rate, frame 113 // to verify the behavior for changing bitrate, changing frame rate, frame
166 // dropping/spatial resize, and temporal layers. The limits for the rate 114 // dropping/spatial resize, and temporal layers. The limits for the rate
167 // control metrics are set to be fairly conservative, so failure should only 115 // control metrics are set to be fairly conservative, so failure should only
168 // happen when some significant regression or breakdown occurs. 116 // happen when some significant regression or breakdown occurs.
169 class VideoProcessorIntegrationTest : public testing::Test { 117 class VideoProcessorIntegrationTest : public testing::Test {
170 protected: 118 protected:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 int num_temporal_layers_; 158 int num_temporal_layers_;
211 int key_frame_interval_; 159 int key_frame_interval_;
212 bool error_concealment_on_; 160 bool error_concealment_on_;
213 bool denoising_on_; 161 bool denoising_on_;
214 bool frame_dropper_on_; 162 bool frame_dropper_on_;
215 bool spatial_resize_on_; 163 bool spatial_resize_on_;
216 164
217 VideoProcessorIntegrationTest() {} 165 VideoProcessorIntegrationTest() {}
218 virtual ~VideoProcessorIntegrationTest() {} 166 virtual ~VideoProcessorIntegrationTest() {}
219 167
220 void SetUpCodecConfig() { 168 void SetUpCodecConfig(const std::string& filename,
169 int width,
170 int height,
171 bool verbose_logging) {
221 if (codec_type_ == kVideoCodecH264) { 172 if (codec_type_ == kVideoCodecH264) {
222 encoder_.reset(H264Encoder::Create(cricket::VideoCodec("H264"))); 173 encoder_.reset(H264Encoder::Create(cricket::VideoCodec("H264")));
223 decoder_.reset(H264Decoder::Create()); 174 decoder_.reset(H264Decoder::Create());
224 VideoCodingModule::Codec(kVideoCodecH264, &codec_settings_); 175 VideoCodingModule::Codec(kVideoCodecH264, &codec_settings_);
225 } else if (codec_type_ == kVideoCodecVP8) { 176 } else if (codec_type_ == kVideoCodecVP8) {
226 encoder_.reset(VP8Encoder::Create()); 177 encoder_.reset(VP8Encoder::Create());
227 decoder_.reset(VP8Decoder::Create()); 178 decoder_.reset(VP8Decoder::Create());
228 VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_); 179 VideoCodingModule::Codec(kVideoCodecVP8, &codec_settings_);
229 } else if (codec_type_ == kVideoCodecVP9) { 180 } else if (codec_type_ == kVideoCodecVP9) {
230 encoder_.reset(VP9Encoder::Create()); 181 encoder_.reset(VP9Encoder::Create());
231 decoder_.reset(VP9Decoder::Create()); 182 decoder_.reset(VP9Decoder::Create());
232 VideoCodingModule::Codec(kVideoCodecVP9, &codec_settings_); 183 VideoCodingModule::Codec(kVideoCodecVP9, &codec_settings_);
233 } 184 }
234 185
235 // CIF is currently used for all tests below. 186 // Configure input filename.
236 // Setup the TestConfig struct for processing of a clip in CIF resolution. 187 config_.input_filename = test::ResourcePath(filename, "yuv");
237 config_.input_filename = webrtc::test::ResourcePath("foreman_cif", "yuv"); 188 if (verbose_logging)
238 189 printf("Filename: %s\n", filename.c_str());
239 // Generate an output filename in a safe way. 190 // Generate an output filename in a safe way.
240 config_.output_filename = webrtc::test::TempFilename( 191 config_.output_filename = test::TempFilename(
241 webrtc::test::OutputPath(), "videoprocessor_integrationtest"); 192 test::OutputPath(), "videoprocessor_integrationtest");
242 config_.frame_length_in_bytes = 193 config_.frame_length_in_bytes = CalcBufferSize(kI420, width, height);
243 CalcBufferSize(kI420, kCIFWidth, kCIFHeight); 194 config_.verbose = verbose_logging;
244 config_.verbose = false;
245 // Only allow encoder/decoder to use single core, for predictability. 195 // Only allow encoder/decoder to use single core, for predictability.
246 config_.use_single_core = true; 196 config_.use_single_core = true;
247 // Key frame interval and packet loss are set for each test. 197 // Key frame interval and packet loss are set for each test.
248 config_.keyframe_interval = key_frame_interval_; 198 config_.keyframe_interval = key_frame_interval_;
249 config_.networking_config.packet_loss_probability = packet_loss_; 199 config_.networking_config.packet_loss_probability = packet_loss_;
250 200
251 // Configure codec settings. 201 // Configure codec settings.
252 config_.codec_settings = &codec_settings_; 202 config_.codec_settings = &codec_settings_;
253 config_.codec_settings->startBitrate = start_bitrate_; 203 config_.codec_settings->startBitrate = start_bitrate_;
254 config_.codec_settings->width = kCIFWidth; 204 config_.codec_settings->width = width;
255 config_.codec_settings->height = kCIFHeight; 205 config_.codec_settings->height = height;
256 206
257 // These features may be set depending on the test. 207 // These features may be set depending on the test.
258 switch (config_.codec_settings->codecType) { 208 switch (config_.codec_settings->codecType) {
259 case kVideoCodecH264: 209 case kVideoCodecH264:
260 config_.codec_settings->H264()->frameDroppingOn = frame_dropper_on_; 210 config_.codec_settings->H264()->frameDroppingOn = frame_dropper_on_;
261 config_.codec_settings->H264()->keyFrameInterval = 211 config_.codec_settings->H264()->keyFrameInterval =
262 kBaseKeyFrameInterval; 212 kBaseKeyFrameInterval;
263 break; 213 break;
264 case kVideoCodecVP8: 214 case kVideoCodecVP8:
265 config_.codec_settings->VP8()->errorConcealmentOn = 215 config_.codec_settings->VP8()->errorConcealmentOn =
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 int max_key_frame_size_mismatch, 320 int max_key_frame_size_mismatch,
371 int max_delta_frame_size_mismatch, 321 int max_delta_frame_size_mismatch,
372 int max_encoding_rate_mismatch, 322 int max_encoding_rate_mismatch,
373 int max_time_hit_target, 323 int max_time_hit_target,
374 int max_num_dropped_frames, 324 int max_num_dropped_frames,
375 int num_spatial_resizes, 325 int num_spatial_resizes,
376 int num_key_frames) { 326 int num_key_frames) {
377 int num_dropped_frames = processor_->NumberDroppedFrames(); 327 int num_dropped_frames = processor_->NumberDroppedFrames();
378 int num_resize_actions = processor_->NumberSpatialResizes(); 328 int num_resize_actions = processor_->NumberSpatialResizes();
379 printf( 329 printf(
380 "For update #: %d,\n " 330 "For update #: %d,\n"
381 " Target Bitrate: %d,\n" 331 " Target Bitrate: %d,\n"
382 " Encoding bitrate: %f,\n" 332 " Encoding bitrate: %f,\n"
383 " Frame rate: %d \n", 333 " Frame rate: %d \n",
384 update_index, bit_rate_, encoding_bitrate_total_, frame_rate_); 334 update_index, bit_rate_, encoding_bitrate_total_, frame_rate_);
385 printf( 335 printf(
386 " Number of frames to approach target rate: %d, \n" 336 " Number of frames to approach target rate: %d, \n"
387 " Number of dropped frames: %d, \n" 337 " Number of dropped frames: %d, \n"
388 " Number of spatial resizes: %d, \n", 338 " Number of spatial resizes: %d, \n",
389 num_frames_to_hit_target_, num_dropped_frames, num_resize_actions); 339 num_frames_to_hit_target_, num_dropped_frames, num_resize_actions);
390 EXPECT_LE(perc_encoding_rate_mismatch_, max_encoding_rate_mismatch); 340 EXPECT_LE(perc_encoding_rate_mismatch_, max_encoding_rate_mismatch);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 // Codec/config settings. 435 // Codec/config settings.
486 codec_type_ = process.codec_type; 436 codec_type_ = process.codec_type;
487 start_bitrate_ = rate_profile.target_bit_rate[0]; 437 start_bitrate_ = rate_profile.target_bit_rate[0];
488 packet_loss_ = process.packet_loss; 438 packet_loss_ = process.packet_loss;
489 key_frame_interval_ = process.key_frame_interval; 439 key_frame_interval_ = process.key_frame_interval;
490 num_temporal_layers_ = process.num_temporal_layers; 440 num_temporal_layers_ = process.num_temporal_layers;
491 error_concealment_on_ = process.error_concealment_on; 441 error_concealment_on_ = process.error_concealment_on;
492 denoising_on_ = process.denoising_on; 442 denoising_on_ = process.denoising_on;
493 frame_dropper_on_ = process.frame_dropper_on; 443 frame_dropper_on_ = process.frame_dropper_on;
494 spatial_resize_on_ = process.spatial_resize_on; 444 spatial_resize_on_ = process.spatial_resize_on;
495 SetUpCodecConfig(); 445 SetUpCodecConfig(process.filename, process.width, process.height,
446 process.verbose_logging);
496 // Update the layers and the codec with the initial rates. 447 // Update the layers and the codec with the initial rates.
497 bit_rate_ = rate_profile.target_bit_rate[0]; 448 bit_rate_ = rate_profile.target_bit_rate[0];
498 frame_rate_ = rate_profile.input_frame_rate[0]; 449 frame_rate_ = rate_profile.input_frame_rate[0];
499 SetLayerRates(); 450 SetLayerRates();
500 // Set the initial target size for key frame. 451 // Set the initial target size for key frame.
501 target_size_key_frame_initial_ = 452 target_size_key_frame_initial_ =
502 0.5 * kInitialBufferSize * bit_rate_layer_[0]; 453 0.5 * kInitialBufferSize * bit_rate_layer_[0];
503 processor_->SetRates(bit_rate_, frame_rate_); 454 processor_->SetRates(bit_rate_, frame_rate_);
504 // Process each frame, up to |num_frames|. 455 // Process each frame, up to |num_frames|.
505 int num_frames = rate_profile.num_frames; 456 int num_frames = rate_profile.num_frames;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 ssim_result.min); 523 ssim_result.min);
573 stats_.PrintSummary(); 524 stats_.PrintSummary();
574 EXPECT_GT(psnr_result.average, quality_metrics.minimum_avg_psnr); 525 EXPECT_GT(psnr_result.average, quality_metrics.minimum_avg_psnr);
575 EXPECT_GT(psnr_result.min, quality_metrics.minimum_min_psnr); 526 EXPECT_GT(psnr_result.min, quality_metrics.minimum_min_psnr);
576 EXPECT_GT(ssim_result.average, quality_metrics.minimum_avg_ssim); 527 EXPECT_GT(ssim_result.average, quality_metrics.minimum_avg_ssim);
577 EXPECT_GT(ssim_result.min, quality_metrics.minimum_min_ssim); 528 EXPECT_GT(ssim_result.min, quality_metrics.minimum_min_ssim);
578 if (remove(config_.output_filename.c_str()) < 0) { 529 if (remove(config_.output_filename.c_str()) < 0) {
579 fprintf(stderr, "Failed to remove temporary file!\n"); 530 fprintf(stderr, "Failed to remove temporary file!\n");
580 } 531 }
581 } 532 }
533
534 void SetRateProfilePars(RateProfile* rate_profile,
brandtr 2017/02/09 13:32:43 Make all these member functions static, to show th
åsapersson 2017/02/09 16:39:37 Done.
535 int update_index,
536 int bit_rate,
537 int frame_rate,
538 int frame_index_rate_update) {
539 rate_profile->target_bit_rate[update_index] = bit_rate;
540 rate_profile->input_frame_rate[update_index] = frame_rate;
541 rate_profile->frame_index_rate_update[update_index] =
542 frame_index_rate_update;
543 }
544
545 void SetCodecParameters(CodecConfigPars* process_settings,
546 VideoCodecType codec_type,
547 float packet_loss,
548 int key_frame_interval,
549 int num_temporal_layers,
550 bool error_concealment_on,
551 bool denoising_on,
552 bool frame_dropper_on,
553 bool spatial_resize_on,
554 int width,
555 int height,
556 const std::string& filename,
557 bool verbose_logging) {
558 process_settings->codec_type = codec_type;
559 process_settings->packet_loss = packet_loss;
560 process_settings->key_frame_interval = key_frame_interval;
561 process_settings->num_temporal_layers = num_temporal_layers,
562 process_settings->error_concealment_on = error_concealment_on;
563 process_settings->denoising_on = denoising_on;
564 process_settings->frame_dropper_on = frame_dropper_on;
565 process_settings->spatial_resize_on = spatial_resize_on;
566 process_settings->width = width;
567 process_settings->height = height;
568 process_settings->filename = filename;
569 process_settings->verbose_logging = verbose_logging;
570 }
571
572 void SetCodecParameters(CodecConfigPars* process_settings,
573 VideoCodecType codec_type,
574 float packet_loss,
575 int key_frame_interval,
576 int num_temporal_layers,
577 bool error_concealment_on,
578 bool denoising_on,
579 bool frame_dropper_on,
580 bool spatial_resize_on) {
581 SetCodecParameters(process_settings, codec_type, packet_loss,
582 key_frame_interval, num_temporal_layers,
583 error_concealment_on, denoising_on, frame_dropper_on,
584 spatial_resize_on, kCifWidth, kCifHeight,
585 kFilenameForemanCif, false /* verbose_logging */);
586 }
587
588 void SetQualityMetrics(QualityMetrics* quality_metrics,
589 double minimum_avg_psnr,
590 double minimum_min_psnr,
591 double minimum_avg_ssim,
592 double minimum_min_ssim) {
593 quality_metrics->minimum_avg_psnr = minimum_avg_psnr;
594 quality_metrics->minimum_min_psnr = minimum_min_psnr;
595 quality_metrics->minimum_avg_ssim = minimum_avg_ssim;
596 quality_metrics->minimum_min_ssim = minimum_min_ssim;
597 }
598
599 void SetRateControlMetrics(RateControlMetrics* rc_metrics,
600 int update_index,
601 int max_num_dropped_frames,
602 int max_key_frame_size_mismatch,
603 int max_delta_frame_size_mismatch,
604 int max_encoding_rate_mismatch,
605 int max_time_hit_target,
606 int num_spatial_resizes,
607 int num_key_frames) {
608 rc_metrics[update_index].max_num_dropped_frames = max_num_dropped_frames;
609 rc_metrics[update_index].max_key_frame_size_mismatch =
610 max_key_frame_size_mismatch;
611 rc_metrics[update_index].max_delta_frame_size_mismatch =
612 max_delta_frame_size_mismatch;
613 rc_metrics[update_index].max_encoding_rate_mismatch =
614 max_encoding_rate_mismatch;
615 rc_metrics[update_index].max_time_hit_target = max_time_hit_target;
616 rc_metrics[update_index].num_spatial_resizes = num_spatial_resizes;
617 rc_metrics[update_index].num_key_frames = num_key_frames;
618 }
582 }; 619 };
583 620
584 #if defined(WEBRTC_VIDEOPROCESSOR_H264_TESTS) 621 } // namespace test
622 } // namespace webrtc
585 623
586 // H264: Run with no packet loss and fixed bitrate. Quality should be very high. 624 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES T_H_
587 // Note(hbos): The PacketManipulatorImpl code used to simulate packet loss in
588 // these unittests appears to drop "packets" in a way that is not compatible
589 // with H264. Therefore ProcessXPercentPacketLossH264, X != 0, unittests have
590 // not been added.
591 TEST_F(VideoProcessorIntegrationTest, Process0PercentPacketLossH264) {
592 // Bitrate and frame rate profile.
593 RateProfile rate_profile;
594 SetRateProfilePars(&rate_profile, 0, 500, 30, 0);
595 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1;
596 rate_profile.num_frames = kNbrFramesShort;
597 // Codec/network settings.
598 CodecConfigPars process_settings;
599 SetCodecParameters(&process_settings, kVideoCodecH264, 0.0f, -1, 1, false,
600 false, true, false);
601 // Metrics for expected quality.
602 QualityMetrics quality_metrics;
603 SetQualityMetrics(&quality_metrics, 35.0, 25.0, 0.93, 0.70);
604 // Metrics for rate control.
605 RateControlMetrics rc_metrics[1];
606 SetRateControlMetrics(rc_metrics, 0, 2, 60, 20, 10, 20, 0, 1);
607 ProcessFramesAndVerify(quality_metrics,
608 rate_profile,
609 process_settings,
610 rc_metrics);
611 }
612
613 #endif // defined(WEBRTC_VIDEOPROCESSOR_H264_TESTS)
614
615 // Fails on iOS. See webrtc:4755.
616 #if !defined(WEBRTC_IOS)
617
618 #if !defined(RTC_DISABLE_VP9)
619 // VP9: Run with no packet loss and fixed bitrate. Quality should be very high.
620 // One key frame (first frame only) in sequence. Setting |key_frame_interval|
621 // to -1 below means no periodic key frames in test.
622 TEST_F(VideoProcessorIntegrationTest, Process0PercentPacketLossVP9) {
623 // Bitrate and frame rate profile.
624 RateProfile rate_profile;
625 SetRateProfilePars(&rate_profile, 0, 500, 30, 0);
626 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1;
627 rate_profile.num_frames = kNbrFramesShort;
628 // Codec/network settings.
629 CodecConfigPars process_settings;
630 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.0f, -1, 1, false,
631 false, true, false);
632 // Metrics for expected quality.
633 QualityMetrics quality_metrics;
634 SetQualityMetrics(&quality_metrics, 37.0, 36.0, 0.93, 0.92);
635 // Metrics for rate control.
636 RateControlMetrics rc_metrics[1];
637 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 20, 0, 1);
638 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings,
639 rc_metrics);
640 }
641
642 // VP9: Run with 5% packet loss and fixed bitrate. Quality should be a bit
643 // lower. One key frame (first frame only) in sequence.
644 TEST_F(VideoProcessorIntegrationTest, Process5PercentPacketLossVP9) {
645 // Bitrate and frame rate profile.
646 RateProfile rate_profile;
647 SetRateProfilePars(&rate_profile, 0, 500, 30, 0);
648 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1;
649 rate_profile.num_frames = kNbrFramesShort;
650 // Codec/network settings.
651 CodecConfigPars process_settings;
652 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.05f, -1, 1, false,
653 false, true, false);
654 // Metrics for expected quality.
655 QualityMetrics quality_metrics;
656 SetQualityMetrics(&quality_metrics, 17.0, 14.0, 0.45, 0.36);
657 // Metrics for rate control.
658 RateControlMetrics rc_metrics[1];
659 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 20, 0, 1);
660 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings,
661 rc_metrics);
662 }
663
664 // VP9: Run with no packet loss, with varying bitrate (3 rate updates):
665 // low to high to medium. Check that quality and encoder response to the new
666 // target rate/per-frame bandwidth (for each rate update) is within limits.
667 // One key frame (first frame only) in sequence.
668 TEST_F(VideoProcessorIntegrationTest, ProcessNoLossChangeBitRateVP9) {
669 // Bitrate and frame rate profile.
670 RateProfile rate_profile;
671 SetRateProfilePars(&rate_profile, 0, 200, 30, 0);
672 SetRateProfilePars(&rate_profile, 1, 700, 30, 100);
673 SetRateProfilePars(&rate_profile, 2, 500, 30, 200);
674 rate_profile.frame_index_rate_update[3] = kNbrFramesLong + 1;
675 rate_profile.num_frames = kNbrFramesLong;
676 // Codec/network settings.
677 CodecConfigPars process_settings;
678 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.0f, -1, 1, false,
679 false, true, false);
680 // Metrics for expected quality.
681 QualityMetrics quality_metrics;
682 SetQualityMetrics(&quality_metrics, 35.5, 30.0, 0.90, 0.85);
683 // Metrics for rate control.
684 RateControlMetrics rc_metrics[3];
685 SetRateControlMetrics(rc_metrics, 0, 0, 30, 20, 20, 30, 0, 1);
686 SetRateControlMetrics(rc_metrics, 1, 2, 0, 20, 20, 60, 0, 0);
687 SetRateControlMetrics(rc_metrics, 2, 0, 0, 25, 20, 40, 0, 0);
688 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings,
689 rc_metrics);
690 }
691
692 // VP9: Run with no packet loss, with an update (decrease) in frame rate.
693 // Lower frame rate means higher per-frame-bandwidth, so easier to encode.
694 // At the low bitrate in this test, this means better rate control after the
695 // update(s) to lower frame rate. So expect less frame drops, and max values
696 // for the rate control metrics can be lower. One key frame (first frame only).
697 // Note: quality after update should be higher but we currently compute quality
698 // metrics averaged over whole sequence run.
699 TEST_F(VideoProcessorIntegrationTest,
700 ProcessNoLossChangeFrameRateFrameDropVP9) {
701 config_.networking_config.packet_loss_probability = 0;
702 // Bitrate and frame rate profile.
703 RateProfile rate_profile;
704 SetRateProfilePars(&rate_profile, 0, 100, 24, 0);
705 SetRateProfilePars(&rate_profile, 1, 100, 15, 100);
706 SetRateProfilePars(&rate_profile, 2, 100, 10, 200);
707 rate_profile.frame_index_rate_update[3] = kNbrFramesLong + 1;
708 rate_profile.num_frames = kNbrFramesLong;
709 // Codec/network settings.
710 CodecConfigPars process_settings;
711 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.0f, -1, 1, false,
712 false, true, false);
713 // Metrics for expected quality.
714 QualityMetrics quality_metrics;
715 SetQualityMetrics(&quality_metrics, 31.5, 18.0, 0.80, 0.43);
716 // Metrics for rate control.
717 RateControlMetrics rc_metrics[3];
718 SetRateControlMetrics(rc_metrics, 0, 38, 50, 75, 15, 45, 0, 1);
719 SetRateControlMetrics(rc_metrics, 1, 10, 0, 40, 10, 30, 0, 0);
720 SetRateControlMetrics(rc_metrics, 2, 5, 0, 30, 5, 20, 0, 0);
721 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings,
722 rc_metrics);
723 }
724
725 // VP9: Run with no packet loss and denoiser on. One key frame (first frame).
726 TEST_F(VideoProcessorIntegrationTest, ProcessNoLossDenoiserOnVP9) {
727 // Bitrate and frame rate profile.
728 RateProfile rate_profile;
729 SetRateProfilePars(&rate_profile, 0, 500, 30, 0);
730 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1;
731 rate_profile.num_frames = kNbrFramesShort;
732 // Codec/network settings.
733 CodecConfigPars process_settings;
734 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.0f, -1, 1, false,
735 true, true, false);
736 // Metrics for expected quality.
737 QualityMetrics quality_metrics;
738 SetQualityMetrics(&quality_metrics, 36.8, 35.8, 0.92, 0.91);
739 // Metrics for rate control.
740 RateControlMetrics rc_metrics[1];
741 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 20, 0, 1);
742 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings,
743 rc_metrics);
744 }
745
746 // Run with no packet loss, at low bitrate.
747 // spatial_resize is on, for this low bitrate expect one resize in sequence.
748 // Resize happens on delta frame. Expect only one key frame (first frame).
749 TEST_F(VideoProcessorIntegrationTest,
750 DISABLED_ProcessNoLossSpatialResizeFrameDropVP9) {
751 config_.networking_config.packet_loss_probability = 0;
752 // Bitrate and frame rate profile.
753 RateProfile rate_profile;
754 SetRateProfilePars(&rate_profile, 0, 50, 30, 0);
755 rate_profile.frame_index_rate_update[1] = kNbrFramesLong + 1;
756 rate_profile.num_frames = kNbrFramesLong;
757 // Codec/network settings.
758 CodecConfigPars process_settings;
759 SetCodecParameters(&process_settings, kVideoCodecVP9, 0.0f, -1, 1, false,
760 false, true, true);
761 // Metrics for expected quality.
762 QualityMetrics quality_metrics;
763 SetQualityMetrics(&quality_metrics, 24.0, 13.0, 0.65, 0.37);
764 // Metrics for rate control.
765 RateControlMetrics rc_metrics[1];
766 SetRateControlMetrics(rc_metrics, 0, 228, 70, 160, 15, 80, 1, 1);
767 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings,
768 rc_metrics);
769 }
770
771 // TODO(marpan): Add temporal layer test for VP9, once changes are in
772 // vp9 wrapper for this.
773
774 #endif // !defined(RTC_DISABLE_VP9)
775
776 // VP8: Run with no packet loss and fixed bitrate. Quality should be very high.
777 // One key frame (first frame only) in sequence. Setting |key_frame_interval|
778 // to -1 below means no periodic key frames in test.
779 TEST_F(VideoProcessorIntegrationTest, ProcessZeroPacketLoss) {
780 // Bitrate and frame rate profile.
781 RateProfile rate_profile;
782 SetRateProfilePars(&rate_profile, 0, 500, 30, 0);
783 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1;
784 rate_profile.num_frames = kNbrFramesShort;
785 // Codec/network settings.
786 CodecConfigPars process_settings;
787 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.0f, -1, 1, false,
788 true, true, false);
789 // Metrics for expected quality.
790 QualityMetrics quality_metrics;
791 SetQualityMetrics(&quality_metrics, 34.95, 33.0, 0.90, 0.89);
792 // Metrics for rate control.
793 RateControlMetrics rc_metrics[1];
794 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 15, 0, 1);
795 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings,
796 rc_metrics);
797 }
798
799 // VP8: Run with 5% packet loss and fixed bitrate. Quality should be a bit
800 // lower. One key frame (first frame only) in sequence.
801 TEST_F(VideoProcessorIntegrationTest, Process5PercentPacketLoss) {
802 // Bitrate and frame rate profile.
803 RateProfile rate_profile;
804 SetRateProfilePars(&rate_profile, 0, 500, 30, 0);
805 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1;
806 rate_profile.num_frames = kNbrFramesShort;
807 // Codec/network settings.
808 CodecConfigPars process_settings;
809 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.05f, -1, 1, false,
810 true, true, false);
811 // Metrics for expected quality.
812 QualityMetrics quality_metrics;
813 SetQualityMetrics(&quality_metrics, 20.0, 16.0, 0.60, 0.40);
814 // Metrics for rate control.
815 RateControlMetrics rc_metrics[1];
816 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 15, 0, 1);
817 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings,
818 rc_metrics);
819 }
820
821 // VP8: Run with 10% packet loss and fixed bitrate. Quality should be lower.
822 // One key frame (first frame only) in sequence.
823 TEST_F(VideoProcessorIntegrationTest, Process10PercentPacketLoss) {
824 // Bitrate and frame rate profile.
825 RateProfile rate_profile;
826 SetRateProfilePars(&rate_profile, 0, 500, 30, 0);
827 rate_profile.frame_index_rate_update[1] = kNbrFramesShort + 1;
828 rate_profile.num_frames = kNbrFramesShort;
829 // Codec/network settings.
830 CodecConfigPars process_settings;
831 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.1f, -1, 1, false,
832 true, true, false);
833 // Metrics for expected quality.
834 QualityMetrics quality_metrics;
835 SetQualityMetrics(&quality_metrics, 19.0, 16.0, 0.50, 0.35);
836 // Metrics for rate control.
837 RateControlMetrics rc_metrics[1];
838 SetRateControlMetrics(rc_metrics, 0, 0, 40, 20, 10, 15, 0, 1);
839 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings,
840 rc_metrics);
841 }
842
843 #endif // !defined(WEBRTC_IOS)
844
845 // The tests below are currently disabled for Android. For ARM, the encoder
846 // uses |cpu_speed| = 12, as opposed to default |cpu_speed| <= 6 for x86,
847 // which leads to significantly different quality. The quality and rate control
848 // settings in the tests below are defined for encoder speed setting
849 // |cpu_speed| <= ~6. A number of settings would need to be significantly
850 // modified for the |cpu_speed| = 12 case. For now, keep the tests below
851 // disabled on Android. Some quality parameter in the above test has been
852 // adjusted to also pass for |cpu_speed| <= 12.
853
854 // VP8: Run with no packet loss, with varying bitrate (3 rate updates):
855 // low to high to medium. Check that quality and encoder response to the new
856 // target rate/per-frame bandwidth (for each rate update) is within limits.
857 // One key frame (first frame only) in sequence.
858 // Too slow to finish before timeout on iOS. See webrtc:4755.
859 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
860 #define MAYBE_ProcessNoLossChangeBitRateVP8 \
861 DISABLED_ProcessNoLossChangeBitRateVP8
862 #else
863 #define MAYBE_ProcessNoLossChangeBitRateVP8 ProcessNoLossChangeBitRateVP8
864 #endif
865 TEST_F(VideoProcessorIntegrationTest, MAYBE_ProcessNoLossChangeBitRateVP8) {
866 // Bitrate and frame rate profile.
867 RateProfile rate_profile;
868 SetRateProfilePars(&rate_profile, 0, 200, 30, 0);
869 SetRateProfilePars(&rate_profile, 1, 800, 30, 100);
870 SetRateProfilePars(&rate_profile, 2, 500, 30, 200);
871 rate_profile.frame_index_rate_update[3] = kNbrFramesLong + 1;
872 rate_profile.num_frames = kNbrFramesLong;
873 // Codec/network settings.
874 CodecConfigPars process_settings;
875 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.0f, -1, 1, false,
876 true, true, false);
877 // Metrics for expected quality.
878 QualityMetrics quality_metrics;
879 SetQualityMetrics(&quality_metrics, 34.0, 32.0, 0.85, 0.80);
880 // Metrics for rate control.
881 RateControlMetrics rc_metrics[3];
882 SetRateControlMetrics(rc_metrics, 0, 0, 45, 20, 10, 15, 0, 1);
883 SetRateControlMetrics(rc_metrics, 1, 0, 0, 25, 20, 10, 0, 0);
884 SetRateControlMetrics(rc_metrics, 2, 0, 0, 25, 15, 10, 0, 0);
885 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings,
886 rc_metrics);
887 }
888
889 // VP8: Run with no packet loss, with an update (decrease) in frame rate.
890 // Lower frame rate means higher per-frame-bandwidth, so easier to encode.
891 // At the bitrate in this test, this means better rate control after the
892 // update(s) to lower frame rate. So expect less frame drops, and max values
893 // for the rate control metrics can be lower. One key frame (first frame only).
894 // Note: quality after update should be higher but we currently compute quality
895 // metrics averaged over whole sequence run.
896 // Too slow to finish before timeout on iOS. See webrtc:4755.
897 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
898 #define MAYBE_ProcessNoLossChangeFrameRateFrameDropVP8 \
899 DISABLED_ProcessNoLossChangeFrameRateFrameDropVP8
900 #else
901 #define MAYBE_ProcessNoLossChangeFrameRateFrameDropVP8 \
902 ProcessNoLossChangeFrameRateFrameDropVP8
903 #endif
904 TEST_F(VideoProcessorIntegrationTest,
905 MAYBE_ProcessNoLossChangeFrameRateFrameDropVP8) {
906 config_.networking_config.packet_loss_probability = 0;
907 // Bitrate and frame rate profile.
908 RateProfile rate_profile;
909 SetRateProfilePars(&rate_profile, 0, 80, 24, 0);
910 SetRateProfilePars(&rate_profile, 1, 80, 15, 100);
911 SetRateProfilePars(&rate_profile, 2, 80, 10, 200);
912 rate_profile.frame_index_rate_update[3] = kNbrFramesLong + 1;
913 rate_profile.num_frames = kNbrFramesLong;
914 // Codec/network settings.
915 CodecConfigPars process_settings;
916 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.0f, -1, 1, false,
917 true, true, false);
918 // Metrics for expected quality.
919 QualityMetrics quality_metrics;
920 SetQualityMetrics(&quality_metrics, 31.0, 22.0, 0.80, 0.65);
921 // Metrics for rate control.
922 RateControlMetrics rc_metrics[3];
923 SetRateControlMetrics(rc_metrics, 0, 40, 20, 75, 15, 60, 0, 1);
924 SetRateControlMetrics(rc_metrics, 1, 10, 0, 25, 10, 35, 0, 0);
925 SetRateControlMetrics(rc_metrics, 2, 0, 0, 20, 10, 15, 0, 0);
926 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings,
927 rc_metrics);
928 }
929
930 // VP8: Run with no packet loss, with 3 temporal layers, with a rate update in
931 // the middle of the sequence. The max values for the frame size mismatch and
932 // encoding rate mismatch are applied to each layer.
933 // No dropped frames in this test, and internal spatial resizer is off.
934 // One key frame (first frame only) in sequence, so no spatial resizing.
935 // Too slow to finish before timeout on iOS. See webrtc:4755.
936 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
937 #define MAYBE_ProcessNoLossTemporalLayersVP8 \
938 DISABLED_ProcessNoLossTemporalLayersVP8
939 #else
940 #define MAYBE_ProcessNoLossTemporalLayersVP8 ProcessNoLossTemporalLayersVP8
941 #endif
942 TEST_F(VideoProcessorIntegrationTest, MAYBE_ProcessNoLossTemporalLayersVP8) {
943 config_.networking_config.packet_loss_probability = 0;
944 // Bitrate and frame rate profile.
945 RateProfile rate_profile;
946 SetRateProfilePars(&rate_profile, 0, 200, 30, 0);
947 SetRateProfilePars(&rate_profile, 1, 400, 30, 150);
948 rate_profile.frame_index_rate_update[2] = kNbrFramesLong + 1;
949 rate_profile.num_frames = kNbrFramesLong;
950 // Codec/network settings.
951 CodecConfigPars process_settings;
952 SetCodecParameters(&process_settings, kVideoCodecVP8, 0.0f, -1, 3, false,
953 true, true, false);
954 // Metrics for expected quality.
955 QualityMetrics quality_metrics;
956 SetQualityMetrics(&quality_metrics, 32.5, 30.0, 0.85, 0.80);
957 // Metrics for rate control.
958 RateControlMetrics rc_metrics[2];
959 SetRateControlMetrics(rc_metrics, 0, 0, 20, 30, 10, 10, 0, 1);
960 SetRateControlMetrics(rc_metrics, 1, 0, 0, 30, 15, 10, 0, 0);
961 ProcessFramesAndVerify(quality_metrics, rate_profile, process_settings,
962 rc_metrics);
963 }
964 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698