Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 #include "webrtc/video/video_quality_test.h" | 10 #include "webrtc/video/video_quality_test.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 #include "webrtc/rtc_base/optional.h" | 38 #include "webrtc/rtc_base/optional.h" |
| 39 #include "webrtc/rtc_base/platform_file.h" | 39 #include "webrtc/rtc_base/platform_file.h" |
| 40 #include "webrtc/rtc_base/timeutils.h" | 40 #include "webrtc/rtc_base/timeutils.h" |
| 41 #include "webrtc/system_wrappers/include/cpu_info.h" | 41 #include "webrtc/system_wrappers/include/cpu_info.h" |
| 42 #include "webrtc/system_wrappers/include/field_trial.h" | 42 #include "webrtc/system_wrappers/include/field_trial.h" |
| 43 #include "webrtc/test/gtest.h" | 43 #include "webrtc/test/gtest.h" |
| 44 #include "webrtc/test/layer_filtering_transport.h" | 44 #include "webrtc/test/layer_filtering_transport.h" |
| 45 #include "webrtc/test/run_loop.h" | 45 #include "webrtc/test/run_loop.h" |
| 46 #include "webrtc/test/statistics.h" | 46 #include "webrtc/test/statistics.h" |
| 47 #include "webrtc/test/testsupport/fileutils.h" | 47 #include "webrtc/test/testsupport/fileutils.h" |
| 48 #include "webrtc/test/testsupport/frame_writer.h" | |
| 48 #include "webrtc/test/vcm_capturer.h" | 49 #include "webrtc/test/vcm_capturer.h" |
| 49 #include "webrtc/test/video_renderer.h" | 50 #include "webrtc/test/video_renderer.h" |
| 50 #include "webrtc/voice_engine/include/voe_base.h" | 51 #include "webrtc/voice_engine/include/voe_base.h" |
| 51 | 52 |
| 52 #include "webrtc/test/rtp_file_writer.h" | 53 #include "webrtc/test/rtp_file_writer.h" |
| 53 | 54 |
| 54 namespace { | 55 namespace { |
| 55 | 56 |
| 56 constexpr int kSendStatsPollingIntervalMs = 1000; | 57 constexpr int kSendStatsPollingIntervalMs = 1000; |
| 57 | 58 |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 796 PrintResult("sender_time", sender_time_, " ms"); | 797 PrintResult("sender_time", sender_time_, " ms"); |
| 797 PrintResult("receiver_time", receiver_time_, " ms"); | 798 PrintResult("receiver_time", receiver_time_, " ms"); |
| 798 PrintResult("total_delay_incl_network", end_to_end_, " ms"); | 799 PrintResult("total_delay_incl_network", end_to_end_, " ms"); |
| 799 PrintResult("time_between_rendered_frames", rendered_delta_, " ms"); | 800 PrintResult("time_between_rendered_frames", rendered_delta_, " ms"); |
| 800 PrintResult("encode_frame_rate", encode_frame_rate_, " fps"); | 801 PrintResult("encode_frame_rate", encode_frame_rate_, " fps"); |
| 801 PrintResult("encode_time", encode_time_ms_, " ms"); | 802 PrintResult("encode_time", encode_time_ms_, " ms"); |
| 802 PrintResult("media_bitrate", media_bitrate_bps_, " bps"); | 803 PrintResult("media_bitrate", media_bitrate_bps_, " bps"); |
| 803 PrintResult("fec_bitrate", fec_bitrate_bps_, " bps"); | 804 PrintResult("fec_bitrate", fec_bitrate_bps_, " bps"); |
| 804 PrintResult("send_bandwidth", send_bandwidth_bps_, " bps"); | 805 PrintResult("send_bandwidth", send_bandwidth_bps_, " bps"); |
| 805 | 806 |
| 807 if (min_psnr_) { | |
| 808 printf("RESULT min_psnr: %s = %lf dB\n", test_label_.c_str(), | |
| 809 *min_psnr_); | |
| 810 } | |
| 811 | |
| 806 if (receive_stream_ != nullptr) { | 812 if (receive_stream_ != nullptr) { |
| 807 PrintResult("decode_time", decode_time_ms_, " ms"); | 813 PrintResult("decode_time", decode_time_ms_, " ms"); |
| 808 } | 814 } |
| 809 | 815 |
| 810 printf("RESULT dropped_frames: %s = %d frames\n", test_label_.c_str(), | 816 printf("RESULT dropped_frames: %s = %d frames\n", test_label_.c_str(), |
| 811 dropped_frames_); | 817 dropped_frames_); |
| 812 printf("RESULT cpu_usage: %s = %lf %%\n", test_label_.c_str(), | 818 printf("RESULT cpu_usage: %s = %lf %%\n", test_label_.c_str(), |
| 813 GetCpuUsagePercent()); | 819 GetCpuUsagePercent()); |
| 814 | 820 |
| 815 #if defined(WEBRTC_WIN) | 821 #if defined(WEBRTC_WIN) |
| 816 // On Linux and Mac in Resident Set some unused pages may be counted. | 822 // On Linux and Mac in Resident Set some unused pages may be counted. |
| 817 // Therefore this metric will depend on order in which tests are run and | 823 // Therefore this metric will depend on order in which tests are run and |
| 818 // will be flaky. | 824 // will be flaky. |
| 819 PrintResult("memory_usage", memory_usage_, " bytes"); | 825 PrintResult("memory_usage", memory_usage_, " bytes"); |
| 820 #endif | 826 #endif |
| 821 | 827 |
| 828 if (bad_frame_) { | |
| 829 test::Y4mFrameWriterImpl frame_writer(test_label_ + ".y4m", | |
| 830 bad_frame_->width(), | |
| 831 bad_frame_->height(), 1); | |
| 832 frame_writer.Init(); | |
|
sprang_webrtc
2017/07/24 14:24:09
Maybe DCHECK the return value?
ilnik
2017/07/25 10:34:54
Done.
| |
| 833 size_t length = | |
| 834 CalcBufferSize(VideoType::kI420, bad_frame_->width(), | |
| 835 bad_frame_->height()); | |
| 836 rtc::Buffer extracted_buffer(length); | |
| 837 size_t extracted_length = ExtractBuffer( | |
| 838 bad_frame_->video_frame_buffer()->ToI420(), length, | |
| 839 extracted_buffer.data()); | |
| 840 RTC_DCHECK_EQ(extracted_length, frame_writer.FrameLength()); | |
| 841 frame_writer.WriteFrame(extracted_buffer.data()); | |
|
sprang_webrtc
2017/07/24 14:24:09
DCHECK return value
ilnik
2017/07/25 10:34:54
Done.
| |
| 842 frame_writer.Close(); | |
| 843 } | |
| 844 | |
| 822 // Disable quality check for quick test, as quality checks may fail | 845 // Disable quality check for quick test, as quality checks may fail |
| 823 // because too few samples were collected. | 846 // because too few samples were collected. |
| 824 if (!is_quick_test_enabled_) { | 847 if (!is_quick_test_enabled_) { |
| 825 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_); | 848 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_); |
| 826 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_); | 849 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_); |
| 827 } | 850 } |
| 828 } | 851 } |
| 829 | 852 |
| 830 void PerformFrameComparison(const FrameComparison& comparison) { | 853 void PerformFrameComparison(const FrameComparison& comparison) { |
| 831 // Perform expensive psnr and ssim calculations while not holding lock. | 854 // Perform expensive psnr and ssim calculations while not holding lock. |
| 832 double psnr = -1.0; | 855 double psnr = -1.0; |
| 833 double ssim = -1.0; | 856 double ssim = -1.0; |
| 834 if (comparison.reference && !comparison.dropped) { | 857 if (comparison.reference && !comparison.dropped) { |
| 835 psnr = I420PSNR(&*comparison.reference, &*comparison.render); | 858 psnr = I420PSNR(&*comparison.reference, &*comparison.render); |
| 836 ssim = I420SSIM(&*comparison.reference, &*comparison.render); | 859 ssim = I420SSIM(&*comparison.reference, &*comparison.render); |
| 837 } | 860 } |
| 838 | 861 |
| 839 rtc::CritScope crit(&comparison_lock_); | 862 rtc::CritScope crit(&comparison_lock_); |
| 863 | |
| 864 if (psnr >= 0.0) { | |
| 865 if (!min_psnr_ || *min_psnr_ > psnr) { | |
|
sprang_webrtc
2017/07/24 14:24:09
Merge these nested ifs into one
ilnik
2017/07/25 10:34:54
Done.
| |
| 866 min_psnr_.emplace(psnr); | |
| 867 bad_frame_.emplace(*comparison.render); | |
| 868 } | |
| 869 } | |
| 870 | |
| 840 if (graph_data_output_file_) { | 871 if (graph_data_output_file_) { |
| 841 samples_.push_back(Sample( | 872 samples_.push_back(Sample( |
| 842 comparison.dropped, comparison.input_time_ms, comparison.send_time_ms, | 873 comparison.dropped, comparison.input_time_ms, comparison.send_time_ms, |
| 843 comparison.recv_time_ms, comparison.render_time_ms, | 874 comparison.recv_time_ms, comparison.render_time_ms, |
| 844 comparison.encoded_frame_size, psnr, ssim)); | 875 comparison.encoded_frame_size, psnr, ssim)); |
| 845 } | 876 } |
| 846 if (psnr >= 0.0) | 877 if (psnr >= 0.0) |
| 847 psnr_.AddSample(psnr); | 878 psnr_.AddSample(psnr); |
| 848 if (ssim >= 0.0) | 879 if (ssim >= 0.0) |
| 849 ssim_.AddSample(ssim); | 880 ssim_.AddSample(ssim); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1032 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_); | 1063 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_); |
| 1033 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_); | 1064 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_); |
| 1034 test::Statistics encode_time_ms_ GUARDED_BY(comparison_lock_); | 1065 test::Statistics encode_time_ms_ GUARDED_BY(comparison_lock_); |
| 1035 test::Statistics encode_usage_percent_ GUARDED_BY(comparison_lock_); | 1066 test::Statistics encode_usage_percent_ GUARDED_BY(comparison_lock_); |
| 1036 test::Statistics decode_time_ms_ GUARDED_BY(comparison_lock_); | 1067 test::Statistics decode_time_ms_ GUARDED_BY(comparison_lock_); |
| 1037 test::Statistics decode_time_max_ms_ GUARDED_BY(comparison_lock_); | 1068 test::Statistics decode_time_max_ms_ GUARDED_BY(comparison_lock_); |
| 1038 test::Statistics media_bitrate_bps_ GUARDED_BY(comparison_lock_); | 1069 test::Statistics media_bitrate_bps_ GUARDED_BY(comparison_lock_); |
| 1039 test::Statistics fec_bitrate_bps_ GUARDED_BY(comparison_lock_); | 1070 test::Statistics fec_bitrate_bps_ GUARDED_BY(comparison_lock_); |
| 1040 test::Statistics send_bandwidth_bps_ GUARDED_BY(comparison_lock_); | 1071 test::Statistics send_bandwidth_bps_ GUARDED_BY(comparison_lock_); |
| 1041 test::Statistics memory_usage_ GUARDED_BY(comparison_lock_); | 1072 test::Statistics memory_usage_ GUARDED_BY(comparison_lock_); |
| 1073 rtc::Optional<double> min_psnr_ GUARDED_BY(comparison_lock_); | |
| 1074 rtc::Optional<VideoFrame> bad_frame_ GUARDED_BY(comparison_lock_); | |
|
sprang_webrtc
2017/07/24 14:24:09
Maybe you could make a struct for these two instea
ilnik
2017/07/25 10:34:54
Done.
| |
| 1042 | 1075 |
| 1043 size_t last_fec_bytes_; | 1076 size_t last_fec_bytes_; |
| 1044 | 1077 |
| 1045 const int frames_to_process_; | 1078 const int frames_to_process_; |
| 1046 int frames_recorded_; | 1079 int frames_recorded_; |
| 1047 int frames_processed_; | 1080 int frames_processed_; |
| 1048 int dropped_frames_; | 1081 int dropped_frames_; |
| 1049 int dropped_frames_before_first_encode_; | 1082 int dropped_frames_before_first_encode_; |
| 1050 int dropped_frames_before_rendering_; | 1083 int dropped_frames_before_rendering_; |
| 1051 int64_t last_render_time_; | 1084 int64_t last_render_time_; |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2082 if (!params_.logging.encoded_frame_base_path.empty()) { | 2115 if (!params_.logging.encoded_frame_base_path.empty()) { |
| 2083 std::ostringstream str; | 2116 std::ostringstream str; |
| 2084 str << receive_logs_++; | 2117 str << receive_logs_++; |
| 2085 std::string path = | 2118 std::string path = |
| 2086 params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; | 2119 params_.logging.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; |
| 2087 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), | 2120 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), |
| 2088 100000000); | 2121 100000000); |
| 2089 } | 2122 } |
| 2090 } | 2123 } |
| 2091 } // namespace webrtc | 2124 } // namespace webrtc |
| OLD | NEW |