Re: [FFmpeg-devel] [PATCHv2] lavfi: add gblur_opencl filter

2019-05-12 Thread Dylan Fernando
On Sun, May 12, 2019 at 10:47 PM Paul B Mahol  wrote:

> On 5/8/19, Song, Ruiling  wrote:
> >
> >
> >> -Original Message-
> >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> >> Of Dylan Fernando
> >> Sent: Tuesday, May 7, 2019 8:27 AM
> >> To: ffmpeg-devel@ffmpeg.org
> >> Subject: Re: [FFmpeg-devel] [PATCHv2] lavfi: add gblur_opencl filter
> >>
> >> Anyone have any comments/feedback?
> > I think unsharp_opencl with a negative amount should do similar thing as
> > this one.
>
> Not really.
>
> > What's the difference? Better quality? or better speed?
>
> This one can blur image with larger radius.
>
> But why step parameter was removed?
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

This one doesn't use a Gaussian approximation, it uses a Gaussian kernel
calculated with:
matrix_horiz[i] = (1 / sqrt(2 * 3.14159*pow(s->sigma, 2)))*exp(-(pow(x, 2)
/ (2 * pow(s->sigma, 2
with kernel size 6 * sigma.
Should there be a parameter for adjusting the kernel size?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCHv2] lavfi: add gblur_opencl filter

2019-05-12 Thread Paul B Mahol
On 5/8/19, Song, Ruiling  wrote:
>
>
>> -Original Message-
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
>> Of Dylan Fernando
>> Sent: Tuesday, May 7, 2019 8:27 AM
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: Re: [FFmpeg-devel] [PATCHv2] lavfi: add gblur_opencl filter
>>
>> Anyone have any comments/feedback?
> I think unsharp_opencl with a negative amount should do similar thing as
> this one.

Not really.

> What's the difference? Better quality? or better speed?

This one can blur image with larger radius.

But why step parameter was removed?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCHv2] lavfi: add gblur_opencl filter

2019-05-08 Thread Song, Ruiling


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Dylan Fernando
> Sent: Tuesday, May 7, 2019 8:27 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCHv2] lavfi: add gblur_opencl filter
> 
> Anyone have any comments/feedback?
I think unsharp_opencl with a negative amount should do similar thing as this 
one.
What's the difference? Better quality? or better speed?

Thanks!
Ruiling
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCHv2] lavfi: add gblur_opencl filter

2019-05-06 Thread Dylan Fernando
Anyone have any comments/feedback?

On Sat, 27 Apr 2019 at 1:05 am, Dylan Fernando  wrote:

> ---
>  configure |   1 +
>  doc/filters.texi  |  28 
>  libavfilter/Makefile  |   2 +
>  libavfilter/allfilters.c  |   1 +
>  libavfilter/opencl/gblur.cl   |  62 +++
>  libavfilter/opencl_source.h   |   1 +
>  libavfilter/vf_gblur_opencl.c | 368
> ++
>  7 files changed, 463 insertions(+)
>  create mode 100644 libavfilter/opencl/gblur.cl
>  create mode 100644 libavfilter/vf_gblur_opencl.c
>
> diff --git a/configure b/configure
> index bbeaf2fadc..8c1d3cdf92 100755
> --- a/configure
> +++ b/configure
> @@ -3451,6 +3451,7 @@ freezedetect_filter_select="scene_sad"
>  frei0r_filter_deps="frei0r libdl"
>  frei0r_src_filter_deps="frei0r libdl"
>  fspp_filter_deps="gpl"
> +gblur_opencl_filter_deps="opencl"
>  geq_filter_deps="gpl"
>  histeq_filter_deps="gpl"
>  hqdn3d_filter_deps="gpl"
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 4bf96b6d90..80485fed83 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -19010,6 +19010,34 @@ Apply erosion filter with threshold0 set to 30,
> threshold1 set 40, threshold2 se
>  @end example
>  @end itemize
>
> +@section gblur_opencl
> +
> +Apply Gaussian blur filter.
> +
> +The filter accepts the following options:
> +
> +@table @option
> +@item sigma
> +Set horizontal sigma, standard deviation of Gaussian blur. Default is
> @code{0.5}.
> +
> +@item planes
> +Set which planes to filter. By default all planes are filtered.
> +
> +@item sigmaV
> +Set vertical sigma, if negative it will be same as @code{sigma}.
> +Default is @code{-1}.
> +@end table
> +
> +@subsection Example
> +
> +@itemize
> +@item
> +Apply Gaussian blur filter with horizontal and vertical sigma of 0.5.
> +@example
> +-i INPUT -vf "hwupload, gblur_opencl=0.5, hwdownload" OUTPUT
> +@end example
> +@end itemize
> +
>  @section overlay_opencl
>
>  Overlay one video on top of another.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index fef6ec5c55..230315ef39 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -243,6 +243,8 @@ OBJS-$(CONFIG_FREEZEDETECT_FILTER)   +=
> vf_freezedetect.o
>  OBJS-$(CONFIG_FREI0R_FILTER) += vf_frei0r.o
>  OBJS-$(CONFIG_FSPP_FILTER)   += vf_fspp.o
>  OBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
> +OBJS-$(CONFIG_GBLUR_OPENCL_FILTER)   += vf_gblur_opencl.o
> opencl.o \
> +opencl/gblur.o
>  OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o
>  OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o
>  OBJS-$(CONFIG_GRAPHMONITOR_FILTER)   += f_graphmonitor.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index c51ae0f3c7..cb0fc051cc 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -229,6 +229,7 @@ extern AVFilter ff_vf_freezedetect;
>  extern AVFilter ff_vf_frei0r;
>  extern AVFilter ff_vf_fspp;
>  extern AVFilter ff_vf_gblur;
> +extern AVFilter ff_vf_gblur_opencl;
>  extern AVFilter ff_vf_geq;
>  extern AVFilter ff_vf_gradfun;
>  extern AVFilter ff_vf_graphmonitor;
> diff --git a/libavfilter/opencl/gblur.cl b/libavfilter/opencl/gblur.cl
> new file mode 100644
> index 00..4fece30d4a
> --- /dev/null
> +++ b/libavfilter/opencl/gblur.cl
> @@ -0,0 +1,62 @@
> +/*
> + * Copyright (c) 2018 Dylan Fernando
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> + */
> +
> +
> +__kernel void gblur_conv_horz(__write_only image2d_t dst,
> +  __read_only  image2d_t src,
> +  int coef_matrix_dim,
> +  __constant float *coef_matrix)
> +{
> +const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
> +   CLK_ADDRESS_CLAMP_TO_EDGE   |
> +   CLK_FILTER_NEAREST);
> +
> +const int half_matrix_dim = (coef_matrix_dim / 2);
> +int2 loc = (int2)(get_global_id(0), get_global_id(1));
> +float4 convPix = (float4)(0.0f, 0.0f, 0.0f, 0.0f);
> +
> +for (int conv_j = -half_matrix_dim; conv_j <=