diff options
Diffstat (limited to 'source/blender/sequencer/intern/effects.c')
-rw-r--r-- | source/blender/sequencer/intern/effects.c | 170 |
1 files changed, 100 insertions, 70 deletions
diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c index b4bc2d25155..5412914e0f6 100644 --- a/source/blender/sequencer/intern/effects.c +++ b/source/blender/sequencer/intern/effects.c @@ -46,7 +46,6 @@ #include "BKE_fcurve.h" #include "BKE_lib_id.h" #include "BKE_main.h" -#include "BKE_sequencer.h" #include "IMB_colormanagement.h" #include "IMB_imbuf.h" @@ -59,8 +58,13 @@ #include "RE_pipeline.h" +#include "SEQ_sequencer.h" + #include "BLF_api.h" +#include "render.h" +#include "sequencer.h" + static struct SeqEffectHandle get_sequence_effect_impl(int seq_type); static void slice_get_byte_buffers(const SeqRenderData *context, @@ -148,15 +152,15 @@ static ImBuf *prepare_effect_imbufs(const SeqRenderData *context, if (out->rect_float) { if (ibuf1 && !ibuf1->rect_float) { - BKE_sequencer_imbuf_to_sequencer_space(scene, ibuf1, true); + seq_imbuf_to_sequencer_space(scene, ibuf1, true); } if (ibuf2 && !ibuf2->rect_float) { - BKE_sequencer_imbuf_to_sequencer_space(scene, ibuf2, true); + seq_imbuf_to_sequencer_space(scene, ibuf2, true); } if (ibuf3 && !ibuf3->rect_float) { - BKE_sequencer_imbuf_to_sequencer_space(scene, ibuf3, true); + seq_imbuf_to_sequencer_space(scene, ibuf3, true); } IMB_colormanagement_assign_float_colorspace(out, scene->sequencer_colorspace_settings.name); @@ -350,7 +354,7 @@ static void do_alphaover_effect_float( static void do_alphaover_effect(const SeqRenderData *context, Sequence *UNUSED(seq), - float UNUSED(cfra), + float UNUSED(timeline_frame), float facf0, float facf1, ImBuf *ibuf1, @@ -557,7 +561,7 @@ static void do_alphaunder_effect_float( static void do_alphaunder_effect(const SeqRenderData *context, Sequence *UNUSED(seq), - float UNUSED(cfra), + float UNUSED(timeline_frame), float facf0, float facf1, ImBuf *ibuf1, @@ -692,7 +696,7 @@ static void do_cross_effect_float( static void do_cross_effect(const SeqRenderData *context, Sequence *UNUSED(seq), - float UNUSED(cfra), + float UNUSED(timeline_frame), float facf0, float facf1, ImBuf *ibuf1, @@ -990,7 +994,7 @@ static struct ImBuf *gammacross_init_execution(const SeqRenderData *context, static void do_gammacross_effect(const SeqRenderData *context, Sequence *UNUSED(seq), - float UNUSED(cfra), + float UNUSED(timeline_frame), float facf0, float facf1, ImBuf *ibuf1, @@ -1125,7 +1129,7 @@ static void do_add_effect_float( static void do_add_effect(const SeqRenderData *context, Sequence *UNUSED(seq), - float UNUSED(cfra), + float UNUSED(timeline_frame), float facf0, float facf1, ImBuf *ibuf1, @@ -1260,7 +1264,7 @@ static void do_sub_effect_float( static void do_sub_effect(const SeqRenderData *context, Sequence *UNUSED(seq), - float UNUSED(cfra), + float UNUSED(timeline_frame), float facf0, float facf1, ImBuf *ibuf1, @@ -1511,7 +1515,7 @@ static void do_mul_effect_float( static void do_mul_effect(const SeqRenderData *context, Sequence *UNUSED(seq), - float UNUSED(cfra), + float UNUSED(timeline_frame), float facf0, float facf1, ImBuf *ibuf1, @@ -1801,7 +1805,7 @@ static void do_blend_effect_byte(float facf0, static void do_blend_mode_effect(const SeqRenderData *context, Sequence *seq, - float UNUSED(cfra), + float UNUSED(timeline_frame), float facf0, float facf1, ImBuf *ibuf1, @@ -1842,7 +1846,7 @@ static void init_colormix_effect(Sequence *seq) static void do_colormix_effect(const SeqRenderData *context, Sequence *seq, - float UNUSED(cfra), + float UNUSED(timeline_frame), float UNUSED(facf0), float UNUSED(facf1), ImBuf *ibuf1, @@ -2307,7 +2311,7 @@ static void do_wipe_effect_float(Sequence *seq, static ImBuf *do_wipe_effect(const SeqRenderData *context, Sequence *seq, - float UNUSED(cfra), + float UNUSED(timeline_frame), float facf0, float facf1, ImBuf *ibuf1, @@ -2438,7 +2442,7 @@ static void transform_image(int x, static void do_transform_effect(const SeqRenderData *context, Sequence *seq, - float UNUSED(cfra), + float UNUSED(timeline_frame), float UNUSED(facf0), float UNUSED(facf1), ImBuf *ibuf1, @@ -2785,7 +2789,7 @@ static void do_glow_effect_float(Sequence *seq, static ImBuf *do_glow_effect(const SeqRenderData *context, Sequence *seq, - float UNUSED(cfra), + float UNUSED(timeline_frame), float facf0, float facf1, ImBuf *ibuf1, @@ -2864,7 +2868,7 @@ static int early_out_color(Sequence *UNUSED(seq), float UNUSED(facf0), float UNU static ImBuf *do_solid_color(const SeqRenderData *context, Sequence *seq, - float UNUSED(cfra), + float UNUSED(timeline_frame), float facf0, float facf1, ImBuf *ibuf1, @@ -2962,7 +2966,7 @@ static int early_out_multicam(Sequence *UNUSED(seq), float UNUSED(facf0), float static ImBuf *do_multicam(const SeqRenderData *context, Sequence *seq, - float cfra, + float timeline_frame, float UNUSED(facf0), float UNUSED(facf1), ImBuf *UNUSED(ibuf1), @@ -2986,7 +2990,7 @@ static ImBuf *do_multicam(const SeqRenderData *context, return NULL; } - out = BKE_sequencer_give_ibuf_seqbase(context, cfra, seq->multicam_source, seqbasep); + out = seq_render_give_ibuf_seqbase(context, timeline_frame, seq->multicam_source, seqbasep); return out; } @@ -3004,7 +3008,7 @@ static int early_out_adjustment(Sequence *UNUSED(seq), float UNUSED(facf0), floa return EARLY_NO_INPUT; } -static ImBuf *do_adjustment_impl(const SeqRenderData *context, Sequence *seq, float cfra) +static ImBuf *do_adjustment_impl(const SeqRenderData *context, Sequence *seq, float timeline_frame) { Editing *ed; ListBase *seqbasep; @@ -3015,7 +3019,7 @@ static ImBuf *do_adjustment_impl(const SeqRenderData *context, Sequence *seq, fl seqbasep = BKE_sequence_seqbase(&ed->seqbase, seq); if (seq->machine > 1) { - i = BKE_sequencer_give_ibuf_seqbase(context, cfra, seq->machine - 1, seqbasep); + i = seq_render_give_ibuf_seqbase(context, timeline_frame, seq->machine - 1, seqbasep); } /* found nothing? so let's work the way up the metastrip stack, so @@ -3029,7 +3033,7 @@ static ImBuf *do_adjustment_impl(const SeqRenderData *context, Sequence *seq, fl meta = BKE_sequence_metastrip(&ed->seqbase, NULL, seq); if (meta) { - i = do_adjustment_impl(context, meta, cfra); + i = do_adjustment_impl(context, meta, timeline_frame); } } @@ -3038,7 +3042,7 @@ static ImBuf *do_adjustment_impl(const SeqRenderData *context, Sequence *seq, fl static ImBuf *do_adjustment(const SeqRenderData *context, Sequence *seq, - float cfra, + float timeline_frame, float UNUSED(facf0), float UNUSED(facf1), ImBuf *UNUSED(ibuf1), @@ -3054,7 +3058,7 @@ static ImBuf *do_adjustment(const SeqRenderData *context, return NULL; } - out = do_adjustment_impl(context, seq, cfra); + out = do_adjustment_impl(context, seq, timeline_frame); return out; } @@ -3142,7 +3146,7 @@ static void store_icu_yrange_speed(Sequence *seq, short UNUSED(adrcode), float * void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool force) { - int cfra; + int timeline_frame; float fallback_fac = 1.0f; SpeedControlVars *v = (SpeedControlVars *)seq->effectdata; FCurve *fcu = NULL; @@ -3195,9 +3199,9 @@ void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool for v->frameMap[0] = 0; v->lastValidFrame = 0; - for (cfra = 1; cfra < v->length; cfra++) { + for (timeline_frame = 1; timeline_frame < v->length; timeline_frame++) { if (fcu) { - facf = evaluate_fcurve(fcu, seq->startdisp + cfra); + facf = evaluate_fcurve(fcu, seq->startdisp + timeline_frame); } else { facf = fallback_fac; @@ -3207,11 +3211,11 @@ void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool for cursor += facf; if (cursor >= seq->seq1->len) { - v->frameMap[cfra] = seq->seq1->len - 1; + v->frameMap[timeline_frame] = seq->seq1->len - 1; } else { - v->frameMap[cfra] = cursor; - v->lastValidFrame = cfra; + v->frameMap[timeline_frame] = cursor; + v->lastValidFrame = timeline_frame; } } } @@ -3219,10 +3223,10 @@ void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool for float facf; v->lastValidFrame = 0; - for (cfra = 0; cfra < v->length; cfra++) { + for (timeline_frame = 0; timeline_frame < v->length; timeline_frame++) { if (fcu) { - facf = evaluate_fcurve(fcu, seq->startdisp + cfra); + facf = evaluate_fcurve(fcu, seq->startdisp + timeline_frame); } else { facf = fallback_fac; @@ -3237,45 +3241,47 @@ void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool for facf = seq->seq1->len - 1; } else { - v->lastValidFrame = cfra; + v->lastValidFrame = timeline_frame; } - v->frameMap[cfra] = facf; + v->frameMap[timeline_frame] = facf; } } } -/* Override cfra when rendering speed effect input. */ +/* Override timeline_frame when rendering speed effect input. */ float BKE_sequencer_speed_effect_target_frame_get(const SeqRenderData *context, Sequence *seq, - float cfra, + float timeline_frame, int input) { - int nr = BKE_sequencer_give_stripelem_index(seq, cfra); + int frame_index = seq_give_frame_index(seq, timeline_frame); SpeedControlVars *s = (SpeedControlVars *)seq->effectdata; BKE_sequence_effect_speed_rebuild_map(context->scene, seq, false); /* No interpolation. */ if ((s->flags & SEQ_SPEED_USE_INTERPOLATION) == 0) { - return seq->start + s->frameMap[nr]; + return seq->start + s->frameMap[frame_index]; } /* We need to provide current and next image for interpolation. */ if (input == 0) { /* Current frame. */ - return floor(seq->start + s->frameMap[nr]); + return floor(seq->start + s->frameMap[frame_index]); } /* Next frame. */ - return ceil(seq->start + s->frameMap[nr]); + return ceil(seq->start + s->frameMap[frame_index]); } -static float speed_effect_interpolation_ratio_get(SpeedControlVars *s, Sequence *seq, float cfra) +static float speed_effect_interpolation_ratio_get(SpeedControlVars *s, + Sequence *seq, + float timeline_frame) { - int nr = BKE_sequencer_give_stripelem_index(seq, cfra); - return s->frameMap[nr] - floor(s->frameMap[nr]); + int frame_index = seq_give_frame_index(seq, timeline_frame); + return s->frameMap[frame_index] - floor(s->frameMap[frame_index]); } static ImBuf *do_speed_effect(const SeqRenderData *context, Sequence *seq, - float cfra, + float timeline_frame, float facf0, float facf1, ImBuf *ibuf1, @@ -3288,10 +3294,10 @@ static ImBuf *do_speed_effect(const SeqRenderData *context, if (s->flags & SEQ_SPEED_USE_INTERPOLATION) { out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); - facf0 = facf1 = speed_effect_interpolation_ratio_get(s, seq, cfra); + facf0 = facf1 = speed_effect_interpolation_ratio_get(s, seq, timeline_frame); /* Current frame is ibuf1, next frame is ibuf2. */ - out = BKE_sequencer_effect_execute_threaded( - &cross_effect, context, NULL, cfra, facf0, facf1, ibuf1, ibuf2, ibuf3); + out = seq_render_effect_execute_threaded( + &cross_effect, context, NULL, timeline_frame, facf0, facf1, ibuf1, ibuf2, ibuf3); return out; } @@ -3303,7 +3309,7 @@ static ImBuf *do_speed_effect(const SeqRenderData *context, static void do_overdrop_effect(const SeqRenderData *context, Sequence *UNUSED(seq), - float UNUSED(cfra), + float UNUSED(timeline_frame), float facf0, float facf1, ImBuf *ibuf1, @@ -3727,7 +3733,7 @@ static void *render_effect_execute_do_y_thread(void *thread_data_v) static ImBuf *do_gaussian_blur_effect(const SeqRenderData *context, Sequence *seq, - float UNUSED(cfra), + float UNUSED(timeline_frame), float UNUSED(facf0), float UNUSED(facf1), ImBuf *ibuf1, @@ -3782,6 +3788,11 @@ static void init_text_effect(Sequence *seq) copy_v4_fl(data->color, 1.0f); data->shadow_color[3] = 1.0f; + data->box_color[0] = 0.5f; + data->box_color[1] = 0.5f; + data->box_color[2] = 0.5f; + data->box_color[3] = 1.0f; + data->box_margin = 0.01f; BLI_strncpy(data->text, "Text", sizeof(data->text)); @@ -3866,7 +3877,7 @@ static int early_out_text(Sequence *seq, float UNUSED(facf0), float UNUSED(facf1 static ImBuf *do_text_effect(const SeqRenderData *context, Sequence *seq, - float UNUSED(cfra), + float UNUSED(timeline_frame), float UNUSED(facf0), float UNUSED(facf1), ImBuf *ibuf1, @@ -3902,7 +3913,7 @@ static ImBuf *do_text_effect(const SeqRenderData *context, /* Compensate text size for preview render size. */ proxy_size_comp = context->scene->r.size / 100.0; if (context->preview_render_size != SEQ_RENDER_SIZE_SCENE) { - proxy_size_comp *= BKE_sequencer_rendersize_to_scale_factor(context->preview_render_size); + proxy_size_comp *= SEQ_rendersize_to_scale_factor(context->preview_render_size); } /* set before return */ @@ -3923,18 +3934,18 @@ static ImBuf *do_text_effect(const SeqRenderData *context, x = (data->loc[0] * width); y = (data->loc[1] * height) + y_ofs; + /* vars for calculating wordwrap and optional box */ + struct { + struct ResultBLF info; + rctf rect; + } wrap; + + BLF_boundbox_ex(font, data->text, sizeof(data->text), &wrap.rect, &wrap.info); + if ((data->align == SEQ_TEXT_ALIGN_X_LEFT) && (data->align_y == SEQ_TEXT_ALIGN_Y_TOP)) { y -= line_height; } else { - /* vars for calculating wordwrap */ - struct { - struct ResultBLF info; - rctf rect; - } wrap; - - BLF_boundbox_ex(font, data->text, sizeof(data->text), &wrap.rect, &wrap.info); - if (data->align == SEQ_TEXT_ALIGN_X_RIGHT) { x -= BLI_rctf_size_x(&wrap.rect); } @@ -3953,8 +3964,34 @@ static ImBuf *do_text_effect(const SeqRenderData *context, } } + if (data->flag & SEQ_TEXT_BOX) { + if (out->rect) { + const int margin = data->box_margin * width; + const int minx = x + wrap.rect.xmin - margin; + const int maxx = x + wrap.rect.xmax + margin; + const int miny = y + wrap.rect.ymin - margin; + const int maxy = y + wrap.rect.ymax + margin; + + if (data->flag & SEQ_TEXT_SHADOW) { + /* draw a shadow behind the box */ + int shadow_offset = 0.005f * width; + + if (shadow_offset == 0) { + shadow_offset = 1; + } + + IMB_rectfill_area_replace(out, + data->shadow_color, + minx + shadow_offset, + miny - shadow_offset, + maxx + shadow_offset, + maxy - shadow_offset); + } + IMB_rectfill_area_replace(out, data->box_color, minx, miny, maxx, maxy); + } + } /* BLF_SHADOW won't work with buffers, instead use cheap shadow trick */ - if (data->flag & SEQ_TEXT_SHADOW) { + else if (data->flag & SEQ_TEXT_SHADOW) { int fontx, fonty; fontx = BLF_width_max(font); fonty = line_height; @@ -4040,16 +4077,16 @@ static void store_icu_yrange_noop(Sequence *UNUSED(seq), } static void get_default_fac_noop(Sequence *UNUSED(seq), - float UNUSED(cfra), + float UNUSED(timeline_frame), float *facf0, float *facf1) { *facf0 = *facf1 = 1.0; } -static void get_default_fac_fade(Sequence *seq, float cfra, float *facf0, float *facf1) +static void get_default_fac_fade(Sequence *seq, float timeline_frame, float *facf0, float *facf1) { - *facf0 = (float)(cfra - seq->startdisp); + *facf0 = (float)(timeline_frame - seq->startdisp); *facf1 = (float)(*facf0 + 0.5f); *facf0 /= seq->len; *facf1 /= seq->len; @@ -4282,10 +4319,3 @@ int BKE_sequence_effect_get_num_inputs(int seq_type) } return 0; } - -int BKE_sequence_effect_get_supports_mask(int seq_type) -{ - struct SeqEffectHandle rval = get_sequence_effect_impl(seq_type); - - return rval.supports_mask; -} |