Go to the documentation of this file.
74 VAProcPipelineCaps pipeline_caps;
76 memset(&pipeline_caps, 0,
sizeof(pipeline_caps));
77 vas = vaQueryVideoProcPipelineCaps(vpp_ctx->
hwctx->
display,
81 if (vas != VA_STATUS_SUCCESS) {
83 "caps: %d (%s).\n", vas, vaErrorStr(vas));
87 if (!pipeline_caps.blend_flags) {
92 support_flag = pipeline_caps.blend_flags & VA_BLEND_GLOBAL_ALPHA;
102 VAProcPipelineParameterBuffer *params,
103 VAProcPipelineParameterBuffer *subpic_params,
107 VASurfaceID output_surface;
108 VABufferID params_id;
109 VABufferID subpic_params_id;
113 output_surface = (VASurfaceID)(uintptr_t)
output_frame->data[3];
115 vas = vaBeginPicture(
ctx->hwctx->display,
116 ctx->va_context, output_surface);
117 if (vas != VA_STATUS_SUCCESS) {
119 "%d (%s).\n", vas, vaErrorStr(vas));
124 vas = vaCreateBuffer(
ctx->hwctx->display,
ctx->va_context,
125 VAProcPipelineParameterBufferType,
126 sizeof(*params), 1, params, ¶ms_id);
127 if (vas != VA_STATUS_SUCCESS) {
129 "%d (%s).\n", vas, vaErrorStr(vas));
131 goto fail_after_begin;
137 vas = vaCreateBuffer(
ctx->hwctx->display,
ctx->va_context,
138 VAProcPipelineParameterBufferType,
139 sizeof(*subpic_params), 1, subpic_params, &subpic_params_id);
140 if (vas != VA_STATUS_SUCCESS) {
142 "%d (%s).\n", vas, vaErrorStr(vas));
144 goto fail_after_begin;
149 vas = vaRenderPicture(
ctx->hwctx->display,
ctx->va_context,
151 if (vas != VA_STATUS_SUCCESS) {
153 "%d (%s).\n", vas, vaErrorStr(vas));
155 goto fail_after_begin;
158 vas = vaRenderPicture(
ctx->hwctx->display,
ctx->va_context,
159 &subpic_params_id, 1);
160 if (vas != VA_STATUS_SUCCESS) {
162 "%d (%s).\n", vas, vaErrorStr(vas));
164 goto fail_after_begin;
167 vas = vaEndPicture(
ctx->hwctx->display,
ctx->va_context);
168 if (vas != VA_STATUS_SUCCESS) {
170 "%d (%s).\n", vas, vaErrorStr(vas));
172 goto fail_after_render;
175 if (CONFIG_VAAPI_1 ||
ctx->hwctx->driver_quirks &
177 vas = vaDestroyBuffer(
ctx->hwctx->display, params_id);
178 if (vas != VA_STATUS_SUCCESS) {
180 "%d (%s).\n", vas, vaErrorStr(vas));
192 vaRenderPicture(
ctx->hwctx->display,
ctx->va_context, ¶ms_id, 1);
194 vaEndPicture(
ctx->hwctx->display,
ctx->va_context);
205 AVFrame *input_main, *input_overlay;
207 VAProcPipelineParameterBuffer params, subpic_params;
208 VABlendState blend_state;
209 VARectangle overlay_region, output_region;
249 overlay_region = (VARectangle) {
250 .x =
ctx->overlay_ox,
251 .y =
ctx->overlay_oy,
252 .width =
ctx->overlay_ow ?
ctx->overlay_ow : input_overlay->
width,
253 .height =
ctx->overlay_oh ?
ctx->overlay_oh : input_overlay->
height,
256 output_region = (VARectangle) {
263 if (overlay_region.x + overlay_region.width > input_main->
width ||
264 overlay_region.y + overlay_region.height > input_main->
height) {
266 "The overlay image exceeds the scope of the main image, "
267 "will crop the overlay image according based on the main image.\n");
273 params.output_region = &output_region;
276 memcpy(&subpic_params, ¶ms,
sizeof(subpic_params));
278 blend_state.flags = VA_BLEND_GLOBAL_ALPHA;
279 blend_state.global_alpha =
ctx->alpha;
280 subpic_params.blend_state = &blend_state;
282 subpic_params.surface = (VASurfaceID)(uintptr_t)input_overlay->
data[3];
283 subpic_params.output_region = &overlay_region;
315 in->
sync =
i ? 1 : 2;
371 #define OFFSET(x) offsetof(OverlayVAAPIContext, x)
372 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
374 {
"x",
"Overlay x position",
376 {
"y",
"Overlay y position",
378 {
"w",
"Overlay width",
380 {
"h",
"Overlay height",
382 {
"alpha",
"Overlay global alpha",
412 .
name =
"overlay_vaapi",
415 .priv_class = &overlay_vaapi_class,
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)
AVRational time_base
Time base for the incoming frames.
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.
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
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
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
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[]
#define FILTER_QUERY_FUNC(func)
static const AVFilterPad overlay_vaapi_outputs[]
VADisplay display
The VADisplay handle, to be filled by the user.
AVFILTER_DEFINE_CLASS(overlay_vaapi)
const char * name
Filter name.
@ EXT_INFINITY
Extend the frame to infinity.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int overlay_vaapi_build_filter_params(AVFilterContext *avctx)
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
@ EXT_STOP
Completely stop all streams with this one.
void * priv
private data for use by the filter
static int overlay_vaapi_query_formats(AVFilterContext *ctx)
static av_cold int overlay_vaapi_init(AVFilterContext *avctx)
unsigned sync
Synchronization level: frames on input at the highest sync level will generate output frame events.
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_fmts[]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
enum AVPixelFormat output_format
AVVAAPIDeviceContext * hwctx
#define FILTER_INPUTS(array)
static int overlay_vaapi_config_output(AVFilterLink *outlink)
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)
unsigned nb_inputs
number of input pads
#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.
static int overlay_vaapi_render_picture(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, VAProcPipelineParameterBuffer *subpic_params, AVFrame *output_frame)
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)
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
#define i(width, name, range_min, range_max)
int w
agreed upon image width
VABufferID filter_buffers[VAProcFilterCount]
const char * name
Pad name.
@ AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS
The driver does not destroy parameter buffers when they are used by vaRenderPicture().
int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
Initialize a frame sync structure.
enum FFFrameSyncExtMode before
Extrapolation mode for timestamps before the first frame.
int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
int h
agreed upon image height
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)
static const int16_t alpha[]
#define FILTER_OUTPUTS(array)
enum FFFrameSyncExtMode after
Extrapolation mode for timestamps after the last frame.
static int overlay_vaapi_blend(FFFrameSync *fs)
static av_cold int uninit(AVCodecContext *avctx)
static int overlay_vaapi_init_framesync(AVFilterContext *avctx)
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
#define VAAPI_VPP_BACKGROUND_BLACK
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