]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_gblur.c
avfilter: Constify all AVFilters
[ffmpeg] / libavfilter / vf_gblur.c
index 68a2ed3520d8126b89faceb9edeedaea8ee9d07b..3f61275658fa610489ed6076f347cbf6791b7b13 100644 (file)
@@ -54,6 +54,15 @@ typedef struct ThreadData {
     int width;
 } ThreadData;
 
+static void postscale_c(float *buffer, int length,
+                        float postscale, float min, float max)
+{
+    for (int i = 0; i < length; i++) {
+        buffer[i] *= postscale;
+        buffer[i] = av_clipf(buffer[i], min, max);
+    }
+}
+
 static void horiz_slice_c(float *buffer, int width, int height, int steps,
                           float nu, float bscale)
 {
@@ -154,7 +163,6 @@ static int filter_vertically(AVFilterContext *ctx, void *arg, int jobnr, int nb_
     return 0;
 }
 
-
 static int filter_postscale(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 {
     GBlurContext *s = ctx->priv;
@@ -163,17 +171,14 @@ static int filter_postscale(AVFilterContext *ctx, void *arg, int jobnr, int nb_j
     const float min = s->flt ? -FLT_MAX : 0.f;
     const int height = td->height;
     const int width = td->width;
-    const int64_t numpixels = width * (int64_t)height;
-    const unsigned slice_start = (numpixels *  jobnr   ) / nb_jobs;
-    const unsigned slice_end   = (numpixels * (jobnr+1)) / nb_jobs;
+    const int awidth = FFALIGN(width, 64);
+    const int slice_start = (height *  jobnr   ) / nb_jobs;
+    const int slice_end   = (height * (jobnr+1)) / nb_jobs;
     const float postscale = s->postscale * s->postscaleV;
-    float *buffer = s->buffer;
-    unsigned i;
+    const int slice_size = slice_end - slice_start;
 
-    for (i = slice_start; i < slice_end; i++) {
-        buffer[i] *= postscale;
-        buffer[i] = av_clipf(buffer[i], min, max);
-    }
+    s->postscale_slice(s->buffer + slice_start * awidth,
+                       slice_size * awidth, postscale, min, max);
 
     return 0;
 }
@@ -228,7 +233,8 @@ static int query_formats(AVFilterContext *ctx)
 void ff_gblur_init(GBlurContext *s)
 {
     s->horiz_slice = horiz_slice_c;
-    if (ARCH_X86_64)
+    s->postscale_slice = postscale_c;
+    if (ARCH_X86)
         ff_gblur_init_x86(s);
 }
 
@@ -246,7 +252,7 @@ static int config_input(AVFilterLink *inlink)
 
     s->nb_planes = av_pix_fmt_count_planes(inlink->format);
 
-    s->buffer = av_malloc_array(FFALIGN(inlink->w, 16), FFALIGN(inlink->h, 16) * sizeof(*s->buffer));
+    s->buffer = av_malloc_array(FFALIGN(inlink->w, 64), FFALIGN(inlink->h, 64) * sizeof(*s->buffer));
     if (!s->buffer)
         return AVERROR(ENOMEM);
 
@@ -387,7 +393,7 @@ static const AVFilterPad gblur_outputs[] = {
     { NULL }
 };
 
-AVFilter ff_vf_gblur = {
+const AVFilter ff_vf_gblur = {
     .name          = "gblur",
     .description   = NULL_IF_CONFIG_SMALL("Apply Gaussian Blur filter."),
     .priv_size     = sizeof(GBlurContext),