+ # Defining the *Dolby PQ shaper that includes the AP1* primaries.
+ dolby_pq_shaper_api1_name = '%s - AP1' % dolby_pq_shaper_name
+ dolby_pq_shaper_api1_colorspace = copy.deepcopy(dolby_pq_shaper_colorspace)
+
+ dolby_pq_shaper_api1_colorspace.name = dolby_pq_shaper_api1_name
+ dolby_pq_shaper_api1_colorspace.description = (
+ 'The %s color space' % dolby_pq_shaper_api1_name)
+ dolby_pq_shaper_api1_colorspace.aliases = [
+ '%s_ap1' % compact(dolby_pq_shaper_name)]
+ dolby_pq_shaper_api1_colorspace.equality_group = dolby_pq_shaper_api1_name
+
+ # *AP1* primaries to *AP0* primaries
+ dolby_pq_shaper_api1_colorspace.to_reference_transforms.append({
+ 'type': 'matrix',
+ 'matrix': mat44_from_mat33(ACES_AP1_TO_AP0),
+ 'direction': 'forward'
+ })
+ colorspaces.append(dolby_pq_shaper_api1_colorspace)
+
+ return shaper_data, colorspaces
+
+
+# -------------------------------------------------------------------------
+# *Shapers*
+# -------------------------------------------------------------------------
+def create_shapers(aces_ctl_directory,
+ lut_directory,
+ lut_resolution_1d,
+ cleanup):
+
+ """
+ Creates sets of shaper colorspaces covering the *Log 2* and *Dolby PQ*
+ transfer functions and dynamic ranges suitable of use with the 48 nit,
+ 1000 nit, 2000 nit and 4000 nit *ACES Output Transforms*
+
+ Parameters
+ ----------
+ aces_ctl_directory : str or unicode
+ The path to the aces 'transforms/ctl/utilities'
+ lut_directory : str or unicode
+ The directory to use when generating LUTs
+ lut_resolution_1d : int
+ The resolution of generated 1D LUTs
+ cleanup : bool
+ Whether or not to clean up the intermediate images
+
+ Returns
+ -------
+ list of dicts
+ Values defining a set of Shapers
+ list of ColorSpaces
+ A list of Shaper colorspaces that covers a varying dynamic ranges and
+ transfer functions
+ """
+
+ colorspaces = []
+ shaper_data = {}
+
+ # Define the base *Log2 48 nits shaper*
+ #
+ (log2_48nits_shaper_data,
+ log2_48nits_colorspaces) = create_shapers_log2(aces_ctl_directory,
+ lut_directory,
+ lut_resolution_1d,
+ cleanup,
+ 'Log2 48 nits Shaper',
+ 0.18,
+ -6.5,
+ 6.5)
+ colorspaces.extend(log2_48nits_colorspaces)
+ shaper_data.update(log2_48nits_shaper_data)
+
+ # Define the base *Log2 1000 nits shaper*
+ #
+ (log2_1000nits_shaper_data,
+ log2_1000nits_colorspaces) = create_shapers_log2(aces_ctl_directory,
+ lut_directory,
+ lut_resolution_1d,
+ cleanup,
+ 'Log2 1000 nits Shaper',
+ 0.18,
+ -12.0,
+ 10.0)
+ colorspaces.extend(log2_1000nits_colorspaces)
+ shaper_data.update(log2_1000nits_shaper_data)
+
+ # Define the base *Log2 2000 nits shaper*
+ #
+ (log2_2000nits_shaper_data,
+ log2_2000nits_colorspaces) = create_shapers_log2(aces_ctl_directory,
+ lut_directory,
+ lut_resolution_1d,
+ cleanup,
+ 'Log2 2000 nits Shaper',
+ 0.18,
+ -12.0,
+ 11.0)
+ colorspaces.extend(log2_2000nits_colorspaces)
+ shaper_data.update(log2_2000nits_shaper_data)
+
+ # Define the base *Log2 4000 nits shaper*
+ #
+ (log2_4000nits_shaper_data,
+ log2_4000nits_colorspaces) = create_shapers_log2(aces_ctl_directory,
+ lut_directory,
+ lut_resolution_1d,
+ cleanup,
+ 'Log2 4000 nits Shaper',
+ 0.18,
+ -12.0,
+ 12.0)
+ colorspaces.extend(log2_4000nits_colorspaces)
+ shaper_data.update(log2_4000nits_shaper_data)
+
+ # Define the base *Dolby PQ transfer function*