Repository navigation
Conversation
|
No blockers.
I checked the rest. HW row: a Mac on the queued two-bank transport (J815, or J813 with the open-queue backend), rebased on #2195: the 26 new resize vectors plus your synthetic aq-mode 1/2/3 streams at 640x360 and 1280x720 against libvpx MD5s, and 0 AVC, 0 failed units, 0 new kernel errors. Assisted-by: LLM (Claude:Opus 5.5) |
1309f5c to
b43dd04
Compare
|
@RyanTheTide thanks.
HW row: after the rebase on #2195, on the J813 with the open-queue backend:
Assisted-by: LLM (Claude:Opus 5.5) |
|
Thanks for b43dd04. The commit message of patch 4 now states the 1280x720 kept-map gap. Thanks also for the plan for the One new thing, from #2773, which touches the same lines of
HW row unchanged: the 26 resize vectors and the aq-mode streams on the open-queue transport, after the #2195 rebase. That row is also what lets the scope come off. Assisted-by: LLM (Claude:Opus 5.5) |
|
@RyanTheTide agreed on both points.
Assisted-by: LLM (Claude:Opus 5.5) |
b43dd04 to
ec360bc
Compare
|
Rebased onto #2773 as agreed. The head is now ec360bc, on integration/aurora f5fae3c.
The scope comes off in the follow-up with the open-queue row: the 26 resize vectors and the aq-mode streams, after #2195. Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR review on ec360bce702f231bbafa504c594f3901547c16b7:
Commits 1 (c2d7aee81e46, temporal MV same-size check) and 2 (d3c0828a7f7b, swapping AVD_HDR_HEIGHT(yscale) | AVD_HDR_WIDTH(xscale) in set_refs()) are solid, well-tested spec fixes, and all 4 commits are §4-clean (human author/committer + Signed-off-by:, zero AI trailers in commits). CI host-tests passed on ec360bce702f.
Concrete blockers before merge:
-
Code correctness — Two-bank segmentation state &
VP9_SEG_RESETedge cases (7a4bc4f37fd5):avd_vp9_run_preamble()unconditionally executesif (vp9_ctx->last.valid && !avd_vp9_same_size(dec_params, &vp9_ctx->last)) memset(vp9_ctx->b->bufs.seg.cpu, 0, vp9_ctx->b->bufs.seg.size);on all transports, including the two-bank queued firmware backend (avd_backend_is_qfw()). Even with Patch 4 gating smaller frames toavd_backend_is_open(), frames whose unaligned dimensions change within the same 64×16 aligned capture format (e.g., 1920×1080 → 1900×1080, noted in commit 1) already passvalidate_dec_params()on the queued backend. Clearing only the active bank leaves the other bank'ssegbuffer stale with the prior size's map (and will race an in-flight bank once#2195unifiessegper stream).- In
make_flags1(),VP9_SEG_RESETis gated onframe->seg.flags & V4L2_VP9_SEGMENTATION_FLAG_ENABLEDon the size-changing frame itself. If frame N changes size with segmentation disabled and frame N+1 (now same size) enables segmentation withupdate_map = 0,VP9_SEG_RESETis never asserted. - §2 Production-ready: Patch 4 (
ec360bce702f) knowingly turns currently rejected (-EINVAL) 1280×720+update_map = 0resize streams into silent pixel corruption (26/40 and 28–29/40 matching frames with no error). Either resolve the 720p+ kept-map corruption before enabling smaller frames, or split out the unconditional spec bugfixes (commits 1–2) so they can land cleanly without shipping silent decode corruption.
-
Stale base —
integration/auroramoved inavd-vp9.candtests/vp9-test.py:- Since this PR's base (
f5fae3cbb047),integration/auroralanded966778e43840(media: apple: avd: vp9: bound the tile counts) and276447127c76(media: apple: avd: build HEVC and VP9 jobs from copies of their controls), both touchingavd-vp9.candtests/vp9-test.py. Rebase onto currentintegration/auroraand re-verifyvp9-test.pyand the newapple-avd-vp9KUnit suite.
- Since this PR's base (
-
§5 — Live-hardware verification missing on exact live head & missing regression tuple:
- Exact head
ec360bce702f(with the#2773rebase andavd_backend_is_open()scoping) has not been booted/tested on hardware; the PR body's results are from an older out-of-tree module build prior to the rebase. - Required §5 evidence fields are missing: exact tested head SHA, kernel/build version, SELinux mode,
0 AVC denials,0 failed units, and0 new kernel errors. Please post a fresh hardware run against the rebased live head with the full §5 tuple.
- Exact head
Assisted-by: LLM (Gemini 4 Neon)
… size VP9 predicts motion vectors from the previous frame only if that frame has the same size (UsePrevFrameMvs in compute_image_size(), libvpx's use_prev_frame_mvs). avd_vp9_uses_prev_mv() does not compare sizes, so after a size change the decoder reads the previous frame's MV buffer, which is laid out for the other size. Frames of different sizes already pass validate_dec_params() when they share the 64x16 aligned capture format, e.g. 1920x1080 and 1900x1080. Accepting frames smaller than the capture format, as aurora-silicon#2136 does, makes this common: with that change alone, every VP9 stream that changes size on an inter frame without error resilience fails at the first frame of the new size with "open firmware error 0x8", a timeout and a decoder reset. With this patch no frame fails in the firmware. Record the size of each frame and require the previous one to match. The host test decodes a 1900x1080 frame after a 1920x1088 one and checks that the prior bank's MV buffer is not used. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
set_refs() packs the horizontal reference scale into the upper 16 bits and the vertical one into the lower 16 bits. The decoder reads them the other way round. A reference scaled the same in both directions (2:1, 4:3) decodes either way, so only references whose aspect ratio differs from the frame's were wrong. A frame whose size changes within its 64x16 aligned capture format (1920x1080 to 1900x1080) already predicts from such a reference. Once frames smaller than the capture format are accepted (aurora-silicon#2136), libvpx's vp90-2-05-resize.ivf (352x288 to 282x173) and vp90-2-18-resize.ivf (310x230 to 248x138) do too, and decode bit-exact against libvpx's MD5s: 10 of 10 and 100 of 100 frames, up from 3 and 94. Pack the vertical scale with AVD_HDR_HEIGHT() and the horizontal one with AVD_HDR_WIDTH(), as the reference size above it is. The host test checks the word for a 1440x1088 reference of a 1920x1088 frame. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
ec360bc to
b176bbc
Compare
|
@DjDeveloperr thanks. I split it as you suggested.
On the review points:
Assisted-by: LLM (Claude:Opus 5.5) |
b176bbc to
b9fee44
Compare
|
@DjDeveloperr both points on commit 3 are fixed. The head is
Host test (
Two mutants fail it:
Checks:
Commit 3's message describes the new behaviour. Its hardware table still comes from the legacy transport, with one bank and segmentation on every frame, where the reset goes to the first frame of the new size as before. The PR stays a draft for the 1280x720+ kept-map case, and the J813 row on this head follows with that fix. Assisted-by: LLM (Claude:Opus 5.5) |
… changes
VP9 clears the segmentation map when the frame size changes
(compute_image_size(); libvpx zeroes last_frame_seg_map). The driver sets
VP9_SEG_RESET only for key frames and after an intra frame without
segmentation, and the decoder keeps part of the map in the seg buffer
across frames. After a size change, a frame that predicts its segment IDs
from the previous frame or keeps them (update_map 0) used the old map,
laid out for the other size.
After a size change, set VP9_SEG_RESET for every frame that uses
segmentation until one updates the map. The decoder does not carry a
reset map forward: a frame that keeps the map (update_map 0) after one
with VP9_SEG_RESET reads the old map again, so the reset is repeated
until a frame has written a new map. Clear each bank's seg buffer before
the bank next runs: a bank still busy with an earlier frame belongs to
the hardware until it retires, so its buffer is cleared when it is next
taken.
Test streams from libvpx with internal scaling (VP8E_SET_SCALEMODE: full,
half, full size on inter frames) and segmentation AQ, no error
resilience, against libvpx-equivalent software decoding, with frames
smaller than the capture format accepted (later in this series):
640x360 cyclic refresh (temporal map) 25/40 -> 40/40
variance, complexity (kept map) 10/40, 25/40 -> 40/40
1280x720 all three 40/40
1920x1080 all three 40/40
With the reset on the first frame of the new size only, the kept-map
streams at 1280x720 and 1920x1080 went wrong from the second frame after
the size grew back (26/40, 26/40, 28/40, 29/40). These streams ran on the
legacy transport, which has one VP9 bank, and use segmentation on every
frame. The host test checks, with two banks, that only a size change
clears the buffers, that a busy bank's buffer waits until the bank is
taken, and that the reset stays until a frame updates the map.
Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
VP9 inter frames can change the frame size and keep predicting from references of the old size. validate_dec_params() refuses every frame whose aligned size differs from the capture format, so userspace has to reallocate the capture buffers and loses those references. FFmpeg's V4L2 request VP9 hwaccel can instead keep the buffers and decode a frame that fits in place (FFmpeg PR 20847, fix 5), and the decoder already handles what this needs: each reference carries its own size and scale (set_refs()), the frame is written with the format's stride, and the scratch buffers are sized for the format. On the legacy transport, accept frames whose aligned size fits the capture format and keep refusing larger ones. The firmware transports (open-queue and the Apple backend) keep requiring the format's size, as they keep the 64-pixel floor: an input their firmware does not expect can reset the engine instead of failing the frame, and this has not been measured there yet. The host test runs a 960x540 frame in a 1920x1088 format on the legacy transport, refuses it on the firmware transport, and refuses a 1984x1088 one on both. On a J813 (legacy transport) with FFmpeg PR 20847 v2 (decoding in place) and the earlier patches of this series, the libvpx VP9 conformance vectors match libvpx's MD5s in 299 of 304 4:2:0 vectors, up from 273. The 26 are the 24 vp90-2-21-resize_inter vectors, vp90-2-05-resize and vp90-2-18-resize. No vector stopped matching, and no frame fails in the firmware. Userspace that renegotiates the format on every size change, such as FFmpeg's current code, decodes as before (273). H.264, HEVC, VP9 and AV1 test clips stay bit-exact. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
b9fee44 to
a8e9047
Compare
|
@DjDeveloperr the 1280x720+ kept-map case is fixed, and here is the J813 row on the exact head The cause. After a size change the decoder needs
Row (MacBook Air M5, J813, legacy transport; one-shot trial boot of
Checks: With this the PR leaves draft. It still sits on #3017. Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR re-review on a8e9047aac5025ec881cbe436a76663dfbbbd46e (CI host-tests: SUCCESS; merges cleanly onto live integration/aurora a3d477d03f8e).
All prior blockers from ec360bce702f resolved
- Two-bank segmentation state &
VP9_SEG_RESETlatch (652a2495c5d3):avd_vp9_run_preamble()now marksvp9_ctx->bank[i].seg_clear = trueacross all banks on a size change and zeroesvp9_ctx->b->bufs.seg.cpuonly when a bank is next taken, never touching an in-flight busy bank's DMA buffer.vp9_ctx->seg_resetis latched on any size change, applied inmake_flags1()wheneverV4L2_VP9_SEGMENTATION_FLAG_ENABLEDis set, and cleared inupdate_ctx_last_info()only once a frame with bothV4L2_VP9_SEGMENTATION_FLAG_ENABLEDandV4L2_VP9_SEGMENTATION_FLAG_UPDATE_MAPcommits.- This also cleanly resolves the 1280×720+ kept-map (
update_map = 0) pixel corruption root-caused on J813 hardware (the decoder does not persist a reset seg map across a subsequent kept-map frame). drivers/media/platform/apple/avd/tests/vp9-test.pythoroughly exercises the two-bank busy-buffer preservation, delayed enable after a non-segmented resize, kept-map persistence ofVP9_SEG_RESET, and latch clearing onUPDATE_MAP.
- Base &
integration/auroracompatibility:- Rebased onto
70a00e583b03(including966778e43840and276447127c76), and checked against currentintegration/auroraa3d477d03f8e(#2946avd_vp9_frame_fits()and26fcdf5859dd): merges cleanly and stays semantically compatible.
- Rebased onto
- §5 Exact-head hardware evidence:
- Exact-head J813 (M5 MacBook Air, legacy transport, enrolled Aura, default kernel command line,
7.3.0-aurora-j813-fit2136+) row verified: all 640×360 / 1280×720 / 1920×1080 AQ 0–3 scale-mode streams 40/40 bit-exact, constant-size kept-map streams 40/40, libvpx VP9 conformance 299/304 (+26 resize vectors with FFmpeg PR 20847 v2 in-place, 0 regressions, 0 AVD errors in dmesg), renegotiating FFmpeg unchanged (273/304), codec clips (H.264/HEVC/Main10/VP9/AV1/4K60) bit-exact, and full regression tuple (0DART faults,0failed units,0AVC denials with SELinux disabled,0new kernel errors on in-place decode).
- Exact-head J813 (M5 MacBook Air, legacy transport, enrolled Aura, default kernel command line,
Checklist Audit (§1–§6)
- §1 No model gating: Pass (
avd_backend_is_open()reuses#2773's backend transport capability check; open-queue enablement is tracked for the follow-up after#2195). - §2 Production-ready: Pass (no new parameters or hacks; silent corruption resolved).
- §3 Safety: Pass (bounds validated against
decoded_fmt, non-zero frame dimensions inset_refs(), no CPU writes to in-flight bank DMA buffers). - §4 Clean-room & Attribution: Pass. All 4 commits (
e04db3b4f021,6fd057431b55,652a2495c5d3,a8e9047aac50) carry human author/committer (Thomas Glanzmann <thomas@glanzmann.de>) and humanSigned-off-by:only, with zero AI commit trailers;Assisted-by:is disclosed in the PR body. - §5 Evidence: Pass (exact-head CI
host-testsgreen + exact-head J813 HW row and regression tuple). - §6 Naming: Pass.
Non-blocking notes
- Commits 1–2 (
e04db3b4f021..6fd057431b55) match open, already-approved#3017; MERGETRAIN6 can land#3017first (or take the stack directly), and whichever of#2136/#2195lands second reconciles per-bankseg_clearwith#2195's sharedvp9_ctx->seg. - Minor pre-existing pattern: if
avd_init_job()(orset_tiles()after#2946) fails afteravd_vp9_run_preamble(),seg_clear/seg_resethave already been mutated for that rejected frame (same asbank->busy/frame_contextin the preamble).
Verdict: APPROVE — 0 blockers; ready for MERGETRAIN6.
Assisted-by: LLM (Gemini 4 Neon)
Stacked on #3017 (commits 1 and 2, the temporal-MV and reference-scale fixes, split out so they can land on their own). Review commits 3 and 4 here. Commit 3 now also fixes the 1280x720+ kept-map case, and has the two-bank and later-enable fixes from Dj's review (head
a8e9047aac50).The AVD now decodes VP9 frames that are smaller than the capture format, so a VP9 stream can change size on an inter frame and keep its references. Today the driver refuses such a frame ("unexpected bitstream resolution") and stops the stream. Accepting it surfaced three bugs in the VP9 path that a size change exposes, and each is fixed in its own commit.
Why
VP9 inter frames can change size and keep predicting from references of the old size: WebRTC and SVC streams do this, as do the libvpx
resize_interconformance vectors. FFmpeg's V4L2 request VP9 hwaccel handles it in FFmpeg PR 20847 (fix 5 of SomeComputerGuy's series): it keeps the capture buffers and decodes a frame that fits in place. On the AVD that path failed, becausevalidate_dec_params()requires the aligned frame size to equal the capture format. mainline rkvdec has the same check.The commits
avd_vp9_uses_prev_mv()didn't check the size. With only the size check relaxed, every non-error-resilient stream crashed the firmware at the first frame of the new size:open firmware error 0x8, a timeout and a decoder reset.set_refs()put the horizontal scale in the upper 16 bits. The decoder reads the vertical one there. This only showed with references whose aspect ratio differs from the frame's:vp90-2-05-resize(352x288 to 282x173) andvp90-2-18-resize.VP9_SEG_RESETfor every frame that uses segmentation until one updates the map: the decoder doesn't carry a reset map forward, so a frame that keeps the map (update_map0) after a reset frame would read the old map again. It also clears each bank's seg buffer, which carries part of the map over, before the bank next runs (a busy bank's buffer belongs to the hardware until it retires).avd_backend_is_open()): an input their firmware does not expect can reset the engine instead of failing the frame. That scope comes off in a follow-up with the open-queue row (the 26 resize vectors and the aq-mode streams, after media: apple: avd: VP9: one segmentation map per stream, shared by the banks #2195).Rebased onto #2773 (integration/aurora f5fae3c): this series reuses its
avd_backend_is_open(). Intests/vp9-test.py, this series' blocks run first, at the 1920x1088 format; #2773's 64x64 blocks run after them.Testing
On a J813 (M5 MacBook Air), with this series built as a module against the 7.3 J813 tree. AVD there uses the legacy transport, one VP9 bank. Test frames are compared with libvpx's MD5s, or with FFmpeg's software decode, which is bit-exact with libvpx.
libvpx VP9 conformance vectors, with FFmpeg PR 20847 v2 (decoding in place): on integration/aurora
70a00e583b03, 299 of 304 4:2:0 vectors match, up from 273 with media: apple: avd: VP9 temporal MVs and reference scale after a size change #3017 alone (11-24 row). The new matches are the 24vp90-2-21-resize_intervectors,05-resizeand18-resize. No vector stopped matching, and no frame fails in the firmware. With FFmpeg's current code, which renegotiates on every size change, the result is unchanged (215).No regressions: H.264, HEVC Main/Main10, VP9 and AV1 test clips stay bit-exact. The 36
resize-fp-tilesvectors match on both FFmpeg paths. 720p streams with segmentation that keep their size stay bit-exact.Synthetic streams: the conformance vectors that change size on inter frames are all error resilient, so they never reach commits 1 and 3. To cover those paths I encoded streams with libvpx's internal scaling (
VP8E_SET_SCALEMODE: full, half, full on inter frames), segmentation AQ and no error resilience. The encoder is below.vp9-scalemode-enc.c (libvpx test stream encoder)
Usage:
vp9-scalemode-enc in.yuv 640 360 40 <aq> 10 25 out.ivfcodes frames 10 to 24 at half size.tests/vp9-test.pyhas a new case for each commit, and each case fails on the commit before it.tools/asahi/run-host-tests.py: 394/394. checkpatch is clean.Known gaps
AV1_REF_SCALE_X). I haven't changed or tested it.cc @Acelogic @DjDeveloperr @RyanTheTide @LiamRay10
tests/vp9-test.pypasses. A 960x540 frame in a 1920x1088 format runs on the legacy transport and is refused on the firmware transport; a 1984x1088 one is refused on both. Both mutants fail it: "fits" on every transport, and exact size on every transport. The AVD host tests inrun-host-tests.pypass (12/12), and theW=1arm64 build ofdrivers/media/platform/apple/avdis clean.Assisted-by: LLM (Claude:Opus 5.5)