Go to the documentation of this file.
93 ctx->hsub =
desc->log2_chroma_w;
94 ctx->vsub =
desc->log2_chroma_h;
100 ctx->command_queue = clCreateCommandQueue(
101 ctx->ocf.hwctx->context,
102 ctx->ocf.hwctx->device_id,
108 ctx->pad_color[rgba_map[0]] =
ctx->pad_rgba[0];
109 ctx->pad_color[rgba_map[1]] =
ctx->pad_rgba[1];
110 ctx->pad_color[rgba_map[2]] =
ctx->pad_rgba[2];
111 ctx->pad_color[rgba_map[3]] =
ctx->pad_rgba[3];
116 ctx->pad_color[3] =
ctx->pad_rgba[3];
121 ctx->kernel_pad = clCreateKernel(
ctx->ocf.program,
"pad", &cle);
124 for (
int i = 0;
i < 4; ++
i) {
125 ctx->pad_color_float.s[
i] = (
float)
ctx->pad_color[
i] / 255.0;
128 ctx->pad_pos.s[0] =
ctx->x;
129 ctx->pad_pos.s[1] =
ctx->y;
131 ctx->initialized = 1;
135 if (
ctx->command_queue)
136 clReleaseCommandQueue(
ctx->command_queue);
138 clReleaseKernel(
ctx->kernel_pad);
150 size_t global_work[2];
169 cl_float4 pad_color_float;
179 if (p > 0 && p < 3) {
180 pad_pos.s[0] = pad_ctx->
pad_pos.s[0] >> pad_ctx->
hsub;
181 pad_pos.s[1] = pad_ctx->
pad_pos.s[1] >> pad_ctx->
vsub;
183 pad_pos.s[0] = pad_ctx->
pad_pos.s[0];
184 pad_pos.s[1] = pad_ctx->
pad_pos.s[1];
187 src = (cl_mem)input_frame->
data[p];
232 if (
ctx->kernel_pad) {
233 cle = clReleaseKernel(
ctx->kernel_pad);
234 if (cle != CL_SUCCESS)
236 "kernel: %d.\n", cle);
239 if (
ctx->command_queue) {
240 cle = clReleaseCommandQueue(
ctx->command_queue);
241 if (cle != CL_SUCCESS)
243 "command queue: %d.\n", cle);
255 double var_values[
VARS_NB], res;
265 (
double)
inlink->sample_aspect_ratio.num /
inlink->sample_aspect_ratio.den : 1;
289 if (adjusted_aspect.
num && adjusted_aspect.
den) {
290 adjusted_aspect =
av_div_q(adjusted_aspect,
inlink->sample_aspect_ratio);
327 ctx->ocf.output_width =
ctx->w;
333 ctx->ocf.output_height =
ctx->h;
367 #define OFFSET(x) offsetof(PadOpenCLContext, x)
368 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
385 .
name =
"pad_opencl",
388 .priv_class = &pad_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.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static const AVFilterPad pad_opencl_inputs[]
uint8_t * data
The data buffer.
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
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.
const char * name
Filter name.
static int filter_frame(AVFilterLink *link, AVFrame *input_frame)
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold void pad_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
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.
#define FF_ARRAY_ELEMS(a)
#define RGB_TO_Y_BT709(r, g, b)
static int pad_opencl_init(AVFilterContext *avctx, AVFrame *input_frame)
#define RGB_TO_U_BT709(r1, g1, b1, max)
#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
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.
Rational number (pair of numerator and denominator).
AVFilterLink ** inputs
array of pointers to input links
static const AVOption pad_opencl_options[]
@ AV_PIX_FMT_OPENCL
Hardware surfaces for OpenCL.
const AVFilter ff_vf_pad_opencl
#define RGB_TO_V_BT709(r1, g1, b1, max)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_expr_parse_and_eval(double *d, const char *s, const char *const *const_names, const double *const_values, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), void *opaque, int log_offset, void *log_ctx)
Parse and evaluate an expression.
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
AVFilterContext * src
source filter
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
static int pad_opencl_config_output(AVFilterLink *outlink)
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.
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
cl_float4 pad_color_float
#define i(width, name, range_min, range_max)
int w
agreed upon image width
static const char *const var_names[]
const char * name
Pad name.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
This struct describes a set or pool of "hardware" frames (i.e.
int ff_opencl_filter_init(AVFilterContext *avctx)
Initialise an OpenCL filter context.
AVFILTER_DEFINE_CLASS(pad_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
static const AVFilterPad pad_opencl_outputs[]
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
void ff_opencl_filter_uninit(AVFilterContext *avctx)
Uninitialise an OpenCL filter context.
cl_command_queue command_queue
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FILTER_OUTPUTS(array)
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
#define CL_FAIL_ON_ERROR(errcode,...)
A helper macro to handle OpenCL errors.
static av_cold int uninit(AVCodecContext *avctx)
const char * ff_opencl_source_pad
AVFilterLink ** outputs
array of pointers to output links