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

Side by Side Diff: webrtc/video/video_quality_test.cc

Issue 2640263002: Add metric for decode time and max decode time in video quality tests. (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | 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) 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 const std::string& test_label, 130 const std::string& test_label,
131 double avg_psnr_threshold, 131 double avg_psnr_threshold,
132 double avg_ssim_threshold, 132 double avg_ssim_threshold,
133 int duration_frames, 133 int duration_frames,
134 FILE* graph_data_output_file, 134 FILE* graph_data_output_file,
135 const std::string& graph_title, 135 const std::string& graph_title,
136 uint32_t ssrc_to_analyze) 136 uint32_t ssrc_to_analyze)
137 : transport_(transport), 137 : transport_(transport),
138 receiver_(nullptr), 138 receiver_(nullptr),
139 send_stream_(nullptr), 139 send_stream_(nullptr),
140 receive_stream_(nullptr),
140 captured_frame_forwarder_(this), 141 captured_frame_forwarder_(this),
141 test_label_(test_label), 142 test_label_(test_label),
142 graph_data_output_file_(graph_data_output_file), 143 graph_data_output_file_(graph_data_output_file),
143 graph_title_(graph_title), 144 graph_title_(graph_title),
144 ssrc_to_analyze_(ssrc_to_analyze), 145 ssrc_to_analyze_(ssrc_to_analyze),
145 pre_encode_proxy_(this), 146 pre_encode_proxy_(this),
146 encode_timing_proxy_(this), 147 encode_timing_proxy_(this),
147 frames_to_process_(duration_frames), 148 frames_to_process_(duration_frames),
148 frames_recorded_(0), 149 frames_recorded_(0),
149 frames_processed_(0), 150 frames_processed_(0),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 193 }
193 194
194 virtual void SetReceiver(PacketReceiver* receiver) { receiver_ = receiver; } 195 virtual void SetReceiver(PacketReceiver* receiver) { receiver_ = receiver; }
195 196
196 void SetSendStream(VideoSendStream* stream) { 197 void SetSendStream(VideoSendStream* stream) {
197 rtc::CritScope lock(&crit_); 198 rtc::CritScope lock(&crit_);
198 RTC_DCHECK(!send_stream_); 199 RTC_DCHECK(!send_stream_);
199 send_stream_ = stream; 200 send_stream_ = stream;
200 } 201 }
201 202
203 void SetReceiveStream(VideoReceiveStream* stream) {
204 rtc::CritScope lock(&crit_);
205 RTC_DCHECK(!receive_stream_);
206 receive_stream_ = stream;
207 }
208
202 rtc::VideoSinkInterface<VideoFrame>* InputInterface() { 209 rtc::VideoSinkInterface<VideoFrame>* InputInterface() {
203 return &captured_frame_forwarder_; 210 return &captured_frame_forwarder_;
204 } 211 }
205 rtc::VideoSourceInterface<VideoFrame>* OutputInterface() { 212 rtc::VideoSourceInterface<VideoFrame>* OutputInterface() {
206 return &captured_frame_forwarder_; 213 return &captured_frame_forwarder_;
207 } 214 }
208 215
209 DeliveryStatus DeliverPacket(MediaType media_type, 216 DeliveryStatus DeliverPacket(MediaType media_type,
210 const uint8_t* packet, 217 const uint8_t* packet,
211 size_t length, 218 size_t length,
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 } 532 }
526 533
527 static bool PollStatsThread(void* obj) { 534 static bool PollStatsThread(void* obj) {
528 return static_cast<VideoAnalyzer*>(obj)->PollStats(); 535 return static_cast<VideoAnalyzer*>(obj)->PollStats();
529 } 536 }
530 537
531 bool PollStats() { 538 bool PollStats() {
532 if (done_.Wait(kSendStatsPollingIntervalMs)) 539 if (done_.Wait(kSendStatsPollingIntervalMs))
533 return false; 540 return false;
534 541
535 VideoSendStream::Stats stats = send_stream_->GetStats(); 542 rtc::CritScope crit(&comparison_lock_);
sprang_webrtc 2017/01/19 12:09:30 Why move the lock to include getting the send stat
philipel 2017/01/19 15:11:39 I did it to avoid one null check. If we get the st
536 543
537 rtc::CritScope crit(&comparison_lock_); 544 VideoSendStream::Stats send_stats = send_stream_->GetStats();
538 // It's not certain that we yet have estimates for any of these stats. Check 545 // It's not certain that we yet have estimates for any of these stats. Check
539 // that they are positive before mixing them in. 546 // that they are positive before mixing them in.
540 if (stats.encode_frame_rate > 0) 547 if (send_stats.encode_frame_rate > 0)
541 encode_frame_rate_.AddSample(stats.encode_frame_rate); 548 encode_frame_rate_.AddSample(send_stats.encode_frame_rate);
542 if (stats.avg_encode_time_ms > 0) 549 if (send_stats.avg_encode_time_ms > 0)
543 encode_time_ms.AddSample(stats.avg_encode_time_ms); 550 encode_time_ms_.AddSample(send_stats.avg_encode_time_ms);
544 if (stats.encode_usage_percent > 0) 551 if (send_stats.encode_usage_percent > 0)
545 encode_usage_percent.AddSample(stats.encode_usage_percent); 552 encode_usage_percent_.AddSample(send_stats.encode_usage_percent);
546 if (stats.media_bitrate_bps > 0) 553 if (send_stats.media_bitrate_bps > 0)
547 media_bitrate_bps.AddSample(stats.media_bitrate_bps); 554 media_bitrate_bps_.AddSample(send_stats.media_bitrate_bps);
555
556 if (receive_stream_ != nullptr) {
557 VideoReceiveStream::Stats receive_stats = receive_stream_->GetStats();
558 if (receive_stats.decode_ms > 0)
559 decode_time_ms_.AddSample(receive_stats.decode_ms);
560 if (receive_stats.max_decode_ms > 0)
561 decode_time_max_ms_.AddSample(receive_stats.max_decode_ms);
562 }
548 563
549 return true; 564 return true;
550 } 565 }
551 566
552 static bool FrameComparisonThread(void* obj) { 567 static bool FrameComparisonThread(void* obj) {
553 return static_cast<VideoAnalyzer*>(obj)->CompareFrames(); 568 return static_cast<VideoAnalyzer*>(obj)->CompareFrames();
554 } 569 }
555 570
556 bool CompareFrames() { 571 bool CompareFrames() {
557 if (AllFramesRecorded()) 572 if (AllFramesRecorded())
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 void PrintResults() { 641 void PrintResults() {
627 rtc::CritScope crit(&comparison_lock_); 642 rtc::CritScope crit(&comparison_lock_);
628 PrintResult("psnr", psnr_, " dB"); 643 PrintResult("psnr", psnr_, " dB");
629 PrintResult("ssim", ssim_, " score"); 644 PrintResult("ssim", ssim_, " score");
630 PrintResult("sender_time", sender_time_, " ms"); 645 PrintResult("sender_time", sender_time_, " ms");
631 PrintResult("receiver_time", receiver_time_, " ms"); 646 PrintResult("receiver_time", receiver_time_, " ms");
632 PrintResult("total_delay_incl_network", end_to_end_, " ms"); 647 PrintResult("total_delay_incl_network", end_to_end_, " ms");
633 PrintResult("time_between_rendered_frames", rendered_delta_, " ms"); 648 PrintResult("time_between_rendered_frames", rendered_delta_, " ms");
634 PrintResult("encoded_frame_size", encoded_frame_size_, " bytes"); 649 PrintResult("encoded_frame_size", encoded_frame_size_, " bytes");
635 PrintResult("encode_frame_rate", encode_frame_rate_, " fps"); 650 PrintResult("encode_frame_rate", encode_frame_rate_, " fps");
636 PrintResult("encode_time", encode_time_ms, " ms"); 651 PrintResult("encode_time", encode_time_ms_, " ms");
637 PrintResult("encode_usage_percent", encode_usage_percent, " percent"); 652 PrintResult("encode_usage_percent", encode_usage_percent_, " percent");
638 PrintResult("media_bitrate", media_bitrate_bps, " bps"); 653 PrintResult("media_bitrate", media_bitrate_bps_, " bps");
654
655 if (receive_stream_ != nullptr) {
656 PrintResult("decode_time", decode_time_ms_, " ms");
657 PrintResult("decode_time_max", decode_time_max_ms_, " ms");
658 }
639 659
640 printf("RESULT dropped_frames: %s = %d frames\n", test_label_.c_str(), 660 printf("RESULT dropped_frames: %s = %d frames\n", test_label_.c_str(),
641 dropped_frames_); 661 dropped_frames_);
642 printf("RESULT dropped_frames_before_first_encode: %s = %d frames\n", 662 printf("RESULT dropped_frames_before_first_encode: %s = %d frames\n",
643 test_label_.c_str(), dropped_frames_before_first_encode_); 663 test_label_.c_str(), dropped_frames_before_first_encode_);
644 printf("RESULT dropped_frames_before_rendering: %s = %d frames\n", 664 printf("RESULT dropped_frames_before_rendering: %s = %d frames\n",
645 test_label_.c_str(), dropped_frames_before_rendering_); 665 test_label_.c_str(), dropped_frames_before_rendering_);
646 666
647 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_); 667 EXPECT_GT(psnr_.Mean(), avg_psnr_threshold_);
648 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_); 668 EXPECT_GT(ssim_.Mean(), avg_ssim_threshold_);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 rtc::CritScope lock(&crit_); 819 rtc::CritScope lock(&crit_);
800 RTC_DCHECK_EQ(0, video_frame.timestamp()); 820 RTC_DCHECK_EQ(0, video_frame.timestamp());
801 // Frames from the capturer does not have a rtp timestamp. Create one so it 821 // Frames from the capturer does not have a rtp timestamp. Create one so it
802 // can be used for comparison. 822 // can be used for comparison.
803 VideoFrame copy = video_frame; 823 VideoFrame copy = video_frame;
804 copy.set_timestamp(copy.ntp_time_ms() * 90); 824 copy.set_timestamp(copy.ntp_time_ms() * 90);
805 frames_.push_back(copy); 825 frames_.push_back(copy);
806 } 826 }
807 827
808 VideoSendStream* send_stream_; 828 VideoSendStream* send_stream_;
829 VideoReceiveStream* receive_stream_;
809 CapturedFrameForwarder captured_frame_forwarder_; 830 CapturedFrameForwarder captured_frame_forwarder_;
810 const std::string test_label_; 831 const std::string test_label_;
811 FILE* const graph_data_output_file_; 832 FILE* const graph_data_output_file_;
812 const std::string graph_title_; 833 const std::string graph_title_;
813 const uint32_t ssrc_to_analyze_; 834 const uint32_t ssrc_to_analyze_;
814 PreEncodeProxy pre_encode_proxy_; 835 PreEncodeProxy pre_encode_proxy_;
815 OnEncodeTimingProxy encode_timing_proxy_; 836 OnEncodeTimingProxy encode_timing_proxy_;
816 std::vector<Sample> samples_ GUARDED_BY(comparison_lock_); 837 std::vector<Sample> samples_ GUARDED_BY(comparison_lock_);
817 std::map<int64_t, int> samples_encode_time_ms_ GUARDED_BY(comparison_lock_); 838 std::map<int64_t, int> samples_encode_time_ms_ GUARDED_BY(comparison_lock_);
818 test::Statistics sender_time_ GUARDED_BY(comparison_lock_); 839 test::Statistics sender_time_ GUARDED_BY(comparison_lock_);
819 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_); 840 test::Statistics receiver_time_ GUARDED_BY(comparison_lock_);
820 test::Statistics psnr_ GUARDED_BY(comparison_lock_); 841 test::Statistics psnr_ GUARDED_BY(comparison_lock_);
821 test::Statistics ssim_ GUARDED_BY(comparison_lock_); 842 test::Statistics ssim_ GUARDED_BY(comparison_lock_);
822 test::Statistics end_to_end_ GUARDED_BY(comparison_lock_); 843 test::Statistics end_to_end_ GUARDED_BY(comparison_lock_);
823 test::Statistics rendered_delta_ GUARDED_BY(comparison_lock_); 844 test::Statistics rendered_delta_ GUARDED_BY(comparison_lock_);
824 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_); 845 test::Statistics encoded_frame_size_ GUARDED_BY(comparison_lock_);
825 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_); 846 test::Statistics encode_frame_rate_ GUARDED_BY(comparison_lock_);
826 test::Statistics encode_time_ms GUARDED_BY(comparison_lock_); 847 test::Statistics encode_time_ms_ GUARDED_BY(comparison_lock_);
827 test::Statistics encode_usage_percent GUARDED_BY(comparison_lock_); 848 test::Statistics encode_usage_percent_ GUARDED_BY(comparison_lock_);
828 test::Statistics media_bitrate_bps GUARDED_BY(comparison_lock_); 849 test::Statistics decode_time_ms_ GUARDED_BY(comparison_lock_);
850 test::Statistics decode_time_max_ms_ GUARDED_BY(comparison_lock_);
851 test::Statistics media_bitrate_bps_ GUARDED_BY(comparison_lock_);
829 852
830 const int frames_to_process_; 853 const int frames_to_process_;
831 int frames_recorded_; 854 int frames_recorded_;
832 int frames_processed_; 855 int frames_processed_;
833 int dropped_frames_; 856 int dropped_frames_;
834 int dropped_frames_before_first_encode_; 857 int dropped_frames_before_first_encode_;
835 int dropped_frames_before_rendering_; 858 int dropped_frames_before_rendering_;
836 int64_t last_render_time_; 859 int64_t last_render_time_;
837 uint32_t rtp_timestamp_delta_; 860 uint32_t rtp_timestamp_delta_;
838 861
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 config.pre_decode_callback = &analyzer; 1325 config.pre_decode_callback = &analyzer;
1303 RTC_DCHECK(!video_send_config_.post_encode_callback); 1326 RTC_DCHECK(!video_send_config_.post_encode_callback);
1304 video_send_config_.post_encode_callback = analyzer.encode_timing_proxy(); 1327 video_send_config_.post_encode_callback = analyzer.encode_timing_proxy();
1305 1328
1306 if (params_.screenshare.enabled) 1329 if (params_.screenshare.enabled)
1307 SetupScreenshare(); 1330 SetupScreenshare();
1308 1331
1309 CreateFlexfecStreams(); 1332 CreateFlexfecStreams();
1310 CreateVideoStreams(); 1333 CreateVideoStreams();
1311 analyzer.SetSendStream(video_send_stream_); 1334 analyzer.SetSendStream(video_send_stream_);
1335 if (video_receive_streams_.size() == 1)
1336 analyzer.SetReceiveStream(video_receive_streams_[0]);
1312 video_send_stream_->SetSource( 1337 video_send_stream_->SetSource(
1313 analyzer.OutputInterface(), 1338 analyzer.OutputInterface(),
1314 VideoSendStream::DegradationPreference::kBalanced); 1339 VideoSendStream::DegradationPreference::kBalanced);
1315 1340
1316 CreateCapturer(); 1341 CreateCapturer();
1317 rtc::VideoSinkWants wants; 1342 rtc::VideoSinkWants wants;
1318 video_capturer_->AddOrUpdateSink(analyzer.InputInterface(), wants); 1343 video_capturer_->AddOrUpdateSink(analyzer.InputInterface(), wants);
1319 1344
1320 StartEncodedFrameLogs(video_send_stream_); 1345 StartEncodedFrameLogs(video_send_stream_);
1321 StartEncodedFrameLogs(video_receive_streams_[0]); 1346 StartEncodedFrameLogs(video_receive_streams_[0]);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 std::ostringstream str; 1562 std::ostringstream str;
1538 str << receive_logs_++; 1563 str << receive_logs_++;
1539 std::string path = 1564 std::string path =
1540 params_.video.encoded_frame_base_path + "." + str.str() + ".recv.ivf"; 1565 params_.video.encoded_frame_base_path + "." + str.str() + ".recv.ivf";
1541 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path), 1566 stream->EnableEncodedFrameRecording(rtc::CreatePlatformFile(path),
1542 10000000); 1567 10000000);
1543 } 1568 }
1544 } 1569 }
1545 1570
1546 } // namespace webrtc 1571 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698