Cherry-pick lane-tiny 9b1297a (chroma tx size in the deblocker) + lane-sub8 r4 report
Browse files at this commita3613e4e77c0a7437ee361e003192a4f24b3c494Parent: c24ba5d- fix
- cherry-pick lane-tiny 9b1297a (chroma tx size in the deblocker) + lane-sub8 r4 report
4 changed files +190 -23
- crates/ec-av1/examples/decode_probe.rs +16 -1
- crates/ec-av1/src/decode.rs +51 -12
- crates/ec-av1/src/stream.rs +49 -10
- lanes/sub8-r4.report.md +74 -0
crates/ec-av1/examples/decode_probe.rsmodified+16 -1
| @@ -32,7 +32,22 @@ fn main() { | |||
| 32 | Ok(frames) if frames.is_empty() => { | 32 | Ok(frames) if frames.is_empty() => { |
| 33 | println!("OK but EMPTY: no frames -- is {path} an IVF rather than a raw OBU stream?"); | 33 | println!("OK but EMPTY: no frames -- is {path} an IVF rather than a raw OBU stream?"); |
| 34 | } | 34 | } |
| 35 | - Ok(frames) => println!("OK: {} frames decoded", frames.len()), | 35 | + Ok(frames) => { |
| 36 | + println!("OK: {} frames decoded", frames.len()); | ||
| 37 | + // Optional second arg: dump the decoded planes as raw yuv420p so a | ||
| 38 | + // pixel diff against `ffmpeg -i s.obu -f rawvideo` needs no test harness. | ||
| 39 | + if let Some(out) = std::env::args().nth(2) { | ||
| 40 | + // 8-bit only: planes are u16, take the low byte. | ||
| 41 | + let mut buf: Vec<u8> = Vec::new(); | ||
| 42 | + for f in &frames { | ||
| 43 | + for p in [&f.y, &f.u, &f.v] { | ||
| 44 | + buf.extend(p.iter().map(|&s| s as u8)); | ||
| 45 | + } | ||
| 46 | + } | ||
| 47 | + std::fs::write(&out, &buf).expect("writing raw planes"); | ||
| 48 | + println!("wrote {} bytes of yuv420p to {out}", buf.len()); | ||
| 49 | + } | ||
| 50 | + } | ||
| 36 | Err(e) => println!("REFUSED: {e}"), | 51 | Err(e) => println!("REFUSED: {e}"), |
| 37 | } | 52 | } |
| 38 | } | 53 | } |
crates/ec-av1/src/decode.rsmodified+51 -12
| @@ -1851,6 +1851,16 @@ struct Neighbours { | |||
| 1851 | /// lane-rect r2: TX_32X16/TX_16X32 strips deblock their horizontal | 1851 | /// lane-rect r2: TX_32X16/TX_16X32 strips deblock their horizontal |
| 1852 | /// edges by tx height (spec 7.14.2 `set_lpf_parameters` dir==VERT). | 1852 | /// edges by tx height (spec 7.14.2 `set_lpf_parameters` dir==VERT). |
| 1853 | tx_h_grid: Vec<u8>, | 1853 | tx_h_grid: Vec<u8>, |
| 1854 | + /// Per-4x4-mi CHROMA transform width/height in pixels -- lane-tiny r4. | ||
| 1855 | + /// A block's chroma transform is `av1_get_max_uv_txsize(bsize)`: the | ||
| 1856 | + /// largest transform covering the subsampled BLOCK, capped at 32x32. It | ||
| 1857 | + /// does NOT follow luma's `tx_depth` split, so deriving it as | ||
| 1858 | + /// `tx_grid / 2` invented chroma transform edges the deblocker then | ||
| 1859 | + /// filtered (32x16 frames, U plane, seeds 42/47). Written from the | ||
| 1860 | + /// block's own mi span in [`Self::fill_lf_grid_rect`], the one place | ||
| 1861 | + /// every caller routes through. | ||
| 1862 | + uv_tx_grid: Vec<u8>, | ||
| 1863 | + uv_tx_h_grid: Vec<u8>, | ||
| 1854 | /// Per-4x4-mi reference frame (`0` = intra, magnitude `1..=7` = | 1864 | /// Per-4x4-mi reference frame (`0` = intra, magnitude `1..=7` = |
| 1855 | /// `MV_REFERENCE_FRAME`, negative = that reference coded as `GLOBALMV` -- | 1865 | /// `MV_REFERENCE_FRAME`, negative = that reference coded as `GLOBALMV` -- |
| 1856 | /// `lf_level`'s `mode_lf_lut` row 0, lane-av1golden2) | 1866 | /// `lf_level`'s `mode_lf_lut` row 0, lane-av1golden2) |
| @@ -1932,6 +1942,8 @@ impl Neighbours { | |||
| 1932 | skip_grid_cols_mi: cols * (SUB / MI), | 1942 | skip_grid_cols_mi: cols * (SUB / MI), |
| 1933 | tx_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], | 1943 | tx_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], |
| 1934 | tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], | 1944 | tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], |
| 1945 | + uv_tx_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], | ||
| 1946 | + uv_tx_h_grid: vec![0u8; cols * (SUB / MI) * rows * (SUB / MI)], | ||
| 1935 | ref_grid: vec![0i8; cols * (SUB / MI) * rows * (SUB / MI)], | 1947 | ref_grid: vec![0i8; cols * (SUB / MI) * rows * (SUB / MI)], |
| 1936 | delta_lf_grid: vec![[0i8; 4]; cols * (SUB / MI) * rows * (SUB / MI)], | 1948 | delta_lf_grid: vec![[0i8; 4]; cols * (SUB / MI) * rows * (SUB / MI)], |
| 1937 | above_palette_size: vec![0; cols], | 1949 | above_palette_size: vec![0; cols], |
| @@ -2135,6 +2147,11 @@ impl Neighbours { | |||
| 2135 | ref_frame: i8, | 2147 | ref_frame: i8, |
| 2136 | ) { | 2148 | ) { |
| 2137 | let (mi_r, mi_c) = at_mi; | 2149 | let (mi_r, mi_c) = at_mi; |
| 2150 | + // `av1_get_max_uv_txsize` under 4:2:0: the block's chroma extent is | ||
| 2151 | + // half its luma one (min 4 px, the smallest transform), capped at | ||
| 2152 | + // TX_32X32 -- independent of this block's luma `tx_depth`. | ||
| 2153 | + let uv_tx_w = ((w_mi * MI / 2).max(4).min(32)) as u8; | ||
| 2154 | + let uv_tx_h = ((h_mi * MI / 2).max(4).min(32)) as u8; | ||
| 2138 | let cur = CURRENT_DELTA_LF.with(|c| c.get()); | 2155 | let cur = CURRENT_DELTA_LF.with(|c| c.get()); |
| 2139 | let snapshot: [i8; 4] = if DELTA_LF_MULTI.with(|c| c.get()) { | 2156 | let snapshot: [i8; 4] = if DELTA_LF_MULTI.with(|c| c.get()) { |
| 2140 | std::array::from_fn(|i| cur[i].clamp(-63, 63) as i8) | 2157 | std::array::from_fn(|i| cur[i].clamp(-63, 63) as i8) |
| @@ -2150,6 +2167,12 @@ impl Neighbours { | |||
| 2150 | if let Some(cell) = self.tx_h_grid.get_mut(idx) { | 2167 | if let Some(cell) = self.tx_h_grid.get_mut(idx) { |
| 2151 | *cell = tx_h_px; | 2168 | *cell = tx_h_px; |
| 2152 | } | 2169 | } |
| 2170 | + if let Some(cell) = self.uv_tx_grid.get_mut(idx) { | ||
| 2171 | + *cell = uv_tx_w; | ||
| 2172 | + } | ||
| 2173 | + if let Some(cell) = self.uv_tx_h_grid.get_mut(idx) { | ||
| 2174 | + *cell = uv_tx_h; | ||
| 2175 | + } | ||
| 2153 | if let Some(cell) = self.ref_grid.get_mut(idx) { | 2176 | if let Some(cell) = self.ref_grid.get_mut(idx) { |
| 2154 | *cell = ref_frame; | 2177 | *cell = ref_frame; |
| 2155 | } | 2178 | } |
| @@ -4397,6 +4420,20 @@ fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 { | |||
| 4397 | /// [`crate::encode`]'s private `Plane`, whose `edges` this mirrors exactly | 4420 | /// [`crate::encode`]'s private `Plane`, whose `edges` this mirrors exactly |
| 4398 | /// (own-edge and reach clamps both), passing what it gathers straight to | 4421 | /// (own-edge and reach clamps both), passing what it gathers straight to |
| 4399 | /// [`crate::intra::predict`] instead of hand-rolling `DC_PRED` alone. | 4422 | /// [`crate::intra::predict`] instead of hand-rolling `DC_PRED` alone. |
| 4423 | +/// lane-tiny r4: raw padded-plane dump for filter-stage bisection, written | ||
| 4424 | +/// only when `var` names a path. Same byte shape as `EC_AV1_PREFILT_DUMP`. | ||
| 4425 | +fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { | ||
| 4426 | + use std::io::Write; | ||
| 4427 | + if let Ok(path) = std::env::var(var) | ||
| 4428 | + && let Ok(mut f) = std::fs::File::create(format!("{path}.f0")) | ||
| 4429 | + { | ||
| 4430 | + for p in [y, u, v] { | ||
| 4431 | + let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect(); | ||
| 4432 | + let _ = f.write_all(&narrow); | ||
| 4433 | + } | ||
| 4434 | + } | ||
| 4435 | +} | ||
| 4436 | + | ||
| 4400 | #[derive(Clone)] | 4437 | #[derive(Clone)] |
| 4401 | struct PlaneBuf { | 4438 | struct PlaneBuf { |
| 4402 | data: Vec<u16>, | 4439 | data: Vec<u16>, |
| @@ -6026,24 +6063,16 @@ fn plane_to_mi(chroma: bool, coord: usize) -> usize { | |||
| 6026 | /// half its coded block's luma transform, spec's `av1_get_max_uv_txsize` | 6063 | /// half its coded block's luma transform, spec's `av1_get_max_uv_txsize` |
| 6027 | /// under 4:2:0 and a block that never splits its own transform). | 6064 | /// under 4:2:0 and a block that never splits its own transform). |
| 6028 | fn tx_px_at(n: &Neighbours, chroma: bool, mi_r: usize, mi_c: usize) -> u32 { | 6065 | fn tx_px_at(n: &Neighbours, chroma: bool, mi_r: usize, mi_c: usize) -> u32 { |
| 6029 | - let luma_tx = n | 6066 | + let grid = if chroma { &n.uv_tx_grid } else { &n.tx_grid }; |
| 6030 | - .tx_grid | 6067 | + grid.get(mi_r * n.skip_grid_cols_mi + mi_c).copied().unwrap_or(0) as u32 |
| 6031 | - .get(mi_r * n.skip_grid_cols_mi + mi_c) | ||
| 6032 | - .copied() | ||
| 6033 | - .unwrap_or(0) as u32; | ||
| 6034 | - if chroma { luma_tx / 2 } else { luma_tx } | ||
| 6035 | } | 6068 | } |
| 6036 | 6069 | ||
| 6037 | /// [`tx_px_at`]'s HEIGHT twin (lane-rect r2): the deblocker's horizontal | 6070 | /// [`tx_px_at`]'s HEIGHT twin (lane-rect r2): the deblocker's horizontal |
| 6038 | /// edges step and gate by transform height, which differs from width only | 6071 | /// edges step and gate by transform height, which differs from width only |
| 6039 | /// on rect partition strips. | 6072 | /// on rect partition strips. |
| 6040 | fn tx_h_px_at(n: &Neighbours, chroma: bool, mi_r: usize, mi_c: usize) -> u32 { | 6073 | fn tx_h_px_at(n: &Neighbours, chroma: bool, mi_r: usize, mi_c: usize) -> u32 { |
| 6041 | - let luma_tx = n | 6074 | + let grid = if chroma { &n.uv_tx_h_grid } else { &n.tx_h_grid }; |
| 6042 | - .tx_h_grid | 6075 | + grid.get(mi_r * n.skip_grid_cols_mi + mi_c).copied().unwrap_or(0) as u32 |
| 6043 | - .get(mi_r * n.skip_grid_cols_mi + mi_c) | ||
| 6044 | - .copied() | ||
| 6045 | - .unwrap_or(0) as u32; | ||
| 6046 | - if chroma { luma_tx / 2 } else { luma_tx } | ||
| 6047 | } | 6076 | } |
| 6048 | 6077 | ||
| 6049 | /// `get_tx_size_context` (spec 9.3's `TxDepthCtx`, libaom | 6078 | /// `get_tx_size_context` (spec 9.3's `TxDepthCtx`, libaom |
| @@ -7850,7 +7879,12 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 7850 | frame_height as usize, | 7879 | frame_height as usize, |
| 7851 | ); | 7880 | ); |
| 7852 | let (deblocked_y, deblocked_u, deblocked_v) = (y.clone(), u.clone(), v.clone()); | 7881 | let (deblocked_y, deblocked_u, deblocked_v) = (y.clone(), u.clone(), v.clone()); |
| 7882 | + // lane-tiny r4: post-deblock / post-CDEF dumps mirroring aomdec's own | ||
| 7883 | + // EC_AV1_POSTDEBLOCK_DUMP (decodeframe.c ~5404) -- with the pre-filter | ||
| 7884 | + // dump above these bisect WHICH filter stage introduced a mismatch. | ||
| 7885 | + dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); | ||
| 7853 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); | 7886 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); |
| 7887 | + dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); | ||
| 7854 | apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid); | 7888 | apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid); |
| 7855 | 7889 | ||
| 7856 | let (fw, fh) = (frame_width as usize, frame_height as usize); | 7890 | let (fw, fh) = (frame_width as usize, frame_height as usize); |
| @@ -13745,7 +13779,12 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 13745 | frame_height as usize, | 13779 | frame_height as usize, |
| 13746 | ); | 13780 | ); |
| 13747 | let (deblocked_y, deblocked_u, deblocked_v) = (y.clone(), u.clone(), v.clone()); | 13781 | let (deblocked_y, deblocked_u, deblocked_v) = (y.clone(), u.clone(), v.clone()); |
| 13782 | + // lane-tiny r4: post-deblock / post-CDEF dumps mirroring aomdec's own | ||
| 13783 | + // EC_AV1_POSTDEBLOCK_DUMP (decodeframe.c ~5404) -- with the pre-filter | ||
| 13784 | + // dump above these bisect WHICH filter stage introduced a mismatch. | ||
| 13785 | + dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); | ||
| 13748 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); | 13786 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); |
| 13787 | + dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); | ||
| 13749 | apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid); | 13788 | apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid); |
| 13750 | 13789 | ||
| 13751 | let motion_field = build_motion_field( | 13790 | let motion_field = build_motion_field( |
crates/ec-av1/src/stream.rsmodified+49 -10
| @@ -6361,20 +6361,23 @@ mod tests { | |||
| 6361 | crate::decode::cdef_idx_hits() | 6361 | crate::decode::cdef_idx_hits() |
| 6362 | ); | 6362 | ); |
| 6363 | } | 6363 | } |
| 6364 | - /// lane-tiny r1 diagnostic (not a gate): sweeps tiny key-frame sizes | 6364 | + /// lane-tiny r4 GATE (was r1's `#[ignore]`d probe): every tiny key-frame |
| 6365 | - /// against real aomenc + ffmpeg to find the exact size boundary of the | 6365 | + /// size real aomenc will encode, decoded pixel-exact against ffmpeg. |
| 6366 | - /// silent-wrong-pixels defect the sub8 lane's r2 dead-end flagged (a | 6366 | + /// Tiny frames are where every edge/partial-superblock corner case is |
| 6367 | - /// plain 16x16 stream, no exotic tools). `#[ignore]`d -- prints a | 6367 | + /// forced, and this sweep is what found both r3's filter-intra tx_type |
| 6368 | - /// pass/fail table, asserts nothing; run manually with `--nocapture`. | 6368 | + /// CDF row and r4's chroma-transform-size deblock defect -- so it |
| 6369 | + /// hard-asserts now: a decode error, a refusal, or one differing sample | ||
| 6370 | + /// at any size/seed fails. Only a genuinely absent oracle skips, and | ||
| 6371 | + /// `EC_AV1_REQUIRE_AOMENC=1` turns that into a failure too. | ||
| 6369 | #[test] | 6372 | #[test] |
| 6370 | - #[ignore = "diagnostic sweep, run manually with --nocapture"] | 6373 | + fn a_real_aomenc_tiny_frame_size_sweep_decodes_pixel_exact() { |
| 6371 | - fn probe_tiny_frame_size_boundary() { | ||
| 6372 | if !have_ffmpeg() || !have_aomenc() { | 6374 | if !have_ffmpeg() || !have_aomenc() { |
| 6373 | eprintln!("SKIP: no ffmpeg/aomenc"); | 6375 | eprintln!("SKIP: no ffmpeg/aomenc"); |
| 6374 | return; | 6376 | return; |
| 6375 | } | 6377 | } |
| 6376 | let sizes: &[(usize, usize)] = | 6378 | let sizes: &[(usize, usize)] = |
| 6377 | &[(8, 8), (16, 16), (32, 32), (16, 32), (32, 16), (64, 64), (48, 48), (24, 24)]; | 6379 | &[(8, 8), (16, 16), (32, 32), (16, 32), (32, 16), (64, 64), (48, 48), (24, 24)]; |
| 6380 | + let mut total_exact = 0u32; | ||
| 6378 | for &(width, height) in sizes { | 6381 | for &(width, height) in sizes { |
| 6379 | let mut ok = 0u32; | 6382 | let mut ok = 0u32; |
| 6380 | let mut bad = 0u32; | 6383 | let mut bad = 0u32; |
| @@ -6423,7 +6426,18 @@ mod tests { | |||
| 6423 | let stream = out.stdout; | 6426 | let stream = out.stdout; |
| 6424 | let frames = match decode_stream(&stream) { | 6427 | let frames = match decode_stream(&stream) { |
| 6425 | Err(e) => { | 6428 | Err(e) => { |
| 6426 | - eprintln!(" {width}x{height} seed {seed}: REFUSED {e}"); | 6429 | + // A NAMED refusal is the only non-exact outcome this |
| 6430 | + // gate tolerates (8x8 still needs a rectangular | ||
| 6431 | + // transform); anything else is a hard failure, and | ||
| 6432 | + // the floor assert below keeps that from going | ||
| 6433 | + // vacuous. | ||
| 6434 | + let msg = e.to_string(); | ||
| 6435 | + assert!( | ||
| 6436 | + msg.contains("unsupported"), | ||
| 6437 | + "{width}x{height} seed {seed}: failed outright, not a named \ | ||
| 6438 | + refusal: {msg}" | ||
| 6439 | + ); | ||
| 6440 | + eprintln!(" {width}x{height} seed {seed}: REFUSED {msg}"); | ||
| 6427 | refused += 1; | 6441 | refused += 1; |
| 6428 | continue; | 6442 | continue; |
| 6429 | } | 6443 | } |
| @@ -6438,6 +6452,12 @@ mod tests { | |||
| 6438 | ok += 1; | 6452 | ok += 1; |
| 6439 | } else { | 6453 | } else { |
| 6440 | bad += 1; | 6454 | bad += 1; |
| 6455 | + let nd = |a: &[u16], b: &[u16]| a.iter().zip(b).filter(|(x, y)| x != y).count(); | ||
| 6456 | + let (ndy, ndu, ndv) = ( | ||
| 6457 | + nd(&frames[0].y, &ffmpeg_frames[0].y), | ||
| 6458 | + nd(&frames[0].u, &ffmpeg_frames[0].u), | ||
| 6459 | + nd(&frames[0].v, &ffmpeg_frames[0].v), | ||
| 6460 | + ); | ||
| 6441 | let mut first = None; | 6461 | let mut first = None; |
| 6442 | for row in 0..height { | 6462 | for row in 0..height { |
| 6443 | for col in 0..width { | 6463 | for col in 0..width { |
| @@ -6458,13 +6478,32 @@ mod tests { | |||
| 6458 | .filter(|(a, b)| a != b) | 6478 | .filter(|(a, b)| a != b) |
| 6459 | .count(); | 6479 | .count(); |
| 6460 | eprintln!( | 6480 | eprintln!( |
| 6461 | - " {width}x{height} seed {seed}: MISMATCH luma first_diff={first:?} ndiff_luma={ndiff}/{}", | 6481 | + " {width}x{height} seed {seed}: MISMATCH first_diff={first:?} \ |
| 6482 | + ndiff_luma={ndiff}/{} ndiff y/u/v={ndy}/{ndu}/{ndv}", | ||
| 6462 | width * height | 6483 | width * height |
| 6463 | ); | 6484 | ); |
| 6464 | } | 6485 | } |
| 6465 | } | 6486 | } |
| 6466 | - eprintln!("{width}x{height}: {ok} ok / {bad} mismatch / {refused} refused (of {n})"); | 6487 | + assert_eq!( |
| 6488 | + bad, 0, | ||
| 6489 | + "{width}x{height}: {bad} of {n} seeds decoded to WRONG PIXELS ({ok} exact, \ | ||
| 6490 | + {refused} named refusals)" | ||
| 6491 | + ); | ||
| 6492 | + eprintln!("{width}x{height}: {ok}/{n} pixel-exact, {refused} named refusals"); | ||
| 6493 | + total_exact += ok; | ||
| 6467 | } | 6494 | } |
| 6495 | + // Hit counter: the sweep proved nothing unless every size x seed | ||
| 6496 | + // attempt really ran end to end (aomenc -> us -> ffmpeg compare). | ||
| 6497 | + // Floor (hit counter): 7 of the 8 sizes must decode all 10 seeds | ||
| 6498 | + // pixel-exact -- only 8x8 is allowed to refuse outright today. If a | ||
| 6499 | + // future change makes sizes refuse instead of decode, this fails | ||
| 6500 | + // rather than passing on refusals alone. | ||
| 6501 | + assert!( | ||
| 6502 | + total_exact >= 70, | ||
| 6503 | + "tiny sweep only reached {total_exact} pixel-exact attempts (floor 70) -- \ | ||
| 6504 | + refusals cannot substitute for decodes" | ||
| 6505 | + ); | ||
| 6506 | + eprintln!("tiny frame sweep: {total_exact} pixel-exact attempts"); | ||
| 6468 | } | 6507 | } |
| 6469 | 6508 | ||
| 6470 | /// lane-tiny r1: re-decodes the known-failing 32x32 seed 45 fixture with | 6509 | /// lane-tiny r1: re-decodes the known-failing 32x32 seed 45 fixture with |
lanes/sub8-r4.report.mdadded+74 -0
| @@ -0,0 +1,74 @@ | |||
| 1 | +# lane-sub8 report (round 4) | ||
| 2 | + | ||
| 3 | +## Premise correction (this is the round's main result) | ||
| 4 | +Round 2/3 assumed aomenc was really choosing `PARTITION_HORZ`/`VERT` below 8x8 | ||
| 5 | +and AB partitions in this gate's recipe. **It is not.** Instrumented aomdec on | ||
| 6 | +the gate's own stream (seed=117 cq=8, `--enable-rect-partitions=0`) reads only | ||
| 7 | +`value=0` (NONE) and `value=3` (SPLIT) at every level: | ||
| 8 | + | ||
| 9 | +``` | ||
| 10 | +EC_TRACE=1 ~/.cache/aom-oracle/build/aomdec --rawvideo -o /dev/null s117.obu \ | ||
| 11 | + | grep EC_PART_VAL | awk '{print $4,$5}' | sort | uniq -c | ||
| 12 | + 42 bsize=3 value=0 22 bsize=3 value=3 16 bsize=6 value=3 | ||
| 13 | + 4 bsize=9 value=3 1 bsize=12 value=3 | ||
| 14 | +``` | ||
| 15 | + | ||
| 16 | +So all 40 of the gate's "refusals" (`HORZ/VERT below 8x8`, `HORZ_A/B/VERT_A | ||
| 17 | +below 16x16`, `a 32x32 partition type value=4/8/9`) were **hallucinated symbols | ||
| 18 | +from our own desync**, not encoder choices. `--enable-rect-partitions=0` IS | ||
| 19 | +honoured. Every refusal-shaped conclusion in rounds 2-3 was measuring the | ||
| 20 | +desync. | ||
| 21 | + | ||
| 22 | +## Root causes found and fixed (commit "mi-exact intra mode neighbours ...") | ||
| 23 | +1. **Coarse mode neighbours (`context-read-from-one-cell` class).** | ||
| 24 | + `above_mode`/`left_mode` are one slot per 16x16; a split cell leaves two | ||
| 25 | + (8x8) or four (4x4) different modes behind, and a leaf whose above/left | ||
| 26 | + neighbour sits in such a cell read the wrong `kf_y_mode` CDF row -> desync. | ||
| 27 | + `Neighbours` now keeps a mi-granular map (`sub8_mode_col`/`sub8_mode_row`, | ||
| 28 | + `record_mode_mi`), written by `record_rect`, `record_split_luma`, | ||
| 29 | + `decode_leaf8` and every 4x4 leaf, read back with an exact-position guard | ||
| 30 | + (`mode_above_mi`/`mode_left_mi`) that falls back to the coarse slot. | ||
| 31 | +2. **`has_tr_4x4`/`has_bl_4x4` never transcribed** (`encode.rs`, the | ||
| 32 | + `corner-cut` comment that named this exact ceiling). Side-4 blocks clamped | ||
| 33 | + into the 8x8 table, so a directional 4x4 leaf predicted from above-right | ||
| 34 | + samples the decoder has not written yet -- all-zero pixels in the leaf's | ||
| 35 | + bottom-right triangle. Both tables transcribed verbatim from | ||
| 36 | + `~/.cache/aom-oracle/src/av1/common/reconintra.c:65,254`; `Reach::table` | ||
| 37 | + maps side 4 to the new row. | ||
| 38 | +3. Cherry-picked lane-tiny `9b1297a` (deblocker chroma tx size from the block | ||
| 39 | + span) per the charter -- it does not change this lane's residue but keeps | ||
| 40 | + the branch aligned with main's fix. | ||
| 41 | + | ||
| 42 | +## Gate result | ||
| 43 | +`a_real_aomenc_stream_with_a_sub8_split_decodes_pixel_exact` -- **still RED**, | ||
| 44 | +but for a 4-pixel chroma residue instead of a desync: | ||
| 45 | +- symbol ladder vs instrumented aomdec is now **exact** on both sampled | ||
| 46 | + streams (324/324 elements seed=117, 318/318 seed=100), no refusal, decode | ||
| 47 | + completes; | ||
| 48 | +- luma is **bit-exact** on seed=100; | ||
| 49 | +- chroma differs on 4 pixels: U/V (row 20, cols 18-19), deltas 1..3. | ||
| 50 | + | ||
| 51 | +EVIDENCE: /tmp/.../scratchpad/{ref100.yuv,ours100.yuv} | aomenc seed=100 cq=6 recipe from the gate, decoded by ec-av1 and by ffmpeg | 4096/4096 luma bytes equal, 4/2048 chroma bytes differ (max |delta| 3); before this round the same stream refused at a hallucinated partition symbol | ||
| 52 | +EVIDENCE: /tmp/.../scratchpad/{ref.txt,ours.txt} + ladder.py | EC_TRACE/EC_TRACE_MODE_STEP ladder, ours vs instrumented aomdec, seed=117 | 324 elements, no divergence (was: first divergence at element 62) | ||
| 53 | + | ||
| 54 | +## Suite | ||
| 55 | +`cargo test -p ec-av1 --lib` (EC_AV1_REQUIRE_AOMENC=1): **267 passed, 2 failed, | ||
| 56 | +22 ignored**, 1124 s. | ||
| 57 | +- `stream::a_real_aomenc_stream_with_a_sub8_split_decodes_pixel_exact` -- the | ||
| 58 | + 4-pixel chroma residue above. | ||
| 59 | +- `refusal_inventory::the_decode_path_refuses_exactly_the_listed_cases` -- | ||
| 60 | + NOT investigated this round (budget). Expected shape: a refusal the | ||
| 61 | + inventory expects to fire no longer fires now that the desync is gone | ||
| 62 | + (that is what the fix was for), but it is a RED test and no refusal string | ||
| 63 | + was lifted this round. | ||
| 64 | + | ||
| 65 | +## Open | ||
| 66 | +- fix-now: the 4-pixel chroma residue (U/V row 20, cols 18-19 of the 64x64 | ||
| 67 | + seed=100 frame; block = chroma 4x4 at (20,16), luma 8x8 group mi(10,8)). | ||
| 68 | + Tried and REVERTED (no effect on these pixels): OR-ing the subsampling scale | ||
| 69 | + into the chroma edge's mi (`set_lpf_parameters`' `scale_vert | ...`) in | ||
| 70 | + `edge_params`. Next step: dump post-reconstruction vs `EC_AV1_PREFILT_DUMP` | ||
| 71 | + to separate recon from deblock before touching either. | ||
| 72 | +- fix-now: `refusal_inventory` red (see above). | ||
| 73 | +- deferred(gate green): lifting any refusal string -- nothing lifted, none | ||
| 74 | + proven. | ||