Blender  V2.93
ocio_capi.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2012 Blender Foundation.
17  * All rights reserved.
18  */
19 
20 #ifndef __OCIO_CAPI_H__
21 #define __OCIO_CAPI_H__
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 typedef struct OCIO_GPUShader OCIO_GPUShader;
28 
29 #define OCIO_DECLARE_HANDLE(name) \
30  typedef struct name##__ { \
31  int unused; \
32  } * name
33 
34 #define OCIO_ROLE_DATA "data"
35 #define OCIO_ROLE_SCENE_LINEAR "scene_linear"
36 #define OCIO_ROLE_COLOR_PICKING "color_picking"
37 #define OCIO_ROLE_TEXTURE_PAINT "texture_paint"
38 #define OCIO_ROLE_DEFAULT_BYTE "default_byte"
39 #define OCIO_ROLE_DEFAULT_FLOAT "default_float"
40 #define OCIO_ROLE_DEFAULT_SEQUENCER "default_sequencer"
41 
42 OCIO_DECLARE_HANDLE(OCIO_ConstConfigRcPtr);
43 OCIO_DECLARE_HANDLE(OCIO_ConstColorSpaceRcPtr);
44 OCIO_DECLARE_HANDLE(OCIO_ConstProcessorRcPtr);
45 OCIO_DECLARE_HANDLE(OCIO_ConstCPUProcessorRcPtr);
46 OCIO_DECLARE_HANDLE(OCIO_ConstContextRcPtr);
47 OCIO_DECLARE_HANDLE(OCIO_PackedImageDesc);
48 OCIO_DECLARE_HANDLE(OCIO_ConstLookRcPtr);
49 
50 /* Standard XYZ to linear sRGB transform, for fallback. */
51 static const float OCIO_XYZ_TO_LINEAR_SRGB[3][3] = {{3.2404542f, -0.9692660f, 0.0556434f},
52  {-1.5371385f, 1.8760108f, -0.2040259f},
53  {-0.4985314f, 0.0415560f, 1.0572252f}};
54 
55 /* This structure is used to pass curve mapping settings from
56  * blender's DNA structure stored in view transform settings
57  * to a generic OpenColorIO C-API.
58  */
59 typedef struct OCIO_CurveMappingSettings {
60  /* This is a LUT which contain values for all 4 curve mapping tables
61  * (combined, R, G and B).
62  *
63  * Element I for table T is stored at I * 4 + T element of this LUT.
64  *
65  * This array is usually returned by curvemapping_table_RGBA().
66  */
67  float *lut;
68 
69  /* Size of single curve mapping table, 1/4 size of lut array. */
70  int lut_size;
71 
72  /* Extend extrapolation flags for all the tables.
73  * if use_extend_extrapolate != 0 means extrapolation for
74  * curve.
75  */
77 
78  /* Minimal X value of the curve mapping tables. */
79  float mintable[4];
80 
81  /* Per curve mapping table range. */
82  float range[4];
83 
84  /* Lower extension value, stored as per-component arrays. */
85  float ext_in_x[4], ext_in_y[4];
86 
87  /* Higher extension value, stored as per-component arrays. */
88  float ext_out_x[4], ext_out_y[4];
89 
90  /* First points of the tables, both X and Y values.
91  * Needed for easier and faster access when extrapolating.
92  */
93  float first_x[4], first_y[4];
94 
95  /* Last points of the tables, both X and Y values.
96  * Needed for easier and faster access when extrapolating.
97  */
98  float last_x[4], last_y[4];
99 
100  /* Premultiplication settings: black level and scale to match
101  * with white level.
102  */
103  float black[3], bwmul[3];
104 
105  /* Cache id of the original curve mapping, used to detect when
106  * upload of new settings to GPU is needed.
107  */
108  size_t cache_id;
110 
111 void OCIO_init(void);
112 void OCIO_exit(void);
113 
114 OCIO_ConstConfigRcPtr *OCIO_getCurrentConfig(void);
115 void OCIO_setCurrentConfig(const OCIO_ConstConfigRcPtr *config);
116 
117 OCIO_ConstConfigRcPtr *OCIO_configCreateFromEnv(void);
118 OCIO_ConstConfigRcPtr *OCIO_configCreateFromFile(const char *filename);
119 OCIO_ConstConfigRcPtr *OCIO_configCreateFallback(void);
120 
121 void OCIO_configRelease(OCIO_ConstConfigRcPtr *config);
122 
123 int OCIO_configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config);
124 const char *OCIO_configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index);
125 OCIO_ConstColorSpaceRcPtr *OCIO_configGetColorSpace(OCIO_ConstConfigRcPtr *config,
126  const char *name);
127 int OCIO_configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
128 
129 int OCIO_colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs);
130 int OCIO_colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs);
131 void OCIO_colorSpaceIsBuiltin(OCIO_ConstConfigRcPtr *config,
132  OCIO_ConstColorSpaceRcPtr *cs,
133  bool *is_scene_linear,
134  bool *is_srgb);
135 
136 void OCIO_colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs);
137 
138 const char *OCIO_configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config);
139 int OCIO_configGetNumDisplays(OCIO_ConstConfigRcPtr *config);
140 const char *OCIO_configGetDisplay(OCIO_ConstConfigRcPtr *config, int index);
141 const char *OCIO_configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display);
142 int OCIO_configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display);
143 const char *OCIO_configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index);
144 const char *OCIO_configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config,
145  const char *display,
146  const char *view);
147 
148 void OCIO_configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb);
149 void OCIO_configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3]);
150 
151 int OCIO_configGetNumLooks(OCIO_ConstConfigRcPtr *config);
152 const char *OCIO_configGetLookNameByIndex(OCIO_ConstConfigRcPtr *config, int index);
153 OCIO_ConstLookRcPtr *OCIO_configGetLook(OCIO_ConstConfigRcPtr *config, const char *name);
154 
155 const char *OCIO_lookGetProcessSpace(OCIO_ConstLookRcPtr *look);
156 void OCIO_lookRelease(OCIO_ConstLookRcPtr *look);
157 
158 OCIO_ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config,
159  const char *srcName,
160  const char *dstName);
161 void OCIO_processorRelease(OCIO_ConstProcessorRcPtr *cpu_processor);
162 
163 OCIO_ConstCPUProcessorRcPtr *OCIO_processorGetCPUProcessor(OCIO_ConstProcessorRcPtr *processor);
164 void OCIO_cpuProcessorApply(OCIO_ConstCPUProcessorRcPtr *cpu_processor, OCIO_PackedImageDesc *img);
165 void OCIO_cpuProcessorApply_predivide(OCIO_ConstCPUProcessorRcPtr *cpu_processor,
166  OCIO_PackedImageDesc *img);
167 void OCIO_cpuProcessorApplyRGB(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel);
168 void OCIO_cpuProcessorApplyRGBA(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel);
169 void OCIO_cpuProcessorApplyRGBA_predivide(OCIO_ConstCPUProcessorRcPtr *cpu_processor,
170  float *pixel);
171 void OCIO_cpuProcessorRelease(OCIO_ConstCPUProcessorRcPtr *processor);
172 
173 const char *OCIO_colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs);
174 const char *OCIO_colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs);
175 const char *OCIO_colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs);
176 
177 OCIO_ConstProcessorRcPtr *OCIO_createDisplayProcessor(OCIO_ConstConfigRcPtr *config,
178  const char *input,
179  const char *view,
180  const char *display,
181  const char *look,
182  const float scale,
183  const float exponent);
184 
185 OCIO_PackedImageDesc *OCIO_createOCIO_PackedImageDesc(float *data,
186  long width,
187  long height,
188  long numChannels,
189  long chanStrideBytes,
190  long xStrideBytes,
191  long yStrideBytes);
192 
193 void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p);
194 
195 bool OCIO_supportGPUShader(void);
196 bool OCIO_gpuDisplayShaderBind(OCIO_ConstConfigRcPtr *config,
197  const char *input,
198  const char *view,
199  const char *display,
200  const char *look,
201  OCIO_CurveMappingSettings *curve_mapping_settings,
202  const float scale,
203  const float exponent,
204  const float dither,
205  const bool use_predivide,
206  const bool use_overlay);
207 void OCIO_gpuDisplayShaderUnbind(void);
208 void OCIO_gpuCacheFree(void);
209 
210 const char *OCIO_getVersionString(void);
211 int OCIO_getVersionHex(void);
212 
213 #ifdef __cplusplus
214 }
215 #endif
216 
217 #endif /* OCIO_CAPI_H */
static AppView * view
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
CCL_NAMESPACE_BEGIN ccl_device float3 xyz_to_rgb(KernelGlobals *kg, float3 xyz)
Definition: kernel_color.h:24
void OCIO_processorRelease(OCIO_ConstProcessorRcPtr *cpu_processor)
Definition: ocio_capi.cc:197
void OCIO_cpuProcessorApplyRGB(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel)
Definition: ocio_capi.cc:218
void OCIO_cpuProcessorApplyRGBA(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel)
Definition: ocio_capi.cc:223
const char * OCIO_configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display)
Definition: ocio_capi.cc:110
void OCIO_cpuProcessorApplyRGBA_predivide(OCIO_ConstCPUProcessorRcPtr *cpu_processor, float *pixel)
Definition: ocio_capi.cc:228
bool OCIO_supportGPUShader(void)
Definition: ocio_capi.cc:281
const char * OCIO_configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index)
Definition: ocio_capi.cc:79
OCIO_ConstCPUProcessorRcPtr * OCIO_processorGetCPUProcessor(OCIO_ConstProcessorRcPtr *processor)
Definition: ocio_capi.cc:202
OCIO_ConstConfigRcPtr * OCIO_getCurrentConfig(void)
Definition: ocio_capi.cc:41
const char * OCIO_colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs)
Definition: ocio_capi.cc:248
void OCIO_lookRelease(OCIO_ConstLookRcPtr *look)
Definition: ocio_capi.cc:162
const char * OCIO_lookGetProcessSpace(OCIO_ConstLookRcPtr *look)
Definition: ocio_capi.cc:157
void OCIO_cpuProcessorApply(OCIO_ConstCPUProcessorRcPtr *cpu_processor, OCIO_PackedImageDesc *img)
Definition: ocio_capi.cc:207
void OCIO_gpuCacheFree(void)
Definition: ocio_capi.cc:316
void OCIO_colorSpaceIsBuiltin(OCIO_ConstConfigRcPtr *config, OCIO_ConstColorSpaceRcPtr *cs, bool *is_scene_linear, bool *is_srgb)
Definition: ocio_capi.cc:177
void OCIO_colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs)
Definition: ocio_capi.cc:185
const char * OCIO_configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index)
Definition: ocio_capi.cc:120
OCIO_PackedImageDesc * OCIO_createOCIO_PackedImageDesc(float *data, long width, long height, long numChannels, long chanStrideBytes, long xStrideBytes, long yStrideBytes)
Definition: ocio_capi.cc:264
const char * OCIO_colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs)
Definition: ocio_capi.cc:238
void OCIO_init(void)
Definition: ocio_capi.cc:26
const char * OCIO_configGetLookNameByIndex(OCIO_ConstConfigRcPtr *config, int index)
Definition: ocio_capi.cc:147
void OCIO_cpuProcessorApply_predivide(OCIO_ConstCPUProcessorRcPtr *cpu_processor, OCIO_PackedImageDesc *img)
Definition: ocio_capi.cc:212
void OCIO_setCurrentConfig(const OCIO_ConstConfigRcPtr *config)
Definition: ocio_capi.cc:54
OCIO_ConstConfigRcPtr * OCIO_configCreateFallback(void)
Definition: ocio_capi.cc:46
int OCIO_configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config)
Definition: ocio_capi.cc:74
void OCIO_gpuDisplayShaderUnbind(void)
Definition: ocio_capi.cc:311
void OCIO_configRelease(OCIO_ConstConfigRcPtr *config)
Definition: ocio_capi.cc:69
OCIO_ConstColorSpaceRcPtr * OCIO_configGetColorSpace(OCIO_ConstConfigRcPtr *config, const char *name)
Definition: ocio_capi.cc:84
OCIO_ConstProcessorRcPtr * OCIO_createDisplayProcessor(OCIO_ConstConfigRcPtr *config, const char *input, const char *view, const char *display, const char *look, const float scale, const float exponent)
Definition: ocio_capi.cc:253
int OCIO_configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display)
Definition: ocio_capi.cc:115
void OCIO_cpuProcessorRelease(OCIO_ConstCPUProcessorRcPtr *processor)
Definition: ocio_capi.cc:233
bool OCIO_gpuDisplayShaderBind(OCIO_ConstConfigRcPtr *config, const char *input, const char *view, const char *display, const char *look, OCIO_CurveMappingSettings *curve_mapping_settings, const float scale, const float exponent, const float dither, const bool use_predivide, const bool use_overlay)
Definition: ocio_capi.cc:286
const char * OCIO_colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs)
Definition: ocio_capi.cc:243
int OCIO_configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name)
Definition: ocio_capi.cc:90
struct OCIO_CurveMappingSettings OCIO_CurveMappingSettings
OCIO_ConstProcessorRcPtr * OCIO_configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config, const char *srcName, const char *dstName)
Definition: ocio_capi.cc:190
int OCIO_colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs)
Definition: ocio_capi.cc:167
void OCIO_exit(void)
Definition: ocio_capi.cc:35
OCIO_ConstConfigRcPtr * OCIO_configCreateFromEnv(void)
Definition: ocio_capi.cc:59
void OCIO_configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3])
Definition: ocio_capi.cc:137
int OCIO_getVersionHex(void)
Definition: ocio_capi.cc:326
#define OCIO_DECLARE_HANDLE(name)
Definition: ocio_capi.h:29
static const float OCIO_XYZ_TO_LINEAR_SRGB[3][3]
Definition: ocio_capi.h:51
const char * OCIO_configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view)
Definition: ocio_capi.cc:125
OCIO_ConstLookRcPtr * OCIO_configGetLook(OCIO_ConstConfigRcPtr *config, const char *name)
Definition: ocio_capi.cc:152
const char * OCIO_configGetDisplay(OCIO_ConstConfigRcPtr *config, int index)
Definition: ocio_capi.cc:105
int OCIO_configGetNumLooks(OCIO_ConstConfigRcPtr *config)
Definition: ocio_capi.cc:142
const char * OCIO_configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config)
Definition: ocio_capi.cc:95
void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p)
Definition: ocio_capi.cc:276
const char * OCIO_getVersionString(void)
Definition: ocio_capi.cc:321
OCIO_ConstConfigRcPtr * OCIO_configCreateFromFile(const char *filename)
Definition: ocio_capi.cc:64
int OCIO_configGetNumDisplays(OCIO_ConstConfigRcPtr *config)
Definition: ocio_capi.cc:100
int OCIO_colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs)
Definition: ocio_capi.cc:172
void OCIO_configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb)
Definition: ocio_capi.cc:132