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_COLOR_ALIGNER_H_ 12 #define RTC_TOOLS_FRAME_ANALYZER_VIDEO_COLOR_ALIGNER_H_ 13 14 #include <array> 15 16 #include "api/scoped_refptr.h" 17 #include "api/video/video_frame_buffer.h" 18 #include "rtc_tools/video_file_reader.h" 19 20 namespace webrtc { 21 namespace test { 22 23 // Represents a linear color transformation from [y, u, v] to [y', u', v'] 24 // through the equation: [y', u', v'] = [y, u, v, 1] * matrix. 25 using ColorTransformationMatrix = std::array<std::array<float, 4>, 3>; 26 27 // Calculate the optimal color transformation that should be applied to the test 28 // video to match as closely as possible to the reference video. 29 ColorTransformationMatrix CalculateColorTransformationMatrix( 30 const rtc::scoped_refptr<Video>& reference_video, 31 const rtc::scoped_refptr<Video>& test_video); 32 33 // Calculate color transformation for a single I420 frame. 34 ColorTransformationMatrix CalculateColorTransformationMatrix( 35 const rtc::scoped_refptr<I420BufferInterface>& reference_frame, 36 const rtc::scoped_refptr<I420BufferInterface>& test_frame); 37 38 // Apply a color transformation to a video. 39 rtc::scoped_refptr<Video> AdjustColors( 40 const ColorTransformationMatrix& color_matrix, 41 const rtc::scoped_refptr<Video>& video); 42 43 // Apply a color transformation to a single I420 frame. 44 rtc::scoped_refptr<I420BufferInterface> AdjustColors( 45 const ColorTransformationMatrix& color_matrix, 46 const rtc::scoped_refptr<I420BufferInterface>& frame); 47 48 } // namespace test 49 } // namespace webrtc 50 51 #endif // RTC_TOOLS_FRAME_ANALYZER_VIDEO_COLOR_ALIGNER_H_ 52