Merge branch 'lane-sub8x4' (8c74306): intra 8x4/4x8/4x4 leaves and intra 16x4/4x16 strips inside inter partitions, TX_64X32/32X64 corner TUs lifted with a pinned 10-bit 3840x1608 witness; the 4K head cut decodes 48 frames with no refusal
Browse files at this commit15 changed files +2711 -250
- crates/ec-av1/examples/decode_probe.rs +11 -0
- crates/ec-av1/fixtures/reelb_rect64_intra16x4_witness.obu +0 -0
- crates/ec-av1/src/decode.rs +1110 -237
- crates/ec-av1/src/mvstack.rs +32 -8
- crates/ec-av1/src/refusal_inventory.rs +0 -2
- crates/ec-av1/src/stream.rs +664 -3
- lanes/intra16x4-r1.handoff.md +72 -0
- lanes/intra16x4-r1.report.md +110 -0
- lanes/intra16x4-r2.handoff.md +67 -0
- lanes/intra16x4-r3.handoff.md +97 -0
- lanes/sub8intra-r1.handoff.md +108 -0
- lanes/sub8intra-r2.handoff.md +73 -0
- lanes/sub8x4-r1.handoff.md +138 -0
- lanes/sub8x4-r2.handoff.md +118 -0
- lanes/sub8x4-r3.report.md +111 -0
crates/ec-av1/examples/decode_probe.rsmodified+11 -0
| @@ -45,6 +45,11 @@ fn main() { | ||
| 45 | 45 | println!("sub8_inter_split: groups={}", ec_av1::decode::sub8_inter_split_hits()); |
| 46 | 46 | let (h84, h48) = ec_av1::decode::sub8_inter_rect_hits(); |
| 47 | 47 | println!("sub8_inter_rect: horz8x4={h84} vert4x8={h48}"); |
| 48 | + let si = ec_av1::stream::sub8_intra_rect_hits(); | |
| 49 | + println!( | |
| 50 | + "sub8_intra_rect: horz8x4={} vert4x8={} chroma_ref={} mixed={} split4x4={}", | |
| 51 | + si.0, si.1, si.2, si.3, si.4 | |
| 52 | + ); | |
| 48 | 53 | let leaf = ec_av1::stream::vartx_rect_leaf_hits(); |
| 49 | 54 | println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]); |
| 50 | 55 | // lane-inter16ab r1: the 16x16-level inter AB arms, so a recipe sweep |
| @@ -110,6 +115,12 @@ fn main() { | ||
| 110 | 115 | // rectangular residual transform unit (a skipped one codes none). |
| 111 | 116 | let r328 = ec_av1::stream::rect32x8_inter_tu_hits(); |
| 112 | 117 | println!("rect32x8_inter_tu: 32x8={} 8x32={}", r328[0], r328[1]); |
| 118 | + // lane-intra16x4: INTRA strips of an inter 16x16-level 1:4 partition. | |
| 119 | + let i164 = ec_av1::stream::intra16x4_in_inter_hits(); | |
| 120 | + println!( | |
| 121 | + "intra16x4_in_inter: 16x4={} 4x16={} chroma_ref={}", | |
| 122 | + i164.0, i164.1, i164.2 | |
| 123 | + ); | |
| 113 | 124 | }; |
| 114 | 125 | // lane-tiles: the tiling a real stream actually uses is a decision input |
| 115 | 126 | // (every gate in `stream.rs` picks its own `--tile-columns`), so report it |
crates/ec-av1/fixtures/reelb_rect64_intra16x4_witness.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+1110 -237
| @@ -2691,6 +2691,21 @@ thread_local! { | ||
| 2691 | 2691 | static INTER16_SUB8_PIECE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2692 | 2692 | } |
| 2693 | 2693 | |
| 2694 | +// lane-intra16x4: INTRA-coded strips of an inter 16x16-level 1:4 partition -- | |
| 2695 | +// [0] 16x4, [1] 4x16, [2] the odd (chroma-reference) ones, which carry the | |
| 2696 | +// pair's single 8x4 (4x8) chroma unit for BOTH strips. | |
| 2697 | +thread_local! { | |
| 2698 | + static INTRA16X4_IN_INTER_HITS: std::cell::Cell<[usize; 3]> = | |
| 2699 | + const { std::cell::Cell::new([0; 3]) }; | |
| 2700 | +} | |
| 2701 | + | |
| 2702 | +/// `(intra 16x4 strips, intra 4x16 strips, of which chroma-reference)` decoded | |
| 2703 | +/// inside an INTER 16x16-level 1:4 partition (lane-intra16x4). | |
| 2704 | +pub fn intra16x4_in_inter_hits() -> (usize, usize, usize) { | |
| 2705 | + let v = INTRA16X4_IN_INTER_HITS.with(std::cell::Cell::get); | |
| 2706 | + (v[0], v[1], v[2]) | |
| 2707 | +} | |
| 2708 | + | |
| 2694 | 2709 | /// Current values of the inter 16x16-level 1:4 counters: `(16x4 strips, 4x16 |
| 2695 | 2710 | /// strips, chroma pairs closed, chroma pairs built from two different |
| 2696 | 2711 | /// strips' motion vectors)`. |
| @@ -3108,6 +3123,24 @@ thread_local! { | ||
| 3108 | 3123 | /// inter leaves (lane-intersub8 r3), indexed `[0] = HORZ` (two BLOCK_8X4), |
| 3109 | 3124 | /// `[1] = VERT` (two BLOCK_4X8). |
| 3110 | 3125 | static SUB8_INTER_RECT_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; |
| 3126 | + /// lane-sub8intra: INTRA leaves decoded inside an inter frame's sub-8x8 | |
| 3127 | + /// HORZ/VERT partition -- `[0]` 8x4, `[1]` 4x8, `[2]` of those that were | |
| 3128 | + /// the chroma reference (so coded the group's 4x4 chroma intra), `[3]` | |
| 3129 | + /// MIXED groups whose chroma reference is INTER while its sibling is | |
| 3130 | + /// intra (the `is_sub8x8_inter` false path), `[4]` INTRA `BLOCK_4X4` | |
| 3131 | + /// leaves of an inter frame's sub-8x8 `PARTITION_SPLIT` (lane-sub8x4 r2 -- | |
| 3132 | + /// the second lifted refusal's own witness; `[0]`/`[1]` count those too, | |
| 3133 | + /// so only this cell separates the split arm from the HORZ/VERT one). | |
| 3134 | + static SUB8_INTRA_RECT_HITS: std::cell::Cell<[usize; 5]> = const { std::cell::Cell::new([0; 5]) }; | |
| 3135 | +} | |
| 3136 | + | |
| 3137 | +/// Current value of [`SUB8_INTRA_RECT_HITS`]: `(8x4, 4x8, chroma-reference, | |
| 3138 | +/// mixed groups, split 4x4 leaves)`. | |
| 3139 | +pub fn sub8_intra_rect_hits() -> (usize, usize, usize, usize, usize) { | |
| 3140 | + SUB8_INTRA_RECT_HITS.with(|c| { | |
| 3141 | + let h = c.get(); | |
| 3142 | + (h[0], h[1], h[2], h[3], h[4]) | |
| 3143 | + }) | |
| 3111 | 3144 | } |
| 3112 | 3145 | |
| 3113 | 3146 | /// Current value of [`SUB8_INTER_RECT_HITS`]: `(8x4 groups, 4x8 groups)`. |
| @@ -4986,6 +5019,9 @@ impl Neighbours { | ||
| 4986 | 5019 | tx_h_px: u8, |
| 4987 | 5020 | ) { |
| 4988 | 5021 | let (mi_r, mi_c) = at_mi; |
| 5022 | + if std::env::var_os("EC_TXGRID_TRACE").is_some() { | |
| 5023 | + eprintln!("EC_LFLEAF mi_row={mi_r} mi_col={mi_c} w_mi={w_mi} h_mi={h_mi} tx_px={tx_px} tx_h_px={tx_h_px}"); | |
| 5024 | + } | |
| 4989 | 5025 | for rr in 0..h_mi { |
| 4990 | 5026 | for cc in 0..w_mi { |
| 4991 | 5027 | let idx = (mi_r + rr) * self.skip_grid_cols_mi + (mi_c + cc); |
| @@ -5372,7 +5408,8 @@ impl Neighbours { | ||
| 5372 | 5408 | let ctx = SKIP_CONTEXTS[(top as usize).min(4)][(left as usize).min(4)]; |
| 5373 | 5409 | if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 5374 | 5410 | eprintln!( |
| 5375 | - "TRACE luma_skip_ctx mi=({mi_r},{mi_c}) side_mi={side_mi} top={top} left={left} ctx={ctx}" | |
| 5411 | + "TRACE luma_skip_ctx mi=({mi_r},{mi_c}) side_mi={side_mi} top={top} left={left} ctx={ctx} band={:?}", | |
| 5412 | + self.left.iter().map(|e| e[0].level).collect::<Vec<_>>() | |
| 5376 | 5413 | ); |
| 5377 | 5414 | } |
| 5378 | 5415 | ctx |
| @@ -6857,14 +6894,14 @@ fn decode_rect_split( | ||
| 6857 | 6894 | // the coded unit is the 32x32 corner [`decode_block_rect64`]'s own |
| 6858 | 6895 | // depth-0 arm already reads on the key-frame path. |
| 6859 | 6896 | // |
| 6860 | - // NO WITNESS YET (r1, measured): on both 10-bit 3840x1608 film cuts | |
| 6861 | - // this arm fires (16x 64x32 + 2x 32x64 / 2x 32x64) but the SAME frame | |
| 6862 | - // then stops at "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs | |
| 6863 | - // rectangular residual coding", so no frame containing it ever | |
| 6864 | - // finishes and no pixel comparison is possible. A refusal is lifted | |
| 6865 | - // only with a gate (COMMON charter), so the arm stays behind | |
| 6866 | - // `EC_RECT64_SPLIT=1` and the refusal below is still the default. | |
| 6867 | - (64, 32) | (32, 64) if std::env::var_os("EC_RECT64_SPLIT").is_some() => None, | |
| 6897 | + // lane-sub8x4 r3: WITNESS FOUND, so this is no longer behind | |
| 6898 | + // `EC_RECT64_SPLIT`. r1's "no witness" was true only while the | |
| 6899 | + // sub-8x8 intra leaves still refused: with those lifted (r2) the | |
| 6900 | + // first 50 frame OBUs of the 10-bit 3840x1608 stream's head decode | |
| 6901 | + // all 33 frames pixel-exact against ffmpeg while this arm fires 90x | |
| 6902 | + // 64x32 + 5x 32x64 -- pinned as `fixtures/reelb_rect64_intra16x4_witness.obu` | |
| 6903 | + // and gated by `a_10bit_film_frames_with_intra_16x4_strips_and_rect64_corner_tus_decode_pixel_exact`. | |
| 6904 | + (64, 32) | (32, 64) => None, | |
| 6868 | 6905 | _ => { |
| 6869 | 6906 | return Err(unsupported(format!( |
| 6870 | 6907 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma \ |
| @@ -7228,6 +7265,9 @@ fn decode_intra_rect_in_inter( | ||
| 7228 | 7265 | bh: usize, |
| 7229 | 7266 | skip: bool, |
| 7230 | 7267 | allow_screen_content_tools: bool, |
| 7268 | + // `(PARTITION_HORZ_4, is_chroma_reference)` when this strip is one of the | |
| 7269 | + // four 16x4 / 4x16 strips of a 16x16-level 1:4 partition (lane-intra16x4). | |
| 7270 | + strip16: Option<(bool, bool)>, | |
| 7231 | 7271 | y: &mut PlaneBuf, |
| 7232 | 7272 | u: &mut PlaneBuf, |
| 7233 | 7273 | v: &mut PlaneBuf, |
| @@ -7244,6 +7284,94 @@ fn decode_intra_rect_in_inter( | ||
| 7244 | 7284 | // finding -- the category is NOT the same for every strip size). |
| 7245 | 7285 | // A 1:4 strip breaks that diagonal (BLOCK_32X8 is group 1 but cat 2), so |
| 7246 | 7286 | // it is refused by name rather than read from the wrong CDF row. |
| 7287 | + // lane-intra16x4: the 16x16-level 1:4 strip. `size_group_lookup` | |
| 7288 | + // (common_data.h:61) puts BLOCK_16X4/BLOCK_4X16 in group 0 and its | |
| 7289 | + // tx-depth category is 1 -- but nothing here has to know either, because | |
| 7290 | + // the strip decodes through the very body the KEY FRAME path proves for | |
| 7291 | + // this shape ([`decode_rect4_16_strip`]), including the 4:2:0 chroma | |
| 7292 | + // pairing (`is_chroma_reference`: strips 0 and 2 read no chroma at all, | |
| 7293 | + // strips 1 and 3 code one 8x4 (4x8) unit at the PAIR's origin). The only | |
| 7294 | + // inter-frame difference is the mode-info read, which | |
| 7295 | + // [`INTRA_IN_INTER_MODE`] switches to `read_intra_block_mode_info`'s | |
| 7296 | + // `y_mode[0]` plus the `skip` this caller already read. | |
| 7297 | + if let Some((horz, has_chroma)) = strip16 { | |
| 7298 | + if allow_screen_content_tools { | |
| 7299 | + return Err(unsupported( | |
| 7300 | + "a HORZ/VERT intra strip in a screen-content frame (palette syntax \ | |
| 7301 | + is consumed for square blocks only)", | |
| 7302 | + )); | |
| 7303 | + } | |
| 7304 | + debug_assert_eq!((bw, bh), if horz { (16, 4) } else { (4, 16) }); | |
| 7305 | + INTRA_IN_INTER_MODE.with(|c| c.set(Some((0, skip)))); | |
| 7306 | + let res = decode_rect4_16_strip( | |
| 7307 | + dec, | |
| 7308 | + cdfs, | |
| 7309 | + neighbours, | |
| 7310 | + (mi_r, mi_c), | |
| 7311 | + horz, | |
| 7312 | + has_chroma, | |
| 7313 | + // The inter strips of the same partition publish their own | |
| 7314 | + // mi-exact mode, so the key-frame caller's coarse-cell stand-in | |
| 7315 | + // has nothing to add here. | |
| 7316 | + None, | |
| 7317 | + y, | |
| 7318 | + u, | |
| 7319 | + v, | |
| 7320 | + ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get), | |
| 7321 | + allow_screen_content_tools, | |
| 7322 | + base_q_idx, | |
| 7323 | + TX_SELECT_INTER.with(std::cell::Cell::get), | |
| 7324 | + REDUCED_TX_SET_INTER.with(std::cell::Cell::get), | |
| 7325 | + ); | |
| 7326 | + INTRA_IN_INTER_MODE.with(|c| c.set(None)); | |
| 7327 | + let (mode, uv, (tx_w, tx_h)) = res?; | |
| 7328 | + // lane-intra16x4, the same publication the 2:1 intra-in-inter strip | |
| 7329 | + // makes ([`decode_intra_rect_in_inter`]'s own tail): libaom runs | |
| 7330 | + // `set_txfm_ctxs(tx_size, n4_w, n4_h, skip && is_inter, xd)` for EVERY | |
| 7331 | + // block of an inter frame, intra ones included, and | |
| 7332 | + // `txfm_partition_update` for the var-tx context. The key-frame body | |
| 7333 | + // writes neither (a key frame has no var-tx tree and its own readers | |
| 7334 | + // use the deblock grid), so the block AFTER this strip read a stale | |
| 7335 | + // band -- measured: a 128x128 8-bit stream decoded the two intra 16x4 | |
| 7336 | + // strips at mi(23,16)/(23,20) exactly and then broke on the very next | |
| 7337 | + // 16x16 row. | |
| 7338 | + txfm_partition_update_rect(neighbours, (mi_r, mi_c), (tx_w, tx_h), (bw, bh)); | |
| 7339 | + for i in 0..bw / MI { | |
| 7340 | + if let Some(cell) = neighbours.above_txfm.get_mut(mi_c + i) { | |
| 7341 | + *cell = tx_w as u8; | |
| 7342 | + } | |
| 7343 | + } | |
| 7344 | + for i in 0..bh / MI { | |
| 7345 | + if let Some(cell) = neighbours.left_txfm.get_mut(mi_r + i) { | |
| 7346 | + *cell = tx_h as u8; | |
| 7347 | + } | |
| 7348 | + } | |
| 7349 | + // [`decode_rect4_16`]'s own post-loop publication, per strip (the | |
| 7350 | + // coarse 16-px cell holds one entry for the whole 16x16 and the last | |
| 7351 | + // block to write it wins). | |
| 7352 | + neighbours.above_mode[c] = mode; | |
| 7353 | + neighbours.left_mode[r] = mode; | |
| 7354 | + if let Some(uvm) = uv { | |
| 7355 | + neighbours.above_uv_mode[c] = uvm; | |
| 7356 | + neighbours.left_uv_mode[r] = uvm; | |
| 7357 | + } | |
| 7358 | + neighbours.above_side[c] = bw; | |
| 7359 | + neighbours.left_side[r] = bh; | |
| 7360 | + if std::env::var_os("EC_INTRA16X4").is_some() { | |
| 7361 | + eprintln!( | |
| 7362 | + "EC_INTRA16X4 decoded mi={mi_r},{mi_c} px={},{} horz={horz} has_chroma={has_chroma} skip={skip} mode={mode} uv={uv:?}", | |
| 7363 | + mi_c * MI, | |
| 7364 | + mi_r * MI | |
| 7365 | + ); | |
| 7366 | + } | |
| 7367 | + INTRA16X4_IN_INTER_HITS.with(|h| { | |
| 7368 | + let mut v = h.get(); | |
| 7369 | + v[usize::from(!horz)] += 1; | |
| 7370 | + v[2] += usize::from(has_chroma); | |
| 7371 | + h.set(v); | |
| 7372 | + }); | |
| 7373 | + return Ok(()); | |
| 7374 | + } | |
| 7247 | 7375 | let (size_group, tx_cat) = match (bw.min(bh), bw.max(bh)) { |
| 7248 | 7376 | (8, 16) => (1usize, 1usize), |
| 7249 | 7377 | (16, 32) => (2, 2), |
| @@ -8747,6 +8875,72 @@ fn decode_rect4_16( | ||
| 8747 | 8875 | (mi_row0, mi_col0 + i) |
| 8748 | 8876 | }; |
| 8749 | 8877 | let has_chroma = i % 2 == 1; |
| 8878 | + let (mode, uv, _tx) = decode_rect4_16_strip( | |
| 8879 | + dec, | |
| 8880 | + cdfs, | |
| 8881 | + neighbours, | |
| 8882 | + lmi, | |
| 8883 | + horz, | |
| 8884 | + has_chroma, | |
| 8885 | + prev, | |
| 8886 | + y, | |
| 8887 | + u, | |
| 8888 | + v, | |
| 8889 | + enable_filter_intra, | |
| 8890 | + allow_screen_content_tools, | |
| 8891 | + base_q_idx, | |
| 8892 | + tx_select, | |
| 8893 | + reduced_tx_set, | |
| 8894 | + )?; | |
| 8895 | + if let Some(m) = uv { | |
| 8896 | + last_uv_mode = m; | |
| 8897 | + } | |
| 8898 | + last_mode = mode; | |
| 8899 | + prev = Some((lmi, mode)); | |
| 8900 | + } | |
| 8901 | + // The coarse 16-px cell holds one entry for the whole 16x16: the last | |
| 8902 | + // strip is what a block below (right) sees through it, the mi-exact maps | |
| 8903 | + // above answering everything finer. | |
| 8904 | + neighbours.above_mode[c] = last_mode; | |
| 8905 | + neighbours.left_mode[r] = last_mode; | |
| 8906 | + neighbours.above_uv_mode[c] = last_uv_mode; | |
| 8907 | + neighbours.left_uv_mode[r] = last_uv_mode; | |
| 8908 | + neighbours.above_side[c] = bw; | |
| 8909 | + neighbours.left_side[r] = bh; | |
| 8910 | + Ok(()) | |
| 8911 | +} | |
| 8912 | + | |
| 8913 | +/// One 16x4 / 4x16 strip of a 16x16-level 1:4 partition, intra-coded -- | |
| 8914 | +/// [`decode_rect4_16`]'s per-strip body, lifted (lane-intra16x4) so the INTER | |
| 8915 | +/// block path can decode a SINGLE intra strip of a partition whose other | |
| 8916 | +/// strips are inter. `prev` is the previous strip's `(mi, mode)` (the | |
| 8917 | +/// key-frame caller's coarse-cell stand-in; `None` on the inter path, where | |
| 8918 | +/// every strip publishes its own mi-exact mode). Returns | |
| 8919 | +/// `(y_mode, uv_predict_mode when this strip closes the 4:2:0 chroma pair)`. | |
| 8920 | +#[allow(clippy::too_many_arguments)] | |
| 8921 | +fn decode_rect4_16_strip( | |
| 8922 | + dec: &mut SymbolDecoder, | |
| 8923 | + cdfs: &mut Cdfs, | |
| 8924 | + neighbours: &mut Neighbours, | |
| 8925 | + lmi: (usize, usize), | |
| 8926 | + horz: bool, | |
| 8927 | + has_chroma: bool, | |
| 8928 | + prev: Option<((usize, usize), usize)>, | |
| 8929 | + y: &mut PlaneBuf, | |
| 8930 | + u: &mut PlaneBuf, | |
| 8931 | + v: &mut PlaneBuf, | |
| 8932 | + enable_filter_intra: bool, | |
| 8933 | + allow_screen_content_tools: bool, | |
| 8934 | + base_q_idx: u8, | |
| 8935 | + tx_select: bool, | |
| 8936 | + reduced_tx_set: bool, | |
| 8937 | +) -> Result<(usize, Option<usize>, (usize, usize))> { | |
| 8938 | + let (r, c) = (lmi.0 / (SUB / MI), lmi.1 / (SUB / MI)); | |
| 8939 | + let (bw, bh) = if horz { (16usize, 4usize) } else { (4, 16) }; | |
| 8940 | + let (mi_w, mi_h) = (bw / MI, bh / MI); | |
| 8941 | + let scan: &[u16] = if horz { &SCAN_16X4 } else { &SCAN_4X16 }; | |
| 8942 | + let chroma_scan: &[u16] = if horz { &SCAN_8X4 } else { &SCAN_4X8 }; | |
| 8943 | + let mut last_uv_mode: Option<usize> = None; | |
| 8750 | 8944 | // `decode_block_rect4`'s own neighbour rule: the coarse 16-px cell |
| 8751 | 8945 | // aliases all four strips onto one entry, so the mi-exact map wins and |
| 8752 | 8946 | // the previous strip stands in on the split axis. |
| @@ -8820,7 +9014,16 @@ fn decode_rect4_16( | ||
| 8820 | 9014 | // depth symbol is the 3-symbol `tx_size_cat1` -- not the 2-symbol |
| 8821 | 9015 | // `cat0` a 4x8 leaf reads nor the `cat2` a 32x8 strip does. |
| 8822 | 9016 | let depth = if tx_select { |
| 8823 | - let ctx = tx_size_context_rect(neighbours, lmi, bw, bh); | |
| 9017 | + // lane-intra16x4: on an INTER frame `get_tx_size_context` reads the | |
| 9018 | + // real `TXFM_CONTEXT` bands ([`tx_size_context_txfm_rect`], what | |
| 9019 | + // the 2:1 intra-in-inter strip already does); the key frame's | |
| 9020 | + // deblock-grid approximation is only right where those bands were | |
| 9021 | + // never written. | |
| 9022 | + let ctx = if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some() { | |
| 9023 | + tx_size_context_txfm_rect(neighbours, lmi, bw, bh) | |
| 9024 | + } else { | |
| 9025 | + tx_size_context_rect(neighbours, lmi, bw, bh) | |
| 9026 | + }; | |
| 8824 | 9027 | dec.symbol(&mut cdfs.tx_size_cat1[ctx]) |
| 8825 | 9028 | } else { |
| 8826 | 9029 | 0 |
| @@ -9162,7 +9365,7 @@ fn decode_rect4_16( | ||
| 9162 | 9365 | slot[2] = v_state; |
| 9163 | 9366 | } |
| 9164 | 9367 | } |
| 9165 | - last_uv_mode = uv_predict_mode; | |
| 9368 | + last_uv_mode = Some(uv_predict_mode); | |
| 9166 | 9369 | } |
| 9167 | 9370 | if horz { |
| 9168 | 9371 | RECT4_16_HORZ_HITS.with(|h| h.set(h.get() + 1)); |
| @@ -9176,21 +9379,10 @@ fn decode_rect4_16( | ||
| 9176 | 9379 | record_strip_palette( |
| 9177 | 9380 | neighbours, lmi, bw, bh, pal_y_size, pal_y_colors, pal_uv_size, pal_uv_colors, |
| 9178 | 9381 | ); |
| 9179 | - last_mode = mode; | |
| 9180 | - prev = Some((lmi, mode)); | |
| 9181 | - } | |
| 9182 | - // The coarse 16-px cell holds one entry for the whole 16x16: the last | |
| 9183 | - // strip is what a block below (right) sees through it, the mi-exact maps | |
| 9184 | - // above answering everything finer. | |
| 9185 | - neighbours.above_mode[c] = last_mode; | |
| 9186 | - neighbours.left_mode[r] = last_mode; | |
| 9187 | - neighbours.above_uv_mode[c] = last_uv_mode; | |
| 9188 | - neighbours.left_uv_mode[r] = last_uv_mode; | |
| 9189 | - neighbours.above_side[c] = bw; | |
| 9190 | - neighbours.left_side[r] = bh; | |
| 9191 | - Ok(()) | |
| 9382 | + Ok((mode, last_uv_mode, (tx_w, tx_h))) | |
| 9192 | 9383 | } |
| 9193 | 9384 | |
| 9385 | + | |
| 9194 | 9386 | /// Decodes one true `bw`x`bh` superblock-level `PARTITION_HORZ`/ |
| 9195 | 9387 | /// `PARTITION_VERT` strip (lane-sbpart r2, `bw, bh` one of `(64, 32)` / |
| 9196 | 9388 | /// `(32, 64)` -- [`decode_block_rect`]'s own sibling one level up). Unlike |
| @@ -13149,6 +13341,19 @@ fn tx_size_context_txfm_rect( | ||
| 13149 | 13341 | if has_left && n.left_inter[mi_r] { |
| 13150 | 13342 | left = n.left_side_mi[mi_r] >= own_h; |
| 13151 | 13343 | } |
| 13344 | + if std::env::var_os("EC_TXCTX").is_some() { | |
| 13345 | + eprintln!( | |
| 13346 | + "EC_TXCTX mi={mi_r},{mi_c} own={own_w}x{own_h} ha={has_above} hl={has_left} \ | |
| 13347 | + above_txfm={} left_txfm={} above_inter={} left_inter={} above_side={} left_side={} \ | |
| 13348 | + above={above} left={left}", | |
| 13349 | + n.above_txfm[mi_c], | |
| 13350 | + n.left_txfm[mi_r], | |
| 13351 | + n.above_inter[mi_c], | |
| 13352 | + n.left_inter[mi_r], | |
| 13353 | + n.above_side_mi[mi_c], | |
| 13354 | + n.left_side_mi[mi_r], | |
| 13355 | + ); | |
| 13356 | + } | |
| 13152 | 13357 | match (has_above, has_left) { |
| 13153 | 13358 | (true, true) => usize::from(above) + usize::from(left), |
| 13154 | 13359 | (true, false) => usize::from(above), |
| @@ -17920,10 +18125,17 @@ fn ref_planes<'a>( | ||
| 17920 | 18125 | /// unit at a time, and does not itself count as a step). `max_neighbors` |
| 17921 | 18126 | /// caller-bounds the scan: `1` for the eligibility check (any hit at all), |
| 17922 | 18127 | /// `av1_build_obmc_inter_prediction`'s own `max_neighbor_obmc` table for the |
| 17923 | -/// real blend pass. Round 1 corner-cut: libaom's own "4-wide block, treat as | |
| 17924 | -/// half of a chroma pair" merge (`obmc.h`'s `mi_step == 1` special case) is | |
| 17925 | -/// not ported -- no block this decoder codes is narrower than 8px, so it | |
| 17926 | -/// never fires here regardless of what a neighbour's own decoder was. | |
| 18128 | +/// real blend pass. lane-intra16x4 r2: libaom's own "4-wide block, treat as | |
| 18129 | +/// half of a chroma pair" merge (`obmc.h`'s `mi_step == 1` special case) IS | |
| 18130 | +/// ported below -- the round-1 note that no block is narrower than 8px stopped | |
| 18131 | +/// being true when the 1:4 partitions landed. A 16x4 / 4x16 strip has | |
| 18132 | +/// `mi_size_high`/`mi_size_wide` 1, so libaom snaps the walk back to the pair's | |
| 18133 | +/// even index, reads the ODD (chroma-carrying) half as the neighbour and steps | |
| 18134 | +/// by 2. Measured: the 16x16 block right of a 16x16-level HORZ_4 partition | |
| 18135 | +/// whose strip 0 is inter and strips 1..3 intra counted that inter strip as | |
| 18136 | +/// overlappable here, while libaom's pair merge reads the INTRA strip 1 and | |
| 18137 | +/// counts none -- so we read a `motion_mode` symbol libaom never wrote (class | |
| 18138 | +/// `symbol-consumption-gap`), desyncing the tile at the next coefficient. | |
| 17927 | 18139 | fn overlappable_above( |
| 17928 | 18140 | grid: &MiGrid, |
| 17929 | 18141 | mi_row: usize, |
| @@ -17940,8 +18152,17 @@ fn overlappable_above( | ||
| 17940 | 18152 | let mut col = mi_col; |
| 17941 | 18153 | while col < end_col && out.len() < max_neighbors { |
| 17942 | 18154 | let cell = grid.get(mi_row - 1, col); |
| 17943 | - let step = cell.map_or(1, |c| c.size).max(1); | |
| 17944 | - if let Some(info) = cell { | |
| 18155 | + let mut step = cell.map_or(1, |c| c.size).max(1).min(SB_MI as usize); | |
| 18156 | + let mut nb = cell; | |
| 18157 | + if step == 1 { | |
| 18158 | + // The pair merge: the walk snaps back to the pair's even column | |
| 18159 | + // and the ODD half (the chroma-carrying one) is the neighbour for | |
| 18160 | + // both -- a 4-wide 1:4 strip is never an OBMC source on its own. | |
| 18161 | + col &= !1; | |
| 18162 | + nb = grid.get(mi_row - 1, col + 1); | |
| 18163 | + step = 2; | |
| 18164 | + } | |
| 18165 | + if let Some(info) = nb { | |
| 17945 | 18166 | if info.is_inter { |
| 17946 | 18167 | out.push((col - mi_col, step.min(end_col - col), *info)); |
| 17947 | 18168 | } |
| @@ -17971,8 +18192,17 @@ fn overlappable_left( | ||
| 17971 | 18192 | let cell = grid.get(row, mi_col - 1); |
| 17972 | 18193 | // Vertical walk steps by the neighbour's HEIGHT -- a 32x16 strip's |
| 17973 | 18194 | // width (8) would swallow the strip below it. |
| 17974 | - let step = cell.map_or(1, |c| c.size_h).max(1); | |
| 17975 | - if let Some(info) = cell { | |
| 18195 | + let mut step = cell.map_or(1, |c| c.size_h).max(1).min(SB_MI as usize); | |
| 18196 | + let mut nb = cell; | |
| 18197 | + if step == 1 { | |
| 18198 | + // The pair merge, left-column mirror: a 4-TALL neighbour (a 16x4 | |
| 18199 | + // strip) is half of a chroma pair and the pair's SECOND row is the | |
| 18200 | + // neighbour for both. | |
| 18201 | + row &= !1; | |
| 18202 | + nb = grid.get(row + 1, mi_col - 1); | |
| 18203 | + step = 2; | |
| 18204 | + } | |
| 18205 | + if let Some(info) = nb { | |
| 17976 | 18206 | if info.is_inter { |
| 17977 | 18207 | out.push((row - mi_row, step.min(end_row - row), *info)); |
| 17978 | 18208 | } |
| @@ -21663,7 +21893,38 @@ fn decode_inter_block( | ||
| 21663 | 21893 | // footprint), so an INTRA 16x4 / 4x16 strip inside a 1:4 partition is |
| 21664 | 21894 | // refused by name rather than decoded with a 8x2 chroma transform |
| 21665 | 21895 | // libaom never coded. |
| 21666 | - if write_w.min(write_h) < 8 { | |
| 21896 | + // lane-intra16x4 r1: the strip DECODES through the key frame's own | |
| 21897 | + // per-strip body, [`decode_rect4_16_strip`]. | |
| 21898 | + // lane-sub8x4 r3: pixel-proven, so `EC_INTRA16X4_DECODE` is gone. r1 | |
| 21899 | + // and r2 found no witness because every firing film frame ALSO carried | |
| 21900 | + // a sub-8x8 intra block, which refused until r2 lifted it; on this tip | |
| 21901 | + // the first 50 frame OBUs of the 10-bit 3840x1608 stream's head decode | |
| 21902 | + // all 33 frames pixel-exact while this arm fires 31x 16x4 + 17x 4x16 | |
| 21903 | + // (23 of them chroma-paired). Pinned as | |
| 21904 | + // `fixtures/reelb_rect64_intra16x4_witness.obu`, gated by | |
| 21905 | + // `a_10bit_film_frames_with_intra_16x4_strips_and_rect64_corner_tus_decode_pixel_exact`. | |
| 21906 | + // The refusal below is NARROWED, not deleted: it still stands for a | |
| 21907 | + // 16x4/4x16 strip with no chroma-pair record and for every other | |
| 21908 | + // sub-8 shape. | |
| 21909 | + let strip16 = strip_chroma | |
| 21910 | + .filter(|_| write_w.min(write_h) == 4 && write_w.max(write_h) == 16) | |
| 21911 | + .map(|s| (s.horz, s.has_chroma)); | |
| 21912 | + if write_w.min(write_h) < 8 && strip16.is_none() { | |
| 21913 | + if std::env::var_os("EC_INTRA16X4").is_some() { | |
| 21914 | + let (idx, hc, prev_inter) = match strip_chroma { | |
| 21915 | + Some(s) => ( | |
| 21916 | + if s.horz { rmi - s.pair_mi.0 } else { cmi - s.pair_mi.1 }, | |
| 21917 | + s.has_chroma, | |
| 21918 | + s.prev.is_some(), | |
| 21919 | + ), | |
| 21920 | + None => (9, true, false), | |
| 21921 | + }; | |
| 21922 | + eprintln!( | |
| 21923 | + "EC_INTRA16X4 w={write_w} h={write_h} pair_parity={idx} has_chroma={hc} prev_single_inter={prev_inter} skip={skip} mi={rmi},{cmi} tx_select={} scr={}", | |
| 21924 | + TX_SELECT_INTER.with(std::cell::Cell::get), | |
| 21925 | + allow_screen_content_tools, | |
| 21926 | + ); | |
| 21927 | + } | |
| 21667 | 21928 | return Err(unsupported( |
| 21668 | 21929 | "an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition (its 4:2:0 chroma pair is coded once for two strips; only the inter path implements that pairing)", |
| 21669 | 21930 | )); |
| @@ -21686,6 +21947,7 @@ fn decode_inter_block( | ||
| 21686 | 21947 | write_h, |
| 21687 | 21948 | skip, |
| 21688 | 21949 | allow_screen_content_tools, |
| 21950 | + strip16, | |
| 21689 | 21951 | y, |
| 21690 | 21952 | u, |
| 21691 | 21953 | v, |
| @@ -22430,6 +22692,9 @@ fn decode_inter_sub8_split4( | ||
| 22430 | 22692 | [None; 4]; |
| 22431 | 22693 | let mut first_tx_type = TxType::DctDct; |
| 22432 | 22694 | let mut last_skip = true; |
| 22695 | + // Set when the chroma-reference (last) sub-block is INTRA: it coded the | |
| 22696 | + // group's one chroma unit itself. | |
| 22697 | + let mut intra_chroma = false; | |
| 22433 | 22698 | for i in 0..4usize { |
| 22434 | 22699 | let (dr, dc) = (i / 2, i % 2); |
| 22435 | 22700 | let lmi = (gr + dr, gc + dc); |
| @@ -22458,10 +22723,48 @@ fn decode_inter_sub8_split4( | ||
| 22458 | 22723 | ); |
| 22459 | 22724 | let is_inter = dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; |
| 22460 | 22725 | if !is_inter { |
| 22461 | - return Err(unsupported( | |
| 22462 | - "an intra 4x4 block inside an inter frame's sub-8x8 split (this decoder codes \ | |
| 22463 | - only inter 4x4 sub-blocks there)", | |
| 22464 | - )); | |
| 22726 | + if std::env::var_os("EC_SUB8INTRA").is_some() { | |
| 22727 | + eprintln!( | |
| 22728 | + "EC_SUB8INTRA shape=4x4 sub={i} has_chroma={} skip={skip} mi={rmi},{cmi} tx_select={}", | |
| 22729 | + i == 3, | |
| 22730 | + TX_SELECT_INTER.with(std::cell::Cell::get), | |
| 22731 | + ); | |
| 22732 | + } | |
| 22733 | + // lane-sub8x4 r2: the refusal and its `EC_SUB8INTRA_DECODE` bypass | |
| 22734 | + // are gone -- `a_real_aomenc_inter_sequence_with_intra_sub8x8_ | |
| 22735 | + // leaves_decodes_pixel_exact` (stream.rs) decodes 12 real aomenc | |
| 22736 | + // streams carrying this arm pixel-exact vs ffmpeg. | |
| 22737 | + SUB8_INTRA_RECT_HITS.with(|h| { | |
| 22738 | + let mut st = h.get(); | |
| 22739 | + st[4] += 1; | |
| 22740 | + h.set(st); | |
| 22741 | + }); | |
| 22742 | + // lane-sub8intra: the `BLOCK_4X4` twin of the HORZ/VERT arm -- | |
| 22743 | + // same [`decode_intra_sub8_leaf`], no tx-depth symbol, chroma on | |
| 22744 | + // the LAST sub-block (`is_chroma_reference` under 4:2:0). | |
| 22745 | + decode_intra_sub8_leaf( | |
| 22746 | + dec, | |
| 22747 | + cdfs, | |
| 22748 | + neighbours, | |
| 22749 | + grid, | |
| 22750 | + group_mi, | |
| 22751 | + lmi, | |
| 22752 | + (B4, B4), | |
| 22753 | + i == 3, | |
| 22754 | + skip, | |
| 22755 | + scan4, | |
| 22756 | + y, | |
| 22757 | + u, | |
| 22758 | + v, | |
| 22759 | + base_q_idx, | |
| 22760 | + ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get), | |
| 22761 | + TX_SELECT_INTER.with(std::cell::Cell::get), | |
| 22762 | + reduced_tx_set, | |
| 22763 | + )?; | |
| 22764 | + if i == 3 { | |
| 22765 | + intra_chroma = true; | |
| 22766 | + } | |
| 22767 | + continue; | |
| 22465 | 22768 | } |
| 22466 | 22769 | // Same print point as the oracle's `EC_MODE` (entry of |
| 22467 | 22770 | // `read_inter_block_mode_info`, i.e. after skip / is_inter), so the |
| @@ -22682,11 +22985,14 @@ fn decode_inter_sub8_split4( | ||
| 22682 | 22985 | None, |
| 22683 | 22986 | None, |
| 22684 | 22987 | )?; |
| 22685 | - if i == 0 { | |
| 22988 | + if i == 0 || piece[0].is_none() { | |
| 22686 | 22989 | // `av1_get_tx_type`: an inter block's chroma inherits the |
| 22687 | 22990 | // tx_type of the CO-LOCATED luma position, which for the |
| 22688 | 22991 | // group's one chroma unit is luma (0, 0) -- the FIRST |
| 22689 | - // sub-block, not the last. | |
| 22992 | + // sub-block, not the last. lane-sub8intra: an INTRA first | |
| 22993 | + // sub-block writes no inter tx_type there at all, so the | |
| 22994 | + // later inter sub-blocks' own is what `xd->tx_type_map` | |
| 22995 | + // holds. | |
| 22690 | 22996 | first_tx_type = tx_type; |
| 22691 | 22997 | } |
| 22692 | 22998 | neighbours.record_mi_luma_rect(lmi, B4, B4, &luma_grid); |
| @@ -22703,59 +23009,98 @@ fn decode_inter_sub8_split4( | ||
| 22703 | 23009 | neighbours.fill_lf_grid_rect(lmi, 1, 1, B4 as u8, B4 as u8, ref_frame.max(LAST_FRAME)); |
| 22704 | 23010 | last_skip = skip; |
| 22705 | 23011 | } |
| 22706 | - // Chroma, once for the whole group, on the last sub-block's own `skip` | |
| 22707 | - // flag -- prediction from all four sub-blocks (2x2 pieces), residual as | |
| 22708 | - // one TX_4X4 unit per plane. | |
| 22709 | - let mut pred_u = vec![0u16; B4 * B4]; | |
| 22710 | - let mut pred_v = vec![0u16; B4 * B4]; | |
| 22711 | - for i in 0..4usize { | |
| 22712 | - let (dr, dc) = (i / 2, i % 2); | |
| 22713 | - let Some((ref_frame, mv, h_filter, v_filter)) = piece[i] else { | |
| 22714 | - continue; | |
| 22715 | - }; | |
| 22716 | - let (_, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?; | |
| 22717 | - let (ox, oy) = (cpx + dc * 2, cpy + dr * 2); | |
| 22718 | - for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] { | |
| 22719 | - let mut buf = vec![0u16; 4]; | |
| 22720 | - mc::predict_with_filters( | |
| 22721 | - &plane.data, | |
| 22722 | - plane.width, | |
| 22723 | - plane.true_width, | |
| 22724 | - plane.true_height, | |
| 22725 | - mv_to_q4(ox, mv.1, false), | |
| 22726 | - mv_to_q4(oy, mv.0, false), | |
| 22727 | - 2, | |
| 22728 | - 2, | |
| 22729 | - h_filter, | |
| 22730 | - v_filter, | |
| 22731 | - &mut buf, | |
| 22732 | - ); | |
| 22733 | - for row in 0..2 { | |
| 22734 | - for col in 0..2 { | |
| 22735 | - dst[(dr * 2 + row) * B4 + dc * 2 + col] = buf[row * 2 + col]; | |
| 23012 | + // lane-sub8intra: when the chroma-reference sub-block was INTRA it coded | |
| 23013 | + // and reconstructed the group's one chroma unit itself. | |
| 23014 | + if !intra_chroma { | |
| 23015 | + // Chroma, once for the whole group, on the last sub-block's own `skip` | |
| 23016 | + // flag -- prediction from all four sub-blocks (2x2 pieces), residual as | |
| 23017 | + // one TX_4X4 unit per plane. | |
| 23018 | + let mut pred_u = vec![0u16; B4 * B4]; | |
| 23019 | + let mut pred_v = vec![0u16; B4 * B4]; | |
| 23020 | + // `is_sub8x8_inter` (reconinter_template.inc:54) is false as soon as ANY | |
| 23021 | + // mi of the group is intra: the group's 4x4 chroma is then predicted WHOLE | |
| 23022 | + // from the chroma-reference (last) sub-block's own mv, not in 2x2 pieces. | |
| 23023 | + let mixed = piece.iter().any(Option::is_none); | |
| 23024 | + if mixed { | |
| 23025 | + SUB8_INTRA_RECT_HITS.with(|h| { | |
| 23026 | + let mut st = h.get(); | |
| 23027 | + st[3] += 1; | |
| 23028 | + h.set(st); | |
| 23029 | + }); | |
| 23030 | + } | |
| 23031 | + for i in 0..4usize { | |
| 23032 | + let (dr, dc) = (i / 2, i % 2); | |
| 23033 | + if mixed && i != 3 { | |
| 23034 | + continue; | |
| 23035 | + } | |
| 23036 | + let Some((ref_frame, mv, h_filter, v_filter)) = piece[i] else { | |
| 23037 | + continue; | |
| 23038 | + }; | |
| 23039 | + let (_, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?; | |
| 23040 | + let (ox, oy) = if mixed { | |
| 23041 | + (cpx, cpy) | |
| 23042 | + } else { | |
| 23043 | + (cpx + dc * 2, cpy + dr * 2) | |
| 23044 | + }; | |
| 23045 | + let (pw, ph) = if mixed { (B4, B4) } else { (2, 2) }; | |
| 23046 | + let (row0, col0) = if mixed { (0, 0) } else { (dr * 2, dc * 2) }; | |
| 23047 | + for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] { | |
| 23048 | + let mut buf = vec![0u16; pw * ph]; | |
| 23049 | + mc::predict_with_filters( | |
| 23050 | + &plane.data, | |
| 23051 | + plane.width, | |
| 23052 | + plane.true_width, | |
| 23053 | + plane.true_height, | |
| 23054 | + mv_to_q4(ox, mv.1, false), | |
| 23055 | + mv_to_q4(oy, mv.0, false), | |
| 23056 | + pw, | |
| 23057 | + ph, | |
| 23058 | + h_filter, | |
| 23059 | + v_filter, | |
| 23060 | + &mut buf, | |
| 23061 | + ); | |
| 23062 | + for row in 0..ph { | |
| 23063 | + for col in 0..pw { | |
| 23064 | + dst[(row0 + row) * B4 + col0 + col] = buf[row * pw + col]; | |
| 23065 | + } | |
| 22736 | 23066 | } |
| 22737 | 23067 | } |
| 22738 | 23068 | } |
| 23069 | + let (u_grid, v_grid) = if last_skip { | |
| 23070 | + u.reconstruct_mc(cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4]); | |
| 23071 | + v.reconstruct_mc(cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4]); | |
| 23072 | + (vec![0i32; B4 * B4], vec![0i32; B4 * B4]) | |
| 23073 | + } else { | |
| 23074 | + let around = neighbours.around_mi(group_mi, 8); | |
| 23075 | + let ug = read_inter_plane( | |
| 23076 | + dec, cdfs, TxbSet::Chroma4, scan4, 1, around[1], 0, u, cpx, cpy, B4, base_q_idx, | |
| 23077 | + &pred_u, Some(first_tx_type), None, | |
| 23078 | + )? | |
| 23079 | + .0; | |
| 23080 | + let vg = read_inter_plane( | |
| 23081 | + dec, cdfs, TxbSet::Chroma4, scan4, 2, around[2], 0, v, cpx, cpy, B4, base_q_idx, | |
| 23082 | + &pred_v, Some(first_tx_type), None, | |
| 23083 | + )? | |
| 23084 | + .0; | |
| 23085 | + (ug, vg) | |
| 23086 | + }; | |
| 23087 | + neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED); | |
| 23088 | + let round_up_even = |n: usize| n.div_ceil(2) * 2; | |
| 23089 | + let bound_h = round_up_even(neighbours.mi_rows); | |
| 23090 | + let bound_w = round_up_even(neighbours.mi_cols); | |
| 23091 | + let u_state = neighbour_state(&u_grid); | |
| 23092 | + let v_state = neighbour_state(&v_grid); | |
| 23093 | + for cell in 0..2usize { | |
| 23094 | + if cell < 2usize.min(bound_h.saturating_sub(gr)) { | |
| 23095 | + neighbours.left[gr + cell][1] = u_state; | |
| 23096 | + neighbours.left[gr + cell][2] = v_state; | |
| 23097 | + } | |
| 23098 | + if cell < 2usize.min(bound_w.saturating_sub(gc)) { | |
| 23099 | + neighbours.above[gc + cell][1] = u_state; | |
| 23100 | + neighbours.above[gc + cell][2] = v_state; | |
| 23101 | + } | |
| 23102 | + } | |
| 22739 | 23103 | } |
| 22740 | - let (u_grid, v_grid) = if last_skip { | |
| 22741 | - u.reconstruct_mc(cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4]); | |
| 22742 | - v.reconstruct_mc(cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4]); | |
| 22743 | - (vec![0i32; B4 * B4], vec![0i32; B4 * B4]) | |
| 22744 | - } else { | |
| 22745 | - let around = neighbours.around_mi(group_mi, 8); | |
| 22746 | - let ug = read_inter_plane( | |
| 22747 | - dec, cdfs, TxbSet::Chroma4, scan4, 1, around[1], 0, u, cpx, cpy, B4, base_q_idx, | |
| 22748 | - &pred_u, Some(first_tx_type), None, | |
| 22749 | - )? | |
| 22750 | - .0; | |
| 22751 | - let vg = read_inter_plane( | |
| 22752 | - dec, cdfs, TxbSet::Chroma4, scan4, 2, around[2], 0, v, cpx, cpy, B4, base_q_idx, | |
| 22753 | - &pred_v, Some(first_tx_type), None, | |
| 22754 | - )? | |
| 22755 | - .0; | |
| 22756 | - (ug, vg) | |
| 22757 | - }; | |
| 22758 | - neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED); | |
| 22759 | 23104 | // Same two neighbour tails [`decode_leaf_split4`] runs: the partition |
| 22760 | 23105 | // context of a `BLOCK_4X4` subsize (`partition_context_lookup` bit 0 = 1, |
| 22761 | 23106 | // reached by `side_mi = 4` here) and the group's chroma coefficient state. |
| @@ -22763,95 +23108,496 @@ fn decode_inter_sub8_split4( | ||
| 22763 | 23108 | neighbours.left_side_mi[gr + cell] = 4; |
| 22764 | 23109 | neighbours.above_side_mi[gc + cell] = 4; |
| 22765 | 23110 | } |
| 22766 | - let round_up_even = |n: usize| n.div_ceil(2) * 2; | |
| 22767 | - let bound_h = round_up_even(neighbours.mi_rows); | |
| 22768 | - let bound_w = round_up_even(neighbours.mi_cols); | |
| 22769 | - let u_state = neighbour_state(&u_grid); | |
| 22770 | - let v_state = neighbour_state(&v_grid); | |
| 22771 | - for cell in 0..2usize { | |
| 22772 | - if cell < 2usize.min(bound_h.saturating_sub(gr)) { | |
| 22773 | - neighbours.left[gr + cell][1] = u_state; | |
| 22774 | - neighbours.left[gr + cell][2] = v_state; | |
| 22775 | - } | |
| 22776 | - if cell < 2usize.min(bound_w.saturating_sub(gc)) { | |
| 22777 | - neighbours.above[gc + cell][1] = u_state; | |
| 22778 | - neighbours.above[gc + cell][2] = v_state; | |
| 22779 | - } | |
| 22780 | - } | |
| 22781 | 23111 | Ok(()) |
| 22782 | 23112 | } |
| 22783 | 23113 | |
| 22784 | -/// Decodes a `PARTITION_HORZ`/`PARTITION_VERT` of one 8x8 INTER block into two | |
| 22785 | -/// `BLOCK_8X4`/`BLOCK_4X8` inter leaves (lane-intersub8 r3) -- the inter twin of | |
| 22786 | -/// [`decode_leaf_rect8`] and the rectangular sibling of | |
| 22787 | -/// [`decode_inter_sub8_split4`], whose element order it follows exactly. | |
| 22788 | -/// Per sub-block, in libaom `decodemv.c` `read_inter_frame_mode_info` order: | |
| 22789 | -/// | |
| 22790 | -/// * `segment_id`, `skip`, `cdef`/`delta_q`/`delta_lf`, `intra_inter`; | |
| 22791 | -/// * NO `skip_mode` symbol: `is_comp_ref_allowed(BLOCK_8X4)` is false | |
| 22792 | -/// (`av1_is_comp_ref_allowed` needs both sides >= 8), so | |
| 22793 | -/// `read_skip_mode` returns 0 without reading and `comp_mode` is never read | |
| 22794 | -/// either (`read_ref_frames`' `is_comp_ref_allowed` guard) -- single | |
| 22795 | -/// reference only; | |
| 22796 | -/// * NO `interintra` and NO `motion_mode`/OBMC/warp symbol: every one of those | |
| 22797 | -/// gates needs `block_size_wide >= 8 && block_size_high >= 8` | |
| 22798 | -/// (`is_interintra_allowed_bsize`, `motion_mode_allowed`), and one side is 4; | |
| 22799 | -/// * `read_mb_interp_filter` DOES run for both sub-blocks. | |
| 22800 | -/// | |
| 22801 | -/// The shape's own differences from the four-way split: | |
| 22802 | -/// | |
| 22803 | -/// * `block_signals_txsize(BLOCK_8X4)` is true (`bsize > BLOCK_4X4`, | |
| 22804 | -/// blockd.h:1027), so a non-skipped sub-block reads ONE `txfm_partition` | |
| 22805 | -/// symbol under `TX_MODE_SELECT` at `max_txsize_rect_lookup[BLOCK_8X4] == | |
| 22806 | -/// TX_8X4` ([`read_var_tx_size`]); split resolves to two `TX_4X4` units | |
| 22807 | -/// (`sub_tx_size_map[TX_8X4] == TX_4X4`, libaom's early return), no split to | |
| 22808 | -/// the whole-leaf `TX_8X4`; | |
| 22809 | -/// * the luma coefficient set is [`TxbSet::LumaRect8x4Inter`] (the 8x8 | |
| 22810 | -/// coefficient class with a 32-position `eob_pt` and the INTER `TX_4X4` | |
| 22811 | -/// `tx_type` row) for the whole-leaf unit, and the square | |
| 22812 | -/// [`TxbSet::Luma4Inter`] for a split `TX_4X4` unit; | |
| 22813 | -/// * chroma is coded ONCE, on the sub-block that is the chroma reference: | |
| 22814 | -/// `is_chroma_reference` (`av1_common_int.h`) is | |
| 22815 | -/// `((mi_row & 1) || !(bh4 & 1) || !ss_y) && ((mi_col & 1) || !(bw4 & 1) || | |
| 22816 | -/// !ss_x)`, i.e. under 4:2:0 the BOTTOM 8x4 (`bh4 == 1`, odd) and the RIGHT | |
| 22817 | -/// 4x8 (`bw4 == 1`) -- always the second sub-block here; | |
| 22818 | -/// * that chroma unit's prediction is the sub8x8 one (`reconinter.c` | |
| 22819 | -/// `build_inter_predictors_sub8x8`: `row_start = -(block_size_high == 4 && | |
| 22820 | -/// ss_y)`, `col_start = -(block_size_wide == 4 && ss_x)`), two 4x2 (HORZ) or | |
| 22821 | -/// 2x4 (VERT) chroma pieces, each from its OWN sub-block's reference, mv and | |
| 22822 | -/// interpolation filters. | |
| 23114 | +/// One INTRA 8x4/4x8 leaf inside an INTER frame's sub-8x8 HORZ/VERT partition | |
| 23115 | +/// (lane-sub8intra) -- the shape [`decode_inter_sub8_rect2`] refused by name. | |
| 23116 | +/// Mode syntax is `read_intra_block_mode_info`'s (decodemv.c:1065), not the key | |
| 23117 | +/// frame's above/left pair: `y_mode[size_group_lookup[BLOCK_8X4] == 0]`, NO | |
| 23118 | +/// angle delta (`av1_use_angle_delta` needs `bsize >= BLOCK_8X8`), `uv_mode` + | |
| 23119 | +/// CfL alphas only on the chroma-reference sub-block (`is_chroma_reference`: | |
| 23120 | +/// the SECOND one under 4:2:0), then `filter_intra` off BLOCK_8X4/BLOCK_4X8's | |
| 23121 | +/// own class row (`av1_filter_intra_allowed_bsize` is `wide <= 32 && high <= | |
| 23122 | +/// 32`, so this shape is allowed). Everything below the mode read -- the tx | |
| 23123 | +/// depth symbol, the whole-leaf `TX_8X4`/`TX_4X8` or split `TX_4X4` walk, the | |
| 23124 | +/// 4x4 chroma unit at the group's origin -- is [`decode_leaf_rect8`]'s body for | |
| 23125 | +/// the same shape; the INTER-frame differences are the tx-depth context | |
| 23126 | +/// (`above_txfm`/`left_txfm`, not the key frame's deblock-grid approximation), | |
| 23127 | +/// `set_txfm_ctxs` publication, and the inter-side bands + mi map the caller's | |
| 23128 | +/// inter leaves also write (`is_inter = 0`, ref `INTRA_FRAME`, no interp | |
| 23129 | +/// filter). | |
| 22823 | 23130 | #[allow(clippy::too_many_arguments)] |
| 22824 | -fn decode_inter_sub8_rect2( | |
| 23131 | +fn decode_intra_sub8_leaf( | |
| 22825 | 23132 | dec: &mut SymbolDecoder, |
| 22826 | 23133 | cdfs: &mut Cdfs, |
| 22827 | 23134 | neighbours: &mut Neighbours, |
| 22828 | 23135 | grid: &mut MiGrid, |
| 22829 | 23136 | group_mi: (usize, usize), |
| 22830 | - vert: bool, | |
| 22831 | - mi_cols: u32, | |
| 22832 | - mi_rows: u32, | |
| 23137 | + lmi: (usize, usize), | |
| 23138 | + // `(bw, bh)`: 8x4 / 4x8 under HORZ/VERT, 4x4 under SPLIT. | |
| 23139 | + (bw, bh): (usize, usize), | |
| 23140 | + has_chroma: bool, | |
| 23141 | + skip: bool, | |
| 23142 | + scan4: &[u16], | |
| 22833 | 23143 | y: &mut PlaneBuf, |
| 22834 | 23144 | u: &mut PlaneBuf, |
| 22835 | 23145 | v: &mut PlaneBuf, |
| 22836 | - ref_y: &PlaneBuf, | |
| 22837 | - ref_u: &PlaneBuf, | |
| 22838 | - ref_v: &PlaneBuf, | |
| 22839 | - other_refs: &RefSlots, | |
| 22840 | - sign_bias_table: &SignBiasTable, | |
| 22841 | - global_motion: &[ec_av1_syntax::WarpParams; 7], | |
| 22842 | 23146 | base_q_idx: u8, |
| 22843 | - scan4: &[u16], | |
| 22844 | - allow_high_precision_mv: bool, | |
| 22845 | - force_integer_mv: bool, | |
| 22846 | - interp_fixed: Option<mc::InterpFilterKind>, | |
| 22847 | - enable_dual_filter: bool, | |
| 22848 | - tpl_frame: Option<&TplFrameArgs>, | |
| 23147 | + enable_filter_intra: bool, | |
| 23148 | + tx_select: bool, | |
| 22849 | 23149 | reduced_tx_set: bool, |
| 22850 | - frame_width: usize, | |
| 22851 | -) -> Result<()> { | |
| 22852 | - const LAST_FRAME: i8 = 1; | |
| 22853 | - // The 8x8 group's own square stride: both leaves' prediction buffers are | |
| 22854 | - // laid out at it, as every other rect inter unit here is. | |
| 23150 | +) -> Result<usize> { | |
| 23151 | + let vert = bw < bh; | |
| 23152 | + let (w_mi, h_mi) = (bw / MI, bh / MI); | |
| 23153 | + let (gr, gc) = group_mi; | |
| 23154 | + let (r, c) = (gr / (SUB / MI), gc / (SUB / MI)); | |
| 23155 | + let (above_mode, left_mode) = neighbours.modes_above_left(r, c); | |
| 23156 | + let leaf_above = neighbours | |
| 23157 | + .mode_above_mi(lmi.0, lmi.1) | |
| 23158 | + .unwrap_or(above_mode); | |
| 23159 | + let leaf_left = neighbours.mode_left_mi(lmi.0, lmi.1).unwrap_or(left_mode); | |
| 23160 | + let step = std::env::var_os("EC_TRACE_MODE_STEP").is_some(); | |
| 23161 | + // `size_group_lookup[BLOCK_8X4] == size_group_lookup[BLOCK_4X8] == 0` | |
| 23162 | + // (libaom common_data.h:61). | |
| 23163 | + let mode = dec.symbol(&mut cdfs.y_mode[0]); | |
| 23164 | + if step { | |
| 23165 | + eprintln!( | |
| 23166 | + "EC_ISTEP mi_row={} mi_col={} name=mode val={mode} rng={}", | |
| 23167 | + lmi.0, | |
| 23168 | + lmi.1, | |
| 23169 | + dec.debug_state().0 | |
| 23170 | + ); | |
| 23171 | + } | |
| 23172 | + // No angle delta below 8x8 (`av1_use_angle_delta`), for luma or chroma. | |
| 23173 | + let angle_delta_y = 0; | |
| 23174 | + let (uv_mode, alpha) = if has_chroma { | |
| 23175 | + // `is_cfl_allowed` is `wide <= 32 && high <= 32` -- true for this | |
| 23176 | + // shape, so the 14-symbol CFL alphabet is the right one. | |
| 23177 | + let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]); | |
| 23178 | + if (9..=12).contains(&uv_mode) { | |
| 23179 | + SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); | |
| 23180 | + } | |
| 23181 | + let alpha = if uv_mode == UV_CFL_PRED { | |
| 23182 | + Some(read_cfl_alphas(dec, cdfs)) | |
| 23183 | + } else { | |
| 23184 | + None | |
| 23185 | + }; | |
| 23186 | + if (V_PRED..=D67_PRED).contains(&uv_mode) { | |
| 23187 | + DIRECTIONAL_UV_HITS.with(|c| c.set(c.get() + 1)); | |
| 23188 | + } | |
| 23189 | + (uv_mode, alpha) | |
| 23190 | + } else { | |
| 23191 | + (DC_PRED, None) | |
| 23192 | + }; | |
| 23193 | + let mut filter_intra = None; | |
| 23194 | + if mode == DC_PRED && enable_filter_intra { | |
| 23195 | + let fi_class = if bw == bh { | |
| 23196 | + filter_intra_size_class(bw).expect("BLOCK_4X4 has its own filter_intra row") | |
| 23197 | + } else { | |
| 23198 | + filter_intra_size_class_rect(bw, bh) | |
| 23199 | + .expect("BLOCK_4X8/BLOCK_8X4 are inside av1_filter_intra_allowed_bsize") | |
| 23200 | + }; | |
| 23201 | + let use_fi = dec.symbol(&mut cdfs.filter_intra[fi_class]); | |
| 23202 | + if step { | |
| 23203 | + eprintln!( | |
| 23204 | + "EC_ISTEP mi_row={} mi_col={} name=use_filter_intra val={use_fi} rng={}", | |
| 23205 | + lmi.0, | |
| 23206 | + lmi.1, | |
| 23207 | + dec.debug_state().0 | |
| 23208 | + ); | |
| 23209 | + } | |
| 23210 | + if use_fi != 0 { | |
| 23211 | + FILTER_INTRA_HITS.with(|c| c.set(c.get() + 1)); | |
| 23212 | + FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); | |
| 23213 | + FILTER_INTRA_RECT_SUB8_HITS.with(|c| c.set(c.get() + 1)); | |
| 23214 | + let fi = dec.symbol(&mut cdfs.filter_intra_mode); | |
| 23215 | + if step { | |
| 23216 | + eprintln!( | |
| 23217 | + "EC_ISTEP mi_row={} mi_col={} name=filter_intra_mode val={fi} rng={}", | |
| 23218 | + lmi.0, | |
| 23219 | + lmi.1, | |
| 23220 | + dec.debug_state().0 | |
| 23221 | + ); | |
| 23222 | + } | |
| 23223 | + filter_intra = Some(fi); | |
| 23224 | + } | |
| 23225 | + } | |
| 23226 | + // `read_block_tx_size`' non-var-tx arm: an INTRA block of an inter frame | |
| 23227 | + // reads `read_tx_size(allow_select = 1)` -- `bsize_to_tx_size_cat | |
| 23228 | + // (BLOCK_4X8) == 0` (blockd.h:1344, depth table entry 1), the same | |
| 23229 | + // 2-symbol category [`decode_leaf_rect8`] reads -- with the var-tx | |
| 23230 | + // context bands, which on an inter frame are live. | |
| 23231 | + // `block_signals_txsize(BLOCK_4X4)` is false (blockd.h:1027): the 4x4 leaf | |
| 23232 | + // codes no depth symbol at all, its transform is its own size. | |
| 23233 | + let depth = if tx_select && bw != bh { | |
| 23234 | + let ctx = tx_size_context_txfm_rect(neighbours, lmi, bw, bh); | |
| 23235 | + let d = dec.symbol(&mut cdfs.tx_size_cat0[ctx]); | |
| 23236 | + if step { | |
| 23237 | + eprintln!( | |
| 23238 | + "EC_ISTEP mi_row={} mi_col={} name=tx_depth val={d} ctx={ctx} cat=0 rng={}", | |
| 23239 | + lmi.0, | |
| 23240 | + lmi.1, | |
| 23241 | + dec.debug_state().0 | |
| 23242 | + ); | |
| 23243 | + } | |
| 23244 | + d | |
| 23245 | + } else { | |
| 23246 | + 0 | |
| 23247 | + }; | |
| 23248 | + if depth != 0 { | |
| 23249 | + TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | |
| 23250 | + RECT8_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | |
| 23251 | + } | |
| 23252 | + let split = depth != 0; | |
| 23253 | + let (px, py) = (lmi.1 * MI, lmi.0 * MI); | |
| 23254 | + let reach = if bw == bh { | |
| 23255 | + Reach::of(bw, px, py, y.width, y.height) | |
| 23256 | + } else { | |
| 23257 | + Reach::of_rect(bw, bh, px, py, y.width, y.height) | |
| 23258 | + }; | |
| 23259 | + let smooth_neighbor = is_smooth_mode(leaf_above) || is_smooth_mode(leaf_left); | |
| 23260 | + if smooth_neighbor { | |
| 23261 | + SMOOTH_LUMA_HITS.with(|c| c.set(c.get() + 1)); | |
| 23262 | + } | |
| 23263 | + neighbours.record_mode_mi(lmi.0, lmi.1, w_mi, h_mi, mode); | |
| 23264 | + let scan: &[u16] = if vert { &SCAN_4X8 } else { &SCAN_8X4 }; | |
| 23265 | + if split { | |
| 23266 | + // `sub_tx_size_map[TX_4X8] == TX_4X4`: two 4x4 units along the long | |
| 23267 | + // axis, each predicted off the previous one's reconstruction. | |
| 23268 | + for tu in 0..2usize { | |
| 23269 | + let tu_mi = if vert { | |
| 23270 | + (lmi.0 + tu, lmi.1) | |
| 23271 | + } else { | |
| 23272 | + (lmi.0, lmi.1 + tu) | |
| 23273 | + }; | |
| 23274 | + let (tu_px, tu_py) = (tu_mi.1 * MI, tu_mi.0 * MI); | |
| 23275 | + let tu_reach = tu_reach( | |
| 23276 | + bw, | |
| 23277 | + bh, | |
| 23278 | + tu_px - px, | |
| 23279 | + tu_py - py, | |
| 23280 | + 4, | |
| 23281 | + reach, | |
| 23282 | + px, | |
| 23283 | + py, | |
| 23284 | + y.width, | |
| 23285 | + y.height, | |
| 23286 | + ); | |
| 23287 | + if skip { | |
| 23288 | + let zeros = vec![0i32; 16]; | |
| 23289 | + y.reconstruct( | |
| 23290 | + tu_px, tu_py, 4, mode, angle_delta_y, tu_reach, &zeros, None, filter_intra, | |
| 23291 | + smooth_neighbor, | |
| 23292 | + ); | |
| 23293 | + neighbours.record_mi_luma(tu_mi, 4, &zeros); | |
| 23294 | + continue; | |
| 23295 | + } | |
| 23296 | + let tu_around = neighbours.around_mi(tu_mi, 4)[0]; | |
| 23297 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, 1); | |
| 23298 | + let tu_grid = read_plane( | |
| 23299 | + dec, | |
| 23300 | + cdfs, | |
| 23301 | + if reduced_tx_set { | |
| 23302 | + TxbSet::Luma4 | |
| 23303 | + } else { | |
| 23304 | + TxbSet::Luma4Set1 | |
| 23305 | + }, | |
| 23306 | + scan4, | |
| 23307 | + 0, | |
| 23308 | + tu_around, | |
| 23309 | + mode, | |
| 23310 | + mode, | |
| 23311 | + angle_delta_y, | |
| 23312 | + tu_reach, | |
| 23313 | + y, | |
| 23314 | + tu_px, | |
| 23315 | + tu_py, | |
| 23316 | + 4, | |
| 23317 | + TX4, | |
| 23318 | + base_q_idx, | |
| 23319 | + None, | |
| 23320 | + filter_intra, | |
| 23321 | + Some(tu_skip_ctx), | |
| 23322 | + smooth_neighbor, | |
| 23323 | + )?; | |
| 23324 | + neighbours.record_mi_luma(tu_mi, 4, &tu_grid); | |
| 23325 | + } | |
| 23326 | + } else if bw == bh { | |
| 23327 | + // A `BLOCK_4X4` leaf's luma TU *is* the whole block, so `get_txb_ctx` | |
| 23328 | + // fixes `txb_skip_ctx` at 0 (`luma_skip_ctx: None`) -- the same square | |
| 23329 | + // reader [`decode_leaf_split4`] uses. | |
| 23330 | + if skip { | |
| 23331 | + y.reconstruct( | |
| 23332 | + px, py, 4, mode, angle_delta_y, reach, &vec![0i32; 16], None, filter_intra, | |
| 23333 | + smooth_neighbor, | |
| 23334 | + ); | |
| 23335 | + neighbours.record_mi_luma(lmi, 4, &vec![0i32; 16]); | |
| 23336 | + } else { | |
| 23337 | + let tu_around = neighbours.around_mi(lmi, 4)[0]; | |
| 23338 | + let tu_grid = read_plane( | |
| 23339 | + dec, | |
| 23340 | + cdfs, | |
| 23341 | + if reduced_tx_set { | |
| 23342 | + TxbSet::Luma4 | |
| 23343 | + } else { | |
| 23344 | + TxbSet::Luma4Set1 | |
| 23345 | + }, | |
| 23346 | + scan4, | |
| 23347 | + 0, | |
| 23348 | + tu_around, | |
| 23349 | + mode, | |
| 23350 | + mode, | |
| 23351 | + angle_delta_y, | |
| 23352 | + reach, | |
| 23353 | + y, | |
| 23354 | + px, | |
| 23355 | + py, | |
| 23356 | + 4, | |
| 23357 | + TX4, | |
| 23358 | + base_q_idx, | |
| 23359 | + None, | |
| 23360 | + filter_intra, | |
| 23361 | + None, | |
| 23362 | + smooth_neighbor, | |
| 23363 | + )?; | |
| 23364 | + neighbours.record_mi_luma(lmi, 4, &tu_grid); | |
| 23365 | + } | |
| 23366 | + } else { | |
| 23367 | + let grid_levels = if skip { | |
| 23368 | + let zeros = vec![0i32; bw * bh]; | |
| 23369 | + y.reconstruct_rect( | |
| 23370 | + px, py, bw, bh, mode, angle_delta_y, reach, &zeros, None, filter_intra, | |
| 23371 | + smooth_neighbor, | |
| 23372 | + ); | |
| 23373 | + zeros | |
| 23374 | + } else { | |
| 23375 | + // The leaf's luma TU *is* the leaf, so `get_txb_ctx` fixes | |
| 23376 | + // `txb_skip_ctx` at 0. | |
| 23377 | + let around = neighbours.around_mi_rect(lmi, bw, bh)[0]; | |
| 23378 | + let set = if reduced_tx_set { | |
| 23379 | + TxbSet::LumaRect4x8 | |
| 23380 | + } else { | |
| 23381 | + TxbSet::LumaRect4x8Set1 | |
| 23382 | + }; | |
| 23383 | + let mut coding = cdfs.txb(set, fi_tx_row(mode, filter_intra)); | |
| 23384 | + let (levels, tx_type) = read_coeffs_rect( | |
| 23385 | + dec, | |
| 23386 | + &mut coding, | |
| 23387 | + scan, | |
| 23388 | + bw, | |
| 23389 | + bh, | |
| 23390 | + 0, | |
| 23391 | + dc_sign_ctx(around.2), | |
| 23392 | + TxType::DctDct, | |
| 23393 | + )?; | |
| 23394 | + let residual = dequant_and_inverse_typed_wh( | |
| 23395 | + &levels, | |
| 23396 | + bw, | |
| 23397 | + bh, | |
| 23398 | + crate::decode::bit_depth(), | |
| 23399 | + CURRENT_Q_IDX.with(|q| q.get()), | |
| 23400 | + plane_q_delta(0).0, | |
| 23401 | + plane_q_delta(0).1, | |
| 23402 | + tx_type, | |
| 23403 | + ); | |
| 23404 | + y.reconstruct_rect( | |
| 23405 | + px, py, bw, bh, mode, angle_delta_y, reach, &residual, None, filter_intra, | |
| 23406 | + smooth_neighbor, | |
| 23407 | + ); | |
| 23408 | + levels | |
| 23409 | + }; | |
| 23410 | + let state = neighbour_state(&grid_levels); | |
| 23411 | + for cell in 0..h_mi { | |
| 23412 | + if lmi.0 + cell < neighbours.mi_rows { | |
| 23413 | + neighbours.left[lmi.0 + cell][0] = state; | |
| 23414 | + } | |
| 23415 | + } | |
| 23416 | + for cell in 0..w_mi { | |
| 23417 | + if lmi.1 + cell < neighbours.mi_cols { | |
| 23418 | + neighbours.above[lmi.1 + cell][0] = state; | |
| 23419 | + } | |
| 23420 | + } | |
| 23421 | + } | |
| 23422 | + let (tx_w, tx_h) = if split { (4, 4) } else { (bw, bh) }; | |
| 23423 | + neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip); | |
| 23424 | + neighbours.fill_lf_grid_rect(lmi, w_mi, h_mi, tx_w as u8, tx_h as u8, 0); | |
| 23425 | + // `set_txfm_ctxs(tx_size, n4_w, n4_h, skip && is_inter == 0, xd)`: an | |
| 23426 | + // intra block of an inter frame publishes its TRANSFORM dims, never its | |
| 23427 | + // block dims (blockd.h). Missing this left the next block reading the | |
| 23428 | + // previous block's band (the lane-intra16x4 finding for the 16x4 strip). | |
| 23429 | + for i in 0..w_mi { | |
| 23430 | + if let Some(cell) = neighbours.above_txfm.get_mut(lmi.1 + i) { | |
| 23431 | + *cell = tx_w as u8; | |
| 23432 | + } | |
| 23433 | + } | |
| 23434 | + for i in 0..h_mi { | |
| 23435 | + if let Some(cell) = neighbours.left_txfm.get_mut(lmi.0 + i) { | |
| 23436 | + *cell = tx_h as u8; | |
| 23437 | + } | |
| 23438 | + } | |
| 23439 | + neighbours.above_mode[c] = mode; | |
| 23440 | + neighbours.left_mode[r] = mode; | |
| 23441 | + // The inter-side bands and the mi map, exactly as the square | |
| 23442 | + // intra-in-inter block writes them: `is_inter = 0`, `INTRA_FRAME` ref, no | |
| 23443 | + // interpolation filter, no skip mode. | |
| 23444 | + neighbours.record_inter_rect_mi(lmi, w_mi, h_mi, skip, false, 0, [3, 3], false); | |
| 23445 | + for dr in 0..h_mi { | |
| 23446 | + for dc in 0..w_mi { | |
| 23447 | + grid.set( | |
| 23448 | + lmi.0 + dr, | |
| 23449 | + lmi.1 + dc, | |
| 23450 | + MiInfo { | |
| 23451 | + is_inter: false, | |
| 23452 | + ref_frame: -1, | |
| 23453 | + ref_frame1: None, | |
| 23454 | + mv1: None, | |
| 23455 | + mv: (0, 0), | |
| 23456 | + is_new_mv: false, | |
| 23457 | + size: w_mi, | |
| 23458 | + size_h: h_mi, | |
| 23459 | + is_global_mv0: false, | |
| 23460 | + is_global_mv1: false, | |
| 23461 | + }, | |
| 23462 | + ); | |
| 23463 | + } | |
| 23464 | + } | |
| 23465 | + SUB8_INTRA_RECT_HITS.with(|h| { | |
| 23466 | + let mut s = h.get(); | |
| 23467 | + s[usize::from(vert)] += 1; | |
| 23468 | + s[2] += usize::from(has_chroma); | |
| 23469 | + h.set(s); | |
| 23470 | + }); | |
| 23471 | + if !has_chroma { | |
| 23472 | + return Ok(mode); | |
| 23473 | + } | |
| 23474 | + // The group's single 4x4 chroma unit, intra-predicted from THIS | |
| 23475 | + // (chroma-reference) sub-block's own `uv_mode` -- `is_sub8x8_inter` | |
| 23476 | + // (reconinter_template.inc:54) returns false as soon as any mi of the | |
| 23477 | + // group is intra, and the decoder reconstructs chroma with the | |
| 23478 | + // chroma-reference block's own type. Same body as [`decode_leaf_rect8`]'s | |
| 23479 | + // post-loop chroma. | |
| 23480 | + let (gpx, gpy) = (gc * MI, gr * MI); | |
| 23481 | + let (cpx, cpy) = (gpx / 2, gpy / 2); | |
| 23482 | + let group_reach = Reach::of(8, gpx, gpy, y.width, y.height); | |
| 23483 | + let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(gr, gc, r, c); | |
| 23484 | + let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; | |
| 23485 | + let angle_delta_uv = 0; | |
| 23486 | + neighbours.above_uv_mode[c] = uv_predict_mode; | |
| 23487 | + neighbours.left_uv_mode[r] = uv_predict_mode; | |
| 23488 | + neighbours.record_uv_mode_mi(gr, gc, 2, 2, uv_predict_mode); | |
| 23489 | + let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); | |
| 23490 | + let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if skip { | |
| 23491 | + if alpha.is_some() { | |
| 23492 | + CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); | |
| 23493 | + SKIP_CFL_HITS.with(|c| c.set(c.get() + 1)); | |
| 23494 | + } | |
| 23495 | + u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv); | |
| 23496 | + v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv); | |
| 23497 | + (vec![0i32; 16], vec![0i32; 16]) | |
| 23498 | + } else { | |
| 23499 | + let chroma_around = neighbours.around_mi(group_mi, 8); | |
| 23500 | + let ug = read_plane( | |
| 23501 | + dec, cdfs, TxbSet::Chroma4, scan4, 1, chroma_around[1], uv_mode, uv_predict_mode, | |
| 23502 | + angle_delta_uv, group_reach, u, cpx, cpy, 4, TX4, base_q_idx, | |
| 23503 | + alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, None, smooth_neighbor_uv, | |
| 23504 | + )?; | |
| 23505 | + let vg = read_plane( | |
| 23506 | + dec, cdfs, TxbSet::Chroma4, scan4, 2, chroma_around[2], uv_mode, uv_predict_mode, | |
| 23507 | + angle_delta_uv, group_reach, v, cpx, cpy, 4, TX4, base_q_idx, | |
| 23508 | + alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, None, smooth_neighbor_uv, | |
| 23509 | + )?; | |
| 23510 | + (ug, vg) | |
| 23511 | + }; | |
| 23512 | + let round_up_even = |n: usize| n.div_ceil(2) * 2; | |
| 23513 | + let bound_h = round_up_even(neighbours.mi_rows); | |
| 23514 | + let bound_w = round_up_even(neighbours.mi_cols); | |
| 23515 | + let u_state = neighbour_state(&u_grid); | |
| 23516 | + let v_state = neighbour_state(&v_grid); | |
| 23517 | + for cell in 0..2usize { | |
| 23518 | + if cell < 2usize.min(bound_h.saturating_sub(gr)) { | |
| 23519 | + neighbours.left[gr + cell][1] = u_state; | |
| 23520 | + neighbours.left[gr + cell][2] = v_state; | |
| 23521 | + } | |
| 23522 | + if cell < 2usize.min(bound_w.saturating_sub(gc)) { | |
| 23523 | + neighbours.above[gc + cell][1] = u_state; | |
| 23524 | + neighbours.above[gc + cell][2] = v_state; | |
| 23525 | + } | |
| 23526 | + } | |
| 23527 | + Ok(mode) | |
| 23528 | +} | |
| 23529 | + | |
| 23530 | +/// Decodes a `PARTITION_HORZ`/`PARTITION_VERT` of one 8x8 INTER block into two | |
| 23531 | +/// `BLOCK_8X4`/`BLOCK_4X8` inter leaves (lane-intersub8 r3) -- the inter twin of | |
| 23532 | +/// [`decode_leaf_rect8`] and the rectangular sibling of | |
| 23533 | +/// [`decode_inter_sub8_split4`], whose element order it follows exactly. | |
| 23534 | +/// Per sub-block, in libaom `decodemv.c` `read_inter_frame_mode_info` order: | |
| 23535 | +/// | |
| 23536 | +/// * `segment_id`, `skip`, `cdef`/`delta_q`/`delta_lf`, `intra_inter`; | |
| 23537 | +/// * NO `skip_mode` symbol: `is_comp_ref_allowed(BLOCK_8X4)` is false | |
| 23538 | +/// (`av1_is_comp_ref_allowed` needs both sides >= 8), so | |
| 23539 | +/// `read_skip_mode` returns 0 without reading and `comp_mode` is never read | |
| 23540 | +/// either (`read_ref_frames`' `is_comp_ref_allowed` guard) -- single | |
| 23541 | +/// reference only; | |
| 23542 | +/// * NO `interintra` and NO `motion_mode`/OBMC/warp symbol: every one of those | |
| 23543 | +/// gates needs `block_size_wide >= 8 && block_size_high >= 8` | |
| 23544 | +/// (`is_interintra_allowed_bsize`, `motion_mode_allowed`), and one side is 4; | |
| 23545 | +/// * `read_mb_interp_filter` DOES run for both sub-blocks. | |
| 23546 | +/// | |
| 23547 | +/// The shape's own differences from the four-way split: | |
| 23548 | +/// | |
| 23549 | +/// * `block_signals_txsize(BLOCK_8X4)` is true (`bsize > BLOCK_4X4`, | |
| 23550 | +/// blockd.h:1027), so a non-skipped sub-block reads ONE `txfm_partition` | |
| 23551 | +/// symbol under `TX_MODE_SELECT` at `max_txsize_rect_lookup[BLOCK_8X4] == | |
| 23552 | +/// TX_8X4` ([`read_var_tx_size`]); split resolves to two `TX_4X4` units | |
| 23553 | +/// (`sub_tx_size_map[TX_8X4] == TX_4X4`, libaom's early return), no split to | |
| 23554 | +/// the whole-leaf `TX_8X4`; | |
| 23555 | +/// * the luma coefficient set is [`TxbSet::LumaRect8x4Inter`] (the 8x8 | |
| 23556 | +/// coefficient class with a 32-position `eob_pt` and the INTER `TX_4X4` | |
| 23557 | +/// `tx_type` row) for the whole-leaf unit, and the square | |
| 23558 | +/// [`TxbSet::Luma4Inter`] for a split `TX_4X4` unit; | |
| 23559 | +/// * chroma is coded ONCE, on the sub-block that is the chroma reference: | |
| 23560 | +/// `is_chroma_reference` (`av1_common_int.h`) is | |
| 23561 | +/// `((mi_row & 1) || !(bh4 & 1) || !ss_y) && ((mi_col & 1) || !(bw4 & 1) || | |
| 23562 | +/// !ss_x)`, i.e. under 4:2:0 the BOTTOM 8x4 (`bh4 == 1`, odd) and the RIGHT | |
| 23563 | +/// 4x8 (`bw4 == 1`) -- always the second sub-block here; | |
| 23564 | +/// * that chroma unit's prediction is the sub8x8 one (`reconinter.c` | |
| 23565 | +/// `build_inter_predictors_sub8x8`: `row_start = -(block_size_high == 4 && | |
| 23566 | +/// ss_y)`, `col_start = -(block_size_wide == 4 && ss_x)`), two 4x2 (HORZ) or | |
| 23567 | +/// 2x4 (VERT) chroma pieces, each from its OWN sub-block's reference, mv and | |
| 23568 | +/// interpolation filters. | |
| 23569 | +#[allow(clippy::too_many_arguments)] | |
| 23570 | +fn decode_inter_sub8_rect2( | |
| 23571 | + dec: &mut SymbolDecoder, | |
| 23572 | + cdfs: &mut Cdfs, | |
| 23573 | + neighbours: &mut Neighbours, | |
| 23574 | + grid: &mut MiGrid, | |
| 23575 | + group_mi: (usize, usize), | |
| 23576 | + vert: bool, | |
| 23577 | + mi_cols: u32, | |
| 23578 | + mi_rows: u32, | |
| 23579 | + y: &mut PlaneBuf, | |
| 23580 | + u: &mut PlaneBuf, | |
| 23581 | + v: &mut PlaneBuf, | |
| 23582 | + ref_y: &PlaneBuf, | |
| 23583 | + ref_u: &PlaneBuf, | |
| 23584 | + ref_v: &PlaneBuf, | |
| 23585 | + other_refs: &RefSlots, | |
| 23586 | + sign_bias_table: &SignBiasTable, | |
| 23587 | + global_motion: &[ec_av1_syntax::WarpParams; 7], | |
| 23588 | + base_q_idx: u8, | |
| 23589 | + scan4: &[u16], | |
| 23590 | + allow_high_precision_mv: bool, | |
| 23591 | + force_integer_mv: bool, | |
| 23592 | + interp_fixed: Option<mc::InterpFilterKind>, | |
| 23593 | + enable_dual_filter: bool, | |
| 23594 | + tpl_frame: Option<&TplFrameArgs>, | |
| 23595 | + reduced_tx_set: bool, | |
| 23596 | + frame_width: usize, | |
| 23597 | +) -> Result<()> { | |
| 23598 | + const LAST_FRAME: i8 = 1; | |
| 23599 | + // The 8x8 group's own square stride: both leaves' prediction buffers are | |
| 23600 | + // laid out at it, as every other rect inter unit here is. | |
| 22855 | 23601 | const SIDE: usize = 8; |
| 22856 | 23602 | let (bw, bh) = if vert { (4usize, 8usize) } else { (8usize, 4usize) }; |
| 22857 | 23603 | let (w_mi, h_mi) = (bw / MI, bh / MI); |
| @@ -22868,11 +23614,34 @@ fn decode_inter_sub8_rect2( | ||
| 22868 | 23614 | [None; 2]; |
| 22869 | 23615 | let mut first_tx_type = TxType::DctDct; |
| 22870 | 23616 | let mut last_skip = true; |
| 23617 | + // Set when the chroma-reference sub-block is INTRA: it coded the group's | |
| 23618 | + // one chroma unit itself. | |
| 23619 | + let mut intra_chroma = false; | |
| 22871 | 23620 | for i in 0..2usize { |
| 22872 | 23621 | let lmi = if vert { (gr, gc + i) } else { (gr + i, gc) }; |
| 22873 | 23622 | if lmi.0 >= mi_rows as usize || lmi.1 >= mi_cols as usize { |
| 22874 | 23623 | continue; |
| 22875 | 23624 | } |
| 23625 | + // libaom's `xd->above_mbmi`/`xd->left_mbmi` are the neighbour block as | |
| 23626 | + // DECODED, so leaf 1 sees leaf 0's own `bsize` -- the group tail below | |
| 23627 | + // publishes the side bands only once both leaves are done, which left | |
| 23628 | + // leaf 1 reading whatever block preceded the GROUP. `get_tx_size_context` | |
| 23629 | + // (pred_common.h:342) takes `block_size_wide[above_mbmi->bsize]` from it, | |
| 23630 | + // so an intra 8x4 leaf 1 read `tx_size_cat0` row 1 where aomdec reads | |
| 23631 | + // row 2 (class tx-grid-published-block-side). | |
| 23632 | + if i == 1 { | |
| 23633 | + if vert { | |
| 23634 | + for cell in 0..h_mi { | |
| 23635 | + neighbours.left_side_mi[gr + cell] = bh; | |
| 23636 | + } | |
| 23637 | + neighbours.above_side_mi[gc] = bw; | |
| 23638 | + } else { | |
| 23639 | + for cell in 0..w_mi { | |
| 23640 | + neighbours.above_side_mi[gc + cell] = bw; | |
| 23641 | + } | |
| 23642 | + neighbours.left_side_mi[gr] = bh; | |
| 23643 | + } | |
| 23644 | + } | |
| 22876 | 23645 | let (rmi, cmi) = lmi; |
| 22877 | 23646 | let (px, py) = (cmi * MI, rmi * MI); |
| 22878 | 23647 | inter_segment_id(dec, cdfs, rmi, cmi, w_mi, h_mi, false, true); |
| @@ -22895,10 +23664,44 @@ fn decode_inter_sub8_rect2( | ||
| 22895 | 23664 | ); |
| 22896 | 23665 | let is_inter = dec.symbol(&mut cdfs.intra_inter[ii_ctx]) == 1; |
| 22897 | 23666 | if !is_inter { |
| 22898 | - return Err(unsupported( | |
| 22899 | - "an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition \ | |
| 22900 | - (this decoder codes only inter sub-blocks there)", | |
| 22901 | - )); | |
| 23667 | + if std::env::var_os("EC_SUB8INTRA").is_some() { | |
| 23668 | + eprintln!( | |
| 23669 | + "EC_SUB8INTRA shape={}x{} sub={i} has_chroma={} skip={skip} mi={rmi},{cmi} tx_select={}", | |
| 23670 | + bw, | |
| 23671 | + bh, | |
| 23672 | + i == 1, | |
| 23673 | + TX_SELECT_INTER.with(std::cell::Cell::get), | |
| 23674 | + ); | |
| 23675 | + } | |
| 23676 | + // lane-sub8x4 r2: refusal and bypass lifted -- see the split arm's | |
| 23677 | + // note above for the gate that proves this leaf. | |
| 23678 | + // Its chroma rule is `is_sub8x8_inter`'s: when the | |
| 23679 | + // chroma-reference (second) sub-block is the intra one, the | |
| 23680 | + // group's 4x4 chroma is coded and predicted INTRA there and the | |
| 23681 | + // inter chroma tail below is skipped entirely. | |
| 23682 | + decode_intra_sub8_leaf( | |
| 23683 | + dec, | |
| 23684 | + cdfs, | |
| 23685 | + neighbours, | |
| 23686 | + grid, | |
| 23687 | + group_mi, | |
| 23688 | + lmi, | |
| 23689 | + (bw, bh), | |
| 23690 | + i == 1, | |
| 23691 | + skip, | |
| 23692 | + scan4, | |
| 23693 | + y, | |
| 23694 | + u, | |
| 23695 | + v, | |
| 23696 | + base_q_idx, | |
| 23697 | + ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get), | |
| 23698 | + TX_SELECT_INTER.with(std::cell::Cell::get), | |
| 23699 | + reduced_tx_set, | |
| 23700 | + )?; | |
| 23701 | + if i == 1 { | |
| 23702 | + intra_chroma = true; | |
| 23703 | + } | |
| 23704 | + continue; | |
| 22902 | 23705 | } |
| 22903 | 23706 | if std::env::var_os("EC_TRACE_MODE").is_some() { |
| 22904 | 23707 | eprintln!( |
| @@ -23158,10 +23961,13 @@ fn decode_inter_sub8_rect2( | ||
| 23158 | 23961 | None, |
| 23159 | 23962 | )? |
| 23160 | 23963 | }; |
| 23161 | - if idx == 0 { | |
| 23964 | + if idx == 0 && (i == 0 || piece[0].is_none()) { | |
| 23162 | 23965 | // `av1_get_tx_type`: the group's one chroma unit scales |
| 23163 | 23966 | // back to luma (0, 0), i.e. the FIRST sub-block's first |
| 23164 | - // transform unit. | |
| 23967 | + // transform unit -- unless that sub-block is INTRA | |
| 23968 | + // (lane-sub8intra), in which case it wrote no inter | |
| 23969 | + // tx_type at all and `xd->tx_type_map[0]` of the | |
| 23970 | + // chroma-reference block is this one's. | |
| 23165 | 23971 | first_tx_type = tu_tx_type; |
| 23166 | 23972 | } |
| 23167 | 23973 | neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid); |
| @@ -23181,64 +23987,109 @@ fn decode_inter_sub8_rect2( | ||
| 23181 | 23987 | neighbours.fill_skip_grid_rect(lmi, w_mi, h_mi, skip); |
| 23182 | 23988 | last_skip = skip; |
| 23183 | 23989 | } |
| 23184 | - // The group's single 4x4 chroma unit per plane, on the chroma-reference | |
| 23185 | - // (second) sub-block's own skip flag. | |
| 23186 | - const B4: usize = 4; | |
| 23187 | - let mut pred_u = vec![0u16; B4 * B4]; | |
| 23188 | - let mut pred_v = vec![0u16; B4 * B4]; | |
| 23189 | - let (piece_w, piece_h) = if vert { (2usize, 4usize) } else { (4usize, 2usize) }; | |
| 23190 | - for i in 0..2usize { | |
| 23191 | - let Some((ref_frame, mv, h_filter, v_filter)) = piece[i] else { | |
| 23192 | - continue; | |
| 23990 | + // lane-sub8intra: when the chroma-reference sub-block was INTRA it coded | |
| 23991 | + // and reconstructed the group's one chroma unit itself. | |
| 23992 | + if !intra_chroma { | |
| 23993 | + // The group's single 4x4 chroma unit per plane, on the chroma-reference | |
| 23994 | + // (second) sub-block's own skip flag. | |
| 23995 | + const B4: usize = 4; | |
| 23996 | + let mut pred_u = vec![0u16; B4 * B4]; | |
| 23997 | + let mut pred_v = vec![0u16; B4 * B4]; | |
| 23998 | + // `is_sub8x8_inter` (reconinter_template.inc:54) is false as soon as ANY | |
| 23999 | + // mi of the group is intra, so a group whose chroma reference is inter but | |
| 24000 | + // whose sibling is INTRA does NOT get the two-piece sub8x8 prediction: the | |
| 24001 | + // ordinary 8x8-and-bigger path predicts the WHOLE 4x4 chroma unit from the | |
| 24002 | + // chroma-reference block's own mv, at the group's chroma origin | |
| 24003 | + // (`row_start`/`col_start` shift `pre_x`/`pre_y` there either way). | |
| 24004 | + let mixed = piece[0].is_none(); | |
| 24005 | + if mixed { | |
| 24006 | + SUB8_INTRA_RECT_HITS.with(|h| { | |
| 24007 | + let mut s = h.get(); | |
| 24008 | + s[3] += 1; | |
| 24009 | + h.set(s); | |
| 24010 | + }); | |
| 24011 | + } | |
| 24012 | + let (piece_w, piece_h) = match (mixed, vert) { | |
| 24013 | + (true, _) => (B4, B4), | |
| 24014 | + (false, true) => (2usize, 4usize), | |
| 24015 | + (false, false) => (4usize, 2usize), | |
| 23193 | 24016 | }; |
| 23194 | - let (_, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?; | |
| 23195 | - let (ox, oy) = if vert { | |
| 23196 | - (cpx + i * piece_w, cpy) | |
| 24017 | + for i in 0..2usize { | |
| 24018 | + let Some((ref_frame, mv, h_filter, v_filter)) = piece[i] else { | |
| 24019 | + continue; | |
| 24020 | + }; | |
| 24021 | + let (_, sref_u, sref_v) = ref_planes(ref_frame, ref_y, ref_u, ref_v, other_refs)?; | |
| 24022 | + let (ox, oy) = if mixed { | |
| 24023 | + (cpx, cpy) | |
| 24024 | + } else if vert { | |
| 24025 | + (cpx + i * piece_w, cpy) | |
| 24026 | + } else { | |
| 24027 | + (cpx, cpy + i * piece_h) | |
| 24028 | + }; | |
| 24029 | + let (dc, dr) = if mixed { | |
| 24030 | + (0, 0) | |
| 24031 | + } else if vert { | |
| 24032 | + (i * piece_w, 0) | |
| 24033 | + } else { | |
| 24034 | + (0, i * piece_h) | |
| 24035 | + }; | |
| 24036 | + for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] { | |
| 24037 | + let mut buf = vec![0u16; piece_w * piece_h]; | |
| 24038 | + mc::predict_with_filters( | |
| 24039 | + &plane.data, | |
| 24040 | + plane.width, | |
| 24041 | + plane.true_width, | |
| 24042 | + plane.true_height, | |
| 24043 | + mv_to_q4(ox, mv.1, false), | |
| 24044 | + mv_to_q4(oy, mv.0, false), | |
| 24045 | + piece_w, | |
| 24046 | + piece_h, | |
| 24047 | + h_filter, | |
| 24048 | + v_filter, | |
| 24049 | + &mut buf, | |
| 24050 | + ); | |
| 24051 | + for row in 0..piece_h { | |
| 24052 | + for col in 0..piece_w { | |
| 24053 | + dst[(dr + row) * B4 + dc + col] = buf[row * piece_w + col]; | |
| 24054 | + } | |
| 24055 | + } | |
| 24056 | + } | |
| 24057 | + } | |
| 24058 | + let (u_grid, v_grid) = if last_skip { | |
| 24059 | + u.reconstruct_mc(cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4]); | |
| 24060 | + v.reconstruct_mc(cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4]); | |
| 24061 | + (vec![0i32; B4 * B4], vec![0i32; B4 * B4]) | |
| 23197 | 24062 | } else { |
| 23198 | - (cpx, cpy + i * piece_h) | |
| 24063 | + let around = neighbours.around_mi(group_mi, 8); | |
| 24064 | + let ug = read_inter_plane( | |
| 24065 | + dec, cdfs, TxbSet::Chroma4, scan4, 1, around[1], 0, u, cpx, cpy, B4, base_q_idx, | |
| 24066 | + &pred_u, Some(first_tx_type), None, | |
| 24067 | + )? | |
| 24068 | + .0; | |
| 24069 | + let vg = read_inter_plane( | |
| 24070 | + dec, cdfs, TxbSet::Chroma4, scan4, 2, around[2], 0, v, cpx, cpy, B4, base_q_idx, | |
| 24071 | + &pred_v, Some(first_tx_type), None, | |
| 24072 | + )? | |
| 24073 | + .0; | |
| 24074 | + (ug, vg) | |
| 23199 | 24075 | }; |
| 23200 | - let (dc, dr) = if vert { (i * piece_w, 0) } else { (0, i * piece_h) }; | |
| 23201 | - for (plane, dst) in [(sref_u, &mut pred_u), (sref_v, &mut pred_v)] { | |
| 23202 | - let mut buf = vec![0u16; piece_w * piece_h]; | |
| 23203 | - mc::predict_with_filters( | |
| 23204 | - &plane.data, | |
| 23205 | - plane.width, | |
| 23206 | - plane.true_width, | |
| 23207 | - plane.true_height, | |
| 23208 | - mv_to_q4(ox, mv.1, false), | |
| 23209 | - mv_to_q4(oy, mv.0, false), | |
| 23210 | - piece_w, | |
| 23211 | - piece_h, | |
| 23212 | - h_filter, | |
| 23213 | - v_filter, | |
| 23214 | - &mut buf, | |
| 23215 | - ); | |
| 23216 | - for row in 0..piece_h { | |
| 23217 | - for col in 0..piece_w { | |
| 23218 | - dst[(dr + row) * B4 + dc + col] = buf[row * piece_w + col]; | |
| 23219 | - } | |
| 24076 | + neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED); | |
| 24077 | + let round_up_even = |n: usize| n.div_ceil(2) * 2; | |
| 24078 | + let bound_h = round_up_even(neighbours.mi_rows); | |
| 24079 | + let bound_w = round_up_even(neighbours.mi_cols); | |
| 24080 | + let u_state = neighbour_state(&u_grid); | |
| 24081 | + let v_state = neighbour_state(&v_grid); | |
| 24082 | + for cell in 0..2usize { | |
| 24083 | + if cell < 2usize.min(bound_h.saturating_sub(gr)) { | |
| 24084 | + neighbours.left[gr + cell][1] = u_state; | |
| 24085 | + neighbours.left[gr + cell][2] = v_state; | |
| 24086 | + } | |
| 24087 | + if cell < 2usize.min(bound_w.saturating_sub(gc)) { | |
| 24088 | + neighbours.above[gc + cell][1] = u_state; | |
| 24089 | + neighbours.above[gc + cell][2] = v_state; | |
| 23220 | 24090 | } |
| 23221 | 24091 | } |
| 23222 | 24092 | } |
| 23223 | - let (u_grid, v_grid) = if last_skip { | |
| 23224 | - u.reconstruct_mc(cpx, cpy, B4, &pred_u, &vec![0i32; B4 * B4]); | |
| 23225 | - v.reconstruct_mc(cpx, cpy, B4, &pred_v, &vec![0i32; B4 * B4]); | |
| 23226 | - (vec![0i32; B4 * B4], vec![0i32; B4 * B4]) | |
| 23227 | - } else { | |
| 23228 | - let around = neighbours.around_mi(group_mi, 8); | |
| 23229 | - let ug = read_inter_plane( | |
| 23230 | - dec, cdfs, TxbSet::Chroma4, scan4, 1, around[1], 0, u, cpx, cpy, B4, base_q_idx, | |
| 23231 | - &pred_u, Some(first_tx_type), None, | |
| 23232 | - )? | |
| 23233 | - .0; | |
| 23234 | - let vg = read_inter_plane( | |
| 23235 | - dec, cdfs, TxbSet::Chroma4, scan4, 2, around[2], 0, v, cpx, cpy, B4, base_q_idx, | |
| 23236 | - &pred_v, Some(first_tx_type), None, | |
| 23237 | - )? | |
| 23238 | - .0; | |
| 23239 | - (ug, vg) | |
| 23240 | - }; | |
| 23241 | - neighbours.record_uv_mode_mi(gr, gc, 2, 2, DC_PRED); | |
| 23242 | 24093 | // `update_partition_context` writes `partition_context_lookup[subsize]` |
| 23243 | 24094 | // over the whole 8x8 span -- BLOCK_4X8's width above and height left, the |
| 23244 | 24095 | // same values [`decode_leaf_rect8`] writes for the intra shape. |
| @@ -23246,21 +24097,6 @@ fn decode_inter_sub8_rect2( | ||
| 23246 | 24097 | neighbours.above_side_mi[gc + cell] = bw; |
| 23247 | 24098 | neighbours.left_side_mi[gr + cell] = bh; |
| 23248 | 24099 | } |
| 23249 | - let round_up_even = |n: usize| n.div_ceil(2) * 2; | |
| 23250 | - let bound_h = round_up_even(neighbours.mi_rows); | |
| 23251 | - let bound_w = round_up_even(neighbours.mi_cols); | |
| 23252 | - let u_state = neighbour_state(&u_grid); | |
| 23253 | - let v_state = neighbour_state(&v_grid); | |
| 23254 | - for cell in 0..2usize { | |
| 23255 | - if cell < 2usize.min(bound_h.saturating_sub(gr)) { | |
| 23256 | - neighbours.left[gr + cell][1] = u_state; | |
| 23257 | - neighbours.left[gr + cell][2] = v_state; | |
| 23258 | - } | |
| 23259 | - if cell < 2usize.min(bound_w.saturating_sub(gc)) { | |
| 23260 | - neighbours.above[gc + cell][1] = u_state; | |
| 23261 | - neighbours.above[gc + cell][2] = v_state; | |
| 23262 | - } | |
| 23263 | - } | |
| 23264 | 24100 | Ok(()) |
| 23265 | 24101 | } |
| 23266 | 24102 | |
| @@ -24114,7 +24950,36 @@ fn decode_inter_block8( | ||
| 24114 | 24950 | // there before. Every leaf of the gate's stream is compound, |
| 24115 | 24951 | // so the 16x16 below a split block read partition ctx 0 |
| 24116 | 24952 | // instead of 1 and mis-read PARTITION_SPLIT as NONE. |
| 24953 | + // lane-sub8x4 r1: the same plane-0 save/restore the fall-through | |
| 24954 | + // (single-ref) path runs below -- a `split8` leaf's plane-0 | |
| 24955 | + // neighbour context is per 4x4 transform unit (written by | |
| 24956 | + // `record_mi_luma` inside `read_inter_luma8`), and `record_mi` | |
| 24957 | + // rewrites all three planes from the whole-block grid, which is | |
| 24958 | + // all-zero in the split case. Missing here, a compound var-tx 8x8 | |
| 24959 | + // leaf published level 0 to its right/below neighbours: the next | |
| 24960 | + // block's first TU read `skip_contexts[4][0] = 3` where aomdec | |
| 24961 | + // reads `[4][4] = 6` (class early-return-skips-tail). | |
| 24962 | + let saved_luma_ctx = split8.then(|| { | |
| 24963 | + ( | |
| 24964 | + [ | |
| 24965 | + neighbours.left[leaf_mi.0][0], | |
| 24966 | + neighbours.left[leaf_mi.0 + 1][0], | |
| 24967 | + ], | |
| 24968 | + [ | |
| 24969 | + neighbours.above[leaf_mi.1][0], | |
| 24970 | + neighbours.above[leaf_mi.1 + 1][0], | |
| 24971 | + ], | |
| 24972 | + ) | |
| 24973 | + }); | |
| 24117 | 24974 | neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); |
| 24975 | + if let Some((left, above)) = saved_luma_ctx { | |
| 24976 | + for (cell, state) in left.into_iter().enumerate() { | |
| 24977 | + neighbours.left[leaf_mi.0 + cell][0] = state; | |
| 24978 | + } | |
| 24979 | + for (cell, state) in above.into_iter().enumerate() { | |
| 24980 | + neighbours.above[leaf_mi.1 + cell][0] = state; | |
| 24981 | + } | |
| 24982 | + } | |
| 24118 | 24983 | // lane-cdef r1: ... and the CDEF skip band too. `apply_cdef`'s |
| 24119 | 24984 | // `is_8x8_block_skip` (libaom `cdef.c:29-38`) reads all four mi |
| 24120 | 24985 | // cells of the 8x8; this leaf wrote none of them, so a 64x64 |
| @@ -24123,10 +24988,18 @@ fn decode_inter_block8( | ||
| 24123 | 24988 | // dlist excludes it (3 luma samples on a 192x128 inter frame). |
| 24124 | 24989 | INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); |
| 24125 | 24990 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 24991 | + // lane-sub8x4 r2: `split8` is this leaf's OWN var-tx split, so | |
| 24992 | + // the deblock grid must publish the TX_4X4 leaves' width the | |
| 24993 | + // same way the fall-through arm below does (libaom | |
| 24994 | + // `get_transform_size`, av1_loopfilter.c:207, reads the per-TU | |
| 24995 | + // `inter_tx_size` for a non-skip inter luma block). Hardcoding | |
| 24996 | + // 8 here left a compound var-tx 8x8 leaf's interior vertical | |
| 24997 | + // edge at x % 8 == 4 unfiltered -- class early-return-skips-tail, | |
| 24998 | + // third instance in this same arm. | |
| 24126 | 24999 | neighbours.fill_lf_grid( |
| 24127 | 25000 | leaf_mi, |
| 24128 | 25001 | 2, |
| 24129 | - 8, | |
| 25002 | + if split8 { 4 } else { 8 }, | |
| 24130 | 25003 | if is_inter { leaf_refs.0.max(LAST_FRAME) } else { 0 }, |
| 24131 | 25004 | ); |
| 24132 | 25005 | return Ok(( |
crates/ec-av1/src/mvstack.rsmodified+32 -8
| @@ -532,7 +532,10 @@ fn scan_row( | ||
| 532 | 532 | let Some(row) = mi_row.checked_add_signed(row_offset) else { |
| 533 | 533 | return false; |
| 534 | 534 | }; |
| 535 | - let col_shift: usize = if row_offset.unsigned_abs() > 1 { 1 } else { 0 }; | |
| 535 | + // libaom `scan_row_mbmi` (mvref_common.c:157): the shift steps BACK on an odd | |
| 536 | + // mi_col when the block is narrower than 8px (a 4-wide 1:4 strip / sub-8x8 leaf). | |
| 537 | + let col_shift: usize = | |
| 538 | + if row_offset.unsigned_abs() > 1 && !(mi_col & 1 != 0 && bw4 < 2) { 1 } else { 0 }; | |
| 536 | 539 | let use_step_16 = bw4 >= 16; |
| 537 | 540 | let end_mi = bw4.min(16); |
| 538 | 541 | let mut found = false; |
| @@ -550,7 +553,10 @@ fn scan_row( | ||
| 550 | 553 | len = len.max(2); |
| 551 | 554 | } |
| 552 | 555 | let mut weight = ROW_COL_WEIGHT_FLOOR; |
| 553 | - if bw4 <= n4 { | |
| 556 | + // libaom `scan_row_mbmi` (mvref_common.c:172) gates this on | |
| 557 | + // `xd->width >= mi_size_wide[BLOCK_8X8]` as well: a 4-wide block (a 1:4 | |
| 558 | + // strip, a sub-8x8 leaf) keeps weight 2 and leaves `processed_rows` alone. | |
| 559 | + if bw4 >= 2 && bw4 <= n4 { | |
| 554 | 560 | let inc = ((-max_row_offset + row_offset + 1) as usize).min(info.size_h); |
| 555 | 561 | weight = weight.max(inc as u32); |
| 556 | 562 | *processed_rows = (inc as isize - row_offset - 1).max(0) as usize; |
| @@ -614,7 +620,10 @@ fn scan_col( | ||
| 614 | 620 | let Some(col) = mi_col.checked_add_signed(col_offset) else { |
| 615 | 621 | return false; |
| 616 | 622 | }; |
| 617 | - let row_shift: usize = if col_offset.unsigned_abs() > 1 { 1 } else { 0 }; | |
| 623 | + // libaom `scan_col_mbmi` (mvref_common.c:206): same step-back on an odd mi_row | |
| 624 | + // under a 4-high block. | |
| 625 | + let row_shift: usize = | |
| 626 | + if col_offset.unsigned_abs() > 1 && !(mi_row & 1 != 0 && bh4 < 2) { 1 } else { 0 }; | |
| 618 | 627 | let use_step_16 = bh4 >= 16; |
| 619 | 628 | let end_mi = bh4.min(16); |
| 620 | 629 | let mut found = false; |
| @@ -632,7 +641,10 @@ fn scan_col( | ||
| 632 | 641 | len = len.max(2); |
| 633 | 642 | } |
| 634 | 643 | let mut weight = ROW_COL_WEIGHT_FLOOR; |
| 635 | - if bh4 <= n4 { | |
| 644 | + // libaom `scan_col_mbmi` (mvref_common.c:222): `xd->height >= | |
| 645 | + // mi_size_high[BLOCK_8X8]` gates this branch, so a 4-high block keeps | |
| 646 | + // weight 2 and leaves `processed_cols` alone. | |
| 647 | + if bh4 >= 2 && bh4 <= n4 { | |
| 636 | 648 | let inc = ((-max_col_offset + col_offset + 1) as usize).min(info.size); |
| 637 | 649 | weight = weight.max(inc as u32); |
| 638 | 650 | *processed_cols = (inc as isize - col_offset - 1).max(0) as usize; |
| @@ -1362,7 +1374,10 @@ fn scan_row_compound( | ||
| 1362 | 1374 | let Some(row) = mi_row.checked_add_signed(row_offset) else { |
| 1363 | 1375 | return false; |
| 1364 | 1376 | }; |
| 1365 | - let col_shift: usize = if row_offset.unsigned_abs() > 1 { 1 } else { 0 }; | |
| 1377 | + // libaom `scan_row_mbmi` (mvref_common.c:157): the shift steps BACK on an odd | |
| 1378 | + // mi_col when the block is narrower than 8px (a 4-wide 1:4 strip / sub-8x8 leaf). | |
| 1379 | + let col_shift: usize = | |
| 1380 | + if row_offset.unsigned_abs() > 1 && !(mi_col & 1 != 0 && bw4 < 2) { 1 } else { 0 }; | |
| 1366 | 1381 | let use_step_16 = bw4 >= 16; |
| 1367 | 1382 | let end_mi = bw4.min(16); |
| 1368 | 1383 | let mut found = false; |
| @@ -1380,7 +1395,10 @@ fn scan_row_compound( | ||
| 1380 | 1395 | len = len.max(2); |
| 1381 | 1396 | } |
| 1382 | 1397 | let mut weight = ROW_COL_WEIGHT_FLOOR; |
| 1383 | - if bw4 <= n4 { | |
| 1398 | + // libaom `scan_row_mbmi` (mvref_common.c:172) gates this on | |
| 1399 | + // `xd->width >= mi_size_wide[BLOCK_8X8]` as well: a 4-wide block (a 1:4 | |
| 1400 | + // strip, a sub-8x8 leaf) keeps weight 2 and leaves `processed_rows` alone. | |
| 1401 | + if bw4 >= 2 && bw4 <= n4 { | |
| 1384 | 1402 | let inc = ((-max_row_offset + row_offset + 1) as usize).min(info.size_h); |
| 1385 | 1403 | weight = weight.max(inc as u32); |
| 1386 | 1404 | *processed_rows = (inc as isize - row_offset - 1).max(0) as usize; |
| @@ -1419,7 +1437,10 @@ fn scan_col_compound( | ||
| 1419 | 1437 | let Some(col) = mi_col.checked_add_signed(col_offset) else { |
| 1420 | 1438 | return false; |
| 1421 | 1439 | }; |
| 1422 | - let row_shift: usize = if col_offset.unsigned_abs() > 1 { 1 } else { 0 }; | |
| 1440 | + // libaom `scan_col_mbmi` (mvref_common.c:206): same step-back on an odd mi_row | |
| 1441 | + // under a 4-high block. | |
| 1442 | + let row_shift: usize = | |
| 1443 | + if col_offset.unsigned_abs() > 1 && !(mi_row & 1 != 0 && bh4 < 2) { 1 } else { 0 }; | |
| 1423 | 1444 | let use_step_16 = bh4 >= 16; |
| 1424 | 1445 | let end_mi = bh4.min(16); |
| 1425 | 1446 | let mut found = false; |
| @@ -1437,7 +1458,10 @@ fn scan_col_compound( | ||
| 1437 | 1458 | len = len.max(2); |
| 1438 | 1459 | } |
| 1439 | 1460 | let mut weight = ROW_COL_WEIGHT_FLOOR; |
| 1440 | - if bh4 <= n4 { | |
| 1461 | + // libaom `scan_col_mbmi` (mvref_common.c:222): `xd->height >= | |
| 1462 | + // mi_size_high[BLOCK_8X8]` gates this branch, so a 4-high block keeps | |
| 1463 | + // weight 2 and leaves `processed_cols` alone. | |
| 1464 | + if bh4 >= 2 && bh4 <= n4 { | |
| 1441 | 1465 | let inc = ((-max_col_offset + col_offset + 1) as usize).min(info.size); |
| 1442 | 1466 | weight = weight.max(inc as u32); |
| 1443 | 1467 | *processed_cols = (inc as isize - col_offset - 1).max(0) as usize; |
crates/ec-av1/src/refusal_inventory.rsmodified+0 -2
| @@ -32,8 +32,6 @@ const REFUSALS: &[&str] = &[ | ||
| 32 | 32 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 33 | 33 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", |
| 34 | 34 | "an OBMC neighbour whose switchable interp filter was never recorded", |
| 35 | - "an intra 4x4 block inside an inter frame's sub-8x8 split (this decoder codes only inter 4x4 sub-blocks there)", | |
| 36 | - "an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition (this decoder codes only inter sub-blocks there)", | |
| 37 | 35 | "a sub-8x8 inter block under a scaled reference (superres, unimplemented)", |
| 38 | 36 | "a rectangular inter luma transform unit whose shape has no coefficient table set here", |
| 39 | 37 | "a rectangular inter chroma transform unit whose shape has no coefficient table set here", |
crates/ec-av1/src/stream.rsmodified+664 -3
| @@ -80,6 +80,19 @@ pub fn rect32x8_inter_tu_hits() -> [usize; 2] { | ||
| 80 | 80 | crate::decode::rect32x8_inter_tu_hits() |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | +/// lane-intra16x4: `(16x4, 4x16, chroma-reference)` INTRA strips decoded inside | |
| 84 | +/// an inter 16x16-level 1:4 partition. | |
| 85 | +pub fn intra16x4_in_inter_hits() -> (usize, usize, usize) { | |
| 86 | + crate::decode::intra16x4_in_inter_hits() | |
| 87 | +} | |
| 88 | + | |
| 89 | +/// lane-sub8intra: INTRA 8x4/4x8 leaves inside an inter frame's sub-8x8 | |
| 90 | +/// HORZ/VERT partition, `(8x4, 4x8, chroma-reference, mixed groups, split | |
| 91 | +/// 4x4 leaves)`. | |
| 92 | +pub fn sub8_intra_rect_hits() -> (usize, usize, usize, usize, usize) { | |
| 93 | + crate::decode::sub8_intra_rect_hits() | |
| 94 | +} | |
| 95 | + | |
| 83 | 96 | /// lane-r14 r3: RECTANGULAR var-tx leaf transform units, `[32x16, 16x32]` -- |
| 84 | 97 | /// the leaves `sub_tx_size_map` produces when a 1:4 strip with a 64-px axis |
| 85 | 98 | /// splits its transform (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`). |
| @@ -11047,6 +11060,321 @@ mod tests { | ||
| 11047 | 11060 | } |
| 11048 | 11061 | |
| 11049 | 11062 | |
| 11063 | + #[test] | |
| 11064 | + #[ignore = "RED at lane-intra16x4 r2, but NOT on this lane's shape: the r2 OBMC \ | |
| 11065 | + pair-merge fix makes the decode entropy-exact through the intra 16x4 strips \ | |
| 11066 | + (620/620 all_zero symbols match aomdec, value and range), and the new arm 4 \ | |
| 11067 | + (bar_h, cq63, --min-partition-size=8, 192x128, 5 strips) decodes 6 frames \ | |
| 11068 | + bit-exact vs ffmpeg outside the harness. Attempt 0 (noise, cq60, 128x128) \ | |
| 11069 | + still mismatches from (122, 13) -- 99 rows ABOVE its first strip, measured in \ | |
| 11070 | + r1 as another shape's defect -- and panics before arm 4 runs. Un-ignore once \ | |
| 11071 | + attempt 0's defect is owned -- lanes/intra16x4-r2.handoff.md"] | |
| 11072 | + // lane-intra16x4 r1: an INTRA-coded 16x4 / 4x16 strip inside an INTER | |
| 11073 | + // frame's 16x16-level 1:4 partition -- the wall all six of his film cuts | |
| 11074 | + // stopped at once lane-rectres landed. The shape's chroma is the pair's: | |
| 11075 | + // `is_chroma_reference` (av1_common_int.h:1454) is false on the even | |
| 11076 | + // strips (which read no `uv_mode` and code no chroma at all) and the odd | |
| 11077 | + // one codes ONE 8x4 (4x8) chroma unit at the pair's origin -- and when the | |
| 11078 | + // pair mixes an intra and an inter strip, the chroma is predicted per the | |
| 11079 | + // strip that CARRIES it, which is exactly what routing the intra strip | |
| 11080 | + // through the key frame's own proven per-strip body | |
| 11081 | + // (`decode_rect4_16_strip`) gives. | |
| 11082 | + // | |
| 11083 | + // Recipes found by a 24 + 24 run sweep (three sources x cq 16..63 x two | |
| 11084 | + // sizes, `~/.cache/intra16x4-tmp/sweep*.sh`): aomenc only picks an INTRA | |
| 11085 | + // 1:4 strip on an inter frame at HIGH cq over content its MC cannot | |
| 11086 | + // predict -- a per-frame-random bright bar sweeping the frame (HORZ_4 | |
| 11087 | + // strips) and a `X*Y` product sinusoid under temporal noise (VERT_4). | |
| 11088 | + // Both sources hash identically twice (report). | |
| 11089 | + fn a_real_aomenc_inter_sequence_with_intra_16x4_strips_in_1to4_partitions_decodes_pixel_exact() { | |
| 11090 | + const NAME: &str = | |
| 11091 | + "a_real_aomenc_inter_sequence_with_intra_16x4_strips_in_1to4_partitions_decodes_pixel_exact"; | |
| 11092 | + let _gate_lock = lock_gate_counters(); | |
| 11093 | + if !have_ffmpeg() { | |
| 11094 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 11095 | + return; | |
| 11096 | + } | |
| 11097 | + if !have_aomenc() { | |
| 11098 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 11099 | + return; | |
| 11100 | + } | |
| 11101 | + let frame_count = 6usize; | |
| 11102 | + // (source kind, cq, width, height) -- the four recipes of the 48-run | |
| 11103 | + // sweep (`~/.cache/intra16x4-tmp/sweep*.sh`, table in the report) that | |
| 11104 | + // reach an INTRA 1:4 strip on an inter frame. `bar` is a per-frame | |
| 11105 | + // random bright bar sweeping the frame (its MC failure is what makes | |
| 11106 | + // aomenc's RD pick intra at 16x4), `prod` an `X*Y` product sinusoid | |
| 11107 | + // under temporal noise; `_v` transposes the structure so the RD picks | |
| 11108 | + // PARTITION_VERT_4. | |
| 11109 | + // lane-intra16x4 r2: the last field is `--min-partition-size` -- the | |
| 11110 | + // `bar_h` recipe (a horizontal bar sweeping DOWN the frame) at | |
| 11111 | + // `--min-partition-size=8` is the one recipe of the r2 96-run sweep | |
| 11112 | + // (`~/.cache/intra16x4-tmp/sweep_r2.sh`) that fires intra 16x4 strips | |
| 11113 | + // WITHOUT also carrying the sub-8x8 intra block another lane refuses, | |
| 11114 | + // so it is the arm that can be pixel-compared at all. | |
| 11115 | + const RECIPES: [(&str, u32, usize, usize, u32); 5] = [ | |
| 11116 | + ("noise", 60, 128, 128, 4), | |
| 11117 | + ("bar", 60, 192, 128, 4), | |
| 11118 | + ("prod_v", 56, 128, 128, 4), | |
| 11119 | + ("prod", 56, 160, 128, 4), | |
| 11120 | + ("bar_h", 63, 192, 128, 8), | |
| 11121 | + ]; | |
| 11122 | + // [16x4 intra strips, 4x16 intra strips, of which chroma-reference]: | |
| 11123 | + // how many pixel-exact attempts fired each, over both bit depths. | |
| 11124 | + let mut arms_total = [0u32; 3]; | |
| 11125 | + // Attempts that refused on the sub-8x8 intra block inside an inter | |
| 11126 | + // frame -- a DIFFERENT lane's shape, and the measured blocker of every | |
| 11127 | + // VERT_4-carrying recipe in the sweep. | |
| 11128 | + let mut sub8_intra_refusals = 0u32; | |
| 11129 | + // Every failure the sweep sees, asserted ONCE at the end. | |
| 11130 | + let mut failures: Vec<String> = Vec::new(); | |
| 11131 | + // Per bit depth: attempts that decoded at all, and attempts that fired an | |
| 11132 | + // intra 1:4 strip AND compared pixel-exact. | |
| 11133 | + let mut decoded_per_depth = [0u32; 2]; | |
| 11134 | + let mut fired_exact_per_depth = [0u32; 2]; | |
| 11135 | + for (depth_idx, bit_depth) in [8u32, 10u32].into_iter().enumerate() { | |
| 11136 | + let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = | |
| 11137 | + (0u32, 0u32, 0u32, 0u32); | |
| 11138 | + let mut arms_proved = [0u32; 3]; | |
| 11139 | + for attempt in 0..RECIPES.len() as u32 { | |
| 11140 | + let (kind, cq, width, height, min_part) = RECIPES[attempt as usize]; | |
| 11141 | + let duration = frame_count as f64 / 25.0; | |
| 11142 | + // Both sources are deterministic (two identical y4m hashes, | |
| 11143 | + // report): `random()` here is geq's own indexed PRNG and the | |
| 11144 | + // noise filter carries an explicit `all_seed`. | |
| 11145 | + let (lum, noise) = match kind { | |
| 11146 | + "noise" => ( | |
| 11147 | + format!("128+58*sin((X+N*3)/6)+40*sin(Y/11)"), | |
| 11148 | + ",noise=alls=40:allf=t+u:all_seed=7", | |
| 11149 | + ), | |
| 11150 | + "bar" => ( | |
| 11151 | + format!( | |
| 11152 | + "if(lt(mod(X+N*37,{width}),24),random(N*100+X+Y)*255,128+50*sin(Y/7))" | |
| 11153 | + ), | |
| 11154 | + "", | |
| 11155 | + ), | |
| 11156 | + "bar_h" => ( | |
| 11157 | + format!( | |
| 11158 | + "if(lt(mod(Y+N*37,{height}),24),random(N*100+X+Y)*255,128+50*sin(X/7))" | |
| 11159 | + ), | |
| 11160 | + "", | |
| 11161 | + ), | |
| 11162 | + "prod_v" => ( | |
| 11163 | + "128+60*sin((X*Y+N*97)/13)+50*sin((Y+N*11)/5)".to_string(), | |
| 11164 | + ",noise=alls=25:allf=t:all_seed=11", | |
| 11165 | + ), | |
| 11166 | + _ => ( | |
| 11167 | + "128+60*sin((X*Y+N*97)/13)+50*sin((X+N*11)/5)".to_string(), | |
| 11168 | + ",noise=alls=25:allf=t:all_seed=11", | |
| 11169 | + ), | |
| 11170 | + }; | |
| 11171 | + let source = format!( | |
| 11172 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | |
| 11173 | + geq=lum='{lum}',format=yuv420p{noise}" | |
| 11174 | + ); | |
| 11175 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | |
| 11176 | + let y4m = Command::new("ffmpeg") | |
| 11177 | + .args([ | |
| 11178 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | |
| 11179 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | |
| 11180 | + ]) | |
| 11181 | + .stdin(Stdio::null()) | |
| 11182 | + .stdout(Stdio::piped()) | |
| 11183 | + .stderr(Stdio::piped()) | |
| 11184 | + .output() | |
| 11185 | + .expect("ffmpeg failed to run"); | |
| 11186 | + assert!( | |
| 11187 | + y4m.status.success(), | |
| 11188 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | |
| 11189 | + String::from_utf8_lossy(&y4m.stderr) | |
| 11190 | + ); | |
| 11191 | + let cq_arg = format!("--cq-level={cq}"); | |
| 11192 | + let min_part_arg = format!("--min-partition-size={min_part}"); | |
| 11193 | + let depth_arg = format!("--bit-depth={bit_depth}"); | |
| 11194 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | |
| 11195 | + let args: Vec<&str> = vec![ | |
| 11196 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", | |
| 11197 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | |
| 11198 | + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", | |
| 11199 | + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", | |
| 11200 | + "--lag-in-frames=0", "--kf-max-dist=9999", "--tile-columns=0", | |
| 11201 | + // Per-arm overrides go LAST (aomenc keeps the last | |
| 11202 | + // occurrence of a repeated --enable-* flag). | |
| 11203 | + "--enable-tx-size-search=1", "--enable-rect-partitions=1", | |
| 11204 | + "--enable-ab-partitions=1", "--enable-1to4-partitions=1", | |
| 11205 | + "--enable-intra-edge-filter=1", | |
| 11206 | + &min_part_arg, "--max-partition-size=16", | |
| 11207 | + "--obu", "-o", "-", "-", | |
| 11208 | + ]; | |
| 11209 | + let mut child = Command::new(aomenc_path()) | |
| 11210 | + .args(&args) | |
| 11211 | + .stdin(Stdio::piped()) | |
| 11212 | + .stdout(Stdio::piped()) | |
| 11213 | + .stderr(Stdio::piped()) | |
| 11214 | + .spawn() | |
| 11215 | + .expect("aomenc failed to start"); | |
| 11216 | + child | |
| 11217 | + .stdin | |
| 11218 | + .take() | |
| 11219 | + .expect("aomenc stdin") | |
| 11220 | + .write_all(&y4m.stdout) | |
| 11221 | + .expect("writing y4m to aomenc"); | |
| 11222 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 11223 | + assert!( | |
| 11224 | + out.status.success(), | |
| 11225 | + "aomenc refused the fixture: {}", | |
| 11226 | + String::from_utf8_lossy(&out.stderr) | |
| 11227 | + ); | |
| 11228 | + let stream = out.stdout; | |
| 11229 | + let before = crate::stream::intra16x4_in_inter_hits(); | |
| 11230 | + let frames = match decode_stream(&stream) { | |
| 11231 | + Err(e) => { | |
| 11232 | + let msg = e.to_string(); | |
| 11233 | + // lane-intra16x4 r3: the ONLY refusals the 120-run sweep | |
| 11234 | + // (`~/.cache/intra16x4-tmp/sweep_r3.sh`, table in the | |
| 11235 | + // report) reaches over these recipes -- each another | |
| 11236 | + // lane's shape. A refusal outside this list is a new wall | |
| 11237 | + // and fails the gate rather than being counted. | |
| 11238 | + const MEASURED_REFUSALS: [&str; 3] = [ | |
| 11239 | + "an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition", | |
| 11240 | + "an intra 4x4 block inside an inter frame's sub-8x8 split", | |
| 11241 | + "an OBMC neighbour whose switchable interp filter was never recorded", | |
| 11242 | + ]; | |
| 11243 | + if !MEASURED_REFUSALS.iter().any(|r| msg.contains(r)) { | |
| 11244 | + failures.push(format!( | |
| 11245 | + "{bit_depth}-bit attempt {attempt}: refusal outside the measured \ | |
| 11246 | + list: {msg}" | |
| 11247 | + )); | |
| 11248 | + continue; | |
| 11249 | + } | |
| 11250 | + if msg.contains("sub-8x8") { | |
| 11251 | + sub8_intra_refusals += 1; | |
| 11252 | + } | |
| 11253 | + named_refusals += 1; | |
| 11254 | + eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); | |
| 11255 | + continue; | |
| 11256 | + } | |
| 11257 | + Ok(frames) => frames, | |
| 11258 | + }; | |
| 11259 | + decoded_per_depth[depth_idx] += 1; | |
| 11260 | + let after = crate::stream::intra16x4_in_inter_hits(); | |
| 11261 | + let fired = [ | |
| 11262 | + (after.0 - before.0) as u32, | |
| 11263 | + (after.1 - before.1) as u32, | |
| 11264 | + (after.2 - before.2) as u32, | |
| 11265 | + ]; | |
| 11266 | + let ffmpeg_frames = if bit_depth == 10 { | |
| 11267 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | |
| 11268 | + } else { | |
| 11269 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | |
| 11270 | + }; | |
| 11271 | + assert_eq!(frames.len(), frame_count); | |
| 11272 | + let mismatched = frames | |
| 11273 | + .iter() | |
| 11274 | + .zip(&ffmpeg_frames) | |
| 11275 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | |
| 11276 | + if fired[0] + fired[1] == 0 { | |
| 11277 | + out_of_scope += 1; | |
| 11278 | + if mismatched { | |
| 11279 | + oos_mismatch += 1; | |
| 11280 | + eprintln!( | |
| 11281 | + "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \ | |
| 11282 | + intra 1:4 strip -- another shape's defect" | |
| 11283 | + ); | |
| 11284 | + } | |
| 11285 | + continue; | |
| 11286 | + } | |
| 11287 | + if mismatched { | |
| 11288 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 11289 | + let bad: Vec<usize> = | |
| 11290 | + (0..got.y.len()).filter(|&k| got.y[k] != want.y[k]).collect(); | |
| 11291 | + if !bad.is_empty() { | |
| 11292 | + eprintln!( | |
| 11293 | + "{NAME}: attempt {attempt} {bit_depth}-bit frame {i}: {} luma \ | |
| 11294 | + pixels differ, first at ({}, {}), max |delta| {}", | |
| 11295 | + bad.len(), | |
| 11296 | + bad[0] % width, | |
| 11297 | + bad[0] / width, | |
| 11298 | + bad.iter() | |
| 11299 | + .map(|&k| (got.y[k] as i32 - want.y[k] as i32).abs()) | |
| 11300 | + .max() | |
| 11301 | + .unwrap_or(0) | |
| 11302 | + ); | |
| 11303 | + } | |
| 11304 | + } | |
| 11305 | + } | |
| 11306 | + // lane-intra16x4 r3: continue-and-sweep -- a mismatching attempt is | |
| 11307 | + // RECORDED and the sweep goes on, so one arm's defect can no longer | |
| 11308 | + // hide every later arm (r2's attempt 0 panicked before arm 4 ran). | |
| 11309 | + // The end-of-sweep assert below fails on any recorded mismatch. | |
| 11310 | + if mismatched { | |
| 11311 | + failures.push(format!( | |
| 11312 | + "{bit_depth}-bit attempt {attempt} (arms {fired:?}) mismatched ffmpeg" | |
| 11313 | + )); | |
| 11314 | + continue; | |
| 11315 | + } | |
| 11316 | + for a in 0..3 { | |
| 11317 | + if fired[a] > 0 { | |
| 11318 | + arms_proved[a] += 1; | |
| 11319 | + arms_total[a] += 1; | |
| 11320 | + } | |
| 11321 | + } | |
| 11322 | + matched += 1; | |
| 11323 | + fired_exact_per_depth[depth_idx] += 1; | |
| 11324 | + } | |
| 11325 | + eprintln!( | |
| 11326 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ | |
| 11327 | + attempts carrying an intra 1:4 strip, per-arm attempts \ | |
| 11328 | + 16x4/4x16/chroma-reference={arms_proved:?}, {out_of_scope} attempts carried none \ | |
| 11329 | + ({oos_mismatch} of them mismatched)" | |
| 11330 | + ); | |
| 11331 | + if oos_mismatch > 0 { | |
| 11332 | + failures.push(format!( | |
| 11333 | + "{bit_depth}-bit: {oos_mismatch} attempt(s) with no intra 1:4 strip decoded \ | |
| 11334 | + but mismatched ffmpeg -- another shape's defect, not a pass" | |
| 11335 | + )); | |
| 11336 | + } | |
| 11337 | + } | |
| 11338 | + assert!( | |
| 11339 | + failures.is_empty(), | |
| 11340 | + "{NAME}: {} sweep failure(s): {failures:#?}", | |
| 11341 | + failures.len() | |
| 11342 | + ); | |
| 11343 | + // The counter must have fired on a pixel-exact attempt at every bit depth | |
| 11344 | + // the sweep actually decoded at. | |
| 11345 | + for (depth_idx, bit_depth) in [8u32, 10u32].into_iter().enumerate() { | |
| 11346 | + assert!( | |
| 11347 | + decoded_per_depth[depth_idx] == 0 || fired_exact_per_depth[depth_idx] > 0, | |
| 11348 | + "{NAME}: {bit_depth}-bit decoded {} attempt(s) but none of them fired an intra \ | |
| 11349 | + 1:4 strip on a pixel-exact compare", | |
| 11350 | + decoded_per_depth[depth_idx] | |
| 11351 | + ); | |
| 11352 | + } | |
| 11353 | + // MEASURED (48-run sweep, report table): every recipe that makes | |
| 11354 | + // aomenc pick an intra PARTITION_VERT_4 strip ALSO contains an intra | |
| 11355 | + // 8x4/4x8 or 4x4 block inside a sub-8x8 partition, a refusal this lane | |
| 11356 | + // does not own -- so the 4x16 orientation is blocked on THAT and the | |
| 11357 | + // gate asserts exactly that. If the sub-8x8 lane lands and this arm | |
| 11358 | + // still reads 0, or the blocker changes, this fails. | |
| 11359 | + assert!( | |
| 11360 | + arms_total[1] > 0 || sub8_intra_refusals > 0, | |
| 11361 | + "{NAME}: the 4x16 (PARTITION_VERT_4) arm read 0 \ | |
| 11362 | + (16x4/4x16/chroma-reference={arms_total:?}) and NO attempt refused on the sub-8x8 \ | |
| 11363 | + intra block -- its documented blocker is gone, so a zero arm is now unexplained" | |
| 11364 | + ); | |
| 11365 | + for (a, what) in [ | |
| 11366 | + (0usize, "intra 16x4 strips (PARTITION_HORZ_4)"), | |
| 11367 | + (2, "chroma-reference (odd) intra strips carrying the pair's 8x4/4x8 chroma"), | |
| 11368 | + ] { | |
| 11369 | + assert!( | |
| 11370 | + arms_total[a] > 0, | |
| 11371 | + "{NAME}: arm {a} ({what}) never fired on a pixel-exact attempt \ | |
| 11372 | + (16x4/4x16/chroma-reference={arms_total:?}) -- unproven" | |
| 11373 | + ); | |
| 11374 | + } | |
| 11375 | + } | |
| 11376 | + | |
| 11377 | + | |
| 11050 | 11378 | #[test] |
| 11051 | 11379 | // lane-sbab r1: the SUPERBLOCK-level (64x64) AB partitions on an INTER |
| 11052 | 11380 | // frame -- PARTITION_HORZ_A/_HORZ_B/_VERT_A/_VERT_B at 64x64, i.e. two |
| @@ -29587,8 +29915,11 @@ mod tests { | ||
| 29587 | 29915 | /// here)". The moment TX_64X32/TX_32X64 luma coefficient tables land, drop |
| 29588 | 29916 | /// the `#[ignore]` -- everything else this gate needs (the reader, the |
| 29589 | 29917 | /// counter, the two-frame pixel compare) is in place and runs. |
| 29918 | + /// | |
| 29919 | + /// lane-sub8x4 r3: un-`#[ignore]`d. The sibling refusal it waited on (the | |
| 29920 | + /// un-split TX_64X32/TX_32X64 corner unit) is lifted in this round, so the | |
| 29921 | + /// frame this gate exists for now finishes. | |
| 29590 | 29922 | #[test] |
| 29591 | - #[ignore = "blocked on a SIBLING refusal, not on this lane: the film frame that carries the intra 1:4 strips (16x64=3) stops at \"a split intra strip whose transform unit is 64x32 (no luma coefficient tables for that shape here)\" -- un-ignore when the 64x32/32x64 luma coefficient tables land"] | |
| 29592 | 29923 | fn a_10bit_film_inter_frame_with_intra_1to4_strips_decodes_pixel_exact() { |
| 29593 | 29924 | const NAME: &str = "a_10bit_film_inter_frame_with_intra_1to4_strips_decodes_pixel_exact"; |
| 29594 | 29925 | if !have_ffmpeg() { |
| @@ -29616,15 +29947,345 @@ mod tests { | ||
| 29616 | 29947 | now.2 - before.2, |
| 29617 | 29948 | now.3 - before.3 |
| 29618 | 29949 | ); |
| 29619 | - assert_eq!(frames.len(), 2, "{NAME}: key frame + one inter frame"); | |
| 29950 | + // lane-sub8x4 r3, MEASURED when this gate first RAN: the fixture has | |
| 29951 | + // TWO frame OBUs but only ONE SHOWN frame -- a raw | |
| 29952 | + // `ffmpeg -i <fixture> -pix_fmt yuv420p10le -f rawvideo` writes exactly | |
| 29953 | + // 18524160 bytes, one 3840x1608 10-bit frame, so the second is a | |
| 29954 | + // no-show frame and `frames.len() == 2` was never true. The compare is | |
| 29955 | + // not vacuous: ffmpeg's own frame count is asserted equal to ours. | |
| 29956 | + assert_eq!(frames.len(), 1, "{NAME}: one shown frame (the second frame OBU is a no-show)"); | |
| 29620 | 29957 | assert_eq!((frames[0].width, frames[0].height), (width, height)); |
| 29621 | 29958 | let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()); |
| 29959 | + assert_eq!( | |
| 29960 | + ffmpeg_frames.len(), | |
| 29961 | + frames.len(), | |
| 29962 | + "{NAME}: ffmpeg returned {} frames, we decoded {}", | |
| 29963 | + ffmpeg_frames.len(), | |
| 29964 | + frames.len() | |
| 29965 | + ); | |
| 29966 | + for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 29967 | + assert_eq!(ours.y, theirs.y, "{NAME}: frame {i} luma vs ffmpeg"); | |
| 29968 | + assert_eq!(ours.u, theirs.u, "{NAME}: frame {i} U vs ffmpeg"); | |
| 29969 | + assert_eq!(ours.v, theirs.v, "{NAME}: frame {i} V vs ffmpeg"); | |
| 29970 | + } | |
| 29971 | + eprintln!("{NAME}: {fired} intra 1:4 strips in an inter frame, the shown frame pixel-exact"); | |
| 29972 | + } | |
| 29973 | + | |
| 29974 | + /// lane-sub8x4 r3: the FILM witness that lifts BOTH the intra 16x4/4x16 | |
| 29975 | + /// strip inside an inter 16x16-level 1:4 partition and the un-split | |
| 29976 | + /// TX_64X32/TX_32X64 corner unit of a split intra strip. | |
| 29977 | + /// | |
| 29978 | + /// `crates/ec-av1/fixtures/reelb_rect64_intra16x4_witness.obu`, 23472 bytes, | |
| 29979 | + /// sha256 `c9e721088766163b9dbeb9fa8dd8b257ff0ec7f9157fc350de4d3c33cd9ec4e4`: | |
| 29980 | + /// the first 50 frame-carrying OBUs of `ffmpeg -ss 0 -t 2 -i <3840x1608 | |
| 29981 | + /// 10-bit AV1 HDR10 mkv> -c:v copy -f obu`, cut twice from independent | |
| 29982 | + /// ffmpeg runs that hashed identically. 33 decode-order frames. | |
| 29983 | + /// | |
| 29984 | + /// MEASURED, and why no earlier round had this: r1/r2 of two lanes | |
| 29985 | + /// reported "no firing witness exists" because every film frame that fires | |
| 29986 | + /// these two arms ALSO carries a sub-8x8 intra leaf, which refused until | |
| 29987 | + /// this lane's r2 lifted it. On that tip the whole 33-frame prefix decodes | |
| 29988 | + /// with no refusal and matches ffmpeg on every plane of every frame, while | |
| 29989 | + /// both arms fire: `intra16x4_in_inter` 16x4=31 4x16=17 chroma_ref=23 and | |
| 29990 | + /// `rect64_corner_tu` 64x32=90 32x64=5. (The full 48-frame 2 s segment | |
| 29991 | + /// diverges at decode-order frame 36, which is a separate wall; the | |
| 29992 | + /// fixture is the exact prefix, not a truncation chosen to hide it.) | |
| 29993 | + /// | |
| 29994 | + /// Both refusal strings stay in `refusal_inventory` because both are | |
| 29995 | + /// NARROWED, not deleted: "a split intra strip whose transform unit is | |
| 29996 | + /// {tx_w}x{tx_h}" still stands for every shape other than 64x32/32x64, and | |
| 29997 | + /// "an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition" | |
| 29998 | + /// still stands for a strip with no chroma-pair record. | |
| 29999 | + #[test] | |
| 30000 | + fn a_10bit_film_frames_with_intra_16x4_strips_and_rect64_corner_tus_decode_pixel_exact() { | |
| 30001 | + const NAME: &str = | |
| 30002 | + "a_10bit_film_frames_with_intra_16x4_strips_and_rect64_corner_tus_decode_pixel_exact"; | |
| 30003 | + if !have_ffmpeg() { | |
| 30004 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 30005 | + return; | |
| 30006 | + } | |
| 30007 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | |
| 30008 | + .join("fixtures/reelb_rect64_intra16x4_witness.obu"); | |
| 30009 | + let stream = std::fs::read(&path) | |
| 30010 | + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); | |
| 30011 | + let (width, height) = (3840usize, 1608usize); | |
| 30012 | + let before16 = crate::decode::intra16x4_in_inter_hits(); | |
| 30013 | + let before64 = ( | |
| 30014 | + crate::decode::rect64_corner_tu_hits(0), | |
| 30015 | + crate::decode::rect64_corner_tu_hits(1), | |
| 30016 | + ); | |
| 30017 | + let frames = match decode_stream(&stream) { | |
| 30018 | + Ok(frames) => frames, | |
| 30019 | + Err(e) => panic!("{NAME}: decode_stream refused: {e}"), | |
| 30020 | + }; | |
| 30021 | + let now16 = crate::decode::intra16x4_in_inter_hits(); | |
| 30022 | + let fired16 = ( | |
| 30023 | + now16.0 - before16.0, | |
| 30024 | + now16.1 - before16.1, | |
| 30025 | + now16.2 - before16.2, | |
| 30026 | + ); | |
| 30027 | + let fired64 = ( | |
| 30028 | + crate::decode::rect64_corner_tu_hits(0) - before64.0, | |
| 30029 | + crate::decode::rect64_corner_tu_hits(1) - before64.1, | |
| 30030 | + ); | |
| 30031 | + // Hard counter asserts: neither lift may rest on a stream that stopped | |
| 30032 | + // carrying its shape (class `tool-disabled-in-every-gate`). | |
| 30033 | + assert!( | |
| 30034 | + fired16.0 > 0 && fired16.1 > 0 && fired16.2 > 0, | |
| 30035 | + "{NAME}: the intra 16x4/4x16 strip arm did not fire (16x4={} 4x16={} chroma_ref={})", | |
| 30036 | + fired16.0, | |
| 30037 | + fired16.1, | |
| 30038 | + fired16.2 | |
| 30039 | + ); | |
| 30040 | + assert!( | |
| 30041 | + fired64.0 > 0 && fired64.1 > 0, | |
| 30042 | + "{NAME}: the un-split TX_64X32/TX_32X64 corner arm did not fire (64x32={} 32x64={})", | |
| 30043 | + fired64.0, | |
| 30044 | + fired64.1 | |
| 30045 | + ); | |
| 30046 | + assert_eq!(frames.len(), 33, "{NAME}: 33 decode-order frames"); | |
| 30047 | + assert_eq!((frames[0].width, frames[0].height), (width, height)); | |
| 30048 | + let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()); | |
| 30049 | + assert_eq!( | |
| 30050 | + ffmpeg_frames.len(), | |
| 30051 | + frames.len(), | |
| 30052 | + "{NAME}: ffmpeg returned {} frames, we decoded {}", | |
| 30053 | + ffmpeg_frames.len(), | |
| 30054 | + frames.len() | |
| 30055 | + ); | |
| 29622 | 30056 | for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 29623 | 30057 | assert_eq!(ours.y, theirs.y, "{NAME}: frame {i} luma vs ffmpeg"); |
| 29624 | 30058 | assert_eq!(ours.u, theirs.u, "{NAME}: frame {i} U vs ffmpeg"); |
| 29625 | 30059 | assert_eq!(ours.v, theirs.v, "{NAME}: frame {i} V vs ffmpeg"); |
| 29626 | 30060 | } |
| 29627 | - eprintln!("{NAME}: {fired} intra 1:4 strips in an inter frame, both frames pixel-exact"); | |
| 30061 | + eprintln!( | |
| 30062 | + "{NAME}: 33 frames pixel-exact, intra16x4_in_inter 16x4={} 4x16={} chroma_ref={}, \ | |
| 30063 | + rect64_corner_tu 64x32={} 32x64={}", | |
| 30064 | + fired16.0, fired16.1, fired16.2, fired64.0, fired64.1 | |
| 30065 | + ); | |
| 30066 | + } | |
| 30067 | + | |
| 30068 | + | |
| 30069 | + /// lane-sub8x4 r2, the gate that lifts BOTH sub-8x8 intra refusals ("an | |
| 30070 | + /// intra 4x4 block inside an inter frame's sub-8x8 split" and "an intra | |
| 30071 | + /// 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition"). | |
| 30072 | + /// | |
| 30073 | + /// Recipe (measured, `~/.cache/sub8intra-tmp/sweep3.sh`): a 24-row band of | |
| 30074 | + /// per-frame-moving noise over a smooth sinusoid, `--min-partition-size=4 | |
| 30075 | + /// --max-partition-size=8 --enable-1to4-partitions=0` -- at that maximum a | |
| 30076 | + /// 16x4 shape cannot exist, so nothing here can be confused with the | |
| 30077 | + /// still-refused intra 1:4 strip, and the noise band is what makes aomenc's | |
| 30078 | + /// RD pick INTRA leaves inside an inter frame's 8x8 groups. 12 arms | |
| 30079 | + /// (8/10-bit x cq 48/55/63 x 128x128/192x128) plus one `--tile-columns=1` | |
| 30080 | + /// arm (COMMON's neighbour-map rule: these leaves publish per-mi side | |
| 30081 | + /// bands), 6 frames each, every decode-order frame and all three planes | |
| 30082 | + /// compared against ffmpeg. Continue-and-sweep: a NAMED refusal is | |
| 30083 | + /// recorded and the arm skipped, any other decode error or any pixel | |
| 30084 | + /// mismatch fails the gate on the spot. | |
| 30085 | + /// | |
| 30086 | + /// The end-of-sweep assert reads all five | |
| 30087 | + /// [`decode::sub8_intra_rect_hits`] cells -- 8x4 leaves, 4x8 leaves, the | |
| 30088 | + /// chroma-reference ones (which code the group's 4x4 chroma intra), | |
| 30089 | + /// `is_sub8x8_inter`-false MIXED groups, and the `PARTITION_SPLIT` 4x4 | |
| 30090 | + /// leaves (the second refusal's own arm) -- so neither lifted refusal | |
| 30091 | + /// rests on a stream that never carried its shape. | |
| 30092 | + #[test] | |
| 30093 | + fn a_real_aomenc_inter_sequence_with_intra_sub8x8_leaves_decodes_pixel_exact() { | |
| 30094 | + const NAME: &str = "a_real_aomenc_inter_sequence_with_intra_sub8x8_leaves_decodes_pixel_exact"; | |
| 30095 | + if !have_ffmpeg() { | |
| 30096 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 30097 | + return; | |
| 30098 | + } | |
| 30099 | + if !have_aomenc() { | |
| 30100 | + let msg = format!("no aomenc at {}", aomenc_path().display()); | |
| 30101 | + assert!( | |
| 30102 | + std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none(), | |
| 30103 | + "EC_AV1_REQUIRE_AOMENC is set but {msg}" | |
| 30104 | + ); | |
| 30105 | + eprintln!("SKIP {NAME}: {msg}"); | |
| 30106 | + return; | |
| 30107 | + } | |
| 30108 | + const FRAMES: usize = 6; | |
| 30109 | + // One arm's stream, byte for byte: the lavfi source (a moving 24-row | |
| 30110 | + // random band over `128+50*sin(x/7)`) feeds aomenc through a pipe. | |
| 30111 | + let encode = |depth: u32, cq: u32, width: usize, height: usize, tiles: bool| -> Vec<u8> { | |
| 30112 | + let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; | |
| 30113 | + let source = format!( | |
| 30114 | + "color=c=gray:s={width}x{height}:d=0.24:r=25,format=gray,\ | |
| 30115 | + geq=lum='if(lt(mod(Y+N*37\\,{height})\\,24)\\,random(N*100+X+Y)*255\\,128+50*sin(X/7))',\ | |
| 30116 | + format={pix}" | |
| 30117 | + ); | |
| 30118 | + let y4m = Command::new("ffmpeg") | |
| 30119 | + .args([ | |
| 30120 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", "0.24", "-pix_fmt", pix, | |
| 30121 | + "-strict", "-1", "-f", "yuv4mpegpipe", "-", | |
| 30122 | + ]) | |
| 30123 | + .stdin(Stdio::null()) | |
| 30124 | + .stdout(Stdio::piped()) | |
| 30125 | + .stderr(Stdio::piped()) | |
| 30126 | + .output() | |
| 30127 | + .expect("ffmpeg failed to run"); | |
| 30128 | + assert!( | |
| 30129 | + y4m.status.success(), | |
| 30130 | + "{NAME}: ffmpeg fixture (depth={depth} cq={cq} {width}x{height}): {}", | |
| 30131 | + String::from_utf8_lossy(&y4m.stderr) | |
| 30132 | + ); | |
| 30133 | + let cq_arg = format!("--cq-level={cq}"); | |
| 30134 | + let mut args: Vec<&str> = vec![ | |
| 30135 | + "--codec=av1", | |
| 30136 | + "--passes=1", | |
| 30137 | + "--end-usage=q", | |
| 30138 | + &cq_arg, | |
| 30139 | + "--cpu-used=0", | |
| 30140 | + "--threads=1", | |
| 30141 | + "--row-mt=0", | |
| 30142 | + "--sb-size=64", | |
| 30143 | + "--enable-restoration=0", | |
| 30144 | + "--enable-palette=0", | |
| 30145 | + "--deltaq-mode=0", | |
| 30146 | + "--enable-intrabc=0", | |
| 30147 | + "--lag-in-frames=0", | |
| 30148 | + "--kf-max-dist=9999", | |
| 30149 | + "--enable-tx-size-search=1", | |
| 30150 | + "--enable-rect-partitions=1", | |
| 30151 | + // The 16x4/4x16 intra strip is a DIFFERENT (still refused) | |
| 30152 | + // shape; keeping 1:4 off is what makes a refusal here mean | |
| 30153 | + // this gate's own arm. | |
| 30154 | + "--enable-1to4-partitions=0", | |
| 30155 | + "--min-partition-size=4", | |
| 30156 | + "--max-partition-size=8", | |
| 30157 | + ]; | |
| 30158 | + if depth == 10 { | |
| 30159 | + args.push("--bit-depth=10"); | |
| 30160 | + args.push("--input-bit-depth=10"); | |
| 30161 | + } | |
| 30162 | + // AOMENC FLAG PRECEDENCE (COMMON): the per-arm override goes last. | |
| 30163 | + args.push(if tiles { "--tile-columns=1" } else { "--tile-columns=0" }); | |
| 30164 | + args.extend(["--obu", "-o", "-", "-"]); | |
| 30165 | + let mut child = Command::new(aomenc_path()) | |
| 30166 | + .args(&args) | |
| 30167 | + .stdin(Stdio::piped()) | |
| 30168 | + .stdout(Stdio::piped()) | |
| 30169 | + .stderr(Stdio::piped()) | |
| 30170 | + .spawn() | |
| 30171 | + .expect("aomenc failed to start"); | |
| 30172 | + child | |
| 30173 | + .stdin | |
| 30174 | + .take() | |
| 30175 | + .expect("aomenc stdin") | |
| 30176 | + .write_all(&y4m.stdout) | |
| 30177 | + .expect("writing y4m to aomenc"); | |
| 30178 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 30179 | + assert!( | |
| 30180 | + out.status.success(), | |
| 30181 | + "{NAME}: aomenc refused the fixture (depth={depth} cq={cq} {width}x{height}): {}", | |
| 30182 | + String::from_utf8_lossy(&out.stderr) | |
| 30183 | + ); | |
| 30184 | + out.stdout | |
| 30185 | + }; | |
| 30186 | + | |
| 30187 | + let mut refusals: Vec<String> = Vec::new(); | |
| 30188 | + let mut exact_arms = 0u32; | |
| 30189 | + let mut fired = [0usize; 5]; | |
| 30190 | + let mut checked_reproducible = false; | |
| 30191 | + let mut arms: Vec<(u32, u32, usize, usize, bool)> = Vec::new(); | |
| 30192 | + for depth in [8u32, 10] { | |
| 30193 | + for cq in [48u32, 55, 63] { | |
| 30194 | + for (w, h) in [(128usize, 128usize), (192usize, 128usize)] { | |
| 30195 | + arms.push((depth, cq, w, h, false)); | |
| 30196 | + } | |
| 30197 | + } | |
| 30198 | + } | |
| 30199 | + // lane-sub8x4 r3: the `--tile-columns=1` arm COMMON's neighbour-map | |
| 30200 | + // rule asks for. It was excluded in r2 because it desynced at | |
| 30201 | + // decode-order frame 4 -- identically with `--min-partition-size=16 | |
| 30202 | + // --max-partition-size=16`, i.e. with no sub-8x8 block at all. That was | |
| 30203 | + // main's `1d2259c` (the saved motion field kept only the LAST tile's | |
| 30204 | + // columns), merged into this lane in r3; the arm is restored here. | |
| 30205 | + arms.push((8, 63, 192, 128, true)); | |
| 30206 | + for (depth, cq, width, height, tiles) in arms { | |
| 30207 | + let arm = format!("depth={depth} cq={cq} {width}x{height} tiles={tiles}"); | |
| 30208 | + let stream = encode(depth, cq, width, height, tiles); | |
| 30209 | + if !checked_reproducible { | |
| 30210 | + // seeded-fixture-not-reproducible: prove the recipe names ONE | |
| 30211 | + // stream before any measurement rests on it. | |
| 30212 | + let again = encode(depth, cq, width, height, tiles); | |
| 30213 | + assert_eq!( | |
| 30214 | + stream, again, | |
| 30215 | + "{NAME}: the fixture recipe is not reproducible ({arm}, {} vs {} bytes)", | |
| 30216 | + stream.len(), | |
| 30217 | + again.len() | |
| 30218 | + ); | |
| 30219 | + checked_reproducible = true; | |
| 30220 | + } | |
| 30221 | + let before = decode::sub8_intra_rect_hits(); | |
| 30222 | + let tiles_before = decode::tile_hits(); | |
| 30223 | + let frames = match decode_stream(&stream) { | |
| 30224 | + Ok(frames) => frames, | |
| 30225 | + Err(e) => { | |
| 30226 | + let msg = e.to_string(); | |
| 30227 | + assert!( | |
| 30228 | + msg.starts_with("unsupported: "), | |
| 30229 | + "{NAME}: decode error that is not a named refusal ({arm}): {msg}" | |
| 30230 | + ); | |
| 30231 | + refusals.push(format!("{arm}: {msg}")); | |
| 30232 | + continue; | |
| 30233 | + } | |
| 30234 | + }; | |
| 30235 | + assert_eq!(frames.len(), FRAMES, "{NAME}: {arm} decoded {} frames", frames.len()); | |
| 30236 | + assert!( | |
| 30237 | + !tiles || decode::tile_hits() - tiles_before >= 2, | |
| 30238 | + "{NAME}: {arm} decoded only {} tile(s)", | |
| 30239 | + decode::tile_hits() - tiles_before | |
| 30240 | + ); | |
| 30241 | + let theirs = if depth == 10 { | |
| 30242 | + ffmpeg_decode_sequence_10bit(&stream, width, height, FRAMES) | |
| 30243 | + } else { | |
| 30244 | + ffmpeg_decode_sequence(&stream, width, height, FRAMES) | |
| 30245 | + }; | |
| 30246 | + for (i, (ours, theirs)) in frames.iter().zip(&theirs).enumerate() { | |
| 30247 | + assert_eq!(ours.y, theirs.y, "{NAME}: {arm} frame {i} luma vs ffmpeg"); | |
| 30248 | + assert_eq!(ours.u, theirs.u, "{NAME}: {arm} frame {i} U vs ffmpeg"); | |
| 30249 | + assert_eq!(ours.v, theirs.v, "{NAME}: {arm} frame {i} V vs ffmpeg"); | |
| 30250 | + } | |
| 30251 | + let now = decode::sub8_intra_rect_hits(); | |
| 30252 | + let delta = [ | |
| 30253 | + now.0 - before.0, | |
| 30254 | + now.1 - before.1, | |
| 30255 | + now.2 - before.2, | |
| 30256 | + now.3 - before.3, | |
| 30257 | + now.4 - before.4, | |
| 30258 | + ]; | |
| 30259 | + exact_arms += 1; | |
| 30260 | + for (slot, d) in fired.iter_mut().zip(delta) { | |
| 30261 | + *slot += d; | |
| 30262 | + } | |
| 30263 | + eprintln!( | |
| 30264 | + "{NAME}: {arm} EXACT 8x4={} 4x8={} chroma_ref={} mixed={} split4x4={}", | |
| 30265 | + delta[0], delta[1], delta[2], delta[3], delta[4] | |
| 30266 | + ); | |
| 30267 | + } | |
| 30268 | + assert!( | |
| 30269 | + exact_arms >= 12, | |
| 30270 | + "{NAME}: only {exact_arms} arm(s) decoded and compared exact; refusals:\n{}", | |
| 30271 | + refusals.join("\n") | |
| 30272 | + ); | |
| 30273 | + for (cell, what) in fired.iter().zip([ | |
| 30274 | + "intra 8x4 leaves", | |
| 30275 | + "intra 4x8 leaves", | |
| 30276 | + "chroma-reference intra leaves", | |
| 30277 | + "is_sub8x8_inter-false MIXED groups", | |
| 30278 | + "intra 4x4 leaves of a sub-8x8 PARTITION_SPLIT", | |
| 30279 | + ]) { | |
| 30280 | + assert!( | |
| 30281 | + *cell > 0, | |
| 30282 | + "{NAME}: zero {what} over {exact_arms} pixel-exact arms -- the lifted refusal \ | |
| 30283 | + rests on nothing (counters {fired:?})" | |
| 30284 | + ); | |
| 30285 | + } | |
| 30286 | + eprintln!( | |
| 30287 | + "{NAME}: {exact_arms} arms pixel-exact over {FRAMES} frames each, counters {fired:?}" | |
| 30288 | + ); | |
| 29628 | 30289 | } |
| 29629 | 30290 | |
| 29630 | 30291 | } |
lanes/intra16x4-r1.handoff.mdadded+72 -0
| @@ -0,0 +1,72 @@ | ||
| 1 | +# lane-intra16x4 r1 HANDOFF (tip 17462bc + this file) | |
| 2 | + | |
| 3 | +Env bypass name is **`EC_INTRA16X4_DECODE=1`** (decode path) and `EC_INTRA16X4=1` (traces | |
| 4 | +only) — the coordinator's message says `EC_INTRA16X4`; the decode switch is the `_DECODE` | |
| 5 | +one. Default behaviour without it: the original refusal, unchanged. | |
| 6 | + | |
| 7 | +## Step 1 measurement (env print at the refusal site, `EC_INTRA16X4=1`, `EC_RECT64_SPLIT=1`) | |
| 8 | + | |
| 9 | +| probe | shape | pair parity | has_chroma | prev strip single-ref inter | skip | tx_select | | |
| 10 | +|---|---|---|---|---|---|---| | |
| 11 | +| 10-bit 3840x1608 cut 0 | 16x4 | 0 (even) | false | – | 0 | 1 | | |
| 12 | +| 10-bit 3840x1608 cut 300 | 4x16 | 0 | false | – | 0 | 1 | | |
| 13 | +| 10-bit 1920x792 @900 | 4x16 | 0 | false | – | 0 | 1 | | |
| 14 | +| 10-bit 1920x792 @5400 | 16x4 | 0 | false | – | 0 | 1 | | |
| 15 | +| 10-bit 1920x792 @6300 | 16x4 | 0 | false | – | 0 | 1 | | |
| 16 | +| 10-bit 1920x792 @8100 | 4x16 | 0 | false | – | 0 | 1 | | |
| 17 | + | |
| 18 | +6/6 fire first on an EVEN strip (`is_chroma_reference` false: no `uv_mode`, no chroma | |
| 19 | +residual), non-skip, `--enable-tx-size-search` on, no screen-content tools. | |
| 20 | + | |
| 21 | +## What the path implements (all in crates/ec-av1/src/decode.rs) | |
| 22 | + | |
| 23 | +* `decode_rect4_16_strip` — the per-strip body of the key frame's `decode_rect4_16`, | |
| 24 | + lifted verbatim (mode info, luma whole-TU or split walk, the pair's single 8x4/4x8 | |
| 25 | + chroma on the ODD strip at the pair's origin, palette/skip/lf/partition bands). | |
| 26 | + `decode_rect4_16` now calls it 4x — key-frame behaviour unchanged. | |
| 27 | +* `decode_intra_rect_in_inter(.., strip16: Option<(horz, has_chroma)>, ..)` — new 16x4/ | |
| 28 | + 4x16 arm running that body with `INTRA_IN_INTER_MODE = Some((0, skip))` | |
| 29 | + (`size_group_lookup[BLOCK_16X4] == 0`, oracle `common_data.h:61`). Mixed intra/inter | |
| 30 | + pairs need no new chroma code: the odd strip carries the pair's chroma predicted per | |
| 31 | + its own type, and the inter side's `InterStripChroma::prev == None` arm already covers | |
| 32 | + intra-then-inter. | |
| 33 | +* The inter arm ALSO publishes `set_txfm_ctxs` (`above_txfm`/`left_txfm` = tx_w/tx_h) and | |
| 34 | + `txfm_partition_update_rect`, and reads tx-depth from `tx_size_context_txfm_rect`. | |
| 35 | + The key-frame body publishes none of that; without it the block AFTER the strip broke | |
| 36 | + while the strip's own pixels were exact (128x128 8-bit: strips at mi(23,16)/(23,20) | |
| 37 | + exact, damage from row 96, chroma exact). | |
| 38 | +* Counter `intra16x4_in_inter_hits()` `[16x4, 4x16, chroma-reference]`, printed by | |
| 39 | + `decode_probe`. | |
| 40 | + | |
| 41 | +## Pixel state under the bypass | |
| 42 | + | |
| 43 | +* 10-bit 3840x1608 cut 0: no longer stops here — 14 intra 16x4 strips decoded, then | |
| 44 | + `an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition` | |
| 45 | + (another lane). Same new refusal on cuts 300 / @900 / @5400 / @6300; @8100 stops on | |
| 46 | + `an intra-coded 16x4/4x16 strip on the inter block path` — that is the `_` arm of | |
| 47 | + `decode_intra_rect_in_inter` reached by a CLIPPED (frame-edge) shape, not a 1:4 strip. | |
| 48 | + No pixel comparison is possible on any cut: every firing frame also carries the | |
| 49 | + sub-8x8 intra block, so no OBU prefix decodes clean (hg-0 prefixes 50 and 52 both | |
| 50 | + refuse inside the same frame). | |
| 51 | +* aomenc witness, 8-bit 192x128 cq60 "bar" recipe (`~/.cache/intra16x4-tmp/s5.obu`, | |
| 52 | + ref `ref5.yuv`, ours `ours5.yuv`): 6 frames decoded, frame 0 exact, **frame 1 LUMA | |
| 53 | + mismatches from (175, 0), 8400 px**; the two intra strips themselves (mi(1,40) and | |
| 54 | + mi(3,40) = px x160..175, y4..15) are exact and all chroma is exact. The first bad | |
| 55 | + pixel is in the EVEN (inter) strip ABOVE them. | |
| 56 | +* The gate `a_real_aomenc_inter_sequence_with_intra_16x4_strips_in_1to4_partitions_ | |
| 57 | + decodes_pixel_exact` (stream.rs) is written, red, and `#[ignore]`d with that | |
| 58 | + measurement in its reason string. No refusal lifted; refusal_inventory/gate_coverage | |
| 59 | + untouched. | |
| 60 | + | |
| 61 | +## Exact next step | |
| 62 | + | |
| 63 | +1. Reproduce with `~/.cache/intra16x4-tmp/s5.obu` (recipe in the report). Ladder the msac | |
| 64 | + RANGE (ours `EC_TRACE_COEFF` vs instrumented aomdec) across frame 1's superblock at | |
| 65 | + mi_col 40, mi_row 0..3 — decide first whether the (175,0) damage is entropy or | |
| 66 | + reconstruction; chroma being exact while luma is wrong argues reconstruction/deblock. | |
| 67 | +2. Prime suspects, in order: (a) the deblock grid the intra strip writes over the PAIR | |
| 68 | + (its `fill_lf_grid_rect` runs at strip granularity while the caller's tail also | |
| 69 | + records the block), (b) the mv/mi field the tail stamps (`is_inter: false, ref -1`) | |
| 70 | + over rows the EVEN inter strip owns, (c) `above_side_mi`/`left_side_mi` partition | |
| 71 | + context published twice (strip body + caller tail). | |
| 72 | +3. Only then re-run the gate; the 4x16 arm stays blocked on the sub-8x8 intra lane. |
lanes/intra16x4-r1.report.mdadded+110 -0
| @@ -0,0 +1,110 @@ | ||
| 1 | +# lane-intra16x4 r1 — an INTRA 16x4/4x16 strip inside an inter 16x16-level 1:4 partition | |
| 2 | + | |
| 3 | +## Step 1 MEASURE — what the six film probes actually stop on | |
| 4 | + | |
| 5 | +Env-gated print at the refusal site (`crates/ec-av1/src/decode.rs`, `EC_INTRA16X4=1`), | |
| 6 | +each probe under `systemd-run --scope -p MemoryMax=6G`, `EC_RECT64_SPLIT=1`: | |
| 7 | + | |
| 8 | +| probe | shape | pair parity | has_chroma | prev strip single-ref inter | skip | tx_select | screen tools | | |
| 9 | +|---|---|---|---|---|---|---|---| | |
| 10 | +| 10-bit 3840x1608 cut 0 | 16x4 | 0 (EVEN) | false | – | 0 | 1 | 0 | | |
| 11 | +| 10-bit 3840x1608 cut 300 | 4x16 | 0 | false | – | 0 | 1 | 0 | | |
| 12 | +| 10-bit 1920x792 @900 | 4x16 | 0 | false | – | 0 | 1 | 0 | | |
| 13 | +| 10-bit 1920x792 @5400 | 16x4 | 0 | false | – | 0 | 1 | 0 | | |
| 14 | +| 10-bit 1920x792 @6300 | 16x4 | 0 | false | – | 0 | 1 | 0 | | |
| 15 | +| 10-bit 1920x792 @8100 | 4x16 | 0 | false | – | 0 | 1 | 0 | | |
| 16 | + | |
| 17 | +6 of 6 first fire on an EVEN strip: `is_chroma_reference` false, so that strip reads no | |
| 18 | +`uv_mode` and codes no chroma at all. All non-skip, all with `--enable-tx-size-search` | |
| 19 | +on, none in a screen-content frame. | |
| 20 | + | |
| 21 | +EVIDENCE: shell probe, 6 streams | `EC_RECT64_SPLIT=1 EC_INTRA16X4=1 decode_probe <cut>` | 3x 16x4 + 3x 4x16, all pair-parity 0 / has_chroma=false / skip=0 | |
| 22 | + | |
| 23 | +## Step 2 IMPLEMENT | |
| 24 | + | |
| 25 | +* `decode.rs` `decode_rect4_16_strip` (new) — the per-strip body of the KEY FRAME's | |
| 26 | + `decode_rect4_16`, lifted verbatim into its own function (mode info, luma TU or split | |
| 27 | + walk, the pair's 8x4/4x8 chroma when `has_chroma`, palette bands, skip/lf/partition | |
| 28 | + bands). `decode_rect4_16` now calls it four times; no behaviour change on the key-frame | |
| 29 | + path (the whole suite is the check). | |
| 30 | +* `decode.rs` `decode_intra_rect_in_inter` — new `strip16: Option<(horz, has_chroma)>` | |
| 31 | + parameter and a 16x4/4x16 arm that runs that body with `INTRA_IN_INTER_MODE = Some((0, | |
| 32 | + skip))`: `size_group_lookup[BLOCK_16X4] == size_group_lookup[BLOCK_4X16] == 0` | |
| 33 | + (oracle `common_data.h:61`, indices 16/17), so the mode is `y_mode[0]` and `skip` is | |
| 34 | + the one `decode_inter_block` already read. Chroma needs NO new code: the lifted body | |
| 35 | + already codes one 8x4 (4x8) unit at the PAIR's origin on the odd strip only, which is | |
| 36 | + exactly "predicted per the carrying strip's own type" for a mixed intra/inter pair; | |
| 37 | + the inter side's `InterStripChroma::prev == None` arm already covers intra-then-inter. | |
| 38 | +* Same arm publishes what the key-frame body does not and an INTER frame needs | |
| 39 | + (`set_txfm_ctxs` + `txfm_partition_update`, libaom `decodeframe.c:1078`): the strip's | |
| 40 | + tx size into `above_txfm`/`left_txfm` and the var-tx partition context — the 2:1 | |
| 41 | + intra-in-inter strip already does this. On the inter path the tx-depth symbol also | |
| 42 | + reads `tx_size_context_txfm_rect` (the real TXFM_CONTEXT bands) instead of the key | |
| 43 | + frame's deblock-grid approximation. | |
| 44 | +* Counter `INTRA16X4_IN_INTER_HITS` `[16x4, 4x16, chroma-reference]`, | |
| 45 | + `stream::intra16x4_in_inter_hits()`, printed by `decode_probe` as `intra16x4_in_inter:`. | |
| 46 | + | |
| 47 | +**The path is behind `EC_INTRA16X4_DECODE=1`; the refusal is still the default.** It is | |
| 48 | +not pixel-proven (below), and a refusal is lifted only with a green gate. | |
| 49 | + | |
| 50 | +## Step 3 GATE — RED, and what it measured | |
| 51 | + | |
| 52 | +`a_real_aomenc_inter_sequence_with_intra_16x4_strips_in_1to4_partitions_decodes_pixel_exact` | |
| 53 | +(`stream.rs`, `#[ignore]`d with its own measurement in the reason string): real aomenc, | |
| 54 | +`--enable-1to4-partitions=1 --enable-intra-edge-filter=1 --min-partition-size=4 | |
| 55 | +--max-partition-size=16` (per-arm overrides last), 4 recipes x {8, 10} bit, every | |
| 56 | +decode-order frame Y/U/V vs ffmpeg, refusals counted never SKIPped, `oos_mismatch == 0`. | |
| 57 | + | |
| 58 | +Recipe search: 48 + 48 runs (`~/.cache/intra16x4-tmp/sweep.sh`, `sweep2.sh`, logs | |
| 59 | +`sweep.log`/`sweep2.log`/`sweep3.log`). aomenc picks an INTRA 1:4 strip on an inter frame | |
| 60 | +only at HIGH cq (>= 56) over content its MC cannot predict. Both gate sources hash | |
| 61 | +identically twice. | |
| 62 | + | |
| 63 | +RED, with the strips themselves exact: | |
| 64 | + | |
| 65 | +* 192x128 cq60 "bar" source, 8-bit, 4 intra 16x4 strips (2 chroma-reference): frame 0 | |
| 66 | + exact, frame 1 luma differs from (175, 0), 8400 px. The strips are at mi(1,40)/(3,40) | |
| 67 | + = px x 160..175, y 4..15 — the first differing pixel is at y=0, i.e. in the EVEN | |
| 68 | + (inter) strip ABOVE them, and chroma of the pair is exact. | |
| 69 | +* 128x128 cq60 "noise" source, 8-bit, 2 skipped intra 16x4 strips at px(80,112)/(80,120): | |
| 70 | + frame 1 differs from (122, 13) — 99 rows ABOVE the first strip, so that arm's mismatch | |
| 71 | + is not this shape at all (an unrelated defect this recipe exposes; the gate's | |
| 72 | + `oos_mismatch` cannot separate it because the stream does carry strips). | |
| 73 | +* The txfm-context publication above was found the same way and DID fix a first | |
| 74 | + measurement: before it, a 128x128 stream decoded its two intra strips at mi(23,16)/ | |
| 75 | + (23,20) exactly and broke on the very next 16x16 row (rows 96+, x>=62), chroma exact. | |
| 76 | + | |
| 77 | +EVIDENCE: /home/user/.cache/intra16x4-gate2.log + ~/.cache/intra16x4-tmp/{s4,s5}.obu | aomenc -> our decode -> ffmpeg raw compare, per frame | frame 1 first luma diff (175, 0) 8400 px with both intra strips' own pixels exact | |
| 78 | + | |
| 79 | +## Film frontier — before / after (with `EC_INTRA16X4_DECODE=1`) | |
| 80 | + | |
| 81 | +All six probes leave the 16x4/4x16 wall. Before: every one stopped on | |
| 82 | +`an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition ...`. | |
| 83 | +After (counters are strips decoded): | |
| 84 | + | |
| 85 | +| probe | new refusal | intra16x4_in_inter | | |
| 86 | +|---|---|---| | |
| 87 | +| hg cut 0 | an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition | 16x4=14 | | |
| 88 | +| hg cut 300 | same | 4x16=8 | | |
| 89 | +| 1920x792 @900 | same | 4x16=4 | | |
| 90 | +| 1920x792 @5400 | same | 16x4=1 4x16=2 | | |
| 91 | +| 1920x792 @6300 | same | 16x4=1 4x16=1 | | |
| 92 | +| 1920x792 @8100 | an intra-coded 16x4/4x16 strip on the inter block path (its `_` arm: a CLIPPED shape, not a 1:4 strip) | 4x16=4 | | |
| 93 | + | |
| 94 | +Since the walls are unproven pixel-wise, this is a REACH measurement, not a decode claim. | |
| 95 | + | |
| 96 | +EVIDENCE: 6 probes | `EC_RECT64_SPLIT=1 EC_INTRA16X4_DECODE=1 decode_probe <cut>` | refusal string moves to the sub-8x8 intra wall on 5 of 6, counters 1..14 strips each | |
| 97 | + | |
| 98 | +## Residue | |
| 99 | + | |
| 100 | +* fix-now (next round): the r1 gate is RED. The defect is NOT in the strip's own pixels | |
| 101 | + (they match) but in what the strip leaves behind for its neighbours — after the | |
| 102 | + txfm-context fix, the surviving mismatch starts in the pair's EVEN (inter) strip above | |
| 103 | + the intra one, which points at the pair's chroma/mv bookkeeping or the deblock grid | |
| 104 | + the intra strip publishes over the pair, not at its luma. | |
| 105 | +* deferred: `EC_RECT64_SPLIT` bypass removal — no witness; the rect64 hits still live | |
| 106 | + inside frames that refuse (confirms lane-rect64port r1 and lane-rectres r1). | |
| 107 | +* deferred: the 4x16 (VERT_4) orientation is unprovable by aomenc today — every | |
| 108 | + VERT_4-carrying recipe in the 96-run sweep also contains an intra 8x4/4x8 or 4x4 | |
| 109 | + sub-8x8 block, another lane's refusal. The gate asserts exactly that blocker. | |
| 110 | +* accepted: `refusal_inventory.rs` / `gate_coverage.rs` unchanged — no refusal was lifted. |
lanes/intra16x4-r2.handoff.mdadded+67 -0
| @@ -0,0 +1,67 @@ | ||
| 1 | +# lane-intra16x4 r2 HANDOFF | |
| 2 | + | |
| 3 | +## Root cause (found, fixed, minimal) | |
| 4 | + | |
| 5 | +`overlappable_above` / `overlappable_left` (`crates/ec-av1/src/decode.rs` ~18092 / ~18130) | |
| 6 | +never ported libaom's `mi_step == 1` chroma-pair merge from | |
| 7 | +`av1/common/obmc.h` (`foreach_overlappable_nb_above` / `foreach_overlappable_nb_left`). | |
| 8 | +Round 1's doc comment declared it unreachable ("no block this decoder codes is narrower | |
| 9 | +than 8px") -- the 1:4 partitions made it reachable: a 16x4 / 4x16 strip has | |
| 10 | +`mi_size_high` / `mi_size_wide` == 1, so libaom snaps the walk back to the pair's EVEN | |
| 11 | +index, reads the ODD (chroma-carrying) half as the neighbour and steps by 2. | |
| 12 | + | |
| 13 | +Witness `~/.cache/intra16x4-tmp/s5.obu`, frame 1, block mi(0,44) (16x16, right of a | |
| 14 | +16x16-level HORZ_4 whose strip 0 is inter and strips 1..3 intra): | |
| 15 | + | |
| 16 | +* our walk read mi(0,43) = the INTER strip 0 -> 1 overlappable neighbour -> | |
| 17 | + `motion_mode_allowed` true -> we READ a `motion_mode` symbol; | |
| 18 | +* libaom's pair merge reads mi(1,43) = the INTRA strip 1 -> 0 overlappable neighbours -> | |
| 19 | + `read_motion_mode` returns SIMPLE_TRANSLATION WITHOUT reading a symbol. | |
| 20 | + | |
| 21 | +Class `symbol-consumption-gap`: rng 39440 -> ours 34918, aomdec 38204 (its | |
| 22 | +`EC_ISTEP2 name=motion_mode` print is unconditional, so an equal rng there means the | |
| 23 | +symbol was NOT read). The tile desynced at the very next coefficient: the first TU of | |
| 24 | +mi(0,44) read `all_zero=1` where libaom reads `all_zero=0, eob=59`, which is the | |
| 25 | +"prediction only, no residual" smooth block at px(176..178, 0..15) the r1 pixel | |
| 26 | +measurement saw as "first luma diff (175,0), 8400 px". | |
| 27 | + | |
| 28 | +The fix is inside the two walk functions only -- every caller (eligibility at ~20908 and | |
| 29 | +~24493, the OBMC blend pass at ~18716/18746) routes through them. | |
| 30 | + | |
| 31 | +## Proof | |
| 32 | + | |
| 33 | +* Entropy ladder AFTER the fix, `s5.obu`, ours `EC_TRACE_COEFF` vs instrumented aomdec | |
| 34 | + `EC_TRACE_COEFF`: 620/620 `tag=all_zero` symbols identical in value AND range, up to the | |
| 35 | + point our decoder stops on another lane's refusal ("an intra 8x4/4x8 block inside an | |
| 36 | + inter frame's sub-8x8 HORZ/VERT partition"). Before the fix the first divergence was the | |
| 37 | + 4th block of frame 1's 3rd superblock row. | |
| 38 | +* New green witness (r2 96-run sweep `~/.cache/intra16x4-tmp/sweep_r2.sh`): | |
| 39 | + `bar_h` source (a horizontal bar sweeping DOWN), cq 63, `--min-partition-size=8`, | |
| 40 | + 192x128, 8-bit -> 5 intra 16x4 strips (2 chroma-reference), 6 frames decoded and | |
| 41 | + `cmp` EXACT against `ffmpeg -i ... -f rawvideo` (`~/.cache/intra16x4-tmp/g_8.obu`, | |
| 42 | + md5 `2eaafd9eb56fbf9d597820ad74c9c4e3`). The 10-bit build of the same recipe decodes | |
| 43 | + 6 frames but fires 0 strips (out of scope). | |
| 44 | + | |
| 45 | +## Gate + refusal state | |
| 46 | + | |
| 47 | +`a_real_aomenc_inter_sequence_with_intra_16x4_strips_in_1to4_partitions_decodes_pixel_exact` | |
| 48 | +gained that recipe as attempt 4 (`RECIPES` is now 5-wide with a per-arm | |
| 49 | +`--min-partition-size`). Run once with `--include-ignored --nocapture`: **RED, and not on | |
| 50 | +this lane's shape** -- attempt 0 (`noise`, cq60, 128x128) mismatches from (122, 13), | |
| 51 | +5466 px on frame 1, which r1 already measured as 99 rows ABOVE that stream's first strip | |
| 52 | +(strips at px(80,112)/(80,120)); it panics before attempt 4 runs. The test is therefore | |
| 53 | +still `#[ignore]`d, with that measurement in its reason string. | |
| 54 | + | |
| 55 | +**The refusal is NOT lifted**: `EC_INTRA16X4_DECODE=1` is still the bypass, | |
| 56 | +`refusal_inventory.rs` / `gate_coverage.rs` untouched. | |
| 57 | + | |
| 58 | +## Next step | |
| 59 | + | |
| 60 | +1. Own attempt 0's defect (128x128 cq60 `noise`, first diff (122,13) frame 1, arms | |
| 61 | + [2,0,0]) -- ladder it the same way; it is a DIFFERENT shape and it is the only thing | |
| 62 | + between this lane and a green gate. | |
| 63 | +2. Then reorder/prune `RECIPES` (or make the mismatch of an out-of-scope-for-this-shape | |
| 64 | + arm non-fatal only with a named owner), un-ignore, lift the refusal, update | |
| 65 | + `refusal_inventory.rs` + `gate_coverage.rs`. | |
| 66 | +3. Not run this round (turn cap): the full `cargo test -p ec-av1 --lib` suite and the film | |
| 67 | + probes. |
lanes/intra16x4-r3.handoff.mdadded+97 -0
| @@ -0,0 +1,97 @@ | ||
| 1 | +# lane-intra16x4 r3 HANDOFF | |
| 2 | + | |
| 3 | +## 1. Attempt 0 verdict: OURS, root cause found and fixed (mv stack, 4-wide / 4-high blocks) | |
| 4 | + | |
| 5 | +Stream reproduced exactly as gate attempt 0 (`~/.cache/intra16x4-tmp/gen_a0.sh 8` -> | |
| 6 | +`a0_8.obu`, md5 `0c9c588bb3d19f2feb2cecd31aa829fe`; 128x128 cq60 `noise`, 8-bit). | |
| 7 | +Before the fix: 6 frames decoded, `cmp` vs ffmpeg differs at byte 26363 = frame 1 (122,13). | |
| 8 | + | |
| 9 | +Ladder (ours `EC_TRACE_MODE`/`EC_TRACE_MODE_STEP`/`EC_TRACE_COEFF` vs instrumented aomdec, | |
| 10 | +same rungs) -- first diverging element is NOT a coefficient: the `tag=all_zero` ladder | |
| 11 | +diverges at #515, but the mode ladder diverges earlier, at frame 1 block **mi(24,15)**, the | |
| 12 | +last 4x16 strip of a 16x16-level `PARTITION_VERT_4`: | |
| 13 | + | |
| 14 | +| | stack | | |
| 15 | +|---|---| | |
| 16 | +| ours | (12,28) w648, (-4,26) w648, (-4,18) w8 -> mv0 (-4,18) | | |
| 17 | +| aomdec | (12,28) w**650**, (-4,18) w648, (-4,26) w8, (6,332) w4 -> mv0 (-4,26) | | |
| 18 | + | |
| 19 | +`crates/ec-av1/src/mvstack.rs` `scan_row` / `scan_col` (and their `_compound` twins) were | |
| 20 | +missing two clauses of libaom `scan_row_mbmi` / `scan_col_mbmi` | |
| 21 | +(`~/.cache/aom-oracle/src/av1/common/mvref_common.c:143-236`): | |
| 22 | + | |
| 23 | +1. the weight / `processed_rows` branch is `if (xd->width >= mi_size_wide[BLOCK_8X8] && | |
| 24 | + xd->width <= n4_w)` -- we had only `bw4 <= n4`, so a **4-wide / 4-high** block (exactly a | |
| 25 | + 1:4 strip or a sub-8x8 leaf) got a raised weight AND set `processed_rows`, which also | |
| 26 | + moves the later outer scans (that is the missing 4th candidate); | |
| 27 | +2. `if (abs(row_offset) > 1) { col_offset = 1; if ((mi_col & 0x01) && xd->width < 2) | |
| 28 | + --col_offset; }` -- the step-back on an odd mi_col under a sub-8px block was absent. | |
| 29 | + | |
| 30 | +Both clauses ported at all four sites (row, col, row-compound, col-compound). | |
| 31 | +AFTER: `a0_8.obu` is entropy-exact -- all **125** aomdec `EC_MODE` entries match ours as an | |
| 32 | +ordered subsequence (ours prints 5 extra `EC_MODE` lines for intra strips aomdec does not | |
| 33 | +print) -- and the decode now stops on ANOTHER lane's named refusal, | |
| 34 | +`an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition`, instead of | |
| 35 | +producing wrong pixels. Aligner: `~/.cache/intra16x4-tmp/align.py o_m2.log r_m.log`. | |
| 36 | + | |
| 37 | +## 2. r2's `g_8.obu` "6 frames bit-exact" claim is FALSE (measured, class stale-measurement) | |
| 38 | + | |
| 39 | +`~/.cache/intra16x4-tmp/g_8.obu` (md5 `2eaafd9eb56fbf9d597820ad74c9c4e3`, the r2 witness) | |
| 40 | +does NOT decode pixel-exact, and did not before this round's fix either: a build of the | |
| 41 | +**unmodified HEAD f403337** mvstack.rs mismatches at the same byte 53825 = frame 2, luma | |
| 42 | +(64,88). aomdec and ffmpeg agree with each other, so the reference is not in doubt. | |
| 43 | + | |
| 44 | +Its first diverging element (`EC_TRACE_COEFF`, all_zero #913) is a DIFFERENT shape, not this | |
| 45 | +lane's: frame 2 block **mi(14,12)**, an 8x8 compound leaf (`ref0=1 ref1=4`, mode 17). | |
| 46 | +Mode info is exact through the interp read (both at rng 34722); then aomdec reads var-tx | |
| 47 | +`txfm_split` symbols (rng 34722 -> 62656) and its first luma TU has `txb_skip ctx=6`, while | |
| 48 | +we read NO tx-split symbol at all and use `ctx=3`. Owner: the sub-8x8 / var-tx inter lane, | |
| 49 | +not intra16x4. | |
| 50 | + | |
| 51 | +## 3. Gate state | |
| 52 | + | |
| 53 | +`a_real_aomenc_inter_sequence_with_intra_16x4_strips_in_1to4_partitions_decodes_pixel_exact` | |
| 54 | +(`crates/ec-av1/src/stream.rs:11023`) rewritten to **continue-and-sweep**: | |
| 55 | +* named refusals accepted ONLY from a measured 3-string list (sub-8x8 HORZ/VERT intra, | |
| 56 | + sub-8x8 split intra 4x4, OBMC-neighbour interp) -- anything else is a failure; | |
| 57 | +* a mismatching attempt is RECORDED and the sweep continues (r2's attempt 0 panicked before | |
| 58 | + arm 4 ran); every decoding attempt compares every decode-order frame Y/U/V; | |
| 59 | +* ONE end-of-sweep assert over all recorded failures (mismatches + out-of-scope mismatches + | |
| 60 | + unmeasured refusals), then a per-bit-depth assert that the counter fired on >= 1 | |
| 61 | + pixel-exact attempt at every depth that decoded anything. | |
| 62 | +Still `#[ignore]`d and the refusal is **NOT lifted**: `EC_INTRA16X4_DECODE=1` remains the | |
| 63 | +bypass, `refusal_inventory.rs` / `gate_coverage.rs` untouched -- because no recipe found so | |
| 64 | +far gives a pixel-exact attempt with the counter > 0 (see 4). | |
| 65 | + | |
| 66 | +Sibling gates run (`cargo test -p ec-av1 --lib -- 1to4 obmc mv_stack refusal_inventory | |
| 67 | +gate_coverage vartx_rect`): **26 passed, 2 failed, 5 ignored**. The two failures are the two | |
| 68 | +gates the ledger already records as known-red firing-assert/recipe defects on main | |
| 69 | +(`..._16x16_level_1to4_partitions...`: "VERT_4/split-tx-8x4 arms read 0"; | |
| 70 | +`real_aomenc_1to4_streams_..._rect_vartx_leaves_fire`: "rect var-tx leaf arm never fired"). | |
| 71 | +Neither is a pixel mismatch, and both fail on a 0-count arm, i.e. recipe, not decode. | |
| 72 | + | |
| 73 | +## 4. Sweep (PARTIAL -- stopped at the turn cap, 49 of 120 rows) | |
| 74 | + | |
| 75 | +`~/.cache/intra16x4-tmp/sweep_r3.sh` -> `sweep_r3_partial.txt`: 5 sources x cq 55/60/63 x | |
| 76 | +192x128|176x144 x --min-partition-size 8|4 x 8/10-bit. 49 rows done, ALL 8-bit. | |
| 77 | +**0 EXACT.** Every row is either a named refusal (sub-8x8 intra, overwhelmingly) or a | |
| 78 | +MISMATCH; the mismatching rows all have `16x4=0 4x16=0`, i.e. out-of-scope shapes. | |
| 79 | +`--min-partition-size=4` is what makes strips fire (up to `16x4=3 4x16=10 chroma_ref=7`) and | |
| 80 | +is also what brings the sub-8x8 intra refusal. 10-bit rows were not reached -- rerun the | |
| 81 | +script (it is idempotent; it appends) to finish rows 50..120. | |
| 82 | + | |
| 83 | +## 5. Films (with the fix, `EC_RECT64_SPLIT=1 EC_INTRA16X4_DECODE=1`) | |
| 84 | + | |
| 85 | +`hg-0` 16x4=14, `hg-300` 4x16=8, `t900` 4x16=4, `t5400` 0/0, `t8100` 0/0 -> all stop at | |
| 86 | +`an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition`; `t6300` | |
| 87 | +(16x4=1 4x16=1) stops at `an OBMC neighbour whose switchable interp filter was never | |
| 88 | +recorded`. Same wall as r1 reported; no before/after frame counts measured this round. | |
| 89 | + | |
| 90 | +## Next step | |
| 91 | + | |
| 92 | +1. Finish the sweep (rows 50..120, the 10-bit half) looking for one EXACT row with a | |
| 93 | + counter > 0. If none exists, this lane cannot lift its refusal until the sub-8x8 intra | |
| 94 | + lane lands -- every strip-firing recipe found so far also carries that block. | |
| 95 | +2. The gate's arm list still contains the r2 `bar_h` arm 4 whose stream (`g_8.obu`) carries | |
| 96 | + the frame-2 8x8-compound var-tx defect of section 2; it will be recorded as a mismatch | |
| 97 | + until that lane's defect is fixed. |
lanes/sub8intra-r1.handoff.mdadded+108 -0
| @@ -0,0 +1,108 @@ | ||
| 1 | +# lane-sub8intra r1 HANDOFF (tip = this commit) | |
| 2 | + | |
| 3 | +Env switch: **`EC_SUB8INTRA_DECODE=1`** enables the decode path; `EC_SUB8INTRA=1` prints the | |
| 4 | +measurement line at the refusal sites. WITHOUT the switch both refusals are unchanged | |
| 5 | +(verified: hg-0 and the 1920x792 @900 cut both still stop at | |
| 6 | +"an intra 8x4/4x8 block inside an inter frame's sub-8x8 HORZ/VERT partition"). | |
| 7 | +No refusal lifted, `refusal_inventory.rs` / `gate_coverage.rs` untouched, no gate added. | |
| 8 | + | |
| 9 | +## Step 1 measurement (`EC_SUB8INTRA=1 EC_RECT64_SPLIT=1 EC_INTRA16X4_DECODE=1`, decode_probe) | |
| 10 | + | |
| 11 | +| probe | shape | sub-block | is chroma ref | skip | tx_select | | |
| 12 | +|---|---|---|---|---|---| | |
| 13 | +| 10-bit 3840x1608 cut 0 | 4x8 | 0 | false | 0 | 1 | | |
| 14 | +| 10-bit 3840x1608 cut 300 | 8x4 | 0 | false | 0 | 1 | | |
| 15 | +| 10-bit 1920x792 @900 | 4x8 | 0 | false | 0 | 1 | | |
| 16 | +| 10-bit 1920x792 @5400 | 4x8 | 0 | false | 0 | 1 | | |
| 17 | +| 10-bit 1920x792 @6300 | 4x8 | 0 | false | 0 | 1 | | |
| 18 | +| 10-bit 1920x792 @8100 | -- (stops earlier on the clipped-16x4 arm) | | |
| 19 | + | |
| 20 | +5/6 fire first on sub-block 0 (NOT the chroma reference), non-skip, `--enable-tx-size-search` on. | |
| 21 | +The 4x4 SPLIT refusal is never the first wall, but becomes the wall on 3/6 probes once the | |
| 22 | +HORZ/VERT arm decodes, so both arms are implemented. | |
| 23 | + | |
| 24 | +## What is implemented (crates/ec-av1/src/decode.rs) | |
| 25 | + | |
| 26 | +* `decode_intra_sub8_leaf(.., (bw,bh), has_chroma, skip, ..)` -- one INTRA 8x4/4x8 **or 4x4** | |
| 27 | + leaf on the inter path. Reads `y_mode[0]` (`size_group_lookup[BLOCK_8X4]==0`), NO angle delta | |
| 28 | + (`av1_use_angle_delta` needs >= 8x8), `uv_mode` off `uv_mode_cfl[mode]` + CfL alphas only on | |
| 29 | + the chroma reference, `filter_intra` off the shape's own class row | |
| 30 | + (`filter_intra_size_class_rect` / `_class(4)`), then the tx-depth symbol | |
| 31 | + (`tx_size_cat0`, ctx from `tx_size_context_txfm_rect` -- the INTER frame's live | |
| 32 | + `above_txfm`/`left_txfm`, not the key frame's deblock approximation; `BLOCK_4X4` reads none, | |
| 33 | + `block_signals_txsize` is false). Luma = `decode_leaf_rect8`'s body (whole `TX_8X4`/`TX_4X8` | |
| 34 | + via `read_coeffs_rect` + `LumaRect4x8[Set1]` + `SCAN_8X4`/`SCAN_4X8`, or two `TX_4X4` units at | |
| 35 | + depth 1; square `read_plane` for 4x4). Chroma, when this leaf IS the chroma reference: the | |
| 36 | + group's one 4x4 unit intra-predicted at the 8x8 group origin with `group_reach = Reach::of(8,..)`, | |
| 37 | + CfL AC from the group's 8x8 luma -- `decode_leaf_rect8`'s post-loop chroma verbatim. | |
| 38 | + Publishes: mode into `record_mode_mi` + the coarse `above_mode`/`left_mode`, skip grid, | |
| 39 | + lf grid at tx dims, `set_txfm_ctxs` equivalent (`above_txfm = tx_w`, `left_txfm = tx_h`), | |
| 40 | + `record_inter_rect_mi(.., is_inter=false, ref 0, filter [3,3])`, and `MiInfo { is_inter:false, | |
| 41 | + ref_frame:-1 }` over every mi cell. | |
| 42 | +* `decode_inter_sub8_rect2` / `decode_inter_sub8_split4`: the `!is_inter` arm calls it (behind | |
| 43 | + the env switch), sets `intra_chroma` when the leaf was the chroma reference, and the whole | |
| 44 | + chroma tail (prediction, residual, `record_uv_mode_mi`, the u/v neighbour-state loop) is | |
| 45 | + guarded by `if !intra_chroma`. | |
| 46 | +* MIXED groups (chroma reference INTER, a sibling INTRA): `is_sub8x8_inter` | |
| 47 | + (reconinter_template.inc:54) returns false as soon as any mi of the group is intra, so the | |
| 48 | + chroma is predicted WHOLE 4x4 from the chroma-reference block's own mv at the group's chroma | |
| 49 | + origin instead of in 2x2/4x2 pieces -- implemented in both functions (`mixed` flag). | |
| 50 | +* tx_type rule for that chroma: `first_tx_type` now comes from the chroma-reference block's own | |
| 51 | + first TU when sub-block 0 is intra (`xd->tx_type_map[0]` of the current mi). NOTE the | |
| 52 | + pre-existing all-inter rule ("FIRST sub-block") is untouched but looks wrong against | |
| 53 | + blockd.h:1288 -- `xd->tx_type_map` is rebased to the CURRENT (chroma-reference) mi, so the | |
| 54 | + co-located luma (0,0) is the LAST sub-block's, not the first's. Flagged, not changed. | |
| 55 | +* Counter `sub8_intra_rect_hits() -> (8x4, 4x8, chroma_ref, mixed)`, printed by decode_probe | |
| 56 | + (`sub8_intra_rect: ...`), exported through `stream.rs`. | |
| 57 | +* `EC_TRACE_MODE_STEP` prints `name=mode` and `name=tx_depth val/ctx` for the leaf, in the | |
| 58 | + oracle's EC_ISTEP format. | |
| 59 | + | |
| 60 | +## Pixel state under the bypass -- the gate is RED | |
| 61 | + | |
| 62 | +* Film: all six probes move past this wall (hg-0 7 leaves, hg-300 10, @900 21 (+2 mixed), | |
| 63 | + @5400 28 (+2 mixed), @6300 2) and stop at the NEXT wall (4x4 split intra on 3 of them, | |
| 64 | + the 16x4 strip arms on the others). No film pixel comparison is possible: every firing frame | |
| 65 | + also carries the unproven intra-16x4 strip. | |
| 66 | +* aomenc witness sweep `~/.cache/sub8intra-tmp/sweep.sh` and `sweep2.sh` (recipe: 128x128 / | |
| 67 | + 192x128 gray lavfi sources, cq 48..63, `--min-partition-size=4 --enable-1to4-partitions=0 | |
| 68 | + --max-partition-size=8|16 --enable-filter-intra=0 --sb-size=64 --enable-tx-size-search=1`), | |
| 69 | + logs `sweep1.log` / `sweep2.log`: the counters fire on every arm (up to 293 8x4 leaves) but | |
| 70 | + **only 1 of 24 arms decodes all 6 frames, and that one MISMATCHES at byte 24735**. Eleven | |
| 71 | + arms encoded with `--max-partition-size=8` -- where a 16x4 block CANNOT exist -- still report | |
| 72 | + "an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition", i.e. the refusal is | |
| 73 | + hallucinated by our own desync (class `refusal-from-own-desync`). | |
| 74 | + | |
| 75 | +## Where the desync is (bisected, do not redo this) | |
| 76 | + | |
| 77 | +Witness `~/.cache/sub8intra-tmp/x_1t_48_8_128x128.obu` (8-bit 128x128, cq48, max-partition 8; | |
| 78 | +1 intra 8x4 leaf then the bogus refusal). | |
| 79 | + | |
| 80 | +* EC_MODE ladder (ours vs instrumented aomdec, `r.l`/`o.l` in that dir): identical for 168 | |
| 81 | + entries; first divergence at `mi_row=24 mi_col=0` (ref rng=39238, ours rng=44268 and ours | |
| 82 | + reads a 16-wide block where the reference reads four 4x4s). | |
| 83 | +* The intra leaf itself is EXACT: it is at mi(23,12) (HORZ pair with the inter leaf at | |
| 84 | + mi(22,12), so the INTRA one is the chroma reference). Ours prints | |
| 85 | + `EC_ISTEP mi_row=23 mi_col=12 name=mode val=0 rng=38508` and | |
| 86 | + `name=tx_depth val=0 ctx=2 cat=0 rng=49194`; the oracle prints the identical tx_depth line | |
| 87 | + (ref_step.log:2463). So `y_mode[0]`, the missing angle delta, the uv/CfL reads and the | |
| 88 | + tx-depth ctx are all right. | |
| 89 | +* `tag=all_zero` ladder (`rz.l`/`oz.l`): the first 1405 luma/chroma transform units match | |
| 90 | + exactly; unit 1406 diverges (ref `all_zero=0 rng=40294`, ours `all_zero=0 rng=52548`). Both | |
| 91 | + decoders are still reading plane 0 there, so the divergence is in symbols read BETWEEN two | |
| 92 | + luma TUs -- i.e. inside the block following the intra leaf (the group at mi(22..23,14), the | |
| 93 | + 8x8 immediately to its right) or in that group's chroma. | |
| 94 | + | |
| 95 | +## Exact next step | |
| 96 | + | |
| 97 | +1. On that witness, ladder the group at mi(22,14)/(23,14) element by element (aomdec | |
| 98 | + `EC_ISTEP2 name=interp` / `EC_MODE`, ours `EC_MODE_MV`/`EC_MODE_VALR`) -- the intra leaf at | |
| 99 | + mi(23,12) is its LEFT neighbour, so the prime suspects are the left-side bands the intra | |
| 100 | + leaf publishes: `left_txfm` (tx dims vs block dims), `left_ref`/`left_inter` from | |
| 101 | + `record_inter_rect_mi(ref 0)` (INTRA_FRAME is 0 vs the `-1` the mi grid gets), the | |
| 102 | + coefficient state `left[..][0..2]`, and `left_side_mi` (the caller writes the group's | |
| 103 | + partition ctx AFTER the leaf, check the order). | |
| 104 | +2. Then re-check the chroma of the MIXED group at mi(22,12): its chroma is coded by the intra | |
| 105 | + leaf, so the inter sibling's own `piece` is dropped -- confirm against | |
| 106 | + `build_inter_predictors_sub8x8`'s `is_sub8x8_inter == false` path. | |
| 107 | +3. Only then re-run the sweep; a green arm needs `--max-partition-size=8` (no 16x4 shape can | |
| 108 | + exist there, so any 1:4 refusal is proof of a remaining desync). |
lanes/sub8intra-r2.handoff.mdadded+73 -0
| @@ -0,0 +1,73 @@ | ||
| 1 | +# lane-sub8intra r2 HANDOFF (tip = this commit) | |
| 2 | + | |
| 3 | +## The band: NOT a band -- the mv-stack's second-outer COLUMN scan (`mvstack.rs`) | |
| 4 | + | |
| 5 | +r1's suspects (above/left txfm, inter, ref, skip, y_mode, coeff, side-mi bands published by | |
| 6 | +the intra leaf) were ALL innocent. The first diverging symbol on the r1 witness | |
| 7 | +`~/.cache/sub8intra-tmp/x_1t_48_8_128x128.obu` is the `refmv` symbol of the INTER 8x4 leaf at | |
| 8 | +mi(23,14) -- the block whose LEFT neighbour is the intra leaf at mi(23,12..13). Same decoded | |
| 9 | +value (NEARESTMV), different CDF ROW (class `wrong-alphabet-same-value` / `cdf-row-held-constant`): | |
| 10 | + | |
| 11 | +* instrumented aomdec (private build, see below): `mode_ctx=75` -> newmv 3, globalmv 1, **refmv 4** | |
| 12 | +* ours before the fix: newmv 3, globalmv 1, **refmv 3** -> rng 62378 where the reference has 47820 | |
| 13 | + | |
| 14 | +`refmv 4` vs `3` is `ref_match_count == 2` vs `1` in `setup_ref_mv_list`'s `case 1:` switch | |
| 15 | +(mvref_common.c:638): libaom's second-outer column scan (`col_offset = -3`) found an inter | |
| 16 | +match at mi(23,11), ours found none. | |
| 17 | + | |
| 18 | +## Two defects fixed (crates/ec-av1/src/mvstack.rs, all FOUR scan functions) | |
| 19 | + | |
| 20 | +Both are pure sub-8x8 (a side < 2 mi) defects; every block main decodes today has both sides | |
| 21 | +>= 8px in at least one of the two axes checked, which is why they survived until this lane. | |
| 22 | + | |
| 23 | +1. **`scan_col_mbmi`'s odd-row snap was missing** (`scan_col` L~600, `scan_col_compound` L~1406): | |
| 24 | + libaom does `row_offset = 1; if ((mi_row & 0x01) && xd->height < n8_h_8) --row_offset;`. | |
| 25 | + For an 8x4 leaf on an ODD mi row our walk probed the row BELOW (undecoded), losing the | |
| 26 | + match. Fixed as `col_offset.unsigned_abs() > 1 && !(mi_row % 2 == 1 && bh4 < 2)`. | |
| 27 | + Transposed twin fixed in `scan_row`/`scan_row_compound` | |
| 28 | + (`(mi_col & 1) && xd->width < n8_w_8`). | |
| 29 | +2. **the weight / `processed_rows|cols` guard dropped libaom's `>= n8_*_8` half**: | |
| 30 | + libaom `if (xd->height >= n8_h_8 && xd->height <= n4_h)`; ours was `if (bh4 <= n4)`, so a | |
| 31 | + 1-mi-tall query block set `processed_cols` and a boosted weight libaom never sets (which can | |
| 32 | + also suppress the second-outer scan entirely). Now `bh4 >= 2 && bh4 <= n4` (and `bw4` twin). | |
| 33 | + | |
| 34 | +`cargo check -p ec-av1`: clean. | |
| 35 | + | |
| 36 | +## Ladder result on x_1t_48_8_128x128.obu (EC_SUB8INTRA_DECODE=1) | |
| 37 | + | |
| 38 | +* mi(24,0) EC_MODE: ref 39238, ours **39238** (was 44268) -- matches. | |
| 39 | +* `tag=all_zero` ladder: **2106/2106 units identical in value AND range, all 6 frames** | |
| 40 | + (`diff rz2.l oz2.l` empty). r1's ladder stopped matching at 1405. | |
| 41 | +* `OK: 6 frames decoded, 128x128`, `sub8_intra_rect: horz8x4=19 vert4x8=2 chroma_ref=10 mixed=3`. | |
| 42 | +* Pixels: 3 residual clusters (frame 3 two 4x4 luma, frames 4/5 one +-1 pixel triple) -- | |
| 43 | + root-caused to the OBMC `mi_step == 1` chroma-pair merge, which is **already fixed on | |
| 44 | + lane-intra16x4 as f403337** (`overlappable_above`/`overlappable_left`). NOT duplicated here | |
| 45 | + (charter: those functions belong to that lane). With f403337's decode.rs hunk applied on top of | |
| 46 | + this commit the witness is **cmp-EXACT vs `ffmpeg -pix_fmt yuv420p` on all 6 frames** | |
| 47 | + (verified, then reverted out of this tree). | |
| 48 | + | |
| 49 | +## Oracle instrumentation added (additive, env-gated `EC_SUB8CTX`) | |
| 50 | + | |
| 51 | +`av1/decoder/decodemv.c` in `~/.cache/aom-oracle/src`: one print after `read_ref_frames` | |
| 52 | +(single-ref p1 ctx + rng) and one after `read_inter_mode` (mode_ctx split into | |
| 53 | +newmv/globalmv/refmv + ref_mv_count). Built into the PRIVATE dir | |
| 54 | +`~/.cache/sub8intra-tmp/aom-build` (`ninja aomdec`); `~/.cache/aom-oracle/build` untouched. | |
| 55 | +This print is what named the band in one step -- keep it. | |
| 56 | + | |
| 57 | +## Next step (r3) | |
| 58 | + | |
| 59 | +1. Sweep `~/.cache/sub8intra-tmp/sweep3.sh` (max-partition-size=8, 1:4 off, 8- and 10-bit, | |
| 60 | + cq 48/55/63, 128x128 + 192x128) -- 5 of 12 arms already decode all 6 frames pixel-EXACT | |
| 61 | + (`10 cq48 128x128`, `10 cq48 192x128`, `10 cq55 128x128`, `10 cq63 128x128`, | |
| 62 | + `8 cq55 192x128`). Those are the gate arms. | |
| 63 | +2. The other arms still stop at a refusal naming a shape the encoder cannot have coded | |
| 64 | + (`--max-partition-size=8` + `--enable-1to4-partitions=0`) -- class `refusal-from-own-desync`, | |
| 65 | + one desync left. Bisected on `g_8_48_128x128.obu`: first divergence at all_zero unit 1581, | |
| 66 | + block mi(25,2) -- the reference reads `use_filter_intra=1`, `filter_intra_mode=3`, | |
| 67 | + `tx_depth=1` for an INTRA sub-8x8 leaf there (ra2.l:4370-4372) which OUR path never reads; | |
| 68 | + ours continues the previous block's 4x4 units instead. So: filter_intra IS read on a | |
| 69 | + sub-8x8 intra leaf in that stream, and the `tx_depth=1` split (two TX_4X4) path is the | |
| 70 | + one to check first. | |
| 71 | +3. Then: gate + refusal lift (both sub-8x8 intra refusals), refusal_inventory.rs + | |
| 72 | + gate_coverage.rs, suite, films. Also still open: the flagged all-inter `first_tx_type` | |
| 73 | + rule (blockd.h:1288, LAST sub-block vs first) -- unmeasured this round. |
lanes/sub8x4-r1.handoff.mdadded+138 -0
| @@ -0,0 +1,138 @@ | ||
| 1 | +# lane-sub8x4 r1 HANDOFF (tip = `bb79462`, branch lane-sub8x4) | |
| 2 | + | |
| 3 | +Two commits on top of c1df2f2 (= lane-intra16x4 r3): | |
| 4 | + | |
| 5 | +* `1845281` merge of `367d873` (lane-sub8intra r2) + the sub-8x8 sibling-size fix | |
| 6 | +* `bb79462` compound 8x8 leaf early-return fix | |
| 7 | + | |
| 8 | +## 1. STEP 0 -- how the merge was resolved | |
| 9 | + | |
| 10 | +`git merge 367d873` conflicted in ONE file, `crates/ec-av1/src/mvstack.rs`, at 8 hunks | |
| 11 | +(4 functions x 2 hunks: `scan_row`, `scan_col`, `scan_row_compound`, `scan_col_compound`). | |
| 12 | +Every hunk was the SAME libaom clause ported twice, once per lane, with different comment | |
| 13 | +wording and `if/else` vs `usize::from` spelling -- **semantically identical on both sides**: | |
| 14 | + | |
| 15 | +1. the outer-scan step-back, `mvref_common.c:155-158` (`scan_row_mbmi`) and `:203-206` | |
| 16 | + (`scan_col_mbmi`): `if (abs(row_offset) > 1) { col_offset = 1; if ((mi_col & 0x01) && | |
| 17 | + xd->width < width_8x8) --col_offset; }` and its transpose; | |
| 18 | +2. the weight / `processed_rows|cols` guard, `mvref_common.c:172` and `:222`: | |
| 19 | + `if (xd->width >= width_8x8 && xd->width <= n4_w)` / `if (xd->height >= n8_h_8 && | |
| 20 | + xd->height <= n4_h)` -- the `>= mi_size_*[BLOCK_8X8]` half is what both lanes added. | |
| 21 | + | |
| 22 | +Resolution: kept the HEAD (intra16x4 r3) spelling of all 8 hunks, which cites the libaom | |
| 23 | +line numbers; the sub8intra rationale is preserved in this file. Both sides' `bw4 >= 2 && | |
| 24 | +bw4 <= n4` / `bh4 >= 2 && bh4 <= n4` guard lines were already identical and auto-merged. | |
| 25 | +All four functions were then re-read whole against `mvref_common.c:143-236`: `end_mi`, | |
| 26 | +`use_step_16`, `len` floors (`width_16x16` / `width_8x8`), the weight `inc`, the | |
| 27 | +`processed_*` update and the `i += len` step all match. | |
| 28 | + | |
| 29 | +`decode.rs`, `stream.rs`, `examples/decode_probe.rs` auto-merged clean (both lanes' code | |
| 30 | +kept: the intra 16x4 strip path + OBMC pair merge from intra16x4, `decode_intra_sub8_leaf` | |
| 31 | ++ the sub-8x8 chroma guards from sub8intra). Both env bypasses (`EC_SUB8INTRA_DECODE`, | |
| 32 | +`EC_INTRA16X4_DECODE`) are still in place; no refusal lifted this round. | |
| 33 | + | |
| 34 | +`cargo check -p ec-av1`: clean. Named gates run after the merge | |
| 35 | +(`cargo test -p ec-av1 --lib -- obmc mv_stack 1to4 sub8 refusal_inventory gate_coverage`): | |
| 36 | +**32 passed, 2 failed, 5 ignored**. The two failures are the two gates the ledger already | |
| 37 | +records as known-red RECIPE defects on main -- `a_real_aomenc_inter_sequence_with_16x16_ | |
| 38 | +level_1to4_partitions_decodes_pixel_exact` ("VERT_4 / split-tx-8x4 arms read 0") and | |
| 39 | +`real_aomenc_1to4_streams_..._rect_vartx_leaves_fire` ("the rectangular var-tx leaf arm | |
| 40 | +never fired"). Both fail on a zero counter, neither on a pixel mismatch. | |
| 41 | + | |
| 42 | +## 2. Two defects found and fixed (both post-merge, both root-caused by ladder) | |
| 43 | + | |
| 44 | +### (a) `decode_inter_sub8_rect2`: leaf 1 never saw leaf 0's block size (`1845281`) | |
| 45 | + | |
| 46 | +libaom's `xd->above_mbmi`/`left_mbmi` are the neighbour block AS DECODED, so leaf 1 of an | |
| 47 | +8x8 HORZ/VERT group sees leaf 0's own bsize. We published `above_side_mi`/`left_side_mi` | |
| 48 | +only in the GROUP tail (after both leaves), so leaf 1 read the block preceding the whole | |
| 49 | +group. `get_tx_size_context` (`pred_common.h:342`) takes `block_size_wide[above_mbmi->bsize]` | |
| 50 | +from there. | |
| 51 | + | |
| 52 | +Witness `~/.cache/sub8intra-tmp/g_8_48_128x128.obu`, mi(25,2) (intra 8x4 leaf 1): | |
| 53 | +ours `tx_depth` **ctx=1** vs aomdec **ctx=2**, same decoded value 1, rng 35938 vs 55960. | |
| 54 | +`EC_TXCTX=1` (new env print in `tx_size_context_txfm_rect`) showed `above_side=4` where the | |
| 55 | +above neighbour is an inter 8x4 leaf of width 8. Class `tx-grid-published-block-side`. | |
| 56 | + | |
| 57 | +Fix: publish the leaf-0 side bands at the top of iteration `i == 1` of the leaf loop | |
| 58 | +(`decode.rs`, `decode_inter_sub8_rect2`). The group tail rewrites the same values, so | |
| 59 | +partition context is unchanged. | |
| 60 | + | |
| 61 | +### (b) `decode_leaf8` COMPOUND arm's early return clobbered its own per-TU luma ctx (`bb79462`) | |
| 62 | + | |
| 63 | +The compound arm `return`s before the fall-through tail, and that tail is where the | |
| 64 | +`split8` plane-0 save/restore around `record_mi` lives. A compound var-tx 8x8 leaf therefore | |
| 65 | +published the whole-block luma grid (all-zero when the transform is split into 4x4 units, | |
| 66 | +since `read_inter_luma8`'s `record_mi_luma` already wrote the per-unit state) into | |
| 67 | +`above[..][0]`/`left[..][0]`. | |
| 68 | + | |
| 69 | +Witness `~/.cache/intra16x4-tmp/g_8.obu` frame 2 mi(14,12), first luma TU: ours | |
| 70 | +`txb_skip` ctx=3 rng=43376 vs reference ctx=6 rng=61310 -- `get_txb_ctx` | |
| 71 | +(`txb_common.h:330`) `skip_contexts[4][0]=3` vs `[4][4]=6`; the block left of it, mi(14,10), | |
| 72 | +is a compound 8x8 whose four TX_4X4 units all read ctx=6 correctly and then had their | |
| 73 | +published levels zeroed. Class `early-return-skips-tail`. | |
| 74 | + | |
| 75 | +Fix: the same save/restore in the compound arm before/after its `record_mi`. | |
| 76 | + | |
| 77 | +## 3. Measured state (probe sweep, both bypasses on) | |
| 78 | + | |
| 79 | +`~/.cache/sub8x4-tmp/check.sh <obu>...` (decode + `cmp` vs `ffmpeg -f rawvideo`), | |
| 80 | +12 sub-8x8-intra streams `~/.cache/sub8intra-tmp/g_{8,10}_{48,55,63}_{128x128,192x128}.obu`: | |
| 81 | + | |
| 82 | +| state | before this round | after (a) | after (b) | | |
| 83 | +|---|---|---|---| | |
| 84 | +| pixel-EXACT (6/6 frames) | 5/12 | 10/12 | 10/12 | | |
| 85 | +| stops at a refusal | 2/12 | 2/12 | **1/12** | | |
| 86 | + | |
| 87 | +Remaining non-EXACT: `g_8_63_128x128.obu` (mismatch) and `g_10_55_192x128.obu` (was | |
| 88 | +"Golomb tail longer than this decoder reads", now decodes all 6 frames and mismatches). | |
| 89 | + | |
| 90 | +`~/.cache/intra16x4-tmp/g_8.obu` is now **entropy-exact end to end**: 2215/2215 `all_zero` | |
| 91 | +units identical in value AND range vs instrumented aomdec, with equal counts -- yet its | |
| 92 | +pixels still differ (frame 1 first at luma (64,88), 1185 px, max delta 20; frames 2..5 | |
| 93 | +150-235 px each). That is a **reconstruction-only** residue (prediction / OBMC blend / | |
| 94 | +loop filter), not entropy. This supersedes the r3 handoff's section-2 diagnosis, whose | |
| 95 | +named cause (the 8x8 compound var-tx read) is now fixed. | |
| 96 | + | |
| 97 | +## 4. STEP 1 list, unchanged / re-measured | |
| 98 | + | |
| 99 | +* (a) sub-8x8 INTRA leaf reads `use_filter_intra` (+ `filter_intra_mode`): **premise was | |
| 100 | + STALE -- already implemented** by sub8intra r2 in `decode_intra_sub8_leaf` | |
| 101 | + (`decode.rs:23101`). Proven: with the new `EC_TRACE_MODE_STEP` prints added there, ours | |
| 102 | + reads `use_filter_intra=1 rng=51020` then `filter_intra_mode=3 rng=45380` at mi(25,2), | |
| 103 | + **bit-identical to aomdec**. `av1_filter_intra_allowed_bsize` is `reconintra.h:68` | |
| 104 | + (`block_size_wide <= 32 && block_size_high <= 32`), so 8x4/4x8/4x4 are all allowed. No | |
| 105 | + angle delta below 8x8 is likewise already implemented. What was actually wrong at that | |
| 106 | + block was the tx_depth CDF ROW -- fix (a) above. | |
| 107 | +* (b) 8x8 COMPOUND inter leaf var-tx `txfm_split`: **premise partly stale** -- we DO read | |
| 108 | + the symbol (ours `txfm_split val=1 ctx=19 rng=62656`, reference reaches the same 62656). | |
| 109 | + The real defect was the `txb_skip` ctx, fix (b) above. DONE. | |
| 110 | +* (c) the flagged all-inter sub-8x8 chroma `first_tx_type` rule (`blockd.h:1288`, | |
| 111 | + tx_type_map rebased to the chroma-reference = LAST sub-block): **NOT MEASURED this | |
| 112 | + round.** Still open. | |
| 113 | + | |
| 114 | +## 5. Next step (r2) | |
| 115 | + | |
| 116 | +1. Root-cause the two remaining non-EXACT sub-8x8 streams and `g_8.obu`'s | |
| 117 | + reconstruction-only residue (entropy is exact, so start at prediction: OBMC blend, | |
| 118 | + sub-8x8 chroma MC, or the deblock grid a sub-8x8 group publishes). | |
| 119 | +2. Then the gates: **no sub-8x8-intra gate test exists yet in `stream.rs`** (only the | |
| 120 | + `sub8_intra_rect_hits()` accessor at `stream.rs:91` and the 1:4 gate's refusal count). | |
| 121 | + It must be WRITTEN, continue-and-sweep, over the now 10 EXACT arms of | |
| 122 | + `~/.cache/sub8intra-tmp/sweep3.sh` (`--max-partition-size=8 --enable-1to4-partitions=0 | |
| 123 | + --min-partition-size=4`, 8/10-bit x cq 48/55/63 x 128x128/192x128). Only then lift | |
| 124 | + `EC_SUB8INTRA_DECODE` + the two refusals at `refusal_inventory.rs:35-36`. | |
| 125 | +3. intra 16x4: still no EXACT witness; re-run `~/.cache/intra16x4-tmp/sweep_r3.sh` (it is | |
| 126 | + idempotent and appends) now that both fixes landed -- r3 measured 0 EXACT of 49 rows | |
| 127 | + BEFORE them. | |
| 128 | +4. Not run this round (turn cap): full `cargo test -p ec-av1 --lib` suite, film probes. | |
| 129 | + | |
| 130 | +## 6. New instrumentation on this branch (env-gated, keep) | |
| 131 | + | |
| 132 | +* `EC_TXCTX=1` -- `tx_size_context_txfm_rect` prints `above_txfm/left_txfm/above_inter/ | |
| 133 | + left_inter/above_side/left_side/above/left`; named defect (a) in one run. | |
| 134 | +* `EC_TRACE_MODE_STEP` now also prints `use_filter_intra` / `filter_intra_mode` from | |
| 135 | + `decode_intra_sub8_leaf` (it read them silently before, which is what made the r2 | |
| 136 | + handoff conclude they were unread). | |
| 137 | +* `EC_AV1_TRACE` `luma_skip_ctx` line now dumps the whole `left[..][0]` level band; | |
| 138 | + that dump is what localised defect (b). |
lanes/sub8x4-r2.handoff.mdadded+118 -0
| @@ -0,0 +1,118 @@ | ||
| 1 | +# lane-sub8x4 r2 HANDOFF (tip = `2515eb1`, branch lane-sub8x4) | |
| 2 | + | |
| 3 | +Two commits on top of `94bda2f`: | |
| 4 | + | |
| 5 | +* `f0bd09d` fix: compound 8x8 leaf published transform width 8 to the deblock grid even | |
| 6 | + when its var-tx split it into 4x4 units | |
| 7 | +* `2515eb1` feat: both sub-8x8 intra refusals lifted behind the new gate | |
| 8 | + | |
| 9 | +## STEP A -- DONE, gate GREEN, both refusals LIFTED | |
| 10 | + | |
| 11 | +### The last defect (root cause, class `early-return-skips-tail`, 3rd instance in that arm) | |
| 12 | + | |
| 13 | +`decode_inter_block8`'s COMPOUND early return called | |
| 14 | +`neighbours.fill_lf_grid(leaf_mi, 2, 8, ..)` with a LITERAL 8 where the fall-through | |
| 15 | +single-ref tail writes `if split8 { 4 } else { 8 }` (decode.rs, ~line 24990 vs ~25980). | |
| 16 | +libaom `get_transform_size` (av1_loopfilter.c:207) reads the per-TU `inter_tx_size` for a | |
| 17 | +non-skip inter LUMA block, so a var-tx-split 8x8's interior edges at `x % 8 == 4` are real | |
| 18 | +filter edges; ours never filtered them and widened the neighbouring x=64 edge from filter4 | |
| 19 | +to filter8. | |
| 20 | + | |
| 21 | +Ladder that named it, on `~/.cache/sub8intra-tmp/g_8_63_128x128.obu`: | |
| 22 | +* `EC_OBMC` trace ours vs instrumented aomdec: **404 = 404 lines, byte-identical** (OBMC | |
| 23 | + neighbour lists are exact -- do not re-audit them). | |
| 24 | +* `EC_AV1_PREFILT_DUMP` (ours, no `EC_AV1_DEBUG_SKIP_CDEF`) vs aomdec's: decode frames | |
| 25 | + 0,1,2 **SAME**; only f3+ differ (propagation). | |
| 26 | +* `EC_AV1_POSTDEBLOCK_DUMP` both sides: frame 2 differs, 12 luma px at rows 78..80 cols | |
| 27 | + 58..63, max delta 3 -> the deblocker is the stage. | |
| 28 | +* `EC_AV1_DEBLOCK_TRACE_V`: no `VEDGE x0=60` in frame 2 where frames 0/1/3 have one; | |
| 29 | + `EC_TXGRID_TRACE` (new `EC_LFLEAF` line added this round in `fill_lf_grid_leaf_luma`) | |
| 30 | + showed the 8x8 at mi(20,14) publishing `tx_px=8` with no leaf fill. | |
| 31 | + | |
| 32 | +Probe sweep `~/.cache/sub8intra-tmp/sweep3.sh` (12 streams): **10/12 -> 12/12 pixel-EXACT**. | |
| 33 | + | |
| 34 | +### The gate | |
| 35 | + | |
| 36 | +`a_real_aomenc_inter_sequence_with_intra_sub8x8_leaves_decodes_pixel_exact` | |
| 37 | +(`crates/ec-av1/src/stream.rs`, end of the test module). | |
| 38 | + | |
| 39 | +* 12 arms: 8/10-bit x cq 48/55/63 x 128x128/192x128, recipe copied from sweep3.sh | |
| 40 | + (`--min-partition-size=4 --max-partition-size=8 --enable-1to4-partitions=0 | |
| 41 | + --enable-rect-partitions=1 --cpu-used=0 --sb-size=64 --lag-in-frames=0`), streams | |
| 42 | + re-encoded BY the gate, first arm encoded twice and compared byte for byte. | |
| 43 | +* 6 decode-order frames per arm, all three planes, vs `ffmpeg_decode_sequence` / | |
| 44 | + `_10bit`. Continue-and-sweep: only `unsupported: ` is recorded and skipped; any other | |
| 45 | + error or ANY pixel mismatch fails. | |
| 46 | +* End-of-sweep asserts `exact_arms >= 12` and all five `sub8_intra_rect_hits` cells > 0. | |
| 47 | +* **Result: 12/12 arms EXACT, counters `[8x4=362, 4x8=80, chroma_ref=156, mixed=153, | |
| 48 | + split4x4=98]`, 7.42 s.** | |
| 49 | +* `SUB8_INTRA_RECT_HITS` grew a 5th cell (split 4x4 leaves); `decode_probe` prints | |
| 50 | + `split4x4=`. | |
| 51 | + | |
| 52 | +Lifted: `EC_SUB8INTRA_DECODE` (both sites) and the two refusal strings, removed from | |
| 53 | +`refusal_inventory.rs` in the same commit. `gate_coverage.rs` needed no edit (this gate | |
| 54 | +spells no tool flag that was previously never-on); `refusal_inventory` + all 12 | |
| 55 | +`gate_coverage` tests pass. | |
| 56 | + | |
| 57 | +Siblings re-run (`-- sub8 obmc mv_stack 1to4 refusal_inventory gate_coverage`): | |
| 58 | +**33 passed, 2 failed, 5 ignored**. The 2 failures are the pre-existing zero-COUNTER | |
| 59 | +recipe defects this branch already carried (`..._16x16_level_1to4_partitions...` | |
| 60 | +stream.rs:10994, `real_aomenc_1to4_streams_..._rect_vartx_leaves_fire` stream.rs:8876); | |
| 61 | +neither is a pixel mismatch and neither moved this round. | |
| 62 | + | |
| 63 | +### NOT in the gate: the `--tile-columns=1` arm (measured, not assumed) | |
| 64 | + | |
| 65 | +The arm was written, run, and **failed** at decode-order frame 4 (12056 luma px). It then | |
| 66 | +failed IDENTICALLY with `--min-partition-size=16 --max-partition-size=16` (frame 3, 13256 | |
| 67 | +luma px) -- a stream with no sub-8x8 block of any kind -- so this is a PRE-EXISTING | |
| 68 | +multi-tile defect, not this lane's bands. Streams pinned: | |
| 69 | +`~/.cache/sub8x4-tmp/tiles.obu` (sub-8x8) and `~/.cache/sub8x4-tmp/t16.obu` (none); | |
| 70 | +`diff.py` in the same dir prints per-frame/plane deltas. The gate carries the repro in a | |
| 71 | +comment with the one line to restore. This is the single most valuable open item. | |
| 72 | + | |
| 73 | +## STEP B -- NOT DONE, its premise is STALE | |
| 74 | + | |
| 75 | +`~/.cache/intra16x4-tmp/g_8.obu` is NOT an intra-16x4 witness: re-measured this round with | |
| 76 | +`EC_INTRA16X4_DECODE=1`, it reports `intra16x4_in_inter: 16x4=0 4x16=0 chroma_ref=0` and | |
| 77 | +still mismatches at byte 53825. Its mismatch is another shape's defect (the ledger already | |
| 78 | +records the same stream as never-exact on unmodified HEAD). There is no firing witness at | |
| 79 | +all: the r3 49-row sweep found 0 EXACT rows and every row had `16x4=0`. Next step for B is | |
| 80 | +therefore NOT the prediction/OBMC/deblock comparison in the charter -- it is finding a | |
| 81 | +stream where the counter fires AND the rest of the frame is clean (r1's dead-end: every | |
| 82 | +firing film frame also carries a sub-8x8 intra block -- which is now DECODABLE, so re-run | |
| 83 | +`~/.cache/intra16x4-tmp/films.sh` and the reelb0-5x prefixes on this tip: that dead-end may | |
| 84 | +have expired with this commit). | |
| 85 | + | |
| 86 | +## STEP C -- suite armed, not read | |
| 87 | + | |
| 88 | +Unit `sub8x4-suite-r2-1788363069.service`, log **`$HOME/.cache/sub8x4-suite.log`**. | |
| 89 | +Check with a single `grep -E "^test result|FAILED" $HOME/.cache/sub8x4-suite.log`. | |
| 90 | + | |
| 91 | +## STEP D -- NOT RUN (turn cap). No film probe, no `EC_RECT64_SPLIT` measurement, no | |
| 92 | +fixture pinned. Inputs are in place: `~/.cache/hg-0.obu`, `~/.cache/hg-300.obu`, | |
| 93 | +`~/.cache/intra16x4-tmp/reelb0-{50,52,55}.obu`. | |
| 94 | + | |
| 95 | +## Next step, in order | |
| 96 | + | |
| 97 | +1. Read the suite log; if a gate outside this lane's files is red, bisect against `94bda2f`. | |
| 98 | +2. Re-run the film/reelb0 probes on this tip (STEP D) -- the sub-8x8 intra lift removes one of | |
| 99 | + the two walls the r1 film sweep hit, so the refusal STRING each cut stops at has moved. | |
| 100 | +3. The multi-tile defect above (own lane; it is not sub-8x8 specific and it blocks the | |
| 101 | + neighbour-map arm COMMON asks every lane for). | |
| 102 | + | |
| 103 | +## ADDENDUM (measured after the handoff above, while the suite ran) | |
| 104 | + | |
| 105 | +The suite's first failure is `a_frame_edge_straddling_band_decodes_pixel_exact`, and it is | |
| 106 | +NOT a regression: `git log --oneline main --not HEAD` shows this branch is missing main's | |
| 107 | +`1d2259c` ("the saved motion field kept only the LAST tile's columns -- | |
| 108 | +`av1_copy_frame_mvs` read the mi grid through the per-tile reach clamp") and its merge | |
| 109 | +`9cca16e`. That gate is green on main only because of that commit; the charter forbids | |
| 110 | +rebasing this lane onto it. | |
| 111 | + | |
| 112 | +**Strong lead:** that same missing commit is the most likely cause of THIS lane's | |
| 113 | +multi-tile desync too -- a 2-tile-column stream whose temporal MV candidates come from the | |
| 114 | +saved motion field, going wrong only from decode-order frame 3/4 (i.e. the first frames | |
| 115 | +that read a motion field saved by a MULTI-TILE frame), with tile 1's pixels exact. Before | |
| 116 | +spending a round on it: merge main into the lane (or cherry-pick `1d2259c`), then re-run | |
| 117 | +`~/.cache/sub8x4-tmp/tiles.obu` + `t16.obu` and, if clean, restore the one commented-out | |
| 118 | +`arms.push((8, 63, 192, 128, true));` line in the gate. |
lanes/sub8x4-r3.report.mdadded+111 -0
| @@ -0,0 +1,111 @@ | ||
| 1 | +# lane-sub8x4 r3 report (branch `lane-sub8x4`, tip `f38f963`) | |
| 2 | + | |
| 3 | +Merged `main` @ `9cca16e` (clean auto-merge, **zero conflicts** -- no hand-resolved | |
| 4 | +function to re-read), then two commits. | |
| 5 | + | |
| 6 | +## r2 suite line (the unit that was still running at the start of this round) | |
| 7 | + | |
| 8 | +`test result: FAILED. 419 passed; 3 failed; 38 ignored; 0 measured; 0 filtered out; finished in 674.52s` | |
| 9 | + | |
| 10 | +The 3: `a_frame_edge_straddling_band_decodes_pixel_exact` (main's `1d2259c` was missing | |
| 11 | +from the lane -- fixed by the merge, see below) plus the two pre-existing zero-COUNTER | |
| 12 | +recipe defects this branch already carried (`..._16x16_level_1to4_partitions...` | |
| 13 | +stream.rs:11002, `real_aomenc_1to4_streams_..._rect_vartx_leaves_fire` stream.rs:8884). | |
| 14 | +Neither of those two is a pixel mismatch and neither moved this round. | |
| 15 | + | |
| 16 | +## STEP 1 -- `13cd475`: the `--tile-columns=1` arm is back, and r2's premise was right | |
| 17 | + | |
| 18 | +r2 excluded the arm with a measurement (desync at decode-order frame 4, identical with | |
| 19 | +`--min-partition-size=16 --max-partition-size=16`, i.e. a stream with no sub-8x8 block at | |
| 20 | +all) and named the suspect: main's `1d2259c`, "the saved motion field kept only the LAST | |
| 21 | +tile's columns -- `av1_copy_frame_mvs` read the mi grid through the per-tile reach clamp". | |
| 22 | +Confirmed: with the merge the arm is pixel-exact and the gate now carries the neighbour-map | |
| 23 | +tile arm COMMON asks every lane for (13 arms). | |
| 24 | + | |
| 25 | +EVIDENCE: crates/ec-av1/src/stream.rs:30038-30044 | `cargo test -p ec-av1 --lib -- sub8 straddling obmc mv_stack 1to4 refusal_inventory gate_coverage` | `34 passed; 2 failed; 5 ignored` in 141.28s -- the 2 are the same two recipe defects above; `a_real_aomenc_inter_sequence_with_intra_sub8x8_leaves_decodes_pixel_exact` and `a_frame_edge_straddling_band_decodes_pixel_exact` both green | |
| 26 | + | |
| 27 | +## STEP 2 -- film probes (release probe, each under `systemd-run --scope MemoryMax=6G`) | |
| 28 | + | |
| 29 | +**The r1/r2 "no witness exists" dead-end EXPIRED**, exactly as this lane's r2 predicted: | |
| 30 | +every firing frame also carried a sub-8x8 intra leaf, which refused until r2 lifted it. | |
| 31 | + | |
| 32 | +| cut | frames / wall | `intra16x4_in_inter` 16x4/4x16/chroma | `rect64_corner_tu` 64x32/32x64 | | |
| 33 | +|---|---|---|---| | |
| 34 | +| head of the 10-bit 3840x1608 stream (2 s) | **OK: 48 frames, no refusal** | 31 / 17 / 23 | 130 / 22 | | |
| 35 | +| same stream @ +300 s | REFUSED: a Golomb tail longer than this decoder reads | 175 / 1350 / 760 | 270 / 90 | | |
| 36 | +| 1080p 10-bit 128-SB cut @ 900 | REFUSED: an OBMC neighbour whose switchable interp filter was never recorded | 1 / 4 / 2 | 0 / 0 | | |
| 37 | +| same @ 5400 | REFUSED: same OBMC string | 15 / 49 / 35 | 0 / 0 | | |
| 38 | +| same @ 6300 | REFUSED: same OBMC string | 1 / 1 / 0 | 0 / 0 | | |
| 39 | +| same @ 8100 | REFUSED: an intra-coded 16x4/4x16 strip **on the inter block path** (decode.rs:7390 -- a DIFFERENT site from the one lifted here) | 0 / 0 / 0 | 1 / 0 | | |
| 40 | + | |
| 41 | +Pixel compare of the only cut that finishes (`EC_PROBE_OUT16` vs | |
| 42 | +`ffmpeg -pix_fmt yuv420p10le -f rawvideo`, `diff16.py`, 889159680 B each side): | |
| 43 | +**decode-order frames 0..35 are byte-identical**; frame 36 is the first differing one | |
| 44 | +(1992768 of 18524160 bytes) and 36..47 all differ -- one wall, propagating. | |
| 45 | + | |
| 46 | +EVIDENCE: ~/.cache/sub8x4-tmp/{o,r}.raw | release decode_probe + ffmpeg on the 2 s head cut, diff16.py 3840x1608 | frames 0-35 differ in 0 bytes, frame 36 in 1992768 | |
| 47 | + | |
| 48 | +## STEP 3 -- `f38f963`: both refusals narrowed, one film gate, one sibling fixed | |
| 49 | + | |
| 50 | +* `EC_RECT64_SPLIT` removed (decode.rs:6890-6903): the un-split TX_64X32/TX_32X64 corner | |
| 51 | + unit of a split intra strip is now the default path. | |
| 52 | +* `EC_INTRA16X4_DECODE` removed (decode.rs:21886-21903): the intra 16x4/4x16 strip inside | |
| 53 | + an inter 16x16-level 1:4 partition decodes by default when it has a chroma-pair record. | |
| 54 | +* Fixture `crates/ec-av1/fixtures/reelb_rect64_intra16x4_witness.obu` (`git add -f`, in | |
| 55 | + `git ls-files`), 23472 bytes, sha256 | |
| 56 | + `c9e721088766163b9dbeb9fa8dd8b257ff0ec7f9157fc350de4d3c33cd9ec4e4` -- the first 50 | |
| 57 | + frame-carrying OBUs of the 2 s head cut. Cut TWICE from independent | |
| 58 | + `ffmpeg -ss 0 -t 2 ... -c:v copy -f obu` runs: both segments hashed | |
| 59 | + `96940689a8c6...` and both truncations hashed `c9e7210887...`. | |
| 60 | +* Gate `a_10bit_film_frames_with_intra_16x4_strips_and_rect64_corner_tus_decode_pixel_exact` | |
| 61 | + (stream.rs, after the intra14 gate): 33 decode-order frames, all three planes, hard | |
| 62 | + asserts on all five counters AND on ffmpeg's own frame count (no vacuous compare). | |
| 63 | +* Why the fixture is 50 OBUs and not the whole 2 s segment is stated in its doc comment: | |
| 64 | + the full segment diverges at frame 36, and the prefix is the exact one, not a | |
| 65 | + truncation chosen to hide that. | |
| 66 | +* **Neither refusal string leaves `refusal_inventory`** -- both are NARROWED. "a split | |
| 67 | + intra strip whose transform unit is {tx_w}x{tx_h}" still stands for every shape other | |
| 68 | + than 64x32/32x64; the 16x4/4x16 one still stands for a strip with no chroma-pair record | |
| 69 | + (and decode.rs:7390 is a separate string, untouched). `refusal_inventory` and all 12 | |
| 70 | + `gate_coverage` tests green with no edit. | |
| 71 | + | |
| 72 | +EVIDENCE: crates/ec-av1/fixtures/reelb_rect64_intra16x4_witness.obu | `cargo test -p ec-av1 --lib -- a_10bit_film_frames_with_intra_16x4 refusal_inventory gate_coverage` | `13 passed; 0 failed` in 62.64s, gate printed `33 frames pixel-exact, intra16x4_in_inter 16x4=31 4x16=17 chroma_ref=23, rect64_corner_tu 64x32=90 32x64=5` | |
| 73 | + | |
| 74 | +### Sibling sweep (COMMON's SIBLING GATES rule) -- found and fixed one | |
| 75 | + | |
| 76 | +`a_10bit_film_inter_frame_with_intra_1to4_strips_decodes_pixel_exact` was `#[ignore]`d | |
| 77 | +with the note "un-ignore when the 64x32/32x64 luma coefficient tables land". They landed | |
| 78 | +here, so it is un-ignored. Running it for the FIRST time (it had never executed) showed | |
| 79 | +its `frames.len() == 2` assert was an untested assumption: a raw | |
| 80 | +`ffmpeg -i <fixture> -pix_fmt yuv420p10le -f rawvideo` writes exactly 18524160 bytes = | |
| 81 | +ONE 3840x1608 10-bit frame, so the second frame OBU is a no-show. Corrected to 1, plus an | |
| 82 | +ffmpeg-frame-count equality assert so the compare cannot silently go vacuous. | |
| 83 | + | |
| 84 | +EVIDENCE: ~/.cache/sub8x4-tmp/{o,r}.raw on the intra14 fixture | release decode_probe + raw ffmpeg decode, diff16.py | 1 frame each side, `0:0` (zero differing bytes); gate green, `480 intra 1:4 strips in an inter frame, the shown frame pixel-exact` | |
| 85 | + | |
| 86 | +## STEP 4 -- full suite | |
| 87 | + | |
| 88 | +Unit `sub8x4-suite-r3-1788364529.service`, log `$HOME/.cache/sub8x4-suite-r3.log` | |
| 89 | +(private path per COMMON): | |
| 90 | + | |
| 91 | +`test result: FAILED. 422 passed; 2 failed; 37 ignored; 0 measured; 0 filtered out; finished in 676.59s` | |
| 92 | + | |
| 93 | +Against r2's `419 passed; 3 failed; 38 ignored`: +3 passed (the straddling gate the merge | |
| 94 | +fixed, plus this round's two film gates net of the un-ignore), -1 failed, -1 ignored (the | |
| 95 | +intra14 gate). The 2 remaining failures are the same two zero-COUNTER 1:4 recipe defects | |
| 96 | +r2 already carried, with the same messages; no new failure, no gate regressed. | |
| 97 | + | |
| 98 | +## Open residue | |
| 99 | + | |
| 100 | +* `fix-now (next round)` -- the head cut's wall at decode-order **frame 36**: 33 frames | |
| 101 | + are pinned and exact, frames 36..47 differ. No refusal fires, so this is a silent | |
| 102 | + reconstruction/entropy defect and the fixture at N=52/N=56 (still exact, 33/35 frames) | |
| 103 | + brackets it: N=58 (37 frames) is the smallest truncation that includes it. | |
| 104 | +* `deferred(a lane that owns the OBMC interp-filter record)` -- three of the four 1080p | |
| 105 | + 128-SB cuts now stop at "an OBMC neighbour whose switchable interp filter was never | |
| 106 | + recorded", which is not this lane's shape. | |
| 107 | +* `deferred(the 16x16-level 1:4 INTER partition itself)` -- decode.rs:7390, the OTHER | |
| 108 | + intra-16x4 refusal, on the inter block path; it is what the 8100 cut stops at and it is | |
| 109 | + refused before the partition this round unblocked. | |
| 110 | +* `accepted` -- the two zero-COUNTER 1:4 recipe defects (stream.rs:8884, :11002) are pure | |
| 111 | + gate-recipe defects carried in from before this lane and did not move this round. |