21 #include <mfx/mfxvideo.h>
22 #include <mfx/mfxplugin.h>
38 #if QSV_VERSION_ATLEAST(1, 8)
40 return MFX_CODEC_HEVC;
44 return MFX_CODEC_MPEG2;
59 case MFX_ERR_MEMORY_ALLOC:
60 case MFX_ERR_NOT_ENOUGH_BUFFER:
62 case MFX_ERR_INVALID_HANDLE:
64 case MFX_ERR_DEVICE_FAILED:
65 case MFX_ERR_DEVICE_LOST:
66 case MFX_ERR_LOCK_MEMORY:
68 case MFX_ERR_NULL_PTR:
69 case MFX_ERR_UNDEFINED_BEHAVIOR:
70 case MFX_ERR_NOT_INITIALIZED:
72 case MFX_ERR_UNSUPPORTED:
73 case MFX_ERR_NOT_FOUND:
75 case MFX_ERR_MORE_DATA:
76 case MFX_ERR_MORE_SURFACE:
77 case MFX_ERR_MORE_BITSTREAM:
79 case MFX_ERR_INCOMPATIBLE_VIDEO_PARAM:
80 case MFX_ERR_INVALID_VIDEO_PARAM:
92 #ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
95 VADisplay va_dpy =
NULL;
96 VAStatus va_res = VA_STATUS_SUCCESS;
97 int major_version = 0, minor_version = 0;
99 char adapterpath[256];
103 qs->va_display =
NULL;
106 for (adapter_num = 0;adapter_num < 6;adapter_num++) {
109 snprintf(adapterpath,
sizeof(adapterpath),
110 "/dev/dri/renderD%d", adapter_num+128);
112 snprintf(adapterpath,
sizeof(adapterpath),
113 "/dev/dri/card%d", adapter_num-3);
116 fd = open(adapterpath, O_RDWR);
119 "mfx init: %s fd open failed\n", adapterpath);
123 va_dpy = vaGetDisplayDRM(fd);
126 "mfx init: %s vaGetDisplayDRM failed\n", adapterpath);
131 va_res = vaInitialize(va_dpy, &major_version, &minor_version);
132 if (VA_STATUS_SUCCESS != va_res) {
134 "mfx init: %s vaInitialize failed\n", adapterpath);
140 "mfx initialization: %s vaInitialize successful\n",adapterpath);
142 qs->va_display = va_dpy;
143 ret = MFXVideoCORE_SetHandle(qs->
session,
144 (mfxHandleType)MFX_HANDLE_VA_DISPLAY, (mfxHDL)va_dpy);
147 "Error %d during set display handle\n", ret);
153 #endif //AVCODEC_QSV_LINUX_SESSION_HANDLE
172 const char *load_plugins)
174 mfxIMPL impl = MFX_IMPL_AUTO_ANY;
180 ret = MFXInit(impl, &ver, &qs->
session);
190 if (load_plugins && *load_plugins) {
191 while (*load_plugins) {
198 if (strlen(plugin) != 2 *
sizeof(uid.Data)) {
201 goto load_plugin_fail;
204 for (i = 0; i <
sizeof(uid.Data); i++) {
205 err = sscanf(plugin + 2 * i,
"%2hhx", uid.Data + i);
209 goto load_plugin_fail;
214 ret = MFXVideoUSER_Load(qs->
session, &uid, 1);
219 goto load_plugin_fail;
231 MFXQueryIMPL(qs->
session, &impl);
233 switch (MFX_IMPL_BASETYPE(impl)) {
234 case MFX_IMPL_SOFTWARE:
237 case MFX_IMPL_HARDWARE:
238 case MFX_IMPL_HARDWARE2:
239 case MFX_IMPL_HARDWARE3:
240 case MFX_IMPL_HARDWARE4:
241 desc =
"hardware accelerated";
248 "Initialized an internal MFX session using %s implementation\n",
260 #ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
261 if (qs->va_display) {
262 vaTerminate(qs->va_display);
263 qs->va_display =
NULL;
265 if (qs->fd_display > 0) {
266 close(qs->fd_display);
#define AV_LOG_VERBOSE
Detailed information.
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int ff_qsv_close_internal_session(QSVSession *qs)
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
#define QSV_VERSION_MINOR
int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
preferred ID for MPEG-1/2 video decoding
int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs, const char *load_plugins)
Initialize a MSDK session.
Libavcodec external API header.
main external API structure.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
int ff_qsv_error(int mfx_err)
Convert a libmfx error code into a ffmpeg error code.
#define QSV_VERSION_MAJOR
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
static int ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession *qs)