22 #include <va/va_vpp.h>
101 "required to associate the processing device.\n");
127 vas = vaCreateConfig(ctx->
hwctx->
display, VAProfileNone,
128 VAEntrypointVideoProc, 0, 0, &ctx->
va_config);
129 if (vas != VA_STATUS_SUCCESS) {
131 "config: %d (%s).\n", vas, vaErrorStr(vas));
170 "size %dx%d (constraints: width %d-%d height %d-%d).\n",
201 "context for output: %d\n", err);
213 if (vas != VA_STATUS_SUCCESS) {
215 "context: %d (%s).\n", vas, vaErrorStr(vas));
242 #define CS(av, va) case AVCOL_SPC_ ## av: return VAProcColorStandard ## va;
245 CS(SMPTE170M, SMPTE170M);
246 CS(SMPTE240M, SMPTE240M);
249 return VAProcColorStandardNone;
259 VASurfaceID input_surface, output_surface;
260 VAProcPipelineParameterBuffer
params;
261 VABufferID params_id;
272 input_surface = (VASurfaceID)(uintptr_t)input_frame->
data[3];
286 "output: %d\n.", err);
289 output_surface = (VASurfaceID)(uintptr_t)output_frame->
data[3];
293 memset(¶ms, 0,
sizeof(params));
295 params.surface = input_surface;
296 params.surface_region = 0;
297 params.surface_color_standard =
300 params.output_region = 0;
301 params.output_background_color = 0xff000000;
302 params.output_color_standard = params.surface_color_standard;
304 params.pipeline_flags = 0;
305 params.filter_flags = VA_FILTER_SCALING_HQ;
309 if (vas != VA_STATUS_SUCCESS) {
311 "%d (%s).\n", vas, vaErrorStr(vas));
317 VAProcPipelineParameterBufferType,
318 sizeof(params), 1, ¶ms, ¶ms_id);
319 if (vas != VA_STATUS_SUCCESS) {
321 "%d (%s).\n", vas, vaErrorStr(vas));
323 goto fail_after_begin;
330 if (vas != VA_STATUS_SUCCESS) {
332 "%d (%s).\n", vas, vaErrorStr(vas));
334 goto fail_after_begin;
338 if (vas != VA_STATUS_SUCCESS) {
340 "%d (%s).\n", vas, vaErrorStr(vas));
342 goto fail_after_render;
347 if (vas != VA_STATUS_SUCCESS) {
349 "%d (%s).\n", vas, vaErrorStr(vas));
412 #define OFFSET(x) offsetof(ScaleVAAPIContext, x)
413 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
415 {
"w",
"Output video width",
417 {
"h",
"Output video height",
419 {
"format",
"Output video format (software format of hardware frames)",
451 .
name =
"scale_vaapi",
457 .
inputs = scale_vaapi_inputs,
458 .
outputs = scale_vaapi_outputs,
459 .priv_class = &scale_vaapi_class,
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
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
#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.
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.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
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)
int width
width and height of the video frame
#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.
int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
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[]
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
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.
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