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;
263 var_values[
VAR_A] = (double) inlink->
w / inlink->
h;
289 if (adjusted_aspect.
num && adjusted_aspect.
den) {
315 if (
ctx->x < 0 ||
ctx->x + inlink->
w >
ctx->w)
317 if (
ctx->y < 0 ||
ctx->y + inlink->
h >
ctx->h)
321 if (
ctx->w < inlink->
w ||
ctx->h < inlink->
h) {
327 ctx->ocf.output_width =
ctx->w;
333 ctx->ocf.output_height =
ctx->h;
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,
static int query_formats(AVFilterContext *ctx)
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
static av_cold int init(AVCodecContext *avctx)
static av_cold int uninit(AVCodecContext *avctx)
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
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.
simple arithmetic expression evaluator
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.
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Various defines for YUV<->RGB conversion.
common internal API header
#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.
int ff_opencl_filter_query_formats(AVFilterContext *avctx)
Return that all inputs and outputs support only AV_PIX_FMT_OPENCL.
#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_opencl_source_pad
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
#define FF_ARRAY_ELEMS(a)
uint8_t * data
The data buffer.
AVFilterLink ** inputs
array of pointers to input links
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 * src
source filter
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
const char * name
Pad name.
const char * name
Filter name.
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.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Rational number (pair of numerator and denominator).
cl_command_queue command_queue
cl_float4 pad_color_float
static av_cold void pad_opencl_uninit(AVFilterContext *avctx)
static const AVOption pad_opencl_options[]
static const AVFilterPad pad_opencl_inputs[]
static int pad_opencl_config_output(AVFilterLink *outlink)
static int filter_frame(AVFilterLink *link, AVFrame *input_frame)
AVFILTER_DEFINE_CLASS(pad_opencl)
static int pad_opencl_init(AVFilterContext *avctx, AVFrame *input_frame)
static const AVFilterPad pad_opencl_outputs[]
static const char *const var_names[]
AVFilter ff_vf_pad_opencl
#define RGB_TO_Y_BT709(r, g, b)
#define RGB_TO_U_BT709(r1, g1, b1, max)
#define RGB_TO_V_BT709(r1, g1, b1, max)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.