[FFmpeg-devel] [PATCH 3/3][RFC] avfilter/vf_chromakey: Add OpenCL acceleration

Wei Gao highgod0401 at gmail.com
Wed Oct 14 08:44:02 CEST 2015

2015-10-14 14:31 GMT+08:00 Timo Rothenpieler <timo at rothenpieler.org>:

> Hi
>> I have check the error, for some card, yes, just like what I said above,
>> some cards does not support double type, so we must check the opencl
>> extension: cl_khr_fp64 before the kernel compile. If the device support,
>> we use GPU, else, we use CPU or use float type, Is it OK?
>> Thanks
>> Best regards
> Of course, if there's a way to only fall back to floats if doubles are not
> available, that'd be preferable.

A simple idea is that

1. Check whether the device support cl_khr_fp64
2. Set a macro in build option. you can reference the unsharp filter, the
code is as follow:

snprintf(build_opts, 96, "-D LU_RADIUS_X=%d -D LU_RADIUS_Y=%d -D
            2*unsharp->luma.steps_x+1, 2*unsharp->luma.steps_y+1,
2*unsharp->chroma.steps_x+1, 2*unsharp->chroma.steps_y+1);
    unsharp->opencl_ctx.program = av_opencl_compile("unsharp", build_opts);

use the macro to decide whether to use double or float at the compile stage

Do you think it is OK?

Best regards

More information about the ffmpeg-devel mailing list