From ac931d258ac33c21ee1a9fd09f87bdf191b9a1b0 Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Tue, 24 Sep 2024 20:03:23 +0800 Subject: [PATCH 1/2] Allow VPL QSV to init with the legacy MSDK path Signed-off-by: nyanmisaka --- ...sv-to-init-with-the-legacy-msdk-path.patch | 236 ++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 237 insertions(+) create mode 100644 debian/patches/0075-allow-vpl-qsv-to-init-with-the-legacy-msdk-path.patch diff --git a/debian/patches/0075-allow-vpl-qsv-to-init-with-the-legacy-msdk-path.patch b/debian/patches/0075-allow-vpl-qsv-to-init-with-the-legacy-msdk-path.patch new file mode 100644 index 00000000000..ebaeeff8868 --- /dev/null +++ b/debian/patches/0075-allow-vpl-qsv-to-init-with-the-legacy-msdk-path.patch @@ -0,0 +1,236 @@ +Index: FFmpeg/configure +=================================================================== +--- FFmpeg.orig/configure ++++ FFmpeg/configure +@@ -2528,6 +2528,7 @@ HAVE_LIST=" + xmllint + zlib_gzip + openvino2 ++ libvpl_legacy_mfxinit + " + + # options emitted with CONFIG_ prefix but not available on the command line +@@ -6947,6 +6948,9 @@ elif enabled libvpl; then + die "ERROR: libvpl >= 2.6 not found" + add_cflags -DMFX_DEPRECATED_OFF + check_type "vpl/mfxdefs.h vpl/mfxvideo.h" "struct mfxConfigInterface" ++# Ancient Intel driver on Windows still require the legacy init functions. ++# No compiler option is changed if the test fails, just needs to add back the disabled libmfx. ++ { test_pkg_config libmfx "vpl >= 2.6" "mfxvideo.h mfxdispatcher.h" "MFXInit MFXInitEx" && enable libvpl_legacy_mfxinit; } || enable libmfx + fi + + if enabled libmfx; then +Index: FFmpeg/libavcodec/qsv.c +=================================================================== +--- FFmpeg.orig/libavcodec/qsv.c ++++ FFmpeg/libavcodec/qsv.c +@@ -496,6 +496,17 @@ static int ff_qsv_set_display_handle(AVC + } + #endif //AVCODEC_QSV_LINUX_SESSION_HANDLE + ++#if !QSV_ONEVPL || HAVE_LIBVPL_LEGACY_MFXINIT ++ ++static int qsv_create_mfx_session_legacy(AVCodecContext *avctx, ++ mfxIMPL implementation, ++ mfxVersion *pver, ++ int gpu_copy, ++ mfxSession *psession, ++ void **ploader); ++ ++#endif ++ + #if QSV_ONEVPL + static int qsv_new_mfx_loader(AVCodecContext *avctx, + mfxIMPL implementation, +@@ -636,6 +647,16 @@ static int qsv_create_mfx_session(AVCode + return 0; + + fail: ++#if HAVE_LIBVPL_LEGACY_MFXINIT ++ av_log(avctx, AV_LOG_VERBOSE, "Error creating a MFX session using oneVPL, " ++ "falling back to retry with the legacy Media SDK path\n"); ++ if (!qsv_create_mfx_session_legacy(avctx, implementation, pver, gpu_copy, psession, ploader)) { ++ if (!*ploader) ++ *ploader = loader; ++ return 0; ++ } ++#endif ++ + if (!*ploader && loader) + MFXUnload(loader); + +@@ -651,6 +672,20 @@ static int qsv_create_mfx_session(AVCode + mfxSession *psession, + void **ploader) + { ++ return qsv_create_mfx_session_legacy(avctx, implementation, pver, gpu_copy, psession, ploader); ++} ++ ++#endif ++ ++#if !QSV_ONEVPL || HAVE_LIBVPL_LEGACY_MFXINIT ++ ++static int qsv_create_mfx_session_legacy(AVCodecContext *avctx, ++ mfxIMPL implementation, ++ mfxVersion *pver, ++ int gpu_copy, ++ mfxSession *psession, ++ void **ploader) ++{ + mfxInitParam init_par = { MFX_IMPL_AUTO_ANY }; + mfxSession session = NULL; + mfxStatus sts; +Index: FFmpeg/libavcodec/qsvenc.c +=================================================================== +--- FFmpeg.orig/libavcodec/qsvenc.c ++++ FFmpeg/libavcodec/qsvenc.c +@@ -1192,7 +1192,7 @@ static int init_video_param(AVCodecConte + + #if QSV_HAVE_EXT_AV1_PARAM + if (avctx->codec_id == AV_CODEC_ID_AV1) { +- if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 2, 5)) { ++ if (QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 255)) { // (2, 5) + q->extav1tileparam.Header.BufferId = MFX_EXTBUFF_AV1_TILE_PARAM; + q->extav1tileparam.Header.BufferSz = sizeof(q->extav1tileparam); + q->extav1tileparam.NumTileColumns = q->tile_cols; +@@ -1416,7 +1416,7 @@ static int qsv_retrieve_enc_av1_params(A + (mfxExtBuffer*)&co3, + }; + +- if (!QSV_RUNTIME_VERSION_ATLEAST(q->ver, 2, 5)) { ++ if (!QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 255)) { // (2, 5) + av_log(avctx, AV_LOG_ERROR, + "This version of runtime doesn't support AV1 encoding\n"); + return AVERROR_UNKNOWN; +Index: FFmpeg/libavfilter/qsvvpp.c +=================================================================== +--- FFmpeg.orig/libavfilter/qsvvpp.c ++++ FFmpeg/libavfilter/qsvvpp.c +@@ -1067,6 +1067,16 @@ int ff_qsvvpp_filter_frame(QSVVPPContext + return 0; + } + ++#if !QSV_ONEVPL || HAVE_LIBVPL_LEGACY_MFXINIT ++ ++static int qsvvpp_create_mfx_session_legacy(void *ctx, ++ void *loader, ++ mfxIMPL implementation, ++ mfxVersion *pver, ++ mfxSession *psession); ++ ++#endif ++ + #if QSV_ONEVPL + + int ff_qsvvpp_create_mfx_session(void *ctx, +@@ -1110,6 +1120,15 @@ int ff_qsvvpp_create_mfx_session(void *c + impl_idx++; + } + ++#if HAVE_LIBVPL_LEGACY_MFXINIT ++ if (sts < 0) { ++ av_log(ctx, AV_LOG_VERBOSE, "Error creating a MFX session using oneVPL, " ++ "falling back to retry with the legacy Media SDK path\n"); ++ if (!qsvvpp_create_mfx_session_legacy(ctx, loader, implementation, pver, psession)) ++ return 0; ++ } ++#endif ++ + if (sts < 0) + return ff_qsvvpp_print_error(ctx, sts, + "Error creating a MFX session"); +@@ -1127,6 +1146,19 @@ int ff_qsvvpp_create_mfx_session(void *c + mfxVersion *pver, + mfxSession *psession) + { ++ return qsvvpp_create_mfx_session_legacy(ctx, loader, implementation, pver, psession); ++} ++ ++#endif ++ ++#if !QSV_ONEVPL || HAVE_LIBVPL_LEGACY_MFXINIT ++ ++static int qsvvpp_create_mfx_session_legacy(void *ctx, ++ void *loader, ++ mfxIMPL implementation, ++ mfxVersion *pver, ++ mfxSession *psession) ++{ + mfxSession session = NULL; + mfxStatus sts; + +Index: FFmpeg/libavfilter/vf_vpp_qsv.c +=================================================================== +--- FFmpeg.orig/libavfilter/vf_vpp_qsv.c ++++ FFmpeg/libavfilter/vf_vpp_qsv.c +@@ -426,7 +426,7 @@ static int vpp_set_frame_ext_params(AVFi + fp->num_ext_buf = 0; + + if (!in || !out || +- !QSV_RUNTIME_VERSION_ATLEAST(qsvvpp->ver, 2, 0)) ++ !QSV_RUNTIME_VERSION_ATLEAST(qsvvpp->ver, 1, 255)) // (2, 0) + return 0; + + memset(&invsi_conf, 0, sizeof(mfxExtVideoSignalInfo)); +Index: FFmpeg/libavutil/hwcontext_qsv.c +=================================================================== +--- FFmpeg.orig/libavutil/hwcontext_qsv.c ++++ FFmpeg/libavutil/hwcontext_qsv.c +@@ -827,6 +827,18 @@ static mfxStatus frame_get_hdl(mfxHDL pt + return MFX_ERR_NONE; + } + ++#if !QSV_ONEVPL || HAVE_LIBVPL_LEGACY_MFXINIT ++ ++static int qsv_create_mfx_session_legacy(void *ctx, ++ mfxHDL handle, ++ mfxHandleType handle_type, ++ mfxIMPL implementation, ++ mfxVersion *pver, ++ mfxSession *psession, ++ void **ploader); ++ ++#endif ++ + #if QSV_ONEVPL + + static int qsv_d3d11_update_config(void *ctx, mfxHDL handle, mfxConfig cfg) +@@ -1218,6 +1230,16 @@ static int qsv_create_mfx_session(void * + return 0; + + fail: ++#if HAVE_LIBVPL_LEGACY_MFXINIT ++ av_log(ctx, AV_LOG_VERBOSE, "Error creating a MFX session using oneVPL, " ++ "falling back to retry with the legacy Media SDK path\n"); ++ if (!qsv_create_mfx_session_legacy(ctx, handle, handle_type, implementation, pver, psession, ploader)) { ++ if (!*ploader) ++ *ploader = loader; ++ return 0; ++ } ++#endif ++ + if (!*ploader && loader) + MFXUnload(loader); + +@@ -1234,6 +1256,21 @@ static int qsv_create_mfx_session(void * + mfxSession *psession, + void **ploader) + { ++ return qsv_create_mfx_session_legacy(ctx, handle, handle_type, implementation, pver, psession, ploader); ++} ++ ++#endif ++ ++#if !QSV_ONEVPL || HAVE_LIBVPL_LEGACY_MFXINIT ++ ++static int qsv_create_mfx_session_legacy(void *ctx, ++ mfxHDL handle, ++ mfxHandleType handle_type, ++ mfxIMPL implementation, ++ mfxVersion *pver, ++ mfxSession *psession, ++ void **ploader) ++{ + mfxVersion ver; + mfxStatus sts; + mfxSession session = NULL; diff --git a/debian/patches/series b/debian/patches/series index 1588cf7b51e..28c2cdfaebd 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -72,3 +72,4 @@ 0072-add-bwdif-videotoolbox-filter.patch 0073-add-12bit-decoding-on-videotoolbox.patch 0074-fix-the-sub2video-perf-regressions.patch +0075-allow-vpl-qsv-to-init-with-the-legacy-msdk-path.patch From 50f1db8d6fcd74626f2aa7aad5760be90432b333 Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Tue, 24 Sep 2024 20:06:26 +0800 Subject: [PATCH 2/2] Bump version to 7.0.2-3 Signed-off-by: nyanmisaka --- build.yaml | 2 +- debian/changelog | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/build.yaml b/build.yaml index f6c34bed486..fb119a69152 100644 --- a/build.yaml +++ b/build.yaml @@ -1,7 +1,7 @@ --- # We just wrap `build` so this is really it name: "jellyfin-ffmpeg" -version: "7.0.2-2" +version: "7.0.2-3" packages: - bullseye-amd64 - bullseye-armhf diff --git a/debian/changelog b/debian/changelog index f0641a35329..655dd1ea267 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +jellyfin-ffmpeg (7.0.2-3) unstable; urgency=medium + + * Allow VPL QSV to init with the legacy MSDK path + + -- nyanmisaka Tue, 24 Sep 2024 20:03:23 +0800 + jellyfin-ffmpeg (7.0.2-2) unstable; urgency=medium * Add bwdif_videotoolbox filter