Skip to content

Commit

Permalink
Merge pull request #336 from nyanmisaka/next
Browse files Browse the repository at this point in the history
Bump version to 6.0.1-3
  • Loading branch information
nyanmisaka authored Feb 12, 2024
2 parents 17311c1 + 47769df commit 615cf03
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 42 deletions.
2 changes: 1 addition & 1 deletion build.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# We just wrap `build` so this is really it
name: "jellyfin-ffmpeg"
version: "6.0.1-2"
version: "6.0.1-3"
packages:
- buster-amd64
- buster-armhf
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
From a5e701025dce2036930b9e049862e5355b07a45f Mon Sep 17 00:00:00 2001
From: David Rosca <nowrep@gmail.com>
Date: Tue, 9 Jan 2024 13:38:08 +0100
Subject: [PATCH] utils/libav: Only adjust bit_shift for DRM P010 frames

Fixes mapping Vulkan P010 frames.

Closes #237
---
src/include/libplacebo/utils/libav_internal.h | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/include/libplacebo/utils/libav_internal.h b/src/include/libplacebo/utils/libav_internal.h
index 4c269e5d..992e5ca6 100644
--- a/src/include/libplacebo/utils/libav_internal.h
+++ b/src/include/libplacebo/utils/libav_internal.h
@@ -967,11 +967,6 @@ static void pl_fix_hwframe_sample_depth(struct pl_frame *out, const AVFrame *fra
struct pl_bit_encoding *bits = &out->repr.bits;

bits->sample_depth = fmt->component_depth[0];
-
- switch (hwfc->sw_format) {
- case AV_PIX_FMT_P010: bits->bit_shift = 6; break;
- default: break;
- }
}

static bool pl_map_avframe_drm(pl_gpu gpu, struct pl_frame *out,
@@ -1016,6 +1011,12 @@ static bool pl_map_avframe_drm(pl_gpu gpu, struct pl_frame *out,
}

pl_fix_hwframe_sample_depth(out, frame);
+
+ switch (hwfc->sw_format) {
+ case AV_PIX_FMT_P010: out->repr.bits.bit_shift = 6; break;
+ default: break;
+ }
+
return true;
}

2 changes: 1 addition & 1 deletion builder/scripts.d/50-ffnvcodec.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

SCRIPT_REPO="https://github.com/FFmpeg/nv-codec-headers.git"
SCRIPT_COMMIT="c5e4af74850a616c42d39ed45b9b8568b71bf8bf"
SCRIPT_COMMIT="451da99614412a7f9526ef301a5ee0c7a6f9ad76"

