4444 'COLORSPACE_NAME_SUBSTITUTION_PATTERNS' ,
4545 'COLORSPACE_FAMILY_SUBSTITUTION_PATTERNS' ,
4646 'VIEW_NAME_SUBSTITUTION_PATTERNS' , 'DISPLAY_NAME_SUBSTITUTION_PATTERNS' ,
47- 'COLORSPACE_TO_CTL_TRANSFORM ' , 'beautify_name ' , 'beautify_colorspace_name ' ,
48- 'beautify_colorspace_family ' , 'beautify_view_name ' ,
49- 'beautify_display_name ' , 'ctl_transform_to_colorspace_name ' ,
50- 'ctl_transform_to_colorspace_family ' , 'ctl_transform_to_colorspace ' ,
51- 'node_to_builtin_transform' , ' node_to_colorspace' , 'generate_config_aces'
47+ 'beautify_name ' , 'beautify_colorspace_name ' , 'beautify_colorspace_family ' ,
48+ 'beautify_view_name ' , 'beautify_display_name ' ,
49+ 'ctl_transform_to_colorspace_name ' , 'ctl_transform_to_colorspace_family ' ,
50+ 'ctl_transform_to_colorspace ' , 'node_to_builtin_transform ' ,
51+ 'node_to_colorspace' , 'generate_config_aces'
5252]
5353
5454ACES_CONFIG_REFERENCE_COLORSPACE = 'ACES2065-1'
166166DISPLAY_NAME_SUBSTITUTION_PATTERNS : dict
167167"""
168168
169- COLORSPACE_TO_CTL_TRANSFORM = {}
170- """
171- Mapping between an *OpenColorIO* colorspace and an *ACES* *CTL* transform.
172-
173- The mapping is filled by :func:`opencolorio_config_aces.\
174- ctl_transform_to_colorspace` definition.
175-
176- COLORSPACE_TO_CTL_TRANSFORM : dict
177- """
178-
179169
180170def beautify_name (name , patterns ):
181171 """
@@ -402,8 +392,6 @@ def ctl_transform_to_colorspace(ctl_transform,
402392
403393 colorspace = colorspace_factory (** settings )
404394
405- COLORSPACE_TO_CTL_TRANSFORM [colorspace .getName ()] = ctl_transform
406-
407395 return colorspace
408396
409397
@@ -525,7 +513,9 @@ def node_to_colorspace(graph, node, complete_description=True):
525513@required ('OpenColorIO' )
526514def generate_config_aces (config_name = None ,
527515 validate = True ,
528- complete_description = True ):
516+ complete_description = True ,
517+ filterers = None ,
518+ additional_data = False ):
529519 """
530520 Generates the *aces-dev* reference implementation *OpenColorIO* Config.
531521
@@ -538,22 +528,36 @@ def generate_config_aces(config_name=None,
538528 Whether to validate the config.
539529 complete_description : bool, optional
540530 Whether to output the full *ACES* *CTL* transform descriptions.
531+ filterers : array_like, optional
532+ List of callables used to filter the *ACES* *CTL* transforms, each
533+ callable takes an *ACES* *CTL* transform as argument and returns
534+ whether to include or exclude the *ACES* *CTL* transform as a bool.
535+ additional_data : bool, optional
536+ Whether to return additional data.
541537
542538 Returns
543539 -------
544- Config
545- *OpenColorIO* config.
540+ Config or tuple
541+ *OpenColorIO* config or tuple of *OpenColorIO* config,
542+ :class:`opencolorio_config_aces.ConfigData` class instance and dict of
543+ *OpenColorIO* colorspaces and
544+ :class:`opencolorio_config_aces.config.reference.CTLTransform` class
545+ instances.
546546 """
547547
548548 import PyOpenColorIO as ocio
549549
550550 ctl_transforms = discover_aces_ctl_transforms ()
551551 classified_ctl_transforms = classify_aces_ctl_transforms (ctl_transforms )
552- filtered_ctl_transforms = filter_ctl_transforms (classified_ctl_transforms )
552+ filtered_ctl_transforms = filter_ctl_transforms (classified_ctl_transforms ,
553+ filterers )
553554
554555 graph = build_aces_conversion_graph (filtered_ctl_transforms )
555556
557+ colorspaces_to_ctl_transforms = {}
556558 colorspaces = []
559+ displays = set ()
560+ views = []
557561
558562 colorspaces += [
559563 colorspace_factory (
@@ -570,62 +574,37 @@ def generate_config_aces(config_name=None,
570574 graph , ACES_CONFIG_OUTPUT_ENCODING_COLORSPACE , 'Reverse' )),
571575 ]
572576
573- # "CSC"
574- csc = []
575- for node in filter_nodes (graph , [lambda x : x .family == 'csc' ]):
576- if node in (ACES_CONFIG_REFERENCE_COLORSPACE ,
577- ACES_CONFIG_OUTPUT_ENCODING_COLORSPACE ):
578- continue
579-
580- csc .append (node_to_colorspace (graph , node , complete_description ))
581- colorspaces += csc
582-
583- # "Input Transforms"
584- input_transforms = []
585- for node in filter_nodes (graph , [lambda x : x .family == 'input_transform' ]):
586- if node in (ACES_CONFIG_REFERENCE_COLORSPACE ,
587- ACES_CONFIG_OUTPUT_ENCODING_COLORSPACE ):
588- continue
589-
590- input_transforms .append (
591- node_to_colorspace (graph , node , complete_description ))
592- colorspaces += input_transforms
593-
594- # "LMTs"
595- lmts = []
596- for node in filter_nodes (graph , [lambda x : x .family == 'lmt' ]):
597- if node in (ACES_CONFIG_REFERENCE_COLORSPACE ,
598- ACES_CONFIG_OUTPUT_ENCODING_COLORSPACE ):
599- continue
600-
601- lmts .append (node_to_colorspace (graph , node , complete_description ))
602- colorspaces += lmts
603-
604- # "Output Transforms"
605- output_transforms = []
606- displays = set ()
607- views = []
608- for node in filter_nodes (graph ,
609- [lambda x : x .family == 'output_transform' ]):
610- if node in (ACES_CONFIG_REFERENCE_COLORSPACE ,
611- ACES_CONFIG_OUTPUT_ENCODING_COLORSPACE ):
612- continue
613-
614- colorspace = node_to_colorspace (graph , node , complete_description )
615- output_transforms .append (colorspace )
616- display = beautify_display_name (
617- node_to_ctl_transform (graph , node ).genus )
618- displays .add (display )
619- view = beautify_view_name (colorspace .getName ())
620- views .append ({
621- 'display' : display ,
622- 'view' : view ,
623- 'colorspace' : colorspace .getName ()
624- })
577+ for family in ('csc' , 'input_transform' , 'lmt' , 'output_transform' ):
578+ family_colourspaces = []
579+ for node in filter_nodes (graph , [lambda x : x .family == family ]):
580+ if node in (ACES_CONFIG_REFERENCE_COLORSPACE ,
581+ ACES_CONFIG_OUTPUT_ENCODING_COLORSPACE ):
582+ continue
583+
584+ colorspace = node_to_colorspace (graph , node , complete_description )
585+
586+ family_colourspaces .append (colorspace )
587+
588+ if family == 'output_transform' :
589+ display = beautify_display_name (
590+ node_to_ctl_transform (graph , node ).genus )
591+ displays .add (display )
592+ view = beautify_view_name (colorspace .getName ())
593+ views .append ({
594+ 'display' : display ,
595+ 'view' : view ,
596+ 'colorspace' : colorspace .getName ()
597+ })
598+
599+ if additional_data :
600+ colorspaces_to_ctl_transforms [colorspace ] = (
601+ node_to_ctl_transform (graph , node ))
602+
603+ colorspaces += family_colourspaces
604+
625605 displays = sorted (list (displays ))
626606 displays .insert (0 , displays .pop (displays .index ('sRGB' )))
627607 views = sorted (views , key = lambda x : (x ['display' ], x ['view' ]))
628- colorspaces += output_transforms
629608
630609 # Utility Raw
631610 colorspaces .append (
@@ -656,13 +635,17 @@ def generate_config_aces(config_name=None,
656635 }],
657636 profile_version = 2 )
658637
659- return generate_config (data , config_name , validate )
638+ config = generate_config (data , config_name , validate )
639+
640+ if additional_data :
641+ return config , data , colorspaces_to_ctl_transforms
642+ else :
643+ return config
660644
661645
662646if __name__ == '__main__' :
663647 import os
664648 import opencolorio_config_aces
665- from pprint import pprint
666649
667650 logging .basicConfig ()
668651 logging .getLogger ().setLevel (logging .INFO )
@@ -673,7 +656,9 @@ def generate_config_aces(config_name=None,
673656 if not os .path .exists (build_directory ):
674657 os .makedirs (build_directory )
675658
676- generate_config_aces (
677- os .path .join (build_directory , 'config-aces-reference.ocio' ))
659+ config , data , colorspaces = generate_config_aces (
660+ os .path .join (build_directory , 'config-aces-reference.ocio' ),
661+ additional_data = True )
678662
679- pprint (COLORSPACE_TO_CTL_TRANSFORM )
663+ for ctl_transform in colorspaces .values ():
664+ print (ctl_transform .aces_transform_id )
0 commit comments