Add possibility to adjust frames before comparison in pc level tests

Bug: None
Change-Id: I363d84096bef50ab6a50531ce877f41f6c327d8f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180123
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Commit-Queue: Andrey Logvin <landrey@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31789}
This commit is contained in:
Andrey Logvin
2020-07-24 07:42:27 +00:00
committed by Commit Bot
parent 60cbf70944
commit 4fd830acab
3 changed files with 22 additions and 2 deletions

View File

@ -648,6 +648,7 @@ if (!build_with_chromium) {
"../../../rtc_base:rtc_numerics",
"../../../rtc_base:timeutils",
"../../../rtc_base/synchronization:mutex",
"../../../rtc_tools:video_quality_analysis",
"../../../system_wrappers",
]
}

View File

@ -22,6 +22,7 @@
#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/time_utils.h"
#include "rtc_tools/frame_analyzer/video_geometry_aligner.h"
namespace webrtc {
namespace webrtc_pc_e2e {
@ -671,8 +672,18 @@ void DefaultVideoQualityAnalyzer::ProcessComparison(
double ssim = -1.0;
if (options_.heavy_metrics_computation_enabled && comparison.captured &&
!comparison.dropped) {
psnr = I420PSNR(&*comparison.captured, &*comparison.rendered);
ssim = I420SSIM(&*comparison.captured, &*comparison.rendered);
rtc::scoped_refptr<I420BufferInterface> reference_buffer =
comparison.captured->video_frame_buffer()->ToI420();
rtc::scoped_refptr<I420BufferInterface> test_buffer =
comparison.rendered->video_frame_buffer()->ToI420();
if (options_.adjust_cropping_before_comparing_frames) {
test_buffer =
ScaleVideoFrameBuffer(*test_buffer.get(), reference_buffer->width(),
reference_buffer->height());
reference_buffer = test::AdjustCropping(reference_buffer, test_buffer);
}
psnr = I420PSNR(*reference_buffer.get(), *test_buffer.get());
ssim = I420SSIM(*reference_buffer.get(), *test_buffer.get());
}
const FrameStats& frame_stats = comparison.frame_stats;

View File

@ -170,6 +170,14 @@ struct DefaultVideoQualityAnalyzerOptions {
// Tells DefaultVideoQualityAnalyzer if heavy metrics like PSNR and SSIM have
// to be computed or not.
bool heavy_metrics_computation_enabled = true;
// If true DefaultVideoQualityAnalyzer will try to adjust frames before
// computing PSNR and SSIM for them. In some cases picture may be shifted by
// a few pixels after the encode/decode step. Those difference is invisible
// for a human eye, but it affects the metrics. So the adjustment is used to
// get metrics that are closer to how human persepts the video. This feature
// significantly slows down the comparison, so turn it on only when it is
// needed.
bool adjust_cropping_before_comparing_frames = false;
// Amount of frames that are queued in the DefaultVideoQualityAnalyzer from
// the point they were captured to the point they were rendered on all
// receivers per stream.