72 "hardware frames context on the input.\n");
77 if (avctx->
inputs[0] != inlink)
122 if (!output_frames_ref) {
136 "frames: %d.\n", err);
165 cle = clReleaseProgram(ctx->
program);
166 if (cle != CL_SUCCESS)
168 "program: %d.\n", cle);
175 const char **program_source_array,
182 program_source_array,
191 if (cle != CL_SUCCESS) {
194 if (cle == CL_BUILD_PROGRAM_FAILURE) {
199 CL_PROGRAM_BUILD_LOG, 0,
NULL, &log_length);
203 cle = clGetProgramBuildInfo(ctx->
program,
205 CL_PROGRAM_BUILD_LOG,
206 log_length, log,
NULL);
207 if (cle == CL_SUCCESS)
214 clReleaseProgram(ctx->
program);
223 const char *filename)
228 const char *src_const;
231 file = fopen(filename,
"r");
234 "source file \"%s\".\n", filename);
245 err =
snprintf(src, len,
"#line 1 \"%s\"\n", filename);
257 rb = fread(src + pos, 1, len - pos - 1, file);
258 if (rb == 0 && ferror(file)) {
287 cl_mem_object_type
type;
297 image = (cl_mem)frame->
data[plane];
304 cle = clGetMemObjectInfo(image, CL_MEM_TYPE,
sizeof(type),
306 if (cle != CL_SUCCESS) {
308 "plane %d: %d.\n", plane, cle);
311 if (type != CL_MEM_OBJECT_IMAGE2D) {
317 cle = clGetImageInfo(image, CL_IMAGE_WIDTH,
sizeof(
size_t),
319 if (cle != CL_SUCCESS) {
325 cle = clGetImageInfo(image, CL_IMAGE_HEIGHT,
sizeof(
size_t),
327 if (cle != CL_SUCCESS) {
333 if (block_alignment) {
334 width =
FFALIGN(width, block_alignment);
335 height =
FFALIGN(height, block_alignment);
338 work_size[0] =
width;
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
API-specific header for AV_HWDEVICE_TYPE_OPENCL.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
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.
Memory handling functions.
int h
agreed upon image height
int width
The allocated dimensions of the frames in this pool.
AVBufferRef * hw_device_ctx
For filters which will create hardware frames, sets the device the filter should create them in...
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
int ff_opencl_filter_init(AVFilterContext *avctx)
Initialise an OpenCL filter context.
AVOpenCLDeviceContext * hwctx
AVFilterLink ** inputs
array of pointers to input links
cl_device_id device_id
The primary device ID of the device.
AVHWDeviceContext * device
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
int ff_opencl_filter_config_output(AVFilterLink *outlink)
Create a suitable hardware frames context for the output.
A link between two filters.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * priv
private data for use by the filter
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
enum AVPixelFormat output_format
int w
agreed upon image width
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames...
static int opencl_filter_set_device(AVFilterContext *avctx, AVBufferRef *device)
Hardware surfaces for OpenCL.
AVFilterContext * src
source filter
int ff_opencl_filter_load_program_from_file(AVFilterContext *avctx, const char *filename)
Load a new OpenCL program from a file.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
uint8_t * data
The data buffer.
This struct describes a set or pool of "hardware" frames (i.e.
static enum AVPixelFormat pix_fmts[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
A reference to a data buffer.
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
void ff_opencl_filter_uninit(AVFilterContext *avctx)
Uninitialise an OpenCL filter context.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
AVFilterContext * dst
dest filter
cl_context context
The OpenCL context which will contain all operations and frames on this device.
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 * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
AVPixelFormat
Pixel format.