Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.0] Update queued key fixes from upstream #230

Merged
merged 2 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

131 changes: 131 additions & 0 deletions debian/patches/0049-add-queued-key-fixes-from-upstream.patch
Original file line number Diff line number Diff line change
@@ -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, &params);
}

- 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;
25 changes: 0 additions & 25 deletions debian/patches/0049-fix-filter_at_id_syntax_from_upstream.patch

This file was deleted.

35 changes: 0 additions & 35 deletions debian/patches/0050-fix-nvenc-b-ref-mode-cap-check.patch

This file was deleted.

6 changes: 2 additions & 4 deletions debian/patches/series
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 9 additions & 10 deletions docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand All @@ -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} ..
Expand All @@ -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
Expand Down Expand Up @@ -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} ..
Expand All @@ -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 \
Expand Down Expand Up @@ -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"
Expand Down