57 ctx->command_queue = clCreateCommandQueue(
58 ctx->ocf.hwctx->context,
59 ctx->ocf.hwctx->device_id,
66 if (
ctx->blend > 0.0001) {
67 ctx->kernel_colorkey = clCreateKernel(
ctx->ocf.program,
"colorkey_blend", &cle);
70 ctx->kernel_colorkey = clCreateKernel(
ctx->ocf.program,
"colorkey", &cle);
74 for (
int i = 0;
i < 4; ++
i) {
75 ctx->colorkey_rgba_float.s[
i] = (
float)
ctx->colorkey_rgba[
i] / 255.0;
82 if (
ctx->command_queue)
83 clReleaseCommandQueue(
ctx->command_queue);
84 if (
ctx->kernel_colorkey)
85 clReleaseKernel(
ctx->kernel_colorkey);
97 size_t global_work[2];
125 src = (cl_mem)input_frame->
data[0];
137 if (colorkey_ctx->
blend > 0.0001) {
145 cle = clEnqueueNDRangeKernel(
183 if (
ctx->kernel_colorkey) {
184 cle = clReleaseKernel(
ctx->kernel_colorkey);
185 if (cle != CL_SUCCESS)
187 "kernel: %d.\n", cle);
190 if (
ctx->command_queue) {
191 cle = clReleaseCommandQueue(
ctx->command_queue);
192 if (cle != CL_SUCCESS)
194 "command queue: %d.\n", cle);
217#define OFFSET(x) offsetof(ColorkeyOpenCLContext, x)
218#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
230 .p.name =
"colorkey_opencl",
231 .p.description =
NULL_IF_CONFIG_SMALL(
"Turns a certain color into transparency. Operates on RGB colors."),
232 .p.priv_class = &colorkey_opencl_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const FFFilter ff_vf_colorkey_opencl
static AVFormatContext * ctx
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void ff_opencl_filter_uninit(AVFilterContext *avctx)
Uninitialise an OpenCL filter context.
int ff_opencl_filter_load_program(AVFilterContext *avctx, const char **program_source_array, int nb_strings)
Load a new OpenCL program from strings in memory.
int ff_opencl_filter_config_input(AVFilterLink *inlink)
Check that the input link contains a suitable hardware frames context and extract the device from it.
int ff_opencl_filter_init(AVFilterContext *avctx)
Initialise an OpenCL filter context.
int ff_opencl_filter_work_size_from_image(AVFilterContext *avctx, size_t *work_size, AVFrame *frame, int plane, int block_alignment)
Find the work size needed needed for a given plane of an image.
int ff_opencl_filter_config_output(AVFilterLink *outlink)
Create a suitable hardware frames context for the output.
#define CL_SET_KERNEL_ARG(kernel, arg_num, type, arg)
set argument to specific Kernel.
#define CL_FAIL_ON_ERROR(errcode,...)
A helper macro to handle OpenCL errors.
const char * ff_source_colorkey_cl
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
@ AV_PIX_FMT_OPENCL
Hardware surfaces for OpenCL.
uint8_t * data
The data buffer.
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame.
This struct describes a set or pool of "hardware" frames (i.e.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
cl_float4 colorkey_rgba_float
cl_kernel kernel_colorkey
cl_command_queue command_queue
static av_cold void colorkey_opencl_uninit(AVFilterContext *avctx)
static const AVOption colorkey_opencl_options[]
static int filter_frame(AVFilterLink *link, AVFrame *input_frame)
static const AVFilterPad colorkey_opencl_inputs[]
static const AVFilterPad colorkey_opencl_outputs[]
static int colorkey_opencl_init(AVFilterContext *avctx)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.