[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13084] trunk/blender/source/blender: == Sequencer ==

Peter Schlaile peter at schlaile.de
Tue Jan 1 12:44:42 CET 2008


Revision: 13084
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13084
Author:   schlaile
Date:     2008-01-01 12:44:42 +0100 (Tue, 01 Jan 2008)

Log Message:
-----------
== Sequencer ==

Attention! Rather large sequencer rewrite:

* Implemented layer blending using implicit effects. (works like layers 
  in "The Gimp" or Photoshop.)
* Fixed Space-Bar start-stop in preview windows.
  You can start playback using spacebar within a preview-window and it _works_!
* Fixed Flip Y (didn't work for float)
* Fixed premul (didn't work for float)
* Added IPOs to _all_ tracks. In blend-mode REPLACE it drives the 
  "mul"-parameter in all other blend modes it drives the effect.
* you can meta single tracks.
* moved "mute track" from "M" to "Shift-M"
* added "Shift-L" for "lock track"
* changed inner workings for Metas. Now all ImBufs have to use the
  reference counting mechanism. (Only interesting for coders :)

!!! Really important change, that affects current files!

Since you can mute tracks and now there is real layer blending capabilities
in place, I changed the silly behaviour that chose the output track.

Old behaviour: if we have an effect track visible, use the uppermost effect
track. If there is _no_ effect track visible, use the lowest input track.

New behaviour: always use the uppermost track. With blend modes active: 
work our way down starting from the uppermost track to the first 
"replace"-mode track. This is the way the gimp, photoshop, basically _all_
other applications work...

So if this change ruins your day: please try to fix your files using
"mute". If this doesn't work out, I can still restore the old behaviour,
but I really hope, that this is _not_ necessary!

Rational: most people won't get affected by this change, since you can't
really do anything usefull with the (old) sequencer without at least one 
effect track and then you are on the safe side...

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/image.c
    trunk/blender/source/blender/imbuf/intern/rotate.c
    trunk/blender/source/blender/include/BSE_seqeffects.h
    trunk/blender/source/blender/include/BSE_sequence.h
    trunk/blender/source/blender/makesdna/DNA_sequence_types.h
    trunk/blender/source/blender/src/buttons_scene.c
    trunk/blender/source/blender/src/drawseq.c
    trunk/blender/source/blender/src/drawview.c
    trunk/blender/source/blender/src/editipo.c
    trunk/blender/source/blender/src/editseq.c
    trunk/blender/source/blender/src/seqeffects.c
    trunk/blender/source/blender/src/sequence.c
    trunk/blender/source/blender/src/space.c
    trunk/blender/source/blender/src/toets.c

Modified: trunk/blender/source/blender/blenkernel/intern/image.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/image.c	2008-01-01 11:14:25 UTC (rev 13083)
+++ trunk/blender/source/blender/blenkernel/intern/image.c	2008-01-01 11:44:42 UTC (rev 13084)
@@ -98,32 +98,50 @@
 /* used by sequencer and image premul option - IMA_DO_PREMUL */
 void converttopremul(struct ImBuf *ibuf)
 {
-	int x, y, val;
-	char *cp;
+	int x, y;
 	
 	if(ibuf==0) return;
-	if(ibuf->depth==24) {	/* put alpha at 255 */
-		
-		cp= (char *)(ibuf->rect);
-		for(y=0; y<ibuf->y; y++) {
-			for(x=0; x<ibuf->x; x++, cp+=4) {
-				cp[3]= 255;
+	if (ibuf->rect) {
+		int val;
+		char *cp;
+		if(ibuf->depth==24) {	/* put alpha at 255 */
+			cp= (char *)(ibuf->rect);
+			for(y=0; y<ibuf->y; y++) {
+				for(x=0; x<ibuf->x; x++, cp+=4) {
+					cp[3]= 255;
+				}
 			}
+		} else {
+			cp= (char *)(ibuf->rect);
+			for(y=0; y<ibuf->y; y++) {
+				for(x=0; x<ibuf->x; x++, cp+=4) {
+					val= cp[3];
+					cp[0]= (cp[0]*val)>>8;
+					cp[1]= (cp[1]*val)>>8;
+					cp[2]= (cp[2]*val)>>8;
+				}
+			}
 		}
-		return;
 	}
-
-	cp= (char *)(ibuf->rect);
-	for(y=0; y<ibuf->y; y++) {
-		for(x=0; x<ibuf->x; x++, cp+=4) {
-			if(cp[3]==0) {
-				cp[0]= cp[1]= cp[2]= 0;
+	if (ibuf->rect_float) {
+		float val;
+		float *cp;
+		if(ibuf->depth==24) {	/* put alpha at 1.0 */
+			cp= ibuf->rect_float;;
+			for(y=0; y<ibuf->y; y++) {
+				for(x=0; x<ibuf->x; x++, cp+=4) {
+					cp[3]= 1.0;
+				}
 			}
-			else if(cp[3]!=255) {
-				val= cp[3];
-				cp[0]= (cp[0]*val)>>8;
-				cp[1]= (cp[1]*val)>>8;
-				cp[2]= (cp[2]*val)>>8;
+		} else {
+			cp= ibuf->rect_float;
+			for(y=0; y<ibuf->y; y++) {
+				for(x=0; x<ibuf->x; x++, cp+=4) {
+					val= cp[3];
+					cp[0]= cp[0]*val;
+					cp[1]= cp[1]*val;
+					cp[2]= cp[2]*val;
+				}
 			}
 		}
 	}

Modified: trunk/blender/source/blender/imbuf/intern/rotate.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/rotate.c	2008-01-01 11:14:25 UTC (rev 13083)
+++ trunk/blender/source/blender/imbuf/intern/rotate.c	2008-01-01 11:44:42 UTC (rev 13084)
@@ -43,48 +43,55 @@
 
 void IMB_flipy(struct ImBuf * ibuf)
 {
-	short x, y;
-	unsigned int *top, *bottom, do_float=0, *line;
-	float *topf=NULL, *bottomf=NULL, *linef=NULL;
+	int x, y;
 
 	if (ibuf == NULL) return;
-	if (ibuf->rect == NULL) return;
+
+	if (ibuf->rect) {
+		unsigned int *top, *bottom, *line;
+
+		x = ibuf->x;
+		y = ibuf->y;
+
+		top = ibuf->rect;
+		bottom = top + ((y-1) * x);
+		line= MEM_mallocN(x*sizeof(int), "linebuf");
 	
-	if (ibuf->rect_float) do_float =1;
+		y >>= 1;
 
-	x = ibuf->x;
-	y = ibuf->y;
+		for(;y>0;y--) {
+			memcpy(line, top, x*sizeof(int));
+			memcpy(top, bottom, x*sizeof(int));
+			memcpy(bottom, line, x*sizeof(int));
+			bottom -= x;
+			top+= x;
+		}
 
-	top = ibuf->rect;
-	bottom = top + ((y-1) * x);
-	line= MEM_mallocN(x*sizeof(int), "linebuf");
-	
-	if (do_float) {
+		MEM_freeN(line);
+	}
+
+	if (ibuf->rect_float) {
+		float *topf=NULL, *bottomf=NULL, *linef=NULL;
+
+		x = ibuf->x;
+		y = ibuf->y;
+
 		topf= ibuf->rect_float;
 		bottomf = topf + 4*((y-1) * x);
 		linef= MEM_mallocN(4*x*sizeof(float), "linebuff");
-	}
-	y >>= 1;
 
-	for(;y>0;y--) {
-		
-		memcpy(line, top, x*sizeof(int));
-		memcpy(top, bottom, x*sizeof(int));
-		memcpy(bottom, line, x*sizeof(int));
-		bottom -= x;
-		top+= x;
-		
-		if(do_float) {
+		y >>= 1;
+
+		for(;y>0;y--) {
 			memcpy(linef, topf, 4*x*sizeof(float));
 			memcpy(topf, bottomf, 4*x*sizeof(float));
 			memcpy(bottomf, linef, 4*x*sizeof(float));
 			bottomf -= 4*x;
 			topf+= 4*x;
 		}
+
+		MEM_freeN(linef);
 	}
-	
-	MEM_freeN(line);
-	if(linef) MEM_freeN(linef);
 }
 
 void IMB_flipx(struct ImBuf * ibuf)

Modified: trunk/blender/source/blender/include/BSE_seqeffects.h
===================================================================
--- trunk/blender/source/blender/include/BSE_seqeffects.h	2008-01-01 11:14:25 UTC (rev 13083)
+++ trunk/blender/source/blender/include/BSE_seqeffects.h	2008-01-01 11:44:42 UTC (rev 13084)
@@ -89,6 +89,7 @@
 };
 
 struct SeqEffectHandle get_sequence_effect(struct Sequence * seq);
+struct SeqEffectHandle get_sequence_blend(struct Sequence * seq);
 int get_sequence_effect_num_inputs(int seq_type);
 void sequence_effect_speed_rebuild_map(struct Sequence * seq, int force);
 

Modified: trunk/blender/source/blender/include/BSE_sequence.h
===================================================================
--- trunk/blender/source/blender/include/BSE_sequence.h	2008-01-01 11:14:25 UTC (rev 13083)
+++ trunk/blender/source/blender/include/BSE_sequence.h	2008-01-01 11:44:42 UTC (rev 13084)
@@ -64,6 +64,9 @@
 void sort_seq(void);
 void clear_scene_in_allseqs(struct Scene *sce);
 
+char *give_seqname_by_type(int type);
+char *give_seqname(struct Sequence *seq);
+
 int evaluate_seq_frame(int cfra);
 struct StripElem *give_stripelem(struct Sequence *seq, int cfra);
 struct TStripElem *give_tstripelem(struct Sequence *seq, int cfra);

Modified: trunk/blender/source/blender/makesdna/DNA_sequence_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_sequence_types.h	2008-01-01 11:14:25 UTC (rev 13083)
+++ trunk/blender/source/blender/makesdna/DNA_sequence_types.h	2008-01-01 11:44:42 UTC (rev 13084)
@@ -50,6 +50,7 @@
 
 typedef struct TStripElem {
 	struct ImBuf *ibuf;
+	struct ImBuf *ibuf_comp;
 	struct TStripElem *se1, *se2, *se3;
 	short ok;
 	short pad;
@@ -267,14 +268,17 @@
 #define SEQ_TRANSFORM		27
 #define SEQ_COLOR               28
 #define SEQ_SPEED               29
+#define SEQ_EFFECT_MAX          29
 
 #define STRIPELEM_FAILED       0
 #define STRIPELEM_OK           1
 #define STRIPELEM_META         2
 
 #define SEQ_BLEND_REPLACE      0
-#define SEQ_BLEND_ALPHA_OVER   1
+/* all other BLEND_MODEs are simple SEQ_EFFECT ids and therefore identical
+   to the table above. (Only those effects that handle _exactly_ two inputs,
+   otherwise, you can't really blend, right :) !)
+*/
 
-
 #endif
 

Modified: trunk/blender/source/blender/src/buttons_scene.c
===================================================================
--- trunk/blender/source/blender/src/buttons_scene.c	2008-01-01 11:14:25 UTC (rev 13083)
+++ trunk/blender/source/blender/src/buttons_scene.c	2008-01-01 11:44:42 UTC (rev 13084)
@@ -483,22 +483,40 @@
 static char* seq_panel_blend_modes()
 {
 	static char string[2048];
-	char formatstring[2048];
 
-       strcpy(formatstring, "Blend mode: %%t|%s %%x%d|%s %%x%d");
-       sprintf(string, formatstring,
-               "REPLACE", SEQ_BLEND_REPLACE,
-               "TODO: ALPHA OVER", SEQ_BLEND_ALPHA_OVER);
-       return string;
+	Sequence *last_seq = get_last_seq();
 
+	sprintf(string, "Blend mode: %%t|%s %%x%d",
+		"Replace", SEQ_BLEND_REPLACE);
+
+	/*
+	  Blending can only work without effect strips. 
+	  Otherwise, one would have
+	  to decide, what the effect strips IPO should do:
+	  - drive the effect _or_
+	  - drive the blend mode ?
+
+	  Also: effectdata is used by these implicit effects,
+	  so that would collide also.
+	*/
+
+	if (!(last_seq->type & SEQ_EFFECT)) {
+		int i;
+
+		for (i = SEQ_EFFECT; i <= SEQ_EFFECT_MAX; i++) {
+			if (get_sequence_effect_num_inputs(i) == 2) {
+				sprintf(string + strlen(string), 
+					"|%s %%x%d", 
+					give_seqname_by_type(i), i);
+			}
+		}
+	}
+	return string;
 }
 
 static void seq_panel_editing()
 {
 	Sequence *last_seq = get_last_seq();
-	char * seq_names[] = { "Image", "Meta", "Scene", "Movie",
-			       "Snd RAM", "Snd HD",
-			       "", "Effect" };
 	uiBlock *block;
 	static char strdata[1024];
 	char * str = strdata;
@@ -512,8 +530,7 @@
 		      10, 230, 318, 204) == 0) return;
 
 	uiDefBut(block, LABEL, 
-		 0, (last_seq->type >= SEQ_EFFECT) ? 
-		 "Effect" : seq_names[last_seq->type], 
+		 0, give_seqname(last_seq), 
 		 10,140,60,19, 0, 
 		 0, 0, 0, 0, "");
 
@@ -575,11 +592,13 @@
 			uiDefButI(block, NUM, 
 				  B_SEQ_BUT_TRANSFORM, "Start-Ofs", 
 				  10, 60, 120, 20, &last_seq->startofs, 
-				  0.0, last_seq->len, 0.0, 0.0, "Start offset");
+				  0.0, last_seq->len - last_seq->endofs, 
+				  0.0, 0.0, "Start offset");
 			uiDefButI(block, NUM, 
 				  B_SEQ_BUT_TRANSFORM, "End-Ofs", 
 				  130, 60, 120, 19, &last_seq->endofs, 
-				  0.0, last_seq->len, 0.0, 0.0, "End offset");
+				  0.0, last_seq->len - last_seq->startofs, 
+				  0.0, 0.0, "End offset");
 		}
 	}
 
@@ -672,16 +691,20 @@
 {
 	Sequence *last_seq = get_last_seq();
 	uiBlock *block;
+
 	block = uiNewBlock(&curarea->uiblocks, "seq_panel_input", 
 			   UI_EMBOSS, UI_HELV, curarea->win);
 
 	if(uiNewPanel(curarea, block, "Input", "Sequencer", 
 		      10, 230, 318, 204) == 0) return;
 
-	uiDefBut(block, TEX, 
-		 B_SEQ_BUT_RELOAD_FILE, "Dir: ", 
-		 10,140,240,19, last_seq->strip->dir, 
-		 0.0, 160.0, 100, 0, "");
+	if (last_seq->type == SEQ_MOVIE 
+	    || last_seq->type == SEQ_IMAGE) {
+		uiDefBut(block, TEX, 
+			 B_SEQ_BUT_RELOAD_FILE, "Dir: ", 
+			 10,140,240,19, last_seq->strip->dir, 
+			 0.0, 160.0, 100, 0, "");
+	}
 
 	if (last_seq->type == SEQ_IMAGE) {
 		StripElem * se = give_stripelem(last_seq, CFRA);
@@ -702,73 +725,89 @@
 			 0.0, 80.0, 100, 0, "");
 	}
 
-	uiDefButBitI(block, TOG, SEQ_USE_CROP,
-		     B_SEQ_BUT_RELOAD, "Use Crop",
-		     10,100,240,19, &last_seq->flag,
-		     0.0, 1.0, 0, 0,
-		     "Crop image before processing.");
+	if (last_seq->type == SEQ_MOVIE 
+	    || last_seq->type == SEQ_IMAGE 
+	    || last_seq->type == SEQ_SCENE) {
+		uiDefButBitI(block, TOG, SEQ_USE_CROP,
+			     B_SEQ_BUT_RELOAD, "Use Crop",
+			     10,100,240,19, &last_seq->flag,
+			     0.0, 1.0, 0, 0,
+			     "Crop image before processing.");
 
-	if (last_seq->flag & SEQ_USE_CROP) {
-		if (!last_seq->strip->crop) {
-			last_seq->strip->crop = 
-				MEM_callocN(sizeof(struct StripCrop), 
-					    "StripCrop");
+		if (last_seq->flag & SEQ_USE_CROP) {
+			if (!last_seq->strip->crop) {
+				last_seq->strip->crop = 
+					MEM_callocN(sizeof(struct StripCrop), 
+						    "StripCrop");
+			}
+			uiDefButI(block, NUM, 
+				  B_SEQ_BUT_RELOAD, "Top", 
+				  10, 80, 120, 20, 
+				  &last_seq->strip->crop->top, 
+				  0.0, 4096, 0.0, 0.0, "Top of source image");
+			uiDefButI(block, NUM, 
+				  B_SEQ_BUT_RELOAD, "Bottom", 
+				  130, 80, 120, 20, 
+				  &last_seq->strip->crop->bottom, 
+				  0.0, 4096, 0.0, 0.0,
+				  "Bottom of source image");
+			
+			uiDefButI(block, NUM, 
+				  B_SEQ_BUT_RELOAD, "Left", 
+				  10, 60, 120, 20,

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list