From 0aa714244235f55cb31755cbda3714971082ff7d Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 21 Feb 2022 09:37:13 +0100 Subject: [PATCH] avfilter/vf_dblur: add float formats support --- libavfilter/vf_dblur.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_dblur.c b/libavfilter/vf_dblur.c index 05beb249b0..131a3ae30a 100644 --- a/libavfilter/vf_dblur.c +++ b/libavfilter/vf_dblur.c @@ -131,6 +131,7 @@ static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16, AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16, AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16, + AV_PIX_FMT_GRAYF32, AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32, AV_PIX_FMT_NONE }; @@ -214,8 +215,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) float *bptr = s->buffer; const uint8_t *src = in->data[plane]; const uint16_t *src16 = (const uint16_t *)in->data[plane]; + const float *src32 = (const float *)in->data[plane]; uint8_t *dst = out->data[plane]; uint16_t *dst16 = (uint16_t *)out->data[plane]; + float *dst32 = (float *)out->data[plane]; int y, x; if (!(s->planes & (1 << plane))) { @@ -234,7 +237,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) bptr += width; src += in->linesize[plane]; } - } else { + } else if (s->depth <= 16) { for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { bptr[x] = src16[x]; @@ -242,6 +245,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) bptr += width; src16 += in->linesize[plane] / 2; } + } else { + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + memcpy(bptr, src32, width * sizeof(float)); + } + bptr += width; + src32 += in->linesize[plane] / 4; + } } diriir2d(ctx, plane); @@ -255,7 +266,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) bptr += width; dst += out->linesize[plane]; } - } else { + } else if (s->depth <= 16) { for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { dst16[x] = av_clip_uintp2_c(lrintf(bptr[x]), s->depth); @@ -263,6 +274,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) bptr += width; dst16 += out->linesize[plane] / 2; } + } else { + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + memcpy(dst32, bptr, width * sizeof(float)); + } + bptr += width; + dst32 += out->linesize[plane] / 4; + } } }