ffbuild_enabled() {
[[ $TARGET == *arm64 ]] && return -1
Expand Down
13 changes: 12 additions & 1 deletion builder/scripts.d/50-vulkan/60-libplacebo.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
#!/bin/bash

SCRIPT_REPO="https://code.videolan.org/videolan/libplacebo.git"
SCRIPT_COMMIT="ed29e541a55acf28022738440b2a925386292551"
SCRIPT_COMMIT="64c1954570f1cd57f8570a57e51fb0249b57bb90"

ffbuild_enabled() {
return 0
}

ffbuild_dockerstage() {
to_df "RUN --mount=src=${SELF},dst=/stage.sh --mount=src=patches/libplacebo,dst=/patches run_stage /stage.sh"
}

ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" placebo
cd placebo
git submodule update --init --recursive

for patch in /patches/*.patch; do
echo "Applying $patch"
patch -p1 < "$patch"
done

sed -i 's/DPL_EXPORT/DPL_STATIC/' src/meson.build

mkdir build && cd build

local myconf=(
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
jellyfin-ffmpeg (6.0.1-3) unstable; urgency=medium

* Fix libplacebo v6 required hostQueryReset capability
* Sync RKMPP fixes from ffmpeg-rockchip
* Update build scripts and dependencies

jellyfin-ffmpeg (6.0.1-2) unstable; urgency=medium

* Add full HWA pipeline for Rockchip RK3588 platform
Expand Down
12 changes: 12 additions & 0 deletions debian/patches/0055-fix-libplacebo-filter-build-with-v6-api.patch
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,15 @@ Index: jellyfin-ffmpeg/libavfilter/vf_libplacebo.c
{ "force_dither", "Force dithering", OFFSET(force_dither), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
{ "disable_fbos", "Force-disable FBOs", OFFSET(disable_fbos), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC },
{ NULL },
Index: jellyfin-ffmpeg/libavutil/hwcontext_vulkan.c
===================================================================
--- jellyfin-ffmpeg.orig/libavutil/hwcontext_vulkan.c
+++ jellyfin-ffmpeg/libavutil/hwcontext_vulkan.c
@@ -1394,6 +1394,7 @@ static int vulkan_device_create_internal
goto end;
}
p->device_features_1_2.timelineSemaphore = 1;
+ p->device_features_1_2.hostQueryReset = dev_features_1_2.hostQueryReset;

/* Setup queue family */
if ((err = setup_queue_families(ctx, &dev_info)))
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ Index: jellyfin-ffmpeg/libavcodec/rkmppdec.c
*
* This file is part of FFmpeg.
*
@@ -19,569 +20,931 @@
@@ -19,569 +20,933 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

Expand Down Expand Up @@ -924,11 +924,11 @@ Index: jellyfin-ffmpeg/libavcodec/rkmppdec.c
+ light = av_content_light_metadata_create_side_data(frame);
+ if (!light)
+ return AVERROR(ENOMEM);
+
+ light->MaxCLL = mpp_light.MaxCLL;
+ light->MaxFALL = mpp_light.MaxFALL;

- av_free(desc);
+ light->MaxCLL = mpp_light.MaxCLL;
+ light->MaxFALL = mpp_light.MaxFALL;
+
+ return 0;
}

Expand Down Expand Up @@ -1239,17 +1239,11 @@ Index: jellyfin-ffmpeg/libavcodec/rkmppdec.c
- } else {
- av_log(avctx, AV_LOG_ERROR, "Failed to retrieve the frame buffer, frame is dropped (code = %d)\n", ret);
- mpp_frame_deinit(&mppframe);
- }
- } else if (decoder->eos_reached) {
- return AVERROR_EOF;
- } else if (ret == MPP_ERR_TIMEOUT) {
- av_log(avctx, AV_LOG_DEBUG, "Timeout when trying to get a frame from MPP\n");
+ if ((ret = r->mapi->control(r->mctx, MPP_SET_OUTPUT_TIMEOUT, (MppParam)&timeout)) != MPP_OK) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to set output timeout: %d\n", ret);
+ return AVERROR_EXTERNAL;
}

- return AVERROR(EAGAIN);
+ }
+
+ ret = r->mapi->decode_get_frame(r->mctx, &mpp_frame);
+ if (ret != MPP_OK && ret != MPP_ERR_TIMEOUT) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to get frame: %d\n", ret);
Expand All @@ -1261,10 +1255,17 @@ Index: jellyfin-ffmpeg/libavcodec/rkmppdec.c
+ }
+ if (mpp_frame_get_eos(mpp_frame)) {
+ av_log(avctx, AV_LOG_DEBUG, "Received a 'EOS' frame\n");
+ r->eof = 1;
+ ret = AVERROR_EOF;
+ goto exit;
+ }
+ /* EOS frame may contain valid data */
+ if (!mpp_frame_get_buffer(mpp_frame)) {
+ r->eof = 1;
+ ret = AVERROR_EOF;
+ goto exit;
}
- } else if (decoder->eos_reached) {
- return AVERROR_EOF;
- } else if (ret == MPP_ERR_TIMEOUT) {
- av_log(avctx, AV_LOG_DEBUG, "Timeout when trying to get a frame from MPP\n");
}
+ if (mpp_frame_get_discard(mpp_frame)) {
+ av_log(avctx, AV_LOG_DEBUG, "Received a 'discard' frame\n");
+ ret = AVERROR(EAGAIN);
Expand Down Expand Up @@ -1299,9 +1300,7 @@ Index: jellyfin-ffmpeg/libavcodec/rkmppdec.c
+ avctx->pix_fmt = ret;
+ }

