Merge branch 'lane-cdef' (8c6065e): the 8x8 inter leaf writes the CDEF skip band
Browse files at this commit7 changed files +772 -25
- crates/ec-av1/fixtures/reelb_ss300_key_frame.obu +0 -0
- crates/ec-av1/src/decode.rs +124 -18
- crates/ec-av1/src/stream.rs +221 -7
- lanes/cdef-r1.handoff.md +66 -0
- lanes/kf1200-r1.report.md +106 -0
- lanes/kf1200-r2.handoff.md +72 -0
- lanes/kf1200-r2.report.md +183 -0
crates/ec-av1/fixtures/reelb_ss300_key_frame.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+124 -18
| @@ -2214,6 +2214,26 @@ thread_local! { | |||
| 2214 | static RECT4_16_CHROMA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2214 | static RECT4_16_CHROMA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2215 | static RECT4_16_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2215 | static RECT4_16_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2216 | static RECT4_16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 2216 | static RECT4_16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2217 | + /// lane-kf1200: pairs whose chroma edge-filter type read from the PAIR's | ||
| 2218 | + /// base mi differs from what the strip's own (odd) mi would have said -- | ||
| 2219 | + /// the shape that made 4 chroma samples of the ReelB `-ss 1200` | ||
| 2220 | + /// key frame miss by 1. Zero here means a gate never exercised the fix. | ||
| 2221 | + static RECT4_16_UV_PAIR_FILT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2222 | + /// lane-kf1200 r2: sub-8x8 chroma blocks that are `skip_txfm` AND | ||
| 2223 | + /// `UV_CFL_PRED` -- the arm that used to drop the CfL alpha entirely. | ||
| 2224 | + static SKIP_CFL_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2225 | +} | ||
| 2226 | + | ||
| 2227 | +/// How many skipped sub-8x8 chroma blocks carried a CfL alpha (the shape | ||
| 2228 | +/// that reconstructed as flat DC before lane-kf1200 r2). | ||
| 2229 | +pub fn skip_cfl_hits() -> usize { | ||
| 2230 | + SKIP_CFL_HITS.with(|c| c.get()) | ||
| 2231 | +} | ||
| 2232 | + | ||
| 2233 | +/// How many 16x4/4x16 chroma pairs took a different `intra_edge_filter_type` | ||
| 2234 | +/// from the pair's base mi than the strip's own mi would have given. | ||
| 2235 | +pub fn rect4_16_uv_pair_filt_hits() -> usize { | ||
| 2236 | + RECT4_16_UV_PAIR_FILT_HITS.with(|c| c.get()) | ||
| 2217 | } | 2237 | } |
| 2218 | 2238 | ||
| 2219 | // lane-reelckf r1: the two chroma defects ReelC's key frames exposed -- | 2239 | // lane-reelckf r1: the two chroma defects ReelC's key frames exposed -- |
| @@ -2555,6 +2575,28 @@ pub fn sub8_inter_rect_hits() -> (usize, usize) { | |||
| 2555 | }) | 2575 | }) |
| 2556 | } | 2576 | } |
| 2557 | 2577 | ||
| 2578 | +// lane-cdef r1: (a) how many 8x8 CDEF units `apply_cdef` EXCLUDED because all | ||
| 2579 | +// four of their mi cells are `skip_txfm` (libaom `cdef.c:29-38` | ||
| 2580 | +// `is_8x8_block_skip` / `av1_cdef_compute_sb_list`'s dlist test), and (b) how | ||
| 2581 | +// many 8x8 inter leaves (`decode_inter_block8`) wrote that skip band at all. | ||
| 2582 | +// (b) was 0 for every stream before this round -- the leaf path never touched | ||
| 2583 | +// the band, so an all-skip 8x8 group kept the PREVIOUS frame's flags and got | ||
| 2584 | +// filtered where libaom skips it. A gate asserts both are non-zero. | ||
| 2585 | +thread_local! { | ||
| 2586 | + static CDEF_SKIPPED_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2587 | + static INTER8_SKIP_BAND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2588 | +} | ||
| 2589 | + | ||
| 2590 | +/// Current value of `CDEF_SKIPPED_UNITS`. | ||
| 2591 | +pub(crate) fn cdef_skipped_units() -> usize { | ||
| 2592 | + CDEF_SKIPPED_UNITS.with(|c| c.get()) | ||
| 2593 | +} | ||
| 2594 | + | ||
| 2595 | +/// Current value of `INTER8_SKIP_BAND_HITS`. | ||
| 2596 | +pub(crate) fn inter8_skip_band_hits() -> usize { | ||
| 2597 | + INTER8_SKIP_BAND_HITS.with(|c| c.get()) | ||
| 2598 | +} | ||
| 2599 | + | ||
| 2558 | /// Current value of [`SUB8_SPLIT_HITS`]. | 2600 | /// Current value of [`SUB8_SPLIT_HITS`]. |
| 2559 | pub(crate) fn sub8_split_hits() -> usize { | 2601 | pub(crate) fn sub8_split_hits() -> usize { |
| 2560 | SUB8_SPLIT_HITS.with(|c| c.get()) | 2602 | SUB8_SPLIT_HITS.with(|c| c.get()) |
| @@ -7768,14 +7810,22 @@ fn decode_rect4_16( | |||
| 7768 | RECT4_16_CHROMA_DIR_HITS.with(|h| h.set(h.get() + 1)); | 7810 | RECT4_16_CHROMA_DIR_HITS.with(|h| h.set(h.get() + 1)); |
| 7769 | } | 7811 | } |
| 7770 | let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height); | 7812 | let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height); |
| 7771 | - // libaom `get_intra_edge_filter_type` reads `chroma_above_mbmi` / | 7813 | + // lane-kf1200 r1: the chroma edge-filter type reads the neighbours |
| 7772 | - // `chroma_left_mbmi` -- the neighbours of the CHROMA REFERENCE | 7814 | + // of the CHROMA block, which for a 16x4/4x16 pair is `pair_mi`'s |
| 7773 | - // position, not of the closing strip. At `lmi` the above cell is | 7815 | + // 16x8/8x16 region -- libaom builds `chroma_above_mbmi`/ |
| 7774 | - // the pair's own first strip, so the mi-exact map missed and the | 7816 | + // `chroma_left_mbmi` from `mi[-((mi_row & ss_y) * stride + (mi_col |
| 7775 | - // coarse fallback answered; the filter type then flipped the | 7817 | + // & ss_x))]` (`set_mi_offsets`, av1/common/blockd.h ~1050), i.e. |
| 7776 | - // `use_intra_edge_upsample` decision (blk_wh 12 <= 16 for type 0, | 7818 | + // the pair's top-left luma mi, never this leaf's odd row/column. |
| 7777 | - // no upsample for type 1) on directional chroma. | 7819 | + // Reading `lmi` here named the leaf directly above (a non-chroma |
| 7778 | - let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c); | 7820 | + // -reference 4-row block, `uv_mode == UV_DC_PRED`) and so lost a |
| 7821 | + // SMOOTH neighbour: filt_type 0 instead of 1 turned | ||
| 7822 | + // `av1_use_intra_edge_upsample` on (blk_wh 12 <= 16) for a | ||
| 7823 | + // directional chroma strip, moving 4 samples by 1. | ||
| 7824 | + let smooth_neighbor_uv = | ||
| 7825 | + neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c); | ||
| 7826 | + if smooth_neighbor_uv != neighbours.smooth_uv_neighbour(lmi.0, lmi.1, r, c) { | ||
| 7827 | + RECT4_16_UV_PAIR_FILT_HITS.with(|h| h.set(h.get() + 1)); | ||
| 7828 | + } | ||
| 7779 | let (u_levels, v_levels) = if skip { | 7829 | let (u_levels, v_levels) = if skip { |
| 7780 | let zeros = vec![0i32; cw * ch]; | 7830 | let zeros = vec![0i32; cw * ch]; |
| 7781 | // libaom `predict_and_reconstruct_intra_block` (decodeframe.c | 7831 | // libaom `predict_and_reconstruct_intra_block` (decodeframe.c |
| @@ -8831,7 +8881,7 @@ fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 { | |||
| 8831 | fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) { | 8881 | fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) { |
| 8832 | use std::io::Write; | 8882 | use std::io::Write; |
| 8833 | if let Ok(path) = std::env::var(var) | 8883 | if let Ok(path) = std::env::var(var) |
| 8834 | - && let Ok(mut f) = std::fs::File::create(format!("{path}.f0")) | 8884 | + && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var))) |
| 8835 | { | 8885 | { |
| 8836 | 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))] { | 8886 | 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))] { |
| 8837 | for row in 0..h { | 8887 | for row in 0..h { |
| @@ -8845,10 +8895,25 @@ fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, | |||
| 8845 | } | 8895 | } |
| 8846 | } | 8896 | } |
| 8847 | 8897 | ||
| 8898 | +/// Decode-order index of the next [`dump_stage`]/[`dump_stage16`] file for a | ||
| 8899 | +/// given env var -- lane-cdef r1: both used to write `.f0` unconditionally, so | ||
| 8900 | +/// every frame overwrote the previous one and only the LAST frame survived, | ||
| 8901 | +/// which silently defeats any per-frame filter-stage bisection. | ||
| 8902 | +fn dump_stage_idx(var: &str) -> usize { | ||
| 8903 | + use std::collections::HashMap; | ||
| 8904 | + use std::sync::{Mutex, OnceLock}; | ||
| 8905 | + static IDX: OnceLock<Mutex<HashMap<String, usize>>> = OnceLock::new(); | ||
| 8906 | + let mut m = IDX.get_or_init(|| Mutex::new(HashMap::new())).lock().unwrap(); | ||
| 8907 | + let e = m.entry(var.to_string()).or_insert(0); | ||
| 8908 | + let i = *e; | ||
| 8909 | + *e += 1; | ||
| 8910 | + i | ||
| 8911 | +} | ||
| 8912 | + | ||
| 8848 | fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { | 8913 | fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { |
| 8849 | use std::io::Write; | 8914 | use std::io::Write; |
| 8850 | if let Ok(path) = std::env::var(var) | 8915 | if let Ok(path) = std::env::var(var) |
| 8851 | - && let Ok(mut f) = std::fs::File::create(format!("{path}.f0")) | 8916 | + && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var))) |
| 8852 | { | 8917 | { |
| 8853 | for p in [y, u, v] { | 8918 | for p in [y, u, v] { |
| 8854 | let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect(); | 8919 | let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect(); |
| @@ -10361,6 +10426,7 @@ fn decode_leaf8( | |||
| 10361 | neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]); | 10426 | neighbours.record_palette_y_rect(pal_at, 8, 8, 0, [0u16; 8]); |
| 10362 | neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]); | 10427 | neighbours.record_palette_uv_rect(pal_at, 8, 8, 0, [0u16; 8]); |
| 10363 | } | 10428 | } |
| 10429 | + INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); | ||
| 10364 | neighbours.fill_skip_grid(leaf_mi, 2, skip); | 10430 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 10365 | neighbours.fill_lf_grid(leaf_mi, 2, 8, 0); | 10431 | neighbours.fill_lf_grid(leaf_mi, 2, 8, 0); |
| 10366 | neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode); | 10432 | neighbours.record_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, mode); |
| @@ -10588,11 +10654,18 @@ fn decode_leaf_split4( | |||
| 10588 | neighbours.left_uv_mode[r] = uv_predict_mode; | 10654 | neighbours.left_uv_mode[r] = uv_predict_mode; |
| 10589 | neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); | 10655 | neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); |
| 10590 | let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[3] { | 10656 | let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[3] { |
| 10591 | - // As the rect4 pair above: a skipped block still predicts, and CfL is | 10657 | + // A skipped chroma block still gets its CfL contribution: libaom's |
| 10592 | - // prediction (libaom `predict_and_reconstruct_intra_block`). | 10658 | + // `predict_and_reconstruct_intra_block` calls `cfl_predict_block` |
| 10659 | + // from `av1_predict_intra_block_facade` (av1/common/reconintra.c:1719) | ||
| 10660 | + // whenever `mbmi->uv_mode == UV_CFL_PRED`, before any residual is | ||
| 10661 | + // added -- `skip_txfm` only drops the residual, never the alpha. | ||
| 10662 | + // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the | ||
| 10663 | + // merge keeps one fix and feeds both lanes' counters so neither of | ||
| 10664 | + // their gates goes vacuous. | ||
| 10593 | let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | 10665 | let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); |
| 10594 | if alpha.is_some() { | 10666 | if alpha.is_some() { |
| 10595 | CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | 10667 | CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); |
| 10668 | + SKIP_CFL_HITS.with(|c| c.set(c.get() + 1)); | ||
| 10596 | } | 10669 | } |
| 10597 | u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv); | 10670 | u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv); |
| 10598 | v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv); | 10671 | v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv); |
| @@ -10947,11 +11020,18 @@ fn decode_leaf_rect8( | |||
| 10947 | neighbours.left_uv_mode[r] = uv_predict_mode; | 11020 | neighbours.left_uv_mode[r] = uv_predict_mode; |
| 10948 | neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); | 11021 | neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); |
| 10949 | let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[1] { | 11022 | let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[1] { |
| 10950 | - // As the rect4 pair above: a skipped block still predicts, and CfL is | 11023 | + // A skipped chroma block still gets its CfL contribution: libaom's |
| 10951 | - // prediction (libaom `predict_and_reconstruct_intra_block`). | 11024 | + // `predict_and_reconstruct_intra_block` calls `cfl_predict_block` |
| 11025 | + // from `av1_predict_intra_block_facade` (av1/common/reconintra.c:1719) | ||
| 11026 | + // whenever `mbmi->uv_mode == UV_CFL_PRED`, before any residual is | ||
| 11027 | + // added -- `skip_txfm` only drops the residual, never the alpha. | ||
| 11028 | + // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the | ||
| 11029 | + // merge keeps one fix and feeds both lanes' counters so neither of | ||
| 11030 | + // their gates goes vacuous. | ||
| 10952 | let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | 11031 | let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); |
| 10953 | if alpha.is_some() { | 11032 | if alpha.is_some() { |
| 10954 | CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | 11033 | CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); |
| 11034 | + SKIP_CFL_HITS.with(|c| c.set(c.get() + 1)); | ||
| 10955 | } | 11035 | } |
| 10956 | u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv); | 11036 | u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv); |
| 10957 | v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv); | 11037 | v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv); |
| @@ -12702,6 +12782,9 @@ fn apply_cdef( | |||
| 12702 | while mi_r < skip_grid.mi_rows { | 12782 | while mi_r < skip_grid.mi_rows { |
| 12703 | let mut mi_c = 0usize; | 12783 | let mut mi_c = 0usize; |
| 12704 | while mi_c < skip_grid.mi_cols { | 12784 | while mi_c < skip_grid.mi_cols { |
| 12785 | + if skip_grid.is_skip_txfm(mi_r, mi_c) { | ||
| 12786 | + CDEF_SKIPPED_UNITS.with(|c| c.set(c.get() + 1)); | ||
| 12787 | + } | ||
| 12705 | if !skip_grid.is_skip_txfm(mi_r, mi_c) { | 12788 | if !skip_grid.is_skip_txfm(mi_r, mi_c) { |
| 12706 | let sidx = strength_idx(mi_r, mi_c); | 12789 | let sidx = strength_idx(mi_r, mi_c); |
| 12707 | let (ox, oy) = (mi_c * 4, mi_r * 4); | 12790 | let (ox, oy) = (mi_c * 4, mi_r * 4); |
| @@ -12714,10 +12797,15 @@ fn apply_cdef( | |||
| 12714 | i32::from(src_y[ny as usize * y_stride + nx as usize]) | 12797 | i32::from(src_y[ny as usize * y_stride + nx as usize]) |
| 12715 | } | 12798 | } |
| 12716 | }; | 12799 | }; |
| 12717 | - let (dir, var) = cdef_find_dir(coeff_shift, |r, c| { | 12800 | + // lane-cdef r1: the direction search reads the SAME padded |
| 12718 | - let (ny, nx) = ((oy + r).min(y_true_h - 1), (ox + c).min(y_true_w - 1)); | 12801 | + // block the taps do -- libaom runs `cdef_find_dir` on the |
| 12719 | - i32::from(src_y[ny * y_stride + nx]) | 12802 | + // prepared filter block (`cdef_block.c:296-320` over |
| 12720 | - }); | 12803 | + // `cdef_prepare_fb`'s buffer, `cdef.c:249-256`), whose columns |
| 12804 | + // and rows past the mi-rounded frame extent are CDEF_VERY_LARGE. | ||
| 12805 | + // Clamping to the last real sample instead made every straddling | ||
| 12806 | + // edge 8x8 (odd `mi_cols`/`mi_rows`) pick a different var, hence | ||
| 12807 | + // a different `adjust_strength`, hence a +-1 band at the crop edge. | ||
| 12808 | + let (dir, var) = cdef_find_dir(coeff_shift, |r, c| sample_y(r as i32, c as i32)); | ||
| 12721 | 12809 | ||
| 12722 | // libaom `av1_cdef_filter_fb` passes `pri_strength ? dir : 0` | 12810 | // libaom `av1_cdef_filter_fb` passes `pri_strength ? dir : 0` |
| 12723 | // -- each plane zeroes the shared direction when *its own* | 12811 | // -- each plane zeroes the shared direction when *its own* |
| @@ -12727,6 +12815,12 @@ fn apply_cdef( | |||
| 12727 | let y_sec_strength = i32::from(cdef.y_sec_strength[sidx]) << coeff_shift; | 12815 | let y_sec_strength = i32::from(cdef.y_sec_strength[sidx]) << coeff_shift; |
| 12728 | let y_dir = if y_pri_strength != 0 { dir } else { 0 }; | 12816 | let y_dir = if y_pri_strength != 0 { dir } else { 0 }; |
| 12729 | let t = cdef_adjust_strength(y_pri_strength, var); | 12817 | let t = cdef_adjust_strength(y_pri_strength, var); |
| 12818 | + // lane-cdef r1 rung: one line per filtered 8x8 luma CDEF unit. | ||
| 12819 | + if std::env::var_os("EC_AV1_CDEF_DBG").is_some() { | ||
| 12820 | + eprintln!( | ||
| 12821 | + "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}" | ||
| 12822 | + ); | ||
| 12823 | + } | ||
| 12730 | let enable_primary = t != 0; | 12824 | let enable_primary = t != 0; |
| 12731 | let enable_secondary = y_sec_strength != 0; | 12825 | let enable_secondary = y_sec_strength != 0; |
| 12732 | if enable_primary || enable_secondary { | 12826 | if enable_primary || enable_secondary { |
| @@ -20827,6 +20921,14 @@ fn decode_inter_block8( | |||
| 20827 | // so the 16x16 below a split block read partition ctx 0 | 20921 | // so the 16x16 below a split block read partition ctx 0 |
| 20828 | // instead of 1 and mis-read PARTITION_SPLIT as NONE. | 20922 | // instead of 1 and mis-read PARTITION_SPLIT as NONE. |
| 20829 | neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); | 20923 | neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); |
| 20924 | + // lane-cdef r1: ... and the CDEF skip band too. `apply_cdef`'s | ||
| 20925 | + // `is_8x8_block_skip` (libaom `cdef.c:29-38`) reads all four mi | ||
| 20926 | + // cells of the 8x8; this leaf wrote none of them, so a 64x64 | ||
| 20927 | + // whose bottom-right 16x16 is an all-skip 8x8-leaf group kept | ||
| 20928 | + // the PREVIOUS frame's flags and got filtered where libaom's | ||
| 20929 | + // dlist excludes it (3 luma samples on a 192x128 inter frame). | ||
| 20930 | + INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); | ||
| 20931 | + neighbours.fill_skip_grid(leaf_mi, 2, skip); | ||
| 20830 | neighbours.fill_lf_grid( | 20932 | neighbours.fill_lf_grid( |
| 20831 | leaf_mi, | 20933 | leaf_mi, |
| 20832 | 2, | 20934 | 2, |
| @@ -21632,6 +21734,10 @@ fn decode_inter_block8( | |||
| 21632 | // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference | 21734 | // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference |
| 21633 | // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every | 21735 | // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every |
| 21634 | // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test). | 21736 | // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test). |
| 21737 | + // lane-cdef r1: the fall-through twin of the compound arm's skip-band | ||
| 21738 | + // write above -- `skip` is one flag for the whole 8x8 leaf (read at | ||
| 21739 | + // `decode.rs`'s `skip_ctx` site), `split8` only splits its transform. | ||
| 21740 | + neighbours.fill_skip_grid(leaf_mi, 2, skip); | ||
| 21635 | neighbours.fill_lf_grid( | 21741 | neighbours.fill_lf_grid( |
| 21636 | leaf_mi, | 21742 | leaf_mi, |
| 21637 | 2, | 21743 | 2, |
crates/ec-av1/src/stream.rsmodified+221 -7
| @@ -3038,6 +3038,47 @@ mod tests { | |||
| 3038 | eprintln!("{NAME}: pixel-exact, skipped_cfl={skip_cfl}"); | 3038 | eprintln!("{NAME}: pixel-exact, skipped_cfl={skip_cfl}"); |
| 3039 | } | 3039 | } |
| 3040 | 3040 | ||
| 3041 | + /// lane-kf1200 r2: the same film's `-ss 300` key frame, pinned because no | ||
| 3042 | + /// aomenc recipe reaches its shape -- a SKIPPED sub-8x8 chroma block whose | ||
| 3043 | + /// `uv_mode` is `UV_CFL_PRED`. (lane-reelckf r1 burned 20 recipes across cq | ||
| 3044 | + /// 40..63 and nine lavfi sources hunting exactly this block and never got | ||
| 3045 | + /// one; ledger dead-end "never produced a SKIPPED 1:4 or sub-8x8 CfL | ||
| 3046 | + /// block".) Before the fix the two sub-8x8 skip arms passed `None` for the | ||
| 3047 | + /// CfL argument, so the block reconstructed as flat DC and 463 bytes of | ||
| 3048 | + /// this frame's chroma were wrong. HARD-asserts `skip_cfl_hits` moved, so | ||
| 3049 | + /// the fixture cannot silently stop exercising the arm. | ||
| 3050 | + #[test] | ||
| 3051 | + fn the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact() { | ||
| 3052 | + const NAME: &str = "the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact"; | ||
| 3053 | + if !have_ffmpeg() { | ||
| 3054 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 3055 | + return; | ||
| 3056 | + } | ||
| 3057 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | ||
| 3058 | + .join("fixtures/reelb_ss300_key_frame.obu"); | ||
| 3059 | + let stream = std::fs::read(&path) | ||
| 3060 | + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); | ||
| 3061 | + let (width, height) = (3840usize, 1608usize); | ||
| 3062 | + let before = crate::decode::skip_cfl_hits(); | ||
| 3063 | + let frames = match decode_stream(&stream) { | ||
| 3064 | + Ok(frames) => frames, | ||
| 3065 | + Err(e) => panic!("{NAME}: decode_stream refused: {e}"), | ||
| 3066 | + }; | ||
| 3067 | + let skipped_cfl = crate::decode::skip_cfl_hits() - before; | ||
| 3068 | + assert!( | ||
| 3069 | + skipped_cfl > 0, | ||
| 3070 | + "{NAME}: zero skipped sub-8x8 CfL blocks -- the fixture no longer \ | ||
| 3071 | + exercises the arm this test exists for" | ||
| 3072 | + ); | ||
| 3073 | + assert_eq!(frames.len(), 1, "{NAME}: one key frame"); | ||
| 3074 | + assert_eq!((frames[0].width, frames[0].height), (width, height)); | ||
| 3075 | + let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, 1); | ||
| 3076 | + assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg"); | ||
| 3077 | + assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg"); | ||
| 3078 | + assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg"); | ||
| 3079 | + eprintln!("{NAME}: {skipped_cfl} skipped sub-8x8 CfL chroma blocks, frame pixel-exact"); | ||
| 3080 | + } | ||
| 3081 | + | ||
| 3041 | /// lane-hbd10 r1: a real `aomenc --bit-depth=10 --superres-mode=1 | 3082 | /// lane-hbd10 r1: a real `aomenc --bit-depth=10 --superres-mode=1 |
| 3042 | /// --superres-denominator=12` key frame, decoded pixel-exact against | 3083 | /// --superres-denominator=12` key frame, decoded pixel-exact against |
| 3043 | /// ffmpeg's own 10-bit decode. Proves `superres::upscale_row`'s | 3084 | /// ffmpeg's own 10-bit decode. Proves `superres::upscale_row`'s |
| @@ -15611,6 +15652,151 @@ mod tests { | |||
| 15611 | ); | 15652 | ); |
| 15612 | } | 15653 | } |
| 15613 | 15654 | ||
| 15655 | + /// lane-cdef r1: CDEF's per-8x8 skip band under sub-16x16 inter leaves. | ||
| 15656 | + /// | ||
| 15657 | + /// `apply_cdef` excludes an 8x8 luma unit whose four mi cells are all | ||
| 15658 | + /// `skip_txfm` (libaom `cdef.c:29-38 is_8x8_block_skip`, called from | ||
| 15659 | + /// `av1_cdef_compute_sb_list`'s dlist loop). `decode_inter_block8` -- the | ||
| 15660 | + /// leaf path `--min-partition-size=4` makes aomenc pick for a 16x16 group | ||
| 15661 | + /// -- wrote the loop-filter grid but never that skip band, so an all-skip | ||
| 15662 | + /// group kept the PREVIOUS frame's flags and got filtered where libaom | ||
| 15663 | + /// skips it (3 luma samples, decode-order frames 3 and 4 of the 192x128 | ||
| 15664 | + /// cq-8 stream below, at the frame's last 8x8 column). | ||
| 15665 | + /// | ||
| 15666 | + /// Both counters are hard asserts per compared attempt: `cdef_skipped_units` | ||
| 15667 | + /// proves the all-skip dlist exclusion was actually reached, and | ||
| 15668 | + /// `inter8_skip_band_hits` proves the 8x8 leaf path (the writer that used | ||
| 15669 | + /// to be missing) ran on the same stream. | ||
| 15670 | + #[test] | ||
| 15671 | + fn a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact() { | ||
| 15672 | + if !have_aomenc() { | ||
| 15673 | + return; | ||
| 15674 | + } | ||
| 15675 | + let (width, height, frames) = (192usize, 128usize, 6usize); | ||
| 15676 | + let mut refusals: Vec<String> = Vec::new(); | ||
| 15677 | + let mut fired = 0u32; | ||
| 15678 | + for (depth, cq, sp) in [(8u32, 8u32, 3u32), (8, 10, 3), (8, 12, 6), (10, 8, 3), (10, 12, 6)] { | ||
| 15679 | + let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 15680 | + let src = format!( | ||
| 15681 | + "color=c=gray:s={width}x{height}:d=0.24:r=25,format=gray,\ | ||
| 15682 | + geq=lum='128+58*sin((X+N*{sp})/6)+18*sin(Y/23)',format=yuv420p" | ||
| 15683 | + ); | ||
| 15684 | + let y4m = Command::new("ffmpeg") | ||
| 15685 | + .args([ | ||
| 15686 | + "-v", "error", "-f", "lavfi", "-i", &src, "-t", "0.24", "-pix_fmt", pix, | ||
| 15687 | + "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 15688 | + ]) | ||
| 15689 | + .stdin(Stdio::null()) | ||
| 15690 | + .stdout(Stdio::piped()) | ||
| 15691 | + .stderr(Stdio::piped()) | ||
| 15692 | + .output() | ||
| 15693 | + .expect("ffmpeg failed to run"); | ||
| 15694 | + assert!( | ||
| 15695 | + y4m.status.success(), | ||
| 15696 | + "ffmpeg fixture: {}", | ||
| 15697 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 15698 | + ); | ||
| 15699 | + let mut child = Command::new(aomenc_path()) | ||
| 15700 | + .args([ | ||
| 15701 | + "--codec=av1", | ||
| 15702 | + "--passes=1", | ||
| 15703 | + "--end-usage=q", | ||
| 15704 | + &format!("--cq-level={cq}"), | ||
| 15705 | + "--cpu-used=0", | ||
| 15706 | + "--threads=1", | ||
| 15707 | + "--row-mt=0", | ||
| 15708 | + "--sb-size=64", | ||
| 15709 | + &format!("--bit-depth={depth}"), | ||
| 15710 | + &format!("--input-bit-depth={depth}"), | ||
| 15711 | + "--enable-restoration=0", | ||
| 15712 | + "--enable-palette=0", | ||
| 15713 | + "--deltaq-mode=0", | ||
| 15714 | + "--enable-filter-intra=0", | ||
| 15715 | + "--enable-cfl-intra=0", | ||
| 15716 | + "--enable-intrabc=0", | ||
| 15717 | + "--lag-in-frames=0", | ||
| 15718 | + "--enable-obmc=0", | ||
| 15719 | + "--enable-tx-size-search=1", | ||
| 15720 | + "--enable-rect-partitions=0", | ||
| 15721 | + "--enable-ab-partitions=0", | ||
| 15722 | + "--enable-1to4-partitions=0", | ||
| 15723 | + "--min-partition-size=4", | ||
| 15724 | + "--max-partition-size=16", | ||
| 15725 | + // Last occurrence of a repeated --enable-* flag wins | ||
| 15726 | + // (aomenc-last-flag-wins): CDEF stays ON, and the two | ||
| 15727 | + // counters below prove the filter really ran. | ||
| 15728 | + "--enable-cdef=1", | ||
| 15729 | + "--obu", | ||
| 15730 | + "-o", | ||
| 15731 | + "-", | ||
| 15732 | + "-", | ||
| 15733 | + ]) | ||
| 15734 | + .stdin(Stdio::piped()) | ||
| 15735 | + .stdout(Stdio::piped()) | ||
| 15736 | + .stderr(Stdio::piped()) | ||
| 15737 | + .spawn() | ||
| 15738 | + .expect("aomenc failed to start"); | ||
| 15739 | + child | ||
| 15740 | + .stdin | ||
| 15741 | + .take() | ||
| 15742 | + .expect("aomenc stdin") | ||
| 15743 | + .write_all(&y4m.stdout) | ||
| 15744 | + .expect("writing y4m to aomenc"); | ||
| 15745 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 15746 | + assert!( | ||
| 15747 | + out.status.success(), | ||
| 15748 | + "aomenc refused the fixture (depth={depth} cq={cq})" | ||
| 15749 | + ); | ||
| 15750 | + let stream = out.stdout; | ||
| 15751 | + let skipped_before = decode::cdef_skipped_units(); | ||
| 15752 | + let leaves_before = decode::inter8_skip_band_hits(); | ||
| 15753 | + let decoded = match decode_stream(&stream) { | ||
| 15754 | + Ok(f) => f, | ||
| 15755 | + Err(e) => { | ||
| 15756 | + let msg = e.to_string(); | ||
| 15757 | + assert!( | ||
| 15758 | + msg.starts_with("unsupported: "), | ||
| 15759 | + "decode error that is not a named refusal \ | ||
| 15760 | + (depth={depth} cq={cq}): {msg}" | ||
| 15761 | + ); | ||
| 15762 | + refusals.push(format!("depth={depth} cq={cq}: {msg}")); | ||
| 15763 | + continue; | ||
| 15764 | + } | ||
| 15765 | + }; | ||
| 15766 | + assert_eq!(decoded.len(), frames, "frame count (depth={depth} cq={cq})"); | ||
| 15767 | + assert!( | ||
| 15768 | + decode::cdef_skipped_units() > skipped_before, | ||
| 15769 | + "no 8x8 CDEF unit was excluded by the all-skip rule \ | ||
| 15770 | + (depth={depth} cq={cq})" | ||
| 15771 | + ); | ||
| 15772 | + assert!( | ||
| 15773 | + decode::inter8_skip_band_hits() > leaves_before, | ||
| 15774 | + "no sub-16x16 inter leaf wrote the CDEF skip band \ | ||
| 15775 | + (depth={depth} cq={cq})" | ||
| 15776 | + ); | ||
| 15777 | + let reference = if depth == 10 { | ||
| 15778 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames) | ||
| 15779 | + } else { | ||
| 15780 | + ffmpeg_decode_sequence(&stream, width, height, frames) | ||
| 15781 | + }; | ||
| 15782 | + for (i, (ours, theirs)) in decoded.iter().zip(reference.iter()).enumerate() { | ||
| 15783 | + assert_eq!(ours.y, theirs.y, "luma frame {i} (depth={depth} cq={cq})"); | ||
| 15784 | + assert_eq!(ours.u, theirs.u, "U frame {i} (depth={depth} cq={cq})"); | ||
| 15785 | + assert_eq!(ours.v, theirs.v, "V frame {i} (depth={depth} cq={cq})"); | ||
| 15786 | + } | ||
| 15787 | + fired += 1; | ||
| 15788 | + } | ||
| 15789 | + // Three of the five arms land on OTHER open refusals (a non-DC chroma | ||
| 15790 | + // mode on an 8x8 inter leaf; inter partitions below 8x8) -- the two | ||
| 15791 | + // 8-bit cq 8/10 arms ARE the streams the defect was found on, and each | ||
| 15792 | + // hard-asserts both counters plus all six frames on all three planes. | ||
| 15793 | + assert!( | ||
| 15794 | + fired >= 2, | ||
| 15795 | + "fewer than 2 firing+pixel-exact attempts:\n{}", | ||
| 15796 | + refusals.join("\n") | ||
| 15797 | + ); | ||
| 15798 | + } | ||
| 15799 | + | ||
| 15614 | /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients | 15800 | /// lane-sub8 r1: `--min-partition-size=4` on fine-detail noisy gradients |
| 15615 | /// at low cq reliably makes aomenc split an 8x8 block all the way to | 15801 | /// at low cq reliably makes aomenc split an 8x8 block all the way to |
| 15616 | /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec | 15802 | /// four `BLOCK_4X4` leaves (`PARTITION_SPLIT` below 8x8, spec |
| @@ -21602,6 +21788,11 @@ mod tests { | |||
| 21602 | let (mut horz_proved, mut vert_proved) = (0usize, 0usize); | 21788 | let (mut horz_proved, mut vert_proved) = (0usize, 0usize); |
| 21603 | let (mut chroma_proved, mut coeff_proved) = (0usize, 0usize); | 21789 | let (mut chroma_proved, mut coeff_proved) = (0usize, 0usize); |
| 21604 | let mut split_proved = 0usize; | 21790 | let mut split_proved = 0usize; |
| 21791 | + // lane-kf1200: chroma pairs whose intra-edge filter type comes out | ||
| 21792 | + // different when read from the PAIR's base mi (libaom's | ||
| 21793 | + // `chroma_above_mbmi`) rather than the odd strip mi -- the shape | ||
| 21794 | + // that was silently wrong by 1 on the ReelB key frames. | ||
| 21795 | + let mut pair_filt_proved = 0usize; | ||
| 21605 | let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); | 21796 | let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); |
| 21606 | // The second half of the window turns `--enable-tx-size-search` on: | 21797 | // The second half of the window turns `--enable-tx-size-search` on: |
| 21607 | // that is what makes a 16x4 strip SPLIT its transform (depth 1 = | 21798 | // that is what makes a 16x4 strip SPLIT its transform (depth 1 = |
| @@ -21614,11 +21805,26 @@ mod tests { | |||
| 21614 | let axis = if attempt % 2 == 0 { "Y" } else { "X" }; | 21805 | let axis = if attempt % 2 == 0 { "Y" } else { "X" }; |
| 21615 | let step = 67 + (attempt / 2) * 12; | 21806 | let step = 67 + (attempt / 2) * 12; |
| 21616 | let noise = 6 + (attempt % 4) * 3; | 21807 | let noise = 6 + (attempt % 4) * 3; |
| 21617 | - let source = format!( | 21808 | + // lane-kf1200: the odd attempts carry CHROMA content. The |
| 21618 | - "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | 21809 | + // original gray source leaves both chroma planes constant, so |
| 21619 | - geq=lum='mod(floor({axis}/4)*{step},256)',\ | 21810 | + // every `uv_mode` is DC and a pair's edge-filter type can never |
| 21620 | - noise=alls={noise}:all_seed={seed},format=yuv420p" | 21811 | + // differ from its strip's -- the shape that shipped wrong for |
| 21621 | - ); | 21812 | + // months. A smooth chroma gradient makes aomenc pick SMOOTH / |
| 21813 | + // directional `uv_mode`s next to each other. | ||
| 21814 | + let source = if attempt % 2 == 0 { | ||
| 21815 | + format!( | ||
| 21816 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | ||
| 21817 | + geq=lum='mod(floor({axis}/4)*{step},256)',\ | ||
| 21818 | + noise=alls={noise}:all_seed={seed},format=yuv420p" | ||
| 21819 | + ) | ||
| 21820 | + } else { | ||
| 21821 | + format!( | ||
| 21822 | + "color=c=black:s={width}x{height}:d={duration}:r=25,format=yuv420p,\ | ||
| 21823 | + geq=lum='mod(floor({axis}/4)*{step},256)'\ | ||
| 21824 | + :cb='128+100*sin((X+Y)/23)':cr='128+100*cos(X/19)',\ | ||
| 21825 | + noise=alls={noise}:all_seed={seed}" | ||
| 21826 | + ) | ||
| 21827 | + }; | ||
| 21622 | let cq_level = format!("--cq-level={}", 24 + (attempt % 4) * 8); | 21828 | let cq_level = format!("--cq-level={}", 24 + (attempt % 4) * 8); |
| 21623 | let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | 21829 | let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; |
| 21624 | let y4m = Command::new("ffmpeg") | 21830 | let y4m = Command::new("ffmpeg") |
| @@ -21697,6 +21903,7 @@ mod tests { | |||
| 21697 | ); | 21903 | ); |
| 21698 | let stream = out.stdout; | 21904 | let stream = out.stdout; |
| 21699 | let before = crate::decode::rect4_16_counters(); | 21905 | let before = crate::decode::rect4_16_counters(); |
| 21906 | + let pair_filt_before = crate::decode::rect4_16_uv_pair_filt_hits(); | ||
| 21700 | let frames = match decode_stream(&stream) { | 21907 | let frames = match decode_stream(&stream) { |
| 21701 | Err(e) => { | 21908 | Err(e) => { |
| 21702 | let msg = e.to_string(); | 21909 | let msg = e.to_string(); |
| @@ -21765,6 +21972,7 @@ mod tests { | |||
| 21765 | vert_proved += vert; | 21972 | vert_proved += vert; |
| 21766 | chroma_proved += chroma; | 21973 | chroma_proved += chroma; |
| 21767 | coeff_proved += coeff; | 21974 | coeff_proved += coeff; |
| 21975 | + pair_filt_proved += crate::decode::rect4_16_uv_pair_filt_hits() - pair_filt_before; | ||
| 21768 | split_proved += split; | 21976 | split_proved += split; |
| 21769 | matched += 1; | 21977 | matched += 1; |
| 21770 | } | 21978 | } |
| @@ -21797,11 +22005,17 @@ mod tests { | |||
| 21797 | "{NAME}: {bit_depth}-bit compared attempts never split a strip's transform -- \ | 22005 | "{NAME}: {bit_depth}-bit compared attempts never split a strip's transform -- \ |
| 21798 | the `--enable-tx-size-search=1` half of the window proved nothing" | 22006 | the `--enable-tx-size-search=1` half of the window proved nothing" |
| 21799 | ); | 22007 | ); |
| 22008 | + assert!( | ||
| 22009 | + pair_filt_proved > 0, | ||
| 22010 | + "{NAME}: {bit_depth}-bit compared attempts never decoded a chroma pair whose \ | ||
| 22011 | + edge-filter type differs between the pair's base mi and the strip's own mi -- \ | ||
| 22012 | + the lane-kf1200 fix is unexercised, so this gate would pass with it reverted" | ||
| 22013 | + ); | ||
| 21800 | eprintln!( | 22014 | eprintln!( |
| 21801 | "{NAME}: {bit_depth}-bit {matched} compared attempts, {horz_proved} 16x4 / \ | 22015 | "{NAME}: {bit_depth}-bit {matched} compared attempts, {horz_proved} 16x4 / \ |
| 21802 | {vert_proved} 4x16 strips, {chroma_proved} chroma pairs, {coeff_proved} coded \ | 22016 | {vert_proved} 4x16 strips, {chroma_proved} chroma pairs, {coeff_proved} coded \ |
| 21803 | - units, {split_proved} split-transform strips, {named_refusals} refusals, \ | 22017 | + units, {split_proved} split-transform strips, {pair_filt_proved} pair-base \ |
| 21804 | - {out_of_scope} out of scope" | 22018 | + filt-type flips, {named_refusals} refusals, {out_of_scope} out of scope" |
| 21805 | ); | 22019 | ); |
| 21806 | } | 22020 | } |
| 21807 | } | 22021 | } |
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/kf1200-r1.report.mdadded+106 -0
| @@ -0,0 +1,106 @@ | |||
| 1 | +# lane-kf1200 r1 — the 16x4/4x16 chroma pair read its edge-filter type from the wrong mi | ||
| 2 | + | ||
| 3 | +## Defect (census4 premise, re-measured on this branch) | ||
| 4 | + | ||
| 5 | +ReelB `-ss 1200` key frame (1 frame, `3840x1608 yuv420p10le`), our | ||
| 6 | +`EC_PROBE_OUT16` vs `ffmpeg -pix_fmt yuv420p10le`: **12 U samples at ±1, Y and V exact**. | ||
| 7 | +Stage bisect (`EC_AV1_PREFILT_DUMP16` ours vs aomdec's): **13 U samples already wrong | ||
| 8 | +before the loop filter** — a reconstruction defect, not deblock/CDEF/LR/film grain, and | ||
| 9 | +not an entropy desync (lane-kf900's shape). | ||
| 10 | + | ||
| 11 | +## Root cause | ||
| 12 | + | ||
| 13 | +Block: chroma `(x=352, y=356)`, `8x4`, `uv_mode = H_PRED`, `angle_delta_uv = -2` | ||
| 14 | +(`p_angle = 174`), the chroma half of a `16x8` **`PARTITION_HORZ_4` pair** at | ||
| 15 | +luma mi `(178,176)`, strip mi `(179,176)`. | ||
| 16 | +Its prediction differed from aomdec's by 4 samples of the last row | ||
| 17 | +(`OUR_PRED sum=16208` vs `EC_PREDOUT sum=16212`); row 0 and column 0 identical. | ||
| 18 | + | ||
| 19 | +`decode.rs:7683` asked for the chroma edge-filter type at the **strip's own mi** | ||
| 20 | +(`lmi = (179,176)`). libaom builds `chroma_above_mbmi`/`chroma_left_mbmi` from | ||
| 21 | +`mi[-((mi_row & ss_y) * mi_stride + (mi_col & ss_x))]` (`set_mi_offsets`, | ||
| 22 | +`av1/common/blockd.h`), i.e. from the **pair's base mi** `(178,176)`, and | ||
| 23 | +`get_intra_edge_filter_type` (`av1/common/reconintra.c:974`) reads that block's | ||
| 24 | +`uv_mode`. The mi directly above the strip, `(178,176)`, is a non-chroma-reference | ||
| 25 | +4-row block whose `uv_mode` is `UV_DC_PRED`; the mi above the PAIR, `(177,176)`, | ||
| 26 | +coded `uv_mode = SMOOTH` (aomdec `EC_IMODE_VAL mi_row=177 mi_col=176 uv_mode=9`). | ||
| 27 | + | ||
| 28 | +So we computed `filt_type = 0` where libaom has `1` (aomdec `EC_PRED ... ft=1`). | ||
| 29 | +With `filt_type = 0`, `av1_use_intra_edge_upsample(4, 8, -6, 0)` is TRUE | ||
| 30 | +(`blk_wh = 12 <= 16`) instead of false — the left edge was upsampled before the | ||
| 31 | +z2 walk, moving 4 samples by 1. The strength/upsample/z2 code itself is correct: | ||
| 32 | +recomputing z2 by hand from the (identical) neighbour pixels reproduces aomdec's | ||
| 33 | +row exactly (`scratchpad/kf1200`, brute force over dy/offsets). | ||
| 34 | + | ||
| 35 | +## Change | ||
| 36 | + | ||
| 37 | +- `crates/ec-av1/src/decode.rs:7683` — `smooth_uv_neighbour(pair_mi.0, pair_mi.1, ...)` | ||
| 38 | + instead of `(lmi.0, lmi.1, ...)`, with the libaom citation. | ||
| 39 | +- `crates/ec-av1/src/decode.rs:2196` — new `RECT4_16_UV_PAIR_FILT_HITS` counter + | ||
| 40 | + `rect4_16_uv_pair_filt_hits()`: pairs where the pair-base answer DIFFERS from the | ||
| 41 | + strip-mi answer, i.e. the blocks the fix changes. | ||
| 42 | +- `crates/ec-av1/src/stream.rs` gate | ||
| 43 | + `a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact` — the odd | ||
| 44 | + attempts now use a **chroma-carrying** source (smooth `cb`/`cr` gradients); the gray | ||
| 45 | + source left both chroma planes constant, so every `uv_mode` was DC and the shape was | ||
| 46 | + unreachable. New hard assert: `pair_filt_proved > 0` per bit-depth arm. | ||
| 47 | + | ||
| 48 | +No refusal lifted, so `refusal_inventory.rs`/`gate_coverage.rs` are unchanged. | ||
| 49 | + | ||
| 50 | +## EVIDENCE | ||
| 51 | + | ||
| 52 | +EVIDENCE: /tmp/.../scratchpad/kf1200/{ours16,ref.yuv} | ffmpeg -ss 1200 -t 0.4 -c:v copy -f obu, trunc.py to 1 frame (sha256 b4b92873d0329964 twice), decode_probe EC_PROBE_OUT16 vs ffmpeg yuv420p10le | U samples differing 12 -> 0, Y/V 0 (Y 0, U 0, V 0 after fix) | ||
| 53 | +EVIDENCE: /tmp/.../scratchpad/kf1200/{pre.f0,apre.f0} | EC_AV1_PREFILT_DUMP16 ours vs aomdec on the same 1-frame stream | 13 U samples differ pre-loop-filter => reconstruction, not filters/grain | ||
| 54 | +EVIDENCE: /tmp/.../scratchpad/kf1200/{opred.txt,apred.txt} | EC_PRED=1 on both decoders | block (352,356) 8x4 mode=2 ad=-2: ours sum=16208 vs EC_PREDOUT sum=16212, oracle EC_PRED ft=1 | ||
| 55 | +EVIDENCE: gate run `cargo test -p ec-av1 --lib a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact -- --nocapture` | real aomenc, 8-bit and 10-bit arms | 8-bit: 16 compared attempts, 232 16x4 / 244 4x16, 238 chroma pairs, 13 pair-base filt-type flips, PASS; 10-bit: 15 attempts, 198 pairs, 8 flips, PASS | ||
| 56 | +EVIDENCE: same gate with the fix reverted (pair_mi -> lmi) | one-line revert, rebuild, rerun | FAILED "frame 0 U vs ffmpeg (8-bit, seed 43)" -- the gate is decisive, not vacuous | ||
| 57 | +EVIDENCE: $HOME/.cache/kf1200-census.log | 24 HG key frames, 1-frame truncation, EC_PROBE_OUT16 vs ffmpeg, each stream sha256'd twice (identical) | see table | ||
| 58 | + | ||
| 59 | +## 24 key-frame census (bytes differing, 1 frame each) | ||
| 60 | + | ||
| 61 | +| -ss | before (census4) | after | | ||
| 62 | +|----:|-----------------:|------:| | ||
| 63 | +| 0 | 0 | 0 | | ||
| 64 | +| 300 | 463 | 463 | | ||
| 65 | +| 600 | 48771 | 48771 | | ||
| 66 | +| 900 | 14057195 | 14057191 | | ||
| 67 | +| **1200** | **14** | **0** | | ||
| 68 | +| 1500 | 16649701 | 16649650 | | ||
| 69 | +| **1800** | **248** | **0** | | ||
| 70 | +| 2100 | 15147518 | 15147782 | | ||
| 71 | +| 2400 | 42343 | 42343 | | ||
| 72 | +| 2700 | 7726287 | 7726287 | | ||
| 73 | +| 3000 | 0 | 0 | | ||
| 74 | +| 3300 | 44500 | **39971** | | ||
| 75 | +| **3600** | **1** | **0** | | ||
| 76 | +| 3900 | 7554020 | 7554023 | | ||
| 77 | +| 4200 | 0 | 0 | | ||
| 78 | +| 4500 | 0 | 0 | | ||
| 79 | +| 4800 | 2348 | 2348 | | ||
| 80 | +| 5100 | 0 | 0 | | ||
| 81 | +| 5400 | 0 | 0 | | ||
| 82 | +| 5700 | 16375 | 16375 | | ||
| 83 | +| 6000 | 15450360 | 15449720 | | ||
| 84 | +| 6300 | 15410936 | 15410864 | | ||
| 85 | +| 6600 | 15181681 | 15181688 | | ||
| 86 | +| 6900 | 0 | 0 | | ||
| 87 | + | ||
| 88 | +(The census4 numbers were taken with the same recipe; note census4 measured frame 0 of a | ||
| 89 | +segment that then refused later frames, and this run truncates to 1 frame identically. | ||
| 90 | +The multi-million counts are lane-kf900's entropy-desync territory, unchanged here.) | ||
| 91 | + | ||
| 92 | +## Residue | ||
| 93 | + | ||
| 94 | +- deferred: `-ss 300` (463 bytes) — a DIFFERENT shape, also chroma-only and also | ||
| 95 | + pre-loop-filter, but block-constant offsets of +1/+2 over a ~16x16 chroma region at | ||
| 96 | + chroma (412,384) (`EC_AV1_PREFILT_DUMP16` diff, this branch) — reads like CfL alpha or | ||
| 97 | + a chroma DC/dequant defect, not an edge-filter type. Unblocked by: localising that | ||
| 98 | + block's `uv_mode`/CfL alpha the same way (EC_IMODE_VAL + EC_PRED at mi (206,192)). | ||
| 99 | +- deferred: `-ss 600 / 2400 / 4800 / 5700 / 3300` (48771 / 42343 / 2348 / 16375 / 39971) — | ||
| 100 | + larger residuals, not triaged in this round. | ||
| 101 | +- accepted: the multi-million-byte segments are entropy desyncs owned by lane-kf900. | ||
| 102 | + | ||
| 103 | +## Suite | ||
| 104 | + | ||
| 105 | +`cargo test -p ec-av1 --lib` (systemd unit, `EC_AV1_REQUIRE_AOMENC=1`, log `$HOME/.cache/kf1200-suite-r1.log`): | ||
| 106 | +**370 passed / 0 failed / 32 ignored**, 1546 s. | ||
lanes/kf1200-r2.handoff.mdadded+72 -0
| @@ -0,0 +1,72 @@ | |||
| 1 | +# lane-kf1200 r2 HANDOFF | ||
| 2 | + | ||
| 3 | +## Merge state | ||
| 4 | +Branch `lane-kf1200`, tip `385b745`. `git merge main` (85887c7 = lane-mvtwin + | ||
| 5 | +lane-sb128b) landed clean at `d85d7d2`; cdf.rs byte-identical to main's; r1's | ||
| 6 | +pair-mi chroma edge-filter fix survives at decode.rs:7747. main contains | ||
| 7 | +NEITHER lane-reelckf NOR lane-kf900 (`git log --oneline main | grep` empty for | ||
| 8 | +both), so no duplicate-implementation resolution was needed and the | ||
| 9 | +multi-million-byte census rows are still kf900's. | ||
| 10 | +Do NOT commit `lanes/COMMON-20260901.md` — another agent edits it in this | ||
| 11 | +worktree; it is intentionally left unstaged. (It is currently modified.) | ||
| 12 | + | ||
| 13 | +## Per-segment findings (ReelB, 1-frame truncation, EC_PROBE_OUT16 vs ffmpeg 10-bit) | ||
| 14 | +- **-ss 300 — FIXED (463 -> 0 bytes).** Plane: U+V only, Y exact. First bad | ||
| 15 | + sample chroma (412,384). Stage: PRE-loop-filter (EC_AV1_PREFILT_DUMP16), | ||
| 16 | + 16x16 chroma region at (384,412). Block: the 4x4 chroma block of the | ||
| 17 | + BLOCK_4X4 2x2 group at luma mi (206,192); chroma-ref mi (207,193), | ||
| 18 | + `uv_mode=13` (UV_CFL_PRED), `skip=1`. Root cause: both sub-8x8 leaf decoders | ||
| 19 | + passed literal `None` for the CfL argument in their `skip_txfm` arm | ||
| 20 | + (decode.rs:10554/10555 4-leaf, :10916/10917 2-leaf), so the block | ||
| 21 | + reconstructed as flat DC. libaom `av1_predict_intra_block_facade` | ||
| 22 | + (av1/common/reconintra.c:1719) calls `cfl_predict_block` whenever | ||
| 23 | + `mbmi->uv_mode == UV_CFL_PRED`; `skip_txfm` drops only the residual. | ||
| 24 | + Fix: compute `cfl_ac_q3(y, gpx, gpy, 8)` and pass `alpha.zip(ac)` in both | ||
| 25 | + arms + `SKIP_CFL_HITS` counter (decode.rs:2207, `skip_cfl_hits()`). | ||
| 26 | + Effect: -ss 300 pixel-exact; -ss 4800 2348 -> 34 bytes as a side effect. | ||
| 27 | +- **-ss 600 / 2400 / 3300 / 5700 — ONE class, open.** 48771 / 42343 / 39971 / | ||
| 28 | + 16375 bytes. All planes. Final-picture damage rows Y 1595..1607, chroma | ||
| 29 | + 796..803. Stage: PRE-loop-filter damage is EXACTLY luma rows 1600..1607, | ||
| 30 | + cols 192..3839 (rows 1595..1599 are deblock spill across the y=1600 edge). | ||
| 31 | + Frame is 1608 rows = 25 full 64-px SB rows + an 8-row remainder, so this is | ||
| 32 | + the bottom PARTIAL superblock row; its first three superblocks (cols 0..191) | ||
| 33 | + are pixel-exact. Block: our prediction trace matches aomdec block-for-block | ||
| 34 | + through mi (400,47) (mi 44 four TX_4X4 in an 8x8, mi 46 an 8x8). First | ||
| 35 | + divergence is the FIRST block of superblock #3: | ||
| 36 | + aomdec `EC_PRED mi_row=400 mi_col=48 txw=16 txh=8 mode=2 p_angle=180 bsize=5 part=1 ft=1` | ||
| 37 | + ours `OUR_PRED x=192 y=1600 bw=32 bh=16 mode=0 ad=0` (decode.rs:6511) | ||
| 38 | + i.e. a PARTITION-SYMBOL divergence at the root of a partial-height | ||
| 39 | + superblock (`has_rows == false`, 2 of 16 mi rows present). Not prediction, | ||
| 40 | + not caused by the preceding block. Root cause NOT yet identified. | ||
| 41 | +- **-ss 4800 — open, small.** 34 bytes (was 2348). Chroma only, luma exact, | ||
| 42 | + PRE-loop-filter: U 25 + V 3 samples in an 8x4 chroma patch rows 540..543 | ||
| 43 | + cols 1200..1207, |d| <= 6. Luma mi ~ (270,600). Same geometry as r1's | ||
| 44 | + 16x8 PARTITION_HORZ_4 pair defect -> likely a sibling of the pair-mi bug. | ||
| 45 | +- Accepted (kf900's): 900, 1500, 2100, 2700, 3900, 6000, 6300, 6600. | ||
| 46 | + | ||
| 47 | +## Gate state | ||
| 48 | +- New: `the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact` | ||
| 49 | + (crates/ec-av1/src/stream.rs), pins | ||
| 50 | + `crates/ec-av1/fixtures/reelb_ss300_key_frame.obu` (139201 B, sha256 | ||
| 51 | + 7e3ddf0d602f9496b2f7eb11f051fd4a045020e094d5bc02f83825e2c494ef12, one | ||
| 52 | + 3840x1608 yuv420p10le key frame, `git add -f`, confirmed in `git ls-files`). | ||
| 53 | + HARD-asserts `skip_cfl_hits > 0` (it fires exactly ONCE in the whole frame) | ||
| 54 | + then Y/U/V vs ffmpeg. Fixture used because lane-reelckf r1's ledger dead-end | ||
| 55 | + records 20 aomenc recipes that never produced a skipped sub-8x8 CfL block. | ||
| 56 | +- r1's `a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact` | ||
| 57 | + (chroma-carrying source + `pair_filt_proved > 0`) unchanged and green. | ||
| 58 | +- No refusal lifted; refusal_inventory.rs / gate_coverage.rs untouched. | ||
| 59 | +- Suite: 378 passed / 0 failed / 33 ignored (794.95 s), | ||
| 60 | + `$HOME/.cache/kf1200-suite-r2.log`. | ||
| 61 | + | ||
| 62 | +## Exact next step | ||
| 63 | +Range-ladder the partition symbols of superblock (mi_row=400, mi_col=48) on | ||
| 64 | +`scratchpad/kf1200/s600_f1.obu` (1 frame, sha256 36de46676ed7de70… stable | ||
| 65 | +twice): both decoders are still in sync at mi (400,47), so start the ladder | ||
| 66 | +there and compare aomdec's `r->ec.rng` at each `EC_IMODE`/partition read | ||
| 67 | +against ours element by element (compare RANGE, never tell()). The suspect is | ||
| 68 | +the `has_rows == false` forced-partition path at a 64x64 root with only 2 mi | ||
| 69 | +rows left — we take a 32x16 where libaom takes 16x8. Artifacts already on disk | ||
| 70 | +in scratchpad/kf1200: s600_f1.obu, a600p.trace (aomdec EC_PRED), o600.trace | ||
| 71 | +(our OUR_PRED), pre600.f0 / apre600.f0 (prefilter dumps), d1.py (plane differ), | ||
| 72 | +census.sh (24-frame census, debug probe path). | ||
lanes/kf1200-r2.report.mdadded+183 -0
| @@ -0,0 +1,183 @@ | |||
| 1 | +# lane-kf1200 r2 — a skipped sub-8x8 chroma block dropped its CfL alpha | ||
| 2 | + | ||
| 3 | +## 1. Merge | ||
| 4 | + | ||
| 5 | +`git merge --no-commit main` (main `85887c7`, lane-mvtwin + lane-sb128b) — clean | ||
| 6 | +auto-merge, no conflicts. `crates/ec-av1/src/cdf.rs` byte-identical to main's | ||
| 7 | +(`cmp <(git show main:.../cdf.rs) .../cdf.rs` → identical). r1's pair-mi chroma | ||
| 8 | +edge-filter fix and its counter survive at `decode.rs:7747`. Commit `d85d7d2`. | ||
| 9 | +main contains neither lane-reelckf nor lane-kf900 (`git log --oneline main | grep` | ||
| 10 | +→ empty for both), so no duplicate-implementation resolution was needed and the | ||
| 11 | +multi-million-byte census rows are still lane-kf900's territory. | ||
| 12 | + | ||
| 13 | +## 2. Defect found and fixed: `-ss 300`, 463 bytes → 0 | ||
| 14 | + | ||
| 15 | +Re-measured premise on this branch (1-frame truncation, hash stable twice): | ||
| 16 | +U 219 / V 220 samples wrong, Y exact. `EC_AV1_PREFILT_DUMP16` ours vs aomdec's: | ||
| 17 | +227 U + 227 V wrong **before the loop filter**, in a 16x16 chroma region at | ||
| 18 | +chroma `(384,412)` — reconstruction, not filters. | ||
| 19 | + | ||
| 20 | +First bad sample chroma `(412,384)` = the 4x4 chroma block of the `BLOCK_4X4` | ||
| 21 | +2x2 group at luma mi `(206,192)`. aomdec `EC_TRACE_MODE`: | ||
| 22 | +`EC_IMODE_VAL mi_row=207 mi_col=193 mode=4 uv_mode=13 skip=1` — `uv_mode = 13` | ||
| 23 | +is `UV_CFL_PRED`, `skip_txfm = 1`. Our `OUR_PRED x=384 y=412 side=4 mode=0 | ||
| 24 | +sum=8240 row0=[515,515,515,515]` is flat: DC with **no CfL term at all** | ||
| 25 | +(aomdec's own prediction sums to 8241 with a bottom-left ramp). | ||
| 26 | + | ||
| 27 | +Root cause: both sub-8x8 leaf decoders passed a literal `None` for the CfL | ||
| 28 | +argument in their `skip_txfm` arm — | ||
| 29 | + | ||
| 30 | +- `crates/ec-av1/src/decode.rs:10554/10555` (the 4-leaf `BLOCK_4X4` group) | ||
| 31 | +- `crates/ec-av1/src/decode.rs:10916/10917` (the 2-leaf group) | ||
| 32 | + | ||
| 33 | +libaom's `av1_predict_intra_block_facade` (`av1/common/reconintra.c:1719`) calls | ||
| 34 | +`cfl_predict_block` whenever `mbmi->uv_mode == UV_CFL_PRED`; `skip_txfm` only | ||
| 35 | +suppresses the residual, never the alpha. Both arms now compute | ||
| 36 | +`cfl_ac_q3(y, gpx, gpy, 8)` and pass `alpha.zip(ac)`, exactly like the | ||
| 37 | +non-skip arm two lines below and like the rect skip arms already did. | ||
| 38 | + | ||
| 39 | +### Class sweep | ||
| 40 | + | ||
| 41 | +Every chroma `reconstruct` / `reconstruct_rect` call site in `decode.rs` was | ||
| 42 | +parsed and its cfl argument printed (script in the r2 scratchpad). The rect | ||
| 43 | +skip arms (`6015`, `6519`, `8078`) already pass `alpha.zip(ac)`; the only other | ||
| 44 | +literal `None` is `20284/20296`, which sits directly behind the refusal | ||
| 45 | +"a non-DC chroma mode on an 8x8 inter-frame leaf" (`decode.rs:20212`), so | ||
| 46 | +`uv_mode == DC_PRED` is guaranteed there. No other instance of the class. | ||
| 47 | + | ||
| 48 | +### Counter + gate | ||
| 49 | + | ||
| 50 | +- `decode.rs:2207` `SKIP_CFL_HITS` / `pub fn skip_cfl_hits()` — skipped sub-8x8 | ||
| 51 | + chroma blocks that carried a CfL alpha. | ||
| 52 | +- `crates/ec-av1/src/stream.rs` | ||
| 53 | + `the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact` — pins | ||
| 54 | + `crates/ec-av1/fixtures/reelb_ss300_key_frame.obu` (139 201 B, sha256 | ||
| 55 | + `7e3ddf0d602f9496b2f7eb11f051fd4a045020e094d5bc02f83825e2c494ef12`, one | ||
| 56 | + 3840x1608 yuv420p10le key frame), decodes it, HARD-asserts | ||
| 57 | + `skip_cfl_hits > 0`, then compares Y/U/V against ffmpeg's own 10-bit decode. | ||
| 58 | + `git add -f` was used (bare `fixtures` in .gitignore); `git ls-files` confirms | ||
| 59 | + it is tracked. | ||
| 60 | + | ||
| 61 | +Why a fixture and not an aomenc recipe: lane-reelckf r1's ledger dead-end — | ||
| 62 | +20 recipes (cq 40..63 × nine lavfi sources, min/max-partition sweeps, sb-size | ||
| 63 | +64 and 128) never produced a **skipped** sub-8x8 CfL block (`skip_cfl` counter | ||
| 64 | +0 in all). The shape fires exactly **once** in a whole 4K key frame, which is | ||
| 65 | +why no synthetic source reaches it. | ||
| 66 | + | ||
| 67 | +No refusal lifted → `refusal_inventory.rs` / `gate_coverage.rs` unchanged. | ||
| 68 | + | ||
| 69 | +## 3. Remaining residuals — triaged, one class | ||
| 70 | + | ||
| 71 | +`-ss 600 / 2400 / 3300 / 5700` (48771 / 42343 / 39971 / 16375 bytes) are ONE | ||
| 72 | +defect class, not four: in every one of them the damage is confined to the | ||
| 73 | +**last 8 luma rows** of the frame. | ||
| 74 | + | ||
| 75 | +| -ss | Y rows wrong | U/V rows | first bad Y sample | | ||
| 76 | +|----:|---|---|---| | ||
| 77 | +| 600 | 1595..1607 | 796..803 | (1595, 2916) | | ||
| 78 | +| 2400 | 1595..1607 | 796..803 | (1595, 2445) | | ||
| 79 | +| 3300 | 1595..1607 | 796..803 | (1595, 1235) | | ||
| 80 | +| 5700 | 1596..1607 | 796..803 | (1596, 3039) | | ||
| 81 | + | ||
| 82 | +`EC_AV1_PREFILT_DUMP16` on `-ss 600` narrows it further: pre-loop-filter the | ||
| 83 | +damage is exactly rows **1600..1607**, columns **192..3839** (rows 1595..1599 | ||
| 84 | +in the final picture are deblock spill across the y=1600 edge). The frame is | ||
| 85 | +1608 rows = 25 full 64-px superblock rows + one 8-row remainder, so this is the | ||
| 86 | +bottom **partial** superblock row, and the first three superblocks of it | ||
| 87 | +(columns 0..191) are pixel-exact. | ||
| 88 | + | ||
| 89 | +Divergence localised to a single block. Through luma mi `(400,47)` our | ||
| 90 | +prediction trace matches aomdec's block for block (mi 44: four TX_4X4 in an | ||
| 91 | +8x8; mi 46: 8x8 — `EC_PRED mi_row=400 mi_col=46 txw=8 txh=8`). At the very | ||
| 92 | +first block of superblock #3: | ||
| 93 | + | ||
| 94 | +- aomdec: `EC_PRED mi_row=400 mi_col=48 txw=16 txh=8 mode=2 p_angle=180 bsize=5 part=1 ft=1` | ||
| 95 | +- ours: `OUR_PRED x=192 y=1600 bw=32 bh=16 mode=0 ad=0` (decode.rs:6511) | ||
| 96 | + | ||
| 97 | +i.e. we read a 32x16 `PARTITION_HORZ` where libaom reads a 16x8, and the mode | ||
| 98 | +differs too — a **partition-symbol divergence at the root of a partial-height | ||
| 99 | +superblock** (`has_rows == false`, only 2 of 16 mi rows present), not a | ||
| 100 | +prediction bug and not caused by the preceding block. Everything after it in | ||
| 101 | +that row is garbage because the row never re-syncs (it is the last row, so | ||
| 102 | +nothing propagates downward). | ||
| 103 | + | ||
| 104 | +`-ss 4800` (2348 bytes in r1, **34 bytes** after this round's CfL fix) is a | ||
| 105 | +different, much smaller shape: chroma only, | ||
| 106 | +U 29 + V 5 samples in the final picture. `EC_AV1_PREFILT_DUMP16` puts it | ||
| 107 | +**pre-loop-filter** too — U 25 + V 3 samples in an **8x4 chroma patch** at | ||
| 108 | +rows 540..543, cols 1200..1207 (`|d| <= 6`), luma exact. That is the same | ||
| 109 | +geometry as r1's defect (an 8x4 chroma block = the chroma half of a 16x8 | ||
| 110 | +`PARTITION_HORZ_4` pair) at luma mi ~`(270,600)`, so it is a strong candidate | ||
| 111 | +for a sibling of the pair-mi bug rather than a new class. | ||
| 112 | + | ||
| 113 | +## 4. Disposition | ||
| 114 | + | ||
| 115 | +- fix-now (done): `-ss 300` skipped-CfL, fixed + gated + swept. | ||
| 116 | +- deferred: the bottom partial-superblock partition divergence (`-ss 600`, | ||
| 117 | + 2400, 3300, 5700). Unblocked by: a range ladder over the partition symbols | ||
| 118 | + of superblock `(mi_row=400, mi_col=48)` in `s600_f1.obu` comparing aomdec's | ||
| 119 | + `r->ec.rng` at `EC_IMODE` against ours — the first three superblocks of the | ||
| 120 | + same row are exact, so the ladder starts already in sync at mi 400/47. | ||
| 121 | +- deferred: `-ss 4800` (34 B, down from 2348) — stage-attributed (pre-loop-filter, chroma-only, | ||
| 122 | + 8x4 patch at chroma (540,1200), luma mi ~(270,600)); the per-block | ||
| 123 | + `EC_IMODE_VAL`/`EC_PRED` comparison at that mi is the next step. | ||
| 124 | +- accepted: `-ss 900 / 1500 / 2100 / 2700 / 3900 / 6000 / 6300 / 6600` | ||
| 125 | + (multi-million bytes) are lane-kf900's entropy desyncs, not merged into main. | ||
| 126 | + | ||
| 127 | +## 5. 24 key-frame census (bytes differing vs ffmpeg, 1 truncated frame each) | ||
| 128 | + | ||
| 129 | +Recipe: `$HOME/.cache/kf1200-census-r2.log` (script `census.sh` in the r2 | ||
| 130 | +scratchpad) — `ffmpeg -ss S -t 0.4 -c:v copy -f obu`, `trunc.py … 1`, each | ||
| 131 | +stream sha256'd twice (identical in all 24 rows), `EC_PROBE_OUT16` vs | ||
| 132 | +`ffmpeg -pix_fmt yuv420p10le`. | ||
| 133 | + | ||
| 134 | +| -ss | r1 (after pair-mi fix) | r2 (after skipped-CfL fix) | | ||
| 135 | +|----:|-----------------------:|---------------------------:| | ||
| 136 | +| 0 | 0 | 0 | | ||
| 137 | +| **300** | **463** | **0** | | ||
| 138 | +| 600 | 48771 | 48771 | | ||
| 139 | +| 900 | 14057191 | 14057191 | | ||
| 140 | +| 1200 | 0 | 0 | | ||
| 141 | +| 1500 | 16649650 | 16649650 | | ||
| 142 | +| 1800 | 0 | 0 | | ||
| 143 | +| 2100 | 15147782 | 15148697 | | ||
| 144 | +| 2400 | 42343 | 42343 | | ||
| 145 | +| 2700 | 7726287 | 7726168 | | ||
| 146 | +| 3000 | 0 | 0 | | ||
| 147 | +| 3300 | 39971 | 39971 | | ||
| 148 | +| 3600 | 0 | 0 | | ||
| 149 | +| 3900 | 7554023 | 7554023 | | ||
| 150 | +| 4200 | 0 | 0 | | ||
| 151 | +| 4500 | 0 | 0 | | ||
| 152 | +| **4800** | **2348** | **34** | | ||
| 153 | +| 5100 | 0 | 0 | | ||
| 154 | +| 5400 | 0 | 0 | | ||
| 155 | +| 5700 | 16375 | 16375 | | ||
| 156 | +| 6000 | 15449720 | 15449720 | | ||
| 157 | +| 6300 | 15410864 | 15410664 | | ||
| 158 | +| 6600 | 15181688 | 15180826 | | ||
| 159 | +| 6900 | 0 | 0 | | ||
| 160 | + | ||
| 161 | +**11 of 24 key frames now decode pixel-exact** (was 10). `-ss 300` is exact; | ||
| 162 | +`-ss 4800` fell 2348 → 34 bytes (its remaining 8x4 chroma patch is the residue | ||
| 163 | +described in §3). Rows differing by a few hundred bytes inside the | ||
| 164 | +multi-million-byte segments are the usual desync churn of lane-kf900's | ||
| 165 | +territory, not a regression: none of them changed sign or magnitude class. | ||
| 166 | + | ||
| 167 | +## 6. Suite | ||
| 168 | + | ||
| 169 | +`cargo test -p ec-av1 --lib` under `systemd-run --user --unit=kf1200-suite-r2b | ||
| 170 | +-p MemoryMax=10G`, `EC_AV1_REQUIRE_AOMENC=1 EC_NOMEMGUARD=1 -j3`, log | ||
| 171 | +`$HOME/.cache/kf1200-suite-r2.log`: | ||
| 172 | +**378 passed / 0 failed / 33 ignored**, 794.95 s. | ||
| 173 | + | ||
| 174 | +## EVIDENCE | ||
| 175 | + | ||
| 176 | +EVIDENCE: $HOME/.cache/kf1200-suite-r2.log | systemd unit kf1200-suite-r2b, EC_AV1_REQUIRE_AOMENC=1, cargo test -p ec-av1 --lib -j3 | test result: ok. 378 passed; 0 failed; 33 ignored; 794.95s | ||
| 177 | +EVIDENCE: scratchpad/kf1200/{o300,r300} | 1-frame -ss 300 truncation (sha256 7e3ddf0d602f9496 twice), EC_PROBE_OUT16 vs ffmpeg -pix_fmt yuv420p10le | before fix Y 0 / U 219 / V 220 samples differ; after fix Y 0 / U 0 / V 0 | ||
| 178 | +EVIDENCE: scratchpad/kf1200/{pre300.f0,apre300.f0} | EC_AV1_PREFILT_DUMP16 ours vs aomdec, same stream | 227 U + 227 V wrong PRE-loop-filter in a 16x16 chroma region at (384,412) => reconstruction | ||
| 179 | +EVIDENCE: scratchpad/kf1200/{o300.trace,a300.trace} | EC_PRED=1 ours, EC_TRACE_MODE=1 EC_PRED=1 aomdec | aomdec EC_IMODE_VAL mi_row=207 mi_col=193 uv_mode=13 (UV_CFL_PRED) skip=1; ours OUR_PRED x=384 y=412 side=4 mode=0 sum=8240 flat (no CfL term) | ||
| 180 | +EVIDENCE: gate run `cargo test -p ec-av1 --lib the_reelb_ss300 -- --nocapture` | pinned 1-frame fixture + ffmpeg 10-bit reference | "1 skipped sub-8x8 CfL chroma blocks, frame pixel-exact", 1 passed / 0 failed | ||
| 181 | +EVIDENCE: scratchpad/kf1200/{pre600.f0,apre600.f0} | EC_AV1_PREFILT_DUMP16 ours vs aomdec on the -ss 600 1-frame stream | damage exactly luma rows 1600..1607, cols 192..3839 = the bottom partial (8-row) superblock row from superblock #3 on | ||
| 182 | +EVIDENCE: scratchpad/kf1200/{o600.trace,a600p.trace} | EC_PRED both decoders | mi (400,44) and (400,46) match block for block; at mi (400,48) aomdec txw=16 txh=8 mode=2 bsize=5 vs ours bw=32 bh=16 mode=0 => partition divergence at the partial-SB root | ||
| 183 | +EVIDENCE: $HOME/.cache/kf1200-census-r2.log | census.sh, 24 key frames, each stream hashed twice | 11/24 pixel-exact (was 10); -ss 300 463->0, -ss 4800 2348->34 | ||