[FFmpeg-devel] [PATCH] lavfilter/vf_unsharp: add the OPENCL share buffer for the unsharp video filter

Michael Niedermayer michaelni at gmx.at
Tue Aug 6 02:40:50 CEST 2013


On Sat, Jul 27, 2013 at 03:15:06PM +0800, weixuan wang wrote:
> * *
> 
> *Hi,*
> 
> * ***
> 
> *I found that there are two video filters having the OPENCL supports in the
> latest trunk. The two video filters are deshake video filter and unsharp
> video filter. when I used all of the two filters with the OPENCL, i find
> out a idea to get a better performance of them.***
> 
> *In these OPENCL filters, they first copy the input frame buffer into the
> input OPENCL buffer like this:***
> 
> *av_opencl_buffer_write_image(unsharp->opencl_ctx.cl_inbuf,***
> 
> *unsharp->opencl_ctx.cl_inbuf_size,0, in->data,
> unsharp->opencl_ctx.in_plane_size,***
> 
> *unsharp->opencl_ctx.plane_num);***
> 
> *the in->data is the input frame buffer and the
> unsharp->opencl_ctx.cl_inbuf is the input OPENCL buffer.***
> 
> *They use the input OPENCL buffer to run the kernel and get the output
> OPENCL buffer. They then copy the output OPENCL buffer into the output
> frame buffer like this:***
> 
> *av_opencl_buffer_read_image(out->data, unsharp->opencl_ctx.out_plane_size,*
> **
> 
> *unsharp->opencl_ctx.plane_num, unsharp->opencl_ctx.cl_outbuf,***
> 
> *unsharp->opencl_ctx.cl_outbuf_size);***
> 
> *the out->data is the output frame buffer and the unsharp->opencl_ctx.cl_
> outbuf is the output OPENCL buffer.***
> 
> *if I use two or more video filters with the OPENCL, the time of the data
> copying will be very long. So I have a idea:***
> 
> *if the first video filter is using the OPENCL and the next video filter is
> using the OPENCL too, we can remove the output data copying of the first
> video filter and the input data copying of the next video filter. we can
> directly use the output OPENCL buffer of the first video filter as the
> input OPENCL buffer of the next video filter.***
> 

> *I implement a patch for my idea. This patch is implemented for the unsharp
> video filter. you can run the command:” **ffmpeg -i test.mp4 -vf
> "unsharp=opencl=1,unsharp=opencl=1" -y out.mpg” to test the improvement of
> the performance. *

please post some benchmarks comparing x86-asm, opencl and the
new opencl buffer passing



> 
> *If this patch can be accepted by community, I will continue to implement
> the patch for the deshake video filter.*

>  libavfilter/avfilter.h       |    8 ++
>  libavfilter/unsharp.h        |    4 +
>  libavfilter/unsharp_opencl.c |  132 ++++++++++++++++++++++++++++++-------------
>  libavfilter/unsharp_opencl.h |    2 
>  libavfilter/vf_unsharp.c     |    2 
>  libavutil/opencl.h           |    3 
>  6 files changed, 112 insertions(+), 39 deletions(-)
> 951a322e65bc5b34b2e5d859c602e0fc7a4a53cc  0001-lavfilter-vf_unsharp-add-the-OPENCL-share-buffer-for.patch
> From 4a7edef094aa04d752c04841d1b319836c2a7aa3 Mon Sep 17 00:00:00 2001
> From: highgod0401 <highgod0401 at gmail.com>
> Date: Sat, 27 Jul 2013 15:08:04 +0800
> Subject: [PATCH] lavfilter/vf_unsharp: add the OPENCL share buffer for the
>  unsharp video filter
> 
> ---
>  libavfilter/avfilter.h       |   8 +++
>  libavfilter/unsharp.h        |   4 ++
>  libavfilter/unsharp_opencl.c | 132 +++++++++++++++++++++++++++++++------------
>  libavfilter/unsharp_opencl.h |   2 +-
>  libavfilter/vf_unsharp.c     |   2 +-
>  libavutil/opencl.h           |   3 +
>  6 files changed, 112 insertions(+), 39 deletions(-)
> 
> diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
> index 6a93436..0238a37 100644
> --- a/libavfilter/avfilter.h
> +++ b/libavfilter/avfilter.h
> @@ -677,6 +677,14 @@ struct AVFilterContext {
>      void *enable;                   ///< parsed expression (AVExpr*)
>      double *var_values;             ///< variable values for the enable expression
>      int is_disabled;                ///< the enabled state from the last expression evaluation
> +#if CONFIG_OPENCL
> +    void *cl_inbuf;                 ///< opencl in buffer
> +    void *cl_outbuf;                ///< opencl out buffer
> +    int i_preclflag;                ///< the previous filter opencl flag
> +    int i_nextclflag;               ///< the next filter opencl flag
> +    int i_filter_type;              ///< the type of the opencl filter
> +#endif
> +
>  };

this looks wrong, the buffer type is not a property of a filter
One could argue about if its a property of a link or a frame but
certainly not a filter. avfilter is not a 1 in 1 out filter framework




[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"    - "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130806/616847ef/attachment.asc>


More information about the ffmpeg-devel mailing list