[FFmpeg-devel] [OPENCL] a idea to get a better performance of the OPENCL video filter

Reimar Döffinger Reimar.Doeffinger at gmx.de
Wed Jun 26 21:02:36 CEST 2013



On 25.06.2013, at 05:01, weixuan wang <batmanwwx at gmail.com> 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. *
> 
> *to implement this function, each OPENCL video filter need a OPENCL buffer
> to store the OPENCL share buffer and this buffer must can be transferred to
> the next video filter. so I want to use the (uint8_t
> *data[AV_NUM_DATA_POINTERS]) of the AVFrame struct to store the OPENCL
> share buffer. The data[] of the AVFrame has 8 pointers and only used 4 of
> them. So I want to use the data[5] of the AVFrame to store the OPENCL share
> buffer of the video filter. *

I think is should rather be a buffer attribute, like for example "read-only" etc.
Ideally this would even mean the buffer copying code could be removed from all opencl filters, and instead be moved to the same code that e.g. makes a copy of a non-writeable buffer when a filter needs a writeable one.


More information about the ffmpeg-devel mailing list