Blender  V3.3
Classes
colormanagement.c File Reference
#include "IMB_colormanagement.h"
#include "IMB_colormanagement_intern.h"
#include <math.h>
#include <string.h>
#include "DNA_color_types.h"
#include "DNA_image_types.h"
#include "DNA_movieclip_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "IMB_filetype.h"
#include "IMB_filter.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "IMB_metadata.h"
#include "IMB_moviecache.h"
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_math_color.h"
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BLI_threads.h"
#include "BKE_appdir.h"
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_image.h"
#include "BKE_image_format.h"
#include "BKE_main.h"
#include "RNA_define.h"
#include "SEQ_iterator.h"
#include <ocio_capi.h>

Go to the source code of this file.

Classes

struct  ColormanageProcessor
 
struct  global_gpu_state
 
struct  global_color_picking_state
 
struct  ColormanageCacheViewSettings
 
struct  ColormanageCacheDisplaySettings
 
struct  ColormanageCacheKey
 
struct  ColormanageCacheData
 
struct  ColormanageCache
 
struct  DisplayBufferThread
 
struct  DisplayBufferInitData
 
struct  ProcessorTransformThread
 
struct  ProcessorTransformInit
 
struct  PartialThreadData
 

Functions

Initialization / De-initialization
static void colormanage_role_color_space_name_get (OCIO_ConstConfigRcPtr *config, char *colorspace_name, const char *role, const char *backup_role)
 
static void colormanage_load_config (OCIO_ConstConfigRcPtr *config)
 
static void colormanage_free_config (void)
 
void colormanagement_init (void)
 
void colormanagement_exit (void)
 
Internal functions
static bool colormanage_compatible_look (ColorManagedLook *look, const char *view_name)
 
static bool colormanage_use_look (const char *look, const char *view_name)
 
void colormanage_cache_free (ImBuf *ibuf)
 
void IMB_colormanagement_display_settings_from_ctx (const bContext *C, ColorManagedViewSettings **r_view_settings, ColorManagedDisplaySettings **r_display_settings)
 
