Color Management: re-implement OCIO-less build configuration
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 14 Sep 2012 14:37:00 +0000 (14:37 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 14 Sep 2012 14:37:00 +0000 (14:37 +0000)
Use OCIO stub file with hardcoded displays, views and color spaces.

Intended to behave in the same way as old implementation, just it's
now more clear code with much fewer ifdef checks.

Also should make it possible to get rid of ibuf's profile flag.

Thanks Brecht van Lommel for this patch!

intern/CMakeLists.txt
intern/SConscript
intern/opencolorio/CMakeLists.txt
intern/opencolorio/SConscript
intern/opencolorio/ocio_capi_stub.cpp [new file with mode: 0644]
source/blender/imbuf/CMakeLists.txt
source/blender/imbuf/SConscript
source/blender/imbuf/intern/colormanagement.c

index 1609bd35fa6966695e6c243fd9e0e12152bcc505..2551df6ba762ef3dd870c299a53814dbf89ce0f8 100644 (file)
@@ -28,6 +28,7 @@ add_subdirectory(ghost)
 add_subdirectory(guardedalloc)
 add_subdirectory(moto)
 add_subdirectory(memutil)
+add_subdirectory(opencolorio)
 add_subdirectory(opennl)
 add_subdirectory(mikktspace)
 add_subdirectory(raskter)
@@ -74,6 +75,3 @@ if(WIN32)
        add_subdirectory(utfconv)
 endif()
 
-if(WITH_OPENCOLORIO)
-       add_subdirectory(opencolorio)
-endif()
index f4771ccf6a7b30ab33a3480cef4a51d68af754c0..3e40ef3870588a46d82ca6c8758f39336b747c12 100644 (file)
@@ -11,6 +11,7 @@ SConscript(['audaspace/SConscript',
             'decimation/SConscript',
             'iksolver/SConscript',
             'itasc/SConscript',
+            'opencolorio/SConscript',
             'opennl/SConscript',
             'mikktspace/SConscript',
             'smoke/SConscript',
@@ -31,5 +32,3 @@ if env['WITH_BF_BOOLEAN']:
 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-mingw', 'linuxcross', 'win64-vc'):
     SConscript(['utfconv/SConscript'])
 
-if env['WITH_BF_OCIO']:
-    SConscript(['opencolorio/SConscript'])
index 131a829017b819cce37bbf413c74052e5f48079b..479bbd3ab0a2554bbf53d9d2f050b17a16f3a5a2 100644 (file)
 #
 # ***** END GPL LICENSE BLOCK *****
 
-set(INC
-       .
-       ${OPENCOLORIO_INCLUDE_DIRS}
-)
+if(WITH_OPENCOLORIO)
+       set(INC
+               .
+               ${OPENCOLORIO_INCLUDE_DIRS}
+       )
+
+       set(SRC
+               ocio_capi.cpp
+               ocio_capi.h
+       )
+
+       if(WIN32 AND NOT MINGW)
+               list(APPEND INC
+                       ${BOOST_INCLUDE_DIR}
+               )
+       endif()
+else()
+       set(INC
+               .
+               ../../source/blender/blenlib
+       )
+
+       set(SRC
+               ocio_capi_stub.cpp
+               ocio_capi.h
+       )
+endif()
 
 set(INC_SYS
        ../guardedalloc
 )
 
-set(SRC
-       ocio_capi.cpp
-       ocio_capi.h
-)
-
 add_definitions(
 )
 
-if(WIN32 AND NOT MINGW)
-       list(APPEND INC
-               ${BOOST_INCLUDE_DIR}
-       )
-endif()
-
 blender_add_lib(bf_intern_opencolorio "${SRC}" "${INC}" "${INC_SYS}")
+
index 4860d94947e029477da0870b3f818c426323cb1e..fec076627353092b241695c1e876b3f0fe026b48 100644 (file)
@@ -4,10 +4,16 @@ Import('env')
 
 sources = env.Glob('*.cpp')
 
-incs = '. ../guardedalloc'
-incs += ' ' + env['BF_OCIO_INC']
+incs = '. ../guardedalloc ../../source/blender/blenlib'
 
-if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
-    incs += ' ' + env['BF_BOOST_INC']
+if env['WITH_BF_OCIO']:
+    sources.remove('ocio_capi_stub.cpp')
+
+    incs += ' ' + env['BF_OCIO_INC']
+
+    if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
+        incs += ' ' + env['BF_BOOST_INC']
+else:
+    sources.remove('ocio_capi.cpp')
 
 env.BlenderLib( 'bf_intern_opencolorio', sources, Split(incs), [], libtype=['extern','player'], priority=[10, 185])
diff --git a/intern/opencolorio/ocio_capi_stub.cpp b/intern/opencolorio/ocio_capi_stub.cpp
new file mode 100644 (file)
index 0000000..a601cd3
--- /dev/null
@@ -0,0 +1,380 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2012 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Brecht van Lommel
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+#include "BLI_math_color.h"
+
+namespace OCIO_NAMESPACE {};
+
+#include "ocio_capi.h"
+
+#define CONFIG_DEFAULT           ((ConstConfigRcPtr*)1)
+
+#define PROCESSOR_LINEAR_TO_SRGB ((ConstProcessorRcPtr*)1)
+#define PROCESSOR_SRGB_TO_LINEAR ((ConstProcessorRcPtr*)2)
+#define PROCESSOR_UNKNOWN        ((ConstProcessorRcPtr*)3)
+
+#define COLORSPACE_LINEAR        ((ConstColorSpaceRcPtr*)1)
+#define COLORSPACE_SRGB          ((ConstColorSpaceRcPtr*)2)
+
+typedef struct PackedImageDescription {
+       float *data;
+       long width;
+       long height;
+       long numChannels;
+       long chanStrideBytes;
+       long xStrideBytes;
+       long yStrideBytes;
+} PackedImageDescription;
+
+ConstConfigRcPtr *OCIO_getCurrentConfig(void)
+{
+       return CONFIG_DEFAULT;
+}
+
+void OCIO_setCurrentConfig(const ConstConfigRcPtr *)
+{
+}
+
+ConstConfigRcPtr *OCIO_configCreateFromEnv(void)
+{
+       return CONFIG_DEFAULT;
+}
+
+ConstConfigRcPtr *OCIO_configCreateFromFile(const char *)
+{
+       return CONFIG_DEFAULT;
+}
+
+void OCIO_configRelease(ConstConfigRcPtr *)
+{
+}
+
+int OCIO_configGetNumColorSpaces(ConstConfigRcPtr *)
+{
+       return 2;
+}
+
+const char *OCIO_configGetColorSpaceNameByIndex(ConstConfigRcPtr *, int index)
+{
+       if (index == 0)
+               return "Linear";
+       else if (index == 1)
+               return "sRGB";
+       
+       return NULL;
+}
+
+ConstColorSpaceRcPtr *OCIO_configGetColorSpace(ConstConfigRcPtr *, const char *name)
+{
+       if (strcmp(name, "scene_linear") == 0)
+               return COLORSPACE_LINEAR;
+       else if (strcmp(name, "color_picking") == 0)
+               return COLORSPACE_SRGB;
+       else if (strcmp(name, "texture_paint") == 0)
+               return COLORSPACE_LINEAR;
+       else if (strcmp(name, "default_byte") == 0)
+               return COLORSPACE_SRGB;
+       else if (strcmp(name, "default_float") == 0)
+               return COLORSPACE_LINEAR;
+       else if (strcmp(name, "default_sequencer") == 0)
+               return COLORSPACE_SRGB;
+       else if (strcmp(name, "Linear") == 0)
+               return COLORSPACE_LINEAR;
+       else if (strcmp(name, "sRGB") == 0)
+               return COLORSPACE_SRGB;
+
+       return NULL;
+}
+
+int OCIO_configGetIndexForColorSpace(ConstConfigRcPtr *config, const char *name)
+{
+       ConstColorSpaceRcPtr *cs = OCIO_configGetColorSpace(config, name);
+
+       if (cs == COLORSPACE_LINEAR)
+               return 0;
+       else if (cs == COLORSPACE_SRGB)
+               return 1;
+
+       return -1;
+}
+
+const char *OCIO_configGetDefaultDisplay(ConstConfigRcPtr *)
+{
+       return "sRGB";
+}
+
+int OCIO_configGetNumDisplays(ConstConfigRcPtr* config)
+{
+       return 1;
+}
+
+const char *OCIO_configGetDisplay(ConstConfigRcPtr *, int index)
+{
+       if (index == 0)
+               return "sRGB";
+       
+       return NULL;
+}
+
+const char *OCIO_configGetDefaultView(ConstConfigRcPtr *, const char *)
+{
+       return "Default";
+}
+
+int OCIO_configGetNumViews(ConstConfigRcPtr *, const char *)
+{
+       return 1;
+}
+
+const char *OCIO_configGetView(ConstConfigRcPtr *, const char *, int index)
+{
+       if (index == 0)
+               return "Default";
+
+       return NULL;
+}
+
+const char *OCIO_configGetDisplayColorSpaceName(ConstConfigRcPtr *, const char *, const char *)
+{
+       return "sRGB";
+}
+
+int OCIO_colorSpaceIsInvertible(ConstColorSpaceRcPtr *cs)
+{
+       return 1;
+}
+
+void OCIO_colorSpaceRelease(ConstColorSpaceRcPtr *cs)
+{
+}
+
+ConstProcessorRcPtr *OCIO_configGetProcessorWithNames(ConstConfigRcPtr *config, const char *srcName, const char *dstName)
+{
+       ConstColorSpaceRcPtr *cs_src = OCIO_configGetColorSpace(config, srcName);
+       ConstColorSpaceRcPtr *cs_dst = OCIO_configGetColorSpace(config, dstName);
+
+       if (cs_src == COLORSPACE_LINEAR && cs_dst == COLORSPACE_SRGB)
+               return PROCESSOR_LINEAR_TO_SRGB;
+       else if (cs_src == COLORSPACE_SRGB && cs_dst == COLORSPACE_LINEAR)
+               return PROCESSOR_SRGB_TO_LINEAR;
+
+       return 0;
+}
+
+ConstProcessorRcPtr *OCIO_configGetProcessor(ConstConfigRcPtr *, ConstTransformRcPtr *tfm)
+{
+       return (ConstProcessorRcPtr*)tfm;
+}
+
+void OCIO_processorApply(ConstProcessorRcPtr *processor, PackedImageDesc *img)
+{
+       /* OCIO_TODO stride not respected, channels must be 3 or 4 */
+       PackedImageDescription *desc = (PackedImageDescription*)img;
+       int channels = desc->numChannels;
+       float *pixels = desc->data;
+       int width = desc->width;
+       int height = desc->height;
+       int x, y;
+
+       for (y = 0; y < height; y++) {
+               for (x = 0; x < width; x++) {
+                       float *pixel = pixels + channels * (y * width + x);
+
+                       if (channels == 4)
+                               OCIO_processorApplyRGBA(processor, pixel);
+                       else if (channels == 3)
+                               OCIO_processorApplyRGB(processor, pixel);
+               }
+       }
+}
+
+void OCIO_processorApply_predivide(ConstProcessorRcPtr *processor, PackedImageDesc *img)
+{
+       /* OCIO_TODO stride not respected, channels must be 3 or 4 */
+       PackedImageDescription *desc = (PackedImageDescription*)img;
+       int channels = desc->numChannels;
+       float *pixels = desc->data;
+       int width = desc->width;
+       int height = desc->height;
+       int x, y;
+
+       for (y = 0; y < height; y++) {
+               for (x = 0; x < width; x++) {
+                       float *pixel = pixels + channels * (y * width + x);
+
+                       if (channels == 4)
+                               OCIO_processorApplyRGBA_predivide(processor, pixel);
+                       else if (channels == 3)
+                               OCIO_processorApplyRGB(processor, pixel);
+               }
+       }
+}
+
+void OCIO_processorApplyRGB(ConstProcessorRcPtr *processor, float *pixel)
+{
+       if (processor == PROCESSOR_LINEAR_TO_SRGB)
+               linearrgb_to_srgb_v3_v3(pixel, pixel);
+       else if (processor == PROCESSOR_SRGB_TO_LINEAR)
+               srgb_to_linearrgb_v3_v3(pixel, pixel);
+}
+
+void OCIO_processorApplyRGBA(ConstProcessorRcPtr *processor, float *pixel)
+{
+       if (processor == PROCESSOR_LINEAR_TO_SRGB)
+               linearrgb_to_srgb_v4(pixel, pixel);
+       else if (processor == PROCESSOR_SRGB_TO_LINEAR)
+               srgb_to_linearrgb_v4(pixel, pixel);
+}
+
+void OCIO_processorApplyRGBA_predivide(ConstProcessorRcPtr *processor, float *pixel)
+{
+       if (pixel[3] == 1.0f || pixel[3] == 0.0f) {
+               OCIO_processorApplyRGBA(processor, pixel);
+       }
+       else {
+               float alpha, inv_alpha;
+
+               alpha = pixel[3];
+               inv_alpha = 1.0f / alpha;
+
+               pixel[0] *= inv_alpha;
+               pixel[1] *= inv_alpha;
+               pixel[2] *= inv_alpha;
+
+               OCIO_processorApplyRGBA(processor, pixel);
+
+               pixel[0] *= alpha;
+               pixel[1] *= alpha;
+               pixel[2] *= alpha;
+       }
+}
+
+void OCIO_processorRelease(ConstProcessorRcPtr *)
+{
+}
+
+const char *OCIO_colorSpaceGetName(ConstColorSpaceRcPtr *cs)
+{
+       if (cs == COLORSPACE_LINEAR)
+               return "Linear";
+       else if (cs == COLORSPACE_SRGB)
+               return "sRGB";
+       
+       return NULL;
+}
+
+const char *OCIO_colorSpaceGetDescription(ConstColorSpaceRcPtr *)
+{
+       return "";
+}
+
+const char *OCIO_colorSpaceGetFamily(ConstColorSpaceRcPtr *)
+{
+       return "";
+}
+
+DisplayTransformRcPtr *OCIO_createDisplayTransform(void)
+{
+       return (DisplayTransformRcPtr*)PROCESSOR_LINEAR_TO_SRGB;
+}
+
+void OCIO_displayTransformSetInputColorSpaceName(DisplayTransformRcPtr *, const char *)
+{
+}
+
+void OCIO_displayTransformSetDisplay(DisplayTransformRcPtr *, const char *)
+{
+}
+
+void OCIO_displayTransformSetView(DisplayTransformRcPtr *, const char *)
+{
+}
+
+void OCIO_displayTransformSetDisplayCC(DisplayTransformRcPtr *, ConstTransformRcPtr *)
+{
+}
+
+void OCIO_displayTransformSetLinearCC(DisplayTransformRcPtr *, ConstTransformRcPtr *)
+{
+}
+
+void OCIO_displayTransformRelease(DisplayTransformRcPtr *)
+{
+}
+
+PackedImageDesc *OCIO_createPackedImageDesc(float *data, long width, long height, long numChannels,
+                                            long chanStrideBytes, long xStrideBytes, long yStrideBytes)
+{
+       PackedImageDescription *desc = (PackedImageDescription*)MEM_callocN(sizeof(PackedImageDescription), "PackedImageDescription");
+
+       desc->data = data;
+       desc->width = width;
+       desc->height = height;
+       desc->numChannels = numChannels;
+       desc->chanStrideBytes = chanStrideBytes;
+       desc->xStrideBytes = xStrideBytes;
+       desc->yStrideBytes = yStrideBytes;
+
+       return (PackedImageDesc*)desc;
+}
+
+void OCIO_packedImageDescRelease(PackedImageDesc* id)
+{
+       MEM_freeN(id);
+}
+
+ExponentTransformRcPtr *OCIO_createExponentTransform(void)
+{
+       return (ExponentTransformRcPtr*)PROCESSOR_UNKNOWN;
+}
+
+void OCIO_exponentTransformSetValue(ExponentTransformRcPtr *, const float *)
+{
+}
+
+void OCIO_exponentTransformRelease(ExponentTransformRcPtr *)
+{
+}
+
+MatrixTransformRcPtr *OCIO_createMatrixTransform(void)
+{
+       return (MatrixTransformRcPtr*)PROCESSOR_UNKNOWN;
+}
+
+void OCIO_matrixTransformSetValue(MatrixTransformRcPtr *, const float *, const float *)
+{
+}
+
+void OCIO_matrixTransformRelease(MatrixTransformRcPtr *)
+{
+}
+
+void OCIO_matrixTransformScale(float * , float * , const float *)
+{
+}
+
index 9c707a459f2c97985f42188f01e6480a01429a62..8849265679a0524d6e72fce7cc8ff6222c719b24 100644 (file)
@@ -183,14 +183,9 @@ if(WITH_IMAGE_HDR)
        add_definitions(-DWITH_HDR)
 endif()
 
-if(WITH_OPENCOLORIO)
-       list(APPEND SRC
-       )
-       list(APPEND INC
-               ../../../intern/opencolorio
-       )
-       add_definitions(-DWITH_OCIO)
-endif()
+list(APPEND INC
+       ../../../intern/opencolorio
+)
 
 if(WIN32)
        list(APPEND INC
index 61cc5684356c33add3347dcaa9ab748499b49104..976108cd84e9bf6b6e712623da86cf7befb6e34d 100644 (file)
@@ -6,7 +6,7 @@ sources = env.Glob('intern/*.c')
 
 incs = '. ../makesdna ../makesrna #/intern/guardedalloc #/intern/memutil ../blenlib'
 incs += ' ../avi ../blenkernel ../blenloader'
-incs += ' #/intern/ffmpeg'
+incs += ' #/intern/ffmpeg #intern/opencolorio'
 
 incs += ' ' + env['BF_JPEG_INC']
 incs += ' ' + env['BF_PNG_INC']
@@ -58,8 +58,4 @@ if env['WITH_BF_QUICKTIME']:
     incs += ' ../quicktime ' + env['BF_QUICKTIME_INC']
     defs.append('WITH_QUICKTIME')
 
-if env['WITH_BF_OCIO']:
-    defs.append('WITH_OCIO')
-    incs += ' #intern/opencolorio'
-
 env.BlenderLib ( libname = 'bf_imbuf', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [185,115] )
index 260aef533b570b0e0e8105f922a99bbb85245809..7548974f073e31d86e0b1b4898c1f41525ddc455 100644 (file)
 
 #include "RNA_define.h"
 
-#ifdef WITH_OCIO
-#  include <ocio_capi.h>
-#else
-/* so function can accept processor and care about disabled OCIO inside */
-typedef struct ConstProcessorRcPtr {
-       int pad;
-} ConstProcessorRcPtr;
-#endif
+#include <ocio_capi.h>
 
 /*********************** Global declarations *************************/
 
 #define MAX_COLORSPACE_NAME 64
 
 /* ** list of all supported color spaces, displays and views */
-#ifdef WITH_OCIO
 static char global_role_scene_linear[MAX_COLORSPACE_NAME];
 static char global_role_color_picking[MAX_COLORSPACE_NAME];
 static char global_role_texture_painting[MAX_COLORSPACE_NAME];
 static char global_role_default_byte[MAX_COLORSPACE_NAME];
 static char global_role_default_float[MAX_COLORSPACE_NAME];
 static char global_role_default_sequencer[MAX_COLORSPACE_NAME];
-#endif
 
 static ListBase global_colorspaces = {NULL};
 static ListBase global_displays = {NULL};
@@ -98,14 +89,6 @@ static int global_tot_view = 0;
 typedef struct ColormanageProcessor {
        ConstProcessorRcPtr *processor;
        CurveMapping *curve_mapping;
-
-#ifndef WITH_OCIO
-       /* this callback is only used in cases when Blender was build without OCIO
-        * and aimed to preserve compatibility with previous Blender versions
-        */
-       void (*display_transform_cb_v3) (float result[3], const float pixel[3]);
-       void (*display_transform_predivide_cb_v4) (float result[4], const float pixel[4]);
-#endif
 } ColormanageProcessor;
 
 /*********************** Color managed cache *************************/
@@ -222,7 +205,6 @@ static ColormnaageCacheData *colormanage_cachedata_get(const ImBuf *ibuf)
        return ibuf->colormanage_cache->data;
 }
 
-#ifdef WITH_OCIO
 static unsigned int colormanage_hashhash(const void *key_v)
 {
        ColormanageCacheKey *key = (ColormanageCacheKey *)key_v;
@@ -419,7 +401,6 @@ static void colormanage_cache_put(ImBuf *ibuf, const ColormanageCacheViewSetting
 
        IMB_moviecache_put(moviecache, &key, cache_ibuf);
 }
-#endif
 
 static void colormanage_cache_handle_release(void *cache_handle)
 {
@@ -430,7 +411,6 @@ static void colormanage_cache_handle_release(void *cache_handle)
 
 /*********************** Initialization / De-initialization *************************/
 
-#ifdef WITH_OCIO
 static void colormanage_role_color_space_name_get(ConstConfigRcPtr *config, char *colorspace_name, const char *role)
 {
        ConstColorSpaceRcPtr *ociocs;
@@ -562,11 +542,9 @@ void colormanage_free_config(void)
        /* free views */
        BLI_freelistN(&global_views);
 }
-#endif
 
 void IMB_colormanagement_init(void)
 {
-#ifdef WITH_OCIO
        const char *ocio_env;
        const char *configdir;
        char configfile[FILE_MAX];
@@ -594,16 +572,13 @@ void IMB_colormanagement_init(void)
 
                OCIO_configRelease(config);
        }
-#endif
 
        BLI_init_srgb_conversion();
 }
 
 void IMB_colormanagement_exit(void)
 {
-#ifdef WITH_OCIO
        colormanage_free_config();
-#endif
 }
 
 /*********************** Internal functions *************************/
@@ -649,7 +624,6 @@ static void display_transform_get_from_ctx(const bContext *C, ColorManagedViewSe
        }
 }
 
-#ifdef WITH_OCIO
 static ConstProcessorRcPtr *create_display_buffer_processor(const char *view_transform, const char *display,
                                                             float exposure, float gamma)
 {
@@ -830,7 +804,6 @@ static void init_default_view_settings(const ColorManagedDisplaySettings *displa
        view_settings->exposure = 0.0f;
        view_settings->curve_mapping = NULL;
 }
-#endif
 
 static void curve_mapping_apply_pixel(CurveMapping *curve_mapping, float *pixel, int channels)
 {
@@ -859,7 +832,6 @@ void colorspace_set_default_role(char *colorspace, int size, int role)
 
 void colormanage_imbuf_make_linear(ImBuf *ibuf, const char *from_colorspace)
 {
-#ifdef WITH_OCIO
        if (ibuf->rect_float) {
                const char *to_colorspace = global_role_scene_linear;
                int predivide = ibuf->flags & IB_cm_predivide;
@@ -872,15 +844,10 @@ void colormanage_imbuf_make_linear(ImBuf *ibuf, const char *from_colorspace)
 
                ibuf->profile = IB_PROFILE_LINEAR_RGB;
        }
-#else
-       (void) ibuf;
-       (void) role;
-#endif
 }
 
 /*********************** Generic functions *************************/
 
-#ifdef WITH_OCIO
 static void colormanage_check_display_settings(ColorManagedDisplaySettings *display_settings, const char *what,
                                                const ColorManagedDisplay *default_display)
 {
@@ -954,11 +921,9 @@ static void colormanage_check_colorspace_settings(ColorManagedColorspaceSettings
 
        (void) what;
 }
-#endif
 
 void IMB_colormanagement_check_file_config(Main *bmain)
 {
-#ifdef WITH_OCIO
        Scene *scene;
        Image *image;
        MovieClip *clip;
@@ -996,15 +961,11 @@ void IMB_colormanagement_check_file_config(Main *bmain)
        for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
                colormanage_check_colorspace_settings(&clip->colorspace_settings, "clip");
        }
-#else
-       (void) bmain;
-#endif
 }
 
 void IMB_colormanagement_validate_settings(ColorManagedDisplaySettings *display_settings,
                                            ColorManagedViewSettings *view_settings)
 {
-#ifdef WITH_OCIO
        ColorManagedDisplay *display;
        ColorManagedView *default_view;
        LinkData *view_link;
@@ -1021,15 +982,10 @@ void IMB_colormanagement_validate_settings(ColorManagedDisplaySettings *display_
 
        if (view_link == NULL)
                BLI_strncpy(view_settings->view_transform, default_view->name, sizeof(view_settings->view_transform));
-#else
-       (void) display_settings;
-       (void) view_settings;
-#endif
 }
 
 const char *IMB_colormanagement_role_colorspace_name_get(int role)
 {
-#ifdef WITH_OCIO
        switch (role) {
                case COLOR_ROLE_SCENE_LINEAR:
                        return global_role_scene_linear;
@@ -1053,9 +1009,6 @@ const char *IMB_colormanagement_role_colorspace_name_get(int role)
                        printf("Unknown role was passed to %s\n", __func__);
                        BLI_assert(0);
        }
-#else
-       (void) role;
-#endif
 
        return NULL;
 }
@@ -1083,7 +1036,6 @@ void IMB_colormanagement_imbuf_float_from_rect(ImBuf *ibuf)
 
 /*********************** Threaded display buffer transform routines *************************/
 
-#ifdef WITH_OCIO
 typedef struct DisplayBufferThread {
        ColormanageProcessor *cm_processor;
 
@@ -1317,7 +1269,6 @@ static void colormanage_display_buffer_process(ImBuf *ibuf, unsigned char *displ
 {
        colormanage_display_buffer_process_ex(ibuf, NULL, display_buffer, view_settings, display_settings);
 }
-#endif
 
 /*********************** Threaded processor transform routines *************************/
 
@@ -1468,7 +1419,6 @@ void IMB_colormanagement_transform_v4(float pixel[4], const char *from_colorspac
  */
 void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], ColorSpace *colorspace)
 {
-#ifdef WITH_OCIO
        ConstProcessorRcPtr *processor;
 
        if (!colorspace) {
@@ -1483,16 +1433,11 @@ void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], ColorSpac
 
        if (processor)
                OCIO_processorApplyRGB(processor, pixel);
-#else
-       (void) pixel;
-       (void) colorspace;
-#endif
 }
 
 /* same as above, but converts colors in opposite direction */
 void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], ColorSpace *colorspace)
 {
-#ifdef WITH_OCIO
        ConstProcessorRcPtr *processor;
 
        if (!colorspace) {
@@ -1507,16 +1452,10 @@ void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], ColorSpac
 
        if (processor)
                OCIO_processorApplyRGB(processor, pixel);
-
-#else
-       (void) pixel;
-       (void) colorspace;
-#endif
 }
 
 void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, int width, int height, int channels, struct ColorSpace *colorspace, int predivide)
 {
-#ifdef WITH_OCIO
        ConstProcessorRcPtr *processor;
 
        if (!colorspace) {
@@ -1542,14 +1481,6 @@ void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, int width, in
 
                OCIO_packedImageDescRelease(img);
        }
-#else
-       (void) buffer;
-       (void) channels;
-       (void) width;
-       (void) height;
-       (void) colorspace;
-       (void) predivide;
-#endif
 }
 
 /* convert pixel from scene linear to display space using default view
@@ -1558,33 +1489,23 @@ void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, int width, in
  */
 void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], ColorManagedDisplay *display)
 {
-#ifdef WITH_OCIO
        ConstProcessorRcPtr *processor;
 
        processor = display_from_scene_linear_processor(display);
 
        if (processor)
                OCIO_processorApplyRGB(processor, pixel);
-#else
-       (void) pixel;
-       (void) display;
-#endif
 }
 
 /* same as above, but converts color in opposite direction */
 void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], ColorManagedDisplay *display)
 {
-#ifdef WITH_OCIO
        ConstProcessorRcPtr *processor;
 
        processor = display_to_scene_linear_processor(display);
 
        if (processor)
                OCIO_processorApplyRGB(processor, pixel);
-#else
-       (void) pixel;
-       (void) display;
-#endif
 }
 
 void IMB_colormanagement_pixel_to_display_space_v4(float result[4], const float pixel[4],
@@ -1615,7 +1536,6 @@ void IMB_colormanagement_pixel_to_display_space_v3(float result[3], const float
 
 void IMB_colormanagement_imbuf_assign_spaces(ImBuf *ibuf, ColorManagedColorspaceSettings *colorspace_settings)
 {
-#ifdef WITH_OCIO
        if (colorspace_settings) {
                if (colorspace_settings->name[0] == '\0') {
                        /* when opening new image, assign it's color space based on default roles */
@@ -1634,10 +1554,6 @@ void IMB_colormanagement_imbuf_assign_spaces(ImBuf *ibuf, ColorManagedColorspace
                else
                        ibuf->rect_colorspace = colormanage_colorspace_get_named(global_role_default_byte);
        }
-#else
-       (void) ibuf;
-       (void) colorspace_settings;
-#endif
 }
 
 void IMB_colormanagement_imbuf_assign_float_space(ImBuf *ibuf, ColorManagedColorspaceSettings *colorspace_settings)
@@ -1648,7 +1564,6 @@ void IMB_colormanagement_imbuf_assign_float_space(ImBuf *ibuf, ColorManagedColor
 void IMB_colormanagement_imbuf_make_display_space(ImBuf *ibuf, const ColorManagedViewSettings *view_settings,
                                                   const ColorManagedDisplaySettings *display_settings)
 {
-#ifdef WITH_OCIO
        /* OCIO_TODO: byte buffer management is not supported here yet */
        if (!ibuf->rect_float)
                return;
@@ -1660,13 +1575,6 @@ void IMB_colormanagement_imbuf_make_display_space(ImBuf *ibuf, const ColorManage
        else {
                colormanage_display_buffer_process_ex(ibuf, ibuf->rect_float, NULL, view_settings, display_settings);
        }
-#else
-       (void) view_settings;
-       (void) display_settings;
-
-       IMB_buffer_float_from_float(ibuf->rect_float, ibuf->rect_float, ibuf->channels, IB_PROFILE_LINEAR_RGB, ibuf->profile,
-                                   ibuf->flags & IB_cm_predivide, ibuf->x, ibuf->y, ibuf->x, ibuf->x);
-#endif
 }
 
 static void imbuf_verify_float(ImBuf *ibuf)
@@ -1708,7 +1616,6 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSet
 
                return (unsigned char *) ibuf->rect;
        }
-#ifdef WITH_OCIO
        else {
                unsigned char *display_buffer;
                int buffer_size;
@@ -1766,12 +1673,6 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSet
 
                return display_buffer;
        }
-#else
-       (void) view_settings;
-       (void) display_settings;
-
-       return NULL;
-#endif
 }
 
 /* same as IMB_display_buffer_acquire but gets view and display settings from context */
@@ -1789,7 +1690,6 @@ unsigned char *IMB_display_buffer_acquire_ctx(const bContext *C, ImBuf *ibuf, vo
 void IMB_display_buffer_to_imbuf_rect(ImBuf *ibuf, const ColorManagedViewSettings *view_settings,
                                       const ColorManagedDisplaySettings *display_settings)
 {
-#ifdef WITH_OCIO
        if (global_tot_display == 0 || global_tot_view == 0) {
                imbuf_verify_float(ibuf);
        }
@@ -1800,19 +1700,12 @@ void IMB_display_buffer_to_imbuf_rect(ImBuf *ibuf, const ColorManagedViewSetting
 
                colormanage_display_buffer_process(ibuf, (unsigned char *) ibuf->rect, view_settings, display_settings);
        }
-#else
-       (void) view_settings;
-       (void) display_settings;
-
-       imbuf_verify_float(ibuf);
-#endif
 }
 
 void IMB_display_buffer_transform_apply(unsigned char *display_buffer, float *linear_buffer, int width, int height,
                                         int channels, const ColorManagedViewSettings *view_settings,
                                         const ColorManagedDisplaySettings *display_settings, int predivide)
 {
-#ifdef WITH_OCIO
        if (global_tot_display == 0 || global_tot_view == 0) {
                IMB_buffer_byte_from_float(display_buffer, linear_buffer, 4, 0.0f, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, FALSE,
                                           width, height, width, width);
@@ -1833,13 +1726,6 @@ void IMB_display_buffer_transform_apply(unsigned char *display_buffer, float *li
 
                MEM_freeN(buffer);
        }
-#else
-       (void) view_settings;
-       (void) display_settings;
-
-       IMB_buffer_byte_from_float(display_buffer, linear_buffer, channels, 0.0f, IB_PROFILE_SRGB, IB_PROFILE_LINEAR_RGB, predivide,
-                                  width, height, width, width);
-#endif
 }
 
 void IMB_display_buffer_release(void *cache_handle)
@@ -1855,7 +1741,6 @@ void IMB_display_buffer_release(void *cache_handle)
 
 /*********************** Display functions *************************/
 
-#ifdef WITH_OCIO
 ColorManagedDisplay *colormanage_display_get_default(void)
 {
        ConstConfigRcPtr *config = OCIO_getCurrentConfig();
@@ -1876,7 +1761,6 @@ ColorManagedDisplay *colormanage_display_get_default(void)
 
        return colormanage_display_get_named(display);
 }
-#endif
 
 ColorManagedDisplay *colormanage_display_add(const char *name)
 {
@@ -1946,13 +1830,9 @@ const char *IMB_colormanagement_display_get_indexed_name(int index)
 
 const char *IMB_colormanagement_display_get_default_name(void)
 {
-#ifdef WITH_OCIO
        ColorManagedDisplay *display = colormanage_display_get_default();
 
        return display->name;
-#else
-       return NULL;
-#endif
 }
 
 /* used by performance-critical pixel processing areas, such as color widgets */
@@ -1963,7 +1843,6 @@ ColorManagedDisplay *IMB_colormanagement_display_get_named(const char *name)
 
 /*********************** View functions *************************/
 
-#ifdef WITH_OCIO
 const char *colormanage_view_get_default_name(const ColorManagedDisplay *display)
 {
        ConstConfigRcPtr *config = OCIO_getCurrentConfig();
@@ -1991,7 +1870,6 @@ ColorManagedView *colormanage_view_get_default(const ColorManagedDisplay *displa
 
        return colormanage_view_get_named(name);
 }
-#endif
 
 ColorManagedView *colormanage_view_add(const char *name)
 {
@@ -2051,16 +1929,12 @@ const char *IMB_colormanagement_view_get_indexed_name(int index)
 
 const char *IMB_colormanagement_view_get_default_name(const char *display_name)
 {
-#if WITH_OCIO
        ColorManagedDisplay *display = colormanage_display_get_named(display_name);
        ColorManagedView *view = colormanage_view_get_default(display);
 
        if (view) {
                return view->name;
        }
-#else
-       (void) display_name;
-#endif
 
        return NULL;
 }
@@ -2277,7 +2151,6 @@ void IMB_colormanagement_colorspace_items_add(EnumPropertyItem **items, int *tot
  * the rest buffers would be marked as dirty
  */
 
-#ifdef WITH_OCIO
 static void partial_buffer_update_rect(ImBuf *ibuf, unsigned char *display_buffer, const float *linear_buffer,
                                        const unsigned char *byte_buffer, int display_stride, int linear_stride,
                                        int linear_offset_x, int linear_offset_y, ColormanageProcessor *cm_processor,
@@ -2336,7 +2209,6 @@ static void partial_buffer_update_rect(ImBuf *ibuf, unsigned char *display_buffe
                MEM_freeN(display_buffer_float);
        }
 }
-#endif
 
 void IMB_partial_display_buffer_update(ImBuf *ibuf, const float *linear_buffer, const unsigned char *byte_buffer,
                                        int stride, int offset_x, int offset_y, const ColorManagedViewSettings *view_settings,
@@ -2362,7 +2234,6 @@ void IMB_partial_display_buffer_update(ImBuf *ibuf, const float *linear_buffer,
                                           IB_PROFILE_SRGB, profile_from, predivide, width, height, ibuf->x, stride);
        }
 
-#ifdef WITH_OCIO
        if (ibuf->display_buffer_flags) {
                ColormanageCacheViewSettings cache_view_settings;
                ColormanageCacheDisplaySettings cache_display_settings;
@@ -2405,11 +2276,6 @@ void IMB_partial_display_buffer_update(ImBuf *ibuf, const float *linear_buffer,
                        IMB_display_buffer_release(cache_handle);
                }
        }
-#else
-       (void) byte_buffer;
-       (void) view_settings;
-       (void) display_settings;
-#endif
 }
 
 /*********************** Pixel processor functions *************************/
@@ -2421,7 +2287,6 @@ ColormanageProcessor *IMB_colormanagement_display_processor_new(const ColorManag
 
        cm_processor = MEM_callocN(sizeof(ColormanageProcessor), "colormanagement processor");
 
-#ifdef WITH_OCIO
        {
                ColorManagedViewSettings default_view_settings;
                const ColorManagedViewSettings *applied_view_settings;
@@ -2442,16 +2307,6 @@ ColormanageProcessor *IMB_colormanagement_display_processor_new(const ColorManag
                        curvemapping_premultiply(cm_processor->curve_mapping, FALSE);
                }
        }
-#else
-       (void) view_settings;
-       (void) display_settings;
-
-       /* assume input is in linear space and color management is always enabled
-        * seams to be quite reasonable behavior in cases there's no OCIO
-        */
-       cm_processor->display_transform_cb_v3 = linearrgb_to_srgb_v3_v3;
-       cm_processor->display_transform_predivide_cb_v4 = linearrgb_to_srgb_predivide_v4;
-#endif
 
        return cm_processor;
 }
@@ -2462,12 +2317,7 @@ ColormanageProcessor *IMB_colormanagement_colorspace_processor_new(const char *f
 
        cm_processor = MEM_callocN(sizeof(ColormanageProcessor), "colormanagement processor");
 
-#ifdef WITH_OCIO
        cm_processor->processor = create_colorspace_transform_processor(from_colorspace, to_colorspace);
-#else
-       (void) from_colorspace;
-       (void) to_colorspace;
-#endif
 
        return cm_processor;
 }
@@ -2477,12 +2327,7 @@ void IMB_colormanagement_processor_apply_v4(ColormanageProcessor *cm_processor,
        if (cm_processor->curve_mapping)
                curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel);
 
-#ifdef WITH_OCIO
        OCIO_processorApplyRGBA(cm_processor->processor, pixel);
-#else
-       if (cm_processor->display_transform_cb_v3)
-               cm_processor->display_transform_cb_v3(pixel, pixel);
-#endif
 }
 
 void IMB_colormanagement_processor_apply_v3(ColormanageProcessor *cm_processor, float pixel[3])
@@ -2490,12 +2335,7 @@ void IMB_colormanagement_processor_apply_v3(ColormanageProcessor *cm_processor,
        if (cm_processor->curve_mapping)
                curvemapping_evaluate_premulRGBF(cm_processor->curve_mapping, pixel, pixel);
 
-#ifdef WITH_OCIO
        OCIO_processorApplyRGB(cm_processor->processor, pixel);
-#else
-       if (cm_processor->display_transform_cb_v3)
-               cm_processor->display_transform_cb_v3(pixel, pixel);
-#endif
 }
 
 void IMB_colormanagement_processor_apply(ColormanageProcessor *cm_processor, float *buffer, int width, int height,
@@ -2514,7 +2354,6 @@ void IMB_colormanagement_processor_apply(ColormanageProcessor *cm_processor, flo
                }
        }
 
-#ifdef WITH_OCIO
        {
                PackedImageDesc *img;
 
@@ -2529,37 +2368,14 @@ void IMB_colormanagement_processor_apply(ColormanageProcessor *cm_processor, flo
 
                OCIO_packedImageDescRelease(img);
        }
-#else
-       if (cm_processor->display_transform_cb_v3) {
-               int x, y;
-
-               for (y = 0; y < height; y++) {
-                       for (x = 0; x < width; x++) {
-                               float *pixel = buffer + channels * (y * width + x);
-
-                               if (channels == 3) {
-                                       cm_processor->display_transform_cb_v3(pixel, pixel);
-                               }
-                               else if (channels == 4) {
-                                       if (!predivide)
-                                               cm_processor->display_transform_predivide_cb_v4(pixel, pixel);
-                                       else
-                                               cm_processor->display_transform_cb_v3(pixel, pixel);
-                               }
-                       }
-               }
-       }
-#endif
 }
 
 void IMB_colormanagement_processor_free(ColormanageProcessor *cm_processor)
 {
-#ifdef WITH_OCIO
        if (cm_processor->curve_mapping)
                curvemapping_free(cm_processor->curve_mapping);
 
        OCIO_processorRelease(cm_processor->processor);
-#endif
 
        MEM_freeN(cm_processor);
 }