51 ctx->command_queue = clCreateCommandQueue(
ctx->ocf.hwctx->context,
52 ctx->ocf.hwctx->device_id,
55 "command queue %d.\n", cle);
57 ctx->kernel = clCreateKernel(
ctx->ocf.program,
"transpose", &cle);
65 if (
ctx->command_queue)
66 clReleaseCommandQueue(
ctx->command_queue);
68 clReleaseKernel(
ctx->kernel);
82 if ((inlink->
w >= inlink->
h &&
84 (inlink->
w <= inlink->
h &&
92 "w:%d h:%d -> w:%d h:%d (passthrough mode)\n",
93 inlink->
w, inlink->
h, inlink->
w, inlink->
h);
106 s->ocf.output_width = inlink->
h;
107 s->ocf.output_height = inlink->
w;
119 "w:%d h:%d dir:%d -> w:%d h:%d rotation:%s vflip:%d\n",
120 inlink->
w, inlink->
h,
s->dir, outlink->
w, outlink->
h,
121 s->dir == 1 ||
s->dir == 3 ?
"clockwise" :
"counterclockwise",
122 s->dir == 0 ||
s->dir == 3);
130 return s->passthrough ?
141 size_t global_work[2];
153 if (
ctx->passthrough)
173 if (!
ctx->initialised) {
181 dst = (cl_mem) output->
data[p];
192 cle = clEnqueueNDRangeKernel(
ctx->command_queue,
ctx->kernel, 2,
NULL,
197 cle = clFinish(
ctx->command_queue);
209 clFinish(
ctx->command_queue);
221 cle = clReleaseKernel(
ctx->kernel);
222 if (cle != CL_SUCCESS)
224 "kernel: %d.\n", cle);
227 if (
ctx->command_queue) {
228 cle = clReleaseCommandQueue(
ctx->command_queue);
229 if (cle != CL_SUCCESS)
231 "command queue: %d.\n", cle);
237#define OFFSET(x) offsetof(TransposeOpenCLContext, x)
238#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
246 {
"passthrough",
"do not apply transposition if the input matches the specified geometry",
276 .p.name =
"transpose_opencl",
278 .p.priv_class = &transpose_opencl_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const FFFilter ff_vf_transpose_opencl
static AVFormatContext * ctx
static AVFrame * get_video_buffer(AVFilterLink *inlink, int w, int h)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
common internal and external API header
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
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_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_VERBOSE
Detailed information.
#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.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
static FilterLink * ff_filter_link(AVFilterLink *link)
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
#define AVFILTER_DEFINE_CLASS(fname)
#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.
#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_source_transpose_cl
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.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
@ AV_PIX_FMT_OPENCL
Hardware surfaces for OpenCL.
#define FF_ARRAY_ELEMS(a)
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
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
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.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Rational number (pair of numerator and denominator).
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.
cl_command_queue command_queue
int passthrough
PassthroughType, landscape passthrough mode enabled.
@ TRANSPOSE_PT_TYPE_PORTRAIT
@ TRANSPOSE_PT_TYPE_LANDSCAPE
static const AVFilterPad transpose_opencl_inputs[]
static int transpose_opencl_init(AVFilterContext *avctx)
static int transpose_opencl_filter_frame(AVFilterLink *inlink, AVFrame *input)
static const AVFilterPad transpose_opencl_outputs[]
static int transpose_opencl_config_output(AVFilterLink *outlink)
static AVFrame * get_video_buffer(AVFilterLink *inlink, int w, int h)
static const AVOption transpose_opencl_options[]
static av_cold void transpose_opencl_uninit(AVFilterContext *avctx)
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)