[Bf-blender-cvs] [57136264220] master: VSE: Improve motion-picture workflow

Richard Antalik noreply at git.blender.org
Wed Dec 16 20:38:54 CET 2020


Commit: 571362642201a743168cdf4c827a59c09c40414b
Author: Richard Antalik
Date:   Wed Dec 16 20:34:26 2020 +0100
Branches: master
https://developer.blender.org/rB571362642201a743168cdf4c827a59c09c40414b

VSE: Improve motion-picture workflow

This commit resolves problem introduced in e1665c3d3190 - it was
difficult to import media at their original resolution.
This is done by using original resolution as reference for scale.

All crop and strip transform values and their animation is converted
form old files.

To make both workflows easy to use, sequencer tool settings have been
created with preset for preffered scaling method. This setting is in
sequencer timeline header and add image or movie strip operator
properties.

Two new operators have been added:
`sequencer.strip_transform_fit` operator with 3 options: Scale To Fit,
Scale to Fill and Stretch To Fill.
Operator can fail if strip image or video is not loaded currently, this
case should be either sanitized or data loaded on demand.

`sequencer.strip_transform_clear` operator with 4 options:
Clear position, scale, rotation and all (previous 3 options combined).

Reviewed By: sergey, fsiddi

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

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

M	release/scripts/startup/bl_ui/space_sequencer.py
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenloader/intern/versioning_290.c
M	source/blender/editors/space_sequencer/sequencer_add.c
M	source/blender/editors/space_sequencer/sequencer_edit.c
M	source/blender/editors/space_sequencer/sequencer_intern.h
M	source/blender/editors/space_sequencer/sequencer_ops.c
M	source/blender/imbuf/IMB_imbuf.h
M	source/blender/imbuf/intern/anim_movie.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/sequencer/SEQ_sequencer.h
M	source/blender/sequencer/intern/render.c
M	source/blender/sequencer/intern/sequencer.c
M	source/blender/sequencer/intern/strip_add.c
M	source/blender/sequencer/intern/utils.c

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

diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 84602057e18..e79b5d3e2c8 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -129,6 +129,8 @@ class SEQUENCER_HT_header(Header):
         layout = self.layout
 
         st = context.space_data
+        scene = context.scene
+        sequencer_tool_settings = context.tool_settings.sequencer_tool_settings
 
         show_region_tool_header = st.show_region_tool_header
 
@@ -139,9 +141,15 @@ class SEQUENCER_HT_header(Header):
 
         SEQUENCER_MT_editor_menus.draw_collapsible(context, layout)
 
-        layout.separator_spacer()
+        if st.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'}:
+            layout.separator_spacer()
+            row = layout.row(align=True)
+            row.prop(sequencer_tool_settings, "fit_method", text="")
+            layout.separator_spacer()
 
         if st.view_type in {'PREVIEW', 'SEQUENCER_PREVIEW'}:
+            if st.view_type == 'PREVIEW':
+                layout.separator_spacer()
 
             layout.prop(st, "display_mode", text="", icon_only=True)
             layout.prop(st, "preview_channels", text="", icon_only=True)
@@ -700,6 +708,22 @@ class SEQUENCER_MT_add_effect(Menu):
         col.enabled = selected_sequences_len(context) != 0
 
 
+class SEQUENCER_MT_strip_image_transform(Menu):
+    bl_label = "Image Transform"
+
+    def draw(self, _context):
+        layout = self.layout
+
+        layout.operator("sequencer.strip_transform_fit", text="Scale To Fit").fit_method = 'FIT'
+        layout.operator("sequencer.strip_transform_fit", text="Scale to Fill").fit_method = 'FILL'
+        layout.operator("sequencer.strip_transform_fit", text="Stretch To Fill").fit_method = 'STRETCH'
+        layout.separator()
+
+        layout.operator("sequencer.strip_transform_clear", text="Clear Position").property = 'POSITION'
+        layout.operator("sequencer.strip_transform_clear", text="Clear Scale").property = 'SCALE'
+        layout.operator("sequencer.strip_transform_clear", text="Clear Rotation").property = 'ROTATION'
+        layout.operator("sequencer.strip_transform_clear", text="Clear All").property = 'ALL'
+
 class SEQUENCER_MT_strip_transform(Menu):
     bl_label = "Transform"
 
