Skip to content

Commit 0a29193

Browse files
committed
pyocioamf: Fix CDL element naming and simplify ACES colorspace lookup
- Remove incorrect AMF version association with CDL element names. SOPNode/SatNode and ASC_SOP/ASC_SAT are both valid ASC CDL naming conventions, not version-specific. - Simplify ACES2065-1 colorspace detection to use the aces_interchange role, which is defined in all standard ACES configs. - Update README to clarify CDL element naming conventions. Signed-off-by: giardiello <[email protected]>
1 parent 3d9cf38 commit 0a29193

File tree

2 files changed

+11
-38
lines changed

2 files changed

+11
-38
lines changed

src/apps/pyocioamf/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ The CTF may then be used with any of the other OCIO tools to process pixels.
1010
**Supports both AMF v1.0 and v2.0** with automatic version detection.
1111

1212
Example files are provided:
13-
- ``example.amf`` - AMF v1.0 format
14-
- ``example_v2.amf`` - AMF v2.0 format (uses ``ASC_SOP``/``ASC_SAT`` elements)
13+
- ``example.amf`` - AMF v1.0 format, references ``example_referenced_lut.clf``
14+
- ``example_v2.amf`` - AMF v2.0 format
1515

16-
Both reference the LUT file ``example_referenced_lut.clf``, which is in the
17-
Academy/ASC Common LUT Format (CLF).
16+
The referenced LUT file is in the Academy/ASC Common LUT Format (CLF).
1817

1918
Usage
2019
-----
@@ -56,7 +55,7 @@ Implementation notes
5655
--------------------
5756

5857
* Automatically detects AMF version (v1.0 or v2.0) from namespace URI or version attribute
59-
* Supports both v1.0 element names (``SOPNode``/``SatNode``) and v2.0 names (``ASC_SOP``/``ASC_SAT``)
58+
* Supports both ASC CDL element naming conventions (``SOPNode``/``SatNode`` and ``ASC_SOP``/``ASC_SAT``)
6059
* Uses a prototype ACES config ``config-aces-reference.yaml`` to interpret the
6160
ACES Transform IDs encountered in the AMF file. This file should be in the
6261
same directory as the script.

src/apps/pyocioamf/pyocioamf.py

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030
import PyOpenColorIO as ocio
3131

3232

33-
# Default color space name for ACES2065-1 (may vary by config)
34-
# Common names: 'ACES - ACES2065-1' (old configs), 'ACES2065-1' (new configs)
35-
DEFAULT_ACES_NAMES = ['ACES2065-1', 'ACES - ACES2065-1']
36-
3733
# Namespace URIs for AMF versions
3834
AMF_NS_V1 = 'urn:ampas:aces:amf:v1.0'
3935
AMF_NS_V2 = 'urn:ampas:aces:amf:v2.0'
@@ -61,33 +57,11 @@ def get_ocio_major_minor_version(config):
6157
def find_aces_colorspace_name(config):
6258
"""
6359
Find the ACES2065-1 colorspace name in the config.
64-
Different configs may use different names for the same colorspace.
60+
Uses the aces_interchange role which is defined in all ACES configs.
6561
"""
66-
# First try the aces_interchange role
67-
try:
68-
role_cs = config.getColorSpaceNameByRole('aces_interchange')
69-
if role_cs:
70-
return role_cs
71-
except:
72-
pass
73-
74-
# Fall back to searching for common names
75-
for name in DEFAULT_ACES_NAMES:
76-
try:
77-
cs = config.getColorSpace(name)
78-
if cs is not None:
79-
return name
80-
except:
81-
continue
82-
83-
# Last resort: search by alias
84-
for cs in config.getColorSpaces():
85-
aliases = cs.getAliases() if hasattr(cs, 'getAliases') else []
86-
for alias in aliases:
87-
if 'aces2065' in alias.lower() or alias in DEFAULT_ACES_NAMES:
88-
return cs.getName()
89-
90-
# Default fallback
62+
if config.hasRole('aces_interchange'):
63+
return config.getRoleColorSpace('aces_interchange')
64+
# Fallback for non-standard configs
9165
return 'ACES2065-1'
9266

9367

@@ -334,15 +308,15 @@ def extract_three_floats(elem):
334308

335309
def parse_cdl(look_elem, amf_version):
336310
""" Return the CDL slope, offset, power, and saturation values from a look element.
337-
Supports both AMF v1.0 (SOPNode/SatNode) and v2.0 (ASC_SOP/ASC_SAT) element names.
311+
Supports both ASC CDL element naming conventions: SOPNode/SatNode and ASC_SOP/ASC_SAT.
338312
"""
339313
slopes = [1., 1., 1.]
340314
offsets = [0., 0., 0.]
341315
powers = [1., 1., 1.]
342316
sat = 1.
343317
has_cdl = False
344318

345-
# Try v2.0 element names first (ASC_SOP), then fall back to v1.0 (SOPNode)
319+
# Support both ASC CDL element naming conventions
346320
sop_elem = look_elem.find('./cdl:ASC_SOP', namespaces=NS)
347321
if sop_elem is None:
348322
sop_elem = look_elem.find('./cdl:SOPNode', namespaces=NS)
@@ -359,7 +333,7 @@ def parse_cdl(look_elem, amf_version):
359333
powers = extract_three_floats(power_elem)
360334
has_cdl = True
361335

362-
# Try v2.0 element names first (ASC_SAT), then fall back to v1.0 (SatNode)
336+
# Support both ASC CDL saturation element naming conventions
363337
sat_elem = look_elem.find('./cdl:ASC_SAT', namespaces=NS)
364338
if sat_elem is None:
365339
sat_elem = look_elem.find('./cdl:SatNode', namespaces=NS)

0 commit comments

Comments
 (0)