Go to the documentation of this file.
48 #define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) )
49 #define ALIGN_UP(a, b) (((a) + (b) - 1) & ~((b) - 1))
53 #define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)
56 CUdeviceptr prev, CUdeviceptr cur, CUdeviceptr next,
65 int parity,
int tff,
int clip_max)
69 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
70 CUtexObject tex_prev = 0, tex_cur = 0, tex_next = 0;
74 void *args[] = { &dst, &tex_prev, &tex_cur, &tex_next,
75 &dst_width, &dst_height, &dst_pitch,
76 &src_width, &src_height, &
parity, &tff,
77 &is_field_end, &clip_max };
79 CUDA_TEXTURE_DESC tex_desc = {
80 .filterMode = CU_TR_FILTER_MODE_POINT,
81 .flags = CU_TRSF_READ_AS_INTEGER,
84 CUDA_RESOURCE_DESC res_desc = {
85 .resType = CU_RESOURCE_TYPE_PITCH2D,
86 .res.pitch2D.format =
format,
88 .res.pitch2D.width = src_width,
89 .res.pitch2D.height = src_height,
90 .res.pitch2D.pitchInBytes = src_pitch,
93 res_desc.res.pitch2D.devPtr = (CUdeviceptr)prev;
94 ret =
CHECK_CU(cu->cuTexObjectCreate(&tex_prev, &res_desc, &tex_desc,
NULL));
98 res_desc.res.pitch2D.devPtr = (CUdeviceptr)cur;
99 ret =
CHECK_CU(cu->cuTexObjectCreate(&tex_cur, &res_desc, &tex_desc,
NULL));
103 res_desc.res.pitch2D.devPtr = (CUdeviceptr)next;
104 ret =
CHECK_CU(cu->cuTexObjectCreate(&tex_next, &res_desc, &tex_desc,
NULL));
111 0,
s->hwctx->stream, args,
NULL));
115 CHECK_CU(cu->cuTexObjectDestroy(tex_prev));
117 CHECK_CU(cu->cuTexObjectDestroy(tex_cur));
119 CHECK_CU(cu->cuTexObjectDestroy(tex_next));
129 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
133 ret =
CHECK_CU(cu->cuCtxPushCurrent(
s->hwctx->cuda_ctx));
143 if (
comp->plane <
i) {
149 pixel_size = (
comp->depth +
comp->shift) / 8;
151 if (pixel_size > 2 ||
channels > 2) {
155 switch (pixel_size) {
158 format = CU_AD_FORMAT_UNSIGNED_INT8;
162 format = CU_AD_FORMAT_UNSIGNED_INT16;
169 clip_max = (1 << (
comp->depth +
comp->shift)) - 1;
172 "Deinterlacing plane %d: pixel_size: %d channels: %d\n",
182 (CUdeviceptr)dst->
data[
i],
203 if (
s->hwctx &&
s->cu_module) {
204 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
205 CHECK_CU(cu->cuCtxPushCurrent(
s->hwctx->cuda_ctx));
206 CHECK_CU(cu->cuModuleUnload(
s->cu_module));
215 s->input_frames =
NULL;
223 if (!
inlink->hw_frames_ctx) {
225 "required to associate the processing device.\n");
230 if (!
s->input_frames_ref) {
252 if (!
s->device_ref) {
258 cu =
s->hwctx->internal->cuda_dl;
271 output_frames->
sw_format =
s->input_frames->sw_format;
272 output_frames->
width =
ctx->inputs[0]->w;
273 output_frames->
height =
ctx->inputs[0]->h;
284 "context for output: %d\n",
ret);
301 ret =
CHECK_CU(cu->cuCtxPushCurrent(
s->hwctx->cuda_ctx));
309 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func_uchar,
s->cu_module,
"bwdif_uchar"));
313 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func_uchar2,
s->cu_module,
"bwdif_uchar2"));
317 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func_ushort,
s->cu_module,
"bwdif_ushort"));
321 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func_ushort2,
s->cu_module,
"bwdif_ushort2"));
358 .
name =
"bwdif_cuda",
int(* func)(AVBPrint *dst, const char *in, const char *arg)
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
static int config_input(AVFilterLink *inlink)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
static const AVClass bwdif_cuda_class
static int config_output(AVFilterLink *link)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
uint8_t * data
The data buffer.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
int ff_cuda_load_module(void *avctx, AVCUDADeviceContext *hwctx, CUmodule *cu_module, const unsigned char *data, const unsigned int length)
Loads a CUDA module and applies any decompression, if necessary.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
const AVPixFmtDescriptor * csp
AVBufferRef * input_frames_ref
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
This structure describes decoded (raw) audio or video data.
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
const char * name
Filter name.
int width
The allocated dimensions of the frames in this pool.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVHWFramesContext * input_frames
int ff_yadif_config_output_common(AVFilterLink *outlink)
AVCUDADeviceContext * hwctx
const unsigned int ff_vf_bwdif_cuda_ptx_len
CUfunction cu_func_uchar2
A filter pad used for either input or output.
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
static CUresult call_kernel(AVFilterContext *ctx, CUfunction func, CUdeviceptr prev, CUdeviceptr cur, CUdeviceptr next, CUarray_format format, int channels, int src_width, int src_height, int src_pitch, CUdeviceptr dst, int dst_width, int dst_height, int dst_pitch, int parity, int tff, int clip_max)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
CUfunction cu_func_ushort2
#define AV_CEIL_RSHIFT(a, b)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
#define av_assert0(cond)
assert() equivalent, that is always enabled.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
#define FILTER_INPUTS(array)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
uint8_t nb_components
The number of components each pixel has, (1-4)
const char * av_default_item_name(void *ptr)
Return the context name.
@ AV_CLASS_CATEGORY_FILTER
const AVOption ff_yadif_options[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void(* filter)(AVFilterContext *ctx, AVFrame *dstpic, int parity, int tff)
static void filter(AVFilterContext *ctx, AVFrame *dst, int parity, int tff)
const unsigned char ff_vf_bwdif_cuda_ptx_data[]
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
static void uninit(AVBSFContext *ctx)
#define i(width, name, range_min, range_max)
const AVFilter ff_vf_bwdif_cuda
const char * name
Pad name.
This struct describes a set or pool of "hardware" frames (i.e.
This struct is allocated as AVHWDeviceContext.hwctx.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame.
static const AVFilterPad deint_cuda_inputs[]
@ YADIF_FIELD_END
The first or last field in a sequence.
int ff_yadif_request_frame(AVFilterLink *link)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
@ YADIF_FIELD_NORMAL
A normal field in the middle of a sequence.
int initial_pool_size
Initial size of the frame pool.
A reference to a data buffer.
void ff_yadif_uninit(AVFilterContext *ctx)
int current_field
YADIFCurrentField.
#define FILTER_OUTPUTS(array)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
static av_cold void deint_cuda_uninit(AVFilterContext *ctx)
CUfunction cu_func_ushort
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static const AVFilterPad deint_cuda_outputs[]
int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame)
int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link, int default_pool_size)
Perform any additional setup required for hardware frames.