49 for (
i = 0;
i <
ctx->nb_filter_buffers;
i++) {
50 if (
ctx->filter_buffers[
i] != VA_INVALID_ID) {
51 vaDestroyBuffer(
ctx->hwctx->display,
ctx->filter_buffers[
i]);
52 ctx->filter_buffers[
i] = VA_INVALID_ID;
55 ctx->nb_filter_buffers = 0;
57 if (
ctx->va_context != VA_INVALID_ID) {
58 vaDestroyContext(
ctx->hwctx->display,
ctx->va_context);
59 ctx->va_context = VA_INVALID_ID;
62 if (
ctx->va_config != VA_INVALID_ID) {
63 vaDestroyConfig(
ctx->hwctx->display,
ctx->va_config);
64 ctx->va_config = VA_INVALID_ID;
77 if (
ctx->pipeline_uninit)
78 ctx->pipeline_uninit(avctx);
82 "required to associate the processing device.\n");
87 if (!
ctx->input_frames_ref) {
111 if (
ctx->pipeline_uninit)
112 ctx->pipeline_uninit(avctx);
114 if (!
ctx->output_width)
116 if (!
ctx->output_height)
119 outlink->
w =
ctx->output_width;
120 outlink->
h =
ctx->output_height;
122 if (
ctx->passthrough) {
132 if (!
ctx->device_ref) {
140 vas = vaCreateConfig(
ctx->hwctx->display, VAProfileNone,
141 VAEntrypointVideoProc,
NULL, 0, &
ctx->va_config);
142 if (vas != VA_STATUS_SUCCESS) {
144 "config: %d (%s).\n", vas, vaErrorStr(vas));
164 ctx->output_format =
ctx->input_frames->sw_format;
183 "size %dx%d (constraints: width %d-%d height %d-%d).\n",
184 ctx->output_width,
ctx->output_height,
203 output_frames->
width =
ctx->output_width;
204 output_frames->
height =
ctx->output_height;
218 "context for output: %d\n", err);
222 va_frames = output_frames->
hwctx;
227 vas = vaCreateContext(
ctx->hwctx->display,
ctx->va_config,
228 ctx->output_width,
ctx->output_height,
232 if (vas != VA_STATUS_SUCCESS) {
234 "context: %d (%s).\n", vas, vaErrorStr(vas));
238 if (
ctx->build_filter_params) {
239 err =
ctx->build_filter_params(avctx);
270 { VAProcColorStandardBT601, 5, 6, 5 },
271 { VAProcColorStandardBT601, 6, 6, 6 },
272 { VAProcColorStandardBT709, 1, 1, 1 },
273 { VAProcColorStandardBT470M, 4, 4, 4 },
274 { VAProcColorStandardBT470BG, 5, 5, 5 },
275 { VAProcColorStandardSMPTE170M, 6, 6, 6 },
276 { VAProcColorStandardSMPTE240M, 7, 7, 7 },
277 { VAProcColorStandardGenericFilm, 8, 1, 1 },
278#if VA_CHECK_VERSION(1, 1, 0)
279 { VAProcColorStandardSRGB, 1, 13, 0 },
280 { VAProcColorStandardXVYCC601, 1, 11, 5 },
281 { VAProcColorStandardXVYCC709, 1, 11, 1 },
282 { VAProcColorStandardBT2020, 9, 14, 9 },
287 VAProcColorStandardType *vacs,
291 int i, j, score, best_score, worst_score;
292 VAProcColorStandardType best_standard;
294#if VA_CHECK_VERSION(1, 3, 0)
299 for (
i = 0;
i < nb_vacs;
i++) {
300 if (vacs[
i] == VAProcColorStandardExplicit) {
312 best_standard = VAProcColorStandardNone;
319 if (worst_score == 0) {
326 for (
i = 0;
i < nb_vacs;
i++) {
342 if (score < worst_score &&
343 (best_score == -1 || score < best_score)) {
354#if VA_CHECK_VERSION(1, 1, 0)
355 static const struct {
361 VA_CHROMA_SITING_HORIZONTAL_LEFT },
363 VA_CHROMA_SITING_HORIZONTAL_CENTER },
365 VA_CHROMA_SITING_HORIZONTAL_LEFT },
367 VA_CHROMA_SITING_HORIZONTAL_CENTER },
369 VA_CHROMA_SITING_HORIZONTAL_LEFT },
371 VA_CHROMA_SITING_HORIZONTAL_CENTER },
389#if VA_CHECK_VERSION(1, 1, 0)
408 VAProcColorStandardType *vacs,
416 "to VA standard %d chroma siting %#x range %#x.\n",
431 frame->hw_frames_ctx);
439 VAProcPipelineParameterBuffer *
params,
445 VAProcPipelineCaps caps;
448 vas = vaQueryVideoProcPipelineCaps(
ctx->hwctx->display,
ctx->va_context,
449 ctx->filter_buffers,
ctx->nb_filter_buffers,
451 if (vas != VA_STATUS_SUCCESS) {
453 "colour standard support: %d (%s).\n", vas, vaErrorStr(vas));
467 caps.input_color_standards,
468 caps.num_input_color_standards);
476 .chroma_sample_location =
output_frame->chroma_location,
479 caps.output_color_standards,
480 caps.num_output_color_standards);
484#if VA_CHECK_VERSION(1, 3, 0)
498 if (output_standard) {
509#if VA_CHECK_VERSION(1, 1, 0)
510 params->input_color_properties = (VAProcColorProperties) {
513#if VA_CHECK_VERSION(1, 3, 0)
515 .transfer_characteristics = input_props.
color_trc,
516 .matrix_coefficients = input_props.
colorspace,
519 params->output_color_properties = (VAProcColorProperties) {
522#if VA_CHECK_VERSION(1, 3, 0)
524 .transfer_characteristics = output_props.
color_trc,
525 .matrix_coefficients = output_props.
colorspace,
534 VAProcPipelineParameterBuffer *
params,
541 ctx->input_region = (VARectangle) {
544 .width = input_frame->
width -
554 *
params = (VAProcPipelineParameterBuffer) {
556 .surface_region = &
ctx->input_region,
557 .output_region =
NULL,
560 .filter_flags = VA_FRAME_PICTURE,
564#if VA_CHECK_VERSION(1, 1, 0)
565 .rotation_state = VA_ROTATION_NONE,
566 .mirror_state = VA_MIRROR_NONE,
594 vas = vaCreateBuffer(
ctx->hwctx->display,
ctx->va_context,
596 if (vas != VA_STATUS_SUCCESS) {
598 "buffer (type %d): %d (%s).\n",
599 type, vas, vaErrorStr(vas));
611 VAProcPipelineParameterBuffer *
params,
612 VABufferID *params_id)
617 vas = vaCreateBuffer(
ctx->hwctx->display,
ctx->va_context,
618 VAProcPipelineParameterBufferType,
620 if (vas != VA_STATUS_SUCCESS) {
622 "%d (%s).\n", vas, vaErrorStr(vas));
623 *params_id = VA_INVALID_ID;
629 vas = vaRenderPicture(
ctx->hwctx->display,
ctx->va_context, params_id, 1);
630 if (vas != VA_STATUS_SUCCESS) {
632 "%d (%s).\n", vas, vaErrorStr(vas));
640 VAProcPipelineParameterBuffer *params_list,
645 VABufferID *params_ids;
653 for (
int i = 0;
i < cout;
i++)
654 params_ids[
i] = VA_INVALID_ID;
656 vas = vaBeginPicture(
ctx->hwctx->display,
658 if (vas != VA_STATUS_SUCCESS) {
660 "%d (%s).\n", vas, vaErrorStr(vas));
665 for (
int i = 0;
i < cout;
i++) {
668 goto fail_after_begin;
671 vas = vaEndPicture(
ctx->hwctx->display,
ctx->va_context);
672 if (vas != VA_STATUS_SUCCESS) {
674 "%d (%s).\n", vas, vaErrorStr(vas));
676 goto fail_after_render;
679 if (CONFIG_VAAPI_1 ||
ctx->hwctx->driver_quirks &
681 for (
int i = 0;
i < cout && params_ids[
i] != VA_INVALID_ID;
i++) {
682 vas = vaDestroyBuffer(
ctx->hwctx->display, params_ids[
i]);
683 if (vas != VA_STATUS_SUCCESS) {
685 "%d (%s).\n", vas, vaErrorStr(vas));
699 vaRenderPicture(
ctx->hwctx->display,
ctx->va_context, ¶ms_ids[0], 1);
701 vaEndPicture(
ctx->hwctx->display,
ctx->va_context);
708 VAProcPipelineParameterBuffer *
params,
719 ctx->va_config = VA_INVALID_ID;
720 ctx->va_context = VA_INVALID_ID;
723 for (
i = 0;
i < VAProcFilterCount;
i++)
724 ctx->filter_buffers[
i] = VA_INVALID_ID;
725 ctx->nb_filter_buffers = 0;
731 if (
ctx->valid_ids &&
ctx->pipeline_uninit)
732 ctx->pipeline_uninit(avctx);
SwsAArch64OpImplParams params
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link, int default_pool_size)
Perform any additional setup required for hardware frames.
#define i(width, name, range_min, range_max)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_hwframe_constraints_free(AVHWFramesConstraints **constraints)
Free an AVHWFrameConstraints structure.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
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...
void * av_hwdevice_hwconfig_alloc(AVBufferRef *ref)
Allocate a HW-specific configuration structure for a given HW device.
@ AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS
The driver does not destroy parameter buffers when they are used by vaRenderPicture().
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
static FilterLink * ff_filter_link(AVFilterLink *link)
static enum AVPixelFormat pix_fmts[]
Memory handling functions.
const char * av_color_space_name(enum AVColorSpace space)
const char * av_color_range_name(enum AVColorRange range)
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 char * av_chroma_location_name(enum AVChromaLocation location)
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
const char * av_color_primaries_name(enum AVColorPrimaries primaries)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
AVChromaLocation
Location of chroma samples.
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
@ AVCHROMA_LOC_BOTTOMLEFT
@ AVCHROMA_LOC_CENTER
MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0.
@ AVCHROMA_LOC_UNSPECIFIED
AVColorRange
Visual content value range.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_JPEG
Full range content.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
AVColorPrimaries
Chromaticity coordinates of the source primaries.
AVColorTransferCharacteristic
Color Transfer Characteristic.
AVColorSpace
YUV colorspace type.
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
#define FF_ARRAY_ELEMS(a)
uint8_t * data
The data buffer.
AVFilterLink ** inputs
array of pointers to input links
void * priv
private data for use by the filter
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVFilterContext * dst
dest filter
This structure describes decoded (raw) audio or video data.
enum AVChromaLocation chroma_location
enum AVColorPrimaries color_primaries
enum AVColorRange color_range
MPEG vs JPEG YUV range.
enum AVColorSpace colorspace
YUV colorspace type.
enum AVColorTransferCharacteristic color_trc
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
int max_width
The maximum size of frames in this hw_frames_ctx.
enum AVPixelFormat * valid_sw_formats
A list of possible values for sw_format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
int min_width
The minimum size of frames in this hw_frames_ctx.
This struct describes a set or pool of "hardware" frames (i.e.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
int initial_pool_size
Initial size of the frame pool.
int width
The allocated dimensions of the frames in this pool.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
VAAPI-specific data associated with a frame pool.
VASurfaceID * surface_ids
The surfaces IDs of all surfaces in the pool after creation.
VAAPI hardware pipeline configuration details.
VAConfigID config_id
ID of a VAAPI pipeline configuration.
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.
enum AVColorSpace colorspace
VAProcColorStandardType va_color_standard
enum AVColorPrimaries color_primaries
uint8_t va_chroma_sample_location
enum AVColorRange color_range
enum AVColorTransferCharacteristic color_trc
enum AVChromaLocation chroma_sample_location
#define av_malloc_array(a, b)
static void vaapi_vpp_fill_colour_range(VAAPIColourProperties *props)
int ff_vaapi_vpp_render_pictures(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params_list, int cout, AVFrame *output_frame)
int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
static void vaapi_vpp_fill_colour_properties(AVFilterContext *avctx, VAAPIColourProperties *props, VAProcColorStandardType *vacs, int nb_vacs)
static const VAAPIColourProperties vaapi_colour_standard_map[]
static void vaapi_vpp_fill_colour_standard(VAAPIColourProperties *props, VAProcColorStandardType *vacs, int nb_vacs)
int ff_vaapi_vpp_config_input(AVFilterLink *inlink)
int ff_vaapi_vpp_query_formats(const AVFilterContext *avctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
void ff_vaapi_vpp_pipeline_uninit(AVFilterContext *avctx)
void ff_vaapi_vpp_ctx_init(AVFilterContext *avctx)
int ff_vaapi_vpp_make_param_buffers(AVFilterContext *avctx, int type, const void *data, size_t size, int count)
static int vaapi_vpp_colour_properties(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, const AVFrame *input_frame, AVFrame *output_frame)
static int vaapi_vpp_frame_is_rgb(const AVFrame *frame)
int ff_vaapi_vpp_init_params(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, const AVFrame *input_frame, AVFrame *output_frame)
int ff_vaapi_vpp_render_picture(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, AVFrame *output_frame)
static int vaapi_vpp_render_single_pipeline_buffer(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, VABufferID *params_id)
void ff_vaapi_vpp_ctx_uninit(AVFilterContext *avctx)
static void vaapi_vpp_fill_chroma_sample_location(VAAPIColourProperties *props)
static VASurfaceID ff_vaapi_vpp_get_surface_id(const AVFrame *frame)
#define VAAPI_VPP_BACKGROUND_BLACK