WIP: VSE: Use seconds for strip length and position #105620

Draft
Richard Antalik wants to merge 13 commits from iss/blender:time-in-seconds into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
4 changed files with 19 additions and 9 deletions
Showing only changes of commit 8ba6379033 - Show all commits

View File

@ -66,7 +66,7 @@ struct ListBase *SEQ_active_seqbase_get(const struct Editing *ed);
* \param seqbase: ListBase with strips
*/
void SEQ_seqbase_active_set(struct Editing *ed, struct ListBase *seqbase);
struct Sequence *SEQ_sequence_alloc(ListBase *lb, int timeline_frame, int machine, int type);
struct Sequence *SEQ_sequence_alloc(ListBase *lb, double start_time, int machine, int type);
void SEQ_sequence_free(struct Scene *scene, struct Sequence *seq);
/**
* Get #MetaStack that corresponds to current level that is being viewed

View File

@ -112,7 +112,7 @@ static void seq_free_strip(Strip *strip)
MEM_freeN(strip);
}
Sequence *SEQ_sequence_alloc(ListBase *lb, int timeline_frame, int machine, int type)
Sequence *SEQ_sequence_alloc(ListBase *lb, double start_time, int machine, int type)
{
Sequence *seq;
@ -123,7 +123,7 @@ Sequence *SEQ_sequence_alloc(ListBase *lb, int timeline_frame, int machine, int
seq->name[2] = 0;
seq->flag = SELECT;
seq->start = timeline_frame;
seq->start = start_time;
seq->machine = machine;
seq->sat = 1.0;
seq->mul = 1.0;

View File

@ -160,8 +160,10 @@ Sequence *SEQ_add_mask_strip(Scene *scene, ListBase *seqbase, struct SeqLoadData
Sequence *SEQ_add_effect_strip(Scene *scene, ListBase *seqbase, struct SeqLoadData *load_data)
{
Sequence *seq = SEQ_sequence_alloc(
seqbase, load_data->start_frame, load_data->channel, load_data->effect.type);
Sequence *seq = SEQ_sequence_alloc(seqbase,
SEQ_time_frames_to_seconds(scene, load_data->start_frame),
load_data->channel,
load_data->effect.type);
seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE;
struct SeqEffectHandle sh = SEQ_effect_handle_get(seq);
@ -175,7 +177,7 @@ Sequence *SEQ_add_effect_strip(Scene *scene, ListBase *seqbase, struct SeqLoadDa
}
if (!load_data->effect.seq1) {
SEQ_time_strip_length_set(scene, seq, 0); /* XXX Effect is generator, set non zero length. */
SEQ_time_strip_length_set(scene, seq, 0);
seq->flag |= SEQ_SINGLE_FRAME_CONTENT;
SEQ_time_right_handle_frame_set(scene, seq, load_data->effect.end_frame);
}

View File

@ -571,13 +571,13 @@ void SEQ_time_left_handle_frame_set(const Scene *scene, Sequence *seq, int timel
timeline_frame = right_handle_orig_frame - 1;
}
float offset = timeline_frame - SEQ_time_start_frame_get(scene, seq);
float offset = SEQ_time_frames_to_seconds(scene, timeline_frame) - seq->start;
if (SEQ_transform_single_image_check(seq)) {
/* This strip has only 1 frame of content, that is always stretched to whole strip length.
* Therefore, strip start should be moved instead of adjusting offset. */
SEQ_time_start_frame_set(scene, seq, timeline_frame);
seq->endofs += offset;
seq->len -= offset;
}
else {
seq->startofs = offset;
@ -597,7 +597,15 @@ void SEQ_time_right_handle_frame_set(const Scene *scene, Sequence *seq, int time
timeline_frame = left_handle_orig_frame + 1;
}
seq->endofs = SEQ_time_content_end_frame_get(scene, seq) - timeline_frame;
if (SEQ_transform_single_image_check(seq)) {
double strip_end_time = seq->start + seq->len;
double time = SEQ_time_frames_to_seconds(scene, timeline_frame);
seq->len += time - strip_end_time;
}
else {
seq->endofs = seq->start + seq->len - SEQ_time_frames_to_seconds(scene, timeline_frame);
}
seq->enddisp = timeline_frame; /* Only to make files usable in older versions. */
SEQ_time_update_meta_strip_range(scene, seq_sequence_lookup_meta_by_seq(scene, seq));