2 # -*- coding: utf-8 -*-
5 Implements support for *Panasonic* colorspaces conversions and transfer
12 import PyOpenColorIO as ocio
14 import aces_ocio.generate_lut as genlut
15 from aces_ocio.utilities import ColorSpace
17 __author__ = 'ACES Developers'
18 __copyright__ = 'Copyright (C) 2014 - 2015 - ACES Developers'
20 __maintainer__ = 'ACES Developers'
21 __email__ = 'aces@oscars.org'
22 __status__ = 'Production'
24 __all__ = ['create_v_log',
28 def create_v_log(gamut,
34 Creates colorspace covering the conversion from VLog to ACES, with various transfer
35 functions and encoding gamuts covered
40 The name of the encoding gamut to use.
41 transfer_function : str
42 The name of the transfer function to use
43 lut_directory : str or unicode
44 The directory to use when generating LUTs
45 lut_resolution_1d : int
46 The resolution of generated 1D LUTs
48 Aliases for this colorspace
53 A ColorSpace container class referencing the LUTs, matrices and identifying
54 information for the requested colorspace.
57 name = '%s - %s' % (transfer_function, gamut)
58 if transfer_function == '':
59 name = 'Linear - %s' % gamut
61 name = 'Curve - %s' % transfer_function
66 cs.equality_group = ''
67 cs.family = 'Input/Panasonic'
70 # A linear space needs allocation variables
71 if transfer_function == '':
72 cs.allocation_type = ocio.Constants.ALLOCATION_LG2
73 cs.allocation_vars = [-8, 5, 0.00390625]
75 def v_log_to_linear(x):
82 return (x - 0.125) / 5.6
84 return pow(10, (x - d) / c) - b
86 cs.to_reference_transforms = []
88 if transfer_function == 'V-Log':
89 data = array.array('f', '\0' * lut_resolution_1d * 4)
90 for c in range(lut_resolution_1d):
91 data[c] = v_log_to_linear(float(c) / (lut_resolution_1d - 1))
93 lut = '%s_to_linear.spi1d' % transfer_function
95 os.path.join(lut_directory, lut),
102 cs.to_reference_transforms.append({
105 'interpolation': 'linear',
106 'direction': 'forward'})
108 if gamut == 'V-Gamut':
109 cs.to_reference_transforms.append({
111 'matrix': [0.724382758, 0.166748484, 0.108497411, 0.0,
112 0.021354009, 0.985138372, -0.006319092, 0.0,
113 -0.009234278, -0.00104295, 1.010272625, 0.0,
115 'direction': 'forward'})
117 cs.from_reference_transforms = []
121 def create_colorspaces(lut_directory, lut_resolution_1d):
123 Generates the colorspace conversions.
127 lut_directory : str or unicode
128 The directory to use when generating LUTs
129 lut_resolution_1d : int
130 The resolution of generated 1D LUTs
135 A list of colorspaces for Panasonic cameras and encodings
141 v_log_1 = create_v_log(
147 colorspaces.append(v_log_1)
150 v_log_2 = create_v_log(
156 colorspaces.append(v_log_2)
159 v_log_3 = create_v_log(
165 colorspaces.append(v_log_3)