forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

av1422hbd422.report.md19.4 KiBHistoryRawDownload

lane-av1422hbd422 — 12-bit 4:2:2 and superres 4:2:2 against ffmpeg

Verdict: both coverages are CLEAN. No divergence to localise, nothing to fix. Every cell below is byte-exact against ffmpeg 8.1.3, per plane, on every decode-order frame, with the comparator's liveness control passing 324/324 flip arms first.

Target tree main = 228a55f5. Branch lane/av1422hbd422. No decoder source was edited — the probe was patch-run-restore in a scratch worktree that has been removed (§6).

Answers the two coverage questions the risk study opened:

  • R3, "12-bit 4:2:2 is codable and has ZERO census coverage" → codable and clean. Three 12-bit 4:2:2 geometries decode byte-exact, including odd width 321 and odd width+height 323x243, plus a lossless 12-bit 4:2:2 cell.
  • R9, "Superres + 4:2:2 has no cell either" → codable and clean. Three superres 4:2:2 cells (8-bit x2, 12-bit x1) with use_superres=true verified in the frame headers, not merely --superres-mode on the command line.

1. ENCODER PROVENANCE (required reading for anyone re-running this)

what value
aomenc /home/user/.cache/aom-oracle/build/aomenc, sha256 af39b8c272d23fd2efb5e8760ac35d7c3a93aaef224f7e330b6b090c95c4a3ac, libaom src 9bb526a ("oracle snapshot: EC_SYMR names each read by its exact call site")
pixel oracle ffmpeg 8.1.3, -f rawvideo -pix_fmt yuv422p12le / yuv422p, geometry read from ffprobe's coded_width/coded_height (the SEQUENCE HEADER), never from an output byte count
comparator scripts/cmp422-ffmpeg.py (imported as cmpff), which re-derives the decode→display assignment from luma identity and enumerates every solution
our side decode_probe with EC_AV1_FINAL_DUMP, on the patch-run-restore build of §6
source material ffmpeg -f lavfi -i testsrc2=... → raw planar → hand-built y4m (header line + FRAME\n before every frame; libaom y4minput.c requires the six bytes per frame)

1a. THE aomenc SPELLING THAT MATTERS: --profile=2 on 12-bit 4:2:2 FAILS

This is the reproducibility trap in this cell family and it costs an hour if unknown.

$ aomenc --profile=2 --input-bit-depth=12 --bit-depth=12 ... 422p12.y4m
Warning: Assuming --pass=1 implies --passes=1
Failed to set chroma subsampling x: Unspecified internal error      (exit 1)

It is not that aomenc refuses 12-bit 4:2:2 — it is the g_profile == 2 branch at apps/aomenc.c:2269-2282, which for a FILE_TYPE_Y4M 12-bit input reaches for AV1E_SET_CHROMA_SUBSAMPLING_X/Y on an already-initialised encoder and gets an error back. 12-bit 4:2:0 at --profile=2 hits the same call and succeeds, because 420's dst_c_dec_h/v are 2/2 and 422's are 2/1 — the call only misbehaves for the 4:2:2 value.

Measured matrix (same y4m, --limit=2 --pass=1 --cq-level=24 --threads=1 --width=320 --height=242):

command result
--profile=2 --bit-depth=12 --input-bit-depth=12 (4:2:2 y4m) exit 1, Failed to set chroma subsampling x
--profile=2 --bit-depth=12 --input-bit-depth=12 --input-chroma-subsampling-x=1 --input-chroma-subsampling-y=0 exit 1, same
--profile=2 --bit-depth=10 --input-bit-depth=12 exit 1, same
--profile=2 --bit-depth=12 --input-bit-depth=10 exit 1, same
--profile=0 --bit-depth=12 --input-bit-depth=12 exit 0, Warning: automatically updating to profile 2 to match input format.

Every 12-bit cell here was therefore produced with --profile=0, which auto-upgrades to profile 2 on the y4m's own chroma tag. That answers the assignment's explicit question: aomenc does accept 12-bit 4:2:2 and does auto-upgrade the profile; the only thing it will not do is accept --profile=2 spelled on the command line at 12-bit 4:2:2. The resulting bitstream is genuinely profile 2 — ffprobe reports Professional,320,242,yuv422p12le for all of them.

1b. Superres needs --superres-denominator=12 AND a matching width, or it silently does nothing

