Added GoPro Protune support
[OpenColorIO-Configs.git] / aces_1.0.0 / python / aces_ocio / create_red_colorspaces.py
index 5443f16..3f52e24 100644 (file)
@@ -5,9 +5,13 @@
 Implements support for *RED* colorspaces conversions and transfer functions.
 """
 
+from __future__ import division
+
 import array
 import os
 
+import PyOpenColorIO as ocio
+
 import aces_ocio.generate_lut as genlut
 from aces_ocio.utilities import ColorSpace, mat44_from_mat33
 
@@ -57,31 +61,36 @@ def create_RED_log_film(gamut,
     cs.family = 'RED'
     cs.is_data = False
 
+    # A linear space needs allocation variables
+    if transfer_function == '':
+        cs.allocation_type = ocio.Constants.ALLOCATION_LG2
+        cs.allocation_vars = [-8, 5, 0.00390625]
+
     def cineon_to_linear(code_value):
         n_gamma = 0.6
-        black_point = 95.0
-        white_point = 685.0
+        black_point = 95
+        white_point = 685
         code_value_to_density = 0.002
 
-        black_linear = pow(10.0, (black_point - white_point) * (
+        black_linear = pow(10, (black_point - white_point) * (
             code_value_to_density / n_gamma))
-        code_linear = pow(10.0, (code_value - white_point) * (
+        code_linear = pow(10, (code_value - white_point) * (
             code_value_to_density / n_gamma))
 
-        return (code_linear - black_linear) / (1.0 - black_linear)
+        return (code_linear - black_linear) / (1 - black_linear)
 
     cs.to_reference_transforms = []
 
     if transfer_function == 'REDlogFilm':
         data = array.array('f', '\0' * lut_resolution_1d * 4)
         for c in range(lut_resolution_1d):
-            data[c] = cineon_to_linear(1023.0 * c / (lut_resolution_1d - 1))
+            data[c] = cineon_to_linear(1023 * c / (lut_resolution_1d - 1))
 
         lut = 'CineonLog_to_linear.spi1d'
         genlut.write_SPI_1d(
             os.path.join(lut_directory, lut),
-            0.0,
-            1.0,
+            0,
+            1,
             data,
             lut_resolution_1d,
             1)
@@ -106,6 +115,13 @@ def create_RED_log_film(gamut,
                                         0.040787, 0.857658, 0.101553,
                                         -0.047504, -0.000282, 1.047756]),
             'direction': 'forward'})
+    elif gamut == 'REDcolor':
+        cs.to_reference_transforms.append({
+            'type': 'matrix',
+            'matrix': mat44_from_mat33([0.451464, 0.388498, 0.160038,
+                                        0.062716, 0.866790, 0.070491,
+                                        -0.017541, 0.086921, 0.930590]),
+            'direction': 'forward'})
     elif gamut == 'REDcolor2':
         cs.to_reference_transforms.append({
             'type': 'matrix',
@@ -168,6 +184,15 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         ["rlf_dgn2"])
     colorspaces.append(RED_log_film_dragon2)
 
+    RED_log_film_color = create_RED_log_film(
+        'REDcolor',
+        'REDlogFilm',
+        'REDlogFilm',
+        lut_directory,
+        lut_resolution_1d,
+        ["rlf_rc"])
+    colorspaces.append(RED_log_film_color)
+
     RED_log_film_color2 = create_RED_log_film(
         'REDcolor2',
         'REDlogFilm',
@@ -224,6 +249,15 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         ["lin_dgn2"])
     colorspaces.append(RED_dragon2)
 
+    RED_color = create_RED_log_film(
+        'REDcolor',
+        '',
+        'REDlogFilm',
+        lut_directory,
+        lut_resolution_1d,
+        ["lin_rc"])
+    colorspaces.append(RED_color)
+
     RED_color2 = create_RED_log_film(
         'REDcolor2',
         '',