FFmpeg
Data Structures | Macros | Functions | Variables
vf_bilateral_cuda.c File Reference
#include <float.h>
#include <stdio.h>
#include "libavutil/common.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_cuda_internal.h"
#include "libavutil/cuda_check.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "internal.h"
#include "cuda/load_helper.h"

Go to the source code of this file.

Data Structures

struct  CUDABilateralContext
 

Macros

#define DIV_UP(a, b)   ( ((a) + (b) - 1) / (b) )
 
#define BLOCKX   32
 
#define BLOCKY   16
 
#define CHECK_CU(x)   FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)
 
#define OFFSET(x)   offsetof(CUDABilateralContext, x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
 

Functions

static av_cold int cudabilateral_init (AVFilterContext *ctx)
 
static av_cold void cudabilateral_uninit (AVFilterContext *ctx)
 
static av_cold int init_hwframe_ctx (CUDABilateralContext *s, AVBufferRef *device_ctx, int width, int height)
 
static int format_is_supported (enum AVPixelFormat fmt)
 
static av_cold void set_format_info (AVFilterContext *ctx, enum AVPixelFormat in_format, enum AVPixelFormat out_format)
 
static av_cold int init_processing_chain (AVFilterContext *ctx, int width, int height)
 
static av_cold int cuda_bilateral_load_functions (AVFilterContext *ctx)
 
static av_cold int cuda_bilateral_config_props (AVFilterLink *outlink)
 
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)
 
static int cuda_bilateral_process_internal (AVFilterContext *ctx, AVFrame *out, AVFrame *in)
 
static int cuda_bilateral_process (AVFilterContext *ctx, AVFrame *out, AVFrame *in)
 
static int cuda_bilateral_filter_frame (AVFilterLink *link, AVFrame *in)
 

Variables

static enum AVPixelFormat supported_formats []
 
static const AVOption options []
 
static const AVClass cuda_bilateral_class
 
static const AVFilterPad cuda_bilateral_inputs []
 
static const AVFilterPad cuda_bilateral_outputs []
 
const AVFilter ff_vf_bilateral_cuda
 

Macro Definition Documentation

◆ DIV_UP

#define DIV_UP (   a,
  b 
)    ( ((a) + (b) - 1) / (b) )

Definition at line 43 of file vf_bilateral_cuda.c.

◆ BLOCKX

#define BLOCKX   32

Definition at line 44 of file vf_bilateral_cuda.c.

◆ BLOCKY

#define BLOCKY   16

Definition at line 45 of file vf_bilateral_cuda.c.

◆ CHECK_CU

#define CHECK_CU (   x)    FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)

Definition at line 47 of file vf_bilateral_cuda.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(CUDABilateralContext, x)

Definition at line 427 of file vf_bilateral_cuda.c.

◆ FLAGS

Definition at line 428 of file vf_bilateral_cuda.c.

Function Documentation

◆ cudabilateral_init()

static av_cold int cudabilateral_init ( AVFilterContext ctx)
static

Definition at line 75 of file vf_bilateral_cuda.c.

◆ cudabilateral_uninit()

static av_cold void cudabilateral_uninit ( AVFilterContext ctx)
static

Definition at line 90 of file vf_bilateral_cuda.c.

◆ init_hwframe_ctx()

static av_cold int init_hwframe_ctx ( CUDABilateralContext s,
AVBufferRef device_ctx,
int  width,
int  height 
)
static

Definition at line 109 of file vf_bilateral_cuda.c.

Referenced by init_processing_chain().

◆ format_is_supported()

static int format_is_supported ( enum AVPixelFormat  fmt)
static

Definition at line 143 of file vf_bilateral_cuda.c.

Referenced by init_processing_chain().

◆ set_format_info()

static av_cold void set_format_info ( AVFilterContext ctx,
enum AVPixelFormat  in_format,
enum AVPixelFormat  out_format 
)
static

Definition at line 153 of file vf_bilateral_cuda.c.

Referenced by init_processing_chain().

◆ init_processing_chain()

static av_cold int init_processing_chain ( AVFilterContext ctx,
int  width,
int  height 
)
static

Definition at line 179 of file vf_bilateral_cuda.c.

Referenced by cuda_bilateral_config_props().

◆ cuda_bilateral_load_functions()

static av_cold int cuda_bilateral_load_functions ( AVFilterContext ctx)
static

Definition at line 210 of file vf_bilateral_cuda.c.

Referenced by cuda_bilateral_config_props().

◆ cuda_bilateral_config_props()

