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

Peter Schlaile peter at schlaile.de
Sun Mar 2 15:54:45 CET 2008


Revision: 13940
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13940
Author:   schlaile
Date:     2008-03-02 15:54:45 +0100 (Sun, 02 Mar 2008)

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

Fixed a bug with ibuf caching on startstill / endstill.

The new blend modes happened to force start and endstill to be rendered
over and over again. This could get very annoying especially on scene
strips.

We therefore now cache the original start or endstill ibuf seperately
and copy on demand.

Modified Paths:
--------------
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/makesdna/DNA_sequence_types.h
    trunk/blender/source/blender/src/sequence.c

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2008-03-02 09:39:14 UTC (rev 13939)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2008-03-02 14:54:45 UTC (rev 13940)
@@ -3460,6 +3460,8 @@
 				seq->strip->tstripdata = 0;
 				seq->strip->tstripdata_startstill = 0;
 				seq->strip->tstripdata_endstill = 0;
+				seq->strip->ibuf_startstill = 0;
+				seq->strip->ibuf_endstill = 0;
 
 				if(seq->type == SEQ_IMAGE ||
 				   seq->type == SEQ_MOVIE ||

Modified: trunk/blender/source/blender/makesdna/DNA_sequence_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_sequence_types.h	2008-03-02 09:39:14 UTC (rev 13939)
+++ trunk/blender/source/blender/makesdna/DNA_sequence_types.h	2008-03-02 14:54:45 UTC (rev 13940)
@@ -97,6 +97,8 @@
 	TStripElem *tstripdata;
 	TStripElem *tstripdata_startstill;
 	TStripElem *tstripdata_endstill;
+	struct ImBuf *ibuf_startstill;
+	struct ImBuf *ibuf_endstill;
 } Strip;
 
 

Modified: trunk/blender/source/blender/src/sequence.c
===================================================================
--- trunk/blender/source/blender/src/sequence.c	2008-03-02 09:39:14 UTC (rev 13939)
+++ trunk/blender/source/blender/src/sequence.c	2008-03-02 14:54:45 UTC (rev 13940)
@@ -139,6 +139,16 @@
 	free_tstripdata(strip->endstill, strip->tstripdata_endstill);
 	free_tstripdata(strip->startstill, strip->tstripdata_startstill);
 
+	if(strip->ibuf_startstill) {
+		IMB_freeImBuf(strip->ibuf_startstill);
+		strip->ibuf_startstill = 0;
+	}
+
+	if(strip->ibuf_endstill) {
+		IMB_freeImBuf(strip->ibuf_endstill);
+		strip->ibuf_endstill = 0;
+	}
+
 	MEM_freeN(strip);
 }
 
@@ -155,6 +165,16 @@
 		seq->strip->tstripdata_endstill= 0;
 		seq->strip->tstripdata_startstill= 0;
 
+		if(seq->strip->ibuf_startstill) {
+			IMB_freeImBuf(seq->strip->ibuf_startstill);
+			seq->strip->ibuf_startstill = 0;
+		}
+
+		if(seq->strip->ibuf_endstill) {
+			IMB_freeImBuf(seq->strip->ibuf_endstill);
+			seq->strip->ibuf_endstill = 0;
+		}
+
 		seq->strip->len= seq->len;
 	}
 }
@@ -1538,6 +1558,61 @@
 	}
 }
 
+static void test_and_auto_discard_ibuf_stills(Strip * strip)
+{
+	if (strip->ibuf_startstill) {
+		if (!strip->ibuf_startstill->rect &&
+		    !strip->ibuf_startstill->rect_float) {
+			IMB_freeImBuf(strip->ibuf_startstill);
+			strip->ibuf_startstill = 0;
+		}
+	}
+	if (strip->ibuf_endstill) {
+		if (!strip->ibuf_endstill->rect &&
+		    !strip->ibuf_endstill->rect_float) {
+			IMB_freeImBuf(strip->ibuf_endstill);
+			strip->ibuf_endstill = 0;
+		}
+	}
+}
+
+static void copy_from_ibuf_still(Sequence * seq, TStripElem * se)
+{
+	if (!se->ibuf) {
+		if (se->nr == 0 && seq->strip->ibuf_startstill) {
+			IMB_cache_limiter_touch(seq->strip->ibuf_startstill);
+
+			se->ibuf = IMB_dupImBuf(seq->strip->ibuf_startstill);
+		}
+		if (se->nr == seq->len - 1 
+		    && (seq->len != 1)
+		    && seq->strip->ibuf_endstill) {
+			IMB_cache_limiter_touch(seq->strip->ibuf_endstill);
+
+			se->ibuf = IMB_dupImBuf(seq->strip->ibuf_endstill);
+		}
+	}
+}
+
+static void copy_to_ibuf_still(Sequence * seq, TStripElem * se)
+{
+	if (se->ibuf) {
+		if (se->nr == 0) {
+			seq->strip->ibuf_startstill = IMB_dupImBuf(se->ibuf);
+
+			IMB_cache_limiter_insert(seq->strip->ibuf_startstill);
+			IMB_cache_limiter_touch(seq->strip->ibuf_startstill);
+		}
+		if (se->nr == seq->len - 1 && seq->len != 1) {
+			seq->strip->ibuf_endstill = IMB_dupImBuf(se->ibuf);
+
+			IMB_cache_limiter_insert(seq->strip->ibuf_endstill);
+			IMB_cache_limiter_touch(seq->strip->ibuf_endstill);
+		}
+	}
+}
+
+
 static TStripElem* do_build_seq_array_recursively(
 	ListBase *seqbasep, int cfra, int chanshown);
 
