46 float sta = strip->content_start();
47 float end = strip->is_effect() ? strip->right_handle(scene) : strip->content_end(scene) - 1;
58 frame_index = end - timeline_frame;
61 frame_index = timeline_frame - sta;
64 frame_index =
max_ff(frame_index, 0);
66 const float scene_fps =
float(scene->
r.frs_sec) /
float(scene->
r.frs_sec_base);
67 frame_index *= strip->media_playback_rate_factor(scene_fps);
73 frame_index = retiming_factor * strip->content_length();
76 float frame_index_max = strip->is_effect() ? end - sta : strip->content_length() - 1;
77 frame_index =
clamp_f(frame_index, 0, frame_index_max);
79 if (strip->strobe > 1.0f) {
80 frame_index -=
fmodf(
double(frame_index),
double(strip->strobe));
88 return strip_meta->start + strip_meta->startofs;
93 return strip_meta->start + strip_meta->content_length() - strip_meta->end_offset();
103 for (
Strip &strip : strip_meta->seqbase) {
111 if (strip.runtime->scene_sound) {
112 int startofs = strip.startofs;
113 int endofs = strip.end_offset();
114 if (strip.startofs + strip.start < start) {
115 startofs = start - strip.start;
118 if (strip.start + strip.content_length() - strip.end_offset() > end) {
119 endofs = strip.start + strip.content_length() - end;
122 double offset_time = 0.0f;
123 if (strip.sound !=
nullptr) {
124 offset_time = strip.sound->offset_time + strip.sound_offset;
128 strip.runtime->scene_sound,
129 strip.start + startofs,
130 strip.start + strip.content_length() - endofs,
131 startofs + strip.anim_startofs,
146 if (strip_meta ==
nullptr) {
150 if (strip_meta->seqbase.is_empty()) {
154 const int strip_start = strip_meta->left_handle();
155 const int strip_end = strip_meta->right_handle(scene);
159 for (
Strip &strip : strip_meta->seqbase) {
164 strip_meta->start =
min + strip_meta->anim_startofs;
165 strip_meta->content_length_set(
max - strip_meta->anim_endofs - strip_meta->start);
169 strip_meta->startofs = strip_start - strip_meta->start;
170 strip_meta->startdisp = strip_start;
171 strip_meta->end_offset_set(strip_meta->start + strip_meta->length(scene) - strip_end);
172 strip_meta->enddisp = strip_end;
184 const int first_start = input1->left_handle();
185 const int second_start = input2->left_handle();
186 return (first_start > second_start) ||
187 (first_start == second_start &&
188 input1->right_handle(scene) > input2->right_handle(scene));
193 if (strip->input1 ==
nullptr && strip->input2 ==
nullptr) {
197 if (strip->input1 && strip->input2) {
198 strip->startdisp =
max_ii(strip->input1->left_handle(), strip->input2->left_handle());
199 strip->enddisp =
min_ii(strip->input1->right_handle(scene),
200 strip->input2->right_handle(scene));
206 std::swap(strip->input1, strip->input2);
209 else if (strip->input1) {
210 strip->startdisp = strip->input1->right_handle(scene);
211 strip->enddisp = strip->input1->left_handle();
213 else if (strip->input2) {
214 strip->startdisp = strip->input2->right_handle(scene);
215 strip->enddisp = strip->input2->left_handle();
218 if (strip->startdisp > strip->enddisp) {
219 std::swap(strip->startdisp, strip->enddisp);
223 strip->startofs = strip->anim_startofs = strip->anim_endofs = 0;
224 strip->end_offset_set(0);
225 strip->start = strip->startdisp;
226 strip->content_length_set(strip->enddisp - strip->startdisp);
232 for (
Strip *strip : effects) {
238 for (
Strip *strip : effects) {
247 const bool do_skip_mute,
248 const bool do_center,
249 const bool do_unselected)
254 int dist, best_dist, best_frame = timeline_frame;
255 int strip_frames[2], strip_frames_tot;
263 return timeline_frame;
266 for (
Strip &strip : *
ed->current_strips()) {
273 if (do_unselected && (strip.flag &
SEQ_SELECT)) {
278 strip_frames[0] = (strip.left_handle() + strip.right_handle(scene)) / 2;
279 strip_frames_tot = 1;
282 strip_frames[0] = strip.left_handle();
283 strip_frames[1] = strip.right_handle(scene);
285 strip_frames_tot = 2;
288 for (i = 0; i < strip_frames_tot; i++) {
289 const int strip_frame = strip_frames[i];
295 if (strip_frame < timeline_frame) {
296 dist = timeline_frame - strip_frame;
300 if (strip_frame > timeline_frame) {
301 dist = strip_frame - timeline_frame;
305 dist =
abs(strip_frame - timeline_frame);
311 if (dist < best_dist) {
312 best_frame = strip_frame;
323 r_rect->
xmin = scene->
r.sfra;
324 r_rect->
xmax = scene->
r.efra + 1;
331 if (seqbase ==
nullptr) {
335 for (
Strip &strip : *seqbase) {
336 rect->
xmin = std::min<float>(rect->
xmin, strip.left_handle() - 1);
337 rect->
xmax = std::max<float>(rect->
xmax, strip.right_handle(scene) + 1);
339 rect->
ymax = std::max(rect->
ymax, strip.channel + 1.0f);
351 const int timeline_frame)
353 for (
Strip *strip : strips) {
354 if (strip->intersects_frame(scene, timeline_frame)) {
362 ListBaseT<Strip> *seqbase,
363 const int initial_frame,
369 const int sfra = int(rectf.
xmin);
370 const int efra = int(rectf.
xmax);
371 int timeline_frame = initial_frame;
378 for (; timeline_frame >= sfra; timeline_frame--) {
384 timeline_frame = initial_frame;
388 for (; timeline_frame <= efra; timeline_frame++) {
396 for (; timeline_frame <= efra; timeline_frame++) {
398 const int gap_end_frame = timeline_frame;
409 float subframe_delta,
414 strip->sound_offset += subframe_delta / scene->frames_per_second();
417 if (delta == 0 && (!slip_keyframes || subframe_delta == 0.0f)) {
423 if (strip->input1 !=
nullptr || strip->input2 !=
nullptr) {
429 if (!recursed && strip->is_effect()) {
436 if (strip->seqbase.is_empty()) {
440 for (
Strip &strip_child : strip->seqbase) {
446 strip->start = strip->start + delta;
448 if (slip_keyframes) {
449 float anim_offset = delta;
451 anim_offset += subframe_delta;
457 strip->startofs = strip->startofs - delta;
458 strip->end_offset_set(strip->end_offset() + delta);
462 strip->startdisp = strip->left_handle();
463 strip->enddisp = strip->right_handle(scene);
470 const Scene *scene,
Strip *strip,
int frame_delta,
float subframe_delta,
bool slip_keyframes)
477float Strip::media_playback_rate_factor(
float scene_fps)
const
482 if (this->media_playback_rate == 0.0f) {
485 return this->media_playback_rate / scene_fps;
488float Strip::media_fps(Scene *scene)
490 switch (this->
type) {
499 if (this->clip !=
nullptr) {
504 if (this->scene !=
nullptr) {
505 return float(this->scene->r.frs_sec) / this->scene->r.frs_sec_base;
514float Strip::content_start()
const
519void Strip::content_start_set(
const Scene *scene,
int timeline_frame)
521 this->start = timeline_frame;
527float Strip::content_end(
const Scene *scene)
const
529 return this->content_start() + this->
length(scene);
532int Strip::length(
const Scene *scene)
const
534 const float scene_fps =
float(scene->r.frs_sec) /
float(scene->r.frs_sec_base);
539 const int sound_offset = this->rounded_sound_offset(scene_fps);
540 return last_key_frame - this->content_start() - sound_offset;
543 return this->content_length() / this->media_playback_rate_factor(scene_fps);
546int Strip::rounded_sound_offset(
float scene_fps)
const
549 return round_fl_to_int((this->sound->offset_time + this->sound_offset) * scene_fps);
554int Strip::left_handle()
const
556 if (this->input1 || this->input2) {
557 return this->startdisp;
560 return this->start + this->startofs;
563int Strip::right_handle(
const Scene *scene)
const
565 if (this->input1 || this->input2) {
566 return this->enddisp;
569 return this->content_end(scene) - this->end_offset();
572void Strip::left_handle_set(
const Scene *scene,
int timeline_frame)
574 const float right_handle_orig_frame = this->right_handle(scene);
576 if (timeline_frame >= right_handle_orig_frame) {
577 timeline_frame = right_handle_orig_frame - 1;
580 float offset = timeline_frame - this->content_start();
585 this->content_start_set(scene, timeline_frame);
586 this->end_offset_set(this->end_offset() + offset);
589 this->startofs = offset;
592 this->startdisp = timeline_frame;
599void Strip::right_handle_set(
const Scene *scene,
int timeline_frame)
601 const float left_handle_orig_frame = this->left_handle();
603 if (timeline_frame <= left_handle_orig_frame) {
604 timeline_frame = left_handle_orig_frame + 1;
607 this->end_offset_set(this->content_end(scene) - timeline_frame);
608 this->enddisp = timeline_frame;
615void Strip::handles_set(
const Scene *scene,
int left_frame,
int right_frame)
619 if (left_frame >= this->right_handle(scene)) {
621 this->right_handle_set(scene, right_frame);
622 this->left_handle_set(scene, left_frame);
625 this->left_handle_set(scene, left_frame);
626 this->right_handle_set(scene, right_frame);
630void Strip::channel_set(
int channel)
635bool Strip::intersects_frame(
const Scene *scene,
const int timeline_frame)
const
637 return (this->left_handle() <= timeline_frame) && (this->right_handle(scene) > timeline_frame);
640int Strip::content_length()
const
643 float new_length = this->scene->r.efra - this->scene->r.sfra + 1 - this->anim_startofs -
645 return max_ff(new_length, 0);
650float Strip::end_offset()
const
653 return this->content_length() - (this->
len - this->endofs);
658void Strip::content_length_set(
int new_length)
660 this->
len = new_length;
663void Strip::end_offset_set(
float new_end_offset)
666 this->
len = this->content_length();
668 this->endofs = new_end_offset;
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
T clamp(const T &a, const T &min, const T &max)
Strip * lookup_meta_by_strip(Editing *ed, const Strip *key)
int time_find_next_prev_edit(Scene *scene, int timeline_frame, const Side side, const bool do_skip_mute, const bool do_center, const bool do_unselected)
void seq_time_gap_info_get(const Scene *scene, ListBaseT< Strip > *seqbase, const int initial_frame, GapInfo *r_gap_info)
static int metastrip_end_get(Strip *strip_meta)
float give_frame_index(const Scene *scene, const Strip *strip, float timeline_frame)
bool render_is_muted(const ListBaseT< SeqTimelineChannel > *channels, const Strip *strip)
Editing * editing_get(const Scene *scene)
MovieReaderAccessor movie_reader_cache_acquire_any(const Scene &scene, const Strip &strip)
void timeline_boundbox(const Scene *scene, const ListBaseT< Strip > *seqbase, rctf *r_rect)
bool effect_is_transition(StripType type)
int retiming_key_frame_get(const Scene *scene, const Strip *strip, const SeqRetimingKey *key)
void offset_animdata(const Scene *scene, Strip *strip, float ofs)
VectorSet< Strip * > query_all_strips(ListBaseT< Strip > *seqbase)
static bool transition_inputs_have_wrong_order(const Scene *scene, const Strip *input1, const Strip *input2)
bool transform_single_image_check(const Strip *strip)
void strip_time_update_effects_strip_range(const Scene *scene, const Span< Strip * > effects)
constexpr int MAX_CHANNELS
void time_update_meta_strip_range(const Scene *scene, Strip *strip_meta)
void time_slip_strip(const Scene *scene, Strip *strip, int frame_delta, float subframe_delta, bool slip_keyframes)
Span< Strip * > lookup_effects_by_strip(Editing *ed, const Strip *key)
bool retiming_has_keys(const Strip *strip)
void strip_update_sound_bounds_recursive(const Scene *scene, Strip *strip_meta)
static void strip_time_slip_strip_ex(const Scene *scene, Strip *strip, int delta, float subframe_delta, bool slip_keyframes, bool recursed)
void timeline_init_boundbox(const Scene *scene, rctf *r_rect)
void timeline_expand_boundbox(const Scene *scene, const ListBaseT< Strip > *seqbase, rctf *rect)
static void strip_update_sound_bounds_recursive_impl(const Scene *scene, Strip *strip_meta, int start, int end)
static int metastrip_start_get(Strip *strip_meta)
static bool strip_exists_at_frame(const Scene *scene, Span< Strip * > strips, const int timeline_frame)
ListBaseT< SeqTimelineChannel > * channels_displayed_get(const Editing *ed)
SeqRetimingKey * retiming_last_key_get(const Strip *strip)
float strip_retiming_evaluate(const Strip *strip, const float frame_index)
void strip_time_effect_range_set(const Scene *scene, Strip *strip)
MINLINE int round_fl_to_int(float a)
void BKE_sound_move_scene_sound(const Scene *scene, AUD_SequenceEntry handle, int startframe, int endframe, int frameskip, double audio_offset)
MINLINE int max_ii(int a, int b)
float BKE_movieclip_get_fps(MovieClip *clip)
MINLINE float max_ff(float a, float b)
float MOV_get_fps(const MovieReader *anim)
MINLINE int min_ii(int a, int b)
MINLINE float clamp_f(float value, float min, float max)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float