diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-07-09 11:52:05 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-07-09 11:53:14 +0200 |
commit | 7871eb43616776626ec9f9075b6d0a8cf73d159e (patch) | |
tree | f9a88703414cd33e32c5f682974d8b4f96837b92 /libavcodec/qsv.c | |
parent | 587980eb7a1f4b0228204aa846b72dc761e49779 (diff) | |
parent | 66acb76bb0492b263215ca9b4d927a7be39ace02 (diff) | |
download | ffmpeg-7871eb43616776626ec9f9075b6d0a8cf73d159e.tar.gz |
Merge commit '66acb76bb0492b263215ca9b4d927a7be39ace02'
* commit '66acb76bb0492b263215ca9b4d927a7be39ace02':
lavc: add Intel libmfx-based HEVC encoder
Conflicts:
Changelog
configure
libavcodec/Makefile
libavcodec/allcodecs.c
libavcodec/qsv.c
libavcodec/qsvenc.c
libavcodec/version.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/qsv.c')
-rw-r--r-- | libavcodec/qsv.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index dab9d1ef59..697af872a6 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -19,7 +19,12 @@ */ #include <mfx/mfxvideo.h> +#include <mfx/mfxplugin.h> +#include <stdio.h> +#include <string.h> + +#include "libavutil/avstring.h" #include "libavutil/error.h" #include "avcodec.h" @@ -30,6 +35,10 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id) switch (codec_id) { case AV_CODEC_ID_H264: return MFX_CODEC_AVC; +#if QSV_VERSION_ATLEAST(1, 8) + case AV_CODEC_ID_HEVC: + return MFX_CODEC_HEVC; +#endif case AV_CODEC_ID_MPEG1VIDEO: case AV_CODEC_ID_MPEG2VIDEO: return MFX_CODEC_MPEG2; @@ -154,7 +163,8 @@ static int ff_qsv_set_display_handle(AVCodecContext *avctx, mfxSession session) * @param avctx ffmpeg metadata for this codec context * @param session the MSDK session used */ -int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session) +int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session, + const char *load_plugins) { mfxIMPL impl = MFX_IMPL_AUTO_ANY; mfxVersion ver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } }; @@ -188,6 +198,45 @@ int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session) desc = "unknown"; } + 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(*session, &uid, 1); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Could not load the requested plugin: %s\n", + plugin); + err = ff_qsv_error(ret); + goto load_plugin_fail; + } + +load_plugin_fail: + av_freep(&plugin); + if (err < 0) + return err; + } + } + av_log(avctx, AV_LOG_VERBOSE, "Initialized an internal MFX session using %s implementation\n", desc); |