b47938e0bc
build and publish packages / distcc-avahi-aarch64 (push) Successful in 1m3s
build and publish packages / lmcp-any (push) Successful in 9s
build and publish packages / lmcp-debian (push) Successful in 4s
build and publish packages / claude-his-any (push) Failing after 4s
build and publish packages / ffmpeg-v4l2-request-aarch64 (push) Has been skipped
build and publish packages / claude-his-debian (push) Has been skipped
Mirrors phase6/step1/ from the ohm_gl_fix campaign. Contract-correct
hantro multi-planar / chromium-149-era stateless H.264 port of
bootlin's libva-v4l2-request, patches 0001..0018 + fourier-local.
Honest characterisation in README:
- Builds cleanly on chromium-builder LXC (boltzmann)
- vainfo enumerates H.264 profiles cleanly with LIBVA_DRIVER_NAME=v4l2_request
- NOT on Brave's decode path on ohm_gl_fix stack — Brave uses
Chromium's own V4L2VideoDecoder in media/gpu/v4l2/.
- Most likely useful for a future Firefox-via-libavcodec-vaapi
campaign, modulo a separate Mesa-panfrost WSI pitch issue.
- DEBUG patches (0010, 0011, 0014) intentionally kept in series
for development; remove for cleaner production runs.
Audit trail in the source repo at ohm_gl_fix:
phase6/step1/audit_0008_decode_params_2026-05-01.md
phase6/step1/api_contract_findings_2026-05-01.md
phase3_remeasure_2026-05-02/B3_decoder_discovery.md (why this
isn't on Brave's path)
83 lines
3.3 KiB
Diff
83 lines
3.3 KiB
Diff
From: Markus Fritsche <fritsche.markus@gmail.com>
|
|
Date: 2026-05-02
|
|
Subject: [PATCH] h264: derive PFRAME / BFRAME flags from VASlice slice_type
|
|
|
|
v4l2_ctrl_h264_decode_params.flags has PFRAME and BFRAME bits per
|
|
ext-ctrls-codec-stateless.rst. fourier never set them; libva-v4l2-
|
|
request relied on each backing driver tolerating frame-class
|
|
ambiguity.
|
|
|
|
Kernel survey (linux 6.19.x):
|
|
- tegra-vde/h264.c (lines 783-799) consumes both flags to select
|
|
the inter-frame decode kernel. Without them the I-frame kernel
|
|
runs on P/B content.
|
|
- visl-trace-h264.h uses them for decode tracing.
|
|
- hantro / rkvdec / cedrus / mediatek / qcom-iris-stateless do
|
|
not consume the flags.
|
|
|
|
Hantro on ohm decoded bbb cleanly without these flags set (see
|
|
phase6/step1/ohm_smoke_2026-05-02T060255Z_post_0015/), so this is
|
|
an upstreamability fix for cross-driver portability rather than a
|
|
correctness fix for hantro.
|
|
|
|
VAAPI's VASliceParameterBufferH264.slice_type maps directly to the
|
|
H.264 slice_header() slice_type field. Per spec 7.4.3:
|
|
0=P 1=B 2=I 3=SP 4=SI; 5..9 = "all slices in the picture have
|
|
this slice_type." `slice_type % 5` recovers the underlying type
|
|
in either encoding form.
|
|
|
|
In FRAME_BASED mode we only see surface->params.h264.slice from the
|
|
most-recent VASliceParameterBuffer — that's fine: a single coded
|
|
picture has a uniform slice_type for the purposes of the PFRAME /
|
|
BFRAME flag (multi-slice frames may mix slice types in some streams,
|
|
but the flag's semantic is "this is an inter-coded frame," which
|
|
holds if any slice is P or B; using the last-seen slice's type is
|
|
a reasonable approximation).
|
|
|
|
Cross-reference: ext-ctrls-codec-stateless.rst Decode Parameters
|
|
Flags table.
|
|
|
|
Signed-off-by: Markus Fritsche <fritsche.markus@gmail.com>
|
|
---
|
|
--- a/src/h264.c
|
|
+++ b/src/h264.c
|
|
@@ -587,6 +587,38 @@
|
|
&surface->params.h264.slice,
|
|
&surface->params.h264.picture, &slice, &weights);
|
|
|
|
+ /*
|
|
+ * Derive PFRAME / BFRAME flags in v4l2_ctrl_h264_decode_params.flags
|
|
+ * from VASliceParameterBufferH264.slice_type. VAAPI's slice_type
|
|
+ * matches the H.264 spec slice_type semantic: 0=P, 1=B, 2=I, 3=SP,
|
|
+ * 4=SI; values 5..9 mean "all slices in the picture have this
|
|
+ * slice_type" (mod 5 yields the underlying type). VAAPI consumers
|
|
+ * (ffmpeg, mpv) populate this for every slice; in FRAME_BASED mode
|
|
+ * we only see the most-recent slice's params, but slice_type is
|
|
+ * uniform across a single coded picture for our purposes.
|
|
+ *
|
|
+ * Kernel consumers that read these flags: tegra-vde
|
|
+ * (drivers/media/platform/nvidia/tegra-vde/h264.c lines 783-799 of
|
|
+ * 6.19.x) selects the inter-frame decode kernel. Hantro / rkvdec /
|
|
+ * cedrus / mediatek / qcom-iris-stateless do not consume them.
|
|
+ * Setting them keeps the libva-v4l2-request fork upstreamable
|
|
+ * across drivers without affecting hantro behaviour.
|
|
+ *
|
|
+ * Cross-reference: ext-ctrls-codec-stateless.rst Decode Parameters
|
|
+ * Flags — V4L2_H264_DECODE_PARAM_FLAG_PFRAME / _BFRAME.
|
|
+ */
|
|
+ switch (surface->params.h264.slice.slice_type % 5) {
|
|
+ case H264_SLICE_P:
|
|
+ decode.flags |= V4L2_H264_DECODE_PARAM_FLAG_PFRAME;
|
|
+ break;
|
|
+ case H264_SLICE_B:
|
|
+ decode.flags |= V4L2_H264_DECODE_PARAM_FLAG_BFRAME;
|
|
+ break;
|
|
+ default:
|
|
+ /* I / SP / SI: no extra flag. */
|
|
+ break;
|
|
+ }
|
|
+
|
|
sps.profile_idc = h264_profile_to_idc(profile);
|
|
|
|
/*
|