Skip to content

Commit 2758949

Browse files
committed
Implement support for *DJI D-Log - D-Gamut*.
Closes #146. Signed-off-by: Thomas Mansencal <[email protected]>
1 parent b136185 commit 2758949

File tree

9 files changed

+242
-9
lines changed

9 files changed

+242
-9
lines changed

docs/opencolorio_config_aces.clf.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Common LUT Format Generation
4343
generate_clf_transforms_bmdfilm
4444
generate_clf_transforms_canon
4545
generate_clf_transforms_davinci
46+
generate_clf_transforms_dji
4647
generate_clf_transforms_itu
4748
generate_clf_transforms_ocio
4849
generate_clf_transforms_panasonic

opencolorio_config_aces/clf/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
generate_clf_transforms_bmdfilm,
1515
generate_clf_transforms_canon,
1616
generate_clf_transforms_davinci,
17+
generate_clf_transforms_dji,
1718
generate_clf_transforms_itu,
1819
generate_clf_transforms_ocio,
1920
generate_clf_transforms_panasonic,
@@ -35,6 +36,7 @@
3536
"generate_clf_transforms_bmdfilm",
3637
"generate_clf_transforms_canon",
3738
"generate_clf_transforms_davinci",
39+
"generate_clf_transforms_dji",
3840
"generate_clf_transforms_itu",
3941
"generate_clf_transforms_ocio",
4042
"generate_clf_transforms_panasonic",

