Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 docs/opencolorio_config_aces.clf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Common LUT Format Generation
.. autosummary::
:toctree: generated/

generate_clf_transforms_apple
generate_clf_transforms_arri
generate_clf_transforms_bmdfilm
generate_clf_transforms_canon
Expand Down
2 changes: 2 additions & 0 deletions opencolorio_config_aces/clf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
)
from .transforms import (
generate_clf_transform,
generate_clf_transforms_apple,
generate_clf_transforms_arri,
generate_clf_transforms_bmdfilm,
generate_clf_transforms_canon,
Expand All @@ -32,6 +33,7 @@
__all__ += [
"generate_clf_transform",
"generate_clf_transform",
"generate_clf_transforms_apple",
"generate_clf_transforms_arri",
"generate_clf_transforms_bmdfilm",
"generate_clf_transforms_canon",
Expand Down
6 changes: 3 additions & 3 deletions opencolorio_config_aces/clf/discover/classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ def discover_clf_transforms(
'input'
>>> sorted([os.path.basename(path) for path in clf_transforms[key]])[:2]
['Apple.Input.Apple_Log-Curve.clf', \
'Apple.Input.Apple_Log_to_ACES2065-1.clf']
'Apple.Input.Apple_Log_2_to_ACES2065-1.clf']
"""

root_directory = os.path.normpath(os.path.expandvars(root_directory))
Expand Down Expand Up @@ -1114,9 +1114,9 @@ def classify_clf_transforms(
[('Apple.Input.Apple_Log-Curve', \
CLFTransform(\
'apple...input...Apple.Input.Apple_Log-Curve.clf')), \
('Apple.Input.Apple_Log_to_ACES2065-1', \
('Apple.Input.Apple_Log_2_to_ACES2065-1', \
CLFTransform(\
'apple...input...Apple.Input.Apple_Log_to_ACES2065-1.clf'))]
'apple...input...Apple.Input.Apple_Log_2_to_ACES2065-1.clf'))]
"""

classified_clf_transforms = defaultdict(lambda: defaultdict(dict))
Expand Down
6 changes: 6 additions & 0 deletions opencolorio_config_aces/clf/transforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
format_clf_transform_id,
clf_basename,
)
from .apple import (
generate_clf_transforms_apple,
)
from .arri import (
generate_clf_transforms_arri,
)
Expand Down Expand Up @@ -46,6 +49,9 @@
"format_clf_transform_id",
"clf_basename",
]
__all__ += [
"generate_clf_transforms_apple",
]
__all__ += [
"generate_clf_transforms_arri",
]
Expand Down
88 changes: 87 additions & 1 deletion opencolorio_config_aces/clf/transforms/apple/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@

from pathlib import Path

import numpy as np
import PyOpenColorIO as ocio

from opencolorio_config_aces.clf.transforms import (
clf_basename,
format_clf_transform_id,
generate_clf_transform,
matrix_transform,
)
from opencolorio_config_aces.utilities import required

__author__ = "OpenColorIO Contributors"
__copyright__ = "Copyright Contributors to the OpenColorIO Project."
Expand Down Expand Up @@ -52,11 +55,51 @@
"""


@required("Colour")
def _build_apple_wg_mtx() -> ocio.MatrixTransform:
"""
Build the `MatrixTransform` for the *Apple Wide Gamut* primaries.

The *Apple Log 2* white paper publishes neither the matrix nor the
chromatic adaptation transform to use, thus the matrix is derived from the
primaries using *Bradford* adaptation, as it is the most consistent with
*ACES* and matches the *OpenColorIO* `APPLE_LOG-APPLEWG_to_ACES2065-1`
builtin transform.

Returns
-------
:class:`ocio.MatrixTransform`
*OpenColorIO* `MatrixTransform`.
"""

import colour

# Primaries as defined in: "Apple Log 2 Profile".
colourspace = colour.RGB_Colourspace(
"Apple Wide Gamut",
np.array([[0.725, 0.301], [0.221, 0.814], [0.068, -0.076]]),
np.array([0.3127, 0.3290]),
)
colourspace.use_derived_transformation_matrices(True)

colourspace_ACES2065_1 = colour.RGB_COLOURSPACES["ACES2065-1"]
colourspace_ACES2065_1.use_derived_transformation_matrices(True)

return matrix_transform(
colour.matrix_RGB_to_RGB(
colourspace,
colourspace_ACES2065_1,
chromatic_adaptation_transform="Bradford",
)
)


def generate_clf_transforms_apple(
output_directory: Path,
) -> dict[Path, ocio.GroupTransform]:
"""
Generate the *CLF* transforms for *Apple Log* and for *Apple Log* curve.
Generate the *CLF* transforms for *Apple Log*, *Apple Log 2* and for the
*Apple Log* curve.

Parameters
----------
Expand All @@ -74,6 +117,9 @@ def generate_clf_transforms_apple(
- Apple. (September 22, 2023). Apple Log Profile.
Retrieved February 2, 2024, from
https://developer.apple.com/download/all/?q=Apple%20log%20profile
- Apple. (2025). Apple Log 2 Profile.
Retrieved from
https://developer.apple.com/download/all/?q=Apple%20log%20profile

Notes
-----
Expand Down Expand Up @@ -105,6 +151,46 @@ def generate_clf_transforms_apple(
style=style,
)

# "Apple Log 2" uses the same transfer function as "Apple Log" but encodes
# in the "Apple Wide Gamut" primaries rather than "ITU-R BT.2020".

aces_transform_id = (
"urn:ampas:aces:transformId:v2.0:CSC.Apple.AppleLog2_to_ACES.a2.v1"
)

name = "Apple_Log_2_to_ACES2065-1"
input_descriptor = "Apple Log 2"
output_descriptor = "ACES2065-1"
clf_transform_id = format_clf_transform_id(FAMILY, GENUS, name, VERSION)
filename = output_directory / clf_basename(clf_transform_id)
style = "APPLE_LOG-APPLEWG_to_ACES2065-1"
clf_transforms[filename] = generate_clf_transform(
filename,
[{"transform_type": "BuiltinTransform", "style": style}],
clf_transform_id,
f"{input_descriptor} to {output_descriptor}",
input_descriptor,
output_descriptor,
aces_transform_id=aces_transform_id,
style=style,
)

# Generate transform for primaries only.

name = "Linear_Apple_Wide_Gamut_to_ACES2065-1"
input_descriptor = "Linear Apple Wide Gamut"
output_descriptor = "ACES2065-1"
clf_transform_id = format_clf_transform_id(FAMILY, GENUS, name, VERSION)
filename = output_directory / clf_basename(clf_transform_id)
clf_transforms[filename] = generate_clf_transform(
filename,
[_build_apple_wg_mtx()],
clf_transform_id,
f"{input_descriptor} to {output_descriptor}",
input_descriptor,
output_descriptor,
)

# Generate `NamedTransform` for log curve only.

name = "Apple_Log-Curve_to_Linear"
Expand Down
Loading
Loading