edith_codecs
Clone
0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits
lane av1v12: 12-bit 4:4:4 V plane off by one (D2 of av1chroma)
Base: main 2ccef013. Worktree ~/.cache/wt/av1v12, branch lane/av1v12.
Cause
The rect DC predictor (intra.rs, dc) divided the edge sum for 1:2 and 1:4
blocks with libaom's multiply-shift (0x5556 / 0x3334, shift 16), not the
exact integer division of spec 7.11.2.5 (avg = (sum + ((w+h)>>1)) / (w+h)).
The approximation is exact only while the edge sum is below 2^16. For 1:4
blocks (4x16, 16x4, 8x32, 16x64) it is off by one from sum 65526. 8- and 10-bit
edges never reach that sum, so only 12-bit streams hit it. A 12-bit 4:4:4 V
block with a 4x16 DC prediction (sum 66290) got 3315 where the spec and
libdav1d give 3314. That is the 274-sample +1 box at x=144..155, y=160..183 in
frame 0. Luma and U hit the same formula, but their sums stayed clear of the
boundary, so only V showed it.
Fix: the rect case now uses the exact division, the same as the square case.
dc_rect_multiplier is removed. 8- and 10-bit results are unchanged, because
the approximation is exact below the boundary.
Evidence
- Repro:
p444.obu(~/…/scratchpad/av1c/p444/), CDEF and LR off, decoded bydump_yuvon host a: frame 0 V has 275 diffs, all +1, bbox x 144..155, y 160..183. Y and U exact. - Trace of the first bad block (4x16 at x=144, y=160, DC): ours predicts 3315 over 64 pixels. Its edge sum (pre-filter, from our own decoder) is in the range the multiply-shift and exact division disagree on. After the fix the frame is byte-exact against libdav1d, which confirms the exact division is the one the reference uses.
- Arithmetic check (python): over all sums up to (w+h)*4095, the multiply-shift first differs from exact division at sum 65526 for 4x16, 16x4 (w+h=20); 131052 for 8x32, 32x8 (w+h=40); 262104 for 16x64, 64x16 (w+h=80). 1:2 shapes never differ in that range.
Verify
Commands are run on server hosts through scripts/remote-run.sh av1v12 --host a.
| check | result |
|---|---|
p444.obu 12-bit 4:4:4, CDEF and LR off, 8 frames, vs ffmpeg -c:v libdav1d -pix_fmt yuv444p12le |
before: frame 0 V 275 diffs. after: 8/8 frames byte-exact |
aom_conformance (EC_AV1_AOM_DIR=~/fixtures/av1-aom, host a) |
aom_vectors_match_per_frame_md5 ok (18.6 s) |
12-bit 4:2:0, 4:2:2, 4:4:4 generated with -aom-params enable-chroma-deltaq=1:deltaq-mode=1 (libaom, 6 frames, 352x288, CDEF/LR on) |
all three byte-exact, 6/6 frames each. Header shows delta_q_u_dc=2, delta_q_u_ac=2, delta_q_v_dc=2, delta_q_v_ac=2, so the chroma delta path is exercised |
new unit test intra::tests::rect_dc_divides_exactly_for_12bit_edge_sums |
asserts 3276 for a 4x16 block with edge sum 65526; the old multiply-shift gives 3277 for the same input, so the test fails on the old code (checked by arithmetic, not by a run on the old tree) |
full cargo test --release -p ec-av1 |
re-run by the coordinator on merged main |
cargo clippy -p ec-av1 --all-targets -- -D warnings |
re-run by the coordinator on merged main |
Not done
- Separate V deltas (
separate_uv_delta_q=1withdelta_q_v != delta_q_u) were not forced. libaom'senable-chroma-deltaqgavev == u, so the V-specific delta path is not covered by these clips. TheQuantDeltasplumbing is unchanged. DONE.mdstill lists profiles 1/2 as Frozen (lines 77 and 113). Owner to update.- D1 (4:2:2 right edge) and D3 (4:2:2 LR refusal) are not touched.