41 ctx->hwctx =
ctx->device->hwctx;
56 "hardware frames context on the input.\n");
61 if (avctx->
inputs[0] != inlink)
75 if (!
ctx->output_width)
76 ctx->output_width = inlink->
w;
77 if (!
ctx->output_height)
78 ctx->output_height = inlink->
h;
94 if (!
ctx->device_ref) {
107 if (!output_frames_ref) {
115 output_frames->
width =
ctx->output_width;
116 output_frames->
height =
ctx->output_height;
121 "frames: %d.\n", err);
126 outlink->
w =
ctx->output_width;
127 outlink->
h =
ctx->output_height;
150 cle = clReleaseProgram(
ctx->program);
151 if (cle != CL_SUCCESS)
153 "program: %d.\n", cle);
160 const char **program_source_array,
166 ctx->program = clCreateProgramWithSource(
ctx->hwctx->context, nb_strings,
167 program_source_array,
174 cle = clBuildProgram(
ctx->program, 1, &
ctx->hwctx->device_id,
176 if (cle != CL_SUCCESS) {
179 if (cle == CL_BUILD_PROGRAM_FAILURE) {
183 clGetProgramBuildInfo(
ctx->program,
ctx->hwctx->device_id,
184 CL_PROGRAM_BUILD_LOG, 0,
NULL, &log_length);
188 cle = clGetProgramBuildInfo(
ctx->program,
189 ctx->hwctx->device_id,
190 CL_PROGRAM_BUILD_LOG,
191 log_length, log,
NULL);
192 if (cle == CL_SUCCESS)
199 clReleaseProgram(
ctx->program);
208 const char *filename)
213 const char *src_const;
219 "source file \"%s\".\n", filename);
243 if (rb == 0 && ferror(file)) {
272 cl_mem_object_type
type;
282 image = (cl_mem)
frame->data[plane];
289 cle = clGetMemObjectInfo(image, CL_MEM_TYPE,
sizeof(
type),
291 if (cle != CL_SUCCESS) {
293 "plane %d: %d.\n", plane, cle);
296 if (
type != CL_MEM_OBJECT_IMAGE2D) {
302 cle = clGetImageInfo(image, CL_IMAGE_WIDTH,
sizeof(
size_t),
304 if (cle != CL_SUCCESS) {
310 cle = clGetImageInfo(image, CL_IMAGE_HEIGHT,
sizeof(
size_t),
312 if (cle != CL_SUCCESS) {
318 if (block_alignment) {
323 work_size[0] =
width;
333 av_bprintf(buf,
"__constant float %s[9] = {\n", name_str);
334 for (
i = 0;
i < 3;
i++) {
335 for (j = 0; j < 3; j++)
346 clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_START,
sizeof(time_start), &time_start,
NULL);
347 clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END,
sizeof(time_end), &time_end,
NULL);
349 return time_end - time_start;
static AVFormatContext * ctx
void av_bprintf(AVBPrint *buf, const char *fmt,...)
#define i(width, name, range_min, range_max)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
static FilterLink * ff_filter_link(AVFilterLink *link)
FILE * avpriv_fopen_utf8(const char *path, const char *mode)
Open a file using a UTF-8 filename.
Memory handling functions.
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.
static int opencl_filter_set_device(AVFilterContext *avctx, AVBufferRef *device)
cl_ulong ff_opencl_get_event_time(cl_event event)
Gets the command start and end times for the given event and returns the difference (the time that th...
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_load_program_from_file(AVFilterContext *avctx, const char *filename)
Load a new OpenCL program from a file.
void ff_opencl_print_const_matrix_3x3(AVBPrint *buf, const char *name_str, double mat[3][3])
Print a 3x3 matrix into a buffer as __constant array, which could be included in an OpenCL program.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
@ AV_PIX_FMT_OPENCL
Hardware surfaces for OpenCL.
A reference to a data buffer.
uint8_t * data
The data buffer.
AVFilterLink ** inputs
array of pointers to input links
void * priv
private data for use by the filter
AVBufferRef * hw_device_ctx
For filters which will create hardware frames, sets the device the filter should create them in.
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVFilterContext * dst
dest filter
This structure describes decoded (raw) audio or video data.
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
This struct describes a set or pool of "hardware" frames (i.e.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
int width
The allocated dimensions of the frames in this pool.
Link properties exposed to filter code, but not external callers.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.