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

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

Issue 1569853002: Measure encoding time on encode callbacks. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: feedback Created 4 years, 10 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) 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 <stdio.h> 10 #include <stdio.h>
(...skipping 26 matching lines...) Expand all
37 namespace webrtc { 37 namespace webrtc {
38 38
39 static const int kSendStatsPollingIntervalMs = 1000; 39 static const int kSendStatsPollingIntervalMs = 1000;
40 static const int kPayloadTypeVP8 = 123; 40 static const int kPayloadTypeVP8 = 123;
41 static const int kPayloadTypeVP9 = 124; 41 static const int kPayloadTypeVP9 = 124;
42 42
43 class VideoAnalyzer : public PacketReceiver, 43 class VideoAnalyzer : public PacketReceiver,
44 public Transport, 44 public Transport,
45 public VideoRenderer, 45 public VideoRenderer,
46 public VideoCaptureInput, 46 public VideoCaptureInput,
47 public EncodedFrameObserver, 47 public EncodedFrameObserver {
48 public EncodingTimeObserver {
49 public: 48 public:
50 VideoAnalyzer(test::LayerFilteringTransport* transport, 49 VideoAnalyzer(test::LayerFilteringTransport* transport,
51 const std::string& test_label, 50 const std::string& test_label,
52 double avg_psnr_threshold, 51 double avg_psnr_threshold,
53 double avg_ssim_threshold, 52 double avg_ssim_threshold,
54 int duration_frames, 53 int duration_frames,
55 FILE* graph_data_output_file, 54 FILE* graph_data_output_file,
56 const std::string& graph_title, 55 const std::string& graph_title,
57 uint32_t ssrc_to_analyze) 56 uint32_t ssrc_to_analyze)
58 : input_(nullptr), 57 : input_(nullptr),
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 parser.Parse(&header); 118 parser.Parse(&header);
120 { 119 {
121 rtc::CritScope lock(&crit_); 120 rtc::CritScope lock(&crit_);
122 recv_times_[header.timestamp - rtp_timestamp_delta_] = 121 recv_times_[header.timestamp - rtp_timestamp_delta_] =
123 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds(); 122 Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
124 } 123 }
125 124
126 return receiver_->DeliverPacket(media_type, packet, length, packet_time); 125 return receiver_->DeliverPacket(media_type, packet, length, packet_time);
127 } 126 }
128 127
129 // EncodingTimeObserver. 128 void OnEncodeTiming(int64_t ntp_time_ms, int encode_time_ms) override {
130 void OnReportEncodedTime(int64_t ntp_time_ms, int encode_time_ms) override {
131 rtc::CritScope crit(&comparison_lock_); 129 rtc::CritScope crit(&comparison_lock_);
132 samples_encode_time_ms_[ntp_time_ms] = encode_time_ms; 130 samples_encode_time_ms_[ntp_time_ms] = encode_time_ms;
133 } 131 }
134 132
135 void IncomingCapturedFrame(const VideoFrame& video_frame) override { 133 void IncomingCapturedFrame(const VideoFrame& video_frame) override {
136 VideoFrame copy = video_frame; 134 VideoFrame copy = video_frame;
137 copy.set_timestamp(copy.ntp_time_ms() * 90); 135 copy.set_timestamp(copy.ntp_time_ms() * 90);
138 136
139 { 137 {
140 rtc::CritScope lock(&crit_); 138 rtc::CritScope lock(&crit_);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 AddFrameComparison(frames_.front(), last_rendered_frame_, true, 194 AddFrameComparison(frames_.front(), last_rendered_frame_, true,
197 render_time_ms); 195 render_time_ms);
198 frames_.pop_front(); 196 frames_.pop_front();
199 } 197 }
200 198
201 VideoFrame reference_frame = frames_.front(); 199 VideoFrame reference_frame = frames_.front();
202 frames_.pop_front(); 200 frames_.pop_front();
203 assert(!reference_frame.IsZeroSize()); 201 assert(!reference_frame.IsZeroSize());
204 if (send_timestamp == reference_frame.timestamp() - 1) { 202 if (send_timestamp == reference_frame.timestamp() - 1) {
205 // TODO(ivica): Make this work for > 2 streams. 203 // TODO(ivica): Make this work for > 2 streams.
206 // Look at rtp_sender.c:RTPSender::BuildRTPHeader. 204 // Look at RTPSender::BuildRTPHeader.
207 ++send_timestamp; 205 ++send_timestamp;
208 } 206 }
209 EXPECT_EQ(reference_frame.timestamp(), send_timestamp); 207 EXPECT_EQ(reference_frame.timestamp(), send_timestamp);
210 assert(reference_frame.timestamp() == send_timestamp); 208 assert(reference_frame.timestamp() == send_timestamp);
211 209
212 AddFrameComparison(reference_frame, video_frame, false, render_time_ms); 210 AddFrameComparison(reference_frame, video_frame, false, render_time_ms);
213 211
214 last_rendered_frame_ = video_frame; 212 last_rendered_frame_ = video_frame;
215 } 213 }
216 214
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 disable_quality_check ? -1.1 : params_.analyzer.avg_ssim_threshold, 958 disable_quality_check ? -1.1 : params_.analyzer.avg_ssim_threshold,
961 params_.analyzer.test_durations_secs * params_.common.fps, 959 params_.analyzer.test_durations_secs * params_.common.fps,
962 graph_data_output_file, graph_title, 960 graph_data_output_file, graph_title,
963 kVideoSendSsrcs[params_.ss.selected_stream]); 961 kVideoSendSsrcs[params_.ss.selected_stream]);
964 962
965 analyzer.SetReceiver(receiver_call_->Receiver()); 963 analyzer.SetReceiver(receiver_call_->Receiver());
966 send_transport.SetReceiver(&analyzer); 964 send_transport.SetReceiver(&analyzer);
967 recv_transport.SetReceiver(sender_call_->Receiver()); 965 recv_transport.SetReceiver(sender_call_->Receiver());
968 966
969 SetupCommon(&analyzer, &recv_transport); 967 SetupCommon(&analyzer, &recv_transport);
970 video_send_config_.encoding_time_observer = &analyzer;
971 video_receive_configs_[params_.ss.selected_stream].renderer = &analyzer; 968 video_receive_configs_[params_.ss.selected_stream].renderer = &analyzer;
972 for (auto& config : video_receive_configs_) 969 for (auto& config : video_receive_configs_)
973 config.pre_decode_callback = &analyzer; 970 config.pre_decode_callback = &analyzer;
974 971
975 if (params_.screenshare.enabled) 972 if (params_.screenshare.enabled)
976 SetupScreenshare(); 973 SetupScreenshare();
977 974
978 CreateVideoStreams(); 975 CreateVideoStreams();
979 analyzer.input_ = video_send_stream_->Input(); 976 analyzer.input_ = video_send_stream_->Input();
980 analyzer.send_stream_ = video_send_stream_; 977 analyzer.send_stream_ = video_send_stream_;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 video_send_stream_->Stop(); 1057 video_send_stream_->Stop();
1061 receive_stream->Stop(); 1058 receive_stream->Stop();
1062 1059
1063 call->DestroyVideoReceiveStream(receive_stream); 1060 call->DestroyVideoReceiveStream(receive_stream);
1064 call->DestroyVideoSendStream(video_send_stream_); 1061 call->DestroyVideoSendStream(video_send_stream_);
1065 1062
1066 transport.StopSending(); 1063 transport.StopSending();
1067 } 1064 }
1068 1065
1069 } // namespace webrtc 1066 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698