FFmpeg
Loading...
Searching...
No Matches
vf_overlay_qsv.c File Reference

A hardware accelerated overlay filter based on Intel Quick Sync Video VPP. More...

#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/common.h"
#include "libavutil/pixdesc.h"
#include "libavutil/eval.h"
#include "libavutil/hwcontext.h"
#include "libavutil/mathematics.h"
#include "filters.h"
#include "avfilter.h"
#include "formats.h"
#include "framesync.h"
#include "qsvvpp.h"

Go to the source code of this file.

Data Structures

struct  QSVOverlayContext
 

Macros

#define MAIN   0
 
#define OVERLAY   1
 
#define OFFSET(x)
 
#define FLAGS   (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM)
 
#define PASS_EXPR(e, s)
 

Enumerations

enum  var_name {
  VAR_MAIN_iW , VAR_MW , VAR_MAIN_iH , VAR_MH ,
  VAR_OVERLAY_iW , VAR_OVERLAY_iH , VAR_OVERLAY_X , VAR_OX ,
  VAR_OVERLAY_Y , VAR_OY , VAR_OVERLAY_W , VAR_OW ,
  VAR_OVERLAY_H , VAR_OH , VAR_VARS_NB
}
 

Functions

 FRAMESYNC_DEFINE_CLASS (overlay_qsv, QSVOverlayContext, fs)
 
static int eval_expr (AVFilterContext *ctx)
 
static int have_alpha_planar (AVFilterLink *link)
 
static int config_main_input (AVFilterLink *inlink)
 
static int config_overlay_input (AVFilterLink *inlink)
 
static int process_frame (FFFrameSync *fs)
 
static int init_framesync (AVFilterContext *ctx)
 
static int config_output (AVFilterLink *outlink)
 
static int filter_callback (AVFilterLink *outlink, AVFrame *frame)
 
static int overlay_qsv_init (AVFilterContext *ctx)
 
static av_cold void overlay_qsv_uninit (AVFilterContext *ctx)
 
static int activate (AVFilterContext *ctx)
 
static int overlay_qsv_query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 

Variables

static const char *const var_names []
 
static const AVOption overlay_qsv_options []
 
static const AVFilterPad overlay_qsv_inputs []
 
static const AVFilterPad overlay_qsv_outputs []
 
const FFFilter ff_vf_overlay_qsv
 

Detailed Description

A hardware accelerated overlay filter based on Intel Quick Sync Video VPP.

Definition in file vf_overlay_qsv.c.

Macro Definition Documentation

◆ MAIN

#define MAIN   0

Definition at line 39 of file vf_overlay_qsv.c.

◆ OVERLAY

#define OVERLAY   1

Definition at line 40 of file vf_overlay_qsv.c.

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 42 of file vf_overlay_qsv.c.

◆ FLAGS

Definition at line 43 of file vf_overlay_qsv.c.

◆ PASS_EXPR

#define PASS_EXPR ( e,
s )
Value:
{\
ret = av_expr_parse(&e, s, var_names, NULL, NULL, NULL, NULL, 0, ctx); \
if (ret < 0) {\
av_log(ctx, AV_LOG_ERROR, "Error when passing '%s'.\n", s);\
goto release;\
}\
}
static AVFormatContext * ctx
#define s(width, name)
Definition cbs_vp9.c:198
#define NULL
Definition coverity.c:32
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
Definition eval.c:735
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
static const char *const var_names[]
Definition noise.c:30

Referenced by eval_expr().

Enumeration Type Documentation

◆ var_name

enum var_name
Enumerator
VAR_MAIN_iW 
VAR_MW 
VAR_MAIN_iH 
VAR_MH 
VAR_OVERLAY_iW 
VAR_OVERLAY_iH 
VAR_OVERLAY_X 
VAR_OX 
VAR_OVERLAY_Y 
VAR_OY 
VAR_OVERLAY_W 
VAR_OW 
VAR_OVERLAY_H 
VAR_OH 
VAR_VARS_NB 

Definition at line 45 of file vf_overlay_qsv.c.

Function Documentation

◆ FRAMESYNC_DEFINE_CLASS()

FRAMESYNC_DEFINE_CLASS ( overlay_qsv ,
QSVOverlayContext ,
fs  )

◆ eval_expr()

static int eval_expr ( AVFilterContext * ctx)
static

Definition at line 101 of file vf_overlay_qsv.c.

Referenced by config_overlay_input().

◆ have_alpha_planar()

static int have_alpha_planar ( AVFilterLink * link)
static

Definition at line 157 of file vf_overlay_qsv.c.

Referenced by config_overlay_input().

◆ config_main_input()

static int config_main_input ( AVFilterLink * inlink)
static

Definition at line 176 of file vf_overlay_qsv.c.

◆ config_overlay_input()

static int config_overlay_input ( AVFilterLink * inlink)
static

Definition at line 200 of file vf_overlay_qsv.c.

◆ process_frame()

static int process_frame ( FFFrameSync * fs)
static

Definition at line 228 of file vf_overlay_qsv.c.

◆ init_framesync()

