ocio_capi.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. #ifndef __OCIO_CAPI_H__
  20. #define __OCIO_CAPI_H__
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. struct OCIO_GLSLDrawState;
  25. #define OCIO_DECLARE_HANDLE(name) \
  26. typedef struct name##__ { \
  27. int unused; \
  28. } * name
  29. #define OCIO_ROLE_DATA "data"
  30. #define OCIO_ROLE_SCENE_LINEAR "scene_linear"
  31. #define OCIO_ROLE_COLOR_PICKING "color_picking"
  32. #define OCIO_ROLE_TEXTURE_PAINT "texture_paint"
  33. #define OCIO_ROLE_DEFAULT_BYTE "default_byte"
  34. #define OCIO_ROLE_DEFAULT_FLOAT "default_float"
  35. #define OCIO_ROLE_DEFAULT_SEQUENCER "default_sequencer"
  36. OCIO_DECLARE_HANDLE(OCIO_ConstConfigRcPtr);
  37. OCIO_DECLARE_HANDLE(OCIO_ConstColorSpaceRcPtr);
  38. OCIO_DECLARE_HANDLE(OCIO_ConstProcessorRcPtr);
  39. OCIO_DECLARE_HANDLE(OCIO_ConstContextRcPtr);
  40. OCIO_DECLARE_HANDLE(OCIO_PackedImageDesc);
  41. OCIO_DECLARE_HANDLE(OCIO_DisplayTransformRcPtr);
  42. OCIO_DECLARE_HANDLE(OCIO_ConstTransformRcPtr);
  43. OCIO_DECLARE_HANDLE(OCIO_ExponentTransformRcPtr);
  44. OCIO_DECLARE_HANDLE(OCIO_MatrixTransformRcPtr);
  45. OCIO_DECLARE_HANDLE(OCIO_ConstLookRcPtr);
  46. /* Standard XYZ to linear sRGB transform, for fallback. */
  47. static const float OCIO_XYZ_TO_LINEAR_SRGB[3][3] = {{3.2404542f, -0.9692660f, 0.0556434f},
  48. {-1.5371385f, 1.8760108f, -0.2040259f},
  49. {-0.4985314f, 0.0415560f, 1.0572252f}};
  50. /* This structure is used to pass curve mapping settings from
  51. * blender's DNA structure stored in view transform settings
  52. * to a generic OpenColorIO C-API.
  53. */
  54. typedef struct OCIO_CurveMappingSettings {
  55. /* This is a LUT which contain values for all 4 curve mapping tables
  56. * (combined, R, G and B).
  57. *
  58. * Element I for table T is stored at I * 4 + T element of this LUT.
  59. *
  60. * This array is usually returned by curvemapping_table_RGBA().
  61. */
  62. float *lut;
  63. /* Size of single curve mapping table, 1/4 size of lut array. */
  64. int lut_size;
  65. /* Extend extrapolation flags for all the tables.
  66. * if use_extend_extrapolate[T] != 0 means extrapolation for
  67. * table T is needed.
  68. */
  69. int use_extend_extrapolate[4];
  70. /* Minimal X value of the curve mapping tables. */
  71. float mintable[4];
  72. /* Per curve mapping table range. */
  73. float range[4];
  74. /* Lower extension value, stored as per-component arrays. */
  75. float ext_in_x[4], ext_in_y[4];
  76. /* Higher extension value, stored as per-component arrays. */
  77. float ext_out_x[4], ext_out_y[4];
  78. /* First points of the tables, both X and Y values.
  79. * Needed for easier and faster access when extrapolating.
  80. */
  81. float first_x[4], first_y[4];
  82. /* Last points of the tables, both X and Y values.
  83. * Needed for easier and faster access when extrapolating.
  84. */
  85. float last_x[4], last_y[4];
  86. /* Premultiplication settings: black level and scale to match
  87. * with white level.
  88. */
  89. float black[3], bwmul[3];
  90. /* Cache id of the original curve mapping, used to detect when
  91. * upload of new settings to GPU is needed.
  92. */
  93. size_t cache_id;
  94. } OCIO_CurveMappingSettings;
  95. void OCIO_init(void);
  96. void OCIO_exit(void);
  97. OCIO_ConstConfigRcPtr *OCIO_getCurrentConfig(void);
  98. void OCIO_setCurrentConfig(const OCIO_ConstConfigRcPtr *config);
  99. OCIO_ConstConfigRcPtr *OCIO_configCreateFromEnv(void);
  100. OCIO_ConstConfigRcPtr *OCIO_configCreateFromFile(const char *filename);
  101. OCIO_ConstConfigRcPtr *OCIO_configCreateFallback(void);
  102. void OCIO_configRelease(OCIO_ConstConfigRcPtr *config);
  103. int OCIO_configGetNumColorSpaces(OCIO_ConstConfigRcPtr *config);
  104. const char *OCIO_configGetColorSpaceNameByIndex(OCIO_ConstConfigRcPtr *config, int index);
  105. OCIO_ConstColorSpaceRcPtr *OCIO_configGetColorSpace(OCIO_ConstConfigRcPtr *config,
  106. const char *name);
  107. int OCIO_configGetIndexForColorSpace(OCIO_ConstConfigRcPtr *config, const char *name);
  108. int OCIO_colorSpaceIsInvertible(OCIO_ConstColorSpaceRcPtr *cs);
  109. int OCIO_colorSpaceIsData(OCIO_ConstColorSpaceRcPtr *cs);
  110. void OCIO_colorSpaceIsBuiltin(OCIO_ConstConfigRcPtr *config,
  111. OCIO_ConstColorSpaceRcPtr *cs,
  112. bool *is_scene_linear,
  113. bool *is_srgb);
  114. void OCIO_colorSpaceRelease(OCIO_ConstColorSpaceRcPtr *cs);
  115. const char *OCIO_configGetDefaultDisplay(OCIO_ConstConfigRcPtr *config);
  116. int OCIO_configGetNumDisplays(OCIO_ConstConfigRcPtr *config);
  117. const char *OCIO_configGetDisplay(OCIO_ConstConfigRcPtr *config, int index);
  118. const char *OCIO_configGetDefaultView(OCIO_ConstConfigRcPtr *config, const char *display);
  119. int OCIO_configGetNumViews(OCIO_ConstConfigRcPtr *config, const char *display);
  120. const char *OCIO_configGetView(OCIO_ConstConfigRcPtr *config, const char *display, int index);
  121. const char *OCIO_configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config,
  122. const char *display,
  123. const char *view);
  124. void OCIO_configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb);
  125. void OCIO_configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3]);
  126. int OCIO_configGetNumLooks(OCIO_ConstConfigRcPtr *config);
  127. const char *OCIO_configGetLookNameByIndex(OCIO_ConstConfigRcPtr *config, int index);
  128. OCIO_ConstLookRcPtr *OCIO_configGetLook(OCIO_ConstConfigRcPtr *config, const char *name);
  129. const char *OCIO_lookGetProcessSpace(OCIO_ConstLookRcPtr *look);
  130. void OCIO_lookRelease(OCIO_ConstLookRcPtr *look);
  131. OCIO_ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config,
  132. const char *srcName,
  133. const char *dstName);
  134. OCIO_ConstProcessorRcPtr *OCIO_configGetProcessor(OCIO_ConstConfigRcPtr *config,
  135. OCIO_ConstTransformRcPtr *transform);
  136. void OCIO_processorApply(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
  137. void OCIO_processorApply_predivide(OCIO_ConstProcessorRcPtr *processor, OCIO_PackedImageDesc *img);
  138. void OCIO_processorApplyRGB(OCIO_ConstProcessorRcPtr *processor, float *pixel);
  139. void OCIO_processorApplyRGBA(OCIO_ConstProcessorRcPtr *processor, float *pixel);
  140. void OCIO_processorApplyRGBA_predivide(OCIO_ConstProcessorRcPtr *processor, float *pixel);
  141. void OCIO_processorRelease(OCIO_ConstProcessorRcPtr *p);
  142. const char *OCIO_colorSpaceGetName(OCIO_ConstColorSpaceRcPtr *cs);
  143. const char *OCIO_colorSpaceGetDescription(OCIO_ConstColorSpaceRcPtr *cs);
  144. const char *OCIO_colorSpaceGetFamily(OCIO_ConstColorSpaceRcPtr *cs);
  145. OCIO_DisplayTransformRcPtr *OCIO_createDisplayTransform(void);
  146. void OCIO_displayTransformSetInputColorSpaceName(OCIO_DisplayTransformRcPtr *dt, const char *name);
  147. void OCIO_displayTransformSetDisplay(OCIO_DisplayTransformRcPtr *dt, const char *name);
  148. void OCIO_displayTransformSetView(OCIO_DisplayTransformRcPtr *dt, const char *name);
  149. void OCIO_displayTransformSetDisplayCC(OCIO_DisplayTransformRcPtr *dt,
  150. OCIO_ConstTransformRcPtr *et);
  151. void OCIO_displayTransformSetLinearCC(OCIO_DisplayTransformRcPtr *dt,
  152. OCIO_ConstTransformRcPtr *et);
  153. void OCIO_displayTransformSetLooksOverride(OCIO_DisplayTransformRcPtr *dt, const char *looks);
  154. void OCIO_displayTransformSetLooksOverrideEnabled(OCIO_DisplayTransformRcPtr *dt, bool enabled);
  155. void OCIO_displayTransformRelease(OCIO_DisplayTransformRcPtr *dt);
  156. OCIO_PackedImageDesc *OCIO_createOCIO_PackedImageDesc(float *data,
  157. long width,
  158. long height,
  159. long numChannels,
  160. long chanStrideBytes,
  161. long xStrideBytes,
  162. long yStrideBytes);
  163. void OCIO_PackedImageDescRelease(OCIO_PackedImageDesc *p);
  164. OCIO_ExponentTransformRcPtr *OCIO_createExponentTransform(void);
  165. void OCIO_exponentTransformSetValue(OCIO_ExponentTransformRcPtr *et, const float *exponent);
  166. void OCIO_exponentTransformRelease(OCIO_ExponentTransformRcPtr *et);
  167. OCIO_MatrixTransformRcPtr *OCIO_createMatrixTransform(void);
  168. void OCIO_matrixTransformSetValue(OCIO_MatrixTransformRcPtr *mt,
  169. const float *m44,
  170. const float *offset4);
  171. void OCIO_matrixTransformRelease(OCIO_MatrixTransformRcPtr *mt);
  172. void OCIO_matrixTransformScale(float *m44, float *offset4, const float *scale4);
  173. int OCIO_supportGLSLDraw(void);
  174. int OCIO_setupGLSLDraw(struct OCIO_GLSLDrawState **state_r,
  175. OCIO_ConstProcessorRcPtr *processor,
  176. OCIO_CurveMappingSettings *curve_mapping_settings,
  177. float dither,
  178. bool predivide);
  179. void OCIO_finishGLSLDraw(struct OCIO_GLSLDrawState *state);
  180. void OCIO_freeOGLState(struct OCIO_GLSLDrawState *state);
  181. const char *OCIO_getVersionString(void);
  182. int OCIO_getVersionHex(void);
  183. #ifdef __cplusplus
  184. }
  185. #endif
  186. #endif /* OCIO_CAPI_H */