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)
62 lines
2.4 KiB
Diff
62 lines
2.4 KiB
Diff
From: Markus Fritsche <fritsche.markus@gmail.com>
|
|
Date: 2026-05-01
|
|
Subject: [PATCH] h264: submit PRED_WEIGHTS only when WEIGHTED_PRED applies
|
|
|
|
Per kernel UAPI (include/uapi/linux/v4l2-controls.h),
|
|
V4L2_CID_STATELESS_H264_PRED_WEIGHTS is a conditional control:
|
|
|
|
V4L2_H264_CTRL_PRED_WEIGHTS_REQUIRED(pps, slice) :=
|
|
((pps->flags & V4L2_H264_PPS_FLAG_WEIGHTED_PRED) &&
|
|
(slice_type == P || slice_type == SP)) ||
|
|
(pps->weighted_bipred_idc == 1 && slice_type == B)
|
|
|
|
Submitting PRED_WEIGHTS on a frame where the macro evaluates false
|
|
triggers VIDIOC_S_EXT_CTRLS to return EINVAL at error_idx=5 (the
|
|
6th, last control in the per-request batch) on hantro-vpu and any
|
|
other driver that strictly enforces the spec.
|
|
|
|
Smoke trace from RK3568 hantro on bbb_1080p30 (Main profile, no
|
|
weighted prediction): every per-frame batch fails identically, 13
|
|
EINVALs over a 10-frame run. Without this fix, ffmpeg's vaapi-copy
|
|
falls back to software decode for every frame.
|
|
|
|
Fix: narrow num_controls to 5 (excluding PRED_WEIGHTS at index 5)
|
|
when the macro returns false; keep at 6 when it returns true.
|
|
|
|
Defect found and fixed via Phase 6 Step 1 ohm smoke testing. Not
|
|
part of Sonnet's six-commit upstreamable plan; slotted in as patch
|
|
0005 ahead of the planned probe-then-set / FRAME_BASED commits
|
|
because it unblocks per-frame submission on every backing driver,
|
|
not just hantro.
|
|
|
|
Signed-off-by: Markus Fritsche <fritsche.markus@gmail.com>
|
|
---
|
|
--- a/src/h264.c 2026-05-01 20:17:02.108697824 +0000
|
|
+++ b/src/h264.c 2026-05-01 20:30:02.632190563 +0000
|
|
@@ -559,8 +559,24 @@
|
|
}
|
|
};
|
|
|
|
+ /*
|
|
+ * PRED_WEIGHTS is conditionally required per kernel UAPI:
|
|
+ * V4L2_H264_CTRL_PRED_WEIGHTS_REQUIRED(pps, slice) is only
|
|
+ * true when explicit weighted prediction applies (P/SP slice
|
|
+ * with WEIGHTED_PRED flag, or B slice with weighted_bipred_idc
|
|
+ * == 1). Submitting it unconditionally on a frame that does
|
|
+ * not need it triggers EINVAL at error_idx=5 on hantro and
|
|
+ * other drivers that strictly enforce the spec.
|
|
+ *
|
|
+ * controls[5] is PRED_WEIGHTS (last in array); narrow the
|
|
+ * submission count to exclude it when not required.
|
|
+ */
|
|
+ unsigned int num_controls = 6;
|
|
+ if (!V4L2_H264_CTRL_PRED_WEIGHTS_REQUIRED(&pps, &slice))
|
|
+ num_controls = 5;
|
|
+
|
|
rc = v4l2_set_controls(driver_data->video_fd, surface->request_fd,
|
|
- controls, 6);
|
|
+ controls, num_controls);
|
|
if (rc < 0)
|
|
return VA_STATUS_ERROR_OPERATION_FAILED;
|
|
|