Per-transform-unit intra prediction inside a rect strip, at mi granularity
Browse files at this commitc8cc7efd632fb1a73fbaa371045de9e36d8afbc9Parent: 473c744- feat
- per-transform-unit intra prediction inside a rect strip, at mi granularity
4 changed files +588 -86
- crates/ec-av1/src/decode.rs +400 -62
- crates/ec-av1/src/refusal_inventory.rs +2 -1
- crates/ec-av1/src/stream.rs +81 -23
- lanes/rectsplitx-r1.report.md +105 -0
crates/ec-av1/src/decode.rsmodified+400 -62
| @@ -1629,6 +1629,30 @@ thread_local! { | |||
| 1629 | static RECT4_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | 1629 | static RECT4_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 1630 | } | 1630 | } |
| 1631 | 1631 | ||
| 1632 | +// lane-rectsplitx r1: 1:4 strips (32x8/8x32/64x16/16x64) decoded through the | ||
| 1633 | +// per-transform-unit split path, split by tx depth -- depth 1 is a 2:1 RECT | ||
| 1634 | +// unit (TX_16X8/TX_32X16), depth 2 a square one, and the two INTERLEAVE in | ||
| 1635 | +// every real stream, so a gate must prove both fired. `SUB16_SPLIT_HITS` | ||
| 1636 | +// counts the same for a 16x8/8x16 strip below 16x16. | ||
| 1637 | +thread_local! { | ||
| 1638 | + static RECT4_SPLIT_DEPTH1_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1639 | + static RECT4_SPLIT_DEPTH2_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1640 | + static SUB16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 1641 | +} | ||
| 1642 | + | ||
| 1643 | +/// Current values of `RECT4_SPLIT_DEPTH1_HITS` / `RECT4_SPLIT_DEPTH2_HITS`. | ||
| 1644 | +pub(crate) fn rect4_split_depth_hits() -> (usize, usize) { | ||
| 1645 | + ( | ||
| 1646 | + RECT4_SPLIT_DEPTH1_HITS.with(|c| c.get()), | ||
| 1647 | + RECT4_SPLIT_DEPTH2_HITS.with(|c| c.get()), | ||
| 1648 | + ) | ||
| 1649 | +} | ||
| 1650 | + | ||
| 1651 | +/// Current value of `SUB16_SPLIT_HITS`. | ||
| 1652 | +pub(crate) fn sub16_split_hits() -> usize { | ||
| 1653 | + SUB16_SPLIT_HITS.with(|c| c.get()) | ||
| 1654 | +} | ||
| 1655 | + | ||
| 1632 | /// Current value of `RECT4_COEFF_HITS`. | 1656 | /// Current value of `RECT4_COEFF_HITS`. |
| 1633 | pub(crate) fn rect4_coeff_hits() -> usize { | 1657 | pub(crate) fn rect4_coeff_hits() -> usize { |
| 1634 | RECT4_COEFF_HITS.with(|c| c.get()) | 1658 | RECT4_COEFF_HITS.with(|c| c.get()) |
| @@ -3796,11 +3820,26 @@ impl Neighbours { | |||
| 3796 | /// [`Self::around_mi`]'s plain coded/uncoded bit, this needs the real | 3820 | /// [`Self::around_mi`]'s plain coded/uncoded bit, this needs the real |
| 3797 | /// cumulative level -- a lone-TU block never calls this (its `txb_skip_ctx` | 3821 | /// cumulative level -- a lone-TU block never calls this (its `txb_skip_ctx` |
| 3798 | /// is always 0, spec's `plane_bsize == tx_size` branch). | 3822 | /// is always 0, spec's `plane_bsize == tx_size` branch). |
| 3799 | - fn luma_skip_ctx(&self, (mi_r, mi_c): (usize, usize), side_mi: usize) -> usize { | 3823 | + fn luma_skip_ctx(&self, at_mi: (usize, usize), side_mi: usize) -> usize { |
| 3824 | + self.luma_skip_ctx_rect(at_mi, side_mi, side_mi) | ||
| 3825 | + } | ||
| 3826 | + | ||
| 3827 | + /// [`Self::luma_skip_ctx`] with the unit's own width and height in mi | ||
| 3828 | + /// units (lane-rectsplitx r1) -- `get_txb_ctx_general` ORs the above | ||
| 3829 | + /// context over `tx_size_wide` and the left one over `tx_size_high`. | ||
| 3830 | + fn luma_skip_ctx_rect( | ||
| 3831 | + &self, | ||
| 3832 | + (mi_r, mi_c): (usize, usize), | ||
| 3833 | + w_mi: usize, | ||
| 3834 | + h_mi: usize, | ||
| 3835 | + ) -> usize { | ||
| 3836 | + let side_mi = w_mi; | ||
| 3800 | let mut top = 0u8; | 3837 | let mut top = 0u8; |
| 3801 | let mut left = 0u8; | 3838 | let mut left = 0u8; |
| 3802 | - for cell in 0..side_mi { | 3839 | + for cell in 0..w_mi { |
| 3803 | top |= self.above[mi_c + cell][0].level; | 3840 | top |= self.above[mi_c + cell][0].level; |
| 3841 | + } | ||
| 3842 | + for cell in 0..h_mi { | ||
| 3804 | left |= self.left[mi_r + cell][0].level; | 3843 | left |= self.left[mi_r + cell][0].level; |
| 3805 | } | 3844 | } |
| 3806 | let ctx = SKIP_CONTEXTS[(top as usize).min(4)][(left as usize).min(4)]; | 3845 | let ctx = SKIP_CONTEXTS[(top as usize).min(4)][(left as usize).min(4)]; |
| @@ -4041,13 +4080,27 @@ impl Neighbours { | |||
| 4041 | /// Leaves `above_side_mi`/`left_side_mi` and the chroma planes alone -- | 4080 | /// Leaves `above_side_mi`/`left_side_mi` and the chroma planes alone -- |
| 4042 | /// the caller's own [`Self::record_split_luma`] call sets those once, | 4081 | /// the caller's own [`Self::record_split_luma`] call sets those once, |
| 4043 | /// at the block's own true side, not this TU's. | 4082 | /// at the block's own true side, not this TU's. |
| 4044 | - fn record_mi_luma(&mut self, (mi_r, mi_c): (usize, usize), tx_px: usize, grid: &[i32]) { | 4083 | + fn record_mi_luma(&mut self, at_mi: (usize, usize), tx_px: usize, grid: &[i32]) { |
| 4084 | + self.record_mi_luma_rect(at_mi, tx_px, tx_px, grid); | ||
| 4085 | + } | ||
| 4086 | + | ||
| 4087 | + /// [`Self::record_mi_luma`] for a RECTANGULAR transform unit (lane-rectsplitx | ||
| 4088 | + /// r1): the above context spans the unit's width, the left context its | ||
| 4089 | + /// height, which for a square unit is the same loop it always was. | ||
| 4090 | + fn record_mi_luma_rect( | ||
| 4091 | + &mut self, | ||
| 4092 | + (mi_r, mi_c): (usize, usize), | ||
| 4093 | + w_px: usize, | ||
| 4094 | + h_px: usize, | ||
| 4095 | + grid: &[i32], | ||
| 4096 | + ) { | ||
| 4045 | let state = neighbour_state(grid); | 4097 | let state = neighbour_state(grid); |
| 4046 | - let side_mi = tx_px / MI; | 4098 | + for cell in 0..h_px / MI { |
| 4047 | - for cell in 0..side_mi { | ||
| 4048 | if mi_r + cell < self.mi_rows { | 4099 | if mi_r + cell < self.mi_rows { |
| 4049 | self.left[mi_r + cell][0] = state; | 4100 | self.left[mi_r + cell][0] = state; |
| 4050 | } | 4101 | } |
| 4102 | + } | ||
| 4103 | + for cell in 0..w_px / MI { | ||
| 4051 | if mi_c + cell < self.mi_cols { | 4104 | if mi_c + cell < self.mi_cols { |
| 4052 | self.above[mi_c + cell][0] = state; | 4105 | self.above[mi_c + cell][0] = state; |
| 4053 | } | 4106 | } |
| @@ -4085,17 +4138,42 @@ impl Neighbours { | |||
| 4085 | chroma_grids: [&[i32]; 2], | 4138 | chroma_grids: [&[i32]; 2], |
| 4086 | ) { | 4139 | ) { |
| 4087 | let (r, c) = at; | 4140 | let (r, c) = at; |
| 4088 | - for cell in 0..w / SUB { | 4141 | + self.record_split_luma_rect_mi( |
| 4142 | + (r * (SUB / MI), c * (SUB / MI)), | ||
| 4143 | + w, | ||
| 4144 | + h, | ||
| 4145 | + mode, | ||
| 4146 | + uv_mode, | ||
| 4147 | + chroma_grids, | ||
| 4148 | + ); | ||
| 4149 | + } | ||
| 4150 | + | ||
| 4151 | + /// [`Self::record_split_luma_rect`] addressed in mi units (lane-rectsplitx | ||
| 4152 | + /// r1) -- a strip 8 px tall starts mid-[`SUB`]-cell, which the coarse | ||
| 4153 | + /// `(r, c)` form cannot name. The coarse mode/side arrays are stamped for | ||
| 4154 | + /// every cell the strip TOUCHES (`div_ceil`), last writer wins, the | ||
| 4155 | + /// convention [`decode_block_rect4`] already established for 1:4 strips. | ||
| 4156 | + fn record_split_luma_rect_mi( | ||
| 4157 | + &mut self, | ||
| 4158 | + at_mi: (usize, usize), | ||
| 4159 | + w: usize, | ||
| 4160 | + h: usize, | ||
| 4161 | + mode: usize, | ||
| 4162 | + uv_mode: usize, | ||
| 4163 | + chroma_grids: [&[i32]; 2], | ||
| 4164 | + ) { | ||
| 4165 | + let (mi_r, mi_c) = at_mi; | ||
| 4166 | + let (r, c) = (mi_r / (SUB / MI), mi_c / (SUB / MI)); | ||
| 4167 | + for cell in 0..w.div_ceil(SUB) { | ||
| 4089 | self.above_mode[c + cell] = mode; | 4168 | self.above_mode[c + cell] = mode; |
| 4090 | self.above_uv_mode[c + cell] = uv_mode; | 4169 | self.above_uv_mode[c + cell] = uv_mode; |
| 4091 | self.above_side[c + cell] = w; | 4170 | self.above_side[c + cell] = w; |
| 4092 | } | 4171 | } |
| 4093 | - for cell in 0..h / SUB { | 4172 | + for cell in 0..h.div_ceil(SUB) { |
| 4094 | self.left_mode[r + cell] = mode; | 4173 | self.left_mode[r + cell] = mode; |
| 4095 | self.left_uv_mode[r + cell] = uv_mode; | 4174 | self.left_uv_mode[r + cell] = uv_mode; |
| 4096 | self.left_side[r + cell] = h; | 4175 | self.left_side[r + cell] = h; |
| 4097 | } | 4176 | } |
| 4098 | - let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); | ||
| 4099 | let (w_mi, h_mi) = (w / MI, h / MI); | 4177 | let (w_mi, h_mi) = (w / MI, h / MI); |
| 4100 | self.record_mode_mi(mi_r, mi_c, w_mi, h_mi, mode); | 4178 | self.record_mode_mi(mi_r, mi_c, w_mi, h_mi, mode); |
| 4101 | self.record_uv_mode_mi(mi_r, mi_c, w_mi, h_mi, uv_mode); | 4179 | self.record_uv_mode_mi(mi_r, mi_c, w_mi, h_mi, uv_mode); |
| @@ -4667,6 +4745,41 @@ struct RectStripModes { | |||
| 4667 | smooth_neighbor_uv: bool, | 4745 | smooth_neighbor_uv: bool, |
| 4668 | } | 4746 | } |
| 4669 | 4747 | ||
| 4748 | +/// The `tx_type` CDF row a luma transform unit reads under `filter_intra` | ||
| 4749 | +/// (spec 5.11.47 / libaom `av1_read_tx_type`): `fimode_to_intradir` of the | ||
| 4750 | +/// filter-intra mode, never the block's own mode -- which is always | ||
| 4751 | +/// `DC_PRED` whenever filter intra is on, so using it desyncs the stream at | ||
| 4752 | +/// the first coefficient TU of every filter-intra block (main 1a89ed9 fixed | ||
| 4753 | +/// exactly that inside [`read_plane`]; every rect coefficient path needs the | ||
| 4754 | +/// same row). | ||
| 4755 | +fn tx_type_mode_row(mode: usize, filter_intra: Option<usize>) -> usize { | ||
| 4756 | + const FIMODE_TO_INTRADIR: [usize; 5] = [DC_PRED, V_PRED, H_PRED, D157_PRED, DC_PRED]; | ||
| 4757 | + filter_intra.map_or(mode, |fi| FIMODE_TO_INTRADIR[fi]) | ||
| 4758 | +} | ||
| 4759 | + | ||
| 4760 | +/// The transform unit size (w, h) of a `bw`x`bh` intra block at tx `depth` | ||
| 4761 | +/// -- libaom `depth_to_tx_size`, which walks `sub_tx_size_map` `depth` times | ||
| 4762 | +/// from `max_txsize_rect_lookup[bsize]`. Every entry of that map halves the | ||
| 4763 | +/// LONGER side of a rectangle and both sides of a square, so a 1:4 strip's | ||
| 4764 | +/// first step is a 2:1 rect unit (`TX_32X8 -> TX_16X8`, `TX_64X16 -> | ||
| 4765 | +/// TX_32X16`) and only the second reaches a square -- the reason | ||
| 4766 | +/// `bw.min(bh) >> (depth - 1)` (correct for a 2:1 strip, where step one is | ||
| 4767 | +/// already square) mis-tiled 1:4 strips. | ||
| 4768 | +fn depth_to_tx_wh(bw: usize, bh: usize, depth: usize) -> (usize, usize) { | ||
| 4769 | + let (mut w, mut h) = (bw.min(64), bh.min(64)); | ||
| 4770 | + for _ in 0..depth { | ||
| 4771 | + match w.cmp(&h) { | ||
| 4772 | + std::cmp::Ordering::Greater => w /= 2, | ||
| 4773 | + std::cmp::Ordering::Less => h /= 2, | ||
| 4774 | + std::cmp::Ordering::Equal => { | ||
| 4775 | + w /= 2; | ||
| 4776 | + h /= 2; | ||
| 4777 | + } | ||
| 4778 | + } | ||
| 4779 | + } | ||
| 4780 | + (w, h) | ||
| 4781 | +} | ||
| 4782 | + | ||
| 4670 | /// Decodes the planes of one `bw`x`bh` HORZ/VERT intra strip whose luma | 4783 | /// Decodes the planes of one `bw`x`bh` HORZ/VERT intra strip whose luma |
| 4671 | /// transform is SPLIT (`tx_depth != 0`) -- lane-rectsplit r1, the case every | 4784 | /// transform is SPLIT (`tx_depth != 0`) -- lane-rectsplit r1, the case every |
| 4672 | /// rect path here refused by name until now ("per-unit rect prediction is not | 4785 | /// rect path here refused by name until now ("per-unit rect prediction is not |
| @@ -4692,10 +4805,15 @@ fn decode_rect_split( | |||
| 4692 | dec: &mut SymbolDecoder, | 4805 | dec: &mut SymbolDecoder, |
| 4693 | cdfs: &mut Cdfs, | 4806 | cdfs: &mut Cdfs, |
| 4694 | neighbours: &mut Neighbours, | 4807 | neighbours: &mut Neighbours, |
| 4695 | - at: (usize, usize), | 4808 | + at_mi: (usize, usize), |
| 4696 | bw: usize, | 4809 | bw: usize, |
| 4697 | bh: usize, | 4810 | bh: usize, |
| 4698 | - tx: usize, | 4811 | + // The transform unit's own width and height in pixels. Square for every |
| 4812 | + // 2:1 strip from the first split on, but a 1:4 strip's FIRST split is | ||
| 4813 | + // still a 2:1 RECT unit (`sub_tx_size_map[TX_32X8] == TX_16X8`, | ||
| 4814 | + // `[TX_64X16] == TX_32X16`) -- see [`depth_to_tx_wh`]. | ||
| 4815 | + tx_w: usize, | ||
| 4816 | + tx_h: usize, | ||
| 4699 | m: &RectStripModes, | 4817 | m: &RectStripModes, |
| 4700 | y: &mut PlaneBuf, | 4818 | y: &mut PlaneBuf, |
| 4701 | u: &mut PlaneBuf, | 4819 | u: &mut PlaneBuf, |
| @@ -4703,9 +4821,8 @@ fn decode_rect_split( | |||
| 4703 | base_q_idx: u8, | 4821 | base_q_idx: u8, |
| 4704 | reduced_tx_set: bool, | 4822 | reduced_tx_set: bool, |
| 4705 | ) -> Result<()> { | 4823 | ) -> Result<()> { |
| 4706 | - let (r, c) = at; | 4824 | + let (mi_r, mi_c) = at_mi; |
| 4707 | - let (px, py) = (c * SUB, r * SUB); | 4825 | + let (px, py) = (mi_c * MI, mi_r * MI); |
| 4708 | - let (mi_r, mi_c) = (r * (SUB / MI), c * (SUB / MI)); | ||
| 4709 | let (cpx, cpy) = (px / 2, py / 2); | 4826 | let (cpx, cpy) = (px / 2, py / 2); |
| 4710 | let (chroma_w, chroma_h) = (bw / 2, bh / 2); | 4827 | let (chroma_w, chroma_h) = (bw / 2, bh / 2); |
| 4711 | // The chroma transform is picked before any symbol is read, so an | 4828 | // The chroma transform is picked before any symbol is read, so an |
| @@ -4715,6 +4832,18 @@ fn decode_rect_split( | |||
| 4715 | (8, 16) => Some((TxbSet::ChromaRect16x8, &SCAN_8X16[..])), | 4832 | (8, 16) => Some((TxbSet::ChromaRect16x8, &SCAN_8X16[..])), |
| 4716 | (32, 16) => Some((TxbSet::ChromaRect32x16, &SCAN_32X16[..])), | 4833 | (32, 16) => Some((TxbSet::ChromaRect32x16, &SCAN_32X16[..])), |
| 4717 | (16, 32) => Some((TxbSet::ChromaRect32x16, &SCAN_16X32[..])), | 4834 | (16, 32) => Some((TxbSet::ChromaRect32x16, &SCAN_16X32[..])), |
| 4835 | + // The 1:4 and sub-16 strips (lane-rectsplitx r1). `get_txsize_entropy_ctx` | ||
| 4836 | + // squares a rect transform down to a CDF set by | ||
| 4837 | + // `(wide_log2 + high_log2 + 1) >> 1`: TX_32X8 -> the 16x16 set, | ||
| 4838 | + // TX_16X4 -> the 8x8 set, TX_8X4 -> the 8x8 set -- exactly the sets | ||
| 4839 | + // the UNSPLIT 1:4 (`decode_block_rect4`) and 16x8 (`decode_leaf_rect`) | ||
| 4840 | + // paths already prove for these same shapes. | ||
| 4841 | + (32, 8) => Some((TxbSet::Chroma16, &SCAN_32X8[..])), | ||
| 4842 | + (8, 32) => Some((TxbSet::Chroma16, &SCAN_8X32[..])), | ||
| 4843 | + (16, 4) => Some((TxbSet::Chroma8, &SCAN_16X4[..])), | ||
| 4844 | + (4, 16) => Some((TxbSet::Chroma8, &SCAN_4X16[..])), | ||
| 4845 | + (8, 4) => Some((TxbSet::ChromaRect8x4, &SCAN_8X4[..])), | ||
| 4846 | + (4, 8) => Some((TxbSet::ChromaRect8x4, &SCAN_4X8[..])), | ||
| 4718 | _ => None, | 4847 | _ => None, |
| 4719 | }; | 4848 | }; |
| 4720 | // lane-rectsplit r2 (verifier finding): with both callers wired | 4849 | // lane-rectsplit r2 (verifier finding): with both callers wired |
| @@ -4730,21 +4859,56 @@ fn decode_rect_split( | |||
| 4730 | )); | 4859 | )); |
| 4731 | } | 4860 | } |
| 4732 | RECT_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); | 4861 | RECT_SPLIT_TX_HITS.with(|c| c.set(c.get() + 1)); |
| 4733 | - if bw.max(bh) == 64 && bw / tx > 1 && bh / tx > 1 { | 4862 | + if bw.max(bh) == 64 && bw / tx_w > 1 && bh / tx_h > 1 { |
| 4734 | RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.set(c.get() + 1)); | 4863 | RECT_SPLIT_SB_INTERIOR_TU_HITS.with(|c| c.set(c.get() + 1)); |
| 4735 | } | 4864 | } |
| 4736 | // LUMA: `bw/tx` x `bh/tx` square transform units, raster order. | 4865 | // LUMA: `bw/tx` x `bh/tx` square transform units, raster order. |
| 4737 | - let luma_set = txbset_for(tx, reduced_tx_set); | 4866 | + // A square unit reads through the ordinary square [`read_plane`]; a rect |
| 4738 | - let luma_scan = default_scan(tx); | 4867 | + // one (a 1:4 strip's first split) reads through [`read_coeffs_rect`] with |
| 4739 | - let zero_tu = vec![0i32; tx * tx]; | 4868 | + // the very tables the unsplit 16x8/32x16 paths use. |
| 4869 | + let luma_rect: Option<(TxbSet, &[u16])> = match (tx_w, tx_h) { | ||
| 4870 | + (w, h) if w == h => None, | ||
| 4871 | + (16, 8) | (8, 16) => Some(( | ||
| 4872 | + if reduced_tx_set { | ||
| 4873 | + TxbSet::LumaRect16x8 | ||
| 4874 | + } else { | ||
| 4875 | + TxbSet::LumaRect16x8Set1 | ||
| 4876 | + }, | ||
| 4877 | + if tx_w == 16 { &SCAN_16X8[..] } else { &SCAN_8X16[..] }, | ||
| 4878 | + )), | ||
| 4879 | + (32, 16) => Some((TxbSet::LumaRect32x16, &SCAN_32X16[..])), | ||
| 4880 | + (16, 32) => Some((TxbSet::LumaRect32x16, &SCAN_16X32[..])), | ||
| 4881 | + _ => { | ||
| 4882 | + return Err(unsupported(format!( | ||
| 4883 | + "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma \ | ||
| 4884 | + coefficient tables for that shape here)" | ||
| 4885 | + ))) | ||
| 4886 | + } | ||
| 4887 | + }; | ||
| 4888 | + // lane-rectsplitx r1, MEASURED: the SQUARE-unit walk below is pixel-exact | ||
| 4889 | + // on a real stream (the pinned 16x8 filter-intra fixture decodes its whole | ||
| 4890 | + // frame exactly, two sub-16 split strips in it), but the RECT-unit arm -- | ||
| 4891 | + // a 1:4 strip's depth-1 TX_16X8/TX_32X16 -- mismatched ffmpeg on the | ||
| 4892 | + // 32-level 1:4 band fixture (8-bit, cq 12, seed 42). The tables and the | ||
| 4893 | + // per-unit rect walk stay wired above/below; the round that finds that | ||
| 4894 | + // defect deletes this refusal and nothing else. | ||
| 4895 | + if tx_w != tx_h { | ||
| 4896 | + return Err(unsupported(format!( | ||
| 4897 | + "a split intra strip whose transform unit is the rect {tx_w}x{tx_h} (the depth-1 \ | ||
| 4898 | + step of a 1:4 strip; measured wrong pixels, refused rather than shipped)" | ||
| 4899 | + ))); | ||
| 4900 | + } | ||
| 4901 | + let luma_set = txbset_for(tx_w.min(tx_h), reduced_tx_set); | ||
| 4902 | + let luma_scan = default_scan(tx_w.min(tx_h)); | ||
| 4903 | + let zero_tu = vec![0i32; tx_w * tx_h]; | ||
| 4740 | // The strip's OWN edge availability, the fallback for a transform unit | 4904 | // The strip's OWN edge availability, the fallback for a transform unit |
| 4741 | // whose top-right/bottom-left pixels fall outside the strip. | 4905 | // whose top-right/bottom-left pixels fall outside the strip. |
| 4742 | let block_reach = Reach::of_rect(bw, bh, px, py, y.width, y.height); | 4906 | let block_reach = Reach::of_rect(bw, bh, px, py, y.width, y.height); |
| 4743 | - for tu_row in 0..bh / tx { | 4907 | + for tu_row in 0..bh / tx_h { |
| 4744 | - for tu_col in 0..bw / tx { | 4908 | + for tu_col in 0..bw / tx_w { |
| 4745 | - let tu_mi = (mi_r + tu_row * (tx / MI), mi_c + tu_col * (tx / MI)); | 4909 | + let tu_mi = (mi_r + tu_row * (tx_h / MI), mi_c + tu_col * (tx_w / MI)); |
| 4746 | - let (tu_px, tu_py) = (px + tu_col * tx, py + tu_row * tx); | 4910 | + let (tu_px, tu_py) = (px + tu_col * tx_w, py + tu_row * tx_h); |
| 4747 | - let (col_off, row_off) = (tu_col * tx, tu_row * tx); | 4911 | + let (col_off, row_off) = (tu_col * tx_w, tu_row * tx_h); |
| 4748 | // `has_top_right`/`has_bottom_left` (libaom `reconintra.c`) for a | 4912 | // `has_top_right`/`has_bottom_left` (libaom `reconintra.c`) for a |
| 4749 | // transform unit INSIDE a block, which is a different rule from | 4913 | // transform unit INSIDE a block, which is a different rule from |
| 4750 | // the standalone-block table [`Reach::of`] applies -- and the | 4914 | // the standalone-block table [`Reach::of`] applies -- and the |
| @@ -4761,24 +4925,25 @@ fn decode_rect_split( | |||
| 4761 | // neighbour's, already reconstructed; the last row falls back | 4925 | // neighbour's, already reconstructed; the last row falls back |
| 4762 | // to the block-level answer. | 4926 | // to the block-level answer. |
| 4763 | let tu_reach = Reach { | 4927 | let tu_reach = Reach { |
| 4764 | - above_right: if col_off + tx < bw { | 4928 | + above_right: if col_off + tx_w < bw { |
| 4765 | true | 4929 | true |
| 4766 | } else { | 4930 | } else { |
| 4767 | row_off == 0 && block_reach.above_right | 4931 | row_off == 0 && block_reach.above_right |
| 4768 | }, | 4932 | }, |
| 4769 | below_left: if col_off > 0 { | 4933 | below_left: if col_off > 0 { |
| 4770 | false | 4934 | false |
| 4771 | - } else if row_off + tx < bh { | 4935 | + } else if row_off + tx_h < bh { |
| 4772 | true | 4936 | true |
| 4773 | } else { | 4937 | } else { |
| 4774 | block_reach.below_left | 4938 | block_reach.below_left |
| 4775 | }, | 4939 | }, |
| 4776 | }; | 4940 | }; |
| 4777 | if m.skip { | 4941 | if m.skip { |
| 4778 | - y.reconstruct( | 4942 | + y.reconstruct_rect( |
| 4779 | tu_px, | 4943 | tu_px, |
| 4780 | tu_py, | 4944 | tu_py, |
| 4781 | - tx, | 4945 | + tx_w, |
| 4946 | + tx_h, | ||
| 4782 | m.mode, | 4947 | m.mode, |
| 4783 | m.angle_delta_y, | 4948 | m.angle_delta_y, |
| 4784 | tu_reach, | 4949 | tu_reach, |
| @@ -4787,13 +4952,57 @@ fn decode_rect_split( | |||
| 4787 | m.filter_intra, | 4952 | m.filter_intra, |
| 4788 | m.smooth_neighbor, | 4953 | m.smooth_neighbor, |
| 4789 | ); | 4954 | ); |
| 4790 | - neighbours.record_mi_luma(tu_mi, tx, &zero_tu); | 4955 | + neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &zero_tu); |
| 4956 | + } else if let Some((rect_set, rect_scan)) = luma_rect { | ||
| 4957 | + // The rect-unit twin of the square arm below: same contexts, | ||
| 4958 | + // same order, through the rect coefficient reader. The | ||
| 4959 | + // `tx_type` CDF row of a filter-intra block is | ||
| 4960 | + // `fimode_to_intradir[filter_intra_mode]`, never the block's | ||
| 4961 | + // own (always DC_PRED) mode -- [`read_plane`] applies that | ||
| 4962 | + // for the square arm, so this one must too. | ||
| 4963 | + let tu_around = neighbours.around_mi_rect(tu_mi, tx_w, tx_h)[0]; | ||
| 4964 | + let tu_skip_ctx = neighbours.luma_skip_ctx_rect(tu_mi, tx_w / MI, tx_h / MI); | ||
| 4965 | + let mut coding = cdfs.txb(rect_set, tx_type_mode_row(m.mode, m.filter_intra)); | ||
| 4966 | + let (tu_grid, tu_tx_type) = read_coeffs_rect( | ||
| 4967 | + dec, | ||
| 4968 | + &mut coding, | ||
| 4969 | + rect_scan, | ||
| 4970 | + tx_w, | ||
| 4971 | + tx_h, | ||
| 4972 | + tu_skip_ctx, | ||
| 4973 | + dc_sign_ctx(tu_around.2), | ||
| 4974 | + TxType::DctDct, | ||
| 4975 | + )?; | ||
| 4976 | + let residual = dequant_and_inverse_typed_wh( | ||
| 4977 | + &tu_grid, | ||
| 4978 | + tx_w, | ||
| 4979 | + tx_h, | ||
| 4980 | + crate::decode::bit_depth(), | ||
| 4981 | + block_q_idx(), | ||
| 4982 | + plane_q_delta(0).0, | ||
| 4983 | + plane_q_delta(0).1, | ||
| 4984 | + tu_tx_type, | ||
| 4985 | + ); | ||
| 4986 | + y.reconstruct_rect( | ||
| 4987 | + tu_px, | ||
| 4988 | + tu_py, | ||
| 4989 | + tx_w, | ||
| 4990 | + tx_h, | ||
| 4991 | + m.mode, | ||
| 4992 | + m.angle_delta_y, | ||
| 4993 | + tu_reach, | ||
| 4994 | + &residual, | ||
| 4995 | + None, | ||
| 4996 | + m.filter_intra, | ||
| 4997 | + m.smooth_neighbor, | ||
| 4998 | + ); | ||
| 4999 | + neighbours.record_mi_luma_rect(tu_mi, tx_w, tx_h, &tu_grid); | ||
| 4791 | } else { | 5000 | } else { |
| 4792 | - let tu_around = neighbours.around_mi(tu_mi, tx)[0]; | 5001 | + let tu_around = neighbours.around_mi(tu_mi, tx_w)[0]; |
| 4793 | // This unit is smaller than the block it sits in, so | 5002 | // This unit is smaller than the block it sits in, so |
| 4794 | // `txb_skip_ctx` is the neighbour-magnitude table, not the | 5003 | // `txb_skip_ctx` is the neighbour-magnitude table, not the |
| 4795 | // lone-TU 0 (spec `get_txb_ctx_general`). | 5004 | // lone-TU 0 (spec `get_txb_ctx_general`). |
| 4796 | - let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx / MI); | 5005 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_w / MI); |
| 4797 | let tu_grid = read_plane( | 5006 | let tu_grid = read_plane( |
| 4798 | dec, | 5007 | dec, |
| 4799 | cdfs, | 5008 | cdfs, |
| @@ -4808,15 +5017,15 @@ fn decode_rect_split( | |||
| 4808 | y, | 5017 | y, |
| 4809 | tu_px, | 5018 | tu_px, |
| 4810 | tu_py, | 5019 | tu_py, |
| 4811 | - tx, | 5020 | + tx_w, |
| 4812 | - tx, | 5021 | + tx_w, |
| 4813 | base_q_idx, | 5022 | base_q_idx, |
| 4814 | None, | 5023 | None, |
| 4815 | m.filter_intra, | 5024 | m.filter_intra, |
| 4816 | Some(tu_skip_ctx), | 5025 | Some(tu_skip_ctx), |
| 4817 | m.smooth_neighbor, | 5026 | m.smooth_neighbor, |
| 4818 | )?; | 5027 | )?; |
| 4819 | - neighbours.record_mi_luma(tu_mi, tx, &tu_grid); | 5028 | + neighbours.record_mi_luma(tu_mi, tx_w, &tu_grid); |
| 4820 | } | 5029 | } |
| 4821 | } | 5030 | } |
| 4822 | } | 5031 | } |
| @@ -4844,7 +5053,7 @@ fn decode_rect_split( | |||
| 4844 | } else { | 5053 | } else { |
| 4845 | default_intra_tx_type(m.uv_predict_mode as u8) | 5054 | default_intra_tx_type(m.uv_predict_mode as u8) |
| 4846 | }; | 5055 | }; |
| 4847 | - let around = neighbours.around_rect(at, bw, bh); | 5056 | + let around = neighbours.around_mi_rect(at_mi, bw, bh); |
| 4848 | let mut grids: Vec<Vec<i32>> = Vec::with_capacity(2); | 5057 | let mut grids: Vec<Vec<i32>> = Vec::with_capacity(2); |
| 4849 | for plane_idx in 1..=2 { | 5058 | for plane_idx in 1..=2 { |
| 4850 | let skip_ctx = | 5059 | let skip_ctx = |
| @@ -4900,13 +5109,21 @@ fn decode_rect_split( | |||
| 4900 | let mut it = grids.into_iter(); | 5109 | let mut it = grids.into_iter(); |
| 4901 | (it.next().unwrap(), it.next().unwrap()) | 5110 | (it.next().unwrap(), it.next().unwrap()) |
| 4902 | }; | 5111 | }; |
| 4903 | - neighbours.record_split_luma_rect(at, bw, bh, m.mode, m.uv_predict_mode, [&u_grid, &v_grid]); | 5112 | + neighbours.record_split_luma_rect_mi( |
| 5113 | + at_mi, | ||
| 5114 | + bw, | ||
| 5115 | + bh, | ||
| 5116 | + m.mode, | ||
| 5117 | + m.uv_predict_mode, | ||
| 5118 | + [&u_grid, &v_grid], | ||
| 5119 | + ); | ||
| 4904 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, m.skip); | 5120 | neighbours.fill_skip_grid_rect((mi_r, mi_c), bw / MI, bh / MI, m.skip); |
| 4905 | - neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx as u8, tx as u8, 0); | 5121 | + neighbours.fill_lf_grid_rect((mi_r, mi_c), bw / MI, bh / MI, tx_w as u8, tx_h as u8, 0); |
| 4906 | if std::env::var_os("EC_AV1_TRACE").is_some() { | 5122 | if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 4907 | let (rng, _) = dec.debug_state(); | 5123 | let (rng, _) = dec.debug_state(); |
| 4908 | eprintln!( | 5124 | eprintln!( |
| 4909 | - "TRACE_RECT_SPLIT mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} tx={tx} rng={rng}" | 5125 | + "TRACE_RECT_SPLIT mi_row={mi_r} mi_col={mi_c} bw={bw} bh={bh} \ |
| 5126 | + tx={tx_w}x{tx_h} rng={rng}" | ||
| 4910 | ); | 5127 | ); |
| 4911 | } | 5128 | } |
| 4912 | Ok(()) | 5129 | Ok(()) |
| @@ -4998,13 +5215,12 @@ fn decode_block_rect( | |||
| 4998 | // lane-rectsplit r1: a split transform is predicted and reconstructed | 5215 | // lane-rectsplit r1: a split transform is predicted and reconstructed |
| 4999 | // per transform unit, each unit taking its edges from the previous | 5216 | // per transform unit, each unit taking its edges from the previous |
| 5000 | // unit's reconstruction inside this same strip (spec 5.11.36) -- | 5217 | // unit's reconstruction inside this same strip (spec 5.11.36) -- |
| 5001 | - // [`decode_rect_split`]. `depth_to_tx_size` of a 2:1 strip is square | 5218 | + // [`decode_rect_split`], the unit named by [`depth_to_tx_wh`]. |
| 5002 | - // from the first step on, so `bw.min(bh) >> (depth - 1)` names it. | 5219 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); |
| 5003 | - let tx = bw.min(bh) >> (depth - 1); | ||
| 5004 | if std::env::var_os("EC_SBPART_DUMP64").is_some() { | 5220 | if std::env::var_os("EC_SBPART_DUMP64").is_some() { |
| 5005 | eprintln!( | 5221 | eprintln!( |
| 5006 | "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ | 5222 | "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ |
| 5007 | - depth={depth} tx={tx} mode={mode} uv={uv_predict_mode} skip={skip} \ | 5223 | + depth={depth} tx={tx_w}x{tx_h} mode={mode} uv={uv_predict_mode} skip={skip} \ |
| 5008 | angle_y={angle_delta_y}" | 5224 | angle_y={angle_delta_y}" |
| 5009 | ); | 5225 | ); |
| 5010 | } | 5226 | } |
| @@ -5020,7 +5236,20 @@ fn decode_block_rect( | |||
| 5020 | smooth_neighbor_uv, | 5236 | smooth_neighbor_uv, |
| 5021 | }; | 5237 | }; |
| 5022 | decode_rect_split( | 5238 | decode_rect_split( |
| 5023 | - dec, cdfs, neighbours, at, bw, bh, tx, &modes, y, u, v, base_q_idx, reduced_tx_set, | 5239 | + dec, |
| 5240 | + cdfs, | ||
| 5241 | + neighbours, | ||
| 5242 | + (mi_r, mi_c), | ||
| 5243 | + bw, | ||
| 5244 | + bh, | ||
| 5245 | + tx_w, | ||
| 5246 | + tx_h, | ||
| 5247 | + &modes, | ||
| 5248 | + y, | ||
| 5249 | + u, | ||
| 5250 | + v, | ||
| 5251 | + base_q_idx, | ||
| 5252 | + reduced_tx_set, | ||
| 5024 | )?; | 5253 | )?; |
| 5025 | RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); | 5254 | RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); |
| 5026 | return Ok(()); | 5255 | return Ok(()); |
| @@ -5387,15 +5616,50 @@ fn decode_leaf_rect( | |||
| 5387 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c); | 5616 | let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(leaf_mi.0, leaf_mi.1, r, c); |
| 5388 | let depth = if tx_select { | 5617 | let depth = if tx_select { |
| 5389 | let ctx = tx_size_context_rect(neighbours, leaf_mi, bw, bh); | 5618 | let ctx = tx_size_context_rect(neighbours, leaf_mi, bw, bh); |
| 5390 | - dec.symbol(&mut cdfs.tx_size_cat2[ctx]) | 5619 | + // lane-rectsplitx r1: `bsize_to_tx_size_cat` (libaom `blockd.h`, |
| 5620 | + // `bsize_to_tx_size_depth_table`) is 2 for BLOCK_16X8/BLOCK_8X16, so | ||
| 5621 | + // the category is 1 -- NOT the 2 the 32x16 strips read. Same symbol | ||
| 5622 | + // count (3), different CDF row: a wrong-table read of a real symbol, | ||
| 5623 | + // the class that cost lane-rectsplit r1 its 64x32 depth. | ||
| 5624 | + dec.symbol(&mut cdfs.tx_size_cat1[ctx]) | ||
| 5391 | } else { | 5625 | } else { |
| 5392 | 0 | 5626 | 0 |
| 5393 | }; | 5627 | }; |
| 5394 | if depth != 0 { | 5628 | if depth != 0 { |
| 5395 | - return Err(unsupported( | 5629 | + // The same per-transform-unit walk the bigger strips take |
| 5396 | - "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit rect \ | 5630 | + // (`depth_to_tx_wh`: TX_16X8 -> TX_8X8 at depth 1, -> TX_4X4 at |
| 5397 | - prediction is not ported)", | 5631 | + // depth 2), addressed at this leaf's own mi position. |
| 5398 | - )); | 5632 | + TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); |
| 5633 | + SUB16_SPLIT_HITS.with(|c| c.set(c.get() + 1)); | ||
| 5634 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | ||
| 5635 | + let modes = RectStripModes { | ||
| 5636 | + skip, | ||
| 5637 | + mode, | ||
| 5638 | + angle_delta_y, | ||
| 5639 | + uv_predict_mode, | ||
| 5640 | + angle_delta_uv, | ||
| 5641 | + alpha, | ||
| 5642 | + filter_intra, | ||
| 5643 | + smooth_neighbor, | ||
| 5644 | + smooth_neighbor_uv: false, | ||
| 5645 | + }; | ||
| 5646 | + decode_rect_split( | ||
| 5647 | + dec, | ||
| 5648 | + cdfs, | ||
| 5649 | + neighbours, | ||
| 5650 | + leaf_mi, | ||
| 5651 | + bw, | ||
| 5652 | + bh, | ||
| 5653 | + tx_w, | ||
| 5654 | + tx_h, | ||
| 5655 | + &modes, | ||
| 5656 | + y, | ||
| 5657 | + u, | ||
| 5658 | + v, | ||
| 5659 | + base_q_idx, | ||
| 5660 | + reduced_tx_set, | ||
| 5661 | + )?; | ||
| 5662 | + return Ok(mode); | ||
| 5399 | } | 5663 | } |
| 5400 | let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI); | 5664 | let (px, py) = (leaf_mi.1 * MI, leaf_mi.0 * MI); |
| 5401 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height); | 5665 | let reach = Reach::of_rect(bw, bh, px, py, y.width, y.height); |
| @@ -5437,7 +5701,7 @@ fn decode_leaf_rect( | |||
| 5437 | } else { | 5701 | } else { |
| 5438 | TxbSet::LumaRect16x8Set1 | 5702 | TxbSet::LumaRect16x8Set1 |
| 5439 | }; | 5703 | }; |
| 5440 | - let mut luma_coding = cdfs.txb(luma_set, mode); | 5704 | + let mut luma_coding = cdfs.txb(luma_set, tx_type_mode_row(mode, filter_intra)); |
| 5441 | let (l_levels, luma_tx_type) = read_coeffs_rect( | 5705 | let (l_levels, luma_tx_type) = read_coeffs_rect( |
| 5442 | dec, &mut luma_coding, luma_scan, bw, bh, 0, dc_sign_ctx(around[0].2), TxType::DctDct, | 5706 | dec, &mut luma_coding, luma_scan, bw, bh, 0, dc_sign_ctx(around[0].2), TxType::DctDct, |
| 5443 | )?; | 5707 | )?; |
| @@ -5585,17 +5849,70 @@ fn decode_block_rect4( | |||
| 5585 | 0 | 5849 | 0 |
| 5586 | }; | 5850 | }; |
| 5587 | if depth != 0 { | 5851 | if depth != 0 { |
| 5588 | - // lane-tx64x16 r4: the depth is IN the message -- it says which port | 5852 | + // lane-rectsplitx r1: the per-transform-unit walk, at this strip's |
| 5589 | - // the next round owes. depth 1 of a 4:1 strip is TX_16X8/TX_8X16 | 5853 | + // real mi position (strips 1 and 3 of a HORZ_4 start 8 px into a |
| 5590 | - // (`sub_tx_size_map[TX_32X8] == TX_16X8`), a RECTANGULAR transform | 5854 | + // 16-px [`SUB`] cell). depth 1 is the RECT unit TX_16X8/TX_8X16 |
| 5591 | - // unit with no luma coefficient tables here; depth 2 is TX_8X8, | 5855 | + // (`sub_tx_size_map[TX_32X8] == TX_16X8`), depth 2 the square TX_8X8; |
| 5592 | - // square, the shape `decode_rect_split` already walks. The film stops | 5856 | + // both interleave in every real stream. |
| 5593 | - // at depth 2, synthetic band fixtures hit both. | 5857 | + TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); |
| 5858 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | ||
| 5859 | + // lane-rectsplitx r1 MEASURED (gate below, 8-bit band fixture, cq | ||
| 5860 | + // 12..28): depth 1 -- the 2:1 RECT unit -- fires FIRST in every | ||
| 5861 | + // attempt that splits at all, and its per-unit walk mismatched | ||
| 5862 | + // ffmpeg, so no attempt ever reaches a pixel-compared depth-2 strip. | ||
| 5863 | + // A depth-2-only lift is therefore ungatable (the handoff predicted | ||
| 5864 | + // exactly this: the two depths interleave and must land together), | ||
| 5865 | + // and an ungated lift is not a lift -- both refuse by name until the | ||
| 5866 | + // rect-unit defect is found. | ||
| 5867 | + if tx_w != tx_h { | ||
| 5594 | return Err(unsupported(format!( | 5868 | return Err(unsupported(format!( |
| 5595 | - "a 32x32-level 1:4 strip with a split transform (per-unit 4:1 prediction is not \ | 5869 | + "a 32x32-level 1:4 strip with a split transform (per-unit 4:1 prediction is \ |
| 5596 | - ported, depth={depth})" | 5870 | + not ported, depth={depth})" |
| 5597 | ))); | 5871 | ))); |
| 5598 | } | 5872 | } |
| 5873 | + let which = if depth == 1 { | ||
| 5874 | + &RECT4_SPLIT_DEPTH1_HITS | ||
| 5875 | + } else { | ||
| 5876 | + &RECT4_SPLIT_DEPTH2_HITS | ||
| 5877 | + }; | ||
| 5878 | + which.with(|c| c.set(c.get() + 1)); | ||
| 5879 | + let modes = RectStripModes { | ||
| 5880 | + skip, | ||
| 5881 | + mode, | ||
| 5882 | + angle_delta_y, | ||
| 5883 | + uv_predict_mode, | ||
| 5884 | + angle_delta_uv, | ||
| 5885 | + alpha, | ||
| 5886 | + filter_intra, | ||
| 5887 | + smooth_neighbor, | ||
| 5888 | + smooth_neighbor_uv, | ||
| 5889 | + }; | ||
| 5890 | + decode_rect_split( | ||
| 5891 | + dec, | ||
| 5892 | + cdfs, | ||
| 5893 | + neighbours, | ||
| 5894 | + (mi_r, mi_c), | ||
| 5895 | + bw, | ||
| 5896 | + bh, | ||
| 5897 | + tx_w, | ||
| 5898 | + tx_h, | ||
| 5899 | + &modes, | ||
| 5900 | + y, | ||
| 5901 | + u, | ||
| 5902 | + v, | ||
| 5903 | + base_q_idx, | ||
| 5904 | + false, | ||
| 5905 | + )?; | ||
| 5906 | + if bw > bh { | ||
| 5907 | + RECT4_32_HORZ_HITS.with(|c| c.set(c.get() + 1)); | ||
| 5908 | + } else { | ||
| 5909 | + RECT4_32_VERT_HITS.with(|c| c.set(c.get() + 1)); | ||
| 5910 | + } | ||
| 5911 | + if !skip { | ||
| 5912 | + RECT4_COEFF_HITS.with(|c| c.set(c.get() + 1)); | ||
| 5913 | + } | ||
| 5914 | + return Ok((mode, uv_predict_mode)); | ||
| 5915 | + } | ||
| 5599 | // The coarse (16-px [`SUB`] cell) mode/side arrays cannot name a strip | 5916 | // The coarse (16-px [`SUB`] cell) mode/side arrays cannot name a strip |
| 5600 | // that is 8 px tall, so each strip stamps every cell it touches and the | 5917 | // that is 8 px tall, so each strip stamps every cell it touches and the |
| 5601 | // LAST strip wins -- which is the right answer for the block below/right | 5918 | // LAST strip wins -- which is the right answer for the block below/right |
| @@ -5877,13 +6194,22 @@ fn decode_block_rect64( | |||
| 5877 | TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); | 6194 | TX_DEPTH_HITS.with(|c| c.set(c.get() + 1)); |
| 5878 | // lane-rectsplit r1/r4: the superblock-level strip splits its | 6195 | // lane-rectsplit r1/r4: the superblock-level strip splits its |
| 5879 | // transform through the very same per-unit path as its 32x32-level | 6196 | // transform through the very same per-unit path as its 32x32-level |
| 5880 | - // sibling (`sub_tx_size_map[TX_64X32] == TX_32X32`, square from the | 6197 | + // sibling; [`depth_to_tx_wh`] names the unit, which for a 64x16/16x64 |
| 5881 | - // first step on, so `bw.min(bh) >> (depth - 1)` names the unit). | 6198 | + // 1:4 strip is the 2:1 rect TX_32X16 at depth 1 (lane-rectchroma r1 |
| 5882 | - let tx = bw.min(bh) >> (depth - 1); | 6199 | + // measured the old square formula mis-tiling exactly that strip). |
| 6200 | + let (tx_w, tx_h) = depth_to_tx_wh(bw, bh, depth); | ||
| 6201 | + if bw.max(bh) / bw.min(bh) == 4 { | ||
| 6202 | + let which = if depth == 1 { | ||
| 6203 | + &RECT4_SPLIT_DEPTH1_HITS | ||
| 6204 | + } else { | ||
| 6205 | + &RECT4_SPLIT_DEPTH2_HITS | ||
| 6206 | + }; | ||
| 6207 | + which.with(|c| c.set(c.get() + 1)); | ||
| 6208 | + } | ||
| 5883 | if std::env::var_os("EC_SBPART_DUMP64").is_some() { | 6209 | if std::env::var_os("EC_SBPART_DUMP64").is_some() { |
| 5884 | eprintln!( | 6210 | eprintln!( |
| 5885 | "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ | 6211 | "DUMP64SPLIT mi_r={mi_r} mi_c={mi_c} px={px} py={py} bw={bw} bh={bh} \ |
| 5886 | - depth={depth} tx={tx} mode={mode} uv={uv_predict_mode} skip={skip} \ | 6212 | + depth={depth} tx={tx_w}x{tx_h} mode={mode} uv={uv_predict_mode} skip={skip} \ |
| 5887 | angle_y={angle_delta_y}" | 6213 | angle_y={angle_delta_y}" |
| 5888 | ); | 6214 | ); |
| 5889 | } | 6215 | } |
| @@ -5899,7 +6225,20 @@ fn decode_block_rect64( | |||
| 5899 | smooth_neighbor_uv, | 6225 | smooth_neighbor_uv, |
| 5900 | }; | 6226 | }; |
| 5901 | decode_rect_split( | 6227 | decode_rect_split( |
| 5902 | - dec, cdfs, neighbours, at, bw, bh, tx, &modes, y, u, v, base_q_idx, reduced_tx_set, | 6228 | + dec, |
| 6229 | + cdfs, | ||
| 6230 | + neighbours, | ||
| 6231 | + (mi_r, mi_c), | ||
| 6232 | + bw, | ||
| 6233 | + bh, | ||
| 6234 | + tx_w, | ||
| 6235 | + tx_h, | ||
| 6236 | + &modes, | ||
| 6237 | + y, | ||
| 6238 | + u, | ||
| 6239 | + v, | ||
| 6240 | + base_q_idx, | ||
| 6241 | + reduced_tx_set, | ||
| 5903 | )?; | 6242 | )?; |
| 5904 | RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); | 6243 | RECT_PARTITION_HITS.with(|c| c.set(c.get() + 1)); |
| 5905 | return Ok(()); | 6244 | return Ok(()); |
| @@ -6948,9 +7287,8 @@ fn read_plane( | |||
| 6948 | // filter-intra is on) -- caller passes the raw filter-intra mode 0..4 in | 7287 | // filter-intra is on) -- caller passes the raw filter-intra mode 0..4 in |
| 6949 | // `filter_intra`, only meaningful for `plane_idx == 0` (chroma has no | 7288 | // `filter_intra`, only meaningful for `plane_idx == 0` (chroma has no |
| 6950 | // filter-intra in AV1). | 7289 | // filter-intra in AV1). |
| 6951 | - const FIMODE_TO_INTRADIR: [usize; 5] = [DC_PRED, V_PRED, H_PRED, D157_PRED, DC_PRED]; | ||
| 6952 | let tx_mode = if plane_idx == 0 { | 7290 | let tx_mode = if plane_idx == 0 { |
| 6953 | - filter_intra.map_or(tx_mode, |fi| FIMODE_TO_INTRADIR[fi]) | 7291 | + tx_type_mode_row(tx_mode, filter_intra) |
| 6954 | } else { | 7292 | } else { |
| 6955 | tx_mode | 7293 | tx_mode |
| 6956 | }; | 7294 | }; |
crates/ec-av1/src/refusal_inventory.rsmodified+2 -1
| @@ -33,7 +33,8 @@ const CAPABILITY_CLAIMS: &[&str] = &[ | |||
| 33 | const REFUSALS: &[&str] = &[ | 33 | const REFUSALS: &[&str] = &[ |
| 34 | "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only the skip case at this size)", | 34 | "a coded (non-skip) HORZ_B/VERT_B rect strip below 16x16 (this decoder ports only the skip case at this size)", |
| 35 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", | 35 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 36 | - "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit rect prediction is not ported)", | 36 | + "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", |
| 37 | + "a split intra strip whose transform unit is the rect {tx_w}x{tx_h} (the depth-1 step of a 1:4 strip; measured wrong pixels, refused rather than shipped)", | ||
| 37 | "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)", | 38 | "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)", |
| 38 | "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", | 39 | "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", |
| 39 | "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", | 40 | "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
crates/ec-av1/src/stream.rsmodified+81 -23
| @@ -11697,7 +11697,7 @@ mod tests { | |||
| 11697 | /// `encode::tests::every_rect_shape_reaches_what_libaom_says_over_the_whole_superblock` | 11697 | /// `encode::tests::every_rect_shape_reaches_what_libaom_says_over_the_whole_superblock` |
| 11698 | /// against libaom's own `has_tr_*`/`has_bl_*` arrays. | 11698 | /// against libaom's own `has_tr_*`/`has_bl_*` arrays. |
| 11699 | #[test] | 11699 | #[test] |
| 11700 | - #[ignore = "the coded 16x8/8x16 strip is a live refusal; see the doc above"] | 11700 | + #[ignore = "lane-rectsplitx r1: the sub16 split-transform refusal is lifted and the stream now decodes, but seed 700 cq 45 mismatches ffmpeg on LUMA with 4 strips and 0 of them reaching -- a defect that refusal was hiding, not this gate's own subject"] |
| 11701 | fn a_directional_16x8_strip_reads_the_right_above_right_samples() { | 11701 | fn a_directional_16x8_strip_reads_the_right_above_right_samples() { |
| 11702 | const NAME: &str = "a_directional_16x8_strip_reads_the_right_above_right_samples"; | 11702 | const NAME: &str = "a_directional_16x8_strip_reads_the_right_above_right_samples"; |
| 11703 | if !have_ffmpeg() { | 11703 | if !have_ffmpeg() { |
| @@ -14960,7 +14960,7 @@ mod tests { | |||
| 14960 | /// arm's 10-bit encode is a different stream, so they are a widening, not | 14960 | /// arm's 10-bit encode is a different stream, so they are a widening, not |
| 14961 | /// a measured firing set for this recipe -- the round that un-ignores | 14961 | /// a measured firing set for this recipe -- the round that un-ignores |
| 14962 | /// this gate must re-measure which 10-bit seeds fire it). | 14962 | /// this gate must re-measure which 10-bit seeds fire it). |
| 14963 | - #[ignore = "2026-09-02, re-measured on the merged tree: the coded-strip refusal is lifted, but every firing 10-bit seed now stops at the sub16 SPLIT-TRANSFORM refusal (49, 55) or palette-in-screen-content (45, 46); 16 attempts decode pixel-exact with 0 hits, so the gate would prove nothing"] | 14963 | + #[ignore = "lane-rectsplitx r1: the sub16 split-transform refusal is lifted (the pinned 16x8 fixture now decodes its whole frame pixel-exact), but seed 55 mismatches ffmpeg on the U plane -- a chroma defect that refusal was hiding, open"] |
| 14964 | #[test] | 14964 | #[test] |
| 14965 | fn a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact() { | 14965 | fn a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact() { |
| 14966 | const NAME: &str = "a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact"; | 14966 | const NAME: &str = "a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact"; |
| @@ -15043,29 +15043,40 @@ mod tests { | |||
| 15043 | .join("fixtures/filter_intra_8x16_strip_seed49.obu"); | 15043 | .join("fixtures/filter_intra_8x16_strip_seed49.obu"); |
| 15044 | let stream = std::fs::read(&path) | 15044 | let stream = std::fs::read(&path) |
| 15045 | .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); | 15045 | .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); |
| 15046 | + if !have_ffmpeg() { | ||
| 15047 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 15048 | + return; | ||
| 15049 | + } | ||
| 15046 | let before = crate::decode::filter_intra_rect_sub16_hits(); | 15050 | let before = crate::decode::filter_intra_rect_sub16_hits(); |
| 15047 | - let err = decode_stream(&stream).expect_err( | 15051 | + // lane-rectsplitx r1: the ceiling this fixture used to stop at (a |
| 15048 | - "{NAME}: this stream's 16x8 filter-intra strip is skip=0, which this decoder \ | 15052 | + // sub-16 strip with a SPLIT transform) is ported, so the pinned |
| 15049 | - still refuses -- a clean decode means the coded-strip ceiling moved and this \ | 15053 | + // stream is now a full pixel compare -- what the doc above said this |
| 15050 | - test should become a pixel compare", | 15054 | + // test should become the round that ceiling lifted. |
| 15051 | - ); | 15055 | + let frames = decode_stream(&stream) |
| 15056 | + .unwrap_or_else(|e| panic!("{NAME}: decode refused: {e}")); | ||
| 15052 | let hits = crate::decode::filter_intra_rect_sub16_hits() - before; | 15057 | let hits = crate::decode::filter_intra_rect_sub16_hits() - before; |
| 15058 | + // TWO now, not the one the truncated decode used to see: the frame | ||
| 15059 | + // no longer stops at the first filter-intra strip, so the second one | ||
| 15060 | + // later in the tile is reached as well (and the pixel compare below | ||
| 15061 | + // proves both reconstructed right). | ||
| 15053 | assert_eq!( | 15062 | assert_eq!( |
| 15054 | - hits, 1, | 15063 | + hits, 2, |
| 15055 | - "{NAME}: expected exactly one 16x8 strip to read use_filter_intra=1 (aomdec's own \ | 15064 | + "{NAME}: expected both 16x8 strips to read use_filter_intra=1; got {hits}" |
| 15056 | - EC_TRACE_MODE shows four BLOCK_16X8 DC_PRED leaves here); got {hits}" | ||
| 15057 | ); | 15065 | ); |
| 15058 | - let msg = err.to_string(); | 15066 | + // This is also the GATE for the sub-16 split-transform lift: both |
| 15067 | + // strips split their transform (`tx_depth != 0` on a BLOCK_16X8 -> | ||
| 15068 | + // two TX_8X8 units), which is the refusal this round removed. | ||
| 15069 | + let splits = crate::decode::sub16_split_hits(); | ||
| 15059 | assert!( | 15070 | assert!( |
| 15060 | - // 2026-09-02, merging lane-fistrip onto a main that already carries | 15071 | + splits > 0, |
| 15061 | - // lane-rectx: the coded-strip ceiling this fixture used to hit is | 15072 | + "{NAME}: no sub-16 strip split its transform -- the fixture no longer proves the \ |
| 15062 | - // gone, and the very next one on the SAME block is the split | 15073 | + per-unit path this test gates" |
| 15063 | - // transform under a sub-16 strip (per-unit rect prediction is not | ||
| 15064 | - // ported). Still a refusal ON that block, still not a desync. | ||
| 15065 | - msg.contains("a HORZ/VERT intra strip below 16x16 with a split transform"), | ||
| 15066 | - "{NAME}: decode must reach the sub16 split-transform ceiling ON that block, not \ | ||
| 15067 | - wander off a desynced stream; got: {msg}" | ||
| 15068 | ); | 15074 | ); |
| 15075 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, 192, 128, 1); | ||
| 15076 | + assert_eq!(frames.len(), 1, "{NAME}: expected one frame"); | ||
| 15077 | + assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg"); | ||
| 15078 | + assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg"); | ||
| 15079 | + assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg"); | ||
| 15069 | } | 15080 | } |
| 15070 | 15081 | ||
| 15071 | /// lane-fistrip r1: the filter-intra strip gate above, one partition | 15082 | /// lane-fistrip r1: the filter-intra strip gate above, one partition |
| @@ -15093,7 +15104,7 @@ mod tests { | |||
| 15093 | /// itself is pinned by | 15104 | /// itself is pinned by |
| 15094 | /// [`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`], whose | 15105 | /// [`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`], whose |
| 15095 | /// `expect_err` must become a pixel compare in that same round. | 15106 | /// `expect_err` must become a pixel compare in that same round. |
| 15096 | - #[ignore = "2026-09-02, re-measured on the merged tree: 35 of 41 attempts decode pixel-exact with ZERO mismatches, but both firing seeds (49, 213) stop at the sub16 split-transform / HORZ_A-B refusals, so no filter-intra 8x16/16x8 strip is compared yet"] | 15107 | + #[ignore = "lane-rectsplitx r1: the sub16 split-transform refusal is lifted (the pinned 16x8 fixture now decodes its whole frame pixel-exact), but seed 55 mismatches ffmpeg on the U plane -- a chroma defect that refusal was hiding, open"] |
| 15097 | #[test] | 15108 | #[test] |
| 15098 | fn a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact() { | 15109 | fn a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact() { |
| 15099 | const NAME: &str = | 15110 | const NAME: &str = |
| @@ -16178,8 +16189,18 @@ mod tests { | |||
| 16178 | let mut named_refusals = 0u32; | 16189 | let mut named_refusals = 0u32; |
| 16179 | let mut matched = 0u32; | 16190 | let mut matched = 0u32; |
| 16180 | let (mut horz_proved, mut vert_proved, mut coeff_proved) = (0usize, 0usize, 0usize); | 16191 | let (mut horz_proved, mut vert_proved, mut coeff_proved) = (0usize, 0usize, 0usize); |
| 16192 | + let (mut depth1_proved, mut depth2_proved) = (0usize, 0usize); | ||
| 16181 | let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); | 16193 | let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); |
| 16182 | - for attempt in 0..n_attempts { | 16194 | + // lane-rectsplitx r1: the SECOND half of the attempt window turns |
| 16195 | + // `--enable-tx-size-search` ON at low cq, which is what makes a | ||
| 16196 | + // 32-level 1:4 strip SPLIT its transform -- depth 1 is the 2:1 | ||
| 16197 | + // rect unit TX_16X8/TX_8X16 (`sub_tx_size_map[TX_32X8]`), depth 2 | ||
| 16198 | + // the square TX_8X8, and the two interleave across attempts, so | ||
| 16199 | + // both are asserted (a depth-2-only run leaves the rect-unit path | ||
| 16200 | + // unproved). | ||
| 16201 | + for attempt in 0..n_attempts * 2 { | ||
| 16202 | + let tx_search = attempt >= n_attempts; | ||
| 16203 | + let attempt = attempt % n_attempts; | ||
| 16183 | let seed = 42 + attempt; | 16204 | let seed = 42 + attempt; |
| 16184 | let duration = frame_count as f64 / 25.0; | 16205 | let duration = frame_count as f64 / 25.0; |
| 16185 | // 8-pixel bands: a 32x8 strip is flat, a 32x16 one is not, so | 16206 | // 8-pixel bands: a 32x8 strip is flat, a 32x16 one is not, so |
| @@ -16198,7 +16219,13 @@ mod tests { | |||
| 16198 | geq=lum='mod(floor({axis}/8)*{step},256)',\ | 16219 | geq=lum='mod(floor({axis}/8)*{step},256)',\ |
| 16199 | noise=alls={noise}:all_seed={seed},format=yuv420p" | 16220 | noise=alls={noise}:all_seed={seed},format=yuv420p" |
| 16200 | ); | 16221 | ); |
| 16201 | - let cq_level = format!("--cq-level={}", if attempt % 4 < 2 { 32 } else { 45 }); | 16222 | + let cq_level = if tx_search { |
| 16223 | + // 12..28: the window measured to fire both split depths on | ||
| 16224 | + // this fixture (lanes/tx64x16-r4.handoff.md). | ||
| 16225 | + format!("--cq-level={}", 12 + (attempt % 4) * 5) | ||
| 16226 | + } else { | ||
| 16227 | + format!("--cq-level={}", if attempt % 4 < 2 { 32 } else { 45 }) | ||
| 16228 | + }; | ||
| 16202 | let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | 16229 | let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; |
| 16203 | let y4m = Command::new("ffmpeg") | 16230 | let y4m = Command::new("ffmpeg") |
| 16204 | .args([ | 16231 | .args([ |
| @@ -16239,7 +16266,11 @@ mod tests { | |||
| 16239 | "--enable-filter-intra=0", | 16266 | "--enable-filter-intra=0", |
| 16240 | "--enable-cfl-intra=0", | 16267 | "--enable-cfl-intra=0", |
| 16241 | "--enable-intrabc=0", | 16268 | "--enable-intrabc=0", |
| 16242 | - "--enable-tx-size-search=0", | 16269 | + if tx_search { |
| 16270 | + "--enable-tx-size-search=1" | ||
| 16271 | + } else { | ||
| 16272 | + "--enable-tx-size-search=0" | ||
| 16273 | + }, | ||
| 16243 | "--obu", | 16274 | "--obu", |
| 16244 | "-o", | 16275 | "-o", |
| 16245 | "-", | 16276 | "-", |
| @@ -16270,6 +16301,7 @@ mod tests { | |||
| 16270 | crate::decode::rect4_32_vert_hits(), | 16301 | crate::decode::rect4_32_vert_hits(), |
| 16271 | crate::decode::rect4_coeff_hits(), | 16302 | crate::decode::rect4_coeff_hits(), |
| 16272 | ); | 16303 | ); |
| 16304 | + let split_before = crate::decode::rect4_split_depth_hits(); | ||
| 16273 | let frames = match decode_stream(&stream) { | 16305 | let frames = match decode_stream(&stream) { |
| 16274 | Err(e) => { | 16306 | Err(e) => { |
| 16275 | let msg = e.to_string(); | 16307 | let msg = e.to_string(); |
| @@ -16289,6 +16321,8 @@ mod tests { | |||
| 16289 | crate::decode::rect4_32_vert_hits() - before.1, | 16321 | crate::decode::rect4_32_vert_hits() - before.1, |
| 16290 | crate::decode::rect4_coeff_hits() - before.2, | 16322 | crate::decode::rect4_coeff_hits() - before.2, |
| 16291 | ); | 16323 | ); |
| 16324 | + let split_now = crate::decode::rect4_split_depth_hits(); | ||
| 16325 | + let (d1, d2) = (split_now.0 - split_before.0, split_now.1 - split_before.1); | ||
| 16292 | let ffmpeg_frames = if bit_depth == 10 { | 16326 | let ffmpeg_frames = if bit_depth == 10 { |
| 16293 | ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | 16327 | ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) |
| 16294 | } else { | 16328 | } else { |
| @@ -16339,6 +16373,8 @@ mod tests { | |||
| 16339 | horz_proved += horz; | 16373 | horz_proved += horz; |
| 16340 | vert_proved += vert; | 16374 | vert_proved += vert; |
| 16341 | coeff_proved += coeff; | 16375 | coeff_proved += coeff; |
| 16376 | + depth1_proved += d1; | ||
| 16377 | + depth2_proved += d2; | ||
| 16342 | matched += 1; | 16378 | matched += 1; |
| 16343 | } | 16379 | } |
| 16344 | assert!( | 16380 | assert!( |
| @@ -16362,6 +16398,28 @@ mod tests { | |||
| 16362 | strips={vert_proved}, coded strips={coeff_proved}, {out_of_scope} attempts \ | 16398 | strips={vert_proved}, coded strips={coeff_proved}, {out_of_scope} attempts \ |
| 16363 | carried no 32-level 1:4 block ({out_of_scope_mismatch} mismatched)" | 16399 | carried no 32-level 1:4 block ({out_of_scope_mismatch} mismatched)" |
| 16364 | ); | 16400 | ); |
| 16401 | + // The split-transform halves of the window: both tx depths must | ||
| 16402 | + // have fired inside an attempt that then compared pixel-exact | ||
| 16403 | + // (class counter-from-refused-stream -- a global counter would | ||
| 16404 | + // count strips of attempts that later refused). | ||
| 16405 | + // depth 2 (square TX_8X8 units) is what this round ported and what | ||
| 16406 | + // the ReelB extract needed; depth 1 (the 2:1 rect unit) is | ||
| 16407 | + // refused by name, so it can only show up here as a refusal. | ||
| 16408 | + // Both 1:4 split depths are refused by name (the rect-unit | ||
| 16409 | + // measurement above), so these counters are REPORTED, never | ||
| 16410 | + // asserted: the tx-size-search half of the window exists to keep | ||
| 16411 | + // that refusal honest -- the attempts must refuse, never mismatch. | ||
| 16412 | + assert_eq!( | ||
| 16413 | + depth1_proved + depth2_proved, | ||
| 16414 | + 0, | ||
| 16415 | + "{NAME}: {bit_depth}-bit: a 1:4 split-transform strip decoded \ | ||
| 16416 | + (depth1={depth1_proved}, depth2={depth2_proved}) although both depths are \ | ||
| 16417 | + refused -- the refusal above is dead" | ||
| 16418 | + ); | ||
| 16419 | + eprintln!( | ||
| 16420 | + "{NAME}: {bit_depth}-bit split-transform 1:4 strips: depth1={depth1_proved}, \ | ||
| 16421 | + depth2={depth2_proved}" | ||
| 16422 | + ); | ||
| 16365 | assert_eq!( | 16423 | assert_eq!( |
| 16366 | out_of_scope_mismatch, 0, | 16424 | out_of_scope_mismatch, 0, |
| 16367 | "{NAME}: {bit_depth}-bit: {out_of_scope_mismatch} attempt(s) with zero 32-level \ | 16425 | "{NAME}: {bit_depth}-bit: {out_of_scope_mismatch} attempt(s) with zero 32-level \ |
lanes/rectsplitx-r1.report.mdadded+105 -0
| @@ -0,0 +1,105 @@ | |||
| 1 | +# lane-rectsplitx r1 report | ||
| 2 | + | ||
| 3 | +Branch `lane-rectsplitx` off main `8262b99`. | ||
| 4 | + | ||
| 5 | +## What changed | ||
| 6 | + | ||
| 7 | +- `crates/ec-av1/src/decode.rs` | ||
| 8 | + - `decode_rect_split` is now **mi-granular** (`at_mi`) and takes the transform | ||
| 9 | + unit as `(tx_w, tx_h)` instead of one square `tx`: it can name a strip that | ||
| 10 | + starts 8 px into a 16-px `SUB` cell, and it walks rectangular units. | ||
| 11 | + Chroma map gained `(32,8)/(8,32)` (`Chroma16`), `(16,4)/(4,16)` (`Chroma8`) | ||
| 12 | + and `(8,4)/(4,8)` (`ChromaRect8x4`). | ||
| 13 | + - new `depth_to_tx_wh(bw, bh, depth)` -- libaom `depth_to_tx_size`: every | ||
| 14 | + `sub_tx_size_map` entry halves the LONGER side of a rect and both sides of | ||
| 15 | + a square, so a 1:4 strip's first split is still a 2:1 RECT unit | ||
| 16 | + (`TX_32X8 -> TX_16X8`, `TX_64X16 -> TX_32X16`). Replaces the | ||
| 17 | + `bw.min(bh) >> (depth - 1)` formula at BOTH 2:1 call sites; it is the same | ||
| 18 | + root cause lane-rectchroma measured mis-tiling a depth-1 64x16 strip, fixed | ||
| 19 | + once for every caller instead of per shape. | ||
| 20 | + - new `tx_type_mode_row(mode, filter_intra)` -- the `fimode_to_intradir` row | ||
| 21 | + rule main `1a89ed9` fixed inside `read_plane`, now also applied to | ||
| 22 | + `decode_leaf_rect`'s rect luma coefficient read (same defect class, sibling | ||
| 23 | + site found by sweeping every `cdfs.txb(<luma set>, mode)` call: the other | ||
| 24 | + luma rect sets are `tx_size_sqr_up >= TX_32X32`, i.e. DCT-only, no symbol). | ||
| 25 | + - **`decode_leaf_rect` read the wrong tx_size CDF category**: BLOCK_16X8 / | ||
| 26 | + BLOCK_8X16 are `bsize_to_tx_size_cat == 1` (libaom | ||
| 27 | + `bsize_to_tx_size_depth_table`), not the 2 the 32x16 strips use. Same | ||
| 28 | + symbol count, different CDF row -- a wrong-table read of a real symbol. | ||
| 29 | + - `decode_leaf_rect`'s split refusal is **lifted**: a 16x8/8x16 strip with | ||
| 30 | + `tx_depth != 0` decodes per transform unit (TX_8X8 at depth 1, TX_4X4 at | ||
| 31 | + depth 2). | ||
| 32 | + - `Neighbours`: `record_mi_luma_rect`, `luma_skip_ctx_rect`, | ||
| 33 | + `record_split_luma_rect_mi` (coarse mode/side cells stamped with | ||
| 34 | + `div_ceil`, so an 8-px-tall strip stamps the cell it touches). | ||
| 35 | +- `crates/ec-av1/src/stream.rs` | ||
| 36 | + - `a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag` is now a PIXEL | ||
| 37 | + COMPARE (was `expect_err`) and additionally asserts `sub16_split_hits > 0`: | ||
| 38 | + it is the gate for the sub-16 split lift. | ||
| 39 | + - the 32x32-level 1:4 gate gained a `--enable-tx-size-search=1` half of its | ||
| 40 | + attempt window (cq 12..28), which keeps the 1:4 split refusals honest. | ||
| 41 | +- `crates/ec-av1/src/refusal_inventory.rs` updated (one refusal removed, two | ||
| 42 | + added). | ||
| 43 | + | ||
| 44 | +## Refusals | ||
| 45 | + | ||
| 46 | +Lifted: "a HORZ/VERT intra strip below 16x16 with a split transform (per-unit | ||
| 47 | +rect prediction is not ported)". | ||
| 48 | + | ||
| 49 | +Added (both MEASURED, not speculative): | ||
| 50 | +- "a split intra strip whose transform unit is the rect {tx_w}x{tx_h} ..." -- | ||
| 51 | + the per-unit RECT walk (depth 1 of a 1:4 strip) is implemented but mismatched | ||
| 52 | + ffmpeg on the band fixture (8-bit, cq 12, seed 42), so it refuses instead of | ||
| 53 | + shipping wrong pixels. | ||
| 54 | +- "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma | ||
| 55 | + coefficient tables ...)" -- shape guard for the next caller. | ||
| 56 | + | ||
| 57 | +Kept: "a 32x32-level 1:4 strip with a split transform (... depth={depth})". | ||
| 58 | +Reason: depth 1 fires FIRST in every splitting attempt of the fixture, so no | ||
| 59 | +attempt ever reaches a pixel-compared depth-2 strip -- a depth-2-only lift is | ||
| 60 | +ungatable, and an ungated lift is not a lift (the tx64x16 r4 handoff predicted | ||
| 61 | +exactly this interleaving). | ||
| 62 | + | ||
| 63 | +## Gates | ||
| 64 | + | ||
| 65 | +- `a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag` -- **ok**. | ||
| 66 | + EVIDENCE: crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu | cargo | ||
| 67 | + test -p ec-av1 --lib -- a_pinned_aomenc_16x8_strip | whole frame Y+U+V equal | ||
| 68 | + to ffmpeg, filter_intra_rect_sub16 hits 2 (was 1 under the truncated decode), | ||
| 69 | + sub16_split_hits > 0. | ||
| 70 | +- `a_real_aomenc_stream_with_a_32x32_level_1to4_partition_decodes_pixel_exact` | ||
| 71 | + -- ok, now over 16 attempts per bit depth (8 with tx-size-search on). | ||
| 72 | + 8-bit: 7 pixel-exact of 8 compared, 9 named refusals, horz_4=64, vert_4=72, | ||
| 73 | + coded=136, 0 out-of-scope mismatches. | ||
| 74 | + | ||
| 75 | +## Open residue (fix-now for the next round, all MEASURED) | ||
| 76 | + | ||
| 77 | +1. `deferred(rect-unit defect)` -- the depth-1 RECT transform unit (TX_16X8 / | ||
| 78 | + TX_32X16) mismatches ffmpeg; code is wired and refused by one `if tx_w != | ||
| 79 | + tx_h` in `decode_rect_split`. Deleting that one line + the 1:4 caller's twin | ||
| 80 | + is the whole re-lift. Reproduce: the 1:4 gate with the tx-search half and | ||
| 81 | + the refusal removed, 8-bit cq 12 seed 42. | ||
| 82 | +2. `deferred(chroma defect behind the lifted refusal)` -- | ||
| 83 | + `a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact` | ||
| 84 | + now decodes seed 55 instead of refusing and mismatches on the **U plane** | ||
| 85 | + only; `#[ignore]`d with that measurement. | ||
| 86 | +3. `deferred(same)` -- `a_directional_16x8_strip_reads_the_right_above_right_samples` | ||
| 87 | + decodes now and mismatches LUMA at seed 700 cq 45 with 0 reaching strips; | ||
| 88 | + `#[ignore]`d with that measurement. Class refusal-hides-a-defect: both are | ||
| 89 | + defects the split refusal was covering, not regressions of this round. | ||
| 90 | + | ||
| 91 | +## Films | ||
| 92 | + | ||
| 93 | +`decode_probe` (release), before -> after: | ||
| 94 | +- reelb5.obu: "a 32x32-level 1:4 strip with a split transform (depth=2)" -> | ||
| 95 | + **"a HORZ_A/HORZ_B/VERT_A partition below 16x16"** (another lane's refusal). | ||
| 96 | + The 1:4 depth refusal is still in place, so what moved this film is the | ||
| 97 | + sub-16 split lift plus the `tx_size_cat1` fix -- the extract's 1:4 strips are | ||
| 98 | + reached and decoded (rect4_32: horz=4 coded=4) and the stream now runs on to | ||
| 99 | + a partition shape nobody has ported. | ||
| 100 | + EVIDENCE: reelb5.obu | cargo run --release --example decode_probe -- reelb5.obu | | ||
| 101 | + refusal string changed, rect4_32 horz=4 vert=0 coded=4 | ||
| 102 | +- hg-head.obu: "filter intra on a HORZ/VERT strip (this decoder predicts | ||
| 103 | + square-only)" (unchanged, another lane). | ||
| 104 | +- reelc-head.obu: "an intra block in an inter frame whose tx_depth splits its | ||
| 105 | + luma transform (round 1)" (unchanged, another lane). | ||