87cbb9b70a
Adds 0016-h264-mb-inspect-callback.patch to the FFmpeg fork. Adds an
opt-in callback fired by ff_h264_hl_decode_mb after the existing
pixel work, for tools that need per-MB visibility into H.264 decode.
API:
typedef void (*ff_h264_mb_inspect_cb)(void *opaque,
const struct H264Context *h,
int mb_x, int mb_y);
void ff_h264_set_mb_inspect_cb(AVCodecContext *avctx,
ff_h264_mb_inspect_cb cb, void *opaque);
Two new fields appended to H264Context (internal struct, declared in
h264dec.h not h264.h, no ABI surface to non-libavcodec callers).
Callback fires post-pixel-work for every MB in coded order; receives
const H264Context* so it can inspect any state (slice ctx via
h->slice_ctx, reconstructed pixels via h->cur_pic.f->data[plane],
etc.).
Default (cb==NULL): zero behaviour change, one load + one branch per
MB in the decoder hot path.
Shape distinction: per-MB observation, NOT per-kernel function-pointer
hijack (the 0003-0014 substitution-arc pattern that PR #105 reverted
+ daedalus-fourier PR #37's measurement-correction architecturally
retired). Per-block synchronous Vulkan dispatch from libavcodec is
non-competitive; per-MB CPU-side observation feeding a per-frame
daedalus-decoder batch submit is the right shape (frame-major UMA
dispatch verdict, memory: dejavu).
Used by:
- daedalus-decoder/tools/daedalus_decode_h264 (PR-A1b, follow-up)
- future daedalus-v4l2 daemon refactor
Wired into arch PKGBUILD source[] + prepare() and debian build-deb.sh
patch sequence. pkgrel bumped 12 → 13.
Refs reauktion/daedalus-decoder!12.
277 lines
11 KiB
Bash
Executable File
277 lines
11 KiB
Bash
Executable File
#!/bin/bash
|
|
# Build ffmpeg-v4l2-request-fourier_<ver>_arm64.deb (the Kwiboo FFmpeg
|
|
# fork with the V4L2-Request API hwaccel patches).
|
|
#
|
|
# Mirror of arch/ffmpeg-v4l2-request-fourier into the Debian tree.
|
|
# Provides the patched `ffmpeg` + `ffprobe` binaries plus the shared
|
|
# libav* libraries with v4l2-request support, so consumers like
|
|
# mpv-fourier (and the kdirect bit-exact reference test rig) work
|
|
# end-to-end without a stock-Debian FFmpeg fallback.
|
|
#
|
|
# **Private prefix /opt/fourier** (Path A per fourier-debian
|
|
# architecture discussion 2026-05-19). Stock Debian trixie ships
|
|
# FFmpeg 7.1.x = libavcodec.so.61; this package ships FFmpeg 8.1 =
|
|
# libavcodec.so.62 — different SOVERSION, NOT a drop-in for trixie's
|
|
# KDE/VLC/etc. Living in /opt/fourier/lib keeps the stock system
|
|
# intact; only fourier-aware consumers (firefox-fourier, mpv-fourier,
|
|
# daedalus-v4l2) RPATH into /opt/fourier/lib. Postinst drops an
|
|
# ld.so.conf.d entry so dlopen-based consumers (firefox at runtime)
|
|
# find the libs by SONAME without LD_LIBRARY_PATH wrappers.
|
|
#
|
|
# Big build: 25-40 min on a runner. Output is a single .deb that
|
|
# bundles ffmpeg/ffprobe + libavcodec.so.62 + libavformat.so.62 etc.
|
|
# all together — no split per-library subpackages. Easier to consume,
|
|
# trades off finer-grained downgrades.
|
|
#
|
|
# Sibling Arch package: ../../arch/ffmpeg-v4l2-request-fourier/PKGBUILD
|
|
# Upstream: https://github.com/Kwiboo/FFmpeg (branch v4l2-request-n8.1)
|
|
set -euo pipefail
|
|
|
|
# Same pin as arch/ — v4l2-request-n8.1 tip 2026-04-24.
|
|
UPSTREAM_COMMIT=b57fbbe50c9b2656fad86a1a7eeabfd2b2a50935
|
|
FFMPEG_VERSION=8.1
|
|
# epoch 2 matches Debian's stock ffmpeg (currently 7:7.1.x in trixie);
|
|
# +rfourier suffix to avoid colliding with upstream/Debian rebuilds.
|
|
PKGVER=2:${FFMPEG_VERSION}+rfourier+gb57fbbe
|
|
PKGREL=13 # pkgrel=13 — per-MB inspection callback (0016) for daedalus-decoder CLI test harness; observation-only, no behaviour change to existing decode path
|
|
# (cycle 9 of the daedalus-v4l2#11 step 2 substitution arc; closes
|
|
# the libavcodec.so substitution sequence 6 IDCT4 / 7 IDCT8 /
|
|
# 8 luma-v deblock / 9 qpel mc20). Pulls daedalus-fourier PR #2
|
|
# which extends the public API with
|
|
# daedalus_recipe_dispatch_h264_qpel_mc20. (2026-05-23)
|
|
|
|
# daedalus-fourier pin. 209a421 = daedalus-fourier PR #2 merge — public
|
|
# API now exposes daedalus_recipe_dispatch_h264_qpel_mc20 +
|
|
# DAEDALUS_KERNEL_H264_QPEL_MC20. Cycle 9 plumbs the last H.264 NEON
|
|
# kernel through the recipe layer. Daemon-side build (debian/daedalus-v4l2)
|
|
# can bump in a follow-up; this PR only changes the libavcodec.so consumer.
|
|
DAEDALUS_FOURIER_COMMIT=b9f9ff2a89c068aea54dcb52b543afddad28311e # PR #25 — public chroma DC Hadamard
|
|
|
|
HERE=$(dirname "$(readlink -f "$0")")
|
|
|
|
# Reproducible build. 2026-05-18 23:00 UTC — Phase 8.13 close.
|
|
export SOURCE_DATE_EPOCH=1779231600
|
|
|
|
work=$(mktemp -d)
|
|
trap "rm -rf $work" EXIT
|
|
|
|
cd "$work"
|
|
git clone --depth 1 \
|
|
--branch v4l2-request-n8.1 \
|
|
https://github.com/Kwiboo/FFmpeg.git FFmpeg
|
|
cd FFmpeg
|
|
# git fetch the specific commit (depth=1 of branch tip might not be it)
|
|
if [ "$(git rev-parse HEAD)" != "$UPSTREAM_COMMIT" ]; then
|
|
git fetch origin "$UPSTREAM_COMMIT"
|
|
git checkout "$UPSTREAM_COMMIT"
|
|
fi
|
|
|
|
# Apply patches (same as Arch).
|
|
patch -Np1 -i "$HERE/0001-libudev-bypass-fallback.patch"
|
|
patch -Np1 -i "$HERE/0002-nv15-to-p010-unpack.patch"
|
|
patch -Np1 -i "$HERE/0003-h264-idct4-daedalus-fourier.patch"
|
|
patch -Np1 -i "$HERE/0004-h264-idct8-daedalus-fourier.patch"
|
|
patch -Np1 -i "$HERE/0005-h264-deblock-luma-v-daedalus-fourier.patch"
|
|
patch -Np1 -i "$HERE/0006-h264-restore-low-delay.patch"
|
|
patch -Np1 -i "$HERE/0007-h264-qpel-mc20-daedalus-fourier.patch"
|
|
patch -Np1 -i "$HERE/0008-h264-deblock-luma-h-daedalus-fourier.patch"
|
|
patch -Np1 -i "$HERE/0009-h264-deblock-chroma-daedalus-fourier.patch"
|
|
patch -Np1 -i "$HERE/0010-h264-deblock-luma-intra-daedalus-fourier.patch"
|
|
patch -Np1 -i "$HERE/0011-h264-chroma-dc-hadamard-daedalus-fourier.patch"
|
|
patch -Np1 -i "$HERE/0012-h264-qpel-rest-daedalus-fourier.patch"
|
|
patch -Np1 -i "$HERE/0013-h264-deblock-chroma-intra-daedalus-fourier.patch"
|
|
patch -Np1 -i "$HERE/0014-h264-ctx-qpu-capable.patch"
|
|
patch -Np1 -i "$HERE/0015-h264-ctx-revert-to-no-qpu.patch"
|
|
patch -Np1 -i "$HERE/0016-h264-mb-inspect-callback.patch"
|
|
|
|
# --- daedalus-fourier: fetch + build static .a with PIC, install to a
|
|
# per-build prefix; libavcodec.so links it into the shared object so
|
|
# H264DSPContext.idct_add (and follow-up kernels) dispatch through the
|
|
# daedalus recipe layer instead of the in-tree NEON .S code. ---
|
|
#
|
|
# PIC is mandatory — the static .a is linked into a .so, so all object
|
|
# code must be relocatable. Vulkan is PUBLIC-linked by daedalus_core
|
|
# (queryable QPU substrate); we add libvulkan1 to Debian Depends below
|
|
# so dlopen of libavcodec.so.62 succeeds on stock trixie.
|
|
FOURIER_PREFIX=$work/fourier-prefix
|
|
mkdir -p "$FOURIER_PREFIX"
|
|
|
|
pushd "$work" >/dev/null
|
|
curl --connect-timeout 10 --max-time 600 --retry 3 --retry-delay 5 -sSLfo daedalus-fourier.tar.gz \
|
|
"https://git.reauktion.de/marfrit/daedalus-fourier/archive/${DAEDALUS_FOURIER_COMMIT}.tar.gz"
|
|
tar xzf daedalus-fourier.tar.gz
|
|
pushd daedalus-fourier >/dev/null
|
|
cmake -B build -G Ninja \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
|
-DCMAKE_INSTALL_PREFIX="$FOURIER_PREFIX"
|
|
cmake --build build --target daedalus_core
|
|
cmake --install build
|
|
popd >/dev/null
|
|
popd >/dev/null
|
|
cd "$work/FFmpeg"
|
|
|
|
# Configure with Arch-parity flags. Drops the same set of features
|
|
# (X11, AMF, CUDA, FireWire, AviSynth, Bluray, OpenMPT, JPEG-XL,
|
|
# Theora, XVid, rsvg, soxr, ssh, vidstab, modplug, SDL2, Vulkan,
|
|
# JACK, GSM, Speex) — not needed on the Fourier fleet, keeps the .deb
|
|
# smaller and the dependency graph tighter.
|
|
./configure \
|
|
--prefix=/opt/fourier \
|
|
--bindir=/opt/fourier/bin \
|
|
--libdir=/opt/fourier/lib \
|
|
--shlibdir=/opt/fourier/lib \
|
|
--incdir=/opt/fourier/include \
|
|
--datadir=/opt/fourier/share/ffmpeg \
|
|
--mandir=/opt/fourier/share/man \
|
|
--extra-ldexeflags='-Wl,-rpath,/opt/fourier/lib' \
|
|
--extra-ldsoflags='-Wl,-rpath,/opt/fourier/lib' \
|
|
--extra-cflags="-I${FOURIER_PREFIX}/include" \
|
|
--extra-ldflags="-L${FOURIER_PREFIX}/lib" \
|
|
--extra-libs="-ldaedalus_core -lvulkan -lpthread" \
|
|
--disable-debug \
|
|
--disable-static \
|
|
--disable-doc \
|
|
--disable-stripping \
|
|
--enable-shared \
|
|
--enable-gpl \
|
|
--enable-version3 \
|
|
--enable-pic \
|
|
--enable-neon \
|
|
--arch=aarch64 \
|
|
--enable-libdrm \
|
|
--enable-libv4l2 \
|
|
--enable-libudev \
|
|
--enable-v4l2-request \
|
|
--enable-v4l2_m2m \
|
|
--enable-vaapi \
|
|
--enable-opengl \
|
|
--enable-gnutls \
|
|
--enable-fontconfig \
|
|
--enable-libass \
|
|
--enable-libfreetype \
|
|
--enable-libfribidi \
|
|
--enable-libpulse \
|
|
--enable-libdav1d \
|
|
--enable-libopus \
|
|
--enable-libvorbis \
|
|
--enable-libmp3lame \
|
|
--enable-libvpx \
|
|
--enable-libx264 \
|
|
--enable-libx265 \
|
|
--enable-libwebp \
|
|
--host-cflags='-fPIC'
|
|
|
|
make -j"$(nproc)"
|
|
make tools/qt-faststart
|
|
|
|
# Stage
|
|
ROOT="$work/pkgroot"
|
|
make DESTDIR="$ROOT" install
|
|
install -Dm755 tools/qt-faststart "$ROOT/opt/fourier/bin/qt-faststart"
|
|
|
|
# ld.so.conf.d entry so dlopen-based consumers (firefox-fourier at
|
|
# runtime) find /opt/fourier/lib/libavcodec.so.62 by SONAME without an
|
|
# LD_LIBRARY_PATH wrapper. No risk of contaminating stock binaries:
|
|
# stock KDE/VLC link against libavcodec.so.61 (different SONAME), so
|
|
# the loader never sees our .so.62 as a match for their .so.61.
|
|
install -Dm644 /dev/stdin "$ROOT/etc/ld.so.conf.d/fourier.conf" <<EOF
|
|
# fourier campaign: FFmpeg 8.1 fork + libVA fork in private prefix.
|
|
/opt/fourier/lib
|
|
EOF
|
|
|
|
# Optional /usr/bin shims so users can call ffmpeg-fourier without
|
|
# remembering the /opt path. No conflict with stock /usr/bin/ffmpeg.
|
|
install -d "$ROOT/usr/bin"
|
|
ln -sf /opt/fourier/bin/ffmpeg "$ROOT/usr/bin/ffmpeg-fourier"
|
|
ln -sf /opt/fourier/bin/ffprobe "$ROOT/usr/bin/ffprobe-fourier"
|
|
|
|
# Doc
|
|
mkdir -p "$ROOT/usr/share/doc/ffmpeg-v4l2-request-fourier" "$ROOT/DEBIAN"
|
|
install -Dm644 "$HERE/debian/copyright" \
|
|
"$ROOT/usr/share/doc/ffmpeg-v4l2-request-fourier/copyright"
|
|
install -Dm644 "$HERE/debian/changelog" \
|
|
"$ROOT/usr/share/doc/ffmpeg-v4l2-request-fourier/changelog.Debian"
|
|
gzip -9 -n "$ROOT/usr/share/doc/ffmpeg-v4l2-request-fourier/changelog.Debian"
|
|
|
|
cat > "$ROOT/DEBIAN/control" <<EOF
|
|
Package: ffmpeg-v4l2-request-fourier
|
|
Version: ${PKGVER}-${PKGREL}
|
|
Section: video
|
|
Priority: optional
|
|
Architecture: arm64
|
|
Depends: libc6,
|
|
libdrm2,
|
|
libvulkan1,
|
|
libfontconfig1,
|
|
libfreetype6,
|
|
libfribidi0,
|
|
libpulse0,
|
|
libdav1d7 | libdav1d6,
|
|
libopus0,
|
|
libvorbis0a,
|
|
libvorbisenc2,
|
|
libmp3lame0,
|
|
libvpx9 | libvpx8 | libvpx7,
|
|
libx264-164 | libx264-163,
|
|
libx265-215 | libx265-209 | libx265-199,
|
|
libwebp7 | libwebp6,
|
|
libwebpmux3,
|
|
libass9,
|
|
libgnutls30,
|
|
libudev1,
|
|
libv4l-0,
|
|
libva2,
|
|
libva-drm2
|
|
Maintainer: Markus Fritsche <mfritsche@reauktion.de>
|
|
Homepage: https://github.com/Kwiboo/FFmpeg
|
|
Description: FFmpeg with V4L2 Request API hwaccel (Kwiboo fork, /opt/fourier prefix)
|
|
FFmpeg ${FFMPEG_VERSION} patched with the V4L2 Request API stateless
|
|
video decoder hwaccel — Kwiboo's long-running rebase of Jernej
|
|
Škrabec's v4l2-request patchset onto FFmpeg release tags.
|
|
.
|
|
Provides 'ffmpeg -hwaccel v4l2request' / '-hwaccel drm' routes that
|
|
drive rkvdec / hantro / cedrus / rpi-hevc-dec / daedalus_v4l2
|
|
stateless decoders directly through libavcodec's hwdevice DRM path,
|
|
bypassing libva. Used by mpv-fourier and firefox-fourier as their
|
|
backing FFmpeg, and as the kdirect bit-exact reference in libva-v4l2-
|
|
request-fourier validation.
|
|
.
|
|
INSTALLED TO /opt/fourier (NOT /usr): this is FFmpeg 8.1 (libav*.so.62)
|
|
sitting alongside Debian trixie's stock FFmpeg 7.1 (libav*.so.61) —
|
|
different SONAMEs, no symbol clash. Consumer binaries RPATH into
|
|
/opt/fourier/lib; ld.so.conf.d/fourier.conf adds the path to ld.so
|
|
cache for dlopen-by-SONAME (firefox). /usr/bin/ffmpeg-fourier and
|
|
/usr/bin/ffprobe-fourier are convenience symlinks to /opt/fourier/bin.
|
|
Stock 'ffmpeg' command unaffected.
|
|
.
|
|
Drops X11/AMF/CUDA/Bluray/JACK/Vulkan/SDL2/Theora/XVid/Speex/JPEG-XL
|
|
per Fourier fleet policy (Wayland + ARM + video-decode focus).
|
|
No 'ffplay' binary; mpv-fourier covers interactive playback.
|
|
EOF
|
|
|
|
# ldconfig must be re-run after install so /opt/fourier/lib is in the cache.
|
|
cat > "$ROOT/DEBIAN/postinst" <<'PEOF'
|
|
#!/bin/sh
|
|
set -e
|
|
if [ "$1" = "configure" ]; then
|
|
ldconfig
|
|
fi
|
|
#DEBHELPER#
|
|
PEOF
|
|
chmod 755 "$ROOT/DEBIAN/postinst"
|
|
|
|
cat > "$ROOT/DEBIAN/postrm" <<'PEOF'
|
|
#!/bin/sh
|
|
set -e
|
|
if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
|
|
ldconfig
|
|
fi
|
|
#DEBHELPER#
|
|
PEOF
|
|
chmod 755 "$ROOT/DEBIAN/postrm"
|
|
|
|
DEB_OUT="ffmpeg-v4l2-request-fourier_${PKGVER//:/%3a}-${PKGREL}_arm64.deb"
|
|
dpkg-deb --root-owner-group --build "$ROOT" "$HERE/$DEB_OUT"
|
|
echo "built: $HERE/$DEB_OUT"
|