diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_blender.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_colortools.h | 23 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_image.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_node.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_scene.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_sequencer.h | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/SConscript | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/colortools.c | 92 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 80 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image_gen.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/movieclip.c | 15 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/ocean.c | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 40 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/seqeffects.c | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/seqmodifier.c | 9 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 135 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 3 |
18 files changed, 381 insertions, 81 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 1e67027ae8c..fed82d7e93d 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 263 -#define BLENDER_SUBVERSION 18 +#define BLENDER_SUBVERSION 19 /* 262 was the last editmesh release but its has compatibility code for bmesh data, * so set the minversion to 2.61 */ diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index 9b7fc1fddad..cd67059ea8c 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -31,6 +31,9 @@ * \ingroup bke */ +struct ColorManagedColorspaceSettings; +struct ColorManagedDisplaySettings; +struct ColorManagedViewSettings; struct CurveMapping; struct CurveMap; struct CurveMapPoint; @@ -89,9 +92,25 @@ void curvemapping_do_ibuf(struct CurveMapping *cumap, struct ImBu void curvemapping_premultiply(struct CurveMapping *cumap, int restore); -void BKE_histogram_update_sample_line(struct Histogram *hist, struct ImBuf *ibuf, const short use_color_management); -void scopes_update(struct Scopes *scopes, struct ImBuf *ibuf, int use_color_management); +void BKE_histogram_update_sample_line(struct Histogram *hist, struct ImBuf *ibuf, + const struct ColorManagedViewSettings *view_settings, + const struct ColorManagedDisplaySettings *display_settings); +void scopes_update(struct Scopes *scopes, struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings, + const struct ColorManagedDisplaySettings *display_settings); void scopes_free(struct Scopes *scopes); void scopes_new(struct Scopes *scopes); +void BKE_color_managed_display_settings_init(struct ColorManagedDisplaySettings *settings); +void BKE_color_managed_display_settings_copy(struct ColorManagedDisplaySettings *new_settings, + const struct ColorManagedDisplaySettings *settings); + +void BKE_color_managed_view_settings_init(struct ColorManagedViewSettings *settings); +void BKE_color_managed_view_settings_copy(struct ColorManagedViewSettings *new_settings, + const struct ColorManagedViewSettings *settings); +void BKE_color_managed_view_settings_free(struct ColorManagedViewSettings *settings); + +void BKE_color_managed_colorspace_settings_init(struct ColorManagedColorspaceSettings *colorspace_settings); +void BKE_color_managed_colorspace_settings_copy(struct ColorManagedColorspaceSettings *colorspace_settings, + const struct ColorManagedColorspaceSettings *settings); + #endif diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 67461281674..ac324b2af00 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -46,6 +46,8 @@ struct Object; struct ImageFormatData; struct Main; +#define IMA_MAX_SPACE 64 + /* call from library */ void BKE_image_free(struct Image *me); @@ -64,6 +66,7 @@ int BKE_imtype_is_movie(const char imtype); int BKE_imtype_supports_zbuf(const char imtype); int BKE_imtype_supports_compress(const char imtype); int BKE_imtype_supports_quality(const char imtype); +int BKE_imtype_supports_float(const char imtype); char BKE_imtype_valid_channels(const char imtype); char BKE_imtype_valid_depths(const char imtype); @@ -72,7 +75,7 @@ char BKE_imtype_from_arg(const char *arg); void BKE_imformat_defaults(struct ImageFormatData *im_format); void BKE_imbuf_to_image_format(struct ImageFormatData *im_format, const struct ImBuf *imbuf); -struct anim *openanim(const char *name, int flags, int streamindex); +struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]); void BKE_image_de_interlace(struct Image *ima, int odd); diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 438d5110666..6ad2ad924e2 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -64,6 +64,8 @@ struct Tex; struct SpaceNode; struct ARegion; struct Object; +struct ColorManagedViewSettings; +struct ColorManagedDisplaySettings; /* ************** NODE TYPE DEFINITIONS ***** */ @@ -725,7 +727,8 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMateria struct CompBuf; struct bNodeTreeExec *ntreeCompositBeginExecTree(struct bNodeTree *ntree, int use_tree_data); void ntreeCompositEndExecTree(struct bNodeTreeExec *exec, int use_tree_data); -void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int rendering, int do_previews); +void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int rendering, int do_previews, + const struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings); void ntreeCompositTagRender(struct Scene *sce); int ntreeCompositTagAnimated(struct bNodeTree *ntree); void ntreeCompositTagGenerators(struct bNodeTree *ntree); diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index bce4243190a..023b7e85c40 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -108,6 +108,8 @@ float get_render_aosss_error(struct RenderData *r, float error); int BKE_scene_use_new_shading_nodes(struct Scene *scene); +void BKE_scene_disable_color_management(struct Scene *scene); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 51a64c97ca6..0c571f62f0e 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -177,6 +177,16 @@ struct ImBuf *BKE_sequencer_give_ibuf_seqbase(SeqRenderData context, float cfra, void BKE_sequencer_give_ibuf_prefetch_request(SeqRenderData context, float cfra, int chan_shown); /* ********************************************************************** + * sequencer.c + * + * sequencer color space functions + * ********************************************************************** */ + +void BKE_sequencer_imbuf_to_sequencer_space(struct Scene *scene, struct ImBuf *ibuf, int make_float); +void BKE_sequencer_imbuf_from_sequencer_space(struct Scene *scene, struct ImBuf *ibuf); +void BKE_sequencer_pixel_from_sequencer_space_v4(struct Scene *scene, float pixel[4]); + +/* ********************************************************************** * sequencer scene functions * ********************************************************************** */ struct Editing *BKE_sequencer_editing_get(struct Scene *scene, int alloc); @@ -350,7 +360,7 @@ struct Sequence *BKE_sequencer_add_sound_strip(struct bContext *C, ListBase *seq struct Sequence *BKE_sequencer_add_movie_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load); /* view3d draw callback, run when not in background view */ -typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, struct Object *, int, int, unsigned int, int, int, char[256]); +typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, struct Object *, int, int, unsigned int, int, int, int, char[256]); extern SequencerDrawView sequencer_view3d_cb; /* copy/paste */ diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index 68ca3170bd8..d1a35b122e8 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -3,6 +3,10 @@ Import ('env') import os sources = env.Glob('intern/*.c') +sources.remove('intern' + os.sep + 'mask_rasterize.c') +sources.remove('intern' + os.sep + 'mask.c') + +sources_mask = env.Glob('intern/mask*.c') incs = '. #/intern/guardedalloc #/intern/memutil' incs += ' ../blenlib ../blenfont ../makesdna ../windowmanager' @@ -118,7 +122,10 @@ if env['WITH_BF_INTERNATIONAL']: if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): incs += ' ' + env['BF_PTHREADS_INC'] + if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player'], priority = [166,25]) #, cc_compileflags = env['CCFLAGS'].append('/WX') ) else: env.BlenderLib ( libname = 'bf_blenkernel', sources = sources, includes = Split(incs), defines = defs, libtype=['core','player', 'player2'], priority = [166,25,0] ) + +env.BlenderLib ( libname = 'bf_blenkernel_mask', sources = sources_mask, includes = Split(incs), defines = defs, libtype=['core','player', 'player2'], priority = [200,25,0] ) diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 45e2167af2f..99b788e80ce 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -89,6 +89,8 @@ #include "WM_api.h" // XXXXX BAD, very BAD dependency (bad level call) - remove asap, elubie +#include "IMB_colormanagement.h" + #ifdef WITH_PYTHON # include "BPY_extern.h" #endif @@ -320,7 +322,11 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath /* baseflags, groups, make depsgraph, etc */ BKE_scene_set_background(G.main, CTX_data_scene(C)); - + + if (mode != 'u') { + IMB_colormanagement_check_file_config(G.main); + } + MEM_freeN(bfd); (void)curscene; /* quiet warning */ diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index d65c81b4f9b..19c8c2cd632 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -49,6 +49,7 @@ #include "BKE_fcurve.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" @@ -174,6 +175,7 @@ void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], con } curvemapping_set_black_white_ex(cumap->black, cumap->white, cumap->bwmul); + cumap->changed_timestamp++; } /* ***************** operations on single curve ************* */ @@ -996,7 +998,8 @@ static void save_sample_line(Scopes *scopes, const int idx, const float fx, cons } } -void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short use_color_management) +void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings) { int i, x, y; float *fp; @@ -1008,6 +1011,8 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short int y1 = 0.5f + hist->co[0][1] * ibuf->y; int y2 = 0.5f + hist->co[1][1] * ibuf->y; + struct ColormanageProcessor *cm_processor = NULL; + hist->channels = 3; hist->x_resolution = 256; hist->xmax = 1.0f; @@ -1015,6 +1020,9 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short if (ibuf->rect == NULL && ibuf->rect_float == NULL) return; + if (ibuf->rect_float) + cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings); + /* persistent draw */ hist->flag |= HISTO_FLAG_SAMPLELINE; /* keep drawing the flag after */ @@ -1029,10 +1037,8 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short if (ibuf->rect_float) { fp = (ibuf->rect_float + (ibuf->channels) * (y * ibuf->x + x)); - if (use_color_management) - linearrgb_to_srgb_v3_v3(rgb, fp); - else - copy_v3_v3(rgb, fp); + copy_v3_v3(rgb, fp); + IMB_colormanagement_processor_apply_v3(cm_processor, rgb); hist->data_luma[i] = rgb_to_luma(rgb); hist->data_r[i] = rgb[0]; @@ -1050,9 +1056,13 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const short } } } + + if (cm_processor) + IMB_colormanagement_processor_free(cm_processor); } -void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) +void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings *view_settings, + const ColorManagedDisplaySettings *display_settings) { int x, y, c; unsigned int n, nl; @@ -1065,6 +1075,8 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) int ycc_mode = -1; const short is_float = (ibuf->rect_float != NULL); + struct ColormanageProcessor *cm_processor = NULL; + if (ibuf->rect == NULL && ibuf->rect_float == NULL) return; if (scopes->ok == 1) return; @@ -1134,6 +1146,9 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) else rc = (unsigned char *)ibuf->rect; + if (ibuf->rect_float) + cm_processor = IMB_colormanagement_display_processor_new(view_settings, display_settings); + for (y = 0; y < ibuf->y; y++) { if (savedlines < scopes->sample_lines && y >= ((savedlines) * ibuf->y) / (scopes->sample_lines + 1)) { saveline = 1; @@ -1144,11 +1159,8 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) for (x = 0; x < ibuf->x; x++) { if (is_float) { - if (use_color_management) - linearrgb_to_srgb_v3_v3(rgba, rf); - else - copy_v3_v3(rgba, rf); - rgba[3] = rf[3]; + copy_v4_v4(rgba, rf); + IMB_colormanagement_processor_apply_v4(cm_processor, rgba); } else { for (c = 0; c < 4; c++) @@ -1219,6 +1231,9 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) MEM_freeN(bin_b); MEM_freeN(bin_a); + if (cm_processor) + IMB_colormanagement_processor_free(cm_processor); + scopes->ok = 1; } @@ -1257,3 +1272,58 @@ void scopes_new(Scopes *scopes) scopes->waveform_3 = NULL; scopes->vecscope = NULL; } + +void BKE_color_managed_display_settings_init(ColorManagedDisplaySettings *settings) +{ + const char *display_name = IMB_colormanagement_display_get_default_name(); + + BLI_strncpy(settings->display_device, display_name, sizeof(settings->display_device)); +} + +void BKE_color_managed_display_settings_copy(ColorManagedDisplaySettings *new_settings, + const ColorManagedDisplaySettings *settings) +{ + BLI_strncpy(new_settings->display_device, settings->display_device, sizeof(new_settings->display_device)); +} + +void BKE_color_managed_view_settings_init(ColorManagedViewSettings *settings) +{ + /* OCIO_TODO: use default view transform here when OCIO is completely integrated + * and proper versioning stuff is added. + * for now use NONE to be compatible with all current files + */ + BLI_strncpy(settings->view_transform, "Default", sizeof(settings->view_transform)); + + settings->gamma = 1.0f; + settings->exposure = 0.0f; +} + +void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings, + const ColorManagedViewSettings *settings) +{ + BLI_strncpy(new_settings->view_transform, settings->view_transform, sizeof(new_settings->view_transform)); + + new_settings->flag = settings->flag; + new_settings->exposure = settings->exposure; + new_settings->gamma = settings->gamma; + + if (settings->curve_mapping) + new_settings->curve_mapping = curvemapping_copy(settings->curve_mapping); +} + +void BKE_color_managed_view_settings_free(ColorManagedViewSettings *settings) +{ + if (settings->curve_mapping) + curvemapping_free(settings->curve_mapping); +} + +void BKE_color_managed_colorspace_settings_init(ColorManagedColorspaceSettings *colorspace_settings) +{ + BLI_strncpy(colorspace_settings->name, "", sizeof(colorspace_settings->name)); +} + +void BKE_color_managed_colorspace_settings_copy(ColorManagedColorspaceSettings *colorspace_settings, + const ColorManagedColorspaceSettings *settings) +{ + BLI_strncpy(colorspace_settings->name, settings->name, sizeof(colorspace_settings->name)); +} diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 3f756e74b26..d514a0a7dd0 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -47,6 +47,7 @@ #include "MEM_guardedalloc.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -70,6 +71,7 @@ #include "BLI_bpath.h" #include "BKE_bmfont.h" +#include "BKE_colortools.h" #include "BKE_global.h" #include "BKE_icons.h" #include "BKE_image.h" @@ -243,6 +245,11 @@ static Image *image_alloc(const char *name, short source, short type) ima->source = source; ima->type = type; + + if (source == IMA_SRC_VIEWER) + ima->flag |= IMA_VIEW_AS_RENDER; + + BKE_color_managed_colorspace_settings_init(&ima->colorspace_settings); } return ima; } @@ -325,6 +332,8 @@ Image *BKE_image_copy(Image *ima) nima->aspx = ima->aspx; nima->aspy = ima->aspy; + BKE_color_managed_colorspace_settings_copy(&nima->colorspace_settings, &ima->colorspace_settings); + return nima; } @@ -603,12 +612,10 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char if (floatbuf) { ibuf = IMB_allocImBuf(width, height, depth, IB_rectfloat); rect_float = ibuf->rect_float; - ibuf->profile = IB_PROFILE_LINEAR_RGB; } else { ibuf = IMB_allocImBuf(width, height, depth, IB_rect); rect = (unsigned char *)ibuf->rect; - ibuf->profile = IB_PROFILE_SRGB; } BLI_strncpy(ibuf->name, name, sizeof(ibuf->name)); @@ -1009,6 +1016,19 @@ int BKE_imtype_supports_quality(const char imtype) return 0; } +int BKE_imtype_supports_float(const char imtype) +{ + switch (imtype) { + case R_IMF_IMTYPE_CINEON: + case R_IMF_IMTYPE_DPX: + case R_IMF_IMTYPE_RADHDR: + case R_IMF_IMTYPE_OPENEXR: + case R_IMF_IMTYPE_MULTILAYER: + return TRUE; + } + return 0; +} + char BKE_imtype_valid_channels(const char imtype) { char chan_flag = IMA_CHAN_FLAG_RGB; /* assume all support rgb */ @@ -1477,10 +1497,11 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec int x, y, y_ofs; float h_fixed; const int mono = blf_mono_font_render; // XXX + struct ColorManagedDisplay *display; + const char *display_device; /* this could be an argument if we want to operate on non linear float imbuf's * for now though this is only used for renders which use scene settings */ - const int do_color_management = (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) != 0; #define BUFF_MARGIN_X 2 #define BUFF_MARGIN_Y 1 @@ -1488,6 +1509,9 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec if (!rect && !rectf) return; + display_device = scene->display_settings.display_device; + display = IMB_colormanagement_display_get_named(display_device); + stampdata(scene, camera, &stamp_data, 1); /* TODO, do_versions */ @@ -1497,7 +1521,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* set before return */ BLF_size(mono, scene->r.stamp_font_id, 72); - BLF_buffer(mono, rectf, rect, width, height, channels, do_color_management); + BLF_buffer(mono, rectf, rect, width, height, channels, display); BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0); pad = BLF_width_max(mono); @@ -1514,7 +1538,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec y -= h; /* also a little of space to the background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and draw the text. */ @@ -1531,7 +1555,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec y -= h; /* and space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); @@ -1547,7 +1571,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec y -= h; /* and space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); @@ -1563,7 +1587,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec y -= h; /* and space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); @@ -1578,7 +1602,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec BLF_width_and_height(mono, stamp_data.marker, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ @@ -1594,7 +1618,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec BLF_width_and_height(mono, stamp_data.time, &w, &h); h = h_fixed; /* extra space for background */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ @@ -1609,7 +1633,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec BLF_width_and_height(mono, stamp_data.frame, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ @@ -1624,7 +1648,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec BLF_width_and_height(mono, stamp_data.camera, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.camera); @@ -1637,7 +1661,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec BLF_width_and_height(mono, stamp_data.cameralens, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.cameralens); @@ -1650,7 +1674,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec x = width - w - 2; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ @@ -1666,7 +1690,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec y = height - h; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, do_color_management, + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, display, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); @@ -1878,12 +1902,12 @@ void BKE_makepicstring(char *string, const char *base, const char *relbase, int } /* used by sequencer too */ -struct anim *openanim(const char *name, int flags, int streamindex) +struct anim *openanim(const char *name, int flags, int streamindex, char colorspace[IMA_MAX_SPACE]) { struct anim *anim; struct ImBuf *ibuf; - anim = IMB_open_anim(name, flags, streamindex); + anim = IMB_open_anim(name, flags, streamindex, colorspace); if (anim == NULL) return NULL; ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE); @@ -2226,7 +2250,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) flag |= IB_premul; /* read ibuf */ - ibuf = IMB_loadiffname(name, flag); + ibuf = IMB_loadiffname(name, flag, ima->colorspace_settings.name); #if 0 if (ibuf) { @@ -2304,7 +2328,6 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f ibuf->flags |= IB_rectfloat; ibuf->mall = IB_rectfloat; ibuf->channels = rpass->channels; - ibuf->profile = IB_PROFILE_LINEAR_RGB; image_initialize_after_load(ima, ibuf); image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : 0, frame); @@ -2334,7 +2357,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) BKE_image_user_file_path(iuser, ima, str); /* FIXME: make several stream accessible in image editor, too*/ - ima->anim = openanim(str, IB_rect, 0); + ima->anim = openanim(str, IB_rect, 0, ima->colorspace_settings.name); /* let's initialize this user */ if (ima->anim && iuser && iuser->frames == 0) @@ -2385,8 +2408,8 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) flag = IB_rect | IB_multilayer; if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul; - ibuf = IMB_ibImageFromMemory((unsigned char *)ima->packedfile->data, - ima->packedfile->size, flag, "<packed data>"); + ibuf = IMB_ibImageFromMemory((unsigned char *)ima->packedfile->data, ima->packedfile->size, flag, + ima->colorspace_settings.name, "<packed data>"); } else { flag = IB_rect | IB_multilayer | IB_metadata; @@ -2398,7 +2421,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) BKE_image_user_file_path(iuser, ima, str); /* read ibuf */ - ibuf = IMB_loadiffname(str, flag); + ibuf = IMB_loadiffname(str, flag, ima->colorspace_settings.name); } if (ibuf) { @@ -2455,7 +2478,6 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser) ibuf->rect_float = rpass->rect; ibuf->flags |= IB_rectfloat; ibuf->channels = rpass->channels; - ibuf->profile = IB_PROFILE_LINEAR_RGB; image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : IMA_NO_INDEX, 0); } @@ -2561,6 +2583,12 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); } + /* invalidate color managed buffers if render result changed */ + BLI_lock_thread(LOCK_COLORMANAGE); + if (ibuf->x != rres.rectx || ibuf->y != rres.recty || ibuf->rect_float != rectf) { + ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; + } + ibuf->x = rres.rectx; ibuf->y = rres.recty; @@ -2592,8 +2620,8 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ ibuf->flags &= ~IB_zbuffloat; } - /* since its possible to access the buffer from the image directly, set the profile [#25073] */ - ibuf->profile = (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_NONE; + BLI_unlock_thread(LOCK_COLORMANAGE); + ibuf->dither = dither; if (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE) { diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index 4d7013b9f73..37572eebed6 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -289,7 +289,11 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width BLF_size(mono, 54, 72); /* hard coded size! */ - BLF_buffer(mono, rect_float, rect, width, height, 4, TRUE); + /* OCIO_TODO: using NULL as display will assume using sRGB display + * this is correct since currently generated images are assumed to be in sRGB space, + * but this would probably needed to be fixed in some way + */ + BLF_buffer(mono, rect_float, rect, width, height, 4, NULL); for (y = 0; y < height; y += step) { text[1] = '1'; diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 1a6a9503887..97d4c150b84 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -66,6 +66,7 @@ #include "BKE_animsys.h" #include "BKE_constraint.h" +#include "BKE_colortools.h" #include "BKE_library.h" #include "BKE_global.h" #include "BKE_main.h" @@ -73,6 +74,7 @@ #include "BKE_image.h" /* openanim */ #include "BKE_tracking.h" +#include "IMB_colormanagement.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_moviecache.h" @@ -197,19 +199,25 @@ static ImBuf *movieclip_load_sequence_file(MovieClip *clip, MovieClipUser *user, struct ImBuf *ibuf; char name[FILE_MAX]; int loadflag, use_proxy = FALSE; + char *colorspace; use_proxy = (flag & MCLIP_USE_PROXY) && user->render_size != MCLIP_PROXY_RENDER_SIZE_FULL; if (use_proxy) { int undistort = user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT; get_proxy_fname(clip, user->render_size, undistort, framenr, name); + + /* proxies were built using default color space settings */ + colorspace = NULL; } - else + else { get_sequence_fname(clip, framenr, name); + colorspace = clip->colorspace_settings.name; + } loadflag = IB_rect | IB_multilayer; /* read ibuf */ - ibuf = IMB_loadiffname(name, loadflag); + ibuf = IMB_loadiffname(name, loadflag, colorspace); return ibuf; } @@ -223,7 +231,7 @@ static void movieclip_open_anim_file(MovieClip *clip) BLI_path_abs(str, ID_BLEND_PATH(G.main, &clip->id)); /* FIXME: make several stream accessible in image editor, too */ - clip->anim = openanim(str, IB_rect, 0); + clip->anim = openanim(str, IB_rect, 0, clip->colorspace_settings.name); if (clip->anim) { if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) { @@ -478,6 +486,7 @@ static MovieClip *movieclip_alloc(const char *name) clip->aspx = clip->aspy = 1.0f; BKE_tracking_settings_init(&clip->tracking); + BKE_color_managed_colorspace_settings_init(&clip->colorspace_settings); clip->proxy.build_size_flag = IMB_PROXY_25; clip->proxy.build_tc_flag = IMB_TC_RECORD_RUN | diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index b862a824d50..4f3921936e8 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -1117,19 +1117,20 @@ void BKE_simulate_ocean_cache(struct OceanCache *och, int frame) /* if image is already loaded in mem, return */ if (och->ibufs_disp[f] != NULL) return; + /* use default color spaces since we know for sure cache files were saved with default settings too */ cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_DISPLACE); - och->ibufs_disp[f] = IMB_loadiffname(string, 0); + och->ibufs_disp[f] = IMB_loadiffname(string, 0, NULL); //if (och->ibufs_disp[f] == NULL) printf("error loading %s\n", string); //else printf("loaded cache %s\n", string); cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_FOAM); - och->ibufs_foam[f] = IMB_loadiffname(string, 0); + och->ibufs_foam[f] = IMB_loadiffname(string, 0, NULL); //if (och->ibufs_foam[f] == NULL) printf("error loading %s\n", string); //else printf("loaded cache %s\n", string); cache_filename(string, och->bakepath, och->relbase, frame, CACHE_TYPE_NORMAL); - och->ibufs_norm[f] = IMB_loadiffname(string, 0); + och->ibufs_norm[f] = IMB_loadiffname(string, 0, NULL); //if (och->ibufs_norm[f] == NULL) printf("error loading %s\n", string); //else printf("loaded cache %s\n", string); } @@ -1172,8 +1173,6 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v ibuf_disp = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat); ibuf_normal = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat); - ibuf_disp->profile = ibuf_foam->profile = ibuf_normal->profile = IB_PROFILE_LINEAR_RGB; - BKE_simulate_ocean(o, och->time[i], och->wave_scale, och->chop_amount); /* add new foam */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 145bd6a88e5..2dec72560a2 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -57,6 +57,7 @@ #include "BKE_anim.h" #include "BKE_animsys.h" +#include "BKE_colortools.h" #include "BKE_depsgraph.h" #include "BKE_global.h" #include "BKE_group.h" @@ -76,6 +77,8 @@ #include "RE_engine.h" +#include "IMB_colormanagement.h" + //XXX #include "BIF_previewrender.h" //XXX #include "BIF_editseq.h" @@ -132,6 +135,8 @@ Scene *BKE_scene_copy(Scene *sce, int type) MEM_freeN(scen->toolsettings); } else { + ImageFormatData *im_format, *im_formatn; + scen = BKE_libblock_copy(&sce->id); BLI_duplicatelist(&(scen->base), &(sce->base)); @@ -167,6 +172,13 @@ Scene *BKE_scene_copy(Scene *sce, int type) obase = obase->next; base = base->next; } + + /* copy color management settings */ + im_format = &sce->r.im_format; + im_formatn = &scen->r.im_format; + + BKE_color_managed_display_settings_copy(&scen->display_settings, &sce->display_settings); + BKE_color_managed_view_settings_copy(&scen->view_settings, &sce->view_settings); } /* tool settings */ @@ -332,6 +344,8 @@ void BKE_scene_free(Scene *sce) MEM_freeN(sce->fps_info); sound_destroy_scene(sce); + + BKE_color_managed_view_settings_free(&sce->view_settings); } Scene *BKE_scene_add(const char *name) @@ -372,7 +386,14 @@ Scene *BKE_scene_add(const char *name) sce->r.frs_sec_base = 1; sce->r.edgeint = 10; sce->r.ocres = 128; + + /* OCIO_TODO: for forwards compatibiliy only, so if no tonecurve are used, + * images would look in the same way as in current blender + * + * perhaps at some point should be completely deprecated? + */ sce->r.color_mgt_flag |= R_COLOR_MANAGEMENT; + sce->r.gauss = 1.0; /* deprecated but keep for upwards compat */ @@ -546,6 +567,9 @@ Scene *BKE_scene_add(const char *name) sound_create_scene(sce); + BKE_color_managed_display_settings_init(&sce->display_settings); + BKE_color_managed_view_settings_init(&sce->view_settings); + return sce; } @@ -1240,3 +1264,19 @@ void BKE_scene_base_flag_from_objects(struct Scene *scene) base = base->next; } } + +void BKE_scene_disable_color_management(Scene *scene) +{ + ColorManagedDisplaySettings *display_settings = &scene->display_settings; + ColorManagedViewSettings *view_settings = &scene->view_settings; + const char *view; + + /* NOTE: None display with Default view should always exist in OCIO configuration, otherwise it wouldn't work as expected */ + BLI_strncpy(display_settings->display_device, "None", sizeof(display_settings->display_device)); + + view = IMB_colormanagement_view_get_default_name(display_settings->display_device); + + if (view) { + BLI_strncpy(view_settings->view_transform, view, sizeof(view_settings->view_transform)); + } +} diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 4dbe0b6290c..eaf3ec384c8 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -52,6 +52,7 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#include "IMB_colormanagement.h" #include "RNA_access.h" @@ -119,13 +120,13 @@ static ImBuf *prepare_effect_imbufs(SeqRenderData context, ImBuf *ibuf1, ImBuf * } if (ibuf1 && !ibuf1->rect_float && out->rect_float) { - IMB_float_from_rect_simple(ibuf1); + BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf1, TRUE); } if (ibuf2 && !ibuf2->rect_float && out->rect_float) { - IMB_float_from_rect_simple(ibuf2); + BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf2, TRUE); } if (ibuf3 && !ibuf3->rect_float && out->rect_float) { - IMB_float_from_rect_simple(ibuf3); + BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf3, TRUE); } if (ibuf1 && !ibuf1->rect && !out->rect_float) { @@ -137,7 +138,7 @@ static ImBuf *prepare_effect_imbufs(SeqRenderData context, ImBuf *ibuf1, ImBuf * if (ibuf3 && !ibuf3->rect && !out->rect_float) { IMB_rect_from_float(ibuf3); } - + return out; } diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c index 65fcd0d85d6..b0dcad64722 100644 --- a/source/blender/blenkernel/intern/seqmodifier.c +++ b/source/blender/blenkernel/intern/seqmodifier.c @@ -581,6 +581,11 @@ ImBuf *BKE_sequence_modifier_apply_stack(SeqRenderData context, Sequence *seq, I SequenceModifierData *smd; ImBuf *processed_ibuf = ibuf; + if (seq->modifiers.first && (seq->flag & SEQ_USE_LINEAR_MODIFIERS)) { + processed_ibuf = IMB_dupImBuf(ibuf); + BKE_sequencer_imbuf_from_sequencer_space(context.scene, processed_ibuf); + } + for (smd = seq->modifiers.first; smd; smd = smd->next) { SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type); @@ -605,6 +610,10 @@ ImBuf *BKE_sequence_modifier_apply_stack(SeqRenderData context, Sequence *seq, I } } + if (seq->modifiers.first && (seq->flag & SEQ_USE_LINEAR_MODIFIERS)) { + BKE_sequencer_imbuf_to_sequencer_space(context.scene, processed_ibuf, FALSE); + } + return processed_ibuf; } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 2596bf57f05..8d7ca94ed48 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -71,6 +71,7 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" +#include "IMB_colormanagement.h" #include "BKE_context.h" #include "BKE_sound.h" @@ -308,6 +309,81 @@ void BKE_sequencer_editing_free(Scene *scene) scene->ed = NULL; } +/*********************** Sequencer color space functions *************************/ + +static void sequencer_imbuf_assign_spaces(Scene *scene, ImBuf *ibuf) +{ + IMB_colormanagement_imbuf_assign_float_space(ibuf, &scene->sequencer_colorspace_settings); +} + +void BKE_sequencer_imbuf_to_sequencer_space(Scene *scene, ImBuf *ibuf, int make_float) +{ + const char *from_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR); + const char *to_colorspace = scene->sequencer_colorspace_settings.name; + int predivide = ibuf->flags & IB_cm_predivide; + + if (!ibuf->rect_float) { + if (make_float && ibuf->rect) { + /* when converting byte buffer to float in sequencer we need to make float + * buffer be in sequencer's working space, which is currently only doable + * from linear space. + * + */ + + /* + * OCIO_TODO: would be nice to support direct single transform from byte to sequencer's + */ + + IMB_float_from_rect(ibuf); + } + else { + /* if there's only byte buffer in image it's already in compositor's working space, + * nothing to do here + */ + + return; + } + } + + if (from_colorspace && from_colorspace[0] != '\0') { + if (ibuf->rect) + imb_freerectImBuf(ibuf); + + IMB_colormanagement_transform_threaded(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels, + from_colorspace, to_colorspace, predivide); + } +} + +void BKE_sequencer_imbuf_from_sequencer_space(Scene *scene, ImBuf *ibuf) +{ + const char *from_colorspace = scene->sequencer_colorspace_settings.name; + const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR); + + if (!ibuf->rect_float) + return; + + if (to_colorspace && to_colorspace[0] != '\0') { + int predivide = ibuf->flags & IB_cm_predivide; + + IMB_colormanagement_transform_threaded(ibuf->rect_float, ibuf->x, ibuf->y, ibuf->channels, + from_colorspace, to_colorspace, predivide); + } +} + +void BKE_sequencer_pixel_from_sequencer_space_v4(struct Scene *scene, float pixel[4]) +{ + const char *from_colorspace = scene->sequencer_colorspace_settings.name; + const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR); + + if (to_colorspace && to_colorspace[0] != '\0') { + IMB_colormanagement_transform_v4(pixel, from_colorspace, to_colorspace); + } + else { + /* if no color management enables fallback to legacy conversion */ + srgb_to_linearrgb_v4(pixel, pixel); + } +} + /*********************** sequencer pipeline functions *************************/ SeqRenderData BKE_sequencer_new_render_data(Main *bmain, Scene *scene, int rectx, int recty, int preview_render_size) @@ -597,7 +673,9 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, int lock_range) BLI_path_abs(str, G.main->name); if (seq->anim) IMB_free_anim(seq->anim); - seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex); + + /* OCIO_TODO: support configurable input space for strips */ + seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, NULL); if (!seq->anim) { return; @@ -1094,7 +1172,8 @@ static void seq_open_anim_file(Sequence *seq) seq->strip->dir, seq->strip->stripdata->name); BLI_path_abs(name, G.main->name); - seq->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex); + /* OCIO_TODO: support configurable input space for strips */ + seq->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, NULL); if (seq->anim == NULL) { return; @@ -1200,8 +1279,9 @@ static ImBuf *seq_proxy_fetch(SeqRenderData context, Sequence *seq, int cfra) if (seq_proxy_get_fname(seq, cfra, render_size, name) == 0) { return NULL; } - - seq->strip->proxy->anim = openanim(name, IB_rect, 0); + + /* proxies are generated in default color space */ + seq->strip->proxy->anim = openanim(name, IB_rect, 0, NULL); } if (seq->strip->proxy->anim == NULL) { return NULL; @@ -1219,7 +1299,13 @@ static ImBuf *seq_proxy_fetch(SeqRenderData context, Sequence *seq, int cfra) } if (BLI_exists(name)) { - return IMB_loadiffname(name, IB_rect); + /* OCIO_TODO: support configurable spaces for strips */ + ImBuf *ibuf = IMB_loadiffname(name, IB_rect, NULL); + + if (ibuf) + sequencer_imbuf_assign_spaces(context.scene, ibuf); + + return ibuf; } else { return NULL; @@ -1257,7 +1343,8 @@ static void seq_proxy_build_frame(SeqRenderData context, Sequence *seq, int cfra ibuf->planes = 24; BLI_make_existing_file(name); - + + /* OCIO_TODO: support per-strip color space settings */ ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat); if (ok == 0) { perror(name); @@ -1706,7 +1793,7 @@ int BKE_sequencer_input_have_to_preprocess(SeqRenderData UNUSED(context), Sequen { float mul; - if (seq->flag & (SEQ_FILTERY | SEQ_USE_CROP | SEQ_USE_TRANSFORM | SEQ_FLIPX | SEQ_FLIPY | SEQ_MAKE_PREMUL)) { + if (seq->flag & (SEQ_FILTERY | SEQ_USE_CROP | SEQ_USE_TRANSFORM | SEQ_FLIPX | SEQ_FLIPY | SEQ_MAKE_PREMUL | SEQ_MAKE_FLOAT)) { return TRUE; } @@ -1826,8 +1913,9 @@ static ImBuf *input_preprocess(SeqRenderData context, Sequence *seq, float cfra, } if (seq->flag & SEQ_MAKE_FLOAT) { - if (!ibuf->rect_float) - IMB_float_from_rect_simple(ibuf); + if (!ibuf->rect_float) { + BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf, TRUE); + } if (ibuf->rect) { imb_freerectImBuf(ibuf); @@ -1893,6 +1981,8 @@ static void copy_to_ibuf_still(SeqRenderData context, Sequence *seq, float nr, I * changing the cached image... */ ibuf = IMB_dupImBuf(ibuf); + sequencer_imbuf_assign_spaces(context.scene, ibuf); + if (nr == 0) { BKE_sequencer_cache_put(context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL, ibuf); } @@ -2307,7 +2397,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float /* opengl offscreen render */ BKE_scene_update_for_newframe(context.bmain, scene, scene->lay); ibuf = sequencer_view3d_cb(scene, camera, context.rectx, context.recty, - IB_rect, context.scene->r.seq_prev_type, TRUE, err_out); + IB_rect, context.scene->r.seq_prev_type, TRUE, FALSE, err_out); if (ibuf == NULL) { fprintf(stderr, "seq_render_scene_strip failed to get opengl buffer: %s\n", err_out); } @@ -2338,11 +2428,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float } /* float buffers in the sequencer are not linear */ - if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) - ibuf->profile = IB_PROFILE_LINEAR_RGB; - else - ibuf->profile = IB_PROFILE_NONE; - IMB_convert_profile(ibuf, IB_PROFILE_SRGB); + BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf, FALSE); } else if (rres.rect32) { ibuf = IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect); @@ -2442,14 +2528,14 @@ static ImBuf *do_render_strip_uncached(SeqRenderData context, Sequence *seq, flo BLI_path_abs(name, G.main->name); } - if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect))) { + /* OCIO_TODO: support configurable space for image strips */ + if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect, NULL))) { /* we don't need both (speed reasons)! */ if (ibuf->rect_float && ibuf->rect) imb_freerectImBuf(ibuf); /* all sequencer color is done in SRGB space, linear gives odd crossfades */ - if (ibuf->profile == IB_PROFILE_LINEAR_RGB) - IMB_convert_profile(ibuf, IB_PROFILE_NONE); + BKE_sequencer_imbuf_to_sequencer_space(context.scene, ibuf, FALSE); copy_to_ibuf_still(context, seq, nr, ibuf); @@ -2497,6 +2583,7 @@ static ImBuf *do_render_strip_uncached(SeqRenderData context, Sequence *seq, flo case SEQ_TYPE_MOVIECLIP: { ibuf = seq_render_movieclip_strip(context, seq, nr); + sequencer_imbuf_assign_spaces(context.scene, ibuf); if (ibuf && use_preprocess) { ImBuf *i = IMB_dupImBuf(ibuf); @@ -2520,6 +2607,9 @@ static ImBuf *do_render_strip_uncached(SeqRenderData context, Sequence *seq, flo } } + if (ibuf) + sequencer_imbuf_assign_spaces(context.scene, ibuf); + return ibuf; } @@ -2561,8 +2651,10 @@ static ImBuf *seq_render_strip(SeqRenderData context, Sequence *seq, float cfra) } } - if (ibuf == NULL) + if (ibuf == NULL) { ibuf = IMB_allocImBuf(context.rectx, context.recty, 32, IB_rect); + sequencer_imbuf_assign_spaces(context.scene, ibuf); + } if (ibuf->x != context.rectx || ibuf->y != context.recty) use_preprocess = TRUE; @@ -2641,12 +2733,12 @@ static ImBuf *seq_render_strip_stack(SeqRenderData context, ListBase *seqbasep, if (count == 1) { out = seq_render_strip(context, seq_arr[0], cfra); + BKE_sequencer_cache_put(context, seq_arr[0], cfra, SEQ_STRIPELEM_IBUF_COMP, out); return out; } - for (i = count - 1; i >= 0; i--) { int early_out; Sequence *seq = seq_arr[i]; @@ -3946,7 +4038,8 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad BLI_strncpy(path, seq_load->path, sizeof(path)); BLI_path_abs(path, G.main->name); - an = openanim(path, IB_rect, 0); + /* OCIO_TODO: support configurable input space for strips */ + an = openanim(path, IB_rect, 0, NULL); if (an == NULL) return NULL; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index ff48f5db9aa..97ebc3a90ba 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1627,7 +1627,6 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *sea float *mask = NULL; pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y, 32, IB_rectfloat); - pattern_ibuf->profile = IB_PROFILE_LINEAR_RGB; if (!search_ibuf->rect_float) { IMB_float_from_rect(search_ibuf); @@ -1722,7 +1721,6 @@ ImBuf *BKE_tracking_get_search_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mov h = (marker->search_max[1] - marker->search_min[1]) * ibuf->y; searchibuf = IMB_allocImBuf(w, h, 32, ibuf->rect_float ? IB_rectfloat : IB_rect); - searchibuf->profile = ibuf->profile; IMB_rectcpy(searchibuf, ibuf, 0, 0, x, y, w, h); @@ -3317,7 +3315,6 @@ static ImBuf *stabilization_allocate_ibuf(ImBuf *cacheibuf, ImBuf *srcibuf, int } else { cacheibuf = IMB_allocImBuf(srcibuf->x, srcibuf->y, srcibuf->planes, flags); - cacheibuf->profile = srcibuf->profile; } return cacheibuf; |