Cleanup: VSE code readability

Add function `SEQ_time_content_end_frame_get` to get content end frame.
New function is shorthand for
`SEQ_time_start_frame_get() + SEQ_time_strip_length_get()`.
This commit is contained in:
Richard Antalik 2022-10-04 19:50:13 +02:00
parent d981418c8c
commit 76043bc3d6
7 changed files with 30 additions and 25 deletions

View File

@ -963,8 +963,7 @@ static void draw_sequence_extensions_overlay(
UI_GetColorPtrShade3ubv(col, blend_col, 10);
const float strip_content_start = SEQ_time_start_frame_get(seq);
const float strip_content_end = SEQ_time_start_frame_get(seq) +
SEQ_time_strip_length_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);
@ -1095,8 +1094,7 @@ static void draw_seq_background(Scene *scene,
}
if (SEQ_time_has_right_still_frames(scene, seq)) {
float right_handle_frame = SEQ_time_right_handle_frame_get(scene, seq);
const float content_end = SEQ_time_start_frame_get(seq) +
SEQ_time_strip_length_get(scene, seq);
const float content_end = SEQ_time_content_end_frame_get(scene, seq);
immRectf(pos, content_end, y1, right_handle_frame, y2);
}
}
@ -1317,8 +1315,7 @@ static void draw_seq_strip(const bContext *C,
x1 = SEQ_time_has_left_still_frames(scene, seq) ? SEQ_time_start_frame_get(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_start_frame_get(seq) + SEQ_time_strip_length_get(scene, seq) :
x2 = SEQ_time_has_right_still_frames(scene, seq) ? SEQ_time_content_end_frame_get(scene, seq) :
SEQ_time_right_handle_frame_get(scene, seq);
y2 = seq->machine + SEQ_STRIP_OFSTOP;
@ -2290,7 +2287,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *region)
continue;
}
if (max_ii(SEQ_time_right_handle_frame_get(scene, seq),
SEQ_time_start_frame_get(seq) + SEQ_time_strip_length_get(scene, seq)) <
SEQ_time_content_end_frame_get(scene, seq)) <
v2d->cur.xmin) {
continue;
}

View File

