OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 0.5 * kInitialBufferSize * bitrate_layer_[0]; | 485 0.5 * kInitialBufferSize * bitrate_layer_[0]; |
486 processor_->SetRates(bitrate_kbps_, framerate_); | 486 processor_->SetRates(bitrate_kbps_, framerate_); |
487 | 487 |
488 // Process each frame, up to |num_frames|. | 488 // Process each frame, up to |num_frames|. |
489 int frame_number = 0; | 489 int frame_number = 0; |
490 int update_index = 0; | 490 int update_index = 0; |
491 int num_frames = rate_profile.num_frames; | 491 int num_frames = rate_profile.num_frames; |
492 ResetRateControlMetrics( | 492 ResetRateControlMetrics( |
493 rate_profile.frame_index_rate_update[update_index + 1]); | 493 rate_profile.frame_index_rate_update[update_index + 1]); |
494 | 494 |
495 if (config_.batch_mode) { | 495 while (frame_number < num_frames) { |
496 // In batch mode, we calculate the metrics for all frames after all frames | 496 processor_->ProcessFrame(frame_number); |
497 // have been sent for encoding. | 497 VerifyQpParser(frame_number); |
| 498 const int tl_idx = TemporalLayerIndexForFrame(frame_number); |
| 499 ++num_frames_per_update_[tl_idx]; |
| 500 ++num_frames_total_; |
| 501 UpdateRateControlMetrics(frame_number); |
498 | 502 |
499 for (frame_number = 0; frame_number < num_frames; ++frame_number) { | 503 ++frame_number; |
500 processor_->ProcessFrame(frame_number); | |
501 } | |
502 | 504 |
503 for (frame_number = 0; frame_number < num_frames; ++frame_number) { | 505 // If we hit another/next update, verify stats for current state and |
504 const int tl_idx = TemporalLayerIndexForFrame(frame_number); | 506 // update layers and codec with new rates. |
505 ++num_frames_per_update_[tl_idx]; | 507 if (frame_number == |
506 ++num_frames_total_; | 508 rate_profile.frame_index_rate_update[update_index + 1]) { |
507 UpdateRateControlMetrics(frame_number); | 509 PrintAndMaybeVerifyRateControlMetrics(update_index, rc_thresholds); |
508 } | |
509 } else { | |
510 // In online mode, we calculate the metrics for a given frame right after | |
511 // it has been sent for encoding. | |
512 | 510 |
513 if (config_.hw_codec) { | 511 // Update layer rates and the codec with new rates. |
514 LOG(LS_WARNING) << "HW codecs should mostly be run in batch mode, " | 512 ++update_index; |
515 "since they may be pipelining."; | 513 bitrate_kbps_ = rate_profile.target_bit_rate[update_index]; |
516 } | 514 framerate_ = rate_profile.input_frame_rate[update_index]; |
517 | 515 SetTemporalLayerRates(); |
518 while (frame_number < num_frames) { | 516 ResetRateControlMetrics( |
519 processor_->ProcessFrame(frame_number); | 517 rate_profile.frame_index_rate_update[update_index + 1]); |
520 VerifyQpParser(frame_number); | 518 processor_->SetRates(bitrate_kbps_, framerate_); |
521 const int tl_idx = TemporalLayerIndexForFrame(frame_number); | |
522 ++num_frames_per_update_[tl_idx]; | |
523 ++num_frames_total_; | |
524 UpdateRateControlMetrics(frame_number); | |
525 | |
526 ++frame_number; | |
527 | |
528 // If we hit another/next update, verify stats for current state and | |
529 // update layers and codec with new rates. | |
530 if (frame_number == | |
531 rate_profile.frame_index_rate_update[update_index + 1]) { | |
532 PrintAndMaybeVerifyRateControlMetrics(update_index, rc_thresholds); | |
533 | |
534 // Update layer rates and the codec with new rates. | |
535 ++update_index; | |
536 bitrate_kbps_ = rate_profile.target_bit_rate[update_index]; | |
537 framerate_ = rate_profile.input_frame_rate[update_index]; | |
538 SetTemporalLayerRates(); | |
539 ResetRateControlMetrics( | |
540 rate_profile.frame_index_rate_update[update_index + 1]); | |
541 processor_->SetRates(bitrate_kbps_, framerate_); | |
542 } | |
543 } | 519 } |
544 } | 520 } |
545 | 521 |
546 // Verify rate control metrics for all frames (if in batch mode), or for all | 522 // Verify rate control metrics for all frames since the last rate update. |
547 // frames since the last rate update (if not in batch mode). | |
548 PrintAndMaybeVerifyRateControlMetrics(update_index, rc_thresholds); | 523 PrintAndMaybeVerifyRateControlMetrics(update_index, rc_thresholds); |
549 EXPECT_EQ(num_frames, frame_number); | 524 EXPECT_EQ(num_frames, frame_number); |
550 EXPECT_EQ(num_frames, static_cast<int>(stats_.stats_.size())); | 525 EXPECT_EQ(num_frames, static_cast<int>(stats_.stats_.size())); |
551 | 526 |
552 // Release encoder and decoder to make sure they have finished processing. | 527 // Release encoder and decoder to make sure they have finished processing. |
553 processor_->Release(); | 528 processor_->Release(); |
554 DestroyEncoderAndDecoder(); | 529 DestroyEncoderAndDecoder(); |
555 | 530 |
556 // Close the analysis files before we use them for SSIM/PSNR calculations. | 531 // Close the analysis files before we use them for SSIM/PSNR calculations. |
557 analysis_frame_reader_->Close(); | 532 analysis_frame_reader_->Close(); |
(...skipping 27 matching lines...) Expand all Loading... |
585 if (remove(config_.output_filename.c_str()) < 0) { | 560 if (remove(config_.output_filename.c_str()) < 0) { |
586 fprintf(stderr, "Failed to remove temporary file!\n"); | 561 fprintf(stderr, "Failed to remove temporary file!\n"); |
587 } | 562 } |
588 } | 563 } |
589 | 564 |
590 static void SetTestConfig(TestConfig* config, | 565 static void SetTestConfig(TestConfig* config, |
591 bool hw_codec, | 566 bool hw_codec, |
592 bool use_single_core, | 567 bool use_single_core, |
593 float packet_loss_probability, | 568 float packet_loss_probability, |
594 std::string filename, | 569 std::string filename, |
595 bool verbose_logging, | 570 bool verbose_logging) { |
596 bool batch_mode) { | |
597 config->filename = filename; | 571 config->filename = filename; |
598 config->input_filename = ResourcePath(filename, "yuv"); | 572 config->input_filename = ResourcePath(filename, "yuv"); |
599 // Generate an output filename in a safe way. | 573 // Generate an output filename in a safe way. |
600 config->output_filename = | 574 config->output_filename = |
601 TempFilename(OutputPath(), "videoprocessor_integrationtest"); | 575 TempFilename(OutputPath(), "videoprocessor_integrationtest"); |
602 config->networking_config.packet_loss_probability = packet_loss_probability; | 576 config->networking_config.packet_loss_probability = packet_loss_probability; |
603 config->use_single_core = use_single_core; | 577 config->use_single_core = use_single_core; |
604 config->verbose = verbose_logging; | 578 config->verbose = verbose_logging; |
605 config->hw_codec = hw_codec; | 579 config->hw_codec = hw_codec; |
606 config->batch_mode = batch_mode; | |
607 } | 580 } |
608 | 581 |
609 static void SetCodecSettings(TestConfig* config, | 582 static void SetCodecSettings(TestConfig* config, |
610 VideoCodecType codec_type, | 583 VideoCodecType codec_type, |
611 int num_temporal_layers, | 584 int num_temporal_layers, |
612 bool error_concealment_on, | 585 bool error_concealment_on, |
613 bool denoising_on, | 586 bool denoising_on, |
614 bool frame_dropper_on, | 587 bool frame_dropper_on, |
615 bool spatial_resize_on, | 588 bool spatial_resize_on, |
616 bool resilience_on, | 589 bool resilience_on, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 float target_size_key_frame_initial_; | 697 float target_size_key_frame_initial_; |
725 float target_size_key_frame_; | 698 float target_size_key_frame_; |
726 float sum_key_frame_size_mismatch_; | 699 float sum_key_frame_size_mismatch_; |
727 int num_key_frames_; | 700 int num_key_frames_; |
728 }; | 701 }; |
729 | 702 |
730 } // namespace test | 703 } // namespace test |
731 } // namespace webrtc | 704 } // namespace webrtc |
732 | 705 |
733 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES
T_H_ | 706 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES
T_H_ |
OLD | NEW |