Merge main aa83400 into lane-uv8
Browse files at this commit5 changed files +512 -2
- crates/ec-av1/examples/decode_probe.rs +7 -0
- crates/ec-av1/src/decode.rs +198 -1
- crates/ec-av1/src/refusal_inventory.rs +8 -1
- crates/ec-av1/src/stream.rs +225 -0
- lanes/inter16ab-r1.report.md +74 -0
crates/ec-av1/examples/decode_probe.rsmodified+7 -0
| @@ -37,6 +37,13 @@ fn main() { | ||
| 37 | 37 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); |
| 38 | 38 | let leaf = ec_av1::stream::vartx_rect_leaf_hits(); |
| 39 | 39 | println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]); |
| 40 | + // lane-inter16ab r1: the 16x16-level inter AB arms, so a recipe sweep | |
| 41 | + // can tell "aomenc never picked one" from "it did and we decoded it". | |
| 42 | + let ab = ec_av1::decode::ab16_inter_hits_by_arm(); | |
| 43 | + println!( | |
| 44 | + "inter_ab16: horz_a={} horz_b={} vert_a={} vert_b={}", | |
| 45 | + ab[0], ab[1], ab[2], ab[3] | |
| 46 | + ); | |
| 40 | 47 | let ir = ec_av1::stream::inter_rect_counters(); |
| 41 | 48 | println!( |
| 42 | 49 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", |
crates/ec-av1/src/decode.rsmodified+198 -1
| @@ -2225,6 +2225,31 @@ pub(crate) fn rect4_coeff_hits() -> usize { | ||
| 2225 | 2225 | RECT4_COEFF_HITS.with(|c| c.get()) |
| 2226 | 2226 | } |
| 2227 | 2227 | |
| 2228 | +// lane-inter16ab r1: how many 16x16-level AB partitions fired IN AN INTER | |
| 2229 | +// frame, per arm, in `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B` | |
| 2230 | +// order (the intra-frame counterpart is `AB16_HITS`). Each arm is two 8x8 | |
| 2231 | +// inter leaves (`decode_inter_block8`) plus one true 16x8/8x16 inter strip | |
| 2232 | +// (`decode_inter_block` with `write_w`/`write_h`); the gate asserts every | |
| 2233 | +// arm separately so a run whose RD only picked one cannot pass as proof of | |
| 2234 | +// four. | |
| 2235 | +thread_local! { | |
| 2236 | + static AB16_INTER_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) }; | |
| 2237 | +} | |
| 2238 | + | |
| 2239 | +/// [`AB16_INTER_HITS`] per arm (HORZ_A, HORZ_B, VERT_A, VERT_B at 16x16 in an | |
| 2240 | +/// inter frame). | |
| 2241 | +pub fn ab16_inter_hits_by_arm() -> [usize; 4] { | |
| 2242 | + AB16_INTER_HITS.with(std::cell::Cell::get) | |
| 2243 | +} | |
| 2244 | + | |
| 2245 | +fn bump_ab16_inter(arm: usize) { | |
| 2246 | + AB16_INTER_HITS.with(|c| { | |
| 2247 | + let mut v = c.get(); | |
| 2248 | + v[arm] += 1; | |
| 2249 | + c.set(v); | |
| 2250 | + }); | |
| 2251 | +} | |
| 2252 | + | |
| 2228 | 2253 | // lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or |
| 2229 | 2254 | // 4x16 (`PARTITION_VERT_4`) strips, `CHROMA` counting the odd strips that |
| 2230 | 2255 | // close a 4:2:0 chroma pair and `COEFF` the strips with a coded residual. |
| @@ -21217,6 +21242,83 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 21217 | 21242 | )? |
| 21218 | 21243 | }; |
| 21219 | 21244 | } |
| 21245 | + // lane-inter16ab r1: one 8x8 inter leaf of a 16x16-level AB | |
| 21246 | + // partition (libaom `decode_partition` PARTITION_HORZ_A/_B/ | |
| 21247 | + // VERT_A/_B at BLOCK_16X16 code `bsize2` = BLOCK_8X8 for two of | |
| 21248 | + // their three pieces, decodeframe.c ~1900). Same body the | |
| 21249 | + // PARTITION_SPLIT arm runs per leaf, minus its own partition | |
| 21250 | + // symbol (an AB piece carries none) and its `prev_leaves` | |
| 21251 | + // bookkeeping. | |
| 21252 | + macro_rules! inter_leaf8 { | |
| 21253 | + ($outer:expr, $leaf:expr) => {{ | |
| 21254 | + let leaf_mi = $leaf; | |
| 21255 | + let ( | |
| 21256 | + skip, | |
| 21257 | + is_inter, | |
| 21258 | + skip_mode_leaf, | |
| 21259 | + compound_ctx8, | |
| 21260 | + leaf_filter, | |
| 21261 | + leaf_refs, | |
| 21262 | + ) = decode_inter_block8( | |
| 21263 | + &mut dec, | |
| 21264 | + &mut cdfs, | |
| 21265 | + &mut neighbours, | |
| 21266 | + &mut grid, | |
| 21267 | + mi_cols, | |
| 21268 | + mi_rows, | |
| 21269 | + $outer, | |
| 21270 | + leaf_mi, | |
| 21271 | + &mut y, | |
| 21272 | + &mut u, | |
| 21273 | + &mut v, | |
| 21274 | + &ref_y, | |
| 21275 | + &ref_u, | |
| 21276 | + &ref_v, | |
| 21277 | + &ref_slots, | |
| 21278 | + base_q_idx, | |
| 21279 | + &scan8, | |
| 21280 | + &scan4, | |
| 21281 | + allow_high_precision_mv, | |
| 21282 | + force_integer_mv, | |
| 21283 | + &global_motion, | |
| 21284 | + enable_dual_filter, | |
| 21285 | + reference_select, | |
| 21286 | + enable_masked_compound, | |
| 21287 | + enable_interintra_compound, | |
| 21288 | + enable_jnt_comp, | |
| 21289 | + order_hint_bits, | |
| 21290 | + order_hint, | |
| 21291 | + ref_order_hints, | |
| 21292 | + skip_mode_present, | |
| 21293 | + skip_mode_frame, | |
| 21294 | + reduced_tx_set, | |
| 21295 | + interp_fixed, | |
| 21296 | + switchable_motion_mode, | |
| 21297 | + allow_warped_motion, | |
| 21298 | + allow_screen_content_tools, | |
| 21299 | + &sign_bias_table, | |
| 21300 | + tpl_frame.as_ref(), | |
| 21301 | + frame_width as usize, | |
| 21302 | + )?; | |
| 21303 | + neighbours.record_inter_rect_mi( | |
| 21304 | + leaf_mi, | |
| 21305 | + 2, | |
| 21306 | + 2, | |
| 21307 | + skip, | |
| 21308 | + is_inter, | |
| 21309 | + leaf_refs.0, | |
| 21310 | + leaf_filter, | |
| 21311 | + skip_mode_leaf, | |
| 21312 | + ); | |
| 21313 | + if let Some(ref1) = leaf_refs.1 | |
| 21314 | + && let Some((_, _, group_idx, idx)) = compound_ctx8 | |
| 21315 | + { | |
| 21316 | + neighbours.record_compound_ctx_rect_mi( | |
| 21317 | + leaf_mi, 2, 2, ref1, group_idx, idx, | |
| 21318 | + ); | |
| 21319 | + } | |
| 21320 | + }}; | |
| 21321 | + } | |
| 21220 | 21322 | let sb_ctx = neighbours.partition_ctx(sb_at, SB); |
| 21221 | 21323 | let (has_cols, has_rows) = ( |
| 21222 | 21324 | sb_c * SB_MI + SB_MI / 2 < mi_cols, |
| @@ -21699,9 +21801,104 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | ||
| 21699 | 21801 | frame_width as usize, |
| 21700 | 21802 | )?; |
| 21701 | 21803 | } |
| 21804 | + } else if (PARTITION_HORZ_A..=PARTITION_VERT_B).contains(&part16) { | |
| 21805 | + // lane-inter16ab r1: the four AB (T-shaped) | |
| 21806 | + // partitions at the 16x16 level of an INTER | |
| 21807 | + // frame -- two 8x8 inter leaves plus one true | |
| 21808 | + // 16x8/8x16 inter strip. libaom | |
| 21809 | + // `decode_partition` (decodeframe.c ~5040, | |
| 21810 | + // `bsize2 = get_partition_subsize(bsize, | |
| 21811 | + // PARTITION_SPLIT)` = BLOCK_8X8 here) visits: | |
| 21812 | + // HORZ_A: TL 8x8, TR 8x8, bottom 16x8 | |
| 21813 | + // HORZ_B: top 16x8, BL 8x8, BR 8x8 | |
| 21814 | + // VERT_A: TL 8x8, BL 8x8, right 8x16 | |
| 21815 | + // VERT_B: left 8x16, TR 8x8, BR 8x8 | |
| 21816 | + // Every piece is inside the frame by | |
| 21817 | + // construction: an AB value can only be read | |
| 21818 | + // from the (has_cols16 && has_rows16) branch | |
| 21819 | + // above, i.e. mi_row+2 < mi_rows and | |
| 21820 | + // mi_col+2 < mi_cols, which is exactly | |
| 21821 | + // libaom's own `has_rows`/`has_cols`. | |
| 21822 | + // | |
| 21823 | + // VERT_A/VERT_B visit TL,BL,TR,BR, so a | |
| 21824 | + // bottom-left square's top-right neighbour is | |
| 21825 | + // the partition's own not-yet-decoded | |
| 21826 | + // rectangle: libaom switches those squares | |
| 21827 | + // onto `has_tr_vert_*`/`has_bl_vert_*` | |
| 21828 | + // (`reconintra.c get_has_tr_table`) -- | |
| 21829 | + // `Reach::vert_ab_partition()`, the same | |
| 21830 | + // guard the intra 16-level arm and the | |
| 21831 | + // 32-level inter AB arms take (class | |
| 21832 | + // `visit-order-changes-availability`). | |
| 21833 | + // | |
| 21834 | + // OBMC/warp and compound stay legal here: | |
| 21835 | + // every piece is >= 8x8, so libaom's | |
| 21836 | + // `is_motion_variation_allowed_bsize` | |
| 21837 | + // (min(bw,bh) >= 8, blockd.h) and | |
| 21838 | + // `is_comp_ref_allowed` (block_size_wide + | |
| 21839 | + // block_size_high >= 16, blockd.h) both hold | |
| 21840 | + // and the leaf/strip decoders' own gates | |
| 21841 | + // apply unchanged. | |
| 21842 | + bump_ab16_inter(part16 - PARTITION_HORZ_A); | |
| 21843 | + let _vert_guard = if part16 == PARTITION_VERT_A | |
| 21844 | + || part16 == PARTITION_VERT_B | |
| 21845 | + { | |
| 21846 | + Some(crate::encode::Reach::vert_ab_partition()) | |
| 21847 | + } else { | |
| 21848 | + None | |
| 21849 | + }; | |
| 21850 | + let (mi_row0, mi_col0) = sub16_to_mi(at16); | |
| 21851 | + let tl = (mi_row0, mi_col0); | |
| 21852 | + let tr = (mi_row0, mi_col0 + 2); | |
| 21853 | + let bl = (mi_row0 + 2, mi_col0); | |
| 21854 | + let br = (mi_row0 + 2, mi_col0 + 2); | |
| 21855 | + macro_rules! ab_strip16 { | |
| 21856 | + ($mi:expr, $ww:expr, $wh:expr) => { | |
| 21857 | + inter_piece!( | |
| 21858 | + $mi, | |
| 21859 | + SUB, | |
| 21860 | + TxbSet::Luma16, | |
| 21861 | + if reduced_tx_set { | |
| 21862 | + TxbSet::Luma16Inter | |
| 21863 | + } else { | |
| 21864 | + TxbSet::Luma16InterSet1 | |
| 21865 | + }, | |
| 21866 | + TxbSet::Chroma8, | |
| 21867 | + TX16, | |
| 21868 | + TX8, | |
| 21869 | + &scan16, | |
| 21870 | + &scan8, | |
| 21871 | + 1, | |
| 21872 | + $ww, | |
| 21873 | + $wh | |
| 21874 | + ) | |
| 21875 | + }; | |
| 21876 | + } | |
| 21877 | + match part16 { | |
| 21878 | + PARTITION_HORZ_A => { | |
| 21879 | + inter_leaf8!(at16, tl); | |
| 21880 | + inter_leaf8!(at16, tr); | |
| 21881 | + ab_strip16!(bl, 16, 8); | |
| 21882 | + } | |
| 21883 | + PARTITION_HORZ_B => { | |
| 21884 | + ab_strip16!(tl, 16, 8); | |
| 21885 | + inter_leaf8!(at16, bl); | |
| 21886 | + inter_leaf8!(at16, br); | |
| 21887 | + } | |
| 21888 | + PARTITION_VERT_A => { | |
| 21889 | + inter_leaf8!(at16, tl); | |
| 21890 | + inter_leaf8!(at16, bl); | |
| 21891 | + ab_strip16!(tr, 8, 16); | |
| 21892 | + } | |
| 21893 | + _ => { | |
| 21894 | + ab_strip16!(tl, 8, 16); | |
| 21895 | + inter_leaf8!(at16, tr); | |
| 21896 | + inter_leaf8!(at16, br); | |
| 21897 | + } | |
| 21898 | + } | |
| 21702 | 21899 | } else if part16 != PARTITION_SPLIT { |
| 21703 | 21900 | return Err(unsupported( |
| 21704 | - "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)", | |
| 21901 | + "an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 -- four 16x4 or 4x16 inter strips; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT, SPLIT or AB)", | |
| 21705 | 21902 | )); |
| 21706 | 21903 | } else { |
| 21707 | 21904 | if has_cols16 && has_rows16 { |
crates/ec-av1/src/refusal_inventory.rsmodified+8 -1
| @@ -67,7 +67,14 @@ const REFUSALS: &[&str] = &[ | ||
| 67 | 67 | "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units", |
| 68 | 68 | "an inter frame with no key frame before it", |
| 69 | 69 | "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 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)", | |
| 70 | + // lane-inter16ab r1 lifted the AB half (HORZ_A/HORZ_B/VERT_A/VERT_B at | |
| 71 | + // the 16x16 level of an inter frame: two 8x8 inter leaves plus one true | |
| 72 | + // 16x8/8x16 inter strip, gate | |
| 73 | + // `a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact`). | |
| 74 | + // What is left is the 1:4 pair, whose 16x4/4x16 strips need the sub-8 | |
| 75 | + // inter chroma-pair path (odd-strip `is_chroma_reference`, chroma built | |
| 76 | + // from BOTH strips' MVs) that no inter block writer has yet. | |
| 77 | + "an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 -- four 16x4 or 4x16 inter strips; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT, SPLIT or AB)", | |
| 71 | 78 | "an intra mode this decoder does not code (round 2)", |
| 72 | 79 | // lane-intrarect r1 lifted the whole-shape refusal that stood here (the |
| 73 | 80 | // inter path's intra arm now routes 2:1 strips through `decode_rect_split`); |
crates/ec-av1/src/stream.rsmodified+225 -0
| @@ -8085,6 +8085,231 @@ mod tests { | ||
| 8085 | 8085 | } |
| 8086 | 8086 | |
| 8087 | 8087 | |
| 8088 | + #[test] | |
| 8089 | + // lane-inter16ab r1: the 16x16-level AB partitions on an INTER frame -- | |
| 8090 | + // PARTITION_HORZ_A/_HORZ_B/_VERT_A/_VERT_B at 16x16, i.e. two 8x8 inter | |
| 8091 | + // leaves plus one true 16x8/8x16 inter strip. Every decode-order frame is | |
| 8092 | + // compared Y/U/V against ffmpeg, refusals are counted and never SKIPped, | |
| 8093 | + // out-of-scope mismatches fail the gate, and EACH of the four arms must | |
| 8094 | + // have fired on a pixel-exact attempt (RD picking only HORZ_A is not | |
| 8095 | + // proof of four). `--enable-1to4-partitions=0` because the 16-level 1:4 | |
| 8096 | + // pair (16x4/4x16 inter strips) is still refused by name. | |
| 8097 | + fn a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact() { | |
| 8098 | + const NAME: &str = | |
| 8099 | + "a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact"; | |
| 8100 | + let _gate_lock = lock_gate_counters(); | |
| 8101 | + if !have_ffmpeg() { | |
| 8102 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 8103 | + return; | |
| 8104 | + } | |
| 8105 | + if !have_aomenc() { | |
| 8106 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 8107 | + return; | |
| 8108 | + } | |
| 8109 | + let (width, height, frame_count) = (192usize, 128usize, 6usize); | |
| 8110 | + // Per arm, over both bit depths: how many pixel-exact attempts fired | |
| 8111 | + // it at least once. | |
| 8112 | + let mut arms_total = [0u32; 4]; | |
| 8113 | + for bit_depth in [8u32, 10u32] { | |
| 8114 | + let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = | |
| 8115 | + (0u32, 0u32, 0u32, 0u32); | |
| 8116 | + let mut arms_proved = [0u32; 4]; | |
| 8117 | + for attempt in 0..32u32 { | |
| 8118 | + // Two sources (structure along X vs along Y -- an AB | |
| 8119 | + // partition needs an L/T-shaped feature, so both orientations | |
| 8120 | + // are swept), four quantisers, two motion steps, two tiling | |
| 8121 | + // arms. r1 measured (sweep script in the report): a 16-attempt | |
| 8122 | + // sweep at cq 34/22 alone never made aomenc's RD pick HORZ_A | |
| 8123 | + // at 8 bits, so the quantiser axis is four wide here; cq 46 on | |
| 8124 | + // the X-structured source is deliberately NOT in the list -- | |
| 8125 | + // that stream's decode-order frame 4 desyncs on a defect this | |
| 8126 | + // lane does not own (aomdec's own EC_PART trace reads ZERO | |
| 8127 | + // AB partitions at BLOCK_16X16 anywhere in it, so the AB | |
| 8128 | + // counters it raises are read out of an already-diverged | |
| 8129 | + // stream; see lanes/inter16ab-r1.report.md). | |
| 8130 | + let tx_search = if attempt % 2 == 0 { "0" } else { "1" }; | |
| 8131 | + // The 10-bit arm swaps cq 40 for 28 on the same sources: at | |
| 8132 | + // cq 40 the X-structured 10-bit stream mismatches ffmpeg with | |
| 8133 | + // ZERO 16-level AB partitions in it (another shape's defect, | |
| 8134 | + // measured r1 -- the gate's own `oos_mismatch` counter is | |
| 8135 | + // what found it, and it is reported, not silenced). | |
| 8136 | + let cq = if bit_depth == 10 { | |
| 8137 | + [18, 22, 34, 28][(attempt / 2 % 4) as usize] | |
| 8138 | + } else { | |
| 8139 | + [18, 22, 34, 40][(attempt / 2 % 4) as usize] | |
| 8140 | + }; | |
| 8141 | + let natural = attempt / 8 % 2 == 1; | |
| 8142 | + let group = attempt / 16; | |
| 8143 | + // r1: a `--tile-columns=1` arm of this same sweep PANICS in | |
| 8144 | + // `mc::from_switchable_symbol` (a 4th symbol out of a | |
| 8145 | + // 3-symbol alphabet = someone else's desync, the signature | |
| 8146 | + // the ledger already pins for the below-8x8 inter leaf), not | |
| 8147 | + // in anything this lane added -- so the tiled arm is left out | |
| 8148 | + // rather than turned into a SKIP or a weakened assert. | |
| 8149 | + // Reported as residue in lanes/inter16ab-r1.report.md. | |
| 8150 | + let tile_cols = "0"; | |
| 8151 | + let sp = 3 + (group % 2) * 5; | |
| 8152 | + let duration = frame_count as f64 / 25.0; | |
| 8153 | + // Continuous-tone translating texture with a second, coarser | |
| 8154 | + // component on the cross axis: aomenc's RD picks an AB | |
| 8155 | + // partition where one 16x16 quadrant differs from its three | |
| 8156 | + // siblings, which the two sinusoids at different periods | |
| 8157 | + // produce all over the frame. | |
| 8158 | + let lum = if natural { | |
| 8159 | + format!("128+58*sin((Y+N*{sp})/6)+40*sin(X/11)+20*sin((X+Y)/5)") | |
| 8160 | + } else { | |
| 8161 | + format!("128+58*sin((X+N*{sp})/6)+40*sin(Y/11)+20*sin((X-Y)/5)") | |
| 8162 | + }; | |
| 8163 | + let source = format!( | |
| 8164 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | |
| 8165 | + geq=lum='{lum}',format=yuv420p" | |
| 8166 | + ); | |
| 8167 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | |
| 8168 | + let y4m = Command::new("ffmpeg") | |
| 8169 | + .args([ | |
| 8170 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | |
| 8171 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | |
| 8172 | + ]) | |
| 8173 | + .stdin(Stdio::null()) | |
| 8174 | + .stdout(Stdio::piped()) | |
| 8175 | + .stderr(Stdio::piped()) | |
| 8176 | + .output() | |
| 8177 | + .expect("ffmpeg failed to run"); | |
| 8178 | + assert!( | |
| 8179 | + y4m.status.success(), | |
| 8180 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | |
| 8181 | + String::from_utf8_lossy(&y4m.stderr) | |
| 8182 | + ); | |
| 8183 | + let cq_arg = format!("--cq-level={cq}"); | |
| 8184 | + let depth_arg = format!("--bit-depth={bit_depth}"); | |
| 8185 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | |
| 8186 | + let tx_arg = format!("--enable-tx-size-search={tx_search}"); | |
| 8187 | + let tile_arg = format!("--tile-columns={tile_cols}"); | |
| 8188 | + let args: Vec<&str> = vec![ | |
| 8189 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", | |
| 8190 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | |
| 8191 | + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", | |
| 8192 | + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", | |
| 8193 | + "--lag-in-frames=0", "--kf-max-dist=9999", &tile_arg, | |
| 8194 | + // Per-arm overrides go LAST: aomenc keeps the last | |
| 8195 | + // occurrence of a repeated --enable-* flag. | |
| 8196 | + &tx_arg, | |
| 8197 | + "--enable-rect-partitions=1", "--enable-ab-partitions=1", | |
| 8198 | + "--enable-1to4-partitions=0", "--min-partition-size=8", | |
| 8199 | + "--max-partition-size=16", | |
| 8200 | + "--obu", "-o", "-", "-", | |
| 8201 | + ]; | |
| 8202 | + let mut child = Command::new(aomenc_path()) | |
| 8203 | + .args(&args) | |
| 8204 | + .stdin(Stdio::piped()) | |
| 8205 | + .stdout(Stdio::piped()) | |
| 8206 | + .stderr(Stdio::piped()) | |
| 8207 | + .spawn() | |
| 8208 | + .expect("aomenc failed to start"); | |
| 8209 | + child | |
| 8210 | + .stdin | |
| 8211 | + .take() | |
| 8212 | + .expect("aomenc stdin") | |
| 8213 | + .write_all(&y4m.stdout) | |
| 8214 | + .expect("writing y4m to aomenc"); | |
| 8215 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 8216 | + assert!( | |
| 8217 | + out.status.success(), | |
| 8218 | + "aomenc refused the fixture: {}", | |
| 8219 | + String::from_utf8_lossy(&out.stderr) | |
| 8220 | + ); | |
| 8221 | + let stream = out.stdout; | |
| 8222 | + let before = decode::ab16_inter_hits_by_arm(); | |
| 8223 | + let frames = match decode_stream(&stream) { | |
| 8224 | + Err(e) => { | |
| 8225 | + let msg = e.to_string(); | |
| 8226 | + assert!( | |
| 8227 | + msg.contains("unsupported"), | |
| 8228 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ | |
| 8229 | + attempt {attempt}): {msg}" | |
| 8230 | + ); | |
| 8231 | + named_refusals += 1; | |
| 8232 | + eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); | |
| 8233 | + continue; | |
| 8234 | + } | |
| 8235 | + Ok(frames) => frames, | |
| 8236 | + }; | |
| 8237 | + let after = decode::ab16_inter_hits_by_arm(); | |
| 8238 | + let fired: Vec<usize> = | |
| 8239 | + (0..4).map(|a| after[a] - before[a]).collect(); | |
| 8240 | + let ffmpeg_frames = if bit_depth == 10 { | |
| 8241 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | |
| 8242 | + } else { | |
| 8243 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | |
| 8244 | + }; | |
| 8245 | + assert_eq!(frames.len(), frame_count); | |
| 8246 | + let mismatched = frames | |
| 8247 | + .iter() | |
| 8248 | + .zip(&ffmpeg_frames) | |
| 8249 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | |
| 8250 | + if fired.iter().sum::<usize>() == 0 { | |
| 8251 | + out_of_scope += 1; | |
| 8252 | + if mismatched { | |
| 8253 | + oos_mismatch += 1; | |
| 8254 | + eprintln!( | |
| 8255 | + "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \ | |
| 8256 | + 16-level inter AB partition -- another shape's defect" | |
| 8257 | + ); | |
| 8258 | + } | |
| 8259 | + continue; | |
| 8260 | + } | |
| 8261 | + if mismatched { | |
| 8262 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 8263 | + let bad: Vec<usize> = | |
| 8264 | + (0..got.y.len()).filter(|&k| got.y[k] != want.y[k]).collect(); | |
| 8265 | + if !bad.is_empty() { | |
| 8266 | + eprintln!( | |
| 8267 | + "{NAME}: attempt {attempt} {bit_depth}-bit frame {i}: {} luma \ | |
| 8268 | + pixels differ, first at ({}, {}), max |delta| {}", | |
| 8269 | + bad.len(), | |
| 8270 | + bad[0] % width, | |
| 8271 | + bad[0] / width, | |
| 8272 | + bad.iter() | |
| 8273 | + .map(|&k| (got.y[k] as i32 - want.y[k] as i32).abs()) | |
| 8274 | + .max() | |
| 8275 | + .unwrap_or(0) | |
| 8276 | + ); | |
| 8277 | + } | |
| 8278 | + } | |
| 8279 | + } | |
| 8280 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 8281 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); | |
| 8282 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); | |
| 8283 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); | |
| 8284 | + } | |
| 8285 | + for a in 0..4 { | |
| 8286 | + if fired[a] > 0 { | |
| 8287 | + arms_proved[a] += 1; | |
| 8288 | + arms_total[a] += 1; | |
| 8289 | + } | |
| 8290 | + } | |
| 8291 | + matched += 1; | |
| 8292 | + } | |
| 8293 | + eprintln!( | |
| 8294 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ | |
| 8295 | + attempts carrying a 16-level inter AB partition, per-arm attempts \ | |
| 8296 | + HORZ_A/HORZ_B/VERT_A/VERT_B={arms_proved:?}, {out_of_scope} attempts carried \ | |
| 8297 | + none ({oos_mismatch} of them mismatched)" | |
| 8298 | + ); | |
| 8299 | + assert_eq!( | |
| 8300 | + oos_mismatch, 0, | |
| 8301 | + "{NAME}: {oos_mismatch} attempt(s) with no 16-level inter AB partition decoded \ | |
| 8302 | + but mismatched ffmpeg -- a defect of another shape, not a pass" | |
| 8303 | + ); | |
| 8304 | + } | |
| 8305 | + assert!( | |
| 8306 | + arms_total.iter().all(|&n| n > 0), | |
| 8307 | + "{NAME}: not every 16-level inter AB arm fired on a pixel-exact attempt \ | |
| 8308 | + (HORZ_A/HORZ_B/VERT_A/VERT_B={arms_total:?}) -- the unfired arm(s) are unproven" | |
| 8309 | + ); | |
| 8310 | + } | |
| 8311 | + | |
| 8312 | + | |
| 8088 | 8313 | #[test] |
| 8089 | 8314 | fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() { |
| 8090 | 8315 | 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`). |