opencolorio_config_aces/clf/transforms/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
from .canon import (
2020
generate_clf_transforms_canon,
2121
)
22+
from .dji import (
23+
generate_clf_transforms_dji,
24+
)
2225
from .itu import (
2326
generate_clf_transforms_itu,
2427
)
@@ -53,6 +56,9 @@
5356
__all__ += [
5457
"generate_clf_transforms_canon",
5558
]
59+
__all__ += [
60+
"generate_clf_transforms_dji",
61+
]
5662
__all__ += [
5763
"generate_clf_transforms_itu",
5864
]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright Contributors to the OpenColorIO Project.
3+
4+
from .generate import (
5+
generate_clf_transforms_dji,
6+
)
7+
8+
__all__ = [
9+
"generate_clf_transforms_dji",
10+
]
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright Contributors to the OpenColorIO Project.
3+
"""
4+
*DJI* CLF Transforms Generation
5+
================================
6+
7+
Defines procedures for generating DJI *Common LUT Format* (CLF)
8+
transforms:
9+
10+
- :func:`opencolorio_config_aces.clf.generate_clf_transforms_dji`
11+
"""
12+
13+
from __future__ import annotations
14+
15+
from pathlib import Path
16+
17+
import PyOpenColorIO as ocio
18+
19+
from opencolorio_config_aces.clf.transforms import (
20+
clf_basename,
21+
format_clf_transform_id,
22+
generate_clf_transform,
23+
matrix_RGB_to_RGB_transform,
24+
)
25+
from opencolorio_config_aces.config import transform_factory
26+
27+
__author__ = "OpenColorIO Contributors"
28+
__copyright__ = "Copyright Contributors to the OpenColorIO Project."
29+
__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause"
30+
__maintainer__ = "OpenColorIO Contributors"
31+
__email__ = "[email protected]"
32+
__status__ = "Production"
33+
34+
__all__ = [
35+
"FAMILY",
36+
"GENUS",
37+
"VERSION",
38+
"generate_clf_transforms_dji",
39+
]
40+
41+
FAMILY: str = "DJI"
42+
"""
43+
*CLF* transforms family.
44+
"""
45+
46+
GENUS: str = "Input"
47+
"""
48+
*CLF* transforms genus.
49+
"""
50+
51+
VERSION: str = "1.0"
52+
"""
53+
*CLF* transforms version.
54+
"""
55+
56+
57+
def generate_clf_transforms_dji(
58+
output_directory: Path,
59+
) -> dict[Path, ocio.GroupTransform]:
60+
"""
61+
Generate the *CLF* transforms for *D-Log - D-Gamut* plus matrix/curve.
62+
63+
Parameters
64+
----------
65+
output_directory
66+
Directory to write the *CLF* transform(s) to.
67+
68+
Returns
69+
-------
70+
:class:`dict`
71+
Dictionary of *CLF* transforms and *OpenColorIO* `GroupTransform`
72+
instances.
73+
74+
References
75+
----------
76+
- Dji. (2017). White Paper on D-Log and D-Gamut of DJI Cinema Color
77+
System (pp. 1-5). https://dl.djicdn.com/downloads/zenmuse+x7/20171010/\
78+
D-Log_D-Gamut_Whitepaper.pdf
79+
"""
80+
81+
output_directory.mkdir(parents=True, exist_ok=True)
82+
83+
clf_transforms = {}
84+
85+
base = 10.0
86+
87+
# Mathematically correct for transition at log = 0.14:
88+
# lin_side_break = (0.14 - 0.0929) / 6.025 = 0.007817427385892119
89+
# Optimized:
90+
lin_side_break = 0.00758078675
91+
92+
log_side_slope = 1.0 / 3.89616
93+
log_side_offset = 2.27752 / 3.89616
94+
lin_side_slope = 0.9892
95+
lin_side_offset = 0.0108
96+
97+
lct = transform_factory(
98+
transform_type="LogCameraTransform",
99+
transform_factory="Constructor",
100+
base=base,
101+
linSideBreak=[lin_side_break] * 3,
102+
logSideSlope=[log_side_slope] * 3,
103+
logSideOffset=[log_side_offset] * 3,
104+
linSideSlope=[lin_side_slope] * 3,
105+
linSideOffset=[lin_side_offset] * 3,
106+
direction=ocio.TRANSFORM_DIR_INVERSE,
107+
)
108+
109+
mtx = matrix_RGB_to_RGB_transform("DJI D-Gamut", "ACES2065-1", "CAT02")
110+
111+
# ACES transform ID from the CTL file
112+
aces_transform_id = (
113+
"urn:ampas:aces:transformId:v2.0:CSC.DJI.DLog_DGamut_to_ACES.a1.v1"
114+
)
115+
116+
# Generate full transform.
117+
name = "DLog_DGamut_to_ACES2065-1"
118+
input_descriptor = "DJI D-Log - D-Gamut"
119+
output_descriptor = "ACES2065-1"
120+
clf_transform_id = format_clf_transform_id(FAMILY, GENUS, name, VERSION)
121+
filename = output_directory / clf_basename(clf_transform_id)
122+
clf_transforms[filename] = generate_clf_transform(
123+
filename,
124+
[lct, mtx],
125+
clf_transform_id,
126+
f"{input_descriptor} to {output_descriptor}",
127+
input_descriptor,
128+
output_descriptor,
129+
aces_transform_id,
130+
)
131+
132+
# Generate transform for primaries only.
133+
name = "Linear_DGamut_to_ACES2065-1"
134+
input_descriptor = "Linear DJI D-Gamut"
135+
output_descriptor = "ACES2065-1"
136+
clf_transform_id = format_clf_transform_id(FAMILY, GENUS, name, VERSION)
137+
filename = output_directory / clf_basename(clf_transform_id)
138+
clf_transforms[filename] = generate_clf_transform(
139+
filename,
140+
[mtx],
141+
clf_transform_id,
142+
f"{input_descriptor} to {output_descriptor}",
143+
input_descriptor,
144+
output_descriptor,
145+
)
146+
147+
# Generate `NamedTransform` for log curve only.
148+
name = "DLog-Curve_to_Linear"
149+
input_descriptor = "DJI D-Log Log (arbitrary primaries)"
150+
output_descriptor = "DJI D-Log Linear (arbitrary primaries)"
151+
clf_transform_id = format_clf_transform_id(FAMILY, GENUS, name, VERSION)
152+
filename = output_directory / clf_basename(clf_transform_id)
153+
clf_transforms[filename] = generate_clf_transform(
154+
filename,
155+
[lct],
156+
clf_transform_id,
157+
f'{input_descriptor.replace(" (arbitrary primaries)", "")} to Linear Curve',
158+
input_descriptor,
159+
output_descriptor,
160+
)
161+
162+
return clf_transforms
163+
164+
165+
if __name__ == "__main__":
166+
import logging
167+
168+
logging.basicConfig()
169+
logging.getLogger().setLevel(logging.INFO)
170+
171+
output_directory = Path(__file__).parent.resolve() / "input"
172+
173+
generate_clf_transforms_dji(output_directory)
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:DJI:Input:DLog-Curve_to_Linear:1.0" name="DJI D-Log Log to Linear Curve">
3+
<InputDescriptor>DJI D-Log Log (arbitrary primaries)</InputDescriptor>
4+
<OutputDescriptor>DJI D-Log Linear (arbitrary primaries)</OutputDescriptor>
5+
<Log inBitDepth="32f" outBitDepth="32f" style="cameraLogToLin">
6+
<LogParams base="10" linSideSlope="0.9892" linSideOffset="0.0108" logSideSlope="0.256662970719888" logSideOffset="0.58455504907396" linSideBreak="0.00758078675" />
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:DJI:Input:DLog_DGamut_to_ACES2065-1:1.0" name="DJI D-Log - D-Gamut to ACES2065-1">
3+
<InputDescriptor>DJI D-Log - D-Gamut</InputDescriptor>
4+
<OutputDescriptor>ACES2065-1</OutputDescriptor>
5+
<Info>
6+
<ACEStransformID>urn:ampas:aces:transformId:v2.0:CSC.DJI.DLog_DGamut_to_ACES.a1.v1</ACEStransformID>
7+
</Info>
8+
<Log inBitDepth="32f" outBitDepth="32f" style="cameraLogToLin">
9+
<LogParams base="10" linSideSlope="0.9892" linSideOffset="0.0108" logSideSlope="0.256662970719888" logSideOffset="0.58455504907396" linSideBreak="0.00758078675" />
10+
</Log>
11+
<Matrix inBitDepth="32f" outBitDepth="32f">
12+
<Array dim="3 3">
13+
0.691279245585754 0.214382527745956 0.0943382266682902
14+
0.0662224037667752 1.0116160801876 -0.0778384839543733
15+
-0.0172985410341745 -0.0773788501012682 1.09467739113544
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:DJI:Input:Linear_DGamut_to_ACES2065-1:1.0" name="Linear DJI D-Gamut to ACES2065-1">
3+
<InputDescriptor>Linear DJI D-Gamut</InputDescriptor>
4+
<OutputDescriptor>ACES2065-1</OutputDescriptor>
5+
<Matrix inBitDepth="32f" outBitDepth="32f">
6+
<Array dim="3 3">
7+
0.691279245585754 0.214382527745956 0.0943382266682902
8+
0.0662224037667752 1.0116160801876 -0.0778384839543733
9+
-0.0172985410341745 -0.0773788501012682 1.09467739113544
10+
</Array>
11+
</Matrix>
12+
</ProcessList>