--superres-mode=1 --superres-denominator=8 encodes cleanly and produces a bitstream in which no frame sets use_superres at all (verified through the frame headers, §4). This is not a 4:2:2 problem — it reproduces at 320x242 with denominators 4 and 8. What makes it bite is the geometry: aomenc floors the coded width to the denominator grid, and a 320-wide frame with --superres-denominator=8 needs 40/8 = 5 coded columns ×8, which the mode-1 selection rejects. --superres-denominator=12 at 320 and 256-wide input does engage it, and matches the shape the repo's own committed superres fixtures have (crates/ec-av1/fixtures/444_lossy_superres_256x128_d12.obu: size=171x128 up=256 superres=true/12). A superres cell that was not checked in the frame headers is not a superres cell.

1c. Odd-width source construction

ffmpeg -pix_fmt yuv422p12le cannot emit an odd width (it silently returns a 320-wide frame for a -size 321x242 request; measured 309760 B, which is 320x242's frame size, not 321x242's 311212 B). The odd-width cells are therefore built by hand: encode a 322-wide (and a 324-wide) 12-bit 4:2:2 y4m, then crop the luma plane to the odd width and the two chroma planes to ceil(w/2) columns per row. Script kept at /home/user/.cache/hbd422/trimodd.py, source y4m sha256 in §2.


2. THE CELLS

aomenc invocation common to all cells below (extras per row are additive):

aomenc --codec=av1 --limit=8 --lag-in-frames=25 --auto-alt-ref=1 --pass=1 --cq-level=24 \
       --threads=4 --kf-min-dist=0 --kf-max-dist=999999 --width=W --height=H \
       --cpu-used=0 --obu -o CELL.obu SRC.y4m
cell geometry / depth extras obu bytes obu sha256 src y4m sha256
s422_320x242_12b 320x242 12-bit --profile=0 --bit-depth=12 --input-bit-depth=12 9589 09a4c533b8f56f89c60fdd5ee1a97dac524534dc64ccd8684d74d8a72e2764c6 41698793bd9f042ef5ce72827b7094a62e2cf964757c4d1ebdf6d75341f1b8b5
s422_321x242_12b 321x242 (odd width) 12-bit same 9566 064a89f99abf3f19a20f3b904aa13dcdab17f7f69c42c68e7b406249a52d92bf 43fbf8df79a4df5db7a9633dab1346abfcf50d05c72339f3cb2f848587c12170
s422_323x243_12b 323x243 (odd width AND odd height) 12-bit same 16633 52b9b72bf6197d954e1c1bc4d0d3cda4a197ddb693599c03faa0cdc1df823106 670f6d45837c5ce6c3a0d50fe3ddc3e96c6ae3d54b70649fcd5ac431f07c2889
s422_320x242_12b_lossless 320x242 12-bit same + --lossless=1 --aq-mode=0 --limit=4 83136 f6d1c9aac24fac11b9e82e5c69bf3c6d4a8a6015e06085861ce94ecbf64d16d1 41698793bd9f042ef5ce72827b7094a62e2cf964757c4d1ebdf6d75341f1b8b5
s422sr_320x180_d12 320x180 8-bit superres d12 --profile=2 --bit-depth=8 --input-bit-depth=8 --cpu-used=4 --limit=6 --superres-mode=1 --superres-denominator=12 --enable-warped-motion=1 --enable-obmc=1 --enable-palette=0 --enable-intrabc=0 10893 48eef43570eee32a334b7230f93c380480f2c9c9d11bfdbd6a49ffc2d0ad4065 443908db3a8f0f63ada7c686b9f4dadc30c7179320eba091937657603b35a33c
s422sr_256x128_d12 256x128 8-bit superres d12 same 11803 047104ccf5dead3b4c9fa24289e2637aa6585b1d3de1cdd6a14792bc82a03197 6ae90321999c3fa94c88c8015af419142f303003feaea13da7bd70e875098d1a
s422sr_256x128_d12_12b 256x128 12-bit superres d12 --profile=0 --bit-depth=12 --input-bit-depth=12 --cpu-used=4 --limit=6 --superres-mode=1 --superres-denominator=12 --enable-warped-motion=1 --enable-obmc=1 --enable-palette=0 --enable-intrabc=0 10736 dad2c2fbb23d51420d4bbd5105d987e6d8df7eb997c4c63404d5de9523ff065f a6e776b3a652e73890535126bf84bd323b71796682c8125474e34d0f55fb68e0

Controls, from the existing 51-cell corpus (unchanged bytes, so the run also re-confirms the corpus verdict on this build):

