61 const int timeline_frame)
63 const float scene_fps = float(scene->
r.frs_sec) / float(scene->
r.frs_sec_base);
71 const int timeline_frame)
75 if (key_timeline_frame == timeline_frame) {
90 if (key.strip_frame_index > frame_index) {
137 dependant.
add(strip);
171 if (strip->
len < 2) {
196 return segment_fac_diff / segment_length;
226 std::swap(v1[0], v1[1]);
227 std::swap(
v2[0],
v2[1]);
237 r_center[0] = s1_1[0] + lambda * (s1_2[0] - s1_1[0]);
238 r_center[1] = s1_1[1] + lambda * (s1_2[1] - s1_1[1]);
276 return abs(prev_speed - next_speed) < 0.01f;
280 const float frame_index)
285 const float y = c[1] + side *
sqrt(
pow(r, 2) -
pow((frame_index - c[0]), 2));
293 const int start_key_index = start_key - strip->
retiming_keys;
294 BLI_assert(start_key_index < strip->retiming_keys_num);
300 return std::min(1.0f, start_key->
retiming_factor +
float(segment_step * segment_frame_index));
305 return std::min(1.0f, start_key->
retiming_factor +
float(segment_step * segment_frame_index));
310 BLI_assert(start_key_index < strip->retiming_keys_num - 1);
322 if (frame_index <= 0) {
345 const int new_key_index = start_key - keys + 1;
350 if (new_key_index > 0) {
353 if (new_key_index < keys_count) {
354 memcpy(new_keys + new_key_index + 1,
355 keys + new_key_index,
377 const int timeline_frame)
384 float new_midpoint_offset = new_frame_index - midpoint;
389 SeqRetimingKey *prev_segment_end = key_start - 1, *next_segment_start = key_end + 1;
390 const float offset_max_left = midpoint - prev_segment_end->
strip_frame_index - 1;
391 const float offset_max_right = next_segment_start->strip_frame_index - midpoint - 1;
392 new_midpoint_offset =
fabs(new_midpoint_offset);
393 new_midpoint_offset =
min_fff(new_midpoint_offset, offset_max_left, offset_max_right);
394 new_midpoint_offset =
max_ff(new_midpoint_offset, 1);
445 size_t new_keys_count = keys_count - keys_to_remove.
size() - transitions.
size() / 2;
486 memcpy(keys + key_index,
499 transition_start = key - 1;
543 return max_tml_frame_offset;
554 const float tml_frame_offset =
math::clamp(
float(offset), max_offset.
min, max_offset.
max);
560 const float scene_fps = float(scene->
r.frs_sec) / float(scene->
r.frs_sec_base);
561 const float frame_index_offset = tml_frame_offset *
566 if (freeze_start ==
nullptr) {
568 return {
nullptr,
nullptr};
570 return {freeze_start, freeze_start + 1};
574 scene, strip, orig_timeline_frame + tml_frame_offset);
576 if (freeze_end ==
nullptr) {
577 return {
nullptr,
nullptr};
580 return {freeze_end - 1, freeze_end};
596 scene, strip, key, offset);
598 if (freeze_keys.first ==
nullptr) {
604 freeze_keys.first->retiming_factor = orig_retiming_factor;
605 freeze_keys.second->retiming_factor = orig_retiming_factor;
606 return freeze_keys.second;
636 orig_frame_index + clamped_offset);
658 const float scene_fps = float(scene->
r.frs_sec) / float(scene->
r.frs_sec_base);
661 return std::clamp(offset, prev_max_offset + min_step, next_max_offset - min_step);
670 const float scene_fps = float(scene->
r.frs_sec) / float(scene->
r.frs_sec_base);
689 const int timeline_frame)
692 return timeline_frame;
695 int prev_key_timeline_frame = -
MAXFRAME;
696 int next_key_timeline_frame =
MAXFRAME;
708 return std::clamp(timeline_frame, prev_key_timeline_frame + 1, next_key_timeline_frame - 1);
718 const float scene_fps = float(scene->
r.frs_sec) / float(scene->
r.frs_sec_base);
765 const float scene_fps = float(scene->
r.frs_sec) / float(scene->
r.frs_sec_base);
775 const int timeline_frame)
783 scene, strip, key, timeline_frame);
784 const float scene_fps = float(scene->
r.frs_sec) / float(scene->
r.frs_sec_base);
785 const float offset = (clamped_timeline_frame - orig_timeline_frame) *
792 for (
int i = key_index;
i < key_count;
i++) {
800 strip->
start += clamped_timeline_frame - orig_timeline_frame;
801 for (
int i = key_index + 1;
i < key_count;
i++) {
822 const int frame_index_max = strip->
len - 1;
825 const float segment_content_frame_count = frame_index_end - frame_index_start;
827 const float speed = segment_content_frame_count / segment_length;
840 const int frame_index_max = strip->
len - 1;
844 const float scene_fps = float(scene->
r.frs_sec) / float(scene->
r.frs_sec_base);
845 const float segment_timeline_duration = (frame_index - frame_index_prev) /
847 const float new_timeline_duration = segment_timeline_duration / speed;
850 const float new_timeline_frame = std::round(
857 const int offset = new_timeline_frame - orig_timeline_frame;
915 int range_offset = 0, rhs_range_offset = 0;
923 new_range.
end = rhs_range.
end;
933 new_range.
end = rhs_range.
end;
944 new_range.
speed = 1.0f;
945 const int new_range_len = new_range.
end - new_range.
start;
948 for (
int i = 0;
i < new_range_len;
i++) {
949 const float range_speed =
speed_table[
i + range_offset];
950 const float rhs_range_speed = rhs_range.
speed_table[
i + rhs_range_offset];
955 for (
int i = 0;
i < new_range_len;
i++) {
956 const float range_speed =
speed_table[
i + range_offset];
961 for (
int i = 0;
i < new_range_len;
i++) {
962 const float rhs_range_speed = rhs_range.
speed_table[
i + rhs_range_offset];
972 for (
int timeline_frame =
start; timeline_frame <=
end; timeline_frame++) {
974 const double normal_step = 1 / double(strip->
len - 1);
980 const double speed_at_frame = (val - val_prev) / normal_step;
1009 if (key.strip_frame_index == 0) {
1034 for (
int i = 0;
i <
ranges.size();
i++) {
1046 ranges.insert(
i, range * rhs_range);
1047 ranges.insert(
i, range * rhs_range);
1048 range.
start = rhs_range.end + 1;
1051 ranges.insert(
i, range * rhs_range);
1052 range.
end = rhs_range.start;
1060 ranges.insert(
i, range * rhs_range);
1073 if (meta_parent ==
nullptr) {
1074 return strip_retiming_data;
1078 strip_retiming_data *= meta_retiming_data;
1079 return strip_retiming_data;
1092 const float scene_fps = float(scene->
r.frs_sec) / float(scene->
r.frs_sec_base);
1096 for (
int i = 0;
i < retiming_data.
ranges.size();
i++) {
1100 const int range_length = range.
end - range.
start;
1101 for (
int i = 0;
i <= range_length;
i++) {
1102 const int frame = range.
start +
i;
1116 bool was_empty =
true;
1154 selection.
add(&key, strip);
1177 bool has_start =
false, has_end =
false;
1181 for (
auto item : selection.
items()) {
1182 if (item.key == key_start) {
1185 if (item.key == key_end) {
1188 if (has_start && has_end) {
void BKE_sound_set_scene_sound_pitch_constant_range(void *handle, int frame_start, int frame_end, float pitch)
void BKE_sound_set_scene_sound_pitch_at_frame(void *handle, int frame, float pitch, char animated)
#define LISTBASE_FOREACH(type, var, list)
MINLINE int round_fl_to_int(float a)
MINLINE float max_ff(float a, float b)
MINLINE float min_fff(float a, float b, float c)
int isect_seg_seg_v2_lambda_mu_db(const double v1[2], const double v2[2], const double v3[2], const double v4[2], double *r_lambda, double *r_mu)
MINLINE void copy_v2_v2_db(double r[2], const double a[2])
MINLINE double len_v2v2_db(const double v1[2], const double v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2v2_db(double r[2], const double a[2], const double b[2])
#define UNUSED_VARS_NDEBUG(...)
@ SEQ_SPEED_TRANSITION_OUT
@ SEQ_SPEED_TRANSITION_IN
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMVert * v2
void append(const T &value)
bool add(const Key &key, const Value &value)
ItemIterator items() const &
bool remove(const Key &key)
void add_multiple(Span< Key > keys)
int64_t remove_if(Predicate &&predicate)
bool contains(const T &value) const
void append_non_duplicates(const T &value)
RetimingRangeData & operator*=(const RetimingRangeData &rhs)
RetimingRangeData(const Strip *strip)
blender::Vector< RetimingRange > ranges
RetimingRange(int start_frame, int end_frame, float speed, eRangeType type)
RetimingRange duplicate()
eIntersectType intersect_type(const RetimingRange &other) const
RetimingRange(const Strip *strip, int start_frame, int end_frame, float speed, eRangeType type)
RetimingRange operator*(const RetimingRange &rhs_range)
blender::Vector< float > speed_table
void claculate_speed_table_from_seq(const Strip *strip)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
ccl_device_inline float2 fabs(const float2 a)
T clamp(const T &a, const T &min, const T &max)
int retiming_key_index_get(const Strip *strip, const SeqRetimingKey *key)
Strip * lookup_meta_by_strip(Editing *ed, const Strip *key)
int time_right_handle_frame_get(const Scene *scene, const Strip *strip)
static bool strip_retiming_transition_is_linear(const Strip *strip, const SeqRetimingKey *key)
SeqRetimingKey * retiming_add_transition(const Scene *scene, Strip *strip, SeqRetimingKey *key, float offset)
void retiming_key_speed_set(const Scene *scene, Strip *strip, SeqRetimingKey *key, const float speed, bool keep_retiming)
static SeqRetimingKey * strip_retiming_add_key(Strip *strip, float frame_index)
bool retiming_key_is_transition_start(const SeqRetimingKey *key)
bool retiming_selection_has_whole_transition(const Editing *ed, SeqRetimingKey *key)
static double strip_retiming_segment_length_get(const SeqRetimingKey *start_key)
void retiming_key_timeline_frame_set(const Scene *scene, Strip *strip, SeqRetimingKey *key, const int timeline_frame)
void retiming_reset(Scene *scene, Strip *strip)
bool retiming_selection_contains(const Editing *ed, const SeqRetimingKey *key)
int retiming_keys_count(const Strip *strip)
blender::Map< SeqRetimingKey *, Strip * > retiming_selection_get(const Editing *ed)
float time_media_playback_rate_factor_get(const Strip *strip, const float scene_fps)
SeqRetimingKey * retiming_add_freeze_frame(const Scene *scene, Strip *strip, SeqRetimingKey *key, const int offset)
int retiming_key_timeline_frame_get(const Scene *scene, const Strip *strip, const SeqRetimingKey *key)
static void strip_retiming_key_offset(const Scene *scene, Strip *strip, SeqRetimingKey *key, const float offset)
static void strip_retiming_line_segments_tangent_circle(const SeqRetimingKey *start_key, double r_center[2], double *radius)
Editing * editing_get(const Scene *scene)
blender::Span< Strip * > SEQ_lookup_effects_by_strip(Editing *ed, const Strip *key)
void retiming_remove_multiple_keys(Strip *strip, blender::Vector< SeqRetimingKey * > &keys_to_remove)
MutableSpan< SeqRetimingKey > retiming_keys_get(const Strip *strip)
SeqRetimingKey * retiming_transition_start_get(SeqRetimingKey *key)
void retiming_data_ensure(Strip *strip)
void retiming_remove_key(Strip *strip, SeqRetimingKey *key)
int time_left_handle_frame_get(const Scene *, const Strip *strip)
static SeqRetimingKey * strip_retiming_remove_transition(Strip *strip, SeqRetimingKey *key)
SeqRetimingKey * retiming_find_segment_start_key(const Strip *strip, float frame_index)
int time_get_rounded_sound_offset(const Strip *strip, const float frames_per_second)
void retiming_selection_remove(SeqRetimingKey *key)
void retiming_data_clear(Strip *strip)
float time_start_frame_get(const Strip *strip)
void query_strip_effect_chain(const Scene *scene, Strip *reference_strip, ListBase *seqbase, VectorSet< Strip * > &r_strips)
void strip_time_update_effects_strip_range(const Scene *scene, const blender::Span< Strip * > effects)
SeqRetimingKey * retiming_key_get_by_timeline_frame(const Scene *scene, const Strip *strip, const int timeline_frame)
bool retiming_is_active(const Strip *strip)
bool retiming_key_is_transition_type(const SeqRetimingKey *key)
void time_update_meta_strip_range(const Scene *scene, Strip *strip_meta)
bool retiming_key_is_freeze_frame(const SeqRetimingKey *key)
static void strip_retiming_remove_key_ex(Strip *strip, SeqRetimingKey *key)
bool retiming_data_is_editable(const Strip *strip)
void iterator_set_expand(const Scene *scene, ListBase *seqbase, VectorSet< Strip * > &strips, void strip_query_func(const Scene *scene, Strip *strip_reference, ListBase *seqbase, VectorSet< Strip * > &strips))
static Bounds< float > strip_retiming_clamp_bounds_get(const Scene *scene, const Strip *strip, SeqRetimingKey *key)
void retiming_selection_copy(SeqRetimingKey *dst, const SeqRetimingKey *src)
static void strip_retiming_transition_offset(const Scene *scene, Strip *strip, SeqRetimingKey *key, const float offset)
static void retiming_key_overlap(Scene *scene, Strip *strip)
void retiming_sound_animation_data_set(const Scene *scene, const Strip *strip)
bool retiming_selection_clear(const Editing *ed)
float retiming_key_speed_get(const Strip *strip, const SeqRetimingKey *key)
static float strip_retiming_evaluate_arc_segment(const SeqRetimingKey *key, const float frame_index)
static float strip_retiming_clamp_transition_offset(const Scene *scene, const Strip *strip, SeqRetimingKey *start_key, float offset)
bool retiming_is_allowed(const Strip *strip)
static void strip_retiming_segment_as_line_segment(const SeqRetimingKey *start_key, double r_v1[2], double r_v2[2])
void retiming_transition_key_frame_set(const Scene *scene, const Strip *strip, SeqRetimingKey *key, const int timeline_frame)
static float strip_retiming_segment_step_get(const SeqRetimingKey *start_key)
void transform_handle_overlap(Scene *scene, ListBase *seqbasep, blender::Span< Strip * > transformed_strips, bool use_sync_markers)
ListBase * active_seqbase_get(const Editing *ed)
static int strip_retiming_clamp_timeline_frame(const Scene *scene, Strip *strip, SeqRetimingKey *key, const int timeline_frame)
static void strip_retiming_fix_transition(const Scene *scene, Strip *strip, SeqRetimingKey *key)
SeqRetimingKey * retiming_last_key_get(const Strip *strip)
void retiming_selection_append(SeqRetimingKey *key)
SeqRetimingKey * retiming_add_key(const Scene *scene, Strip *strip, const int timeline_frame)
bool retiming_is_last_key(const Strip *strip, const SeqRetimingKey *key)
static void strip_retiming_fix_transitions(const Scene *scene, Strip *strip, SeqRetimingKey *key)
float strip_retiming_evaluate(const Strip *strip, const float frame_index)
static RetimingRangeData strip_retiming_range_data_get(const Scene *scene, const Strip *strip)
static std::pair< SeqRetimingKey *, SeqRetimingKey * > freeze_key_pair_create(const Scene *scene, Strip *strip, SeqRetimingKey *key, const int offset)
static void strip_retiming_cleanup_freeze_frame(SeqRetimingKey *key)
static int content_frame_index_get(const Scene *scene, const Strip *strip, const int timeline_frame)
VecBase< double, 2 > double2
double original_strip_frame_index
float original_retiming_factor
struct SeqRetimingKey * retiming_keys