static int init_framesync ( AVFilterContext * ctx)
static

Definition at line 249 of file vf_overlay_qsv.c.

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink * outlink)
static

Definition at line 271 of file vf_overlay_qsv.c.

◆ filter_callback()

static int filter_callback ( AVFilterLink * outlink,
AVFrame * frame )
static

Definition at line 317 of file vf_overlay_qsv.c.

Referenced by overlay_qsv_init(), and qsv_stack_init().

◆ overlay_qsv_init()

static int overlay_qsv_init ( AVFilterContext * ctx)
static

Definition at line 326 of file vf_overlay_qsv.c.

◆ overlay_qsv_uninit()

static av_cold void overlay_qsv_uninit ( AVFilterContext * ctx)
static

Definition at line 353 of file vf_overlay_qsv.c.

◆ activate()

static int activate ( AVFilterContext * ctx)
static

Definition at line 363 of file vf_overlay_qsv.c.

◆ overlay_qsv_query_formats()

static int overlay_qsv_query_formats ( const AVFilterContext * ctx,
AVFilterFormatsConfig ** cfg_in,
AVFilterFormatsConfig ** cfg_out )
static

Definition at line 369 of file vf_overlay_qsv.c.

Variable Documentation

◆ var_names

const char* const var_names[]
static
Initial value:
= {
"main_w", "W",
"main_h", "H",
"overlay_iw",
"overlay_ih",
"overlay_x", "x",
"overlay_y", "y",
"overlay_w", "w",
"overlay_h", "h",
}

Definition at line 70 of file vf_overlay_qsv.c.

◆ overlay_qsv_options

const AVOption overlay_qsv_options[]
static
Initial value:
= {
{ "x", "Overlay x position", OFFSET(overlay_ox), AV_OPT_TYPE_STRING, { .str="0"}, 0, 255, .flags = FLAGS},
{ "y", "Overlay y position", OFFSET(overlay_oy), AV_OPT_TYPE_STRING, { .str="0"}, 0, 255, .flags = FLAGS},
{ "w", "Overlay width", OFFSET(overlay_ow), AV_OPT_TYPE_STRING, { .str="overlay_iw"}, 0, 255, .flags = FLAGS},
{ "h", "Overlay height", OFFSET(overlay_oh), AV_OPT_TYPE_STRING, { .str="overlay_ih*w/overlay_iw"}, 0, 255, .flags = FLAGS},
{ "alpha", "Overlay global alpha", OFFSET(overlay_alpha), AV_OPT_TYPE_INT, { .i64 = 255}, 0, 255, .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, .unit = "eof_action" },
{ "repeat", "Repeat the previous frame.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, .unit = "eof_action" },
{ "endall", "End both streams.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ENDALL }, .flags = FLAGS, .unit = "eof_action" },
{ "pass", "Pass through the main input.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS }, .flags = FLAGS, .unit = "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 fs(width, name, subs,...)
Definition cbs_vp9.c:200
#define FLAGS
Definition cmdutils.c:598
#define OFFSET(x)
@ EOF_ACTION_REPEAT
Definition framesync.h:27
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ 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:275
@ EOF_ACTION_PASS
Definition packetsync.h:31
@ EOF_ACTION_ENDALL
Definition packetsync.h:30

Definition at line 82 of file vf_overlay_qsv.c.

◆ overlay_qsv_inputs

const AVFilterPad overlay_qsv_inputs[]
static
Initial value:
= {
{
.name = "main",
.config_props = config_main_input,
.get_buffer.video = ff_qsvvpp_get_video_buffer,
},
{
.name = "overlay",
.config_props = config_overlay_input,
.get_buffer.video = ff_qsvvpp_get_video_buffer,
},
}
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
AVFrame * ff_qsvvpp_get_video_buffer(AVFilterLink *inlink, int w, int h)
Definition qsvvpp.c:1141
static int config_overlay_input(AVFilterLink *inlink)
static int config_main_input(AVFilterLink *inlink)

Definition at line 403 of file vf_overlay_qsv.c.

◆ overlay_qsv_outputs

const AVFilterPad overlay_qsv_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}
static int config_output(AVBitStreamFilterLink *outlink)

Definition at line 418 of file vf_overlay_qsv.c.

◆ ff_vf_overlay_qsv

const FFFilter ff_vf_overlay_qsv
Initial value:
= {
.p.name = "overlay_qsv",
.p.description = NULL_IF_CONFIG_SMALL("Quick Sync Video overlay."),
.p.priv_class = &overlay_qsv_class,
.priv_size = sizeof(QSVOverlayContext),
.preinit = overlay_qsv_framesync_preinit,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition avfilter.h:187
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#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:208
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static av_cold int preinit(AVBitStreamFilterContext *ctx)
Definition source.c:137
static int overlay_qsv_init(AVFilterContext *ctx)
static av_cold void overlay_qsv_uninit(AVFilterContext *ctx)
static const AVFilterPad overlay_qsv_outputs[]
static const AVFilterPad overlay_qsv_inputs[]
static int overlay_qsv_query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)

Definition at line 426 of file vf_overlay_qsv.c.