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

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

Issue 2995513002: Minor improvements to VideoProcessor and corresponding test. (Closed)
Patch Set: Fix compile. Created 3 years, 4 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
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 RTC_CHECK(analysis_frame_reader_->Init()); 224 RTC_CHECK(analysis_frame_reader_->Init());
225 RTC_CHECK(analysis_frame_writer_->Init()); 225 RTC_CHECK(analysis_frame_writer_->Init());
226 226
227 if (visualization_params) { 227 if (visualization_params) {
228 // clang-format off 228 // clang-format off
229 const std::string output_filename_base = 229 const std::string output_filename_base =
230 test::OutputPath() + config_.filename + 230 test::OutputPath() + config_.filename +
231 "_cd-" + CodecTypeToPayloadName( 231 "_cd-" + CodecTypeToPayloadName(
232 config_.codec_settings->codecType).value_or("") + 232 config_.codec_settings->codecType).value_or("") +
233 "_hw-" + std::to_string(config_.hw_codec) + 233 "_hw-" + std::to_string(config_.hw_codec) +
234 "_fr-" + std::to_string(start_frame_rate_) +
235 "_br-" + std::to_string( 234 "_br-" + std::to_string(
236 static_cast<int>(config_.codec_settings->startBitrate)); 235 static_cast<int>(config_.codec_settings->startBitrate));
237 // clang-format on 236 // clang-format on
238 if (visualization_params->save_source_y4m) { 237 if (visualization_params->save_source_y4m) {
239 source_frame_writer_.reset(new test::Y4mFrameWriterImpl( 238 source_frame_writer_.reset(new test::Y4mFrameWriterImpl(
240 output_filename_base + "_source.y4m", config_.codec_settings->width, 239 output_filename_base + "_source.y4m", config_.codec_settings->width,
241 config_.codec_settings->height, start_frame_rate_)); 240 config_.codec_settings->height, start_frame_rate_));
242 RTC_CHECK(source_frame_writer_->Init()); 241 RTC_CHECK(source_frame_writer_->Init());
243 } 242 }
244 if (visualization_params->save_encoded_ivf) { 243 if (visualization_params->save_encoded_ivf) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 encoding_rate_within_target_ = true; 335 encoding_rate_within_target_ = true;
337 } 336 }
338 } 337 }
339 338
340 // Verify expected behavior of rate control and print out data. 339 // Verify expected behavior of rate control and print out data.
341 void VerifyRateControlMetrics(int update_index, 340 void VerifyRateControlMetrics(int update_index,
342 const RateControlThresholds& rc_expected) { 341 const RateControlThresholds& rc_expected) {
343 int num_dropped_frames = processor_->NumberDroppedFrames(); 342 int num_dropped_frames = processor_->NumberDroppedFrames();
344 int num_resize_actions = processor_->NumberSpatialResizes(); 343 int num_resize_actions = processor_->NumberSpatialResizes();
345 printf( 344 printf(
346 "For update #: %d,\n" 345 "Rate update #%d:\n"
347 " Target Bitrate: %d,\n" 346 " Target bitrate : %d\n"
348 " Encoding bitrate: %f,\n" 347 " Encoded bitrate : %f\n"
349 " Frame rate: %d \n", 348 " Frame rate : %d\n",
350 update_index, bit_rate_, encoding_bitrate_total_, frame_rate_); 349 update_index, bit_rate_, encoding_bitrate_total_, frame_rate_);
351 printf( 350 printf(
352 " Number of processed frames: %d, \n" 351 " # processed frames : %d\n"
353 " Number of frames to approach target rate: %d, \n" 352 " # frames to convergence: %d\n"
354 " Number of dropped frames: %d, \n" 353 " # dropped frames : %d\n"
355 " Number of spatial resizes: %d, \n", 354 " # spatial resizes : %d\n",
356 num_frames_total_, num_frames_to_hit_target_, num_dropped_frames, 355 num_frames_total_, num_frames_to_hit_target_, num_dropped_frames,
357 num_resize_actions); 356 num_resize_actions);
358 EXPECT_LE(perc_encoding_rate_mismatch_, 357 EXPECT_LE(perc_encoding_rate_mismatch_,
359 rc_expected.max_encoding_rate_mismatch); 358 rc_expected.max_encoding_rate_mismatch);
360 if (num_key_frames_ > 0) { 359 if (num_key_frames_ > 0) {
361 int perc_key_frame_size_mismatch = 360 int perc_key_frame_size_mismatch =
362 100 * sum_key_frame_size_mismatch_ / num_key_frames_; 361 100 * sum_key_frame_size_mismatch_ / num_key_frames_;
363 printf( 362 printf(
364 " Number of Key frames: %d \n" 363 " # key frames : %d\n"
365 " Key frame rate mismatch: %d \n", 364 " Key frame rate mismatch: %d\n",
366 num_key_frames_, perc_key_frame_size_mismatch); 365 num_key_frames_, perc_key_frame_size_mismatch);
367 EXPECT_LE(perc_key_frame_size_mismatch, 366 EXPECT_LE(perc_key_frame_size_mismatch,
368 rc_expected.max_key_frame_size_mismatch); 367 rc_expected.max_key_frame_size_mismatch);
369 } 368 }
370 printf("\n");
371 printf("Rates statistics for Layer data \n");
372 for (int i = 0; i < num_temporal_layers_; i++) { 369 for (int i = 0; i < num_temporal_layers_; i++) {
373 printf("Temporal layer #%d \n", i); 370 printf(" Temporal layer #%d:\n", i);
374 int perc_frame_size_mismatch = 371 int perc_frame_size_mismatch =
375 100 * sum_frame_size_mismatch_[i] / num_frames_per_update_[i]; 372 100 * sum_frame_size_mismatch_[i] / num_frames_per_update_[i];
376 int perc_encoding_rate_mismatch = 373 int perc_encoding_rate_mismatch =
377 100 * fabs(encoding_bitrate_[i] - bit_rate_layer_[i]) / 374 100 * fabs(encoding_bitrate_[i] - bit_rate_layer_[i]) /
378 bit_rate_layer_[i]; 375 bit_rate_layer_[i];
379 printf( 376 printf(
380 " Target Layer Bit rate: %f \n" 377 " Target layer bitrate : %f\n"
381 " Layer frame rate: %f, \n" 378 " Layer frame rate : %f\n"
382 " Layer per frame bandwidth: %f, \n" 379 " Layer per frame bandwidth : %f\n"
383 " Layer Encoding bit rate: %f, \n" 380 " Layer encoding bitrate : %f\n"
384 " Layer Percent frame size mismatch: %d, \n" 381 " Layer percent frame size mismatch : %d\n"
385 " Layer Percent encoding rate mismatch: %d, \n" 382 " Layer percent encoding rate mismatch: %d\n"
386 " Number of frame processed per layer: %d \n", 383 " # frame processed per layer : %d\n",
387 bit_rate_layer_[i], frame_rate_layer_[i], per_frame_bandwidth_[i], 384 bit_rate_layer_[i], frame_rate_layer_[i], per_frame_bandwidth_[i],
388 encoding_bitrate_[i], perc_frame_size_mismatch, 385 encoding_bitrate_[i], perc_frame_size_mismatch,
389 perc_encoding_rate_mismatch, num_frames_per_update_[i]); 386 perc_encoding_rate_mismatch, num_frames_per_update_[i]);
390 EXPECT_LE(perc_frame_size_mismatch, 387 EXPECT_LE(perc_frame_size_mismatch,
391 rc_expected.max_delta_frame_size_mismatch); 388 rc_expected.max_delta_frame_size_mismatch);
392 EXPECT_LE(perc_encoding_rate_mismatch, 389 EXPECT_LE(perc_encoding_rate_mismatch,
393 rc_expected.max_encoding_rate_mismatch); 390 rc_expected.max_encoding_rate_mismatch);
394 } 391 }
395 printf("\n"); 392 printf("\n");
396 EXPECT_LE(num_frames_to_hit_target_, rc_expected.max_time_hit_target); 393 EXPECT_LE(num_frames_to_hit_target_, rc_expected.max_time_hit_target);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 decoded_frame_writer_->Close(); 591 decoded_frame_writer_->Close();
595 } 592 }
596 593
597 // TODO(marpan): Should compute these quality metrics per SetRates update. 594 // TODO(marpan): Should compute these quality metrics per SetRates update.
598 test::QualityMetricsResult psnr_result, ssim_result; 595 test::QualityMetricsResult psnr_result, ssim_result;
599 EXPECT_EQ(0, test::I420MetricsFromFiles(config_.input_filename.c_str(), 596 EXPECT_EQ(0, test::I420MetricsFromFiles(config_.input_filename.c_str(),
600 config_.output_filename.c_str(), 597 config_.output_filename.c_str(),
601 config_.codec_settings->width, 598 config_.codec_settings->width,
602 config_.codec_settings->height, 599 config_.codec_settings->height,
603 &psnr_result, &ssim_result)); 600 &psnr_result, &ssim_result));
601 VerifyQuality(psnr_result, ssim_result, quality_thresholds);
602 stats_.PrintSummary();
604 printf("PSNR avg: %f, min: %f\nSSIM avg: %f, min: %f\n", 603 printf("PSNR avg: %f, min: %f\nSSIM avg: %f, min: %f\n",
605 psnr_result.average, psnr_result.min, ssim_result.average, 604 psnr_result.average, psnr_result.min, ssim_result.average,
606 ssim_result.min); 605 ssim_result.min);
607 VerifyQuality(psnr_result, ssim_result, quality_thresholds); 606 printf("\n");
608 stats_.PrintSummary();
609 607
610 // Remove analysis file. 608 // Remove analysis file.
611 if (remove(config_.output_filename.c_str()) < 0) { 609 if (remove(config_.output_filename.c_str()) < 0) {
612 fprintf(stderr, "Failed to remove temporary file!\n"); 610 fprintf(stderr, "Failed to remove temporary file!\n");
613 } 611 }
614 } 612 }
615 613
616 static void SetProcessParams(test::TestConfig* config, 614 static void SetProcessParams(test::TestConfig* config,
617 bool hw_codec, 615 bool hw_codec,
618 bool use_single_core, 616 bool use_single_core,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 int start_frame_rate_; 761 int start_frame_rate_;
764 762
765 // Codec and network settings. 763 // Codec and network settings.
766 int num_temporal_layers_; 764 int num_temporal_layers_;
767 }; 765 };
768 766
769 } // namespace test 767 } // namespace test
770 } // namespace webrtc 768 } // namespace webrtc
771 769
772 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES T_H_ 770 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES T_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698