diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_scene.h | 13 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_sequence.h | 70 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/sequence.c | 235 | ||||
-rw-r--r-- | source/blender/blenlib/intern/bpath.c | 29 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 102 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 10 | ||||
-rw-r--r-- | source/blender/editors/screen/stubs.c | 2 |
8 files changed, 370 insertions, 94 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; +} + + diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index b907f77e64c..a18efb09515 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -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,7 +69,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> - +#include <string.h> #define FILE_MAX 240 @@ -219,7 +218,7 @@ static struct Sequence *seq_stepdata__internal(struct BPathIterator *bpi, int st if (bpi->seqdata.scene->ed) { if (bpi->seqdata.seqar == NULL) { /* allocate the sequencer array */ - build_seqar( &(((Editing *)bpi->seqdata.scene->ed)->seqbase), &bpi->seqdata.seqar, &bpi->seqdata.totseq); + seq_array(bpi->seqdata.scene->ed, &bpi->seqdata.seqar, &bpi->seqdata.totseq); bpi->seqdata.seq = 0; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index df2c680c951..91120f78e9a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -134,6 +134,7 @@ #include "BKE_softbody.h" // sbNew() #include "BKE_bullet.h" // bsbNew() #include "BKE_sculpt.h" +#include "BKE_sequence.h" #include "BKE_texture.h" // for open_plugin_tex #include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND #include "BKE_idprop.h" @@ -3443,7 +3444,6 @@ static void lib_link_scene(FileData *fd, Main *main) { Scene *sce; Base *base, *next; - Editing *ed; Sequence *seq; SceneRenderLayer *srl; int a; @@ -3486,23 +3486,20 @@ static void lib_link_scene(FileData *fd, Main *main) } } - ed= sce->ed; - if(ed) { - WHILE_SEQ(&ed->seqbase) { //XXX todo replace WHILE_SEQ - if(seq->ipo) seq->ipo= newlibadr_us(fd, sce->id.lib, seq->ipo); - if(seq->scene) seq->scene= newlibadr(fd, sce->id.lib, seq->scene); - if(seq->sound) { - seq->sound= newlibadr(fd, sce->id.lib, seq->sound); - if (seq->sound) { - seq->sound->id.us++; - seq->sound->flags |= SOUND_FLAGS_SEQUENCE; - } + SEQ_BEGIN(sce->ed, seq) { + if(seq->ipo) seq->ipo= newlibadr_us(fd, sce->id.lib, seq->ipo); + if(seq->scene) seq->scene= newlibadr(fd, sce->id.lib, seq->scene); + if(seq->sound) { + seq->sound= newlibadr(fd, sce->id.lib, seq->sound); + if (seq->sound) { + seq->sound->id.us++; + seq->sound->flags |= SOUND_FLAGS_SEQUENCE; } - seq->anim= 0; - seq->hdaudio = 0; } - END_SEQ + seq->anim= 0; + seq->hdaudio = 0; } + SEQ_END lib_link_scriptlink(fd, &sce->id, &sce->scriptlink); @@ -3526,11 +3523,10 @@ static void link_recurs_seq(FileData *fd, ListBase *lb) Sequence *seq; link_list(fd, lb); - seq= lb->first; - while(seq) { - if(seq->seqbase.first) link_recurs_seq(fd, &seq->seqbase); - seq= seq->next; - } + + for(seq=lb->first; seq; seq=seq->next) + if(seq->seqbase.first) + link_recurs_seq(fd, &seq->seqbase); } static void direct_link_scene(FileData *fd, Scene *sce) @@ -3572,7 +3568,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) /* recursive link sequences, lb will be correctly initialized */ link_recurs_seq(fd, &ed->seqbase); - WHILE_SEQ(&ed->seqbase) { //XXX todo replace WHILE_SEQ + SEQ_BEGIN(ed, seq) { seq->seq1= newdataadr(fd, seq->seq1); seq->seq2= newdataadr(fd, seq->seq2); seq->seq3= newdataadr(fd, seq->seq3); @@ -3630,7 +3626,7 @@ static void direct_link_scene(FileData *fd, Scene *sce) } } } - END_SEQ + SEQ_END /* link metastack, slight abuse of structs here, have to restore pointer to internal part in struct */ { @@ -3714,30 +3710,26 @@ static void direct_link_scene(FileData *fd, Scene *sce) */ static Sequence * find_sequence_from_ipo_helper(Main * main, Ipo * ipo) { - Editing *ed; - Sequence *seq = NULL; - - Scene * sce= main->scene.first; - while(sce) { - if(sce->ed) { - int found = 0; - - ed= sce->ed; + Sequence *seq; + Scene *sce; + + for(sce=main->scene.first; sce; sce=sce->id.next) { + int found = 0; - WHILE_SEQ(&ed->seqbase) { //XXX todo replace WHILE_SEQ - if (seq->ipo == ipo) { - found = 1; - break; - } - } - END_SEQ - if (found) { + SEQ_BEGIN(sce->ed, seq) { + if (seq->ipo == ipo) { + found = 1; break; } - seq = NULL; + } + SEQ_END + + if (found) { + break; } - sce= sce->id.next; + seq = NULL; } + if (seq) return seq; else @@ -5022,7 +5014,7 @@ static void alphasort_version_246(FileData *fd, Library *lib, Mesh *me) /* if we do, set alpha sort if the game engine did it before */ for(a=0, mf=me->mface; a<me->totface; a++, mf++) { if(mf->mat_nr < me->totcol) { - ma= newlibadr(fd, lib, me->mat[mf->mat_nr]); + ma= newlibadr(fd, lib, me->mat[(int)mf->mat_nr]); texalpha = 0; /* we can't read from this if it comes from a library, @@ -5208,7 +5200,6 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) static void do_versions_windowmanager_2_50(bScreen *screen) { ScrArea *sa; - ARegion *ar; SpaceLink *sl; /* add regions */ @@ -6522,10 +6513,11 @@ static void do_versions(FileData *fd, Library *lib, Main *main) while(sce) { ed= sce->ed; if(ed) { - WHILE_SEQ(&ed->seqbase) { //XXX todo replace WHILE_SEQ - if(seq->type==SEQ_IMAGE || seq->type==SEQ_MOVIE) seq->flag |= SEQ_MAKE_PREMUL; + SEQ_BEGIN(sce->ed, seq) { + if(seq->type==SEQ_IMAGE || seq->type==SEQ_MOVIE) + seq->flag |= SEQ_MAKE_PREMUL; } - END_SEQ + SEQ_END } sce= sce->id.next; @@ -8021,22 +8013,16 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 14)) { - Scene *sce= main->scene.first; + Scene *sce; Sequence *seq; Editing *ed; - while(sce) { - ed= sce->ed; - if(ed) { - WHILE_SEQ(&ed->seqbase) { - if (seq->blend_mode == 0) { - seq->blend_opacity = 100.0; - } - } - END_SEQ + for(sce=main->scene.first; sce; sce=sce->id.next) { + SEQ_BEGIN(ed, seq) { + if (seq->blend_mode == 0) + seq->blend_opacity = 100.0; } - - sce= sce->id.next; + SEQ_END } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 96611b6fa9d..b5081888a96 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -155,7 +155,7 @@ Any case: direct data is ALWAYS after the lib block #include "BKE_node.h" #include "BKE_packedFile.h" // for packAll #include "BKE_screen.h" // for waitcursor -#include "BKE_scene.h" // for do_seq +#include "BKE_sequence.h" #include "BKE_sound.h" /* ... and for samples */ #include "BKE_utildefines.h" // for defines #include "BKE_modifier.h" @@ -1471,13 +1471,13 @@ static void write_scenes(WriteData *wd, ListBase *scebase) /* reset write flags too */ - WHILE_SEQ(&ed->seqbase) { //XXX todo replace WHILE_SEQ + SEQ_BEGIN(ed, seq) { if(seq->strip) seq->strip->done= 0; writestruct(wd, DATA, "Sequence", 1, seq); } - END_SEQ + SEQ_END - WHILE_SEQ(&ed->seqbase) { //XXX todo replace WHILE_SEQ + SEQ_BEGIN(ed, seq) { if(seq->strip && seq->strip->done==0) { /* write strip with 'done' at 0 because readfile */ @@ -1524,7 +1524,7 @@ static void write_scenes(WriteData *wd, ListBase *scebase) strip->done= 1; } } - END_SEQ + SEQ_END /* new; meta stack too, even when its nasty restore code */ for(ms= ed->metastack.first; ms; ms= ms->next) { diff --git a/source/blender/editors/screen/stubs.c b/source/blender/editors/screen/stubs.c index 6e6881d8e5c..1cc657be985 100644 --- a/source/blender/editors/screen/stubs.c +++ b/source/blender/editors/screen/stubs.c @@ -63,9 +63,7 @@ void copy_view3d_lock() {} /* seq */ void do_render_seq() {} -void free_editing() {} void get_forground_frame_seq() {} -void build_seqar() {} /* sculpt */ void sculptmode_free_all() {} |