Implement __future__ division support.
[OpenColorIO-Configs.git] / aces_1.0.0 / python / aces_ocio / create_sony_colorspaces.py
index af334b8..c16b708 100644 (file)
@@ -5,6 +5,8 @@
 Implements support for *Sony* colorspaces conversions and transfer functions.
 """
 
+from __future__ import division
+
 import array
 import os
 
@@ -26,7 +28,8 @@ def create_s_log(gamut,
                  transfer_function,
                  name,
                  lut_directory,
-                 lut_resolution_1d):
+                 lut_resolution_1d,
+                 aliases):
     """
     Object description.
 
@@ -51,6 +54,7 @@ def create_s_log(gamut,
 
     cs = ColorSpace(name)
     cs.description = name
+    cs.aliases = aliases
     cs.equality_group = ''
     cs.family = 'Sony'
     cs.is_data = False
@@ -87,10 +91,10 @@ def create_s_log(gamut,
 
     def s_log3_to_linear(code_value):
         if code_value >= 171.2102946929:
-            linear = (pow(10.0, ((code_value - 420.0) / 261.5)) *
+            linear = (pow(10, ((code_value - 420) / 261.5)) *
                       (0.18 + 0.01) - 0.01)
         else:
-            linear = (code_value - 95.0) * 0.01125000 / (171.2102946929 - 95.0)
+            linear = (code_value - 95) * 0.01125000 / (171.2102946929 - 95)
 
         return linear
 
@@ -99,13 +103,13 @@ def create_s_log(gamut,
     if transfer_function == 'S-Log1':
         data = array.array('f', '\0' * lut_resolution_1d * 4)
         for c in range(lut_resolution_1d):
-            data[c] = s_log1_to_linear(1023.0 * c / (lut_resolution_1d - 1))
+            data[c] = s_log1_to_linear(1023 * c / (lut_resolution_1d - 1))
 
         lut = '%s_to_linear.spi1d' % transfer_function
         genlut.write_SPI_1d(
             os.path.join(lut_directory, lut),
-            0.0,
-            1.0,
+            0,
+            1,
             data,
             lut_resolution_1d,
             1)
@@ -118,13 +122,13 @@ def create_s_log(gamut,
     elif transfer_function == 'S-Log2':
         data = array.array('f', '\0' * lut_resolution_1d * 4)
         for c in range(lut_resolution_1d):
-            data[c] = s_log2_to_linear(1023.0 * c / (lut_resolution_1d - 1))
+            data[c] = s_log2_to_linear(1023 * c / (lut_resolution_1d - 1))
 
         lut = '%s_to_linear.spi1d' % transfer_function
         genlut.write_SPI_1d(
             os.path.join(lut_directory, lut),
-            0.0,
-            1.0,
+            0,
+            1,
             data,
             lut_resolution_1d,
             1)
@@ -137,13 +141,13 @@ def create_s_log(gamut,
     elif transfer_function == 'S-Log3':
         data = array.array('f', '\0' * lut_resolution_1d * 4)
         for c in range(lut_resolution_1d):
-            data[c] = s_log3_to_linear(1023.0 * c / (lut_resolution_1d - 1))
+            data[c] = s_log3_to_linear(1023 * c / (lut_resolution_1d - 1))
 
         lut = '%s_to_linear.spi1d' % transfer_function
         genlut.write_SPI_1d(
             os.path.join(lut_directory, lut),
-            0.0,
-            1.0,
+            0,
+            1,
             data,
             lut_resolution_1d,
             1)
@@ -222,7 +226,8 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         'S-Log1',
         'S-Log',
         lut_directory,
-        lut_resolution_1d)
+        lut_resolution_1d,
+        ["slog1_sgamut"])
     colorspaces.append(s_log1_s_gamut)
 
     # *S-Log2*
@@ -231,7 +236,8 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         'S-Log2',
         'S-Log2',
         lut_directory,
-        lut_resolution_1d)
+        lut_resolution_1d,
+        ["slog2_sgamut"])
     colorspaces.append(s_log2_s_gamut)
 
     s_log2_s_gamut_daylight = create_s_log(
@@ -239,7 +245,8 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         'S-Log2',
         'S-Log2',
         lut_directory,
-        lut_resolution_1d)
+        lut_resolution_1d,
+        ["slog2_sgamutday"])
     colorspaces.append(s_log2_s_gamut_daylight)
 
     s_log2_s_gamut_tungsten = create_s_log(
@@ -247,7 +254,8 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         'S-Log2',
         'S-Log2',
         lut_directory,
-        lut_resolution_1d)
+        lut_resolution_1d,
+        ["slog2_sgamuttung"])
     colorspaces.append(s_log2_s_gamut_tungsten)
 
     # *S-Log3*
@@ -256,7 +264,8 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         'S-Log3',
         'S-Log3',
         lut_directory,
-        lut_resolution_1d)
+        lut_resolution_1d,
+        ["slog3_sgamutcine"])
     colorspaces.append(s_log3_s_gamut3Cine)
 
     s_log3_s_gamut3 = create_s_log(
@@ -264,7 +273,8 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         'S-Log3',
         'S-Log3',
         lut_directory,
-        lut_resolution_1d)
+        lut_resolution_1d,
+        ["slog3_sgamut3"])
     colorspaces.append(s_log3_s_gamut3)
 
     # Linearization Only
@@ -273,7 +283,8 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         'S-Log1',
         'S-Log',
         lut_directory,
-        lut_resolution_1d)
+        lut_resolution_1d,
+        ["crv_slog1"])
     colorspaces.append(s_log1)
 
     s_log2 = create_s_log(
@@ -281,7 +292,8 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         'S-Log2',
         'S-Log2',
         lut_directory,
-        lut_resolution_1d)
+        lut_resolution_1d,
+        ["crv_slog2"])
     colorspaces.append(s_log2)
 
     s_log3 = create_s_log(
@@ -289,7 +301,8 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         'S-Log3',
         'S-Log3',
         lut_directory,
-        lut_resolution_1d)
+        lut_resolution_1d,
+        ["crv_slog3"])
     colorspaces.append(s_log3)
 
     # Primaries Only
@@ -298,7 +311,8 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         '',
         'S-Log',
         lut_directory,
-        lut_resolution_1d)
+        lut_resolution_1d,
+        ["lin_sgamut"])
     colorspaces.append(s_gamut)
 
     s_gamut_daylight = create_s_log(
@@ -306,7 +320,8 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         '',
         'S-Log2',
         lut_directory,
-        lut_resolution_1d)
+        lut_resolution_1d,
+        ["lin_sgamutday"])
     colorspaces.append(s_gamut_daylight)
 
     s_gamut_tungsten = create_s_log(
@@ -314,7 +329,8 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         '',
         'S-Log2',
         lut_directory,
-        lut_resolution_1d)
+        lut_resolution_1d,
+        ["lin_sgamuttung"])
     colorspaces.append(s_gamut_tungsten)
 
     s_gamut3Cine = create_s_log(
@@ -322,7 +338,8 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         '',
         'S-Log3',
         lut_directory,
-        lut_resolution_1d)
+        lut_resolution_1d,
+        ["lin_sgamut3cine"])
     colorspaces.append(s_gamut3Cine)
 
     s_gamut3 = create_s_log(
@@ -330,7 +347,8 @@ def create_colorspaces(lut_directory, lut_resolution_1d):
         '',
         'S-Log3',
         lut_directory,
-        lut_resolution_1d)
+        lut_resolution_1d,
+        ["lin_sgamut3"])
     colorspaces.append(s_gamut3)
 
     return colorspaces