70static std::unique_ptr<ocio::Config>
g_config =
nullptr;
73#define DISPLAY_BUFFER_CHANNELS 4
317 cache_view_settings->
look = look;
320 cache_view_settings->
gamma = view_settings->
gamma;
323 cache_view_settings->
tint = view_settings->
tint;
324 cache_view_settings->
flag = view_settings->
flag;
334 cache_display_settings->
display = display;
358 *cache_handle =
nullptr;
362 *cache_handle = cache_ibuf;
374 int view_flag = 1 << view_settings->
view;
376 int curve_mapping_timestamp = curve_mapping ? curve_mapping->
changed_timestamp : 0;
400 if (cache_data->
look != view_settings->
look ||
404 cache_data->
tint != view_settings->
tint || cache_data->
flag != view_settings->
flag ||
408 *cache_handle =
nullptr;
424 uchar *display_buffer,
430 int view_flag = 1 << view_settings->
view;
433 int curve_mapping_timestamp = curve_mapping ? curve_mapping->
changed_timestamp : 0;
447 cache_data->
look = view_settings->
look;
452 cache_data->
tint = view_settings->
tint;
453 cache_data->
flag = view_settings->
flag;
459 *cache_handle = cache_ibuf;
466 ImBuf *cache_ibuf =
static_cast<ImBuf *
>(cache_handle);
478 char *colorspace_name,
480 const char *backup_role,
481 const bool optional =
false)
485 if (ociocs ==
nullptr && backup_role) {
489 if (ociocs ==
nullptr) {
494 if (ociocs ==
nullptr) {
495 if (!optional && !
G.quiet) {
496 printf(
"Color management: Error, could not find role \"%s\"\n", role);
498 colorspace_name[0] =
'\0';
529 if (
g_config->get_num_displays() == 0) {
531 printf(
"Color management: Error, could not find any displays\n");
536 if (
g_config->get_num_looks() == 0) {
538 printf(
"Color management: Error, could not find any looks\n");
546 if (num_views <= 0) {
548 printf(
"Color management: Error, could not find any views for display %s\n",
588 if (ocio_env && ocio_env[0] !=
'\0') {
592 printf(
"Color management: Using %s as a configuration file\n", ocio_env);
598 printf(
"Color management: Failed to load config from environment\n");
609 if (configdir.has_value()) {
620 printf(
"Color management: Failed to load bundled config\n");
631 printf(
"Color management: Using fallback mode for management\n");
662 if (look->
view() == view_name) {
671 const char *view_name,
672 const bool has_explicit_look)
681 if (view_name && look->
view() == view_name) {
685 if (has_explicit_look) {
737 if (sima && sima->
image) {
739 *r_view_settings =
nullptr;
754 const char *view_transform,
756 const float exposure,
758 const float temperature,
760 const bool use_white_balance,
761 const char *from_colorspace)
765 display_parameters.
view = view_transform;
766 display_parameters.
display = display;
768 display_parameters.
scale = (exposure == 0.0f) ? 1.0f :
powf(2.0f, exposure);
769 display_parameters.
exponent = (gamma == 1.0f) ? 1.0f : 1.0f /
max_ff(FLT_EPSILON, gamma);
771 display_parameters.
tint = tint;
773 display_parameters.
inverse =
false;
775 return g_config->get_display_cpu_processor(display_parameters);
789 if (default_view ==
nullptr) {
792 if (default_view !=
nullptr) {
801 view_settings->
flag = 0;
802 view_settings->
gamma = 1.0f;
805 view_settings->
tint = 10.0f;
816 else if (channels == 2) {
840 if (colorspace && colorspace->
is_data()) {
883 "Color management: display \"%s\" used by %s not found, setting to default "
917 printf(
"Color management: %s view \"%s\" not found, setting default \"%s\".\n",
927 if (view_settings->
look[0] ==
'\0') {
932 if (look ==
nullptr) {
934 printf(
"Color management: %s look \"%s\" not found, setting default \"%s\".\n",
945 "Color management: %s look \"%s\" is not compatible with view \"%s\", setting "
959 if (view_settings->
exposure == 0.0f && view_settings->
gamma == 0.0f) {
961 view_settings->
gamma = 1.0f;
968 if (colorspace_settings->
name[0] ==
'\0') {
976 printf(
"Color management: %s colorspace \"%s\" not found, will use default instead.\n",
978 colorspace_settings->
name);
999 if (!default_display) {
1011 sequencer_colorspace_settings = &scene->sequencer_colorspace_settings;
1015 if (sequencer_colorspace_settings->
name[0] ==
'\0') {
1020 if (scene->ed !=
nullptr) {
1051 if (!found && default_view) {
1077 printf(
"Unknown role was passed to %s\n", __func__);
1090 if (colorspace && colorspace->
is_data()) {
1121 if (colorspace && colorspace->
is_data()) {
1135 if (colorspace && colorspace->
is_data()) {
1163 return g_config->get_color_space_from_filepath(filepath);
1168 return g_config->get_color_space(name);
1173 return (colorspace && colorspace->
is_data());
1183 return (colorspace && colorspace->
is_srgb());
1189 return (colorspace && colorspace->
is_data());
1207 const char *names[] = {
"sRGB Encoded Rec.709 (sRGB)",
1208 "srgb_rec709_scene",
1209 "Utility - sRGB - Texture",
1213 for (
int i = 0; names[
i];
i++) {
1242 float whitepoint[3])
1306 float dither = ibuf->
dither;
1309 size_t offset = size_t(channels) * start_line * ibuf->
x;
1348 float *linear_buffer,
1349 bool *is_straight_alpha)
1352 int width = handle->
width;
1354 size_t buffer_size = size_t(channels) * width * height;
1356 bool is_data = handle->
is_data;
1368 const size_t i_last = size_t(width) * height;
1372 for (
i = 0, fp = linear_buffer, cp = byte_buffer;
i != i_last;
1373 i++, fp += channels, cp += channels)
1375 if (channels == 3) {
1378 else if (channels == 4) {
1382 BLI_assert_msg(0,
"Buffers of 3 or 4 channels are only supported here");
1386 if (!is_data && !is_data_display) {
1389 linear_buffer, width, height, channels, from_colorspace, to_colorspace,
false);
1392 *is_straight_alpha =
true;
1404 memcpy(linear_buffer, handle->
buffer, buffer_size *
sizeof(
float));
1406 if (!is_data && !is_data_display) {
1408 linear_buffer, width, height, channels, from_colorspace, to_colorspace, predivide);
1411 *is_straight_alpha =
false;
1420 memcpy(linear_buffer, handle->
buffer, buffer_size *
sizeof(
float));
1422 *is_straight_alpha =
false;
1428 const int width = handle->
width;
1429 const int height = handle->
tot_line;
1442 else if (handle->
buffer) {
1470 else if (handle->
buffer) {
1488 if (cm_processor ==
nullptr) {
1496 int width = handle->
width;
1499 size_t(channels) *
size_t(width) *
size_t(height),
"color conversion linear buffer");
1501 bool is_straight_alpha;
1504 bool predivide = handle->
predivide && (is_straight_alpha ==
false);
1509 cm_processor, linear_buffer, width, height, channels, predivide);
1513 if (display_buffer_byte) {
1529 if (display_buffer) {
1530 memcpy(display_buffer, linear_buffer,
size_t(width) * height * channels *
sizeof(
float));
1532 if (is_straight_alpha && channels == 4) {
1533 const size_t i_last = size_t(width) * height;
1537 for (
i = 0, fp = display_buffer;
i != i_last;
i++, fp += channels) {
1547 const float *buffer,
1549 float *display_buffer,
1550 uchar *display_buffer_byte,
1560 init_data.display_buffer = display_buffer;
1561 init_data.display_buffer_byte = display_buffer_byte;
1582 DisplayBufferThread handle;
1583 display_buffer_init_handle(&handle, y_range.first(), y_range.size(), &init_data);
1584 do_display_buffer_apply_thread(&handle);
1597 view_settings->
exposure != 0.0f || view_settings->
gamma != 1.0f)
1608 if (display_colorspace == colorspace) {
1617 float *display_buffer,
1618 uchar *display_buffer_byte,
1624 bool skip_transform =
false;
1634 if (skip_transform ==
false) {
1642 display_buffer_byte,
1651 uchar *display_buffer,
1656 ibuf,
nullptr, display_buffer, view_settings, display_settings);
1693 const int channels =
init_data->channels;
1695 const bool predivide =
init_data->predivide;
1696 const bool float_from_byte =
init_data->float_from_byte;
1698 const size_t offset = size_t(channels) * start_line * width;
1704 if (
init_data->byte_buffer !=
nullptr) {
1708 if (
init_data->float_buffer !=
nullptr) {
1712 handle->
width = width;
1726 const int channels = handle->
channels;
1727 const int width = handle->
width;
1728 const int height = handle->
tot_line;
1729 const bool predivide = handle->
predivide;
1732 if (float_from_byte) {
1743 handle->
cm_processor, float_buffer, width, height, channels, predivide);
1747 if (byte_buffer !=
nullptr) {
1749 handle->
cm_processor, byte_buffer, width, height, channels);
1751 if (float_buffer !=
nullptr) {
1753 handle->
cm_processor, float_buffer, width, height, channels, predivide);
1759 float *float_buffer,
1764 const bool predivide,
1765 const bool float_from_byte)
1777 init_data.float_from_byte = float_from_byte;
1795 float *float_buffer,
1799 const char *from_colorspace,
1800 const char *to_colorspace,
1803 if (from_colorspace[0] ==
'\0') {
1807 if (
STREQ(from_colorspace, to_colorspace)) {
1813 from_colorspace, to_colorspace);
1820 byte_buffer, float_buffer, width, height, channels, cm_processor, predivide,
false);
1828 const char *from_colorspace,
1829 const char *to_colorspace,
1833 nullptr, buffer, width, height, channels, from_colorspace, to_colorspace, predivide);
1840 const char *from_colorspace,
1841 const char *to_colorspace)
1844 buffer,
nullptr, width, height, channels, from_colorspace, to_colorspace,
false);
1852 const char *from_colorspace,
1853 const char *to_colorspace)
1857 if (from_colorspace ==
nullptr || from_colorspace[0] ==
'\0') {
1860 if (
STREQ(from_colorspace, to_colorspace) && channels == 4) {
1864 float *dst_ptr = float_buffer + pix_range.
first() * channels;
1865 uchar *src_ptr = byte_buffer + pix_range.
first() * channels;
1866 for ([[maybe_unused]]
const int i : pix_range) {
1868 float cr = float(src_ptr[0]) * (1.0f / 255.0f);
1869 float cg = float(src_ptr[1]) * (1.0f / 255.0f);
1870 float cb = float(src_ptr[2]) * (1.0f / 255.0f);
1871 float ca = float(src_ptr[3]) * (1.0f / 255.0f);
1872 dst_ptr[0] = cr * ca;
1873 dst_ptr[1] = cg * ca;
1874 dst_ptr[2] = cb * ca;
1884 byte_buffer, float_buffer, width, height, channels, cm_processor,
false,
true);
1889 const char *from_colorspace,
1890 const char *to_colorspace)
1894 if (from_colorspace[0] ==
'\0') {
1898 if (
STREQ(from_colorspace, to_colorspace)) {
1915 if (colorspace ==
nullptr) {
1916 printf(
"%s: perform conversion from unknown color space\n", __func__);
1920 if (processor ==
nullptr) {
1929 if (colorspace ==
nullptr) {
1930 printf(
"%s: perform conversion from unknown color space\n", __func__);
1934 if (processor ==
nullptr) {
1941 const bool predivide,
1944 if (colorspace ==
nullptr) {
1945 printf(
"%s: perform conversion from unknown color space\n", __func__);
1949 if (processor ==
nullptr) {
1965 const bool predivide)
1967 if (colorspace ==
nullptr) {
1968 printf(
"%s: perform conversion from unknown color space\n", __func__);
1972 if (processor ==
nullptr) {
1981 size_t(channels) *
sizeof(
float),
1982 size_t(channels) *
sizeof(
float) * width);
1988 processor->
apply(img);
1998 if (colorspace ==
nullptr) {
1999 printf(
"%s: perform conversion from unknown color space\n", __func__);
2003 if (processor ==
nullptr) {
2012 size_t(channels) *
sizeof(
float),
2013 size_t(channels) *
sizeof(
float) * width);
2014 processor->
apply(img);
2023 const bool store_premultiplied)
2036 for (
int y = 0;
y < height;
y++) {
2037 const size_t in_offset = (offset_y +
y) * ibuf->
x + offset_x;
2038 const size_t out_offset =
y * width;
2039 const uchar *
in = in_buffer + in_offset * 4;
2040 uchar *
out = out_buffer + out_offset * 4;
2042 if (use_premultiply) {
2044 for (
int x = 0;
x < width;
x++,
in += 4,
out += 4) {
2045 out[0] = (
in[0] *
in[3]) >> 8;
2046 out[1] = (
in[1] *
in[3]) >> 8;
2047 out[2] = (
in[2] *
in[3]) >> 8;
2053 for (
int x = 0;
x < width;
x++,
in += 4,
out += 4) {
2069 const bool store_premultiplied)
2078 const int in_channels = ibuf->
channels;
2081 for (
int y = 0;
y < height;
y++) {
2082 const size_t in_offset = (offset_y +
y) * ibuf->
x + offset_x;
2083 const size_t out_offset =
y * width;
2084 const float *
in = in_buffer + in_offset * in_channels;
2085 float *
out = out_buffer + out_offset * 4;
2087 if (in_channels == 1) {
2089 for (
int x = 0;
x < width;
x++,
in += 1,
out += 4) {
2096 else if (in_channels == 3) {
2098 for (
int x = 0;
x < width;
x++,
in += 3,
out += 4) {
2105 else if (in_channels == 4) {
2107 if (use_unpremultiply) {
2108 for (
int x = 0;
x < width;
x++,
in += 4,
out += 4) {
2113 memcpy(
out,
in,
sizeof(
float[4]) * width);
2129 for (
const int y : y_range) {
2130 const size_t in_offset = (offset_y +
y) * ibuf->
x + offset_x;
2131 const size_t out_offset =
y * width;
2132 const uchar *
in = in_buffer + in_offset * 4;
2133 float *
out = out_buffer + out_offset * 4;
2134 for (
int x = 0;
x < width;
x++,
in += 4,
out += 4) {
2144 if (use_premultiply) {
2155 const float scene_linear[3])
2162 std::shared_ptr<const ocio::CPUProcessor> cpu_processor =
g_config->get_cpu_processor(
2165 if (cpu_processor) {
2184 const float color_picking[3])
2191 std::shared_ptr<const ocio::CPUProcessor> cpu_processor =
g_config->get_cpu_processor(
2194 if (cpu_processor) {
2216 if (processor !=
nullptr) {
2225 if (processor !=
nullptr) {
2232 const float pixel[4],
2247 const float pixel[3],
2284 if (colormanaged_ibuf != ibuf) {
2286 return colormanaged_ibuf;
2289 if (allocate_result) {
2293 return colormanaged_ibuf;
2306 bool save_as_render,
2307 bool allocate_result,
2310 ImBuf *colormanaged_ibuf = ibuf;
2340 float color[3] = {0, 0, 0};
2355 if (save_as_render && !linear_float_output) {
2393 if (to_colorspace[0] ==
'\0' ||
STREQ(from_colorspace, to_colorspace)) {
2411 colormanaged_ibuf->
x,
2412 colormanaged_ibuf->
y,
2435 colormanaged_ibuf->
x,
2436 colormanaged_ibuf->
y,
2449 return colormanaged_ibuf;
2461 void **cache_handle)
2463 uchar *display_buffer;
2469 *cache_handle =
nullptr;
2471 if (!ibuf->
x || !ibuf->
y) {
2475 if (view_settings) {
2476 applied_view_settings = view_settings;
2482 applied_view_settings = &default_view_settings;
2505 applied_view_settings,
2521 "imbuf display_buffer_flags");
2533 ibuf, &cache_view_settings, &cache_display_settings, cache_handle);
2535 if (display_buffer) {
2537 return display_buffer;
2544 ibuf, display_buffer, applied_view_settings, display_settings);
2547 ibuf, &cache_view_settings, &cache_display_settings, display_buffer, cache_handle);
2551 return display_buffer;
2565 float *linear_buffer,
2578 "display transform temp buffer");
2579 memcpy(buffer, linear_buffer,
size_t(channels) * width * height *
sizeof(
float));
2601 float *linear_buffer,
2614 "display transform temp buffer");
2615 memcpy(buffer, linear_buffer,
size_t(channels) * width * height *
sizeof(
float));
2621 memcpy(float_display_buffer, buffer,
size_t(channels) * width * height *
sizeof(
float));
2646 return display->
index;
2668 return g_config->get_display_by_name(name);
2673 if (
g_config->get_display_by_name(
"None") !=
nullptr) {
2683 if (!default_view) {
2725 return view->name().c_str();
2749 return view->name().c_str();
2760 return g_config->get_color_space(name);
2774 return colorspace->
index;
2799 if (colorspace && colorspace->
is_data()) {
2805 if (type !=
nullptr) {
2806 if (type->
save !=
nullptr) {
2809 STRNCPY(colorspace_settings->
name, role_colorspace);
2848 const char *look_name)
2899 const char *display_name)
2923 const char *view_name)
2948 const ColorSpace *colorspace =
g_config->get_sorted_color_space_by_index(colorspace_index);
2983 uchar *display_buffer,
2984 const float *linear_buffer,
2985 const uchar *byte_buffer,
2988 int linear_offset_x,
2989 int linear_offset_y,
2998 float dither = ibuf->
dither;
3000 float *display_buffer_float =
nullptr;
3001 const int width = xmax - xmin;
3002 const int height = ymax - ymin;
3005 if (dither != 0.0f) {
3013 if (!cm_processor) {
3018 size_t(channels) *
size_t(width) *
size_t(height),
"display buffer for dither");
3022 for (
y = ymin;
y < ymax;
y++) {
3023 for (
x = xmin;
x < xmax;
x++) {
3024 size_t display_index = (size_t(
y) * display_stride +
x) * 4;
3025 size_t linear_index = (size_t(
y - linear_offset_y) * linear_stride +
3026 (
x - linear_offset_x)) *
3030 if (linear_buffer) {
3031 if (channels == 4) {
3032 copy_v4_v4(pixel, (
float *)linear_buffer + linear_index);
3034 else if (channels == 3) {
3035 copy_v3_v3(pixel, (
float *)linear_buffer + linear_index);
3038 else if (channels == 1) {
3039 pixel[0] = linear_buffer[linear_index];
3042 BLI_assert_msg(0,
"Unsupported number of channels in partial buffer update");
3045 else if (byte_buffer) {
3055 if (display_buffer_float) {
3056 size_t index = (size_t(
y - ymin) * width + (
x - xmin)) * channels;
3058 if (channels == 4) {
3059 copy_v4_v4(display_buffer_float + index, pixel);
3061 else if (channels == 3) {
3062 copy_v3_v3(display_buffer_float + index, pixel);
3065 display_buffer_float[index] = pixel[0];
3069 if (channels == 4) {
3070 float pixel_straight[4];
3074 else if (channels == 3) {
3076 display_buffer[display_index + 3] = 255;
3079 display_buffer[display_index] = display_buffer[display_index + 1] =
3080 display_buffer[display_index + 2] = display_buffer[display_index + 3] =
3088 if (display_buffer_float) {
3103 for (
i = ymin;
i < ymax;
i++) {
3104 size_t byte_offset = (size_t(linear_stride) *
i + xmin) * 4;
3105 size_t display_offset = (size_t(display_stride) *
i + xmin) * 4;
3108 display_buffer + display_offset, byte_buffer + byte_offset,
sizeof(
char[4]) * width);
3113 if (display_buffer_float) {
3114 size_t display_index = (size_t(ymin) * display_stride + xmin) * channels;
3117 display_buffer_float,
3135 const float *linear_buffer,
3136 const uchar *byte_buffer,
3151 void *cache_handle =
nullptr;
3152 uchar *display_buffer =
nullptr;
3153 int buffer_width = ibuf->
x;
3156 int view_flag, display_index;
3161 view_flag = 1 << cache_view_settings.
view;
3162 display_index = cache_display_settings.
display;
3168 ibuf, &cache_view_settings, &cache_display_settings, &cache_handle);
3175 buffer_width = ibuf->
x;
3184 if (display_buffer) {
3186 bool skip_transform =
false;
3193 if (linear_buffer ==
nullptr && byte_buffer !=
nullptr) {
3197 if (byte_buffer ==
nullptr && linear_buffer !=
nullptr) {
3202 if (!skip_transform) {
3207 do_threads ? 64 : ymax - ymin,
3233 const float *linear_buffer,
3234 const uchar *byte_buffer,
3262 const float *linear_buffer,
3263 const uchar *byte_buffer,
3274 int width = xmax - xmin;
3275 int height = ymax - ymin;
3276 bool do_threads = (size_t(width) * height >= 64 * 64);
3319 cm_processor = MEM_new<ColormanageProcessor>(
"colormanagement processor");
3321 if (view_settings) {
3322 applied_view_settings = view_settings;
3326 applied_view_settings = &default_view_settings;
3330 if (display_space) {
3339 applied_view_settings->
gamma,
3341 applied_view_settings->
tint,
3350 return cm_processor;
3354 const char *to_colorspace)
3358 cm_processor = MEM_new<ColormanageProcessor>(
"colormanagement processor");
3363 return cm_processor;
3430 if (channels == 4) {
3433 else if (channels == 3) {
3436 else if (channels == 1) {
3443 false,
"Incorrect number of channels passed to IMB_colormanagement_processor_apply_pixel");
3458 for (
y = 0;
y < height;
y++) {
3459 for (
x = 0;
x < width;
x++) {
3460 float *pixel = buffer + channels * (size_t(
y) * width +
x);
3475 size_t(channels) *
sizeof(
float),
3476 size_t(channels) *
sizeof(
float) * width);
3495 for (
int y = 0;
y < height;
y++) {
3496 for (
int x = 0;
x < width;
x++) {
3497 size_t offset = channels * (size_t(
y) * width +
x);
3511 MEM_delete(cm_processor);
3520 if (!use_curve_mapping) {
3557 bool do_overlay_merge)
3562 if (view_settings) {
3563 applied_view_settings = view_settings;
3569 applied_view_settings = &default_view_settings;
3578 const float exposure = applied_view_settings->
exposure;
3579 const float gamma = applied_view_settings->
gamma;
3587 display_parameters.
look = (use_look) ? applied_view_settings->
look :
"";
3589 display_parameters.
scale = (exposure == 0.0f) ? 1.0f :
powf(2.0f, exposure);
3590 display_parameters.
exponent = (gamma == 1.0f) ? 1.0f : 1.0f /
max_ff(FLT_EPSILON, gamma);
3591 display_parameters.
dither = dither;
3593 display_parameters.
tint = applied_view_settings->
tint;
3603 display_parameters);
3614 view_settings, display_settings,
nullptr, dither, predivide,
false);
3628 view_settings, display_settings, from_colorspace, dither, predivide,
false);
3637 const bool predivide)
3640 from_colorspace_name, predivide);
3647 g_config->get_gpu_shader_binder().unbind();
3665 {2.48845471e+03f, -1.11330907e-03f, 3.22621544e+00f},
3666 {3.34143193e+03f, -4.86551192e-04f, 1.76486769e+00f},
3667 {4.09461742e+03f, -1.27446582e-04f, 7.25731635e-01f},
3668 {4.67028036e+03f, 2.91258199e-05f, 1.26703442e-01f},
3669 {4.59509185e+03f, 2.87495649e-05f, 1.50345020e-01f},
3670 {3.78717450e+03f, 9.35907826e-06f, 3.99075871e-01f}};
3673 {-4.88999748e+02f, 6.04330754e-04f, -7.55807526e-02f},
3674 {-7.55994277e+02f, 3.16730098e-04f, 4.78306139e-01f},
3675 {-1.02363977e+03f, 1.20223470e-04f, 9.36662319e-01f},
3676 {-1.26571316e+03f, 4.87340896e-06f, 1.27054498e+00f},
3677 {-1.42529332e+03f, -4.01150431e-05f, 1.43972784e+00f},
3678 {-1.17554822e+03f, -2.16378048e-05f, 1.30408023e+00f},
3679 {-5.00799571e+02f, -4.59832026e-06f, 1.09098763e+00f}};
3682 {5.96945309e-11f, -4.85742887e-08f, -9.70622247e-05f, -4.07936148e-03f},
3683 {2.40430366e-11f, 5.55021075e-08f, -1.98503712e-04f, 2.89312858e-02f},
3684 {-1.40949732e-11f, 1.89878968e-07f, -3.56632824e-04f, 9.10767778e-02f},
3685 {-3.61460868e-11f, 2.84822009e-07f, -4.93211319e-04f, 1.56723440e-01f},
3686 {-1.97075738e-11f, 1.75359352e-07f, -2.50542825e-04f, -2.22783266e-02f},
3687 {-1.61997957e-13f, -1.64216008e-08f, 3.86216271e-04f, -7.38077418e-01f},
3688 {6.72650283e-13f, -2.73078809e-08f, 4.24098264e-04f, -7.52335691e-01f}};
3692 if (t >= 12000.0f) {
3693 rec709[0] = 0.8262954810464208f;
3694 rec709[1] = 0.9945080501520986f;
3695 rec709[2] = 1.566307710274283f;
3697 else if (t < 800.0f) {
3698 rec709[0] = 5.413294490189271f;
3699 rec709[1] = -0.20319390035873933f;
3700 rec709[2] = -0.0822535242887164f;
3703 int i = (t >= 6365.0f) ? 6 :
3704 (t >= 3315.0f) ? 5 :
3705 (t >= 1902.0f) ? 4 :
3706 (t >= 1449.0f) ? 3 :
3707 (t >= 1167.0f) ? 2 :
3715 const float t_inv = 1.0f / t;
3716 rec709[0] = r[0] * t_inv + r[1] * t + r[2];
3717 rec709[1] = g[0] * t_inv + g[1] * t + g[2];
3718 rec709[2] = ((
b[0] * t +
b[1]) * t +
b[2]) * t +
b[3];
3740 for (
int i = 0;
i < width;
i++) {
3741 float temperature =
min + (
max -
min) /
float(width) * float(
i);
3759 {0.0014f, 0.0000f, 0.0065f}, {0.0022f, 0.0001f, 0.0105f}, {0.0042f, 0.0001f, 0.0201f},
3760 {0.0076f, 0.0002f, 0.0362f}, {0.0143f, 0.0004f, 0.0679f}, {0.0232f, 0.0006f, 0.1102f},
3761 {0.0435f, 0.0012f, 0.2074f}, {0.0776f, 0.0022f, 0.3713f}, {0.1344f, 0.0040f, 0.6456f},
3762 {0.2148f, 0.0073f, 1.0391f}, {0.2839f, 0.0116f, 1.3856f}, {0.3285f, 0.0168f, 1.6230f},
3763 {0.3483f, 0.0230f, 1.7471f}, {0.3481f, 0.0298f, 1.7826f}, {0.3362f, 0.0380f, 1.7721f},
3764 {0.3187f, 0.0480f, 1.7441f}, {0.2908f, 0.0600f, 1.6692f}, {0.2511f, 0.0739f, 1.5281f},
3765 {0.1954f, 0.0910f, 1.2876f}, {0.1421f, 0.1126f, 1.0419f}, {0.0956f, 0.1390f, 0.8130f},
3766 {0.0580f, 0.1693f, 0.6162f}, {0.0320f, 0.2080f, 0.4652f}, {0.0147f, 0.2586f, 0.3533f},
3767 {0.0049f, 0.3230f, 0.2720f}, {0.0024f, 0.4073f, 0.2123f}, {0.0093f, 0.5030f, 0.1582f},
3768 {0.0291f, 0.6082f, 0.1117f}, {0.0633f, 0.7100f, 0.0782f}, {0.1096f, 0.7932f, 0.0573f},
3769 {0.1655f, 0.8620f, 0.0422f}, {0.2257f, 0.9149f, 0.0298f}, {0.2904f, 0.9540f, 0.0203f},
3770 {0.3597f, 0.9803f, 0.0134f}, {0.4334f, 0.9950f, 0.0087f}, {0.5121f, 1.0000f, 0.0057f},
3771 {0.5945f, 0.9950f, 0.0039f}, {0.6784f, 0.9786f, 0.0027f}, {0.7621f, 0.9520f, 0.0021f},
3772 {0.8425f, 0.9154f, 0.0018f}, {0.9163f, 0.8700f, 0.0017f}, {0.9786f, 0.8163f, 0.0014f},
3773 {1.0263f, 0.7570f, 0.0011f}, {1.0567f, 0.6949f, 0.0010f}, {1.0622f, 0.6310f, 0.0008f},
3774 {1.0456f, 0.5668f, 0.0006f}, {1.0026f, 0.5030f, 0.0003f}, {0.9384f, 0.4412f, 0.0002f},
3775 {0.8544f, 0.3810f, 0.0002f}, {0.7514f, 0.3210f, 0.0001f}, {0.6424f, 0.2650f, 0.0000f},
3776 {0.5419f, 0.2170f, 0.0000f}, {0.4479f, 0.1750f, 0.0000f}, {0.3608f, 0.1382f, 0.0000f},
3777 {0.2835f, 0.1070f, 0.0000f}, {0.2187f, 0.0816f, 0.0000f}, {0.1649f, 0.0610f, 0.0000f},
3778 {0.1212f, 0.0446f, 0.0000f}, {0.0874f, 0.0320f, 0.0000f}, {0.0636f, 0.0232f, 0.0000f},
3779 {0.0468f, 0.0170f, 0.0000f}, {0.0329f, 0.0119f, 0.0000f}, {0.0227f, 0.0082f, 0.0000f},
3780 {0.0158f, 0.0057f, 0.0000f}, {0.0114f, 0.0041f, 0.0000f}, {0.0081f, 0.0029f, 0.0000f},
3781 {0.0058f, 0.0021f, 0.0000f}, {0.0041f, 0.0015f, 0.0000f}, {0.0029f, 0.0010f, 0.0000f},
3782 {0.0020f, 0.0007f, 0.0000f}, {0.0014f, 0.0005f, 0.0000f}, {0.0010f, 0.0004f, 0.0000f},
3783 {0.0007f, 0.0002f, 0.0000f}, {0.0005f, 0.0002f, 0.0000f}, {0.0003f, 0.0001f, 0.0000f},
3784 {0.0002f, 0.0001f, 0.0000f}, {0.0002f, 0.0001f, 0.0000f}, {0.0001f, 0.0000f, 0.0000f},
3785 {0.0001f, 0.0000f, 0.0000f}, {0.0001f, 0.0000f, 0.0000f}, {0.0000f, 0.0000f, 0.0000f}};
3789 float ii = (lambda_nm - 380.0f) * (1.0f / 5.0f);
3800 xyz[0] = c[0] + ii * (c[3] - c[0]);
3801 xyz[1] = c[1] + ii * (c[4] - c[1]);
3802 xyz[2] = c[2] + ii * (c[5] - c[2]);
3821 for (
int i = 0;
i < width;
i++) {
3822 float wavelength = 380 + 400 / float(width) * float(
i);
std::optional< std::string > BKE_appdir_folder_id(int folder_id, const char *subfolder) ATTR_WARN_UNUSED_RESULT
SpaceImage * CTX_wm_space_image(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
blender::ocio::Display ColorManagedDisplay
#define BLI_assert_msg(a, msg)
#define LISTBASE_FOREACH(type, var, list)
MINLINE float max_ff(float a, float b)
MINLINE void straight_to_premul_v4(float color[4])
void BLI_init_srgb_conversion(void)
void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
MINLINE void premul_to_straight_v4_v4(float straight[4], const float premul[4])
void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
void rgb_uchar_to_float(float r_col[3], const unsigned char col_ub[3])
void rgb_float_to_uchar(unsigned char r_col[3], const float col_f[3])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void clamp_v3(float vec[3], float min, float max)
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
#define BLI_path_join(...)
const char * BLI_getenv(const char *env) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void BLI_rcti_union(struct rcti *rct_a, const struct rcti *rct_b)
void BLI_rcti_init(struct rcti *rect, int xmin, int xmax, int ymin, int ymax)
char * STRNCPY(char(&dst)[N], const char *src)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
void BLI_thread_unlock(int type)
void BLI_thread_lock(int type)
#define BLI_MUTEX_INITIALIZER
void BLI_mutex_lock(ThreadMutex *mutex)
void BLI_mutex_unlock(ThreadMutex *mutex)
@ COLORMANAGE_VIEW_USE_WHITE_BALANCE
@ COLORMANAGE_VIEW_USE_CURVES
@ COLORMANAGE_VIEW_USE_HDR
bool IMB_colormanagement_space_is_scene_linear(const ColorSpace *colorspace)
bool IMB_colormanagement_space_is_data(const ColorSpace *colorspace)
@ COLOR_ROLE_DEFAULT_FLOAT
@ COLOR_ROLE_ACES_INTERCHANGE
@ COLOR_ROLE_DEFAULT_BYTE
@ COLOR_ROLE_SCENE_LINEAR
@ COLOR_ROLE_COLOR_PICKING
@ COLOR_ROLE_DEFAULT_SEQUENCER
@ COLOR_ROLE_TEXTURE_PAINTING
BLI_INLINE void IMB_colormanagement_xyz_to_scene_linear(float scene_linear[3], const float xyz[3])
BLI_INLINE void IMB_colormanagement_rec709_to_scene_linear(float scene_linear[3], const float rec709[3])
BLI_INLINE void IMB_colormanagement_scene_linear_to_xyz(float xyz[3], const float scene_linear[3])
blender::ocio::ColorSpace ColorSpace
#define MAX_COLORSPACE_NAME
Function declarations for filter.cc.
ImBuf * IMB_dupImBuf(const ImBuf *ibuf1)
void IMB_make_writable_byte_buffer(ImBuf *ibuf)
void IMB_buffer_byte_from_float(unsigned char *rect_to, const float *rect_from, int channels_from, float dither, int profile_to, int profile_from, bool predivide, int width, int height, int stride_to, int stride_from, int start_y=0)
bool IMB_alpha_affects_rgb(const ImBuf *ibuf)
bool IMB_alloc_byte_pixels(ImBuf *ibuf, bool initialize_pixels=true)
void IMB_buffer_byte_from_byte(unsigned char *rect_to, const unsigned char *rect_from, int profile_to, int profile_from, bool predivide, int width, int height, int stride_to, int stride_from)
void IMB_buffer_float_from_byte(float *rect_to, const unsigned char *rect_from, int profile_to, int profile_from, bool predivide, int width, int height, int stride_to, int stride_from)
void IMB_byte_from_float(ImBuf *ibuf)
void IMB_buffer_float_from_float(float *rect_to, const float *rect_from, int channels_from, int profile_to, int profile_from, bool predivide, int width, int height, int stride_to, int stride_from)
void IMB_make_writable_float_buffer(ImBuf *ibuf)
void IMB_freeImBuf(ImBuf *ibuf)
ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
void IMB_free_byte_pixels(ImBuf *ibuf)
void IMB_alpha_under_color_float(float *rect_float, int x, int y, float backcol[3])
void IMB_assign_byte_buffer(ImBuf *ibuf, uint8_t *buffer_data, ImBufOwnership ownership)
void IMB_alpha_under_color_byte(unsigned char *rect, int x, int y, const float backcol[3])
void IMB_float_from_byte(ImBuf *ibuf)
@ IB_DISPLAY_BUFFER_INVALID
@ IMB_COLORMANAGE_IS_DATA
@ IB_alphamode_channel_packed
void IMB_moviecache_free(MovieCache *cache)
ImBuf * IMB_moviecache_get(MovieCache *cache, void *userkey, bool *r_is_cached_empty)
void IMB_moviecache_put(MovieCache *cache, void *userkey, ImBuf *ibuf)
MovieCache * IMB_moviecache_create(const char *name, int keysize, GHashHashFP hashfp, GHashCmpFP cmpfp)
Read Guarded memory(de)allocation.
static void init_data(ModifierData *md)
#define OCIO_ROLE_COLOR_PICKING
#define OCIO_ROLE_TEXTURE_PAINT
#define OCIO_ROLE_DEFAULT_FLOAT
#define OCIO_ROLE_DEFAULT_SEQUENCER
#define OCIO_ROLE_DEFAULT_BYTE
#define OCIO_ROLE_ACES_INTERCHANGE
#define OCIO_ROLE_SCENE_LINEAR
BMesh const char void * data
constexpr int64_t first() const
constexpr int64_t one_after_last() const
constexpr int64_t size() const
constexpr bool is_empty() const
constexpr const char * c_str() const
virtual void apply_rgba_predivide(float rgba[4]) const =0
virtual void apply_predivide(const PackedImage &image) const =0
virtual void apply_rgb(float rgb[3]) const =0
virtual void apply(const PackedImage &image) const =0
virtual void apply_rgba(float rgba[4]) const =0
virtual StringRefNull name() const =0
virtual bool is_invertible() const =0
virtual const CPUProcessor * get_to_scene_linear_cpu_processor() const =0
virtual const CPUProcessor * get_from_scene_linear_cpu_processor() const =0
virtual StringRefNull description() const =0
virtual bool is_data() const =0
virtual bool is_scene_linear() const =0
virtual bool is_srgb() const =0
virtual float3 get_default_luma_coefs() const =0
static std::unique_ptr< Config > create_fallback()
virtual const ColorSpace * get_color_space(StringRefNull name) const =0
static std::unique_ptr< Config > create_from_environment()
virtual float3x3 get_xyz_to_scene_linear_matrix() const =0
static std::unique_ptr< Config > create_from_file(StringRefNull filename)
virtual StringRefNull name() const =0
virtual const CPUProcessor * get_from_scene_linear_cpu_processor() const =0
virtual const View * get_view_by_name(StringRefNull name) const =0
virtual const CPUProcessor * get_to_scene_linear_cpu_processor() const =0
virtual const View * get_default_view() const =0
virtual int get_num_views() const =0
virtual const View * get_view_by_index(int index) const =0
virtual StringRefNull view() const =0
virtual StringRefNull name() const =0
virtual StringRefNull ui_name() const =0
virtual StringRefNull process_space() const =0
virtual StringRefNull name() const =0
static void partial_buffer_update_rect(ImBuf *ibuf, uchar *display_buffer, const float *linear_buffer, const uchar *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 char global_role_data[MAX_COLORSPACE_NAME]
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], const ColorSpace *colorspace)
static CurveMapping * update_glsl_curve_mapping(const ColorManagedViewSettings *view_settings)
static void display_buffer_apply_get_linear_buffer(DisplayBufferThread *handle, int height, float *linear_buffer, bool *is_straight_alpha)
void IMB_colormanagement_pixel_to_display_space_v3(float result[3], const float pixel[3], const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
static const float blackbody_table_r[7][3]
void IMB_colormanagement_assign_byte_colorspace(ImBuf *ibuf, const char *name)
float3x3 imbuf_scene_linear_to_xyz
static void blackbody_temperature_to_rec709(float rec709[3], float t)
static uint colormanage_hashhash(const void *key_v)
void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], const ColorSpace *colorspace)
void IMB_colormanagement_colorspace_items_add(EnumPropertyItem **items, int *totitem)
bool IMB_colormanagement_set_whitepoint(const float whitepoint[3], float &temperature, float &tint)
const char * IMB_colormanagement_colorspace_get_indexed_name(const int index)
void colormanage_cache_free(ImBuf *ibuf)
float3x3 imbuf_xyz_to_scene_linear
static float cie_color_match[81][3]
ColormanageProcessor * IMB_colormanagement_colorspace_processor_new(const char *from_colorspace, const char *to_colorspace)
static blender::VectorSet< blender::StringRefNull > g_all_view_names
void IMB_colormanagement_assign_float_colorspace(ImBuf *ibuf, const char *name)
void IMB_colormanagement_wavelength_to_rgb(float r_dest[4], float value)
static void colormanage_check_colorspace_settings(ColorManagedColorspaceSettings *colorspace_settings, const char *what)
const char * IMB_colormanagement_display_get_none_name()
const ColorSpace * IMB_colormanagement_space_get_named(const char *name)
uchar * IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, void **cache_handle)
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_transform_byte(uchar *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace)
static void colormanage_cachedata_set(ImBuf *ibuf, ColormanageCacheData *data)
static void colormanagement_imbuf_make_display_space(ImBuf *ibuf, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, bool make_byte)
blender::float3x3 IMB_colormanagement_get_scene_linear_to_xyz()
static std::unique_ptr< ocio::Config > g_config
bool IMB_colormanagement_space_is_scene_linear(const ColorSpace *colorspace)
const ColorSpace * colormanage_colorspace_get_roled(const int role)
void IMB_colormanagement_processor_apply_byte(ColormanageProcessor *cm_processor, uchar *buffer, int width, int height, int channels)
const ColorSpace * colormanage_colorspace_get_named(const char *name)
void IMB_colormanagement_color_picking_to_scene_linear_v3(float scene_linear[3], const float color_picking[3])
uchar * IMB_display_buffer_acquire_ctx(const bContext *C, ImBuf *ibuf, void **cache_handle)
void IMB_colormanagement_view_items_add(EnumPropertyItem **items, int *totitem, const char *display_name)
const char * IMB_colormanagement_view_get_raw_or_default_name(const char *display_name)
static ImBuf * colormanage_cache_get_ibuf(ImBuf *ibuf, ColormanageCacheKey *key, void **cache_handle)
static char global_role_default_sequencer[MAX_COLORSPACE_NAME]
void colormanagement_exit()
const char * IMB_colormanagement_look_get_default_name()
void IMB_colormanagement_check_is_data(ImBuf *ibuf, const char *name)
void colormanagement_init()
bool IMB_colormanagement_setup_glsl_draw(const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, float dither, bool predivide)
bool IMB_colormanagement_space_name_is_srgb(const char *name)
bool IMB_colormanagement_space_name_is_scene_linear(const char *name)
void IMB_colormanagement_imbuf_make_display_space(ImBuf *ibuf, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
const char * IMB_colormanagement_look_validate_for_view(const char *view_name, const char *look_name)
static pthread_mutex_t processor_lock
static void colormanage_check_display_settings(ColorManagedDisplaySettings *display_settings, const char *what, const ocio::Display *default_display)
void IMB_colormanagement_transform_byte_to_float(float *float_buffer, uchar *byte_buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace)
static bool colormanage_compatible_look(const ocio::Look *look, const char *view_name, const bool has_explicit_look)
void IMB_display_buffer_transform_apply(uchar *display_buffer, float *linear_buffer, int width, int height, int channels, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, bool predivide)
void IMB_colormanagement_transform_float(float *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace, bool predivide)
bool IMB_colormanagement_space_is_data(const ColorSpace *colorspace)
void IMB_partial_display_buffer_update(ImBuf *ibuf, const float *linear_buffer, const uchar *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 IMB_colormanagement_processor_is_noop(ColormanageProcessor *cm_processor)
static void colormanage_display_buffer_process_ex(ImBuf *ibuf, float *display_buffer, uchar *display_buffer_byte, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
static MovieCache * colormanage_moviecache_get(const ImBuf *ibuf)
void IMB_colormanagement_check_file_config(Main *bmain)
static struct GlobalColorPickingState global_color_picking_state
static ColormanageCacheData * colormanage_cachedata_get(const ImBuf *ibuf)
static bool has_explicit_look_for_view(const char *view_name)
bool IMB_colormanagement_setup_glsl_draw_to_scene_linear(const char *from_colorspace_name, const bool predivide)
ImBuf * IMB_colormanagement_imbuf_for_write(ImBuf *ibuf, bool save_as_render, bool allocate_result, const ImageFormatData *image_format)
ColormanageProcessor * IMB_colormanagement_display_processor_new(const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
static struct GlobalGPUState global_gpu_state
bool IMB_colormanagement_space_name_is_data(const char *name)
float3x3 imbuf_scene_linear_to_rec709
bool IMB_colormanagement_setup_glsl_draw_from_space_ctx(const bContext *C, const ColorSpace *from_colorspace, float dither, bool predivide)
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 ImBuf *ibuf, const bool store_premultiplied)
const char * IMB_colormanagement_display_get_indexed_name(const int index)
static bool colormanage_hashcmp(const void *av, const void *bv)
void IMB_colormanagement_init_default_view_settings(ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
const char * IMB_colormanagement_srgb_colorspace_name_get()
static bool is_colorspace_same_as_display(const ColorSpace *colorspace, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
const char * IMB_colormanagement_look_get_indexed_name(const int index)
void IMB_colormanagement_validate_settings(const ColorManagedDisplaySettings *display_settings, ColorManagedViewSettings *view_settings)
void IMB_colormanagement_colorspace_to_scene_linear_v4(float pixel[4], const bool predivide, const ColorSpace *colorspace)
static void do_processor_transform_thread(ProcessorTransformThread *handle)
void IMB_colormanagement_wavelength_to_rgb_table(float *r_table, const int width)
void IMB_colormanagement_colorspace_from_ibuf_ftype(ColorManagedColorspaceSettings *colorspace_settings, ImBuf *ibuf)
void IMB_colormanagement_processor_apply_v3(ColormanageProcessor *cm_processor, float pixel[3])
static const float blackbody_table_g[7][3]
void IMB_colormanagegent_copy_settings(ImBuf *ibuf_src, ImBuf *ibuf_dst)
static void processor_transform_apply_threaded(uchar *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 void colormanagement_transform_ex(uchar *byte_buffer, float *float_buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace, bool predivide)
void IMB_colormanagement_processor_apply(ColormanageProcessor *cm_processor, float *buffer, int width, int height, int channels, bool predivide)
const char * IMB_colormanagement_colorspace_get_name(const ColorSpace *colorspace)
const char * IMB_colormanagement_space_from_filepath_rules(const char *filepath)
static void colormanage_display_buffer_process(ImBuf *ibuf, uchar *display_buffer, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
bool IMB_colormanagement_setup_glsl_draw_ctx(const bContext *C, float dither, bool predivide)
const char * IMB_colormanagement_view_get_name_by_id(const int index)
void IMB_display_buffer_release(void *cache_handle)
void IMB_colormanagement_get_whitepoint(const float temperature, const float tint, float whitepoint[3])
int IMB_colormanagement_view_get_id_by_name(const char *name)
const char * IMB_colormanagement_role_colorspace_name_get(int role)
void IMB_colormanagement_display_settings_from_ctx(const bContext *C, ColorManagedViewSettings **r_view_settings, ColorManagedDisplaySettings **r_display_settings)
blender::float3x3 IMB_colormanagement_get_xyz_to_scene_linear()
static bool colormanage_load_config(ocio::Config &config)
void IMB_colormanagement_scene_linear_to_colorspace(float *buffer, const int width, const int height, const int channels, const ColorSpace *colorspace)
void IMB_partial_display_buffer_update_threaded(ImBuf *ibuf, const float *linear_buffer, const uchar *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)
const char * IMB_colormanagement_view_get_default_name(const char *display_name)
static void colormanage_cache_handle_release(void *cache_handle)
static void do_display_buffer_apply_no_processor(DisplayBufferThread *handle)
static const ColorSpace * get_display_colorspace(const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
static void do_display_buffer_apply_thread(DisplayBufferThread *handle)
static void processor_transform_init_handle(ProcessorTransformThread *handle, int start_line, int tot_line, ProcessorTransformInitData *init_data)
#define DISPLAY_BUFFER_CHANNELS
void IMB_colormanagement_finish_glsl_draw()
void IMB_colormanagement_imbuf_to_byte_texture(uchar *out_buffer, const int offset_x, const int offset_y, const int width, const int height, const ImBuf *ibuf, const bool store_premultiplied)
void colormanage_imbuf_set_default_spaces(ImBuf *ibuf)
static const float blackbody_table_b[7][4]
float3x3 imbuf_rec709_to_scene_linear
float3x3 imbuf_aces_to_scene_linear
int IMB_colormanagement_look_get_named_index(const char *name)
static ImBuf * imbuf_ensure_editable(ImBuf *ibuf, ImBuf *colormanaged_ibuf, bool allocate_result)
const char * IMB_colormanagement_display_get_default_view_transform_name(const ColorManagedDisplay *display)
static void colormanage_display_settings_to_cache(ColormanageCacheDisplaySettings *cache_display_settings, const ColorManagedDisplaySettings *display_settings)
static void display_buffer_apply_threaded(ImBuf *ibuf, const float *buffer, uchar *byte_buffer, float *display_buffer, uchar *display_buffer_byte, ColormanageProcessor *cm_processor)
void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, const int width, const int height, const int channels, const ColorSpace *colorspace, const bool predivide)
static void imb_partial_display_buffer_update_ex(ImBuf *ibuf, const float *linear_buffer, const uchar *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 std::shared_ptr< const ocio::CPUProcessor > get_display_buffer_processor(const char *look, const char *view_transform, const char *display, const float exposure, const float gamma, const float temperature, const float tint, const bool use_white_balance, const char *from_colorspace)
static void colormanage_cache_put(ImBuf *ibuf, const ColormanageCacheViewSettings *view_settings, const ColormanageCacheDisplaySettings *display_settings, uchar *display_buffer, void **cache_handle)
void IMB_colormanagement_display_items_add(EnumPropertyItem **items, int *totitem)
const ColorManagedDisplay * IMB_colormanagement_display_get_named(const char *name)
void IMB_colormanagement_blackbody_temperature_to_rgb_table(float *r_table, const int width, const float min, const float max)
static bool strip_callback(Strip *strip, void *)
void IMB_colormanagement_scene_linear_to_color_picking_v3(float color_picking[3], const float scene_linear[3])
static char global_role_scene_linear[MAX_COLORSPACE_NAME]
void IMB_colormanagement_blackbody_temperature_to_rgb(float r_dest[4], float value)
void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], const ColorManagedDisplay *display)
int IMB_colormanagement_colorspace_get_named_index(const char *name)
static bool colormanage_role_color_space_name_get(ocio::Config &config, char *colorspace_name, const char *role, const char *backup_role, const bool optional=false)
void IMB_display_buffer_transform_apply_float(float *float_display_buffer, float *linear_buffer, int width, int height, int channels, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, bool predivide)
static char global_role_texture_painting[MAX_COLORSPACE_NAME]
static void colormanage_settings_to_key(ColormanageCacheKey *key, const ColormanageCacheViewSettings *view_settings, const ColormanageCacheDisplaySettings *display_settings)
static void curve_mapping_apply_pixel(const CurveMapping *curve_mapping, float *pixel, int channels)
void colormanage_imbuf_make_linear(ImBuf *ibuf, const char *from_colorspace)
void IMB_colormanagement_processor_apply_v4_predivide(ColormanageProcessor *cm_processor, float pixel[4])
void IMB_colormanagement_look_items_add(EnumPropertyItem **items, int *totitem, const char *view_name)
static bool colormanage_use_look(const char *look_name, const char *view_name)
static char global_role_aces_interchange[MAX_COLORSPACE_NAME]
static char global_role_default_byte[MAX_COLORSPACE_NAME]
static char global_role_default_float[MAX_COLORSPACE_NAME]
void IMB_colormanagement_processor_free(ColormanageProcessor *cm_processor)
const char * IMB_colormanagement_get_rect_colorspace(ImBuf *ibuf)
void IMB_partial_display_buffer_update_delayed(ImBuf *ibuf, int xmin, int ymin, int xmax, int ymax)
static void colormanage_free_config()
void IMB_colormanagement_transform_v4(float pixel[4], const char *from_colorspace, const char *to_colorspace)
static void colormanage_view_settings_to_cache(ImBuf *ibuf, ColormanageCacheViewSettings *cache_view_settings, const ColorManagedViewSettings *view_settings)
void IMB_colormanagement_processor_apply_v4(ColormanageProcessor *cm_processor, float pixel[4])
int IMB_colormanagement_display_get_named_index(const char *name)
static char global_role_color_picking[MAX_COLORSPACE_NAME]
static uchar * colormanage_cache_get(ImBuf *ibuf, const ColormanageCacheViewSettings *view_settings, const ColormanageCacheDisplaySettings *display_settings, void **cache_handle)
const char * IMB_colormanagement_get_float_colorspace(ImBuf *ibuf)
static void colormanage_check_view_settings(ColorManagedDisplaySettings *display_settings, ColorManagedViewSettings *view_settings, const char *what)
float3x3 imbuf_scene_linear_to_aces
static void wavelength_to_xyz(float xyz[3], float lambda_nm)
float3 imbuf_luma_coefficients(0.0f)
const char * IMB_colormanagement_display_get_default_name()
static MovieCache * colormanage_moviecache_ensure(ImBuf *ibuf)
bool IMB_colormanagement_space_is_srgb(const ColorSpace *colorspace)
bool IMB_colormanagement_setup_glsl_draw_from_space(const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, const ColorSpace *from_colorspace, float dither, bool predivide, bool do_overlay_merge)
void IMB_colormanagement_processor_apply_pixel(ColormanageProcessor *cm_processor, float *pixel, int channels)
void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], const ColorManagedDisplay *display)
static void display_buffer_init_handle(DisplayBufferThread *handle, int start_line, int tot_line, DisplayBufferInitData *init_data)
const ImFileType * IMB_file_type_from_ibuf(const ImBuf *ibuf)
void IMB_premultiply_rect_float(float *rect_float, int channels, int w, int h)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
float3 whitepoint_from_temp_tint(float temperature, float tint)
bool whitepoint_to_temp_tint(const float3 &white, float &temperature, float &tint)
CartesianBasis invert(const CartesianBasis &basis)
static const float3x3 ACES_TO_XYZ
static const float3x3 XYZ_TO_REC709
void for_each_callback(ListBase *seqbase, ForEachFunc callback, void *user_data)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
MatBase< float, 3, 3 > float3x3
VecBase< float, 3 > float3
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
struct CurveMapping * curve_mapping
int curve_mapping_timestamp
CurveMapping * curve_mapping
CurveMapping * curve_mapping
ColormanageCacheData * data
CurveMapping * curve_mapping
std::shared_ptr< const ocio::CPUProcessor > cpu_processor
ColormanageProcessor * cm_processor
const char * float_colorspace
const char * byte_colorspace
uchar * display_buffer_byte
const char * byte_colorspace
uchar * display_buffer_byte
ColormanageProcessor * cm_processor
const char * float_colorspace
GlobalColorPickingState()=default
std::shared_ptr< const ocio::CPUProcessor > cpu_processor_to
std::shared_ptr< const ocio::CPUProcessor > cpu_processor_from
CurveMapping * curve_mapping
int curve_mapping_timestamp
CurveMapping * orig_curve_mapping
const ColorSpace * colorspace
const ColorSpace * colorspace
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
unsigned int * display_buffer_flags
ColormanageCache * colormanage_cache
bool(* save)(ImBuf *ibuf, const char *filepath, int flags)
ColorManagedViewSettings view_settings
ColorManagedDisplaySettings display_settings
ColorManagedColorspaceSettings colorspace_settings
StringRefNull from_colorspace
CurveMapping * curve_mapping
StringRefNull from_colorspace