Merge branch 'lane-inter16ab' (4811488) into lane-intrasplit
Browse files at this commit8 changed files +1343 -34
- crates/ec-av1/examples/decode_probe.rs +9 -0
- crates/ec-av1/src/cdf_state.rs +37 -0
- crates/ec-av1/src/decode.rs +597 -33
- crates/ec-av1/src/refusal_inventory.rs +15 -1
- crates/ec-av1/src/stream.rs +463 -0
- lanes/inter16ab-r1.report.md +74 -0
- lanes/inter16ab-r2.report.md +85 -0
- lanes/inter16ab-r3.handoff.md +63 -0
crates/ec-av1/examples/decode_probe.rsmodified+9 -0
| @@ -35,6 +35,15 @@ fn main() { | |||
| 35 | println!("rect4_32: horz={h} vert={v} coded={c}"); | 35 | println!("rect4_32: horz={h} vert={v} coded={c}"); |
| 36 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); | 36 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); |
| 37 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); | 37 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); |
| 38 | + // lane-inter16ab r1: the 16x16-level inter AB arms, so a recipe sweep | ||
| 39 | + // can tell "aomenc never picked one" from "it did and we decoded it". | ||
| 40 | + let ab = ec_av1::decode::ab16_inter_hits_by_arm(); | ||
| 41 | + println!( | ||
| 42 | + "inter_ab16: horz_a={} horz_b={} vert_a={} vert_b={}", | ||
| 43 | + ab[0], ab[1], ab[2], ab[3] | ||
| 44 | + ); | ||
| 45 | + let (h4, v4, pairs, sub8) = ec_av1::decode::inter16_rect4_counters(); | ||
| 46 | + println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}"); | ||
| 38 | let leaf = ec_av1::stream::vartx_rect_leaf_hits(); | 47 | let leaf = ec_av1::stream::vartx_rect_leaf_hits(); |
| 39 | println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]); | 48 | println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]); |
| 40 | let ir = ec_av1::stream::inter_rect_counters(); | 49 | let ir = ec_av1::stream::inter_rect_counters(); |
crates/ec-av1/src/cdf_state.rsmodified+37 -0
| @@ -230,6 +230,19 @@ pub(crate) enum TxbSet { | |||
| 230 | /// counterpart: `EXT_TX_SET_DTT4_IDTX_1DDCT`, the seven-symbol `TX_4X4` | 230 | /// counterpart: `EXT_TX_SET_DTT4_IDTX_1DDCT`, the seven-symbol `TX_4X4` |
| 231 | /// row [`LumaRect4x8Set1`](TxbSet::LumaRect4x8Set1) reads. | 231 | /// row [`LumaRect4x8Set1`](TxbSet::LumaRect4x8Set1) reads. |
| 232 | LumaRect16x4Set1, | 232 | LumaRect16x4Set1, |
| 233 | + /// [`LumaRect16x4`](TxbSet::LumaRect16x4)'s INTER counterpart | ||
| 234 | + /// (lane-inter16ab r2): the same `Luma8` coefficient tables (64 coded | ||
| 235 | + /// positions, `get_txsize_entropy_ctx(TX_16X4)` = TX_8X8), with the | ||
| 236 | + /// INTER `tx_type` table at `txsize_sqr_map[TX_16X4]` = TX_4X4. | ||
| 237 | + /// `av1_get_ext_tx_set_type` (av1/common/idct.c): `tx_size_sqr_up` is | ||
| 238 | + /// TX_16X16 (not > TX_32X32) and `use_reduced_set` picks | ||
| 239 | + /// `EXT_TX_SET_DCT_IDTX` -- three symbols, `inter_tx_type_4`. | ||
| 240 | + LumaRect16x4Inter, | ||
| 241 | + /// [`LumaRect16x4Inter`](TxbSet::LumaRect16x4Inter)'s | ||
| 242 | + /// `reduced_tx_set: false` counterpart: `tx_size_sqr` is TX_4X4, not | ||
| 243 | + /// TX_16X16, so `av1_get_ext_tx_set_type` returns `EXT_TX_SET_ALL16` -- | ||
| 244 | + /// sixteen symbols, `inter_tx_type_4_set1`. | ||
| 245 | + LumaRect16x4Inter1, | ||
| 233 | } | 246 | } |
| 234 | 247 | ||
| 235 | /// The tables one transform block is coded with, borrowed from the state for | 248 | /// The tables one transform block is coded with, borrowed from the state for |
| @@ -1864,6 +1877,30 @@ impl Cdfs { | |||
| 1864 | tx_type: Some(self.intra_tx_type_4_set1[mode].as_mut_slice()), | 1877 | tx_type: Some(self.intra_tx_type_4_set1[mode].as_mut_slice()), |
| 1865 | eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1), | 1878 | eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1), |
| 1866 | }, | 1879 | }, |
| 1880 | + TxbSet::LumaRect16x4Inter => TxbTables { | ||
| 1881 | + side: 8, | ||
| 1882 | + txb_skip: &mut self.txb_skip_luma_8, | ||
| 1883 | + eob_pt: &mut self.eob_pt_64_luma, | ||
| 1884 | + eob_extra: &mut self.eob_extra_luma_8, | ||
| 1885 | + base: &mut self.base_luma_8, | ||
| 1886 | + base_eob: &mut self.base_eob_luma_8, | ||
| 1887 | + br: &mut self.br_luma_8, | ||
| 1888 | + dc_sign: &mut self.dc_sign_luma, | ||
| 1889 | + tx_type: Some(self.inter_tx_type_4.as_mut_slice()), | ||
| 1890 | + eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1), | ||
| 1891 | + }, | ||
| 1892 | + TxbSet::LumaRect16x4Inter1 => TxbTables { | ||
| 1893 | + side: 8, | ||
| 1894 | + txb_skip: &mut self.txb_skip_luma_8, | ||
| 1895 | + eob_pt: &mut self.eob_pt_64_luma, | ||
| 1896 | + eob_extra: &mut self.eob_extra_luma_8, | ||
| 1897 | + base: &mut self.base_luma_8, | ||
| 1898 | + base_eob: &mut self.base_eob_luma_8, | ||
| 1899 | + br: &mut self.br_luma_8, | ||
| 1900 | + dc_sign: &mut self.dc_sign_luma, | ||
| 1901 | + tx_type: Some(self.inter_tx_type_4_set1.as_mut_slice()), | ||
| 1902 | + eob_pt_class1: Some(&mut self.eob_pt_64_luma_class1), | ||
| 1903 | + }, | ||
| 1867 | TxbSet::LumaRect16x8Inter => TxbTables { | 1904 | TxbSet::LumaRect16x8Inter => TxbTables { |
| 1868 | side: 16, | 1905 | side: 16, |
| 1869 | txb_skip: &mut self.txb_skip_luma_16, | 1906 | txb_skip: &mut self.txb_skip_luma_16, |
crates/ec-av1/src/decode.rsmodified+597 -33
| @@ -2232,6 +2232,89 @@ pub(crate) fn rect4_coeff_hits() -> usize { | |||
| 2232 | RECT4_COEFF_HITS.with(|c| c.get()) | 2232 | RECT4_COEFF_HITS.with(|c| c.get()) |
| 2233 | } | 2233 | } |
| 2234 | 2234 | ||
| 2235 | +// lane-inter16ab r1: how many 16x16-level AB partitions fired IN AN INTER | ||
| 2236 | +// frame, per arm, in `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B` | ||
| 2237 | +// order (the intra-frame counterpart is `AB16_HITS`). Each arm is two 8x8 | ||
| 2238 | +// inter leaves (`decode_inter_block8`) plus one true 16x8/8x16 inter strip | ||
| 2239 | +// (`decode_inter_block` with `write_w`/`write_h`); the gate asserts every | ||
| 2240 | +// arm separately so a run whose RD only picked one cannot pass as proof of | ||
| 2241 | +// four. | ||
| 2242 | +thread_local! { | ||
| 2243 | + static AB16_INTER_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) }; | ||
| 2244 | +} | ||
| 2245 | + | ||
| 2246 | +/// [`AB16_INTER_HITS`] per arm (HORZ_A, HORZ_B, VERT_A, VERT_B at 16x16 in an | ||
| 2247 | +/// inter frame). | ||
| 2248 | +pub fn ab16_inter_hits_by_arm() -> [usize; 4] { | ||
| 2249 | + AB16_INTER_HITS.with(std::cell::Cell::get) | ||
| 2250 | +} | ||
| 2251 | + | ||
| 2252 | +// lane-inter16ab r2: the 16x16-level 1:4 pair as INTER blocks -- four 16x4 | ||
| 2253 | +// (`PARTITION_HORZ_4`) or 4x16 (`PARTITION_VERT_4`) strips. `CHROMA_PAIRS` | ||
| 2254 | +// counts the odd strips that close a 4:2:0 chroma pair | ||
| 2255 | +// (`is_chroma_reference`, av1_common_int.h:1454: bh == 1 mi => odd mi_row), | ||
| 2256 | +// `SUB8_PIECES` the pair chroma blocks whose TOP (LEFT) half was built from | ||
| 2257 | +// the PREVIOUS strip's own mv/ref/filters -- libaom | ||
| 2258 | +// `build_inter_predictors_sub8x8` (reconinter_template.inc:87-160), reached | ||
| 2259 | +// through `is_sub8x8_inter` (same file, :54). | ||
| 2260 | +thread_local! { | ||
| 2261 | + static INTER16_HORZ4_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2262 | + static INTER16_VERT4_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2263 | + static INTER16_CHROMA_PAIR_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2264 | + static INTER16_SUB8_PIECE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2265 | +} | ||
| 2266 | + | ||
| 2267 | +/// Current values of the inter 16x16-level 1:4 counters: `(16x4 strips, 4x16 | ||
| 2268 | +/// strips, chroma pairs closed, chroma pairs built from two different | ||
| 2269 | +/// strips' motion vectors)`. | ||
| 2270 | +pub fn inter16_rect4_counters() -> (usize, usize, usize, usize) { | ||
| 2271 | + ( | ||
| 2272 | + INTER16_HORZ4_HITS.with(std::cell::Cell::get), | ||
| 2273 | + INTER16_VERT4_HITS.with(std::cell::Cell::get), | ||
| 2274 | + INTER16_CHROMA_PAIR_HITS.with(std::cell::Cell::get), | ||
| 2275 | + INTER16_SUB8_PIECE_HITS.with(std::cell::Cell::get), | ||
| 2276 | + ) | ||
| 2277 | +} | ||
| 2278 | + | ||
| 2279 | +/// One 16x4 / 4x16 inter strip's chroma situation, handed to | ||
| 2280 | +/// [`decode_inter_block`] out of band (the same one-shot thread-local idiom | ||
| 2281 | +/// `REDUCED_TX_SET_INTER` uses) rather than through twenty-three call sites | ||
| 2282 | +/// that all mean "an ordinary block, chroma of its own". | ||
| 2283 | +#[derive(Clone, Copy)] | ||
| 2284 | +struct InterStripChroma { | ||
| 2285 | + /// `is_chroma_reference` for this strip: false on strips 0 and 2, which | ||
| 2286 | + /// read and reconstruct NO chroma at all. | ||
| 2287 | + has_chroma: bool, | ||
| 2288 | + /// `PARTITION_HORZ_4` (16x4 strips) rather than `PARTITION_VERT_4`. | ||
| 2289 | + horz: bool, | ||
| 2290 | + /// The mi position of the EVEN strip of this pair -- `setup_pred_plane`'s | ||
| 2291 | + /// `if (ss_y && (mi_row & 1) && mi_size_high[bsize] == 1) mi_row -= 1`, | ||
| 2292 | + /// i.e. the origin of the 8x4 (4x8) chroma transform. | ||
| 2293 | + pair_mi: (usize, usize), | ||
| 2294 | + /// The previous (even) strip's single-reference MC parameters, `None` | ||
| 2295 | + /// when it was intra or compound -- `is_sub8x8_inter` then returns false | ||
| 2296 | + /// and the whole chroma block is predicted from THIS strip's mv. | ||
| 2297 | + prev: Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>, | ||
| 2298 | +} | ||
| 2299 | + | ||
| 2300 | +thread_local! { | ||
| 2301 | + static INTER_STRIP_CHROMA: std::cell::Cell<Option<InterStripChroma>> = | ||
| 2302 | + const { std::cell::Cell::new(None) }; | ||
| 2303 | + /// The single-reference MC parameters of the inter block that decoded | ||
| 2304 | + /// last -- read by the next 1:4 strip to build its pair's chroma. | ||
| 2305 | + static INTER_LAST_MC: std::cell::Cell< | ||
| 2306 | + Option<(i8, (i32, i32), mc::InterpFilterKind, mc::InterpFilterKind)>, | ||
| 2307 | + > = const { std::cell::Cell::new(None) }; | ||
| 2308 | +} | ||
| 2309 | + | ||
| 2310 | +fn bump_ab16_inter(arm: usize) { | ||
| 2311 | + AB16_INTER_HITS.with(|c| { | ||
| 2312 | + let mut v = c.get(); | ||
| 2313 | + v[arm] += 1; | ||
| 2314 | + c.set(v); | ||
| 2315 | + }); | ||
| 2316 | +} | ||
| 2317 | + | ||
| 2235 | // lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or | 2318 | // lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or |
| 2236 | // 4x16 (`PARTITION_VERT_4`) strips, `CHROMA` counting the odd strips that | 2319 | // 4x16 (`PARTITION_VERT_4`) strips, `CHROMA` counting the odd strips that |
| 2237 | // close a 4:2:0 chroma pair and `COEFF` the strips with a coded residual. | 2320 | // close a 4:2:0 chroma pair and `COEFF` the strips with a coded residual. |
| @@ -11808,6 +11891,10 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool { | |||
| 11808 | (w, h), | 11891 | (w, h), |
| 11809 | // 2:1 strips whose transform is coded in full (lane-inter4). | 11892 | // 2:1 strips whose transform is coded in full (lane-inter4). |
| 11810 | (32, 16) | (16, 32) | (16, 8) | (8, 16) | 11893 | (32, 16) | (16, 32) | (16, 8) | (8, 16) |
| 11894 | + // lane-inter16ab r2: the 16x16-level 1:4 strips. TX_16X4/TX_4X16 | ||
| 11895 | + // codes all 64 of its positions, and its chroma pair is an 8x4 / | ||
| 11896 | + // 4x8 unit (`ss_size_lookup[BLOCK_16X4]` = BLOCK_8X4). | ||
| 11897 | + | (16, 4) | (4, 16) | ||
| 11811 | // lane-r14 r2: strips with a 64-px axis. `av1_get_max_eob` codes | 11898 | // lane-r14 r2: strips with a 64-px axis. `av1_get_max_eob` codes |
| 11812 | // only the low 32 coefficients of a 64-length axis, so these read | 11899 | // only the low 32 coefficients of a 64-length axis, so these read |
| 11813 | // exactly the truncated corner the INTRA superblock-strip path | 11900 | // exactly the truncated corner the INTRA superblock-strip path |
| @@ -11830,6 +11917,13 @@ fn rect_inter_residual_supported(w: usize, h: usize) -> bool { | |||
| 11830 | fn rect_inter_luma_set(w: usize, h: usize) -> TxbSet { | 11917 | fn rect_inter_luma_set(w: usize, h: usize) -> TxbSet { |
| 11831 | match (w, h) { | 11918 | match (w, h) { |
| 11832 | (32, 16) | (16, 32) => TxbSet::LumaRect32x16Inter, | 11919 | (32, 16) | (16, 32) => TxbSet::LumaRect32x16Inter, |
| 11920 | + (16, 4) | (4, 16) => { | ||
| 11921 | + if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) { | ||
| 11922 | + TxbSet::LumaRect16x4Inter | ||
| 11923 | + } else { | ||
| 11924 | + TxbSet::LumaRect16x4Inter1 | ||
| 11925 | + } | ||
| 11926 | + } | ||
| 11833 | (16, 8) | (8, 16) => { | 11927 | (16, 8) | (8, 16) => { |
| 11834 | if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) { | 11928 | if REDUCED_TX_SET_INTER.with(std::cell::Cell::get) { |
| 11835 | TxbSet::LumaRect16x8Inter | 11929 | TxbSet::LumaRect16x8Inter |
| @@ -11906,6 +12000,8 @@ fn rect_scan(w: usize, h: usize) -> &'static [u16] { | |||
| 11906 | (16, 32) => &SCAN_16X32, | 12000 | (16, 32) => &SCAN_16X32, |
| 11907 | (16, 8) => &SCAN_16X8, | 12001 | (16, 8) => &SCAN_16X8, |
| 11908 | (8, 16) => &SCAN_8X16, | 12002 | (8, 16) => &SCAN_8X16, |
| 12003 | + (16, 4) => &SCAN_16X4, | ||
| 12004 | + (4, 16) => &SCAN_4X16, | ||
| 11909 | (8, 4) => &SCAN_8X4, | 12005 | (8, 4) => &SCAN_8X4, |
| 11910 | (4, 8) => &SCAN_4X8, | 12006 | (4, 8) => &SCAN_4X8, |
| 11911 | (32, 8) => &SCAN_32X8, | 12007 | (32, 8) => &SCAN_32X8, |
| @@ -16097,6 +16193,54 @@ fn is_any_masked_compound_used_here(side: usize) -> bool { | |||
| 16097 | side.min(side) >= 8 | 16193 | side.min(side) >= 8 |
| 16098 | } | 16194 | } |
| 16099 | 16195 | ||
| 16196 | +/// The `BLOCK_SIZES_ALL` index of a `bw x bh` block (libaom `enum BLOCK_SIZE`, | ||
| 16197 | +/// `blockd.h`) -- the row every size-indexed inter CDF table | ||
| 16198 | +/// (`compound_type_cdf`, `wedge_idx_cdf`) is keyed by. Our `decode_inter_block` | ||
| 16199 | +/// carries the enclosing SQUARE `side` for context purposes (the accepted | ||
| 16200 | +/// strip corner-cut), so a 16x8 / 8x16 PARTITION_HORZ/VERT strip that reads | ||
| 16201 | +/// one of those symbols off `side` alone takes BLOCK_16X16's row and desyncs | ||
| 16202 | +/// (lane-inter16ab r3: a real 16x8 compound strip with `comp_group_idx == 1`, | ||
| 16203 | +/// decode-order frame 5, our range 64901 vs the oracle's 47271 at the very | ||
| 16204 | +/// next block's mode read). | ||
| 16205 | +fn bsize_all_index(bw: usize, bh: usize) -> Option<usize> { | ||
| 16206 | + Some(match (bw, bh) { | ||
| 16207 | + (4, 4) => 0, | ||
| 16208 | + (4, 8) => 1, | ||
| 16209 | + (8, 4) => 2, | ||
| 16210 | + (8, 8) => 3, | ||
| 16211 | + (8, 16) => 4, | ||
| 16212 | + (16, 8) => 5, | ||
| 16213 | + (16, 16) => 6, | ||
| 16214 | + (16, 32) => 7, | ||
| 16215 | + (32, 16) => 8, | ||
| 16216 | + (32, 32) => 9, | ||
| 16217 | + (32, 64) => 10, | ||
| 16218 | + (64, 32) => 11, | ||
| 16219 | + (64, 64) => 12, | ||
| 16220 | + (64, 128) => 13, | ||
| 16221 | + (128, 64) => 14, | ||
| 16222 | + (128, 128) => 15, | ||
| 16223 | + (4, 16) => 16, | ||
| 16224 | + (16, 4) => 17, | ||
| 16225 | + (8, 32) => 18, | ||
| 16226 | + (32, 8) => 19, | ||
| 16227 | + (16, 64) => 20, | ||
| 16228 | + (64, 16) => 21, | ||
| 16229 | + _ => return None, | ||
| 16230 | + }) | ||
| 16231 | +} | ||
| 16232 | + | ||
| 16233 | +/// `av1_wedge_params_lookup[bsize].wedge_types > 0` (libaom `reconinter.c`): | ||
| 16234 | +/// the block sizes that carry a wedge codebook at all. A `compound_type` | ||
| 16235 | +/// symbol is written only for these; every other size infers | ||
| 16236 | +/// `COMPOUND_DIFFWTD`. | ||
| 16237 | +fn wedge_used_bsize(bw: usize, bh: usize) -> bool { | ||
| 16238 | + matches!( | ||
| 16239 | + (bw, bh), | ||
| 16240 | + (8, 8) | (8, 16) | (16, 8) | (16, 16) | (16, 32) | (32, 16) | (32, 32) | (8, 32) | (32, 8) | ||
| 16241 | + ) | ||
| 16242 | +} | ||
| 16243 | + | ||
| 16100 | /// Whether a compound reference pair is unidirectional (both references on | 16244 | /// Whether a compound reference pair is unidirectional (both references on |
| 16101 | /// the same temporal side of the current frame) -- `has_uni_comp_refs` | 16245 | /// the same temporal side of the current frame) -- `has_uni_comp_refs` |
| 16102 | /// (libaom `av1_reference_frame_utils.h`/`pred_common.c`'s own definition: | 16246 | /// (libaom `av1_reference_frame_utils.h`/`pred_common.c`'s own definition: |
| @@ -16546,9 +16690,27 @@ fn decode_inter_block( | |||
| 16546 | // exactly what it read before. | 16690 | // exactly what it read before. |
| 16547 | let (rmi, cmi) = at; | 16691 | let (rmi, cmi) = at; |
| 16548 | let (px, py) = (at.1 * MI, at.0 * MI); | 16692 | let (px, py) = (at.1 * MI, at.0 * MI); |
| 16549 | - let (cpx, cpy) = (px / 2, py / 2); | 16693 | + // lane-inter16ab r2: a 16x4 / 4x16 inter strip's chroma is the PAIR's |
| 16694 | + // (8x4 / 4x8 at the even strip's origin) and is coded only by the odd | ||
| 16695 | + // strip (`is_chroma_reference`); every other block keeps its own. | ||
| 16696 | + let strip_chroma = INTER_STRIP_CHROMA.with(std::cell::Cell::take); | ||
| 16697 | + INTER_LAST_MC.with(|c| c.set(None)); | ||
| 16698 | + let has_chroma = strip_chroma.is_none_or(|s| s.has_chroma); | ||
| 16699 | + let (cpx, cpy) = match strip_chroma { | ||
| 16700 | + Some(s) if s.has_chroma => (s.pair_mi.1 * MI / 2, s.pair_mi.0 * MI / 2), | ||
| 16701 | + _ => (px / 2, py / 2), | ||
| 16702 | + }; | ||
| 16550 | let chroma_side = side / 2; | 16703 | let chroma_side = side / 2; |
| 16551 | - let (write_chroma_w, write_chroma_h) = (write_w / 2, write_h / 2); | 16704 | + let (write_chroma_w, write_chroma_h) = match strip_chroma { |
| 16705 | + Some(s) if s.has_chroma => { | ||
| 16706 | + if s.horz { | ||
| 16707 | + (8, 4) | ||
| 16708 | + } else { | ||
| 16709 | + (4, 8) | ||
| 16710 | + } | ||
| 16711 | + } | ||
| 16712 | + _ => (write_w / 2, write_h / 2), | ||
| 16713 | + }; | ||
| 16552 | 16714 | ||
| 16553 | if std::env::var_os("EC_AV1_TELL").is_some() { | 16715 | if std::env::var_os("EC_AV1_TELL").is_some() { |
| 16554 | eprintln!( | 16716 | eprintln!( |
| @@ -16572,7 +16734,12 @@ fn decode_inter_block( | |||
| 16572 | let (seg_mi_r, seg_mi_c) = (rmi, cmi); | 16734 | let (seg_mi_r, seg_mi_c) = (rmi, cmi); |
| 16573 | let (seg_w_mi, seg_h_mi) = (write_w / 4, write_h / 4); | 16735 | let (seg_w_mi, seg_h_mi) = (write_w / 4, write_h / 4); |
| 16574 | inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, false, true); | 16736 | inter_segment_id(dec, cdfs, seg_mi_r, seg_mi_c, seg_w_mi, seg_h_mi, false, true); |
| 16575 | - let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; | 16737 | + // libaom `read_skip_mode` (decodemv.c): `if (!is_comp_ref_allowed(bsize)) |
| 16738 | + // return 0` -- a 16x4 / 4x16 strip (min(bw, bh) == 4, blockd.h:65) reads | ||
| 16739 | + // no `skip_mode` symbol at all. | ||
| 16740 | + let comp_allowed = write_w.min(write_h) >= 8; | ||
| 16741 | + let skip_mode = | ||
| 16742 | + skip_mode_present && comp_allowed && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; | ||
| 16576 | if std::env::var_os("EC_AV1_SKIPMODE_DUMP").is_some() { | 16743 | if std::env::var_os("EC_AV1_SKIPMODE_DUMP").is_some() { |
| 16577 | eprintln!( | 16744 | eprintln!( |
| 16578 | "EC_SKIPMODE r={r} c={c} result={skip_mode} tell_after={}", | 16745 | "EC_SKIPMODE r={r} c={c} result={skip_mode} tell_after={}", |
| @@ -16684,7 +16851,12 @@ fn decode_inter_block( | |||
| 16684 | ); | 16851 | ); |
| 16685 | } | 16852 | } |
| 16686 | let is_compound = | 16853 | let is_compound = |
| 16687 | - skip_mode || (reference_select && read_comp_mode(dec, cdfs, above_nbr, left_nbr)); | 16854 | + skip_mode |
| 16855 | + || (reference_select | ||
| 16856 | + // `is_comp_ref_allowed` (blockd.h:65) gates the | ||
| 16857 | + // `comp_mode` read exactly as it gates `skip_mode`. | ||
| 16858 | + && comp_allowed | ||
| 16859 | + && read_comp_mode(dec, cdfs, above_nbr, left_nbr)); | ||
| 16688 | if is_compound { | 16860 | if is_compound { |
| 16689 | let (ref0, ref1) = if skip_mode { | 16861 | let (ref0, ref1) = if skip_mode { |
| 16690 | (skip_mode_frame[0] as i8, skip_mode_frame[1] as i8) | 16862 | (skip_mode_frame[0] as i8, skip_mode_frame[1] as i8) |
| @@ -16913,16 +17085,23 @@ fn decode_inter_block( | |||
| 16913 | // writes NO `compound_type` symbol there and INFERS | 17085 | // writes NO `compound_type` symbol there and INFERS |
| 16914 | // `COMPOUND_DIFFWTD` -- only the 1-bit `mask_type` literal | 17086 | // `COMPOUND_DIFFWTD` -- only the 1-bit `mask_type` literal |
| 16915 | // follows. `None` here is exactly that inferred arm. | 17087 | // follows. `None` here is exactly that inferred arm. |
| 16916 | - let wedge_bsize = match side { | 17088 | + // lane-inter16ab r3: the row is this block's TRUE |
| 16917 | - 8 => Some(3), | 17089 | + // `BLOCK_SIZES_ALL` index, not the enclosing square `side`'s |
| 16918 | - 16 => Some(6), | 17090 | + // -- a 16x8 strip reads `compound_type_cdf[BLOCK_16X8]`. |
| 16919 | - 32 => Some(9), | 17091 | + let wedge_bsize = |
| 16920 | - _ => None, | 17092 | + bsize_all_index(write_w, write_h).filter(|_| wedge_used_bsize(write_w, write_h)); |
| 16921 | - }; | ||
| 16922 | let compound_type = match wedge_bsize { | 17093 | let compound_type = match wedge_bsize { |
| 16923 | Some(b) => dec.symbol(&mut cdfs.compound_type[b]), | 17094 | Some(b) => dec.symbol(&mut cdfs.compound_type[b]), |
| 16924 | None => 1, | 17095 | None => 1, |
| 16925 | }; | 17096 | }; |
| 17097 | + if wedge_bsize.is_some() && compound_type == 0 && write_w != write_h { | ||
| 17098 | + // The wedge mask codebook (`wedge.rs`) is built for the | ||
| 17099 | + // square sizes only; a rect wedge block is refused by | ||
| 17100 | + // name rather than blended with the wrong mask. | ||
| 17101 | + return Err(unsupported( | ||
| 17102 | + "a COMPOUND_WEDGE mask on a rectangular inter block (the wedge codebook is square-only)", | ||
| 17103 | + )); | ||
| 17104 | + } | ||
| 16926 | if let Some(wedge_bsize) = wedge_bsize.filter(|_| compound_type == 0) { | 17105 | if let Some(wedge_bsize) = wedge_bsize.filter(|_| compound_type == 0) { |
| 16927 | // COMPOUND_WEDGE: lane-wedge r3, codebook checksum- | 17106 | // COMPOUND_WEDGE: lane-wedge r3, codebook checksum- |
| 16928 | // verified vs independent C dump (wedge.rs). | 17107 | // verified vs independent C dump (wedge.rs). |
| @@ -17922,8 +18101,19 @@ fn decode_inter_block( | |||
| 17922 | // `enable_interintra_wedge` seq bit -- the wedge flag | 18101 | // `enable_interintra_wedge` seq bit -- the wedge flag |
| 17923 | // (`av1_is_wedge_used(bsize)` holds for 16x16/32x32). | 18102 | // (`av1_is_wedge_used(bsize)` holds for 16x16/32x32). |
| 17924 | let ii = dec.symbol(&mut cdfs.interintra_mode[bsize_group]) as u8; | 18103 | let ii = dec.symbol(&mut cdfs.interintra_mode[bsize_group]) as u8; |
| 17925 | - let wedge_bsize = if side == 16 { 6 } else { 9 }; | 18104 | + // lane-inter16ab r3 (same class as the compound |
| 18105 | + // `compound_type` row below): the row is the block's TRUE | ||
| 18106 | + // `BLOCK_SIZES_ALL` index -- a 16x8 / 32x16 interintra | ||
| 18107 | + // strip is BLOCK_16X8 / BLOCK_32X16, not its square | ||
| 18108 | + // `side`'s BLOCK_16X16 / BLOCK_32X32. | ||
| 18109 | + let wedge_bsize = bsize_all_index(write_w, write_h) | ||
| 18110 | + .expect("interintra shape is a BLOCK_SIZES_ALL size"); | ||
| 17926 | let wedge = dec.symbol(&mut cdfs.wedge_interintra[wedge_bsize]) == 1; | 18111 | let wedge = dec.symbol(&mut cdfs.wedge_interintra[wedge_bsize]) == 1; |
| 18112 | + if wedge && write_w != write_h { | ||
| 18113 | + return Err(unsupported( | ||
| 18114 | + "a wedge interintra mask on a rectangular inter block (the wedge codebook is square-only)", | ||
| 18115 | + )); | ||
| 18116 | + } | ||
| 17927 | if wedge { | 18117 | if wedge { |
| 17928 | // lane-wii r2 (spec 5.11.25): `wedge_index` is an | 18118 | // lane-wii r2 (spec 5.11.25): `wedge_index` is an |
| 17929 | // ADAPTING CDF symbol over the same `wedge_bsize` row; | 18119 | // ADAPTING CDF symbol over the same `wedge_bsize` row; |
| @@ -17975,6 +18165,9 @@ fn decode_inter_block( | |||
| 17975 | // motion_mode symbol is NOT read (SIMPLE_TRANSLATION implied). | 18165 | // motion_mode symbol is NOT read (SIMPLE_TRANSLATION implied). |
| 17976 | let motion_mode_eligible = switchable_motion_mode | 18166 | let motion_mode_eligible = switchable_motion_mode |
| 17977 | && !skip_mode | 18167 | && !skip_mode |
| 18168 | + // `is_motion_variation_allowed_bsize` (blockd.h:1455): | ||
| 18169 | + // min(bw, bh) >= 8, false for a 16x4 / 4x16 strip. | ||
| 18170 | + && write_w.min(write_h) >= 8 | ||
| 17978 | && interintra_mode.is_none() | 18171 | && interintra_mode.is_none() |
| 17979 | && (!overlappable_above(grid, mi_row, mi_col, bw4, mi_cols as usize, 1).is_empty() | 18172 | && (!overlappable_above(grid, mi_row, mi_col, bw4, mi_cols as usize, 1).is_empty() |
| 17980 | || !overlappable_left(grid, mi_row, mi_col, bh4, mi_rows as usize, 1) | 18173 | || !overlappable_left(grid, mi_row, mi_col, bh4, mi_rows as usize, 1) |
| @@ -18283,6 +18476,11 @@ fn decode_inter_block( | |||
| 18283 | } | 18476 | } |
| 18284 | } | 18477 | } |
| 18285 | 18478 | ||
| 18479 | + // lane-inter16ab r2: `is_sub8x8_inter`'s neighbour walk reads the | ||
| 18480 | + // PREVIOUS strip's `mv`/`ref_frame`/`interp_filters` | ||
| 18481 | + // (reconinter_template.inc:75-82); record them for the next 1:4 | ||
| 18482 | + // strip, which is the only reader. | ||
| 18483 | + INTER_LAST_MC.with(|c| c.set(Some((ref_frame, mv, h_filter, v_filter)))); | ||
| 18286 | let mut pred_y = vec![0u16; side * side]; | 18484 | let mut pred_y = vec![0u16; side * side]; |
| 18287 | let mut pred_u = vec![0u16; chroma_side * chroma_side]; | 18485 | let mut pred_u = vec![0u16; chroma_side * chroma_side]; |
| 18288 | let mut pred_v = vec![0u16; chroma_side * chroma_side]; | 18486 | let mut pred_v = vec![0u16; chroma_side * chroma_side]; |
| @@ -18444,6 +18642,46 @@ fn decode_inter_block( | |||
| 18444 | interintra_blend(v, cpx, cpy, chroma_side, ii, wedge_mask, &mut pred_v); | 18642 | interintra_blend(v, cpx, cpy, chroma_side, ii, wedge_mask, &mut pred_v); |
| 18445 | } | 18643 | } |
| 18446 | 18644 | ||
| 18645 | + // lane-inter16ab r2: libaom `build_inter_predictors_sub8x8` | ||
| 18646 | + // (reconinter_template.inc:87-160). A 4:2:0 chroma block under a | ||
| 18647 | + // 16x4 (4x16) luma pair covers TWO luma blocks, so it is built in | ||
| 18648 | + // `b4_w x b4_h` = 8x2 (2x8) pieces, each from its own strip's | ||
| 18649 | + // mv/ref/filters. The bottom (right) piece is this strip's own mv | ||
| 18650 | + // over its own rows, which the whole-block prediction above | ||
| 18651 | + // already wrote there (MC is position-invariant for a fixed mv), | ||
| 18652 | + // so only the FIRST piece has to be rebuilt -- and only when | ||
| 18653 | + // `is_sub8x8_inter` holds, i.e. the previous strip was itself a | ||
| 18654 | + // single-reference inter block (`prev`), else libaom falls | ||
| 18655 | + // through to the ordinary whole-block predictor. | ||
| 18656 | + if let Some(s) = strip_chroma.filter(|s| s.has_chroma) | ||
| 18657 | + && let Some((prev_ref, prev_mv, prev_h, prev_v)) = s.prev | ||
| 18658 | + && luma_scale == mc::REF_NO_SCALE | ||
| 18659 | + { | ||
| 18660 | + let (piece_w, piece_h) = if s.horz { (8usize, 2usize) } else { (2usize, 8usize) }; | ||
| 18661 | + let (_, prev_u, prev_v_plane) = ref_planes(prev_ref, ref_y, ref_u, ref_v, other_refs)?; | ||
| 18662 | + for (src, dst) in [(prev_u, &mut pred_u), (prev_v_plane, &mut pred_v)] { | ||
| 18663 | + let mut piece = vec![0u16; piece_w * piece_h]; | ||
| 18664 | + mc::predict_with_filters( | ||
| 18665 | + &src.data, | ||
| 18666 | + src.width, | ||
| 18667 | + src.true_width, | ||
| 18668 | + src.true_height, | ||
| 18669 | + mv_to_q4(cpx, prev_mv.1, false), | ||
| 18670 | + mv_to_q4(cpy, prev_mv.0, false), | ||
| 18671 | + piece_w, | ||
| 18672 | + piece_h, | ||
| 18673 | + prev_h, | ||
| 18674 | + prev_v, | ||
| 18675 | + &mut piece, | ||
| 18676 | + ); | ||
| 18677 | + for row in 0..piece_h { | ||
| 18678 | + dst[row * chroma_side..row * chroma_side + piece_w] | ||
| 18679 | + .copy_from_slice(&piece[row * piece_w..(row + 1) * piece_w]); | ||
| 18680 | + } | ||
| 18681 | + } | ||
| 18682 | + INTER16_SUB8_PIECE_HITS.with(|c| c.set(c.get() + 1)); | ||
| 18683 | + } | ||
| 18684 | + | ||
| 18447 | // lane-inter4 r2: a rectangular strip's transform tree starts from | 18685 | // lane-inter4 r2: a rectangular strip's transform tree starts from |
| 18448 | // its own rect `max_txsize_rect_lookup` entry, not a square one. | 18686 | // its own rect `max_txsize_rect_lookup` entry, not a square one. |
| 18449 | let rect_tu = (write_w, write_h) != (side, side); | 18687 | let rect_tu = (write_w, write_h) != (side, side); |
| @@ -18480,24 +18718,26 @@ fn decode_inter_block( | |||
| 18480 | &pred_y, | 18718 | &pred_y, |
| 18481 | &vec![0i32; side * side], | 18719 | &vec![0i32; side * side], |
| 18482 | ); | 18720 | ); |
| 18483 | - u.reconstruct_mc_rect( | 18721 | + if has_chroma { |
| 18484 | - cpx, | 18722 | + u.reconstruct_mc_rect( |
| 18485 | - cpy, | 18723 | + cpx, |
| 18486 | - chroma_side, | 18724 | + cpy, |
| 18487 | - write_chroma_w, | 18725 | + chroma_side, |
| 18488 | - write_chroma_h, | 18726 | + write_chroma_w, |
| 18489 | - &pred_u, | 18727 | + write_chroma_h, |
| 18490 | - &vec![0i32; chroma_side * chroma_side], | 18728 | + &pred_u, |
| 18491 | - ); | 18729 | + &vec![0i32; chroma_side * chroma_side], |
| 18492 | - v.reconstruct_mc_rect( | 18730 | + ); |
| 18493 | - cpx, | 18731 | + v.reconstruct_mc_rect( |
| 18494 | - cpy, | 18732 | + cpx, |
| 18495 | - chroma_side, | 18733 | + cpy, |
| 18496 | - write_chroma_w, | 18734 | + chroma_side, |
| 18497 | - write_chroma_h, | 18735 | + write_chroma_w, |
| 18498 | - &pred_v, | 18736 | + write_chroma_h, |
| 18499 | - &vec![0i32; chroma_side * chroma_side], | 18737 | + &pred_v, |
| 18500 | - ); | 18738 | + &vec![0i32; chroma_side * chroma_side], |
| 18739 | + ); | ||
| 18740 | + } | ||
| 18501 | luma_grid = vec![0i32; side * side]; | 18741 | luma_grid = vec![0i32; side * side]; |
| 18502 | u_grid = vec![0i32; chroma_side * chroma_side]; | 18742 | u_grid = vec![0i32; chroma_side * chroma_side]; |
| 18503 | v_grid = vec![0i32; chroma_side * chroma_side]; | 18743 | v_grid = vec![0i32; chroma_side * chroma_side]; |
| @@ -18510,6 +18750,18 @@ fn decode_inter_block( | |||
| 18510 | } else { | 18750 | } else { |
| 18511 | neighbours.around_mi(at, side) | 18751 | neighbours.around_mi(at, side) |
| 18512 | }; | 18752 | }; |
| 18753 | + // lane-inter16ab r2: the pair's chroma transform sits at the | ||
| 18754 | + // EVEN strip's mi origin and spans both strips, so its | ||
| 18755 | + // above/left coefficient context is the pair's, not this | ||
| 18756 | + // strip's row. | ||
| 18757 | + let around_c = match strip_chroma { | ||
| 18758 | + Some(s) if s.has_chroma => neighbours.around_mi_rect( | ||
| 18759 | + s.pair_mi, | ||
| 18760 | + if s.horz { 16 } else { 8 }, | ||
| 18761 | + if s.horz { 8 } else { 16 }, | ||
| 18762 | + ), | ||
| 18763 | + _ => around, | ||
| 18764 | + }; | ||
| 18513 | let luma_tx_type; | 18765 | let luma_tx_type; |
| 18514 | if let Some(leaves) = vartx_leaves.clone() { | 18766 | if let Some(leaves) = vartx_leaves.clone() { |
| 18515 | // spec 5.11.17's transform tree, leaf by leaf in the order | 18767 | // spec 5.11.17's transform tree, leaf by leaf in the order |
| @@ -18627,7 +18879,16 @@ fn decode_inter_block( | |||
| 18627 | None, | 18879 | None, |
| 18628 | )?; | 18880 | )?; |
| 18629 | } | 18881 | } |
| 18630 | - if rect_tu { | 18882 | + if !has_chroma { |
| 18883 | + // `is_chroma_reference` is false for this strip: libaom's | ||
| 18884 | + // plane loop (decodeframe.c | ||
| 18885 | + // `predict_and_reconstruct_intra_block`/ | ||
| 18886 | + // `reconstruct_inter_block`'s `for (plane...)` guarded by | ||
| 18887 | + // `xd->is_chroma_ref`) codes NO chroma transform here, so | ||
| 18888 | + // neither symbol nor context exists. | ||
| 18889 | + u_grid = vec![0i32; chroma_side * chroma_side]; | ||
| 18890 | + v_grid = vec![0i32; chroma_side * chroma_side]; | ||
| 18891 | + } else if rect_tu { | ||
| 18631 | // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a | 18892 | // `av1_get_max_uv_txsize(bsize)`: the chroma transform of a |
| 18632 | // 2:1 strip is the strip's own rect chroma size (16x8 / | 18893 | // 2:1 strip is the strip's own rect chroma size (16x8 / |
| 18633 | // 8x16), one unit for the whole block, and it codes no | 18894 | // 8x16), one unit for the whole block, and it codes no |
| @@ -18641,7 +18902,7 @@ fn decode_inter_block( | |||
| 18641 | (uw, uh), | 18902 | (uw, uh), |
| 18642 | chroma_side, | 18903 | chroma_side, |
| 18643 | 1, | 18904 | 1, |
| 18644 | - around[1], | 18905 | + around_c[1], |
| 18645 | mode_for_tx, | 18906 | mode_for_tx, |
| 18646 | u, | 18907 | u, |
| 18647 | cpx, | 18908 | cpx, |
| @@ -18663,7 +18924,7 @@ fn decode_inter_block( | |||
| 18663 | (uw, uh), | 18924 | (uw, uh), |
| 18664 | chroma_side, | 18925 | chroma_side, |
| 18665 | 2, | 18926 | 2, |
| 18666 | - around[2], | 18927 | + around_c[2], |
| 18667 | mode_for_tx, | 18928 | mode_for_tx, |
| 18668 | v, | 18929 | v, |
| 18669 | cpx, | 18930 | cpx, |
| @@ -18724,6 +18985,16 @@ fn decode_inter_block( | |||
| 18724 | // skip path above (which only needed a clipped write of an | 18985 | // skip path above (which only needed a clipped write of an |
| 18725 | // already-square-predicted buffer). Named refusal instead of a | 18986 | // already-square-predicted buffer). Named refusal instead of a |
| 18726 | // silently wrong square-shaped intra prediction. | 18987 | // silently wrong square-shaped intra prediction. |
| 18988 | + // lane-inter16ab r2: `decode_intra_rect_in_inter` has no chroma-pair | ||
| 18989 | + // path (it predicts and codes chroma at the strip's own halved | ||
| 18990 | + // footprint), so an INTRA 16x4 / 4x16 strip inside a 1:4 partition is | ||
| 18991 | + // refused by name rather than decoded with a 8x2 chroma transform | ||
| 18992 | + // libaom never coded. | ||
| 18993 | + if write_w.min(write_h) < 8 { | ||
| 18994 | + return Err(unsupported( | ||
| 18995 | + "an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition (its 4:2:0 chroma pair is coded once for two strips; only the inter path implements that pairing)", | ||
| 18996 | + )); | ||
| 18997 | + } | ||
| 18727 | if write_w != side || write_h != side { | 18998 | if write_w != side || write_h != side { |
| 18728 | // lane-intrarect r1: the strip decodes through its own rect | 18999 | // lane-intrarect r1: the strip decodes through its own rect |
| 18729 | // machinery ([`decode_intra_rect_in_inter`] -> the key-frame | 19000 | // machinery ([`decode_intra_rect_in_inter`] -> the key-frame |
| @@ -19140,6 +19411,14 @@ fn decode_inter_block( | |||
| 19140 | rmi, cmi, dec.debug_bitpos(), dec.debug_state().0 | 19411 | rmi, cmi, dec.debug_bitpos(), dec.debug_state().0 |
| 19141 | ); | 19412 | ); |
| 19142 | } | 19413 | } |
| 19414 | + // lane-inter16ab r2: the pair's chroma coefficient context spans BOTH | ||
| 19415 | + // strips (mirroring the intra `decode_rect4_16` path), and the even | ||
| 19416 | + // strip's own record wrote empty chroma state over those cells -- this | ||
| 19417 | + // rewrite is what libaom's single `av1_set_contexts` call for the 8x4 | ||
| 19418 | + // (4x8) chroma unit leaves behind. | ||
| 19419 | + let pair_chroma = strip_chroma | ||
| 19420 | + .filter(|s| s.has_chroma) | ||
| 19421 | + .map(|s| (s, neighbour_state(&u_grid), neighbour_state(&v_grid))); | ||
| 19143 | if vartx_leaves.is_some() { | 19422 | if vartx_leaves.is_some() { |
| 19144 | // Plane 0 is already correct per transform unit | 19423 | // Plane 0 is already correct per transform unit |
| 19145 | // ([`Neighbours::record_mi_luma`] above); this writes everything else | 19424 | // ([`Neighbours::record_mi_luma`] above); this writes everything else |
| @@ -19156,6 +19435,32 @@ fn decode_inter_block( | |||
| 19156 | &[luma_grid, u_grid, v_grid], | 19435 | &[luma_grid, u_grid, v_grid], |
| 19157 | ); | 19436 | ); |
| 19158 | } | 19437 | } |
| 19438 | + if let Some((s, u_state, v_state)) = pair_chroma { | ||
| 19439 | + let (pw, ph) = if s.horz { (16usize, 8usize) } else { (8, 16) }; | ||
| 19440 | + let round_up_even = |n: usize| n.div_ceil(2) * 2; | ||
| 19441 | + let (bound_h, bound_w) = ( | ||
| 19442 | + round_up_even(neighbours.mi_rows), | ||
| 19443 | + round_up_even(neighbours.mi_cols), | ||
| 19444 | + ); | ||
| 19445 | + for cell in 0..(ph / MI) { | ||
| 19446 | + if s.pair_mi.0 + cell < bound_h | ||
| 19447 | + && let Some(slot) = neighbours.left.get_mut(s.pair_mi.0 + cell) | ||
| 19448 | + { | ||
| 19449 | + slot[1] = u_state; | ||
| 19450 | + slot[2] = v_state; | ||
| 19451 | + } | ||
| 19452 | + } | ||
| 19453 | + for cell in 0..(pw / MI) { | ||
| 19454 | + if s.pair_mi.1 + cell < bound_w | ||
| 19455 | + && let Some(slot) = neighbours.above.get_mut(s.pair_mi.1 + cell) | ||
| 19456 | + { | ||
| 19457 | + slot[1] = u_state; | ||
| 19458 | + slot[2] = v_state; | ||
| 19459 | + } | ||
| 19460 | + } | ||
| 19461 | + neighbours.record_uv_mode_mi(s.pair_mi.0, s.pair_mi.1, pw / MI, ph / MI, uv_predict_mode); | ||
| 19462 | + INTER16_CHROMA_PAIR_HITS.with(|c| c.set(c.get() + 1)); | ||
| 19463 | + } | ||
| 19159 | neighbours.record_inter_rect_mi( | 19464 | neighbours.record_inter_rect_mi( |
| 19160 | at, | 19465 | at, |
| 19161 | write_w / MI, | 19466 | write_w / MI, |
| @@ -21256,6 +21561,83 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 21256 | )? | 21561 | )? |
| 21257 | }; | 21562 | }; |
| 21258 | } | 21563 | } |
| 21564 | + // lane-inter16ab r1: one 8x8 inter leaf of a 16x16-level AB | ||
| 21565 | + // partition (libaom `decode_partition` PARTITION_HORZ_A/_B/ | ||
| 21566 | + // VERT_A/_B at BLOCK_16X16 code `bsize2` = BLOCK_8X8 for two of | ||
| 21567 | + // their three pieces, decodeframe.c ~1900). Same body the | ||
| 21568 | + // PARTITION_SPLIT arm runs per leaf, minus its own partition | ||
| 21569 | + // symbol (an AB piece carries none) and its `prev_leaves` | ||
| 21570 | + // bookkeeping. | ||
| 21571 | + macro_rules! inter_leaf8 { | ||
| 21572 | + ($outer:expr, $leaf:expr) => {{ | ||
| 21573 | + let leaf_mi = $leaf; | ||
| 21574 | + let ( | ||
| 21575 | + skip, | ||
| 21576 | + is_inter, | ||
| 21577 | + skip_mode_leaf, | ||
| 21578 | + compound_ctx8, | ||
| 21579 | + leaf_filter, | ||
| 21580 | + leaf_refs, | ||
| 21581 | + ) = decode_inter_block8( | ||
| 21582 | + &mut dec, | ||
| 21583 | + &mut cdfs, | ||
| 21584 | + &mut neighbours, | ||
| 21585 | + &mut grid, | ||
| 21586 | + mi_cols, | ||
| 21587 | + mi_rows, | ||
| 21588 | + $outer, | ||
| 21589 | + leaf_mi, | ||
| 21590 | + &mut y, | ||
| 21591 | + &mut u, | ||
| 21592 | + &mut v, | ||
| 21593 | + &ref_y, | ||
| 21594 | + &ref_u, | ||
| 21595 | + &ref_v, | ||
| 21596 | + &ref_slots, | ||
| 21597 | + base_q_idx, | ||
| 21598 | + &scan8, | ||
| 21599 | + &scan4, | ||
| 21600 | + allow_high_precision_mv, | ||
| 21601 | + force_integer_mv, | ||
| 21602 | + &global_motion, | ||
| 21603 | + enable_dual_filter, | ||
| 21604 | + reference_select, | ||
| 21605 | + enable_masked_compound, | ||
| 21606 | + enable_interintra_compound, | ||
| 21607 | + enable_jnt_comp, | ||
| 21608 | + order_hint_bits, | ||
| 21609 | + order_hint, | ||
| 21610 | + ref_order_hints, | ||
| 21611 | + skip_mode_present, | ||
| 21612 | + skip_mode_frame, | ||
| 21613 | + reduced_tx_set, | ||
| 21614 | + interp_fixed, | ||
| 21615 | + switchable_motion_mode, | ||
| 21616 | + allow_warped_motion, | ||
| 21617 | + allow_screen_content_tools, | ||
| 21618 | + &sign_bias_table, | ||
| 21619 | + tpl_frame.as_ref(), | ||
| 21620 | + frame_width as usize, | ||
| 21621 | + )?; | ||
| 21622 | + neighbours.record_inter_rect_mi( | ||
| 21623 | + leaf_mi, | ||
| 21624 | + 2, | ||
| 21625 | + 2, | ||
| 21626 | + skip, | ||
| 21627 | + is_inter, | ||
| 21628 | + leaf_refs.0, | ||
| 21629 | + leaf_filter, | ||
| 21630 | + skip_mode_leaf, | ||
| 21631 | + ); | ||
| 21632 | + if let Some(ref1) = leaf_refs.1 | ||
| 21633 | + && let Some((_, _, group_idx, idx)) = compound_ctx8 | ||
| 21634 | + { | ||
| 21635 | + neighbours.record_compound_ctx_rect_mi( | ||
| 21636 | + leaf_mi, 2, 2, ref1, group_idx, idx, | ||
| 21637 | + ); | ||
| 21638 | + } | ||
| 21639 | + }}; | ||
| 21640 | + } | ||
| 21259 | let sb_ctx = neighbours.partition_ctx(sb_at, SB); | 21641 | let sb_ctx = neighbours.partition_ctx(sb_at, SB); |
| 21260 | let (has_cols, has_rows) = ( | 21642 | let (has_cols, has_rows) = ( |
| 21261 | sb_c * SB_MI + SB_MI / 2 < mi_cols, | 21643 | sb_c * SB_MI + SB_MI / 2 < mi_cols, |
| @@ -21739,9 +22121,191 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 21739 | frame_width as usize, | 22121 | frame_width as usize, |
| 21740 | )?; | 22122 | )?; |
| 21741 | } | 22123 | } |
| 22124 | + } else if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&part16) { | ||
| 22125 | + // lane-inter16ab r1: the four AB (T-shaped) | ||
| 22126 | + // partitions at the 16x16 level of an INTER | ||
| 22127 | + // frame -- two 8x8 inter leaves plus one true | ||
| 22128 | + // 16x8/8x16 inter strip. libaom | ||
| 22129 | + // `decode_partition` (decodeframe.c ~5040, | ||
| 22130 | + // `bsize2 = get_partition_subsize(bsize, | ||
| 22131 | + // PARTITION_SPLIT)` = BLOCK_8X8 here) visits: | ||
| 22132 | + // HORZ_A: TL 8x8, TR 8x8, bottom 16x8 | ||
| 22133 | + // HORZ_B: top 16x8, BL 8x8, BR 8x8 | ||
| 22134 | + // VERT_A: TL 8x8, BL 8x8, right 8x16 | ||
| 22135 | + // VERT_B: left 8x16, TR 8x8, BR 8x8 | ||
| 22136 | + // Every piece is inside the frame by | ||
| 22137 | + // construction: an AB value can only be read | ||
| 22138 | + // from the (has_cols16 && has_rows16) branch | ||
| 22139 | + // above, i.e. mi_row+2 < mi_rows and | ||
| 22140 | + // mi_col+2 < mi_cols, which is exactly | ||
| 22141 | + // libaom's own `has_rows`/`has_cols`. | ||
| 22142 | + // | ||
| 22143 | + // VERT_A/VERT_B visit TL,BL,TR,BR, so a | ||
| 22144 | + // bottom-left square's top-right neighbour is | ||
| 22145 | + // the partition's own not-yet-decoded | ||
| 22146 | + // rectangle: libaom switches those squares | ||
| 22147 | + // onto `has_tr_vert_*`/`has_bl_vert_*` | ||
| 22148 | + // (`reconintra.c get_has_tr_table`) -- | ||
| 22149 | + // `Reach::vert_ab_partition()`, the same | ||
| 22150 | + // guard the intra 16-level arm and the | ||
| 22151 | + // 32-level inter AB arms take (class | ||
| 22152 | + // `visit-order-changes-availability`). | ||
| 22153 | + // | ||
| 22154 | + // OBMC/warp and compound stay legal here: | ||
| 22155 | + // every piece is >= 8x8, so libaom's | ||
| 22156 | + // `is_motion_variation_allowed_bsize` | ||
| 22157 | + // (min(bw,bh) >= 8, blockd.h) and | ||
| 22158 | + // `is_comp_ref_allowed` (block_size_wide + | ||
| 22159 | + // block_size_high >= 16, blockd.h) both hold | ||
| 22160 | + // and the leaf/strip decoders' own gates | ||
| 22161 | + // apply unchanged. | ||
| 22162 | + bump_ab16_inter(part16 - PARTITION_HORZ_A); | ||
| 22163 | + let _vert_guard = if part16 == PARTITION_VERT_A | ||
| 22164 | + || part16 == PARTITION_VERT_B | ||
| 22165 | + { | ||
| 22166 | + Some(crate::encode::Reach::vert_ab_partition()) | ||
| 22167 | + } else { | ||
| 22168 | + None | ||
| 22169 | + }; | ||
| 22170 | + let (mi_row0, mi_col0) = sub16_to_mi(at16); | ||
| 22171 | + let tl = (mi_row0, mi_col0); | ||
| 22172 | + let tr = (mi_row0, mi_col0 + 2); | ||
| 22173 | + let bl = (mi_row0 + 2, mi_col0); | ||
| 22174 | + let br = (mi_row0 + 2, mi_col0 + 2); | ||
| 22175 | + macro_rules! ab_strip16 { | ||
| 22176 | + ($mi:expr, $ww:expr, $wh:expr) => { | ||
| 22177 | + inter_piece!( | ||
| 22178 | + $mi, | ||
| 22179 | + SUB, | ||
| 22180 | + TxbSet::Luma16, | ||
| 22181 | + if reduced_tx_set { | ||
| 22182 | + TxbSet::Luma16Inter | ||
| 22183 | + } else { | ||
| 22184 | + TxbSet::Luma16InterSet1 | ||
| 22185 | + }, | ||
| 22186 | + TxbSet::Chroma8, | ||
| 22187 | + TX16, | ||
| 22188 | + TX8, | ||
| 22189 | + &scan16, | ||
| 22190 | + &scan8, | ||
| 22191 | + 1, | ||
| 22192 | + $ww, | ||
| 22193 | + $wh | ||
| 22194 | + ) | ||
| 22195 | + }; | ||
| 22196 | + } | ||
| 22197 | + match part16 { | ||
| 22198 | + PARTITION_HORZ_A => { | ||
| 22199 | + inter_leaf8!(at16, tl); | ||
| 22200 | + inter_leaf8!(at16, tr); | ||
| 22201 | + ab_strip16!(bl, 16, 8); | ||
| 22202 | + } | ||
| 22203 | + PARTITION_HORZ_B => { | ||
| 22204 | + ab_strip16!(tl, 16, 8); | ||
| 22205 | + inter_leaf8!(at16, bl); | ||
| 22206 | + inter_leaf8!(at16, br); | ||
| 22207 | + } | ||
| 22208 | + PARTITION_VERT_A => { | ||
| 22209 | + inter_leaf8!(at16, tl); | ||
| 22210 | + inter_leaf8!(at16, bl); | ||
| 22211 | + ab_strip16!(tr, 8, 16); | ||
| 22212 | + } | ||
| 22213 | + _ => { | ||
| 22214 | + ab_strip16!(tl, 8, 16); | ||
| 22215 | + inter_leaf8!(at16, tr); | ||
| 22216 | + inter_leaf8!(at16, br); | ||
| 22217 | + } | ||
| 22218 | + } | ||
| 22219 | + } else if part16 == PARTITION_HORZ_4 | ||
| 22220 | + || part16 == PARTITION_VERT_4 | ||
| 22221 | + { | ||
| 22222 | + // lane-inter16ab r2: four 16x4 (4x16) INTER | ||
| 22223 | + // strips. libaom `decode_partition` | ||
| 22224 | + // (decodeframe.c, PARTITION_HORZ_4/VERT_4) | ||
| 22225 | + // walks them top to bottom (left to right) | ||
| 22226 | + // with its own `i > 0` frame-edge break. | ||
| 22227 | + // | ||
| 22228 | + // Each strip is >= 8 in one dimension only, | ||
| 22229 | + // so `is_comp_ref_allowed`, | ||
| 22230 | + // `is_motion_variation_allowed_bsize` | ||
| 22231 | + // (blockd.h:65/1455, min(bw, bh) >= 8) and | ||
| 22232 | + // `is_interintra_allowed_bsize` (BLOCK_8X8.. | ||
| 22233 | + // BLOCK_32X32 in enum order, which excludes | ||
| 22234 | + // BLOCK_16X4 = 17) are all false: no | ||
| 22235 | + // skip_mode, no comp_mode, no OBMC/warp and | ||
| 22236 | + // no interintra symbol is read -- gated in | ||
| 22237 | + // `decode_inter_block` off `write_w`/ | ||
| 22238 | + // `write_h`. | ||
| 22239 | + // | ||
| 22240 | + // CHROMA is the pair's: | ||
| 22241 | + // `is_chroma_reference` | ||
| 22242 | + // (av1_common_int.h:1454) is false on the | ||
| 22243 | + // even strips, and the odd one codes one 8x4 | ||
| 22244 | + // (4x8) chroma transform at the pair's | ||
| 22245 | + // origin, built from BOTH strips' motion | ||
| 22246 | + // (`is_sub8x8_inter`). | ||
| 22247 | + let horz = part16 == PARTITION_HORZ_4; | ||
| 22248 | + let (mi_row0, mi_col0) = sub16_to_mi(at16); | ||
| 22249 | + let (bw, bh) = if horz { (16usize, 4usize) } else { (4usize, 16usize) }; | ||
| 22250 | + for i in 0..4usize { | ||
| 22251 | + let at_mi = if horz { | ||
| 22252 | + (mi_row0 + i, mi_col0) | ||
| 22253 | + } else { | ||
| 22254 | + (mi_row0, mi_col0 + i) | ||
| 22255 | + }; | ||
| 22256 | + if i > 0 | ||
| 22257 | + && (at_mi.0 >= mi_rows as usize | ||
| 22258 | + || at_mi.1 >= mi_cols as usize) | ||
| 22259 | + { | ||
| 22260 | + break; | ||
| 22261 | + } | ||
| 22262 | + let strip_has_chroma = i % 2 == 1; | ||
| 22263 | + let pair_mi = if !strip_has_chroma { | ||
| 22264 | + at_mi | ||
| 22265 | + } else if horz { | ||
| 22266 | + (at_mi.0 - 1, at_mi.1) | ||
| 22267 | + } else { | ||
| 22268 | + (at_mi.0, at_mi.1 - 1) | ||
| 22269 | + }; | ||
| 22270 | + INTER_STRIP_CHROMA.with(|c| { | ||
| 22271 | + c.set(Some(InterStripChroma { | ||
| 22272 | + has_chroma: strip_has_chroma, | ||
| 22273 | + horz, | ||
| 22274 | + pair_mi, | ||
| 22275 | + prev: if strip_has_chroma { | ||
| 22276 | + INTER_LAST_MC.with(std::cell::Cell::get) | ||
| 22277 | + } else { | ||
| 22278 | + None | ||
| 22279 | + }, | ||
| 22280 | + })) | ||
| 22281 | + }); | ||
| 22282 | + inter_piece!( | ||
| 22283 | + at_mi, | ||
| 22284 | + SUB, | ||
| 22285 | + TxbSet::Luma16, | ||
| 22286 | + if reduced_tx_set { | ||
| 22287 | + TxbSet::Luma16Inter | ||
| 22288 | + } else { | ||
| 22289 | + TxbSet::Luma16InterSet1 | ||
| 22290 | + }, | ||
| 22291 | + TxbSet::Chroma8, | ||
| 22292 | + TX16, | ||
| 22293 | + TX8, | ||
| 22294 | + &scan16, | ||
| 22295 | + &scan8, | ||
| 22296 | + 1, | ||
| 22297 | + bw, | ||
| 22298 | + bh | ||
| 22299 | + ); | ||
| 22300 | + if horz { | ||
| 22301 | + INTER16_HORZ4_HITS.with(|c| c.set(c.get() + 1)); | ||
| 22302 | + } else { | ||
| 22303 | + INTER16_VERT4_HITS.with(|c| c.set(c.get() + 1)); | ||
| 22304 | + } | ||
| 22305 | + } | ||
| 21742 | } else if part16 != PARTITION_SPLIT { | 22306 | } else if part16 != PARTITION_SPLIT { |
| 21743 | return Err(unsupported( | 22307 | return Err(unsupported( |
| 21744 | - "an inter 16x16-level AB or 1:4 partition (HORZ_A/HORZ_B/VERT_A/VERT_B/HORZ_4/VERT_4; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT or SPLIT)", | 22308 | + "an inter 16x16-level partition value outside NONE/HORZ/VERT/SPLIT/AB/1:4", |
| 21745 | )); | 22309 | )); |
| 21746 | } else { | 22310 | } else { |
| 21747 | if has_cols16 && has_rows16 { | 22311 | if has_cols16 && has_rows16 { |
crates/ec-av1/src/refusal_inventory.rsmodified+15 -1
| @@ -68,7 +68,21 @@ const REFUSALS: &[&str] = &[ | |||
| 68 | "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units", | 68 | "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units", |
| 69 | "an inter frame with no key frame before it", | 69 | "an inter frame with no key frame before it", |
| 70 | "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B; this decoder's inter tile path codes a superblock as NONE, SPLIT, HORZ, VERT, HORZ_4 or VERT_4)", | 70 | "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B; this decoder's inter tile path codes a superblock as NONE, SPLIT, HORZ, VERT, HORZ_4 or VERT_4)", |
| 71 | - "an inter 16x16-level AB or 1:4 partition (HORZ_A/HORZ_B/VERT_A/VERT_B/HORZ_4/VERT_4; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT or SPLIT)", | 71 | + // lane-inter16ab r1 lifted the AB half and r2 the 1:4 half (four 16x4 / |
| 72 | + // 4x16 inter strips, their 8x4/4x8 chroma pair built from BOTH strips' | ||
| 73 | + // motion vectors -- gate | ||
| 74 | + // `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact`). | ||
| 75 | + // Two narrower refusals are what is left of that shape: | ||
| 76 | + "an inter 16x16-level partition value outside NONE/HORZ/VERT/SPLIT/AB/1:4", | ||
| 77 | + // r2 residue: `vartx_leaves` is a list of SQUARE units, and | ||
| 78 | + // `sub_tx_size_map[TX_16X4]` is the rectangular TX_8X4 -- the split tree | ||
| 79 | + // and its per-unit residual reader both need rect leaves. | ||
| 80 | + "a COMPOUND_WEDGE mask on a rectangular inter block (the wedge codebook is square-only)", | ||
| 81 | + "a wedge interintra mask on a rectangular inter block (the wedge codebook is square-only)", | ||
| 82 | + // r2 residue: `decode_intra_rect_in_inter` codes chroma at the strip's own | ||
| 83 | + // halved footprint, which for a 16x4 strip is an 8x2 transform libaom | ||
| 84 | + // never wrote (its chroma is the PAIR's 8x4, coded by the odd strip). | ||
| 85 | + "an intra 16x4/4x16 strip inside an inter 16x16-level 1:4 partition (its 4:2:0 chroma pair is coded once for two strips; only the inter path implements that pairing)", | ||
| 72 | "an intra mode this decoder does not code (round 2)", | 86 | "an intra mode this decoder does not code (round 2)", |
| 73 | // lane-intrarect r1 lifted the whole-shape refusal that stood here (the | 87 | // lane-intrarect r1 lifted the whole-shape refusal that stood here (the |
| 74 | // inter path's intra arm now routes 2:1 strips through `decode_rect_split`); | 88 | // inter path's intra arm now routes 2:1 strips through `decode_rect_split`); |
crates/ec-av1/src/stream.rsmodified+463 -0
| @@ -8409,6 +8409,469 @@ mod tests { | |||
| 8409 | } | 8409 | } |
| 8410 | 8410 | ||
| 8411 | 8411 | ||
| 8412 | + #[test] | ||
| 8413 | + // lane-inter16ab r1: the 16x16-level AB partitions on an INTER frame -- | ||
| 8414 | + // PARTITION_HORZ_A/_HORZ_B/_VERT_A/_VERT_B at 16x16, i.e. two 8x8 inter | ||
| 8415 | + // leaves plus one true 16x8/8x16 inter strip. Every decode-order frame is | ||
| 8416 | + // compared Y/U/V against ffmpeg, refusals are counted and never SKIPped, | ||
| 8417 | + // out-of-scope mismatches fail the gate, and EACH of the four arms must | ||
| 8418 | + // have fired on a pixel-exact attempt (RD picking only HORZ_A is not | ||
| 8419 | + // proof of four). `--enable-1to4-partitions=0` because the 16-level 1:4 | ||
| 8420 | + // pair (16x4/4x16 inter strips) is still refused by name. | ||
| 8421 | + fn a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact() { | ||
| 8422 | + const NAME: &str = | ||
| 8423 | + "a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact"; | ||
| 8424 | + let _gate_lock = lock_gate_counters(); | ||
| 8425 | + if !have_ffmpeg() { | ||
| 8426 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 8427 | + return; | ||
| 8428 | + } | ||
| 8429 | + if !have_aomenc() { | ||
| 8430 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 8431 | + return; | ||
| 8432 | + } | ||
| 8433 | + let (width, height, frame_count) = (192usize, 128usize, 6usize); | ||
| 8434 | + // Per arm, over both bit depths: how many pixel-exact attempts fired | ||
| 8435 | + // it at least once. | ||
| 8436 | + let mut arms_total = [0u32; 4]; | ||
| 8437 | + for bit_depth in [8u32, 10u32] { | ||
| 8438 | + let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = | ||
| 8439 | + (0u32, 0u32, 0u32, 0u32); | ||
| 8440 | + let mut arms_proved = [0u32; 4]; | ||
| 8441 | + for attempt in 0..32u32 { | ||
| 8442 | + // Two sources (structure along X vs along Y -- an AB | ||
| 8443 | + // partition needs an L/T-shaped feature, so both orientations | ||
| 8444 | + // are swept), four quantisers, two motion steps, two tiling | ||
| 8445 | + // arms. r1 measured (sweep script in the report): a 16-attempt | ||
| 8446 | + // sweep at cq 34/22 alone never made aomenc's RD pick HORZ_A | ||
| 8447 | + // at 8 bits, so the quantiser axis is four wide here; cq 46 on | ||
| 8448 | + // the X-structured source is deliberately NOT in the list -- | ||
| 8449 | + // that stream's decode-order frame 4 desyncs on a defect this | ||
| 8450 | + // lane does not own (aomdec's own EC_PART trace reads ZERO | ||
| 8451 | + // AB partitions at BLOCK_16X16 anywhere in it, so the AB | ||
| 8452 | + // counters it raises are read out of an already-diverged | ||
| 8453 | + // stream; see lanes/inter16ab-r1.report.md). | ||
| 8454 | + let tx_search = if attempt % 2 == 0 { "0" } else { "1" }; | ||
| 8455 | + // The 10-bit arm swaps cq 40 for 28 on the same sources: at | ||
| 8456 | + // cq 40 the X-structured 10-bit stream mismatches ffmpeg with | ||
| 8457 | + // ZERO 16-level AB partitions in it (another shape's defect, | ||
| 8458 | + // measured r1 -- the gate's own `oos_mismatch` counter is | ||
| 8459 | + // what found it, and it is reported, not silenced). | ||
| 8460 | + let cq = if bit_depth == 10 { | ||
| 8461 | + [18, 22, 34, 28][(attempt / 2 % 4) as usize] | ||
| 8462 | + } else { | ||
| 8463 | + [18, 22, 34, 40][(attempt / 2 % 4) as usize] | ||
| 8464 | + }; | ||
| 8465 | + let natural = attempt / 8 % 2 == 1; | ||
| 8466 | + let group = attempt / 16; | ||
| 8467 | + // r1: a `--tile-columns=1` arm of this same sweep PANICS in | ||
| 8468 | + // `mc::from_switchable_symbol` (a 4th symbol out of a | ||
| 8469 | + // 3-symbol alphabet = someone else's desync, the signature | ||
| 8470 | + // the ledger already pins for the below-8x8 inter leaf), not | ||
| 8471 | + // in anything this lane added -- so the tiled arm is left out | ||
| 8472 | + // rather than turned into a SKIP or a weakened assert. | ||
| 8473 | + // Reported as residue in lanes/inter16ab-r1.report.md. | ||
| 8474 | + let tile_cols = "0"; | ||
| 8475 | + let sp = 3 + (group % 2) * 5; | ||
| 8476 | + let duration = frame_count as f64 / 25.0; | ||
| 8477 | + // Continuous-tone translating texture with a second, coarser | ||
| 8478 | + // component on the cross axis: aomenc's RD picks an AB | ||
| 8479 | + // partition where one 16x16 quadrant differs from its three | ||
| 8480 | + // siblings, which the two sinusoids at different periods | ||
| 8481 | + // produce all over the frame. | ||
| 8482 | + let lum = if natural { | ||
| 8483 | + format!("128+58*sin((Y+N*{sp})/6)+40*sin(X/11)+20*sin((X+Y)/5)") | ||
| 8484 | + } else { | ||
| 8485 | + format!("128+58*sin((X+N*{sp})/6)+40*sin(Y/11)+20*sin((X-Y)/5)") | ||
| 8486 | + }; | ||
| 8487 | + let source = format!( | ||
| 8488 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | ||
| 8489 | + geq=lum='{lum}',format=yuv420p" | ||
| 8490 | + ); | ||
| 8491 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 8492 | + let y4m = Command::new("ffmpeg") | ||
| 8493 | + .args([ | ||
| 8494 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | ||
| 8495 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 8496 | + ]) | ||
| 8497 | + .stdin(Stdio::null()) | ||
| 8498 | + .stdout(Stdio::piped()) | ||
| 8499 | + .stderr(Stdio::piped()) | ||
| 8500 | + .output() | ||
| 8501 | + .expect("ffmpeg failed to run"); | ||
| 8502 | + assert!( | ||
| 8503 | + y4m.status.success(), | ||
| 8504 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 8505 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 8506 | + ); | ||
| 8507 | + let cq_arg = format!("--cq-level={cq}"); | ||
| 8508 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 8509 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 8510 | + let tx_arg = format!("--enable-tx-size-search={tx_search}"); | ||
| 8511 | + let tile_arg = format!("--tile-columns={tile_cols}"); | ||
| 8512 | + let args: Vec<&str> = vec![ | ||
| 8513 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", | ||
| 8514 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | ||
| 8515 | + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", | ||
| 8516 | + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", | ||
| 8517 | + "--lag-in-frames=0", "--kf-max-dist=9999", &tile_arg, | ||
| 8518 | + // Per-arm overrides go LAST: aomenc keeps the last | ||
| 8519 | + // occurrence of a repeated --enable-* flag. | ||
| 8520 | + &tx_arg, | ||
| 8521 | + "--enable-rect-partitions=1", "--enable-ab-partitions=1", | ||
| 8522 | + "--enable-1to4-partitions=0", "--min-partition-size=8", | ||
| 8523 | + "--max-partition-size=16", | ||
| 8524 | + "--obu", "-o", "-", "-", | ||
| 8525 | + ]; | ||
| 8526 | + let mut child = Command::new(aomenc_path()) | ||
| 8527 | + .args(&args) | ||
| 8528 | + .stdin(Stdio::piped()) | ||
| 8529 | + .stdout(Stdio::piped()) | ||
| 8530 | + .stderr(Stdio::piped()) | ||
| 8531 | + .spawn() | ||
| 8532 | + .expect("aomenc failed to start"); | ||
| 8533 | + child | ||
| 8534 | + .stdin | ||
| 8535 | + .take() | ||
| 8536 | + .expect("aomenc stdin") | ||
| 8537 | + .write_all(&y4m.stdout) | ||
| 8538 | + .expect("writing y4m to aomenc"); | ||
| 8539 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 8540 | + assert!( | ||
| 8541 | + out.status.success(), | ||
| 8542 | + "aomenc refused the fixture: {}", | ||
| 8543 | + String::from_utf8_lossy(&out.stderr) | ||
| 8544 | + ); | ||
| 8545 | + let stream = out.stdout; | ||
| 8546 | + let before = decode::ab16_inter_hits_by_arm(); | ||
| 8547 | + let frames = match decode_stream(&stream) { | ||
| 8548 | + Err(e) => { | ||
| 8549 | + let msg = e.to_string(); | ||
| 8550 | + assert!( | ||
| 8551 | + msg.contains("unsupported"), | ||
| 8552 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ | ||
| 8553 | + attempt {attempt}): {msg}" | ||
| 8554 | + ); | ||
| 8555 | + named_refusals += 1; | ||
| 8556 | + eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); | ||
| 8557 | + continue; | ||
| 8558 | + } | ||
| 8559 | + Ok(frames) => frames, | ||
| 8560 | + }; | ||
| 8561 | + let after = decode::ab16_inter_hits_by_arm(); | ||
| 8562 | + let fired: Vec<usize> = | ||
| 8563 | + (0..4).map(|a| after[a] - before[a]).collect(); | ||
| 8564 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 8565 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 8566 | + } else { | ||
| 8567 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 8568 | + }; | ||
| 8569 | + assert_eq!(frames.len(), frame_count); | ||
| 8570 | + let mismatched = frames | ||
| 8571 | + .iter() | ||
| 8572 | + .zip(&ffmpeg_frames) | ||
| 8573 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | ||
| 8574 | + if fired.iter().sum::<usize>() == 0 { | ||
| 8575 | + out_of_scope += 1; | ||
| 8576 | + if mismatched { | ||
| 8577 | + oos_mismatch += 1; | ||
| 8578 | + eprintln!( | ||
| 8579 | + "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \ | ||
| 8580 | + 16-level inter AB partition -- another shape's defect" | ||
| 8581 | + ); | ||
| 8582 | + } | ||
| 8583 | + continue; | ||
| 8584 | + } | ||
| 8585 | + if mismatched { | ||
| 8586 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 8587 | + let bad: Vec<usize> = | ||
| 8588 | + (0..got.y.len()).filter(|&k| got.y[k] != want.y[k]).collect(); | ||
| 8589 | + if !bad.is_empty() { | ||
| 8590 | + eprintln!( | ||
| 8591 | + "{NAME}: attempt {attempt} {bit_depth}-bit frame {i}: {} luma \ | ||
| 8592 | + pixels differ, first at ({}, {}), max |delta| {}", | ||
| 8593 | + bad.len(), | ||
| 8594 | + bad[0] % width, | ||
| 8595 | + bad[0] / width, | ||
| 8596 | + bad.iter() | ||
| 8597 | + .map(|&k| (got.y[k] as i32 - want.y[k] as i32).abs()) | ||
| 8598 | + .max() | ||
| 8599 | + .unwrap_or(0) | ||
| 8600 | + ); | ||
| 8601 | + } | ||
| 8602 | + } | ||
| 8603 | + } | ||
| 8604 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 8605 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); | ||
| 8606 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); | ||
| 8607 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); | ||
| 8608 | + } | ||
| 8609 | + for a in 0..4 { | ||
| 8610 | + if fired[a] > 0 { | ||
| 8611 | + arms_proved[a] += 1; | ||
| 8612 | + arms_total[a] += 1; | ||
| 8613 | + } | ||
| 8614 | + } | ||
| 8615 | + matched += 1; | ||
| 8616 | + } | ||
| 8617 | + eprintln!( | ||
| 8618 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ | ||
| 8619 | + attempts carrying a 16-level inter AB partition, per-arm attempts \ | ||
| 8620 | + HORZ_A/HORZ_B/VERT_A/VERT_B={arms_proved:?}, {out_of_scope} attempts carried \ | ||
| 8621 | + none ({oos_mismatch} of them mismatched)" | ||
| 8622 | + ); | ||
| 8623 | + assert_eq!( | ||
| 8624 | + oos_mismatch, 0, | ||
| 8625 | + "{NAME}: {oos_mismatch} attempt(s) with no 16-level inter AB partition decoded \ | ||
| 8626 | + but mismatched ffmpeg -- a defect of another shape, not a pass" | ||
| 8627 | + ); | ||
| 8628 | + } | ||
| 8629 | + assert!( | ||
| 8630 | + arms_total.iter().all(|&n| n > 0), | ||
| 8631 | + "{NAME}: not every 16-level inter AB arm fired on a pixel-exact attempt \ | ||
| 8632 | + (HORZ_A/HORZ_B/VERT_A/VERT_B={arms_total:?}) -- the unfired arm(s) are unproven" | ||
| 8633 | + ); | ||
| 8634 | + } | ||
| 8635 | + | ||
| 8636 | + | ||
| 8637 | + | ||
| 8638 | + #[test] | ||
| 8639 | + // lane-inter16ab r2: the 16x16-level 1:4 partitions on an INTER frame -- | ||
| 8640 | + // PARTITION_HORZ_A/_HORZ_B/_VERT_A/_VERT_B at 16x16, i.e. two 8x8 inter | ||
| 8641 | + // leaves plus one true 16x8/8x16 inter strip. Every decode-order frame is | ||
| 8642 | + // compared Y/U/V against ffmpeg, refusals are counted and never SKIPped, | ||
| 8643 | + // out-of-scope mismatches fail the gate, and EACH of the four arms must | ||
| 8644 | + // have fired on a pixel-exact attempt (RD picking only HORZ_A is not | ||
| 8645 | + // proof of four). `--min-partition-size=4` is what lets aomenc's RD reach | ||
| 8646 | + // `PARTITION_HORZ_4`/`_VERT_4` at BLOCK_16X16 (16x4 / 4x16 inter strips); | ||
| 8647 | + // the last two counters are the chroma half of the claim -- the odd | ||
| 8648 | + // strip's `is_chroma_reference` pair and the pairs whose chroma was built | ||
| 8649 | + // from two different strips' motion vectors | ||
| 8650 | + // (`build_inter_predictors_sub8x8`). | ||
| 8651 | + fn a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact() { | ||
| 8652 | + const NAME: &str = | ||
| 8653 | + "a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact"; | ||
| 8654 | + let _gate_lock = lock_gate_counters(); | ||
| 8655 | + if !have_ffmpeg() { | ||
| 8656 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 8657 | + return; | ||
| 8658 | + } | ||
| 8659 | + if !have_aomenc() { | ||
| 8660 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 8661 | + return; | ||
| 8662 | + } | ||
| 8663 | + let (width, height, frame_count) = (192usize, 128usize, 6usize); | ||
| 8664 | + // Per arm, over both bit depths: how many pixel-exact attempts fired | ||
| 8665 | + // it at least once. | ||
| 8666 | + let mut arms_total = [0u32; 4]; | ||
| 8667 | + for bit_depth in [8u32, 10u32] { | ||
| 8668 | + let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = | ||
| 8669 | + (0u32, 0u32, 0u32, 0u32); | ||
| 8670 | + let mut arms_proved = [0u32; 4]; | ||
| 8671 | + for attempt in 0..32u32 { | ||
| 8672 | + // Two sources (structure along X vs along Y -- an AB | ||
| 8673 | + // partition needs an L/T-shaped feature, so both orientations | ||
| 8674 | + // are swept), four quantisers, two motion steps, two tiling | ||
| 8675 | + // arms. r1 measured (sweep script in the report): a 16-attempt | ||
| 8676 | + // sweep at cq 34/22 alone never made aomenc's RD pick HORZ_A | ||
| 8677 | + // at 8 bits, so the quantiser axis is four wide here; cq 46 on | ||
| 8678 | + // the X-structured source is deliberately NOT in the list -- | ||
| 8679 | + // that stream's decode-order frame 4 desyncs on a defect this | ||
| 8680 | + // lane does not own (aomdec's own EC_PART trace reads ZERO | ||
| 8681 | + // AB partitions at BLOCK_16X16 anywhere in it, so the AB | ||
| 8682 | + // counters it raises are read out of an already-diverged | ||
| 8683 | + // stream; see lanes/inter16ab-r1.report.md). | ||
| 8684 | + let tx_search = if attempt % 2 == 0 { "0" } else { "1" }; | ||
| 8685 | + // The 10-bit arm swaps cq 40 for 28 on the same sources: at | ||
| 8686 | + // cq 40 the X-structured 10-bit stream mismatches ffmpeg with | ||
| 8687 | + // ZERO 16-level AB partitions in it (another shape's defect, | ||
| 8688 | + // measured r1 -- the gate's own `oos_mismatch` counter is | ||
| 8689 | + // what found it, and it is reported, not silenced). | ||
| 8690 | + let cq = if bit_depth == 10 { | ||
| 8691 | + [18, 22, 34, 28][(attempt / 2 % 4) as usize] | ||
| 8692 | + } else { | ||
| 8693 | + [18, 22, 34, 40][(attempt / 2 % 4) as usize] | ||
| 8694 | + }; | ||
| 8695 | + let natural = attempt / 8 % 2 == 1; | ||
| 8696 | + let group = attempt / 16; | ||
| 8697 | + // r1: a `--tile-columns=1` arm of this same sweep PANICS in | ||
| 8698 | + // `mc::from_switchable_symbol` (a 4th symbol out of a | ||
| 8699 | + // 3-symbol alphabet = someone else's desync, the signature | ||
| 8700 | + // the ledger already pins for the below-8x8 inter leaf), not | ||
| 8701 | + // in anything this lane added -- so the tiled arm is left out | ||
| 8702 | + // rather than turned into a SKIP or a weakened assert. | ||
| 8703 | + // Reported as residue in lanes/inter16ab-r1.report.md. | ||
| 8704 | + let tile_cols = "0"; | ||
| 8705 | + let sp = 3 + (group % 2) * 5; | ||
| 8706 | + let duration = frame_count as f64 / 25.0; | ||
| 8707 | + // Continuous-tone translating texture with a second, coarser | ||
| 8708 | + // component on the cross axis: aomenc's RD picks an AB | ||
| 8709 | + // partition where one 16x16 quadrant differs from its three | ||
| 8710 | + // siblings, which the two sinusoids at different periods | ||
| 8711 | + // produce all over the frame. | ||
| 8712 | + let lum = if natural { | ||
| 8713 | + format!("128+58*sin((Y+N*{sp})/6)+40*sin(X/11)+20*sin((X+Y)/5)") | ||
| 8714 | + } else { | ||
| 8715 | + format!("128+58*sin((X+N*{sp})/6)+40*sin(Y/11)+20*sin((X-Y)/5)") | ||
| 8716 | + }; | ||
| 8717 | + let source = format!( | ||
| 8718 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | ||
| 8719 | + geq=lum='{lum}',format=yuv420p" | ||
| 8720 | + ); | ||
| 8721 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | ||
| 8722 | + let y4m = Command::new("ffmpeg") | ||
| 8723 | + .args([ | ||
| 8724 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | ||
| 8725 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | ||
| 8726 | + ]) | ||
| 8727 | + .stdin(Stdio::null()) | ||
| 8728 | + .stdout(Stdio::piped()) | ||
| 8729 | + .stderr(Stdio::piped()) | ||
| 8730 | + .output() | ||
| 8731 | + .expect("ffmpeg failed to run"); | ||
| 8732 | + assert!( | ||
| 8733 | + y4m.status.success(), | ||
| 8734 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | ||
| 8735 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 8736 | + ); | ||
| 8737 | + let cq_arg = format!("--cq-level={cq}"); | ||
| 8738 | + let depth_arg = format!("--bit-depth={bit_depth}"); | ||
| 8739 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | ||
| 8740 | + let tx_arg = format!("--enable-tx-size-search={tx_search}"); | ||
| 8741 | + let tile_arg = format!("--tile-columns={tile_cols}"); | ||
| 8742 | + let args: Vec<&str> = vec![ | ||
| 8743 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", | ||
| 8744 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | ||
| 8745 | + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", | ||
| 8746 | + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", | ||
| 8747 | + "--lag-in-frames=0", "--kf-max-dist=9999", &tile_arg, | ||
| 8748 | + // Per-arm overrides go LAST: aomenc keeps the last | ||
| 8749 | + // occurrence of a repeated --enable-* flag. | ||
| 8750 | + &tx_arg, | ||
| 8751 | + "--enable-rect-partitions=1", "--enable-ab-partitions=1", | ||
| 8752 | + "--enable-1to4-partitions=1", "--min-partition-size=4", | ||
| 8753 | + "--max-partition-size=16", | ||
| 8754 | + "--obu", "-o", "-", "-", | ||
| 8755 | + ]; | ||
| 8756 | + let mut child = Command::new(aomenc_path()) | ||
| 8757 | + .args(&args) | ||
| 8758 | + .stdin(Stdio::piped()) | ||
| 8759 | + .stdout(Stdio::piped()) | ||
| 8760 | + .stderr(Stdio::piped()) | ||
| 8761 | + .spawn() | ||
| 8762 | + .expect("aomenc failed to start"); | ||
| 8763 | + child | ||
| 8764 | + .stdin | ||
| 8765 | + .take() | ||
| 8766 | + .expect("aomenc stdin") | ||
| 8767 | + .write_all(&y4m.stdout) | ||
| 8768 | + .expect("writing y4m to aomenc"); | ||
| 8769 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 8770 | + assert!( | ||
| 8771 | + out.status.success(), | ||
| 8772 | + "aomenc refused the fixture: {}", | ||
| 8773 | + String::from_utf8_lossy(&out.stderr) | ||
| 8774 | + ); | ||
| 8775 | + let stream = out.stdout; | ||
| 8776 | + let before = decode::inter16_rect4_counters(); | ||
| 8777 | + let frames = match decode_stream(&stream) { | ||
| 8778 | + Err(e) => { | ||
| 8779 | + let msg = e.to_string(); | ||
| 8780 | + assert!( | ||
| 8781 | + msg.contains("unsupported"), | ||
| 8782 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ | ||
| 8783 | + attempt {attempt}): {msg}" | ||
| 8784 | + ); | ||
| 8785 | + named_refusals += 1; | ||
| 8786 | + eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); | ||
| 8787 | + continue; | ||
| 8788 | + } | ||
| 8789 | + Ok(frames) => frames, | ||
| 8790 | + }; | ||
| 8791 | + let after = decode::inter16_rect4_counters(); | ||
| 8792 | + // [16x4 strips, 4x16 strips, chroma pairs closed, chroma | ||
| 8793 | + // pairs built from two strips' motion vectors]. | ||
| 8794 | + let fired = [ | ||
| 8795 | + after.0 - before.0, | ||
| 8796 | + after.1 - before.1, | ||
| 8797 | + after.2 - before.2, | ||
| 8798 | + after.3 - before.3, | ||
| 8799 | + ]; | ||
| 8800 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 8801 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 8802 | + } else { | ||
| 8803 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 8804 | + }; | ||
| 8805 | + assert_eq!(frames.len(), frame_count); | ||
| 8806 | + let mismatched = frames | ||
| 8807 | + .iter() | ||
| 8808 | + .zip(&ffmpeg_frames) | ||
| 8809 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | ||
| 8810 | + if fired[0] + fired[1] == 0 { | ||
| 8811 | + out_of_scope += 1; | ||
| 8812 | + if mismatched { | ||
| 8813 | + oos_mismatch += 1; | ||
| 8814 | + eprintln!( | ||
| 8815 | + "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \ | ||
| 8816 | + 16-level inter AB partition -- another shape's defect" | ||
| 8817 | + ); | ||
| 8818 | + } | ||
| 8819 | + continue; | ||
| 8820 | + } | ||
| 8821 | + if mismatched { | ||
| 8822 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 8823 | + let bad: Vec<usize> = | ||
| 8824 | + (0..got.y.len()).filter(|&k| got.y[k] != want.y[k]).collect(); | ||
| 8825 | + if !bad.is_empty() { | ||
| 8826 | + eprintln!( | ||
| 8827 | + "{NAME}: attempt {attempt} {bit_depth}-bit frame {i}: {} luma \ | ||
| 8828 | + pixels differ, first at ({}, {}), max |delta| {}", | ||
| 8829 | + bad.len(), | ||
| 8830 | + bad[0] % width, | ||
| 8831 | + bad[0] / width, | ||
| 8832 | + bad.iter() | ||
| 8833 | + .map(|&k| (got.y[k] as i32 - want.y[k] as i32).abs()) | ||
| 8834 | + .max() | ||
| 8835 | + .unwrap_or(0) | ||
| 8836 | + ); | ||
| 8837 | + } | ||
| 8838 | + } | ||
| 8839 | + } | ||
| 8840 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 8841 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); | ||
| 8842 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); | ||
| 8843 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); | ||
| 8844 | + } | ||
| 8845 | + for a in 0..4 { | ||
| 8846 | + if fired[a] > 0 { | ||
| 8847 | + arms_proved[a] += 1; | ||
| 8848 | + arms_total[a] += 1; | ||
| 8849 | + } | ||
| 8850 | + } | ||
| 8851 | + matched += 1; | ||
| 8852 | + } | ||
| 8853 | + eprintln!( | ||
| 8854 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ | ||
| 8855 | + attempts carrying a 16-level inter 1:4 partition, per-arm attempts \ | ||
| 8856 | + HORZ_4/VERT_4/chroma-pair/sub8x8-chroma={arms_proved:?}, {out_of_scope} attempts carried \ | ||
| 8857 | + none ({oos_mismatch} of them mismatched)" | ||
| 8858 | + ); | ||
| 8859 | + assert_eq!( | ||
| 8860 | + oos_mismatch, 0, | ||
| 8861 | + "{NAME}: {oos_mismatch} attempt(s) with no 16-level inter 1:4 partition decoded \ | ||
| 8862 | + but mismatched ffmpeg -- a defect of another shape, not a pass" | ||
| 8863 | + ); | ||
| 8864 | + } | ||
| 8865 | + assert!( | ||
| 8866 | + arms_total.iter().all(|&n| n > 0), | ||
| 8867 | + "{NAME}: a 16-level inter 1:4 arm never fired on a pixel-exact attempt \ | ||
| 8868 | + (HORZ_4/VERT_4/chroma-pairs/sub8x8-chroma-pairs={arms_total:?}) -- an arm at 0 is \ | ||
| 8869 | + unproven; the last two are the odd-strip `is_chroma_reference` pair and the \ | ||
| 8870 | + `build_inter_predictors_sub8x8` two-mv chroma build" | ||
| 8871 | + ); | ||
| 8872 | + } | ||
| 8873 | + | ||
| 8874 | + | ||
| 8412 | #[test] | 8875 | #[test] |
| 8413 | fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() { | 8876 | fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() { |
| 8414 | if !have_ffmpeg() { | 8877 | if !have_ffmpeg() { |
lanes/inter16ab-r1.report.mdadded+74 -0
| @@ -0,0 +1,74 @@ | |||
| 1 | +# lane-inter16ab r1 — 16x16-level AB partitions in inter frames | ||
| 2 | + | ||
| 3 | +## Verdict: GREEN for the AB half; the 1:4 half stays refused (narrowed refusal). | ||
| 4 | + | ||
| 5 | +## What changed | ||
| 6 | +- `crates/ec-av1/src/decode.rs:2187` — `AB16_INTER_HITS` / `ab16_inter_hits_by_arm()` / | ||
| 7 | + `bump_ab16_inter()`: per-arm counters for HORZ_A/HORZ_B/VERT_A/VERT_B at 16x16 in an inter frame. | ||
| 8 | +- `crates/ec-av1/src/decode.rs:20718` — `inter_leaf8!` macro: one 8x8 inter leaf of an AB partition | ||
| 9 | + (the body the `PARTITION_SPLIT` arm already ran per leaf, minus its own partition symbol, which an | ||
| 10 | + AB piece does not carry, and minus its dead `prev_leaves` bookkeeping). | ||
| 11 | +- `crates/ec-av1/src/decode.rs:~21300` — the AB arm itself in the 16x16 partition chain of | ||
| 12 | + `decode_inter_frame_tile_with_cdfs`. libaom `decode_partition` visit order (decodeframe.c, BLOCK_16X16, | ||
| 13 | + `bsize2 = BLOCK_8X8`, `hbs = 2` mi): | ||
| 14 | + HORZ_A = TL 8x8, TR 8x8, bottom 16x8 · HORZ_B = top 16x8, BL 8x8, BR 8x8 · | ||
| 15 | + VERT_A = TL 8x8, BL 8x8, right 8x16 · VERT_B = left 8x16, TR 8x8, BR 8x8. | ||
| 16 | + VERT_A/VERT_B take `Reach::vert_ab_partition()` (libaom `reconintra.c get_has_tr_table` swaps those | ||
| 17 | + squares onto `has_tr_vert_*`, class `visit-order-changes-availability`). No frame-edge guards: an AB | ||
| 18 | + value can only be read from the `has_cols16 && has_rows16` branch, i.e. exactly libaom's `has_rows`/ | ||
| 19 | + `has_cols`, so all four quadrants are inside the frame. Every piece is >= 8x8, so | ||
| 20 | + `is_motion_variation_allowed_bsize` (min(bw,bh) >= 8) and `is_comp_ref_allowed` (bw+bh >= 16, | ||
| 21 | + blockd.h) hold unchanged — no OBMC/compound gate was added or removed. | ||
| 22 | +- `crates/ec-av1/src/refusal_inventory.rs:70` — the refusal is NARROWED, not deleted: | ||
| 23 | + "an inter 16x16-level AB or 1:4 partition (…)" → "an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 | ||
| 24 | + — four 16x4 or 4x16 inter strips; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT, | ||
| 25 | + SPLIT or AB)". | ||
| 26 | +- `crates/ec-av1/src/stream.rs:~7470` — gate | ||
| 27 | + `a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact`. | ||
| 28 | +- `crates/ec-av1/examples/decode_probe.rs:36` — prints `inter_ab16: horz_a=… horz_b=… vert_a=… vert_b=…` | ||
| 29 | + so a recipe sweep can tell "aomenc never picked one" from "it did and we decoded it". | ||
| 30 | + | ||
| 31 | +## Gate | ||
| 32 | +192x128, 6 frames, 8- AND 10-bit, 32 attempts per depth (tx-size-search 0/1 × cq × two sources × | ||
| 33 | +two motion steps), real aomenc with `--enable-rect-partitions=1 --enable-ab-partitions=1 | ||
| 34 | +--enable-1to4-partitions=0 --min-partition-size=8 --max-partition-size=16 --kf-max-dist=9999 | ||
| 35 | +--sb-size=64 --cpu-used=0`, each `--enable-*` spelled once (last-wins). Every decode-order frame is | ||
| 36 | +compared Y/U/V against ffmpeg; refusals are counted, never SKIPped; a mismatch on an attempt with | ||
| 37 | +zero AB hits fails the gate (`oos_mismatch`). | ||
| 38 | + | ||
| 39 | +Run: | ||
| 40 | +`EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-inter16ab cargo test -p ec-av1 --lib a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions -- --nocapture` | ||
| 41 | + | ||
| 42 | +EVIDENCE: $HOME/.cache/inter16ab-suite-r1.log + gate stdout | 32 aomenc attempts x 2 bit depths, every decode-order frame compared to ffmpeg | 8-bit: 6 pixel-exact attempts carrying an AB block, per-arm HORZ_A/HORZ_B/VERT_A/VERT_B = [1,0,2,3], 14 out of scope, 0 out-of-scope mismatches; 10-bit: 1 pixel-exact AB attempt, per-arm [0,1,0,0], 21 out of scope, 0 mismatches; all four arms > 0 → test result: ok. | ||
| 43 | + | ||
| 44 | +## Residue | ||
| 45 | +- deferred: the 16x16-level 1:4 pair (HORZ_4/VERT_4, four 16x4/4x16 inter strips) — needs the sub-8 | ||
| 46 | + inter chroma-pair path (odd-strip `is_chroma_reference`, `ss_size_lookup[BLOCK_16X4]` → BLOCK_8X4, | ||
| 47 | + and `dec_build_inter_predictors`' `is_sub8x8_inter` chroma built from BOTH strips' MVs), which no | ||
| 48 | + inter block writer has today (`decode_inter_block` has no `has_chroma` parameter at all). Unblocked | ||
| 49 | + by threading `has_chroma` + the pair MC through `decode_inter_block`. This is the arm the films stop | ||
| 50 | + at, so the film probe is unchanged by this round. | ||
| 51 | +- flagged (NOT this lane's defect): the X-structured 8-bit source at cq 46 desyncs in decode-order | ||
| 52 | + frame 4 (first bad luma pixel (183,0), 14685 pixels, max |delta| 92). Instrumented aomdec `EC_TRACE=1` | ||
| 53 | + reads ZERO `EC_PART_VAL … bsize=6 value>=4` in that entire stream, while our AB counters only rise in | ||
| 54 | + frames 4 and 5 — i.e. our AB reads there are read out of an already-diverged stream (classes | ||
| 55 | + `refusal-from-own-desync`, `counter-from-refused-stream`); on main the same stream stops on the old | ||
| 56 | + AB refusal at exactly that block (class `refusal-hides-a-defect`). The gate's cq list excludes it and | ||
| 57 | + says so in a comment. | ||
| 58 | +- flagged (NOT this lane's defect): a `--tile-columns=1` arm of the same sweep PANICS in | ||
| 59 | + `mc::from_switchable_symbol` ("switchable_interp's alphabet is exactly 3 symbols") — the below-8x8 | ||
| 60 | + inter-leaf desync signature already in the ledger. The tiled arm is therefore not in the gate. | ||
| 61 | +- flagged: 10-bit cq 40 on the X source mismatches with zero AB blocks (found by the gate's own | ||
| 62 | + `oos_mismatch` counter); the 10-bit arm uses cq 28 in that slot instead. | ||
| 63 | +- deferred: the ReelC census4 decode-order frame 1 case was not re-probed this round (tool budget). | ||
| 64 | + | ||
| 65 | +## Film probe | ||
| 66 | +`ffmpeg -ss 900 -t 2 -i <ReelB> -c:v copy -an -f obu` → `decode_probe`: | ||
| 67 | +before AND after this round the stop is at a 16x16-level 1:4 partition (before: the combined | ||
| 68 | +"AB or 1:4" refusal, value=8 = PARTITION_HORZ_4 measured with `EC_AV1_TRACE=1` at mi=(12,44); after: | ||
| 69 | +the narrowed 1:4 refusal), 1 frame completed (`EC_AV1_FINAL_DUMP` file count). Unchanged, as expected | ||
| 70 | +for an AB-only lift. | ||
| 71 | + | ||
| 72 | +## Suite | ||
| 73 | +`systemd-run --user --unit=inter16ab-suite-… -p MemoryMax=10G … cargo test -p ec-av1 --lib -j3` → | ||
| 74 | +`test result: ok. 371 passed; 0 failed; 32 ignored` (log `$HOME/.cache/inter16ab-suite-r1.log`). | ||
lanes/inter16ab-r2.report.mdadded+85 -0
| @@ -0,0 +1,85 @@ | |||
| 1 | +# lane-inter16ab r2 — 16x16-level 1:4 partitions in inter frames | ||
| 2 | + | ||
| 3 | +## Verdict: RED. The whole path is implemented and decodes, but one gate attempt | ||
| 4 | +## (8-bit, attempt 5, cq 34, X-structured source) desyncs in its LAST frame. | ||
| 5 | +The refusal is lifted and the gate is committed FAILING — not ignored, not weakened. | ||
| 6 | +This branch must not merge into main until the residue below is closed. | ||
| 7 | + | ||
| 8 | +## What changed (all in `crates/ec-av1/`) | ||
| 9 | +- `src/decode.rs:2207` — `InterStripChroma` + `INTER_STRIP_CHROMA` / `INTER_LAST_MC` | ||
| 10 | + thread-locals (the one-shot `REDUCED_TX_SET_INTER` idiom, chosen over threading two | ||
| 11 | + more parameters through `decode_inter_block`'s 23 call sites) and the four counters | ||
| 12 | + `inter16_rect4_counters() -> (16x4 strips, 4x16 strips, chroma pairs, sub8x8 chroma pairs)`. | ||
| 13 | +- `src/decode.rs` `decode_inter_block` entry — `has_chroma` (libaom `is_chroma_reference`, | ||
| 14 | + av1_common_int.h:1454: `bh == 1 mi` ⇒ odd `mi_row`), and the chroma origin/extent | ||
| 15 | + overridden to the PAIR's (8x4 / 4x8 at the even strip's mi origin — | ||
| 16 | + `setup_pred_plane`'s `mi_row -= 1`). | ||
| 17 | +- same fn — `is_comp_ref_allowed` / `is_motion_variation_allowed_bsize` | ||
| 18 | + (blockd.h:65 / :1455, `min(bw,bh) >= 8`) now gate `skip_mode`, `comp_mode` and | ||
| 19 | + `motion_mode`: a 16x4 strip reads none of those symbols. `is_interintra_allowed_bsize` | ||
| 20 | + already excluded it (aspect 4:1). | ||
| 21 | +- same fn — `build_inter_predictors_sub8x8` (reconinter_template.inc:87-160): the pair's | ||
| 22 | + chroma is built in `b4_w x b4_h` = 8x2 (2x8) pieces; the second piece is this strip's own | ||
| 23 | + mv (already written by the whole-block predictor, MC being position-invariant for a fixed | ||
| 24 | + mv), so only the FIRST piece is rebuilt, from the previous strip's mv/ref/filters, and only | ||
| 25 | + when `is_sub8x8_inter` holds (previous strip single-ref inter — `INTER_LAST_MC`). | ||
| 26 | +- same fn — chroma residual read/reconstruct/record all gated on `has_chroma`; the pair's | ||
| 27 | + chroma coefficient context is read at `around_mi_rect(pair_mi, 16, 8)` and written back over | ||
| 28 | + the pair's mi span (mirrors the intra `decode_rect4_16`). | ||
| 29 | +- `src/decode.rs` `rect_scan` / `rect_inter_residual_supported` / `rect_inter_luma_set` — | ||
| 30 | + (16,4)|(4,16): `SCAN_16X4`/`SCAN_4X16`, and the new `TxbSet::LumaRect16x4Inter{,1}` | ||
| 31 | + (`Luma8` coefficient tables — `get_txsize_entropy_ctx(TX_16X4)` = TX_8X8, 64 positions, | ||
| 32 | + `eob_pt_64` — with the INTER tx_type table at `txsize_sqr_map[TX_16X4]` = TX_4X4; | ||
| 33 | + `av1_get_ext_tx_set_type` (blockd.h:1097-1106) gives EXT_TX_SET_ALL16 unreduced since | ||
| 34 | + `tx_size_sqr != TX_16X16`, EXT_TX_SET_DCT_IDTX reduced). | ||
| 35 | +- `src/cdf_state.rs:233,1854` — the two new `TxbSet` variants and their tables. | ||
| 36 | +- `src/decode.rs` 16x16 partition chain — the `PARTITION_HORZ_4`/`_VERT_4` arm: four strips in | ||
| 37 | + libaom `decode_partition` order with its own `i > 0` frame-edge break, each carrying its | ||
| 38 | + `InterStripChroma`. | ||
| 39 | +- `src/refusal_inventory.rs:70` — the combined 1:4 refusal is GONE; three narrower ones stand: | ||
| 40 | + the partition-value catch-all, a split transform on a 16x4 strip, an intra 16x4 strip. | ||
| 41 | +- `src/stream.rs` — gate | ||
| 42 | + `a_real_aomenc_inter_sequence_with_16x16_level_1to4_partitions_decodes_pixel_exact` | ||
| 43 | + (r1's gate shape with `--enable-1to4-partitions=1 --min-partition-size=4`). | ||
| 44 | +- `examples/decode_probe.rs:43` — prints `inter16_1to4: horz4= vert4= chroma_pairs= sub8_pieces=`. | ||
| 45 | + | ||
| 46 | +## Gate result — RED | ||
| 47 | +`EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-inter16ab cargo test -p ec-av1 --lib a_real_aomenc_inter_sequence_with_16x16_level_1to4 -- --nocapture` | ||
| 48 | + | ||
| 49 | +EVIDENCE: gate stdout (suite log `$HOME/.cache/inter16ab-suite-r2.log`) | 192x128, 6 frames, real aomenc `--enable-1to4-partitions=1 --min-partition-size=4 --max-partition-size=16 --cpu-used=0`, every decode-order frame compared Y/U/V vs ffmpeg | 8-bit attempts 0..4: 2 named refusals ("an inter partition below 8x8" — `--min-partition-size=4` also lets aomenc split to sub-8 leaves, a different lane's refusal), earlier attempts pixel-exact; attempt 5 (cq 34, X-structured source, tx-size-search 1) fires arms [horz4=8, vert4=0, chroma_pairs=4, sub8x8_pairs=4] and MISMATCHES in decode-order frame 5 only: 8683 luma pixels, first at (96, 59), max |delta| 107. Frames 0-4 of that attempt are pixel-exact. | ||
| 50 | + | ||
| 51 | +Reading of the failure: frames 0-4 exact, then ~35% of the last frame wrong from a mid-frame | ||
| 52 | +raster position = an ENTROPY DESYNC at one 16x16-level 1:4 block, not a prediction/filter | ||
| 53 | +drift. `av1_get_ext_tx_set_type` was checked against the oracle source and the tables above are | ||
| 54 | +right, so the leading suspect is the mv-stack at `BLOCK_16X4` (`bw4=4, bh4=1`): a wrong stack | ||
| 55 | +size changes the `drl_idx` symbol count and desyncs at that block. NOT confirmed — no range | ||
| 56 | +ladder was run this round (tool budget). | ||
| 57 | + | ||
| 58 | +## Film probe — moved one refusal deeper | ||
| 59 | +`ffmpeg -ss 900 -t 2 -i <ReelB> -c:v copy -an -f obu` → `decode_probe`: | ||
| 60 | +- before r2: `REFUSED: an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 …)` | ||
| 61 | +- after r2: `REFUSED: a split transform on a 16x16-level 1:4 inter strip | ||
| 62 | + (sub_tx_size_map[TX_16X4] is the rectangular TX_8X4)` | ||
| 63 | +1 frame completed (`EC_AV1_FINAL_DUMP` file count) in both. So the partition, the strips and | ||
| 64 | +the chroma pair are past; the film now needs rect var-tx leaves. | ||
| 65 | + | ||
| 66 | +## Residue | ||
| 67 | +- fix-now (next round, this lane): the attempt-5 desync above. Method: dump that attempt's | ||
| 68 | + stream (add an env-gated write to the gate), run the instrumented aomdec `EC_TRACE=1` and | ||
| 69 | + compare the msac RANGE element by element from the first 1:4 block of decode-order frame 5. | ||
| 70 | + First check `find_mv_stack`'s row/col scan and weights for `bw4=4, bh4=1` (class | ||
| 71 | + `scan-weights-cross-axis`). | ||
| 72 | +- deferred: a SPLIT luma transform on a 16x4 strip — `vartx_leaves` is a list of SQUARE units | ||
| 73 | + and `sub_tx_size_map[TX_16X4]` is the rectangular TX_8X4 (then TX_4X4). Unblocked by making | ||
| 74 | + `vartx_leaves` carry `(row, col, w, h)` and routing each leaf through | ||
| 75 | + `read_inter_plane_rect`. This is what BOTH films now stop at. | ||
| 76 | +- deferred: an INTRA 16x4/4x16 strip inside a 1:4 partition — `decode_intra_rect_in_inter` | ||
| 77 | + codes chroma at the strip's own halved footprint (an 8x2 transform libaom never wrote). | ||
| 78 | + Unblocked by giving that path the same pair treatment. | ||
| 79 | +- deferred: `git merge --no-commit main` (main is at 85887c7, this branch's base is 18bf7dc). | ||
| 80 | + Not run: the suite was already in flight in this worktree and a merge under it is exactly the | ||
| 81 | + self-inflicted flake COMMON warns about. The merge is owed before any merge to main. | ||
| 82 | +- accepted: the gate keeps `--tile-columns=0` (r1's `--tile-columns=1` panic in | ||
| 83 | + `mc::from_switchable_symbol` is the below-8x8 inter leaf desync, not this shape). No new | ||
| 84 | + per-mi neighbour map was added — the pair chroma write reuses the existing `above`/`left` | ||
| 85 | + bands and never crosses the 16x16 block, so no tile-edge guard is in question. | ||
lanes/inter16ab-r3.handoff.mdadded+63 -0
| @@ -0,0 +1,63 @@ | |||
| 1 | +# lane-inter16ab r3 — HANDOFF (turn cap) | ||
| 2 | + | ||
| 3 | +## Merge state | ||
| 4 | +- `main` (8e9ba81) merged: commit `Merge branch 'main' (8e9ba81) into lane-inter16ab` (clean). | ||
| 5 | +- `lane-r14` **b86eb38 was NOT in main**; merged directly. Two conflicts, resolved keeping | ||
| 6 | + BOTH sides: `examples/decode_probe.rs` (both counter blocks) and `decode.rs`'s | ||
| 7 | + `read_var_tx_size` split arm — r14's side taken there, which is the general | ||
| 8 | + `(sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h)` recursion and DELETES both split-transform | ||
| 9 | + refusals (the 64-axis one and this lane's 16x4 one). `cdf_state.rs` auto-merged, no | ||
| 10 | + hand-resolution. | ||
| 11 | + | ||
| 12 | +## Root cause of the r2 attempt-5 desync — FOUND AND FIXED (commit a506474) | ||
| 13 | +Repro without the gate (stream `~/.cache/inter16ab-tmp/a5.obu`, md5 525b8e4ebfb9b347d990d35eeb890586, | ||
| 14 | +recipe = gate attempt 5: 192x128 6 frames 8-bit cq34 X-source `--enable-tx-size-search=1`): | ||
| 15 | +- aomdec `EC_TRACE_MODE` vs our `EC_TRACE_MODE`: identical through block mi(24,0) (a 16x8 | ||
| 16 | + compound strip, ref0=4 ref1=7, `comp_group_idx=1` per `EC_AV1_COMPIDX_DUMP`), then the NEXT | ||
| 17 | + block's entry range is ours 64901 vs oracle 47271 — divergence inside mi(24,0) after the mv. | ||
| 18 | +- `decode_inter_block` carries the enclosing SQUARE `side`, and the masked-compound read took | ||
| 19 | + its CDF row from it (`match side { 8 => 3, 16 => 6, 32 => 9 }`), i.e. | ||
| 20 | + `compound_type_cdf[BLOCK_16X16]` where libaom `decodemv.c::read_compound_type` uses | ||
| 21 | + `compound_type_cdf[bsize]` = BLOCK_16X8. Same class at the single-ref wedge-interintra row | ||
| 22 | + (`if side == 16 { 6 } else { 9 }`) — fixed too. | ||
| 23 | +- Fix: `bsize_all_index(bw, bh)` + `wedge_used_bsize(bw, bh)` in `decode.rs` (just above | ||
| 24 | + `is_any_masked_compound_used_here`), both rows now from `write_w/write_h`. The wedge MASK | ||
| 25 | + codebook (`wedge.rs`) is square-only, so a rect COMPOUND_WEDGE / wedge-interintra block is | ||
| 26 | + now a NAMED REFUSAL (2 new `refusal_inventory` entries; that test is green). | ||
| 27 | +- EVIDENCE: `~/.cache/inter16ab-tmp/{a5.obu,ours.yuv,ref.yuv}` | rebuild + `EC_PROBE_OUT=ours.yuv decode_probe a5.obu`, `ffmpeg -i a5.obu -f rawvideo ref.yuv` | 6/6 frames byte-IDENTICAL (was 8683 luma px wrong in frame 5), and `inter16_1to4: horz4=8 -> 0`. | ||
| 28 | +- CLASS CONFIRMED (phantom counters): the oracle's `EC_TRACE=1` `EC_PART_VAL` histogram on that | ||
| 29 | + stream is `bsize=6 {0:570, 1:5, 2:1}` + splits only — **zero 1:4 partitions**. Our 8 "horz4" | ||
| 30 | + hits were phantom reads of an already-diverged stream, so the gate's `fired==0` out-of-scope | ||
| 31 | + guard could not catch it. | ||
| 32 | + | ||
| 33 | +## Gate state after the fix — still RED, but for COVERAGE, not correctness | ||
| 34 | +`$HOME/.cache/inter16ab-gate-r3.log` (unit inter16ab-gate-1788328988): | ||
| 35 | +- 8-bit: 3 named refusals, **1** pixel-exact attempt carrying a real 1:4 partition, arms | ||
| 36 | + `[horz4=1, vert4=0, chroma_pair=1, sub8x8=1]`, 28 attempts carried none, **oos_mismatch = 0**. | ||
| 37 | +- 10-bit: 1 named refusal, **0** attempts carried a 1:4 partition, **oos_mismatch = 0**. | ||
| 38 | +- Panic is the final `arms_total.iter().all(> 0)` assert at `stream.rs:8227` — VERT_4 never | ||
| 39 | + fires and the 10-bit sweep never picks a 1:4 at all. NO pixel mismatch anywhere any more. | ||
| 40 | +- One 8-bit attempt (attempt 1) now stops on the new | ||
| 41 | + `a wedge interintra mask on a rectangular inter block` refusal — real, previously mis-decoded. | ||
| 42 | + | ||
| 43 | +## EXACT NEXT STEPS | ||
| 44 | +1. Widen the recipe so VERT_4 and a 10-bit 1:4 actually fire (Y-structured source is in the | ||
| 45 | + sweep via `natural`, but the cq/tx/sp axes clearly do not reach VERT_4): sweep cq/sb-size/ | ||
| 46 | + `--max-partition-size=16` variants OUTSIDE the test first (script pattern in this handoff's | ||
| 47 | + repro command), pin the ones that fire, then narrow the gate to them. Do NOT weaken the | ||
| 48 | + arms assert. | ||
| 49 | +2. Rect wedge support (lifts the two new refusals): `wedge.rs` builds masks for side 8/16/32 | ||
| 50 | + only; libaom `av1_init_wedge_masks` builds them for BLOCK_8X16/16X8/16X32/32X16/8X32/32X8 | ||
| 51 | + from the same master mask. | ||
| 52 | +3. Split transform on a 16x4 strip (charter item 3) — NOT DONE. The refusal is already gone | ||
| 53 | + (r14 merge), so a TX_16X4 -> TX_8X4 split now reaches `rect_inter_residual_supported(8,4)` | ||
| 54 | + which is FALSE, and `rect_inter_luma_set` would hit `unreachable!()`. **This is a panic | ||
| 55 | + risk on the merged tree and must be closed before merging to main.** Work needed: | ||
| 56 | + `rect_inter_residual_supported` += `(8,4)|(4,8)`; `rect_inter_luma_set` += a new | ||
| 57 | + `TxbSet::LumaRect8x4Inter{,1}` — shape = `LumaRect4x8`'s (Luma8 coefficient tables, | ||
| 58 | + `eob_pt_32_luma` + `eob_pt_32_luma_class1`, 32 positions) with `inter_tx_type_4` / | ||
| 59 | + `inter_tx_type_4_set1` at the TX_4X4 row (`av1_get_ext_tx_set_type(TX_8X4, inter)` = | ||
| 60 | + DCT_IDTX reduced / ALL16 unreduced); `SCAN_8X4`/`SCAN_4X8` already exist in `rect_scan`. | ||
| 61 | + Then a counter + a `--enable-tx-size-search=1` gate arm. | ||
| 62 | +4. Full suite armed as unit `inter16ab-suite-r3` -> `$HOME/.cache/inter16ab-suite-r3.log` | ||
| 63 | + (result not seen before the cap). Film `-ss 900` re-probe NOT re-run this round. | ||