[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12615] trunk/blender/source/blender: General cleanup in sequencer:

Peter Schlaile peter at schlaile.de
Sun Nov 18 18:39:31 CET 2007


Revision: 12615
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12615
Author:   schlaile
Date:     2007-11-18 18:39:30 +0100 (Sun, 18 Nov 2007)

Log Message:
-----------
General cleanup in sequencer:

- Seperated StripData into
  StripData
  TStripData
  where StripData holds only image-filenames and TStripData holds
  the working information needed for ImBuf caching.
  => Large drop in memory usage, if you used a lot of movie and meta strips.
  => Fixed bugs in "duplicate" on the way (imbufs where copied around without
     taking reference counting seriously...)
  => Code is much cleaner now
- Added defines for TStripData->ok
  Finally figured out, what the magic values ment and named them properly :)
- Got rid of Sequence->curelem.
  Reason: very bad idea(tm) for multi threading with more than one render
  thread. Still not there, but this was a real show stopper on the way.

Modified Paths:
--------------
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/include/BSE_sequence.h
    trunk/blender/source/blender/makesdna/DNA_sequence_types.h
    trunk/blender/source/blender/python/api2_2x/sceneSequence.c
    trunk/blender/source/blender/src/drawseq.c
    trunk/blender/source/blender/src/editseq.c
    trunk/blender/source/blender/src/sequence.c

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2007-11-17 21:12:25 UTC (rev 12614)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2007-11-18 17:39:30 UTC (rev 12615)
@@ -3204,7 +3204,6 @@
 	Editing *ed;
 	Sequence *seq;
 	MetaStack *ms;
-	StripElem *se;
 	int a;
 
 	sce->theDag = NULL;
@@ -3240,8 +3239,6 @@
 			/* a patch: after introduction of effects with 3 input strips */
 			if(seq->seq3==0) seq->seq3= seq->seq2;
 
-			seq->curelem= 0;
-
 			seq->plugin= newdataadr(fd, seq->plugin);
 			seq->effectdata= newdataadr(fd, seq->effectdata);
 			
@@ -3252,59 +3249,17 @@
 			seq->strip= newdataadr(fd, seq->strip);
 			if(seq->strip && seq->strip->done==0) {
 				seq->strip->done= 1;
+				seq->strip->tstripdata = 0;
 
-				/* standard: strips from effects/metas are not written, but are mallocced */
-
-				if(seq->type==SEQ_IMAGE) {
-					seq->strip->stripdata= newdataadr(fd, seq->strip->stripdata);
-					se= seq->strip->stripdata;
-					if(se) {
-						for(a=0; a<seq->strip->len; a++, se++) {
-							se->ok= 1;
-							se->ibuf= 0;
-						}
-					}
+				if(seq->type == SEQ_IMAGE ||
+				   seq->type == SEQ_MOVIE ||
+				   seq->type == SEQ_RAM_SOUND ||
+				   seq->type == SEQ_HD_SOUND) {
+					seq->strip->stripdata = newdataadr(
+						fd, seq->strip->stripdata);
+				} else {
+					seq->strip->stripdata = 0;
 				}
-				else if(seq->type==SEQ_MOVIE) {
-					/* only first stripelem is in file */
-					se= newdataadr(fd, seq->strip->stripdata);
-
-					if(se) {
-						seq->strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
-						*seq->strip->stripdata= *se;
-						MEM_freeN(se);
-
-						se= seq->strip->stripdata;
-
-						for(a=0; a<seq->strip->len; a++, se++) {
-							se->ok= 1;
-							se->ibuf= 0;
-							se->nr= a + 1;
-						}
-					}
-				}
-				else if(seq->type==SEQ_RAM_SOUND
-					|| seq->type == SEQ_HD_SOUND) {
-					/* only first stripelem is in file */
-					se= newdataadr(fd, seq->strip->stripdata);
-
-					if(se) {
-						seq->strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
-						*seq->strip->stripdata= *se;
-						MEM_freeN(se);
-
-						se= seq->strip->stripdata;
-
-						for(a=0; a<seq->strip->len; a++, se++) {
-							se->ok= 2; /* why? */
-							se->ibuf= 0;
-							se->nr= a + 1;
-						}
-					}
-				}
-				else if(seq->len>0)
-					seq->strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
-
 			}
 		}
 		END_SEQ

Modified: trunk/blender/source/blender/include/BSE_sequence.h
===================================================================
--- trunk/blender/source/blender/include/BSE_sequence.h	2007-11-17 21:12:25 UTC (rev 12614)
+++ trunk/blender/source/blender/include/BSE_sequence.h	2007-11-18 17:39:30 UTC (rev 12615)
@@ -37,6 +37,7 @@
 
 struct PluginSeq;
 struct StripElem;
+struct TStripElem;
 struct Strip;
 struct Sequence;
 struct ListBase;
@@ -44,9 +45,9 @@
 struct ImBuf;
 struct Scene;
 
