Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-12-15 08:21:44 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-12-15 08:21:44 +0300
commited7bf5a479fdf8ff778a3dd645400830d805e038 (patch)
tree96e268585c10692b1fb3aa425c1291f9b7625c5d /source/blender/blenkernel
parentb1e07d13ec7aa04cae31495343fcadc70e9a2be3 (diff)
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.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_scene.h13
-rw-r--r--source/blender/blenkernel/BKE_sequence.h70
-rw-r--r--source/blender/blenkernel/intern/scene.c3
-rw-r--r--source/blender/blenkernel/intern/sequence.c235
4 files changed, 307 insertions, 14 deletions
diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h
index 35168cb65f2..4f951129842 100644
--- a/source/blender/blenkernel/BKE_scene.h
+++ b/source/blender/blenkernel/BKE_scene.h
@@ -40,19 +40,6 @@ struct QuicktimeCodecData;
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)
diff --git a/source/blender/blenkernel/BKE_sequence.h b/source/blender/blenkernel/BKE_sequence.h
new file mode 100644
index 00000000000..2c4daf7fce5
--- /dev/null
+++ b/source/blender/blenkernel/BKE_sequence.h
@@ -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
+
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 096c04b7bd3..d7df27d9c35 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -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 @@ void free_scene(Scene *sce)
/* 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;
diff --git a/source/blender/blenkernel/intern/sequence.c b/source/blender/blenkernel/intern/sequence.c
new file mode 100644
index 00000000000..e203c1bcb8e
--- /dev/null
+++ b/source/blender/blenkernel/intern/sequence.c
@@ -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;
+}
+
+