Go to the documentation of this file.
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) {
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");
231 memcpy(¶ms[1], ¶ms[0],
sizeof(params[0]));
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];
238 params[1].surface_region =
NULL;
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 .
name =
"overlay_vaapi",
421 .priv_class = &overlay_vaapi_class,
425 .
preinit = overlay_vaapi_framesync_preinit,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
void ff_vaapi_vpp_ctx_init(AVFilterContext *avctx)
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
#define AV_LOG_WARNING
Something somehow does not look correct.
AVPixelFormat
Pixel format.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
double var_values[VAR_VARS_NB]
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
uint8_t * data
The data buffer.
VAAPIVPPContext vpp_ctx
must be the first field
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define FILTER_INPUTS(array)
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).
static const AVOption overlay_vaapi_options[]
static const AVFilterPad overlay_vaapi_outputs[]
int ff_vaapi_vpp_render_pictures(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params_list, int cout, AVFrame *output_frame)
VADisplay display
The VADisplay handle, to be filled by the user.
static av_cold int preinit(AVFilterContext *ctx)
static const char *const var_names[]
const char * name
Filter name.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Link properties exposed to filter code, but not external callers.
static int overlay_vaapi_build_filter_params(AVFilterContext *avctx)
static int eval_expr(AVFilterContext *avctx)
void * priv
private data for use by the filter
static int overlay_vaapi_config_input_overlay(AVFilterLink *inlink)
static av_cold int overlay_vaapi_init(AVFilterContext *avctx)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
A filter pad used for either input or output.
const AVFilter ff_vf_overlay_vaapi
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const AVFilterPad overlay_vaapi_inputs[]
static enum AVPixelFormat pix_fmt
static int overlay_vaapi_config_input_main(AVFilterLink *inlink)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
enum AVPixelFormat output_format
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
AVVAAPIDeviceContext * hwctx
#define FILTER_OUTPUTS(array)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
static int overlay_vaapi_config_output(AVFilterLink *outlink)
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define fs(width, name, subs,...)
filter_frame For filters that do not use the activate() callback
AVFilterLink ** inputs
array of pointers to input links
int ff_vaapi_vpp_config_input(AVFilterLink *inlink)
void ff_vaapi_vpp_ctx_uninit(AVFilterContext *avctx)
static FilterLink * ff_filter_link(AVFilterLink *link)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
int(* init)(AVBSFContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
AVFilterContext * src
source filter
static av_cold void overlay_vaapi_uninit(AVFilterContext *avctx)
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
static void uninit(AVBSFContext *ctx)
int w
agreed upon image width
const char * name
Pad name.
This struct describes a set or pool of "hardware" frames (i.e.
int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
int h
agreed upon image height
@ AV_OPT_TYPE_INT
Underlying C type is int.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
static int overlay_vaapi_activate(AVFilterContext *avctx)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static const int16_t alpha[]
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
FRAMESYNC_DEFINE_CLASS(overlay_vaapi, OverlayVAAPIContext, fs)
static int have_alpha_planar(AVFilterLink *link)
static int overlay_vaapi_blend(FFFrameSync *fs)
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
@ 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...
#define VAAPI_VPP_BACKGROUND_BLACK
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
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.
int ff_vaapi_vpp_init_params(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, const AVFrame *input_frame, AVFrame *output_frame)
AVFilterLink ** outputs
array of pointers to output links