Merge branch 'lane-fistrip': 8x16/16x8 strips read use_filter_intra (rows were missing, tile desynced silently); sub-16 filter-intra pixel gates re-measured on the merged tree
Browse files at this commit8 changed files +923 -4
- crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu +0 -0
- crates/ec-av1/src/decode.rs +124 -3
- crates/ec-av1/src/intra.rs +192 -0
- crates/ec-av1/src/refusal_inventory.rs +2 -0
- crates/ec-av1/src/stream.rs +331 -1
- lanes/fistrip-r1.report.md +128 -0
- lanes/fistrip-r2.report.md +116 -0
- scripts/extract-filter-intra-cdfs.py +30 -0
crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+124 -3
| @@ -871,6 +871,21 @@ pub(crate) fn filter_intra_rect_hits() -> usize { | |||
| 871 | FILTER_INTRA_RECT_HITS.with(|c| c.get()) | 871 | FILTER_INTRA_RECT_HITS.with(|c| c.get()) |
| 872 | } | 872 | } |
| 873 | 873 | ||
| 874 | +// As [`FILTER_INTRA_RECT_HITS`], counting only the strips BELOW 16x16 | ||
| 875 | +// (8x16/16x8 leaves of a 16x16 HORZ/VERT partition, lane-fistrip r1) -- the | ||
| 876 | +// shapes whose `use_filter_intra` symbol had no CDF class before this round. | ||
| 877 | +// A gate asserting the wider counter would be satisfied by a 32x16 strip and | ||
| 878 | +// prove nothing about the new shapes. | ||
| 879 | +thread_local! { | ||
| 880 | + static FILTER_INTRA_RECT_SUB16_HITS: std::cell::Cell<usize> = | ||
| 881 | + const { std::cell::Cell::new(0) }; | ||
| 882 | +} | ||
| 883 | + | ||
| 884 | +/// Current value of [`FILTER_INTRA_RECT_SUB16_HITS`]. | ||
| 885 | +pub(crate) fn filter_intra_rect_sub16_hits() -> usize { | ||
| 886 | + FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.get()) | ||
| 887 | +} | ||
| 888 | + | ||
| 874 | // How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D` | 889 | // How many [`read_coeffs`] reads resolved a `tx_type` outside `TX_CLASS_2D` |
| 875 | // (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every | 890 | // (`V_DCT`/`H_DCT`, spec 5.11.39's `TxClass::Horiz`/`Vert`), across every |
| 876 | // call on the current thread -- the same before/after counter pattern as | 891 | // call on the current thread -- the same before/after counter pattern as |
| @@ -5170,9 +5185,12 @@ fn decode_leaf_rect( | |||
| 5170 | eprintln!(" skip={skip} mode={mode} angle_delta_y={angle_delta_y} uv_mode={uv_mode}"); | 5185 | eprintln!(" skip={skip} mode={mode} angle_delta_y={angle_delta_y} uv_mode={uv_mode}"); |
| 5171 | } | 5186 | } |
| 5172 | if filter_intra.is_some() { | 5187 | if filter_intra.is_some() { |
| 5173 | - return Err(unsupported( | 5188 | + // lane-fistrip r1: `predict_filter_intra` already walks its 4x2 |
| 5174 | - "filter intra on a HORZ/VERT strip (this decoder predicts square-only)", | 5189 | + // patches over a true `bw`x`bh` block (lane-rectsplit r1), so an |
| 5175 | - )); | 5190 | + // 8x16/16x8 strip predicts through the same call `reconstruct_rect` |
| 5191 | + // below already makes; this refusal was square-only prose. | ||
| 5192 | + FILTER_INTRA_RECT_HITS.with(|c| c.set(c.get() + 1)); | ||
| 5193 | + FILTER_INTRA_RECT_SUB16_HITS.with(|c| c.set(c.get() + 1)); | ||
| 5176 | } | 5194 | } |
| 5177 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; | 5195 | let uv_predict_mode = if uv_mode == UV_CFL_PRED { DC_PRED } else { uv_mode }; |
| 5178 | let depth = if tx_select { | 5196 | let depth = if tx_select { |
| @@ -18251,6 +18269,109 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 18251 | 18269 | ||
| 18252 | #[cfg(test)] | 18270 | #[cfg(test)] |
| 18253 | mod tests { | 18271 | mod tests { |
| 18272 | + | ||
| 18273 | + /// lane-fistrip r1 (class `enumerate-the-table-domain`): every block | ||
| 18274 | + /// shape this decoder can hand [`filter_intra_size_class_rect`], against | ||
| 18275 | + /// `av1_filter_intra_allowed_bsize` (`block_size_wide <= 32 && | ||
| 18276 | + /// block_size_high <= 32`) and `default_filter_intra_cdfs` | ||
| 18277 | + /// (entropymode.c) row by row. A class that exists must carry ITS OWN | ||
| 18278 | + /// bsize's default probability -- a wrong row is a silently different | ||
| 18279 | + /// symbol, not a decode error. The shapes with no class are listed here | ||
| 18280 | + /// with their reason so the residue is pinned rather than implied. | ||
| 18281 | + #[test] | ||
| 18282 | + fn filter_intra_classes_carry_their_own_libaom_default_row() { | ||
| 18283 | + // `default_filter_intra_cdfs[bsize]`, BLOCK_SIZES_ALL order, as | ||
| 18284 | + // (width, height, default, refused_by) for the shapes <= 32 on both | ||
| 18285 | + // axes. The first three fields are GENERATED from the oracle by | ||
| 18286 | + // `scripts/extract-filter-intra-cdfs.py` (it reads BLOCK_SIZES_ALL's | ||
| 18287 | + // order from enums.h and the table from entropymode.c, so no hand | ||
| 18288 | + // transcription can drift -- lane-fistrip r1 listed the four 1:4 | ||
| 18289 | + // shapes as 16384 out of exactly that kind of guess; their real rows | ||
| 18290 | + // are 12770/10368/20229/18101). `refused_by` is `None` for a shape | ||
| 18291 | + // this decoder's partition tree reaches today -- it must own a class, | ||
| 18292 | + // and that class must carry exactly this row -- and the refusal | ||
| 18293 | + // string that blocks the shape otherwise. Either way the row is | ||
| 18294 | + // pinned HERE, so the round that lifts one of those refusals cannot | ||
| 18295 | + // land a wrong CDF row for the shape it unlocks. | ||
| 18296 | + const BELOW_8X8: &str = | ||
| 18297 | + "a partition below 8x8 (this decoder codes no leaf smaller than 8x8)"; | ||
| 18298 | + const PART16: &str = "a HORZ_A/HORZ_B/VERT_A partition below 16x16 (this decoder codes \ | ||
| 18299 | + only the square arms, HORZ, VERT, VERT_B, and a clean split below 16x16)"; | ||
| 18300 | + const PART32: &str = "a 32x32 partition type this decoder does not code (value={part32})"; | ||
| 18301 | + let libaom: &[(usize, usize, u16, Option<&str>)] = &[ | ||
| 18302 | + (4, 4, 4621, None), | ||
| 18303 | + (4, 8, 6743, Some(BELOW_8X8)), | ||
| 18304 | + (8, 4, 5893, Some(BELOW_8X8)), | ||
| 18305 | + (8, 8, 7866, None), | ||
| 18306 | + (8, 16, 12551, None), | ||
| 18307 | + (16, 8, 9394, None), | ||
| 18308 | + (16, 16, 12408, None), | ||
| 18309 | + (16, 32, 14301, None), | ||
| 18310 | + (32, 16, 12756, None), | ||
| 18311 | + (32, 32, 22343, None), | ||
| 18312 | + // The 1:4 strips: a 16x16-level PARTITION_HORZ_4/VERT_4 gives | ||
| 18313 | + // 4x16/16x4, a 32x32-level one 8x32/32x8, and both partition | ||
| 18314 | + // values refuse by name before any leaf is coded. | ||
| 18315 | + (4, 16, 12770, Some(PART16)), | ||
| 18316 | + (16, 4, 10368, Some(PART16)), | ||
| 18317 | + (8, 32, 20229, Some(PART32)), | ||
| 18318 | + (32, 8, 18101, Some(PART32)), | ||
| 18319 | + ]; | ||
| 18320 | + let mut classes_seen = std::collections::BTreeSet::new(); | ||
| 18321 | + for &(bw, bh, default, refused_by) in libaom { | ||
| 18322 | + match filter_intra_size_class_rect(bw, bh) { | ||
| 18323 | + Some(class) => { | ||
| 18324 | + assert!( | ||
| 18325 | + refused_by.is_none(), | ||
| 18326 | + "{bw}x{bh} has a CDF class but is listed as refused by {refused_by:?} -- \ | ||
| 18327 | + one of the two is stale" | ||
| 18328 | + ); | ||
| 18329 | + assert_eq!( | ||
| 18330 | + crate::cdf::FILTER_INTRA[class][0], | ||
| 18331 | + default, | ||
| 18332 | + "{bw}x{bh} (class {class}) must carry default_filter_intra_cdfs' own row" | ||
| 18333 | + ); | ||
| 18334 | + assert_eq!( | ||
| 18335 | + &crate::cdf::FILTER_INTRA[class][1..], | ||
| 18336 | + &[32768u16, 0][..], | ||
| 18337 | + "{bw}x{bh} (class {class}) is a 2-symbol CDF: {{p, 32768, count}}" | ||
| 18338 | + ); | ||
| 18339 | + assert!( | ||
| 18340 | + classes_seen.insert(class), | ||
| 18341 | + "class {class} is claimed by two shapes -- one of them reads the other's \ | ||
| 18342 | + probability" | ||
| 18343 | + ); | ||
| 18344 | + } | ||
| 18345 | + None => { | ||
| 18346 | + let why = refused_by.unwrap_or_else(|| { | ||
| 18347 | + panic!( | ||
| 18348 | + "{bw}x{bh} is inside av1_filter_intra_allowed_bsize and reachable, \ | ||
| 18349 | + but has no CDF class -- its use_filter_intra symbol is never read" | ||
| 18350 | + ) | ||
| 18351 | + }); | ||
| 18352 | + assert!(!why.is_empty(), "{bw}x{bh}'s refusal string must name the blocker"); | ||
| 18353 | + } | ||
| 18354 | + } | ||
| 18355 | + } | ||
| 18356 | + // The other direction: every row of `cdf::FILTER_INTRA` was claimed | ||
| 18357 | + // by exactly one shape above, so no row can be left over (or shared) | ||
| 18358 | + // once a class is added or removed. | ||
| 18359 | + assert_eq!( | ||
| 18360 | + classes_seen.len(), | ||
| 18361 | + crate::cdf::FILTER_INTRA.len(), | ||
| 18362 | + "cdf::FILTER_INTRA has {} rows but only {:?} are claimed by an allowed shape", | ||
| 18363 | + crate::cdf::FILTER_INTRA.len(), | ||
| 18364 | + classes_seen | ||
| 18365 | + ); | ||
| 18366 | + // Past the bound on either axis: no symbol at all (spec | ||
| 18367 | + // `filter_intra_mode_info` never reads one). | ||
| 18368 | + for (bw, bh) in [(64, 64), (64, 32), (32, 64)] { | ||
| 18369 | + assert!( | ||
| 18370 | + filter_intra_size_class_rect(bw, bh).is_none(), | ||
| 18371 | + "{bw}x{bh} is past av1_filter_intra_allowed_bsize's <=32 bound" | ||
| 18372 | + ); | ||
| 18373 | + } | ||
| 18374 | + } | ||
| 18254 | use super::*; | 18375 | use super::*; |
| 18255 | 18376 | ||
| 18256 | /// lane-tx64x16 r3: the two new 4:1 chroma scans are a TRANSPOSED PAIR -- | 18377 | /// lane-tx64x16 r3: the two new 4:1 chroma scans are a TRANSPOSED PAIR -- |
crates/ec-av1/src/intra.rsmodified+192 -0
| @@ -865,6 +865,198 @@ mod tests { | |||
| 865 | .sum() | 865 | .sum() |
| 866 | } | 866 | } |
| 867 | 867 | ||
| 868 | + /// libaom `av1_filter_intra_taps` (reconintra.c:807-858), transcribed | ||
| 869 | + /// here INDEPENDENTLY of [`FILTER_INTRA_TAPS`] -- the point of the test | ||
| 870 | + /// below is that two transcriptions of the reference agree, so it must | ||
| 871 | + /// not read the table it is checking. (libaom's rows are 8 wide with the | ||
| 872 | + /// 8th tap always 0; only seven are used.) | ||
| 873 | + const LIBAOM_FILTER_INTRA_TAPS: [[[i32; 7]; 8]; 5] = [ | ||
| 874 | + [ | ||
| 875 | + [-6, 10, 0, 0, 0, 12, 0], | ||
| 876 | + [-5, 2, 10, 0, 0, 9, 0], | ||
| 877 | + [-3, 1, 1, 10, 0, 7, 0], | ||
| 878 | + [-3, 1, 1, 2, 10, 5, 0], | ||
| 879 | + [-4, 6, 0, 0, 0, 2, 12], | ||
| 880 | + [-3, 2, 6, 0, 0, 2, 9], | ||
| 881 | + [-3, 2, 2, 6, 0, 2, 7], | ||
| 882 | + [-3, 1, 2, 2, 6, 3, 5], | ||
| 883 | + ], | ||
| 884 | + [ | ||
| 885 | + [-10, 16, 0, 0, 0, 10, 0], | ||
| 886 | + [-6, 0, 16, 0, 0, 6, 0], | ||
| 887 | + [-4, 0, 0, 16, 0, 4, 0], | ||
| 888 | + [-2, 0, 0, 0, 16, 2, 0], | ||
| 889 | + [-10, 16, 0, 0, 0, 0, 10], | ||
| 890 | + [-6, 0, 16, 0, 0, 0, 6], | ||
| 891 | + [-4, 0, 0, 16, 0, 0, 4], | ||
| 892 | + [-2, 0, 0, 0, 16, 0, 2], | ||
| 893 | + ], | ||
| 894 | + [ | ||
| 895 | + [-8, 8, 0, 0, 0, 16, 0], | ||
| 896 | + [-8, 0, 8, 0, 0, 16, 0], | ||
| 897 | + [-8, 0, 0, 8, 0, 16, 0], | ||
| 898 | + [-8, 0, 0, 0, 8, 16, 0], | ||
| 899 | + [-4, 4, 0, 0, 0, 0, 16], | ||
| 900 | + [-4, 0, 4, 0, 0, 0, 16], | ||
| 901 | + [-4, 0, 0, 4, 0, 0, 16], | ||
| 902 | + [-4, 0, 0, 0, 4, 0, 16], | ||
| 903 | + ], | ||
| 904 | + [ | ||
| 905 | + [-2, 8, 0, 0, 0, 10, 0], | ||
| 906 | + [-1, 3, 8, 0, 0, 6, 0], | ||
| 907 | + [-1, 2, 3, 8, 0, 4, 0], | ||
| 908 | + [0, 1, 2, 3, 8, 2, 0], | ||
| 909 | + [-1, 4, 0, 0, 0, 3, 10], | ||
| 910 | + [-1, 3, 4, 0, 0, 4, 6], | ||
| 911 | + [-1, 2, 3, 4, 0, 4, 4], | ||
| 912 | + [-1, 2, 2, 3, 4, 3, 3], | ||
| 913 | + ], | ||
| 914 | + [ | ||
| 915 | + [-12, 14, 0, 0, 0, 14, 0], | ||
| 916 | + [-10, 0, 14, 0, 0, 12, 0], | ||
| 917 | + [-9, 0, 0, 14, 0, 11, 0], | ||
| 918 | + [-8, 0, 0, 0, 14, 10, 0], | ||
| 919 | + [-10, 12, 0, 0, 0, 0, 14], | ||
| 920 | + [-9, 1, 12, 0, 0, 0, 12], | ||
| 921 | + [-8, 0, 0, 12, 0, 1, 11], | ||
| 922 | + [-7, 0, 0, 1, 12, 1, 9], | ||
| 923 | + ], | ||
| 924 | + ]; | ||
| 925 | + | ||
| 926 | + /// A straight port of `av1_filter_intra_predictor_c` / | ||
| 927 | + /// `highbd_filter_intra_predictor` (reconintra.c:860-905 / 908-955 -- | ||
| 928 | + /// identical except for the clip), written from the C rather than from | ||
| 929 | + /// [`predict_filter_intra`]. `above` is the C `&above[-1]`, i.e. the | ||
| 930 | + /// corner followed by `bw` samples; `left` is `bh` samples. | ||
| 931 | + fn libaom_filter_intra_predictor( | ||
| 932 | + dst: &mut [u16], | ||
| 933 | + bw: usize, | ||
| 934 | + bh: usize, | ||
| 935 | + above: &[u16], | ||
| 936 | + left: &[u16], | ||
| 937 | + mode: usize, | ||
| 938 | + bd: u32, | ||
| 939 | + ) { | ||
| 940 | + assert!(bw <= 32 && bh <= 32); | ||
| 941 | + let mut buffer = [[0i32; 33]; 33]; | ||
| 942 | + for r in 0..bh { | ||
| 943 | + buffer[r + 1][0] = i32::from(left[r]); | ||
| 944 | + } | ||
| 945 | + for c in 0..bw + 1 { | ||
| 946 | + buffer[0][c] = i32::from(above[c]); | ||
| 947 | + } | ||
| 948 | + let max = (1i32 << bd) - 1; | ||
| 949 | + let mut r = 1; | ||
| 950 | + while r < bh + 1 { | ||
| 951 | + let mut c = 1; | ||
| 952 | + while c < bw + 1 { | ||
| 953 | + let p = [ | ||
| 954 | + buffer[r - 1][c - 1], | ||
| 955 | + buffer[r - 1][c], | ||
| 956 | + buffer[r - 1][c + 1], | ||
| 957 | + buffer[r - 1][c + 2], | ||
| 958 | + buffer[r - 1][c + 3], | ||
| 959 | + buffer[r][c - 1], | ||
| 960 | + buffer[r + 1][c - 1], | ||
| 961 | + ]; | ||
| 962 | + for k in 0..8 { | ||
| 963 | + let mut pr = 0i32; | ||
| 964 | + for t in 0..7 { | ||
| 965 | + pr += LIBAOM_FILTER_INTRA_TAPS[mode][k][t] * p[t]; | ||
| 966 | + } | ||
| 967 | + // ROUND_POWER_OF_TWO(pr, 4) then clip_pixel[_highbd]. | ||
| 968 | + let v = ((pr + 8) >> 4).clamp(0, max); | ||
| 969 | + buffer[r + (k >> 2)][c + (k & 3)] = v; | ||
| 970 | + } | ||
| 971 | + c += 4; | ||
| 972 | + } | ||
| 973 | + r += 2; | ||
| 974 | + } | ||
| 975 | + for row in 0..bh { | ||
| 976 | + for col in 0..bw { | ||
| 977 | + dst[row * bw + col] = buffer[row + 1][col + 1] as u16; | ||
| 978 | + } | ||
| 979 | + } | ||
| 980 | + } | ||
| 981 | + | ||
| 982 | + /// lane-fistrip r2: [`predict_filter_intra`] had NO unit test at all -- | ||
| 983 | + /// the 8x16/16x8 strips r1 unblocked read their `use_filter_intra` flag | ||
| 984 | + /// with zero pixel evidence behind it (every firing strip is `skip=0` | ||
| 985 | + /// and refuses, see `stream.rs`'s ignored gate). This compares it | ||
| 986 | + /// bit-exact against the independent C port above for every filter-intra | ||
| 987 | + /// mode, every shape `av1_filter_intra_allowed_bsize` allows (both sides | ||
| 988 | + /// <= 32, squares and both orientations of 1:2 and 1:4), 8- and 10-bit, | ||
| 989 | + /// on three seeded random edges. | ||
| 990 | + #[test] | ||
| 991 | + fn filter_intra_matches_the_libaom_predictor_for_every_mode_and_shape() { | ||
| 992 | + // xorshift64*: a seeded stream, so a failure names one (shape, mode, | ||
| 993 | + // seed) triple that reproduces. | ||
| 994 | + let mut rng = |state: &mut u64| { | ||
| 995 | + *state ^= *state << 13; | ||
| 996 | + *state ^= *state >> 7; | ||
| 997 | + *state ^= *state << 17; | ||
| 998 | + *state | ||
| 999 | + }; | ||
| 1000 | + let shapes = [ | ||
| 1001 | + (4usize, 4usize), | ||
| 1002 | + (8, 8), | ||
| 1003 | + (16, 16), | ||
| 1004 | + (32, 32), | ||
| 1005 | + (4, 8), | ||
| 1006 | + (8, 4), | ||
| 1007 | + (8, 16), | ||
| 1008 | + (16, 8), | ||
| 1009 | + (16, 32), | ||
| 1010 | + (32, 16), | ||
| 1011 | + (4, 16), | ||
| 1012 | + (16, 4), | ||
| 1013 | + (8, 32), | ||
| 1014 | + (32, 8), | ||
| 1015 | + ]; | ||
| 1016 | + let mut compared = 0u32; | ||
| 1017 | + for bd in [8u32, 10] { | ||
| 1018 | + crate::decode::set_bit_depth(bd as u8); | ||
| 1019 | + let max = (1u32 << bd) - 1; | ||
| 1020 | + for &(bw, bh) in &shapes { | ||
| 1021 | + for mode in 0..5usize { | ||
| 1022 | + for seed in [1u64, 0x5eed_5eed, 0xdead_beef_cafe] { | ||
| 1023 | + let mut state = seed | ||
| 1024 | + .wrapping_mul(0x9E37_79B9_7F4A_7C15) | ||
| 1025 | + .wrapping_add((bw * 97 + bh * 7 + mode) as u64) | ||
| 1026 | + | 1; | ||
| 1027 | + let sample = |state: &mut u64| (rng(state) % u64::from(max + 1)) as u16; | ||
| 1028 | + let corner = sample(&mut state); | ||
| 1029 | + let above: Vec<u16> = (0..bw).map(|_| sample(&mut state)).collect(); | ||
| 1030 | + let left: Vec<u16> = (0..bh).map(|_| sample(&mut state)).collect(); | ||
| 1031 | + let mut want = vec![0u16; bw * bh]; | ||
| 1032 | + let mut c_above = vec![corner]; | ||
| 1033 | + c_above.extend_from_slice(&above); | ||
| 1034 | + libaom_filter_intra_predictor( | ||
| 1035 | + &mut want, bw, bh, &c_above, &left, mode, bd, | ||
| 1036 | + ); | ||
| 1037 | + let mut got = vec![0u16; bw * bh]; | ||
| 1038 | + predict_filter_intra( | ||
| 1039 | + mode, | ||
| 1040 | + Some(&above), | ||
| 1041 | + Some(&left), | ||
| 1042 | + Some(corner), | ||
| 1043 | + bw, | ||
| 1044 | + bh, | ||
| 1045 | + &mut got, | ||
| 1046 | + ); | ||
| 1047 | + assert_eq!( | ||
| 1048 | + got, want, | ||
| 1049 | + "filter intra mode {mode}, {bw}x{bh}, {bd}-bit, seed {seed:#x}" | ||
| 1050 | + ); | ||
| 1051 | + compared += 1; | ||
| 1052 | + } | ||
| 1053 | + } | ||
| 1054 | + } | ||
| 1055 | + } | ||
| 1056 | + crate::decode::set_bit_depth(8); | ||
| 1057 | + assert_eq!(compared, 2 * 14 * 5 * 3, "every shape/mode/seed was compared"); | ||
| 1058 | + } | ||
| 1059 | + | ||
| 868 | /// lane-intrarect r1: checksum-verify DC/SMOOTH/PAETH and a directional | 1060 | /// lane-intrarect r1: checksum-verify DC/SMOOTH/PAETH and a directional |
| 869 | /// sweep across all three zones, `enable_edge_filter`/`smooth_neighbor` | 1061 | /// sweep across all three zones, `enable_edge_filter`/`smooth_neighbor` |
| 870 | /// on and off, for eight rect shapes (both 1:2 and 1:4, both | 1062 | /// on and off, for eight rect shapes (both 1:2 and 1:4, both |
crates/ec-av1/src/refusal_inventory.rsmodified+2 -0
| @@ -67,6 +67,8 @@ const REFUSALS: &[&str] = &[ | |||
| 67 | "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)", | 67 | "an inter partition below 16x16 other than SPLIT (16x8/8x16 rect inter leaves are not coded yet)", |
| 68 | "an intra mode this decoder does not code (round 2)", | 68 | "an intra mode this decoder does not code (round 2)", |
| 69 | "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet", | 69 | "an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet", |
| 70 | + // Lifted for the 16x8/8x16 leaf by lane-fistrip; still live one level | ||
| 71 | + // down, at the 4x8/8x4 sub-8 leaf (lane-tx4x8's `decode_leaf_rect8`). | ||
| 70 | "filter intra on a HORZ/VERT strip (this decoder predicts square-only)", | 72 | "filter intra on a HORZ/VERT strip (this decoder predicts square-only)", |
| 71 | "warp prediction with a scaled reference (superres, unimplemented)", | 73 | "warp prediction with a scaled reference (superres, unimplemented)", |
| 72 | "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", | 74 | "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", |
crates/ec-av1/src/stream.rsmodified+331 -1
| @@ -9172,7 +9172,16 @@ mod tests { | |||
| 9172 | let mut other_refusals = Vec::new(); | 9172 | let mut other_refusals = Vec::new(); |
| 9173 | for attempt in 0..n_attempts { | 9173 | for attempt in 0..n_attempts { |
| 9174 | let seed = 42 + attempt; | 9174 | let seed = 42 + attempt; |
| 9175 | - let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); | 9175 | + // Diagnosis knob: which content makes RD pick an 8x16/16x8 strip |
| 9176 | + // AND filter intra on it is a search (see lanes/fistrip-r1.report.md). | ||
| 9177 | + let source = match std::env::var("EC_FISTRIP_SRC").unwrap_or_default().as_str() { | ||
| 9178 | + "bars" => format!("smptebars=size={width}x{height}:duration=0.04:rate=25"), | ||
| 9179 | + "src2" => format!("testsrc2=size={width}x{height}:duration=0.04:rate=25"), | ||
| 9180 | + "noise" => format!( | ||
| 9181 | + "nullsrc=size={width}x{height}:duration=0.04:rate=25,geq=random(1)*255:128:128" | ||
| 9182 | + ), | ||
| 9183 | + _ => gradients_source(seed, width, height, "duration=0.04:rate=25"), | ||
| 9184 | + }; | ||
| 9176 | let y4m = Command::new("ffmpeg") | 9185 | let y4m = Command::new("ffmpeg") |
| 9177 | .args(["-v", "error", "-f", "lavfi", "-i"]) | 9186 | .args(["-v", "error", "-f", "lavfi", "-i"]) |
| 9178 | .arg(&source) | 9187 | .arg(&source) |
| @@ -14147,6 +14156,327 @@ mod tests { | |||
| 14147 | ); | 14156 | ); |
| 14148 | } | 14157 | } |
| 14149 | 14158 | ||
| 14159 | + /// lane-fistrip r1, the 10-bit arm of the strip gate (his films are | ||
| 14160 | + /// yuv420p10le). Same ceiling as its 8-bit twin -- kept `#[ignore]`d | ||
| 14161 | + /// with the measurement rather than weakened: MEASURED over seeds | ||
| 14162 | + /// 42..61 the 8x16/16x8 strips aomenc writes filter intra on are | ||
| 14163 | + /// `skip=0`, which `decode_leaf_rect` refuses, so | ||
| 14164 | + /// `filter_intra_rect_sub16_hits` never reaches a pixel compare. | ||
| 14165 | + /// lane-fistrip r2 adds seeds 49 and 213 to the window: those are the two | ||
| 14166 | + /// seeds measured to fire the feature on the 8-BIT twin's recipe (this | ||
| 14167 | + /// arm's 10-bit encode is a different stream, so they are a widening, not | ||
| 14168 | + /// a measured firing set for this recipe -- the round that un-ignores | ||
| 14169 | + /// this gate must re-measure which 10-bit seeds fire it). | ||
| 14170 | + #[ignore = "2026-09-02, re-measured on the merged tree: the coded-strip refusal is lifted, but every firing 10-bit seed now stops at the sub16 SPLIT-TRANSFORM refusal (49, 55) or palette-in-screen-content (45, 46); 16 attempts decode pixel-exact with 0 hits, so the gate would prove nothing"] | ||
| 14171 | + #[test] | ||
| 14172 | + fn a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact() { | ||
| 14173 | + const NAME: &str = "a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact"; | ||
| 14174 | + let _gate_lock = lock_gate_counters(); | ||
| 14175 | + if !have_ffmpeg() { | ||
| 14176 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 14177 | + return; | ||
| 14178 | + } | ||
| 14179 | + if !have_aomenc() { | ||
| 14180 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 14181 | + return; | ||
| 14182 | + } | ||
| 14183 | + let mut seeds: Vec<u32> = (42..62).collect(); | ||
| 14184 | + seeds.push(213); | ||
| 14185 | + ten_bit_tool_gate( | ||
| 14186 | + NAME, | ||
| 14187 | + 192, | ||
| 14188 | + 128, | ||
| 14189 | + 1, | ||
| 14190 | + &[ | ||
| 14191 | + "--limit=1", | ||
| 14192 | + "--cq-level=25", | ||
| 14193 | + "--cpu-used=0", | ||
| 14194 | + "--threads=1", | ||
| 14195 | + "--row-mt=0", | ||
| 14196 | + "--sb-size=64", | ||
| 14197 | + "--enable-rect-partitions=1", | ||
| 14198 | + "--enable-ab-partitions=0", | ||
| 14199 | + "--enable-1to4-partitions=0", | ||
| 14200 | + "--min-partition-size=8", | ||
| 14201 | + "--max-partition-size=32", | ||
| 14202 | + "--enable-restoration=0", | ||
| 14203 | + "--enable-palette=0", | ||
| 14204 | + "--deltaq-mode=0", | ||
| 14205 | + "--enable-filter-intra=1", | ||
| 14206 | + "--enable-cfl-intra=0", | ||
| 14207 | + "--enable-intrabc=0", | ||
| 14208 | + ], | ||
| 14209 | + &seeds, | ||
| 14210 | + &[( | ||
| 14211 | + "filter_intra_rect_sub16_hits", | ||
| 14212 | + crate::decode::filter_intra_rect_sub16_hits as fn() -> usize, | ||
| 14213 | + )], | ||
| 14214 | + ); | ||
| 14215 | + } | ||
| 14216 | + | ||
| 14217 | + /// lane-fistrip r1, the pinned half of this lane's proof: one real | ||
| 14218 | + /// `aomenc` stream (recipe below, byte-reproducible -- md5 | ||
| 14219 | + /// ac3a64773e5454ee9b5d8650507063cd, hashed twice) whose key frame | ||
| 14220 | + /// carries four `BLOCK_16X8` DC_PRED leaves, one of which sets | ||
| 14221 | + /// `use_filter_intra`. `av1_filter_intra_allowed_bsize` allows 16x8, so | ||
| 14222 | + /// aomenc writes that flag; before this round `filter_intra_size_class_rect` | ||
| 14223 | + /// had no row for the shape, the symbol was never read, and the tile | ||
| 14224 | + /// desynced ON THAT BLOCK -- observable as a DIFFERENT named refusal | ||
| 14225 | + /// ("a HORZ/VERT intra strip below 16x16 with a split transform", a | ||
| 14226 | + /// `tx_depth` read out of a desynced stream) instead of this one. | ||
| 14227 | + /// | ||
| 14228 | + /// The stream cannot be pixel-compared yet: the 16x8 strip that carries | ||
| 14229 | + /// the flag is `skip=0`, and a coded rect strip below 16x16 has no | ||
| 14230 | + /// residual path here (its own refusal, another lane's ceiling). What | ||
| 14231 | + /// this test pins is the SYMBOL: the flag is read, the counter fires | ||
| 14232 | + /// once, and the decode stops at the coded-strip ceiling rather than | ||
| 14233 | + /// wandering off a desynced stream. | ||
| 14234 | + /// | ||
| 14235 | + /// Fixture recipe (`crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu`): | ||
| 14236 | + /// `ffmpeg -f lavfi -i gradients=size=192x128:c0=0x986ae1:c1=0xd3e49a: | ||
| 14237 | + /// c2=0x0b1e53:c3=0x42980c:seed=49:duration=0.04:rate=25 -pix_fmt yuv420p` | ||
| 14238 | + /// into `aomenc --codec=av1 --passes=1 --end-usage=q --cq-level=25 | ||
| 14239 | + /// --cpu-used=0 --threads=1 --row-mt=0 --sb-size=64 | ||
| 14240 | + /// --enable-rect-partitions=1 --enable-ab-partitions=0 | ||
| 14241 | + /// --enable-1to4-partitions=0 --min-partition-size=8 | ||
| 14242 | + /// --max-partition-size=32 --enable-restoration=0 --enable-palette=0 | ||
| 14243 | + /// --deltaq-mode=0 --enable-filter-intra=1 --enable-cfl-intra=0 | ||
| 14244 | + /// --enable-intrabc=0 --obu`. | ||
| 14245 | + #[test] | ||
| 14246 | + fn a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag() { | ||
| 14247 | + const NAME: &str = "a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag"; | ||
| 14248 | + let _gate_lock = lock_gate_counters(); | ||
| 14249 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | ||
| 14250 | + .join("fixtures/filter_intra_8x16_strip_seed49.obu"); | ||
| 14251 | + let stream = std::fs::read(&path) | ||
| 14252 | + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); | ||
| 14253 | + let before = crate::decode::filter_intra_rect_sub16_hits(); | ||
| 14254 | + let err = decode_stream(&stream).expect_err( | ||
| 14255 | + "{NAME}: this stream's 16x8 filter-intra strip is skip=0, which this decoder \ | ||
| 14256 | + still refuses -- a clean decode means the coded-strip ceiling moved and this \ | ||
| 14257 | + test should become a pixel compare", | ||
| 14258 | + ); | ||
| 14259 | + let hits = crate::decode::filter_intra_rect_sub16_hits() - before; | ||
| 14260 | + assert_eq!( | ||
| 14261 | + hits, 1, | ||
| 14262 | + "{NAME}: expected exactly one 16x8 strip to read use_filter_intra=1 (aomdec's own \ | ||
| 14263 | + EC_TRACE_MODE shows four BLOCK_16X8 DC_PRED leaves here); got {hits}" | ||
| 14264 | + ); | ||
| 14265 | + let msg = err.to_string(); | ||
| 14266 | + assert!( | ||
| 14267 | + // 2026-09-02, merging lane-fistrip onto a main that already carries | ||
| 14268 | + // lane-rectx: the coded-strip ceiling this fixture used to hit is | ||
| 14269 | + // gone, and the very next one on the SAME block is the split | ||
| 14270 | + // transform under a sub-16 strip (per-unit rect prediction is not | ||
| 14271 | + // ported). Still a refusal ON that block, still not a desync. | ||
| 14272 | + msg.contains("a HORZ/VERT intra strip below 16x16 with a split transform"), | ||
| 14273 | + "{NAME}: decode must reach the sub16 split-transform ceiling ON that block, not \ | ||
| 14274 | + wander off a desynced stream; got: {msg}" | ||
| 14275 | + ); | ||
| 14276 | + } | ||
| 14277 | + | ||
| 14278 | + /// lane-fistrip r1: the filter-intra strip gate above, one partition | ||
| 14279 | + /// level DOWN (`--min-partition-size=8`, so a 16x16 HORZ/VERT splits | ||
| 14280 | + /// into 8x16/16x8 leaves). `av1_filter_intra_allowed_bsize` is | ||
| 14281 | + /// `wide <= 32 && high <= 32`, which both of those satisfy, so aomenc | ||
| 14282 | + /// writes a `use_filter_intra` flag on every DC_PRED one of them -- | ||
| 14283 | + /// `filter_intra_size_class_rect` had no row for either shape and | ||
| 14284 | + /// [`crate::decode::read_intra_mode_rect`] therefore never READ that | ||
| 14285 | + /// symbol (class `symbol-consumption-gap`, a silent desync rather than | ||
| 14286 | + /// a refusal). Hard-asserts | ||
| 14287 | + /// [`crate::decode::filter_intra_rect_sub16_hits`], not the wider | ||
| 14288 | + /// `filter_intra_rect_hits`: a 32x16 strip firing filter intra would | ||
| 14289 | + /// satisfy that one and prove nothing about the new shapes. | ||
| 14290 | + /// MEASURED (lane-fistrip r1, seeds 42..=241; r2 re-ran 50..=241), which | ||
| 14291 | + /// is why it is `#[ignore]`d rather than green: over those 200 seeds at | ||
| 14292 | + /// cq 25 aomenc put filter intra on an 8x16/16x8 strip exactly TWICE -- | ||
| 14293 | + /// **seed 49 and seed 213** -- and both times that strip was `skip=0`, so | ||
| 14294 | + /// the attempt refused at the coded-rect-strip-below-16x16 ceiling before | ||
| 14295 | + /// any pixel compare (r1: 177 pixel-exact matches, 23 refusals, compared | ||
| 14296 | + /// sub16 delta 0, all-attempt delta 2; r2 seeds 50..=241: 172 matches, 20 | ||
| 14297 | + /// refusals, the one all-attempt hit at seed 213). BOTH firing seeds are | ||
| 14298 | + /// appended to this gate's seed window below, so the un-ignore compares | ||
| 14299 | + /// two real hits. Un-ignore this the round that ceiling lifts; the symbol | ||
| 14300 | + /// itself is pinned by | ||
| 14301 | + /// [`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`], whose | ||
| 14302 | + /// `expect_err` must become a pixel compare in that same round. | ||
| 14303 | + #[ignore = "2026-09-02, re-measured on the merged tree: 35 of 41 attempts decode pixel-exact with ZERO mismatches, but both firing seeds (49, 213) stop at the sub16 split-transform / HORZ_A-B refusals, so no filter-intra 8x16/16x8 strip is compared yet"] | ||
| 14304 | + #[test] | ||
| 14305 | + fn a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact() { | ||
| 14306 | + const NAME: &str = | ||
| 14307 | + "a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact"; | ||
| 14308 | + let _gate_lock = lock_gate_counters(); | ||
| 14309 | + if !have_ffmpeg() { | ||
| 14310 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 14311 | + return; | ||
| 14312 | + } | ||
| 14313 | + if !have_aomenc() { | ||
| 14314 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 14315 | + return; | ||
| 14316 | + } | ||
| 14317 | + let (width, height) = (192usize, 128usize); | ||
| 14318 | + let mut named_refusals = 0u32; | ||
| 14319 | + let mut matched = 0u32; | ||
| 14320 | + let mut compared_hits = 0usize; | ||
| 14321 | + let n_attempts: u32 = std::env::var("EC_FISTRIP_GATE_ATTEMPTS") | ||
| 14322 | + .ok() | ||
| 14323 | + .and_then(|s| s.parse().ok()) | ||
| 14324 | + .unwrap_or(40); | ||
| 14325 | + // lane-fistrip r2: the two seeds that MEASURABLY fire filter intra on | ||
| 14326 | + // an 8x16/16x8 strip are 49 and 213 -- the only two in seeds 42..=241 | ||
| 14327 | + // (r1 measured 42..=241 and reported "all-attempt delta 2" with seed | ||
| 14328 | + // 49; r2 re-ran seeds 50..=241 and found the second, log | ||
| 14329 | + // `$HOME/.cache/fistrip-seedscan-r2.log`: "seed 213 refused with sub16 | ||
| 14330 | + // filter-intra delta 1"). Both are appended to whatever window | ||
| 14331 | + // `EC_FISTRIP_GATE_ATTEMPTS` asks for, so the un-ignore after the | ||
| 14332 | + // coded-rect-strip ceiling lifts compares TWO real hits instead of | ||
| 14333 | + // depending on the default window happening to contain one. | ||
| 14334 | + const FIRING_SEEDS: [u32; 2] = [49, 213]; | ||
| 14335 | + let mut seeds: Vec<u32> = (0..n_attempts).map(|a| 42 + a).collect(); | ||
| 14336 | + for s in FIRING_SEEDS { | ||
| 14337 | + if !seeds.contains(&s) { | ||
| 14338 | + seeds.push(s); | ||
| 14339 | + } | ||
| 14340 | + } | ||
| 14341 | + let cq = format!( | ||
| 14342 | + "--cq-level={}", | ||
| 14343 | + std::env::var("EC_FISTRIP_CQ").unwrap_or_else(|_| "25".into()) | ||
| 14344 | + ); | ||
| 14345 | + // Diagnosis: the counter over EVERY attempt, refused ones included -- | ||
| 14346 | + // a filter-intra 8x16 strip inside an attempt that later refused | ||
| 14347 | + // (non-skip, split transform) fires this but never reaches | ||
| 14348 | + // `compared_hits`, and the two numbers differing is what says the | ||
| 14349 | + // recipe reaches the feature but this decoder's other ceilings hide | ||
| 14350 | + // it. | ||
| 14351 | + let all_before = crate::decode::filter_intra_rect_sub16_hits(); | ||
| 14352 | + for &seed in &seeds { | ||
| 14353 | + let source = gradients_source(seed, width, height, "duration=0.04:rate=25"); | ||
| 14354 | + let y4m = Command::new("ffmpeg") | ||
| 14355 | + .args([ | ||
| 14356 | + "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | ||
| 14357 | + "yuv4mpegpipe", "-", | ||
| 14358 | + ]) | ||
| 14359 | + .stdin(Stdio::null()) | ||
| 14360 | + .stdout(Stdio::piped()) | ||
| 14361 | + .stderr(Stdio::piped()) | ||
| 14362 | + .output() | ||
| 14363 | + .expect("ffmpeg failed to run"); | ||
| 14364 | + assert!( | ||
| 14365 | + y4m.status.success(), | ||
| 14366 | + "ffmpeg fixture: {}", | ||
| 14367 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 14368 | + ); | ||
| 14369 | + let args: Vec<&str> = vec![ | ||
| 14370 | + "--codec=av1", | ||
| 14371 | + "--passes=1", | ||
| 14372 | + "--end-usage=q", | ||
| 14373 | + &cq, | ||
| 14374 | + "--cpu-used=0", | ||
| 14375 | + "--threads=1", | ||
| 14376 | + "--row-mt=0", | ||
| 14377 | + "--sb-size=64", | ||
| 14378 | + "--enable-rect-partitions=1", | ||
| 14379 | + "--enable-ab-partitions=0", | ||
| 14380 | + "--enable-1to4-partitions=0", | ||
| 14381 | + // The point of this gate: one level below the 32x16/16x32 | ||
| 14382 | + // strips the sibling gate covers. | ||
| 14383 | + "--min-partition-size=8", | ||
| 14384 | + "--max-partition-size=32", | ||
| 14385 | + "--enable-restoration=0", | ||
| 14386 | + "--enable-palette=0", | ||
| 14387 | + "--deltaq-mode=0", | ||
| 14388 | + "--enable-filter-intra=1", | ||
| 14389 | + "--enable-cfl-intra=0", | ||
| 14390 | + "--enable-intrabc=0", | ||
| 14391 | + "--obu", | ||
| 14392 | + "-o", | ||
| 14393 | + "-", | ||
| 14394 | + "-", | ||
| 14395 | + ]; | ||
| 14396 | + // Diagnosis knob only (default: every intra mode on) -- the same | ||
| 14397 | + // subset search the 32x16/16x32 sibling gate carries. | ||
| 14398 | + let mut args = args; | ||
| 14399 | + let off = std::env::var("EC_FISTRIP_OFF").unwrap_or_default(); | ||
| 14400 | + for tool in off.split(',').filter(|t| !t.is_empty()) { | ||
| 14401 | + args.push(match tool { | ||
| 14402 | + "smooth" => "--enable-smooth-intra=0", | ||
| 14403 | + "paeth" => "--enable-paeth-intra=0", | ||
| 14404 | + "dir" => "--enable-directional-intra=0", | ||
| 14405 | + "angle" => "--enable-angle-delta=0", | ||
| 14406 | + other => panic!("unknown EC_FISTRIP_OFF entry {other}"), | ||
| 14407 | + }); | ||
| 14408 | + } | ||
| 14409 | + let mut child = Command::new(aomenc_path()) | ||
| 14410 | + .args(&args) | ||
| 14411 | + .stdin(Stdio::piped()) | ||
| 14412 | + .stdout(Stdio::piped()) | ||
| 14413 | + .stderr(Stdio::piped()) | ||
| 14414 | + .spawn() | ||
| 14415 | + .expect("aomenc failed to start"); | ||
| 14416 | + child | ||
| 14417 | + .stdin | ||
| 14418 | + .take() | ||
| 14419 | + .expect("aomenc stdin") | ||
| 14420 | + .write_all(&y4m.stdout) | ||
| 14421 | + .expect("writing y4m to aomenc"); | ||
| 14422 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 14423 | + assert!( | ||
| 14424 | + out.status.success(), | ||
| 14425 | + "aomenc refused the fixture: {}", | ||
| 14426 | + String::from_utf8_lossy(&out.stderr) | ||
| 14427 | + ); | ||
| 14428 | + let stream = out.stdout; | ||
| 14429 | + assert!(!stream.is_empty(), "{NAME}: aomenc wrote an empty stream (seed {seed})"); | ||
| 14430 | + let attempt_before = crate::decode::filter_intra_rect_sub16_hits(); | ||
| 14431 | + let frames = match decode_stream(&stream) { | ||
| 14432 | + Err(e) => { | ||
| 14433 | + let msg = e.to_string(); | ||
| 14434 | + assert!( | ||
| 14435 | + msg.contains("unsupported"), | ||
| 14436 | + "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" | ||
| 14437 | + ); | ||
| 14438 | + // Diagnosis: a refused attempt that DID fire the feature | ||
| 14439 | + // says which other ceiling of this decoder hides it. | ||
| 14440 | + eprintln!( | ||
| 14441 | + "{NAME}: seed {seed} refused with sub16 filter-intra delta {}: {msg}", | ||
| 14442 | + crate::decode::filter_intra_rect_sub16_hits() - attempt_before | ||
| 14443 | + ); | ||
| 14444 | + named_refusals += 1; | ||
| 14445 | + continue; | ||
| 14446 | + } | ||
| 14447 | + Ok(frames) => frames, | ||
| 14448 | + }; | ||
| 14449 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | ||
| 14450 | + assert_eq!(frames.len(), 1, "{NAME}: expected one frame (seed {seed})"); | ||
| 14451 | + assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg (seed {seed})"); | ||
| 14452 | + assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg (seed {seed})"); | ||
| 14453 | + assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg (seed {seed})"); | ||
| 14454 | + compared_hits += crate::decode::filter_intra_rect_sub16_hits() - attempt_before; | ||
| 14455 | + matched += 1; | ||
| 14456 | + } | ||
| 14457 | + eprintln!( | ||
| 14458 | + "{NAME}: filter_intra_rect_sub16_hits over ALL attempts (refused included) = {}", | ||
| 14459 | + crate::decode::filter_intra_rect_sub16_hits() - all_before | ||
| 14460 | + ); | ||
| 14461 | + assert!( | ||
| 14462 | + matched > 0, | ||
| 14463 | + "{NAME}: every attempt refused ({named_refusals} named refusals) -- gate decoded nothing" | ||
| 14464 | + ); | ||
| 14465 | + assert!( | ||
| 14466 | + compared_hits > 0, | ||
| 14467 | + "{NAME}: no 8x16/16x8 strip used filter intra ({matched} pixel-exact matches, \ | ||
| 14468 | + {named_refusals} refusals out of {} attempts) -- gate proved nothing this run", | ||
| 14469 | + seeds.len() | ||
| 14470 | + ); | ||
| 14471 | + eprintln!( | ||
| 14472 | + "{NAME}: {matched} pixel-exact matches, {named_refusals} named refusals, \ | ||
| 14473 | + filter_intra_rect_sub16_hits delta={compared_hits} (all attempts including \ | ||
| 14474 | + refused: {}) out of {} attempts", | ||
| 14475 | + crate::decode::filter_intra_rect_sub16_hits() - all_before, | ||
| 14476 | + seeds.len() | ||
| 14477 | + ); | ||
| 14478 | + } | ||
| 14479 | + | ||
| 14150 | /// lane-rectsplit r1 gate (b): [`a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact`]'s | 14480 | /// lane-rectsplit r1 gate (b): [`a_real_aomenc_stream_with_a_superblock_level_horz_vert_partition_decodes_pixel_exact`]'s |
| 14151 | /// own recipe (`--sb-size=64`, `--min/max-partition-size=32/64`, so every | 14481 | /// own recipe (`--sb-size=64`, `--min/max-partition-size=32/64`, so every |
| 14152 | /// SB-level decision is genuinely NONE/SPLIT/HORZ/VERT) with its | 14482 | /// SB-level decision is genuinely NONE/SPLIT/HORZ/VERT) with its |
lanes/fistrip-r1.report.mdadded+128 -0
| @@ -0,0 +1,128 @@ | |||
| 1 | +# lane-fistrip r1 — filter intra on a rect strip | ||
| 2 | + | ||
| 3 | +Branch `lane-fistrip` off main `df5d630`. Worktree | ||
| 4 | +`/home/user/Documents/Code/Rust/edith_codecs-fistrip`, | ||
| 5 | +`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-fistrip`. | ||
| 6 | + | ||
| 7 | +## Charter premise: stale, corrected by measurement | ||
| 8 | + | ||
| 9 | +The charter said `predict_filter_intra` is square-only. It is not: lane-rectsplit r1 | ||
| 10 | +already gave it `bw`x`bh` (`crates/ec-av1/src/intra.rs:773`), and 32x16/16x32 strips | ||
| 11 | +already predict filter intra with a real-aomenc gate | ||
| 12 | +(`a_real_aomenc_stream_with_filter_intra_on_a_horz_vert_strip_decodes_pixel_exact`). | ||
| 13 | + | ||
| 14 | +The real defect one level down was a **symbol-consumption gap**, not a prediction gap: | ||
| 15 | +`filter_intra_size_class_rect` (`decode.rs:3491`) returned `None` for 8x16/16x8, so | ||
| 16 | +`read_intra_mode_rect` never read the `use_filter_intra` flag that | ||
| 17 | +`av1_filter_intra_allowed_bsize` (`wide <= 32 && high <= 32`, oracle | ||
| 18 | +`av1/common/reconintra.h`) makes aomenc write on every DC_PRED 8x16/16x8 leaf. The | ||
| 19 | +`decode_leaf_rect` refusal "filter intra on a HORZ/VERT strip (this decoder predicts | ||
| 20 | +square-only)" (old `decode.rs:4661`) was DEAD CODE behind that `None` — it never fired; | ||
| 21 | +the tile desynced silently instead. | ||
| 22 | + | ||
| 23 | +Film stops measured on main `df5d630` (release `decode_probe`), BEFORE any change: | ||
| 24 | +- `hghead.obu` (ReelB 0.4 s head): `a partition below 8x8 (this decoder codes no | ||
| 25 | + leaf smaller than 8x8)` — earlier than filter intra, as the charter suspected, so the | ||
| 26 | + film is not this lane's gate. | ||
| 27 | +- `reelb5.obu`: `a superblock-level HORZ/VERT strip with a split transform (per-unit rect | ||
| 28 | + prediction is not ported)`. | ||
| 29 | + | ||
| 30 | +## Changed | ||
| 31 | + | ||
| 32 | +- `crates/ec-av1/src/cdf.rs:424` — `FILTER_INTRA` grows to 8 rows: `[6]`=8x16 (12551), | ||
| 33 | + `[7]`=16x8 (9394), `default_filter_intra_cdfs` index 4/5 (oracle | ||
| 34 | + `av1/common/entropymode.c:821`). | ||
| 35 | +- `crates/ec-av1/src/cdf_state.rs:462` — the field's type/doc follow. | ||
| 36 | +- `crates/ec-av1/src/decode.rs:3491` — `filter_intra_size_class_rect` maps | ||
| 37 | + `(8,16)`/`(16,8)` to those rows, so the symbol is READ where aomenc writes it. | ||
| 38 | +- `crates/ec-av1/src/decode.rs` (`decode_leaf_rect`) — the dead square-only refusal | ||
| 39 | + replaced by the counters; the strip predicts through the `reconstruct_rect` call that | ||
| 40 | + was already there. | ||
| 41 | +- `crates/ec-av1/src/decode.rs` — new `FILTER_INTRA_RECT_SUB16_HITS` / | ||
| 42 | + `filter_intra_rect_sub16_hits()`: a gate asserting the wider `filter_intra_rect_hits` | ||
| 43 | + would be satisfied by a 32x16 strip and prove nothing about the new shapes. | ||
| 44 | +- `crates/ec-av1/src/refusal_inventory.rs` — the square-only line removed. | ||
| 45 | +- `crates/ec-av1/src/decode.rs` tests — `filter_intra_classes_carry_their_own_libaom_default_row` | ||
| 46 | + enumerates every shape inside `av1_filter_intra_allowed_bsize` against | ||
| 47 | + `default_filter_intra_cdfs` row by row and pins the shapes still without a class | ||
| 48 | + (4x8/8x4/4x16/16x4/8x32/32x8 — their partition levels refuse first). | ||
| 49 | +- `crates/ec-av1/src/stream.rs` — `a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag` | ||
| 50 | + (green) plus the pixel gate | ||
| 51 | + `a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact` | ||
| 52 | + (`#[ignore]`d with its measurement, see below). | ||
| 53 | +- `crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu` — the pinned stream | ||
| 54 | + (md5 `ac3a64773e5454ee9b5d8650507063cd`, hashed twice from the same recipe; `.gitignore` | ||
| 55 | + ignores `fixtures`, so it is committed with `git add -f`). | ||
| 56 | + | ||
| 57 | +## Gate status — honest | ||
| 58 | + | ||
| 59 | +The charter's gate (`..._on_a_rect_strip_decodes_pixel_exact`) is written and **cannot be | ||
| 60 | +green on this tree**, so it ships `#[ignore]`d carrying its measurement rather than | ||
| 61 | +weakened: over **200 aomenc streams** (seeds 42..241, cq 25, `--min-partition-size=8 | ||
| 62 | +--max-partition-size=32 --enable-filter-intra=1`) aomenc put filter intra on an 8x16/16x8 | ||
| 63 | +strip exactly **twice**, and **both** strips were `skip=0`, which | ||
| 64 | +`decode_leaf_rect` still refuses ("a coded (non-skip) HORZ/VERT rect strip below 16x16"). | ||
| 65 | +Sweeps that found nothing better: cq {15,20,25,30,34,40,45,55}; content | ||
| 66 | +{gradients, testsrc2, smptebars-style, geq noise}; intra-tool subsets | ||
| 67 | +{none, smooth+paeth off, smooth+paeth+dir+angle off} — the last kills filter intra | ||
| 68 | +entirely. Flag-arrival note (coordinator correction, aomenc keeps the LAST repeated | ||
| 69 | +`--enable-*`): this gate spells every flag once and appends the `EC_FISTRIP_OFF` | ||
| 70 | +diagnosis overrides AFTER the base recipe, and arrival of `--enable-filter-intra=1` is | ||
| 71 | +proven decoder-side by the counters, not by the command line. | ||
| 72 | + | ||
| 73 | +10-bit arm (`a_real_aomenc_10bit_filter_intra_on_a_sub16_strip_decodes_pixel_exact`, | ||
| 74 | +`ten_bit_tool_gate`, seeds 42..61, same recipe): **16/20 attempts decode pixel-exact at | ||
| 75 | +10 bits** with the new CDF rows in place (no regression), and the same seed 49 refuses at | ||
| 76 | +the coded-strip ceiling -- `filter_intra_rect_sub16_hits` never reaches a compare, so this | ||
| 77 | +arm is `#[ignore]`d with its measurement too. | ||
| 78 | + | ||
| 79 | +What IS proven, green, and pinned: the symbol read. On the pinned stream aomdec's own | ||
| 80 | +`EC_TRACE_MODE` shows four `BLOCK_16X8` (`bsize=5`) DC_PRED leaves; our decoder now reads | ||
| 81 | +`use_filter_intra` on them, fires the counter once, and stops at the coded-strip ceiling | ||
| 82 | +ON that block. Before the fix the same stream refused with a DIFFERENT string — "a | ||
| 83 | +HORZ/VERT intra strip below 16x16 with a split transform" — a `tx_depth` read out of an | ||
| 84 | +already-desynced stream, which is the desync this round removes. | ||
| 85 | + | ||
| 86 | +EVIDENCE: `crates/ec-av1/fixtures/filter_intra_8x16_strip_seed49.obu` | pre-fix release | ||
| 87 | +`decode_probe` on main df5d630 vs post-fix `cargo test -p ec-av1 --lib | ||
| 88 | +a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag` | refusal string moves | ||
| 89 | +"split transform" -> "coded (non-skip) rect strip below 16x16", | ||
| 90 | +`filter_intra_rect_sub16_hits` delta 0 -> 1 | ||
| 91 | +EVIDENCE: oracle `EC_TRACE_MODE=1 aomdec` on that fixture | grep `bsize=` | 4x BLOCK_16X8 | ||
| 92 | +DC_PRED leaves (`skip=0`), 6x 16x16, 4x 32x16-class, 20x 32x32 | ||
| 93 | + | ||
| 94 | +## Residue | ||
| 95 | + | ||
| 96 | +- deferred: pixel-exact gate for filter intra on 8x16/16x8 — blocked on the "coded | ||
| 97 | + (non-skip) HORZ/VERT rect strip below 16x16" refusal (needs TX_16X8/TX_8X16 luma plus | ||
| 98 | + 8x4/4x8 chroma coefficient tables) — un-ignore the gate the round that lands. | ||
| 99 | +- deferred: the 10-bit pixel arm rides the same ceiling as the 8-bit one. | ||
| 100 | +- deferred: 8x32/32x8 (HORZ_4/VERT_4) and 4x8/8x4 (sub-8x8) filter-intra classes — their | ||
| 101 | + partition levels refuse before the mode read; the domain test pins them as absent. | ||
| 102 | +- accepted: the capability claim "filter intra on a superblock-level HORZ/VERT strip | ||
| 103 | + (never expected -- av1_filter_intra_allowed_bsize caps at 32x32)" stays; 64x32/32x64 | ||
| 104 | + are past the <=32 bound on one axis, verified in the same domain test. | ||
| 105 | + | ||
| 106 | +## Film probes after the fix (release `decode_probe`, this branch) | ||
| 107 | + | ||
| 108 | +- `hghead.obu`: `a partition below 8x8 (this decoder codes no leaf smaller than 8x8)` (unchanged) | ||
| 109 | +- `reelb5.obu`: `a superblock-level HORZ/VERT strip with a split transform (per-unit rect | ||
| 110 | + prediction is not ported)` (unchanged) | ||
| 111 | + | ||
| 112 | +Both films stop before any 8x16/16x8 filter-intra strip, so this lane moves neither | ||
| 113 | +frontier; it removes a silent desync that would have bitten once those two lift. | ||
| 114 | + | ||
| 115 | +## Suite totals | ||
| 116 | + | ||
| 117 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib` (log `$HOME/.cache/fistrip-suite.log`, | ||
| 118 | +826 s): **300 passed, 1 failed, 29 ignored**. | ||
| 119 | + | ||
| 120 | +The one failure is PRE-EXISTING on main `df5d630` and not this lane's: | ||
| 121 | +`decode::tests::nz_map_ctx_offset_tables_match_the_rect_rule` — "32x64 nz_map offset at | ||
| 122 | +display (row 0, col 2): left 6, right 11", the known rectsplit-r4 `table[col][row]` vs | ||
| 123 | +`[row][col]` convention clash already in the ledger. This lane touched neither | ||
| 124 | +`NZ_MAP_CTX_OFFSET_*` nor `base_ctx_rect`. | ||
| 125 | + | ||
| 126 | +New/changed tests, all green: `filter_intra_classes_carry_their_own_libaom_default_row`, | ||
| 127 | +`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag`; the two pixel arms are among | ||
| 128 | +the 29 ignored, each carrying its measurement in its doc. | ||
lanes/fistrip-r2.report.mdadded+116 -0
| @@ -0,0 +1,116 @@ | |||
| 1 | +# lane-fistrip r2 — verifier fix-now items | ||
| 2 | + | ||
| 3 | +Round 1 (57f1fcb) landed the defect fix (8x16/16x8 strips never read their | ||
| 4 | +`use_filter_intra` flag). This round closes the four fix-now items the verifier | ||
| 5 | +raised against it. No decode-path behaviour changed: every edit is a test, a | ||
| 6 | +generator script, or a gate's seed window. | ||
| 7 | + | ||
| 8 | +## 1. The filter-intra CDF row table is generated from the oracle, and pins every allowed shape | ||
| 9 | + | ||
| 10 | +`scripts/extract-filter-intra-cdfs.py` (new) reads `BLOCK_SIZES_ALL`'s order from | ||
| 11 | +`av1/common/enums.h` and `default_filter_intra_cdfs` from `av1/common/entropymode.c` | ||
| 12 | +in the oracle tree and prints the `(width, height, default)` rows for the shapes | ||
| 13 | +`av1_filter_intra_allowed_bsize` allows. r1 had guessed 16384 for the four 1:4 | ||
| 14 | +shapes; their real rows are **4x16=12770, 16x4=10368, 8x32=20229, 32x8=18101** | ||
| 15 | +(entropymode.c:827-828, BLOCK_SIZES_ALL indices 16..19). | ||
| 16 | + | ||
| 17 | +`decode.rs` `filter_intra_classes_carry_their_own_libaom_default_row` now lists all | ||
| 18 | +14 allowed shapes with their true row plus a `refused_by` note for the six with no | ||
| 19 | +class today (4x8/8x4 → "a partition below 8x8 …"; 4x16/16x4 → the 16x16-level | ||
| 20 | +partition refusal; 8x32/32x8 → "a 32x32 partition type this decoder does not code"), | ||
| 21 | +and asserts, per shape: the class's row equals the oracle default, the row is a real | ||
| 22 | +2-symbol CDF (`{p, 32768, 0}`), no two shapes share a class, and every one of | ||
| 23 | +`cdf::FILTER_INTRA`'s 8 rows is claimed by exactly one shape. So the round that | ||
| 24 | +lifts one of those refusals cannot land a wrong CDF row for the shape it unlocks. | ||
| 25 | + | ||
| 26 | +## 2. `predict_filter_intra` now has a bit-exact unit test | ||
| 27 | + | ||
| 28 | +`intra.rs` `filter_intra_matches_the_libaom_predictor_for_every_mode_and_shape`: | ||
| 29 | +`av1_filter_intra_taps` and `av1_filter_intra_predictor_c` / | ||
| 30 | +`highbd_filter_intra_predictor` (reconintra.c:807-955) are transcribed into the test | ||
| 31 | +module from the C, independently of `FILTER_INTRA_TAPS`, and compared against | ||
| 32 | +`predict_filter_intra` for **5 modes x 14 shapes (4x4 … 32x32, both orientations of | ||
| 33 | +1:2 and 1:4) x 3 seeded random edge sets x {8-bit, 10-bit} = 420 blocks**, whole | ||
| 34 | +block, bit-exact. Before this round the predictor had no unit test at all. | ||
| 35 | + | ||
| 36 | +## 3. Both firing seeds are inside the ignored gate's default window | ||
| 37 | + | ||
| 38 | +r1 recorded only the first firing seed (49) of its 200-seed measurement. r2 re-ran | ||
| 39 | +just the missing window (seeds 50..=241, `EC_FISTRIP_GATE_SEED0=50 | ||
| 40 | +EC_FISTRIP_GATE_ATTEMPTS=192`, 31 s): **172 pixel-exact matches, 20 named refusals, | ||
| 41 | +exactly one attempt with a sub16 filter-intra delta -- seed 213**, refusing at | ||
| 42 | +"a coded (non-skip) HORZ/VERT rect strip below 16x16". So over seeds 42..=241 the | ||
| 43 | +firing set is exactly {49, 213}, both `skip=0`. | ||
| 44 | + | ||
| 45 | +The 8-bit gate now builds its seed list as `(0..n_attempts).map(|a| 42 + a)` plus | ||
| 46 | +`FIRING_SEEDS = [49, 213]` (appended when the window misses them), so the default | ||
| 47 | +40-attempt run -- and even a 2-attempt one -- carries both hits; the doc and the | ||
| 48 | +`#[ignore]` string both name them. The 10-bit arm gets seed 213 appended too, marked | ||
| 49 | +in its doc as a widening from the 8-bit recipe's measurement, NOT a measured 10-bit | ||
| 50 | +firing set (its encode is a different stream; the round that un-ignores it must | ||
| 51 | +re-measure). The temporary `EC_FISTRIP_GATE_SEED0` knob used for the scan was removed | ||
| 52 | +again -- the seeds are in the source, not in an env var. | ||
| 53 | + | ||
| 54 | +## 4. MERGE NOTE | ||
| 55 | + | ||
| 56 | +`a_pinned_aomenc_16x8_strip_reads_its_use_filter_intra_flag` (stream.rs) asserts | ||
| 57 | +`decode_stream(...).expect_err(...)` on the refusal | ||
| 58 | +"a coded (non-skip) HORZ/VERT rect strip below 16x16". **The round that lifts that | ||
| 59 | +refusal MUST flip this test from `expect_err` to a full pixel compare against ffmpeg** | ||
| 60 | +(the fixture's strip is `skip=0`, so it becomes decodable the moment the ceiling | ||
| 61 | +moves) and un-ignore | ||
| 62 | +`a_real_aomenc_stream_with_filter_intra_on_a_sub16_horz_vert_strip_decodes_pixel_exact` | ||
| 63 | +plus its 10-bit twin. A green `expect_err` after that lift is a stale refusal claim, | ||
| 64 | +not a pass. | ||
| 65 | + | ||
| 66 | +## Files changed | ||
| 67 | + | ||
| 68 | +- `scripts/extract-filter-intra-cdfs.py` (new) — generates the `default_filter_intra_cdfs` | ||
| 69 | + rows from the oracle tree; no hand transcription. | ||
| 70 | +- `crates/ec-av1/src/decode.rs:16315` — the domain test now pins all 14 allowed shapes | ||
| 71 | + (true rows for the six refused ones) + row shape + class uniqueness + full table coverage. | ||
| 72 | +- `crates/ec-av1/src/intra.rs` (tests) — independent C port of | ||
| 73 | + `av1_filter_intra_taps`/`av1_filter_intra_predictor_c` and the 420-block bit-exact compare. | ||
| 74 | +- `crates/ec-av1/src/stream.rs` — 8-bit sub16 gate: seed window + `FIRING_SEEDS = [49, 213]`, | ||
| 75 | + doc and `#[ignore]` string record both firing seeds; 10-bit arm: seed 213 appended with | ||
| 76 | + its "widening, not measured" note. | ||
| 77 | + | ||
| 78 | +## EVIDENCE | ||
| 79 | + | ||
| 80 | +EVIDENCE: `scripts/extract-filter-intra-cdfs.py` output | run against `~/.cache/aom-oracle/src` | | ||
| 81 | +14 rows, 1:4 shapes = 12770/10368/20229/18101 (r1 had 16384 for all four) | ||
| 82 | + | ||
| 83 | +EVIDENCE: `cargo test -p ec-av1 --lib filter_intra` | 5 passed, 0 failed, 2 ignored (14.9 s) | | ||
| 84 | +`filter_intra_matches_the_libaom_predictor_for_every_mode_and_shape` compares 420 blocks | ||
| 85 | +(2 depths x 14 shapes x 5 modes x 3 seeds), all bit-exact; the test asserts that count | ||
| 86 | + | ||
| 87 | +EVIDENCE: `$HOME/.cache/fistrip-seedscan-r2.log` | `EC_FISTRIP_GATE_SEED0=50 | ||
| 88 | +EC_FISTRIP_GATE_ATTEMPTS=192` on the ignored 8-bit gate | 172 matches, 20 refusals, one | ||
| 89 | +sub16 delta: "seed 213 refused with sub16 filter-intra delta 1" | ||
| 90 | + | ||
| 91 | +EVIDENCE: `EC_FISTRIP_GATE_ATTEMPTS=2 ... -- --ignored --nocapture` | default window of 2 | ||
| 92 | +attempts + FIRING_SEEDS | "seed 49 ... delta 1", "seed 213 ... delta 1", | ||
| 93 | +"filter_intra_rect_sub16_hits over ALL attempts (refused included) = 2"; the gate still | ||
| 94 | +fails its `compared_hits > 0` assert, which is exactly the ceiling it is ignored for | ||
| 95 | + | ||
| 96 | +## Residue | ||
| 97 | + | ||
| 98 | +- deferred: the pixel gates (8- and 10-bit) stay `#[ignore]`d — blocked on | ||
| 99 | + "a coded (non-skip) HORZ/VERT rect strip below 16x16"; un-ignore + flip the pinned | ||
| 100 | + test's `expect_err` (MERGE NOTE above) the round that lifts it. | ||
| 101 | +- deferred: 10-bit firing seeds are unmeasured — the 10-bit encode is a different stream; | ||
| 102 | + measure when that gate un-ignores. | ||
| 103 | +- accepted: `predict_filter_intra` is now proven on all 14 shapes including the four 1:4 | ||
| 104 | + ones whose partition levels refuse — prediction ahead of reach, deliberately. | ||
| 105 | + | ||
| 106 | +## Suite totals | ||
| 107 | + | ||
| 108 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib` under `systemd-run --user` | ||
| 109 | +(log `$HOME/.cache/fistrip-suite-r2.log`, 257 s): **301 passed, 1 failed, 29 ignored** | ||
| 110 | +(r1: 300/1/29 — the new predictor test is the +1). | ||
| 111 | + | ||
| 112 | +The single failure is the PRE-EXISTING one already red on main `df5d630`: | ||
| 113 | +`decode::tests::nz_map_ctx_offset_tables_match_the_rect_rule` (32x64 nz_map offset at | ||
| 114 | +display row 0 col 2), the rectsplit-r4 `[col][row]` convention clash. This round touched | ||
| 115 | +neither `NZ_MAP_CTX_OFFSET_*` nor `base_ctx_rect`. | ||
| 116 | +`refusal_inventory` (3 passed) and `gate_coverage` (9 passed) both green. | ||
scripts/extract-filter-intra-cdfs.pyadded+30 -0
| @@ -0,0 +1,30 @@ | |||
| 1 | +#!/usr/bin/env python3 | ||
| 2 | +"""Emit `default_filter_intra_cdfs` as (width, height, default) straight from | ||
| 3 | +the libaom oracle source, so the ec-av1 test that pins those rows is never | ||
| 4 | +transcribed by hand (class: shared-oracle blindness / table-indexed-by-raw). | ||
| 5 | + | ||
| 6 | +Reads BLOCK_SIZES_ALL's order from av1/common/enums.h and the CDF table from | ||
| 7 | +av1/common/entropymode.c, and prints the Rust literal rows for the shapes | ||
| 8 | +`av1_filter_intra_allowed_bsize` allows (both sides <= 32). | ||
| 9 | + | ||
| 10 | + scripts/extract-filter-intra-cdfs.py [<aom source tree>] | ||
| 11 | +""" | ||
| 12 | +import re | ||
| 13 | +import sys | ||
| 14 | +from pathlib import Path | ||
| 15 | + | ||
| 16 | +src = Path(sys.argv[1] if len(sys.argv) > 1 else Path.home() / ".cache/aom-oracle/src") | ||
| 17 | + | ||
| 18 | +enums = (src / "av1/common/enums.h").read_text() | ||
| 19 | +body = enums[enums.index(" BLOCK_4X4,"):enums.index(" BLOCK_SIZES_ALL,")] | ||
| 20 | +sizes = [tuple(int(x) for x in m) for m in re.findall(r"BLOCK_(\d+)X(\d+),", body)] | ||
| 21 | + | ||
| 22 | +ent = (src / "av1/common/entropymode.c").read_text() | ||
| 23 | +start = ent.index("default_filter_intra_cdfs") | ||
| 24 | +table = ent[start:ent.index("};", start)] | ||
| 25 | +values = [int(v) for v in re.findall(r"AOM_CDF2\((\d+)\)", table)] | ||
| 26 | + | ||
| 27 | +assert len(values) == len(sizes), f"{len(values)} rows vs {len(sizes)} block sizes" | ||
| 28 | +for (w, h), v in zip(sizes, values): | ||
| 29 | + if w <= 32 and h <= 32: | ||
| 30 | + print(f" ({w}, {h}, {v}),") | ||