From dfa3839d4e6944099673245618fb27ac99008e4c Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Tue, 21 Mar 2023 23:43:43 +0800 Subject: [PATCH 1/2] Update queued key fixes from upstream Signed-off-by: nyanmisaka --- ...c-potential-null-pointer-dereference.patch | 27 ---- ...-empty-output-in-webvtt-transcoding.patch} | 0 ...9-add-queued-key-fixes-from-upstream.patch | 131 ++++++++++++++++++ ...ix-filter_at_id_syntax_from_upstream.patch | 25 ---- .../0050-fix-nvenc-b-ref-mode-cap-check.patch | 35 ----- debian/patches/series | 6 +- 6 files changed, 133 insertions(+), 91 deletions(-) delete mode 100644 debian/patches/0048-fix-nvenc-potential-null-pointer-dereference.patch rename debian/patches/{0051-fix-the-empty-output-in-webvtt-transcoding.patch => 0048-fix-the-empty-output-in-webvtt-transcoding.patch} (100%) create mode 100644 debian/patches/0049-add-queued-key-fixes-from-upstream.patch delete mode 100644 debian/patches/0049-fix-filter_at_id_syntax_from_upstream.patch delete mode 100644 debian/patches/0050-fix-nvenc-b-ref-mode-cap-check.patch diff --git a/debian/patches/0048-fix-nvenc-potential-null-pointer-dereference.patch b/debian/patches/0048-fix-nvenc-potential-null-pointer-dereference.patch deleted file mode 100644 index a1b8cc4171..0000000000 --- a/debian/patches/0048-fix-nvenc-potential-null-pointer-dereference.patch +++ /dev/null @@ -1,27 +0,0 @@ -Index: jellyfin-ffmpeg/libavcodec/nvenc.c -=================================================================== ---- jellyfin-ffmpeg.orig/libavcodec/nvenc.c -+++ jellyfin-ffmpeg/libavcodec/nvenc.c -@@ -178,6 +178,8 @@ static void reorder_queue_flush(AVFifo * - { - FrameData fd; - -+ av_assert0(queue); -+ - while (av_fifo_read(queue, &fd, 1) >= 0) - av_buffer_unref(&fd.frame_opaque_ref); - } -@@ -1853,8 +1855,11 @@ av_cold int ff_nvenc_encode_close(AVCode - p_nvenc->nvEncEncodePicture(ctx->nvencoder, ¶ms); - } - -- reorder_queue_flush(ctx->reorder_queue); -- av_fifo_freep2(&ctx->reorder_queue); -+ if (ctx->reorder_queue) { -+ reorder_queue_flush(ctx->reorder_queue); -+ av_fifo_freep2(&ctx->reorder_queue); -+ } -+ - av_fifo_freep2(&ctx->output_surface_ready_queue); - av_fifo_freep2(&ctx->output_surface_queue); - av_fifo_freep2(&ctx->unused_surface_queue); diff --git a/debian/patches/0051-fix-the-empty-output-in-webvtt-transcoding.patch b/debian/patches/0048-fix-the-empty-output-in-webvtt-transcoding.patch similarity index 100% rename from debian/patches/0051-fix-the-empty-output-in-webvtt-transcoding.patch rename to debian/patches/0048-fix-the-empty-output-in-webvtt-transcoding.patch diff --git a/debian/patches/0049-add-queued-key-fixes-from-upstream.patch b/debian/patches/0049-add-queued-key-fixes-from-upstream.patch new file mode 100644 index 0000000000..563d5b4735 --- /dev/null +++ b/debian/patches/0049-add-queued-key-fixes-from-upstream.patch @@ -0,0 +1,131 @@ +Index: jellyfin-ffmpeg/libavcodec/nvenc.c +=================================================================== +--- jellyfin-ffmpeg.orig/libavcodec/nvenc.c ++++ jellyfin-ffmpeg/libavcodec/nvenc.c +@@ -178,6 +178,8 @@ static void reorder_queue_flush(AVFifo * + { + FrameData fd; + ++ av_assert0(queue); ++ + while (av_fifo_read(queue, &fd, 1) >= 0) + av_buffer_unref(&fd.frame_opaque_ref); + } +@@ -1853,8 +1855,11 @@ av_cold int ff_nvenc_encode_close(AVCode + p_nvenc->nvEncEncodePicture(ctx->nvencoder, ¶ms); + } + +- reorder_queue_flush(ctx->reorder_queue); +- av_fifo_freep2(&ctx->reorder_queue); ++ if (ctx->reorder_queue) { ++ reorder_queue_flush(ctx->reorder_queue); ++ av_fifo_freep2(&ctx->reorder_queue); ++ } ++ + av_fifo_freep2(&ctx->output_surface_ready_queue); + av_fifo_freep2(&ctx->output_surface_queue); + av_fifo_freep2(&ctx->unused_surface_queue); +Index: jellyfin-ffmpeg/libavfilter/graphparser.c +=================================================================== +--- jellyfin-ffmpeg.orig/libavfilter/graphparser.c ++++ jellyfin-ffmpeg/libavfilter/graphparser.c +@@ -532,8 +532,7 @@ int avfilter_graph_segment_create_filter + for (size_t j = 0; j < ch->nb_filters; j++) { + AVFilterParams *p = ch->filters[j]; + const AVFilter *f = avfilter_get_by_name(p->filter_name); +- char inst_name[30], *name = p->instance_name ? p->instance_name : +- inst_name; ++ char name[64]; + + // skip already processed filters + if (p->filter || !p->filter_name) +@@ -546,7 +545,9 @@ int avfilter_graph_segment_create_filter + } + + if (!p->instance_name) +- snprintf(inst_name, sizeof(inst_name), "Parsed_%s_%zu", f->name, idx); ++ snprintf(name, sizeof(name), "Parsed_%s_%zu", f->name, idx); ++ else ++ snprintf(name, sizeof(name), "%s@%s", f->name, p->instance_name); + + p->filter = avfilter_graph_alloc_filter(seg->graph, f, name); + if (!p->filter) +Index: jellyfin-ffmpeg/libavcodec/nvenc.c +=================================================================== +--- jellyfin-ffmpeg.orig/libavcodec/nvenc.c ++++ jellyfin-ffmpeg/libavcodec/nvenc.c +@@ -461,7 +461,7 @@ static int nvenc_check_cap(AVCodecContex + static int nvenc_check_capabilities(AVCodecContext *avctx) + { + NvencContext *ctx = avctx->priv_data; +- int ret; ++ int tmp, ret; + + ret = nvenc_check_codec_support(avctx); + if (ret < 0) { +@@ -542,16 +542,18 @@ static int nvenc_check_capabilities(AVCo + } + + #ifdef NVENC_HAVE_BFRAME_REF_MODE ++ tmp = (ctx->b_ref_mode >= 0) ? ctx->b_ref_mode : NV_ENC_BFRAME_REF_MODE_DISABLED; + ret = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_BFRAME_REF_MODE); +- if (ctx->b_ref_mode == NV_ENC_BFRAME_REF_MODE_EACH && ret != 1 && ret != 3) { ++ if (tmp == NV_ENC_BFRAME_REF_MODE_EACH && ret != 1 && ret != 3) { + av_log(avctx, AV_LOG_WARNING, "Each B frame as reference is not supported\n"); + return AVERROR(ENOSYS); +- } else if (ctx->b_ref_mode != NV_ENC_BFRAME_REF_MODE_DISABLED && ret == 0) { ++ } else if (tmp != NV_ENC_BFRAME_REF_MODE_DISABLED && ret == 0) { + av_log(avctx, AV_LOG_WARNING, "B frames as references are not supported\n"); + return AVERROR(ENOSYS); + } + #else +- if (ctx->b_ref_mode != 0) { ++ tmp = (ctx->b_ref_mode >= 0) ? ctx->b_ref_mode : 0; ++ if (tmp > 0) { + av_log(avctx, AV_LOG_WARNING, "B frames as references need SDK 8.1 at build time\n"); + return AVERROR(ENOSYS); + } +Index: jellyfin-ffmpeg/libavcodec/decode.c +=================================================================== +--- jellyfin-ffmpeg.orig/libavcodec/decode.c ++++ jellyfin-ffmpeg/libavcodec/decode.c +@@ -140,7 +140,7 @@ static int extract_packet_props(AVCodecI + if (pkt) { + ret = av_packet_copy_props(avci->last_pkt_props, pkt); + if (!ret) +- avci->last_pkt_props->opaque = (void *)(intptr_t)pkt->size; // Needed for ff_decode_frame_props(). ++ avci->last_pkt_props->stream_index = pkt->size; // Needed for ff_decode_frame_props(). + } + return ret; + } +@@ -461,7 +461,7 @@ FF_ENABLE_DEPRECATION_WARNINGS + pkt->dts = AV_NOPTS_VALUE; + if (!(codec->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) { + // See extract_packet_props() comment. +- avci->last_pkt_props->opaque = (void *)((intptr_t)avci->last_pkt_props->opaque - consumed); ++ avci->last_pkt_props->stream_index = avci->last_pkt_props->stream_index - consumed; + avci->last_pkt_props->pts = AV_NOPTS_VALUE; + avci->last_pkt_props->dts = AV_NOPTS_VALUE; + } +@@ -1355,7 +1355,7 @@ int ff_decode_frame_props(AVCodecContext + int ret = ff_decode_frame_props_from_pkt(avctx, frame, pkt); + if (ret < 0) + return ret; +- frame->pkt_size = (int)(intptr_t)pkt->opaque; ++ frame->pkt_size = pkt->stream_index; + } + #if FF_API_REORDERED_OPAQUE + FF_DISABLE_DEPRECATION_WARNINGS +Index: jellyfin-ffmpeg/fftools/ffmpeg_mux_init.c +=================================================================== +--- jellyfin-ffmpeg.orig/fftools/ffmpeg_mux_init.c ++++ jellyfin-ffmpeg/fftools/ffmpeg_mux_init.c +@@ -2063,7 +2063,7 @@ static void parse_forced_key_frames(Keyf + if (next) + *next++ = 0; + +- if (!memcmp(p, "chapters", 8)) { ++ if (strstr(p, "chapters") == p) { + AVChapter * const *ch = mux->fc->chapters; + unsigned int nb_ch = mux->fc->nb_chapters; + int j; diff --git a/debian/patches/0049-fix-filter_at_id_syntax_from_upstream.patch b/debian/patches/0049-fix-filter_at_id_syntax_from_upstream.patch deleted file mode 100644 index d2c299499e..0000000000 --- a/debian/patches/0049-fix-filter_at_id_syntax_from_upstream.patch +++ /dev/null @@ -1,25 +0,0 @@ -Index: jellyfin-ffmpeg/libavfilter/graphparser.c -=================================================================== ---- jellyfin-ffmpeg.orig/libavfilter/graphparser.c -+++ jellyfin-ffmpeg/libavfilter/graphparser.c -@@ -532,8 +532,7 @@ int avfilter_graph_segment_create_filter - for (size_t j = 0; j < ch->nb_filters; j++) { - AVFilterParams *p = ch->filters[j]; - const AVFilter *f = avfilter_get_by_name(p->filter_name); -- char inst_name[30], *name = p->instance_name ? p->instance_name : -- inst_name; -+ char name[64]; - - // skip already processed filters - if (p->filter || !p->filter_name) -@@ -546,7 +545,9 @@ int avfilter_graph_segment_create_filter - } - - if (!p->instance_name) -- snprintf(inst_name, sizeof(inst_name), "Parsed_%s_%zu", f->name, idx); -+ snprintf(name, sizeof(name), "Parsed_%s_%zu", f->name, idx); -+ else -+ snprintf(name, sizeof(name), "%s@%s", f->name, p->instance_name); - - p->filter = avfilter_graph_alloc_filter(seg->graph, f, name); - if (!p->filter) diff --git a/debian/patches/0050-fix-nvenc-b-ref-mode-cap-check.patch b/debian/patches/0050-fix-nvenc-b-ref-mode-cap-check.patch deleted file mode 100644 index f6e837aff6..0000000000 --- a/debian/patches/0050-fix-nvenc-b-ref-mode-cap-check.patch +++ /dev/null @@ -1,35 +0,0 @@ -Index: jellyfin-ffmpeg/libavcodec/nvenc.c -=================================================================== ---- jellyfin-ffmpeg.orig/libavcodec/nvenc.c -+++ jellyfin-ffmpeg/libavcodec/nvenc.c -@@ -461,7 +461,7 @@ static int nvenc_check_cap(AVCodecContex - static int nvenc_check_capabilities(AVCodecContext *avctx) - { - NvencContext *ctx = avctx->priv_data; -- int ret; -+ int tmp, ret; - - ret = nvenc_check_codec_support(avctx); - if (ret < 0) { -@@ -542,16 +542,18 @@ static int nvenc_check_capabilities(AVCo - } - - #ifdef NVENC_HAVE_BFRAME_REF_MODE -+ tmp = (ctx->b_ref_mode >= 0) ? ctx->b_ref_mode : NV_ENC_BFRAME_REF_MODE_DISABLED; - ret = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_BFRAME_REF_MODE); -- if (ctx->b_ref_mode == NV_ENC_BFRAME_REF_MODE_EACH && ret != 1 && ret != 3) { -+ if (tmp == NV_ENC_BFRAME_REF_MODE_EACH && ret != 1 && ret != 3) { - av_log(avctx, AV_LOG_WARNING, "Each B frame as reference is not supported\n"); - return AVERROR(ENOSYS); -- } else if (ctx->b_ref_mode != NV_ENC_BFRAME_REF_MODE_DISABLED && ret == 0) { -+ } else if (tmp != NV_ENC_BFRAME_REF_MODE_DISABLED && ret == 0) { - av_log(avctx, AV_LOG_WARNING, "B frames as references are not supported\n"); - return AVERROR(ENOSYS); - } - #else -- if (ctx->b_ref_mode != 0) { -+ tmp = (ctx->b_ref_mode >= 0) ? ctx->b_ref_mode : 0; -+ if (tmp > 0) { - av_log(avctx, AV_LOG_WARNING, "B frames as references need SDK 8.1 at build time\n"); - return AVERROR(ENOSYS); - } diff --git a/debian/patches/series b/debian/patches/series index 68a663b5fc..00b6cdc5fd 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -45,7 +45,5 @@ 0045-add-fixes-for-the-incorrect-null-terminator-in-assenc.patch 0046-skip-loading-plugins-on-vpl-runtime.patch 0047-update-the-default-params-of-qsv-encoders.patch -0048-fix-nvenc-potential-null-pointer-dereference.patch -0049-fix-filter_at_id_syntax_from_upstream.patch -0050-fix-nvenc-b-ref-mode-cap-check.patch -0051-fix-the-empty-output-in-webvtt-transcoding.patch +0048-fix-the-empty-output-in-webvtt-transcoding.patch +0049-add-queued-key-fixes-from-upstream.patch From d3a7d5ccb11310d69ea9c9708298834ed271ef90 Mon Sep 17 00:00:00 2001 From: nyanmisaka Date: Tue, 21 Mar 2023 23:43:56 +0800 Subject: [PATCH 2/2] Update dependencies Signed-off-by: nyanmisaka --- docker-build.sh | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/docker-build.sh b/docker-build.sh index 6c11a52af5..84c7d89e50 100755 --- a/docker-build.sh +++ b/docker-build.sh @@ -196,7 +196,7 @@ prepare_extra_amd64() { # LIBVA pushd ${SOURCE_DIR} - git clone -b 2.17.0 --depth=1 https://github.com/intel/libva.git + git clone -b 2.18.0 --depth=1 https://github.com/intel/libva.git pushd libva sed -i 's|getenv("LIBVA_DRIVERS_PATH")|"/usr/lib/jellyfin-ffmpeg/lib/dri:/usr/lib/x86_64-linux-gnu/dri:/usr/lib/dri:/usr/local/lib/dri"|g' va/va.c sed -i 's|getenv("LIBVA_DRIVER_NAME")|getenv("LIBVA_DRIVER_NAME_JELLYFIN")|g' va/va.c @@ -213,7 +213,7 @@ prepare_extra_amd64() { # LIBVA-UTILS pushd ${SOURCE_DIR} - git clone -b 2.17.1 --depth=1 https://github.com/intel/libva-utils.git + git clone -b 2.18.0 --depth=1 https://github.com/intel/libva-utils.git pushd libva-utils ./autogen.sh ./configure --prefix=${TARGET_DIR} @@ -237,7 +237,7 @@ prepare_extra_amd64() { # GMMLIB pushd ${SOURCE_DIR} - git clone -b intel-gmmlib-22.3.4 --depth=1 https://github.com/intel/gmmlib.git + git clone -b intel-gmmlib-22.3.5 --depth=1 https://github.com/intel/gmmlib.git pushd gmmlib mkdir build && pushd build cmake -DCMAKE_INSTALL_PREFIX=${TARGET_DIR} .. @@ -251,7 +251,7 @@ prepare_extra_amd64() { # Provides MSDK runtime (libmfxhw64.so.1) for 11th Gen Rocket Lake and older # Provides MFX dispatcher (libmfx.so.1) for FFmpeg pushd ${SOURCE_DIR} - git clone -b intel-mediasdk-23.1.3 --depth=1 https://github.com/Intel-Media-SDK/MediaSDK.git + git clone -b intel-mediasdk-23.1.4 --depth=1 https://github.com/Intel-Media-SDK/MediaSDK.git pushd MediaSDK sed -i 's|MFX_PLUGINS_CONF_DIR "/plugins.cfg"|"/usr/lib/jellyfin-ffmpeg/lib/mfx/plugins.cfg"|g' api/mfx_dispatch/linux/mfxloader.cpp mkdir build && pushd build @@ -292,7 +292,7 @@ prepare_extra_amd64() { # Provides VPL runtime (libmfx-gen.so.1.2) for 11th Gen Tiger Lake and newer # Both MSDK and VPL runtime can be loaded by MFX dispatcher (libmfx.so.1) pushd ${SOURCE_DIR} - git clone -b intel-onevpl-23.1.3 --depth=1 https://github.com/oneapi-src/oneVPL-intel-gpu.git + git clone -b intel-onevpl-23.1.4 --depth=1 https://github.com/oneapi-src/oneVPL-intel-gpu.git pushd oneVPL-intel-gpu mkdir build && pushd build cmake -DCMAKE_INSTALL_PREFIX=${TARGET_DIR} .. @@ -306,10 +306,12 @@ prepare_extra_amd64() { # Full Feature Build: ENABLE_KERNELS=ON(Default) ENABLE_NONFREE_KERNELS=ON(Default) # Free Kernel Build: ENABLE_KERNELS=ON ENABLE_NONFREE_KERNELS=OFF pushd ${SOURCE_DIR} - git clone -b intel-media-23.1.3 --depth=1 https://github.com/intel/media-driver.git + git clone -b intel-media-23.1.4 --depth=1 https://github.com/intel/media-driver.git pushd media-driver # Possible fix for TGLx timeout caused by 'HCP Scalability Decode' under heavy load wget -q -O - https://github.com/intel/media-driver/commit/284750bf.patch | git apply + # Fix for the HEVC encoder ICQ rate control capability on DG2 + wget -q -O - https://github.com/intel/media-driver/commit/580f8738.patch | git apply mkdir build && pushd build cmake -DCMAKE_INSTALL_PREFIX=${TARGET_DIR} \ -DENABLE_KERNELS=ON \ @@ -390,10 +392,7 @@ prepare_extra_amd64() { pushd ${SOURCE_DIR} git clone -b main https://gitlab.freedesktop.org/mesa/mesa.git pushd mesa - git reset --hard "10622ccc" - # fix building with python 3.8 - wget -q -O - https://gitlab.freedesktop.org/mesa/mesa/-/commit/044db56a.patch | git apply - wget -q -O - https://gitlab.freedesktop.org/mesa/mesa/-/commit/40f89860.patch | git apply + git reset --hard "f39ffc69" popd # disable the broken hevc packed header MESA_VA_PIC="mesa/src/gallium/frontends/va/picture.c"