Chromium Code Reviews

Unified Diff: webrtc/video/video_quality_test.cc

Issue 2709483009: Fixed Full stack tests to correctly process selected TL and SL while (Closed)
Patch Set: fixing mistake where important code is inside DCHECK Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/video/video_quality_test.cc
diff --git a/webrtc/video/video_quality_test.cc b/webrtc/video/video_quality_test.cc
index b754d295485342a208420502be117e28ab1ee87e..756906cca5e44c37d9cf89daf652d0c25d823d66 100644
--- a/webrtc/video/video_quality_test.cc
+++ b/webrtc/video/video_quality_test.cc
@@ -28,6 +28,7 @@
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
#include "webrtc/modules/audio_mixer/audio_mixer_impl.h"
#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
+#include "webrtc/modules/rtp_rtcp/source/rtp_format.h"
#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
@@ -139,6 +140,8 @@ class VideoAnalyzer : public PacketReceiver,
uint32_t rtx_ssrc_to_analyze,
uint32_t selected_stream_width,
uint32_t selected_stream_height,
+ int selected_sl,
+ int selected_tl,
bool is_quick_test_enabled)
: transport_(transport),
receiver_(nullptr),
@@ -152,6 +155,8 @@ class VideoAnalyzer : public PacketReceiver,
rtx_ssrc_to_analyze_(rtx_ssrc_to_analyze),
selected_stream_width_(selected_stream_width),
selected_stream_height_(selected_stream_height),
+ selected_sl_(selected_sl),
+ selected_tl_(selected_tl),
pre_encode_proxy_(this),
encode_timing_proxy_(this),
frames_to_process_(duration_frames),
@@ -162,6 +167,9 @@ class VideoAnalyzer : public PacketReceiver,
dropped_frames_before_rendering_(0),
last_render_time_(0),
rtp_timestamp_delta_(0),
+ total_media_bytes_(0),
+ first_sending_time_(0),
+ last_sending_time_(0),
avg_psnr_threshold_(avg_psnr_threshold),
avg_ssim_threshold_(avg_ssim_threshold),
is_quick_test_enabled_(is_quick_test_enabled),
@@ -305,11 +313,44 @@ class VideoAnalyzer : public PacketReceiver,
int64_t timestamp =
wrap_handler_.Unwrap(header.timestamp - rtp_timestamp_delta_);
send_times_[timestamp] = current_time;
- if (!transport_->DiscardedLastPacket() &&
- header.ssrc == ssrc_to_analyze_) {
+
+ // Ignore incorrect temporal and spatial layers.
+ bool is_correct_layer = true;
+ if (header.payloadType == kPayloadTypeVP9 ||
+ header.payloadType == kPayloadTypeVP8) {
+ // Get VP8 and VP9 specific header to check layers indexes.
+ const uint8_t* payload = packet + header.headerLength;
+ const size_t payload_length = length - header.headerLength;
+ const size_t payload_data_length =
+ payload_length - header.paddingLength;
+ const bool is_vp8 = header.payloadType == kPayloadTypeVP8;
+ std::unique_ptr<RtpDepacketizer> depacketizer(
+ RtpDepacketizer::Create(is_vp8 ? kRtpVideoVp8 : kRtpVideoVp9));
sprang_webrtc 2017/02/22 16:56:07 Can you extract this to a helper method?
ilnik 2017/02/23 08:58:29 Done.
+ RtpDepacketizer::ParsedPayload parsed_payload;
+ bool result = depacketizer->Parse(&parsed_payload, payload,
+ payload_data_length);
+ RTC_DCHECK(result);
+ const int temporal_idx = static_cast<int>(
+ is_vp8 ? parsed_payload.type.Video.codecHeader.VP8.temporalIdx
+ : parsed_payload.type.Video.codecHeader.VP9.temporal_idx);
+ const int spatial_idx = static_cast<int>(
+ is_vp8 ? kNoSpatialIdx
+ : parsed_payload.type.Video.codecHeader.VP9.spatial_idx);
+ is_correct_layer =
+ (selected_tl_ < 0 || temporal_idx == kNoTemporalIdx ||
+ temporal_idx <= selected_tl_) &&
+ (selected_sl_ < 0 || spatial_idx == kNoSpatialIdx ||
+ spatial_idx <= selected_sl_);
+ }
+ if (is_correct_layer) {
encoded_frame_sizes_[timestamp] +=
length - (header.headerLength + header.paddingLength);
+ total_media_bytes_ +=
+ length - (header.headerLength + header.paddingLength);
}
+ if (first_sending_time_ == 0)
+ first_sending_time_ = current_time;
+ last_sending_time_ = current_time;
}
}
return result;
@@ -319,11 +360,7 @@ class VideoAnalyzer : public PacketReceiver,
return transport_->SendRtcp(packet, length);
}
- void EncodedFrameCallback(const EncodedFrame& frame) override {
- rtc::CritScope lock(&comparison_lock_);
- if (frames_recorded_ < frames_to_process_)
- encoded_frame_size_.AddSample(frame.length_);
- }
+ void EncodedFrameCallback(const EncodedFrame& frame) override { }
sprang_webrtc 2017/02/22 16:56:07 encoded_frame_size_ isn't being populate any more?
ilnik 2017/02/23 08:58:29 No, it is populated in sendRtp to encoded_frame_si
sprang_webrtc 2017/02/23 10:46:54 I see. Then I guess you can remove this method, r
ilnik 2017/02/23 10:55:59 Done.
void OnFrame(const VideoFrame& video_frame) override {
int64_t render_time_ms =
@@ -676,6 +713,9 @@ class VideoAnalyzer : public PacketReceiver,
PrintResult("encode_usage_percent", encode_usage_percent_, " percent");
PrintResult("media_bitrate", media_bitrate_bps_, " bps");
+ printf("RESULT actual_bitrate: %s = %.6lf bps\n", test_label_.c_str(),
+ GetActualBitrate());
+
if (receive_stream_ != nullptr) {
PrintResult("decode_time", decode_time_ms_, " ms");
PrintResult("decode_time_max", decode_time_max_ms_, " ms");
@@ -800,6 +840,12 @@ class VideoAnalyzer : public PacketReceiver,
}
}
+ double GetActualBitrate() {
sprang_webrtc 2017/02/22 16:56:07 Maybe GetAverageMediaPayloadBitrateBps() ?
ilnik 2017/02/23 08:58:29 Done.
+ return static_cast<double>(total_media_bytes_) * 8 /
+ (last_sending_time_ - first_sending_time_) *
+ rtc::kNumMillisecsPerSec;
sprang_webrtc 2017/02/22 16:56:06 Just to be sure, maybe add a dcheck verifying that
ilnik 2017/02/23 08:58:29 Actually, in quick mode there will be exactly one
+ }
+
// Implements VideoSinkInterface to receive captured frames from a
// FrameGeneratorCapturer. Implements VideoSourceInterface to be able to act
// as a source to VideoSendStream.
@@ -859,6 +905,8 @@ class VideoAnalyzer : public PacketReceiver,
const uint32_t rtx_ssrc_to_analyze_;
const uint32_t selected_stream_width_;
const uint32_t selected_stream_height_;
+ const int selected_sl_;
+ const int selected_tl_;
PreEncodeProxy pre_encode_proxy_;
OnEncodeTimingProxy encode_timing_proxy_;
std::vector<Sample> samples_ GUARDED_BY(comparison_lock_);
@@ -885,6 +933,10 @@ class VideoAnalyzer : public PacketReceiver,
int dropped_frames_before_rendering_;
int64_t last_render_time_;
uint32_t rtp_timestamp_delta_;
+ int64_t total_media_bytes_;
+
+ int64_t first_sending_time_;
+ int64_t last_sending_time_;
rtc::CriticalSection crit_;
std::deque<VideoFrame> frames_ GUARDED_BY(crit_);
@@ -1357,7 +1409,8 @@ void VideoQualityTest::RunWithAnalyzer(const Params& params) {
kVideoSendSsrcs[params_.ss.selected_stream],
kSendRtxSsrcs[params_.ss.selected_stream],
static_cast<uint32_t>(selected_stream.width),
- static_cast<uint32_t>(selected_stream.height), is_quick_test_enabled);
+ static_cast<uint32_t>(selected_stream.height), params.ss.selected_sl,
+ params_.video.selected_tl, is_quick_test_enabled);
analyzer.SetReceiver(receiver_call_->Receiver());
send_transport.SetReceiver(&analyzer);
recv_transport.SetReceiver(sender_call_->Receiver());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine