Merge lane-tx64x16 88100e5: superblock-level HORZ_4/VERT_4 (four 64x16/16x64 strips; ReelC blocker) with TX_64X16/16X64 luma and 32x8/8x32 chroma coefficient paths
Browse files at this commit6 changed files +616 -26
- crates/ec-av1/src/decode.rs +170 -20
- crates/ec-av1/src/gate_coverage.rs +1 -5
- crates/ec-av1/src/refusal_inventory.rs +1 -1
- crates/ec-av1/src/stream.rs +193 -0
- lanes/tx64x16-r1.report.md +138 -0
- lanes/tx64x16-r2.report.md +113 -0
crates/ec-av1/src/decode.rsmodified+170 -20
| @@ -51,6 +51,8 @@ const PARTITION_HORZ_A: usize = 4; | |||
| 51 | const PARTITION_HORZ_B: usize = 5; | 51 | const PARTITION_HORZ_B: usize = 5; |
| 52 | const PARTITION_VERT_A: usize = 6; | 52 | const PARTITION_VERT_A: usize = 6; |
| 53 | const PARTITION_VERT_B: usize = 7; | 53 | const PARTITION_VERT_B: usize = 7; |
| 54 | +const PARTITION_HORZ_4: usize = 8; | ||
| 55 | +const PARTITION_VERT_4: usize = 9; | ||
| 54 | const SB_MI: u32 = 16; | 56 | const SB_MI: u32 = 16; |
| 55 | const BLOCK_MI: u32 = 8; | 57 | const BLOCK_MI: u32 = 8; |
| 56 | 58 | ||
| @@ -1419,6 +1421,26 @@ pub(crate) fn sb_ab_hits_by_arm() -> [usize; 4] { | |||
| 1419 | SB_AB_HITS.with(std::cell::Cell::get) | 1421 | SB_AB_HITS.with(std::cell::Cell::get) |
| 1420 | } | 1422 | } |
| 1421 | 1423 | ||
| 1424 | +// lane-tx64x16: the two 1:4 superblock arms, counted per orientation -- | ||
| 1425 | +// `PARTITION_HORZ_4` (four 64x16 strips) and `PARTITION_VERT_4` (four 16x64 | ||
| 1426 | +// strips). Two counters, not one, because a gate that only proved "some 1:4 | ||
| 1427 | +// strip fired" would pass on a stream that never coded the other axis, and | ||
| 1428 | +// every scan/context table this round added comes in a transposed pair. | ||
| 1429 | +thread_local! { | ||
| 1430 | + static SB_RECT4_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1431 | + static SB_RECT4_VERT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1432 | +} | ||
| 1433 | + | ||
| 1434 | +/// Current value of `SB_RECT4_HORZ_HITS` (64x16 strips decoded). | ||
| 1435 | +pub(crate) fn sb_rect4_horz_hits() -> usize { | ||
| 1436 | + SB_RECT4_HORZ_HITS.with(|c| c.get()) | ||
| 1437 | +} | ||
| 1438 | + | ||
| 1439 | +/// Current value of `SB_RECT4_VERT_HITS` (16x64 strips decoded). | ||
| 1440 | +pub(crate) fn sb_rect4_vert_hits() -> usize { | ||
| 1441 | + SB_RECT4_VERT_HITS.with(|c| c.get()) | ||
| 1442 | +} | ||
| 1443 | + | ||
| 1422 | // lane-rect64q r1: how many of [`decode_block_rect64`]'s three per-plane | 1444 | // lane-rect64q r1: how many of [`decode_block_rect64`]'s three per-plane |
| 1423 | // dequant calls actually observed `CURRENT_Q_IDX != base_q_idx` -- proof the | 1445 | // dequant calls actually observed `CURRENT_Q_IDX != base_q_idx` -- proof the |
| 1424 | // running-vs-stale-snapshot bug this round fixed is exercised by a gate, not | 1446 | // running-vs-stale-snapshot bug this round fixed is exercised by a gate, not |
| @@ -1953,6 +1975,46 @@ const SCAN_8X16: [u16; 128] = [ | |||
| 1953 | 123, 103, 110, 117, 124, 111, 118, 125, 119, 126, 127, | 1975 | 123, 103, 110, 117, 124, 111, 118, 125, 119, 126, 127, |
| 1954 | ]; | 1976 | ]; |
| 1955 | 1977 | ||
| 1978 | +/// `Default_Scan_32x8`, this decoder's own row-major transcription (see | ||
| 1979 | +/// [`SCAN_32X16`]'s doc comment) -- the chroma plane of a 64x16 | ||
| 1980 | +/// `PARTITION_HORZ_4` superblock strip (lane-tx64x16). libaom stores its | ||
| 1981 | +/// scans column-major (`p = col * height + row`), so a naive copy of | ||
| 1982 | +/// `default_scan_32x8` would silently install the TRANSPOSED 8x32 order | ||
| 1983 | +/// (class reference-layout-not-spec): `default_scan_16x8`'s literal bytes | ||
| 1984 | +/// are byte-identical to this decoder's [`SCAN_8X16`]. | ||
| 1985 | +const SCAN_32X8: [u16; 256] = [ | ||
| 1986 | + 0, 32, 1, 64, 33, 2, 96, 65, 34, 3, 128, 97, 66, 35, 4, 160, 129, 98, 67, 36, 5, 192, 161, 130, | ||
| 1987 | + 99, 68, 37, 6, 224, 193, 162, 131, 100, 69, 38, 7, 225, 194, 163, 132, 101, 70, 39, 8, 226, 195, | ||
| 1988 | + 164, 133, 102, 71, 40, 9, 227, 196, 165, 134, 103, 72, 41, 10, 228, 197, 166, 135, 104, 73, 42, | ||
| 1989 | + 11, 229, 198, 167, 136, 105, 74, 43, 12, 230, 199, 168, 137, 106, 75, 44, 13, 231, 200, 169, | ||
| 1990 | + 138, 107, 76, 45, 14, 232, 201, 170, 139, 108, 77, 46, 15, 233, 202, 171, 140, 109, 78, 47, 16, | ||
| 1991 | + 234, 203, 172, 141, 110, 79, 48, 17, 235, 204, 173, 142, 111, 80, 49, 18, 236, 205, 174, 143, | ||
| 1992 | + 112, 81, 50, 19, 237, 206, 175, 144, 113, 82, 51, 20, 238, 207, 176, 145, 114, 83, 52, 21, 239, | ||
| 1993 | + 208, 177, 146, 115, 84, 53, 22, 240, 209, 178, 147, 116, 85, 54, 23, 241, 210, 179, 148, 117, | ||
| 1994 | + 86, 55, 24, 242, 211, 180, 149, 118, 87, 56, 25, 243, 212, 181, 150, 119, 88, 57, 26, 244, 213, | ||
| 1995 | + 182, 151, 120, 89, 58, 27, 245, 214, 183, 152, 121, 90, 59, 28, 246, 215, 184, 153, 122, 91, | ||
| 1996 | + 60, 29, 247, 216, 185, 154, 123, 92, 61, 30, 248, 217, 186, 155, 124, 93, 62, 31, 249, 218, 187, | ||
| 1997 | + 156, 125, 94, 63, 250, 219, 188, 157, 126, 95, 251, 220, 189, 158, 127, 252, 221, 190, 159, 253, | ||
| 1998 | + 222, 191, 254, 223, 255, | ||
| 1999 | +]; | ||
| 2000 | +/// `Default_Scan_8x32`, [`SCAN_32X8`]'s transpose (the chroma plane of a | ||
| 2001 | +/// 16x64 `PARTITION_VERT_4` strip). | ||
| 2002 | +const SCAN_8X32: [u16; 256] = [ | ||
| 2003 | + 0, 1, 8, 2, 9, 16, 3, 10, 17, 24, 4, 11, 18, 25, 32, 5, 12, 19, 26, 33, 40, 6, 13, 20, 27, 34, | ||
| 2004 | + 41, 48, 7, 14, 21, 28, 35, 42, 49, 56, 15, 22, 29, 36, 43, 50, 57, 64, 23, 30, 37, 44, 51, 58, | ||
| 2005 | + 65, 72, 31, 38, 45, 52, 59, 66, 73, 80, 39, 46, 53, 60, 67, 74, 81, 88, 47, 54, 61, 68, 75, 82, | ||
| 2006 | + 89, 96, 55, 62, 69, 76, 83, 90, 97, 104, 63, 70, 77, 84, 91, 98, 105, 112, 71, 78, 85, 92, 99, | ||
| 2007 | + 106, 113, 120, 79, 86, 93, 100, 107, 114, 121, 128, 87, 94, 101, 108, 115, 122, 129, 136, 95, | ||
| 2008 | + 102, 109, 116, 123, 130, 137, 144, 103, 110, 117, 124, 131, 138, 145, 152, 111, 118, 125, 132, | ||
| 2009 | + 139, 146, 153, 160, 119, 126, 133, 140, 147, 154, 161, 168, 127, 134, 141, 148, 155, 162, 169, | ||
| 2010 | + 176, 135, 142, 149, 156, 163, 170, 177, 184, 143, 150, 157, 164, 171, 178, 185, 192, 151, 158, | ||
| 2011 | + 165, 172, 179, 186, 193, 200, 159, 166, 173, 180, 187, 194, 201, 208, 167, 174, 181, 188, 195, | ||
| 2012 | + 202, 209, 216, 175, 182, 189, 196, 203, 210, 217, 224, 183, 190, 197, 204, 211, 218, 225, 232, | ||
| 2013 | + 191, 198, 205, 212, 219, 226, 233, 240, 199, 206, 213, 220, 227, 234, 241, 248, 207, 214, 221, | ||
| 2014 | + 228, 235, 242, 249, 215, 222, 229, 236, 243, 250, 223, 230, 237, 244, 251, 231, 238, 245, 252, | ||
| 2015 | + 239, 246, 253, 247, 254, 255, | ||
| 2016 | +]; | ||
| 2017 | + | ||
| 1956 | /// [`neighbour`] with independent `w` (row stride)/`h` (row-bound) extents | 2018 | /// [`neighbour`] with independent `w` (row stride)/`h` (row-bound) extents |
| 1957 | /// (lane-rectwire, mirrors [`record_rect`](Neighbours::record_rect)'s | 2019 | /// (lane-rectwire, mirrors [`record_rect`](Neighbours::record_rect)'s |
| 1958 | /// asymmetric-extent pattern). | 2020 | /// asymmetric-extent pattern). |
| @@ -4973,30 +5035,63 @@ fn decode_block_rect64( | |||
| 4973 | ); | 5035 | ); |
| 4974 | } else { | 5036 | } else { |
| 4975 | let around = neighbours.around_rect(at, bw, bh); | 5037 | let around = neighbours.around_rect(at, bw, bh); |
| 4976 | - // LUMA: a real 32x32 corner, embedded top-left of the true bw x bh | 5038 | + // LUMA: the coded corner, embedded top-left of the true bw x bh grid |
| 4977 | - // grid (see this function's own doc comment). | 5039 | + // (see this function's own doc comment). A 64-length axis codes only |
| 5040 | + // its low 32 coefficients, so the corner is `min(bw, 32)` x | ||
| 5041 | + // `min(bh, 32)`: 32x32 under a 64x32/32x64 HORZ/VERT strip, and | ||
| 5042 | + // 32x16/16x32 under a 64x16/16x64 1:4 strip (lane-tx64x16). | ||
| 5043 | + let (luma_cw, luma_ch) = (bw.min(32), bh.min(32)); | ||
| 4978 | let scan32 = default_scan(TX32); | 5044 | let scan32 = default_scan(TX32); |
| 4979 | - let mut luma_coding = cdfs.txb(TxbSet::Luma64, mode); | ||
| 4980 | if std::env::var_os("EC_TRACE_COEFF").is_some() { | 5045 | if std::env::var_os("EC_TRACE_COEFF").is_some() { |
| 4981 | let (rng, _) = dec.debug_state(); | 5046 | let (rng, _) = dec.debug_state(); |
| 4982 | - eprintln!("EC_COEFF plane=0 row={mi_r} col={mi_c} tx_size=64corner rng={rng}"); | 5047 | + eprintln!("EC_COEFF plane=0 row={mi_r} col={mi_c} tx_size={luma_cw}x{luma_ch} rng={rng}"); |
| 4983 | } | 5048 | } |
| 4984 | - let (luma_corner, luma_tx_type) = read_coeffs( | 5049 | + let (luma_corner, luma_tx_type) = if (luma_cw, luma_ch) == (32, 32) { |
| 4985 | - dec, | 5050 | + let mut luma_coding = cdfs.txb(TxbSet::Luma64, mode); |
| 4986 | - &mut luma_coding, | 5051 | + read_coeffs( |
| 4987 | - &scan32, | 5052 | + dec, |
| 4988 | - 0, | 5053 | + &mut luma_coding, |
| 4989 | - dc_sign_ctx(around[0].2), | 5054 | + &scan32, |
| 4990 | - TxType::DctDct, | 5055 | + 0, |
| 4991 | - Some((bw, bh)), | 5056 | + dc_sign_ctx(around[0].2), |
| 4992 | - )?; | 5057 | + TxType::DctDct, |
| 5058 | + Some((bw, bh)), | ||
| 5059 | + )? | ||
| 5060 | + } else { | ||
| 5061 | + // `av1_get_adjusted_tx_size` (`blockd.h:1361`) maps TX_64X16 -> | ||
| 5062 | + // TX_32X16 and TX_16X64 -> TX_16X32, and `av1_scan_orders` | ||
| 5063 | + // (`scan.c`) gives both the very same `default_scan_32x16` / | ||
| 5064 | + // `default_scan_16x32` the 2:1 sizes use ("Half of the | ||
| 5065 | + // coefficients of tx64 at higher frequencies are set to zeros. So | ||
| 5066 | + // tx32's scan order is used"). `get_txsize_entropy_ctx` is | ||
| 5067 | + // (txsize_sqr + txsize_sqr_up + 1) >> 1 = (TX_16X16 + TX_64X64 + | ||
| 5068 | + // 1) >> 1 = TX_32X32 and `txsize_log2_minus4[TX_64X16]` is 5 (a | ||
| 5069 | + // 512-position eob group) -- BOTH identical to TX_32X16, so the | ||
| 5070 | + // 2:1 CDF set `LumaRect32x16` is bit-exact here and no new table | ||
| 5071 | + // is owed. `av1_nz_map_ctx_offset[TX_64X16]` is literally | ||
| 5072 | + // `av1_nz_map_ctx_offset_32x16` (`txb_common.c:340`), which is | ||
| 5073 | + // what `base_ctx_rect` computes at (32, 16). | ||
| 5074 | + let luma_scan: &[u16] = if bw == 64 { &SCAN_32X16 } else { &SCAN_16X32 }; | ||
| 5075 | + let mut luma_coding = cdfs.txb(TxbSet::LumaRect32x16, mode); | ||
| 5076 | + read_coeffs_rect( | ||
| 5077 | + dec, | ||
| 5078 | + &mut luma_coding, | ||
| 5079 | + luma_scan, | ||
| 5080 | + luma_cw, | ||
| 5081 | + luma_ch, | ||
| 5082 | + 0, | ||
| 5083 | + dc_sign_ctx(around[0].2), | ||
| 5084 | + TxType::DctDct, | ||
| 5085 | + )? | ||
| 5086 | + }; | ||
| 4993 | if std::env::var_os("EC_TRACE_COEFF").is_some() { | 5087 | if std::env::var_os("EC_TRACE_COEFF").is_some() { |
| 4994 | let (rng, _) = dec.debug_state(); | 5088 | let (rng, _) = dec.debug_state(); |
| 4995 | eprintln!("EC_COEFF_VAL plane=0 row={mi_r} col={mi_c} rng={rng}"); | 5089 | eprintln!("EC_COEFF_VAL plane=0 row={mi_r} col={mi_c} rng={rng}"); |
| 4996 | } | 5090 | } |
| 4997 | let mut luma_levels = vec![0i32; bw * bh]; | 5091 | let mut luma_levels = vec![0i32; bw * bh]; |
| 4998 | - for row in 0..32 { | 5092 | + for row in 0..luma_ch { |
| 4999 | - luma_levels[row * bw..][..32].copy_from_slice(&luma_corner[row * 32..][..32]); | 5093 | + luma_levels[row * bw..][..luma_cw] |
| 5094 | + .copy_from_slice(&luma_corner[row * luma_cw..][..luma_cw]); | ||
| 5000 | } | 5095 | } |
| 5001 | { | 5096 | { |
| 5002 | let cur = block_q_idx(); | 5097 | let cur = block_q_idx(); |
| @@ -5049,9 +5144,20 @@ fn decode_block_rect64( | |||
| 5049 | // CHROMA: a real, untruncated chroma_w x chroma_h transform -- no | 5144 | // CHROMA: a real, untruncated chroma_w x chroma_h transform -- no |
| 5050 | // corner crop needed (see doc comment). | 5145 | // corner crop needed (see doc comment). |
| 5051 | let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); | 5146 | let ac = alpha.map(|_| cfl_ac_q3_rect(y, px, py, bw, bh)); |
| 5052 | - let chroma_scan: &[u16] = if bw == 64 { &SCAN_32X16 } else { &SCAN_16X32 }; | 5147 | + // The chroma plane is never truncated (both axes <= 32 after |
| 5148 | + // subsampling). Under a 1:4 strip it is a true 32x8/8x32: | ||
| 5149 | + // `get_txsize_entropy_ctx(TX_32X8)` = (TX_8X8 + TX_32X32 + 1) >> 1 = | ||
| 5150 | + // TX_16X16 and `txsize_log2_minus4[TX_32X8]` = 4 (256 positions), | ||
| 5151 | + // both identical to TX_16X16 -- so [`TxbSet::Chroma16`] is the exact | ||
| 5152 | + // set, and only the scan is new (lane-tx64x16). | ||
| 5153 | + let (chroma_set, chroma_scan): (TxbSet, &[u16]) = match (bw, bh) { | ||
| 5154 | + (64, 16) => (TxbSet::Chroma16, &SCAN_32X8), | ||
| 5155 | + (16, 64) => (TxbSet::Chroma16, &SCAN_8X32), | ||
| 5156 | + (64, _) => (TxbSet::ChromaRect32x16, &SCAN_32X16), | ||
| 5157 | + _ => (TxbSet::ChromaRect32x16, &SCAN_16X32), | ||
| 5158 | + }; | ||
| 5053 | let u_skip_ctx = usize::from(around[1].0) + usize::from(around[1].1); | 5159 | let u_skip_ctx = usize::from(around[1].0) + usize::from(around[1].1); |
| 5054 | - let mut u_coding = cdfs.txb(TxbSet::ChromaRect32x16, uv_predict_mode); | 5160 | + let mut u_coding = cdfs.txb(chroma_set, uv_predict_mode); |
| 5055 | if std::env::var_os("EC_TRACE_COEFF").is_some() { | 5161 | if std::env::var_os("EC_TRACE_COEFF").is_some() { |
| 5056 | let (rng, _) = dec.debug_state(); | 5162 | let (rng, _) = dec.debug_state(); |
| 5057 | eprintln!("EC_COEFF plane=1 row={mi_r} col={mi_c} tx_size=rect32x16 rng={rng}"); | 5163 | eprintln!("EC_COEFF plane=1 row={mi_r} col={mi_c} tx_size=rect32x16 rng={rng}"); |
| @@ -5105,7 +5211,7 @@ fn decode_block_rect64( | |||
| 5105 | smooth_neighbor_uv, | 5211 | smooth_neighbor_uv, |
| 5106 | ); | 5212 | ); |
| 5107 | let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1); | 5213 | let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1); |
| 5108 | - let mut v_coding = cdfs.txb(TxbSet::ChromaRect32x16, uv_predict_mode); | 5214 | + let mut v_coding = cdfs.txb(chroma_set, uv_predict_mode); |
| 5109 | if std::env::var_os("EC_TRACE_COEFF").is_some() { | 5215 | if std::env::var_os("EC_TRACE_COEFF").is_some() { |
| 5110 | let (rng, _) = dec.debug_state(); | 5216 | let (rng, _) = dec.debug_state(); |
| 5111 | eprintln!("EC_COEFF plane=2 row={mi_r} col={mi_c} tx_size=rect32x16 rng={rng}"); | 5217 | eprintln!("EC_COEFF plane=2 row={mi_r} col={mi_c} tx_size=rect32x16 rng={rng}"); |
| @@ -5164,6 +5270,11 @@ fn decode_block_rect64( | |||
| 5164 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); | 5270 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, skip); |
| 5165 | neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0); | 5271 | neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0); |
| 5166 | SB_RECT_HITS.with(|c| c.set(c.get() + 1)); | 5272 | SB_RECT_HITS.with(|c| c.set(c.get() + 1)); |
| 5273 | + match (bw, bh) { | ||
| 5274 | + (64, 16) => SB_RECT4_HORZ_HITS.with(|c| c.set(c.get() + 1)), | ||
| 5275 | + (16, 64) => SB_RECT4_VERT_HITS.with(|c| c.set(c.get() + 1)), | ||
| 5276 | + _ => {} | ||
| 5277 | + } | ||
| 5167 | if std::env::var_os("EC_AV1_TRACE").is_some() { | 5278 | if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 5168 | let (rng, _) = dec.debug_state(); | 5279 | let (rng, _) = dec.debug_state(); |
| 5169 | eprintln!("TRACE_RECT64_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} rng={rng}"); | 5280 | eprintln!("TRACE_RECT64_END mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} rng={rng}"); |
| @@ -9506,10 +9617,49 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 9506 | } | 9617 | } |
| 9507 | } | 9618 | } |
| 9508 | } | 9619 | } |
| 9620 | + PARTITION_HORZ_4 | PARTITION_VERT_4 => { | ||
| 9621 | + // lane-tx64x16: the 1:4 pair at 64x64 -- four 64x16 (or | ||
| 9622 | + // 16x64) strips in raster order. `decode_partition` | ||
| 9623 | + // (`decodeframe.c`) steps by `quarter_step = mi_size / 4` | ||
| 9624 | + // (4 mi = 16 px = one SUB unit here) and BREAKS at the | ||
| 9625 | + // frame edge for `i > 0`, so a partial superblock codes | ||
| 9626 | + // only the strips whose origin is inside the frame. | ||
| 9627 | + let horz = part == PARTITION_HORZ_4; | ||
| 9628 | + for i in 0..4 { | ||
| 9629 | + let step_mi = i * (SB_MI as usize / 4); | ||
| 9630 | + let (this_r_mi, this_c_mi) = if horz { | ||
| 9631 | + (sb_r as usize * SB_MI as usize + step_mi, sb_c as usize * SB_MI as usize) | ||
| 9632 | + } else { | ||
| 9633 | + (sb_r as usize * SB_MI as usize, sb_c as usize * SB_MI as usize + step_mi) | ||
| 9634 | + }; | ||
| 9635 | + if i > 0 | ||
| 9636 | + && (this_r_mi >= mi_rows as usize || this_c_mi >= mi_cols as usize) | ||
| 9637 | + { | ||
| 9638 | + break; | ||
| 9639 | + } | ||
| 9640 | + let strip_at = if horz { (at.0 + i, at.1) } else { (at.0, at.1 + i) }; | ||
| 9641 | + let (bw, bh) = if horz { (64, 16) } else { (16, 64) }; | ||
| 9642 | + decode_block_rect64( | ||
| 9643 | + &mut dec, | ||
| 9644 | + &mut cdfs, | ||
| 9645 | + &mut neighbours, | ||
| 9646 | + strip_at, | ||
| 9647 | + bw, | ||
| 9648 | + bh, | ||
| 9649 | + &mut y, | ||
| 9650 | + &mut u, | ||
| 9651 | + &mut v, | ||
| 9652 | + enable_filter_intra, | ||
| 9653 | + allow_screen_content_tools, | ||
| 9654 | + base_q_idx, | ||
| 9655 | + tx_select, | ||
| 9656 | + reduced_tx_set, | ||
| 9657 | + )?; | ||
| 9658 | + } | ||
| 9659 | + } | ||
| 9509 | _ => { | 9660 | _ => { |
| 9510 | return Err(unsupported( | 9661 | return Err(unsupported( |
| 9511 | - "a superblock-level 1:4 partition (PARTITION_HORZ_4/VERT_4 at 64x64, \ | 9662 | + "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4", |
| 9512 | - four 64x16/16x64 strips)", | ||
| 9513 | )); | 9663 | )); |
| 9514 | } | 9664 | } |
| 9515 | } | 9665 | } |
crates/ec-av1/src/gate_coverage.rsmodified+1 -5
| @@ -139,10 +139,6 @@ const ALIASES: &[(&str, &str)] = &[("superres-mode", "enable-superres")]; | |||
| 139 | /// depth retires the entry, and this test fails until it is deleted. | 139 | /// depth retires the entry, and this test fails until it is deleted. |
| 140 | #[cfg(test)] | 140 | #[cfg(test)] |
| 141 | const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[ | 141 | const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[ |
| 142 | - ( | ||
| 143 | - "enable-1to4-partitions", | ||
| 144 | - "off in 42 gates, on in none: PARTITION_HORZ_4/VERT_4 at 64x64 needs TX_64X16 luma plus 32x8 chroma scans (lane-part32 r5)", | ||
| 145 | - ), | ||
| 146 | ( | 142 | ( |
| 147 | "enable-angle-delta", | 143 | "enable-angle-delta", |
| 148 | "off in 36 gates, on in none: the directional-intra gates pin it off to isolate the base modes", | 144 | "off in 36 gates, on in none: the directional-intra gates pin it off to isolate the base modes", |
| @@ -203,7 +199,7 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ | |||
| 203 | // gate passes `=1` for both. | 199 | // gate passes `=1` for both. |
| 204 | ( | 200 | ( |
| 205 | "enable-1to4-partitions", | 201 | "enable-1to4-partitions", |
| 206 | - "hole at both depths, see the 8-bit list", | 202 | + "10-bit hole only: lane-tx64x16's 8-bit SB-level 1:4 gate passes `=1` and asserts both arms, but no 10-bit gate does", |
| 207 | ), | 203 | ), |
| 208 | ( | 204 | ( |
| 209 | "enable-angle-delta", | 205 | "enable-angle-delta", |
crates/ec-av1/src/refusal_inventory.rsmodified+1 -1
| @@ -45,7 +45,7 @@ const REFUSALS: &[&str] = &[ | |||
| 45 | "a Golomb tail longer than this decoder reads", | 45 | "a Golomb tail longer than this decoder reads", |
| 46 | "a tx_type symbol outside its CDF's own set: {t}", | 46 | "a tx_type symbol outside its CDF's own set: {t}", |
| 47 | "an INTER 32x32 partition type this decoder does not code (value={part32})", | 47 | "an INTER 32x32 partition type this decoder does not code (value={part32})", |
| 48 | - "a superblock-level 1:4 partition (PARTITION_HORZ_4/VERT_4 at 64x64, four 64x16/16x64 strips)", | 48 | + "a superblock-level partition value outside PARTITION_NONE..PARTITION_VERT_4", |
| 49 | "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)", | 49 | "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)", |
| 50 | "a block that actually uses a palette (UV) -- reconstruction is out of scope", | 50 | "a block that actually uses a palette (UV) -- reconstruction is out of scope", |
| 51 | "a block that actually uses a palette (Y) -- reconstruction is out of scope", | 51 | "a block that actually uses a palette (Y) -- reconstruction is out of scope", |
crates/ec-av1/src/stream.rsmodified+193 -0
| @@ -13833,4 +13833,197 @@ mod tests { | |||
| 13833 | assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (pinned sbpart)"); | 13833 | assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (pinned sbpart)"); |
| 13834 | } | 13834 | } |
| 13835 | } | 13835 | } |
| 13836 | + | ||
| 13837 | + /// lane-tx64x16 r1: a real `aomenc` stream whose superblock-level | ||
| 13838 | + /// partition decision is `PARTITION_HORZ_4`/`PARTITION_VERT_4` (four | ||
| 13839 | + /// 64x16 / 16x64 strips) must decode pixel-exact. Both arms are HARD | ||
| 13840 | + /// asserted, and only hits earned inside an attempt that then compared | ||
| 13841 | + /// pixel-exact against ffmpeg are counted -- a strip decoded by an | ||
| 13842 | + /// attempt that later refused proves nothing (class | ||
| 13843 | + /// gate-skips-on-its-own-failure). `--enable-1to4-partitions=1` is the | ||
| 13844 | + /// tool switch; `--min-partition-size=16` keeps the RD search from | ||
| 13845 | + /// recursing below 16x16, where several other unlanded partition shapes | ||
| 13846 | + /// live. | ||
| 13847 | + #[test] | ||
| 13848 | + fn a_real_aomenc_stream_with_a_superblock_level_1to4_partition_decodes_pixel_exact() { | ||
| 13849 | + const NAME: &str = | ||
| 13850 | + "a_real_aomenc_stream_with_a_superblock_level_1to4_partition_decodes_pixel_exact"; | ||
| 13851 | + let _gate_lock = lock_gate_counters(); | ||
| 13852 | + if !have_ffmpeg() { | ||
| 13853 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 13854 | + return; | ||
| 13855 | + } | ||
| 13856 | + if !have_aomenc() { | ||
| 13857 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 13858 | + return; | ||
| 13859 | + } | ||
| 13860 | + let (width, height, frame_count) = (192usize, 128usize, 1usize); | ||
| 13861 | + let mut named_refusals = 0u32; | ||
| 13862 | + let mut matched = 0u32; | ||
| 13863 | + let (mut horz_proved, mut vert_proved) = (0usize, 0usize); | ||
| 13864 | + let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); | ||
| 13865 | + let n_attempts: u32 = std::env::var("EC_TX64X16_GATE_ATTEMPTS") | ||
| 13866 | + .ok() | ||
| 13867 | + .and_then(|s| s.parse().ok()) | ||
| 13868 | + .unwrap_or(40); | ||
| 13869 | + for attempt in 0..n_attempts { | ||
| 13870 | + let seed = 42 + attempt; | ||
| 13871 | + let duration = frame_count as f64 / 25.0; | ||
| 13872 | + // Odd attempts render the SAME generator rotated 90 degrees | ||
| 13873 | + // (generated at height x width, then `transpose`), because | ||
| 13874 | + // aomenc's RD picks `PARTITION_VERT_4` on this content and | ||
| 13875 | + // essentially never `HORZ_4`: the two arms are a transposed | ||
| 13876 | + // pair, and a gate that only ever sees one of them cannot catch | ||
| 13877 | + // a transposed scan/context table (class scan-weights-cross-axis). | ||
| 13878 | + let source = if attempt % 2 == 0 { | ||
| 13879 | + gradients_source(seed, width, height, &format!("duration={duration}:rate=25")) | ||
| 13880 | + } else { | ||
| 13881 | + format!( | ||
| 13882 | + "{},transpose=1", | ||
| 13883 | + gradients_source(seed, height, width, &format!("duration={duration}:rate=25")) | ||
| 13884 | + ) | ||
| 13885 | + }; | ||
| 13886 | + let y4m = Command::new("ffmpeg") | ||
| 13887 | + .args([ | ||
| 13888 | + "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | ||
| 13889 | + "yuv4mpegpipe", "-", | ||
| 13890 | + ]) | ||
| 13891 | + .stdin(Stdio::null()) | ||
| 13892 | + .stdout(Stdio::piped()) | ||
| 13893 | + .stderr(Stdio::piped()) | ||
| 13894 | + .output() | ||
| 13895 | + .expect("ffmpeg failed to run"); | ||
| 13896 | + assert!( | ||
| 13897 | + y4m.status.success(), | ||
| 13898 | + "ffmpeg fixture: {}", | ||
| 13899 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 13900 | + ); | ||
| 13901 | + let args: Vec<&str> = vec![ | ||
| 13902 | + "--codec=av1", | ||
| 13903 | + "--passes=1", | ||
| 13904 | + "--end-usage=q", | ||
| 13905 | + "--cq-level=45", | ||
| 13906 | + "--cpu-used=0", | ||
| 13907 | + "--threads=1", | ||
| 13908 | + "--row-mt=0", | ||
| 13909 | + "--sb-size=64", | ||
| 13910 | + "--enable-rect-partitions=1", | ||
| 13911 | + "--enable-ab-partitions=0", | ||
| 13912 | + "--enable-1to4-partitions=1", | ||
| 13913 | + "--min-partition-size=16", | ||
| 13914 | + "--max-partition-size=64", | ||
| 13915 | + "--enable-restoration=0", | ||
| 13916 | + "--enable-palette=0", | ||
| 13917 | + "--deltaq-mode=0", | ||
| 13918 | + "--enable-filter-intra=0", | ||
| 13919 | + "--enable-cfl-intra=0", | ||
| 13920 | + "--enable-intrabc=0", | ||
| 13921 | + "--enable-tx-size-search=0", | ||
| 13922 | + "--obu", | ||
| 13923 | + "-o", | ||
| 13924 | + "-", | ||
| 13925 | + "-", | ||
| 13926 | + ]; | ||
| 13927 | + let mut child = Command::new(aomenc_path()) | ||
| 13928 | + .args(&args) | ||
| 13929 | + .stdin(Stdio::piped()) | ||
| 13930 | + .stdout(Stdio::piped()) | ||
| 13931 | + .stderr(Stdio::piped()) | ||
| 13932 | + .spawn() | ||
| 13933 | + .expect("aomenc failed to start"); | ||
| 13934 | + child | ||
| 13935 | + .stdin | ||
| 13936 | + .take() | ||
| 13937 | + .expect("aomenc stdin") | ||
| 13938 | + .write_all(&y4m.stdout) | ||
| 13939 | + .expect("writing y4m to aomenc"); | ||
| 13940 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 13941 | + assert!( | ||
| 13942 | + out.status.success(), | ||
| 13943 | + "aomenc refused the fixture: {}", | ||
| 13944 | + String::from_utf8_lossy(&out.stderr) | ||
| 13945 | + ); | ||
| 13946 | + let stream = out.stdout; | ||
| 13947 | + let before = ( | ||
| 13948 | + crate::decode::sb_rect4_horz_hits(), | ||
| 13949 | + crate::decode::sb_rect4_vert_hits(), | ||
| 13950 | + ); | ||
| 13951 | + let frames = match decode_stream(&stream) { | ||
| 13952 | + Err(e) => { | ||
| 13953 | + let msg = e.to_string(); | ||
| 13954 | + assert!( | ||
| 13955 | + msg.contains("unsupported"), | ||
| 13956 | + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" | ||
| 13957 | + ); | ||
| 13958 | + named_refusals += 1; | ||
| 13959 | + eprintln!("seed {seed} refusal: {msg}"); | ||
| 13960 | + continue; | ||
| 13961 | + } | ||
| 13962 | + Ok(frames) => frames, | ||
| 13963 | + }; | ||
| 13964 | + let (horz, vert) = ( | ||
| 13965 | + crate::decode::sb_rect4_horz_hits() - before.0, | ||
| 13966 | + crate::decode::sb_rect4_vert_hits() - before.1, | ||
| 13967 | + ); | ||
| 13968 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); | ||
| 13969 | + assert_eq!(frames.len(), frame_count); | ||
| 13970 | + let mismatched = frames | ||
| 13971 | + .iter() | ||
| 13972 | + .zip(&ffmpeg_frames) | ||
| 13973 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | ||
| 13974 | + if horz + vert == 0 { | ||
| 13975 | + // Out of this gate's territory: aomenc's RD picked no 1:4 | ||
| 13976 | + // partition at all for this seed, so the attempt can neither | ||
| 13977 | + // prove nor disprove the arms under test. NOT silently | ||
| 13978 | + // dropped -- counted and printed, and a mismatch here is | ||
| 13979 | + // reported as a defect of another lane's shape (r1 found | ||
| 13980 | + // one: seed 55 of this very recipe decodes 3944 wrong luma | ||
| 13981 | + // samples with zero 1:4 blocks in the stream, first at | ||
| 13982 | + // (154, 59), inside the 64x32 `PARTITION_HORZ` superblock at | ||
| 13983 | + // (128, 64) -- see lanes/tx64x16-r1.report.md). Selecting on | ||
| 13984 | + // "the stream contains the feature", never on "the stream | ||
| 13985 | + // decoded correctly", is what keeps this from being survivor | ||
| 13986 | + // bias. | ||
| 13987 | + out_of_scope += 1; | ||
| 13988 | + if mismatched { | ||
| 13989 | + out_of_scope_mismatch += 1; | ||
| 13990 | + eprintln!( | ||
| 13991 | + "{NAME}: seed {seed} MISMATCHES with zero 1:4 blocks -- a pre-existing \ | ||
| 13992 | + defect of another shape, not this gate's arms" | ||
| 13993 | + ); | ||
| 13994 | + } | ||
| 13995 | + continue; | ||
| 13996 | + } | ||
| 13997 | + if mismatched { | ||
| 13998 | + if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { | ||
| 13999 | + std::fs::write(&path, &stream).expect("writing pinned stream"); | ||
| 14000 | + eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); | ||
| 14001 | + } | ||
| 14002 | + } | ||
| 14003 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 14004 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (seed {seed})"); | ||
| 14005 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (seed {seed})"); | ||
| 14006 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (seed {seed})"); | ||
| 14007 | + } | ||
| 14008 | + horz_proved += horz; | ||
| 14009 | + vert_proved += vert; | ||
| 14010 | + matched += 1; | ||
| 14011 | + } | ||
| 14012 | + assert!( | ||
| 14013 | + matched > 0, | ||
| 14014 | + "{NAME}: every attempt refused; the gate never decoded a stream" | ||
| 14015 | + ); | ||
| 14016 | + assert!( | ||
| 14017 | + horz_proved > 0 && vert_proved > 0, | ||
| 14018 | + "{NAME}: a 1:4 arm never fired inside a pixel-exact attempt \ | ||
| 14019 | + (horz={horz_proved}, vert={vert_proved}, {matched} matches, {named_refusals} \ | ||
| 14020 | + refusals out of {n_attempts}) -- gate proved nothing this run" | ||
| 14021 | + ); | ||
| 14022 | + eprintln!( | ||
| 14023 | + "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of \ | ||
| 14024 | + {n_attempts}, horz_4 strips={horz_proved}, vert_4 strips={vert_proved}, \ | ||
| 14025 | + {out_of_scope} attempts carried no 1:4 block ({out_of_scope_mismatch} of them \ | ||
| 14026 | + mismatched -- other lanes' shapes)" | ||
| 14027 | + ); | ||
| 14028 | + } | ||
| 13836 | } | 14029 | } |
lanes/tx64x16-r1.report.mdadded+138 -0
| @@ -0,0 +1,138 @@ | |||
| 1 | +# lane-tx64x16 r1 — the 1:4 pair at 64x64 (TX_64X16 / TX_16X64) | ||
| 2 | + | ||
| 3 | +Branch `lane-tx64x16`, worktree `edith_codecs-tx64x16`, off main `dc5553f`. | ||
| 4 | + | ||
| 5 | +## STATUS: INCOMPLETE — gate RED. The refusal is narrowed in the code but NOT | ||
| 6 | +proven: a real `PARTITION_VERT_4` stream with coefficients still mismatches. | ||
| 7 | +Do not merge as is. | ||
| 8 | + | ||
| 9 | +## Premises re-measured (charter carried two stale ones) | ||
| 10 | + | ||
| 11 | +- "the refusal string now names the 1:4 pair" — FALSE at `dc5553f`. It read | ||
| 12 | + *"a superblock-level partition type other than NONE or SPLIT"* | ||
| 13 | + (`refusal_inventory.rs:48`) while `decode.rs` already coded HORZ/VERT; the AB | ||
| 14 | + arms part32-r5 reports are NOT on main. Command: | ||
| 15 | + `grep -n "64" crates/ec-av1/src/refusal_inventory.rs`. | ||
| 16 | +- "requires the transform primitives (TX_64X16 / TX_16X64 …)" — FALSE. They | ||
| 17 | + already exist: `inverse_transform_2d_typed_wh` (transform.rs:817) is generic | ||
| 18 | + in (w,h), already zeroes everything past the low 32 on a 64-length axis | ||
| 19 | + (`transform.rs:842`), already gets the rect scale right (fires only at | ||
| 20 | + log2 ratio 1, i.e. never for 4:1 — `transform.rs:837`, and its comment | ||
| 21 | + already names 16x64/64x16), and `row_shift_wh` (transform.rs:288) already | ||
| 22 | + carries `(16,64)|(64,16) => 2` and `(8,32)|(32,8) => 2`, both verified | ||
| 23 | + against `av1_inv_txfm_shift_ls` / `inv_shift_64x16` == `{-2,-4}` | ||
| 24 | + (`~/.cache/aom-oracle/src/av1/common/av1_inv_txfm2d.c:150`). Dequant is | ||
| 25 | + area-keyed (`dq_denom_area`), and `av1_get_tx_scale` is too (1024 pels → 1). | ||
| 26 | + Nothing was owed here; the real work was entropy wiring + partition wiring. | ||
| 27 | + | ||
| 28 | +## What changed | ||
| 29 | + | ||
| 30 | +- `crates/ec-av1/src/decode.rs` | ||
| 31 | + - `SCAN_32X8` / `SCAN_8X32` (new, ~line 1650): row-major transcriptions of | ||
| 32 | + libaom `default_scan_32x8` / `default_scan_8x32`, converted with | ||
| 33 | + `row*w+col = (p % h)*w + (p / h)` from libaom's COLUMN-major `p`. The rule | ||
| 34 | + was validated by reproducing this repo's existing `SCAN_16X8` byte for byte | ||
| 35 | + from `default_scan_16x8` before generating anything new — and libaom's | ||
| 36 | + `default_scan_16x8` literal is byte-identical to this repo's `SCAN_8X16`, | ||
| 37 | + i.e. a naive copy installs the transpose (class | ||
| 38 | + reference-layout-not-spec). | ||
| 39 | + - `decode_block_rect64`: luma corner generalised from a hardcoded 32x32 to | ||
| 40 | + `(bw.min(32), bh.min(32))`, reading 32x16/16x32 through `read_coeffs_rect` | ||
| 41 | + with `SCAN_32X16`/`SCAN_16X32` and `TxbSet::LumaRect32x16`; chroma set/scan | ||
| 42 | + picked per shape, 32x8/8x32 reading `TxbSet::Chroma16` with the new scans. | ||
| 43 | + Why no new CDF tables are owed, all read out of the oracle source: | ||
| 44 | + `av1_get_adjusted_tx_size` maps TX_64X16→TX_32X16, TX_16X64→TX_16X32 | ||
| 45 | + (`blockd.h:1361`); `av1_scan_orders` gives TX_64X16 `default_scan_32x16` | ||
| 46 | + ("tx32's scan order is used", `scan.c`); `get_txsize_entropy_ctx` is 3 for | ||
| 47 | + both TX_64X16 and TX_32X16 and 2 for both TX_32X8 and TX_16X16; | ||
| 48 | + `txsize_log2_minus4` is 5 for TX_64X16 *and* TX_32X16, 4 for TX_32X8 *and* | ||
| 49 | + TX_16X16 (`common_data.h:346`) so the eob alphabet matches too; and | ||
| 50 | + `av1_nz_map_ctx_offset[TX_64X16]` is literally | ||
| 51 | + `av1_nz_map_ctx_offset_32x16` (`txb_common.c:340`) — which is what | ||
| 52 | + `base_ctx_rect(32,16)` computes, since both raw and coded dims are w>h. | ||
| 53 | + - `PARTITION_HORZ_4`/`PARTITION_VERT_4` (8/9) wired at the superblock level: | ||
| 54 | + four strips, `quarter_step` = 1 SUB unit, with libaom's `i > 0` frame-edge | ||
| 55 | + break. | ||
| 56 | + - New per-orientation hit counters `sb_rect4_horz_hits()` / | ||
| 57 | + `sb_rect4_vert_hits()`. | ||
| 58 | +- `crates/ec-av1/src/refusal_inventory.rs`: SB-level string narrowed to | ||
| 59 | + "a superblock-level HORZ_A/HORZ_B/VERT_A/VERT_B partition (… codes NONE, | ||
| 60 | + SPLIT, HORZ, VERT and the 1:4 pair at 64x64)". | ||
| 61 | +- `crates/ec-av1/src/stream.rs`: new gate | ||
| 62 | + `a_real_aomenc_stream_with_a_superblock_level_1to4_partition_decodes_pixel_exact`. | ||
| 63 | +- `crates/ec-av1/fixtures/tx64x16-vert4-mismatch-seed73.obu`: the failing | ||
| 64 | + stream, pinned. | ||
| 65 | + | ||
| 66 | +## Gate | ||
| 67 | + | ||
| 68 | +`cargo test -p ec-av1 --lib -- --exact stream::tests::a_real_aomenc_stream_with_a_superblock_level_1to4_partition_decodes_pixel_exact` | ||
| 69 | +(`EC_TX64X16_GATE_ATTEMPTS`, default 40). aomenc recipe = the sbpart gate's, | ||
| 70 | +with `--enable-1to4-partitions=1` and `--min-partition-size=16`; odd attempts | ||
| 71 | +render the generator rotated 90 degrees (`transpose=1`) because aomenc picks | ||
| 72 | +VERT_4 on this content and essentially never HORZ_4, and the two arms are a | ||
| 73 | +transposed pair. Attempts whose decode fired zero 1:4 strips are counted and | ||
| 74 | +printed, never asserted on — selection is on "the stream contains the | ||
| 75 | +feature", never on "the stream decoded correctly". | ||
| 76 | + | ||
| 77 | +RESULT: **FAIL**. `seed 73` (a stream with four real 16x64 `PARTITION_VERT_4` | ||
| 78 | +strips at mi(16,16..28)) mismatches ffmpeg: 10754 wrong luma samples, first at | ||
| 79 | +(64, 56) — one row band ABOVE the strips, i.e. across the y=64 deblock edge. | ||
| 80 | +An earlier 13-attempt run (before the transpose arm) had VERT_4 fire 4 strips | ||
| 81 | +and decode PIXEL-EXACT, so the skip/low-energy case works and the coded case | ||
| 82 | +does not. | ||
| 83 | + | ||
| 84 | +EVIDENCE: /home/user/Documents/Code/Rust/edith_codecs-tx64x16/crates/ec-av1/fixtures/tx64x16-vert4-mismatch-seed73.obu | decode_probe dump vs `ffmpeg -f rawvideo`, EC_AV1_TRACE partition trace | 10754/24576 luma samples differ, first (64,56); trace shows `partition_w64 value=9` then four `TRACE_RECT64_END bw=16 bh=64` | ||
| 85 | +EVIDENCE: gate stdout above | 40 aomenc attempts, seeds 42..81, `--enable-1to4-partitions=1` | 21 named refusals, VERT_4 arm reached a real decode, HORZ_4 arm never selected by aomenc on this content | ||
| 86 | + | ||
| 87 | +## Open, with dispositions | ||
| 88 | + | ||
| 89 | +- **fix-now (r2)**: the coded-16x64 mismatch above. Not yet root-caused. | ||
| 90 | + Ruled out by reading the oracle source, NOT by experiment: shift chain | ||
| 91 | + (`inv_shift_64x16`/`inv_shift_16x64` = {-2,-4} = our `row_shift_wh` 2), rect | ||
| 92 | + scale (4:1 gets none), dequant denominator (area 1024 → 2), eob alphabet | ||
| 93 | + (512), CDF set, scan choice, nz-map offset table. Untested suspects, in | ||
| 94 | + order: (1) the deblock grid for a 1:4 strip | ||
| 95 | + (`fill_lf_grid_rect(.., tx_w=16, tx_h=64, 0)`) — the first diffs are on the | ||
| 96 | + OTHER side of the edge; (2) 16x64 intra prediction edge reach; (3) the | ||
| 97 | + chroma 8x32 plane. First move should be a prefilt dump | ||
| 98 | + (`EC_AV1_PREFILT_DUMP`) to split "reconstruction wrong" from "deblock | ||
| 99 | + wrong" — the diff band starting above the block is exactly the tell that | ||
| 100 | + cost lane-tiny a round. | ||
| 101 | +- **deferred(a green 64-level gate)**: the 32x32-level 1:4 arms. They ARE | ||
| 102 | + requested by this recipe — `a 32x32 partition type this decoder does not | ||
| 103 | + code (value=9)` appears in the sweep — and need TX_32X8/TX_8X32 luma | ||
| 104 | + (`TxbSet::Luma16` exactly: entropy ctx 2, eob 256) plus 16x4/4x16 chroma | ||
| 105 | + (`TxbSet::Chroma8`: ctx 1, eob 64) and two more scans. Same shape of work, | ||
| 106 | + not started. | ||
| 107 | +- **flagged, not this lane's shape (pre-existing)**: with | ||
| 108 | + `--min-partition-size=16`, seed 55 of this recipe decodes 3944 wrong luma | ||
| 109 | + samples with ZERO 1:4 blocks in the stream (trace: SB(1,0) SPLIT with a | ||
| 110 | + 32x32 `PARTITION_HORZ`, SB(1,2) a 64x32 `PARTITION_HORZ`), first diff at | ||
| 111 | + (154, 59). My diff cannot reach that stream (every path it touches needs a | ||
| 112 | + 16-with-64 dimension pair), so it is a pre-existing defect of the 32x16 / | ||
| 113 | + 64x32 strip shapes exposed by a recipe the existing sbpart gate | ||
| 114 | + (`--min-partition-size=32`) never uses. Stream: rerun the gate with | ||
| 115 | + `EC_AV1_GATE_DUMP` at `EC_TX64X16_GATE_ATTEMPTS=14`. | ||
| 116 | +- **accepted**: `palette_bsize_ctx_wh` has no rect caller at all | ||
| 117 | + (`read_intra_mode_rect` never reads a palette symbol), so 64x16/16x64 need | ||
| 118 | + no entry there; a screen-content rect strip is a different lane's hole. | ||
| 119 | + | ||
| 120 | +## Suite totals | ||
| 121 | + | ||
| 122 | +`cargo test -p ec-av1 --lib` (worktree, `CARGO_TARGET_DIR=~/.cache/cargo-target-tx64x16`, | ||
| 123 | +1347s under a 10-lane concurrent load): | ||
| 124 | +**256 passed, 17 failed, 22 ignored, 0 filtered out.** | ||
| 125 | +Two of the 17 captured by name -- | ||
| 126 | +`stream::tests::a_real_aomenc_superres_key_frame_sequence_decodes_pixel_exact` | ||
| 127 | +and `stream::tests::real_aomenc_film_grain_streams_decode_pixel_exact` -- are | ||
| 128 | +outside anything this diff can reach (no 16-with-64 dimension pair), plus this | ||
| 129 | +lane's own new gate. The remaining 14 were NOT enumerated: the capture pipeline | ||
| 130 | +dropped the failure list and a re-run costs another 22 minutes, which the tool | ||
| 131 | +budget did not have. A successor MUST re-run this and diff the failure set | ||
| 132 | +against `main` before attributing any of it to this branch. | ||
| 133 | + | ||
| 134 | +Note: `crates/ec-av1/fixtures/` is covered by `.gitignore:2 (fixtures)`, so the | ||
| 135 | +pinned mismatching stream is NOT in the commit -- it is on disk in the worktree | ||
| 136 | +at `crates/ec-av1/fixtures/tx64x16-vert4-mismatch-seed73.obu` | ||
| 137 | +(sha256 0d9c3dd8a178a96309ea7165f3018146b5e09e660fd78a6870da2a5b5b1b60c1) and | ||
| 138 | +regenerable by the gate with `EC_AV1_GATE_DUMP`. | ||
lanes/tx64x16-r2.report.mdadded+113 -0
| @@ -0,0 +1,113 @@ | |||
| 1 | +# lane-tx64x16 r2 — the SB-level 1:4 pair is GREEN; r1's "17 failures" were a stale base | ||
| 2 | + | ||
| 3 | +Branch `lane-tx64x16`, rebased dc5553f -> `5811ec5` -> **`6d86d3a`** (current main | ||
| 4 | +at the time of writing). Commits: `3435835` (r1 wiring, replayed), `23aa4b3` | ||
| 5 | +(r1 report), `d1f71b6` (this round). | ||
| 6 | + | ||
| 7 | +## Headline | ||
| 8 | + | ||
| 9 | +**r1's red gate was a STALE BASE, not a defect.** Nothing in the 1:4 wiring | ||
| 10 | +changed this round. Rebasing onto main turns | ||
| 11 | +`a_real_aomenc_stream_with_a_superblock_level_1to4_partition_decodes_pixel_exact` | ||
| 12 | +GREEN (both arms hard-asserted, 40 aomenc attempts), and the r1 suite's | ||
| 13 | +"17 failed" collapses to 2 — neither of them reachable by this lane's diff. | ||
| 14 | + | ||
| 15 | +Class for the ledger: **stale-premise lane** (5th instance) — a lane whose gate | ||
| 16 | +is red against a base that is 20 merges behind measures the base, not its own | ||
| 17 | +change. Re-measure the premise on today's main BEFORE bisecting your own diff. | ||
| 18 | + | ||
| 19 | +## The 17, enumerated (charter's first job) | ||
| 20 | + | ||
| 21 | +They do not exist on the rebased branch. Full `cargo test -p ec-av1 --lib` | ||
| 22 | +(`EC_AV1_REQUIRE_AOMENC=1`) on the rebase-onto-5811ec5 tree, before any fix of | ||
| 23 | +mine: **290 passed, 2 failed, 27 ignored**, the two being | ||
| 24 | + | ||
| 25 | +1. `decode::tests::nz_map_ctx_offset_tables_match_the_rect_rule` — **RED ON | ||
| 26 | + MAIN**, not caused by this branch (`git diff --stat main..HEAD` touches | ||
| 27 | + `decode.rs` (partition arms + counters + scans), `refusal_inventory.rs`, | ||
| 28 | + `stream.rs` only; the table, its consumer and this test are all main's). | ||
| 29 | + Root cause: the test read `NZ_MAP_CTX_OFFSET_32X64`/`_64X32` as | ||
| 30 | + `table[col][row]` — lane-rectsplit r2's column-major premise, which r3 | ||
| 31 | + disproved and reverted in the *tables* without reverting the *test*. The | ||
| 32 | + tables as they stand are display-major and satisfy libaom's generating rule | ||
| 33 | + (`txb_common.h:199-209`) read `[row][col]`, which is exactly how the only | ||
| 34 | + real consumer reads them (`base_ctx`, `TxClass::TwoD` arm, | ||
| 35 | + `crates/ec-av1/src/decode.rs:1829`) and the reading every merged rect gate | ||
| 36 | + is green under. FIX: read the test in the consumer's order. Table content | ||
| 37 | + untouched — zero risk to the 64x32/32x64 path. | ||
| 38 | + Verification of the direction: for `TX_32X64` (w<h) libaom's rule gives | ||
| 39 | + `11+ctx` for every `row < 2`; our const's row 0 is `[0,11,11,11,11]` and row | ||
| 40 | + 2 is `[6,6,21,21,21]` = `row+col<4 -> 6`, i.e. display-major and correct. | ||
| 41 | +2. `gate_coverage::tests::never_exercised_8bit_matches_the_gate_recipes` — | ||
| 42 | + caused by this branch, and by design: this lane's gate is the first to pass | ||
| 43 | + `--enable-1to4-partitions=1` at 8 bit, so the 8-bit coverage hole is retired. | ||
| 44 | + FIX: entry deleted from `NEVER_EXERCISED_8BIT`; the 10-bit entry stays and | ||
| 45 | + now says "10-bit hole only". | ||
| 46 | + | ||
| 47 | +Bisecting the corner generalisation vs the scan additions (the charter's plan) | ||
| 48 | +was therefore not needed and not run — the premise it rested on ("a change that | ||
| 49 | +breaks 17 gates") was false. | ||
| 50 | + | ||
| 51 | +## Rebase conflict resolutions (main had moved onto the same lines) | ||
| 52 | + | ||
| 53 | +- `decode.rs` SB partition dispatch: BOTH arms kept — main's | ||
| 54 | + `PARTITION_HORZ_A/_B/VERT_A/_B` (part32 r4) and this lane's | ||
| 55 | + `PARTITION_HORZ_4/VERT_4`; `reduced_tx_set` (new on main) threaded into the | ||
| 56 | + 1:4 `decode_block_rect64` calls. | ||
| 57 | +- `decode.rs` counters: both `SB_AB_HITS` and `SB_RECT4_{HORZ,VERT}_HITS` kept. | ||
| 58 | +- The `_` arm of the SB partition match is now unreachable (all ten partition | ||
| 59 | + values are coded at 64x64); it refuses "a superblock-level partition value | ||
| 60 | + outside PARTITION_NONE..PARTITION_VERT_4" and `refusal_inventory` lists that | ||
| 61 | + string instead of the retired 1:4 one. | ||
| 62 | +- `stream.rs`: git had spliced this lane's gate INTO main's AB gate. Resolved by | ||
| 63 | + taking main's file whole and re-appending the 1:4 gate function verbatim. | ||
| 64 | + | ||
| 65 | +## Refusal lifted | ||
| 66 | + | ||
| 67 | +`"a superblock-level 1:4 partition (PARTITION_HORZ_4/VERT_4 at 64x64, four | ||
| 68 | +64x16/16x64 strips)"` — gone from `decode.rs` and `refusal_inventory.rs`, with | ||
| 69 | +the gate above green. `refusal_inventory` + all five `gate_coverage` tests green. | ||
| 70 | + | ||
| 71 | +## EVIDENCE | ||
| 72 | + | ||
| 73 | +EVIDENCE: ~/.cache/tx64-sb-gates.log | `cargo test -p ec-av1 --lib -- superblock_level` with EC_AV1_REQUIRE_AOMENC=1 on d1f71b6 | 3 passed, 0 failed, 1 ignored (rect64q drift gate, ignored on main): the 1:4 gate AND both sibling SB gates (horz_vert, ab) green — SIBLING GATES rule satisfied | ||
| 74 | +EVIDENCE: ~/.cache/tx64-suite-r2.log | full `cargo test -p ec-av1 --lib`, rebase onto 5811ec5, before my fixes | 290 passed / 2 failed / 27 ignored — the two named above, replacing r1's unenumerated 17 | ||
| 75 | +EVIDENCE: /tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/b6d8a07f-96a4-4bbb-b378-af9ae25cf7c9/scratchpad/reelc.obu (sha256 32e0619ca9fd9ae0e16072c66013757aa7abfedccc99bc6d3509f6e213195226, `ffmpeg -ss 300 -t 0.4 -c:v copy -f obu`) | `cargo run -p ec-av1 --example decode_probe` on d1f71b6 | ReelC no longer stops at the 1:4 refusal; new stop is "a superblock-level HORZ/VERT strip with a split transform (per-unit rect prediction is not ported)" — the refusal lane-rectsplit r4 (7b55227) lifts | ||
| 76 | +EVIDENCE: ~/.cache/tx64-suite-r2b.log | full `cargo test -p ec-av1 --lib` on d1f71b6 (rebased onto 6d86d3a, both fixes in) | see "Suite totals" below | ||
| 77 | + | ||
| 78 | +## Open, with dispositions | ||
| 79 | + | ||
| 80 | +- **fix-now, NEXT ROUND (ReelB critical path)**: the **32x32-level** | ||
| 81 | + `PARTITION_HORZ_4/VERT_4` (`decode.rs:9384`, refusal "a 32x32 partition type | ||
| 82 | + this decoder does not code (value={part32})", value 8 = HORZ_4). Shape of the | ||
| 83 | + work, already scouted: four `decode_block_rect(at32, 32, 8)` / | ||
| 84 | + `(8, 32)` strips at `quarter_step` = 1 mi-pair, same `i > 0` frame-edge break | ||
| 85 | + as the 64-level arm. Luma TX_32X8/TX_8X32 are their own adjusted size | ||
| 86 | + (`av1_get_adjusted_tx_size` leaves them alone), entropy ctx = TX_16X16 and | ||
| 87 | + `txsize_log2_minus4` = 4 (256 positions) => `TxbSet::Luma16` exactly, and the | ||
| 88 | + scans **already exist** in this branch: `SCAN_32X8` / `SCAN_8X32` | ||
| 89 | + (`decode.rs:1952`/`1969`). What is genuinely missing is CHROMA 16x4 / 4x16: | ||
| 90 | + `TxbSet::Chroma8` (ctx TX_8X8, 64 positions) plus two new scans | ||
| 91 | + `default_scan_16x4` / `default_scan_4x16`, transcribed with this repo's | ||
| 92 | + column-major -> row-major rule (`row*w+col = (p % h)*w + (p / h)`; validate | ||
| 93 | + the rule by regenerating an existing scan first — a naive copy installs the | ||
| 94 | + transpose). | ||
| 95 | +- **deferred(the 32-level arms above)**: a 10-bit twin of the 1:4 gate. The | ||
| 96 | + `NEVER_EXERCISED_10BIT` entry for `enable-1to4-partitions` is still live and | ||
| 97 | + now says so explicitly. | ||
| 98 | +- **flagged, resolved**: r1's "pre-existing seed-55 defect (3944 wrong luma, | ||
| 99 | + zero 1:4 blocks)" did not reproduce on the rebased tree — the 1:4 gate runs | ||
| 100 | + all 40 seeds of that same recipe (seeds 42..81, `--min-partition-size=16`) and | ||
| 101 | + every decoded attempt now compares pixel-exact, including seed 55. It was | ||
| 102 | + another symptom of the stale base (main has since landed inter8/rectsplit/ | ||
| 103 | + txselect/seg fixes). No separate pin is owed. | ||
| 104 | +- **accepted**: `main` moved again during the round (rectsplit r4 `7b55227` is | ||
| 105 | + not yet merged). If it lands first, its `base_ctx` rewrite may delete | ||
| 106 | + `NZ_MAP_CTX_OFFSET_32X64/_64X32` outright and conflict with my one-line test | ||
| 107 | + fix — resolve by taking r4's version, the defect is the same one. | ||
| 108 | + | ||
| 109 | +## Suite totals | ||
| 110 | + | ||
| 111 | +`cargo test -p ec-av1 --lib` with `EC_AV1_REQUIRE_AOMENC=1`, on `d1f71b6`: | ||
| 112 | +**295 passed, 0 failed, 27 ignored, 0 filtered out** (1234s under concurrent lane load). | ||
| 113 | +Both failures above are fixed; no new failure introduced. r1's 256/17/22 is superseded. | ||