diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 250b4e61e3..8108dadf89 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -247,9 +247,9 @@ load_plugin_fail: } int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session, - const char *load_plugins) + const char *load_plugins, int hw_impl_only) { - mfxIMPL impl = MFX_IMPL_AUTO_ANY; + mfxIMPL impl = hw_impl_only ? MFX_IMPL_HARDWARE_ANY : MFX_IMPL_AUTO_ANY; mfxVersion ver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } }; const char *desc; diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index c0305508dd..a6d278d1bf 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -88,7 +88,7 @@ int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int profile); int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc); int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session, - const char *load_plugins); + const char *load_plugins, int hw_impl_only); int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession, AVBufferRef *device_ref, const char *load_plugins); diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 55fe59b531..fde8b3b969 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -96,7 +96,7 @@ static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession ses } else { if (!q->internal_session) { ret = ff_qsv_init_internal_session(avctx, &q->internal_session, - q->load_plugins); + q->load_plugins, q->hw_impl_only); if (ret < 0) return ret; } diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h index 5b7b03a48b..e76560c2a9 100644 --- a/libavcodec/qsvdec.h +++ b/libavcodec/qsvdec.h @@ -69,6 +69,8 @@ typedef struct QSVContext { mfxExtBuffer **ext_buffers; int nb_ext_buffers; + + int hw_impl_only; } QSVContext; extern const AVCodecHWConfigInternal *ff_qsv_hw_configs[]; diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index fee2f9f0e8..a8bde48579 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -793,7 +793,7 @@ static int qsvenc_init_session(AVCodecContext *avctx, QSVEncContext *q) q->session = q->internal_session; } else { ret = ff_qsv_init_internal_session(avctx, &q->internal_session, - q->load_plugins); + q->load_plugins, q->hw_impl_only); if (ret < 0) return ret; diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index 88e0728110..b5c0b95d7d 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -156,6 +156,8 @@ typedef struct QSVEncContext { int a53_cc; char *load_plugins; SetEncodeCtrlCB *set_encode_ctrl_cb; + + int hw_impl_only; } QSVEncContext; int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q); diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index 09e4c0e599..2159187af5 100644 --- a/libavcodec/qsvenc_h264.c +++ b/libavcodec/qsvenc_h264.c @@ -142,6 +142,7 @@ static const AVOption options[] = { { "high" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_AVC_HIGH }, INT_MIN, INT_MAX, VE, "profile" }, { "a53cc" , "Use A53 Closed Captions (if available)", OFFSET(qsv.a53_cc), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, VE}, + { "hw_impl_only", "Require hardware QSV implemtation", OFFSET(qsv.hw_impl_only), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, { NULL }, };