forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-kf1200' (d44afba): second 10-bit key-frame fixture for the skipped-leaf transform grid

Browse files at this commit

edebe8890fee2625c3bd1ec47d7f2b59d8ff0cf7Ahmet Kaan GümüşParent: b4cddf34ac57e0
Same decode_leaf8 root cause as lane-kf900 (kept once, kf900's comment); this lane
contributes an independent 10-bit key-frame fixture (reelb_ss600_key_frame.obu, a partial
8-px bottom superblock row) that pins it pixel-exact including chroma, plus the
frame-edge partition-bit gate and the trace_edge rung.

Gates: ss600 (1), frame_edge_partition_bit (1), skipped_8x8_intra_leaves (1),
refusal_inventory (3), gate_coverage (9), base_ctx_rect_offsets (1) -- all pass.
crates/ec-av1/fixtures/reelb_ss600_key_frame.obuadded+0 -0

Binary file changed

crates/ec-av1/src/decode.rsmodified+13 -1
@@ -2762,6 +2762,12 @@ const MAX_BR_LEVEL: i32 = NUM_BASE_LEVELS + COEFF_BASE_RANGE;
27622762 const VERT_ALIKE: [usize; 6] = [2, PARTITION_SPLIT, 4, 6, 7, 9];
27632763 const HORZ_ALIKE: [usize; 6] = [1, PARTITION_SPLIT, 4, 5, 6, 8];
27642764
2765+fn trace_edge(mi_r: usize, mi_c: usize, bsize: u32, ctx: usize, rng: u32) {
2766+ if std::env::var_os("EC_AV1_TRACE").is_some() {
2767+ eprintln!("OUR_PART mi_row={mi_r} mi_col={mi_c} bsize={bsize} ctx={ctx} rng={rng}");
2768+ }
2769+}
2770+
27652771 fn element_prob(cdf: &[u16], element: usize) -> u16 {
27662772 cdf[element] - if element > 0 { cdf[element - 1] } else { 0 }
27672773 }
@@ -13832,11 +13838,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1383213838 // the first block of that row.
1383313839 match (has_cols, has_rows) {
1383413840 (true, false) => {
13841+ trace_edge((sb_r * SB_MI) as usize, (sb_c * SB_MI) as usize, 12, ctx, dec.debug_state().0 as u32);
1383513842 let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE));
1383613843 bump_edge_part(b.min(1) as usize);
1383713844 if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }
1383813845 }
1383913846 (false, true) => {
13847+ trace_edge((sb_r * SB_MI) as usize, (sb_c * SB_MI) as usize, 12, ctx, dec.debug_state().0 as u32);
1384013848 let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE));
1384113849 bump_edge_part(b.min(1) as usize);
1384213850 if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT }
@@ -13902,6 +13910,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1390213910 // superblock level above).
1390313911 match (has_cols32, has_rows32) {
1390413912 (true, false) => {
13913+ trace_edge((r32 * BLOCK_MI) as usize, (c32 * BLOCK_MI) as usize, 9, ctx32, dec.debug_state().0 as u32);
1390513914 let b = dec.symbol_fixed(&gather(
1390613915 &cdfs.partition_w32[ctx32],
1390713916 VERT_ALIKE,
@@ -13910,6 +13919,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1391013919 if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ }
1391113920 }
1391213921 (false, true) => {
13922+ trace_edge((r32 * BLOCK_MI) as usize, (c32 * BLOCK_MI) as usize, 9, ctx32, dec.debug_state().0 as u32);
1391313923 let b = dec.symbol_fixed(&gather(
1391413924 &cdfs.partition_w32[ctx32],
1391513925 HORZ_ALIKE,
@@ -14388,6 +14398,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1438814398 // This path can only walk the four SPLIT
1438914399 // leaves, so a 0 refuses by name instead
1439014400 // of desyncing.
14401+ trace_edge(sr * SUB_MI as usize, sc * SUB_MI as usize, 6, ctx16, dec.debug_state().0 as u32);
1439114402 let edge_split = if has_cols16 {
1439214403 dec.symbol_fixed(&gather(
1439314404 &cdfs.partition_w16[ctx16],
@@ -14468,10 +14479,11 @@ pub(crate) fn decode_key_frame_tile_with_cdfs(
1446814479 }
1446914480 }
1447014481 let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8);
14482+ let pre8 = dec.debug_state().0;
1447114483 let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]);
1447214484 if std::env::var_os("EC_AV1_TRACE").is_some() {
1447314485 eprintln!(
14474- "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8}"
14486+ "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8} pre_rng={pre8}"
1447514487 );
1447614488 }
1447714489 let leaf_mode = if part8 == PARTITION_NONE {
crates/ec-av1/src/stream.rsmodified+76 -3
@@ -3667,6 +3667,50 @@ mod tests {
36673667 assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg");
36683668 }
36693669
3670+ /// lane-kf1200 r3: the same film's `-ss 600` key frame (3840x1608, one
3671+ /// 8-px partial bottom superblock row), pinned because no aomenc recipe
3672+ /// reaches its shape -- a SKIPPED 8x8 intra leaf whose `tx_depth` resolved
3673+ /// to TX_4X4. (80 recipes swept this round: 4 frame shapes x 2 sources x
3674+ /// cq 32..63 x cpu-used 0/3 x 8/10-bit, all with
3675+ /// `--enable-tx-size-search=1 --enable-filter-intra=1`; every one came
3676+ /// back with `skip_split_tx_hits == 0`, `lanes/kf1200-r3.report.md`.)
3677+ /// An intra block reads `tx_depth` whether or not it is skipped, so the
3678+ /// leaf must record its resolved 4 -- not its 8x8 side -- in the txfm
3679+ /// context; recording 8 gave the NEXT block's `tx_depth` symbol the wrong
3680+ /// `tx_size_cdf` row (ctx 2 where libaom reads 1) and desynced the
3681+ /// entropy stream at mi (400,46). HARD-asserts `skip_split_tx_hits` moved.
3682+ #[test]
3683+ fn the_reelb_ss600_key_frame_skipped_split_tx_decodes_pixel_exact() {
3684+ const NAME: &str = "the_reelb_ss600_key_frame_skipped_split_tx_decodes_pixel_exact";
3685+ if !have_ffmpeg() {
3686+ eprintln!("SKIP {NAME}: no ffmpeg");
3687+ return;
3688+ }
3689+ let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
3690+ .join("fixtures/reelb_ss600_key_frame.obu");
3691+ let stream = std::fs::read(&path)
3692+ .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display()));
3693+ let (width, height) = (3840usize, 1608usize);
3694+ crate::decode::reset_skip_split_tx_hits();
3695+ let frames = match decode_stream(&stream) {
3696+ Ok(frames) => frames,
3697+ Err(e) => panic!("{NAME}: decode_stream refused: {e}"),
3698+ };
3699+ let skipped_split_tx = crate::decode::skip_split_tx_hits();
3700+ assert!(
3701+ skipped_split_tx > 0,
3702+ "{NAME}: zero skipped 8x8 leaves with a split transform -- the fixture no longer \
3703+ exercises the arm this test exists for"
3704+ );
3705+ assert_eq!(frames.len(), 1, "{NAME}: one key frame");
3706+ assert_eq!((frames[0].width, frames[0].height), (width, height));
3707+ let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, 1);
3708+ assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg");
3709+ assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg");
3710+ assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg");
3711+ eprintln!("{NAME}: {skipped_split_tx} skipped 8x8 TX_4X4 leaves, frame pixel-exact");
3712+ }
3713+
36703714 /// lane-hbd10 r1: a real `aomenc --bit-depth=10 --superres-mode=1
36713715 /// --superres-denominator=12` key frame, decoded pixel-exact against
36723716 /// ffmpeg's own 10-bit decode. Proves `superres::upscale_row`'s
@@ -24392,16 +24436,29 @@ mod tests {
2439224436 let mut compared = 0usize;
2439324437 let mut edge_horz_total = 0usize;
2439424438 let mut edge_sub_total = 0usize;
24439+ let mut skip_split_tx_total = 0usize;
2439524440 // The last two shapes are the ledger-measured 64-level pair: on a
2439624441 // flat band (192x80 / 80x192) real aomenc answers the bottom-edge
2439724442 // superblock with the 64-level HORZ/VERT, which the 136 shapes above
2439824443 // never produce (their SBs always split down to the 32/16 levels).
24444+ // lane-kf1200 r3: the 2-/4-/6-mi partial bottom rows (h mod 64 == 8,
24445+ // 16, 24) with partial RIGHT columns as well (w mod 64 == 8), the
24446+ // geometry of the film key frames this lane chases.
2439924447 for (width, height, flat) in [
2440024448 (192usize, 136usize, false),
2440124449 (136usize, 192usize, false),
2440224450 (192usize, 80usize, true),
2440324451 (80usize, 192usize, true),
24452+ (200usize, 72usize, false),
24453+ (136usize, 88usize, false),
24454+ (264usize, 104usize, false),
2440424455 ] {
24456+ // lane-kf1200 r3 (class `tool-disabled-in-every-gate`): the whole
24457+ // recipe ran with `--enable-tx-size-search=0`, so no block ever
24458+ // carried a nonzero `tx_depth` and the SKIPPED 8x8 leaf that
24459+ // resolves to TX_4X4 -- whose txfm context this round fixed --
24460+ // was unreachable by construction. The second arm turns it on.
24461+ for tx_search in [0usize, 1] {
2440524462 for depth in [8usize, 10] {
2440624463 let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" };
2440724464 let y4m = Command::new("ffmpeg")
@@ -24432,7 +24489,8 @@ mod tests {
2443224489 "--cpu-used=3", "--threads=1", "--row-mt=0", "--sb-size=64",
2443324490 "--kf-max-dist=0", "--enable-rect-partitions=1",
2443424491 "--enable-ab-partitions=0", "--enable-1to4-partitions=0",
24435- "--enable-tx-size-search=0", "--reduced-tx-type-set=1",
24492+ &format!("--enable-tx-size-search={tx_search}"),
24493+ "--reduced-tx-type-set=1",
2443624494 "--min-partition-size=8", "--max-partition-size=64",
2443724495 &format!("--input-bit-depth={depth}"),
2443824496 &format!("--bit-depth={depth}"),
@@ -24464,6 +24522,7 @@ mod tests {
2446424522 "{NAME}: aomenc output is not reproducible ({width}x{height}, depth={depth})"
2446524523 );
2446624524 crate::decode::reset_edge_part_hits();
24525+ crate::decode::reset_skip_split_tx_hits();
2446724526 let frames = match decode_stream(&stream) {
2446824527 Ok(frames) => frames,
2446924528 Err(e) => {
@@ -24479,6 +24538,7 @@ mod tests {
2447924538 }
2448024539 };
2448124540 let hits = crate::decode::edge_part_hits();
24541+ let skip_split_tx = crate::decode::skip_split_tx_hits();
2448224542 let ffmpeg_frames = if depth == 10 {
2448324543 ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len())
2448424544 } else {
@@ -24504,12 +24564,15 @@ mod tests {
2450424564 compared += 1;
2450524565 edge_horz_total += hits[0];
2450624566 edge_sub_total += hits[2];
24567+ skip_split_tx_total += skip_split_tx;
2450724568 eprintln!(
24508- "{NAME}: pixel-exact {width}x{height} at {depth}-bit, edge bits \
24509- 64-level horz/vert={} split={} sub-level horz/vert={} split={}",
24569+ "{NAME}: pixel-exact {width}x{height} at {depth}-bit tx_search={tx_search}, \
24570+ edge bits 64-level horz/vert={} split={} sub-level horz/vert={} split={}, \
24571+ skipped 8x8 leaves with TX_4X4 {skip_split_tx}",
2451024572 hits[0], hits[1], hits[2], hits[3]
2451124573 );
2451224574 }
24575+ }
2451324576 }
2451424577 assert!(
2451524578 compared > 0,
@@ -24524,5 +24587,15 @@ mod tests {
2452424587 edge_sub_total > 0,
2452524588 "{NAME}: no 32/16-level frame-edge bit was ever answered HORZ/VERT"
2452624589 );
24590+ // lane-kf1200 r3: the `--enable-tx-size-search=1` half of the window
24591+ // exists so a partial-row block can carry a nonzero `tx_depth` at all
24592+ // (the whole recipe ran with it OFF before -- class
24593+ // `tool-disabled-in-every-gate`). The SKIPPED 8x8 leaf that resolves
24594+ // to TX_4X4 -- whose txfm context this round fixed -- is NOT reachable
24595+ // from any synthetic source measured here (80 recipes, all zero), so
24596+ // that arm is asserted by the pinned film fixture
24597+ // `the_reelb_ss600_key_frame_skipped_split_tx_decodes_pixel_exact`
24598+ // instead; this counter is reported, not gated.
24599+ eprintln!("{NAME}: {skip_split_tx_total} skipped 8x8 TX_4X4 leaves across compared attempts");
2452724600 }
2452824601 }
lanes/kf1200-r3.report.mdadded+130 -0
@@ -0,0 +1,130 @@
1+# lane-kf1200 r3 report — the partial-bottom-row desync, root cause found and fixed
2+
3+Tip `9d18288` on `lane-kf1200` (parent `bee8ec0`, main merged at `d85d7d2`).
4+
5+## Root cause (ONE symbol, not the partition path the charter suspected)
6+
7+The charter's premise — "our 32-level gathered `split_or_horz` CDF/ctx differs" —
8+is REFUTED by measurement. A cross-decoder range ladder over the whole partial
9+bottom superblock row shows every partition symbol of mi_row=400 in sync,
10+including the gathered ones (our `ctx` values equal libaom's
11+`partition_plane_context` minus its `bsl * PARTITION_PLOFFSET` offset, and every
12+`rng` matches):
13+
14+ aomdec EC_PART mi_row=400 mi_col=44 bsize=6 ctx=6 rng=55482 value=3 (SPLIT)
15+ ours OUR_PART mi_row=400 mi_col=44 bsize=6 ctx=2 rng=55482
16+ aomdec EC_PART mi_row=400 mi_col=44 bsize=3 ctx=0 rng=52288
17+ ours TRACE partition_w8 mi=(400,44) ctx=0 value=0 pre_rng=52288
18+ aomdec EC_PART mi_row=400 mi_col=46 bsize=3 ctx=0 rng=53128
19+ ours TRACE partition_w8 mi=(400,46) ctx=0 value=0 pre_rng=53128
20+
21+The first differing element is the `tx_depth` symbol of the SECOND 8x8 leaf:
22+
23+ aomdec EC_ISTEP mi_row=400 mi_col=46 name=tx_depth val=0 ctx=1 rng=42998
24+ ours EC_ISTEP mi_row=400 mi_col=46 name=tx_depth val=0 ctx=2 rng=54191
25+
26+Same decoded value, different CDF row, therefore a different interval narrowing:
27+the entropy stream is desynced from there on, and the rest of the row (and the
28+1595..1607 deblock spill) decodes as garbage. What the charter saw as "aomdec
29+reads a 16x8 where we read 32x16" was our *already desynced* reader at
30+mi (400,48), one block later.
31+
32+`ctx` comes from libaom `get_tx_size_context`: `above_txfm_context[0] >=
33+max_tx_wide` + `left_txfm_context[0] >= max_tx_high`. The left neighbour of
34+(400,46) is the 8x8 leaf at (400,44), which is `skip=1` and whose `tx_depth`
35+resolved to TX_4X4 — so libaom's `set_txfm_ctxs` published 4 and its left term
36+is 0. Our `decode_leaf8` skip branch fell through to a hardcoded
37+`fill_lf_grid(leaf_mi, 2, 8, 0)`, publishing 8, so our left term read 1.
38+
39+An intra block reads `tx_depth` whether or not it is skipped (libaom
40+`read_intra_frame_mode_info` calls `read_tx_size` above the skip branch); only a
41+skipped *inter* block records its block size instead of its transform.
42+
43+## Change
44+
45+- `crates/ec-av1/src/decode.rs:10330` — `fill_lf_grid(leaf_mi, 2, resolved as u8, 0)`
46+ (was the literal `8`). The non-skip TX_4X4 branch already returned early with 4;
47+ only the skip path was wrong. One line.
48+- `crates/ec-av1/src/decode.rs:2652` `trace_edge()` + 5 call sites — `OUR_PART
49+ mi_row/mi_col/bsize/ctx/rng` under `EC_AV1_TRACE` for the three gathered
50+ frame-edge partition reads (there was no emitter for them, only for the full
51+ alphabet reads), plus `pre_rng` on the 8x8 partition trace. Instrument only.
52+- `crates/ec-av1/examples/decode_probe.rs:34` — prints `skip_split_tx`.
53+
54+Sibling sweep for the same shape (a skip branch publishing the block side where
55+the resolved transform belongs): `fill_lf_grid` has 6 call sites.
56+`decode_block` (9872) already passes `logical_tx`; the inter 8x8 leaf (20449)
57+passes `if split8 {4} else {8}`; the inter-leaf skip early-return (19644) passes
58+8, which is CORRECT — a skipped inter block records its block size. The 4x4 leaf
59+(10541) passes 4. Only 10330 was wrong.
60+
61+## Gates
62+
63+1. NEW `the_reelb_ss600_key_frame_skipped_split_tx_decodes_pixel_exact`
64+ (`crates/ec-av1/src/stream.rs`), pinning
65+ `crates/ec-av1/fixtures/reelb_ss600_key_frame.obu` (94717 B, sha256
66+ `36de46676ed7de7049d4dabe8571d8cd31c8a1f53d72011c0ee532a7c6725cd6`, hashed
67+ twice, `git add -f`, present in `git ls-files`): one 3840x1608 yuv420p10le key
68+ frame. HARD-asserts `skip_split_tx_hits > 0` (24 in this frame) then Y/U/V vs
69+ ffmpeg's 10-bit decode. Fixture, not aomenc, because the shape is not
70+ synthetically reachable: 80 recipes this round (4 frame shapes x 2 lavfi
71+ sources x cq 32/35/40/45/48/50/55/58/63 x cpu-used 0/3 x 8/10-bit, all with
72+ `--enable-tx-size-search=1 --enable-filter-intra=1 --min-partition-size=8`)
73+ returned `skip_split_tx_hits == 0` every time. Widths with a partial right
74+ column (200, 264, 136, 776, 1288) additionally hit the existing named refusal
75+ "a 16x16 block whose true edge cuts through both axes", so the charter's
76+ 200x72 / 72x200 / 136x104 / 264x136 shapes cannot be compared at all today.
77+2. WIDENED `a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact`:
78+ three more partial-bottom-row shapes (200x72, 136x88, 264x104 — 2/4/6 mi rows)
79+ and an `--enable-tx-size-search=1` arm. The whole recipe ran with
80+ `--enable-tx-size-search=0`, so no block in it could carry a nonzero
81+ `tx_depth` at all (class `tool-disabled-in-every-gate`) — that is why 8 green
82+ arms never saw this defect. 18 arms compared pixel-exact, 10 named refusals
83+ (all the double-axis 16x16 one), `edge_horz_total`/`edge_sub_total` still
84+ hard-asserted; the `skip_split_tx` counter is reported, not gated, there.
85+
86+## 24-key-frame census (1 frame each, ours vs ffmpeg 10-bit, differing BYTES)
87+
88+r2: 11/24 exact, four multi-million-byte rows. r3: 17/24 exact, **luma exact on
89+all 24**, every remaining row chroma-only.
90+
91+| -ss | Y | U | V | r2 total |
92+|---|---|---|---|---|
93+| 0,300,600,1200,1500,1800,2400,3000,3300,3600,4200,4500,5100,5400,5700,6900 | 0 | 0 | 0 | 4 of these were 16.6M/48771/42343/39971/16375 |
94+| 900 | 0 | 40 | 50980 | 14057191 |
95+| 2100 | 0 | 1289 | 1067 | 15148697 |
96+| 2700 | 0 | 231 | 739 | 7726168 |
97+| 3900 | 0 | 4 | 4 | 7554023 |
98+| 4800 | 0 | 29 | 5 | 34 |
99+| 6000 | 0 | 210 | 0 | 15449720 |
100+| 6300 | 0 | 4 | 0 | 15410664 |
101+| 6600 | 0 | 124 | 124 | 15180826 |
102+
103+The four charter segments (600/2400/3300/5700) are all 0/0/0.
104+
105+## EVIDENCE
106+
107+EVIDENCE: /home/user/.cache/kf1200-tmp/a600s.part + o600s.trace | aomdec EC_TRACE=1 EC_TRACE_MODE_STEP=1 vs our EC_AV1_TRACE=1 EC_TRACE_MODE_STEP=1 on the pinned 1-frame stream | first differing element mi(400,46) tx_depth ctx 2 vs 1, rng 54191 vs 42998; after the fix ours reads ctx=1 rng=42998
108+EVIDENCE: /home/user/.cache/kf1200-tmp/ours600.yuv vs ref600.yuv | EC_PROBE_OUT16 decode vs `ffmpeg -pix_fmt yuv420p10le` | cmp -l = 0 differing bytes of 18524160 (was 48771)
109+EVIDENCE: /home/user/.cache/kf1200-census-r3.log | 24 key frames extracted with `-frames:v 1 -c:v copy`, per-plane byte diff vs ffmpeg | 17/24 all-zero, luma zero on 24/24
110+EVIDENCE: cargo test -p ec-av1 --lib a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz -- --nocapture | 7 shapes x 2 tx arms x 2 depths | 18 arms pixel-exact, 10 named refusals, edge bits 64-level horz/vert up to 3, sub-level up to 9
111+EVIDENCE: cargo test -p ec-av1 --lib the_reelb_ss600_key_frame -- --nocapture | pinned fixture decode vs ffmpeg 10-bit | "24 skipped 8x8 TX_4X4 leaves, frame pixel-exact"
112+
113+## Suite
114+
115+`cargo test -p ec-av1 --lib` (systemd unit, EC_AV1_REQUIRE_AOMENC=1): **379 passed, 0 failed,
116+33 ignored**, 514.26 s — `/home/user/.cache/kf1200-suite-r3.log`.
117+
118+## Residue
119+
120+- deferred(-ss 4800, U=29/V=5): chroma-only, 8x4 chroma patch at (540,1200) —
121+ unchanged by this round, still the r2 pair-mi sibling hypothesis. Unblocked by
122+ an `EC_IMODE_VAL`/`EC_PRED` ladder at luma mi ~(270,600); I ran out of turn
123+ budget after the census. Same for the other six chroma-only rows (900 V=50980
124+ is the largest and the only one big enough to be a second desync rather than a
125+ prediction/edge-filter off-by-one).
126+- accepted: the charter's partial-RIGHT-column gate shapes (200x72 etc.) cannot
127+ be compared until the "16x16 block whose true edge cuts through both axes"
128+ refusal is lifted; they are in the gate and currently take the refusal arm.
129+- No refusal was lifted this round; `refusal_inventory.rs` / `gate_coverage.rs`
130+ untouched.