@ -74,10 +74,11 @@ 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->start) > view_area->xmax) {
if (min_ii(SEQ_time_left_handle_frame_get(scene, seq), SEQ_time_start_frame_get(seq)) >
view_area->xmax) {
return false;
}
if (max_ii(SEQ_time_right_handle_frame_get(scene, seq), seq->start + seq->len) <
if (max_ii(SEQ_time_right_handle_frame_get(scene, seq), SEQ_time_content_end_frame_get(scene, seq)) <
view_area->xmin) {
return false;
}

View File

@ -203,8 +203,10 @@ static void seq_snap_target_points_build(Scene *scene,
i += 2;
if (snap_mode & SEQ_SNAP_TO_STRIP_HOLD) {
int content_start = min_ii(SEQ_time_right_handle_frame_get(scene, seq), seq->start);
int content_end = max_ii(SEQ_time_left_handle_frame_get(scene, seq), seq->start + seq->len);
int content_start = min_ii(SEQ_time_left_handle_frame_get(scene, seq),
SEQ_time_start_frame_get(seq));
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) {
content_start = SEQ_time_left_handle_frame_get(scene, seq);

View File

@ -74,6 +74,7 @@ void SEQ_time_speed_factor_set(const struct Scene *scene,
struct Sequence *seq,
const float speed_factor);
float SEQ_time_start_frame_get(const struct Sequence *seq);
float SEQ_time_content_end_frame_get(const struct Scene *scene, const struct Sequence *seq);
void SEQ_time_start_frame_set(const struct Scene *scene, struct Sequence *seq, int timeline_frame);
void SEQ_time_update_meta_strip_range(const struct Scene *scene, struct Sequence *seq_meta);

View File

@ -2103,7 +2103,7 @@ void SEQ_render_thumbnails(const SeqRenderData *context,
/* Adding the hold offset value (seq->anim_startofs) to the start frame. Position of image not
* affected, but frame loaded affected. */
float upper_thumb_bound = SEQ_time_has_right_still_frames(scene, seq) ?
(seq->start + seq->len) :
SEQ_time_content_end_frame_get(scene, seq) :
SEQ_time_right_handle_frame_get(scene, seq);
upper_thumb_bound = (upper_thumb_bound > view_area->xmax) ? view_area->xmax + frame_step :
upper_thumb_bound;
@ -2137,9 +2137,10 @@ 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->start);
const int content_start = max_ii(SEQ_time_left_handle_frame_get(scene, seq),
SEQ_time_start_frame_get(seq));
const int content_end = min_ii(SEQ_time_right_handle_frame_get(scene, seq),
seq->start + seq->len);
SEQ_time_content_end_frame_get(scene, seq));
const int content_len = content_end - content_start;
/* Arbitrary, but due to performance reasons should be as low as possible. */

View File

@ -260,8 +260,8 @@ bool SEQ_edit_move_strip_to_meta(Scene *scene,
static void seq_split_set_right_hold_offset(Scene *scene, Sequence *seq, int timeline_frame)
{
const float content_start = seq->start;
const float content_end = seq->start + SEQ_time_strip_length_get(scene, seq);
const float content_start = SEQ_time_start_frame_get(seq);
const float content_end = SEQ_time_content_end_frame_get(scene, seq);
/* Adjust within range of extended still-frames before strip. */
if (timeline_frame < content_start) {
@ -283,8 +283,8 @@ static void seq_split_set_right_hold_offset(Scene *scene, Sequence *seq, int tim
static void seq_split_set_left_hold_offset(Scene *scene, Sequence *seq, int timeline_frame)
{
const float content_start = seq->start;
const float content_end = seq->start + SEQ_time_strip_length_get(scene, seq);
const float content_start = SEQ_time_start_frame_get(seq);
const float content_end = SEQ_time_content_end_frame_get(scene, seq);
/* Adjust within range of extended still-frames before strip. */
if (timeline_frame < content_start) {

View File

@ -53,7 +53,7 @@ float seq_give_frame_index(const Scene *scene, Sequence *seq, float timeline_fra
{
float frame_index;
float sta = SEQ_time_start_frame_get(seq);
float end = SEQ_time_start_frame_get(seq) + SEQ_time_strip_length_get(scene, seq) - 1;
float end = SEQ_time_content_end_frame_get(scene, seq) - 1;
if (seq->type & SEQ_TYPE_EFFECT) {
end = SEQ_time_right_handle_frame_get(scene, seq);
@ -470,8 +470,7 @@ bool SEQ_time_has_left_still_frames(const Scene *scene, const Sequence *seq)
bool SEQ_time_has_right_still_frames(const Scene *scene, const Sequence *seq)
{
return SEQ_time_right_handle_frame_get(scene, seq) >
SEQ_time_start_frame_get(seq) + SEQ_time_strip_length_get(scene, seq);
return SEQ_time_right_handle_frame_get(scene, seq) > SEQ_time_content_end_frame_get(scene, seq);
}
bool SEQ_time_has_still_frames(const Scene *scene, const Sequence *seq)
@ -503,6 +502,11 @@ void SEQ_time_start_frame_set(const Scene *scene, Sequence *seq, int timeline_fr
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);
}
int SEQ_time_left_handle_frame_get(const Scene *UNUSED(scene), const Sequence *seq)
{
if (seq->seq1 || seq->seq2) {
@ -518,7 +522,7 @@ int SEQ_time_right_handle_frame_get(const Scene *scene, const Sequence *seq)
return seq->enddisp;
}
return seq->start + SEQ_time_strip_length_get(scene, seq) - seq->endofs;
return SEQ_time_content_end_frame_get(scene, seq) - seq->endofs;
}
void SEQ_time_left_handle_frame_set(const Scene *scene, Sequence *seq, int val)
@ -529,7 +533,7 @@ void SEQ_time_left_handle_frame_set(const Scene *scene, Sequence *seq, int val)
val = right_handle_orig_frame - 1;
}
seq->startofs = val - seq->start;
seq->startofs = val - SEQ_time_start_frame_get(seq);
seq->startdisp = val; /* Only to make files usable in older versions. */
SEQ_time_update_meta_strip_range(scene, seq_sequence_lookup_meta_by_seq(scene, seq));
@ -538,14 +542,13 @@ void SEQ_time_left_handle_frame_set(const Scene *scene, Sequence *seq, int val)
void SEQ_time_right_handle_frame_set(const Scene *scene, Sequence *seq, int val)
{
const float strip_content_end_frame = seq->start + SEQ_time_strip_length_get(scene, seq);
const float left_handle_orig_frame = SEQ_time_left_handle_frame_get(scene, seq);
if (val <= left_handle_orig_frame) {
val = left_handle_orig_frame + 1;
}
seq->endofs = strip_content_end_frame - val;
seq->endofs = SEQ_time_content_end_frame_get(scene, seq) - val;
seq->enddisp = val; /* Only to make files usable in older versions. */
SEQ_time_update_meta_strip_range(scene, seq_sequence_lookup_meta_by_seq(scene, seq));