static const char * get_display_colorspace_name (const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
 
static ColorSpacedisplay_transform_get_colorspace (const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
 
static OCIO_ConstCPUProcessorRcPtr * create_display_buffer_processor (const char *look, const char *view_transform, const char *display, float exposure, float gamma, const char *from_colorspace)
 
static OCIO_ConstProcessorRcPtr * create_colorspace_transform_processor (const char *from_colorspace, const char *to_colorspace)
 
static OCIO_ConstCPUProcessorRcPtr * colorspace_to_scene_linear_cpu_processor (ColorSpace *colorspace)
 
static OCIO_ConstCPUProcessorRcPtr * colorspace_from_scene_linear_cpu_processor (ColorSpace *colorspace)
 
static OCIO_ConstCPUProcessorRcPtr * display_from_scene_linear_processor (ColorManagedDisplay *display)
 
static OCIO_ConstCPUProcessorRcPtr * display_to_scene_linear_processor (ColorManagedDisplay *display)
 
void IMB_colormanagement_init_default_view_settings (ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
 
static void curve_mapping_apply_pixel (CurveMapping *curve_mapping, float *pixel, int channels)
 
void colorspace_set_default_role (char *colorspace, int size, int role)
 
void colormanage_imbuf_set_default_spaces (ImBuf *ibuf)
 
void colormanage_imbuf_make_linear (ImBuf *ibuf, const char *from_colorspace)
 
Generic Functions
static void colormanage_check_display_settings (ColorManagedDisplaySettings *display_settings, const char *what, const ColorManagedDisplay *default_display)
 
static void colormanage_check_view_settings (ColorManagedDisplaySettings *display_settings, ColorManagedViewSettings *view_settings, const char *what)
 
static void colormanage_check_colorspace_settings (ColorManagedColorspaceSettings *colorspace_settings, const char *what)
 
static bool seq_callback (Sequence *seq, void *UNUSED(user_data))
 
void IMB_colormanagement_check_file_config (Main *bmain)
 
void IMB_colormanagement_validate_settings (const ColorManagedDisplaySettings *display_settings, ColorManagedViewSettings *view_settings)
 
const char * IMB_colormanagement_role_colorspace_name_get (int role)
 
void IMB_colormanagement_check_is_data (ImBuf *ibuf, const char *name)
 
void IMB_colormanagegent_copy_settings (ImBuf *ibuf_src, ImBuf *ibuf_dst)
 
void IMB_colormanagement_assign_float_colorspace (ImBuf *ibuf, const char *name)
 
void IMB_colormanagement_assign_rect_colorspace (ImBuf *ibuf, const char *name)
 
const char * IMB_colormanagement_get_float_colorspace (ImBuf *ibuf)
 
const char * IMB_colormanagement_get_rect_colorspace (ImBuf *ibuf)
 
bool IMB_colormanagement_space_is_data (ColorSpace *colorspace)
 
static void colormanage_ensure_srgb_scene_linear_info (ColorSpace *colorspace)
 
bool IMB_colormanagement_space_is_scene_linear (ColorSpace *colorspace)
 
bool IMB_colormanagement_space_is_srgb (ColorSpace *colorspace)
 
bool IMB_colormanagement_space_name_is_data (const char *name)
 
bool IMB_colormanagement_space_name_is_scene_linear (const char *name)
 
bool IMB_colormanagement_space_name_is_srgb (const char *name)
 
const floatIMB_colormanagement_get_xyz_to_scene_linear ()
 
Color Space Transformation Functions
static void colormanagement_transform_ex (unsigned char *byte_buffer, float *float_buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace, bool predivide, bool do_threaded)
 
void IMB_colormanagement_transform (float *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace, bool predivide)
 
void IMB_colormanagement_transform_threaded (float *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace, bool predivide)
 
void IMB_colormanagement_transform_byte (unsigned char *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace)
 
void IMB_colormanagement_transform_byte_threaded (unsigned char *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace)
 
void IMB_colormanagement_transform_from_byte (float *float_buffer, unsigned char *byte_buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace)
 
void IMB_colormanagement_transform_from_byte_threaded (float *float_buffer, unsigned char *byte_buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace)
 
void IMB_colormanagement_transform_v4 (float pixel[4], const char *from_colorspace, const char *to_colorspace)
 
void IMB_colormanagement_colorspace_to_scene_linear_v3 (float pixel[3], ColorSpace *colorspace)
 
void IMB_colormanagement_scene_linear_to_colorspace_v3 (float pixel[3], ColorSpace *colorspace)
 
void IMB_colormanagement_colorspace_to_scene_linear_v4 (float pixel[4], bool predivide, ColorSpace *colorspace)
 
void IMB_colormanagement_colorspace_to_scene_linear (float *buffer, int width, int height, int channels, struct ColorSpace *colorspace, bool predivide)
 
void IMB_colormanagement_imbuf_to_byte_texture (unsigned char *out_buffer, const int offset_x, const int offset_y, const int width, const int height, const struct ImBuf *ibuf, const bool store_premultiplied)
 
void IMB_colormanagement_imbuf_to_float_texture (float *out_buffer, const int offset_x, const int offset_y, const int width, const int height, const struct ImBuf *ibuf, const bool store_premultiplied)
 
void IMB_colormanagement_scene_linear_to_color_picking_v3 (float color_picking[3], const float scene_linear[3])
 
void IMB_colormanagement_color_picking_to_scene_linear_v3 (float scene_linear[3], const float color_picking[3])
 
void IMB_colormanagement_scene_linear_to_display_v3 (float pixel[3], ColorManagedDisplay *display)
 
void IMB_colormanagement_display_to_scene_linear_v3 (float pixel[3], ColorManagedDisplay *display)
 
void IMB_colormanagement_pixel_to_display_space_v4 (float result[4], const float pixel[4], const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
 
void IMB_colormanagement_pixel_to_display_space_v3 (float result[3], const float pixel[3], const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
 
static void colormanagement_imbuf_make_display_space (ImBuf *ibuf, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, bool make_byte)
 
void IMB_colormanagement_imbuf_make_display_space (ImBuf *ibuf, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
 
static ImBufimbuf_ensure_editable (ImBuf *ibuf, ImBuf *colormanaged_ibuf, bool allocate_result)
 
ImBufIMB_colormanagement_imbuf_for_write (ImBuf *ibuf, bool save_as_render, bool allocate_result, const ImageFormatData *image_format)
 
Public Display Buffers Interfaces
unsigned char * IMB_display_buffer_acquire (ImBuf *ibuf, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, void **cache_handle)
 
unsigned char * IMB_display_buffer_acquire_ctx (const bContext *C, ImBuf *ibuf, void **cache_handle)
 
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, bool predivide)
 
void IMB_display_buffer_release (void *cache_handle)
 
Display Functions
const char * colormanage_display_get_default_name (void)
 
ColorManagedDisplaycolormanage_display_get_default (void)
 
ColorManagedDisplaycolormanage_display_add (const char *name)
 
ColorManagedDisplaycolormanage_display_get_named (const char *name)
 
ColorManagedDisplaycolormanage_display_get_indexed (int index)
 
int IMB_colormanagement_display_get_named_index (const char *name)
 
const char * IMB_colormanagement_display_get_indexed_name (int index)
 
const char * IMB_colormanagement_display_get_default_name (void)
 
ColorManagedDisplayIMB_colormanagement_display_get_named (const char *name)
 
const char * IMB_colormanagement_display_get_none_name (void)
 
const char * IMB_colormanagement_display_get_default_view_transform_name (struct ColorManagedDisplay *display)
 
View Functions
const char * colormanage_view_get_default_name (const ColorManagedDisplay *display)
 
ColorManagedViewcolormanage_view_get_default (const ColorManagedDisplay *display)
 
ColorManagedViewcolormanage_view_add (const char *name)
 
ColorManagedViewcolormanage_view_get_named (const char *name)
 
ColorManagedViewcolormanage_view_get_indexed (int index)
 
ColorManagedViewcolormanage_view_get_named_for_display (const char *display_name, const char *name)
 
int IMB_colormanagement_view_get_named_index (const char *name)
 
const char * IMB_colormanagement_view_get_indexed_name (int index)
 
const char * IMB_colormanagement_view_get_default_name (const char *display_name)
 
Color Space Functions
static void colormanage_description_strip (char *description)
 
ColorSpacecolormanage_colorspace_add (const char *name, const char *description, bool is_invertible, bool is_data)
 
ColorSpacecolormanage_colorspace_get_named (const char *name)
 
ColorSpacecolormanage_colorspace_get_roled (int role)
 
ColorSpacecolormanage_colorspace_get_indexed (int index)
 
int IMB_colormanagement_colorspace_get_named_index (const char *name)
 
const char * IMB_colormanagement_colorspace_get_indexed_name (int index)
 
const char * IMB_colormanagement_colorspace_get_name (const ColorSpace *colorspace)
 
void IMB_colormanagement_colorspace_from_ibuf_ftype (ColorManagedColorspaceSettings *colorspace_settings, ImBuf *ibuf)
 
Looks Functions
ColorManagedLookcolormanage_look_add (const char *name, const char *process_space, bool is_noop)
 
ColorManagedLookcolormanage_look_get_named (const char *name)
 
ColorManagedLookcolormanage_look_get_indexed (int index)
 
int IMB_colormanagement_look_get_named_index (const char *name)
 
const char * IMB_colormanagement_look_get_indexed_name (int index)
 
RNA Helper Functions
void IMB_colormanagement_display_items_add (EnumPropertyItem **items, int *totitem)
 
static void colormanagement_view_item_add (EnumPropertyItem **items, int *totitem, ColorManagedView *view)
 
void IMB_colormanagement_view_items_add (EnumPropertyItem **items, int *totitem, const char *display_name)
 
void IMB_colormanagement_look_items_add (struct EnumPropertyItem **items, int *totitem, const char *view_name)
 
void IMB_colormanagement_colorspace_items_add (EnumPropertyItem **items, int *totitem)
 
Pixel Processor Functions
ColormanageProcessorIMB_colormanagement_display_processor_new (const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
 
ColormanageProcessorIMB_colormanagement_colorspace_processor_new (const char *from_colorspace, const char *to_colorspace)
 
void IMB_colormanagement_processor_apply_v4 (ColormanageProcessor *cm_processor, float pixel[4])
 
void IMB_colormanagement_processor_apply_v4_predivide (ColormanageProcessor *cm_processor, float pixel[4])
 
void IMB_colormanagement_processor_apply_v3 (ColormanageProcessor *cm_processor, float pixel[3])
 
void IMB_colormanagement_processor_apply_pixel (struct ColormanageProcessor *cm_processor, float *pixel, int channels)
 
void IMB_colormanagement_processor_apply (ColormanageProcessor *cm_processor, float *buffer, int width, int height, int channels, bool predivide)
 
void IMB_colormanagement_processor_apply_byte (ColormanageProcessor *cm_processor, unsigned char *buffer, int width, int height, int channels)
 
void IMB_colormanagement_processor_free (ColormanageProcessor *cm_processor)
 
static void curve_mapping_to_ocio_settings (CurveMapping *curve_mapping, OCIO_CurveMappingSettings *curve_mapping_settings)
 
static OCIO_CurveMappingSettingsupdate_glsl_curve_mapping (const ColorManagedViewSettings *view_settings)
 
bool IMB_colormanagement_support_glsl_draw (const ColorManagedViewSettings *UNUSED(view_settings))
 
bool IMB_colormanagement_setup_glsl_draw_from_space (const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, struct ColorSpace *from_colorspace, float dither, bool predivide, bool do_overlay_merge)
 
bool IMB_colormanagement_setup_glsl_draw (const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, float dither, bool predivide)
 
bool IMB_colormanagement_setup_glsl_draw_from_space_ctx (const bContext *C, struct ColorSpace *from_colorspace, float dither, bool predivide)
 
bool IMB_colormanagement_setup_glsl_draw_ctx (const bContext *C, float dither, bool predivide)
 
void IMB_colormanagement_finish_glsl_draw (void)
 

Global declarations

#define DISPLAY_BUFFER_CHANNELS   4
 
typedef struct ColormanageProcessor ColormanageProcessor
 
static char global_role_data [MAX_COLORSPACE_NAME]
 
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]
 
static ListBase global_colorspaces = {NULL, NULL}
 
static ListBase global_displays = {NULL, NULL}
 
static ListBase global_views = {NULL, NULL}
 
static ListBase global_looks = {NULL, NULL}
 
static int global_tot_colorspace = 0
 
static int global_tot_display = 0
 
static int global_tot_view = 0
 
static int global_tot_looks = 0
 
float imbuf_luma_coefficients [3] = {0.0f}
 
float imbuf_scene_linear_to_xyz [3][3] = {{0.0f}}
 
float imbuf_xyz_to_scene_linear [3][3] = {{0.0f}}
 
float imbuf_scene_linear_to_rec709 [3][3] = {{0.0f}}
 
float imbuf_rec709_to_scene_linear [3][3] = {{0.0f}}
 
float imbuf_scene_linear_to_aces [3][3] = {{0.0f}}
 
float imbuf_aces_to_scene_linear [3][3] = {{0.0f}}
 
static pthread_mutex_t processor_lock = BLI_MUTEX_INITIALIZER
 
static struct global_gpu_state global_gpu_state = {false}
 
static struct global_color_picking_state global_color_picking_state = {NULL}
 

Color Managed Cache

typedef struct ColormanageCacheViewSettings ColormanageCacheViewSettings
 
typedef struct ColormanageCacheDisplaySettings ColormanageCacheDisplaySettings
 
typedef struct ColormanageCacheKey ColormanageCacheKey
 
typedef struct ColormanageCacheData ColormanageCacheData
 
typedef struct ColormanageCache ColormanageCache
 
static struct MovieCachecolormanage_moviecache_get (const ImBuf *ibuf)
 
static ColormanageCacheDatacolormanage_cachedata_get (const ImBuf *ibuf)
 
static unsigned int colormanage_hashhash (const void *key_v)
 
static bool colormanage_hashcmp (const void *av, const void *bv)
 
static struct MovieCachecolormanage_moviecache_ensure (ImBuf *ibuf)
 
static void colormanage_cachedata_set (ImBuf *ibuf, ColormanageCacheData *data)
 
static void colormanage_view_settings_to_cache (ImBuf *ibuf, ColormanageCacheViewSettings *cache_view_settings, const ColorManagedViewSettings *view_settings)
 
static void colormanage_display_settings_to_cache (ColormanageCacheDisplaySettings *cache_display_settings, const ColorManagedDisplaySettings *display_settings)
 
static void colormanage_settings_to_key (ColormanageCacheKey *key, const ColormanageCacheViewSettings *view_settings, const ColormanageCacheDisplaySettings *display_settings)
 
static ImBufcolormanage_cache_get_ibuf (ImBuf *ibuf, ColormanageCacheKey *key, void **cache_handle)
 
static unsigned char * colormanage_cache_get (ImBuf *ibuf, const ColormanageCacheViewSettings *view_settings, const ColormanageCacheDisplaySettings *display_settings, void **cache_handle)
 
static void colormanage_cache_put (ImBuf *ibuf, const ColormanageCacheViewSettings *view_settings, const ColormanageCacheDisplaySettings *display_settings, unsigned char *display_buffer, void **cache_handle)
 
static void colormanage_cache_handle_release (void *cache_handle)
 

Threaded Display Buffer Transform Routines

typedef struct DisplayBufferThread DisplayBufferThread
 
typedef struct DisplayBufferInitData DisplayBufferInitData
 
static void display_buffer_init_handle (void *handle_v, int start_line, int tot_line, void *init_data_v)
 
static void display_buffer_apply_get_linear_buffer (DisplayBufferThread *handle, int height, float *linear_buffer, bool *is_straight_alpha)
 
static voiddo_display_buffer_apply_thread (void *handle_v)
 
static void display_buffer_apply_threaded (ImBuf *ibuf, const float *buffer, unsigned char *byte_buffer, float *display_buffer, unsigned char *display_buffer_byte, ColormanageProcessor *cm_processor)
 
static bool is_ibuf_rect_in_display_space (ImBuf *ibuf, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
 
static void colormanage_display_buffer_process_ex (ImBuf *ibuf, float *display_buffer, unsigned char *display_buffer_byte, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
 
static void colormanage_display_buffer_process (ImBuf *ibuf, unsigned char *display_buffer, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
 

Threaded Processor Transform Routines

typedef struct ProcessorTransformThread ProcessorTransformThread
 
typedef struct ProcessorTransformInit ProcessorTransformInitData
 
static void processor_transform_init_handle (void *handle_v, int start_line, int tot_line, void *init_data_v)
 
static voiddo_processor_transform_thread (void *handle_v)
 
static void processor_transform_apply_threaded (unsigned char *byte_buffer, float *float_buffer, const int width, const int height, const int channels, ColormanageProcessor *cm_processor, const bool predivide, const bool float_from_byte)
 

Partial Display Buffer Update

typedef struct PartialThreadData PartialThreadData
 
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, const int xmin, const int ymin, const int xmax, const int ymax)
 
static void partial_buffer_update_rect_thread_do (void *data_v, int scanline)
 
static void imb_partial_display_buffer_update_ex (ImBuf *ibuf, const float *linear_buffer, const unsigned char *byte_buffer, int stride, int offset_x, int offset_y, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, int xmin, int ymin, int xmax, int ymax, bool do_threads)
 
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, const ColorManagedDisplaySettings *display_settings, int xmin, int ymin, int xmax, int ymax)
 
void IMB_partial_display_buffer_update_threaded (struct ImBuf *ibuf, const float *linear_buffer, const unsigned char *byte_buffer, int stride, int offset_x, int offset_y, const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings, int xmin, int ymin, int xmax, int ymax)
 
void IMB_partial_display_buffer_update_delayed (ImBuf *ibuf, int xmin, int ymin, int xmax, int ymax)
 

Rendering Tables

static const float blackbody_table_r [7][3]
 
static const float blackbody_table_g [7][3]
 
static const float blackbody_table_b [7][4]
 
static float cie_colour_match [81][3]
 
static void blackbody_temperature_to_rec709 (float rec709[3], float t)
 
void IMB_colormanagement_blackbody_temperature_to_rgb_table (float *r_table, const int width, const float min, const float max)
 
static void wavelength_to_xyz (float xyz[3], float lambda_nm)
 
void IMB_colormanagement_wavelength_to_rgb_table (float *r_table, const int width)
 

Macro Definition Documentation

◆ DISPLAY_BUFFER_CHANNELS

#define DISPLAY_BUFFER_CHANNELS   4

Definition at line 53 of file colormanagement.c.

Typedef Documentation

◆ ColormanageCache

◆ ColormanageCacheData

◆ ColormanageCacheDisplaySettings

◆ ColormanageCacheKey

◆ ColormanageCacheViewSettings

Cache Implementation Notes

All color management cache stuff is stored in two properties of image buffers:

  1. display_buffer_flags

    This is a bit field which used to mark calculated transformations for particular image buffer. Index inside of this array means index of a color managed display. Element with given index matches view transformations applied for a given display. So if bit B of array element B is set to 1, this means display buffer with display index of A and view transform of B was ever calculated for this imbuf.

    In contrast with indices in global lists of displays and views this indices are 0-based, not 1-based. This is needed to save some bytes of memory.

  2. colormanage_cache

    This is a pointer to a structure which holds all data which is needed for color management cache to work.

    It contains two parts:

    • data
    • moviecache

    Data field is used to store additional information about cached buffers which affects on whether cached buffer could be used. This data can't go to cache key because changes in this data shouldn't lead extra buffers adding to cache, it shall invalidate cached images.

    Currently such a data contains only exposure and gamma, but would likely extended further.

    data field is not null only for elements of cache, not used for original image buffers.

    Color management cache is using generic MovieCache implementation to make it easier to deal with memory limitation.

    Currently color management is using the same memory limitation pool as sequencer and clip editor are using which means color managed buffers would be removed from the cache as soon as new frames are loading for the movie clip and there's no space in cache.

    Every image buffer has got own movie cache instance, which means keys for color managed buffers could be really simple and look up in this cache would be fast and independent from overall amount of color managed images.

◆ ColormanageProcessor

◆ DisplayBufferInitData

◆ DisplayBufferThread

◆ PartialThreadData

◆ ProcessorTransformInitData

◆ ProcessorTransformThread

Function Documentation

◆ blackbody_temperature_to_rec709()

static void blackbody_temperature_to_rec709 ( float  rec709[3],
float  t 
)
static

◆ colormanage_cache_free()

void colormanage_cache_free ( ImBuf ibuf)

◆ colormanage_cache_get()

static unsigned char* colormanage_cache_get ( ImBuf ibuf,
const ColormanageCacheViewSettings view_settings,
const ColormanageCacheDisplaySettings display_settings,
void **  cache_handle 
)
static

◆ colormanage_cache_get_ibuf()

static ImBuf* colormanage_cache_get_ibuf ( ImBuf ibuf,
ColormanageCacheKey key,
void **  cache_handle 
)
static

Definition at line 317 of file colormanagement.c.

References colormanage_moviecache_get(), IMB_moviecache_get(), and NULL.

Referenced by colormanage_cache_get().

◆ colormanage_cache_handle_release()

static void colormanage_cache_handle_release ( void cache_handle)
static

Definition at line 436 of file colormanagement.c.

References IMB_freeImBuf().

Referenced by IMB_display_buffer_release().

◆ colormanage_cache_put()

static void colormanage_cache_put ( ImBuf ibuf,
const ColormanageCacheViewSettings view_settings,
const ColormanageCacheDisplaySettings display_settings,
unsigned char *  display_buffer,
void **  cache_handle 
)
static

◆ colormanage_cachedata_get()

static ColormanageCacheData* colormanage_cachedata_get ( const ImBuf ibuf)
static

◆ colormanage_cachedata_set()

static void colormanage_cachedata_set ( ImBuf ibuf,
ColormanageCacheData data 
)
static

Definition at line 275 of file colormanagement.c.

References ImBuf::colormanage_cache, data, ColormanageCache::data, and MEM_callocN.

Referenced by colormanage_cache_put().

◆ colormanage_check_colorspace_settings()

static void colormanage_check_colorspace_settings ( ColorManagedColorspaceSettings colorspace_settings,
const char *  what 
)
static

◆ colormanage_check_display_settings()

static void colormanage_check_display_settings ( ColorManagedDisplaySettings display_settings,
const char *  what,
const ColorManagedDisplay default_display 
)
static

◆ colormanage_check_view_settings()

static void colormanage_check_view_settings ( ColorManagedDisplaySettings display_settings,
ColorManagedViewSettings view_settings,
const char *  what 
)
static

◆ colormanage_colorspace_add()

ColorSpace* colormanage_colorspace_add ( const char *  name,
const char *  description,
bool  is_invertible,
bool  is_data 
)

◆ colormanage_colorspace_get_indexed()

ColorSpace* colormanage_colorspace_get_indexed ( int  index)

◆ colormanage_colorspace_get_named()

ColorSpace* colormanage_colorspace_get_named ( const char *  name)

◆ colormanage_colorspace_get_roled()

ColorSpace* colormanage_colorspace_get_roled ( int  role)

◆ colormanage_compatible_look()

static bool colormanage_compatible_look ( ColorManagedLook look,
const char *  view_name 
)
static

◆ colormanage_description_strip()

static void colormanage_description_strip ( char *  description)
static

Definition at line 3054 of file colormanagement.c.

References ELEM.

Referenced by colormanage_colorspace_add().

◆ colormanage_display_add()

ColorManagedDisplay* colormanage_display_add ( const char *  name)

◆ colormanage_display_buffer_process()

static void colormanage_display_buffer_process ( ImBuf ibuf,
unsigned char *  display_buffer,
const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings 
)
static

Definition at line 1796 of file colormanagement.c.

References colormanage_display_buffer_process_ex(), and NULL.

Referenced by IMB_display_buffer_acquire().

◆ colormanage_display_buffer_process_ex()

static void colormanage_display_buffer_process_ex ( ImBuf ibuf,
float display_buffer,
unsigned char *  display_buffer_byte,
const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings 
)
static

◆ colormanage_display_get_default()

ColorManagedDisplay* colormanage_display_get_default ( void  )

◆ colormanage_display_get_default_name()

const char* colormanage_display_get_default_name ( void  )

◆ colormanage_display_get_indexed()

ColorManagedDisplay* colormanage_display_get_indexed ( int  index)

Definition at line 2871 of file colormanagement.c.

References BLI_findlink(), and global_displays.

Referenced by IMB_colormanagement_display_get_indexed_name().

◆ colormanage_display_get_named()

ColorManagedDisplay* colormanage_display_get_named ( const char *  name)

◆ colormanage_display_settings_to_cache()

static void colormanage_display_settings_to_cache ( ColormanageCacheDisplaySettings cache_display_settings,
const ColorManagedDisplaySettings display_settings 
)
static

◆ colormanage_ensure_srgb_scene_linear_info()

static void colormanage_ensure_srgb_scene_linear_info ( ColorSpace colorspace)
static

◆ colormanage_free_config()

static void colormanage_free_config ( void  )
static

◆ colormanage_hashcmp()

static bool colormanage_hashcmp ( const void av,
const void bv 
)
static

Definition at line 247 of file colormanagement.c.

References Freestyle::a, and usdtokens::b().

Referenced by colormanage_moviecache_ensure().

◆ colormanage_hashhash()

static unsigned int colormanage_hashhash ( const void key_v)
static

◆ colormanage_imbuf_make_linear()

void colormanage_imbuf_make_linear ( ImBuf ibuf,
const char *  from_colorspace 
)

◆ colormanage_imbuf_set_default_spaces()

void colormanage_imbuf_set_default_spaces ( ImBuf ibuf)

◆ colormanage_load_config()

static void colormanage_load_config ( OCIO_ConstConfigRcPtr *  config)
static

Definition at line 474 of file colormanagement.c.

References ColorSpace::aliases, BLI_addtail(), BLI_genericNodeN(), BLI_strncpy(), colormanage_colorspace_add(), colormanage_display_add(), colormanage_look_add(), colormanage_role_color_space_name_get(), colormanage_view_add(), colormanage_view_get_named(), global_role_color_picking, global_role_data, global_role_default_byte, global_role_default_float, global_role_default_sequencer, global_role_scene_linear, global_role_texture_painting, global_tot_display, imbuf_aces_to_scene_linear, imbuf_luma_coefficients, imbuf_rec709_to_scene_linear, imbuf_scene_linear_to_aces, imbuf_scene_linear_to_rec709, imbuf_scene_linear_to_xyz, imbuf_xyz_to_scene_linear, invert_m3_m3(), MAX_COLORSPACE_NAME, MEM_callocN, mul_m3_m3m3(), MovieCache::name, NULL, ColorSpace::num_aliases, OCIO_ACES_TO_XYZ, OCIO_colorSpaceGetAlias(), OCIO_colorSpaceGetDescription(), OCIO_colorSpaceGetNumAliases(), OCIO_colorSpaceIsData(), OCIO_colorSpaceIsInvertible(), OCIO_colorSpaceRelease(), OCIO_configGetColorSpace(), OCIO_configGetColorSpaceNameByIndex(), OCIO_configGetDefaultLumaCoefs(), OCIO_configGetDisplay(), OCIO_configGetLook(), OCIO_configGetLookNameByIndex(), OCIO_configGetNumColorSpaces(), OCIO_configGetNumDisplays(), OCIO_configGetNumLooks(), OCIO_configGetNumViews(), OCIO_configGetView(), OCIO_configGetXYZtoSceneLinear(), OCIO_lookGetProcessSpace(), OCIO_lookRelease(), OCIO_ROLE_COLOR_PICKING, OCIO_ROLE_DATA, OCIO_ROLE_DEFAULT_BYTE, OCIO_ROLE_DEFAULT_FLOAT, OCIO_ROLE_DEFAULT_SEQUENCER, OCIO_ROLE_SCENE_LINEAR, OCIO_ROLE_TEXTURE_PAINT, OCIO_XYZ_TO_REC709, view, and ColorManagedDisplay::views.

Referenced by colormanagement_init().

◆ colormanage_look_add()

ColorManagedLook* colormanage_look_add ( const char *  name,
const char *  process_space,
bool  is_noop 
)

◆ colormanage_look_get_indexed()

ColorManagedLook* colormanage_look_get_indexed ( int  index)

Definition at line 3249 of file colormanagement.c.

References BLI_findlink(), and global_looks.

Referenced by IMB_colormanagement_look_get_indexed_name().

◆ colormanage_look_get_named()

ColorManagedLook* colormanage_look_get_named ( const char *  name)

◆ colormanage_moviecache_ensure()

static struct MovieCache* colormanage_moviecache_ensure ( ImBuf ibuf)
static

◆ colormanage_moviecache_get()

static struct MovieCache* colormanage_moviecache_get ( const ImBuf ibuf)
static

◆ colormanage_role_color_space_name_get()

static void colormanage_role_color_space_name_get ( OCIO_ConstConfigRcPtr *  config,
char *  colorspace_name,
const char *  role,
const char *  backup_role 
)
static

◆ colormanage_settings_to_key()

static void colormanage_settings_to_key ( ColormanageCacheKey key,
const ColormanageCacheViewSettings view_settings,
const ColormanageCacheDisplaySettings display_settings 
)
static

◆ colormanage_use_look()

static bool colormanage_use_look ( const char *  look,
const char *  view_name 
)
static

◆ colormanage_view_add()

ColorManagedView* colormanage_view_add ( const char *  name)

◆ colormanage_view_get_default()

ColorManagedView* colormanage_view_get_default ( const ColorManagedDisplay display)

◆ colormanage_view_get_default_name()

const char* colormanage_view_get_default_name ( const ColorManagedDisplay display)

◆ colormanage_view_get_indexed()

ColorManagedView* colormanage_view_get_indexed ( int  index)

Definition at line 2988 of file colormanagement.c.

References BLI_findlink(), and global_views.

Referenced by IMB_colormanagement_view_get_indexed_name().

◆ colormanage_view_get_named()

ColorManagedView* colormanage_view_get_named ( const char *  name)

◆ colormanage_view_get_named_for_display()

ColorManagedView* colormanage_view_get_named_for_display ( const char *  display_name,
const char *  name 
)

◆ colormanage_view_settings_to_cache()

static void colormanage_view_settings_to_cache ( ImBuf ibuf,
ColormanageCacheViewSettings cache_view_settings,
const ColorManagedViewSettings view_settings 
)
static

◆ colormanagement_exit()

void colormanagement_exit ( void  )

◆ colormanagement_imbuf_make_display_space()

static void colormanagement_imbuf_make_display_space ( ImBuf ibuf,
const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings,
bool  make_byte 
)
static

◆ colormanagement_init()

void colormanagement_init ( void  )

◆ colormanagement_transform_ex()

static void colormanagement_transform_ex ( unsigned char *  byte_buffer,
float float_buffer,
int  width,
int  height,
int  channels,
const char *  from_colorspace,
const char *  to_colorspace,
bool  predivide,
bool  do_threaded 
)
static

◆ colormanagement_view_item_add()

static void colormanagement_view_item_add ( EnumPropertyItem **  items,
int *  totitem,
ColorManagedView view 
)
static

◆ colorspace_from_scene_linear_cpu_processor()

static OCIO_ConstCPUProcessorRcPtr* colorspace_from_scene_linear_cpu_processor ( ColorSpace colorspace)
static

◆ colorspace_set_default_role()

void colorspace_set_default_role ( char *  colorspace,
int  size,
int  role 
)

◆ colorspace_to_scene_linear_cpu_processor()

static OCIO_ConstCPUProcessorRcPtr* colorspace_to_scene_linear_cpu_processor ( ColorSpace colorspace)
static

◆ create_colorspace_transform_processor()

static OCIO_ConstProcessorRcPtr* create_colorspace_transform_processor ( const char *  from_colorspace,
const char *  to_colorspace 
)
static

◆ create_display_buffer_processor()

static OCIO_ConstCPUProcessorRcPtr* create_display_buffer_processor ( const char *  look,
const char *  view_transform,
const char *  display,
float  exposure,
float  gamma,
const char *  from_colorspace 
)
static

◆ curve_mapping_apply_pixel()

static void curve_mapping_apply_pixel ( CurveMapping curve_mapping,
float pixel,
int  channels 
)
static

◆ curve_mapping_to_ocio_settings()

static void curve_mapping_to_ocio_settings ( CurveMapping curve_mapping,
OCIO_CurveMappingSettings curve_mapping_settings 
)
static

◆ display_buffer_apply_get_linear_buffer()

static void display_buffer_apply_get_linear_buffer ( DisplayBufferThread handle,
int  height,
float linear_buffer,
bool is_straight_alpha 
)
static

◆ display_buffer_apply_threaded()

static void display_buffer_apply_threaded ( ImBuf ibuf,
const float buffer,
unsigned char *  byte_buffer,
float display_buffer,
unsigned char *  display_buffer_byte,
ColormanageProcessor cm_processor 
)
static

◆ display_buffer_init_handle()

static void display_buffer_init_handle ( void handle_v,
int  start_line,
int  tot_line,
void init_data_v 
)
static

◆ display_from_scene_linear_processor()

static OCIO_ConstCPUProcessorRcPtr* display_from_scene_linear_processor ( ColorManagedDisplay display)
static

◆ display_to_scene_linear_processor()

static OCIO_ConstCPUProcessorRcPtr* display_to_scene_linear_processor ( ColorManagedDisplay display)
static

◆ display_transform_get_colorspace()

static ColorSpace* display_transform_get_colorspace ( const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings 
)
static

◆ do_display_buffer_apply_thread()

static void* do_display_buffer_apply_thread ( void handle_v)
static

◆ do_processor_transform_thread()

static void* do_processor_transform_thread ( void handle_v)
static

◆ get_display_colorspace_name()

static const char* get_display_colorspace_name ( const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings 
)
static

◆ IMB_colormanagegent_copy_settings()

void IMB_colormanagegent_copy_settings ( ImBuf ibuf_src,
ImBuf ibuf_dst 
)

◆ IMB_colormanagement_assign_float_colorspace()

void IMB_colormanagement_assign_float_colorspace ( ImBuf ibuf,
const char *  name 
)

◆ IMB_colormanagement_assign_rect_colorspace()

void IMB_colormanagement_assign_rect_colorspace ( ImBuf ibuf,
const char *  name 
)

◆ IMB_colormanagement_blackbody_temperature_to_rgb_table()

void IMB_colormanagement_blackbody_temperature_to_rgb_table ( float r_table,
const int  width,
const float  min,
const float  max 
)

◆ IMB_colormanagement_check_file_config()

void IMB_colormanagement_check_file_config ( Main bmain)

◆ IMB_colormanagement_check_is_data()

void IMB_colormanagement_check_is_data ( ImBuf ibuf,
const char *  name 
)

◆ IMB_colormanagement_color_picking_to_scene_linear_v3()

void IMB_colormanagement_color_picking_to_scene_linear_v3 ( float  scene_linear[3],
const float  color_picking[3] 
)

◆ IMB_colormanagement_colorspace_from_ibuf_ftype()

void IMB_colormanagement_colorspace_from_ibuf_ftype ( ColorManagedColorspaceSettings colorspace_settings,
ImBuf ibuf 
)

◆ IMB_colormanagement_colorspace_get_indexed_name()

const char* IMB_colormanagement_colorspace_get_indexed_name ( int  index)

Definition at line 3165 of file colormanagement.c.

References colormanage_colorspace_get_indexed(), and ColorSpace::name.

◆ IMB_colormanagement_colorspace_get_name()

const char* IMB_colormanagement_colorspace_get_name ( const ColorSpace colorspace)

Definition at line 3178 of file colormanagement.c.

References ColorSpace::name.

◆ IMB_colormanagement_colorspace_get_named_index()

int IMB_colormanagement_colorspace_get_named_index ( const char *  name)

◆ IMB_colormanagement_colorspace_items_add()

void IMB_colormanagement_colorspace_items_add ( EnumPropertyItem **  items,
int *  totitem 
)

◆ IMB_colormanagement_colorspace_processor_new()

ColormanageProcessor* IMB_colormanagement_colorspace_processor_new ( const char *  from_colorspace,
const char *  to_colorspace 
)

◆ IMB_colormanagement_colorspace_to_scene_linear()

void IMB_colormanagement_colorspace_to_scene_linear ( float buffer,
int  width,
int  height,
int  channels,
struct ColorSpace colorspace,
bool  predivide 
)

◆ IMB_colormanagement_colorspace_to_scene_linear_v3()

void IMB_colormanagement_colorspace_to_scene_linear_v3 ( float  pixel[3],
struct ColorSpace colorspace 
)

◆ IMB_colormanagement_colorspace_to_scene_linear_v4()

void IMB_colormanagement_colorspace_to_scene_linear_v4 ( float  pixel[4],
bool  predivide,
ColorSpace colorspace 
)

◆ IMB_colormanagement_display_get_default_name()

const char* IMB_colormanagement_display_get_default_name ( void  )

◆ IMB_colormanagement_display_get_default_view_transform_name()

const char* IMB_colormanagement_display_get_default_view_transform_name ( struct ColorManagedDisplay display)

◆ IMB_colormanagement_display_get_indexed_name()

const char* IMB_colormanagement_display_get_indexed_name ( int  index)

◆ IMB_colormanagement_display_get_named()

ColorManagedDisplay* IMB_colormanagement_display_get_named ( const char *  name)

◆ IMB_colormanagement_display_get_named_index()

int IMB_colormanagement_display_get_named_index ( const char *  name)

◆ IMB_colormanagement_display_get_none_name()

const char* IMB_colormanagement_display_get_none_name ( void  )

◆ IMB_colormanagement_display_items_add()

void IMB_colormanagement_display_items_add ( EnumPropertyItem **  items,
int *  totitem 
)

◆ IMB_colormanagement_display_processor_new()

ColormanageProcessor* IMB_colormanagement_display_processor_new ( const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings 
)

◆ IMB_colormanagement_display_settings_from_ctx()

void IMB_colormanagement_display_settings_from_ctx ( const bContext C,
ColorManagedViewSettings **  r_view_settings,
ColorManagedDisplaySettings **  r_display_settings 
)

◆ IMB_colormanagement_display_to_scene_linear_v3()

void IMB_colormanagement_display_to_scene_linear_v3 ( float  pixel[3],
struct ColorManagedDisplay display 
)

◆ IMB_colormanagement_finish_glsl_draw()

void IMB_colormanagement_finish_glsl_draw ( void  )

◆ IMB_colormanagement_get_float_colorspace()

const char* IMB_colormanagement_get_float_colorspace ( ImBuf ibuf)

◆ IMB_colormanagement_get_rect_colorspace()

const char* IMB_colormanagement_get_rect_colorspace ( ImBuf ibuf)

◆ IMB_colormanagement_get_xyz_to_scene_linear()

const float* IMB_colormanagement_get_xyz_to_scene_linear ( void  )

Definition at line 1429 of file colormanagement.c.

References imbuf_xyz_to_scene_linear.

Referenced by get_XYZ_to_RGB_for_gpu().

◆ IMB_colormanagement_imbuf_for_write()

ImBuf* IMB_colormanagement_imbuf_for_write ( ImBuf ibuf,
bool  save_as_render,
bool  allocate_result,
const ImageFormatData image_format 
)

◆ IMB_colormanagement_imbuf_make_display_space()

void IMB_colormanagement_imbuf_make_display_space ( ImBuf ibuf,
const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings 
)

Definition at line 2464 of file colormanagement.c.

References colormanagement_imbuf_make_display_space().

◆ IMB_colormanagement_imbuf_to_byte_texture()

void IMB_colormanagement_imbuf_to_byte_texture ( unsigned char *  out_buffer,
const int  offset_x,
const int  offset_y,
const int  width,
const int  height,
const struct ImBuf ibuf,
const bool  store_premultiplied 
)

◆ IMB_colormanagement_imbuf_to_float_texture()

void IMB_colormanagement_imbuf_to_float_texture ( float out_buffer,
const int  offset_x,
const int  offset_y,
const int  width,
const int  height,
const struct ImBuf ibuf,
const bool  store_premultiplied 
)

◆ IMB_colormanagement_init_default_view_settings()

void IMB_colormanagement_init_default_view_settings ( ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings 
)

◆ IMB_colormanagement_look_get_indexed_name()

const char* IMB_colormanagement_look_get_indexed_name ( int  index)

Definition at line 3268 of file colormanagement.c.

References colormanage_look_get_indexed(), ColorManagedLook::name, and NULL.

◆ IMB_colormanagement_look_get_named_index()

int IMB_colormanagement_look_get_named_index ( const char *  name)

◆ IMB_colormanagement_look_items_add()

void IMB_colormanagement_look_items_add ( struct EnumPropertyItem **  items,
int *  totitem,
const char *  view_name 
)

◆ IMB_colormanagement_pixel_to_display_space_v3()

void IMB_colormanagement_pixel_to_display_space_v3 ( float  result[3],
const float  pixel[3],
const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings 
)

◆ IMB_colormanagement_pixel_to_display_space_v4()

void IMB_colormanagement_pixel_to_display_space_v4 ( float  result[4],
const float  pixel[4],
const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings 
)

◆ IMB_colormanagement_processor_apply()

void IMB_colormanagement_processor_apply ( ColormanageProcessor cm_processor,
float buffer,
int  width,
int  height,
int  channels,
bool  predivide 
)

◆ IMB_colormanagement_processor_apply_byte()

void IMB_colormanagement_processor_apply_byte ( ColormanageProcessor cm_processor,
unsigned char *  buffer,
int  width,
int  height,
int  channels 
)

◆ IMB_colormanagement_processor_apply_pixel()

void IMB_colormanagement_processor_apply_pixel ( struct ColormanageProcessor cm_processor,
float pixel,
int  channels 
)

◆ IMB_colormanagement_processor_apply_v3()

void IMB_colormanagement_processor_apply_v3 ( ColormanageProcessor cm_processor,
float  pixel[3] 
)

◆ IMB_colormanagement_processor_apply_v4()

void IMB_colormanagement_processor_apply_v4 ( ColormanageProcessor cm_processor,
float  pixel[4] 
)

◆ IMB_colormanagement_processor_apply_v4_predivide()

void IMB_colormanagement_processor_apply_v4_predivide ( ColormanageProcessor cm_processor,
float  pixel[4] 
)

◆ IMB_colormanagement_processor_free()

void IMB_colormanagement_processor_free ( ColormanageProcessor cm_processor)

◆ IMB_colormanagement_role_colorspace_name_get()

const char* IMB_colormanagement_role_colorspace_name_get ( int  role)

◆ IMB_colormanagement_scene_linear_to_color_picking_v3()

void IMB_colormanagement_scene_linear_to_color_picking_v3 ( float  color_picking[3],
const float  scene_linear[3] 
)

Conversion between color picking role. Typically we would expect such a requirements:

  • It is approximately perceptually linear, so that the HSV numbers and the HSV cube/circle have an intuitive distribution.
  • It has the same gamut as the scene linear color space.
  • Color picking values 0..1 map to scene linear values in the 0..1 range, so that picked albedo values are energy conserving.

Definition at line 2342 of file colormanagement.c.

References BLI_mutex_lock(), BLI_mutex_unlock(), copy_v3_v3(), global_color_picking_state::cpu_processor_to, create_colorspace_transform_processor(), global_color_picking_state::failed, global_role_color_picking, global_role_scene_linear, NULL, OCIO_cpuProcessorApplyRGB(), OCIO_processorGetCPUProcessor(), OCIO_processorRelease(), and processor_lock.

Referenced by ui_scene_linear_to_perceptual_space().

◆ IMB_colormanagement_scene_linear_to_colorspace_v3()

void IMB_colormanagement_scene_linear_to_colorspace_v3 ( float  pixel[3],
struct ColorSpace colorspace 
)

◆ IMB_colormanagement_scene_linear_to_display_v3()

void IMB_colormanagement_scene_linear_to_display_v3 ( float  pixel[3],
struct ColorManagedDisplay display 
)

Convert pixel from scene linear to display space using default view used by performance-critical areas such as color-related widgets where we want to reduce amount of per-widget allocations.

Definition at line 2402 of file colormanagement.c.

References display_from_scene_linear_processor(), NULL, and OCIO_cpuProcessorApplyRGB().

Referenced by brush_painter_imbuf_new(), brush_painter_imbuf_update(), eyedropper_color_set(), eyedropper_gpencil_color_set(), ui_block_cm_to_display_space_v3(), ui_draw_but_COLORBAND(), and ui_draw_colorband_handle().

◆ IMB_colormanagement_setup_glsl_draw()

bool IMB_colormanagement_setup_glsl_draw ( const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings,
float  dither,
bool  predivide 
)

Definition at line 4105 of file colormanagement.c.

References IMB_colormanagement_setup_glsl_draw_from_space(), and NULL.

◆ IMB_colormanagement_setup_glsl_draw_ctx()

bool IMB_colormanagement_setup_glsl_draw_ctx ( const bContext C,
float  dither,
bool  predivide 
)

Definition at line 4128 of file colormanagement.c.

References C, IMB_colormanagement_setup_glsl_draw_from_space_ctx(), and NULL.

◆ IMB_colormanagement_setup_glsl_draw_from_space()

bool IMB_colormanagement_setup_glsl_draw_from_space ( const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings,
struct ColorSpace from_colorspace,
float  dither,
bool  predivide,
bool  do_overlay_merge 
)

◆ IMB_colormanagement_setup_glsl_draw_from_space_ctx()

bool IMB_colormanagement_setup_glsl_draw_from_space_ctx ( const bContext C,
struct ColorSpace from_colorspace,
float  dither,
bool  predivide 
)

◆ IMB_colormanagement_space_is_data()

bool IMB_colormanagement_space_is_data ( ColorSpace colorspace)

Definition at line 1375 of file colormanagement.c.

Referenced by IMB_colormanagement_imbuf_to_byte_texture().

◆ IMB_colormanagement_space_is_scene_linear()

bool IMB_colormanagement_space_is_scene_linear ( ColorSpace colorspace)

◆ IMB_colormanagement_space_is_srgb()

bool IMB_colormanagement_space_is_srgb ( ColorSpace colorspace)

◆ IMB_colormanagement_space_name_is_data()

bool IMB_colormanagement_space_name_is_data ( const char *  name)

◆ IMB_colormanagement_space_name_is_scene_linear()

bool IMB_colormanagement_space_name_is_scene_linear ( const char *  name)

◆ IMB_colormanagement_space_name_is_srgb()

bool IMB_colormanagement_space_name_is_srgb ( const char *  name)

◆ IMB_colormanagement_support_glsl_draw()

bool IMB_colormanagement_support_glsl_draw ( const ColorManagedViewSettings UNUSEDview_settings)

Definition at line 4043 of file colormanagement.c.

References OCIO_supportGPUShader().

◆ IMB_colormanagement_transform()

void IMB_colormanagement_transform ( float buffer,
int  width,
int  height,
int  channels,
const char *  from_colorspace,
const char *  to_colorspace,
bool  predivide 
)

◆ IMB_colormanagement_transform_byte()

void IMB_colormanagement_transform_byte ( unsigned char *  buffer,
int  width,
int  height,
int  channels,
const char *  from_colorspace,
const char *  to_colorspace 
)

Similar to IMB_colormanagement_transform_threaded, but operates on byte buffer.

Definition at line 2011 of file colormanagement.c.

References buffer, channels(), colormanagement_transform_ex(), height, NULL, and width.

◆ IMB_colormanagement_transform_byte_threaded()

void IMB_colormanagement_transform_byte_threaded ( unsigned char *  buffer,
int  width,
int  height,
int  channels,
const char *  from_colorspace,
const char *  to_colorspace 
)

◆ IMB_colormanagement_transform_from_byte()

void IMB_colormanagement_transform_from_byte ( float float_buffer,
unsigned char *  byte_buffer,
int  width,
int  height,
int  channels,
const char *  from_colorspace,
const char *  to_colorspace 
)

Similar to IMB_colormanagement_transform_byte_threaded, but gets float buffer from display one.

Definition at line 2032 of file colormanagement.c.

References channels(), height, IB_PROFILE_SRGB, IMB_buffer_float_from_byte(), IMB_colormanagement_transform(), and width.

◆ IMB_colormanagement_transform_from_byte_threaded()

void IMB_colormanagement_transform_from_byte_threaded ( float float_buffer,
unsigned char *  byte_buffer,
int  width,
int  height,
int  channels,
const char *  from_colorspace,
const char *  to_colorspace 
)

◆ IMB_colormanagement_transform_threaded()

void IMB_colormanagement_transform_threaded ( float buffer,
int  width,
int  height,
int  channels,
const char *  from_colorspace,
const char *  to_colorspace,
bool  predivide 
)

Convert the whole buffer from specified by name color space to another will do threaded conversion.

Definition at line 1999 of file colormanagement.c.

References buffer, channels(), colormanagement_transform_ex(), height, NULL, and width.

Referenced by seq_imbuf_to_sequencer_space(), and SEQ_render_imbuf_from_sequencer_space().

◆ IMB_colormanagement_transform_v4()

void IMB_colormanagement_transform_v4 ( float  pixel[4],
const char *  from_colorspace,
const char *  to_colorspace 
)

◆ IMB_colormanagement_validate_settings()

void IMB_colormanagement_validate_settings ( const ColorManagedDisplaySettings display_settings,
ColorManagedViewSettings view_settings 
)

◆ IMB_colormanagement_view_get_default_name()

const char* IMB_colormanagement_view_get_default_name ( const char *  display_name)

◆ IMB_colormanagement_view_get_indexed_name()

const char* IMB_colormanagement_view_get_indexed_name ( int  index)

Definition at line 3021 of file colormanagement.c.

References colormanage_view_get_indexed(), NULL, and view.

◆ IMB_colormanagement_view_get_named_index()

int IMB_colormanagement_view_get_named_index ( const char *  name)

Definition at line 3010 of file colormanagement.c.

References colormanage_view_get_named(), and view.

Referenced by colormanage_view_settings_to_cache().

◆ IMB_colormanagement_view_items_add()

void IMB_colormanagement_view_items_add ( EnumPropertyItem **  items,
int *  totitem,
const char *  display_name 
)

◆ IMB_colormanagement_wavelength_to_rgb_table()

void IMB_colormanagement_wavelength_to_rgb_table ( float r_table,
const int  width 
)

◆ IMB_display_buffer_acquire()

unsigned char* IMB_display_buffer_acquire ( ImBuf ibuf,
const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings,
void **  cache_handle 
)

◆ IMB_display_buffer_acquire_ctx()

unsigned char* IMB_display_buffer_acquire_ctx ( const bContext C,
ImBuf ibuf,
void **  cache_handle 
)

◆ IMB_display_buffer_release()

void IMB_display_buffer_release ( void cache_handle)

◆ IMB_display_buffer_transform_apply()

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,
bool  predivide 
)

◆ IMB_partial_display_buffer_update()

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,
const ColorManagedDisplaySettings display_settings,
int  xmin,
int  ymin,
int  xmax,
int  ymax 
)

Definition at line 3690 of file colormanagement.c.

References imb_partial_display_buffer_update_ex(), and stride.

◆ IMB_partial_display_buffer_update_delayed()

void IMB_partial_display_buffer_update_delayed ( ImBuf ibuf,
int  xmin,
int  ymin,
int  xmax,
int  ymax 
)

◆ imb_partial_display_buffer_update_ex()

static void imb_partial_display_buffer_update_ex ( ImBuf ibuf,
const float linear_buffer,
const unsigned char *  byte_buffer,
int  stride,
int  offset_x,
int  offset_y,
const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings,
int  xmin,
int  ymin,
int  xmax,
int  ymax,
bool  do_threads 
)
static

◆ IMB_partial_display_buffer_update_threaded()

void IMB_partial_display_buffer_update_threaded ( struct ImBuf ibuf,
const float linear_buffer,
const unsigned char *  byte_buffer,
int  stride,
int  offset_x,
int  offset_y,
const struct ColorManagedViewSettings view_settings,
const struct ColorManagedDisplaySettings display_settings,
int  xmin,
int  ymin,
int  xmax,
int  ymax 
)

Definition at line 3718 of file colormanagement.c.

References height, imb_partial_display_buffer_update_ex(), stride, and width.

Referenced by IMB_display_buffer_acquire().

◆ imbuf_ensure_editable()

static ImBuf* imbuf_ensure_editable ( ImBuf ibuf,
ImBuf colormanaged_ibuf,
bool  allocate_result 
)
static

◆ is_ibuf_rect_in_display_space()

static bool is_ibuf_rect_in_display_space ( ImBuf ibuf,
const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings 
)
static

◆ partial_buffer_update_rect()

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,
const int  xmin,
const int  ymin,
const int  xmax,
const int  ymax 
)
static

◆ partial_buffer_update_rect_thread_do()

static void partial_buffer_update_rect_thread_do ( void data_v,
int  scanline 
)
static

Definition at line 3560 of file colormanagement.c.

References data, and partial_buffer_update_rect().

Referenced by imb_partial_display_buffer_update_ex().

◆ processor_transform_apply_threaded()

static void processor_transform_apply_threaded ( unsigned char *  byte_buffer,
float float_buffer,
const int  width,
const int  height,
const int  channels,
ColormanageProcessor cm_processor,
const bool  predivide,
const bool  float_from_byte 
)
static

◆ processor_transform_init_handle()

static void processor_transform_init_handle ( void handle_v,
int  start_line,
int  tot_line,
void init_data_v 
)
static

◆ seq_callback()

static bool seq_callback ( Sequence seq,
void UNUSEDuser_data 
)
static

◆ update_glsl_curve_mapping()

static OCIO_CurveMappingSettings* update_glsl_curve_mapping ( const ColorManagedViewSettings view_settings)
static

◆ wavelength_to_xyz()

static void wavelength_to_xyz ( float  xyz[3],
float  lambda_nm 
)
static

Definition at line 4272 of file colormanagement.c.

References Freestyle::c, cie_colour_match, and float().

Referenced by IMB_colormanagement_wavelength_to_rgb_table().

Variable Documentation

◆ blackbody_table_b

const float blackbody_table_b[7][4]
static
Initial value:
= {
{5.96945309e-11f, -4.85742887e-08f, -9.70622247e-05f, -4.07936148e-03f},
{2.40430366e-11f, 5.55021075e-08f, -1.98503712e-04f, 2.89312858e-02f},
{-1.40949732e-11f, 1.89878968e-07f, -3.56632824e-04f, 9.10767778e-02f},
{-3.61460868e-11f, 2.84822009e-07f, -4.93211319e-04f, 1.56723440e-01f},
{-1.97075738e-11f, 1.75359352e-07f, -2.50542825e-04f, -2.22783266e-02f},
{-1.61997957e-13f, -1.64216008e-08f, 3.86216271e-04f, -7.38077418e-01f},
{6.72650283e-13f, -2.73078809e-08f, 4.24098264e-04f, -7.52335691e-01f}}

Definition at line 4170 of file colormanagement.c.

Referenced by blackbody_temperature_to_rec709().

◆ blackbody_table_g

const float blackbody_table_g[7][3]
static
Initial value:
= {
{-4.88999748e+02f, 6.04330754e-04f, -7.55807526e-02f},
{-7.55994277e+02f, 3.16730098e-04f, 4.78306139e-01f},
{-1.02363977e+03f, 1.20223470e-04f, 9.36662319e-01f},
{-1.26571316e+03f, 4.87340896e-06f, 1.27054498e+00f},
{-1.42529332e+03f, -4.01150431e-05f, 1.43972784e+00f},
{-1.17554822e+03f, -2.16378048e-05f, 1.30408023e+00f},
{-5.00799571e+02f, -4.59832026e-06f, 1.09098763e+00f}}

Definition at line 4161 of file colormanagement.c.

Referenced by blackbody_temperature_to_rec709().

◆ blackbody_table_r

const float blackbody_table_r[7][3]
static
Initial value:
= {{1.61919106e+03f, -2.05010916e-03f, 5.02995757e+00f},
{2.48845471e+03f, -1.11330907e-03f, 3.22621544e+00f},
{3.34143193e+03f, -4.86551192e-04f, 1.76486769e+00f},
{4.09461742e+03f, -1.27446582e-04f, 7.25731635e-01f},
{4.67028036e+03f, 2.91258199e-05f, 1.26703442e-01f},
{4.59509185e+03f, 2.87495649e-05f, 1.50345020e-01f},
{3.78717450e+03f, 9.35907826e-06f, 3.99075871e-01f}}

Definition at line 4153 of file colormanagement.c.

Referenced by blackbody_temperature_to_rec709().

◆ cie_colour_match

float cie_colour_match[81][3]
static
Initial value:
= {
{0.0014f, 0.0000f, 0.0065f}, {0.0022f, 0.0001f, 0.0105f}, {0.0042f, 0.0001f, 0.0201f},
{0.0076f, 0.0002f, 0.0362f}, {0.0143f, 0.0004f, 0.0679f}, {0.0232f, 0.0006f, 0.1102f},
{0.0435f, 0.0012f, 0.2074f}, {0.0776f, 0.0022f, 0.3713f}, {0.1344f, 0.0040f, 0.6456f},
{0.2148f, 0.0073f, 1.0391f}, {0.2839f, 0.0116f, 1.3856f}, {0.3285f, 0.0168f, 1.6230f},
{0.3483f, 0.0230f, 1.7471f}, {0.3481f, 0.0298f, 1.7826f}, {0.3362f, 0.0380f, 1.7721f},
{0.3187f, 0.0480f, 1.7441f}, {0.2908f, 0.0600f, 1.6692f}, {0.2511f, 0.0739f, 1.5281f},
{0.1954f, 0.0910f, 1.2876f}, {0.1421f, 0.1126f, 1.0419f}, {0.0956f, 0.1390f, 0.8130f},
{0.0580f, 0.1693f, 0.6162f}, {0.0320f, 0.2080f, 0.4652f}, {0.0147f, 0.2586f, 0.3533f},
{0.0049f, 0.3230f, 0.2720f}, {0.0024f, 0.4073f, 0.2123f}, {0.0093f, 0.5030f, 0.1582f},
{0.0291f, 0.6082f, 0.1117f}, {0.0633f, 0.7100f, 0.0782f}, {0.1096f, 0.7932f, 0.0573f},
{0.1655f, 0.8620f, 0.0422f}, {0.2257f, 0.9149f, 0.0298f}, {0.2904f, 0.9540f, 0.0203f},
{0.3597f, 0.9803f, 0.0134f}, {0.4334f, 0.9950f, 0.0087f}, {0.5121f, 1.0000f, 0.0057f},
{0.5945f, 0.9950f, 0.0039f}, {0.6784f, 0.9786f, 0.0027f}, {0.7621f, 0.9520f, 0.0021f},
{0.8425f, 0.9154f, 0.0018f}, {0.9163f, 0.8700f, 0.0017f}, {0.9786f, 0.8163f, 0.0014f},
{1.0263f, 0.7570f, 0.0011f}, {1.0567f, 0.6949f, 0.0010f}, {1.0622f, 0.6310f, 0.0008f},
{1.0456f, 0.5668f, 0.0006f}, {1.0026f, 0.5030f, 0.0003f}, {0.9384f, 0.4412f, 0.0002f},
{0.8544f, 0.3810f, 0.0002f}, {0.7514f, 0.3210f, 0.0001f}, {0.6424f, 0.2650f, 0.0000f},
{0.5419f, 0.2170f, 0.0000f}, {0.4479f, 0.1750f, 0.0000f}, {0.3608f, 0.1382f, 0.0000f},
{0.2835f, 0.1070f, 0.0000f}, {0.2187f, 0.0816f, 0.0000f}, {0.1649f, 0.0610f, 0.0000f},
{0.1212f, 0.0446f, 0.0000f}, {0.0874f, 0.0320f, 0.0000f}, {0.0636f, 0.0232f, 0.0000f},
{0.0468f, 0.0170f, 0.0000f}, {0.0329f, 0.0119f, 0.0000f}, {0.0227f, 0.0082f, 0.0000f},
{0.0158f, 0.0057f, 0.0000f}, {0.0114f, 0.0041f, 0.0000f}, {0.0081f, 0.0029f, 0.0000f},
{0.0058f, 0.0021f, 0.0000f}, {0.0041f, 0.0015f, 0.0000f}, {0.0029f, 0.0010f, 0.0000f},
{0.0020f, 0.0007f, 0.0000f}, {0.0014f, 0.0005f, 0.0000f}, {0.0010f, 0.0004f, 0.0000f},
{0.0007f, 0.0002f, 0.0000f}, {0.0005f, 0.0002f, 0.0000f}, {0.0003f, 0.0001f, 0.0000f},
{0.0002f, 0.0001f, 0.0000f}, {0.0002f, 0.0001f, 0.0000f}, {0.0001f, 0.0000f, 0.0000f},
{0.0001f, 0.0000f, 0.0000f}, {0.0001f, 0.0000f, 0.0000f}, {0.0000f, 0.0000f, 0.0000f}}

CIE color matching functions xBar, yBar, and zBar for wavelengths from 380 through 780 nanometers, every 5 nanometers.

For a wavelength lambda in this range:

cie_color_match[(lambda - 380) / 5][0] = xBar
cie_color_match[(lambda - 380) / 5][1] = yBar
cie_color_match[(lambda - 380) / 5][2] = zBar

Definition at line 4243 of file colormanagement.c.

Referenced by wavelength_to_xyz().

◆ global_color_picking_state

◆ global_colorspaces

ListBase global_colorspaces = {NULL, NULL}
static

◆ global_displays

ListBase global_displays = {NULL, NULL}
static

◆ global_gpu_state

struct global_gpu_state global_gpu_state = {false}
static

◆ global_looks

ListBase global_looks = {NULL, NULL}
static

◆ global_role_color_picking

char global_role_color_picking[MAX_COLORSPACE_NAME]
static

◆ global_role_data

char global_role_data[MAX_COLORSPACE_NAME]
static

◆ global_role_default_byte

char global_role_default_byte[MAX_COLORSPACE_NAME]
static

◆ global_role_default_float

char global_role_default_float[MAX_COLORSPACE_NAME]
static

◆ global_role_default_sequencer

char global_role_default_sequencer[MAX_COLORSPACE_NAME]
static

◆ global_role_scene_linear

char global_role_scene_linear[MAX_COLORSPACE_NAME]
static

◆ global_role_texture_painting

char global_role_texture_painting[MAX_COLORSPACE_NAME]
static

◆ global_tot_colorspace

int global_tot_colorspace = 0
static

Definition at line 69 of file colormanagement.c.

Referenced by colormanage_colorspace_add(), and colormanage_free_config().

◆ global_tot_display

int global_tot_display = 0
static

◆ global_tot_looks

int global_tot_looks = 0
static

Definition at line 72 of file colormanagement.c.

Referenced by colormanage_free_config(), and colormanage_look_add().

◆ global_tot_view

int global_tot_view = 0
static

◆ global_views

ListBase global_views = {NULL, NULL}
static

◆ imbuf_aces_to_scene_linear

float imbuf_aces_to_scene_linear[3][3] = {{0.0f}}

◆ imbuf_luma_coefficients

float imbuf_luma_coefficients[3] = {0.0f}

◆ imbuf_rec709_to_scene_linear

float imbuf_rec709_to_scene_linear[3][3] = {{0.0f}}

◆ imbuf_scene_linear_to_aces

float imbuf_scene_linear_to_aces[3][3] = {{0.0f}}

◆ imbuf_scene_linear_to_rec709

float imbuf_scene_linear_to_rec709[3][3] = {{0.0f}}

◆ imbuf_scene_linear_to_xyz

float imbuf_scene_linear_to_xyz[3][3] = {{0.0f}}

◆ imbuf_xyz_to_scene_linear

float imbuf_xyz_to_scene_linear[3][3] = {{0.0f}}

◆ processor_lock

pthread_mutex_t processor_lock = BLI_MUTEX_INITIALIZER
static