static av_cold int cuda_bilateral_config_props ( AVFilterLink outlink)
static

Definition at line 247 of file vf_bilateral_cuda.c.

◆ call_cuda_kernel()

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 
)
static

Definition at line 275 of file vf_bilateral_cuda.c.

Referenced by cuda_bilateral_process_internal().

◆ cuda_bilateral_process_internal()

static int cuda_bilateral_process_internal ( AVFilterContext ctx,
AVFrame out,
AVFrame in 
)
static

Definition at line 306 of file vf_bilateral_cuda.c.

Referenced by cuda_bilateral_process().

◆ cuda_bilateral_process()

static int cuda_bilateral_process ( AVFilterContext ctx,
AVFrame out,
AVFrame in 
)
static

Definition at line 367 of file vf_bilateral_cuda.c.

Referenced by cuda_bilateral_filter_frame().

◆ cuda_bilateral_filter_frame()

static int cuda_bilateral_filter_frame ( AVFilterLink link,
AVFrame in 
)
static

Definition at line 392 of file vf_bilateral_cuda.c.

Variable Documentation

◆ supported_formats

enum AVPixelFormat supported_formats[]
static
Initial value:

Definition at line 37 of file vf_bilateral_cuda.c.

Referenced by format_is_supported().

◆ options

const AVOption options[]
static
Initial value:
= {
{ "sigmaS", "set spatial sigma", OFFSET(sigmaS), AV_OPT_TYPE_FLOAT, {.dbl=0.1}, 0.1, 512, FLAGS },
{ "sigmaR", "set range sigma", OFFSET(sigmaR), AV_OPT_TYPE_FLOAT, {.dbl=0.1}, 0.1, 512, FLAGS },
{ "window_size", "set neighbours window_size", OFFSET(window_size), AV_OPT_TYPE_INT, {.i64=1}, 1, 255, FLAGS },
{ NULL }
}

Definition at line 429 of file vf_bilateral_cuda.c.

◆ cuda_bilateral_class

const AVClass cuda_bilateral_class
static
Initial value:
= {
.class_name = "cudabilateral",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 436 of file vf_bilateral_cuda.c.

◆ cuda_bilateral_inputs

const AVFilterPad cuda_bilateral_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = cuda_bilateral_filter_frame,
},
}

Definition at line 443 of file vf_bilateral_cuda.c.

◆ cuda_bilateral_outputs

const AVFilterPad cuda_bilateral_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = cuda_bilateral_config_props,
},
}

Definition at line 451 of file vf_bilateral_cuda.c.

◆ ff_vf_bilateral_cuda

const AVFilter ff_vf_bilateral_cuda
Initial value:
= {
.name = "bilateral_cuda",
.description = NULL_IF_CONFIG_SMALL("GPU accelerated bilateral filter"),
.priv_size = sizeof(CUDABilateralContext),
.priv_class = &cuda_bilateral_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}

Definition at line 459 of file vf_bilateral_cuda.c.

AV_PIX_FMT_CUDA
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
Definition: pixfmt.h:260
FF_FILTER_FLAG_HWFRAME_AWARE
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition: internal.h:351
options
static const AVOption options[]
Definition: vf_bilateral_cuda.c:429
cuda_bilateral_filter_frame
static int cuda_bilateral_filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_bilateral_cuda.c:392
cuda_bilateral_inputs
static const AVFilterPad cuda_bilateral_inputs[]
Definition: vf_bilateral_cuda.c:443
CUDABilateralContext
Definition: vf_bilateral_cuda.c:50
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
FLAGS
#define FLAGS
Definition: vf_bilateral_cuda.c:428
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
cudabilateral_init
static av_cold int cudabilateral_init(AVFilterContext *ctx)
Definition: vf_bilateral_cuda.c:75
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:106
cuda_bilateral_outputs
static const AVFilterPad cuda_bilateral_outputs[]
Definition: vf_bilateral_cuda.c:451
cudabilateral_uninit
static av_cold void cudabilateral_uninit(AVFilterContext *ctx)
Definition: vf_bilateral_cuda.c:90
cuda_bilateral_config_props
static av_cold int cuda_bilateral_config_props(AVFilterLink *outlink)
Definition: vf_bilateral_cuda.c:247
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:238
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:172
AV_PIX_FMT_NV12
@ 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...
Definition: pixfmt.h:96
cuda_bilateral_class
static const AVClass cuda_bilateral_class
Definition: vf_bilateral_cuda.c:436
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
OFFSET
#define OFFSET(x)
Definition: vf_bilateral_cuda.c:427
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183