[FFmpeg-cvslog] avfilter/vf_morpho: move structure processing in separate loop

Paul B Mahol git at videolan.org
Mon May 8 18:52:41 EEST 2023


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon May  8 16:12:07 2023 +0200| [bbe410a7fd912277f99b9c071f9ca095b201ef34] | committer: Paul B Mahol

avfilter/vf_morpho: move structure processing in separate loop

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bbe410a7fd912277f99b9c071f9ca095b201ef34
---

 libavfilter/vf_morpho.c | 39 ++++++++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/libavfilter/vf_morpho.c b/libavfilter/vf_morpho.c
index f91957ab81..64b199ac03 100644
--- a/libavfilter/vf_morpho.c
+++ b/libavfilter/vf_morpho.c
@@ -808,30 +808,13 @@ static int do_morpho(FFFrameSync *fs)
     av_frame_copy_props(out, in);
 
     for (int p = 0; p < s->nb_planes; p++) {
-        const uint8_t *src = in->data[p];
-        int src_linesize = in->linesize[p];
         const uint8_t *ssrc = structurepic->data[p];
         const int ssrc_linesize = structurepic->linesize[p];
-        uint8_t *dst = out->data[p];
-        int dst_linesize = out->linesize[p];
         const int swidth = s->splanewidth[p];
         const int sheight = s->splaneheight[p];
-        const int width = s->planewidth[p];
-        const int height = s->planeheight[p];
         const int depth = s->depth;
         int type_size = s->type_size;
 
-        if (ctx->is_disabled || !(s->planes & (1 << p))) {
-copy:
-            av_image_copy_plane(out->data[p] + 0 * out->linesize[p],
-                out->linesize[p],
-                in->data[p] + 0 * in->linesize[p],
-                in->linesize[p],
-                width * ((s->depth + 7) / 8),
-                height);
-            continue;
-        }
-
         if (!s->got_structure[p] || s->structures) {
             free_chord_set(&s->SE[p]);
 
@@ -843,6 +826,28 @@ copy:
                 goto fail;
             s->got_structure[p] = 1;
         }
+    }
+
+    for (int p = 0; p < s->nb_planes; p++) {
+        const uint8_t *src = in->data[p];
+        int src_linesize = in->linesize[p];
+        uint8_t *dst = out->data[p];
+        int dst_linesize = out->linesize[p];
+        const int width = s->planewidth[p];
+        const int height = s->planeheight[p];
+        const int depth = s->depth;
+        int type_size = s->type_size;
+
+        if (ctx->is_disabled || !(s->planes & (1 << p))) {
+copy:
+            av_image_copy_plane(out->data[p] + 0 * out->linesize[p],
+                out->linesize[p],
+                in->data[p] + 0 * in->linesize[p],
+                in->linesize[p],
+                width * ((depth + 7) / 8),
+                height);
+            continue;
+        }
 
         if (s->SE[p].minX == INT16_MAX ||
             s->SE[p].minY == INT16_MAX ||



More information about the ffmpeg-cvslog mailing list