Merge branch 'lane-rectres' (a66f9a4): rectangular residual coding for non-skip 32x8/8x32 inter strips (the film's rect-residual wall)
Browse files at this commit6 changed files +420 -0
- crates/ec-av1/examples/decode_probe.rs +4 -0
- crates/ec-av1/src/cdf_state.rs +20 -0
- crates/ec-av1/src/decode.rs +39 -0
- crates/ec-av1/src/refusal_inventory.rs +6 -0
- crates/ec-av1/src/stream.rs +236 -0
- lanes/rectres-r1.report.md +115 -0
crates/ec-av1/examples/decode_probe.rsmodified+4 -0
| @@ -106,6 +106,10 @@ fn main() { | |||
| 106 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", | 106 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", |
| 107 | ir.0, ir.1, ir.2, ir.3, ir.4, ir.5 | 107 | ir.0, ir.1, ir.2, ir.3, ir.4, ir.5 |
| 108 | ); | 108 | ); |
| 109 | + // lane-rectres r1: how many of those 32x8/8x32 strips coded a real | ||
| 110 | + // rectangular residual transform unit (a skipped one codes none). | ||
| 111 | + let r328 = ec_av1::stream::rect32x8_inter_tu_hits(); | ||
| 112 | + println!("rect32x8_inter_tu: 32x8={} 8x32={}", r328[0], r328[1]); | ||
| 109 | }; | 113 | }; |
| 110 | // lane-tiles: the tiling a real stream actually uses is a decision input | 114 | // lane-tiles: the tiling a real stream actually uses is a decision input |
| 111 | // (every gate in `stream.rs` picks its own `--tile-columns`), so report it | 115 | // (every gate in `stream.rs` picks its own `--tile-columns`), so report it |
crates/ec-av1/src/cdf_state.rsmodified+20 -0
| @@ -118,6 +118,14 @@ pub(crate) enum TxbSet { | |||
| 118 | /// block, so the encoder writes none (same reason | 118 | /// block, so the encoder writes none (same reason |
| 119 | /// [`LumaRect32x16`](TxbSet::LumaRect32x16) has none). | 119 | /// [`LumaRect32x16`](TxbSet::LumaRect32x16) has none). |
| 120 | LumaRect32x8, | 120 | LumaRect32x8, |
| 121 | + /// lane-rectres r1: [`LumaRect32x8`](TxbSet::LumaRect32x8)'s INTER twin -- | ||
| 122 | + /// the 32x32-level 1:4 strip (`max_txsize_rect_lookup[BLOCK_32X8] == | ||
| 123 | + /// TX_32X8`). Same coefficient tables (`get_txsize_entropy_ctx` = TX_16X16, | ||
| 124 | + /// `txsize_log2_minus4` = 4, 256 positions), but an inter unit DOES code a | ||
| 125 | + /// `tx_type`: `av1_get_ext_tx_set_type` at `tx_size_sqr_up == TX_32X32` is | ||
| 126 | + /// `EXT_TX_SET_DCT_IDTX` for inter regardless of `reduced_tx_set`, read at | ||
| 127 | + /// the `txsize_sqr_map[TX_32X8] == TX_8X8` CDF row. | ||
| 128 | + LumaRect32x8Inter, | ||
| 121 | LumaRect32x16, | 129 | LumaRect32x16, |
| 122 | /// lane-inter4 r2: [`LumaRect32x16`](TxbSet::LumaRect32x16)'s INTER twin -- | 130 | /// lane-inter4 r2: [`LumaRect32x16`](TxbSet::LumaRect32x16)'s INTER twin -- |
| 123 | /// same coefficient tables (`get_txsize_entropy_ctx` reduces TX_32X16 and | 131 | /// same coefficient tables (`get_txsize_entropy_ctx` reduces TX_32X16 and |
| @@ -1761,6 +1769,18 @@ impl Cdfs { | |||
| 1761 | tx_type: None, | 1769 | tx_type: None, |
| 1762 | eob_pt_class1: Some(&mut self.eob_pt_1024_chroma_class1), | 1770 | eob_pt_class1: Some(&mut self.eob_pt_1024_chroma_class1), |
| 1763 | }, | 1771 | }, |
| 1772 | + TxbSet::LumaRect32x8Inter => TxbTables { | ||
| 1773 | + side: 16, | ||
| 1774 | + txb_skip: &mut self.txb_skip_luma_16, | ||
| 1775 | + eob_pt: &mut self.eob_pt_256_luma, | ||
| 1776 | + eob_extra: &mut self.eob_extra_luma_16, | ||
| 1777 | + base: &mut self.base_luma_16, | ||
| 1778 | + base_eob: &mut self.base_eob_luma_16, | ||
| 1779 | + br: &mut self.br_luma_16, | ||
| 1780 | + dc_sign: &mut self.dc_sign_luma, | ||
| 1781 | + tx_type: Some(self.inter_tx_type_8.as_mut_slice()), | ||
| 1782 | + eob_pt_class1: Some(&mut self.eob_pt_256_luma_class1), | ||
| 1783 | + }, | ||
| 1764 | TxbSet::LumaRect32x8 => TxbTables { | 1784 | TxbSet::LumaRect32x8 => TxbTables { |
| 1765 | side: 16, | 1785 | side: 16, |
| 1766 | txb_skip: &mut self.txb_skip_luma_16, | 1786 | txb_skip: &mut self.txb_skip_luma_16, |
crates/ec-av1/src/decode.rsmodified+39 -0
| @@ -1027,6 +1027,9 @@ thread_local! { | |||
| 1027 | // (64x32/32x64/64x16/16x64), whose coefficients are coded as the | 1027 | // (64x32/32x64/64x16/16x64), whose coefficients are coded as the |
| 1028 | // truncated low-32 corner. | 1028 | // truncated low-32 corner. |
| 1029 | static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 1029 | static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 1030 | + // lane-rectres r1: whole-block luma transform units of a 32x32-level 1:4 | ||
| 1031 | + // inter strip, `[32x8, 8x32]`. | ||
| 1032 | + static RECT32X8_INTER_TU_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; | ||
| 1030 | // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32]. | 1033 | // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32]. |
| 1031 | static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; | 1034 | static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; |
| 1032 | // lane-inter16ab r4: rectangular var-tx leaves with a 4-px axis, [8x4, 4x8] | 1035 | // lane-inter16ab r4: rectangular var-tx leaves with a 4-px axis, [8x4, 4x8] |
| @@ -1084,6 +1087,12 @@ pub(crate) fn rect64_inter_tu_hits() -> usize { | |||
| 1084 | RECT64_INTER_TU_HITS.with(|c| c.get()) | 1087 | RECT64_INTER_TU_HITS.with(|c| c.get()) |
| 1085 | } | 1088 | } |
| 1086 | 1089 | ||
| 1090 | +/// Current value of [`RECT32X8_INTER_TU_HITS`] (lane-rectres r1): `[32x8, 8x32]` | ||
| 1091 | +/// whole-block luma units of a 32x32-level 1:4 inter strip. | ||
| 1092 | +pub(crate) fn rect32x8_inter_tu_hits() -> [usize; 2] { | ||
| 1093 | + RECT32X8_INTER_TU_HITS.with(|c| c.get()) | ||
| 1094 | +} | ||
| 1095 | + | ||
| 1087 | /// Current value of [`VARTX_RECT_LEAF_HITS`] (lane-r14 r3): how many | 1096 | /// Current value of [`VARTX_RECT_LEAF_HITS`] (lane-r14 r3): how many |
| 1088 | /// rectangular var-tx leaf transform units were coded, `[32x16, 16x32]`. | 1097 | /// rectangular var-tx leaf transform units were coded, `[32x16, 16x32]`. |
| 1089 | pub(crate) fn vartx_rect_leaf_hits() -> [usize; 2] { | 1098 | pub(crate) fn vartx_rect_leaf_hits() -> [usize; 2] { |
| @@ -13622,6 +13631,13 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool { | |||
| 13622 | // TX_64X64 units read through the mu-chunk loop, same as the | 13631 | // TX_64X64 units read through the mu-chunk loop, same as the |
| 13623 | // 128x128 NONE block's four. | 13632 | // 128x128 NONE block's four. |
| 13624 | | (128, 64) | (64, 128) | 13633 | | (128, 64) | (64, 128) |
| 13634 | + // lane-rectres r1: the 32x32-level 1:4 strips -- THE shape both | ||
| 13635 | + // 10-bit film cuts and every measured 1080p offset stop on | ||
| 13636 | + // (measured: 6/6 probes refuse at 32x8 or 8x32, nothing else). | ||
| 13637 | + // `max_txsize_rect_lookup[BLOCK_32X8] == TX_32X8` codes all 256 | ||
| 13638 | + // positions, and its chroma pair is a 16x4 / 4x16 unit | ||
| 13639 | + // (`ss_size_lookup[BLOCK_32X8]` = BLOCK_16X4). | ||
| 13640 | + | (32, 8) | (8, 32) | ||
| 13625 | ) | 13641 | ) |
| 13626 | } | 13642 | } |
| 13627 | 13643 | ||
| @@ -13666,6 +13682,11 @@ fn rect_inter_luma_set(w: usize, h: usize) -> Result<TxbSet> { | |||
| 13666 | // `get_txsize_entropy_ctx`/`txsize_log2_minus4` agree with the | 13682 | // `get_txsize_entropy_ctx`/`txsize_log2_minus4` agree with the |
| 13667 | // adjusted size, so the existing sets are bit-exact. Neither carries a | 13683 | // adjusted size, so the existing sets are bit-exact. Neither carries a |
| 13668 | // `tx_type` table (DCT_ONLY above), so the intra/inter split is moot. | 13684 | // `tx_type` table (DCT_ONLY above), so the intra/inter split is moot. |
| 13685 | + // lane-rectres r1: `tx_size_sqr_up[TX_32X8] == TX_32X32`, so | ||
| 13686 | + // `av1_get_ext_tx_set_type` is `EXT_TX_SET_DCT_IDTX` for inter with or | ||
| 13687 | + // without `reduced_tx_set` -- one set, no `REDUCED_TX_SET_INTER` | ||
| 13688 | + // branch, read at the `txsize_sqr_map[TX_32X8] == TX_8X8` row. | ||
| 13689 | + (32, 8) | (8, 32) => TxbSet::LumaRect32x8Inter, | ||
| 13669 | (64, 32) | (32, 64) => TxbSet::Luma64, | 13690 | (64, 32) | (32, 64) => TxbSet::Luma64, |
| 13670 | (64, 16) | (16, 64) => TxbSet::LumaRect32x16, | 13691 | (64, 16) | (16, 64) => TxbSet::LumaRect32x16, |
| 13671 | _ => { | 13692 | _ => { |
| @@ -13691,6 +13712,10 @@ fn rect_inter_chroma_set(w: usize, h: usize) -> Result<TxbSet> { | |||
| 13691 | // `txsize_log2_minus4` = 4), same as the intra strip path uses. | 13712 | // `txsize_log2_minus4` = 4), same as the intra strip path uses. |
| 13692 | (32, 16) | (16, 32) => TxbSet::ChromaRect32x16, | 13713 | (32, 16) | (16, 32) => TxbSet::ChromaRect32x16, |
| 13693 | (32, 8) | (8, 32) => TxbSet::Chroma16, | 13714 | (32, 8) | (8, 32) => TxbSet::Chroma16, |
| 13715 | + // lane-rectres r1: chroma of a 32x8/8x32 strip. `Chroma8` is the exact | ||
| 13716 | + // set for TX_16X4/TX_4X16 (`get_txsize_entropy_ctx` = TX_8X8, | ||
| 13717 | + // `txsize_log2_minus4` = 2, 64-coefficient `eob_pt`). | ||
| 13718 | + (16, 4) | (4, 16) => TxbSet::Chroma8, | ||
| 13694 | _ => { | 13719 | _ => { |
| 13695 | return Err(unsupported( | 13720 | return Err(unsupported( |
| 13696 | "a rectangular inter chroma transform unit whose shape has no coefficient table set here", | 13721 | "a rectangular inter chroma transform unit whose shape has no coefficient table set here", |
| @@ -13945,6 +13970,13 @@ fn read_inter_plane_rect( | |||
| 13945 | if plane_idx == 0 && w.max(h) == 64 { | 13970 | if plane_idx == 0 && w.max(h) == 64 { |
| 13946 | RECT64_INTER_TU_HITS.with(|c| c.set(c.get() + 1)); | 13971 | RECT64_INTER_TU_HITS.with(|c| c.set(c.get() + 1)); |
| 13947 | } | 13972 | } |
| 13973 | + if plane_idx == 0 && (w, h) == (32, 8) || plane_idx == 0 && (w, h) == (8, 32) { | ||
| 13974 | + RECT32X8_INTER_TU_HITS.with(|c| { | ||
| 13975 | + let mut v = c.get(); | ||
| 13976 | + v[usize::from(w == 8)] += 1; | ||
| 13977 | + c.set(v); | ||
| 13978 | + }); | ||
| 13979 | + } | ||
| 13948 | let (corner, tx_type) = if (cw, ch) == (32, 32) { | 13980 | let (corner, tx_type) = if (cw, ch) == (32, 32) { |
| 13949 | let scan32 = default_scan(TX32); | 13981 | let scan32 = default_scan(TX32); |
| 13950 | read_coeffs( | 13982 | read_coeffs( |
| @@ -19191,6 +19223,13 @@ fn decode_inter_block( | |||
| 19191 | && !rect_inter_residual_supported(write_w, write_h) | 19223 | && !rect_inter_residual_supported(write_w, write_h) |
| 19192 | && (is_inter || (write_w == side && write_h == side)) | 19224 | && (is_inter || (write_w == side && write_h == side)) |
| 19193 | { | 19225 | { |
| 19226 | + if std::env::var_os("EC_RECTRES").is_some() { | ||
| 19227 | + eprintln!( | ||
| 19228 | + "EC_RECTRES w={write_w} h={write_h} side={side} skip={} is_inter={} mi_row={rmi} mi_col={cmi}", | ||
| 19229 | + u8::from(skip), | ||
| 19230 | + u8::from(is_inter) | ||
| 19231 | + ); | ||
| 19232 | + } | ||
| 19194 | return Err(unsupported( | 19233 | return Err(unsupported( |
| 19195 | "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", | 19234 | "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", |
| 19196 | )); | 19235 | )); |
crates/ec-av1/src/refusal_inventory.rsmodified+6 -0
| @@ -58,6 +58,12 @@ const REFUSALS: &[&str] = &[ | |||
| 58 | "a frame naming primary_ref_frame at a reference slot with no saved CDF state", | 58 | "a frame naming primary_ref_frame at a reference slot with no saved CDF state", |
| 59 | "a frame with no mode-info grid", | 59 | "a frame with no mode-info grid", |
| 60 | "a frame whose segmentation enables SEG_LVL_REF_FRAME/SKIP/GLOBALMV (this decoder reads segment_id but never lets a segment override a block's reference, skip or mode)", | 60 | "a frame whose segmentation enables SEG_LVL_REF_FRAME/SKIP/GLOBALMV (this decoder reads segment_id but never lets a segment override a block's reference, skip or mode)", |
| 61 | + // Still live, but NARROWED: lane-rectres r1 added the 32x32-level 1:4 | ||
| 62 | + // strips (32x8 / 8x32) to `rect_inter_residual_supported` -- THE shape both | ||
| 63 | + // 10-bit 3840x1608 film cuts and every measured 1080p offset stopped on | ||
| 64 | + // (gate `a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_codes_\ | ||
| 65 | + // their_rect_residual`). The string stays because the shapes below 8x8 and | ||
| 66 | + // the AB-partition footprints still have no rectangular residual path. | ||
| 61 | "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", | 67 | "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding", |
| 62 | "a reference frame selected with no picture at this frame's own ref_frame_idx slot for it", | 68 | "a reference frame selected with no picture at this frame's own ref_frame_idx slot for it", |
| 63 | "a reference picture whose height does not match this frame's own true size", | 69 | "a reference picture whose height does not match this frame's own true size", |
crates/ec-av1/src/stream.rsmodified+236 -0
| @@ -74,6 +74,12 @@ pub fn rect64_inter_tu_hits() -> usize { | |||
| 74 | crate::decode::rect64_inter_tu_hits() | 74 | crate::decode::rect64_inter_tu_hits() |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | +/// lane-rectres r1: whole-block luma transform units of a 32x32-level 1:4 | ||
| 78 | +/// inter strip (`TX_32X8`/`TX_8X32`), `[32x8, 8x32]`. | ||
| 79 | +pub fn rect32x8_inter_tu_hits() -> [usize; 2] { | ||
| 80 | + crate::decode::rect32x8_inter_tu_hits() | ||
| 81 | +} | ||
| 82 | + | ||
| 77 | /// lane-r14 r3: RECTANGULAR var-tx leaf transform units, `[32x16, 16x32]` -- | 83 | /// lane-r14 r3: RECTANGULAR var-tx leaf transform units, `[32x16, 16x32]` -- |
| 78 | /// the leaves `sub_tx_size_map` produces when a 1:4 strip with a 64-px axis | 84 | /// the leaves `sub_tx_size_map` produces when a 1:4 strip with a 64-px axis |
| 79 | /// splits its transform (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`). | 85 | /// splits its transform (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`). |
| @@ -8864,6 +8870,236 @@ mod tests { | |||
| 8864 | } | 8870 | } |
| 8865 | } | 8871 | } |
| 8866 | 8872 | ||
| 8873 | + /// lane-rectres r1: a 32x32-level 1:4 INTER strip (32x8 / 8x32) that codes | ||
| 8874 | + /// a REAL rectangular residual. THIS is the shape both 10-bit 3840x1608 | ||
| 8875 | + /// film cuts and every measured 1080p offset stopped on -- six of six | ||
| 8876 | + /// `decode_probe` runs refused at "a non-skip rectangular (HORZ/VERT/ | ||
| 8877 | + /// HORZ_B) strip needs rectangular residual coding" with `w=32 h=8` or | ||
| 8878 | + /// `w=8 h=32`, nothing else. | ||
| 8879 | + /// | ||
| 8880 | + /// `max_txsize_rect_lookup[BLOCK_32X8] == TX_32X8` codes all 256 of its | ||
| 8881 | + /// positions ([`TxbSet::LumaRect32x8Inter`]: `get_txsize_entropy_ctx` = | ||
| 8882 | + /// TX_16X16 so the coefficient tables are the luma-16 ones, | ||
| 8883 | + /// `txsize_log2_minus4` = 4 so `eob_pt` is the 256-position alphabet), and | ||
| 8884 | + /// unlike the INTRA twin it DOES code a `tx_type`: | ||
| 8885 | + /// `av1_get_ext_tx_set_type` at `tx_size_sqr_up == TX_32X32` is | ||
| 8886 | + /// `EXT_TX_SET_DCT_IDTX` for inter with or without `reduced_tx_set`, read | ||
| 8887 | + /// at the `txsize_sqr_map[TX_32X8] == TX_8X8` CDF row (class | ||
| 8888 | + /// table-indexed-by-raw-size: the coefficient tables follow the ADJUSTED | ||
| 8889 | + /// size, the `tx_type` row the SQUARE one -- they disagree here). | ||
| 8890 | + /// Its chroma pair is one 16x4 / 4x16 unit (`ss_size_lookup[BLOCK_32X8]` | ||
| 8891 | + /// = BLOCK_16X4, `Chroma8`'s tables, 64-position `eob_pt`), and a split | ||
| 8892 | + /// transform gives 16x8 / 8x16 leaves (`sub_tx_size_map[TX_32X8] == | ||
| 8893 | + /// TX_16X8`) the rect var-tx path already reads. | ||
| 8894 | + /// | ||
| 8895 | + /// `--enable-1to4-partitions=1 --min-partition-size=8 | ||
| 8896 | + /// --max-partition-size=32 --enable-tx-size-search=1` (each spelled once, | ||
| 8897 | + /// last occurrence wins -- aomenc keeps the LAST `--enable-*`) is what | ||
| 8898 | + /// lets aomenc pick a 32x32-level HORZ_4 / VERT_4; the 8-pixel banded | ||
| 8899 | + /// translating source is what makes those strips the RD winner and keeps | ||
| 8900 | + /// them non-skip so the residual is really coded. Both orientations, 8-bit | ||
| 8901 | + /// AND 10-bit, every decode-order frame compared to ffmpeg on Y/U/V, | ||
| 8902 | + /// refusals counted (never SKIPped), attempts that carried no 32x8/8x32 | ||
| 8903 | + /// residual unit counted separately and still required pixel-exact. | ||
| 8904 | + #[test] | ||
| 8905 | + fn a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_codes_their_rect_residual() { | ||
| 8906 | + const NAME: &str = | ||
| 8907 | + "a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_codes_their_rect_residual"; | ||
| 8908 | + let _gate_lock = lock_gate_counters(); | ||
| 8909 | + if !have_ffmpeg() { | ||
| 8910 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 8911 | + return; | ||
| 8912 | + } | ||
| 8913 | + if !have_aomenc() { | ||
| 8914 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 8915 | + return; | ||
| 8916 | + } | ||
| 8917 | + let frame_count = 6usize; | ||
| 8918 | + let (mut proved_32x8, mut proved_8x32) = (0usize, 0usize); | ||
| 8919 | + let (mut fired_32x8, mut fired_8x32) = (0usize, 0usize); | ||
| 8920 | + for bit_depth in [8u32, 10u32] { | ||
| 8921 | + let (mut named_refusals, mut compared, mut out_of_scope, mut oos_mismatch) = | ||
| 8922 | + (0u32, 0u32, 0u32, 0u32); | ||
| 8923 | + for attempt in 0..16u32 { | ||
| 8924 | + // Two orientations (the transposed pair a one-sided gate could | ||
| 8925 | + // never separate) x four quantisers x two motion steps. | ||
| 8926 | + let vertical = attempt % 2 == 1; | ||
| 8927 | + let (width, height) = (192usize, 128usize); | ||
| 8928 | + let cq = [48, 52, 56, 60][(attempt / 2 % 4) as usize]; | ||
| 8929 | + let sp = 3 + (attempt / 8) * 4; | ||
| 8930 | + // 32-pixel bands, each translating at its OWN speed across the | ||
| 8931 | + // other axis: that is what makes aomenc's RD split a 32x32 | ||
| 8932 | + // block into four 32x8 (or 8x32) strips with distinct motion | ||
| 8933 | + // vectors, and the texture inside a band is what keeps a strip | ||
| 8934 | + // non-skip. MEASURED (72-run recipe sweep, 192x128..256x192, | ||
| 8935 | + // cq 24..60, bands 8/16/32/64): only 32-pixel bands at cq >= 48 | ||
| 8936 | + // make aomenc code a NON-SKIP one -- attempt 0 (cq 48, | ||
| 8937 | + // horizontal source) codes an 8x32 residual unit, attempt 7 | ||
| 8938 | + // (cq 60, the transposed source) five 32x8 ones. Narrower | ||
| 8939 | + // bands give the same strips with `skip` set, which proves the | ||
| 8940 | + // partition symbol and nothing about the residual. | ||
| 8941 | + let geq = if vertical { | ||
| 8942 | + format!("128+62*sin((Y+N*({sp}+7*mod(floor(X/32),4)))/6)+28*sin(X/9)") | ||
| 8943 | + } else { | ||
| 8944 | + format!("128+62*sin((X+N*({sp}+7*mod(floor(Y/32),4)))/6)+28*sin(Y/9)") | ||
| 8945 | + }; | ||
| 8946 | + let duration = frame_count as f64 / 25.0; | ||
| 8947 | + let source = format!( | ||
| 8948 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | ||
| 8949 | + geq=lum='{geq}',format=yuv420p" | ||
| 8950 | + ); | ||
| 8951 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 8952 | + let y4m = Command::new("ffmpeg") | ||
| 8953 | + .args([ | ||
| 8954 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | ||
| 8955 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 8956 | + ]) | ||
| 8957 | + .stdin(Stdio::null()) | ||
| 8958 | + .stdout(Stdio::piped()) | ||
| 8959 | + .stderr(Stdio::piped()) | ||
| 8960 | + .output() | ||
| 8961 | + .expect("ffmpeg failed to run"); | ||
| 8962 | + assert!( | ||
| 8963 | + y4m.status.success(), | ||
| 8964 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 8965 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 8966 | + ); | ||
| 8967 | + let cq_arg = format!("--cq-level={cq}"); | ||
| 8968 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 8969 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 8970 | + let args: Vec<&str> = vec![ | ||
| 8971 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", | ||
| 8972 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | ||
| 8973 | + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", | ||
| 8974 | + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", | ||
| 8975 | + "--lag-in-frames=0", | ||
| 8976 | + // Per-arm overrides go LAST: aomenc keeps the last | ||
| 8977 | + // occurrence of a repeated --enable-* flag. | ||
| 8978 | + "--enable-tx64=0", "--enable-rect-partitions=1", | ||
| 8979 | + "--enable-ab-partitions=0", "--enable-1to4-partitions=1", | ||
| 8980 | + "--enable-tx-size-search=1", | ||
| 8981 | + "--enable-dual-filter=0", "--enable-obmc=0", | ||
| 8982 | + // aomenc's min-partition-size bounds the SMALLER side of a | ||
| 8983 | + // 1:4 strip, so 32x8 needs 8 (memory | ||
| 8984 | + // aomenc-min-partition-bounds-smaller-side). | ||
| 8985 | + "--min-partition-size=8", "--max-partition-size=32", | ||
| 8986 | + "--obu", "-o", "-", "-", | ||
| 8987 | + ]; | ||
| 8988 | + let mut child = Command::new(aomenc_path()) | ||
| 8989 | + .args(&args) | ||
| 8990 | + .stdin(Stdio::piped()) | ||
| 8991 | + .stdout(Stdio::piped()) | ||
| 8992 | + .stderr(Stdio::piped()) | ||
| 8993 | + .spawn() | ||
| 8994 | + .expect("aomenc failed to start"); | ||
| 8995 | + child | ||
| 8996 | + .stdin | ||
| 8997 | + .take() | ||
| 8998 | + .expect("aomenc stdin") | ||
| 8999 | + .write_all(&y4m.stdout) | ||
| 9000 | + .expect("writing y4m to aomenc"); | ||
| 9001 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 9002 | + assert!( | ||
| 9003 | + out.status.success(), | ||
| 9004 | + "aomenc refused the fixture: {}", | ||
| 9005 | + String::from_utf8_lossy(&out.stderr) | ||
| 9006 | + ); | ||
| 9007 | + let stream = out.stdout; | ||
| 9008 | + let before = crate::stream::rect32x8_inter_tu_hits(); | ||
| 9009 | + let frames = match decode_stream(&stream) { | ||
| 9010 | + Err(e) => { | ||
| 9011 | + let msg = e.to_string(); | ||
| 9012 | + assert!( | ||
| 9013 | + msg.contains("unsupported"), | ||
| 9014 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ | ||
| 9015 | + attempt {attempt}): {msg}" | ||
| 9016 | + ); | ||
| 9017 | + let after = crate::stream::rect32x8_inter_tu_hits(); | ||
| 9018 | + // Firing counted on a refused stream is kept apart from | ||
| 9019 | + // the pixel-proved tally (class | ||
| 9020 | + // counter-from-refused-stream). | ||
| 9021 | + fired_32x8 += after[0] - before[0]; | ||
| 9022 | + fired_8x32 += after[1] - before[1]; | ||
| 9023 | + named_refusals += 1; | ||
| 9024 | + eprintln!( | ||
| 9025 | + "{NAME} {bit_depth}-bit attempt {attempt} refusal (32x8 residual \ | ||
| 9026 | + units decoded before it: {}, 8x32: {}): {msg}", | ||
| 9027 | + after[0] - before[0], | ||
| 9028 | + after[1] - before[1] | ||
| 9029 | + ); | ||
| 9030 | + continue; | ||
| 9031 | + } | ||
| 9032 | + Ok(frames) => frames, | ||
| 9033 | + }; | ||
| 9034 | + let after = crate::stream::rect32x8_inter_tu_hits(); | ||
| 9035 | + let (h, v) = (after[0] - before[0], after[1] - before[1]); | ||
| 9036 | + fired_32x8 += h; | ||
| 9037 | + fired_8x32 += v; | ||
| 9038 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 9039 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 9040 | + } else { | ||
| 9041 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 9042 | + }; | ||
| 9043 | + assert_eq!(frames.len(), frame_count); | ||
| 9044 | + let mismatched = frames | ||
| 9045 | + .iter() | ||
| 9046 | + .zip(&ffmpeg_frames) | ||
| 9047 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | ||
| 9048 | + if h + v == 0 { | ||
| 9049 | + out_of_scope += 1; | ||
| 9050 | + if mismatched { | ||
| 9051 | + oos_mismatch += 1; | ||
| 9052 | + eprintln!( | ||
| 9053 | + "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \ | ||
| 9054 | + 32x8/8x32 inter residual units -- another shape's defect" | ||
| 9055 | + ); | ||
| 9056 | + } | ||
| 9057 | + continue; | ||
| 9058 | + } | ||
| 9059 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 9060 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); | ||
| 9061 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); | ||
| 9062 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); | ||
| 9063 | + } | ||
| 9064 | + proved_32x8 += h; | ||
| 9065 | + proved_8x32 += v; | ||
| 9066 | + compared += 1; | ||
| 9067 | + } | ||
| 9068 | + eprintln!( | ||
| 9069 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {compared} \ | ||
| 9070 | + pixel-exact attempts carrying the arm, {out_of_scope} attempts carried none \ | ||
| 9071 | + ({oos_mismatch} of them mismatched)" | ||
| 9072 | + ); | ||
| 9073 | + assert_eq!( | ||
| 9074 | + oos_mismatch, 0, | ||
| 9075 | + "{NAME}: {oos_mismatch} attempt(s) with no 32x8/8x32 inter residual unit \ | ||
| 9076 | + decoded but mismatched ffmpeg -- a defect of another shape, not a pass" | ||
| 9077 | + ); | ||
| 9078 | + assert!( | ||
| 9079 | + compared + out_of_scope > 0, | ||
| 9080 | + "{NAME} ({bit_depth}-bit): every attempt refused -- the gate compared no pixels" | ||
| 9081 | + ); | ||
| 9082 | + } | ||
| 9083 | + eprintln!( | ||
| 9084 | + "{NAME}: pixel-compared 32x32-level 1:4 inter residual units 32x8={proved_32x8} \ | ||
| 9085 | + 8x32={proved_8x32} (decoded anywhere in the sweep 32x8={fired_32x8} \ | ||
| 9086 | + 8x32={fired_8x32})" | ||
| 9087 | + ); | ||
| 9088 | + // The firing half, one assert per lifted shape. Both orientations must | ||
| 9089 | + // be PIXEL-PROVED: a transposed table passes one and fails the other | ||
| 9090 | + // (class reference-layout-not-spec). | ||
| 9091 | + assert!( | ||
| 9092 | + proved_32x8 > 0, | ||
| 9093 | + "{NAME}: no 32x8 inter residual transform unit was decoded inside a pixel-exact \ | ||
| 9094 | + attempt (decoded anywhere: {fired_32x8}) -- the lift is unproved" | ||
| 9095 | + ); | ||
| 9096 | + assert!( | ||
| 9097 | + proved_8x32 > 0, | ||
| 9098 | + "{NAME}: no 8x32 inter residual transform unit was decoded inside a pixel-exact \ | ||
| 9099 | + attempt (decoded anywhere: {fired_8x32}) -- the lift is unproved" | ||
| 9100 | + ); | ||
| 9101 | + } | ||
| 9102 | + | ||
| 8867 | /// lane-sbrect10 r1: a 64x64 INTRA block inside an INTER frame, whose | 9103 | /// lane-sbrect10 r1: a 64x64 INTRA block inside an INTER frame, whose |
| 8868 | /// `uv_mode` alphabet libaom's `is_cfl_allowed` (`blockd.h`: `wide <= 32 | 9104 | /// `uv_mode` alphabet libaom's `is_cfl_allowed` (`blockd.h`: `wide <= 32 |
| 8869 | /// && high <= 32`) narrows to the 13-symbol NO-CFL table. Reading the | 9105 | /// && high <= 32`) narrows to the 13-symbol NO-CFL table. Reading the |
lanes/rectres-r1.report.mdadded+115 -0
| @@ -0,0 +1,115 @@ | |||
| 1 | +# lane-rectres r1 — the 32x32-level 1:4 inter strip's rectangular residual | ||
| 2 | + | ||
| 3 | +## Step 1 MEASURE — the shape histogram (this is the whole finding) | ||
| 4 | + | ||
| 5 | +An env-gated one-liner at the refusal site (`crates/ec-av1/src/decode.rs`, in the | ||
| 6 | +`reject_residual` block, `EC_RECTRES=1`) prints `(w, h, side, skip, is_inter, mi_row, mi_col)`. | ||
| 7 | +Six probes, `EC_RECT64_SPLIT=1 EC_RECTRES=1`, each under `systemd-run --scope -p MemoryMax=6G`: | ||
| 8 | + | ||
| 9 | +| stream | refusing shape | skip | is_inter | at | | ||
| 10 | +|---|---|---|---|---| | ||
| 11 | +| 10-bit 3840x1608 cut 0 | **32x8** | 0 | 1 | mi 16,744 | | ||
| 12 | +| 10-bit 3840x1608 cut 300 | **32x8** | 0 | 1 | mi 0,64 | | ||
| 13 | +| 10-bit 1920x792 @900 | **8x32** | 0 | 1 | mi 24,148 | | ||
| 14 | +| 10-bit 1920x792 @5400 | **32x8** | 0 | 1 | mi 20,448 | | ||
| 15 | +| 10-bit 1920x792 @6300 | **8x32** | 0 | 1 | mi 0,56 | | ||
| 16 | +| 10-bit 1920x792 @8100 | **32x8** | 0 | 1 | mi 10,184 | | ||
| 17 | + | ||
| 18 | +6 of 6 are the 32x32-level 1:4 strip. No 64-axis shape, no AB footprint, nothing else. | ||
| 19 | +The charter's "most likely 32x64/64x32 and 64x16/16x64" premise is WRONG for these films — | ||
| 20 | +those shapes are already supported and the films never stop on them. | ||
| 21 | + | ||
| 22 | +EVIDENCE: shell probe, 6 streams | `EC_RECT64_SPLIT=1 EC_RECTRES=1 decode_probe <cut>` | histogram above, 32x8 x4 / 8x32 x2, 0 other shapes | ||
| 23 | + | ||
| 24 | +## Step 2 IMPLEMENT — one shape family | ||
| 25 | + | ||
| 26 | +`max_txsize_rect_lookup[BLOCK_32X8] == TX_32X8`, all 256 positions coded. | ||
| 27 | + | ||
| 28 | +* `crates/ec-av1/src/cdf_state.rs` — new `TxbSet::LumaRect32x8Inter`: the existing INTRA | ||
| 29 | + `LumaRect32x8` tables (`get_txsize_entropy_ctx(TX_32X8)` = TX_16X16 -> luma-16 coefficient | ||
| 30 | + tables; `txsize_log2_minus4` = 4 -> 256-position `eob_pt`) **plus** a `tx_type` table the | ||
| 31 | + intra twin has none of. `av1_get_ext_tx_set_type` at `tx_size_sqr_up == TX_32X32` is | ||
| 32 | + `EXT_TX_SET_DCT_IDTX` for inter with *or without* `reduced_tx_set` (no branch), read at the | ||
| 33 | + `txsize_sqr_map[TX_32X8] == TX_8X8` row -> `inter_tx_type_8`. Class | ||
| 34 | + `table-indexed-by-raw-size`: the coefficient tables follow the ADJUSTED size and the | ||
| 35 | + `tx_type` row the SQUARE one, and here the two disagree. | ||
| 36 | +* `crates/ec-av1/src/decode.rs` `rect_inter_residual_supported` — `+ (32, 8) | (8, 32)`. | ||
| 37 | +* `crates/ec-av1/src/decode.rs` `rect_inter_luma_set` — `(32, 8) | (8, 32) => LumaRect32x8Inter`. | ||
| 38 | +* `crates/ec-av1/src/decode.rs` `rect_inter_chroma_set` — `(16, 4) | (4, 16) => Chroma8` | ||
| 39 | + (`ss_size_lookup[BLOCK_32X8]` = BLOCK_16X4; TX_16X4 entropy ctx = TX_8X8, 64-position `eob_pt`). | ||
| 40 | +* Counter `RECT32X8_INTER_TU_HITS` `[32x8, 8x32]` + `stream::rect32x8_inter_tu_hits()`, and | ||
| 41 | + `decode_probe` prints `rect32x8_inter_tu:`. | ||
| 42 | + | ||
| 43 | +Nothing else was needed: `SCAN_32X8`/`SCAN_8X32` already exist (the intra strip path uses them), | ||
| 44 | +`sub_tx_size_map(32,8) == (16,8)` is an already-supported rect var-tx leaf, and | ||
| 45 | +`read_inter_plane_rect`/`read_coeffs_rect` are shape-general. | ||
| 46 | + | ||
| 47 | +## Step 3 GATE | ||
| 48 | + | ||
| 49 | +`a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips_codes_their_rect_residual` | ||
| 50 | +(`crates/ec-av1/src/stream.rs`) — real aomenc, `--enable-1to4-partitions=1 | ||
| 51 | +--enable-rect-partitions=1 --enable-tx-size-search=1 --min-partition-size=8 | ||
| 52 | +--max-partition-size=32` (per-arm overrides last: aomenc keeps the last `--enable-*`), | ||
| 53 | +16 attempts x {8-bit, 10-bit}, both orientations, every decode-order frame compared on Y/U/V | ||
| 54 | +against ffmpeg, refusals counted never SKIPped, `oos_mismatch == 0` asserted, and one | ||
| 55 | +hard assert per lifted shape on the PIXEL-COMPARED counter (a refused stream's hits are | ||
| 56 | +tallied separately, class `counter-from-refused-stream`). | ||
| 57 | + | ||
| 58 | +Recipe found by a 72-run sweep (192x128..256x192, cq 24..60, bands 8/16/32/64): only | ||
| 59 | +**32-pixel** motion bands at **cq >= 48** make aomenc code a NON-SKIP 32x32-level 1:4 strip. | ||
| 60 | +Narrower bands give the same strips with `skip` set — they prove the partition symbol and | ||
| 61 | +nothing about the residual (class `gate-blind-to-feature`). | ||
| 62 | + | ||
| 63 | +``` | ||
| 64 | +cargo test -p ec-av1 --lib a_real_aomenc_inter_sequence_with_32x32_level_1to4_strips -- --nocapture | ||
| 65 | +8-bit : 0 named refusals, 5 pixel-exact attempts carrying the arm, 11 carried none (0 mismatched) | ||
| 66 | +10-bit: 0 named refusals, 4 pixel-exact attempts carrying the arm, 12 carried none (0 mismatched) | ||
| 67 | +pixel-compared units 32x8=7 8x32=8 (decoded anywhere 32x8=7 8x32=8) | ||
| 68 | +test result: ok. 1 passed; 0 failed | ||
| 69 | +``` | ||
| 70 | + | ||
| 71 | +EVIDENCE: /home/user/.cache/rectres-gate2.log | aomenc 32 streams (8+10 bit) -> decode -> ffmpeg Y/U/V compare | 15 pixel-compared 32x8/8x32 residual TUs, 0 mismatches | ||
| 72 | + | ||
| 73 | +`refusal_inventory.rs`: the string stays (sub-8x8 and AB footprints still have no rect | ||
| 74 | +residual path) with a comment recording the narrowing. `gate_coverage.rs` needs no change — | ||
| 75 | +it derives from `--enable-*` flags and this gate turns no tool off that others turn on. | ||
| 76 | + | ||
| 77 | +## Film frontier — before / after | ||
| 78 | + | ||
| 79 | +hg cut 0 (10-bit 3840x1608, 73 frame OBUs): **33 shown frames before, 33 after.** The gain is | ||
| 80 | +INSIDE frame 34, not across frames: at prefix 50 that frame now decodes a 32x8 residual unit | ||
| 81 | +(`rect32x8_inter_tu: 32x8=1`) and stops on a *different* wall — | ||
| 82 | +`an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition`. All six cuts moved to | ||
| 83 | +that same next refusal. So this lane removed one of at least two refusals in the films' | ||
| 84 | +first blocking frame; the shown-frame count cannot move until the other lane lands. | ||
| 85 | + | ||
| 86 | +EVIDENCE: /home/user/.cache/rectres-bisect.log + probe on the 50-OBU prefix | trunc.py bisect over frame-OBU prefixes, decode_probe each | max OK prefix 49 OBUs = 33 shown frames; prefix 50 refuses on the intra-1:4 wall after coding one 32x8 residual TU | ||
| 87 | + | ||
| 88 | +## rect64 refusal — NOT lifted | ||
| 89 | + | ||
| 90 | +deferred: removing the `EC_RECT64_SPLIT` bypass — no witness exists. The 49-OBU prefix that | ||
| 91 | +decodes clean reports `rect64_corner_tu: 64x32=0 32x64=0`; every rect64 hit (22 + 4) lives | ||
| 92 | +inside the frame that still refuses on the intra 16x4/4x16 wall. Confirms the ledger dead-end | ||
| 93 | +`lane-rect64port r1`. Unblocked by: the intra-16x4/4x16-in-inter-1:4 lane. | ||
| 94 | + | ||
| 95 | +## Suite — INCOMPLETE at the turn cap | ||
| 96 | + | ||
| 97 | +`systemd-run --user --unit=rectres-suite-r1-... -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3` | ||
| 98 | +(log `$HOME/.cache/rectres-suite-r1.log`) was still running when the cap hit: 1259 log lines, | ||
| 99 | +no `^test result` line yet. **The full-suite result is UNKNOWN — not claimed green.** | ||
| 100 | +What DID run and pass: `cargo test -p ec-av1 --lib --no-run` (compiles) and the new gate alone, | ||
| 101 | +`test result: ok. 1 passed; 0 failed; 457 filtered out`. | ||
| 102 | + | ||
| 103 | +## Exact next step | ||
| 104 | + | ||
| 105 | +1. `grep -E "^test result|^failures:" -A20 $HOME/.cache/rectres-suite-r1.log` — the unit is still | ||
| 106 | + live; if it died, re-arm the same command. Expected known reds (from main 7e6d60b, unrelated | ||
| 107 | + to this lane): `a_frame_edge_straddling_band`, | ||
| 108 | + `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions`, | ||
| 109 | + `real_aomenc_1to4_streams_..._rect_vartx_leaves_fire`. Anything else is this commit's. | ||
| 110 | + Re-run the two SIBLING gates by name first (they share `rect_inter_luma_set` / | ||
| 111 | + `rect_inter_chroma_set` / `read_inter_plane_rect`): `real_aomenc_1to4_streams_...` and | ||
| 112 | + `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions`. | ||
| 113 | +2. Then the next film wall is a DIFFERENT lane's shape: `an intra 16x4/4x16 strip inside an | ||
| 114 | + inter 16x16-level 1:4 partition (its 4:2:0 chroma pair is coded once for two strips; only | ||
| 115 | + the inter path implements that pairing)` — all six cuts now stop there. | ||