2 # -*- coding: utf-8 -*-
5 Implements support for *ACES* colorspaces conversions and transfer functions.
8 from __future__ import division
17 import PyOpenColorIO as ocio
19 from aces_ocio.generate_lut import (
20 generate_1d_LUT_from_CTL,
21 generate_3d_LUT_from_CTL,
23 from aces_ocio.utilities import (
30 __author__ = 'ACES Developers'
31 __copyright__ = 'Copyright (C) 2014 - 2015 - ACES Developers'
33 __maintainer__ = 'ACES Developers'
34 __email__ = 'aces@oscars.org'
35 __status__ = 'Production'
37 __all__ = ['ACES_AP1_TO_AP0',
45 'create_ACES_RRT_plus_ODT',
54 # Matrix converting *ACES AP1* primaries to *AP0*.
55 ACES_AP1_TO_AP0 = [0.6954522414, 0.1406786965, 0.1638690622,
56 0.0447945634, 0.8596711185, 0.0955343182,
57 -0.0055258826, 0.0040252103, 1.0015006723]
59 # Matrix converting *ACES AP0* primaries to *XYZ*.
60 ACES_AP0_TO_XYZ = [0.9525523959, 0.0000000000, 0.0000936786,
61 0.3439664498, 0.7281660966, -0.0721325464,
62 0.0000000000, 0.0000000000, 1.0088251844]
72 Parameter description.
77 Return value description.
80 # Defining the reference colorspace.
81 aces2065_1 = ColorSpace('ACES2065-1')
82 aces2065_1.description = (
83 'The Academy Color Encoding System reference color space')
84 aces2065_1.equality_group = ''
85 aces2065_1.aliases = ["lin_ap0", "aces"]
86 aces2065_1.family = 'ACES'
87 aces2065_1.is_data = False
88 aces2065_1.allocation_type = ocio.Constants.ALLOCATION_LG2
89 aces2065_1.allocation_vars = [-15, 6]
94 def create_ACEScc(aces_ctl_directory,
103 Creates the *ACEScc* colorspace.
108 Parameter description.
116 cs = ColorSpace(name)
117 cs.description = 'The %s color space' % name
118 cs.aliases = ["acescc_ap1"]
119 cs.equality_group = ''
123 ctls = [os.path.join(aces_ctl_directory,
125 'ACEScsc.ACEScc_to_ACES.a1.0.0.ctl'),
126 # This transform gets back to the *AP1* primaries.
127 # Useful as the 1d LUT is only covering the transfer function.
128 # The primaries switch is covered by the matrix below:
129 os.path.join(aces_ctl_directory,
131 'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')]
132 lut = '%s_to_ACES.spi1d' % name
136 generate_1d_LUT_from_CTL(
137 os.path.join(lut_directory, lut),
149 cs.to_reference_transforms = []
150 cs.to_reference_transforms.append({
153 'interpolation': 'linear',
154 'direction': 'forward'})
156 # *AP1* primaries to *AP0* primaries.
157 cs.to_reference_transforms.append({
159 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
160 'direction': 'forward'})
162 cs.from_reference_transforms = []
166 def create_ACESproxy(aces_ctl_directory,
172 Creates the *ACESproxy* colorspace.
177 Parameter description.
182 *ACESproxy* colorspace.
185 cs = ColorSpace(name)
186 cs.description = 'The %s color space' % name
187 cs.aliases = ["acesproxy_ap1"]
188 cs.equality_group = ''
192 ctls = [os.path.join(aces_ctl_directory,
194 'ACEScsc.ACESproxy10i_to_ACES.a1.0.0.ctl'),
195 # This transform gets back to the *AP1* primaries.
196 # Useful as the 1d LUT is only covering the transfer function.
197 # The primaries switch is covered by the matrix below:
198 os.path.join(aces_ctl_directory,
200 'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')]
201 lut = '%s_to_aces.spi1d' % name
205 generate_1d_LUT_from_CTL(
206 os.path.join(lut_directory, lut),
216 cs.to_reference_transforms = []
217 cs.to_reference_transforms.append({
220 'interpolation': 'linear',
221 'direction': 'forward'})
223 # *AP1* primaries to *AP0* primaries.
224 cs.to_reference_transforms.append({
226 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
227 'direction': 'forward'})
229 cs.from_reference_transforms = []
233 # -------------------------------------------------------------------------
235 # -------------------------------------------------------------------------
236 def create_ACEScg(aces_ctl_directory,
242 Creates the *ACEScg* colorspace.
247 Parameter description.
255 cs = ColorSpace(name)
256 cs.description = 'The %s color space' % name
257 cs.aliases = ["lin_ap1"]
258 cs.equality_group = ''
262 cs.to_reference_transforms = []
264 # *AP1* primaries to *AP0* primaries.
265 cs.to_reference_transforms.append({
267 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
268 'direction': 'forward'})
270 cs.from_reference_transforms = []
274 # -------------------------------------------------------------------------
276 # -------------------------------------------------------------------------
277 def create_ADX(lut_directory,
282 Creates the *ADX* colorspace.
287 Parameter description.
295 name = '%s%s' % (name, bit_depth)
296 cs = ColorSpace(name)
297 cs.description = '%s color space - used for film scans' % name
298 cs.aliases = ["adx%s" % str(bit_depth)]
299 cs.equality_group = ''
304 cs.bit_depth = ocio.Constants.BIT_DEPTH_UINT10
305 ADX_to_CDD = [1023 / 500, 0, 0, 0,
309 offset = [-95 / 500, -95 / 500, -95 / 500, 0]
310 elif bit_depth == 16:
311 cs.bit_depth = ocio.Constants.BIT_DEPTH_UINT16
312 ADX_to_CDD = [65535 / 8000, 0, 0, 0,
313 0, 65535 / 8000, 0, 0,
314 0, 0, 65535 / 8000, 0,
316 offset = [-1520 / 8000, -1520 / 8000, -1520 / 8000, 0]
318 cs.to_reference_transforms = []
320 # Converting from *ADX* to *Channel-Dependent Density*.
321 cs.to_reference_transforms.append({
323 'matrix': ADX_to_CDD,
325 'direction': 'forward'})
327 # Convert from Channel-Dependent Density to Channel-Independent Density
328 cs.to_reference_transforms.append({
330 'matrix': [0.75573, 0.22197, 0.02230, 0,
331 0.05901, 0.96928, -0.02829, 0,
332 0.16134, 0.07406, 0.76460, 0,
334 'direction': 'forward'})
336 # Copied from *Alex Fry*'s *adx_cid_to_rle.py*
337 def create_CID_to_RLE_LUT():
339 def interpolate_1D(x, xp, fp):
340 return numpy.interp(x, xp, fp)
342 LUT_1D_xp = [-0.190000000000000,
354 LUT_1D_fp = [-6.000000000000000,
366 REF_PT = ((7120 - 1520) / 8000 * (100 / 55) -
371 return interpolate_1D(x, LUT_1D_xp, LUT_1D_fp)
372 return (100 / 55) * x - REF_PT
374 def fit(value, from_min, from_max, to_min, to_max):
375 if from_min == from_max:
376 raise ValueError('from_min == from_max')
377 return (value - from_min) / (from_max - from_min) * (
378 to_max - to_min) + to_min
380 num_samples = 2 ** 12
383 for i in xrange(num_samples):
384 x = i / (num_samples - 1)
385 x = fit(x, 0, 1, domain[0], domain[1])
386 data.append(cid_to_rle(x))
388 lut = 'ADX_CID_to_RLE.spi1d'
389 write_SPI_1d(os.path.join(lut_directory, lut),
397 # Converting *Channel Independent Density* values to
398 # *Relative Log Exposure* values.
399 lut = create_CID_to_RLE_LUT()
400 cs.to_reference_transforms.append({
403 'interpolation': 'linear',
404 'direction': 'forward'})
406 # Converting *Relative Log Exposure* values to
407 # *Relative Exposure* values.
408 cs.to_reference_transforms.append({
411 'direction': 'inverse'})
413 # Convert *Relative Exposure* values to *ACES* values.
414 cs.to_reference_transforms.append({
416 'matrix': [0.72286, 0.12630, 0.15084, 0,
417 0.11923, 0.76418, 0.11659, 0,
418 0.01427, 0.08213, 0.90359, 0,
420 'direction': 'forward'})
422 cs.from_reference_transforms = []
426 def create_ACES_LMT(lmt_name,
431 lut_resolution_1d=1024,
432 lut_resolution_3d=64,
436 Creates the *ACES LMT* colorspace.
441 Parameter description.
446 *ACES LMT* colorspace.
452 cs = ColorSpace('%s' % lmt_name)
453 cs.description = 'The ACES Look Transform: %s' % lmt_name
455 cs.equality_group = ''
459 pprint.pprint(lmt_values)
461 # Generating the *shaper* transform.
464 shaper_from_ACES_CTL,
466 shaper_params) = shaper_info
468 shaper_lut = '%s_to_aces.spi1d' % shaper_name
469 if not os.path.exists(os.path.join(lut_directory, shaper_lut)):
470 ctls = [shaper_to_ACES_CTL % aces_ctl_directory]
472 shaper_lut = sanitize(shaper_lut)
474 generate_1d_LUT_from_CTL(
475 os.path.join(lut_directory, shaper_lut),
479 1 / shaper_input_scale,
485 shaper_OCIO_transform = {
488 'interpolation': 'linear',
489 'direction': 'inverse'}
491 # Generating the forward transform.
492 cs.from_reference_transforms = []
494 if 'transformCTL' in lmt_values:
495 ctls = [shaper_to_ACES_CTL % aces_ctl_directory,
496 os.path.join(aces_ctl_directory,
497 lmt_values['transformCTL'])]
498 lut = '%s.%s.spi3d' % (shaper_name, lmt_name)
502 generate_3d_LUT_from_CTL(
503 os.path.join(lut_directory, lut),
507 1 / shaper_input_scale,
513 cs.from_reference_transforms.append(shaper_OCIO_transform)
514 cs.from_reference_transforms.append({
517 'interpolation': 'tetrahedral',
518 'direction': 'forward'})
520 # Generating the inverse transform.
521 cs.to_reference_transforms = []
523 if 'transformCTLInverse' in lmt_values:
524 ctls = [os.path.join(aces_ctl_directory,
525 # TODO: Investigate "odt_values" undeclared
527 odt_values['transformCTLInverse']),
528 shaper_from_ACES_CTL % aces_ctl_directory]
529 lut = 'Inverse.%s.%s.spi3d' % (odt_name, shaper_name)
533 generate_3d_LUT_from_CTL(
534 os.path.join(lut_directory, lut),
544 cs.to_reference_transforms.append({
547 'interpolation': 'tetrahedral',
548 'direction': 'forward'})
550 shaper_inverse = shaper_OCIO_transform.copy()
551 shaper_inverse['direction'] = 'forward'
552 cs.to_reference_transforms.append(shaper_inverse)
557 def create_ACES_RRT_plus_ODT(odt_name,
562 lut_resolution_1d=1024,
563 lut_resolution_3d=64,
572 Parameter description.
577 Return value description.
583 cs = ColorSpace('%s' % odt_name)
584 cs.description = '%s - %s Output Transform' % (
585 odt_values['transformUserNamePrefix'], odt_name)
587 cs.equality_group = ''
591 pprint.pprint(odt_values)
593 # Generating the *shaper* transform.
596 shaper_from_ACES_CTL,
598 shaper_params) = shaper_info
600 if 'legalRange' in odt_values:
601 shaper_params['legalRange'] = odt_values['legalRange']
603 shaper_params['legalRange'] = 0
605 shaper_lut = '%s_to_aces.spi1d' % shaper_name
606 if not os.path.exists(os.path.join(lut_directory, shaper_lut)):
607 ctls = [shaper_to_ACES_CTL % aces_ctl_directory]
609 shaper_lut = sanitize(shaper_lut)
611 generate_1d_LUT_from_CTL(
612 os.path.join(lut_directory, shaper_lut),
616 1 / shaper_input_scale,
622 shaper_OCIO_transform = {
625 'interpolation': 'linear',
626 'direction': 'inverse'}
628 # Generating the *forward* transform.
629 cs.from_reference_transforms = []
631 if 'transformLUT' in odt_values:
632 transform_LUT_file_name = os.path.basename(
633 odt_values['transformLUT'])
634 lut = os.path.join(lut_directory, transform_LUT_file_name)
635 shutil.copy(odt_values['transformLUT'], lut)
637 cs.from_reference_transforms.append(shaper_OCIO_transform)
638 cs.from_reference_transforms.append({
640 'path': transform_LUT_file_name,
641 'interpolation': 'tetrahedral',
642 'direction': 'forward'})
643 elif 'transformCTL' in odt_values:
645 shaper_to_ACES_CTL % aces_ctl_directory,
646 os.path.join(aces_ctl_directory,
649 os.path.join(aces_ctl_directory,
651 odt_values['transformCTL'])]
652 lut = '%s.RRT.a1.0.0.%s.spi3d' % (shaper_name, odt_name)
656 generate_3d_LUT_from_CTL(
657 os.path.join(lut_directory, lut),
662 1 / shaper_input_scale,
668 cs.from_reference_transforms.append(shaper_OCIO_transform)
669 cs.from_reference_transforms.append({
672 'interpolation': 'tetrahedral',
673 'direction': 'forward'})
675 # Generating the *inverse* transform.
676 cs.to_reference_transforms = []
678 if 'transformLUTInverse' in odt_values:
679 transform_LUT_inverse_file_name = os.path.basename(
680 odt_values['transformLUTInverse'])
681 lut = os.path.join(lut_directory, transform_LUT_inverse_file_name)
682 shutil.copy(odt_values['transformLUTInverse'], lut)
684 cs.to_reference_transforms.append({
686 'path': transform_LUT_inverse_file_name,
687 'interpolation': 'tetrahedral',
688 'direction': 'forward'})
690 shaper_inverse = shaper_OCIO_transform.copy()
691 shaper_inverse['direction'] = 'forward'
692 cs.to_reference_transforms.append(shaper_inverse)
693 elif 'transformCTLInverse' in odt_values:
694 ctls = [os.path.join(aces_ctl_directory,
696 odt_values['transformCTLInverse']),
697 os.path.join(aces_ctl_directory,
699 'InvRRT.a1.0.0.ctl'),
700 shaper_from_ACES_CTL % aces_ctl_directory]
701 lut = 'InvRRT.a1.0.0.%s.%s.spi3d' % (odt_name, shaper_name)
705 generate_3d_LUT_from_CTL(
706 os.path.join(lut_directory, lut),
717 cs.to_reference_transforms.append({
720 'interpolation': 'tetrahedral',
721 'direction': 'forward'})
723 shaper_inverse = shaper_OCIO_transform.copy()
724 shaper_inverse['direction'] = 'forward'
725 cs.to_reference_transforms.append(shaper_inverse)
730 def create_generic_log(aces_ctl_directory,
743 Creates the *Generic Log* colorspace.
748 Parameter description.
753 *Generic Log* colorspace.
756 cs = ColorSpace(name)
757 cs.description = 'The %s color space' % name
759 cs.equality_group = name
760 cs.family = 'Utility'
763 ctls = [os.path.join(
766 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl')]
767 lut = '%s_to_aces.spi1d' % name
771 generate_1d_LUT_from_CTL(
772 os.path.join(lut_directory, lut),
778 {'middleGrey': middle_grey,
779 'minExposure': min_exposure,
780 'maxExposure': max_exposure},
786 cs.to_reference_transforms = []
787 cs.to_reference_transforms.append({
790 'interpolation': 'linear',
791 'direction': 'forward'})
793 cs.from_reference_transforms = []
797 def create_LMTs(aces_ctl_directory,
810 Parameter description.
815 Return value description.
820 # -------------------------------------------------------------------------
822 # -------------------------------------------------------------------------
823 lmt_lut_resolution_1d = max(4096, lut_resolution_1d)
824 lmt_lut_resolution_3d = max(65, lut_resolution_3d)
826 # Defining the *Log 2* shaper.
827 lmt_shaper_name = 'LMT Shaper'
828 lmt_shaper_name_aliases = ['crv_lmtshaper']
834 lmt_shaper = create_generic_log(aces_ctl_directory,
836 lmt_lut_resolution_1d,
838 name=lmt_shaper_name,
839 middle_grey=lmt_params['middleGrey'],
840 min_exposure=lmt_params['minExposure'],
841 max_exposure=lmt_params['maxExposure'],
842 aliases=lmt_shaper_name_aliases)
843 colorspaces.append(lmt_shaper)
845 shaper_input_scale_generic_log2 = 1
847 # *Log 2* shaper name and *CTL* transforms bundled up.
852 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl'),
855 'ACESlib.OCIO_shaper_lin_to_log2_param.a1.0.0.ctl'),
856 shaper_input_scale_generic_log2,
859 sorted_LMTs = sorted(lmt_info.iteritems(), key=lambda x: x[1])
861 for lmt in sorted_LMTs:
862 lmt_name, lmt_values = lmt
863 lmt_aliases = ["look_%s" % compact(lmt_values['transformUserName'])]
864 cs = create_ACES_LMT(
865 lmt_values['transformUserName'],
870 lmt_lut_resolution_1d,
871 lmt_lut_resolution_3d,
874 colorspaces.append(cs)
879 def create_ODTs(aces_ctl_directory,
886 linear_display_space,
894 Parameter description.
899 Return value description.
905 # -------------------------------------------------------------------------
906 # *RRT / ODT* Shaper Options
907 # -------------------------------------------------------------------------
910 # Defining the *Log 2* shaper.
911 log2_shaper_name = shaper_name
912 log2_shaper_name_aliases = ["crv_%s" % compact(shaper_name)]
918 log2_shaper = create_generic_log(
923 name=log2_shaper_name,
924 middle_grey=log2_params['middleGrey'],
925 min_exposure=log2_params['minExposure'],
926 max_exposure=log2_params['maxExposure'],
927 aliases=log2_shaper_name_aliases)
928 colorspaces.append(log2_shaper)
930 shaper_input_scale_generic_log2 = 1
932 # *Log 2* shaper name and *CTL* transforms bundled up.
937 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl'),
940 'ACESlib.OCIO_shaper_lin_to_log2_param.a1.0.0.ctl'),
941 shaper_input_scale_generic_log2,
944 shaper_data[log2_shaper_name] = log2_shaper_data
946 # Shaper that also includes the AP1 primaries.
947 # Needed for some LUT baking steps.
948 log2_shaper_api1_name_aliases = ["%s_ap1" % compact(shaper_name)]
949 log2_shaper_ap1 = create_generic_log(
954 name=log2_shaper_name,
955 middle_grey=log2_params['middleGrey'],
956 min_exposure=log2_params['minExposure'],
957 max_exposure=log2_params['maxExposure'],
958 aliases=log2_shaper_api1_name_aliases)
959 log2_shaper_ap1.name = '%s - AP1' % log2_shaper_ap1.name
961 # *AP1* primaries to *AP0* primaries.
962 log2_shaper_ap1.to_reference_transforms.append({
964 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
965 'direction': 'forward'
967 colorspaces.append(log2_shaper_ap1)
969 rrt_shaper = log2_shaper_data
971 # *RRT + ODT* combinations.
972 sorted_odts = sorted(odt_info.iteritems(), key=lambda x: x[1])
974 for odt in sorted_odts:
975 (odt_name, odt_values) = odt
977 # Generating legal range transform for *ODTs* that can generate
978 # either *legal* or *full* output.
979 if odt_values['transformHasFullLegalSwitch']:
980 odt_name_legal = '%s - Legal' % odt_values['transformUserName']
982 odt_name_legal = odt_values['transformUserName']
984 odt_legal = odt_values.copy()
985 odt_legal['legalRange'] = 1
987 odt_aliases = ["out_%s" % compact(odt_name_legal)]
989 cs = create_ACES_RRT_plus_ODT(
999 colorspaces.append(cs)
1001 displays[odt_name_legal] = {
1002 'Linear': linear_display_space,
1003 'Log': log_display_space,
1004 'Output Transform': cs}
1007 # Generating full range transform for *ODTs* that can generate
1008 # either *legal* or *full* output.
1009 if odt_values['transformHasFullLegalSwitch']:
1010 print('Generating full range ODT for %s' % odt_name)
1012 odt_name_full = '%s - Full' % odt_values['transformUserName']
1013 odt_full = odt_values.copy()
1014 odt_full['legalRange'] = 0
1016 odt_full_aliases = ["out_%s" % compact(odt_name_full)]
1018 cs_full = create_ACES_RRT_plus_ODT(
1028 colorspaces.append(cs_full)
1030 displays[odt_name_full] = {
1031 'Linear': linear_display_space,
1032 'Log': log_display_space,
1033 'Output Transform': cs_full}
1035 return (colorspaces, displays)
1038 def get_transform_info(ctl_transform):
1045 Parameter description.
1050 Return value description.
1053 with open(ctl_transform, 'rb') as fp:
1054 lines = fp.readlines()
1056 # Retrieving the *transform ID* and *User Name*.
1057 transform_id = lines[1][3:].split('<')[1].split('>')[1].strip()
1058 transform_user_name = '-'.join(
1059 lines[2][3:].split('<')[1].split('>')[1].split('-')[1:]).strip()
1060 transform_user_name_prefix = (
1061 lines[2][3:].split('<')[1].split('>')[1].split('-')[0].strip())
1063 # Figuring out if this transform has options for processing full and legal range
1064 transform_full_legal_switch = False
1066 if line.strip() == "input varying int legalRange = 0":
1067 # print( "%s has legal range flag" % transform_user_name)
1068 transform_full_legal_switch = True
1071 return (transform_id, transform_user_name, transform_user_name_prefix,
1072 transform_full_legal_switch)
1075 def get_ODTs_info(aces_ctl_directory):
1079 For versions after WGR9.
1084 Parameter description.
1089 Return value description.
1092 # TODO: Investigate usage of *files_walker* definition here.
1093 # Credit to *Alex Fry* for the original approach here.
1094 odt_dir = os.path.join(aces_ctl_directory, 'odt')
1096 for dir_name, subdir_list, file_list in os.walk(odt_dir):
1097 for fname in file_list:
1098 all_odt.append((os.path.join(dir_name, fname)))
1100 odt_CTLs = [x for x in all_odt if
1101 ('InvODT' not in x) and (os.path.split(x)[-1][0] != '.')]
1105 for odt_CTL in odt_CTLs:
1106 odt_tokens = os.path.split(odt_CTL)
1108 # Handling nested directories.
1109 odt_path_tokens = os.path.split(odt_tokens[-2])
1110 odt_dir = odt_path_tokens[-1]
1111 while odt_path_tokens[-2][-3:] != 'odt':
1112 odt_path_tokens = os.path.split(odt_path_tokens[-2])
1113 odt_dir = os.path.join(odt_path_tokens[-1], odt_dir)
1115 # Building full name,
1116 transform_CTL = odt_tokens[-1]
1117 odt_name = string.join(transform_CTL.split('.')[1:-1], '.')
1119 # Finding id, user name and user name prefix.
1121 transform_user_name,
1122 transform_user_name_prefix,
1123 transform_full_legal_switch) = get_transform_info(
1124 os.path.join(aces_ctl_directory, 'odt', odt_dir, transform_CTL))
1127 transform_CTL_inverse = 'InvODT.%s.ctl' % odt_name
1128 if not os.path.exists(
1129 os.path.join(odt_tokens[-2], transform_CTL_inverse)):
1130 transform_CTL_inverse = None
1132 # Add to list of ODTs
1134 odts[odt_name]['transformCTL'] = os.path.join(odt_dir, transform_CTL)
1135 if transform_CTL_inverse is not None:
1136 odts[odt_name]['transformCTLInverse'] = os.path.join(
1137 odt_dir, transform_CTL_inverse)
1139 odts[odt_name]['transformID'] = transform_ID
1140 odts[odt_name]['transformUserNamePrefix'] = transform_user_name_prefix
1141 odts[odt_name]['transformUserName'] = transform_user_name
1143 'transformHasFullLegalSwitch'] = transform_full_legal_switch
1145 forward_CTL = odts[odt_name]['transformCTL']
1147 print('ODT : %s' % odt_name)
1148 print('\tTransform ID : %s' % transform_ID)
1149 print('\tTransform User Name Prefix : %s' % transform_user_name_prefix)
1150 print('\tTransform User Name : %s' % transform_user_name)
1152 '\tHas Full / Legal Switch : %s' % transform_full_legal_switch)
1153 print('\tForward ctl : %s' % forward_CTL)
1154 if 'transformCTLInverse' in odts[odt_name]:
1155 inverse_CTL = odts[odt_name]['transformCTLInverse']
1156 print('\tInverse ctl : %s' % inverse_CTL)
1158 print('\tInverse ctl : %s' % 'None')
1165 def get_LMTs_info(aces_ctl_directory):
1169 For versions after WGR9.
1174 Parameter description.
1179 Return value description.
1182 # TODO: Investigate refactoring with previous definition.
1184 # Credit to Alex Fry for the original approach here
1185 lmt_dir = os.path.join(aces_ctl_directory, 'lmt')
1187 for dir_name, subdir_list, file_list in os.walk(lmt_dir):
1188 for fname in file_list:
1189 all_lmt.append((os.path.join(dir_name, fname)))
1191 lmt_CTLs = [x for x in all_lmt if
1192 ('InvLMT' not in x) and ('README' not in x) and (
1193 os.path.split(x)[-1][0] != '.')]
1197 for lmt_CTL in lmt_CTLs:
1198 lmt_tokens = os.path.split(lmt_CTL)
1200 # Handlimg nested directories.
1201 lmt_path_tokens = os.path.split(lmt_tokens[-2])
1202 lmt_dir = lmt_path_tokens[-1]
1203 while lmt_path_tokens[-2][-3:] != 'ctl':
1204 lmt_path_tokens = os.path.split(lmt_path_tokens[-2])
1205 lmt_dir = os.path.join(lmt_path_tokens[-1], lmt_dir)
1207 # Building full name.
1208 transform_CTL = lmt_tokens[-1]
1209 lmt_name = string.join(transform_CTL.split('.')[1:-1], '.')
1211 # Finding id, user name and user name prefix.
1213 transform_user_name,
1214 transform_user_name_prefix,
1215 transform_full_legal_switch) = get_transform_info(
1216 os.path.join(aces_ctl_directory, lmt_dir, transform_CTL))
1219 transform_CTL_inverse = 'InvLMT.%s.ctl' % lmt_name
1220 if not os.path.exists(
1221 os.path.join(lmt_tokens[-2], transform_CTL_inverse)):
1222 transform_CTL_inverse = None
1225 lmts[lmt_name]['transformCTL'] = os.path.join(lmt_dir, transform_CTL)
1226 if transform_CTL_inverse is not None:
1227 lmts[lmt_name]['transformCTLInverse'] = os.path.join(
1228 lmt_dir, transform_CTL_inverse)
1230 lmts[lmt_name]['transformID'] = transform_ID
1231 lmts[lmt_name]['transformUserNamePrefix'] = transform_user_name_prefix
1232 lmts[lmt_name]['transformUserName'] = transform_user_name
1234 forward_CTL = lmts[lmt_name]['transformCTL']
1236 print('LMT : %s' % lmt_name)
1237 print('\tTransform ID : %s' % transform_ID)
1238 print('\tTransform User Name Prefix : %s' % transform_user_name_prefix)
1239 print('\tTransform User Name : %s' % transform_user_name)
1240 print('\t Forward ctl : %s' % forward_CTL)
1241 if 'transformCTLInverse' in lmts[lmt_name]:
1242 inverse_CTL = lmts[lmt_name]['transformCTLInverse']
1243 print('\t Inverse ctl : %s' % inverse_CTL)
1245 print('\t Inverse ctl : %s' % 'None')
1252 def create_colorspaces(aces_ctl_directory,
1261 Generates the colorspace conversions.
1266 Parameter description.
1271 Return value description.
1276 ACES = create_ACES()
1278 ACEScc = create_ACEScc(aces_ctl_directory, lut_directory,
1279 lut_resolution_1d, cleanup)
1280 colorspaces.append(ACEScc)
1282 ACESproxy = create_ACESproxy(aces_ctl_directory, lut_directory,
1283 lut_resolution_1d, cleanup)
1284 colorspaces.append(ACESproxy)
1286 ACEScg = create_ACEScg(aces_ctl_directory, lut_directory,
1287 lut_resolution_1d, cleanup)
1288 colorspaces.append(ACEScg)
1290 ADX10 = create_ADX(lut_directory, lut_resolution_1d, bit_depth=10)
1291 colorspaces.append(ADX10)
1293 ADX16 = create_ADX(lut_directory, lut_resolution_1d, bit_depth=16)
1294 colorspaces.append(ADX16)
1296 lmts = create_LMTs(aces_ctl_directory,
1303 colorspaces.extend(lmts)
1305 odts, displays = create_ODTs(aces_ctl_directory,
1314 colorspaces.extend(odts)
1316 return ACES, colorspaces, displays, ACEScc