-void free_stripdata(int len, struct StripElem *se);
+void free_tstripdata(int len, struct TStripElem *se);
 void free_strip(struct Strip *strip);
-void new_stripdata(struct Sequence *seq);
+void new_tstripdata(struct Sequence *seq);
 void free_sequence(struct Sequence *seq);
 void build_seqar(struct ListBase *seqbase, struct Sequence  ***seqar, int *totseq);
 void free_editing(struct Editing *ed);
@@ -57,17 +58,20 @@
 
 int evaluate_seq_frame(int cfra);
 struct StripElem *give_stripelem(struct Sequence *seq, int cfra);
+struct TStripElem *give_tstripelem(struct Sequence *seq, int cfra);
 void set_meta_stripdata(struct Sequence *seqm);
 struct ImBuf *give_ibuf_seq(int rectx, int recty, int cfra, int chansel); 
 /* chansel: render this channel. Default=0 (renders end result)*/
+struct ImBuf *give_ibuf_seq_direct(int rectx, int recty, int cfra,
+				   struct Sequence * seq);
 
 /* sequence prefetch API */
 void seq_start_threads();
 void seq_stop_threads();
 void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown);
 void seq_wait_for_prefetch_ready();
-struct ImBuf * give_ibuf_threaded(int rectx, int recty, int cfra, 
-				  int chanshown);
+struct ImBuf * give_ibuf_seq_threaded(int rectx, int recty, int cfra, 
+				      int chanshown);
 
 
 void free_imbuf_seq_except(int cfra);

Modified: trunk/blender/source/blender/makesdna/DNA_sequence_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_sequence_types.h	2007-11-17 21:12:25 UTC (rev 12614)
+++ trunk/blender/source/blender/makesdna/DNA_sequence_types.h	2007-11-18 17:39:30 UTC (rev 12615)
@@ -46,12 +46,15 @@
 
 typedef struct StripElem {
 	char name[80];
+} StripElem;
+
+typedef struct TStripElem {
 	struct ImBuf *ibuf;
-	struct StripElem *se1, *se2, *se3;
+	struct TStripElem *se1, *se2, *se3;
 	short ok;
 	short pad;
 	int nr;
-} StripElem;
+} TStripElem;
 
 typedef struct Strip {
 	struct Strip *next, *prev;
@@ -59,6 +62,7 @@
 	StripElem *stripdata;
 	char dir[160];
 	int orx, ory;
+	TStripElem *tstripdata;
 } Strip;
 
 
@@ -87,7 +91,6 @@
 /* WATCH IT: first part identical to ID (for use in ipo's) */
 
 typedef struct Sequence {
-
 	struct Sequence *next, *prev;
 	void *tmp; /* tmp var for copying, and tagging for linked selection */
 	void *lib; /* needed (to be like ipo), else it will raise libdata warnings, this should never be used */
@@ -104,7 +107,8 @@
 	int sfra;		/* starting frame according to the timeline of the scene. */
 
 	Strip *strip;
-	StripElem *curelem;	/* reference the current frame - value from give_stripelem */
+	int pad2;
+	int pad3;
 
 	struct Ipo *ipo;
 	struct Scene *scene;
@@ -234,6 +238,9 @@
 #define SEQ_COLOR               28
 #define SEQ_SPEED               29
 
+#define STRIPELEM_FAILED       0
+#define STRIPELEM_OK           1
+#define STRIPELEM_META         2
 
 #endif
 

Modified: trunk/blender/source/blender/python/api2_2x/sceneSequence.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/sceneSequence.c	2007-11-17 21:12:25 UTC (rev 12614)
+++ trunk/blender/source/blender/python/api2_2x/sceneSequence.c	2007-11-18 17:39:30 UTC (rev 12615)
@@ -156,7 +156,6 @@
 		for(a=0; a<seq->len; a++) {
 			name = PyString_AsString(PyList_GetItem( list, a ));
 			strncpy(se->name, name, FILE_MAXFILE-1);
-			se->ok= 1;
 			se++;
 		}		
 		
@@ -179,16 +178,10 @@
 		strip->len= totframe;
 		strip->us= 1;
 		strncpy(strip->dir, sound->name, FILE_MAXDIR-1);
-		strip->stripdata= se= MEM_callocN(totframe*sizeof(StripElem), "stripelem");
+		strip->stripdata= se= MEM_callocN(sizeof(StripElem), "stripelem");
 
 		/* name sound in first strip */
 		strncpy(se->name, sound->name, FILE_MAXFILE-1);
-
-		for(a=1; a<=totframe; a++, se++) {
-			se->ok= 2; /* why? */
-			se->ibuf= 0;
-			se->nr= a;
-		}
 		
 	} else if (BPy_Scene_Check(py_data)) {
 		/* scene */
@@ -205,8 +198,6 @@
 			sizeof(seq->name) - 2);
 		strip->len= seq->len;
 		strip->us= 1;
