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
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/sequencer/intern/strip_edit.c')
-rw-r--r--source/blender/sequencer/intern/strip_edit.c184
1 files changed, 80 insertions, 104 deletions
diff --git a/source/blender/sequencer/intern/strip_edit.c b/source/blender/sequencer/intern/strip_edit.c
index bd439e3c9f8..c35138b280a 100644
--- a/source/blender/sequencer/intern/strip_edit.c
+++ b/source/blender/sequencer/intern/strip_edit.c
@@ -37,32 +37,32 @@
#include "SEQ_transform.h"
#include "SEQ_utils.h"
-int SEQ_edit_sequence_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str)
+bool SEQ_edit_sequence_swap(Scene *scene, Sequence *seq_a, Sequence *seq_b, const char **error_str)
{
char name[sizeof(seq_a->name)];
- if (seq_a->len != seq_b->len) {
+ if (SEQ_time_strip_length_get(scene, seq_a) != SEQ_time_strip_length_get(scene, seq_b)) {
*error_str = N_("Strips must be the same length");
- return 0;
+ return false;
}
/* type checking, could be more advanced but disallow sound vs non-sound copy */
if (seq_a->type != seq_b->type) {
if (seq_a->type == SEQ_TYPE_SOUND_RAM || seq_b->type == SEQ_TYPE_SOUND_RAM) {
*error_str = N_("Strips were not compatible");
- return 0;
+ return false;
}
/* disallow effects to swap with non-effects strips */
if ((seq_a->type & SEQ_TYPE_EFFECT) != (seq_b->type & SEQ_TYPE_EFFECT)) {
*error_str = N_("Strips were not compatible");
- return 0;
+ return false;
}
if ((seq_a->type & SEQ_TYPE_EFFECT) && (seq_b->type & SEQ_TYPE_EFFECT)) {
if (SEQ_effect_get_num_inputs(seq_a->type) != SEQ_effect_get_num_inputs(seq_b->type)) {
*error_str = N_("Strips must have the same number of inputs");
- return 0;
+ return false;
}
}
}
@@ -80,34 +80,33 @@ int SEQ_edit_sequence_swap(Sequence *seq_a, Sequence *seq_b, const char **error_
SWAP(Sequence *, seq_a->prev, seq_b->prev);
SWAP(Sequence *, seq_a->next, seq_b->next);
- SWAP(int, seq_a->start, seq_b->start);
- SWAP(int, seq_a->startofs, seq_b->startofs);
- SWAP(int, seq_a->endofs, seq_b->endofs);
+ SWAP(float, seq_a->start, seq_b->start);
+ SWAP(float, seq_a->startofs, seq_b->startofs);
+ SWAP(float, seq_a->endofs, seq_b->endofs);
SWAP(int, seq_a->machine, seq_b->machine);
- seq_time_effect_range_set(seq_a);
- seq_time_effect_range_set(seq_b);
+ seq_time_effect_range_set(scene, seq_a);
+ seq_time_effect_range_set(scene, seq_b);
- return 1;
+ return true;
}
static void seq_update_muting_recursive(ListBase *channels,
ListBase *seqbasep,
Sequence *metaseq,
- int mute)
+ const bool mute)
{
Sequence *seq;
- int seqmute;
/* For sound we go over full meta tree to update muted state,
* since sound is played outside of evaluating the imbufs. */
for (seq = seqbasep->first; seq; seq = seq->next) {
- seqmute = (mute || SEQ_render_is_muted(channels, seq));
+ bool seqmute = (mute || SEQ_render_is_muted(channels, seq));
if (seq->type == SEQ_TYPE_META) {
/* if this is the current meta sequence, unmute because
* all sequences above this were set to mute */
if (seq == metaseq) {
- seqmute = 0;
+ seqmute = false;
}
seq_update_muting_recursive(&seq->channels, &seq->seqbase, metaseq, seqmute);
@@ -127,10 +126,10 @@ void SEQ_edit_update_muting(Editing *ed)
MetaStack *ms = ed->metastack.last;
if (ms) {
- seq_update_muting_recursive(&ed->channels, &ed->seqbase, ms->parseq, 1);
+ seq_update_muting_recursive(&ed->channels, &ed->seqbase, ms->parseq, true);
}
else {
- seq_update_muting_recursive(&ed->channels, &ed->seqbase, NULL, 0);
+ seq_update_muting_recursive(&ed->channels, &ed->seqbase, NULL, false);
}
}
}
@@ -192,19 +191,6 @@ void SEQ_edit_remove_flagged_sequences(Scene *scene, ListBase *seqbase)
}
}
-static bool seq_exists_in_seqbase(Sequence *seq, ListBase *seqbase)
-{
- LISTBASE_FOREACH (Sequence *, seq_test, seqbase) {
- if (seq_test->type == SEQ_TYPE_META && seq_exists_in_seqbase(seq, &seq_test->seqbase)) {
- return true;
- }
- if (seq_test == seq) {
- return true;
- }
- }
- return false;
-}
-
bool SEQ_edit_move_strip_to_seqbase(Scene *scene,
ListBase *seqbase,
Sequence *seq,
@@ -216,7 +202,7 @@ bool SEQ_edit_move_strip_to_seqbase(Scene *scene,
SEQ_relations_invalidate_cache_preprocessed(scene, seq);
/* Update meta. */
- if (SEQ_transform_test_overlap(dst_seqbase, seq)) {
+ if (SEQ_transform_test_overlap(scene, dst_seqbase, seq)) {
SEQ_transform_seqbase_shuffle(dst_seqbase, seq, scene);
}
@@ -247,19 +233,19 @@ bool SEQ_edit_move_strip_to_meta(Scene *scene,
return false;
}
- if (src_seq->type == SEQ_TYPE_META && seq_exists_in_seqbase(dst_seqm, &src_seq->seqbase)) {
+ if (src_seq->type == SEQ_TYPE_META && SEQ_exists_in_seqbase(dst_seqm, &src_seq->seqbase)) {
*error_str = N_("Moved strip is parent of provided meta strip");
return false;
}
- if (!seq_exists_in_seqbase(dst_seqm, &ed->seqbase)) {
+ if (!SEQ_exists_in_seqbase(dst_seqm, &ed->seqbase)) {
*error_str = N_("Can not move strip to different scene");
return false;
}
SeqCollection *collection = SEQ_collection_create(__func__);
SEQ_collection_append_strip(src_seq, collection);
- SEQ_collection_expand(seqbase, collection, SEQ_query_strip_effect_chain);
+ SEQ_collection_expand(scene, seqbase, collection, SEQ_query_strip_effect_chain);
Sequence *seq;
SEQ_ITERATOR_FOREACH (seq, collection) {
@@ -272,77 +258,58 @@ bool SEQ_edit_move_strip_to_meta(Scene *scene,
return true;
}
-static void seq_split_set_left_hold_offset(const Scene *scene, Sequence *seq, int timeline_frame)
-{
- /* Adjust within range of extended stillframes before strip. */
- if (timeline_frame < seq->start) {
- SEQ_time_left_handle_frame_set(scene, seq, timeline_frame);
- }
- /* Adjust within range of strip contents. */
- else if ((timeline_frame >= seq->start) && (timeline_frame <= (seq->start + seq->len))) {
- seq->anim_startofs += timeline_frame - seq->start;
- seq->start = timeline_frame;
- seq->startofs = 0;
- }
- /* Adjust within range of extended stillframes after strip. */
- else if ((seq->start + seq->len) < timeline_frame) {
- const int right_handle_backup = SEQ_time_right_handle_frame_get(seq);
- seq->start += timeline_frame - seq->start;
- seq->anim_startofs += seq->len - 1;
- seq->len = 1;
- SEQ_time_left_handle_frame_set(scene, seq, timeline_frame);
- SEQ_time_right_handle_frame_set(scene, seq, right_handle_backup);
- }
-}
-
-static void seq_split_set_right_hold_offset(const Scene *scene, Sequence *seq, int timeline_frame)
+static void seq_split_set_left_hold_offset(Scene *scene, Sequence *seq, int timeline_frame)
{
/* Adjust within range of extended stillframes before strip. */
if (timeline_frame < seq->start) {
- const int left_handle_backup = SEQ_time_left_handle_frame_get(seq);
seq->start = timeline_frame - 1;
- SEQ_time_left_handle_frame_set(scene, seq, left_handle_backup);
- SEQ_time_right_handle_frame_set(scene, seq, timeline_frame);
+ seq->anim_endofs += SEQ_time_strip_length_get(scene, seq) - 1;
+ seq->startstill = timeline_frame - seq->startdisp - 1;
+ seq->endstill = 0;
}
/* Adjust within range of strip contents. */
- else if ((timeline_frame >= seq->start) && (timeline_frame <= (seq->start + seq->len))) {
- seq->anim_endofs += seq->start + seq->len - timeline_frame;
+ else if ((timeline_frame >= seq->start) &&
+ (timeline_frame <= (seq->start + SEQ_time_strip_length_get(scene, seq)))) {
seq->endofs = 0;
+ seq->endstill = 0;
+ seq->anim_endofs += (seq->start + SEQ_time_strip_length_get(scene, seq)) - timeline_frame;
}
/* Adjust within range of extended stillframes after strip. */
- else if ((seq->start + seq->len) < timeline_frame) {
- SEQ_time_right_handle_frame_set(scene, seq, timeline_frame);
+ else if ((seq->start + SEQ_time_strip_length_get(scene, seq)) < timeline_frame) {
+ seq->endstill = timeline_frame - seq->start - SEQ_time_strip_length_get(scene, seq);
}
}
-static void seq_split_set_right_offset(const Scene *scene, Sequence *seq, int timeline_frame)
+static void seq_split_set_right_hold_offset(Scene *scene, Sequence *seq, int timeline_frame)
{
/* Adjust within range of extended stillframes before strip. */
if (timeline_frame < seq->start) {
- const int content_offset = seq->start - timeline_frame + 1;
- seq->start = timeline_frame - 1;
- seq->startofs += content_offset;
+ seq->startstill = seq->start - timeline_frame;
+ }
+ /* Adjust within range of strip contents. */
+ else if ((timeline_frame >= seq->start) &&
+ (timeline_frame <= (seq->start + SEQ_time_strip_length_get(scene, seq)))) {
+ seq->anim_startofs += timeline_frame - seq->start;
+ seq->start = timeline_frame;
+ seq->startstill = 0;
+ seq->startofs = 0;
}
-
- SEQ_time_right_handle_frame_set(scene, seq, timeline_frame);
-}
-
-static void seq_split_set_left_offset(const Scene *scene, Sequence *seq, int timeline_frame)
-{
/* Adjust within range of extended stillframes after strip. */
- if (timeline_frame > seq->start + seq->len) {
- const int content_offset = timeline_frame - (seq->start + seq->len) + 1;
- seq->start += content_offset;
- seq->endofs += content_offset;
+ else if ((seq->start + SEQ_time_strip_length_get(scene, seq)) < timeline_frame) {
+ seq->start = timeline_frame;
+ seq->startofs = 0;
+ seq->anim_startofs += SEQ_time_strip_length_get(scene, seq) - 1;
+ seq->endstill = seq->enddisp - timeline_frame - 1;
+ seq->startstill = 0;
}
-
- SEQ_time_left_handle_frame_set(scene, seq, timeline_frame);
}
-static bool seq_edit_split_effect_intersect_check(const Sequence *seq, const int timeline_frame)
+static bool seq_edit_split_effect_intersect_check(const Scene *scene,
+ const Sequence *seq,
+ const int timeline_frame)
{
- return timeline_frame > SEQ_time_left_handle_frame_get(seq) &&
- timeline_frame < SEQ_time_right_handle_frame_get(seq);
+ return timeline_frame > SEQ_time_left_handle_frame_get(scene, seq) &&
+ timeline_frame < SEQ_time_right_handle_frame_get(scene, seq);
}
static void seq_edit_split_handle_strip_offsets(Main *bmain,
@@ -352,10 +319,10 @@ static void seq_edit_split_handle_strip_offsets(Main *bmain,
const int timeline_frame,
const eSeqSplitMethod method)
{
- if (seq_edit_split_effect_intersect_check(right_seq, timeline_frame)) {
+ if (seq_edit_split_effect_intersect_check(scene, right_seq, timeline_frame)) {
switch (method) {
case SEQ_SPLIT_SOFT:
- seq_split_set_left_offset(scene, right_seq, timeline_frame);
+ SEQ_time_left_handle_frame_set(scene, right_seq, timeline_frame);
break;
case SEQ_SPLIT_HARD:
seq_split_set_left_hold_offset(scene, right_seq, timeline_frame);
@@ -364,10 +331,10 @@ static void seq_edit_split_handle_strip_offsets(Main *bmain,
}
}
- if (seq_edit_split_effect_intersect_check(left_seq, timeline_frame)) {
+ if (seq_edit_split_effect_intersect_check(scene, left_seq, timeline_frame)) {
switch (method) {
case SEQ_SPLIT_SOFT:
- seq_split_set_right_offset(scene, left_seq, timeline_frame);
+ SEQ_time_right_handle_frame_set(scene, left_seq, timeline_frame);
break;
case SEQ_SPLIT_HARD:
seq_split_set_right_hold_offset(scene, left_seq, timeline_frame);
@@ -377,31 +344,40 @@ static void seq_edit_split_handle_strip_offsets(Main *bmain,
}
}
-static bool seq_edit_split_effect_inputs_intersect(const Sequence *seq, const int timeline_frame)
+static bool seq_edit_split_effect_inputs_intersect(const Scene *scene,
+ const Sequence *seq,
+ const int timeline_frame)
{
bool input_does_intersect = false;
if (seq->seq1) {
- input_does_intersect |= seq_edit_split_effect_intersect_check(seq->seq1, timeline_frame);
+ input_does_intersect |= seq_edit_split_effect_intersect_check(
+ scene, seq->seq1, timeline_frame);
if ((seq->seq1->type & SEQ_TYPE_EFFECT) != 0) {
- input_does_intersect |= seq_edit_split_effect_inputs_intersect(seq->seq1, timeline_frame);
+ input_does_intersect |= seq_edit_split_effect_inputs_intersect(
+ scene, seq->seq1, timeline_frame);
}
}
if (seq->seq2) {
- input_does_intersect |= seq_edit_split_effect_intersect_check(seq->seq2, timeline_frame);
+ input_does_intersect |= seq_edit_split_effect_intersect_check(
+ scene, seq->seq2, timeline_frame);
if ((seq->seq1->type & SEQ_TYPE_EFFECT) != 0) {
- input_does_intersect |= seq_edit_split_effect_inputs_intersect(seq->seq2, timeline_frame);
+ input_does_intersect |= seq_edit_split_effect_inputs_intersect(
+ scene, seq->seq2, timeline_frame);
}
}
if (seq->seq3) {
- input_does_intersect |= seq_edit_split_effect_intersect_check(seq->seq3, timeline_frame);
+ input_does_intersect |= seq_edit_split_effect_intersect_check(
+ scene, seq->seq3, timeline_frame);
if ((seq->seq1->type & SEQ_TYPE_EFFECT) != 0) {
- input_does_intersect |= seq_edit_split_effect_inputs_intersect(seq->seq3, timeline_frame);
+ input_does_intersect |= seq_edit_split_effect_inputs_intersect(
+ scene, seq->seq3, timeline_frame);
}
}
return input_does_intersect;
}
-static bool seq_edit_split_operation_permitted_check(SeqCollection *strips,
+static bool seq_edit_split_operation_permitted_check(const Scene *scene,
+ SeqCollection *strips,
const int timeline_frame,
const char **r_error)
{
@@ -410,7 +386,7 @@ static bool seq_edit_split_operation_permitted_check(SeqCollection *strips,
if ((seq->type & SEQ_TYPE_EFFECT) == 0) {
continue;
}
- if (!seq_edit_split_effect_intersect_check(seq, timeline_frame)) {
+ if (!seq_edit_split_effect_intersect_check(scene, seq, timeline_frame)) {
continue;
}
if (SEQ_effect_get_num_inputs(seq->type) <= 1) {
@@ -420,7 +396,7 @@ static bool seq_edit_split_operation_permitted_check(SeqCollection *strips,
*r_error = "Splitting transition effect is not permitted.";
return false;
}
- if (!seq_edit_split_effect_inputs_intersect(seq, timeline_frame)) {
+ if (!seq_edit_split_effect_inputs_intersect(scene, seq, timeline_frame)) {
*r_error = "Effect inputs don't overlap. Can not split such effect.";
return false;
}
@@ -436,16 +412,16 @@ Sequence *SEQ_edit_strip_split(Main *bmain,
const eSeqSplitMethod method,
const char **r_error)
{
- if (!seq_edit_split_effect_intersect_check(seq, timeline_frame)) {
+ if (!seq_edit_split_effect_intersect_check(scene, seq, timeline_frame)) {
return NULL;
}
/* Whole strip chain must be duplicated in order to preserve relationships. */
SeqCollection *collection = SEQ_collection_create(__func__);
SEQ_collection_append_strip(seq, collection);
- SEQ_collection_expand(seqbase, collection, SEQ_query_strip_effect_chain);
+ SEQ_collection_expand(scene, seqbase, collection, SEQ_query_strip_effect_chain);
- if (!seq_edit_split_operation_permitted_check(collection, timeline_frame, r_error)) {
+ if (!seq_edit_split_operation_permitted_check(scene, collection, timeline_frame, r_error)) {
SEQ_collection_free(collection);
return NULL;
}
@@ -487,10 +463,10 @@ Sequence *SEQ_edit_strip_split(Main *bmain,
/* Split strips. */
while (left_seq && right_seq) {
- if (SEQ_time_left_handle_frame_get(left_seq) >= timeline_frame) {
+ if (SEQ_time_left_handle_frame_get(scene, left_seq) >= timeline_frame) {
SEQ_edit_flag_for_removal(scene, seqbase, left_seq);
}
- else if (SEQ_time_right_handle_frame_get(right_seq) <= timeline_frame) {
+ else if (SEQ_time_right_handle_frame_get(scene, right_seq) <= timeline_frame) {
SEQ_edit_flag_for_removal(scene, seqbase, right_seq);
}
else if (return_seq == NULL) {