2 # -*- coding: utf-8 -*-
5 Implements support for *GoPro* colorspaces conversions and transfer functions.
8 from __future__ import division
13 import PyOpenColorIO as ocio
15 import aces_ocio.generate_lut as genlut
16 from aces_ocio.utilities import (ColorSpace, sanitize)
18 __author__ = 'ACES Developers'
19 __copyright__ = 'Copyright (C) 2014 - 2015 - ACES Developers'
21 __maintainer__ = 'ACES Developers'
22 __email__ = 'aces@oscars.org'
23 __status__ = 'Production'
25 __all__ = ['create_protune',
29 def create_protune(gamut,
43 Parameter description.
48 Return value description.
51 name = '%s - %s' % (transfer_function, gamut)
52 if transfer_function == '':
53 name = 'Linear - %s' % gamut
55 name = '%s' % transfer_function
60 cs.equality_group = ''
64 # A linear space needs allocation variables
65 if transfer_function == '':
66 cs.allocation_type = ocio.Constants.ALLOCATION_LG2
67 cs.allocation_vars = [-8, 5, 0.00390625]
69 def protune_to_linear(normalized_code_value):
73 linear = ((pow(c1, (normalized_code_value)) - c2) / c3)
77 cs.to_reference_transforms = []
79 if transfer_function == 'Protune Flat':
80 data = array.array('f', '\0' * lut_resolution_1d * 4)
81 for c in range(lut_resolution_1d):
82 data[c] = protune_to_linear(float(c) / (lut_resolution_1d - 1))
84 lut = '%s_to_linear.spi1d' % transfer_function
87 os.path.join(lut_directory, lut),
94 cs.to_reference_transforms.append({
97 'interpolation': 'linear',
98 'direction': 'forward'})
100 if gamut == 'Protune Gamut':
101 cs.to_reference_transforms.append({
103 'matrix': [ 0.533448429, 0.32413911, 0.142412421, 0,
104 -0.050729924, 1.07572006, -0.024990416, 0,
105 0.071419661, -0.290521962, 1.219102381, 0,
107 'direction': 'forward'})
109 cs.from_reference_transforms = []
113 def create_colorspaces(lut_directory, lut_resolution_1d):
115 Generates the colorspace conversions.
120 Parameter description.
125 Return value description.
131 protune_1 = create_protune(
137 ["protuneflat_protunegamut"])
138 colorspaces.append(protune_1)
141 protune_2 = create_protune(
148 colorspaces.append(protune_2)
151 protune_3 = create_protune(
157 ["lin_protunegamut"])
158 colorspaces.append(protune_3)