Skip to content

Commit

Permalink
Add Canon CLFs (#71)
Browse files Browse the repository at this point in the history
* Add Canon CLFs

Signed-off-by: Doug Walker <[email protected]>

* Address formatting issues

Signed-off-by: Doug Walker <[email protected]>

* Address rst line

Signed-off-by: Doug Walker <[email protected]>

Signed-off-by: Doug Walker <[email protected]>
  • Loading branch information
doug-walker authored Sep 27, 2022
1 parent 484930d commit f5f4930
Show file tree
Hide file tree
Showing 5 changed files with 4,276 additions and 0 deletions.
10 changes: 10 additions & 0 deletions opencolorio_config_aces/clf/transforms/canon/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.

from .generate import (
generate_clf_transforms_canon,
)

__all__ = [
"generate_clf_transforms_canon",
]
138 changes: 138 additions & 0 deletions opencolorio_config_aces/clf/transforms/canon/generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.
"""
*Canon* CLF Transforms Generation
=================================
Defines procedures for generating Canon *Common LUT Format* (CLF)
transforms:
- :func:`opencolorio_config_aces.clf.generate_clf_transforms_canon`
"""

import PyOpenColorIO as ocio
from pathlib import Path

from opencolorio_config_aces.clf.transforms import (
clf_basename,
format_clf_transform_id,
generate_clf_transform,
matrix_RGB_to_RGB_transform,
)

__author__ = "OpenColorIO Contributors"
__copyright__ = "Copyright Contributors to the OpenColorIO Project."
__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause"
__maintainer__ = "OpenColorIO Contributors"
__email__ = "[email protected]"
__status__ = "Production"

__all__ = [
"FAMILY",
"GENUS",
"VERSION",
"generate_clf_transforms_canon",
]

FAMILY = "Canon"
"""
*CLF* transforms family.
"""

GENUS = "Input"
"""
*CLF* transforms genus.
"""

VERSION = "1.0"
"""
*CLF* transforms version.
"""


def generate_clf_transforms_canon(output_directory):
"""
Make the CLF file for Canon C-Log3 Cinema Gamut plus matrix/curve CLFs.
Returns
-------
dict
Dictionary of *CLF* transforms and *OpenColorIO* `GroupTransform`
instances.
References
----------
- Canon. (2018). White Paper on Canon Log.
Retrieved September 22, 2022, from http://downloads.canon.com/nw/learn/\
white-papers/cinema-eos/white-paper-canon-log-gamma-curves.pdf
Notes
-----
- The resulting *CLF* transforms were reviewed by *Canon*.
"""

output_directory.mkdir(parents=True, exist_ok=True)

clf_transforms = {}

bt = ocio.BuiltinTransform(style="CANON_CLOG3-CGAMUT_to_ACES2065-1")

mtx = matrix_RGB_to_RGB_transform("Cinema Gamut", "ACES2065-1", "CAT02")

aces_transform_id = (
"urn:ampas:aces:transformId:v1.5:"
"ACEScsc.Academy.CLog3_CGamut_to_ACES.a1.1.0"
)

# Generate full transform.
# NB: This is being saved in CTF format to allow us of a Built-in Transform
# and thus avoid the need for an external LUT file.

name = "CanonLog3_CinemaGamut-D55_to_ACES2065-1"
input_descriptor = "Canon Log 3 Cinema Gamut (Daylight)"
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,
[bt],
clf_transform_id,
f"{input_descriptor} to {output_descriptor}",
input_descriptor,
output_descriptor,
aces_transform_id,
)

# Generate transform for primaries only.

name = "Linear-CinemaGamut-D55_to_ACES2065-1"
input_descriptor = "Linear Canon Cinema Gamut (Daylight)"
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,
[mtx],
clf_transform_id,
f"{input_descriptor} to {output_descriptor}",
input_descriptor,
output_descriptor,
)

# Generate `NamedTransform` for log curve only.

# TODO: This will have to wait for OCIO 2.2 in order to do this without
# requiring an external LUT file.

return clf_transforms


if __name__ == "__main__":
import logging

logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)

output_directory = Path(__file__).parent.resolve() / "input"

generate_clf_transforms_canon(output_directory)
Loading

0 comments on commit f5f4930

Please sign in to comment.