cell obu sha256
s420_320x242 (4:2:0 8-bit) 5832ecded9bc128f41b5a0ff16baa2283d4c2528b9bd301b4bfb706aafd7ea64
s422_320x242 (4:2:2 8-bit) 909e58db18fd4b7590501e2cecfbc090cde49eb26c9a42e15b1ef1fc265843d8

Cells built and measured but not part of the verdict, recorded because the negative result is the useful part: s422sr_320x242 and s422sr_322x246 (sha 8bf07a4a…, 8d5d9a95…) at --superres-denominator=8 — both byte-exact, both with use_superres=false on every frame, i.e. plain 4:2:2 cells wearing a superres command line. §1b.


3. LIVENESS CONTROL (run FIRST, before any exactness verdict)

scripts/flipctl-422.py maps once from the untouched streams, then flips one sample per arm per plane — three arms per plane (first / middle / last), 36 arms per cell — in both directions (oracle arm, ours arm) with the mapping pinned, over every decode→display solution.

ctl_s420_320x242_8b:   baseline [0, 0, 0]  17 decode / 16 shown, hidden [1], 1 mapping solution(s), 36 arms
ctl_s422_320x242_8b:   baseline [0, 0, 0]  17 decode / 16 shown, hidden [1], 1 mapping solution(s), 36 arms
s422_320x242_12b:      baseline [0, 0, 0]   9 decode /  8 shown, hidden [1], 1 mapping solution(s), 36 arms
s422_321x242_12b:      baseline [0, 0, 0]   9 decode /  8 shown, hidden [1], 1 mapping solution(s), 36 arms
s422_323x243_12b:      baseline [0, 0, 0]   9 decode /  8 shown, hidden [1], 1 mapping solution(s), 36 arms
s422sr_320x180_d12:    baseline [0, 0, 0]   7 decode /  6 shown, hidden [1], 1 mapping solution(s), 36 arms
s422sr_256x128_d12:    baseline [0, 0, 0]   7 decode /  6 shown, hidden [1], 1 mapping solution(s), 36 arms
s422sr_256x128_d12_12b:baseline [0, 0, 0]   7 decode /  6 shown, hidden [1], 1 mapping solution(s), 36 arms
   288 PASS, 0 FAIL of 288 flip arms

s422_320x242_12b_lossless: baseline [0, 0, 0]  4 decode / 4 shown, hidden [], 1 mapping solution(s), 36 arms
    36 PASS, 0 FAIL of 36 flip arms

324 arms, 324 PASS, 0 FAIL. Each flipped sample moved its own plane's wrong-count by exactly +1 and every other plane by exactly 0. A 0/0/0 surviving that is a comparator that is not reading the oracle; it does not, here.


4. PER-PLANE, PER-FRAME RESULTS

