diff options
Diffstat (limited to 'intern')
-rw-r--r-- | intern/opencolorio/fallback_impl.cc | 7 | ||||
-rw-r--r-- | intern/opencolorio/ocio_capi.cc | 5 | ||||
-rw-r--r-- | intern/opencolorio/ocio_capi.h | 8 | ||||
-rw-r--r-- | intern/opencolorio/ocio_impl.cc | 27 | ||||
-rw-r--r-- | intern/opencolorio/ocio_impl.h | 3 |
5 files changed, 50 insertions, 0 deletions
diff --git a/intern/opencolorio/fallback_impl.cc b/intern/opencolorio/fallback_impl.cc index 87629422013..7bf8134b41c 100644 --- a/intern/opencolorio/fallback_impl.cc +++ b/intern/opencolorio/fallback_impl.cc @@ -333,6 +333,13 @@ void FallbackImpl::configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr * /*config*/, rgb[2] = 0.0722f; } +void FallbackImpl::configGetXYZtoRGB(OCIO_ConstConfigRcPtr * /*config*/, + float xyz_to_rgb[3][3]) +{ + /* Default to ITU-BT.709. */ + memcpy(xyz_to_rgb, OCIO_XYZ_TO_LINEAR_SRGB, sizeof(OCIO_XYZ_TO_LINEAR_SRGB)); +} + int FallbackImpl::configGetNumLooks(OCIO_ConstConfigRcPtr * /*config*/) { return 0; diff --git a/intern/opencolorio/ocio_capi.cc b/intern/opencolorio/ocio_capi.cc index 7a0b9faa5fc..25e1b31630c 100644 --- a/intern/opencolorio/ocio_capi.cc +++ b/intern/opencolorio/ocio_capi.cc @@ -137,6 +137,11 @@ void OCIO_configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb) impl->configGetDefaultLumaCoefs(config, rgb); } +void OCIO_configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3]) +{ + impl->configGetXYZtoRGB(config, xyz_to_rgb); +} + int OCIO_configGetNumLooks(OCIO_ConstConfigRcPtr *config) { return impl->configGetNumLooks(config); diff --git a/intern/opencolorio/ocio_capi.h b/intern/opencolorio/ocio_capi.h index 52a86727902..5bed24d64b1 100644 --- a/intern/opencolorio/ocio_capi.h +++ b/intern/opencolorio/ocio_capi.h @@ -54,6 +54,13 @@ OCIO_DECLARE_HANDLE(OCIO_ExponentTransformRcPtr); OCIO_DECLARE_HANDLE(OCIO_MatrixTransformRcPtr); OCIO_DECLARE_HANDLE(OCIO_ConstLookRcPtr); +/* Standard XYZ to linear sRGB transform, for fallback. */ +static const float OCIO_XYZ_TO_LINEAR_SRGB[3][3] = { + {3.2404542f, -0.9692660f, 0.0556434f}, + {-1.5371385f, 1.8760108f, -0.2040259f}, + {-0.4985314f, 0.0415560f, 1.0572252f}}; + + /* This structure is used to pass curve mapping settings from * blender's DNA structure stored in view transform settings * to a generic OpenColorIO C-API. @@ -141,6 +148,7 @@ const char *OCIO_configGetView(OCIO_ConstConfigRcPtr *config, const char *displa const char *OCIO_configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view); void OCIO_configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb); +void OCIO_configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3]); int OCIO_configGetNumLooks(OCIO_ConstConfigRcPtr *config); const char *OCIO_configGetLookNameByIndex(OCIO_ConstConfigRcPtr *config, int index); diff --git a/intern/opencolorio/ocio_impl.cc b/intern/opencolorio/ocio_impl.cc index 4c9115af810..ac167692647 100644 --- a/intern/opencolorio/ocio_impl.cc +++ b/intern/opencolorio/ocio_impl.cc @@ -419,6 +419,33 @@ void OCIOImpl::configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *r } } +void OCIOImpl::configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config_, float xyz_to_rgb[3][3]) +{ + ConstConfigRcPtr config = (*(ConstConfigRcPtr *) config_); + + /* Default to ITU-BT.709 in case no appropriate transform found. */ + memcpy(xyz_to_rgb, OCIO_XYZ_TO_LINEAR_SRGB, sizeof(OCIO_XYZ_TO_LINEAR_SRGB)); + + /* Auto estimate from XYZ and scene_linear roles, assumed to be a linear transform. */ + if(config->hasRole("XYZ") && config->hasRole("scene_linear")) { + ConstProcessorRcPtr to_rgb_processor = config->getProcessor("XYZ", "scene_linear"); + if(to_rgb_processor) { + xyz_to_rgb[0][0] = 1.0f; + xyz_to_rgb[0][1] = 0.0f; + xyz_to_rgb[0][2] = 0.0f; + xyz_to_rgb[1][0] = 0.0f; + xyz_to_rgb[1][1] = 1.0f; + xyz_to_rgb[1][2] = 0.0f; + xyz_to_rgb[2][0] = 0.0f; + xyz_to_rgb[2][1] = 0.0f; + xyz_to_rgb[2][2] = 1.0f; + to_rgb_processor->applyRGB(xyz_to_rgb[0]); + to_rgb_processor->applyRGB(xyz_to_rgb[1]); + to_rgb_processor->applyRGB(xyz_to_rgb[2]); + } + } +} + int OCIOImpl::configGetNumLooks(OCIO_ConstConfigRcPtr *config) { try { diff --git a/intern/opencolorio/ocio_impl.h b/intern/opencolorio/ocio_impl.h index f086bbb1a26..4e844584bca 100644 --- a/intern/opencolorio/ocio_impl.h +++ b/intern/opencolorio/ocio_impl.h @@ -59,6 +59,7 @@ public: virtual const char *configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view) = 0; virtual void configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb) = 0; + virtual void configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3]) = 0; virtual int configGetNumLooks(OCIO_ConstConfigRcPtr *config) = 0; virtual const char *configGetLookNameByIndex(OCIO_ConstConfigRcPtr *config, int index) = 0; @@ -148,6 +149,7 @@ public: const char *configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view); void configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb); + void configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3]); int configGetNumLooks(OCIO_ConstConfigRcPtr *config); const char *configGetLookNameByIndex(OCIO_ConstConfigRcPtr *config, int index); @@ -238,6 +240,7 @@ public: const char *configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *display, const char *view); void configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb); + void configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3]); int configGetNumLooks(OCIO_ConstConfigRcPtr *config); const char *configGetLookNameByIndex(OCIO_ConstConfigRcPtr *config, int index); |