-fail:
- if (mppframe)
- mpp_frame_deinit(&mppframe);
- return AVERROR(EAGAIN);
+ avctx->width = mpp_frame_get_width(mpp_frame);
+ avctx->height = mpp_frame_get_height(mpp_frame);
+ avctx->coded_width = FFALIGN(avctx->width, 64);
Expand All @@ -1328,8 +1327,9 @@ Index: jellyfin-ffmpeg/libavcodec/rkmppdec.c
+ goto exit;
+ }

- if (framecontext)
- av_buffer_unref(&framecontext->decoder_ref);
-fail:
- if (mppframe)
- mpp_frame_deinit(&mppframe);
+ if ((ret = r->mapi->control(r->mctx, MPP_DEC_SET_INFO_CHANGE_READY, NULL)) != MPP_OK) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to set info change ready: %d\n", ret);
+ ret = AVERROR_EXTERNAL;
Expand Down Expand Up @@ -1389,29 +1389,31 @@ Index: jellyfin-ffmpeg/libavcodec/rkmppdec.c
+ }
+ }

- if (framecontextref)
- av_buffer_unref(&framecontextref);
- if (framecontext)
- av_buffer_unref(&framecontext->decoder_ref);
+exit:
+ if (mpp_frame)
+ mpp_frame_deinit(&mpp_frame);
+ return ret;
+}

- if (desc)
- av_free(desc);
- if (framecontextref)
- av_buffer_unref(&framecontextref);
+static int rkmpp_send_eos(AVCodecContext *avctx)
+{
+ RKMPPDecContext *r = avctx->priv_data;
+ MppPacket mpp_pkt = NULL;
+ int ret;

- return ret;
- if (desc)
- av_free(desc);
+ if ((ret = mpp_packet_init(&mpp_pkt, NULL, 0)) != MPP_OK) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to init 'EOS' packet: %d\n", ret);
+ return AVERROR_EXTERNAL;
+ }
+ mpp_packet_set_eos(mpp_pkt);
+

