[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17864] branches/blender2.5/blender/source /blender:

Brecht Van Lommel brecht at blender.org
Mon Dec 15 06:21:44 CET 2008


Revision: 17864
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17864
Author:   blendix
Date:     2008-12-15 06:21:44 +0100 (Mon, 15 Dec 2008)

Log Message:
-----------

2.50: added sequence.c in blenkernel for sequencer functionality
that is not supposed to be in the editor but at blenkernel level
to avoid bad level calls. Added sequencer free and strip iterator
functions there and used them to make sequencer data load/save
work again.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_scene.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c
    branches/blender2.5/blender/source/blender/blenlib/intern/bpath.c
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c
    branches/blender2.5/blender/source/blender/editors/screen/stubs.c

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/blenkernel/BKE_sequence.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/sequence.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_scene.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_scene.h	2008-12-15 01:04:44 UTC (rev 17863)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_scene.h	2008-12-15 05:21:44 UTC (rev 17864)
@@ -40,19 +40,6 @@
 struct SculptData;
 struct RenderData;
 
-/* sequence related defines */
-
-#define WHILE_SEQ(base)	{											\
-	int totseq_, seq_; Sequence **seqar;	\
-		build_seqar( base,  &seqar, &totseq_);	\
-			for(seq_ = 0; seq_ < totseq_; seq_++) {	\
-				seq= seqar[seq_];
-				
-				
-#define END_SEQ					}						\
-				if(seqar) MEM_freeN(seqar);		\
-}
-
 /* note; doesn't work when scene is empty */
 #define SETLOOPER(s, b) sce= s, b= (Base*)sce->base.first; b; b= (Base*)(b->next?b->next:sce->set?(sce=sce->set)->base.first:NULL)
 

Added: branches/blender2.5/blender/source/blender/blenkernel/BKE_sequence.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_sequence.h	                        (rev 0)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_sequence.h	2008-12-15 05:21:44 UTC (rev 17864)
@@ -0,0 +1,70 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License.  See http://www.blender.org/BL/ for information
+ * about this.	
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2004 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation (2008).
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef BKE_SEQUENCE_H
+#define BKE_SEQUENCE_H
+
+struct Editing;
+struct Sequence;
+
+/* free */
+
+void seq_free_sequence(struct Sequence *seq);
+void seq_free_editing(struct Editing *ed);
+
+/* sequence iterator */
+
+typedef struct SeqIterator {
+	struct Sequence **array;
+	int tot, cur;
+
+	struct Sequence *seq;
+	int valid;
+} SeqIterator;
+
+void seq_begin(struct Editing *ed, SeqIterator *iter);
+void seq_next(SeqIterator *iter);
+void seq_end(SeqIterator *iter);
+
+void seq_array(struct Editing *ed, struct Sequence ***array, int *tot);
+
+#define SEQ_BEGIN(ed, seq) \
+	{ \
+		SeqIterator iter;\
+		for(seq_begin(ed, &iter); iter.valid; seq_next(&iter)) { \
+			seq= iter.seq;
+
+#define SEQ_END \
+		} \
+		seq_end(&iter); \
+	}
+
+#endif
+

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c	2008-12-15 01:04:44 UTC (rev 17863)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/scene.c	2008-12-15 05:21:44 UTC (rev 17864)
@@ -76,6 +76,7 @@
 #include "BKE_object.h"
 #include "BKE_scene.h"
 #include "BKE_sculpt.h"
+#include "BKE_sequence.h"
 #include "BKE_world.h"
 #include "BKE_utildefines.h"
 
@@ -138,7 +139,7 @@
 	/* do not free objects! */
 
 	BLI_freelistN(&sce->base);
-	//XXX free_editing(sce->ed);
+	seq_free_editing(sce->ed);
 	if(sce->radio) MEM_freeN(sce->radio);
 	sce->radio= 0;
 	

