diff options
Diffstat (limited to 'source/blender/sequencer/intern/effects.c')
-rw-r--r-- | source/blender/sequencer/intern/effects.c | 57 |
1 files changed, 25 insertions, 32 deletions
diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c index 0e5e56908b0..25a6acb8975 100644 --- a/source/blender/sequencer/intern/effects.c +++ b/source/blender/sequencer/intern/effects.c @@ -2475,8 +2475,8 @@ static ImBuf *do_adjustment_impl(const SeqRenderData *context, Sequence *seq, fl * frame is static after end of strip). This is how most strips behave. This way transition * effects that doesn't overlap or speed effect can't fail rendering outside of strip range. */ timeline_frame = clamp_i(timeline_frame, - SEQ_time_left_handle_frame_get(seq), - SEQ_time_right_handle_frame_get(seq) - 1); + SEQ_time_left_handle_frame_get(context->scene, seq), + SEQ_time_right_handle_frame_get(context->scene, seq) - 1); if (seq->machine > 1) { i = seq_render_give_ibuf_seqbase( @@ -2578,20 +2578,6 @@ static int early_out_speed(Sequence *UNUSED(seq), float UNUSED(fac)) return EARLY_DO_EFFECT; } -/** - * Generator strips with zero inputs have their length set to 1 permanently. In some cases it is - * useful to use speed effect on these strips because they can be animated. This can be done by - * using their length as is on timeline as content length. See T82698. - */ -static int seq_effect_speed_get_strip_content_length(const Sequence *seq) -{ - if ((seq->type & SEQ_TYPE_EFFECT) != 0 && SEQ_effect_get_num_inputs(seq->type) == 0) { - return SEQ_time_right_handle_frame_get(seq) - SEQ_time_left_handle_frame_get(seq); - } - - return seq->len; -} - static FCurve *seq_effect_speed_speed_factor_curve_get(Scene *scene, Sequence *seq) { return id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_factor", 0, NULL); @@ -2599,7 +2585,10 @@ static FCurve *seq_effect_speed_speed_factor_curve_get(Scene *scene, Sequence *s void seq_effect_speed_rebuild_map(Scene *scene, Sequence *seq) { - if ((seq->seq1 == NULL) || (seq->len < 1)) { + const int effect_strip_length = SEQ_time_right_handle_frame_get(scene, seq) - + SEQ_time_left_handle_frame_get(scene, seq); + + if ((seq->seq1 == NULL) || (effect_strip_length < 1)) { return; /* Make coverity happy and check for (CID 598) input strip... */ } @@ -2613,15 +2602,14 @@ void seq_effect_speed_rebuild_map(Scene *scene, Sequence *seq) MEM_freeN(v->frameMap); } - const int effect_strip_length = SEQ_time_right_handle_frame_get(seq) - - SEQ_time_left_handle_frame_get(seq); v->frameMap = MEM_mallocN(sizeof(float) * effect_strip_length, __func__); v->frameMap[0] = 0.0f; float target_frame = 0; for (int frame_index = 1; frame_index < effect_strip_length; frame_index++) { - target_frame += evaluate_fcurve(fcu, SEQ_time_left_handle_frame_get(seq) + frame_index); - CLAMP(target_frame, 0, seq->seq1->len); + target_frame += evaluate_fcurve(fcu, SEQ_time_left_handle_frame_get(scene, seq) + frame_index); + const int target_frame_max = SEQ_time_strip_length_get(scene, seq->seq1); + CLAMP(target_frame, 0, target_frame_max); v->frameMap[frame_index] = target_frame; } } @@ -2646,7 +2634,7 @@ float seq_speed_effect_target_frame_get(Scene *scene, } SEQ_effect_handle_get(seq_speed); /* Ensure, that data are initialized. */ - int frame_index = seq_give_frame_index(seq_speed, timeline_frame); + int frame_index = seq_give_frame_index(scene, seq_speed, timeline_frame); SpeedControlVars *s = (SpeedControlVars *)seq_speed->effectdata; const Sequence *source = seq_speed->seq1; @@ -2654,10 +2642,10 @@ float seq_speed_effect_target_frame_get(Scene *scene, switch (s->speed_control_type) { case SEQ_SPEED_STRETCH: { /* Only right handle controls effect speed! */ - const float target_content_length = seq_effect_speed_get_strip_content_length(source) - + const float target_content_length = SEQ_time_strip_length_get(scene, source) - source->startofs; - const float speed_effetct_length = SEQ_time_right_handle_frame_get(seq_speed) - - SEQ_time_left_handle_frame_get(seq_speed); + const float speed_effetct_length = SEQ_time_right_handle_frame_get(scene, seq_speed) - + SEQ_time_left_handle_frame_get(scene, seq_speed); const float ratio = frame_index / speed_effetct_length; target_frame = target_content_length * ratio; break; @@ -2674,15 +2662,14 @@ float seq_speed_effect_target_frame_get(Scene *scene, break; } case SEQ_SPEED_LENGTH: - target_frame = seq_effect_speed_get_strip_content_length(source) * - (s->speed_fader_length / 100.0f); + target_frame = SEQ_time_strip_length_get(scene, source) * (s->speed_fader_length / 100.0f); break; case SEQ_SPEED_FRAME_NUMBER: target_frame = s->speed_fader_frame_number; break; } - CLAMP(target_frame, 0, seq_effect_speed_get_strip_content_length(source)); + CLAMP(target_frame, 0, SEQ_time_strip_length_get(scene, source)); target_frame += seq_speed->start; /* No interpolation. */ @@ -3507,15 +3494,21 @@ static int early_out_mul_input1(Sequence *UNUSED(seq), float fac) return EARLY_DO_EFFECT; } -static void get_default_fac_noop(Sequence *UNUSED(seq), float UNUSED(timeline_frame), float *fac) +static void get_default_fac_noop(const Scene *UNUSED(scene), + Sequence *UNUSED(seq), + float UNUSED(timeline_frame), + float *fac) { *fac = 1.0f; } -static void get_default_fac_fade(Sequence *seq, float timeline_frame, float *fac) +static void get_default_fac_fade(const Scene *scene, + Sequence *seq, + float timeline_frame, + float *fac) { - *fac = (float)(timeline_frame - SEQ_time_left_handle_frame_get(seq)); - *fac /= seq->len; + *fac = (float)(timeline_frame - SEQ_time_left_handle_frame_get(scene, seq)); + *fac /= SEQ_time_strip_length_get(scene, seq); } static struct ImBuf *init_execution(const SeqRenderData *context, |