Merge branch 'lane-sqdrift' (7d498c0) into lane-intrasplit
Browse files at this commit10 changed files +1126 -13
- crates/ec-av1/src/decode.rs +65 -6
- crates/ec-av1/src/motion_field.rs +9 -0
- crates/ec-av1/src/stream.rs +341 -7
- lanes/sbrect10-r1.handoff.md +81 -0
- lanes/sbrect10-r2.handoff.md +175 -0
- lanes/sbrect10-r2.report.md +124 -0
- lanes/sbrect10-r3.report.md +98 -0
- lanes/sqdrift-r1.handoff.md +40 -0
- lanes/sqdrift-r1.report.md +100 -0
- lanes/sqdrift-r2.report.md +93 -0
crates/ec-av1/src/decode.rsmodified+65 -6
| @@ -1849,6 +1849,20 @@ pub(crate) fn wii_hits() -> usize { | |||
| 1849 | WII_HITS.with(|c| c.get()) | 1849 | WII_HITS.with(|c| c.get()) |
| 1850 | } | 1850 | } |
| 1851 | 1851 | ||
| 1852 | +// lane-sbrect10 r1: how many INTRA blocks read `uv_mode` off the 13-symbol | ||
| 1853 | +// NO-CFL alphabet *because their size excludes CFL* (libaom `is_cfl_allowed`: | ||
| 1854 | +// wide <= 32 && high <= 32). The witness that a gate stream really carries a | ||
| 1855 | +// 64-axis intra block -- the shape whose 14-symbol read desynced every inter | ||
| 1856 | +// frame carrying one. | ||
| 1857 | +thread_local! { | ||
| 1858 | + static NOCFL_UV_MODE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1859 | +} | ||
| 1860 | + | ||
| 1861 | +/// Current value of [`NOCFL_UV_MODE_HITS`]. | ||
| 1862 | +pub(crate) fn nocfl_uv_mode_hits() -> usize { | ||
| 1863 | + NOCFL_UV_MODE_HITS.with(|c| c.get()) | ||
| 1864 | +} | ||
| 1865 | + | ||
| 1852 | // lane-inter4 r4: how many 16x8/8x16 INTER LEAVES actually ran the OBMC | 1866 | // lane-inter4 r4: how many 16x8/8x16 INTER LEAVES actually ran the OBMC |
| 1853 | // blend -- the gate's proof that `--enable-obmc=1` reached this shape (the | 1867 | // blend -- the gate's proof that `--enable-obmc=1` reached this shape (the |
| 1854 | // r3 refusal's replacement: prefilt frames are bit-exact vs an instrumented | 1868 | // r3 refusal's replacement: prefilt frames are bit-exact vs an instrumented |
| @@ -5527,6 +5541,17 @@ fn read_intra_mode_rect( | |||
| 5527 | } | 5541 | } |
| 5528 | }; | 5542 | }; |
| 5529 | } | 5543 | } |
| 5544 | + // lane-sbrect10 r1: libaom `is_cfl_allowed` (blockd.h) is | ||
| 5545 | + // `block_size_wide <= 32 && block_size_high <= 32` -- enforce it HERE, at | ||
| 5546 | + // the one point every rect caller routes through, so no call site can | ||
| 5547 | + // offer the 14-symbol CFL alphabet on a 64-axis block (class | ||
| 5548 | + // wrong-alphabet-same-value: same value, wrong interval, silent desync). | ||
| 5549 | + let cfl = if cfl && bw.max(bh) > 32 { | ||
| 5550 | + NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1)); | ||
| 5551 | + false | ||
| 5552 | + } else { | ||
| 5553 | + cfl | ||
| 5554 | + }; | ||
| 5530 | // Same `intra_segment_id` placement as the square reader above. | 5555 | // Same `intra_segment_id` placement as the square reader above. |
| 5531 | let (seg_w_mi, seg_h_mi) = (bw / 4, bh / 4); | 5556 | let (seg_w_mi, seg_h_mi) = (bw / 4, bh / 4); |
| 5532 | if seg_id_pre_skip() { | 5557 | if seg_id_pre_skip() { |
| @@ -8508,6 +8533,14 @@ fn read_intra_mode( | |||
| 8508 | } | 8533 | } |
| 8509 | }; | 8534 | }; |
| 8510 | } | 8535 | } |
| 8536 | + // lane-sbrect10 r1: `is_cfl_allowed`'s <=32 bound, enforced at the single | ||
| 8537 | + // point every square caller routes through (see `read_intra_mode_rect`). | ||
| 8538 | + let cfl = if cfl && side > 32 { | ||
| 8539 | + NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1)); | ||
| 8540 | + false | ||
| 8541 | + } else { | ||
| 8542 | + cfl | ||
| 8543 | + }; | ||
| 8511 | // spec 5.11.6 `intra_frame_mode_info`: `intra_segment_id` is read BEFORE | 8544 | // spec 5.11.6 `intra_frame_mode_info`: `intra_segment_id` is read BEFORE |
| 8512 | // `skip` when `SegIdPreSkip`, and after it otherwise. | 8545 | // `skip` when `SegIdPreSkip`, and after it otherwise. |
| 8513 | let (seg_w_mi, seg_h_mi) = (side / 4, side / 4); | 8546 | let (seg_w_mi, seg_h_mi) = (side / 4, side / 4); |
| @@ -8851,8 +8884,13 @@ fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 { | |||
| 8851 | /// matches aomdec's own `ec_dump16` rung byte for byte (crop dims, u16 LE). | 8884 | /// matches aomdec's own `ec_dump16` rung byte for byte (crop dims, u16 LE). |
| 8852 | fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) { | 8885 | fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) { |
| 8853 | use std::io::Write; | 8886 | use std::io::Write; |
| 8887 | + // lane-sbrect10 r2: index the dump by decode-order picture like | ||
| 8888 | + // EC_AV1_PREFILT_DUMP already does -- a fixed `.f0` name kept only the | ||
| 8889 | + // LAST frame, so a mid-sequence divergence could not be read out at all. | ||
| 8890 | + static STAGE16_IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); | ||
| 8854 | if let Ok(path) = std::env::var(var) | 8891 | if let Ok(path) = std::env::var(var) |
| 8855 | - && let Ok(mut f) = std::fs::File::create(format!("{path}.f0")) | 8892 | + && let idx = STAGE16_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst) |
| 8893 | + && let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) | ||
| 8856 | { | 8894 | { |
| 8857 | for (p, w, h) in [(y, fw, fh), (u, fw.div_ceil(2), fh.div_ceil(2)), (v, fw.div_ceil(2), fh.div_ceil(2))] { | 8895 | for (p, w, h) in [(y, fw, fh), (u, fw.div_ceil(2), fh.div_ceil(2)), (v, fw.div_ceil(2), fh.div_ceil(2))] { |
| 8858 | for row in 0..h { | 8896 | for row in 0..h { |
| @@ -18619,6 +18657,12 @@ fn decode_inter_block( | |||
| 18619 | return Ok(()); | 18657 | return Ok(()); |
| 18620 | } | 18658 | } |
| 18621 | let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]); | 18659 | let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]); |
| 18660 | + if std::env::var_os("EC_IIS").is_some() { | ||
| 18661 | + eprintln!( | ||
| 18662 | + "TRACE iis px={px} py={py} side={side} w={write_w} h={write_h} sg={} mode={mode} skip={skip}", | ||
| 18663 | + size_group_wh(write_w, write_h) | ||
| 18664 | + ); | ||
| 18665 | + } | ||
| 18622 | if mode >= 13 { | 18666 | if mode >= 13 { |
| 18623 | return Err(unsupported( | 18667 | return Err(unsupported( |
| 18624 | "an intra mode this decoder does not code (round 2)", | 18668 | "an intra mode this decoder does not code (round 2)", |
| @@ -18647,13 +18691,27 @@ fn decode_inter_block( | |||
| 18647 | // directional intra-in-inter block was refused above. | 18691 | // directional intra-in-inter block was refused above. |
| 18648 | let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left(r, c); | 18692 | let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left(r, c); |
| 18649 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); | 18693 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 18650 | - let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]); | 18694 | + // lane-sbrect10 r1 (class wrong-alphabet-same-value, second instance |
| 18695 | + // after lane-sbpart r3's rect strips): `is_cfl_allowed` (libaom | ||
| 18696 | + // `blockd.h` -- `block_size_wide[bsize] <= 32 && block_size_high[bsize] | ||
| 18697 | + // <= 32`, spec 5.11.5) caps CFL at 32x32, so a 64x64 intra block inside | ||
| 18698 | + // an INTER frame reads the 13-symbol `uv_mode_no_cfl` alphabet. Reading | ||
| 18699 | + // the 14-symbol CFL one gave the same DC_PRED VALUE but narrowed the | ||
| 18700 | + // arithmetic coder by the wrong interval, desyncing the tile from this | ||
| 18701 | + // block on. | ||
| 18702 | + let cfl_allowed = write_w.max(write_h) <= 32; | ||
| 18703 | + if !cfl_allowed { | ||
| 18704 | + NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1)); | ||
| 18705 | + } | ||
| 18706 | + let uv_mode = if cfl_allowed { | ||
| 18707 | + dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | ||
| 18708 | + } else { | ||
| 18709 | + dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | ||
| 18710 | + }; | ||
| 18651 | if (9..=12).contains(&uv_mode) { | 18711 | if (9..=12).contains(&uv_mode) { |
| 18652 | SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); | 18712 | SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); |
| 18653 | } | 18713 | } |
| 18654 | - let alpha = if uv_mode == DC_PRED { | 18714 | + let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { |
| 18655 | - None | ||
| 18656 | - } else if uv_mode == UV_CFL_PRED { | ||
| 18657 | Some(read_cfl_alphas(dec, cdfs)) | 18715 | Some(read_cfl_alphas(dec, cdfs)) |
| 18658 | } else { | 18716 | } else { |
| 18659 | None | 18717 | None |
| @@ -21084,10 +21142,11 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 21084 | // instead of silently decoding as SPLIT and desyncing. | 21142 | // instead of silently decoding as SPLIT and desyncing. |
| 21085 | let part64 = match (has_cols, has_rows) { | 21143 | let part64 = match (has_cols, has_rows) { |
| 21086 | (true, true) => { | 21144 | (true, true) => { |
| 21145 | + let pre_rng = dec.debug_state().0; | ||
| 21087 | let p = dec.symbol(&mut cdfs.partition_w64[sb_ctx]); | 21146 | let p = dec.symbol(&mut cdfs.partition_w64[sb_ctx]); |
| 21088 | if std::env::var_os("EC_AV1_TRACE").is_some() { | 21147 | if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 21089 | eprintln!( | 21148 | eprintln!( |
| 21090 | - "TRACE partition_w64 mi=({},{}) ctx={sb_ctx} value={p}", | 21149 | + "TRACE partition_w64 mi=({},{}) ctx={sb_ctx} value={p} pre_rng={pre_rng}", |
| 21091 | sb_r * SB_MI, | 21150 | sb_r * SB_MI, |
| 21092 | sb_c * SB_MI | 21151 | sb_c * SB_MI |
| 21093 | ); | 21152 | ); |
crates/ec-av1/src/motion_field.rsmodified+9 -0
| @@ -442,6 +442,15 @@ pub fn setup_motion_field( | |||
| 442 | ); | 442 | ); |
| 443 | } | 443 | } |
| 444 | 444 | ||
| 445 | + if std::env::var_os("EC_TRACE_TPL").is_some() { | ||
| 446 | + eprintln!("EC_TPL_FIELD oh={cur_order_hint} rows={rows} cols={cols}"); | ||
| 447 | + for r in 0..rows { | ||
| 448 | + let row: String = (0..cols) | ||
| 449 | + .map(|c| if cells[r * cols + c].is_some() { '#' } else { '.' }) | ||
| 450 | + .collect(); | ||
| 451 | + eprintln!("EC_TPL_FIELD r{r} {row}"); | ||
| 452 | + } | ||
| 453 | + } | ||
| 445 | TplField { cols, rows, cells } | 454 | TplField { cols, rows, cells } |
| 446 | } | 455 | } |
| 447 | 456 | ||
crates/ec-av1/src/stream.rsmodified+341 -7
| @@ -6925,13 +6925,16 @@ mod tests { | |||
| 6925 | // refusal it names is GONE (this round codes a 64-px transform axis as | 6925 | // refusal it names is GONE (this round codes a 64-px transform axis as |
| 6926 | // its truncated low-32 corner), and a 10-bit sweep of this exact | 6926 | // its truncated low-32 corner), and a 10-bit sweep of this exact |
| 6927 | // recipe now reaches the arm -- 2 pixel-exact attempts, 2 64x32 and 2 | 6927 | // recipe now reaches the arm -- 2 pixel-exact attempts, 2 64x32 and 2 |
| 6928 | - // 32x64 strips, 2 of them carrying a coded 64-axis residual. It stays | 6928 | + // 32x64 strips, 2 of them carrying a coded 64-axis residual. |
| 6929 | - // 8-bit here for a DIFFERENT, newly exposed reason: 10-bit attempt 14 | 6929 | + // lane-sbrect10 r1 closed the newly exposed 10-bit defect r14 r2 |
| 6930 | - // (cq 61, horizontal split, motion step 12) mismatches ffmpeg while | 6930 | + // parked this arm on (10-bit attempt 14, cq 61, horizontal split, |
| 6931 | - // decoding ZERO superblock-level rect strips and zero 64-axis | 6931 | + // motion step 12 -- it mismatched ffmpeg while decoding ZERO rect |
| 6932 | - // residual units, i.e. a defect of some other shape that this gate | 6932 | + // strips): a 64x64 INTRA block inside an inter frame read `uv_mode` |
| 6933 | - // must not absorb. See lanes/r14-r2.report.md. | 6933 | + // off the 14-symbol CFL-allowed alphabet, which libaom's |
| 6934 | - for bit_depth in [8u32] { | 6934 | + // `is_cfl_allowed` caps at 32x32 -- same DC_PRED value, wrong |
| 6935 | + // interval narrowing, tile desynced from that block on. Both depths | ||
| 6936 | + // run now. | ||
| 6937 | + for bit_depth in [8u32, 10u32] { | ||
| 6935 | let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = | 6938 | let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = |
| 6936 | (0u32, 0u32, 0u32, 0u32); | 6939 | (0u32, 0u32, 0u32, 0u32); |
| 6937 | let (mut horz_proved, mut vert_proved) = (0usize, 0usize); | 6940 | let (mut horz_proved, mut vert_proved) = (0usize, 0usize); |
| @@ -7086,6 +7089,337 @@ mod tests { | |||
| 7086 | } | 7089 | } |
| 7087 | } | 7090 | } |
| 7088 | 7091 | ||
| 7092 | + /// lane-sbrect10 r1: a 64x64 INTRA block inside an INTER frame, whose | ||
| 7093 | + /// `uv_mode` alphabet libaom's `is_cfl_allowed` (`blockd.h`: `wide <= 32 | ||
| 7094 | + /// && high <= 32`) narrows to the 13-symbol NO-CFL table. Reading the | ||
| 7095 | + /// 14-symbol CFL one produced the same `DC_PRED` value with the wrong | ||
| 7096 | + /// interval narrowing, so the tile desynced from that block on and the | ||
| 7097 | + /// frame decoded silently wrong (class `wrong-alphabet-same-value`; found | ||
| 7098 | + /// as the "another shape" mismatch the superblock rect gate above had to | ||
| 7099 | + /// park its 10-bit arm on). | ||
| 7100 | + /// | ||
| 7101 | + /// The counter `nocfl_uv_mode_hits` proves the shape fired in EVERY | ||
| 7102 | + /// compared attempt, and every decode-order frame is compared against | ||
| 7103 | + /// ffmpeg -- an attempt that mismatches fails, it never SKIPs. | ||
| 7104 | + /// | ||
| 7105 | + /// lane-sbrect10 r2: with the half-random source below this gate also | ||
| 7106 | + /// covers a SECOND defect it exposed at 10-bit cq 58/61 -- the compound | ||
| 7107 | + /// MV stack's extension pass zero-filled the `comp_list` tail slots | ||
| 7108 | + /// libaom fills with each side's GLOBAL MOTION vector | ||
| 7109 | + /// (`combine_compound_candidates`, mvref_common.c:723-729). A compound | ||
| 7110 | + /// block with no usable neighbour pair (frame top row, intra block to | ||
| 7111 | + /// its left, empty temporal field) then took a `(0, 0)` predictor | ||
| 7112 | + /// instead of the frame's translation: 32890/39907 wrong luma samples | ||
| 7113 | + /// on decode-order frame 2 with the entropy stream still in sync. | ||
| 7114 | + #[test] | ||
| 7115 | + fn a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet() { | ||
| 7116 | + const NAME: &str = | ||
| 7117 | + "a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet"; | ||
| 7118 | + let _gate_lock = lock_gate_counters(); | ||
| 7119 | + if !have_ffmpeg() { | ||
| 7120 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 7121 | + return; | ||
| 7122 | + } | ||
| 7123 | + if !have_aomenc() { | ||
| 7124 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 7125 | + return; | ||
| 7126 | + } | ||
| 7127 | + let (width, height, frame_count) = (192usize, 128usize, 6usize); | ||
| 7128 | + for bit_depth in [8u32, 10u32] { | ||
| 7129 | + let (mut named_refusals, mut matched, mut carried_none) = (0u32, 0u32, 0u32); | ||
| 7130 | + let mut total_hits = 0usize; | ||
| 7131 | + for attempt in 0..16u32 { | ||
| 7132 | + // The sibling superblock-rect gate's own grid (its 10-bit | ||
| 7133 | + // attempt 14 -- cq 61, horizontal split, motion step 12 -- is | ||
| 7134 | + // the stream that exposed the defect); which superblock the RD | ||
| 7135 | + // hands an intra 64x64 block moves with the quantiser and the | ||
| 7136 | + // depth, so both orientations x four quantisers x two motion | ||
| 7137 | + // steps run here too. | ||
| 7138 | + let vertical_split = attempt % 2 == 1; | ||
| 7139 | + let cq = [58, 52, 45, 61][(attempt / 2 % 4) as usize]; | ||
| 7140 | + let sp = 8 + (attempt / 8) * 4; | ||
| 7141 | + // Half ramp, half deterministic pseudo-noise: the flat "200" | ||
| 7142 | + // half of r1's source made aomenc code the right-hand | ||
| 7143 | + // superblocks skip, so at 8 bit no >32 intra block ever | ||
| 7144 | + // appeared (probed cq 45/52/58/61/63 = 0 hits). The textured | ||
| 7145 | + // half forces intra above 32x32 in an inter frame at BOTH | ||
| 7146 | + // depths, so both arms carry the shape. | ||
| 7147 | + let geq = if vertical_split { | ||
| 7148 | + format!( | ||
| 7149 | + "if(lt(Y,64), 40+mod(floor((X+N*{sp})/32)*90,200), mod((X*7+Y*13+N*97)*31,256))" | ||
| 7150 | + ) | ||
| 7151 | + } else { | ||
| 7152 | + format!( | ||
| 7153 | + "if(lt(X,128), 40+mod(floor((Y+N*{sp})/32)*90,200), mod((X*7+Y*13+N*97)*31,256))" | ||
| 7154 | + ) | ||
| 7155 | + }; | ||
| 7156 | + let duration = frame_count as f64 / 25.0; | ||
| 7157 | + let source = format!( | ||
| 7158 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | ||
| 7159 | + geq=lum='{geq}',format=yuv420p" | ||
| 7160 | + ); | ||
| 7161 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 7162 | + let y4m = Command::new("ffmpeg") | ||
| 7163 | + .args([ | ||
| 7164 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | ||
| 7165 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 7166 | + ]) | ||
| 7167 | + .stdin(Stdio::null()) | ||
| 7168 | + .stdout(Stdio::piped()) | ||
| 7169 | + .stderr(Stdio::piped()) | ||
| 7170 | + .output() | ||
| 7171 | + .expect("ffmpeg failed to run"); | ||
| 7172 | + assert!( | ||
| 7173 | + y4m.status.success(), | ||
| 7174 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 7175 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 7176 | + ); | ||
| 7177 | + let cq_arg = format!("--cq-level={cq}"); | ||
| 7178 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 7179 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 7180 | + let args: Vec<&str> = vec![ | ||
| 7181 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", | ||
| 7182 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | ||
| 7183 | + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", | ||
| 7184 | + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", | ||
| 7185 | + "--enable-tx-size-search=0", "--lag-in-frames=0", | ||
| 7186 | + "--enable-rect-partitions=1", "--enable-ab-partitions=0", | ||
| 7187 | + "--enable-1to4-partitions=1", "--min-partition-size=32", | ||
| 7188 | + "--max-partition-size=64", | ||
| 7189 | + "--obu", "-o", "-", "-", | ||
| 7190 | + ]; | ||
| 7191 | + let mut child = Command::new(aomenc_path()) | ||
| 7192 | + .args(&args) | ||
| 7193 | + .stdin(Stdio::piped()) | ||
| 7194 | + .stdout(Stdio::piped()) | ||
| 7195 | + .stderr(Stdio::piped()) | ||
| 7196 | + .spawn() | ||
| 7197 | + .expect("aomenc failed to start"); | ||
| 7198 | + child | ||
| 7199 | + .stdin | ||
| 7200 | + .take() | ||
| 7201 | + .expect("aomenc stdin") | ||
| 7202 | + .write_all(&y4m.stdout) | ||
| 7203 | + .expect("writing y4m to aomenc"); | ||
| 7204 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 7205 | + assert!( | ||
| 7206 | + out.status.success(), | ||
| 7207 | + "aomenc refused the fixture: {}", | ||
| 7208 | + String::from_utf8_lossy(&out.stderr) | ||
| 7209 | + ); | ||
| 7210 | + let stream = out.stdout; | ||
| 7211 | + let before = crate::decode::nocfl_uv_mode_hits(); | ||
| 7212 | + let frames = match decode_stream(&stream) { | ||
| 7213 | + Err(e) => { | ||
| 7214 | + let msg = e.to_string(); | ||
| 7215 | + assert!( | ||
| 7216 | + msg.contains("unsupported"), | ||
| 7217 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ | ||
| 7218 | + attempt {attempt}): {msg}" | ||
| 7219 | + ); | ||
| 7220 | + named_refusals += 1; | ||
| 7221 | + eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); | ||
| 7222 | + continue; | ||
| 7223 | + } | ||
| 7224 | + Ok(frames) => frames, | ||
| 7225 | + }; | ||
| 7226 | + let hits = crate::decode::nocfl_uv_mode_hits() - before; | ||
| 7227 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 7228 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 7229 | + } else { | ||
| 7230 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 7231 | + }; | ||
| 7232 | + assert_eq!(frames.len(), frame_count); | ||
| 7233 | + if hits == 0 { | ||
| 7234 | + // No 64-axis intra block in this stream: still compared | ||
| 7235 | + // (a mismatch here is a defect, never a pass), just not | ||
| 7236 | + // proof of this gate's shape. | ||
| 7237 | + carried_none += 1; | ||
| 7238 | + } | ||
| 7239 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 7240 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})"); | ||
| 7241 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})"); | ||
| 7242 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})"); | ||
| 7243 | + } | ||
| 7244 | + if hits > 0 { | ||
| 7245 | + matched += 1; | ||
| 7246 | + total_hits += hits; | ||
| 7247 | + } | ||
| 7248 | + } | ||
| 7249 | + eprintln!( | ||
| 7250 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ | ||
| 7251 | + attempts carrying a >32 intra block ({total_hits} no-CFL uv_mode reads), \ | ||
| 7252 | + {carried_none} attempts carried none" | ||
| 7253 | + ); | ||
| 7254 | + assert!( | ||
| 7255 | + matched > 0 && total_hits > 0, | ||
| 7256 | + "{NAME} ({bit_depth}-bit): no attempt decoded an intra block above 32x32, so the \ | ||
| 7257 | + no-CFL uv_mode alphabet was never exercised -- gate proved nothing \ | ||
| 7258 | + ({named_refusals} refusals, {carried_none} attempts carried none)" | ||
| 7259 | + ); | ||
| 7260 | + } | ||
| 7261 | + } | ||
| 7262 | + /// lane-sqdrift r2: the SQUARE-ONLY twin of the no-CFL `uv_mode` gate | ||
| 7263 | + /// above. With `--enable-rect-partitions=0` the encoder codes only | ||
| 7264 | + /// `PARTITION_NONE` and `PARTITION_SPLIT`, and on detailed content the RD | ||
| 7265 | + /// eventually hands one whole 64x64 superblock of an INTER frame to an | ||
| 7266 | + /// INTRA block -- `bsize == sb_size`, the one shape whose `uv_mode` must | ||
| 7267 | + /// come off the 13-symbol `uv_mode_no_cfl` alphabet because libaom's | ||
| 7268 | + /// `is_cfl_allowed` (`blockd.h`: `wide <= 32 && high <= 32`) excludes it. | ||
| 7269 | + /// | ||
| 7270 | + /// Before the fix this decoder read the 14-symbol CFL alphabet there: the | ||
| 7271 | + /// same `DC_PRED` value, a different interval, and the tile desynced from | ||
| 7272 | + /// that block on. r1 measured the damage on the pinned 192x128 stream | ||
| 7273 | + /// (sha256 `c6af4fb4...`): decode-order frames 0-3 pre-filter byte-exact, | ||
| 7274 | + /// frame 4 luma 3540 samples wrong over exactly the last superblock | ||
| 7275 | + /// (x 128..191, y 64..127), then 24k wrong by frame 7 -- and the decoder | ||
| 7276 | + /// did not even report a mismatch, it reported an intra-rect-strip refusal | ||
| 7277 | + /// read out of the already-desynced stream (class `refusal-from-own-desync`; | ||
| 7278 | + /// aomdec's own partition histogram over that stream is rect-free). | ||
| 7279 | + /// After the fix the same stream is byte-exact on all 8 frames. | ||
| 7280 | + /// | ||
| 7281 | + /// Distinct from the sibling gate: rect partitions OFF (so the 64x64 NONE | ||
| 7282 | + /// really is a whole superblock), `--min-partition-size=16`, natural | ||
| 7283 | + /// mandelbrot detail instead of a synthetic half-noise ramp, and 8 frames | ||
| 7284 | + /// of drift so a desync that survives one frame still fails here. Every | ||
| 7285 | + /// decode-order frame of every attempt is compared against ffmpeg, so a | ||
| 7286 | + /// mismatch of ANY shape fails; the gate never turns one into a SKIP. | ||
| 7287 | + #[test] | ||
| 7288 | + fn a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact() | ||
| 7289 | + { | ||
| 7290 | + const NAME: &str = "a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact"; | ||
| 7291 | + let _gate_lock = lock_gate_counters(); | ||
| 7292 | + if !have_ffmpeg() { | ||
| 7293 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 7294 | + return; | ||
| 7295 | + } | ||
| 7296 | + if !have_aomenc() { | ||
| 7297 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 7298 | + return; | ||
| 7299 | + } | ||
| 7300 | + let (width, height, frame_count) = (192usize, 128usize, 8usize); | ||
| 7301 | + for bit_depth in [8u32, 10u32] { | ||
| 7302 | + let (mut named_refusals, mut matched, mut carried_none) = (0u32, 0u32, 0u32); | ||
| 7303 | + let mut total_hits = 0usize; | ||
| 7304 | + for attempt in 0..4u32 { | ||
| 7305 | + // r1's pinned recipe is (start_scale 4.76, cq 55); the other | ||
| 7306 | + // three points move the detail level and the quantiser, which | ||
| 7307 | + // is what moves WHICH superblock the RD codes intra. | ||
| 7308 | + let start_scale = ["4.76", "3.20"][(attempt % 2) as usize]; | ||
| 7309 | + let cq = [55, 45][(attempt / 2) as usize]; | ||
| 7310 | + let duration = frame_count as f64 / 25.0; | ||
| 7311 | + let source = format!( | ||
| 7312 | + "mandelbrot=size={width}x{height}:start_scale={start_scale}:\ | ||
| 7313 | + end_scale=0.004:end_pts=8:rate=25" | ||
| 7314 | + ); | ||
| 7315 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 7316 | + let y4m = Command::new("ffmpeg") | ||
| 7317 | + .args([ | ||
| 7318 | + "-v", "error", "-f", "lavfi", "-i", &source, "-vf", "hue=s=0", | ||
| 7319 | + "-t", &duration.to_string(), "-pix_fmt", pix_fmt, "-strict", "-1", | ||
| 7320 | + "-f", "yuv4mpegpipe", "-strict", "-1", "-", | ||
| 7321 | + ]) | ||
| 7322 | + .stdin(Stdio::null()) | ||
| 7323 | + .stdout(Stdio::piped()) | ||
| 7324 | + .stderr(Stdio::piped()) | ||
| 7325 | + .output() | ||
| 7326 | + .expect("ffmpeg failed to run"); | ||
| 7327 | + assert!( | ||
| 7328 | + y4m.status.success(), | ||
| 7329 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 7330 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 7331 | + ); | ||
| 7332 | + let cq_arg = format!("--cq-level={cq}"); | ||
| 7333 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 7334 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 7335 | + let args: Vec<&str> = vec![ | ||
| 7336 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=1", | ||
| 7337 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | ||
| 7338 | + "--lag-in-frames=0", "--auto-alt-ref=0", | ||
| 7339 | + "--kf-min-dist=1000", "--kf-max-dist=1000", | ||
| 7340 | + "--enable-rect-partitions=0", "--enable-ab-partitions=0", | ||
| 7341 | + "--enable-1to4-partitions=0", "--min-partition-size=16", | ||
| 7342 | + "--max-partition-size=64", "--enable-tx-size-search=0", | ||
| 7343 | + "--enable-order-hint=0", "--enable-warped-motion=0", "--enable-obmc=0", | ||
| 7344 | + "--enable-masked-comp=0", "--enable-interintra-comp=0", | ||
| 7345 | + "--enable-dist-wtd-comp=0", "--enable-diff-wtd-comp=0", | ||
| 7346 | + "--enable-onesided-comp=0", "--enable-interintra-wedge=0", | ||
| 7347 | + "--enable-smooth-interintra=0", "--enable-filter-intra=0", | ||
| 7348 | + "--enable-smooth-intra=0", "--enable-paeth-intra=0", | ||
| 7349 | + "--enable-directional-intra=0", "--enable-angle-delta=0", | ||
| 7350 | + "--enable-cdef=0", "--enable-restoration=0", "--enable-palette=0", | ||
| 7351 | + "--enable-intrabc=0", "--enable-cfl-intra=0", "--enable-ref-frame-mvs=0", | ||
| 7352 | + "--obu", "-o", "-", "-", | ||
| 7353 | + ]; | ||
| 7354 | + let mut child = Command::new(aomenc_path()) | ||
| 7355 | + .args(&args) | ||
| 7356 | + .stdin(Stdio::piped()) | ||
| 7357 | + .stdout(Stdio::piped()) | ||
| 7358 | + .stderr(Stdio::piped()) | ||
| 7359 | + .spawn() | ||
| 7360 | + .expect("aomenc failed to start"); | ||
| 7361 | + child | ||
| 7362 | + .stdin | ||
| 7363 | + .take() | ||
| 7364 | + .expect("aomenc stdin") | ||
| 7365 | + .write_all(&y4m.stdout) | ||
| 7366 | + .expect("writing y4m to aomenc"); | ||
| 7367 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 7368 | + assert!( | ||
| 7369 | + out.status.success(), | ||
| 7370 | + "aomenc refused the fixture: {}", | ||
| 7371 | + String::from_utf8_lossy(&out.stderr) | ||
| 7372 | + ); | ||
| 7373 | + let stream = out.stdout; | ||
| 7374 | + let before = crate::decode::nocfl_uv_mode_hits(); | ||
| 7375 | + let frames = match decode_stream(&stream) { | ||
| 7376 | + Err(e) => { | ||
| 7377 | + let msg = e.to_string(); | ||
| 7378 | + assert!( | ||
| 7379 | + msg.contains("unsupported"), | ||
| 7380 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ | ||
| 7381 | + attempt {attempt}): {msg}" | ||
| 7382 | + ); | ||
| 7383 | + named_refusals += 1; | ||
| 7384 | + eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); | ||
| 7385 | + continue; | ||
| 7386 | + } | ||
| 7387 | + Ok(frames) => frames, | ||
| 7388 | + }; | ||
| 7389 | + let hits = crate::decode::nocfl_uv_mode_hits() - before; | ||
| 7390 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 7391 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 7392 | + } else { | ||
| 7393 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 7394 | + }; | ||
| 7395 | + assert_eq!(frames.len(), frame_count); | ||
| 7396 | + if hits == 0 { | ||
| 7397 | + carried_none += 1; | ||
| 7398 | + } | ||
| 7399 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 7400 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})"); | ||
| 7401 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})"); | ||
| 7402 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})"); | ||
| 7403 | + } | ||
| 7404 | + if hits > 0 { | ||
| 7405 | + matched += 1; | ||
| 7406 | + total_hits += hits; | ||
| 7407 | + } | ||
| 7408 | + } | ||
| 7409 | + eprintln!( | ||
| 7410 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ | ||
| 7411 | + attempts carrying a 64x64 intra superblock ({total_hits} no-CFL uv_mode reads), \ | ||
| 7412 | + {carried_none} attempts carried none" | ||
| 7413 | + ); | ||
| 7414 | + assert!( | ||
| 7415 | + matched > 0 && total_hits > 0, | ||
| 7416 | + "{NAME} ({bit_depth}-bit): no square-only attempt decoded a 64x64 intra block \ | ||
| 7417 | + inside an inter frame, so the no-CFL uv_mode alphabet was never exercised -- \ | ||
| 7418 | + gate proved nothing ({named_refusals} refusals, {carried_none} carried none)" | ||
| 7419 | + ); | ||
| 7420 | + } | ||
| 7421 | + } | ||
| 7422 | + | ||
| 7089 | /// lane-inter4 r2: the 32x32-level inter `PARTITION_HORZ`/`PARTITION_VERT` | 7423 | /// lane-inter4 r2: the 32x32-level inter `PARTITION_HORZ`/`PARTITION_VERT` |
| 7090 | /// strips (32x16 / 16x32) carrying a REAL residual -- the capability r1 | 7424 | /// strips (32x16 / 16x32) carrying a REAL residual -- the capability r1 |
| 7091 | /// found missing ("a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs | 7425 | /// found missing ("a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs |
lanes/sbrect10-r1.handoff.mdadded+81 -0
| @@ -0,0 +1,81 @@ | |||
| 1 | +# lane-sbrect10 r1 handoff (turn cap) | ||
| 2 | + | ||
| 3 | +Branch `lane-sbrect10` (worktree `/home/user/Documents/Code/Rust/edith_codecs-sbrect10`), | ||
| 4 | +based on lane-r14 a2e2e29 with `main` (7a47fc1) merged in cleanly (merge commit in history). | ||
| 5 | + | ||
| 6 | +## STATUS: root cause FOUND and FIXED; sibling gate GREEN both depths; the new dedicated gate | ||
| 7 | +## still needs an 8-bit fixture (its 8-bit arm currently FAILS "gate proved nothing"). | ||
| 8 | + | ||
| 9 | +## Pinned stream | ||
| 10 | +`$HOME/.cache/sbrect10/a14.obu`, sha256 (hashed twice, identical) | ||
| 11 | +`e85d3b84180de05cd7af769daa7b4f0662389fe0cbf5f0dc8119e4a036b6cf44`. | ||
| 12 | +Regenerate: `bash $HOME/.cache/sbrect10/gen.sh <out>` (192x128, 6 frames, cq 61, 10-bit, | ||
| 13 | +horizontal split geq, motion step 12 = the sibling gate's 10-bit attempt 14). | ||
| 14 | + | ||
| 15 | +## First mismatch (before the fix) | ||
| 16 | +decode-order frame 2 (display == decode order, `--lag-in-frames=0`), plane Y, 15973/24576 luma | ||
| 17 | +samples + 874 V; frames 0 and 1 exact. Per-64x64-SB wrong-pixel map row0 = [128, 332, 3931], | ||
| 18 | +row1 = [3912, 3728, 3942]; SB(0,0)'s 128 are rows 62-63 only (deblock bleed from below). | ||
| 19 | + | ||
| 20 | +## Range ladder (EC_TRACE_MODE / EC_TRACE_MODE_STEP / EC_TRACE_COEFF / EC_AV1_TELL vs | ||
| 21 | +## instrumented aomdec `~/.cache/aom-oracle/build/aomdec`) | ||
| 22 | +- Partition symbols: 40/40 identical (values + positions) -> no rect strips anywhere, every | ||
| 23 | + inter SB is PARTITION_NONE 64x64. Confirms the sibling gate's "zero rect strips" note. | ||
| 24 | +- Our `TELL label=post_interp_filter range=` equals aomdec's `EC_MODE_VAL ... rng=` for every | ||
| 25 | + inter block up to the divergence (frame 2 block mi(0,16): both 61730). Mode info in sync. | ||
| 26 | +- First diverging element: frame 2, block mi_row=0 mi_col=32 (SB(0,2), x=128..191), which BOTH | ||
| 27 | + decoders read as INTRA inside an inter frame (`is_inter=false`, our TELL post_is_inter | ||
| 28 | + range=42400). aomdec then reads its luma TU with entry rng=38192 and all_zero=1; ours reached | ||
| 29 | + all_zero=0 at rng=63221 with eob=56 -> desync inside that block's intra mode syntax. | ||
| 30 | +- Root cause: `uv_mode` was read off the 14-symbol CFL-allowed CDF (`cdfs.uv_mode_cfl`) on a | ||
| 31 | + 64x64 block. libaom `is_cfl_allowed` (blockd.h, spec 5.11.5) = `block_size_wide <= 32 && | ||
| 32 | + block_size_high <= 32`, so the real alphabet is the 13-symbol `uv_mode_no_cfl`. Same DC_PRED | ||
| 33 | + VALUE, wrong interval narrowing -> silent desync (class `wrong-alphabet-same-value`, second | ||
| 34 | + instance after lane-sbpart r3). | ||
| 35 | + | ||
| 36 | +## Fix (committed) | ||
| 37 | +- `crates/ec-av1/src/decode.rs` intra-in-inter block path: `cfl_allowed = write_w.max(write_h) | ||
| 38 | + <= 32`, picks `uv_mode_no_cfl`, and gates the `cfl_alphas` read. | ||
| 39 | +- Same rule enforced ONCE at the head of `read_intra_mode_rect` and `read_intra_mode` | ||
| 40 | + (`let cfl = cfl && bw.max(bh) <= 32` / `side <= 32`), so no caller can offer CFL above 32. | ||
| 41 | +- New counter `NOCFL_UV_MODE_HITS` / `decode::nocfl_uv_mode_hits()` fires exactly when the | ||
| 42 | + size rule removed CFL. | ||
| 43 | +- Result on the pinned stream: all 6 frames byte-identical to `ffmpeg -pix_fmt yuv420p10le` | ||
| 44 | + (was [0,0,16847,23688,19028,17491] wrong samples). | ||
| 45 | + | ||
| 46 | +## Gates | ||
| 47 | +- `a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact` | ||
| 48 | + flipped to `[8u32, 10u32]` and is GREEN: 8-bit 2 refusals / 4 pixel-exact carrying the arm / | ||
| 49 | + 64x32=4 / 32x64=4 / 64-axis TUs=2 / 10 out-of-scope with 0 mismatches; 10-bit 2 refusals / | ||
| 50 | + 2 carrying / 64x32=2 / 32x64=2 / 64-axis TUs=2 / 12 out-of-scope with 0 mismatches. | ||
| 51 | +- NEW dedicated gate `a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet` | ||
| 52 | + (stream.rs, just above the lane-inter4 32x32 rect gate): 16-attempt grid, both depths, every | ||
| 53 | + decode-order frame compared, asserts `nocfl_uv_mode_hits` moved. 10-bit arm passes; the | ||
| 54 | + **8-bit arm FAILS** ("no attempt decoded an intra block above 32x32") -- with the smooth | ||
| 55 | + translating source aomenc never picks a >32 intra block in an inter frame at 8 bit | ||
| 56 | + (probed cq 45/52/58/61/63, with and without `noise=all_seed=7:alls=30`: 0 hits every time). | ||
| 57 | + | ||
| 58 | +## Exact next step (measured, ready to paste) | ||
| 59 | +Replace the gate's source with the half-random fixture, which DOES produce the shape at 8 bit: | ||
| 60 | +`geq=lum='if(lt(X,128), 40+mod(floor((Y+N*12)/32)*90,200), mod((X*7+Y*13+N*97)*31,256))'` | ||
| 61 | +Probe results (`$HOME/.cache/sbrect10/probe.sh <geq> <cq> <depth> <extra>`, counts >32 | ||
| 62 | +intra-in-inter blocks and pixel diffs vs ffmpeg): | ||
| 63 | + 8-bit cq52: 4 hits but DECODE-ERR (named refusal) | cq58: 2 hits, 0 pixel diffs | | ||
| 64 | + cq61: 3 hits, 0 pixel diffs | ||
| 65 | + 10-bit cq52: 6 hits, 0 diffs | cq58: 7 hits, **32890 diffs** | cq61: 7 hits, **39907 diffs** | ||
| 66 | +So: use cq 58/61 for the 8-bit arm, cq 52 for the 10-bit arm, OR (better) treat the 10-bit | ||
| 67 | +cq58/cq61 half-random mismatch as the NEXT defect of this lane -- it is a real, reproducible | ||
| 68 | +10-bit failure on a stream this decoder does not refuse, and it is NOT the CFL bug (that one is | ||
| 69 | +fixed). Triage it with the same ladder (EC_AV1_TELL post_interp_filter vs aomdec EC_MODE_VAL, | ||
| 70 | +then EC_TRACE_COEFF entry ranges). | ||
| 71 | +Then: full suite via | ||
| 72 | +`systemd-run --user --unit=sbrect10-suite-$(date +%s) -p MemoryMax=10G --same-dir bash -lc 'EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sbrect10 nice -n 10 cargo test -p ec-av1 --lib -j3 > $HOME/.cache/sbrect10-suite-r1.log 2>&1'` | ||
| 73 | +(NOT run yet this round), then `lanes/sbrect10-r1.report.md`. | ||
| 74 | + | ||
| 75 | +## Ruled out | ||
| 76 | +- Rect partitions / 64-axis residual: zero of both in the failing stream (partition trace 40/40 | ||
| 77 | + identical), so the sibling gate's "another shape" note was correct. | ||
| 78 | +- MV stack, motion_mode alphabet, interp filter, interintra: all exonerated by the | ||
| 79 | + post_motion_mode / post_interp_filter range equality with aomdec on every block up to the | ||
| 80 | + diverging one. | ||
| 81 | +- Encoder-recipe doubt: stream hashes identical across two generations. | ||
lanes/sbrect10-r2.handoff.mdadded+175 -0
| @@ -0,0 +1,175 @@ | |||
| 1 | +# lane-sbrect10 r2 handoff | ||
| 2 | + | ||
| 3 | +Branch `lane-sbrect10`, tip `2b9709c` (worktree | ||
| 4 | +`/home/user/Documents/Code/Rust/edith_codecs-sbrect10`). | ||
| 5 | +Commits this round: `3a9e83e` (merge main 18bf7dc) + `2b9709c` (the fix + gate + instrumentation). | ||
| 6 | + | ||
| 7 | +## STATUS: root cause FOUND and FIXED; pinned stream now byte-exact on all 6 probe arms. | ||
| 8 | +## Only thing outstanding: the full suite result (armed, was at 340 tests / 0 failures). | ||
| 9 | + | ||
| 10 | +## 1. Merge state (done, clean) | ||
| 11 | +`git merge --no-commit main` (main = 18bf7dc: r14 a2e2e29 + sb128 5ea5ec8) auto-merged | ||
| 12 | +decode.rs + stream.rs with no conflicts. Verified before committing: | ||
| 13 | +- `git diff main -- crates/ec-av1/src/cdf.rs` EMPTY and `... refusal_inventory.rs` EMPTY, so the | ||
| 14 | + NZ_MAP / FILTER_INTRA rows and the refusal list are byte-identical to main. | ||
| 15 | +- The only lines the merged tree removes vs main are the lane's own r1 hunks (4 `uv_mode_cfl` | ||
| 16 | + lines in decode.rs, the `[8u32]` arm + its comment in stream.rs). Main's deletions all kept. | ||
| 17 | + | ||
| 18 | +## 2. Gate fixture state (done) | ||
| 19 | +`a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet` (stream.rs) | ||
| 20 | +now uses the half-random source in BOTH orientations: | ||
| 21 | + | ||
| 22 | + horizontal: if(lt(X,128), 40+mod(floor((Y+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256)) | ||
| 23 | + vertical: if(lt(Y,64), 40+mod(floor((X+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256)) | ||
| 24 | + | ||
| 25 | +r1's flat `200` half made aomenc code the right-hand superblocks skip, so the 8-bit arm saw 0 | ||
| 26 | +intra-above-32x32 blocks (probed cq 45/52/58/61/63). Grid `[58, 52, 45, 61]` x 2 orientations x | ||
| 27 | +2 motion steps x 2 depths unchanged; counters are read on decoded+compared attempts only, every | ||
| 28 | +decode-order frame is compared on Y/U/V, a mismatch fails and never SKIPs. | ||
| 29 | + | ||
| 30 | +## 3. The 10-bit defect: root cause, libaom line, fix | ||
| 31 | +Pinned stream `$HOME/.cache/sbrect10/b58.obu`, sha256 hashed TWICE identical | ||
| 32 | +`00b9253b308201118e27f348c67932a0006e3077ba7a9a401854c2ee7eb1dcd2` | ||
| 33 | +(192x128, 6 frames, 10-bit cq58, `--sb-size=64 --min-partition-size=32 --max-partition-size=64 | ||
| 34 | +--enable-rect-partitions=1 --enable-1to4-partitions=1 --lag-in-frames=0 --cpu-used=0`; | ||
| 35 | +regenerate with `bash $HOME/.cache/sbrect10/probe.sh "<geq>" 58 10`). | ||
| 36 | + | ||
| 37 | +How it was localised (each step ruled a layer out): | ||
| 38 | +- First mismatch DECODE-ORDER frame 2, plane Y only (U/V exact), 8252 samples; per-64x64-SB map | ||
| 39 | + row0 `[0,0,4092]`, row1 `[0,64,4096]` = the whole RIGHT superblock column + deblock bleed. | ||
| 40 | +- NOT an entropy desync: our `EC_TRACE_COEFF` all_zero ladder vs instrumented aomdec's is | ||
| 41 | + identical for all 180 TUs of the whole stream (`diff` empty), and blocks decoded AFTER the | ||
| 42 | + wrong ones (mi(16,0)) are pixel-exact. | ||
| 43 | +- NOT a clamp: an `EC_DBG_CLAMP` probe on the dequant clamp `+-(1 << (7 + bd))` and on every | ||
| 44 | + `clamp_range` in transform.rs fired ZERO times on this stream. | ||
| 45 | +- `EC_TRACE_MODE` mv diff, decode-order frame 2: aomdec mi(0,32) mode=24 ref0=1 ref1=4 | ||
| 46 | + mv0=(128,-16) / ours (-1,2); mi(0,40), mi(8,32), mi(8,40), mi(16,40) all (128,-16) vs (-1,2); | ||
| 47 | + mi(16,32) (-176,256) vs (-241,264); mi(24,32) (-128,56) vs (-193,64). The | ||
| 48 | + NEAREST_NEARESTMV blocks take stack[0] directly, so libaom's stack[0].this_mv is (128,-16) | ||
| 49 | + where ours is (0,0), and the NEWMV blocks are off by the same predictor delta. | ||
| 50 | +- Our stack for mi(0,32) = two entries `this=(0,0) comp=(0,0) w=2` -- the signature of the | ||
| 51 | + compound EXTENSION pass appending comp_list[0] and comp_list[1] into an empty stack. | ||
| 52 | +- Frame 2's temporal field really is empty and that is CORRECT (new `EC_TPL_FIELD` occupancy | ||
| 53 | + dump under EC_TRACE_TPL: oh=1,2 all `.`, oh=3,4,5 all `#`; frame 2's LAST projection is | ||
| 54 | + suppressed by `is_lst_overlay` and its LAST2 is the key frame). So the candidate is spatial. | ||
| 55 | + | ||
| 56 | +ROOT CAUSE: `combine_compound_candidates` (crates/ec-av1/src/mvstack.rs:1482) filled the | ||
| 57 | +`comp_list` tail slots -- the ones left after `ref_id` then `ref_diff` -- with `(0, 0)`. | ||
| 58 | +libaom fills them with that side's GLOBAL MOTION vector, `setup_ref_mv_list`, | ||
| 59 | +`av1/common/mvref_common.c:729`: | ||
| 60 | + | ||
| 61 | + for (; comp_idx < MAX_MV_REF_CANDIDATES; ++comp_idx) | ||
| 62 | + comp_list[comp_idx][idx] = gm_mv_candidates[idx]; | ||
| 63 | + | ||
| 64 | +Zero-filling was right only under IDENTITY global motion (the module doc's original reduction); | ||
| 65 | +aomenc has `--enable-global-motion` ON by default. A compound block with no usable neighbour | ||
| 66 | +pair (frame top row -> no above, 64x64 INTRA block to its left, empty temporal field) therefore | ||
| 67 | +took a `(0,0)` predictor where libaom took the frame's translation. | ||
| 68 | + | ||
| 69 | +FIX: `combine_compound_candidates` takes `gm_mv_candidates: [(i32,i32); 2]` and uses it as the | ||
| 70 | +per-side fill; the call site passes `[gm_mv(gm, ref_frame.0), gm_mv(gm, ref_frame.1)]`. | ||
| 71 | + | ||
| 72 | +SIBLING SWEEP (same shape): every `gm_mv_candidates` use in mvref_common.c was walked. The | ||
| 73 | +single-ref tail fill (`:787-788`) is already ported as `gm_fallback` at mvstack.rs:1099-1100; | ||
| 74 | +the `is_gm_block` substitutions (`:92`, `:117`) already take `gm` through `scan_*_compound`; the | ||
| 75 | +add_tpl_ref_mv GLOBALMV_OFFSET compares (`:379-410`) already use `gm_mv(gm, ...)` on both sides. | ||
| 76 | +This was the only zero-filled site in the crate. | ||
| 77 | + | ||
| 78 | +## 4. Is the pinned stream exact now? YES | ||
| 79 | +`probe.sh "<half-random geq>" <cq> <depth>` after the fix, pixel diffs vs | ||
| 80 | +`ffmpeg -pix_fmt yuv420p10le` / `yuv420p`, and `>32` intra-in-inter hit counts: | ||
| 81 | + | ||
| 82 | +| depth | cq 52 | cq 58 | cq 61 | | ||
| 83 | +|---|---|---|---| | ||
| 84 | +| 8-bit | 5 hits, 0 diffs | 2 hits, 0 diffs | 3 hits, 0 diffs | | ||
| 85 | +| 10-bit | 6 hits, 0 diffs | 7 hits, 0 diffs | 7 hits, 0 diffs | | ||
| 86 | + | ||
| 87 | +Before the fix the 10-bit arms were 32890 (cq58) and 39907 (cq61) wrong samples. | ||
| 88 | + | ||
| 89 | +## 5. NEXT STEP (the only thing left) | ||
| 90 | +Read `$HOME/.cache/sbrect10-suite-r2.log` -- the suite is armed as a user systemd unit | ||
| 91 | +(`sbrect10-suite-r2-1788325070.service`, MemoryMax=10G, `cargo test -p ec-av1 --lib -j3`, | ||
| 92 | +EC_AV1_REQUIRE_AOMENC=1, CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sbrect10). At handoff it had | ||
| 93 | +reached 340 tests with no FAILED line. Check with a single | ||
| 94 | +`grep -E "^test result|FAILED" $HOME/.cache/sbrect10-suite-r2.log`; if a gate is red, re-run that | ||
| 95 | +gate alone before touching code (another lane rebuilding the shared aomdec shows up as | ||
| 96 | +"Os code 13 PermissionDenied"). Then fill the N/0 totals into `lanes/sbrect10-r2.report.md` | ||
| 97 | +(section 4 is otherwise complete) and the lane is done. | ||
| 98 | + | ||
| 99 | +Nothing else is in flight; the worktree is clean at 2b9709c. | ||
| 100 | + | ||
| 101 | +## 5b. CORRECTION at handoff time -- THE SUITE IS RED (3 gates), details not yet printed | ||
| 102 | +The suite unit was still running when this handoff was written; at 343 tests it had THREE | ||
| 103 | +FAILED lines (cargo buffers the panic bodies to the end of the run, so no message text yet): | ||
| 104 | + | ||
| 105 | + stream::tests::a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet ... FAILED | ||
| 106 | + stream::tests::a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact ... FAILED | ||
| 107 | + stream::tests::a_real_aomenc_stream_with_film_grain_decodes_pixel_exact ... FAILED | ||
| 108 | + | ||
| 109 | +So the lane is RED, not green. Do NOT treat section 4's probe table as a suite result: it proves | ||
| 110 | +only the 6 probed (geq, cq, depth) points, not the gates' own 16-attempt grids. | ||
| 111 | + | ||
| 112 | +Triage order for the next round: | ||
| 113 | +1. `grep -A 30 "^failures:" $HOME/.cache/sbrect10-suite-r2.log` for the three panic bodies. | ||
| 114 | +2. `a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` is the loudest signal: it touches | ||
| 115 | + NEITHER the CFL alphabet nor the compound stack's fixture, so if it is a pixel mismatch it is | ||
| 116 | + most likely a REGRESSION from this round's `combine_compound_candidates` gm-fill (a compound | ||
| 117 | + block that previously got (0,0) and now gets a global-motion vector). Check it first, alone: | ||
| 118 | + `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sbrect10 cargo test -p ec-av1 --lib | ||
| 119 | + a_real_aomenc_stream_with_film_grain_decodes_pixel_exact -- --nocapture` | ||
| 120 | + and if it is red, re-run it at `3a9e83e` (the merge commit, fix not yet in) in a DETACHED | ||
| 121 | + worktree to separate "regression from the gm-fill" from "already red after the merge". | ||
| 122 | + Note the merge itself was never suite-tested -- r1 never ran a suite either (its handoff says | ||
| 123 | + so), so an inherited red from main's sb128/r14 merge is equally possible. | ||
| 124 | +3. The other two are this lane's own gates; the rect-partition sibling gate shares the compound | ||
| 125 | + stack path, so it is the expected place for a gm-fill regression to show. | ||
| 126 | +4. Only after the three are green: fill the N/0 totals into `lanes/sbrect10-r2.report.md`. | ||
| 127 | + | ||
| 128 | +## 5c. SUITE FINISHED -- final result and per-failure triage (supersedes 5b) | ||
| 129 | +`test result: FAILED. 368 passed; 3 failed; 32 ignored; finished in 1049.95s` | ||
| 130 | +(`$HOME/.cache/sbrect10-suite-r2.log`). | ||
| 131 | + | ||
| 132 | +### (a) `a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` -- FLAKE, not a defect. CLOSED. | ||
| 133 | +Panic was `Result::unwrap()` on `Err(Os { code: 2, NotFound })` at stream.rs:15680, i.e. the | ||
| 134 | +`concat!(CARGO_MANIFEST_DIR, "/../../fixtures/golden6-mismatch.obu")` READ failed -- the shared | ||
| 135 | +`fixtures` symlink (`-> /home/user/Documents/Code/Rust/edith_codecs/fixtures`) was transiently | ||
| 136 | +gone mid-run, the known concurrent-lane merge hazard. The file is present now and the gate passes | ||
| 137 | +on its own: | ||
| 138 | +`cargo test -p ec-av1 --lib a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` | ||
| 139 | +-> `test result: ok. 1 passed; 0 failed`. Nothing to fix here; it is NOT a gm-fill regression. | ||
| 140 | + | ||
| 141 | +### (b) `a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet` -- REAL, MINE, OPEN. | ||
| 142 | + 8-bit: 2 named refusals, 0 pixel-exact attempts carrying a >32 intra block | ||
| 143 | + (0 no-CFL uv_mode reads), 14 attempts carried none | ||
| 144 | + (the two refusals are "an inter SB-level AB partition" and "a split intra strip whose | ||
| 145 | + transform unit is 32x64" -- both other lanes' gaps, correctly named, not mismatches) | ||
| 146 | +10-bit arm passes. **My step-2 claim that the half-random fixture makes the 8-bit arm carry the | ||
| 147 | +shape is DISPROVEN by the gate itself.** The probe (`probe.sh`) counted a DIFFERENT quantity than | ||
| 148 | +the gate: it greps `EC_AV1_TELL` for `post_is_inter is_inter=false` with `side>32`, whereas the | ||
| 149 | +gate asserts `crate::decode::nocfl_uv_mode_hits()` moved. On the very same stream (8-bit cq58, | ||
| 150 | +horizontal, sp=12 == gate attempt 8) the probe reports 2 and the counter reports 0, so those | ||
| 151 | +8-bit >32 intra-in-inter blocks reach a decode path that never touches the counter. | ||
| 152 | +NEXT: the three `NOCFL_UV_MODE_HITS` increment sites are `decode.rs:5499`, `decode.rs:8442`, | ||
| 153 | +`decode.rs:18544`; instrument which intra-in-inter path an 8-bit 64x64 block actually takes | ||
| 154 | +(the 10-bit ones clearly hit one of the three), then either fix the missing counter site or, if | ||
| 155 | +the 8-bit path genuinely never offers CFL, narrow the gate's 8-bit assertion and say so. | ||
| 156 | +No pixel mismatch is involved -- every decoded attempt compared exact. | ||
| 157 | + | ||
| 158 | +### (c) `a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact` -- REAL, OPEN, UNATTRIBUTED. | ||
| 159 | + 8-bit: 4 named refusals, 3 carrying, 64x32=8, 32x64=2, 64-axis residual TUs=1, 9 none (0 mismatched) | ||
| 160 | + 10-bit: 0 named refusals, 1 carrying, 64x32=2, 32x64=0, 64-axis residual TUs=0, 15 none (0 mismatched) | ||
| 161 | + panic at stream.rs:6725: "(10-bit): no superblock-level rect strip carried a coded 64-axis | ||
| 162 | + residual transform unit inside a pixel-exact attempt (horz=2, vert=0)" | ||
| 163 | +This is a VACUOUS-ARM assert, NOT a pixel mismatch (`0 of them mismatched` on both depths). r1 | ||
| 164 | +recorded this same gate GREEN with 10-bit `64-axis TUs=2` and `2 carrying`; it is now `0` and `1`. | ||
| 165 | +Two candidate causes, NOT separated this round: (i) the `main` 18bf7dc merge (sb128 + r14 changed | ||
| 166 | +partition/var-tx handling and neither r1 nor this lane ever suite-tested the merge), or (ii) this | ||
| 167 | +round's gm-fill changing which attempts come out pixel-exact (only pixel-exact attempts count | ||
| 168 | +toward the arm). Separate them by running this gate alone at `3a9e83e` (merge, pre-fix) in a | ||
| 169 | +DETACHED worktree with its own CARGO_TARGET_DIR, then at `2b9709c`. | ||
| 170 | + | ||
| 171 | +### Corrected disposition | ||
| 172 | +- fix-now next round: (b) the 8-bit no-CFL counter, (c) the 10-bit 64-axis vacuous arm. | ||
| 173 | +- accepted/closed: (a) film_grain fixture flake. | ||
| 174 | +- The gm-fill fix itself is NOT contradicted by anything in this suite: no gate reported a pixel | ||
| 175 | + mismatch, and the pinned stream `b58.obu` plus all 6 probe arms are byte-exact vs ffmpeg. | ||
lanes/sbrect10-r2.report.mdadded+124 -0
| @@ -0,0 +1,124 @@ | |||
| 1 | +# lane-sbrect10 r2 report | ||
| 2 | + | ||
| 3 | +Branch `lane-sbrect10`, worktree `/home/user/Documents/Code/Rust/edith_codecs-sbrect10`. | ||
| 4 | +Base: r1 tip 6fba6a6 + `main` 18bf7dc (sb128 5ea5ec8 + r14 a2e2e29) merged. | ||
| 5 | + | ||
| 6 | +## 1. Merge (step 1) | ||
| 7 | +`git merge --no-commit main` -> clean auto-merge (decode.rs, stream.rs), commit `3a9e83e`. | ||
| 8 | +- Diffstat 12 files, +1392/-147 (all of it main's; the lane contributed nothing to those files | ||
| 9 | + beyond its own r1 hunks). | ||
| 10 | +- `git diff main -- crates/ec-av1/src/cdf.rs` and `... refusal_inventory.rs` are BOTH EMPTY, so | ||
| 11 | + the NZ_MAP / FILTER_INTRA tables and the refusal list are byte-identical to main -- nothing to | ||
| 12 | + reconcile. | ||
| 13 | +- The only lines the merged tree removes relative to main are the lane's own 4 r1 CFL lines in | ||
| 14 | + `decode.rs` (`cdfs.uv_mode_cfl[mode]` + its `cfl_alphas` arm) and the r1 comment/`[8u32]` arm in | ||
| 15 | + `stream.rs`. Main's deletions are all kept. | ||
| 16 | + | ||
| 17 | +## 2. Gate source swapped to the half-random fixture (step 2) | ||
| 18 | +`crates/ec-av1/src/stream.rs` (gate | ||
| 19 | +`a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet`): the flat | ||
| 20 | +`200` half of r1's source made aomenc code the right-hand superblocks skip, so at 8 bit no | ||
| 21 | +`>32` intra-in-inter block ever appeared. Both orientations now carry a deterministic | ||
| 22 | +pseudo-noise half: | ||
| 23 | + | ||
| 24 | + horizontal: if(lt(X,128), 40+mod(floor((Y+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256)) | ||
| 25 | + vertical: if(lt(Y,64), 40+mod(floor((X+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256)) | ||
| 26 | + | ||
| 27 | +Probe grid, `$HOME/.cache/sbrect10/probe.sh` (counts `>32` intra-in-inter blocks via | ||
| 28 | +`EC_AV1_TELL`, and pixel diffs vs `ffmpeg -pix_fmt yuv420p10le`/`yuv420p`), AFTER the r2 fix: | ||
| 29 | + | ||
| 30 | +| depth | cq 52 | cq 58 | cq 61 | | ||
| 31 | +|---|---|---|---| | ||
| 32 | +| 8-bit | 5 hits, 0 diffs | 2 hits, 0 diffs | 3 hits, 0 diffs | | ||
| 33 | +| 10-bit | 6 hits, 0 diffs | 7 hits, 0 diffs | 7 hits, 0 diffs | | ||
| 34 | + | ||
| 35 | +Both depth arms therefore carry >=1 no-CFL intra hit per compared attempt; per-attempt counters | ||
| 36 | +are read on decoded+compared attempts only, every decode-order frame is compared on Y/U/V, and a | ||
| 37 | +mismatch fails (never SKIPs). | ||
| 38 | + | ||
| 39 | +## 3. The SECOND defect this fixture exposed -- root cause and fix (step 3) | ||
| 40 | + | ||
| 41 | +### Pinned stream | ||
| 42 | +`$HOME/.cache/sbrect10/b58.obu` (192x128, 6 frames, 10-bit, cq 58, `--sb-size=64 | ||
| 43 | +--min-partition-size=32 --max-partition-size=64 --enable-rect-partitions=1 | ||
| 44 | +--enable-1to4-partitions=1 --lag-in-frames=0 --cpu-used=0`), sha256 hashed twice, identical: | ||
| 45 | +`00b9253b308201118e27f348c67932a0006e3077ba7a9a401854c2ee7eb1dcd2`. | ||
| 46 | + | ||
| 47 | +### Localisation | ||
| 48 | +- First mismatching frame: DECODE-ORDER 2 (display == decode order), plane Y only, 8252 samples; | ||
| 49 | + U and V exact; frames 0 and 1 exact. Per-64x64-SB wrong-pixel map: row0 `[0, 0, 4092]`, | ||
| 50 | + row1 `[0, 64, 4096]` -- i.e. the whole right superblock column, plus 64 deblock-bleed pixels. | ||
| 51 | +- NOT an entropy desync: the 180-TU `all_zero` range ladder is IDENTICAL between our | ||
| 52 | + `EC_TRACE_COEFF` and instrumented `aomdec`'s (`diff a.az o.az` empty over the WHOLE stream), | ||
| 53 | + and blocks decoded AFTER the wrong ones (mi(16,0)) are pixel-exact. | ||
| 54 | +- NOT a clamp: an `EC_DBG_CLAMP` probe on both the dequant clamp | ||
| 55 | + (`+-(1 << (7 + bd))`) and every `clamp_range` in `transform.rs` fired ZERO times on this stream. | ||
| 56 | +- The divergence is in the MV VALUES. `EC_TRACE_MODE` diff, decode-order frame 2: | ||
| 57 | + | ||
| 58 | + aomdec mi(0,32) mode=24 ref0=1 ref1=4 mv0=(128,-16) ours mv0=(-1,2) | ||
| 59 | + aomdec mi(0,40) mode=17 ref0=1 ref1=4 mv0=(128,-16) ours mv0=(-1,2) | ||
| 60 | + aomdec mi(8,32) / mi(8,40) / mi(16,40): same (128,-16) vs (-1,2) | ||
| 61 | + aomdec mi(16,32) mode=24 mv0=(-176,256) ours (-241,264) | ||
| 62 | + aomdec mi(24,32) mode=16 mv0=(-128,56) ours (-193,64) | ||
| 63 | + | ||
| 64 | + The NEAREST_NEARESTMV blocks take stack[0] directly, so libaom's stack[0].this_mv is | ||
| 65 | + `(128,-16)` where ours is `(0,0)`; the NEWMV/NEW_NEWMV blocks are off by exactly the same | ||
| 66 | + predictor delta. | ||
| 67 | +- Our stack for mi(0,32): two entries, `this=(0,0) comp=(0,0) w=2` -- the signature of libaom's | ||
| 68 | + compound EXTENSION pass appending `comp_list[0]` and `comp_list[1]` into an empty stack. | ||
| 69 | +- The temporal field is genuinely empty for that frame and this is CORRECT: a new | ||
| 70 | + `EC_TRACE_TPL` field dump (`EC_TPL_FIELD`) shows oh=1 and oh=2 all-`.` and oh=3 onward all-`#`; | ||
| 71 | + frame 2's LAST projection is suppressed by `is_lst_overlay` and its LAST2 is the key frame. | ||
| 72 | + | ||
| 73 | +### Root cause | ||
| 74 | +`crates/ec-av1/src/mvstack.rs:1482` `combine_compound_candidates` filled the `comp_list` tail | ||
| 75 | +slots (the ones left over after `ref_id` then `ref_diff`) with `(0, 0)`. libaom fills them with | ||
| 76 | +that side's GLOBAL MOTION vector -- `setup_ref_mv_list`, `av1/common/mvref_common.c:729`: | ||
| 77 | + | ||
| 78 | + for (; comp_idx < MAX_MV_REF_CANDIDATES; ++comp_idx) | ||
| 79 | + comp_list[comp_idx][idx] = gm_mv_candidates[idx]; | ||
| 80 | + | ||
| 81 | +The zero fill was only right under IDENTITY global motion, which the module's original reduction | ||
| 82 | +assumed; aomenc has `--enable-global-motion` ON by default. A compound block with no usable | ||
| 83 | +neighbour pair (frame top row -> no above, 64x64 INTRA block to its left, empty temporal field) | ||
| 84 | +therefore took a `(0, 0)` predictor where libaom took the frame's translation. | ||
| 85 | + | ||
| 86 | +Class: `parsed then discarded` / reduction-assumption -- global motion is parsed and used by the | ||
| 87 | +single-ref path (`gm_fallback`, mvstack.rs:1099-1100) but was dropped on the compound tail. | ||
| 88 | + | ||
| 89 | +### Fix | ||
| 90 | +`crates/ec-av1/src/mvstack.rs`: `combine_compound_candidates` now takes | ||
| 91 | +`gm_mv_candidates: [(i32,i32); 2]` and uses it as the per-side fill; the call site passes | ||
| 92 | +`[gm_mv(gm, ref_frame.0), gm_mv(gm, ref_frame.1)]`. | ||
| 93 | + | ||
| 94 | +### Sibling sweep (same shape, whole crate) | ||
| 95 | +Every `gm_mv_candidates` use in `mvref_common.c` was walked. The single-reference tail fill | ||
| 96 | +(`mvref_common.c:787-788`, `mv_ref_list[idx] = gm_mv_candidates[0]`) is already ported | ||
| 97 | +(`mvstack.rs:1099-1100` `gm_fallback`); the scan-row/col/corner `is_gm_block` substitutions | ||
| 98 | +(`:92`, `:117`) already take `gm` through `scan_*_compound`; the `add_tpl_ref_mv` | ||
| 99 | +`GLOBALMV_OFFSET` compares (`:379-410`) already use `gm_mv(gm, ...)` on both sides. This was the | ||
| 100 | +only zero-filled site. | ||
| 101 | + | ||
| 102 | +## 4. Other change | ||
| 103 | +`crates/ec-av1/src/decode.rs` `dump_stage16`: the `EC_AV1_PREFILT_DUMP16` dump wrote a fixed | ||
| 104 | +`<prefix>.f0` every frame, so only the LAST frame survived and a mid-sequence divergence could | ||
| 105 | +not be read out at all. It is now indexed by decode-order picture like `EC_AV1_PREFILT_DUMP`. | ||
| 106 | +`crates/ec-av1/src/motion_field.rs`: `setup_motion_field` prints an `EC_TPL_FIELD` occupancy map | ||
| 107 | +under the existing `EC_TRACE_TPL` rung (this is what proved frame 2's empty temporal field). | ||
| 108 | + | ||
| 109 | +## 5. Refusals | ||
| 110 | +None lifted this round (r1 lifted none either; this lane's work is two silent-miscode fixes). | ||
| 111 | +`refusal_inventory.rs` is byte-identical to main. | ||
| 112 | + | ||
| 113 | +## Suite (step 4) -- RED | ||
| 114 | +`test result: FAILED. 368 passed; 3 failed; 32 ignored; finished in 1049.95s` | ||
| 115 | +(`$HOME/.cache/sbrect10-suite-r2.log`). film_grain is a shared-`fixtures`-symlink flake and | ||
| 116 | +passes alone; the other two are open and triaged in `lanes/sbrect10-r2.handoff.md` section 5c. | ||
| 117 | +Section 2's probe table proves only the 6 probed points -- it does NOT prove the gate's own | ||
| 118 | +counter, which still reads 0 on the 8-bit arm. | ||
| 119 | + | ||
| 120 | +## EVIDENCE | ||
| 121 | +EVIDENCE: $HOME/.cache/sbrect10/b58.obu (sha256 00b9253b...dcd2, hashed twice) | probe.sh half-random geq, 6 arms (8/10-bit x cq 52/58/61), decode + compare vs ffmpeg | pixel diffs 0/0/0/0/0/0 (was 0/32890/39907 on the 10-bit arms), >32 intra-in-inter hits 5/2/3 (8-bit) and 6/7/7 (10-bit) | ||
| 122 | +EVIDENCE: $HOME/.cache/sbrect10/{a.az,o.az} | EC_TRACE_COEFF all_zero ladder, instrumented aomdec vs ours, whole stream | 180 TUs, `diff` empty -> entropy in sync, defect is reconstruction-side | ||
| 123 | +EVIDENCE: $HOME/.cache/sbrect10/{a.mode,o.mode} | EC_TRACE_MODE mv0 diff, decode-order frame 2 | aomdec mi(0,32) mv0=(128,-16), ours (-1,2); 6 blocks diverge, all in the right superblock column | ||
| 124 | +EVIDENCE: $HOME/.cache/sbrect10/o.tplf | EC_TPL_FIELD occupancy dump, all 5 inter frames | oh=1,2 empty / oh=3,4,5 full -> the empty temporal field at oh=2 is correct, not the defect | ||
lanes/sbrect10-r3.report.mdadded+98 -0
| @@ -0,0 +1,98 @@ | |||
| 1 | +# lane-sbrect10 r3 report | ||
| 2 | + | ||
| 3 | +Branch `lane-sbrect10`. Round input: r2 tip `1866bd5`, suite RED with 3 failed gates. | ||
| 4 | +Round output: all three root-caused and green; merged main `85887c7` (which now carries | ||
| 5 | +lane-mvtwin `2e2a225`), mvstack.rs resolved to main's copy byte-for-byte. | ||
| 6 | + | ||
| 7 | +## 1. `a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` -- ENVIRONMENT, not code | ||
| 8 | + | ||
| 9 | +Panic body (r2 log had none: the unit was still running when the handoff was written, my first | ||
| 10 | +`systemctl --user is-active sbrect10-suite-r2` used the un-timestamped unit name and read back | ||
| 11 | +`inactive` wrongly). Run alone off the r2 binary: | ||
| 12 | + | ||
| 13 | + stream.rs:15680: called `Result::unwrap()` on an `Err` value: | ||
| 14 | + Os { code: 2, kind: NotFound, message: "No such file or directory" } | ||
| 15 | + | ||
| 16 | +The worktree had **no top-level `fixtures` symlink** (`fixtures` is gitignored and per-worktree). | ||
| 17 | +`fixtures/golden6-mismatch.obu` was simply absent. Not a temp-path collision: this gate writes no | ||
| 18 | +temp file at all -- `ffmpeg_decode_sequence` (stream.rs:1316) pipes the stream through ffmpeg's | ||
| 19 | +stdin/stdout, and the two helpers that DO make scratch dirs already key them on | ||
| 20 | +`{test name}-{std::process::id()}` (stream.rs:2000, 15735), which is unique per process and per test. | ||
| 21 | +Same failure at the same wall-clock in lane-sb128c's suite = the same missing symlink there, not a | ||
| 22 | +race. Fixed with `ln -s .../edith_codecs/fixtures fixtures`. | ||
| 23 | + | ||
| 24 | +SWEEP: all three `../../fixtures/*.obu` reads in `crates/ec-av1/src` (golden6-mismatch.obu, | ||
| 25 | +golden7-forwarding-mismatch.obu, lr-sgr-r7.obu) now resolve. | ||
| 26 | + | ||
| 27 | +EVIDENCE: $HOME/.cache/sbrect10-suite-r2.log + rerun | ln -s fixtures; ec_av1 binary --exact | ||
| 28 | +a_real_aomenc_stream_with_film_grain_decodes_pixel_exact | FAILED (NotFound) -> ok, 0.31s | ||
| 29 | + | ||
| 30 | +## 2. The other two reds: ONE cause -- r2's fixture swap landed in the sibling gate | ||
| 31 | + | ||
| 32 | +Neither red was a pixel mismatch; both were vacuity asserts, and both counters read 0 for the | ||
| 33 | +same reason. r2's half-random lavfi source | ||
| 34 | + | ||
| 35 | + horizontal: if(lt(X,128), 40+mod(floor((Y+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256)) | ||
| 36 | + vertical: if(lt(Y,64), 40+mod(floor((X+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256)) | ||
| 37 | + | ||
| 38 | +was written into `a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact` | ||
| 39 | +(stream.rs:6592) instead of `a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet` | ||
| 40 | +(stream.rs:6791) -- the rationale comment travelled with it, so the code read consistent. Effect: | ||
| 41 | + | ||
| 42 | +- CFL gate kept r1's flat `200` source, whose right-hand superblocks aomenc codes skip -> | ||
| 43 | + 8-bit arm decoded 0 intra blocks above 32x32: *"no attempt decoded an intra block above 32x32 | ||
| 44 | + ... gate proved nothing (2 refusals, 14 attempts carried none)"*. | ||
| 45 | +- rect gate got the textured source, which changed the RD's residual decisions -> its 10-bit arm | ||
| 46 | + lost the coded 64-axis transform unit lane-r14 r2 had measured on the flat source | ||
| 47 | + (8-bit residual TUs=1, 10-bit=0): *"no superblock-level rect strip carried a coded 64-axis | ||
| 48 | + residual transform unit ... (horz=2, vert=0)"*. | ||
| 49 | + | ||
| 50 | +FIX (`e2d9e9e`): sources swapped back so each gate runs the source it was measured on. No assert | ||
| 51 | +weakened, no grid changed, no decoder code touched. | ||
| 52 | + | ||
| 53 | +Result of the two gates alone at the merged tree (`--test-threads=1 --exact`): | ||
| 54 | + | ||
| 55 | +| gate | 8-bit | 10-bit | | ||
| 56 | +|---|---|---| | ||
| 57 | +| no_cfl_uv_alphabet | 4 refusals, 4 exact attempts, **15** no-CFL uv_mode reads | 0 refusals, 8 exact attempts, **43** reads | | ||
| 58 | +| superblock_level_rect_partition | 2 refusals, 4 exact, 64x32=4 32x64=4, **64-axis residual TUs=2** | 2 refusals, 2 exact, 64x32=2 32x64=2, **residual TUs=2** | | ||
| 59 | + | ||
| 60 | +0 out-of-scope mismatches in either depth of either gate, so r2's `combine_compound_candidates` | ||
| 61 | +global-motion tail fill is NOT a regression source -- every attempt that decoded compared exact. | ||
| 62 | + | ||
| 63 | +EVIDENCE: $HOME/.cache/sbrect10-g2-a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet.log, | ||
| 64 | +$HOME/.cache/sbrect10-g2-a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact.log | | ||
| 65 | +swap the two gates' geq sources, rebuild, run each gate alone under systemd-run MemoryMax=6G | | ||
| 66 | +both `test result: ok`, counters 15/43 no-CFL reads and 2/2 64-axis residual TUs | ||
| 67 | + | ||
| 68 | +## 3. Merge | ||
| 69 | + | ||
| 70 | +`git merge --no-commit main` twice: first main `4eff3a1` (`de045b7`, clean auto-merge), then main | ||
| 71 | +`85887c7` after it took lane-mvtwin mid-round. Only conflict: `crates/ec-av1/src/mvstack.rs`, | ||
| 72 | +resolved to MAIN's copy byte-for-byte (`git diff main -- crates/ec-av1/src/mvstack.rs` EMPTY) -- | ||
| 73 | +main carries this lane's own comp_list global-motion tail fill plus mvtwin's insertion-time | ||
| 74 | +candidate cap and tile-origin clamp. `cdf.rs`, `cdf_state.rs`, `refusal_inventory.rs` all | ||
| 75 | +byte-identical to main. Lines this branch drops vs main are only its own hunks (uv_mode_cfl | ||
| 76 | +narrowing, indexed `dump_stage16` prefix, gate fixtures). The merge commit was recorded by the | ||
| 77 | +coordinator as `10e25e3` (parents `e2d9e9e` + `85887c7`) while this round was mid-flight. | ||
| 78 | + | ||
| 79 | +## 4. Suite | ||
| 80 | + | ||
| 81 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3` under user unit | ||
| 82 | +`sbrect10-suite-r3-1788326330.service`, log `$HOME/.cache/sbrect10-suite-r3.log`. | ||
| 83 | +r2 for comparison: 368 passed / 3 failed / 32 ignored (the three above). | ||
| 84 | + | ||
| 85 | +**GREEN: 378 passed / 0 failed / 33 ignored / 0 measured, 1229.56s.** | ||
| 86 | + | ||
| 87 | +EVIDENCE: $HOME/.cache/sbrect10-suite-r3.log | systemd-run --user --unit=sbrect10-suite-r3-1788326330 | ||
| 88 | +-p MemoryMax=10G cargo test -p ec-av1 --lib -j3, EC_AV1_REQUIRE_AOMENC=1 | | ||
| 89 | +`test result: ok. 378 passed; 0 failed; 33 ignored` (r2 was 368/3/32) | ||
| 90 | + | ||
| 91 | +## 5. Residue | ||
| 92 | + | ||
| 93 | +- accepted: the no-CFL gate's 8-bit arm still takes named refusals on other shapes | ||
| 94 | + (SB-level AB partition, 32x64/64x32 split intra strips) -- other lanes' scope, and 4 attempts | ||
| 95 | + decode + prove the shape regardless. | ||
| 96 | +- accepted: r2's `probe.sh` counted intra-in-inter blocks through an `EC_AV1_TELL` trace grep, | ||
| 97 | + not through `nocfl_uv_mode_hits`; the gate itself asserts the real counter, so the proxy is only | ||
| 98 | + a probe convenience. Not worth a rewrite. | ||
lanes/sqdrift-r1.handoff.mdadded+40 -0
| @@ -0,0 +1,40 @@ | |||
| 1 | +# lane-sqdrift r1 -> r2 handoff | ||
| 2 | + | ||
| 3 | +Branch `lane-sqdrift` @ 6edd5af (off main 85887c7). Worktree | ||
| 4 | +`/home/user/Documents/Code/Rust/edith_codecs-sqdrift`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sqdrift`. | ||
| 5 | + | ||
| 6 | +## Do NOT redo any of this (all measured, see lanes/sqdrift-r1.report.md for the EVIDENCE lines) | ||
| 7 | +* Stream: `/home/user/.cache/sqdrift/gen.sh` -> `s.obu`, sha256 | ||
| 8 | + `c6af4fb4ebdc3d74dcfa0c945c0ef2d5e1e3a0902891d9e0a97a5608776b5d55`, hashed twice. | ||
| 9 | +* Frames 0-3 byte-exact pre-filter AND post-filter (both dumps). No poisoned reference. | ||
| 10 | +* Frame 4 damage = exactly the last SB, mi(16,32), PARTITION_NONE at 64x64, INTRA in an | ||
| 11 | + inter frame (aomdec prints neither EC_MODE nor EC_IMODE for it). | ||
| 12 | +* We enter that block IN SYNC: our `pre_rng=33730` == aomdec `EC_PART ... rng=33730`. | ||
| 13 | +* TX_64X64 dequant + inverse transform EXONERATED against real libaom (0/4096). | ||
| 14 | +* The stream contains no rect/AB/1:4 partition at all; main's 1:4-strip refusal on it is | ||
| 15 | + a phantom of this desync. | ||
| 16 | +* aomdec's prediction there is none of DC/SMOOTH/SMOOTH_V/SMOOTH_H/PAETH computed from | ||
| 17 | + the true neighbours, so its coefficients differ too -> a SYMBOL diverges, not a predictor. | ||
| 18 | + | ||
| 19 | +## The one open question | ||
| 20 | +Which symbol between `partition_w64` and the end of that block. Ordered suspects: | ||
| 21 | +1. `read_delta_q_params` -- delta_q IS present (base_q_idx 80/110/168) and this is the | ||
| 22 | + only block in the stream with `bsize == sb_size`, libaom's own special case | ||
| 23 | + (`decodemv.c`: `if (bsize != cm->seq_params->sb_size || !mbmi->skip_txfm)`), incl. the | ||
| 24 | + `delta_lf` sub-read. | ||
| 25 | +2. `skip` / `is_inter` ctx at a 64x64 block. | ||
| 26 | +3. `y_mode[size_group_lookup[BLOCK_64X64]=3]` CDF content (adaptation drift; frames 0-3 | ||
| 27 | + never crossed a decision boundary). | ||
| 28 | +4. `tx_depth`: `--enable-tx-size-search=0`, so TX_64X64 must code no depth symbol. | ||
| 29 | +5. The 64x64 luma coefficient read (eob_pt alphabet at TX_64X64, `all_zero` ctx). | ||
| 30 | + | ||
| 31 | +## Instruments already in the tree | ||
| 32 | +* `EC_AV1_TRACE=1` -> `TRACE partition_w64 ... pre_rng=<range before the symbol>`. | ||
| 33 | +* `EC_IIS=1` -> `TRACE iis px= py= side= w= h= sg= mode= skip=` at the square | ||
| 34 | + intra-in-inter `y_mode` read (decode.rs, right after `cdfs.y_mode[size_group_wh(..)]`). | ||
| 35 | +* `/home/user/.cache/sqdrift/h.c` -- libaom inverse-transform harness. Build: | ||
| 36 | + `gcc -O1 -o h h.c -I$SRC -I$BUILD -I$SRC/apps $BUILD/libaom.a -lm -lpthread`. | ||
| 37 | + MUST call `av1_rtcd(); aom_dsp_rtcd();` first or `av1_idct64` is a NULL fn ptr (segfault). | ||
| 38 | +* The oracle has NO range print inside `read_intra_block_mode_info` / | ||
| 39 | + `read_delta_q_params`. Add one via `scripts/instrument-aom-oracle.sh` into a PRIVATE | ||
| 40 | + build dir; never rebuild the shared `~/.cache/aom-oracle/build/aomdec` in place. | ||
lanes/sqdrift-r1.report.mdadded+100 -0
| @@ -0,0 +1,100 @@ | |||
| 1 | +# lane-sqdrift r1 -- the square-only silent pixel drift, localised to ONE block | ||
| 2 | + | ||
| 3 | +## Verdict: RED (defect localised and bounded, not yet fixed). No refusal lifted. | ||
| 4 | + | ||
| 5 | +## The stream (pinned, reproducible) | ||
| 6 | + | ||
| 7 | +`/home/user/.cache/sqdrift/gen.sh` (kept; recipe = lane-intra14's gate recipe with | ||
| 8 | +`--enable-rect-partitions=0`): 192x128 8-bit `mandelbrot start_scale=4.76 end_scale=0.004 | ||
| 9 | +end_pts=8 rate=25`, hue=s=0, `-t 0.32`, real `~/.cache/aom-oracle/build/aomenc` | ||
| 10 | +`--cpu-used=1 --cq-level=55 --min-partition-size=16 --max-partition-size=64 | ||
| 11 | +--enable-tx-size-search=0 --kf-min/max-dist=1000 --threads=1 --row-mt=0`, order-hint / | ||
| 12 | +warped / obmc / masked / interintra / dist-wtd / diff-wtd / onesided / ab / 1to4 / | ||
| 13 | +filter-intra / smooth-intra / paeth-intra / directional-intra / angle-delta / cdef / | ||
| 14 | +restoration / palette / intrabc / cfl / ref-frame-mvs ALL `=0`. | ||
| 15 | +sha256 `c6af4fb4ebdc3d74dcfa0c945c0ef2d5e1e3a0902891d9e0a97a5608776b5d55`, hashed twice | ||
| 16 | +from two independent encodes -- reproducible. | ||
| 17 | + | ||
| 18 | +## What is actually wrong (measured, not reasoned) | ||
| 19 | + | ||
| 20 | +1. `aomdec EC_TRACE=1` partition histogram over the whole stream: only | ||
| 21 | + `value=0 (NONE)` and `value=3 (SPLIT)` at bsize 12/9/6. **No rect, no AB, no 1:4 | ||
| 22 | + partition exists in this stream at all** -- so main's refusal | ||
| 23 | + "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", which this | ||
| 24 | + stream stops at on `main@85887c7`, is a PHANTOM read out of an already-diverged | ||
| 25 | + bitstream (class `refusal-from-own-desync`). | ||
| 26 | +2. Pre-loop-filter dumps, our `EC_AV1_PREFILT_DUMP` vs aomdec's, per decode-order frame: | ||
| 27 | + f0..f3 **byte-exact (luma AND chroma)**; f4 luma 3540 samples wrong, max |d| = 6, | ||
| 28 | + **chroma exact**. Post-filter reference dumps (`EC_AV1_FINAL_DUMP`) f0..f3 exact too, | ||
| 29 | + so no reference frame is poisoned going into f4. | ||
| 30 | +3. The f4 damage is EXACTLY one superblock: bbox x 128..191, y 64..127 -- the last SB, | ||
| 31 | + mi (16,32), which frame 4 codes as `PARTITION_NONE` at 64x64. It is the ONLY | ||
| 32 | + 64x64 PARTITION_NONE block in any inter frame of this stream. | ||
| 33 | +4. Range ladder at that block's entry: our pre-read msac range for its `partition_w64` | ||
| 34 | + symbol is **33730**, identical to aomdec's `EC_PART mi_row=16 mi_col=32 bsize=12 | ||
| 35 | + ctx=15 tell=25598 rng=33730`, and the ctx matches too (aomdec prints `bsl*4+ctx` | ||
| 36 | + = 12+3, ours `ctx=3`). **We enter that block bit-exactly in sync.** | ||
| 37 | +5. The divergence is INSIDE that block. aomdec prints neither `EC_MODE` (= | ||
| 38 | + `read_inter_block_mode_info`) nor `EC_IMODE`, i.e. libaom takes | ||
| 39 | + `read_intra_block_mode_info` -- an INTRA block inside an inter frame. Our decoder | ||
| 40 | + takes the same arm and reads `y_mode[size_group=3] = 0 (DC_PRED)` | ||
| 41 | + (new `EC_IIS=1` rung: `TRACE iis px=128 py=64 side=64 w=64 h=64 sg=3 mode=0 skip=false`). | ||
| 42 | + Our reconstruction there is a FLAT 93, which is exactly | ||
| 43 | + `(sum(above 64) + sum(left 64) + 64) >> 7` -- textbook DC_PRED. aomdec's | ||
| 44 | + reconstruction is not flat. | ||
| 45 | +6. The luma residual is NOT the defect. The block's 5 non-zero levels were pushed | ||
| 46 | + through libaom itself (`av1_inv_txfm2d_add_64x64_c`, real `libaom.a`, dequant | ||
| 47 | + replicated from `decodetxb.c:361-374` with `av1_dc/ac_quant_QTX(80,0,8)` = 74/87 and | ||
| 48 | + `av1_get_tx_scale` shift 2): **0 mismatches** against our own `residual` for those | ||
| 49 | + levels (and 2171 with the axes swapped, so the layout is right too). Our TX_64X64 | ||
| 50 | + dequant + inverse transform is exact. | ||
| 51 | +7. Everything after that block drifts: frame 5's SB0 `partition_w64` still reads 3, SB1 | ||
| 52 | + reads 8 where aomdec reads 3 -- a CDF-state divergence carried across the frame | ||
| 53 | + boundary (frame 5 restarts its own msac, so only the adapted CDFs can carry the | ||
| 54 | + damage). f5..f7 then drift to ~24k samples / max |d| ~220 as they predict from f4. | ||
| 55 | + | ||
| 56 | +So: **the first divergent symbol is in the mode-info or coefficient read of a 64x64 | ||
| 57 | +PARTITION_NONE intra-in-inter block, after `partition_w64` and at/after `y_mode`.** | ||
| 58 | +The candidate set is now tiny: `skip`, `read_delta_q_params` (this is the ONE block in | ||
| 59 | +the stream where `bsize == sb_size`, the exact case libaom's | ||
| 60 | +`read_delta_q_params` special-cases), `is_inter`, `y_mode[3]`, `uv_mode_cfl[0]`, | ||
| 61 | +`tx_depth` (`--enable-tx-size-search=0`, so a TX_64X64 must code no depth symbol), or the | ||
| 62 | +64x64 coefficient read itself. `base_q_idx` in our trace takes three values (80/110/168) | ||
| 63 | +across the stream, i.e. **delta_q IS present in this stream** -- that makes the | ||
| 64 | +`bsize == sb_size` delta-q exception a first-class suspect. | ||
| 65 | + | ||
| 66 | +## What changed (all env-gated instrumentation, no decode behaviour) | ||
| 67 | + | ||
| 68 | +* `crates/ec-av1/src/decode.rs` (`decode_inter_frame_tile_with_cdfs`'s `partition_w64` | ||
| 69 | + read) -- the `EC_AV1_TRACE` line now carries `pre_rng=`, the msac range BEFORE the | ||
| 70 | + symbol, which is what makes it directly comparable to aomdec's `EC_PART ... rng=` | ||
| 71 | + (class `compare-range-not-tell`). This is the measurement that proved fact 4. | ||
| 72 | +* `crates/ec-av1/src/decode.rs` (square intra-in-inter `y_mode` read) -- new `EC_IIS=1` | ||
| 73 | + rung printing `px/py/side/w/h/size_group/mode/skip` for every intra block in an inter | ||
| 74 | + frame. That is fact 5. | ||
| 75 | + | ||
| 76 | +## Gate | ||
| 77 | + | ||
| 78 | +None added -- there is no fix to gate yet. Adding a gate now would pin the defect, not a | ||
| 79 | +capability; the reproducing recipe is `scripts`-free and lives in this report plus | ||
| 80 | +`/home/user/.cache/sqdrift/gen.sh`. | ||
| 81 | + | ||
| 82 | +## EVIDENCE | ||
| 83 | + | ||
| 84 | +EVIDENCE: /home/user/.cache/sqdrift/{op,aom}.f0..f4 | our EC_AV1_PREFILT_DUMP vs aomdec EC_AV1_PREFILT_DUMP on the pinned stream, every decode-order frame compared Y/U/V | f0-f3 0 bad samples; f4 luma 3540 bad, max |d| 6, chroma 0 bad, bbox exactly x128-191 y64-127 | ||
| 85 | +EVIDENCE: /home/user/.cache/sqdrift/{of,af}.f0..f4 | EC_AV1_FINAL_DUMP (post-filter reference buffers) both decoders | f0-f3 0 bad; f4 first bad (145,58), 3848 bad, max 6 -- deblocking only spreads the f4 damage, no reference is poisoned earlier | ||
| 86 | +EVIDENCE: /home/user/.cache/sqdrift/aom.trace | aomdec EC_TRACE=1 partition histogram, whole stream | bsize12 {0:2, 3:46}, bsize9 {0:58, 3:126}, bsize6 {0:504} -- zero rect/AB/1:4 partitions, so main's 1:4-strip refusal on this stream is a phantom | ||
| 87 | +EVIDENCE: our EC_AV1_TRACE pre_rng vs /home/user/.cache/sqdrift/aom.both | range ladder at frame 4 SB (16,32) | ours pre_rng=33730 ctx=3, aomdec rng=33730 ctx=15(=12+3) -- in sync at block entry, so the defect is inside the block | ||
| 88 | +EVIDENCE: /home/user/.cache/sqdrift/{h.c,aomres1.txt,ourres.txt} | the block's 5 non-zero levels through real libaom av1_inv_txfm2d_add_64x64_c vs our residual | 0/4096 mismatches (swapped-axis control: 2171) -- TX_64X64 dequant+inverse is exact | ||
| 89 | +EVIDENCE: EC_IIS=1 rung on the pinned stream | our intra-in-inter mode read at the failing block | `TRACE iis px=128 py=64 side=64 w=64 h=64 sg=3 mode=0 skip=false`, reconstruction flat 93 = DC_PRED of the true neighbours; aomdec's is not flat (SMOOTH/SMOOTH_V/SMOOTH_H/PAETH all rejected numerically too, so aomdec's coefficients differ as well -- the divergence is a SYMBOL, not a predictor) | ||
| 90 | + | ||
| 91 | +## Residue | ||
| 92 | + | ||
| 93 | +* fix-now (next round, r2): bisect the ~6 remaining symbols of that one block. The | ||
| 94 | + cheapest decisive instrument is a `pre_rng` print on every symbol of | ||
| 95 | + `read_inter_frame_mode_info`'s square intra arm plus an aomdec-side `rng` print at the | ||
| 96 | + same points in `read_intra_block_mode_info` / `read_delta_q_params` (the oracle has no | ||
| 97 | + print there today -- add one to `scripts/instrument-aom-oracle.sh`, do NOT rebuild the | ||
| 98 | + shared aomdec in place). Start with `read_delta_q_params`' `bsize == sb_size` exception. | ||
| 99 | +* deferred: 10-bit arm -- unblocked by the fix; there is nothing to gate yet. | ||
| 100 | +* accepted: the two `EC_*` trace rungs ship as permanent debug instrumentation. | ||
lanes/sqdrift-r2.report.mdadded+93 -0
| @@ -0,0 +1,93 @@ | |||
| 1 | +# lane-sqdrift r2 -- the square-only silent drift is the no-CFL `uv_mode` alphabet | ||
| 2 | + | ||
| 3 | +## Verdict: GREEN. Root cause confirmed by ablation, gated with a new real-aomenc gate. | ||
| 4 | + | ||
| 5 | +Tip `2b750e6` on `lane-sqdrift` (base main `85887c7`). | ||
| 6 | + | ||
| 7 | +## 1. What the divergence was | ||
| 8 | + | ||
| 9 | +r1 had localised it to one 64x64 `PARTITION_NONE` INTRA block inside an INTER frame | ||
| 10 | +(frame 4, mi(16,32) = the last superblock), entered bit-exactly in sync (`pre_rng=33730` | ||
| 11 | +== aomdec's `rng=33730`), with TX_64X64 dequant+inverse already exonerated against real | ||
| 12 | +libaom. The open question was "which symbol inside that block". | ||
| 13 | + | ||
| 14 | +Answer: `uv_mode`. libaom's `is_cfl_allowed` (`blockd.h`: `block_size_wide[bsize] <= 32 && | ||
| 15 | +block_size_high[bsize] <= 32`, spec 5.11.5) excludes a 64-axis block from CFL, so its | ||
| 16 | +`uv_mode` comes off the **13-symbol `uv_mode_no_cfl`** alphabet. We read the 14-symbol | ||
| 17 | +`uv_mode_cfl` one: the same `DC_PRED` VALUE, a different interval narrowing, and the tile | ||
| 18 | +desynced from that block on (class `wrong-alphabet-same-value`). | ||
| 19 | + | ||
| 20 | +The fix was found independently by lane-sbrect10 (`9f1f108`) and is merged here, not | ||
| 21 | +rewritten: commit `cbcbf13` merges `lane-sbrect10` into this branch. `decode.rs` gets the | ||
| 22 | +`cfl_allowed = write_w.max(write_h) <= 32` test at the intra-in-inter square arm plus the | ||
| 23 | +same `is_cfl_allowed` bound enforced at the two funnels `read_intra_mode` / | ||
| 24 | +`read_intra_mode_rect`, and the `nocfl_uv_mode_hits()` witness counter. No decoder line in | ||
| 25 | +this round is mine; my round's contributions are the confirmation, the ablation, and the | ||
| 26 | +square-only gate. | ||
| 27 | + | ||
| 28 | +## 2. The decisive before/after, same stream, same tree | ||
| 29 | + | ||
| 30 | +Pinned stream `/home/user/.cache/sqdrift/keep-s.obu`, sha256 | ||
| 31 | +`c6af4fb4ebdc3d74dcfa0c945c0ef2d5e1e3a0902891d9e0a97a5608776b5d55` (r1's `gen.sh`, | ||
| 32 | +hashed twice from two independent encodes), compared PRE-LOOP-FILTER, per decode-order | ||
| 33 | +frame, byte for byte against instrumented aomdec's own `EC_AV1_PREFILT_DUMP`: | ||
| 34 | + | ||
| 35 | +| | f0 | f1 | f2 | f3 | f4 | f5 | f6 | f7 | outcome | | ||
| 36 | +|---|---|---|---|---|---|---|---|---|---| | ||
| 37 | +| before (`cfl_allowed = true` ablation on THIS tree) | 0 | 0 | 0 | 0 | **3540** | - | - | - | REFUSED after f4: "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path" | | ||
| 38 | +| after (merged fix) | 0 | 0 | 0 | 0 | **0** | 0 | 0 | 0 | 8 frames decoded, all byte-exact | | ||
| 39 | + | ||
| 40 | +The "before" row is not r1's memory: it is the one-line ablation | ||
| 41 | +`decode.rs:18548 let cfl_allowed = true;` rebuilt and re-run in this round, then reverted | ||
| 42 | +(`git diff --stat` after revert shows stream.rs only). It also re-confirms r1's finding | ||
| 43 | +that the refusal main stops at on this stream is a PHANTOM of the desync -- aomdec's | ||
| 44 | +partition histogram over the stream contains no rect partition at all (class | ||
| 45 | +`refusal-from-own-desync`). | ||
| 46 | + | ||
| 47 | +## 3. The gate (new) | ||
| 48 | + | ||
| 49 | +`crates/ec-av1/src/stream.rs:6900` | ||
| 50 | +`a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact` | ||
| 51 | + | ||
| 52 | +The SQUARE-ONLY twin of lane-sbrect10's gate, pinning r1's recipe: real aomenc, | ||
| 53 | +192x128 mandelbrot (`start_scale` 4.76/3.20), cq 55/45, `--cpu-used=1 --sb-size=64 | ||
| 54 | +--enable-rect-partitions=0 --enable-ab-partitions=0 --enable-1to4-partitions=0 | ||
| 55 | +--min-partition-size=16 --max-partition-size=64 --enable-tx-size-search=0`, 8 decode-order | ||
| 56 | +frames, **both bit depths**. Rect OFF is what makes the 64x64 `PARTITION_NONE` a WHOLE | ||
| 57 | +superblock (`bsize == sb_size`), a shape the sibling gate's rect-on recipe does not pin; | ||
| 58 | +8 frames of drift means a desync that survives one frame still fails here. | ||
| 59 | + | ||
| 60 | +Asserts: every decode-order frame's Y/U/V compared against ffmpeg (a mismatch of ANY shape | ||
| 61 | +is a failure, never a SKIP -- so out-of-scope mismatches are structurally 0); a decode | ||
| 62 | +error must be a named `unsupported` refusal; and `nocfl_uv_mode_hits` delta per attempt | ||
| 63 | +must be > 0 on at least one pixel-exact attempt per depth. | ||
| 64 | + | ||
| 65 | +Result (`--exact --nocapture --test-threads=1`), 10.4 s: | ||
| 66 | + | ||
| 67 | +* 8-bit: 0 named refusals, **4/4 pixel-exact attempts**, 6 no-CFL `uv_mode` reads, 0 carried none | ||
| 68 | +* 10-bit: 0 named refusals, **4/4 pixel-exact attempts**, 6 no-CFL `uv_mode` reads, 0 carried none | ||
| 69 | + | ||
| 70 | +No refusal string is removed in this round: the refusal this stream used to hit was never | ||
| 71 | +about this shape. | ||
| 72 | + | ||
| 73 | +## 4. Suite | ||
| 74 | + | ||
| 75 | +`cargo test -p ec-av1 --lib` under `systemd-run --user --unit=sqdrift-suite-r2-...`, | ||
| 76 | +log `$HOME/.cache/sqdrift-suite-r2.log`: **379 passed, 0 failed, 33 ignored** in 958.68 s (r1 baseline on the unfixed tree never completed). | ||
| 77 | + | ||
| 78 | +## EVIDENCE | ||
| 79 | + | ||
| 80 | +EVIDENCE: /home/user/.cache/sqdrift/np.f0..f7 vs aom.f0..f7 | decode_probe with EC_AV1_PREFILT_DUMP on the pinned stream (sha256 c6af4fb4...) after merging lane-sbrect10, cmp -l per decode-order frame Y+U+V | 0 differing bytes on all 8 frames (r1: f4 3540 wrong luma samples, then refusal) | ||
| 81 | +EVIDENCE: /home/user/.cache/sqdrift/ab.f0..f4 | same binary with decode.rs:18548 ablated to `cfl_allowed = true`, rebuilt, re-run, then reverted | f0-f3 0, f4 3540 differing bytes, decode then REFUSES "an intra-coded 1:4 ... rect strip on the inter block path" -- the phantom refusal is produced by this desync alone | ||
| 82 | +EVIDENCE: cargo test -p ec-av1 --lib -- --exact --nocapture a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact | 4 attempts x 2 bit depths of real aomenc, rect partitions off, every decode-order frame vs ffmpeg | ok in 10.38s; 8-bit 4 exact/6 hits, 10-bit 4 exact/6 hits, 0 refusals, 0 attempts carried none | ||
| 83 | + | ||
| 84 | +## Residue | ||
| 85 | + | ||
| 86 | +* deferred(lane-intra14 re-runs its own gate): `lanes/intra14-r2.report.md` records its | ||
| 87 | + blocker as "decode-order frame 3/4 luma ~3.7-4.5k samples at max |d| 6..17, first diff | ||
| 88 | + around x=128..141, y=58..59, then frames 5-7 drift to ~24k at max |d| ~220" on the same | ||
| 89 | + 192x128 mandelbrot source -- the identical signature to this lane's, at the identical | ||
| 90 | + coordinates. Very likely the same defect, so its two `#[ignore]`d 1:4-strip arms should | ||
| 91 | + be re-measured on a tree carrying this fix. Not measured here: its recipe (1:4 on) is | ||
| 92 | + another lane's surface. | ||
| 93 | +* accepted: r1's `EC_AV1_TRACE pre_rng` and `EC_IIS` rungs stay as debug instrumentation. | ||