- return ret;
+ do {
+ ret = r->mapi->decode_put_packet(r->mctx, mpp_pkt);
+ } while (ret != MPP_OK);
Expand Down Expand Up @@ -1567,7 +1569,6 @@ Index: jellyfin-ffmpeg/libavcodec/rkmppdec.c
- if (ret == MPP_OK) {
- decoder->first_packet = 1;
+ av_packet_unref(&r->last_pkt);
+ av_frame_unref(&r->last_frame);
} else
- av_log(avctx, AV_LOG_ERROR, "Failed to reset MPI (code = %d)\n", ret);
+ av_log(avctx, AV_LOG_ERROR, "Failed to reset MPP context: %d\n", ret);
Expand Down Expand Up @@ -1641,7 +1642,7 @@ Index: jellyfin-ffmpeg/libavcodec/rkmppdec.h
===================================================================
--- /dev/null
+++ jellyfin-ffmpeg/libavcodec/rkmppdec.h
@@ -0,0 +1,157 @@
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2017 Lionel CHAZALLON
+ * Copyright (c) 2023 Huseyin BIYIK
Expand Down Expand Up @@ -1698,8 +1699,6 @@ Index: jellyfin-ffmpeg/libavcodec/rkmppdec.h
+ AVBufferRef *hwframe;
+
+ AVPacket last_pkt;
+ AVFrame last_frame;
+
+ int eof;
+ int info_change;
+ int errinfo_cnt;
Expand Down Expand Up @@ -5543,15 +5542,15 @@ Index: jellyfin-ffmpeg/libavutil/hwcontext_opencl.c
{
OpenCLDeviceSelector selector = {
.platform_index = -1,
@@ -3193,6 +3208,7 @@ static int opencl_map_from_drm_arm(AVHWF
@@ -3198,6 +3213,7 @@ static int opencl_map_from_drm_arm(AVHWF
AVHWFramesContext *src_fc =
(AVHWFramesContext*)src->hw_frames_ctx->data;
AVOpenCLDeviceContext *dst_dev = dst_fc->device_ctx->hwctx;
+ OpenCLDeviceContext *device_priv = dst_fc->device_ctx->internal->priv;
const AVDRMFrameDescriptor *desc;
DRMARMtoOpenCLMapping *mapping = NULL;
cl_mem_flags cl_flags;
@@ -3226,8 +3242,8 @@ static int opencl_map_from_drm_arm(AVHWF
@@ -3231,8 +3247,8 @@ static int opencl_map_from_drm_arm(AVHWF
}

mapping->object_buffers[i] =
Expand All @@ -5562,7 +5561,7 @@ Index: jellyfin-ffmpeg/libavutil/hwcontext_opencl.c
if (!mapping->object_buffers[i]) {
av_log(dst_fc, AV_LOG_ERROR, "Failed to create CL buffer "
"from object %d (fd %d, size %"SIZE_SPECIFIER") of DRM frame: %d.\n",
@@ -3258,6 +3274,8 @@ static int opencl_map_from_drm_arm(AVHWF
@@ -3263,6 +3279,8 @@ static int opencl_map_from_drm_arm(AVHWF
goto fail;
}

Expand Down
2 changes: 1 addition & 1 deletion docker-build-win64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ EOF
popd

# FFNVCODEC
git clone -b n12.0.16.0 --depth=1 https://github.com/FFmpeg/nv-codec-headers.git
git clone -b n12.0.16.1 --depth=1 https://github.com/FFmpeg/nv-codec-headers.git
pushd nv-codec-headers
make PREFIX=${FF_DEPS_PREFIX} install
popd
Expand Down
18 changes: 14 additions & 4 deletions docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ prepare_extra_common() {
prepare_extra_amd64() {
# FFNVCODEC
pushd ${SOURCE_DIR}
git clone -b n12.0.16.0 --depth=1 https://github.com/FFmpeg/nv-codec-headers.git
git clone -b n12.0.16.1 --depth=1 https://github.com/FFmpeg/nv-codec-headers.git
pushd nv-codec-headers
make && make install
popd
Expand Down Expand Up @@ -300,7 +300,7 @@ prepare_extra_amd64() {
# ONEVPL-INTEL-GPU (RT only)
# Provides VPL runtime (libmfx-gen.so.1.2) for 11th Gen Tiger Lake and newer
pushd ${SOURCE_DIR}
git clone -b intel-onevpl-24.1.1 --depth=1 https://github.com/oneapi-src/oneVPL-intel-gpu.git
git clone -b intel-onevpl-24.1.3 --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 @@ -320,7 +320,7 @@ 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-24.1.1 --depth=1 https://github.com/intel/media-driver.git
git clone -b intel-media-24.1.3 --depth=1 https://github.com/intel/media-driver.git
pushd media-driver
mkdir build && pushd build
cmake -DCMAKE_INSTALL_PREFIX=${TARGET_DIR} \
Expand Down Expand Up @@ -450,8 +450,18 @@ prepare_extra_amd64() {
fi

# LIBPLACEBO
pl_ver="v6.338.2"
if [[ $( lsb_release -c -s ) == "buster" ]]; then
pl_ver="v5.264.1"
fi
pushd ${SOURCE_DIR}
git clone -b v5.264.1 --recursive --depth=1 https://github.com/haasn/libplacebo.git
git clone -b ${pl_ver} --recursive --depth=1 https://github.com/haasn/libplacebo.git
if [[ $( lsb_release -c -s ) != "buster" ]]; then
pushd libplacebo
# fix p010 green screen in v6.338.2
wget -q -O - https://github.com/haasn/libplacebo/commit/a5e7010.patch | git apply
popd
fi
sed -i 's|env: python_env,||g' libplacebo/src/vulkan/meson.build
meson setup libplacebo placebo_build \
--prefix=${TARGET_DIR} \
Expand Down

0 comments on commit 615cf03

Please sign in to comment.