-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Built-In Transform support for Apple Log (#1941)
* Built-In Transform support for Apple Log Signed-off-by: Joseph Goldstone <[email protected]> * Add Apple Log to Linear curve Signed-off-by: Joseph Goldstone <[email protected]> * Don't allow use of Apple Log in pre-2.4 configs; create half LUT to avoid clipping input Signed-off-by: Joseph Goldstone <[email protected]> * Insert std:: in front of that square root Signed-off-by: Joseph Goldstone <[email protected]> * Bump minor version number to 4 in testing config (stored as string literal); bump LastSupportedMinorVersion to 4 Signed-off-by: Joseph Goldstone <[email protected]> * Adjust string literal against which maximum minor version is tested to be 4, not 3 Signed-off-by: Joseph Goldstone <[email protected]> --------- Signed-off-by: Joseph Goldstone <[email protected]>
- Loading branch information
1 parent
0c90ded
commit 184566e
Showing
9 changed files
with
146 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// 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 | ||
{ | ||
|
||
void GenerateAppleLogToLinearOps(OpRcPtrVec & ops) | ||
{ | ||
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 * std::pow((R_t - R_0), 2.0); | ||
|
||
if (in >= P_t) | ||
{ | ||
return float(std::pow(2.0, (in - delta) / gamma) - beta); | ||
} | ||
else if (in < P_t && in >= 0.0) | ||
{ | ||
return float(std::sqrt(in / c) + R_0); | ||
} | ||
else | ||
{ | ||
return float(R_0); | ||
} | ||
}; | ||
|
||
CreateHalfLut(ops, GenerateLutValues); | ||
|
||
} | ||
|
||
} // namespace APPLE_LOG | ||
|
||
namespace CAMERA | ||
{ | ||
|
||
namespace APPLE | ||
{ | ||
|
||
void RegisterAll(BuiltinTransformRegistryImpl & registry) noexcept | ||
{ | ||
{ | ||
auto APPLE_LOG_to_ACES2065_1_Functor = [](OpRcPtrVec & ops) | ||
{ | ||
APPLE_LOG::GenerateAppleLogToLinearOps(ops); | ||
|
||
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) | ||
{ | ||
APPLE_LOG::GenerateAppleLogToLinearOps(ops); | ||
}; | ||
|
||
registry.addBuiltin("CURVE - APPLE_LOG_to_LINEAR", | ||
"Convert Apple Log to linear", | ||
APPLE_LOG_to_Linear_Functor); | ||
} | ||
} | ||
|
||
} // namespace APPLE | ||
|
||
} // namespace CAMERA | ||
|
||
} // namespace OCIO_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters