Merge branch 'main' into lane-sb128
Browse files at this commit14 changed files +2499 -322
- crates/ec-av1/examples/dump_yuv.rs +46 -0
- crates/ec-av1/src/decode.rs +758 -165
- crates/ec-av1/src/encode.rs +10 -6
- crates/ec-av1/src/gate_coverage.rs +6 -4
- crates/ec-av1/src/refusal_inventory.rs +6 -4
- crates/ec-av1/src/stream.rs +990 -143
- lanes/fiinter-r1.report.md +95 -0
- lanes/intrainter-r1.handoff.md +70 -0
- lanes/intrainter-r1.report.md +63 -0
- lanes/modectx-r1.report.md +93 -0
- lanes/rect1d-r1.report.md +77 -0
- lanes/rectsplitx-r1.report.md +105 -0
- lanes/rectsplitx-r2.report.md +102 -0
- lanes/rectsplitx-r3.report.md +78 -0
crates/ec-av1/examples/dump_yuv.rsadded+46 -0
| @@ -0,0 +1,46 @@ | |||
| 1 | +//! Decode one OBU stream and write every frame's planes as raw little-endian | ||
| 2 | +//! `u16` (`<out-prefix>.f<N>.yuv`) — the high-bit-depth companion to | ||
| 3 | +//! `EC_AV1_PREFILT_DUMP`, whose `as u8` narrowing throws away exactly the bits | ||
| 4 | +//! a 10-bit mismatch lives in (lane-rect1d r1 found its defect by diffing this | ||
| 5 | +//! against `ffmpeg -pix_fmt yuv420p10le -f rawvideo`). | ||
| 6 | +//! | ||
| 7 | +//! ```text | ||
| 8 | +//! cargo run -p ec-av1 --example dump_yuv -- s.obu /tmp/ours | ||
| 9 | +//! ffmpeg -v error -i s.obu -pix_fmt yuv420p10le -f rawvideo /tmp/ref.yuv | ||
| 10 | +//! cmp /tmp/ours.f0.yuv /tmp/ref.yuv | ||
| 11 | +//! ``` | ||
| 12 | +fn main() { | ||
| 13 | + let mut args = std::env::args().skip(1); | ||
| 14 | + let (Some(path), Some(out)) = (args.next(), args.next()) else { | ||
| 15 | + eprintln!("usage: dump_yuv <stream.obu> <out-prefix>"); | ||
| 16 | + std::process::exit(2); | ||
| 17 | + }; | ||
| 18 | + let data = match std::fs::read(&path) { | ||
| 19 | + Ok(data) => data, | ||
| 20 | + Err(e) => { | ||
| 21 | + eprintln!("{path}: {e}"); | ||
| 22 | + std::process::exit(2); | ||
| 23 | + } | ||
| 24 | + }; | ||
| 25 | + let frames = match ec_av1::stream::decode_stream(&data) { | ||
| 26 | + Ok(frames) => frames, | ||
| 27 | + Err(e) => { | ||
| 28 | + eprintln!("{path}: {e}"); | ||
| 29 | + std::process::exit(1); | ||
| 30 | + } | ||
| 31 | + }; | ||
| 32 | + for (i, f) in frames.iter().enumerate() { | ||
| 33 | + let mut buf = Vec::with_capacity((f.y.len() + f.u.len() + f.v.len()) * 2); | ||
| 34 | + for plane in [&f.y, &f.u, &f.v] { | ||
| 35 | + for &s in plane.iter() { | ||
| 36 | + buf.extend_from_slice(&s.to_le_bytes()); | ||
| 37 | + } | ||
| 38 | + } | ||
| 39 | + let name = format!("{out}.f{i}.yuv"); | ||
| 40 | + if let Err(e) = std::fs::write(&name, &buf) { | ||
| 41 | + eprintln!("{name}: {e}"); | ||
| 42 | + std::process::exit(2); | ||
| 43 | + } | ||
| 44 | + println!("frame {i}: {}x{} -> {name}", f.width, f.height); | ||
| 45 | + } | ||
| 46 | +} | ||
crates/ec-av1/src/decode.rsmodified+758 -165
| @@ -128,6 +128,20 @@ pub(crate) fn filter_intra_hits() -> usize { | |||
| 128 | FILTER_INTRA_HITS.with(|c| c.get()) | 128 | FILTER_INTRA_HITS.with(|c| c.get()) |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | +// lane-fiinter r1: how many of those `use_filter_intra == 1` symbols belonged | ||
| 132 | +// to an INTRA block inside an INTER frame (`read_intra_block_mode_info`'s own | ||
| 133 | +// `read_filter_intra_mode_info` call), which no gate exercised before this | ||
| 134 | +// round -- every inter gate recipe passed `--enable-filter-intra=0`. | ||
| 135 | +thread_local! { | ||
| 136 | + static INTRA_IN_INTER_FILTER_INTRA_HITS: std::cell::Cell<usize> = | ||
| 137 | + const { std::cell::Cell::new(0) }; | ||
| 138 | +} | ||
| 139 | + | ||
| 140 | +/// Current value of [`INTRA_IN_INTER_FILTER_INTRA_HITS`]. | ||
| 141 | +pub(crate) fn intra_in_inter_filter_intra_hits() -> usize { | ||
| 142 | + INTRA_IN_INTER_FILTER_INTRA_HITS.with(|c| c.get()) | ||
| 143 | +} | ||
| 144 | + | ||
| 131 | // lane-realworld r1: this frame's `cdef.bits` (spec 5.9.19), threaded into | 145 | // lane-realworld r1: this frame's `cdef.bits` (spec 5.9.19), threaded into |
| 132 | // [`maybe_read_cdef_idx`] the same way [`ENABLE_EDGE_FILTER`] threads a | 146 | // [`maybe_read_cdef_idx`] the same way [`ENABLE_EDGE_FILTER`] threads a |
| 133 | // frame-level flag through the recursive block decode -- `0` (the default) | 147 | // frame-level flag through the recursive block decode -- `0` (the default) |
| @@ -779,7 +793,7 @@ fn tu_reach( | |||
| 779 | width: usize, | 793 | width: usize, |
| 780 | height: usize, | 794 | height: usize, |
| 781 | ) -> Reach { | 795 | ) -> Reach { |
| 782 | - let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx, block); | 796 | + let fixed = Reach::of_tu(bw, bh, col_off, row_off, tx, tx, block); |
| 783 | let standalone = Reach::of(tx, px + col_off, py + row_off, width, height); | 797 | let standalone = Reach::of(tx, px + col_off, py + row_off, width, height); |
| 784 | if fixed != standalone { | 798 | if fixed != standalone { |
| 785 | SPLIT_TU_REACH_FIX_HITS.with(|c| c.set(c.get() + 1)); | 799 | SPLIT_TU_REACH_FIX_HITS.with(|c| c.set(c.get() + 1)); |
| @@ -947,6 +961,11 @@ thread_local! { | |||
| 947 | // frame-constant. | 961 | // frame-constant. |
| 948 | static TX_SELECT_INTER: std::cell::Cell<bool> = const { std::cell::Cell::new(false) }; | 962 | static TX_SELECT_INTER: std::cell::Cell<bool> = const { std::cell::Cell::new(false) }; |
| 949 | static REDUCED_TX_SET_INTER: std::cell::Cell<bool> = const { std::cell::Cell::new(true) }; | 963 | static REDUCED_TX_SET_INTER: std::cell::Cell<bool> = const { std::cell::Cell::new(true) }; |
| 964 | + // lane-fiinter r1: this sequence header's own `enable_filter_intra` bit, | ||
| 965 | + // frame-constant like the two above and stashed the same way -- an intra | ||
| 966 | + // block inside an inter frame reads `use_filter_intra` under it. | ||
| 967 | + static ENABLE_FILTER_INTRA_INTER: std::cell::Cell<bool> = | ||
| 968 | + const { std::cell::Cell::new(false) }; | ||
| 950 | } | 969 | } |
| 951 | 970 | ||
| 952 | /// Current value of [`TXFM_SPLIT_READS`]. | 971 | /// Current value of [`TXFM_SPLIT_READS`]. |
| @@ -959,10 +978,16 @@ pub(crate) fn txfm_split_hits() -> usize { | |||
| 959 | TXFM_SPLIT_HITS.with(|c| c.get()) | 978 | TXFM_SPLIT_HITS.with(|c| c.get()) |
| 960 | } | 979 | } |
| 961 | 980 | ||
| 962 | -/// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]. | 981 | +/// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/ |
| 963 | -pub(crate) fn set_inter_tx_mode(tx_select: bool, reduced_tx_set: bool) { | 982 | +/// [`ENABLE_FILTER_INTRA_INTER`]. |
| 983 | +pub(crate) fn set_inter_tx_mode( | ||
| 984 | + tx_select: bool, | ||
| 985 | + reduced_tx_set: bool, | ||
| 986 | + enable_filter_intra: bool, | ||
| 987 | +) { | ||
| 964 | TX_SELECT_INTER.with(|c| c.set(tx_select)); | 988 | TX_SELECT_INTER.with(|c| c.set(tx_select)); |
| 965 | REDUCED_TX_SET_INTER.with(|c| c.set(reduced_tx_set)); | 989 | REDUCED_TX_SET_INTER.with(|c| c.set(reduced_tx_set)); |
| 990 | + ENABLE_FILTER_INTRA_INTER.with(|c| c.set(enable_filter_intra)); | ||
| 966 | } | 991 | } |
| 967 | 992 | ||
| 968 | // How many `partition_w16` reads (a 16x16 block's own partition symbol, key | 993 | // How many `partition_w16` reads (a 16x16 block's own partition symbol, key |
| @@ -1119,6 +1144,28 @@ pub(crate) fn filter_intra_rect4_vert_hits() -> usize { | |||
| 1119 | FILTER_INTRA_RECT4_VERT_HITS.with(|c| c.get()) | 1144 | FILTER_INTRA_RECT4_VERT_HITS.with(|c| c.get()) |
| 1120 | } | 1145 | } |
| 1121 | 1146 | ||
| 1147 | +// How many rectangular transform units actually coded coefficients through | ||
| 1148 | +// [`read_coeffs_rect`] (`all_zero == 0`) -- lane-rect1d's measure that a gate | ||
| 1149 | +// exercised the rect coefficient reader at all rather than passing on | ||
| 1150 | +// all-skip blocks. | ||
| 1151 | +thread_local! { | ||
| 1152 | + static RECT_COEFF_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1153 | + static RECT_CLASS1_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1154 | +} | ||
| 1155 | + | ||
| 1156 | +/// Current value of [`RECT_COEFF_TU_HITS`]. | ||
| 1157 | +pub(crate) fn rect_coeff_tu_hits() -> usize { | ||
| 1158 | + RECT_COEFF_TU_HITS.with(|c| c.get()) | ||
| 1159 | +} | ||
| 1160 | + | ||
| 1161 | +/// Rectangular transform units whose resolved `tx_type` is a 1D class | ||
| 1162 | +/// (`V_DCT`/`H_DCT`) -- [`TX_CLASS1_HITS`]'s rect-only half, so a gate can | ||
| 1163 | +/// pin that the 1D-class-on-a-RECT-transform path fired rather than settling | ||
| 1164 | +/// for the square reader's own 1D types. | ||
| 1165 | +pub(crate) fn rect_class1_hits() -> usize { | ||
| 1166 | + RECT_CLASS1_HITS.with(|c| c.get()) | ||
| 1167 | +} | ||
| 1168 | + | ||
| 1122 | // As [`FILTER_INTRA_RECT_HITS`], counting only the strips BELOW 16x16 | 1169 | // As [`FILTER_INTRA_RECT_HITS`], counting only the strips BELOW 16x16 |
| 1123 | // (8x16/16x8 leaves of a 16x16 HORZ/VERT partition, lane-fistrip r1) -- the | 1170 | // (8x16/16x8 leaves of a 16x16 HORZ/VERT partition, lane-fistrip r1) -- the |
| 1124 | // shapes whose `use_filter_intra` symbol had no CDF class before this round. | 1171 | // shapes whose `use_filter_intra` symbol had no CDF class before this round. |
| @@ -1327,6 +1374,19 @@ pub(crate) fn palette_split_tx_hits() -> usize { | |||
| 1327 | PALETTE_SPLIT_TX_HITS.with(|c| c.get()) | 1374 | PALETTE_SPLIT_TX_HITS.with(|c| c.get()) |
| 1328 | } | 1375 | } |
| 1329 | 1376 | ||
| 1377 | +// lane-intrainter r1: intra blocks inside an INTER frame whose `tx_depth` | ||
| 1378 | +// symbol split their luma transform, bucketed by block side (8, 16, 32, 64) -- | ||
| 1379 | +// the gate's proof that the lifted path actually ran, per size. | ||
| 1380 | +thread_local! { | ||
| 1381 | + static INTRA_IN_INTER_SPLIT_TX_HITS: std::cell::Cell<[usize; 4]> = | ||
| 1382 | + const { std::cell::Cell::new([0; 4]) }; | ||
| 1383 | +} | ||
| 1384 | + | ||
| 1385 | +/// Current value of [`INTRA_IN_INTER_SPLIT_TX_HITS`], indexed 8/16/32/64. | ||
| 1386 | +pub(crate) fn intra_in_inter_split_tx_hits() -> [usize; 4] { | ||
| 1387 | + INTRA_IN_INTER_SPLIT_TX_HITS.with(std::cell::Cell::get) | ||
| 1388 | +} | ||
| 1389 | + | ||
| 1330 | thread_local! { | 1390 | thread_local! { |
| 1331 | /// A just-decoded palette-Y block's own predicted pixels | 1391 | /// A just-decoded palette-Y block's own predicted pixels |
| 1332 | /// (`side*side`, row-major, `colors[map[i]]`), consumed by | 1392 | /// (`side*side`, row-major, `colors[map[i]]`), consumed by |
| @@ -1789,6 +1849,24 @@ pub(crate) fn mode_mi_override_hits() -> usize { | |||
| 1789 | MODE_MI_OVERRIDE_HITS.with(|c| c.get()) | 1849 | MODE_MI_OVERRIDE_HITS.with(|c| c.get()) |
| 1790 | } | 1850 | } |
| 1791 | 1851 | ||
| 1852 | +// lane-modectx r1: how many times a `kf_y_mode`/`y_mode` neighbour read at a | ||
| 1853 | +// TILE edge found its coarse fallback band holding a NON-DC mode -- i.e. a | ||
| 1854 | +// mode from the previous tile, where libaom's `up_available`/`left_available` | ||
| 1855 | +// make the neighbour DC_PRED. Measured 0 over 20 two-tile-column streams: | ||
| 1856 | +// `above_mode` is cleared per tile in `Neighbours::start_tile` and `left_mode` | ||
| 1857 | +// per superblock row in `start_row`, so the luma fallback cannot leak the way | ||
| 1858 | +// lane-mtfix's `above_uv_mode` one did. The gate asserts it stays 0 -- this is | ||
| 1859 | +// the invariant that makes the coarse fallback safe. | ||
| 1860 | +thread_local! { | ||
| 1861 | + static MODE_TILE_EDGE_COARSE_LEAKS: std::cell::Cell<usize> = | ||
| 1862 | + const { std::cell::Cell::new(0) }; | ||
| 1863 | +} | ||
| 1864 | + | ||
| 1865 | +/// Current value of [`MODE_TILE_EDGE_COARSE_LEAKS`]. | ||
| 1866 | +pub(crate) fn mode_tile_edge_coarse_leaks() -> usize { | ||
| 1867 | + MODE_TILE_EDGE_COARSE_LEAKS.with(|c| c.get()) | ||
| 1868 | +} | ||
| 1869 | + | ||
| 1792 | // lane-cfl r1: how many times a chroma intra-edge filter-type read | 1870 | // lane-cfl r1: how many times a chroma intra-edge filter-type read |
| 1793 | // (`get_filt_type`, libaom reconintra.c) took an above/left UV mode from the | 1871 | // (`get_filt_type`, libaom reconintra.c) took an above/left UV mode from the |
| 1794 | // mi-exact map that DIFFERS from its coarse 16x16 slot -- i.e. how often the | 1872 | // mi-exact map that DIFFERS from its coarse 16x16 slot -- i.e. how often the |
| @@ -1910,6 +1988,30 @@ thread_local! { | |||
| 1910 | static RECT4_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 1988 | static RECT4_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 1911 | } | 1989 | } |
| 1912 | 1990 | ||
| 1991 | +// lane-rectsplitx r1: 1:4 strips (32x8/8x32/64x16/16x64) decoded through the | ||
| 1992 | +// per-transform-unit split path, split by tx depth -- depth 1 is a 2:1 RECT | ||
| 1993 | +// unit (TX_16X8/TX_32X16), depth 2 a square one, and the two INTERLEAVE in | ||
| 1994 | +// every real stream, so a gate must prove both fired. `SUB16_SPLIT_HITS` | ||
| 1995 | +// counts the same for a 16x8/8x16 strip below 16x16. | ||
| 1996 | +thread_local! { | ||
| 1997 | + static RECT4_SPLIT_DEPTH1_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1998 | + static RECT4_SPLIT_DEPTH2_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1999 | + static SUB16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2000 | +} | ||
| 2001 | + | ||
| 2002 | +/// Current values of `RECT4_SPLIT_DEPTH1_HITS` / `RECT4_SPLIT_DEPTH2_HITS`. | ||
| 2003 | +pub(crate) fn rect4_split_depth_hits() -> (usize, usize) { | ||
| 2004 | + ( | ||
| 2005 | + RECT4_SPLIT_DEPTH1_HITS.with(|c| c.get()), | ||
| 2006 | + RECT4_SPLIT_DEPTH2_HITS.with(|c| c.get()), | ||
| 2007 | + ) | ||
| 2008 | +} | ||
| 2009 | + | ||
| 2010 | +/// Current value of `SUB16_SPLIT_HITS`. | ||
| 2011 | +pub(crate) fn sub16_split_hits() -> usize { | ||
| 2012 | + SUB16_SPLIT_HITS.with(|c| c.get()) | ||
| 2013 | +} | ||
| 2014 | + | ||
| 1913 | /// Current value of `RECT4_COEFF_HITS`. | 2015 | /// Current value of `RECT4_COEFF_HITS`. |
| 1914 | pub(crate) fn rect4_coeff_hits() -> usize { | 2016 | pub(crate) fn rect4_coeff_hits() -> usize { |
| 1915 | RECT4_COEFF_HITS.with(|c| c.get()) | 2017 | RECT4_COEFF_HITS.with(|c| c.get()) |
| @@ -2949,6 +3051,7 @@ fn read_coeffs( | |||
| 2949 | let class = TxClass::of(tx_type); | 3051 | let class = TxClass::of(tx_type); |
| 2950 | if class != TxClass::TwoD { | 3052 | if class != TxClass::TwoD { |
| 2951 | TX_CLASS1_HITS.with(|c| c.set(c.get() + 1)); | 3053 | TX_CLASS1_HITS.with(|c| c.set(c.get() + 1)); |
| 3054 | + RECT_CLASS1_HITS.with(|c| c.set(c.get() + 1)); | ||
| 2952 | } | 3055 | } |
| 2953 | let eob = read_eob(dec, coding, class); | 3056 | let eob = read_eob(dec, coding, class); |
| 2954 | if trace { | 3057 | if trace { |
| @@ -3099,6 +3202,7 @@ fn read_coeffs_rect( | |||
| 3099 | if all_zero { | 3202 | if all_zero { |
| 3100 | return Ok((grid, TxType::DctDct)); | 3203 | return Ok((grid, TxType::DctDct)); |
| 3101 | } | 3204 | } |
| 3205 | + RECT_COEFF_TU_HITS.with(|c| c.set(c.get() + 1)); | ||
| 3102 | // lane-tx4x8: a 4x8/8x4 luma TU DOES carry a `tx_type` symbol (its set is | 3206 | // lane-tx4x8: a 4x8/8x4 luma TU DOES carry a `tx_type` symbol (its set is |
| 3103 | // `EXT_TX_SET_DTT4_IDTX(_1DDCT)`, `tx_size_sqr_up == TX_8X8`), including | 3207 | // `EXT_TX_SET_DTT4_IDTX(_1DDCT)`, `tx_size_sqr_up == TX_8X8`), including |
| 3104 | // the `V_DCT`/`H_DCT` members whose 1D tx class needs its own scan and | 3208 | // the `V_DCT`/`H_DCT` members whose 1D tx class needs its own scan and |
| @@ -4139,11 +4243,26 @@ impl Neighbours { | |||
| 4139 | /// [`Self::around_mi`]'s plain coded/uncoded bit, this needs the real | 4243 | /// [`Self::around_mi`]'s plain coded/uncoded bit, this needs the real |
| 4140 | /// cumulative level -- a lone-TU block never calls this (its `txb_skip_ctx` | 4244 | /// cumulative level -- a lone-TU block never calls this (its `txb_skip_ctx` |
| 4141 | /// is always 0, spec's `plane_bsize == tx_size` branch). | 4245 | /// is always 0, spec's `plane_bsize == tx_size` branch). |
| 4142 | - fn luma_skip_ctx(&self, (mi_r, mi_c): (usize, usize), side_mi: usize) -> usize { | 4246 | + fn luma_skip_ctx(&self, at_mi: (usize, usize), side_mi: usize) -> usize { |
| 4247 | + self.luma_skip_ctx_rect(at_mi, side_mi, side_mi) | ||
| 4248 | + } | ||
| 4249 | + | ||
| 4250 | + /// [`Self::luma_skip_ctx`] with the unit's own width and height in mi | ||
| 4251 | + /// units (lane-rectsplitx r1) -- `get_txb_ctx_general` ORs the above | ||
| 4252 | + /// context over `tx_size_wide` and the left one over `tx_size_high`. | ||
| 4253 | + fn luma_skip_ctx_rect( | ||
| 4254 | + &self, | ||
| 4255 | + (mi_r, mi_c): (usize, usize), | ||
| 4256 | + w_mi: usize, | ||
| 4257 | + h_mi: usize, | ||
| 4258 | + ) -> usize { | ||
| 4259 | + let side_mi = w_mi; | ||
| 4143 | let mut top = 0u8; | 4260 | let mut top = 0u8; |
| 4144 | let mut left = 0u8; | 4261 | let mut left = 0u8; |
| 4145 | - for cell in 0..side_mi { | 4262 | + for cell in 0..w_mi { |
| 4146 | top |= self.above[mi_c + cell][0].level; | 4263 | top |= self.above[mi_c + cell][0].level; |
| 4264 | + } | ||
| 4265 | + for cell in 0..h_mi { | ||
| 4147 | left |= self.left[mi_r + cell][0].level; | 4266 | left |= self.left[mi_r + cell][0].level; |
| 4148 | } | 4267 | } |
| 4149 | let ctx = SKIP_CONTEXTS[(top as usize).min(4)][(left as usize).min(4)]; | 4268 | let ctx = SKIP_CONTEXTS[(top as usize).min(4)][(left as usize).min(4)]; |
| @@ -4295,13 +4414,56 @@ impl Neighbours { | |||
| 4295 | /// strip path ([`decode_leaf_rect`] took this override in r4; a 32x16 strip | 4414 | /// strip path ([`decode_leaf_rect`] took this override in r4; a 32x16 strip |
| 4296 | /// whose left neighbour was a 16x8 leaf still read the stale row and picked | 4415 | /// whose left neighbour was a 16x8 leaf still read the stale row and picked |
| 4297 | /// a different CDF for the same mode value). | 4416 | /// a different CDF for the same mode value). |
| 4417 | + /// lane-rectsplitx r2: availability-correct above/left luma modes for a | ||
| 4418 | + /// block whose top-left mi is `(mi_r, mi_c)`. libaom reads `above_mbmi` | ||
| 4419 | + /// only when `up_available` and `left_mbmi` only when `left_available`; | ||
| 4420 | + /// the coarse [`SUB`] bands cannot express that, and with 8-px strips they | ||
| 4421 | + /// actively lie -- four 32x8 strips of one `HORZ_4` share ONE 16x16 | ||
| 4422 | + /// `left_mode` cell, so the second strip at tile column 0 read the FIRST | ||
| 4423 | + /// strip's mode as its "left neighbour" (measured on the band fixture at | ||
| 4424 | + /// mi(10,0): mode 2 where libaom has DC, a different `kf_y_mode` row). | ||
| 4425 | + fn modes_above_left_mi( | ||
| 4426 | + &self, | ||
| 4427 | + mi_r: usize, | ||
| 4428 | + mi_c: usize, | ||
| 4429 | + fallback: (usize, usize), | ||
| 4430 | + ) -> (usize, usize) { | ||
| 4431 | + let above = if mi_r > self.tile_row0_mi { | ||
| 4432 | + self.mode_above_mi(mi_r, mi_c).unwrap_or(fallback.0) | ||
| 4433 | + } else { | ||
| 4434 | + DC_PRED | ||
| 4435 | + }; | ||
| 4436 | + let left = if mi_c > self.tile_col0_mi { | ||
| 4437 | + self.mode_left_mi(mi_r, mi_c).unwrap_or(fallback.1) | ||
| 4438 | + } else { | ||
| 4439 | + DC_PRED | ||
| 4440 | + }; | ||
| 4441 | + (above, left) | ||
| 4442 | + } | ||
| 4443 | + | ||
| 4444 | + /// lane-modectx r1: the coarse-[`SUB`]-grid entry point, now availability | ||
| 4445 | + /// correct. The mi-exact lookups already refuse to cross a tile edge, but | ||
| 4446 | + /// their FALLBACK (`above_mode`/`left_mode`) did not: `left_mode` is reset | ||
| 4447 | + /// per superblock row and never per tile, so the first block column of | ||
| 4448 | + /// tile 2..N read the previous tile's mode as its left neighbour, and the | ||
| 4449 | + /// above band survives across a tile ROW boundary the same way lane-mtfix's | ||
| 4450 | + /// `above_uv_mode` did. libaom reads `above_mbmi`/`left_mbmi` only when | ||
| 4451 | + /// `up_available`/`left_available` and uses DC_PRED otherwise | ||
| 4452 | + /// ([`Self::modes_above_left_mi`]). | ||
| 4298 | fn modes_above_left(&self, r: usize, c: usize) -> (usize, usize) { | 4453 | fn modes_above_left(&self, r: usize, c: usize) -> (usize, usize) { |
| 4299 | let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); | 4454 | let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); |
| 4300 | - let above = self.mode_above_mi(mi_r, mi_c).unwrap_or(self.above_mode[c]); | 4455 | + let (above, left) = |
| 4301 | - let left = self.mode_left_mi(mi_r, mi_c).unwrap_or(self.left_mode[r]); | 4456 | + self.modes_above_left_mi(mi_r, mi_c, (self.above_mode[c], self.left_mode[r])); |
| 4302 | if above != self.above_mode[c] || left != self.left_mode[r] { | 4457 | if above != self.above_mode[c] || left != self.left_mode[r] { |
| 4303 | MODE_MI_OVERRIDE_HITS.with(|h| h.set(h.get() + 1)); | 4458 | MODE_MI_OVERRIDE_HITS.with(|h| h.set(h.get() + 1)); |
| 4304 | } | 4459 | } |
| 4460 | + // A neighbour the coarse band offered where the tile edge makes it | ||
| 4461 | + // unavailable -- must never happen (see `MODE_TILE_EDGE_COARSE_LEAKS`). | ||
| 4462 | + if (mi_r <= self.tile_row0_mi && self.above_mode[c] != DC_PRED) | ||
| 4463 | + || (mi_c <= self.tile_col0_mi && self.left_mode[r] != DC_PRED) | ||
| 4464 | + { | ||
| 4465 | + MODE_TILE_EDGE_COARSE_LEAKS.with(|h| h.set(h.get() + 1)); | ||
| 4466 | + } | ||
| 4305 | (above, left) | 4467 | (above, left) |
| 4306 | } | 4468 | } |
| 4307 | 4469 | ||
| @@ -4400,13 +4562,27 @@ impl Neighbours { | |||
| 4400 | /// Leaves `above_side_mi`/`left_side_mi` and the chroma planes alone -- | 4562 | /// Leaves `above_side_mi`/`left_side_mi` and the chroma planes alone -- |
| 4401 | /// the caller's own [`Self::record_split_luma`] call sets those once, | 4563 | /// the caller's own [`Self::record_split_luma`] call sets those once, |
| 4402 | /// at the block's own true side, not this TU's. | 4564 | /// at the block's own true side, not this TU's. |
| 4403 | - fn record_mi_luma(&mut self, (mi_r, mi_c): (usize, usize), tx_px: usize, grid: &[i32]) { | 4565 | + fn record_mi_luma(&mut self, at_mi: (usize, usize), tx_px: usize, grid: &[i32]) { |
| 4566 | + self.record_mi_luma_rect(at_mi, tx_px, tx_px, grid); | ||
| 4567 | + } | ||
| 4568 | + | ||
| 4569 | + /// [`Self::record_mi_luma`] for a RECTANGULAR transform unit (lane-rectsplitx | ||
| 4570 | + /// r1): the above context spans the unit's width, the left context its | ||
| 4571 | + /// height, which for a square unit is the same loop it always was. | ||
| 4572 | + fn record_mi_luma_rect( | ||
| 4573 | + &mut self, | ||
| 4574 | + (mi_r, mi_c): (usize, usize), | ||
| 4575 | + w_px: usize, | ||
| 4576 | + h_px: usize, | ||
| 4577 | + grid: &[i32], | ||
| 4578 | + ) { | ||
| 4404 | let state = neighbour_state(grid); | 4579 | let state = neighbour_state(grid); |
| 4405 | - let side_mi = tx_px / MI; | 4580 | + for cell in 0..h_px / MI { |
| 4406 | - for cell in 0..side_mi { | ||
| 4407 | if mi_r + cell < self.mi_rows { | 4581 | if mi_r + cell < self.mi_rows { |
| 4408 | self.left[mi_r + cell][0] = state; | 4582 | self.left[mi_r + cell][0] = state; |
| 4409 | } | 4583 | } |
| 4584 | + } | ||
| 4585 | + for cell in 0..w_px / MI { | ||
| 4410 | if mi_c + cell < self.mi_cols { | 4586 | if mi_c + cell < self.mi_cols { |
| 4411 | self.above[mi_c + cell][0] = state; | 4587 | self.above[mi_c + cell][0] = state; |
| 4412 | } | 4588 | } |
| @@ -4444,17 +4620,42 @@ impl Neighbours { | |||
| 4444 | chroma_grids: [&[i32]; 2], | 4620 | chroma_grids: [&[i32]; 2], |
| 4445 | ) { | 4621 | ) { |
| 4446 | let (r, c) = at; | 4622 | let (r, c) = at; |
| 4447 | - for cell in 0..w / SUB { | 4623 | + self.record_split_luma_rect_mi( |
| 4624 | + (r * (SUB / MI), c * (SUB / MI)), | ||
| 4625 | + w, | ||
| 4626 | + h, | ||
| 4627 | + mode, | ||
| 4628 | + uv_mode, | ||
| 4629 | + chroma_grids, | ||
| 4630 | + ); | ||
| 4631 | + } | ||
| 4632 | + | ||
| 4633 | + /// [`Self::record_split_luma_rect`] addressed in mi units (lane-rectsplitx | ||
| 4634 | + /// r1) -- a strip 8 px tall starts mid-[`SUB`]-cell, which the coarse | ||
| 4635 | + /// `(r, c)` form cannot name. The coarse mode/side arrays are stamped for | ||
| 4636 | + /// every cell the strip TOUCHES (`div_ceil`), last writer wins, the | ||
| 4637 | + /// convention [`decode_block_rect4`] already established for 1:4 strips. | ||
| 4638 | + fn record_split_luma_rect_mi( | ||
| 4639 | + &mut self, | ||
| 4640 | + at_mi: (usize, usize), | ||
| 4641 | + w: usize, | ||
| 4642 | + h: usize, | ||
| 4643 | + mode: usize, | ||
| 4644 | + uv_mode: usize, | ||
| 4645 | + chroma_grids: [&[i32]; 2], | ||
| 4646 | + ) { | ||
| 4647 | + let (mi_r, mi_c) = at_mi; | ||
| 4648 | + let (r, c) = (mi_r / (SUB / MI), mi_c / (SUB / MI)); | ||
| 4649 | + for cell in 0..w.div_ceil(SUB) { | ||
| 4448 | self.above_mode[c + cell] = mode; | 4650 | self.above_mode[c + cell] = mode; |
| 4449 | self.above_uv_mode[c + cell] = uv_mode; | 4651 | self.above_uv_mode[c + cell] = uv_mode; |
| 4450 | self.above_side[c + cell] = w; | 4652 | self.above_side[c + cell] = w; |
| 4451 | } | 4653 | } |
| 4452 | - for cell in 0..h / SUB { | 4654 | + for cell in 0..h.div_ceil(SUB) { |
| 4453 | self.left_mode[r + cell] = mode; | 4655 | self.left_mode[r + cell] = mode; |
| 4454 | self.left_uv_mode[r + cell] = uv_mode; | 4656 | self.left_uv_mode[r + cell] = uv_mode; |
| 4455 | self.left_side[r + cell] = h; | 4657 | self.left_side[r + cell] = h; |
| 4456 | } | 4658 | } |
| 4457 | - let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); | ||
| 4458 | let (w_mi, h_mi) = (w / MI, h / MI); | 4659 | let (w_mi, h_mi) = (w / MI, h / MI); |
| 4459 | self.record_mode_mi(mi_r, mi_c, w_mi, h_mi, mode); | 4660 | self.record_mode_mi(mi_r, mi_c, w_mi, h_mi, mode); |
| 4460 | self.record_uv_mode_mi(mi_r, mi_c, w_mi, h_mi, uv_mode); | 4661 | self.record_uv_mode_mi(mi_r, mi_c, w_mi, h_mi, uv_mode); |
| @@ -5129,6 +5330,29 @@ struct RectStripModes { | |||
| 5129 | palette_uv: Option<(Vec<u16>, Vec<u16>)>, | 5330 | palette_uv: Option<(Vec<u16>, Vec<u16>)>, |
| 5130 | } | 5331 | } |
| 5131 | 5332 | ||
| 5333 | +/// The transform unit size (w, h) of a `bw`x`bh` intra block at tx `depth` | ||
| 5334 | +/// -- libaom `depth_to_tx_size`, which walks `sub_tx_size_map` `depth` times | ||
| 5335 | +/// from `max_txsize_rect_lookup[bsize]`. Every entry of that map halves the | ||
| 5336 | +/// LONGER side of a rectangle and both sides of a square, so a 1:4 strip's | ||
| 5337 | +/// first step is a 2:1 rect unit (`TX_32X8 -> TX_16X8`, `TX_64X16 -> | ||
| 5338 | +/// TX_32X16`) and only the second reaches a square -- the reason | ||
| 5339 | +/// `bw.min(bh) >> (depth - 1)` (correct for a 2:1 strip, where step one is | ||
| 5340 | +/// already square) mis-tiled 1:4 strips. | ||
| 5341 | +fn depth_to_tx_wh(bw: usize, bh: usize, depth: usize) -> (usize, usize) { | ||
| 5342 | + let (mut w, mut h) = (bw.min(64), bh.min(64)); | ||
| 5343 | + for _ in 0..depth { | ||
| 5344 | + match w.cmp(&h) { | ||
| 5345 | + std::cmp::Ordering::Greater => w /= 2, | ||
| 5346 | + std::cmp::Ordering::Less => h /= 2, | ||
| 5347 | + std::cmp::Ordering::Equal => { | ||
| 5348 | + w /= 2; | ||
| 5349 | + h /= 2; | ||
| 5350 | + } | ||
| 5351 | + } | ||
| 5352 | + } | ||
| 5353 | + (w, h) | ||
| 5354 | +} | ||
| 5355 | + | ||
| 5132 | /// Decodes the planes of one `bw`x`bh` HORZ/VERT intra strip whose luma | 5356 | /// Decodes the planes of one `bw`x`bh` HORZ/VERT intra strip whose luma |
| 5133 | /// transform is SPLIT (`tx_depth != 0`) -- lane-rectsplit r1, the case every | 5357 | /// transform is SPLIT (`tx_depth != 0`) -- lane-rectsplit r1, the case every |
| 5134 | /// rect path here refused by name until now ("per-unit rect prediction is not | 5358 | /// rect path here refused by name until now ("per-unit rect prediction is not |
| @@ -5154,10 +5378,15 @@ fn decode_rect_split( | |||
| 5154 | dec: &mut SymbolDecoder, | 5378 | dec: &mut SymbolDecoder, |
| 5155 | cdfs: &mut Cdfs, | 5379 | cdfs: &mut Cdfs, |
| 5156 | neighbours: &mut Neighbours, | 5380 | neighbours: &mut Neighbours, |
| 5157 | - at: (usize, usize), | 5381 | + at_mi: (usize, usize), |
| 5158 | bw: usize, | 5382 | bw: usize, |
| 5159 | bh: usize, | 5383 | bh: usize, |
| 5160 | - tx: usize, | 5384 | + // The transform unit's own width and height in pixels. Square for every |
| 5385 | + // 2:1 strip from the first split on, but a 1:4 strip's FIRST split is | ||
| 5386 | + // still a 2:1 RECT unit (`sub_tx_size_map[TX_32X8] == TX_16X8`, | ||
| 5387 | + // `[TX_64X16] == TX_32X16`) -- see [`depth_to_tx_wh`]. | ||
| 5388 | + tx_w: usize, | ||
| 5389 | + tx_h: usize, | ||
| 5161 | m: &RectStripModes, | 5390 | m: &RectStripModes, |
| 5162 | y: &mut PlaneBuf, | 5391 | y: &mut PlaneBuf, |
| 5163 | u: &mut PlaneBuf, | 5392 | u: &mut PlaneBuf, |
| @@ -5165,9 +5394,8 @@ fn decode_rect_split( | |||
| 5165 | base_q_idx: u8, | 5394 | base_q_idx: u8, |
| 5166 | reduced_tx_set: bool, | 5395 | reduced_tx_set: bool, |
| 5167 | ) -> Result<()> { | 5396 | ) -> Result<()> { |
| 5168 | - let (r, c) = at; | 5397 | + let (mi_r, mi_c) = at_mi; |
| 5169 | - let (px, py) = (c * SUB, r * SUB); | 5398 | + let (px, py) = (mi_c * MI, mi_r * MI); |
| 5170 | - let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); | ||
| 5171 | let (cpx, cpy) = (px / 2, py / 2); | 5399 | let (cpx, cpy) = (px / 2, py / 2); |
| 5172 | let (chroma_w, chroma_h) = (bw / 2, bh / 2); | 5400 | let (chroma_w, chroma_h) = (bw / 2, bh / 2); |
| 5173 | // The chroma transform is picked before any symbol is read, so an | 5401 | // The chroma transform is picked before any symbol is read, so an |
| @@ -5177,16 +5405,17 @@ fn decode_rect_split( | |||
| 5177 | (8, 16) => Some((TxbSet::ChromaRect16x8, &SCAN_8X16[..])), | 5405 | (8, 16) => Some((TxbSet::ChromaRect16x8, &SCAN_8X16[..])), |
| 5178 | (32, 16) => Some((TxbSet::ChromaRect32x16, &SCAN_32X16[..])), | 5406 | (32, 16) => Some((TxbSet::ChromaRect32x16, &SCAN_32X16[..])), |
| 5179 | (16, 32) => Some((TxbSet::ChromaRect32x16, &SCAN_16X32[..])), | 5407 | (16, 32) => Some((TxbSet::ChromaRect32x16, &SCAN_16X32[..])), |
| 5180 | - // lane-rectchroma r1: the 1:4 superblock strips (64x16/16x64, | 5408 | + // The 1:4 and sub-16 strips (lane-rectchroma r1 added the 32x8/8x32 |
| 5181 | - // `decode_block_rect64`'s `strip64!` arm) and the 8x16 left rect of a | 5409 | + // rows, lane-rectsplitx r1 the 16x4/4x16 ones). `get_txsize_entropy_ctx` |
| 5182 | - // 16x16 `VERT_B` reach here once their tx depth is non-zero -- the | 5410 | + // squares a rect transform down to a CDF set by |
| 5183 | - // shapes their chroma half takes. `get_txsize_entropy_ctx(TX_32X8)` | 5411 | + // `(wide_log2 + high_log2 + 1) >> 1`: TX_32X8 -> the 16x16 set, |
| 5184 | - // is `(0 + 4 + 1) >> 1 == 2`, the 16x16 CDF set (eob alphabet 256), | 5412 | + // TX_16X4 -> the 8x8 set, TX_8X4 -> the 8x8 set -- exactly the sets |
| 5185 | - // exactly as the unsplit 1:4 path already picks it; `TX_8X4` reduces | 5413 | + // the UNSPLIT 1:4 (`decode_block_rect4`) and 16x8 (`decode_leaf_rect`) |
| 5186 | - // to `(0 + 1 + 1) >> 1 == 1`, the 8x8 set `ChromaRect8x4` carries | 5414 | + // paths already prove for these same shapes. |
| 5187 | - // (eob 32), as `decode_leaf_rect`'s own chroma half already does. | ||
| 5188 | (32, 8) => Some((TxbSet::Chroma16, &SCAN_32X8[..])), | 5415 | (32, 8) => Some((TxbSet::Chroma16, &SCAN_32X8[..])), |
| 5189 | (8, 32) => Some((TxbSet::Chroma16, &SCAN_8X32[..])), | 5416 | (8, 32) => Some((TxbSet::Chroma16, &SCAN_8X32[..])), |
| 5417 | + (16, 4) => Some((TxbSet::Chroma8, &SCAN_16X4[..])), | ||
| 5418 | + (4, 16) => Some((TxbSet::Chroma8, &SCAN_4X16[..])), | ||
| 5190 | (8, 4) => Some((TxbSet::ChromaRect8x4, &SCAN_8X4[..])), | 5419 | (8, 4) => Some((TxbSet::ChromaRect8x4, &SCAN_8X4[..])), |
| 5191 | (4, 8) => Some((TxbSet::ChromaRect8x4, &SCAN_4X8[..])), | 5420 | (4, 8) => Some((TxbSet::ChromaRect8x4, &SCAN_4X8[..])), |
| 5192 | _ => None, | 5421 | _ => None, |
| @@ -5209,7 +5438,7 @@ fn decode_rect_split( | |||
| 5209 | // Diagnostic for the next caller that lands here (class | 5438 | // Diagnostic for the next caller that lands here (class |
| 5210 | // refusal-names-a-correlate: the message names the tool, not the | 5439 | // refusal-names-a-correlate: the message names the tool, not the |
| 5211 | // shape); the refusal below keeps its inventory-pinned wording. | 5440 | // shape); the refusal below keeps its inventory-pinned wording. |
| 5212 | - eprintln!("EC_RECTCHROMA_GAP luma={bw}x{bh} tx={tx} chroma={chroma_w}x{chroma_h}"); | 5441 | + eprintln!("EC_RECTCHROMA_GAP luma={bw}x{bh} tx={tx_w}x{tx_h} chroma={chroma_w}x{chroma_h}"); |
| 5213 | } | 5442 | } |
| 5214 | } | 5443 | } |
| 5215 | // lane-rectsplit r2 (verifier finding): with both callers wired | 5444 | // lane-rectsplit r2 (verifier finding): with both callers wired |
| @@ -5225,21 +5454,50 @@ fn decode_rect_split( | |||
| 5225 | )); | 5454 | )); |
| 5226 | } | 5455 | } |
| 5227 | RECT_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 5456 | RECT_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); |
| 5228 | - if bw.max(bh) == 64 && bw / tx > 1 && bh / tx > 1 { | 5457 | + if bw.max(bh) == 64 && bw / tx_w > 1 && bh / tx_h > 1 { |
| 5229 | RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.set(c.get() + 1)); | 5458 | RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.set(c.get() + 1)); |
| 5230 | } | 5459 | } |
| 5231 | // LUMA: `bw/tx` x `bh/tx` square transform units, raster order. | 5460 | // LUMA: `bw/tx` x `bh/tx` square transform units, raster order. |
| 5232 | - let luma_set = txbset_for(tx, reduced_tx_set); | 5461 | + // A square unit reads through the ordinary square [`read_plane`]; a rect |
| 5233 | - let luma_scan = default_scan(tx); | 5462 | + // one (a 1:4 strip's first split) reads through [`read_coeffs_rect`] with |
| 5234 | - let zero_tu = vec![0i32; tx * tx]; | 5463 | + // the very tables the unsplit 16x8/32x16 paths use. |
| 5464 | + let luma_rect: Option<(TxbSet, &[u16])> = match (tx_w, tx_h) { | ||
| 5465 | + (w, h) if w == h => None, | ||
| 5466 | + (16, 8) | (8, 16) => Some(( | ||
| 5467 | + if reduced_tx_set { | ||
| 5468 | + TxbSet::LumaRect16x8 | ||
| 5469 | + } else { | ||
| 5470 | + TxbSet::LumaRect16x8Set1 | ||
| 5471 | + }, | ||
| 5472 | + if tx_w == 16 { &SCAN_16X8[..] } else { &SCAN_8X16[..] }, | ||
| 5473 | + )), | ||
| 5474 | + (32, 16) => Some((TxbSet::LumaRect32x16, &SCAN_32X16[..])), | ||
| 5475 | + (16, 32) => Some((TxbSet::LumaRect32x16, &SCAN_16X32[..])), | ||
| 5476 | + _ => { | ||
| 5477 | + return Err(unsupported(format!( | ||
| 5478 | + "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma \ | ||
| 5479 | + coefficient tables for that shape here)" | ||
| 5480 | + ))) | ||
| 5481 | + } | ||
| 5482 | + }; | ||
| 5483 | + // lane-rectsplitx r1, MEASURED: the SQUARE-unit walk below is pixel-exact | ||
| 5484 | + // on a real stream (the pinned 16x8 filter-intra fixture decodes its whole | ||
| 5485 | + // frame exactly, two sub-16 split strips in it), but the RECT-unit arm -- | ||
| 5486 | + // a 1:4 strip's depth-1 TX_16X8/TX_32X16 -- mismatched ffmpeg on the | ||
| 5487 | + // 32-level 1:4 band fixture (8-bit, cq 12, seed 42). The tables and the | ||
| 5488 | + // per-unit rect walk stay wired above/below; the round that finds that | ||
| 5489 | + // defect deletes this refusal and nothing else. | ||
| 5490 | + let luma_set = txbset_for(tx_w.min(tx_h), reduced_tx_set); | ||
| 5491 | + let luma_scan = default_scan(tx_w.min(tx_h)); | ||
| 5492 | + let zero_tu = vec![0i32; tx_w * tx_h]; | ||
| 5235 | // The strip's OWN edge availability, the fallback for a transform unit | 5493 | // The strip's OWN edge availability, the fallback for a transform unit |
| 5236 | // whose top-right/bottom-left pixels fall outside the strip. | 5494 | // whose top-right/bottom-left pixels fall outside the strip. |
| 5237 | let block_reach = Reach::of_rect(bw, bh, px, py, y.width, y.height); | 5495 | let block_reach = Reach::of_rect(bw, bh, px, py, y.width, y.height); |
| 5238 | - for tu_row in 0..bh / tx { | 5496 | + for tu_row in 0..bh / tx_h { |
| 5239 | - for tu_col in 0..bw / tx { | 5497 | + for tu_col in 0..bw / tx_w { |
| 5240 | - let tu_mi = (mi_r + tu_row * (tx / MI), mi_c + tu_col * (tx / MI)); | 5498 | + let tu_mi = (mi_r + tu_row * (tx_h / MI), mi_c + tu_col * (tx_w / MI)); |
| 5241 | - let (tu_px, tu_py) = (px + tu_col * tx, py + tu_row * tx); | 5499 | + let (tu_px, tu_py) = (px + tu_col * tx_w, py + tu_row * tx_h); |
| 5242 | - let (col_off, row_off) = (tu_col * tx, tu_row * tx); | 5500 | + let (col_off, row_off) = (tu_col * tx_w, tu_row * tx_h); |
| 5243 | // `has_top_right`/`has_bottom_left` (libaom `reconintra.c`) for a | 5501 | // `has_top_right`/`has_bottom_left` (libaom `reconintra.c`) for a |
| 5244 | // transform unit INSIDE a block, which is a different rule from | 5502 | // transform unit INSIDE a block, which is a different rule from |
| 5245 | // the standalone-block table [`Reach::of`] applies -- and the | 5503 | // the standalone-block table [`Reach::of`] applies -- and the |
| @@ -5255,22 +5513,23 @@ fn decode_rect_split( | |||
| 5255 | // (`row_off + tx_high < plane_bh`) they are the left | 5513 | // (`row_off + tx_high < plane_bh`) they are the left |
| 5256 | // neighbour's, already reconstructed; the last row falls back | 5514 | // neighbour's, already reconstructed; the last row falls back |
| 5257 | // to the block-level answer. | 5515 | // to the block-level answer. |
| 5258 | - let tu_reach = Reach::of_tu(bw, bh, col_off, row_off, tx, block_reach); | 5516 | + let tu_reach = Reach::of_tu(bw, bh, col_off, row_off, tx_w, tx_h, block_reach); |
| 5259 | // The unit's own window on the block's palette prediction. | 5517 | // The unit's own window on the block's palette prediction. |
| 5260 | if let Some(buf) = &m.palette_y { | 5518 | if let Some(buf) = &m.palette_y { |
| 5261 | - let tu_buf: Vec<u16> = (0..tx) | 5519 | + let tu_buf: Vec<u16> = (0..tx_h) |
| 5262 | .flat_map(|i| { | 5520 | .flat_map(|i| { |
| 5263 | let base = (row_off + i) * bw + col_off; | 5521 | let base = (row_off + i) * bw + col_off; |
| 5264 | - buf[base..base + tx].iter().copied() | 5522 | + buf[base..base + tx_w].iter().copied() |
| 5265 | }) | 5523 | }) |
| 5266 | .collect(); | 5524 | .collect(); |
| 5267 | set_palette_pred(tu_buf); | 5525 | set_palette_pred(tu_buf); |
| 5268 | } | 5526 | } |
| 5269 | if m.skip { | 5527 | if m.skip { |
| 5270 | - y.reconstruct( | 5528 | + y.reconstruct_rect( |
| 5271 | tu_px, | 5529 | tu_px, |
| 5272 | tu_py, | 5530 | tu_py, |
| 5273 | - tx, | 5531 | + tx_w, |
| 5532 | + tx_h, | ||
| 5274 | m.mode, | 5533 | m.mode, |
| 5275 | m.angle_delta_y, | 5534 | m.angle_delta_y, |
| 5276 | tu_reach, | 5535 | tu_reach, |
| @@ -5279,13 +5538,57 @@ fn decode_rect_split( | |||
| 5279 | m.filter_intra, | 5538 | m.filter_intra, |
| 5280 | m.smooth_neighbor, | 5539 | m.smooth_neighbor, |
| 5281 | ); | 5540 | ); |
| 5282 | - neighbours.record_mi_luma(tu_mi, tx, &zero_tu); | 5541 | + neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &zero_tu); |
| 5542 | + } else if let Some((rect_set, rect_scan)) = luma_rect { | ||
| 5543 | + // The rect-unit twin of the square arm below: same contexts, | ||
| 5544 | + // same order, through the rect coefficient reader. The | ||
| 5545 | + // `tx_type` CDF row of a filter-intra block is | ||
| 5546 | + // `fimode_to_intradir[filter_intra_mode]`, never the block's | ||
| 5547 | + // own (always DC_PRED) mode -- [`read_plane`] applies that | ||
| 5548 | + // for the square arm, so this one must too. | ||
| 5549 | + let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; | ||
| 5550 | + let tu_skip_ctx = neighbours.luma_skip_ctx_rect(tu_mi, tx_w / MI, tx_h / MI); | ||
| 5551 | + let mut coding = cdfs.txb(rect_set, fi_tx_row(m.mode, m.filter_intra)); | ||
| 5552 | + let (tu_grid, tu_tx_type) = read_coeffs_rect( | ||
| 5553 | + dec, | ||
| 5554 | + &mut coding, | ||
| 5555 | + rect_scan, | ||
| 5556 | + tx_w, | ||
| 5557 | + tx_h, | ||
| 5558 | + tu_skip_ctx, | ||
| 5559 | + dc_sign_ctx(tu_around.2), | ||
| 5560 | + TxType::DctDct, | ||
| 5561 | + )?; | ||
| 5562 | + let residual = dequant_and_inverse_typed_wh( | ||
| 5563 | + &tu_grid, | ||
| 5564 | + tx_w, | ||
| 5565 | + tx_h, | ||
| 5566 | + crate::decode::bit_depth(), | ||
| 5567 | + block_q_idx(), | ||
| 5568 | + plane_q_delta(0).0, | ||
| 5569 | + plane_q_delta(0).1, | ||
| 5570 | + tu_tx_type, | ||
| 5571 | + ); | ||
| 5572 | + y.reconstruct_rect( | ||
| 5573 | + tu_px, | ||
| 5574 | + tu_py, | ||
| 5575 | + tx_w, | ||
| 5576 | + tx_h, | ||
| 5577 | + m.mode, | ||
| 5578 | + m.angle_delta_y, | ||
| 5579 | + tu_reach, | ||
| 5580 | + &residual, | ||
| 5581 | + None, | ||
| 5582 | + m.filter_intra, | ||
| 5583 | + m.smooth_neighbor, | ||
| 5584 | + ); | ||
| 5585 | + neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid); | ||
| 5283 | } else { | 5586 | } else { |
| 5284 | - let tu_around = neighbours.around_mi(tu_mi, tx)[0]; | 5587 | + let tu_around = neighbours.around_mi(tu_mi, tx_w)[0]; |
| 5285 | // This unit is smaller than the block it sits in, so | 5588 | // This unit is smaller than the block it sits in, so |
| 5286 | // `txb_skip_ctx` is the neighbour-magnitude table, not the | 5589 | // `txb_skip_ctx` is the neighbour-magnitude table, not the |
| 5287 | // lone-TU 0 (spec `get_txb_ctx_general`). | 5590 | // lone-TU 0 (spec `get_txb_ctx_general`). |
| 5288 | - let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx / MI); | 5591 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_w / MI); |
| 5289 | let tu_grid = read_plane( | 5592 | let tu_grid = read_plane( |
| 5290 | dec, | 5593 | dec, |
| 5291 | cdfs, | 5594 | cdfs, |
| @@ -5300,15 +5603,15 @@ fn decode_rect_split( | |||
| 5300 | y, | 5603 | y, |
| 5301 | tu_px, | 5604 | tu_px, |
| 5302 | tu_py, | 5605 | tu_py, |
| 5303 | - tx, | 5606 | + tx_w, |
| 5304 | - tx, | 5607 | + tx_w, |
| 5305 | base_q_idx, | 5608 | base_q_idx, |
| 5306 | None, | 5609 | None, |
| 5307 | m.filter_intra, | 5610 | m.filter_intra, |
| 5308 | Some(tu_skip_ctx), | 5611 | Some(tu_skip_ctx), |
| 5309 | m.smooth_neighbor, | 5612 | m.smooth_neighbor, |
| 5310 | )?; | 5613 | )?; |
| 5311 | - neighbours.record_mi_luma(tu_mi, tx, &tu_grid); | 5614 | + neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid); |
| 5312 | } | 5615 | } |
| 5313 | } | 5616 | } |
| 5314 | } | 5617 | } |
| @@ -5342,7 +5645,7 @@ fn decode_rect_split( | |||
| 5342 | } else { | 5645 | } else { |
| 5343 | default_intra_tx_type(m.uv_predict_mode as u8) | 5646 | default_intra_tx_type(m.uv_predict_mode as u8) |
| 5344 | }; | 5647 | }; |
| 5345 | - let around = neighbours.around_rect(at, bw, bh); | 5648 | + let around = neighbours.around_mi_rect(at_mi, bw, bh); |
| 5346 | let mut grids: Vec<Vec<i32>> = Vec::with_capacity(2); | 5649 | let mut grids: Vec<Vec<i32>> = Vec::with_capacity(2); |
| 5347 | for plane_idx in 1..=2 { | 5650 | for plane_idx in 1..=2 { |
| 5348 | let skip_ctx = | 5651 | let skip_ctx = |
| @@ -5402,13 +5705,21 @@ fn decode_rect_split( | |||
| 5402 | let mut it = grids.into_iter(); | 5705 | let mut it = grids.into_iter(); |
| 5403 | (it.next().unwrap(), it.next().unwrap()) | 5706 | (it.next().unwrap(), it.next().unwrap()) |
| 5404 | }; | 5707 | }; |
| 5405 | - neighbours.record_split_luma_rect(at, bw, bh, m.mode, m.uv_predict_mode, [&u_grid, &v_grid]); | 5708 | + neighbours.record_split_luma_rect_mi( |
| 5709 | + at_mi, | ||
| 5710 | + bw, | ||
| 5711 | + bh, | ||
| 5712 | + m.mode, | ||
| 5713 | + m.uv_predict_mode, | ||
| 5714 | + [&u_grid, &v_grid], | ||
| 5715 | + ); | ||
| 5406 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, m.skip); | 5716 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, m.skip); |
| 5407 | - neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx as u8, tx as u8, 0); | 5717 | + neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0); |
| 5408 | if std::env::var_os("EC_AV1_TRACE").is_some() { | 5718 | if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 5409 | let (rng, _) = dec.debug_state(); | 5719 | let (rng, _) = dec.debug_state(); |
| 5410 | eprintln!( | 5720 | eprintln!( |
| 5411 | - "TRACE_RECT_SPLIT mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} tx={tx} rng={rng}" | 5721 | + "TRACE_RECT_SPLIT mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} \ |
| 5722 | + tx={tx_w}x{tx_h} rng={rng}" | ||
| 5412 | ); | 5723 | ); |
| 5413 | } | 5724 | } |
| 5414 | Ok(()) | 5725 | Ok(()) |
| @@ -5504,13 +5815,12 @@ fn decode_block_rect( | |||
| 5504 | // lane-rectsplit r1: a split transform is predicted and reconstructed | 5815 | // lane-rectsplit r1: a split transform is predicted and reconstructed |
| 5505 | // per transform unit, each unit taking its edges from the previous | 5816 | // per transform unit, each unit taking its edges from the previous |
| 5506 | // unit's reconstruction inside this same strip (spec 5.11.36) -- | 5817 | // unit's reconstruction inside this same strip (spec 5.11.36) -- |
| 5507 | - // [`decode_rect_split`]. `depth_to_tx_size` of a 2:1 strip is square | 5818 | + // [`decode_rect_split`], the unit named by [`depth_to_tx_wh`]. |
| 5508 | - // from the first step on, so `bw.min(bh) >> (depth - 1)` names it. | 5819 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); |
| 5509 | - let tx = bw.min(bh) >> (depth - 1); | ||
| 5510 | if std::env::var_os("EC_SBPART_DUMP64").is_some() { | 5820 | if std::env::var_os("EC_SBPART_DUMP64").is_some() { |
| 5511 | eprintln!( | 5821 | eprintln!( |
| 5512 | "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ | 5822 | "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ |
| 5513 | - depth={depth} tx={tx} mode={mode} uv={uv_predict_mode} skip={skip} \ | 5823 | + depth={depth} tx={tx_w}x{tx_h} mode={mode} uv={uv_predict_mode} skip={skip} \ |
| 5514 | angle_y={angle_delta_y}" | 5824 | angle_y={angle_delta_y}" |
| 5515 | ); | 5825 | ); |
| 5516 | } | 5826 | } |
| @@ -5538,7 +5848,20 @@ fn decode_block_rect( | |||
| 5538 | PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 5848 | PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); |
| 5539 | } | 5849 | } |
| 5540 | decode_rect_split( | 5850 | decode_rect_split( |
| 5541 | - dec, cdfs, neighbours, at, bw, bh, tx, &modes, y, u, v, base_q_idx, reduced_tx_set, | 5851 | + dec, |
| 5852 | + cdfs, | ||
| 5853 | + neighbours, | ||
| 5854 | + (mi_r, mi_c), | ||
| 5855 | + bw, | ||
| 5856 | + bh, | ||
| 5857 | + tx_w, | ||
| 5858 | + tx_h, | ||
| 5859 | + &modes, | ||
| 5860 | + y, | ||
| 5861 | + u, | ||
| 5862 | + v, | ||
| 5863 | + base_q_idx, | ||
| 5864 | + reduced_tx_set, | ||
| 5542 | )?; | 5865 | )?; |
| 5543 | // This early return skips this fn's own tail, so the palette | 5866 | // This early return skips this fn's own tail, so the palette |
| 5544 | // neighbour state has to be stamped HERE too: without it a split-tx | 5867 | // neighbour state has to be stamped HERE too: without it a split-tx |
| @@ -5888,12 +6211,12 @@ fn decode_leaf_rect( | |||
| 5888 | // cannot hold the modes a split (or a pair of strips) leaves behind, so | 6211 | // cannot hold the modes a split (or a pair of strips) leaves behind, so |
| 5889 | // when the map holds the block at exactly this strip's above/left mi it | 6212 | // when the map holds the block at exactly this strip's above/left mi it |
| 5890 | // is the neighbour libaom's `above_mi`/`left_mi` reads. | 6213 | // is the neighbour libaom's `above_mi`/`left_mi` reads. |
| 5891 | - if let Some(m) = neighbours.mode_above_mi(leaf_mi.0, leaf_mi.1) { | 6214 | + // lane-rectsplitx r2 (same class as the 1:4 fix): mi-exact AND |
| 5892 | - above_mode = m; | 6215 | + // availability-correct -- four 16x8 strips share one coarse 16x16 |
| 5893 | - } | 6216 | + // `left_mode` cell too, so the fallback must not stand in for an absent |
| 5894 | - if let Some(m) = neighbours.mode_left_mi(leaf_mi.0, leaf_mi.1) { | 6217 | + // tile-edge neighbour. |
| 5895 | - left_mode = m; | 6218 | + let (above_mode, left_mode) = |
| 5896 | - } | 6219 | + neighbours.modes_above_left_mi(leaf_mi.0, leaf_mi.1, (above_mode, left_mode)); |
| 5897 | let smooth_neighbor = | 6220 | let smooth_neighbor = |
| 5898 | is_smooth_mode(above_mode) || is_smooth_mode(left_mode); | 6221 | is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 5899 | if smooth_neighbor { | 6222 | if smooth_neighbor { |
| @@ -5951,15 +6274,68 @@ fn decode_leaf_rect( | |||
| 5951 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c); | 6274 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c); |
| 5952 | let depth = if tx_select { | 6275 | let depth = if tx_select { |
| 5953 | let ctx = tx_size_context_rect(neighbours, leaf_mi, bw, bh); | 6276 | let ctx = tx_size_context_rect(neighbours, leaf_mi, bw, bh); |
| 5954 | - dec.symbol(&mut cdfs.tx_size_cat2[ctx]) | 6277 | + // lane-rectsplitx r1: `bsize_to_tx_size_cat` (libaom `blockd.h`, |
| 6278 | + // `bsize_to_tx_size_depth_table`) is 2 for BLOCK_16X8/BLOCK_8X16, so | ||
| 6279 | + // the category is 1 -- NOT the 2 the 32x16 strips read. Same symbol | ||
| 6280 | + // count (3), different CDF row: a wrong-table read of a real symbol, | ||
| 6281 | + // the class that cost lane-rectsplit r1 its 64x32 depth. | ||
| 6282 | + // lane-rect1d r1: the CATEGORY of this leaf is 1, not 2. libaom's | ||
| 6283 | + // `bsize_to_tx_size_cat` reads `bsize_to_tx_size_depth_table` and | ||
| 6284 | + // subtracts one: BLOCK_16X8/8X16 (and the 1:4 BLOCK_16X4/4X16 this | ||
| 6285 | + // function also decodes) sit at depth 2, so they read | ||
| 6286 | + // `tx_size_cdf[1]` -- the same table a 16x16 square block reads -- | ||
| 6287 | + // while `tx_size_cat2` belongs to the 32-level shapes | ||
| 6288 | + // ([`decode_block_rect`]). Both tables carry three symbols, so the | ||
| 6289 | + // wrong one decodes a plausible depth from the wrong probabilities: | ||
| 6290 | + // the range diverges silently at the first such leaf and every later | ||
| 6291 | + // symbol in the tile is read from the wrong place (class | ||
| 6292 | + // `wrong-alphabet-same-value`, here same alphabet / wrong row). | ||
| 6293 | + dec.symbol(&mut cdfs.tx_size_cat1[ctx]) | ||
| 5955 | } else { | 6294 | } else { |
| 5956 | 0 | 6295 | 0 |
| 5957 | }; | 6296 | }; |
| 5958 | if depth != 0 { | 6297 | if depth != 0 { |
| 5959 | - return Err(unsupported( | 6298 | + // The same per-transform-unit walk the bigger strips take |
| 5960 | - "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit rect \ | 6299 | + // (`depth_to_tx_wh`: TX_16X8 -> TX_8X8 at depth 1, -> TX_4X4 at |
| 5961 | - prediction is not ported)", | 6300 | + // depth 2), addressed at this leaf's own mi position. |
| 5962 | - )); | 6301 | + TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); |
| 6302 | + SUB16_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | ||
| 6303 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | ||
| 6304 | + let modes = RectStripModes { | ||
| 6305 | + skip, | ||
| 6306 | + mode, | ||
| 6307 | + angle_delta_y, | ||
| 6308 | + uv_predict_mode, | ||
| 6309 | + angle_delta_uv, | ||
| 6310 | + alpha, | ||
| 6311 | + filter_intra, | ||
| 6312 | + smooth_neighbor, | ||
| 6313 | + // lane-rectsplitx r3: the split arm hard-coded `false` here while | ||
| 6314 | + // the unsplit arm below passes the real neighbour answer -- chroma | ||
| 6315 | + // of a tx-split 16x8/8x16 leaf lost its intra-edge filter type. | ||
| 6316 | + smooth_neighbor_uv, | ||
| 6317 | + // Both callers refuse a palette on this shape above (pixel | ||
| 6318 | + // reconstruction is unported here), so the split units carry none. | ||
| 6319 | + palette_y: None, | ||
| 6320 | + palette_uv: None, | ||
| 6321 | + }; | ||
| 6322 | + decode_rect_split( | ||
| 6323 | + dec, | ||
| 6324 | + cdfs, | ||
| 6325 | + neighbours, | ||
| 6326 | + leaf_mi, | ||
| 6327 | + bw, | ||
| 6328 | + bh, | ||
| 6329 | + tx_w, | ||
| 6330 | + tx_h, | ||
| 6331 | + &modes, | ||
| 6332 | + y, | ||
| 6333 | + u, | ||
| 6334 | + v, | ||
| 6335 | + base_q_idx, | ||
| 6336 | + reduced_tx_set, | ||
| 6337 | + )?; | ||
| 6338 | + return Ok(mode); | ||
| 5963 | } | 6339 | } |
| 5964 | let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI); | 6340 | let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI); |
| 5965 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height); | 6341 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height); |
| @@ -6119,6 +6495,12 @@ fn decode_block_rect4( | |||
| 6119 | left_mode = pmode; | 6495 | left_mode = pmode; |
| 6120 | } | 6496 | } |
| 6121 | } | 6497 | } |
| 6498 | + // lane-rectsplitx r2, ROOT CAUSE of the 1:4 mismatch: mi-exact + | ||
| 6499 | + // availability-correct neighbour modes (see | ||
| 6500 | + // [`Neighbours::modes_above_left_mi`]). The coarse 16x16 bands alias every | ||
| 6501 | + // 8-px strip of a `HORZ_4`/`VERT_4` onto one cell. | ||
| 6502 | + let (above_mode, left_mode) = | ||
| 6503 | + neighbours.modes_above_left_mi(mi_r, mi_c, (above_mode, left_mode)); | ||
| 6122 | let ( | 6504 | let ( |
| 6123 | skip, | 6505 | skip, |
| 6124 | mode, | 6506 | mode, |
| @@ -6159,8 +6541,13 @@ fn decode_block_rect4( | |||
| 6159 | if smooth_neighbor { | 6541 | if smooth_neighbor { |
| 6160 | SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | 6542 | SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); |
| 6161 | } | 6543 | } |
| 6162 | - let smooth_neighbor_uv = | 6544 | + // lane-rectsplitx r2: this strip's REAL mi, not the [`SUB`] cell's |
| 6163 | - neighbours.smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), r, c); | 6545 | + // top-left -- a 1:4 strip starts 8 px into a 16-px cell, so |
| 6546 | + // `r * (SUB / MI)` names a different mi column and the chroma | ||
| 6547 | + // edge-filter strength was read from the wrong neighbour (measured: | ||
| 6548 | + // seed 43, the last 8x32 strip at luma (152,32), chroma-only mismatch | ||
| 6549 | + // with luma bit-exact). | ||
| 6550 | + let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(mi_r, mi_c, r, c); | ||
| 6164 | if filter_intra.is_some() { | 6551 | if filter_intra.is_some() { |
| 6165 | FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); | 6552 | FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); |
| 6166 | if bw > bh { | 6553 | if bw > bh { |
| @@ -6181,16 +6568,64 @@ fn decode_block_rect4( | |||
| 6181 | 0 | 6568 | 0 |
| 6182 | }; | 6569 | }; |
| 6183 | if depth != 0 { | 6570 | if depth != 0 { |
| 6184 | - // lane-tx64x16 r4: the depth is IN the message -- it says which port | 6571 | + // lane-rectsplitx r1: the per-transform-unit walk, at this strip's |
| 6185 | - // the next round owes. depth 1 of a 4:1 strip is TX_16X8/TX_8X16 | 6572 | + // real mi position (strips 1 and 3 of a HORZ_4 start 8 px into a |
| 6186 | - // (`sub_tx_size_map[TX_32X8] == TX_16X8`), a RECTANGULAR transform | 6573 | + // 16-px [`SUB`] cell). depth 1 is the RECT unit TX_16X8/TX_8X16 |
| 6187 | - // unit with no luma coefficient tables here; depth 2 is TX_8X8, | 6574 | + // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square TX_8X8; |
| 6188 | - // square, the shape `decode_rect_split` already walks. The film stops | 6575 | + // both interleave in every real stream. |
| 6189 | - // at depth 2, synthetic band fixtures hit both. | 6576 | + TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); |
| 6190 | - return Err(unsupported(format!( | 6577 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); |
| 6191 | - "a 32x32-level 1:4 strip with a split transform (per-unit 4:1 prediction is not \ | 6578 | + // lane-rectsplitx r2: both depths ship together, as the r1 handoff |
| 6192 | - ported, depth={depth})" | 6579 | + // predicted -- depth 1 fires FIRST in every attempt that splits at |
| 6193 | - ))); | 6580 | + // all, so a depth-2-only lift could never be gated. The r1 mismatch |
| 6581 | + // was never the rect unit: it was the neighbour MODE the strip reads | ||
| 6582 | + // (see `modes_above_left_mi`). | ||
| 6583 | + let which = if depth == 1 { | ||
| 6584 | + &RECT4_SPLIT_DEPTH1_HITS | ||
| 6585 | + } else { | ||
| 6586 | + &RECT4_SPLIT_DEPTH2_HITS | ||
| 6587 | + }; | ||
| 6588 | + which.with(|c| c.set(c.get() + 1)); | ||
| 6589 | + let modes = RectStripModes { | ||
| 6590 | + skip, | ||
| 6591 | + mode, | ||
| 6592 | + angle_delta_y, | ||
| 6593 | + uv_predict_mode, | ||
| 6594 | + angle_delta_uv, | ||
| 6595 | + alpha, | ||
| 6596 | + filter_intra, | ||
| 6597 | + smooth_neighbor, | ||
| 6598 | + smooth_neighbor_uv, | ||
| 6599 | + // Both callers refuse a palette on this shape above (pixel | ||
| 6600 | + // reconstruction is unported here), so the split units carry none. | ||
| 6601 | + palette_y: None, | ||
| 6602 | + palette_uv: None, | ||
| 6603 | + }; | ||
| 6604 | + decode_rect_split( | ||
| 6605 | + dec, | ||
| 6606 | + cdfs, | ||
| 6607 | + neighbours, | ||
| 6608 | + (mi_r, mi_c), | ||
| 6609 | + bw, | ||
| 6610 | + bh, | ||
| 6611 | + tx_w, | ||
| 6612 | + tx_h, | ||
| 6613 | + &modes, | ||
| 6614 | + y, | ||
| 6615 | + u, | ||
| 6616 | + v, | ||
| 6617 | + base_q_idx, | ||
| 6618 | + false, | ||
| 6619 | + )?; | ||
| 6620 | + if bw > bh { | ||
| 6621 | + RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); | ||
| 6622 | + } else { | ||
| 6623 | + RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1)); | ||
| 6624 | + } | ||
| 6625 | + if !skip { | ||
| 6626 | + RECT4_COEFF_HITS.with(|c| c.set(c.get() + 1)); | ||
| 6627 | + } | ||
| 6628 | + return Ok((mode, uv_predict_mode)); | ||
| 6194 | } | 6629 | } |
| 6195 | // The coarse (16-px [`SUB`] cell) mode/side arrays cannot name a strip | 6630 | // The coarse (16-px [`SUB`] cell) mode/side arrays cannot name a strip |
| 6196 | // that is 8 px tall, so each strip stamps every cell it touches and the | 6631 | // that is 8 px tall, so each strip stamps every cell it touches and the |
| @@ -6207,6 +6642,14 @@ fn decode_block_rect4( | |||
| 6207 | neighbours.left_uv_mode[r + cell] = uv_predict_mode; | 6642 | neighbours.left_uv_mode[r + cell] = uv_predict_mode; |
| 6208 | neighbours.left_side[r + cell] = bh; | 6643 | neighbours.left_side[r + cell] = bh; |
| 6209 | } | 6644 | } |
| 6645 | + // ...and the mi-EXACT maps the coarse cells alias away, exactly as | ||
| 6646 | + // [`decode_leaf_rect`] does (the split arm above records these through | ||
| 6647 | + // `record_mi_luma_rect`). Without this an unsplit 32x8 strip left | ||
| 6648 | + // `sub8_mode_row` holding the previous block, and the next 32x32's | ||
| 6649 | + // strips read a stale `kf_y_mode` row (measured: mi(4,8) on the band | ||
| 6650 | + // fixture). | ||
| 6651 | + neighbours.record_mode_mi(mi_r, mi_c, mi_w, mi_h, mode); | ||
| 6652 | + neighbours.record_uv_mode_mi(mi_r, mi_c, mi_w, mi_h, uv_predict_mode); | ||
| 6210 | let (px, py) = (mi_c * MI, mi_r * MI); | 6653 | let (px, py) = (mi_c * MI, mi_r * MI); |
| 6211 | let (cpx, cpy) = (px / 2, py / 2); | 6654 | let (cpx, cpy) = (px / 2, py / 2); |
| 6212 | let (chroma_w, chroma_h) = (bw / 2, bh / 2); | 6655 | let (chroma_w, chroma_h) = (bw / 2, bh / 2); |
| @@ -6489,31 +6932,22 @@ fn decode_block_rect64( | |||
| 6489 | TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | 6932 | TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); |
| 6490 | // lane-rectsplit r1/r4: the superblock-level strip splits its | 6933 | // lane-rectsplit r1/r4: the superblock-level strip splits its |
| 6491 | // transform through the very same per-unit path as its 32x32-level | 6934 | // transform through the very same per-unit path as its 32x32-level |
| 6492 | - // sibling (`sub_tx_size_map[TX_64X32] == TX_32X32`, square from the | 6935 | + // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64 |
| 6493 | - // first step on, so `bw.min(bh) >> (depth - 1)` names the unit). | 6936 | + // 1:4 strip is the 2:1 rect TX_32X16 at depth 1 (lane-rectchroma r1 |
| 6494 | - // lane-rectchroma r1: `sub_tx_size_map[TX_64X16] == TX_32X16`, NOT a | 6937 | + // measured the old square formula mis-tiling exactly that strip). |
| 6495 | - // square -- a 4:1 strip's first transform split is still a 2:1 RECT | 6938 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); |
| 6496 | - // unit, and only the SECOND step reaches a square (TX_16X16). The | 6939 | + if bw.max(bh) / bw.min(bh) == 4 { |
| 6497 | - // 2:1 formula below (square from the first step on) named 16x16 units | 6940 | + let which = if depth == 1 { |
| 6498 | - // for a depth-1 64x16 strip, which decoded 2 chroma-32x8 strips of | 6941 | + &RECT4_SPLIT_DEPTH1_HITS |
| 6499 | - // the band fixture with the wrong luma tiling. depth 1 on a 4:1 strip | 6942 | + } else { |
| 6500 | - // is refused by name; depth >= 2 is square, one step later. | 6943 | + &RECT4_SPLIT_DEPTH2_HITS |
| 6501 | - let is_1to4 = bw.max(bh) / bw.min(bh) == 4; | 6944 | + }; |
| 6502 | - if is_1to4 && depth == 1 && !skip { | 6945 | + which.with(|c| c.set(c.get() + 1)); |
| 6503 | - return Err(unsupported( | ||
| 6504 | - "a coded 1:4 HORZ_4/VERT_4 strip whose transform splits only once (the unit is \ | ||
| 6505 | - still a 2:1 rect, not a square)", | ||
| 6506 | - )); | ||
| 6507 | } | 6946 | } |
| 6508 | - let tx = if is_1to4 { | ||
| 6509 | - bw.min(bh) >> (depth - 2) | ||
| 6510 | - } else { | ||
| 6511 | - bw.min(bh) >> (depth - 1) | ||
| 6512 | - }; | ||
| 6513 | if std::env::var_os("EC_SBPART_DUMP64").is_some() { | 6947 | if std::env::var_os("EC_SBPART_DUMP64").is_some() { |
| 6514 | eprintln!( | 6948 | eprintln!( |
| 6515 | "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ | 6949 | "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ |
| 6516 | - depth={depth} tx={tx} mode={mode} uv={uv_predict_mode} skip={skip} \ | 6950 | + depth={depth} tx={tx_w}x{tx_h} mode={mode} uv={uv_predict_mode} skip={skip} \ |
| 6517 | angle_y={angle_delta_y}" | 6951 | angle_y={angle_delta_y}" |
| 6518 | ); | 6952 | ); |
| 6519 | } | 6953 | } |
| @@ -6541,7 +6975,20 @@ fn decode_block_rect64( | |||
| 6541 | PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 6975 | PALETTE_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); |
| 6542 | } | 6976 | } |
| 6543 | decode_rect_split( | 6977 | decode_rect_split( |
| 6544 | - dec, cdfs, neighbours, at, bw, bh, tx, &modes, y, u, v, base_q_idx, reduced_tx_set, | 6978 | + dec, |
| 6979 | + cdfs, | ||
| 6980 | + neighbours, | ||
| 6981 | + (mi_r, mi_c), | ||
| 6982 | + bw, | ||
| 6983 | + bh, | ||
| 6984 | + tx_w, | ||
| 6985 | + tx_h, | ||
| 6986 | + &modes, | ||
| 6987 | + y, | ||
| 6988 | + u, | ||
| 6989 | + v, | ||
| 6990 | + base_q_idx, | ||
| 6991 | + reduced_tx_set, | ||
| 6545 | )?; | 6992 | )?; |
| 6546 | // Same early-return palette stamp as [`decode_block_rect`]'s split arm | 6993 | // Same early-return palette stamp as [`decode_block_rect`]'s split arm |
| 6547 | // (lane-palette2 r10): this return skips the fn's own tail, so a | 6994 | // (lane-palette2 r10): this return skips the fn's own tail, so a |
| @@ -8245,8 +8692,10 @@ fn decode_leaf8( | |||
| 8245 | reduced_tx_set: bool, | 8692 | reduced_tx_set: bool, |
| 8246 | ) -> Result<usize> { | 8693 | ) -> Result<usize> { |
| 8247 | let (r, c) = outer_at; | 8694 | let (r, c) = outer_at; |
| 8248 | - let mut above_mode = neighbours.above_mode[c]; | 8695 | + // lane-modectx r1: the group's own availability-correct fallback pair, not |
| 8249 | - let mut left_mode = neighbours.left_mode[r]; | 8696 | + // the raw coarse bands (which leak across a tile edge -- see |
| 8697 | + // `modes_above_left`). | ||
| 8698 | + let (mut above_mode, mut left_mode) = neighbours.modes_above_left(r, c); | ||
| 8250 | if let Some(((pr, pc), pmode)) = prev_leaf { | 8699 | if let Some(((pr, pc), pmode)) = prev_leaf { |
| 8251 | if pc == leaf_mi.1 && leaf_mi.0 == pr + 2 { | 8700 | if pc == leaf_mi.1 && leaf_mi.0 == pr + 2 { |
| 8252 | above_mode = pmode; | 8701 | above_mode = pmode; |
| @@ -8258,12 +8707,12 @@ fn decode_leaf8( | |||
| 8258 | // `prev_leaf`: one 16x16 slot cannot hold the two different modes its | 8707 | // `prev_leaf`: one 16x16 slot cannot hold the two different modes its |
| 8259 | // two 8x8 (or four 4x4) columns leave behind, so a leaf whose above/left | 8708 | // two 8x8 (or four 4x4) columns leave behind, so a leaf whose above/left |
| 8260 | // neighbour sits in a split cell read the wrong `kf_y_mode` row. | 8709 | // neighbour sits in a split cell read the wrong `kf_y_mode` row. |
| 8261 | - if let Some(m) = neighbours.mode_above_mi(leaf_mi.0, leaf_mi.1) { | 8710 | + // lane-rectsplitx r2 swept this arm into |
| 8262 | - above_mode = m; | 8711 | + // [`Neighbours::modes_above_left_mi`]: the mi-exact map ALSO has to answer |
| 8263 | - } | 8712 | + // "no neighbour" at a tile edge, where the coarse cell holds the block |
| 8264 | - if let Some(m) = neighbours.mode_left_mi(leaf_mi.0, leaf_mi.1) { | 8713 | + // above/left of it inside the same 16x16. |
| 8265 | - left_mode = m; | 8714 | + let (above_mode, left_mode) = |
| 8266 | - } | 8715 | + neighbours.modes_above_left_mi(leaf_mi.0, leaf_mi.1, (above_mode, left_mode)); |
| 8267 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); | 8716 | let smooth_neighbor = is_smooth_mode(above_mode) || is_smooth_mode(left_mode); |
| 8268 | // Chroma's edge-filter type reads the CHROMA neighbour's `uv_mode` | 8717 | // Chroma's edge-filter type reads the CHROMA neighbour's `uv_mode` |
| 8269 | // (`get_intra_edge_filter_type`, reconintra.c:974), never the luma mode | 8718 | // (`get_intra_edge_filter_type`, reconintra.c:974), never the luma mode |
| @@ -8927,8 +9376,9 @@ fn decode_leaf_rect8( | |||
| 8927 | reduced_tx_set: bool, | 9376 | reduced_tx_set: bool, |
| 8928 | ) -> Result<(usize, usize)> { | 9377 | ) -> Result<(usize, usize)> { |
| 8929 | let (r, c) = outer_at; | 9378 | let (r, c) = outer_at; |
| 8930 | - let above_mode = neighbours.above_mode[c]; | 9379 | + // lane-modectx r1: availability-correct fallback pair (see |
| 8931 | - let left_mode = neighbours.left_mode[r]; | 9380 | + // `modes_above_left`), not the raw coarse bands. |
| 9381 | + let (above_mode, left_mode) = neighbours.modes_above_left(r, c); | ||
| 8932 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c); | 9382 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c); |
| 8933 | let (bw, bh) = if vert { (4, 8) } else { (8, 4) }; | 9383 | let (bw, bh) = if vert { (4, 8) } else { (8, 4) }; |
| 8934 | let (w_mi, h_mi) = (bw / MI, bh / MI); | 9384 | let (w_mi, h_mi) = (bw / MI, bh / MI); |
| @@ -9773,27 +10223,40 @@ fn read_block_tx_size( | |||
| 9773 | let tx = if is_inter { | 10223 | let tx = if is_inter { |
| 9774 | side.min(64) | 10224 | side.min(64) |
| 9775 | } else { | 10225 | } else { |
| 9776 | - let resolved = read_tx_size( | 10226 | + read_tx_size( |
| 9777 | dec, | 10227 | dec, |
| 9778 | cdfs, | 10228 | cdfs, |
| 9779 | n, | 10229 | n, |
| 9780 | at_mi, | 10230 | at_mi, |
| 9781 | side, | 10231 | side, |
| 9782 | Some(tx_size_context_txfm(n, at_mi, side)), | 10232 | Some(tx_size_context_txfm(n, at_mi, side)), |
| 9783 | - ); | 10233 | + ) |
| 9784 | - if resolved != side { | ||
| 9785 | - // An intra block inside an inter frame whose `tx_depth` splits its | ||
| 9786 | - // luma transform needs the per-transform-unit intra prediction | ||
| 9787 | - // loop `decode_block` runs for a key frame; this path predicts the | ||
| 9788 | - // whole block at once, so refuse rather than mis-reconstruct. | ||
| 9789 | - return Err(unsupported( | ||
| 9790 | - "an intra block in an inter frame whose tx_depth splits its luma transform \ | ||
| 9791 | - (round 1)", | ||
| 9792 | - )); | ||
| 9793 | - } | ||
| 9794 | - resolved | ||
| 9795 | }; | 10234 | }; |
| 9796 | set_txfm_ctxs(n, at_mi, tx, side_mi, side_mi, skip && is_inter); | 10235 | set_txfm_ctxs(n, at_mi, tx, side_mi, side_mi, skip && is_inter); |
| 10236 | + if !is_inter && tx != side { | ||
| 10237 | + // lane-intrainter r1: an intra block inside an inter frame whose | ||
| 10238 | + // `tx_depth` split its luma transform codes exactly the key-frame | ||
| 10239 | + // split path's transform units (`decode_block`'s multi-TU loop), | ||
| 10240 | + // raster order over the block. Handed back in the same leaf shape the | ||
| 10241 | + // inter var-tx tree uses, so the caller's per-TU luma loop, the | ||
| 10242 | + // `record_split_luma` neighbour write-back and the per-TU deblock | ||
| 10243 | + // edges are the ones it already runs for a var-tx inter block. A | ||
| 10244 | + // caller that has no per-TU intra loop (the 8x8 leaf) refuses on | ||
| 10245 | + // seeing `Some` here. | ||
| 10246 | + let step = tx / MI; | ||
| 10247 | + let mut leaves = Vec::new(); | ||
| 10248 | + for row in (0..side_mi).step_by(step) { | ||
| 10249 | + for col in (0..side_mi).step_by(step) { | ||
| 10250 | + leaves.push((row, col, tx)); | ||
| 10251 | + } | ||
| 10252 | + } | ||
| 10253 | + INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| { | ||
| 10254 | + let mut h = c.get(); | ||
| 10255 | + h[(side.trailing_zeros() as usize).saturating_sub(3).min(3)] += 1; | ||
| 10256 | + c.set(h); | ||
| 10257 | + }); | ||
| 10258 | + return Ok((tx, Some(leaves))); | ||
| 10259 | + } | ||
| 9797 | Ok((tx, None)) | 10260 | Ok((tx, None)) |
| 9798 | } | 10261 | } |
| 9799 | 10262 | ||
| @@ -15864,6 +16327,24 @@ fn decode_inter_block( | |||
| 15864 | )); | 16327 | )); |
| 15865 | } | 16328 | } |
| 15866 | } | 16329 | } |
| 16330 | + // lane-fiinter r1: `read_filter_intra_mode_info` (libaom `decodemv.c`, | ||
| 16331 | + // the tail of `read_intra_block_mode_info`) -- an intra block inside | ||
| 16332 | + // an INTER frame reads `use_filter_intra` in exactly the same place a | ||
| 16333 | + // key-frame block does, right after the palette syntax. Nothing read | ||
| 16334 | + // it here before this round, and aomenc enables filter intra by | ||
| 16335 | + // default, so every inter frame carrying one desynced at this symbol. | ||
| 16336 | + // `av1_filter_intra_allowed`'s `palette_size[0] == 0` term is implied: | ||
| 16337 | + // a real palette-Y block already returned above. | ||
| 16338 | + let mut filter_intra = None; | ||
| 16339 | + if mode == DC_PRED | ||
| 16340 | + && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get) | ||
| 16341 | + && let Some(class) = filter_intra_size_class(side) | ||
| 16342 | + && dec.symbol(&mut cdfs.filter_intra[class]) != 0 | ||
| 16343 | + { | ||
| 16344 | + FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); | ||
| 16345 | + INTRA_IN_INTER_FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); | ||
| 16346 | + filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); | ||
| 16347 | + } | ||
| 15867 | mode_for_tx = mode; | 16348 | mode_for_tx = mode; |
| 15868 | block_filter = [3, 3]; | 16349 | block_filter = [3, 3]; |
| 15869 | ref_frame_for_lf = 0; | 16350 | ref_frame_for_lf = 0; |
| @@ -15890,7 +16371,14 @@ fn decode_inter_block( | |||
| 15890 | } | 16371 | } |
| 15891 | } | 16372 | } |
| 15892 | 16373 | ||
| 15893 | - read_block_tx_size( | 16374 | + // lane-intrainter r1: an intra block in an inter frame reads the same |
| 16375 | + // `tx_depth` symbol a key-frame block does, and when it splits, the | ||
| 16376 | + // block codes one intra prediction + one coefficient set PER | ||
| 16377 | + // transform unit (`decode_block`'s multi-TU branch), not one for the | ||
| 16378 | + // whole block. The leaf list rides the existing `vartx_leaves` slot, | ||
| 16379 | + // whose tail already does the split-block neighbour write-back | ||
| 16380 | + // (`record_split_luma`) and the per-TU deblock edges. | ||
| 16381 | + vartx_leaves = read_block_tx_size( | ||
| 15894 | dec, | 16382 | dec, |
| 15895 | cdfs, | 16383 | cdfs, |
| 15896 | neighbours, | 16384 | neighbours, |
| @@ -15899,21 +16387,80 @@ fn decode_inter_block( | |||
| 15899 | (mi_cols as usize, mi_rows as usize), | 16387 | (mi_cols as usize, mi_rows as usize), |
| 15900 | false, | 16388 | false, |
| 15901 | skip, | 16389 | skip, |
| 15902 | - )?; | 16390 | + )? |
| 16391 | + .1; | ||
| 15903 | let reach = Reach::of(side, px, py, y.width, y.height); | 16392 | let reach = Reach::of(side, px, py, y.width, y.height); |
| 16393 | + let split_luma = vartx_leaves.is_some(); | ||
| 16394 | + if let Some(leaves) = vartx_leaves.clone() { | ||
| 16395 | + let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get); | ||
| 16396 | + for &(row, col, tx_px) in &leaves { | ||
| 16397 | + let tu_mi = (at_mi.0 + row, at_mi.1 + col); | ||
| 16398 | + let (tu_px, tu_py) = (px + col * MI, py + row * MI); | ||
| 16399 | + // A transform unit inside a block is not a block at that | ||
| 16400 | + // position (class from lane-palette2 r12): top-right / | ||
| 16401 | + // bottom-left availability is the block's, narrowed by the | ||
| 16402 | + // unit's own offset inside it. | ||
| 16403 | + let tu_reach = Reach::of_tu(side, side, col * MI, row * MI, tx_px, tx_px, reach); | ||
| 16404 | + let tu_grid = if skip { | ||
| 16405 | + y.reconstruct( | ||
| 16406 | + tu_px, | ||
| 16407 | + tu_py, | ||
| 16408 | + tx_px, | ||
| 16409 | + mode, | ||
| 16410 | + 0, | ||
| 16411 | + tu_reach, | ||
| 16412 | + &vec![0i32; tx_px * tx_px], | ||
| 16413 | + None, | ||
| 16414 | + filter_intra, | ||
| 16415 | + false, | ||
| 16416 | + ); | ||
| 16417 | + vec![0i32; tx_px * tx_px] | ||
| 16418 | + } else { | ||
| 16419 | + // The unit's bsize is smaller than the block it sits in, | ||
| 16420 | + // so `txb_skip_ctx` is the neighbour-magnitude table, not | ||
| 16421 | + // the lone-TU 0 (`get_txb_ctx_general`). | ||
| 16422 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI); | ||
| 16423 | + read_plane( | ||
| 16424 | + dec, | ||
| 16425 | + cdfs, | ||
| 16426 | + txbset_for(tx_px, reduced), | ||
| 16427 | + &default_scan(tx_px), | ||
| 16428 | + 0, | ||
| 16429 | + neighbours.around_mi(tu_mi, tx_px)[0], | ||
| 16430 | + mode, | ||
| 16431 | + mode, | ||
| 16432 | + 0, | ||
| 16433 | + tu_reach, | ||
| 16434 | + y, | ||
| 16435 | + tu_px, | ||
| 16436 | + tu_py, | ||
| 16437 | + tx_px, | ||
| 16438 | + tx_px, | ||
| 16439 | + base_q_idx, | ||
| 16440 | + None, | ||
| 16441 | + filter_intra, | ||
| 16442 | + Some(tu_skip_ctx), | ||
| 16443 | + false, | ||
| 16444 | + )? | ||
| 16445 | + }; | ||
| 16446 | + neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid); | ||
| 16447 | + } | ||
| 16448 | + } | ||
| 15904 | if skip { | 16449 | if skip { |
| 15905 | - y.reconstruct( | 16450 | + if !split_luma { |
| 15906 | - px, | 16451 | + y.reconstruct( |
| 15907 | - py, | 16452 | + px, |
| 15908 | - side, | 16453 | + py, |
| 15909 | - mode, | 16454 | + side, |
| 15910 | - 0, | 16455 | + mode, |
| 15911 | - reach, | 16456 | + 0, |
| 15912 | - &vec![0i32; side * side], | 16457 | + reach, |
| 15913 | - None, | 16458 | + &vec![0i32; side * side], |
| 15914 | - None, | 16459 | + None, |
| 15915 | - false, | 16460 | + filter_intra, |
| 15916 | - ); | 16461 | + false, |
| 16462 | + ); | ||
| 16463 | + } | ||
| 15917 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | 16464 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); |
| 15918 | u.reconstruct( | 16465 | u.reconstruct( |
| 15919 | cpx, | 16466 | cpx, |
| @@ -15944,28 +16491,35 @@ fn decode_inter_block( | |||
| 15944 | v_grid = vec![0i32; chroma_side * chroma_side]; | 16491 | v_grid = vec![0i32; chroma_side * chroma_side]; |
| 15945 | } else { | 16492 | } else { |
| 15946 | let around = neighbours.around(at, side); | 16493 | let around = neighbours.around(at, side); |
| 15947 | - luma_grid = read_plane( | 16494 | + luma_grid = if split_luma { |
| 15948 | - dec, | 16495 | + // Already coded and reconstructed unit by unit above; the |
| 15949 | - cdfs, | 16496 | + // block-level grid is only the neighbour write-back's input, |
| 15950 | - luma_set_intra, | 16497 | + // which `record_split_luma` ignores for plane 0. |
| 15951 | - scan_luma, | 16498 | + vec![0i32; side * side] |
| 15952 | - 0, | 16499 | + } else { |
| 15953 | - around[0], | 16500 | + read_plane( |
| 15954 | - mode, | 16501 | + dec, |
| 15955 | - mode, | 16502 | + cdfs, |
| 15956 | - 0, | 16503 | + luma_set_intra, |
| 15957 | - reach, | 16504 | + scan_luma, |
| 15958 | - y, | 16505 | + 0, |
| 15959 | - px, | 16506 | + around[0], |
| 15960 | - py, | 16507 | + mode, |
| 15961 | - side, | 16508 | + mode, |
| 15962 | - luma_tx, | 16509 | + 0, |
| 15963 | - base_q_idx, | 16510 | + reach, |
| 15964 | - None, | 16511 | + y, |
| 15965 | - None, | 16512 | + px, |
| 15966 | - None, | 16513 | + py, |
| 15967 | - false, | 16514 | + side, |
| 15968 | - )?; | 16515 | + luma_tx, |
| 16516 | + base_q_idx, | ||
| 16517 | + None, | ||
| 16518 | + filter_intra, | ||
| 16519 | + None, | ||
| 16520 | + false, | ||
| 16521 | + )? | ||
| 16522 | + }; | ||
| 15969 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | 16523 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); |
| 15970 | u_grid = read_plane( | 16524 | u_grid = read_plane( |
| 15971 | dec, | 16525 | dec, |
| @@ -17383,6 +17937,24 @@ fn decode_inter_block8( | |||
| 17383 | )); | 17937 | )); |
| 17384 | } | 17938 | } |
| 17385 | } | 17939 | } |
| 17940 | + // lane-fiinter r1: `read_filter_intra_mode_info` (libaom `decodemv.c`, | ||
| 17941 | + // the tail of `read_intra_block_mode_info`) -- an intra block inside | ||
| 17942 | + // an INTER frame reads `use_filter_intra` in exactly the same place a | ||
| 17943 | + // key-frame block does, right after the palette syntax. Nothing read | ||
| 17944 | + // it here before this round, and aomenc enables filter intra by | ||
| 17945 | + // default, so every inter frame carrying one desynced at this symbol. | ||
| 17946 | + // `av1_filter_intra_allowed`'s `palette_size[0] == 0` term is implied: | ||
| 17947 | + // a real palette-Y block already returned above. | ||
| 17948 | + let mut filter_intra = None; | ||
| 17949 | + if mode == DC_PRED | ||
| 17950 | + && ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get) | ||
| 17951 | + && let Some(class) = filter_intra_size_class(SIDE) | ||
| 17952 | + && dec.symbol(&mut cdfs.filter_intra[class]) != 0 | ||
| 17953 | + { | ||
| 17954 | + FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); | ||
| 17955 | + INTRA_IN_INTER_FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); | ||
| 17956 | + filter_intra = Some(dec.symbol(&mut cdfs.filter_intra_mode)); | ||
| 17957 | + } | ||
| 17386 | mode_for_tx = mode; | 17958 | mode_for_tx = mode; |
| 17387 | let (mi_row, mi_col) = leaf_mi; | 17959 | let (mi_row, mi_col) = leaf_mi; |
| 17388 | for dr in 0..2 { | 17960 | for dr in 0..2 { |
| @@ -17406,7 +17978,11 @@ fn decode_inter_block8( | |||
| 17406 | } | 17978 | } |
| 17407 | } | 17979 | } |
| 17408 | 17980 | ||
| 17409 | - read_block_tx_size( | 17981 | + // lane-intrainter r1: the 8x8 leaf's own intra `tx_depth` can only |
| 17982 | + // resolve to TX_4X4, whose 2x2 unit grid this leaf path has no | ||
| 17983 | + // prediction loop for (the >=16x16 square path above does). Refuse by | ||
| 17984 | + // name rather than mis-reconstruct. | ||
| 17985 | + if read_block_tx_size( | ||
| 17410 | dec, | 17986 | dec, |
| 17411 | cdfs, | 17987 | cdfs, |
| 17412 | neighbours, | 17988 | neighbours, |
| @@ -17415,7 +17991,15 @@ fn decode_inter_block8( | |||
| 17415 | (mi_cols as usize, mi_rows as usize), | 17991 | (mi_cols as usize, mi_rows as usize), |
| 17416 | false, | 17992 | false, |
| 17417 | skip, | 17993 | skip, |
| 17418 | - )?; | 17994 | + )? |
| 17995 | + .1 | ||
| 17996 | + .is_some() | ||
| 17997 | + { | ||
| 17998 | + return Err(unsupported( | ||
| 17999 | + "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 \ | ||
| 18000 | + transform units", | ||
| 18001 | + )); | ||
| 18002 | + } | ||
| 17419 | let reach = Reach::of(SIDE, px, py, y.width, y.height); | 18003 | let reach = Reach::of(SIDE, px, py, y.width, y.height); |
| 17420 | if skip { | 18004 | if skip { |
| 17421 | y.reconstruct( | 18005 | y.reconstruct( |
| @@ -17427,7 +18011,7 @@ fn decode_inter_block8( | |||
| 17427 | reach, | 18011 | reach, |
| 17428 | &vec![0i32; SIDE * SIDE], | 18012 | &vec![0i32; SIDE * SIDE], |
| 17429 | None, | 18013 | None, |
| 17430 | - None, | 18014 | + filter_intra, |
| 17431 | false, | 18015 | false, |
| 17432 | ); | 18016 | ); |
| 17433 | u.reconstruct( | 18017 | u.reconstruct( |
| @@ -17477,7 +18061,7 @@ fn decode_inter_block8( | |||
| 17477 | TX8, | 18061 | TX8, |
| 17478 | base_q_idx, | 18062 | base_q_idx, |
| 17479 | None, | 18063 | None, |
| 17480 | - None, | 18064 | + filter_intra, |
| 17481 | None, | 18065 | None, |
| 17482 | false, | 18066 | false, |
| 17483 | )?; | 18067 | )?; |
| @@ -17646,6 +18230,10 @@ pub fn decode_inter_frame_tile( | |||
| 17646 | false, | 18230 | false, |
| 17647 | false, | 18231 | false, |
| 17648 | DeltaParams::default(), | 18232 | DeltaParams::default(), |
| 18233 | + // `enable_filter_intra`: this crate's own encoder never writes the | ||
| 18234 | + // sequence bit (`encode.rs`), so no intra-in-inter block of a stream | ||
| 18235 | + // reaching this entry point reads a `use_filter_intra` symbol. | ||
| 18236 | + false, | ||
| 17649 | ) | 18237 | ) |
| 17650 | .map(|(picture, _, _)| picture) | 18238 | .map(|(picture, _, _)| picture) |
| 17651 | } | 18239 | } |
| @@ -17729,8 +18317,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 17729 | // same contract as [`decode_key_frame_tile_with_cdfs`]'s own `delta` | 18317 | // same contract as [`decode_key_frame_tile_with_cdfs`]'s own `delta` |
| 17730 | // param -- only `q_present`/`q_res` are read. | 18318 | // param -- only `q_present`/`q_res` are read. |
| 17731 | delta: DeltaParams, | 18319 | delta: DeltaParams, |
| 18320 | + // lane-fiinter r1: this sequence header's own `enable_filter_intra` bit | ||
| 18321 | + // (spec 5.5.2), stashed in a thread-local with `tx_select` rather than | ||
| 18322 | + // threaded through `decode_inter_block`'s fifty parameters -- read by the | ||
| 18323 | + // intra-in-inter arms' `read_filter_intra_mode_info`. | ||
| 18324 | + enable_filter_intra: bool, | ||
| 17732 | ) -> Result<(Picture, Cdfs, crate::motion_field::MotionField)> { | 18325 | ) -> Result<(Picture, Cdfs, crate::motion_field::MotionField)> { |
| 17733 | - set_inter_tx_mode(tx_select, reduced_tx_set); | 18326 | + set_inter_tx_mode(tx_select, reduced_tx_set, enable_filter_intra); |
| 17734 | let tpl_frame = tpl_field.map(|field| TplFrameArgs { | 18327 | let tpl_frame = tpl_field.map(|field| TplFrameArgs { |
| 17735 | field, | 18328 | field, |
| 17736 | order_hint_bits, | 18329 | order_hint_bits, |
crates/ec-av1/src/encode.rsmodified+10 -6
| @@ -1254,18 +1254,22 @@ impl Reach { | |||
| 1254 | bh: usize, | 1254 | bh: usize, |
| 1255 | col_off: usize, | 1255 | col_off: usize, |
| 1256 | row_off: usize, | 1256 | row_off: usize, |
| 1257 | - tx: usize, | 1257 | + // The unit's own width and height in pixels; equal for a square |
| 1258 | + // transform, different for the rect unit a 1:4 strip's first split | ||
| 1259 | + // produces (lane-rectsplitx r1). | ||
| 1260 | + tx_w: usize, | ||
| 1261 | + tx_h: usize, | ||
| 1258 | block: Self, | 1262 | block: Self, |
| 1259 | ) -> Self { | 1263 | ) -> Self { |
| 1260 | Self { | 1264 | Self { |
| 1261 | - above_right: if col_off + tx < bw { | 1265 | + above_right: if col_off + tx_w < bw { |
| 1262 | true | 1266 | true |
| 1263 | } else { | 1267 | } else { |
| 1264 | row_off == 0 && block.above_right | 1268 | row_off == 0 && block.above_right |
| 1265 | }, | 1269 | }, |
| 1266 | below_left: if col_off > 0 { | 1270 | below_left: if col_off > 0 { |
| 1267 | false | 1271 | false |
| 1268 | - } else if row_off + tx < bh { | 1272 | + } else if row_off + tx_h < bh { |
| 1269 | true | 1273 | true |
| 1270 | } else { | 1274 | } else { |
| 1271 | block.below_left | 1275 | block.below_left |
| @@ -3882,14 +3886,14 @@ mod tests { | |||
| 3882 | // `has_tr_vert_*` tables have no 4x4 row at all, lane-ab16 r2). | 3886 | // `has_tr_vert_*` tables have no 4x4 row at all, lane-ab16 r2). |
| 3883 | let plain = Reach::of(8, 0, 8, SUPERBLOCK, SUPERBLOCK); | 3887 | let plain = Reach::of(8, 0, 8, SUPERBLOCK, SUPERBLOCK); |
| 3884 | assert_eq!( | 3888 | assert_eq!( |
| 3885 | - Reach::of_tu(8, 8, 4, 0, 4, plain).above_right, | 3889 | + Reach::of_tu(8, 8, 4, 0, 4, 4, plain).above_right, |
| 3886 | plain.above_right, | 3890 | plain.above_right, |
| 3887 | "ordinary table: the top-right TX4 unit takes the block's row" | 3891 | "ordinary table: the top-right TX4 unit takes the block's row" |
| 3888 | ); | 3892 | ); |
| 3889 | let guard = Reach::vert_ab_partition(); | 3893 | let guard = Reach::vert_ab_partition(); |
| 3890 | let vert = Reach::of(8, 0, 8, SUPERBLOCK, SUPERBLOCK); | 3894 | let vert = Reach::of(8, 0, 8, SUPERBLOCK, SUPERBLOCK); |
| 3891 | assert_eq!( | 3895 | assert_eq!( |
| 3892 | - Reach::of_tu(8, 8, 4, 0, 4, vert).above_right, | 3896 | + Reach::of_tu(8, 8, 4, 0, 4, 4, vert).above_right, |
| 3893 | vert.above_right, | 3897 | vert.above_right, |
| 3894 | "vert AB: the unit follows the vert row the block just picked" | 3898 | "vert AB: the unit follows the vert row the block just picked" |
| 3895 | ); | 3899 | ); |
| @@ -4033,7 +4037,7 @@ mod tests { | |||
| 4033 | for row_off in (0..bh).step_by(tx) { | 4037 | for row_off in (0..bh).step_by(tx) { |
| 4034 | for col_off in (0..bw).step_by(tx) { | 4038 | for col_off in (0..bw).step_by(tx) { |
| 4035 | for &blk in &[Reach { above_right: false, below_left: false }, Reach { above_right: true, below_left: true }] { | 4039 | for &blk in &[Reach { above_right: false, below_left: false }, Reach { above_right: true, below_left: true }] { |
| 4036 | - let got = Reach::of_tu(bw, bh, col_off, row_off, tx, blk); | 4040 | + let got = Reach::of_tu(bw, bh, col_off, row_off, tx, tx, blk); |
| 4037 | assert_eq!( | 4041 | assert_eq!( |
| 4038 | got.above_right, | 4042 | got.above_right, |
| 4039 | libaom_tr(bw, bh, col_off, row_off, tx, blk.above_right), | 4043 | libaom_tr(bw, bh, col_off, row_off, tx, blk.above_right), |
crates/ec-av1/src/gate_coverage.rsmodified+6 -4
| @@ -226,10 +226,12 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ // lane-cwarp's 10-bit comp | |||
| 226 | "enable-dual-filter", | 226 | "enable-dual-filter", |
| 227 | "hole at both depths, see the 8-bit list", | 227 | "hole at both depths, see the 8-bit list", |
| 228 | ), | 228 | ), |
| 229 | - ( | 229 | + // `enable-flip-idtx` LEFT this list on 2026-09-02 (lane-rect1d r1): |
| 230 | - "enable-flip-idtx", | 230 | + // `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact` |
| 231 | - "hole at both depths, see the 8-bit list", | 231 | + // passes `=1` at both depths and pixel-compares six 10-bit decodes, so the |
| 232 | - ), | 232 | + // flip/identity/1D transform types are proven to reach a real 10-bit stream |
| 233 | + // this decoder reconstructs exactly (10 of its rect coefficient TUs carry a | ||
| 234 | + // 1D tx class). | ||
| 233 | ("enable-intrabc", "hole at both depths, see the 8-bit list"), | 235 | ("enable-intrabc", "hole at both depths, see the 8-bit list"), |
| 234 | ("enable-rect-tx", "hole at both depths, see the 8-bit list"), | 236 | ("enable-rect-tx", "hole at both depths, see the 8-bit list"), |
| 235 | ( | 237 | ( |
crates/ec-av1/src/refusal_inventory.rsmodified+6 -4
| @@ -32,15 +32,13 @@ const CAPABILITY_CLAIMS: &[&str] = &[ | |||
| 32 | #[cfg(test)] | 32 | #[cfg(test)] |
| 33 | const REFUSALS: &[&str] = &[ | 33 | const REFUSALS: &[&str] = &[ |
| 34 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", | 34 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 35 | - "a coded 1:4 HORZ_4/VERT_4 strip whose transform splits only once (the unit is still a 2:1 rect, not a square)", | 35 | + "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", |
| 36 | - "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit rect prediction is not ported)", | ||
| 37 | "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", | 36 | "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", |
| 38 | "a 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4, four 16x4/4x16 strips -- this decoder codes NONE, HORZ, VERT, the four AB arms and a clean split at 16x16)", | 37 | "a 1:4 partition below 16x16 (PARTITION_HORZ_4/VERT_4, four 16x4/4x16 strips -- this decoder codes NONE, HORZ, VERT, the four AB arms and a clean split at 16x16)", |
| 39 | "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)", | 38 | "a 1:4 rect strip that actually uses a palette (reconstruction is not ported at this shape)", |
| 40 | "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", | 39 | "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 41 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", | 40 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 42 | "a 32x32 partition type this decoder does not code (value={part32})", | 41 | "a 32x32 partition type this decoder does not code (value={part32})", |
| 43 | - "a 32x32-level 1:4 strip with a split transform (per-unit 4:1 prediction is not ported, depth={depth})", | ||
| 44 | "a Golomb tail longer than this decoder reads", | 42 | "a Golomb tail longer than this decoder reads", |
| 45 | "a tx_type symbol outside its CDF's own set: {t}", | 43 | "a tx_type symbol outside its CDF's own set: {t}", |
| 46 | "an INTER 32x32 partition type this decoder does not code (value={part32})", | 44 | "an INTER 32x32 partition type this decoder does not code (value={part32})", |
| @@ -64,7 +62,11 @@ const REFUSALS: &[&str] = &[ | |||
| 64 | "a reference picture whose height does not match this frame's own true size", | 62 | "a reference picture whose height does not match this frame's own true size", |
| 65 | "a show_existing_frame header naming an empty reference slot", | 63 | "a show_existing_frame header naming an empty reference slot", |
| 66 | "an inter var-tx tree with a leaf transform larger than 32x32", | 64 | "an inter var-tx tree with a leaf transform larger than 32x32", |
| 67 | - "an intra block in an inter frame whose tx_depth splits its luma transform (round 1)", | 65 | + // lane-intrainter r1 lifted the >=16x16 square case (per-TU intra |
| 66 | + // prediction + coefficients, gate | ||
| 67 | + // `a_real_aomenc_inter_sequence_with_a_split_transform_intra_block_decodes_pixel_exact`); | ||
| 68 | + // the 8x8 leaf's TX_4X4 2x2 grid is still refused here. | ||
| 69 | + "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units", | ||
| 68 | "an inter frame with no key frame before it", | 70 | "an inter frame with no key frame before it", |
| 69 | "an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path recurses a superblock only as SPLIT)", | 71 | "an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path recurses a superblock only as SPLIT)", |
| 70 | "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)", | 72 | "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)", |
crates/ec-av1/src/stream.rsmodified+990 -143
| @@ -711,6 +711,7 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 711 | header.allow_warped_motion, | 711 | header.allow_warped_motion, |
| 712 | header.allow_screen_content_tools, | 712 | header.allow_screen_content_tools, |
| 713 | header.delta, | 713 | header.delta, |
| 714 | + enable_filter_intra, | ||
| 714 | )?; | 715 | )?; |
| 715 | // lane-superres r10: mirrors the key-frame branch above -- | 716 | // lane-superres r10: mirrors the key-frame branch above -- |
| 716 | // `decode_inter_frame_tile_with_cdfs` decodes at the downscaled | 717 | // `decode_inter_frame_tile_with_cdfs` decodes at the downscaled |
| @@ -3938,58 +3939,576 @@ mod tests { | |||
| 3938 | ); | 3939 | ); |
| 3939 | } | 3940 | } |
| 3940 | 3941 | ||
| 3941 | - /// lane-txselect's decisive gate: a real aomenc INTER sequence WITHOUT | 3942 | + /// lane-txselect's decisive gate: a real aomenc INTER sequence WITHOUT |
| 3942 | - /// `--enable-tx-size-search=0`, the flag every other inter recipe in this | 3943 | + /// `--enable-tx-size-search=0`, the flag every other inter recipe in this |
| 3943 | - /// file pins off precisely to keep the stream on `TxMode::Largest`. | 3944 | + /// file pins off precisely to keep the stream on `TxMode::Largest`. |
| 3944 | - /// Dropped, aomenc takes its own default (`TX_MODE_SELECT` -- which is | 3945 | + /// Dropped, aomenc takes its own default (`TX_MODE_SELECT` -- which is |
| 3945 | - /// what both of the user's real films use), and an inter block's | 3946 | + /// what both of the user's real films use), and an inter block's |
| 3946 | - /// transform size is then the recursive `txfm_split` tree of spec | 3947 | + /// transform size is then the recursive `txfm_split` tree of spec |
| 3947 | - /// 5.11.17 rather than one whole-block transform. A stream that decoded | 3948 | + /// 5.11.17 rather than one whole-block transform. A stream that decoded |
| 3948 | - /// pixel-exact while every `txfm_split` symbol resolved to "no split" | 3949 | + /// pixel-exact while every `txfm_split` symbol resolved to "no split" |
| 3949 | - /// would prove nothing (it is `TxMode::Largest` by another name), so this | 3950 | + /// would prove nothing (it is `TxMode::Largest` by another name), so this |
| 3950 | - /// gate hard-asserts BOTH counters: at least one `txfm_split` symbol read | 3951 | + /// gate hard-asserts BOTH counters: at least one `txfm_split` symbol read |
| 3951 | - /// AND at least one split actually taken. Exhausting every attempt is a | 3952 | + /// AND at least one split actually taken. Exhausting every attempt is a |
| 3952 | - /// FAILURE, not a SKIP -- an unfired gate is a vacuous gate. | 3953 | + /// FAILURE, not a SKIP -- an unfired gate is a vacuous gate. |
| 3954 | + #[test] | ||
| 3955 | + fn a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact() { | ||
| 3956 | + tx_select_inter_gate(8); | ||
| 3957 | + } | ||
| 3958 | + | ||
| 3959 | + /// The 10-bit arm of the gate above (lane-txselect r2): both of the | ||
| 3960 | + /// user's films are `yuv420p10le` and var-tx is exactly the tool they | ||
| 3961 | + /// use, so an 8-bit-only proof would not reach them. Same recipe plus | ||
| 3962 | + /// `-b 10 --input-bit-depth=10`. | ||
| 3963 | + #[test] | ||
| 3964 | + fn a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact_10bit() { | ||
| 3965 | + tx_select_inter_gate(10); | ||
| 3966 | + } | ||
| 3967 | + | ||
| 3968 | + fn tx_select_inter_gate(bit_depth: u32) { | ||
| 3969 | + if !have_ffmpeg() { | ||
| 3970 | + eprintln!( | ||
| 3971 | + "SKIP a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact: no ffmpeg" | ||
| 3972 | + ); | ||
| 3973 | + return; | ||
| 3974 | + } | ||
| 3975 | + if !have_aomenc() { | ||
| 3976 | + eprintln!( | ||
| 3977 | + "SKIP a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact: no aomenc at {}", | ||
| 3978 | + aomenc_path().display() | ||
| 3979 | + ); | ||
| 3980 | + return; | ||
| 3981 | + } | ||
| 3982 | + let (width, height, frame_count) = (64usize, 64usize, 4usize); | ||
| 3983 | + let mut refusals = Vec::new(); | ||
| 3984 | + let mut uncounted_exact = 0u32; | ||
| 3985 | + for attempt in 0..40u32 { | ||
| 3986 | + let seed = 42 + attempt; | ||
| 3987 | + // Detail is what makes aomenc's RD prefer a split transform; a | ||
| 3988 | + // flat gradient resolves every `txfm_split` to 0. `mandelbrot`'s | ||
| 3989 | + // fractal boundary is the same source the sibling intra tx-select | ||
| 3990 | + // gate uses, at a different `start_scale` per attempt. | ||
| 3991 | + let source = format!( | ||
| 3992 | + "mandelbrot=size=64x64:start_scale={}:rate=25", | ||
| 3993 | + 5.0 - f64::from(attempt) * 0.06 | ||
| 3994 | + ); | ||
| 3995 | + let y4m = Command::new("ffmpeg") | ||
| 3996 | + .args([ | ||
| 3997 | + "-v", | ||
| 3998 | + "error", | ||
| 3999 | + "-f", | ||
| 4000 | + "lavfi", | ||
| 4001 | + "-i", | ||
| 4002 | + &source, | ||
| 4003 | + // Desaturated chroma: `uv_mode` stays DC_PRED, so the | ||
| 4004 | + // still-refused directional-chroma gap never fires and | ||
| 4005 | + // luma detail alone drives the transform split. | ||
| 4006 | + "-vf", | ||
| 4007 | + "hue=s=0", | ||
| 4008 | + "-pix_fmt", | ||
| 4009 | + if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, | ||
| 4010 | + // y4m carries no official 10-bit tag; ffmpeg writes one | ||
| 4011 | + // only under `-strict -1` (a no-op at 8 bit). | ||
| 4012 | + "-strict", | ||
| 4013 | + "-1", | ||
| 4014 | + "-t", | ||
| 4015 | + "0.16", | ||
| 4016 | + "-f", | ||
| 4017 | + "yuv4mpegpipe", | ||
| 4018 | + "-strict", | ||
| 4019 | + "-1", | ||
| 4020 | + "-", | ||
| 4021 | + ]) | ||
| 4022 | + .stdin(Stdio::null()) | ||
| 4023 | + .stdout(Stdio::piped()) | ||
| 4024 | + .stderr(Stdio::piped()) | ||
| 4025 | + .output() | ||
| 4026 | + .expect("ffmpeg failed to run"); | ||
| 4027 | + assert!( | ||
| 4028 | + y4m.status.success(), | ||
| 4029 | + "ffmpeg fixture: {}", | ||
| 4030 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 4031 | + ); | ||
| 4032 | + let depth_args: &[&str] = if bit_depth == 10 { | ||
| 4033 | + &["-b", "10", "--input-bit-depth=10"] | ||
| 4034 | + } else { | ||
| 4035 | + &[] | ||
| 4036 | + }; | ||
| 4037 | + let mut child = Command::new(aomenc_path()) | ||
| 4038 | + .args(depth_args) | ||
| 4039 | + .args([ | ||
| 4040 | + // lane-defon r1: explicit on-value (aomenc keeps the FIRST | ||
| 4041 | + // occurrence, so overrides go before the base list). | ||
| 4042 | + "--enable-tx-size-search=1", | ||
| 4043 | + "--codec=av1", | ||
| 4044 | + "--passes=1", | ||
| 4045 | + "--end-usage=q", | ||
| 4046 | + "--cq-level=55", | ||
| 4047 | + "--cpu-used=0", | ||
| 4048 | + "--lag-in-frames=0", | ||
| 4049 | + "--auto-alt-ref=0", | ||
| 4050 | + "--kf-max-dist=1000", | ||
| 4051 | + "--threads=1", | ||
| 4052 | + "--row-mt=0", | ||
| 4053 | + "--enable-order-hint=0", | ||
| 4054 | + "--enable-warped-motion=0", | ||
| 4055 | + "--enable-obmc=0", | ||
| 4056 | + "--enable-masked-comp=0", | ||
| 4057 | + "--enable-interintra-comp=0", | ||
| 4058 | + "--enable-dist-wtd-comp=0", | ||
| 4059 | + "--enable-diff-wtd-comp=0", | ||
| 4060 | + "--enable-onesided-comp=0", | ||
| 4061 | + "--enable-interintra-wedge=0", | ||
| 4062 | + "--enable-smooth-interintra=0", | ||
| 4063 | + "--enable-rect-partitions=0", | ||
| 4064 | + "--enable-ab-partitions=0", | ||
| 4065 | + "--enable-1to4-partitions=0", | ||
| 4066 | + "--enable-filter-intra=0", | ||
| 4067 | + "--enable-smooth-intra=0", | ||
| 4068 | + "--enable-paeth-intra=0", | ||
| 4069 | + "--enable-directional-intra=0", | ||
| 4070 | + "--enable-angle-delta=0", | ||
| 4071 | + // DELIBERATELY ABSENT: --enable-tx-size-search=0. | ||
| 4072 | + "--enable-cdef=0", | ||
| 4073 | + "--enable-restoration=0", | ||
| 4074 | + "--max-partition-size=32", | ||
| 4075 | + // Sub-16 inter partitions are a separate named refusal | ||
| 4076 | + // (this decoder codes no inter block below 16x16 through | ||
| 4077 | + // the square path this gate drives), and detailed content | ||
| 4078 | + // makes aomenc's RD reach for them on nearly every seed. | ||
| 4079 | + "--min-partition-size=16", | ||
| 4080 | + "--enable-palette=0", | ||
| 4081 | + "--enable-intrabc=0", | ||
| 4082 | + "--enable-cfl-intra=0", | ||
| 4083 | + "--enable-ref-frame-mvs=0", | ||
| 4084 | + "--obu", | ||
| 4085 | + "-o", | ||
| 4086 | + "-", | ||
| 4087 | + "-", | ||
| 4088 | + ]) | ||
| 4089 | + .stdin(Stdio::piped()) | ||
| 4090 | + .stdout(Stdio::piped()) | ||
| 4091 | + .stderr(Stdio::piped()) | ||
| 4092 | + .spawn() | ||
| 4093 | + .expect("aomenc failed to start"); | ||
| 4094 | + child | ||
| 4095 | + .stdin | ||
| 4096 | + .take() | ||
| 4097 | + .expect("aomenc stdin") | ||
| 4098 | + .write_all(&y4m.stdout) | ||
| 4099 | + .expect("writing y4m to aomenc"); | ||
| 4100 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 4101 | + assert!( | ||
| 4102 | + out.status.success(), | ||
| 4103 | + "aomenc refused the fixture: {}", | ||
| 4104 | + String::from_utf8_lossy(&out.stderr) | ||
| 4105 | + ); | ||
| 4106 | + let stream = out.stdout; | ||
| 4107 | + let (reads_before, hits_before) = | ||
| 4108 | + (decode::txfm_split_reads(), decode::txfm_split_hits()); | ||
| 4109 | + let frames = match decode_stream(&stream) { | ||
| 4110 | + Ok(frames) => frames, | ||
| 4111 | + Err(e) => { | ||
| 4112 | + let msg = e.to_string(); | ||
| 4113 | + assert!( | ||
| 4114 | + msg.contains("unsupported"), | ||
| 4115 | + "tx-select inter decode failed outright (seed {seed}): {msg}" | ||
| 4116 | + ); | ||
| 4117 | + refusals.push(format!("seed {seed}: {msg}")); | ||
| 4118 | + continue; | ||
| 4119 | + } | ||
| 4120 | + }; | ||
| 4121 | + let (reads, hits) = ( | ||
| 4122 | + decode::txfm_split_reads() - reads_before, | ||
| 4123 | + decode::txfm_split_hits() - hits_before, | ||
| 4124 | + ); | ||
| 4125 | + // class [[gate-skips-on-its-own-failure]]: a decode that succeeded | ||
| 4126 | + // is ALWAYS pixel-compared below; the hit counter only decides whether | ||
| 4127 | + // the attempt counts toward the firing total. | ||
| 4128 | + let counted = hits != 0; | ||
| 4129 | + if !counted { | ||
| 4130 | + uncounted_exact += 1; | ||
| 4131 | + refusals.push(format!( | ||
| 4132 | + "seed {seed}: decoded and pixel-compared, but no block took a txfm_split \ | ||
| 4133 | + ({reads} symbols read)" | ||
| 4134 | + )); | ||
| 4135 | + } | ||
| 4136 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 4137 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 4138 | + } else { | ||
| 4139 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 4140 | + }; | ||
| 4141 | + assert_eq!(frames.len(), frame_count); | ||
| 4142 | + eprintln!( | ||
| 4143 | + "txselect gate {bit_depth}-bit seed={seed}: txfm_split reads={reads} splits taken={hits}" | ||
| 4144 | + ); | ||
| 4145 | + // Name the first differing sample before the assert fires: a | ||
| 4146 | + // 64x64 plane's `assert_eq!` output is 4096 numbers, useless for | ||
| 4147 | + // locating a desync. | ||
| 4148 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 4149 | + for (plane, (g, w)) in [ | ||
| 4150 | + ("Y", (&got.y, &want.y)), | ||
| 4151 | + ("U", (&got.u, &want.u)), | ||
| 4152 | + ("V", (&got.v, &want.v)), | ||
| 4153 | + ] { | ||
| 4154 | + let stride = if plane == "Y" { width } else { width / 2 }; | ||
| 4155 | + if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { | ||
| 4156 | + eprintln!( | ||
| 4157 | + "txselect gate seed={seed}: frame {i} {plane} first diff at \ | ||
| 4158 | + ({}, {}) got {} want {} ({} samples differ)", | ||
| 4159 | + at % stride, | ||
| 4160 | + at / stride, | ||
| 4161 | + g[at], | ||
| 4162 | + w[at], | ||
| 4163 | + g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), | ||
| 4164 | + ); | ||
| 4165 | + let coords: Vec<String> = g | ||
| 4166 | + .iter() | ||
| 4167 | + .zip(w.iter()) | ||
| 4168 | + .enumerate() | ||
| 4169 | + .filter(|(_, (a, b))| a != b) | ||
| 4170 | + .take(12) | ||
| 4171 | + .map(|(k, (a, b))| format!("({},{})={a}/{b}", k % stride, k / stride)) | ||
| 4172 | + .collect(); | ||
| 4173 | + eprintln!("txselect gate seed={seed}: frame {i} {plane} diffs {coords:?}"); | ||
| 4174 | + } | ||
| 4175 | + } | ||
| 4176 | + } | ||
| 4177 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 4178 | + assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (seed {seed})"); | ||
| 4179 | + assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed})"); | ||
| 4180 | + assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (seed {seed})"); | ||
| 4181 | + } | ||
| 4182 | + if counted { | ||
| 4183 | + gate_buckets( | ||
| 4184 | + &format!("tx_select_inter_gate({bit_depth})"), | ||
| 4185 | + 1, | ||
| 4186 | + uncounted_exact, | ||
| 4187 | + refusals.len() - uncounted_exact as usize, | ||
| 4188 | + ); | ||
| 4189 | + return; | ||
| 4190 | + } | ||
| 4191 | + } | ||
| 4192 | + gate_buckets( | ||
| 4193 | + &format!("tx_select_inter_gate({bit_depth})"), | ||
| 4194 | + 0, | ||
| 4195 | + uncounted_exact, | ||
| 4196 | + refusals.len() - uncounted_exact as usize, | ||
| 4197 | + ); | ||
| 4198 | + panic!( | ||
| 4199 | + "tx_select_inter_gate({bit_depth}) never observed a taken txfm_split:\n{}", | ||
| 4200 | + refusals.join("\n") | ||
| 4201 | + ); | ||
| 4202 | + } | ||
| 4203 | + | ||
| 4204 | + /// lane-intrainter r1's decisive gate: a real aomenc INTER sequence in | ||
| 4205 | + /// which aomenc's RD picks an INTRA block inside an inter frame AND | ||
| 4206 | + /// splits that block's luma transform (`tx_depth >= 1`, the intra depth | ||
| 4207 | + /// symbol -- not the inter var-tx tree). That block codes one intra | ||
| 4208 | + /// prediction plus one coefficient set per transform unit, exactly like a | ||
| 4209 | + /// key frame's split block but with the inter frame's CDF state and the | ||
| 4210 | + /// inter-frame intra mode syntax; before this lane it was a named | ||
| 4211 | + /// refusal. Hard-asserts [`decode::intra_in_inter_split_tx_hits`] per | ||
| 4212 | + /// block size: an attempt that never produced such a block proves | ||
| 4213 | + /// nothing, and exhausting every attempt is a FAILURE, not a SKIP. | ||
| 4214 | + #[test] | ||
| 4215 | + fn a_real_aomenc_inter_sequence_with_a_split_transform_intra_block_decodes_pixel_exact() { | ||
| 4216 | + intra_in_inter_split_tx_gate(8); | ||
| 4217 | + } | ||
| 4218 | + | ||
| 4219 | + /// The 10-bit arm (both of the user's films are `yuv420p10le`). | ||
| 4220 | + #[test] | ||
| 4221 | + fn a_real_aomenc_10bit_inter_sequence_with_a_split_transform_intra_block_decodes_pixel_exact() { | ||
| 4222 | + intra_in_inter_split_tx_gate(10); | ||
| 4223 | + } | ||
| 4224 | + | ||
| 4225 | + fn intra_in_inter_split_tx_gate(bit_depth: u32) { | ||
| 4226 | + let name = format!("intra_in_inter_split_tx_gate({bit_depth})"); | ||
| 4227 | + if !have_ffmpeg() { | ||
| 4228 | + eprintln!("SKIP {name}: no ffmpeg"); | ||
| 4229 | + return; | ||
| 4230 | + } | ||
| 4231 | + if !have_aomenc() { | ||
| 4232 | + eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); | ||
| 4233 | + return; | ||
| 4234 | + } | ||
| 4235 | + let (width, height, frame_count) = (64usize, 64usize, 8usize); | ||
| 4236 | + let mut refusals = Vec::new(); | ||
| 4237 | + let mut uncounted_exact = 0u32; | ||
| 4238 | + for attempt in 0..40u32 { | ||
| 4239 | + let seed = 42 + attempt; | ||
| 4240 | + // A zooming fractal: every frame moves (so the sequence is | ||
| 4241 | + // genuinely inter-coded) and keeps sharp new detail entering at | ||
| 4242 | + // the borders, which is what makes aomenc's RD choose an INTRA | ||
| 4243 | + // block inside an inter frame -- and then split its transform. | ||
| 4244 | + // A zooming fractal with a hard CUT halfway (`overlay` switching | ||
| 4245 | + // a second, unrelated fractal on at frame 4): after the cut every | ||
| 4246 | + // block is unpredictable from the reference, which is what makes | ||
| 4247 | + // aomenc code INTRA blocks inside an inter frame -- and at this | ||
| 4248 | + // cq the RD then splits their transforms. | ||
| 4249 | + let source = format!( | ||
| 4250 | + "mandelbrot=size=64x64:start_scale={}:rate=25[a];\ | ||
| 4251 | + mandelbrot=size=64x64:start_scale={}:rate=25[b];\ | ||
| 4252 | + [a][b]overlay=enable='gte(n,4)'", | ||
| 4253 | + 5.0 - f64::from(attempt) * 0.06, | ||
| 4254 | + 0.9 + f64::from(attempt) * 0.11 | ||
| 4255 | + ); | ||
| 4256 | + let y4m = Command::new("ffmpeg") | ||
| 4257 | + .args([ | ||
| 4258 | + "-v", | ||
| 4259 | + "error", | ||
| 4260 | + "-f", | ||
| 4261 | + "lavfi", | ||
| 4262 | + "-i", | ||
| 4263 | + &source, | ||
| 4264 | + // Desaturated chroma keeps `uv_mode` on DC_PRED, so the | ||
| 4265 | + // still-refused directional-chroma gaps never fire and | ||
| 4266 | + // luma detail alone drives the transform split. | ||
| 4267 | + "-vf", | ||
| 4268 | + "hue=s=0", | ||
| 4269 | + "-pix_fmt", | ||
| 4270 | + if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, | ||
| 4271 | + "-strict", | ||
| 4272 | + "-1", | ||
| 4273 | + "-t", | ||
| 4274 | + "0.32", | ||
| 4275 | + "-f", | ||
| 4276 | + "yuv4mpegpipe", | ||
| 4277 | + "-strict", | ||
| 4278 | + "-1", | ||
| 4279 | + "-", | ||
| 4280 | + ]) | ||
| 4281 | + .stdin(Stdio::null()) | ||
| 4282 | + .stdout(Stdio::piped()) | ||
| 4283 | + .stderr(Stdio::piped()) | ||
| 4284 | + .output() | ||
| 4285 | + .expect("ffmpeg failed to run"); | ||
| 4286 | + assert!( | ||
| 4287 | + y4m.status.success(), | ||
| 4288 | + "ffmpeg fixture: {}", | ||
| 4289 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 4290 | + ); | ||
| 4291 | + let depth_args: &[&str] = if bit_depth == 10 { | ||
| 4292 | + &["-b", "10", "--input-bit-depth=10"] | ||
| 4293 | + } else { | ||
| 4294 | + &[] | ||
| 4295 | + }; | ||
| 4296 | + let mut child = Command::new(aomenc_path()) | ||
| 4297 | + .args(depth_args) | ||
| 4298 | + .args([ | ||
| 4299 | + "--codec=av1", | ||
| 4300 | + "--passes=1", | ||
| 4301 | + "--end-usage=q", | ||
| 4302 | + "--cq-level=30", | ||
| 4303 | + "--cpu-used=0", | ||
| 4304 | + "--lag-in-frames=0", | ||
| 4305 | + "--auto-alt-ref=0", | ||
| 4306 | + // One key frame only: every later frame is an inter frame, | ||
| 4307 | + // which is where this gate's intra blocks must sit. The | ||
| 4308 | + // MIN distance is what stops aomenc's scene-cut detector | ||
| 4309 | + // from inserting a second key frame at the cut this gate's | ||
| 4310 | + // source deliberately contains. | ||
| 4311 | + "--kf-max-dist=1000", | ||
| 4312 | + "--kf-min-dist=1000", | ||
| 4313 | + "--threads=1", | ||
| 4314 | + "--row-mt=0", | ||
| 4315 | + "--enable-order-hint=0", | ||
| 4316 | + "--enable-warped-motion=0", | ||
| 4317 | + "--enable-obmc=0", | ||
| 4318 | + "--enable-masked-comp=0", | ||
| 4319 | + "--enable-interintra-comp=0", | ||
| 4320 | + "--enable-dist-wtd-comp=0", | ||
| 4321 | + "--enable-diff-wtd-comp=0", | ||
| 4322 | + "--enable-onesided-comp=0", | ||
| 4323 | + "--enable-interintra-wedge=0", | ||
| 4324 | + "--enable-smooth-interintra=0", | ||
| 4325 | + "--enable-ab-partitions=0", | ||
| 4326 | + "--enable-1to4-partitions=0", | ||
| 4327 | + "--enable-filter-intra=0", | ||
| 4328 | + "--enable-smooth-intra=0", | ||
| 4329 | + "--enable-paeth-intra=0", | ||
| 4330 | + "--enable-directional-intra=0", | ||
| 4331 | + "--enable-angle-delta=0", | ||
| 4332 | + "--enable-cdef=0", | ||
| 4333 | + "--enable-restoration=0", | ||
| 4334 | + "--enable-palette=0", | ||
| 4335 | + "--enable-intrabc=0", | ||
| 4336 | + "--enable-cfl-intra=0", | ||
| 4337 | + "--enable-ref-frame-mvs=0", | ||
| 4338 | + // Per-arm overrides go LAST (aomenc keeps the last | ||
| 4339 | + // occurrence of a repeated --enable-* flag): the intra | ||
| 4340 | + // tx_depth symbol only exists under TX_MODE_SELECT, and | ||
| 4341 | + // rect partitions are a separate named refusal. | ||
| 4342 | + "--enable-tx-size-search=1", | ||
| 4343 | + "--enable-rect-partitions=0", | ||
| 4344 | + "--max-partition-size=32", | ||
| 4345 | + // Sub-16 inter partitions are a separate named refusal, | ||
| 4346 | + // as is the 8x8 intra leaf's own TX_4X4 split. | ||
| 4347 | + "--min-partition-size=16", | ||
| 4348 | + "--obu", | ||
| 4349 | + "-o", | ||
| 4350 | + "-", | ||
| 4351 | + "-", | ||
| 4352 | + ]) | ||
| 4353 | + .stdin(Stdio::piped()) | ||
| 4354 | + .stdout(Stdio::piped()) | ||
| 4355 | + .stderr(Stdio::piped()) | ||
| 4356 | + .spawn() | ||
| 4357 | + .expect("aomenc failed to start"); | ||
| 4358 | + child | ||
| 4359 | + .stdin | ||
| 4360 | + .take() | ||
| 4361 | + .expect("aomenc stdin") | ||
| 4362 | + .write_all(&y4m.stdout) | ||
| 4363 | + .expect("writing y4m to aomenc"); | ||
| 4364 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 4365 | + assert!( | ||
| 4366 | + out.status.success(), | ||
| 4367 | + "aomenc refused the fixture: {}", | ||
| 4368 | + String::from_utf8_lossy(&out.stderr) | ||
| 4369 | + ); | ||
| 4370 | + let stream = out.stdout; | ||
| 4371 | + let before = decode::intra_in_inter_split_tx_hits(); | ||
| 4372 | + let frames = match decode_stream(&stream) { | ||
| 4373 | + Ok(frames) => frames, | ||
| 4374 | + Err(e) => { | ||
| 4375 | + let msg = e.to_string(); | ||
| 4376 | + assert!( | ||
| 4377 | + msg.contains("unsupported"), | ||
| 4378 | + "{name} decode failed outright (seed {seed}): {msg}" | ||
| 4379 | + ); | ||
| 4380 | + refusals.push(format!("seed {seed}: {msg}")); | ||
| 4381 | + continue; | ||
| 4382 | + } | ||
| 4383 | + }; | ||
| 4384 | + let after = decode::intra_in_inter_split_tx_hits(); | ||
| 4385 | + let mut per_size = [0usize; 4]; | ||
| 4386 | + for i in 0..4 { | ||
| 4387 | + per_size[i] = after[i] - before[i]; | ||
| 4388 | + } | ||
| 4389 | + // class [[gate-skips-on-its-own-failure]]: a decode that | ||
| 4390 | + // succeeded is ALWAYS pixel-compared below; the counter only | ||
| 4391 | + // decides whether the attempt counts as firing. | ||
| 4392 | + let counted = per_size.iter().sum::<usize>() != 0; | ||
| 4393 | + if !counted { | ||
| 4394 | + uncounted_exact += 1; | ||
| 4395 | + refusals.push(format!( | ||
| 4396 | + "seed {seed}: decoded and pixel-compared, but no intra block in an inter \ | ||
| 4397 | + frame split its transform" | ||
| 4398 | + )); | ||
| 4399 | + } | ||
| 4400 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 4401 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 4402 | + } else { | ||
| 4403 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 4404 | + }; | ||
| 4405 | + assert_eq!(frames.len(), frame_count); | ||
| 4406 | + eprintln!( | ||
| 4407 | + "{name} seed={seed}: split intra-in-inter blocks 8x8={} 16x16={} 32x32={} \ | ||
| 4408 | + 64x64={}", | ||
| 4409 | + per_size[0], per_size[1], per_size[2], per_size[3] | ||
| 4410 | + ); | ||
| 4411 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 4412 | + for (plane, (g, w)) in [ | ||
| 4413 | + ("Y", (&got.y, &want.y)), | ||
| 4414 | + ("U", (&got.u, &want.u)), | ||
| 4415 | + ("V", (&got.v, &want.v)), | ||
| 4416 | + ] { | ||
| 4417 | + let stride = if plane == "Y" { width } else { width / 2 }; | ||
| 4418 | + if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { | ||
| 4419 | + eprintln!( | ||
| 4420 | + "{name} seed={seed}: frame {i} {plane} first diff at ({}, {}) got {} \ | ||
| 4421 | + want {} ({} samples differ)", | ||
| 4422 | + at % stride, | ||
| 4423 | + at / stride, | ||
| 4424 | + g[at], | ||
| 4425 | + w[at], | ||
| 4426 | + g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), | ||
| 4427 | + ); | ||
| 4428 | + } | ||
| 4429 | + } | ||
| 4430 | + } | ||
| 4431 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 4432 | + assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (seed {seed})"); | ||
| 4433 | + assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed})"); | ||
| 4434 | + assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (seed {seed})"); | ||
| 4435 | + } | ||
| 4436 | + if counted { | ||
| 4437 | + gate_buckets( | ||
| 4438 | + &name, | ||
| 4439 | + 1, | ||
| 4440 | + uncounted_exact, | ||
| 4441 | + refusals.len() - uncounted_exact as usize, | ||
| 4442 | + ); | ||
| 4443 | + return; | ||
| 4444 | + } | ||
| 4445 | + } | ||
| 4446 | + gate_buckets( | ||
| 4447 | + &name, | ||
| 4448 | + 0, | ||
| 4449 | + uncounted_exact, | ||
| 4450 | + refusals.len() - uncounted_exact as usize, | ||
| 4451 | + ); | ||
| 4452 | + panic!( | ||
| 4453 | + "{name} never observed a split-transform intra block in an inter frame:\n{}", | ||
| 4454 | + refusals.join("\n") | ||
| 4455 | + ); | ||
| 4456 | + } | ||
| 4457 | + | ||
| 4458 | + /// lane-fiinter r1 (class [[symbol-consumption-gap]] + | ||
| 4459 | + /// [[tool-disabled-in-every-gate]]): a real aomenc inter sequence with | ||
| 4460 | + /// `--enable-filter-intra=1` (aomenc's own default -- every inter gate | ||
| 4461 | + /// recipe before this one pinned it OFF, so nothing ever exercised it) in | ||
| 4462 | + /// which the RD picks an INTRA block inside an inter frame and gives it | ||
| 4463 | + /// filter intra. `read_intra_block_mode_info` reads `use_filter_intra` | ||
| 4464 | + /// there exactly as a key frame does; this decoder read no such symbol at | ||
| 4465 | + /// all until this round, so such a stream desynced at that symbol and | ||
| 4466 | + /// decoded silently wrong. Hard-asserts | ||
| 4467 | + /// [`decode::intra_in_inter_filter_intra_hits`]: an attempt that never | ||
| 4468 | + /// produced one proves nothing, and exhausting every attempt is a | ||
| 4469 | + /// FAILURE, not a SKIP. | ||
| 3953 | #[test] | 4470 | #[test] |
| 3954 | - fn a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact() { | 4471 | + fn a_real_aomenc_inter_sequence_with_filter_intra_on_an_intra_block_decodes_pixel_exact() { |
| 3955 | - tx_select_inter_gate(8); | 4472 | + filter_intra_in_inter_gate(8); |
| 3956 | } | 4473 | } |
| 3957 | 4474 | ||
| 3958 | - /// The 10-bit arm of the gate above (lane-txselect r2): both of the | 4475 | + /// The 10-bit arm (both of the user's films are `yuv420p10le`). |
| 3959 | - /// user's films are `yuv420p10le` and var-tx is exactly the tool they | ||
| 3960 | - /// use, so an 8-bit-only proof would not reach them. Same recipe plus | ||
| 3961 | - /// `-b 10 --input-bit-depth=10`. | ||
| 3962 | #[test] | 4476 | #[test] |
| 3963 | - fn a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact_10bit() { | 4477 | + fn a_real_aomenc_10bit_inter_sequence_with_filter_intra_on_an_intra_block_decodes_pixel_exact() |
| 3964 | - tx_select_inter_gate(10); | 4478 | + { |
| 4479 | + filter_intra_in_inter_gate(10); | ||
| 3965 | } | 4480 | } |
| 3966 | 4481 | ||
| 3967 | - fn tx_select_inter_gate(bit_depth: u32) { | 4482 | + fn filter_intra_in_inter_gate(bit_depth: u32) { |
| 4483 | + let name = format!("filter_intra_in_inter_gate({bit_depth})"); | ||
| 3968 | if !have_ffmpeg() { | 4484 | if !have_ffmpeg() { |
| 3969 | - eprintln!( | 4485 | + eprintln!("SKIP {name}: no ffmpeg"); |
| 3970 | - "SKIP a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact: no ffmpeg" | ||
| 3971 | - ); | ||
| 3972 | return; | 4486 | return; |
| 3973 | } | 4487 | } |
| 3974 | if !have_aomenc() { | 4488 | if !have_aomenc() { |
| 3975 | - eprintln!( | 4489 | + eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); |
| 3976 | - "SKIP a_real_aomenc_inter_sequence_with_tx_select_decodes_pixel_exact: no aomenc at {}", | ||
| 3977 | - aomenc_path().display() | ||
| 3978 | - ); | ||
| 3979 | return; | 4490 | return; |
| 3980 | } | 4491 | } |
| 3981 | - let (width, height, frame_count) = (64usize, 64usize, 4usize); | 4492 | + let (width, height, frame_count) = (64usize, 64usize, 8usize); |
| 3982 | let mut refusals = Vec::new(); | 4493 | let mut refusals = Vec::new(); |
| 3983 | let mut uncounted_exact = 0u32; | 4494 | let mut uncounted_exact = 0u32; |
| 3984 | for attempt in 0..40u32 { | 4495 | for attempt in 0..40u32 { |
| 3985 | let seed = 42 + attempt; | 4496 | let seed = 42 + attempt; |
| 3986 | - // Detail is what makes aomenc's RD prefer a split transform; a | 4497 | + // A zooming fractal: every frame moves (so the sequence is |
| 3987 | - // flat gradient resolves every `txfm_split` to 0. `mandelbrot`'s | 4498 | + // genuinely inter-coded) and keeps sharp new detail entering at |
| 3988 | - // fractal boundary is the same source the sibling intra tx-select | 4499 | + // the borders, which is what makes aomenc's RD choose an INTRA |
| 3989 | - // gate uses, at a different `start_scale` per attempt. | 4500 | + // block inside an inter frame -- and then split its transform. |
| 4501 | + // A zooming fractal with a hard CUT halfway (`overlay` switching | ||
| 4502 | + // a second, unrelated fractal on at frame 4): after the cut every | ||
| 4503 | + // block is unpredictable from the reference, which is what makes | ||
| 4504 | + // aomenc code INTRA blocks inside an inter frame -- and at this | ||
| 4505 | + // cq the RD then splits their transforms. | ||
| 3990 | let source = format!( | 4506 | let source = format!( |
| 3991 | - "mandelbrot=size=64x64:start_scale={}:rate=25", | 4507 | + "mandelbrot=size=64x64:start_scale={}:rate=25[a];\ |
| 3992 | - 5.0 - f64::from(attempt) * 0.06 | 4508 | + mandelbrot=size=64x64:start_scale={}:rate=25[b];\ |
| 4509 | + [a][b]overlay=enable='gte(n,4)'", | ||
| 4510 | + 5.0 - f64::from(attempt) * 0.06, | ||
| 4511 | + 0.9 + f64::from(attempt) * 0.11 | ||
| 3993 | ); | 4512 | ); |
| 3994 | let y4m = Command::new("ffmpeg") | 4513 | let y4m = Command::new("ffmpeg") |
| 3995 | .args([ | 4514 | .args([ |
| @@ -3999,19 +4518,17 @@ mod tests { | |||
| 3999 | "lavfi", | 4518 | "lavfi", |
| 4000 | "-i", | 4519 | "-i", |
| 4001 | &source, | 4520 | &source, |
| 4002 | - // Desaturated chroma: `uv_mode` stays DC_PRED, so the | 4521 | + // Desaturated chroma keeps `uv_mode` on DC_PRED, so the |
| 4003 | - // still-refused directional-chroma gap never fires and | 4522 | + // still-refused directional-chroma gaps never fire and |
| 4004 | // luma detail alone drives the transform split. | 4523 | // luma detail alone drives the transform split. |
| 4005 | "-vf", | 4524 | "-vf", |
| 4006 | "hue=s=0", | 4525 | "hue=s=0", |
| 4007 | "-pix_fmt", | 4526 | "-pix_fmt", |
| 4008 | if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, | 4527 | if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, |
| 4009 | - // y4m carries no official 10-bit tag; ffmpeg writes one | ||
| 4010 | - // only under `-strict -1` (a no-op at 8 bit). | ||
| 4011 | "-strict", | 4528 | "-strict", |
| 4012 | "-1", | 4529 | "-1", |
| 4013 | "-t", | 4530 | "-t", |
| 4014 | - "0.16", | 4531 | + "0.32", |
| 4015 | "-f", | 4532 | "-f", |
| 4016 | "yuv4mpegpipe", | 4533 | "yuv4mpegpipe", |
| 4017 | "-strict", | 4534 | "-strict", |
| @@ -4036,17 +4553,20 @@ mod tests { | |||
| 4036 | let mut child = Command::new(aomenc_path()) | 4553 | let mut child = Command::new(aomenc_path()) |
| 4037 | .args(depth_args) | 4554 | .args(depth_args) |
| 4038 | .args([ | 4555 | .args([ |
| 4039 | - // lane-defon r1: explicit on-value (aomenc keeps the FIRST | ||
| 4040 | - // occurrence, so overrides go before the base list). | ||
| 4041 | - "--enable-tx-size-search=1", | ||
| 4042 | "--codec=av1", | 4556 | "--codec=av1", |
| 4043 | "--passes=1", | 4557 | "--passes=1", |
| 4044 | "--end-usage=q", | 4558 | "--end-usage=q", |
| 4045 | - "--cq-level=55", | 4559 | + "--cq-level=30", |
| 4046 | "--cpu-used=0", | 4560 | "--cpu-used=0", |
| 4047 | "--lag-in-frames=0", | 4561 | "--lag-in-frames=0", |
| 4048 | "--auto-alt-ref=0", | 4562 | "--auto-alt-ref=0", |
| 4563 | + // One key frame only: every later frame is an inter frame, | ||
| 4564 | + // which is where this gate's intra blocks must sit. The | ||
| 4565 | + // MIN distance is what stops aomenc's scene-cut detector | ||
| 4566 | + // from inserting a second key frame at the cut this gate's | ||
| 4567 | + // source deliberately contains. | ||
| 4049 | "--kf-max-dist=1000", | 4568 | "--kf-max-dist=1000", |
| 4569 | + "--kf-min-dist=1000", | ||
| 4050 | "--threads=1", | 4570 | "--threads=1", |
| 4051 | "--row-mt=0", | 4571 | "--row-mt=0", |
| 4052 | "--enable-order-hint=0", | 4572 | "--enable-order-hint=0", |
| @@ -4059,27 +4579,29 @@ mod tests { | |||
| 4059 | "--enable-onesided-comp=0", | 4579 | "--enable-onesided-comp=0", |
| 4060 | "--enable-interintra-wedge=0", | 4580 | "--enable-interintra-wedge=0", |
| 4061 | "--enable-smooth-interintra=0", | 4581 | "--enable-smooth-interintra=0", |
| 4062 | - "--enable-rect-partitions=0", | ||
| 4063 | "--enable-ab-partitions=0", | 4582 | "--enable-ab-partitions=0", |
| 4064 | "--enable-1to4-partitions=0", | 4583 | "--enable-1to4-partitions=0", |
| 4065 | - "--enable-filter-intra=0", | ||
| 4066 | "--enable-smooth-intra=0", | 4584 | "--enable-smooth-intra=0", |
| 4067 | "--enable-paeth-intra=0", | 4585 | "--enable-paeth-intra=0", |
| 4068 | "--enable-directional-intra=0", | 4586 | "--enable-directional-intra=0", |
| 4069 | "--enable-angle-delta=0", | 4587 | "--enable-angle-delta=0", |
| 4070 | - // DELIBERATELY ABSENT: --enable-tx-size-search=0. | ||
| 4071 | "--enable-cdef=0", | 4588 | "--enable-cdef=0", |
| 4072 | "--enable-restoration=0", | 4589 | "--enable-restoration=0", |
| 4073 | - "--max-partition-size=32", | ||
| 4074 | - // Sub-16 inter partitions are a separate named refusal | ||
| 4075 | - // (this decoder codes no inter block below 16x16 through | ||
| 4076 | - // the square path this gate drives), and detailed content | ||
| 4077 | - // makes aomenc's RD reach for them on nearly every seed. | ||
| 4078 | - "--min-partition-size=16", | ||
| 4079 | "--enable-palette=0", | 4590 | "--enable-palette=0", |
| 4080 | "--enable-intrabc=0", | 4591 | "--enable-intrabc=0", |
| 4081 | "--enable-cfl-intra=0", | 4592 | "--enable-cfl-intra=0", |
| 4082 | "--enable-ref-frame-mvs=0", | 4593 | "--enable-ref-frame-mvs=0", |
| 4594 | + // Per-arm overrides go LAST (aomenc keeps the last | ||
| 4595 | + // occurrence of a repeated --enable-* flag): the intra | ||
| 4596 | + // tx_depth symbol only exists under TX_MODE_SELECT, and | ||
| 4597 | + // rect partitions are a separate named refusal. | ||
| 4598 | + "--enable-filter-intra=1", | ||
| 4599 | + "--enable-tx-size-search=1", | ||
| 4600 | + "--enable-rect-partitions=0", | ||
| 4601 | + "--max-partition-size=32", | ||
| 4602 | + // Sub-16 inter partitions are a separate named refusal, | ||
| 4603 | + // as is the 8x8 intra leaf's own TX_4X4 split. | ||
| 4604 | + "--min-partition-size=16", | ||
| 4083 | "--obu", | 4605 | "--obu", |
| 4084 | "-o", | 4606 | "-o", |
| 4085 | "-", | 4607 | "-", |
| @@ -4103,33 +4625,29 @@ mod tests { | |||
| 4103 | String::from_utf8_lossy(&out.stderr) | 4625 | String::from_utf8_lossy(&out.stderr) |
| 4104 | ); | 4626 | ); |
| 4105 | let stream = out.stdout; | 4627 | let stream = out.stdout; |
| 4106 | - let (reads_before, hits_before) = | 4628 | + let before = decode::intra_in_inter_filter_intra_hits(); |
| 4107 | - (decode::txfm_split_reads(), decode::txfm_split_hits()); | ||
| 4108 | let frames = match decode_stream(&stream) { | 4629 | let frames = match decode_stream(&stream) { |
| 4109 | Ok(frames) => frames, | 4630 | Ok(frames) => frames, |
| 4110 | Err(e) => { | 4631 | Err(e) => { |
| 4111 | let msg = e.to_string(); | 4632 | let msg = e.to_string(); |
| 4112 | assert!( | 4633 | assert!( |
| 4113 | msg.contains("unsupported"), | 4634 | msg.contains("unsupported"), |
| 4114 | - "tx-select inter decode failed outright (seed {seed}): {msg}" | 4635 | + "{name} decode failed outright (seed {seed}): {msg}" |
| 4115 | ); | 4636 | ); |
| 4116 | refusals.push(format!("seed {seed}: {msg}")); | 4637 | refusals.push(format!("seed {seed}: {msg}")); |
| 4117 | continue; | 4638 | continue; |
| 4118 | } | 4639 | } |
| 4119 | }; | 4640 | }; |
| 4120 | - let (reads, hits) = ( | 4641 | + let fired = decode::intra_in_inter_filter_intra_hits() - before; |
| 4121 | - decode::txfm_split_reads() - reads_before, | 4642 | + // class [[gate-skips-on-its-own-failure]]: a decode that |
| 4122 | - decode::txfm_split_hits() - hits_before, | 4643 | + // succeeded is ALWAYS pixel-compared below; the counter only |
| 4123 | - ); | 4644 | + // decides whether the attempt counts as firing. |
| 4124 | - // class [[gate-skips-on-its-own-failure]]: a decode that succeeded | 4645 | + let counted = fired != 0; |
| 4125 | - // is ALWAYS pixel-compared below; the hit counter only decides whether | ||
| 4126 | - // the attempt counts toward the firing total. | ||
| 4127 | - let counted = hits != 0; | ||
| 4128 | if !counted { | 4646 | if !counted { |
| 4129 | uncounted_exact += 1; | 4647 | uncounted_exact += 1; |
| 4130 | refusals.push(format!( | 4648 | refusals.push(format!( |
| 4131 | - "seed {seed}: decoded and pixel-compared, but no block took a txfm_split \ | 4649 | + "seed {seed}: decoded and pixel-compared, but no intra block in an inter \ |
| 4132 | - ({reads} symbols read)" | 4650 | + frame used filter intra" |
| 4133 | )); | 4651 | )); |
| 4134 | } | 4652 | } |
| 4135 | let ffmpeg_frames = if bit_depth == 10 { | 4653 | let ffmpeg_frames = if bit_depth == 10 { |
| @@ -4139,11 +4657,8 @@ mod tests { | |||
| 4139 | }; | 4657 | }; |
| 4140 | assert_eq!(frames.len(), frame_count); | 4658 | assert_eq!(frames.len(), frame_count); |
| 4141 | eprintln!( | 4659 | eprintln!( |
| 4142 | - "txselect gate {bit_depth}-bit seed={seed}: txfm_split reads={reads} splits taken={hits}" | 4660 | + "{name} seed={seed}: filter-intra blocks inside inter frames = {fired}" |
| 4143 | ); | 4661 | ); |
| 4144 | - // Name the first differing sample before the assert fires: a | ||
| 4145 | - // 64x64 plane's `assert_eq!` output is 4096 numbers, useless for | ||
| 4146 | - // locating a desync. | ||
| 4147 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | 4662 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 4148 | for (plane, (g, w)) in [ | 4663 | for (plane, (g, w)) in [ |
| 4149 | ("Y", (&got.y, &want.y)), | 4664 | ("Y", (&got.y, &want.y)), |
| @@ -4153,23 +4668,14 @@ mod tests { | |||
| 4153 | let stride = if plane == "Y" { width } else { width / 2 }; | 4668 | let stride = if plane == "Y" { width } else { width / 2 }; |
| 4154 | if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { | 4669 | if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { |
| 4155 | eprintln!( | 4670 | eprintln!( |
| 4156 | - "txselect gate seed={seed}: frame {i} {plane} first diff at \ | 4671 | + "{name} seed={seed}: frame {i} {plane} first diff at ({}, {}) got {} \ |
| 4157 | - ({}, {}) got {} want {} ({} samples differ)", | 4672 | + want {} ({} samples differ)", |
| 4158 | at % stride, | 4673 | at % stride, |
| 4159 | at / stride, | 4674 | at / stride, |
| 4160 | g[at], | 4675 | g[at], |
| 4161 | w[at], | 4676 | w[at], |
| 4162 | g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), | 4677 | g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), |
| 4163 | ); | 4678 | ); |
| 4164 | - let coords: Vec<String> = g | ||
| 4165 | - .iter() | ||
| 4166 | - .zip(w.iter()) | ||
| 4167 | - .enumerate() | ||
| 4168 | - .filter(|(_, (a, b))| a != b) | ||
| 4169 | - .take(12) | ||
| 4170 | - .map(|(k, (a, b))| format!("({},{})={a}/{b}", k % stride, k / stride)) | ||
| 4171 | - .collect(); | ||
| 4172 | - eprintln!("txselect gate seed={seed}: frame {i} {plane} diffs {coords:?}"); | ||
| 4173 | } | 4679 | } |
| 4174 | } | 4680 | } |
| 4175 | } | 4681 | } |
| @@ -4180,7 +4686,7 @@ mod tests { | |||
| 4180 | } | 4686 | } |
| 4181 | if counted { | 4687 | if counted { |
| 4182 | gate_buckets( | 4688 | gate_buckets( |
| 4183 | - &format!("tx_select_inter_gate({bit_depth})"), | 4689 | + &name, |
| 4184 | 1, | 4690 | 1, |
| 4185 | uncounted_exact, | 4691 | uncounted_exact, |
| 4186 | refusals.len() - uncounted_exact as usize, | 4692 | refusals.len() - uncounted_exact as usize, |
| @@ -4189,13 +4695,13 @@ mod tests { | |||
| 4189 | } | 4695 | } |
| 4190 | } | 4696 | } |
| 4191 | gate_buckets( | 4697 | gate_buckets( |
| 4192 | - &format!("tx_select_inter_gate({bit_depth})"), | 4698 | + &name, |
| 4193 | 0, | 4699 | 0, |
| 4194 | uncounted_exact, | 4700 | uncounted_exact, |
| 4195 | refusals.len() - uncounted_exact as usize, | 4701 | refusals.len() - uncounted_exact as usize, |
| 4196 | ); | 4702 | ); |
| 4197 | panic!( | 4703 | panic!( |
| 4198 | - "tx_select_inter_gate({bit_depth}) never observed a taken txfm_split:\n{}", | 4704 | + "{name} never observed a filter-intra intra block in an inter frame:\n{}", |
| 4199 | refusals.join("\n") | 4705 | refusals.join("\n") |
| 4200 | ); | 4706 | ); |
| 4201 | } | 4707 | } |
| @@ -9302,22 +9808,26 @@ mod tests { | |||
| 9302 | attempts.iter().filter(|a| !a.tx_size_search).count(), | 9808 | attempts.iter().filter(|a| !a.tx_size_search).count(), |
| 9303 | "{NAME}: every fixed-transform attempt must decode and compare" | 9809 | "{NAME}: every fixed-transform attempt must decode and compare" |
| 9304 | ); | 9810 | ); |
| 9305 | - // The tx-size-search attempts cannot be compared pixel by pixel yet: | 9811 | + // Until the lane-rectsplitx merge every tx-size-search attempt stopped |
| 9306 | - // every 16x16 AB partition contains a strip, and with a free | 9812 | + // at "a HORZ/VERT intra strip below 16x16 with a split transform", so |
| 9307 | - // transform size aomenc splits at least one of them in every stream | 9813 | + // this gate could only claim that the TX4 sub-grid of an 8x8 square |
| 9308 | - // of a 40-cell {source, cq} sweep (r2 report), so they all stop at | 9814 | + // inside a VERT_A/VERT_B was REACHED (`tx4_reached`, counted even on a |
| 9309 | - // lane-rectx's "strip with a split transform" refusal (or the 1:4 / | 9815 | + // refused attempt). With per-TU rect prediction those same attempts now |
| 9310 | - // sub-8x8 ones) before the frame is done. What they DO prove is that | 9816 | + // decode to the end and compare pixel-exact, and they carry no vert-AB |
| 9311 | - // the TX4 sub-grid of an 8x8 square inside a VERT_A/VERT_B is reached | 9817 | + // TX4 unit at all -- the pre-merge nonzero count came from decodes that |
| 9312 | - // on a real stream and answers -- it used to panic there, and a panic | 9818 | + // were still desynced when they hit the refusal (class |
| 9313 | - // cannot be tolerated by the `unsupported` arm above. The values it | 9819 | + // counter-from-refused-stream). The full pixel compare is the stronger |
| 9314 | - // answers are pinned separately against libaom in | 9820 | + // claim and replaces it; the lookup's VALUES stay pinned against libaom |
| 9315 | - // `of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab`. | 9821 | + // in `of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab`. |
| 9316 | - let _ = tx4_compared; | 9822 | + eprintln!("{NAME}: vert-AB TX4 units reached across tx-size-search attempts: {tx4_reached}"); |
| 9317 | - assert!( | 9823 | + let _ = tx4_reached; |
| 9318 | - tx4_reached > 0, | 9824 | + assert_eq!( |
| 9319 | - "{NAME}: no --enable-tx-size-search=1 attempt reached a TX4 unit inside a \ | 9825 | + tx4_compared, |
| 9320 | - vertical AB partition -- the r2 panic path is unproven" | 9826 | + attempts.iter().filter(|a| a.tx_size_search).count(), |
| 9827 | + "{NAME}: every --enable-tx-size-search=1 attempt must now decode to the end and \ | ||
| 9828 | + compare pixel-exact (the split-transform strip refusal these used to stop at is \ | ||
| 9829 | + lifted); the vert-AB TX4 lookup values stay pinned by \ | ||
| 9830 | + `of_tu_keeps_the_ordinary_answer_and_uses_the_block_row_under_vert_ab`" | ||
| 9321 | ); | 9831 | ); |
| 9322 | for (i, arm) in ["HORZ_A", "HORZ_B", "VERT_A", "VERT_B"].iter().enumerate() { | 9832 | for (i, arm) in ["HORZ_A", "HORZ_B", "VERT_A", "VERT_B"].iter().enumerate() { |
| 9323 | assert!(arms[i] > 0, "{NAME}: PARTITION_{arm} at 16x16 never fired across {compared} \ | 9833 | assert!(arms[i] > 0, "{NAME}: PARTITION_{arm} at 16x16 never fired across {compared} \ |
| @@ -12947,7 +13457,7 @@ mod tests { | |||
| 12947 | /// `encode::tests::every_rect_shape_reaches_what_libaom_says_over_the_whole_superblock` | 13457 | /// `encode::tests::every_rect_shape_reaches_what_libaom_says_over_the_whole_superblock` |
| 12948 | /// against libaom's own `has_tr_*`/`has_bl_*` arrays. | 13458 | /// against libaom's own `has_tr_*`/`has_bl_*` arrays. |
| 12949 | #[test] | 13459 | #[test] |
| 12950 | - #[ignore = "the coded 16x8/8x16 strip is a live refusal; see the doc above"] | 13460 | + #[ignore = "lane-rectsplitx r2 (re-measured after the neighbour-mode fix): every seed 700..739 attempt now stops at another lane's refusal 'a HORZ_A/HORZ_B/VERT_A partition below 16x16', so the gate reaches no strip at all -- blocked on AB partitions below 16x16, not on this lane"] |
| 12951 | fn a_directional_16x8_strip_reads_the_right_above_right_samples() { | 13461 | fn a_directional_16x8_strip_reads_the_right_above_right_samples() { |
| 12952 | const NAME: &str = "a_directional_16x8_strip_reads_the_right_above_right_samples"; | 13462 | const NAME: &str = "a_directional_16x8_strip_reads_the_right_above_right_samples"; |
| 12953 | if !have_ffmpeg() { | 13463 | if !have_ffmpeg() { |
| @@ -13369,6 +13879,13 @@ mod tests { | |||
| 13369 | let (width, height) = (128usize, 64usize); | 13879 | let (width, height) = (128usize, 64usize); |
| 13370 | let mut matched = 0u32; | 13880 | let mut matched = 0u32; |
| 13371 | let mut named_refusals = 0u32; | 13881 | let mut named_refusals = 0u32; |
| 13882 | + // lane-modectx r1: luma `kf_y_mode` neighbour reads whose coarse | ||
| 13883 | + // fallback band held a previous tile's mode at a tile edge. Measured 0 | ||
| 13884 | + // -- `above_mode` is cleared per tile and `left_mode` per superblock | ||
| 13885 | + // row -- and that is exactly why the coarse fallback is safe where | ||
| 13886 | + // lane-mtfix's chroma one was not. Accumulated only for attempts that | ||
| 13887 | + // then compared pixel-exact (class counter-from-refused-stream). | ||
| 13888 | + let mut mode_edge_leaks = 0usize; | ||
| 13372 | for attempt in 0..20u32 { | 13889 | for attempt in 0..20u32 { |
| 13373 | let seed = 42 + attempt; | 13890 | let seed = 42 + attempt; |
| 13374 | let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); | 13891 | let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); |
| @@ -13511,6 +14028,7 @@ mod tests { | |||
| 13511 | .is_some_and(|seq| seq.enable_intra_edge_filter); | 14028 | .is_some_and(|seq| seq.enable_intra_edge_filter); |
| 13512 | 14029 | ||
| 13513 | let before = crate::decode::tile_hits(); | 14030 | let before = crate::decode::tile_hits(); |
| 14031 | + let before_edge = crate::decode::mode_tile_edge_coarse_leaks(); | ||
| 13514 | let picture = match decode_key_frame_tile_with_cdfs( | 14032 | let picture = match decode_key_frame_tile_with_cdfs( |
| 13515 | &tile_bufs, | 14033 | &tile_bufs, |
| 13516 | &header.tile_info, | 14034 | &header.tile_info, |
| @@ -13561,6 +14079,7 @@ mod tests { | |||
| 13561 | assert_eq!(picture.y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); | 14079 | assert_eq!(picture.y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); |
| 13562 | assert_eq!(picture.u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); | 14080 | assert_eq!(picture.u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); |
| 13563 | assert_eq!(picture.v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); | 14081 | assert_eq!(picture.v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); |
| 14082 | + mode_edge_leaks += crate::decode::mode_tile_edge_coarse_leaks() - before_edge; | ||
| 13564 | matched += 1; | 14083 | matched += 1; |
| 13565 | } | 14084 | } |
| 13566 | assert!( | 14085 | assert!( |
| @@ -13568,8 +14087,15 @@ mod tests { | |||
| 13568 | "{NAME}: every attempt refused ({named_refusals} refusals); the gate never decoded \ | 14087 | "{NAME}: every attempt refused ({named_refusals} refusals); the gate never decoded \ |
| 13569 | a two-tile-column stream" | 14088 | a two-tile-column stream" |
| 13570 | ); | 14089 | ); |
| 14090 | + assert_eq!( | ||
| 14091 | + mode_edge_leaks, 0, | ||
| 14092 | + "{NAME}: a luma mode neighbour read at a tile edge saw a NON-DC coarse band -- the \ | ||
| 14093 | + per-tile `above_mode` / per-superblock-row `left_mode` reset that makes the coarse \ | ||
| 14094 | + fallback safe has regressed" | ||
| 14095 | + ); | ||
| 13571 | eprintln!( | 14096 | eprintln!( |
| 13572 | - "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20" | 14097 | + "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals out of 20, \ |
| 14098 | + {mode_edge_leaks} tile-edge coarse leaks" | ||
| 13573 | ); | 14099 | ); |
| 13574 | } | 14100 | } |
| 13575 | 14101 | ||
| @@ -16258,6 +16784,269 @@ mod tests { | |||
| 16258 | ); | 16784 | ); |
| 16259 | } | 16785 | } |
| 16260 | 16786 | ||
| 16787 | + /// lane-rect1d r1 (copied from lane-rectclass r1): the class-correctness measurement for every | ||
| 16788 | + /// RECTANGULAR transform unit this decoder reads. [`crate::decode::read_coeffs_rect`] | ||
| 16789 | + /// handles `TxClass::TwoD` only -- it refuses by name both a coded | ||
| 16790 | + /// `tx_type` symbol and a non-2D default -- so the open question a | ||
| 16791 | + /// verifier raised was whether a real encoder ever puts a | ||
| 16792 | + /// `V_DCT`/`H_DCT` (`TX_CLASS_HORIZ`/`VERT`) type on a rect TU that | ||
| 16793 | + /// reaches this reader. The recipe deliberately maximises the chance: | ||
| 16794 | + /// `--enable-flip-idtx=1` (the flip/identity/1D types are exactly what | ||
| 16795 | + /// `EXT_TX_SET_DTT4_IDTX_1DDCT` and the wider inter sets add), | ||
| 16796 | + /// `--enable-tx-size-search=1`, rect partitions on, small minimum | ||
| 16797 | + /// partition size, both bit depths. Every successful decode is | ||
| 16798 | + /// pixel-compared; the rect-TU counter is folded in PER ATTEMPT and only | ||
| 16799 | + /// after that attempt compared (class `counter-from-refused-stream`), and | ||
| 16800 | + /// the class-1 refusal counter is summed over EVERY attempt including the | ||
| 16801 | + /// refused ones -- a refused attempt is exactly where a 1D class on a | ||
| 16802 | + /// rect TU would show up. | ||
| 16803 | + /// | ||
| 16804 | + /// lane-rect1d: on THIS tree `read_coeffs_rect` no longer refuses a 1D | ||
| 16805 | + /// class -- lane-tx4x8 gave it the mrow/mcol scan and the class-aware | ||
| 16806 | + /// base/br contexts -- so the live pins are `compared_class1 > 0` (the | ||
| 16807 | + /// flag arrived and 1D types were coded) plus the pixel compare itself. | ||
| 16808 | + #[test] | ||
| 16809 | + fn a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact() { | ||
| 16810 | + const NAME: &str = | ||
| 16811 | + "a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact"; | ||
| 16812 | + let _gate_lock = lock_gate_counters(); | ||
| 16813 | + if !have_ffmpeg() { | ||
| 16814 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 16815 | + return; | ||
| 16816 | + } | ||
| 16817 | + if !have_aomenc() { | ||
| 16818 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 16819 | + return; | ||
| 16820 | + } | ||
| 16821 | + let (width, height) = (192usize, 128usize); | ||
| 16822 | + let mut named_refusals = 0u32; | ||
| 16823 | + let mut matched = 0u32; | ||
| 16824 | + let mut matched_10bit = 0u32; | ||
| 16825 | + let mut compared_rect_tus = 0usize; | ||
| 16826 | + let mut compared_rect_parts = 0usize; | ||
| 16827 | + let mut compared_tx_depths = 0usize; | ||
| 16828 | + let mut compared_class1 = 0usize; | ||
| 16829 | + let mut compared_rect_class1 = 0usize; | ||
| 16830 | + let n_attempts: u32 = std::env::var("EC_RECTCLASS_GATE_ATTEMPTS") | ||
| 16831 | + .ok() | ||
| 16832 | + .and_then(|s| s.parse().ok()) | ||
| 16833 | + .unwrap_or(12); | ||
| 16834 | + // Both bit depths in one sweep: his two films are yuv420p10le, and a | ||
| 16835 | + // class claim that only holds at 8 bits is worth nothing to them. | ||
| 16836 | + for attempt in 0..n_attempts { | ||
| 16837 | + let seed = 42 + attempt / 2; | ||
| 16838 | + let ten_bit = attempt % 2 == 1; | ||
| 16839 | + let pix_fmt = if ten_bit { "yuv420p10le" } else { "yuv420p" }; | ||
| 16840 | + // Content + quantiser sweep: the 1D (`V_DCT`/`H_DCT`) types RD can | ||
| 16841 | + // only pick on strongly one-directional detail, and only when the | ||
| 16842 | + // quantiser leaves that detail in the residual -- smooth gradients | ||
| 16843 | + // at cq 45 produced exactly zero of them (measured this round), | ||
| 16844 | + // which would have made the `--enable-flip-idtx=1` arrival assert | ||
| 16845 | + // fail rather than the gate pass vacuously. | ||
| 16846 | + let period = [4u32, 6, 8, 12, 16][(attempt as usize / 2) % 5]; | ||
| 16847 | + let source = format!("testsrc2=size={width}x{height}:rate=25"); | ||
| 16848 | + let filter = format!( | ||
| 16849 | + "geq=lum='128+80*sin(2*PI*Y/{period})':cb='128+60*sin(2*PI*X/{period})':cr=128,\ | ||
| 16850 | + noise=alls=6:allf=t" | ||
| 16851 | + ); | ||
| 16852 | + let cq = if attempt % 4 < 2 { "--cq-level=20" } else { "--cq-level=40" }; | ||
| 16853 | + let y4m = Command::new("ffmpeg") | ||
| 16854 | + .args([ | ||
| 16855 | + // `-strict -1`: y4m calls 10-bit an unofficial pixel | ||
| 16856 | + // format and refuses to write the header otherwise (no-op | ||
| 16857 | + // at 8 bit). | ||
| 16858 | + "-v", "error", "-f", "lavfi", "-i", &source, "-vf", &filter, "-t", "0.04", | ||
| 16859 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 16860 | + ]) | ||
| 16861 | + .stdin(Stdio::null()) | ||
| 16862 | + .stdout(Stdio::piped()) | ||
| 16863 | + .stderr(Stdio::piped()) | ||
| 16864 | + .output() | ||
| 16865 | + .expect("ffmpeg failed to run"); | ||
| 16866 | + assert!( | ||
| 16867 | + y4m.status.success(), | ||
| 16868 | + "ffmpeg fixture: {}", | ||
| 16869 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 16870 | + ); | ||
| 16871 | + // aomenc keeps the LAST occurrence of a repeated `--enable-*` | ||
| 16872 | + // flag (measured 2026-09-02 by md5 of four orderings), so this | ||
| 16873 | + // lane's overrides come AFTER the base recipe. They are also | ||
| 16874 | + // proven to have ARRIVED rather than assumed: the asserts below | ||
| 16875 | + // pin a nonzero rect-partition, tx-depth and 1D-tx-class counter | ||
| 16876 | + // on pixel-compared attempts, one per override. | ||
| 16877 | + let mut args: Vec<&str> = vec![ | ||
| 16878 | + "--codec=av1", | ||
| 16879 | + "--passes=1", | ||
| 16880 | + "--end-usage=q", | ||
| 16881 | + cq, | ||
| 16882 | + "--cpu-used=0", | ||
| 16883 | + "--threads=1", | ||
| 16884 | + "--row-mt=0", | ||
| 16885 | + "--sb-size=64", | ||
| 16886 | + "--enable-ab-partitions=0", | ||
| 16887 | + "--enable-1to4-partitions=0", | ||
| 16888 | + "--enable-restoration=0", | ||
| 16889 | + "--enable-palette=0", | ||
| 16890 | + "--deltaq-mode=0", | ||
| 16891 | + "--enable-filter-intra=0", | ||
| 16892 | + "--enable-cfl-intra=0", | ||
| 16893 | + "--enable-intrabc=0", | ||
| 16894 | + ]; | ||
| 16895 | + if ten_bit { | ||
| 16896 | + args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]); | ||
| 16897 | + } | ||
| 16898 | + args.extend_from_slice(&[ | ||
| 16899 | + "--enable-rect-partitions=1", | ||
| 16900 | + "--enable-tx-size-search=1", | ||
| 16901 | + "--enable-flip-idtx=1", | ||
| 16902 | + // Without this aomenc's reduced tx set narrows every block to | ||
| 16903 | + // DCT_DCT/IDTX and no 1D type can be coded at all -- the flag | ||
| 16904 | + // that actually gates the class, as the arrival assert below | ||
| 16905 | + // proved by staying at 0 without it. | ||
| 16906 | + "--reduced-tx-type-set=0", | ||
| 16907 | + "--min-partition-size=8", | ||
| 16908 | + "--max-partition-size=32", | ||
| 16909 | + "--obu", | ||
| 16910 | + "-o", | ||
| 16911 | + "-", | ||
| 16912 | + "-", | ||
| 16913 | + ]); | ||
| 16914 | + let mut child = Command::new(aomenc_path()) | ||
| 16915 | + .args(&args) | ||
| 16916 | + .stdin(Stdio::piped()) | ||
| 16917 | + .stdout(Stdio::piped()) | ||
| 16918 | + .stderr(Stdio::piped()) | ||
| 16919 | + .spawn() | ||
| 16920 | + .expect("aomenc failed to start"); | ||
| 16921 | + child | ||
| 16922 | + .stdin | ||
| 16923 | + .take() | ||
| 16924 | + .expect("aomenc stdin") | ||
| 16925 | + .write_all(&y4m.stdout) | ||
| 16926 | + .expect("writing y4m to aomenc"); | ||
| 16927 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 16928 | + assert!( | ||
| 16929 | + out.status.success(), | ||
| 16930 | + "aomenc refused the fixture: {}", | ||
| 16931 | + String::from_utf8_lossy(&out.stderr) | ||
| 16932 | + ); | ||
| 16933 | + let stream = out.stdout; | ||
| 16934 | + assert!(!stream.is_empty(), "{NAME}: aomenc wrote an empty stream (seed {seed})"); | ||
| 16935 | + if ten_bit { | ||
| 16936 | + let mut probe = Av1Parser::new(); | ||
| 16937 | + let mut pos = 0usize; | ||
| 16938 | + while pos < stream.len() && probe.sequence_header().is_none() { | ||
| 16939 | + let obu = probe.parse_obu(&stream[pos..]).unwrap(); | ||
| 16940 | + pos += obu.total_size; | ||
| 16941 | + } | ||
| 16942 | + assert_eq!( | ||
| 16943 | + probe | ||
| 16944 | + .sequence_header() | ||
| 16945 | + .expect("stream has a sequence header OBU") | ||
| 16946 | + .color_config | ||
| 16947 | + .bit_depth, | ||
| 16948 | + 10, | ||
| 16949 | + "{NAME}: aomenc did not actually write a 10-bit sequence header" | ||
| 16950 | + ); | ||
| 16951 | + } | ||
| 16952 | + let attempt_before = crate::decode::rect_coeff_tu_hits(); | ||
| 16953 | + let rect_before = crate::decode::rect_partition_hits(); | ||
| 16954 | + let depth_before = crate::decode::tx_depth_hits(); | ||
| 16955 | + let class1_before = crate::decode::tx_class1_hits(); | ||
| 16956 | + let rect_class1_before = crate::decode::rect_class1_hits(); | ||
| 16957 | + let frames = match decode_stream(&stream) { | ||
| 16958 | + Err(e) => { | ||
| 16959 | + let msg = e.to_string(); | ||
| 16960 | + assert!( | ||
| 16961 | + msg.contains("unsupported"), | ||
| 16962 | + "{NAME} failed outright, not a named refusal (seed {seed}, 10bit \ | ||
| 16963 | + {ten_bit}): {msg}" | ||
| 16964 | + ); | ||
| 16965 | + named_refusals += 1; | ||
| 16966 | + continue; | ||
| 16967 | + } | ||
| 16968 | + Ok(frames) => frames, | ||
| 16969 | + }; | ||
| 16970 | + let ffmpeg_frames = if ten_bit { | ||
| 16971 | + ffmpeg_decode_sequence_10bit(&stream, width, height, 1) | ||
| 16972 | + } else { | ||
| 16973 | + ffmpeg_decode_sequence(&stream, width, height, 1) | ||
| 16974 | + }; | ||
| 16975 | + assert_eq!(frames.len(), 1, "{NAME}: expected one frame (seed {seed})"); | ||
| 16976 | + assert_eq!( | ||
| 16977 | + frames[0].y, ffmpeg_frames[0].y, | ||
| 16978 | + "{NAME}: luma vs ffmpeg (seed {seed}, 10bit {ten_bit})" | ||
| 16979 | + ); | ||
| 16980 | + assert_eq!( | ||
| 16981 | + frames[0].u, ffmpeg_frames[0].u, | ||
| 16982 | + "{NAME}: U vs ffmpeg (seed {seed}, 10bit {ten_bit})" | ||
| 16983 | + ); | ||
| 16984 | + assert_eq!( | ||
| 16985 | + frames[0].v, ffmpeg_frames[0].v, | ||
| 16986 | + "{NAME}: V vs ffmpeg (seed {seed}, 10bit {ten_bit})" | ||
| 16987 | + ); | ||
| 16988 | + compared_rect_tus += crate::decode::rect_coeff_tu_hits() - attempt_before; | ||
| 16989 | + compared_rect_parts += crate::decode::rect_partition_hits() - rect_before; | ||
| 16990 | + compared_tx_depths += crate::decode::tx_depth_hits() - depth_before; | ||
| 16991 | + compared_class1 += crate::decode::tx_class1_hits() - class1_before; | ||
| 16992 | + compared_rect_class1 += crate::decode::rect_class1_hits() - rect_class1_before; | ||
| 16993 | + matched += 1; | ||
| 16994 | + matched_10bit += u32::from(ten_bit); | ||
| 16995 | + } | ||
| 16996 | + assert!( | ||
| 16997 | + matched > 0, | ||
| 16998 | + "{NAME}: every attempt refused ({named_refusals} named refusals) -- gate decoded \ | ||
| 16999 | + nothing" | ||
| 17000 | + ); | ||
| 17001 | + assert!( | ||
| 17002 | + matched_10bit > 0, | ||
| 17003 | + "{NAME}: every 10-bit attempt refused -- his films are yuv420p10le, so a gate that \ | ||
| 17004 | + only compared 8-bit streams proves nothing for them" | ||
| 17005 | + ); | ||
| 17006 | + assert!( | ||
| 17007 | + compared_rect_tus > 0, | ||
| 17008 | + "{NAME}: no pixel-exact attempt coded a single rectangular transform unit \ | ||
| 17009 | + ({matched} matches, {named_refusals} refusals out of {n_attempts}) -- the gate \ | ||
| 17010 | + measured nothing about rect coefficient reading" | ||
| 17011 | + ); | ||
| 17012 | + // FLAG ARRIVAL, one assert per override (a flag whose counter stays | ||
| 17013 | + // at 0 is an inert flag, not a passing gate). | ||
| 17014 | + assert!( | ||
| 17015 | + compared_rect_parts > 0, | ||
| 17016 | + "{NAME}: --enable-rect-partitions=1 never produced a rect partition on a compared \ | ||
| 17017 | + attempt ({matched} matches) -- the flag did not arrive" | ||
| 17018 | + ); | ||
| 17019 | + assert!( | ||
| 17020 | + compared_tx_depths > 0, | ||
| 17021 | + "{NAME}: --enable-tx-size-search=1 never produced a nonzero tx depth on a compared \ | ||
| 17022 | + attempt ({matched} matches) -- the flag did not arrive" | ||
| 17023 | + ); | ||
| 17024 | + assert!( | ||
| 17025 | + compared_class1 > 0, | ||
| 17026 | + "{NAME}: --enable-flip-idtx=1 never produced a V_DCT/H_DCT transform on a compared \ | ||
| 17027 | + attempt ({matched} matches) -- the 1D types live only in the extended ext-tx sets \ | ||
| 17028 | + this flag enables, so the flag did not arrive" | ||
| 17029 | + ); | ||
| 17030 | + // lane-rect1d r1: the pin of the LANE's own capability -- a V_DCT/H_DCT | ||
| 17031 | + // transform on a RECTANGULAR transform unit, read through | ||
| 17032 | + // `read_coeffs_rect`'s own 1D scan and contexts. `compared_class1` | ||
| 17033 | + // above counts square TUs too, so it can be nonzero while this path | ||
| 17034 | + // never fires. | ||
| 17035 | + assert!( | ||
| 17036 | + compared_rect_class1 > 0, | ||
| 17037 | + "{NAME}: no pixel-exact attempt put a 1D tx class on a RECTANGULAR transform \ | ||
| 17038 | + ({compared_class1} 1D transforms overall, {compared_rect_tus} rect coefficient \ | ||
| 17039 | + TUs) -- the gate proves nothing about the rect 1D path" | ||
| 17040 | + ); | ||
| 17041 | + eprintln!( | ||
| 17042 | + "{NAME}: {matched} pixel-exact decodes ({named_refusals} named refusals out of \ | ||
| 17043 | + {n_attempts} attempts, {matched_10bit} of the matches 10-bit), rect coefficient \ | ||
| 17044 | + TUs on compared attempts: {compared_rect_tus} ({compared_rect_class1} of them a \ | ||
| 17045 | + 1D tx class); flag arrival: rect partitions {compared_rect_parts}, tx \ | ||
| 17046 | + depths {compared_tx_depths}, 1D-class (square) transforms {compared_class1}" | ||
| 17047 | + ); | ||
| 17048 | + } | ||
| 17049 | + | ||
| 16261 | /// lane-rectsplit r1 gate (c): gate (a)'s recipe with | 17050 | /// lane-rectsplit r1 gate (c): gate (a)'s recipe with |
| 16262 | /// `--enable-filter-intra=1` (every sibling gate here pins it to 0), so | 17051 | /// `--enable-filter-intra=1` (every sibling gate here pins it to 0), so |
| 16263 | /// aomenc's RD is free to pick `use_filter_intra` on a 32x16/16x32 strip | 17052 | /// aomenc's RD is free to pick `use_filter_intra` on a 32x16/16x32 strip |
| @@ -16481,17 +17270,15 @@ mod tests { | |||
| 16481 | } | 17270 | } |
| 16482 | 17271 | ||
| 16483 | /// lane-fistrip r1, the 10-bit arm of the strip gate (his films are | 17272 | /// lane-fistrip r1, the 10-bit arm of the strip gate (his films are |
| 16484 | - /// yuv420p10le). Same ceiling as its 8-bit twin -- kept `#[ignore]`d | 17273 | + /// yuv420p10le). Same ceiling as its 8-bit twin, lifted in lane-rectsplitx |
| 16485 | - /// with the measurement rather than weakened: MEASURED over seeds | 17274 | + /// r3 (the split arm's `smooth_neighbor_uv`); before that, MEASURED over seeds |
| 16486 | /// 42..61 the 8x16/16x8 strips aomenc writes filter intra on are | 17275 | /// 42..61 the 8x16/16x8 strips aomenc writes filter intra on are |
| 16487 | /// `skip=0`, which `decode_leaf_rect` refuses, so | 17276 | /// `skip=0`, which `decode_leaf_rect` refuses, so |
| 16488 | /// `filter_intra_rect_sub16_hits` never reaches a pixel compare. | 17277 | /// `filter_intra_rect_sub16_hits` never reaches a pixel compare. |
| 16489 | /// lane-fistrip r2 adds seeds 49 and 213 to the window: those are the two | 17278 | /// lane-fistrip r2 adds seeds 49 and 213 to the window: those are the two |
| 16490 | /// seeds measured to fire the feature on the 8-BIT twin's recipe (this | 17279 | /// seeds measured to fire the feature on the 8-BIT twin's recipe (this |
| 16491 | /// arm's 10-bit encode is a different stream, so they are a widening, not | 17280 | /// arm's 10-bit encode is a different stream, so they are a widening, not |
| 16492 | - /// a measured firing set for this recipe -- the round that un-ignores | 17281 | + /// a measured firing set for this recipe). Green since r3. |
| 16493 | - /// this gate must re-measure which 10-bit seeds fire it). | ||
| 16494 | - #[ignore = "2026-09-02, re-measured on the merged tree: the coded-strip refusal is lifted, but every firing 10-bit seed now stops at the sub16 SPLIT-TRANSFORM refusal (49, 55) or palette-in-screen-content (45, 46); 16 attempts decode pixel-exact with 0 hits, so the gate would prove nothing"] | ||
| 16495 | #[test] | 17282 | #[test] |
| 16496 | fn a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact() { | 17283 | fn a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact() { |
| 16497 | const NAME: &str = "a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact"; | 17284 | const NAME: &str = "a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact"; |
| @@ -16574,29 +17361,40 @@ mod tests { | |||
| 16574 | .join("fixtures/filter_intra_8x16_strip_seed49.obu"); | 17361 | .join("fixtures/filter_intra_8x16_strip_seed49.obu"); |
| 16575 | let stream = std::fs::read(&path) | 17362 | let stream = std::fs::read(&path) |
| 16576 | .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); | 17363 | .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); |
| 17364 | + if !have_ffmpeg() { | ||
| 17365 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 17366 | + return; | ||
| 17367 | + } | ||
| 16577 | let before = crate::decode::filter_intra_rect_sub16_hits(); | 17368 | let before = crate::decode::filter_intra_rect_sub16_hits(); |
| 16578 | - let err = decode_stream(&stream).expect_err( | 17369 | + // lane-rectsplitx r1: the ceiling this fixture used to stop at (a |
| 16579 | - "{NAME}: this stream's 16x8 filter-intra strip is skip=0, which this decoder \ | 17370 | + // sub-16 strip with a SPLIT transform) is ported, so the pinned |
| 16580 | - still refuses -- a clean decode means the coded-strip ceiling moved and this \ | 17371 | + // stream is now a full pixel compare -- what the doc above said this |
| 16581 | - test should become a pixel compare", | 17372 | + // test should become the round that ceiling lifted. |
| 16582 | - ); | 17373 | + let frames = decode_stream(&stream) |
| 17374 | + .unwrap_or_else(|e| panic!("{NAME}: decode refused: {e}")); | ||
| 16583 | let hits = crate::decode::filter_intra_rect_sub16_hits() - before; | 17375 | let hits = crate::decode::filter_intra_rect_sub16_hits() - before; |
| 17376 | + // TWO now, not the one the truncated decode used to see: the frame | ||
| 17377 | + // no longer stops at the first filter-intra strip, so the second one | ||
| 17378 | + // later in the tile is reached as well (and the pixel compare below | ||
| 17379 | + // proves both reconstructed right). | ||
| 16584 | assert_eq!( | 17380 | assert_eq!( |
| 16585 | - hits, 1, | 17381 | + hits, 2, |
| 16586 | - "{NAME}: expected exactly one 16x8 strip to read use_filter_intra=1 (aomdec's own \ | 17382 | + "{NAME}: expected both 16x8 strips to read use_filter_intra=1; got {hits}" |
| 16587 | - EC_TRACE_MODE shows four BLOCK_16X8 DC_PRED leaves here); got {hits}" | ||
| 16588 | ); | 17383 | ); |
| 16589 | - let msg = err.to_string(); | 17384 | + // This is also the GATE for the sub-16 split-transform lift: both |
| 17385 | + // strips split their transform (`tx_depth != 0` on a BLOCK_16X8 -> | ||
| 17386 | + // two TX_8X8 units), which is the refusal this round removed. | ||
| 17387 | + let splits = crate::decode::sub16_split_hits(); | ||
| 16590 | assert!( | 17388 | assert!( |
| 16591 | - // 2026-09-02, merging lane-fistrip onto a main that already carries | 17389 | + splits > 0, |
| 16592 | - // lane-rectx: the coded-strip ceiling this fixture used to hit is | 17390 | + "{NAME}: no sub-16 strip split its transform -- the fixture no longer proves the \ |
| 16593 | - // gone, and the very next one on the SAME block is the split | 17391 | + per-unit path this test gates" |
| 16594 | - // transform under a sub-16 strip (per-unit rect prediction is not | ||
| 16595 | - // ported). Still a refusal ON that block, still not a desync. | ||
| 16596 | - msg.contains("a HORZ/VERT intra strip below 16x16 with a split transform"), | ||
| 16597 | - "{NAME}: decode must reach the sub16 split-transform ceiling ON that block, not \ | ||
| 16598 | - wander off a desynced stream; got: {msg}" | ||
| 16599 | ); | 17392 | ); |
| 17393 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, 192, 128, 1); | ||
| 17394 | + assert_eq!(frames.len(), 1, "{NAME}: expected one frame"); | ||
| 17395 | + assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg"); | ||
| 17396 | + assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg"); | ||
| 17397 | + assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg"); | ||
| 16600 | } | 17398 | } |
| 16601 | 17399 | ||
| 16602 | /// lane-fistrip r1: the filter-intra strip gate above, one partition | 17400 | /// lane-fistrip r1: the filter-intra strip gate above, one partition |
| @@ -16612,19 +17410,20 @@ mod tests { | |||
| 16612 | /// `filter_intra_rect_hits`: a 32x16 strip firing filter intra would | 17410 | /// `filter_intra_rect_hits`: a 32x16 strip firing filter intra would |
| 16613 | /// satisfy that one and prove nothing about the new shapes. | 17411 | /// satisfy that one and prove nothing about the new shapes. |
| 16614 | /// MEASURED (lane-fistrip r1, seeds 42..=241; r2 re-ran 50..=241), which | 17412 | /// MEASURED (lane-fistrip r1, seeds 42..=241; r2 re-ran 50..=241), which |
| 16615 | - /// is why it is `#[ignore]`d rather than green: over those 200 seeds at | 17413 | + /// is why the window carries the two firing seeds: over those 200 seeds at |
| 16616 | /// cq 25 aomenc put filter intra on an 8x16/16x8 strip exactly TWICE -- | 17414 | /// cq 25 aomenc put filter intra on an 8x16/16x8 strip exactly TWICE -- |
| 16617 | /// **seed 49 and seed 213** -- and both times that strip was `skip=0`, so | 17415 | /// **seed 49 and seed 213** -- and both times that strip was `skip=0`, so |
| 16618 | /// the attempt refused at the coded-rect-strip-below-16x16 ceiling before | 17416 | /// the attempt refused at the coded-rect-strip-below-16x16 ceiling before |
| 16619 | /// any pixel compare (r1: 177 pixel-exact matches, 23 refusals, compared | 17417 | /// any pixel compare (r1: 177 pixel-exact matches, 23 refusals, compared |
| 16620 | /// sub16 delta 0, all-attempt delta 2; r2 seeds 50..=241: 172 matches, 20 | 17418 | /// sub16 delta 0, all-attempt delta 2; r2 seeds 50..=241: 172 matches, 20 |
| 16621 | /// refusals, the one all-attempt hit at seed 213). BOTH firing seeds are | 17419 | /// refusals, the one all-attempt hit at seed 213). BOTH firing seeds are |
| 16622 | - /// appended to this gate's seed window below, so the un-ignore compares | 17420 | + /// appended to this gate's seed window below, so it compares two real |
| 16623 | - /// two real hits. Un-ignore this the round that ceiling lifts; the symbol | 17421 | + /// hits. UN-IGNORED lane-rectsplitx r3: the ceiling lifted with the split |
| 16624 | - /// itself is pinned by | 17422 | + /// refusal, and the residual chroma defect was the split arm of |
| 16625 | - /// [`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`], whose | 17423 | + /// [`crate::decode::decode_leaf_rect`] passing `smooth_neighbor_uv: false` |
| 16626 | - /// `expect_err` must become a pixel compare in that same round. | 17424 | + /// where the unsplit arm passes the neighbour's real answer. The symbol |
| 16627 | - #[ignore = "2026-09-02, re-measured on the merged tree: 35 of 41 attempts decode pixel-exact with ZERO mismatches, but both firing seeds (49, 213) stop at the sub16 split-transform / HORZ_A-B refusals, so no filter-intra 8x16/16x8 strip is compared yet"] | 17425 | + /// itself stays pinned by |
| 17426 | + /// [`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`]. | ||
| 16628 | #[test] | 17427 | #[test] |
| 16629 | fn a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact() { | 17428 | fn a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact() { |
| 16630 | const NAME: &str = | 17429 | const NAME: &str = |
| @@ -17709,8 +18508,18 @@ mod tests { | |||
| 17709 | let mut named_refusals = 0u32; | 18508 | let mut named_refusals = 0u32; |
| 17710 | let mut matched = 0u32; | 18509 | let mut matched = 0u32; |
| 17711 | let (mut horz_proved, mut vert_proved, mut coeff_proved) = (0usize, 0usize, 0usize); | 18510 | let (mut horz_proved, mut vert_proved, mut coeff_proved) = (0usize, 0usize, 0usize); |
| 18511 | + let (mut depth1_proved, mut depth2_proved) = (0usize, 0usize); | ||
| 17712 | let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); | 18512 | let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); |
| 17713 | - for attempt in 0..n_attempts { | 18513 | + // lane-rectsplitx r1: the SECOND half of the attempt window turns |
| 18514 | + // `--enable-tx-size-search` ON at low cq, which is what makes a | ||
| 18515 | + // 32-level 1:4 strip SPLIT its transform -- depth 1 is the 2:1 | ||
| 18516 | + // rect unit TX_16X8/TX_8X16 (`sub_tx_size_map[TX_32X8]`), depth 2 | ||
| 18517 | + // the square TX_8X8, and the two interleave across attempts, so | ||
| 18518 | + // both are asserted (a depth-2-only run leaves the rect-unit path | ||
| 18519 | + // unproved). | ||
| 18520 | + for attempt in 0..n_attempts * 2 { | ||
| 18521 | + let tx_search = attempt >= n_attempts; | ||
| 18522 | + let attempt = attempt % n_attempts; | ||
| 17714 | let seed = 42 + attempt; | 18523 | let seed = 42 + attempt; |
| 17715 | let duration = frame_count as f64 / 25.0; | 18524 | let duration = frame_count as f64 / 25.0; |
| 17716 | // 8-pixel bands: a 32x8 strip is flat, a 32x16 one is not, so | 18525 | // 8-pixel bands: a 32x8 strip is flat, a 32x16 one is not, so |
| @@ -17729,7 +18538,13 @@ mod tests { | |||
| 17729 | geq=lum='mod(floor({axis}/8)*{step},256)',\ | 18538 | geq=lum='mod(floor({axis}/8)*{step},256)',\ |
| 17730 | noise=alls={noise}:all_seed={seed},format=yuv420p" | 18539 | noise=alls={noise}:all_seed={seed},format=yuv420p" |
| 17731 | ); | 18540 | ); |
| 17732 | - let cq_level = format!("--cq-level={}", if attempt % 4 < 2 { 32 } else { 45 }); | 18541 | + let cq_level = if tx_search { |
| 18542 | + // 12..28: the window measured to fire both split depths on | ||
| 18543 | + // this fixture (lanes/tx64x16-r4.handoff.md). | ||
| 18544 | + format!("--cq-level={}", 12 + (attempt % 4) * 5) | ||
| 18545 | + } else { | ||
| 18546 | + format!("--cq-level={}", if attempt % 4 < 2 { 32 } else { 45 }) | ||
| 18547 | + }; | ||
| 17733 | let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | 18548 | let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; |
| 17734 | let y4m = Command::new("ffmpeg") | 18549 | let y4m = Command::new("ffmpeg") |
| 17735 | .args([ | 18550 | .args([ |
| @@ -17770,7 +18585,11 @@ mod tests { | |||
| 17770 | "--enable-filter-intra=0", | 18585 | "--enable-filter-intra=0", |
| 17771 | "--enable-cfl-intra=0", | 18586 | "--enable-cfl-intra=0", |
| 17772 | "--enable-intrabc=0", | 18587 | "--enable-intrabc=0", |
| 17773 | - "--enable-tx-size-search=0", | 18588 | + if tx_search { |
| 18589 | + "--enable-tx-size-search=1" | ||
| 18590 | + } else { | ||
| 18591 | + "--enable-tx-size-search=0" | ||
| 18592 | + }, | ||
| 17774 | "--obu", | 18593 | "--obu", |
| 17775 | "-o", | 18594 | "-o", |
| 17776 | "-", | 18595 | "-", |
| @@ -17801,6 +18620,7 @@ mod tests { | |||
| 17801 | crate::decode::rect4_32_vert_hits(), | 18620 | crate::decode::rect4_32_vert_hits(), |
| 17802 | crate::decode::rect4_coeff_hits(), | 18621 | crate::decode::rect4_coeff_hits(), |
| 17803 | ); | 18622 | ); |
| 18623 | + let split_before = crate::decode::rect4_split_depth_hits(); | ||
| 17804 | let frames = match decode_stream(&stream) { | 18624 | let frames = match decode_stream(&stream) { |
| 17805 | Err(e) => { | 18625 | Err(e) => { |
| 17806 | let msg = e.to_string(); | 18626 | let msg = e.to_string(); |
| @@ -17820,6 +18640,8 @@ mod tests { | |||
| 17820 | crate::decode::rect4_32_vert_hits() - before.1, | 18640 | crate::decode::rect4_32_vert_hits() - before.1, |
| 17821 | crate::decode::rect4_coeff_hits() - before.2, | 18641 | crate::decode::rect4_coeff_hits() - before.2, |
| 17822 | ); | 18642 | ); |
| 18643 | + let split_now = crate::decode::rect4_split_depth_hits(); | ||
| 18644 | + let (d1, d2) = (split_now.0 - split_before.0, split_now.1 - split_before.1); | ||
| 17823 | let ffmpeg_frames = if bit_depth == 10 { | 18645 | let ffmpeg_frames = if bit_depth == 10 { |
| 17824 | ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | 18646 | ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) |
| 17825 | } else { | 18647 | } else { |
| @@ -17870,6 +18692,8 @@ mod tests { | |||
| 17870 | horz_proved += horz; | 18692 | horz_proved += horz; |
| 17871 | vert_proved += vert; | 18693 | vert_proved += vert; |
| 17872 | coeff_proved += coeff; | 18694 | coeff_proved += coeff; |
| 18695 | + depth1_proved += d1; | ||
| 18696 | + depth2_proved += d2; | ||
| 17873 | matched += 1; | 18697 | matched += 1; |
| 17874 | } | 18698 | } |
| 17875 | assert!( | 18699 | assert!( |
| @@ -17893,6 +18717,25 @@ mod tests { | |||
| 17893 | strips={vert_proved}, coded strips={coeff_proved}, {out_of_scope} attempts \ | 18717 | strips={vert_proved}, coded strips={coeff_proved}, {out_of_scope} attempts \ |
| 17894 | carried no 32-level 1:4 block ({out_of_scope_mismatch} mismatched)" | 18718 | carried no 32-level 1:4 block ({out_of_scope_mismatch} mismatched)" |
| 17895 | ); | 18719 | ); |
| 18720 | + // The split-transform halves of the window: both tx depths must | ||
| 18721 | + // have fired inside an attempt that then compared pixel-exact | ||
| 18722 | + // (class counter-from-refused-stream -- a global counter would | ||
| 18723 | + // count strips of attempts that later refused). | ||
| 18724 | + // lane-rectsplitx r2: BOTH depths are now decoded, so both are | ||
| 18725 | + // HARD-asserted -- depth 1 is the 2:1 rect unit | ||
| 18726 | + // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square | ||
| 18727 | + // TX_8X8, and they interleave across the window; a run that only | ||
| 18728 | + // reached one of them proves half the walk. | ||
| 18729 | + assert!( | ||
| 18730 | + depth1_proved > 0 && depth2_proved > 0, | ||
| 18731 | + "{NAME}: {bit_depth}-bit: a 1:4 split-transform depth never fired inside a \ | ||
| 18732 | + pixel-exact attempt (depth1={depth1_proved}, depth2={depth2_proved}) -- the \ | ||
| 18733 | + tx-size-search half of the window proved nothing" | ||
| 18734 | + ); | ||
| 18735 | + eprintln!( | ||
| 18736 | + "{NAME}: {bit_depth}-bit split-transform 1:4 strips: depth1={depth1_proved}, \ | ||
| 18737 | + depth2={depth2_proved}" | ||
| 18738 | + ); | ||
| 17896 | assert_eq!( | 18739 | assert_eq!( |
| 17897 | out_of_scope_mismatch, 0, | 18740 | out_of_scope_mismatch, 0, |
| 17898 | "{NAME}: {bit_depth}-bit: {out_of_scope_mismatch} attempt(s) with zero 32-level \ | 18741 | "{NAME}: {bit_depth}-bit: {out_of_scope_mismatch} attempt(s) with zero 32-level \ |
| @@ -18606,9 +19449,14 @@ mod tests { | |||
| 18606 | // 10-bit half has to carry the shape on its own. | 19449 | // 10-bit half has to carry the shape on its own. |
| 18607 | let mut rect4_strips_10bit = 0usize; | 19450 | let mut rect4_strips_10bit = 0usize; |
| 18608 | let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); | 19451 | let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); |
| 18609 | - // Attempts that stopped at the new named refusal for a 1:4 strip | 19452 | + // 1:4 strips whose transform splits ONCE (the unit is still a 2:1 |
| 18610 | - // whose transform splits once (see the assert at the end). | 19453 | + // rect) that decoded and compared pixel-exact. Until the rectsplitx |
| 18611 | - let mut depth1_refusals = 0u32; | 19454 | + // merge this shape was refused by name and the gate counted the |
| 19455 | + // REFUSALS; counting the decoded hits instead keeps the same | ||
| 19456 | + // territory claim now that the capability landed (class | ||
| 19457 | + // counter-from-refused-stream: only attempts that compared exact | ||
| 19458 | + // count). | ||
| 19459 | + let mut depth1_decoded = 0usize; | ||
| 18612 | for (bit_depth, cq) in [(8u32, 45u32), (8, 32), (8, 60), (10, 45), (10, 32), (10, 60)] { | 19460 | for (bit_depth, cq) in [(8u32, 45u32), (8, 32), (8, 60), (10, 45), (10, 32), (10, 60)] { |
| 18613 | for attempt in 0..n_attempts { | 19461 | for attempt in 0..n_attempts { |
| 18614 | let seed = 42 + attempt; | 19462 | let seed = 42 + attempt; |
| @@ -18618,6 +19466,7 @@ mod tests { | |||
| 18618 | let stream = rectchroma_stream(bit_depth, cq, attempt, width, height); | 19466 | let stream = rectchroma_stream(bit_depth, cq, attempt, width, height); |
| 18619 | let before = crate::decode::rect_split_chroma_shape_hits(); | 19467 | let before = crate::decode::rect_split_chroma_shape_hits(); |
| 18620 | let split_before = crate::decode::rect_split_tx_hits(); | 19468 | let split_before = crate::decode::rect_split_tx_hits(); |
| 19469 | + let depth1_before = crate::decode::rect4_split_depth_hits().0; | ||
| 18621 | let rect4_before = ( | 19470 | let rect4_before = ( |
| 18622 | crate::decode::sb_rect4_horz_hits(), | 19471 | crate::decode::sb_rect4_horz_hits(), |
| 18623 | crate::decode::sb_rect4_vert_hits(), | 19472 | crate::decode::sb_rect4_vert_hits(), |
| @@ -18631,9 +19480,6 @@ mod tests { | |||
| 18631 | {seed}): {msg}" | 19480 | {seed}): {msg}" |
| 18632 | ); | 19481 | ); |
| 18633 | refusals += 1; | 19482 | refusals += 1; |
| 18634 | - if msg.contains("splits only once") { | ||
| 18635 | - depth1_refusals += 1; | ||
| 18636 | - } | ||
| 18637 | all_rect4 += (crate::decode::sb_rect4_horz_hits() - rect4_before.0) | 19483 | all_rect4 += (crate::decode::sb_rect4_horz_hits() - rect4_before.0) |
| 18638 | + (crate::decode::sb_rect4_vert_hits() - rect4_before.1); | 19484 | + (crate::decode::sb_rect4_vert_hits() - rect4_before.1); |
| 18639 | let r4 = (crate::decode::sb_rect4_horz_hits() - rect4_before.0) | 19485 | let r4 = (crate::decode::sb_rect4_horz_hits() - rect4_before.0) |
| @@ -18703,6 +19549,7 @@ mod tests { | |||
| 18703 | proved[k] += after[k] - before[k]; | 19549 | proved[k] += after[k] - before[k]; |
| 18704 | } | 19550 | } |
| 18705 | split_strips += crate::decode::rect_split_tx_hits() - split_before; | 19551 | split_strips += crate::decode::rect_split_tx_hits() - split_before; |
| 19552 | + depth1_decoded += crate::decode::rect4_split_depth_hits().0 - depth1_before; | ||
| 18706 | let rect4 = (crate::decode::sb_rect4_horz_hits() - rect4_before.0) | 19553 | let rect4 = (crate::decode::sb_rect4_horz_hits() - rect4_before.0) |
| 18707 | + (crate::decode::sb_rect4_vert_hits() - rect4_before.1); | 19554 | + (crate::decode::sb_rect4_vert_hits() - rect4_before.1); |
| 18708 | rect4_strips += rect4; | 19555 | rect4_strips += rect4; |
| @@ -18755,11 +19602,11 @@ mod tests { | |||
| 18755 | // tables this round wired are in place for it). This assert is what | 19602 | // tables this round wired are in place for it). This assert is what |
| 18756 | // keeps that from silently regressing to a wrong-pixel decode. | 19603 | // keeps that from silently regressing to a wrong-pixel decode. |
| 18757 | assert!( | 19604 | assert!( |
| 18758 | - depth1_refusals > 0, | 19605 | + depth1_decoded > 0, |
| 18759 | - "{NAME}: no attempt reached a depth-1 1:4 split strip -- the recipe no longer \ | 19606 | + "{NAME}: no attempt decoded a depth-1 1:4 split strip -- the recipe no longer \ |
| 18760 | covers the shape this round fixed" | 19607 | covers the shape this round fixed" |
| 18761 | ); | 19608 | ); |
| 18762 | - eprintln!("{NAME}: {depth1_refusals} attempts refused the depth-1 1:4 split strip by name"); | 19609 | + eprintln!("{NAME}: {depth1_decoded} depth-1 1:4 split strips decoded pixel-exact"); |
| 18763 | } | 19610 | } |
| 18764 | 19611 | ||
| 18765 | /// The chroma-rect gate's fixture + aomenc recipe for one attempt, shared | 19612 | /// The chroma-rect gate's fixture + aomenc recipe for one attempt, shared |
lanes/fiinter-r1.report.mdadded+95 -0
| @@ -0,0 +1,95 @@ | |||
| 1 | +# lane-fiinter r1 -- `use_filter_intra` on an intra block inside an inter frame | ||
| 2 | + | ||
| 3 | +Branch `lane-fiinter`, rebased onto main `eebf24e` (charter's base `lane-intrainter e841b2a` | ||
| 4 | +replayed onto main; no conflicts). | ||
| 5 | + | ||
| 6 | +## Premise, re-measured | ||
| 7 | + | ||
| 8 | +`decode_inter_block`'s INTRA arm and `decode_inter_block8`'s 8x8 INTRA arm read | ||
| 9 | +`y_mode` -> `angle_delta_y` -> `uv_mode` (+cfl/angle) -> palette and then went straight to | ||
| 10 | +`read_block_tx_size` -- no `use_filter_intra` symbol at all, while libaom's | ||
| 11 | +`read_intra_block_mode_info` (decodemv.c) ends with `read_filter_intra_mode_info` in exactly | ||
| 12 | +that place, key frame or inter frame alike. Every inter gate recipe in `stream.rs` spelled | ||
| 13 | +`--enable-filter-intra=0` (69 occurrences), so nothing had ever exercised it; aomenc's own | ||
| 14 | +default is ON, so his films' inter frames desynced silently at the first such block. | ||
| 15 | +Classes: [[symbol-consumption-gap]] + [[tool-disabled-in-every-gate]]. | ||
| 16 | + | ||
| 17 | +## What changed | ||
| 18 | + | ||
| 19 | +- `crates/ec-av1/src/decode.rs:64-80` -- `INTRA_IN_INTER_FILTER_INTRA_HITS` counter + | ||
| 20 | + `intra_in_inter_filter_intra_hits()`, the gate's firing proof (the existing | ||
| 21 | + `FILTER_INTRA_HITS` is also incremented, so the key-frame gates' deltas stay meaningful). | ||
| 22 | +- `crates/ec-av1/src/decode.rs:830-856` -- `ENABLE_FILTER_INTRA_INTER` thread-local, set by | ||
| 23 | + `set_inter_tx_mode(tx_select, reduced_tx_set, enable_filter_intra)`; same frame-constant | ||
| 24 | + stash `TX_SELECT_INTER`/`REDUCED_TX_SET_INTER` already use rather than a 51st | ||
| 25 | + `decode_inter_block` parameter. | ||
| 26 | +- `crates/ec-av1/src/decode.rs:17497+` -- `decode_inter_frame_tile_with_cdfs` takes | ||
| 27 | + `enable_filter_intra` (last param); `decode_inter_frame_tile` passes `false` (this crate's | ||
| 28 | + encoder never writes the sequence bit), `stream.rs:694` passes the sequence header's bit. | ||
| 29 | +- `crates/ec-av1/src/decode.rs:15578-15594` (>=16x16 square intra-in-inter arm) and | ||
| 30 | + `:17188-17204` (8x8 leaf arm) -- `use_filter_intra` read via | ||
| 31 | + `cdfs.filter_intra[filter_intra_size_class(side)]` right after the palette syntax, then | ||
| 32 | + `filter_intra_mode`. `av1_filter_intra_allowed`'s `palette_size[0] == 0` term is implied (a | ||
| 33 | + real palette-Y block already returned by refusal); `filter_intra_size_class` returns `None` | ||
| 34 | + at 64x64, so no symbol is read there, matching `av1_filter_intra_allowed_bsize`. | ||
| 35 | +- Same arms: `filter_intra` now threaded into every LUMA prediction/coefficient call -- | ||
| 36 | + the per-TU split path (`y.reconstruct` and `read_plane` inside the `vartx_leaves` loop, | ||
| 37 | + i.e. lane-intrainter's split-tx path), the whole-block skip `reconstruct`, and the | ||
| 38 | + whole-block `read_plane`. Chroma keeps `None`, exactly as the key-frame square arm does. | ||
| 39 | + `read_plane`'s own `FIMODE_TO_INTRADIR` mapping (decode.rs:7445) supplies the tx_type CDF | ||
| 40 | + row per TU, so lane-tiny's filter-intra tx_type row fix applies here unchanged. | ||
| 41 | + | ||
| 42 | +## Gate | ||
| 43 | + | ||
| 44 | +`stream.rs:4438-4700`: | ||
| 45 | +`a_real_aomenc_inter_sequence_with_filter_intra_on_an_intra_block_decodes_pixel_exact` (8-bit) | ||
| 46 | +and `..._10bit_...` (10-bit), driven by `filter_intra_in_inter_gate(bit_depth)` -- the | ||
| 47 | +intrainter recipe (mandelbrot + hard overlay cut at frame 4, cq30, `--kf-min-dist=1000`, | ||
| 48 | +`--enable-tx-size-search=1`, `--max/min-partition-size=32/16`) with `--enable-filter-intra=1`. | ||
| 49 | +The flag is spelled ONCE (the base `=0` deleted) so no aomenc precedence question arises; | ||
| 50 | +arrival is proved decoder-side by the counter, per COMMON. Every decoded frame's Y/U/V is | ||
| 51 | +compared against ffmpeg; a decode error is only accepted when its message contains | ||
| 52 | +"unsupported"; running out of attempts panics (no SKIP). | ||
| 53 | + | ||
| 54 | +``` | ||
| 55 | +CARGO_TARGET_DIR=$HOME/.cache/cargo-target-fiinter EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 \ | ||
| 56 | + cargo test -p ec-av1 --lib filter_intra_on_an_intra_block -- --nocapture | ||
| 57 | +``` | ||
| 58 | + | ||
| 59 | +EVIDENCE: $HOME/.cache/fiinter-suite.log | cargo test -p ec-av1 --lib filter_intra_on_an_intra_block | 8-bit seed 42: 11 filter-intra intra-in-inter blocks, 8 frames Y/U/V exact; 10-bit seed 47: 8 blocks, 8 frames exact; buckets counted-exact=1 uncounted-exact=0 | ||
| 60 | + | ||
| 61 | +EVIDENCE: negative control (`&& false` in front of both new reads, decode.rs restored after) | same gate command | 8-bit: 40/40 attempts, 0 firings, 33 named refusals + 7 decoded-uncounted -> PANIC. The gate is not vacuous: without the read the stream desyncs. | ||
| 62 | + | ||
| 63 | +EVIDENCE: mutation sweep (`sed 's/--enable-filter-intra=0/=1/g' stream.rs`, restored after) | `cargo test -p ec-av1 --lib inter_sequence` | 15 passed / 0 failed / 2 ignored (both pre-existing `#[ignore]`s: the 10-bit 8x8-leaf-split twin and the tile-column 8x8 gate) -- every inter gate that passed with filter intra OFF still passes with it ON, including `..._split_transform_intra_block_...` at both depths. | ||
| 64 | + | ||
| 65 | +## Refusals | ||
| 66 | + | ||
| 67 | +None lifted -- there was no refusal here, only an unread symbol (which is the worse shape: | ||
| 68 | +`refusal_inventory.rs` is unchanged and stays green). `gate_coverage.rs` needs no edit: its | ||
| 69 | +coverage is derived from the `--enable-*` spellings in the gate source, and the two new tests | ||
| 70 | +spell `--enable-filter-intra=1` at 8 and 10 bit. | ||
| 71 | + | ||
| 72 | +## Residue | ||
| 73 | + | ||
| 74 | +- deferred(a directional-intra-in-inter gate): the `"a nonzero angle delta (this encoder never | ||
| 75 | + writes one)"` refusal in both intra-in-inter arms stays. The symbol read itself is correct | ||
| 76 | + (`cdfs.angle_delta[mode - V_PRED]`, compared to `ANGLE_DELTA_ZERO`), so lifting it is | ||
| 77 | + mechanical -- but lifting a refusal without a gate that fires it is forbidden by COMMON, and | ||
| 78 | + this lane's recipe pins `--enable-angle-delta=0`/`--enable-directional-intra=0` (a nonzero | ||
| 79 | + delta would need its own source family). Unblocked by: an aomenc recipe that puts a | ||
| 80 | + directional intra block with a nonzero delta inside an inter frame. | ||
| 81 | +- accepted: the 8x8-leaf arm's read is size-generic and compiles/decodes, but no gate proves it | ||
| 82 | + FIRED -- this gate pins `--min-partition-size=16`. The mutation sweep ran the 8x8-leaf-split | ||
| 83 | + gates with filter intra ON and they stayed pixel-exact, which bounds the risk but does not | ||
| 84 | + prove the symbol fired at 8x8. | ||
| 85 | +- accepted: CfL/palette parity is unchanged from the key-frame arm -- a real palette-Y/UV block | ||
| 86 | + still refuses by name before the filter-intra read, and `UV_CFL_PRED` chroma alphas are read | ||
| 87 | + as before (filter intra is luma-only). | ||
| 88 | + | ||
| 89 | +## Suite + film | ||
| 90 | + | ||
| 91 | +`cargo test -p ec-av1 --lib` (systemd unit, log `$HOME/.cache/fiinter-suite.log`): **346 passed / 0 failed / 32 ignored**, 739 s. | ||
| 92 | + | ||
| 93 | +EVIDENCE: $HOME/.cache/fiinter-suite.log | systemd-run --user --unit=fiinter-suite ... cargo test -p ec-av1 --lib -j3 | test result: ok. 346 passed; 0 failed; 32 ignored | ||
| 94 | + | ||
| 95 | +EVIDENCE: scratchpad/hg-head.obu | cargo run -p ec-av1 --example decode_probe -- hg-head.obu | 18 frame headers parsed, now stops at `unsupported: AV1 tile (filter intra on a HORZ/VERT strip (this decoder predicts square-only))` -- i.e. his film really does carry filter intra, and the next blocker is the rect-strip filter-intra predictor (another lane), not the unread inter symbol this lane fixed. | ||
lanes/intrainter-r1.handoff.mdadded+70 -0
| @@ -0,0 +1,70 @@ | |||
| 1 | +# lane-intrainter r1 handoff | ||
| 2 | + | ||
| 3 | +Branch `lane-intrainter`, based on main `c729a38` (worktree was already at main's head; no rebase needed). | ||
| 4 | +Code commit: `955ecf9` (`feat(av1): intra blocks in inter frames may split their luma transform`). | ||
| 5 | + | ||
| 6 | +## Implemented (all in `crates/ec-av1/src/decode.rs`) | ||
| 7 | + | ||
| 8 | +- `read_block_tx_size` (~9470): intra branch no longer refuses a split `tx_depth`. It calls | ||
| 9 | + `set_txfm_ctxs` with the RESOLVED transform (so later blocks' txfm ctx is right) and returns | ||
| 10 | + the transform-unit leaf list `(row_mi, col_mi, tx_px)` in raster order — the same shape the | ||
| 11 | + inter var-tx tree returns. | ||
| 12 | +- `decode_inter_block` intra arm (~15490): the leaves ride the existing `vartx_leaves` slot; a | ||
| 13 | + per-TU loop predicts + codes each unit with `txbset_for(tx_px, reduced)` (INTRA tx set), | ||
| 14 | + `default_scan(tx_px)`, `Reach::of_tu` (block-relative availability), `luma_skip_ctx` | ||
| 15 | + (neighbour-magnitude txb_skip ctx, not the lone-TU 0), `around_mi`, `record_mi_luma`. | ||
| 16 | + Skip blocks predict PER UNIT too (an intra block reads tx_depth even when skip). | ||
| 17 | + Chroma is unchanged (its transform is not split). The function tail already ran | ||
| 18 | + `record_split_luma` + per-TU deblock edges whenever `vartx_leaves.is_some()`. | ||
| 19 | +- Inter-frame intra syntax differences all pre-existed in that arm and are unchanged: | ||
| 20 | + `y_mode_cdf[size_group]` (not kf_y_mode), `uv_mode_cfl[mode]`, angle deltas, CfL alphas, | ||
| 21 | + palette-mode probes; angle_delta_y is refused nonzero, filter intra is not read in this arm. | ||
| 22 | +- Counter `INTRA_IN_INTER_SPLIT_TX_HITS` + `intra_in_inter_split_tx_hits() -> [usize;4]` | ||
| 23 | + bucketed by block side 8/16/32/64, one increment per split block. | ||
| 24 | + | ||
| 25 | +## Sizes / refusals | ||
| 26 | + | ||
| 27 | +- Squares 16x16..64x64 through `decode_inter_block` are lifted (the code is size-generic). | ||
| 28 | + OBSERVED FIRING: 16x16 only (12 blocks 8-bit, 1 block 10-bit). 32/64 buckets stayed 0 under | ||
| 29 | + `--min/max-partition-size=16/32`; unproven above 16x16. | ||
| 30 | +- NEW refusal (`decode_inter_block8`, ~17070, listed in refusal_inventory.rs:63 replacing the | ||
| 31 | + lifted string): "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 | ||
| 32 | + transform units" — that leaf path has no per-TU intra prediction loop. | ||
| 33 | +- RECT intra strips in inter frames stay refused earlier ("an intra-coded HORZ/VERT strip needs | ||
| 34 | + rectangular intra prediction this decoder does not code yet"), so no rect work was needed. | ||
| 35 | + | ||
| 36 | +## Gate state — PASSING, both depths | ||
| 37 | + | ||
| 38 | +`a_real_aomenc_inter_sequence_with_a_split_transform_intra_block_decodes_pixel_exact` and | ||
| 39 | +`a_real_aomenc_10bit_...` (`intra_in_inter_split_tx_gate` in stream.rs). | ||
| 40 | +Real aomenc, 64x64, 8 frames, mandelbrot zoom with a HARD CUT at frame 4 | ||
| 41 | +(`overlay=enable='gte(n,4)'`), `--kf-min-dist=1000 --kf-max-dist=1000` (stops the scene-cut | ||
| 42 | +detector inserting a second key frame), cq 30, overrides appended LAST. All frames Y/U/V vs | ||
| 43 | +ffmpeg; decode errors only continue if they contain "unsupported"; exhausting 40 attempts panics. | ||
| 44 | + | ||
| 45 | +Run: | ||
| 46 | +`EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-intrainter cargo test -p ec-av1 --lib -- split_transform_intra_block --nocapture` | ||
| 47 | + | ||
| 48 | +Result: 8-bit seed 45 `16x16=12`, 10-bit seed 72 `16x16=1`, 0 differing samples, both `ok`. | ||
| 49 | +No entropy ladder was needed — no divergence was ever observed. | ||
| 50 | + | ||
| 51 | +## Suite | ||
| 52 | + | ||
| 53 | +`$HOME/.cache/intrainter-suite.log` (unit `intrainter-suite-1788315424.service`), completed after | ||
| 54 | +the turn cap: `test result: ok. 341 passed; 0 failed; 31 ignored; 0 measured` in 457.31s. Nothing | ||
| 55 | +further is owed on the suite. | ||
| 56 | + | ||
| 57 | + | ||
| 58 | +## Film | ||
| 59 | + | ||
| 60 | +Both `.../b6d8a07f.../scratchpad/reelc-head.obu` and `.../cdc46329.../scratchpad/reelc5.obu` stop at | ||
| 61 | +"a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here" (lane-rectchroma | ||
| 62 | +territory), NOT at this lane's refusal — the wall string in the charter was not reproducible on | ||
| 63 | +these extracts (matches an existing ledger dead-end line). | ||
| 64 | + | ||
| 65 | +## Exact next step | ||
| 66 | + | ||
| 67 | +1. Merge (suite already green). | ||
| 68 | +2. Optional follow-up round: prove 32x32/64x64 split intra-in-inter blocks (raise | ||
| 69 | + `--max-partition-size` to 64 and lower cq, assert the 32/64 buckets), and lift the 8x8 leaf's | ||
| 70 | + TX_4X4 2x2 grid in `decode_inter_block8`. | ||
lanes/intrainter-r1.report.mdadded+63 -0
| @@ -0,0 +1,63 @@ | |||
| 1 | +# lane-intrainter r1 — intra blocks in inter frames with a split luma transform | ||
| 2 | + | ||
| 3 | +Branch `lane-intrainter` off main `c729a38` (worktree already at main's head; no rebase needed). | ||
| 4 | +Commit: `955ecf9`. | ||
| 5 | + | ||
| 6 | +## What changed | ||
| 7 | + | ||
| 8 | +- `crates/ec-av1/src/decode.rs` `read_block_tx_size` (~9470): the intra branch no longer | ||
| 9 | + refuses a `tx_depth` that resolves below the block side. It runs `set_txfm_ctxs` with the | ||
| 10 | + resolved transform (so later blocks' txfm ctx is right) and returns the transform-unit leaf | ||
| 11 | + list in the same `(row_mi, col_mi, tx_px)` shape the inter var-tx tree uses, raster order. | ||
| 12 | +- `crates/ec-av1/src/decode.rs` `decode_inter_block` intra arm (~15490): the returned leaves ride | ||
| 13 | + the existing `vartx_leaves` slot, and a per-TU loop predicts + codes each unit | ||
| 14 | + (`txbset_for(tx_px, reduced)`, `default_scan(tx_px)`, `Reach::of_tu`, `luma_skip_ctx`, | ||
| 15 | + `around_mi`, `record_mi_luma`) exactly as `decode_block`'s key-frame multi-TU branch does — | ||
| 16 | + including the skip case, which predicts per unit rather than whole-block. Chroma is unchanged | ||
| 17 | + (its transform is not split). The function tail already did `record_split_luma` and per-TU | ||
| 18 | + deblock edges whenever `vartx_leaves.is_some()`, so intra split blocks inherit both. | ||
| 19 | +- `crates/ec-av1/src/decode.rs` counter `INTRA_IN_INTER_SPLIT_TX_HITS` + | ||
| 20 | + `intra_in_inter_split_tx_hits() -> [usize; 4]` (bucketed 8/16/32/64), incremented once per | ||
| 21 | + split intra-in-inter block. | ||
| 22 | +- `crates/ec-av1/src/decode.rs` `decode_inter_block8` (~17070): an 8x8 intra leaf whose depth | ||
| 23 | + resolves to TX_4X4 has no per-TU intra loop in that path — refused by name. | ||
| 24 | +- `crates/ec-av1/src/refusal_inventory.rs:63`: lifted string replaced by the narrower | ||
| 25 | + `"an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units"`. | ||
| 26 | +- `crates/ec-av1/src/stream.rs`: new gate `intra_in_inter_split_tx_gate` + its 8/10-bit tests. | ||
| 27 | + | ||
| 28 | +## Gate | ||
| 29 | + | ||
| 30 | +`a_real_aomenc_inter_sequence_with_a_split_transform_intra_block_decodes_pixel_exact` | ||
| 31 | +and `..._10bit_...`. Real aomenc, 64x64, 8 frames, mandelbrot zoom with a HARD CUT at frame 4 | ||
| 32 | +(`overlay=enable='gte(n,4)'` of a second fractal) so aomenc codes intra blocks inside an inter | ||
| 33 | +frame; `--kf-min-dist=1000 --kf-max-dist=1000` stops the scene-cut detector inserting a second | ||
| 34 | +key frame. Overrides (`--enable-tx-size-search=1`, `--enable-rect-partitions=0`, | ||
| 35 | +`--max-partition-size=32`, `--min-partition-size=16`) are appended AFTER the base recipe | ||
| 36 | +(last occurrence wins). Every decoded frame's Y, U and V are compared with ffmpeg; a decode | ||
| 37 | +error only continues the attempt loop if it contains "unsupported"; exhausting all 40 attempts | ||
| 38 | +is a panic, never a SKIP. | ||
| 39 | + | ||
| 40 | +Run: | ||
| 41 | +`EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-intrainter cargo test -p ec-av1 --lib -- split_transform_intra_block --nocapture` | ||
| 42 | + | ||
| 43 | +EVIDENCE: $HOME/.cache/intrainter-suite.log | aomenc cut-fractal stream, ours vs ffmpeg, all 8 frames Y/U/V | 8-bit seed 45: 12 split intra-in-inter 16x16 blocks, 0 differing samples; 10-bit seed 72: 1 such block, 0 differing samples | ||
| 44 | + | ||
| 45 | +## Suite | ||
| 46 | + | ||
| 47 | +`EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-intrainter cargo test -p ec-av1 --lib` | ||
| 48 | +(as user unit `intrainter-suite-1788315424.service`, log `$HOME/.cache/intrainter-suite.log`): | ||
| 49 | +`test result: ok. 341 passed; 0 failed; 31 ignored; 0 measured` in 457.31s — includes every sibling | ||
| 50 | +(inter_sequence*, tx_select, 8x8_leaf_split, split_transform_*, filter_intra_*, cfl, | ||
| 51 | +refusal_inventory, gate_coverage). | ||
| 52 | + | ||
| 53 | +## Film | ||
| 54 | + | ||
| 55 | +`reelc-head.obu` and `reelc5.obu` both stop at "a coded HORZ/VERT strip whose chroma transform has no | ||
| 56 | +rect coefficient tables here" (lane-rectchroma), not at this lane's refusal. | ||
| 57 | + | ||
| 58 | +## Residue | ||
| 59 | + | ||
| 60 | +- deferred(a follow-up arm at --max-partition-size=64 and a lower cq): 32x32/64x64 split | ||
| 61 | + intra-in-inter blocks never fired; the per-TU loop is size-generic but unproven above 16x16. | ||
| 62 | +- deferred(a per-TU intra loop inside decode_inter_block8): the 8x8 leaf's TX_4X4 2x2 grid, | ||
| 63 | + now the narrower named refusal. | ||
lanes/modectx-r1.report.mdadded+93 -0
| @@ -0,0 +1,93 @@ | |||
| 1 | +# lane-modectx r1 — the luma mode-context readers, and the charter's premise | ||
| 2 | + | ||
| 3 | +Base: `lane-rectsplitx` cbf8ffd (NOT rebased onto main — `git rebase main` conflicts in | ||
| 4 | +`crates/ec-av1/src/decode.rs` + `refusal_inventory.rs` because lane-rectsplitx is not merged | ||
| 5 | +yet; aborted, work stays on cbf8ffd as chartered. Deviation from COMMON's "rebase first"). | ||
| 6 | + | ||
| 7 | +## 1. The pinned defect does NOT reproduce on this base (charter premise stale) | ||
| 8 | + | ||
| 9 | +Stream pinned by the charter (192x128, 8-bit, seed 48, axis Y, step 103, noise 12, cq 32, | ||
| 10 | +32x32_level_1to4 recipe), regenerated twice: | ||
| 11 | + | ||
| 12 | +``` | ||
| 13 | +36cd6fae68d91d4b1fdbb77d7a7854b46a535f727a8b12094411ab0185d07673 a.obu | ||
| 14 | +36cd6fae68d91d4b1fdbb77d7a7854b46a535f727a8b12094411ab0185d07673 b.obu | ||
| 15 | +``` | ||
| 16 | + | ||
| 17 | +There is no `mode` divergence at mi(24,8). Our `EC_TRACE_MODE_STEP` ladder is IDENTICAL to the | ||
| 18 | +instrumented aomdec's (`name=dq` excluded: our `val` field carries a different quantity there, | ||
| 19 | +range identical) up to the last element we read, and we then stop on a REFUSAL, not a desync: | ||
| 20 | + | ||
| 21 | +* ours: 48 non-dq ladder lines, last `mi_row=6 mi_col=8 name=angle_uv val=0 rng=37000` | ||
| 22 | + == aomdec line 48 exactly; then | ||
| 23 | + `REFUSED: unsupported: AV1 tile (a HORZ_A/HORZ_B/VERT_A partition below 16x16 ...)`. | ||
| 24 | +* aomdec `EC_TRACE=1` confirms the stream really does code that partition: | ||
| 25 | + `EC_PART mi_row=8 mi_col=0 bsize=6 ctx=4 ... EC_PART_VAL value=4` (= `PARTITION_HORZ_A` at | ||
| 26 | + 16x16) — aomenc emits an AB partition at 16x16 despite `--enable-ab-partitions=0`. | ||
| 27 | + So the cq-32 arm of this fixture is blocked by a real, named capability gap (16x16 AB | ||
| 28 | + partitions), not by a mode-context defect. | ||
| 29 | + | ||
| 30 | +At the gate's own cq for this attempt (attempt 6 uses `--cq-level=45`, seed 48 axis Y step 103 | ||
| 31 | +noise 12 — i.e. the charter's stream IS already in the gate window) the frame decodes and the | ||
| 32 | +whole ladder matches, before and after this lane's change. | ||
| 33 | + | ||
| 34 | +Conclusion: the mi(24,8) `kf_y_mode` divergence lane-band63 r1 pinned was fixed by | ||
| 35 | +lane-rectsplitx ec0b3b5 ("a 1:4 strip read its neighbour MODE from a 16px-coarse band"), which | ||
| 36 | +is in this lane's base. Item (4) of the charter (add seed 48 to the gate window) needs no new | ||
| 37 | +pin: it is attempt 6 of the existing window and passes. | ||
| 38 | + | ||
| 39 | +EVIDENCE: /tmp/.../scratchpad/{a.obu,ours.log,ref.log,ours45.log,ref45.log} | regenerate the | ||
| 40 | +pinned stream twice (identical sha256), decode with EC_TRACE_MODE_STEP under ours + instrumented | ||
| 41 | +aomdec, diff ladders | cq32: 48/48 ladder lines identical then a named refusal (aomdec EC_PART | ||
| 42 | +value=4 = HORZ_A at 16x16); cq45: 0 ladder differences, `OK: 1 frames decoded`. | ||
| 43 | + | ||
| 44 | +## 2. What did change: availability-correct coarse fallback (class new-map-ignores-tile-edge) | ||
| 45 | + | ||
| 46 | +`Neighbours::modes_above_left` (decode.rs:4005) — the entry point of every remaining coarse | ||
| 47 | +reader (`decode_block_rect` :5182, `decode_block_rect64` :6169, `decode_block` :7442) — took the | ||
| 48 | +mi-exact override first but then fell back to the raw `above_mode`/`left_mode` band with NO | ||
| 49 | +tile-relative availability. It now routes through `modes_above_left_mi`, which returns `DC_PRED` | ||
| 50 | +where libaom's `up_available`/`left_available` are false. Same for the two raw-band leaf sites, | ||
| 51 | +`decode_leaf_split4` (:8348) and `decode_leaf_rect8` (:8547), which read | ||
| 52 | +`neighbours.above_mode[c]`/`left_mode[r]` directly as their per-leaf fallback. | ||
| 53 | + | ||
| 54 | +Measured result of the fix: **zero behavioural change**, and that is now asserted. New counter | ||
| 55 | +`MODE_TILE_EDGE_COARSE_LEAKS` counts every coarse fallback at a tile edge that held a non-DC | ||
| 56 | +mode; over the 20 attempts of | ||
| 57 | +`a_real_aomenc_stream_with_two_tile_columns_decodes_pixel_exact` it is 0, because `above_mode` | ||
| 58 | +is cleared per tile in `start_tile` and `left_mode` per superblock row in `start_row`. The gate | ||
| 59 | +now asserts `== 0` — the invariant that makes the coarse fallback safe, and the thing that | ||
| 60 | +would regress if either reset were dropped (that is exactly how lane-mtfix's chroma | ||
| 61 | +`above_uv_mode` twin broke). | ||
| 62 | + | ||
| 63 | +Honest statement: this is hardening plus a regression guard, not a defect fix. No stream in the | ||
| 64 | +suite changes. | ||
| 65 | + | ||
| 66 | +## 3. Band granularity sweep (charter item 3) | ||
| 67 | + | ||
| 68 | +| band | granularity | availability guard | can an 8/4-px strip alias it? | | ||
| 69 | +|---|---|---|---| | ||
| 70 | +| `above_mode`/`left_mode` | SUB (16px) | now tile-relative via `modes_above_left_mi` | yes, but only as a fallback — `sub8_mode_col/row` (mi) is primary and always written by `record_mode_mi` | | ||
| 71 | +| `above_uv_mode`/`left_uv_mode` | SUB | tile-relative in `smooth_uv_neighbour` (mi primary, `uv_mode_col/row`) | same shape as luma; primary is mi-exact | | ||
| 72 | +| `above_side`/`left_side` | SUB | — | WRITE-ONLY: no reader left (partition ctx uses `above_side_mi`/`left_side_mi`, mi-granular). Dead state, left alone this round | | ||
| 73 | +| `above_side_mi`/`left_side_mi` | mi | reset in `start_tile`/`start_row` | no | | ||
| 74 | +| `above_skip`/`skip_mode`/`inter`/`ref`/`ref1`/`comp_group_idx`/`compound_idx`/`filter`/`txfm` | mi | reset per tile/row | no | | ||
| 75 | +| `skip_grid`/`tx_grid`/`tx_h_grid`/`uv_tx_grid`/`ref_grid`/`delta_lf_grid` | mi, 2-D | absolute mi coords | no | | ||
| 76 | +| `above_palette_size/colors`, `left_palette_size/colors` (+ `_uv_`) | **SUB, square-only writer** | above: `r % 4 != 0`; left: tile-relative | **YES** — `record_palette_y` loops `0..side/SUB`, so a 32x8 / 8x32 palette strip writes NOTHING on its short axis and leaves an older block's palette cache in the cell; four 32x8 strips also share one left cell | | ||
| 77 | + | ||
| 78 | +The palette row is the one live instance of the charter's "last strip wins" class that remains. | ||
| 79 | +It is NOT fixed here: every 1:4 / rect-strip gate runs `--enable-palette=0`, so there is no | ||
| 80 | +stream in the repo that can prove or disprove it, and a blind fix would be an unverified change | ||
| 81 | +to lane-palette2's territory. | ||
| 82 | +Disposition: deferred(needs a real aomenc stream with `--enable-palette=1` that codes a 32x8 or | ||
| 83 | +8x32 palette strip — same fixture family, palette enabled, screen-content source). | ||
| 84 | + | ||
| 85 | +## 4. Suite | ||
| 86 | + | ||
| 87 | +`cargo test -p ec-av1 --lib` (systemd unit, EC_AV1_REQUIRE_AOMENC=1): **335 passed; 0 failed; 29 ignored** (768.77s), log `$HOME/.cache/modectx-suite.log`. | ||
| 88 | + | ||
| 89 | +EVIDENCE: $HOME/.cache/modectx-suite.log | `systemd-run --user --unit=modectx-suite-1788316736 ... cargo test -p ec-av1 --lib -j3` on 4339963 | test result: ok. 335 passed; 0 failed; 29 ignored | ||
| 90 | + | ||
| 91 | +Gate re-run of the charter siblings is inside that suite run (32x32_level_1to4, superblock_level_1to4, | ||
| 92 | +split_transform_*, coded_rect_strip_below_16x16, sub8_*, filter_intra_*, multi_tile/two+four tile | ||
| 93 | +columns and tile rows, tiny sweep, refusal_inventory, gate_coverage — all ok). | ||
lanes/rect1d-r1.report.mdadded+77 -0
| @@ -0,0 +1,77 @@ | |||
| 1 | +# lane-rect1d r1 — the 1D-tx-class-on-a-rect-transform gate, and the defect it exposed | ||
| 2 | + | ||
| 3 | +Branch `lane-rect1d` off main `eebf24e`. One commit: `6faae24`. | ||
| 4 | + | ||
| 5 | +## What changed | ||
| 6 | + | ||
| 7 | +- `crates/ec-av1/src/decode.rs:5773` — `decode_leaf_rect`'s `tx_depth` symbol now reads | ||
| 8 | + `cdfs.tx_size_cat1[ctx]`, was `cdfs.tx_size_cat2[ctx]`. **The defect.** | ||
| 9 | +- `crates/ec-av1/src/decode.rs:978` — `RECT_COEFF_TU_HITS` + `RECT_CLASS1_HITS` counters | ||
| 10 | + (`rect_coeff_tu_hits()` / `rect_class1_hits()`), bumped in `read_coeffs_rect` at | ||
| 11 | + `:2943` and `:2960`. | ||
| 12 | +- `crates/ec-av1/src/stream.rs:15570` — the gate | ||
| 13 | + `a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform_decodes_pixel_exact`, | ||
| 14 | + copied from lane-rectclass `ef7a476` minus its two refusal strings (they no longer | ||
| 15 | + exist on main — lane-tx4x8 ported the 1D arms) and minus the now-vacuous | ||
| 16 | + `class1_refusals == 0` assert; plus one new hard assert `compared_rect_class1 > 0`. | ||
| 17 | +- `crates/ec-av1/src/gate_coverage.rs:229` — `enable-flip-idtx` leaves `NEVER_EXERCISED_10BIT` | ||
| 18 | + (`enable-tx-size-search` was already off that list on this tree). | ||
| 19 | +- `crates/ec-av1/examples/dump_yuv.rs` — new: raw `u16` plane dump. Both existing prefilt | ||
| 20 | + dumps (ours and the instrumented aomdec) write `as u8`, which is blind to a 10-bit | ||
| 21 | + mismatch by construction. | ||
| 22 | + | ||
| 23 | +## Root cause | ||
| 24 | + | ||
| 25 | +libaom `blockd.h:1344 bsize_to_tx_size_cat` = `bsize_to_tx_size_depth_table[bsize] - 1`. | ||
| 26 | +BLOCK_16X8/8X16 (and the 1:4 BLOCK_16X4/4X16 `decode_leaf_rect` also decodes) are depth 2 → | ||
| 27 | +category **1**, the same table a 16x16 square block reads. Category 2 belongs to the | ||
| 28 | +32-level shapes. Both tables carry three symbols, so the wrong row decodes a *plausible* | ||
| 29 | +depth from the wrong probabilities — the msac range diverges silently at the first such | ||
| 30 | +leaf and every later symbol in the tile is read from the wrong place. Class: same shape as | ||
| 31 | +`cdf-row-held-constant` / `wrong-alphabet-same-value`, here same alphabet, wrong row. | ||
| 32 | +This only surfaces with `--enable-tx-size-search=1`; 11 of 15 gate recipes pin it to 0, | ||
| 33 | +which is why the tree was green. | ||
| 34 | + | ||
| 35 | +Sweep of the whole class (every `tx_size_cat*` read, `grep -n tx_size_cat crates/ec-av1/src/decode.rs`): | ||
| 36 | +`decode_block_rect` 32x16/16x32 → cat2 ✅, `decode_block_rect4` 32x8/8x32 → cat2 ✅, | ||
| 37 | +`decode_block_rect64` 64x32/32x64/64x16/16x64 → cat3 ✅, sub-8 4x8/8x4 leaf → cat0 ✅, | ||
| 38 | +square `read_tx_size` 8/16/32/64 → cat0/1/2/3 ✅. `decode_leaf_rect` was the only wrong site. | ||
| 39 | + | ||
| 40 | +## Evidence | ||
| 41 | + | ||
| 42 | +EVIDENCE: /home/user/.cache/rect1d/s42a.obu (sha256 5b3c8fc94b8e01f59755a4534eae7f5f9037440b5e4040357105b5a1d0dd395c, identical on two independent aomenc runs) | ffmpeg lavfi sinusoidal stripes 192x128 10-bit → aomenc `--reduced-tx-type-set=0 --enable-rect-partitions=1 --enable-tx-size-search=1 --enable-flip-idtx=1` → `dump_yuv` vs `ffmpeg -pix_fmt yuv420p10le` | luma differs at 846 samples before the fix (first at row 94 col 175, 509 vs 510; max |Δ| 551, all in the bottom-right of the frame), **0 differing samples after** | ||
| 43 | + | ||
| 44 | +EVIDENCE: /home/user/.cache/rect1d/ours.both + aom.both (EC_TRACE_COEFF + mode traces) | range ladder ours vs instrumented aomdec through the pinned stream | first 105 transform units' `all_zero`/`base`/`br`/`sign` ranges identical; TU 106 (block mi_row=24 mi_col=44, BLOCK_16X8) diverged: mode ladder agreed through `uv_mode` (rng 50640 both), then aomdec `EC_ISTEP name=tx_depth val=0 ctx=2 cat=1 rng=60682` against our cat-2 read (our next `all_zero` came out at rng 36870 vs its 60086) — **first divergent element = the `tx_depth` symbol's CDF row** | ||
| 45 | + | ||
| 46 | +EVIDENCE: gate output | `cargo test -p ec-av1 --lib a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform -- --nocapture` | `12 pixel-exact decodes (0 named refusals out of 12 attempts, 6 of the matches 10-bit), rect coefficient TUs on compared attempts: 219 (10 of them a 1D tx class); flag arrival: rect partitions 120, tx depths 53, 1D-class (square) transforms 13` — before the fix the same gate panicked at seed 42 10-bit | ||
| 47 | + | ||
| 48 | +## Tests | ||
| 49 | + | ||
| 50 | +`cargo test -p ec-av1 --lib` (systemd unit, `$HOME/.cache/rect1d-suite.log`): see the | ||
| 51 | +trailer line appended below by the run. | ||
| 52 | + | ||
| 53 | +## Residue | ||
| 54 | + | ||
| 55 | +- accepted: `decode_leaf_rect` still refuses a *split* transform at this level | ||
| 56 | + ("a HORZ/VERT intra strip below 16x16 with a split transform"). The depth symbol is now | ||
| 57 | + read from the right table, so a `depth != 0` leaf refuses by name instead of desyncing; | ||
| 58 | + porting per-unit rect prediction is its own lane. | ||
| 59 | +- deferred: the 4x16/16x4 shapes share category 1 and this fix covers them, but no gate | ||
| 60 | + recipe in the tree is known to produce one — unblocks with a 1:4-at-16-level gate. | ||
| 61 | + | ||
| 62 | +## Handoff (turn cap) | ||
| 63 | + | ||
| 64 | +The lane is COMPLETE, not WIP: the defect is found, fixed, and gated. The only thing not | ||
| 65 | +witnessed by me is the tail of the full-suite run — it was still executing (179 tests | ||
| 66 | +printed, no `FAILED`, no `test result:` line yet) when my turn cap hit. Check with | ||
| 67 | +`grep -E "^test result|FAILED" $HOME/.cache/rect1d-suite.log`; it is a plain | ||
| 68 | +`cargo test -p ec-av1 --lib` under a systemd unit, nothing else to redo. | ||
| 69 | + | ||
| 70 | +Reproduce the original defect on main `eebf24e` (before `6faae24`): | ||
| 71 | +``` | ||
| 72 | +bash ~/.cache/rect1d/gen.sh /tmp/s42 # ffmpeg lavfi + aomenc, 10-bit, seed 42 | ||
| 73 | +cargo run -p ec-av1 --example dump_yuv -- /tmp/s42.obu /tmp/ours | ||
| 74 | +ffmpeg -v error -i /tmp/s42.obu -pix_fmt yuv420p10le -f rawvideo /tmp/ref.yuv | ||
| 75 | +cmp /tmp/ours.f0.yuv /tmp/ref.yuv # 846 differing luma samples before, 0 after | ||
| 76 | +``` | ||
| 77 | +or just `cargo test -p ec-av1 --lib a_real_aomenc_stream_with_a_1d_tx_class_on_a_rect_transform`. | ||
lanes/rectsplitx-r1.report.mdadded+105 -0
| @@ -0,0 +1,105 @@ | |||
| 1 | +# lane-rectsplitx r1 report | ||
| 2 | + | ||
| 3 | +Branch `lane-rectsplitx` off main `8262b99`. | ||
| 4 | + | ||
| 5 | +## What changed | ||
| 6 | + | ||
| 7 | +- `crates/ec-av1/src/decode.rs` | ||
| 8 | + - `decode_rect_split` is now **mi-granular** (`at_mi`) and takes the transform | ||
| 9 | + unit as `(tx_w, tx_h)` instead of one square `tx`: it can name a strip that | ||
| 10 | + starts 8 px into a 16-px `SUB` cell, and it walks rectangular units. | ||
| 11 | + Chroma map gained `(32,8)/(8,32)` (`Chroma16`), `(16,4)/(4,16)` (`Chroma8`) | ||
| 12 | + and `(8,4)/(4,8)` (`ChromaRect8x4`). | ||
| 13 | + - new `depth_to_tx_wh(bw, bh, depth)` -- libaom `depth_to_tx_size`: every | ||
| 14 | + `sub_tx_size_map` entry halves the LONGER side of a rect and both sides of | ||
| 15 | + a square, so a 1:4 strip's first split is still a 2:1 RECT unit | ||
| 16 | + (`TX_32X8 -> TX_16X8`, `TX_64X16 -> TX_32X16`). Replaces the | ||
| 17 | + `bw.min(bh) >> (depth - 1)` formula at BOTH 2:1 call sites; it is the same | ||
| 18 | + root cause lane-rectchroma measured mis-tiling a depth-1 64x16 strip, fixed | ||
| 19 | + once for every caller instead of per shape. | ||
| 20 | + - new `tx_type_mode_row(mode, filter_intra)` -- the `fimode_to_intradir` row | ||
| 21 | + rule main `1a89ed9` fixed inside `read_plane`, now also applied to | ||
| 22 | + `decode_leaf_rect`'s rect luma coefficient read (same defect class, sibling | ||
| 23 | + site found by sweeping every `cdfs.txb(<luma set>, mode)` call: the other | ||
| 24 | + luma rect sets are `tx_size_sqr_up >= TX_32X32`, i.e. DCT-only, no symbol). | ||
| 25 | + - **`decode_leaf_rect` read the wrong tx_size CDF category**: BLOCK_16X8 / | ||
| 26 | + BLOCK_8X16 are `bsize_to_tx_size_cat == 1` (libaom | ||
| 27 | + `bsize_to_tx_size_depth_table`), not the 2 the 32x16 strips use. Same | ||
| 28 | + symbol count, different CDF row -- a wrong-table read of a real symbol. | ||
| 29 | + - `decode_leaf_rect`'s split refusal is **lifted**: a 16x8/8x16 strip with | ||
| 30 | + `tx_depth != 0` decodes per transform unit (TX_8X8 at depth 1, TX_4X4 at | ||
| 31 | + depth 2). | ||
| 32 | + - `Neighbours`: `record_mi_luma_rect`, `luma_skip_ctx_rect`, | ||
| 33 | + `record_split_luma_rect_mi` (coarse mode/side cells stamped with | ||
| 34 | + `div_ceil`, so an 8-px-tall strip stamps the cell it touches). | ||
| 35 | +- `crates/ec-av1/src/stream.rs` | ||
| 36 | + - `a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag` is now a PIXEL | ||
| 37 | + COMPARE (was `expect_err`) and additionally asserts `sub16_split_hits > 0`: | ||
| 38 | + it is the gate for the sub-16 split lift. | ||
| 39 | + - the 32x32-level 1:4 gate gained a `--enable-tx-size-search=1` half of its | ||
| 40 | + attempt window (cq 12..28), which keeps the 1:4 split refusals honest. | ||
| 41 | +- `crates/ec-av1/src/refusal_inventory.rs` updated (one refusal removed, two | ||
| 42 | + added). | ||
| 43 | + | ||
| 44 | +## Refusals | ||
| 45 | + | ||
| 46 | +Lifted: "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit | ||
| 47 | +rect prediction is not ported)". | ||
| 48 | + | ||
| 49 | +Added (both MEASURED, not speculative): | ||
| 50 | +- "a split intra strip whose transform unit is the rect {tx_w}x{tx_h} ..." -- | ||
| 51 | + the per-unit RECT walk (depth 1 of a 1:4 strip) is implemented but mismatched | ||
| 52 | + ffmpeg on the band fixture (8-bit, cq 12, seed 42), so it refuses instead of | ||
| 53 | + shipping wrong pixels. | ||
| 54 | +- "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma | ||
| 55 | + coefficient tables ...)" -- shape guard for the next caller. | ||
| 56 | + | ||
| 57 | +Kept: "a 32x32-level 1:4 strip with a split transform (... depth={depth})". | ||
| 58 | +Reason: depth 1 fires FIRST in every splitting attempt of the fixture, so no | ||
| 59 | +attempt ever reaches a pixel-compared depth-2 strip -- a depth-2-only lift is | ||
| 60 | +ungatable, and an ungated lift is not a lift (the tx64x16 r4 handoff predicted | ||
| 61 | +exactly this interleaving). | ||
| 62 | + | ||
| 63 | +## Gates | ||
| 64 | + | ||
| 65 | +- `a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag` -- **ok**. | ||
| 66 | + EVIDENCE: crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu | cargo | ||
| 67 | + test -p ec-av1 --lib -- a_pinned_aomenc_16x8_strip | whole frame Y+U+V equal | ||
| 68 | + to ffmpeg, filter_intra_rect_sub16 hits 2 (was 1 under the truncated decode), | ||
| 69 | + sub16_split_hits > 0. | ||
| 70 | +- `a_real_aomenc_stream_with_a_32x32_level_1to4_partition_decodes_pixel_exact` | ||
| 71 | + -- ok, now over 16 attempts per bit depth (8 with tx-size-search on). | ||
| 72 | + 8-bit: 7 pixel-exact of 8 compared, 9 named refusals, horz_4=64, vert_4=72, | ||
| 73 | + coded=136, 0 out-of-scope mismatches. | ||
| 74 | + | ||
| 75 | +## Open residue (fix-now for the next round, all MEASURED) | ||
| 76 | + | ||
| 77 | +1. `deferred(rect-unit defect)` -- the depth-1 RECT transform unit (TX_16X8 / | ||
| 78 | + TX_32X16) mismatches ffmpeg; code is wired and refused by one `if tx_w != | ||
| 79 | + tx_h` in `decode_rect_split`. Deleting that one line + the 1:4 caller's twin | ||
| 80 | + is the whole re-lift. Reproduce: the 1:4 gate with the tx-search half and | ||
| 81 | + the refusal removed, 8-bit cq 12 seed 42. | ||
| 82 | +2. `deferred(chroma defect behind the lifted refusal)` -- | ||
| 83 | + `a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact` | ||
| 84 | + now decodes seed 55 instead of refusing and mismatches on the **U plane** | ||
| 85 | + only; `#[ignore]`d with that measurement. | ||
| 86 | +3. `deferred(same)` -- `a_directional_16x8_strip_reads_the_right_above_right_samples` | ||
| 87 | + decodes now and mismatches LUMA at seed 700 cq 45 with 0 reaching strips; | ||
| 88 | + `#[ignore]`d with that measurement. Class refusal-hides-a-defect: both are | ||
| 89 | + defects the split refusal was covering, not regressions of this round. | ||
| 90 | + | ||
| 91 | +## Films | ||
| 92 | + | ||
| 93 | +`decode_probe` (release), before -> after: | ||
| 94 | +- reelb5.obu: "a 32x32-level 1:4 strip with a split transform (depth=2)" -> | ||
| 95 | + **"a HORZ_A/HORZ_B/VERT_A partition below 16x16"** (another lane's refusal). | ||
| 96 | + The 1:4 depth refusal is still in place, so what moved this film is the | ||
| 97 | + sub-16 split lift plus the `tx_size_cat1` fix -- the extract's 1:4 strips are | ||
| 98 | + reached and decoded (rect4_32: horz=4 coded=4) and the stream now runs on to | ||
| 99 | + a partition shape nobody has ported. | ||
| 100 | + EVIDENCE: reelb5.obu | cargo run --release --example decode_probe -- reelb5.obu | | ||
| 101 | + refusal string changed, rect4_32 horz=4 vert=0 coded=4 | ||
| 102 | +- hg-head.obu: "filter intra on a HORZ/VERT strip (this decoder predicts | ||
| 103 | + square-only)" (unchanged, another lane). | ||
| 104 | +- reelc-head.obu: "an intra block in an inter frame whose tx_depth splits its | ||
| 105 | + luma transform (round 1)" (unchanged, another lane). | ||
lanes/rectsplitx-r2.report.mdadded+102 -0
| @@ -0,0 +1,102 @@ | |||
| 1 | +# lane-rectsplitx r2 report | ||
| 2 | + | ||
| 3 | +Branch `lane-rectsplitx`, rebased onto main `ce05d5f` (clean), commit `ec0b3b5`. | ||
| 4 | + | ||
| 5 | +## Root cause (the r1 premise was wrong) | ||
| 6 | + | ||
| 7 | +r1 refused the depth-1 RECT transform unit (`TX_16X8`/`TX_32X16`) as "measured | ||
| 8 | +wrong pixels". It is not the transform unit. Range ladder, band fixture 8-bit | ||
| 9 | +cq 12 seed 42 (`EC_TRACE_MODE_STEP=1` ours vs instrumented aomdec): | ||
| 10 | + | ||
| 11 | +``` | ||
| 12 | +ours: EC_ISTEP mi_row=4 mi_col=8 name=mode val=11 rng=52576 | ||
| 13 | +ref : EC_ISTEP mi_row=4 mi_col=8 name=mode val=12 rng=34624 | ||
| 14 | + (entry rng identical, 38331, on the preceding dq line) | ||
| 15 | +``` | ||
| 16 | + | ||
| 17 | +Same entry range, different value => a different `kf_y_mode` CDF row => the | ||
| 18 | +neighbour MODE, not the transform. Three defects, all in the neighbour bands: | ||
| 19 | + | ||
| 20 | +1. `decode.rs` `decode_block_rect4` unsplit arm never wrote the mi-exact | ||
| 21 | + mode/uv maps (`record_mode_mi`/`record_uv_mode_mi`); only the split arm did | ||
| 22 | + (via `record_mi_luma_rect`). So `mode_left_mi` returned `None` and the | ||
| 23 | + coarse 16x16 cell answered -- holding the LAST of the four 32x8 strips. | ||
| 24 | +2. New `Neighbours::modes_above_left_mi` (decode.rs, above `modes_above_left`): | ||
| 25 | + mi-exact AND availability-correct. Four 32x8 strips at tile column 0 share | ||
| 26 | + one `left_mode` cell, so strip 2 read strip 1's mode as its "left" where | ||
| 27 | + libaom has no left neighbour at all (measured at mi(10,0): ours left=2, | ||
| 28 | + libaom DC). Class swept into `decode_leaf_rect` and `decode_leaf8`. | ||
| 29 | +3. `decode_block_rect4` asked `smooth_uv_neighbour(r*(SUB/MI), c*(SUB/MI), ..)` | ||
| 30 | + -- the SUB cell's top-left mi, not the strip's real mi (a 1:4 strip starts | ||
| 31 | + 8 px into a 16-px cell). Chroma-only defect: seed 43 VERT_4 had luma | ||
| 32 | + bit-exact with U/V wrong. | ||
| 33 | + | ||
| 34 | +## Evidence | ||
| 35 | + | ||
| 36 | +EVIDENCE: scratchpad/s42.obu (sha256 7d578ff5deb0c6ec1ac7142ac0b73dcbdf702417da7868448bada17b4cb07e18) | aomenc band fixture 192x128 8-bit cq12 seed42 --enable-tx-size-search=1, EC_AV1_PREFILT_DUMP ours vs aomdec | 22986 luma + 5293 U diffs -> 0 (byte-identical 36864-byte dumps), rect4_32 horz=92 coded=92 | ||
| 37 | +EVIDENCE: scratchpad/s43_17.obu | same recipe, axis X (VERT_4), seed43 cq17 | luma 0 diffs / U 39 / V 150 -> byte-identical after the `smooth_uv_neighbour` mi fix, rect4_32 vert=88 coded=88 | ||
| 38 | + | ||
| 39 | +## Gate | ||
| 40 | + | ||
| 41 | +`a_real_aomenc_stream_with_a_32x32_level_1to4_partition_decodes_pixel_exact` | ||
| 42 | +now HARD-asserts `depth1_proved > 0 && depth2_proved > 0` (was | ||
| 43 | +`depth1+depth2 == 0`, the refusal-honest form), and both `tx_w != tx_h` | ||
| 44 | +refusals are deleted from `decode.rs` + `refusal_inventory.rs`. | ||
| 45 | + | ||
| 46 | +**This gate is RED as committed.** 8-bit seed 46 (cq 12, tx-size-search on) | ||
| 47 | +mismatches CHROMA ONLY: luma bit-exact, U 32 samples and V 173 samples off by | ||
| 48 | ++-1..2, bounding box U x16..23 y8..15 / V x16..35 y8..24, first wrong sample | ||
| 49 | +chroma (16,8) = the 16x4 chroma of the 32x8 strip at luma (32,16). The same | ||
| 50 | +seed at cq 32 (tx-size-search OFF) is byte-exact, so it is specific to a | ||
| 51 | +strip whose luma transform is SPLIT. Reproducer: | ||
| 52 | + | ||
| 53 | +``` | ||
| 54 | +ffmpeg -v error -f lavfi -i "color=c=gray:s=192x128:d=0.04:r=25,format=gray,\ | ||
| 55 | +geq=lum='mod(floor(Y/8)*91,256)',noise=alls=6:all_seed=46,format=yuv420p" \ | ||
| 56 | + -t 0.04 -pix_fmt yuv420p -strict -1 -f yuv4mpegpipe - > src46.y4m | ||
| 57 | +aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=12 --cpu-used=0 \ | ||
| 58 | + --threads=1 --row-mt=0 --sb-size=64 --bit-depth=8 --input-bit-depth=8 \ | ||
| 59 | + --enable-rect-partitions=1 --enable-ab-partitions=0 --enable-1to4-partitions=1 \ | ||
| 60 | + --min-partition-size=8 --max-partition-size=32 --enable-restoration=0 \ | ||
| 61 | + --enable-palette=0 --deltaq-mode=0 --enable-filter-intra=0 --enable-cfl-intra=0 \ | ||
| 62 | + --enable-intrabc=0 --enable-tx-size-search=1 --obu -o s46.obu src46.y4m | ||
| 63 | +EC_AV1_PREFILT_DUMP=o cargo run -p ec-av1 --example decode_probe -- s46.obu | ||
| 64 | +EC_AV1_PREFILT_DUMP=r aomdec --rawvideo -o /dev/null s46.obu # o.f0 vs r.f0 | ||
| 65 | +``` | ||
| 66 | + | ||
| 67 | +Entropy is exact through the whole frame (all luma bit-exact), so the residue | ||
| 68 | +is chroma RECONSTRUCTION inside `decode_rect_split`'s chroma arm | ||
| 69 | +(decode.rs ~5060-5130) -- prediction inputs or the 16x4 inverse, not a symbol. | ||
| 70 | + | ||
| 71 | +FALLBACK TO GREEN (one edit, if the batch needs a merge before that is found): | ||
| 72 | +re-insert `if tx_w != tx_h { return Err(unsupported(..)) }` in | ||
| 73 | +`decode_rect_split` (before `let luma_set =`) and in `decode_block_rect4` | ||
| 74 | +(before `let which = if depth == 1`), re-add the two strings to | ||
| 75 | +`refusal_inventory::REFUSALS`, and flip the gate's depth assert back to | ||
| 76 | +`assert_eq!(depth1_proved + depth2_proved, 0, ..)`. The three neighbour-map | ||
| 77 | +fixes stay and remain gated by the unsplit half of the same gate. | ||
| 78 | + | ||
| 79 | +## r1's two ignored gates -- re-measured, both still ignored | ||
| 80 | + | ||
| 81 | +- `a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact` | ||
| 82 | + (and its 8-bit twin): still CHROMA-only. 10-bit seed 49 frame 0 plane V, | ||
| 83 | + first diff row 4 col 60, ours 510 vs ffmpeg 509, | ||
| 84 | + `filter_intra_rect_sub16_hits=2`. Ignore text updated with that measurement. | ||
| 85 | + deferred: sub-16 filter-intra chroma prediction -- unblocked by the same | ||
| 86 | + chroma-reconstruction hunt as the seed-46 residue. | ||
| 87 | +- `a_directional_16x8_strip_reads_the_right_above_right_samples`: NOT this | ||
| 88 | + lane's defect any more -- every seed 700..739 attempt now stops at another | ||
| 89 | + lane's refusal "a HORZ_A/HORZ_B/VERT_A partition below 16x16", so the gate | ||
| 90 | + reaches no strip at all. deferred: blocked on AB partitions below 16x16. | ||
| 91 | + | ||
| 92 | +## Films | ||
| 93 | + | ||
| 94 | +Not re-measured this round (turn cap). r1 measured reelb5.obu moving to | ||
| 95 | +"a HORZ_A/HORZ_B/VERT_A partition below 16x16"; the ledger records that no | ||
| 96 | +`reelc-head.obu` exists on the box. | ||
| 97 | + | ||
| 98 | +## Suite | ||
| 99 | + | ||
| 100 | +`systemd-run --user --unit=rectsplitx-suite-1788313999` -> | ||
| 101 | +`$HOME/.cache/rectsplitx-suite-r2.log`. Expected: 1 failure, the 1:4 gate | ||
| 102 | +above (the only gate whose assertion this round strengthened). | ||
lanes/rectsplitx-r3.report.mdadded+78 -0
| @@ -0,0 +1,78 @@ | |||
| 1 | +# lane-rectsplitx r3 report | ||
| 2 | + | ||
| 3 | +Branch `lane-rectsplitx`, commit `58149c8` on top of r2 `eec6a40` (base main | ||
| 4 | +`ce05d5f`; main has since moved to `11633d7` -- **not rebased this round**, see | ||
| 5 | +"Open"). | ||
| 6 | + | ||
| 7 | +## Root cause (one line of code) | ||
| 8 | + | ||
| 9 | +`crates/ec-av1/src/decode.rs:5665` -- `decode_leaf_rect`'s SPLIT arm built | ||
| 10 | +`RectStripModes { .., smooth_neighbor_uv: false }`, hard-coded, while the | ||
| 11 | +unsplit arm two dozen lines below passes the real | ||
| 12 | +`neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c)` computed at | ||
| 13 | +`decode.rs:5637`. So every tx-split 16x8/8x16 leaf predicted its chroma with | ||
| 14 | +the intra-edge FILTER TYPE off: luma bit-exact, chroma off by +-1..2 across | ||
| 15 | +the block, with the error leaking into the blocks below/right. | ||
| 16 | + | ||
| 17 | +Class: a split/unsplit pair where the split arm drops a field the unsplit arm | ||
| 18 | +passes (sibling of `cdf-row-held-constant` -- a value pinned to a constant | ||
| 19 | +where the reference varies it). Sweep: all four `RectStripModes` literals | ||
| 20 | +(`decode.rs:5248`, `5656`, `5905`, `6250`) now pass the computed value; that | ||
| 21 | +was the only constant one. | ||
| 22 | + | ||
| 23 | +The charter's suspects (chroma TU geometry, CfL, TX_16X4 dequant/inverse) were | ||
| 24 | +all wrong: the failing block is not a 32x8 1:4 strip. `EC_AV1_TRACE` puts a | ||
| 25 | +`TRACE_RECT_SPLIT mi_row=4 mi_col=8 bw=16 bh=8 tx=8x8` (and its twin at | ||
| 26 | +mi_row=6) exactly over the wrong region -- a 16x16 block split PARTITION_HORZ | ||
| 27 | +into two 16x8 strips, each with `tx_depth=1`, chroma 8x4. | ||
| 28 | + | ||
| 29 | +## Evidence | ||
| 30 | + | ||
| 31 | +EVIDENCE: scratchpad/r3/s46.obu (sha256 31de47355a098b460975ca0156e0b10cebaacc3c1614d2a8791ece3440c8ba45, generated TWICE identical) | aomenc 192x128 8-bit cq12 seed46 `--enable-tx-size-search=1 --enable-1to4-partitions=1`, `EC_AV1_PREFILT_DUMP` ours vs instrumented aomdec | before: Y 0 diffs, U 32 diffs (all inside chroma cell x16..23 y8..15), V 173; after: `cmp o.f0 r.f0` BYTE-IDENTICAL (36864 bytes) | ||
| 32 | +EVIDENCE: scratchpad/r3/trace.txt | `EC_AV1_TRACE=1 decode_probe s46.obu`, grep mi_row=4..7 mi_col=8..11 | `TRACE_RECT_SPLIT mi_row=4 mi_col=8 bw=16 bh=8 tx=8x8` == luma (32,16), the exact 8x8 chroma cell that was wrong | ||
| 33 | + | ||
| 34 | +## Gates | ||
| 35 | + | ||
| 36 | +`cargo test -p ec-av1 --lib -- <3 names>` (EC_AV1_REQUIRE_AOMENC=1): | ||
| 37 | +`test result: ok. 3 passed; 0 failed` in 21.4s -- | ||
| 38 | + | ||
| 39 | +- `a_real_aomenc_stream_with_a_32x32_level_1to4_partition_decodes_pixel_exact` | ||
| 40 | + (RED as committed in r2, the round's target) -- GREEN, still hard-asserting | ||
| 41 | + `depth1_proved > 0 && depth2_proved > 0`. | ||
| 42 | +- `a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact` | ||
| 43 | + -- **un-ignored**, GREEN (ignored since lane-fistrip r1). | ||
| 44 | +- `a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact` | ||
| 45 | + -- **un-ignored**, GREEN (his films are 10-bit; this is the 10-bit arm). | ||
| 46 | + | ||
| 47 | +Both `#[ignore]` attributes and the stale prose in their doc comments are gone | ||
| 48 | +in the same commit. No refusal string changed this round (r2 already deleted | ||
| 49 | +the two `tx_w != tx_h` ones); `refusal_inventory` and `gate_coverage` stay | ||
| 50 | +green in the suite below. | ||
| 51 | + | ||
| 52 | +## Suite | ||
| 53 | + | ||
| 54 | +`systemd-run --user --unit=rectsplitx-suite-r3-1788314510 -p MemoryMax=10G` -> | ||
| 55 | +`$HOME/.cache/rectsplitx-suite-r3.log`: `test result: ok. 335 passed; 0 failed; 29 ignored; 0 measured; 0 filtered out; finished in 398.99s` (r2 was 1 failed / 31 ignored). | ||
| 56 | + | ||
| 57 | +## Films (this worktree, not rebased -- other lanes' refusals dominate) | ||
| 58 | + | ||
| 59 | +- `hg-head.obu`: `filter intra on a HORZ/VERT strip (this decoder predicts square-only)` (unchanged) | ||
| 60 | +- `reelc-head.obu`: `an intra block in an inter frame whose tx_depth splits its luma transform (round 1)` (unchanged) | ||
| 61 | +- `reelb5.obu`: `a HORZ_A/HORZ_B/VERT_A partition below 16x16` (unchanged; lifted on main by lane-ab16) | ||
| 62 | + | ||
| 63 | +## Open | ||
| 64 | + | ||
| 65 | +- deferred: rebase onto main `11633d7` -- this lane is 3 merges behind | ||
| 66 | + (`ce05d5f..11633d7`, palette2/ab16/tiles all touch `decode.rs` hot spots incl. | ||
| 67 | + `Reach::of_tu` arity and a duplicate `FIMODE_TO_INTRADIR` helper per the | ||
| 68 | + ledger). Unblocked by: whoever merges this lane resolving those conflicts; | ||
| 69 | + the fix itself is one field in a struct literal and applies unchanged. | ||
| 70 | +- deferred: `reelc-head.obu`'s refusal, "an intra block in an inter frame whose | ||
| 71 | + tx_depth splits its luma transform (round 1)", is this lane's family (the | ||
| 72 | + same split walk, in an inter frame). Unblocked by: an inter-frame gate with | ||
| 73 | + tx-size-search on. | ||
| 74 | +- accepted: the coarse-cell `smooth_uv_neighbour(r * (SUB / MI), c * (SUB / MI), ..)` | ||
| 75 | + call form still stands at `decode.rs:5206`, `6197`, `7487`, `15310`. Those | ||
| 76 | + callers are 16px-aligned strips (32x16/64x32) where the SUB cell's mi IS the | ||
| 77 | + strip's mi, so they are correct today -- but a future sub-cell caller would | ||
| 78 | + repeat r2's defect. | ||