From 4c0921129d0677a6a634beb3f9ef16705206586d Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Fri, 20 Mar 2020 12:58:25 +0100 Subject: [PATCH] Use real video duration instead of test duration. Use real video duration instead of test duration to calculate harmonic frame rate in DefaultVideoQualityAnalyzer. Bug: webrtc:11445 Change-Id: Ia5f96b2f87178419ec6ebe2ff5dbcb5a0c03c824 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171104 Reviewed-by: Ilya Nikolaevskiy Commit-Queue: Artem Titov Cr-Commit-Position: refs/heads/master@{#30854} --- .../video/default_video_quality_analyzer.cc | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc index a1c5d0aa25..7f61a379cd 100644 --- a/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc +++ b/test/pc/e2e/analyzer/video/default_video_quality_analyzer.cc @@ -592,20 +592,30 @@ void DefaultVideoQualityAnalyzer::ReportResults( using ::webrtc::test::ImproveDirection; double sum_squared_interframe_delays_secs = 0; - for (const double interframe_delay_ms : - stats.time_between_rendered_frames_ms.GetSamples()) { + Timestamp video_start_time = Timestamp::PlusInfinity(); + Timestamp video_end_time = Timestamp::MinusInfinity(); + for (const SamplesStatsCounter::StatsSample& sample : + stats.time_between_rendered_frames_ms.GetTimedSamples()) { + double interframe_delay_ms = sample.value; const double interframe_delays_secs = interframe_delay_ms / 1000.0; // Sum of squared inter frame intervals is used to calculate the harmonic // frame rate metric. The metric aims to reflect overall experience related // to smoothness of video playback and includes both freezes and pauses. sum_squared_interframe_delays_secs += interframe_delays_secs * interframe_delays_secs; + if (sample.time < video_start_time) { + video_start_time = sample.time; + } + if (sample.time > video_end_time) { + video_end_time = sample.time; + } } double harmonic_framerate_fps = 0; - if (sum_squared_interframe_delays_secs > 0.0) { - TimeDelta video_duration = Now() - start_time_; - harmonic_framerate_fps = - video_duration.seconds() / sum_squared_interframe_delays_secs; + TimeDelta video_duration = video_end_time - video_start_time; + if (sum_squared_interframe_delays_secs > 0.0 && video_duration.IsFinite()) { + harmonic_framerate_fps = static_cast(video_duration.us()) / + static_cast(kMicrosPerSecond) / + sum_squared_interframe_delays_secs; } ReportResult("psnr", test_case_name, stats.psnr, "dB",