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 *ACES 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 *ACES AP1*.
60 ACES_AP0_TO_AP1 = [1.4514393161, -0.2365107469, -0.2149285693,
61 -0.0765537734, 1.1762296998, -0.0996759264,
62 0.0083161484, -0.0060324498, 0.9977163014]
64 # Matrix converting *ACES AP0* primaries to *XYZ*.
65 ACES_AP0_TO_XYZ = [0.9525523959, 0.0000000000, 0.0000936786,
66 0.3439664498, 0.7281660966, -0.0721325464,
67 0.0000000000, 0.0000000000, 1.0088251844]
69 # Matrix converting *ACES AP0* primaries to *XYZ*.
70 ACES_XYZ_TO_AP0 = [1.0498110175, 0.0000000000, -0.0000974845,
71 -0.4959030231, 1.3733130458, 0.0982400361,
72 0.0000000000, 0.0000000000, 0.9912520182]
82 Parameter description.
87 Return value description.
90 # Defining the reference colorspace.
91 aces2065_1 = ColorSpace('ACES2065-1')
92 aces2065_1.description = (
93 'The Academy Color Encoding System reference color space')
94 aces2065_1.equality_group = ''
95 aces2065_1.aliases = ["lin_ap0", "aces"]
96 aces2065_1.family = 'ACES'
97 aces2065_1.is_data = False
98 aces2065_1.allocation_type = ocio.Constants.ALLOCATION_LG2
99 aces2065_1.allocation_vars = [-8, 5, 0.00390625]
104 def create_ACEScc(aces_ctl_directory,
113 Creates the *ACEScc* colorspace.
118 Parameter description.
126 cs = ColorSpace(name)
127 cs.description = 'The %s color space' % name
128 cs.aliases = ["acescc_ap1"]
129 cs.equality_group = ''
132 cs.allocation_type = ocio.Constants.ALLOCATION_UNIFORM
133 cs.allocation_vars = [min_value, max_value]
135 ctls = [os.path.join(aces_ctl_directory,
137 'ACEScsc.ACEScc_to_ACES.a1.0.0.ctl')]
138 lut = '%s_to_linear.spi1d' % name
142 generate_1d_LUT_from_CTL(
143 os.path.join(lut_directory, lut),
149 {'transferFunctionOnly':1},
156 cs.to_reference_transforms = []
157 cs.to_reference_transforms.append({
160 'interpolation': 'linear',
161 'direction': 'forward'})
163 # *AP1* primaries to *AP0* primaries.
164 cs.to_reference_transforms.append({
166 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
167 'direction': 'forward'})
169 cs.from_reference_transforms = []
173 def create_ACESproxy(aces_ctl_directory,
179 Creates the *ACESproxy* colorspace.
184 Parameter description.
189 *ACESproxy* colorspace.
192 cs = ColorSpace(name)
193 cs.description = 'The %s color space' % name
194 cs.aliases = ["acesproxy_ap1"]
195 cs.equality_group = ''
199 ctls = [os.path.join(aces_ctl_directory,
201 'ACEScsc.ACESproxy10i_to_ACES.a1.0.0.ctl'),
202 # This transform gets back to the *AP1* primaries.
203 # Useful as the 1d LUT is only covering the transfer function.
204 # The primaries switch is covered by the matrix below:
205 os.path.join(aces_ctl_directory,
207 'ACEScsc.ACES_to_ACEScg.a1.0.0.ctl')]
208 lut = '%s_to_linear.spi1d' % name
212 generate_1d_LUT_from_CTL(
213 os.path.join(lut_directory, lut),
226 cs.to_reference_transforms = []
227 cs.to_reference_transforms.append({
230 'interpolation': 'linear',
231 'direction': 'forward'})
233 # *AP1* primaries to *AP0* primaries.
234 cs.to_reference_transforms.append({
236 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
237 'direction': 'forward'})
239 cs.from_reference_transforms = []
243 # -------------------------------------------------------------------------
245 # -------------------------------------------------------------------------
246 def create_ACEScg(aces_ctl_directory,
252 Creates the *ACEScg* colorspace.
257 Parameter description.
265 cs = ColorSpace(name)
266 cs.description = 'The %s color space' % name
267 cs.aliases = ["lin_ap1"]
268 cs.equality_group = ''
271 cs.allocation_type = ocio.Constants.ALLOCATION_LG2
272 cs.allocation_vars = [-8, 5, 0.00390625]
274 cs.to_reference_transforms = []
276 # *AP1* primaries to *AP0* primaries.
277 cs.to_reference_transforms.append({
279 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
280 'direction': 'forward'})
282 cs.from_reference_transforms = []
286 # -------------------------------------------------------------------------
288 # -------------------------------------------------------------------------
289 def create_ADX(lut_directory,
294 Creates the *ADX* colorspace.
299 Parameter description.
307 name = '%s%s' % (name, bit_depth)
308 cs = ColorSpace(name)
309 cs.description = '%s color space - used for film scans' % name
310 cs.aliases = ["adx%s" % str(bit_depth)]
311 cs.equality_group = ''
316 cs.bit_depth = ocio.Constants.BIT_DEPTH_UINT10
317 ADX_to_CDD = [1023 / 500, 0, 0, 0,
321 offset = [-95 / 500, -95 / 500, -95 / 500, 0]
322 elif bit_depth == 16:
323 cs.bit_depth = ocio.Constants.BIT_DEPTH_UINT16
324 ADX_to_CDD = [65535 / 8000, 0, 0, 0,
325 0, 65535 / 8000, 0, 0,
326 0, 0, 65535 / 8000, 0,
328 offset = [-1520 / 8000, -1520 / 8000, -1520 / 8000, 0]
330 cs.to_reference_transforms = []
332 # Converting from *ADX* to *Channel-Dependent Density*.
333 cs.to_reference_transforms.append({
335 'matrix': ADX_to_CDD,
337 'direction': 'forward'})
339 # Convert from Channel-Dependent Density to Channel-Independent Density
340 cs.to_reference_transforms.append({
342 'matrix': [0.75573, 0.22197, 0.02230, 0,
343 0.05901, 0.96928, -0.02829, 0,
344 0.16134, 0.07406, 0.76460, 0,
346 'direction': 'forward'})
348 # Copied from *Alex Fry*'s *adx_cid_to_rle.py*
349 def create_CID_to_RLE_LUT():
351 def interpolate_1D(x, xp, fp):
352 return numpy.interp(x, xp, fp)
354 LUT_1D_xp = [-0.190000000000000,
366 LUT_1D_fp = [-6.000000000000000,
378 REF_PT = ((7120 - 1520) / 8000 * (100 / 55) -
383 return interpolate_1D(x, LUT_1D_xp, LUT_1D_fp)
384 return (100 / 55) * x - REF_PT
386 def fit(value, from_min, from_max, to_min, to_max):
387 if from_min == from_max:
388 raise ValueError('from_min == from_max')
389 return (value - from_min) / (from_max - from_min) * (
390 to_max - to_min) + to_min
392 num_samples = 2 ** 12
395 for i in xrange(num_samples):
396 x = i / (num_samples - 1)
397 x = fit(x, 0, 1, domain[0], domain[1])
398 data.append(cid_to_rle(x))
400 lut = 'ADX_CID_to_RLE.spi1d'
401 write_SPI_1d(os.path.join(lut_directory, lut),
409 # Converting *Channel Independent Density* values to
410 # *Relative Log Exposure* values.
411 lut = create_CID_to_RLE_LUT()
412 cs.to_reference_transforms.append({
415 'interpolation': 'linear',
416 'direction': 'forward'})
418 # Converting *Relative Log Exposure* values to
419 # *Relative Exposure* values.
420 cs.to_reference_transforms.append({
423 'direction': 'inverse'})
425 # Convert *Relative Exposure* values to *ACES* values.
426 cs.to_reference_transforms.append({
428 'matrix': [0.72286, 0.12630, 0.15084, 0,
429 0.11923, 0.76418, 0.11659, 0,
430 0.01427, 0.08213, 0.90359, 0,
432 'direction': 'forward'})
434 cs.from_reference_transforms = []
438 def create_ACES_LMT(lmt_name,
443 lut_resolution_1d=1024,
444 lut_resolution_3d=64,
448 Creates the *ACES LMT* colorspace.
453 Parameter description.
458 *ACES LMT* colorspace.
464 cs = ColorSpace('%s' % lmt_name)
465 cs.description = 'The ACES Look Transform: %s' % lmt_name
467 cs.equality_group = ''
470 cs.allocation_type = ocio.Constants.ALLOCATION_LG2
471 cs.allocation_vars = [-8, 5, 0.00390625]
473 pprint.pprint(lmt_values)
475 # Generating the *shaper* transform.
478 shaper_from_ACES_CTL,
480 shaper_params) = shaper_info
482 shaper_lut = '%s_to_linear.spi1d' % shaper_name
483 if not os.path.exists(os.path.join(lut_directory, shaper_lut)):
484 ctls = [shaper_to_ACES_CTL % aces_ctl_directory]
486 shaper_lut = sanitize(shaper_lut)
488 generate_1d_LUT_from_CTL(
489 os.path.join(lut_directory, shaper_lut),
493 1 / shaper_input_scale,
502 shaper_OCIO_transform = {
505 'interpolation': 'linear',
506 'direction': 'inverse'}
508 # Generating the forward transform.
509 cs.from_reference_transforms = []
511 if 'transformCTL' in lmt_values:
512 ctls = [shaper_to_ACES_CTL % aces_ctl_directory,
513 os.path.join(aces_ctl_directory,
514 lmt_values['transformCTL'])]
515 lut = '%s.%s.spi3d' % (shaper_name, lmt_name)
519 generate_3d_LUT_from_CTL(
520 os.path.join(lut_directory, lut),
524 1 / shaper_input_scale,
530 cs.from_reference_transforms.append(shaper_OCIO_transform)
531 cs.from_reference_transforms.append({
534 'interpolation': 'tetrahedral',
535 'direction': 'forward'})
537 # Generating the inverse transform.
538 cs.to_reference_transforms = []
540 if 'transformCTLInverse' in lmt_values:
541 ctls = [os.path.join(aces_ctl_directory,
542 lmt_values['transformCTLInverse']),
543 shaper_from_ACES_CTL % aces_ctl_directory]
544 lut = 'Inverse.%s.%s.spi3d' % (odt_name, shaper_name)
548 generate_3d_LUT_from_CTL(
549 os.path.join(lut_directory, lut),
562 cs.to_reference_transforms.append({
565 'interpolation': 'tetrahedral',
566 'direction': 'forward'})
568 shaper_inverse = shaper_OCIO_transform.copy()
569 shaper_inverse['direction'] = 'forward'
570 cs.to_reference_transforms.append(shaper_inverse)
575 def create_ACES_RRT_plus_ODT(odt_name,
580 lut_resolution_1d=1024,
581 lut_resolution_3d=64,
590 Parameter description.
595 Return value description.
601 cs = ColorSpace('%s' % odt_name)
602 cs.description = '%s - %s Output Transform' % (
603 odt_values['transformUserNamePrefix'], odt_name)
605 cs.equality_group = ''
609 pprint.pprint(odt_values)
611 # Generating the *shaper* transform.
614 shaper_from_ACES_CTL,
616 shaper_params) = shaper_info
618 if 'legalRange' in odt_values:
619 shaper_params['legalRange'] = odt_values['legalRange']
621 shaper_params['legalRange'] = 0
623 shaper_lut = '%s_to_linear.spi1d' % shaper_name
624 if not os.path.exists(os.path.join(lut_directory, shaper_lut)):
625 ctls = [shaper_to_ACES_CTL % aces_ctl_directory]
627 shaper_lut = sanitize(shaper_lut)
629 generate_1d_LUT_from_CTL(
630 os.path.join(lut_directory, shaper_lut),
634 1 / shaper_input_scale,
643 shaper_OCIO_transform = {
646 'interpolation': 'linear',
647 'direction': 'inverse'}
649 # Generating the *forward* transform.
650 cs.from_reference_transforms = []
652 if 'transformLUT' in odt_values:
653 transform_LUT_file_name = os.path.basename(
654 odt_values['transformLUT'])
655 lut = os.path.join(lut_directory, transform_LUT_file_name)
656 shutil.copy(odt_values['transformLUT'], lut)
658 cs.from_reference_transforms.append(shaper_OCIO_transform)
659 cs.from_reference_transforms.append({
661 'path': transform_LUT_file_name,
662 'interpolation': 'tetrahedral',
663 'direction': 'forward'})
664 elif 'transformCTL' in odt_values:
666 shaper_to_ACES_CTL % aces_ctl_directory,
667 os.path.join(aces_ctl_directory,
670 os.path.join(aces_ctl_directory,
672 odt_values['transformCTL'])]
673 lut = '%s.RRT.a1.0.0.%s.spi3d' % (shaper_name, odt_name)
677 generate_3d_LUT_from_CTL(
678 os.path.join(lut_directory, lut),
683 1 / shaper_input_scale,
689 cs.from_reference_transforms.append(shaper_OCIO_transform)
690 cs.from_reference_transforms.append({
693 'interpolation': 'tetrahedral',
694 'direction': 'forward'})
696 # Generating the *inverse* transform.
697 cs.to_reference_transforms = []
699 if 'transformLUTInverse' in odt_values:
700 transform_LUT_inverse_file_name = os.path.basename(
701 odt_values['transformLUTInverse'])
702 lut = os.path.join(lut_directory, transform_LUT_inverse_file_name)
703 shutil.copy(odt_values['transformLUTInverse'], lut)
705 cs.to_reference_transforms.append({
707 'path': transform_LUT_inverse_file_name,
708 'interpolation': 'tetrahedral',
709 'direction': 'forward'})
711 shaper_inverse = shaper_OCIO_transform.copy()
712 shaper_inverse['direction'] = 'forward'
713 cs.to_reference_transforms.append(shaper_inverse)
714 elif 'transformCTLInverse' in odt_values:
715 ctls = [os.path.join(aces_ctl_directory,
717 odt_values['transformCTLInverse']),
718 os.path.join(aces_ctl_directory,
720 'InvRRT.a1.0.0.ctl'),
721 shaper_from_ACES_CTL % aces_ctl_directory]
722 lut = 'InvRRT.a1.0.0.%s.%s.spi3d' % (odt_name, shaper_name)
726 generate_3d_LUT_from_CTL(
727 os.path.join(lut_directory, lut),
738 cs.to_reference_transforms.append({
741 'interpolation': 'tetrahedral',
742 'direction': 'forward'})
744 shaper_inverse = shaper_OCIO_transform.copy()
745 shaper_inverse['direction'] = 'forward'
746 cs.to_reference_transforms.append(shaper_inverse)
751 def create_generic_log(aces_ctl_directory,
764 Creates the *Generic Log* colorspace.
769 Parameter description.
774 *Generic Log* colorspace.
777 cs = ColorSpace(name)
778 cs.description = 'The %s color space' % name
780 cs.equality_group = name
781 cs.family = 'Utility'
784 ctls = [os.path.join(
787 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl')]
788 lut = '%s_to_linear.spi1d' % name
792 generate_1d_LUT_from_CTL(
793 os.path.join(lut_directory, lut),
799 {'middleGrey': middle_grey,
800 'minExposure': min_exposure,
801 'maxExposure': max_exposure},
808 cs.to_reference_transforms = []
809 cs.to_reference_transforms.append({
812 'interpolation': 'linear',
813 'direction': 'forward'})
815 cs.from_reference_transforms = []
819 def create_LMTs(aces_ctl_directory,
832 Parameter description.
837 Return value description.
842 # -------------------------------------------------------------------------
844 # -------------------------------------------------------------------------
845 lmt_lut_resolution_1d = max(4096, lut_resolution_1d)
846 lmt_lut_resolution_3d = max(65, lut_resolution_3d)
848 # Defining the *Log 2* shaper.
849 lmt_shaper_name = 'LMT Shaper'
850 lmt_shaper_name_aliases = ['crv_lmtshaper']
856 lmt_shaper = create_generic_log(aces_ctl_directory,
858 lmt_lut_resolution_1d,
860 name=lmt_shaper_name,
861 middle_grey=lmt_params['middleGrey'],
862 min_exposure=lmt_params['minExposure'],
863 max_exposure=lmt_params['maxExposure'],
864 aliases=lmt_shaper_name_aliases)
865 colorspaces.append(lmt_shaper)
867 shaper_input_scale_generic_log2 = 1
869 # *Log 2* shaper name and *CTL* transforms bundled up.
874 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl'),
877 'ACESlib.OCIO_shaper_lin_to_log2_param.a1.0.0.ctl'),
878 shaper_input_scale_generic_log2,
881 sorted_LMTs = sorted(lmt_info.iteritems(), key=lambda x: x[1])
883 for lmt in sorted_LMTs:
884 lmt_name, lmt_values = lmt
885 lmt_aliases = ["look_%s" % compact(lmt_values['transformUserName'])]
886 cs = create_ACES_LMT(
887 lmt_values['transformUserName'],
892 lmt_lut_resolution_1d,
893 lmt_lut_resolution_3d,
896 colorspaces.append(cs)
901 def create_ODTs(aces_ctl_directory,
908 linear_display_space,
916 Parameter description.
921 Return value description.
927 # -------------------------------------------------------------------------
928 # *RRT / ODT* Shaper Options
929 # -------------------------------------------------------------------------
932 # Defining the *Log 2* shaper.
933 log2_shaper_name = shaper_name
934 log2_shaper_name_aliases = ["crv_%s" % compact(shaper_name)]
940 log2_shaper = create_generic_log(
945 name=log2_shaper_name,
946 middle_grey=log2_params['middleGrey'],
947 min_exposure=log2_params['minExposure'],
948 max_exposure=log2_params['maxExposure'],
949 aliases=log2_shaper_name_aliases)
950 colorspaces.append(log2_shaper)
952 shaper_input_scale_generic_log2 = 1
954 # *Log 2* shaper name and *CTL* transforms bundled up.
959 'ACESlib.OCIO_shaper_log2_to_lin_param.a1.0.0.ctl'),
962 'ACESlib.OCIO_shaper_lin_to_log2_param.a1.0.0.ctl'),
963 shaper_input_scale_generic_log2,
966 shaper_data[log2_shaper_name] = log2_shaper_data
968 # Shaper that also includes the AP1 primaries.
969 # Needed for some LUT baking steps.
970 log2_shaper_api1_name_aliases = ["%s_ap1" % compact(shaper_name)]
971 log2_shaper_ap1 = create_generic_log(
976 name=log2_shaper_name,
977 middle_grey=log2_params['middleGrey'],
978 min_exposure=log2_params['minExposure'],
979 max_exposure=log2_params['maxExposure'],
980 aliases=log2_shaper_api1_name_aliases)
981 log2_shaper_ap1.name = '%s - AP1' % log2_shaper_ap1.name
983 # *AP1* primaries to *AP0* primaries.
984 log2_shaper_ap1.to_reference_transforms.append({
986 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
987 'direction': 'forward'
989 colorspaces.append(log2_shaper_ap1)
991 rrt_shaper = log2_shaper_data
993 # *RRT + ODT* combinations.
994 sorted_odts = sorted(odt_info.iteritems(), key=lambda x: x[1])
996 for odt in sorted_odts:
997 (odt_name, odt_values) = odt
999 # Generating legal range transform for *ODTs* that can generate
1000 # either *legal* or *full* output.
1001 if odt_values['transformHasFullLegalSwitch']:
1002 odt_name_legal = '%s - Legal' % odt_values['transformUserName']
1004 odt_name_legal = odt_values['transformUserName']
1006 odt_legal = odt_values.copy()
1007 odt_legal['legalRange'] = 1
1009 odt_aliases = ["out_%s" % compact(odt_name_legal)]
1011 cs = create_ACES_RRT_plus_ODT(
1021 colorspaces.append(cs)
1023 displays[odt_name_legal] = {
1024 'Linear': linear_display_space,
1025 'Log': log_display_space,
1026 'Output Transform': cs}
1029 # Generating full range transform for *ODTs* that can generate
1030 # either *legal* or *full* output.
1031 if odt_values['transformHasFullLegalSwitch']:
1032 print('Generating full range ODT for %s' % odt_name)
1034 odt_name_full = '%s - Full' % odt_values['transformUserName']
1035 odt_full = odt_values.copy()
1036 odt_full['legalRange'] = 0
1038 odt_full_aliases = ["out_%s" % compact(odt_name_full)]
1040 cs_full = create_ACES_RRT_plus_ODT(
1050 colorspaces.append(cs_full)
1052 displays[odt_name_full] = {
1053 'Linear': linear_display_space,
1054 'Log': log_display_space,
1055 'Output Transform': cs_full}
1057 return (colorspaces, displays)
1060 def get_transform_info(ctl_transform):
1067 Parameter description.
1072 Return value description.
1075 with open(ctl_transform, 'rb') as fp:
1076 lines = fp.readlines()
1078 # Retrieving the *transform ID* and *User Name*.
1079 transform_id = lines[1][3:].split('<')[1].split('>')[1].strip()
1080 transform_user_name = '-'.join(
1081 lines[2][3:].split('<')[1].split('>')[1].split('-')[1:]).strip()
1082 transform_user_name_prefix = (
1083 lines[2][3:].split('<')[1].split('>')[1].split('-')[0].strip())
1085 # Figuring out if this transform has options for processing full and legal range
1086 transform_full_legal_switch = False
1088 if line.strip() == "input varying int legalRange = 0":
1089 # print( "%s has legal range flag" % transform_user_name)
1090 transform_full_legal_switch = True
1093 return (transform_id, transform_user_name, transform_user_name_prefix,
1094 transform_full_legal_switch)
1097 def get_ODTs_info(aces_ctl_directory):
1101 For versions after WGR9.
1106 Parameter description.
1111 Return value description.
1114 # TODO: Investigate usage of *files_walker* definition here.
1115 # Credit to *Alex Fry* for the original approach here.
1116 odt_dir = os.path.join(aces_ctl_directory, 'odt')
1118 for dir_name, subdir_list, file_list in os.walk(odt_dir):
1119 for fname in file_list:
1120 all_odt.append((os.path.join(dir_name, fname)))
1122 odt_CTLs = [x for x in all_odt if
1123 ('InvODT' not in x) and (os.path.split(x)[-1][0] != '.')]
1127 for odt_CTL in odt_CTLs:
1128 odt_tokens = os.path.split(odt_CTL)
1130 # Handling nested directories.
1131 odt_path_tokens = os.path.split(odt_tokens[-2])
1132 odt_dir = odt_path_tokens[-1]
1133 while odt_path_tokens[-2][-3:] != 'odt':
1134 odt_path_tokens = os.path.split(odt_path_tokens[-2])
1135 odt_dir = os.path.join(odt_path_tokens[-1], odt_dir)
1137 # Building full name,
1138 transform_CTL = odt_tokens[-1]
1139 odt_name = string.join(transform_CTL.split('.')[1:-1], '.')
1141 # Finding id, user name and user name prefix.
1143 transform_user_name,
1144 transform_user_name_prefix,
1145 transform_full_legal_switch) = get_transform_info(
1146 os.path.join(aces_ctl_directory, 'odt', odt_dir, transform_CTL))
1149 transform_CTL_inverse = 'InvODT.%s.ctl' % odt_name
1150 if not os.path.exists(
1151 os.path.join(odt_tokens[-2], transform_CTL_inverse)):
1152 transform_CTL_inverse = None
1154 # Add to list of ODTs
1156 odts[odt_name]['transformCTL'] = os.path.join(odt_dir, transform_CTL)
1157 if transform_CTL_inverse is not None:
1158 odts[odt_name]['transformCTLInverse'] = os.path.join(
1159 odt_dir, transform_CTL_inverse)
1161 odts[odt_name]['transformID'] = transform_ID
1162 odts[odt_name]['transformUserNamePrefix'] = transform_user_name_prefix
1163 odts[odt_name]['transformUserName'] = transform_user_name
1165 'transformHasFullLegalSwitch'] = transform_full_legal_switch
1167 forward_CTL = odts[odt_name]['transformCTL']
1169 print('ODT : %s' % odt_name)
1170 print('\tTransform ID : %s' % transform_ID)
1171 print('\tTransform User Name Prefix : %s' % transform_user_name_prefix)
1172 print('\tTransform User Name : %s' % transform_user_name)
1174 '\tHas Full / Legal Switch : %s' % transform_full_legal_switch)
1175 print('\tForward ctl : %s' % forward_CTL)
1176 if 'transformCTLInverse' in odts[odt_name]:
1177 inverse_CTL = odts[odt_name]['transformCTLInverse']
1178 print('\tInverse ctl : %s' % inverse_CTL)
1180 print('\tInverse ctl : %s' % 'None')
1187 def get_LMTs_info(aces_ctl_directory):
1191 For versions after WGR9.
1196 Parameter description.
1201 Return value description.
1204 # TODO: Investigate refactoring with previous definition.
1206 # Credit to Alex Fry for the original approach here
1207 lmt_dir = os.path.join(aces_ctl_directory, 'lmt')
1209 for dir_name, subdir_list, file_list in os.walk(lmt_dir):
1210 for fname in file_list:
1211 all_lmt.append((os.path.join(dir_name, fname)))
1213 lmt_CTLs = [x for x in all_lmt if
1214 ('InvLMT' not in x) and ('README' not in x) and (
1215 os.path.split(x)[-1][0] != '.')]
1219 for lmt_CTL in lmt_CTLs:
1220 lmt_tokens = os.path.split(lmt_CTL)
1222 # Handlimg nested directories.
1223 lmt_path_tokens = os.path.split(lmt_tokens[-2])
1224 lmt_dir = lmt_path_tokens[-1]
1225 while lmt_path_tokens[-2][-3:] != 'ctl':
1226 lmt_path_tokens = os.path.split(lmt_path_tokens[-2])
1227 lmt_dir = os.path.join(lmt_path_tokens[-1], lmt_dir)
1229 # Building full name.
1230 transform_CTL = lmt_tokens[-1]
1231 lmt_name = string.join(transform_CTL.split('.')[1:-1], '.')
1233 # Finding id, user name and user name prefix.
1235 transform_user_name,
1236 transform_user_name_prefix,
1237 transform_full_legal_switch) = get_transform_info(
1238 os.path.join(aces_ctl_directory, lmt_dir, transform_CTL))
1241 transform_CTL_inverse = 'InvLMT.%s.ctl' % lmt_name
1242 if not os.path.exists(
1243 os.path.join(lmt_tokens[-2], transform_CTL_inverse)):
1244 transform_CTL_inverse = None
1247 lmts[lmt_name]['transformCTL'] = os.path.join(lmt_dir, transform_CTL)
1248 if transform_CTL_inverse is not None:
1249 lmts[lmt_name]['transformCTLInverse'] = os.path.join(
1250 lmt_dir, transform_CTL_inverse)
1252 lmts[lmt_name]['transformID'] = transform_ID
1253 lmts[lmt_name]['transformUserNamePrefix'] = transform_user_name_prefix
1254 lmts[lmt_name]['transformUserName'] = transform_user_name
1256 forward_CTL = lmts[lmt_name]['transformCTL']
1258 print('LMT : %s' % lmt_name)
1259 print('\tTransform ID : %s' % transform_ID)
1260 print('\tTransform User Name Prefix : %s' % transform_user_name_prefix)
1261 print('\tTransform User Name : %s' % transform_user_name)
1262 print('\t Forward ctl : %s' % forward_CTL)
1263 if 'transformCTLInverse' in lmts[lmt_name]:
1264 inverse_CTL = lmts[lmt_name]['transformCTLInverse']
1265 print('\t Inverse ctl : %s' % inverse_CTL)
1267 print('\t Inverse ctl : %s' % 'None')
1274 def create_colorspaces(aces_ctl_directory,
1283 Generates the colorspace conversions.
1288 Parameter description.
1293 Return value description.
1298 ACES = create_ACES()
1300 ACEScc = create_ACEScc(aces_ctl_directory, lut_directory,
1301 lut_resolution_1d, cleanup,
1302 min_value=-0.35840, max_value=1.468)
1303 colorspaces.append(ACEScc)
1305 ACESproxy = create_ACESproxy(aces_ctl_directory, lut_directory,
1306 lut_resolution_1d, cleanup)
1307 colorspaces.append(ACESproxy)
1309 ACEScg = create_ACEScg(aces_ctl_directory, lut_directory,
1310 lut_resolution_1d, cleanup)
1311 colorspaces.append(ACEScg)
1313 ADX10 = create_ADX(lut_directory, lut_resolution_1d, bit_depth=10)
1314 colorspaces.append(ADX10)
1316 ADX16 = create_ADX(lut_directory, lut_resolution_1d, bit_depth=16)
1317 colorspaces.append(ADX16)
1319 lmts = create_LMTs(aces_ctl_directory,
1326 colorspaces.extend(lmts)
1328 odts, displays = create_ODTs(aces_ctl_directory,
1337 colorspaces.extend(odts)
1339 return ACES, colorspaces, displays, ACEScc