Skip to content

Commit a4cc1e6

Browse files
authored
Add Sony CLFs (#62)
* Add Sony CLFs Signed-off-by: Doug Walker <doug.walker@autodesk.com> * Fix formatting problem Signed-off-by: Doug Walker <doug.walker@autodesk.com>
1 parent 0fb005e commit a4cc1e6

12 files changed

+381
-0
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 generate_sony
5+
6+
__all__ = [
7+
"generate_sony",
8+
]
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright Contributors to the OpenColorIO Project.
3+
"""
4+
*Sony* CLF Transforms Generation
5+
================================
6+
7+
Defines procedures for generating Sony *Common LUT Format* (CLF)
8+
transforms for the OpenColorIO project.
9+
"""
10+
11+
import PyOpenColorIO as ocio
12+
from pathlib import Path
13+
14+
from opencolorio_config_aces.clf import (
15+
create_conversion_matrix,
16+
generate_clf,
17+
)
18+
19+
__author__ = "OpenColorIO Contributors"
20+
__copyright__ = "Copyright Contributors to the OpenColorIO Project."
21+
__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause"
22+
__maintainer__ = "OpenColorIO Contributors"
23+
__email__ = "ocio-dev@lists.aswf.io"
24+
__status__ = "Production"
25+
26+
__all__ = [
27+
"generate_sony",
28+
]
29+
30+
DEST_DIR = Path(__file__).parent.resolve() / "input"
31+
32+
TF_ID_PREFIX = "urn:aswf:ocio:transformId:1.0:"
33+
TF_ID_SUFFIX = ":1.0"
34+
35+
CLF_SUFFIX = ".clf"
36+
37+
38+
def _build_slog3_curve():
39+
"""Build the Log transform for the S-Log3 curve."""
40+
linSideSlope = 1.0 / (0.18 + 0.01)
41+
linSideOffset = 0.01 / (0.18 + 0.01)
42+
logSideSlope = 261.5 / 1023.0
43+
logSideOffset = 420.0 / 1023.0
44+
linSideBreak = 0.01125000
45+
linearSlope = ((171.2102946929 - 95.0) / 0.01125000) / 1023.0
46+
base = 10.0
47+
48+
lct = ocio.LogCameraTransform(
49+
base=base,
50+
linSideBreak=[linSideBreak] * 3,
51+
logSideSlope=[logSideSlope] * 3,
52+
logSideOffset=[logSideOffset] * 3,
53+
linSideSlope=[linSideSlope] * 3,
54+
linSideOffset=[linSideOffset] * 3,
55+
linearSlope=[linearSlope] * 3,
56+
direction=ocio.TRANSFORM_DIR_INVERSE,
57+
)
58+
return lct
59+
60+
61+
def _build_sgamut3_mtx():
62+
"""Build the Matrix transform for the S-Gamut3 primaries."""
63+
mtx = create_conversion_matrix("S-Gamut3", "ACES2065-1", "CAT02")
64+
return mtx
65+
66+
67+
def _build_sgamut3_cine_mtx():
68+
"""Build the Matrix transform for the S-Gamut3.Cine primaries."""
69+
mtx = create_conversion_matrix("S-Gamut3.Cine", "ACES2065-1", "CAT02")
70+
return mtx
71+
72+
73+
def _build_venice_sgamut3_mtx():
74+
"""Build the Matrix transform for the Venice S-Gamut3 primaries."""
75+
mtx = create_conversion_matrix("Venice S-Gamut3", "ACES2065-1", "CAT02")
76+
return mtx
77+
78+
79+
def _build_venice_sgamut3_cine_mtx():
80+
"""Build the Matrix transform for the Venice S-Gamut3.Cine primaries."""
81+
mtx = create_conversion_matrix(
82+
"Venice S-Gamut3.Cine", "ACES2065-1", "CAT02"
83+
)
84+
return mtx
85+
86+
87+
def generate_sony():
88+
"""Make all the Sony CLFs."""
89+
90+
if not DEST_DIR.exists():
91+
DEST_DIR.mkdir()
92+
93+
# The full transforms generated here were developed in collaboration with Sony.
94+
95+
# Generate full S-Log3 - S-Gamut3 transform.
96+
97+
generate_clf(
98+
ocio.GroupTransform(
99+
transforms=[
100+
_build_slog3_curve(),
101+
_build_sgamut3_mtx(),
102+
]
103+
),
104+
TF_ID_PREFIX + "Sony:Input:SLog3_SGamut3_to_ACES2065-1" + TF_ID_SUFFIX,
105+
"Sony S-Log3 S-Gamut3 to ACES2065-1",
106+
DEST_DIR / ("SLog3-SGamut3_to_ACES2065-1" + CLF_SUFFIX),
107+
"Sony S-Log3 S-Gamut3",
108+
"ACES2065-1",
109+
"urn:ampas:aces:transformId:v1.5:IDT.Sony.SLog3_SGamut3.a1.v1",
110+
)
111+
112+
# Generate the Linear S-Gamut3 transform.
113+
114+
generate_clf(
115+
ocio.GroupTransform([_build_sgamut3_mtx()]),
116+
TF_ID_PREFIX
117+
+ "Sony:Input:Linear_SGamut3_to_ACES2065-1"
118+
+ TF_ID_SUFFIX,
119+
"Linear S-Gamut3 to ACES2065-1",
120+
DEST_DIR / ("Linear-SGamut3_to_ACES2065-1" + CLF_SUFFIX),
121+
"Linear S-Gamut3",
122+
"ACES2065-1",
123+
None,
124+
)
125+
126+
# Generate full S-Log3 - S-Gamut3.Cine transform.
127+
128+
generate_clf(
129+
ocio.GroupTransform(
130+
transforms=[
131+
_build_slog3_curve(),
132+
_build_sgamut3_cine_mtx(),
133+
]
134+
),
135+
TF_ID_PREFIX
136+
+ "Sony:Input:SLog3_SGamut3Cine_to_ACES2065-1"
137+
+ TF_ID_SUFFIX,
138+
"Sony S-Log3 S-Gamut3.Cine to ACES2065-1",
139+
DEST_DIR / ("SLog3-SGamut3Cine_to_ACES2065-1" + CLF_SUFFIX),
140+
"Sony S-Log3 S-Gamut3.Cine",
141+
"ACES2065-1",
142+
"urn:ampas:aces:transformId:v1.5:IDT.Sony.SLog3_SGamut3Cine.a1.v1",
143+
)
144+
145+
# Generate the Linear S-Gamut3.Cine transform.
146+
147+
generate_clf(
148+
ocio.GroupTransform([_build_sgamut3_cine_mtx()]),
149+
TF_ID_PREFIX
150+
+ "Sony:Input:Linear_SGamut3Cine_to_ACES2065-1"
151+
+ TF_ID_SUFFIX,
152+
"Linear S-Gamut3.Cine to ACES2065-1",
153+
DEST_DIR / ("Linear-SGamut3Cine_to_ACES2065-1" + CLF_SUFFIX),
154+
"Linear S-Gamut3.Cine",
155+
"ACES2065-1",
156+
None,
157+
)
158+
159+
# Generate full Venice S-Log3 - S-Gamut3 transform.
160+
161+
generate_clf(
162+
ocio.GroupTransform(
163+
transforms=[
164+
_build_slog3_curve(),
165+
_build_venice_sgamut3_mtx(),
166+
]
167+
),
168+
TF_ID_PREFIX
169+
+ "Sony:Input:Venice_SLog3_SGamut3_to_ACES2065-1"
170+
+ TF_ID_SUFFIX,
171+
"Sony Venice S-Log3 S-Gamut3 to ACES2065-1",
172+
DEST_DIR / ("Venice-SLog3-SGamut3_to_ACES2065-1" + CLF_SUFFIX),
173+
"Sony Venice S-Log3 S-Gamut3",
174+
"ACES2065-1",
175+
"urn:ampas:aces:transformId:v1.5:IDT.Sony.Venice_SLog3_SGamut3.a1.v1",
176+
)
177+
178+
# Generate the Linear Venice S-Gamut3 transform.
179+
180+
generate_clf(
181+
ocio.GroupTransform([_build_venice_sgamut3_cine_mtx()]),
182+
TF_ID_PREFIX
183+
+ "Sony:Input:Linear_Venice_SGamut3_to_ACES2065-1"
184+
+ TF_ID_SUFFIX,
185+
"Linear Venice S-Gamut3 to ACES2065-1",
186+
DEST_DIR / ("Linear-Venice-SGamut3_to_ACES2065-1" + CLF_SUFFIX),
187+
"Linear Venice S-Gamut3",
188+
"ACES2065-1",
189+
None,
190+
)
191+
192+
# Generate full Venice S-Log3 - S-Gamut3.Cine transform.
193+
194+
generate_clf(
195+
ocio.GroupTransform(
196+
transforms=[
197+
_build_slog3_curve(),
198+
_build_venice_sgamut3_cine_mtx(),
199+
]
200+
),
201+
TF_ID_PREFIX
202+
+ "Sony:Input:Venice_SLog3_SGamut3Cine_to_ACES2065-1"
203+
+ TF_ID_SUFFIX,
204+
"Sony Venice S-Log3 S-Gamut3.Cine to ACES2065-1",
205+
DEST_DIR / ("Venice-SLog3-SGamut3Cine_to_ACES2065-1" + CLF_SUFFIX),
206+
"Sony Venice S-Log3 S-Gamut3.Cine",
207+
"ACES2065-1",
208+
"urn:ampas:aces:transformId:v1.5:IDT.Sony.Venice_SLog3_SGamut3Cine.a1.v1",
209+
)
210+
211+
# Generate the Linear Venice S-Gamut3.Cine transform.
212+
213+
generate_clf(
214+
ocio.GroupTransform([_build_venice_sgamut3_cine_mtx()]),
215+
TF_ID_PREFIX
216+
+ "Sony:Input:Linear_Venice_SGamut3Cine_to_ACES2065-1"
217+
+ TF_ID_SUFFIX,
218+
"Linear Venice S-Gamut3.Cine to ACES2065-1",
219+
DEST_DIR / ("Linear-Venice-SGamut3Cine_to_ACES2065-1" + CLF_SUFFIX),
220+
"Linear Venice S-Gamut3.Cine",
221+
"ACES2065-1",
222+
None,
223+
)
224+
225+
# Generate named transform for S-Log3 curve only.
226+
227+
generate_clf(
228+
ocio.GroupTransform([_build_slog3_curve()]),
229+
TF_ID_PREFIX + "Sony:Input:SLog3_Log_to_Linear" + TF_ID_SUFFIX,
230+
"S-Log3 Log to Linear Curve",
231+
DEST_DIR / ("SLog3-Curve" + CLF_SUFFIX),
232+
"S-Log3 Log (arbitrary primaries)",
233+
"S-Log3 Linear (arbitrary primaries)",
234+
None,
235+
)
236+
237+
return 0
238+
239+
240+
if __name__ == "__main__":
241+
import sys
242+
243+
sys.exit(generate_sony())
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:Sony:Input:Linear_SGamut3Cine_to_ACES2065-1:1.0" name="Linear S-Gamut3.Cine to ACES2065-1">
3+
<InputDescriptor>Linear S-Gamut3.Cine</InputDescriptor>
4+
<OutputDescriptor>ACES2065-1</OutputDescriptor>
5+
<Matrix inBitDepth="32f" outBitDepth="32f">
6+
<Array dim="3 3">
7+
0.638788667185978 0.272351433711262 0.0888598991027595
8+
-0.00391590602528225 1.0880732308974 -0.0841573248721177
9+
-0.0299072021239151 -0.0264325799101947 1.05633978203411
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:Sony:Input:Linear_SGamut3_to_ACES2065-1:1.0" name="Linear S-Gamut3 to ACES2065-1">
3+
<InputDescriptor>Linear S-Gamut3</InputDescriptor>
4+
<OutputDescriptor>ACES2065-1</OutputDescriptor>
5+
<Matrix inBitDepth="32f" outBitDepth="32f">
6+
<Array dim="3 3">
7+
0.75298259539984 0.143370216235557 0.103647188364603
8+
0.0217076974414428 1.01531883550528 -0.0370265329467195
9+
-0.00941605274963355 0.00337041785882367 1.00604563489081
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:Sony:Input:Linear_Venice_SGamut3Cine_to_ACES2065-1:1.0" name="Linear Venice S-Gamut3.Cine to ACES2065-1">
3+
<InputDescriptor>Linear Venice S-Gamut3.Cine</InputDescriptor>
4+
<OutputDescriptor>ACES2065-1</OutputDescriptor>
5+
<Matrix inBitDepth="32f" outBitDepth="32f">
6+
<Array dim="3 3">
7+
0.674257092126512 0.220571735923398 0.10517117195009
8+
-0.00931360607857167 1.10595886142466 -0.0966452553460855
9+
-0.0382090673002312 -0.017938376600236 1.05614744390047
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:Sony:Input:Linear_Venice_SGamut3_to_ACES2065-1:1.0" name="Linear Venice S-Gamut3 to ACES2065-1">
3+
<InputDescriptor>Linear Venice S-Gamut3</InputDescriptor>
4+
<OutputDescriptor>ACES2065-1</OutputDescriptor>
5+
<Matrix inBitDepth="32f" outBitDepth="32f">
6+
<Array dim="3 3">
7+
0.674257092126512 0.220571735923398 0.10517117195009
8+
-0.00931360607857167 1.10595886142466 -0.0966452553460855
9+
-0.0382090673002312 -0.017938376600236 1.05614744390047
10+
</Array>
11+
</Matrix>
12+
</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:Sony:Input:SLog3_Log_to_Linear:1.0" name="S-Log3 Log to Linear Curve">
3+
<InputDescriptor>S-Log3 Log (arbitrary primaries)</InputDescriptor>
4+
<OutputDescriptor>S-Log3 Linear (arbitrary primaries)</OutputDescriptor>
5+
<Log inBitDepth="32f" outBitDepth="32f" style="cameraLogToLin">
6+
<LogParams base="10" linSideSlope="5.26315789473684" linSideOffset="0.0526315789473684" logSideSlope="0.255620723362659" logSideOffset="0.410557184750733" linSideBreak="0.01125" linearSlope="6.62194371177582" />
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:Sony:Input:SLog3_SGamut3Cine_to_ACES2065-1:1.0" name="Sony S-Log3 S-Gamut3.Cine to ACES2065-1">
3+
<InputDescriptor>Sony S-Log3 S-Gamut3.Cine</InputDescriptor>
4+
<OutputDescriptor>ACES2065-1</OutputDescriptor>
5+
<Info>
6+
<ACEStransformID>urn:ampas:aces:transformId:v1.5:IDT.Sony.SLog3_SGamut3Cine.a1.v1</ACEStransformID>
7+
</Info>
8+
<Log inBitDepth="32f" outBitDepth="32f" style="cameraLogToLin">
9+
<LogParams base="10" linSideSlope="5.26315789473684" linSideOffset="0.0526315789473684" logSideSlope="0.255620723362659" logSideOffset="0.410557184750733" linSideBreak="0.01125" linearSlope="6.62194371177582" />
10+
</Log>
11+
<Matrix inBitDepth="32f" outBitDepth="32f">
12+
<Array dim="3 3">
13+
0.638788667185978 0.272351433711262 0.0888598991027595
14+
-0.00391590602528225 1.0880732308974 -0.0841573248721177
15+
-0.0299072021239151 -0.0264325799101947 1.05633978203411
16+
</Array>
17+
</Matrix>
18+
</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:Sony:Input:SLog3_SGamut3_to_ACES2065-1:1.0" name="Sony S-Log3 S-Gamut3 to ACES2065-1">
3+
<InputDescriptor>Sony S-Log3 S-Gamut3</InputDescriptor>
4+
<OutputDescriptor>ACES2065-1</OutputDescriptor>
5+
<Info>
6+
<ACEStransformID>urn:ampas:aces:transformId:v1.5:IDT.Sony.SLog3_SGamut3.a1.v1</ACEStransformID>
7+
</Info>
8+
<Log inBitDepth="32f" outBitDepth="32f" style="cameraLogToLin">
9+
<LogParams base="10" linSideSlope="5.26315789473684" linSideOffset="0.0526315789473684" logSideSlope="0.255620723362659" logSideOffset="0.410557184750733" linSideBreak="0.01125" linearSlope="6.62194371177582" />
10+
</Log>
11+
<Matrix inBitDepth="32f" outBitDepth="32f">
12+
<Array dim="3 3">
13+
0.75298259539984 0.143370216235557 0.103647188364603
14+
0.0217076974414428 1.01531883550528 -0.0370265329467195
15+
-0.00941605274963355 0.00337041785882367 1.00604563489081
16+
</Array>
17+
</Matrix>
18+
</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:Sony:Input:Venice_SLog3_SGamut3Cine_to_ACES2065-1:1.0" name="Sony Venice S-Log3 S-Gamut3.Cine to ACES2065-1">
3+
<InputDescriptor>Sony Venice S-Log3 S-Gamut3.Cine</InputDescriptor>
4+
<OutputDescriptor>ACES2065-1</OutputDescriptor>
5+
<Info>
6+
<ACEStransformID>urn:ampas:aces:transformId:v1.5:IDT.Sony.Venice_SLog3_SGamut3Cine.a1.v1</ACEStransformID>
7+
</Info>
8+
<Log inBitDepth="32f" outBitDepth="32f" style="cameraLogToLin">
9+
<LogParams base="10" linSideSlope="5.26315789473684" linSideOffset="0.0526315789473684" logSideSlope="0.255620723362659" logSideOffset="0.410557184750733" linSideBreak="0.01125" linearSlope="6.62194371177582" />
10+
</Log>
11+
<Matrix inBitDepth="32f" outBitDepth="32f">
12+
<Array dim="3 3">
13+
0.674257092126512 0.220571735923398 0.10517117195009
14+
-0.00931360607857167 1.10595886142466 -0.0966452553460855
15+
-0.0382090673002312 -0.017938376600236 1.05614744390047
16+
</Array>
17+
</Matrix>
18+
</ProcessList>

0 commit comments

Comments
 (0)