@@ -794,6 +818,7 @@ class SEQUENCER_MT_strip(Menu):
 
         layout.separator()
         layout.menu("SEQUENCER_MT_strip_transform")
+        layout.menu("SEQUENCER_MT_strip_image_transform")
 
         layout.separator()
         layout.operator("sequencer.split", text="Split").type = 'SOFT'
@@ -2285,6 +2310,7 @@ classes = (
     SEQUENCER_MT_strip_effect,
     SEQUENCER_MT_strip_movie,
     SEQUENCER_MT_strip,
+    SEQUENCER_MT_strip_image_transform,
     SEQUENCER_MT_strip_transform,
     SEQUENCER_MT_strip_input,
     SEQUENCER_MT_strip_lock_mute,
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index ca95ca8bda0..1ed4d1183a1 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -39,7 +39,7 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 7
+#define BLENDER_FILE_SUBVERSION 8
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if the file
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index f63d443d29f..cc192c1c3c0 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -222,6 +222,7 @@ static void scene_init_data(ID *id)
 
   /* Curve Profile */
   scene->toolsettings->custom_bevel_profile_preset = BKE_curveprofile_add(PROF_PRESET_LINE);
+  scene->toolsettings->sequencer_tool_settings = SEQ_tool_settings_init();
 
   for (size_t i = 0; i < ARRAY_SIZE(scene->orientation_slots); i++) {
     scene->orientation_slots[i].index_custom = -1;
@@ -862,6 +863,9 @@ static void scene_blend_write(BlendWriter *writer, ID *id, const void *id_addres
   if (tos->custom_bevel_profile_preset) {
     BKE_curveprofile_blend_write(writer, tos->custom_bevel_profile_preset);
   }
+  if (tos->sequencer_tool_settings) {
+    BLO_write_struct(writer, SequencerToolSettings, tos->sequencer_tool_settings);
+  }
 
   BKE_paint_blend_write(writer, &tos->imapaint.paint);
 
@@ -1121,6 +1125,8 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id)
     if (sce->toolsettings->custom_bevel_profile_preset) {
       BKE_curveprofile_blend_read(reader, sce->toolsettings->custom_bevel_profile_preset);
     }
+
+    BLO_read_data_address(reader, &sce->toolsettings->sequencer_tool_settings);
   }
 
   if (sce->ed) {
@@ -1792,6 +1798,8 @@ ToolSettings *BKE_toolsettings_copy(ToolSettings *toolsettings, const int flag)
   ts->gp_sculpt.cur_primitive = BKE_curvemapping_copy(ts->gp_sculpt.cur_primitive);
 
   ts->custom_bevel_profile_preset = BKE_curveprofile_copy(ts->custom_bevel_profile_preset);
+
+  ts->sequencer_tool_settings = SEQ_tool_settings_copy(ts->sequencer_tool_settings);
   return ts;
 }
 
@@ -1850,6 +1858,10 @@ void BKE_toolsettings_free(ToolSettings *toolsettings)
     BKE_curveprofile_free(toolsettings->custom_bevel_profile_preset);
   }
 
+  if (toolsettings->sequencer_tool_settings) {
+    SEQ_tool_settings_free(toolsettings->sequencer_tool_settings);
+  }
+
   MEM_freeN(toolsettings);
 }
 
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 49e1b057b39..753cc861982 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -74,6 +74,29 @@
 /* Make preferences read-only, use versioning_userdef.c. */
 #define U (*((const UserDef *)&U))
 
