diff --git a/rtc_tools/BUILD.gn b/rtc_tools/BUILD.gn index b2a97ea6f3..294cc5ae25 100644 --- a/rtc_tools/BUILD.gn +++ b/rtc_tools/BUILD.gn @@ -77,12 +77,17 @@ rtc_static_library("video_quality_analysis") { sources = [ "frame_analyzer/video_quality_analysis.cc", "frame_analyzer/video_quality_analysis.h", + "frame_analyzer/video_temporal_aligner.cc", + "frame_analyzer/video_temporal_aligner.h", ] deps = [ ":video_file_reader", "../api/video:video_frame_i420", "../common_video", + "../rtc_base:checks", + "../rtc_base:rtc_base_approved", "../test:perf_test", + "//third_party/abseil-cpp/absl/types:optional", "//third_party/libyuv", ] } @@ -298,6 +303,7 @@ if (rtc_include_tests) { } tools_unittests_resources = [ + "../resources/foreman_128x96.yuv", "../resources/foreman_cif.yuv", "../resources/reference_less_video_test_file.y4m", ] @@ -318,6 +324,7 @@ if (rtc_include_tests) { sources = [ "frame_analyzer/reference_less_video_analysis_unittest.cc", "frame_analyzer/video_quality_analysis_unittest.cc", + "frame_analyzer/video_temporal_aligner_unittest.cc", "frame_editing/frame_editing_unittest.cc", "sanitizers_unittest.cc", "simple_command_line_parser_unittest.cc", diff --git a/rtc_tools/frame_analyzer/video_temporal_aligner.cc b/rtc_tools/frame_analyzer/video_temporal_aligner.cc new file mode 100644 index 0000000000..f106852ed2 --- /dev/null +++ b/rtc_tools/frame_analyzer/video_temporal_aligner.cc @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "rtc_tools/frame_analyzer/video_temporal_aligner.h" + +#include +#include +#include +#include +#include + +#include "api/video/i420_buffer.h" +#include "rtc_base/checks.h" +#include "rtc_base/refcountedobject.h" +#include "rtc_tools/frame_analyzer/video_quality_analysis.h" +#include "third_party/libyuv/include/libyuv/compare.h" + +namespace webrtc { +namespace test { + +namespace { + +// This constant controls how many frames we look ahead while seeking for the +// match for the next frame. Note that we may span bigger gaps than this number +// since we reset the counter as soon as we find a better match. The seeking +// will stop when there is no improvement in the next kNumberOfFramesLookAhead +// frames. Typically, the SSIM will improve as we get closer and closer to the +// real match. +const int kNumberOfFramesLookAhead = 60; + +// Helper class that takes a video and generates an infinite looping video. +class LoopingVideo : public rtc::RefCountedObject