[Bf-blender-cvs] [c32ddae8477] soc-2021-vse-strip-thumbnails: Cleanup : Fixed the thumbnail size to max 256 for any dimension. Removed scaling and cropping from UI - hard scale to match result dimensions and no crop. Removed any further preprocessing as the thumbnails should represent original source footage. any rotation or tranform could confuse users as to what the strip original footage was.

Aditya Y Jeppu noreply at git.blender.org
Tue Jun 22 14:41:19 CEST 2021


Commit: c32ddae847714e7199de6e3df57a60ffb6f50fd5
Author: Aditya Y Jeppu
Date:   Tue Jun 22 18:07:54 2021 +0530
Branches: soc-2021-vse-strip-thumbnails
https://developer.blender.org/rBc32ddae847714e7199de6e3df57a60ffb6f50fd5

Cleanup : Fixed the thumbnail size to max 256 for any dimension. Removed
scaling and cropping from UI - hard scale to match result dimensions and
no crop. Removed any further preprocessing as the thumbnails should represent
original source footage. any rotation or tranform could confuse users as to
what the strip original footage was.

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

M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/sequencer/intern/render.c

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

diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 09e40e92777..ca7115104c9 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1103,21 +1103,21 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
   double render_size;
   float strip_x2 = x2;
   bool min_size;
+  float aspect_ratio;
 
-  if (sseq->render_size == SEQ_RENDER_SIZE_NONE) {
-    return;
-  }
+  /* Fix size of obtained ibuf to max 256 for any dimension keeping aspect ratio same. Depends upon
+   * the scene set resolution for uniformity in all strips */
+  aspect_ratio = (float)scene->r.xsch / scene->r.ysch;
 
-  if (sseq->render_size == SEQ_RENDER_SIZE_SCENE) {
-    render_size = scene->r.size / 100.0;
+  if (scene->r.xsch > scene->r.ysch) {
+    rectx = 256;
+    recty = roundf(rectx / aspect_ratio);
   }
   else {
-    render_size = SEQ_rendersize_to_scale_factor(sseq->render_size);
+    recty = 256;
+    rectx = roundf(recty * aspect_ratio);
   }
 
-  rectx = roundf(render_size * 0.25 * scene->r.xsch);
-  recty = roundf(render_size * 0.25 * scene->r.ysch);
-
   /* if thumbs too small ignore */
   min_size = ((y2 - y1) / pixely) > 40 * U.dpi_fac;
 
@@ -1134,7 +1134,7 @@ static void draw_seq_strip_thumbnail(View2D *v2d,
 
   /*Calculate thumb dimensions */
   float thumb_h = (SEQ_STRIP_OFSTOP - SEQ_STRIP_OFSBOTTOM) - (20 * U.dpi_fac * pixely);
-  float aspect_ratio = ((float)rectx) / recty;
+  aspect_ratio = ((float)rectx) / recty;
   float thumb_h_px = thumb_h / pixely;
   float thumb_w = aspect_ratio * thumb_h_px * pixelx;
   float zoom_x = thumb_w / rectx;
@@ -1292,7 +1292,7 @@ static void draw_seq_strip(const bContext *C,
     draw_seq_invalid(x1, x2, y2, text_margin_y);
   }
 
-  if (seq->type == SEQ_TYPE_MOVIE) {
+  if (seq->type == SEQ_TYPE_MOVIE || seq->type == SEQ_TYPE_IMAGE) {
     draw_seq_strip_thumbnail(
         v2d, C, sseq, scene, seq, x1, y1, x2, y2, handsize_clamped, pixelx, pixely);
   }
diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c
index 1eee3e01bb1..11feea1ddb3 100644
--- a/source/blender/sequencer/intern/render.c
+++ b/source/blender/sequencer/intern/render.c
@@ -531,6 +531,41 @@ static void sequencer_image_crop_init(const Sequence *seq,
   BLI_rctf_init(r_crop, left, in->x - right, bottom, in->y - top);
 }
 
+static void sequencer_thumbnail_transform(ImBuf *in, ImBuf *out, const SeqRenderData *context)
+{
+  const Scene *scene = context->scene;
+  const float preview_scale_factor = context->preview_render_size == SEQ_RENDER_SIZE_SCENE ?
+                                         (float)scene->r.size / 100 :
+                                         SEQ_rendersize_to_scale_factor(
+                                             context->preview_render_size);
+
+  float image_scale_factor = (float)context->rectx / in->x;
+  float transform_matrix[3][3];
+
+  /* set to keep same loc,scale,rot but change scale to thumb size limit*/
+  const float scale_x = 1 * image_scale_factor;
+  const float scale_y = 1 * image_scale_factor;
+  const float image_center_offs_x = (out->x - in->x) / 2;
+  const float image_center_offs_y = (out->y - in->y) / 2;
+  const float translate_x = 0 * preview_scale_factor + image_center_offs_x;
+  const float translate_y = 0 * preview_scale_factor + image_center_offs_y;
+  const float pivot[2] = {in->x / 2, in->y / 2};
+  loc_rot_size_to_mat3(transform_matrix,
+                       (const float[]){translate_x, translate_y},
+                       0,
+                       (const float[]){scale_x, scale_y});
+  transform_pivot_set_m3(transform_matrix, pivot);
+  invert_m3(transform_matrix);
+
+  /* no crop */
+  rctf source_crop;
+  BLI_rctf_init(&source_crop, 0, in->x, 0, in->y);
+
+  const eIMBInterpolationFilterMode filter = context->for_render ? IMB_FILTER_BILINEAR :
+                                                                   IMB_FILTER_NEAREST;
+  IMB_transform(in, out, transform_matrix, &source_crop, filter);
+}
+
 static void sequencer_preprocess_transform_crop(
     ImBuf *in, ImBuf *out, const SeqRenderData *context, Sequence *seq, const bool is_proxy_image)
 {
@@ -541,9 +576,9 @@ static void sequencer_preprocess_transform_crop(
                                              context->preview_render_size);
   const bool do_scale_to_render_size = seq_need_scale_to_render_size(seq, is_proxy_image);
   float image_scale_factor = do_scale_to_render_size ? 1.0f : preview_scale_factor;
-  if (context->is_thumb)
-    image_scale_factor = 0.25f;
-
+  if (context->is_thumb) {
+    image_scale_factor = (float)context->rectx / in->x;
+  }
   float transform_matrix[3][3];
   sequencer_image_crop_transform_matrix(
       seq, in, out, image_scale_factor, preview_scale_factor, transform_matrix);
@@ -612,6 +647,19 @@ static ImBuf *input_preprocess(const SeqRenderData *context,
     IMB_filtery(preprocessed_ibuf);
   }
 
+  /* For thumbnails only scale to low res and return. No need for other preprocess as thumbnail
+   * represents source */
+  if (context->is_thumb) {
+    preprocessed_ibuf = IMB_allocImBuf(
+        context->rectx, context->recty, 32, ibuf->rect_float ? IB_rectfloat : IB_rect);
+    sequencer_thumbnail_transform(ibuf, preprocessed_ibuf, context);
+    seq_imbuf_assign_spaces(scene, preprocessed_ibuf);
+    IMB_metadata_copy(preprocessed_ibuf, ibuf);
+    IMB_freeImBuf(ibuf);
+
+    return preprocessed_ibuf;
+  }
+
   if (sequencer_use_crop(seq) || sequencer_use_transform(seq) || context->rectx != ibuf->x ||
       context->recty != ibuf->y || context->is_thumb) {
     const int x = context->rectx;



More information about the Bf-blender-cvs mailing list