Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorRichard Antalik <richardantalik@gmail.com>2021-06-02 22:41:38 +0300
committerRichard Antalik <richardantalik@gmail.com>2021-06-02 22:41:38 +0300
commit925df8ef26a353497c8088657a82b6b8545c67c1 (patch)
tree83dcc1f9fadaff90a3b7729b915bedfcda52a67d /source
parent2ee575fc1f2b13f083bc5996e20e7350570be546 (diff)
VSE: Add strip-time intersection test function
Use SEQ_time_strip_intersects_frame function to test if strip intersects with frame. Note: There are cases where this function should not be used. For example splitting strips require at least 1 frame "inside" strip. Another example is drawing, where playhead technically doesn't intersect strip, but it is rendered, because current frame has "duration" or "thickness" of 1 frame. Reviewed By: sergey Differential Revision: https://developer.blender.org/D11320
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c3
-rw-r--r--source/blender/sequencer/SEQ_time.h1
-rw-r--r--source/blender/sequencer/intern/render.c3
-rw-r--r--source/blender/sequencer/intern/strip_relations.c4
-rw-r--r--source/blender/sequencer/intern/strip_time.c16
-rw-r--r--source/blender/sequencer/intern/utils.c3
6 files changed, 24 insertions, 6 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index 867b8e3d40a..7e515271b13 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -42,6 +42,7 @@
#include "SEQ_iterator.h"
#include "SEQ_select.h"
#include "SEQ_sequencer.h"
+#include "SEQ_time.h"
#include "SEQ_transform.h"
/* For menu, popup, icons, etc. */
@@ -1187,7 +1188,7 @@ static int sequencer_select_side_of_frame_exec(bContext *C, wmOperator *op)
test = (timeline_frame <= seq->startdisp);
break;
case 2:
- test = (timeline_frame <= seq->enddisp) && (timeline_frame >= seq->startdisp);
+ test = SEQ_time_strip_intersects_frame(seq, timeline_frame);
break;
}
diff --git a/source/blender/sequencer/SEQ_time.h b/source/blender/sequencer/SEQ_time.h
index 31549ff3994..2a875370830 100644
--- a/source/blender/sequencer/SEQ_time.h
+++ b/source/blender/sequencer/SEQ_time.h
@@ -45,6 +45,7 @@ int SEQ_time_find_next_prev_edit(struct Scene *scene,
void SEQ_time_update_sequence(struct Scene *scene, struct Sequence *seq);
void SEQ_time_update_sequence_bounds(struct Scene *scene, struct Sequence *seq);
int SEQ_time_cmp_time_startdisp(const void *a, const void *b);
+bool SEQ_time_strip_intersects_frame(struct Sequence *seq, const int timeline_frame);
#ifdef __cplusplus
}
diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c
index 8ed769880a4..4b8df111f07 100644
--- a/source/blender/sequencer/intern/render.c
+++ b/source/blender/sequencer/intern/render.c
@@ -70,6 +70,7 @@
#include "SEQ_proxy.h"
#include "SEQ_render.h"
#include "SEQ_sequencer.h"
+#include "SEQ_time.h"
#include "SEQ_utils.h"
#include "effects.h"
@@ -309,7 +310,7 @@ static SeqCollection *query_strips_at_frame(ListBase *seqbase, const int timelin
SeqCollection *collection = SEQ_collection_create();
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
- if ((seq->startdisp <= timeline_frame) && (seq->enddisp > timeline_frame)) {
+ if (SEQ_time_strip_intersects_frame(seq, timeline_frame)) {
SEQ_collection_append_strip(seq, collection);
}
}
diff --git a/source/blender/sequencer/intern/strip_relations.c b/source/blender/sequencer/intern/strip_relations.c
index 1215cb78b56..7c5a3f031db 100644
--- a/source/blender/sequencer/intern/strip_relations.c
+++ b/source/blender/sequencer/intern/strip_relations.c
@@ -259,7 +259,7 @@ void SEQ_relations_free_imbuf(Scene *scene, ListBase *seqbase, bool for_render)
SEQ_prefetch_stop(scene);
for (seq = seqbase->first; seq; seq = seq->next) {
- if (for_render && CFRA >= seq->startdisp && CFRA <= seq->enddisp) {
+ if (for_render && SEQ_time_strip_intersects_frame(seq, CFRA)) {
continue;
}
@@ -358,7 +358,7 @@ void SEQ_relations_update_changed_seq_and_deps(Scene *scene,
static void sequencer_all_free_anim_ibufs(ListBase *seqbase, int timeline_frame)
{
for (Sequence *seq = seqbase->first; seq != NULL; seq = seq->next) {
- if (seq->enddisp < timeline_frame || seq->startdisp > timeline_frame) {
+ if (!SEQ_time_strip_intersects_frame(seq, timeline_frame)) {
SEQ_relations_sequence_free_anim(seq);
}
if (seq->type == SEQ_TYPE_META) {
diff --git a/source/blender/sequencer/intern/strip_time.c b/source/blender/sequencer/intern/strip_time.c
index 40d7fade308..e64550f1428 100644
--- a/source/blender/sequencer/intern/strip_time.c
+++ b/source/blender/sequencer/intern/strip_time.c
@@ -409,7 +409,7 @@ static bool strip_exists_at_frame(SeqCollection *all_strips, const int timeline_
{
Sequence *seq;
SEQ_ITERATOR_FOREACH (seq, all_strips) {
- if ((seq->startdisp <= timeline_frame) && (seq->enddisp > timeline_frame)) {
+ if (SEQ_time_strip_intersects_frame(seq, timeline_frame)) {
return true;
}
}
@@ -468,3 +468,17 @@ void seq_time_gap_info_get(const Scene *scene,
}
}
}
+
+/**
+ * Test if strip intersects with timeline frame.
+ * Note: This checks if strip would be rendered at this frame. For rendering it is assumed, that
+ * timeline frame has width of 1 frame and therefore ends at timeline_frame + 1
+ *
+ * \param seq: Sequence to be checked
+ * \param timeline_frame: absolute frame position
+ * \return true if strip intersects with timeline frame.
+ */
+bool SEQ_time_strip_intersects_frame(Sequence *seq, const int timeline_frame)
+{
+ return (seq->startdisp <= timeline_frame) && (seq->enddisp > timeline_frame);
+}
diff --git a/source/blender/sequencer/intern/utils.c b/source/blender/sequencer/intern/utils.c
index cf1d7d66476..9aeb2961751 100644
--- a/source/blender/sequencer/intern/utils.c
+++ b/source/blender/sequencer/intern/utils.c
@@ -43,6 +43,7 @@
#include "SEQ_relations.h"
#include "SEQ_select.h"
#include "SEQ_sequencer.h"
+#include "SEQ_time.h"
#include "SEQ_utils.h"
#include "IMB_imbuf.h"
@@ -406,7 +407,7 @@ const Sequence *SEQ_get_topmost_sequence(const Scene *scene, int frame)
}
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
- if (seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame) {
+ if (seq->flag & SEQ_MUTE || !SEQ_time_strip_intersects_frame(seq, frame)) {
continue;
}
/* Only use strips that generate an image, not ones that combine