Added: branches/blender2.5/blender/source/blender/blenkernel/intern/sequence.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/sequence.c	                        (rev 0)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/sequence.c	2008-12-15 05:21:44 UTC (rev 17864)
@@ -0,0 +1,235 @@
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_listBase.h"
+#include "DNA_sequence_types.h"
+
+#include "BLI_blenlib.h"
+
+#include "IMB_imbuf.h"
+
+#include "BKE_sequence.h"
+
+/* strip data */
+
+static void free_tstripdata(int len, TStripElem *se)
+{
+	TStripElem *seo;
+	int a;
+
+	seo= se;
+	if (!se)
+		return;
+
+	for(a=0; a<len; a++, se++) {
+		if(se->ibuf) {
+			IMB_freeImBuf(se->ibuf);
+			se->ibuf = 0;
+		}
+		if(se->ibuf_comp) {
+			IMB_freeImBuf(se->ibuf_comp);
+			se->ibuf_comp = 0;
+		}
+	}
+
+	MEM_freeN(seo);
+}
+
+/*
+static void new_tstripdata(Sequence *seq)
+{
+	if(seq->strip) {
+		free_tstripdata(seq->strip->len, seq->strip->tstripdata);
+		free_tstripdata(seq->strip->endstill, 
+				seq->strip->tstripdata_endstill);
+		free_tstripdata(seq->strip->startstill, 
+				seq->strip->tstripdata_startstill);
+
+		seq->strip->tstripdata= 0;
+		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;
+	}
+}
+*/
+
+/* free */
+
+static void seq_free_strip(Strip *strip)
+{
+	strip->us--;
+	if(strip->us>0) return;
+	if(strip->us<0) {
+		printf("error: negative users in strip\n");
+		return;
+	}
+
+	if (strip->stripdata) {
+		MEM_freeN(strip->stripdata);
+	}
+
+	if (strip->proxy) {
+		MEM_freeN(strip->proxy);
+	}
+	if (strip->crop) {
+		MEM_freeN(strip->crop);
+	}
+	if (strip->transform) {
+		MEM_freeN(strip->transform);
+	}
+	if (strip->color_balance) {
+		MEM_freeN(strip->color_balance);
+	}
+
+	free_tstripdata(strip->len, strip->tstripdata);
+	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);
+}
+
+void seq_free_sequence(Sequence *seq)
+{
+	//XXX Sequence *last_seq = get_last_seq();
+
+	if(seq->strip) seq_free_strip(seq->strip);
+
+	if(seq->anim) IMB_free_anim(seq->anim);
+	//XXX if(seq->hdaudio) sound_close_hdaudio(seq->hdaudio);
+
+	/* XXX if (seq->type & SEQ_EFFECT) {
+		struct SeqEffectHandle sh = get_sequence_effect(seq);
+
+		sh.free(seq);
+	}*/
+
+	//XXX if(seq==last_seq) set_last_seq(NULL);
+
+	MEM_freeN(seq);
+}
+
+void seq_free_editing(Editing *ed)
+{
+	MetaStack *ms;
+	Sequence *seq;
+
+	if(ed==NULL)
+		return;
+	
+	//XXX set_last_seq(NULL); /* clear_last_seq doesnt work, it screws up free_sequence */
+
+	SEQ_BEGIN(ed, seq) {
+		seq_free_sequence(seq);
+	}
+	SEQ_END
+
+	while((ms= ed->metastack.first)) {
+		BLI_remlink(&ed->metastack, ms);
+		MEM_freeN(ms);
+	}
+
+	MEM_freeN(ed);
+}
+
+/* sequence strip iterator:
+ * - builds a full array, recursively into meta strips */
+
+static void seq_count(ListBase *seqbase, int *tot)
+{
+	Sequence *seq;
+
+	for(seq=seqbase->first; seq; seq=seq->next) {
+		(*tot)++;
+
+		if(seq->seqbase.first)
+			seq_count(&seq->seqbase, tot);
+	}
+}
+
+static void seq_build_array(ListBase *seqbase, Sequence ***array, int depth)
+{
+	Sequence *seq;
+
+	for(seq=seqbase->first; seq; seq=seq->next) {
+		seq->depth= depth;
+
+		if(seq->seqbase.first)
+			seq_build_array(&seq->seqbase, array, depth+1);
+
+		**array= seq;
+		(*array)++;
+	}
+}
+
+void seq_array(Editing *ed, Sequence ***seqarray, int *tot)
+{
+	Sequence **array;
+
+	*seqarray= NULL;
+	*tot= 0;
+
+	if(ed == NULL)
+		return;
+
+	seq_count(&ed->seqbase, tot);
+
+	if(*tot == 0)
+		return;
+
+	*seqarray= array= MEM_mallocN(sizeof(Sequence *)*(*tot), "SeqArray");
+	seq_build_array(&ed->seqbase, &array, 0);
+}
+
+void seq_begin(Editing *ed, SeqIterator *iter)
+{
+	memset(iter, 0, sizeof(*iter));
+	seq_array(ed, &iter->array, &iter->tot);
+
+	if(iter->tot) {
+		iter->cur= 0;
+		iter->seq= iter->array[iter->cur];
+		iter->valid= 1;
+	}
+}
+
+void seq_next(SeqIterator *iter)
+{
+	if(++iter->cur < iter->tot)
+		iter->seq= iter->array[iter->cur];
+	else
+		iter->valid= 0;
+}
+
+void seq_end(SeqIterator *iter)
+{
+	if(iter->array)
+		MEM_freeN(iter->array);
+
+	iter->valid= 0;
+}
+
+

