Color Management, Stage 1: Initial OpenColorIO library integration

This commit integrates support of OpenColorIO library into build systems.

It also contains C-API for OpenColorIO library which could be used by Blender.

CMake has got find rules familiar to OpenImageIO's one which makes it easier
for build system to find needed libraries and includes. Scons only could use
explicitly defined paths to libraries and includes.

C-API would be compiled and Blender would be linked against C-API and OpenColorIO
but it wouldn't affect on Blender behavior at all.

OpenColorIO could be disabled by setting up WITH_OCIO to Off in CMake and
setting WITH_BF_OCIO in Scons.
This commit is contained in:
Sergey Sharybin 2012-09-15 10:03:17 +00:00
parent 8add19d3ec
commit b93da9b01e
38 changed files with 381405 additions and 0 deletions

@ -131,6 +131,7 @@ option(WITH_FFTW3 "Enable FFTW3 support (Used for smoke and audio effect
option(WITH_BULLET "Enable Bullet (Physics Engine)" ON)
option(WITH_GAMEENGINE "Enable Game Engine" ON)
option(WITH_PLAYER "Build Player" OFF)
option(WITH_OPENCOLORIO "Enable OpenColorIO color management" ON)
option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON)
option(WITH_COMPOSITOR_LEGACY "Enable legacy compositor" OFF)
@ -672,6 +673,24 @@ if(UNIX AND NOT APPLE)
endif()
endif()
if(WITH_OPENCOLORIO)
# use lib dir if available and nothing else specified
if(LIBDIR AND NOT OPENCOLORIO_ROOT_DIR)
set(OPENCOLORIO_ROOT_DIR ${LIBDIR}/ocio)
endif()
find_package(OpenColorIO)
set(OPENCOLORIO_LIBRARIES ${OPENCOLORIO_LIBRARIES})
set(OPENCOLORIO_LIBPATH) # TODO, remove and reference the absolute path everywhere
set(OPENCOLORIO_DEFINITIONS)
if(NOT OPENCOLORIO_FOUND)
set(WITH_OPENCOLORIO OFF)
message(STATUS "OpenColorIO not found")
endif()
endif()
if(WITH_CYCLES_OSL)
set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
@ -1065,6 +1084,14 @@ elseif(WIN32)
set(OPENIMAGEIO_DEFINITIONS)
endif()
if(WITH_OPENCOLORIO)
set(OPENCOLORIO ${LIBDIR}/opencolorio)
set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
set(OPENCOLORIO_LIBRARIES OpenColorIO)
set_lib_path(OPENCOLORIO_LIBPATH "opencolorio/lib")
set(OPENCOLORIO_DEFINITIONS)
endif()
set(PLATFORM_LINKFLAGS "/SUBSYSTEM:CONSOLE /STACK:2097152 /INCREMENTAL:NO /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcmrt.lib /NODEFAULTLIB:msvcurt.lib /NODEFAULTLIB:msvcrtd.lib")
# MSVC only, Mingw doesnt need
@ -1236,6 +1263,14 @@ elseif(WIN32)
set(OPENIMAGEIO_DEFINITIONS)
endif()
if(WITH_OPENCOLORIO)
set(OPENCOLORIO ${LIBDIR}/opencolorio)
set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
set(OPENCOLORIO_LIBRARIES OpenColorIO)
set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib)
set(OPENCOLORIO_DEFINITIONS)
endif()
set(PLATFORM_LINKFLAGS "-Xlinker --stack=2097152")
## DISABLE - causes linking errors
@ -1482,6 +1517,14 @@ elseif(APPLE)
set(OPENIMAGEIO_DEFINITIONS "-DOIIO_STATIC_BUILD")
endif()
if(WITH_OPENCOLORIO)
set(OPENCOLORIO ${LIBDIR}/opencolorio)
set(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO}/include)
set(OPENCOLORIO_LIBRARIES OpenColorIO tinyxml yaml-cpp)
set(OPENCOLORIO_LIBPATH ${OPENCOLORIO}/lib)
set(OPENCOLORIO_DEFINITIONS "-DOCIO_STATIC_BUILD")
endif()
if(WITH_CYCLES_OSL)
set(CYCLES_OSL ${LIBDIR}/osl CACHE PATH "Path to OpenShadingLanguage installation")
@ -1885,6 +1928,7 @@ if(FIRST_RUN)
info_cfg_option(WITH_INTERNATIONAL)
info_cfg_option(WITH_INPUT_NDOF)
info_cfg_option(WITH_CYCLES)
info_cfg_option(WITH_OPENCOLORIO)
info_cfg_text("Compiler Options:")
info_cfg_option(WITH_BUILDINFO)

@ -719,6 +719,26 @@ if env['OURPLATFORM']!='darwin':
cubin_file = os.path.join(kernel_build_dir, "kernel_%s.cubin" % arch)
scriptinstall.append(env.Install(dir=dir,source=cubin_file))
if env['WITH_BF_OCIO']:
colormanagement = os.path.join('release', 'datafiles', 'colormanagement')
for dp, dn, df in os.walk(colormanagement):
if '.svn' in dn:
dn.remove('.svn')
if '_svn' in dn:
dn.remove('_svn')
dir = os.path.join(env['BF_INSTALLDIR'], VERSION, 'datafiles')
dir += os.sep + os.path.basename(colormanagement) + dp[len(colormanagement):]
source = [os.path.join(dp, f) for f in df if not f.endswith(".pyc")]
# To ensure empty dirs are created too
if len(source) == 0:
env.Execute(Mkdir(dir))
scriptinstall.append(env.Install(dir=dir,source=source))
if env['WITH_BF_INTERNATIONAL']:
internationalpaths=['release' + os.sep + 'datafiles']
@ -851,6 +871,9 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
if env['WITH_BF_OIIO'] and env['OURPLATFORM'] != 'win32-mingw':
dllsources.append('${LCGDIR}/openimageio/bin/OpenImageIO.dll')
if env['WITH_BF_OCIO'] and env['OURPLATFORM'] != 'win32-mingw':
dllsources.append('${LCGDIR}/opencolorio/bin/OpenColorIO.dll')
dllsources.append('#source/icons/blender.exe.manifest')
windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)

