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

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

Issue 2708993005: Minor changes in videoprocessor and videoprocessor_integrationtests.h (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « webrtc/modules/video_coding/codecs/test/videoprocessor.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "webrtc/test/testsupport/metrics/video_metrics.h" 46 #include "webrtc/test/testsupport/metrics/video_metrics.h"
47 #include "webrtc/test/testsupport/packet_reader.h" 47 #include "webrtc/test/testsupport/packet_reader.h"
48 #include "webrtc/typedefs.h" 48 #include "webrtc/typedefs.h"
49 49
50 namespace webrtc { 50 namespace webrtc {
51 namespace test { 51 namespace test {
52 // Maximum number of rate updates (i.e., calls to encoder to change bitrate 52 // Maximum number of rate updates (i.e., calls to encoder to change bitrate
53 // and/or frame rate) for the current tests. 53 // and/or frame rate) for the current tests.
54 const int kMaxNumRateUpdates = 3; 54 const int kMaxNumRateUpdates = 3;
55 55
56 // Maximum number of temporal layers to use in tests.
57 const int kMaxNumTemporalLayers = 3;
58
56 const int kPercTargetvsActualMismatch = 20; 59 const int kPercTargetvsActualMismatch = 20;
57 const int kBaseKeyFrameInterval = 3000; 60 const int kBaseKeyFrameInterval = 3000;
58 61
59 // Default sequence is foreman (CIF): may be better to use VGA for resize test. 62 // Default sequence is foreman (CIF): may be better to use VGA for resize test.
60 const int kCifWidth = 352; 63 const int kCifWidth = 352;
61 const int kCifHeight = 288; 64 const int kCifHeight = 288;
62 const char kFilenameForemanCif[] = "foreman_cif"; 65 const char kFilenameForemanCif[] = "foreman_cif";
63 66
64 // Codec and network settings. 67 // Codec and network settings.
65 struct CodecParams { 68 struct CodecParams {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 InitializeAndroidObjects(); 153 InitializeAndroidObjects();
151 154
152 external_encoder_factory_.reset( 155 external_encoder_factory_.reset(
153 new webrtc_jni::MediaCodecVideoEncoderFactory()); 156 new webrtc_jni::MediaCodecVideoEncoderFactory());
154 external_decoder_factory_.reset( 157 external_decoder_factory_.reset(
155 new webrtc_jni::MediaCodecVideoDecoderFactory()); 158 new webrtc_jni::MediaCodecVideoDecoderFactory());
156 #endif 159 #endif
157 } 160 }
158 virtual ~VideoProcessorIntegrationTest() = default; 161 virtual ~VideoProcessorIntegrationTest() = default;
159 162
160 void SetUpCodecConfig(const CodecParams& process, 163 void CreateEncoderAndDecoder(bool hw_codec, VideoCodecType codec_type) {
161 const VisualizationParams* visualization_params) { 164 if (hw_codec) {
162 if (process.hw_codec) {
163 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED) 165 #if defined(WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED)
164 #if defined(WEBRTC_ANDROID) 166 #if defined(WEBRTC_ANDROID)
165 // In general, external codecs should be destroyed by the factories that 167 // In general, external codecs should be destroyed by the factories that
166 // allocated them. For the particular case of the Android 168 // allocated them. For the particular case of the Android
167 // MediaCodecVideo{En,De}coderFactory's, however, it turns out that it is 169 // MediaCodecVideo{En,De}coderFactory's, however, it turns out that it is
168 // fine for the std::unique_ptr to destroy the owned codec directly. 170 // fine for the std::unique_ptr to destroy the owned codec directly.
169 switch (process.codec_type) { 171 switch (codec_type) {
170 case kVideoCodecH264: 172 case kVideoCodecH264:
171 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( 173 encoder_.reset(external_encoder_factory_->CreateVideoEncoder(
172 cricket::VideoCodec(cricket::kH264CodecName))); 174 cricket::VideoCodec(cricket::kH264CodecName)));
173 decoder_.reset( 175 decoder_.reset(
174 external_decoder_factory_->CreateVideoDecoder(kVideoCodecH264)); 176 external_decoder_factory_->CreateVideoDecoder(kVideoCodecH264));
175 break; 177 break;
176 case kVideoCodecVP8: 178 case kVideoCodecVP8:
177 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( 179 encoder_.reset(external_encoder_factory_->CreateVideoEncoder(
178 cricket::VideoCodec(cricket::kVp8CodecName))); 180 cricket::VideoCodec(cricket::kVp8CodecName)));
179 decoder_.reset( 181 decoder_.reset(
180 external_decoder_factory_->CreateVideoDecoder(kVideoCodecVP8)); 182 external_decoder_factory_->CreateVideoDecoder(kVideoCodecVP8));
181 break; 183 break;
182 case kVideoCodecVP9: 184 case kVideoCodecVP9:
183 encoder_.reset(external_encoder_factory_->CreateVideoEncoder( 185 encoder_.reset(external_encoder_factory_->CreateVideoEncoder(
184 cricket::VideoCodec(cricket::kVp9CodecName))); 186 cricket::VideoCodec(cricket::kVp9CodecName)));
185 decoder_.reset( 187 decoder_.reset(
186 external_decoder_factory_->CreateVideoDecoder(kVideoCodecVP9)); 188 external_decoder_factory_->CreateVideoDecoder(kVideoCodecVP9));
187 break; 189 break;
188 default: 190 default:
189 RTC_NOTREACHED(); 191 RTC_NOTREACHED();
190 break; 192 break;
191 } 193 }
192 #elif defined(WEBRTC_IOS) 194 #elif defined(WEBRTC_IOS)
193 ASSERT_EQ(kVideoCodecH264, process.codec_type) 195 ASSERT_EQ(kVideoCodecH264, codec_type)
194 << "iOS HW codecs only support H264."; 196 << "iOS HW codecs only support H264.";
195 encoder_.reset(new H264VideoToolboxEncoder( 197 encoder_.reset(new H264VideoToolboxEncoder(
196 cricket::VideoCodec(cricket::kH264CodecName))); 198 cricket::VideoCodec(cricket::kH264CodecName)));
197 decoder_.reset(new H264VideoToolboxDecoder()); 199 decoder_.reset(new H264VideoToolboxDecoder());
198 #else 200 #else
199 RTC_NOTREACHED() << "Only support HW codecs on Android and iOS."; 201 RTC_NOTREACHED() << "Only support HW codecs on Android and iOS.";
200 #endif 202 #endif
201 #endif // WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED 203 #endif // WEBRTC_VIDEOPROCESSOR_INTEGRATIONTEST_HW_CODECS_ENABLED
202 RTC_CHECK(encoder_) << "HW encoder not successfully created."; 204 RTC_CHECK(encoder_) << "HW encoder not successfully created.";
203 RTC_CHECK(decoder_) << "HW decoder not successfully created."; 205 RTC_CHECK(decoder_) << "HW decoder not successfully created.";
204 } else { 206 return;
205 // SW codecs.
206 switch (process.codec_type) {
207 case kVideoCodecH264:
208 encoder_.reset(H264Encoder::Create(
209 cricket::VideoCodec(cricket::kH264CodecName)));
210 decoder_.reset(H264Decoder::Create());
211 break;
212 case kVideoCodecVP8:
213 encoder_.reset(VP8Encoder::Create());
214 decoder_.reset(VP8Decoder::Create());
215 break;
216 case kVideoCodecVP9:
217 encoder_.reset(VP9Encoder::Create());
218 decoder_.reset(VP9Decoder::Create());
219 break;
220 default:
221 RTC_NOTREACHED();
222 break;
223 }
224 } 207 }
225 208
226 VideoCodingModule::Codec(process.codec_type, &codec_settings_); 209 // SW codecs.
210 switch (codec_type) {
211 case kVideoCodecH264:
212 encoder_.reset(
213 H264Encoder::Create(cricket::VideoCodec(cricket::kH264CodecName)));
214 decoder_.reset(H264Decoder::Create());
215 break;
216 case kVideoCodecVP8:
217 encoder_.reset(VP8Encoder::Create());
218 decoder_.reset(VP8Decoder::Create());
219 break;
220 case kVideoCodecVP9:
221 encoder_.reset(VP9Encoder::Create());
222 decoder_.reset(VP9Decoder::Create());
223 break;
224 default:
225 RTC_NOTREACHED();
226 break;
227 }
228 }
229
230 void SetUpCodecConfig(const CodecParams& process,
231 const VisualizationParams* visualization_params) {
232 CreateEncoderAndDecoder(process.hw_codec, process.codec_type);
227 233
228 // Configure input filename. 234 // Configure input filename.
229 config_.input_filename = test::ResourcePath(process.filename, "yuv"); 235 config_.input_filename = test::ResourcePath(process.filename, "yuv");
230 if (process.verbose_logging) 236 if (process.verbose_logging)
231 printf("Filename: %s\n", process.filename.c_str()); 237 printf("Filename: %s\n", process.filename.c_str());
232 // Generate an output filename in a safe way. 238 // Generate an output filename in a safe way.
233 config_.output_filename = test::TempFilename( 239 config_.output_filename = test::TempFilename(
234 test::OutputPath(), "videoprocessor_integrationtest"); 240 test::OutputPath(), "videoprocessor_integrationtest");
241
235 config_.frame_length_in_bytes = 242 config_.frame_length_in_bytes =
236 CalcBufferSize(kI420, process.width, process.height); 243 CalcBufferSize(kI420, process.width, process.height);
237 config_.verbose = process.verbose_logging; 244 config_.verbose = process.verbose_logging;
238 config_.use_single_core = process.use_single_core; 245 config_.use_single_core = process.use_single_core;
239 // Key frame interval and packet loss are set for each test. 246 // Key frame interval and packet loss are set for each test.
240 config_.keyframe_interval = process.key_frame_interval; 247 config_.keyframe_interval = process.key_frame_interval;
241 config_.networking_config.packet_loss_probability = 248 config_.networking_config.packet_loss_probability =
242 packet_loss_probability_; 249 packet_loss_probability_;
243 250
244 // Configure codec settings. 251 // Configure codec settings.
252 VideoCodingModule::Codec(process.codec_type, &codec_settings_);
245 config_.codec_settings = &codec_settings_; 253 config_.codec_settings = &codec_settings_;
246 config_.codec_settings->startBitrate = start_bitrate_; 254 config_.codec_settings->startBitrate = start_bitrate_;
247 config_.codec_settings->width = process.width; 255 config_.codec_settings->width = process.width;
248 config_.codec_settings->height = process.height; 256 config_.codec_settings->height = process.height;
249 257
250 // These features may be set depending on the test. 258 // These features may be set depending on the test.
251 switch (config_.codec_settings->codecType) { 259 switch (config_.codec_settings->codecType) {
252 case kVideoCodecH264: 260 case kVideoCodecH264:
253 config_.codec_settings->H264()->frameDroppingOn = 261 config_.codec_settings->H264()->frameDroppingOn =
254 process.frame_dropper_on; 262 process.frame_dropper_on;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 100 * fabs(encoding_bitrate_total_ - bit_rate_) / bit_rate_; 401 100 * fabs(encoding_bitrate_total_ - bit_rate_) / bit_rate_;
394 if (perc_encoding_rate_mismatch_ < kPercTargetvsActualMismatch && 402 if (perc_encoding_rate_mismatch_ < kPercTargetvsActualMismatch &&
395 !encoding_rate_within_target_) { 403 !encoding_rate_within_target_) {
396 num_frames_to_hit_target_ = num_frames_total_; 404 num_frames_to_hit_target_ = num_frames_total_;
397 encoding_rate_within_target_ = true; 405 encoding_rate_within_target_ = true;
398 } 406 }
399 } 407 }
400 408
401 // Verify expected behavior of rate control and print out data. 409 // Verify expected behavior of rate control and print out data.
402 void VerifyRateControlMetrics(int update_index, 410 void VerifyRateControlMetrics(int update_index,
403 int max_key_frame_size_mismatch, 411 const RateControlThresholds& rc_expected) {
404 int max_delta_frame_size_mismatch,
405 int max_encoding_rate_mismatch,
406 int max_time_hit_target,
407 int max_num_dropped_frames,
408 int num_spatial_resizes,
409 int num_key_frames) {
410 int num_dropped_frames = processor_->NumberDroppedFrames(); 412 int num_dropped_frames = processor_->NumberDroppedFrames();
411 int num_resize_actions = processor_->NumberSpatialResizes(); 413 int num_resize_actions = processor_->NumberSpatialResizes();
412 printf( 414 printf(
413 "For update #: %d,\n" 415 "For update #: %d,\n"
414 " Target Bitrate: %d,\n" 416 " Target Bitrate: %d,\n"
415 " Encoding bitrate: %f,\n" 417 " Encoding bitrate: %f,\n"
416 " Frame rate: %d \n", 418 " Frame rate: %d \n",
417 update_index, bit_rate_, encoding_bitrate_total_, frame_rate_); 419 update_index, bit_rate_, encoding_bitrate_total_, frame_rate_);
418 printf( 420 printf(
419 " Number of frames to approach target rate: %d, \n" 421 " Number of frames to approach target rate: %d, \n"
420 " Number of dropped frames: %d, \n" 422 " Number of dropped frames: %d, \n"
421 " Number of spatial resizes: %d, \n", 423 " Number of spatial resizes: %d, \n",
422 num_frames_to_hit_target_, num_dropped_frames, num_resize_actions); 424 num_frames_to_hit_target_, num_dropped_frames, num_resize_actions);
423 EXPECT_LE(perc_encoding_rate_mismatch_, max_encoding_rate_mismatch); 425 EXPECT_LE(perc_encoding_rate_mismatch_,
426 rc_expected.max_encoding_rate_mismatch);
424 if (num_key_frames_ > 0) { 427 if (num_key_frames_ > 0) {
425 int perc_key_frame_size_mismatch = 428 int perc_key_frame_size_mismatch =
426 100 * sum_key_frame_size_mismatch_ / num_key_frames_; 429 100 * sum_key_frame_size_mismatch_ / num_key_frames_;
427 printf( 430 printf(
428 " Number of Key frames: %d \n" 431 " Number of Key frames: %d \n"
429 " Key frame rate mismatch: %d \n", 432 " Key frame rate mismatch: %d \n",
430 num_key_frames_, perc_key_frame_size_mismatch); 433 num_key_frames_, perc_key_frame_size_mismatch);
431 EXPECT_LE(perc_key_frame_size_mismatch, max_key_frame_size_mismatch); 434 EXPECT_LE(perc_key_frame_size_mismatch,
435 rc_expected.max_key_frame_size_mismatch);
432 } 436 }
433 printf("\n"); 437 printf("\n");
434 printf("Rates statistics for Layer data \n"); 438 printf("Rates statistics for Layer data \n");
435 for (int i = 0; i < num_temporal_layers_; i++) { 439 for (int i = 0; i < num_temporal_layers_; i++) {
436 printf("Temporal layer #%d \n", i); 440 printf("Temporal layer #%d \n", i);
437 int perc_frame_size_mismatch = 441 int perc_frame_size_mismatch =
438 100 * sum_frame_size_mismatch_[i] / num_frames_per_update_[i]; 442 100 * sum_frame_size_mismatch_[i] / num_frames_per_update_[i];
439 int perc_encoding_rate_mismatch = 443 int perc_encoding_rate_mismatch =
440 100 * fabs(encoding_bitrate_[i] - bit_rate_layer_[i]) / 444 100 * fabs(encoding_bitrate_[i] - bit_rate_layer_[i]) /
441 bit_rate_layer_[i]; 445 bit_rate_layer_[i];
442 printf( 446 printf(
443 " Target Layer Bit rate: %f \n" 447 " Target Layer Bit rate: %f \n"
444 " Layer frame rate: %f, \n" 448 " Layer frame rate: %f, \n"
445 " Layer per frame bandwidth: %f, \n" 449 " Layer per frame bandwidth: %f, \n"
446 " Layer Encoding bit rate: %f, \n" 450 " Layer Encoding bit rate: %f, \n"
447 " Layer Percent frame size mismatch: %d, \n" 451 " Layer Percent frame size mismatch: %d, \n"
448 " Layer Percent encoding rate mismatch: %d, \n" 452 " Layer Percent encoding rate mismatch: %d, \n"
449 " Number of frame processed per layer: %d \n", 453 " Number of frame processed per layer: %d \n",
450 bit_rate_layer_[i], frame_rate_layer_[i], per_frame_bandwidth_[i], 454 bit_rate_layer_[i], frame_rate_layer_[i], per_frame_bandwidth_[i],
451 encoding_bitrate_[i], perc_frame_size_mismatch, 455 encoding_bitrate_[i], perc_frame_size_mismatch,
452 perc_encoding_rate_mismatch, num_frames_per_update_[i]); 456 perc_encoding_rate_mismatch, num_frames_per_update_[i]);
453 EXPECT_LE(perc_frame_size_mismatch, max_delta_frame_size_mismatch); 457 EXPECT_LE(perc_frame_size_mismatch,
454 EXPECT_LE(perc_encoding_rate_mismatch, max_encoding_rate_mismatch); 458 rc_expected.max_delta_frame_size_mismatch);
459 EXPECT_LE(perc_encoding_rate_mismatch,
460 rc_expected.max_encoding_rate_mismatch);
455 } 461 }
456 printf("\n"); 462 printf("\n");
457 EXPECT_LE(num_frames_to_hit_target_, max_time_hit_target); 463 EXPECT_LE(num_frames_to_hit_target_, rc_expected.max_time_hit_target);
458 EXPECT_LE(num_dropped_frames, max_num_dropped_frames); 464 EXPECT_LE(num_dropped_frames, rc_expected.max_num_dropped_frames);
459 EXPECT_EQ(num_resize_actions, num_spatial_resizes); 465 EXPECT_EQ(rc_expected.num_spatial_resizes, num_resize_actions);
460 EXPECT_EQ(num_key_frames_, num_key_frames); 466 EXPECT_EQ(rc_expected.num_key_frames, num_key_frames_);
461 } 467 }
462 468
463 void VerifyQuality(const test::QualityMetricsResult& psnr_result, 469 void VerifyQuality(const test::QualityMetricsResult& psnr_result,
464 const test::QualityMetricsResult& ssim_result, 470 const test::QualityMetricsResult& ssim_result,
465 const QualityThresholds& quality_thresholds) { 471 const QualityThresholds& quality_thresholds) {
466 EXPECT_GT(psnr_result.average, quality_thresholds.min_avg_psnr); 472 EXPECT_GT(psnr_result.average, quality_thresholds.min_avg_psnr);
467 EXPECT_GT(psnr_result.min, quality_thresholds.min_min_psnr); 473 EXPECT_GT(psnr_result.min, quality_thresholds.min_min_psnr);
468 EXPECT_GT(ssim_result.average, quality_thresholds.min_avg_ssim); 474 EXPECT_GT(ssim_result.average, quality_thresholds.min_avg_ssim);
469 EXPECT_GT(ssim_result.min, quality_thresholds.min_min_ssim); 475 EXPECT_GT(ssim_result.min, quality_thresholds.min_min_ssim);
470 } 476 }
471 477
472 // Layer index corresponding to frame number, for up to 3 layers. 478 // Layer index corresponding to frame number, for up to 3 layers.
473 void LayerIndexForFrame(int frame_number) { 479 void LayerIndexForFrame(int frame_number) {
474 if (num_temporal_layers_ == 1) { 480 switch (num_temporal_layers_) {
475 layer_ = 0; 481 case 1:
476 } else if (num_temporal_layers_ == 2) {
477 // layer 0: 0 2 4 ...
478 // layer 1: 1 3
479 if (frame_number % 2 == 0) {
480 layer_ = 0; 482 layer_ = 0;
brandtr 2017/02/28 15:34:56 While you're at it, could you remove |layer_| and
åsapersson 2017/02/28 16:01:56 Done.
481 } else { 483 break;
482 layer_ = 1; 484 case 2:
483 } 485 // layer 0: 0 2 4 ...
484 } else if (num_temporal_layers_ == 3) { 486 // layer 1: 1 3
485 // layer 0: 0 4 8 ... 487 layer_ = (frame_number % 2 == 0) ? 0 : 1;
486 // layer 1: 2 6 488 break;
487 // layer 2: 1 3 5 7 489 case 3:
488 if (frame_number % 4 == 0) { 490 // layer 0: 0 4 8 ...
489 layer_ = 0; 491 // layer 1: 2 6
490 } else if ((frame_number + 2) % 4 == 0) { 492 // layer 2: 1 3 5 7
491 layer_ = 1; 493 if (frame_number % 4 == 0) {
492 } else if ((frame_number + 1) % 2 == 0) { 494 layer_ = 0;
493 layer_ = 2; 495 } else if ((frame_number + 2) % 4 == 0) {
494 } 496 layer_ = 1;
495 } else { 497 } else if ((frame_number + 1) % 2 == 0) {
496 RTC_NOTREACHED() << "Max 3 layers are supported."; 498 layer_ = 2;
499 }
500 break;
501 default:
502 RTC_NOTREACHED();
503 break;
497 } 504 }
498 } 505 }
499 506
500 // Set the bitrate and frame rate per layer, for up to 3 layers. 507 // Set the bitrate and frame rate per layer, for up to 3 layers.
501 void SetLayerRates() { 508 void SetLayerRates() {
502 RTC_DCHECK_LE(num_temporal_layers_, 3); 509 RTC_DCHECK_LE(num_temporal_layers_, kMaxNumTemporalLayers);
503 for (int i = 0; i < num_temporal_layers_; i++) { 510 for (int i = 0; i < num_temporal_layers_; i++) {
504 float bit_rate_ratio = 511 float bit_rate_ratio =
505 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i]; 512 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i];
506 if (i > 0) { 513 if (i > 0) {
507 float bit_rate_delta_ratio = 514 float bit_rate_delta_ratio =
508 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i] - 515 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i] -
509 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i - 1]; 516 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i - 1];
510 bit_rate_layer_[i] = bit_rate_ * bit_rate_delta_ratio; 517 bit_rate_layer_[i] = bit_rate_ * bit_rate_delta_ratio;
511 } else { 518 } else {
512 bit_rate_layer_[i] = bit_rate_ * bit_rate_ratio; 519 bit_rate_layer_[i] = bit_rate_ * bit_rate_ratio;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 // Counter for whole sequence run. 563 // Counter for whole sequence run.
557 ++frame_number; 564 ++frame_number;
558 // Counters for each rate update. 565 // Counters for each rate update.
559 ++num_frames_per_update_[layer_]; 566 ++num_frames_per_update_[layer_];
560 ++num_frames_total_; 567 ++num_frames_total_;
561 UpdateRateControlMetrics(frame_number, frame_type); 568 UpdateRateControlMetrics(frame_number, frame_type);
562 // If we hit another/next update, verify stats for current state and 569 // If we hit another/next update, verify stats for current state and
563 // update layers and codec with new rates. 570 // update layers and codec with new rates.
564 if (frame_number == 571 if (frame_number ==
565 rate_profile.frame_index_rate_update[update_index + 1]) { 572 rate_profile.frame_index_rate_update[update_index + 1]) {
566 VerifyRateControlMetrics( 573 VerifyRateControlMetrics(update_index, rc_thresholds[update_index]);
567 update_index,
568 rc_thresholds[update_index].max_key_frame_size_mismatch,
569 rc_thresholds[update_index].max_delta_frame_size_mismatch,
570 rc_thresholds[update_index].max_encoding_rate_mismatch,
571 rc_thresholds[update_index].max_time_hit_target,
572 rc_thresholds[update_index].max_num_dropped_frames,
573 rc_thresholds[update_index].num_spatial_resizes,
574 rc_thresholds[update_index].num_key_frames);
575 // Update layer rates and the codec with new rates. 574 // Update layer rates and the codec with new rates.
576 ++update_index; 575 ++update_index;
577 bit_rate_ = rate_profile.target_bit_rate[update_index]; 576 bit_rate_ = rate_profile.target_bit_rate[update_index];
578 frame_rate_ = rate_profile.input_frame_rate[update_index]; 577 frame_rate_ = rate_profile.input_frame_rate[update_index];
579 SetLayerRates(); 578 SetLayerRates();
580 ResetRateControlMetrics( 579 ResetRateControlMetrics(
581 rate_profile.frame_index_rate_update[update_index + 1]); 580 rate_profile.frame_index_rate_update[update_index + 1]);
582 processor_->SetRates(bit_rate_, frame_rate_); 581 processor_->SetRates(bit_rate_, frame_rate_);
583 } 582 }
584 } 583 }
585 VerifyRateControlMetrics( 584 VerifyRateControlMetrics(update_index, rc_thresholds[update_index]);
586 update_index, rc_thresholds[update_index].max_key_frame_size_mismatch,
587 rc_thresholds[update_index].max_delta_frame_size_mismatch,
588 rc_thresholds[update_index].max_encoding_rate_mismatch,
589 rc_thresholds[update_index].max_time_hit_target,
590 rc_thresholds[update_index].max_num_dropped_frames,
591 rc_thresholds[update_index].num_spatial_resizes,
592 rc_thresholds[update_index].num_key_frames);
593 EXPECT_EQ(num_frames, frame_number); 585 EXPECT_EQ(num_frames, frame_number);
594 EXPECT_EQ(num_frames + 1, static_cast<int>(stats_.stats_.size())); 586 EXPECT_EQ(num_frames + 1, static_cast<int>(stats_.stats_.size()));
595 587
596 // Release encoder and decoder to make sure they have finished processing: 588 // Release encoder and decoder to make sure they have finished processing:
597 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release()); 589 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release());
598 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release()); 590 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release());
599 591
600 // Close the analysis files before we use them for SSIM/PSNR calculations. 592 // Close the analysis files before we use them for SSIM/PSNR calculations.
601 analysis_frame_reader_->Close(); 593 analysis_frame_reader_->Close();
602 analysis_frame_writer_->Close(); 594 analysis_frame_writer_->Close();
(...skipping 12 matching lines...) Expand all
615 // TODO(marpan): Should compute these quality metrics per SetRates update. 607 // TODO(marpan): Should compute these quality metrics per SetRates update.
616 test::QualityMetricsResult psnr_result, ssim_result; 608 test::QualityMetricsResult psnr_result, ssim_result;
617 EXPECT_EQ(0, test::I420MetricsFromFiles(config_.input_filename.c_str(), 609 EXPECT_EQ(0, test::I420MetricsFromFiles(config_.input_filename.c_str(),
618 config_.output_filename.c_str(), 610 config_.output_filename.c_str(),
619 config_.codec_settings->width, 611 config_.codec_settings->width,
620 config_.codec_settings->height, 612 config_.codec_settings->height,
621 &psnr_result, &ssim_result)); 613 &psnr_result, &ssim_result));
622 printf("PSNR avg: %f, min: %f\nSSIM avg: %f, min: %f\n", 614 printf("PSNR avg: %f, min: %f\nSSIM avg: %f, min: %f\n",
623 psnr_result.average, psnr_result.min, ssim_result.average, 615 psnr_result.average, psnr_result.min, ssim_result.average,
624 ssim_result.min); 616 ssim_result.min);
617 VerifyQuality(psnr_result, ssim_result, quality_thresholds);
625 stats_.PrintSummary(); 618 stats_.PrintSummary();
626 VerifyQuality(psnr_result, ssim_result, quality_thresholds);
627 619
628 // Remove analysis file. 620 // Remove analysis file.
629 if (remove(config_.output_filename.c_str()) < 0) { 621 if (remove(config_.output_filename.c_str()) < 0) {
630 fprintf(stderr, "Failed to remove temporary file!\n"); 622 fprintf(stderr, "Failed to remove temporary file!\n");
631 } 623 }
632 } 624 }
633 625
634 static void SetCodecParams(CodecParams* process_settings, 626 static void SetCodecParams(CodecParams* process_settings,
635 VideoCodecType codec_type, 627 VideoCodecType codec_type,
636 bool hw_codec, 628 bool hw_codec,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 test::TestConfig config_; 731 test::TestConfig config_;
740 // Must be destroyed before |encoder_| and |decoder_|. 732 // Must be destroyed before |encoder_| and |decoder_|.
741 std::unique_ptr<test::VideoProcessor> processor_; 733 std::unique_ptr<test::VideoProcessor> processor_;
742 734
743 // Visualization objects. 735 // Visualization objects.
744 std::unique_ptr<test::FrameWriter> source_frame_writer_; 736 std::unique_ptr<test::FrameWriter> source_frame_writer_;
745 std::unique_ptr<IvfFileWriter> encoded_frame_writer_; 737 std::unique_ptr<IvfFileWriter> encoded_frame_writer_;
746 std::unique_ptr<test::FrameWriter> decoded_frame_writer_; 738 std::unique_ptr<test::FrameWriter> decoded_frame_writer_;
747 739
748 // Quantities defined/updated for every encoder rate update. 740 // Quantities defined/updated for every encoder rate update.
749 // Some quantities defined per temporal layer (at most 3 layers in this test). 741 int num_frames_per_update_[kMaxNumTemporalLayers];
750 int num_frames_per_update_[3]; 742 float sum_frame_size_mismatch_[kMaxNumTemporalLayers];
751 float sum_frame_size_mismatch_[3]; 743 float sum_encoded_frame_size_[kMaxNumTemporalLayers];
752 float sum_encoded_frame_size_[3]; 744 float encoding_bitrate_[kMaxNumTemporalLayers];
753 float encoding_bitrate_[3]; 745 float per_frame_bandwidth_[kMaxNumTemporalLayers];
754 float per_frame_bandwidth_[3]; 746 float bit_rate_layer_[kMaxNumTemporalLayers];
755 float bit_rate_layer_[3]; 747 float frame_rate_layer_[kMaxNumTemporalLayers];
756 float frame_rate_layer_[3];
757 int num_frames_total_; 748 int num_frames_total_;
758 float sum_encoded_frame_size_total_; 749 float sum_encoded_frame_size_total_;
759 float encoding_bitrate_total_; 750 float encoding_bitrate_total_;
760 float perc_encoding_rate_mismatch_; 751 float perc_encoding_rate_mismatch_;
761 int num_frames_to_hit_target_; 752 int num_frames_to_hit_target_;
762 bool encoding_rate_within_target_; 753 bool encoding_rate_within_target_;
763 int bit_rate_; 754 int bit_rate_;
764 int frame_rate_; 755 int frame_rate_;
765 int layer_; 756 int layer_;
766 float target_size_key_frame_initial_; 757 float target_size_key_frame_initial_;
767 float target_size_key_frame_; 758 float target_size_key_frame_;
768 float sum_key_frame_size_mismatch_; 759 float sum_key_frame_size_mismatch_;
769 int num_key_frames_; 760 int num_key_frames_;
770 float start_bitrate_; 761 float start_bitrate_;
771 int start_frame_rate_; 762 int start_frame_rate_;
772 763
773 // Codec and network settings. 764 // Codec and network settings.
774 float packet_loss_probability_; 765 float packet_loss_probability_;
775 int num_temporal_layers_; 766 int num_temporal_layers_;
776 }; 767 };
777 768
778 } // namespace test 769 } // namespace test
779 } // namespace webrtc 770 } // namespace webrtc
780 771
781 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES T_H_ 772 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES T_H_
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/test/videoprocessor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698