75 double *var_values =
ctx->var_values;
80#define PARSE_EXPR(e, s) {\
81 ret = av_expr_parse(&(e), s, var_names, NULL, NULL, NULL, NULL, 0, ctx); \
83 av_log(ctx, AV_LOG_ERROR, "Error when parsing '%s'.\n", s);\
133 VAProcPipelineCaps pipeline_caps;
135 memset(&pipeline_caps, 0,
sizeof(pipeline_caps));
136 vas = vaQueryVideoProcPipelineCaps(vpp_ctx->
hwctx->
display,
140 if (vas != VA_STATUS_SUCCESS) {
142 "caps: %d (%s).\n", vas, vaErrorStr(vas));
146 if (!pipeline_caps.blend_flags) {
151 support_flag = pipeline_caps.blend_flags & VA_BLEND_GLOBAL_ALPHA;
166 AVFrame *input_main, *input_overlay;
168 VAProcPipelineParameterBuffer
params[2];
169 VABlendState blend_state = { 0 };
170 VARectangle overlay_region, output_region;
202 output_region = (VARectangle) {
205 .width = output->
width,
209 params[0].output_region = &output_region;
217 overlay_region = (VARectangle) {
224 if (overlay_region.x + overlay_region.width > input_main->
width ||
225 overlay_region.y + overlay_region.height > input_main->
height) {
227 "The overlay image exceeds the scope of the main image, "
228 "will crop the overlay image according based on the main image.\n");
233 blend_state.flags =
ctx->blend_flags;
234 blend_state.global_alpha =
ctx->blend_alpha;
235 params[1].blend_state = &blend_state;
237 params[1].surface = (VASurfaceID)(uintptr_t)input_overlay->
data[3];
239 params[1].output_region = &overlay_region;
307 ctx->blend_flags = 0;
308 ctx->blend_alpha = 1.0f;
310 if (
ctx->alpha < 1.0f) {
311 ctx->blend_flags |= VA_BLEND_GLOBAL_ALPHA;
312 ctx->blend_alpha =
ctx->alpha;
316 ctx->blend_flags |= VA_BLEND_PREMULTIPLIED_ALPHA;
375#define OFFSET(x) offsetof(OverlayVAAPIContext, x)
376#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
383 {
"eof_action",
"Action to take when encountering EOF from secondary input ",
389 {
"shortest",
"force termination when the shortest input terminates",
OFFSET(
fs.opt_shortest),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
FLAGS },
418 .p.name =
"overlay_vaapi",
420 .p.priv_class = &overlay_vaapi_class,
425 .
preinit = overlay_vaapi_framesync_preinit,
SwsAArch64OpImplParams params
const FFFilter ff_vf_overlay_vaapi
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define fs(width, name, subs,...)
static enum AVPixelFormat pix_fmt
int(* init)(AVBSFContext *ctx)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
simple arithmetic expression evaluator
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
#define FRAMESYNC_DEFINE_CLASS(name, context, field)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ 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...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const int16_t alpha[]
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
static FilterLink * ff_filter_link(AVFilterLink *link)
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const char *const var_names[]
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
static av_cold int preinit(AVBitStreamFilterContext *ctx)
uint8_t * data
The data buffer.
AVFilterLink ** inputs
array of pointers to input links
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
This struct describes a set or pool of "hardware" frames (i.e.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
VADisplay display
The VADisplay handle, to be filled by the user.
Link properties exposed to filter code, but not external callers.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
double var_values[VAR_VARS_NB]
VAAPIVPPContext vpp_ctx
must be the first field
enum AVPixelFormat output_format
AVVAAPIDeviceContext * hwctx
static AVFormatContext * ctx
int ff_vaapi_vpp_render_pictures(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params_list, int cout, AVFrame *output_frame)
int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
int ff_vaapi_vpp_config_input(AVFilterLink *inlink)
void ff_vaapi_vpp_ctx_init(AVFilterContext *avctx)
int ff_vaapi_vpp_init_params(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, const AVFrame *input_frame, AVFrame *output_frame)
void ff_vaapi_vpp_ctx_uninit(AVFilterContext *avctx)
#define VAAPI_VPP_BACKGROUND_BLACK
static int overlay_vaapi_blend(FFFrameSync *fs)
static int overlay_vaapi_config_output(AVFilterLink *outlink)
static const AVOption overlay_vaapi_options[]
static int eval_expr(AVFilterContext *avctx)
static const AVFilterPad overlay_vaapi_inputs[]
static int overlay_vaapi_activate(AVFilterContext *avctx)
static int overlay_vaapi_build_filter_params(AVFilterContext *avctx)
static const AVFilterPad overlay_vaapi_outputs[]
static int overlay_vaapi_config_input_overlay(AVFilterLink *inlink)
static av_cold int overlay_vaapi_init(AVFilterContext *avctx)
static int overlay_vaapi_config_input_main(AVFilterLink *inlink)
static av_cold void overlay_vaapi_uninit(AVFilterContext *avctx)
static int have_alpha_planar(AVFilterLink *link)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.