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 = [-8, 5, 0.00390625]
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 = ''
122 cs.allocation_type = ocio.Constants.ALLOCATION_UNIFORM
123 cs.allocation_vars = [min_value, max_value]
125 ctls = [os.path.join(aces_ctl_directory,
127 'ACEScsc.ACEScc_to_ACES.a1.0.0.ctl'),
128 # This transform gets back to the *AP1* primaries.
129 # Useful as the 1d LUT is only covering the transfer function.
130 # The primaries switch is covered by the matrix below:
131 os.path.join(aces_ctl_directory,
133 'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')]
134 lut = '%s_to_linear.spi1d' % name
138 generate_1d_LUT_from_CTL(
139 os.path.join(lut_directory, lut),
151 cs.to_reference_transforms = []
152 cs.to_reference_transforms.append({
155 'interpolation': 'linear',
156 'direction': 'forward'})
158 # *AP1* primaries to *AP0* primaries.
159 cs.to_reference_transforms.append({
161 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
162 'direction': 'forward'})
164 cs.from_reference_transforms = []
168 def create_ACESproxy(aces_ctl_directory,
174 Creates the *ACESproxy* colorspace.
179 Parameter description.
184 *ACESproxy* colorspace.
187 cs = ColorSpace(name)
188 cs.description = 'The %s color space' % name
189 cs.aliases = ["acesproxy_ap1"]
190 cs.equality_group = ''
194 ctls = [os.path.join(aces_ctl_directory,
196 'ACEScsc.ACESproxy10i_to_ACES.a1.0.0.ctl'),
197 # This transform gets back to the *AP1* primaries.
198 # Useful as the 1d LUT is only covering the transfer function.
199 # The primaries switch is covered by the matrix below:
200 os.path.join(aces_ctl_directory,
202 'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')]
203 lut = '%s_to_linear.spi1d' % name
207 generate_1d_LUT_from_CTL(
208 os.path.join(lut_directory, lut),
218 cs.to_reference_transforms = []
219 cs.to_reference_transforms.append({
222 'interpolation': 'linear',
223 'direction': 'forward'})
225 # *AP1* primaries to *AP0* primaries.
226 cs.to_reference_transforms.append({
228 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
229 'direction': 'forward'})
231 cs.from_reference_transforms = []
235 # -------------------------------------------------------------------------
237 # -------------------------------------------------------------------------
238 def create_ACEScg(aces_ctl_directory,
244 Creates the *ACEScg* colorspace.
249 Parameter description.
257 cs = ColorSpace(name)
258 cs.description = 'The %s color space' % name
259 cs.aliases = ["lin_ap1"]
260 cs.equality_group = ''
263 cs.allocation_type = ocio.Constants.ALLOCATION_LG2
264 cs.allocation_vars = [-8, 5, 0.00390625]
266 cs.to_reference_transforms = []
268 # *AP1* primaries to *AP0* primaries.
269 cs.to_reference_transforms.append({
271 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
272 'direction': 'forward'})
274 cs.from_reference_transforms = []
278 # -------------------------------------------------------------------------
280 # -------------------------------------------------------------------------
281 def create_ADX(lut_directory,
286 Creates the *ADX* colorspace.
291 Parameter description.
299 name = '%s%s' % (name, bit_depth)
300 cs = ColorSpace(name)
301 cs.description = '%s color space - used for film scans' % name
302 cs.aliases = ["adx%s" % str(bit_depth)]
303 cs.equality_group = ''
308 cs.bit_depth = ocio.Constants.BIT_DEPTH_UINT10
309 ADX_to_CDD = [1023 / 500, 0, 0, 0,
313 offset = [-95 / 500, -95 / 500, -95 / 500, 0]
314 elif bit_depth == 16:
315 cs.bit_depth = ocio.Constants.BIT_DEPTH_UINT16
316 ADX_to_CDD = [65535 / 8000, 0, 0, 0,
317 0, 65535 / 8000, 0, 0,
318 0, 0, 65535 / 8000, 0,
320 offset = [-1520 / 8000, -1520 / 8000, -1520 / 8000, 0]
322 cs.to_reference_transforms = []
324 # Converting from *ADX* to *Channel-Dependent Density*.
325 cs.to_reference_transforms.append({
327 'matrix': ADX_to_CDD,
329 'direction': 'forward'})
331 # Convert from Channel-Dependent Density to Channel-Independent Density
332 cs.to_reference_transforms.append({
334 'matrix': [0.75573, 0.22197, 0.02230, 0,
335 0.05901, 0.96928, -0.02829, 0,
336 0.16134, 0.07406, 0.76460, 0,
338 'direction': 'forward'})
340 # Copied from *Alex Fry*'s *adx_cid_to_rle.py*
341 def create_CID_to_RLE_LUT():
343 def interpolate_1D(x, xp, fp):
344 return numpy.interp(x, xp, fp)
346 LUT_1D_xp = [-0.190000000000000,
358 LUT_1D_fp = [-6.000000000000000,
370 REF_PT = ((7120 - 1520) / 8000 * (100 / 55) -
375 return interpolate_1D(x, LUT_1D_xp, LUT_1D_fp)
376 return (100 / 55) * x - REF_PT
378 def fit(value, from_min, from_max, to_min, to_max):
379 if from_min == from_max:
380 raise ValueError('from_min == from_max')
381 return (value - from_min) / (from_max - from_min) * (
382 to_max - to_min) + to_min
384 num_samples = 2 ** 12
387 for i in xrange(num_samples):
388 x = i / (num_samples - 1)
389 x = fit(x, 0, 1, domain[0], domain[1])
390 data.append(cid_to_rle(x))
392 lut = 'ADX_CID_to_RLE.spi1d'
393 write_SPI_1d(os.path.join(lut_directory, lut),
401 # Converting *Channel Independent Density* values to
402 # *Relative Log Exposure* values.
403 lut = create_CID_to_RLE_LUT()
404 cs.to_reference_transforms.append({
407 'interpolation': 'linear',
408 'direction': 'forward'})
410 # Converting *Relative Log Exposure* values to
411 # *Relative Exposure* values.
412 cs.to_reference_transforms.append({
415 'direction': 'inverse'})
417 # Convert *Relative Exposure* values to *ACES* values.
418 cs.to_reference_transforms.append({
420 'matrix': [0.72286, 0.12630, 0.15084, 0,
421 0.11923, 0.76418, 0.11659, 0,
422 0.01427, 0.08213, 0.90359, 0,
424 'direction': 'forward'})
426 cs.from_reference_transforms = []
430 def create_ACES_LMT(lmt_name,
435 lut_resolution_1d=1024,
436 lut_resolution_3d=64,
440 Creates the *ACES LMT* colorspace.
445 Parameter description.
450 *ACES LMT* colorspace.
456 cs = ColorSpace('%s' % lmt_name)
457 cs.description = 'The ACES Look Transform: %s' % lmt_name
459 cs.equality_group = ''
462 cs.allocation_type = ocio.Constants.ALLOCATION_LG2
463 cs.allocation_vars = [-8, 5, 0.00390625]
465 pprint.pprint(lmt_values)
467 # Generating the *shaper* transform.
470 shaper_from_ACES_CTL,
472 shaper_params) = shaper_info
474 shaper_lut = '%s_to_linear.spi1d' % shaper_name
475 if not os.path.exists(os.path.join(lut_directory, shaper_lut)):
476 ctls = [shaper_to_ACES_CTL % aces_ctl_directory]
478 shaper_lut = sanitize(shaper_lut)
480 generate_1d_LUT_from_CTL(
481 os.path.join(lut_directory, shaper_lut),
485 1 / shaper_input_scale,
491 shaper_OCIO_transform = {
494 'interpolation': 'linear',
495 'direction': 'inverse'}
497 # Generating the forward transform.
498 cs.from_reference_transforms = []
500 if 'transformCTL' in lmt_values:
501 ctls = [shaper_to_ACES_CTL % aces_ctl_directory,
502 os.path.join(aces_ctl_directory,
503 lmt_values['transformCTL'])]
504 lut = '%s.%s.spi3d' % (shaper_name, lmt_name)
508 generate_3d_LUT_from_CTL(
509 os.path.join(lut_directory, lut),
513 1 / shaper_input_scale,
519 cs.from_reference_transforms.append(shaper_OCIO_transform)
520 cs.from_reference_transforms.append({
523 'interpolation': 'tetrahedral',
524 'direction': 'forward'})
526 # Generating the inverse transform.
527 cs.to_reference_transforms = []
529 if 'transformCTLInverse' in lmt_values:
530 ctls = [os.path.join(aces_ctl_directory,
531 lmt_values['transformCTLInverse']),
532 shaper_from_ACES_CTL % aces_ctl_directory]
533 lut = 'Inverse.%s.%s.spi3d' % (odt_name, shaper_name)
537 generate_3d_LUT_from_CTL(
538 os.path.join(lut_directory, lut),
548 cs.to_reference_transforms.append({
551 'interpolation': 'tetrahedral',
552 'direction': 'forward'})
554 shaper_inverse = shaper_OCIO_transform.copy()
555 shaper_inverse['direction'] = 'forward'
556 cs.to_reference_transforms.append(shaper_inverse)
561 def create_ACES_RRT_plus_ODT(odt_name,
566 lut_resolution_1d=1024,
567 lut_resolution_3d=64,
576 Parameter description.
581 Return value description.
587 cs = ColorSpace('%s' % odt_name)
588 cs.description = '%s - %s Output Transform' % (
589 odt_values['transformUserNamePrefix'], odt_name)
591 cs.equality_group = ''
595 pprint.pprint(odt_values)
597 # Generating the *shaper* transform.
600 shaper_from_ACES_CTL,
602 shaper_params) = shaper_info
604 if 'legalRange' in odt_values:
605 shaper_params['legalRange'] = odt_values['legalRange']
607 shaper_params['legalRange'] = 0
609 shaper_lut = '%s_to_linear.spi1d' % shaper_name
610 if not os.path.exists(os.path.join(lut_directory, shaper_lut)):
611 ctls = [shaper_to_ACES_CTL % aces_ctl_directory]
613 shaper_lut = sanitize(shaper_lut)
615 generate_1d_LUT_from_CTL(
616 os.path.join(lut_directory, shaper_lut),
620 1 / shaper_input_scale,
626 shaper_OCIO_transform = {
629 'interpolation': 'linear',
630 'direction': 'inverse'}
632 # Generating the *forward* transform.
633 cs.from_reference_transforms = []
635 if 'transformLUT' in odt_values:
636 transform_LUT_file_name = os.path.basename(
637 odt_values['transformLUT'])
638 lut = os.path.join(lut_directory, transform_LUT_file_name)
639 shutil.copy(odt_values['transformLUT'], lut)
641 cs.from_reference_transforms.append(shaper_OCIO_transform)
642 cs.from_reference_transforms.append({
644 'path': transform_LUT_file_name,
645 'interpolation': 'tetrahedral',
646 'direction': 'forward'})
647 elif 'transformCTL' in odt_values:
649 shaper_to_ACES_CTL % aces_ctl_directory,
650 os.path.join(aces_ctl_directory,
653 os.path.join(aces_ctl_directory,
655 odt_values['transformCTL'])]
656 lut = '%s.RRT.a1.0.0.%s.spi3d' % (shaper_name, odt_name)
660 generate_3d_LUT_from_CTL(
661 os.path.join(lut_directory, lut),
666 1 / shaper_input_scale,
672 cs.from_reference_transforms.append(shaper_OCIO_transform)
673 cs.from_reference_transforms.append({
676 'interpolation': 'tetrahedral',
677 'direction': 'forward'})
679 # Generating the *inverse* transform.
680 cs.to_reference_transforms = []
682 if 'transformLUTInverse' in odt_values:
683 transform_LUT_inverse_file_name = os.path.basename(
684 odt_values['transformLUTInverse'])
685 lut = os.path.join(lut_directory, transform_LUT_inverse_file_name)
686 shutil.copy(odt_values['transformLUTInverse'], lut)
688 cs.to_reference_transforms.append({
690 'path': transform_LUT_inverse_file_name,
691 'interpolation': 'tetrahedral',
692 'direction': 'forward'})
694 shaper_inverse = shaper_OCIO_transform.copy()
695 shaper_inverse['direction'] = 'forward'
696 cs.to_reference_transforms.append(shaper_inverse)
697 elif 'transformCTLInverse' in odt_values:
698 ctls = [os.path.join(aces_ctl_directory,
700 odt_values['transformCTLInverse']),
701 os.path.join(aces_ctl_directory,
703 'InvRRT.a1.0.0.ctl'),
704 shaper_from_ACES_CTL % aces_ctl_directory]
705 lut = 'InvRRT.a1.0.0.%s.%s.spi3d' % (odt_name, shaper_name)
709 generate_3d_LUT_from_CTL(
710 os.path.join(lut_directory, lut),
721 cs.to_reference_transforms.append({
724 'interpolation': 'tetrahedral',
725 'direction': 'forward'})
727 shaper_inverse = shaper_OCIO_transform.copy()
728 shaper_inverse['direction'] = 'forward'
729 cs.to_reference_transforms.append(shaper_inverse)
734 def create_generic_log(aces_ctl_directory,
747 Creates the *Generic Log* colorspace.
752 Parameter description.
757 *Generic Log* colorspace.
760 cs = ColorSpace(name)
761 cs.description = 'The %s color space' % name
763 cs.equality_group = name
764 cs.family = 'Utility'
767 ctls = [os.path.join(
770 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl')]
771 lut = '%s_to_linear.spi1d' % name
775 generate_1d_LUT_from_CTL(
776 os.path.join(lut_directory, lut),
782 {'middleGrey': middle_grey,
783 'minExposure': min_exposure,
784 'maxExposure': max_exposure},
790 cs.to_reference_transforms = []
791 cs.to_reference_transforms.append({
794 'interpolation': 'linear',
795 'direction': 'forward'})
797 cs.from_reference_transforms = []
801 def create_LMTs(aces_ctl_directory,
814 Parameter description.
819 Return value description.
824 # -------------------------------------------------------------------------
826 # -------------------------------------------------------------------------
827 lmt_lut_resolution_1d = max(4096, lut_resolution_1d)
828 lmt_lut_resolution_3d = max(65, lut_resolution_3d)
830 # Defining the *Log 2* shaper.
831 lmt_shaper_name = 'LMT Shaper'
832 lmt_shaper_name_aliases = ['crv_lmtshaper']
838 lmt_shaper = create_generic_log(aces_ctl_directory,
840 lmt_lut_resolution_1d,
842 name=lmt_shaper_name,
843 middle_grey=lmt_params['middleGrey'],
844 min_exposure=lmt_params['minExposure'],
845 max_exposure=lmt_params['maxExposure'],
846 aliases=lmt_shaper_name_aliases)
847 colorspaces.append(lmt_shaper)
849 shaper_input_scale_generic_log2 = 1
851 # *Log 2* shaper name and *CTL* transforms bundled up.
856 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl'),
859 'ACESlib.OCIO_shaper_lin_to_log2_param.a1.0.0.ctl'),
860 shaper_input_scale_generic_log2,
863 sorted_LMTs = sorted(lmt_info.iteritems(), key=lambda x: x[1])
865 for lmt in sorted_LMTs:
866 lmt_name, lmt_values = lmt
867 lmt_aliases = ["look_%s" % compact(lmt_values['transformUserName'])]
868 cs = create_ACES_LMT(
869 lmt_values['transformUserName'],
874 lmt_lut_resolution_1d,
875 lmt_lut_resolution_3d,
878 colorspaces.append(cs)
883 def create_ODTs(aces_ctl_directory,
890 linear_display_space,
898 Parameter description.
903 Return value description.
909 # -------------------------------------------------------------------------
910 # *RRT / ODT* Shaper Options
911 # -------------------------------------------------------------------------
914 # Defining the *Log 2* shaper.
915 log2_shaper_name = shaper_name
916 log2_shaper_name_aliases = ["crv_%s" % compact(shaper_name)]
922 log2_shaper = create_generic_log(
927 name=log2_shaper_name,
928 middle_grey=log2_params['middleGrey'],
929 min_exposure=log2_params['minExposure'],
930 max_exposure=log2_params['maxExposure'],
931 aliases=log2_shaper_name_aliases)
932 colorspaces.append(log2_shaper)
934 shaper_input_scale_generic_log2 = 1
936 # *Log 2* shaper name and *CTL* transforms bundled up.
941 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl'),
944 'ACESlib.OCIO_shaper_lin_to_log2_param.a1.0.0.ctl'),
945 shaper_input_scale_generic_log2,
948 shaper_data[log2_shaper_name] = log2_shaper_data
950 # Shaper that also includes the AP1 primaries.
951 # Needed for some LUT baking steps.
952 log2_shaper_api1_name_aliases = ["%s_ap1" % compact(shaper_name)]
953 log2_shaper_ap1 = create_generic_log(
958 name=log2_shaper_name,
959 middle_grey=log2_params['middleGrey'],
960 min_exposure=log2_params['minExposure'],
961 max_exposure=log2_params['maxExposure'],
962 aliases=log2_shaper_api1_name_aliases)
963 log2_shaper_ap1.name = '%s - AP1' % log2_shaper_ap1.name
965 # *AP1* primaries to *AP0* primaries.
966 log2_shaper_ap1.to_reference_transforms.append({
968 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
969 'direction': 'forward'
971 colorspaces.append(log2_shaper_ap1)
973 rrt_shaper = log2_shaper_data
975 # *RRT + ODT* combinations.
976 sorted_odts = sorted(odt_info.iteritems(), key=lambda x: x[1])
978 for odt in sorted_odts:
979 (odt_name, odt_values) = odt
981 # Generating legal range transform for *ODTs* that can generate
982 # either *legal* or *full* output.
983 if odt_values['transformHasFullLegalSwitch']:
984 odt_name_legal = '%s - Legal' % odt_values['transformUserName']
986 odt_name_legal = odt_values['transformUserName']
988 odt_legal = odt_values.copy()
989 odt_legal['legalRange'] = 1
991 odt_aliases = ["out_%s" % compact(odt_name_legal)]
993 cs = create_ACES_RRT_plus_ODT(
1003 colorspaces.append(cs)
1005 displays[odt_name_legal] = {
1006 'Linear': linear_display_space,
1007 'Log': log_display_space,
1008 'Output Transform': cs}
1011 # Generating full range transform for *ODTs* that can generate
1012 # either *legal* or *full* output.
1013 if odt_values['transformHasFullLegalSwitch']:
1014 print('Generating full range ODT for %s' % odt_name)
1016 odt_name_full = '%s - Full' % odt_values['transformUserName']
1017 odt_full = odt_values.copy()
1018 odt_full['legalRange'] = 0
1020 odt_full_aliases = ["out_%s" % compact(odt_name_full)]
1022 cs_full = create_ACES_RRT_plus_ODT(
1032 colorspaces.append(cs_full)
1034 displays[odt_name_full] = {
1035 'Linear': linear_display_space,
1036 'Log': log_display_space,
1037 'Output Transform': cs_full}
1039 return (colorspaces, displays)
1042 def get_transform_info(ctl_transform):
1049 Parameter description.
1054 Return value description.
1057 with open(ctl_transform, 'rb') as fp:
1058 lines = fp.readlines()
1060 # Retrieving the *transform ID* and *User Name*.
1061 transform_id = lines[1][3:].split('<')[1].split('>')[1].strip()
1062 transform_user_name = '-'.join(
1063 lines[2][3:].split('<')[1].split('>')[1].split('-')[1:]).strip()
1064 transform_user_name_prefix = (
1065 lines[2][3:].split('<')[1].split('>')[1].split('-')[0].strip())
1067 # Figuring out if this transform has options for processing full and legal range
1068 transform_full_legal_switch = False
1070 if line.strip() == "input varying int legalRange = 0":
1071 # print( "%s has legal range flag" % transform_user_name)
1072 transform_full_legal_switch = True
1075 return (transform_id, transform_user_name, transform_user_name_prefix,
1076 transform_full_legal_switch)
1079 def get_ODTs_info(aces_ctl_directory):
1083 For versions after WGR9.
1088 Parameter description.
1093 Return value description.
1096 # TODO: Investigate usage of *files_walker* definition here.
1097 # Credit to *Alex Fry* for the original approach here.
1098 odt_dir = os.path.join(aces_ctl_directory, 'odt')
1100 for dir_name, subdir_list, file_list in os.walk(odt_dir):
1101 for fname in file_list:
1102 all_odt.append((os.path.join(dir_name, fname)))
1104 odt_CTLs = [x for x in all_odt if
1105 ('InvODT' not in x) and (os.path.split(x)[-1][0] != '.')]
1109 for odt_CTL in odt_CTLs:
1110 odt_tokens = os.path.split(odt_CTL)
1112 # Handling nested directories.
1113 odt_path_tokens = os.path.split(odt_tokens[-2])
1114 odt_dir = odt_path_tokens[-1]
1115 while odt_path_tokens[-2][-3:] != 'odt':
1116 odt_path_tokens = os.path.split(odt_path_tokens[-2])
1117 odt_dir = os.path.join(odt_path_tokens[-1], odt_dir)
1119 # Building full name,
1120 transform_CTL = odt_tokens[-1]
1121 odt_name = string.join(transform_CTL.split('.')[1:-1], '.')
1123 # Finding id, user name and user name prefix.
1125 transform_user_name,
1126 transform_user_name_prefix,
1127 transform_full_legal_switch) = get_transform_info(
1128 os.path.join(aces_ctl_directory, 'odt', odt_dir, transform_CTL))
1131 transform_CTL_inverse = 'InvODT.%s.ctl' % odt_name
1132 if not os.path.exists(
1133 os.path.join(odt_tokens[-2], transform_CTL_inverse)):
1134 transform_CTL_inverse = None
1136 # Add to list of ODTs
1138 odts[odt_name]['transformCTL'] = os.path.join(odt_dir, transform_CTL)
1139 if transform_CTL_inverse is not None:
1140 odts[odt_name]['transformCTLInverse'] = os.path.join(
1141 odt_dir, transform_CTL_inverse)
1143 odts[odt_name]['transformID'] = transform_ID
1144 odts[odt_name]['transformUserNamePrefix'] = transform_user_name_prefix
1145 odts[odt_name]['transformUserName'] = transform_user_name
1147 'transformHasFullLegalSwitch'] = transform_full_legal_switch
1149 forward_CTL = odts[odt_name]['transformCTL']
1151 print('ODT : %s' % odt_name)
1152 print('\tTransform ID : %s' % transform_ID)
1153 print('\tTransform User Name Prefix : %s' % transform_user_name_prefix)
1154 print('\tTransform User Name : %s' % transform_user_name)
1156 '\tHas Full / Legal Switch : %s' % transform_full_legal_switch)
1157 print('\tForward ctl : %s' % forward_CTL)
1158 if 'transformCTLInverse' in odts[odt_name]:
1159 inverse_CTL = odts[odt_name]['transformCTLInverse']
1160 print('\tInverse ctl : %s' % inverse_CTL)
1162 print('\tInverse ctl : %s' % 'None')
1169 def get_LMTs_info(aces_ctl_directory):
1173 For versions after WGR9.
1178 Parameter description.
1183 Return value description.
1186 # TODO: Investigate refactoring with previous definition.
1188 # Credit to Alex Fry for the original approach here
1189 lmt_dir = os.path.join(aces_ctl_directory, 'lmt')
1191 for dir_name, subdir_list, file_list in os.walk(lmt_dir):
1192 for fname in file_list:
1193 all_lmt.append((os.path.join(dir_name, fname)))
1195 lmt_CTLs = [x for x in all_lmt if
1196 ('InvLMT' not in x) and ('README' not in x) and (
1197 os.path.split(x)[-1][0] != '.')]
1201 for lmt_CTL in lmt_CTLs:
1202 lmt_tokens = os.path.split(lmt_CTL)
1204 # Handlimg nested directories.
1205 lmt_path_tokens = os.path.split(lmt_tokens[-2])
1206 lmt_dir = lmt_path_tokens[-1]
1207 while lmt_path_tokens[-2][-3:] != 'ctl':
1208 lmt_path_tokens = os.path.split(lmt_path_tokens[-2])
1209 lmt_dir = os.path.join(lmt_path_tokens[-1], lmt_dir)
1211 # Building full name.
1212 transform_CTL = lmt_tokens[-1]
1213 lmt_name = string.join(transform_CTL.split('.')[1:-1], '.')
1215 # Finding id, user name and user name prefix.
1217 transform_user_name,
1218 transform_user_name_prefix,
1219 transform_full_legal_switch) = get_transform_info(
1220 os.path.join(aces_ctl_directory, lmt_dir, transform_CTL))
1223 transform_CTL_inverse = 'InvLMT.%s.ctl' % lmt_name
1224 if not os.path.exists(
1225 os.path.join(lmt_tokens[-2], transform_CTL_inverse)):
1226 transform_CTL_inverse = None
1229 lmts[lmt_name]['transformCTL'] = os.path.join(lmt_dir, transform_CTL)
1230 if transform_CTL_inverse is not None:
1231 lmts[lmt_name]['transformCTLInverse'] = os.path.join(
1232 lmt_dir, transform_CTL_inverse)
1234 lmts[lmt_name]['transformID'] = transform_ID
1235 lmts[lmt_name]['transformUserNamePrefix'] = transform_user_name_prefix
1236 lmts[lmt_name]['transformUserName'] = transform_user_name
1238 forward_CTL = lmts[lmt_name]['transformCTL']
1240 print('LMT : %s' % lmt_name)
1241 print('\tTransform ID : %s' % transform_ID)
1242 print('\tTransform User Name Prefix : %s' % transform_user_name_prefix)
1243 print('\tTransform User Name : %s' % transform_user_name)
1244 print('\t Forward ctl : %s' % forward_CTL)
1245 if 'transformCTLInverse' in lmts[lmt_name]:
1246 inverse_CTL = lmts[lmt_name]['transformCTLInverse']
1247 print('\t Inverse ctl : %s' % inverse_CTL)
1249 print('\t Inverse ctl : %s' % 'None')
1256 def create_colorspaces(aces_ctl_directory,
1265 Generates the colorspace conversions.
1270 Parameter description.
1275 Return value description.
1280 ACES = create_ACES()
1282 ACEScc = create_ACEScc(aces_ctl_directory, lut_directory,
1283 lut_resolution_1d, cleanup,
1284 min_value=-0.35840, max_value=1.468)
1285 colorspaces.append(ACEScc)
1287 ACESproxy = create_ACESproxy(aces_ctl_directory, lut_directory,
1288 lut_resolution_1d, cleanup)
1289 colorspaces.append(ACESproxy)
1291 ACEScg = create_ACEScg(aces_ctl_directory, lut_directory,
1292 lut_resolution_1d, cleanup)
1293 colorspaces.append(ACEScg)
1295 ADX10 = create_ADX(lut_directory, lut_resolution_1d, bit_depth=10)
1296 colorspaces.append(ADX10)
1298 ADX16 = create_ADX(lut_directory, lut_resolution_1d, bit_depth=16)
1299 colorspaces.append(ADX16)
1301 lmts = create_LMTs(aces_ctl_directory,
1308 colorspaces.extend(lmts)
1310 odts, displays = create_ODTs(aces_ctl_directory,
1319 colorspaces.extend(odts)
1321 return ACES, colorspaces, displays, ACEScc