Go to the documentation of this file.
59 ctx->command_queue = clCreateCommandQueue(
60 ctx->ocf.hwctx->context,
61 ctx->ocf.hwctx->device_id,
68 if (
ctx->blend > 0.0001) {
69 ctx->kernel_colorkey = clCreateKernel(
ctx->ocf.program,
"colorkey_blend", &cle);
72 ctx->kernel_colorkey = clCreateKernel(
ctx->ocf.program,
"colorkey", &cle);
76 for (
int i = 0;
i < 4; ++
i) {
77 ctx->colorkey_rgba_float.s[
i] = (float)
ctx->colorkey_rgba[
i] / 255.0;
84 if (
ctx->command_queue)
85 clReleaseCommandQueue(
ctx->command_queue);
86 if (
ctx->kernel_colorkey)
87 clReleaseKernel(
ctx->kernel_colorkey);
99 size_t global_work[2];
127 src = (cl_mem)input_frame->
data[0];
139 if (colorkey_ctx->
blend > 0.0001) {
147 cle = clEnqueueNDRangeKernel(
185 if (
ctx->kernel_colorkey) {
186 cle = clReleaseKernel(
ctx->kernel_colorkey);
187 if (cle != CL_SUCCESS)
189 "kernel: %d.\n", cle);
192 if (
ctx->command_queue) {
193 cle = clReleaseCommandQueue(
ctx->command_queue);
194 if (cle != CL_SUCCESS)
196 "command queue: %d.\n", cle);
219 #define OFFSET(x) offsetof(ColorkeyOpenCLContext, x)
220 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
232 .
name =
"colorkey_opencl",
233 .description =
NULL_IF_CONFIG_SMALL(
"Turns a certain color into transparency. Operates on RGB colors."),
235 .priv_class = &colorkey_opencl_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define CL_SET_KERNEL_ARG(kernel, arg_num, type, arg)
set argument to specific Kernel.
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
uint8_t * data
The data buffer.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
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.
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
const char * name
Filter name.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
cl_kernel kernel_colorkey
static av_cold void colorkey_opencl_uninit(AVFilterContext *avctx)
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.
void * priv
private data for use by the filter
static int filter_frame(AVFilterLink *link, AVFrame *input_frame)
const char * ff_opencl_source_colorkey
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.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int colorkey_opencl_init(AVFilterContext *avctx)
static const AVFilterPad colorkey_opencl_inputs[]
static const AVOption colorkey_opencl_options[]
#define FILTER_INPUTS(array)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
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.
@ AV_PIX_FMT_OPENCL
Hardware surfaces for OpenCL.
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const AVFilterPad colorkey_opencl_outputs[]
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
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.
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
#define i(width, name, range_min, range_max)
int w
agreed upon image width
const char * name
Pad name.
This struct describes a set or pool of "hardware" frames (i.e.
int ff_opencl_filter_init(AVFilterContext *avctx)
Initialise an OpenCL filter context.
const AVFilter ff_vf_colorkey_opencl
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame.
int h
agreed upon image height
void ff_opencl_filter_uninit(AVFilterContext *avctx)
Uninitialise an OpenCL filter context.
cl_float4 colorkey_rgba_float
#define FILTER_OUTPUTS(array)
cl_command_queue command_queue
#define CL_FAIL_ON_ERROR(errcode,...)
A helper macro to handle OpenCL errors.
static av_cold int uninit(AVCodecContext *avctx)
AVFILTER_DEFINE_CLASS(colorkey_opencl)
AVFilterLink ** outputs
array of pointers to output links