[Bf-blender-cvs] [8ec6b34b8eb] master: VSE: Move split operator logic to module code
Richard Antalik
noreply at git.blender.org
Thu Nov 19 05:32:03 CET 2020
Commit: 8ec6b34b8eb2b0c4565950c39bef622d76e78ff9
Author: Richard Antalik
Date: Thu Nov 19 05:26:57 2020 +0100
Branches: master
https://developer.blender.org/rB8ec6b34b8eb2b0c4565950c39bef622d76e78ff9
VSE: Move split operator logic to module code
Code was rewritten to work on per-sequence basis returning reference to
created strip.
There should be no functional changes.
Selection logic is left as is for now. I could simplify it, but it
belongs to operator, not split logic.
Reviewed By: sergey
Differential Revision: developer.blender.org/D9592
===================================================================
M source/blender/editors/space_sequencer/sequencer_edit.c
M source/blender/sequencer/SEQ_sequencer.h
M source/blender/sequencer/intern/strip_edit.c
===================================================================
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index eb4a1601187..9594aaf28a9 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -692,299 +692,6 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de
/** \} */
-/* -------------------------------------------------------------------- */
-/** \name Split (Hard) Utility
- * \{ */
-
-static Sequence *split_seq_hard(
- Main *bmain, Scene *scene, Sequence *seq, ListBase *new_seq_list, int split_frame)
-{
- TransSeq ts;
- Sequence *seqn = NULL;
- bool skip_dup = false;
-
- /* Unlike soft-split, it's important to use the same value for both strips. */
- const bool is_end_exact = ((seq->start + seq->len) == split_frame);
-
- /* Backup values. */
- ts.start = seq->start;
- ts.machine = seq->machine;
- ts.startstill = seq->startstill;
- ts.endstill = seq->endstill;
- ts.startdisp = seq->startdisp;
- ts.enddisp = seq->enddisp;
- ts.startofs = seq->startofs;
- ts.endofs = seq->endofs;
- ts.anim_startofs = seq->anim_startofs;
- ts.anim_endofs = seq->anim_endofs;
- ts.len = seq->len;
-
- if (seq->type != SEQ_TYPE_META) {
- /* Precaution, needed because the length saved on-disk may not match the length saved in the
- * blend file, or our code may have minor differences reading file length between versions.
- * This causes hard-split to fail, see: T47862. */
- BKE_sequence_reload_new_file(bmain, scene, seq, true);
- BKE_sequence_calc(scene, seq);
- }
-
- /* First Strip. */
- /* Important to offset the start when 'split_frame == seq->start'
- * because we need at least one frame of content after start/end still have clipped it. */
- if ((seq->startstill) && (split_frame <= seq->start)) {
- /* Don't do funny things with METAs. */
- if (seq->type == SEQ_TYPE_META) {
- skip_dup = true;
- seq->startstill = seq->start - split_frame;
- }
- else {
- seq->start = split_frame - 1;
- seq->startstill = split_frame - seq->startdisp - 1;
- seq->anim_endofs += seq->len - 1;
- seq->endstill = 0;
- }
- }
- /* Normal strip. */
- else if ((is_end_exact == false) &&
- ((split_frame >= seq->start) && (split_frame <= (seq->start + seq->len)))) {
- seq->endofs = 0;
- seq->endstill = 0;
- seq->anim_endofs += (seq->start + seq->len) - split_frame;
- }
- /* Strips with extended stillframes. */
- else if ((is_end_exact == true) ||
- (((seq->start + seq->len) < split_frame) && (seq->endstill))) {
- seq->endstill -= seq->enddisp - split_frame;
- /* Don't do funny things with METAs. */
- if (seq->type == SEQ_TYPE_META) {
- skip_dup = true;
- }
- }
-
- BKE_sequence_reload_new_file(bmain, scene, seq, false);
- BKE_sequence_calc(scene, seq);
-
- if (!skip_dup) {
- /* Duplicate AFTER the first change. */
- seqn = BKE_sequence_dupli_recursive(
- scene, scene, new_seq_list, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
- }
-
- if (seqn) {
- seqn->flag |= SELECT;
-
-#if 0
- is_end_exact = ((seqn->start + seqn->len) == split_frame);
-#endif
- /* Second Strip. */
- /* strips with extended stillframes. */
- if ((seqn->startstill) && (split_frame == seqn->start + 1)) {
- seqn->start = ts.start;
- seqn->startstill = ts.start - split_frame;
- seqn->anim_endofs = ts.anim_endofs;
- seqn->endstill = ts.endstill;
- }
-
- /* Normal strip. */
- else if ((is_end_exact == false) &&
- ((split_frame >= seqn->start) && (split_frame <= (seqn->start + seqn->len)))) {
- seqn->start = split_frame;
- seqn->startstill = 0;
- seqn->startofs = 0;
- seqn->endofs = ts.endofs;
- seqn->anim_startofs += split_frame - ts.start;
- seqn->anim_endofs = ts.anim_endofs;
- seqn->endstill = ts.endstill;
- }
-
- /* Strips with extended stillframes after. */
- else if ((is_end_exact == true) ||
- (((seqn->start + seqn->len) < split_frame) && (seqn->endstill))) {
- seqn->start = split_frame;
- seqn->startofs = 0;
- seqn->anim_startofs += ts.len - 1;
- seqn->endstill = ts.enddisp - split_frame - 1;
- seqn->startstill = 0;
- }
-
- BKE_sequence_reload_new_file(bmain, scene, seqn, false);
- BKE_sequence_calc(scene, seqn);
- BKE_sequence_invalidate_cache_in_range(scene, seq, seqn, SEQ_CACHE_ALL_TYPES);
- }
- return seqn;
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
-/** \name Split (Soft) Utility
- * \{ */
-
-static Sequence *split_seq_soft(
- Main *UNUSED(bmain), Scene *scene, Sequence *seq, ListBase *new_seq_list, int split_frame)
-{
- TransSeq ts;
- Sequence *seqn = NULL;
- bool skip_dup = false;
-
- bool is_end_exact = ((seq->start + seq->len) == split_frame);
-
- /* Backup values. */
- ts.start = seq->start;
- ts.machine = seq->machine;
- ts.startstill = seq->startstill;
- ts.endstill = seq->endstill;
- ts.startdisp = seq->startdisp;
- ts.enddisp = seq->enddisp;
- ts.startofs = seq->startofs;
- ts.endofs = seq->endofs;
- ts.anim_startofs = seq->anim_startofs;
- ts.anim_endofs = seq->anim_endofs;
- ts.len = seq->len;
-
- /* First Strip. */
- /* Strips with extended stillfames. */
- /* Important to offset the start when 'split_frame == seq->start'
- * because we need at least one frame of content after start/end still have clipped it. */
- if ((seq->startstill) && (split_frame <= seq->start)) {
- /* don't do funny things with METAs ... */
- if (seq->type == SEQ_TYPE_META) {
- skip_dup = true;
- seq->startstill = seq->start - split_frame;
- }
- else {
- seq->start = split_frame - 1;
- seq->startstill = split_frame - seq->startdisp - 1;
- seq->endofs = seq->len - 1;
- seq->endstill = 0;
- }
- }
- /* Normal strip. */
- else if ((is_end_exact == false) && (split_frame >= seq->start) &&
- (split_frame <= (seq->start + seq->len))) {
- seq->endofs = (seq->start + seq->len) - split_frame;
- }
- /* Strips with extended stillframes. */
- else if ((is_end_exact == true) ||
- (((seq->start + seq->len) < split_frame) && (seq->endstill))) {
- seq->endstill -= seq->enddisp - split_frame;
- /* Don't do funny things with METAs. */
- if (seq->type == SEQ_TYPE_META) {
- skip_dup = true;
- }
- }
-
- BKE_sequence_calc(scene, seq);
-
- if (!skip_dup) {
- /* Duplicate AFTER the first change. */
- seqn = BKE_sequence_dupli_recursive(
- scene, scene, new_seq_list, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM);
- }
-
- if (seqn) {
- seqn->flag |= SELECT;
-
- is_end_exact = ((seqn->start + seqn->len) == split_frame);
-
- /* Second Strip. */
- /* Strips with extended stillframes. */
- if ((seqn->startstill) && (split_frame == seqn->start + 1)) {
- seqn->start = ts.start;
- seqn->startstill = ts.start - split_frame;
- seqn->endofs = ts.endofs;
- seqn->endstill = ts.endstill;
- }
-
- /* Normal strip. */
- else if ((is_end_exact == false) && (split_frame >= seqn->start) &&
- (split_frame <= (seqn->start + seqn->len))) {
- seqn->startstill = 0;
- seqn->startofs = split_frame - ts.start;
- seqn->endofs = ts.endofs;
- seqn->endstill = ts.endstill;
- }
-
- /* Strips with extended stillframes. */
- else if ((is_end_exact == true) ||
- (((seqn->start + seqn->len) < split_frame) && (seqn->endstill))) {
- seqn->start = split_frame - ts.len + 1;
- seqn->startofs = ts.len - 1;
- seqn->endstill = ts.enddisp - split_frame - 1;
- seqn->startstill = 0;
- }
-
- BKE_sequence_calc(scene, seqn);
- BKE_sequence_invalidate_cache_in_range(scene, seq, seqn, SEQ_CACHE_ALL_TYPES);
- }
- return seqn;
-}
-
-/* Like duplicate, but only duplicate and split overlapping strips,
- * strips to the left of the split_frame are ignored and strips to the right
- * are moved to the end of slist.
- * We have to work on the same slist (not using a separate list), since
- * otherwise dupli_seq can't check for duplicate names properly and
- * may generate strips with the same name which will mess up animdata.
- */
-
-static bool split_seq_list(
- Main *bmain,
- Scene *scene,
- ListBase *slist,
- int split_frame,
- int channel,
- bool use_cursor_position,
- Sequence *(*split_seq)(Main *bmain, Scene *, Sequence *, ListBase *, int))
-
-{
- Sequence *seq, *seq_next_iter;
- Sequence *seq_first_new = NULL;
-
- seq = slist->first;
-
- while (seq && seq != seq_first_new) {
- seq_next_iter = seq->next; /* We need this because we may remove seq. */
- seq->tmp = NULL;
- if (use_cursor_position) {
- if (seq->machine == channel && seq->startdisp < split_frame && seq->enddisp > split_frame) {
- Sequence *seqn = split_seq(bmain, scene, seq, slist, split_frame);
- if (seqn) {
- if (seq_first_new == NULL) {
- seq_first_new = seqn;
- }
- }
- }
- }
- else {
- if (seq->flag & SELECT) {
- if (split_frame > seq->startdisp && split_frame < seq->enddisp) {
- Sequence *seqn = split_seq(bmain, scene, seq, slist, split_frame);
- if (seqn) {
- if (seq_first_new == NULL) {
- seq_first_new = seqn;
- }
- }
- }
- else if (seq->enddisp <= split_frame) {
- /* Pass. */
- }
- else if (seq->startdisp >= split_frame) {
- /* Move to tail. */
- BLI_remlink(slist, seq);
- BLI_addtail(slist, seq);
-
- if (seq_first_new == NULL) {
- seq_first_new = seq;
- }
- }
- }
- }
- seq = seq_next_iter;
- }
-
- return (seq_first_new != NULL);
-}
-
static bool sequence_offset_after_frame(Scene *scene, const int delta, const int timeline_frame)
{
Sequence *seq;
@@ -2242,11 +1949,6 @@ void SEQUENCER_OT_swap_inputs(struct wmOperatorType *ot)
/** \name Split Strips Operator
* \{ */
-enum {
- SEQ_SPLIT_SOFT,
- SEQ_SPLIT_HARD,
-};
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list