26 # include <va/va_x11.h>
29 # include <va/va_drm.h>
33 #include "libavutil/avconfig.h"
53 #define DEFAULT_SURFACES 20
94 (
unsigned int)(uintptr_t)frame->
data[3]);
114 (
unsigned int)(uintptr_t)input->
data[3]);
125 "output frame: %d.\n", err);
148 static const struct {
153 #define MAP(c, p, v) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, VAProfile ## v }
154 MAP(MPEG2VIDEO, MPEG2_SIMPLE, MPEG2Simple ),
155 MAP(MPEG2VIDEO, MPEG2_MAIN, MPEG2Main ),
157 MAP(MPEG4, MPEG4_SIMPLE, MPEG4Simple ),
158 MAP(MPEG4, MPEG4_ADVANCED_SIMPLE,
159 MPEG4AdvancedSimple),
160 MAP(MPEG4, MPEG4_MAIN, MPEG4Main ),
161 MAP(H264, H264_CONSTRAINED_BASELINE,
162 H264ConstrainedBaseline),
163 MAP(H264, H264_BASELINE, H264Baseline),
164 MAP(H264, H264_MAIN, H264Main ),
165 MAP(H264, H264_HIGH, H264High ),
166 #if VA_CHECK_VERSION(0, 37, 0)
167 MAP(HEVC, HEVC_MAIN, HEVCMain ),
169 MAP(WMV3, VC1_SIMPLE, VC1Simple ),
170 MAP(WMV3, VC1_MAIN, VC1Main ),
171 MAP(WMV3, VC1_COMPLEX, VC1Advanced ),
172 MAP(WMV3, VC1_ADVANCED, VC1Advanced ),
173 MAP(VC1, VC1_SIMPLE, VC1Simple ),
174 MAP(VC1, VC1_MAIN, VC1Main ),
175 MAP(VC1, VC1_COMPLEX, VC1Advanced ),
176 MAP(VC1, VC1_ADVANCED, VC1Advanced ),
177 #if VA_CHECK_VERSION(0, 35, 0)
180 #if VA_CHECK_VERSION(0, 37, 1)
181 MAP(VP9, VP9_0, VP9Profile0 ),
188 int fallback_allowed)
200 int profile_count, exact_match, alt_profile;
208 profile_count = vaMaxNumProfiles(hwctx->
display);
209 profile_list =
av_malloc(profile_count *
sizeof(VAProfile));
215 vas = vaQueryConfigProfiles(hwctx->
display,
216 profile_list, &profile_count);
217 if (vas != VA_STATUS_SUCCESS) {
218 av_log(ctx, loglevel,
"Failed to query profiles: %d (%s).\n",
219 vas, vaErrorStr(vas));
224 profile = VAProfileNone;
228 int profile_match = 0;
234 for (j = 0; j < profile_count; j++) {
235 if (profile == profile_list[j]) {
236 exact_match = profile_match;
240 if (j < profile_count) {
248 if (profile == VAProfileNone) {
249 av_log(ctx, loglevel,
"No VAAPI support for codec %s.\n",
256 av_log(ctx, loglevel,
"No VAAPI support for codec %s "
257 "profile %d.\n", codec_desc->
name, avctx->
profile);
258 if (!fallback_allowed) {
260 "anyway with a possibly-incompatible profile, add "
261 "the option -hwaccel_lax_profile_check.\n");
267 "profile %d: trying instead with profile %d.\n",
270 "incorrect results, depending on your hardware.\n");
279 if (vas != VA_STATUS_SUCCESS) {
281 "configuration: %d (%s).\n", vas, vaErrorStr(vas));
352 "size %dx%d (constraints: width %d-%d height %d-%d).\n",
452 av_log(ctx, loglevel,
"No supported configuration for this codec.");
460 av_log(ctx, loglevel,
"Failed to create VAAPI frame context.\n");
475 av_log(ctx, loglevel,
"Failed to initialise VAAPI frame "
476 "context: %d\n", err);
487 if (vas != VA_STATUS_SUCCESS) {
489 "context: %d (%s).\n", vas, vaErrorStr(vas));
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
static enum AVPixelFormat pix_fmt
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
VAAPI-specific data associated with a frame pool.
static const struct @25 vaapi_profile_map[]
This structure describes decoded (raw) audio or video data.
AVHWDeviceContext * device
int coded_width
Bitstream width / height, may be different from width/height e.g.
#define AV_LOG_WARNING
Something somehow does not look correct.
static int vaapi_build_decoder_config(VAAPIDecoderContext *ctx, AVCodecContext *avctx, int fallback_allowed)
#define LIBAVUTIL_VERSION_INT
uint32_t context_id
Context ID (video decode pipeline)
int width
The allocated dimensions of the frames in this pool.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
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.
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
This structure is used to share data between the FFmpeg library and the client video application...
int vaapi_decode_init(AVCodecContext *avctx)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
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 * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
void * hwaccel_context
Hardware accelerator context.
struct vaapi_context decoder_vaapi_context
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
int av_hwdevice_ctx_create(AVBufferRef **pdevice_ref, enum AVHWDeviceType type, const char *device, AVDictionary *opts, int flags)
Open a device of the specified type and create an AVHWDeviceContext for it.
VAEntrypoint va_entrypoint
#define AV_LOG_VERBOSE
Detailed information.
static AVClass vaapi_class
enum AVPixelFormat output_format
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
VAAPI hardware pipeline configuration details.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int active_thread_type
Which multithreading methods are in use by the codec.
#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().
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
static int vaapi_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
int hwaccel_lax_profile_check
reference-counted frame API
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags)
Copy data to or from a hw surface.
int initial_pool_size
Initial size of the frame pool.
uint8_t nb_components
The number of components each pixel has, (1-4)
#define FF_THREAD_FRAME
Decode more than one frame at once.
enum AVPixelFormat decode_format
AVHWFramesContext * frames
#define FF_ARRAY_ELEMS(a)
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
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...
void * display
Window system dependent data.
int min_width
The minimum size of frames in this hw_frames_ctx.
av_cold int vaapi_device_init(const char *device)
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
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.
Describe the class of an AVClass context structure.
static int vaapi_retrieve_data(AVCodecContext *avctx, AVFrame *input)
Public libavcodec VA API header.
This struct describes a set or pool of "hardware" frames (i.e.
refcounted data buffer API
const char * name
Name of the codec described by this descriptor.
This struct describes the properties of a single codec described by an AVCodecID. ...
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
A reference to a data buffer.
static void vaapi_decode_uninit(AVCodecContext *avctx)
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
AVBufferRef * hw_device_ctx
static AVClass * vaapi_log
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.
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.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
AVPixelFormat
Pixel format.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
void * opaque
Private data of the user, can be used to carry app specific stuff.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
uint32_t config_id
Configuration ID.