This files apparently were't marked for delete/add properly
This commit is contained in:
382
intern/opencolorio/fallback_impl.cc
Normal file
382
intern/opencolorio/fallback_impl.cc
Normal file
@@ -0,0 +1,382 @@
|
||||
/*
|
||||
* ***** 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"
|
||||
|
||||
#include "ocio_impl.h"
|
||||
|
||||
#define CONFIG_DEFAULT ((OCIO_ConstConfigRcPtr*)1)
|
||||
|
||||
#define PROCESSOR_LINEAR_TO_SRGB ((OCIO_ConstProcessorRcPtr*)1)
|
||||
#define PROCESSOR_SRGB_TO_LINEAR ((OCIO_ConstProcessorRcPtr*)2)
|
||||
#define PROCESSOR_UNKNOWN ((OCIO_ConstProcessorRcPtr*)3)
|
||||
|
||||
#define COLORSPACE_LINEAR ((OCIO_ConstColorSpaceRcPtr*)1)
|
||||
#define COLORSPACE_SRGB ((OCIO_ConstColorSpaceRcPtr*)2)
|
||||
|
||||
typedef struct OCIO_PackedImageDescription {
|
||||
float *data;
|
||||
long width;
|
||||
long height;
|
||||
long numChannels;
|
||||
long chanStrideBytes;
|
||||
long xStrideBytes;
|
||||
long yStrideBytes;
|
||||
} OCIO_PackedImageDescription;
|
||||
|
||||
OCIO_ConstConfigRcPtr *FallbackImpl::getCurrentConfig(void)
|
||||
{
|
||||
return CONFIG_DEFAULT;
|
||||
}
|
||||
|
||||
void FallbackImpl::setCurrentConfig(const OCIO_ConstConfigRcPtr *)
|
||||
{
|
||||
}
|
||||
|
||||
OCIO_ConstConfigRcPtr *FallbackImpl::configCreateFromEnv(void)
|
||||
{
|
||||
return CONFIG_DEFAULT;
|
||||
}
|
||||
|
||||
OCIO_ConstConfigRcPtr *FallbackImpl::configCreateFromFile(const char *)
|
||||
{
|
||||
return CONFIG_DEFAULT;
|
||||
}
|
||||
|
||||
void FallbackImpl::configRelease(OCIO_ConstConfigRcPtr *)
|
||||
{
|
||||
}
|
||||
|
||||
int FallbackImpl::configGetNumColorSpaces(OCIO_ConstConfigRcPtr *)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
const char *FallbackImpl::configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *, int index)
|
||||
{
|
||||
if (index == 0)
|
||||
return "Linear";
|
||||
else if (index == 1)
|
||||
return "sRGB";
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
OCIO_ConstColorSpaceRcPtr *FallbackImpl::configGetColorSpace(OCIO_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 FallbackImpl::configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name)
|
||||
{
|
||||
OCIO_ConstColorSpaceRcPtr *cs = configGetColorSpace(config, name);
|
||||
|
||||
if (cs == COLORSPACE_LINEAR)
|
||||
return 0;
|
||||
else if (cs == COLORSPACE_SRGB)
|
||||
return 1;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char *FallbackImpl::configGetDefaultDisplay(OCIO_ConstConfigRcPtr *)
|
||||
{
|
||||
return "sRGB";
|
||||
}
|
||||
|
||||
int FallbackImpl::configGetNumDisplays(OCIO_ConstConfigRcPtr* config)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *FallbackImpl::configGetDisplay(OCIO_ConstConfigRcPtr *, int index)
|
||||
{
|
||||
if (index == 0)
|
||||
return "sRGB";
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *FallbackImpl::configGetDefaultView(OCIO_ConstConfigRcPtr *, const char *)
|
||||
{
|
||||
return "Default";
|
||||
}
|
||||
|
||||
int FallbackImpl::configGetNumViews(OCIO_ConstConfigRcPtr *, const char *)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *FallbackImpl::configGetView(OCIO_ConstConfigRcPtr *, const char *, int index)
|
||||
{
|
||||
if (index == 0)
|
||||
return "Default";
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *FallbackImpl::configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *, const char *, const char *)
|
||||
{
|
||||
return "sRGB";
|
||||
}
|
||||
|
||||
int FallbackImpl::colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int FallbackImpl::colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FallbackImpl::colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
}
|
||||
|
||||
OCIO_ConstProcessorRcPtr *FallbackImpl::configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config, const char *srcName, const char *dstName)
|
||||
{
|
||||
OCIO_ConstColorSpaceRcPtr *cs_src = configGetColorSpace(config, srcName);
|
||||
OCIO_ConstColorSpaceRcPtr *cs_dst = 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;
|
||||
}
|
||||
|
||||
OCIO_ConstProcessorRcPtr *FallbackImpl::configGetProcessor(OCIO_ConstConfigRcPtr *, OCIO_ConstTransformRcPtr *tfm)
|
||||
{
|
||||
return (OCIO_ConstProcessorRcPtr*)tfm;
|
||||
}
|
||||
|
||||
void FallbackImpl::processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img)
|
||||
{
|
||||
/* OCIO_TODO stride not respected, channels must be 3 or 4 */
|
||||
OCIO_PackedImageDescription *desc = (OCIO_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)
|
||||
processorApplyRGBA(processor, pixel);
|
||||
else if (channels == 3)
|
||||
processorApplyRGB(processor, pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FallbackImpl::processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img)
|
||||
{
|
||||
/* OCIO_TODO stride not respected, channels must be 3 or 4 */
|
||||
OCIO_PackedImageDescription *desc = (OCIO_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)
|
||||
processorApplyRGBA_predivide(processor, pixel);
|
||||
else if (channels == 3)
|
||||
processorApplyRGB(processor, pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FallbackImpl::processorApplyRGB(OCIO_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 FallbackImpl::processorApplyRGBA(OCIO_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 FallbackImpl::processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel)
|
||||
{
|
||||
if (pixel[3] == 1.0f || pixel[3] == 0.0f) {
|
||||
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;
|
||||
|
||||
processorApplyRGBA(processor, pixel);
|
||||
|
||||
pixel[0] *= alpha;
|
||||
pixel[1] *= alpha;
|
||||
pixel[2] *= alpha;
|
||||
}
|
||||
}
|
||||
|
||||
void FallbackImpl::processorRelease(OCIO_ConstProcessorRcPtr *)
|
||||
{
|
||||
}
|
||||
|
||||
const char *FallbackImpl::colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
if (cs == COLORSPACE_LINEAR)
|
||||
return "Linear";
|
||||
else if (cs == COLORSPACE_SRGB)
|
||||
return "sRGB";
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *FallbackImpl::colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
const char *FallbackImpl::colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
OCIO_DisplayTransformRcPtr *FallbackImpl::createDisplayTransform(void)
|
||||
{
|
||||
return (OCIO_DisplayTransformRcPtr*)PROCESSOR_LINEAR_TO_SRGB;
|
||||
}
|
||||
|
||||
void FallbackImpl::displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *, const char *)
|
||||
{
|
||||
}
|
||||
|
||||
void FallbackImpl::displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *, const char *)
|
||||
{
|
||||
}
|
||||
|
||||
void FallbackImpl::displayTransformSetView(OCIO_DisplayTransformRcPtr *, const char *)
|
||||
{
|
||||
}
|
||||
|
||||
void FallbackImpl::displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *, OCIO_ConstTransformRcPtr *)
|
||||
{
|
||||
}
|
||||
|
||||
void FallbackImpl::displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *, OCIO_ConstTransformRcPtr *)
|
||||
{
|
||||
}
|
||||
|
||||
void FallbackImpl::displayTransformRelease(OCIO_DisplayTransformRcPtr *)
|
||||
{
|
||||
}
|
||||
|
||||
OCIO_PackedImageDesc *FallbackImpl::createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
|
||||
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
|
||||
{
|
||||
OCIO_PackedImageDescription *desc = (OCIO_PackedImageDescription*)MEM_callocN(sizeof(OCIO_PackedImageDescription), "OCIO_PackedImageDescription");
|
||||
|
||||
desc->data = data;
|
||||
desc->width = width;
|
||||
desc->height = height;
|
||||
desc->numChannels = numChannels;
|
||||
desc->chanStrideBytes = chanStrideBytes;
|
||||
desc->xStrideBytes = xStrideBytes;
|
||||
desc->yStrideBytes = yStrideBytes;
|
||||
|
||||
return (OCIO_PackedImageDesc*)desc;
|
||||
}
|
||||
|
||||
void FallbackImpl::OCIO_PackedImageDescRelease(OCIO_PackedImageDesc* id)
|
||||
{
|
||||
MEM_freeN(id);
|
||||
}
|
||||
|
||||
OCIO_ExponentTransformRcPtr *FallbackImpl::createExponentTransform(void)
|
||||
{
|
||||
return (OCIO_ExponentTransformRcPtr*)PROCESSOR_UNKNOWN;
|
||||
}
|
||||
|
||||
void FallbackImpl::exponentTransformSetValue(OCIO_ExponentTransformRcPtr *, const float *)
|
||||
{
|
||||
}
|
||||
|
||||
void FallbackImpl::exponentTransformRelease(OCIO_ExponentTransformRcPtr *)
|
||||
{
|
||||
}
|
||||
|
||||
OCIO_MatrixTransformRcPtr *FallbackImpl::createMatrixTransform(void)
|
||||
{
|
||||
return (OCIO_MatrixTransformRcPtr*)PROCESSOR_UNKNOWN;
|
||||
}
|
||||
|
||||
void FallbackImpl::matrixTransformSetValue(OCIO_MatrixTransformRcPtr *, const float *, const float *)
|
||||
{
|
||||
}
|
||||
|
||||
void FallbackImpl::matrixTransformRelease(OCIO_MatrixTransformRcPtr *)
|
||||
{
|
||||
}
|
||||
|
||||
void FallbackImpl::matrixTransformScale(float * , float * , const float *)
|
||||
{
|
||||
}
|
||||
284
intern/opencolorio/ocio_capi.cc
Normal file
284
intern/opencolorio/ocio_capi.cc
Normal file
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
* ***** 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): Sergey Sharybin
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "ocio_impl.h"
|
||||
|
||||
static IOCIOImpl *impl = NULL;
|
||||
|
||||
void OCIO_init(void)
|
||||
{
|
||||
#ifdef WITH_OCIO
|
||||
impl = new OCIOImpl();
|
||||
#else
|
||||
impl = new FallbackImpl();
|
||||
#endif
|
||||
}
|
||||
|
||||
void OCIO_exit(void)
|
||||
{
|
||||
delete impl;
|
||||
impl = NULL;
|
||||
}
|
||||
|
||||
OCIO_ConstConfigRcPtr *OCIO_getCurrentConfig(void)
|
||||
{
|
||||
return impl->getCurrentConfig();
|
||||
}
|
||||
|
||||
OCIO_ConstConfigRcPtr *OCIO_configCreateFallback(void)
|
||||
{
|
||||
delete impl;
|
||||
impl = new FallbackImpl();
|
||||
|
||||
return impl->getCurrentConfig();
|
||||
}
|
||||
|
||||
void OCIO_setCurrentConfig(const OCIO_ConstConfigRcPtr *config)
|
||||
{
|
||||
impl->setCurrentConfig(config);
|
||||
}
|
||||
|
||||
OCIO_ConstConfigRcPtr *OCIO_configCreateFromEnv(void)
|
||||
{
|
||||
return impl->configCreateFromEnv();
|
||||
}
|
||||
|
||||
OCIO_ConstConfigRcPtr *OCIO_configCreateFromFile(const char *filename)
|
||||
{
|
||||
return impl->configCreateFromFile(filename);
|
||||
}
|
||||
|
||||
void OCIO_configRelease(OCIO_ConstConfigRcPtr *config)
|
||||
{
|
||||
impl->configRelease(config);
|
||||
}
|
||||
|
||||
int OCIO_configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config)
|
||||
{
|
||||
return impl->configGetNumColorSpaces(config);
|
||||
}
|
||||
|
||||
const char *OCIO_configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index)
|
||||
{
|
||||
return impl->configGetColorSpaceNameByIndex(config, index);
|
||||
}
|
||||
|
||||
OCIO_ConstColorSpaceRcPtr *OCIO_configGetColorSpace(OCIO_ConstConfigRcPtr *config, const char *name)
|
||||
{
|
||||
return impl->configGetColorSpace(config, name);
|
||||
}
|
||||
|
||||
int OCIO_configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name)
|
||||
{
|
||||
return impl->configGetIndexForColorSpace(config, name);
|
||||
}
|
||||
|
||||
const char *OCIO_configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config)
|
||||
{
|
||||
return impl->configGetDefaultDisplay(config);
|
||||
}
|
||||
|
||||
int OCIO_configGetNumDisplays(OCIO_ConstConfigRcPtr* config)
|
||||
{
|
||||
return impl->configGetNumDisplays(config);
|
||||
}
|
||||
|
||||
const char *OCIO_configGetDisplay(OCIO_ConstConfigRcPtr *config, int index)
|
||||
{
|
||||
return impl->configGetDisplay(config, index);
|
||||
}
|
||||
|
||||
const char *OCIO_configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display)
|
||||
{
|
||||
return impl->configGetDefaultView(config, display);
|
||||
}
|
||||
|
||||
int OCIO_configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display)
|
||||
{
|
||||
return impl->configGetNumViews(config, display);
|
||||
}
|
||||
|
||||
const char *OCIO_configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index)
|
||||
{
|
||||
return impl->configGetView(config, display, index);
|
||||
}
|
||||
|
||||
const char *OCIO_configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view)
|
||||
{
|
||||
return impl->configGetDisplayColorSpaceName(config, display, view);
|
||||
}
|
||||
|
||||
int OCIO_colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
return impl->colorSpaceIsInvertible(cs);
|
||||
}
|
||||
|
||||
int OCIO_colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
return impl->colorSpaceIsData(cs);
|
||||
}
|
||||
|
||||
void OCIO_colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
impl->colorSpaceRelease(cs);
|
||||
}
|
||||
|
||||
OCIO_ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config, const char *srcName, const char *dstName)
|
||||
{
|
||||
return impl->configGetProcessorWithNames(config, srcName, dstName);
|
||||
}
|
||||
|
||||
OCIO_ConstProcessorRcPtr *OCIO_configGetProcessor(OCIO_ConstConfigRcPtr *config, OCIO_ConstTransformRcPtr *transform)
|
||||
{
|
||||
return impl->configGetProcessor(config, transform);
|
||||
}
|
||||
|
||||
void OCIO_processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img)
|
||||
{
|
||||
impl->processorApply(processor, img);
|
||||
}
|
||||
|
||||
void OCIO_processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img)
|
||||
{
|
||||
impl->processorApply_predivide(processor, img);
|
||||
}
|
||||
|
||||
void OCIO_processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel)
|
||||
{
|
||||
impl->processorApplyRGB(processor, pixel);
|
||||
}
|
||||
|
||||
void OCIO_processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel)
|
||||
{
|
||||
impl->processorApplyRGBA(processor, pixel);
|
||||
}
|
||||
|
||||
void OCIO_processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel)
|
||||
{
|
||||
impl->processorApplyRGBA_predivide(processor, pixel);
|
||||
}
|
||||
|
||||
void OCIO_processorRelease(OCIO_ConstProcessorRcPtr *p)
|
||||
{
|
||||
impl->processorRelease(p);
|
||||
}
|
||||
|
||||
const char *OCIO_colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
return impl->colorSpaceGetName(cs);
|
||||
}
|
||||
|
||||
const char *OCIO_colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
return impl->colorSpaceGetDescription(cs);
|
||||
}
|
||||
|
||||
const char *OCIO_colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
return impl->colorSpaceGetFamily(cs);
|
||||
}
|
||||
|
||||
OCIO_DisplayTransformRcPtr *OCIO_createDisplayTransform(void)
|
||||
{
|
||||
return impl->createDisplayTransform();
|
||||
}
|
||||
|
||||
void OCIO_displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name)
|
||||
{
|
||||
impl->displayTransformSetInputColorSpaceName(dt, name);
|
||||
}
|
||||
|
||||
void OCIO_displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name)
|
||||
{
|
||||
impl->displayTransformSetDisplay(dt, name);
|
||||
}
|
||||
|
||||
void OCIO_displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name)
|
||||
{
|
||||
impl->displayTransformSetView(dt, name);
|
||||
}
|
||||
|
||||
void OCIO_displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *t)
|
||||
{
|
||||
impl->displayTransformSetDisplayCC(dt, t);
|
||||
}
|
||||
|
||||
void OCIO_displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *t)
|
||||
{
|
||||
impl->displayTransformSetLinearCC(dt, t);
|
||||
}
|
||||
|
||||
void OCIO_displayTransformRelease(OCIO_DisplayTransformRcPtr *dt)
|
||||
{
|
||||
impl->displayTransformRelease(dt);
|
||||
}
|
||||
|
||||
OCIO_PackedImageDesc *OCIO_createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
|
||||
long chanStrideBytes, long xStrideBytes, long yStrideBytes)
|
||||
{
|
||||
return impl->createOCIO_PackedImageDesc(data, width, height, numChannels, chanStrideBytes, xStrideBytes, yStrideBytes);
|
||||
}
|
||||
|
||||
void OCIO_OCIO_PackedImageDescRelease(OCIO_PackedImageDesc* id)
|
||||
{
|
||||
impl->OCIO_PackedImageDescRelease(id);
|
||||
}
|
||||
|
||||
OCIO_ExponentTransformRcPtr *OCIO_createExponentTransform(void)
|
||||
{
|
||||
return impl->createExponentTransform();
|
||||
}
|
||||
|
||||
void OCIO_exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent)
|
||||
{
|
||||
impl->exponentTransformSetValue(et, exponent);
|
||||
}
|
||||
|
||||
void OCIO_exponentTransformRelease(OCIO_ExponentTransformRcPtr *et)
|
||||
{
|
||||
impl->exponentTransformRelease(et);
|
||||
}
|
||||
|
||||
OCIO_MatrixTransformRcPtr *OCIO_createMatrixTransform(void)
|
||||
{
|
||||
return impl->createMatrixTransform();
|
||||
}
|
||||
|
||||
void OCIO_matrixTransformSetValue(OCIO_MatrixTransformRcPtr *mt, const float *m44, const float *offset4)
|
||||
{
|
||||
impl->matrixTransformSetValue(mt, m44, offset4);
|
||||
}
|
||||
|
||||
void OCIO_matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt)
|
||||
{
|
||||
impl->matrixTransformRelease(mt);
|
||||
}
|
||||
|
||||
void OCIO_matrixTransformScale(float * m44, float * offset4, const float *scale4f)
|
||||
{
|
||||
impl->matrixTransformScale(m44, offset4, scale4f);
|
||||
}
|
||||
@@ -1,525 +0,0 @@
|
||||
/*
|
||||
* ***** 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);
|
||||
}
|
||||
@@ -1,380 +0,0 @@
|
||||
/*
|
||||
* ***** 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 *)
|
||||
{
|
||||
}
|
||||
|
||||
544
intern/opencolorio/ocio_impl.cc
Normal file
544
intern/opencolorio/ocio_impl.cc
Normal file
@@ -0,0 +1,544 @@
|
||||
/*
|
||||
* ***** 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>
|
||||
|
||||
using namespace OCIO_NAMESPACE;
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "ocio_impl.h"
|
||||
|
||||
#if !defined(WITH_ASSERT_ABORT)
|
||||
# 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) if(what) { (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());
|
||||
}
|
||||
|
||||
OCIO_ConstConfigRcPtr *OCIOImpl::getCurrentConfig(void)
|
||||
{
|
||||
ConstConfigRcPtr *config = MEM_NEW(ConstConfigRcPtr);
|
||||
|
||||
try {
|
||||
*config = GetCurrentConfig();
|
||||
|
||||
if (*config)
|
||||
return (OCIO_ConstConfigRcPtr *) config;
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
MEM_DELETE(config, ConstConfigRcPtr);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void OCIOImpl::setCurrentConfig(const OCIO_ConstConfigRcPtr *config)
|
||||
{
|
||||
try {
|
||||
SetCurrentConfig(*(ConstConfigRcPtr *) config);
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
OCIO_ConstConfigRcPtr *OCIOImpl::configCreateFromEnv(void)
|
||||
{
|
||||
ConstConfigRcPtr *config = MEM_NEW(ConstConfigRcPtr);
|
||||
|
||||
try {
|
||||
*config = Config::CreateFromEnv();
|
||||
|
||||
if (*config)
|
||||
return (OCIO_ConstConfigRcPtr *) config;
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
MEM_DELETE(config, ConstConfigRcPtr);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
OCIO_ConstConfigRcPtr *OCIOImpl::configCreateFromFile(const char *filename)
|
||||
{
|
||||
ConstConfigRcPtr *config = MEM_NEW(ConstConfigRcPtr);
|
||||
|
||||
try {
|
||||
*config = Config::CreateFromFile(filename);
|
||||
|
||||
if (*config)
|
||||
return (OCIO_ConstConfigRcPtr *) config;
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
MEM_DELETE(config, ConstConfigRcPtr);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void OCIOImpl::configRelease(OCIO_ConstConfigRcPtr *config)
|
||||
{
|
||||
MEM_DELETE((ConstConfigRcPtr *) config, ConstConfigRcPtr);
|
||||
}
|
||||
|
||||
int OCIOImpl::configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config)
|
||||
{
|
||||
try {
|
||||
return (*(ConstConfigRcPtr *) config)->getNumColorSpaces();
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *OCIOImpl::configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index)
|
||||
{
|
||||
try {
|
||||
return (*(ConstConfigRcPtr *) config)->getColorSpaceNameByIndex(index);
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
OCIO_ConstColorSpaceRcPtr *OCIOImpl::configGetColorSpace(OCIO_ConstConfigRcPtr *config, const char *name)
|
||||
{
|
||||
ConstColorSpaceRcPtr *cs = MEM_NEW(ConstColorSpaceRcPtr);
|
||||
|
||||
try {
|
||||
*cs = (*(ConstConfigRcPtr *) config)->getColorSpace(name);
|
||||
|
||||
if (*cs)
|
||||
return (OCIO_ConstColorSpaceRcPtr *) cs;
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
MEM_DELETE(cs, ConstColorSpaceRcPtr);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int OCIOImpl::configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name)
|
||||
{
|
||||
try {
|
||||
return (*(ConstConfigRcPtr *) config)->getIndexForColorSpace(name);
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char *OCIOImpl::configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config)
|
||||
{
|
||||
try {
|
||||
return (*(ConstConfigRcPtr *) config)->getDefaultDisplay();
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int OCIOImpl::configGetNumDisplays(OCIO_ConstConfigRcPtr* config)
|
||||
{
|
||||
try {
|
||||
return (*(ConstConfigRcPtr *) config)->getNumDisplays();
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *OCIOImpl::configGetDisplay(OCIO_ConstConfigRcPtr *config, int index)
|
||||
{
|
||||
try {
|
||||
return (*(ConstConfigRcPtr *) config)->getDisplay(index);
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *OCIOImpl::configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display)
|
||||
{
|
||||
try {
|
||||
return (*(ConstConfigRcPtr *) config)->getDefaultView(display);
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int OCIOImpl::configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display)
|
||||
{
|
||||
try {
|
||||
return (*(ConstConfigRcPtr *) config)->getNumViews(display);
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *OCIOImpl::configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index)
|
||||
{
|
||||
try {
|
||||
return (*(ConstConfigRcPtr *) config)->getView(display, index);
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *OCIOImpl::configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view)
|
||||
{
|
||||
try {
|
||||
return (*(ConstConfigRcPtr *) config)->getDisplayColorSpaceName(display, view);
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int OCIOImpl::colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs_)
|
||||
{
|
||||
ConstColorSpaceRcPtr *cs = (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;
|
||||
}
|
||||
|
||||
int OCIOImpl::colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
return (*(ConstColorSpaceRcPtr *) cs)->isData();
|
||||
}
|
||||
|
||||
void OCIOImpl::colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
MEM_DELETE((ConstColorSpaceRcPtr *) cs, ConstColorSpaceRcPtr);
|
||||
}
|
||||
|
||||
OCIO_ConstProcessorRcPtr *OCIOImpl::configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config, const char *srcName, const char *dstName)
|
||||
{
|
||||
ConstProcessorRcPtr *p = MEM_NEW(ConstProcessorRcPtr);
|
||||
|
||||
try {
|
||||
*p = (*(ConstConfigRcPtr *) config)->getProcessor(srcName, dstName);
|
||||
|
||||
if (*p)
|
||||
return (OCIO_ConstProcessorRcPtr *) p;
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
MEM_DELETE(p, ConstProcessorRcPtr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
OCIO_ConstProcessorRcPtr *OCIOImpl::configGetProcessor(OCIO_ConstConfigRcPtr *config, OCIO_ConstTransformRcPtr *transform)
|
||||
{
|
||||
ConstProcessorRcPtr *p = MEM_NEW(ConstProcessorRcPtr);
|
||||
|
||||
try {
|
||||
*p = (*(ConstConfigRcPtr *) config)->getProcessor(*(ConstTransformRcPtr *) transform);
|
||||
|
||||
if (*p)
|
||||
return (OCIO_ConstProcessorRcPtr *) p;
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
MEM_DELETE(p, ConstProcessorRcPtr);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void OCIOImpl::processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img)
|
||||
{
|
||||
try {
|
||||
(*(ConstProcessorRcPtr *) processor)->apply(*(PackedImageDesc *) img);
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOImpl::processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img_)
|
||||
{
|
||||
try {
|
||||
PackedImageDesc *img = (PackedImageDesc *) img_;
|
||||
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);
|
||||
|
||||
processorApplyRGBA_predivide(processor, pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
(*(ConstProcessorRcPtr *) processor)->apply(*img);
|
||||
}
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOImpl::processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel)
|
||||
{
|
||||
(*(ConstProcessorRcPtr *) processor)->applyRGB(pixel);
|
||||
}
|
||||
|
||||
void OCIOImpl::processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel)
|
||||
{
|
||||
(*(ConstProcessorRcPtr *) processor)->applyRGBA(pixel);
|
||||
}
|
||||
|
||||
void OCIOImpl::processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel)
|
||||
{
|
||||
if (pixel[3] == 1.0f || pixel[3] == 0.0f) {
|
||||
(*(ConstProcessorRcPtr *) 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;
|
||||
|
||||
(*(ConstProcessorRcPtr *) processor)->applyRGBA(pixel);
|
||||
|
||||
pixel[0] *= alpha;
|
||||
pixel[1] *= alpha;
|
||||
pixel[2] *= alpha;
|
||||
}
|
||||
}
|
||||
|
||||
void OCIOImpl::processorRelease(OCIO_ConstProcessorRcPtr *p)
|
||||
{
|
||||
p->~OCIO_ConstProcessorRcPtr();
|
||||
MEM_freeN(p);
|
||||
}
|
||||
|
||||
const char *OCIOImpl::colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
return (*(ConstColorSpaceRcPtr *) cs)->getName();
|
||||
}
|
||||
|
||||
const char *OCIOImpl::colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
return (*(ConstColorSpaceRcPtr *) cs)->getDescription();
|
||||
}
|
||||
|
||||
const char *OCIOImpl::colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs)
|
||||
{
|
||||
return (*(ConstColorSpaceRcPtr *)cs)->getFamily();
|
||||
}
|
||||
|
||||
OCIO_DisplayTransformRcPtr *OCIOImpl::createDisplayTransform(void)
|
||||
{
|
||||
DisplayTransformRcPtr *dt = MEM_NEW(DisplayTransformRcPtr);
|
||||
|
||||
*dt = DisplayTransform::Create();
|
||||
|
||||
return (OCIO_DisplayTransformRcPtr *) dt;
|
||||
}
|
||||
|
||||
void OCIOImpl::displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name)
|
||||
{
|
||||
(*(DisplayTransformRcPtr *) dt)->setInputColorSpaceName(name);
|
||||
}
|
||||
|
||||
void OCIOImpl::displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name)
|
||||
{
|
||||
(*(DisplayTransformRcPtr *) dt)->setDisplay(name);
|
||||
}
|
||||
|
||||
void OCIOImpl::displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name)
|
||||
{
|
||||
(*(DisplayTransformRcPtr *) dt)->setView(name);
|
||||
}
|
||||
|
||||
void OCIOImpl::displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *t)
|
||||
{
|
||||
(*(DisplayTransformRcPtr *) dt)->setDisplayCC(* (ConstTransformRcPtr *) t);
|
||||
}
|
||||
|
||||
void OCIOImpl::displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *t)
|
||||
{
|
||||
(*(DisplayTransformRcPtr *) dt)->setLinearCC(*(ConstTransformRcPtr *) t);
|
||||
}
|
||||
|
||||
void OCIOImpl::displayTransformRelease(OCIO_DisplayTransformRcPtr *dt)
|
||||
{
|
||||
MEM_DELETE((DisplayTransformRcPtr *) dt, DisplayTransformRcPtr);
|
||||
}
|
||||
|
||||
OCIO_PackedImageDesc *OCIOImpl::createOCIO_PackedImageDesc(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 (OCIO_PackedImageDesc *) id;
|
||||
}
|
||||
catch (Exception &exception) {
|
||||
OCIO_reportException(exception);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void OCIOImpl::OCIO_PackedImageDescRelease(OCIO_PackedImageDesc* id)
|
||||
{
|
||||
MEM_DELETE((PackedImageDesc *) id, PackedImageDesc);
|
||||
}
|
||||
|
||||
OCIO_ExponentTransformRcPtr *OCIOImpl::createExponentTransform(void)
|
||||
{
|
||||
ExponentTransformRcPtr *et = MEM_NEW(ExponentTransformRcPtr);
|
||||
|
||||
*et = ExponentTransform::Create();
|
||||
|
||||
return (OCIO_ExponentTransformRcPtr *) et;
|
||||
}
|
||||
|
||||
void OCIOImpl::exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent)
|
||||
{
|
||||
(*(ExponentTransformRcPtr *) et)->setValue(exponent);
|
||||
}
|
||||
|
||||
void OCIOImpl::exponentTransformRelease(OCIO_ExponentTransformRcPtr *et)
|
||||
{
|
||||
MEM_DELETE((ExponentTransformRcPtr *) et, ExponentTransformRcPtr);
|
||||
}
|
||||
|
||||
OCIO_MatrixTransformRcPtr *OCIOImpl::createMatrixTransform(void)
|
||||
{
|
||||
MatrixTransformRcPtr *mt = MEM_NEW(MatrixTransformRcPtr);
|
||||
|
||||
*mt = MatrixTransform::Create();
|
||||
|
||||
return (OCIO_MatrixTransformRcPtr *) mt;
|
||||
}
|
||||
|
||||
void OCIOImpl::matrixTransformSetValue(OCIO_MatrixTransformRcPtr *mt, const float *m44, const float *offset4)
|
||||
{
|
||||
(*(MatrixTransformRcPtr *) mt)->setValue(m44, offset4);
|
||||
}
|
||||
|
||||
void OCIOImpl::matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt)
|
||||
{
|
||||
MEM_DELETE((MatrixTransformRcPtr *) mt, MatrixTransformRcPtr);
|
||||
}
|
||||
|
||||
void OCIOImpl::matrixTransformScale(float * m44, float * offset4, const float *scale4f)
|
||||
{
|
||||
MatrixTransform::Scale(m44, offset4, scale4f);
|
||||
}
|
||||
240
intern/opencolorio/ocio_impl.h
Normal file
240
intern/opencolorio/ocio_impl.h
Normal file
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* ***** 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): Sergey Sharybin
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#ifndef __OCIO_IMPL_H__
|
||||
#define __OCIO_IMPL_H__
|
||||
|
||||
#include "ocio_capi.h"
|
||||
|
||||
class IOCIOImpl {
|
||||
public:
|
||||
virtual ~IOCIOImpl() {};
|
||||
|
||||
virtual OCIO_ConstConfigRcPtr *getCurrentConfig(void) = 0;
|
||||
virtual void setCurrentConfig(const OCIO_ConstConfigRcPtr *config) = 0;
|
||||
|
||||
virtual OCIO_ConstConfigRcPtr *configCreateFromEnv(void) = 0;
|
||||
virtual OCIO_ConstConfigRcPtr *configCreateFromFile(const char* filename) = 0;
|
||||
|
||||
virtual void configRelease(OCIO_ConstConfigRcPtr *config) = 0;
|
||||
|
||||
virtual int configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config) = 0;
|
||||
virtual const char *configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index) = 0;
|
||||
virtual OCIO_ConstColorSpaceRcPtr *configGetColorSpace(OCIO_ConstConfigRcPtr *config, const char *name) = 0;
|
||||
virtual int configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name) = 0;
|
||||
|
||||
virtual int colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs) = 0;
|
||||
virtual int colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs) = 0;
|
||||
|
||||
virtual void colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs) = 0;
|
||||
|
||||
virtual const char *configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config) = 0;
|
||||
virtual int configGetNumDisplays(OCIO_ConstConfigRcPtr *config) = 0;
|
||||
virtual const char *configGetDisplay(OCIO_ConstConfigRcPtr *config, int index) = 0;
|
||||
virtual const char *configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display) = 0;
|
||||
virtual int configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display) = 0;
|
||||
virtual const char *configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index) = 0;
|
||||
virtual const char *configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view) = 0;
|
||||
|
||||
virtual OCIO_ConstProcessorRcPtr *configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config, const char *srcName, const char *dstName) = 0;
|
||||
virtual OCIO_ConstProcessorRcPtr *configGetProcessor(OCIO_ConstConfigRcPtr *config, OCIO_ConstTransformRcPtr *transform) = 0;
|
||||
|
||||
virtual void processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img) = 0;
|
||||
virtual void processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img) = 0;
|
||||
virtual void processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel) = 0;
|
||||
virtual void processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel) = 0;
|
||||
virtual void processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel) = 0;
|
||||
|
||||
virtual void processorRelease(OCIO_ConstProcessorRcPtr *p) = 0;
|
||||
|
||||
virtual const char *colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs) = 0;
|
||||
virtual const char *colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs) = 0;
|
||||
virtual const char *colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs) = 0;
|
||||
|
||||
virtual OCIO_DisplayTransformRcPtr *createDisplayTransform(void) = 0;
|
||||
virtual void displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name) = 0;
|
||||
virtual void displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name) = 0;
|
||||
virtual void displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name) = 0;
|
||||
virtual void displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et) = 0;
|
||||
virtual void displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et) = 0;
|
||||
virtual void displayTransformRelease(OCIO_DisplayTransformRcPtr *dt) = 0;
|
||||
|
||||
virtual OCIO_PackedImageDesc *createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
|
||||
long chanStrideBytes, long xStrideBytes, long yStrideBytes) = 0;
|
||||
|
||||
virtual void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p) = 0;
|
||||
|
||||
virtual OCIO_ExponentTransformRcPtr *createExponentTransform(void) = 0;
|
||||
virtual void exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent) = 0;
|
||||
virtual void exponentTransformRelease(OCIO_ExponentTransformRcPtr *et) = 0;
|
||||
|
||||
virtual OCIO_MatrixTransformRcPtr *createMatrixTransform(void) = 0;
|
||||
virtual void matrixTransformSetValue(OCIO_MatrixTransformRcPtr *et, const float *m44, const float *offset4) = 0;
|
||||
virtual void matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt) = 0;
|
||||
|
||||
virtual void matrixTransformScale(float * m44, float * offset4, const float * scale4) = 0;
|
||||
};
|
||||
|
||||
class FallbackImpl : public IOCIOImpl {
|
||||
public:
|
||||
FallbackImpl() {};
|
||||
|
||||
OCIO_ConstConfigRcPtr *getCurrentConfig(void);
|
||||
void setCurrentConfig(const OCIO_ConstConfigRcPtr *config);
|
||||
|
||||
OCIO_ConstConfigRcPtr *configCreateFromEnv(void);
|
||||
OCIO_ConstConfigRcPtr *configCreateFromFile(const char* filename);
|
||||
|
||||
void configRelease(OCIO_ConstConfigRcPtr *config);
|
||||
|
||||
int configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config);
|
||||
const char *configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index);
|
||||
OCIO_ConstColorSpaceRcPtr *configGetColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
|
||||
int configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
|
||||
|
||||
int colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs);
|
||||
int colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs);
|
||||
|
||||
void colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs);
|
||||
|
||||
const char *configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config);
|
||||
int configGetNumDisplays(OCIO_ConstConfigRcPtr *config);
|
||||
const char *configGetDisplay(OCIO_ConstConfigRcPtr *config, int index);
|
||||
const char *configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display);
|
||||
int configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display);
|
||||
const char *configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index);
|
||||
const char *configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view);
|
||||
|
||||
OCIO_ConstProcessorRcPtr *configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config, const char *srcName, const char *dstName);
|
||||
OCIO_ConstProcessorRcPtr *configGetProcessor(OCIO_ConstConfigRcPtr *config, OCIO_ConstTransformRcPtr *transform);
|
||||
|
||||
void processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
|
||||
void processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
|
||||
void processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel);
|
||||
void processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel);
|
||||
void processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel);
|
||||
|
||||
void processorRelease(OCIO_ConstProcessorRcPtr *p);
|
||||
|
||||
const char *colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs);
|
||||
const char *colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs);
|
||||
const char *colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs);
|
||||
|
||||
OCIO_DisplayTransformRcPtr *createDisplayTransform(void);
|
||||
void displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name);
|
||||
void displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name);
|
||||
void displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name);
|
||||
void displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
|
||||
void displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
|
||||
void displayTransformRelease(OCIO_DisplayTransformRcPtr *dt);
|
||||
|
||||
OCIO_PackedImageDesc *createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
|
||||
long chanStrideBytes, long xStrideBytes, long yStrideBytes);
|
||||
|
||||
void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p);
|
||||
|
||||
OCIO_ExponentTransformRcPtr *createExponentTransform(void);
|
||||
void exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent);
|
||||
void exponentTransformRelease(OCIO_ExponentTransformRcPtr *et);
|
||||
|
||||
OCIO_MatrixTransformRcPtr *createMatrixTransform(void);
|
||||
void matrixTransformSetValue(OCIO_MatrixTransformRcPtr *et, const float *m44, const float *offset4);
|
||||
void matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt);
|
||||
|
||||
void matrixTransformScale(float * m44, float * offset4, const float * scale4);
|
||||
};
|
||||
|
||||
#ifdef WITH_OCIO
|
||||
class OCIOImpl : public IOCIOImpl {
|
||||
public:
|
||||
OCIOImpl() {};
|
||||
|
||||
OCIO_ConstConfigRcPtr *getCurrentConfig(void);
|
||||
void setCurrentConfig(const OCIO_ConstConfigRcPtr *config);
|
||||
|
||||
OCIO_ConstConfigRcPtr *configCreateFromEnv(void);
|
||||
OCIO_ConstConfigRcPtr *configCreateFromFile(const char* filename);
|
||||
|
||||
void configRelease(OCIO_ConstConfigRcPtr *config);
|
||||
|
||||
int configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config);
|
||||
const char *configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index);
|
||||
OCIO_ConstColorSpaceRcPtr *configGetColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
|
||||
int configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
|
||||
|
||||
int colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs);
|
||||
int colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs);
|
||||
|
||||
void colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs);
|
||||
|
||||
const char *configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config);
|
||||
int configGetNumDisplays(OCIO_ConstConfigRcPtr *config);
|
||||
const char *configGetDisplay(OCIO_ConstConfigRcPtr *config, int index);
|
||||
const char *configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display);
|
||||
int configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display);
|
||||
const char *configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index);
|
||||
const char *configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view);
|
||||
|
||||
OCIO_ConstProcessorRcPtr *configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config, const char *srcName, const char *dstName);
|
||||
OCIO_ConstProcessorRcPtr *configGetProcessor(OCIO_ConstConfigRcPtr *config, OCIO_ConstTransformRcPtr *transform);
|
||||
|
||||
void processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
|
||||
void processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
|
||||
void processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel);
|
||||
void processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel);
|
||||
void processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel);
|
||||
|
||||
void processorRelease(OCIO_ConstProcessorRcPtr *p);
|
||||
|
||||
const char *colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs);
|
||||
const char *colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs);
|
||||
const char *colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs);
|
||||
|
||||
OCIO_DisplayTransformRcPtr *createDisplayTransform(void);
|
||||
void displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name);
|
||||
void displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name);
|
||||
void displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name);
|
||||
void displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
|
||||
void displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt, OCIO_ConstTransformRcPtr *et);
|
||||
void displayTransformRelease(OCIO_DisplayTransformRcPtr *dt);
|
||||
|
||||
OCIO_PackedImageDesc *createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels,
|
||||
long chanStrideBytes, long xStrideBytes, long yStrideBytes);
|
||||
|
||||
void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p);
|
||||
|
||||
OCIO_ExponentTransformRcPtr *createExponentTransform(void);
|
||||
void exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent);
|
||||
void exponentTransformRelease(OCIO_ExponentTransformRcPtr *et);
|
||||
|
||||
OCIO_MatrixTransformRcPtr *createMatrixTransform(void);
|
||||
void matrixTransformSetValue(OCIO_MatrixTransformRcPtr *et, const float *m44, const float *offset4);
|
||||
void matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt);
|
||||
|
||||
void matrixTransformScale(float * m44, float * offset4, const float * scale4);
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* OCIO_IMPL_H */
|
||||
Reference in New Issue
Block a user