Repository navigation
media: apple: avd: VP9 temporal MVs and reference scale after a size change - #3017
Conversation
… 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>
|
J813 row on this exact head. Setup
What this shows and what it doesn't. It shows no regression on the J813. It doesn't show the fixes working: none of these vectors reaches the changed code without #2136. In the in-place build a smaller frame is still refused, and the renegotiating build gives the same results on both kernels. Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal adversarial §1–§6 pre-PR review at live head 6fd057431b55e034a3b01e7f97d97e09ba55cb2a (checked against live integration/aurora 5746ef8a5afd).
Checklist Audit (§1–§6)
- §1 No model gating: Pass. Pure VP9 specification and hardware-packing fixes in
drivers/media/platform/apple/avd/avd-vp9.c; zero model, SoC, board, or firmware-version gating. - §2 Production-ready / Code correctness: Pass.
- Commit 1 (
e04db3b4f021): Recordswidth/height(frame_*_minus_1 + 1) instruct avd_vp9_frame_infoviaupdate_ctx_cur_info(), propagated tovp9_ctx->lastin both QFW (avd_vp9_run()) and legacy (avd_vp9_done()) paths, and enforcesavd_vp9_same_size(frame, last)inavd_vp9_uses_prev_mv()at both call sites (make_flags1()VP9_HAS_REFandset_header()temporal-MVcolorDMA address). No integer overflow or lifetime issues. (Minor pre-existing non-blocking note: VP9UsePrevFrameMvsalso excludeslast->flags & V4L2_VP9_FRAME_FLAG_INTRA_ONLY, which was already absent prior to this PR.) - Commit 2 (
6fd057431b55): Fixes the swapped 16-bit halves inset_refs()fromAVD_HDR_HEIGHT(xscale) | AVD_HDR_WIDTH(yscale)toAVD_HDR_HEIGHT(yscale) | AVD_HDR_WIDTH(xscale), matchingAVD_HDR_HEIGHT(GENMASK(31, 16)) /AVD_HDR_WIDTH(GENMASK(15, 0)) inavd-inst.handhdr_70_ref_height_widthimmediately above. drivers/media/platform/apple/avd/tests/vp9-test.pyadds deterministic host tests exercising both commits under ASan/UBSan in QFW two-bank mode (prior-bank MV suppression on1920x1088 -> 1900x1080, and0x40003000vs0x30004000for1440x1088 -> 1920x1088), failing prior to each commit.
- Commit 1 (
- §3 Safety: Pass. Prevents reading a mismatched-size temporal MV buffer and fixes wrong reference scale packing.
- §4 Clean-room & Attribution: Pass. Both commits (
e04db3b4f021,6fd057431b55) carry human author/committer (Thomas Glanzmann <thomas@glanzmann.de>) and humanSigned-off-by:only; zero AI commit trailers;Assisted-by:disclosed in PR body. - §5 Evidence: Pass. Exact-head A/B hardware row on J813 (
6fd057431b55vsintegration/aurora70a00e583b03, default kernel command line, enrolled Aura1.0.0b12-g693083b4) ran all 314 libvpx VP9 vectors across both FFmpeg builds + 6 codec clips (bit-exact), matching base with0DART faults,0failed units,0AVC denials (SELinux disabled on J813), and0new kernel error lines vs base, backed by 12/12 AVD host tests, 81/81 arm64 QEMU KUnit tests, and positive resize decode proof with #2136 (05-resize10/10,18-resize100/100 bit-exact). (Note for MERGETRAIN6: a queued-firmware / SELinux-enforcing Mac smoke run is good coverage alongside the J813 legacy-transport row.) - §6 Naming & CI: Pass. Clean naming; CI
host-testsisSUCCESS; merges cleanly onto liveintegration/aurora.
Verdict: APPROVE — 0 blockers; ready for MERGETRAIN6.
Assisted-by: LLM (Gemini 4 Neon)
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
What: Two VP9 fixes in the Apple AVD decoder for streams that change size: no temporal motion vectors from a reference frame of another size, and the reference scale's two 16-bit halves in the right order. Split out of #2136.
Tested: J813 M5 Air at
6fd057431b55: all libvpx VP9 vectors in both FFmpeg builds match the base, and the codec clips are bit-exact; 0 failed units, 0 DART faults, 0 new kernel errors (issuecomment-7115442359).Risk: two-way door · every Mac whose AVD decodes VP9 (shared
avd-vp9.c); checked on the J813 only.Not yet: a row on a Mac with the queued-firmware AVD transport.
Details
Two VP9 fixes in the AVD driver for frames that change size, split out of #2136. Both are independent of #2136's change that accepts frames smaller than the capture format.
UsePrevFrameMvs, libvpx'suse_prev_frame_mvs).avd_vp9_uses_prev_mv()doesn't compare sizes, so after a size change the decoder reads an MV buffer laid out for the other size.validate_dec_params()when they share the 64x16 aligned capture format, for example 1920x1080 and 1900x1080.set_refs()packs the horizontal reference scale into the upper 16 bits. The decoder reads the vertical one there.vp90-2-05-resize(352x288 to 282x173) andvp90-2-18-resizedecode bit-exact (10/10 and 100/100 frames, up from 3 and 94).Evidence
Testing
At this head (
6fd057431b55, on integration/aurora70a00e583b03):tests/vp9-test.pypasses. Each commit adds its own case, which fails on the commit before it.run-host-tests.pypass (12/12).avd-pm.kunitconfig): 81/81,apple-avd-vp9included.--strictis clean on both commits.Hardware: J813 (MacBook Air M5, legacy transport) row on this exact head against its base: #3017 (comment). The libvpx VP9 suite (273/31/10) and the codec clips are identical to the base in both FFmpeg builds, with the same AVD kernel lines and 0 DART faults, 0 failed units and 0 AVC denials. None of those vectors reaches the changed code without #2136.