@ -0,0 +1,85 @@
# - Find OpenColorIO library
# Find the native OpenColorIO includes and library
# This module defines
# OPENCOLORIO_INCLUDE_DIRS, where to find OpenColorIO.h, Set when
# OPENCOLORIO_INCLUDE_DIR is found.
# OPENCOLORIO_LIBRARIES, libraries to link against to use OpenColorIO.
# OPENCOLORIO_ROOT_DIR, The base directory to search for OpenColorIO.
# This can also be an environment variable.
# OPENCOLORIO_FOUND, If false, do not try to use OpenColorIO.
#
# also defined, but not for general use are
# OPENCOLORIO_LIBRARY, where to find the OpenColorIO library.
#=============================================================================
# Copyright 2012 Blender Foundation.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# If OPENCOLORIO_ROOT_DIR was defined in the environment, use it.
IF(NOT OPENCOLORIO_ROOT_DIR AND NOT $ENV{OPENCOLORIO_ROOT_DIR} STREQUAL "")
SET(OPENCOLORIO_ROOT_DIR $ENV{OPENCOLORIO_ROOT_DIR})
ENDIF()
SET(_opencolorio_FIND_COMPONENTS
OpenColorIO
yaml-cpp
tinyxml
)
SET(_opencolorio_SEARCH_DIRS
${OPENCOLORIO_ROOT_DIR}
/usr/local
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
)
FIND_PATH(OPENCOLORIO_INCLUDE_DIR
NAMES
OpenColorIO/OpenColorIO.h
HINTS
${_opencolorio_SEARCH_DIRS}
PATH_SUFFIXES
include
)
SET(_opencolorio_LIBRARIES)
FOREACH(COMPONENT ${_opencolorio_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
FIND_LIBRARY(OPENCOLORIO_${UPPERCOMPONENT}_LIBRARY
NAMES
${COMPONENT}
HINTS
${_opencolorio_SEARCH_DIRS}
PATH_SUFFIXES
lib64 lib
)
if(OPENCOLORIO_${UPPERCOMPONENT}_LIBRARY)
LIST(APPEND _opencolorio_LIBRARIES "${OPENCOLORIO_${UPPERCOMPONENT}_LIBRARY}")
endif()
ENDFOREACH()
# handle the QUIETLY and REQUIRED arguments and set OPENCOLORIO_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenColorIO DEFAULT_MSG
_opencolorio_LIBRARIES OPENCOLORIO_INCLUDE_DIR)
IF(OPENCOLORIO_FOUND)
SET(OPENCOLORIO_LIBRARIES ${_opencolorio_LIBRARIES})
SET(OPENCOLORIO_INCLUDE_DIRS ${OPENCOLORIO_INCLUDE_DIR})
ENDIF(OPENCOLORIO_FOUND)
MARK_AS_ADVANCED(
OPENCOLORIO_INCLUDE_DIR
OPENCOLORIO_LIBRARY
)

@ -218,6 +218,9 @@ macro(SETUP_LIBDIRS)
if(WITH_OPENIMAGEIO)
link_directories(${OPENIMAGEIO_LIBPATH})
endif()
if(WITH_OPENCOLORIO)
link_directories(${OPENCOLORIO_LIBPATH})
endif()
if(WITH_IMAGE_OPENJPEG AND WITH_SYSTEM_OPENJPEG)
link_directories(${OPENJPEG_LIBPATH})
endif()
@ -313,6 +316,9 @@ macro(setup_liblinks
if(WITH_OPENIMAGEIO)
target_link_libraries(${target} ${OPENIMAGEIO_LIBRARIES})
endif()
if(WITH_OPENCOLORIO)
target_link_libraries(${target} ${OPENCOLORIO_LIBRARIES})
endif()
if(WITH_BOOST)
target_link_libraries(${target} ${BOOST_LIBRARIES})
endif()

@ -287,6 +287,12 @@ BF_OIIO_INC = BF_OIIO + '/include'
BF_OIIO_LIB = 'OpenImageIO'
BF_OIIO_LIBPATH = BF_OIIO + '/lib'
WITH_BF_OCIO = True
BF_OCIO = LIBDIR + '/opencolorio'
BF_OCIO_INC = BF_OCIO + '/include'
BF_OCIO_LIB = 'OpenColorIO tinyxml yaml-cpp'
BF_OCIO_LIBPATH = BF_OCIO + '/lib'
WITH_BF_BOOST = True
BF_BOOST = LIBDIR + '/boost'
BF_BOOST_INC = BF_BOOST + '/include'

@ -215,6 +215,16 @@ BF_OIIO_INC = BF_OIIO + '/include'
BF_OIIO_LIB = 'OpenImageIO'
BF_OIIO_LIBPATH = BF_OIIO + '/lib'
WITH_BF_OCIO = True
WITH_BF_STATICOCIO = False
BF_OCIO = LIBDIR + '/ocio'
if not os.path.exists(LCGDIR + '/ocio'):
WITH_BF_OCIO = False
BF_OCIO = '/usr'
BF_OCIO_INC = BF_OCIO + '/include'
BF_OCIO_LIB = 'OpenColorIO yaml-cpp tinyxml'
BF_OCIO_LIBPATH = BF_OCIO + '/lib'
WITH_BF_BOOST = True
WITH_BF_STATICBOOST = False
BF_BOOST = LIBDIR + '/boost'

@ -159,6 +159,12 @@ BF_OIIO_INC = BF_OIIO + '/include'
BF_OIIO_LIB = 'OpenImageIO'
BF_OIIO_LIBPATH = BF_OIIO + '/lib'
WITH_BF_OCIO = False
BF_OCIO = LIBDIR + '/opencolorio'
BF_OCIO_INC = BF_OCIO + '/include'
BF_OCIO_LIB = 'OpenColorIO'
BF_OCIO_LIBPATH = BF_OCIO + '/lib'
WITH_BF_BOOST = True
BF_BOOST = LIBDIR + '/boost'
BF_BOOST_INC = BF_BOOST + '/include'

@ -161,6 +161,12 @@ BF_OIIO_INC = '${BF_OIIO}/include'
BF_OIIO_LIB = 'OpenImageIO'
BF_OIIO_LIBPATH = '${BF_OIIO}/lib'
WITH_BF_OCIO = True
BF_OCIO = '${LIBDIR}/opencolorio'
BF_OCIO_INC = '${BF_OCIO}/include'
BF_OCIO_LIB = 'OpenColorIO'
BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
WITH_BF_BOOST = True
BF_BOOST = '${LIBDIR}/boost'
BF_BOOST_INC = '${BF_BOOST}/include'

@ -159,6 +159,12 @@ BF_OIIO_INC = '${BF_OIIO}/include'
BF_OIIO_LIB = 'OpenImageIO'
BF_OIIO_LIBPATH = '${BF_OIIO}/lib'
WITH_BF_OCIO = False
BF_OCIO = LIBDIR + '/opencolorio'
BF_OCIO_INC = '${BF_OCIO}/include'
BF_OCIO_LIB = 'OpenColorIO'
BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
WITH_BF_BOOST = True
BF_BOOST = LIBDIR + '/boost'
BF_BOOST_INC = BF_BOOST + '/include'

@ -158,6 +158,13 @@ BF_OIIO_LIB = 'OpenImageIO'
BF_OIIO_LIBPATH = '${BF_OIIO}/lib'
BF_OIIO_LIBPATH = '${BF_OIIO}/lib'
WITH_BF_OCIO = True
BF_OCIO = '${LIBDIR}/opencolorio'
BF_OCIO_INC = '${BF_OCIO}/include'
BF_OCIO_LIB = 'OpenColorIO'
BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
BF_OCIO_LIBPATH = '${BF_OCIO}/lib'
WITH_BF_BOOST = True
BF_BOOST = '${LIBDIR}/boost'
BF_BOOST_INC = '${BF_BOOST}/include'

@ -204,6 +204,11 @@ def setup_staticlibs(lenv):
if lenv['WITH_BF_STATICOIIO']:
statlibs += Split(lenv['BF_OIIO_LIB_STATIC'])
if lenv['WITH_BF_OCIO']:
libincs += Split(lenv['BF_OCIO_LIBPATH'])
if lenv['WITH_BF_STATICOCIO']:
statlibs += Split(lenv['BF_OCIO_LIB_STATIC'])
if lenv['WITH_BF_BOOST']:
libincs += Split(lenv['BF_BOOST_LIBPATH'])
if lenv['WITH_BF_STATICBOOST']:
@ -252,6 +257,10 @@ def setup_syslibs(lenv):
if not lenv['WITH_BF_STATICOIIO']:
syslibs += Split(lenv['BF_OIIO_LIB'])
if lenv['WITH_BF_OCIO']:
if not lenv['WITH_BF_STATICOCIO']:
syslibs += Split(lenv['BF_OCIO_LIB'])
if lenv['WITH_BF_OPENEXR'] and not lenv['WITH_BF_STATICOPENEXR']:
syslibs += Split(lenv['BF_OPENEXR_LIB'])
if lenv['WITH_BF_TIFF'] and not lenv['WITH_BF_STATICTIFF']:
@ -584,6 +593,9 @@ def AppIt(target=None, source=None, env=None):
commands.getoutput(cmd)
cmd = 'cp -R %s/release/datafiles/fonts %s/%s.app/Contents/MacOS/%s/datafiles/'%(bldroot,installdir,binary,VERSION)
commands.getoutput(cmd)
if env['WITH_BF_OCIO']:
cmd = 'cp -R %s/release/datafiles/colormanagement %s/%s.app/Contents/MacOS/%s/datafiles/'%(bldroot,installdir,binary,VERSION)
commands.getoutput(cmd)
cmd = 'cp -R %s/release/scripts %s/%s.app/Contents/MacOS/%s/'%(bldroot,installdir,binary,VERSION)
commands.getoutput(cmd)

@ -163,6 +163,7 @@ def validate_arguments(args, bc):
'WITH_BF_3DMOUSE', 'WITH_BF_STATIC3DMOUSE', 'BF_3DMOUSE', 'BF_3DMOUSE_INC', 'BF_3DMOUSE_LIB', 'BF_3DMOUSE_LIBPATH', 'BF_3DMOUSE_LIB_STATIC',
'WITH_BF_CYCLES', 'WITH_BF_CYCLES_CUDA_BINARIES', 'BF_CYCLES_CUDA_NVCC', 'BF_CYCLES_CUDA_NVCC', 'WITH_BF_CYCLES_CUDA_THREADED_COMPILE',
'WITH_BF_OIIO', 'WITH_BF_STATICOIIO', 'BF_OIIO', 'BF_OIIO_INC', 'BF_OIIO_LIB', 'BF_OIIO_LIB_STATIC', 'BF_OIIO_LIBPATH',
'WITH_BF_OCIO', 'WITH_BF_STATICOCIO', 'BF_OCIO', 'BF_OCIO_INC', 'BF_OCIO_LIB', 'BF_OCIO_LIB_STATIC', 'BF_OCIO_LIBPATH',
'WITH_BF_BOOST', 'WITH_BF_STATICBOOST', 'BF_BOOST', 'BF_BOOST_INC', 'BF_BOOST_LIB', 'BF_BOOST_LIB_STATIC', 'BF_BOOST_LIBPATH',
'WITH_BF_LIBMV'
]
@ -575,6 +576,14 @@ def read_opts(env, cfg, args):
('BF_OIIO_LIBPATH', 'OIIO library path', ''),
('BF_OIIO_LIB_STATIC', 'OIIO static library', ''),
(BoolVariable('WITH_BF_OCIO', 'Build with OpenColorIO', False)),
(BoolVariable('WITH_BF_STATICOCIO', 'Staticly link to OpenColorIO', False)),
('BF_OCIO', 'OCIO root path', ''),
('BF_OCIO_INC', 'OCIO include path', ''),
('BF_OCIO_LIB', 'OCIO library', ''),
('BF_OCIO_LIBPATH', 'OCIO library path', ''),
('BF_OCIO_LIB_STATIC', 'OCIO static library', ''),
(BoolVariable('WITH_BF_BOOST', 'Build with Boost', False)),
(BoolVariable('WITH_BF_STATICBOOST', 'Staticly link to boost', False)),
('BF_BOOST', 'Boost root path', ''),

@ -28,6 +28,7 @@ add_subdirectory(ghost)
add_subdirectory(guardedalloc)
add_subdirectory(moto)
add_subdirectory(memutil)
add_subdirectory(opencolorio)
add_subdirectory(opennl)
add_subdirectory(mikktspace)
add_subdirectory(raskter)
@ -73,3 +74,4 @@ endif()
if(WIN32)
add_subdirectory(utfconv)
endif()

@ -11,6 +11,7 @@ SConscript(['audaspace/SConscript',
'decimation/SConscript',
'iksolver/SConscript',
'itasc/SConscript',
'opencolorio/SConscript',
'opennl/SConscript',
'mikktspace/SConscript',
'smoke/SConscript',
@ -30,3 +31,4 @@ if env['WITH_BF_BOOLEAN']:
if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-mingw', 'linuxcross', 'win64-vc'):
SConscript(['utfconv/SConscript'])

@ -0,0 +1,62 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2012, Blender Foundation
# All rights reserved.
#
# The Original Code is: all of this file.
#
# Contributor(s): Sergey Sharybin.
#
# ***** END GPL LICENSE BLOCK *****
if(WITH_OPENCOLORIO)
set(INC
.
${OPENCOLORIO_INCLUDE_DIRS}
)
set(SRC
ocio_capi.cpp
ocio_capi.h
)
if(WIN32 AND NOT MINGW)
list(APPEND INC
${BOOST_INCLUDE_DIR}
)
endif()
else()
set(INC
.
../../source/blender/blenlib
)
set(SRC
ocio_capi_stub.cpp
ocio_capi.h
)
endif()
set(INC_SYS
../guardedalloc
)
add_definitions(
)
blender_add_lib(bf_intern_opencolorio "${SRC}" "${INC}" "${INC_SYS}")

@ -0,0 +1,19 @@
#!/usr/bin/python
Import('env')
sources = env.Glob('*.cpp')
incs = '. ../guardedalloc ../../source/blender/blenlib'
if env['WITH_BF_OCIO']:
sources.remove('ocio_capi_stub.cpp')
incs += ' ' + env['BF_OCIO_INC']
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
incs += ' ' + env['BF_BOOST_INC']
else:
sources.remove('ocio_capi.cpp')
env.BlenderLib( 'bf_intern_opencolorio', sources, Split(incs), [], libtype=['extern','player'], priority=[10, 185])

@ -0,0 +1,525 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2012 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Xavier Thomas
* Lukas Toene,
* Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <iostream>
#include <string.h>
#include <OpenColorIO/OpenColorIO.h>
#include "MEM_guardedalloc.h"
#define OCIO_CAPI_IMPLEMENTATION
#include "ocio_capi.h"
#ifdef NDEBUG
# define OCIO_abort()
#else
# include <stdlib.h>
# define OCIO_abort() abort()
#endif
#if defined(_MSC_VER)
# define __func__ __FUNCTION__
#endif
#define MEM_NEW(type) new(MEM_mallocN(sizeof(type), __func__)) type()
#define MEM_DELETE(what, type) { what->~type(); MEM_freeN(what); } (void)0
static void OCIO_reportError(const char *err)
{
std::cerr << "OpenColorIO Error: " << err << std::endl;
OCIO_abort();
}
static void OCIO_reportException(Exception &exception)
{
OCIO_reportError(exception.what());
}
ConstConfigRcPtr *OCIO_getCurrentConfig(void)
{
ConstConfigRcPtr *config = MEM_NEW(ConstConfigRcPtr);
try {
*config = GetCurrentConfig();
if(*config)
return config;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
void OCIO_setCurrentConfig(const ConstConfigRcPtr *config)
{
try {
SetCurrentConfig(*config);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
}
ConstConfigRcPtr *OCIO_configCreateFromEnv(void)
{
ConstConfigRcPtr *config = MEM_NEW(ConstConfigRcPtr);
try {
*config = Config::CreateFromEnv();
if (*config)
return config;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
ConstConfigRcPtr *OCIO_configCreateFromFile(const char *filename)
{
ConstConfigRcPtr *config = MEM_NEW(ConstConfigRcPtr);
try {
*config = Config::CreateFromFile(filename);
if (*config)
return config;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
void OCIO_configRelease(ConstConfigRcPtr *config)
{
MEM_DELETE(config, ConstConfigRcPtr);
}
int OCIO_configGetNumColorSpaces(ConstConfigRcPtr *config)
{
try {
return (*config)->getNumColorSpaces();
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return 0;
}
const char *OCIO_configGetColorSpaceNameByIndex(ConstConfigRcPtr *config, int index)
{
try {
return (*config)->getColorSpaceNameByIndex(index);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
ConstColorSpaceRcPtr *OCIO_configGetColorSpace(ConstConfigRcPtr *config, const char *name)
{
ConstColorSpaceRcPtr *cs = MEM_NEW(ConstColorSpaceRcPtr);
try {
*cs = (*config)->getColorSpace(name);
if (*cs)
return cs;
}
catch (Exception &exception) {
OCIO_reportException(exception);
MEM_DELETE(cs, ConstColorSpaceRcPtr);
}
return NULL;
}
int OCIO_configGetIndexForColorSpace(ConstConfigRcPtr *config, const char *name)
{
try {
return (*config)->getIndexForColorSpace(name);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return -1;
}
const char *OCIO_configGetDefaultDisplay(ConstConfigRcPtr *config)
{
try {
return (*config)->getDefaultDisplay();
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
int OCIO_configGetNumDisplays(ConstConfigRcPtr* config)
{
try {
return (*config)->getNumDisplays();
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return 0;
}
const char *OCIO_configGetDisplay(ConstConfigRcPtr *config, int index)
{
try {
return (*config)->getDisplay(index);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
const char *OCIO_configGetDefaultView(ConstConfigRcPtr *config, const char *display)
{
try {
return (*config)->getDefaultView(display);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
int OCIO_configGetNumViews(ConstConfigRcPtr *config, const char *display)
{
try {
return (*config)->getNumViews(display);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return 0;
}
const char *OCIO_configGetView(ConstConfigRcPtr *config, const char *display, int index)
{
try {
return (*config)->getView(display, index);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
const char *OCIO_configGetDisplayColorSpaceName(ConstConfigRcPtr *config, const char *display, const char *view)
{
try {
return (*config)->getDisplayColorSpaceName(display, view);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
int OCIO_colorSpaceIsInvertible(ConstColorSpaceRcPtr *cs)
{
const char *family = (*cs)->getFamily();
if (!strcmp(family, "rrt") || !strcmp(family, "display")) {
/* assume display and rrt transformations are not invertible
* in fact some of them could be, but it doesn't make much sense to allow use them as invertible
*/
return false;
}
if ((*cs)->isData()) {
/* data color spaces don't have transformation at all */
return true;
}
if ((*cs)->getTransform(COLORSPACE_DIR_TO_REFERENCE)) {
/* if there's defined transform to reference space, color space could be converted to scene linear */
return true;
}
return true;
}
void OCIO_colorSpaceRelease(ConstColorSpaceRcPtr *cs)
{
MEM_DELETE(cs, ConstColorSpaceRcPtr);
}
ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(ConstConfigRcPtr *config, const char *srcName, const char *dstName)
{
ConstProcessorRcPtr *p = MEM_NEW(ConstProcessorRcPtr);
try {
*p = (*config)->getProcessor(srcName, dstName);
if (*p)
return p;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return 0;
}
ConstProcessorRcPtr *OCIO_configGetProcessor(ConstConfigRcPtr *config, ConstTransformRcPtr *transform)
{
ConstProcessorRcPtr *p = MEM_NEW(ConstProcessorRcPtr);
try {
*p = (*config)->getProcessor(*transform);
if (*p)
return p;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
void OCIO_processorApply(ConstProcessorRcPtr *processor, PackedImageDesc *img)
{
try {
(*processor)->apply(*img);
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
}
void OCIO_processorApply_predivide(ConstProcessorRcPtr *processor, PackedImageDesc *img)
{
try {
int channels = img->getNumChannels();
if (channels == 4) {
float *pixels = img->getData();
int width = img->getWidth();
int height = img->getHeight();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
float *pixel = pixels + 4 * (y * width + x);
OCIO_processorApplyRGBA_predivide(processor, pixel);
}
}
}
else {
(*processor)->apply(*img);
}
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
}
void OCIO_processorApplyRGB(ConstProcessorRcPtr *processor, float *pixel)
{
(*processor)->applyRGB(pixel);
}
void OCIO_processorApplyRGBA(ConstProcessorRcPtr *processor, float *pixel)
{
(*processor)->applyRGBA(pixel);
}
void OCIO_processorApplyRGBA_predivide(ConstProcessorRcPtr *processor, float *pixel)
{
if (pixel[3] == 1.0f || pixel[3] == 0.0f) {
(*processor)->applyRGBA(pixel);
}
else {
float alpha, inv_alpha;
alpha = pixel[3];
inv_alpha = 1.0f / alpha;
pixel[0] *= inv_alpha;
pixel[1] *= inv_alpha;
pixel[2] *= inv_alpha;
(*processor)->applyRGBA(pixel);
pixel[0] *= alpha;
pixel[1] *= alpha;
pixel[2] *= alpha;
}
}
void OCIO_processorRelease(ConstProcessorRcPtr *p)
{
p->~ConstProcessorRcPtr();
MEM_freeN(p);
}
const char *OCIO_colorSpaceGetName(ConstColorSpaceRcPtr *cs)
{
return (*cs)->getName();
}
const char *OCIO_colorSpaceGetDescription(ConstColorSpaceRcPtr *cs)
{
return (*cs)->getDescription();
}
const char *OCIO_colorSpaceGetFamily(ConstColorSpaceRcPtr *cs)
{
return (*cs)->getFamily();
}
DisplayTransformRcPtr *OCIO_createDisplayTransform(void)
{
DisplayTransformRcPtr *dt = MEM_NEW(DisplayTransformRcPtr);
*dt = DisplayTransform::Create();
return dt;
}
void OCIO_displayTransformSetInputColorSpaceName(DisplayTransformRcPtr *dt, const char *name)
{
(*dt)->setInputColorSpaceName(name);
}
void OCIO_displayTransformSetDisplay(DisplayTransformRcPtr *dt, const char *name)
{
(*dt)->setDisplay(name);
}
void OCIO_displayTransformSetView(DisplayTransformRcPtr *dt, const char *name)
{
(*dt)->setView(name);
}
void OCIO_displayTransformSetDisplayCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *t)
{
(*dt)->setDisplayCC(*t);
}
void OCIO_displayTransformSetLinearCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *t)
{
(*dt)->setLinearCC(*t);
}
void OCIO_displayTransformRelease(DisplayTransformRcPtr *dt)
{
MEM_DELETE(dt, DisplayTransformRcPtr);
}
PackedImageDesc *OCIO_createPackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
{
try {
void *mem = MEM_mallocN(sizeof(PackedImageDesc), __func__);
PackedImageDesc *id = new(mem) PackedImageDesc(data, width, height, numChannels, chanStrideBytes, xStrideBytes, yStrideBytes);
return id;
}
catch (Exception &exception) {
OCIO_reportException(exception);
}
return NULL;
}
void OCIO_packedImageDescRelease(PackedImageDesc* id)
{
MEM_DELETE(id, PackedImageDesc);
}
ExponentTransformRcPtr *OCIO_createExponentTransform(void)
{
ExponentTransformRcPtr *et = MEM_NEW(ExponentTransformRcPtr);
*et = ExponentTransform::Create();
return et;
}
void OCIO_exponentTransformSetValue(ExponentTransformRcPtr *et, const float *exponent)
{
(*et)->setValue(exponent);
}
void OCIO_exponentTransformRelease(ExponentTransformRcPtr *et)
{
MEM_DELETE(et, ExponentTransformRcPtr);
}
MatrixTransformRcPtr *OCIO_createMatrixTransform(void)
{
MatrixTransformRcPtr *mt = MEM_NEW(MatrixTransformRcPtr);
*mt = MatrixTransform::Create();
return mt;
}
void OCIO_matrixTransformSetValue(MatrixTransformRcPtr *mt, const float *m44, const float *offset4)
{
(*mt)->setValue(m44, offset4);
}
void OCIO_matrixTransformRelease(MatrixTransformRcPtr *mt)
{
MEM_DELETE(mt, MatrixTransformRcPtr);
}
void OCIO_matrixTransformScale(float * m44, float * offset4, const float *scale4f)
{
MatrixTransform::Scale(m44, offset4, scale4f);
}

@ -0,0 +1,128 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2012 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Xavier Thomas
* Lukas Toene
* Sergey Sharybin
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __OCIO_CAPI_H__
#define __OCIO_CAPI_H__
#ifdef __cplusplus
using namespace OCIO_NAMESPACE;
extern "C" {
#endif
#define OCIO_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
#ifndef OCIO_CAPI_IMPLEMENTATION
#define OCIO_ROLE_SCENE_LINEAR "scene_linear"
#define OCIO_ROLE_COLOR_PICKING "color_picking"
#define OCIO_ROLE_TEXTURE_PAINT "texture_paint"
#define OCIO_ROLE_DEFAULT_BYTE "default_byte"
#define OCIO_ROLE_DEFAULT_FLOAT "default_float"
#define OCIO_ROLE_DEFAULT_SEQUENCER "default_sequencer"
OCIO_DECLARE_HANDLE(ConstConfigRcPtr);
OCIO_DECLARE_HANDLE(ConstColorSpaceRcPtr);
OCIO_DECLARE_HANDLE(ConstProcessorRcPtr);
OCIO_DECLARE_HANDLE(ConstContextRcPtr);
OCIO_DECLARE_HANDLE(PackedImageDesc);
OCIO_DECLARE_HANDLE(DisplayTransformRcPtr);
OCIO_DECLARE_HANDLE(ConstTransformRcPtr);
OCIO_DECLARE_HANDLE(ExponentTransformRcPtr);
OCIO_DECLARE_HANDLE(MatrixTransformRcPtr);
#endif
ConstConfigRcPtr *OCIO_getCurrentConfig(void);
void OCIO_setCurrentConfig(const ConstConfigRcPtr *config);
ConstConfigRcPtr *OCIO_configCreateFromEnv(void);
ConstConfigRcPtr *OCIO_configCreateFromFile(const char* filename);
void OCIO_configRelease(ConstConfigRcPtr *config);
int OCIO_configGetNumColorSpaces(ConstConfigRcPtr *config);
const char *OCIO_configGetColorSpaceNameByIndex(ConstConfigRcPtr *config, int index);
ConstColorSpaceRcPtr *OCIO_configGetColorSpace(ConstConfigRcPtr *config, const char *name);
int OCIO_configGetIndexForColorSpace(ConstConfigRcPtr *config, const char *name);
int OCIO_colorSpaceIsInvertible(ConstColorSpaceRcPtr *cs);
void OCIO_colorSpaceRelease(ConstColorSpaceRcPtr *cs);
const char *OCIO_configGetDefaultDisplay(ConstConfigRcPtr *config);
int OCIO_configGetNumDisplays(ConstConfigRcPtr *config);
const char *OCIO_configGetDisplay(ConstConfigRcPtr *config, int index);
const char *OCIO_configGetDefaultView(ConstConfigRcPtr *config, const char *display);
int OCIO_configGetNumViews(ConstConfigRcPtr *config, const char *display);
const char *OCIO_configGetView(ConstConfigRcPtr *config, const char *display, int index);
const char *OCIO_configGetDisplayColorSpaceName(ConstConfigRcPtr *config, const char *display, const char *view);
ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(ConstConfigRcPtr *config, const char *srcName, const char *dstName);
ConstProcessorRcPtr *OCIO_configGetProcessor(ConstConfigRcPtr *config, ConstTransformRcPtr *transform);
void OCIO_processorApply(ConstProcessorRcPtr *processor, PackedImageDesc *img);
void OCIO_processorApply_predivide(ConstProcessorRcPtr *processor, PackedImageDesc *img);
void OCIO_processorApplyRGB(ConstProcessorRcPtr *processor, float *pixel);
void OCIO_processorApplyRGBA(ConstProcessorRcPtr *processor, float *pixel);
void OCIO_processorApplyRGBA_predivide(ConstProcessorRcPtr *processor, float *pixel);
void OCIO_processorRelease(ConstProcessorRcPtr *p);
const char *OCIO_colorSpaceGetName(ConstColorSpaceRcPtr *cs);
const char *OCIO_colorSpaceGetDescription(ConstColorSpaceRcPtr *cs);
const char *OCIO_colorSpaceGetFamily(ConstColorSpaceRcPtr *cs);
DisplayTransformRcPtr *OCIO_createDisplayTransform(void);
void OCIO_displayTransformSetInputColorSpaceName(DisplayTransformRcPtr *dt, const char *name);
void OCIO_displayTransformSetDisplay(DisplayTransformRcPtr *dt, const char *name);
void OCIO_displayTransformSetView(DisplayTransformRcPtr *dt, const char *name);
void OCIO_displayTransformSetDisplayCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *et);
void OCIO_displayTransformSetLinearCC(DisplayTransformRcPtr *dt, ConstTransformRcPtr *et);
void OCIO_displayTransformRelease(DisplayTransformRcPtr *dt);
PackedImageDesc *OCIO_createPackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes);
void OCIO_packedImageDescRelease(PackedImageDesc *p);
ExponentTransformRcPtr *OCIO_createExponentTransform(void);
void OCIO_exponentTransformSetValue(ExponentTransformRcPtr *et, const float *exponent);
void OCIO_exponentTransformRelease(ExponentTransformRcPtr *et);
MatrixTransformRcPtr *OCIO_createMatrixTransform(void);
void OCIO_matrixTransformSetValue(MatrixTransformRcPtr *et, const float *m44, const float *offset4);
void OCIO_matrixTransformRelease(MatrixTransformRcPtr *mt);
void OCIO_matrixTransformScale(float * m44, float * offset4, const float * scale4);
#ifdef __cplusplus
}
#endif
#endif //OCIO_CAPI_H

@ -0,0 +1,380 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2012 Blender Foundation.
* All rights reserved.
*
* Contributor(s): Brecht van Lommel
*
* ***** END GPL LICENSE BLOCK *****
*/
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_math_color.h"
namespace OCIO_NAMESPACE {};
#include "ocio_capi.h"
#define CONFIG_DEFAULT ((ConstConfigRcPtr*)1)
#define PROCESSOR_LINEAR_TO_SRGB ((ConstProcessorRcPtr*)1)
#define PROCESSOR_SRGB_TO_LINEAR ((ConstProcessorRcPtr*)2)
#define PROCESSOR_UNKNOWN ((ConstProcessorRcPtr*)3)
#define COLORSPACE_LINEAR ((ConstColorSpaceRcPtr*)1)
#define COLORSPACE_SRGB ((ConstColorSpaceRcPtr*)2)
typedef struct PackedImageDescription {
float *data;
long width;
long height;
long numChannels;
long chanStrideBytes;
long xStrideBytes;
long yStrideBytes;
} PackedImageDescription;
ConstConfigRcPtr *OCIO_getCurrentConfig(void)
{
return CONFIG_DEFAULT;
}
void OCIO_setCurrentConfig(const ConstConfigRcPtr *)
{
}
ConstConfigRcPtr *OCIO_configCreateFromEnv(void)
{
return CONFIG_DEFAULT;
}
ConstConfigRcPtr *OCIO_configCreateFromFile(const char *)
{
return CONFIG_DEFAULT;
}
void OCIO_configRelease(ConstConfigRcPtr *)
{
}
int OCIO_configGetNumColorSpaces(ConstConfigRcPtr *)
{
return 2;
}
const char *OCIO_configGetColorSpaceNameByIndex(ConstConfigRcPtr *, int index)
{
if (index == 0)
return "Linear";
else if (index == 1)
return "sRGB";
return NULL;
}
ConstColorSpaceRcPtr *OCIO_configGetColorSpace(ConstConfigRcPtr *, const char *name)
{
if (strcmp(name, "scene_linear") == 0)
return COLORSPACE_LINEAR;
else if (strcmp(name, "color_picking") == 0)
return COLORSPACE_SRGB;
else if (strcmp(name, "texture_paint") == 0)
return COLORSPACE_LINEAR;
else if (strcmp(name, "default_byte") == 0)
return COLORSPACE_SRGB;
else if (strcmp(name, "default_float") == 0)
return COLORSPACE_LINEAR;
else if (strcmp(name, "default_sequencer") == 0)
return COLORSPACE_SRGB;
else if (strcmp(name, "Linear") == 0)
return COLORSPACE_LINEAR;
else if (strcmp(name, "sRGB") == 0)
return COLORSPACE_SRGB;
return NULL;
}
int OCIO_configGetIndexForColorSpace(ConstConfigRcPtr *config, const char *name)
{
ConstColorSpaceRcPtr *cs = OCIO_configGetColorSpace(config, name);
if (cs == COLORSPACE_LINEAR)
return 0;
else if (cs == COLORSPACE_SRGB)
return 1;
return -1;
}
const char *OCIO_configGetDefaultDisplay(ConstConfigRcPtr *)
{
return "sRGB";
}
int OCIO_configGetNumDisplays(ConstConfigRcPtr* config)
{
return 1;
}
const char *OCIO_configGetDisplay(ConstConfigRcPtr *, int index)
{
if (index == 0)
return "sRGB";
return NULL;
}
const char *OCIO_configGetDefaultView(ConstConfigRcPtr *, const char *)
{
return "Default";
}
int OCIO_configGetNumViews(ConstConfigRcPtr *, const char *)
{
return 1;
}
const char *OCIO_configGetView(ConstConfigRcPtr *, const char *, int index)
{
if (index == 0)
return "Default";
return NULL;
}
const char *OCIO_configGetDisplayColorSpaceName(ConstConfigRcPtr *, const char *, const char *)
{
return "sRGB";
}
int OCIO_colorSpaceIsInvertible(ConstColorSpaceRcPtr *cs)
{
return 1;
}
void OCIO_colorSpaceRelease(ConstColorSpaceRcPtr *cs)
{
}
ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(ConstConfigRcPtr *config, const char *srcName, const char *dstName)
{
ConstColorSpaceRcPtr *cs_src = OCIO_configGetColorSpace(config, srcName);
ConstColorSpaceRcPtr *cs_dst = OCIO_configGetColorSpace(config, dstName);
if (cs_src == COLORSPACE_LINEAR && cs_dst == COLORSPACE_SRGB)
return PROCESSOR_LINEAR_TO_SRGB;
else if (cs_src == COLORSPACE_SRGB && cs_dst == COLORSPACE_LINEAR)
return PROCESSOR_SRGB_TO_LINEAR;
return 0;
}
ConstProcessorRcPtr *OCIO_configGetProcessor(ConstConfigRcPtr *, ConstTransformRcPtr *tfm)
{
return (ConstProcessorRcPtr*)tfm;
}
void OCIO_processorApply(ConstProcessorRcPtr *processor, PackedImageDesc *img)
{
/* OCIO_TODO stride not respected, channels must be 3 or 4 */
PackedImageDescription *desc = (PackedImageDescription*)img;
int channels = desc->numChannels;
float *pixels = desc->data;
int width = desc->width;
int height = desc->height;
int x, y;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
float *pixel = pixels + channels * (y * width + x);
if (channels == 4)
OCIO_processorApplyRGBA(processor, pixel);
else if (channels == 3)
OCIO_processorApplyRGB(processor, pixel);
}
}
}
void OCIO_processorApply_predivide(ConstProcessorRcPtr *processor, PackedImageDesc *img)
{
/* OCIO_TODO stride not respected, channels must be 3 or 4 */
PackedImageDescription *desc = (PackedImageDescription*)img;
int channels = desc->numChannels;
float *pixels = desc->data;
int width = desc->width;
int height = desc->height;
int x, y;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
float *pixel = pixels + channels * (y * width + x);
if (channels == 4)
OCIO_processorApplyRGBA_predivide(processor, pixel);
else if (channels == 3)
OCIO_processorApplyRGB(processor, pixel);
}
}
}
void OCIO_processorApplyRGB(ConstProcessorRcPtr *processor, float *pixel)
{
if (processor == PROCESSOR_LINEAR_TO_SRGB)
linearrgb_to_srgb_v3_v3(pixel, pixel);
else if (processor == PROCESSOR_SRGB_TO_LINEAR)
srgb_to_linearrgb_v3_v3(pixel, pixel);
}
void OCIO_processorApplyRGBA(ConstProcessorRcPtr *processor, float *pixel)
{
if (processor == PROCESSOR_LINEAR_TO_SRGB)
linearrgb_to_srgb_v4(pixel, pixel);
else if (processor == PROCESSOR_SRGB_TO_LINEAR)
srgb_to_linearrgb_v4(pixel, pixel);
}
void OCIO_processorApplyRGBA_predivide(ConstProcessorRcPtr *processor, float *pixel)
{
if (pixel[3] == 1.0f || pixel[3] == 0.0f) {
OCIO_processorApplyRGBA(processor, pixel);
}
else {
float alpha, inv_alpha;
alpha = pixel[3];
inv_alpha = 1.0f / alpha;
pixel[0] *= inv_alpha;
pixel[1] *= inv_alpha;
pixel[2] *= inv_alpha;
OCIO_processorApplyRGBA(processor, pixel);
pixel[0] *= alpha;
pixel[1] *= alpha;
pixel[2] *= alpha;
}
}
void OCIO_processorRelease(ConstProcessorRcPtr *)
{
}
const char *OCIO_colorSpaceGetName(ConstColorSpaceRcPtr *cs)
{
if (cs == COLORSPACE_LINEAR)
return "Linear";
else if (cs == COLORSPACE_SRGB)
return "sRGB";
return NULL;
}
const char *OCIO_colorSpaceGetDescription(ConstColorSpaceRcPtr *)
{
return "";
}
const char *OCIO_colorSpaceGetFamily(ConstColorSpaceRcPtr *)
{
return "";
}
DisplayTransformRcPtr *OCIO_createDisplayTransform(void)
{
return (DisplayTransformRcPtr*)PROCESSOR_LINEAR_TO_SRGB;
}
void OCIO_displayTransformSetInputColorSpaceName(DisplayTransformRcPtr *, const char *)
{
}
void OCIO_displayTransformSetDisplay(DisplayTransformRcPtr *, const char *)
{
}
void OCIO_displayTransformSetView(DisplayTransformRcPtr *, const char *)
{
}
void OCIO_displayTransformSetDisplayCC(DisplayTransformRcPtr *, ConstTransformRcPtr *)
{
}
void OCIO_displayTransformSetLinearCC(DisplayTransformRcPtr *, ConstTransformRcPtr *)
{
}
void OCIO_displayTransformRelease(DisplayTransformRcPtr *)
{
}
PackedImageDesc *OCIO_createPackedImageDesc(float *data, long width, long height, long numChannels,
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
{
PackedImageDescription *desc = (PackedImageDescription*)MEM_callocN(sizeof(PackedImageDescription), "PackedImageDescription");
desc->data = data;
desc->width = width;
desc->height = height;
desc->numChannels = numChannels;
desc->chanStrideBytes = chanStrideBytes;
desc->xStrideBytes = xStrideBytes;
desc->yStrideBytes = yStrideBytes;
return (PackedImageDesc*)desc;
}
void OCIO_packedImageDescRelease(PackedImageDesc* id)
{
MEM_freeN(id);
}
ExponentTransformRcPtr *OCIO_createExponentTransform(void)
{
return (ExponentTransformRcPtr*)PROCESSOR_UNKNOWN;
}
void OCIO_exponentTransformSetValue(ExponentTransformRcPtr *, const float *)
{
}
void OCIO_exponentTransformRelease(ExponentTransformRcPtr *)
{
}
MatrixTransformRcPtr *OCIO_createMatrixTransform(void)
{
return (MatrixTransformRcPtr*)PROCESSOR_UNKNOWN;
}
void OCIO_matrixTransformSetValue(MatrixTransformRcPtr *, const float *, const float *)
{
}
void OCIO_matrixTransformRelease(MatrixTransformRcPtr *)
{
}
void OCIO_matrixTransformScale(float * , float * , const float *)
{
}

@ -0,0 +1,284 @@
# OpenCOlorIO configuration file for Blender
#
# Based on aces, nuke-default and spi configurations from OpenColorIO-Config
ocio_profile_version: 1
search_path: luts
strictparsing: true
luma: [0.2126, 0.7152, 0.0722]
description: RRT version ut33
roles:
reference: Linear ACES
# Internal scene linear space
scene_linear: Linear
# Default color space for byte image
default_byte: sRGB
# Default color space for float images
default_float: Linear
# Default color space sequencer is working in
default_sequencer: sRGB
# Color spaces for color picking and exture painting (not internally supported yet)
color_picking: Raw
texture_paint: Raw
displays:
sRGB:
- !<View> {name: Default, colorspace: sRGB}
- !<View> {name: RRT, colorspace: rrt_srgb}
- !<View> {name: Film, colorspace: srgb8}
- !<View> {name: Raw, colorspace: Raw}
- !<View> {name: Log, colorspace: lg10}
DCI-P3:
- !<View> {name: RRT, colorspace: rrt_p3dci}
- !<View> {name: Film, colorspace: p3dci8}
- !<View> {name: Raw, colorspace: Raw}
- !<View> {name: Log, colorspace: adx10}
Rec709:
- !<View> {name: Default, colorspace: nuke_rec709}
- !<View> {name: RRT, colorspace: rrt_rec709}
XYZ:
- !<View> {name: Default, colorspace: XYZ}
- !<View> {name: RRT, colorspace: rrt_xyz}
- !<View> {name: DCI, colorspace: dci_xyz}
- !<View> {name: Raw, colorspace: Raw}
- !<View> {name: Log, colorspace: adx10}
None:
- !<View> {name: Default, colorspace: raw}
active_displays: [sRGB, DCIP3, Rec709, XYZ, None]
active_views: [Default, RRT, Raw, Log]
colorspaces:
- !<ColorSpace>
name: Linear ACES
family: aces
equalitygroup:
bitdepth: 32f
isdata: false
allocation: lg2
allocationvars: [-8.5, 5]
- !<ColorSpace>
name: Raw
family: raw
equalitygroup:
bitdepth: 32f
isdata: true
allocation: uniform
allocationvars: [0, 1]
- !<ColorSpace>
name: adx10
family: display
equalitygroup:
bitdepth: 10ui
description: |
Film Scan, using the 10-bit Academy Density Encoding
isdata: false
allocation: uniform
allocationvars: [0, 1]
to_reference: !<GroupTransform>
children:
- !<FileTransform> {src: adx_adx10_to_cdd.spimtx}
- !<FileTransform> {src: adx_cdd_to_cid.spimtx}
- !<FileTransform> {src: adx_cid_to_rle.spi1d, interpolation: linear}
- !<LogTransform> {base: 10, direction: inverse}
- !<FileTransform> {src: adx_exp_to_aces.spimtx}
- !<ColorSpace>
name: Linear
family:
equalitygroup:
bitdepth: 32f
description: |
Rec. 709 (Full Range), Blender native linear space
isdata: false
allocation: uniform
allocationvars: [-0.125, 1.125]
to_reference: !<FileTransform> {src: rec709_to_aces.spimtx, interpolation: nearest}
- !<ColorSpace>
name: rrt_srgb
family: rrt
equalitygroup:
bitdepth: 32f
isdata: false
allocation: uniform
allocationvars: [0, 1]
from_reference: !<GroupTransform>
children:
- !<AllocationTransform> {allocation: lg2, vars: [-8.5, 5]}
- !<FileTransform> {src: rrt_ut33_sRGB.spi3d, interpolation: tetrahedral}
- !<ColorSpace>
name: nuke_rec709
family: display
equalitygroup:
bitdepth: 32f
description: |
Rec. 709 (Full Range) Display Space
isdata: false
allocation: uniform
allocationvars: [-0.125, 1.125]
to_reference: !<GroupTransform>
children:
- !<FileTransform> {src: rec709.spi1d, interpolation: linear}
- !<FileTransform> {src: rec709_to_aces.spimtx, interpolation: nearest}
- !<ColorSpace>
name: rrt_rec709
family: rrt
equalitygroup:
bitdepth: 32f
isdata: false
allocation: uniform
allocationvars: [0, 1]
from_reference: !<GroupTransform>
children:
- !<AllocationTransform> {allocation: lg2, vars: [-8.5, 5]}
- !<FileTransform> {src: rrt_ut33_rec709.spi3d, interpolation: tetrahedral}
- !<ColorSpace>
name: rrt_p3dci
family: rrt
equalitygroup:
bitdepth: 32f
isdata: false
allocation: uniform
allocationvars: [0, 1]
from_reference: !<GroupTransform>
children:
- !<AllocationTransform> {allocation: lg2, vars: [-8.5, 5]}
- !<FileTransform> {src: rrt_ut33_p3dci.spi3d, interpolation: tetrahedral}
- !<ColorSpace>
name: XYZ
family:
equalitygroup:
bitdepth: 32f
isdata: false
allocation: uniform
allocationvars: [0, 1]
from_reference: !<GroupTransform>
children:
- !<FileTransform> {src: aces_to_xyz.spimtx, interpolation: linear}
- !<ColorSpace>
name: rrt_xyz
family: rrt
equalitygroup:
bitdepth: 32f
isdata: false
allocation: uniform
allocationvars: [0, 1]
from_reference: !<GroupTransform>
children:
- !<AllocationTransform> {allocation: lg2, vars: [-8.5, 5]}
- !<FileTransform> {src: rrt_ut33_dcdm.spi3d, interpolation: tetrahedral}
- !<ColorSpace>
name: dci_xyz
family: display
equalitygroup:
bitdepth: 16f
description: |
OpenDCP output LUT with DCI reference white and Gamma 2.6
isdata: false
allocation: uniform
allocationvars: [0, 1]
from_reference: !<GroupTransform>
children:
- !<FileTransform> {src: rec709_to_aces.spimtx, interpolation: linear, direction: inverse}
- !<FileTransform> {src: srgb_to_xyz.spimtx, interpolation: linear}
- !<FileTransform> {src: dci_xyz.spi1d, interpolation: linear}
- !<ColorSpace>
name: lg10
family: display
equalitygroup:
bitdepth: 10ui
description: |
conversion from film log
isdata: false
allocation: uniform
to_reference: !<GroupTransform>
children:
- !<FileTransform> {src: lg10.spi1d, interpolation: nearest}
- !<FileTransform> {src: rec709_to_aces.spimtx, interpolation: nearest}
- !<ColorSpace>
name: srgb8
family: display
equalitygroup:
bitdepth: 8ui
description: |
RGB display space for the sRGB standard.
isdata: false
allocation: uniform
from_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Linear ACES, dst: lg10}
- !<FileTransform> {src: spi_ocio_srgb_test.spi3d, interpolation: linear}
- !<ColorSpace>
name: sRGB
family:
equalitygroup:
bitdepth: 32f
description: |
Standard RGB Display Space
isdata: false
allocation: uniform
allocationvars: [-0.125, 1.125]
to_reference: !<GroupTransform>
children:
- !<FileTransform> {src: srgb.spi1d, interpolation: linear}
- !<FileTransform> {src: rec709_to_aces.spimtx, interpolation: nearest}
- !<ColorSpace>
name: VD16
family: vd
equalitygroup:
bitdepth: 16ui
description: |
The simple video conversion from a gamma 2.2 sRGB space
isdata: false
allocation: uniform
to_reference: !<GroupTransform>
children:
- !<FileTransform> {src: vd16.spi1d, interpolation: nearest}
- !<FileTransform> {src: rec709_to_aces.spimtx, interpolation: linear}
- !<ColorSpace>
name: Non-Color
family: raw
description: |
Color space used for images which contains non-color data (i,e, normal maps)
equalitygroup:
bitdepth: 32f
isdata: true
allocation: uniform
allocationvars: [0, 1]
- !<ColorSpace>
name: p3dci8
family: display
equalitygroup:
bitdepth: 8ui
description: |
p3dci8 :rgb display space for gamma 2.6 P3 projection.
isdata: false
allocation: uniform
from_reference: !<GroupTransform>
children:
- !<ColorSpaceTransform> {src: Linear ACES, dst: lg10}
- !<FileTransform> {src: colorworks_filmlg_to_p3.3dl, interpolation: linear}

@ -0,0 +1,3 @@
0.9525523959 0.0000000000 0.0000936786 0
0.3439664498 0.7281660966 -0.072132546 0
0.0000000000 0.0000000000 1.0088251844 0

@ -0,0 +1,4 @@
2.046 0.0 0.0 -12451.65
0.0 2.046 0.0 -12451.65
0.0 0.0 2.046 -12451.65

@ -0,0 +1,4 @@
0.75573 0.22197 0.02230 0
0.05901 0.96928 -0.02829 0
0.16134 0.07406 0.76460 0

File diff suppressed because it is too large Load Diff

@ -0,0 +1,4 @@
0.72286 0.12630 0.15084 0
0.11923 0.76418 0.11659 0
0.01427 0.08213 0.90359 0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,3 @@
0.4395770431 0.3839148879 0.1765103489 0.0
0.0895979404 0.8147120476 0.0956883803 0.0
0.0174174830 0.1087378338 0.8738504052 0.0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,3 @@
0.4124564 0.3575761 0.1804375 0
0.2126729 0.7151522 0.0721750 0
0.0193339 0.1191920 0.9503041 0

File diff suppressed because it is too large Load Diff