Go to the documentation of this file.
44 #define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) )
48 #define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)
74 if (
s->hwctx &&
s->cu_module) {
75 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
78 CHECK_CU(cu->cuCtxPushCurrent(
s->hwctx->cuda_ctx));
79 CHECK_CU(cu->cuModuleUnload(
s->cu_module));
81 CHECK_CU(cu->cuCtxPopCurrent(&bilateral));
107 for (
i = 0;
i <
s->in_desc->nb_components;
i++) {
108 d = (
s->in_desc->comp[
i].depth + 7) / 8;
109 p =
s->in_desc->comp[
i].plane;
110 s->in_plane_channels[
p] =
FFMAX(
s->in_plane_channels[
p],
s->in_desc->comp[
i].step / d);
144 CUcontext bilateral, cuda_ctx =
s->hwctx->cuda_ctx;
145 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
148 extern const unsigned char ff_vf_bilateral_cuda_ptx_data[];
149 extern const unsigned int ff_vf_bilateral_cuda_ptx_len;
156 ff_vf_bilateral_cuda_ptx_data, ff_vf_bilateral_cuda_ptx_len);
160 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func,
s->cu_module,
"Process_uchar"));
166 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func_uv,
s->cu_module,
"Process_uchar2"));
173 CHECK_CU(cu->cuCtxPopCurrent(&bilateral));
195 s->hwctx = device_hwctx;
196 s->cu_stream =
s->hwctx->stream;
211 CUtexObject src_tex[3],
AVFrame *out_frame,
213 int width_uv,
int height_uv,
int pitch_uv,
214 int window_size,
float sigmaS,
float sigmaR)
217 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
220 CUdeviceptr dst_devptr[3] = {
221 (CUdeviceptr)out_frame->
data[0], (CUdeviceptr)out_frame->
data[1], (CUdeviceptr)out_frame->
data[2]
224 void *args_uchar[] = {
225 &src_tex[0], &src_tex[1], &src_tex[2],
226 &dst_devptr[0], &dst_devptr[1], &dst_devptr[2],
228 &width_uv, &height_uv, &pitch_uv,
229 &window_size, &sigmaS, &sigmaR
245 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
246 CUcontext bilateral, cuda_ctx =
s->hwctx->cuda_ctx;
249 CUtexObject tex[3] = { 0, 0, 0 };
255 for (
i = 0;
i <
s->in_planes;
i++) {
256 CUDA_TEXTURE_DESC tex_desc = {
257 .filterMode = CU_TR_FILTER_MODE_LINEAR,
261 CUDA_RESOURCE_DESC res_desc = {
262 .resType = CU_RESOURCE_TYPE_PITCH2D,
263 .res.pitch2D.format = CU_AD_FORMAT_UNSIGNED_INT8,
264 .res.pitch2D.numChannels =
s->in_plane_channels[
i],
265 .res.pitch2D.pitchInBytes = in->
linesize[
i],
266 .res.pitch2D.devPtr = (CUdeviceptr)in->
data[
i],
269 if (
i == 1 ||
i == 2) {
273 res_desc.res.pitch2D.width = in->
width;
274 res_desc.res.pitch2D.height = in->
height;
284 out->width,
out->height,
out->linesize[0],
287 out->linesize[1] >> ((
s->in_plane_channels[1] > 1) ? 1 : 0),
288 s->window_size,
s->sigmaS,
s->sigmaR);
291 for (
i = 0;
i <
s->in_planes;
i++)
293 CHECK_CU(cu->cuTexObjectDestroy(tex[
i]));
295 CHECK_CU(cu->cuCtxPopCurrent(&bilateral));
305 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
317 ret =
CHECK_CU(cu->cuCtxPushCurrent(
s->hwctx->cuda_ctx));
341 #define OFFSET(x) offsetof(CUDABilateralContext, x)
342 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
374 .
p.
name =
"bilateral_cuda",
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
int(* func)(AVBPrint *dst, const char *in, const char *arg)
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
const AVPixFmtDescriptor * in_desc
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
AVPixelFormat
Pixel format.
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
static const AVOption options[]
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
AVCUDADeviceContext * hwctx
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
uint8_t * data
The data buffer.
static int call_cuda_kernel(AVFilterContext *ctx, CUfunction func, CUtexObject src_tex[3], AVFrame *out_frame, int width, int height, int pitch, int width_uv, int height_uv, int pitch_uv, int window_size, float sigmaS, float sigmaR)
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
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
static int cuda_bilateral_filter_frame(AVFilterLink *link, AVFrame *in)
static av_cold int init_processing_chain(AVFilterContext *ctx, int width, int height)
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
const char * name
Filter name.
A link between two filters.
static av_cold int cuda_bilateral_load_functions(AVFilterContext *ctx)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Link properties exposed to filter code, but not external callers.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
static const AVFilterPad cuda_bilateral_inputs[]
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
#define AV_CEIL_RSHIFT(a, b)
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
static int format_is_supported(enum AVPixelFormat fmt)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_OUTPUTS(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.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image format
AVFilterLink ** inputs
array of pointers to input links
const char * av_default_item_name(void *ptr)
Return the context name.
static int cuda_bilateral_process_internal(AVFilterContext *ctx, AVFrame *out, AVFrame *in)
static FilterLink * ff_filter_link(AVFilterLink *link)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const AVFilterPad cuda_bilateral_outputs[]
static av_cold void cudabilateral_uninit(AVFilterContext *ctx)
const FFFilter ff_vf_bilateral_cuda
AVFilterContext * src
source filter
static enum AVPixelFormat supported_formats[]
static av_cold int cuda_bilateral_config_props(AVFilterLink *outlink)
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
#define i(width, name, range_min, range_max)
int w
agreed upon image width
static av_cold void set_format_info(AVFilterContext *ctx, enum AVPixelFormat format)
const char * name
Pad name.
This struct describes a set or pool of "hardware" frames (i.e.
This struct is allocated as AVHWDeviceContext.hwctx.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
static const AVClass cuda_bilateral_class
int h
agreed upon image height
@ AV_OPT_TYPE_INT
Underlying C type is int.
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
AVFilter p
The public AVFilter.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data 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...
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
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.