2 # -*- coding: utf-8 -*-
5 Implements support for *ACES* colorspaces conversions and transfer functions.
15 import PyOpenColorIO as ocio
17 from aces_ocio.generate_lut import (
18 generate_1d_LUT_from_CTL,
19 generate_3d_LUT_from_CTL,
21 from aces_ocio.utilities import (
28 __author__ = 'ACES Developers'
29 __copyright__ = 'Copyright (C) 2014 - 2015 - ACES Developers'
31 __maintainer__ = 'ACES Developers'
32 __email__ = 'aces@oscars.org'
33 __status__ = 'Production'
35 __all__ = ['ACES_AP1_TO_AP0',
43 'create_ACES_RRT_plus_ODT',
52 # Matrix converting *ACES AP1* primaries to *AP0*.
53 ACES_AP1_TO_AP0 = [0.6954522414, 0.1406786965, 0.1638690622,
54 0.0447945634, 0.8596711185, 0.0955343182,
55 -0.0055258826, 0.0040252103, 1.0015006723]
57 # Matrix converting *ACES AP0* primaries to *XYZ*.
58 ACES_AP0_TO_XYZ = [0.9525523959, 0.0000000000, 0.0000936786,
59 0.3439664498, 0.7281660966, -0.0721325464,
60 0.0000000000, 0.0000000000, 1.0088251844]
70 Parameter description.
75 Return value description.
78 # Defining the reference colorspace.
79 aces2065_1 = ColorSpace('ACES2065-1')
80 aces2065_1.description = (
81 'The Academy Color Encoding System reference color space')
82 aces2065_1.equality_group = ''
83 aces2065_1.aliases = ["lin_ap0", "aces"]
84 aces2065_1.family = 'ACES'
85 aces2065_1.is_data = False
86 aces2065_1.allocation_type = ocio.Constants.ALLOCATION_LG2
87 aces2065_1.allocation_vars = [-15, 6]
92 def create_ACEScc(aces_ctl_directory,
101 Creates the *ACEScc* colorspace.
106 Parameter description.
114 cs = ColorSpace(name)
115 cs.description = 'The %s color space' % name
116 cs.aliases = ["acescc_ap1"]
117 cs.equality_group = ''
121 ctls = [os.path.join(aces_ctl_directory,
123 'ACEScsc.ACEScc_to_ACES.a1.0.0.ctl'),
124 # This transform gets back to the *AP1* primaries.
125 # Useful as the 1d LUT is only covering the transfer function.
126 # The primaries switch is covered by the matrix below:
127 os.path.join(aces_ctl_directory,
129 'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')]
130 lut = '%s_to_ACES.spi1d' % name
134 generate_1d_LUT_from_CTL(
135 os.path.join(lut_directory, lut),
147 cs.to_reference_transforms = []
148 cs.to_reference_transforms.append({
151 'interpolation': 'linear',
152 'direction': 'forward'})
154 # *AP1* primaries to *AP0* primaries.
155 cs.to_reference_transforms.append({
157 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
158 'direction': 'forward'})
160 cs.from_reference_transforms = []
164 def create_ACESproxy(aces_ctl_directory,
170 Creates the *ACESproxy* colorspace.
175 Parameter description.
180 *ACESproxy* colorspace.
183 cs = ColorSpace(name)
184 cs.description = 'The %s color space' % name
185 cs.aliases = ["acesproxy_ap1"]
186 cs.equality_group = ''
190 ctls = [os.path.join(aces_ctl_directory,
192 'ACEScsc.ACESproxy10i_to_ACES.a1.0.0.ctl'),
193 # This transform gets back to the *AP1* primaries.
194 # Useful as the 1d LUT is only covering the transfer function.
195 # The primaries switch is covered by the matrix below:
196 os.path.join(aces_ctl_directory,
198 'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')]
199 lut = '%s_to_aces.spi1d' % name
203 generate_1d_LUT_from_CTL(
204 os.path.join(lut_directory, lut),
214 cs.to_reference_transforms = []
215 cs.to_reference_transforms.append({
218 'interpolation': 'linear',
219 'direction': 'forward'})
221 # *AP1* primaries to *AP0* primaries.
222 cs.to_reference_transforms.append({
224 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
225 'direction': 'forward'})
227 cs.from_reference_transforms = []
231 # -------------------------------------------------------------------------
233 # -------------------------------------------------------------------------
234 def create_ACEScg(aces_ctl_directory,
240 Creates the *ACEScg* colorspace.
245 Parameter description.
253 cs = ColorSpace(name)
254 cs.description = 'The %s color space' % name
255 cs.aliases = ["lin_ap1"]
256 cs.equality_group = ''
260 cs.to_reference_transforms = []
262 # *AP1* primaries to *AP0* primaries.
263 cs.to_reference_transforms.append({
265 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
266 'direction': 'forward'})
268 cs.from_reference_transforms = []
272 # -------------------------------------------------------------------------
274 # -------------------------------------------------------------------------
275 def create_ADX(lut_directory,
280 Creates the *ADX* colorspace.
285 Parameter description.
293 name = '%s%s' % (name, bit_depth)
294 cs = ColorSpace(name)
295 cs.description = '%s color space - used for film scans' % name
296 cs.aliases = ["adx%s" % str(bit_depth)]
297 cs.equality_group = ''
302 cs.bit_depth = ocio.Constants.BIT_DEPTH_UINT10
303 ADX_to_CDD = [1023.0 / 500.0, 0.0, 0.0, 0.0,
304 0.0, 1023.0 / 500.0, 0.0, 0.0,
305 0.0, 0.0, 1023.0 / 500.0, 0.0,
307 offset = [-95.0 / 500.0, -95.0 / 500.0, -95.0 / 500.0, 0.0]
308 elif bit_depth == 16:
309 cs.bit_depth = ocio.Constants.BIT_DEPTH_UINT16
310 ADX_to_CDD = [65535.0 / 8000.0, 0.0, 0.0, 0.0,
311 0.0, 65535.0 / 8000.0, 0.0, 0.0,
312 0.0, 0.0, 65535.0 / 8000.0, 0.0,
314 offset = [-1520.0 / 8000.0, -1520.0 / 8000.0, -1520.0 / 8000.0, 0.0]
316 cs.to_reference_transforms = []
318 # Converting from *ADX* to *Channel-Dependent Density*.
319 cs.to_reference_transforms.append({
321 'matrix': ADX_to_CDD,
323 'direction': 'forward'})
325 # Convert from Channel-Dependent Density to Channel-Independent Density
326 cs.to_reference_transforms.append({
328 'matrix': [0.75573, 0.22197, 0.02230, 0,
329 0.05901, 0.96928, -0.02829, 0,
330 0.16134, 0.07406, 0.76460, 0,
332 'direction': 'forward'})
334 # Copied from *Alex Fry*'s *adx_cid_to_rle.py*
335 def create_CID_to_RLE_LUT():
337 def interpolate_1D(x, xp, fp):
338 return numpy.interp(x, xp, fp)
340 LUT_1D_xp = [-0.190000000000000,
352 LUT_1D_fp = [-6.000000000000000,
364 REF_PT = ((7120.0 - 1520.0) / 8000.0 * (100.0 / 55.0) -
365 math.log(0.18, 10.0))
369 return interpolate_1D(x, LUT_1D_xp, LUT_1D_fp)
370 return (100.0 / 55.0) * x - REF_PT
372 def fit(value, from_min, from_max, to_min, to_max):
373 if from_min == from_max:
374 raise ValueError('from_min == from_max')
375 return (value - from_min) / (from_max - from_min) * (
376 to_max - to_min) + to_min
378 num_samples = 2 ** 12
379 domain = (-0.19, 3.0)
381 for i in xrange(num_samples):
382 x = i / (num_samples - 1.0)
383 x = fit(x, 0.0, 1.0, domain[0], domain[1])
384 data.append(cid_to_rle(x))
386 lut = 'ADX_CID_to_RLE.spi1d'
387 write_SPI_1d(os.path.join(lut_directory, lut),
395 # Converting *Channel Independent Density* values to
396 # *Relative Log Exposure* values.
397 lut = create_CID_to_RLE_LUT()
398 cs.to_reference_transforms.append({
401 'interpolation': 'linear',
402 'direction': 'forward'})
404 # Converting *Relative Log Exposure* values to
405 # *Relative Exposure* values.
406 cs.to_reference_transforms.append({
409 'direction': 'inverse'})
411 # Convert *Relative Exposure* values to *ACES* values.
412 cs.to_reference_transforms.append({
414 'matrix': [0.72286, 0.12630, 0.15084, 0,
415 0.11923, 0.76418, 0.11659, 0,
416 0.01427, 0.08213, 0.90359, 0,
418 'direction': 'forward'})
420 cs.from_reference_transforms = []
424 def create_ACES_LMT(lmt_name,
429 lut_resolution_1d=1024,
430 lut_resolution_3d=64,
434 Creates the *ACES LMT* colorspace.
439 Parameter description.
444 *ACES LMT* colorspace.
447 cs = ColorSpace('%s' % lmt_name)
448 cs.description = 'The ACES Look Transform: %s' % lmt_name
450 cs.equality_group = ''
454 pprint.pprint(lmt_values)
456 # Generating the *shaper* transform.
459 shaper_from_ACES_CTL,
461 shaper_params) = shaper_info
463 shaper_lut = '%s_to_aces.spi1d' % shaper_name
464 if not os.path.exists(os.path.join(lut_directory, shaper_lut)):
465 ctls = [shaper_to_ACES_CTL % aces_ctl_directory]
467 shaper_lut = sanitize(shaper_lut)
469 generate_1d_LUT_from_CTL(
470 os.path.join(lut_directory, shaper_lut),
474 1.0 / shaper_input_scale,
480 shaper_OCIO_transform = {
483 'interpolation': 'linear',
484 'direction': 'inverse'}
486 # Generating the forward transform.
487 cs.from_reference_transforms = []
489 if 'transformCTL' in lmt_values:
490 ctls = [shaper_to_ACES_CTL % aces_ctl_directory,
491 os.path.join(aces_ctl_directory,
492 lmt_values['transformCTL'])]
493 lut = '%s.%s.spi3d' % (shaper_name, lmt_name)
497 generate_3d_LUT_from_CTL(
498 os.path.join(lut_directory, lut),
502 1.0 / shaper_input_scale,
508 cs.from_reference_transforms.append(shaper_OCIO_transform)
509 cs.from_reference_transforms.append({
512 'interpolation': 'tetrahedral',
513 'direction': 'forward'})
515 # Generating the inverse transform.
516 cs.to_reference_transforms = []
518 if 'transformCTLInverse' in lmt_values:
519 ctls = [os.path.join(aces_ctl_directory,
520 # TODO: Investigate "odt_values" undeclared
522 odt_values['transformCTLInverse']),
523 shaper_from_ACES_CTL % aces_ctl_directory]
524 lut = 'Inverse.%s.%s.spi3d' % (odt_name, shaper_name)
528 generate_3d_LUT_from_CTL(
529 os.path.join(lut_directory, lut),
539 cs.to_reference_transforms.append({
542 'interpolation': 'tetrahedral',
543 'direction': 'forward'})
545 shaper_inverse = shaper_OCIO_transform.copy()
546 shaper_inverse['direction'] = 'forward'
547 cs.to_reference_transforms.append(shaper_inverse)
552 def create_ACES_RRT_plus_ODT(odt_name,
557 lut_resolution_1d=1024,
558 lut_resolution_3d=64,
567 Parameter description.
572 Return value description.
575 cs = ColorSpace('%s' % odt_name)
576 cs.description = '%s - %s Output Transform' % (
577 odt_values['transformUserNamePrefix'], odt_name)
579 cs.equality_group = ''
583 pprint.pprint(odt_values)
585 # Generating the *shaper* transform.
588 shaper_from_ACES_CTL,
590 shaper_params) = shaper_info
592 if 'legalRange' in odt_values:
593 shaper_params['legalRange'] = odt_values['legalRange']
595 shaper_params['legalRange'] = 0
597 shaper_lut = '%s_to_aces.spi1d' % shaper_name
598 if not os.path.exists(os.path.join(lut_directory, shaper_lut)):
599 ctls = [shaper_to_ACES_CTL % aces_ctl_directory]
601 shaper_lut = sanitize(shaper_lut)
603 generate_1d_LUT_from_CTL(
604 os.path.join(lut_directory, shaper_lut),
608 1.0 / shaper_input_scale,
614 shaper_OCIO_transform = {
617 'interpolation': 'linear',
618 'direction': 'inverse'}
620 # Generating the *forward* transform.
621 cs.from_reference_transforms = []
623 if 'transformLUT' in odt_values:
624 transform_LUT_file_name = os.path.basename(
625 odt_values['transformLUT'])
626 lut = os.path.join(lut_directory, transform_LUT_file_name)
627 shutil.copy(odt_values['transformLUT'], lut)
629 cs.from_reference_transforms.append(shaper_OCIO_transform)
630 cs.from_reference_transforms.append({
632 'path': transform_LUT_file_name,
633 'interpolation': 'tetrahedral',
634 'direction': 'forward'})
635 elif 'transformCTL' in odt_values:
637 shaper_to_ACES_CTL % aces_ctl_directory,
638 os.path.join(aces_ctl_directory,
641 os.path.join(aces_ctl_directory,
643 odt_values['transformCTL'])]
644 lut = '%s.RRT.a1.0.0.%s.spi3d' % (shaper_name, odt_name)
648 generate_3d_LUT_from_CTL(
649 os.path.join(lut_directory, lut),
654 1.0 / shaper_input_scale,
660 cs.from_reference_transforms.append(shaper_OCIO_transform)
661 cs.from_reference_transforms.append({
664 'interpolation': 'tetrahedral',
665 'direction': 'forward'})
667 # Generating the *inverse* transform.
668 cs.to_reference_transforms = []
670 if 'transformLUTInverse' in odt_values:
671 transform_LUT_inverse_file_name = os.path.basename(
672 odt_values['transformLUTInverse'])
673 lut = os.path.join(lut_directory, transform_LUT_inverse_file_name)
674 shutil.copy(odt_values['transformLUTInverse'], lut)
676 cs.to_reference_transforms.append({
678 'path': transform_LUT_inverse_file_name,
679 'interpolation': 'tetrahedral',
680 'direction': 'forward'})
682 shaper_inverse = shaper_OCIO_transform.copy()
683 shaper_inverse['direction'] = 'forward'
684 cs.to_reference_transforms.append(shaper_inverse)
685 elif 'transformCTLInverse' in odt_values:
686 ctls = [os.path.join(aces_ctl_directory,
688 odt_values['transformCTLInverse']),
689 os.path.join(aces_ctl_directory,
691 'InvRRT.a1.0.0.ctl'),
692 shaper_from_ACES_CTL % aces_ctl_directory]
693 lut = 'InvRRT.a1.0.0.%s.%s.spi3d' % (odt_name, shaper_name)
697 generate_3d_LUT_from_CTL(
698 os.path.join(lut_directory, lut),
709 cs.to_reference_transforms.append({
712 'interpolation': 'tetrahedral',
713 'direction': 'forward'})
715 shaper_inverse = shaper_OCIO_transform.copy()
716 shaper_inverse['direction'] = 'forward'
717 cs.to_reference_transforms.append(shaper_inverse)
722 def create_generic_log(aces_ctl_directory,
735 Creates the *Generic Log* colorspace.
740 Parameter description.
745 *Generic Log* colorspace.
748 cs = ColorSpace(name)
749 cs.description = 'The %s color space' % name
751 cs.equality_group = name
752 cs.family = 'Utility'
755 ctls = [os.path.join(
758 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl')]
759 lut = '%s_to_aces.spi1d' % name
763 generate_1d_LUT_from_CTL(
764 os.path.join(lut_directory, lut),
770 {'middleGrey': middle_grey,
771 'minExposure': min_exposure,
772 'maxExposure': max_exposure},
778 cs.to_reference_transforms = []
779 cs.to_reference_transforms.append({
782 'interpolation': 'linear',
783 'direction': 'forward'})
785 cs.from_reference_transforms = []
789 def create_LMTs(aces_ctl_directory,
802 Parameter description.
807 Return value description.
812 # -------------------------------------------------------------------------
814 # -------------------------------------------------------------------------
815 lmt_lut_resolution_1d = max(4096, lut_resolution_1d)
816 lmt_lut_resolution_3d = max(65, lut_resolution_3d)
818 # Defining the *Log 2* shaper.
819 lmt_shaper_name = 'LMT Shaper'
820 lmt_shaper_name_aliases = ['crv_lmtshaper']
823 'minExposure': -10.0,
826 lmt_shaper = create_generic_log(aces_ctl_directory,
828 lmt_lut_resolution_1d,
830 name=lmt_shaper_name,
831 middle_grey=lmt_params['middleGrey'],
832 min_exposure=lmt_params['minExposure'],
833 max_exposure=lmt_params['maxExposure'],
834 aliases=lmt_shaper_name_aliases)
835 colorspaces.append(lmt_shaper)
837 shaper_input_scale_generic_log2 = 1.0
839 # *Log 2* shaper name and *CTL* transforms bundled up.
844 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl'),
847 'ACESlib.OCIO_shaper_lin_to_log2_param.a1.0.0.ctl'),
848 shaper_input_scale_generic_log2,
851 sorted_LMTs = sorted(lmt_info.iteritems(), key=lambda x: x[1])
853 for lmt in sorted_LMTs:
854 lmt_name, lmt_values = lmt
855 lmt_aliases = ["look_%s" % compact(lmt_values['transformUserName'])]
856 cs = create_ACES_LMT(
857 lmt_values['transformUserName'],
862 lmt_lut_resolution_1d,
863 lmt_lut_resolution_3d,
866 colorspaces.append(cs)
871 def create_ODTs(aces_ctl_directory,
878 linear_display_space,
886 Parameter description.
891 Return value description.
897 # -------------------------------------------------------------------------
898 # *RRT / ODT* Shaper Options
899 # -------------------------------------------------------------------------
902 # Defining the *Log 2* shaper.
903 log2_shaper_name = shaper_name
904 log2_shaper_name_aliases = ["crv_%s" % compact(shaper_name)]
910 log2_shaper = create_generic_log(
915 name=log2_shaper_name,
916 middle_grey=log2_params['middleGrey'],
917 min_exposure=log2_params['minExposure'],
918 max_exposure=log2_params['maxExposure'],
919 aliases=log2_shaper_name_aliases)
920 colorspaces.append(log2_shaper)
922 shaper_input_scale_generic_log2 = 1.0
924 # *Log 2* shaper name and *CTL* transforms bundled up.
929 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl'),
932 'ACESlib.OCIO_shaper_lin_to_log2_param.a1.0.0.ctl'),
933 shaper_input_scale_generic_log2,
936 shaper_data[log2_shaper_name] = log2_shaper_data
938 # Shaper that also includes the AP1 primaries.
939 # Needed for some LUT baking steps.
940 log2_shaper_api1_name_aliases = ["%s_ap1" % compact(shaper_name)]
941 log2_shaper_ap1 = create_generic_log(
946 name=log2_shaper_name,
947 middle_grey=log2_params['middleGrey'],
948 min_exposure=log2_params['minExposure'],
949 max_exposure=log2_params['maxExposure'],
950 aliases=log2_shaper_api1_name_aliases)
951 log2_shaper_ap1.name = '%s - AP1' % log2_shaper_ap1.name
953 # *AP1* primaries to *AP0* primaries.
954 log2_shaper_ap1.to_reference_transforms.append({
956 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
957 'direction': 'forward'
959 colorspaces.append(log2_shaper_ap1)
961 rrt_shaper = log2_shaper_data
963 # *RRT + ODT* combinations.
964 sorted_odts = sorted(odt_info.iteritems(), key=lambda x: x[1])
966 for odt in sorted_odts:
967 (odt_name, odt_values) = odt
969 # Generating legal range transform for *ODTs* that can generate
970 # either *legal* or *full* output.
971 if odt_values['transformHasFullLegalSwitch']:
972 odt_name_legal = '%s - Legal' % odt_values['transformUserName']
974 odt_name_legal = odt_values['transformUserName']
976 odt_legal = odt_values.copy()
977 odt_legal['legalRange'] = 1
979 odt_aliases = ["out_%s" % compact(odt_name_legal)]
981 cs = create_ACES_RRT_plus_ODT(
991 colorspaces.append(cs)
993 displays[odt_name_legal] = {
994 'Linear': linear_display_space,
995 'Log': log_display_space,
996 'Output Transform': cs}
999 # Generating full range transform for *ODTs* that can generate
1000 # either *legal* or *full* output.
1001 if odt_values['transformHasFullLegalSwitch']:
1002 print('Generating full range ODT for %s' % odt_name)
1004 odt_name_full = '%s - Full' % odt_values['transformUserName']
1005 odt_full = odt_values.copy()
1006 odt_full['legalRange'] = 0
1008 odt_full_aliases = ["out_%s" % compact(odt_name_full)]
1010 cs_full = create_ACES_RRT_plus_ODT(
1020 colorspaces.append(cs_full)
1022 displays[odt_name_full] = {
1023 'Linear': linear_display_space,
1024 'Log': log_display_space,
1025 'Output Transform': cs_full}
1027 return (colorspaces, displays)
1030 def get_transform_info(ctl_transform):
1037 Parameter description.
1042 Return value description.
1045 with open(ctl_transform, 'rb') as fp:
1046 lines = fp.readlines()
1048 # Retrieving the *transform ID* and *User Name*.
1049 transform_id = lines[1][3:].split('<')[1].split('>')[1].strip()
1050 transform_user_name = '-'.join(
1051 lines[2][3:].split('<')[1].split('>')[1].split('-')[1:]).strip()
1052 transform_user_name_prefix = (
1053 lines[2][3:].split('<')[1].split('>')[1].split('-')[0].strip())
1055 # Figuring out if this transform has options for processing full and legal range
1056 transform_full_legal_switch = False
1058 if line.strip() == "input varying int legalRange = 0":
1059 # print( "%s has legal range flag" % transform_user_name)
1060 transform_full_legal_switch = True
1063 return (transform_id, transform_user_name, transform_user_name_prefix,
1064 transform_full_legal_switch)
1067 def get_ODTs_info(aces_ctl_directory):
1071 For versions after WGR9.
1076 Parameter description.
1081 Return value description.
1084 # TODO: Investigate usage of *files_walker* definition here.
1085 # Credit to *Alex Fry* for the original approach here.
1086 odt_dir = os.path.join(aces_ctl_directory, 'odt')
1088 for dir_name, subdir_list, file_list in os.walk(odt_dir):
1089 for fname in file_list:
1090 all_odt.append((os.path.join(dir_name, fname)))
1092 odt_CTLs = [x for x in all_odt if
1093 ('InvODT' not in x) and (os.path.split(x)[-1][0] != '.')]
1097 for odt_CTL in odt_CTLs:
1098 odt_tokens = os.path.split(odt_CTL)
1100 # Handling nested directories.
1101 odt_path_tokens = os.path.split(odt_tokens[-2])
1102 odt_dir = odt_path_tokens[-1]
1103 while odt_path_tokens[-2][-3:] != 'odt':
1104 odt_path_tokens = os.path.split(odt_path_tokens[-2])
1105 odt_dir = os.path.join(odt_path_tokens[-1], odt_dir)
1107 # Building full name,
1108 transform_CTL = odt_tokens[-1]
1109 odt_name = string.join(transform_CTL.split('.')[1:-1], '.')
1111 # Finding id, user name and user name prefix.
1113 transform_user_name,
1114 transform_user_name_prefix,
1115 transform_full_legal_switch) = get_transform_info(
1116 os.path.join(aces_ctl_directory, 'odt', odt_dir, transform_CTL))
1119 transform_CTL_inverse = 'InvODT.%s.ctl' % odt_name
1120 if not os.path.exists(
1121 os.path.join(odt_tokens[-2], transform_CTL_inverse)):
1122 transform_CTL_inverse = None
1124 # Add to list of ODTs
1126 odts[odt_name]['transformCTL'] = os.path.join(odt_dir, transform_CTL)
1127 if transform_CTL_inverse is not None:
1128 odts[odt_name]['transformCTLInverse'] = os.path.join(
1129 odt_dir, transform_CTL_inverse)
1131 odts[odt_name]['transformID'] = transform_ID
1132 odts[odt_name]['transformUserNamePrefix'] = transform_user_name_prefix
1133 odts[odt_name]['transformUserName'] = transform_user_name
1135 'transformHasFullLegalSwitch'] = transform_full_legal_switch
1137 forward_CTL = odts[odt_name]['transformCTL']
1139 print('ODT : %s' % odt_name)
1140 print('\tTransform ID : %s' % transform_ID)
1141 print('\tTransform User Name Prefix : %s' % transform_user_name_prefix)
1142 print('\tTransform User Name : %s' % transform_user_name)
1144 '\tHas Full / Legal Switch : %s' % transform_full_legal_switch)
1145 print('\tForward ctl : %s' % forward_CTL)
1146 if 'transformCTLInverse' in odts[odt_name]:
1147 inverse_CTL = odts[odt_name]['transformCTLInverse']
1148 print('\tInverse ctl : %s' % inverse_CTL)
1150 print('\tInverse ctl : %s' % 'None')
1157 def get_LMTs_info(aces_ctl_directory):
1161 For versions after WGR9.
1166 Parameter description.
1171 Return value description.
1174 # TODO: Investigate refactoring with previous definition.
1176 # Credit to Alex Fry for the original approach here
1177 lmt_dir = os.path.join(aces_ctl_directory, 'lmt')
1179 for dir_name, subdir_list, file_list in os.walk(lmt_dir):
1180 for fname in file_list:
1181 all_lmt.append((os.path.join(dir_name, fname)))
1183 lmt_CTLs = [x for x in all_lmt if
1184 ('InvLMT' not in x) and ('README' not in x) and (
1185 os.path.split(x)[-1][0] != '.')]
1189 for lmt_CTL in lmt_CTLs:
1190 lmt_tokens = os.path.split(lmt_CTL)
1192 # Handlimg nested directories.
1193 lmt_path_tokens = os.path.split(lmt_tokens[-2])
1194 lmt_dir = lmt_path_tokens[-1]
1195 while lmt_path_tokens[-2][-3:] != 'ctl':
1196 lmt_path_tokens = os.path.split(lmt_path_tokens[-2])
1197 lmt_dir = os.path.join(lmt_path_tokens[-1], lmt_dir)
1199 # Building full name.
1200 transform_CTL = lmt_tokens[-1]
1201 lmt_name = string.join(transform_CTL.split('.')[1:-1], '.')
1203 # Finding id, user name and user name prefix.
1205 transform_user_name,
1206 transform_user_name_prefix,
1207 transform_full_legal_switch) = get_transform_info(
1208 os.path.join(aces_ctl_directory, lmt_dir, transform_CTL))
1211 transform_CTL_inverse = 'InvLMT.%s.ctl' % lmt_name
1212 if not os.path.exists(
1213 os.path.join(lmt_tokens[-2], transform_CTL_inverse)):
1214 transform_CTL_inverse = None
1217 lmts[lmt_name]['transformCTL'] = os.path.join(lmt_dir, transform_CTL)
1218 if transform_CTL_inverse is not None:
1219 lmts[lmt_name]['transformCTLInverse'] = os.path.join(
1220 lmt_dir, transform_CTL_inverse)
1222 lmts[lmt_name]['transformID'] = transform_ID
1223 lmts[lmt_name]['transformUserNamePrefix'] = transform_user_name_prefix
1224 lmts[lmt_name]['transformUserName'] = transform_user_name
1226 forward_CTL = lmts[lmt_name]['transformCTL']
1228 print('LMT : %s' % lmt_name)
1229 print('\tTransform ID : %s' % transform_ID)
1230 print('\tTransform User Name Prefix : %s' % transform_user_name_prefix)
1231 print('\tTransform User Name : %s' % transform_user_name)
1232 print('\t Forward ctl : %s' % forward_CTL)
1233 if 'transformCTLInverse' in lmts[lmt_name]:
1234 inverse_CTL = lmts[lmt_name]['transformCTLInverse']
1235 print('\t Inverse ctl : %s' % inverse_CTL)
1237 print('\t Inverse ctl : %s' % 'None')
1244 def create_colorspaces(aces_ctl_directory,
1253 Generates the colorspace conversions.
1258 Parameter description.
1263 Return value description.
1268 ACES = create_ACES()
1270 ACEScc = create_ACEScc(aces_ctl_directory, lut_directory,
1271 lut_resolution_1d, cleanup)
1272 colorspaces.append(ACEScc)
1274 ACESproxy = create_ACESproxy(aces_ctl_directory, lut_directory,
1275 lut_resolution_1d, cleanup)
1276 colorspaces.append(ACESproxy)
1278 ACEScg = create_ACEScg(aces_ctl_directory, lut_directory,
1279 lut_resolution_1d, cleanup)
1280 colorspaces.append(ACEScg)
1282 ADX10 = create_ADX(lut_directory, lut_resolution_1d, bit_depth=10)
1283 colorspaces.append(ADX10)
1285 ADX16 = create_ADX(lut_directory, lut_resolution_1d, bit_depth=16)
1286 colorspaces.append(ADX16)
1288 lmts = create_LMTs(aces_ctl_directory,
1295 colorspaces.extend(lmts)
1297 odts, displays = create_ODTs(aces_ctl_directory,
1306 colorspaces.extend(odts)
1308 return ACES, colorspaces, displays, ACEScc