From 8d6f6fb3b7ec7d7a1e881ac6603b6b33cdcfdccb Mon Sep 17 00:00:00 2001 From: Haarm-Pieter Duiker Date: Wed, 29 Apr 2015 10:39:40 -0700 Subject: [PATCH] Added GoPro Protune support Added RED REDcolor gamut support --- aces_1.0.0/python/aces_ocio/create_aces_config.py | 7 + .../python/aces_ocio/create_gopro_colorspaces.py | 160 ++++++++++++++++++++ .../python/aces_ocio/create_red_colorspaces.py | 25 +++ 3 files changed, 192 insertions(+) create mode 100644 aces_1.0.0/python/aces_ocio/create_gopro_colorspaces.py diff --git a/aces_1.0.0/python/aces_ocio/create_aces_config.py b/aces_1.0.0/python/aces_ocio/create_aces_config.py index 1de65b1..8cf3d36 100755 --- a/aces_1.0.0/python/aces_ocio/create_aces_config.py +++ b/aces_1.0.0/python/aces_ocio/create_aces_config.py @@ -15,6 +15,7 @@ import PyOpenColorIO as ocio import aces_ocio.create_aces_colorspaces as aces import aces_ocio.create_arri_colorspaces as arri import aces_ocio.create_canon_colorspaces as canon +import aces_ocio.create_gopro_colorspaces as gopro import aces_ocio.create_panasonic_colorspaces as panasonic import aces_ocio.create_red_colorspaces as red import aces_ocio.create_sony_colorspaces as sony @@ -504,6 +505,12 @@ def generate_LUTs(odt_info, for cs in canon_colorspaces: config_data['colorSpaces'].append(cs) + # *GoPro Protune* to *ACES*. + gopro_colorspaces = gopro.create_colorspaces(lut_directory, + lut_resolution_1d) + for cs in gopro_colorspaces: + config_data['colorSpaces'].append(cs) + # *Panasonic V-Log* to *ACES*. panasonic_colorSpaces = panasonic.create_colorspaces(lut_directory, lut_resolution_1d) diff --git a/aces_1.0.0/python/aces_ocio/create_gopro_colorspaces.py b/aces_1.0.0/python/aces_ocio/create_gopro_colorspaces.py new file mode 100644 index 0000000..3e9ff54 --- /dev/null +++ b/aces_1.0.0/python/aces_ocio/create_gopro_colorspaces.py @@ -0,0 +1,160 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Implements support for *GoPro* 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, sanitize) + +__author__ = 'ACES Developers' +__copyright__ = 'Copyright (C) 2014 - 2015 - ACES Developers' +__license__ = '' +__maintainer__ = 'ACES Developers' +__email__ = 'aces@oscars.org' +__status__ = 'Production' + +__all__ = ['create_protune', + 'create_colorspaces'] + + +def create_protune(gamut, + transfer_function, + name, + lut_directory, + lut_resolution_1d, + aliases): + """ + Object description. + + Protune to ACES. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + + name = '%s - %s' % (transfer_function, gamut) + if transfer_function == '': + name = 'Linear - %s' % gamut + if gamut == '': + name = '%s' % transfer_function + + cs = ColorSpace(name) + cs.description = name + cs.aliases = aliases + cs.equality_group = '' + cs.family = 'GoPro' + 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 protune_to_linear(normalized_code_value): + c1 = 113.0 + c2 = 1.0 + c3 = 112.0 + linear = ((pow(c1, (normalized_code_value)) - c2) / c3) + + return linear + + cs.to_reference_transforms = [] + + if transfer_function == 'Protune Flat': + data = array.array('f', '\0' * lut_resolution_1d * 4) + for c in range(lut_resolution_1d): + data[c] = protune_to_linear(float(c) / (lut_resolution_1d - 1)) + + lut = '%s_to_linear.spi1d' % transfer_function + lut = sanitize(lut) + genlut.write_SPI_1d( + os.path.join(lut_directory, lut), + 0, + 1, + data, + lut_resolution_1d, + 1) + + cs.to_reference_transforms.append({ + 'type': 'lutFile', + 'path': lut, + 'interpolation': 'linear', + 'direction': 'forward'}) + + if gamut == 'Protune Gamut': + cs.to_reference_transforms.append({ + 'type': 'matrix', + 'matrix': [ 0.533448429, 0.32413911, 0.142412421, 0, + -0.050729924, 1.07572006, -0.024990416, 0, + 0.071419661, -0.290521962, 1.219102381, 0, + 0, 0, 0, 1], + 'direction': 'forward'}) + + cs.from_reference_transforms = [] + return cs + + +def create_colorspaces(lut_directory, lut_resolution_1d): + """ + Generates the colorspace conversions. + + Parameters + ---------- + parameter : type + Parameter description. + + Returns + ------- + type + Return value description. + """ + + colorspaces = [] + + # Full conversion + protune_1 = create_protune( + 'Protune Native', + 'Protune Flat', + 'Protune', + lut_directory, + lut_resolution_1d, + ["protuneflat_protunegamut"]) + colorspaces.append(protune_1) + + # Linearization Only + protune_2 = create_protune( + '', + 'Protune Flat', + 'Protune', + lut_directory, + lut_resolution_1d, + ["crv_protuneflat"]) + colorspaces.append(protune_2) + + # Primaries Only + protune_3 = create_protune( + 'Protune Native', + '', + 'Protune', + lut_directory, + lut_resolution_1d, + ["lin_protunegamut"]) + colorspaces.append(protune_3) + + return colorspaces diff --git a/aces_1.0.0/python/aces_ocio/create_red_colorspaces.py b/aces_1.0.0/python/aces_ocio/create_red_colorspaces.py index 3c88750..3f52e24 100644 --- a/aces_1.0.0/python/aces_ocio/create_red_colorspaces.py +++ b/aces_1.0.0/python/aces_ocio/create_red_colorspaces.py @@ -115,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', @@ -177,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', @@ -233,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', '', -- 1.7.10.4