Modified: branches/blender2.5/blender/source/blender/blenlib/intern/bpath.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/intern/bpath.c	2008-12-15 01:04:44 UTC (rev 17863)
+++ branches/blender2.5/blender/source/blender/blenlib/intern/bpath.c	2008-12-15 05:21:44 UTC (rev 17864)
@@ -26,34 +26,33 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#include "BLI_bpath.h"
-#include "BKE_global.h"
-//XXX #include "BIF_screen.h" /* only for wait cursor */
+#include "MEM_guardedalloc.h"
+
 #include "DNA_ID.h" /* Library */
 #include "DNA_vfont_types.h"
 #include "DNA_image_types.h"
 #include "DNA_sound_types.h"
 #include "DNA_scene_types.h" /* to get the current frame */
 #include "DNA_sequence_types.h"
-#include <stdlib.h>
-#include <string.h>
+#include "DNA_text_types.h"
 
-#include "BKE_main.h" /* so we can access G.main->*.first */
-#include "BKE_image.h" /* so we can check the image's type */
+#include "BLI_blenlib.h"
+#include "BLI_bpath.h"
 
+#include "BKE_global.h"
+#include "BKE_image.h" /* so we can check the image's type */
+#include "BKE_main.h" /* so we can access G.main->*.first */
+#include "BKE_sequence.h"
+#include "BKE_text.h" /* for writing to a textblock */
 #include "BKE_utildefines.h"
-#include "MEM_guardedalloc.h"
 
+//XXX #include "BIF_screen.h" /* only for wait cursor */
+//
 /* for sequence */
 //XXX #include "BSE_sequence.h"
 //XXX define below from BSE_sequence.h - otherwise potentially odd behaviour
 #define SEQ_HAS_PATH(seq) (seq->type==SEQ_MOVIE || seq->type==SEQ_HD_SOUND || seq->type==SEQ_RAM_SOUND || seq->type==SEQ_IMAGE)
 
-/* for writing to a textblock */
-#include "BKE_text.h" 
-#include "BLI_blenlib.h"
-#include "DNA_text_types.h"
-
 /* path/file handeling stuff */
 #ifndef WIN32
   #include <dirent.h>
@@ -70,8 +69,8 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list