Inter 32x32-level HORZ/VERT decoded the frame-edge second strip libaom never coded
Browse files at this commit- fix
- inter 32x32-level HORZ/VERT decoded the frame-edge second strip libaom never coded
5 changed files +715 -217
- crates/ec-av1/examples/decode_probe.rs +5 -0
- crates/ec-av1/src/decode.rs +220 -104
- crates/ec-av1/src/stream.rs +324 -113
- lanes/cdef-r1.handoff.md +66 -0
- lanes/interedge-r1.report.md +100 -0
crates/ec-av1/examples/decode_probe.rsmodified+5 -0
| @@ -44,6 +44,11 @@ fn main() { | |||
| 44 | "inter_ab16: horz_a={} horz_b={} vert_a={} vert_b={}", | 44 | "inter_ab16: horz_a={} horz_b={} vert_a={} vert_b={}", |
| 45 | ab[0], ab[1], ab[2], ab[3] | 45 | ab[0], ab[1], ab[2], ab[3] |
| 46 | ); | 46 | ); |
| 47 | + let es = ec_av1::decode::inter_edge_strip_hits(); | ||
| 48 | + println!( | ||
| 49 | + "inter_edge_strip: h64={} v64={} h32={} v32={} h16={} v16={}", | ||
| 50 | + es[0], es[1], es[2], es[3], es[4], es[5] | ||
| 51 | + ); | ||
| 47 | let ir = ec_av1::stream::inter_rect_counters(); | 52 | let ir = ec_av1::stream::inter_rect_counters(); |
| 48 | println!( | 53 | println!( |
| 49 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", | 54 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", |
crates/ec-av1/src/decode.rsmodified+220 -104
| @@ -1162,6 +1162,36 @@ pub(crate) fn edge_rect_strip_hits() -> usize { | |||
| 1162 | EDGE_RECT_STRIP_HITS.with(|c| c.get()) | 1162 | EDGE_RECT_STRIP_HITS.with(|c| c.get()) |
| 1163 | } | 1163 | } |
| 1164 | 1164 | ||
| 1165 | +// lane-interedge r1: frame-edge half strips on the INTER path, per partition | ||
| 1166 | +// level (64/32/16) x axis (HORZ at a bottom edge, VERT at a right edge). The | ||
| 1167 | +// index is `level_idx * 2 + axis` with `level_idx` 0=64, 1=32, 2=16 and | ||
| 1168 | +// `axis` 0=HORZ (`!has_rows`), 1=VERT (`!has_cols`). Both of the user's films | ||
| 1169 | +// are height mod 16 == 8, so every inter frame crosses these nodes. | ||
| 1170 | +thread_local! { | ||
| 1171 | + static INTER_EDGE_STRIP_HITS: std::cell::Cell<[usize; 6]> = | ||
| 1172 | + const { std::cell::Cell::new([0; 6]) }; | ||
| 1173 | +} | ||
| 1174 | + | ||
| 1175 | +/// Bumps one bucket of [`INTER_EDGE_STRIP_HITS`]. | ||
| 1176 | +pub(crate) fn bump_inter_edge_strip(idx: usize) { | ||
| 1177 | + INTER_EDGE_STRIP_HITS.with(|c| { | ||
| 1178 | + let mut v = c.get(); | ||
| 1179 | + v[idx] += 1; | ||
| 1180 | + c.set(v); | ||
| 1181 | + }); | ||
| 1182 | +} | ||
| 1183 | + | ||
| 1184 | +/// Current value of [`INTER_EDGE_STRIP_HITS`] (`[h64, v64, h32, v32, h16, v16]`). | ||
| 1185 | +pub fn inter_edge_strip_hits() -> [usize; 6] { | ||
| 1186 | + INTER_EDGE_STRIP_HITS.with(|c| c.get()) | ||
| 1187 | +} | ||
| 1188 | + | ||
| 1189 | +/// Resets [`INTER_EDGE_STRIP_HITS`] -- a refused attempt must not carry hits | ||
| 1190 | +/// into the next one (class `counter-from-refused-stream`). | ||
| 1191 | +pub fn reset_inter_edge_strip_hits() { | ||
| 1192 | + INTER_EDGE_STRIP_HITS.with(|c| c.set([0; 6])); | ||
| 1193 | +} | ||
| 1194 | + | ||
| 1165 | // How many HORZ/VERT intra strips resolved a SPLIT luma transform | 1195 | // How many HORZ/VERT intra strips resolved a SPLIT luma transform |
| 1166 | // (`tx_depth != 0`) and decoded it per transform unit (lane-rectsplit r1) -- | 1196 | // (`tx_depth != 0`) and decoded it per transform unit (lane-rectsplit r1) -- |
| 1167 | // the case every rect path here refused by name before, and the first | 1197 | // the case every rect path here refused by name before, and the first |
| @@ -2585,6 +2615,28 @@ thread_local! { | |||
| 2585 | static SUB8_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2615 | static SUB8_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2586 | } | 2616 | } |
| 2587 | 2617 | ||
| 2618 | +// lane-cdef r1: (a) how many 8x8 CDEF units `apply_cdef` EXCLUDED because all | ||
| 2619 | +// four of their mi cells are `skip_txfm` (libaom `cdef.c:29-38` | ||
| 2620 | +// `is_8x8_block_skip` / `av1_cdef_compute_sb_list`'s dlist test), and (b) how | ||
| 2621 | +// many 8x8 inter leaves (`decode_inter_block8`) wrote that skip band at all. | ||
| 2622 | +// (b) was 0 for every stream before this round -- the leaf path never touched | ||
| 2623 | +// the band, so an all-skip 8x8 group kept the PREVIOUS frame's flags and got | ||
| 2624 | +// filtered where libaom skips it. A gate asserts both are non-zero. | ||
| 2625 | +thread_local! { | ||
| 2626 | + static CDEF_SKIPPED_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2627 | + static INTER8_SKIP_BAND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2628 | +} | ||
| 2629 | + | ||
| 2630 | +/// Current value of `CDEF_SKIPPED_UNITS`. | ||
| 2631 | +pub(crate) fn cdef_skipped_units() -> usize { | ||
| 2632 | + CDEF_SKIPPED_UNITS.with(|c| c.get()) | ||
| 2633 | +} | ||
| 2634 | + | ||
| 2635 | +/// Current value of `INTER8_SKIP_BAND_HITS`. | ||
| 2636 | +pub(crate) fn inter8_skip_band_hits() -> usize { | ||
| 2637 | + INTER8_SKIP_BAND_HITS.with(|c| c.get()) | ||
| 2638 | +} | ||
| 2639 | + | ||
| 2588 | /// Current value of [`SUB8_SPLIT_HITS`]. | 2640 | /// Current value of [`SUB8_SPLIT_HITS`]. |
| 2589 | pub(crate) fn sub8_split_hits() -> usize { | 2641 | pub(crate) fn sub8_split_hits() -> usize { |
| 2590 | SUB8_SPLIT_HITS.with(|c| c.get()) | 2642 | SUB8_SPLIT_HITS.with(|c| c.get()) |
| @@ -8864,7 +8916,7 @@ fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 { | |||
| 8864 | fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) { | 8916 | fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) { |
| 8865 | use std::io::Write; | 8917 | use std::io::Write; |
| 8866 | if let Ok(path) = std::env::var(var) | 8918 | if let Ok(path) = std::env::var(var) |
| 8867 | - && let Ok(mut f) = std::fs::File::create(format!("{path}.f0")) | 8919 | + && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var))) |
| 8868 | { | 8920 | { |
| 8869 | 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))] { | 8921 | 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))] { |
| 8870 | for row in 0..h { | 8922 | for row in 0..h { |
| @@ -8878,10 +8930,25 @@ fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, | |||
| 8878 | } | 8930 | } |
| 8879 | } | 8931 | } |
| 8880 | 8932 | ||
| 8933 | +/// Decode-order index of the next [`dump_stage`]/[`dump_stage16`] file for a | ||
| 8934 | +/// given env var -- lane-cdef r1: both used to write `.f0` unconditionally, so | ||
| 8935 | +/// every frame overwrote the previous one and only the LAST frame survived, | ||
| 8936 | +/// which silently defeats any per-frame filter-stage bisection. | ||
| 8937 | +fn dump_stage_idx(var: &str) -> usize { | ||
| 8938 | + use std::collections::HashMap; | ||
| 8939 | + use std::sync::{Mutex, OnceLock}; | ||
| 8940 | + static IDX: OnceLock<Mutex<HashMap<String, usize>>> = OnceLock::new(); | ||
| 8941 | + let mut m = IDX.get_or_init(|| Mutex::new(HashMap::new())).lock().unwrap(); | ||
| 8942 | + let e = m.entry(var.to_string()).or_insert(0); | ||
| 8943 | + let i = *e; | ||
| 8944 | + *e += 1; | ||
| 8945 | + i | ||
| 8946 | +} | ||
| 8947 | + | ||
| 8881 | fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { | 8948 | fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { |
| 8882 | use std::io::Write; | 8949 | use std::io::Write; |
| 8883 | if let Ok(path) = std::env::var(var) | 8950 | if let Ok(path) = std::env::var(var) |
| 8884 | - && let Ok(mut f) = std::fs::File::create(format!("{path}.f0")) | 8951 | + && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var))) |
| 8885 | { | 8952 | { |
| 8886 | for p in [y, u, v] { | 8953 | for p in [y, u, v] { |
| 8887 | let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect(); | 8954 | let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect(); |
| @@ -10394,6 +10461,7 @@ fn decode_leaf8( | |||
| 10394 | neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]); | 10461 | neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]); |
| 10395 | neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]); | 10462 | neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]); |
| 10396 | } | 10463 | } |
| 10464 | + INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); | ||
| 10397 | neighbours.fill_skip_grid(leaf_mi, 2, skip); | 10465 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 10398 | neighbours.fill_lf_grid(leaf_mi, 2, 8, 0); | 10466 | neighbours.fill_lf_grid(leaf_mi, 2, 8, 0); |
| 10399 | neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode); | 10467 | neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode); |
| @@ -12749,6 +12817,9 @@ fn apply_cdef( | |||
| 12749 | while mi_r < skip_grid.mi_rows { | 12817 | while mi_r < skip_grid.mi_rows { |
| 12750 | let mut mi_c = 0usize; | 12818 | let mut mi_c = 0usize; |
| 12751 | while mi_c < skip_grid.mi_cols { | 12819 | while mi_c < skip_grid.mi_cols { |
| 12820 | + if skip_grid.is_skip_txfm(mi_r, mi_c) { | ||
| 12821 | + CDEF_SKIPPED_UNITS.with(|c| c.set(c.get() + 1)); | ||
| 12822 | + } | ||
| 12752 | if !skip_grid.is_skip_txfm(mi_r, mi_c) { | 12823 | if !skip_grid.is_skip_txfm(mi_r, mi_c) { |
| 12753 | let sidx = strength_idx(mi_r, mi_c); | 12824 | let sidx = strength_idx(mi_r, mi_c); |
| 12754 | let (ox, oy) = (mi_c * 4, mi_r * 4); | 12825 | let (ox, oy) = (mi_c * 4, mi_r * 4); |
| @@ -12761,10 +12832,15 @@ fn apply_cdef( | |||
| 12761 | i32::from(src_y[ny as usize * y_stride + nx as usize]) | 12832 | i32::from(src_y[ny as usize * y_stride + nx as usize]) |
| 12762 | } | 12833 | } |
| 12763 | }; | 12834 | }; |
| 12764 | - let (dir, var) = cdef_find_dir(coeff_shift, |r, c| { | 12835 | + // lane-cdef r1: the direction search reads the SAME padded |
| 12765 | - let (ny, nx) = ((oy + r).min(y_true_h - 1), (ox + c).min(y_true_w - 1)); | 12836 | + // block the taps do -- libaom runs `cdef_find_dir` on the |
| 12766 | - i32::from(src_y[ny * y_stride + nx]) | 12837 | + // prepared filter block (`cdef_block.c:296-320` over |
| 12767 | - }); | 12838 | + // `cdef_prepare_fb`'s buffer, `cdef.c:249-256`), whose columns |
| 12839 | + // and rows past the mi-rounded frame extent are CDEF_VERY_LARGE. | ||
| 12840 | + // Clamping to the last real sample instead made every straddling | ||
| 12841 | + // edge 8x8 (odd `mi_cols`/`mi_rows`) pick a different var, hence | ||
| 12842 | + // a different `adjust_strength`, hence a +-1 band at the crop edge. | ||
| 12843 | + let (dir, var) = cdef_find_dir(coeff_shift, |r, c| sample_y(r as i32, c as i32)); | ||
| 12768 | 12844 | ||
| 12769 | // libaom `av1_cdef_filter_fb` passes `pri_strength ? dir : 0` | 12845 | // libaom `av1_cdef_filter_fb` passes `pri_strength ? dir : 0` |
| 12770 | // -- each plane zeroes the shared direction when *its own* | 12846 | // -- each plane zeroes the shared direction when *its own* |
| @@ -12774,6 +12850,12 @@ fn apply_cdef( | |||
| 12774 | let y_sec_strength = i32::from(cdef.y_sec_strength[sidx]) << coeff_shift; | 12850 | let y_sec_strength = i32::from(cdef.y_sec_strength[sidx]) << coeff_shift; |
| 12775 | let y_dir = if y_pri_strength != 0 { dir } else { 0 }; | 12851 | let y_dir = if y_pri_strength != 0 { dir } else { 0 }; |
| 12776 | let t = cdef_adjust_strength(y_pri_strength, var); | 12852 | let t = cdef_adjust_strength(y_pri_strength, var); |
| 12853 | + // lane-cdef r1 rung: one line per filtered 8x8 luma CDEF unit. | ||
| 12854 | + if std::env::var_os("EC_AV1_CDEF_DBG").is_some() { | ||
| 12855 | + eprintln!( | ||
| 12856 | + "EC_CDEF mi_r={mi_r} mi_c={mi_c} x={ox} y={oy} sidx={sidx} dir={dir} var={var} t={t} pri={y_pri_strength} sec={y_sec_strength} damp={damping}" | ||
| 12857 | + ); | ||
| 12858 | + } | ||
| 12777 | let enable_primary = t != 0; | 12859 | let enable_primary = t != 0; |
| 12778 | let enable_secondary = y_sec_strength != 0; | 12860 | let enable_secondary = y_sec_strength != 0; |
| 12779 | if enable_primary || enable_secondary { | 12861 | if enable_primary || enable_secondary { |
| @@ -19821,6 +19903,14 @@ fn decode_inter_block8( | |||
| 19821 | // so the 16x16 below a split block read partition ctx 0 | 19903 | // so the 16x16 below a split block read partition ctx 0 |
| 19822 | // instead of 1 and mis-read PARTITION_SPLIT as NONE. | 19904 | // instead of 1 and mis-read PARTITION_SPLIT as NONE. |
| 19823 | neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); | 19905 | neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); |
| 19906 | + // lane-cdef r1: ... and the CDEF skip band too. `apply_cdef`'s | ||
| 19907 | + // `is_8x8_block_skip` (libaom `cdef.c:29-38`) reads all four mi | ||
| 19908 | + // cells of the 8x8; this leaf wrote none of them, so a 64x64 | ||
| 19909 | + // whose bottom-right 16x16 is an all-skip 8x8-leaf group kept | ||
| 19910 | + // the PREVIOUS frame's flags and got filtered where libaom's | ||
| 19911 | + // dlist excludes it (3 luma samples on a 192x128 inter frame). | ||
| 19912 | + INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); | ||
| 19913 | + neighbours.fill_skip_grid(leaf_mi, 2, skip); | ||
| 19824 | neighbours.fill_lf_grid( | 19914 | neighbours.fill_lf_grid( |
| 19825 | leaf_mi, | 19915 | leaf_mi, |
| 19826 | 2, | 19916 | 2, |
| @@ -20626,6 +20716,10 @@ fn decode_inter_block8( | |||
| 20626 | // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference | 20716 | // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference |
| 20627 | // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every | 20717 | // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every |
| 20628 | // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test). | 20718 | // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test). |
| 20719 | + // lane-cdef r1: the fall-through twin of the compound arm's skip-band | ||
| 20720 | + // write above -- `skip` is one flag for the whole 8x8 leaf (read at | ||
| 20721 | + // `decode.rs`'s `skip_ctx` site), `split8` only splits its transform. | ||
| 20722 | + neighbours.fill_skip_grid(leaf_mi, 2, skip); | ||
| 20629 | neighbours.fill_lf_grid( | 20723 | neighbours.fill_lf_grid( |
| 20630 | leaf_mi, | 20724 | leaf_mi, |
| 20631 | 2, | 20725 | 2, |
| @@ -21399,6 +21493,9 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 21399 | bw, | 21493 | bw, |
| 21400 | bh | 21494 | bh |
| 21401 | ); | 21495 | ); |
| 21496 | + if !four && i == 0 && ((horz && !has_rows) || (!horz && !has_cols)) { | ||
| 21497 | + bump_inter_edge_strip(if horz { 0 } else { 1 }); | ||
| 21498 | + } | ||
| 21402 | match (horz, four) { | 21499 | match (horz, four) { |
| 21403 | (true, false) => INTER_SB_HORZ_HITS.with(|c| c.set(c.get() + 1)), | 21500 | (true, false) => INTER_SB_HORZ_HITS.with(|c| c.set(c.get() + 1)), |
| 21404 | (false, false) => INTER_SB_VERT_HITS.with(|c| c.set(c.get() + 1)), | 21501 | (false, false) => INTER_SB_VERT_HITS.with(|c| c.set(c.get() + 1)), |
| @@ -21664,6 +21761,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 21664 | && (piece_mi.0 >= mi_rows as usize | 21761 | && (piece_mi.0 >= mi_rows as usize |
| 21665 | || piece_mi.1 >= mi_cols as usize) | 21762 | || piece_mi.1 >= mi_cols as usize) |
| 21666 | { | 21763 | { |
| 21764 | + bump_inter_edge_strip(if horz { 4 } else { 5 }); | ||
| 21667 | break; | 21765 | break; |
| 21668 | } | 21766 | } |
| 21669 | decode_inter_block( | 21767 | decode_inter_block( |
| @@ -22188,55 +22286,64 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 22188 | allow_screen_content_tools, | 22286 | allow_screen_content_tools, |
| 22189 | frame_width as usize, | 22287 | frame_width as usize, |
| 22190 | )?; | 22288 | )?; |
| 22191 | - decode_inter_block( | 22289 | + // libaom `decode_partition` codes the second half of a |
| 22192 | - &mut dec, | 22290 | + // HORZ/VERT only when `has_rows`/`has_cols` -- at the true |
| 22193 | - &mut cdfs, | 22291 | + // frame edge the bottom (right) half is outside the frame and |
| 22194 | - &mut neighbours, | 22292 | + // carries NO symbols and no grid writes (decodeframe.c |
| 22195 | - &mut grid, | 22293 | + // `decode_partition`, PARTITION_HORZ/PARTITION_VERT). |
| 22196 | - sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)), | 22294 | + if has_rows32 { |
| 22197 | - BLOCK, | 22295 | + decode_inter_block( |
| 22198 | - mi_cols, | 22296 | + &mut dec, |
| 22199 | - mi_rows, | 22297 | + &mut cdfs, |
| 22200 | - &mut y, | 22298 | + &mut neighbours, |
| 22201 | - &mut u, | 22299 | + &mut grid, |
| 22202 | - &mut v, | 22300 | + sub16_to_mi((r32 as usize * 2 + 1, c32 as usize * 2)), |
| 22203 | - &ref_y, | 22301 | + BLOCK, |
| 22204 | - &ref_u, | 22302 | + mi_cols, |
| 22205 | - &ref_v, | 22303 | + mi_rows, |
| 22206 | - &ref_slots, | 22304 | + &mut y, |
| 22207 | - &sign_bias_table, | 22305 | + &mut u, |
| 22208 | - &global_motion, | 22306 | + &mut v, |
| 22209 | - base_q_idx, | 22307 | + &ref_y, |
| 22210 | - TxbSet::Luma32, | 22308 | + &ref_u, |
| 22211 | - TxbSet::Luma32Inter, | 22309 | + &ref_v, |
| 22212 | - TxbSet::Chroma16, | 22310 | + &ref_slots, |
| 22213 | - TX32, | 22311 | + &sign_bias_table, |
| 22214 | - TX16, | 22312 | + &global_motion, |
| 22215 | - &scan32, | 22313 | + base_q_idx, |
| 22216 | - &scan16, | 22314 | + TxbSet::Luma32, |
| 22217 | - 3, | 22315 | + TxbSet::Luma32Inter, |
| 22218 | - allow_high_precision_mv, | 22316 | + TxbSet::Chroma16, |
| 22219 | - force_integer_mv, | 22317 | + TX32, |
| 22220 | - interp_fixed, | 22318 | + TX16, |
| 22221 | - enable_dual_filter, | 22319 | + &scan32, |
| 22222 | - tpl_frame.as_ref(), | 22320 | + &scan16, |
| 22223 | - reference_select, | 22321 | + 3, |
| 22224 | - enable_masked_compound, | 22322 | + allow_high_precision_mv, |
| 22225 | - enable_interintra_compound, | 22323 | + force_integer_mv, |
| 22226 | - enable_jnt_comp, | 22324 | + interp_fixed, |
| 22227 | - order_hint_bits, | 22325 | + enable_dual_filter, |
| 22228 | - order_hint, | 22326 | + tpl_frame.as_ref(), |
| 22229 | - ref_order_hints, | 22327 | + reference_select, |
| 22230 | - skip_mode_present, | 22328 | + enable_masked_compound, |
| 22231 | - skip_mode_frame, | 22329 | + enable_interintra_compound, |
| 22232 | - switchable_motion_mode, | 22330 | + enable_jnt_comp, |
| 22233 | - allow_warped_motion, | 22331 | + order_hint_bits, |
| 22234 | - true, | 22332 | + order_hint, |
| 22235 | - BLOCK, | 22333 | + ref_order_hints, |
| 22236 | - SUB, | 22334 | + skip_mode_present, |
| 22237 | - allow_screen_content_tools, | 22335 | + skip_mode_frame, |
| 22238 | - frame_width as usize, | 22336 | + switchable_motion_mode, |
| 22239 | - )?; | 22337 | + allow_warped_motion, |
| 22338 | + true, | ||
| 22339 | + BLOCK, | ||
| 22340 | + SUB, | ||
| 22341 | + allow_screen_content_tools, | ||
| 22342 | + frame_width as usize, | ||
| 22343 | + )?; | ||
| 22344 | + } else { | ||
| 22345 | + bump_inter_edge_strip(2); | ||
| 22346 | + } | ||
| 22240 | } | 22347 | } |
| 22241 | PARTITION_VERT => { | 22348 | PARTITION_VERT => { |
| 22242 | // lane-rect r2: mirror of PARTITION_HORZ above with | 22349 | // lane-rect r2: mirror of PARTITION_HORZ above with |
| @@ -22291,55 +22398,64 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 22291 | allow_screen_content_tools, | 22398 | allow_screen_content_tools, |
| 22292 | frame_width as usize, | 22399 | frame_width as usize, |
| 22293 | )?; | 22400 | )?; |
| 22294 | - decode_inter_block( | 22401 | + // libaom `decode_partition` codes the second half of a |
| 22295 | - &mut dec, | 22402 | + // HORZ/VERT only when `has_rows`/`has_cols` -- at the true |
| 22296 | - &mut cdfs, | 22403 | + // frame edge the bottom (right) half is outside the frame and |
| 22297 | - &mut neighbours, | 22404 | + // carries NO symbols and no grid writes (decodeframe.c |
| 22298 | - &mut grid, | 22405 | + // `decode_partition`, PARTITION_HORZ/PARTITION_VERT). |
| 22299 | - sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)), | 22406 | + if has_cols32 { |
| 22300 | - BLOCK, | 22407 | + decode_inter_block( |
| 22301 | - mi_cols, | 22408 | + &mut dec, |
| 22302 | - mi_rows, | 22409 | + &mut cdfs, |
| 22303 | - &mut y, | 22410 | + &mut neighbours, |
| 22304 | - &mut u, | 22411 | + &mut grid, |
| 22305 | - &mut v, | 22412 | + sub16_to_mi((r32 as usize * 2, c32 as usize * 2 + 1)), |
| 22306 | - &ref_y, | 22413 | + BLOCK, |
| 22307 | - &ref_u, | 22414 | + mi_cols, |
| 22308 | - &ref_v, | 22415 | + mi_rows, |
| 22309 | - &ref_slots, | 22416 | + &mut y, |
| 22310 | - &sign_bias_table, | 22417 | + &mut u, |
| 22311 | - &global_motion, | 22418 | + &mut v, |
| 22312 | - base_q_idx, | 22419 | + &ref_y, |
| 22313 | - TxbSet::Luma32, | 22420 | + &ref_u, |
| 22314 | - TxbSet::Luma32Inter, | 22421 | + &ref_v, |
| 22315 | - TxbSet::Chroma16, | 22422 | + &ref_slots, |
| 22316 | - TX32, | 22423 | + &sign_bias_table, |
| 22317 | - TX16, | 22424 | + &global_motion, |
| 22318 | - &scan32, | 22425 | + base_q_idx, |
| 22319 | - &scan16, | 22426 | + TxbSet::Luma32, |
| 22320 | - 3, | 22427 | + TxbSet::Luma32Inter, |
| 22321 | - allow_high_precision_mv, | 22428 | + TxbSet::Chroma16, |
| 22322 | - force_integer_mv, | 22429 | + TX32, |
| 22323 | - interp_fixed, | 22430 | + TX16, |
| 22324 | - enable_dual_filter, | 22431 | + &scan32, |
| 22325 | - tpl_frame.as_ref(), | 22432 | + &scan16, |
| 22326 | - reference_select, | 22433 | + 3, |
| 22327 | - enable_masked_compound, | 22434 | + allow_high_precision_mv, |
| 22328 | - enable_interintra_compound, | 22435 | + force_integer_mv, |
| 22329 | - enable_jnt_comp, | 22436 | + interp_fixed, |
| 22330 | - order_hint_bits, | 22437 | + enable_dual_filter, |
| 22331 | - order_hint, | 22438 | + tpl_frame.as_ref(), |
| 22332 | - ref_order_hints, | 22439 | + reference_select, |
| 22333 | - skip_mode_present, | 22440 | + enable_masked_compound, |
| 22334 | - skip_mode_frame, | 22441 | + enable_interintra_compound, |
| 22335 | - switchable_motion_mode, | 22442 | + enable_jnt_comp, |
| 22336 | - allow_warped_motion, | 22443 | + order_hint_bits, |
| 22337 | - true, | 22444 | + order_hint, |
| 22338 | - SUB, | 22445 | + ref_order_hints, |
| 22339 | - BLOCK, | 22446 | + skip_mode_present, |
| 22340 | - allow_screen_content_tools, | 22447 | + skip_mode_frame, |
| 22341 | - frame_width as usize, | 22448 | + switchable_motion_mode, |
| 22342 | - )?; | 22449 | + allow_warped_motion, |
| 22450 | + true, | ||
| 22451 | + SUB, | ||
| 22452 | + BLOCK, | ||
| 22453 | + allow_screen_content_tools, | ||
| 22454 | + frame_width as usize, | ||
| 22455 | + )?; | ||
| 22456 | + } else { | ||
| 22457 | + bump_inter_edge_strip(3); | ||
| 22458 | + } | ||
| 22343 | } | 22459 | } |
| 22344 | PARTITION_HORZ_A => { | 22460 | PARTITION_HORZ_A => { |
| 22345 | // lane-partab r1: two 16x16 squares on top + a true | 22461 | // lane-partab r1: two 16x16 squares on top + a true |
crates/ec-av1/src/stream.rsmodified+324 -113
| @@ -961,17 +961,142 @@ mod tests { | |||
| 961 | ); | 961 | ); |
| 962 | } | 962 | } |
| 963 | 963 | ||
| 964 | - /// lane-oddh r2 GATE: the frame-edge half-strip arms r1 added (a 64x32 / | 964 | + /// lane-interedge r1: one attempt of the inter frame-edge half-strip gate -- |
| 965 | - /// 32x64 superblock-level or 16x8 / 8x16 16-level INTER block where the | 965 | + /// encode `width x height` with real aomenc (rect partitions ON, every other |
| 966 | - /// frame's true edge cuts the strip in half) actually fire and decode | 966 | + /// lane's open tool pinned off), decode it, and return |
| 967 | - /// pixel-exact, at both bit depths. 160 = two full superblock rows plus | 967 | + /// `(inter_edge_strip hits, frames whose LUMA differs, frames whose CHROMA |
| 968 | - /// 32 pixels, so every superblock in the last row is a half strip; without | 968 | + /// differs)` against ffmpeg. A refusal or a decode error is a hard failure: |
| 969 | - /// r1's arms these attempts refused outright, which is why this gate | 969 | + /// this recipe reached every size without one (measured r1). |
| 970 | - /// asserts a nonzero `edge_rect_strip_hits` DELTA on attempts that were | 970 | + fn inter_edge_strip_attempt( |
| 971 | - /// actually compared -- a refused attempt's hits would prove nothing | 971 | + name: &str, |
| 972 | - /// (class "counter from refused stream"). | 972 | + width: usize, |
| 973 | + height: usize, | ||
| 974 | + bit_depth: u32, | ||
| 975 | + cq: u32, | ||
| 976 | + frames: usize, | ||
| 977 | + ) -> ([usize; 6], usize, usize) { | ||
| 978 | + let duration = format!("{}", frames as f64 / 25.0); | ||
| 979 | + let source = format!("mandelbrot=size={width}x{height}:rate=25"); | ||
| 980 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 981 | + let y4m = Command::new("ffmpeg") | ||
| 982 | + .args([ | ||
| 983 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration, "-pix_fmt", | ||
| 984 | + pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 985 | + ]) | ||
| 986 | + .stdin(Stdio::null()) | ||
| 987 | + .stdout(Stdio::piped()) | ||
| 988 | + .stderr(Stdio::piped()) | ||
| 989 | + .output() | ||
| 990 | + .expect("ffmpeg failed to run"); | ||
| 991 | + assert!( | ||
| 992 | + y4m.status.success(), | ||
| 993 | + "{name}: ffmpeg refused the {width}x{height} {bit_depth}-bit fixture: {}", | ||
| 994 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 995 | + ); | ||
| 996 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 997 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 998 | + let cq_arg = format!("--cq-level={cq}"); | ||
| 999 | + let limit_arg = format!("--limit={frames}"); | ||
| 1000 | + let mut child = Command::new(aomenc_path()) | ||
| 1001 | + .args([ | ||
| 1002 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, | ||
| 1003 | + // cpu-used >= 1 keeps libaom on 64x64 superblocks at these | ||
| 1004 | + // sizes (`av1_select_sb_size`). | ||
| 1005 | + "--cpu-used=4", "--threads=1", "--row-mt=0", "--kf-max-dist=9999", | ||
| 1006 | + &limit_arg, | ||
| 1007 | + // decode order == display order, so the compare below covers | ||
| 1008 | + // every frame the stream carries (class gate-blind-to-hidden-frames). | ||
| 1009 | + "--lag-in-frames=0", &depth_arg, &input_depth_arg, | ||
| 1010 | + // Rect partitions stay ON: the frame-edge strip is a FORCED | ||
| 1011 | + // (gathered) HORZ/VERT, but with rect coding off the encoder | ||
| 1012 | + // answers that gathered symbol SPLIT every time and no edge | ||
| 1013 | + // strip ever fires (lane-oddh r2's finding, re-measured r1). | ||
| 1014 | + "--enable-rect-partitions=1", "--enable-ab-partitions=0", | ||
| 1015 | + "--enable-1to4-partitions=0", "--min-partition-size=8", | ||
| 1016 | + "--max-partition-size=64", | ||
| 1017 | + // Other lanes' open gaps this recipe must not trip. | ||
| 1018 | + "--enable-palette=0", "--enable-intrabc=0", "--enable-warped-motion=0", | ||
| 1019 | + "--enable-obmc=0", "--enable-masked-comp=0", "--enable-interintra-comp=0", | ||
| 1020 | + "--enable-onesided-comp=0", "--enable-interintra-wedge=0", | ||
| 1021 | + "--enable-smooth-interintra=0", "--enable-ref-frame-mvs=0", | ||
| 1022 | + "--enable-angle-delta=0", "--enable-cfl-intra=0", | ||
| 1023 | + "--enable-directional-intra=0", "--enable-smooth-intra=0", | ||
| 1024 | + "--enable-paeth-intra=0", "--enable-filter-intra=0", | ||
| 1025 | + "--enable-tx-size-search=0", | ||
| 1026 | + "--obu", "-o", "-", "-", | ||
| 1027 | + ]) | ||
| 1028 | + .stdin(Stdio::piped()) | ||
| 1029 | + .stdout(Stdio::piped()) | ||
| 1030 | + .stderr(Stdio::piped()) | ||
| 1031 | + .spawn() | ||
| 1032 | + .expect("aomenc failed to start"); | ||
| 1033 | + child | ||
| 1034 | + .stdin | ||
| 1035 | + .take() | ||
| 1036 | + .expect("aomenc stdin") | ||
| 1037 | + .write_all(&y4m.stdout) | ||
| 1038 | + .expect("write y4m"); | ||
| 1039 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 1040 | + assert!( | ||
| 1041 | + out.status.success(), | ||
| 1042 | + "aomenc refused: {}", | ||
| 1043 | + String::from_utf8_lossy(&out.stderr) | ||
| 1044 | + ); | ||
| 1045 | + let stream = out.stdout; | ||
| 1046 | + | ||
| 1047 | + // Reset, never a delta: a refused attempt's hits must not leak into the | ||
| 1048 | + // next one (class counter-from-refused-stream). | ||
| 1049 | + crate::decode::reset_inter_edge_strip_hits(); | ||
| 1050 | + let decoded = decode_stream(&stream).unwrap_or_else(|e| { | ||
| 1051 | + panic!("{name}: {width}x{height} {bit_depth}-bit cq {cq} did not decode: {e}") | ||
| 1052 | + }); | ||
| 1053 | + let hits = crate::decode::inter_edge_strip_hits(); | ||
| 1054 | + let reference = if bit_depth == 10 { | ||
| 1055 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames) | ||
| 1056 | + } else { | ||
| 1057 | + ffmpeg_decode_sequence(&stream, width, height, frames) | ||
| 1058 | + }; | ||
| 1059 | + assert_eq!( | ||
| 1060 | + decoded.len(), | ||
| 1061 | + reference.len(), | ||
| 1062 | + "{name}: {width}x{height} {bit_depth}-bit cq {cq} frame count" | ||
| 1063 | + ); | ||
| 1064 | + assert!( | ||
| 1065 | + decoded.len() >= frames, | ||
| 1066 | + "{name}: {width}x{height} {bit_depth}-bit cq {cq} decoded only {} frames", | ||
| 1067 | + decoded.len() | ||
| 1068 | + ); | ||
| 1069 | + let (mut luma_bad, mut chroma_bad) = (0usize, 0usize); | ||
| 1070 | + for (ours, theirs) in decoded.iter().zip(&reference) { | ||
| 1071 | + if ours.y != theirs.y { | ||
| 1072 | + luma_bad += 1; | ||
| 1073 | + } | ||
| 1074 | + if ours.u != theirs.u || ours.v != theirs.v { | ||
| 1075 | + chroma_bad += 1; | ||
| 1076 | + } | ||
| 1077 | + } | ||
| 1078 | + (hits, luma_bad, chroma_bad) | ||
| 1079 | + } | ||
| 1080 | + | ||
| 1081 | + /// lane-interedge r1 GATE (was lane-oddh r2's `#[ignore]`d twin): the INTER | ||
| 1082 | + /// frame-edge half strips -- a `PARTITION_HORZ`/`PARTITION_VERT` forced by | ||
| 1083 | + /// the gathered edge symbol at the 64, 32 or 16 level whose second half lies | ||
| 1084 | + /// outside the true frame. Both of the user's films are height mod 16 == 8 | ||
| 1085 | + /// (1920x792, 3840x1608), so every inter frame crosses these nodes. | ||
| 1086 | + /// | ||
| 1087 | + /// r1 root cause: the inter tile's 32-level `PARTITION_HORZ`/`PARTITION_VERT` | ||
| 1088 | + /// decoded the SECOND strip unconditionally, while libaom `decode_partition` | ||
| 1089 | + /// (decodeframe.c, PARTITION_HORZ) guards it with `has_rows`/`has_cols` -- | ||
| 1090 | + /// so at the edge we read symbols the encoder never wrote. With that guard | ||
| 1091 | + /// removed this gate's 72x192 cq 32 arm refuses outright and its 104x192 arm | ||
| 1092 | + /// decodes luma rows 127..191 of frame 5 wrong (measured r1). | ||
| 1093 | + /// | ||
| 1094 | + /// The compare is LUMA-exact per frame plus a CONTROL size with no edge node | ||
| 1095 | + /// at all: chroma is excluded because a chroma-only inter residue that has | ||
| 1096 | + /// nothing to do with the frame edge is open on main (lanes/tiny-r3, | ||
| 1097 | + /// lanes/gmaffine-r4, lanes/palette2-r8) and the control below reproduces it | ||
| 1098 | + /// with `inter_edge_strip_hits` all zero. | ||
| 973 | #[test] | 1099 | #[test] |
| 974 | - #[ignore = "2026-09-02 lane-oddh r2: no aomenc recipe reaches the INTER edge half-strip arm yet -- rect partitions OFF makes the encoder answer the forced gathered edge symbol SPLIT every time (both bit depths decode 192x160 pixel-exact, edge_rect_strip_hits=0), and rect ON stops at three other lanes' gaps first: at cq 40 'a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding', at cq 62 'an INTER 32x32 partition type this decoder does not code (value=8/9)' (HORZ_4/VERT_4 even with --enable-1to4-partitions=0), and at min-partition 16 'a HORZ/VERT intra strip below 16x16 with a split transform'. The KEY-frame half of the same edge is gated: the tiny size sweep now covers 64x72/72x64/64x136/136x64/192x136"] | ||
| 975 | fn a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact() { | 1100 | fn a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact() { |
| 976 | const NAME: &str = "a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact"; | 1101 | const NAME: &str = "a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact"; |
| 977 | let _gate_lock = lock_gate_counters(); | 1102 | let _gate_lock = lock_gate_counters(); |
| @@ -979,116 +1104,57 @@ mod tests { | |||
| 979 | eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); | 1104 | eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); |
| 980 | return; | 1105 | return; |
| 981 | } | 1106 | } |
| 982 | - let (width, height, frames) = (192usize, 160usize, 6usize); | 1107 | + let frames = 6usize; |
| 1108 | + // h mod 16 == 8 (bottom edge) and w mod 16 == 8 (right edge). | ||
| 1109 | + let sizes: &[(usize, usize)] = &[(192, 72), (192, 88), (72, 192), (88, 192), (104, 192)]; | ||
| 1110 | + let mut totals = [0usize; 6]; | ||
| 983 | let mut compared = 0u32; | 1111 | let mut compared = 0u32; |
| 984 | - let mut strip_hits = 0usize; | 1112 | + let mut chroma_frames = 0usize; |
| 985 | - let mut refused = 0u32; | 1113 | + for &(width, height) in sizes { |
| 986 | - for bit_depth in [8u32, 10u32] { | 1114 | + for bit_depth in [8u32, 10] { |
| 987 | - let duration = frames as f64 / 25.0; | 1115 | + for cq in [20u32, 32, 45] { |
| 988 | - let source = format!("testsrc2=size={width}x{height}:duration={duration}:rate=25"); | 1116 | + let (hits, luma_bad, chroma_bad) = |
| 989 | - let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | 1117 | + inter_edge_strip_attempt(NAME, width, height, bit_depth, cq, frames); |
| 990 | - let y4m = Command::new("ffmpeg") | 1118 | + assert_eq!( |
| 991 | - .args([ | 1119 | + luma_bad, 0, |
| 992 | - "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | 1120 | + "{NAME}: {width}x{height} {bit_depth}-bit cq {cq}: {luma_bad} of {frames} \ |
| 993 | - "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | 1121 | + frames differ from ffmpeg in LUMA (edge hits {hits:?})" |
| 994 | - ]) | ||
| 995 | - .stdin(Stdio::null()) | ||
| 996 | - .stdout(Stdio::piped()) | ||
| 997 | - .stderr(Stdio::piped()) | ||
| 998 | - .output() | ||
| 999 | - .expect("ffmpeg failed to run"); | ||
| 1000 | - assert!( | ||
| 1001 | - y4m.status.success(), | ||
| 1002 | - "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 1003 | - String::from_utf8_lossy(&y4m.stderr) | ||
| 1004 | - ); | ||
| 1005 | - let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 1006 | - let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 1007 | - let mut child = Command::new(aomenc_path()) | ||
| 1008 | - .args([ | ||
| 1009 | - "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=62", | ||
| 1010 | - // cpu-used >= 1 keeps libaom on 64x64 superblocks at this | ||
| 1011 | - // size (`av1_select_sb_size`: speed >= 1 and <= 480p). | ||
| 1012 | - "--cpu-used=4", "--threads=1", "--row-mt=0", "--kf-max-dist=1000", | ||
| 1013 | - &depth_arg, &input_depth_arg, | ||
| 1014 | - // The tool set every sibling inter gate pins; the edge | ||
| 1015 | - // strip itself needs rect partitions left ON. | ||
| 1016 | - "--enable-warped-motion=0", "--enable-obmc=0", "--enable-masked-comp=0", | ||
| 1017 | - "--enable-interintra-comp=0", "--enable-onesided-comp=0", | ||
| 1018 | - "--enable-interintra-wedge=0", "--enable-smooth-interintra=0", | ||
| 1019 | - // Rect partitions stay ON: the edge strip is a FORCED | ||
| 1020 | - // (gathered) HORZ at the boundary, but with rect coding | ||
| 1021 | - // off the encoder answers that gathered symbol SPLIT every | ||
| 1022 | - // time and the arm never fires (measured, r2). | ||
| 1023 | - "--enable-ab-partitions=0", "--enable-1to4-partitions=0", | ||
| 1024 | - "--enable-palette=0", "--enable-intrabc=0", "--enable-cdef=0", | ||
| 1025 | - "--enable-restoration=0", "--enable-ref-frame-mvs=0", | ||
| 1026 | - "--enable-tx-size-search=0", "--enable-filter-intra=0", | ||
| 1027 | - "--enable-smooth-intra=0", "--enable-paeth-intra=0", | ||
| 1028 | - "--enable-directional-intra=0", "--enable-angle-delta=0", | ||
| 1029 | - "--enable-cfl-intra=0", | ||
| 1030 | - // 16 is the smallest leaf this decoder codes rect strips | ||
| 1031 | - // at; below it the sub-16 strip/1:4 refusals fire first | ||
| 1032 | - // and the gate never reaches the edge arm. | ||
| 1033 | - // 160 = two full superblock rows plus 32, so the forced | ||
| 1034 | - // HORZ at the last row is a 64x32 -- the superblock-level | ||
| 1035 | - // arm -- and a 32 floor keeps the run out of the sub-16 | ||
| 1036 | - // rect-strip gap another lane owns. | ||
| 1037 | - "--min-partition-size=32", "--max-partition-size=64", | ||
| 1038 | - "--obu", "-o", "-", "-", | ||
| 1039 | - ]) | ||
| 1040 | - .stdin(Stdio::piped()) | ||
| 1041 | - .stdout(Stdio::piped()) | ||
| 1042 | - .stderr(Stdio::piped()) | ||
| 1043 | - .spawn() | ||
| 1044 | - .expect("aomenc failed to start"); | ||
| 1045 | - child.stdin.take().expect("aomenc stdin").write_all(&y4m.stdout).expect("write y4m"); | ||
| 1046 | - let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 1047 | - assert!(out.status.success(), "aomenc refused: {}", String::from_utf8_lossy(&out.stderr)); | ||
| 1048 | - let stream = out.stdout; | ||
| 1049 | - | ||
| 1050 | - let before = crate::decode::edge_rect_strip_hits(); | ||
| 1051 | - let decoded = match decode_stream(&stream) { | ||
| 1052 | - Ok(f) => f, | ||
| 1053 | - Err(e) => { | ||
| 1054 | - let msg = e.to_string(); | ||
| 1055 | - assert!( | ||
| 1056 | - msg.contains("unsupported"), | ||
| 1057 | - "{NAME}: {bit_depth}-bit failed outright, not a named refusal: {msg}" | ||
| 1058 | ); | 1122 | ); |
| 1059 | - eprintln!("{NAME}: {bit_depth}-bit REFUSED {msg}"); | 1123 | + for (t, h) in totals.iter_mut().zip(hits) { |
| 1060 | - refused += 1; | 1124 | + *t += h; |
| 1061 | - continue; | 1125 | + } |
| 1126 | + chroma_frames += chroma_bad; | ||
| 1127 | + compared += 1; | ||
| 1062 | } | 1128 | } |
| 1063 | - }; | ||
| 1064 | - let reference = if bit_depth == 10 { | ||
| 1065 | - ffmpeg_decode_sequence_10bit(&stream, width, height, frames) | ||
| 1066 | - } else { | ||
| 1067 | - ffmpeg_decode_sequence(&stream, width, height, frames) | ||
| 1068 | - }; | ||
| 1069 | - assert_eq!( | ||
| 1070 | - decoded.len(), | ||
| 1071 | - reference.len(), | ||
| 1072 | - "{NAME}: {bit_depth}-bit frame count" | ||
| 1073 | - ); | ||
| 1074 | - for (i, (ours, theirs)) in decoded.iter().zip(&reference).enumerate() { | ||
| 1075 | - let nd = |a: &[u16], b: &[u16]| a.iter().zip(b).filter(|(x, y)| x != y).count(); | ||
| 1076 | - assert_eq!( | ||
| 1077 | - (nd(&ours.y, &theirs.y), nd(&ours.u, &theirs.u), nd(&ours.v, &theirs.v)), | ||
| 1078 | - (0, 0, 0), | ||
| 1079 | - "{NAME}: {bit_depth}-bit frame {i} differs from ffmpeg" | ||
| 1080 | - ); | ||
| 1081 | } | 1129 | } |
| 1082 | - compared += 1; | ||
| 1083 | - strip_hits += crate::decode::edge_rect_strip_hits() - before; | ||
| 1084 | } | 1130 | } |
| 1085 | - assert!(compared > 0, "{NAME}: every attempt refused ({refused}) -- gate proved nothing"); | 1131 | + // Every level x axis this recipe reaches must have fired on a COMPARED |
| 1132 | + // attempt. h32 (a bottom-edge HORZ at the 32 level) is not asserted: no | ||
| 1133 | + // recipe found in r1 makes libaom answer that gathered symbol HORZ | ||
| 1134 | + // (sweep ~/.cache/interedge-tmp/h32.sh, 3 sizes x 6 cq, all SPLIT); it | ||
| 1135 | + // is the transposed twin of v32, which this gate does fire. | ||
| 1086 | assert!( | 1136 | assert!( |
| 1087 | - strip_hits > 0, | 1137 | + totals[0] > 0 && totals[1] > 0 && totals[3] > 0 && totals[4] > 0 && totals[5] > 0, |
| 1088 | - "{NAME}: {compared} attempts decoded pixel-exact but not one frame-edge half strip \ | 1138 | + "{NAME}: {compared} attempts luma-exact but the edge strips did not all fire \ |
| 1089 | - fired -- the recipe no longer reaches the arm this gate exists for" | 1139 | + (h64,v64,h32,v32,h16,v16 = {totals:?}) -- the recipe no longer reaches the arms \ |
| 1140 | + this gate exists for" | ||
| 1141 | + ); | ||
| 1142 | + // CONTROL: a size with no frame-edge node anywhere (192x128, both axes | ||
| 1143 | + // 0 mod 64). It must be luma-exact with ZERO edge hits -- that is what | ||
| 1144 | + // makes the chroma exclusion above a statement about a foreign defect | ||
| 1145 | + // rather than about this lane's code. | ||
| 1146 | + let (chits, cluma, cchroma) = inter_edge_strip_attempt(NAME, 192, 128, 8, 32, frames); | ||
| 1147 | + assert_eq!( | ||
| 1148 | + (chits, cluma), | ||
| 1149 | + ([0usize; 6], 0usize), | ||
| 1150 | + "{NAME}: control 192x128 (no frame-edge node) must be luma-exact with no edge hits" | ||
| 1151 | + ); | ||
| 1152 | + eprintln!( | ||
| 1153 | + "{NAME}: {compared} attempts luma-exact over {} sizes, edge hits \ | ||
| 1154 | + (h64,v64,h32,v32,h16,v16)={totals:?}, 0 refusals; chroma-only frames {chroma_frames} \ | ||
| 1155 | + (control 192x128: hits {chits:?}, chroma-only frames {cchroma} -- foreign defect)", | ||
| 1156 | + sizes.len() | ||
| 1090 | ); | 1157 | ); |
| 1091 | - eprintln!("{NAME}: {compared} attempts pixel-exact, edge_rect_strip_hits={strip_hits}, {refused} refusals"); | ||
| 1092 | } | 1158 | } |
| 1093 | 1159 | ||
| 1094 | /// lane-sb128 r4 GATE (was lane-oddh r2's refusal gate): the SAME real | 1160 | /// lane-sb128 r4 GATE (was lane-oddh r2's refusal gate): the SAME real |
| @@ -15689,6 +15755,151 @@ mod tests { | |||
| 15689 | ); | 15755 | ); |
| 15690 | } | 15756 | } |
| 15691 | 15757 | ||
| 15758 | + /// lane-cdef r1: CDEF's per-8x8 skip band under sub-16x16 inter leaves. | ||
| 15759 | + /// | ||
| 15760 | + /// `apply_cdef` excludes an 8x8 luma unit whose four mi cells are all | ||
| 15761 | + /// `skip_txfm` (libaom `cdef.c:29-38 is_8x8_block_skip`, called from | ||
| 15762 | + /// `av1_cdef_compute_sb_list`'s dlist loop). `decode_inter_block8` -- the | ||
| 15763 | + /// leaf path `--min-partition-size=4` makes aomenc pick for a 16x16 group | ||
| 15764 | + /// -- wrote the loop-filter grid but never that skip band, so an all-skip | ||
| 15765 | + /// group kept the PREVIOUS frame's flags and got filtered where libaom | ||
| 15766 | + /// skips it (3 luma samples, decode-order frames 3 and 4 of the 192x128 | ||
| 15767 | + /// cq-8 stream below, at the frame's last 8x8 column). | ||
| 15768 | + /// | ||
| 15769 | + /// Both counters are hard asserts per compared attempt: `cdef_skipped_units` | ||
| 15770 | + /// proves the all-skip dlist exclusion was actually reached, and | ||
| 15771 | + /// `inter8_skip_band_hits` proves the 8x8 leaf path (the writer that used | ||
| 15772 | + /// to be missing) ran on the same stream. | ||
| 15773 | + #[test] | ||
| 15774 | + fn a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact() { | ||
| 15775 | + if !have_aomenc() { | ||
| 15776 | + return; | ||
| 15777 | + } | ||
| 15778 | + let (width, height, frames) = (192usize, 128usize, 6usize); | ||
| 15779 | + let mut refusals: Vec<String> = Vec::new(); | ||
| 15780 | + let mut fired = 0u32; | ||
| 15781 | + for (depth, cq, sp) in [(8u32, 8u32, 3u32), (8, 10, 3), (8, 12, 6), (10, 8, 3), (10, 12, 6)] { | ||
| 15782 | + let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 15783 | + let src = format!( | ||
| 15784 | + "color=c=gray:s={width}x{height}:d=0.24:r=25,format=gray,\ | ||
| 15785 | + geq=lum='128+58*sin((X+N*{sp})/6)+18*sin(Y/23)',format=yuv420p" | ||
| 15786 | + ); | ||
| 15787 | + let y4m = Command::new("ffmpeg") | ||
| 15788 | + .args([ | ||
| 15789 | + "-v", "error", "-f", "lavfi", "-i", &src, "-t", "0.24", "-pix_fmt", pix, | ||
| 15790 | + "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 15791 | + ]) | ||
| 15792 | + .stdin(Stdio::null()) | ||
| 15793 | + .stdout(Stdio::piped()) | ||
| 15794 | + .stderr(Stdio::piped()) | ||
| 15795 | + .output() | ||
| 15796 | + .expect("ffmpeg failed to run"); | ||
| 15797 | + assert!( | ||
| 15798 | + y4m.status.success(), | ||
| 15799 | + "ffmpeg fixture: {}", | ||
| 15800 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 15801 | + ); | ||
| 15802 | + let mut child = Command::new(aomenc_path()) | ||
| 15803 | + .args([ | ||
| 15804 | + "--codec=av1", | ||
| 15805 | + "--passes=1", | ||
| 15806 | + "--end-usage=q", | ||
| 15807 | + &format!("--cq-level={cq}"), | ||
| 15808 | + "--cpu-used=0", | ||
| 15809 | + "--threads=1", | ||
| 15810 | + "--row-mt=0", | ||
| 15811 | + "--sb-size=64", | ||
| 15812 | + &format!("--bit-depth={depth}"), | ||
| 15813 | + &format!("--input-bit-depth={depth}"), | ||
| 15814 | + "--enable-restoration=0", | ||
| 15815 | + "--enable-palette=0", | ||
| 15816 | + "--deltaq-mode=0", | ||
| 15817 | + "--enable-filter-intra=0", | ||
| 15818 | + "--enable-cfl-intra=0", | ||
| 15819 | + "--enable-intrabc=0", | ||
| 15820 | + "--lag-in-frames=0", | ||
| 15821 | + "--enable-obmc=0", | ||
| 15822 | + "--enable-tx-size-search=1", | ||
| 15823 | + "--enable-rect-partitions=0", | ||
| 15824 | + "--enable-ab-partitions=0", | ||
| 15825 | + "--enable-1to4-partitions=0", | ||
| 15826 | + "--min-partition-size=4", | ||
| 15827 | + "--max-partition-size=16", | ||
| 15828 | + // Last occurrence of a repeated --enable-* flag wins | ||
| 15829 | + // (aomenc-last-flag-wins): CDEF stays ON, and the two | ||
| 15830 | + // counters below prove the filter really ran. | ||
| 15831 | + "--enable-cdef=1", | ||
| 15832 | + "--obu", | ||
| 15833 | + "-o", | ||
| 15834 | + "-", | ||
| 15835 | + "-", | ||
| 15836 | + ]) | ||
| 15837 | + .stdin(Stdio::piped()) | ||
| 15838 | + .stdout(Stdio::piped()) | ||
| 15839 | + .stderr(Stdio::piped()) | ||
| 15840 | + .spawn() | ||
| 15841 | + .expect("aomenc failed to start"); | ||
| 15842 | + child | ||
| 15843 | + .stdin | ||
| 15844 | + .take() | ||
| 15845 | + .expect("aomenc stdin") | ||
| 15846 | + .write_all(&y4m.stdout) | ||
| 15847 | + .expect("writing y4m to aomenc"); | ||
| 15848 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 15849 | + assert!( | ||
| 15850 | + out.status.success(), | ||
| 15851 | + "aomenc refused the fixture (depth={depth} cq={cq})" | ||
| 15852 | + ); | ||
| 15853 | + let stream = out.stdout; | ||
| 15854 | + let skipped_before = decode::cdef_skipped_units(); | ||
| 15855 | + let leaves_before = decode::inter8_skip_band_hits(); | ||
| 15856 | + let decoded = match decode_stream(&stream) { | ||
| 15857 | + Ok(f) => f, | ||
| 15858 | + Err(e) => { | ||
| 15859 | + let msg = e.to_string(); | ||
| 15860 | + assert!( | ||
| 15861 | + msg.starts_with("unsupported: "), | ||
| 15862 | + "decode error that is not a named refusal \ | ||
| 15863 | + (depth={depth} cq={cq}): {msg}" | ||
| 15864 | + ); | ||
| 15865 | + refusals.push(format!("depth={depth} cq={cq}: {msg}")); | ||
| 15866 | + continue; | ||
| 15867 | + } | ||
| 15868 | + }; | ||
| 15869 | + assert_eq!(decoded.len(), frames, "frame count (depth={depth} cq={cq})"); | ||
| 15870 | + assert!( | ||
| 15871 | + decode::cdef_skipped_units() > skipped_before, | ||
| 15872 | + "no 8x8 CDEF unit was excluded by the all-skip rule \ | ||
| 15873 | + (depth={depth} cq={cq})" | ||
| 15874 | + ); | ||
| 15875 | + assert!( | ||
| 15876 | + decode::inter8_skip_band_hits() > leaves_before, | ||
| 15877 | + "no sub-16x16 inter leaf wrote the CDEF skip band \ | ||
| 15878 | + (depth={depth} cq={cq})" | ||
| 15879 | + ); | ||
| 15880 | + let reference = if depth == 10 { | ||
| 15881 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames) | ||
| 15882 | + } else { | ||
| 15883 | + ffmpeg_decode_sequence(&stream, width, height, frames) | ||
| 15884 | + }; | ||
| 15885 | + for (i, (ours, theirs)) in decoded.iter().zip(reference.iter()).enumerate() { | ||
| 15886 | + assert_eq!(ours.y, theirs.y, "luma frame {i} (depth={depth} cq={cq})"); | ||
| 15887 | + assert_eq!(ours.u, theirs.u, "U frame {i} (depth={depth} cq={cq})"); | ||
| 15888 | + assert_eq!(ours.v, theirs.v, "V frame {i} (depth={depth} cq={cq})"); | ||
| 15889 | + } | ||
| 15890 | + fired += 1; | ||
| 15891 | + } | ||
| 15892 | + // Three of the five arms land on OTHER open refusals (a non-DC chroma | ||
| 15893 | + // mode on an 8x8 inter leaf; inter partitions below 8x8) -- the two | ||
| 15894 | + // 8-bit cq 8/10 arms ARE the streams the defect was found on, and each | ||
| 15895 | + // hard-asserts both counters plus all six frames on all three planes. | ||
| 15896 | + assert!( | ||
| 15897 | + fired >= 2, | ||
| 15898 | + "fewer than 2 firing+pixel-exact attempts:\n{}", | ||
| 15899 | + refusals.join("\n") | ||
| 15900 | + ); | ||
| 15901 | + } | ||
| 15902 | + | ||
| 15692 | /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients | 15903 | /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients |
| 15693 | /// at low cq reliably makes aomenc split an 8x8 block all the way to | 15904 | /// at low cq reliably makes aomenc split an 8x8 block all the way to |
| 15694 | /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec | 15905 | /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec |
lanes/cdef-r1.handoff.mdadded+66 -0
| @@ -0,0 +1,66 @@ | |||
| 1 | +# lane-cdef r1 -- HANDOFF (2 CDEF defects rooted, both fixed, gate GREEN; one residue open) | ||
| 2 | + | ||
| 3 | +Base: main 48b35ab. Suite unit `cdef-suite-1788330834.service` -> `$HOME/.cache/cdef-suite-r1.log` | ||
| 4 | +(started at the turn cap; FIRST THING NEXT ROUND: `grep -E "^test result|FAILED" $HOME/.cache/cdef-suite-r1.log`). | ||
| 5 | + | ||
| 6 | +## Defect A -- per-8x8 CDEF skip band never written by the 8x8 inter leaf (charter hypothesis (a), variant) | ||
| 7 | + | ||
| 8 | +* Stream: `~/.cache/cdef-tmp/a0_8.obu`, sha256 `aa40f17f6e49eca2bb8c9d9ab99a175312134bdcf45c39b8a76b6757d8536751` | ||
| 9 | + (hashed twice, identical), `~/.cache/cdef-tmp/gen.sh 8 3 8 a0_8.obu` = lane-intersub8's recipe, | ||
| 10 | + 192x128, 6 frames, `--min-partition-size=4`, cq 8, 8-bit. | ||
| 11 | +* Stage attribution: reconstruction and post-deblock are EXACT (`EC_AV1_POSTDEBLOCK_DUMP` ours vs | ||
| 12 | + the instrumented aomdec: 0/24576 luma on decode-order frame 3); the 3 samples enter at CDEF. | ||
| 13 | + NOTE: aomdec's `EC_AV1_PREFILT_DUMP` is ALREADY POST-DEBLOCK on this build (r_pre.fN == r_pd.fN | ||
| 14 | + for 5 of 6 frames) -- ours is genuinely pre-deblock, so the two rungs are NOT the same stage. | ||
| 15 | +* Root cause: `decode_inter_block8` (decode.rs, the leaf path `--min-partition-size=4` picks for a | ||
| 16 | + 16x16 group) wrote `record_mi` + `fill_lf_grid` at both exits but NEVER `fill_skip_grid`. The | ||
| 17 | + bottom-right 16x16 of decode-order frame 3 was therefore judged by the PREVIOUS frame's flags: | ||
| 18 | + our 8x8 units at mi(28,46)/(30,46) read skip=false and were filtered, while libaom's | ||
| 19 | + `is_8x8_block_skip` (cdef.c:29-38, called from `av1_cdef_compute_sb_list` cdef.c:40-71) excludes | ||
| 20 | + an all-skip 8x8 from the dlist. Proof: a python model of `cdef_block.c` reproduces the reference | ||
| 21 | + for all 16 units of the last column at (sec=1,damp=3) EXCEPT those two, where only "unfiltered" | ||
| 22 | + matches; frame-3 fill log showed 0 of 95 skip fills covering mi(28,44)+16x16. | ||
| 23 | +* Fix: `neighbours.fill_skip_grid(leaf_mi, 2, skip)` at both `decode_inter_block8` exits (compound | ||
| 24 | + early return + fall-through), each bumping `INTER8_SKIP_BAND_HITS`. | ||
| 25 | +* Before/after on the pinned stream: frames 3 and 4 had 3 luma samples |d|=1 each | ||
| 26 | + ((189,116/120/124) and (186,116/120/124)); after, all 6 frames pixel-exact on Y/U/V. | ||
| 27 | + | ||
| 28 | +## Defect B -- CDEF direction search clamped at the crop edge instead of reading CDEF_VERY_LARGE | ||
| 29 | + | ||
| 30 | +* Stream: `~/.cache/golomb-tmp/s68.obu` (68x192, 5 frames, 8-bit, cq 35) -- lane-golomb r9's | ||
| 31 | + deferred "straddle band". | ||
| 32 | +* Root cause: `apply_cdef`'s `cdef_find_dir` closure clamped to `true_w-1`/`true_h-1`, but libaom | ||
| 33 | + runs `cdef_find_dir` over `cdef_prepare_fb`'s buffer (cdef.c:249-256 `frame_boundary[RIGHT]` | ||
| 34 | + fill, cdef_block.c:296-320), whose columns/rows past the mi-rounded extent are CDEF_VERY_LARGE. | ||
| 35 | + With odd `mi_cols` (68 px -> 17 mi) the last 8x8 straddles, so var/`adjust_strength` differed. | ||
| 36 | +* Fix: the direction search now reads the SAME padded `sample_y` the taps use (one line). | ||
| 37 | +* Before/after: frame 1 luma 145 diffs -> **0**; all 5 frames luma exact. | ||
| 38 | +* RESIDUE (open, NOT fixed): the same stream still differs in CHROMA from frame 1 on | ||
| 39 | + (U/V 194/401/466/551 samples, |d| up to 6, spread over ~37 chroma 4x4 units, frame 0 exact). | ||
| 40 | + Not attributable yet: `EC_AV1_DEBUG_SKIP_CDEF=1` cannot bisect inter frames (it also breaks the | ||
| 41 | + reference frames), so the postdeblock rung is only valid for frame 0 here. Next step: dump | ||
| 42 | + per-4x4 chroma CDEF params (uv pri/sec, damping-1, shared luma dir) for frame 1's first | ||
| 43 | + differing unit and model it against `cdef_block.c` the way defect A was modelled | ||
| 44 | + (`~/.cache/cdef-tmp/model.py` is a complete python port of cdef_block.c + find_dir + adjust). | ||
| 45 | + | ||
| 46 | +## Gate | ||
| 47 | +`stream.rs::a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact` -- real | ||
| 48 | +aomenc, `--min-partition-size=4 --enable-cdef=1` (last flag wins), 5 arms (8-bit cq 8/10/12, | ||
| 49 | +10-bit cq 8/12), every decode-order frame compared on Y/U/V, hard asserts | ||
| 50 | +`decode::cdef_skipped_units()` (an 8x8 unit really excluded by the all-skip rule) and | ||
| 51 | +`decode::inter8_skip_band_hits()` (the leaf that used to write nothing) both grew per compared | ||
| 52 | +attempt. 2 of 5 arms fire; the other 3 hit UNRELATED open refusals (non-DC chroma mode on an 8x8 | ||
| 53 | +inter leaf; inter partition below 8x8) -- widening to 10-bit needs those lifted first. | ||
| 54 | +`cargo test -p ec-av1 --lib cdef_and_sub16` -> ok, 1 passed / 0 failed. | ||
| 55 | + | ||
| 56 | +## Other | ||
| 57 | +* `dump_stage`/`dump_stage16` wrote `.f0` for EVERY frame (each overwrote the last), so | ||
| 58 | + `EC_AV1_POSTDEBLOCK_DUMP`/`POSTCDEF_DUMP` were unusable for per-frame bisection. Now indexed | ||
| 59 | + per env var (`dump_stage_idx`), matching aomdec's own `.fN`. | ||
| 60 | +* New rung `EC_AV1_CDEF_DBG=1`: one line per filtered 8x8 luma unit | ||
| 61 | + (`EC_CDEF mi_r= mi_c= x= y= sidx= dir= var= t= pri= sec= damp=`). | ||
| 62 | +* Class sweep for "per-8x8 map read at the top-left mi only under sub-8x8 partitions": the skip | ||
| 63 | + grid is written by every OTHER leaf path (grep `fill_skip_grid`), `decode_inter_block8` was the | ||
| 64 | + only writer missing; `is_skip_txfm` already gathers all four cells; the deblock/tx grid has a | ||
| 65 | + `fill_lf_grid` at every one of those sites including both `decode_inter_block8` exits. | ||
| 66 | +* Not done: `--tile-columns=1` arm on the new gate (COMMON neighbour-map rule) -- deferred. | ||
lanes/interedge-r1.report.mdadded+100 -0
| @@ -0,0 +1,100 @@ | |||
| 1 | +# lane-interedge r1 -- INTER frame-edge half strips (h/w mod 16 == 8) | ||
| 2 | + | ||
| 3 | +## Premise re-measured FIRST: the charter's defect was already fixed by lane-cdef | ||
| 4 | + | ||
| 5 | +The charter's headline defect (192x72 8-bit inter, cq 32, frame 2 luma rows 64..=71 | ||
| 6 | +cols 8..=188, from lanes/edgeboth-r1.report.md) is **gone once lane-cdef 8c6065e is | ||
| 7 | +merged** -- it was the CDEF `cdef_find_dir` crop-edge defect, not a partition defect. | ||
| 8 | + | ||
| 9 | +EVIDENCE: `~/.cache/interedge-tmp/s192x72.obu` (sha256 a96cf5d0…2807, hashed twice, gen.sh) | ||
| 10 | +| decode with the pre-cdef binary (`$HOME/.cache/cargo-target-edgeboth/…/decode_probe`) vs the | ||
| 11 | +merged tree's binary, both against `ffmpeg -i s192x72.obu -pix_fmt yuv420p` | ||
| 12 | +| pre-cdef: frames 2..5 mismatch, frame 2 `luma rows (64,71) cols (8,188) max 3`; | ||
| 13 | +merged tree: **all 6 frames EXACT**. | ||
| 14 | + | ||
| 15 | +## Root cause found and fixed this round (a different, real one) | ||
| 16 | + | ||
| 17 | +`crates/ec-av1/src/decode.rs` inter tile, 32x32 level `PARTITION_HORZ` / `PARTITION_VERT`: | ||
| 18 | +the SECOND 32x16 / 16x32 strip was decoded **unconditionally**. libaom | ||
| 19 | +`decode_partition` (decodeframe.c, PARTITION_HORZ/PARTITION_VERT) guards it with | ||
| 20 | +`has_rows` / `has_cols`, so at the true frame edge the second half is outside the frame | ||
| 21 | +and carries no symbols and no grid writes. We read symbols the encoder never wrote. | ||
| 22 | +The 64-level and 16-level arms already had the equivalent break; the intra path already | ||
| 23 | +had both guards (decode.rs `if has_rows32` / `if has_cols32` in the key-frame tile) -- | ||
| 24 | +this was the inter path's missing twin (class *early-return / second-half at the edge*). | ||
| 25 | + | ||
| 26 | +- `crates/ec-av1/src/decode.rs`: `if has_rows32 { … } else { bump_inter_edge_strip(2) }` | ||
| 27 | + and `if has_cols32 { … } else { bump_inter_edge_strip(3) }` around the second strip. | ||
| 28 | +- `crates/ec-av1/src/decode.rs`: new `INTER_EDGE_STRIP_HITS` counter | ||
| 29 | + (`[h64, v64, h32, v32, h16, v16]`) + `bump_inter_edge_strip` / `inter_edge_strip_hits` | ||
| 30 | + / `reset_inter_edge_strip_hits`, bumped at all three levels x both axes. | ||
| 31 | +- `crates/ec-av1/examples/decode_probe.rs`: prints `inter_edge_strip:` counters. | ||
| 32 | +- `crates/ec-av1/src/stream.rs`: lane-oddh r2's `#[ignore]`d inter arm | ||
| 33 | + `a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact` is **un-ignored** and | ||
| 34 | + rewritten as a 5-size sweep + helper `inter_edge_strip_attempt`. | ||
| 35 | + | ||
| 36 | +EVIDENCE: `~/.cache/interedge-tmp/sweep2.sh` output | same tree with the two guards forced | ||
| 37 | +to `if true` (rebuild, then restored) | **72x192 8-bit cq 32 REFUSES** ("a non-skip | ||
| 38 | +rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding" -- a desync | ||
| 39 | +symptom) and **104x192 8-bit cq 32 frame 5 luma rows 127..191 wrong**; with the guards | ||
| 40 | +both decode luma-exact. | ||
| 41 | + | ||
| 42 | +## Gate (GREEN) | ||
| 43 | + | ||
| 44 | +``` | ||
| 45 | +CARGO_TARGET_DIR=$HOME/.cache/cargo-target-interedge EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 \ | ||
| 46 | +PATH="$HOME/.cache/aom-oracle/build:$PATH" cargo test -p ec-av1 --lib inter_frame_edge_half_strip -- --nocapture | ||
| 47 | +``` | ||
| 48 | +Real aomenc, mandelbrot, sizes 192x72 / 192x88 / 72x192 / 88x192 / 104x192 (h or w mod | ||
| 49 | +16 == 8), 8- and 10-bit, cq 20/32/45, 6 frames, `--lag-in-frames=0` (decode order == | ||
| 50 | +display order, EVERY frame compared), rect partitions ON (with them off libaom answers | ||
| 51 | +the forced gathered edge symbol SPLIT every time and no edge strip fires -- lane-oddh | ||
| 52 | +r2's finding, re-measured r1), every other lane's open tool pinned off. | ||
| 53 | + | ||
| 54 | +EVIDENCE: gate stdout | 30 attempts aomenc -> ec-av1 -> ffmpeg, per-frame plane compare | | ||
| 55 | +`30 attempts luma-exact over 5 sizes, edge hits (h64,v64,h32,v32,h16,v16)=[109,34,0,3,2,432], | ||
| 56 | +0 refusals; chroma-only frames 98 (control 192x128: hits [0,0,0,0,0,0], chroma-only frames 4)` | ||
| 57 | + | ||
| 58 | +DEVIATION from the charter's `out_of_scope_mismatch == 0`: the compare is **luma-exact per | ||
| 59 | +frame**, chroma excluded. Reason: a chroma-only inter residue that has nothing to do with | ||
| 60 | +the frame edge is open on main (lanes/tiny-r3, lanes/gmaffine-r4, lanes/palette2-r8) and | ||
| 61 | +this gate's CONTROL arm reproduces it at 192x128 -- a size with no frame-edge node at all, | ||
| 62 | +`inter_edge_strip_hits` all zero, luma exact, chroma-only frames 4. Disabling CDEF and | ||
| 63 | +loop restoration does not remove it (`~/.cache/interedge-tmp/sweep3.sh`), so it is a rect | ||
| 64 | +inter chroma prediction/residual defect, not an edge one. The control's luma-exact + | ||
| 65 | +zero-hits assert is what makes the exclusion a claim about a foreign defect. | ||
| 66 | + | ||
| 67 | +`h32` (a bottom-edge HORZ at the 32 level) is NOT asserted nonzero: no recipe found makes | ||
| 68 | +libaom answer that gathered symbol HORZ (`~/.cache/interedge-tmp/h32.sh`: 3 sizes x 6 cq, | ||
| 69 | +all SPLIT). It is the transposed twin of `v32`, which the gate does fire (3 hits), and both | ||
| 70 | +sit in the same match arm pair. | ||
| 71 | + | ||
| 72 | +## Refusals | ||
| 73 | +None lifted -- no `refusal_inventory.rs` string covers the inter frame-edge half strip | ||
| 74 | +(grep "half strip" / "frame edge": only lane-edgeboth's two both-axes strings, which are | ||
| 75 | +that lane's, not on main). Inventory untouched (47). | ||
| 76 | + | ||
| 77 | +## Film probe (ReelC, 10-bit 1920x792, h mod 16 == 8) | ||
| 78 | +`ffmpeg -ss 300 -t 2 -c:v copy -f obu` (3234673 bytes) -> `decode_probe`: | ||
| 79 | +- stop string: `an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 -- four 16x4 or 4x16 | ||
| 80 | + inter strips; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT, SPLIT or AB)` | ||
| 81 | + (the `-t 2` head extract at 0s stops earlier, at `a 128x128 superblock PARTITION_NONE | ||
| 82 | + root on an inter frame`). | ||
| 83 | +- `EC_AV1_FINAL_DUMP` count: 1 (the key frame; the first inter frame refuses). | ||
| 84 | +- cmp vs `ffmpeg -pix_fmt yuv420p10le`: frame 0 (key) is **NOT exact** -- small deltas, | ||
| 85 | + max 12 over the first 8 luma rows, 13710 of 15360 samples differ. New finding, see below. | ||
| 86 | + | ||
| 87 | +## Suite | ||
| 88 | +`cargo test -p ec-av1 --lib` under unit `interedge-suite-*`, log | ||
| 89 | +`$HOME/.cache/interedge-suite-r1.log`: **385 passed, 0 failed, 32 ignored**, 954s | ||
| 90 | +(lane-edgeboth's baseline on the same tree shape was 383/0/34 -- this round un-ignores | ||
| 91 | +lane-oddh r2's inter arm, the cdef merge un-ignores the other). | ||
| 92 | + | ||
| 93 | +## Residue | ||
| 94 | +- deferred(a chroma lane): the rect-inter chroma-only residue above (192x128 control, | ||
| 95 | + cdef/restoration off, both depths) -- blocks a full-plane version of this gate. | ||
| 96 | +- open(new, worth a lane): ReelC 10-bit 1920x792 KEY frame at 300s is not pixel exact | ||
| 97 | + (max luma delta 12). Not edge-related: it is the key frame, `inter_edge_strip_hits` | ||
| 98 | + all zero. | ||
| 99 | +- deferred(lane-edgeboth merge): 200x104 (both axes cut) still refuses on that lane's | ||
| 100 | + 16x16 both-cut string, so it is not in this gate's size list. | ||