]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/vf_w3fdif: reduce overhead calling execute for every plane
authorPaul B Mahol <onemda@gmail.com>
Fri, 22 Jan 2021 12:27:06 +0000 (13:27 +0100)
committerPaul B Mahol <onemda@gmail.com>
Fri, 22 Jan 2021 12:28:41 +0000 (13:28 +0100)
libavfilter/vf_w3fdif.c

index 5d213c80dabb67413fae02723b1bac6d0ffef2a6..1a64b2b95360e6e23f7deededf401e62c20ab2df 100644 (file)
@@ -359,17 +359,16 @@ static const int16_t coef_hf[2][5] = {{ -2048,  4096, -2048,     0,    0},
 
 typedef struct ThreadData {
     AVFrame *out, *cur, *adj;
-    int plane;
 } ThreadData;
 
-static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
+static int deinterlace_plane_slice(AVFilterContext *ctx, void *arg,
+                                   int jobnr, int nb_jobs, int plane)
 {
     W3FDIFContext *s = ctx->priv;
     ThreadData *td = arg;
     AVFrame *out = td->out;
     AVFrame *cur = td->cur;
     AVFrame *adj = td->adj;
-    const int plane = td->plane;
     const int filter = s->filter;
     uint8_t *in_line, *in_lines_cur[5], *in_lines_adj[5];
     uint8_t *out_line, *out_pixel;
@@ -470,13 +469,23 @@ static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_
     return 0;
 }
 
+static int deinterlace_slice(AVFilterContext *ctx, void *arg,
+                             int jobnr, int nb_jobs)
+{
+    W3FDIFContext *s = ctx->priv;
+
+    for (int p = 0; p < s->nb_planes; p++)
+        deinterlace_plane_slice(ctx, arg, jobnr, nb_jobs, p);
+
+    return 0;
+}
+
 static int filter(AVFilterContext *ctx, int is_second)
 {
     W3FDIFContext *s = ctx->priv;
     AVFilterLink *outlink = ctx->outputs[0];
     AVFrame *out, *adj;
     ThreadData td;
-    int plane;
 
     out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
     if (!out)
@@ -500,10 +509,7 @@ static int filter(AVFilterContext *ctx, int is_second)
 
     adj = s->field ? s->next : s->prev;
     td.out = out; td.cur = s->cur; td.adj = adj;
-    for (plane = 0; plane < s->nb_planes; plane++) {
-        td.plane = plane;
-        ctx->internal->execute(ctx, deinterlace_slice, &td, NULL, FFMIN(s->planeheight[plane], s->nb_threads));
-    }
+    ctx->internal->execute(ctx, deinterlace_slice, &td, NULL, FFMIN(s->planeheight[1], s->nb_threads));
 
     if (s->mode)
         s->field = !s->field;