Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built-In Transform support for Apple Log #1941

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/OpenColorIO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ set(SOURCES
transforms/builtins/BuiltinTransformRegistry.cpp
transforms/builtins/ColorMatrixHelpers.cpp
transforms/builtins/OpHelpers.cpp
transforms/builtins/AppleCameras.cpp
transforms/builtins/ArriCameras.cpp
transforms/builtins/CanonCameras.cpp
transforms/builtins/Displays.cpp
Expand Down
85 changes: 85 additions & 0 deletions src/OpenColorIO/transforms/builtins/AppleCameras.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright Contributors to the OpenColorIO Project.


#include <cmath>

#include <OpenColorIO/OpenColorIO.h>

#include "ops/matrix/MatrixOp.h"
#include "transforms/builtins/AppleCameras.h"
#include "transforms/builtins/BuiltinTransformRegistry.h"
#include "transforms/builtins/ColorMatrixHelpers.h"
#include "transforms/builtins/OpHelpers.h"


namespace OCIO_NAMESPACE
{

namespace APPLE_LOG
{
auto GenerateLutValues = [](double in) -> float
{
constexpr double R_0 = -0.05641088;
constexpr double R_t = 0.01;
constexpr double c = 47.28711236;
constexpr double beta = 0.00964052;
constexpr double gamma = 0.08550479;
constexpr double delta = 0.69336945;
const double P_t = c * pow((R_t - R_0), 2.0);

if (in >= P_t)
{
return pow(2.0, (in - delta) / gamma) - beta;
doug-walker marked this conversation as resolved.
Show resolved Hide resolved
}
else if (in < P_t && in >= 0.0)
{
return sqrt(in / c) + R_0;
}
else
{
return R_0;
}

};
} // namespace APPLE_LOG

namespace CAMERA
{

namespace APPLE
{

void RegisterAll(BuiltinTransformRegistryImpl & registry) noexcept
{
{
auto APPLE_LOG_to_ACES2065_1_Functor = [](OpRcPtrVec & ops)
{
CreateLut(ops, 4096, APPLE_LOG::GenerateLutValues);
doug-walker marked this conversation as resolved.
Show resolved Hide resolved

MatrixOpData::MatrixArrayPtr matrix
= build_conversion_matrix(REC2020::primaries, ACES_AP0::primaries, ADAPTATION_BRADFORD);
CreateMatrixOp(ops, matrix, TRANSFORM_DIR_FORWARD);
};

registry.addBuiltin("APPLE_LOG_to_ACES2065-1",
"Convert Apple Log to ACES2065-1",
APPLE_LOG_to_ACES2065_1_Functor);
}
{
auto APPLE_LOG_to_Linear_Functor = [](OpRcPtrVec & ops)
{
CreateLut(ops, 4096, APPLE_LOG::GenerateLutValues);
};

registry.addBuiltin("CURVE - APPLE_LOG_to_LINEAR",
"Convert Apple Log to linear",
APPLE_LOG_to_Linear_Functor);
}
}

} // namespace APPLE

} // namespace CAMERA

} // namespace OCIO_NAMESPACE
31 changes: 31 additions & 0 deletions src/OpenColorIO/transforms/builtins/AppleCameras.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright Contributors to the OpenColorIO Project.


#ifndef INCLUDED_OCIO_APPLE_CAMERAS_H
#define INCLUDED_OCIO_APPLE_CAMERAS_H


#include <OpenColorIO/OpenColorIO.h>


namespace OCIO_NAMESPACE
{

class BuiltinTransformRegistryImpl;

namespace CAMERA
{

namespace APPLE
{

void RegisterAll(BuiltinTransformRegistryImpl & registry) noexcept;

} // namespace APPLE

} // namespace CAMERA

} // namespace OCIO_NAMESPACE

#endif // INCLUDED_OCIO_APPLE_CAMERAS_H
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "OpBuilders.h"
#include "Platform.h"
#include "transforms/builtins/ACES.h"
#include "transforms/builtins/AppleCameras.h"
#include "transforms/builtins/ArriCameras.h"
#include "transforms/builtins/BuiltinTransformRegistry.h"
#include "transforms/builtins/CanonCameras.h"
Expand Down Expand Up @@ -109,6 +110,7 @@ void BuiltinTransformRegistryImpl::registerAll() noexcept
ACES::RegisterAll(*this);

// Camera support.
CAMERA::APPLE::RegisterAll(*this);
CAMERA::ARRI::RegisterAll(*this);
CAMERA::CANON::RegisterAll(*this);
CAMERA::PANASONIC::RegisterAll(*this);
Expand Down
1 change: 1 addition & 0 deletions tests/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ set(SOURCES
ScanlineHelper.cpp
Transform.cpp
transforms/builtins/ACES.cpp
transforms/builtins/AppleCameras.cpp
transforms/builtins/ArriCameras.cpp
transforms/builtins/CanonCameras.cpp
transforms/builtins/ColorMatrixHelpers.cpp
Expand Down
4 changes: 4 additions & 0 deletions tests/cpu/transforms/BuiltinTransform_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ AllValues UnitTestValues
{ "ACES-OUTPUT - ACES2065-1_to_CIE-XYZ-D65 - HDR-CINEMA-108nit-7.2nit-P3lim_1.1",
{ { 0.5f, 0.4f, 0.3f }, { 0.22214814f, 0.21179835f, 0.15639816f } } },

{ "APPLE_LOG_to_ACES2065-1",
{ { 0.5f, 0.4f, 0.3f }, { 0.153334766f, 0.083515430f, 0.032948254f } } },
{ "CURVE - APPLE_LOG_to_LINEAR",
{ { 0.5f, 0.4f, 0.3f }, { 0.198913991f, 0.083076466024f, 0.0315782763f } } },
{ "ARRI_ALEXA-LOGC-EI800-AWG_to_ACES2065-1",
{ { 0.5f, 0.4f, 0.3f }, { 0.401621427766f, 0.236455447604f, 0.064830001192f } } },
{ "ARRI_LOGC4_to_ACES2065-1",
Expand Down
Loading