[Bf-blender-cvs] [8ca9ce09865] master: VSE: Remove still frame offsets

Richard Antalik noreply at git.blender.org
Wed May 18 21:45:44 CEST 2022


Commit: 8ca9ce09865e6a617d6c2f78f3483ba1fd5d6aef
Author: Richard Antalik
Date:   Wed May 18 21:26:47 2022 +0200
Branches: master
https://developer.blender.org/rB8ca9ce09865e6a617d6c2f78f3483ba1fd5d6aef

VSE: Remove still frame offsets

To clarify term still frame: This is portion of strip that displays
static image. This area can exist before or after strip movie content.

Still frames were implemented as strip property, but this was never
displayed in panel. Only way to set still frames was to drag strip
handle with mouse or using python API. This would set either
`seq->*still` or `seq->*ofs` where * stands for `start` or `end`.

When strip had offset, it can't have still frames and vice versa, but
this had to be enforced in RNA functions and everywhere in code where
these fields are set directly. Strip can not have negative offset or
negative number of still frames.

This is not very practical approach and still frames can be simply
implemented as applying negative offset. Merging these offsets would
simplify offset calculations for example in D14962 and could make it
easier to also deprecate usage `seq->*disp` and necessity to call
update functions to recalculate strip boundaries.

For users only functional change is ability to set negative strip offset
using property in side panel.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D14976

===================================================================

M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/editors/space_sequencer/sequencer_edit.c
M	source/blender/editors/space_sequencer/sequencer_thumbnails.c
M	source/blender/makesdna/DNA_sequence_types.h
M	source/blender/makesrna/intern/rna_sequencer.c
M	source/blender/sequencer/SEQ_time.h
M	source/blender/sequencer/intern/proxy.c
M	source/blender/sequencer/intern/render.c
M	source/blender/sequencer/intern/strip_edit.c
M	source/blender/sequencer/intern/strip_time.c
M	source/blender/sequencer/intern/strip_transform.c

===================================================================

diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index de47fe49946..74621a477cd 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -1217,6 +1217,15 @@ static bool version_fix_seq_meta_range(Sequence *seq, void *user_data)
   return true;
 }
 
+static bool version_merge_still_offsets(Sequence *seq, void *UNUSED(user_data))
+{
+  seq->startofs -= seq->startstill;
+  seq->endofs -= seq->endstill;
+  seq->startstill = 0;
+  seq->endstill = 0;
+  return true;
+}
+
 /* Those `version_liboverride_rnacollections_*` functions mimic the old, pre-3.0 code to find
  * anchor and source items in the given list of modifiers, constraints etc., using only the
  * `subitem_local` data of the override property operation.
@@ -3045,5 +3054,13 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
         }
       }
     }
+
+    /* Merge still offsets into start/end offsets. */
+    LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+      Editing *ed = SEQ_editing_get(scene);
+      if (ed != NULL) {
+        SEQ_for_each_callback(&ed->seqbase, version_merge_still_offsets, NULL);
+      }
+    }
   }
 }
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index a561de1ef64..2b01892bbe7 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1109,15 +1109,15 @@ static void draw_seq_background(Scene *scene,
   }
 
   /* Draw background for hold still regions. */
