Skip to content

Commit 0fb005e

Browse files
authored
Add Blackmagic CLFs (#60)
* Add Blackmagic CLFs Signed-off-by: Doug Walker <doug.walker@autodesk.com> * Add Linear and Curve CLFs Signed-off-by: Doug Walker <doug.walker@autodesk.com> * Address review comments Signed-off-by: Doug Walker <doug.walker@autodesk.com>
1 parent 198f7de commit 0fb005e

18 files changed

+370
-28
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright Contributors to the OpenColorIO Project.
3+
4+
from .generate import main
5+
6+
__all__ = [
7+
"main",
8+
]
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright Contributors to the OpenColorIO Project.
3+
"""
4+
*Blackmagic* CLF Transforms Generation
5+
=======================================
6+
7+
Defines procedures for generating Blackmagic *Common LUT Format* (CLF)
8+
transforms for the OpenColorIO project.
9+
"""
10+
11+
import PyOpenColorIO as ocio
12+
from pathlib import Path
13+
import math
14+
15+
from opencolorio_config_aces.clf import (
16+
create_conversion_matrix,
17+
generate_clf,
18+
)
19+
20+
__author__ = "OpenColorIO Contributors"
21+
__copyright__ = "Copyright Contributors to the OpenColorIO Project."
22+
__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause"
23+
__maintainer__ = "OpenColorIO Contributors"
24+
__email__ = "ocio-dev@lists.aswf.io"
25+
__status__ = "Production"
26+
27+
__all__ = [
28+
"main",
29+
]
30+
31+
DEST_DIR = Path(__file__).parent.resolve() / "input"
32+
33+
TF_ID_PREFIX = "urn:aswf:ocio:transformId:1.0:"
34+
TF_ID_SUFFIX = ":1.0"
35+
36+
CLF_SUFFIX = ".clf"
37+
38+
39+
def _generate_clf_bmdfilm():
40+
"""Make the CLF file for BMDFilm_WideGamut_Gen5 plus matrix/curve CLFs."""
41+
42+
# Based on the document "Blackmagic Generation 5 Color Technical Reference.pdf"
43+
# dated May 2021. The resulting CLF was reviewed by Blackmagic.
44+
45+
cut = 0.005
46+
a = 0.08692876065491224
47+
b = 0.005494072432257808
48+
c = 0.5300133392291939
49+
# d = 8.283605932402494
50+
# e = 0.09246575342465753
51+
52+
BASE = math.e
53+
LIN_SB = cut
54+
LOG_SLP = a
55+
LOG_OFF = c
56+
LIN_SLP = 1.0
57+
LIN_OFF = b
58+
59+
# It is not necessary to set the linear_slope value in the LogCameraTransform
60+
# since the values automatically calculated by OCIO match the published values
61+
# to within double precision. This may be verified using the following formulas:
62+
# LINEAR_SLOPE =
63+
# LOG_SLP * LIN_SLP / ( (LIN_SLP * LIN_SB + LIN_OFF) * math.log(BASE) )
64+
# LOG_SB = LOG_SLP * math.log(LIN_SLP * LIN_SB + LIN_OFF) + LOG_OFF
65+
# LINEAR_OFFSET = LOG_SB - LINEAR_SLOPE * LIN_SB
66+
# print(LINEAR_SLOPE, LINEAR_OFFSET)
67+
# This prints 8.283605932402494 0.09246575342465779, which is sufficiently close
68+
# to the specified d and e above.
69+
70+
lct = ocio.LogCameraTransform(
71+
base=BASE,
72+
linSideBreak=[LIN_SB] * 3,
73+
logSideSlope=[LOG_SLP] * 3,
74+
logSideOffset=[LOG_OFF] * 3,
75+
linSideSlope=[LIN_SLP] * 3,
76+
linSideOffset=[LIN_OFF] * 3,
77+
direction=ocio.TRANSFORM_DIR_INVERSE,
78+
)
79+
80+
mtx = create_conversion_matrix(
81+
"Blackmagic Wide Gamut", "ACES2065-1", "CAT02"
82+
)
83+
84+
# Taking the color space name and IDT transform ID from:
85+
# https://github.com/ampas/aces-dev/pull/126/files
86+
aces_transform_id = (
87+
"urn:ampas:aces:transformId:v1.5:"
88+
"IDT.BlackmagicDesign.BMDFilm_WideGamut_Gen5.a1.v1"
89+
)
90+
91+
# Generate full transform.
92+
93+
generate_clf(
94+
ocio.GroupTransform(
95+
transforms=[
96+
lct,
97+
mtx,
98+
]
99+
),
100+
TF_ID_PREFIX
101+
+ "BlackmagicDesign:Input:BMDFilm_WideGamut_Gen5_to_ACES2065-1"
102+
+ TF_ID_SUFFIX,
103+
"Blackmagic Film Wide Gamut (Gen 5) to ACES2065-1",
104+
DEST_DIR / ("BMDFilm-WideGamut-Gen5_to_ACES2065-1" + CLF_SUFFIX),
105+
"Blackmagic Film Wide Gamut (Gen 5)",
106+
"ACES2065-1",
107+
aces_transform_id,
108+
)
109+
110+
# Generate transform for primaries only.
111+
112+
generate_clf(
113+
ocio.GroupTransform([mtx]),
114+
TF_ID_PREFIX
115+
+ "BlackmagicDesign:Input:Linear_BMD_WideGamut_Gen5_to_ACES2065-1"
116+
+ TF_ID_SUFFIX,
117+
"Linear Blackmagic Wide Gamut (Gen 5) to ACES2065-1",
118+
DEST_DIR / ("Linear-BMD-WideGamut-Gen5_to_ACES2065-1" + CLF_SUFFIX),
119+
"Linear Blackmagic Wide Gamut (Gen 5)",
120+
"ACES2065-1",
121+
None,
122+
)
123+
124+
# Generate named transform for log curve only.
125+
126+
generate_clf(
127+
ocio.GroupTransform([lct]),
128+
TF_ID_PREFIX
129+
+ "BlackmagicDesign:Input:BMDFilm_Gen5_Log_to_Linear"
130+
+ TF_ID_SUFFIX,
131+
"Blackmagic Film (Gen 5) Log to Linear Curve",
132+
DEST_DIR / ("BMDFilm-WideGamut-Gen5-Curve" + CLF_SUFFIX),
133+
"Blackmagic Film (Gen 5) Log",
134+
"Blackmagic Film (Gen 5) Linear",
135+
None,
136+
)
137+
138+
139+
def _generate_clf_davinci():
140+
"""Make the CLF file for DaVinci Intermediate Wide Gamut plus matrix/curve CLFs."""
141+
142+
# Based on the document "DaVinci_Resolve_17_Wide_Gamut_Intermediate.pdf"
143+
# dated 2021-07-31. The resulting CLF was reviewed by Blackmagic.
144+
145+
cut = 0.00262409
146+
a = 0.0075
147+
b = 7.0
148+
c = 0.07329248
149+
m = 10.44426855
150+
151+
BASE = 2.0
152+
LIN_SB = cut
153+
LOG_SLP = c
154+
LOG_OFF = c * b
155+
LIN_SLP = 1.0
156+
LIN_OFF = a
157+
158+
# The linear slope that would be calculated by OCIO based on continuity of the
159+
# derivatives is 10.444266836 vs. the published value of 10.44426855. Based on
160+
# input from Blackmagic, it is preferable to set the linear slope value explicitly.
161+
LINEAR_SLOPE = m
162+
163+
lct = ocio.LogCameraTransform(
164+
base=BASE,
165+
linSideBreak=[LIN_SB] * 3,
166+
logSideSlope=[LOG_SLP] * 3,
167+
logSideOffset=[LOG_OFF] * 3,
168+
linSideSlope=[LIN_SLP] * 3,
169+
linSideOffset=[LIN_OFF] * 3,
170+
linearSlope=[LINEAR_SLOPE] * 3,
171+
direction=ocio.TRANSFORM_DIR_INVERSE,
172+
)
173+
174+
mtx = create_conversion_matrix("DaVinci Wide Gamut", "ACES2065-1", "CAT02")
175+
176+
# This transform is not yet part of aces-dev, but an ID will be needed for AMF.
177+
# Proposing the following ID:
178+
aces_transform_id = (
179+
"urn:ampas:aces:transformId:v1.5:"
180+
"ACEScsc.Academy.DaVinci_Intermediate_WideGamut_to_ACES.a1.v1"
181+
)
182+
183+
# Generate full transform.
184+
185+
generate_clf(
186+
ocio.GroupTransform(
187+
transforms=[
188+
lct,
189+
mtx,
190+
]
191+
),
192+
TF_ID_PREFIX
193+
+ "BlackmagicDesign:Input:DaVinci_Intermediate_WideGamut_to_ACES2065-1"
194+
+ TF_ID_SUFFIX,
195+
"DaVinci Intermediate Wide Gamut to ACES2065-1",
196+
DEST_DIR
197+
/ ("DaVinci-Intermediate-WideGamut_to_ACES2065-1" + CLF_SUFFIX),
198+
"DaVinci Intermediate Wide Gamut",
199+
"ACES2065-1",
200+
aces_transform_id,
201+
)
202+
203+
# Generate transform for primaries only.
204+
205+
generate_clf(
206+
ocio.GroupTransform([mtx]),
207+
TF_ID_PREFIX
208+
+ "BlackmagicDesign:Input:Linear_DaVinci_WideGamut_to_ACES2065-1"
209+
+ TF_ID_SUFFIX,
210+
"Linear DaVinci Wide Gamut to ACES2065-1",
211+
DEST_DIR / ("Linear-DaVinci-WideGamut_to_ACES2065-1" + CLF_SUFFIX),
212+
"Linear DaVinci Wide Gamut",
213+
"ACES2065-1",
214+
None,
215+
)
216+
217+
# Generate named transform for log curve only.
218+
219+
generate_clf(
220+
ocio.GroupTransform([lct]),
221+
TF_ID_PREFIX
222+
+ "BlackmagicDesign:Input:DaVinci_Intermediate_Log_to_Linear"
223+
+ TF_ID_SUFFIX,
224+
"DaVinci Intermediate Log to Linear Curve",
225+
DEST_DIR / ("DaVinci-Intermediate-Curve" + CLF_SUFFIX),
226+
"DaVinci Intermediate Log",
227+
"DaVinci Intermediate Linear",
228+
None,
229+
)
230+
231+
232+
def main():
233+
"""Make all the Blackmagic CLFs."""
234+
235+
if not DEST_DIR.exists():
236+
DEST_DIR.mkdir()
237+
238+
_generate_clf_bmdfilm()
239+
_generate_clf_davinci()
240+
241+
return 0
242+
243+
244+
if __name__ == "__main__":
245+
import sys
246+
247+
sys.exit(main())
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ProcessList compCLFversion="3" id="urn:aswf:ocio:transformId:1.0:BlackmagicDesign:Input:BMDFilm_Gen5_Log_to_Linear:1.0" name="Blackmagic Film (Gen 5) Log to Linear Curve">
3+
<InputDescriptor>Blackmagic Film (Gen 5) Log</InputDescriptor>
4+
<OutputDescriptor>Blackmagic Film (Gen 5) Linear</OutputDescriptor>
5+
<Log inBitDepth="32f" outBitDepth="32f" style="cameraLogToLin">
6+
<LogParams base="2.71828182845905" linSideSlope="1" linSideOffset="0.00549407243225781" logSideSlope="0.0869287606549122" logSideOffset="0.530013339229194" linSideBreak="0.005" />
7+
</Log>
8+
</ProcessList>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ProcessList compCLFversion="3" id="urn:aswf:ocio:transformId:1.0:BlackmagicDesign:Input:BMDFilm_WideGamut_Gen5_to_ACES2065-1:1.0" name="Blackmagic Film Wide Gamut (Gen 5) to ACES2065-1">
3+
<InputDescriptor>Blackmagic Film Wide Gamut (Gen 5)</InputDescriptor>
4+
<OutputDescriptor>ACES2065-1</OutputDescriptor>
5+
<Info>
6+
<ACEStransformID>urn:ampas:aces:transformId:v1.5:IDT.BlackmagicDesign.BMDFilm_WideGamut_Gen5.a1.v1</ACEStransformID>
7+
</Info>
8+
<Log inBitDepth="32f" outBitDepth="32f" style="cameraLogToLin">
9+
<LogParams base="2.71828182845905" linSideSlope="1" linSideOffset="0.00549407243225781" logSideSlope="0.0869287606549122" logSideOffset="0.530013339229194" linSideBreak="0.005" />
10+
</Log>
11+
<Matrix inBitDepth="32f" outBitDepth="32f">
12+
<Array dim="3 3">
13+
0.647091325580708 0.242595385134207 0.110313289285085
14+
0.0651915997328518 1.02504756760476 -0.0902391673376126
15+
-0.0275570729194699 -0.0805887097177784 1.10814578263725
16+
</Array>
17+
</Matrix>
18+
</ProcessList>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ProcessList compCLFversion="3" id="urn:aswf:ocio:transformId:1.0:BlackmagicDesign:Input:DaVinci_Intermediate_Log_to_Linear:1.0" name="DaVinci Intermediate Log to Linear Curve">
3+
<InputDescriptor>DaVinci Intermediate Log</InputDescriptor>
4+
<OutputDescriptor>DaVinci Intermediate Linear</OutputDescriptor>
5+
<Log inBitDepth="32f" outBitDepth="32f" style="cameraLogToLin">
6+
<LogParams base="2" linSideSlope="1" linSideOffset="0.0075" logSideSlope="0.07329248" logSideOffset="0.51304736" linSideBreak="0.00262409" linearSlope="10.44426855" />
7+
</Log>
8+
</ProcessList>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ProcessList compCLFversion="3" id="urn:aswf:ocio:transformId:1.0:BlackmagicDesign:Input:DaVinci_Intermediate_WideGamut_to_ACES2065-1:1.0" name="DaVinci Intermediate Wide Gamut to ACES2065-1">
3+
<InputDescriptor>DaVinci Intermediate Wide Gamut</InputDescriptor>
4+
<OutputDescriptor>ACES2065-1</OutputDescriptor>
5+
<Info>
6+
<ACEStransformID>urn:ampas:aces:transformId:v1.5:ACEScsc.Academy.DaVinci_Intermediate_WideGamut_to_ACES.a1.v1</ACEStransformID>
7+
</Info>
8+
<Log inBitDepth="32f" outBitDepth="32f" style="cameraLogToLin">
9+
<LogParams base="2" linSideSlope="1" linSideOffset="0.0075" logSideSlope="0.07329248" logSideOffset="0.51304736" linSideBreak="0.00262409" linearSlope="10.44426855" />
10+
</Log>
11+
<Matrix inBitDepth="32f" outBitDepth="32f">
12+
<Array dim="3 3">
13+
0.748270290272981 0.167694659554328 0.0840350501726906
14+
0.0208421234689102 1.11190474268894 -0.132746866157851
15+
-0.0915122574225729 -0.127746712807307 1.21925897022988
16+
</Array>
17+
</Matrix>
18+
</ProcessList>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ProcessList compCLFversion="3" id="urn:aswf:ocio:transformId:1.0:BlackmagicDesign:Input:Linear_BMD_WideGamut_Gen5_to_ACES2065-1:1.0" name="Linear Blackmagic Wide Gamut (Gen 5) to ACES2065-1">
3+
<InputDescriptor>Linear Blackmagic Wide Gamut (Gen 5)</InputDescriptor>
4+
<OutputDescriptor>ACES2065-1</OutputDescriptor>
5+
<Matrix inBitDepth="32f" outBitDepth="32f">
6+
<Array dim="3 3">
7+
0.647091325580708 0.242595385134207 0.110313289285085
8+
0.0651915997328518 1.02504756760476 -0.0902391673376126
9+
-0.0275570729194699 -0.0805887097177784 1.10814578263725
10+
</Array>
11+
</Matrix>
12+
</ProcessList>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ProcessList compCLFversion="3" id="urn:aswf:ocio:transformId:1.0:BlackmagicDesign:Input:Linear_DaVinci_WideGamut_to_ACES2065-1:1.0" name="Linear DaVinci Wide Gamut to ACES2065-1">
3+
<InputDescriptor>Linear DaVinci Wide Gamut</InputDescriptor>
4+
<OutputDescriptor>ACES2065-1</OutputDescriptor>
5+
<Matrix inBitDepth="32f" outBitDepth="32f">
6+
<Array dim="3 3">
7+
0.748270290272981 0.167694659554328 0.0840350501726906
8+
0.0208421234689102 1.11190474268894 -0.132746866157851
9+
-0.0915122574225729 -0.127746712807307 1.21925897022988
10+
</Array>
11+
</Matrix>
12+
</ProcessList>

opencolorio_config_aces/clf/transforms/ocio/input/OCIO.Input.AP0_to_Rec709-sRGB.clf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<OutputDescriptor>sRGB</OutputDescriptor>
55
<Matrix inBitDepth="32f" outBitDepth="32f">
66
<Array dim="3 3">
7-
2.52140088857822 -1.13399574938275 -0.387561856768867
8-
-0.276214061561748 1.37259556630409 -0.0962823557364663
9-
-0.0153202000774786 -0.152992561800699 1.16838719961932
7+
2.52168618674388 -1.13413098823972 -0.387555198504163
8+
-0.276479914229922 1.37271908766826 -0.096239173438334
9+
-0.0153780649660342 -0.152975335867399 1.16835340083343
1010
</Array>
1111
</Matrix>
1212
<Exponent inBitDepth="32f" outBitDepth="32f" style="monCurveRev">

opencolorio_config_aces/clf/transforms/ocio/utility/OCIO.Utility.AP0_to_AP1-Gamma2.2.clf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<OutputDescriptor>2.2 gamma-corrected AP1 primaries, D60 white point</OutputDescriptor>
55
<Matrix inBitDepth="32f" outBitDepth="32f">
66
<Array dim="3 3">
7-
1.45143931607166 -0.23651074688936 -0.214928569308364
8-
-0.0765537733142628 1.17622969981179 -0.0996759264503605
9-
0.00831614842496078 -0.0060324497909093 0.997716301412982
7+
1.45143931614567 -0.23651074689374 -0.214928569251925
8+
-0.0765537733960205 1.17622969983357 -0.0996759264375522
9+
0.00831614842569773 -0.00603244979102103 0.997716301365324
1010
</Array>
1111
</Matrix>
1212
<Exponent inBitDepth="32f" outBitDepth="32f" style="basicPassThruRev">

0 commit comments

Comments
 (0)