opencolorio_config_aces/config/studio/generate/resources/Loading... - Studio Config - Mapping.csv

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,24 @@ Ordering,Colorspace,Legacy,ACEStransformID,CLFtransformID,Interface,BuiltinTrans
2323
120,Linear CinemaGamut D55,TRUE,,urn:aswf:ocio:transformId:1.0:Canon:Input:Linear-CinemaGamut-D55_to_ACES2065-1:1.0,ColorSpace,,"lin_canoncgamutday,Input - Canon - Linear - Canon Cinema Gamut Daylight",scene-linear,file-io
2424
121,C-Log3 - Curve,TRUE,,urn:aswf:ocio:transformId:1.0:Canon:Input:CLog3-Curve_to_Linear:1.0,NamedTransform,CURVE - CANON_CLOG3_to_LINEAR,"crv_canonlog3,Input - Canon - Curve - Canon-Log3",log,file-io
2525
121,CanonLog3 CinemaGamut D55,TRUE,urn:ampas:aces:transformId:v2.0:CSC.Canon.CLog3_CGamut_to_ACES.a1.v1,urn:aswf:ocio:transformId:1.0:Canon:Input:CanonLog3_CinemaGamut-D55_to_ACES2065-1:1.0,ColorSpace,CANON_CLOG3-CGAMUT_to_ACES2065-1,"canonlog3_cgamutday,Input - Canon - Canon-Log3 - Cinema Gamut Daylight",log,file-io
26-
130,Linear V-Gamut,TRUE,,urn:aswf:ocio:transformId:1.0:Panasonic:Input:Linear_VGamut_to_ACES2065-1:1.0,ColorSpace,,"lin_vgamut,Input - Panasonic - Linear - V-Gamut",scene-linear,file-io
27-
130,V-Log - Curve,TRUE,,urn:aswf:ocio:transformId:1.0:Panasonic:Input:VLog-Curve_to_Linear:1.0,NamedTransform,,"crv_vlog,Input - Panasonic - Curve - V-Log",log,file-io
26+
125,Input - DJI - D-Log - D-Gamut,FALSE,urn:ampas:aces:transformId:v2.0:CSC.DJI.DLog_DGamut_to_ACES.a1.v1,urn:aswf:ocio:transformId:1.0:DJI:Input:DLog_DGamut_to_ACES2065-1:1.0,ColorSpace,,dlog_dgamut,log,file-io
27+
130,D-Log - Curve,TRUE,,urn:aswf:ocio:transformId:1.0:DJI:Input:DLog-Curve_to_Linear:1.0,NamedTransform,,crv_dlog,log,file-io
28+
130,Linear D-Gamut,TRUE,,urn:aswf:ocio:transformId:1.0:DJI:Input:Linear_DGamut_to_ACES2065-1:1.0,ColorSpace,,lin_dgamut,scene-linear,file-io
2829
130,V-Log V-Gamut,TRUE,urn:ampas:aces:transformId:v2.0:CSC.Panasonic.VLog_VGamut_to_ACES.a2.v1,urn:aswf:ocio:transformId:1.0:Panasonic:Input:VLog_VGamut_to_ACES2065-1:1.0,ColorSpace,,"vlog_vgamut,Input - Panasonic - V-Log - V-Gamut",log,file-io
29-
135,Linear REDWideGamutRGB,TRUE,,urn:aswf:ocio:transformId:1.0:RED:Input:Linear_REDWideGamutRGB_to_ACES2065-1:1.0,ColorSpace,,"lin_rwg,Input - RED - Linear - REDWideGamutRGB",scene-linear,file-io
30-
135,Log3G10 - Curve,TRUE,,urn:aswf:ocio:transformId:1.0:RED:Input:Log3G10-Curve_to_Linear:1.0,NamedTransform,,"crv_rl3g10,Input - RED - Curve - REDLog3G10",log,file-io
30+
135,Linear V-Gamut,TRUE,,urn:aswf:ocio:transformId:1.0:Panasonic:Input:Linear_VGamut_to_ACES2065-1:1.0,ColorSpace,,"lin_vgamut,Input - Panasonic - Linear - V-Gamut",scene-linear,file-io
3131
135,Log3G10 REDWideGamutRGB,TRUE,urn:ampas:aces:transformId:v2.0:CSC.Red.Log3G10_RWG_to_ACES.a2.v1,urn:aswf:ocio:transformId:1.0:RED:Input:Log3G10_REDWideGamutRGB_to_ACES2065-1:1.0,ColorSpace,,"rl3g10_rwg,Input - RED - REDLog3G10 - REDWideGamutRGB",log,file-io
32-
140,Linear S-Gamut3,TRUE,,urn:aswf:ocio:transformId:1.0:Sony:Input:Linear_SGamut3_to_ACES2065-1:1.0,ColorSpace,,"lin_sgamut3,Input - Sony - Linear - S-Gamut3",scene-linear,file-io
33-
140,S-Log3 - Curve,TRUE,,urn:aswf:ocio:transformId:1.0:Sony:Input:SLog3-Curve_to_Linear:1.0,NamedTransform,,"crv_slog3,Input - Sony - Curve - S-Log3",log,file-io
32+
135,V-Log - Curve,TRUE,,urn:aswf:ocio:transformId:1.0:Panasonic:Input:VLog-Curve_to_Linear:1.0,NamedTransform,,"crv_vlog,Input - Panasonic - Curve - V-Log",log,file-io
33+
140,Linear REDWideGamutRGB,TRUE,,urn:aswf:ocio:transformId:1.0:RED:Input:Linear_REDWideGamutRGB_to_ACES2065-1:1.0,ColorSpace,,"lin_rwg,Input - RED - Linear - REDWideGamutRGB",scene-linear,file-io
34+
140,Log3G10 - Curve,TRUE,,urn:aswf:ocio:transformId:1.0:RED:Input:Log3G10-Curve_to_Linear:1.0,NamedTransform,,"crv_rl3g10,Input - RED - Curve - REDLog3G10",log,file-io
3435
140,S-Log3 S-Gamut3,TRUE,urn:ampas:aces:transformId:v2.0:CSC.Sony.SLog3_SGamut3_to_ACES.a2.v1,urn:aswf:ocio:transformId:1.0:Sony:Input:SLog3_SGamut3_to_ACES2065-1:1.0,ColorSpace,,"slog3_sgamut3,Input - Sony - S-Log3 - S-Gamut3",log,file-io
35-
141,Linear S-Gamut3.Cine,TRUE,,urn:aswf:ocio:transformId:1.0:Sony:Input:Linear_SGamut3Cine_to_ACES2065-1:1.0,ColorSpace,,"lin_sgamut3cine,Input - Sony - Linear - S-Gamut3.Cine",scene-linear,file-io
3636
141,S-Log3 S-Gamut3.Cine,TRUE,urn:ampas:aces:transformId:v2.0:CSC.Sony.SLog3_SGamut3Cine_to_ACES.a2.v1,urn:aswf:ocio:transformId:1.0:Sony:Input:SLog3_SGamut3Cine_to_ACES2065-1:1.0,ColorSpace,,"slog3_sgamutcine,Input - Sony - S-Log3 - S-Gamut3.Cine",log,file-io
37-
142,Linear Venice S-Gamut3,TRUE,,urn:aswf:ocio:transformId:1.0:Sony:Input:Linear_Venice_SGamut3_to_ACES2065-1:1.0,ColorSpace,,"lin_venice_sgamut3,Input - Sony - Linear - Venice S-Gamut3",scene-linear,file-io
3837
142,S-Log3 Venice S-Gamut3,TRUE,urn:ampas:aces:transformId:v2.0:CSC.Sony.Venice_SLog3_SGamut3_to_ACES.a2.v1,urn:aswf:ocio:transformId:1.0:Sony:Input:SLog3_Venice_SGamut3_to_ACES2065-1:1.0,ColorSpace,,"slog3_venice_sgamut3,Input - Sony - S-Log3 - Venice S-Gamut3",log,file-io
39-
143,Linear Venice S-Gamut3.Cine,TRUE,,urn:aswf:ocio:transformId:1.0:Sony:Input:Linear_Venice_SGamut3Cine_to_ACES2065-1:1.0,ColorSpace,,"lin_venice_sgamut3cine,Input - Sony - Linear - Venice S-Gamut3.Cine",scene-linear,file-io
4038
143,S-Log3 Venice S-Gamut3.Cine,TRUE,urn:ampas:aces:transformId:v2.0:CSC.Sony.Venice_SLog3_SGamut3Cine_to_ACES.a2.v1,urn:aswf:ocio:transformId:1.0:Sony:Input:SLog3_Venice_SGamut3Cine_to_ACES2065-1:1.0,ColorSpace,,"slog3_venice_sgamutcine,Input - Sony - S-Log3 - Venice S-Gamut3.Cine",log,file-io
39+
145,Linear S-Gamut3,TRUE,,urn:aswf:ocio:transformId:1.0:Sony:Input:Linear_SGamut3_to_ACES2065-1:1.0,ColorSpace,,"lin_sgamut3,Input - Sony - Linear - S-Gamut3",scene-linear,file-io
40+
145,S-Log3 - Curve,TRUE,,urn:aswf:ocio:transformId:1.0:Sony:Input:SLog3-Curve_to_Linear:1.0,NamedTransform,,"crv_slog3,Input - Sony - Curve - S-Log3",log,file-io
41+
146,Linear S-Gamut3.Cine,TRUE,,urn:aswf:ocio:transformId:1.0:Sony:Input:Linear_SGamut3Cine_to_ACES2065-1:1.0,ColorSpace,,"lin_sgamut3cine,Input - Sony - Linear - S-Gamut3.Cine",scene-linear,file-io
42+
147,Linear Venice S-Gamut3,TRUE,,urn:aswf:ocio:transformId:1.0:Sony:Input:Linear_Venice_SGamut3_to_ACES2065-1:1.0,ColorSpace,,"lin_venice_sgamut3,Input - Sony - Linear - Venice S-Gamut3",scene-linear,file-io
43+
148,Linear Venice S-Gamut3.Cine,TRUE,,urn:aswf:ocio:transformId:1.0:Sony:Input:Linear_Venice_SGamut3Cine_to_ACES2065-1:1.0,ColorSpace,,"lin_venice_sgamut3cine,Input - Sony - Linear - Venice S-Gamut3.Cine",scene-linear,file-io
4144
300,ACES 1.3 Reference Gamut Compression,FALSE,urn:ampas:aces:transformId:v2.0:Look.Academy.ReferenceGamutCompress.a2.v1,,Look,,,scene-linear,
4245
300,SDR Tonescale Match,FALSE,urn:ampas:aces:transformId:v2.0:Look.Academy.v1_SDR_Tonescale_Match.a2.v1,,Look,,,scene-linear,
4346
400,Rec709-D65_100nit_in_Rec709-D65_sRGB-Piecewise,FALSE,urn:ampas:aces:transformId:v2.0:Output.Academy.Rec709-D65_100nit_in_Rec709-D65_sRGB-Piecewise.a2.v1,,ViewTransform,ACES-OUTPUT - ACES2065-1_to_CIE-XYZ-D65 - SDR-100nit-REC709_2.0,,sdr-video,file-io

0 commit comments

Comments
 (0)