[FFmpeg-devel] [PATCH 5/5] avcodec/qsv: remove no longer needed functions ff_qsv_init_internal_session & ff_qsv_close_internal_session, structure QSVSession, since they are now replaced by avutil/hwcontext_qsv
nablet developer
sdk at nablet.com
Wed May 25 14:20:51 CEST 2016
Signed-off-by: nablet developer <sdk at nablet.com>
---
libavcodec/qsv.c | 186 ----------------------------------------------
libavcodec/qsv_internal.h | 30 --------
2 files changed, 216 deletions(-)
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 8cd03e8..22c99cf 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -19,7 +19,6 @@
*/
#include <mfx/mfxvideo.h>
-#include <mfx/mfxplugin.h>
#include <stdio.h>
#include <string.h>
@@ -51,188 +50,3 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
return AVERROR(ENOSYS);
}
-
-static int ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession *qs)
-{
- // this code is only required for Linux. It searches for a valid
- // display handle. First in /dev/dri/renderD then in /dev/dri/card
-#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
- // VAAPI display handle
- int ret = 0;
- VADisplay va_dpy = NULL;
- VAStatus va_res = VA_STATUS_SUCCESS;
- int major_version = 0, minor_version = 0;
- int fd = -1;
- char adapterpath[256];
- int adapter_num;
-
- qs->fd_display = -1;
- qs->va_display = NULL;
-
- //search for valid graphics device
- for (adapter_num = 0;adapter_num < 6;adapter_num++) {
-
- if (adapter_num<3) {
- snprintf(adapterpath,sizeof(adapterpath),
- "/dev/dri/renderD%d", adapter_num+128);
- } else {
- snprintf(adapterpath,sizeof(adapterpath),
- "/dev/dri/card%d", adapter_num-3);
- }
-
- fd = open(adapterpath, O_RDWR);
- if (fd < 0) {
- av_log(avctx, AV_LOG_ERROR,
- "mfx init: %s fd open failed\n", adapterpath);
- continue;
- }
-
- va_dpy = vaGetDisplayDRM(fd);
- if (!va_dpy) {
- av_log(avctx, AV_LOG_ERROR,
- "mfx init: %s vaGetDisplayDRM failed\n", adapterpath);
- close(fd);
- continue;
- }
-
- va_res = vaInitialize(va_dpy, &major_version, &minor_version);
- if (VA_STATUS_SUCCESS != va_res) {
- av_log(avctx, AV_LOG_ERROR,
- "mfx init: %s vaInitialize failed\n", adapterpath);
- close(fd);
- fd = -1;
- continue;
- } else {
- av_log(avctx, AV_LOG_VERBOSE,
- "mfx initialization: %s vaInitialize successful\n",adapterpath);
- qs->fd_display = fd;
- qs->va_display = va_dpy;
- ret = MFXVideoCORE_SetHandle(qs->session,
- (mfxHandleType)MFX_HANDLE_VA_DISPLAY, (mfxHDL)va_dpy);
- if (ret < 0) {
- av_log(avctx, AV_LOG_ERROR,
- "Error %d during set display handle\n", ret);
- return avpriv_qsv_error(ret);
- }
- break;
- }
- }
-#endif //AVCODEC_QSV_LINUX_SESSION_HANDLE
- return 0;
-}
-/**
- * @brief Initialize a MSDK session
- *
- * Media SDK is based on sessions, so this is the prerequisite
- * initialization for HW acceleration. For Windows the session is
- * complete and ready to use, for Linux a display handle is
- * required. For releases of Media Server Studio >= 2015 R4 the
- * render nodes interface is preferred (/dev/dri/renderD).
- * Using Media Server Studio 2015 R4 or newer is recommended
- * but the older /dev/dri/card interface is also searched
- * for broader compatibility.
- *
- * @param avctx ffmpeg metadata for this codec context
- * @param session the MSDK session used
- */
-int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs,
- const char *load_plugins)
-{
- mfxIMPL impl = MFX_IMPL_AUTO_ANY;
- mfxVersion ver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } };
-
- const char *desc;
- int ret;
-
- ret = MFXInit(impl, &ver, &qs->session);
- if (ret < 0) {
- av_log(avctx, AV_LOG_ERROR, "Error initializing an internal MFX session\n");
- return avpriv_qsv_error(ret);
- }
-
- ret = ff_qsv_set_display_handle(avctx, qs);
- if (ret < 0)
- return ret;
-
- if (load_plugins && *load_plugins) {
- while (*load_plugins) {
- mfxPluginUID uid;
- int i, err = 0;
-
- char *plugin = av_get_token(&load_plugins, ":");
- if (!plugin)
- return AVERROR(ENOMEM);
- if (strlen(plugin) != 2 * sizeof(uid.Data)) {
- av_log(avctx, AV_LOG_ERROR, "Invalid plugin UID length\n");
- err = AVERROR(EINVAL);
- goto load_plugin_fail;
- }
-
- for (i = 0; i < sizeof(uid.Data); i++) {
- err = sscanf(plugin + 2 * i, "%2hhx", uid.Data + i);
- if (err != 1) {
- av_log(avctx, AV_LOG_ERROR, "Invalid plugin UID\n");
- err = AVERROR(EINVAL);
- goto load_plugin_fail;
- }
-
- }
-
- ret = MFXVideoUSER_Load(qs->session, &uid, 1);
- if (ret < 0) {
- av_log(avctx, AV_LOG_ERROR, "Could not load the requested plugin: %s\n",
- plugin);
- err = avpriv_qsv_error(ret);
- goto load_plugin_fail;
- }
-
- if (*load_plugins)
- load_plugins++;
-load_plugin_fail:
- av_freep(&plugin);
- if (err < 0)
- return err;
- }
- }
-
- MFXQueryIMPL(qs->session, &impl);
-
- switch (MFX_IMPL_BASETYPE(impl)) {
- case MFX_IMPL_SOFTWARE:
- desc = "software";
- break;
- case MFX_IMPL_HARDWARE:
- case MFX_IMPL_HARDWARE2:
- case MFX_IMPL_HARDWARE3:
- case MFX_IMPL_HARDWARE4:
- desc = "hardware accelerated";
- break;
- default:
- desc = "unknown";
- }
-
- av_log(avctx, AV_LOG_VERBOSE,
- "Initialized an internal MFX session using %s implementation\n",
- desc);
-
- return 0;
-}
-
-int ff_qsv_close_internal_session(QSVSession *qs)
-{
- if (qs->session) {
- MFXClose(qs->session);
- qs->session = NULL;
- }
-#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
- if (qs->va_display) {
- vaTerminate(qs->va_display);
- qs->va_display = NULL;
- }
- if (qs->fd_display > 0) {
- close(qs->fd_display);
- qs->fd_display = -1;
- }
-#endif
- return 0;
-}
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index ce2531b..e577917 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -21,30 +21,12 @@
#ifndef AVCODEC_QSV_INTERNAL_H
#define AVCODEC_QSV_INTERNAL_H
-#if CONFIG_VAAPI
-#define AVCODEC_QSV_LINUX_SESSION_HANDLE
-#endif //CONFIG_VAAPI
-
-#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
-#include <stdio.h>
-#include <string.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <fcntl.h>
-#include <va/va.h>
-#include <va/va_drm.h>
-#endif
-
#include <mfx/mfxvideo.h>
#include "libavutil/frame.h"
#include "avcodec.h"
-#define QSV_VERSION_MAJOR 1
-#define QSV_VERSION_MINOR 9
-
#define ASYNC_DEPTH_DEFAULT 4 // internal parallelism
#define QSV_MAX_ENC_PAYLOAD 2 // # of mfxEncodeCtrl payloads supported
@@ -65,18 +47,6 @@ typedef struct QSVFrame {
struct QSVFrame *next;
} QSVFrame;
-typedef struct QSVSession {
- mfxSession session;
-#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
- int fd_display;
- VADisplay va_display;
-#endif
-} QSVSession;
-
int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id);
-int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs,
- const char *load_plugins);
-int ff_qsv_close_internal_session(QSVSession *qs);
-
#endif /* AVCODEC_QSV_INTERNAL_H */
--
1.8.3.1
More information about the ffmpeg-devel
mailing list