forked from marfrit/marfrit-packages
Compare commits
5 Commits
87cbb9b70a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b0cb71370 | |||
| 25610930ad | |||
| 368fcff41f | |||
| ea99dc8e27 | |||
| 59901bceca |
@@ -35,13 +35,20 @@ to fall through.
|
||||
|
||||
Used by:
|
||||
- daedalus-decoder/tools/daedalus_decode_h264 (PR-A1b)
|
||||
- future daedalus-v4l2 daemon refactor
|
||||
- daedalus-v4l2 daemon shadow-mode path (PR-Q3a.1+)
|
||||
|
||||
The CLI static-links libavcodec.a so symbol visibility doesn't matter
|
||||
there. The daemon dlopens libavcodec.so.62 and resolves the callback
|
||||
via dlsym, so the symbol MUST be exported — added to libavcodec.v
|
||||
explicitly (FFmpeg's default version script hides every `ff_*` symbol
|
||||
as LOCAL behind a glob).
|
||||
|
||||
Refs reauktion/daedalus-decoder!12 (Stage 2 PR-b complete).
|
||||
---
|
||||
libavcodec/h264_mb.c | 20 ++++++++++++++++++++
|
||||
libavcodec/h264dec.h | 26 ++++++++++++++++++++++++++
|
||||
2 files changed, 46 insertions(+)
|
||||
libavcodec/h264_mb.c | 20 ++++++++++++++++++++
|
||||
libavcodec/h264dec.h | 26 ++++++++++++++++++++++++++
|
||||
libavcodec/libavcodec.v | 1 +
|
||||
3 files changed, 47 insertions(+)
|
||||
|
||||
--- a/libavcodec/h264dec.h
|
||||
+++ b/libavcodec/h264dec.h
|
||||
@@ -113,3 +120,13 @@ Refs reauktion/daedalus-decoder!12 (Stage 2 PR-b complete).
|
||||
+ h->mb_inspect_cb = cb;
|
||||
+ h->mb_inspect_opaque = opaque;
|
||||
}
|
||||
--- a/libavcodec/libavcodec.v
|
||||
+++ b/libavcodec/libavcodec.v
|
||||
@@ -3,6 +3,7 @@
|
||||
av_*;
|
||||
avcodec_*;
|
||||
avpriv_*;
|
||||
+ ff_h264_set_mb_inspect_cb;
|
||||
avsubtitle_free;
|
||||
local:
|
||||
*;
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Markus Fritsche <mfritsche@reauktion.de>
|
||||
Date: Tue, 26 May 2026 07:30:00 +0200
|
||||
Subject: [PATCH] avcodec/h264: preserve sl->mb coefficients for the inspection
|
||||
callback (companion to 0016)
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Patch 0016 adds a per-MB inspection callback fired at the end of
|
||||
ff_h264_hl_decode_mb. By that time the IDCT-add path has already
|
||||
zeroed sl->mb (FFmpeg's convention — see ff_h264_idct_add_neon and
|
||||
friends), so consumers reading coefficients from the callback get
|
||||
zeros.
|
||||
|
||||
Add a coefficient side buffer in H264Context, populated at the
|
||||
START of ff_h264_hl_decode_mb (before any IDCT runs) with a single
|
||||
memcpy from sl->mb. The post-pixel-work callback (still in 0016)
|
||||
can then read both:
|
||||
- the side-buffer coefficients (= just-entropy-decoded, pre-IDCT)
|
||||
- the reconstructed pixels in h->cur_pic.f->data (= P + IDCT(C),
|
||||
pre-deblock for this MB)
|
||||
and the consumer can derive P = pixels − IDCT(C) for daedalus-
|
||||
decoder's frame-major dispatch.
|
||||
|
||||
Memcpy is gated on (h->mb_inspect_cb != NULL) — zero overhead when
|
||||
no consumer is registered. Buffer size = sizeof(int16_t) * 16 * 48
|
||||
= 1536 bytes per H264Context (fits in one cache line family;
|
||||
allocated once at H264Context lifetime, reused per MB).
|
||||
|
||||
8-bit path only. High-bit-depth H.264 uses the upper half of
|
||||
sl->mb (int16_t[16 * 48 * 2] declared; the * 2 reserves space for
|
||||
the high-depth case); preserving the high-depth coefficients
|
||||
correctly would need a wider side buffer. Punted for now — the
|
||||
daedalus-decoder consumer is 8-bit-only.
|
||||
|
||||
Single-threaded decode assumed at the consumer side (avctx->
|
||||
thread_count = 1). Multi-slice / multi-threaded streams would
|
||||
race on the single side buffer — that's an explicit limitation of
|
||||
the inspection mechanism, documented in 0016's comment block.
|
||||
Future extension: per-H264SliceContext side buffers.
|
||||
|
||||
Used by:
|
||||
- daedalus-decoder/tools/daedalus_decode_h264 PR-A3+ (CLI test
|
||||
harness extracts coefficients here for daedalus-decoder
|
||||
IDCT validation on real H.264 streams).
|
||||
|
||||
Refs reauktion/daedalus-decoder!14 (PR-A2 callback wiring).
|
||||
---
|
||||
libavcodec/h264_mb.c | 9 +++++++++
|
||||
libavcodec/h264dec.h | 8 ++++++++
|
||||
2 files changed, 17 insertions(+)
|
||||
|
||||
--- a/libavcodec/h264dec.h
|
||||
+++ b/libavcodec/h264dec.h
|
||||
@@ -593,6 +593,14 @@
|
||||
/* Per-MB inspection hook — set via ff_h264_set_mb_inspect_cb. */
|
||||
ff_h264_mb_inspect_cb mb_inspect_cb;
|
||||
void *mb_inspect_opaque;
|
||||
+
|
||||
+ /* Per-MB coefficient side buffer — populated at the start of
|
||||
+ * ff_h264_hl_decode_mb so the post-pixel-work inspection callback
|
||||
+ * can read the just-entropy-decoded coefficients before IDCT-add
|
||||
+ * zeros sl->mb. 16 blocks × 48 int16 = libavcodec sl->mb size
|
||||
+ * (matches DECLARE_ALIGNED(16, int16_t, mb)[16 * 48 * 2] for the
|
||||
+ * 8-bit half; high-bit-depth paths skip this — see h264_mb.c). */
|
||||
+ DECLARE_ALIGNED(16, int16_t, mb_inspect_coeffs)[16 * 48];
|
||||
} H264Context;
|
||||
|
||||
extern const uint16_t ff_h264_mb_sizes[4];
|
||||
--- a/libavcodec/h264_mb.c
|
||||
+++ b/libavcodec/h264_mb.c
|
||||
@@ -801,6 +801,15 @@
|
||||
{
|
||||
const int mb_xy = sl->mb_xy;
|
||||
const int mb_type = h->cur_pic.mb_type[mb_xy];
|
||||
+
|
||||
+ /* Snapshot just-entropy-decoded coefficients before IDCT-add
|
||||
+ * destroys them. Only when an inspection callback is registered
|
||||
+ * — zero cost otherwise. 8-bit path only (high-bit-depth uses
|
||||
+ * the upper half of sl->mb which we don't preserve here). */
|
||||
+ if (h->mb_inspect_cb && !h->pixel_shift)
|
||||
+ memcpy((int16_t *) (uintptr_t) h->mb_inspect_coeffs, sl->mb,
|
||||
+ sizeof(((H264Context *) NULL)->mb_inspect_coeffs));
|
||||
+
|
||||
int is_complex = CONFIG_SMALL || sl->is_complex ||
|
||||
IS_INTRA_PCM(mb_type) || sl->qscale == 0;
|
||||
|
||||
@@ -24,7 +24,7 @@ _srcname=FFmpeg
|
||||
_version='8.1'
|
||||
_commit='b57fbbe50c9b2656fad86a1a7eeabfd2b2a50935' # v4l2-request-n8.1 tip 2026-04-24
|
||||
pkgver=8.1.r123329.b57fbbe
|
||||
pkgrel=13 # pkgrel=13 — per-MB inspection callback (0016) for daedalus-decoder CLI test harness; observation-only, no behaviour change to existing decode path
|
||||
pkgrel=15 # pkgrel=15 — export ff_h264_set_mb_inspect_cb via libavcodec.v so dlsym consumers (daedalus-v4l2 daemon shadow_decoder, PR-Q3a.1) can resolve the symbol; static-link CLI was unaffected. No behaviour change to existing decode path. (2026-05-26)
|
||||
epoch=2
|
||||
|
||||
# daedalus-fourier pin. 209a421 = PR #2 merge (Phase 8c — public API
|
||||
@@ -103,8 +103,9 @@ source=("git+https://github.com/Kwiboo/FFmpeg.git#commit=${_commit}"
|
||||
'0013-h264-deblock-chroma-intra-daedalus-fourier.patch'
|
||||
'0014-h264-ctx-qpu-capable.patch'
|
||||
'0015-h264-ctx-revert-to-no-qpu.patch'
|
||||
'0016-h264-mb-inspect-callback.patch')
|
||||
sha256sums=('SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP')
|
||||
'0016-h264-mb-inspect-callback.patch'
|
||||
'0017-h264-mb-coeffs-side-buffer.patch')
|
||||
sha256sums=('SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP')
|
||||
|
||||
pkgver() {
|
||||
cd "${_srcname}"
|
||||
@@ -131,6 +132,7 @@ prepare() {
|
||||
patch -Np1 -i "${srcdir}/0014-h264-ctx-qpu-capable.patch"
|
||||
patch -Np1 -i "${srcdir}/0015-h264-ctx-revert-to-no-qpu.patch"
|
||||
patch -Np1 -i "${srcdir}/0016-h264-mb-inspect-callback.patch"
|
||||
patch -Np1 -i "${srcdir}/0017-h264-mb-coeffs-side-buffer.patch"
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
@@ -35,13 +35,20 @@ to fall through.
|
||||
|
||||
Used by:
|
||||
- daedalus-decoder/tools/daedalus_decode_h264 (PR-A1b)
|
||||
- future daedalus-v4l2 daemon refactor
|
||||
- daedalus-v4l2 daemon shadow-mode path (PR-Q3a.1+)
|
||||
|
||||
The CLI static-links libavcodec.a so symbol visibility doesn't matter
|
||||
there. The daemon dlopens libavcodec.so.62 and resolves the callback
|
||||
via dlsym, so the symbol MUST be exported — added to libavcodec.v
|
||||
explicitly (FFmpeg's default version script hides every `ff_*` symbol
|
||||
as LOCAL behind a glob).
|
||||
|
||||
Refs reauktion/daedalus-decoder!12 (Stage 2 PR-b complete).
|
||||
---
|
||||
libavcodec/h264_mb.c | 20 ++++++++++++++++++++
|
||||
libavcodec/h264dec.h | 26 ++++++++++++++++++++++++++
|
||||
2 files changed, 46 insertions(+)
|
||||
libavcodec/h264_mb.c | 20 ++++++++++++++++++++
|
||||
libavcodec/h264dec.h | 26 ++++++++++++++++++++++++++
|
||||
libavcodec/libavcodec.v | 1 +
|
||||
3 files changed, 47 insertions(+)
|
||||
|
||||
--- a/libavcodec/h264dec.h
|
||||
+++ b/libavcodec/h264dec.h
|
||||
@@ -113,3 +120,13 @@ Refs reauktion/daedalus-decoder!12 (Stage 2 PR-b complete).
|
||||
+ h->mb_inspect_cb = cb;
|
||||
+ h->mb_inspect_opaque = opaque;
|
||||
}
|
||||
--- a/libavcodec/libavcodec.v
|
||||
+++ b/libavcodec/libavcodec.v
|
||||
@@ -3,6 +3,7 @@
|
||||
av_*;
|
||||
avcodec_*;
|
||||
avpriv_*;
|
||||
+ ff_h264_set_mb_inspect_cb;
|
||||
avsubtitle_free;
|
||||
local:
|
||||
*;
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Markus Fritsche <mfritsche@reauktion.de>
|
||||
Date: Tue, 26 May 2026 07:30:00 +0200
|
||||
Subject: [PATCH] avcodec/h264: preserve sl->mb coefficients for the inspection
|
||||
callback (companion to 0016)
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Patch 0016 adds a per-MB inspection callback fired at the end of
|
||||
ff_h264_hl_decode_mb. By that time the IDCT-add path has already
|
||||
zeroed sl->mb (FFmpeg's convention — see ff_h264_idct_add_neon and
|
||||
friends), so consumers reading coefficients from the callback get
|
||||
zeros.
|
||||
|
||||
Add a coefficient side buffer in H264Context, populated at the
|
||||
START of ff_h264_hl_decode_mb (before any IDCT runs) with a single
|
||||
memcpy from sl->mb. The post-pixel-work callback (still in 0016)
|
||||
can then read both:
|
||||
- the side-buffer coefficients (= just-entropy-decoded, pre-IDCT)
|
||||
- the reconstructed pixels in h->cur_pic.f->data (= P + IDCT(C),
|
||||
pre-deblock for this MB)
|
||||
and the consumer can derive P = pixels − IDCT(C) for daedalus-
|
||||
decoder's frame-major dispatch.
|
||||
|
||||
Memcpy is gated on (h->mb_inspect_cb != NULL) — zero overhead when
|
||||
no consumer is registered. Buffer size = sizeof(int16_t) * 16 * 48
|
||||
= 1536 bytes per H264Context (fits in one cache line family;
|
||||
allocated once at H264Context lifetime, reused per MB).
|
||||
|
||||
8-bit path only. High-bit-depth H.264 uses the upper half of
|
||||
sl->mb (int16_t[16 * 48 * 2] declared; the * 2 reserves space for
|
||||
the high-depth case); preserving the high-depth coefficients
|
||||
correctly would need a wider side buffer. Punted for now — the
|
||||
daedalus-decoder consumer is 8-bit-only.
|
||||
|
||||
Single-threaded decode assumed at the consumer side (avctx->
|
||||
thread_count = 1). Multi-slice / multi-threaded streams would
|
||||
race on the single side buffer — that's an explicit limitation of
|
||||
the inspection mechanism, documented in 0016's comment block.
|
||||
Future extension: per-H264SliceContext side buffers.
|
||||
|
||||
Used by:
|
||||
- daedalus-decoder/tools/daedalus_decode_h264 PR-A3+ (CLI test
|
||||
harness extracts coefficients here for daedalus-decoder
|
||||
IDCT validation on real H.264 streams).
|
||||
|
||||
Refs reauktion/daedalus-decoder!14 (PR-A2 callback wiring).
|
||||
---
|
||||
libavcodec/h264_mb.c | 9 +++++++++
|
||||
libavcodec/h264dec.h | 8 ++++++++
|
||||
2 files changed, 17 insertions(+)
|
||||
|
||||
--- a/libavcodec/h264dec.h
|
||||
+++ b/libavcodec/h264dec.h
|
||||
@@ -593,6 +593,14 @@
|
||||
/* Per-MB inspection hook — set via ff_h264_set_mb_inspect_cb. */
|
||||
ff_h264_mb_inspect_cb mb_inspect_cb;
|
||||
void *mb_inspect_opaque;
|
||||
+
|
||||
+ /* Per-MB coefficient side buffer — populated at the start of
|
||||
+ * ff_h264_hl_decode_mb so the post-pixel-work inspection callback
|
||||
+ * can read the just-entropy-decoded coefficients before IDCT-add
|
||||
+ * zeros sl->mb. 16 blocks × 48 int16 = libavcodec sl->mb size
|
||||
+ * (matches DECLARE_ALIGNED(16, int16_t, mb)[16 * 48 * 2] for the
|
||||
+ * 8-bit half; high-bit-depth paths skip this — see h264_mb.c). */
|
||||
+ DECLARE_ALIGNED(16, int16_t, mb_inspect_coeffs)[16 * 48];
|
||||
} H264Context;
|
||||
|
||||
extern const uint16_t ff_h264_mb_sizes[4];
|
||||
--- a/libavcodec/h264_mb.c
|
||||
+++ b/libavcodec/h264_mb.c
|
||||
@@ -801,6 +801,15 @@
|
||||
{
|
||||
const int mb_xy = sl->mb_xy;
|
||||
const int mb_type = h->cur_pic.mb_type[mb_xy];
|
||||
+
|
||||
+ /* Snapshot just-entropy-decoded coefficients before IDCT-add
|
||||
+ * destroys them. Only when an inspection callback is registered
|
||||
+ * — zero cost otherwise. 8-bit path only (high-bit-depth uses
|
||||
+ * the upper half of sl->mb which we don't preserve here). */
|
||||
+ if (h->mb_inspect_cb && !h->pixel_shift)
|
||||
+ memcpy((int16_t *) (uintptr_t) h->mb_inspect_coeffs, sl->mb,
|
||||
+ sizeof(((H264Context *) NULL)->mb_inspect_coeffs));
|
||||
+
|
||||
int is_complex = CONFIG_SMALL || sl->is_complex ||
|
||||
IS_INTRA_PCM(mb_type) || sl->qscale == 0;
|
||||
|
||||
+5
-6
@@ -33,12 +33,10 @@ 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)
|
||||
PKGREL=15 # pkgrel=15 — export ff_h264_set_mb_inspect_cb via libavcodec.v so
|
||||
# dlsym consumers (daedalus-v4l2 daemon shadow_decoder, PR-Q3a.1)
|
||||
# can resolve the symbol; static-link CLI was unaffected. No
|
||||
# behaviour change to existing decode path. (2026-05-26)
|
||||
|
||||
# daedalus-fourier pin. 209a421 = daedalus-fourier PR #2 merge — public
|
||||
# API now exposes daedalus_recipe_dispatch_h264_qpel_mc20 +
|
||||
@@ -83,6 +81,7 @@ 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"
|
||||
patch -Np1 -i "$HERE/0017-h264-mb-coeffs-side-buffer.patch"
|
||||
|
||||
# --- daedalus-fourier: fetch + build static .a with PIC, install to a
|
||||
# per-build prefix; libavcodec.so links it into the shared object so
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
ffmpeg-v4l2-request-fourier (2:8.1+rfourier+gb57fbbe-15) bookworm trixie; urgency=medium
|
||||
|
||||
* Amend 0016-h264-mb-inspect-callback.patch to also add
|
||||
ff_h264_set_mb_inspect_cb to libavcodec/libavcodec.v so the
|
||||
symbol is exported (GLOBAL) on the shipped libavcodec.so.62.
|
||||
Without this, FFmpeg's default version script hides every ff_*
|
||||
symbol behind a glob → LOCAL → dlsym() returns NULL. The CLI
|
||||
consumer (daedalus_decode_h264) was unaffected because it
|
||||
static-links libavcodec.a; the daedalus-v4l2 daemon (PR-Q3a.1
|
||||
shadow_decoder path) dlopens libavcodec.so.62 and needs the
|
||||
symbol resolvable at runtime.
|
||||
* No behaviour change to existing decode path. Callback is still
|
||||
opt-in via the function pointer (NULL default), so paying the
|
||||
one-load-one-branch cost only when a consumer has explicitly
|
||||
installed an inspection callback.
|
||||
|
||||
-- Markus Fritsche <mfritsche@reauktion.de> Tue, 26 May 2026 15:00:00 +0200
|
||||
|
||||
ffmpeg-v4l2-request-fourier (2:8.1+rfourier+gb57fbbe-10) bookworm trixie; urgency=medium
|
||||
|
||||
* Add 0007-h264-qpel-mc20-daedalus-fourier.patch —
|
||||
|
||||
Reference in New Issue
Block a user