FFmpeg
Data Structures | Macros | Functions | Variables
vf_overlay_cuda.c File Reference
#include "libavutil/log.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_cuda_internal.h"
#include "libavutil/cuda_check.h"
#include "avfilter.h"
#include "framesync.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  OverlayCUDAContext
 OverlayCUDAContext. More...
 

Macros

#define CHECK_CU(x)   FF_CUDA_CHECK_DL(ctx, ctx->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(OverlayCUDAContext, x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
 

Functions

static int format_is_supported (const enum AVPixelFormat formats[], enum AVPixelFormat fmt)
 Helper to find out if provided format is supported by filter. More...
 
static int formats_match (const enum AVPixelFormat format_main, const enum AVPixelFormat format_overlay)
 Helper checks if we can process main and overlay pixel formats. More...
 
static int overlay_cuda_call_kernel (OverlayCUDAContext *ctx, int x_position, int y_position, uint8_t *main_data, int main_linesize, int main_width, int main_height, uint8_t *overlay_data, int overlay_linesize, int overlay_width, int overlay_height, uint8_t *alpha_data, int alpha_linesize, int alpha_adj_x, int alpha_adj_y)
 Call overlay kernell for a plane. More...
 
static int overlay_cuda_blend (FFFrameSync *fs)
 Perform blend overlay picture over main picture. More...
 
static av_cold int overlay_cuda_init (AVFilterContext *avctx)
 Initialize overlay_cuda. More...
 
static av_cold void overlay_cuda_uninit (AVFilterContext *avctx)
 Uninitialize overlay_cuda. More...
 
static int overlay_cuda_activate (AVFilterContext *avctx)
 Activate overlay_cuda. More...
 
static int overlay_cuda_query_formats (AVFilterContext *avctx)
 Query formats. More...
 
static int overlay_cuda_config_output (AVFilterLink *outlink)
 Configure output. More...
 
 FRAMESYNC_DEFINE_CLASS (overlay_cuda, OverlayCUDAContext, fs)
 

Variables

static enum AVPixelFormat supported_main_formats []
 
static enum AVPixelFormat supported_overlay_formats []
 
static const AVOption overlay_cuda_options []
 
static const AVFilterPad overlay_cuda_inputs []
 
static const AVFilterPad overlay_cuda_outputs []
 
AVFilter ff_vf_overlay_cuda
 

Detailed Description

Overlay one video on top of another using cuda hardware acceleration

Definition in file vf_overlay_cuda.c.

Macro Definition Documentation

◆ CHECK_CU

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

Definition at line 38 of file vf_overlay_cuda.c.

◆ DIV_UP

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

Definition at line 39 of file vf_overlay_cuda.c.

◆ BLOCK_X

#define BLOCK_X   32

Definition at line 41 of file vf_overlay_cuda.c.

◆ BLOCK_Y

#define BLOCK_Y   16

Definition at line 42 of file vf_overlay_cuda.c.

◆ OFFSET

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

Definition at line 396 of file vf_overlay_cuda.c.

◆ FLAGS

Definition at line 397 of file vf_overlay_cuda.c.

Function Documentation

◆ format_is_supported()

static int format_is_supported ( const enum AVPixelFormat  formats[],
enum AVPixelFormat  fmt 
)
static

Helper to find out if provided format is supported by filter.

Definition at line 84 of file vf_overlay_cuda.c.

Referenced by overlay_cuda_config_output().

◆ formats_match()

static int formats_match ( const enum AVPixelFormat  format_main,
const enum AVPixelFormat  format_overlay 
)
static

Helper checks if we can process main and overlay pixel formats.

Definition at line 95 of file vf_overlay_cuda.c.

Referenced by overlay_cuda_config_output().

◆ overlay_cuda_call_kernel()

static int overlay_cuda_call_kernel ( OverlayCUDAContext ctx,
int  x_position,
int  y_position,
uint8_t main_data,
int  main_linesize,
int  main_width,
int  main_height,
uint8_t overlay_data,
int  overlay_linesize,
int  overlay_width,
int  overlay_height,
uint8_t alpha_data,
int  alpha_linesize,
int  alpha_adj_x,
int  alpha_adj_y 
)
static

Call overlay kernell for a plane.

Definition at line 110 of file vf_overlay_cuda.c.

Referenced by overlay_cuda_blend().

◆ overlay_cuda_blend()

static int overlay_cuda_blend ( FFFrameSync fs)
static

Perform blend overlay picture over main picture.

Definition at line 141 of file vf_overlay_cuda.c.

Referenced by overlay_cuda_init().

◆ overlay_cuda_init()

static av_cold int overlay_cuda_init ( AVFilterContext avctx)
static

Initialize overlay_cuda.

Definition at line 236 of file vf_overlay_cuda.c.

◆ overlay_cuda_uninit()

static av_cold void overlay_cuda_uninit ( AVFilterContext avctx)
static

Uninitialize overlay_cuda.

Definition at line 247 of file vf_overlay_cuda.c.

◆ overlay_cuda_activate()

