diff options
Diffstat (limited to 'source/blender/blenkernel/intern/seqeffects.c')
-rw-r--r-- | source/blender/blenkernel/intern/seqeffects.c | 353 |
1 files changed, 215 insertions, 138 deletions
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 73c19772c69..461cb075bb0 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -41,6 +41,7 @@ #include "DNA_anim_types.h" #include "BKE_fcurve.h" +#include "BKE_main.h" #include "BKE_plugin_types.h" #include "BKE_sequencer.h" #include "BKE_texture.h" @@ -67,6 +68,48 @@ enum { GlowA=3 }; +static struct ImBuf * prepare_effect_imbufs( + int x, int y, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) +{ + struct ImBuf * out; + + if (!ibuf1 && !ibuf2 && !ibuf3) { + /* hmmm, global float option ? */ + out = IMB_allocImBuf((short)x, (short)y, 32, IB_rect, 0); + } else if ((ibuf1 && ibuf1->rect_float) || + (ibuf2 && ibuf2->rect_float) || + (ibuf3 && ibuf3->rect_float)) { + /* if any inputs are rectfloat, output is float too */ + + out = IMB_allocImBuf((short)x, (short)y, 32, IB_rectfloat, 0); + } else { + out = IMB_allocImBuf((short)x, (short)y, 32, IB_rect, 0); + } + + if (ibuf1 && !ibuf1->rect_float && out->rect_float) { + IMB_float_from_rect_simple(ibuf1); + } + if (ibuf2 && !ibuf2->rect_float && out->rect_float) { + IMB_float_from_rect_simple(ibuf2); + } + if (ibuf3 && !ibuf3->rect_float && out->rect_float) { + IMB_float_from_rect_simple(ibuf3); + } + + if (ibuf1 && !ibuf1->rect && !out->rect_float) { + IMB_rect_from_float(ibuf1); + } + if (ibuf2 && !ibuf2->rect && !out->rect_float) { + IMB_rect_from_float(ibuf2); + } + if (ibuf3 && !ibuf3->rect && !out->rect_float) { + IMB_rect_from_float(ibuf3); + } + + return out; +} /* ********************************************************************** PLUGINS @@ -229,11 +272,12 @@ static ImBuf * IMB_cast_away_list(ImBuf * i) return (ImBuf*) (((void**) i) + 2); } -static void do_plugin_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_plugin_effect( + Main *bmain, Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { char *cp; int float_rendering; @@ -241,6 +285,8 @@ static void do_plugin_effect(Scene *scene, Sequence *seq, int cfra, old plugins) do very bad stuff with imbuf-internals */ + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if(seq->plugin && seq->plugin->doit) { if(seq->plugin->cfra) @@ -321,6 +367,7 @@ static void do_plugin_effect(Scene *scene, Sequence *seq, int cfra, if (ibuf3) IMB_freeImBuf(ibuf3); } } + return out; } static int do_plugin_early_out(struct Sequence *seq, @@ -476,12 +523,15 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, } } -static void do_alphaover_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_alphaover_effect( + Main *bmain, Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_alphaover_effect_float( facf0, facf1, x, y, @@ -493,6 +543,7 @@ static void do_alphaover_effect(Scene *scene, Sequence *seq, int cfra, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } + return out; } @@ -644,12 +695,15 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, } } -static void do_alphaunder_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf* do_alphaunder_effect( + Main *bmain, Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_alphaunder_effect_float( facf0, facf1, x, y, @@ -661,6 +715,7 @@ static void do_alphaunder_effect(Scene *scene, Sequence *seq, int cfra, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } + return out; } @@ -765,12 +820,15 @@ void do_cross_effect_float(float facf0, float facf1, int x, int y, /* carefull: also used by speed effect! */ -static void do_cross_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf* do_cross_effect( + Main *bmain, Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_cross_effect_float( facf0, facf1, x, y, @@ -782,6 +840,7 @@ static void do_cross_effect(Scene *scene, Sequence *seq, int cfra, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } + return out; } @@ -827,7 +886,7 @@ static void makeGammaTables(float gamma) /* The end of the table should match 1.0 carefully. In order to avoid */ /* rounding errors, we just set this explicitly. The last segment may */ - /* have a different lenght than the other segments, but our */ + /* have a different length than the other segments, but our */ /* interpolation is insensitive to that. */ color_domain_table[RE_GAMMA_TABLE_SIZE] = 1.0; gamma_range_table[RE_GAMMA_TABLE_SIZE] = 1.0; @@ -1028,12 +1087,15 @@ static void do_gammacross_effect_float(float facf0, float facf1, } } -static void do_gammacross_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_gammacross_effect( + Main *bmain, Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + build_gammatabs(); if (out->rect_float) { @@ -1047,6 +1109,7 @@ static void do_gammacross_effect(Scene *scene, Sequence *seq, int cfra, (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, (unsigned char*) out->rect); } + return out; } @@ -1143,12 +1206,14 @@ static void do_add_effect_float(float facf0, float facf1, int x, int y, } } -static void do_add_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_add_effect(Main *bmain, Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_add_effect_float( facf0, facf1, x, y, @@ -1160,6 +1225,7 @@ static void do_add_effect(Scene *scene, Sequence *seq, int cfra, (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, (unsigned char*) out->rect); } + return out; } @@ -1256,12 +1322,15 @@ static void do_sub_effect_float(float facf0, float facf1, int x, int y, } } -static void do_sub_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_sub_effect( + Main *bmain, Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_sub_effect_float( facf0, facf1, x, y, @@ -1273,6 +1342,7 @@ static void do_sub_effect(Scene *scene, Sequence *seq, int cfra, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } + return out; } /* ********************************************************************** @@ -1284,8 +1354,8 @@ static void do_sub_effect(Scene *scene, Sequence *seq, int cfra, #define YOFF 8 static void do_drop_effect_byte(float facf0, float facf1, int x, int y, - unsigned char *rect2i, unsigned char *rect1i, - unsigned char *outi) + char *rect2i, char *rect1i, + char *outi) { int height, width, temp, fac, fac1, fac2; char *rt1, *rt2, *out; @@ -1364,27 +1434,6 @@ static void do_drop_effect_float(float facf0, float facf1, int x, int y, memcpy(out, rt1, 4 * sizeof(float)*YOFF*width); } - -static void do_drop_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf * ibuf3, - struct ImBuf *out) -{ - if (out->rect_float) { - do_drop_effect_float( - facf0, facf1, x, y, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); - } else { - do_drop_effect_byte( - facf0, facf1, x, y, - (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, - (unsigned char*) out->rect); - } -} - /* ********************************************************************** MUL ********************************************************************** */ @@ -1487,12 +1536,15 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y, } } -static void do_mul_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_mul_effect( + Main *bmain, Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_mul_effect_float( facf0, facf1, x, y, @@ -1504,6 +1556,8 @@ static void do_mul_effect(Scene *scene, Sequence *seq, int cfra, (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, (unsigned char*) out->rect); } + + return out; } /* ********************************************************************** @@ -1938,12 +1992,15 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float facf1, } } -static void do_wipe_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_wipe_effect( + Main *bmain, Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_wipe_effect_float(seq, facf0, facf1, x, y, @@ -1955,6 +2012,8 @@ static void do_wipe_effect(Scene *scene, Sequence *seq, int cfra, (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, (unsigned char*) out->rect); } + + return out; } /* ********************************************************************** TRANSFORM @@ -2084,13 +2143,18 @@ static void do_transform(Scene *scene, Sequence *seq, float facf0, int x, int y, } -static void do_transform_effect(Scene *scene, Sequence *seq,int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_transform_effect( + Main *bmain, Scene *scene, Sequence *seq,float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + do_transform(scene, seq, facf0, x, y, ibuf1, out); + + return out; } @@ -2597,12 +2661,15 @@ static void do_glow_effect_float(Sequence *seq, float facf0, float facf1, RVAddBitmaps_float (inbuf , outbuf, outbuf, x, y); } -static void do_glow_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_glow_effect( + Main *bmain, Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_glow_effect_float(seq, facf0, facf1, x, y, @@ -2614,6 +2681,8 @@ static void do_glow_effect(Scene *scene, Sequence *seq, int cfra, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } + + return out; } /* ********************************************************************** @@ -2653,12 +2722,15 @@ static int early_out_color(struct Sequence *seq, return -1; } -static void do_solid_color(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_solid_color( + Main *bmain, Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + SolidColorVars *cv = (SolidColorVars *)seq->effectdata; unsigned char *rect; @@ -2728,6 +2800,7 @@ static void do_solid_color(Scene *scene, Sequence *seq, int cfra, } } } + return out; } /* ********************************************************************** @@ -2745,47 +2818,45 @@ static int early_out_multicam(struct Sequence *seq, float facf0, float facf1) return -1; } -static void do_multicam(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_multicam( + Main *bmain, Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { struct ImBuf * i; + struct ImBuf * out; Editing * ed; ListBase * seqbasep; if (seq->multicam_source == 0 || seq->multicam_source >= seq->machine) { - return; + return 0; } ed = scene->ed; if (!ed) { - return; + return 0; } seqbasep = seq_seqbase(&ed->seqbase, seq); if (!seqbasep) { - return; + return 0; } - i = give_ibuf_seqbase(scene, - out->x, out->y, cfra, seq->multicam_source, + i = give_ibuf_seqbase(bmain, scene, x, y, cfra, seq->multicam_source, preview_render_size, seqbasep); if (!i) { - return; + return 0; } - if (out->rect && i->rect) { - memcpy(out->rect, i->rect, out->x * out->y * 4); - } else if (out->rect_float && i->rect_float) { - memcpy(out->rect_float, i->rect_float, out->x * out->y *4*sizeof(float)); - } else if (out->rect && i->rect_float) { - IMB_rect_from_float(i); - memcpy(out->rect, i->rect, out->x * out->y * 4); - } else if (out->rect_float && i->rect) { - IMB_float_from_rect_simple(i); - memcpy(out->rect_float, i->rect_float, out->x * out->y *4*sizeof(float)); + if (input_have_to_preprocess(scene, seq, cfra, x, y)) { + out = IMB_dupImBuf(i); + IMB_freeImBuf(i); + } else { + out = i; } + + return out; } /* ********************************************************************** @@ -2898,22 +2969,11 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) fallback_fac = 1.0; - /* if there is no IPO, try to make retiming easy by stretching the + /* if there is no fcurve, try to make retiming easy by stretching the strip */ - // XXX old animation system - seq if (!fcu && seq->seq1->enddisp != seq->seq1->start && seq->seq1->len != 0) { fallback_fac = (float) seq->seq1->len / (float) (seq->seq1->enddisp - seq->seq1->start); - /* FIXME: this strip stretching gets screwed by stripdata - handling one layer up. - - So it currently works by enlarging, never by shrinking! - - (IPOs still work, if used correctly) - */ - if (fallback_fac > 1.0) { - fallback_fac = 1.0; - } } if ((v->flags & SEQ_SPEED_INTEGRATE) != 0) { @@ -2936,8 +2996,8 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) cursor += facf; - if (cursor >= v->length) { - v->frameMap[cfra] = v->length - 1; + if (cursor >= seq->seq1->len) { + v->frameMap[cfra] = seq->seq1->len - 1; } else { v->frameMap[cfra] = cursor; v->lastValidFrame = cfra; @@ -2963,8 +3023,8 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) facf = (float) cfra * fallback_fac; } facf *= v->globalSpeed; - if (facf >= v->length) { - facf = v->length - 1; + if (facf >= seq->seq1->len) { + facf = seq->seq1->len - 1; } else { v->lastValidFrame = cfra; } @@ -3048,13 +3108,13 @@ static void store_icu_yrange_noop(struct Sequence * seq, /* defaults are fine */ } -static void get_default_fac_noop(struct Sequence *seq, int cfra, +static void get_default_fac_noop(struct Sequence *seq, float cfra, float * facf0, float * facf1) { *facf0 = *facf1 = 1.0; } -static void get_default_fac_fade(struct Sequence *seq, int cfra, +static void get_default_fac_fade(struct Sequence *seq, float cfra, float * facf0, float * facf1) { *facf0 = (float)(cfra - seq->startdisp); @@ -3063,21 +3123,38 @@ static void get_default_fac_fade(struct Sequence *seq, int cfra, *facf1 /= seq->len; } -static void do_overdrop_effect(Scene *scene, Sequence *seq, int cfra, - float fac, float facf, - int x, int y, - int preview_render_size, - struct ImBuf * ibuf1, - struct ImBuf * ibuf2, - struct ImBuf * ibuf3, - struct ImBuf * out) -{ - do_drop_effect(scene, seq, cfra, fac, facf, x, y, - preview_render_size, - ibuf1, ibuf2, ibuf3, out); - do_alphaover_effect(scene, seq, cfra, fac, facf, x, y, - preview_render_size, - ibuf1, ibuf2, ibuf3, out); +static struct ImBuf * do_overdrop_effect(Main *bmain, Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, + int x, int y, + int preview_render_size, + struct ImBuf * ibuf1, + struct ImBuf * ibuf2, + struct ImBuf * ibuf3) +{ + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + + if (out->rect_float) { + do_drop_effect_float( + facf0, facf1, x, y, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); + do_alphaover_effect_float( + facf0, facf1, x, y, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); + } else { + do_drop_effect_byte( + facf0, facf1, x, y, + (char*) ibuf1->rect, + (char*) ibuf2->rect, + (char*) out->rect); + do_alphaover_effect_byte( + facf0, facf1, x, y, + (char*) ibuf1->rect, (char*) ibuf2->rect, + (char*) out->rect); + } + + return out; } static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) |