-		if(seq->len>0) strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem");
-		
 	} else {
 		/* movie, pydata is a path to a movie file */
 		char *name = PyString_AsString ( py_data );

Modified: trunk/blender/source/blender/src/drawseq.c
===================================================================
--- trunk/blender/source/blender/src/drawseq.c	2007-11-17 21:12:25 UTC (rev 12614)
+++ trunk/blender/source/blender/src/drawseq.c	2007-11-18 17:39:30 UTC (rev 12615)
@@ -775,7 +775,6 @@
 static void draw_image_seq(ScrArea *sa)
 {
 	SpaceSeq *sseq;
-	StripElem *se;
 	struct ImBuf *ibuf;
 	int x1, y1, rectx, recty;
 	int free_ibuf = 0;
@@ -800,10 +799,18 @@
 		return;
 	else {
 		recursive= 1;
-		if (!U.prefetchframes || (G.f & G_PLAYANIM) == 0) {
-			ibuf= (ImBuf *)give_ibuf_seq(rectx, recty, (G.scene->r.cfra), sseq->chanshown);
+		if (special_seq_update) {
+			ibuf= give_ibuf_seq_direct(
+				rectx, recty, (G.scene->r.cfra),
+				special_seq_update);
+		} else if (!U.prefetchframes || (G.f & G_PLAYANIM) == 0) {
+			ibuf= (ImBuf *)give_ibuf_seq(
+				rectx, recty, (G.scene->r.cfra), 
+				sseq->chanshown);
 		} else {
-			ibuf= (ImBuf *)give_ibuf_threaded(rectx, recty, (G.scene->r.cfra), sseq->chanshown);
+			ibuf= (ImBuf *)give_ibuf_seq_threaded(
+				rectx, recty, (G.scene->r.cfra), 
+				sseq->chanshown);
 		}
 		recursive= 0;
 		
@@ -815,16 +822,6 @@
 		}
 	}
 	
-	if(special_seq_update) {
-		se = special_seq_update->curelem;
-		if(se) {
-			if(se->ok==2) {
-				if(se->se1)
-					ibuf= se->se1->ibuf;
-			}
-			else ibuf= se->ibuf;
-		}
-	}
 	if(ibuf==NULL) 
 		return;
 	if(ibuf->rect_float && ibuf->rect==NULL)
@@ -862,7 +859,7 @@
 
 	if (free_ibuf) {
 		IMB_freeImBuf(ibuf);
-	}
+	} 
 
 	sa->win_swap= WIN_BACK_OK;
 }
@@ -917,7 +914,7 @@
 	if(last_seq->type==SEQ_IMAGE) {
 		if (last_seq->len > 1) {
 			/* CURRENT */
-			se= (StripElem *)give_stripelem(last_seq,  (G.scene->r.cfra));
+			se= give_stripelem(last_seq,  (G.scene->r.cfra));
 			if(se) {
 				sprintf(str, "Cur: %s", se->name);
 				glRasterPos3f(xco,  yco, 0.0);
@@ -966,7 +963,7 @@
 		BMF_DrawString(G.font, str);
 	}
 	else if(last_seq->type==SEQ_SCENE) {
-		se= (StripElem *)give_stripelem(last_seq,  (G.scene->r.cfra));
+		TStripElem * se= give_tstripelem(last_seq,  (G.scene->r.cfra));
 		if(se && last_seq->scene) {
 			sprintf(str, "Cur: %d  First: %d  Last: %d", last_seq->sfra+se->nr, last_seq->sfra, last_seq->sfra+last_seq->len-1); 
 			glRasterPos3f(xco,  yco, 0.0);

Modified: trunk/blender/source/blender/src/editseq.c
===================================================================
--- trunk/blender/source/blender/src/editseq.c	2007-11-17 21:12:25 UTC (rev 12614)
+++ trunk/blender/source/blender/src/editseq.c	2007-11-18 17:39:30 UTC (rev 12615)
@@ -985,7 +985,6 @@
 		if(sfile->filelist[a].flags & ACTIVE) {
 			if( (sfile->filelist[a].type & S_IFDIR)==0 ) {
 				strncpy(se->name, sfile->filelist[a].relname, FILE_MAXFILE-1);
-				se->ok= 1;
 				se++;
 			}
 		}
@@ -993,7 +992,6 @@
 	/* no selected file: */
 	if(totsel==1 && se==strip->stripdata) {
 		strncpy(se->name, sfile->file, FILE_MAXFILE-1);
-		se->ok= 1;
 	}
 
 	/* last active name */
@@ -1010,7 +1008,7 @@
 	struct anim *anim;
 	Strip *strip;
 	StripElem *se;
-	int totframe, a;
+	int totframe;
 	char name[160], rel[160];
 	char str[FILE_MAXDIR+FILE_MAXFILE];
 
@@ -1054,7 +1052,7 @@
 	strip->len= totframe;
 	strip->us= 1;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list