Changeset View
Changeset View
Standalone View
Standalone View
source/blender/sequencer/intern/effects.c
| Show First 20 Lines • Show All 3,144 Lines • ▼ Show 20 Lines | else { | ||||
| } | } | ||||
| else { | else { | ||||
| *ymin = 0.0; | *ymin = 0.0; | ||||
| *ymax = seq->len; | *ymax = seq->len; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Generator strips with zero inputs have their length set to 1 pernamently. In some cases it is | |||||
| * useful to use speed effect on these strips because they can be animated. This can be done by | |||||
sergey: Add explanation why this is needed (mostly copy-paste info from the patch description). Reading… | |||||
| * using their length as is on timeline as content length. See T82698. */ | |||||
| int seq_effect_speed_get_strip_content_length(const Sequence *seq) | |||||
| { | |||||
| if (SEQ_effect_get_num_inputs(seq->type) == 0) { | |||||
| return seq->enddisp - seq->startdisp; | |||||
| } | |||||
| return seq->len; | |||||
| } | |||||
| void seq_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool force) | void seq_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool force) | ||||
| { | { | ||||
| int timeline_frame; | int timeline_frame; | ||||
| float fallback_fac = 1.0f; | float fallback_fac = 1.0f; | ||||
| SpeedControlVars *v = (SpeedControlVars *)seq->effectdata; | SpeedControlVars *v = (SpeedControlVars *)seq->effectdata; | ||||
| FCurve *fcu = NULL; | FCurve *fcu = NULL; | ||||
| int flags = v->flags; | int flags = v->flags; | ||||
| Show All 18 Lines | if (!v->frameMap || v->length != seq->len) { | ||||
| v->length = seq->len; | v->length = seq->len; | ||||
| v->frameMap = MEM_callocN(sizeof(float) * v->length, "speedcontrol frameMap"); | v->frameMap = MEM_callocN(sizeof(float) * v->length, "speedcontrol frameMap"); | ||||
| } | } | ||||
| fallback_fac = 1.0; | fallback_fac = 1.0; | ||||
| const int target_strip_length = seq_effect_speed_get_strip_content_length(seq->seq1); | |||||
Done Inline Actionsconst sergey: `const` | |||||
| if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) { | if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) { | ||||
| if ((seq->seq1->enddisp != seq->seq1->start) && (seq->seq1->len != 0)) { | if ((seq->seq1->enddisp != seq->seq1->start) && (target_strip_length != 0)) { | ||||
| fallback_fac = (float)seq->seq1->len / (float)(seq->seq1->enddisp - seq->seq1->start); | fallback_fac = (float)target_strip_length / (float)(seq->seq1->enddisp - seq->seq1->start); | ||||
| flags = SEQ_SPEED_INTEGRATE; | flags = SEQ_SPEED_INTEGRATE; | ||||
| fcu = NULL; | fcu = NULL; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* if there is no fcurve, use value as simple multiplier */ | /* if there is no fcurve, use value as simple multiplier */ | ||||
| if (!fcu) { | if (!fcu) { | ||||
| fallback_fac = seq->speed_fader; /* same as speed_factor in rna*/ | fallback_fac = seq->speed_fader; /* same as speed_factor in rna*/ | ||||
| Show All 13 Lines | for (timeline_frame = 1; timeline_frame < v->length; timeline_frame++) { | ||||
| } | } | ||||
| else { | else { | ||||
| facf = fallback_fac; | facf = fallback_fac; | ||||
| } | } | ||||
| facf *= v->globalSpeed; | facf *= v->globalSpeed; | ||||
| cursor += facf; | cursor += facf; | ||||
| if (cursor >= seq->seq1->len) { | if (cursor >= target_strip_length) { | ||||
| v->frameMap[timeline_frame] = seq->seq1->len - 1; | v->frameMap[timeline_frame] = target_strip_length - 1; | ||||
| } | } | ||||
| else { | else { | ||||
| v->frameMap[timeline_frame] = cursor; | v->frameMap[timeline_frame] = cursor; | ||||
| v->lastValidFrame = timeline_frame; | v->lastValidFrame = timeline_frame; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| float facf; | float facf; | ||||
| v->lastValidFrame = 0; | v->lastValidFrame = 0; | ||||
| for (timeline_frame = 0; timeline_frame < v->length; timeline_frame++) { | for (timeline_frame = 0; timeline_frame < v->length; timeline_frame++) { | ||||
| if (fcu) { | if (fcu) { | ||||
| facf = evaluate_fcurve(fcu, seq->startdisp + timeline_frame); | facf = evaluate_fcurve(fcu, seq->startdisp + timeline_frame); | ||||
| } | } | ||||
| else { | else { | ||||
| facf = fallback_fac; | facf = fallback_fac; | ||||
| } | } | ||||
| if (flags & SEQ_SPEED_COMPRESS_IPO_Y) { | if (flags & SEQ_SPEED_COMPRESS_IPO_Y) { | ||||
| facf *= seq->seq1->len; | facf *= target_strip_length; | ||||
| } | } | ||||
| facf *= v->globalSpeed; | facf *= v->globalSpeed; | ||||
| if (facf >= seq->seq1->len) { | if (facf >= target_strip_length) { | ||||
| facf = seq->seq1->len - 1; | facf = target_strip_length - 1; | ||||
| } | } | ||||
| else { | else { | ||||
| v->lastValidFrame = timeline_frame; | v->lastValidFrame = timeline_frame; | ||||
| } | } | ||||
| v->frameMap[timeline_frame] = facf; | v->frameMap[timeline_frame] = facf; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,072 Lines • Show Last 20 Lines | |||||
Add explanation why this is needed (mostly copy-paste info from the patch description). Reading comment in the code is easier than to track down commit and read its description.