diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 2df093e1..83946ada 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -29248,6 +29248,12 @@ fn decode_inter_block( cu_mi, luma_span, luma_span, plane_idx, &cu_grid, ); hit!(CHROMA_SPLIT_TX_HITS); + // lane-dpm1: the two INTER mu-chunk sites set this and this + // INTRA-in-inter one did not, so the whole-block chroma + // record below re-stamped all four 32x32 units with the + // TOP-LEFT unit's level and the next block read a txb_skip + // row libaom never selects (class `override-slot-on-one-arm`). + mu_chroma = true; let dst = mu_units( if plane_idx == 1 { &mut u_units } else { &mut v_units }, chroma_side * chroma_side, diff --git a/crates/ec-av1/src/encode.rs b/crates/ec-av1/src/encode.rs index bd1e82ca..a6d27f5a 100644 --- a/crates/ec-av1/src/encode.rs +++ b/crates/ec-av1/src/encode.rs @@ -13310,25 +13310,31 @@ mod tests { // 25 dB garbage while this gate stayed green) and the crf-5 key // frame desync. A failure names the encoder, the point's flags and // the first differing frame/plane/sample. + // lane-dpm1: a failing reference point is COLLECTED, not panicked + // on, so one run still prints the whole BD table and names every + // bad point instead of stopping at the first. The collection is + // asserted empty by [`assert_ladder_decodes`] at the end of each + // gate. match crate::stream::decode_stream(&stream) { + Ok(ours) if ours.len() != decoded.len() => note_ladder_failure(format!( + "{encoder} {params:?}: our decoder returned {} shown frames, ffmpeg {}", + ours.len(), + decoded.len(), + )), Ok(ours) => { - assert_eq!( - ours.len(), - decoded.len(), - "{encoder} {params:?}: our decoder returned {} shown frames, ffmpeg {}", - ours.len(), - decoded.len(), - ); for (f, (o, d)) in ours.iter().zip(&decoded).enumerate() { if let Some((plane, s, got, want)) = first_plane_mismatch(o, d) { - panic!( + note_ladder_failure(format!( "{encoder} {params:?} frame {f} plane {plane} sample {s}: our \ decoder decoded {got}, ffmpeg {want}" - ); + )); + break; } } } - Err(e) => panic!("{encoder} {params:?}: our decoder refused the stream ({e})"), + Err(e) => note_ladder_failure(format!( + "{encoder} {params:?}: our decoder refused the stream ({e})" + )), } let mean: f64 = decoded .iter() @@ -13344,6 +13350,28 @@ mod tests { (ladder, wall) } + /// Every reference ladder point that did not decode sample-exactly + /// through our own decoder, collected across a whole gate run so the BD + /// table still prints and EVERY bad point is named + /// (`encoder params frame plane sample`) instead of only the first. + static LADDER_FAILURES: std::sync::Mutex> = std::sync::Mutex::new(Vec::new()); + + fn note_ladder_failure(msg: String) { + eprintln!("LADDER DECODE FAILURE: {msg}"); + LADDER_FAILURES.lock().expect("ladder failures").push(msg); + } + + /// Fail the gate at its END on everything [`external_ladder`] collected. + fn assert_ladder_decodes() { + let failures = std::mem::take(&mut *LADDER_FAILURES.lock().expect("ladder failures")); + assert!( + failures.is_empty(), + "{} reference ladder point(s) did not decode exactly through our decoder:\n{}", + failures.len(), + failures.join("\n"), + ); + } + /// First differing sample between two pictures, as /// `(plane, index, left, right)` -- so a gate failure names the plane and /// the sample instead of just "differs". A length difference counts as a @@ -14446,6 +14474,7 @@ mod tests { .join(", "), ); } + assert_ladder_decodes(); } /// Which var-tx depth this clip's INTER blocks resolved to (lane-av1tx2, /// split by block class in lane-av1txdepth): depth 0 is one transform over @@ -14846,6 +14875,7 @@ mod tests { bd_rate(&rav1e, &ours) * 100.0, ); } + assert_ladder_decodes(); } /// lane-av1tpl3 step 1: the SHAPE of the propagating map's denominator diff --git a/crates/ec-av1/src/refusal_inventory.rs b/crates/ec-av1/src/refusal_inventory.rs index cd1eec6b..3836a99e 100644 --- a/crates/ec-av1/src/refusal_inventory.rs +++ b/crates/ec-av1/src/refusal_inventory.rs @@ -57,6 +57,15 @@ const REFUSALS: &[&str] = &[ "intra block copy on a HORZ/VERT/1:4 rect intra strip (reconstruction is not ported at this shape)", "a sub-8x8 leaf that uses intrabc (this reader has no block-vector path; the 8x8-and-up reader reconstructs one)", "a bit depth of 12 (this decoder is gated at 8 and 10 only: warp/MC/wiener rounding shifts change at 12-bit and no 12-bit gate exists)", + // lane-dpm1: libaom codes his screen-capture row at `-crf 5` with + // `base_q_idx == 0`, i.e. LOSSLESS -- TX_4X4 with the Walsh-Hadamard + // transform over every block (no `tx_depth` symbol at all) and + // `is_cfl_allowed` narrowed to `plane_bsize == BLOCK_4X4`, which changes + // the `uv_mode` alphabet. Nothing here consumes the header's `lossless`, + // so the first block of such a frame read `uv_mode` = UV_CFL_PRED where + // aomdec reads V_PRED. Refused by name (gate + // `a_lossless_libaom_stream_is_refused_by_name`) until the path exists. + "a lossless frame (qindex 0): the TX_4X4 Walsh-Hadamard tile syntax and the lossless CfL rule are unimplemented", "a frame OBU with no tile group", "a frame naming primary_ref_frame at a reference slot with no saved CDF state", "a frame with no mode-info grid", @@ -275,6 +284,10 @@ const PROVEN: &[(&str, &str)] = &[ "an inter frame with no key frame before it", "an_inter_frame_opening_a_stream_is_refused_by_name", ), + ( + "a lossless frame (qindex 0): the TX_4X4 Walsh-Hadamard tile syntax and the lossless CfL rule are unimplemented", + "a_lossless_libaom_stream_is_refused_by_name", + ), // lane-t900 r25, enumeration: a motion_mode/obmc symbol is read only under // `is_motion_variation_allowed_bsize` (min side >= 8), and each of the 17 // `BLOCK_SIZES_ALL` footprints that clause admits maps to a distinct row of diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index c30c81f2..fb982e04 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -1591,6 +1591,24 @@ fn decode_frame( "a bit depth of 12 (this decoder is gated at 8 and 10 only: warp/MC/wiener rounding shifts change at 12-bit and no 12-bit gate exists)", )); } + // lane-dpm1: a LOSSLESS frame (`qindex == 0` with zero deltas, spec 5.9.12) + // is a different tile syntax, and this decoder has none of it: libaom + // forces TX_4X4 with the WALSH-HADAMARD transform over every block (so no + // `tx_depth` symbol is coded at all), and `is_cfl_allowed` narrows to + // `plane_bsize == BLOCK_4X4` instead of the 32x32 rule, which changes the + // `uv_mode` ALPHABET. Measured on his own screen-capture row at libaom + // `-crf 5` (base_q_idx 0): the very first block, mi(0,0) BLOCK_32X32, + // reads `uv_mode` off the CfL alphabet where libaom reads the plain one + // (ours 12 = UV_CFL_PRED, aomdec 1 = V_PRED) and the tile desyncs at + // symbol four of the frame. Refuse by name rather than return a picture + // that is silently wrong from luma sample 0 (class `refusal-hides-a-defect` + // read the other way: a silent wrong decode is worse than a named gap). + if header.lossless.iter().any(|&l| l) { + return Err(Error::unsupported( + "AV1 decode_stream", + "a lossless frame (qindex 0): the TX_4X4 Walsh-Hadamard tile syntax and the lossless CfL rule are unimplemented", + )); + } crate::decode::set_bit_depth(bit_depth, fctx); // spec 7.16: this frame's superres state, for the filter chain -- // `decode.rs` upscales between CDEF and loop restoration and sizes @@ -3771,14 +3789,22 @@ pub(crate) mod tests { /// the desync surfaced blocks later as "a Golomb tail longer than this /// decoder reads". /// - /// The source is SYNTHETIC (no film sample lives in `fixtures`): a - /// near-flat dark background at the film-B crop size, 1920x1024, with one - /// textured patch stepping 9 px every SECOND frame, so half the frames are - /// exact duplicates of their predecessor (the `C == T` trigger) while the - /// motion field still holds non-zero MVs whose projections are not - /// multiples of 8. The gate asserts both halves: at least one INTER frame - /// really carries `force_integer_mv` (class `gate-blind-to-feature`), and - /// every shown frame decodes sample-exact against ffmpeg's own decode. + /// The source is SYNTHETIC (no film sample lives in `fixtures`): the + /// near-flat dark pattern libaom's own screen-content detector counts as + /// screen content, at the film-B crop size 1920x1024, SCROLLING globally + /// 5 px per frame and frozen on frame 8 -- an exact duplicate of frame 7 + /// (the `C == T` trigger) whose twin is not among its own references, so + /// its blocks still code real motion under `force_integer_mv`. + /// + /// lane-dpm1 made this gate SENSITIVE: with the `force_integer_mv` branch + /// of [`crate::motion_field::lower_mv_precision`] stubbed out (`if false + /// &&`) the stream decodes WRONG -- frame 8, luma sample 25695, 20 against + /// ffmpeg's 19 -- where the previous patch-in-a-static-background recipe + /// (and two others tried) still decoded byte-exact: there the used mv-stack + /// slots came from agreeing spatial neighbours and the rounded temporal + /// entries never won one. The gate asserts both halves: at least one INTER + /// frame really carries `force_integer_mv` (class `gate-blind-to-feature`), + /// and every shown frame decodes sample-exact against ffmpeg's own decode. #[test] fn a_libaom_force_integer_mv_stream_decodes_exact() { const NAME: &str = "a_libaom_force_integer_mv_stream_decodes_exact"; @@ -3786,23 +3812,30 @@ pub(crate) mod tests { eprintln!("SKIP {NAME}: no ffmpeg"); return; } - let (w, h, frames) = (1920usize, 1024usize, 12usize); + let (w, h, frames) = (1920usize, 1024usize, 16usize); let mut raw = Vec::with_capacity(frames * w * h * 3 / 2); + let mut off = 0usize; for f in 0..frames { + // lane-dpm1: the WHOLE picture scrolls 5 px per frame and freezes + // on frame 8, so (a) every block of the frozen frame -- including + // mi(0,0), which has no spatial neighbour at all -- still codes + // real motion against the references that are not its twin, and + // (b) 40 eighth-pels projected over the pyramid's distances lands + // on non-multiples of 8 (40/2 = 20 -> 16). A patch moving inside a + // static background was NOT sensitive: there the used stack slots + // came from spatial neighbours that agreed, and the rounded + // temporal entries never won one. + if f > 0 && f != 8 { + off = (off + 5) % h; + } let mut y = vec![0u8; w * h]; for row in 0..h { + let src = (row + off) % h; for col in 0..w { // 2..=4 distinct values per 16x16 block, all dark: the // screen-content detector's own counting rule. y[row * w + col] = - 16 + ((col / 32 + row / 32) % 5) as u8 + ((col / 4 + row / 4) % 3) as u8; - } - } - let x0 = 200 + 9 * (f / 2); - for row in 300..428 { - for col in x0..x0 + 192 { - y[row * w + col] = - ((((col - x0) / 3) * 7 + ((row - 300) / 5) * 13) % 200 + 30) as u8; + 16 + ((col / 32 + src / 32) % 5) as u8 + ((col / 4 + src / 4) % 3) as u8; } } raw.extend_from_slice(&y); @@ -3815,7 +3848,7 @@ pub(crate) mod tests { .args(["-v", "error", "-y", "-f", "rawvideo", "-pix_fmt", "yuv420p"]) .args(["-s", &format!("{w}x{h}"), "-r", "24", "-i"]) .arg(&src) - .args(["-an", "-threads", "1", "-g", "12", "-c:v", "libaom-av1"]) + .args(["-an", "-threads", "1", "-g", "16", "-c:v", "libaom-av1"]) .args(["-cpu-used", "6", "-b:v", "0", "-crf", "35", "-f", "obu", "-"]) .stdin(Stdio::null()) .stdout(Stdio::piped()) @@ -3867,6 +3900,165 @@ pub(crate) mod tests { } } + /// lane-dpm1: the 128x128-INTRA-inside-an-INTER-frame chroma context gate. + /// A 128x128 block codes its chroma as four TX_32X32 units, one per 64x64 + /// mu chunk, and libaom stamps the coefficient context PER UNIT. The two + /// INTER mu-chunk sites set `mu_chroma` so the block tail re-stamps the + /// four units in mu order; the INTRA-in-inter site did not, so the + /// whole-block record left every unit carrying the TOP-LEFT unit's level. + /// The next block then read its `txb_skip` off ctx 11 where libaom reads + /// ctx 10 (class `override-slot-on-one-arm`) -- one symbol on the wrong + /// CDF row, tile desynced, and because the loop-restoration coefficients + /// live in the same tile data the damage showed up as a +-1 luma sample at + /// the TOP of the frame (measured: frame 1, luma sample 66, ours 146 / + /// ffmpeg 145, with 1.7M samples wrong behind it). + /// + /// Source: the repository's own 2160p colour-bar fixture at the native + /// gate's crop (1920x1024 out of the middle), 12 frames, libaom + /// `-cpu-used 6 -crf 45 -g 12` -- the first reference point of + /// `bd_rate_screen_native`'s "bars 2160p" row, which is where the assertion + /// caught it. The gate asserts the tool fired (class + /// `gate-blind-to-feature`) and that every shown frame decodes sample-exact + /// against ffmpeg's own decode. + #[test] + fn a_libaom_stream_with_128_intra_blocks_in_inter_frames_decodes_exact() { + const NAME: &str = "a_libaom_stream_with_128_intra_blocks_in_inter_frames_decodes_exact"; + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } + let clip = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../../fixtures/video/h264-2160p-23.976-8bit.mp4"); + if !clip.exists() { + eprintln!("SKIP {NAME}: the 2160p bars fixture is missing"); + return; + } + let (w, h, frames) = (1920usize, 1024usize, 12usize); + // [[pid-keyed-temp-path]]: parallel test binaries must not share a name. + let src = std::env::temp_dir().join(format!("ec-av1-i128-{}.yuv", std::process::id())); + let load = Command::new("ffmpeg") + .args(["-v", "error", "-y", "-i"]) + .arg(&clip) + .args(["-frames:v", &frames.to_string(), "-vf", "crop=1920:1024:960:568"]) + .args(["-f", "rawvideo", "-pix_fmt", "yuv420p"]) + .arg(&src) + .output() + .expect("ffmpeg failed to run"); + assert!(load.status.success(), "{NAME}: {}", String::from_utf8_lossy(&load.stderr)); + let out = Command::new("ffmpeg") + .args(["-v", "error", "-y", "-f", "rawvideo", "-pix_fmt", "yuv420p"]) + .args(["-s", &format!("{w}x{h}"), "-r", "24", "-i"]) + .arg(&src) + .args(["-an", "-threads", "1", "-g", "12", "-c:v", "libaom-av1"]) + .args(["-cpu-used", "6", "-b:v", "0", "-crf", "45", "-f", "obu", "-"]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + let _ = std::fs::remove_file(&src); + if !out.status.success() { + eprintln!( + "SKIP {NAME}: ffmpeg has no libaom-av1 encoder ({})", + String::from_utf8_lossy(&out.stderr) + ); + return; + } + let stream = out.stdout; + let before = crate::decode::intra_128_in_inter_hits(); + let ours = decode_stream(&stream).expect("libaom bars stream decodes"); + assert!( + crate::decode::intra_128_in_inter_hits() > before, + "{NAME} went blind: no 128-rooted intra block inside an inter frame" + ); + let theirs = ffmpeg_decode_sequence(&stream, w, h, frames); + assert_eq!(ours.len(), frames, "shown frame count"); + for (i, (a, b)) in ours.iter().zip(theirs.iter()).enumerate() { + for (plane, l, r) in [("Y", &a.y, &b.y), ("U", &a.u, &b.u), ("V", &a.v, &b.v)] { + let first = l.iter().zip(r.iter()).position(|(x, y)| x != y); + assert!( + first.is_none(), + "frame {i} plane {plane} differs from ffmpeg at sample {}", + first.unwrap() + ); + } + } + } + + /// lane-dpm1: the lossless refusal is a CLAIM, so it gets a stream that + /// reaches it. libaom at `-crf 0` codes `base_q_idx == 0` -- the same + /// lossless frame his screen-capture row gets at `-crf 5` -- where the tile + /// syntax is TX_4X4 + Walsh-Hadamard and `is_cfl_allowed` narrows to + /// `plane_bsize == BLOCK_4X4`. Before the refusal our decoder returned a + /// picture that was wrong from luma sample 0 (measured on that row: 126 + /// against ffmpeg's 33, the first block's `uv_mode` read off the CfL + /// alphabet). The gate asserts the stream really is lossless and that we + /// refuse it BY NAME rather than decode it wrong. + #[test] + fn a_lossless_libaom_stream_is_refused_by_name() { + const NAME: &str = "a_lossless_libaom_stream_is_refused_by_name"; + if !have_ffmpeg() { + eprintln!("SKIP {NAME}: no ffmpeg"); + return; + } + let (w, h, frames) = (256usize, 128usize, 2usize); + let mut raw = Vec::with_capacity(frames * w * h * 3 / 2); + for f in 0..frames { + for row in 0..h { + for col in 0..w { + raw.push(((col * 7 + row * 13 + f * 31) % 251) as u8); + } + } + raw.extend(std::iter::repeat_n(128u8, w * h / 2)); + } + // [[pid-keyed-temp-path]]: parallel test binaries must not share a name. + let src = std::env::temp_dir().join(format!("ec-av1-lossless-{}.yuv", std::process::id())); + std::fs::write(&src, &raw).expect("raw source"); + let out = Command::new("ffmpeg") + .args(["-v", "error", "-y", "-f", "rawvideo", "-pix_fmt", "yuv420p"]) + .args(["-s", &format!("{w}x{h}"), "-r", "24", "-i"]) + .arg(&src) + .args(["-an", "-threads", "1", "-g", "2", "-c:v", "libaom-av1"]) + .args(["-cpu-used", "6", "-b:v", "0", "-crf", "0", "-f", "obu", "-"]) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .output() + .expect("ffmpeg failed to run"); + let _ = std::fs::remove_file(&src); + if !out.status.success() { + eprintln!( + "SKIP {NAME}: ffmpeg has no libaom-av1 encoder ({})", + String::from_utf8_lossy(&out.stderr) + ); + return; + } + let stream = out.stdout; + // Half of the gate: the stream must really carry a lossless frame + // (class `gate-blind-to-feature`). + let mut parser = Av1Parser::new(); + let (mut pos, mut lossless) = (0usize, 0usize); + while pos < stream.len() { + let obu = parser.parse_obu(&stream[pos..]).expect("libaom OBU parses"); + pos += obu.total_size.max(1); + let header = match &obu.kind { + ObuKind::FrameHeader(h) | ObuKind::Frame(h, _) => h, + _ => continue, + }; + if header.lossless.iter().any(|&l| l) { + lossless += 1; + } + } + assert!(lossless > 0, "{NAME} went blind: libaom coded no lossless frame at -crf 0"); + match decode_stream(&stream) { + Ok(_) => panic!("{NAME}: a lossless stream decoded instead of being refused"), + Err(e) => assert!( + format!("{e}").contains("a lossless frame (qindex 0)"), + "{NAME}: refused for the wrong reason: {e}" + ), + } + } + /// lane-dkey: the palette-neighbour-band gate. A palette-Y block's size and /// colours used to stay standing in the mi-granular above/left bands after a /// sub-8x8 group was decoded next to it -- the sub-8x8 readers published diff --git a/lanes/dpm1.report.md b/lanes/dpm1.report.md new file mode 100644 index 00000000..435b0202 --- /dev/null +++ b/lanes/dpm1.report.md @@ -0,0 +1,121 @@ +# lane-dpm1 — the native gate's decode assertion, all reference points + +## (0) The assertion now COLLECTS (encode.rs) +`external_ladder` no longer panics on the first bad reference point: every +failure is printed at once (`LADDER DECODE FAILURE: ...`) and pushed onto +`LADDER_FAILURES`; each gate calls `assert_ladder_decodes()` after its loop, so +the whole BD table still prints and every bad point is named. First run already +paid for itself: it found a SECOND failure (screen capture, crf 5) the +panic-at-first version hid, and it showed the bars failure is the 2160p clip, +not the 1080p one. + +## (1) bars ±1 — the charter's premise was mis-attributed +`bars 1080p` libaom crf 45 decodes EXACT (reproduced standalone: crop +1920x1024+0+28, 12 frames, -g 12, cpu-used 6, crf 45 -> our decode == ffmpeg, +byte for byte). The real failing row is **bars 2160p** (same crf 45, frame 1, +Y sample 66, ours 146 / ffmpeg 145). Status below. + +## (2) film B crf 5 — STALE premise, already closed +Regenerated from the manifest (film B, 00:40:00, crop 1920x1024+960+292): +`-cpu-used 6 -crf 5 -g 48` and `-g 12` both decode **sample-exact** vs ffmpeg +at this head (48 and 12 frames). No Golomb refusal. The lane-dkey/dgolomb +reports' "4th inter frame refuses" is pre-merge state. + +## (3) force_integer_mv fixture — now SENSITIVE +`stream.rs a_libaom_force_integer_mv_stream_decodes_exact`: source replaced by a +GLOBAL 5 px/frame vertical scroll of the screen-detector pattern, frozen on +frame 8, 16 frames, -g 16. With the fix stubbed (`if false && force_integer_mv`) +it now decodes WRONG at frame 8 luma sample 25695 (20 vs ffmpeg 19); with the +fix it is exact. Blind recipes tried: patch-in-static-background (the old one), +3 patches at 3 speeds with freezes at {5,9} / {4,8,12} / {8}, 3 px scroll. +Instrumented finding: a +64 perturbation of rounded candidates DID change the +output on those streams, so the rounded candidates were consumed but only in +slots whose ±4 eighth-pel difference never reached a coded block's mv. + +## (B) bars 2160p libaom crf 45 — FIXED (root cause, class, sweep, fixture) +First divergence (two instrumented decoders, `EC_TRACE_MODE_STEP` + +`EC_TRACE_COEFF`): INTER frame 1, block **mi(0,288)**, a 128x128 INTRA block +inside an inter frame, its FIRST chroma (U) transform unit -- aomdec reads +`txb_skip` on ctx 10, ours on ctx 11 (`get_txb_ctx`'s offset-10 rows, base 1 vs +0). The luma ladder and every symbol before it matched exactly. + +Root cause, `crates/ec-av1/src/decode.rs`: a 128x128 block codes its chroma as +four TX_32X32 units, one per 64x64 mu chunk, and libaom stamps the coefficient +context PER UNIT. The block tail re-stamps those four units only when +`mu_chroma` is set -- the two INTER mu-chunk sites (27255, 28552) set it, the +INTRA-in-inter site did not, so the whole-block record left all four units +carrying the TOP-LEFT unit's level. Class **`override-slot-on-one-arm`** (a fix +installed on one arm of a set of twins). Sweep: all `CHROMA_SPLIT_TX_HITS` +sites -- the two key-frame ones (14364, 14703) have their own local re-stamp, +the three inter-frame ones now all set `mu_chroma`. No other site. + +Why it read as a `+-1` at sample 66: the U-plane symbol desynced the tile, and +the loop-restoration coefficients live in the same tile data, so the whole +frame shifted by one level while 1.7M samples behind it went wrong. + +Fixture: `stream.rs a_libaom_stream_with_128_intra_blocks_in_inter_frames_decodes_exact` -- the repo's own 2160p bars fixture at the native crop, libaom +`-cpu-used 6 -crf 45 -g 12`, asserts the tool fired and every frame is exact. +With `mu_chroma = false` on that arm it FAILS with "frame 1 plane Y differs +from ffmpeg at sample 66" (verified). + +## (A) screen capture libaom crf 5 — root cause found, feature DEFERRED +That stream's key frame is coded **LOSSLESS** (`base_q_idx 0`, `lossless[seg]` +true; aomdec's own `EC_IMODE_VAL ... tx=0` shows TX_4X4 on a BLOCK_32X32). +libaom then (a) forces TX_4X4 + the Walsh-Hadamard transform everywhere and +codes NO `tx_depth` symbol, and (b) narrows `is_cfl_allowed` to +`plane_bsize == BLOCK_4X4`, which changes the `uv_mode` alphabet. Our tile +reader ignores `header.lossless` entirely: the FIRST block, mi(0,0), reads +`uv_mode` = 12 (UV_CFL_PRED) where aomdec reads 1 (V_PRED) -- symbol four of +the frame. Class `branch-dropped-as-unreachable` (the header computes +`lossless`/`coded_lossless` and nothing consumes it). + +Shipped now: a NAMED REFUSAL in `stream.rs` (`a lossless frame (qindex 0) ...`) +so the decoder stops returning a picture that is wrong from luma sample 0. +`deferred: the lossless decode path (WHT 4x4, forced tx size, lossless CfL +rule, filter bypass) — a feature lane, not a fix — unblocks: implement +`inverse WHT + the TX_4X4 forcing + `is_cfl_allowed`'s lossless branch, gate +with this same screen row at crf 5.` + +## OPEN +* The native gate's screen row now reports the refusal instead of a silent + wrong decode; it is RED until the lossless lane lands. + +## Gate results (this head, fea6a377) + +`cargo test -p ec-av1 --release --lib -- --ignored --exact bd_rate_screen_native` +(12 frames, all five rows, every reference point of every row decoded through +our decoder and compared to ffmpeg): + +| row | verdict | +|---|---| +| bars 1080p | all 8 reference points exact | +| bars 2160p | all 8 exact (was: libaom crf 45 frame 1 Y sample 66) | +| film A (1080p source) | all 8 exact | +| film B (2160p HDR source) | all 8 exact | +| screen capture | 7 of 8 exact; libaom crf 5 REFUSED (lossless, deferred) | + +The gate ends RED on exactly that one point, and the collecting assertion is +why the four film/bars rows and their BD table are measured at all in the same +run: + + 1 reference ladder point(s) did not decode exactly through our decoder: + libaom-av1 ["-cpu-used","6","-b:v","0","-crf","5"]: our decoder refused the + stream (a lossless frame (qindex 0) ...) + +BD table unchanged by this lane (bars 1080p +2.0/-14.0, bars 2160p +13.1/-9.6, +film A +38.5/+8.2, film B +58.2/+26.5, screen +33.4/-23.8 vs libaom/rav1e). + +`cargo check --workspace --all-targets -j4`: 0 errors, 0 ec-av1 warnings (the +25 warnings are pre-existing ec-opus/ec-vorbis ones). + +## Deferred +* `deferred: the lossless decode path (WHT TX_4X4, forced tx size, the lossless + CfL rule) — a feature lane, refused by name meanwhile — unblocks: implement + the inverse Walsh-Hadamard + `is_cfl_allowed`'s lossless branch, gate on the + screen row at crf 5.` +* `deferred: the inter-side palette-band publication (lane-dkey's open half) — + not what any defect in this lane needed, and the previous naive stamp + regressed 13 tests — unblocks: derive each inter reader's real band footprint + from how `record_palette_*` indexes the bands.` + +`cargo test -p ec-av1 --release --lib`: **554 passed, 0 failed, 43 ignored** (552 + the two new gates); pins `the_encoders_own_streams_are_byte_identical_to_their_pins` green (9778 / 35450 untouched -- no encoder file changed). /tmp at 66%.