+static eSpaceSeq_Proxy_RenderSize get_sequencer_render_size(Main *bmain)
+{
+  eSpaceSeq_Proxy_RenderSize render_size = 100;
+
+  for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+    LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+      LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+        switch (sl->spacetype) {
+          case SPACE_SEQ: {
+            SpaceSeq *sseq = (SpaceSeq *)sl;
+            if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
+              render_size = sseq->render_size;
+              break;
+            }
+          }
+        }
+      }
+    }
+  }
+
+  return render_size;
+}
+
 /* image_size is width or height depending what RNA property is converted - X or Y. */
 static void seq_convert_transform_animation(const Scene *scene,
                                             const char *path,
@@ -212,6 +235,90 @@ static void seq_convert_transform_crop_lb(const Scene *scene,
   }
 }
 
+static void seq_convert_transform_animation_2(const Scene *scene,
+                                              const char *path,
+                                              const float scale_to_fit_factor)
+{
+  if (scene->adt == NULL || scene->adt->action == NULL) {
+    return;
+  }
+
+  FCurve *fcu = BKE_fcurve_find(&scene->adt->action->curves, path, 0);
+  if (fcu != NULL && !BKE_fcurve_is_empty(fcu)) {
+    BezTriple *bezt = fcu->bezt;
+    for (int i = 0; i < fcu->totvert; i++, bezt++) {
+      /* Same math as with old_image_center_*, but simplified. */
+      bezt->vec[1][1] *= scale_to_fit_factor;
+    }
+  }
+}
+
+static void seq_convert_transform_crop_2(const Scene *scene,
+                                         Sequence *seq,
+                                         const eSpaceSeq_Proxy_RenderSize render_size)
+{
+  const StripElem *s_elem = SEQ_render_give_stripelem(seq, seq->start);
+  if (s_elem == NULL) {
+    return;
+  }
+
+  StripCrop *c = seq->strip->crop;
+  StripTransform *t = seq->strip->transform;
+  int image_size_x = s_elem->orig_width;
+  int image_size_y = s_elem->orig_height;
+
+  if (SEQ_can_use_proxy(seq, SEQ_rendersize_to_proxysize(render_size))) {
+    image_size_x /= SEQ_rendersize_to_scale_factor(render_size);
+    image_size_y /= SEQ_rendersize_to_scale_factor(render_size);
+  }
+
+  /* Calculate scale factor, so image fits in preview area with original aspect ratio. */
+  const float scale_to_fit_factor = MIN2((float)scene->r.xsch / (float)image_size_x,
+                                         (float)scene->r.ysch / (float)image_size_y);
+  t->scale_x *= scale_to_fit_factor;
+  t->scale_y *= scale_to_fit_factor;
+  c->top /= scale_to_fit_factor;
+  c->bottom /= scale_to_fit_factor;
+  c->left /= scale_to_fit_factor;
+  c->right /= scale_to_fit_factor;
+
+  char name_esc[(sizeof(seq->name) - 2) * 2], *path;
+  BLI_str_escape(name_esc, seq->name + 2, sizeof(name_esc));
+  path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.offset_x", name_esc);
+  seq_convert_transform_animation_2(scene, path, scale_to_fit_factor);
+  MEM_freeN(path);
+  path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform.offset_y", name_esc);
+  seq_convert_transform_animation_2(scene, path, scale_to_fit_factor);
+  MEM_freeN(path);
+  path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop.min_x", name_esc);
+  seq_convert_transform_animation_2(scene, path, 1 / scale_to_fit_factor);
+  MEM_freeN(path);
+  path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop.max_x", name_esc);
+  seq_convert_transform_animation_2(scene, path, 1 / scale_to_fit_factor);
+  MEM_freeN(path);
+  path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop.min_y", name_esc);
+  seq_convert_transform_animation_2(scene, path, 1 / scale_to_fit_factor);
+  MEM_freeN(path);
+  path = BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop.max_x", name_esc);
+  seq_convert_transform_animation_2(scene, path, 1 / scale_to_fit_factor);
+  MEM_freeN(path);
+}
+
+static void seq_convert_transform_crop_lb_2(const Scene *scene,
+                                            const ListBase *lb,
+                                            const eSpaceSeq_Proxy_RenderSize render_size)
+{
+
+  LISTBASE_FORE

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list