1 /* 2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef RTC_TOOLS_FRAME_ANALYZER_VIDEO_TEMPORAL_ALIGNER_H_ 12 #define RTC_TOOLS_FRAME_ANALYZER_VIDEO_TEMPORAL_ALIGNER_H_ 13 14 #include <stddef.h> 15 16 #include <vector> 17 18 #include "api/scoped_refptr.h" 19 #include "rtc_tools/video_file_reader.h" 20 21 namespace webrtc { 22 namespace test { 23 24 // Returns a vector with the same size as the given test video. Each index 25 // corresponds to what reference frame that test frame matches to. These 26 // indices are strictly increasing and might loop around the reference video, 27 // e.g. their values can be bigger than the number of frames in the reference 28 // video and they should be interpreted modulo that size. The matching frames 29 // will be determined by maximizing SSIM. 30 std::vector<size_t> FindMatchingFrameIndices( 31 const rtc::scoped_refptr<Video>& reference_video, 32 const rtc::scoped_refptr<Video>& test_video); 33 34 // Generate a new video using the frames from the original video. The returned 35 // video will have the same number of frames as the size of |indices|, and 36 // frame nr i in the returned video will point to frame nr indices[i] in the 37 // original video. 38 rtc::scoped_refptr<Video> ReorderVideo(const rtc::scoped_refptr<Video>& video, 39 const std::vector<size_t>& indices); 40 41 // Returns a modified version of the reference video where the frames have 42 // been aligned to the test video. The test video is assumed to be captured 43 // during a quality measurement test where the reference video is the source. 44 // The test video may start at an arbitrary position in the reference video 45 // and there might be missing frames. The reference video is assumed to loop 46 // over when it reaches the end. The returned result is a version of the 47 // reference video where the missing frames are left out so it aligns to the 48 // test video. 49 rtc::scoped_refptr<Video> GenerateAlignedReferenceVideo( 50 const rtc::scoped_refptr<Video>& reference_video, 51 const rtc::scoped_refptr<Video>& test_video); 52 53 // As above, but using precalculated indices. 54 rtc::scoped_refptr<Video> GenerateAlignedReferenceVideo( 55 const rtc::scoped_refptr<Video>& reference_video, 56 const std::vector<size_t>& indices); 57 58 } // namespace test 59 } // namespace webrtc 60 61 #endif // RTC_TOOLS_FRAME_ANALYZER_VIDEO_TEMPORAL_ALIGNER_H_ 62