68 if (ctx->
blend > 0.0001) {
76 for (
int i = 0;
i < 4; ++
i) {
99 size_t global_work[2];
127 src = (cl_mem)input_frame->
data[0];
133 dst = (cl_mem)output_frame->
data[0];
139 if (colorkey_ctx->
blend > 0.0001) {
147 cle = clEnqueueNDRangeKernel(
187 if (cle != CL_SUCCESS)
189 "kernel: %d.\n", cle);
194 if (cle != CL_SUCCESS)
196 "command queue: %d.\n", cle);
221 #define OFFSET(x) offsetof(ColorkeyOpenCLContext, x) 222 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM 234 .
name =
"colorkey_opencl",
235 .description =
NULL_IF_CONFIG_SMALL(
"Turns a certain color into transparency. Operates on RGB colors."),
237 .priv_class = &colorkey_opencl_class,
241 .
inputs = colorkey_opencl_inputs,
242 .
outputs = colorkey_opencl_outputs,
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
const char * ff_opencl_source_colorkey
cl_float4 colorkey_rgba_float
This structure describes decoded (raw) audio or video data.
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_input(AVFilterLink *inlink)
Check that the input link contains a suitable hardware frames context and extract the device from it...
int ff_opencl_filter_query_formats(AVFilterContext *avctx)
Return that all inputs and outputs support only AV_PIX_FMT_OPENCL.
cl_command_queue command_queue
Main libavfilter public API header.
static av_cold int init(AVCodecContext *avctx)
int h
agreed upon image height
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static const AVFilterPad colorkey_opencl_inputs[]
int ff_opencl_filter_init(AVFilterContext *avctx)
Initialise an OpenCL filter context.
AVOpenCLDeviceContext * hwctx
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame...
const char * name
Pad name.
static const AVFilterPad colorkey_opencl_outputs[]
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static av_cold void colorkey_opencl_uninit(AVFilterContext *avctx)
static av_cold int uninit(AVCodecContext *avctx)
cl_device_id device_id
The primary device ID of the device.
cl_kernel kernel_colorkey
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
int ff_opencl_filter_config_output(AVFilterLink *outlink)
Create a suitable hardware frames context for the output.
A filter pad used for either input or output.
A link between two filters.
#define i(width, name, range_min, range_max)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
void * priv
private data for use by the filter
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
int w
agreed upon image width
AVFilter ff_vf_colorkey_opencl
static int filter_frame(AVFilterLink *link, AVFrame *input_frame)
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
#define CL_SET_KERNEL_ARG(kernel, arg_num, type, arg)
set argument to specific Kernel.
uint8_t * data
The data buffer.
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
This struct describes a set or pool of "hardware" frames (i.e.
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
AVFILTER_DEFINE_CLASS(colorkey_opencl)
static const AVOption colorkey_opencl_options[]
#define CL_FAIL_ON_ERROR(errcode,...)
A helper macro to handle OpenCL errors.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int query_formats(AVFilterContext *ctx)
void ff_opencl_filter_uninit(AVFilterContext *avctx)
Uninitialise an OpenCL filter context.
AVFilterContext * dst
dest filter
cl_context context
The OpenCL context which will contain all operations and frames on this device.
static int colorkey_opencl_init(AVFilterContext *avctx)
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.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.