/* * 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_color_aligner.h" #include #include "api/video/i420_buffer.h" #include "rtc_tools/frame_analyzer/video_quality_analysis.h" #include "rtc_tools/video_file_reader.h" #include "test/gtest.h" #include "test/testsupport/file_utils.h" namespace webrtc { namespace test { namespace { const ColorTransformationMatrix kIdentityColorMatrix = { {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}}}; void ExpectNear(const ColorTransformationMatrix& expected, const ColorTransformationMatrix& actual) { // The scaling factor on y/u/v should be pretty precise. for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) EXPECT_NEAR(expected[i][j], actual[i][j], /* abs_error= */ 1.0e-3) << "at element i: " << i << ", j: " << j; } // The offset can be less precise since the range is [0, 255]. for (int i = 0; i < 3; ++i) EXPECT_NEAR(expected[i][3], actual[i][3], /* abs_error= */ 0.1) << "at element i: " << i; } } // namespace class VideoColorAlignerTest : public ::testing::Test { protected: void SetUp() { reference_video_ = OpenYuvFile(ResourcePath("foreman_128x96", "yuv"), 128, 96); ASSERT_TRUE(reference_video_); } rtc::scoped_refptr