From 86c68c0569b3cd82a1de27470b3d4858cde96e30 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 2 Apr 2012 11:04:24 +0000 Subject: Multithreaded EXR files loading Use multithreaded loading of EXR files which is enabling by call of setGlobalThreadCount function from OpenEXR library to set up number of used threads to number of system threads which speeds up loading high-resolution files on multi-core / multi-cpu systems and allows to work with high-resolution sequences in clip editor and sequencer. --- source/blender/imbuf/intern/filetype.c | 2 +- source/blender/imbuf/intern/openexr/openexr_api.cpp | 7 +++++++ source/blender/imbuf/intern/openexr/openexr_api.h | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'source/blender/imbuf/intern') diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index 9ece4bd9f6d..74fd601e3f6 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -80,7 +80,7 @@ ImFileType IMB_FILE_TYPES[]= { {NULL, NULL, imb_is_a_openexr, imb_ftype_default, imb_load_openexr, imb_save_openexr, NULL, IM_FTYPE_FLOAT, OPENEXR}, #endif #ifdef WITH_OPENJPEG - {NULL, NULL, imb_is_a_jp2, imb_ftype_default, imb_jp2_decode, imb_savejp2, NULL, IM_FTYPE_FLOAT, JP2}, + {imb_initopenexr, NULL, imb_is_a_jp2, imb_ftype_default, imb_jp2_decode, imb_savejp2, NULL, IM_FTYPE_FLOAT, JP2}, #endif #ifdef WITH_DDS {NULL, NULL, imb_is_a_dds, imb_ftype_default, imb_load_dds, NULL, NULL, 0, DDS}, diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 3d90267b030..5090155522d 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -51,6 +51,7 @@ _CRTIMP void __cdecl _invalid_parameter_noinfo(void) #include "BLI_blenlib.h" #include "BLI_math_color.h" +#include "BLI_threads.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -1066,5 +1067,11 @@ struct ImBuf *imb_load_openexr(unsigned char *mem, size_t size, int flags) } +void imb_initopenexr(void) +{ + int num_threads = BLI_system_thread_count(); + + setGlobalThreadCount(num_threads); +} } // export "C" diff --git a/source/blender/imbuf/intern/openexr/openexr_api.h b/source/blender/imbuf/intern/openexr/openexr_api.h index e0358361713..d12fe2fc49f 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.h +++ b/source/blender/imbuf/intern/openexr/openexr_api.h @@ -43,7 +43,9 @@ extern "C" { * Test presence of OpenEXR file. * \param mem pointer to loaded OpenEXR bitstream */ - + +void imb_initopenexr (void); + int imb_is_a_openexr (unsigned char *mem); int imb_save_openexr (struct ImBuf *ibuf, const char *name, int flags); -- cgit v1.2.3