FFmpeg
Data Structures | Macros | Functions | Variables
vf_overlay_cuda.c File Reference

Overlay one video on top of another using cuda hardware acceleration. More...

#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

#define CHECK_CU (   x)    FF_CUDA_CHECK_DL(ctx, ctx->hwctx->internal->cuda_dl, x)
#define DIV_UP (   a,
  b 
)    ( ((a) + (b) - 1) / (b) )

Definition at line 39 of file vf_overlay_cuda.c.

Referenced by overlay_cuda_call_kernel().

#define BLOCK_X   32

Definition at line 41 of file vf_overlay_cuda.c.

Referenced by overlay_cuda_call_kernel().

#define BLOCK_Y   16

Definition at line 42 of file vf_overlay_cuda.c.

Referenced by overlay_cuda_call_kernel().

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

Definition at line 383 of file vf_overlay_cuda.c.

Definition at line 384 of file vf_overlay_cuda.c.

Function Documentation

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 83 of file vf_overlay_cuda.c.

Referenced by overlay_cuda_config_output().

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 94 of file vf_overlay_cuda.c.

Referenced by overlay_cuda_config_output().

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 109 of file vf_overlay_cuda.c.

Referenced by overlay_cuda_blend().

static int overlay_cuda_blend ( FFFrameSync fs)
static

Perform blend overlay picture over main picture.

Definition at line 140 of file vf_overlay_cuda.c.

Referenced by overlay_cuda_init().

static av_cold int overlay_cuda_init ( AVFilterContext avctx)
static

Initialize overlay_cuda.

Definition at line 232 of file vf_overlay_cuda.c.

static av_cold void overlay_cuda_uninit ( AVFilterContext avctx)
static

Uninitialize overlay_cuda.

Definition at line 243 of file vf_overlay_cuda.c.

static int overlay_cuda_activate ( AVFilterContext avctx)
static

Activate overlay_cuda.

Definition at line 261 of file vf_overlay_cuda.c.

static int overlay_cuda_query_formats ( AVFilterContext avctx)
static

Query formats.

Definition at line 271 of file vf_overlay_cuda.c.

static int overlay_cuda_config_output ( AVFilterLink outlink)
static

Configure output.

Definition at line 285 of file vf_overlay_cuda.c.

FRAMESYNC_DEFINE_CLASS ( overlay_cuda  ,
OverlayCUDAContext  ,
fs   
)

Variable Documentation

enum AVPixelFormat supported_main_formats[]
static
Initial value:
= {
}
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
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66

Definition at line 44 of file vf_overlay_cuda.c.

Referenced by overlay_cuda_config_output().

enum AVPixelFormat supported_overlay_formats[]
static
Initial value:
= {
}
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
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
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66

Definition at line 50 of file vf_overlay_cuda.c.

Referenced by overlay_cuda_config_output().

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 },
}
#define NULL
Definition: coverity.c:32
#define FLAGS
#define fs(width, name, subs,...)
Definition: cbs_vp9.c:259
#define OFFSET(x)

Definition at line 386 of file vf_overlay_cuda.c.

const AVFilterPad overlay_cuda_inputs[]
static
Initial value:
= {
{
.name = "main",
},
{
.name = "overlay",
},
{ NULL }
}
#define NULL
Definition: coverity.c:32

Definition at line 404 of file vf_overlay_cuda.c.

const AVFilterPad overlay_cuda_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = &overlay_cuda_config_output,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int overlay_cuda_config_output(AVFilterLink *outlink)
Configure output.

Definition at line 416 of file vf_overlay_cuda.c.

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,
}
#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:365
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold int uninit(AVCodecContext *avctx)
Definition: crystalhd.c:279
filter_frame For filters that do not use the activate() callback
static const AVFilterPad overlay_cuda_inputs[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
OverlayCUDAContext.
static av_cold int overlay_cuda_init(AVFilterContext *avctx)
Initialize overlay_cuda.
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
static int overlay_cuda_activate(AVFilterContext *avctx)
Activate overlay_cuda.
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
static av_cold void overlay_cuda_uninit(AVFilterContext *avctx)
Uninitialize overlay_cuda.
static const AVFilterPad overlay_cuda_outputs[]
static int query_formats(AVFilterContext *ctx)
Definition: aeval.c:244
static int overlay_cuda_query_formats(AVFilterContext *avctx)
Query formats.

Definition at line 425 of file vf_overlay_cuda.c.