49#define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) )
50#define ALIGN_UP(a, b) (((a) + (b) - 1) & ~((b) - 1))
54#define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)
57 CUdeviceptr prev, CUdeviceptr cur, CUdeviceptr next,
66 int parity,
int tff,
int clip_max)
70 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
71 CUtexObject tex_prev = 0, tex_cur = 0, tex_next = 0;
75 void *args[] = { &
dst, &tex_prev, &tex_cur, &tex_next,
76 &dst_width, &dst_height, &dst_pitch,
77 &src_width, &src_height, &
parity, &tff,
78 &is_field_end, &clip_max };
80 CUDA_TEXTURE_DESC tex_desc = {
81 .filterMode = CU_TR_FILTER_MODE_POINT,
82 .flags = CU_TRSF_READ_AS_INTEGER,
85 CUDA_RESOURCE_DESC res_desc = {
86 .resType = CU_RESOURCE_TYPE_PITCH2D,
87 .res.pitch2D.format =
format,
89 .res.pitch2D.width = src_width,
90 .res.pitch2D.height = src_height,
91 .res.pitch2D.pitchInBytes = src_pitch,
94 res_desc.res.pitch2D.devPtr = (CUdeviceptr)prev;
95 ret =
CHECK_CU(cu->cuTexObjectCreate(&tex_prev, &res_desc, &tex_desc,
NULL));
99 res_desc.res.pitch2D.devPtr = (CUdeviceptr)cur;
100 ret =
CHECK_CU(cu->cuTexObjectCreate(&tex_cur, &res_desc, &tex_desc,
NULL));
104 res_desc.res.pitch2D.devPtr = (CUdeviceptr)next;
105 ret =
CHECK_CU(cu->cuTexObjectCreate(&tex_next, &res_desc, &tex_desc,
NULL));
112 0,
s->hwctx->stream, args,
NULL));
116 CHECK_CU(cu->cuTexObjectDestroy(tex_prev));
118 CHECK_CU(cu->cuTexObjectDestroy(tex_cur));
120 CHECK_CU(cu->cuTexObjectDestroy(tex_next));
130 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
134 ret =
CHECK_CU(cu->cuCtxPushCurrent(
s->hwctx->cuda_ctx));
144 if (
comp->plane <
i) {
150 pixel_size = (
comp->depth +
comp->shift) / 8;
152 if (pixel_size > 2 ||
channels > 2) {
156 switch (pixel_size) {
159 format = CU_AD_FORMAT_UNSIGNED_INT8;
163 format = CU_AD_FORMAT_UNSIGNED_INT16;
170 clip_max = (1 << (
comp->depth +
comp->shift)) - 1;
173 "Deinterlacing plane %d: pixel_size: %d channels: %d\n",
183 (CUdeviceptr)
dst->data[
i],
204 if (
s->hwctx &&
s->cu_module) {
205 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
206 CHECK_CU(cu->cuCtxPushCurrent(
s->hwctx->cuda_ctx));
207 CHECK_CU(cu->cuModuleUnload(
s->cu_module));
216 s->input_frames =
NULL;
227 "required to associate the processing device.\n");
232 if (!
s->input_frames_ref) {
255 if (!
s->device_ref) {
261 cu =
s->hwctx->internal->cuda_dl;
274 output_frames->
sw_format =
s->input_frames->sw_format;
275 output_frames->
width =
ctx->inputs[0]->w;
276 output_frames->
height =
ctx->inputs[0]->h;
287 "context for output: %d\n", ret);
304 ret =
CHECK_CU(cu->cuCtxPushCurrent(
s->hwctx->cuda_ctx));
312 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func_uchar,
s->cu_module,
"bwdif_uchar"));
316 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func_uchar2,
s->cu_module,
"bwdif_uchar2"));
320 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func_ushort,
s->cu_module,
"bwdif_ushort"));
324 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func_ushort2,
s->cu_module,
"bwdif_ushort2"));
335 .class_name =
"bwdif_cuda",
361 .p.name =
"bwdif_cuda",
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static int config_input(AVFilterLink *inlink)
static const char *const format[]
const FFFilter ff_vf_bwdif_cuda
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link, int default_pool_size)
Perform any additional setup required for hardware frames.
#define i(width, name, range_min, range_max)
#define AV_CEIL_RSHIFT(a, b)
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
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 AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
#define LIBAVUTIL_VERSION_INT
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.
FFmpeg internal API for CUDA.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
int(* func)(AVBPrint *dst, const char *in, const char *arg)
#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 NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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.
@ AV_CLASS_CATEGORY_FILTER
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
A reference to a data buffer.
uint8_t * data
The data buffer.
This struct is allocated as AVHWDeviceContext.hwctx.
Describe the class of an AVClass context structure.
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
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
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.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
int initial_pool_size
Initial size of the frame pool.
int width
The allocated dimensions of the frames in this pool.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
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.
uint8_t nb_components
The number of components each pixel has, (1-4)
AVCUDADeviceContext * hwctx
AVHWFramesContext * input_frames
CUfunction cu_func_uchar2
CUfunction cu_func_ushort2
AVBufferRef * input_frames_ref
CUfunction cu_func_ushort
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.
void(* filter)(AVFilterContext *ctx, AVFrame *dstpic, int parity, int tff)
int current_field
YADIFCurrentField.
const AVPixFmtDescriptor * csp
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
static const AVClass bwdif_cuda_class
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)
static av_cold void deint_cuda_uninit(AVFilterContext *ctx)
static int config_input(AVFilterLink *inlink)
const unsigned int ff_vf_bwdif_cuda_ptx_len
static const AVFilterPad deint_cuda_inputs[]
const unsigned char ff_vf_bwdif_cuda_ptx_data[]
static int config_output(AVFilterLink *link)
static const AVFilterPad deint_cuda_outputs[]
@ YADIF_FIELD_NORMAL
A normal field in the middle of a sequence.
@ YADIF_FIELD_END
The first or last field in a sequence.
int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame)
int ff_yadif_request_frame(AVFilterLink *link)
const AVOption ff_yadif_options[]
void ff_yadif_uninit(AVFilterContext *ctx)
int ff_yadif_config_output_common(AVFilterLink *outlink)