FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
vf_pad_cuda.c File Reference
#include <float.h>
#include "filters.h"
#include "libavutil/avstring.h"
#include "libavutil/common.h"
#include "libavutil/cuda_check.h"
#include "libavutil/eval.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_cuda_internal.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/colorspace.h"
#include "cuda/load_helper.h"

Go to the source code of this file.

Data Structures

struct  CUDAPadContext
 

Macros

#define CHECK_CU(x)   FF_CUDA_CHECK_DL(ctx, device_hwctx->internal->cuda_dl, x)
 
#define DIV_UP(a, b)   ( ((a) + (b) - 1) / (b) )
 
#define BLOCK_X   32
 
#define BLOCK_Y   16
 
#define OFFSET(x)   offsetof(CUDAPadContext, x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
 

Enumerations

enum  {
  VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH,
  VAR_OUT_W, VAR_OW, VAR_OUT_H, VAR_OH,
  VAR_X, VAR_Y, VAR_A, VAR_SAR,
  VAR_DAR, VAR_HSUB, VAR_VSUB, VARS_NB
}
 
enum  EvalMode {
  EVAL_MODE_ONCE, EVAL_MODE_FRAME, EVAL_MODE_NB, EVAL_MODE_INIT,
  EVAL_MODE_FRAME, EVAL_MODE_NB, EVAL_MODE_INIT, EVAL_MODE_FRAME,
  EVAL_MODE_NB, EVAL_MODE_INIT, EVAL_MODE_FRAME, EVAL_MODE_NB,
  EVAL_MODE_INIT, EVAL_MODE_FRAME, EVAL_MODE_NB, EVAL_MODE_INIT,
  EVAL_MODE_FRAME, EVAL_MODE_NB, EVAL_MODE_INIT, EVAL_MODE_FRAME,
  EVAL_MODE_NB, EVAL_MODE_INIT, EVAL_MODE_FRAME, EVAL_MODE_NB,
  EVAL_MODE_INIT, EVAL_MODE_FRAME, EVAL_MODE_NB, EVAL_MODE_INIT,
  EVAL_MODE_FRAME, EVAL_MODE_NB
}
 

Functions

static int eval_expr (AVFilterContext *ctx)
 
static int cuda_pad_alloc_out_frames_ctx (AVFilterContext *ctx, AVBufferRef **out_frames_ctx, const int width, const int height)
 
static av_cold int cuda_pad_init (AVFilterContext *ctx)
 
static av_cold void cuda_pad_uninit (AVFilterContext *ctx)
 
static av_cold int cuda_pad_load_functions (AVFilterContext *ctx)
 
static int cuda_pad_config_props (AVFilterLink *outlink)
 
static int cuda_pad_pad (AVFilterContext *ctx, AVFrame *out, const AVFrame *in)
 
static int cuda_pad_filter_frame (AVFilterLink *inlink, AVFrame *in)
 

Variables

static enum AVPixelFormat supported_formats []
 
static const char *const var_names []
 
static const AVOption cuda_pad_options []
 
static const AVClass cuda_pad_class
 
static const AVFilterPad cuda_pad_inputs []
 
static const AVFilterPad cuda_pad_outputs []
 
const FFFilter ff_vf_pad_cuda
 

Detailed Description

CUDA video padding filter

Definition in file vf_pad_cuda.c.

Macro Definition Documentation

◆ CHECK_CU

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

Definition at line 41 of file vf_pad_cuda.c.

◆ DIV_UP

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

Definition at line 42 of file vf_pad_cuda.c.

◆ BLOCK_X

#define BLOCK_X   32

Definition at line 43 of file vf_pad_cuda.c.

◆ BLOCK_Y

#define BLOCK_Y   16

Definition at line 44 of file vf_pad_cuda.c.

◆ OFFSET

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

Definition at line 584 of file vf_pad_cuda.c.

◆ FLAGS

Definition at line 585 of file vf_pad_cuda.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
VAR_IN_W 
VAR_IW 
VAR_IN_H 
VAR_IH 
VAR_OUT_W 
VAR_OW 
VAR_OUT_H 
VAR_OH 
VAR_X 
VAR_Y 
VAR_A 
VAR_SAR 
VAR_DAR 
VAR_HSUB 
VAR_VSUB 
VARS_NB 

Definition at line 97 of file vf_pad_cuda.c.

◆ EvalMode

enum EvalMode
Enumerator
EVAL_MODE_ONCE 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 
EVAL_MODE_INIT 
EVAL_MODE_FRAME 
EVAL_MODE_NB 

Definition at line 116 of file vf_pad_cuda.c.

Function Documentation

◆ eval_expr()

static int eval_expr ( AVFilterContext ctx)
static

Definition at line 122 of file vf_pad_cuda.c.

Referenced by cuda_pad_config_props(), and cuda_pad_filter_frame().

◆ cuda_pad_alloc_out_frames_ctx()

static int cuda_pad_alloc_out_frames_ctx ( AVFilterContext ctx,
AVBufferRef **  out_frames_ctx,
const int  width,
const int  height 
)
static

Definition at line 239 of file vf_pad_cuda.c.

Referenced by cuda_pad_config_props(), and cuda_pad_filter_frame().

◆ cuda_pad_init()

static av_cold int cuda_pad_init ( AVFilterContext ctx)
static

Definition at line 268 of file vf_pad_cuda.c.

◆ cuda_pad_uninit()

static av_cold void cuda_pad_uninit ( AVFilterContext ctx)
static

Definition at line 278 of file vf_pad_cuda.c.

