22 #include <va/va_vpp.h>
109 "required to associate the processing device.\n");
136 vas = vaCreateConfig(ctx->
hwctx->
display, VAProfileNone,
137 VAEntrypointVideoProc, 0, 0, &ctx->
va_config);
138 if (vas != VA_STATUS_SUCCESS) {
140 "config: %d (%s).\n", vas, vaErrorStr(vas));
185 "size %dx%d (constraints: width %d-%d height %d-%d).\n",
216 "context for output: %d\n", err);
228 if (vas != VA_STATUS_SUCCESS) {
230 "context: %d (%s).\n", vas, vaErrorStr(vas));
257 #define CS(av, va) case AVCOL_SPC_ ## av: return VAProcColorStandard ## va;
260 CS(SMPTE170M, SMPTE170M);
261 CS(SMPTE240M, SMPTE240M);
264 return VAProcColorStandardNone;
274 VASurfaceID input_surface, output_surface;
275 VAProcPipelineParameterBuffer
params;
276 VABufferID params_id;
277 VARectangle input_region;
288 input_surface = (VASurfaceID)(uintptr_t)input_frame->
data[3];
299 output_surface = (VASurfaceID)(uintptr_t)output_frame->
data[3];
303 memset(¶ms, 0,
sizeof(params));
307 input_region = (VARectangle) {
310 .width = input_frame->
width,
311 .height = input_frame->
height,
314 params.surface = input_surface;
315 params.surface_region = &input_region;
316 params.surface_color_standard =
319 params.output_region = 0;
320 params.output_background_color = 0xff000000;
321 params.output_color_standard = params.surface_color_standard;
323 params.pipeline_flags = 0;
324 params.filter_flags = VA_FILTER_SCALING_HQ;
328 if (vas != VA_STATUS_SUCCESS) {
330 "%d (%s).\n", vas, vaErrorStr(vas));
336 VAProcPipelineParameterBufferType,
337 sizeof(params), 1, ¶ms, ¶ms_id);
338 if (vas != VA_STATUS_SUCCESS) {
340 "%d (%s).\n", vas, vaErrorStr(vas));
342 goto fail_after_begin;
349 if (vas != VA_STATUS_SUCCESS) {
351 "%d (%s).\n", vas, vaErrorStr(vas));
353 goto fail_after_begin;
357 if (vas != VA_STATUS_SUCCESS) {
359 "%d (%s).\n", vas, vaErrorStr(vas));
361 goto fail_after_render;
367 if (vas != VA_STATUS_SUCCESS) {
369 "%d (%s).\n", vas, vaErrorStr(vas));
432 #define OFFSET(x) offsetof(ScaleVAAPIContext, x)
433 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
435 {
"w",
"Output video width",
437 {
"h",
"Output video height",
439 {
"format",
"Output video format (software format of hardware frames)",
471 .
name =
"scale_vaapi",
477 .
inputs = scale_vaapi_inputs,
478 .
outputs = scale_vaapi_outputs,
479 .priv_class = &scale_vaapi_class,
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
#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_scale_eval_dimensions(void *log_ctx, const char *w_expr, const char *h_expr, AVFilterLink *inlink, AVFilterLink *outlink, int *ret_w, int *ret_h)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
VAAPI-specific data associated with a frame pool.
This structure describes decoded (raw) audio or video data.
char * output_format_string
The driver does not destroy parameter buffers when they are used by vaRenderPicture().
#define LIBAVUTIL_VERSION_INT
Main libavfilter public API header.
Memory handling functions.
static av_cold int init(AVCodecContext *avctx)
int h
agreed upon image height
static av_cold void scale_vaapi_uninit(AVFilterContext *avctx)
int width
The allocated dimensions of the frames in this pool.
void * av_hwdevice_hwconfig_alloc(AVBufferRef *ref)
Allocate a HW-specific configuration structure for a given HW device.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
static int vaapi_proc_colour_standard(enum AVColorSpace av_cs)
AVBufferRef * input_frames_ref
int max_width
The maximum size of frames in this hw_frames_ctx.
API-specific header for AV_HWDEVICE_TYPE_VAAPI.
void av_hwframe_constraints_free(AVHWFramesConstraints **constraints)
Free an AVHWFrameConstraints structure.
const char * name
Pad name.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static av_cold int uninit(AVCodecContext *avctx)
AVFilter ff_vf_scale_vaapi
AVColorSpace
YUV colorspace type.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static int scale_vaapi_pipeline_uninit(ScaleVAAPIContext *ctx)
static const AVOption scale_vaapi_options[]
A filter pad used for either input or output.
A link between two filters.
static av_cold int scale_vaapi_init(AVFilterContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVVAAPIDeviceContext * hwctx
VAAPI hardware pipeline configuration details.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int scale_vaapi_config_output(AVFilterLink *outlink)
void * priv
private data for use by the filter
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
enum AVColorSpace colorspace
YUV colorspace type.
simple assert() macros that are a bit more flexible than ISO C assert().
AVFilterFormats * in_formats
Lists of formats and channel layouts supported by the input and output filters respectively.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
static const AVFilterPad scale_vaapi_inputs[]
static int scale_vaapi_config_input(AVFilterLink *inlink)
int w
agreed upon image width
int initial_pool_size
Initial size of the frame pool.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames...
AVFilterContext * src
source filter
static const AVClass scale_vaapi_class
static const AVFilterPad outputs[]
VADisplay display
The VADisplay handle, to be filled by the user.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int min_width
The minimum size of frames in this hw_frames_ctx.
static const AVFilterPad inputs[]
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
AVHWFramesConstraints * av_hwdevice_get_hwframe_constraints(AVBufferRef *ref, const void *hwconfig)
Get the constraints on HW frames given a device and the HW-specific configuration to be used with tha...
uint8_t * data
The data buffer.
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
unsigned int driver_quirks
Driver quirks to apply - this is filled by av_hwdevice_ctx_init(), with reference to a table of known...
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
Describe the class of an AVClass context structure.
enum AVPixelFormat output_format
This struct describes a set or pool of "hardware" frames (i.e.
static const AVFilterPad scale_vaapi_outputs[]
const char * name
Filter name.
AVHWFramesContext * output_frames
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
A reference to a data buffer.
static int query_formats(AVFilterContext *ctx)
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
AVHWFramesContext * input_frames
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
AVFilterContext * dst
dest filter
static int scale_vaapi_query_formats(AVFilterContext *avctx)
enum AVPixelFormat * valid_sw_formats
A list of possible values for sw_format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
VAAPI connection details.
VAConfigID config_id
ID of a VAAPI pipeline configuration.
VASurfaceID * surface_ids
The surfaces IDs of all surfaces in the pool after creation.
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
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.
static int scale_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
AVBufferRef * output_frames_ref
AVPixelFormat
Pixel format.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFilterFormats * out_formats