Go to the source code of this file.
Data Structures
Macros
set argument to specific Kernel.
More...
A helper macro to handle OpenCL errors.
More...
Create a kernel with the given name.
More...
release an OpenCL Memory Object
More...
Enqueue a kernel with the given information.
More...
Uses the above macro to enqueue the given kernel and then additionally runs it to completion via clFinish.
More...
Create a buffer with the given information.
More...
Perform a blocking write to a buffer.
More...
Create a buffer with the given information.
More...
Functions
Check that the input link contains a suitable hardware frames context and extract the device from it.
More...
Create a suitable hardware frames context for the output.
More...
Initialise an OpenCL filter context.
More...
Uninitialise an OpenCL filter context.
More...
Load a new OpenCL program from strings in memory.
More...
Load a new OpenCL program from a file.
More...
Find the work size needed needed for a given plane of an image.
More...
Print a 3x3 matrix into a buffer as __constant array, which could be included in an OpenCL program.
More...
Gets the command start and end times for the given event and returns the difference (the time that the event took).
More...
Macro Definition Documentation
◆ CL_USE_DEPRECATED_OPENCL_1_2_APIS
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
◆ CL_SET_KERNEL_ARG
#define CL_SET_KERNEL_ARG
(
kernel,
arg_num,
)
Value: cle = clSetKernelArg(kernel, arg_num,
sizeof(
type),
arg); \
if (cle != CL_SUCCESS) { \
"argument %d: error %d.\n", arg_num, cle); \
}
set argument to specific Kernel.
This macro relies on usage of local label "fail" and variables: avctx, cle and err.
Definition at line 61 of file opencl.h.
◆ CL_FAIL_ON_ERROR
#define CL_FAIL_ON_ERROR
(
errcode,
...
)
Value: do { \
if (cle != CL_SUCCESS) { \
err = errcode; \
} \
} while(0)
A helper macro to handle OpenCL errors.
It will assign errcode to variable err, log error msg, and jump to fail label on error.
Definition at line 74 of file opencl.h.
◆ CL_CREATE_KERNEL
#define CL_CREATE_KERNEL
(
ctx,
kernel_name
)
Value: do { \
ctx->kernel_ ## kernel_name = clCreateKernel(
ctx->ocf.program, #kernel_name, &cle); \
CL_FAIL_ON_ERROR(
AVERROR(EIO),
"Failed to create %s kernel: %d.\n", #kernel_name, cle); \
} while(0)
Create a kernel with the given name.
The kernel variable in the context structure must have a name of the form kernel_<kernel_name>.
The OpenCLFilterContext variable in the context structure must be named ocf.
Requires the presence of a local cl_int variable named cle and a fail label for error handling.
Definition at line 93 of file opencl.h.
◆ CL_RELEASE_KERNEL
#define CL_RELEASE_KERNEL
(
k )
Value:do { \
if (k) { \
cle = clReleaseKernel(k); \
if (cle != CL_SUCCESS) \
"OpenCL kernel: %d.\n", cle); \
} \
} while(0)
release an OpenCL Kernel
Definition at line 101 of file opencl.h.
◆ CL_RELEASE_MEMORY
#define CL_RELEASE_MEMORY
(
m )
Value:do { \
if (m) { \
cle = clReleaseMemObject(m); \
if (cle != CL_SUCCESS) \
"OpenCL memory: %d.\n", cle); \
} \
} while(0)
release an OpenCL Memory Object
Definition at line 114 of file opencl.h.
◆ CL_RELEASE_QUEUE
#define CL_RELEASE_QUEUE
(
q )
Value:do { \
if (q) { \
cle = clReleaseCommandQueue(q); \
if (cle != CL_SUCCESS) \
"OpenCL command queue: %d.\n", cle); \
} \
} while(0)
release an OpenCL Command Queue
Definition at line 127 of file opencl.h.
◆ CL_ENQUEUE_KERNEL_WITH_ARGS
#define CL_ENQUEUE_KERNEL_WITH_ARGS
(
queue,
kernel,
global_work_size,
local_work_size,
event,
...
)
Value:do { \
OpenCLKernelArg args[] = {__VA_ARGS__}; \
cle = clSetKernelArg(kernel,
i, args[
i].arg_size, args[
i].arg_val); \
if (cle != CL_SUCCESS) { \
"argument %d: error %d.\n",
i, cle); \
} \
} \
\
cle = clEnqueueNDRangeKernel( \
queue, \
kernel, \
global_work_size, \
local_work_size, \
0, \
); \
CL_FAIL_ON_ERROR(
AVERROR(EIO),
"Failed to enqueue kernel: %d.\n", cle); \
} while (0)
Enqueue a kernel with the given information.
Kernel arguments are provided as KernelArg structures and are set in the order that they are passed.
Requires the presence of a local cl_int variable named cle and a fail label for error handling.
Definition at line 146 of file opencl.h.
◆ CL_RUN_KERNEL_WITH_ARGS
#define CL_RUN_KERNEL_WITH_ARGS
(
queue,
kernel,
global_work_size,
local_work_size,
event,
...
)
Value: do { \
CL_ENQUEUE_KERNEL_WITH_ARGS( \
queue, kernel, global_work_size, local_work_size,
event, __VA_ARGS__ \
); \
\
cle = clFinish(queue); \
CL_FAIL_ON_ERROR(
AVERROR(EIO),
"Failed to finish command queue: %d.\n", cle); \
} while (0)
Uses the above macro to enqueue the given kernel and then additionally runs it to completion via clFinish.
Requires the presence of a local cl_int variable named cle and a fail label for error handling.
Definition at line 180 of file opencl.h.
◆ CL_CREATE_BUFFER_FLAGS
#define CL_CREATE_BUFFER_FLAGS
(
ctx,
buffer_name,
host_ptr
)
Value: do { \
ctx->buffer_name = clCreateBuffer( \
ctx->ocf.hwctx->context, \
host_ptr, \
&cle \
); \
CL_FAIL_ON_ERROR(
AVERROR(EIO),
"Failed to create buffer %s: %d.\n", #buffer_name, cle); \
} while(0)
Create a buffer with the given information.
The buffer variable in the context structure must be named <buffer_name>.
Requires the presence of a local cl_int variable named cle and a fail label for error handling.
Definition at line 197 of file opencl.h.
◆ CL_BLOCKING_WRITE_BUFFER
#define CL_BLOCKING_WRITE_BUFFER
(
queue,
host_ptr,
event
)
Value: do { \
cle = clEnqueueWriteBuffer( \
queue, \
CL_TRUE, \
0, \
host_ptr, \
0, \
); \
CL_FAIL_ON_ERROR(
AVERROR(EIO),
"Failed to write buffer to device: %d.\n", cle); \
} while(0)
Perform a blocking write to a buffer.
Requires the presence of a local cl_int variable named cle and a fail label for error handling.
Definition at line 214 of file opencl.h.
◆ CL_CREATE_BUFFER
#define CL_CREATE_BUFFER
(
ctx,
buffer_name,
Create a buffer with the given information.
The buffer variable in the context structure must be named <buffer_name>.
Requires the presence of a local cl_int variable named cle and a fail label for error handling.
Definition at line 237 of file opencl.h.
Function Documentation
◆ ff_opencl_filter_config_input()
Check that the input link contains a suitable hardware frames context and extract the device from it.
Definition at line 46 of file opencl.c.
Referenced by program_opencl_init().
◆ ff_opencl_filter_config_output()
int ff_opencl_filter_config_output
(
AVFilterLink *
outlink )
◆ ff_opencl_filter_init()
◆ ff_opencl_filter_uninit()
Uninitialise an OpenCL filter context.
Definition at line 144 of file opencl.c.
Referenced by avgblur_opencl_uninit(), colorkey_opencl_uninit(), convolution_opencl_uninit(), deshake_opencl_uninit(), neighbor_opencl_uninit(), nlmeans_opencl_uninit(), overlay_opencl_uninit(), pad_opencl_uninit(), program_opencl_uninit(), remap_opencl_uninit(), tonemap_opencl_uninit(), transpose_opencl_uninit(), unsharp_opencl_uninit(), and xfade_opencl_uninit().
◆ ff_opencl_filter_load_program()
const char **
program_source_array,
int
nb_strings
)
Load a new OpenCL program from strings in memory.
Creates a new program and compiles it for the current device. Will log any build errors if compilation fails.
Definition at line 159 of file opencl.c.
Referenced by avgblur_opencl_init(), colorkey_opencl_init(), convolution_opencl_init(), deshake_opencl_init(), ff_opencl_filter_load_program_from_file(), neighbor_opencl_init(), nlmeans_opencl_init(), overlay_opencl_load(), pad_opencl_init(), remap_opencl_load(), tonemap_opencl_init(), transpose_opencl_init(), unsharp_opencl_init(), and xfade_opencl_load().
◆ ff_opencl_filter_load_program_from_file()
◆ ff_opencl_filter_work_size_from_image()
size_t *
work_size,
int
plane,
int
block_alignment
)
Find the work size needed needed for a given plane of an image.
Definition at line 266 of file opencl.c.
Referenced by avgblur_opencl_filter_frame(), convolution_opencl_filter_frame(), filter_frame(), launch_kernel(), neighbor_opencl_filter_frame(), overlay_opencl_blend(), program_opencl_run(), queue_frame(), remap_opencl_process_frame(), transpose_opencl_filter_frame(), unsharp_opencl_filter_frame(), and xfade_frame().
◆ ff_opencl_print_const_matrix_3x3()
void ff_opencl_print_const_matrix_3x3
(
AVBPrint *
buf,
const char *
name_str,
)
Print a 3x3 matrix into a buffer as __constant array, which could be included in an OpenCL program.
Definition at line 329 of file opencl.c.
Referenced by tonemap_opencl_init().
◆ ff_opencl_get_event_time()
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 the event took).
Definition at line 342 of file opencl.c.
Referenced by filter_frame().