video_geometry_aligner.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #ifndef RTC_TOOLS_FRAME_ANALYZER_VIDEO_GEOMETRY_ALIGNER_H_
  11. #define RTC_TOOLS_FRAME_ANALYZER_VIDEO_GEOMETRY_ALIGNER_H_
  12. #include "api/video/video_frame_buffer.h"
  13. #include "rtc_tools/video_file_reader.h"
  14. namespace webrtc {
  15. namespace test {
  16. struct CropRegion {
  17. // Each value represents how much to crop from each side. Left is where x=0,
  18. // and top is where y=0. All values equal to zero represents no cropping.
  19. int left = 0;
  20. int right = 0;
  21. int top = 0;
  22. int bottom = 0;
  23. };
  24. // Crops and zooms in on the cropped region so that the returned frame has the
  25. // same resolution as the input frame.
  26. rtc::scoped_refptr<I420BufferInterface> CropAndZoom(
  27. const CropRegion& crop_region,
  28. const rtc::scoped_refptr<I420BufferInterface>& frame);
  29. // Calculate the optimal cropping region on the reference frame to maximize SSIM
  30. // to the test frame.
  31. CropRegion CalculateCropRegion(
  32. const rtc::scoped_refptr<I420BufferInterface>& reference_frame,
  33. const rtc::scoped_refptr<I420BufferInterface>& test_frame);
  34. // Returns a cropped and zoomed version of the reference frame that matches up
  35. // to the test frame. This is a simple helper function on top of
  36. // CalculateCropRegion() and CropAndZoom().
  37. rtc::scoped_refptr<I420BufferInterface> AdjustCropping(
  38. const rtc::scoped_refptr<I420BufferInterface>& reference_frame,
  39. const rtc::scoped_refptr<I420BufferInterface>& test_frame);
  40. // Returns a cropped and zoomed version of the reference video that matches up
  41. // to the test video. Frames are individually adjusted for cropping.
  42. rtc::scoped_refptr<Video> AdjustCropping(
  43. const rtc::scoped_refptr<Video>& reference_video,
  44. const rtc::scoped_refptr<Video>& test_video);
  45. } // namespace test
  46. } // namespace webrtc
  47. #endif // RTC_TOOLS_FRAME_ANALYZER_VIDEO_GEOMETRY_ALIGNER_H_