| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 comparison_available_event_(false, false), | 150 comparison_available_event_(false, false), |
| 151 done_(true, false) { | 151 done_(true, false) { |
| 152 // Create thread pool for CPU-expensive PSNR/SSIM calculations. | 152 // Create thread pool for CPU-expensive PSNR/SSIM calculations. |
| 153 | 153 |
| 154 // Try to use about as many threads as cores, but leave kMinCoresLeft alone, | 154 // Try to use about as many threads as cores, but leave kMinCoresLeft alone, |
| 155 // so that we don't accidentally starve "real" worker threads (codec etc). | 155 // so that we don't accidentally starve "real" worker threads (codec etc). |
| 156 // Also, don't allocate more than kMaxComparisonThreads, even if there are | 156 // Also, don't allocate more than kMaxComparisonThreads, even if there are |
| 157 // spare cores. | 157 // spare cores. |
| 158 | 158 |
| 159 uint32_t num_cores = CpuInfo::DetectNumberOfCores(); | 159 uint32_t num_cores = CpuInfo::DetectNumberOfCores(); |
| 160 RTC_DCHECK_GE(num_cores, 1u); | 160 RTC_DCHECK_GE(num_cores, 1); |
| 161 static const uint32_t kMinCoresLeft = 4; | 161 static const uint32_t kMinCoresLeft = 4; |
| 162 static const uint32_t kMaxComparisonThreads = 8; | 162 static const uint32_t kMaxComparisonThreads = 8; |
| 163 | 163 |
| 164 if (num_cores <= kMinCoresLeft) { | 164 if (num_cores <= kMinCoresLeft) { |
| 165 num_cores = 1; | 165 num_cores = 1; |
| 166 } else { | 166 } else { |
| 167 num_cores -= kMinCoresLeft; | 167 num_cores -= kMinCoresLeft; |
| 168 num_cores = std::min(num_cores, kMaxComparisonThreads); | 168 num_cores = std::min(num_cores, kMaxComparisonThreads); |
| 169 } | 169 } |
| 170 | 170 |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 send_stream_input_ = nullptr; | 750 send_stream_input_ = nullptr; |
| 751 } | 751 } |
| 752 | 752 |
| 753 VideoAnalyzer* const analyzer_; | 753 VideoAnalyzer* const analyzer_; |
| 754 rtc::CriticalSection crit_; | 754 rtc::CriticalSection crit_; |
| 755 rtc::VideoSinkInterface<VideoFrame>* send_stream_input_ GUARDED_BY(crit_); | 755 rtc::VideoSinkInterface<VideoFrame>* send_stream_input_ GUARDED_BY(crit_); |
| 756 }; | 756 }; |
| 757 | 757 |
| 758 void AddCapturedFrameForComparison(const VideoFrame& video_frame) { | 758 void AddCapturedFrameForComparison(const VideoFrame& video_frame) { |
| 759 rtc::CritScope lock(&crit_); | 759 rtc::CritScope lock(&crit_); |
| 760 RTC_DCHECK_EQ(0u, video_frame.timestamp()); | 760 RTC_DCHECK_EQ(0, video_frame.timestamp()); |
| 761 // Frames from the capturer does not have a rtp timestamp. Create one so it | 761 // Frames from the capturer does not have a rtp timestamp. Create one so it |
| 762 // can be used for comparison. | 762 // can be used for comparison. |
| 763 VideoFrame copy = video_frame; | 763 VideoFrame copy = video_frame; |
| 764 copy.set_timestamp(copy.ntp_time_ms() * 90); | 764 copy.set_timestamp(copy.ntp_time_ms() * 90); |
| 765 frames_.push_back(copy); | 765 frames_.push_back(copy); |
| 766 } | 766 } |
| 767 | 767 |
| 768 VideoSendStream* send_stream_; | 768 VideoSendStream* send_stream_; |
| 769 CapturedFrameForwarder captured_frame_forwarder_; | 769 CapturedFrameForwarder captured_frame_forwarder_; |
| 770 const std::string test_label_; | 770 const std::string test_label_; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 // the total bitrate? We anyway have to update them in the case bitrate | 884 // the total bitrate? We anyway have to update them in the case bitrate |
| 885 // estimator changes the total bitrates. | 885 // estimator changes the total bitrates. |
| 886 RTC_CHECK_GE(params_.ss.num_spatial_layers, 1); | 886 RTC_CHECK_GE(params_.ss.num_spatial_layers, 1); |
| 887 RTC_CHECK_LE(params_.ss.selected_sl, params_.ss.num_spatial_layers); | 887 RTC_CHECK_LE(params_.ss.selected_sl, params_.ss.num_spatial_layers); |
| 888 RTC_CHECK(params_.ss.spatial_layers.empty() || | 888 RTC_CHECK(params_.ss.spatial_layers.empty() || |
| 889 params_.ss.spatial_layers.size() == | 889 params_.ss.spatial_layers.size() == |
| 890 static_cast<size_t>(params_.ss.num_spatial_layers)); | 890 static_cast<size_t>(params_.ss.num_spatial_layers)); |
| 891 if (params_.video.codec == "VP8") { | 891 if (params_.video.codec == "VP8") { |
| 892 RTC_CHECK_EQ(params_.ss.num_spatial_layers, 1); | 892 RTC_CHECK_EQ(params_.ss.num_spatial_layers, 1); |
| 893 } else if (params_.video.codec == "VP9") { | 893 } else if (params_.video.codec == "VP9") { |
| 894 RTC_CHECK_EQ(params_.ss.streams.size(), 1u); | 894 RTC_CHECK_EQ(params_.ss.streams.size(), 1); |
| 895 } | 895 } |
| 896 } | 896 } |
| 897 | 897 |
| 898 // Static. | 898 // Static. |
| 899 std::vector<int> VideoQualityTest::ParseCSV(const std::string& str) { | 899 std::vector<int> VideoQualityTest::ParseCSV(const std::string& str) { |
| 900 // Parse comma separated nonnegative integers, where some elements may be | 900 // Parse comma separated nonnegative integers, where some elements may be |
| 901 // empty. The empty values are replaced with -1. | 901 // empty. The empty values are replaced with -1. |
| 902 // E.g. "10,-20,,30,40" --> {10, 20, -1, 30,40} | 902 // E.g. "10,-20,,30,40" --> {10, 20, -1, 30,40} |
| 903 // E.g. ",,10,,20," --> {-1, -1, 10, -1, 20, -1} | 903 // E.g. ",,10,,20," --> {-1, -1, 10, -1, 20, -1} |
| 904 std::vector<int> result; | 904 std::vector<int> result; |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 std::ostringstream str; | 1485 std::ostringstream str; |
| 1486 str << receive_logs_++; | 1486 str << receive_logs_++; |
| 1487 std::string path = | 1487 std::string path = |
| 1488 params_.video.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; | 1488 params_.video.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; |
| 1489 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), | 1489 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), |
| 1490 10000000); | 1490 10000000); |
| 1491 } | 1491 } |
| 1492 } | 1492 } |
| 1493 | 1493 |
| 1494 } // namespace webrtc | 1494 } // namespace webrtc |
| OLD | NEW |