124 for (
int i = 0;
i < 4; ++
i) {
150 size_t global_work[2];
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];
188 dst = (cl_mem)output_frame->
data[p];
234 if (cle != CL_SUCCESS)
236 "kernel: %d.\n", cle);
241 if (cle != CL_SUCCESS)
243 "command queue: %d.\n", cle);
255 double var_values[
VARS_NB], res;
263 var_values[
VAR_A] = (double) inlink->
w / inlink->
h;
289 if (adjusted_aspect.
num && adjusted_aspect.
den) {
302 ctx->
x = var_values[
VAR_X] = res;
307 ctx->
y = var_values[
VAR_Y] = res;
313 ctx->
x = var_values[
VAR_X] = res;
315 if (ctx->
x < 0 || ctx->
x + inlink->
w > ctx->
w)
316 ctx->
x = var_values[
VAR_X] = (ctx->
w - inlink->
w) / 2;
317 if (ctx->
y < 0 || ctx->
y + inlink->
h > ctx->
h)
318 ctx->
y = var_values[
VAR_Y] = (ctx->
h - inlink->
h) / 2;
321 if (ctx->
w < inlink->
w || ctx->
h < inlink->
h) {
322 av_log(ctx,
AV_LOG_ERROR,
"Padded dimensions cannot be smaller than input dimensions.\n");
369 #define OFFSET(x) offsetof(PadOpenCLContext, x) 370 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM 387 .
name =
"pad_opencl",
390 .priv_class = &pad_opencl_class,
394 .
inputs = pad_opencl_inputs,
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
static int pad_opencl_config_output(AVFilterLink *outlink)
#define RGB_TO_Y_BT709(r, g, b)
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
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.
Main libavfilter public API header.
static av_cold int init(AVCodecContext *avctx)
int h
agreed upon image height
AVFILTER_DEFINE_CLASS(pad_opencl)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
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.
cl_float4 pad_color_float
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static av_cold int uninit(AVCodecContext *avctx)
const char * ff_opencl_source_pad
cl_device_id device_id
The primary device ID of the device.
#define RGB_TO_V_BT709(r1, g1, b1, shift)
static const AVFilterPad pad_opencl_inputs[]
static const char *const var_names[]
int ff_opencl_filter_config_output(AVFilterLink *outlink)
Create a suitable hardware frames context for the output.
#define RGB_TO_U_BT709(r1, g1, b1, shift)
A filter pad used for either input or output.
A link between two filters.
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_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Various defines for YUV<->RGB conversion.
static int filter_frame(AVFilterLink *link, AVFrame *input_frame)
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
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. ...
void * priv
private data for use by the filter
int w
agreed upon image width
cl_command_queue command_queue
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
AVFilter ff_vf_pad_opencl
AVFilterContext * src
source filter
static const AVFilterPad outputs[]
#define FF_ARRAY_ELEMS(a)
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
#define CL_SET_KERNEL_ARG(kernel, arg_num, type, arg)
set argument to specific Kernel.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
uint8_t * data
The data buffer.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
Rational number (pair of numerator and denominator).
This struct describes a set or pool of "hardware" frames (i.e.
const char * name
Filter name.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
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
AVFilterLink ** outputs
array of pointers to output links
#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.
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
static int query_formats(AVFilterContext *ctx)
static const AVOption pad_opencl_options[]
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 av_cold void pad_opencl_uninit(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.
static int pad_opencl_init(AVFilterContext *avctx, AVFrame *input_frame)
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
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
static const AVFilterPad pad_opencl_outputs[]
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
simple arithmetic expression evaluator