[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51910] trunk/blender: Sequencer: input color space support for image and movie strips

Sergey Sharybin sergey.vfx at gmail.com
Mon Nov 5 15:44:30 CET 2012


Revision: 51910
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51910
Author:   nazgul
Date:     2012-11-05 14:44:29 +0000 (Mon, 05 Nov 2012)
Log Message:
-----------
Sequencer: input color space support for image and movie strips

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py
    trunk/blender/source/blender/blenkernel/BKE_sequencer.h
    trunk/blender/source/blender/blenkernel/intern/sequencer.c
    trunk/blender/source/blender/editors/space_sequencer/sequencer_add.c
    trunk/blender/source/blender/makesdna/DNA_sequence_types.h
    trunk/blender/source/blender/makesrna/intern/rna_color.c
    trunk/blender/source/blender/makesrna/intern/rna_sequencer.c
    trunk/blender/source/blender/makesrna/intern/rna_sequencer_api.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py	2012-11-05 14:39:49 UTC (rev 51909)
+++ trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py	2012-11-05 14:44:29 UTC (rev 51910)
@@ -601,6 +601,8 @@
                 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 @@
             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")
 

Modified: trunk/blender/source/blender/blenkernel/BKE_sequencer.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_sequencer.h	2012-11-05 14:39:49 UTC (rev 51909)
+++ trunk/blender/source/blender/blenkernel/BKE_sequencer.h	2012-11-05 14:44:29 UTC (rev 51910)
@@ -356,6 +356,7 @@
 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);

Modified: trunk/blender/source/blender/blenkernel/intern/sequencer.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/sequencer.c	2012-11-05 14:39:49 UTC (rev 51909)
+++ trunk/blender/source/blender/blenkernel/intern/sequencer.c	2012-11-05 14:44:29 UTC (rev 51910)
@@ -676,8 +676,8 @@
 
 			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 @@
 	                 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 @@
 	}
 
 	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 @@
 
 	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 @@
 				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 @@
 	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 *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 @@
 	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");
 

Modified: trunk/blender/source/blender/editors/space_sequencer/sequencer_add.c
===================================================================
--- trunk/blender/source/blender/editors/space_sequencer/sequencer_add.c	2012-11-05 14:39:49 UTC (rev 51909)
+++ trunk/blender/source/blender/editors/space_sequencer/sequencer_add.c	2012-11-05 14:44:29 UTC (rev 51910)
@@ -719,7 +719,9 @@
 			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);

Modified: trunk/blender/source/blender/makesdna/DNA_sequence_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_sequence_types.h	2012-11-05 14:39:49 UTC (rev 51909)
+++ trunk/blender/source/blender/makesdna/DNA_sequence_types.h	2012-11-05 14:44:29 UTC (rev 51910)
@@ -100,6 +100,9 @@
 	StripCrop *crop;
 	StripTransform *transform;
 	StripColorBalance *color_balance DNA_DEPRECATED;
+
+	/* color management */
+	ColorManagedColorspaceSettings colorspace_settings;
 } Strip;
 
 /**

Modified: trunk/blender/source/blender/makesrna/intern/rna_color.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_color.c	2012-11-05 14:39:49 UTC (rev 51909)
+++ trunk/blender/source/blender/makesrna/intern/rna_color.c	2012-11-05 14:44:29 UTC (rev 51910)
@@ -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 @@
 		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)

Modified: trunk/blender/source/blender/makesrna/intern/rna_sequencer.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_sequencer.c	2012-11-05 14:39:49 UTC (rev 51909)
+++ trunk/blender/source/blender/makesrna/intern/rna_sequencer.c	2012-11-05 14:44:29 UTC (rev 51910)
@@ -1688,6 +1688,16 @@
 #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 @@
 	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 @@
 	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)

Modified: trunk/blender/source/blender/makesrna/intern/rna_sequencer_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_sequencer_api.c	2012-11-05 14:39:49 UTC (rev 51909)
+++ trunk/blender/source/blender/makesrna/intern/rna_sequencer_api.c	2012-11-05 14:44:29 UTC (rev 51910)
@@ -89,6 +89,8 @@
 	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;




More information about the Bf-blender-cvs mailing list