◆ cuda_pad_load_functions()

static av_cold int cuda_pad_load_functions ( AVFilterContext ctx)
static

Definition at line 297 of file vf_pad_cuda.c.

Referenced by cuda_pad_config_props().

◆ cuda_pad_config_props()

static int cuda_pad_config_props ( AVFilterLink outlink)
static

Definition at line 336 of file vf_pad_cuda.c.

◆ cuda_pad_pad()

static int cuda_pad_pad ( AVFilterContext ctx,
AVFrame out,
const AVFrame in 
)
static

Definition at line 403 of file vf_pad_cuda.c.

Referenced by cuda_pad_filter_frame().

◆ cuda_pad_filter_frame()

static int cuda_pad_filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 479 of file vf_pad_cuda.c.

Variable Documentation

◆ supported_formats

enum AVPixelFormat supported_formats[]
static

◆ var_names

const char* const var_names[]
static
Initial value:
= {
"in_w", "iw",
"in_h", "ih",
"out_w", "ow",
"out_h", "oh",
"x",
"y",
"a",
"sar",
"dar",
"hsub",
"vsub",
}

Definition at line 82 of file vf_pad_cuda.c.

Referenced by eval_expr().

◆ cuda_pad_options

const AVOption cuda_pad_options[]
static
Initial value:
= {
{ "width", "set the pad area width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, 0, 0, FLAGS },
{ "w", "set the pad area width expression", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, 0, 0, FLAGS },
{ "height", "set the pad area height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, 0, 0, FLAGS },
{ "h", "set the pad area height expression", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, 0, 0, FLAGS },
{ "x", "set the x offset expression for the input image position", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = "0"}, 0, 0, FLAGS },
{ "y", "set the y offset expression for the input image position", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = "0"}, 0, 0, FLAGS },
{ "color", "set the color of the padded area border", OFFSET(rgba_color), AV_OPT_TYPE_COLOR, {.str = "black"}, .flags = FLAGS },
{ "eval", "specify when to evaluate expressions", OFFSET(eval_mode), AV_OPT_TYPE_INT, {.i64 = EVAL_MODE_INIT}, 0, EVAL_MODE_NB-1, FLAGS, .unit = "eval" },
{ "init", "eval expressions once during initialization", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_INIT}, .flags = FLAGS, .unit = "eval" },
{ "frame", "eval expressions during initialization and per-frame", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_FRAME}, .flags = FLAGS, .unit = "eval" },
{ "aspect", "pad to fit an aspect instead of a resolution", OFFSET(aspect), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, DBL_MAX, FLAGS },
{ NULL }
}

Definition at line 587 of file vf_pad_cuda.c.

◆ cuda_pad_class

const AVClass cuda_pad_class
static
Initial value:
= {
.class_name = "pad_cuda",
.item_name = av_default_item_name,
.option = cuda_pad_options,
}

Definition at line 602 of file vf_pad_cuda.c.

◆ cuda_pad_inputs

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

Definition at line 609 of file vf_pad_cuda.c.

◆ cuda_pad_outputs

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

Definition at line 615 of file vf_pad_cuda.c.

◆ ff_vf_pad_cuda

const FFFilter ff_vf_pad_cuda
Initial value:
= {
.p.name = "pad_cuda",
.p.description = NULL_IF_CONFIG_SMALL("CUDA-based GPU padding filter"),
.init = cuda_pad_init,
.uninit = cuda_pad_uninit,
.p.priv_class = &cuda_pad_class,
.priv_size = sizeof(CUDAPadContext),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}

Definition at line 621 of file vf_pad_cuda.c.

AV_PIX_FMT_CUDA
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
Definition: pixfmt.h:260
cuda_pad_outputs
static const AVFilterPad cuda_pad_outputs[]
Definition: vf_pad_cuda.c:615
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:263
AV_OPT_TYPE_RATIONAL
@ AV_OPT_TYPE_RATIONAL
Underlying C type is AVRational.
Definition: opt.h:280
cuda_pad_inputs
static const AVFilterPad cuda_pad_inputs[]
Definition: vf_pad_cuda.c:609
cuda_pad_options
static const AVOption cuda_pad_options[]
Definition: vf_pad_cuda.c:587
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:108
EVAL_MODE_NB
@ EVAL_MODE_NB
Definition: vf_pad_cuda.c:119
FLAGS
#define FLAGS
Definition: vf_pad_cuda.c:585
cuda_pad_class
static const AVClass cuda_pad_class
Definition: vf_pad_cuda.c:602
EVAL_MODE_FRAME
@ EVAL_MODE_FRAME
Definition: vf_pad_cuda.c:118
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_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:264
cuda_pad_config_props
static int cuda_pad_config_props(AVFilterLink *outlink)
Definition: vf_pad_cuda.c:336
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
EVAL_MODE_INIT
@ EVAL_MODE_INIT
Definition: vf_pad_cuda.c:117
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
Definition: opt.h:323
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:240
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: filters.h:207
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:94
CUDAPadContext
Definition: vf_pad_cuda.c:54
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:174
cuda_pad_filter_frame
static int cuda_pad_filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_pad_cuda.c:479
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
OFFSET
#define OFFSET(x)
Definition: vf_pad_cuda.c:584
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
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:200
cuda_pad_uninit
static av_cold void cuda_pad_uninit(AVFilterContext *ctx)
Definition: vf_pad_cuda.c:278
cuda_pad_init
static av_cold int cuda_pad_init(AVFilterContext *ctx)
Definition: vf_pad_cuda.c:268
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:253