[Bf-blender-cvs] [3119a014a6e] blender-v2.82-release: Fix T70415 100% proxy files playing with poor performance

Richard Antalik noreply at git.blender.org
Wed Jan 22 01:38:26 CET 2020


Commit: 3119a014a6e126102c67b014a55dd455dc9557e2
Author: Richard Antalik
Date:   Wed Jan 22 00:27:02 2020 +0100
Branches: blender-v2.82-release
https://developer.blender.org/rB3119a014a6e126102c67b014a55dd455dc9557e2

Fix T70415 100% proxy files playing with poor performance

Refactor code to use `eSpaceSeq_Proxy_RenderSize` or corresponding `IMB_Proxy_Size`
enum items directly.

`SEQ_PROXY_RENDER_SIZE_100` has assigned value 99 to distinguish from `SEQ_PROXY_RENDER_SIZE_FULL`.
This caused error in image size calculation and because of that image had to be scaled.

Author: EitanSomething

Reviewed By: ISS

Differential Revision: http://developer.blender.org/D6368

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

M	source/blender/blenkernel/BKE_sequencer.h
M	source/blender/blenkernel/intern/seqeffects.c
M	source/blender/blenkernel/intern/sequencer.c
M	source/blender/editors/space_sequencer/sequencer_draw.c

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

diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h
index 770318883c0..33bcd3bc91d 100644
--- a/source/blender/blenkernel/BKE_sequencer.h
+++ b/source/blender/blenkernel/BKE_sequencer.h
@@ -208,6 +208,7 @@ struct SeqEffectHandle {
  *
  * sequencer render functions
  * ********************************************************************** */
+double BKE_sequencer_rendersize_to_scale_factor(int size);
 
 struct ImBuf *BKE_sequencer_give_ibuf(const SeqRenderData *context, float cfra, int chanshown);
 struct ImBuf *BKE_sequencer_give_ibuf_threaded(const SeqRenderData *context,
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 236fb43e89c..8dfe01ae1fd 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -3888,7 +3888,7 @@ static ImBuf *do_text_effect(const SeqRenderData *context,
   int font = blf_mono_font_render;
   int line_height;
   int y_ofs, x, y;
-  float proxy_size_comp;
+  double proxy_size_comp;
 
   if (data->text_blf_id == SEQ_FONT_NOT_LOADED) {
     data->text_blf_id = -1;
@@ -3906,15 +3906,11 @@ static ImBuf *do_text_effect(const SeqRenderData *context,
   display = IMB_colormanagement_display_get_named(display_device);
 
   /* Compensate text size for preview render size. */
-  if (ELEM(
-          context->preview_render_size, SEQ_PROXY_RENDER_SIZE_SCENE, SEQ_PROXY_RENDER_SIZE_FULL)) {
-    proxy_size_comp = context->scene->r.size / 100.0f;
-  }
-  else if (context->preview_render_size == SEQ_PROXY_RENDER_SIZE_100) {
-    proxy_size_comp = 1.0f;
+  if (context->preview_render_size == SEQ_PROXY_RENDER_SIZE_SCENE) {
+    proxy_size_comp = context->scene->r.size / 100.0;
   }
   else {
-    proxy_size_comp = context->preview_render_size / 100.0f;
+    proxy_size_comp = BKE_sequencer_rendersize_to_scale_factor(context->preview_render_size);
   }
 
   /* set before return */
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index b05724ca6af..70ec3035c3c 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -38,6 +38,7 @@
 #include "DNA_anim_types.h"
 #include "DNA_object_types.h"
 #include "DNA_sound_types.h"
+#include "DNA_space_types.h"
 
 #include "BLI_math.h"
 #include "BLI_fileops.h"
@@ -1587,35 +1588,32 @@ typedef struct SeqIndexBuildContext {
 
 #define PROXY_MAXFILE (2 * FILE_MAXDIR + FILE_MAXFILE)
 
-static IMB_Proxy_Size seq_rendersize_to_proxysize(int size)
+static IMB_Proxy_Size seq_rendersize_to_proxysize(int render_size)
 {
-  if (size >= 100) {
-    return IMB_PROXY_NONE;
+  switch (render_size) {
+    case SEQ_PROXY_RENDER_SIZE_25:
+      return IMB_PROXY_25;
+    case SEQ_PROXY_RENDER_SIZE_50:
+      return IMB_PROXY_50;
+    case SEQ_PROXY_RENDER_SIZE_75:
+      return IMB_PROXY_75;
+    case SEQ_PROXY_RENDER_SIZE_100:
+      return IMB_PROXY_100;
   }
-  if (size >= 99) {
-    return IMB_PROXY_100;
-  }
-  if (size >= 75) {
-    return IMB_PROXY_75;
-  }
-  if (size >= 50) {
-    return IMB_PROXY_50;
-  }
-  return IMB_PROXY_25;
+  return IMB_PROXY_NONE;
 }
 
-static double seq_rendersize_to_scale_factor(int size)
+double BKE_sequencer_rendersize_to_scale_factor(int render_size)
 {
-  if (size >= 99) {
-    return 1.0;
+  switch (render_size) {
+    case SEQ_PROXY_RENDER_SIZE_25:
+      return 0.25;
+    case SEQ_PROXY_RENDER_SIZE_50:
+      return 0.50;
+    case SEQ_PROXY_RENDER_SIZE_75:
+      return 0.75;
   }
-  if (size >= 75) {
-    return 0.75;
-  }
-  if (size >= 50) {
-    return 0.50;
-  }
-  return 0.25;
+  return 1.0;
 }
 
 /* the number of files will vary according to the stereo format */
@@ -1773,8 +1771,12 @@ static void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile)
   }
 }
 
-static bool seq_proxy_get_fname(
-    Editing *ed, Sequence *seq, int cfra, int render_size, char *name, const int view_id)
+static bool seq_proxy_get_fname(Editing *ed,
+                                Sequence *seq,
+                                int cfra,
+                                eSpaceSeq_Proxy_RenderSize render_size,
+                                char *name,
+                                const int view_id)
 {
   int frameno;
   char dir[PROXY_MAXFILE];
@@ -1868,19 +1870,21 @@ static bool seq_proxy_get_fname(
 
   /* generate a separate proxy directory for each preview size */
 
+  int proxy_size_number = BKE_sequencer_rendersize_to_scale_factor(render_size) * 100;
+
   if (seq->type == SEQ_TYPE_IMAGE) {
     BLI_snprintf(name,
                  PROXY_MAXFILE,
                  "%s/images/%d/%s_proxy%s",
                  dir,
-                 render_size,
+                 proxy_size_number,
                  BKE_sequencer_give_stripelem(seq, cfra)->name,
                  suffix);
     frameno = 1;
   }
   else {
     frameno = (int)give_stripelem_index(seq, cfra) + seq->anim_startofs;
-    BLI_snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####%s", dir, render_size, suffix);
+    BLI_snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####%s", dir, proxy_size_number, suffix);
   }
 
   BLI_path_abs(name, BKE_main_blendfile_path_from_global());
@@ -1896,7 +1900,6 @@ static ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int c
   char name[PROXY_MAXFILE];
   IMB_Proxy_Size psize = seq_rendersize_to_proxysize(context->preview_render_size);
   int size_flags;
-  int render_size = context->preview_render_size;
   StripProxy *proxy = seq->strip->proxy;
   Editing *ed = context->scene->ed;
   StripAnim *sanim;
@@ -1905,22 +1908,17 @@ static ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int c
     return NULL;
   }
 
-  /* dirty hack to distinguish 100% render size from PROXY_100 */
-  if (render_size == 99) {
-    render_size = 100;
-  }
-
   size_flags = proxy->build_size_flags;
 
   /* only use proxies, if they are enabled (even if present!) */
-  if (psize == IMB_PROXY_NONE || ((size_flags & psize) != psize)) {
+  if (psize == IMB_PROXY_NONE || (size_flags & psize) == 0) {
     return NULL;
   }
 
   if (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_FILE) {
     int frameno = (int)give_stripelem_index(seq, cfra) + seq->anim_startofs;
     if (proxy->anim == NULL) {
-      if (seq_proxy_get_fname(ed, seq, cfra, render_size, name, context->view_id) == 0) {
+      if (seq_proxy_get_fname(ed, seq, cfra, psize, name, context->view_id) == 0) {
         return NULL;
       }
 
@@ -1939,7 +1937,7 @@ static ImBuf *seq_proxy_fetch(const SeqRenderData *context, Sequence *seq, int c
     return IMB_anim_absolute(proxy->anim, frameno, IMB_TC_NONE, IMB_PROXY_NONE);
   }
 
-  if (seq_proxy_get_fname(ed, seq, cfra, render_size, name, context->view_id) == 0) {
+  if (seq_proxy_get_fname(ed, seq, cfra, psize, name, context->view_id) == 0) {
     return NULL;
   }
 
@@ -2700,10 +2698,10 @@ static ImBuf *input_preprocess(const SeqRenderData *context,
     int sx, sy, dx, dy;
 
     if (is_proxy_image) {
-      double f = seq_rendersize_to_scale_factor(context->preview_render_size);
+      double f = BKE_sequencer_rendersize_to_scale_factor(context->preview_render_size);
 
       if (f != 1.0) {
-        IMB_scalefastImBuf(ibuf, ibuf->x / f, ibuf->y / f);
+        IMB_scalefastImBuf(ibuf, ibuf->x * f, ibuf->y * f);
       }
     }
 
@@ -3151,12 +3149,11 @@ static ImBuf *seq_render_movie_strip(const SeqRenderData *context,
   bool is_multiview = (seq->flag & SEQ_USE_VIEWS) != 0 &&
                       (context->scene->r.scemode & R_MULTIVIEW) != 0;
 
-  IMB_Proxy_Size proxy_size = seq_rendersize_to_proxysize(context->preview_render_size);
+  IMB_Proxy_Size psize = seq_rendersize_to_proxysize(context->preview_render_size);
 
   if ((seq->flag & SEQ_USE_PROXY) == 0) {
-    proxy_size = IMB_PROXY_NONE;
+    psize = IMB_PROXY_NONE;
   }
-
   /* load all the videos */
   seq_open_anim_file(context->scene, seq, false);
 
@@ -3181,10 +3178,10 @@ static ImBuf *seq_render_movie_strip(const SeqRenderData *context,
                                         nr + seq->anim_startofs,
                                         seq->strip->proxy ? seq->strip->proxy->tc :
                                                             IMB_TC_RECORD_RUN,
-                                        proxy_size);
+                                        psize);
 
         /* fetching for requested proxy size failed, try fetching the original instead */
-        if (!ibuf_arr[i] && proxy_size != IMB_PROXY_NONE) {
+        if (!ibuf_arr[i] && psize != IMB_PROXY_NONE) {
           ibuf_arr[i] = IMB_anim_absolute(sanim->anim,
                                           nr + seq->anim_startofs,
                                           seq->strip->proxy ? seq->strip->proxy->tc :
@@ -3250,10 +3247,10 @@ static ImBuf *seq_render_movie_strip(const SeqRenderData *context,
       ibuf = IMB_anim_absolute(sanim->anim,
                                nr + seq->anim_startofs,
                                seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN,
-                               proxy_size);
+                               psize);
 
       /* fetching for requested proxy size failed, try fetching the original instead */
-      if (!ibuf && proxy_size != IMB_PROXY_NONE) {
+      if (!ibuf && psize != IMB_PROXY_NONE) {
         ibuf = IMB_anim_absolute(sanim->anim,
                                  nr + seq->anim_startofs,
                                  seq->strip->proxy ? seq->strip->proxy->tc : IMB_TC_RECORD_RUN,
@@ -3280,6 +3277,7 @@ static ImBuf *seq_render_movieclip_strip(const SeqRenderData *context, Sequence
   ImBuf *ibuf = NULL;
   MovieClipUser user;
   float tloc[2], tscale, tangle;
+  IMB_Proxy_Size psize = seq_rendersize_to_proxysize(context->preview_render_size);
 
   if (!seq->clip) {
     return NULL;
@@ -3292,7 +3290,7 @@ static ImBuf *seq_render_movieclip_strip(const SeqRenderData *context, Sequence
   user.render_flag |= MCLIP_PROXY_RENDER_USE_FALLBACK_RENDER;
 
   user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL;
-  switch (seq_rendersize_to_proxysize(context->preview_render_size)) {
+  switch (psize

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list