WIP: VSE: Use seconds for strip length and position #105620
|
@ -542,7 +542,7 @@ static void drawmeta_contents(Scene *scene,
|
|||
ListBase *meta_channels;
|
||||
int offset;
|
||||
|
||||
meta_seqbase = SEQ_get_seqbase_from_sequence(seqm, &meta_channels, &offset);
|
||||
meta_seqbase = SEQ_get_seqbase_from_sequence(scene, seqm, &meta_channels, &offset);
|
||||
|
||||
if (!meta_seqbase || BLI_listbase_is_empty(meta_seqbase)) {
|
||||
return;
|
||||
|
@ -961,7 +961,7 @@ static void draw_sequence_extensions_overlay(
|
|||
col[3] = SEQ_render_is_muted(channels, seq) ? MUTE_ALPHA : 200;
|
||||
UI_GetColorPtrShade3ubv(col, blend_col, 10);
|
||||
|
||||
const float strip_content_start = SEQ_time_start_frame_get(seq);
|
||||
const float strip_content_start = SEQ_time_start_frame_get(scene, seq);
|
||||
const float strip_content_end = SEQ_time_content_end_frame_get(scene, seq);
|
||||
float right_handle_frame = SEQ_time_right_handle_frame_get(scene, seq);
|
||||
float left_handle_frame = SEQ_time_left_handle_frame_get(scene, seq);
|
||||
|
@ -1089,7 +1089,7 @@ static void draw_seq_background(Scene *scene,
|
|||
|
||||
if (SEQ_time_has_left_still_frames(scene, seq)) {
|
||||
float left_handle_frame = SEQ_time_left_handle_frame_get(scene, seq);
|
||||
const float content_start = SEQ_time_start_frame_get(seq);
|
||||
const float content_start = SEQ_time_start_frame_get(scene, seq);
|
||||
immRectf(pos, left_handle_frame, y1, content_start, y2);
|
||||
}
|
||||
if (SEQ_time_has_right_still_frames(scene, seq)) {
|
||||
|
@ -1312,7 +1312,7 @@ static void draw_seq_strip(const bContext *C,
|
|||
SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG);
|
||||
|
||||
/* Draw strip body. */
|
||||
x1 = SEQ_time_has_left_still_frames(scene, seq) ? SEQ_time_start_frame_get(seq) :
|
||||
x1 = SEQ_time_has_left_still_frames(scene, seq) ? SEQ_time_start_frame_get(scene, seq) :
|
||||
SEQ_time_left_handle_frame_get(scene, seq);
|
||||
y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
|
||||
x2 = SEQ_time_has_right_still_frames(scene, seq) ? SEQ_time_content_end_frame_get(scene, seq) :
|
||||
|
@ -2282,8 +2282,8 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region)
|
|||
if (seq == last_seq && (last_seq->flag & SELECT)) {
|
||||
continue;
|
||||
}
|
||||
if (min_ii(SEQ_time_left_handle_frame_get(scene, seq), SEQ_time_start_frame_get(seq)) >
|
||||
v2d->cur.xmax) {
|
||||
if (min_ii(SEQ_time_left_handle_frame_get(scene, seq),
|
||||
SEQ_time_start_frame_get(scene, seq)) > v2d->cur.xmax) {
|
||||
continue;
|
||||
}
|
||||
if (max_ii(SEQ_time_right_handle_frame_get(scene, seq),
|
||||
|
|
|
@ -77,11 +77,12 @@
|
|||
* \{ */
|
||||
|
||||
typedef struct TransSeq {
|
||||
int start, machine;
|
||||
int startofs, endofs;
|
||||
double start;
|
||||
int machine;
|
||||
double startofs, endofs;
|
||||
int anim_startofs, anim_endofs;
|
||||
/* int final_left, final_right; */ /* UNUSED */
|
||||
int len;
|
||||
double len;
|
||||
float content_start;
|
||||
} TransSeq;
|
||||
|
||||
|
@ -475,7 +476,7 @@ typedef struct SlipData {
|
|||
|
||||
static void transseq_backup(TransSeq *ts, Sequence *seq)
|
||||
{
|
||||
ts->content_start = SEQ_time_start_frame_get(seq);
|
||||
// ts->content_start = SEQ_time_start_frame_get(seq); //XXX
|
||||
ts->start = seq->start;
|
||||
ts->machine = seq->machine;
|
||||
ts->startofs = seq->startofs;
|
||||
|
@ -3592,7 +3593,7 @@ static int sequencer_scene_frame_range_update_exec(bContext *C, wmOperator *UNUS
|
|||
|
||||
Scene *target_scene = seq->scene;
|
||||
|
||||
seq->len = target_scene->r.efra - target_scene->r.sfra + 1;
|
||||
SEQ_time_strip_length_set(scene, seq, target_scene->r.efra - target_scene->r.sfra + 1);
|
||||
SEQ_time_left_handle_frame_set(scene, seq, old_start);
|
||||
SEQ_time_right_handle_frame_set(scene, seq, old_end);
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ static bool check_seq_need_thumbnails(const Scene *scene, Sequence *seq, rctf *v
|
|||
if (!ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE)) {
|
||||
return false;
|
||||
}
|
||||
if (min_ii(SEQ_time_left_handle_frame_get(scene, seq), SEQ_time_start_frame_get(seq)) >
|
||||
if (min_ii(SEQ_time_left_handle_frame_get(scene, seq), SEQ_time_start_frame_get(scene, seq)) >
|
||||
view_area->xmax) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -180,7 +180,8 @@ static TransData *SeqToTransData(Scene *scene,
|
|||
* tdsq->start_offset is used when flushing the tx data back */
|
||||
start_left = SEQ_time_left_handle_frame_get(scene, seq);
|
||||
td2d->loc[0] = start_left;
|
||||
tdsq->start_offset = start_left - seq->start; /* use to apply the original location */
|
||||
tdsq->start_offset = start_left - SEQ_time_start_frame_get(
|
||||
scene, seq); /* use to apply the original location */
|
||||
break;
|
||||
case SEQ_LEFTSEL:
|
||||
start_left = SEQ_time_left_handle_frame_get(scene, seq);
|
||||
|
@ -602,7 +603,7 @@ static void flushTransSeq(TransInfo *t)
|
|||
switch (tdsq->sel_flag) {
|
||||
case SELECT: {
|
||||
if (SEQ_transform_sequence_can_be_translated(seq)) {
|
||||
offset = new_frame - tdsq->start_offset - seq->start;
|
||||
offset = new_frame - tdsq->start_offset - SEQ_time_start_frame_get(scene, seq);
|
||||
SEQ_transform_translate_sequence(scene, seq, offset);
|
||||
if (abs(offset) > abs(max_offset)) {
|
||||
max_offset = offset;
|
||||
|
|
|
@ -208,7 +208,8 @@ static void seq_snap_target_points_build(Scene *scene,
|
|||
int content_end = max_ii(SEQ_time_right_handle_frame_get(scene, seq),
|
||||
SEQ_time_content_end_frame_get(scene, seq));
|
||||
/* Effects and single image strips produce incorrect content length. Skip these strips. */
|
||||
if ((seq->type & SEQ_TYPE_EFFECT) != 0 || seq->len == 1) {
|
||||
if ((seq->type & SEQ_TYPE_EFFECT) != 0 ||
|
||||
seq->len == 1) { // XXX - this has to have some flag. it can't rely on precise length.
|
||||
content_start = SEQ_time_left_handle_frame_get(scene, seq);
|
||||
content_end = SEQ_time_right_handle_frame_get(scene, seq);
|
||||
}
|
||||
|
|
|
@ -152,17 +152,17 @@ typedef struct Sequence {
|
|||
/** Flags bitmap (see below) and the type of sequence. */
|
||||
int flag, type;
|
||||
/** The length of the contents of this strip - before handles are applied. */
|
||||
int len;
|
||||
double len;
|
||||
/**
|
||||
* Start frame of contents of strip in absolute frame coordinates.
|
||||
* For metastrips start of first strip startdisp.
|
||||
*/
|
||||
float start;
|
||||
double start;
|
||||
/**
|
||||
* Frames after the first frame where display starts,
|
||||
* frames before the last frame where display ends.
|
||||
*/
|
||||
float startofs, endofs;
|
||||
double startofs, endofs;
|
||||
/**
|
||||
* Frames that use the first frame before data begins,
|
||||
* frames that use the last frame after data ends.
|
||||
|
|
|
@ -345,7 +345,7 @@ static int rna_Sequence_retiming_handle_frame_get(PointerRNA *ptr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return SEQ_time_start_frame_get(seq) + handle->strip_frame_index;
|
||||
return SEQ_time_start_frame_get(scene, seq) + handle->strip_frame_index;
|
||||
}
|
||||
|
||||
static void rna_Sequence_retiming_handle_frame_set(PointerRNA *ptr, int value)
|
||||
|
@ -358,7 +358,7 @@ static void rna_Sequence_retiming_handle_frame_set(PointerRNA *ptr, int value)
|
|||
return;
|
||||
}
|
||||
|
||||
const int offset = value - SEQ_time_start_frame_get(seq) + handle->strip_frame_index;
|
||||
const int offset = value - SEQ_time_start_frame_get(scene, seq) + handle->strip_frame_index;
|
||||
SEQ_retiming_offset_handle(scene, seq, handle, offset);
|
||||
SEQ_relations_invalidate_cache_raw(scene, seq);
|
||||
}
|
||||
|
@ -2095,6 +2095,7 @@ static void rna_def_sequence(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Lock", "Lock strip so that it cannot be transformed");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
|
||||
|
||||
# if 0
|
||||
/* strip positioning */
|
||||
/* Cache has to be invalidated before and after transformation. */
|
||||
prop = RNA_def_property(srna, "frame_final_duration", PROP_INT, PROP_TIME);
|
||||
|
@ -2120,7 +2121,7 @@ static void rna_def_sequence(BlenderRNA *brna)
|
|||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_ui_text(prop, "Start Frame", "X position where the strip begins");
|
||||
RNA_def_property_ui_range(prop, MINFRAME, MAXFRAME, 3, 0);
|
||||
RNA_def_property_float_funcs(
|
||||
/* RNA_def_property_float_funcs(
|
||||
prop, NULL, "rna_Sequence_start_frame_set", NULL); /* overlap tests and calc_seq_disp */
|
||||
RNA_def_property_editable_func(prop, "rna_Sequence_frame_editable");
|
||||
RNA_def_property_update(
|
||||
|
@ -2170,6 +2171,7 @@ static void rna_def_sequence(BlenderRNA *brna)
|
|||
RNA_def_property_float_funcs(
|
||||
prop, NULL, "rna_Sequence_frame_offset_end_set", "rna_Sequence_frame_offset_end_range");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_frame_change_update");
|
||||
# endif
|
||||
|
||||
prop = RNA_def_property(srna, "channel", PROP_INT, PROP_UNSIGNED);
|
||||
RNA_def_property_int_sdna(prop, NULL, "machine");
|
||||
|
|
|
@ -576,9 +576,9 @@ static StripElem *rna_SequenceElements_append(ID *id, Sequence *seq, const char
|
|||
|
||||
seq->strip->stripdata = se = MEM_reallocN(seq->strip->stripdata,
|
||||
sizeof(StripElem) * (seq->len + 1));
|
||||
se += seq->len;
|
||||
/* se += seq->len; // XXX get size of se before realloc...
|
||||
BLI_strncpy(se->name, filename, sizeof(se->name));
|
||||
seq->len++;
|
||||
seq->len++;*/
|
||||
|
||||
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene);
|
||||
|
||||
|
|
|
@ -111,6 +111,10 @@ void SEQ_time_right_handle_frame_set(const struct Scene *scene,
|
|||
* This can change depending on scene FPS or strip speed factor.
|
||||
*/
|
||||
int SEQ_time_strip_length_get(const struct Scene *scene, const struct Sequence *seq);
|
||||
void SEQ_time_strip_length_set(const struct Scene *scene,
|
||||
struct Sequence *seq,
|
||||
const double length_in_frames);
|
||||
|
||||
/**
|
||||
* Set strip playback speed.
|
||||
* Strip length is affected by changing speed factor.
|
||||
|
@ -121,7 +125,7 @@ void SEQ_time_speed_factor_set(const struct Scene *scene,
|
|||
/**
|
||||
* Get timeline frame where strip content starts.
|
||||
*/
|
||||
float SEQ_time_start_frame_get(const struct Sequence *seq);
|
||||
float SEQ_time_start_frame_get(const struct Scene *scene, const struct Sequence *seq);
|
||||
/**
|
||||
* Get timeline frame where strip content ends.
|
||||
*/
|
||||
|
@ -136,6 +140,9 @@ void SEQ_time_start_frame_set(const struct Scene *scene, struct Sequence *seq, i
|
|||
* \note this function is currently only used internally and in versioning code.
|
||||
*/
|
||||
void SEQ_time_update_meta_strip_range(const struct Scene *scene, struct Sequence *seq_meta);
|
||||
double SEQ_time_frames_to_seconds(const struct Scene *scene, const double frames);
|
||||
int SEQ_time_seconds_to_frames(const struct Scene *scene, const double seconds);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,8 @@ void SEQ_sequence_base_unique_name_recursive(struct Scene *scene,
|
|||
struct ListBase *seqbasep,
|
||||
struct Sequence *seq);
|
||||
const char *SEQ_sequence_give_name(struct Sequence *seq);
|
||||
struct ListBase *SEQ_get_seqbase_from_sequence(struct Sequence *seq,
|
||||
struct ListBase *SEQ_get_seqbase_from_sequence(const struct Scene *scene,
|
||||
struct Sequence *seq,
|
||||
struct ListBase **channels,
|
||||
int *r_offset);
|
||||
const struct Sequence *SEQ_get_topmost_sequence(const struct Scene *scene, int frame);
|
||||
|
|
|
@ -391,7 +391,7 @@ static void seq_disk_cache_delete_invalid_files(SeqDiskCache *disk_cache,
|
|||
if (cache_file->cache_type & invalidate_types) {
|
||||
if (STREQ(cache_dir, cache_file->dir)) {
|
||||
int timeline_frame_start = seq_cache_frame_index_to_timeline_frame(
|
||||
seq, cache_file->start_frame);
|
||||
scene, seq, cache_file->start_frame);
|
||||
if (timeline_frame_start > range_start && timeline_frame_start <= range_end) {
|
||||
seq_disk_cache_delete_file(disk_cache, cache_file);
|
||||
}
|
||||
|
|
|
@ -145,12 +145,12 @@ static float seq_cache_timeline_frame_to_frame_index(Scene *scene,
|
|||
return seq_give_frame_index(scene, seq, timeline_frame);
|
||||
}
|
||||
|
||||
return timeline_frame - SEQ_time_start_frame_get(seq);
|
||||
return timeline_frame - SEQ_time_start_frame_get(scene, seq);
|
||||
}
|
||||
|
||||
float seq_cache_frame_index_to_timeline_frame(Sequence *seq, float frame_index)
|
||||
float seq_cache_frame_index_to_timeline_frame(const Scene *scene, Sequence *seq, float frame_index)
|
||||
{
|
||||
return frame_index + SEQ_time_start_frame_get(seq);
|
||||
return frame_index + SEQ_time_start_frame_get(scene, seq);
|
||||
}
|
||||
|
||||
static SeqCache *seq_cache_get_from_scene(Scene *scene)
|
||||
|
|
|
@ -69,7 +69,9 @@ void seq_cache_cleanup_sequence(struct Scene *scene,
|
|||
bool force_seq_changed_range);
|
||||
void seq_cache_thumbnail_cleanup(Scene *scene, rctf *view_area);
|
||||
bool seq_cache_is_full(void);
|
||||
float seq_cache_frame_index_to_timeline_frame(struct Sequence *seq, float frame_index);
|
||||
float seq_cache_frame_index_to_timeline_frame(const struct Scene *scene,
|
||||
struct Sequence *seq,
|
||||
float frame_index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1625,7 +1625,7 @@ static ImBuf *do_render_strip_seqbase(const SeqRenderData *context,
|
|||
ListBase *channels = NULL;
|
||||
int offset;
|
||||
|
||||
seqbase = SEQ_get_seqbase_from_sequence(seq, &channels, &offset);
|
||||
seqbase = SEQ_get_seqbase_from_sequence(context->scene, seq, &channels, &offset);
|
||||
|
||||
if (seqbase && !BLI_listbase_is_empty(seqbase)) {
|
||||
|
||||
|
@ -2168,7 +2168,7 @@ void SEQ_render_thumbnails(const SeqRenderData *context,
|
|||
int SEQ_render_thumbnails_guaranteed_set_frame_step_get(const Scene *scene, const Sequence *seq)
|
||||
{
|
||||
const int content_start = max_ii(SEQ_time_left_handle_frame_get(scene, seq),
|
||||
SEQ_time_start_frame_get(seq));
|
||||
SEQ_time_start_frame_get(scene, seq));
|
||||
const int content_end = min_ii(SEQ_time_right_handle_frame_get(scene, seq),
|
||||
SEQ_time_content_end_frame_get(scene, seq));
|
||||
const int content_len = content_end - content_start;
|
||||
|
|
|
@ -127,7 +127,7 @@ Sequence *SEQ_add_scene_strip(Scene *scene, ListBase *seqbase, struct SeqLoadDat
|
|||
Sequence *seq = SEQ_sequence_alloc(
|
||||
seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_SCENE);
|
||||
seq->scene = load_data->scene;
|
||||
seq->len = load_data->scene->r.efra - load_data->scene->r.sfra + 1;
|
||||
SEQ_time_strip_length_set(scene, seq, load_data->scene->r.efra - load_data->scene->r.sfra + 1);
|
||||
id_us_ensure_real((ID *)load_data->scene);
|
||||
seq_add_set_name(scene, seq, load_data);
|
||||
seq_add_generic_update(scene, seq);
|
||||
|
@ -139,7 +139,7 @@ Sequence *SEQ_add_movieclip_strip(Scene *scene, ListBase *seqbase, struct SeqLoa
|
|||
Sequence *seq = SEQ_sequence_alloc(
|
||||
seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_MOVIECLIP);
|
||||
seq->clip = load_data->clip;
|
||||
seq->len = BKE_movieclip_get_duration(load_data->clip);
|
||||
SEQ_time_strip_length_set(scene, seq, BKE_movieclip_get_duration(load_data->clip));
|
||||
id_us_ensure_real((ID *)load_data->clip);
|
||||
seq_add_set_name(scene, seq, load_data);
|
||||
seq_add_generic_update(scene, seq);
|
||||
|
@ -151,7 +151,7 @@ Sequence *SEQ_add_mask_strip(Scene *scene, ListBase *seqbase, struct SeqLoadData
|
|||
Sequence *seq = SEQ_sequence_alloc(
|
||||
seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_MASK);
|
||||
seq->mask = load_data->mask;
|
||||
seq->len = BKE_mask_get_duration(load_data->mask);
|
||||
SEQ_time_strip_length_set(scene, seq, BKE_mask_get_duration(load_data->mask));
|
||||
id_us_ensure_real((ID *)load_data->mask);
|
||||
seq_add_set_name(scene, seq, load_data);
|
||||
seq_add_generic_update(scene, seq);
|
||||
|
@ -175,7 +175,7 @@ Sequence *SEQ_add_effect_strip(Scene *scene, ListBase *seqbase, struct SeqLoadDa
|
|||
}
|
||||
|
||||
if (!load_data->effect.seq1) {
|
||||
seq->len = 1; /* Effect is generator, set non zero length. */
|
||||
SEQ_time_strip_length_set(scene, seq, 0); /* XXX Effect is generator, set non zero length. */
|
||||
SEQ_time_right_handle_frame_set(scene, seq, load_data->effect.end_frame);
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ void SEQ_add_image_set_directory(Sequence *seq, char *path)
|
|||
void SEQ_add_image_load_file(Scene *scene, Sequence *seq, size_t strip_frame, char *filename)
|
||||
{
|
||||
StripElem *se = SEQ_render_give_stripelem(
|
||||
scene, seq, SEQ_time_start_frame_get(seq) + strip_frame);
|
||||
scene, seq, SEQ_time_start_frame_get(scene, seq) + strip_frame);
|
||||
BLI_strncpy(se->name, filename, sizeof(se->name));
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ Sequence *SEQ_add_image_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL
|
|||
{
|
||||
Sequence *seq = SEQ_sequence_alloc(
|
||||
seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_IMAGE);
|
||||
seq->len = load_data->image.len;
|
||||
SEQ_time_strip_length_set(scene, seq, load_data->image.len);
|
||||
Strip *strip = seq->strip;
|
||||
strip->stripdata = MEM_callocN(load_data->image.len * sizeof(StripElem), "stripelem");
|
||||
|
||||
|
@ -315,7 +315,7 @@ Sequence *SEQ_add_sound_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL
|
|||
* nearest frame as the audio track usually overshoots or undershoots the
|
||||
* end frame of the video by a little bit.
|
||||
* See #47135 for under shoot example. */
|
||||
seq->len = MAX2(1, round((info.length - sound->offset_time) * FPS));
|
||||
SEQ_time_strip_length_set(scene, seq, MAX2(1, round((info.length - sound->offset_time) * FPS)));
|
||||
|
||||
Strip *strip = seq->strip;
|
||||
/* We only need 1 element to store the filename. */
|
||||
|
@ -438,8 +438,10 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL
|
|||
load_data->r_video_stream_start = IMD_anim_get_offset(anim_arr[0]);
|
||||
}
|
||||
|
||||
Sequence *seq = SEQ_sequence_alloc(
|
||||
seqbase, load_data->start_frame, load_data->channel, SEQ_TYPE_MOVIE);
|
||||
Sequence *seq = SEQ_sequence_alloc(seqbase,
|
||||
SEQ_time_frames_to_seconds(scene, load_data->start_frame),
|
||||
load_data->channel,
|
||||
SEQ_TYPE_MOVIE);
|
||||
|
||||
/* Multiview settings. */
|
||||
if (load_data->use_multiview) {
|
||||
|
@ -462,7 +464,7 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL
|
|||
}
|
||||
|
||||
if (anim_arr[0] != NULL) {
|
||||
seq->len = IMB_anim_get_duration(anim_arr[0], IMB_TC_RECORD_RUN);
|
||||
SEQ_time_strip_length_set(scene, seq, IMB_anim_get_duration(anim_arr[0], IMB_TC_RECORD_RUN));
|
||||
|
||||
IMB_anim_load_metadata(anim_arr[0]);
|
||||
|
||||
|
@ -479,7 +481,7 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL
|
|||
}
|
||||
}
|
||||
|
||||
seq->len = MAX2(1, seq->len);
|
||||
seq->len = MAX2(SEQ_time_frames_to_seconds(scene, 1), seq->len); // XXX
|
||||
if (load_data->adjust_playback_rate) {
|
||||
seq->flag |= SEQ_AUTO_PLAYBACK_RATE;
|
||||
}
|
||||
|
@ -528,17 +530,17 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo
|
|||
prev_enddisp = SEQ_time_right_handle_frame_get(scene, seq);
|
||||
}
|
||||
|
||||
int length;
|
||||
switch (seq->type) {
|
||||
case SEQ_TYPE_IMAGE: {
|
||||
/* Hack? */
|
||||
size_t olen = MEM_allocN_len(seq->strip->stripdata) / sizeof(StripElem);
|
||||
|
||||
seq->len = olen;
|
||||
seq->len -= seq->anim_startofs;
|
||||
seq->len -= seq->anim_endofs;
|
||||
if (seq->len < 0) {
|
||||
seq->len = 0;
|
||||
length = olen - seq->anim_startofs - seq->anim_endofs;
|
||||
if (length < 0) {
|
||||
length = 0;
|
||||
}
|
||||
SEQ_time_strip_length_set(scene, seq, length);
|
||||
break;
|
||||
}
|
||||
case SEQ_TYPE_MOVIE: {
|
||||
|
@ -604,14 +606,15 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo
|
|||
|
||||
IMB_anim_load_metadata(sanim->anim);
|
||||
|
||||
seq->len = IMB_anim_get_duration(
|
||||
length = IMB_anim_get_duration(
|
||||
sanim->anim, seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN);
|
||||
|
||||
seq->len -= seq->anim_startofs;
|
||||
seq->len -= seq->anim_endofs;
|
||||
if (seq->len < 0) {
|
||||
seq->len = 0;
|
||||
length -= seq->anim_startofs;
|
||||
length -= seq->anim_endofs;
|
||||
if (length < 0) {
|
||||
length = 0;
|
||||
}
|
||||
SEQ_time_strip_length_set(scene, seq, length);
|
||||
break;
|
||||
}
|
||||
case SEQ_TYPE_MOVIECLIP:
|
||||
|
@ -619,48 +622,52 @@ void SEQ_add_reload_new_file(Main *bmain, Scene *scene, Sequence *seq, const boo
|
|||
return;
|
||||
}
|
||||
|
||||
seq->len = BKE_movieclip_get_duration(seq->clip);
|
||||
length = BKE_movieclip_get_duration(seq->clip);
|
||||
|
||||
seq->len -= seq->anim_startofs;
|
||||
seq->len -= seq->anim_endofs;
|
||||
if (seq->len < 0) {
|
||||
seq->len = 0;
|
||||
length -= seq->anim_startofs;
|
||||
length -= seq->anim_endofs;
|
||||
if (length < 0) {
|
||||
length = 0;
|
||||
}
|
||||
SEQ_time_strip_length_set(scene, seq, length);
|
||||
break;
|
||||
case SEQ_TYPE_MASK:
|
||||
if (seq->mask == NULL) {
|
||||
return;
|
||||
}
|
||||
seq->len = BKE_mask_get_duration(seq->mask);
|
||||
seq->len -= seq->anim_startofs;
|
||||
seq->len -= seq->anim_endofs;
|
||||
if (seq->len < 0) {
|
||||
seq->len = 0;
|
||||
length = BKE_mask_get_duration(seq->mask);
|
||||
length -= seq->anim_startofs;
|
||||
length -= seq->anim_endofs;
|
||||
if (length < 0) {
|
||||
length = 0;
|
||||
}
|
||||
SEQ_time_strip_length_set(scene, seq, length);
|
||||
break;
|
||||
case SEQ_TYPE_SOUND_RAM:
|
||||
#ifdef WITH_AUDASPACE
|
||||
if (!seq->sound) {
|
||||
return;
|
||||
}
|
||||
seq->len = ceil((double)BKE_sound_get_length(bmain, seq->sound) * FPS);
|
||||
seq->len -= seq->anim_startofs;
|
||||
seq->len -= seq->anim_endofs;
|
||||
if (seq->len < 0) {
|
||||
seq->len = 0;
|
||||
length = ceil((double)BKE_sound_get_length(bmain, seq->sound) * FPS);
|
||||
length -= seq->anim_startofs;
|
||||
length -= seq->anim_endofs;
|
||||
if (length < 0) {
|
||||
length = 0;
|
||||
}
|
||||
SEQ_time_strip_length_set(scene, seq, length);
|
||||
#else
|
||||
UNUSED_VARS(bmain);
|
||||
return;
|
||||
#endif
|
||||
break;
|
||||
case SEQ_TYPE_SCENE: {
|
||||
seq->len = (seq->scene) ? seq->scene->r.efra - seq->scene->r.sfra + 1 : 0;
|
||||
seq->len -= seq->anim_startofs;
|
||||
seq->len -= seq->anim_endofs;
|
||||
if (seq->len < 0) {
|
||||
seq->len = 0;
|
||||
length = (seq->scene) ? seq->scene->r.efra - seq->scene->r.sfra + 1 : 0;
|
||||
length -= seq->anim_startofs;
|
||||
length -= seq->anim_endofs;
|
||||
if (length < 0) {
|
||||
length = 0;
|
||||
}
|
||||
SEQ_time_strip_length_set(scene, seq, length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ static void seq_split_set_right_hold_offset(Main *bmain,
|
|||
Sequence *seq,
|
||||
int timeline_frame)
|
||||
{
|
||||
const float content_start = SEQ_time_start_frame_get(seq);
|
||||
const float content_start = SEQ_time_start_frame_get(scene, seq);
|
||||
const float content_end = SEQ_time_content_end_frame_get(scene, seq);
|
||||
|
||||
/* Adjust within range of extended still-frames before strip. */
|
||||
|
@ -289,7 +289,7 @@ static void seq_split_set_left_hold_offset(Main *bmain,
|
|||
Sequence *seq,
|
||||
int timeline_frame)
|
||||
{
|
||||
const float content_start = SEQ_time_start_frame_get(seq);
|
||||
const float content_start = SEQ_time_start_frame_get(scene, seq);
|
||||
const float content_end = SEQ_time_content_end_frame_get(scene, seq);
|
||||
|
||||
/* Adjust within range of strip contents. */
|
||||
|
|
|
@ -149,7 +149,7 @@ float seq_retiming_evaluate(const Scene *scene, const Sequence *seq, const int f
|
|||
|
||||
SeqRetimingHandle *SEQ_retiming_add_handle(Scene *scene, Sequence *seq, const int timeline_frame)
|
||||
{
|
||||
float frame_index = (timeline_frame - SEQ_time_start_frame_get(seq)) *
|
||||
float frame_index = (timeline_frame - SEQ_time_start_frame_get(scene, seq)) *
|
||||
seq_time_media_playback_rate_factor_get(scene, seq);
|
||||
float value = seq_retiming_evaluate(scene, seq, frame_index);
|
||||
|
||||
|
@ -251,6 +251,6 @@ float SEQ_retiming_handle_timeline_frame_get(const Scene *scene,
|
|||
const Sequence *seq,
|
||||
const SeqRetimingHandle *handle)
|
||||
{
|
||||
return SEQ_time_start_frame_get(seq) +
|
||||
return SEQ_time_start_frame_get(scene, seq) +
|
||||
handle->strip_frame_index / seq_time_media_playback_rate_factor_get(scene, seq);
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ int seq_time_strip_original_content_length_get(const Scene *scene, const Sequenc
|
|||
float seq_give_frame_index(const Scene *scene, Sequence *seq, float timeline_frame)
|
||||
{
|
||||
float frame_index;
|
||||
float sta = SEQ_time_start_frame_get(seq);
|
||||
float sta = SEQ_time_start_frame_get(scene, seq);
|
||||
float end = SEQ_time_content_end_frame_get(scene, seq) - 1;
|
||||
const float length = seq_time_strip_original_content_length_get(scene, seq);
|
||||
|
||||
|
@ -490,7 +490,7 @@ void SEQ_time_speed_factor_set(const Scene *scene, Sequence *seq, const float sp
|
|||
|
||||
bool SEQ_time_has_left_still_frames(const Scene *scene, const Sequence *seq)
|
||||
{
|
||||
return SEQ_time_left_handle_frame_get(scene, seq) < SEQ_time_start_frame_get(seq);
|
||||
return SEQ_time_left_handle_frame_get(scene, seq) < SEQ_time_start_frame_get(scene, seq);
|
||||
}
|
||||
|
||||
bool SEQ_time_has_right_still_frames(const Scene *scene, const Sequence *seq)
|
||||
|
@ -503,10 +503,15 @@ bool SEQ_time_has_still_frames(const Scene *scene, const Sequence *seq)
|
|||
return SEQ_time_has_right_still_frames(scene, seq) || SEQ_time_has_left_still_frames(scene, seq);
|
||||
}
|
||||
|
||||
void SEQ_time_strip_length_set(const Scene *scene, Sequence *seq, double length_in_frames)
|
||||
{
|
||||
seq->len = SEQ_time_frames_to_seconds(scene, length_in_frames);
|
||||
}
|
||||
|
||||
int SEQ_time_strip_length_get(const Scene *scene, const Sequence *seq)
|
||||
{
|
||||
if (seq->type == SEQ_TYPE_SOUND_RAM) {
|
||||
return seq->len;
|
||||
return SEQ_time_seconds_to_frames(scene, seq->len);
|
||||
}
|
||||
|
||||
if (SEQ_retiming_is_active(seq)) {
|
||||
|
@ -517,33 +522,35 @@ int SEQ_time_strip_length_get(const Scene *scene, const Sequence *seq)
|
|||
seq_time_media_playback_rate_factor_get(scene, seq);
|
||||
}
|
||||
|
||||
return seq->len / seq_time_media_playback_rate_factor_get(scene, seq);
|
||||
/* XXX it was seq->len / seq_time_media_playback_rate_factor_get(scene, seq) but now it doesn't
|
||||
* make sense, because playback rate factor does not influence length. */
|
||||
return SEQ_time_seconds_to_frames(scene, seq->len);
|
||||
}
|
||||
|
||||
float SEQ_time_start_frame_get(const Sequence *seq)
|
||||
float SEQ_time_start_frame_get(const Scene *scene, const Sequence *seq)
|
||||
{
|
||||
return seq->start;
|
||||
return SEQ_time_seconds_to_frames(scene, seq->start);
|
||||
}
|
||||
|
||||
void SEQ_time_start_frame_set(const Scene *scene, Sequence *seq, int timeline_frame)
|
||||
{
|
||||
seq->start = timeline_frame;
|
||||
seq->start = SEQ_time_frames_to_seconds(scene, timeline_frame);
|
||||
SEQ_time_update_meta_strip_range(scene, seq_sequence_lookup_meta_by_seq(scene, seq));
|
||||
seq_time_update_effects_strip_range(scene, seq_sequence_lookup_effects_by_seq(scene, seq));
|
||||
}
|
||||
|
||||
float SEQ_time_content_end_frame_get(const Scene *scene, const Sequence *seq)
|
||||
{
|
||||
return SEQ_time_start_frame_get(seq) + SEQ_time_strip_length_get(scene, seq);
|
||||
return SEQ_time_start_frame_get(scene, seq) + SEQ_time_strip_length_get(scene, seq);
|
||||
}
|
||||
|
||||
int SEQ_time_left_handle_frame_get(const Scene *UNUSED(scene), const Sequence *seq)
|
||||
int SEQ_time_left_handle_frame_get(const Scene *scene, const Sequence *seq)
|
||||
{
|
||||
if (seq->seq1 || seq->seq2) {
|
||||
return seq->startdisp;
|
||||
}
|
||||
|
||||
return seq->start + seq->startofs;
|
||||
return SEQ_time_start_frame_get(scene, seq) + SEQ_time_seconds_to_frames(scene, seq->startofs);
|
||||
}
|
||||
|
||||
int SEQ_time_right_handle_frame_get(const Scene *scene, const Sequence *seq)
|
||||
|
@ -552,7 +559,8 @@ int SEQ_time_right_handle_frame_get(const Scene *scene, const Sequence *seq)
|
|||
return seq->enddisp;
|
||||
}
|
||||
|
||||
return SEQ_time_content_end_frame_get(scene, seq) - seq->endofs;
|
||||
return SEQ_time_content_end_frame_get(scene, seq) -
|
||||
SEQ_time_seconds_to_frames(scene, seq->endofs);
|
||||
}
|
||||
|
||||
void SEQ_time_left_handle_frame_set(const Scene *scene, Sequence *seq, int timeline_frame)
|
||||
|
@ -563,7 +571,7 @@ 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(seq);
|
||||
float offset = timeline_frame - SEQ_time_start_frame_get(scene, seq);
|
||||
|
||||
if (SEQ_transform_single_image_check(seq)) {
|
||||
/* This strip has only 1 frame of content, that is always stretched to whole strip length.
|
||||
|
@ -606,3 +614,15 @@ void seq_time_translate_handles(const Scene *scene, Sequence *seq, const int off
|
|||
SEQ_time_update_meta_strip_range(scene, seq_sequence_lookup_meta_by_seq(scene, seq));
|
||||
seq_time_update_effects_strip_range(scene, seq_sequence_lookup_effects_by_seq(scene, seq));
|
||||
}
|
||||
|
||||
double SEQ_time_frames_to_seconds(const Scene *scene, double frames)
|
||||
{
|
||||
double scene_playback_rate = (float)scene->r.frs_sec / scene->r.frs_sec_base;
|
||||
return frames / scene_playback_rate;
|
||||
}
|
||||
|
||||
int SEQ_time_seconds_to_frames(const Scene *scene, double seconds)
|
||||
{
|
||||
double scene_playback_rate = (float)scene->r.frs_sec / scene->r.frs_sec_base;
|
||||
return round_db_to_int(seconds * scene_playback_rate);
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ void SEQ_transform_translate_sequence(Scene *evil_scene, Sequence *seq, int delt
|
|||
seq_time_translate_handles(evil_scene, seq, delta);
|
||||
}
|
||||
else if (seq->seq1 == NULL && seq->seq2 == NULL) { /* All other strip types. */
|
||||
seq->start += delta;
|
||||
seq->start += SEQ_time_frames_to_seconds(evil_scene, delta);
|
||||
/* Only to make files usable in older versions. */
|
||||
seq->startdisp = SEQ_time_left_handle_frame_get(evil_scene, seq);
|
||||
seq->enddisp = SEQ_time_right_handle_frame_get(evil_scene, seq);
|
||||
|
|
|
@ -179,7 +179,10 @@ const char *SEQ_sequence_give_name(Sequence *seq)
|
|||
return name;
|
||||
}
|
||||
|
||||
ListBase *SEQ_get_seqbase_from_sequence(Sequence *seq, ListBase **r_channels, int *r_offset)
|
||||
ListBase *SEQ_get_seqbase_from_sequence(const Scene *scene,
|
||||
Sequence *seq,
|
||||
ListBase **r_channels,
|
||||
int *r_offset)
|
||||
{
|
||||
ListBase *seqbase = NULL;
|
||||
|
||||
|
@ -187,7 +190,7 @@ ListBase *SEQ_get_seqbase_from_sequence(Sequence *seq, ListBase **r_channels, in
|
|||
case SEQ_TYPE_META: {
|
||||
seqbase = &seq->seqbase;
|
||||
*r_channels = &seq->channels;
|
||||
*r_offset = SEQ_time_start_frame_get(seq);
|
||||
*r_offset = SEQ_time_start_frame_get(scene, seq);
|
||||
break;
|
||||
}
|
||||
case SEQ_TYPE_SCENE: {
|
||||
|
|
Loading…
Reference in New Issue