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

Unified Diff: webrtc/video/video_quality_test.cc

Issue 1600973002: Initialize VideoEncoder objects asynchronously. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/video/video_quality_test.cc
diff --git a/webrtc/video/video_quality_test.cc b/webrtc/video/video_quality_test.cc
index 08ae0a9cee420241bf41084c32883405e184abef..597faf02c2b7d15c47af0892d4a9035e1eda7f38 100644
--- a/webrtc/video/video_quality_test.cc
+++ b/webrtc/video/video_quality_test.cc
@@ -42,6 +42,7 @@ static const int kPayloadTypeVP9 = 124;
class VideoAnalyzer : public PacketReceiver,
public Transport,
+ public I420FrameCallback,
public VideoRenderer,
public VideoCaptureInput,
public EncodedFrameObserver,
@@ -67,6 +68,7 @@ class VideoAnalyzer : public PacketReceiver,
frames_recorded_(0),
frames_processed_(0),
dropped_frames_(0),
+ frames_dropped_before_first_encode_(0),
last_render_time_(0),
rtp_timestamp_delta_(0),
avg_psnr_threshold_(avg_psnr_threshold),
@@ -135,18 +137,26 @@ class VideoAnalyzer : public PacketReceiver,
void IncomingCapturedFrame(const VideoFrame& video_frame) override {
VideoFrame copy = video_frame;
copy.set_timestamp(copy.ntp_time_ms() * 90);
-
{
rtc::CritScope lock(&crit_);
- if (first_send_frame_.IsZeroSize() && rtp_timestamp_delta_ == 0)
- first_send_frame_ = copy;
-
frames_.push_back(copy);
}
input_->IncomingCapturedFrame(video_frame);
}
+ void FrameCallback(VideoFrame* video_frame) {
+ rtc::CritScope lock(&crit_);
+ if (first_send_frame_.IsZeroSize() && rtp_timestamp_delta_ == 0) {
+ while (frames_.front().timestamp() != video_frame->timestamp()) {
+ ++frames_dropped_before_first_encode_;
+ frames_.pop_front();
+ RTC_CHECK(!frames_.empty());
+ }
+ first_send_frame_ = *video_frame;
+ }
+ }
+
bool SendRtp(const uint8_t* packet,
size_t length,
const PacketOptions& options) override {
@@ -159,7 +169,7 @@ class VideoAnalyzer : public PacketReceiver,
bool result = transport_->SendRtp(packet, length, options);
{
rtc::CritScope lock(&crit_);
- if (rtp_timestamp_delta_ == 0) {
+ if (!first_send_frame_.IsZeroSize()) {
rtp_timestamp_delta_ = header.timestamp - first_send_frame_.timestamp();
first_send_frame_.Reset();
}
@@ -192,10 +202,11 @@ class VideoAnalyzer : public PacketReceiver,
rtc::CritScope lock(&crit_);
- while (frames_.front().timestamp() < send_timestamp) {
+ while (frames_.front().timestamp() != send_timestamp) {
AddFrameComparison(frames_.front(), last_rendered_frame_, true,
render_time_ms);
frames_.pop_front();
+ RTC_DCHECK(!frames_.empty());
}
VideoFrame reference_frame = frames_.front();
@@ -329,6 +340,7 @@ class VideoAnalyzer : public PacketReceiver,
bool dropped,
int64_t render_time_ms)
EXCLUSIVE_LOCKS_REQUIRED(crit_) {
+ RTC_CHECK(!render.IsZeroSize());
int64_t send_time_ms = send_times_[reference.timestamp()];
send_times_.erase(reference.timestamp());
int64_t recv_time_ms = recv_times_[reference.timestamp()];
@@ -460,6 +472,8 @@ class VideoAnalyzer : public PacketReceiver,
PrintResult("sender_time", sender_time_, " ms");
printf("RESULT dropped_frames: %s = %d frames\n", test_label_.c_str(),
dropped_frames_);
+ printf("RESULT frames_dropped_before_first_encode: %s = %d frames\n",
+ test_label_.c_str(), frames_dropped_before_first_encode_);
PrintResult("receiver_time", receiver_time_, " ms");
PrintResult("total_delay_incl_network", end_to_end_, " ms");
PrintResult("time_between_rendered_frames", rendered_delta_, " ms");
@@ -582,6 +596,7 @@ class VideoAnalyzer : public PacketReceiver,
int frames_recorded_;
int frames_processed_;
int dropped_frames_;
+ int frames_dropped_before_first_encode_;
int64_t last_render_time_;
uint32_t rtp_timestamp_delta_;
@@ -972,6 +987,7 @@ void VideoQualityTest::RunWithAnalyzer(const Params& params) {
SetupCommon(&analyzer, &recv_transport);
video_send_config_.encoding_time_observer = &analyzer;
+ video_send_config_.pre_encode_callback = &analyzer;
video_receive_configs_[params_.ss.selected_stream].renderer = &analyzer;
for (auto& config : video_receive_configs_)
config.pre_decode_callback = &analyzer;

Powered by Google App Engine
This is Rietveld 408576698