42 type, size, 1, (
void*)data, &buffer);
43 if (vas != VA_STATUS_SUCCESS) {
45 "buffer (type %d): %d (%s).\n",
46 type, vas, vaErrorStr(vas));
53 "is %#x.\n", type, size, buffer);
60 const void *params_data,
62 const void *slice_data,
88 VASliceParameterBufferType,
89 params_size, 1, (
void*)params_data,
91 if (vas != VA_STATUS_SUCCESS) {
93 "parameter buffer: %d (%s).\n", vas, vaErrorStr(vas));
102 VASliceDataBufferType,
103 slice_size, 1, (
void*)slice_data,
105 if (vas != VA_STATUS_SUCCESS) {
107 "data buffer (size %zu): %d (%s).\n",
108 slice_size, vas, vaErrorStr(vas));
132 if (vas != VA_STATUS_SUCCESS) {
134 "parameter buffer %#x: %d (%s).\n",
139 for (i = 0; i < 2 * pic->
nb_slices; i++) {
142 if (vas != VA_STATUS_SUCCESS) {
144 "slice buffer %#x: %d (%s).\n",
162 if (vas != VA_STATUS_SUCCESS) {
164 "issue: %d (%s).\n", vas, vaErrorStr(vas));
166 goto fail_with_picture;
171 if (vas != VA_STATUS_SUCCESS) {
173 "parameters: %d (%s).\n", vas, vaErrorStr(vas));
175 goto fail_with_picture;
180 if (vas != VA_STATUS_SUCCESS) {
182 "%d (%s).\n", vas, vaErrorStr(vas));
184 goto fail_with_picture;
188 if (vas != VA_STATUS_SUCCESS) {
190 "issue: %d (%s).\n", vas, vaErrorStr(vas));
208 if (vas != VA_STATUS_SUCCESS) {
210 "after error: %d (%s).\n", vas, vaErrorStr(vas));
237 static const struct {
241 #define MAP(va, av) { VA_FOURCC_ ## va, AV_PIX_FMT_ ## av }
248 #ifdef VA_FOURCC_I420
256 #ifdef VA_FOURCC_YV16
264 #ifdef VA_FOURCC_P010
267 #ifdef VA_FOURCC_I010
268 MAP(I010, YUV420P10),
275 VAConfigID config_id,
280 VASurfaceAttrib *attr;
282 uint32_t best_fourcc,
fourcc;
288 vas = vaQuerySurfaceAttributes(hwctx->
display, config_id,
290 if (vas != VA_STATUS_SUCCESS) {
292 "%d (%s).\n", vas, vaErrorStr(vas));
300 vas = vaQuerySurfaceAttributes(hwctx->
display, config_id,
302 if (vas != VA_STATUS_SUCCESS) {
304 "%d (%s).\n", vas, vaErrorStr(vas));
311 for (i = 0; i < nb_attr; i++) {
312 if (attr[i].
type != VASurfaceAttribPixelFormat)
315 fourcc = attr[i].value.value.i;
330 source_format, 0,
NULL);
331 if (format == best_format)
352 .type = VASurfaceAttribPixelFormat,
353 .value.value.i = best_fourcc,
363 static const struct {
368 #define MAP(c, p, v) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, VAProfile ## v }
369 MAP(MPEG2VIDEO, MPEG2_SIMPLE, MPEG2Simple ),
370 MAP(MPEG2VIDEO, MPEG2_MAIN, MPEG2Main ),
372 MAP(MPEG4, MPEG4_SIMPLE, MPEG4Simple ),
373 MAP(MPEG4, MPEG4_ADVANCED_SIMPLE,
374 MPEG4AdvancedSimple),
375 MAP(MPEG4, MPEG4_MAIN, MPEG4Main ),
376 MAP(H264, H264_CONSTRAINED_BASELINE,
377 H264ConstrainedBaseline),
378 MAP(H264, H264_MAIN, H264Main ),
379 MAP(H264, H264_HIGH, H264High ),
380 #if VA_CHECK_VERSION(0, 37, 0)
381 MAP(HEVC, HEVC_MAIN, HEVCMain ),
382 MAP(HEVC, HEVC_MAIN_10, HEVCMain10 ),
384 MAP(MJPEG, MJPEG_HUFFMAN_BASELINE_DCT,
386 MAP(WMV3, VC1_SIMPLE, VC1Simple ),
387 MAP(WMV3, VC1_MAIN, VC1Main ),
388 MAP(WMV3, VC1_COMPLEX, VC1Advanced ),
389 MAP(WMV3, VC1_ADVANCED, VC1Advanced ),
390 MAP(VC1, VC1_SIMPLE, VC1Simple ),
391 MAP(VC1, VC1_MAIN, VC1Main ),
392 MAP(VC1, VC1_COMPLEX, VC1Advanced ),
393 MAP(VC1, VC1_ADVANCED, VC1Advanced ),
395 #if VA_CHECK_VERSION(0, 38, 0)
396 MAP(VP9, VP9_0, VP9Profile0 ),
398 #if VA_CHECK_VERSION(0, 39, 0)
399 MAP(VP9, VP9_2, VP9Profile2 ),
410 VAConfigID *va_config,
418 VAProfile *profile_list =
NULL, matched_va_profile;
419 int profile_count, exact_match, matched_ff_profile;
430 profile_count = vaMaxNumProfiles(hwctx->display);
438 vas = vaQueryConfigProfiles(hwctx->display,
439 profile_list, &profile_count);
440 if (vas != VA_STATUS_SUCCESS) {
442 "%d (%s).\n", vas, vaErrorStr(vas));
447 matched_va_profile = VAProfileNone;
451 int profile_match = 0;
457 for (j = 0; j < profile_count; j++) {
459 exact_match = profile_match;
463 if (j < profile_count) {
472 if (matched_va_profile == VAProfileNone) {
474 "profile %d.\n", codec_desc->
name, avctx->
profile);
482 "supported for hardware decode.\n",
485 "incompatible profile %d instead.\n",
489 "supported for hardware decode.\n",
496 vas = vaCreateConfig(hwctx->display, matched_va_profile,
497 VAEntrypointVLD,
NULL, 0,
499 if (vas != VA_STATUS_SUCCESS) {
501 "configuration: %d (%s).\n", vas, vaErrorStr(vas));
525 "size %dx%d (constraints: width %d-%d height %d-%d).\n",
535 "usable surface formats.\n");
578 if (*va_config != VA_INVALID_ID) {
579 vaDestroyConfig(hwctx->display, *va_config);
580 *va_config = VA_INVALID_ID;
592 VAConfigID va_config = VA_INVALID_ID;
597 hwctx = device_ctx->hwctx;
604 if (va_config != VA_INVALID_ID)
605 vaDestroyConfig(hwctx->display, va_config);
619 #if FF_API_STRUCT_VAAPI_CONTEXT
622 "vaapi_context in decode.\n");
649 #if FF_API_STRUCT_VAAPI_CONTEXT
679 if (vas != VA_STATUS_SUCCESS) {
681 "context: %d (%s).\n", vas, vaErrorStr(vas));
688 #if FF_API_STRUCT_VAAPI_CONTEXT
704 #if FF_API_STRUCT_VAAPI_CONTEXT
712 if (vas != VA_STATUS_SUCCESS) {
714 "context %#x: %d (%s).\n",
720 if (vas != VA_STATUS_SUCCESS) {
722 "configuration %#x: %d (%s).\n",
727 #if FF_API_STRUCT_VAAPI_CONTEXT
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
static const char * format[]
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.
ptrdiff_t const GLvoid * data
int coded_width
Bitstream width / height, may be different from width/height e.g.
#define AV_LOG_WARNING
Something somehow does not look correct.
VASurfaceAttrib * attributes
Set by the user to apply surface attributes to all surfaces in the frame pool.
static void ff_vaapi_decode_destroy_buffers(AVCodecContext *avctx, VAAPIDecodePicture *pic)
int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx, VAAPIDecodePicture *pic, int type, const void *data, size_t size)
The driver does not destroy parameter buffers when they are used by vaRenderPicture().
VASurfaceAttrib pixel_format_attribute
enum AVPixelFormat pix_fmt
uint32_t context_id
Context ID (video decode pipeline)
FF_ENABLE_DEPRECATION_WARNINGS AVHWDeviceContext * device
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.
int max_width
The maximum size of frames in this hw_frames_ctx.
int ff_vaapi_common_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
void av_hwframe_constraints_free(AVHWFramesConstraints **constraints)
Free an AVHWFrameConstraints structure.
static int vaapi_decode_find_best_format(AVCodecContext *avctx, AVHWDeviceContext *device, VAConfigID config_id, AVHWFramesContext *frames)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_vaapi_decode_uninit(AVCodecContext *avctx)
void * hwaccel_context
Hardware accelerator context.
int ff_vaapi_decode_issue(AVCodecContext *avctx, VAAPIDecodePicture *pic)
AVHWFramesContext * frames
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
AVVAAPIDeviceContext * hwctx
#define AV_LOG_VERBOSE
Detailed information.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVVAAPIFramesContext * hwfc
VAAPI hardware pipeline configuration details.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
simple assert() macros that are a bit more flexible than ISO C assert().
FF_DISABLE_DEPRECATION_WARNINGS int have_old_context
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
static const struct @155 vaapi_format_map[]
int initial_pool_size
Initial size of the frame pool.
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
int ff_vaapi_decode_init(AVCodecContext *avctx)
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames...
#define FF_PROFILE_UNKNOWN
VABufferID * slice_buffers
struct vaapi_context * old_context
#define FF_ARRAY_ELEMS(a)
VABufferID param_buffers[MAX_PARAM_BUFFERS]
VADisplay display
The VADisplay handle, to be filled by the user.
VASurfaceID output_surface
void * display
Window system dependent data.
int min_width
The minimum size of frames in this hw_frames_ctx.
AVBufferRef * av_hwdevice_ctx_alloc(enum AVHWDeviceType type)
Allocate an AVHWDeviceContext for a given hardware type.
Libavcodec external API header.
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
main external API structure.
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...
This struct describes a set or pool of "hardware" frames (i.e.
const char * name
Name of the codec described by this descriptor.
int ff_vaapi_decode_cancel(AVCodecContext *avctx, VAAPIDecodePicture *pic)
This struct describes the properties of a single codec described by an AVCodecID. ...
int ff_decode_get_hw_frames_ctx(AVCodecContext *avctx, enum AVHWDeviceType dev_type)
Make sure avctx.hw_frames_ctx is set.
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
A reference to a data buffer.
common internal api header.
common internal and external API header
void * hwaccel_priv_data
hwaccel-specific private data
enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
Compute what kind of losses will occur when converting from one specific pixel format to another...
struct AVCodecInternal * internal
Private context used for internal data.
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.
static int vaapi_decode_make_config(AVCodecContext *avctx, AVBufferRef *device_ref, VAConfigID *va_config, AVBufferRef *frames_ref)
VASurfaceID * surface_ids
The surfaces IDs of all surfaces in the pool after creation.
#define AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH
Hardware acceleration should still be attempted for decoding when the codec profile does not match th...
int hwaccel_flags
Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated decoding (if active)...
#define av_malloc_array(a, b)
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 const struct @156 vaapi_profile_map[]
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
AVPixelFormat
Pixel format.
int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx, VAAPIDecodePicture *pic, const void *params_data, size_t params_size, const void *slice_data, size_t slice_size)
enum AVPixelFormat sw_pix_fmt
Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
uint32_t config_id
Configuration ID.