Blender  V2.59
BKE_sequencer.h
Go to the documentation of this file.
00001 /*
00002  * $Id: BKE_sequencer.h 36972 2011-05-28 09:59:34Z lmg $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version. The Blender
00010  * Foundation also sells licenses for use in proprietary software under
00011  * the Blender License.  See http://www.blender.org/BL/ for information
00012  * about this.  
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software Foundation,
00021  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00022  *
00023  * The Original Code is Copyright (C) 2004 Blender Foundation.
00024  * All rights reserved.
00025  *
00026  * Contributor(s): Blender Foundation (2008).
00027  *
00028  * ***** END GPL LICENSE BLOCK *****
00029  */
00030 
00031 #ifndef BKE_SEQUENCER_H
00032 #define BKE_SEQUENCER_H
00033 
00038 struct bContext;
00039 struct Editing;
00040 struct ImBuf;
00041 struct Main;
00042 struct Scene;
00043 struct Sequence;
00044 struct Strip;
00045 struct StripElem;
00046 
00047 #define MAXSEQ          32
00048 
00049 #define BUILD_SEQAR_COUNT_NOTHING  0
00050 #define BUILD_SEQAR_COUNT_CURRENT  1
00051 #define BUILD_SEQAR_COUNT_CHILDREN 2
00052 
00053 #define EARLY_NO_INPUT          -1
00054 #define EARLY_DO_EFFECT         0
00055 #define EARLY_USE_INPUT_1       1
00056 #define EARLY_USE_INPUT_2       2
00057 
00058 /* sequence iterator */
00059 
00060 typedef struct SeqIterator {
00061         struct Sequence **array;
00062         int tot, cur;
00063 
00064         struct Sequence *seq;
00065         int valid;
00066 } SeqIterator;
00067 
00068 void seq_begin(struct Editing *ed, SeqIterator *iter, int use_pointer);
00069 void seq_next(SeqIterator *iter);
00070 void seq_end(SeqIterator *iter);
00071 void seq_array(struct Editing *ed, struct Sequence ***seqarray, int *tot, int use_pointer);
00072 
00073 #define SEQP_BEGIN(ed, _seq) \
00074 { \
00075         SeqIterator iter;\
00076                 for(seq_begin(ed, &iter, 1); iter.valid; seq_next(&iter)) { \
00077                         _seq= iter.seq;
00078                         
00079 #define SEQ_BEGIN(ed, _seq) \
00080         { \
00081                 SeqIterator iter;\
00082                 for(seq_begin(ed, &iter, 0); iter.valid; seq_next(&iter)) { \
00083                         _seq= iter.seq;
00084 
00085 #define SEQ_END \
00086                 } \
00087                 seq_end(&iter); \
00088         }
00089 
00090 typedef struct SeqRenderData {
00091         struct Main *bmain;
00092         struct Scene *scene;
00093         int rectx;
00094         int recty;
00095         int preview_render_size;
00096         int motion_blur_samples;
00097         float motion_blur_shutter;
00098 } SeqRenderData;
00099 
00100 SeqRenderData seq_new_render_data(
00101         struct Main * bmain, struct Scene * scene,
00102         int rectx, int recty, int preview_render_size);
00103 
00104 int seq_cmp_render_data(const SeqRenderData * a, const SeqRenderData * b);
00105 unsigned int seq_hash_render_data(const SeqRenderData * a);
00106 
00107 /* Wipe effect */
00108 enum {DO_SINGLE_WIPE, DO_DOUBLE_WIPE, DO_BOX_WIPE, DO_CROSS_WIPE,
00109         DO_IRIS_WIPE,DO_CLOCK_WIPE};
00110 
00111 
00112 struct SeqEffectHandle {
00113         /* constructors & destructor */
00114         /* init & init_plugin are _only_ called on first creation */
00115         void (*init)(struct Sequence *seq);
00116         void (*init_plugin)(struct Sequence *seq, const char *fname);
00117         
00118         /* number of input strips needed 
00119                 (called directly after construction) */
00120         int (*num_inputs)(void);
00121         
00122         /* load is called first time after readblenfile in
00123                 get_sequence_effect automatically */
00124         void (*load)(struct Sequence *seq);
00125         
00126         /* duplicate */
00127         void (*copy)(struct Sequence *dst, struct Sequence *src);
00128         
00129         /* destruct */
00130         void (*free)(struct Sequence *seq);
00131         
00132         /* returns: -1: no input needed,
00133         0: no early out, 
00134         1: out = ibuf1, 
00135         2: out = ibuf2 */
00136         int (*early_out)(struct Sequence *seq, float facf0, float facf1); 
00137         
00138         /* stores the y-range of the effect IPO */
00139         void (*store_icu_yrange)(struct Sequence * seq,
00140                                  short adrcode, float *ymin, float *ymax);
00141         
00142         /* stores the default facf0 and facf1 if no IPO is present */
00143         void (*get_default_fac)(struct Sequence *seq, float cfra,
00144                                 float * facf0, float * facf1);
00145         
00146         /* execute the effect
00147            sequence effects are only required to either support
00148            float-rects or byte-rects 
00149            (mixed cases are handled one layer up...) */
00150         
00151         struct ImBuf* (*execute)(
00152                 SeqRenderData context,
00153                 struct Sequence *seq, float cfra,
00154                 float facf0, float facf1,
00155                 struct ImBuf *ibuf1, struct ImBuf *ibuf2,
00156                 struct ImBuf *ibuf3);
00157 };
00158 
00159 /* ********************* prototypes *************** */
00160 
00161 /* **********************************************************************
00162    * sequence.c
00163 
00164    * sequencer render functions
00165    ********************************************************************** */
00166 
00167 struct ImBuf *give_ibuf_seq(SeqRenderData context, float cfra, int chanshown);
00168 struct ImBuf *give_ibuf_seq_threaded(SeqRenderData context, float cfra, int chanshown);
00169 struct ImBuf *give_ibuf_seq_direct(SeqRenderData context, float cfra, struct Sequence *seq);
00170 struct ImBuf *give_ibuf_seqbase(SeqRenderData context, float cfra, int chan_shown, struct ListBase *seqbasep);
00171 void give_ibuf_prefetch_request(SeqRenderData context, float cfra, int chan_shown);
00172 
00173 /* apply functions recursively */
00174 int seqbase_recursive_apply(struct ListBase *seqbase, int (*apply_func)(struct Sequence *seq, void *), void *arg);
00175 int seq_recursive_apply(struct Sequence *seq, int (*apply_func)(struct Sequence *, void *), void *arg);
00176 
00177 /* maintainance functions, mostly for RNA */
00178 // extern 
00179 void seq_free_sequence(struct Scene *scene, struct Sequence *seq);
00180 void seq_free_strip(struct Strip *strip);
00181 void seq_free_editing(struct Scene *scene);
00182 void seq_free_clipboard(void);
00183 struct Editing *seq_give_editing(struct Scene *scene, int alloc);
00184 const char *give_seqname(struct Sequence *seq);
00185 void calc_sequence(struct Scene *scene, struct Sequence *seq);
00186 void calc_sequence_disp(struct Scene *scene, struct Sequence *seq);
00187 void new_tstripdata(struct Sequence *seq);
00188 void reload_sequence_new_file(struct Scene *scene, struct Sequence * seq, int lock_range);
00189 void sort_seq(struct Scene *scene);
00190 void build_seqar_cb(struct ListBase *seqbase, struct Sequence  ***seqar, int *totseq,
00191                                         int (*test_func)(struct Sequence * seq));
00192 int evaluate_seq_frame(struct Scene *scene, int cfra);
00193 struct StripElem *give_stripelem(struct Sequence *seq, int cfra);
00194 
00195 // intern
00196 void printf_strip(struct Sequence *seq); // debugging function (unused)
00197 void update_changed_seq_and_deps(struct Scene *scene, struct Sequence *changed_seq, int len_change, int ibuf_change);
00198 
00199 int input_have_to_preprocess(
00200         SeqRenderData context, struct Sequence * seq, float cfra);
00201 
00202 /* **********************************************************************
00203    seqcache.c
00204 
00205    Sequencer memory cache management functions
00206    ********************************************************************** */
00207 
00208 typedef enum {
00209         SEQ_STRIPELEM_IBUF,
00210         SEQ_STRIPELEM_IBUF_COMP,
00211         SEQ_STRIPELEM_IBUF_STARTSTILL,
00212         SEQ_STRIPELEM_IBUF_ENDSTILL
00213 } seq_stripelem_ibuf_t;
00214 
00215 void seq_stripelem_cache_init(void);
00216 void seq_stripelem_cache_destruct(void);
00217 
00218 void seq_stripelem_cache_cleanup(void);
00219 
00220 /* returned ImBuf is properly refed and has to be freed */
00221 struct ImBuf * seq_stripelem_cache_get(
00222         SeqRenderData context, struct Sequence * seq, 
00223         float cfra, seq_stripelem_ibuf_t type);
00224 
00225 /* passed ImBuf is properly refed, so ownership is *not* 
00226    transfered to the cache.
00227    you can pass the same ImBuf multiple times to the cache without problems.
00228 */
00229    
00230 void seq_stripelem_cache_put(
00231         SeqRenderData context, struct Sequence * seq, 
00232         float cfra, seq_stripelem_ibuf_t type, struct ImBuf * nval);
00233 
00234 /* **********************************************************************
00235    seqeffects.c 
00236 
00237    Sequencer effect strip managment functions
00238    **********************************************************************
00239 */
00240 
00241 /* intern */
00242 struct SeqEffectHandle get_sequence_blend(struct Sequence *seq);
00243 void sequence_effect_speed_rebuild_map(struct Scene *scene, struct Sequence *seq, int force);
00244 
00245 /* extern */
00246 struct SeqEffectHandle get_sequence_effect(struct Sequence *seq);
00247 int get_sequence_effect_num_inputs(int seq_type);
00248 
00249 
00250 /* **********************************************************************
00251    Sequencer editing functions
00252    **********************************************************************
00253 */
00254    
00255 /* for transform but also could use elsewhere */
00256 int seq_tx_get_start(struct Sequence *seq);
00257 int seq_tx_get_end(struct Sequence *seq);
00258 int seq_tx_get_final_left(struct Sequence *seq, int metaclip);
00259 int seq_tx_get_final_right(struct Sequence *seq, int metaclip);
00260 void seq_tx_set_final_left(struct Sequence *seq, int val);
00261 void seq_tx_set_final_right(struct Sequence *seq, int val);
00262 void seq_tx_handle_xlimits(struct Sequence *seq, int leftflag, int rightflag);
00263 int seq_tx_test(struct Sequence * seq);
00264 int seq_single_check(struct Sequence *seq);
00265 void seq_single_fix(struct Sequence *seq);
00266 int seq_test_overlap(struct ListBase * seqbasep, struct Sequence *test);
00267 void seq_translate(struct Scene *scene, struct Sequence *seq, int delta);
00268 void seq_sound_init(struct Scene *scene, struct Sequence *seq);
00269 struct Sequence *seq_foreground_frame_get(struct Scene *scene, int frame);
00270 struct ListBase *seq_seqbase(struct ListBase *seqbase, struct Sequence *seq);
00271 struct Sequence *seq_metastrip(
00272         ListBase * seqbase /* = ed->seqbase */, 
00273         struct Sequence * meta /* = NULL */, struct Sequence *seq);
00274 
00275 void seq_offset_animdata(struct Scene *scene, struct Sequence *seq, int ofs);
00276 void seq_dupe_animdata(struct Scene *scene, char *name_from, char *name_to);
00277 int shuffle_seq(struct ListBase * seqbasep, struct Sequence *test, struct Scene *evil_scene);
00278 int shuffle_seq_time(ListBase * seqbasep, struct Scene *evil_scene);
00279 int seqbase_isolated_sel_check(struct ListBase *seqbase);
00280 void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_mem_usage, int keep_file_handles);
00281 struct Sequence *seq_dupli_recursive(struct Scene *scene, struct Scene *scene_to, struct Sequence * seq, int dupe_flag);
00282 int seq_swap(struct Sequence *seq_a, struct Sequence *seq_b, const char **error_str);
00283 
00284 void seq_update_sound(struct Scene* scene, struct Sequence *seq);
00285 void seq_update_muting(struct Scene* scene, struct Editing *ed);
00286 void seqbase_sound_reload(struct Scene *scene, ListBase *seqbase);
00287 void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq);
00288 void seqbase_dupli_recursive(struct Scene *scene, struct Scene *scene_to, ListBase *nseqbase, ListBase *seqbase, int dupe_flag);
00289 
00290 void clear_scene_in_allseqs(struct Main *bmain, struct Scene *sce);
00291 
00292 struct Sequence *get_seq_by_name(struct ListBase *seqbase, const char *name, int recursive);
00293 
00294 struct Sequence *seq_active_get(struct Scene *scene);
00295 void seq_active_set(struct Scene *scene, struct Sequence *seq);
00296 int seq_active_pair_get(struct Scene *scene, struct Sequence **seq_act, struct Sequence **seq_other);
00297 
00298 /* api for adding new sequence strips */
00299 typedef struct SeqLoadInfo {
00300         int start_frame;
00301         int end_frame;
00302         int channel;
00303         int flag;       /* use sound, replace sel */
00304         int type;
00305         int tot_success;
00306         int tot_error;
00307         int len;                /* only for image strips */
00308         char path[512];
00309         char name[32];
00310 } SeqLoadInfo;
00311 
00312 /* SeqLoadInfo.flag */
00313 #define SEQ_LOAD_REPLACE_SEL    (1<<0)
00314 #define SEQ_LOAD_FRAME_ADVANCE  (1<<1)
00315 #define SEQ_LOAD_MOVIE_SOUND    (1<<2)
00316 #define SEQ_LOAD_SOUND_CACHE    (1<<3)
00317 
00318 
00319 /* seq_dupli' flags */
00320 #define SEQ_DUPE_UNIQUE_NAME    (1<<0)
00321 #define SEQ_DUPE_CONTEXT                (1<<1)
00322 #define SEQ_DUPE_ANIM                   (1<<2)
00323 #define SEQ_DUPE_ALL                    (1<<3) /* otherwise only selected are copied */
00324 
00325 /* use as an api function */
00326 typedef struct Sequence *(*SeqLoadFunc)(struct bContext *, ListBase *, struct SeqLoadInfo *);
00327 
00328 struct Sequence *alloc_sequence(ListBase *lb, int cfra, int machine);
00329 
00330 void seq_load_apply(struct Scene *scene, struct Sequence *seq, struct SeqLoadInfo *seq_load);
00331 
00332 struct Sequence *sequencer_add_image_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load);
00333 struct Sequence *sequencer_add_sound_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load);
00334 struct Sequence *sequencer_add_movie_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load);
00335 
00336 /* view3d draw callback, run when not in background view */
00337 typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, struct Object *, int, int, unsigned int, int, char[256]);
00338 extern SequencerDrawView sequencer_view3d_cb;
00339 
00340 /* copy/paste */
00341 extern ListBase seqbase_clipboard;
00342 extern int seqbase_clipboard_frame;
00343 
00344 #endif // BKE_SEQUENCER_H