static int overlay_cuda_activate ( AVFilterContext avctx)
static

Activate overlay_cuda.

Definition at line 268 of file vf_overlay_cuda.c.

◆ overlay_cuda_query_formats()

static int overlay_cuda_query_formats ( AVFilterContext avctx)
static

Query formats.

Definition at line 278 of file vf_overlay_cuda.c.

◆ overlay_cuda_config_output()

static int overlay_cuda_config_output ( AVFilterLink outlink)
static

Configure output.

Definition at line 292 of file vf_overlay_cuda.c.

◆ FRAMESYNC_DEFINE_CLASS()

FRAMESYNC_DEFINE_CLASS ( overlay_cuda  ,
OverlayCUDAContext  ,
fs   
)

Variable Documentation

◆ supported_main_formats

enum AVPixelFormat supported_main_formats[]
static
Initial value:

Definition at line 44 of file vf_overlay_cuda.c.

Referenced by overlay_cuda_config_output().

◆ supported_overlay_formats

enum AVPixelFormat supported_overlay_formats[]
static

◆ overlay_cuda_options

const AVOption overlay_cuda_options[]
static
Initial value:
= {
{ "x", "Overlay x position",
OFFSET(x_position), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, .flags = FLAGS },
{ "y", "Overlay y position",
OFFSET(y_position), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, .flags = FLAGS },
{ "eof_action", "Action to take when encountering EOF from secondary input ",
OFFSET(fs.opt_eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT },
EOF_ACTION_REPEAT, EOF_ACTION_PASS, .flags = FLAGS, "eof_action" },
{ "repeat", "Repeat the previous frame.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, "eof_action" },
{ "endall", "End both streams.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ENDALL }, .flags = FLAGS, "eof_action" },
{ "pass", "Pass through the main input.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS }, .flags = FLAGS, "eof_action" },
{ "shortest", "force termination when the shortest input terminates", OFFSET(fs.opt_shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
{ "repeatlast", "repeat overlay of the last overlay frame", OFFSET(fs.opt_repeatlast), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS },
{ NULL },
}

Definition at line 399 of file vf_overlay_cuda.c.

◆ overlay_cuda_inputs

const AVFilterPad overlay_cuda_inputs[]
static
Initial value:
= {
{
.name = "main",
},
{
.name = "overlay",
},
{ NULL }
}

Definition at line 417 of file vf_overlay_cuda.c.

◆ overlay_cuda_outputs

const AVFilterPad overlay_cuda_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = &overlay_cuda_config_output,
},
{ NULL }
}

Definition at line 429 of file vf_overlay_cuda.c.

◆ ff_vf_overlay_cuda

AVFilter ff_vf_overlay_cuda
Initial value:
= {
.name = "overlay_cuda",
.description = NULL_IF_CONFIG_SMALL("Overlay one video on top of another using CUDA"),
.priv_size = sizeof(OverlayCUDAContext),
.priv_class = &overlay_cuda_class,
.preinit = overlay_cuda_framesync_preinit,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}

Definition at line 438 of file vf_overlay_cuda.c.

init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
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:339
overlay_cuda_inputs
static const AVFilterPad overlay_cuda_inputs[]
Definition: vf_overlay_cuda.c:417
EOF_ACTION_ENDALL
@ EOF_ACTION_ENDALL
Definition: framesync.h:28
overlay_cuda_outputs
static const AVFilterPad overlay_cuda_outputs[]
Definition: vf_overlay_cuda.c:429
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:101
OFFSET
#define OFFSET(x)
Definition: vf_overlay_cuda.c:396
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
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:66
EOF_ACTION_PASS
@ EOF_ACTION_PASS
Definition: framesync.h:29
overlay_cuda_config_output
static int overlay_cuda_config_output(AVFilterLink *outlink)
Configure output.
Definition: vf_overlay_cuda.c:292
NULL
#define NULL
Definition: coverity.c:32
fs
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:259
activate
filter_frame For filters that do not use the activate() callback
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
overlay_cuda_init
static av_cold int overlay_cuda_init(AVFilterContext *avctx)
Initialize overlay_cuda.
Definition: vf_overlay_cuda.c:236
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:117
FLAGS
#define FLAGS
Definition: vf_overlay_cuda.c:397
OverlayCUDAContext
OverlayCUDAContext.
Definition: vf_overlay_cuda.c:60
overlay_cuda_uninit
static av_cold void overlay_cuda_uninit(AVFilterContext *avctx)
Uninitialize overlay_cuda.
Definition: vf_overlay_cuda.c:247
overlay_cuda_query_formats
static int overlay_cuda_query_formats(AVFilterContext *avctx)
Query formats.
Definition: vf_overlay_cuda.c:278
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:89
EOF_ACTION_REPEAT
@ EOF_ACTION_REPEAT
Definition: framesync.h:27
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
overlay_cuda_activate
static int overlay_cuda_activate(AVFilterContext *avctx)
Activate overlay_cuda.
Definition: vf_overlay_cuda.c:268
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:242
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: aeval.c:243
uninit
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:279
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234