@@ -1549,6 +1624,7 @@
 
 	if (seq->type != SEQ_META) {
 		test_and_auto_discard_ibuf(se);
+		test_and_auto_discard_ibuf_stills(seq->strip);
 	}
 
 	if(seq->type == SEQ_META) {
@@ -1606,9 +1682,12 @@
 			if (!build_proxy_run) {
 				se->ibuf = seq_proxy_fetch(seq, cfra);
 			}
+			copy_from_ibuf_still(seq, se);
+
 			if (!se->ibuf) {
 				se->ibuf= IMB_loadiffname(
 					name, IB_rect);
+				copy_to_ibuf_still(seq, se);
 			}
 			
 			if(se->ibuf == 0) {
@@ -1622,6 +1701,7 @@
 			if(!build_proxy_run) {
 				se->ibuf = seq_proxy_fetch(seq, cfra);
 			}
+			copy_from_ibuf_still(seq, se);
 
 			if (se->ibuf == 0) {
 				if(seq->anim==0) {
@@ -1635,6 +1715,7 @@
 					IMB_anim_set_preseek(seq->anim, seq->anim_preseek);
 					se->ibuf = IMB_anim_absolute(seq->anim, se->nr + seq->anim_startofs);
 				}
+				copy_to_ibuf_still(seq, se);
 			}
 			
 			if(se->ibuf == 0) {
@@ -1650,17 +1731,25 @@
 		RenderResult rres;
 		int doseq, rendering= G.rendering;
 		char scenename[64];
+		int sce_valid =sce&& (sce->camera || sce->r.scemode & R_DOSEQ);
 			
-		if (se->ibuf==NULL && sce && (sce->camera || sce->r.scemode & R_DOSEQ) && !build_proxy_run) {
+		if (se->ibuf == NULL && sce_valid && !build_proxy_run) {
 			se->ibuf = seq_proxy_fetch(seq, cfra);
 			if (se->ibuf) {
 				input_preprocess(seq, se, cfra);
 			}
 		}
+
+		if (se->ibuf == NULL && sce_valid) {
+			copy_from_ibuf_still(seq, se);
+			if (se->ibuf) {
+				input_preprocess(seq, se, cfra);
+			}
+		}
 		
-		if (sce && sce->camera==NULL && (sce->r.scemode & R_DOSEQ) == 0) {
+		if (!sce_valid) {
 			se->ok = STRIPELEM_FAILED;
-		} else if (se->ibuf==NULL && sce && (sce->camera || sce->r.scemode & R_DOSEQ) ) {
+		} else if (se->ibuf==NULL && sce_valid) {
 			waitcursor(1);
 			
 			/* Hack! This function can be called from do_render_seq(), in that case
@@ -1716,6 +1805,8 @@
 				waitcursor(0);
 			CFRA = oldcfra;
 
+			copy_to_ibuf_still(seq, se);
+
 			if (!build_proxy_run) {
 				if(se->ibuf == NULL) {
 					se->ok = STRIPELEM_FAILED;
@@ -2582,7 +2673,16 @@
 					free_imbuf_strip_elem(se);
 				}
 			}
+			if(seq->strip->ibuf_startstill) {
+				IMB_freeImBuf(seq->strip->ibuf_startstill);
+				seq->strip->ibuf_startstill = 0;
+			}
 
+			if(seq->strip->ibuf_endstill) {
+				IMB_freeImBuf(seq->strip->ibuf_endstill);
+				seq->strip->ibuf_endstill = 0;
+			}
+
 			if(seq->type==SEQ_MOVIE)
 				if(seq->startdisp > cfra || seq->enddisp < cfra)
 					free_anim_seq(seq);
@@ -2614,7 +2714,16 @@
 			    a < seq->strip->endstill && se; a++, se++) {
 				free_imbuf_strip_elem(se);
 			}
+			if(seq->strip->ibuf_startstill) {
+				IMB_freeImBuf(seq->strip->ibuf_startstill);
+				seq->strip->ibuf_startstill = 0;
+			}
 
+			if(seq->strip->ibuf_endstill) {
+				IMB_freeImBuf(seq->strip->ibuf_endstill);
+				seq->strip->ibuf_endstill = 0;
+			}
+
 			if(seq->type==SEQ_MOVIE)
 				free_anim_seq(seq);
 			if(seq->type==SEQ_SPEED) {





More information about the Bf-blender-cvs mailing list