From 39da85800161d91b6c0d6408a7c6e34c297d624a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 5 Nov 2012 14:44:29 +0000 Subject: Sequencer: input color space support for image and movie strips --- release/scripts/startup/bl_ui/space_sequencer.py | 4 +++ source/blender/blenkernel/BKE_sequencer.h | 1 + source/blender/blenkernel/intern/sequencer.c | 38 ++++++++++++++++------ .../editors/space_sequencer/sequencer_add.c | 4 ++- source/blender/makesdna/DNA_sequence_types.h | 3 ++ source/blender/makesrna/intern/rna_color.c | 33 +++++++++++++++++++ source/blender/makesrna/intern/rna_sequencer.c | 12 +++++++ source/blender/makesrna/intern/rna_sequencer_api.c | 2 ++ 8 files changed, 86 insertions(+), 11 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 14fbc7c34be..cba45d4c2b7 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -601,6 +601,8 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, Panel): split.label(text="File:") split.prop(elem, "filename", text="") # strip.elements[0] could be a fallback + layout.prop(strip.colorspace_settings, "name") + layout.operator("sequencer.change_path") elif seq_type == 'MOVIE': @@ -608,6 +610,8 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, Panel): split.label(text="Path:") split.prop(strip, "filepath", text="") + layout.prop(strip.colorspace_settings, "name") + layout.prop(strip, "mpeg_preseek") layout.prop(strip, "stream_index") diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 1667c119790..ba611817c8f 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -356,6 +356,7 @@ typedef struct SeqLoadInfo { typedef struct Sequence *(*SeqLoadFunc)(struct bContext *, ListBase *, struct SeqLoadInfo *); struct Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine); +void BKE_sequence_init_colorspace(struct Sequence *seq); struct Sequence *BKE_sequencer_add_image_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load); struct Sequence *BKE_sequencer_add_sound_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 80ea00fc703..af0cab98fe0 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -676,8 +676,8 @@ void BKE_sequence_reload_new_file(Scene *scene, Sequence *seq, int lock_range) if (seq->anim) IMB_free_anim(seq->anim); - /* OCIO_TODO: support configurable input space for strips */ - seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, NULL); + seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), + seq->streamindex, seq->strip->colorspace_settings.name); if (!seq->anim) { return; @@ -1174,8 +1174,8 @@ static void seq_open_anim_file(Sequence *seq) seq->strip->dir, seq->strip->stripdata->name); BLI_path_abs(name, G.main->name); - /* OCIO_TODO: support configurable input space for strips */ - seq->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex, NULL); + seq->anim = openanim(name, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), + seq->streamindex, seq->strip->colorspace_settings.name); if (seq->anim == NULL) { return; @@ -1301,7 +1301,6 @@ static ImBuf *seq_proxy_fetch(SeqRenderData context, Sequence *seq, int cfra) } if (BLI_exists(name)) { - /* OCIO_TODO: support configurable spaces for strips */ ImBuf *ibuf = IMB_loadiffname(name, IB_rect, NULL); if (ibuf) @@ -1346,7 +1345,6 @@ static void seq_proxy_build_frame(SeqRenderData context, Sequence *seq, int cfra 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); @@ -2529,8 +2527,7 @@ static ImBuf *do_render_strip_uncached(SeqRenderData context, Sequence *seq, flo BLI_path_abs(name, G.main->name); } - /* OCIO_TODO: support configurable space for image strips */ - if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect, NULL))) { + if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect, seq->strip->colorspace_settings.name))) { /* we don't need both (speed reasons)! */ if (ibuf->rect_float && ibuf->rect) imb_freerectImBuf(ibuf); @@ -3940,6 +3937,25 @@ Sequence *BKE_sequence_alloc(ListBase *lb, int cfra, int machine) return seq; } +void BKE_sequence_init_colorspace(Sequence *seq) +{ + if (seq->strip && seq->strip->stripdata) { + char name[FILE_MAX]; + ImBuf *ibuf; + + BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name); + BLI_path_abs(name, G.main->name); + + /* initialize input color space */ + if (seq->type == SEQ_TYPE_IMAGE) { + ibuf = IMB_loadiffname(name, IB_rect, seq->strip->colorspace_settings.name); + + if (ibuf) + IMB_freeImBuf(ibuf); + } + } +} + /* NOTE: this function doesn't fill in image names */ Sequence *BKE_sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo *seq_load) { @@ -4046,14 +4062,14 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad Sequence *seq; /* generic strip vars */ Strip *strip; StripElem *se; + char colorspace[64] = "\0"; /* MAX_COLORSPACE_NAME */ struct anim *an; BLI_strncpy(path, seq_load->path, sizeof(path)); BLI_path_abs(path, G.main->name); - /* OCIO_TODO: support configurable input space for strips */ - an = openanim(path, IB_rect, 0, NULL); + an = openanim(path, IB_rect, 0, colorspace); if (an == NULL) return NULL; @@ -4072,6 +4088,8 @@ Sequence *BKE_sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoad seq->len = IMB_anim_get_duration(an, IMB_TC_RECORD_RUN); strip->us = 1; + BLI_strncpy(seq->strip->colorspace_settings.name, colorspace, sizeof(seq->strip->colorspace_settings.name)); + /* we only need 1 element for MOVIE strips */ strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem"); diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index fd46f69da83..8155f9d645e 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -719,7 +719,9 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) seq->endstill = seq_load.end_frame - seq_load.start_frame; } } - + + BKE_sequence_init_colorspace(seq); + BKE_sequence_calc_disp(scene, seq); BKE_sequencer_sort(scene); diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 4d259fad246..f106c8f918a 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -100,6 +100,9 @@ typedef struct Strip { StripCrop *crop; StripTransform *transform; StripColorBalance *color_balance DNA_DEPRECATED; + + /* color management */ + ColorManagedColorspaceSettings colorspace_settings; } Strip; /** diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index c93d2ef15cf..f534864e65a 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -45,6 +45,7 @@ #include "DNA_material_types.h" #include "DNA_movieclip_types.h" #include "DNA_node_types.h" +#include "DNA_sequence_types.h" #include "MEM_guardedalloc.h" @@ -53,6 +54,7 @@ #include "BKE_image.h" #include "BKE_movieclip.h" #include "BKE_node.h" +#include "BKE_sequencer.h" #include "BKE_texture.h" #include "ED_node.h" @@ -504,6 +506,37 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain) WM_main_add_notifier(NC_MOVIECLIP | ND_DISPLAY, &clip->id); WM_main_add_notifier(NC_MOVIECLIP | NA_EDITED, &clip->id); } + else if (GS(id->name) == ID_SCE) { + Scene *scene = (Scene *) id; + + if (scene->ed) { + ColorManagedColorspaceSettings *colorspace_settings = (ColorManagedColorspaceSettings *) ptr->data; + Sequence *seq; + int seq_found = FALSE; + + if (&scene->sequencer_colorspace_settings != colorspace_settings) { + SEQ_BEGIN(scene->ed, seq); + { + if (seq->strip && &seq->strip->colorspace_settings == colorspace_settings) { + seq_found = TRUE; + break; + } + } + SEQ_END; + } + + if (seq_found) { + BKE_sequence_invalidate_cache(scene, seq); + BKE_sequencer_preprocessed_cache_cleanup_sequence(seq); + } + else { + BKE_sequencer_cache_cleanup(); + BKE_sequencer_preprocessed_cache_cleanup(); + } + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL); + } + } } static void rna_ColorManagement_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 054d0cc82c6..c2fa64698e4 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -1688,6 +1688,16 @@ static void rna_def_effect_inputs(StructRNA *srna, int count) #endif } +static void rna_def_color_management(StructRNA *srna) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "colorspace_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "strip->colorspace_settings"); + RNA_def_property_struct_type(prop, "ColorManagedColorspaceSettings"); + RNA_def_property_ui_text(prop, "Color Space Settings", "Input color space settings"); +} + static void rna_def_image(BlenderRNA *brna) { StructRNA *srna; @@ -1714,6 +1724,7 @@ static void rna_def_image(BlenderRNA *brna) rna_def_filter_video(srna); rna_def_proxy(srna); rna_def_input(srna); + rna_def_color_management(srna); } static void rna_def_meta(BlenderRNA *brna) @@ -1799,6 +1810,7 @@ static void rna_def_movie(BlenderRNA *brna) rna_def_filter_video(srna); rna_def_proxy(srna); rna_def_input(srna); + rna_def_color_management(srna); } static void rna_def_movieclip(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index 8ddb9d0a7e7..7602ec99c2b 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -89,6 +89,8 @@ static Sequence *alloc_generic_sequence(Editing *ed, const char *name, int start if (file) { strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem"); BLI_split_dirfile(file, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name)); + + BKE_sequence_init_colorspace(seq); } else { strip->stripdata = NULL; -- cgit v1.2.3