]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_gblur.c
avformat/aviobuf: do not allocate a new buffer in ffio_ensure_seekback if not needed
[ffmpeg] / libavfilter / vf_gblur.c
index 1957d79e0f6a33f0db771338bd75823ca9acf5bd..2e587f6a0af1652e891c4646443a39fc4b44f5ca 100644 (file)
@@ -157,6 +157,7 @@ static int filter_postscale(AVFilterContext *ctx, void *arg, int jobnr, int nb_j
 {
     GBlurContext *s = ctx->priv;
     ThreadData *td = arg;
+    const float max = (1 << s->depth) - 1;
     const int height = td->height;
     const int width = td->width;
     const int64_t numpixels = width * (int64_t)height;
@@ -166,8 +167,10 @@ static int filter_postscale(AVFilterContext *ctx, void *arg, int jobnr, int nb_j
     float *buffer = s->buffer;
     unsigned i;
 
-    for (i = slice_start; i < slice_end; i++)
+    for (i = slice_start; i < slice_end; i++) {
         buffer[i] *= postscale;
+        buffer[i] = av_clipf(buffer[i], 0.f, max);
+    }
 
     return 0;
 }
@@ -205,6 +208,7 @@ static int query_formats(AVFilterContext *ctx)
         AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16,
         AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA444P9,
         AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA444P10,
+        AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA444P12,
         AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA444P16,
         AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
         AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
@@ -236,7 +240,7 @@ static int config_input(AVFilterLink *inlink)
 
     s->nb_planes = av_pix_fmt_count_planes(inlink->format);
 
-    s->buffer = av_malloc_array(inlink->w, inlink->h * sizeof(*s->buffer));
+    s->buffer = av_malloc_array(FFALIGN(inlink->w, 16), FFALIGN(inlink->h, 16) * sizeof(*s->buffer));
     if (!s->buffer)
         return AVERROR(ENOMEM);