Columns are wrong sample counts (Y, U, V), decode order. None = hidden alt-ref/forward frame (never shown, therefore never counted — the hidden=[1] each stream's mapping reports). Display-order rows are given too, because the mapping is what makes index-by-index comparison legitimate; every cell had exactly 1 mapping solution, so there is no ambiguity to choose between.

4a. 12-bit 4:2:2

cell pix_fmt decode frames (Y,U,V) display frames (Y,U,V) total
s422_320x242_12b yuv422p12le [0,0,0] None [0,0,0] [0,0,0] [0,0,0] [0,0,0] [0,0,0] [0,0,0] [0,0,0] 8 × [0,0,0] Y=0 U=0 V=0
s422_321x242_12b yuv422p12le [0,0,0] None [0,0,0] [0,0,0] [0,0,0] [0,0,0] [0,0,0] [0,0,0] [0,0,0] 8 × [0,0,0] Y=0 U=0 V=0
s422_323x243_12b yuv422p12le [0,0,0] None [0,0,0] [0,0,0] [0,0,0] [0,0,0] [0,0,0] [0,0,0] [0,0,0] 8 × [0,0,0] Y=0 U=0 V=0
s422_320x242_12b_lossless yuv422p12le [0,0,0] [0,0,0] [0,0,0] [0,0,0] 4 × [0,0,0] Y=0 U=0 V=0
ctl_s420_320x242_8b yuv420p 16 × [0,0,0] + 1 None 16 × [0,0,0] Y=0 U=0 V=0
ctl_s422_320x242_8b yuv422p 16 × [0,0,0] + 1 None 16 × [0,0,0] Y=0 U=0 V=0

No first divergent sample exists for any of these; the comparator's first is none and its per-plane bounding box is [None, None, None, None] for all three planes.

4b. Superres 4:2:2

cell pix_fmt decode frames (Y,U,V) display frames (Y,U,V) total
s422sr_320x180_d12 yuv422p [0,0,0] None [0,0,0] [0,0,0] [0,0,0] [0,0,0] [0,0,0] 6 × [0,0,0] Y=0 U=0 V=0
s422sr_256x128_d12 yuv422p [0,0,0] None [0,0,0] [0,0,0] [0,0,0] [0,0,0] [0,0,0] 6 × [0,0,0] Y=0 U=0 V=0
s422sr_256x128_d12_12b yuv422p12le [0,0,0] None [0,0,0] [0,0,0] [0,0,0] [0,0,0] [0,0,0] 6 × [0,0,0] Y=0 U=0 V=0

4c. Superres is genuinely engaged (frame headers, EC_PROBE_HDR=1)

A green pixel verdict on a bitstream that never set use_superres would prove nothing about the superres upscale path. Per-cell distinct frame-header shapes:

cell frame_width x frame_height upscaled_width use_superres / superres_denom
s422sr_320x180_d12 213x180 320 true / 12 (plus 320x180 up=320 superres=false on the key/alt-ref frames)
s422sr_256x128_d12 171x128 256 true / 12 (plus 256x128 up=256 superres=false)
s422sr_256x128_d12_12b 171x128 256 true / 12 (plus 256x128 up=256 superres=false)
s422sr_320x242 (rejected) 320x242 320 false / 8 — no superres frame at all
s422sr_322x246 (rejected) 322x246 322 false / 8 — no superres frame at all
reference: committed 444_lossy_superres_256x128_d12.obu 171x128 256 true / 12

Note the chroma geometry under superres: the frame header's coded luma is 171x128 and the chroma planes are per-axis (round_ss(171,1) x 128), then upscaled to the 256-wide render size. All of it byte-exact.

4d. Reachability counters (non-vacuity: the arms really ran)

decode_probe's census on the new cells, so a reader can tell an exact result that exercised something from one that exercised nothing:

counter s422_320x242_12b s422_321x242_12b s422_323x243_12b s422sr_320x180_d12 s422sr_256x128_d12 s422sr_256x128_d12_12b
cfl_ac 422 arm 146 156 24 214 206 186
cfl_ac 444 / 420 arms 0 / 0 0 / 0 0 / 0 0 / 0 0 / 0 0 / 0
chroma422_square 52 52 128 68 5 8
chroma422_rect 276 270 824 540 374 322
chroma422_sub8 92 118 405 289 256 239
intra_in_inter_palette y/uv 8 / 3 11 / 3 43 / 18 0 / 0 0 / 0 0 / 0
intrabc_hits 15 23 14 0 0 0
rect_inter tu / txsplit / obmc 21 / 2 / 36 12 / 2 / 43 83 / 5 / 73 45 / 0 / 0 27 / 0 / 0 23 / 0 / 0
sub8_inter_rect horz8x4 91 93 355 65 73 50
predict_scaled 0 0 0 4066 3442 3070
predict_scaled sub8 / leaf8 0 / 0 0 / 0 0 307 / 158 320 / 159 227 / 133

Filter coverage from the same frame headers (per-cell distinct (cdef_bits, lr)): 323x243 reaches cdef_bits=1 and cdef_bits=2, lr=[Sgrproj, Sgrproj, Sgrproj] and lr=[None, Switchable, Switchable]; the 12-bit superres cell reaches cdef_bits=2 and lr=[Wiener, None, None]. So 12-bit 4:2:2 is not exact only on a filter-free stretch of pixels, and the superres cells exercise the scaled-reference prediction path thousands of times per stream (predict_scaled > 3000, including 227–320 sub-8x8 inter blocks under a scaled reference and 133–159 8x8 partition leaves under one — the three "scaled" refusal strings in refusal_inventory.rs, none of which fired).


5. WHAT THIS DOES AND DOES NOT CLOSE

Closes: R3 and R9 as coverage gaps. The risk study's claim was that no 12-bit 4:2:2 cell and no superres 4:2:2 cell exists anywhere, so neither format had ever been decoded here. Both are now measured byte-exact against ffmpeg.

Does not close, and is not touched by this lane:

  1. R8's "no 4:2:2 unit census". Still true and still a prerequisite for the lift's non-vacuity gate: set_census_444 arms the unit counters at ss (0,0) only, so census_444_units() reads [0,0,0] on every cell in this report. The chroma422_* counters above are the only 4:2:2 arm-reachability signal the tree currently has, and they cover a subset of arms. Anyone writing the post-lift exactness gate should gate on one of the chroma422_* counters (they are > 0 on every cell here) rather than on the 444 census.
  2. R2, film grain. This lane produced no --film-grain-test cell at all, so film_grain.rs's 4:2:0-only geometry is unmeasured here — that arm belongs to lane/av1422grain. Nothing in this report says anything about it.
  3. The seven known-diverging 8-bit cells (R4). Untouched; they are not in either coverage question and the corpus controls re-confirm s420_320x242 and s422_320x242 are still byte-exact on this build.
  4. refusal_inventory.rs:2129-2148 (R7) and the residual (0,1) assertion (R11). Source-level, not measurement-level; untouched.

No divergence was found, therefore no arm was localised and nothing was fixed. The reserved group-tail chroma SKIP arm, film_grain.rs, and decode_rect4_16_intrabc were not edited.


6. PROBE HYGIENE

The 4:2:2 guard at crates/ec-av1/src/stream.rs:1803 was neutralised only in a throwaway worktree:

git worktree add -f --detach /home/user/.cache/wt/probe422hbd main
# stream.rs:1802 -> "// TEMP-PROBE-BYPASS: EC_AV1_ALLOW_422_PROBE -- patch, run, restore."
# stream.rs:1803 -> "if false && seq.subsampling_x != seq.subsampling_y {"
EC_NOMEMGUARD=1 CARGO_TARGET_DIR=/home/user/.cache/tgt/av1422hbd422 \
  cargo build -p ec-av1 --example decode_probe          # Finished in 8.79s
# ...all measurements above...
cd /home/user/.cache/wt/probe422hbd && git checkout -- crates/ec-av1/src/stream.rs
git worktree remove --force /home/user/.cache/wt/probe422hbd

Post-restore state, verified:

  • git status --porcelain in the probe worktree: empty.
  • grep -c TEMP-PROBE-BYPASS crates/ec-av1/src/stream.rs: 0.
  • grep -n 'if false &&' crates/ec-av1/src/stream.rs: no matches.
  • The primary checkout /home/user/Documents/Code/Rust/edith_codecs: git status --porcelain empty, grep -c TEMP-PROBE-BYPASS 0.
  • git worktree list no longer contains probe422hbd.

The bypassed binary at /home/user/.cache/tgt/av1422hbd422 was built into a target directory only this lane uses, deliberately not the one scripts/run422-ffmpeg.py hardcodes (/home/user/.cache/tgt/av1422seed/debug/examples/decode_probe), so no concurrent lane can be served a 4:2:2-decoding binary by that shared driver. The stale- binary trap in §4 of the bypass skill does not apply to anyone else here.

Artifacts (not committed): cells, y4m sources, encoder stderr, work/<cell>/ours.f*, out_final.json, out_extra.json, cells_final.json, drv.py — all under /home/user/.cache/hbd422/.


7. ONE-LINE VERDICTS

  • 12-bit 4:2:2 — CLEAN. Byte-exact vs ffmpeg yuv422p12le at 320x242, 321x242 (odd width), 323x243 (odd width and height) and 320x242 lossless; Y=U=V=0 on every frame; 324/324 liveness arms pass. R3's "zero coverage" is now measured coverage. No defect to attribute.
  • Superres 4:2:2 — CLEAN. Byte-exact with use_superres=true, superres_denom=12 confirmed in the frame headers, at 320x180 and 256x128 in 8-bit and 256x128 in 12-bit; predict_scaled 3070–4066 per stream including sub-8x8 inter and 8x8 leaves under a scaled reference, so the upscale path is genuinely exercised. R9 closed. No defect to attribute.
  • aomenc and 12-bit 4:2:2 — one spelling caveat, not a capability gap: --profile=0 works (auto-upgrades to profile 2); --profile=2 spelled explicitly fails with Failed to set chroma subsampling x at apps/aomenc.c:2269-2282. Use --profile=0.
  • aomenc and superres — one silent-no-op caveat: --superres-mode=1 --superres-denominator=8 at 320-wide input encodes cleanly with use_superres=false on every frame. Always read the flag back out of the frame headers before believing a superres cell.
  • Nothing was fixed, because nothing diverged. The decoder source is untouched and the guard stands; this report adds coverage, not a fix.