-  if (!is_single_image && (seq->startstill || seq->endstill)) {
+  if (!is_single_image && SEQ_time_has_still_frames(seq)) {
     UI_GetColorPtrShade3ubv(col, col, -35);
     immUniformColor4ubv(col);
 
-    if (seq->startstill) {
+    if (SEQ_time_has_left_still_frames(seq)) {
       const float content_start = min_ff(seq->enddisp, seq->start);
       immRectf(pos, seq->startdisp, y1, content_start, y2);
     }
-    if (seq->endstill) {
+    if (SEQ_time_has_right_still_frames(seq)) {
       const float content_end = max_ff(seq->startdisp, seq->start + seq->len);
       immRectf(pos, content_end, y1, seq->enddisp, y2);
     }
@@ -1336,9 +1336,9 @@ static void draw_seq_strip(const bContext *C,
                                      SEQ_TIMELINE_SHOW_STRIP_COLOR_TAG);
 
   /* Draw strip body. */
-  x1 = (seq->startstill) ? seq->start : seq->startdisp;
+  x1 = SEQ_time_has_left_still_frames(seq) ? seq->start : seq->startdisp;
   y1 = seq->machine + SEQ_STRIP_OFSBOTTOM;
-  x2 = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp;
+  x2 = SEQ_time_has_right_still_frames(seq) ? (seq->start + seq->len) : seq->enddisp;
   y2 = seq->machine + SEQ_STRIP_OFSTOP;
 
   /* Limit body to strip bounds. Meta strip can end up with content outside of strip range. */
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 677ee0c1683..7afc3684d3a 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -77,7 +77,6 @@
 
 typedef struct TransSeq {
   int start, machine;
-  int startstill, endstill;
   int startdisp, enddisp;
   int startofs, endofs;
   int anim_startofs, anim_endofs;
@@ -358,8 +357,7 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op)
     if (seq->flag & SELECT && !SEQ_transform_is_locked(channels, seq) &&
         SEQ_transform_sequence_can_be_translated(seq)) {
       if ((seq->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) == 0) {
-        SEQ_transform_translate_sequence(
-            scene, seq, (snap_frame - seq->startofs + seq->startstill) - seq->start);
+        SEQ_transform_translate_sequence(scene, seq, (snap_frame - seq->startofs) - seq->start);
       }
       else {
         if (seq->flag & SEQ_LEFTSEL) {
@@ -479,8 +477,6 @@ static void transseq_backup(TransSeq *ts, Sequence *seq)
 {
   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;
@@ -494,8 +490,6 @@ static void transseq_restore(TransSeq *ts, Sequence *seq)
 {
   seq->start = ts->start;
   seq->machine = ts->machine;
-  seq->startstill = ts->startstill;
-  seq->endstill = ts->endstill;
   seq->startdisp = ts->startdisp;
   seq->enddisp = ts->enddisp;
   seq->startofs = ts->startofs;
@@ -596,11 +590,8 @@ static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *eve
   return OPERATOR_RUNNING_MODAL;
 }
 
-static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset)
+static void sequencer_slip_recursively(Scene *scene, SlipData *data, int offset)
 {
-  /* Only data types supported for now. */
-  bool changed = false;
-
   /* Iterate in reverse so meta-strips are iterated after their children. */
   for (int i = data->num_seq - 1; i >= 0; i--) {
     Sequence *seq = data->seq_array[i];
@@ -614,33 +605,13 @@ static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset)
       endframe = seq->start + seq->len;
 
       /* Compute the sequence offsets. */
-      if (endframe > seq->enddisp) {
-        seq->endstill = 0;
-        seq->endofs = endframe - seq->enddisp;
-        changed = true;
-      }
-      else {
-        seq->endstill = seq->enddisp - endframe;
-        seq->endofs = 0;
-        changed = true;
-      }
-
-      if (seq->start > seq->startdisp) {
-        seq->startstill = seq->start - seq->startdisp;
-        seq->startofs = 0;
-        changed = true;
-      }
-      else {
-        seq->startstill = 0;
-        seq->startofs = seq->startdisp - seq->start;
-        changed = true;
-      }
+      seq->endofs = endframe - seq->enddisp;
+      seq->startofs = seq->startdisp - seq->start;
     }
     else {
       /* No transform data (likely effect strip). Only move start and end. */
       seq->startdisp = data->ts[i].startdisp + offset;
       seq->enddisp = data->ts[i].enddisp + offset;
-      changed = true;
     }
 
     /* Effects are only added if we they are in a meta-strip.
@@ -652,13 +623,11 @@ static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset)
       SEQ_time_update_sequence(scene, seqbase, seq);
     }
   }
-  if (changed) {
-    for (int i = data->num_seq - 1; i >= 0; i--) {
-      Sequence *seq = data->seq_array[i];
-      SEQ_relations_invalidate_cache_preprocessed(scene, seq);
-    }
+
+  for (int i = data->num_seq - 1; i >= 0; i--) {
+    Sequence *seq = data->seq_array[i];
+    SEQ_relations_invalidate_cache_preprocessed(scene, seq);
   }
-  return changed;
 }
 
 /* Make sure, that each strip contains at least 1 frame of content. */
@@ -688,7 +657,6 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op)
   Scene *scene = CTX_data_scene(C);
   Editing *ed = SEQ_editing_get(scene);
   int offset = RNA_int_get(op->ptr, "offset");
-  bool success = false;
 
   /* Recursively count the trimmed elements. */
   int num_seq = slip_count_sequences_recursive(ed->seqbasep, true);
@@ -710,19 +678,16 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op)
   }
 
   sequencer_slip_apply_limits(data, &offset);
-  success = sequencer_slip_recursively(scene, data, offset);
+  sequencer_slip_recursively(scene, data, offset);
 
   MEM_freeN(data->seq_array);
   MEM_freeN(data->trim);
   MEM_freeN(data->ts);
   MEM_freeN(data);
 
-  if (success) {
-    WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-    DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
-    return OPERATOR_FINISHED;
-  }
-  return OPERATOR_CANCELLED;
+  WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+  DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
+  return OPERATOR_FINISHED;
 }
 
 static void sequencer_slip_update_header(Scene *scene, ScrArea *area, SlipData *data, int offset)
@@ -763,9 +728,8 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even
 
     RNA_int_set(op->ptr, "offset", offset);
 
-    if (sequencer_slip_recursively(scene, data, offset)) {
-      WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-    }
+    sequencer_slip_recursively(scene, data, offset);
+    WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
 
     return OPERATOR_RUNNING_MODAL;
   }
@@ -796,9 +760,8 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even
 
         RNA_int_set(op->ptr, "offset", offset);
 
-        if (sequencer_slip_recursively(scene, data, offset)) {
-          WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-        }
+        sequencer_slip_recursively(scene, data, offset);
+        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
       }
       break;
     }
@@ -876,9 +839,8 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even
 
     RNA_int_set(op->ptr, "offset", offset);
 
-    if (sequencer_slip_recursively(scene, data, offset)) {
-      WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
-    }
+    sequencer_slip_recursively(scene, data, offset);
+    WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
   }
 
   return OPERATOR_RUNNING_MODAL;
@@ -1822,7 +1784,7 @@ static int sequencer_offset_clear_exec(bContext *C, wmOperator *UNUSED(op))
   /* For effects, try to find a replacement input. */
   for (seq = ed->seqbasep->first; seq; seq = seq->next) {
     if ((seq->type & SEQ_TYPE_EFFECT) == 0 && (seq->flag & SELECT)) {
-      seq->startofs = seq->endofs = seq->startstill = seq->endstill = 0;
+      seq->startofs = seq->endofs = 0;
     }
   }
 
@@ -1908,7 +1870,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op)
         seq_new->start = start_ofs;
         seq_new->type = SEQ_TYPE_IMAGE;
         seq_new->len = 1;
-        seq_new->endstill = step - 1;
+        seq_new->endofs = 1 - step;
 
         /* New strip. */
         strip_new = seq_new->strip;
diff --git a/source/blender/editors/space_sequencer/sequencer_th

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list