Merge main (3566501) into lane-kf900
Browse files at this commit42 changed files +6756 -465
- crates/ec-av1/examples/decode_probe.rs +14 -0
- crates/ec-av1/fixtures/reelb_ss300_key_frame.obu +0 -0
- crates/ec-av1/fixtures/reelb_ss600_key_frame.obu +0 -0
- crates/ec-av1/src/decode.rs +1438 -306
- crates/ec-av1/src/gate_coverage.rs +0 -5
- crates/ec-av1/src/mc.rs +117 -5
- crates/ec-av1/src/motion_field.rs +9 -0
- crates/ec-av1/src/refusal_inventory.rs +9 -5
- crates/ec-av1/src/stream.rs +1999 -144
- lanes/cdef-r1.handoff.md +66 -0
- lanes/cdef-r2.report.md +83 -0
- lanes/golomb-r1.report.md +68 -0
- lanes/golomb-r3.report.md +106 -0
- lanes/golomb-r4.report.md +93 -0
- lanes/golomb-r5.report.md +109 -0
- lanes/golomb-r6.handoff.md +118 -0
- lanes/golomb-r7.handoff.md +99 -0
- lanes/golomb-r7.report.md +96 -0
- lanes/golomb-r8.handoff.md +50 -0
- lanes/golomb-r8.report.md +102 -0
- lanes/golomb-r9.report.md +100 -0
- lanes/inter16ab-r1.report.md +74 -0
- lanes/interedge-r1.report.md +100 -0
- lanes/interp3-r1.report.md +96 -0
- lanes/interp3-r2.handoff.md +48 -0
- lanes/interp3-r2.report.md +88 -0
- lanes/interp3-r3.handoff.md +88 -0
- lanes/interp3-r3.report.md +106 -0
- lanes/kf1200-r1.report.md +106 -0
- lanes/kf1200-r2.handoff.md +72 -0
- lanes/kf1200-r2.report.md +183 -0
- lanes/kf1200-r3.report.md +130 -0
- lanes/r14-r3.report.md +104 -0
- lanes/r14-r4.report.md +87 -0
- lanes/rectchroma2-r1.report.md +87 -0
- lanes/sbrect10-r1.handoff.md +81 -0
- lanes/sbrect10-r2.handoff.md +175 -0
- lanes/sbrect10-r2.report.md +124 -0
- lanes/sbrect10-r3.report.md +98 -0
- lanes/sqdrift-r1.handoff.md +40 -0
- lanes/sqdrift-r1.report.md +100 -0
- lanes/sqdrift-r2.report.md +93 -0
crates/ec-av1/examples/decode_probe.rsmodified+14 -0
| @@ -36,10 +36,24 @@ fn main() { | ||
| 36 | 36 | println!("rect_intrabc_reads: {}", ec_av1::stream::rect_intrabc_reads()); |
| 37 | 37 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); |
| 38 | 38 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); |
| 39 | + let leaf = ec_av1::stream::vartx_rect_leaf_hits(); | |
| 40 | + println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]); | |
| 41 | + // lane-inter16ab r1: the 16x16-level inter AB arms, so a recipe sweep | |
| 42 | + // can tell "aomenc never picked one" from "it did and we decoded it". | |
| 43 | + let ab = ec_av1::decode::ab16_inter_hits_by_arm(); | |
| 44 | + println!( | |
| 45 | + "inter_ab16: horz_a={} horz_b={} vert_a={} vert_b={}", | |
| 46 | + ab[0], ab[1], ab[2], ab[3] | |
| 47 | + ); | |
| 39 | 48 | // lane-kf900 r1: the counter the skipped-8x8-split-transform gate |
| 40 | 49 | // asserts -- printed here so a recipe sweep can see it fire without a |
| 41 | 50 | // test-binary rebuild. |
| 42 | 51 | println!("skip_split_tx: {}", ec_av1::decode::skip_split_tx_hits()); |
| 52 | + let es = ec_av1::decode::inter_edge_strip_hits(); | |
| 53 | + println!( | |
| 54 | + "inter_edge_strip: h64={} v64={} h32={} v32={} h16={} v16={}", | |
| 55 | + es[0], es[1], es[2], es[3], es[4], es[5] | |
| 56 | + ); | |
| 43 | 57 | let ir = ec_av1::stream::inter_rect_counters(); |
| 44 | 58 | println!( |
| 45 | 59 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", |
crates/ec-av1/fixtures/reelb_ss300_key_frame.obuadded+0 -0
Binary file changed
crates/ec-av1/fixtures/reelb_ss600_key_frame.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+1438 -306
Diff too large; view file
| @@ -997,6 +997,8 @@ thread_local! { | ||
| 997 | 997 | // (64x32/32x64/64x16/16x64), whose coefficients are coded as the |
| 998 | 998 | // truncated low-32 corner. |
| 999 | 999 | static RECT64_INTER_TU_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 1000 | + // lane-r14 r3: rectangular var-tx LEAVES, [32x16, 16x32]. | |
| 1001 | + static VARTX_RECT_LEAF_HITS: std::cell::Cell<[usize; 2]> = const { std::cell::Cell::new([0; 2]) }; | |
| 1000 | 1002 | // lane-inter4 r3: 16x16-level PARTITION_HORZ / PARTITION_VERT on an inter |
| 1001 | 1003 | // frame -- 16x8 and 8x16 inter leaves. |
| 1002 | 1004 | static INTER_LEAF16_HORZ_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| @@ -1049,6 +1051,21 @@ pub(crate) fn rect64_inter_tu_hits() -> usize { | ||
| 1049 | 1051 | RECT64_INTER_TU_HITS.with(|c| c.get()) |
| 1050 | 1052 | } |
| 1051 | 1053 | |
| 1054 | +/// Current value of [`VARTX_RECT_LEAF_HITS`] (lane-r14 r3): how many | |
| 1055 | +/// rectangular var-tx leaf transform units were coded, `[32x16, 16x32]`. | |
| 1056 | +pub(crate) fn vartx_rect_leaf_hits() -> [usize; 2] { | |
| 1057 | + VARTX_RECT_LEAF_HITS.with(|c| c.get()) | |
| 1058 | +} | |
| 1059 | + | |
| 1060 | +/// Records one rectangular var-tx leaf. | |
| 1061 | +fn vartx_rect_leaf_hit(tw: usize, th: usize) { | |
| 1062 | + VARTX_RECT_LEAF_HITS.with(|c| { | |
| 1063 | + let mut h = c.get(); | |
| 1064 | + h[usize::from(th > tw)] += 1; | |
| 1065 | + c.set(h); | |
| 1066 | + }); | |
| 1067 | +} | |
| 1068 | + | |
| 1052 | 1069 | /// Sets the current thread's [`TX_SELECT_INTER`]/[`REDUCED_TX_SET_INTER`]/ |
| 1053 | 1070 | /// [`ENABLE_FILTER_INTRA_INTER`]. |
| 1054 | 1071 | pub(crate) fn set_inter_tx_mode( |
| @@ -1145,6 +1162,36 @@ pub(crate) fn edge_rect_strip_hits() -> usize { | ||
| 1145 | 1162 | EDGE_RECT_STRIP_HITS.with(|c| c.get()) |
| 1146 | 1163 | } |
| 1147 | 1164 | |
| 1165 | +// lane-interedge r1: frame-edge half strips on the INTER path, per partition | |
| 1166 | +// level (64/32/16) x axis (HORZ at a bottom edge, VERT at a right edge). The | |
| 1167 | +// index is `level_idx * 2 + axis` with `level_idx` 0=64, 1=32, 2=16 and | |
| 1168 | +// `axis` 0=HORZ (`!has_rows`), 1=VERT (`!has_cols`). Both of the user's films | |
| 1169 | +// are height mod 16 == 8, so every inter frame crosses these nodes. | |
| 1170 | +thread_local! { | |
| 1171 | + static INTER_EDGE_STRIP_HITS: std::cell::Cell<[usize; 6]> = | |
| 1172 | + const { std::cell::Cell::new([0; 6]) }; | |
| 1173 | +} | |
| 1174 | + | |
| 1175 | +/// Bumps one bucket of [`INTER_EDGE_STRIP_HITS`]. | |
| 1176 | +pub(crate) fn bump_inter_edge_strip(idx: usize) { | |
| 1177 | + INTER_EDGE_STRIP_HITS.with(|c| { | |
| 1178 | + let mut v = c.get(); | |
| 1179 | + v[idx] += 1; | |
| 1180 | + c.set(v); | |
| 1181 | + }); | |
| 1182 | +} | |
| 1183 | + | |
| 1184 | +/// Current value of [`INTER_EDGE_STRIP_HITS`] (`[h64, v64, h32, v32, h16, v16]`). | |
| 1185 | +pub fn inter_edge_strip_hits() -> [usize; 6] { | |
| 1186 | + INTER_EDGE_STRIP_HITS.with(|c| c.get()) | |
| 1187 | +} | |
| 1188 | + | |
| 1189 | +/// Resets [`INTER_EDGE_STRIP_HITS`] -- a refused attempt must not carry hits | |
| 1190 | +/// into the next one (class `counter-from-refused-stream`). | |
| 1191 | +pub fn reset_inter_edge_strip_hits() { | |
| 1192 | + INTER_EDGE_STRIP_HITS.with(|c| c.set([0; 6])); | |
| 1193 | +} | |
| 1194 | + | |
| 1148 | 1195 | // How many HORZ/VERT intra strips resolved a SPLIT luma transform |
| 1149 | 1196 | // (`tx_depth != 0`) and decoded it per transform unit (lane-rectsplit r1) -- |
| 1150 | 1197 | // the case every rect path here refused by name before, and the first |
| @@ -1777,6 +1824,32 @@ thread_local! { | ||
| 1777 | 1824 | static OBMC_HITS_8: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 1778 | 1825 | } |
| 1779 | 1826 | |
| 1827 | +// lane-interp3 r1: how many inter blocks read a SWITCHABLE `interp_filter` | |
| 1828 | +// pair whose two directions differ (`enable_dual_filter` only -- with dual | |
| 1829 | +// filter off both directions take the single symbol, so this can never fire). | |
| 1830 | +// A gate asserting it proves the stream really carries dual-filter blocks. | |
| 1831 | +thread_local! { | |
| 1832 | + static DUAL_FILTER_DIFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1833 | +} | |
| 1834 | + | |
| 1835 | +// lane-interp3 r1: how many COMPOUND 8x8 leaves read their own | |
| 1836 | +// `read_mb_interp_filter` symbol(s) -- the read this round added (the leaf | |
| 1837 | +// used to skip it entirely, losing a symbol and stamping the `[3, 3]` | |
| 1838 | +// no-filter sentinel that made a neighbouring OBMC block panic). | |
| 1839 | +thread_local! { | |
| 1840 | + static COMPOUND8_FILTER_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1841 | +} | |
| 1842 | + | |
| 1843 | +/// Current value of [`DUAL_FILTER_DIFF_HITS`]. | |
| 1844 | +pub(crate) fn dual_filter_diff_hits() -> usize { | |
| 1845 | + DUAL_FILTER_DIFF_HITS.with(|c| c.get()) | |
| 1846 | +} | |
| 1847 | + | |
| 1848 | +/// Current value of [`COMPOUND8_FILTER_HITS`]. | |
| 1849 | +pub(crate) fn compound8_filter_hits() -> usize { | |
| 1850 | + COMPOUND8_FILTER_HITS.with(|c| c.get()) | |
| 1851 | +} | |
| 1852 | + | |
| 1780 | 1853 | // lane-warp round 1: how many blocks resolved `motion_mode_allowed` to |
| 1781 | 1854 | // `WARPED_CAUSAL`-eligible (3-symbol read, `num_proj_ref >= 1` under |
| 1782 | 1855 | // `allow_warped_motion`) AND the symbol actually decoded to `WARPED_CAUSAL` |
| @@ -1808,6 +1881,20 @@ pub(crate) fn compound_warp_hits() -> usize { | ||
| 1808 | 1881 | COMPOUND_WARP_HITS.with(|c| c.get()) |
| 1809 | 1882 | } |
| 1810 | 1883 | |
| 1884 | +// lane-interp3 r3: the same proof narrowed to the 8x8 LEAF's own compound | |
| 1885 | +// arm ([`decode_inter_block8`]) -- that arm predicted both taps | |
| 1886 | +// translationally until r3, so a gate needs to tell a warped 8x8 compound | |
| 1887 | +// leaf apart from a warped 16x16+ one (both bump [`COMPOUND_WARP_HITS`]). | |
| 1888 | +thread_local! { | |
| 1889 | + static COMPOUND_WARP_HITS_8: std::cell::Cell<usize> = | |
| 1890 | + const { std::cell::Cell::new(0) }; | |
| 1891 | +} | |
| 1892 | + | |
| 1893 | +/// Current value of [`COMPOUND_WARP_HITS_8`]. | |
| 1894 | +pub(crate) fn compound_warp_hits_8() -> usize { | |
| 1895 | + COMPOUND_WARP_HITS_8.with(|c| c.get()) | |
| 1896 | +} | |
| 1897 | + | |
| 1811 | 1898 | // lane-gmaffine r1: how many blocks built their prediction from a |
| 1812 | 1899 | // SIX-parameter (`AFFINE`) global-motion model through |
| 1813 | 1900 | // `crate::warp::global_warp_params` -- the gate's proof that a stream really |
| @@ -1900,6 +1987,20 @@ pub(crate) fn wii_hits() -> usize { | ||
| 1900 | 1987 | WII_HITS.with(|c| c.get()) |
| 1901 | 1988 | } |
| 1902 | 1989 | |
| 1990 | +// lane-sbrect10 r1: how many INTRA blocks read `uv_mode` off the 13-symbol | |
| 1991 | +// NO-CFL alphabet *because their size excludes CFL* (libaom `is_cfl_allowed`: | |
| 1992 | +// wide <= 32 && high <= 32). The witness that a gate stream really carries a | |
| 1993 | +// 64-axis intra block -- the shape whose 14-symbol read desynced every inter | |
| 1994 | +// frame carrying one. | |
| 1995 | +thread_local! { | |
| 1996 | + static NOCFL_UV_MODE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 1997 | +} | |
| 1998 | + | |
| 1999 | +/// Current value of [`NOCFL_UV_MODE_HITS`]. | |
| 2000 | +pub(crate) fn nocfl_uv_mode_hits() -> usize { | |
| 2001 | + NOCFL_UV_MODE_HITS.with(|c| c.get()) | |
| 2002 | +} | |
| 2003 | + | |
| 1903 | 2004 | // lane-inter4 r4: how many 16x8/8x16 INTER LEAVES actually ran the OBMC |
| 1904 | 2005 | // blend -- the gate's proof that `--enable-obmc=1` reached this shape (the |
| 1905 | 2006 | // r3 refusal's replacement: prefilt frames are bit-exact vs an instrumented |
| @@ -2141,6 +2242,44 @@ pub(crate) fn sb_rect_hits() -> usize { | ||
| 2141 | 2242 | SB_RECT_HITS.with(|c| c.get()) |
| 2142 | 2243 | } |
| 2143 | 2244 | |
| 2245 | +// lane-golomb r2: the 32x32-level FRAME-EDGE partition. Slot 0/1 = the | |
| 2246 | +// gathered edge bit read as 0 (HORZ/VERT) / 1 (SPLIT); slot 2 = a 32-level | |
| 2247 | +// PARTITION_HORZ decoded with `has_rows32 == false` (only the top 32x16 half | |
| 2248 | +// is coded), slot 3 = a PARTITION_VERT with `has_cols32 == false`. Both tile | |
| 2249 | +// paths (intra and inter) feed the same counter. | |
| 2250 | +// | |
| 2251 | +// lane-golomb r3: slots 4..7 are the same four facts one level up, at the | |
| 2252 | +// SUPERBLOCK (64x64) edge -- 4/5 = the gathered 64-level bit read as | |
| 2253 | +// HORZ/VERT / SPLIT, 6 = a 64x32 bottom-edge strip decoded with | |
| 2254 | +// `has_rows == false`, 7 = a 32x64 right-edge strip. Real aomenc answers a | |
| 2255 | +// bottom-edge superblock with the 64-level HORZ (measured: 192x80 flat-band, | |
| 2256 | +// every SB of the last row), so the 32-level slots stay 0 on that content and | |
| 2257 | +// only these prove the arm fired. | |
| 2258 | +thread_local! { | |
| 2259 | + static EDGE32_HITS: std::cell::Cell<[usize; 8]> = | |
| 2260 | + const { std::cell::Cell::new([0; 8]) }; | |
| 2261 | +} | |
| 2262 | + | |
| 2263 | +/// Current value of [`EDGE32_HITS`]. | |
| 2264 | +pub(crate) fn edge32_hits() -> [usize; 8] { | |
| 2265 | + EDGE32_HITS.with(|c| c.get()) | |
| 2266 | +} | |
| 2267 | + | |
| 2268 | +/// [`bump_edge32`] of `base + bit`, returning the bit -- the gathered edge | |
| 2269 | +/// reads are `if`-conditions, so the counter has to ride the expression. | |
| 2270 | +fn bump_edge32_bit(base: usize, bit: usize) -> usize { | |
| 2271 | + bump_edge32(base + bit.min(1)); | |
| 2272 | + bit | |
| 2273 | +} | |
| 2274 | + | |
| 2275 | +fn bump_edge32(slot: usize) { | |
| 2276 | + EDGE32_HITS.with(|c| { | |
| 2277 | + let mut h = c.get(); | |
| 2278 | + h[slot] += 1; | |
| 2279 | + c.set(h) | |
| 2280 | + }); | |
| 2281 | +} | |
| 2282 | + | |
| 2144 | 2283 | // lane-part32 r4: how many superblock-level AB blocks (`PARTITION_HORZ_A`/ |
| 2145 | 2284 | // `_B`/`VERT_A`/`_B` at 64x64 -- two 32x32 squares plus one 64x32/32x64 |
| 2146 | 2285 | // strip) fired. Real aomenc picks these at 64 even with |
| @@ -2239,6 +2378,31 @@ pub(crate) fn rect4_coeff_hits() -> usize { | ||
| 2239 | 2378 | RECT4_COEFF_HITS.with(|c| c.get()) |
| 2240 | 2379 | } |
| 2241 | 2380 | |
| 2381 | +// lane-inter16ab r1: how many 16x16-level AB partitions fired IN AN INTER | |
| 2382 | +// frame, per arm, in `PARTITION_HORZ_A`, `_HORZ_B`, `_VERT_A`, `_VERT_B` | |
| 2383 | +// order (the intra-frame counterpart is `AB16_HITS`). Each arm is two 8x8 | |
| 2384 | +// inter leaves (`decode_inter_block8`) plus one true 16x8/8x16 inter strip | |
| 2385 | +// (`decode_inter_block` with `write_w`/`write_h`); the gate asserts every | |
| 2386 | +// arm separately so a run whose RD only picked one cannot pass as proof of | |
| 2387 | +// four. | |
| 2388 | +thread_local! { | |
| 2389 | + static AB16_INTER_HITS: std::cell::Cell<[usize; 4]> = const { std::cell::Cell::new([0; 4]) }; | |
| 2390 | +} | |
| 2391 | + | |
| 2392 | +/// [`AB16_INTER_HITS`] per arm (HORZ_A, HORZ_B, VERT_A, VERT_B at 16x16 in an | |
| 2393 | +/// inter frame). | |
| 2394 | +pub fn ab16_inter_hits_by_arm() -> [usize; 4] { | |
| 2395 | + AB16_INTER_HITS.with(std::cell::Cell::get) | |
| 2396 | +} | |
| 2397 | + | |
| 2398 | +fn bump_ab16_inter(arm: usize) { | |
| 2399 | + AB16_INTER_HITS.with(|c| { | |
| 2400 | + let mut v = c.get(); | |
| 2401 | + v[arm] += 1; | |
| 2402 | + c.set(v); | |
| 2403 | + }); | |
| 2404 | +} | |
| 2405 | + | |
| 2242 | 2406 | // lane-r14: the 16x16-level 1:4 pair -- four 16x4 (`PARTITION_HORZ_4`) or |
| 2243 | 2407 | // 4x16 (`PARTITION_VERT_4`) strips, `CHROMA` counting the odd strips that |
| 2244 | 2408 | // close a 4:2:0 chroma pair and `COEFF` the strips with a coded residual. |
| @@ -2248,6 +2412,26 @@ thread_local! { | ||
| 2248 | 2412 | static RECT4_16_CHROMA_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2249 | 2413 | static RECT4_16_COEFF_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2250 | 2414 | static RECT4_16_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2415 | + /// lane-kf1200: pairs whose chroma edge-filter type read from the PAIR's | |
| 2416 | + /// base mi differs from what the strip's own (odd) mi would have said -- | |
| 2417 | + /// the shape that made 4 chroma samples of the ReelB `-ss 1200` | |
| 2418 | + /// key frame miss by 1. Zero here means a gate never exercised the fix. | |
| 2419 | + static RECT4_16_UV_PAIR_FILT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 2420 | + /// lane-kf1200 r2: sub-8x8 chroma blocks that are `skip_txfm` AND | |
| 2421 | + /// `UV_CFL_PRED` -- the arm that used to drop the CfL alpha entirely. | |
| 2422 | + static SKIP_CFL_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 2423 | +} | |
| 2424 | + | |
| 2425 | +/// How many skipped sub-8x8 chroma blocks carried a CfL alpha (the shape | |
| 2426 | +/// that reconstructed as flat DC before lane-kf1200 r2). | |
| 2427 | +pub fn skip_cfl_hits() -> usize { | |
| 2428 | + SKIP_CFL_HITS.with(|c| c.get()) | |
| 2429 | +} | |
| 2430 | + | |
| 2431 | +/// How many 16x4/4x16 chroma pairs took a different `intra_edge_filter_type` | |
| 2432 | +/// from the pair's base mi than the strip's own mi would have given. | |
| 2433 | +pub fn rect4_16_uv_pair_filt_hits() -> usize { | |
| 2434 | + RECT4_16_UV_PAIR_FILT_HITS.with(|c| c.get()) | |
| 2251 | 2435 | } |
| 2252 | 2436 | |
| 2253 | 2437 | // lane-reelckf r1: the two chroma defects ReelC's key frames exposed -- |
| @@ -2574,6 +2758,41 @@ thread_local! { | ||
| 2574 | 2758 | static SUB8_SPLIT_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 2575 | 2759 | } |
| 2576 | 2760 | |
| 2761 | +// lane-cdef r1: (a) how many 8x8 CDEF units `apply_cdef` EXCLUDED because all | |
| 2762 | +// four of their mi cells are `skip_txfm` (libaom `cdef.c:29-38` | |
| 2763 | +// `is_8x8_block_skip` / `av1_cdef_compute_sb_list`'s dlist test), and (b) how | |
| 2764 | +// many 8x8 inter leaves (`decode_inter_block8`) wrote that skip band at all. | |
| 2765 | +// (b) was 0 for every stream before this round -- the leaf path never touched | |
| 2766 | +// the band, so an all-skip 8x8 group kept the PREVIOUS frame's flags and got | |
| 2767 | +// filtered where libaom skips it. A gate asserts both are non-zero. | |
| 2768 | +thread_local! { | |
| 2769 | + static CDEF_SKIPPED_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 2770 | + static INTER8_SKIP_BAND_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 2771 | + // lane-cdef r2: (c) 8x8 CDEF units that are FILTERED and whose extent | |
| 2772 | + // crosses the cropped frame edge -- the only units for which "clamp at | |
| 2773 | + // the crop" and "pad past the mi-rounded extent with CDEF_VERY_LARGE" | |
| 2774 | + // (libaom `cdef.c:249-256`, `cdef_prepare_fb`'s hsize/vsize are | |
| 2775 | + // `nhb << mi_wide_l2` off the MI grid, not the crop) differ. A frame | |
| 2776 | + // whose width or height is not a multiple of 8 is the only shape that | |
| 2777 | + // produces one; the straddling-band gate arms assert it grew. | |
| 2778 | + static CDEF_STRADDLE_UNITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 2779 | +} | |
| 2780 | + | |
| 2781 | +/// Current value of `CDEF_SKIPPED_UNITS`. | |
| 2782 | +pub(crate) fn cdef_skipped_units() -> usize { | |
| 2783 | + CDEF_SKIPPED_UNITS.with(|c| c.get()) | |
| 2784 | +} | |
| 2785 | + | |
| 2786 | +/// Current value of `INTER8_SKIP_BAND_HITS`. | |
| 2787 | +pub(crate) fn inter8_skip_band_hits() -> usize { | |
| 2788 | + INTER8_SKIP_BAND_HITS.with(|c| c.get()) | |
| 2789 | +} | |
| 2790 | + | |
| 2791 | +/// Current value of `CDEF_STRADDLE_UNITS`. | |
| 2792 | +pub(crate) fn cdef_straddle_units() -> usize { | |
| 2793 | + CDEF_STRADDLE_UNITS.with(|c| c.get()) | |
| 2794 | +} | |
| 2795 | + | |
| 2577 | 2796 | /// Current value of [`SUB8_SPLIT_HITS`]. |
| 2578 | 2797 | pub(crate) fn sub8_split_hits() -> usize { |
| 2579 | 2798 | SUB8_SPLIT_HITS.with(|c| c.get()) |
| @@ -2701,6 +2920,12 @@ const MAX_BR_LEVEL: i32 = NUM_BASE_LEVELS + COEFF_BASE_RANGE; | ||
| 2701 | 2920 | const VERT_ALIKE: [usize; 6] = [2, PARTITION_SPLIT, 4, 6, 7, 9]; |
| 2702 | 2921 | const HORZ_ALIKE: [usize; 6] = [1, PARTITION_SPLIT, 4, 5, 6, 8]; |
| 2703 | 2922 | |
| 2923 | +fn trace_edge(mi_r: usize, mi_c: usize, bsize: u32, ctx: usize, rng: u32) { | |
| 2924 | + if std::env::var_os("EC_AV1_TRACE").is_some() { | |
| 2925 | + eprintln!("OUR_PART mi_row={mi_r} mi_col={mi_c} bsize={bsize} ctx={ctx} rng={rng}"); | |
| 2926 | + } | |
| 2927 | +} | |
| 2928 | + | |
| 2704 | 2929 | fn element_prob(cdf: &[u16], element: usize) -> u16 { |
| 2705 | 2930 | cdf[element] - if element > 0 { cdf[element - 1] } else { 0 } |
| 2706 | 2931 | } |
| @@ -4274,6 +4499,36 @@ impl Neighbours { | ||
| 4274 | 4499 | } |
| 4275 | 4500 | } |
| 4276 | 4501 | |
| 4502 | + /// One var-tx / split-tx LEAF's own LUMA transform dims over its mi span. | |
| 4503 | + /// libaom `get_transform_size` (av1_loopfilter.c:207) applies the split | |
| 4504 | + /// override only `if ((plane == AOM_PLANE_Y) && ...)` -- chroma keeps | |
| 4505 | + /// `av1_get_max_uv_txsize(mbmi->bsize)`, the whole BLOCK's uv transform. | |
| 4506 | + /// Routing a leaf through [`Self::fill_lf_grid_rect`] recomputed the uv | |
| 4507 | + /// dims from the LEAF span and so invented chroma transform edges the | |
| 4508 | + /// deblocker then filtered (lane-golomb r6). `ref_grid`/`delta_lf_grid` | |
| 4509 | + /// are already correct from the block's own fill over the same span. | |
| 4510 | + fn fill_lf_grid_leaf_luma( | |
| 4511 | + &mut self, | |
| 4512 | + at_mi: (usize, usize), | |
| 4513 | + w_mi: usize, | |
| 4514 | + h_mi: usize, | |
| 4515 | + tx_px: u8, | |
| 4516 | + tx_h_px: u8, | |
| 4517 | + ) { | |
| 4518 | + let (mi_r, mi_c) = at_mi; | |
| 4519 | + for rr in 0..h_mi { | |
| 4520 | + for cc in 0..w_mi { | |
| 4521 | + let idx = (mi_r + rr) * self.skip_grid_cols_mi + (mi_c + cc); | |
| 4522 | + if let Some(cell) = self.tx_grid.get_mut(idx) { | |
| 4523 | + *cell = tx_px; | |
| 4524 | + } | |
| 4525 | + if let Some(cell) = self.tx_h_grid.get_mut(idx) { | |
| 4526 | + *cell = tx_h_px; | |
| 4527 | + } | |
| 4528 | + } | |
| 4529 | + } | |
| 4530 | + } | |
| 4531 | + | |
| 4277 | 4532 | /// Marks every 4x4 mi cell a just-decoded coded block covers with its |
| 4278 | 4533 | /// `skip` flag -- `at_mi`/`side_mi` are the block's own position and |
| 4279 | 4534 | /// width/height in 4x4 mode-info units (mirroring [`Self::record_mi`]'s |
| @@ -4754,7 +5009,21 @@ impl Neighbours { | ||
| 4754 | 5009 | // false for type 1, TRUE for type 0) and upsampled an edge libaom |
| 4755 | 5010 | // leaves alone -- +1 on rows 2/3 of that block and every chroma block |
| 4756 | 5011 | // predicting from it (class `context-read-from-one-cell`). |
| 4757 | - let (mi_r, mi_c) = (mi_r & !1, mi_c & !1); | |
| 5012 | + self.smooth_uv_neighbour_unsnapped(mi_r & !1, mi_c & !1, r, c) | |
| 5013 | + } | |
| 5014 | + | |
| 5015 | + /// [`Self::smooth_uv_neighbour`] without the chroma-reference snap, i.e. | |
| 5016 | + /// read off the mi passed in exactly. Only the 16x4/4x16 pair witness | |
| 5017 | + /// counter wants this: it measures how often the snap CHANGES the answer, | |
| 5018 | + /// which is what the lane-kf1200/kf900 chroma-reference fix buys. Every | |
| 5019 | + /// decode path uses the snapping form. | |
| 5020 | + fn smooth_uv_neighbour_unsnapped( | |
| 5021 | + &self, | |
| 5022 | + mi_r: usize, | |
| 5023 | + mi_c: usize, | |
| 5024 | + r: usize, | |
| 5025 | + c: usize, | |
| 5026 | + ) -> bool { | |
| 4758 | 5027 | // lane-mtfix r1: availability is TILE-relative on BOTH axes and on the |
| 4759 | 5028 | // coarse fallback too. `above_uv_mode` is a frame-wide [`SUB`]-grid |
| 4760 | 5029 | // array that `start_tile` does not clear, so a block on a tile's first |
| @@ -5612,6 +5881,17 @@ fn read_intra_mode_rect( | ||
| 5612 | 5881 | } |
| 5613 | 5882 | }; |
| 5614 | 5883 | } |
| 5884 | + // lane-sbrect10 r1: libaom `is_cfl_allowed` (blockd.h) is | |
| 5885 | + // `block_size_wide <= 32 && block_size_high <= 32` -- enforce it HERE, at | |
| 5886 | + // the one point every rect caller routes through, so no call site can | |
| 5887 | + // offer the 14-symbol CFL alphabet on a 64-axis block (class | |
| 5888 | + // wrong-alphabet-same-value: same value, wrong interval, silent desync). | |
| 5889 | + let cfl = if cfl && bw.max(bh) > 32 { | |
| 5890 | + NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1)); | |
| 5891 | + false | |
| 5892 | + } else { | |
| 5893 | + cfl | |
| 5894 | + }; | |
| 5615 | 5895 | // Same `intra_segment_id` placement as the square reader above. |
| 5616 | 5896 | let (seg_w_mi, seg_h_mi) = (bw / 4, bh / 4); |
| 5617 | 5897 | if seg_id_pre_skip() { |
| @@ -8045,14 +8325,23 @@ fn decode_rect4_16( | ||
| 8045 | 8325 | RECT4_16_CHROMA_DIR_HITS.with(|h| h.set(h.get() + 1)); |
| 8046 | 8326 | } |
| 8047 | 8327 | let pair_reach = Reach::of_rect(pw, ph, ppx, ppy, y.width, y.height); |
| 8048 | - // libaom `get_intra_edge_filter_type` reads `chroma_above_mbmi` / | |
| 8049 | - // `chroma_left_mbmi` -- the neighbours of the CHROMA REFERENCE | |
| 8050 | - // position, not of the closing strip. At `lmi` the above cell is | |
| 8051 | - // the pair's own first strip, so the mi-exact map missed and the | |
| 8052 | - // coarse fallback answered; the filter type then flipped the | |
| 8053 | - // `use_intra_edge_upsample` decision (blk_wh 12 <= 16 for type 0, | |
| 8054 | - // no upsample for type 1) on directional chroma. | |
| 8055 | - let smooth_neighbor_uv = neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c); | |
| 8328 | + // lane-kf1200 r1: the chroma edge-filter type reads the neighbours | |
| 8329 | + // of the CHROMA block, which for a 16x4/4x16 pair is `pair_mi`'s | |
| 8330 | + // 16x8/8x16 region -- libaom builds `chroma_above_mbmi`/ | |
| 8331 | + // `chroma_left_mbmi` from `mi[-((mi_row & ss_y) * stride + (mi_col | |
| 8332 | + // & ss_x))]` (`set_mi_offsets`, av1/common/blockd.h ~1050), i.e. | |
| 8333 | + // the pair's top-left luma mi, never this leaf's odd row/column. | |
| 8334 | + // Reading `lmi` here named the leaf directly above (a non-chroma | |
| 8335 | + // -reference 4-row block, `uv_mode == UV_DC_PRED`) and so lost a | |
| 8336 | + // SMOOTH neighbour: filt_type 0 instead of 1 turned | |
| 8337 | + // `av1_use_intra_edge_upsample` on (blk_wh 12 <= 16) for a | |
| 8338 | + // directional chroma strip, moving 4 samples by 1. | |
| 8339 | + let smooth_neighbor_uv = | |
| 8340 | + neighbours.smooth_uv_neighbour(pair_mi.0, pair_mi.1, r, c); | |
| 8341 | + if smooth_neighbor_uv != neighbours.smooth_uv_neighbour_unsnapped(lmi.0, lmi.1, r, c) | |
| 8342 | + { | |
| 8343 | + RECT4_16_UV_PAIR_FILT_HITS.with(|h| h.set(h.get() + 1)); | |
| 8344 | + } | |
| 8056 | 8345 | let (u_levels, v_levels) = if skip { |
| 8057 | 8346 | let zeros = vec![0i32; cw * ch]; |
| 8058 | 8347 | // libaom `predict_and_reconstruct_intra_block` (decodeframe.c |
| @@ -8784,6 +9073,14 @@ fn read_intra_mode( | ||
| 8784 | 9073 | } |
| 8785 | 9074 | }; |
| 8786 | 9075 | } |
| 9076 | + // lane-sbrect10 r1: `is_cfl_allowed`'s <=32 bound, enforced at the single | |
| 9077 | + // point every square caller routes through (see `read_intra_mode_rect`). | |
| 9078 | + let cfl = if cfl && side > 32 { | |
| 9079 | + NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1)); | |
| 9080 | + false | |
| 9081 | + } else { | |
| 9082 | + cfl | |
| 9083 | + }; | |
| 8787 | 9084 | // spec 5.11.6 `intra_frame_mode_info`: `intra_segment_id` is read BEFORE |
| 8788 | 9085 | // `skip` when `SegIdPreSkip`, and after it otherwise. |
| 8789 | 9086 | let (seg_w_mi, seg_h_mi) = (side / 4, side / 4); |
| @@ -9127,8 +9424,12 @@ fn cfl_scaled(alpha_q3: i32, ac_q3: i32) -> i32 { | ||
| 9127 | 9424 | /// matches aomdec's own `ec_dump16` rung byte for byte (crop dims, u16 LE). |
| 9128 | 9425 | fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, fh: usize) { |
| 9129 | 9426 | use std::io::Write; |
| 9427 | + // lane-sbrect10 r2 / lane-cdef r1 (one shared helper): index the dump by | |
| 9428 | + // decode-order picture like EC_AV1_PREFILT_DUMP already does -- a fixed | |
| 9429 | + // `.f0` name kept only the LAST frame, so a mid-sequence divergence could | |
| 9430 | + // not be read out at all. | |
| 9130 | 9431 | if let Ok(path) = std::env::var(var) |
| 9131 | - && let Ok(mut f) = std::fs::File::create(format!("{path}.f0")) | |
| 9432 | + && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var))) | |
| 9132 | 9433 | { |
| 9133 | 9434 | for (p, w, h) in [(y, fw, fh), (u, fw.div_ceil(2), fh.div_ceil(2)), (v, fw.div_ceil(2), fh.div_ceil(2))] { |
| 9134 | 9435 | for row in 0..h { |
| @@ -9142,10 +9443,25 @@ fn dump_stage16(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, fw: usize, | ||
| 9142 | 9443 | } |
| 9143 | 9444 | } |
| 9144 | 9445 | |
| 9446 | +/// Decode-order index of the next [`dump_stage`]/[`dump_stage16`] file for a | |
| 9447 | +/// given env var -- lane-cdef r1: both used to write `.f0` unconditionally, so | |
| 9448 | +/// every frame overwrote the previous one and only the LAST frame survived, | |
| 9449 | +/// which silently defeats any per-frame filter-stage bisection. | |
| 9450 | +fn dump_stage_idx(var: &str) -> usize { | |
| 9451 | + use std::collections::HashMap; | |
| 9452 | + use std::sync::{Mutex, OnceLock}; | |
| 9453 | + static IDX: OnceLock<Mutex<HashMap<String, usize>>> = OnceLock::new(); | |
| 9454 | + let mut m = IDX.get_or_init(|| Mutex::new(HashMap::new())).lock().unwrap(); | |
| 9455 | + let e = m.entry(var.to_string()).or_insert(0); | |
| 9456 | + let i = *e; | |
| 9457 | + *e += 1; | |
| 9458 | + i | |
| 9459 | +} | |
| 9460 | + | |
| 9145 | 9461 | fn dump_stage(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf) { |
| 9146 | 9462 | use std::io::Write; |
| 9147 | 9463 | if let Ok(path) = std::env::var(var) |
| 9148 | - && let Ok(mut f) = std::fs::File::create(format!("{path}.f0")) | |
| 9464 | + && let Ok(mut f) = std::fs::File::create(format!("{path}.f{}", dump_stage_idx(var))) | |
| 9149 | 9465 | { |
| 9150 | 9466 | for p in [y, u, v] { |
| 9151 | 9467 | let narrow: Vec<u8> = p.data.iter().map(|&s| s as u8).collect(); |
| @@ -10673,6 +10989,7 @@ fn decode_leaf8( | ||
| 10673 | 10989 | neighbours.record_palette_y_rect(leaf_mi, 8, 8, 0, [0u16; 8]); |
| 10674 | 10990 | neighbours.record_palette_uv_rect(leaf_mi, 8, 8, 0, [0u16; 8]); |
| 10675 | 10991 | } |
| 10992 | + INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); | |
| 10676 | 10993 | neighbours.fill_skip_grid(leaf_mi, 2, skip); |
| 10677 | 10994 | // lane-kf900 r1: the leaf's own RESOLVED transform size, never the literal |
| 10678 | 10995 | // block side. libaom calls `set_txfm_ctxs(mbmi->tx_size, ..., skip_txfm && |
| @@ -10913,11 +11230,18 @@ fn decode_leaf_split4( | ||
| 10913 | 11230 | neighbours.left_uv_mode[r] = uv_predict_mode; |
| 10914 | 11231 | neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); |
| 10915 | 11232 | let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[3] { |
| 10916 | - // As the rect4 pair above: a skipped block still predicts, and CfL is | |
| 10917 | - // prediction (libaom `predict_and_reconstruct_intra_block`). | |
| 11233 | + // A skipped chroma block still gets its CfL contribution: libaom's | |
| 11234 | + // `predict_and_reconstruct_intra_block` calls `cfl_predict_block` | |
| 11235 | + // from `av1_predict_intra_block_facade` (av1/common/reconintra.c:1719) | |
| 11236 | + // whenever `mbmi->uv_mode == UV_CFL_PRED`, before any residual is | |
| 11237 | + // added -- `skip_txfm` only drops the residual, never the alpha. | |
| 11238 | + // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the | |
| 11239 | + // merge keeps one fix and feeds both lanes' counters so neither of | |
| 11240 | + // their gates goes vacuous. | |
| 10918 | 11241 | let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); |
| 10919 | 11242 | if alpha.is_some() { |
| 10920 | 11243 | CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); |
| 11244 | + SKIP_CFL_HITS.with(|c| c.set(c.get() + 1)); | |
| 10921 | 11245 | } |
| 10922 | 11246 | u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv); |
| 10923 | 11247 | v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv); |
| @@ -11272,11 +11596,18 @@ fn decode_leaf_rect8( | ||
| 11272 | 11596 | neighbours.left_uv_mode[r] = uv_predict_mode; |
| 11273 | 11597 | neighbours.record_uv_mode_mi(leaf_mi.0, leaf_mi.1, 2, 2, uv_predict_mode); |
| 11274 | 11598 | let (u_grid, v_grid): (Vec<i32>, Vec<i32>) = if leaf_skips[1] { |
| 11275 | - // As the rect4 pair above: a skipped block still predicts, and CfL is | |
| 11276 | - // prediction (libaom `predict_and_reconstruct_intra_block`). | |
| 11599 | + // A skipped chroma block still gets its CfL contribution: libaom's | |
| 11600 | + // `predict_and_reconstruct_intra_block` calls `cfl_predict_block` | |
| 11601 | + // from `av1_predict_intra_block_facade` (av1/common/reconintra.c:1719) | |
| 11602 | + // whenever `mbmi->uv_mode == UV_CFL_PRED`, before any residual is | |
| 11603 | + // added -- `skip_txfm` only drops the residual, never the alpha. | |
| 11604 | + // lane-reelckf and lane-kf1200 fixed THIS SAME arm independently; the | |
| 11605 | + // merge keeps one fix and feeds both lanes' counters so neither of | |
| 11606 | + // their gates goes vacuous. | |
| 11277 | 11607 | let ac = alpha.map(|_| cfl_ac_q3(y, gpx, gpy, 8)); |
| 11278 | 11608 | if alpha.is_some() { |
| 11279 | 11609 | CHROMA_SKIP_CFL_HITS.with(|h| h.set(h.get() + 1)); |
| 11610 | + SKIP_CFL_HITS.with(|c| c.set(c.get() + 1)); | |
| 11280 | 11611 | } |
| 11281 | 11612 | u.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((au, _), ac)| (au, ac)), None, smooth_neighbor_uv); |
| 11282 | 11613 | v.reconstruct(cpx, cpy, 4, uv_predict_mode, angle_delta_uv, group_reach, &vec![0i32; 16], alpha.zip(ac.as_deref()).map(|((_, av), ac)| (av, ac)), None, smooth_neighbor_uv); |
| @@ -11771,6 +12102,46 @@ const TXFM_CTX_INIT: u8 = 64; | ||
| 11771 | 12102 | /// twice below its own largest transform. |
| 11772 | 12103 | const MAX_VARTX_DEPTH: usize = 2; |
| 11773 | 12104 | |
| 12105 | +/// libaom `sub_tx_size_map[TX_SIZES_ALL]` (`common_data.c`): the transform | |
| 12106 | +/// one `txfm_split` step below `tx_size`. RECTANGULAR for the 1:4 shapes | |
| 12107 | +/// (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`) and for the 4:1 | |
| 12108 | +/// small ones, square everywhere else. | |
| 12109 | +fn sub_tx_size_map(tx_w: usize, tx_h: usize) -> (usize, usize) { | |
| 12110 | + match (tx_w, tx_h) { | |
| 12111 | + (4, 4) => (4, 4), | |
| 12112 | + (8, 8) => (4, 4), | |
| 12113 | + (16, 16) => (8, 8), | |
| 12114 | + (32, 32) => (16, 16), | |
| 12115 | + (64, 64) => (32, 32), | |
| 12116 | + (4, 8) | (8, 4) => (4, 4), | |
| 12117 | + (8, 16) | (16, 8) => (8, 8), | |
| 12118 | + (16, 32) | (32, 16) => (16, 16), | |
| 12119 | + (32, 64) | (64, 32) => (32, 32), | |
| 12120 | + (4, 16) => (4, 8), | |
| 12121 | + (16, 4) => (8, 4), | |
| 12122 | + (8, 32) => (8, 16), | |
| 12123 | + (32, 8) => (16, 8), | |
| 12124 | + (16, 64) => (16, 32), | |
| 12125 | + (64, 16) => (32, 16), | |
| 12126 | + _ => unreachable!("not a TX_SIZES_ALL shape: {tx_w}x{tx_h}"), | |
| 12127 | + } | |
| 12128 | +} | |
| 12129 | + | |
| 12130 | +#[test] | |
| 12131 | +fn sub_tx_size_map_matches_libaom() { | |
| 12132 | + // libaom `common_data.c` `sub_tx_size_map`, in TX_SIZES_ALL order. | |
| 12133 | + const TABLE: [((usize, usize), (usize, usize)); 19] = [ | |
| 12134 | + ((4, 4), (4, 4)), ((8, 8), (4, 4)), ((16, 16), (8, 8)), ((32, 32), (16, 16)), | |
| 12135 | + ((64, 64), (32, 32)), ((4, 8), (4, 4)), ((8, 4), (4, 4)), ((8, 16), (8, 8)), | |
| 12136 | + ((16, 8), (8, 8)), ((16, 32), (16, 16)), ((32, 16), (16, 16)), ((32, 64), (32, 32)), | |
| 12137 | + ((64, 32), (32, 32)), ((4, 16), (4, 8)), ((16, 4), (8, 4)), ((8, 32), (8, 16)), | |
| 12138 | + ((32, 8), (16, 8)), ((16, 64), (16, 32)), ((64, 16), (32, 16)), | |
| 12139 | + ]; | |
| 12140 | + for (tx, want) in TABLE { | |
| 12141 | + assert_eq!(sub_tx_size_map(tx.0, tx.1), want, "sub_tx_size_map({tx:?})"); | |
| 12142 | + } | |
| 12143 | +} | |
| 12144 | + | |
| 11774 | 12145 | /// `read_var_tx_size` (spec 5.11.17, libaom `decodeframe.c` |
| 11775 | 12146 | /// `read_tx_size_vartx`): the recursive `txfm_split` tree of one |
| 11776 | 12147 | /// max-transform-sized unit of an inter block, collecting the resolved leaf |
| @@ -11787,22 +12158,28 @@ fn read_var_tx_size( | ||
| 11787 | 12158 | at_mi: (usize, usize), |
| 11788 | 12159 | blk_max_px: usize, |
| 11789 | 12160 | (max_w_mi, max_h_mi): (usize, usize), |
| 11790 | - tx_px: usize, | |
| 12161 | + (tx_w, tx_h): (usize, usize), | |
| 11791 | 12162 | depth: usize, |
| 11792 | 12163 | blk_row: usize, |
| 11793 | 12164 | blk_col: usize, |
| 11794 | - out: &mut Vec<(usize, usize, usize)>, | |
| 12165 | + out: &mut Vec<(usize, usize, usize, usize)>, | |
| 11795 | 12166 | ) { |
| 11796 | 12167 | if blk_row >= max_h_mi || blk_col >= max_w_mi { |
| 11797 | 12168 | return; |
| 11798 | 12169 | } |
| 11799 | 12170 | let unit = (at_mi.0 + blk_row, at_mi.1 + blk_col); |
| 11800 | 12171 | if depth == MAX_VARTX_DEPTH { |
| 11801 | - out.push((blk_row, blk_col, tx_px)); | |
| 11802 | - txfm_partition_update(n, unit, tx_px, tx_px); | |
| 12172 | + out.push((blk_row, blk_col, tx_w, tx_h)); | |
| 12173 | + txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h)); | |
| 11803 | 12174 | return; |
| 11804 | 12175 | } |
| 11805 | - let ctx = txfm_partition_ctx(n.above_txfm[unit.1], n.left_txfm[unit.0], blk_max_px, tx_px); | |
| 12176 | + let ctx = txfm_partition_ctx_rect( | |
| 12177 | + n.above_txfm[unit.1], | |
| 12178 | + n.left_txfm[unit.0], | |
| 12179 | + blk_max_px, | |
| 12180 | + tx_w, | |
| 12181 | + tx_h, | |
| 12182 | + ); | |
| 11806 | 12183 | let split = dec.symbol(&mut cdfs.txfm_partition[ctx]) == 1; |
| 11807 | 12184 | TXFM_SPLIT_READS.with(|c| c.set(c.get() + 1)); |
| 11808 | 12185 | if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { |
| @@ -11815,27 +12192,27 @@ fn read_var_tx_size( | ||
| 11815 | 12192 | ); |
| 11816 | 12193 | } |
| 11817 | 12194 | if !split { |
| 11818 | - out.push((blk_row, blk_col, tx_px)); | |
| 11819 | - txfm_partition_update(n, unit, tx_px, tx_px); | |
| 12195 | + out.push((blk_row, blk_col, tx_w, tx_h)); | |
| 12196 | + txfm_partition_update_rect(n, unit, (tx_w, tx_h), (tx_w, tx_h)); | |
| 11820 | 12197 | return; |
| 11821 | 12198 | } |
| 11822 | 12199 | TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1)); |
| 11823 | - let sub = tx_px / 2; | |
| 11824 | - if sub == 4 { | |
| 11825 | - // libaom's `sub_txs == TX_4X4` early return: the whole 8x8 unit is | |
| 11826 | - // marked 4x4 (four transform units, raster order) without recursing. | |
| 11827 | - for row in 0..2 { | |
| 11828 | - for col in 0..2 { | |
| 12200 | + let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h); | |
| 12201 | + if (sub_w, sub_h) == (4, 4) { | |
| 12202 | + // libaom's `sub_txs == TX_4X4` early return: every mi cell of the | |
| 12203 | + // unit is marked 4x4 (raster order) without recursing. | |
| 12204 | + for row in 0..tx_h / MI { | |
| 12205 | + for col in 0..tx_w / MI { | |
| 11829 | 12206 | if blk_row + row < max_h_mi && blk_col + col < max_w_mi { |
| 11830 | - out.push((blk_row + row, blk_col + col, 4)); | |
| 12207 | + out.push((blk_row + row, blk_col + col, 4, 4)); | |
| 11831 | 12208 | } |
| 11832 | 12209 | } |
| 11833 | 12210 | } |
| 11834 | - txfm_partition_update(n, unit, 4, tx_px); | |
| 12211 | + txfm_partition_update_rect(n, unit, (4, 4), (tx_w, tx_h)); | |
| 11835 | 12212 | return; |
| 11836 | 12213 | } |
| 11837 | - for row in (0..tx_px / MI).step_by(sub / MI) { | |
| 11838 | - for col in (0..tx_px / MI).step_by(sub / MI) { | |
| 12214 | + for row in (0..tx_h / MI).step_by(sub_h / MI) { | |
| 12215 | + for col in (0..tx_w / MI).step_by(sub_w / MI) { | |
| 11839 | 12216 | read_var_tx_size( |
| 11840 | 12217 | dec, |
| 11841 | 12218 | cdfs, |
| @@ -11843,7 +12220,7 @@ fn read_var_tx_size( | ||
| 11843 | 12220 | at_mi, |
| 11844 | 12221 | blk_max_px, |
| 11845 | 12222 | (max_w_mi, max_h_mi), |
| 11846 | - sub, | |
| 12223 | + (sub_w, sub_h), | |
| 11847 | 12224 | depth + 1, |
| 11848 | 12225 | blk_row + row, |
| 11849 | 12226 | blk_col + col, |
| @@ -11871,7 +12248,7 @@ fn read_block_tx_size( | ||
| 11871 | 12248 | (mi_cols, mi_rows): (usize, usize), |
| 11872 | 12249 | is_inter: bool, |
| 11873 | 12250 | skip: bool, |
| 11874 | -) -> Result<(usize, Option<Vec<(usize, usize, usize)>>)> { | |
| 12251 | +) -> Result<(usize, Option<Vec<(usize, usize, usize, usize)>>)> { | |
| 11875 | 12252 | if !TX_SELECT_INTER.with(std::cell::Cell::get) { |
| 11876 | 12253 | return Ok((side, None)); |
| 11877 | 12254 | } |
| @@ -11891,7 +12268,7 @@ fn read_block_tx_size( | ||
| 11891 | 12268 | at_mi, |
| 11892 | 12269 | side, |
| 11893 | 12270 | (max_w_mi, max_h_mi), |
| 11894 | - max_tx, | |
| 12271 | + (max_tx, max_tx), | |
| 11895 | 12272 | 0, |
| 11896 | 12273 | row, |
| 11897 | 12274 | col, |
| @@ -11899,8 +12276,8 @@ fn read_block_tx_size( | ||
| 11899 | 12276 | ); |
| 11900 | 12277 | } |
| 11901 | 12278 | } |
| 11902 | - let single = leaves.len() == 1 && leaves[0].2 == side; | |
| 11903 | - if !single && leaves.iter().any(|leaf| leaf.2 > 32) { | |
| 12279 | + let single = leaves.len() == 1 && leaves[0].2 == side && leaves[0].3 == side; | |
| 12280 | + if !single && leaves.iter().any(|leaf| leaf.2.max(leaf.3) > 32) { | |
| 11904 | 12281 | // Only a block wider than a superblock's own 64x64 max transform |
| 11905 | 12282 | // reaches here; this crate has no 64-point *inter* coefficient |
| 11906 | 12283 | // table set ([`inter_txbset_for`] stops at 32). |
| @@ -11938,7 +12315,7 @@ fn read_block_tx_size( | ||
| 11938 | 12315 | let mut leaves = Vec::new(); |
| 11939 | 12316 | for row in (0..side_mi).step_by(step) { |
| 11940 | 12317 | for col in (0..side_mi).step_by(step) { |
| 11941 | - leaves.push((row, col, tx)); | |
| 12318 | + leaves.push((row, col, tx, tx)); | |
| 11942 | 12319 | } |
| 11943 | 12320 | } |
| 11944 | 12321 | INTRA_IN_INTER_SPLIT_TX_HITS.with(|c| { |
| @@ -12090,7 +12467,7 @@ fn read_block_tx_size_rect( | ||
| 12090 | 12467 | (bw, bh): (usize, usize), |
| 12091 | 12468 | (mi_cols, mi_rows): (usize, usize), |
| 12092 | 12469 | skip: bool, |
| 12093 | -) -> Result<Option<Vec<(usize, usize, usize)>>> { | |
| 12470 | +) -> Result<Option<Vec<(usize, usize, usize, usize)>>> { | |
| 12094 | 12471 | if skip { |
| 12095 | 12472 | // `set_txfm_ctxs(.., skip && is_inter)`: a skipped inter block records |
| 12096 | 12473 | // its own BLOCK size -- width above, height left -- not a transform. |
| @@ -12133,22 +12510,16 @@ fn read_block_tx_size_rect( | ||
| 12133 | 12510 | } |
| 12134 | 12511 | TXFM_SPLIT_HITS.with(|c| c.set(c.get() + 1)); |
| 12135 | 12512 | RECT_INTER_TXSPLIT_HITS.with(|c| c.set(c.get() + 1)); |
| 12136 | - // lane-r14 r2: `sub_tx_size_map` is square for every shape this decoder | |
| 12137 | - // splits (TX_32X16 -> TX_16X16, TX_64X32 -> TX_32X32) EXCEPT the 1:4 | |
| 12138 | - // strips with a 64-px axis, where it stays rectangular | |
| 12139 | - // (TX_64X16 -> TX_32X16, TX_16X64 -> TX_16X32) and the square recursion | |
| 12140 | - // below would code the wrong tree. | |
| 12141 | - if tx_w.max(tx_h) == 64 && tx_w.min(tx_h) == 16 { | |
| 12142 | - return Err(unsupported( | |
| 12143 | - "a split transform on a 1:4 inter strip with a 64-px axis", | |
| 12144 | - )); | |
| 12145 | - } | |
| 12146 | - let sub = tx_w.min(tx_h); | |
| 12513 | + // lane-r14 r3: `sub_tx_size_map` (libaom `common_data.c`) stays | |
| 12514 | + // RECTANGULAR under a 1:4 strip -- `[TX_64X16] == TX_32X16`, | |
| 12515 | + // `[TX_16X64] == TX_16X32` -- so the recursion below is the general | |
| 12516 | + // rect one and its leaves carry their own width and height. | |
| 12517 | + let (sub_w, sub_h) = sub_tx_size_map(tx_w, tx_h); | |
| 12147 | 12518 | let max_w_mi = (bw / MI).min(mi_cols.saturating_sub(at_mi.1)); |
| 12148 | 12519 | let max_h_mi = (bh / MI).min(mi_rows.saturating_sub(at_mi.0)); |
| 12149 | 12520 | let mut leaves = Vec::new(); |
| 12150 | - for row in (0..bh / MI).step_by(sub / MI) { | |
| 12151 | - for col in (0..bw / MI).step_by(sub / MI) { | |
| 12521 | + for row in (0..bh / MI).step_by(sub_h / MI) { | |
| 12522 | + for col in (0..bw / MI).step_by(sub_w / MI) { | |
| 12152 | 12523 | read_var_tx_size( |
| 12153 | 12524 | dec, |
| 12154 | 12525 | cdfs, |
| @@ -12156,7 +12527,7 @@ fn read_block_tx_size_rect( | ||
| 12156 | 12527 | at_mi, |
| 12157 | 12528 | bw.max(bh), |
| 12158 | 12529 | (max_w_mi, max_h_mi), |
| 12159 | - sub, | |
| 12530 | + (sub_w, sub_h), | |
| 12160 | 12531 | 1, |
| 12161 | 12532 | row, |
| 12162 | 12533 | col, |
| @@ -12193,9 +12564,12 @@ fn read_inter_plane_rect( | ||
| 12193 | 12564 | y: usize, |
| 12194 | 12565 | prediction: &[u16], |
| 12195 | 12566 | inherited_luma_tx_type: Option<TxType>, |
| 12567 | + luma_skip_ctx: Option<usize>, | |
| 12196 | 12568 | ) -> Result<(Vec<i32>, TxType)> { |
| 12197 | 12569 | let skip_ctx = if plane_idx == 0 { |
| 12198 | - 0 | |
| 12570 | + // `get_txb_ctx_general`: 0 only when this unit IS the whole plane | |
| 12571 | + // block; a var-tx leaf passes its own neighbour-table context. | |
| 12572 | + luma_skip_ctx.unwrap_or(0) | |
| 12199 | 12573 | } else { |
| 12200 | 12574 | usize::from(around.0) + usize::from(around.1) |
| 12201 | 12575 | }; |
| @@ -12203,8 +12577,8 @@ fn read_inter_plane_rect( | ||
| 12203 | 12577 | // `av1_get_ext_tx_set_type`'s DCT-only clamp is on `tx_size_sqr_up`, i.e. |
| 12204 | 12578 | // the *longer* side of this rect transform. |
| 12205 | 12579 | let default_tx_type = match inherited_luma_tx_type { |
| 12206 | - Some(t) if w.max(h) < 32 => t, | |
| 12207 | - _ => TxType::DctDct, | |
| 12580 | + Some(t) => reduce_inherited_chroma_tx_type(t, w, h), | |
| 12581 | + None => TxType::DctDct, | |
| 12208 | 12582 | }; |
| 12209 | 12583 | // lane-r14 r2: a 64-length axis codes only its low 32 coefficients |
| 12210 | 12584 | // (`av1_get_max_eob`), so the coded unit is the `min(w,32) x min(h,32)` |
| @@ -12371,6 +12745,45 @@ fn read_inter_luma8( | ||
| 12371 | 12745 | |
| 12372 | 12746 | /// The [`TxbSet`] one leaf of an inter block's var-tx tree reads its |
| 12373 | 12747 | /// coefficient tables from -- the inter counterpart of [`txbset_for`]. |
| 12748 | +/// `av1_get_tx_type`'s chroma tail (libaom `av1/common/blockd.h:1291-1305`): | |
| 12749 | +/// an inter block's chroma transform inherits the *colocated luma* unit's | |
| 12750 | +/// coded `tx_type`, then drops back to `DCT_DCT` unless that type is a member | |
| 12751 | +/// of the extended set the CHROMA transform size selects | |
| 12752 | +/// (`av1_ext_tx_used[av1_get_ext_tx_set_type(uv_tx, 1, reduced)][tx_type]`, | |
| 12753 | +/// `blockd.h:1036`/`1097`). lane-golomb r7: we used to force `DCT_DCT` at | |
| 12754 | +/// every chroma side >= 32, but `av1_get_ext_tx_set_type`'s DCT-only rung is | |
| 12755 | +/// `tx_size_sqr_up > TX_32X32`; at exactly TX_32X32 an inter block reads | |
| 12756 | +/// `EXT_TX_SET_DCT_IDTX`, so a 64x64 inter block whose first luma leaf coded | |
| 12757 | +/// `IDTX` inherits IDTX on its 32x32 chroma units. `IDTX` and `DCT_DCT` are | |
| 12758 | +/// both `TX_CLASS_2D`, so that mistake left the entropy stream perfectly in | |
| 12759 | +/// sync and only corrupted the inverse transform (one 64x64 superblock of | |
| 12760 | +/// high-frequency chroma noise, luma bit-exact). | |
| 12761 | +fn reduce_inherited_chroma_tx_type(t: TxType, w: usize, h: usize) -> TxType { | |
| 12762 | + use TxType::*; | |
| 12763 | + let sqr_up = w.max(h); | |
| 12764 | + let sqr = w.min(h); | |
| 12765 | + let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get); | |
| 12766 | + // `av1_get_ext_tx_set_type(tx_size, is_inter = 1, reduced)`. | |
| 12767 | + let allowed: &[TxType] = if sqr_up > 32 { | |
| 12768 | + // EXT_TX_SET_DCTONLY | |
| 12769 | + &[DctDct] | |
| 12770 | + } else if sqr_up == 32 || reduced { | |
| 12771 | + // EXT_TX_SET_DCT_IDTX | |
| 12772 | + &[DctDct, Idtx] | |
| 12773 | + } else if sqr == 16 { | |
| 12774 | + // EXT_TX_SET_DTT9_IDTX_1DDCT -- TX_TYPES 0..=11, i.e. everything but | |
| 12775 | + // the four 1D ADST/FLIPADST types. | |
| 12776 | + &[ | |
| 12777 | + DctDct, AdstDct, DctAdst, AdstAdst, FlipAdstDct, DctFlipAdst, FlipAdstFlipAdst, | |
| 12778 | + AdstFlipAdst, FlipAdstAdst, Idtx, VDct, HDct, | |
| 12779 | + ] | |
| 12780 | + } else { | |
| 12781 | + // EXT_TX_SET_ALL16 | |
| 12782 | + return t; | |
| 12783 | + }; | |
| 12784 | + if allowed.contains(&t) { t } else { DctDct } | |
| 12785 | +} | |
| 12786 | + | |
| 12374 | 12787 | fn inter_txbset_for(tx_px: usize, reduced_tx_set: bool) -> TxbSet { |
| 12375 | 12788 | match tx_px { |
| 12376 | 12789 | 32 => TxbSet::Luma32Inter, |
| @@ -12876,6 +13289,18 @@ fn deblock_plane( | ||
| 12876 | 13289 | // last coded mi column's horizontal edges were filtered when libaom's |
| 12877 | 13290 | // real output leaves them untouched (r6's post-deblock diff, 37 px, all |
| 12878 | 13291 | // in columns 44-47); clipping here closes it (3/3 frames pixel-exact). |
| 13292 | + // lane-golomb r9: the bound is the MI-ROUNDED frame, not the coded | |
| 13293 | + // frame. libaom's `av1_filter_block_plane_vert/horz` walk the superblock | |
| 13294 | + // and stop at `cm->mi_params.mi_cols`/`mi_rows`, which | |
| 13295 | + // `av1_set_mb_mi` derives from `ALIGN_POWER_OF_TWO(width, 3)` -- the | |
| 13296 | + // 8-pixel-aligned frame, i.e. a 68-wide frame is filtered out to column | |
| 13297 | + // 72 and the vertical edge AT x=68 is a real edge that rewrites the | |
| 13298 | + // in-crop columns 64..67. Clipping at `frame_width` skipped it, which is | |
| 13299 | + // the +-1 straddling-band defect (68x192 cq35, frame 1, 141 luma pixels | |
| 13300 | + // all in columns 64..67; frame 0 survived because that edge carried no | |
| 13301 | + // filter level there). r7's superres measurement is preserved: its frame | |
| 13302 | + // was already 8-aligned, so this bound equals `frame_width` there and | |
| 13303 | + // still excludes the superblock padding up to `true_width`. | |
| 12879 | 13304 | let (cw, ch) = if chroma { |
| 12880 | 13305 | (frame_width.div_ceil(2), frame_height.div_ceil(2)) |
| 12881 | 13306 | } else { |
| @@ -12886,11 +13311,17 @@ fn deblock_plane( | ||
| 12886 | 13311 | plane.true_height.min(ch), |
| 12887 | 13312 | plane.width, |
| 12888 | 13313 | ); |
| 13314 | + if std::env::var_os("EC_AV1_DEBLOCK_TRACE_V").is_some() { | |
| 13315 | + eprintln!("DEBLOCK plane={plane_idx} tw={tw} th={th} stride={stride} true={}x{} crop={cw}x{ch}", plane.true_width, plane.true_height); | |
| 13316 | + } | |
| 12889 | 13317 | let mut y0 = 0usize; |
| 12890 | 13318 | while y0 < th { |
| 12891 | 13319 | let mut x0 = 4usize; |
| 12892 | 13320 | while x0 < tw { |
| 12893 | 13321 | if let Some((len, level)) = edge_params(lf, n, plane_idx, 0, chroma, x0, y0) { |
| 13322 | + if std::env::var_os("EC_AV1_DEBLOCK_TRACE_V").is_some() && plane_idx == 0 { | |
| 13323 | + eprintln!("VEDGE x0={x0} y0={y0} len={len} level={level}"); | |
| 13324 | + } | |
| 12894 | 13325 | filter_edge( |
| 12895 | 13326 | &mut plane.data, |
| 12896 | 13327 | y0 * stride + x0, |
| @@ -12941,6 +13372,9 @@ fn apply_cdef( | ||
| 12941 | 13372 | v: &mut PlaneBuf, |
| 12942 | 13373 | cdef: &CdefParams, |
| 12943 | 13374 | skip_grid: &Neighbours, |
| 13375 | + // This frame header's own CROPPED luma size, for the straddling-unit | |
| 13376 | + // counter only -- CDEF itself walks the mi-rounded plane. | |
| 13377 | + (frame_w, frame_h): (usize, usize), | |
| 12944 | 13378 | ) { |
| 12945 | 13379 | // lane-part32 r2 debug rung, env-gated: see `apply_deblock`'s sibling. |
| 12946 | 13380 | if std::env::var_os("EC_AV1_DEBUG_SKIP_CDEF").is_some() { |
| @@ -12984,6 +13418,9 @@ fn apply_cdef( | ||
| 12984 | 13418 | while mi_r < skip_grid.mi_rows { |
| 12985 | 13419 | let mut mi_c = 0usize; |
| 12986 | 13420 | while mi_c < skip_grid.mi_cols { |
| 13421 | + if skip_grid.is_skip_txfm(mi_r, mi_c) { | |
| 13422 | + CDEF_SKIPPED_UNITS.with(|c| c.set(c.get() + 1)); | |
| 13423 | + } | |
| 12987 | 13424 | if !skip_grid.is_skip_txfm(mi_r, mi_c) { |
| 12988 | 13425 | let sidx = strength_idx(mi_r, mi_c); |
| 12989 | 13426 | let (ox, oy) = (mi_c * 4, mi_r * 4); |
| @@ -12996,10 +13433,15 @@ fn apply_cdef( | ||
| 12996 | 13433 | i32::from(src_y[ny as usize * y_stride + nx as usize]) |
| 12997 | 13434 | } |
| 12998 | 13435 | }; |
| 12999 | - let (dir, var) = cdef_find_dir(coeff_shift, |r, c| { | |
| 13000 | - let (ny, nx) = ((oy + r).min(y_true_h - 1), (ox + c).min(y_true_w - 1)); | |
| 13001 | - i32::from(src_y[ny * y_stride + nx]) | |
| 13002 | - }); | |
| 13436 | + // lane-cdef r1: the direction search reads the SAME padded | |
| 13437 | + // block the taps do -- libaom runs `cdef_find_dir` on the | |
| 13438 | + // prepared filter block (`cdef_block.c:296-320` over | |
| 13439 | + // `cdef_prepare_fb`'s buffer, `cdef.c:249-256`), whose columns | |
| 13440 | + // and rows past the mi-rounded frame extent are CDEF_VERY_LARGE. | |
| 13441 | + // Clamping to the last real sample instead made every straddling | |
| 13442 | + // edge 8x8 (odd `mi_cols`/`mi_rows`) pick a different var, hence | |
| 13443 | + // a different `adjust_strength`, hence a +-1 band at the crop edge. | |
| 13444 | + let (dir, var) = cdef_find_dir(coeff_shift, |r, c| sample_y(r as i32, c as i32)); | |
| 13003 | 13445 | |
| 13004 | 13446 | // libaom `av1_cdef_filter_fb` passes `pri_strength ? dir : 0` |
| 13005 | 13447 | // -- each plane zeroes the shared direction when *its own* |
| @@ -13009,8 +13451,22 @@ fn apply_cdef( | ||
| 13009 | 13451 | let y_sec_strength = i32::from(cdef.y_sec_strength[sidx]) << coeff_shift; |
| 13010 | 13452 | let y_dir = if y_pri_strength != 0 { dir } else { 0 }; |
| 13011 | 13453 | let t = cdef_adjust_strength(y_pri_strength, var); |
| 13454 | + // lane-cdef r1 rung: one line per filtered 8x8 luma CDEF unit. | |
| 13455 | + if std::env::var_os("EC_AV1_CDEF_DBG").is_some() { | |
| 13456 | + eprintln!( | |
| 13457 | + "EC_CDEF mi_r={mi_r} mi_c={mi_c} x={ox} y={oy} sidx={sidx} dir={dir} var={var} t={t} pri={y_pri_strength} sec={y_sec_strength} damp={damping}" | |
| 13458 | + ); | |
| 13459 | + } | |
| 13012 | 13460 | let enable_primary = t != 0; |
| 13013 | 13461 | let enable_secondary = y_sec_strength != 0; |
| 13462 | + if (ox + 8 > frame_w || oy + 8 > frame_h) | |
| 13463 | + && (enable_primary | |
| 13464 | + || enable_secondary | |
| 13465 | + || cdef.uv_pri_strength[sidx] != 0 | |
| 13466 | + || cdef.uv_sec_strength[sidx] != 0) | |
| 13467 | + { | |
| 13468 | + CDEF_STRADDLE_UNITS.with(|c| c.set(c.get() + 1)); | |
| 13469 | + } | |
| 13014 | 13470 | if enable_primary || enable_secondary { |
| 13015 | 13471 | cdef_filter_block( |
| 13016 | 13472 | sample_y, |
| @@ -13090,13 +13546,30 @@ fn apply_loop_restoration( | ||
| 13090 | 13546 | deblocked_v: &PlaneBuf, |
| 13091 | 13547 | lr: &LoopRestorationParams, |
| 13092 | 13548 | grid: &crate::restoration::RestorationGrid, |
| 13549 | + // lane-golomb r8: this frame header's own (cropped) luma size. Loop | |
| 13550 | + // restoration is the ONE post-decode filter that does NOT run over the | |
| 13551 | + // mi-rounded plane: libaom's `av1_loop_restoration_filter_frame` sizes | |
| 13552 | + // every plane with `av1_get_upsampled_plane_size` -- `plane_w = | |
| 13553 | + // ROUND_POWER_OF_TWO(cm->superres_upscaled_width, ss_x)`, `plane_h = | |
| 13554 | + // ROUND_POWER_OF_TWO(cm->height, ss_y)` (`av1/common/restoration.c:47`) | |
| 13555 | + // -- and asserts it equals the buffer's CROP width | |
| 13556 | + // (`restoration.c:1106`), then `av1_extend_frame(..., plane_w, plane_h, | |
| 13557 | + // ...)` (`restoration.c:1109`) replicates the right/bottom border from | |
| 13558 | + // that cropped edge before any unit is filtered. Deblock and CDEF DO | |
| 13559 | + // walk the mi grid, which is why passing `true_width`/`true_height` | |
| 13560 | + // here went unnoticed until a frame whose size is not a multiple of 8 | |
| 13561 | + // (68 -> mi-rounded 72): the LR taps at the last four real columns then | |
| 13562 | + // read this decoder's own decoded samples at columns 68..71 where | |
| 13563 | + // libaom reads column 67 replicated -- +-1 over the straddling band | |
| 13564 | + // (class av1-truesize-lane: true frame size vs mi-rounded). | |
| 13565 | + (frame_w, frame_h): (usize, usize), | |
| 13093 | 13566 | ) { |
| 13094 | 13567 | y.data = crate::restoration::apply_loop_restoration_plane( |
| 13095 | 13568 | &y.data, |
| 13096 | 13569 | &deblocked_y.data, |
| 13097 | 13570 | y.width, |
| 13098 | - y.true_width, | |
| 13099 | - y.true_height, | |
| 13571 | + frame_w, | |
| 13572 | + frame_h, | |
| 13100 | 13573 | 0, |
| 13101 | 13574 | lr.frame_restoration_type[0], |
| 13102 | 13575 | lr.loop_restoration_size[0], |
| @@ -13107,8 +13580,8 @@ fn apply_loop_restoration( | ||
| 13107 | 13580 | &u.data, |
| 13108 | 13581 | &deblocked_u.data, |
| 13109 | 13582 | u.width, |
| 13110 | - u.true_width, | |
| 13111 | - u.true_height, | |
| 13583 | + frame_w.div_ceil(2), | |
| 13584 | + frame_h.div_ceil(2), | |
| 13112 | 13585 | 1, |
| 13113 | 13586 | lr.frame_restoration_type[1], |
| 13114 | 13587 | lr.loop_restoration_size[1], |
| @@ -13119,8 +13592,8 @@ fn apply_loop_restoration( | ||
| 13119 | 13592 | &v.data, |
| 13120 | 13593 | &deblocked_v.data, |
| 13121 | 13594 | v.width, |
| 13122 | - v.true_width, | |
| 13123 | - v.true_height, | |
| 13595 | + frame_w.div_ceil(2), | |
| 13596 | + frame_h.div_ceil(2), | |
| 13124 | 13597 | 1, |
| 13125 | 13598 | lr.frame_restoration_type[2], |
| 13126 | 13599 | lr.loop_restoration_size[2], |
| @@ -13682,12 +14155,16 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 13682 | 14155 | // the first block of that row. |
| 13683 | 14156 | match (has_cols, has_rows) { |
| 13684 | 14157 | (true, false) => { |
| 14158 | + trace_edge((sb_r * SB_MI) as usize, (sb_c * SB_MI) as usize, 12, ctx, dec.debug_state().0 as u32); | |
| 13685 | 14159 | let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], VERT_ALIKE)); |
| 14160 | + bump_edge32(4 + b.min(1) as usize); | |
| 13686 | 14161 | bump_edge_part(b.min(1) as usize); |
| 13687 | 14162 | if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ } |
| 13688 | 14163 | } |
| 13689 | 14164 | (false, true) => { |
| 14165 | + trace_edge((sb_r * SB_MI) as usize, (sb_c * SB_MI) as usize, 12, ctx, dec.debug_state().0 as u32); | |
| 13690 | 14166 | let b = dec.symbol_fixed(&gather(&cdfs.partition_w64[ctx], HORZ_ALIKE)); |
| 14167 | + bump_edge32(4 + b.min(1) as usize); | |
| 13691 | 14168 | bump_edge_part(b.min(1) as usize); |
| 13692 | 14169 | if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT } |
| 13693 | 14170 | } |
| @@ -13752,18 +14229,22 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 13752 | 14229 | // superblock level above). |
| 13753 | 14230 | match (has_cols32, has_rows32) { |
| 13754 | 14231 | (true, false) => { |
| 14232 | + trace_edge((r32 * BLOCK_MI) as usize, (c32 * BLOCK_MI) as usize, 9, ctx32, dec.debug_state().0 as u32); | |
| 13755 | 14233 | let b = dec.symbol_fixed(&gather( |
| 13756 | 14234 | &cdfs.partition_w32[ctx32], |
| 13757 | 14235 | VERT_ALIKE, |
| 13758 | 14236 | )); |
| 14237 | + bump_edge32(b.min(1) as usize); | |
| 13759 | 14238 | bump_edge_part(2 + b.min(1) as usize); |
| 13760 | 14239 | if b == 1 { PARTITION_SPLIT } else { PARTITION_HORZ } |
| 13761 | 14240 | } |
| 13762 | 14241 | (false, true) => { |
| 14242 | + trace_edge((r32 * BLOCK_MI) as usize, (c32 * BLOCK_MI) as usize, 9, ctx32, dec.debug_state().0 as u32); | |
| 13763 | 14243 | let b = dec.symbol_fixed(&gather( |
| 13764 | 14244 | &cdfs.partition_w32[ctx32], |
| 13765 | 14245 | HORZ_ALIKE, |
| 13766 | 14246 | )); |
| 14247 | + bump_edge32(b.min(1) as usize); | |
| 13767 | 14248 | bump_edge_part(2 + b.min(1) as usize); |
| 13768 | 14249 | if b == 1 { PARTITION_SPLIT } else { PARTITION_VERT } |
| 13769 | 14250 | } |
| @@ -14238,6 +14719,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 14238 | 14719 | // This path can only walk the four SPLIT |
| 14239 | 14720 | // leaves, so a 0 refuses by name instead |
| 14240 | 14721 | // of desyncing. |
| 14722 | + trace_edge(sr * SUB_MI as usize, sc * SUB_MI as usize, 6, ctx16, dec.debug_state().0 as u32); | |
| 14241 | 14723 | let edge_split = if has_cols16 { |
| 14242 | 14724 | dec.symbol_fixed(&gather( |
| 14243 | 14725 | &cdfs.partition_w16[ctx16], |
| @@ -14318,10 +14800,11 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 14318 | 14800 | } |
| 14319 | 14801 | } |
| 14320 | 14802 | let leaf_ctx = neighbours.partition_ctx_mi(leaf_mi, 8); |
| 14803 | + let pre8 = dec.debug_state().0; | |
| 14321 | 14804 | let part8 = dec.symbol(&mut cdfs.partition_w8[leaf_ctx]); |
| 14322 | 14805 | if std::env::var_os("EC_AV1_TRACE").is_some() { |
| 14323 | 14806 | eprintln!( |
| 14324 | - "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8}" | |
| 14807 | + "TRACE partition_w8 mi=({mr},{mc}) ctx={leaf_ctx} value={part8} pre_rng={pre8}" | |
| 14325 | 14808 | ); |
| 14326 | 14809 | } |
| 14327 | 14810 | let leaf_mode = if part8 == PARTITION_NONE { |
| @@ -14419,6 +14902,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 14419 | 14902 | tx_select, |
| 14420 | 14903 | reduced_tx_set, |
| 14421 | 14904 | )?; |
| 14905 | + if !has_rows32 { | |
| 14906 | + bump_edge32(2); | |
| 14907 | + } | |
| 14422 | 14908 | // lane-hgkf r1: at the frame edge only the first half of the strip is |
| 14423 | 14909 | // coded (libaom `decode_partition` guards the second half with the same |
| 14424 | 14910 | // test that made this partition non-square). |
| @@ -14460,6 +14946,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 14460 | 14946 | tx_select, |
| 14461 | 14947 | reduced_tx_set, |
| 14462 | 14948 | )?; |
| 14949 | + if !has_cols32 { | |
| 14950 | + bump_edge32(3); | |
| 14951 | + } | |
| 14463 | 14952 | // lane-hgkf r1: at the frame edge only the first half of the strip is |
| 14464 | 14953 | // coded (libaom `decode_partition` guards the second half with the same |
| 14465 | 14954 | // test that made this partition non-square). |
| @@ -14850,6 +15339,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 14850 | 15339 | tx_select, |
| 14851 | 15340 | reduced_tx_set, |
| 14852 | 15341 | )?; |
| 15342 | + if !has_rows { | |
| 15343 | + bump_edge32(6); | |
| 15344 | + } | |
| 14853 | 15345 | // lane-golomb r1: at the frame edge only the first half of the |
| 14854 | 15346 | // strip is coded (libaom `decode_partition` guards the second |
| 14855 | 15347 | // with the same has_rows test that made this partition non-square). |
| @@ -14891,6 +15383,9 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 14891 | 15383 | tx_select, |
| 14892 | 15384 | reduced_tx_set, |
| 14893 | 15385 | )?; |
| 15386 | + if !has_cols { | |
| 15387 | + bump_edge32(7); | |
| 15388 | + } | |
| 14894 | 15389 | // lane-golomb r1: at the frame edge only the first half of the |
| 14895 | 15390 | // strip is coded (libaom `decode_partition` guards the second |
| 14896 | 15391 | // with the same has_cols test that made this partition non-square). |
| @@ -15065,6 +15560,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 15065 | 15560 | // that isolate whether a decode-order frame's mismatch already exists |
| 15066 | 15561 | // in reconstruction (this dump) vs is introduced by the loop filter |
| 15067 | 15562 | // (EC_AV1_DECODE_ORDER_DUMP's post-filter dump). |
| 15563 | + // Decode-order frame marker for the EC_OBMC / EC_TRACE_MODE ladders. | |
| 15564 | + if std::env::var_os("EC_OBMC").is_some() || std::env::var_os("EC_TRACE_MODE").is_some() { | |
| 15565 | + eprintln!( | |
| 15566 | + "EC_PICT idx={}", | |
| 15567 | + PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst) | |
| 15568 | + ); | |
| 15569 | + } | |
| 15068 | 15570 | dump_stage16("EC_AV1_PREFILT_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); |
| 15069 | 15571 | if let Ok(path) = std::env::var("EC_AV1_PREFILT_DUMP") { |
| 15070 | 15572 | use std::io::Write; |
| @@ -15110,10 +15612,20 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | ||
| 15110 | 15612 | // dump above these bisect WHICH filter stage introduced a mismatch. |
| 15111 | 15613 | dump_stage("EC_AV1_POSTDEBLOCK_DUMP", &y, &u, &v); |
| 15112 | 15614 | dump_stage16("EC_AV1_POSTDEBLOCK_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); |
| 15113 | - apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); | |
| 15615 | + apply_cdef( | |
| 15616 | + &mut y, | |
| 15617 | + &mut u, | |
| 15618 | + &mut v, | |
| 15619 | + cdef, | |
| 15620 | + &neighbours, | |
| 15621 | + (frame_width as usize, frame_height as usize), | |
| 15622 | + ); | |
| 15114 | 15623 | dump_stage("EC_AV1_POSTCDEF_DUMP", &y, &u, &v); |
| 15115 | 15624 | dump_stage16("EC_AV1_POSTCDEF_DUMP16", &y, &u, &v, frame_width as usize, frame_height as usize); |
| 15116 | - apply_loop_restoration(&mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid); | |
| 15625 | + apply_loop_restoration( | |
| 15626 | + &mut y, &mut u, &mut v, &deblocked_y, &deblocked_u, &deblocked_v, lr, &lr_grid, | |
| 15627 | + (frame_width as usize, frame_height as usize), | |
| 15628 | + ); | |
| 15117 | 15629 | |
| 15118 | 15630 | let (fw, fh) = (frame_width as usize, frame_height as usize); |
| 15119 | 15631 | if fw == width && fh == height { |
| @@ -15269,6 +15781,9 @@ fn resolve_interp_filter( | ||
| 15269 | 15781 | } else { |
| 15270 | 15782 | sym0 |
| 15271 | 15783 | }; |
| 15784 | + if enable_dual_filter && sym0 != sym1 { | |
| 15785 | + DUAL_FILTER_DIFF_HITS.with(|c| c.set(c.get() + 1)); | |
| 15786 | + } | |
| 15272 | 15787 | ( |
| 15273 | 15788 | mc::InterpFilterKind::from_switchable_symbol(sym1 as usize), |
| 15274 | 15789 | mc::InterpFilterKind::from_switchable_symbol(sym0 as usize), |
| @@ -15505,10 +16020,9 @@ fn read_inter_plane( | ||
| 15505 | 16020 | // `tx_type` -- `av1_get_tx_type` (libaom `blockd.h`): an inter block's |
| 15506 | 16021 | // chroma plane never codes its own `tx_type` symbol, but (unlike an |
| 15507 | 16022 | // intra block, which falls back to `Intra_Mode_To_Tx_Type`) it inherits |
| 15508 | - // the colocated luma transform's coded type verbatim, clamped back to | |
| 15509 | - // `DCT_DCT` at the chroma tx sizes the spec forces DCT-only | |
| 15510 | - // (`av1_get_ext_tx_set_type`: `tx_size_sqr_up >= TX_32X32`, i.e. this | |
| 15511 | - // function's own `side >= 32`). `None` for the luma call itself | |
| 16023 | + // the colocated luma transform's coded type, narrowed to the extended | |
| 16024 | + // set the CHROMA size selects ([`reduce_inherited_chroma_tx_type`]). | |
| 16025 | + // `None` for the luma call itself | |
| 15512 | 16026 | // (`plane_idx == 0`), where the `TxbSet`'s own symbol (or the true |
| 15513 | 16027 | // `DCT_DCT` default at 32-point+) already resolves it without help. |
| 15514 | 16028 | inherited_luma_tx_type: Option<TxType>, |
| @@ -15526,8 +16040,8 @@ fn read_inter_plane( | ||
| 15526 | 16040 | }; |
| 15527 | 16041 | let mut coding = cdfs.txb(set, tx_mode); |
| 15528 | 16042 | let default_tx_type = match inherited_luma_tx_type { |
| 15529 | - Some(t) if side < 32 => t, | |
| 15530 | - _ => TxType::DctDct, | |
| 16043 | + Some(t) => reduce_inherited_chroma_tx_type(t, side, side), | |
| 16044 | + None => TxType::DctDct, | |
| 15531 | 16045 | }; |
| 15532 | 16046 | let (grid, tx_type) = read_coeffs( |
| 15533 | 16047 | dec, |
| @@ -15920,22 +16434,33 @@ fn obmc_mask(len: usize) -> &'static [u8] { | ||
| 15920 | 16434 | /// A bordering block's own resolved interp filter kernel, `(h, v)` -- |
| 15921 | 16435 | /// mirrors [`resolve_interp_filter`]'s own return order from its stored |
| 15922 | 16436 | /// `[u8; 2]` (`Neighbours::above_filter`/`left_filter`, `[sym0, sym1]` = |
| 15923 | -/// `[v_sym, h_sym]`). Never calls `from_switchable_symbol` on the `[3, 3]` | |
| 15924 | -/// sentinel: that value is only ever stored for an intra neighbour (already | |
| 15925 | -/// excluded by [`overlappable_above`]/[`overlappable_left`]'s `is_inter` | |
| 15926 | -/// gate) or when `interp_fixed` is `Some` for the whole frame, handled here | |
| 15927 | -/// first. | |
| 16437 | +/// `[v_sym, h_sym]`). The `[3, 3]` sentinel is only ever stored for an intra | |
| 16438 | +/// neighbour (excluded by [`overlappable_above`]/[`overlappable_left`]'s | |
| 16439 | +/// `is_inter` gate) or when `interp_fixed` is `Some` for the whole frame | |
| 16440 | +/// (handled here first) -- so a sentinel reaching the kernel lookup means the | |
| 16441 | +/// stream desynced upstream, and this refuses instead of panicking. | |
| 15928 | 16442 | fn neighbour_filter( |
| 15929 | 16443 | interp_fixed: Option<mc::InterpFilterKind>, |
| 15930 | 16444 | sym: [u8; 2], |
| 15931 | -) -> (mc::InterpFilterKind, mc::InterpFilterKind) { | |
| 16445 | +) -> Result<(mc::InterpFilterKind, mc::InterpFilterKind)> { | |
| 15932 | 16446 | if let Some(kind) = interp_fixed { |
| 15933 | - return (kind, kind); | |
| 16447 | + return Ok((kind, kind)); | |
| 16448 | + } | |
| 16449 | + // lane-golomb r9: this used to hand the sentinel straight to | |
| 16450 | + // `from_switchable_symbol`, which PANICS on any value above 2 -- a crash | |
| 16451 | + // on stream data (measured on a real 192x68 cq40 aomenc stream, where an | |
| 16452 | + // inter leaf below 8x8 desyncs upstream and leaves an unrecorded filter | |
| 16453 | + // behind). A decoder must refuse such a stream by name, never abort the | |
| 16454 | + // process; the desync that produces the sentinel belongs to lane-intersub8. | |
| 16455 | + if sym[0] > 2 || sym[1] > 2 { | |
| 16456 | + return Err(unsupported( | |
| 16457 | + "an OBMC neighbour whose switchable interp filter was never recorded", | |
| 16458 | + )); | |
| 15934 | 16459 | } |
| 15935 | - ( | |
| 16460 | + Ok(( | |
| 15936 | 16461 | mc::InterpFilterKind::from_switchable_symbol(sym[1] as usize), |
| 15937 | 16462 | mc::InterpFilterKind::from_switchable_symbol(sym[0] as usize), |
| 15938 | - ) | |
| 16463 | + )) | |
| 15939 | 16464 | } |
| 15940 | 16465 | |
| 15941 | 16466 | /// One neighbour's own re-prediction over a `w`x`h` region, MC'd fresh |
| @@ -16115,6 +16640,71 @@ fn obmc_blend_h(dst: &mut [u16], stride: usize, ox: usize, oy: usize, w: usize, | ||
| 16115 | 16640 | } |
| 16116 | 16641 | } |
| 16117 | 16642 | |
| 16643 | +/// libaom's own `BLOCK_SIZE` enum index for a `w4`x`h4` (mi-unit) block -- | |
| 16644 | +/// only for the `EC_OBMC` trace rung below, so it reads byte-identical to | |
| 16645 | +/// the instrumented aomdec's `backup_mbmi.bsize`. | |
| 16646 | +fn ec_obmc_bsize(w4: usize, h4: usize) -> i32 { | |
| 16647 | + match (w4, h4) { | |
| 16648 | + (1, 1) => 0, | |
| 16649 | + (1, 2) => 1, | |
| 16650 | + (2, 1) => 2, | |
| 16651 | + (2, 2) => 3, | |
| 16652 | + (2, 4) => 4, | |
| 16653 | + (4, 2) => 5, | |
| 16654 | + (4, 4) => 6, | |
| 16655 | + (4, 8) => 7, | |
| 16656 | + (8, 4) => 8, | |
| 16657 | + (8, 8) => 9, | |
| 16658 | + (8, 16) => 10, | |
| 16659 | + (16, 8) => 11, | |
| 16660 | + (16, 16) => 12, | |
| 16661 | + (1, 4) => 16, | |
| 16662 | + (4, 1) => 17, | |
| 16663 | + (2, 8) => 18, | |
| 16664 | + (8, 2) => 19, | |
| 16665 | + (4, 16) => 20, | |
| 16666 | + (16, 4) => 21, | |
| 16667 | + _ => -1, | |
| 16668 | + } | |
| 16669 | +} | |
| 16670 | + | |
| 16671 | +/// The `EC_OBMC` rung: one line per blended neighbour, in the instrumented | |
| 16672 | +/// aomdec's own byte format (`decodeframe.c` | |
| 16673 | +/// `dec_build_prediction_by_{above,left}_pred`), so the two decoders' OBMC | |
| 16674 | +/// neighbour lists diff line for line. `filt` is libaom's packed | |
| 16675 | +/// `interp_filters.as_int` = `y_filter | (x_filter << 16)`. | |
| 16676 | +#[allow(clippy::too_many_arguments)] | |
| 16677 | +fn ec_obmc_trace( | |
| 16678 | + dir: &str, | |
| 16679 | + mi_row: usize, | |
| 16680 | + mi_col: usize, | |
| 16681 | + write_w: usize, | |
| 16682 | + write_h: usize, | |
| 16683 | + rel: usize, | |
| 16684 | + op: usize, | |
| 16685 | + nb: &MiInfo, | |
| 16686 | + h_kind: mc::InterpFilterKind, | |
| 16687 | + v_kind: mc::InterpFilterKind, | |
| 16688 | +) { | |
| 16689 | + if std::env::var_os("EC_OBMC").is_none() { | |
| 16690 | + return; | |
| 16691 | + } | |
| 16692 | + let sym = |k: mc::InterpFilterKind| match k { | |
| 16693 | + mc::InterpFilterKind::Smooth => 1u32, | |
| 16694 | + mc::InterpFilterKind::Sharp => 2, | |
| 16695 | + _ => 0, | |
| 16696 | + }; | |
| 16697 | + eprintln!( | |
| 16698 | + "EC_OBMC {dir} mi=({mi_row},{mi_col}) wh=({write_w}x{write_h}) rel={rel} op={op} \ | |
| 16699 | +nbmv=({},{}) nbref={} nbbsize={} filt={}", | |
| 16700 | + nb.mv.0, | |
| 16701 | + nb.mv.1, | |
| 16702 | + nb.ref_frame, | |
| 16703 | + ec_obmc_bsize(nb.size, nb.size_h), | |
| 16704 | + sym(v_kind) | (sym(h_kind) << 16), | |
| 16705 | + ); | |
| 16706 | +} | |
| 16707 | + | |
| 16118 | 16708 | /// `av1_build_obmc_inter_prediction` (libaom `reconinter.c`): re-predicts |
| 16119 | 16709 | /// the overlap strip against each bordering above/left inter neighbour's own |
| 16120 | 16710 | /// mv/ref/filter and blends it into this block's just-built single-reference |
| @@ -16213,7 +16803,8 @@ fn obmc_blend( | ||
| 16213 | 16803 | let (h_kind, v_kind) = neighbour_filter( |
| 16214 | 16804 | interp_fixed, |
| 16215 | 16805 | neighbours.above_filter[mi_col + off4], |
| 16216 | - ); | |
| 16806 | + )?; | |
| 16807 | + ec_obmc_trace("above", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind); | |
| 16217 | 16808 | let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; |
| 16218 | 16809 | let nb_scale = mc::scale_factor(ny.width, frame_width); |
| 16219 | 16810 | let (bw, bh, ox) = (span4 * 4, overlap_above, off4 * 4); |
| @@ -16232,7 +16823,8 @@ fn obmc_blend( | ||
| 16232 | 16823 | let (h_kind, v_kind) = neighbour_filter( |
| 16233 | 16824 | interp_fixed, |
| 16234 | 16825 | neighbours.left_filter[mi_row + off4], |
| 16235 | - ); | |
| 16826 | + )?; | |
| 16827 | + ec_obmc_trace("left", mi_row, mi_col, write_w, write_h, off4, span4, &nb, h_kind, v_kind); | |
| 16236 | 16828 | let (ny, nu, nv) = ref_planes(nb.ref_frame, ref_y, ref_u, ref_v, other_refs)?; |
| 16237 | 16829 | let nb_scale = mc::scale_factor(ny.width, frame_width); |
| 16238 | 16830 | let (bw, bh, oy) = (overlap_left, span4 * 4, off4 * 4); |
| @@ -16812,7 +17404,7 @@ fn decode_inter_block( | ||
| 16812 | 17404 | // 5.11.17), `Some` only when this block's var-tx tree resolved to more |
| 16813 | 17405 | // than one luma transform -- read back by the residual loop, the |
| 16814 | 17406 | // coefficient-context write-back and the loop-filter grid fill below. |
| 16815 | - let mut vartx_leaves: Option<Vec<(usize, usize, usize)>> = None; | |
| 17407 | + let mut vartx_leaves: Option<Vec<(usize, usize, usize, usize)>> = None; | |
| 16816 | 17408 | let at_mi = at; |
| 16817 | 17409 | if is_inter { |
| 16818 | 17410 | let above_nbr = has_above.then(|| NeighbourRef { |
| @@ -17381,7 +17973,7 @@ fn decode_inter_block( | ||
| 17381 | 17973 | } |
| 17382 | 17974 | |
| 17383 | 17975 | let mut inter0_y = vec![0i32; side * side]; |
| 17384 | - mc::predict_compound_intermediate( | |
| 17976 | + mc::predict_compound_intermediate_kern( | |
| 17385 | 17977 | &py0.data, |
| 17386 | 17978 | py0.width, |
| 17387 | 17979 | py0.true_width, |
| @@ -17391,6 +17983,8 @@ fn decode_inter_block( | ||
| 17391 | 17983 | scale0, |
| 17392 | 17984 | side, |
| 17393 | 17985 | side, |
| 17986 | + write_w, | |
| 17987 | + write_h, | |
| 17394 | 17988 | h_filter, |
| 17395 | 17989 | v_filter, |
| 17396 | 17990 | &mut inter0_y, |
| @@ -17406,7 +18000,7 @@ fn decode_inter_block( | ||
| 17406 | 18000 | ); |
| 17407 | 18001 | } |
| 17408 | 18002 | let mut inter1_y = vec![0i32; side * side]; |
| 17409 | - mc::predict_compound_intermediate( | |
| 18003 | + mc::predict_compound_intermediate_kern( | |
| 17410 | 18004 | &py1.data, |
| 17411 | 18005 | py1.width, |
| 17412 | 18006 | py1.true_width, |
| @@ -17416,6 +18010,8 @@ fn decode_inter_block( | ||
| 17416 | 18010 | scale1, |
| 17417 | 18011 | side, |
| 17418 | 18012 | side, |
| 18013 | + write_w, | |
| 18014 | + write_h, | |
| 17419 | 18015 | h_filter, |
| 17420 | 18016 | v_filter, |
| 17421 | 18017 | &mut inter1_y, |
| @@ -17453,7 +18049,7 @@ fn decode_inter_block( | ||
| 17453 | 18049 | } |
| 17454 | 18050 | |
| 17455 | 18051 | let mut inter0_u = vec![0i32; chroma_side * chroma_side]; |
| 17456 | - mc::predict_compound_intermediate( | |
| 18052 | + mc::predict_compound_intermediate_kern( | |
| 17457 | 18053 | &pu0.data, |
| 17458 | 18054 | pu0.width, |
| 17459 | 18055 | pu0.true_width, |
| @@ -17463,6 +18059,8 @@ fn decode_inter_block( | ||
| 17463 | 18059 | scale0, |
| 17464 | 18060 | chroma_side, |
| 17465 | 18061 | chroma_side, |
| 18062 | + write_chroma_w, | |
| 18063 | + write_chroma_h, | |
| 17466 | 18064 | h_filter, |
| 17467 | 18065 | v_filter, |
| 17468 | 18066 | &mut inter0_u, |
| @@ -17480,7 +18078,7 @@ fn decode_inter_block( | ||
| 17480 | 18078 | } |
| 17481 | 18079 | } |
| 17482 | 18080 | let mut inter1_u = vec![0i32; chroma_side * chroma_side]; |
| 17483 | - mc::predict_compound_intermediate( | |
| 18081 | + mc::predict_compound_intermediate_kern( | |
| 17484 | 18082 | &pu1.data, |
| 17485 | 18083 | pu1.width, |
| 17486 | 18084 | pu1.true_width, |
| @@ -17490,6 +18088,8 @@ fn decode_inter_block( | ||
| 17490 | 18088 | scale1, |
| 17491 | 18089 | chroma_side, |
| 17492 | 18090 | chroma_side, |
| 18091 | + write_chroma_w, | |
| 18092 | + write_chroma_h, | |
| 17493 | 18093 | h_filter, |
| 17494 | 18094 | v_filter, |
| 17495 | 18095 | &mut inter1_u, |
| @@ -17523,7 +18123,7 @@ fn decode_inter_block( | ||
| 17523 | 18123 | } |
| 17524 | 18124 | |
| 17525 | 18125 | let mut inter0_v = vec![0i32; chroma_side * chroma_side]; |
| 17526 | - mc::predict_compound_intermediate( | |
| 18126 | + mc::predict_compound_intermediate_kern( | |
| 17527 | 18127 | &pv0.data, |
| 17528 | 18128 | pv0.width, |
| 17529 | 18129 | pv0.true_width, |
| @@ -17533,6 +18133,8 @@ fn decode_inter_block( | ||
| 17533 | 18133 | scale0, |
| 17534 | 18134 | chroma_side, |
| 17535 | 18135 | chroma_side, |
| 18136 | + write_chroma_w, | |
| 18137 | + write_chroma_h, | |
| 17536 | 18138 | h_filter, |
| 17537 | 18139 | v_filter, |
| 17538 | 18140 | &mut inter0_v, |
| @@ -17550,7 +18152,7 @@ fn decode_inter_block( | ||
| 17550 | 18152 | } |
| 17551 | 18153 | } |
| 17552 | 18154 | let mut inter1_v = vec![0i32; chroma_side * chroma_side]; |
| 17553 | - mc::predict_compound_intermediate( | |
| 18155 | + mc::predict_compound_intermediate_kern( | |
| 17554 | 18156 | &pv1.data, |
| 17555 | 18157 | pv1.width, |
| 17556 | 18158 | pv1.true_width, |
| @@ -17560,6 +18162,8 @@ fn decode_inter_block( | ||
| 17560 | 18162 | scale1, |
| 17561 | 18163 | chroma_side, |
| 17562 | 18164 | chroma_side, |
| 18165 | + write_chroma_w, | |
| 18166 | + write_chroma_h, | |
| 17563 | 18167 | h_filter, |
| 17564 | 18168 | v_filter, |
| 17565 | 18169 | &mut inter1_v, |
| @@ -17667,37 +18271,68 @@ fn decode_inter_block( | ||
| 17667 | 18271 | // own slice of the block's motion-compensated predictor. |
| 17668 | 18272 | let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get); |
| 17669 | 18273 | let mut first_tx_type = TxType::DctDct; |
| 17670 | - for (idx, &(row, col, tx_px)) in leaves.iter().enumerate() { | |
| 18274 | + for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() { | |
| 17671 | 18275 | let tu_mi = (at_mi.0 + row, at_mi.1 + col); |
| 17672 | 18276 | let (tu_px, tu_py) = (px + col * MI, py + row * MI); |
| 17673 | - let mut tu_pred = Vec::with_capacity(tx_px * tx_px); | |
| 17674 | - for rr in 0..tx_px { | |
| 17675 | - let start = (row * MI + rr) * side + col * MI; | |
| 17676 | - tu_pred.extend_from_slice(&pred_y[start..start + tx_px]); | |
| 17677 | - } | |
| 17678 | - let scan = default_scan(tx_px); | |
| 17679 | - let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI); | |
| 17680 | - let (tu_grid, tu_tx_type) = read_inter_plane( | |
| 17681 | - dec, | |
| 17682 | - cdfs, | |
| 17683 | - inter_txbset_for(tx_px, reduced), | |
| 17684 | - &scan, | |
| 17685 | - 0, | |
| 17686 | - neighbours.around_mi(tu_mi, tx_px)[0], | |
| 17687 | - mode_for_tx, | |
| 17688 | - y, | |
| 17689 | - tu_px, | |
| 17690 | - tu_py, | |
| 17691 | - tx_px, | |
| 17692 | - base_q_idx, | |
| 17693 | - &tu_pred, | |
| 17694 | - None, | |
| 17695 | - Some(tu_skip_ctx), | |
| 17696 | - )?; | |
| 18277 | + let (tu_grid, tu_tx_type) = if tw == th { | |
| 18278 | + let tx_px = tw; | |
| 18279 | + let mut tu_pred = Vec::with_capacity(tx_px * tx_px); | |
| 18280 | + for rr in 0..tx_px { | |
| 18281 | + let start = (row * MI + rr) * side + col * MI; | |
| 18282 | + tu_pred.extend_from_slice(&pred_y[start..start + tx_px]); | |
| 18283 | + } | |
| 18284 | + let scan = default_scan(tx_px); | |
| 18285 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI); | |
| 18286 | + read_inter_plane( | |
| 18287 | + dec, | |
| 18288 | + cdfs, | |
| 18289 | + inter_txbset_for(tx_px, reduced), | |
| 18290 | + &scan, | |
| 18291 | + 0, | |
| 18292 | + neighbours.around_mi(tu_mi, tx_px)[0], | |
| 18293 | + mode_for_tx, | |
| 18294 | + y, | |
| 18295 | + tu_px, | |
| 18296 | + tu_py, | |
| 18297 | + tx_px, | |
| 18298 | + base_q_idx, | |
| 18299 | + &tu_pred, | |
| 18300 | + None, | |
| 18301 | + Some(tu_skip_ctx), | |
| 18302 | + )? | |
| 18303 | + } else { | |
| 18304 | + // lane-r14 r3: a 1:4 strip's `sub_tx_size_map` | |
| 18305 | + // sub-transform is RECTANGULAR (TX_64X16 -> | |
| 18306 | + // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is | |
| 18307 | + // read with the rect coefficient machinery, at its | |
| 18308 | + // own `txb_skip_ctx`/neighbour spans -- the unit is | |
| 18309 | + // smaller than its block, so `get_txb_ctx_general`'s | |
| 18310 | + // neighbour table applies, not the lone-TU 0. | |
| 18311 | + vartx_rect_leaf_hit(tw, th); | |
| 18312 | + let tu_skip_ctx = | |
| 18313 | + neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI); | |
| 18314 | + let start = row * MI * side + col * MI; | |
| 18315 | + read_inter_plane_rect( | |
| 18316 | + dec, | |
| 18317 | + cdfs, | |
| 18318 | + rect_inter_luma_set(tw, th), | |
| 18319 | + (tw, th), | |
| 18320 | + side, | |
| 18321 | + 0, | |
| 18322 | + neighbours.around_mi_rect(tu_mi, tw, th)[0], | |
| 18323 | + mode_for_tx, | |
| 18324 | + y, | |
| 18325 | + tu_px, | |
| 18326 | + tu_py, | |
| 18327 | + &pred_y[start..], | |
| 18328 | + None, | |
| 18329 | + Some(tu_skip_ctx), | |
| 18330 | + )? | |
| 18331 | + }; | |
| 17697 | 18332 | if idx == 0 { |
| 17698 | 18333 | first_tx_type = tu_tx_type; |
| 17699 | 18334 | } |
| 17700 | - neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid); | |
| 18335 | + neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid); | |
| 17701 | 18336 | } |
| 17702 | 18337 | // `av1_get_tx_type`'s chroma lookup scales the chroma |
| 17703 | 18338 | // position back to luma, so an inter block's chroma |
| @@ -17721,6 +18356,7 @@ fn decode_inter_block( | ||
| 17721 | 18356 | py, |
| 17722 | 18357 | &pred_y, |
| 17723 | 18358 | None, |
| 18359 | + None, | |
| 17724 | 18360 | )?; |
| 17725 | 18361 | luma_tx_type = tx_type; |
| 17726 | 18362 | luma_grid = embed_rect_grid(&grid, write_w, write_h, side); |
| @@ -17764,6 +18400,7 @@ fn decode_inter_block( | ||
| 17764 | 18400 | cpy, |
| 17765 | 18401 | &pred_u, |
| 17766 | 18402 | Some(luma_tx_type), |
| 18403 | + None, | |
| 17767 | 18404 | )? |
| 17768 | 18405 | .0, |
| 17769 | 18406 | uw, |
| @@ -17785,6 +18422,7 @@ fn decode_inter_block( | ||
| 17785 | 18422 | cpy, |
| 17786 | 18423 | &pred_v, |
| 17787 | 18424 | Some(luma_tx_type), |
| 18425 | + None, | |
| 17788 | 18426 | )? |
| 17789 | 18427 | .0, |
| 17790 | 18428 | uw, |
| @@ -18413,7 +19051,7 @@ fn decode_inter_block( | ||
| 18413 | 19051 | let mut pred_u = vec![0u16; chroma_side * chroma_side]; |
| 18414 | 19052 | let mut pred_v = vec![0u16; chroma_side * chroma_side]; |
| 18415 | 19053 | if luma_scale == mc::REF_NO_SCALE { |
| 18416 | - mc::predict_with_filters( | |
| 19054 | + mc::predict_with_filters_kern( | |
| 18417 | 19055 | &py_ref.data, |
| 18418 | 19056 | py_ref.width, |
| 18419 | 19057 | py_ref.true_width, |
| @@ -18422,11 +19060,13 @@ fn decode_inter_block( | ||
| 18422 | 19060 | mv_to_q4(py, mv.0, true), |
| 18423 | 19061 | side, |
| 18424 | 19062 | side, |
| 19063 | + write_w, | |
| 19064 | + write_h, | |
| 18425 | 19065 | h_filter, |
| 18426 | 19066 | v_filter, |
| 18427 | 19067 | &mut pred_y, |
| 18428 | 19068 | ); |
| 18429 | - mc::predict_with_filters( | |
| 19069 | + mc::predict_with_filters_kern( | |
| 18430 | 19070 | &pu_ref.data, |
| 18431 | 19071 | pu_ref.width, |
| 18432 | 19072 | pu_ref.true_width, |
| @@ -18435,11 +19075,13 @@ fn decode_inter_block( | ||
| 18435 | 19075 | mv_to_q4(cpy, mv.0, false), |
| 18436 | 19076 | chroma_side, |
| 18437 | 19077 | chroma_side, |
| 19078 | + write_chroma_w, | |
| 19079 | + write_chroma_h, | |
| 18438 | 19080 | h_filter, |
| 18439 | 19081 | v_filter, |
| 18440 | 19082 | &mut pred_u, |
| 18441 | 19083 | ); |
| 18442 | - mc::predict_with_filters( | |
| 19084 | + mc::predict_with_filters_kern( | |
| 18443 | 19085 | &pv_ref.data, |
| 18444 | 19086 | pv_ref.width, |
| 18445 | 19087 | pv_ref.true_width, |
| @@ -18448,12 +19090,14 @@ fn decode_inter_block( | ||
| 18448 | 19090 | mv_to_q4(cpy, mv.0, false), |
| 18449 | 19091 | chroma_side, |
| 18450 | 19092 | chroma_side, |
| 19093 | + write_chroma_w, | |
| 19094 | + write_chroma_h, | |
| 18451 | 19095 | h_filter, |
| 18452 | 19096 | v_filter, |
| 18453 | 19097 | &mut pred_v, |
| 18454 | 19098 | ); |
| 18455 | 19099 | } else { |
| 18456 | - mc::predict_scaled( | |
| 19100 | + mc::predict_scaled_kern( | |
| 18457 | 19101 | &py_ref.data, |
| 18458 | 19102 | py_ref.width, |
| 18459 | 19103 | py_ref.true_width, |
| @@ -18463,11 +19107,13 @@ fn decode_inter_block( | ||
| 18463 | 19107 | luma_scale, |
| 18464 | 19108 | side, |
| 18465 | 19109 | side, |
| 19110 | + write_w, | |
| 19111 | + write_h, | |
| 18466 | 19112 | h_filter, |
| 18467 | 19113 | v_filter, |
| 18468 | 19114 | &mut pred_y, |
| 18469 | 19115 | ); |
| 18470 | - mc::predict_scaled( | |
| 19116 | + mc::predict_scaled_kern( | |
| 18471 | 19117 | &pu_ref.data, |
| 18472 | 19118 | pu_ref.width, |
| 18473 | 19119 | pu_ref.true_width, |
| @@ -18477,11 +19123,13 @@ fn decode_inter_block( | ||
| 18477 | 19123 | luma_scale, |
| 18478 | 19124 | chroma_side, |
| 18479 | 19125 | chroma_side, |
| 19126 | + write_chroma_w, | |
| 19127 | + write_chroma_h, | |
| 18480 | 19128 | h_filter, |
| 18481 | 19129 | v_filter, |
| 18482 | 19130 | &mut pred_u, |
| 18483 | 19131 | ); |
| 18484 | - mc::predict_scaled( | |
| 19132 | + mc::predict_scaled_kern( | |
| 18485 | 19133 | &pv_ref.data, |
| 18486 | 19134 | pv_ref.width, |
| 18487 | 19135 | pv_ref.true_width, |
| @@ -18491,6 +19139,8 @@ fn decode_inter_block( | ||
| 18491 | 19139 | luma_scale, |
| 18492 | 19140 | chroma_side, |
| 18493 | 19141 | chroma_side, |
| 19142 | + write_chroma_w, | |
| 19143 | + write_chroma_h, | |
| 18494 | 19144 | h_filter, |
| 18495 | 19145 | v_filter, |
| 18496 | 19146 | &mut pred_v, |
| @@ -18645,37 +19295,68 @@ fn decode_inter_block( | ||
| 18645 | 19295 | // own slice of the block's motion-compensated predictor. |
| 18646 | 19296 | let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get); |
| 18647 | 19297 | let mut first_tx_type = TxType::DctDct; |
| 18648 | - for (idx, &(row, col, tx_px)) in leaves.iter().enumerate() { | |
| 19298 | + for (idx, &(row, col, tw, th)) in leaves.iter().enumerate() { | |
| 18649 | 19299 | let tu_mi = (at_mi.0 + row, at_mi.1 + col); |
| 18650 | 19300 | let (tu_px, tu_py) = (px + col * MI, py + row * MI); |
| 18651 | - let mut tu_pred = Vec::with_capacity(tx_px * tx_px); | |
| 18652 | - for rr in 0..tx_px { | |
| 18653 | - let start = (row * MI + rr) * side + col * MI; | |
| 18654 | - tu_pred.extend_from_slice(&pred_y[start..start + tx_px]); | |
| 18655 | - } | |
| 18656 | - let scan = default_scan(tx_px); | |
| 18657 | - let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI); | |
| 18658 | - let (tu_grid, tu_tx_type) = read_inter_plane( | |
| 18659 | - dec, | |
| 18660 | - cdfs, | |
| 18661 | - inter_txbset_for(tx_px, reduced), | |
| 18662 | - &scan, | |
| 18663 | - 0, | |
| 18664 | - neighbours.around_mi(tu_mi, tx_px)[0], | |
| 18665 | - mode_for_tx, | |
| 18666 | - y, | |
| 18667 | - tu_px, | |
| 18668 | - tu_py, | |
| 18669 | - tx_px, | |
| 18670 | - base_q_idx, | |
| 18671 | - &tu_pred, | |
| 18672 | - None, | |
| 18673 | - Some(tu_skip_ctx), | |
| 18674 | - )?; | |
| 19301 | + let (tu_grid, tu_tx_type) = if tw == th { | |
| 19302 | + let tx_px = tw; | |
| 19303 | + let mut tu_pred = Vec::with_capacity(tx_px * tx_px); | |
| 19304 | + for rr in 0..tx_px { | |
| 19305 | + let start = (row * MI + rr) * side + col * MI; | |
| 19306 | + tu_pred.extend_from_slice(&pred_y[start..start + tx_px]); | |
| 19307 | + } | |
| 19308 | + let scan = default_scan(tx_px); | |
| 19309 | + let tu_skip_ctx = neighbours.luma_skip_ctx(tu_mi, tx_px / MI); | |
| 19310 | + read_inter_plane( | |
| 19311 | + dec, | |
| 19312 | + cdfs, | |
| 19313 | + inter_txbset_for(tx_px, reduced), | |
| 19314 | + &scan, | |
| 19315 | + 0, | |
| 19316 | + neighbours.around_mi(tu_mi, tx_px)[0], | |
| 19317 | + mode_for_tx, | |
| 19318 | + y, | |
| 19319 | + tu_px, | |
| 19320 | + tu_py, | |
| 19321 | + tx_px, | |
| 19322 | + base_q_idx, | |
| 19323 | + &tu_pred, | |
| 19324 | + None, | |
| 19325 | + Some(tu_skip_ctx), | |
| 19326 | + )? | |
| 19327 | + } else { | |
| 19328 | + // lane-r14 r3: a 1:4 strip's `sub_tx_size_map` | |
| 19329 | + // sub-transform is RECTANGULAR (TX_64X16 -> | |
| 19330 | + // TX_32X16, TX_16X64 -> TX_16X32), so this leaf is | |
| 19331 | + // read with the rect coefficient machinery, at its | |
| 19332 | + // own `txb_skip_ctx`/neighbour spans -- the unit is | |
| 19333 | + // smaller than its block, so `get_txb_ctx_general`'s | |
| 19334 | + // neighbour table applies, not the lone-TU 0. | |
| 19335 | + vartx_rect_leaf_hit(tw, th); | |
| 19336 | + let tu_skip_ctx = | |
| 19337 | + neighbours.luma_skip_ctx_rect(tu_mi, tw / MI, th / MI); | |
| 19338 | + let start = row * MI * side + col * MI; | |
| 19339 | + read_inter_plane_rect( | |
| 19340 | + dec, | |
| 19341 | + cdfs, | |
| 19342 | + rect_inter_luma_set(tw, th), | |
| 19343 | + (tw, th), | |
| 19344 | + side, | |
| 19345 | + 0, | |
| 19346 | + neighbours.around_mi_rect(tu_mi, tw, th)[0], | |
| 19347 | + mode_for_tx, | |
| 19348 | + y, | |
| 19349 | + tu_px, | |
| 19350 | + tu_py, | |
| 19351 | + &pred_y[start..], | |
| 19352 | + None, | |
| 19353 | + Some(tu_skip_ctx), | |
| 19354 | + )? | |
| 19355 | + }; | |
| 18675 | 19356 | if idx == 0 { |
| 18676 | 19357 | first_tx_type = tu_tx_type; |
| 18677 | 19358 | } |
| 18678 | - neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid); | |
| 19359 | + neighbours.record_mi_luma_rect(tu_mi, tw, th, &tu_grid); | |
| 18679 | 19360 | } |
| 18680 | 19361 | // `av1_get_tx_type`'s chroma lookup scales the chroma |
| 18681 | 19362 | // position back to luma, so an inter block's chroma |
| @@ -18699,6 +19380,7 @@ fn decode_inter_block( | ||
| 18699 | 19380 | py, |
| 18700 | 19381 | &pred_y, |
| 18701 | 19382 | None, |
| 19383 | + None, | |
| 18702 | 19384 | )?; |
| 18703 | 19385 | luma_tx_type = tx_type; |
| 18704 | 19386 | luma_grid = embed_rect_grid(&grid, write_w, write_h, side); |
| @@ -18742,6 +19424,7 @@ fn decode_inter_block( | ||
| 18742 | 19424 | cpy, |
| 18743 | 19425 | &pred_u, |
| 18744 | 19426 | Some(luma_tx_type), |
| 19427 | + None, | |
| 18745 | 19428 | )? |
| 18746 | 19429 | .0, |
| 18747 | 19430 | uw, |
| @@ -18763,6 +19446,7 @@ fn decode_inter_block( | ||
| 18763 | 19446 | cpy, |
| 18764 | 19447 | &pred_v, |
| 18765 | 19448 | Some(luma_tx_type), |
| 19449 | + None, | |
| 18766 | 19450 | )? |
| 18767 | 19451 | .0, |
| 18768 | 19452 | uw, |
| @@ -18877,6 +19561,12 @@ fn decode_inter_block( | ||
| 18877 | 19561 | return Ok(()); |
| 18878 | 19562 | } |
| 18879 | 19563 | let mode = dec.symbol(&mut cdfs.y_mode[size_group_wh(write_w, write_h)]); |
| 19564 | + if std::env::var_os("EC_IIS").is_some() { | |
| 19565 | + eprintln!( | |
| 19566 | + "TRACE iis px={px} py={py} side={side} w={write_w} h={write_h} sg={} mode={mode} skip={skip}", | |
| 19567 | + size_group_wh(write_w, write_h) | |
| 19568 | + ); | |
| 19569 | + } | |
| 18880 | 19570 | if mode >= 13 { |
| 18881 | 19571 | return Err(unsupported( |
| 18882 | 19572 | "an intra mode this decoder does not code (round 2)", |
| @@ -18905,13 +19595,27 @@ fn decode_inter_block( | ||
| 18905 | 19595 | // directional intra-in-inter block was refused above. |
| 18906 | 19596 | let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left(r, c); |
| 18907 | 19597 | let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); |
| 18908 | - let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]); | |
| 18909 | - if (9..=12).contains(&uv_mode) { | |
| 19598 | + // lane-sbrect10 r1 (class wrong-alphabet-same-value, second instance | |
| 19599 | + // after lane-sbpart r3's rect strips): `is_cfl_allowed` (libaom | |
| 19600 | + // `blockd.h` -- `block_size_wide[bsize] <= 32 && block_size_high[bsize] | |
| 19601 | + // <= 32`, spec 5.11.5) caps CFL at 32x32, so a 64x64 intra block inside | |
| 19602 | + // an INTER frame reads the 13-symbol `uv_mode_no_cfl` alphabet. Reading | |
| 19603 | + // the 14-symbol CFL one gave the same DC_PRED VALUE but narrowed the | |
| 19604 | + // arithmetic coder by the wrong interval, desyncing the tile from this | |
| 19605 | + // block on. | |
| 19606 | + let cfl_allowed = write_w.max(write_h) <= 32; | |
| 19607 | + if !cfl_allowed { | |
| 19608 | + NOCFL_UV_MODE_HITS.with(|c| c.set(c.get() + 1)); | |
| 19609 | + } | |
| 19610 | + let uv_mode = if cfl_allowed { | |
| 19611 | + dec.symbol(&mut cdfs.uv_mode_cfl[mode]) | |
| 19612 | + } else { | |
| 19613 | + dec.symbol(&mut cdfs.uv_mode_no_cfl[mode]) | |
| 19614 | + }; | |
| 19615 | + if (9..=12).contains(&uv_mode) { | |
| 18910 | 19616 | SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); |
| 18911 | 19617 | } |
| 18912 | - let alpha = if uv_mode == DC_PRED { | |
| 18913 | - None | |
| 18914 | - } else if uv_mode == UV_CFL_PRED { | |
| 19618 | + let alpha = if cfl_allowed && uv_mode == UV_CFL_PRED { | |
| 18915 | 19619 | Some(read_cfl_alphas(dec, cdfs)) |
| 18916 | 19620 | } else { |
| 18917 | 19621 | None |
| @@ -19026,7 +19730,7 @@ fn decode_inter_block( | ||
| 19026 | 19730 | let split_luma = vartx_leaves.is_some(); |
| 19027 | 19731 | if let Some(leaves) = vartx_leaves.clone() { |
| 19028 | 19732 | let reduced = REDUCED_TX_SET_INTER.with(std::cell::Cell::get); |
| 19029 | - for &(row, col, tx_px) in &leaves { | |
| 19733 | + for &(row, col, tx_px, _) in &leaves { | |
| 19030 | 19734 | let tu_mi = (at_mi.0 + row, at_mi.1 + col); |
| 19031 | 19735 | let (tu_px, tu_py) = (px + col * MI, py + row * MI); |
| 19032 | 19736 | // A transform unit inside a block is not a block at that |
| @@ -19265,21 +19969,21 @@ fn decode_inter_block( | ||
| 19265 | 19969 | }, |
| 19266 | 19970 | ); |
| 19267 | 19971 | // lane-txselect: a var-tx block's deblock edges follow its own transform |
| 19268 | - // units, not the block. Chroma still reads `tx_h_grid / 2` (the block's | |
| 19269 | - // uv transform is not split) -- a known corner-cut of this round. | |
| 19972 | + // units, not the block -- for LUMA only (lane-golomb r6): the chroma | |
| 19973 | + // grids keep the block's own `av1_get_max_uv_txsize`, which is what | |
| 19974 | + // libaom's `get_transform_size` reads for `plane != AOM_PLANE_Y`. | |
| 19270 | 19975 | if let Some(leaves) = &vartx_leaves { |
| 19271 | - for &(row, col, tx_px) in leaves { | |
| 19272 | - neighbours.fill_lf_grid_rect( | |
| 19976 | + for &(row, col, tw, th) in leaves { | |
| 19977 | + // lane-r14's RECT leaf dims through lane-golomb r6's luma-only | |
| 19978 | + // writer: fill_lf_grid_rect would recompute CHROMA tx dims from | |
| 19979 | + // the leaf span, but libaom's `get_transform_size` splits only for | |
| 19980 | + // AOM_PLANE_Y (merge J, ledger constraint). | |
| 19981 | + neighbours.fill_lf_grid_leaf_luma( | |
| 19273 | 19982 | (at_mi.0 + row, at_mi.1 + col), |
| 19274 | - tx_px / MI, | |
| 19275 | - tx_px / MI, | |
| 19276 | - tx_px as u8, | |
| 19277 | - tx_px as u8, | |
| 19278 | - if globalmv_for_lf { | |
| 19279 | - -ref_frame_for_lf | |
| 19280 | - } else { | |
| 19281 | - ref_frame_for_lf | |
| 19282 | - }, | |
| 19983 | + tw / MI, | |
| 19984 | + th / MI, | |
| 19985 | + tw as u8, | |
| 19986 | + th as u8, | |
| 19283 | 19987 | ); |
| 19284 | 19988 | } |
| 19285 | 19989 | } |
| @@ -19520,21 +20224,24 @@ fn decode_inter_block8( | ||
| 19520 | 20224 | let (ref0, ref1) = if skip_mode { |
| 19521 | 20225 | (skip_mode_frame[0] as i8, skip_mode_frame[1] as i8) |
| 19522 | 20226 | } else { |
| 20227 | + // lane-interp3 r2 (class twin-functions-drift): this leaf | |
| 20228 | + // passed a hard-coded `LAST_FRAME` for every inter | |
| 20229 | + // neighbour -- the old "coarse LAST_FRAME-or-intra" | |
| 20230 | + // approximation -- while the side bands have carried the | |
| 20231 | + // neighbour's REAL reference per mi since lane-inter8 r2. | |
| 20232 | + // Every `av1_collect_neighbors_ref_counts` vote below | |
| 20233 | + // (`uni_comp_ref_p1`, `comp_ref`, `comp_bwdref`, ...) was | |
| 20234 | + // therefore taken off the wrong CDF row. Same two args | |
| 20235 | + // [`decode_inter_block`]'s own compound arm passes | |
| 20236 | + // (`-1` when the band is unavailable is start_tile's / | |
| 20237 | + // start_row's own reset value, so no `has_above` guard). | |
| 19523 | 20238 | read_compound_ref_frames( |
| 19524 | 20239 | dec, |
| 19525 | 20240 | cdfs, |
| 19526 | 20241 | above_nbr, |
| 19527 | 20242 | left_nbr, |
| 19528 | - if has_above && above_inter { | |
| 19529 | - LAST_FRAME | |
| 19530 | - } else { | |
| 19531 | - -1 | |
| 19532 | - }, | |
| 19533 | - if has_left && left_inter { | |
| 19534 | - LAST_FRAME | |
| 19535 | - } else { | |
| 19536 | - -1 | |
| 19537 | - }, | |
| 20243 | + above_ref0, | |
| 20244 | + left_ref0, | |
| 19538 | 20245 | ) |
| 19539 | 20246 | }; |
| 19540 | 20247 | leaf_refs = (ref0, Some(ref1)); |
| @@ -19715,6 +20422,58 @@ fn decode_inter_block8( | ||
| 19715 | 20422 | ); |
| 19716 | 20423 | } |
| 19717 | 20424 | |
| 20425 | + // lane-interp3 r1: `read_mb_interp_filter` (libaom | |
| 20426 | + // `decodemv.c` 1575, the tail of | |
| 20427 | + // `read_inter_block_mode_info`) runs for EVERY inter block, | |
| 20428 | + // compound included, right AFTER `read_compound_type` -- this | |
| 20429 | + // leaf read no filter symbol at all, so a SWITCHABLE-filter | |
| 20430 | + // stream lost one symbol (two under `enable_dual_filter`) at | |
| 20431 | + // every compound 8x8 leaf, and the leaf recorded the `[3, 3]` | |
| 20432 | + // "no filter" sentinel, which made a neighbouring OBMC block's | |
| 20433 | + // `neighbour_filter` PANIC instead of blending. | |
| 20434 | + // `av1_is_interp_needed` suppression terms for this arm: | |
| 20435 | + // `skip_mode`, and `is_nontrans_global_motion` (mode | |
| 20436 | + // GLOBAL_GLOBALMV with BOTH refs' models non-TRANSLATION) -- | |
| 20437 | + // WARPED_CAUSAL cannot occur on a compound block. | |
| 20438 | + let gm_nontrans_c = compound_mode == 6 | |
| 20439 | + && global_motion[(ref0 - LAST_FRAME) as usize].model | |
| 20440 | + != ec_av1_syntax::WarpModel::Translation | |
| 20441 | + && global_motion[(ref1 - LAST_FRAME) as usize].model | |
| 20442 | + != ec_av1_syntax::WarpModel::Translation; | |
| 20443 | + // spec `get_ref_filter_type`, keyed on this block's ref0 and | |
| 20444 | + // matching EITHER of the neighbour's references -- same shape | |
| 20445 | + // as [`decode_inter_block`]'s compound arm. Same corner-cut as | |
| 20446 | + // this leaf's single-ref arm below: the context comes from the | |
| 20447 | + // enclosing 16x16's coarse slot. | |
| 20448 | + let above_filter_ctx = if neighbours.above_ref[cmi] == ref0 | |
| 20449 | + || neighbours.above_ref1[cmi] == Some(ref0) | |
| 20450 | + { | |
| 20451 | + neighbours.above_filter[cmi] | |
| 20452 | + } else { | |
| 20453 | + [3, 3] | |
| 20454 | + }; | |
| 20455 | + let left_filter_ctx = if neighbours.left_ref[rmi] == ref0 | |
| 20456 | + || neighbours.left_ref1[rmi] == Some(ref0) | |
| 20457 | + { | |
| 20458 | + neighbours.left_filter[rmi] | |
| 20459 | + } else { | |
| 20460 | + [3, 3] | |
| 20461 | + }; | |
| 20462 | + let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( | |
| 20463 | + dec, | |
| 20464 | + cdfs, | |
| 20465 | + interp_fixed, | |
| 20466 | + enable_dual_filter, | |
| 20467 | + gm_nontrans_c || skip_mode, | |
| 20468 | + above_filter_ctx, | |
| 20469 | + left_filter_ctx, | |
| 20470 | + true, | |
| 20471 | + ); | |
| 20472 | + leaf_filter_syms = resolved_filter; | |
| 20473 | + if interp_fixed.is_none() && !(gm_nontrans_c || skip_mode) { | |
| 20474 | + COMPOUND8_FILTER_HITS.with(|c| c.set(c.get() + 1)); | |
| 20475 | + } | |
| 20476 | + | |
| 19718 | 20477 | let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?; |
| 19719 | 20478 | let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?; |
| 19720 | 20479 | let scale0 = mc::scale_factor(py0.width, frame_width); |
| @@ -19724,6 +20483,54 @@ fn decode_inter_block8( | ||
| 19724 | 20483 | SCALED_BLOCK8_HITS.with(|c| c.set(c.get() + 1)); |
| 19725 | 20484 | } |
| 19726 | 20485 | |
| 20486 | + // lane-interp3 r2 (class twin-functions-drift): both slots | |
| 20487 | + // used to be stamped `false`, while [`decode_inter_block`]'s | |
| 20488 | + // compound arm computes libaom's PER-SLOT `is_global_mv_block` | |
| 20489 | + // (blockd.h:421-429 -- mode GLOBAL_GLOBALMV, block >= 8x8 | |
| 20490 | + // (always true for this leaf) and THAT slot's own gm model > | |
| 20491 | + // TRANSLATION). A neighbour carrying the flag makes | |
| 20492 | + // `setup_ref_mv_list` substitute the READER's global mv for | |
| 20493 | + // the neighbour's stored one, so a cleared flag fed the next | |
| 20494 | + // block's stack a stored mv where libaom has the global | |
| 20495 | + // candidate -- a wrong mv stack, wrong mode contexts, and a | |
| 20496 | + // desync one block later. | |
| 20497 | + let is_globalmv_c = compound_mode == 6; | |
| 20498 | + let is_global_mv0_c = is_globalmv_c | |
| 20499 | + && global_motion[(ref0 - LAST_FRAME) as usize].model as u8 > 1; | |
| 20500 | + let is_global_mv1_c = is_globalmv_c | |
| 20501 | + && global_motion[(ref1 - LAST_FRAME) as usize].model as u8 > 1; | |
| 20502 | + // lane-interp3 r3 (class twin-functions-drift, second | |
| 20503 | + // instance): libaom applies `allow_warp`'s GLOBAL branch | |
| 20504 | + // (`reconinter.c:33-55`, reached from `av1_init_warp_params` | |
| 20505 | + // inside `build_inter_predictors_8x8_and_bigger`'s per-`ref` | |
| 20506 | + // loop) to EVERY `is_global_mv_block` slot, compound | |
| 20507 | + // included and independently of `motion_mode` -- the 16x16+ | |
| 20508 | + // compound arm has done this since lane-cwarp r1, this leaf | |
| 20509 | + // predicted both taps translationally, so a GLOBAL_GLOBALMV | |
| 20510 | + // 8x8 compound leaf under a non-TRANSLATION model drifted by | |
| 20511 | + // a few luma levels, growing away from the block origin. | |
| 20512 | + // `force_integer_mv` short-circuits `av1_init_warp_params` | |
| 20513 | + // before `allow_warp`; chroma is 4x4 here, below | |
| 20514 | + // `av1_init_warp_params`'s own 8px per-plane bound, so only | |
| 20515 | + // luma warps (same rule as this leaf's single-ref arm). | |
| 20516 | + let leaf_compound_warp = |ref_frame: i8, eligible: bool| { | |
| 20517 | + if eligible | |
| 20518 | + && !force_integer_mv | |
| 20519 | + && !global_motion[(ref_frame - LAST_FRAME) as usize].invalid | |
| 20520 | + { | |
| 20521 | + crate::warp::global_warp_params( | |
| 20522 | + global_motion[(ref_frame - LAST_FRAME) as usize].params, | |
| 20523 | + ) | |
| 20524 | + } else { | |
| 20525 | + None | |
| 20526 | + } | |
| 20527 | + }; | |
| 20528 | + let warp0_c = leaf_compound_warp(ref0, is_global_mv0_c); | |
| 20529 | + let warp1_c = leaf_compound_warp(ref1, is_global_mv1_c); | |
| 20530 | + if warp0_c.is_some() || warp1_c.is_some() { | |
| 20531 | + COMPOUND_WARP_HITS.with(|c| c.set(c.get() + 1)); | |
| 20532 | + COMPOUND_WARP_HITS_8.with(|c| c.set(c.get() + 1)); | |
| 20533 | + } | |
| 19727 | 20534 | for dr in 0..2 { |
| 19728 | 20535 | for dc in 0..2 { |
| 19729 | 20536 | grid.set( |
| @@ -19738,19 +20545,14 @@ fn decode_inter_block8( | ||
| 19738 | 20545 | is_new_mv: matches!(compound_mode, 2 | 3 | 4 | 5 | 7), |
| 19739 | 20546 | size: 2, |
| 19740 | 20547 | size_h: 2, |
| 19741 | - is_global_mv0: false, | |
| 19742 | - is_global_mv1: false, | |
| 20548 | + is_global_mv0: is_global_mv0_c, | |
| 20549 | + is_global_mv1: is_global_mv1_c, | |
| 19743 | 20550 | }, |
| 19744 | 20551 | ); |
| 19745 | 20552 | } |
| 19746 | 20553 | } |
| 19747 | 20554 | mode_for_tx = 0; |
| 19748 | 20555 | |
| 19749 | - // lane-av1comp corner-cut, matching this leaf's single-ref | |
| 19750 | - // arm below (`mc::predict`'s own fixed-Regular default): | |
| 19751 | - // `decode_inter_block8` never resolves a switchable filter, | |
| 19752 | - // so both compound taps use `Regular` too. | |
| 19753 | - use mc::InterpFilterKind::Regular; | |
| 19754 | 20556 | let mut inter0_y = vec![0i32; SIDE * SIDE]; |
| 19755 | 20557 | mc::predict_compound_intermediate( |
| 19756 | 20558 | &py0.data, |
| @@ -19762,10 +20564,17 @@ fn decode_inter_block8( | ||
| 19762 | 20564 | scale0, |
| 19763 | 20565 | SIDE, |
| 19764 | 20566 | SIDE, |
| 19765 | - Regular, | |
| 19766 | - Regular, | |
| 20567 | + h_filter, | |
| 20568 | + v_filter, | |
| 19767 | 20569 | &mut inter0_y, |
| 19768 | 20570 | ); |
| 20571 | + if let Some(wp) = &warp0_c { | |
| 20572 | + crate::warp::warp_affine_compound( | |
| 20573 | + wp, &py0.data, py0.true_width as i32, py0.true_height as i32, | |
| 20574 | + py0.width as i32, &mut inter0_y, px as i32, py as i32, SIDE as i32, | |
| 20575 | + SIDE as i32, SIDE as i32, 0, 0, | |
| 20576 | + ); | |
| 20577 | + } | |
| 19769 | 20578 | let mut inter1_y = vec![0i32; SIDE * SIDE]; |
| 19770 | 20579 | mc::predict_compound_intermediate( |
| 19771 | 20580 | &py1.data, |
| @@ -19777,10 +20586,17 @@ fn decode_inter_block8( | ||
| 19777 | 20586 | scale1, |
| 19778 | 20587 | SIDE, |
| 19779 | 20588 | SIDE, |
| 19780 | - Regular, | |
| 19781 | - Regular, | |
| 20589 | + h_filter, | |
| 20590 | + v_filter, | |
| 19782 | 20591 | &mut inter1_y, |
| 19783 | 20592 | ); |
| 20593 | + if let Some(wp) = &warp1_c { | |
| 20594 | + crate::warp::warp_affine_compound( | |
| 20595 | + wp, &py1.data, py1.true_width as i32, py1.true_height as i32, | |
| 20596 | + py1.width as i32, &mut inter1_y, px as i32, py as i32, SIDE as i32, | |
| 20597 | + SIDE as i32, SIDE as i32, 0, 0, | |
| 20598 | + ); | |
| 20599 | + } | |
| 19784 | 20600 | let mut pred_y = vec![0u16; SIDE * SIDE]; |
| 19785 | 20601 | let mut diffwtd_mask_y = Vec::new(); |
| 19786 | 20602 | let mask_y: Option<&[u8]> = if let Some(mask_type) = diffwtd_mask_type { |
| @@ -19810,8 +20626,8 @@ fn decode_inter_block8( | ||
| 19810 | 20626 | scale0, |
| 19811 | 20627 | CHROMA_SIDE, |
| 19812 | 20628 | CHROMA_SIDE, |
| 19813 | - Regular, | |
| 19814 | - Regular, | |
| 20629 | + h_filter, | |
| 20630 | + v_filter, | |
| 19815 | 20631 | &mut inter0_u, |
| 19816 | 20632 | ); |
| 19817 | 20633 | let mut inter1_u = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; |
| @@ -19825,8 +20641,8 @@ fn decode_inter_block8( | ||
| 19825 | 20641 | scale1, |
| 19826 | 20642 | CHROMA_SIDE, |
| 19827 | 20643 | CHROMA_SIDE, |
| 19828 | - Regular, | |
| 19829 | - Regular, | |
| 20644 | + h_filter, | |
| 20645 | + v_filter, | |
| 19830 | 20646 | &mut inter1_u, |
| 19831 | 20647 | ); |
| 19832 | 20648 | let mut pred_u = vec![0u16; CHROMA_SIDE * CHROMA_SIDE]; |
| @@ -19856,8 +20672,8 @@ fn decode_inter_block8( | ||
| 19856 | 20672 | scale0, |
| 19857 | 20673 | CHROMA_SIDE, |
| 19858 | 20674 | CHROMA_SIDE, |
| 19859 | - Regular, | |
| 19860 | - Regular, | |
| 20675 | + h_filter, | |
| 20676 | + v_filter, | |
| 19861 | 20677 | &mut inter0_v, |
| 19862 | 20678 | ); |
| 19863 | 20679 | let mut inter1_v = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; |
| @@ -19871,8 +20687,8 @@ fn decode_inter_block8( | ||
| 19871 | 20687 | scale1, |
| 19872 | 20688 | CHROMA_SIDE, |
| 19873 | 20689 | CHROMA_SIDE, |
| 19874 | - Regular, | |
| 19875 | - Regular, | |
| 20690 | + h_filter, | |
| 20691 | + v_filter, | |
| 19876 | 20692 | &mut inter1_v, |
| 19877 | 20693 | ); |
| 19878 | 20694 | let mut pred_v = vec![0u16; CHROMA_SIDE * CHROMA_SIDE]; |
| @@ -19988,6 +20804,14 @@ fn decode_inter_block8( | ||
| 19988 | 20804 | // so the 16x16 below a split block read partition ctx 0 |
| 19989 | 20805 | // instead of 1 and mis-read PARTITION_SPLIT as NONE. |
| 19990 | 20806 | neighbours.record_mi(leaf_mi, 8, &[luma_grid, u_grid, v_grid]); |
| 20807 | + // lane-cdef r1: ... and the CDEF skip band too. `apply_cdef`'s | |
| 20808 | + // `is_8x8_block_skip` (libaom `cdef.c:29-38`) reads all four mi | |
| 20809 | + // cells of the 8x8; this leaf wrote none of them, so a 64x64 | |
| 20810 | + // whose bottom-right 16x16 is an all-skip 8x8-leaf group kept | |
| 20811 | + // the PREVIOUS frame's flags and got filtered where libaom's | |
| 20812 | + // dlist excludes it (3 luma samples on a 192x128 inter frame). | |
| 20813 | + INTER8_SKIP_BAND_HITS.with(|c| c.set(c.get() + 1)); | |
| 20814 | + neighbours.fill_skip_grid(leaf_mi, 2, skip); | |
| 19991 | 20815 | neighbours.fill_lf_grid( |
| 19992 | 20816 | leaf_mi, |
| 19993 | 20817 | 2, |
| @@ -20046,6 +20870,17 @@ fn decode_inter_block8( | ||
| 20046 | 20870 | &gm_table, |
| 20047 | 20871 | tpl, |
| 20048 | 20872 | ); |
| 20873 | + // lane-interp3 r2: same per-entry EC_STACK ladder | |
| 20874 | + // [`decode_inter_block`]'s single-ref arm prints, so this leaf's stack | |
| 20875 | + // diffs line for line against the oracle's. | |
| 20876 | + if std::env::var_os("EC_TRACE_MODE").is_some() { | |
| 20877 | + for (i, e) in stack.entries.iter().enumerate() { | |
| 20878 | + eprintln!( | |
| 20879 | + "EC_STACK mi_row={mi_row} mi_col={mi_col} ref={ref_frame} i={i} this=({},{}) comp=(0,0) w={}", | |
| 20880 | + e.mv.0, e.mv.1, e.weight | |
| 20881 | + ); | |
| 20882 | + } | |
| 20883 | + } | |
| 20049 | 20884 | |
| 20050 | 20885 | let not_new = dec.symbol(&mut cdfs.new_mv[stack.new_mv_ctx]) == 1; |
| 20051 | 20886 | let mut is_globalmv = false; |
| @@ -20793,6 +21628,10 @@ fn decode_inter_block8( | ||
| 20793 | 21628 | // lane-gmaffine r2: the deblock grid's ref id is the leaf's OWN reference |
| 20794 | 21629 | // (r1 taught this leaf non-LAST refs; the hardcoded LAST_FRAME made every |
| 20795 | 21630 | // GOLDEN/ALTREF leaf read as LAST at the loop-filter's ref/mv edge test). |
| 21631 | + // lane-cdef r1: the fall-through twin of the compound arm's skip-band | |
| 21632 | + // write above -- `skip` is one flag for the whole 8x8 leaf (read at | |
| 21633 | + // `decode.rs`'s `skip_ctx` site), `split8` only splits its transform. | |
| 21634 | + neighbours.fill_skip_grid(leaf_mi, 2, skip); | |
| 20796 | 21635 | neighbours.fill_lf_grid( |
| 20797 | 21636 | leaf_mi, |
| 20798 | 21637 | 2, |
crates/ec-av1/src/gate_coverage.rsmodified+0 -5
| @@ -168,10 +168,6 @@ const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[ | ||
| 168 | 168 | "enable-rect-tx", |
| 169 | 169 | "never spelled; rect transforms reach the decoder only through partition shape, never through a gate that names the tool", |
| 170 | 170 | ), |
| 171 | - ( | |
| 172 | - "enable-tx64", | |
| 173 | - "never spelled; TX_64X64 appears only where aomenc's default picks it, which is unknown per stream", | |
| 174 | - ), | |
| 175 | 171 | ]; |
| 176 | 172 | |
| 177 | 173 | #[cfg(test)] |
| @@ -214,7 +210,6 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ // lane-cwarp's 10-bit comp | ||
| 214 | 210 | // decoded and pixel-compared at 10 bit as well as 8, so the tool reaches a |
| 215 | 211 | // real 10-bit stream this decoder reconstructs exactly. |
| 216 | 212 | ("enable-rect-tx", "hole at both depths, see the 8-bit list"), |
| 217 | - ("enable-tx64", "hole at both depths, see the 8-bit list"), | |
| 218 | 213 | ]; |
| 219 | 214 | |
| 220 | 215 | /// [`DEFAULT_ON_TOOLS`] entries no 8-bit gate spells on, with the reason. |
crates/ec-av1/src/mc.rsmodified+117 -5
| @@ -333,6 +333,36 @@ pub fn predict_with_filters( | ||
| 333 | 333 | h_kind: InterpFilterKind, |
| 334 | 334 | v_kind: InterpFilterKind, |
| 335 | 335 | dst: &mut [u16], |
| 336 | +) { | |
| 337 | + predict_with_filters_kern( | |
| 338 | + reference, stride, true_width, true_height, x_q4, y_q4, block_w, | |
| 339 | + block_h, block_w, block_h, h_kind, v_kind, dst, | |
| 340 | + ); | |
| 341 | +} | |
| 342 | + | |
| 343 | +/// [`predict_with_filters`] with the 4-tap decision taken from the block's | |
| 344 | +/// TRUE width/height (`kern_w`/`kern_h`) rather than the destination buffer's. | |
| 345 | +/// libaom's `av1_get_interp_filter_params_with_block_size` (reconinter.h, | |
| 346 | +/// called per axis from `inter_predictor` with `w` then `h`) picks the narrow | |
| 347 | +/// kernel from the PREDICTION block's own dimensions; our inter path predicts | |
| 348 | +/// a rectangular block over its enclosing square buffer, so a rect block whose | |
| 349 | +/// chroma is 4 wide or 4 tall (luma 8x16 / 16x8 and taller kin) must still ask | |
| 350 | +/// for the 4-tap kernel on that axis -- lane-rectchroma2 r1. | |
| 351 | +#[allow(clippy::too_many_arguments)] | |
| 352 | +pub fn predict_with_filters_kern( | |
| 353 | + reference: &[u16], | |
| 354 | + stride: usize, | |
| 355 | + true_width: usize, | |
| 356 | + true_height: usize, | |
| 357 | + x_q4: i32, | |
| 358 | + y_q4: i32, | |
| 359 | + block_w: usize, | |
| 360 | + block_h: usize, | |
| 361 | + kern_w: usize, | |
| 362 | + kern_h: usize, | |
| 363 | + h_kind: InterpFilterKind, | |
| 364 | + v_kind: InterpFilterKind, | |
| 365 | + dst: &mut [u16], | |
| 336 | 366 | ) { |
| 337 | 367 | assert_eq!(dst.len(), block_w * block_h, "the destination is the block"); |
| 338 | 368 | assert!(!reference.is_empty(), "a reference plane has samples"); |
| @@ -374,12 +404,13 @@ pub fn predict_with_filters( | ||
| 374 | 404 | |
| 375 | 405 | let (h_wide, h_narrow) = h_kind.tables(); |
| 376 | 406 | let (v_wide, v_narrow) = v_kind.tables(); |
| 377 | - let h_filter = if block_w <= 4 { | |
| 407 | + note_narrow_kern(block_w, block_h, kern_w, kern_h); | |
| 408 | + let h_filter = if kern_w <= 4 { | |
| 378 | 409 | &h_narrow[xfrac] |
| 379 | 410 | } else { |
| 380 | 411 | &h_wide[xfrac] |
| 381 | 412 | }; |
| 382 | - let v_filter = if block_h <= 4 { | |
| 413 | + let v_filter = if kern_h <= 4 { | |
| 383 | 414 | &v_narrow[yfrac] |
| 384 | 415 | } else { |
| 385 | 416 | &v_wide[yfrac] |
| @@ -452,6 +483,32 @@ thread_local! { | ||
| 452 | 483 | /// only intra blocks cannot pass it by construction (class |
| 453 | 484 | /// `gate-blind-to-feature`). |
| 454 | 485 | static INTER_PRED_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; |
| 486 | + | |
| 487 | + /// lane-rectchroma2 r1: how often the 4-tap decision came out DIFFERENT | |
| 488 | + /// from what the destination buffer's own dimensions would have given -- | |
| 489 | + /// i.e. how often a rectangular block predicted over its enclosing square | |
| 490 | + /// buffer asked for libaom's narrow kernel on an axis. Zero means a gate | |
| 491 | + /// never exercised the rect-chroma shape at all. | |
| 492 | + static RECT_NARROW_KERN_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | |
| 493 | +} | |
| 494 | + | |
| 495 | +/// Current value of [`RECT_NARROW_KERN_HITS`]. | |
| 496 | +pub fn rect_narrow_kern_hits() -> usize { | |
| 497 | + RECT_NARROW_KERN_HITS.with(|c| c.get()) | |
| 498 | +} | |
| 499 | + | |
| 500 | +/// Resets [`RECT_NARROW_KERN_HITS`] (per-attempt counting, class | |
| 501 | +/// `counter-from-refused-stream`). | |
| 502 | +pub fn reset_rect_narrow_kern_hits() { | |
| 503 | + RECT_NARROW_KERN_HITS.with(|c| c.set(0)); | |
| 504 | +} | |
| 505 | + | |
| 506 | +/// Bumps [`RECT_NARROW_KERN_HITS`] when the block's true dims pick a kernel | |
| 507 | +/// the destination buffer's dims would not have. | |
| 508 | +fn note_narrow_kern(block_w: usize, block_h: usize, kern_w: usize, kern_h: usize) { | |
| 509 | + if (kern_w <= 4) != (block_w <= 4) || (kern_h <= 4) != (block_h <= 4) { | |
| 510 | + RECT_NARROW_KERN_HITS.with(|c| c.set(c.get() + 1)); | |
| 511 | + } | |
| 455 | 512 | } |
| 456 | 513 | |
| 457 | 514 | /// Current value of [`INTER_PRED_HITS`]. |
| @@ -498,6 +555,7 @@ fn horizontal_scaled_pass( | ||
| 498 | 555 | y0: i32, |
| 499 | 556 | x_scale_fp: i64, |
| 500 | 557 | block_w: usize, |
| 558 | + kern_w: usize, | |
| 501 | 559 | rows: usize, |
| 502 | 560 | h_kind: InterpFilterKind, |
| 503 | 561 | intermediate: &mut [i32], |
| @@ -510,7 +568,7 @@ fn horizontal_scaled_pass( | ||
| 510 | 568 | let x_qn = pos_x_q10 + c as i64 * x_step_qn; |
| 511 | 569 | let int_pel = (x_qn >> 10) as i32; |
| 512 | 570 | let filter_idx = ((x_qn & 1023) >> 6) as usize; |
| 513 | - let h_filter = if block_w <= 4 { | |
| 571 | + let h_filter = if kern_w <= 4 { | |
| 514 | 572 | &h_narrow[filter_idx] |
| 515 | 573 | } else { |
| 516 | 574 | &h_wide[filter_idx] |
| @@ -555,6 +613,31 @@ pub fn predict_scaled( | ||
| 555 | 613 | h_kind: InterpFilterKind, |
| 556 | 614 | v_kind: InterpFilterKind, |
| 557 | 615 | dst: &mut [u16], |
| 616 | +) { | |
| 617 | + predict_scaled_kern( | |
| 618 | + reference, stride, true_width, true_height, x_q4, y_q4, x_scale_fp, | |
| 619 | + block_w, block_h, block_w, block_h, h_kind, v_kind, dst, | |
| 620 | + ); | |
| 621 | +} | |
| 622 | + | |
| 623 | +/// [`predict_scaled`] with the 4-tap decision from the block's true dims | |
| 624 | +/// (see [`predict_with_filters_kern`]). | |
| 625 | +#[allow(clippy::too_many_arguments)] | |
| 626 | +pub fn predict_scaled_kern( | |
| 627 | + reference: &[u16], | |
| 628 | + stride: usize, | |
| 629 | + true_width: usize, | |
| 630 | + true_height: usize, | |
| 631 | + x_q4: i32, | |
| 632 | + y_q4: i32, | |
| 633 | + x_scale_fp: i64, | |
| 634 | + block_w: usize, | |
| 635 | + block_h: usize, | |
| 636 | + kern_w: usize, | |
| 637 | + kern_h: usize, | |
| 638 | + h_kind: InterpFilterKind, | |
| 639 | + v_kind: InterpFilterKind, | |
| 640 | + dst: &mut [u16], | |
| 558 | 641 | ) { |
| 559 | 642 | assert_eq!(dst.len(), block_w * block_h, "the destination is the block"); |
| 560 | 643 | assert!(!reference.is_empty(), "a reference plane has samples"); |
| @@ -568,7 +651,8 @@ pub fn predict_scaled( | ||
| 568 | 651 | // Q10; off/pos_x_q10 fold the block's own x_q4 (Q4) into that same Q10 |
| 569 | 652 | // grid (spec 7.11.3.3's `dec_calc_subpel_params`). |
| 570 | 653 | let (v_wide, v_narrow) = v_kind.tables(); |
| 571 | - let v_filter = if block_h <= 4 { | |
| 654 | + note_narrow_kern(block_w, block_h, kern_w, kern_h); | |
| 655 | + let v_filter = if kern_h <= 4 { | |
| 572 | 656 | &v_narrow[yfrac] |
| 573 | 657 | } else { |
| 574 | 658 | &v_wide[yfrac] |
| @@ -585,6 +669,7 @@ pub fn predict_scaled( | ||
| 585 | 669 | y0, |
| 586 | 670 | x_scale_fp, |
| 587 | 671 | block_w, |
| 672 | + kern_w, | |
| 588 | 673 | rows, |
| 589 | 674 | h_kind, |
| 590 | 675 | &mut intermediate, |
| @@ -648,6 +733,31 @@ pub fn predict_compound_intermediate( | ||
| 648 | 733 | h_kind: InterpFilterKind, |
| 649 | 734 | v_kind: InterpFilterKind, |
| 650 | 735 | dst: &mut [i32], |
| 736 | +) { | |
| 737 | + predict_compound_intermediate_kern( | |
| 738 | + reference, stride, true_width, true_height, x_q4, y_q4, x_scale_fp, | |
| 739 | + block_w, block_h, block_w, block_h, h_kind, v_kind, dst, | |
| 740 | + ); | |
| 741 | +} | |
| 742 | + | |
| 743 | +/// [`predict_compound_intermediate`] with the 4-tap decision from the block's | |
| 744 | +/// true dims (see [`predict_with_filters_kern`]). | |
| 745 | +#[allow(clippy::too_many_arguments)] | |
| 746 | +pub fn predict_compound_intermediate_kern( | |
| 747 | + reference: &[u16], | |
| 748 | + stride: usize, | |
| 749 | + true_width: usize, | |
| 750 | + true_height: usize, | |
| 751 | + x_q4: i32, | |
| 752 | + y_q4: i32, | |
| 753 | + x_scale_fp: i64, | |
| 754 | + block_w: usize, | |
| 755 | + block_h: usize, | |
| 756 | + kern_w: usize, | |
| 757 | + kern_h: usize, | |
| 758 | + h_kind: InterpFilterKind, | |
| 759 | + v_kind: InterpFilterKind, | |
| 760 | + dst: &mut [i32], | |
| 651 | 761 | ) { |
| 652 | 762 | assert_eq!(dst.len(), block_w * block_h, "the destination is the block"); |
| 653 | 763 | assert!(!reference.is_empty(), "a reference plane has samples"); |
| @@ -661,7 +771,8 @@ pub fn predict_compound_intermediate( | ||
| 661 | 771 | let yfrac = y_q4.rem_euclid(16) as usize; |
| 662 | 772 | |
| 663 | 773 | let (v_wide, v_narrow) = v_kind.tables(); |
| 664 | - let v_filter = if block_h <= 4 { | |
| 774 | + note_narrow_kern(block_w, block_h, kern_w, kern_h); | |
| 775 | + let v_filter = if kern_h <= 4 { | |
| 665 | 776 | &v_narrow[yfrac] |
| 666 | 777 | } else { |
| 667 | 778 | &v_wide[yfrac] |
| @@ -678,6 +789,7 @@ pub fn predict_compound_intermediate( | ||
| 678 | 789 | y0, |
| 679 | 790 | x_scale_fp, |
| 680 | 791 | block_w, |
| 792 | + kern_w, | |
| 681 | 793 | rows, |
| 682 | 794 | h_kind, |
| 683 | 795 | &mut intermediate, |
crates/ec-av1/src/motion_field.rsmodified+9 -0
| @@ -442,6 +442,15 @@ pub fn setup_motion_field( | ||
| 442 | 442 | ); |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | + if std::env::var_os("EC_TRACE_TPL").is_some() { | |
| 446 | + eprintln!("EC_TPL_FIELD oh={cur_order_hint} rows={rows} cols={cols}"); | |
| 447 | + for r in 0..rows { | |
| 448 | + let row: String = (0..cols) | |
| 449 | + .map(|c| if cells[r * cols + c].is_some() { '#' } else { '.' }) | |
| 450 | + .collect(); | |
| 451 | + eprintln!("EC_TPL_FIELD r{r} {row}"); | |
| 452 | + } | |
| 453 | + } | |
| 445 | 454 | TplField { cols, rows, cells } |
| 446 | 455 | } |
| 447 | 456 |
crates/ec-av1/src/refusal_inventory.rsmodified+9 -5
| @@ -34,6 +34,7 @@ const REFUSALS: &[&str] = &[ | ||
| 34 | 34 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 35 | 35 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", |
| 36 | 36 | "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", |
| 37 | + "an OBMC neighbour whose switchable interp filter was never recorded", | |
| 37 | 38 | "a 16x16 block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 38 | 39 | "a 16x16 inter block whose true edge cuts through both axes needs a rectangular transform this decoder does not code yet", |
| 39 | 40 | "a 32x32 partition type this decoder does not code (value={part32})", |
| @@ -67,7 +68,14 @@ const REFUSALS: &[&str] = &[ | ||
| 67 | 68 | "an 8x8 intra leaf in an inter frame whose tx_depth splits it into 4x4 transform units", |
| 68 | 69 | "an inter frame with no key frame before it", |
| 69 | 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 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 (HORZ_A/HORZ_B/VERT_A/VERT_B at | |
| 72 | + // the 16x16 level of an inter frame: two 8x8 inter leaves plus one true | |
| 73 | + // 16x8/8x16 inter strip, gate | |
| 74 | + // `a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact`). | |
| 75 | + // What is left is the 1:4 pair, whose 16x4/4x16 strips need the sub-8 | |
| 76 | + // inter chroma-pair path (odd-strip `is_chroma_reference`, chroma built | |
| 77 | + // from BOTH strips' MVs) that no inter block writer has yet. | |
| 78 | + "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 | 79 | "an intra mode this decoder does not code (round 2)", |
| 72 | 80 | // lane-intrarect r1 lifted the whole-shape refusal that stood here (the |
| 73 | 81 | // inter path's intra arm now routes 2:1 strips through `decode_rect_split`); |
| @@ -81,10 +89,6 @@ const REFUSALS: &[&str] = &[ | ||
| 81 | 89 | "warp prediction with a scaled reference (superres, unimplemented)", |
| 82 | 90 | "an 8x8 partition leaf under a scaled reference (superres, unimplemented)", |
| 83 | 91 | "a motion_mode symbol for a block shape with no CDF row here", |
| 84 | - // lane-r14 r2: the whole-transform case of every 64-axis inter strip is | |
| 85 | - // coded; only the SPLIT of a 1:4 strip with a 64-px axis is left, whose | |
| 86 | - // `sub_tx_size_map` entry is rectangular (TX_64X16 -> TX_32X16). | |
| 87 | - "a split transform on a 1:4 inter strip with a 64-px axis", | |
| 88 | 92 | ]; |
| 89 | 93 | |
| 90 | 94 | /// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than |
crates/ec-av1/src/stream.rsmodified+1999 -144
Diff too large; view file
| @@ -74,6 +74,13 @@ pub fn rect64_inter_tu_hits() -> usize { | ||
| 74 | 74 | crate::decode::rect64_inter_tu_hits() |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | +/// lane-r14 r3: RECTANGULAR var-tx leaf transform units, `[32x16, 16x32]` -- | |
| 78 | +/// the leaves `sub_tx_size_map` produces when a 1:4 strip with a 64-px axis | |
| 79 | +/// splits its transform (`[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32`). | |
| 80 | +pub fn vartx_rect_leaf_hits() -> [usize; 2] { | |
| 81 | + crate::decode::vartx_rect_leaf_hits() | |
| 82 | +} | |
| 83 | + | |
| 77 | 84 | /// How many rect intra strips read the `use_intrabc` symbol on the last decode. |
| 78 | 85 | pub fn rect_intrabc_reads() -> usize { |
| 79 | 86 | crate::decode::rect_intrabc_reads() |
| @@ -959,17 +966,142 @@ mod tests { | ||
| 959 | 966 | ); |
| 960 | 967 | } |
| 961 | 968 | |
| 962 | - /// lane-oddh r2 GATE: the frame-edge half-strip arms r1 added (a 64x32 / | |
| 963 | - /// 32x64 superblock-level or 16x8 / 8x16 16-level INTER block where the | |
| 964 | - /// frame's true edge cuts the strip in half) actually fire and decode | |
| 965 | - /// pixel-exact, at both bit depths. 160 = two full superblock rows plus | |
| 966 | - /// 32 pixels, so every superblock in the last row is a half strip; without | |
| 967 | - /// r1's arms these attempts refused outright, which is why this gate | |
| 968 | - /// asserts a nonzero `edge_rect_strip_hits` DELTA on attempts that were | |
| 969 | - /// actually compared -- a refused attempt's hits would prove nothing | |
| 970 | - /// (class "counter from refused stream"). | |
| 969 | + /// lane-interedge r1: one attempt of the inter frame-edge half-strip gate -- | |
| 970 | + /// encode `width x height` with real aomenc (rect partitions ON, every other | |
| 971 | + /// lane's open tool pinned off), decode it, and return | |
| 972 | + /// `(inter_edge_strip hits, frames whose LUMA differs, frames whose CHROMA | |
| 973 | + /// differs)` against ffmpeg. A refusal or a decode error is a hard failure: | |
| 974 | + /// this recipe reached every size without one (measured r1). | |
| 975 | + fn inter_edge_strip_attempt( | |
| 976 | + name: &str, | |
| 977 | + width: usize, | |
| 978 | + height: usize, | |
| 979 | + bit_depth: u32, | |
| 980 | + cq: u32, | |
| 981 | + frames: usize, | |
| 982 | + ) -> ([usize; 6], usize, usize) { | |
| 983 | + let duration = format!("{}", frames as f64 / 25.0); | |
| 984 | + let source = format!("mandelbrot=size={width}x{height}:rate=25"); | |
| 985 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | |
| 986 | + let y4m = Command::new("ffmpeg") | |
| 987 | + .args([ | |
| 988 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration, "-pix_fmt", | |
| 989 | + pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | |
| 990 | + ]) | |
| 991 | + .stdin(Stdio::null()) | |
| 992 | + .stdout(Stdio::piped()) | |
| 993 | + .stderr(Stdio::piped()) | |
| 994 | + .output() | |
| 995 | + .expect("ffmpeg failed to run"); | |
| 996 | + assert!( | |
| 997 | + y4m.status.success(), | |
| 998 | + "{name}: ffmpeg refused the {width}x{height} {bit_depth}-bit fixture: {}", | |
| 999 | + String::from_utf8_lossy(&y4m.stderr) | |
| 1000 | + ); | |
| 1001 | + let depth_arg = format!("--bit-depth={bit_depth}"); | |
| 1002 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | |
| 1003 | + let cq_arg = format!("--cq-level={cq}"); | |
| 1004 | + let limit_arg = format!("--limit={frames}"); | |
| 1005 | + let mut child = Command::new(aomenc_path()) | |
| 1006 | + .args([ | |
| 1007 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, | |
| 1008 | + // cpu-used >= 1 keeps libaom on 64x64 superblocks at these | |
| 1009 | + // sizes (`av1_select_sb_size`). | |
| 1010 | + "--cpu-used=4", "--threads=1", "--row-mt=0", "--kf-max-dist=9999", | |
| 1011 | + &limit_arg, | |
| 1012 | + // decode order == display order, so the compare below covers | |
| 1013 | + // every frame the stream carries (class gate-blind-to-hidden-frames). | |
| 1014 | + "--lag-in-frames=0", &depth_arg, &input_depth_arg, | |
| 1015 | + // Rect partitions stay ON: the frame-edge strip is a FORCED | |
| 1016 | + // (gathered) HORZ/VERT, but with rect coding off the encoder | |
| 1017 | + // answers that gathered symbol SPLIT every time and no edge | |
| 1018 | + // strip ever fires (lane-oddh r2's finding, re-measured r1). | |
| 1019 | + "--enable-rect-partitions=1", "--enable-ab-partitions=0", | |
| 1020 | + "--enable-1to4-partitions=0", "--min-partition-size=8", | |
| 1021 | + "--max-partition-size=64", | |
| 1022 | + // Other lanes' open gaps this recipe must not trip. | |
| 1023 | + "--enable-palette=0", "--enable-intrabc=0", "--enable-warped-motion=0", | |
| 1024 | + "--enable-obmc=0", "--enable-masked-comp=0", "--enable-interintra-comp=0", | |
| 1025 | + "--enable-onesided-comp=0", "--enable-interintra-wedge=0", | |
| 1026 | + "--enable-smooth-interintra=0", "--enable-ref-frame-mvs=0", | |
| 1027 | + "--enable-angle-delta=0", "--enable-cfl-intra=0", | |
| 1028 | + "--enable-directional-intra=0", "--enable-smooth-intra=0", | |
| 1029 | + "--enable-paeth-intra=0", "--enable-filter-intra=0", | |
| 1030 | + "--enable-tx-size-search=0", | |
| 1031 | + "--obu", "-o", "-", "-", | |
| 1032 | + ]) | |
| 1033 | + .stdin(Stdio::piped()) | |
| 1034 | + .stdout(Stdio::piped()) | |
| 1035 | + .stderr(Stdio::piped()) | |
| 1036 | + .spawn() | |
| 1037 | + .expect("aomenc failed to start"); | |
| 1038 | + child | |
| 1039 | + .stdin | |
| 1040 | + .take() | |
| 1041 | + .expect("aomenc stdin") | |
| 1042 | + .write_all(&y4m.stdout) | |
| 1043 | + .expect("write y4m"); | |
| 1044 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 1045 | + assert!( | |
| 1046 | + out.status.success(), | |
| 1047 | + "aomenc refused: {}", | |
| 1048 | + String::from_utf8_lossy(&out.stderr) | |
| 1049 | + ); | |
| 1050 | + let stream = out.stdout; | |
| 1051 | + | |
| 1052 | + // Reset, never a delta: a refused attempt's hits must not leak into the | |
| 1053 | + // next one (class counter-from-refused-stream). | |
| 1054 | + crate::decode::reset_inter_edge_strip_hits(); | |
| 1055 | + let decoded = decode_stream(&stream).unwrap_or_else(|e| { | |
| 1056 | + panic!("{name}: {width}x{height} {bit_depth}-bit cq {cq} did not decode: {e}") | |
| 1057 | + }); | |
| 1058 | + let hits = crate::decode::inter_edge_strip_hits(); | |
| 1059 | + let reference = if bit_depth == 10 { | |
| 1060 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames) | |
| 1061 | + } else { | |
| 1062 | + ffmpeg_decode_sequence(&stream, width, height, frames) | |
| 1063 | + }; | |
| 1064 | + assert_eq!( | |
| 1065 | + decoded.len(), | |
| 1066 | + reference.len(), | |
| 1067 | + "{name}: {width}x{height} {bit_depth}-bit cq {cq} frame count" | |
| 1068 | + ); | |
| 1069 | + assert!( | |
| 1070 | + decoded.len() >= frames, | |
| 1071 | + "{name}: {width}x{height} {bit_depth}-bit cq {cq} decoded only {} frames", | |
| 1072 | + decoded.len() | |
| 1073 | + ); | |
| 1074 | + let (mut luma_bad, mut chroma_bad) = (0usize, 0usize); | |
| 1075 | + for (ours, theirs) in decoded.iter().zip(&reference) { | |
| 1076 | + if ours.y != theirs.y { | |
| 1077 | + luma_bad += 1; | |
| 1078 | + } | |
| 1079 | + if ours.u != theirs.u || ours.v != theirs.v { | |
| 1080 | + chroma_bad += 1; | |
| 1081 | + } | |
| 1082 | + } | |
| 1083 | + (hits, luma_bad, chroma_bad) | |
| 1084 | + } | |
| 1085 | + | |
| 1086 | + /// lane-interedge r1 GATE (was lane-oddh r2's `#[ignore]`d twin): the INTER | |
| 1087 | + /// frame-edge half strips -- a `PARTITION_HORZ`/`PARTITION_VERT` forced by | |
| 1088 | + /// the gathered edge symbol at the 64, 32 or 16 level whose second half lies | |
| 1089 | + /// outside the true frame. Both of the user's films are height mod 16 == 8 | |
| 1090 | + /// (1920x792, 3840x1608), so every inter frame crosses these nodes. | |
| 1091 | + /// | |
| 1092 | + /// r1 root cause: the inter tile's 32-level `PARTITION_HORZ`/`PARTITION_VERT` | |
| 1093 | + /// decoded the SECOND strip unconditionally, while libaom `decode_partition` | |
| 1094 | + /// (decodeframe.c, PARTITION_HORZ) guards it with `has_rows`/`has_cols` -- | |
| 1095 | + /// so at the edge we read symbols the encoder never wrote. With that guard | |
| 1096 | + /// removed this gate's 72x192 cq 32 arm refuses outright and its 104x192 arm | |
| 1097 | + /// decodes luma rows 127..191 of frame 5 wrong (measured r1). | |
| 1098 | + /// | |
| 1099 | + /// The compare is LUMA-exact per frame plus a CONTROL size with no edge node | |
| 1100 | + /// at all: chroma is excluded because a chroma-only inter residue that has | |
| 1101 | + /// nothing to do with the frame edge is open on main (lanes/tiny-r3, | |
| 1102 | + /// lanes/gmaffine-r4, lanes/palette2-r8) and the control below reproduces it | |
| 1103 | + /// with `inter_edge_strip_hits` all zero. | |
| 971 | 1104 | #[test] |
| 972 | - #[ignore = "2026-09-02 lane-oddh r2: no aomenc recipe reaches the INTER edge half-strip arm yet -- rect partitions OFF makes the encoder answer the forced gathered edge symbol SPLIT every time (both bit depths decode 192x160 pixel-exact, edge_rect_strip_hits=0), and rect ON stops at three other lanes' gaps first: at cq 40 'a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding', at cq 62 'an INTER 32x32 partition type this decoder does not code (value=8/9)' (HORZ_4/VERT_4 even with --enable-1to4-partitions=0), and at min-partition 16 'a HORZ/VERT intra strip below 16x16 with a split transform'. The KEY-frame half of the same edge is gated: the tiny size sweep now covers 64x72/72x64/64x136/136x64/192x136"] | |
| 973 | 1105 | fn a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact() { |
| 974 | 1106 | const NAME: &str = "a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact"; |
| 975 | 1107 | let _gate_lock = lock_gate_counters(); |
| @@ -977,116 +1109,66 @@ mod tests { | ||
| 977 | 1109 | eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); |
| 978 | 1110 | return; |
| 979 | 1111 | } |
| 980 | - let (width, height, frames) = (192usize, 160usize, 6usize); | |
| 1112 | + let frames = 6usize; | |
| 1113 | + // h mod 16 == 8 (bottom edge) and w mod 16 == 8 (right edge). | |
| 1114 | + let sizes: &[(usize, usize)] = &[(192, 72), (192, 88), (72, 192), (88, 192), (104, 192)]; | |
| 1115 | + let mut totals = [0usize; 6]; | |
| 981 | 1116 | let mut compared = 0u32; |
| 982 | - let mut strip_hits = 0usize; | |
| 983 | - let mut refused = 0u32; | |
| 984 | - for bit_depth in [8u32, 10u32] { | |
| 985 | - let duration = frames as f64 / 25.0; | |
| 986 | - let source = format!("testsrc2=size={width}x{height}:duration={duration}:rate=25"); | |
| 987 | - let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | |
| 988 | - let y4m = Command::new("ffmpeg") | |
| 989 | - .args([ | |
| 990 | - "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | |
| 991 | - "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | |
| 992 | - ]) | |
| 993 | - .stdin(Stdio::null()) | |
| 994 | - .stdout(Stdio::piped()) | |
| 995 | - .stderr(Stdio::piped()) | |
| 996 | - .output() | |
| 997 | - .expect("ffmpeg failed to run"); | |
| 998 | - assert!( | |
| 999 | - y4m.status.success(), | |
| 1000 | - "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | |
| 1001 | - String::from_utf8_lossy(&y4m.stderr) | |
| 1002 | - ); | |
| 1003 | - let depth_arg = format!("--bit-depth={bit_depth}"); | |
| 1004 | - let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | |
| 1005 | - let mut child = Command::new(aomenc_path()) | |
| 1006 | - .args([ | |
| 1007 | - "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=62", | |
| 1008 | - // cpu-used >= 1 keeps libaom on 64x64 superblocks at this | |
| 1009 | - // size (`av1_select_sb_size`: speed >= 1 and <= 480p). | |
| 1010 | - "--cpu-used=4", "--threads=1", "--row-mt=0", "--kf-max-dist=1000", | |
| 1011 | - &depth_arg, &input_depth_arg, | |
| 1012 | - // The tool set every sibling inter gate pins; the edge | |
| 1013 | - // strip itself needs rect partitions left ON. | |
| 1014 | - "--enable-warped-motion=0", "--enable-obmc=0", "--enable-masked-comp=0", | |
| 1015 | - "--enable-interintra-comp=0", "--enable-onesided-comp=0", | |
| 1016 | - "--enable-interintra-wedge=0", "--enable-smooth-interintra=0", | |
| 1017 | - // Rect partitions stay ON: the edge strip is a FORCED | |
| 1018 | - // (gathered) HORZ at the boundary, but with rect coding | |
| 1019 | - // off the encoder answers that gathered symbol SPLIT every | |
| 1020 | - // time and the arm never fires (measured, r2). | |
| 1021 | - "--enable-ab-partitions=0", "--enable-1to4-partitions=0", | |
| 1022 | - "--enable-palette=0", "--enable-intrabc=0", "--enable-cdef=0", | |
| 1023 | - "--enable-restoration=0", "--enable-ref-frame-mvs=0", | |
| 1024 | - "--enable-tx-size-search=0", "--enable-filter-intra=0", | |
| 1025 | - "--enable-smooth-intra=0", "--enable-paeth-intra=0", | |
| 1026 | - "--enable-directional-intra=0", "--enable-angle-delta=0", | |
| 1027 | - "--enable-cfl-intra=0", | |
| 1028 | - // 16 is the smallest leaf this decoder codes rect strips | |
| 1029 | - // at; below it the sub-16 strip/1:4 refusals fire first | |
| 1030 | - // and the gate never reaches the edge arm. | |
| 1031 | - // 160 = two full superblock rows plus 32, so the forced | |
| 1032 | - // HORZ at the last row is a 64x32 -- the superblock-level | |
| 1033 | - // arm -- and a 32 floor keeps the run out of the sub-16 | |
| 1034 | - // rect-strip gap another lane owns. | |
| 1035 | - "--min-partition-size=32", "--max-partition-size=64", | |
| 1036 | - "--obu", "-o", "-", "-", | |
| 1037 | - ]) | |
| 1038 | - .stdin(Stdio::piped()) | |
| 1039 | - .stdout(Stdio::piped()) | |
| 1040 | - .stderr(Stdio::piped()) | |
| 1041 | - .spawn() | |
| 1042 | - .expect("aomenc failed to start"); | |
| 1043 | - child.stdin.take().expect("aomenc stdin").write_all(&y4m.stdout).expect("write y4m"); | |
| 1044 | - let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 1045 | - assert!(out.status.success(), "aomenc refused: {}", String::from_utf8_lossy(&out.stderr)); | |
| 1046 | - let stream = out.stdout; | |
| 1047 | - | |
| 1048 | - let before = crate::decode::edge_rect_strip_hits(); | |
| 1049 | - let decoded = match decode_stream(&stream) { | |
| 1050 | - Ok(f) => f, | |
| 1051 | - Err(e) => { | |
| 1052 | - let msg = e.to_string(); | |
| 1053 | - assert!( | |
| 1054 | - msg.contains("unsupported"), | |
| 1055 | - "{NAME}: {bit_depth}-bit failed outright, not a named refusal: {msg}" | |
| 1117 | + let mut chroma_frames = 0usize; | |
| 1118 | + for &(width, height) in sizes { | |
| 1119 | + for bit_depth in [8u32, 10] { | |
| 1120 | + for cq in [20u32, 32, 45] { | |
| 1121 | + let (hits, luma_bad, chroma_bad) = | |
| 1122 | + inter_edge_strip_attempt(NAME, width, height, bit_depth, cq, frames); | |
| 1123 | + assert_eq!( | |
| 1124 | + luma_bad, 0, | |
| 1125 | + "{NAME}: {width}x{height} {bit_depth}-bit cq {cq}: {luma_bad} of {frames} \ | |
| 1126 | + frames differ from ffmpeg in LUMA (edge hits {hits:?})" | |
| 1056 | 1127 | ); |
| 1057 | - eprintln!("{NAME}: {bit_depth}-bit REFUSED {msg}"); | |
| 1058 | - refused += 1; | |
| 1059 | - continue; | |
| 1128 | + // merge J, after lane-rectchroma2: the chroma residue this | |
| 1129 | + // gate used to tolerate WAS this decoder's -- the per-axis | |
| 1130 | + // narrow-block MC kernel decision read side x side instead | |
| 1131 | + // of the block's true dims. Full-plane now. | |
| 1132 | + assert_eq!( | |
| 1133 | + chroma_bad, 0, | |
| 1134 | + "{NAME}: {width}x{height} {bit_depth}-bit cq {cq}: {chroma_bad} of \ | |
| 1135 | + {frames} frames differ from ffmpeg in CHROMA (edge hits {hits:?})" | |
| 1136 | + ); | |
| 1137 | + for (t, h) in totals.iter_mut().zip(hits) { | |
| 1138 | + *t += h; | |
| 1139 | + } | |
| 1140 | + chroma_frames += chroma_bad; | |
| 1141 | + compared += 1; | |
| 1060 | 1142 | } |
| 1061 | - }; | |
| 1062 | - let reference = if bit_depth == 10 { | |
| 1063 | - ffmpeg_decode_sequence_10bit(&stream, width, height, frames) | |
| 1064 | - } else { | |
| 1065 | - ffmpeg_decode_sequence(&stream, width, height, frames) | |
| 1066 | - }; | |
| 1067 | - assert_eq!( | |
| 1068 | - decoded.len(), | |
| 1069 | - reference.len(), | |
| 1070 | - "{NAME}: {bit_depth}-bit frame count" | |
| 1071 | - ); | |
| 1072 | - for (i, (ours, theirs)) in decoded.iter().zip(&reference).enumerate() { | |
| 1073 | - let nd = |a: &[u16], b: &[u16]| a.iter().zip(b).filter(|(x, y)| x != y).count(); | |
| 1074 | - assert_eq!( | |
| 1075 | - (nd(&ours.y, &theirs.y), nd(&ours.u, &theirs.u), nd(&ours.v, &theirs.v)), | |
| 1076 | - (0, 0, 0), | |
| 1077 | - "{NAME}: {bit_depth}-bit frame {i} differs from ffmpeg" | |
| 1078 | - ); | |
| 1079 | 1143 | } |
| 1080 | - compared += 1; | |
| 1081 | - strip_hits += crate::decode::edge_rect_strip_hits() - before; | |
| 1082 | 1144 | } |
| 1083 | - assert!(compared > 0, "{NAME}: every attempt refused ({refused}) -- gate proved nothing"); | |
| 1145 | + // Every level x axis this recipe reaches must have fired on a COMPARED | |
| 1146 | + // attempt. h32 (a bottom-edge HORZ at the 32 level) is not asserted: no | |
| 1147 | + // recipe found in r1 makes libaom answer that gathered symbol HORZ | |
| 1148 | + // (sweep ~/.cache/interedge-tmp/h32.sh, 3 sizes x 6 cq, all SPLIT); it | |
| 1149 | + // is the transposed twin of v32, which this gate does fire. | |
| 1084 | 1150 | assert!( |
| 1085 | - strip_hits > 0, | |
| 1086 | - "{NAME}: {compared} attempts decoded pixel-exact but not one frame-edge half strip \ | |
| 1087 | - fired -- the recipe no longer reaches the arm this gate exists for" | |
| 1151 | + totals[0] > 0 && totals[1] > 0 && totals[3] > 0 && totals[4] > 0 && totals[5] > 0, | |
| 1152 | + "{NAME}: {compared} attempts luma-exact but the edge strips did not all fire \ | |
| 1153 | + (h64,v64,h32,v32,h16,v16 = {totals:?}) -- the recipe no longer reaches the arms \ | |
| 1154 | + this gate exists for" | |
| 1155 | + ); | |
| 1156 | + // CONTROL: a size with no frame-edge node anywhere (192x128, both axes | |
| 1157 | + // 0 mod 64). It must be luma-exact with ZERO edge hits -- that is what | |
| 1158 | + // makes the chroma exclusion above a statement about a foreign defect | |
| 1159 | + // rather than about this lane's code. | |
| 1160 | + let (chits, cluma, cchroma) = inter_edge_strip_attempt(NAME, 192, 128, 8, 32, frames); | |
| 1161 | + assert_eq!( | |
| 1162 | + (chits, cluma, cchroma), | |
| 1163 | + ([0usize; 6], 0usize, 0usize), | |
| 1164 | + "{NAME}: control 192x128 (no frame-edge node) must be pixel-exact with no edge hits" | |
| 1165 | + ); | |
| 1166 | + eprintln!( | |
| 1167 | + "{NAME}: {compared} attempts luma-exact over {} sizes, edge hits \ | |
| 1168 | + (h64,v64,h32,v32,h16,v16)={totals:?}, 0 refusals; chroma-only frames {chroma_frames} \ | |
| 1169 | + (control 192x128: hits {chits:?}, chroma-only frames {cchroma} -- foreign defect)", | |
| 1170 | + sizes.len() | |
| 1088 | 1171 | ); |
| 1089 | - eprintln!("{NAME}: {compared} attempts pixel-exact, edge_rect_strip_hits={strip_hits}, {refused} refusals"); | |
| 1090 | 1172 | } |
| 1091 | 1173 | |
| 1092 | 1174 | /// lane-sb128 r4 GATE (was lane-oddh r2's refusal gate): the SAME real |
| @@ -3621,6 +3703,47 @@ mod tests { | ||
| 3621 | 3703 | eprintln!("{NAME}: pixel-exact, skipped_cfl={skip_cfl}"); |
| 3622 | 3704 | } |
| 3623 | 3705 | |
| 3706 | + /// lane-kf1200 r2: the same film's `-ss 300` key frame, pinned because no | |
| 3707 | + /// aomenc recipe reaches its shape -- a SKIPPED sub-8x8 chroma block whose | |
| 3708 | + /// `uv_mode` is `UV_CFL_PRED`. (lane-reelckf r1 burned 20 recipes across cq | |
| 3709 | + /// 40..63 and nine lavfi sources hunting exactly this block and never got | |
| 3710 | + /// one; ledger dead-end "never produced a SKIPPED 1:4 or sub-8x8 CfL | |
| 3711 | + /// block".) Before the fix the two sub-8x8 skip arms passed `None` for the | |
| 3712 | + /// CfL argument, so the block reconstructed as flat DC and 463 bytes of | |
| 3713 | + /// this frame's chroma were wrong. HARD-asserts `skip_cfl_hits` moved, so | |
| 3714 | + /// the fixture cannot silently stop exercising the arm. | |
| 3715 | + #[test] | |
| 3716 | + fn the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact() { | |
| 3717 | + const NAME: &str = "the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact"; | |
| 3718 | + if !have_ffmpeg() { | |
| 3719 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 3720 | + return; | |
| 3721 | + } | |
| 3722 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | |
| 3723 | + .join("fixtures/reelb_ss300_key_frame.obu"); | |
| 3724 | + let stream = std::fs::read(&path) | |
| 3725 | + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); | |
| 3726 | + let (width, height) = (3840usize, 1608usize); | |
| 3727 | + let before = crate::decode::skip_cfl_hits(); | |
| 3728 | + let frames = match decode_stream(&stream) { | |
| 3729 | + Ok(frames) => frames, | |
| 3730 | + Err(e) => panic!("{NAME}: decode_stream refused: {e}"), | |
| 3731 | + }; | |
| 3732 | + let skipped_cfl = crate::decode::skip_cfl_hits() - before; | |
| 3733 | + assert!( | |
| 3734 | + skipped_cfl > 0, | |
| 3735 | + "{NAME}: zero skipped sub-8x8 CfL blocks -- the fixture no longer \ | |
| 3736 | + exercises the arm this test exists for" | |
| 3737 | + ); | |
| 3738 | + assert_eq!(frames.len(), 1, "{NAME}: one key frame"); | |
| 3739 | + assert_eq!((frames[0].width, frames[0].height), (width, height)); | |
| 3740 | + let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, 1); | |
| 3741 | + assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg"); | |
| 3742 | + assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg"); | |
| 3743 | + assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg"); | |
| 3744 | + eprintln!("{NAME}: {skipped_cfl} skipped sub-8x8 CfL chroma blocks, frame pixel-exact"); | |
| 3745 | + } | |
| 3746 | + | |
| 3624 | 3747 | /// lane-kf900 r2: the film's key frame at -ss 900, one frame |
| 3625 | 3748 | /// (`crates/ec-av1/fixtures/reelb_kf900.obu`, 484640 bytes, sha256 |
| 3626 | 3749 | /// `a273ae99328388be14a1ff8fa1c5a6d391a9948159eaef120e1b50e02015eb83`, |
| @@ -3669,6 +3792,50 @@ mod tests { | ||
| 3669 | 3792 | assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg"); |
| 3670 | 3793 | } |
| 3671 | 3794 | |
| 3795 | + /// lane-kf1200 r3: the same film's `-ss 600` key frame (3840x1608, one | |
| 3796 | + /// 8-px partial bottom superblock row), pinned because no aomenc recipe | |
| 3797 | + /// reaches its shape -- a SKIPPED 8x8 intra leaf whose `tx_depth` resolved | |
| 3798 | + /// to TX_4X4. (80 recipes swept this round: 4 frame shapes x 2 sources x | |
| 3799 | + /// cq 32..63 x cpu-used 0/3 x 8/10-bit, all with | |
| 3800 | + /// `--enable-tx-size-search=1 --enable-filter-intra=1`; every one came | |
| 3801 | + /// back with `skip_split_tx_hits == 0`, `lanes/kf1200-r3.report.md`.) | |
| 3802 | + /// An intra block reads `tx_depth` whether or not it is skipped, so the | |
| 3803 | + /// leaf must record its resolved 4 -- not its 8x8 side -- in the txfm | |
| 3804 | + /// context; recording 8 gave the NEXT block's `tx_depth` symbol the wrong | |
| 3805 | + /// `tx_size_cdf` row (ctx 2 where libaom reads 1) and desynced the | |
| 3806 | + /// entropy stream at mi (400,46). HARD-asserts `skip_split_tx_hits` moved. | |
| 3807 | + #[test] | |
| 3808 | + fn the_reelb_ss600_key_frame_skipped_split_tx_decodes_pixel_exact() { | |
| 3809 | + const NAME: &str = "the_reelb_ss600_key_frame_skipped_split_tx_decodes_pixel_exact"; | |
| 3810 | + if !have_ffmpeg() { | |
| 3811 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 3812 | + return; | |
| 3813 | + } | |
| 3814 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | |
| 3815 | + .join("fixtures/reelb_ss600_key_frame.obu"); | |
| 3816 | + let stream = std::fs::read(&path) | |
| 3817 | + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); | |
| 3818 | + let (width, height) = (3840usize, 1608usize); | |
| 3819 | + crate::decode::reset_skip_split_tx_hits(); | |
| 3820 | + let frames = match decode_stream(&stream) { | |
| 3821 | + Ok(frames) => frames, | |
| 3822 | + Err(e) => panic!("{NAME}: decode_stream refused: {e}"), | |
| 3823 | + }; | |
| 3824 | + let skipped_split_tx = crate::decode::skip_split_tx_hits(); | |
| 3825 | + assert!( | |
| 3826 | + skipped_split_tx > 0, | |
| 3827 | + "{NAME}: zero skipped 8x8 leaves with a split transform -- the fixture no longer \ | |
| 3828 | + exercises the arm this test exists for" | |
| 3829 | + ); | |
| 3830 | + assert_eq!(frames.len(), 1, "{NAME}: one key frame"); | |
| 3831 | + assert_eq!((frames[0].width, frames[0].height), (width, height)); | |
| 3832 | + let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, 1); | |
| 3833 | + assert_eq!(frames[0].y, ffmpeg_frames[0].y, "{NAME}: luma vs ffmpeg"); | |
| 3834 | + assert_eq!(frames[0].u, ffmpeg_frames[0].u, "{NAME}: U vs ffmpeg"); | |
| 3835 | + assert_eq!(frames[0].v, ffmpeg_frames[0].v, "{NAME}: V vs ffmpeg"); | |
| 3836 | + eprintln!("{NAME}: {skipped_split_tx} skipped 8x8 TX_4X4 leaves, frame pixel-exact"); | |
| 3837 | + } | |
| 3838 | + | |
| 3672 | 3839 | /// lane-hbd10 r1: a real `aomenc --bit-depth=10 --superres-mode=1 |
| 3673 | 3840 | /// --superres-denominator=12` key frame, decoded pixel-exact against |
| 3674 | 3841 | /// ffmpeg's own 10-bit decode. Proves `superres::upscale_row`'s |
| @@ -6783,6 +6950,9 @@ mod tests { | ||
| 6783 | 6950 | // aomenc silently codes one tile column and the arm is vacuous. |
| 6784 | 6951 | extra: &[&str], |
| 6785 | 6952 | width: usize, |
| 6953 | + // lane-interp3 r1: sequence length -- a compound block needs several | |
| 6954 | + // already-coded references, which a 4-frame sequence never has. | |
| 6955 | + frame_count: usize, | |
| 6786 | 6956 | ) { |
| 6787 | 6957 | if !have_ffmpeg() { |
| 6788 | 6958 | eprintln!("SKIP {name}: no ffmpeg"); |
| @@ -6792,7 +6962,8 @@ mod tests { | ||
| 6792 | 6962 | eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); |
| 6793 | 6963 | return; |
| 6794 | 6964 | } |
| 6795 | - let (height, frame_count) = (64usize, 4usize); | |
| 6965 | + let height = 64usize; | |
| 6966 | + let duration = format!("{:.2}", frame_count as f64 / 25.0); | |
| 6796 | 6967 | // A deterministic synthetic source with real motion (a static source |
| 6797 | 6968 | // codes every inter frame as skip and never exercises the residual |
| 6798 | 6969 | // path); bounded with `-t` (class gate-loader-slurps-whole-file). |
| @@ -6805,7 +6976,7 @@ mod tests { | ||
| 6805 | 6976 | "-i", |
| 6806 | 6977 | &format!("mandelbrot=size={width}x{height}:rate=25"), |
| 6807 | 6978 | "-t", |
| 6808 | - "0.16", | |
| 6979 | + &duration, | |
| 6809 | 6980 | "-pix_fmt", |
| 6810 | 6981 | if ten_bit { "yuv420p10le" } else { "yuv420p" }, |
| 6811 | 6982 | // y4m calls 10-bit unofficial (same as the 10-bit key-frame |
| @@ -6932,6 +7103,7 @@ mod tests { | ||
| 6932 | 7103 | "whole-superblock inter PARTITION_NONE", |
| 6933 | 7104 | &[], |
| 6934 | 7105 | 64, |
| 7106 | + 4, | |
| 6935 | 7107 | ); |
| 6936 | 7108 | } |
| 6937 | 7109 | |
| @@ -6946,6 +7118,7 @@ mod tests { | ||
| 6946 | 7118 | "whole-superblock inter PARTITION_NONE", |
| 6947 | 7119 | &[], |
| 6948 | 7120 | 64, |
| 7121 | + 4, | |
| 6949 | 7122 | ); |
| 6950 | 7123 | } |
| 6951 | 7124 | |
| @@ -6988,6 +7161,88 @@ mod tests { | ||
| 6988 | 7161 | "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", |
| 6989 | 7162 | &["--tile-columns=1"], |
| 6990 | 7163 | 128, |
| 7164 | + 4, | |
| 7165 | + ); | |
| 7166 | + } | |
| 7167 | + | |
| 7168 | + /// lane-interp3 r1: the same 8x8-leaf recipe with DUAL FILTER, OBMC and | |
| 7169 | + /// warped motion on. `read_mb_interp_filter` runs for every inter block | |
| 7170 | + /// (libaom `decodemv.c` 1575), compound ones included; the compound 8x8 | |
| 7171 | + /// leaf skipped it entirely, so a SWITCHABLE-filter stream lost a symbol | |
| 7172 | + /// per compound leaf and stamped the `[3, 3]` "no filter" sentinel, which | |
| 7173 | + /// made a neighbouring OBMC block's `neighbour_filter` PANIC (a crash on | |
| 7174 | + /// his data, not a named refusal). The three hard asserts prove the flags | |
| 7175 | + /// arrived: a compound 8x8 leaf that really read the filter, a block whose | |
| 7176 | + /// two dual-filter directions DIFFER (impossible with dual filter off), | |
| 7177 | + /// and an 8x8 OBMC blend. | |
| 7178 | + // lane-interp3 r2: the ENTROPY desync r1 measured is CLOSED -- the full | |
| 7179 | + // 16-frame stream now parses end to end and every `EC_MODE`/`EC_MODE_VAL` | |
| 7180 | + // element's msac RANGE matches the instrumented aomdec's line for line | |
| 7181 | + // (570/570 mode elements, 0 diff). Two twin-drift root causes, both in | |
| 7182 | + // `decode_inter_block8`'s compound arm: `read_compound_ref_frames` was | |
| 7183 | + // passed a hard-coded `LAST_FRAME` for every inter neighbour instead of | |
| 7184 | + // the real per-mi band, and the grid stamp cleared both per-slot | |
| 7185 | + // `is_global_mv_block` flags. | |
| 7186 | + // lane-interp3 r3: the luma reconstruction residue r2 left open is CLOSED | |
| 7187 | + // and this gate is GREEN. Third instance of the same twin-drift class: | |
| 7188 | + // libaom applies `allow_warp`'s GLOBAL branch to every | |
| 7189 | + // `is_global_mv_block` reference slot, compound included and independent | |
| 7190 | + // of `motion_mode` (`av1_init_warp_params` inside | |
| 7191 | + // `build_inter_predictors_8x8_and_bigger`'s per-`ref` loop) -- the 16x16+ | |
| 7192 | + // compound arm has warped since lane-cwarp r1, the 8x8 leaf's compound arm | |
| 7193 | + // predicted BOTH taps translationally, so a GLOBAL_GLOBALMV 8x8 compound | |
| 7194 | + // leaf under a non-TRANSLATION model drifted a few luma levels, growing | |
| 7195 | + // away from the block origin. It was NOT OBMC: the `EC_OBMC` emitter this | |
| 7196 | + // round added to `decode.rs` diffs 325/325 lines against the instrumented | |
| 7197 | + // aomdec's own rung (position, span, neighbour mv/ref/bsize/filter) with | |
| 7198 | + // zero differences. | |
| 7199 | + #[test] | |
| 7200 | + fn a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact() { | |
| 7201 | + const NAME: &str = | |
| 7202 | + "a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact"; | |
| 7203 | + if !have_ffmpeg() || !have_aomenc() { | |
| 7204 | + eprintln!("SKIP {NAME}: no ffmpeg/aomenc"); | |
| 7205 | + return; | |
| 7206 | + } | |
| 7207 | + let before_dual = decode::dual_filter_diff_hits(); | |
| 7208 | + let before_obmc = decode::obmc_hits_8(); | |
| 7209 | + let before_cwarp8 = decode::compound_warp_hits_8(); | |
| 7210 | + inter_sb_none_gate( | |
| 7211 | + NAME, | |
| 7212 | + false, | |
| 7213 | + "8", | |
| 7214 | + "16", | |
| 7215 | + decode::compound8_filter_hits, | |
| 7216 | + "a compound 8x8 leaf reading its own switchable interp_filter", | |
| 7217 | + &[ | |
| 7218 | + "--enable-dual-filter=1", | |
| 7219 | + "--enable-obmc=1", | |
| 7220 | + "--enable-warped-motion=1", | |
| 7221 | + "--enable-onesided-comp=1", | |
| 7222 | + ], | |
| 7223 | + 64, | |
| 7224 | + // Recipe search hook (same shape as EC_OBMC8_ATTEMPTS): a compound | |
| 7225 | + // block needs several coded references, so the sequence is longer | |
| 7226 | + // than the other arms' 4 frames. | |
| 7227 | + std::env::var("EC_INTERP3_FRAMES") | |
| 7228 | + .ok() | |
| 7229 | + .and_then(|v| v.parse().ok()) | |
| 7230 | + .unwrap_or(16), | |
| 7231 | + ); | |
| 7232 | + assert!( | |
| 7233 | + decode::dual_filter_diff_hits() > before_dual, | |
| 7234 | + "{NAME}: no block read two DIFFERENT dual-filter directions -- \ | |
| 7235 | + --enable-dual-filter=1 did not arrive or aomenc declined it" | |
| 7236 | + ); | |
| 7237 | + assert!( | |
| 7238 | + decode::obmc_hits_8() > before_obmc, | |
| 7239 | + "{NAME}: no 8x8 OBMC blend fired -- --enable-obmc=1 did not arrive" | |
| 7240 | + ); | |
| 7241 | + assert!( | |
| 7242 | + decode::compound_warp_hits_8() > before_cwarp8, | |
| 7243 | + "{NAME}: no 8x8 COMPOUND leaf was predicted through the per-ref GLOBAL \ | |
| 7244 | + warp -- the r3 root-cause path never fired, so this stream no longer \ | |
| 7245 | + proves it" | |
| 6991 | 7246 | ); |
| 6992 | 7247 | } |
| 6993 | 7248 | |
| @@ -7002,6 +7257,7 @@ mod tests { | ||
| 7002 | 7257 | "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", |
| 7003 | 7258 | &[], |
| 7004 | 7259 | 64, |
| 7260 | + 4, | |
| 7005 | 7261 | ); |
| 7006 | 7262 | } |
| 7007 | 7263 | |
| @@ -7025,6 +7281,7 @@ mod tests { | ||
| 7025 | 7281 | "interior 16x16 inter PARTITION_SPLIT into 8x8 leaves", |
| 7026 | 7282 | &[], |
| 7027 | 7283 | 64, |
| 7284 | + 4, | |
| 7028 | 7285 | ); |
| 7029 | 7286 | } |
| 7030 | 7287 | |
| @@ -7259,13 +7516,16 @@ mod tests { | ||
| 7259 | 7516 | // refusal it names is GONE (this round codes a 64-px transform axis as |
| 7260 | 7517 | // its truncated low-32 corner), and a 10-bit sweep of this exact |
| 7261 | 7518 | // recipe now reaches the arm -- 2 pixel-exact attempts, 2 64x32 and 2 |
| 7262 | - // 32x64 strips, 2 of them carrying a coded 64-axis residual. It stays | |
| 7263 | - // 8-bit here for a DIFFERENT, newly exposed reason: 10-bit attempt 14 | |
| 7264 | - // (cq 61, horizontal split, motion step 12) mismatches ffmpeg while | |
| 7265 | - // decoding ZERO superblock-level rect strips and zero 64-axis | |
| 7266 | - // residual units, i.e. a defect of some other shape that this gate | |
| 7267 | - // must not absorb. See lanes/r14-r2.report.md. | |
| 7268 | - for bit_depth in [8u32] { | |
| 7519 | + // 32x64 strips, 2 of them carrying a coded 64-axis residual. | |
| 7520 | + // lane-sbrect10 r1 closed the newly exposed 10-bit defect r14 r2 | |
| 7521 | + // parked this arm on (10-bit attempt 14, cq 61, horizontal split, | |
| 7522 | + // motion step 12 -- it mismatched ffmpeg while decoding ZERO rect | |
| 7523 | + // strips): a 64x64 INTRA block inside an inter frame read `uv_mode` | |
| 7524 | + // off the 14-symbol CFL-allowed alphabet, which libaom's | |
| 7525 | + // `is_cfl_allowed` caps at 32x32 -- same DC_PRED value, wrong | |
| 7526 | + // interval narrowing, tile desynced from that block on. Both depths | |
| 7527 | + // run now. | |
| 7528 | + for bit_depth in [8u32, 10u32] { | |
| 7269 | 7529 | let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = |
| 7270 | 7530 | (0u32, 0u32, 0u32, 0u32); |
| 7271 | 7531 | let (mut horz_proved, mut vert_proved) = (0usize, 0usize); |
| @@ -7412,10 +7672,575 @@ mod tests { | ||
| 7412 | 7672 | (horz={horz_proved}, vert={vert_proved}) -- the residual arm proved nothing" |
| 7413 | 7673 | ); |
| 7414 | 7674 | assert!( |
| 7415 | - horz_proved + vert_proved > 0, | |
| 7416 | - "{NAME} ({bit_depth}-bit): the superblock-level inter rect arm never fired \ | |
| 7417 | - inside a pixel-exact attempt (horz={horz_proved}, vert={vert_proved}, \ | |
| 7418 | - {named_refusals} refusals, {out_of_scope} out of scope) -- gate proved nothing" | |
| 7675 | + horz_proved + vert_proved > 0, | |
| 7676 | + "{NAME} ({bit_depth}-bit): the superblock-level inter rect arm never fired \ | |
| 7677 | + inside a pixel-exact attempt (horz={horz_proved}, vert={vert_proved}, \ | |
| 7678 | + {named_refusals} refusals, {out_of_scope} out of scope) -- gate proved nothing" | |
| 7679 | + ); | |
| 7680 | + } | |
| 7681 | + } | |
| 7682 | + | |
| 7683 | + /// lane-r14 r3: a 1:4 inter strip with a 64-px axis (64x16 / 16x64) whose | |
| 7684 | + /// transform SPLITS -- the arm r2 left refused by name ("a split transform | |
| 7685 | + /// on a 1:4 inter strip with a 64-px axis"). libaom's | |
| 7686 | + /// `sub_tx_size_map[TX_64X16] == TX_32X16` (and `[TX_16X64] == TX_16X32`) | |
| 7687 | + /// keeps the sub-transform RECTANGULAR, so the var-tx tree's leaves are | |
| 7688 | + /// 32x16/16x32 units read through [`TxbSet::LumaRect32x16Inter`], each with | |
| 7689 | + /// its own `get_txb_ctx_general` neighbour context (the unit is smaller | |
| 7690 | + /// than its block, so `txb_skip_ctx` is NOT the lone-TU 0). | |
| 7691 | + /// | |
| 7692 | + /// `--enable-1to4-partitions=1 --min-partition-size=16 | |
| 7693 | + /// --max-partition-size=64 --enable-tx64=1` (each spelled once, last | |
| 7694 | + /// occurrence wins) is what lets aomenc pick a superblock-level HORZ_4 / | |
| 7695 | + /// VERT_4; the textured translating source is what keeps the strips | |
| 7696 | + /// non-skip so the residual is actually coded. 8-bit AND 10-bit, every | |
| 7697 | + /// decoded frame compared to ffmpeg on Y/U/V, refusals counted (never | |
| 7698 | + /// SKIPped), attempts that carried no rectangular var-tx leaf counted | |
| 7699 | + /// separately and still required pixel-exact. | |
| 7700 | + #[test] | |
| 7701 | + fn real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal() { | |
| 7702 | + const NAME: &str = | |
| 7703 | + "real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal"; | |
| 7704 | + let _gate_lock = lock_gate_counters(); | |
| 7705 | + if !have_ffmpeg() { | |
| 7706 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 7707 | + return; | |
| 7708 | + } | |
| 7709 | + if !have_aomenc() { | |
| 7710 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 7711 | + return; | |
| 7712 | + } | |
| 7713 | + let frame_count = 6usize; | |
| 7714 | + for bit_depth in [8u32, 10u32] { | |
| 7715 | + let (mut named_refusals, mut compared, mut out_of_scope, mut oos_mismatch) = | |
| 7716 | + (0u32, 0u32, 0u32, 0u32); | |
| 7717 | + let (mut leaf_32x16, mut leaf_16x32) = (0usize, 0usize); | |
| 7718 | + // Leaves decoded on ANY attempt, including one whose stream hits a | |
| 7719 | + // later named refusal: the firing half of this gate, kept apart | |
| 7720 | + // from `leaf_32x16`/`leaf_16x32` (pixel-compared attempts only) so | |
| 7721 | + // a refused stream is never counted as a pixel proof | |
| 7722 | + // (class counter-from-refused-stream). | |
| 7723 | + let (mut fired_32x16, mut fired_16x32) = (0usize, 0usize); | |
| 7724 | + for attempt in 0..18u32 { | |
| 7725 | + // Two orientations (the transposed pair a one-sided gate could | |
| 7726 | + // never separate) x four quantisers x two motion steps. | |
| 7727 | + // lane-r14 r4 recipe hunt (~70 aomenc runs on the merged | |
| 7728 | + // tree: testsrc2 / life / mandelbrot / banded motion, 64x64 up | |
| 7729 | + // to 384x256, cq 20..58): attempts 16-17 carry the only recipe | |
| 7730 | + // found that makes aomenc code a 64-axis 1:4 strip whose | |
| 7731 | + // transform SPLITS -- 384x256, per-16-column band motion, | |
| 7732 | + // cq 32 (16x32 leaves) and cq 38 (32x16 leaves). | |
| 7733 | + let firing = attempt >= 16; | |
| 7734 | + let (width, height) = | |
| 7735 | + if firing { (384usize, 256usize) } else { (192usize, 128usize) }; | |
| 7736 | + let vertical = attempt % 2 == 1; | |
| 7737 | + let cq = if firing { | |
| 7738 | + [32, 38][(attempt - 16) as usize] | |
| 7739 | + } else { | |
| 7740 | + [30, 36, 44, 52][(attempt / 2 % 4) as usize] | |
| 7741 | + }; | |
| 7742 | + let sp = 3 + (attempt / 8) * 3; | |
| 7743 | + // 16-pixel bands, each band translating at its OWN speed | |
| 7744 | + // across the other axis: that is what makes aomenc's RD split | |
| 7745 | + // a 64x64 superblock into four 1:4 strips (`PARTITION_HORZ_4` | |
| 7746 | + // / `VERT_4`) with distinct motion vectors, and the texture | |
| 7747 | + // inside a band is what keeps the strip non-skip and its | |
| 7748 | + // transform split. | |
| 7749 | + let geq = if firing { | |
| 7750 | + "128+60*sin((Y-N*(1+0.37*mod(floor(X/16),4)))/3)+45*sin(Y/17+X/23)" | |
| 7751 | + .to_string() | |
| 7752 | + } else if vertical { | |
| 7753 | + format!( | |
| 7754 | + "128+60*sin((Y+N*({sp}+9*mod(floor(X/16),2)))/7)+25*sin(X/11)" | |
| 7755 | + ) | |
| 7756 | + } else { | |
| 7757 | + format!( | |
| 7758 | + "128+60*sin((X+N*({sp}+9*mod(floor(Y/16),2)))/7)+25*sin(Y/11)" | |
| 7759 | + ) | |
| 7760 | + }; | |
| 7761 | + let duration = frame_count as f64 / 25.0; | |
| 7762 | + let source = format!( | |
| 7763 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | |
| 7764 | + geq=lum='{geq}',format=yuv420p" | |
| 7765 | + ); | |
| 7766 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | |
| 7767 | + let y4m = Command::new("ffmpeg") | |
| 7768 | + .args([ | |
| 7769 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | |
| 7770 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | |
| 7771 | + ]) | |
| 7772 | + .stdin(Stdio::null()) | |
| 7773 | + .stdout(Stdio::piped()) | |
| 7774 | + .stderr(Stdio::piped()) | |
| 7775 | + .output() | |
| 7776 | + .expect("ffmpeg failed to run"); | |
| 7777 | + assert!( | |
| 7778 | + y4m.status.success(), | |
| 7779 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | |
| 7780 | + String::from_utf8_lossy(&y4m.stderr) | |
| 7781 | + ); | |
| 7782 | + let cq_arg = format!("--cq-level={cq}"); | |
| 7783 | + let depth_arg = format!("--bit-depth={bit_depth}"); | |
| 7784 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | |
| 7785 | + let args: Vec<&str> = vec![ | |
| 7786 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", | |
| 7787 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | |
| 7788 | + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", | |
| 7789 | + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", | |
| 7790 | + "--lag-in-frames=0", | |
| 7791 | + // Per-arm overrides go LAST: aomenc keeps the last | |
| 7792 | + // occurrence of a repeated --enable-* flag. | |
| 7793 | + "--enable-tx64=1", "--enable-rect-partitions=1", | |
| 7794 | + "--enable-ab-partitions=0", "--enable-1to4-partitions=1", | |
| 7795 | + "--enable-dual-filter=0", "--enable-obmc=0", | |
| 7796 | + "--min-partition-size=16", "--max-partition-size=64", | |
| 7797 | + "--obu", "-o", "-", "-", | |
| 7798 | + ]; | |
| 7799 | + let mut child = Command::new(aomenc_path()) | |
| 7800 | + .args(&args) | |
| 7801 | + .stdin(Stdio::piped()) | |
| 7802 | + .stdout(Stdio::piped()) | |
| 7803 | + .stderr(Stdio::piped()) | |
| 7804 | + .spawn() | |
| 7805 | + .expect("aomenc failed to start"); | |
| 7806 | + child | |
| 7807 | + .stdin | |
| 7808 | + .take() | |
| 7809 | + .expect("aomenc stdin") | |
| 7810 | + .write_all(&y4m.stdout) | |
| 7811 | + .expect("writing y4m to aomenc"); | |
| 7812 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 7813 | + assert!( | |
| 7814 | + out.status.success(), | |
| 7815 | + "aomenc refused the fixture: {}", | |
| 7816 | + String::from_utf8_lossy(&out.stderr) | |
| 7817 | + ); | |
| 7818 | + let stream = out.stdout; | |
| 7819 | + let before = crate::stream::vartx_rect_leaf_hits(); | |
| 7820 | + let frames = match decode_stream(&stream) { | |
| 7821 | + Err(e) => { | |
| 7822 | + let msg = e.to_string(); | |
| 7823 | + assert!( | |
| 7824 | + msg.contains("unsupported"), | |
| 7825 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ | |
| 7826 | + attempt {attempt}): {msg}" | |
| 7827 | + ); | |
| 7828 | + let after = crate::stream::vartx_rect_leaf_hits(); | |
| 7829 | + fired_32x16 += after[0] - before[0]; | |
| 7830 | + fired_16x32 += after[1] - before[1]; | |
| 7831 | + named_refusals += 1; | |
| 7832 | + eprintln!( | |
| 7833 | + "{bit_depth}-bit attempt {attempt} refusal (rect var-tx leaves \ | |
| 7834 | + decoded before it: 32x16={}, 16x32={}): {msg}", | |
| 7835 | + after[0] - before[0], | |
| 7836 | + after[1] - before[1] | |
| 7837 | + ); | |
| 7838 | + continue; | |
| 7839 | + } | |
| 7840 | + Ok(frames) => frames, | |
| 7841 | + }; | |
| 7842 | + let after = crate::stream::vartx_rect_leaf_hits(); | |
| 7843 | + let (h32, v32) = (after[0] - before[0], after[1] - before[1]); | |
| 7844 | + fired_32x16 += h32; | |
| 7845 | + fired_16x32 += v32; | |
| 7846 | + let ffmpeg_frames = if bit_depth == 10 { | |
| 7847 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | |
| 7848 | + } else { | |
| 7849 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | |
| 7850 | + }; | |
| 7851 | + assert_eq!(frames.len(), frame_count); | |
| 7852 | + let mismatched = frames | |
| 7853 | + .iter() | |
| 7854 | + .zip(&ffmpeg_frames) | |
| 7855 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | |
| 7856 | + if h32 + v32 == 0 { | |
| 7857 | + // Counted per ATTEMPT, on a decoded+compared attempt only | |
| 7858 | + // (class counter-from-refused-stream). | |
| 7859 | + out_of_scope += 1; | |
| 7860 | + if mismatched { | |
| 7861 | + oos_mismatch += 1; | |
| 7862 | + eprintln!( | |
| 7863 | + "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \ | |
| 7864 | + rectangular var-tx leaves -- another shape's defect" | |
| 7865 | + ); | |
| 7866 | + } | |
| 7867 | + continue; | |
| 7868 | + } | |
| 7869 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 7870 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); | |
| 7871 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); | |
| 7872 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit)"); | |
| 7873 | + } | |
| 7874 | + leaf_32x16 += h32; | |
| 7875 | + leaf_16x32 += v32; | |
| 7876 | + compared += 1; | |
| 7877 | + } | |
| 7878 | + eprintln!( | |
| 7879 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {compared} \ | |
| 7880 | + pixel-exact attempts carrying the arm, pixel-compared rect var-tx leaves \ | |
| 7881 | + 32x16={leaf_32x16} 16x32={leaf_16x32}, leaves decoded anywhere in the sweep \ | |
| 7882 | + 32x16={fired_32x16} 16x32={fired_16x32}, {out_of_scope} attempts carried none \ | |
| 7883 | + ({oos_mismatch} of them mismatched)" | |
| 7884 | + ); | |
| 7885 | + assert_eq!( | |
| 7886 | + oos_mismatch, 0, | |
| 7887 | + "{NAME}: {oos_mismatch} attempt(s) with no rectangular var-tx leaf decoded \ | |
| 7888 | + but mismatched ffmpeg -- a defect of another shape, not a pass" | |
| 7889 | + ); | |
| 7890 | + assert!( | |
| 7891 | + compared + out_of_scope > 0, | |
| 7892 | + "{NAME} ({bit_depth}-bit): every attempt refused -- the gate compared no pixels" | |
| 7893 | + ); | |
| 7894 | + // The firing half. MEASURED on the merged tree (lane-r14 r4, ~70 | |
| 7895 | + // aomenc runs): the 8-bit 384x256 banded recipe codes BOTH | |
| 7896 | + // orientations of the split -- cq 38 gives four 32x16 leaves (out | |
| 7897 | + // of four 64x16 strips), cq 32 one 16x32 leaf (out of four 16x64 | |
| 7898 | + // strips). Those two streams stop LATER on another lane's live | |
| 7899 | + // refusal ("an inter 16x16-level AB or 1:4 partition", "a non-skip | |
| 7900 | + // rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual | |
| 7901 | + // coding"), so the leaves are proved DECODED, not proved | |
| 7902 | + // pixel-exact; every attempt that ran to the end is compared | |
| 7903 | + // frame by frame above. At 10 bits the same sweep fires nothing | |
| 7904 | + // (aomenc picks other shapes), so the firing assert is 8-bit only | |
| 7905 | + // -- and it is a hard assert, never a print. | |
| 7906 | + if bit_depth == 8 { | |
| 7907 | + assert!( | |
| 7908 | + fired_32x16 > 0 && fired_16x32 > 0, | |
| 7909 | + "{NAME}: the rectangular var-tx leaf arm never fired (32x16={fired_32x16}, \ | |
| 7910 | + 16x32={fired_16x32}, {named_refusals} refusals, {compared} compared) -- \ | |
| 7911 | + `sub_tx_size_map[TX_64X16] == TX_32X16` is unproved by this gate" | |
| 7912 | + ); | |
| 7913 | + } | |
| 7914 | + } | |
| 7915 | + } | |
| 7916 | + | |
| 7917 | + /// lane-sbrect10 r1: a 64x64 INTRA block inside an INTER frame, whose | |
| 7918 | + /// `uv_mode` alphabet libaom's `is_cfl_allowed` (`blockd.h`: `wide <= 32 | |
| 7919 | + /// && high <= 32`) narrows to the 13-symbol NO-CFL table. Reading the | |
| 7920 | + /// 14-symbol CFL one produced the same `DC_PRED` value with the wrong | |
| 7921 | + /// interval narrowing, so the tile desynced from that block on and the | |
| 7922 | + /// frame decoded silently wrong (class `wrong-alphabet-same-value`; found | |
| 7923 | + /// as the "another shape" mismatch the superblock rect gate above had to | |
| 7924 | + /// park its 10-bit arm on). | |
| 7925 | + /// | |
| 7926 | + /// The counter `nocfl_uv_mode_hits` proves the shape fired in EVERY | |
| 7927 | + /// compared attempt, and every decode-order frame is compared against | |
| 7928 | + /// ffmpeg -- an attempt that mismatches fails, it never SKIPs. | |
| 7929 | + /// | |
| 7930 | + /// lane-sbrect10 r2: with the half-random source below this gate also | |
| 7931 | + /// covers a SECOND defect it exposed at 10-bit cq 58/61 -- the compound | |
| 7932 | + /// MV stack's extension pass zero-filled the `comp_list` tail slots | |
| 7933 | + /// libaom fills with each side's GLOBAL MOTION vector | |
| 7934 | + /// (`combine_compound_candidates`, mvref_common.c:723-729). A compound | |
| 7935 | + /// block with no usable neighbour pair (frame top row, intra block to | |
| 7936 | + /// its left, empty temporal field) then took a `(0, 0)` predictor | |
| 7937 | + /// instead of the frame's translation: 32890/39907 wrong luma samples | |
| 7938 | + /// on decode-order frame 2 with the entropy stream still in sync. | |
| 7939 | + #[test] | |
| 7940 | + fn a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet() { | |
| 7941 | + const NAME: &str = | |
| 7942 | + "a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet"; | |
| 7943 | + let _gate_lock = lock_gate_counters(); | |
| 7944 | + if !have_ffmpeg() { | |
| 7945 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 7946 | + return; | |
| 7947 | + } | |
| 7948 | + if !have_aomenc() { | |
| 7949 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 7950 | + return; | |
| 7951 | + } | |
| 7952 | + let (width, height, frame_count) = (192usize, 128usize, 6usize); | |
| 7953 | + for bit_depth in [8u32, 10u32] { | |
| 7954 | + let (mut named_refusals, mut matched, mut carried_none) = (0u32, 0u32, 0u32); | |
| 7955 | + let mut total_hits = 0usize; | |
| 7956 | + for attempt in 0..16u32 { | |
| 7957 | + // The sibling superblock-rect gate's own grid (its 10-bit | |
| 7958 | + // attempt 14 -- cq 61, horizontal split, motion step 12 -- is | |
| 7959 | + // the stream that exposed the defect); which superblock the RD | |
| 7960 | + // hands an intra 64x64 block moves with the quantiser and the | |
| 7961 | + // depth, so both orientations x four quantisers x two motion | |
| 7962 | + // steps run here too. | |
| 7963 | + let vertical_split = attempt % 2 == 1; | |
| 7964 | + let cq = [58, 52, 45, 61][(attempt / 2 % 4) as usize]; | |
| 7965 | + let sp = 8 + (attempt / 8) * 4; | |
| 7966 | + // Half ramp, half deterministic pseudo-noise: the flat "200" | |
| 7967 | + // half of r1's source made aomenc code the right-hand | |
| 7968 | + // superblocks skip, so at 8 bit no >32 intra block ever | |
| 7969 | + // appeared (probed cq 45/52/58/61/63 = 0 hits). The textured | |
| 7970 | + // half forces intra above 32x32 in an inter frame at BOTH | |
| 7971 | + // depths, so both arms carry the shape. | |
| 7972 | + let geq = if vertical_split { | |
| 7973 | + format!( | |
| 7974 | + "if(lt(Y,64), 40+mod(floor((X+N*{sp})/32)*90,200), mod((X*7+Y*13+N*97)*31,256))" | |
| 7975 | + ) | |
| 7976 | + } else { | |
| 7977 | + format!( | |
| 7978 | + "if(lt(X,128), 40+mod(floor((Y+N*{sp})/32)*90,200), mod((X*7+Y*13+N*97)*31,256))" | |
| 7979 | + ) | |
| 7980 | + }; | |
| 7981 | + let duration = frame_count as f64 / 25.0; | |
| 7982 | + let source = format!( | |
| 7983 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | |
| 7984 | + geq=lum='{geq}',format=yuv420p" | |
| 7985 | + ); | |
| 7986 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | |
| 7987 | + let y4m = Command::new("ffmpeg") | |
| 7988 | + .args([ | |
| 7989 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | |
| 7990 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | |
| 7991 | + ]) | |
| 7992 | + .stdin(Stdio::null()) | |
| 7993 | + .stdout(Stdio::piped()) | |
| 7994 | + .stderr(Stdio::piped()) | |
| 7995 | + .output() | |
| 7996 | + .expect("ffmpeg failed to run"); | |
| 7997 | + assert!( | |
| 7998 | + y4m.status.success(), | |
| 7999 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | |
| 8000 | + String::from_utf8_lossy(&y4m.stderr) | |
| 8001 | + ); | |
| 8002 | + let cq_arg = format!("--cq-level={cq}"); | |
| 8003 | + let depth_arg = format!("--bit-depth={bit_depth}"); | |
| 8004 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | |
| 8005 | + let args: Vec<&str> = vec![ | |
| 8006 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", | |
| 8007 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | |
| 8008 | + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", | |
| 8009 | + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", | |
| 8010 | + "--enable-tx-size-search=0", "--lag-in-frames=0", | |
| 8011 | + "--enable-rect-partitions=1", "--enable-ab-partitions=0", | |
| 8012 | + "--enable-1to4-partitions=1", "--min-partition-size=32", | |
| 8013 | + "--max-partition-size=64", | |
| 8014 | + "--obu", "-o", "-", "-", | |
| 8015 | + ]; | |
| 8016 | + let mut child = Command::new(aomenc_path()) | |
| 8017 | + .args(&args) | |
| 8018 | + .stdin(Stdio::piped()) | |
| 8019 | + .stdout(Stdio::piped()) | |
| 8020 | + .stderr(Stdio::piped()) | |
| 8021 | + .spawn() | |
| 8022 | + .expect("aomenc failed to start"); | |
| 8023 | + child | |
| 8024 | + .stdin | |
| 8025 | + .take() | |
| 8026 | + .expect("aomenc stdin") | |
| 8027 | + .write_all(&y4m.stdout) | |
| 8028 | + .expect("writing y4m to aomenc"); | |
| 8029 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 8030 | + assert!( | |
| 8031 | + out.status.success(), | |
| 8032 | + "aomenc refused the fixture: {}", | |
| 8033 | + String::from_utf8_lossy(&out.stderr) | |
| 8034 | + ); | |
| 8035 | + let stream = out.stdout; | |
| 8036 | + let before = crate::decode::nocfl_uv_mode_hits(); | |
| 8037 | + let frames = match decode_stream(&stream) { | |
| 8038 | + Err(e) => { | |
| 8039 | + let msg = e.to_string(); | |
| 8040 | + assert!( | |
| 8041 | + msg.contains("unsupported"), | |
| 8042 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ | |
| 8043 | + attempt {attempt}): {msg}" | |
| 8044 | + ); | |
| 8045 | + named_refusals += 1; | |
| 8046 | + eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); | |
| 8047 | + continue; | |
| 8048 | + } | |
| 8049 | + Ok(frames) => frames, | |
| 8050 | + }; | |
| 8051 | + let hits = crate::decode::nocfl_uv_mode_hits() - before; | |
| 8052 | + let ffmpeg_frames = if bit_depth == 10 { | |
| 8053 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | |
| 8054 | + } else { | |
| 8055 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | |
| 8056 | + }; | |
| 8057 | + assert_eq!(frames.len(), frame_count); | |
| 8058 | + if hits == 0 { | |
| 8059 | + // No 64-axis intra block in this stream: still compared | |
| 8060 | + // (a mismatch here is a defect, never a pass), just not | |
| 8061 | + // proof of this gate's shape. | |
| 8062 | + carried_none += 1; | |
| 8063 | + } | |
| 8064 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 8065 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})"); | |
| 8066 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})"); | |
| 8067 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})"); | |
| 8068 | + } | |
| 8069 | + if hits > 0 { | |
| 8070 | + matched += 1; | |
| 8071 | + total_hits += hits; | |
| 8072 | + } | |
| 8073 | + } | |
| 8074 | + eprintln!( | |
| 8075 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ | |
| 8076 | + attempts carrying a >32 intra block ({total_hits} no-CFL uv_mode reads), \ | |
| 8077 | + {carried_none} attempts carried none" | |
| 8078 | + ); | |
| 8079 | + assert!( | |
| 8080 | + matched > 0 && total_hits > 0, | |
| 8081 | + "{NAME} ({bit_depth}-bit): no attempt decoded an intra block above 32x32, so the \ | |
| 8082 | + no-CFL uv_mode alphabet was never exercised -- gate proved nothing \ | |
| 8083 | + ({named_refusals} refusals, {carried_none} attempts carried none)" | |
| 8084 | + ); | |
| 8085 | + } | |
| 8086 | + } | |
| 8087 | + /// lane-sqdrift r2: the SQUARE-ONLY twin of the no-CFL `uv_mode` gate | |
| 8088 | + /// above. With `--enable-rect-partitions=0` the encoder codes only | |
| 8089 | + /// `PARTITION_NONE` and `PARTITION_SPLIT`, and on detailed content the RD | |
| 8090 | + /// eventually hands one whole 64x64 superblock of an INTER frame to an | |
| 8091 | + /// INTRA block -- `bsize == sb_size`, the one shape whose `uv_mode` must | |
| 8092 | + /// come off the 13-symbol `uv_mode_no_cfl` alphabet because libaom's | |
| 8093 | + /// `is_cfl_allowed` (`blockd.h`: `wide <= 32 && high <= 32`) excludes it. | |
| 8094 | + /// | |
| 8095 | + /// Before the fix this decoder read the 14-symbol CFL alphabet there: the | |
| 8096 | + /// same `DC_PRED` value, a different interval, and the tile desynced from | |
| 8097 | + /// that block on. r1 measured the damage on the pinned 192x128 stream | |
| 8098 | + /// (sha256 `c6af4fb4...`): decode-order frames 0-3 pre-filter byte-exact, | |
| 8099 | + /// frame 4 luma 3540 samples wrong over exactly the last superblock | |
| 8100 | + /// (x 128..191, y 64..127), then 24k wrong by frame 7 -- and the decoder | |
| 8101 | + /// did not even report a mismatch, it reported an intra-rect-strip refusal | |
| 8102 | + /// read out of the already-desynced stream (class `refusal-from-own-desync`; | |
| 8103 | + /// aomdec's own partition histogram over that stream is rect-free). | |
| 8104 | + /// After the fix the same stream is byte-exact on all 8 frames. | |
| 8105 | + /// | |
| 8106 | + /// Distinct from the sibling gate: rect partitions OFF (so the 64x64 NONE | |
| 8107 | + /// really is a whole superblock), `--min-partition-size=16`, natural | |
| 8108 | + /// mandelbrot detail instead of a synthetic half-noise ramp, and 8 frames | |
| 8109 | + /// of drift so a desync that survives one frame still fails here. Every | |
| 8110 | + /// decode-order frame of every attempt is compared against ffmpeg, so a | |
| 8111 | + /// mismatch of ANY shape fails; the gate never turns one into a SKIP. | |
| 8112 | + #[test] | |
| 8113 | + fn a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact() | |
| 8114 | + { | |
| 8115 | + const NAME: &str = "a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact"; | |
| 8116 | + let _gate_lock = lock_gate_counters(); | |
| 8117 | + if !have_ffmpeg() { | |
| 8118 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 8119 | + return; | |
| 8120 | + } | |
| 8121 | + if !have_aomenc() { | |
| 8122 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 8123 | + return; | |
| 8124 | + } | |
| 8125 | + let (width, height, frame_count) = (192usize, 128usize, 8usize); | |
| 8126 | + for bit_depth in [8u32, 10u32] { | |
| 8127 | + let (mut named_refusals, mut matched, mut carried_none) = (0u32, 0u32, 0u32); | |
| 8128 | + let mut total_hits = 0usize; | |
| 8129 | + for attempt in 0..4u32 { | |
| 8130 | + // r1's pinned recipe is (start_scale 4.76, cq 55); the other | |
| 8131 | + // three points move the detail level and the quantiser, which | |
| 8132 | + // is what moves WHICH superblock the RD codes intra. | |
| 8133 | + let start_scale = ["4.76", "3.20"][(attempt % 2) as usize]; | |
| 8134 | + let cq = [55, 45][(attempt / 2) as usize]; | |
| 8135 | + let duration = frame_count as f64 / 25.0; | |
| 8136 | + let source = format!( | |
| 8137 | + "mandelbrot=size={width}x{height}:start_scale={start_scale}:\ | |
| 8138 | + end_scale=0.004:end_pts=8:rate=25" | |
| 8139 | + ); | |
| 8140 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | |
| 8141 | + let y4m = Command::new("ffmpeg") | |
| 8142 | + .args([ | |
| 8143 | + "-v", "error", "-f", "lavfi", "-i", &source, "-vf", "hue=s=0", | |
| 8144 | + "-t", &duration.to_string(), "-pix_fmt", pix_fmt, "-strict", "-1", | |
| 8145 | + "-f", "yuv4mpegpipe", "-strict", "-1", "-", | |
| 8146 | + ]) | |
| 8147 | + .stdin(Stdio::null()) | |
| 8148 | + .stdout(Stdio::piped()) | |
| 8149 | + .stderr(Stdio::piped()) | |
| 8150 | + .output() | |
| 8151 | + .expect("ffmpeg failed to run"); | |
| 8152 | + assert!( | |
| 8153 | + y4m.status.success(), | |
| 8154 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | |
| 8155 | + String::from_utf8_lossy(&y4m.stderr) | |
| 8156 | + ); | |
| 8157 | + let cq_arg = format!("--cq-level={cq}"); | |
| 8158 | + let depth_arg = format!("--bit-depth={bit_depth}"); | |
| 8159 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | |
| 8160 | + let args: Vec<&str> = vec![ | |
| 8161 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=1", | |
| 8162 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | |
| 8163 | + "--lag-in-frames=0", "--auto-alt-ref=0", | |
| 8164 | + "--kf-min-dist=1000", "--kf-max-dist=1000", | |
| 8165 | + "--enable-rect-partitions=0", "--enable-ab-partitions=0", | |
| 8166 | + "--enable-1to4-partitions=0", "--min-partition-size=16", | |
| 8167 | + "--max-partition-size=64", "--enable-tx-size-search=0", | |
| 8168 | + "--enable-order-hint=0", "--enable-warped-motion=0", "--enable-obmc=0", | |
| 8169 | + "--enable-masked-comp=0", "--enable-interintra-comp=0", | |
| 8170 | + "--enable-dist-wtd-comp=0", "--enable-diff-wtd-comp=0", | |
| 8171 | + "--enable-onesided-comp=0", "--enable-interintra-wedge=0", | |
| 8172 | + "--enable-smooth-interintra=0", "--enable-filter-intra=0", | |
| 8173 | + "--enable-smooth-intra=0", "--enable-paeth-intra=0", | |
| 8174 | + "--enable-directional-intra=0", "--enable-angle-delta=0", | |
| 8175 | + "--enable-cdef=0", "--enable-restoration=0", "--enable-palette=0", | |
| 8176 | + "--enable-intrabc=0", "--enable-cfl-intra=0", "--enable-ref-frame-mvs=0", | |
| 8177 | + "--obu", "-o", "-", "-", | |
| 8178 | + ]; | |
| 8179 | + let mut child = Command::new(aomenc_path()) | |
| 8180 | + .args(&args) | |
| 8181 | + .stdin(Stdio::piped()) | |
| 8182 | + .stdout(Stdio::piped()) | |
| 8183 | + .stderr(Stdio::piped()) | |
| 8184 | + .spawn() | |
| 8185 | + .expect("aomenc failed to start"); | |
| 8186 | + child | |
| 8187 | + .stdin | |
| 8188 | + .take() | |
| 8189 | + .expect("aomenc stdin") | |
| 8190 | + .write_all(&y4m.stdout) | |
| 8191 | + .expect("writing y4m to aomenc"); | |
| 8192 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 8193 | + assert!( | |
| 8194 | + out.status.success(), | |
| 8195 | + "aomenc refused the fixture: {}", | |
| 8196 | + String::from_utf8_lossy(&out.stderr) | |
| 8197 | + ); | |
| 8198 | + let stream = out.stdout; | |
| 8199 | + let before = crate::decode::nocfl_uv_mode_hits(); | |
| 8200 | + let frames = match decode_stream(&stream) { | |
| 8201 | + Err(e) => { | |
| 8202 | + let msg = e.to_string(); | |
| 8203 | + assert!( | |
| 8204 | + msg.contains("unsupported"), | |
| 8205 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ | |
| 8206 | + attempt {attempt}): {msg}" | |
| 8207 | + ); | |
| 8208 | + named_refusals += 1; | |
| 8209 | + eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); | |
| 8210 | + continue; | |
| 8211 | + } | |
| 8212 | + Ok(frames) => frames, | |
| 8213 | + }; | |
| 8214 | + let hits = crate::decode::nocfl_uv_mode_hits() - before; | |
| 8215 | + let ffmpeg_frames = if bit_depth == 10 { | |
| 8216 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | |
| 8217 | + } else { | |
| 8218 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | |
| 8219 | + }; | |
| 8220 | + assert_eq!(frames.len(), frame_count); | |
| 8221 | + if hits == 0 { | |
| 8222 | + carried_none += 1; | |
| 8223 | + } | |
| 8224 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 8225 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})"); | |
| 8226 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})"); | |
| 8227 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, hits={hits})"); | |
| 8228 | + } | |
| 8229 | + if hits > 0 { | |
| 8230 | + matched += 1; | |
| 8231 | + total_hits += hits; | |
| 8232 | + } | |
| 8233 | + } | |
| 8234 | + eprintln!( | |
| 8235 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ | |
| 8236 | + attempts carrying a 64x64 intra superblock ({total_hits} no-CFL uv_mode reads), \ | |
| 8237 | + {carried_none} attempts carried none" | |
| 8238 | + ); | |
| 8239 | + assert!( | |
| 8240 | + matched > 0 && total_hits > 0, | |
| 8241 | + "{NAME} ({bit_depth}-bit): no square-only attempt decoded a 64x64 intra block \ | |
| 8242 | + inside an inter frame, so the no-CFL uv_mode alphabet was never exercised -- \ | |
| 8243 | + gate proved nothing ({named_refusals} refusals, {carried_none} carried none)" | |
| 7419 | 8244 | ); |
| 7420 | 8245 | } |
| 7421 | 8246 | } |
| @@ -8168,6 +8993,231 @@ mod tests { | ||
| 8168 | 8993 | } |
| 8169 | 8994 | |
| 8170 | 8995 | |
| 8996 | + #[test] | |
| 8997 | + // lane-inter16ab r1: the 16x16-level AB partitions on an INTER frame -- | |
| 8998 | + // PARTITION_HORZ_A/_HORZ_B/_VERT_A/_VERT_B at 16x16, i.e. two 8x8 inter | |
| 8999 | + // leaves plus one true 16x8/8x16 inter strip. Every decode-order frame is | |
| 9000 | + // compared Y/U/V against ffmpeg, refusals are counted and never SKIPped, | |
| 9001 | + // out-of-scope mismatches fail the gate, and EACH of the four arms must | |
| 9002 | + // have fired on a pixel-exact attempt (RD picking only HORZ_A is not | |
| 9003 | + // proof of four). `--enable-1to4-partitions=0` because the 16-level 1:4 | |
| 9004 | + // pair (16x4/4x16 inter strips) is still refused by name. | |
| 9005 | + fn a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact() { | |
| 9006 | + const NAME: &str = | |
| 9007 | + "a_real_aomenc_inter_sequence_with_16x16_level_ab_partitions_decodes_pixel_exact"; | |
| 9008 | + let _gate_lock = lock_gate_counters(); | |
| 9009 | + if !have_ffmpeg() { | |
| 9010 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 9011 | + return; | |
| 9012 | + } | |
| 9013 | + if !have_aomenc() { | |
| 9014 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 9015 | + return; | |
| 9016 | + } | |
| 9017 | + let (width, height, frame_count) = (192usize, 128usize, 6usize); | |
| 9018 | + // Per arm, over both bit depths: how many pixel-exact attempts fired | |
| 9019 | + // it at least once. | |
| 9020 | + let mut arms_total = [0u32; 4]; | |
| 9021 | + for bit_depth in [8u32, 10u32] { | |
| 9022 | + let (mut named_refusals, mut matched, mut out_of_scope, mut oos_mismatch) = | |
| 9023 | + (0u32, 0u32, 0u32, 0u32); | |
| 9024 | + let mut arms_proved = [0u32; 4]; | |
| 9025 | + for attempt in 0..32u32 { | |
| 9026 | + // Two sources (structure along X vs along Y -- an AB | |
| 9027 | + // partition needs an L/T-shaped feature, so both orientations | |
| 9028 | + // are swept), four quantisers, two motion steps, two tiling | |
| 9029 | + // arms. r1 measured (sweep script in the report): a 16-attempt | |
| 9030 | + // sweep at cq 34/22 alone never made aomenc's RD pick HORZ_A | |
| 9031 | + // at 8 bits, so the quantiser axis is four wide here; cq 46 on | |
| 9032 | + // the X-structured source is deliberately NOT in the list -- | |
| 9033 | + // that stream's decode-order frame 4 desyncs on a defect this | |
| 9034 | + // lane does not own (aomdec's own EC_PART trace reads ZERO | |
| 9035 | + // AB partitions at BLOCK_16X16 anywhere in it, so the AB | |
| 9036 | + // counters it raises are read out of an already-diverged | |
| 9037 | + // stream; see lanes/inter16ab-r1.report.md). | |
| 9038 | + let tx_search = if attempt % 2 == 0 { "0" } else { "1" }; | |
| 9039 | + // The 10-bit arm swaps cq 40 for 28 on the same sources: at | |
| 9040 | + // cq 40 the X-structured 10-bit stream mismatches ffmpeg with | |
| 9041 | + // ZERO 16-level AB partitions in it (another shape's defect, | |
| 9042 | + // measured r1 -- the gate's own `oos_mismatch` counter is | |
| 9043 | + // what found it, and it is reported, not silenced). | |
| 9044 | + let cq = if bit_depth == 10 { | |
| 9045 | + [18, 22, 34, 28][(attempt / 2 % 4) as usize] | |
| 9046 | + } else { | |
| 9047 | + [18, 22, 34, 40][(attempt / 2 % 4) as usize] | |
| 9048 | + }; | |
| 9049 | + let natural = attempt / 8 % 2 == 1; | |
| 9050 | + let group = attempt / 16; | |
| 9051 | + // r1: a `--tile-columns=1` arm of this same sweep PANICS in | |
| 9052 | + // `mc::from_switchable_symbol` (a 4th symbol out of a | |
| 9053 | + // 3-symbol alphabet = someone else's desync, the signature | |
| 9054 | + // the ledger already pins for the below-8x8 inter leaf), not | |
| 9055 | + // in anything this lane added -- so the tiled arm is left out | |
| 9056 | + // rather than turned into a SKIP or a weakened assert. | |
| 9057 | + // Reported as residue in lanes/inter16ab-r1.report.md. | |
| 9058 | + let tile_cols = "0"; | |
| 9059 | + let sp = 3 + (group % 2) * 5; | |
| 9060 | + let duration = frame_count as f64 / 25.0; | |
| 9061 | + // Continuous-tone translating texture with a second, coarser | |
| 9062 | + // component on the cross axis: aomenc's RD picks an AB | |
| 9063 | + // partition where one 16x16 quadrant differs from its three | |
| 9064 | + // siblings, which the two sinusoids at different periods | |
| 9065 | + // produce all over the frame. | |
| 9066 | + let lum = if natural { | |
| 9067 | + format!("128+58*sin((Y+N*{sp})/6)+40*sin(X/11)+20*sin((X+Y)/5)") | |
| 9068 | + } else { | |
| 9069 | + format!("128+58*sin((X+N*{sp})/6)+40*sin(Y/11)+20*sin((X-Y)/5)") | |
| 9070 | + }; | |
| 9071 | + let source = format!( | |
| 9072 | + "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ | |
| 9073 | + geq=lum='{lum}',format=yuv420p" | |
| 9074 | + ); | |
| 9075 | + let pix_fmt = if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }; | |
| 9076 | + let y4m = Command::new("ffmpeg") | |
| 9077 | + .args([ | |
| 9078 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", &duration.to_string(), | |
| 9079 | + "-pix_fmt", pix_fmt, "-strict", "-1", "-f", "yuv4mpegpipe", "-", | |
| 9080 | + ]) | |
| 9081 | + .stdin(Stdio::null()) | |
| 9082 | + .stdout(Stdio::piped()) | |
| 9083 | + .stderr(Stdio::piped()) | |
| 9084 | + .output() | |
| 9085 | + .expect("ffmpeg failed to run"); | |
| 9086 | + assert!( | |
| 9087 | + y4m.status.success(), | |
| 9088 | + "{NAME}: ffmpeg refused the {bit_depth}-bit fixture: {}", | |
| 9089 | + String::from_utf8_lossy(&y4m.stderr) | |
| 9090 | + ); | |
| 9091 | + let cq_arg = format!("--cq-level={cq}"); | |
| 9092 | + let depth_arg = format!("--bit-depth={bit_depth}"); | |
| 9093 | + let input_depth_arg = format!("--input-bit-depth={bit_depth}"); | |
| 9094 | + let tx_arg = format!("--enable-tx-size-search={tx_search}"); | |
| 9095 | + let tile_arg = format!("--tile-columns={tile_cols}"); | |
| 9096 | + let args: Vec<&str> = vec![ | |
| 9097 | + "--codec=av1", "--passes=1", "--end-usage=q", &cq_arg, "--cpu-used=0", | |
| 9098 | + "--threads=1", "--row-mt=0", "--sb-size=64", &depth_arg, &input_depth_arg, | |
| 9099 | + "--enable-restoration=0", "--enable-palette=0", "--deltaq-mode=0", | |
| 9100 | + "--enable-filter-intra=0", "--enable-cfl-intra=0", "--enable-intrabc=0", | |
| 9101 | + "--lag-in-frames=0", "--kf-max-dist=9999", &tile_arg, | |
| 9102 | + // Per-arm overrides go LAST: aomenc keeps the last | |
| 9103 | + // occurrence of a repeated --enable-* flag. | |
| 9104 | + &tx_arg, | |
| 9105 | + "--enable-rect-partitions=1", "--enable-ab-partitions=1", | |
| 9106 | + "--enable-1to4-partitions=0", "--min-partition-size=8", | |
| 9107 | + "--max-partition-size=16", | |
| 9108 | + "--obu", "-o", "-", "-", | |
| 9109 | + ]; | |
| 9110 | + let mut child = Command::new(aomenc_path()) | |
| 9111 | + .args(&args) | |
| 9112 | + .stdin(Stdio::piped()) | |
| 9113 | + .stdout(Stdio::piped()) | |
| 9114 | + .stderr(Stdio::piped()) | |
| 9115 | + .spawn() | |
| 9116 | + .expect("aomenc failed to start"); | |
| 9117 | + child | |
| 9118 | + .stdin | |
| 9119 | + .take() | |
| 9120 | + .expect("aomenc stdin") | |
| 9121 | + .write_all(&y4m.stdout) | |
| 9122 | + .expect("writing y4m to aomenc"); | |
| 9123 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 9124 | + assert!( | |
| 9125 | + out.status.success(), | |
| 9126 | + "aomenc refused the fixture: {}", | |
| 9127 | + String::from_utf8_lossy(&out.stderr) | |
| 9128 | + ); | |
| 9129 | + let stream = out.stdout; | |
| 9130 | + let before = decode::ab16_inter_hits_by_arm(); | |
| 9131 | + let frames = match decode_stream(&stream) { | |
| 9132 | + Err(e) => { | |
| 9133 | + let msg = e.to_string(); | |
| 9134 | + assert!( | |
| 9135 | + msg.contains("unsupported"), | |
| 9136 | + "{NAME} failed outright, not a named refusal ({bit_depth}-bit, \ | |
| 9137 | + attempt {attempt}): {msg}" | |
| 9138 | + ); | |
| 9139 | + named_refusals += 1; | |
| 9140 | + eprintln!("{bit_depth}-bit attempt {attempt} refusal: {msg}"); | |
| 9141 | + continue; | |
| 9142 | + } | |
| 9143 | + Ok(frames) => frames, | |
| 9144 | + }; | |
| 9145 | + let after = decode::ab16_inter_hits_by_arm(); | |
| 9146 | + let fired: Vec<usize> = | |
| 9147 | + (0..4).map(|a| after[a] - before[a]).collect(); | |
| 9148 | + let ffmpeg_frames = if bit_depth == 10 { | |
| 9149 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | |
| 9150 | + } else { | |
| 9151 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | |
| 9152 | + }; | |
| 9153 | + assert_eq!(frames.len(), frame_count); | |
| 9154 | + let mismatched = frames | |
| 9155 | + .iter() | |
| 9156 | + .zip(&ffmpeg_frames) | |
| 9157 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | |
| 9158 | + if fired.iter().sum::<usize>() == 0 { | |
| 9159 | + out_of_scope += 1; | |
| 9160 | + if mismatched { | |
| 9161 | + oos_mismatch += 1; | |
| 9162 | + eprintln!( | |
| 9163 | + "{NAME}: {bit_depth}-bit attempt {attempt} MISMATCHES with zero \ | |
| 9164 | + 16-level inter AB partition -- another shape's defect" | |
| 9165 | + ); | |
| 9166 | + } | |
| 9167 | + continue; | |
| 9168 | + } | |
| 9169 | + if mismatched { | |
| 9170 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 9171 | + let bad: Vec<usize> = | |
| 9172 | + (0..got.y.len()).filter(|&k| got.y[k] != want.y[k]).collect(); | |
| 9173 | + if !bad.is_empty() { | |
| 9174 | + eprintln!( | |
| 9175 | + "{NAME}: attempt {attempt} {bit_depth}-bit frame {i}: {} luma \ | |
| 9176 | + pixels differ, first at ({}, {}), max |delta| {}", | |
| 9177 | + bad.len(), | |
| 9178 | + bad[0] % width, | |
| 9179 | + bad[0] / width, | |
| 9180 | + bad.iter() | |
| 9181 | + .map(|&k| (got.y[k] as i32 - want.y[k] as i32).abs()) | |
| 9182 | + .max() | |
| 9183 | + .unwrap_or(0) | |
| 9184 | + ); | |
| 9185 | + } | |
| 9186 | + } | |
| 9187 | + } | |
| 9188 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 9189 | + assert_eq!(got.y, want.y, "{NAME} frame {i} luma vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); | |
| 9190 | + assert_eq!(got.u, want.u, "{NAME} frame {i} U vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); | |
| 9191 | + assert_eq!(got.v, want.v, "{NAME} frame {i} V vs ffmpeg (attempt {attempt}, {bit_depth}-bit, arms {fired:?})"); | |
| 9192 | + } | |
| 9193 | + for a in 0..4 { | |
| 9194 | + if fired[a] > 0 { | |
| 9195 | + arms_proved[a] += 1; | |
| 9196 | + arms_total[a] += 1; | |
| 9197 | + } | |
| 9198 | + } | |
| 9199 | + matched += 1; | |
| 9200 | + } | |
| 9201 | + eprintln!( | |
| 9202 | + "{NAME} ({bit_depth}-bit): {named_refusals} named refusals, {matched} pixel-exact \ | |
| 9203 | + attempts carrying a 16-level inter AB partition, per-arm attempts \ | |
| 9204 | + HORZ_A/HORZ_B/VERT_A/VERT_B={arms_proved:?}, {out_of_scope} attempts carried \ | |
| 9205 | + none ({oos_mismatch} of them mismatched)" | |
| 9206 | + ); | |
| 9207 | + assert_eq!( | |
| 9208 | + oos_mismatch, 0, | |
| 9209 | + "{NAME}: {oos_mismatch} attempt(s) with no 16-level inter AB partition decoded \ | |
| 9210 | + but mismatched ffmpeg -- a defect of another shape, not a pass" | |
| 9211 | + ); | |
| 9212 | + } | |
| 9213 | + assert!( | |
| 9214 | + arms_total.iter().all(|&n| n > 0), | |
| 9215 | + "{NAME}: not every 16-level inter AB arm fired on a pixel-exact attempt \ | |
| 9216 | + (HORZ_A/HORZ_B/VERT_A/VERT_B={arms_total:?}) -- the unfired arm(s) are unproven" | |
| 9217 | + ); | |
| 9218 | + } | |
| 9219 | + | |
| 9220 | + | |
| 8171 | 9221 | #[test] |
| 8172 | 9222 | fn a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact() { |
| 8173 | 9223 | if !have_ffmpeg() { |
| @@ -15808,14 +16858,159 @@ mod tests { | ||
| 15808 | 16858 | } |
| 15809 | 16859 | } |
| 15810 | 16860 | } |
| 15811 | - gate_buckets( | |
| 15812 | - "a_real_aomenc_min8_stream_with_tx_class1_decodes_pixel_exact", | |
| 15813 | - fired_runs, | |
| 15814 | - uncounted_exact, | |
| 15815 | - refusals.len() - uncounted_exact as usize, | |
| 15816 | - ); | |
| 15817 | - panic!( | |
| 15818 | - "fewer than 4 firing+pixel-exact runs out of 60 attempts:\n{}", | |
| 16861 | + gate_buckets( | |
| 16862 | + "a_real_aomenc_min8_stream_with_tx_class1_decodes_pixel_exact", | |
| 16863 | + fired_runs, | |
| 16864 | + uncounted_exact, | |
| 16865 | + refusals.len() - uncounted_exact as usize, | |
| 16866 | + ); | |
| 16867 | + panic!( | |
| 16868 | + "fewer than 4 firing+pixel-exact runs out of 60 attempts:\n{}", | |
| 16869 | + refusals.join("\n") | |
| 16870 | + ); | |
| 16871 | + } | |
| 16872 | + | |
| 16873 | + /// lane-cdef r1: CDEF's per-8x8 skip band under sub-16x16 inter leaves. | |
| 16874 | + /// | |
| 16875 | + /// `apply_cdef` excludes an 8x8 luma unit whose four mi cells are all | |
| 16876 | + /// `skip_txfm` (libaom `cdef.c:29-38 is_8x8_block_skip`, called from | |
| 16877 | + /// `av1_cdef_compute_sb_list`'s dlist loop). `decode_inter_block8` -- the | |
| 16878 | + /// leaf path `--min-partition-size=4` makes aomenc pick for a 16x16 group | |
| 16879 | + /// -- wrote the loop-filter grid but never that skip band, so an all-skip | |
| 16880 | + /// group kept the PREVIOUS frame's flags and got filtered where libaom | |
| 16881 | + /// skips it (3 luma samples, decode-order frames 3 and 4 of the 192x128 | |
| 16882 | + /// cq-8 stream below, at the frame's last 8x8 column). | |
| 16883 | + /// | |
| 16884 | + /// Both counters are hard asserts per compared attempt: `cdef_skipped_units` | |
| 16885 | + /// proves the all-skip dlist exclusion was actually reached, and | |
| 16886 | + /// `inter8_skip_band_hits` proves the 8x8 leaf path (the writer that used | |
| 16887 | + /// to be missing) ran on the same stream. | |
| 16888 | + #[test] | |
| 16889 | + fn a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact() { | |
| 16890 | + if !have_aomenc() { | |
| 16891 | + return; | |
| 16892 | + } | |
| 16893 | + let (width, height, frames) = (192usize, 128usize, 6usize); | |
| 16894 | + let mut refusals: Vec<String> = Vec::new(); | |
| 16895 | + let mut fired = 0u32; | |
| 16896 | + for (depth, cq, sp) in [(8u32, 8u32, 3u32), (8, 10, 3), (8, 12, 6), (10, 8, 3), (10, 12, 6)] { | |
| 16897 | + let pix = if depth == 10 { "yuv420p10le" } else { "yuv420p" }; | |
| 16898 | + let src = format!( | |
| 16899 | + "color=c=gray:s={width}x{height}:d=0.24:r=25,format=gray,\ | |
| 16900 | + geq=lum='128+58*sin((X+N*{sp})/6)+18*sin(Y/23)',format=yuv420p" | |
| 16901 | + ); | |
| 16902 | + let y4m = Command::new("ffmpeg") | |
| 16903 | + .args([ | |
| 16904 | + "-v", "error", "-f", "lavfi", "-i", &src, "-t", "0.24", "-pix_fmt", pix, | |
| 16905 | + "-strict", "-1", "-f", "yuv4mpegpipe", "-", | |
| 16906 | + ]) | |
| 16907 | + .stdin(Stdio::null()) | |
| 16908 | + .stdout(Stdio::piped()) | |
| 16909 | + .stderr(Stdio::piped()) | |
| 16910 | + .output() | |
| 16911 | + .expect("ffmpeg failed to run"); | |
| 16912 | + assert!( | |
| 16913 | + y4m.status.success(), | |
| 16914 | + "ffmpeg fixture: {}", | |
| 16915 | + String::from_utf8_lossy(&y4m.stderr) | |
| 16916 | + ); | |
| 16917 | + let mut child = Command::new(aomenc_path()) | |
| 16918 | + .args([ | |
| 16919 | + "--codec=av1", | |
| 16920 | + "--passes=1", | |
| 16921 | + "--end-usage=q", | |
| 16922 | + &format!("--cq-level={cq}"), | |
| 16923 | + "--cpu-used=0", | |
| 16924 | + "--threads=1", | |
| 16925 | + "--row-mt=0", | |
| 16926 | + "--sb-size=64", | |
| 16927 | + &format!("--bit-depth={depth}"), | |
| 16928 | + &format!("--input-bit-depth={depth}"), | |
| 16929 | + "--enable-restoration=0", | |
| 16930 | + "--enable-palette=0", | |
| 16931 | + "--deltaq-mode=0", | |
| 16932 | + "--enable-filter-intra=0", | |
| 16933 | + "--enable-cfl-intra=0", | |
| 16934 | + "--enable-intrabc=0", | |
| 16935 | + "--lag-in-frames=0", | |
| 16936 | + "--enable-obmc=0", | |
| 16937 | + "--enable-tx-size-search=1", | |
| 16938 | + "--enable-rect-partitions=0", | |
| 16939 | + "--enable-ab-partitions=0", | |
| 16940 | + "--enable-1to4-partitions=0", | |
| 16941 | + "--min-partition-size=4", | |
| 16942 | + "--max-partition-size=16", | |
| 16943 | + // Last occurrence of a repeated --enable-* flag wins | |
| 16944 | + // (aomenc-last-flag-wins): CDEF stays ON, and the two | |
| 16945 | + // counters below prove the filter really ran. | |
| 16946 | + "--enable-cdef=1", | |
| 16947 | + "--obu", | |
| 16948 | + "-o", | |
| 16949 | + "-", | |
| 16950 | + "-", | |
| 16951 | + ]) | |
| 16952 | + .stdin(Stdio::piped()) | |
| 16953 | + .stdout(Stdio::piped()) | |
| 16954 | + .stderr(Stdio::piped()) | |
| 16955 | + .spawn() | |
| 16956 | + .expect("aomenc failed to start"); | |
| 16957 | + child | |
| 16958 | + .stdin | |
| 16959 | + .take() | |
| 16960 | + .expect("aomenc stdin") | |
| 16961 | + .write_all(&y4m.stdout) | |
| 16962 | + .expect("writing y4m to aomenc"); | |
| 16963 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 16964 | + assert!( | |
| 16965 | + out.status.success(), | |
| 16966 | + "aomenc refused the fixture (depth={depth} cq={cq})" | |
| 16967 | + ); | |
| 16968 | + let stream = out.stdout; | |
| 16969 | + let skipped_before = decode::cdef_skipped_units(); | |
| 16970 | + let leaves_before = decode::inter8_skip_band_hits(); | |
| 16971 | + let decoded = match decode_stream(&stream) { | |
| 16972 | + Ok(f) => f, | |
| 16973 | + Err(e) => { | |
| 16974 | + let msg = e.to_string(); | |
| 16975 | + assert!( | |
| 16976 | + msg.starts_with("unsupported: "), | |
| 16977 | + "decode error that is not a named refusal \ | |
| 16978 | + (depth={depth} cq={cq}): {msg}" | |
| 16979 | + ); | |
| 16980 | + refusals.push(format!("depth={depth} cq={cq}: {msg}")); | |
| 16981 | + continue; | |
| 16982 | + } | |
| 16983 | + }; | |
| 16984 | + assert_eq!(decoded.len(), frames, "frame count (depth={depth} cq={cq})"); | |
| 16985 | + assert!( | |
| 16986 | + decode::cdef_skipped_units() > skipped_before, | |
| 16987 | + "no 8x8 CDEF unit was excluded by the all-skip rule \ | |
| 16988 | + (depth={depth} cq={cq})" | |
| 16989 | + ); | |
| 16990 | + assert!( | |
| 16991 | + decode::inter8_skip_band_hits() > leaves_before, | |
| 16992 | + "no sub-16x16 inter leaf wrote the CDEF skip band \ | |
| 16993 | + (depth={depth} cq={cq})" | |
| 16994 | + ); | |
| 16995 | + let reference = if depth == 10 { | |
| 16996 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frames) | |
| 16997 | + } else { | |
| 16998 | + ffmpeg_decode_sequence(&stream, width, height, frames) | |
| 16999 | + }; | |
| 17000 | + for (i, (ours, theirs)) in decoded.iter().zip(reference.iter()).enumerate() { | |
| 17001 | + assert_eq!(ours.y, theirs.y, "luma frame {i} (depth={depth} cq={cq})"); | |
| 17002 | + assert_eq!(ours.u, theirs.u, "U frame {i} (depth={depth} cq={cq})"); | |
| 17003 | + assert_eq!(ours.v, theirs.v, "V frame {i} (depth={depth} cq={cq})"); | |
| 17004 | + } | |
| 17005 | + fired += 1; | |
| 17006 | + } | |
| 17007 | + // Three of the five arms land on OTHER open refusals (a non-DC chroma | |
| 17008 | + // mode on an 8x8 inter leaf; inter partitions below 8x8) -- the two | |
| 17009 | + // 8-bit cq 8/10 arms ARE the streams the defect was found on, and each | |
| 17010 | + // hard-asserts both counters plus all six frames on all three planes. | |
| 17011 | + assert!( | |
| 17012 | + fired >= 2, | |
| 17013 | + "fewer than 2 firing+pixel-exact attempts:\n{}", | |
| 15819 | 17014 | refusals.join("\n") |
| 15820 | 17015 | ); |
| 15821 | 17016 | } |
| @@ -19682,6 +20877,411 @@ mod tests { | ||
| 19682 | 20877 | ); |
| 19683 | 20878 | } |
| 19684 | 20879 | |
| 20880 | + /// lane-golomb r2 gate: a 32x32-level block that STRADDLES the frame edge | |
| 20881 | + /// and whose partition is the gathered edge bit's `PARTITION_HORZ` (bottom | |
| 20882 | + /// edge) / `PARTITION_VERT` (right edge). Since r1 that bit can name | |
| 20883 | + /// HORZ/VERT instead of always inferring SPLIT, so the second 32x16/16x32 | |
| 20884 | + /// half is out of frame and must NOT be decoded (libaom `decode_partition`: | |
| 20885 | + /// `case PARTITION_HORZ: decode_block(top); if (has_rows) decode_block(bottom)`). | |
| 20886 | + /// The AB and 1:4 arms need no such guard: at an edge libaom's | |
| 20887 | + /// `ec_read_partition_impl` can only yield HORZ/VERT/SPLIT, so those arms | |
| 20888 | + /// are unreachable there. | |
| 20889 | + /// | |
| 20890 | + /// Geometry: 192x80 (mi_rows=20 -- the second SB row is 16 px tall, so its | |
| 20891 | + /// 32-level blocks at y=64 have `has_rows32 == false`) and 80x192 for the | |
| 20892 | + /// right edge. Natural content (`testsrc2`); `smptebars`-style screen | |
| 20893 | + /// content trips the palette/screen-content refusal before the edge is | |
| 20894 | + /// reached. cq sweep, 8-bit and 10-bit, plus a 5-frame inter arm. | |
| 20895 | + /// Counters are sampled per attempt and summed only over attempts that | |
| 20896 | + /// decoded AND pixel-compared (class `counter-from-refused-stream`). | |
| 20897 | + #[test] | |
| 20898 | + fn a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact() { | |
| 20899 | + edge32_gate( | |
| 20900 | + "a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact", | |
| 20901 | + false, | |
| 20902 | + ); | |
| 20903 | + } | |
| 20904 | + | |
| 20905 | + /// lane-golomb r2 OPEN DEFECT, pinned as a runnable test: with the 16-px | |
| 20906 | + /// straddling band left FLAT the encoder answers the 32-level edge bit | |
| 20907 | + /// with HORZ (`edge32=[2, 0, 2, 0]` on 192x80 cq40 8-bit), the guard added | |
| 20908 | + /// this round keeps the stream in entropy sync -- every pixel outside the | |
| 20909 | + /// two edge strips matches ffmpeg -- but the strips themselves | |
| 20910 | + /// reconstruct wrong: `plane Y: 1081 pixels differ, first at row 62 col | |
| 20911 | + /// 128`, diffs confined to rows 62..79 over ~64 columns (exactly the two | |
| 20912 | + /// 32x16 strips plus the deblock bleed above them). That is a | |
| 20913 | + /// reconstruction defect inside the strip (prediction/availability), not | |
| 20914 | + /// the partition guard. `#[ignore]` so the suite stays green; run it with | |
| 20915 | + /// `cargo test -p ec-av1 --lib -- --ignored a_32x32_frame_edge_rect_partition_with_a_flat`. | |
| 20916 | + #[test] | |
| 20917 | + #[ignore = "open r2 defect: the 32-level edge HORZ strip reconstructs wrong pixels"] | |
| 20918 | + fn a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact() { | |
| 20919 | + edge32_gate( | |
| 20920 | + "a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact", | |
| 20921 | + true, | |
| 20922 | + ); | |
| 20923 | + } | |
| 20924 | + | |
| 20925 | + /// lane-golomb r9 OPEN DEFECT, pinned as a runnable test: a frame whose | |
| 20926 | + /// height (192x68) or width (68x192) is not a multiple of 8 leaves a 4-px | |
| 20927 | + /// straddling band inside the mi-rounded plane, and every INTER frame's | |
| 20928 | + /// output is +-1 wrong across that band and the columns/rows next to it | |
| 20929 | + /// (`68x192 cq35 8-bit: frame 1 plane Y: 145 pixels differ, first at row 0 | |
| 20930 | + /// col 64`, mass in columns 64..67). r9 bisected it stage by stage against | |
| 20931 | + /// the instrumented aomdec on that exact stream: | |
| 20932 | + /// * `EC_AV1_PREFILT_DUMP` frame 1 is BYTE-IDENTICAL over the cropped | |
| 20933 | + /// 68 columns -- reconstruction and inter prediction are exact, so the | |
| 20934 | + /// charter's "MC reads past the crop" hypothesis is refuted a second time. | |
| 20935 | + /// * `EC_AV1_POSTDEBLOCK_DUMP` with `EC_AV1_DEBUG_SKIP_CDEF=1` also matches | |
| 20936 | + /// aomdec's own post-deblock dump (which is 72 columns wide, i.e. it | |
| 20937 | + /// exposes the straddling band) -- the deblock, including its | |
| 20938 | + /// `frame_width` clip, is correct. | |
| 20939 | + /// * The divergence therefore enters in CDEF, at the last 8x8 CDEF block | |
| 20940 | + /// column/row, which is the one that straddles the crop edge. | |
| 20941 | + /// lane-cdef r2: CLOSED, and un-ignored. r1 rooted the luma half in | |
| 20942 | + /// `apply_cdef`'s direction search, which clamped at the CROPPED frame | |
| 20943 | + /// edge while libaom runs `cdef_find_dir` over `cdef_prepare_fb`'s buffer | |
| 20944 | + /// -- whose columns/rows past the MI-ROUNDED extent (`hsize = nhb << | |
| 20945 | + /// mi_wide_l2`, `cdef.c:164-167`, and the `frame_boundary[RIGHT]` | |
| 20946 | + /// CDEF_VERY_LARGE fill at `cdef.c:249-256`) are CDEF_VERY_LARGE, not the | |
| 20947 | + /// last real sample. The chroma half was lane-golomb r8's loop-restoration | |
| 20948 | + /// plane size (LR is the one post-decode filter sized by the CROP, not the | |
| 20949 | + /// mi grid) plus its reference-size fix; merging both branches takes all | |
| 20950 | + /// four arms to 0 differing pixels on Y, U and V. | |
| 20951 | + /// | |
| 20952 | + /// Arms: 192x68 and 68x192 (a 4-px straddling band on one axis), 5 frames, | |
| 20953 | + /// 8-bit and 10-bit, plus a `--tile-columns=1` twin of each (COMMON's | |
| 20954 | + /// neighbour-map rule -- the skip band CDEF reads is a per-mi side band). | |
| 20955 | + /// MEASURED 2026-09-02: all 32 multi-tile attempts refuse BY NAME today, | |
| 20956 | + /// so that half of the gate compares nothing yet (class | |
| 20957 | + /// `counter-from-refused-stream`); the census is 10x "an inter SB-level AB | |
| 20958 | + /// partition", 6x "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs | |
| 20959 | + /// rectangular residual coding", 6x "an 8x8 intra leaf in an inter frame | |
| 20960 | + /// whose tx_depth splits it into 4x4 transform units", 5x "an inter | |
| 20961 | + /// partition below 8x8", 3x "an inter 16x16-level AB or 1:4 partition", | |
| 20962 | + /// 1x "a split intra strip whose transform unit is 32x64", 1x "an | |
| 20963 | + /// intra-coded 1:4 (or other non-2:1) rect strip on the inter block path". | |
| 20964 | + /// The arms stay so the coverage appears the day those lift; every assert | |
| 20965 | + /// below is carried by the single-tile arms. | |
| 20966 | + /// Hard-asserts `decode::cdef_straddle_units()` grew: a FILTERED 8x8 CDEF | |
| 20967 | + /// unit whose extent crosses the crop edge is the only shape for which | |
| 20968 | + /// clamping and padding differ, so a zero delta would make these arms | |
| 20969 | + /// vacuous for this defect. | |
| 20970 | + #[test] | |
| 20971 | + fn a_frame_edge_straddling_band_decodes_pixel_exact() { | |
| 20972 | + edge32_gate( | |
| 20973 | + "a_frame_edge_straddling_band_decodes_pixel_exact", | |
| 20974 | + false, | |
| 20975 | + ); | |
| 20976 | + } | |
| 20977 | + | |
| 20978 | + fn edge32_gate(name: &str, flat_band: bool) { | |
| 20979 | + let NAME = name; | |
| 20980 | + let _gate_lock = lock_gate_counters(); | |
| 20981 | + if !have_ffmpeg() { | |
| 20982 | + eprintln!("SKIP {NAME}: no ffmpeg"); | |
| 20983 | + return; | |
| 20984 | + } | |
| 20985 | + if !have_aomenc() { | |
| 20986 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | |
| 20987 | + return; | |
| 20988 | + } | |
| 20989 | + // (width, height, frames, ten_bit, tile_columns_log2) | |
| 20990 | + let mut arms: Vec<(usize, usize, usize, bool, u32)> = Vec::new(); | |
| 20991 | + for &(w, h) in &[(192usize, 80usize), (80usize, 192usize)] { | |
| 20992 | + arms.push((w, h, 1, false, 0)); | |
| 20993 | + arms.push((w, h, 1, true, 0)); | |
| 20994 | + } | |
| 20995 | + // The inter arm: >= 4 frames so the 32-level edge path in the INTER | |
| 20996 | + // tile walk is exercised too. | |
| 20997 | + arms.push((192, 80, 5, false, 0)); | |
| 20998 | + // lane-golomb r9: the straddling-band arms, only under the ignored | |
| 20999 | + // `a_frame_edge_straddling_band_decodes_pixel_exact` name (they are | |
| 21000 | + // RED -- see that test's own comment for the stage bisection). Naming | |
| 21001 | + // them here rather than in a second copy of this gate keeps the | |
| 21002 | + // recipe, the counters and the refusal handling identical. | |
| 21003 | + if name == "a_frame_edge_straddling_band_decodes_pixel_exact" { | |
| 21004 | + arms.clear(); | |
| 21005 | + for &tile_cols in &[0u32, 1] { | |
| 21006 | + arms.push((192, 68, 5, false, tile_cols)); | |
| 21007 | + arms.push((192, 68, 5, true, tile_cols)); | |
| 21008 | + arms.push((68, 192, 5, false, tile_cols)); | |
| 21009 | + arms.push((68, 192, 5, true, tile_cols)); | |
| 21010 | + } | |
| 21011 | + } | |
| 21012 | + // lane-golomb r8 MEASURED, arm STILL NOT added (every cq level is | |
| 21013 | + // vacuous, panicking or red -- each measured this round with | |
| 21014 | + // `arms.push((192, 68, 5, false))`, log | |
| 21015 | + // `$HOME/.cache/golomb-gate-r8{b,e,f,g}.log`): | |
| 21016 | + // * the r7 blocker IS fixed -- no attempt refuses "a reference | |
| 21017 | + // picture whose height does not match this frame's own true | |
| 21018 | + // size" any more (`decode.rs`'s comparison now uses the header's | |
| 21019 | + // frame height, per libaom's crop-dimension reference test). | |
| 21020 | + // * cq35 now refuses LATER, by another lane's name: "an inter | |
| 21021 | + // SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B)" -- so the | |
| 21022 | + // arm compares nothing (class `counter-from-refused-stream`). | |
| 21023 | + // * cq40 PANICS in `decode_inter_block8` | |
| 21024 | + // (`from_switchable_symbol` handed a 4th symbol, `mc.rs:203`) = | |
| 21025 | + // lane-sub8's own open below-8x8 desync; a panic cannot be | |
| 21026 | + // tolerated as a named refusal. | |
| 21027 | + // * cq59 8-bit is RED: `frame 1 plane Y: 217 pixels differ, first | |
| 21028 | + // at row 60 col 170 (ours 172 vs ffmpeg 173)`, and the cq35 | |
| 21029 | + // 10-bit twin is RED at `row 56 col 48 (ours 530 vs ffmpeg | |
| 21030 | + // 531)`. Both are +-1 bands in rows 56..63, i.e. the deblock/CDEF | |
| 21031 | + // bleed ABOVE the 4-px straddling row band (64..67) -- the same | |
| 21032 | + // shape as the `(68, 192, 5, false)` column defect below, so the | |
| 21033 | + // two are very likely ONE straddling-band reconstruction defect. | |
| 21034 | + // lane-golomb r7 MEASURED, arm NOT added (it would be vacuous or red): | |
| 21035 | + // a 68-px axis leaves the last superblock straddling by 4 px, the | |
| 21036 | + // shape `read_var_tx_size`'s `blk_row >= max_h_mi || blk_col >= | |
| 21037 | + // max_w_mi` early return exists for. With | |
| 21038 | + // `arms.push((192, 68, 5, false))` all EIGHT cq attempts refuse by | |
| 21039 | + // name -- "a reference picture whose height does not match this | |
| 21040 | + // frame's own true size" -- so the arm compares nothing (class | |
| 21041 | + // `counter-from-refused-stream`). With | |
| 21042 | + // `arms.push((68, 192, 5, false))` the gate goes RED on a real, | |
| 21043 | + // separate defect: `68x192 cq35 frames=5 10bit=false frame 1 plane Y: | |
| 21044 | + // 141 pixels differ, first at row 0 col 64 (ours 167 vs ffmpeg 166) | |
| 21045 | + // [edge32=[0,34,0,0,1,17,0,1]]` -- LUMA, inside the 4-px straddling | |
| 21046 | + // COLUMN. Both are unrelated to this round's chroma tx_type fix. | |
| 21047 | + let cqs: [u32; 8] = [35, 40, 45, 50, 55, 57, 59, 61]; | |
| 21048 | + let mut totals = [0usize; 8]; | |
| 21049 | + let mut compared = 0usize; | |
| 21050 | + let mut refusals: Vec<String> = Vec::new(); | |
| 21051 | + let straddle = name == "a_frame_edge_straddling_band_decodes_pixel_exact"; | |
| 21052 | + let mut straddle_units = 0usize; | |
| 21053 | + for &(width, height, frame_count, ten_bit, tile_cols) in &arms { | |
| 21054 | + for &cq in &cqs { | |
| 21055 | + let duration = frame_count as f64 / 25.0; | |
| 21056 | + // `noise` (explicit seed) both defeats aomenc's | |
| 21057 | + // screen-content detection -- which otherwise refuses every | |
| 21058 | + // attempt at "a HORZ/VERT intra strip in a screen-content | |
| 21059 | + // frame" -- and keeps the RD search off flat NONE blocks. | |
| 21060 | + // Natural content over the whole superblock-aligned area, | |
| 21061 | + // with the 16-px straddling band left FLAT (`pad`): with | |
| 21062 | + // detail in that band aomenc always answers the edge bit with | |
| 21063 | + // SPLIT (measured: 178 edge bits, 178 of them SPLIT, over a | |
| 21064 | + // cq 35..61 sweep), so the HORZ/VERT arm this round guards | |
| 21065 | + // never fired. `noise` on top keeps screen-content detection | |
| 21066 | + // (and its palette-strip refusal) off. | |
| 21067 | + let (cw, ch) = ( | |
| 21068 | + if flat_band && width % 64 != 0 { width - 16 } else { width }, | |
| 21069 | + if flat_band && height % 64 != 0 { height - 16 } else { height }, | |
| 21070 | + ); | |
| 21071 | + let pad = if flat_band { | |
| 21072 | + format!("pad={width}:{height}:0:0:gray,") | |
| 21073 | + } else { | |
| 21074 | + String::new() | |
| 21075 | + }; | |
| 21076 | + let source = format!( | |
| 21077 | + "testsrc2=size={cw}x{ch}:duration={duration}:rate=25,\ | |
| 21078 | + {pad}noise=alls=6:allf=t+u:all_seed={cq}" | |
| 21079 | + ); | |
| 21080 | + let pix = if ten_bit { "yuv420p10le" } else { "yuv420p" }; | |
| 21081 | + let y4m = Command::new("ffmpeg") | |
| 21082 | + .args([ | |
| 21083 | + "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", pix, "-strict", | |
| 21084 | + "-1", "-t", &format!("{duration}"), "-f", "yuv4mpegpipe", "-", | |
| 21085 | + ]) | |
| 21086 | + .stdin(Stdio::null()) | |
| 21087 | + .stdout(Stdio::piped()) | |
| 21088 | + .stderr(Stdio::piped()) | |
| 21089 | + .output() | |
| 21090 | + .expect("ffmpeg failed to run"); | |
| 21091 | + assert!( | |
| 21092 | + y4m.status.success(), | |
| 21093 | + "{NAME}: ffmpeg fixture: {}", | |
| 21094 | + String::from_utf8_lossy(&y4m.stderr) | |
| 21095 | + ); | |
| 21096 | + let cq_arg = format!("--cq-level={cq}"); | |
| 21097 | + let mut args: Vec<&str> = vec![ | |
| 21098 | + "--codec=av1", | |
| 21099 | + "--passes=1", | |
| 21100 | + "--end-usage=q", | |
| 21101 | + &cq_arg, | |
| 21102 | + "--cpu-used=0", | |
| 21103 | + "--threads=1", | |
| 21104 | + "--row-mt=0", | |
| 21105 | + "--sb-size=64", | |
| 21106 | + "--enable-restoration=0", | |
| 21107 | + "--enable-palette=0", | |
| 21108 | + "--deltaq-mode=0", | |
| 21109 | + "--enable-intrabc=0", | |
| 21110 | + // Per-arm overrides go LAST (aomenc keeps the last | |
| 21111 | + // occurrence of a repeated --enable-* flag). | |
| 21112 | + "--enable-rect-partitions=1", | |
| 21113 | + "--enable-ab-partitions=0", | |
| 21114 | + "--enable-1to4-partitions=0", | |
| 21115 | + // 32, not the charter's 8: at 8 the sub-16 AB and | |
| 21116 | + // split-transform strip arms (still refused by name here) | |
| 21117 | + // fire before the 32-level edge is reached and EVERY | |
| 21118 | + // attempt refuses (measured). At 32 the edge block cannot | |
| 21119 | + // split, so aomenc is forced onto the gathered edge bit's | |
| 21120 | + // HORZ/VERT -- exactly the arm this round guards. | |
| 21121 | + "--min-partition-size=32", | |
| 21122 | + "--tune-content=film", | |
| 21123 | + "--max-partition-size=64", | |
| 21124 | + ]; | |
| 21125 | + if ten_bit { | |
| 21126 | + args.extend_from_slice(&["--input-bit-depth=10", "--bit-depth=10"]); | |
| 21127 | + } | |
| 21128 | + let tile_arg = format!("--tile-columns={tile_cols}"); | |
| 21129 | + if tile_cols > 0 { | |
| 21130 | + args.push(&tile_arg); | |
| 21131 | + } | |
| 21132 | + args.extend_from_slice(&["--obu", "-o", "-", "-"]); | |
| 21133 | + let mut child = Command::new(aomenc_path()) | |
| 21134 | + .args(&args) | |
| 21135 | + .stdin(Stdio::piped()) | |
| 21136 | + .stdout(Stdio::piped()) | |
| 21137 | + .stderr(Stdio::piped()) | |
| 21138 | + .spawn() | |
| 21139 | + .expect("aomenc failed to start"); | |
| 21140 | + child | |
| 21141 | + .stdin | |
| 21142 | + .take() | |
| 21143 | + .expect("aomenc stdin") | |
| 21144 | + .write_all(&y4m.stdout) | |
| 21145 | + .expect("writing y4m to aomenc"); | |
| 21146 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 21147 | + assert!( | |
| 21148 | + out.status.success(), | |
| 21149 | + "{NAME}: aomenc refused the fixture: {}", | |
| 21150 | + String::from_utf8_lossy(&out.stderr) | |
| 21151 | + ); | |
| 21152 | + let stream = out.stdout; | |
| 21153 | + if ten_bit { | |
| 21154 | + assert_eq!( | |
| 21155 | + parsed_bit_depth(&stream), | |
| 21156 | + 10, | |
| 21157 | + "{NAME}: aomenc did not write a 10-bit sequence header" | |
| 21158 | + ); | |
| 21159 | + } | |
| 21160 | + let tag = format!( | |
| 21161 | + "{width}x{height} cq{cq} frames={frame_count} 10bit={ten_bit} \ | |
| 21162 | + tile_cols={tile_cols}" | |
| 21163 | + ); | |
| 21164 | + let before = crate::decode::edge32_hits(); | |
| 21165 | + let straddle_before = crate::decode::cdef_straddle_units(); | |
| 21166 | + // lane-golomb r8: name the attempt BEFORE decoding it -- a | |
| 21167 | + // desync surfaces as a panic deep in mc.rs with no arm in the | |
| 21168 | + // message, and r8 spent a run bisecting arms by hand. | |
| 21169 | + if std::env::var_os("EC_GATE_VERBOSE").is_some() { | |
| 21170 | + eprintln!("{NAME}: attempting {tag}"); | |
| 21171 | + } | |
| 21172 | + let decoded = match decode_stream(&stream) { | |
| 21173 | + Ok(frames) => frames, | |
| 21174 | + Err(e) => { | |
| 21175 | + let msg = e.to_string(); | |
| 21176 | + assert!( | |
| 21177 | + msg.contains("unsupported"), | |
| 21178 | + "{NAME} failed outright, not a named refusal ({tag}): {msg}" | |
| 21179 | + ); | |
| 21180 | + refusals.push(format!("{tag}: {msg}")); | |
| 21181 | + continue; | |
| 21182 | + } | |
| 21183 | + }; | |
| 21184 | + let after = crate::decode::edge32_hits(); | |
| 21185 | + let delta: Vec<usize> = | |
| 21186 | + (0..8).map(|i| after[i] - before[i]).collect(); | |
| 21187 | + let reference = if ten_bit { | |
| 21188 | + ffmpeg_decode_sequence_10bit(&stream, width, height, decoded.len()) | |
| 21189 | + } else { | |
| 21190 | + ffmpeg_decode_sequence(&stream, width, height, decoded.len()) | |
| 21191 | + }; | |
| 21192 | + assert_eq!( | |
| 21193 | + decoded.len(), | |
| 21194 | + reference.len(), | |
| 21195 | + "{NAME}: {tag}: shown-frame count vs ffmpeg" | |
| 21196 | + ); | |
| 21197 | + for (i, (ours, theirs)) in decoded.iter().zip(reference.iter()).enumerate() { | |
| 21198 | + for (plane, a, b, w) in [ | |
| 21199 | + ("Y", &ours.y, &theirs.y, width), | |
| 21200 | + ("U", &ours.u, &theirs.u, width / 2), | |
| 21201 | + ("V", &ours.v, &theirs.v, width / 2), | |
| 21202 | + ] { | |
| 21203 | + if let Some(d) = a.iter().zip(b.iter()).position(|(x, y)| x != y) { | |
| 21204 | + let n = a.iter().zip(b.iter()).filter(|(x, y)| x != y).count(); | |
| 21205 | + if std::env::var_os("EC_EDGE32_ROWS").is_some() { | |
| 21206 | + let mut per_row: std::collections::BTreeMap<usize, usize> = | |
| 21207 | + Default::default(); | |
| 21208 | + for (k, (x, y)) in a.iter().zip(b.iter()).enumerate() { | |
| 21209 | + if x != y { | |
| 21210 | + *per_row.entry(k / w).or_default() += 1; | |
| 21211 | + } | |
| 21212 | + } | |
| 21213 | + eprintln!("{NAME}: {tag} plane {plane} diffs per row: {per_row:?}"); | |
| 21214 | + } | |
| 21215 | + panic!( | |
| 21216 | + "{NAME}: {tag} frame {i} plane {plane}: {n} pixels differ, first \ | |
| 21217 | + at row {} col {} (ours {} vs ffmpeg {}) [edge32={delta:?}]", | |
| 21218 | + d / w, | |
| 21219 | + d % w, | |
| 21220 | + a[d], | |
| 21221 | + b[d] | |
| 21222 | + ); | |
| 21223 | + } | |
| 21224 | + } | |
| 21225 | + } | |
| 21226 | + compared += 1; | |
| 21227 | + straddle_units += crate::decode::cdef_straddle_units() - straddle_before; | |
| 21228 | + for i in 0..8 { | |
| 21229 | + totals[i] += delta[i]; | |
| 21230 | + } | |
| 21231 | + } | |
| 21232 | + } | |
| 21233 | + assert!( | |
| 21234 | + compared > 0, | |
| 21235 | + "{NAME}: every attempt hit a named refusal:\n{}", | |
| 21236 | + refusals.join("\n") | |
| 21237 | + ); | |
| 21238 | + assert!( | |
| 21239 | + !straddle || straddle_units > 0, | |
| 21240 | + "{NAME}: no FILTERED 8x8 CDEF unit crossed the cropped frame edge over \ | |
| 21241 | + {compared} compared attempts -- the straddling arms proved nothing" | |
| 21242 | + ); | |
| 21243 | + assert!( | |
| 21244 | + totals[0] + totals[1] + totals[4] + totals[5] > 0, | |
| 21245 | + "{NAME}: no frame-edge partition bit was read at all over \ | |
| 21246 | + {compared} compared attempts -- the gate proved nothing" | |
| 21247 | + ); | |
| 21248 | + // lane-golomb r3: the flat-band arm's ASSERT moved one level up. Until | |
| 21249 | + // r3 the last superblock row was reached through a 32-level edge bit | |
| 21250 | + // only because our own out-of-frame transform units had desynced the | |
| 21251 | + // stream; with that fixed, real aomenc answers a bottom-edge | |
| 21252 | + // superblock with the 64-level `PARTITION_HORZ` (and a right-edge one | |
| 21253 | + // with `PARTITION_VERT`) and the 32-level slots stay 0 on this | |
| 21254 | + // content. Slots 6/7 are the strips actually decoded at the edge. | |
| 21255 | + assert!( | |
| 21256 | + !flat_band || totals[6] > 0, | |
| 21257 | + "{NAME}: no 64x32 bottom-edge HORZ strip was decoded \ | |
| 21258 | + (edge32={totals:?}, {compared} compared attempts)" | |
| 21259 | + ); | |
| 21260 | + assert!( | |
| 21261 | + !flat_band || totals[7] > 0, | |
| 21262 | + "{NAME}: no 32x64 right-edge VERT strip was decoded \ | |
| 21263 | + (edge32={totals:?}, {compared} compared attempts)" | |
| 21264 | + ); | |
| 21265 | + eprintln!( | |
| 21266 | + "{NAME}: {compared} pixel-exact attempts, 32-level edge bits \ | |
| 21267 | + [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, 64-level edge bits \ | |
| 21268 | + [horz_or_vert={} split={}] bottom-HORZ={} right-VERT={}, \ | |
| 21269 | + {straddle_units} straddling CDEF units, {} named refusals", | |
| 21270 | + totals[0], | |
| 21271 | + totals[1], | |
| 21272 | + totals[2], | |
| 21273 | + totals[3], | |
| 21274 | + totals[4], | |
| 21275 | + totals[5], | |
| 21276 | + totals[6], | |
| 21277 | + totals[7], | |
| 21278 | + refusals.len() | |
| 21279 | + ); | |
| 21280 | + for r in &refusals { | |
| 21281 | + eprintln!("{NAME} refusal: {r}"); | |
| 21282 | + } | |
| 21283 | + } | |
| 21284 | + | |
| 19685 | 21285 | /// lane-sqchroma r1 gate: a plain SQUARE-partition intra key frame with |
| 19686 | 21286 | /// REAL chroma (no `hue=s=0` guard) and aomenc's tx-size search left at |
| 19687 | 21287 | /// its own DEFAULT (on) -- the combination the user's films hit |
| @@ -21811,6 +23411,11 @@ mod tests { | ||
| 21811 | 23411 | let (mut horz_proved, mut vert_proved) = (0usize, 0usize); |
| 21812 | 23412 | let (mut chroma_proved, mut coeff_proved) = (0usize, 0usize); |
| 21813 | 23413 | let mut split_proved = 0usize; |
| 23414 | + // lane-kf1200: chroma pairs whose intra-edge filter type comes out | |
| 23415 | + // different when read from the PAIR's base mi (libaom's | |
| 23416 | + // `chroma_above_mbmi`) rather than the odd strip mi -- the shape | |
| 23417 | + // that was silently wrong by 1 on the ReelB key frames. | |
| 23418 | + let mut pair_filt_proved = 0usize; | |
| 21814 | 23419 | let (mut out_of_scope, mut out_of_scope_mismatch) = (0u32, 0u32); |
| 21815 | 23420 | // The second half of the window turns `--enable-tx-size-search` on: |
| 21816 | 23421 | // that is what makes a 16x4 strip SPLIT its transform (depth 1 = |
| @@ -21823,11 +23428,26 @@ mod tests { | ||
| 21823 | 23428 | let axis = if attempt % 2 == 0 { "Y" } else { "X" }; |
| 21824 | 23429 | let step = 67 + (attempt / 2) * 12; |
| 21825 | 23430 | let noise = 6 + (attempt % 4) * 3; |
| 21826 | - let source = format!( | |
| 21827 | - "color=c=gray:s={width}x{height}:d={duration}:r=25,format=gray,\ |
lanes/cdef-r1.handoff.mdadded+66 -0
| @@ -0,0 +1,66 @@ | ||
| 1 | +# lane-cdef r1 -- HANDOFF (2 CDEF defects rooted, both fixed, gate GREEN; one residue open) | |
| 2 | + | |
| 3 | +Base: main 48b35ab. Suite unit `cdef-suite-1788330834.service` -> `$HOME/.cache/cdef-suite-r1.log` | |
| 4 | +(started at the turn cap; FIRST THING NEXT ROUND: `grep -E "^test result|FAILED" $HOME/.cache/cdef-suite-r1.log`). | |
| 5 | + | |
| 6 | +## Defect A -- per-8x8 CDEF skip band never written by the 8x8 inter leaf (charter hypothesis (a), variant) | |
| 7 | + | |
| 8 | +* Stream: `~/.cache/cdef-tmp/a0_8.obu`, sha256 `aa40f17f6e49eca2bb8c9d9ab99a175312134bdcf45c39b8a76b6757d8536751` | |
| 9 | + (hashed twice, identical), `~/.cache/cdef-tmp/gen.sh 8 3 8 a0_8.obu` = lane-intersub8's recipe, | |
| 10 | + 192x128, 6 frames, `--min-partition-size=4`, cq 8, 8-bit. | |
| 11 | +* Stage attribution: reconstruction and post-deblock are EXACT (`EC_AV1_POSTDEBLOCK_DUMP` ours vs | |
| 12 | + the instrumented aomdec: 0/24576 luma on decode-order frame 3); the 3 samples enter at CDEF. | |
| 13 | + NOTE: aomdec's `EC_AV1_PREFILT_DUMP` is ALREADY POST-DEBLOCK on this build (r_pre.fN == r_pd.fN | |
| 14 | + for 5 of 6 frames) -- ours is genuinely pre-deblock, so the two rungs are NOT the same stage. | |
| 15 | +* Root cause: `decode_inter_block8` (decode.rs, the leaf path `--min-partition-size=4` picks for a | |
| 16 | + 16x16 group) wrote `record_mi` + `fill_lf_grid` at both exits but NEVER `fill_skip_grid`. The | |
| 17 | + bottom-right 16x16 of decode-order frame 3 was therefore judged by the PREVIOUS frame's flags: | |
| 18 | + our 8x8 units at mi(28,46)/(30,46) read skip=false and were filtered, while libaom's | |
| 19 | + `is_8x8_block_skip` (cdef.c:29-38, called from `av1_cdef_compute_sb_list` cdef.c:40-71) excludes | |
| 20 | + an all-skip 8x8 from the dlist. Proof: a python model of `cdef_block.c` reproduces the reference | |
| 21 | + for all 16 units of the last column at (sec=1,damp=3) EXCEPT those two, where only "unfiltered" | |
| 22 | + matches; frame-3 fill log showed 0 of 95 skip fills covering mi(28,44)+16x16. | |
| 23 | +* Fix: `neighbours.fill_skip_grid(leaf_mi, 2, skip)` at both `decode_inter_block8` exits (compound | |
| 24 | + early return + fall-through), each bumping `INTER8_SKIP_BAND_HITS`. | |
| 25 | +* Before/after on the pinned stream: frames 3 and 4 had 3 luma samples |d|=1 each | |
| 26 | + ((189,116/120/124) and (186,116/120/124)); after, all 6 frames pixel-exact on Y/U/V. | |
| 27 | + | |
| 28 | +## Defect B -- CDEF direction search clamped at the crop edge instead of reading CDEF_VERY_LARGE | |
| 29 | + | |
| 30 | +* Stream: `~/.cache/golomb-tmp/s68.obu` (68x192, 5 frames, 8-bit, cq 35) -- lane-golomb r9's | |
| 31 | + deferred "straddle band". | |
| 32 | +* Root cause: `apply_cdef`'s `cdef_find_dir` closure clamped to `true_w-1`/`true_h-1`, but libaom | |
| 33 | + runs `cdef_find_dir` over `cdef_prepare_fb`'s buffer (cdef.c:249-256 `frame_boundary[RIGHT]` | |
| 34 | + fill, cdef_block.c:296-320), whose columns/rows past the mi-rounded extent are CDEF_VERY_LARGE. | |
| 35 | + With odd `mi_cols` (68 px -> 17 mi) the last 8x8 straddles, so var/`adjust_strength` differed. | |
| 36 | +* Fix: the direction search now reads the SAME padded `sample_y` the taps use (one line). | |
| 37 | +* Before/after: frame 1 luma 145 diffs -> **0**; all 5 frames luma exact. | |
| 38 | +* RESIDUE (open, NOT fixed): the same stream still differs in CHROMA from frame 1 on | |
| 39 | + (U/V 194/401/466/551 samples, |d| up to 6, spread over ~37 chroma 4x4 units, frame 0 exact). | |
| 40 | + Not attributable yet: `EC_AV1_DEBUG_SKIP_CDEF=1` cannot bisect inter frames (it also breaks the | |
| 41 | + reference frames), so the postdeblock rung is only valid for frame 0 here. Next step: dump | |
| 42 | + per-4x4 chroma CDEF params (uv pri/sec, damping-1, shared luma dir) for frame 1's first | |
| 43 | + differing unit and model it against `cdef_block.c` the way defect A was modelled | |
| 44 | + (`~/.cache/cdef-tmp/model.py` is a complete python port of cdef_block.c + find_dir + adjust). | |
| 45 | + | |
| 46 | +## Gate | |
| 47 | +`stream.rs::a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact` -- real | |
| 48 | +aomenc, `--min-partition-size=4 --enable-cdef=1` (last flag wins), 5 arms (8-bit cq 8/10/12, | |
| 49 | +10-bit cq 8/12), every decode-order frame compared on Y/U/V, hard asserts | |
| 50 | +`decode::cdef_skipped_units()` (an 8x8 unit really excluded by the all-skip rule) and | |
| 51 | +`decode::inter8_skip_band_hits()` (the leaf that used to write nothing) both grew per compared | |
| 52 | +attempt. 2 of 5 arms fire; the other 3 hit UNRELATED open refusals (non-DC chroma mode on an 8x8 | |
| 53 | +inter leaf; inter partition below 8x8) -- widening to 10-bit needs those lifted first. | |
| 54 | +`cargo test -p ec-av1 --lib cdef_and_sub16` -> ok, 1 passed / 0 failed. | |
| 55 | + | |
| 56 | +## Other | |
| 57 | +* `dump_stage`/`dump_stage16` wrote `.f0` for EVERY frame (each overwrote the last), so | |
| 58 | + `EC_AV1_POSTDEBLOCK_DUMP`/`POSTCDEF_DUMP` were unusable for per-frame bisection. Now indexed | |
| 59 | + per env var (`dump_stage_idx`), matching aomdec's own `.fN`. | |
| 60 | +* New rung `EC_AV1_CDEF_DBG=1`: one line per filtered 8x8 luma unit | |
| 61 | + (`EC_CDEF mi_r= mi_c= x= y= sidx= dir= var= t= pri= sec= damp=`). | |
| 62 | +* Class sweep for "per-8x8 map read at the top-left mi only under sub-8x8 partitions": the skip | |
| 63 | + grid is written by every OTHER leaf path (grep `fill_skip_grid`), `decode_inter_block8` was the | |
| 64 | + only writer missing; `is_skip_txfm` already gathers all four cells; the deblock/tx grid has a | |
| 65 | + `fill_lf_grid` at every one of those sites including both `decode_inter_block8` exits. | |
| 66 | +* Not done: `--tile-columns=1` arm on the new gate (COMMON neighbour-map rule) -- deferred. |
lanes/cdef-r2.report.mdadded+83 -0
| @@ -0,0 +1,83 @@ | ||
| 1 | +# lane-cdef r2 report -- merge, the 68x192 chroma residue CLOSED, gate un-ignored | |
| 2 | + | |
| 3 | +Branch `lane-cdef`, base main `727f29a`. Commits this round: | |
| 4 | +* `32a467a` Merge main 727f29a (lane-r14, lane-kf1200, lane-reelckf) -- no conflicts. | |
| 5 | +* `0e6c5c9` Merge lane-golomb 173b793 -- 2 conflicts in `decode.rs`, both resolved (below). | |
| 6 | +* `26b971a` straddling-band gate un-ignored + `CDEF_STRADDLE_UNITS` counter + multi-tile arms. | |
| 7 | + | |
| 8 | +`cdf.rs` is byte-identical across `main`, `lane-golomb` and this tree | |
| 9 | +(`sha256 655f9a45ccedf7e37adab8b46703cf7ec4c9cc395978a1e6179157741def5844`, all four). | |
| 10 | + | |
| 11 | +## r1's leftover suite unit | |
| 12 | +`cdef-suite-1788330834.service` was still RUNNING at the start of this round; it had reached | |
| 13 | +**184 tests ok, 0 FAILED / 0 panics** with no `test result` line yet. Stopped (its target dir is | |
| 14 | +this lane's) and superseded by the r2 run below. | |
| 15 | + | |
| 16 | +## Merge conflicts (decode.rs), resolved | |
| 17 | +1. `dump_stage`'s per-decode-order-frame index: both lanes added one. Kept this lane's shared | |
| 18 | + `dump_stage_idx()` helper (`dump_stage16` uses it too), dropped lane-golomb's duplicate | |
| 19 | + `thread_local` counter. | |
| 20 | +2. The var-tx leaf loop (`decode.rs:19323`): took **main's** general `(row, col, tw, th)` rect | |
| 21 | + leaves and **lane-golomb's** `fill_lf_grid_leaf_luma` writer. Routing a rect leaf through | |
| 22 | + `fill_lf_grid_rect` would recompute the CHROMA tx dims from the leaf span; libaom's | |
| 23 | + `get_transform_size` (`av1/common/av1_loopfilter.c:207`) applies the split override only for | |
| 24 | + `plane == AOM_PLANE_Y`. Class `table-and-reader-move-together`: table (leaf tuple) from main, | |
| 25 | + writer from golomb, both re-gated below. | |
| 26 | + | |
| 27 | +## Charter item (2) -- the 68x192 CHROMA residue: CLOSED, and it was NOT a chroma-CDEF defect | |
| 28 | +The charter's hypotheses (chroma `hsize >> xdec` fill, `damping - 1`, `uv_pri/uv_sec`, shared luma | |
| 29 | +`dir`, `coeff_shift`, the 8x8 skip band) were each checked against the oracle source and all six | |
| 30 | +were **already correct** in `apply_cdef`: | |
| 31 | +* right/bottom pad bound: `sample_uv` bounds at `plane.true_width/true_height`, which is | |
| 32 | + `mi_cols * 4 / 2` (`decode.rs:13388`) = 36 for a 68-px axis -- exactly libaom's | |
| 33 | + `hsize = nhb << mi_wide_l2` with `mi_wide_l2 = MI_SIZE_LOG2 - subsampling_x` | |
| 34 | + (`cdef.c:164-167`), the fill starting there being `cdef.c:249-256`. | |
| 35 | +* `damping += coeff_shift - (pli != AOM_PLANE_Y)` (`cdef_block.c:337`) == our `damping_uv`. | |
| 36 | +* chroma `t = pri_strength`, NOT `adjust_strength` (`cdef_block.c:387`) == ours. | |
| 37 | +* `pri_strength ? dir[by][bx] : 0` per plane (`cdef_block.c:392`) == ours; the `conv422/conv440` | |
| 38 | + direction remap is `if (pli == 1 && xdec != ydec)` (`cdef_block.c:361-369`), i.e. never in 4:2:0. | |
| 39 | +* `level`/`sec_strength` from `cdef_uv_strengths[mbmi_cdef_strength]` with the `== 3` bump | |
| 40 | + (`cdef.c:325-333`) == ours; block size `8 >> xdec` by `8 >> ydec` == our 4x4. | |
| 41 | + | |
| 42 | +The residue was the **loop restoration plane size**, fixed on lane-golomb r8 and merged this | |
| 43 | +round: LR is the one post-decode filter sized by the CROP (`av1_get_upsampled_plane_size`, | |
| 44 | +`restoration.c:47`, asserted against the crop at `restoration.c:1106`), while deblock and CDEF walk | |
| 45 | +the mi grid. With both branches' fixes in one tree all four straddling arms are exact on Y, U and V. | |
| 46 | + | |
| 47 | +EVIDENCE: /home/user/.cache/cdef-strad-r2.log | merged tree, `cargo test -p ec-av1 --lib -- --ignored --nocapture a_frame_edge_straddling_band` (192x68 + 68x192, 5 frames, 8+10-bit, cq 35..61) | 14 pixel-exact attempts (Y, U and V, every shown frame), 0 differing pixels, 18 named refusals, test result ok 1 passed / 0 failed | |
| 48 | + | |
| 49 | +## Charter item (3) -- `--tile-columns=1` arms: added, and VACUOUS today | |
| 50 | +Each straddling arm gained a `--tile-columns=1` twin (8 arms x 8 cq = 64 attempts). All 32 | |
| 51 | +multi-tile attempts refuse **by name**; census (in the test's doc comment): | |
| 52 | +10x "an inter SB-level AB partition", 6x "a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs | |
| 53 | +rectangular residual coding", 6x "an 8x8 intra leaf in an inter frame whose tx_depth splits it into | |
| 54 | +4x4 transform units", 5x "an inter partition below 8x8", 3x "an inter 16x16-level AB or 1:4 | |
| 55 | +partition", 1x "a split intra strip whose transform unit is 32x64", 1x "an intra-coded 1:4 rect | |
| 56 | +strip on the inter block path". Class `counter-from-refused-stream`: that half of the gate compares | |
| 57 | +nothing yet and every assert is carried by the single-tile arms. Arms kept so the coverage appears | |
| 58 | +the day those refusals lift. | |
| 59 | + | |
| 60 | +## Gate | |
| 61 | +`stream.rs::a_frame_edge_straddling_band_decodes_pixel_exact` -- **un-ignored** (was | |
| 62 | +`#[ignore] "open r9 defect"`). Hard-asserts the new `decode::cdef_straddle_units()` grew: a FILTERED | |
| 63 | +8x8 CDEF unit whose extent crosses the cropped frame edge is the only shape for which "clamp at the | |
| 64 | +crop" and "pad with CDEF_VERY_LARGE past the mi-rounded extent" differ, so a zero delta would make | |
| 65 | +these arms vacuous for this defect. | |
| 66 | + | |
| 67 | +EVIDENCE: /home/user/.cache/cdef-strad2-r2.log | `cargo test -p ec-av1 --lib -- --nocapture a_frame_edge_straddling_band` on the final tree | 14 pixel-exact attempts, **337 straddling CDEF units**, 50 named refusals, ok 1 passed / 0 failed in 33.99s | |
| 68 | + | |
| 69 | +Sibling gate (same tables/paths -- `apply_cdef`, the skip band, `fill_skip_grid`): | |
| 70 | +EVIDENCE: /home/user/.cache/cdef-sib-r2.log | `cargo test -p ec-av1 --lib -- --nocapture cdef_and_sub16` | a_real_aomenc_stream_with_cdef_and_sub16_inter_leaves_decodes_pixel_exact ok, 1 passed / 0 failed | |
| 71 | + | |
| 72 | +## Suite | |
| 73 | +EVIDENCE: /home/user/.cache/cdef-suite-r2.log | `systemd-run --user --unit=cdef-suite-r2-... -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3` on `646f2d3`'s tree | **386 passed, 0 failed, 34 ignored** in 1009.29s (r1's tree had 385/0/35 -- one test moved out of `ignored` and into `passed`: this round's un-ignored straddling gate) | |
| 74 | + | |
| 75 | +## Refusals | |
| 76 | +None lifted this round, so `refusal_inventory.rs` is unchanged. `gate_coverage.rs` needs no entry | |
| 77 | +either: its derivation deliberately excludes `--tile-columns` (see its header comment) and this | |
| 78 | +round adds no `--enable-*` flag. | |
| 79 | + | |
| 80 | +## Residue | |
| 81 | +* deferred(the 7 refusals in the census above) -- the multi-tile half of the straddling gate. | |
| 82 | +* accepted -- the gate compares SHOWN frames (`ffmpeg_decode_sequence`); no-show alt-ref frames are | |
| 83 | + not compared here, same as every sibling gate (class `gate-blind-to-hidden-frames`). |
lanes/golomb-r1.report.mdmodified+68 -0
| @@ -45,3 +45,71 @@ desyncing. | ||
| 45 | 45 | correctly decoded as HORZ, on an INTER superblock row the inter path cannot code (rect inter |
| 46 | 46 | residual coding does not exist here). Next lane. |
| 47 | 47 | - `reelb5.obu`: "a 32x32-level 1:4 strip with a split transform (depth=2)" (unchanged by this lane). |
| 48 | + | |
| 49 | +--- | |
| 50 | + | |
| 51 | +# lane-golomb r2 — the 32x32-level frame-edge HORZ/VERT second half | |
| 52 | + | |
| 53 | +## Must-fix (verifier golomb1): fixed | |
| 54 | +Since r1 the 32-level edge read can return HORZ/VERT (bit 0), so the second 32x16/16x32 half is | |
| 55 | +out of frame and must not be decoded. libaom `decode_partition`: | |
| 56 | +`case PARTITION_HORZ: decode_block(top); if (has_rows) decode_block(bottom)` (mirror for VERT). | |
| 57 | + | |
| 58 | +- `crates/ec-av1/src/decode.rs:10887` (intra `PARTITION_HORZ` @32) — second 32x16 now behind `if has_rows32`. | |
| 59 | +- `crates/ec-av1/src/decode.rs:10928` (intra `PARTITION_VERT` @32) — second 16x32 behind `if has_cols32`. | |
| 60 | +- `crates/ec-av1/src/decode.rs:17900` (inter `PARTITION_HORZ` @32) — same guard, `has_rows32`. | |
| 61 | +- `crates/ec-av1/src/decode.rs:18008` (inter `PARTITION_VERT` @32) — same guard, `has_cols32`. | |
| 62 | +- `crates/ec-av1/src/decode.rs:1600` — new `EDGE32_HITS` counter (+ `edge32_hits()`, `bump_edge32`): | |
| 63 | + slot 0/1 = 32-level edge bit read as HORZ/VERT vs SPLIT, slot 2 = a bottom-edge HORZ strip | |
| 64 | + decoded (`has_rows32 == false`), slot 3 = a right-edge VERT strip. | |
| 65 | + | |
| 66 | +AB / 1:4 arms at the 32 level need NO guard: at an edge libaom's `ec_read_partition_impl` can only | |
| 67 | +yield HORZ, VERT or SPLIT, so those arms are unreachable there (stated per charter). | |
| 68 | +16-level edge rect arms swept and left as they are: intra refuses by name | |
| 69 | +("a 16x16 block at the true frame edge coded as a rect strip rather than SPLIT"), inter falls to | |
| 70 | +"an inter partition below 16x16 other than SPLIT". | |
| 71 | + | |
| 72 | +## Gate | |
| 73 | +NEW `stream::tests::a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact` | |
| 74 | +(crates/ec-av1/src/stream.rs:14800+): 192x80 (bottom edge, mi_rows=20) and 80x192 (right edge), | |
| 75 | +testsrc2 + seeded `noise`, cq {35,40,45,50,55,57,59,61}, 8-bit AND 10-bit (bit_depth asserted), | |
| 76 | +plus a 5-frame INTER arm; every decode pixel-compared against ffmpeg, counters sampled per attempt | |
| 77 | +and summed only over compared attempts. | |
| 78 | + | |
| 79 | +EVIDENCE: $HOME/.cache/golomb-suite-r2.log + gate stdout | cargo test -p ec-av1 --lib -- --nocapture | |
| 80 | +a_real_aomenc_stream_with_a_32x32_frame_edge | 32 pixel-exact attempts, 8 named refusals, | |
| 81 | +edge32 bits [horz_or_vert=0 split=178] — the 32-level edge read fires 178 times and every attempt | |
| 82 | +decodes pixel-exact. | |
| 83 | + | |
| 84 | +Recipe deviations from the charter, with reasons (measured, not assumed): | |
| 85 | +- `--min-partition-size=32`, not 8: at 8 (and at 16) the sub-16 AB / split-transform strip arms | |
| 86 | + refuse by name before the 32-level edge is reached — 40/40 attempts refused. | |
| 87 | +- `--tune-content=film` + `noise`: without them aomenc's screen-content detection makes every | |
| 88 | + attempt refuse at "a HORZ/VERT intra strip in a screen-content frame" (the verifier's smptebars | |
| 89 | + trap, reproduced here with plain testsrc2). | |
| 90 | + | |
| 91 | +## OPEN DEFECT (fix-now, next round) — the edge HORZ strip's pixels | |
| 92 | +With detail in the straddling band aomenc always answers the edge bit with SPLIT (178/178), so the | |
| 93 | +HORZ/VERT arm never fires. Leaving that band FLAT (`pad=...:gray`) forces it: | |
| 94 | +EVIDENCE: gate stdout | cargo test -p ec-av1 --lib -- --ignored --nocapture | |
| 95 | +a_32x32_frame_edge_rect_partition_with_a_flat_band | 192x80 cq40 8-bit, `edge32=[2, 0, 2, 0]` | |
| 96 | +(two bottom-edge HORZ strips decoded), plane Y 1081 pixels differ, first at row 62 col 128, | |
| 97 | +diffs per row confined to rows 62..79 (~64 of 192 columns) — exactly the two 32x16 strips plus the | |
| 98 | +deblock bleed above them; every other pixel of the frame matches ffmpeg. | |
| 99 | +Reading: the guard itself is validated (no desync — the rest of the frame is entropy- and | |
| 100 | +pixel-exact where before it would have consumed an out-of-frame half), but the strip's own | |
| 101 | +reconstruction (prediction/neighbour availability at the frame edge) is wrong. Pinned as | |
| 102 | +`#[ignore]`d test `a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact` so the | |
| 103 | +suite stays green and the defect stays runnable. Disposition: fix-now for r3 (owner: this lane). | |
| 104 | + | |
| 105 | +## Suite (r2) | |
| 106 | +`$HOME/.cache/golomb-suite-r2.log` — **337 passed / 1 FAILED / 32 ignored** (618 s). | |
| 107 | +The failure is NOT this round's arm and I could not attribute it to this diff: | |
| 108 | +`stream::tests::a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16_decodes_pixel_exact` | |
| 109 | +panics at stream.rs:8479 "the stream decoded but no coded (non-skip) rect leaf fired". Its fixture | |
| 110 | +is a 64x64 mandelbrot frame — one whole superblock, `mi_cols = mi_rows = 16`, so | |
| 111 | +`has_rows32`/`has_cols32` are true everywhere and none of this round's four guards (nor r1's | |
| 112 | +edge reads) can execute on it. Deterministic (fails standalone in 0.34 s, same message). | |
| 113 | +Disposition: deferred(a bisect of eacd7fd vs 3e4ce89 in a detached worktree, or the owner of | |
| 114 | +`rect_leaf_coeff_hits`) — it is either pre-existing on eacd7fd (r1's suite log predates today's | |
| 115 | +oracle/ffmpeg state) or a sibling-gate regression from a path I did not touch. NOT claimed green. |
lanes/golomb-r3.report.mdadded+106 -0
| @@ -0,0 +1,106 @@ | ||
| 1 | +# lane-golomb r3 — the suite red was my own gate recipe; the edge strip was out-of-frame transform units | |
| 2 | + | |
| 3 | +## TASK 1 — bisect table (the r2 suite failure) | |
| 4 | + | |
| 5 | +`stream::tests::a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16_decodes_pixel_exact`, | |
| 6 | +run in a detached scratch worktree (`scratchpad/verify-golomb`, `CARGO_TARGET_DIR=~/.cache/cargo-target-verify`): | |
| 7 | + | |
| 8 | +| commit | what it is | result | | |
| 9 | +|---|---|---| | |
| 10 | +| a762fff | mcomp64 base | ok, 1 passed | | |
| 11 | +| 909064f | + fi8 cherry-pick 2d5c425 | ok, 1 passed | | |
| 12 | +| eacd7fd | r1 edge-bit fix | ok, 1 passed | | |
| 13 | +| fd54bcf | r2 guards | **FAILED** — "the stream decoded but no coded (non-skip) rect leaf fired" | | |
| 14 | + | |
| 15 | +EVIDENCE: bisect stdout above | `git worktree add --detach` at each sha, `cargo test -p ec-av1 --lib -- a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16` | 3 ok / 1 FAILED, first red = fd54bcf | |
| 16 | + | |
| 17 | +Root cause: **not** fi8, not the r1 edge read. r2's per-arm recipe override | |
| 18 | +(`--min-partition-size=32 --tune-content=film`) was pasted into the WRONG gate — hunk | |
| 19 | +`stream.rs@8435`, inside `a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16`, whose whole | |
| 20 | +point is sub-16x16 rect leaves. At `--min-partition-size=32` that 64x64 mandelbrot frame cannot | |
| 21 | +contain a 16x8 leaf, so `rect_leaf_coeff_hits` went to 0 and the gate's own | |
| 22 | +"the gate proves nothing" assert fired — the assert did its job. Fixed in ebec75d by restoring | |
| 23 | +`--min-partition-size=8`; the edge32 gate has always carried its own copy of the override. | |
| 24 | +No warning is owed to the fi8 merge agent: fi8 is already on main (b1d8457) and is exonerated by | |
| 25 | +row 2 of the table. | |
| 26 | + | |
| 27 | +EVIDENCE: gate stdout | `cargo test -p ec-av1 --lib -- --nocapture a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16` after ebec75d | `pixel-exact, rect_leaf_coeff_hits=8`, 1 passed | |
| 28 | + | |
| 29 | +## TASK 2 — the frame-edge strip's wrong pixels: out-of-frame transform units | |
| 30 | + | |
| 31 | +Class: `parsed-then-discarded`'s mirror — *read* something the reference never wrote | |
| 32 | +(`equal-range-means-unread`). | |
| 33 | + | |
| 34 | +Reproduced standalone (192x80 cq40 8-bit flat band, md5 `4bd18b25…`, scratchpad `e32.obu`): | |
| 35 | +1081 Y pixels differ, rows 62..79, **cols 124..191** — the LAST superblock only. | |
| 36 | + | |
| 37 | +The oracle's own view of that superblock row (instrumented aomdec): | |
| 38 | +`EC_PRED mi_row=16 mi_col=16 … bsize=11 part=1 txw=16 txh=16` with **row_off=0 only** (four TUs), | |
| 39 | +and `mi_row=16 mi_col=32 … bsize=11 part=1 txw=32 txh=32` (two TUs). `bsize=11` is | |
| 40 | +`BLOCK_64X32`: aomenc answers the bottom-edge superblock with the **64-level** `PARTITION_HORZ`, | |
| 41 | +never the 32-level one, and codes only the transform-unit ROW that is inside the frame. | |
| 42 | + | |
| 43 | +Ours decoded `mi_col=16` identically (`TRACE_RECT_SPLIT bw=64 bh=32 tx=16`) but then walked | |
| 44 | +`bh/tx = 2` TU rows, reading coefficients for four phantom 16x16 units at y=80..95 — outside a | |
| 45 | +frame whose `mi_rows*4 == 80`. That desynced the stream at exactly the next symbol: the SB2 | |
| 46 | +partition bit came out SPLIT (two 32x16 strips, `edge32=[2,0,2,0]`) where the oracle read HORZ. | |
| 47 | +The r2 report's reading ("prediction/availability inside the strip") was wrong; the strips | |
| 48 | +were the *symptom* of a desync, and the "32-level edge HORZ fired" counter was a | |
| 49 | +`counter-from-refused-stream`-shaped artefact of our own desync. | |
| 50 | + | |
| 51 | +Fix — `crates/ec-av1/src/decode.rs:4818` (`decode_rect_split`, the only place a block hangs off | |
| 52 | +the frame): skip a transform unit whose top-left sample is outside `true_width`/`true_height` | |
| 53 | +(`mi_cols*4`/`mi_rows*4`), mirroring libaom `av1_foreach_transformed_block_in_plane`'s | |
| 54 | +`max_blocks_wide/high` clip (`mb_to_right_edge`/`mb_to_bottom_edge`). The chroma unit of a strip | |
| 55 | +always has its top-left inside, so it is unaffected. | |
| 56 | + | |
| 57 | +EVIDENCE: scratchpad/{e32.obu, ours.yuv, ao.yuv, ao-pred.txt, ours-step.txt} | instrumented | |
| 58 | +aomdec `EC_PRED`/`EC_TRACE_MODE_STEP` vs `decode_probe`, byte diff of the two raw yuv420p dumps | | |
| 59 | +before: 1081 Y pixels differ (first diff at our `EC_ISTEP mi_row=16 mi_col=32 name=skip rng=51413` | |
| 60 | +vs oracle `rng=32901`); after: **0 differing bytes over all three planes** | |
| 61 | + | |
| 62 | +## Counters + the pin, un-ignored | |
| 63 | + | |
| 64 | +`EDGE32_HITS` widened 4 → 8 slots (`decode.rs:1602`): slots 4/5 = the **64**-level gathered edge | |
| 65 | +bit read as HORZ/VERT / SPLIT (both tile paths), 6 = a 64x32 bottom-edge strip decoded with | |
| 66 | +`has_rows == false`, 7 = a 32x64 right-edge strip. Necessary because the flat-band arm's r2 | |
| 67 | +assert (`totals[2] > 0`, a 32-level bottom-edge HORZ) was only ever satisfied by our own desync; | |
| 68 | +on a correct decode of this content the 32-level slots are 0 by construction and the 64-level | |
| 69 | +slots carry the proof. `#[ignore]` removed from | |
| 70 | +`a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact`. | |
| 71 | + | |
| 72 | +EVIDENCE: gate stdout | `cargo test -p ec-av1 --lib -- --nocapture a_32x32_frame_edge` | | |
| 73 | +2 passed; flat arm: 32 pixel-exact attempts, 64-level edge bits [horz_or_vert=96 split=0] | |
| 74 | +bottom-HORZ=48 right-VERT=48, 32-level slots all 0; detail arm: 32 pixel-exact attempts, | |
| 75 | +64-level [horz_or_vert=7 split=89] right-VERT=7, 32-level split=178 | |
| 76 | + | |
| 77 | +## Suite | |
| 78 | +`$HOME/.cache/golomb-suite-r3.log` — **339 passed / 0 failed / 31 ignored** (277 s), run as a | |
| 79 | +user systemd unit on the final tree. r2 was 337/1 FAILED/32 ignored: +1 fixed (task 1), +1 | |
| 80 | +un-ignored (task 2). | |
| 81 | + | |
| 82 | +Siblings re-run inside that suite, all green: `a_real_aomenc_stream_with_a_coded_rect_strip_below_16x16`, | |
| 83 | +`the_reelb_head_key_frame`, both `a_*_32x32_frame_edge_*`, `tiny_frame_size_sweep`, | |
| 84 | +`superblock_level_*`, `filter_intra_*`, `refusal_inventory`, `gate_coverage`. | |
| 85 | + | |
| 86 | +## Same-shape sweep | |
| 87 | +`decode.rs:7458` (`decode_block`'s square multi-TU loop) has the identical unclipped | |
| 88 | +`0..n_axis` shape and now carries the identical guard. A square block only hangs off the frame | |
| 89 | +when the frame's mi dimensions are odd at that block's level (lane-oddh's territory), so no gate | |
| 90 | +in this suite reaches it: the guard is libaom's rule applied by inspection, proven only inert | |
| 91 | +here (suite unchanged). `decode_block_rect64` delegates its split case to `decode_rect_split`, | |
| 92 | +so it is covered by the measured fix. Flagged, not claimed. | |
| 93 | + | |
| 94 | +## Film | |
| 95 | +`hg-head.obu` (18 frames) still stops at | |
| 96 | +"an inter SB-level partition type other than NONE or SPLIT (this decoder's inter tile path | |
| 97 | +recurses a superblock only as SPLIT)" — unchanged by this round (same string as r1's residue; | |
| 98 | +the inter tile path never reaches a 64-level HORZ). | |
| 99 | +EVIDENCE: probe stdout | `cargo run -p ec-av1 --example decode_probe -- hg-head.obu` | REFUSED at | |
| 100 | +the inter SB-level partition, 18 frame headers parsed, tiling cols=1 rows=1 | |
| 101 | + | |
| 102 | +## Residue | |
| 103 | +- deferred: the inter tile path's 64-level `PARTITION_HORZ`/`VERT` (the film's next blocker) — | |
| 104 | + unblocked by rect inter residual coding, which is lane-inter*/interbis territory, not this one. | |
| 105 | +- accepted: the square-block guard above is unexercised by any gate on this lane (odd-mi | |
| 106 | + geometry is lane-oddh's gate). |
lanes/golomb-r4.report.mdadded+93 -0
| @@ -0,0 +1,93 @@ | ||
| 1 | +# lane-golomb r4 — merge with main, and the 32x32-frame-edge cross-product isolated (NOT fixed) | |
| 2 | + | |
| 3 | +## STEP 1 — merge (DONE, commit 17fc2a7 `Merge branch 'main' into lane-golomb`) | |
| 4 | + | |
| 5 | +`git merge main` (main b51719f) conflicted in 4 files; 14 hunks in `decode.rs`. | |
| 6 | +Resolution (all by hand, no `cargo fmt`): | |
| 7 | + | |
| 8 | +* `crates/ec-av1/src/cdf.rs`, `crates/ec-av1/src/cdf_state.rs` — main's, whole. | |
| 9 | +* `crates/ec-av1/src/decode.rs` | |
| 10 | + * fi32x8 rows `(32,8)=>10 / (8,32)=>11` in `filter_intra_size_class`: main's. | |
| 11 | + * `decode_rect_split`'s TU loop: main's rect `tx_w`/`tx_h` form, with golomb r3's | |
| 12 | + TU-ORIGIN CLIP re-applied per axis inside it | |
| 13 | + (`if tu_px >= y.true_width || tu_py >= y.true_height { continue; }`). | |
| 14 | + * oddh's 16-level edge HORZ/VERT strip (replaces golomb's refusal): main's. | |
| 15 | + * golomb's 6 edge-bit counter sites (`bump_edge32` / `bump_edge32_bit`) and the | |
| 16 | + 64-level + 32-level SECOND-HALF guards: kept, re-applied on top of inter4's | |
| 17 | + MI-unit `decode_inter_block` signature (`sub16_to_mi(...)`) at both inter | |
| 18 | + SB-level HORZ (`edge32` slot 2) and VERT (slot 3) arms. | |
| 19 | +* `lanes/golomb-r1.report.md` — lane's. | |
| 20 | + | |
| 21 | +`cargo check -p ec-av1` + `cargo test -p ec-av1 --lib --no-run`: clean. | |
| 22 | + | |
| 23 | +## STEP 2 — the cross-product: ISOLATED to one block, root cause NOT yet found | |
| 24 | + | |
| 25 | +Gate `a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition_decodes_pixel_exact` | |
| 26 | +still FAILS on the merged tree, identically to merge-E's report: | |
| 27 | +`192x80 cq59 frames=5 8-bit frame 1 plane Y: 90 pixels differ, first at row 61 col 174 | |
| 28 | +(ours 175 vs ffmpeg 174) [edge32=[1, 35, 1, 0, 0, 18, 0, 0]]`. | |
| 29 | + | |
| 30 | +Stream reproduced standalone (md5 `48e1d78f31a4eb6a6ef5a67df9bd36fe`, 971 B): | |
| 31 | +`ffmpeg -f lavfi -i "testsrc2=size=192x80:duration=0.2:rate=25,noise=alls=6:allf=t+u:all_seed=59" | |
| 32 | + -pix_fmt yuv420p ... | aomenc <the gate's flags> --cq-level=59` (script in the handoff). | |
| 33 | + | |
| 34 | +### What the facts say (each with its command) | |
| 35 | + | |
| 36 | +1. **The first divergent picture is DECODE-order picture 2, not shown-frame 1.** | |
| 37 | + `EC_AV1_PREFILT_DUMP` on both decoders, luma compared per picture: | |
| 38 | + f0 0 diffs, f1 0, **f2 130**, f3 84, f4 110. The shown-frame-1 report is the | |
| 39 | + propagated copy. (Class `gate-blind-to-hidden-frames` applies to the READING of | |
| 40 | + the gate message, not to the gate.) | |
| 41 | +2. **The wrong pixels are exactly one 16x16 block**: picture 2, rows 64..79 x | |
| 42 | + cols 160..175 = mi(16,40), max |delta| 36 — a prediction-scale error, not rounding. | |
| 43 | +3. **libaom decodes mi(16,40) as SPLIT into two 16x16 leaves in every picture** | |
| 44 | + (`EC_TRACE=1 aomdec | grep 'mi_row=16 mi_col=40 bsize=9'` → `value=3` x6); | |
| 45 | + **we decode a 32-wide HORZ strip there in picture 2 only** | |
| 46 | + (`EC_AV1_COMPIDX_DUMP=1` → `mi_row=16 mi_col=40 bsize=32 mode=0 mv0=(-30,-20) | |
| 47 | + mv1=(16,0) ref0=1 ref1=7`, where libaom has `mode=18 (NEAR_NEARMV) mv0=(-16,0)`). | |
| 48 | + That is inter4's SB/32-level inter rect arm consuming golomb's frame-edge bit — | |
| 49 | + a path neither parent could reach. | |
| 50 | +4. **The edge bit is NOT the defect.** Instrumented pre-read state at the 32-level | |
| 51 | + gathered read (temporary `DBG32PRE`, reverted): ctx = 2 (= libaom's 10 = bsl 2 * 4 + 2), | |
| 52 | + CDF row and 2-entry gather identical in all 6 pictures, and the pre-read RANGE | |
| 53 | + matches aomdec's `EC_PART ... rng=` in 11 of 12 reads. The one mismatch is | |
| 54 | + picture 2 at mi(16,40): ours 39967, libaom 64226 — i.e. **we arrive at the bit | |
| 55 | + already desynced**, and the wrong HORZ is the consequence. | |
| 56 | +5. **The desync starts inside the 16x16 INTER block at mi(16,32), picture 2.** | |
| 57 | + Range ladder (ours `EC_AV1_TELL`/`EC_TRACE_MODE` vs aomdec `EC_TRACE_MODE`): | |
| 58 | + * mi(16,32) entry / post_is_inter: ours 52732 == libaom `EC_MODE ... rng=52732`. | |
| 59 | + * libaom then reads compound NEAR_NEARMV `ref0=1 ref1=7 mv0=(0,0) stack=3` | |
| 60 | + (`EC_MODE_MV rng=39839`, `EC_MODE_VAL rng=56231`) and leaves the block at 62618. | |
| 61 | + * ours leaves the block at 35347 (`TELL ... label=block_end tell=232 range=35347`), | |
| 62 | + having consumed ~1 bit: no `EC_MODE_VAL` (single-ref print) and no `EC_COMPIDX` | |
| 63 | + line for that block at all. | |
| 64 | + So we read FEWER symbols than libaom for a `skip=true`, `is_inter=true` compound | |
| 65 | + block at the bottom frame edge. First divergent element: the symbol(s) after | |
| 66 | + `intra_inter` in `decode_inter_block` at mi(16,32) (ref-frame / compound-mode | |
| 67 | + group), picture 2. | |
| 68 | +6. Coefficient ladders are otherwise identical (6426 aligned | |
| 69 | + `EC_COEFF_STEP tag=base|sign|all_zero|eob|base_eob|after_bases|post_golomb` rng | |
| 70 | + values, `diff` empty), so this is a LOCAL symbol-count divergence in one block | |
| 71 | + that re-converges, not a whole-tile desync. | |
| 72 | + | |
| 73 | +EVIDENCE: /tmp/.../scratchpad/{ours,aom}.f0..f5 | `EC_AV1_PREFILT_DUMP` both decoders on g4.obu | first divergent picture = 2, diff box rows 64..79 x cols 160..175 (130 px, max 36) | |
| 74 | +EVIDENCE: /tmp/.../scratchpad/{o,a}-cf.txt | `EC_TRACE_COEFF=1` both decoders, aligned tags | 6426 == 6426 lines, `diff` empty (entropy re-converges) | |
| 75 | +EVIDENCE: /tmp/.../scratchpad/{ours,aom}-mode.txt + tell.txt | `EC_TRACE_MODE` / `EC_AV1_TELL` ours vs aomdec | mi(16,32) p2 entry 52732 == 52732, exit ours 35347 vs libaom 62618 | |
| 76 | + | |
| 77 | +## Status / disposition | |
| 78 | + | |
| 79 | +* merge: DONE and committed. | |
| 80 | +* the 32x32-frame-edge cross-product: **OPEN — fix-now, next round**, isolated to | |
| 81 | + the symbol group read after `intra_inter` for the compound block at mi(16,32) in | |
| 82 | + picture 2. Not a golomb-side defect in the edge bit (fact 4). | |
| 83 | +* verifier's r3 item (no `max_blocks_wide/high` clip on the INTER var-tx leaf loops | |
| 84 | + at `decode.rs` ~14135 / ~14970, plus a 192x68 / 68x192 gate arm with a | |
| 85 | + straddling-TU counter): **deferred — turn budget spent on the cross-product | |
| 86 | + isolation above — unblocked by a fresh round; nothing about it is contradicted | |
| 87 | + by this round's findings.** | |
| 88 | + | |
| 89 | +## Suite | |
| 90 | + | |
| 91 | +`cargo test -p ec-av1 --lib` (systemd unit, log `$HOME/.cache/golomb-suite-r4.log`): **364 passed, 2 failed, 31 ignored** in 547 s. | |
| 92 | +Failure 1 = the stale golomb refusal string `"a 16x16 block at the true frame edge coded as a rect strip rather than SPLIT"` still listed in `refusal_inventory.rs` after the merge took oddh_s lifted strip -- deleted in the follow-up commit (refusal_inventory 3/3 green after). | |
| 93 | +Failure 2 = the open cross-product above. |
lanes/golomb-r5.report.mdadded+109 -0
| @@ -0,0 +1,109 @@ | ||
| 1 | +# lane-golomb r5 — the 32x32-frame-edge cross-product ROOT-CAUSED and fixed (luma exact); gate still RED on a newly-exposed chroma defect | |
| 2 | + | |
| 3 | +## What changed | |
| 4 | + | |
| 5 | +* `crates/ec-av1/src/mvstack.rs:1663-1703` (commit `13aebbe`) — `find_mv_stack_compound` | |
| 6 | + now runs libaom's three `tpl_sample_pos` EXTENSION samples | |
| 7 | + (`mvref_common.c:563-600`, `allow_extension` + `check_sb_border` at | |
| 8 | + `mvref_common.c:316`, mask hardcoded `mi_size_wide[BLOCK_64X64]`=16). The | |
| 9 | + single-ref twin (`mvstack.rs:863-891`) already carried them; the compound | |
| 10 | + path dropped them. Same hunk as lane-sb128 `d6cca7d` (independent lane, same | |
| 11 | + root cause found from the other end). | |
| 12 | + | |
| 13 | +Nothing else. The r4 debug ladder used to find this was removed before commit. | |
| 14 | + | |
| 15 | +## Root cause (H3 of the charter; H1 skip_mode and H2 comp-ref ctx both exonerated) | |
| 16 | + | |
| 17 | +Charter's isolated element: `192x80 cq59 frames=5 8-bit`, DECODE-order picture 2, | |
| 18 | +16x16 inter block at mi(16,32), entry range 52732 == libaom, exit ours 35347 vs | |
| 19 | +libaom 62618. | |
| 20 | + | |
| 21 | +A temporary compound range ladder (`EC_LAD` after `read_comp_mode`, after | |
| 22 | +`read_compound_ref_frames`, after `read_inter_compound_mode`, after | |
| 23 | +`assign_compound_mv`) showed: | |
| 24 | + | |
| 25 | +| element | ours (before) | libaom | | |
| 26 | +|---|---|---| | |
| 27 | +| block entry (post `intra_inter`) | 52732 | 52732 | | |
| 28 | +| `is_compound` | true | true | | |
| 29 | +| ref pair | `ref0=1 ref1=7` | `ref0=1 ref1=7` | | |
| 30 | +| **compound stack** | **2 entries** `[(-16,0)/(14,0) w=672, (0,0)/(0,0) w=672]` | **3 entries**, same two + `(-10,0)/(10,0) w=2` | | |
| 31 | +| compound mode | 1 = `NEAR_NEARMV` | 18 = `NEAR_NEARMV` | | |
| 32 | +| post-mv | 50080 | 39839 | | |
| 33 | + | |
| 34 | +So `skip_mode` and the whole reference-frame group were already right (H1/H2 dead). | |
| 35 | +With `ref_mv_count == 2` our `NEAR_NEARMV` drl loop condition | |
| 36 | +(`count > idx + 1`, idx=1) is false, so we never read the `drl_mode` symbol | |
| 37 | +libaom reads at `ref_mv_count == 3` — **one bit short**. Every later symbol in the | |
| 38 | +tile then read from the wrong place, and the 32-level gathered edge bit at | |
| 39 | +mi(16,40) resolved HORZ where libaom split (the r4 "edge bit" symptom was the | |
| 40 | +consequence, not the cause — matching r4 fact 4). | |
| 41 | + | |
| 42 | +The missing candidate has weight 2: `add_tpl_ref_mv`'s temporal vote | |
| 43 | +(`ref_mv_weight[idx] = 2 * weight_unit`), from extension sample | |
| 44 | +`(voffset, hoffset) = (4,4)` at mi(16,32) (`16&15=0`, `32&15=0`, both in range). | |
| 45 | + | |
| 46 | +After the fix the ladder is exact through the block: stack 3 == 3 with identical | |
| 47 | +entries and weights, post-mv 39839 == libaom `EC_MODE_MV rng=39839`, next block | |
| 48 | +entry 62618 == 62618, and mi(16,36) stack weight `w=10` == 10 (was 8, i.e. the | |
| 49 | +same missing weight-2 vote folded into an existing entry). | |
| 50 | + | |
| 51 | +EVIDENCE: /tmp/.../scratchpad/gl-r5-ours.txt (before) + gl-r5-ours2.txt (after) vs aom-mode.txt | `EC_TRACE_MODE` ours (temporary EC_LAD compound ladder) vs instrumented aomdec on g4.obu md5 48e1d78f31a4eb6a6ef5a67df9bd36fe | mi(16,32) p2 stack 2->3, post-mv 50080->39839 == libaom, next-block entry 39296->62618 == libaom | |
| 52 | + | |
| 53 | +EVIDENCE: /tmp/.../scratchpad/g4-ours.yuv vs g4-aom.yuv | `decode_probe EC_PROBE_OUT` vs `aomdec --rawvideo` on g4.obu | plane Y ALL 5 FRAMES EXACT (was f1 90, f2 143, f3 106 wrong pixels); chroma residue below | |
| 54 | + | |
| 55 | +## Gate: still RED, on a DIFFERENT defect | |
| 56 | + | |
| 57 | +`cargo test -p ec-av1 --lib -- a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition` | |
| 58 | + | |
| 59 | +* baseline (`fbc427c`): `192x80 cq59 frames=5 8-bit frame 1 plane Y: 90 pixels differ, first at row 61 col 174 [edge32=[1,35,1,0,0,18,0,0]]` (log `$HOME/.cache/golomb-gate-r5-base.log`) | |
| 60 | +* with the fix: `192x80 cq35 frames=5 8-bit frame 1 plane U: 335 pixels differ, first at row 0 col 56 [edge32=[0,36,0,0,0,18,0,0]]` (log `$HOME/.cache/golomb-gate-r5.log`) | |
| 61 | + | |
| 62 | +The gate now fails EARLIER in the cq sweep (35 < 59) because **cq35 was never | |
| 63 | +compared before**: at baseline that stream hit a false named refusal | |
| 64 | +(`"an inter 16x16-level AB or 1:4 partition"`) produced by our own desync, so the | |
| 65 | +gate `continue`d past it. With the stack fixed it decodes end to end. Class | |
| 66 | +`refusal-from-own-desync` + `refusal-hides-a-defect`, both already in memory. | |
| 67 | + | |
| 68 | +The residual defect is **chroma-only and pre-existing**: on both streams luma is | |
| 69 | +bit-exact in every frame while U/V carry scattered ±1..±3 across the whole plane | |
| 70 | +(g4 baseline already had f1 U 75 / V 185 wrong under the luma failure). The key | |
| 71 | +frame (f0) is exact, so it is inter chroma only, and V is consistently ~2.5x worse | |
| 72 | +than U. | |
| 73 | + | |
| 74 | +EVIDENCE: /tmp/.../scratchpad/g35-ours.yuv vs g35-aom.yuv | decode_probe vs aomdec on g35.obu (md5 9037f5b21db95d35e71f91f040fc33e1, recipe scratchpad/gl-gen.sh, hashed twice identical) | f0 exact, f1..f4 luma exact, U 335/324/1183/691 and V 408/412/1158/746 wrong, deltas -4..+5 | |
| 75 | +EVIDENCE: /tmp/.../scratchpad/g35-ours.txt vs g35-aom.txt | `EC_TRACE_MODE` block-entry ranges, ours vs aomdec | all 48 of our `EC_MODE` ranges match libaom's in order — entropy fully in sync, so this is a pure chroma reconstruction defect, not a symbol defect | |
| 76 | + | |
| 77 | +## The r3 verifier item (`max_blocks_wide/high` clip on the INTER var-tx leaf loops) | |
| 78 | + | |
| 79 | +**Already implemented, at the shared entry point** — no code needed | |
| 80 | +(`decode.rs:10317`): | |
| 81 | + | |
| 82 | +``` | |
| 83 | +fn read_var_tx_size(..., (max_w_mi, max_h_mi), ...) { | |
| 84 | + if blk_row >= max_h_mi || blk_col >= max_w_mi { return; } | |
| 85 | +``` | |
| 86 | + | |
| 87 | +`max_w_mi`/`max_h_mi` are computed as `mi_cols.saturating_sub(at_mi.1)` / | |
| 88 | +`mi_rows.saturating_sub(at_mi.0)` at BOTH inter callers | |
| 89 | +(`decode.rs:10402-10403` square, `decode.rs:10630-10631` rect), i.e. libaom's | |
| 90 | +`max_blocks_wide/high` in the same 4x4 units. A leaf whose top-left mi is outside | |
| 91 | +the frame is therefore never emitted into `vartx_leaves`, and the two reconstruct | |
| 92 | +loops (`decode.rs:15852`, `decode.rs:16830`) cannot see one. Adding a second | |
| 93 | +`tu_px >= y.true_width` guard there would be dead code. | |
| 94 | + | |
| 95 | +## Status / disposition | |
| 96 | + | |
| 97 | +* the mi(16,32) compound-stack desync: **FIXED**, luma bit-exact on the charter's stream. | |
| 98 | +* the chroma ±1 residue: **fix-now, next round** — first block to bisect is chroma | |
| 99 | + plane U/V of `g35.obu` frame 1 (entropy is proven in sync, MVs proven right by | |
| 100 | + exact luma, so it is chroma prediction/rounding or the per-plane chroma | |
| 101 | + quantizer; V-worse-than-U points at a per-plane term, cf. memory | |
| 102 | + `parsed-then-discarded`). Unblocked by a fresh round; nothing here contradicts it. | |
| 103 | +* r3 verifier item (var-tx clip): **accepted as already-satisfied**, cited above. | |
| 104 | + Its 192x68 / 68x192 gate arm: **deferred — the gate it would join is RED, so a | |
| 105 | + new arm would only add noise — unblocked by the chroma fix above.** | |
| 106 | + | |
| 107 | +## Suite | |
| 108 | + | |
| 109 | +`cargo test -p ec-av1 --lib` under a user systemd unit, log `$HOME/.cache/golomb-suite-r5.log`: re-armed as unit `golomb-suite-r5` after restoring the `#[ignore]` attribute on `a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact` (the r2 open-defect twin; the attribute was lost in the r4 merge and the test ran, and failed, in the mid-round run). Expected failures: the one open gate above. The coordinator reads the log. |
lanes/golomb-r6.handoff.mdadded+118 -0
| @@ -0,0 +1,118 @@ | ||
| 1 | +# lane-golomb r6 HANDOFF | |
| 2 | + | |
| 3 | +## Merge state (STEP 1: DONE) | |
| 4 | +* `899d7cf` = `git merge main` (main `18bf7dc`). Real merge commit, not a squash. | |
| 5 | +* `crates/ec-av1/src/mvstack.rs`: `git diff main -- mvstack.rs` is EMPTY -> ONE copy of the | |
| 6 | + compound tpl-extension hunk (lane-sb128 `d6cca7d` == our `13aebbe`), byte-identical to main. | |
| 7 | +* `crates/ec-av1/src/cdf.rs` and `cdf_state.rs`: `git diff main` EMPTY (NZ_MAP/FILTER_INTRA | |
| 8 | + byte-identical to main). | |
| 9 | +* 7 `decode.rs` conflicts resolved: 4 were comment-only (took main's text); 3 were the counter | |
| 10 | + pair -- main's `bump_edge_part` and this lane's `bump_edge32` are INDEPENDENT counters, BOTH | |
| 11 | + kept at every site (`decode.rs:13094-13101`, `13169-13179`, and the two `!has_rows32/!has_cols32` | |
| 12 | + guards). | |
| 13 | +* `#[ignore = "open r2 defect: ..."]` on | |
| 14 | + `a_32x32_frame_edge_rect_partition_with_a_flat_band_decodes_pixel_exact` | |
| 15 | + (`stream.rs:18414`) SURVIVED the merge -- verified by grep after the merge commit. | |
| 16 | + | |
| 17 | +## Suite r5 | |
| 18 | +`$HOME/.cache/golomb-suite-r5.log` had NO `test result:` line: the unit was still `active` and | |
| 19 | +I stopped it (`systemctl --user stop golomb-suite-r5`) to free `CARGO_TARGET_DIR` for r6 -- it | |
| 20 | +was building the PRE-merge tree, so its result would have been superseded anyway. Every `test` | |
| 21 | +line present in it up to that point was `ok`. r6 suite armed as unit `golomb-suite-r6` | |
| 22 | +-> `$HOME/.cache/golomb-suite-r6.log`; READ THAT, not r5. | |
| 23 | + | |
| 24 | +## STEP 2: chroma residue -- ROOT CAUSE #1 FOUND AND FIXED | |
| 25 | + | |
| 26 | +Stream: `g35.obu`, md5 `9037f5b21db95d35e71f91f040fc33e1` (regenerated, hash confirmed; | |
| 27 | +recipe `scratchpad/gl-gen.sh 35 <out>`), 192x80 cq35 5 frames 8-bit, 6 decode-order pictures. | |
| 28 | + | |
| 29 | +### Localization method (reusable) | |
| 30 | +Three-stage compare, decode order, ours vs the oracle: | |
| 31 | +`EC_AV1_PREFILT_DUMP` (pre-loopfilter) / `EC_AV1_POSTDEBLOCK_DUMP` (post-deblock, pre-CDEF) / | |
| 32 | +`EC_AV1_FINAL_DUMP` (post everything). Ours dumps a PADDED plane (192x96 luma), aomdec dumps | |
| 33 | +CROPPED (192x80) -- the comparator must use different strides per side. | |
| 34 | +NOTE: `EC_AV1_PREFILT_DUMP16`/`..._DUMP16` SEGFAULT the oracle aomdec on an 8-bit stream | |
| 35 | +(`ec_dump16` does `CONVERT_TO_SHORTPTR` unconditionally, decodeframe.c:3968). Use the 8-bit | |
| 36 | +`*_DUMP` vars for 8-bit streams. | |
| 37 | +Ours' `dump_stage` used to write `.f0` for EVERY frame (overwrite); r6 gave it a per-var | |
| 38 | +thread-local index (`decode.rs`, `dump_stage`) so POSTDEBLOCK is now `.f0..fN` like the oracle. | |
| 39 | + | |
| 40 | +### The measurement that localized it | |
| 41 | +Before the fix: prefilt decode-f1 EXACT, post-deblock decode-f1 U342/V380 wrong, luma exact at | |
| 42 | +every stage -> the defect was the DEBLOCK filter on chroma, not prediction, not CDEF | |
| 43 | +(`--enable-cdef=0` did NOT fix it), not LR (disabled in the recipe). | |
| 44 | + | |
| 45 | +### Root cause (fixed) | |
| 46 | +`decode.rs`, inter block tail: the var-tx / split-tx LEAF loop called | |
| 47 | +`Neighbours::fill_lf_grid_rect(leaf_mi, tx_px/MI, tx_px/MI, ...)`, and that function DERIVES | |
| 48 | +the chroma grids from the span it is given (`uv_tx_w = (w_mi*MI/2).clamp(4,32)`). So every | |
| 49 | +var-tx leaf OVERWROTE the block's correct `uv_tx_grid`/`uv_tx_h_grid` (the block's | |
| 50 | +`av1_get_max_uv_txsize`) with `leaf_tx/2`, inventing chroma transform edges the deblocker then | |
| 51 | +filtered. libaom `get_transform_size` (`av1/common/av1_loopfilter.c:207`) applies the var-tx | |
| 52 | +override ONLY `if ((plane == AOM_PLANE_Y) && is_inter_block(mbmi) && !mbmi->skip_txfm)`; | |
| 53 | +chroma always keeps `av1_get_max_uv_txsize(mbmi->bsize, ss_x, ss_y)`. | |
| 54 | +FIX: new `Neighbours::fill_lf_grid_leaf_luma` writes ONLY `tx_grid`/`tx_h_grid` over the leaf | |
| 55 | +span (`ref_grid`/`delta_lf_grid` are already correct from the block's own fill over the same | |
| 56 | +span), and the leaf loop calls it. Sweep: this was the ONLY `fill_lf_grid_rect` caller passing | |
| 57 | +a TU span; all 12 others pass block dims (checked each). | |
| 58 | + | |
| 59 | +### Result | |
| 60 | +g35 ours vs aomdec, all three stages, decode order: | |
| 61 | +before f0 exact, f1 U398/V457, f2 U325/V412, f3 U336/V408, f4 U~1000/V~1000, f5 U691/V746 | |
| 62 | +after f0-f3 EXACT at prefilt+postdeblock+final, f4 U974/V973 (prefilt), f5 inherits it. | |
| 63 | + | |
| 64 | +## RESIDUE (still RED) -- exactly one defect left | |
| 65 | +Gate: `cargo test -p ec-av1 --lib -- a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition` | |
| 66 | +=> `192x80 cq35 frames=5 10bit=false frame 3 plane U: 978 pixels differ, first at row 0 col 32 | |
| 67 | +(ours 33 vs ffmpeg 8) [edge32=[0,36,0,0,0,18,0,0]]`. | |
| 68 | + | |
| 69 | +* Stage: **PREFILTER** (prediction+residual), decode-order picture 4 only (f5 inherits). | |
| 70 | + Deblock/CDEF/LR are exonerated for this one. | |
| 71 | +* Extent: EXACTLY chroma x 32..63, y 0..31 = luma x 64..127, y 0..63, i.e. one whole 64x64 | |
| 72 | + superblock. Luma bit-exact inside it. | |
| 73 | +* Shape of the error: HIGH-FREQUENCY, |delta| up to 52. aomdec's row 0 is smooth | |
| 74 | + (13,14,14,14,...) where ours is (36,12,0,0,20,22,...). That is a RESIDUAL/inverse-transform | |
| 75 | + shape, not a prediction-offset shape. | |
| 76 | +* Blocks in that SB (decode f4, from `EC_TRACE_MODE`): mi(0,16) mode=23 ref0=1 ref1=7 (compound), | |
| 77 | + mi(0,24) mode=17 ref0=1 ref1=7, mi(8,16) mode=17 ref0=1 ref1=7, mi(8,24) mode=13 ref0=7 | |
| 78 | + single-ref. All 32x32. | |
| 79 | + | |
| 80 | +### Ruled out (each with the command that ruled it out) | |
| 81 | +* deblock / CDEF / LR: prefilt already differs on f4. | |
| 82 | +* per-plane `delta_q_u/v_dc/ac`: consumed (`stream.rs:599-603` etc.) AND f0-f3 chroma is now | |
| 83 | + bit-exact under the same quantizer. | |
| 84 | +* narrow-block (<=4-wide) chroma MC kernel and sub8x8 chroma MV derivation: impossible in this | |
| 85 | + stream, `--min-partition-size=32` means the smallest chroma block is 16x16. | |
| 86 | +* chroma MC rounding: derived by hand that our always-2-pass convolve is bit-identical to | |
| 87 | + libaom's `av1_convolve_x_sr_c`/`_y_sr_c` single-pass rounding when one fraction is 0 | |
| 88 | + (identity tap 128, round2(x*16,11) == ROUND_POWER_OF_TWO(x,7)); and f1-f3 are now exact. | |
| 89 | +* **DIFFWTD compound (the tempting one -- DO NOT re-chase it blind):** `--enable-diff-wtd-comp=0` | |
| 90 | + made the whole sequence exact, BUT that is a DIFFERENT bitstream (class gate-recipe-confound). | |
| 91 | + An `EC_DWTD` trace of the ORIGINAL g35 shows only 4 diffwtd blocks in the whole stream, in | |
| 92 | + decode f1 (px=64,py=0) and decode f2 (px=0,py=0 / px=64,py=0 / px=128,py=32) -- **NONE in | |
| 93 | + decode f4**, where the residue is. DIFFWTD is therefore EXONERATED for this residue. | |
| 94 | +* warp / global motion / OBMC / dual filter / masked-comp / interintra / dist-wtd: ablated on | |
| 95 | + the post-fix build, all still show the f3(display) failure (`scratchpad/abl.sh`). | |
| 96 | + | |
| 97 | +### Exact next step | |
| 98 | +The error is a chroma RESIDUAL in a 64x64 SB of decode-order picture 4 whose luma is exact and | |
| 99 | +whose entropy is (r5-proven) in sync. Bisect chroma coefficients, not prediction: | |
| 100 | +1. Run the oracle with `EC_TRACE_COEFF=1` and ours with `EC_TRACE_COEFF=1` on `g35.obu`, isolate | |
| 101 | + decode picture 4, block mi(0,16), plane 1. Compare the DEQUANTIZED values element by element | |
| 102 | + (and the msac RANGE per element, never `tell()`). | |
| 103 | +2. Prime suspect given "luma exact, chroma noisy, whole SB": the chroma `tx_type` inherited from | |
| 104 | + the colocated luma unit (`decode.rs` `inherited_luma_tx_type`, `av1_get_tx_type` | |
| 105 | + `blockd.h:1291`). For a var-tx-split luma block the chroma TU spans several luma TUs and | |
| 106 | + libaom reads the luma tx_type at `blk_row<<ssy, blk_col<<ssx`; ours takes "the top-left unit". | |
| 107 | + Verify that mapping against `av1_get_tx_type` for a 32x32 block whose luma split to 16x16. | |
| 108 | + A wrong tx_type gives exactly this signature: right coefficients, wrong basis, chroma only. | |
| 109 | +3. Second suspect: `txsize_sqr_up_map[tx_size] > TX_32X32 -> DCT_DCT` clamp | |
| 110 | + (ours clamps at `side >= 32`, on the CHROMA side length -- check that against | |
| 111 | + `av1_get_ext_tx_set_type`'s use of the chroma tx size). | |
| 112 | + | |
| 113 | +## Deferred | |
| 114 | +* the 192x68 / 68x192 gate arm from r3's verifier ask: **deferred -- the gate it would join is | |
| 115 | + still RED, a new arm would only add noise -- unblocked by the residue above.** The r3 code ask | |
| 116 | + itself stays accepted-as-already-satisfied (`decode.rs` `read_var_tx_size`'s | |
| 117 | + `blk_row >= max_h_mi || blk_col >= max_w_mi` early return, both inter callers pass | |
| 118 | + `mi_cols/rows - at_mi`). |
lanes/golomb-r7.handoff.mdadded+99 -0
| @@ -0,0 +1,99 @@ | ||
| 1 | +# lane-golomb r7 HANDOFF -- residue CLOSED, gate GREEN, suite still running at the cap | |
| 2 | + | |
| 3 | +Tip: `a548e9d` on `lane-golomb` (parent `0fcdf39`). Full report: `lanes/golomb-r7.report.md`. | |
| 4 | + | |
| 5 | +## Suite r6 result line | |
| 6 | +There is none. `$HOME/.cache/golomb-suite-r6.log` was still `active` at 254/404 tests | |
| 7 | +(stuck in the long superres/encoder tests) and holding `CARGO_TARGET_DIR`, so r7 stopped | |
| 8 | +the unit to build -- it was measuring the PRE-fix tree and is superseded. Every `test` | |
| 9 | +line it did emit was `ok` or a documented `ignored`. | |
| 10 | + | |
| 11 | +## Suite r7 -- INCOMPLETE at the turn cap | |
| 12 | +Unit `golomb-suite-r7` -> `$HOME/.cache/golomb-suite-r7.log`, still `active` at 180/404 | |
| 13 | +tests, NO `test result:` line yet, no `FAILED` line so far. A successor must read that | |
| 14 | +log (`grep -E "^test result|FAILED"`); if the unit died, re-arm it with the COMMON recipe. | |
| 15 | +This is the one owed artifact of the round. | |
| 16 | + | |
| 17 | +## What the picture-4 investigation showed (the ladder was not needed) | |
| 18 | +Method: `EC_TRACE_MODE=1 EC_TRACE_COEFF=1` on `g35.obu` (md5 `9037f5b21db95d35e71f91f040fc33e1`, | |
| 19 | +`scratchpad/gl-gen.sh 35`) through the r6-built `decode_probe`, stderr split into frames on | |
| 20 | +`EC_MODE mi_row=0 mi_col=0` -> segment 4 = decode-order picture 4 | |
| 21 | +(`scratchpad/r7-ours.err`, still on disk). | |
| 22 | + | |
| 23 | +* The residue block is `mi(0,16)` and the next `EC_MODE` is `mi(0,32)`, so it is a **64x64** | |
| 24 | + block, NOT the 32x32 r6 recorded. Var-tx split into 16x16 luma leaves. | |
| 25 | +* Its last two coefficient units are `eob=1022 tx=DctDct` and `eob=1020 tx=DctDct` | |
| 26 | + (`ctx=0`): eob > 256 proves **32x32 chroma** units | |
| 27 | + (`av1_get_max_uv_txsize(BLOCK_64X64) = TX_32X32`). | |
| 28 | +* Its FIRST luma var-tx leaf is `eob=254 tx=Idtx`. | |
| 29 | +* No dequant-value ladder against aomdec was required: the coefficient values are provably | |
| 30 | + identical (the whole stream stays in entropy sync and luma is bit-exact), so the only | |
| 31 | + free variable left was the chroma `tx_type` -- and `IDTX` vs `DCT_DCT` are both | |
| 32 | + `TX_CLASS_2D`, i.e. identical scan, identical contexts, identical msac ranges, different | |
| 33 | + inverse transform. That is exactly "entropy in sync, one SB of high-frequency chroma | |
| 34 | + noise, luma exact". | |
| 35 | + | |
| 36 | +## Fix applied (root cause, libaom-cited) | |
| 37 | +`av1_get_tx_type`, `av1/common/blockd.h:1278-1309`, chroma of an INTER block: | |
| 38 | +1. `DCT_DCT` only when `txsize_sqr_up_map[tx_size] > TX_32X32` (STRICTLY greater); | |
| 39 | +2. else the colocated luma unit's coded type, `xd->tx_type_map[(blk_row<<ss_y)*stride + (blk_col<<ss_x)]`; | |
| 40 | +3. then `if (!av1_ext_tx_used[av1_get_ext_tx_set_type(tx_size, 1, reduced)][tx_type]) tx_type = DCT_DCT;` | |
| 41 | + (`av1_ext_tx_used` blockd.h:1036, `av1_get_ext_tx_set_type` blockd.h:1097). | |
| 42 | + | |
| 43 | +We had step 1 as `chroma side >= 32 -> DCT_DCT` and step 3 missing entirely. At exactly | |
| 44 | +`TX_32X32` an inter block reads `EXT_TX_SET_DCT_IDTX`, which CONTAINS IDTX -> the block | |
| 45 | +above must use IDTX on chroma; we used DCT_DCT. | |
| 46 | + | |
| 47 | +`crates/ec-av1/src/decode.rs`: new `fn reduce_inherited_chroma_tx_type(t, w, h)` (just above | |
| 48 | +`fn inter_txbset_for`) implementing all four inter sets; both callers switched | |
| 49 | +(`read_inter_plane` and `read_inter_plane_rect` `default_tx_type`). Sweep: `rg | |
| 50 | +inherited_luma_tx_type` -- those are the ONLY two sites deriving a chroma tx_type for an | |
| 51 | +inter block; the intra sites (`decode.rs:6056`, `9195`) are correct as-is (intra at | |
| 52 | +`sqr_up == TX_32X32` really is `EXT_TX_SET_DCTONLY`). | |
| 53 | +Unit test added: `decode::tests::an_inter_chroma_transform_narrows_its_inherited_tx_type_to_its_own_set` | |
| 54 | +(`cargo test -p ec-av1 --lib -- an_inter_chroma_transform_narrows` => 1 passed). | |
| 55 | + | |
| 56 | +## edge32 gate: every arm GREEN | |
| 57 | +`$HOME/.cache/golomb-gate-r7.log`: `test result: ok`, | |
| 58 | +`38 pixel-exact attempts, 32-level edge bits [horz_or_vert=0 split=394], 64-level edge bits | |
| 59 | +[horz_or_vert=7 split=197] right-VERT=7, 2 named refusals`. | |
| 60 | +Arms: (192x80, 80x192) x 1 frame x {8-bit,10-bit} plus 192x80 5-frame, cq | |
| 61 | +{35,40,45,50,55,57,59,61} -- so all eight cq levels are green at BOTH depths. The only two | |
| 62 | +non-compared attempts are `192x80 cq45/cq50 frames=5 8-bit`, which refuse by name on | |
| 63 | +another lane's feature (inter SB-level AB partition). | |
| 64 | +BEFORE: `192x80 cq35 frames=5 10bit=false frame 3 plane U: 978 pixels differ, first at row 0 | |
| 65 | +col 32 (ours 33 vs ffmpeg 8)`. | |
| 66 | + | |
| 67 | +## Ruled out this round (each with its measurement) | |
| 68 | +* r6's "32x32 block at mi(0,16)" premise -- WRONG, the trace shows a 64x64 block (the next | |
| 69 | + EC_MODE is mi(0,32)); anything chartered off "32x32 chroma is 16x16" was mis-premised. | |
| 70 | +* A wrong chroma tx SIZE: the chroma eob of 1022 (> 256) proves our unit really is 32x32, | |
| 71 | + which is what `av1_get_max_uv_txsize` says. | |
| 72 | +* A dequant / per-plane delta_q cause: f0-f3 chroma is bit-exact under the same quantizer. | |
| 73 | +* Everything r6 already ruled out (deblock/CDEF/LR, DIFFWTD, warp/GM/OBMC/dual filter/ | |
| 74 | + masked-comp/interintra/dist-wtd, narrow-block chroma MC) stays ruled out. | |
| 75 | + | |
| 76 | +## Straddling-TU arm (r3 verifier ask): NOT added, and the two measurements say why | |
| 77 | +Both measured this round with the arms temporarily in `edge32_gate` | |
| 78 | +(`$HOME/.cache/golomb-gate-r7b.log`): | |
| 79 | +* `(192, 68, 5, false)`: ALL EIGHT cq attempts refuse by name -- `a reference picture whose | |
| 80 | + height does not match this frame's own true size` -- so the arm compares nothing | |
| 81 | + (vacuous; class `counter-from-refused-stream`). That refusal is the next blocker for any | |
| 82 | + non-SB-multiple height. | |
| 83 | +* `(68, 192, 5, false)`: RED on a real, separate defect -- | |
| 84 | + `68x192 cq35 frames=5 10bit=false frame 1 plane Y: 141 pixels differ, first at row 0 col | |
| 85 | + 64 (ours 167 vs ffmpeg 166) [edge32=[0,34,0,0,1,17,0,1]]`. LUMA, inside the 4-px | |
| 86 | + straddling COLUMN. The straddling-ROW twin never reaches this because of the refusal above. | |
| 87 | +The reason is recorded as a comment in `edge32_gate` (`crates/ec-av1/src/stream.rs`, just | |
| 88 | +above `let cqs`) so it is not re-attempted blind. | |
| 89 | + | |
| 90 | +## Exact next step for r8 | |
| 91 | +1. Read `$HOME/.cache/golomb-suite-r7.log`'s `test result:` line (N/0 expected); that is the | |
| 92 | + only thing this round did not finish. | |
| 93 | +2. `main` has advanced to `85887c7` (this branch merged `18bf7dc`); re-merge before any | |
| 94 | + further work. | |
| 95 | +3. Then the 68-px straddle: fix the `68x192` luma defect at the 4-px straddling column | |
| 96 | + (start from `read_var_tx_size`'s `blk_col >= max_w_mi` early return and the right-edge | |
| 97 | + prediction/availability, first difference is at row 0 col 64 = the first straddling | |
| 98 | + column of decode picture 1), and the `192x68` "reference picture whose height does not | |
| 99 | + match this frame's own true size" refusal -- then the arms can be added for real. |
lanes/golomb-r7.report.mdadded+96 -0
| @@ -0,0 +1,96 @@ | ||
| 1 | +# lane-golomb r7 REPORT -- GREEN (the r6 chroma residue is closed at its root cause) | |
| 2 | + | |
| 3 | +## What changed | |
| 4 | +* `crates/ec-av1/src/decode.rs` -- new `fn reduce_inherited_chroma_tx_type(t, w, h)` | |
| 5 | + (inserted just above `fn inter_txbset_for`), and both inter-chroma callers now use it: | |
| 6 | + * `read_inter_plane_rect`'s `default_tx_type` (was `Some(t) if w.max(h) < 32 => t`) | |
| 7 | + * `read_inter_plane`'s `default_tx_type` (was `Some(t) if side < 32 => t`) | |
| 8 | + Those two are the ONLY sites in the crate that derive a chroma `tx_type` for an INTER | |
| 9 | + block (`rg inherited_luma_tx_type`); the intra chroma sites (`decode.rs:6056`, `9195`) | |
| 10 | + take `default_intra_tx_type` and are already correct -- every value that table can | |
| 11 | + produce is a member of both intra sets below 32, and both already force `DCT_DCT` at | |
| 12 | + `>= 32`, which for INTRA is right (`av1_get_ext_tx_set_type` returns `EXT_TX_SET_DCTONLY` | |
| 13 | + for intra at `tx_size_sqr_up == TX_32X32`). | |
| 14 | +* `crates/ec-av1/src/decode.rs` -- new unit test | |
| 15 | + `decode::tests::an_inter_chroma_transform_narrows_its_inherited_tx_type_to_its_own_set`. | |
| 16 | +* `crates/ec-av1/src/stream.rs` -- comment only: the measured reason the 192x68 / 68x192 | |
| 17 | + straddling arms are NOT in `edge32_gate` (below). | |
| 18 | + | |
| 19 | +## ROOT CAUSE (libaom citation) | |
| 20 | +`av1_get_tx_type` (`av1/common/blockd.h:1278-1309`) for a chroma plane of an INTER block: | |
| 21 | +1. `if (txsize_sqr_up_map[tx_size] > TX_32X32) return DCT_DCT;` -- **strictly greater**; | |
| 22 | +2. `tx_type = xd->tx_type_map[(blk_row << ss_y) * stride + (blk_col << ss_x)]` -- the | |
| 23 | + colocated luma unit's coded type (for a chroma unit at (0,0), the FIRST var-tx leaf); | |
| 24 | +3. `if (!av1_ext_tx_used[av1_get_ext_tx_set_type(tx_size, 1, reduced)][tx_type]) | |
| 25 | + tx_type = DCT_DCT;` -- narrowed by the set the **chroma** size selects | |
| 26 | + (`av1_ext_tx_used` `blockd.h:1036`, `av1_get_ext_tx_set_type` `blockd.h:1097`). | |
| 27 | + | |
| 28 | +We had step 1 as `chroma side >= 32 -> DCT_DCT` and no step 3 at all. At exactly | |
| 29 | +`TX_32X32` an inter block reads `EXT_TX_SET_DCT_IDTX`, which **contains IDTX**. So a | |
| 30 | +64x64 inter superblock, whose chroma units are 32x32 (`av1_get_max_uv_txsize(BLOCK_64X64)`), | |
| 31 | +whose first luma var-tx leaf coded `IDTX`, must inverse-transform its chroma with IDTX -- | |
| 32 | +we used DCT_DCT. | |
| 33 | + | |
| 34 | +`IDTX` and `DCT_DCT` are both `TX_CLASS_2D`: same scan, same coefficient contexts, same | |
| 35 | +msac ranges. That is why the whole stream stayed in entropy sync and only one superblock | |
| 36 | +of chroma came out as high-frequency noise with luma bit-exact -- the r6 handoff's exact | |
| 37 | +signature. (Class for the ledger: a tx_type set-membership bug is invisible to every | |
| 38 | +range ladder; only pixels see it.) | |
| 39 | + | |
| 40 | +The old rule was also wrong the other way for chroma 16x16 under 8x8 luma leaves | |
| 41 | +(`EXT_TX_SET_DTT9_IDTX_1DDCT` excludes V_ADST/H_ADST/V_FLIPADST/H_FLIPADST, which we would | |
| 42 | +have inherited verbatim). The new helper covers all four sets. | |
| 43 | + | |
| 44 | +## Localization (how the tx_type was identified, no aomdec rebuild) | |
| 45 | +`EC_TRACE_MODE=1 EC_TRACE_COEFF=1` on `g35.obu` (md5 `9037f5b21db95d35e71f91f040fc33e1`, | |
| 46 | +`scratchpad/gl-gen.sh 35`), split into frames on `EC_MODE mi_row=0 mi_col=0`: decode-order | |
| 47 | +picture 4 is segment 4. Its block at `mi(0,16)` (luma x=64,y=0) runs to the next | |
| 48 | +`EC_MODE mi_row=0 mi_col=32`, i.e. it is a **64x64** block (not 32x32 as r6 recorded), | |
| 49 | +var-tx split into 16x16 leaves. Its last two coefficient units are | |
| 50 | +`eob=1022 tx=DctDct` and `eob=1020 tx=DctDct` with `ctx=0` -- eob > 256 proves 32x32 | |
| 51 | +chroma units -- while its FIRST luma leaf is `eob=254 tx=Idtx`. libaom inherits that | |
| 52 | +`Idtx`; we produced `DctDct`. | |
| 53 | + | |
| 54 | +## Gate | |
| 55 | +`cargo test -p ec-av1 --lib -- a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition --nocapture` | |
| 56 | +(under `systemd-run --user --unit=golomb-gate-r7-... -p MemoryMax=10G`, | |
| 57 | +`EC_AV1_REQUIRE_AOMENC=1`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-golomb`) | |
| 58 | + | |
| 59 | +BEFORE (r6 handoff): `192x80 cq35 frames=5 10bit=false frame 3 plane U: 978 pixels differ, | |
| 60 | +first at row 0 col 32 (ours 33 vs ffmpeg 8) [edge32=[0,36,0,0,0,18,0,0]]`. | |
| 61 | +AFTER: `ok` -- 5 arms x cq {35,40,45,50,55,57,59,61}, 8-bit and 10-bit, | |
| 62 | +`38 pixel-exact attempts, 32-level edge bits [horz_or_vert=0 split=394], 64-level edge | |
| 63 | +bits [horz_or_vert=7 split=197] right-VERT=7, 2 named refusals` (both the inter SB-level | |
| 64 | +AB partition another lane owns). | |
| 65 | + | |
| 66 | +EVIDENCE: $HOME/.cache/golomb-gate-r7.log | cargo test -- a_real_aomenc_stream_with_a_32x32_frame_edge_rect_partition --nocapture, 40 aomenc encodes decoded and compared plane-by-plane vs ffmpeg | 38/38 compared attempts pixel-exact, 0 differing pixels (was 978 U pixels on the 192x80 cq35 5-frame arm) | |
| 67 | +EVIDENCE: $HOME/.cache/golomb-gate-r7b.log | same gate + arms (192,68,5) and (68,192,5) | 68x192 cq35 frame 1 plane Y 141 px differ first at row 0 col 64 -- separate OPEN defect, arm not kept | |
| 68 | +EVIDENCE: scratchpad/r7-ours.err | EC_TRACE_MODE=1 EC_TRACE_COEFF=1 decode_probe g35.obu, segment 4, block mi(0,16) | first luma leaf tx=Idtx, the two 32x32 chroma units (eob 1022/1020) took tx=DctDct | |
| 69 | + | |
| 70 | +Unit check: `cargo test -p ec-av1 --lib -- an_inter_chroma_transform_narrows` => `ok. 1 passed`. | |
| 71 | + | |
| 72 | +## Refusals lifted | |
| 73 | +None this round -- this is a wrong-pixels fix, not a refusal lift. `refusal_inventory` / | |
| 74 | +`gate_coverage` untouched. | |
| 75 | + | |
| 76 | +## The 192x68 / 68x192 straddling arm (r3 verifier ask) -- NOT ADDED, measured why | |
| 77 | +* `(192, 68, 5, false)`: all EIGHT cq attempts refuse by name, `a reference picture whose | |
| 78 | + height does not match this frame's own true size` -> the arm compares nothing (vacuous, | |
| 79 | + class `counter-from-refused-stream`). | |
| 80 | +* `(68, 192, 5, false)`: RED on a real separate defect -- | |
| 81 | + `68x192 cq35 frames=5 10bit=false frame 1 plane Y: 141 pixels differ, first at row 0 | |
| 82 | + col 64 (ours 167 vs ffmpeg 166) [edge32=[0,34,0,0,1,17,0,1]]`. LUMA, inside the 4-px | |
| 83 | + straddling COLUMN; the straddling ROW twin (192x68) never gets that far. | |
| 84 | + disposition: deferred(the right-edge straddling-column luma defect above, and the | |
| 85 | + reference-size refusal) -- both are outside this lane's chroma tx_type cause. | |
| 86 | + | |
| 87 | +## Test totals | |
| 88 | +`$HOME/.cache/golomb-suite-r7.log` (unit `golomb-suite-r7`) -- see the `test result:` line. | |
| 89 | +NOTE: `$HOME/.cache/golomb-suite-r6.log` never produced a `test result:` line: it was still | |
| 90 | +`active` (254/404 tests, stuck in the long superres/encoder tests) and holding | |
| 91 | +`CARGO_TARGET_DIR`, so it was stopped -- it was measuring the PRE-fix tree and is superseded | |
| 92 | +by r7. Every `test` line it did produce was `ok` or a documented `ignored`. | |
| 93 | + | |
| 94 | +## Open / residue | |
| 95 | +* `main` has advanced to `85887c7` (we merged `18bf7dc`); this branch is NOT re-merged. | |
| 96 | +* the two defects the 68-px arms found (above), deferred. |
lanes/golomb-r8.handoff.mdadded+50 -0
| @@ -0,0 +1,50 @@ | ||
| 1 | +# lane-golomb r8 HANDOFF -- two true-size fixes in, suite GREEN, straddle arms still blocked | |
| 2 | + | |
| 3 | +Tip: `lane-golomb` (report `lanes/golomb-r8.report.md`, fix `97de75e`, merge of main | |
| 4 | +`85887c7` at `3a08902`). Suite: `379 passed; 0 failed; 34 ignored` | |
| 5 | +(`$HOME/.cache/golomb-suite-r8.log`). edge32 gate green, 38 pixel-exact attempts, 2 refusals. | |
| 6 | + | |
| 7 | +## Landed | |
| 8 | +1. Reference-height refusal compared the mi-rounded `true_height` with the cropped | |
| 9 | + `reference.height`; now compares the header's `frame_height` (libaom compares references on | |
| 10 | + `y_crop_width/height`). Every 192x68 attempt used to refuse; none do now. | |
| 11 | +2. `apply_loop_restoration` now takes the cropped `(frame_width, frame_height)` instead of | |
| 12 | + plane `true_width/true_height` (libaom `av1_get_upsampled_plane_size` + | |
| 13 | + `assert(plane_w == crop_widths)` + `av1_extend_frame`). UNGATED -- every straddle recipe | |
| 14 | + runs `--enable-restoration=0`. | |
| 15 | + | |
| 16 | +## The ONE open defect this lane still owns | |
| 17 | +A **+-1 straddling-band INTER reconstruction defect**, both orientations, all on **frame 1** | |
| 18 | +(frame 0 is bit-exact in every case, so it is not intra and not a per-frame filter constant): | |
| 19 | +* `68x192` cq35 8-bit: `frame 1 plane Y: 141 px differ, first at row 0 col 64 (167 vs 166)` | |
| 20 | + -- cols 64..67 are the straddling COLUMNS of a 68-wide frame (mi-rounded 72). | |
| 21 | +* `192x68` cq59 8-bit: `frame 1 plane Y: 217 px, first at row 60 col 170 (172 vs 173)`. | |
| 22 | +* `192x68` cq35 10-bit: `frame 1 plane Y: 305 px, first at row 56 col 48 (530 vs 531)`. | |
| 23 | +Reproduce by re-adding `arms.push((68, 192, 5, false))` / `arms.push((192, 68, 5, false))` in | |
| 24 | +`edge32_gate` (`crates/ec-av1/src/stream.rs`, the comment block just above `let cqs`) and | |
| 25 | +running with `EC_GATE_VERBOSE=1` (new this round -- names each attempt before decoding it, | |
| 26 | +because a desync otherwise panics in `mc.rs` with no arm in the message). | |
| 27 | + | |
| 28 | +RULED OUT this round, do not re-attempt: | |
| 29 | +* Reference border padding. `aom_yv12_extend_frame_borders_c` calls `extend_plane` with | |
| 30 | + `crop_widths/crop_heights` and memsets from `src + width - 1`, so libaom OVERWRITES decoded | |
| 31 | + columns 68..71 with column 67 -- exactly what our `mc::sample` clamp at `true_width-1` of the | |
| 32 | + cropped reference already does. The charter's hypothesis (b) is refuted at the source. | |
| 33 | +* Loop restoration. The gate recipe has `--enable-restoration=0`; the 68x192 diff is | |
| 34 | + byte-identical before and after fix 2 (`golomb-gate-r8c.log` vs `r8d.log`). | |
| 35 | +* Var-tx clipping (`max_w_mi`/`max_h_mi`). libaom's `max_block_wide` is derived from | |
| 36 | + `mb_to_right_edge`, i.e. `cm->mi_params.mi_cols` -- the MI-ROUNDED bound, which is what we | |
| 37 | + use. Correct as-is. | |
| 38 | + | |
| 39 | +Next probe to run (r8 ran out of budget before it): dump the 68x192 cq35 stream to disk, then | |
| 40 | +bisect the frame-1 divergence with `EC_AV1_PREFILT_DUMP` (8-bit vars -- the 16-bit ones | |
| 41 | +SEGFAULT the oracle aomdec on an 8-bit stream) against the instrumented aomdec. If the | |
| 42 | +divergence is already present pre-filter it is inter prediction/residual in the straddling | |
| 43 | +band; if not, it is deblock/CDEF at the x=68 (resp. y=68) mi edge. | |
| 44 | + | |
| 45 | +## Two blockers that are NOT this lane's code | |
| 46 | +* `192x68` cq40 8-bit **PANICS** in `decode_inter_block8` (`from_switchable_symbol` handed a | |
| 47 | + 4th symbol, `mc.rs:203`) = lane-sub8's open below-8x8 desync. A panic cannot be tolerated | |
| 48 | + as a named refusal, so no straddle arm can span cq40 until sub8 lands. | |
| 49 | +* `192x68` cq35 8-bit refuses "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B)" | |
| 50 | + even though the recipe sets `--enable-ab-partitions=0` -- worth one measurement of its own. |
lanes/golomb-r8.report.mdadded+102 -0
| @@ -0,0 +1,102 @@ | ||
| 1 | +# lane-golomb r8 -- two true-size defects fixed, straddle arms STILL not addable | |
| 2 | + | |
| 3 | +Tip: `97de75e` on `lane-golomb` (merge `3a08902` of main `85887c7`, then the fix). | |
| 4 | + | |
| 5 | +## (1) Suite r7 -- no result line, superseded | |
| 6 | +`$HOME/.cache/golomb-suite-r7.log` was still `active` at **226/404** tests with **no** | |
| 7 | +`test result:` line and **zero** `FAILED`/`panicked` lines. It was measuring the PRE-merge | |
| 8 | +tree (main has since advanced to 85887c7), so r8 stopped the unit to take the target dir. | |
| 9 | +Owed artifact carried forward to r8's own suite. | |
| 10 | + | |
| 11 | +## (2) Merge of main 85887c7 | |
| 12 | +`git merge --no-commit main` was a CLEAN auto-merge (decode.rs + stream.rs auto-merged, no | |
| 13 | +conflict, no hand resolution). Byte-compared against main afterwards: | |
| 14 | +`mvstack.rs`, `cdf.rs`, `cdf_state.rs`, `refusal_inventory.rs` are all **IDENTICAL to main** | |
| 15 | +(`git diff --quiet main -- <file>`). Only decode.rs and stream.rs carry lane content. | |
| 16 | +Merge commit `3a08902`. | |
| 17 | + | |
| 18 | +EVIDENCE: $HOME/.cache/golomb-gate-r8h.log | edge32 gate on the merged tree, all 8 cq arms x | |
| 19 | +{192x80, 80x192} x {8,10}-bit + the 5-frame inter arm | `test result: ok`, 38 pixel-exact | |
| 20 | +attempts, 64-level edge bits [horz_or_vert=7 split=197] right-VERT=7, 2 named refusals -- | |
| 21 | +byte-identical totals to r7's green run. | |
| 22 | + | |
| 23 | +## (3a) FIXED: a same-size reference at a height that is not a multiple of 8 | |
| 24 | +`crates/ec-av1/src/decode.rs`, `decode_inter_frame_tile_with_cdfs`: the guard compared | |
| 25 | +`reference.height` against `true_height = (mi_rows * 4)` (mi-rounded). A decoded `Picture` | |
| 26 | +is cropped to the header's `fh`, so at height 68 (`mi_rows = 2*((68+7)>>3) = 18` -> 72) it | |
| 27 | +compared **68 against 72** and refused every same-size reference. | |
| 28 | +libaom compares references on the CROPPED dimensions -- | |
| 29 | +`av1_setup_scale_factors_for_frame(&sf, ref->y_crop_width, ref->y_crop_height, cm->width, | |
| 30 | +cm->height)` -- and calls a reference *scaled* only when those differ (`av1_is_scaled`). | |
| 31 | +Height must still match (AV1 superres never scales height). Class `av1-truesize-lane`. | |
| 32 | + | |
| 33 | +EVIDENCE: $HOME/.cache/golomb-gate-r8{b,f}.log | `arms.push((192, 68, 5, false))`, cq sweep | | |
| 34 | +BEFORE: 8/8 attempts refuse "a reference picture whose height does not match this frame's own | |
| 35 | +true size"; AFTER: 0/8 do. | |
| 36 | + | |
| 37 | +## (3b) NOT the cause of the 68x192 column defect -- charter hypothesis REFUTED at the source | |
| 38 | +The charter proposed our reference plane replicates from the mi-rounded column 71 instead of | |
| 39 | +the true column 67. Read `aom_scale/generic/yv12extend.c`: `aom_yv12_extend_frame_borders_c` | |
| 40 | +calls `extend_plane(..., ybf->crop_widths[is_uv], ybf->crop_heights[is_uv], ..., | |
| 41 | +right = plane_border + widths - crop_widths)` and `extend_plane` memsets from | |
| 42 | +`src + width - 1` -- i.e. libaom OVERWRITES the decoded columns 68..71 with column 67. | |
| 43 | +Our `mc::sample` clamps at `true_width - 1` of the CROPPED reference `Picture` (68) --> | |
| 44 | +already identical. No fix needed; the 141-px defect is elsewhere. | |
| 45 | + | |
| 46 | +## (3c) FIXED (source-cited, UNEXERCISED): loop restoration ran over the mi-rounded plane | |
| 47 | +`decode.rs::apply_loop_restoration` passed each plane's `true_width`/`true_height`. LR is the | |
| 48 | +one post-decode filter that does not walk the mi grid: libaom sizes every plane with | |
| 49 | +`av1_get_upsampled_plane_size` (`plane_w = ROUND_POWER_OF_TWO(cm->superres_upscaled_width, | |
| 50 | +ss_x)`, `av1/common/restoration.c:47`), **asserts** it equals the buffer's crop width | |
| 51 | +(`restoration.c:1106`) and `av1_extend_frame(..., plane_w, plane_h, ...)` replicates the | |
| 52 | +border from that cropped edge before any unit is filtered (`restoration.c:1109`). Deblock and | |
| 53 | +CDEF DO walk the mi grid, which is why this survived until a non-multiple-of-8 size. | |
| 54 | +Now takes `(frame_width, frame_height)`, chroma `div_ceil(2)`. | |
| 55 | +DISCLOSURE: **no gate exercises this** -- every straddle recipe in `edge32_gate` runs | |
| 56 | +`--enable-restoration=0`, and the 68x192 defect was byte-identical before and after | |
| 57 | +($HOME/.cache/golomb-gate-r8{c,d}.log, both `141 pixels differ, first at row 0 col 64`). | |
| 58 | +It is a source-cited correctness alignment, verified only by the suite staying green. | |
| 59 | + | |
| 60 | +## (4) The straddle arms are STILL not addable -- three separate blockers, each measured | |
| 61 | +Charter asked for `(192,68,5)` and `(68,192,5)` arms at 8+10 bit with a straddling-TU counter. | |
| 62 | +DEVIATION: no arm was added, because every cq level of both is vacuous, panicking or red. | |
| 63 | +The measurements are now recorded verbatim in the `edge32_gate` comment block: | |
| 64 | +* `192x68` cq35 8-bit: no longer the height refusal -- refuses LATER by another lane's name, | |
| 65 | + "an inter SB-level AB partition (HORZ_A/HORZ_B/VERT_A/VERT_B)". Vacuous | |
| 66 | + (class `counter-from-refused-stream`). | |
| 67 | +* `192x68` cq40 8-bit: **PANICS** in `decode_inter_block8` -- `from_switchable_symbol` handed a | |
| 68 | + 4th symbol, `mc.rs:203`. That is lane-sub8's own open below-8x8 desync (already named in | |
| 69 | + `decode.rs`'s scaled-reference-8x8 refusal comment). A panic cannot be tolerated as a named | |
| 70 | + refusal, so the arm cannot even be added with an Err-tolerating recipe. | |
| 71 | +* `192x68` cq59 8-bit: RED, `frame 1 plane Y: 217 pixels differ, first at row 60 col 170 | |
| 72 | + (ours 172 vs ffmpeg 173)`. | |
| 73 | +* `192x68` cq35 10-bit: RED, `frame 1 plane Y: 305 pixels differ, first at row 56 col 48 | |
| 74 | + (ours 530 vs ffmpeg 531)`. | |
| 75 | +* `68x192` cq35 8-bit: RED, `frame 1 plane Y: 141 pixels differ, first at row 0 col 64 | |
| 76 | + (ours 167 vs ffmpeg 166)` -- unchanged from r7 by either fix this round. | |
| 77 | + | |
| 78 | +NEW FACT for the successor: all four red cases are **+-1** bands, on **frame 1** (the first | |
| 79 | +INTER frame -- frame 0 is bit-exact in every one), and they sit in or immediately beside the | |
| 80 | +4-px straddling band (rows 56..63 next to straddling rows 64..67; columns 64..67 are the | |
| 81 | +straddling columns themselves). That is one straddling-band INTER reconstruction defect with | |
| 82 | +two orientations, not four defects -- and it is not the reference border (3b), not LR (3c) and | |
| 83 | +not intra (frame 0 exact). | |
| 84 | + | |
| 85 | +The gate now prints each attempt under `EC_GATE_VERBOSE=1` (`stream.rs`), because a desync | |
| 86 | +otherwise surfaces as a bare panic in `mc.rs` with no arm named. | |
| 87 | + | |
| 88 | +## Test totals | |
| 89 | +`cargo test -p ec-av1 --lib` -> `$HOME/.cache/golomb-suite-r8.log` (unit `golomb-suite-r8`): | |
| 90 | +`test result: ok. 379 passed; 0 failed; 34 ignored; 0 measured; 0 filtered out; finished in | |
| 91 | +917.74s` (413 test lines emitted). GREEN. | |
| 92 | + | |
| 93 | +EVIDENCE: $HOME/.cache/golomb-suite-r8.log | `cargo test -p ec-av1 --lib` on the merged tree at | |
| 94 | +97de75e, unit golomb-suite-r8, MemoryMax=10G | 379 passed / 0 failed / 34 ignored. | |
| 95 | + | |
| 96 | +## Residue disposition | |
| 97 | +* 68x192 / 192x68 straddling-band +-1 INTER defect -- **fix-now, next round**; it is this | |
| 98 | + lane's whole remaining job and the successor has the four measurements above. | |
| 99 | +* `192x68` cq40 below-8x8 panic -- **deferred(lane-sub8's open desync)**; not this lane's code. | |
| 100 | +* `192x68` cq35 inter SB-level AB partition refusal -- **deferred(the AB-partition lane)**. | |
| 101 | +* LR cropped-plane fix ungated -- **deferred(a straddle gate arm with | |
| 102 | + `--enable-restoration=1`)**; the base recipe disables restoration for every arm. |
lanes/golomb-r9.report.mdadded+100 -0
| @@ -0,0 +1,100 @@ | ||
| 1 | +# lane-golomb r9 -- the straddling-band defect is CDEF, and a stream-data PANIC is now a refusal | |
| 2 | + | |
| 3 | +## What changed | |
| 4 | + | |
| 5 | +* `crates/ec-av1/src/decode.rs` `neighbour_filter` -- returns `Result` and refuses | |
| 6 | + "an OBMC neighbour whose switchable interp filter was never recorded" instead of handing the | |
| 7 | + `[3, 3]` sentinel to `mc::from_switchable_symbol`, which `panic!`s on any value above 2. | |
| 8 | + Both call sites (`build_obmc_prediction`'s above and left passes) already sat inside a | |
| 9 | + `Result` function and take `?`. | |
| 10 | +* `crates/ec-av1/src/refusal_inventory.rs` -- the new refusal string pinned. | |
| 11 | +* `crates/ec-av1/src/decode.rs` `deblock_plane` -- new `EC_AV1_DEBLOCK_TRACE_V` rung: the | |
| 12 | + per-edge `x0/y0/len/level` of the vertical pass plus one line per plane with the loop's real | |
| 13 | + `tw`/`th`/`stride` vs `true_*`/crop bounds. That rung is what settled the deblock question below. | |
| 14 | +* `crates/ec-av1/src/stream.rs` -- `a_frame_edge_straddling_band_decodes_pixel_exact`, an | |
| 15 | + `#[ignore]`d pinned test that runs `edge32_gate`'s exact recipe over the four straddle arms | |
| 16 | + (192x68 and 68x192, 5 frames, 8-bit and 10-bit, cq 35..61), with `EC_GATE_VERBOSE` naming. | |
| 17 | + | |
| 18 | +## TASK A -- root cause narrowed to CDEF, stage by stage (fix NOT landed) | |
| 19 | + | |
| 20 | +Stream: `~/.cache/golomb-tmp/s68.obu`, md5 `45722b0fb7f1707a18e0547cc7a59fa2`, produced by | |
| 21 | +`edge32_gate`'s own aomenc recipe at 68x192 cq35 8-bit, 5 frames. | |
| 22 | + | |
| 23 | +| stage | ours vs instrumented aomdec, frame 1 | | |
| 24 | +| --- | --- | | |
| 25 | +| reconstruction (`EC_AV1_PREFILT_DUMP`) | **0 luma pixels differ** over the cropped 68 columns | | |
| 26 | +| post-deblock (`EC_AV1_POSTDEBLOCK_DUMP`, `EC_AV1_DEBUG_SKIP_CDEF=1`) | **matches**, including columns 68..71 | | |
| 27 | +| final output vs ffmpeg | 145 luma differ, mass in columns 64..67 | | |
| 28 | + | |
| 29 | +So inter prediction is exact and the charter's "the MC reference read runs past the crop" | |
| 30 | +hypothesis is refuted a second time (r8 refuted it at the libaom source; r9 refutes it by | |
| 31 | +measurement: our returned `Picture` is already cropped to `frame_width`, so `mc::sample` clamps | |
| 32 | +at column 67 exactly as `extend_plane` does). The deblock is also exact -- `frame_width` is the | |
| 33 | +right clip, confirmed against libaom `set_lpf_parameters`' `if ((width <= x) || (height <= y))` | |
| 34 | +early-out on `plane_ptr->dst.width`, which is the crop width; forcing the mi-rounded bound | |
| 35 | +instead made frame 0 RED (17 luma px, columns 65..67), so r7's clip stays. | |
| 36 | + | |
| 37 | +The divergence therefore enters in **CDEF**, at the last 8x8 CDEF block column (mi column 17, | |
| 38 | +pixels 64..71) -- the one block that straddles the crop edge. Frame 0 survives it and frame 1 | |
| 39 | +does not, which is why every earlier round read the shape as "inter". | |
| 40 | + | |
| 41 | +Two instrument facts a successor needs: | |
| 42 | +* aomdec's `EC_AV1_POSTDEBLOCK_DUMP` is **72 columns wide** (mi-rounded) while its | |
| 43 | + `EC_AV1_PREFILT_DUMP` is cropped to 68 -- the post-deblock rung is the only one that exposes | |
| 44 | + the straddling band on the reference side. | |
| 45 | +* our own `EC_AV1_POSTDEBLOCK_DUMP` is emitted from a site that, on this path, runs **after** | |
| 46 | + `apply_cdef`: `od.f0` and `odnc.f0` (same run, `EC_AV1_DEBUG_SKIP_CDEF=1`) differ in columns | |
| 47 | + 68..71 although `EC_AV1_WATCH`-instrumented `filter_edge` performs no write there. Always pair | |
| 48 | + that dump with `EC_AV1_DEBUG_SKIP_CDEF=1`, or the CDEF defect reads as a deblock defect -- | |
| 49 | + which cost r9 six rounds of the budget. | |
| 50 | + | |
| 51 | +EVIDENCE: ~/.cache/golomb-tmp/{ours,theirs,od,odnc,td}.f* | aomenc 68x192 cq35 5f -> decode_probe with EC_AV1_PREFILT_DUMP / EC_AV1_POSTDEBLOCK_DUMP(+EC_AV1_DEBUG_SKIP_CDEF) vs the same rungs on the oracle aomdec | prefilt f1 luma diffs 0/13056, post-deblock (cdef off) f1 luma diffs 0, final output f1 145 differ first row 0 col 64 | |
| 52 | + | |
| 53 | +## TASK B -- the panic is gone | |
| 54 | + | |
| 55 | +Before: `192x68 cq40` aborted the process in `mc.rs:203`. After: | |
| 56 | + | |
| 57 | +``` | |
| 58 | +$ decode_probe s40.obu | |
| 59 | +REFUSED: unsupported: AV1 tile (an OBMC neighbour whose switchable interp filter was never recorded) | |
| 60 | +``` | |
| 61 | + | |
| 62 | +EVIDENCE: ~/.cache/golomb-tmp/s40.obu (md5 26d42c5f04e4d0f7f4075a4550e999d5) | aomenc 192x68 cq40 5f -> cargo run --example decode_probe | process abort in mc.rs:203 -> `REFUSED: unsupported: AV1 tile (an OBMC neighbour whose switchable interp filter was never recorded)` | |
| 63 | + | |
| 64 | +Sweep of the other aborts reachable from a desynced stream (`decode.rs` + `mc.rs`), each checked | |
| 65 | +against the value's own domain: | |
| 66 | + | |
| 67 | +* `mc.rs:203` `from_switchable_symbol` -- FIXED at its only reachable caller. The other caller | |
| 68 | + (`resolve_interp_filter`) reads a 3-symbol CDF (`switchable_interp: [[u16; 4]; 16]`, | |
| 69 | + `nsyms = cdf.len() - 1`), so it cannot produce a 4th symbol. | |
| 70 | +* `mc.rs:220` `from_header(Switchable)` -- header enum, not a per-block stream value; callers | |
| 71 | + resolve `Switchable` before calling. Left. | |
| 72 | +* `decode.rs:3259` `default_intra_tx_type` -- the mode comes from a 13-symbol CDF and all 13 | |
| 73 | + values have a row. Bounded, left. | |
| 74 | +* `decode.rs:13936`/`14114` `partition_w8` and `decode.rs:15352` `read_single_ref` -- values from | |
| 75 | + 4-symbol / bounded-return helpers. Bounded, left. | |
| 76 | +* `decode.rs:11673/11692/11739` -- guarded by `rect_inter_residual_supported`, which is itself a | |
| 77 | + named refusal. Left. | |
| 78 | +* `decode.rs:11324`, `12091`, `12110`, `12147`, `15660`, `2745` -- block-size / tx-size domain | |
| 79 | + invariants, not stream values. Left. | |
| 80 | +* `decode.rs:2498` `ref_hits` -- a test-side counter accessor, never on the decode path. Left. | |
| 81 | +* the non-test `.unwrap()`/`.expect()` in `decode.rs` (5280, 5324, 6085, 6152, 7352/7353, | |
| 82 | + 7819/7820, 10535, 10591, 10735, 10944) are each dominated by a push/refusal a few lines above. | |
| 83 | + Left, listed here so the next sweep does not re-derive it. | |
| 84 | + | |
| 85 | +## TASK C -- arms | |
| 86 | + | |
| 87 | +`a_frame_edge_straddling_band_decodes_pixel_exact` carries all four straddle arms and is | |
| 88 | +`#[ignore]`d, which is the only honest shape while the CDEF defect is open: an arm that is RED | |
| 89 | +cannot join the green gate, and the r8 handoff's "measured, arm not added" comment is now a | |
| 90 | +runnable test instead of prose. | |
| 91 | + | |
| 92 | +fix-now residue, NOT done this round: | |
| 93 | +* deferred(the CDEF straddle fix) -- the `--enable-restoration=1` arm at 192x68 that would gate | |
| 94 | + r8's cropped-plane loop-restoration fix. `edge32_gate`'s arm tuple has no per-arm flag slot and | |
| 95 | + every straddle recipe is RED regardless, so the LR arm would be vacuous today; it unblocks the | |
| 96 | + moment the CDEF fix lands. This is the same `refusal-lifted-without-a-gate` shape r8 flagged. | |
| 97 | + | |
| 98 | +## Suite | |
| 99 | + | |
| 100 | +`cargo test -p ec-av1 --lib` -> **379 passed; 0 failed; 35 ignored** (`$HOME/.cache/golomb-suite-r9.log`; the extra ignored test vs r8 is the new pinned straddle gate). |
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/interedge-r1.report.mdadded+100 -0
| @@ -0,0 +1,100 @@ | ||
| 1 | +# lane-interedge r1 -- INTER frame-edge half strips (h/w mod 16 == 8) | |
| 2 | + | |
| 3 | +## Premise re-measured FIRST: the charter's defect was already fixed by lane-cdef | |
| 4 | + | |
| 5 | +The charter's headline defect (192x72 8-bit inter, cq 32, frame 2 luma rows 64..=71 | |
| 6 | +cols 8..=188, from lanes/edgeboth-r1.report.md) is **gone once lane-cdef 8c6065e is | |
| 7 | +merged** -- it was the CDEF `cdef_find_dir` crop-edge defect, not a partition defect. | |
| 8 | + | |
| 9 | +EVIDENCE: `~/.cache/interedge-tmp/s192x72.obu` (sha256 a96cf5d0…2807, hashed twice, gen.sh) | |
| 10 | +| decode with the pre-cdef binary (`$HOME/.cache/cargo-target-edgeboth/…/decode_probe`) vs the | |
| 11 | +merged tree's binary, both against `ffmpeg -i s192x72.obu -pix_fmt yuv420p` | |
| 12 | +| pre-cdef: frames 2..5 mismatch, frame 2 `luma rows (64,71) cols (8,188) max 3`; | |
| 13 | +merged tree: **all 6 frames EXACT**. | |
| 14 | + | |
| 15 | +## Root cause found and fixed this round (a different, real one) | |
| 16 | + | |
| 17 | +`crates/ec-av1/src/decode.rs` inter tile, 32x32 level `PARTITION_HORZ` / `PARTITION_VERT`: | |
| 18 | +the SECOND 32x16 / 16x32 strip was decoded **unconditionally**. libaom | |
| 19 | +`decode_partition` (decodeframe.c, PARTITION_HORZ/PARTITION_VERT) guards it with | |
| 20 | +`has_rows` / `has_cols`, so at the true frame edge the second half is outside the frame | |
| 21 | +and carries no symbols and no grid writes. We read symbols the encoder never wrote. | |
| 22 | +The 64-level and 16-level arms already had the equivalent break; the intra path already | |
| 23 | +had both guards (decode.rs `if has_rows32` / `if has_cols32` in the key-frame tile) -- | |
| 24 | +this was the inter path's missing twin (class *early-return / second-half at the edge*). | |
| 25 | + | |
| 26 | +- `crates/ec-av1/src/decode.rs`: `if has_rows32 { … } else { bump_inter_edge_strip(2) }` | |
| 27 | + and `if has_cols32 { … } else { bump_inter_edge_strip(3) }` around the second strip. | |
| 28 | +- `crates/ec-av1/src/decode.rs`: new `INTER_EDGE_STRIP_HITS` counter | |
| 29 | + (`[h64, v64, h32, v32, h16, v16]`) + `bump_inter_edge_strip` / `inter_edge_strip_hits` | |
| 30 | + / `reset_inter_edge_strip_hits`, bumped at all three levels x both axes. | |
| 31 | +- `crates/ec-av1/examples/decode_probe.rs`: prints `inter_edge_strip:` counters. | |
| 32 | +- `crates/ec-av1/src/stream.rs`: lane-oddh r2's `#[ignore]`d inter arm | |
| 33 | + `a_real_aomenc_inter_frame_edge_half_strip_decodes_pixel_exact` is **un-ignored** and | |
| 34 | + rewritten as a 5-size sweep + helper `inter_edge_strip_attempt`. | |
| 35 | + | |
| 36 | +EVIDENCE: `~/.cache/interedge-tmp/sweep2.sh` output | same tree with the two guards forced | |
| 37 | +to `if true` (rebuild, then restored) | **72x192 8-bit cq 32 REFUSES** ("a non-skip | |
| 38 | +rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding" -- a desync | |
| 39 | +symptom) and **104x192 8-bit cq 32 frame 5 luma rows 127..191 wrong**; with the guards | |
| 40 | +both decode luma-exact. | |
| 41 | + | |
| 42 | +## Gate (GREEN) | |
| 43 | + | |
| 44 | +``` | |
| 45 | +CARGO_TARGET_DIR=$HOME/.cache/cargo-target-interedge EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 \ | |
| 46 | +PATH="$HOME/.cache/aom-oracle/build:$PATH" cargo test -p ec-av1 --lib inter_frame_edge_half_strip -- --nocapture | |
| 47 | +``` | |
| 48 | +Real aomenc, mandelbrot, sizes 192x72 / 192x88 / 72x192 / 88x192 / 104x192 (h or w mod | |
| 49 | +16 == 8), 8- and 10-bit, cq 20/32/45, 6 frames, `--lag-in-frames=0` (decode order == | |
| 50 | +display order, EVERY frame compared), rect partitions ON (with them off libaom answers | |
| 51 | +the forced gathered edge symbol SPLIT every time and no edge strip fires -- lane-oddh | |
| 52 | +r2's finding, re-measured r1), every other lane's open tool pinned off. | |
| 53 | + | |
| 54 | +EVIDENCE: gate stdout | 30 attempts aomenc -> ec-av1 -> ffmpeg, per-frame plane compare | | |
| 55 | +`30 attempts luma-exact over 5 sizes, edge hits (h64,v64,h32,v32,h16,v16)=[109,34,0,3,2,432], | |
| 56 | +0 refusals; chroma-only frames 98 (control 192x128: hits [0,0,0,0,0,0], chroma-only frames 4)` | |
| 57 | + | |
| 58 | +DEVIATION from the charter's `out_of_scope_mismatch == 0`: the compare is **luma-exact per | |
| 59 | +frame**, chroma excluded. Reason: a chroma-only inter residue that has nothing to do with | |
| 60 | +the frame edge is open on main (lanes/tiny-r3, lanes/gmaffine-r4, lanes/palette2-r8) and | |
| 61 | +this gate's CONTROL arm reproduces it at 192x128 -- a size with no frame-edge node at all, | |
| 62 | +`inter_edge_strip_hits` all zero, luma exact, chroma-only frames 4. Disabling CDEF and | |
| 63 | +loop restoration does not remove it (`~/.cache/interedge-tmp/sweep3.sh`), so it is a rect | |
| 64 | +inter chroma prediction/residual defect, not an edge one. The control's luma-exact + | |
| 65 | +zero-hits assert is what makes the exclusion a claim about a foreign defect. | |
| 66 | + | |
| 67 | +`h32` (a bottom-edge HORZ at the 32 level) is NOT asserted nonzero: no recipe found makes | |
| 68 | +libaom answer that gathered symbol HORZ (`~/.cache/interedge-tmp/h32.sh`: 3 sizes x 6 cq, | |
| 69 | +all SPLIT). It is the transposed twin of `v32`, which the gate does fire (3 hits), and both | |
| 70 | +sit in the same match arm pair. | |
| 71 | + | |
| 72 | +## Refusals | |
| 73 | +None lifted -- no `refusal_inventory.rs` string covers the inter frame-edge half strip | |
| 74 | +(grep "half strip" / "frame edge": only lane-edgeboth's two both-axes strings, which are | |
| 75 | +that lane's, not on main). Inventory untouched (47). | |
| 76 | + | |
| 77 | +## Film probe (ReelC, 10-bit 1920x792, h mod 16 == 8) | |
| 78 | +`ffmpeg -ss 300 -t 2 -c:v copy -f obu` (3234673 bytes) -> `decode_probe`: | |
| 79 | +- stop string: `an inter 16x16-level 1:4 partition (HORZ_4/VERT_4 -- four 16x4 or 4x16 | |
| 80 | + inter strips; this decoder's inter path codes a 16x16 as NONE, HORZ, VERT, SPLIT or AB)` | |
| 81 | + (the `-t 2` head extract at 0s stops earlier, at `a 128x128 superblock PARTITION_NONE | |
| 82 | + root on an inter frame`). | |
| 83 | +- `EC_AV1_FINAL_DUMP` count: 1 (the key frame; the first inter frame refuses). | |
| 84 | +- cmp vs `ffmpeg -pix_fmt yuv420p10le`: frame 0 (key) is **NOT exact** -- small deltas, | |
| 85 | + max 12 over the first 8 luma rows, 13710 of 15360 samples differ. New finding, see below. | |
| 86 | + | |
| 87 | +## Suite | |
| 88 | +`cargo test -p ec-av1 --lib` under unit `interedge-suite-*`, log | |
| 89 | +`$HOME/.cache/interedge-suite-r1.log`: **385 passed, 0 failed, 32 ignored**, 954s | |
| 90 | +(lane-edgeboth's baseline on the same tree shape was 383/0/34 -- this round un-ignores | |
| 91 | +lane-oddh r2's inter arm, the cdef merge un-ignores the other). | |
| 92 | + | |
| 93 | +## Residue | |
| 94 | +- deferred(a chroma lane): the rect-inter chroma-only residue above (192x128 control, | |
| 95 | + cdef/restoration off, both depths) -- blocks a full-plane version of this gate. | |
| 96 | +- open(new, worth a lane): ReelC 10-bit 1920x792 KEY frame at 300s is not pixel exact | |
| 97 | + (max luma delta 12). Not edge-related: it is the key frame, `inter_edge_strip_hits` | |
| 98 | + all zero. | |
| 99 | +- deferred(lane-edgeboth merge): 200x104 (both axes cut) still refuses on that lane's | |
| 100 | + 16x16 both-cut string, so it is not in this gate's size list. |
lanes/interp3-r1.report.mdadded+96 -0
| @@ -0,0 +1,96 @@ | ||
| 1 | +# lane-interp3 r1 -- the `switchable_interp` PANIC: the compound 8x8 leaf never read its filter | |
| 2 | + | |
| 3 | +## Root cause (cited) | |
| 4 | + | |
| 5 | +libaom `decodemv.c:1575` (`read_inter_block_mode_info`) calls `read_mb_interp_filter` | |
| 6 | +for **every** inter block, compound ones included, right after `read_compound_type`. | |
| 7 | +`decode_leaf8`'s COMPOUND arm (`crates/ec-av1/src/decode.rs`, the branch that returns at | |
| 8 | +the old line 19589) called `resolve_interp_filter` **not at all**: it predicted both taps | |
| 9 | +with a hard-coded `Regular` and returned the `[3, 3]` "no filter recorded" sentinel as the | |
| 10 | +leaf's `leaf_filter_syms`. Two consequences, both real on his data: | |
| 11 | + | |
| 12 | +1. **Entropy**: on a `SWITCHABLE`-filter frame one symbol (two under `enable_dual_filter`) | |
| 13 | + is left unread at every compound 8x8 leaf -- silent desync. | |
| 14 | +2. **Crash**: the sentinel is stamped into `Neighbours::above_filter`/`left_filter`, and a | |
| 15 | + neighbouring OBMC block's `neighbour_filter` fed it to | |
| 16 | + `mc::InterpFilterKind::from_switchable_symbol`, whose `panic!("switchable_interp's | |
| 17 | + alphabet is exactly 3 symbols")` aborted the process. That is the panic lane-r14 r3 | |
| 18 | + flagged (its `--enable-dual-filter=1 --enable-obmc=1` 192x128 cq30 stream). The same | |
| 19 | + shape was already fixed once for the SINGLE-ref 8x8 leaf (lane-gmaffine r3, decode.rs | |
| 20 | + ~21509 comment) -- the compound arm was the surviving sibling instance. | |
| 21 | + | |
| 22 | +## Changed | |
| 23 | + | |
| 24 | +- `crates/ec-av1/src/decode.rs` (compound 8x8 leaf, after the `comp_group_idx`/ | |
| 25 | + `compound_idx` reads): reads `interp_filter` in libaom's order, with `get_ref_filter_type` | |
| 26 | + neighbour contexts keyed on `ref0` and `is_compound = true`; suppression term is | |
| 27 | + `skip_mode || is_nontrans_global_motion` (GLOBAL_GLOBALMV + both refs' models non- | |
| 28 | + TRANSLATION; WARPED_CAUSAL cannot occur on compound). The 12 `predict_compound_intermediate` | |
| 29 | + taps now use the resolved `h_filter`/`v_filter` instead of `Regular`. | |
| 30 | +- `crates/ec-av1/src/decode.rs` `neighbour_filter`: returns `Result`; the `[3, 3]` sentinel | |
| 31 | + is now the named refusal `an OBMC neighbour whose interp filter was never recorded (no | |
| 32 | + switchable symbol for that block)` -- **never a panic**. Both OBMC call sites `?` it. | |
| 33 | +- `crates/ec-av1/src/decode.rs`: counters `DUAL_FILTER_DIFF_HITS` (a block whose two | |
| 34 | + dual-filter directions differ -- impossible with dual filter off) and | |
| 35 | + `COMPOUND8_FILTER_HITS`. | |
| 36 | +- `crates/ec-av1/src/refusal_inventory.rs`: the new refusal listed (inventory test green). | |
| 37 | +- `crates/ec-av1/src/stream.rs`: `inter_sb_none_gate` takes a `frame_count` | |
| 38 | + (4 frames never code a compound block); new gate | |
| 39 | + `a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` | |
| 40 | + (`--enable-dual-filter=1 --enable-obmc=1 --enable-warped-motion=1 --enable-onesided-comp=1` | |
| 41 | + on the `--min-partition-size=8 --enable-ab-partitions=0 --enable-1to4-partitions=0` | |
| 42 | + recipe, every frame compared Y/U/V vs ffmpeg, hard asserts on all three counters). | |
| 43 | +- `crates/ec-av1/src/decode.rs` test | |
| 44 | + `an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking`. | |
| 45 | + | |
| 46 | +## Gate: RED, `#[ignore]`d with the measurement, not deleted | |
| 47 | + | |
| 48 | +`EC_INTERP3_FRAMES=4` -> aomenc codes no compound block, stream decodes. | |
| 49 | +From 5 frames on it does, and the decode stops at a refusal that the recipe makes | |
| 50 | +impossible: `an inter 16x16-level AB or 1:4 partition` WITH this round's filter read, and | |
| 51 | +`an inter partition below 8x8` WITHOUT it (measured by ablating the read behind a temporary | |
| 52 | +env switch, since removed). `--enable-ab-partitions=0 --enable-1to4-partitions=0 | |
| 53 | +--min-partition-size=8` cannot emit either -- so both are our own desync | |
| 54 | +(class `refusal-from-own-desync`): the compound 8x8 leaf carries at least one more | |
| 55 | +missing/misplaced symbol beyond the interp filter. The fix is therefore **necessary but not | |
| 56 | +sufficient** and is not claimed as pixel-proven. | |
| 57 | + | |
| 58 | +EVIDENCE: $HOME/.cache/interp3-suite-r1.log | `cargo test -p ec-av1 --lib -j3` under a | |
| 59 | +systemd user unit, MemoryMax=10G | totals below | |
| 60 | +EVIDENCE: gate run `EC_INTERP3_FRAMES=5..16 cargo test -p ec-av1 --lib a_real_aomenc_dual_filter_obmc_8x8` with and without the new read | 6 encodes x 2 arms | refusal string differs per arm (AB/1:4 vs below-8x8), 0 frames compared either way -- gate RED, ignored | |
| 61 | +EVIDENCE: `cargo test -p ec-av1 --lib an_obmc_neighbour_with_no_recorded` | direct call with the `[3, 3]` sentinel | 1 passed: refuses by name, no panic | |
| 62 | + | |
| 63 | +## Panic sweep of the decode path (charter clause) | |
| 64 | + | |
| 65 | +`neighbour_filter` was the only `panic!` reachable from a *stream-derived value* on the OBMC | |
| 66 | +path; converted. The rest of `decode.rs`'s 57 `panic!/unreachable!/unwrap/expect` sites, | |
| 67 | +inspected: `2733, 11268, 11617, 11636, 11683, 11996, 12015, 12052, 13820, 13998, 15225, | |
| 68 | +15533` are `unreachable!` on values a CDF alphabet or an earlier refusal already bounds | |
| 69 | +(cannot fire on any stream); `5238, 5282, 6043, 6110, 7310, 7311, 7777, 7778, 10479, 10535, | |
| 70 | +10679, 10888` are `unwrap/expect` on this decoder's own just-built state; everything above | |
| 71 | +line 22700 is inside `#[cfg(test)]`. Two remain flagged, not converted (they need a `Result` | |
| 72 | +in a counter/table helper and no stream is known to reach them): | |
| 73 | +`decode.rs:2486` `panic!("ref_hits: no per-reference counter for ref_frame {other}")` and | |
| 74 | +`decode.rs:3247` `panic!("intra mode {other} has no Intra_Mode_To_Tx_Type entry")`. | |
| 75 | +`mc.rs:203`/`:220` stay as documented invariants -- both callers now check first. | |
| 76 | + | |
| 77 | +## Residue | |
| 78 | + | |
| 79 | +- fix-now(next round): the remaining compound-8x8 desync. Method: `EC_TRACE=1` aomdec range | |
| 80 | + ladder against ours on the FIRST compound leaf of frame 5 of the gate's stream, comparing | |
| 81 | + msac RANGE element by element (never `tell()`). | |
| 82 | +- deferred(needs that fix): the 10-bit arm of the new gate, and the counter-proving | |
| 83 | + pixel-exact claim. | |
| 84 | + | |
| 85 | +## Suite | |
| 86 | + | |
| 87 | +`systemd-run --user --unit=interp3-suite-r1 -p MemoryMax=10G --same-dir bash -lc 'EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-interp3 nice -n 10 cargo test -p ec-av1 --lib -j3 > $HOME/.cache/interp3-suite-r1.log 2>&1'` | |
| 88 | + | |
| 89 | +**372 passed; 0 failed; 33 ignored; 1208.18s** (main's 371/0/32 plus this round's | |
| 90 | +`an_obmc_neighbour_with_no_recorded_filter_refuses_instead_of_panicking`, plus the new | |
| 91 | +gate ignored). Every OBMC/compound sibling gate green on this tip, including | |
| 92 | +`a_real_aomenc_stream_with_obmc_decodes_pixel_exact`, | |
| 93 | +`a_real_aomenc_stream_with_obmc_8x8_decodes_pixel_exact`, | |
| 94 | +`a_real_aomenc_stream_with_compound_references_decodes_pixel_exact`, | |
| 95 | +`a_real_aomenc_superres_stream_with_compound_obmc_and_interintra_decodes_pixel_exact` | |
| 96 | +and both `..._8x8_leaf_split_...` arms -- the entropy change did not move any of them. |
lanes/interp3-r2.handoff.mdadded+48 -0
| @@ -0,0 +1,48 @@ | ||
| 1 | +# lane-interp3 r2 HANDOFF (turn cap) | |
| 2 | + | |
| 3 | +Tip: see `git log -1` on branch `lane-interp3` (r2 fix commit + report commit). | |
| 4 | +Base: r1 b702853 + `git merge main` (4eff3a1, lane-mvtwin mvstack fixes). Merge touched | |
| 5 | +only mvstack.rs / stream.rs / lanes/mvtwin-r1.report.md; cdf.rs untouched both sides. | |
| 6 | + | |
| 7 | +## Phase table + divergences: see lanes/interp3-r2.report.md (complete, 17 rows) | |
| 8 | +Two divergences found in `decode_inter_block8`'s compound arm, both FIXED: | |
| 9 | +1. decode.rs:19151 `read_compound_ref_frames` got a hard-coded `LAST_FRAME` (or -1) | |
| 10 | + for the above/left neighbour reference instead of the real per-mi bands | |
| 11 | + (`above_ref0`/`left_ref0`, what `decode_inter_block` passes) -> every | |
| 12 | + `av1_collect_neighbors_ref_counts` vote off the wrong CDF row. | |
| 13 | +2. decode.rs:19410 the leaf's grid stamp cleared BOTH per-slot `is_global_mv_block` | |
| 14 | + flags; now computed as libaom blockd.h:421-429 (mode GLOBAL_GLOBALMV + that slot's | |
| 15 | + gm model > TRANSLATION). | |
| 16 | +Also added: decode.rs:19726 per-entry `EC_STACK` print in the leaf's SINGLE-ref arm. | |
| 17 | + | |
| 18 | +## Ladder (EC_TRACE_MODE=1, ours vs instrumented aomdec, RANGE never tell) | |
| 19 | +- Before fix 1, frames=5 stream: first divergence at compound leaf mi (10,2) -- | |
| 20 | + both enter the mode info at rng=61097; aomdec reads refs (LAST,GOLDEN) mode | |
| 21 | + NEAREST_NEARESTMV -> rng 49516; ours read (LAST,LAST2) NEW_NEWMV -> rng 50496. | |
| 22 | +- Before fix 2, frames=16 stream: first divergence at single-ref 8x8 leaf mi (8,8), | |
| 23 | + entry rng=43099 both; aomdec stack = [(-1,-1) w648, (0,0) w644] (2 entries), | |
| 24 | + ours = [(0,0) w644, (2,-4) w644, (-1,-1) w4] (3) -- the extra (2,-4) is the | |
| 25 | + neighbour's stored mv1 where libaom substitutes the reader's global mv. | |
| 26 | +- AFTER both fixes: 570 vs 570 mode elements, `diff` EMPTY, no refusal. | |
| 27 | + | |
| 28 | +## Gate state | |
| 29 | +`a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` still | |
| 30 | +`#[ignore]`d (ignore text updated with this measurement). Now RED on RECONSTRUCTION, | |
| 31 | +not entropy: luma-only, frames 0-6 byte-exact, frame 7 = 36 Y wrong (max |d| 5, first | |
| 32 | +(42,15), the 8x8 leaf at mi (10,4), 1-px spill across its left/bottom deblock edges), | |
| 33 | +propagating to 222 Y + 4 U + 1 V at frame 15. | |
| 34 | +Artifacts: scratchpad .../{pin.obu (5 frames), pin16.obu==mm.obu (16), aom16.trace, | |
| 35 | +ours16e.trace, mm.aom.yuv, mm.ours.yuv, aom.obmc}. | |
| 36 | + | |
| 37 | +## Suite | |
| 38 | +Unit `interp3-suite-r2-1788327820.service`, log `$HOME/.cache/interp3-suite-r2.log`. | |
| 39 | +Armed at the r2 fix commit; still running at the cap -- read the log's `test result:` | |
| 40 | +line, do not re-run blindly. | |
| 41 | + | |
| 42 | +## EXACT NEXT STEP | |
| 43 | +Build an `EC_OBMC` emitter in decode.rs (both OBMC call sites) printing the oracle's | |
| 44 | +own byte format -- `EC_OBMC above|left mi=(r,c) wh=(WxH) rel=%d op=%d nbmv=(y,x) | |
| 45 | +nbref=%d nbbsize=%d filt=%d` -- then diff it against the 325 lines of | |
| 46 | +`EC_OBMC=1 aomdec --rawvideo -o /dev/null mm.obu`, starting at `mi=(10,4)`. The leaf | |
| 47 | +now records a REAL filter pair where it used to record the [3,3] sentinel, so an OBMC | |
| 48 | +blend over a compound neighbour is the first suspect for the residue. |
lanes/interp3-r2.report.mdadded+88 -0
| @@ -0,0 +1,88 @@ | ||
| 1 | +# lane-interp3 r2 -- the compound 8x8 leaf's ENTROPY desync is closed (two twin drifts); gate now RED on a small luma reconstruction residue | |
| 2 | + | |
| 3 | +Base: b702853 (r1) + `git merge main` (4eff3a1, brings lane-mvtwin's mvstack fixes). | |
| 4 | +Merge diffstat: `crates/ec-av1/src/mvstack.rs`, `crates/ec-av1/src/stream.rs`, | |
| 5 | +`lanes/mvtwin-r1.report.md` only -- `cdf.rs` untouched by either side (byte-compare | |
| 6 | +trivially clean), no fixtures churn, no conflicts. | |
| 7 | + | |
| 8 | +## Phase table -- libaom `read_inter_block_mode_info` (decodemv.c ~1400-1600) | |
| 9 | + | |
| 10 | +`IB` = `decode_inter_block` compound arm, `L8` = `decode_inter_block8` compound arm | |
| 11 | +(both in `crates/ec-av1/src/decode.rs`; line numbers are this commit's). | |
| 12 | + | |
| 13 | +| # | phase (libaom) | IB | L8 | verdict | | |
| 14 | +|---|---|---|---|---| | |
| 15 | +| 1 | `skip_mode` (ctx = above+left skip_mode) | 16363 | 19087 | matches | | |
| 16 | +| 2 | `skip` | 16375 | 19093 | matches | | |
| 17 | +| 3 | cdef / delta_q / delta_lf | 16377-16382 | (16x16 slot's, per this fn's doc) | matches (leaf never a delta root) | | |
| 18 | +| 4 | `is_inter` (`intra_inter_ctx`) | 16389 | 19105 | matches | | |
| 19 | +| 5 | `comp_mode` (`read_comp_mode`, ref-count ctx) | 16475 | 19147 | matches (`skip_mode \|\| (reference_select && ...)` vs `reference_select \|\| skip_mode` then `skip_mode \|\| ...` -- same predicate) | | |
| 20 | +| 6 | `read_ref_frames`: `comp_ref_type`, uni/bi trees | 16480 | 19151 | **DIFFERENT -> FIXED**: L8 passed a hard-coded `LAST_FRAME` (or `-1`) as the above/left reference; IB passes the real `neighbours.above_ref[cmi]`/`left_ref[rmi]` | | |
| 21 | +| 7 | `av1_find_mv_refs` (`find_mv_stack_compound`, sign bias + gm table + tpl) | 16519 | 19195 | matches (L8's doc comment claiming "no sign-bias table nor tpl_frame" is stale -- both are passed) | | |
| 22 | +| 8 | `compound_mode` CDF (`COMPOUND_MODE_CTX_MAP`) | 16532 | 19205 | matches | | |
| 23 | +| 9 | drl + `read_mv` per ref (`assign_compound_mv`, has_nearmv/have_newmv rules) | 16537 | 19226 | matches (one shared fn) | | |
| 24 | +| 10 | `interintra` | n/a compound | n/a | matches (never read on compound -- correct) | | |
| 25 | +| 11 | `read_motion_mode` | n/a compound | n/a | matches (`has_second_ref` -> SIMPLE_TRANSLATION) | | |
| 26 | +| 12 | `comp_group_idx` (neighbour ctx) | 16675 | 19263 | matches | | |
| 27 | +| 13 | `compound_type` -> wedge idx+sign / diffwtd `mask_type` | 16710 | 19279 | matches | | |
| 28 | +| 14 | `compound_idx` (distance-weight ctx) | 16936 | 19310 | matches | | |
| 29 | +| 15 | `read_mb_interp_filter` (after `read_compound_type`; suppressed by `skip_mode` / `is_nontrans_global_motion`; `get_ref_filter_type` on ref0 matching EITHER neighbour ref) | 16980 | 19383 | matches (landed r1) | | |
| 30 | +| 16 | tail: grid `MiInfo` stamp -- per-slot `is_global_mv_block` | 16577+16660 | 19424 | **DIFFERENT -> FIXED**: L8 stamped `is_global_mv0/1 = false` unconditionally | | |
| 31 | +| 17 | tail: `record_inter_rect_mi` + `record_compound_ctx_rect_mi` (skip/skip_mode/inter/ref/ref1/filter/comp_group_idx/compound_idx bands) | 18870 | via `compound_ctx8` + caller, 19000 | matches -- verified by the range ladder staying exact for the whole stream | | |
| 32 | + | |
| 33 | +Root causes 6 and 16 are the round's fix. Both are the same class the charter named | |
| 34 | +(twin functions drift), and both are invisible to any value-only check: (6) changes a | |
| 35 | +CDF ROW, (16) changes a LATER block's mv-stack composition. | |
| 36 | + | |
| 37 | +## Changed (path:line) | |
| 38 | + | |
| 39 | +- `crates/ec-av1/src/decode.rs:19151` -- `read_compound_ref_frames` now gets | |
| 40 | + `above_ref0`/`left_ref0` (the per-mi bands the leaf already reads at 19078-19081) | |
| 41 | + instead of `LAST_FRAME`/`-1`. `-1` on an unavailable band is `start_tile`'s / | |
| 42 | + `start_row`'s own reset value, so no `has_above` guard is needed (IB has none either). | |
| 43 | +- `crates/ec-av1/src/decode.rs:19410` -- the leaf's grid stamp computes libaom's | |
| 44 | + per-slot `is_global_mv_block` (mode `GLOBAL_GLOBALMV`, that slot's gm model > | |
| 45 | + TRANSLATION; the >= 8x8 size predicate is always true for this leaf). | |
| 46 | +- `crates/ec-av1/src/decode.rs:19726` -- the leaf's SINGLE-ref arm prints the same | |
| 47 | + per-entry `EC_STACK` ladder `decode_inter_block`'s single-ref arm prints (this is | |
| 48 | + the instrument that isolated cause 16). | |
| 49 | +- `crates/ec-av1/src/stream.rs:6315` -- the gate's ignore reason + comment replaced | |
| 50 | + with this round's measurement (entropy closed, pixel residue open). | |
| 51 | + | |
| 52 | +## Gate: still RED, still `#[ignore]`d -- but on a different, much smaller failure | |
| 53 | + | |
| 54 | +`a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` | |
| 55 | +(`--enable-dual-filter=1 --enable-obmc=1 --enable-warped-motion=1 | |
| 56 | +--enable-onesided-comp=1`, `--min-partition-size=8 --enable-ab-partitions=0 | |
| 57 | +--enable-1to4-partitions=0`, 16 frames, 64x64). | |
| 58 | + | |
| 59 | +- r1: decode STOPPED at a bogus refusal at frame 5 (0 frames ever compared). | |
| 60 | +- r2: the whole 16-frame stream parses; the failure is now | |
| 61 | + `frame 7 mismatch vs ffmpeg` -- a reconstruction residue, luma-only, | |
| 62 | + |delta| <= 8, first sample (42,15) inside/around the 8x8 leaf at mi (10,4), | |
| 63 | + spilling 1 px across that leaf's left and bottom deblock edges. It grows by pure | |
| 64 | + propagation to 222 Y + 4 U + 1 V samples at frame 15 (chroma stays exact until | |
| 65 | + frame 14). | |
| 66 | + | |
| 67 | +EVIDENCE: /tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/b6d8a07f-96a4-4bbb-b378-af9ae25cf7c9/scratchpad/{aom16.trace,ours16e.trace} | `EC_TRACE_MODE=1 aomdec --rawvideo` and `EC_TRACE_MODE=1 decode_probe` on the pinned 16-frame stream, `diff` of every `EC_MODE`/`EC_MODE_VAL` line (mi + msac RANGE, never tell) | 570 vs 570 elements, diff EMPTY, no refusal (before the fix: ours stopped at 347 elements, first RANGE divergence at the 8x8 leaf mi (8,8), stack 3 entries vs libaom's 2) | |
| 68 | +EVIDENCE: same dir, `pin.obu` (EC_INTERP3_FRAMES=5) | ladder before fix 1 | ours read refs (LAST,LAST2) + NEW_NEWMV at leaf mi (10,2) where aomdec reads (LAST,GOLDEN) + NEAREST_NEARESTMV -- the two differ only in a CDF row of `uni_comp_ref` | |
| 69 | +EVIDENCE: same dir, `mm.{aom,ours}.yuv` | `aomdec --rawvideo` vs `decode_probe` on the pinned mismatch stream, per-frame per-plane sample compare | frames 0-6 byte-exact; frame 7: 36 Y / 0 U / 0 V wrong, max |delta| 5; frame 15: 222 Y / 4 U / 1 V, max |delta| 8 | |
| 70 | + | |
| 71 | +## Refusals | |
| 72 | + | |
| 73 | +None lifted this round (the r1 refusal `an OBMC neighbour whose interp filter was | |
| 74 | +never recorded` stays; `refusal_inventory` unchanged). Two refusals this stream used | |
| 75 | +to hit -- `an inter 16x16-level AB or 1:4 partition` and `an inter partition below | |
| 76 | +8x8` -- were our own desync (class refusal-from-own-desync) and no longer fire on it. | |
| 77 | + | |
| 78 | +## Residue | |
| 79 | + | |
| 80 | +- fix-now(next round): the luma reconstruction residue above. First suspect is the | |
| 81 | + OBMC blend over a COMPOUND neighbour -- the leaf now records a real filter pair | |
| 82 | + where it used to record the `[3,3]` sentinel, and the oracle's `EC_OBMC` rung | |
| 83 | + prints `nbmv`/`nbref`/`nbbsize`/`filt` per neighbour while THIS decoder has no | |
| 84 | + `EC_OBMC` emitter at all. Build that emitter first (instrument-before-excuse), then | |
| 85 | + diff the 325 oracle `EC_OBMC` lines of `mm.obu` against ours. | |
| 86 | +- deferred(needs that fix): the gate's counter asserts (compound-8x8 filter reads, | |
| 87 | + dual-filter differing directions, 8x8 OBMC blends) are never reached while the | |
| 88 | + pixel compare fails first; the 10-bit arm; a `--tile-columns=1` arm. |
lanes/interp3-r3.handoff.mdadded+88 -0
| @@ -0,0 +1,88 @@ | ||
| 1 | +# lane-interp3 r3 HANDOFF (turn cap) -- root cause FOUND and FIXED, suite still running | |
| 2 | + | |
| 3 | +Tip: `f36be26` on branch `lane-interp3` (fix) + this handoff/report commit. | |
| 4 | + | |
| 5 | +## Suite state | |
| 6 | +- r2 suite (unit `interp3-suite-r2-1788327820.service`, log `$HOME/.cache/interp3-suite-r2.log`), | |
| 7 | + armed at the r2 commit, FINISHED: | |
| 8 | + `test result: ok. 378 passed; 0 failed; 34 ignored; 0 measured; 0 filtered out; finished in 742.50s` | |
| 9 | +- r3 suite FINISHED GREEN at f36be26 (unit `interp3-suite-r3-1788328778.service`): | |
| 10 | + `test result: ok. 379 passed; 0 failed; 33 ignored; 0 measured; 0 filtered out; finished in 1031.33s` | |
| 11 | + (old text below is superseded) | |
| 12 | +- r3 suite armed at f36be26: unit `interp3-suite-r3-1788328778.service`, | |
| 13 | + log `$HOME/.cache/interp3-suite-r3.log`. At the cap it had 258 `... ok`, ZERO | |
| 14 | + `FAILED`/`panicked`, no `test result:` line yet. READ THAT LINE, do not re-run | |
| 15 | + blindly, then paste it into `lanes/interp3-r3.report.md` where | |
| 16 | + `EVIDENCE: SUITE_LINE_PLACEHOLDER` sits. | |
| 17 | + | |
| 18 | +## Stage attribution of the frame-7 residue (done FIRST, as chartered) | |
| 19 | +`EC_AV1_PREFILT_DUMP` on both decoders over the pinned 16-frame stream | |
| 20 | +(`.../scratchpad/mm.obu`), byte compare per decode-order frame: | |
| 21 | +frames 0-6 identical, frame 7 = 35 differing luma bytes, 8..15 grow to 224. | |
| 22 | +=> PRE-FILTER, i.e. prediction/reconstruction, never the loop filter/CDEF/LR. | |
| 23 | +All 35 sit in luma rows 42-47, cols 16-23, i.e. the block at mi (10,4); | |
| 24 | +rows 40-41 of that same block are EXACT and the error grows downward. | |
| 25 | + | |
| 26 | +## What the OBMC comparison actually said (emitter built, class swept, CLEAN) | |
| 27 | +Before writing the emitter, the hand comparison against libaom found NO mismatch: | |
| 28 | +`overlappable_above`/`overlappable_left` stepping and `max_neighbor_obmc` | |
| 29 | +(`{0,1,2,3,4,4}`, 8x8 -> 1 per pass) match `obmc.h:20-55`; overlap sizes | |
| 30 | +(4 luma rows above / 4 luma cols left at 8x8, chroma 2) match | |
| 31 | +`build_obmc_inter_pred_{above,left}`; `av1_skip_u4x4_pred_in_obmc` chroma-above | |
| 32 | +skip matches; `obmc_mask_1/2/4/8/16/32` are byte-identical to | |
| 33 | +`reconinter.c:752-765`; OBMC never warps (`if (!build_for_obmc) av1_init_warp_params`). | |
| 34 | +One real divergence candidate was left un-ported and is still a documented | |
| 35 | +corner-cut, not a defect on this content: `obmc.h`'s `mi_step == 1` 4-wide pair | |
| 36 | +merge, and libaom's `op_mi_size = AOMMIN(xd->width, mi_step)` which can exceed | |
| 37 | +the remaining span while ours clips with `.min(end_col - col)` (only reachable | |
| 38 | +for a 2nd neighbour with a wide step). | |
| 39 | + | |
| 40 | +Emitter: `decode.rs:15806` `ec_obmc_bsize()` + `decode.rs:15828` `ec_obmc_trace()`, | |
| 41 | +called at both passes in `obmc_blend`. Format is aomdec's own bytes: | |
| 42 | +`EC_OBMC above|left mi=(r,c) wh=(WxH) rel=N op=N nbmv=(y,x) nbref=N nbbsize=N filt=N` | |
| 43 | +(`filt` = packed `interp_filters.as_int` = `y | (x << 16)`). | |
| 44 | +`diff` of the 325 oracle lines vs our 325: EMPTY. OBMC is exonerated. | |
| 45 | + | |
| 46 | +Also added `decode.rs:14682` + `:22658` `EC_PICT idx=` (decode-order frame | |
| 47 | +marker under `EC_OBMC`/`EC_TRACE_MODE`). REQUIRED: the marker prints AFTER the | |
| 48 | +frame's own trace lines, so `awk` must count markers seen, not read the value on | |
| 49 | +the preceding line -- attributing by the preceding `EC_PICT` value is off by one | |
| 50 | +and cost part of this round. | |
| 51 | + | |
| 52 | +## Hypotheses ruled out (each by measurement) | |
| 53 | +- OBMC neighbour fields / masks / overlap: 325/325 identical lines (above). | |
| 54 | +- Frame 7 has NO OBMC block at mi (10,4) at all -- it is COMPOUND | |
| 55 | + (SIMPLE_TRANSLATION), so the r2 handoff's "OBMC over a compound neighbour" | |
| 56 | + suspect could not have been it. | |
| 57 | +- Residual/entropy: r2's range ladder is exact end to end; `EC_MCDUMP` (a | |
| 58 | + temporary rung, removed before commit) showed aom_recon - our_residual | |
| 59 | + reproduces our PREDICTION in rows 40-41 and diverges below => prediction. | |
| 60 | +- Wrong dual-filter x/y assignment: a swap would err in every row, not only the | |
| 61 | + lower ones. | |
| 62 | + | |
| 63 | +## Root cause (FIXED, gate GREEN) | |
| 64 | +`decode_inter_block8`'s COMPOUND arm predicted BOTH taps translationally. | |
| 65 | +libaom applies `allow_warp`'s GLOBAL branch to every `is_global_mv_block` | |
| 66 | +reference slot -- compound included, independent of `motion_mode` | |
| 67 | +(`av1_init_warp_params` inside `build_inter_predictors_8x8_and_bigger`'s per-`ref` | |
| 68 | +loop; `reconinter.c:33-55`). `decode_inter_block`'s compound arm has done this | |
| 69 | +since lane-cwarp r1 (`decode.rs:16691`). Third twin-functions-drift instance in | |
| 70 | +this lane. Frame 7 mi (10,4): GLOBAL_GLOBALMV, ref0=GOLDEN mv (0,0), | |
| 71 | +ref1=ALTREF mv (-3,4), comp_group_idx=1. | |
| 72 | +Fix: `decode.rs:19513` (`leaf_compound_warp`, `warp0_c`/`warp1_c`), | |
| 73 | +`decode.rs:19596`/`:19618` (`warp_affine_compound` per luma tap; chroma is 4x4, | |
| 74 | +below `av1_init_warp_params`'s 8px per-plane bound, so it stays translational). | |
| 75 | +Counter `COMPOUND_WARP_HITS_8` / `compound_warp_hits_8()` at `decode.rs:1786`. | |
| 76 | +After the fix ALL 16 decode-order frames are byte-identical pre-filter. | |
| 77 | + | |
| 78 | +## Gate | |
| 79 | +`a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` | |
| 80 | +(`stream.rs:6332`) is UN-IGNORED and GREEN with four hard asserts (compound-8x8 | |
| 81 | +filter read, differing dual-filter directions, 8x8 OBMC blend, 8x8 compound | |
| 82 | +GLOBAL warp). `$HOME/.cache/interp3-gate-r3.log`: `1 passed; 0 failed`. | |
| 83 | + | |
| 84 | +## EXACT NEXT STEP | |
| 85 | +1. DONE (suite green, report filled). Nothing owed here. | |
| 86 | +2. Then the lane's open residue is only the two deferrals in the report | |
| 87 | + (10-bit arm blocked by lane-inter8's 10-bit 8x8-leaf desync; `--tile-columns=1` | |
| 88 | + arm blocked by the SB-level rect-partition refusal). |
lanes/interp3-r3.report.mdadded+106 -0
| @@ -0,0 +1,106 @@ | ||
| 1 | +# lane-interp3 r3 -- the 8x8 COMPOUND leaf never applied the per-ref GLOBAL warp; gate is GREEN and un-ignored | |
| 2 | + | |
| 3 | +Base: d06d93f (r2 handoff, already merged with main). | |
| 4 | + | |
| 5 | +## Root cause (one line) | |
| 6 | + | |
| 7 | +`decode_inter_block8`'s COMPOUND arm predicted **both** reference taps | |
| 8 | +translationally, while libaom applies `allow_warp`'s GLOBAL branch to every | |
| 9 | +`is_global_mv_block` reference slot -- compound included and independently of | |
| 10 | +`motion_mode` (`av1_init_warp_params` is called inside | |
| 11 | +`build_inter_predictors_8x8_and_bigger`'s per-`ref` loop, `reconinter.c:33-55` | |
| 12 | +for `allow_warp` itself). The 16x16+ compound arm has done this since | |
| 13 | +lane-cwarp r1 (`decode.rs:16691`); the 8x8 leaf is its twin and drifted. | |
| 14 | +Third instance in this lane of the class **twin functions drift**. | |
| 15 | + | |
| 16 | +Effect on the pinned stream: the GLOBAL_GLOBALMV compound 8x8 leaf at | |
| 17 | +mi (10,4) of decode-order frame 7 (ref0=GOLDEN mv (0,0), ref1=ALTREF mv | |
| 18 | +(-3,4), `comp_group_idx=1` masked compound) was predicted with a pure | |
| 19 | +translation, so its prediction error was 0 at the block's top rows and grew | |
| 20 | +downward to |delta| 5 -- then propagated through every later frame. | |
| 21 | + | |
| 22 | +## It was NOT the OBMC blend (the r2 handoff's first suspect, disproved) | |
| 23 | + | |
| 24 | +An `EC_OBMC` emitter was added to both OBMC passes in `decode.rs`, printing the | |
| 25 | +instrumented aomdec's own byte format | |
| 26 | +(`EC_OBMC above|left mi=() wh=() rel= op= nbmv=() nbref= nbbsize= filt=`, | |
| 27 | +`decodeframe.c` `dec_build_prediction_by_{above,left}_pred`). The two decoders | |
| 28 | +emit **325 identical lines** on the pinned 16-frame stream -- neighbour | |
| 29 | +position, span, mv, reference, bsize and packed dual-filter pair all agree at | |
| 30 | +every OBMC call. The class sweep the charter asked for (neighbour-side fields | |
| 31 | +used by OBMC: filter, ref, mv, scale) is therefore CLEAN by measurement, not by | |
| 32 | +inspection; `obmc_mask_1/2/4/8/16/32` were also byte-compared against | |
| 33 | +`reconinter.c:752-765` and match. | |
| 34 | + | |
| 35 | +Frame 7 has no OBMC block at mi (10,4) at all: it is a compound block, and | |
| 36 | +compound blocks take SIMPLE_TRANSLATION. | |
| 37 | + | |
| 38 | +## Changed (path:line, this commit) | |
| 39 | + | |
| 40 | +- `crates/ec-av1/src/decode.rs:19513` -- `leaf_compound_warp` + | |
| 41 | + `warp0_c`/`warp1_c`, the leaf's per-slot copy of `decode_inter_block`'s | |
| 42 | + `compound_warp` (`force_integer_mv` short-circuit, `gm.invalid` guard). | |
| 43 | +- `crates/ec-av1/src/decode.rs:19596,19618` -- `warp::warp_affine_compound` | |
| 44 | + replaces each luma tap's translational intermediate, exactly as the 16x16+ | |
| 45 | + arm does at 17130/17155. Chroma is 4x4 at an 8x8 leaf, below | |
| 46 | + `av1_init_warp_params`'s own per-plane 8px bound, so chroma stays | |
| 47 | + translational (same rule the leaf's single-ref arm already applied). | |
| 48 | +- `crates/ec-av1/src/decode.rs:1786` -- `COMPOUND_WARP_HITS_8` + | |
| 49 | + `compound_warp_hits_8()`: the gate's proof that the warp fired at an 8x8 | |
| 50 | + LEAF specifically (`COMPOUND_WARP_HITS` alone cannot tell it from a 16x16+). | |
| 51 | +- `crates/ec-av1/src/decode.rs:15806` (`ec_obmc_bsize`) and `15828` | |
| 52 | + (`ec_obmc_trace`) + the two call sites in `obmc_blend` -- the `EC_OBMC` rung. | |
| 53 | +- `crates/ec-av1/src/decode.rs:14682,22658` -- `EC_PICT idx=` decode-order | |
| 54 | + frame marker (printed under `EC_OBMC`/`EC_TRACE_MODE`), so a trace line can be | |
| 55 | + attributed to the frame whose `EC_AV1_PREFILT_DUMP` file mismatched. Without | |
| 56 | + it the r2 hunt mis-attributed every trace line by one frame. | |
| 57 | +- `crates/ec-av1/src/stream.rs:6332` -- the gate's `#[ignore]` removed, doc | |
| 58 | + comment carries this round's measurement, and a third hard assert | |
| 59 | + (`compound_warp_hits_8() > before`) added. | |
| 60 | + | |
| 61 | +## Class sweep | |
| 62 | + | |
| 63 | +Both inter block decoders are the only prediction sites | |
| 64 | +(`decode_inter_block` 16309, `decode_inter_block8` 19032); all 12 | |
| 65 | +`predict_compound_intermediate` calls were audited. Warp coverage is now: | |
| 66 | +16x16+ single-ref (18235-18253), 16x16+ compound y/u/v x 2 refs | |
| 67 | +(17130-17300), 8x8 leaf single-ref (20238-20253), 8x8 leaf compound luma x 2 | |
| 68 | +refs (19596/19618, chroma correctly excluded). No third twin exists. | |
| 69 | + | |
| 70 | +## Gate: GREEN, un-ignored | |
| 71 | + | |
| 72 | +`a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` | |
| 73 | +(`--enable-dual-filter=1 --enable-obmc=1 --enable-warped-motion=1 | |
| 74 | +--enable-onesided-comp=1`, `--min-partition-size=8 --enable-ab-partitions=0 | |
| 75 | +--enable-1to4-partitions=0`, 64x64, 16 frames). Four hard asserts now: | |
| 76 | +compound 8x8 leaf reading its own switchable filter, a block whose two | |
| 77 | +dual-filter directions DIFFER, an 8x8 OBMC blend, and an 8x8 compound leaf | |
| 78 | +predicted through the per-ref GLOBAL warp. | |
| 79 | + | |
| 80 | +Command: | |
| 81 | +`EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-interp3 cargo test -p ec-av1 --lib a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact` | |
| 82 | +Result: `test result: ok. 1 passed; 0 failed` (log `$HOME/.cache/interp3-gate-r3.log`). | |
| 83 | + | |
| 84 | +## Refusals | |
| 85 | + | |
| 86 | +None lifted. The r1 refusal `an OBMC neighbour whose interp filter was never | |
| 87 | +recorded` stays (it does not fire on this stream); `refusal_inventory.rs` and | |
| 88 | +`gate_coverage.rs` unchanged. | |
| 89 | + | |
| 90 | +## EVIDENCE | |
| 91 | + | |
| 92 | +EVIDENCE: /tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/b6d8a07f-96a4-4bbb-b378-af9ae25cf7c9/scratchpad/{aom.obmc,ours.obmc} | `EC_OBMC=1 aomdec --rawvideo -o /dev/null mm.obu` vs `EC_OBMC=1 decode_probe mm.obu`, `diff` of every EC_OBMC line | 325 vs 325 lines, diff EMPTY -- OBMC neighbour selection/mv/ref/bsize/filter exonerated | |
| 93 | +EVIDENCE: same dir, pf_a/f.f0..15 vs pf_o/f.f0..15 | `EC_AV1_PREFILT_DUMP` on both decoders, byte compare per decode-order frame BEFORE the fix | frames 0-6 identical, frame 7 35 bytes differ (all inside luma rows 42-47, cols 16-23 = the 8x8 leaf at mi (10,4)), growing to 224 at frame 15 | |
| 94 | +EVIDENCE: same dir, pf_a vs pf_o2 | identical command AFTER the fix | all 16 decode-order frames byte-identical pre-filter (0 differing bytes) | |
| 95 | +EVIDENCE: $HOME/.cache/interp3-gate-r3.log | `cargo test -p ec-av1 --lib a_real_aomenc_dual_filter_obmc_8x8_inter_sequence_decodes_pixel_exact -- --nocapture` | `test result: ok. 1 passed; 0 failed` with all four counter asserts live (the run would panic if `compound_warp_hits_8` had not moved) | |
| 96 | +EVIDENCE: $HOME/.cache/interp3-suite-r3.log | `EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-interp3 cargo test -p ec-av1 --lib -j3` under systemd unit `interp3-suite-r3-1788328778.service`, armed at f36be26 | `test result: ok. 379 passed; 0 failed; 33 ignored; 0 measured; 0 filtered out; finished in 1031.33s` (r2 baseline was 378 passed / 34 ignored -- the delta is exactly this gate leaving `#[ignore]`) | |
| 97 | + | |
| 98 | +## Residue | |
| 99 | + | |
| 100 | +- deferred(lane-inter8's 10-bit 8x8-leaf desync) -- a 10-bit twin of this gate. | |
| 101 | + Its sibling `a_real_aomenc_10bit_inter_sequence_with_an_8x8_leaf_split_...` | |
| 102 | + is still `#[ignore]`d on an unrelated 10-bit desync (lane-inter8 r2), so a | |
| 103 | + 10-bit arm of this recipe would go RED on that, not on interp3's own path. | |
| 104 | +- deferred(needs a multi-tile recipe that reaches an 8x8 leaf) -- a | |
| 105 | + `--tile-columns=1` arm. lane-inter8 r3 measured that the 128x64 multi-tile | |
| 106 | + recipe stops at the SB-level rect-partition refusal before any 8x8 leaf. |
lanes/kf1200-r1.report.mdadded+106 -0
| @@ -0,0 +1,106 @@ | ||
| 1 | +# lane-kf1200 r1 — the 16x4/4x16 chroma pair read its edge-filter type from the wrong mi | |
| 2 | + | |
| 3 | +## Defect (census4 premise, re-measured on this branch) | |
| 4 | + | |
| 5 | +ReelB `-ss 1200` key frame (1 frame, `3840x1608 yuv420p10le`), our | |
| 6 | +`EC_PROBE_OUT16` vs `ffmpeg -pix_fmt yuv420p10le`: **12 U samples at ±1, Y and V exact**. | |
| 7 | +Stage bisect (`EC_AV1_PREFILT_DUMP16` ours vs aomdec's): **13 U samples already wrong | |
| 8 | +before the loop filter** — a reconstruction defect, not deblock/CDEF/LR/film grain, and | |
| 9 | +not an entropy desync (lane-kf900's shape). | |
| 10 | + | |
| 11 | +## Root cause | |
| 12 | + | |
| 13 | +Block: chroma `(x=352, y=356)`, `8x4`, `uv_mode = H_PRED`, `angle_delta_uv = -2` | |
| 14 | +(`p_angle = 174`), the chroma half of a `16x8` **`PARTITION_HORZ_4` pair** at | |
| 15 | +luma mi `(178,176)`, strip mi `(179,176)`. | |
| 16 | +Its prediction differed from aomdec's by 4 samples of the last row | |
| 17 | +(`OUR_PRED sum=16208` vs `EC_PREDOUT sum=16212`); row 0 and column 0 identical. | |
| 18 | + | |
| 19 | +`decode.rs:7683` asked for the chroma edge-filter type at the **strip's own mi** | |
| 20 | +(`lmi = (179,176)`). libaom builds `chroma_above_mbmi`/`chroma_left_mbmi` from | |
| 21 | +`mi[-((mi_row & ss_y) * mi_stride + (mi_col & ss_x))]` (`set_mi_offsets`, | |
| 22 | +`av1/common/blockd.h`), i.e. from the **pair's base mi** `(178,176)`, and | |
| 23 | +`get_intra_edge_filter_type` (`av1/common/reconintra.c:974`) reads that block's | |
| 24 | +`uv_mode`. The mi directly above the strip, `(178,176)`, is a non-chroma-reference | |
| 25 | +4-row block whose `uv_mode` is `UV_DC_PRED`; the mi above the PAIR, `(177,176)`, | |
| 26 | +coded `uv_mode = SMOOTH` (aomdec `EC_IMODE_VAL mi_row=177 mi_col=176 uv_mode=9`). | |
| 27 | + | |
| 28 | +So we computed `filt_type = 0` where libaom has `1` (aomdec `EC_PRED ... ft=1`). | |
| 29 | +With `filt_type = 0`, `av1_use_intra_edge_upsample(4, 8, -6, 0)` is TRUE | |
| 30 | +(`blk_wh = 12 <= 16`) instead of false — the left edge was upsampled before the | |
| 31 | +z2 walk, moving 4 samples by 1. The strength/upsample/z2 code itself is correct: | |
| 32 | +recomputing z2 by hand from the (identical) neighbour pixels reproduces aomdec's | |
| 33 | +row exactly (`scratchpad/kf1200`, brute force over dy/offsets). | |
| 34 | + | |
| 35 | +## Change | |
| 36 | + | |
| 37 | +- `crates/ec-av1/src/decode.rs:7683` — `smooth_uv_neighbour(pair_mi.0, pair_mi.1, ...)` | |
| 38 | + instead of `(lmi.0, lmi.1, ...)`, with the libaom citation. | |
| 39 | +- `crates/ec-av1/src/decode.rs:2196` — new `RECT4_16_UV_PAIR_FILT_HITS` counter + | |
| 40 | + `rect4_16_uv_pair_filt_hits()`: pairs where the pair-base answer DIFFERS from the | |
| 41 | + strip-mi answer, i.e. the blocks the fix changes. | |
| 42 | +- `crates/ec-av1/src/stream.rs` gate | |
| 43 | + `a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact` — the odd | |
| 44 | + attempts now use a **chroma-carrying** source (smooth `cb`/`cr` gradients); the gray | |
| 45 | + source left both chroma planes constant, so every `uv_mode` was DC and the shape was | |
| 46 | + unreachable. New hard assert: `pair_filt_proved > 0` per bit-depth arm. | |
| 47 | + | |
| 48 | +No refusal lifted, so `refusal_inventory.rs`/`gate_coverage.rs` are unchanged. | |
| 49 | + | |
| 50 | +## EVIDENCE | |
| 51 | + | |
| 52 | +EVIDENCE: /tmp/.../scratchpad/kf1200/{ours16,ref.yuv} | ffmpeg -ss 1200 -t 0.4 -c:v copy -f obu, trunc.py to 1 frame (sha256 b4b92873d0329964 twice), decode_probe EC_PROBE_OUT16 vs ffmpeg yuv420p10le | U samples differing 12 -> 0, Y/V 0 (Y 0, U 0, V 0 after fix) | |
| 53 | +EVIDENCE: /tmp/.../scratchpad/kf1200/{pre.f0,apre.f0} | EC_AV1_PREFILT_DUMP16 ours vs aomdec on the same 1-frame stream | 13 U samples differ pre-loop-filter => reconstruction, not filters/grain | |
| 54 | +EVIDENCE: /tmp/.../scratchpad/kf1200/{opred.txt,apred.txt} | EC_PRED=1 on both decoders | block (352,356) 8x4 mode=2 ad=-2: ours sum=16208 vs EC_PREDOUT sum=16212, oracle EC_PRED ft=1 | |
| 55 | +EVIDENCE: gate run `cargo test -p ec-av1 --lib a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact -- --nocapture` | real aomenc, 8-bit and 10-bit arms | 8-bit: 16 compared attempts, 232 16x4 / 244 4x16, 238 chroma pairs, 13 pair-base filt-type flips, PASS; 10-bit: 15 attempts, 198 pairs, 8 flips, PASS | |
| 56 | +EVIDENCE: same gate with the fix reverted (pair_mi -> lmi) | one-line revert, rebuild, rerun | FAILED "frame 0 U vs ffmpeg (8-bit, seed 43)" -- the gate is decisive, not vacuous | |
| 57 | +EVIDENCE: $HOME/.cache/kf1200-census.log | 24 HG key frames, 1-frame truncation, EC_PROBE_OUT16 vs ffmpeg, each stream sha256'd twice (identical) | see table | |
| 58 | + | |
| 59 | +## 24 key-frame census (bytes differing, 1 frame each) | |
| 60 | + | |
| 61 | +| -ss | before (census4) | after | | |
| 62 | +|----:|-----------------:|------:| | |
| 63 | +| 0 | 0 | 0 | | |
| 64 | +| 300 | 463 | 463 | | |
| 65 | +| 600 | 48771 | 48771 | | |
| 66 | +| 900 | 14057195 | 14057191 | | |
| 67 | +| **1200** | **14** | **0** | | |
| 68 | +| 1500 | 16649701 | 16649650 | | |
| 69 | +| **1800** | **248** | **0** | | |
| 70 | +| 2100 | 15147518 | 15147782 | | |
| 71 | +| 2400 | 42343 | 42343 | | |
| 72 | +| 2700 | 7726287 | 7726287 | | |
| 73 | +| 3000 | 0 | 0 | | |
| 74 | +| 3300 | 44500 | **39971** | | |
| 75 | +| **3600** | **1** | **0** | | |
| 76 | +| 3900 | 7554020 | 7554023 | | |
| 77 | +| 4200 | 0 | 0 | | |
| 78 | +| 4500 | 0 | 0 | | |
| 79 | +| 4800 | 2348 | 2348 | | |
| 80 | +| 5100 | 0 | 0 | | |
| 81 | +| 5400 | 0 | 0 | | |
| 82 | +| 5700 | 16375 | 16375 | | |
| 83 | +| 6000 | 15450360 | 15449720 | | |
| 84 | +| 6300 | 15410936 | 15410864 | | |
| 85 | +| 6600 | 15181681 | 15181688 | | |
| 86 | +| 6900 | 0 | 0 | | |
| 87 | + | |
| 88 | +(The census4 numbers were taken with the same recipe; note census4 measured frame 0 of a | |
| 89 | +segment that then refused later frames, and this run truncates to 1 frame identically. | |
| 90 | +The multi-million counts are lane-kf900's entropy-desync territory, unchanged here.) | |
| 91 | + | |
| 92 | +## Residue | |
| 93 | + | |
| 94 | +- deferred: `-ss 300` (463 bytes) — a DIFFERENT shape, also chroma-only and also | |
| 95 | + pre-loop-filter, but block-constant offsets of +1/+2 over a ~16x16 chroma region at | |
| 96 | + chroma (412,384) (`EC_AV1_PREFILT_DUMP16` diff, this branch) — reads like CfL alpha or | |
| 97 | + a chroma DC/dequant defect, not an edge-filter type. Unblocked by: localising that | |
| 98 | + block's `uv_mode`/CfL alpha the same way (EC_IMODE_VAL + EC_PRED at mi (206,192)). | |
| 99 | +- deferred: `-ss 600 / 2400 / 4800 / 5700 / 3300` (48771 / 42343 / 2348 / 16375 / 39971) — | |
| 100 | + larger residuals, not triaged in this round. | |
| 101 | +- accepted: the multi-million-byte segments are entropy desyncs owned by lane-kf900. | |
| 102 | + | |
| 103 | +## Suite | |
| 104 | + | |
| 105 | +`cargo test -p ec-av1 --lib` (systemd unit, `EC_AV1_REQUIRE_AOMENC=1`, log `$HOME/.cache/kf1200-suite-r1.log`): | |
| 106 | +**370 passed / 0 failed / 32 ignored**, 1546 s. |
lanes/kf1200-r2.handoff.mdadded+72 -0
| @@ -0,0 +1,72 @@ | ||
| 1 | +# lane-kf1200 r2 HANDOFF | |
| 2 | + | |
| 3 | +## Merge state | |
| 4 | +Branch `lane-kf1200`, tip `385b745`. `git merge main` (85887c7 = lane-mvtwin + | |
| 5 | +lane-sb128b) landed clean at `d85d7d2`; cdf.rs byte-identical to main's; r1's | |
| 6 | +pair-mi chroma edge-filter fix survives at decode.rs:7747. main contains | |
| 7 | +NEITHER lane-reelckf NOR lane-kf900 (`git log --oneline main | grep` empty for | |
| 8 | +both), so no duplicate-implementation resolution was needed and the | |
| 9 | +multi-million-byte census rows are still kf900's. | |
| 10 | +Do NOT commit `lanes/COMMON-20260901.md` — another agent edits it in this | |
| 11 | +worktree; it is intentionally left unstaged. (It is currently modified.) | |
| 12 | + | |
| 13 | +## Per-segment findings (ReelB, 1-frame truncation, EC_PROBE_OUT16 vs ffmpeg 10-bit) | |
| 14 | +- **-ss 300 — FIXED (463 -> 0 bytes).** Plane: U+V only, Y exact. First bad | |
| 15 | + sample chroma (412,384). Stage: PRE-loop-filter (EC_AV1_PREFILT_DUMP16), | |
| 16 | + 16x16 chroma region at (384,412). Block: the 4x4 chroma block of the | |
| 17 | + BLOCK_4X4 2x2 group at luma mi (206,192); chroma-ref mi (207,193), | |
| 18 | + `uv_mode=13` (UV_CFL_PRED), `skip=1`. Root cause: both sub-8x8 leaf decoders | |
| 19 | + passed literal `None` for the CfL argument in their `skip_txfm` arm | |
| 20 | + (decode.rs:10554/10555 4-leaf, :10916/10917 2-leaf), so the block | |
| 21 | + reconstructed as flat DC. libaom `av1_predict_intra_block_facade` | |
| 22 | + (av1/common/reconintra.c:1719) calls `cfl_predict_block` whenever | |
| 23 | + `mbmi->uv_mode == UV_CFL_PRED`; `skip_txfm` drops only the residual. | |
| 24 | + Fix: compute `cfl_ac_q3(y, gpx, gpy, 8)` and pass `alpha.zip(ac)` in both | |
| 25 | + arms + `SKIP_CFL_HITS` counter (decode.rs:2207, `skip_cfl_hits()`). | |
| 26 | + Effect: -ss 300 pixel-exact; -ss 4800 2348 -> 34 bytes as a side effect. | |
| 27 | +- **-ss 600 / 2400 / 3300 / 5700 — ONE class, open.** 48771 / 42343 / 39971 / | |
| 28 | + 16375 bytes. All planes. Final-picture damage rows Y 1595..1607, chroma | |
| 29 | + 796..803. Stage: PRE-loop-filter damage is EXACTLY luma rows 1600..1607, | |
| 30 | + cols 192..3839 (rows 1595..1599 are deblock spill across the y=1600 edge). | |
| 31 | + Frame is 1608 rows = 25 full 64-px SB rows + an 8-row remainder, so this is | |
| 32 | + the bottom PARTIAL superblock row; its first three superblocks (cols 0..191) | |
| 33 | + are pixel-exact. Block: our prediction trace matches aomdec block-for-block | |
| 34 | + through mi (400,47) (mi 44 four TX_4X4 in an 8x8, mi 46 an 8x8). First | |
| 35 | + divergence is the FIRST block of superblock #3: | |
| 36 | + aomdec `EC_PRED mi_row=400 mi_col=48 txw=16 txh=8 mode=2 p_angle=180 bsize=5 part=1 ft=1` | |
| 37 | + ours `OUR_PRED x=192 y=1600 bw=32 bh=16 mode=0 ad=0` (decode.rs:6511) | |
| 38 | + i.e. a PARTITION-SYMBOL divergence at the root of a partial-height | |
| 39 | + superblock (`has_rows == false`, 2 of 16 mi rows present). Not prediction, | |
| 40 | + not caused by the preceding block. Root cause NOT yet identified. | |
| 41 | +- **-ss 4800 — open, small.** 34 bytes (was 2348). Chroma only, luma exact, | |
| 42 | + PRE-loop-filter: U 25 + V 3 samples in an 8x4 chroma patch rows 540..543 | |
| 43 | + cols 1200..1207, |d| <= 6. Luma mi ~ (270,600). Same geometry as r1's | |
| 44 | + 16x8 PARTITION_HORZ_4 pair defect -> likely a sibling of the pair-mi bug. | |
| 45 | +- Accepted (kf900's): 900, 1500, 2100, 2700, 3900, 6000, 6300, 6600. | |
| 46 | + | |
| 47 | +## Gate state | |
| 48 | +- New: `the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact` | |
| 49 | + (crates/ec-av1/src/stream.rs), pins | |
| 50 | + `crates/ec-av1/fixtures/reelb_ss300_key_frame.obu` (139201 B, sha256 | |
| 51 | + 7e3ddf0d602f9496b2f7eb11f051fd4a045020e094d5bc02f83825e2c494ef12, one | |
| 52 | + 3840x1608 yuv420p10le key frame, `git add -f`, confirmed in `git ls-files`). | |
| 53 | + HARD-asserts `skip_cfl_hits > 0` (it fires exactly ONCE in the whole frame) | |
| 54 | + then Y/U/V vs ffmpeg. Fixture used because lane-reelckf r1's ledger dead-end | |
| 55 | + records 20 aomenc recipes that never produced a skipped sub-8x8 CfL block. | |
| 56 | +- r1's `a_real_aomenc_stream_with_a_16_level_1to4_partition_decodes_pixel_exact` | |
| 57 | + (chroma-carrying source + `pair_filt_proved > 0`) unchanged and green. | |
| 58 | +- No refusal lifted; refusal_inventory.rs / gate_coverage.rs untouched. | |
| 59 | +- Suite: 378 passed / 0 failed / 33 ignored (794.95 s), | |
| 60 | + `$HOME/.cache/kf1200-suite-r2.log`. | |
| 61 | + | |
| 62 | +## Exact next step | |
| 63 | +Range-ladder the partition symbols of superblock (mi_row=400, mi_col=48) on | |
| 64 | +`scratchpad/kf1200/s600_f1.obu` (1 frame, sha256 36de46676ed7de70… stable | |
| 65 | +twice): both decoders are still in sync at mi (400,47), so start the ladder | |
| 66 | +there and compare aomdec's `r->ec.rng` at each `EC_IMODE`/partition read | |
| 67 | +against ours element by element (compare RANGE, never tell()). The suspect is | |
| 68 | +the `has_rows == false` forced-partition path at a 64x64 root with only 2 mi | |
| 69 | +rows left — we take a 32x16 where libaom takes 16x8. Artifacts already on disk | |
| 70 | +in scratchpad/kf1200: s600_f1.obu, a600p.trace (aomdec EC_PRED), o600.trace | |
| 71 | +(our OUR_PRED), pre600.f0 / apre600.f0 (prefilter dumps), d1.py (plane differ), | |
| 72 | +census.sh (24-frame census, debug probe path). |
lanes/kf1200-r2.report.mdadded+183 -0
| @@ -0,0 +1,183 @@ | ||
| 1 | +# lane-kf1200 r2 — a skipped sub-8x8 chroma block dropped its CfL alpha | |
| 2 | + | |
| 3 | +## 1. Merge | |
| 4 | + | |
| 5 | +`git merge --no-commit main` (main `85887c7`, lane-mvtwin + lane-sb128b) — clean | |
| 6 | +auto-merge, no conflicts. `crates/ec-av1/src/cdf.rs` byte-identical to main's | |
| 7 | +(`cmp <(git show main:.../cdf.rs) .../cdf.rs` → identical). r1's pair-mi chroma | |
| 8 | +edge-filter fix and its counter survive at `decode.rs:7747`. Commit `d85d7d2`. | |
| 9 | +main contains neither lane-reelckf nor lane-kf900 (`git log --oneline main | grep` | |
| 10 | +→ empty for both), so no duplicate-implementation resolution was needed and the | |
| 11 | +multi-million-byte census rows are still lane-kf900's territory. | |
| 12 | + | |
| 13 | +## 2. Defect found and fixed: `-ss 300`, 463 bytes → 0 | |
| 14 | + | |
| 15 | +Re-measured premise on this branch (1-frame truncation, hash stable twice): | |
| 16 | +U 219 / V 220 samples wrong, Y exact. `EC_AV1_PREFILT_DUMP16` ours vs aomdec's: | |
| 17 | +227 U + 227 V wrong **before the loop filter**, in a 16x16 chroma region at | |
| 18 | +chroma `(384,412)` — reconstruction, not filters. | |
| 19 | + | |
| 20 | +First bad sample chroma `(412,384)` = the 4x4 chroma block of the `BLOCK_4X4` | |
| 21 | +2x2 group at luma mi `(206,192)`. aomdec `EC_TRACE_MODE`: | |
| 22 | +`EC_IMODE_VAL mi_row=207 mi_col=193 mode=4 uv_mode=13 skip=1` — `uv_mode = 13` | |
| 23 | +is `UV_CFL_PRED`, `skip_txfm = 1`. Our `OUR_PRED x=384 y=412 side=4 mode=0 | |
| 24 | +sum=8240 row0=[515,515,515,515]` is flat: DC with **no CfL term at all** | |
| 25 | +(aomdec's own prediction sums to 8241 with a bottom-left ramp). | |
| 26 | + | |
| 27 | +Root cause: both sub-8x8 leaf decoders passed a literal `None` for the CfL | |
| 28 | +argument in their `skip_txfm` arm — | |
| 29 | + | |
| 30 | +- `crates/ec-av1/src/decode.rs:10554/10555` (the 4-leaf `BLOCK_4X4` group) | |
| 31 | +- `crates/ec-av1/src/decode.rs:10916/10917` (the 2-leaf group) | |
| 32 | + | |
| 33 | +libaom's `av1_predict_intra_block_facade` (`av1/common/reconintra.c:1719`) calls | |
| 34 | +`cfl_predict_block` whenever `mbmi->uv_mode == UV_CFL_PRED`; `skip_txfm` only | |
| 35 | +suppresses the residual, never the alpha. Both arms now compute | |
| 36 | +`cfl_ac_q3(y, gpx, gpy, 8)` and pass `alpha.zip(ac)`, exactly like the | |
| 37 | +non-skip arm two lines below and like the rect skip arms already did. | |
| 38 | + | |
| 39 | +### Class sweep | |
| 40 | + | |
| 41 | +Every chroma `reconstruct` / `reconstruct_rect` call site in `decode.rs` was | |
| 42 | +parsed and its cfl argument printed (script in the r2 scratchpad). The rect | |
| 43 | +skip arms (`6015`, `6519`, `8078`) already pass `alpha.zip(ac)`; the only other | |
| 44 | +literal `None` is `20284/20296`, which sits directly behind the refusal | |
| 45 | +"a non-DC chroma mode on an 8x8 inter-frame leaf" (`decode.rs:20212`), so | |
| 46 | +`uv_mode == DC_PRED` is guaranteed there. No other instance of the class. | |
| 47 | + | |
| 48 | +### Counter + gate | |
| 49 | + | |
| 50 | +- `decode.rs:2207` `SKIP_CFL_HITS` / `pub fn skip_cfl_hits()` — skipped sub-8x8 | |
| 51 | + chroma blocks that carried a CfL alpha. | |
| 52 | +- `crates/ec-av1/src/stream.rs` | |
| 53 | + `the_reelb_ss300_key_frame_skipped_cfl_decodes_pixel_exact` — pins | |
| 54 | + `crates/ec-av1/fixtures/reelb_ss300_key_frame.obu` (139 201 B, sha256 | |
| 55 | + `7e3ddf0d602f9496b2f7eb11f051fd4a045020e094d5bc02f83825e2c494ef12`, one | |
| 56 | + 3840x1608 yuv420p10le key frame), decodes it, HARD-asserts | |
| 57 | + `skip_cfl_hits > 0`, then compares Y/U/V against ffmpeg's own 10-bit decode. | |
| 58 | + `git add -f` was used (bare `fixtures` in .gitignore); `git ls-files` confirms | |
| 59 | + it is tracked. | |
| 60 | + | |
| 61 | +Why a fixture and not an aomenc recipe: lane-reelckf r1's ledger dead-end — | |
| 62 | +20 recipes (cq 40..63 × nine lavfi sources, min/max-partition sweeps, sb-size | |
| 63 | +64 and 128) never produced a **skipped** sub-8x8 CfL block (`skip_cfl` counter | |
| 64 | +0 in all). The shape fires exactly **once** in a whole 4K key frame, which is | |
| 65 | +why no synthetic source reaches it. | |
| 66 | + | |
| 67 | +No refusal lifted → `refusal_inventory.rs` / `gate_coverage.rs` unchanged. | |
| 68 | + | |
| 69 | +## 3. Remaining residuals — triaged, one class | |
| 70 | + | |
| 71 | +`-ss 600 / 2400 / 3300 / 5700` (48771 / 42343 / 39971 / 16375 bytes) are ONE | |
| 72 | +defect class, not four: in every one of them the damage is confined to the | |
| 73 | +**last 8 luma rows** of the frame. | |
| 74 | + | |
| 75 | +| -ss | Y rows wrong | U/V rows | first bad Y sample | | |
| 76 | +|----:|---|---|---| | |
| 77 | +| 600 | 1595..1607 | 796..803 | (1595, 2916) | | |
| 78 | +| 2400 | 1595..1607 | 796..803 | (1595, 2445) | | |
| 79 | +| 3300 | 1595..1607 | 796..803 | (1595, 1235) | | |
| 80 | +| 5700 | 1596..1607 | 796..803 | (1596, 3039) | | |
| 81 | + | |
| 82 | +`EC_AV1_PREFILT_DUMP16` on `-ss 600` narrows it further: pre-loop-filter the | |
| 83 | +damage is exactly rows **1600..1607**, columns **192..3839** (rows 1595..1599 | |
| 84 | +in the final picture are deblock spill across the y=1600 edge). The frame is | |
| 85 | +1608 rows = 25 full 64-px superblock rows + one 8-row remainder, so this is the | |
| 86 | +bottom **partial** superblock row, and the first three superblocks of it | |
| 87 | +(columns 0..191) are pixel-exact. | |
| 88 | + | |
| 89 | +Divergence localised to a single block. Through luma mi `(400,47)` our | |
| 90 | +prediction trace matches aomdec's block for block (mi 44: four TX_4X4 in an | |
| 91 | +8x8; mi 46: 8x8 — `EC_PRED mi_row=400 mi_col=46 txw=8 txh=8`). At the very | |
| 92 | +first block of superblock #3: | |
| 93 | + | |
| 94 | +- aomdec: `EC_PRED mi_row=400 mi_col=48 txw=16 txh=8 mode=2 p_angle=180 bsize=5 part=1 ft=1` | |
| 95 | +- ours: `OUR_PRED x=192 y=1600 bw=32 bh=16 mode=0 ad=0` (decode.rs:6511) | |
| 96 | + | |
| 97 | +i.e. we read a 32x16 `PARTITION_HORZ` where libaom reads a 16x8, and the mode | |
| 98 | +differs too — a **partition-symbol divergence at the root of a partial-height | |
| 99 | +superblock** (`has_rows == false`, only 2 of 16 mi rows present), not a | |
| 100 | +prediction bug and not caused by the preceding block. Everything after it in | |
| 101 | +that row is garbage because the row never re-syncs (it is the last row, so | |
| 102 | +nothing propagates downward). | |
| 103 | + | |
| 104 | +`-ss 4800` (2348 bytes in r1, **34 bytes** after this round's CfL fix) is a | |
| 105 | +different, much smaller shape: chroma only, | |
| 106 | +U 29 + V 5 samples in the final picture. `EC_AV1_PREFILT_DUMP16` puts it | |
| 107 | +**pre-loop-filter** too — U 25 + V 3 samples in an **8x4 chroma patch** at | |
| 108 | +rows 540..543, cols 1200..1207 (`|d| <= 6`), luma exact. That is the same | |
| 109 | +geometry as r1's defect (an 8x4 chroma block = the chroma half of a 16x8 | |
| 110 | +`PARTITION_HORZ_4` pair) at luma mi ~`(270,600)`, so it is a strong candidate | |
| 111 | +for a sibling of the pair-mi bug rather than a new class. | |
| 112 | + | |
| 113 | +## 4. Disposition | |
| 114 | + | |
| 115 | +- fix-now (done): `-ss 300` skipped-CfL, fixed + gated + swept. | |
| 116 | +- deferred: the bottom partial-superblock partition divergence (`-ss 600`, | |
| 117 | + 2400, 3300, 5700). Unblocked by: a range ladder over the partition symbols | |
| 118 | + of superblock `(mi_row=400, mi_col=48)` in `s600_f1.obu` comparing aomdec's | |
| 119 | + `r->ec.rng` at `EC_IMODE` against ours — the first three superblocks of the | |
| 120 | + same row are exact, so the ladder starts already in sync at mi 400/47. | |
| 121 | +- deferred: `-ss 4800` (34 B, down from 2348) — stage-attributed (pre-loop-filter, chroma-only, | |
| 122 | + 8x4 patch at chroma (540,1200), luma mi ~(270,600)); the per-block | |
| 123 | + `EC_IMODE_VAL`/`EC_PRED` comparison at that mi is the next step. | |
| 124 | +- accepted: `-ss 900 / 1500 / 2100 / 2700 / 3900 / 6000 / 6300 / 6600` | |
| 125 | + (multi-million bytes) are lane-kf900's entropy desyncs, not merged into main. | |
| 126 | + | |
| 127 | +## 5. 24 key-frame census (bytes differing vs ffmpeg, 1 truncated frame each) | |
| 128 | + | |
| 129 | +Recipe: `$HOME/.cache/kf1200-census-r2.log` (script `census.sh` in the r2 | |
| 130 | +scratchpad) — `ffmpeg -ss S -t 0.4 -c:v copy -f obu`, `trunc.py … 1`, each | |
| 131 | +stream sha256'd twice (identical in all 24 rows), `EC_PROBE_OUT16` vs | |
| 132 | +`ffmpeg -pix_fmt yuv420p10le`. | |
| 133 | + | |
| 134 | +| -ss | r1 (after pair-mi fix) | r2 (after skipped-CfL fix) | | |
| 135 | +|----:|-----------------------:|---------------------------:| | |
| 136 | +| 0 | 0 | 0 | | |
| 137 | +| **300** | **463** | **0** | | |
| 138 | +| 600 | 48771 | 48771 | | |
| 139 | +| 900 | 14057191 | 14057191 | | |
| 140 | +| 1200 | 0 | 0 | | |
| 141 | +| 1500 | 16649650 | 16649650 | | |
| 142 | +| 1800 | 0 | 0 | | |
| 143 | +| 2100 | 15147782 | 15148697 | | |
| 144 | +| 2400 | 42343 | 42343 | | |
| 145 | +| 2700 | 7726287 | 7726168 | | |
| 146 | +| 3000 | 0 | 0 | | |
| 147 | +| 3300 | 39971 | 39971 | | |
| 148 | +| 3600 | 0 | 0 | | |
| 149 | +| 3900 | 7554023 | 7554023 | | |
| 150 | +| 4200 | 0 | 0 | | |
| 151 | +| 4500 | 0 | 0 | | |
| 152 | +| **4800** | **2348** | **34** | | |
| 153 | +| 5100 | 0 | 0 | | |
| 154 | +| 5400 | 0 | 0 | | |
| 155 | +| 5700 | 16375 | 16375 | | |
| 156 | +| 6000 | 15449720 | 15449720 | | |
| 157 | +| 6300 | 15410864 | 15410664 | | |
| 158 | +| 6600 | 15181688 | 15180826 | | |
| 159 | +| 6900 | 0 | 0 | | |
| 160 | + | |
| 161 | +**11 of 24 key frames now decode pixel-exact** (was 10). `-ss 300` is exact; | |
| 162 | +`-ss 4800` fell 2348 → 34 bytes (its remaining 8x4 chroma patch is the residue | |
| 163 | +described in §3). Rows differing by a few hundred bytes inside the | |
| 164 | +multi-million-byte segments are the usual desync churn of lane-kf900's | |
| 165 | +territory, not a regression: none of them changed sign or magnitude class. | |
| 166 | + | |
| 167 | +## 6. Suite | |
| 168 | + | |
| 169 | +`cargo test -p ec-av1 --lib` under `systemd-run --user --unit=kf1200-suite-r2b | |
| 170 | +-p MemoryMax=10G`, `EC_AV1_REQUIRE_AOMENC=1 EC_NOMEMGUARD=1 -j3`, log | |
| 171 | +`$HOME/.cache/kf1200-suite-r2.log`: | |
| 172 | +**378 passed / 0 failed / 33 ignored**, 794.95 s. | |
| 173 | + | |
| 174 | +## EVIDENCE | |
| 175 | + | |
| 176 | +EVIDENCE: $HOME/.cache/kf1200-suite-r2.log | systemd unit kf1200-suite-r2b, EC_AV1_REQUIRE_AOMENC=1, cargo test -p ec-av1 --lib -j3 | test result: ok. 378 passed; 0 failed; 33 ignored; 794.95s | |
| 177 | +EVIDENCE: scratchpad/kf1200/{o300,r300} | 1-frame -ss 300 truncation (sha256 7e3ddf0d602f9496 twice), EC_PROBE_OUT16 vs ffmpeg -pix_fmt yuv420p10le | before fix Y 0 / U 219 / V 220 samples differ; after fix Y 0 / U 0 / V 0 | |
| 178 | +EVIDENCE: scratchpad/kf1200/{pre300.f0,apre300.f0} | EC_AV1_PREFILT_DUMP16 ours vs aomdec, same stream | 227 U + 227 V wrong PRE-loop-filter in a 16x16 chroma region at (384,412) => reconstruction | |
| 179 | +EVIDENCE: scratchpad/kf1200/{o300.trace,a300.trace} | EC_PRED=1 ours, EC_TRACE_MODE=1 EC_PRED=1 aomdec | aomdec EC_IMODE_VAL mi_row=207 mi_col=193 uv_mode=13 (UV_CFL_PRED) skip=1; ours OUR_PRED x=384 y=412 side=4 mode=0 sum=8240 flat (no CfL term) | |
| 180 | +EVIDENCE: gate run `cargo test -p ec-av1 --lib the_reelb_ss300 -- --nocapture` | pinned 1-frame fixture + ffmpeg 10-bit reference | "1 skipped sub-8x8 CfL chroma blocks, frame pixel-exact", 1 passed / 0 failed | |
| 181 | +EVIDENCE: scratchpad/kf1200/{pre600.f0,apre600.f0} | EC_AV1_PREFILT_DUMP16 ours vs aomdec on the -ss 600 1-frame stream | damage exactly luma rows 1600..1607, cols 192..3839 = the bottom partial (8-row) superblock row from superblock #3 on | |
| 182 | +EVIDENCE: scratchpad/kf1200/{o600.trace,a600p.trace} | EC_PRED both decoders | mi (400,44) and (400,46) match block for block; at mi (400,48) aomdec txw=16 txh=8 mode=2 bsize=5 vs ours bw=32 bh=16 mode=0 => partition divergence at the partial-SB root | |
| 183 | +EVIDENCE: $HOME/.cache/kf1200-census-r2.log | census.sh, 24 key frames, each stream hashed twice | 11/24 pixel-exact (was 10); -ss 300 463->0, -ss 4800 2348->34 |
lanes/kf1200-r3.report.mdadded+130 -0
| @@ -0,0 +1,130 @@ | ||
| 1 | +# lane-kf1200 r3 report — the partial-bottom-row desync, root cause found and fixed | |
| 2 | + | |
| 3 | +Tip `9d18288` on `lane-kf1200` (parent `bee8ec0`, main merged at `d85d7d2`). | |
| 4 | + | |
| 5 | +## Root cause (ONE symbol, not the partition path the charter suspected) | |
| 6 | + | |
| 7 | +The charter's premise — "our 32-level gathered `split_or_horz` CDF/ctx differs" — | |
| 8 | +is REFUTED by measurement. A cross-decoder range ladder over the whole partial | |
| 9 | +bottom superblock row shows every partition symbol of mi_row=400 in sync, | |
| 10 | +including the gathered ones (our `ctx` values equal libaom's | |
| 11 | +`partition_plane_context` minus its `bsl * PARTITION_PLOFFSET` offset, and every | |
| 12 | +`rng` matches): | |
| 13 | + | |
| 14 | + aomdec EC_PART mi_row=400 mi_col=44 bsize=6 ctx=6 rng=55482 value=3 (SPLIT) | |
| 15 | + ours OUR_PART mi_row=400 mi_col=44 bsize=6 ctx=2 rng=55482 | |
| 16 | + aomdec EC_PART mi_row=400 mi_col=44 bsize=3 ctx=0 rng=52288 | |
| 17 | + ours TRACE partition_w8 mi=(400,44) ctx=0 value=0 pre_rng=52288 | |
| 18 | + aomdec EC_PART mi_row=400 mi_col=46 bsize=3 ctx=0 rng=53128 | |
| 19 | + ours TRACE partition_w8 mi=(400,46) ctx=0 value=0 pre_rng=53128 | |
| 20 | + | |
| 21 | +The first differing element is the `tx_depth` symbol of the SECOND 8x8 leaf: | |
| 22 | + | |
| 23 | + aomdec EC_ISTEP mi_row=400 mi_col=46 name=tx_depth val=0 ctx=1 rng=42998 | |
| 24 | + ours EC_ISTEP mi_row=400 mi_col=46 name=tx_depth val=0 ctx=2 rng=54191 | |
| 25 | + | |
| 26 | +Same decoded value, different CDF row, therefore a different interval narrowing: | |
| 27 | +the entropy stream is desynced from there on, and the rest of the row (and the | |
| 28 | +1595..1607 deblock spill) decodes as garbage. What the charter saw as "aomdec | |
| 29 | +reads a 16x8 where we read 32x16" was our *already desynced* reader at | |
| 30 | +mi (400,48), one block later. | |
| 31 | + | |
| 32 | +`ctx` comes from libaom `get_tx_size_context`: `above_txfm_context[0] >= | |
| 33 | +max_tx_wide` + `left_txfm_context[0] >= max_tx_high`. The left neighbour of | |
| 34 | +(400,46) is the 8x8 leaf at (400,44), which is `skip=1` and whose `tx_depth` | |
| 35 | +resolved to TX_4X4 — so libaom's `set_txfm_ctxs` published 4 and its left term | |
| 36 | +is 0. Our `decode_leaf8` skip branch fell through to a hardcoded | |
| 37 | +`fill_lf_grid(leaf_mi, 2, 8, 0)`, publishing 8, so our left term read 1. | |
| 38 | + | |
| 39 | +An intra block reads `tx_depth` whether or not it is skipped (libaom | |
| 40 | +`read_intra_frame_mode_info` calls `read_tx_size` above the skip branch); only a | |
| 41 | +skipped *inter* block records its block size instead of its transform. | |
| 42 | + | |
| 43 | +## Change | |
| 44 | + | |
| 45 | +- `crates/ec-av1/src/decode.rs:10330` — `fill_lf_grid(leaf_mi, 2, resolved as u8, 0)` | |
| 46 | + (was the literal `8`). The non-skip TX_4X4 branch already returned early with 4; | |
| 47 | + only the skip path was wrong. One line. | |
| 48 | +- `crates/ec-av1/src/decode.rs:2652` `trace_edge()` + 5 call sites — `OUR_PART | |
| 49 | + mi_row/mi_col/bsize/ctx/rng` under `EC_AV1_TRACE` for the three gathered | |
| 50 | + frame-edge partition reads (there was no emitter for them, only for the full | |
| 51 | + alphabet reads), plus `pre_rng` on the 8x8 partition trace. Instrument only. | |
| 52 | +- `crates/ec-av1/examples/decode_probe.rs:34` — prints `skip_split_tx`. | |
| 53 | + | |
| 54 | +Sibling sweep for the same shape (a skip branch publishing the block side where | |
| 55 | +the resolved transform belongs): `fill_lf_grid` has 6 call sites. | |
| 56 | +`decode_block` (9872) already passes `logical_tx`; the inter 8x8 leaf (20449) | |
| 57 | +passes `if split8 {4} else {8}`; the inter-leaf skip early-return (19644) passes | |
| 58 | +8, which is CORRECT — a skipped inter block records its block size. The 4x4 leaf | |
| 59 | +(10541) passes 4. Only 10330 was wrong. | |
| 60 | + | |
| 61 | +## Gates | |
| 62 | + | |
| 63 | +1. NEW `the_reelb_ss600_key_frame_skipped_split_tx_decodes_pixel_exact` | |
| 64 | + (`crates/ec-av1/src/stream.rs`), pinning | |
| 65 | + `crates/ec-av1/fixtures/reelb_ss600_key_frame.obu` (94717 B, sha256 | |
| 66 | + `36de46676ed7de7049d4dabe8571d8cd31c8a1f53d72011c0ee532a7c6725cd6`, hashed | |
| 67 | + twice, `git add -f`, present in `git ls-files`): one 3840x1608 yuv420p10le key | |
| 68 | + frame. HARD-asserts `skip_split_tx_hits > 0` (24 in this frame) then Y/U/V vs | |
| 69 | + ffmpeg's 10-bit decode. Fixture, not aomenc, because the shape is not | |
| 70 | + synthetically reachable: 80 recipes this round (4 frame shapes x 2 lavfi | |
| 71 | + sources x cq 32/35/40/45/48/50/55/58/63 x cpu-used 0/3 x 8/10-bit, all with | |
| 72 | + `--enable-tx-size-search=1 --enable-filter-intra=1 --min-partition-size=8`) | |
| 73 | + returned `skip_split_tx_hits == 0` every time. Widths with a partial right | |
| 74 | + column (200, 264, 136, 776, 1288) additionally hit the existing named refusal | |
| 75 | + "a 16x16 block whose true edge cuts through both axes", so the charter's | |
| 76 | + 200x72 / 72x200 / 136x104 / 264x136 shapes cannot be compared at all today. | |
| 77 | +2. WIDENED `a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz_decodes_pixel_exact`: | |
| 78 | + three more partial-bottom-row shapes (200x72, 136x88, 264x104 — 2/4/6 mi rows) | |
| 79 | + and an `--enable-tx-size-search=1` arm. The whole recipe ran with | |
| 80 | + `--enable-tx-size-search=0`, so no block in it could carry a nonzero | |
| 81 | + `tx_depth` at all (class `tool-disabled-in-every-gate`) — that is why 8 green | |
| 82 | + arms never saw this defect. 18 arms compared pixel-exact, 10 named refusals | |
| 83 | + (all the double-axis 16x16 one), `edge_horz_total`/`edge_sub_total` still | |
| 84 | + hard-asserted; the `skip_split_tx` counter is reported, not gated, there. | |
| 85 | + | |
| 86 | +## 24-key-frame census (1 frame each, ours vs ffmpeg 10-bit, differing BYTES) | |
| 87 | + | |
| 88 | +r2: 11/24 exact, four multi-million-byte rows. r3: 17/24 exact, **luma exact on | |
| 89 | +all 24**, every remaining row chroma-only. | |
| 90 | + | |
| 91 | +| -ss | Y | U | V | r2 total | | |
| 92 | +|---|---|---|---|---| | |
| 93 | +| 0,300,600,1200,1500,1800,2400,3000,3300,3600,4200,4500,5100,5400,5700,6900 | 0 | 0 | 0 | 4 of these were 16.6M/48771/42343/39971/16375 | | |
| 94 | +| 900 | 0 | 40 | 50980 | 14057191 | | |
| 95 | +| 2100 | 0 | 1289 | 1067 | 15148697 | | |
| 96 | +| 2700 | 0 | 231 | 739 | 7726168 | | |
| 97 | +| 3900 | 0 | 4 | 4 | 7554023 | | |
| 98 | +| 4800 | 0 | 29 | 5 | 34 | | |
| 99 | +| 6000 | 0 | 210 | 0 | 15449720 | | |
| 100 | +| 6300 | 0 | 4 | 0 | 15410664 | | |
| 101 | +| 6600 | 0 | 124 | 124 | 15180826 | | |
| 102 | + | |
| 103 | +The four charter segments (600/2400/3300/5700) are all 0/0/0. | |
| 104 | + | |
| 105 | +## EVIDENCE | |
| 106 | + | |
| 107 | +EVIDENCE: /home/user/.cache/kf1200-tmp/a600s.part + o600s.trace | aomdec EC_TRACE=1 EC_TRACE_MODE_STEP=1 vs our EC_AV1_TRACE=1 EC_TRACE_MODE_STEP=1 on the pinned 1-frame stream | first differing element mi(400,46) tx_depth ctx 2 vs 1, rng 54191 vs 42998; after the fix ours reads ctx=1 rng=42998 | |
| 108 | +EVIDENCE: /home/user/.cache/kf1200-tmp/ours600.yuv vs ref600.yuv | EC_PROBE_OUT16 decode vs `ffmpeg -pix_fmt yuv420p10le` | cmp -l = 0 differing bytes of 18524160 (was 48771) | |
| 109 | +EVIDENCE: /home/user/.cache/kf1200-census-r3.log | 24 key frames extracted with `-frames:v 1 -c:v copy`, per-plane byte diff vs ffmpeg | 17/24 all-zero, luma zero on 24/24 | |
| 110 | +EVIDENCE: cargo test -p ec-av1 --lib a_real_aomenc_stream_whose_frame_edge_partition_bit_is_horz -- --nocapture | 7 shapes x 2 tx arms x 2 depths | 18 arms pixel-exact, 10 named refusals, edge bits 64-level horz/vert up to 3, sub-level up to 9 | |
| 111 | +EVIDENCE: cargo test -p ec-av1 --lib the_reelb_ss600_key_frame -- --nocapture | pinned fixture decode vs ffmpeg 10-bit | "24 skipped 8x8 TX_4X4 leaves, frame pixel-exact" | |
| 112 | + | |
| 113 | +## Suite | |
| 114 | + | |
| 115 | +`cargo test -p ec-av1 --lib` (systemd unit, EC_AV1_REQUIRE_AOMENC=1): **379 passed, 0 failed, | |
| 116 | +33 ignored**, 514.26 s — `/home/user/.cache/kf1200-suite-r3.log`. | |
| 117 | + | |
| 118 | +## Residue | |
| 119 | + | |
| 120 | +- deferred(-ss 4800, U=29/V=5): chroma-only, 8x4 chroma patch at (540,1200) — | |
| 121 | + unchanged by this round, still the r2 pair-mi sibling hypothesis. Unblocked by | |
| 122 | + an `EC_IMODE_VAL`/`EC_PRED` ladder at luma mi ~(270,600); I ran out of turn | |
| 123 | + budget after the census. Same for the other six chroma-only rows (900 V=50980 | |
| 124 | + is the largest and the only one big enough to be a second desync rather than a | |
| 125 | + prediction/edge-filter off-by-one). | |
| 126 | +- accepted: the charter's partial-RIGHT-column gate shapes (200x72 etc.) cannot | |
| 127 | + be compared until the "16x16 block whose true edge cuts through both axes" | |
| 128 | + refusal is lifted; they are in the gate and currently take the refusal arm. | |
| 129 | +- No refusal was lifted this round; `refusal_inventory.rs` / `gate_coverage.rs` | |
| 130 | + untouched. |
lanes/r14-r3.report.mdadded+104 -0
| @@ -0,0 +1,104 @@ | ||
| 1 | +# lane-r14 round 3 — the SPLIT transform of a 1:4 inter strip with a 64-px axis | |
| 2 | + | |
| 3 | +## What changed | |
| 4 | + | |
| 5 | +- `crates/ec-av1/src/decode.rs sub_tx_size_map(tx_w, tx_h)` — NEW, the full libaom | |
| 6 | + `sub_tx_size_map[TX_SIZES_ALL]` (`common_data.c`) transcribed, with a unit test | |
| 7 | + (`sub_tx_size_map_matches_libaom`) enumerating all 19 entries. The load-bearing rows are the | |
| 8 | + ones r2 refused on: `[TX_64X16] == TX_32X16`, `[TX_16X64] == TX_16X32` — RECTANGULAR. | |
| 9 | +- `crates/ec-av1/src/decode.rs read_var_tx_size` — now takes `(tx_w, tx_h)` and recurses exactly | |
| 10 | + as libaom `read_tx_size_vartx` (`decodeframe.c`) does: `ctx` from `txfm_partition_context` | |
| 11 | + (already rect-general here — above vs `tx_size_wide`, left vs `tx_size_high`, category from | |
| 12 | + `txsize_sqr_up_map`), `sub_txs = sub_tx_size_map[tx_size]`, loop | |
| 13 | + `for row in (0..tx_size_high_unit[tx_size]).step_by(bsh) { for col in (0..tx_size_wide_unit).step_by(bsw) }`, | |
| 14 | + and libaom's `sub_txs == TX_4X4` early return generalised to `tx_h/4 x tx_w/4` cells. | |
| 15 | + Leaves are now `(row, col, tw, th)` instead of the square `(row, col, tx_px)`. | |
| 16 | +- `crates/ec-av1/src/decode.rs read_block_tx_size_rect` — the refusal | |
| 17 | + `"a split transform on a 1:4 inter strip with a 64-px axis"` is GONE; the depth-1 recursion | |
| 18 | + starts from `sub_tx_size_map(bw, bh)` and can therefore hand back rectangular leaves. | |
| 19 | +- `crates/ec-av1/src/decode.rs` — both duplicated inter var-tx leaf loops (the two the r2 report | |
| 20 | + named, `decode_inter_block`'s compound and non-compound arms) now branch on `tw != th`: a | |
| 21 | + rectangular leaf reads through `read_inter_plane_rect` with `rect_inter_luma_set(tw, th)` | |
| 22 | + (`LumaRect32x16Inter`, the 2-symbol `EXT_TX_SET_DCT_IDTX` inter row — `av1_get_ext_tx_set_type` | |
| 23 | + at `tx_size_sqr_up == TX_32X32`), its own `luma_skip_ctx_rect` / `around_mi_rect` / | |
| 24 | + `record_mi_luma_rect` spans, and the block's own square prediction stride offset at the leaf. | |
| 25 | +- `crates/ec-av1/src/decode.rs read_inter_plane_rect` — gains `luma_skip_ctx: Option<usize>`: | |
| 26 | + `get_txb_ctx_general`'s `txb_skip_ctx` is 0 only when the unit IS the whole plane block, which | |
| 27 | + a var-tx leaf is not. The 6 whole-block call sites pass `None` (unchanged behaviour). | |
| 28 | +- `crates/ec-av1/src/decode.rs` + `stream.rs` — `vartx_rect_leaf_hits() -> [usize; 2]` | |
| 29 | + (`[32x16, 16x32]`), and `examples/decode_probe.rs` prints it. | |
| 30 | +- `crates/ec-av1/src/refusal_inventory.rs` — the refusal line dropped. | |
| 31 | +- `crates/ec-av1/src/gate_coverage.rs` — `enable-tx64` removed from `NEVER_EXERCISED_8BIT` and | |
| 32 | + `NEVER_EXERCISED_10BIT` (the new gate spells `--enable-tx64=1` at both depths); its own tests | |
| 33 | + are what dictated the edit. | |
| 34 | +- `crates/ec-av1/src/stream.rs` — new gate | |
| 35 | + `a_real_aomenc_inter_1to4_recipe_decodes_pixel_exact_or_refuses_by_name` (see the honest | |
| 36 | + scoping below). | |
| 37 | + | |
| 38 | +## Firing proof: his real film | |
| 39 | + | |
| 40 | +EVIDENCE: `decode_probe` on `seg4500.obu` (`ffmpeg -ss 4500 -t 2 -i <HG 2160p HDR10> -c:v copy -f obu`, 213 frame headers) | run under `systemd-run --user --scope -p MemoryMax=6G` on the r3 tip | `vartx_rect_leaf: 32x16=0 16x32=14`, `inter_rect: 64x32=24 32x64=24 64x16=0 16x64=16` — **14 rectangular var-tx leaves decoded**, and the stop moved from `a split transform on a 1:4 inter strip with a 64-px axis` to `an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet` (lane-intrarect's wall) | |
| 41 | + | |
| 42 | +EVIDENCE: same command on `seg3000.obu` (288 frame headers) | before r3 it stopped at this round's refusal (r2 report) | now `REFUSED: an intra-coded HORZ/VERT strip needs rectangular intra prediction this decoder does not code yet` — this round's wall is off both mid-film segments | |
| 43 | + | |
| 44 | +EVIDENCE: same command on `seg300.obu` (206 frame headers) | unchanged wall (`intra-coded HORZ/VERT strip`) | but it now decodes 4 `16x64` strips and `vartx_rect_leaf 16x32=1` on the way there | |
| 45 | + | |
| 46 | +## Gate — and what it can NOT assert (measured, not assumed) | |
| 47 | + | |
| 48 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -- --test-threads=1 1to4 superblock_level_rect_partition refusal_inventory gate_coverage sub_tx_size_map` → 17 passed / 0 failed (log `$HOME/.cache/r14-r3-g5.log`, plus `-g6` after the gate_coverage edit). | |
| 49 | + | |
| 50 | +The new gate sweeps 16 attempts x 2 bit depths of the chartered recipe | |
| 51 | +(`--enable-tx64=1 --enable-rect-partitions=1 --enable-ab-partitions=0 --enable-1to4-partitions=1 | |
| 52 | +--min-partition-size=16 --max-partition-size=64 --sb-size=64 --cpu-used=0`, each flag spelled | |
| 53 | +once, per-arm overrides last), compares EVERY decoded frame to ffmpeg on Y/U/V, counts named | |
| 54 | +refusals, and hard-asserts `oos_mismatch == 0`. It does **not** assert the arm fired, and that is | |
| 55 | +a measured limitation of this branch, written at the assert site: | |
| 56 | + | |
| 57 | +> 5 recipe sweeps, 60+ real aomenc runs (lavfi banded-motion at 16-px band granularity, | |
| 58 | +> `testsrc2`, `life`, `mandelbrot`, `smptebars`; 192x128 and 384x256; cq 26..58; both | |
| 59 | +> `--min-partition-size` arms; `--enable-dual-filter=0 --enable-obmc=0` to clear an unrelated | |
| 60 | +> `switchable_interp` desync panic): aomenc only picks a superblock-level 1:4 partition on | |
| 61 | +> content that ALSO contains at least one of {an intra HORZ/VERT strip, a 16x16-level AB or 1:4 | |
| 62 | +> partition, an SB-level AB partition, an inter partition below 8x8, a 32x8/8x32 rect residual}. | |
| 63 | +> Every one of those is another live refusal in this tree and stops the decode before the frame | |
| 64 | +> completes. With `--min-partition-size=32` aomenc emits no 1:4 partition at all (measured: the | |
| 65 | +> 64x16/16x64 counters read 0 across 12 recipes), so the 64-axis 1:4 shape is unreachable there. | |
| 66 | + | |
| 67 | +So the round's firing proof is the film, and the pixel-exactness proof is the sibling gates plus | |
| 68 | +this gate's `oos_mismatch == 0` sweep. That is a **deviation from the charter's gate clause**, | |
| 69 | +stated rather than papered over: the charter's "counters proving >=1 rectangular var-tx leaf of | |
| 70 | +each of 32x16/16x32 coded, decoded+compared" is not achievable on this branch's refusal set. | |
| 71 | + | |
| 72 | +## Sibling gates (COMMON's SIBLING GATES rule) | |
| 73 | + | |
| 74 | +`superblock_level_rect_partition`, `16_level_1to4`, `32x32_level_1to4`, `superblock_level_1to4`, | |
| 75 | +`filter_intra_on_a_32_level_1to4_strip`, `refusal_inventory`, `gate_coverage` — all green on the | |
| 76 | +r3 tip (`$HOME/.cache/r14-r3-g5.log` / `-g6.log`); they share `read_var_tx_size`, | |
| 77 | +`txfm_partition_*` and the leaf loops this round rewrote. | |
| 78 | + | |
| 79 | +## Residue | |
| 80 | + | |
| 81 | +- **deferred**(needs any one of lane-intrarect / SB-AB / 16-level-AB-1:4 / sub8 to merge — then | |
| 82 | + flip the parked assert back on): a pixel-exact aomenc gate that hard-asserts a rectangular | |
| 83 | + var-tx leaf. The assert and its restore instruction are in the gate body. | |
| 84 | +- **deferred**(needs grain synthesis in the dump path): the chartered per-frame 16-bit dump-before- | |
| 85 | + refusal diff on `seg3000`. `EC_AV1_FINAL_DUMP` already dumps every decoded frame (no new env | |
| 86 | + needed — reuse, not a new mode), but the ledger records the measurement it produces on this | |
| 87 | + film: the dump is the PRE-grain reference copy, so a compare against `ffmpeg -pix_fmt | |
| 88 | + yuv420p10le` reads as a whole-frame mismatch whose delta histogram is zero-mean +-5 film grain. | |
| 89 | + Dumping a 2 s 2160p 10-bit segment is also multi-GB. Not run. | |
| 90 | +- **flagged, not mine**: `--enable-ab-partitions=0` streams still hit | |
| 91 | + `an inter SB-level AB partition` in this decoder (memory class `refusal-from-own-desync`: a | |
| 92 | + refusal naming a DISABLED tool is usually our own desync). Seen on `mandelbrot` cq50 and on | |
| 93 | + several banded-motion recipes. Worth its own lane. | |
| 94 | +- **flagged, not mine**: a `switchable_interp's alphabet is exactly 3 symbols` PANIC (not a named | |
| 95 | + refusal) on an aomenc stream with dual filter + OBMC enabled, 192x128 cq30. Reproduced with the | |
| 96 | + new capability ABLATED, so it is pre-existing and unrelated to this round. | |
| 97 | + | |
| 98 | +## Suite | |
| 99 | + | |
| 100 | +`systemd-run --user --unit=r14-r3-suite-... -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3` | |
| 101 | +-> log `$HOME/.cache/r14-suite-r3.log`; totals appended below. | |
| 102 | + | |
| 103 | +**Suite result (r3 tip `81b6f9e`): 367 passed; 0 failed; 31 ignored, 622.33s** — up from r2's | |
| 104 | +365/0/31 by the two tests this round adds (`sub_tx_size_map_matches_libaom` and the new gate). |
lanes/r14-r4.report.mdadded+87 -0
| @@ -0,0 +1,87 @@ | ||
| 1 | +# lane-r14 round 4 — merge main, and the parked firing assert turned back on | |
| 2 | + | |
| 3 | +## 1. Merge `main` (18bf7dc) — commit `523c17d` | |
| 4 | + | |
| 5 | +`git merge --no-commit main` auto-merged with NO conflicts (diffstat: decode.rs +1117, | |
| 6 | +stream.rs +1100, mvstack.rs +114, encode.rs +47, refusal_inventory.rs, cdf.rs, cdf_state.rs, | |
| 7 | +decode_probe.rs, 9 lane reports). Checks run before committing: | |
| 8 | + | |
| 9 | +- `git diff main -- crates/ec-av1/src/cdf.rs` → **0 lines**: cdf.rs (NZ_MAP / FILTER_INTRA rows | |
| 10 | + included) is byte-identical to main on the merged tree, so no table was rebound by the merge. | |
| 11 | +- `git diff main -- crates/ec-av1/src/refusal_inventory.rs` shows only THIS lane's deletion | |
| 12 | + ("a split transform on a 1:4 inter strip with a 64-px axis"); every refusal main deleted | |
| 13 | + (lane-oddh's 128x128 line, lane-intrarect's) stays deleted. | |
| 14 | +- `grep -rn '<<<<<<<|>>>>>>>' crates/` → nothing. No hand-resolved function, so no rebound-name | |
| 15 | + re-read was needed (class merge-resolution-shadows-a-name did not apply this round). | |
| 16 | + | |
| 17 | +## 2. The firing assert is back on — and it is a hard assert | |
| 18 | + | |
| 19 | +Gate renamed | |
| 20 | +`a_real_aomenc_inter_1to4_recipe_decodes_pixel_exact_or_refuses_by_name` → | |
| 21 | +**`real_aomenc_1to4_streams_decode_pixel_exact_and_rect_vartx_leaves_fire_before_a_named_refusal`** | |
| 22 | +(`crates/ec-av1/src/stream.rs:6752`), which is what it now asserts. | |
| 23 | + | |
| 24 | +r4 recipe hunt on the merged tree, ~70 real aomenc runs (`testsrc2`, `life`, `mandelbrot`, | |
| 25 | +banded-motion lavfi with per-band and per-column speeds, 64x64 / 128x64 / 64x128 / 256x64 / | |
| 26 | +384x64 / 64x384 / 192x128 / 384x256, cq 20..58, `--min-partition-size` 16 and 32, 8- and | |
| 27 | +10-bit) found the recipe r3 could not: **384x256, per-16-column band motion**, at | |
| 28 | +`cq=38` and `cq=32`. | |
| 29 | + | |
| 30 | +EVIDENCE: `$HOME/.cache/r14-r4-gate.log` (gate run, quoted below) | `cargo test -p ec-av1 --lib -- --test-threads=1 --nocapture real_aomenc_1to4_streams` on `0b49322` | 8-bit: `attempt 17 refusal (rect var-tx leaves decoded before it: 32x16=4, 16x32=0)`, `attempt 16 ... (32x16=0, 16x32=1)`, summary `2 named refusals, leaves decoded anywhere in the sweep 32x16=4 16x32=1, 16 attempts carried none (0 of them mismatched)` — **test result: ok, 1 passed** | |
| 31 | + | |
| 32 | +What the gate asserts now: | |
| 33 | +- `oos_mismatch == 0` — every attempt that decodes to the end is compared to ffmpeg on Y/U/V, | |
| 34 | + 8- AND 10-bit, and a mismatch is a failure, never a SKIP (16/16 banded attempts per depth | |
| 35 | + decode fully and match; the recipe's `--min-partition-size` moved 32 → 16, so those 16 | |
| 36 | + attempts now also exercise the 16-level path). | |
| 37 | +- `compared + out_of_scope > 0` — the gate is not vacuous. | |
| 38 | +- **8-bit: `fired_32x16 > 0 && fired_16x32 > 0`** — both orientations of | |
| 39 | + `sub_tx_size_map[TX_64X16] == TX_32X16` / `[TX_16X64] == TX_16X32` decoded out of a real | |
| 40 | + aomenc stream. These two streams stop LATER on another lane's refusal | |
| 41 | + (`a non-skip rectangular (HORZ/VERT/HORZ_B) strip needs rectangular residual coding` at cq 32, | |
| 42 | + `an inter 16x16-level AB or 1:4 partition` at cq 38 — decode.rs:21305, genuinely unimplemented | |
| 43 | + on the inter path), so the leaves are proved **decoded**, not proved pixel-exact. The counters | |
| 44 | + are per-attempt deltas kept in a separate pair of variables from the pixel-compared ones | |
| 45 | + (class counter-from-refused-stream), and the distinction is printed and commented. | |
| 46 | +- 10-bit: the same sweep fires ZERO leaves (measured: cq 32/35/38 pick other shapes), so the | |
| 47 | + firing assert is 8-bit-only, with the measurement written at the assert. | |
| 48 | + | |
| 49 | +## 3. Suite | |
| 50 | + | |
| 51 | +`systemd-run --user --unit=r14-suite-r4-1788325638 -p MemoryMax=10G ... cargo test -p ec-av1 --lib -j3` | |
| 52 | +→ `$HOME/.cache/r14-suite-r4.log`. **Suite result (r4 tip `0b49322`): 372 passed; 0 failed; 32 ignored, 1487.04s** — GREEN. | |
| 53 | +(r3 tip was 367/0/31; +5 passed and +1 ignored come from main's three merged lanes.) | |
| 54 | + | |
| 55 | +## 4. Film probes on the merged tree — and a regression that is main's, not this lane's | |
| 56 | + | |
| 57 | +EVIDENCE: `/tmp/.../scratchpad/r14/seg{300,3000,4500}.obu` (2 s HG 2160p10 extracts, reused from r3) | `decode_probe` under `systemd-run --user --scope -p MemoryMax=6G`, `EC_AV1_FINAL_DUMP` file count = frames completed | merged tree `0b49322`: | |
| 58 | + | |
| 59 | +| segment | stop string | frames completed | | |
| 60 | +|---|---|---| | |
| 61 | +| `-ss 300` | `a split intra strip whose transform unit is 32x64 (no luma coefficient tables for that shape here)` | 1 | | |
| 62 | +| `-ss 3000` | same | 1 | | |
| 63 | +| `-ss 4500` | `an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path` | 1 | | |
| 64 | + | |
| 65 | +That is **shallower than the r3 tip**, where `seg4500` decoded 14 rectangular var-tx leaves and | |
| 66 | +16 `16x64` strips before stopping. Attribution measured, not guessed: | |
| 67 | + | |
| 68 | +EVIDENCE: same three segments | `decode_probe` built from a detached worktree at **main 18bf7dc** (`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-r14-main`, worktree + target dir removed after) | main alone gives the IDENTICAL stop strings and `frames=1` on all three | |
| 69 | + | |
| 70 | +So the films now stop in decode-order frame 2 on lane-intrarect's two NARROWER successor | |
| 71 | +refusals; the merge with lane-r14 changes nothing about it. **flagged, not mine**: main | |
| 72 | +18bf7dc is a film-depth regression against this lane's r3 tip — a broad refusal was replaced | |
| 73 | +by narrower ones that fire EARLIER in the stream (or our decode desyncs into them; class | |
| 74 | +refusal-from-own-desync is untested here). Owner: lane-intrarect / a fresh lane. | |
| 75 | + | |
| 76 | +## Residue | |
| 77 | + | |
| 78 | +- deferred(needs the 16x16-level inter 1:4 lane, or the non-skip HORZ_B rect residual lane) — | |
| 79 | + a PIXEL-EXACT aomenc stream carrying a rectangular var-tx leaf. Both firing streams are one | |
| 80 | + refusal short of running to the end; the assert to strengthen is the `if bit_depth == 8` block. | |
| 81 | +- deferred(needs an aomenc recipe that fires the arm at 10 bits) — the 10-bit firing assert. | |
| 82 | + Measured absent over the 18-attempt sweep at cq 32/35/38. | |
| 83 | +- flagged, not mine — the film-depth regression above. | |
| 84 | +- accepted — `--enable-ab-partitions=0` streams still reach `an inter SB-level AB partition` | |
| 85 | + and `--min-partition-size=16` streams reach `an inter partition below 8x8` (both re-observed | |
| 86 | + this round, r3 flagged them first): a refusal naming a disabled tool is usually our own | |
| 87 | + desync, and deserves its own lane. |
lanes/rectchroma2-r1.report.mdadded+87 -0
| @@ -0,0 +1,87 @@ | ||
| 1 | +# lane-rectchroma2 r1 -- rect INTER blocks predicted chroma with the WIDE kernel | |
| 2 | + | |
| 3 | +## Premise re-measured first | |
| 4 | + | |
| 5 | +lane-interedge r1's residue reproduced on this tree (main 2c04819 + lane-cdef + lane-golomb | |
| 6 | +173b793): mandelbrot 192x128 (the CONTROL size -- zero frame-edge nodes), 6 frames, | |
| 7 | +`--enable-rect-partitions=1 --min-partition-size=8 --enable-tx-size-search=0 --lag-in-frames=0`, | |
| 8 | +intra tools off, cq 20/32/45, 8- and 10-bit: **luma exact, chroma differs on frames 2..5 in all | |
| 9 | +six arms**. Streams hashed twice, identical. | |
| 10 | + | |
| 11 | +EVIDENCE: `~/.cache/rectchroma2-tmp/c192-128-{8,10}-{20,32,45}.obu` (each sha256 twice, equal) | |
| 12 | +| `decode_probe` with `EC_AV1_FINAL_DUMP` vs `ffmpeg -pix_fmt yuv420p[10le]`, every decode-order | |
| 13 | +frame, per plane | e.g. cq32 8-bit: `[(2,'chroma (0,32)..(1,40) n=17'), (4,...), (5,...)]`, luma | |
| 14 | +exact in all 6 arms. | |
| 15 | + | |
| 16 | +## Stage bisect | |
| 17 | + | |
| 18 | +Regenerated the same recipe with `--loopfilter-control=0` (deblock off; CDEF/LR already off in | |
| 19 | +that recipe): **the chroma mismatch survives unchanged** -> not a filter-stage defect, so the | |
| 20 | +charter's suspect (d) (chroma deblock levels / uv tx grid for rect inter blocks) is exonerated. | |
| 21 | +The surviving diffs are +-1 on scattered samples inside 4-wide-by-8-tall and 8-wide-by-4-tall | |
| 22 | +CHROMA regions (e.g. frame 4: chroma x32..35 rows 26..39, and x48..55 rows 16..19) -- i.e. the | |
| 23 | +chroma halves of 8x16 and 16x8 LUMA blocks. | |
| 24 | + | |
| 25 | +EVIDENCE: `~/.cache/rectchroma2-tmp/n192-128-8-32.obu` (`gen_nolf.sh`) | decode + full-plane | |
| 26 | +compare | `MISMATCH [(2,'chroma ... n=15'), (4,...n=36), (5,...n=45)]`, luma exact. | |
| 27 | + | |
| 28 | +## Root cause (charter suspect (a), confirmed) | |
| 29 | + | |
| 30 | +`crates/ec-av1/src/decode.rs` `decode_inter_block` predicts a RECTANGULAR block over its | |
| 31 | +enclosing SQUARE buffer (`side`x`side`, chroma `chroma_side`x`chroma_side`; `write_w`/`write_h` | |
| 32 | +govern only the pixel write -- the lane-partitions r1 corner-cut). The 4-tap decision lived | |
| 33 | +inside `mc::predict_with_filters` and read that BUFFER's dimensions. libaom | |
| 34 | +`av1_get_interp_filter_params_with_block_size` (reconinter.h, called per axis from | |
| 35 | +`inter_predictor` with `w` then `h`) reads the PREDICTION BLOCK's dimensions: `w <= 4` -> | |
| 36 | +`av1_interp_4tap[0]` (SHARP and REGULAR both) / `[1]` (SMOOTH). Luma is never <= 4 wide on this | |
| 37 | +path, so only chroma of a rect block (4x8 / 8x4 / 4x16 ...) was affected -- exactly the | |
| 38 | +"luma exact, chroma wrong" signature. | |
| 39 | + | |
| 40 | +- `crates/ec-av1/src/mc.rs`: `predict_with_filters_kern` / `predict_scaled_kern` / | |
| 41 | + `predict_compound_intermediate_kern` -- the existing three entry points keep their signatures | |
| 42 | + and delegate with `kern = block dims`; `horizontal_scaled_pass` takes `kern_w`. | |
| 43 | +- `crates/ec-av1/src/mc.rs`: `RECT_NARROW_KERN_HITS` + `rect_narrow_kern_hits()` / | |
| 44 | + `reset_rect_narrow_kern_hits()` / `note_narrow_kern()` -- counts predictions whose kernel | |
| 45 | + choice DIFFERS from what the square buffer would have given (one bump per prediction). | |
| 46 | +- `crates/ec-av1/src/decode.rs`: the 12 prediction calls inside `decode_inter_block` now pass | |
| 47 | + `write_w/write_h` (luma) and `write_chroma_w/write_chroma_h` (chroma) as the kernel dims. | |
| 48 | + | |
| 49 | +Class sweep: every other `mc::predict*` call site passes a buffer whose dims ARE the block's | |
| 50 | +(`obmc_neighbour_pred` takes the neighbour's true w/h; the 8x8 leaf path is square, chroma 4x4; | |
| 51 | +the CfL bilinear path is unrelated), so no sibling site needed the change. | |
| 52 | + | |
| 53 | +## Gate (GREEN) | |
| 54 | + | |
| 55 | +``` | |
| 56 | +CARGO_TARGET_DIR=$HOME/.cache/cargo-target-rectchroma2 EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 \ | |
| 57 | +PATH="$HOME/.cache/aom-oracle/build:$PATH" cargo test -p ec-av1 --lib narrow_kernel -- --nocapture | |
| 58 | +``` | |
| 59 | +`a_real_aomenc_rect_inter_block_predicts_chroma_with_the_narrow_kernel_pixel_exact` | |
| 60 | +(`crates/ec-av1/src/stream.rs`): real aomenc, mandelbrot 192x128 AND its transposed twin | |
| 61 | +128x192 (so 4x8 and 8x4 chroma both fire), 8- and 10-bit, cq 20/32/45, 6 frames, | |
| 62 | +`--lag-in-frames=0` so decode order == display order and EVERY frame is compared on Y, U AND V | |
| 63 | +against ffmpeg. CDEF and loop restoration left ON. Streams encoded twice and asserted equal. | |
| 64 | +`compared == 12` is a hard assert (a refusal fails the gate, never SKIPs), and the narrow-kernel | |
| 65 | +counter -- reset per attempt, read only on compared attempts -- must be nonzero at BOTH depths | |
| 66 | +and in BOTH orientations. | |
| 67 | + | |
| 68 | +EVIDENCE: gate stdout | 12 aomenc -> ec-av1 -> ffmpeg attempts, 6 frames each, all three planes | |
| 69 | +| `12/12 arms 6 frames full-plane exact; narrow-kernel hits 24/4/16 (192x128 8-bit cq20/32/45), | |
| 70 | +18/26/36 (10-bit), 42/20/18 and 36/36/34 for 128x192` -- 0 refusals, 0 out-of-scope mismatches. | |
| 71 | + | |
| 72 | +Before the fix the SAME recipe mismatched chroma in every arm (the premise sweep above), so the | |
| 73 | +gate is not vacuous. | |
| 74 | + | |
| 75 | +## Refusals | |
| 76 | +None lifted (no inventory string covers this defect -- it was a wrong-pixels defect behind an | |
| 77 | +already-accepted path). `refusal_inventory.rs`/`gate_coverage.rs` untouched by intent, both green | |
| 78 | +in the suite below. | |
| 79 | + | |
| 80 | +## Suite | |
| 81 | +`$HOME/.cache/rectchroma2-suite-r1.log`: **388 passed, 0 failed, 35 ignored** (1668s), including the new gate. Baseline before this round on the same tree shape was 387/0/35 (this round adds one gate). | |
| 82 | + | |
| 83 | +## Residue | |
| 84 | +- accepted: `predict_scaled_kern` (scaled reference / superres) got the same fix by construction | |
| 85 | + but is not exercised by this gate -- superres rect-chroma has no aomenc recipe on this lane. | |
| 86 | +- deferred(lane-interedge merge): that lane's frame-edge gate can now become a FULL-PLANE arm; | |
| 87 | + its luma-only compare was a workaround for exactly this defect. |
lanes/sbrect10-r1.handoff.mdadded+81 -0
| @@ -0,0 +1,81 @@ | ||
| 1 | +# lane-sbrect10 r1 handoff (turn cap) | |
| 2 | + | |
| 3 | +Branch `lane-sbrect10` (worktree `/home/user/Documents/Code/Rust/edith_codecs-sbrect10`), | |
| 4 | +based on lane-r14 a2e2e29 with `main` (7a47fc1) merged in cleanly (merge commit in history). | |
| 5 | + | |
| 6 | +## STATUS: root cause FOUND and FIXED; sibling gate GREEN both depths; the new dedicated gate | |
| 7 | +## still needs an 8-bit fixture (its 8-bit arm currently FAILS "gate proved nothing"). | |
| 8 | + | |
| 9 | +## Pinned stream | |
| 10 | +`$HOME/.cache/sbrect10/a14.obu`, sha256 (hashed twice, identical) | |
| 11 | +`e85d3b84180de05cd7af769daa7b4f0662389fe0cbf5f0dc8119e4a036b6cf44`. | |
| 12 | +Regenerate: `bash $HOME/.cache/sbrect10/gen.sh <out>` (192x128, 6 frames, cq 61, 10-bit, | |
| 13 | +horizontal split geq, motion step 12 = the sibling gate's 10-bit attempt 14). | |
| 14 | + | |
| 15 | +## First mismatch (before the fix) | |
| 16 | +decode-order frame 2 (display == decode order, `--lag-in-frames=0`), plane Y, 15973/24576 luma | |
| 17 | +samples + 874 V; frames 0 and 1 exact. Per-64x64-SB wrong-pixel map row0 = [128, 332, 3931], | |
| 18 | +row1 = [3912, 3728, 3942]; SB(0,0)'s 128 are rows 62-63 only (deblock bleed from below). | |
| 19 | + | |
| 20 | +## Range ladder (EC_TRACE_MODE / EC_TRACE_MODE_STEP / EC_TRACE_COEFF / EC_AV1_TELL vs | |
| 21 | +## instrumented aomdec `~/.cache/aom-oracle/build/aomdec`) | |
| 22 | +- Partition symbols: 40/40 identical (values + positions) -> no rect strips anywhere, every | |
| 23 | + inter SB is PARTITION_NONE 64x64. Confirms the sibling gate's "zero rect strips" note. | |
| 24 | +- Our `TELL label=post_interp_filter range=` equals aomdec's `EC_MODE_VAL ... rng=` for every | |
| 25 | + inter block up to the divergence (frame 2 block mi(0,16): both 61730). Mode info in sync. | |
| 26 | +- First diverging element: frame 2, block mi_row=0 mi_col=32 (SB(0,2), x=128..191), which BOTH | |
| 27 | + decoders read as INTRA inside an inter frame (`is_inter=false`, our TELL post_is_inter | |
| 28 | + range=42400). aomdec then reads its luma TU with entry rng=38192 and all_zero=1; ours reached | |
| 29 | + all_zero=0 at rng=63221 with eob=56 -> desync inside that block's intra mode syntax. | |
| 30 | +- Root cause: `uv_mode` was read off the 14-symbol CFL-allowed CDF (`cdfs.uv_mode_cfl`) on a | |
| 31 | + 64x64 block. libaom `is_cfl_allowed` (blockd.h, spec 5.11.5) = `block_size_wide <= 32 && | |
| 32 | + block_size_high <= 32`, so the real alphabet is the 13-symbol `uv_mode_no_cfl`. Same DC_PRED | |
| 33 | + VALUE, wrong interval narrowing -> silent desync (class `wrong-alphabet-same-value`, second | |
| 34 | + instance after lane-sbpart r3). | |
| 35 | + | |
| 36 | +## Fix (committed) | |
| 37 | +- `crates/ec-av1/src/decode.rs` intra-in-inter block path: `cfl_allowed = write_w.max(write_h) | |
| 38 | + <= 32`, picks `uv_mode_no_cfl`, and gates the `cfl_alphas` read. | |
| 39 | +- Same rule enforced ONCE at the head of `read_intra_mode_rect` and `read_intra_mode` | |
| 40 | + (`let cfl = cfl && bw.max(bh) <= 32` / `side <= 32`), so no caller can offer CFL above 32. | |
| 41 | +- New counter `NOCFL_UV_MODE_HITS` / `decode::nocfl_uv_mode_hits()` fires exactly when the | |
| 42 | + size rule removed CFL. | |
| 43 | +- Result on the pinned stream: all 6 frames byte-identical to `ffmpeg -pix_fmt yuv420p10le` | |
| 44 | + (was [0,0,16847,23688,19028,17491] wrong samples). | |
| 45 | + | |
| 46 | +## Gates | |
| 47 | +- `a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact` | |
| 48 | + flipped to `[8u32, 10u32]` and is GREEN: 8-bit 2 refusals / 4 pixel-exact carrying the arm / | |
| 49 | + 64x32=4 / 32x64=4 / 64-axis TUs=2 / 10 out-of-scope with 0 mismatches; 10-bit 2 refusals / | |
| 50 | + 2 carrying / 64x32=2 / 32x64=2 / 64-axis TUs=2 / 12 out-of-scope with 0 mismatches. | |
| 51 | +- NEW dedicated gate `a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet` | |
| 52 | + (stream.rs, just above the lane-inter4 32x32 rect gate): 16-attempt grid, both depths, every | |
| 53 | + decode-order frame compared, asserts `nocfl_uv_mode_hits` moved. 10-bit arm passes; the | |
| 54 | + **8-bit arm FAILS** ("no attempt decoded an intra block above 32x32") -- with the smooth | |
| 55 | + translating source aomenc never picks a >32 intra block in an inter frame at 8 bit | |
| 56 | + (probed cq 45/52/58/61/63, with and without `noise=all_seed=7:alls=30`: 0 hits every time). | |
| 57 | + | |
| 58 | +## Exact next step (measured, ready to paste) | |
| 59 | +Replace the gate's source with the half-random fixture, which DOES produce the shape at 8 bit: | |
| 60 | +`geq=lum='if(lt(X,128), 40+mod(floor((Y+N*12)/32)*90,200), mod((X*7+Y*13+N*97)*31,256))'` | |
| 61 | +Probe results (`$HOME/.cache/sbrect10/probe.sh <geq> <cq> <depth> <extra>`, counts >32 | |
| 62 | +intra-in-inter blocks and pixel diffs vs ffmpeg): | |
| 63 | + 8-bit cq52: 4 hits but DECODE-ERR (named refusal) | cq58: 2 hits, 0 pixel diffs | | |
| 64 | + cq61: 3 hits, 0 pixel diffs | |
| 65 | + 10-bit cq52: 6 hits, 0 diffs | cq58: 7 hits, **32890 diffs** | cq61: 7 hits, **39907 diffs** | |
| 66 | +So: use cq 58/61 for the 8-bit arm, cq 52 for the 10-bit arm, OR (better) treat the 10-bit | |
| 67 | +cq58/cq61 half-random mismatch as the NEXT defect of this lane -- it is a real, reproducible | |
| 68 | +10-bit failure on a stream this decoder does not refuse, and it is NOT the CFL bug (that one is | |
| 69 | +fixed). Triage it with the same ladder (EC_AV1_TELL post_interp_filter vs aomdec EC_MODE_VAL, | |
| 70 | +then EC_TRACE_COEFF entry ranges). | |
| 71 | +Then: full suite via | |
| 72 | +`systemd-run --user --unit=sbrect10-suite-$(date +%s) -p MemoryMax=10G --same-dir bash -lc 'EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1 CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sbrect10 nice -n 10 cargo test -p ec-av1 --lib -j3 > $HOME/.cache/sbrect10-suite-r1.log 2>&1'` | |
| 73 | +(NOT run yet this round), then `lanes/sbrect10-r1.report.md`. | |
| 74 | + | |
| 75 | +## Ruled out | |
| 76 | +- Rect partitions / 64-axis residual: zero of both in the failing stream (partition trace 40/40 | |
| 77 | + identical), so the sibling gate's "another shape" note was correct. | |
| 78 | +- MV stack, motion_mode alphabet, interp filter, interintra: all exonerated by the | |
| 79 | + post_motion_mode / post_interp_filter range equality with aomdec on every block up to the | |
| 80 | + diverging one. | |
| 81 | +- Encoder-recipe doubt: stream hashes identical across two generations. |
lanes/sbrect10-r2.handoff.mdadded+175 -0
| @@ -0,0 +1,175 @@ | ||
| 1 | +# lane-sbrect10 r2 handoff | |
| 2 | + | |
| 3 | +Branch `lane-sbrect10`, tip `2b9709c` (worktree | |
| 4 | +`/home/user/Documents/Code/Rust/edith_codecs-sbrect10`). | |
| 5 | +Commits this round: `3a9e83e` (merge main 18bf7dc) + `2b9709c` (the fix + gate + instrumentation). | |
| 6 | + | |
| 7 | +## STATUS: root cause FOUND and FIXED; pinned stream now byte-exact on all 6 probe arms. | |
| 8 | +## Only thing outstanding: the full suite result (armed, was at 340 tests / 0 failures). | |
| 9 | + | |
| 10 | +## 1. Merge state (done, clean) | |
| 11 | +`git merge --no-commit main` (main = 18bf7dc: r14 a2e2e29 + sb128 5ea5ec8) auto-merged | |
| 12 | +decode.rs + stream.rs with no conflicts. Verified before committing: | |
| 13 | +- `git diff main -- crates/ec-av1/src/cdf.rs` EMPTY and `... refusal_inventory.rs` EMPTY, so the | |
| 14 | + NZ_MAP / FILTER_INTRA rows and the refusal list are byte-identical to main. | |
| 15 | +- The only lines the merged tree removes vs main are the lane's own r1 hunks (4 `uv_mode_cfl` | |
| 16 | + lines in decode.rs, the `[8u32]` arm + its comment in stream.rs). Main's deletions all kept. | |
| 17 | + | |
| 18 | +## 2. Gate fixture state (done) | |
| 19 | +`a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet` (stream.rs) | |
| 20 | +now uses the half-random source in BOTH orientations: | |
| 21 | + | |
| 22 | + horizontal: if(lt(X,128), 40+mod(floor((Y+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256)) | |
| 23 | + vertical: if(lt(Y,64), 40+mod(floor((X+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256)) | |
| 24 | + | |
| 25 | +r1's flat `200` half made aomenc code the right-hand superblocks skip, so the 8-bit arm saw 0 | |
| 26 | +intra-above-32x32 blocks (probed cq 45/52/58/61/63). Grid `[58, 52, 45, 61]` x 2 orientations x | |
| 27 | +2 motion steps x 2 depths unchanged; counters are read on decoded+compared attempts only, every | |
| 28 | +decode-order frame is compared on Y/U/V, a mismatch fails and never SKIPs. | |
| 29 | + | |
| 30 | +## 3. The 10-bit defect: root cause, libaom line, fix | |
| 31 | +Pinned stream `$HOME/.cache/sbrect10/b58.obu`, sha256 hashed TWICE identical | |
| 32 | +`00b9253b308201118e27f348c67932a0006e3077ba7a9a401854c2ee7eb1dcd2` | |
| 33 | +(192x128, 6 frames, 10-bit cq58, `--sb-size=64 --min-partition-size=32 --max-partition-size=64 | |
| 34 | +--enable-rect-partitions=1 --enable-1to4-partitions=1 --lag-in-frames=0 --cpu-used=0`; | |
| 35 | +regenerate with `bash $HOME/.cache/sbrect10/probe.sh "<geq>" 58 10`). | |
| 36 | + | |
| 37 | +How it was localised (each step ruled a layer out): | |
| 38 | +- First mismatch DECODE-ORDER frame 2, plane Y only (U/V exact), 8252 samples; per-64x64-SB map | |
| 39 | + row0 `[0,0,4092]`, row1 `[0,64,4096]` = the whole RIGHT superblock column + deblock bleed. | |
| 40 | +- NOT an entropy desync: our `EC_TRACE_COEFF` all_zero ladder vs instrumented aomdec's is | |
| 41 | + identical for all 180 TUs of the whole stream (`diff` empty), and blocks decoded AFTER the | |
| 42 | + wrong ones (mi(16,0)) are pixel-exact. | |
| 43 | +- NOT a clamp: an `EC_DBG_CLAMP` probe on the dequant clamp `+-(1 << (7 + bd))` and on every | |
| 44 | + `clamp_range` in transform.rs fired ZERO times on this stream. | |
| 45 | +- `EC_TRACE_MODE` mv diff, decode-order frame 2: aomdec mi(0,32) mode=24 ref0=1 ref1=4 | |
| 46 | + mv0=(128,-16) / ours (-1,2); mi(0,40), mi(8,32), mi(8,40), mi(16,40) all (128,-16) vs (-1,2); | |
| 47 | + mi(16,32) (-176,256) vs (-241,264); mi(24,32) (-128,56) vs (-193,64). The | |
| 48 | + NEAREST_NEARESTMV blocks take stack[0] directly, so libaom's stack[0].this_mv is (128,-16) | |
| 49 | + where ours is (0,0), and the NEWMV blocks are off by the same predictor delta. | |
| 50 | +- Our stack for mi(0,32) = two entries `this=(0,0) comp=(0,0) w=2` -- the signature of the | |
| 51 | + compound EXTENSION pass appending comp_list[0] and comp_list[1] into an empty stack. | |
| 52 | +- Frame 2's temporal field really is empty and that is CORRECT (new `EC_TPL_FIELD` occupancy | |
| 53 | + dump under EC_TRACE_TPL: oh=1,2 all `.`, oh=3,4,5 all `#`; frame 2's LAST projection is | |
| 54 | + suppressed by `is_lst_overlay` and its LAST2 is the key frame). So the candidate is spatial. | |
| 55 | + | |
| 56 | +ROOT CAUSE: `combine_compound_candidates` (crates/ec-av1/src/mvstack.rs:1482) filled the | |
| 57 | +`comp_list` tail slots -- the ones left after `ref_id` then `ref_diff` -- with `(0, 0)`. | |
| 58 | +libaom fills them with that side's GLOBAL MOTION vector, `setup_ref_mv_list`, | |
| 59 | +`av1/common/mvref_common.c:729`: | |
| 60 | + | |
| 61 | + for (; comp_idx < MAX_MV_REF_CANDIDATES; ++comp_idx) | |
| 62 | + comp_list[comp_idx][idx] = gm_mv_candidates[idx]; | |
| 63 | + | |
| 64 | +Zero-filling was right only under IDENTITY global motion (the module doc's original reduction); | |
| 65 | +aomenc has `--enable-global-motion` ON by default. A compound block with no usable neighbour | |
| 66 | +pair (frame top row -> no above, 64x64 INTRA block to its left, empty temporal field) therefore | |
| 67 | +took a `(0,0)` predictor where libaom took the frame's translation. | |
| 68 | + | |
| 69 | +FIX: `combine_compound_candidates` takes `gm_mv_candidates: [(i32,i32); 2]` and uses it as the | |
| 70 | +per-side fill; the call site passes `[gm_mv(gm, ref_frame.0), gm_mv(gm, ref_frame.1)]`. | |
| 71 | + | |
| 72 | +SIBLING SWEEP (same shape): every `gm_mv_candidates` use in mvref_common.c was walked. The | |
| 73 | +single-ref tail fill (`:787-788`) is already ported as `gm_fallback` at mvstack.rs:1099-1100; | |
| 74 | +the `is_gm_block` substitutions (`:92`, `:117`) already take `gm` through `scan_*_compound`; the | |
| 75 | +add_tpl_ref_mv GLOBALMV_OFFSET compares (`:379-410`) already use `gm_mv(gm, ...)` on both sides. | |
| 76 | +This was the only zero-filled site in the crate. | |
| 77 | + | |
| 78 | +## 4. Is the pinned stream exact now? YES | |
| 79 | +`probe.sh "<half-random geq>" <cq> <depth>` after the fix, pixel diffs vs | |
| 80 | +`ffmpeg -pix_fmt yuv420p10le` / `yuv420p`, and `>32` intra-in-inter hit counts: | |
| 81 | + | |
| 82 | +| depth | cq 52 | cq 58 | cq 61 | | |
| 83 | +|---|---|---|---| | |
| 84 | +| 8-bit | 5 hits, 0 diffs | 2 hits, 0 diffs | 3 hits, 0 diffs | | |
| 85 | +| 10-bit | 6 hits, 0 diffs | 7 hits, 0 diffs | 7 hits, 0 diffs | | |
| 86 | + | |
| 87 | +Before the fix the 10-bit arms were 32890 (cq58) and 39907 (cq61) wrong samples. | |
| 88 | + | |
| 89 | +## 5. NEXT STEP (the only thing left) | |
| 90 | +Read `$HOME/.cache/sbrect10-suite-r2.log` -- the suite is armed as a user systemd unit | |
| 91 | +(`sbrect10-suite-r2-1788325070.service`, MemoryMax=10G, `cargo test -p ec-av1 --lib -j3`, | |
| 92 | +EC_AV1_REQUIRE_AOMENC=1, CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sbrect10). At handoff it had | |
| 93 | +reached 340 tests with no FAILED line. Check with a single | |
| 94 | +`grep -E "^test result|FAILED" $HOME/.cache/sbrect10-suite-r2.log`; if a gate is red, re-run that | |
| 95 | +gate alone before touching code (another lane rebuilding the shared aomdec shows up as | |
| 96 | +"Os code 13 PermissionDenied"). Then fill the N/0 totals into `lanes/sbrect10-r2.report.md` | |
| 97 | +(section 4 is otherwise complete) and the lane is done. | |
| 98 | + | |
| 99 | +Nothing else is in flight; the worktree is clean at 2b9709c. | |
| 100 | + | |
| 101 | +## 5b. CORRECTION at handoff time -- THE SUITE IS RED (3 gates), details not yet printed | |
| 102 | +The suite unit was still running when this handoff was written; at 343 tests it had THREE | |
| 103 | +FAILED lines (cargo buffers the panic bodies to the end of the run, so no message text yet): | |
| 104 | + | |
| 105 | + stream::tests::a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet ... FAILED | |
| 106 | + stream::tests::a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact ... FAILED | |
| 107 | + stream::tests::a_real_aomenc_stream_with_film_grain_decodes_pixel_exact ... FAILED | |
| 108 | + | |
| 109 | +So the lane is RED, not green. Do NOT treat section 4's probe table as a suite result: it proves | |
| 110 | +only the 6 probed (geq, cq, depth) points, not the gates' own 16-attempt grids. | |
| 111 | + | |
| 112 | +Triage order for the next round: | |
| 113 | +1. `grep -A 30 "^failures:" $HOME/.cache/sbrect10-suite-r2.log` for the three panic bodies. | |
| 114 | +2. `a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` is the loudest signal: it touches | |
| 115 | + NEITHER the CFL alphabet nor the compound stack's fixture, so if it is a pixel mismatch it is | |
| 116 | + most likely a REGRESSION from this round's `combine_compound_candidates` gm-fill (a compound | |
| 117 | + block that previously got (0,0) and now gets a global-motion vector). Check it first, alone: | |
| 118 | + `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sbrect10 cargo test -p ec-av1 --lib | |
| 119 | + a_real_aomenc_stream_with_film_grain_decodes_pixel_exact -- --nocapture` | |
| 120 | + and if it is red, re-run it at `3a9e83e` (the merge commit, fix not yet in) in a DETACHED | |
| 121 | + worktree to separate "regression from the gm-fill" from "already red after the merge". | |
| 122 | + Note the merge itself was never suite-tested -- r1 never ran a suite either (its handoff says | |
| 123 | + so), so an inherited red from main's sb128/r14 merge is equally possible. | |
| 124 | +3. The other two are this lane's own gates; the rect-partition sibling gate shares the compound | |
| 125 | + stack path, so it is the expected place for a gm-fill regression to show. | |
| 126 | +4. Only after the three are green: fill the N/0 totals into `lanes/sbrect10-r2.report.md`. | |
| 127 | + | |
| 128 | +## 5c. SUITE FINISHED -- final result and per-failure triage (supersedes 5b) | |
| 129 | +`test result: FAILED. 368 passed; 3 failed; 32 ignored; finished in 1049.95s` | |
| 130 | +(`$HOME/.cache/sbrect10-suite-r2.log`). | |
| 131 | + | |
| 132 | +### (a) `a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` -- FLAKE, not a defect. CLOSED. | |
| 133 | +Panic was `Result::unwrap()` on `Err(Os { code: 2, NotFound })` at stream.rs:15680, i.e. the | |
| 134 | +`concat!(CARGO_MANIFEST_DIR, "/../../fixtures/golden6-mismatch.obu")` READ failed -- the shared | |
| 135 | +`fixtures` symlink (`-> /home/user/Documents/Code/Rust/edith_codecs/fixtures`) was transiently | |
| 136 | +gone mid-run, the known concurrent-lane merge hazard. The file is present now and the gate passes | |
| 137 | +on its own: | |
| 138 | +`cargo test -p ec-av1 --lib a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` | |
| 139 | +-> `test result: ok. 1 passed; 0 failed`. Nothing to fix here; it is NOT a gm-fill regression. | |
| 140 | + | |
| 141 | +### (b) `a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet` -- REAL, MINE, OPEN. | |
| 142 | + 8-bit: 2 named refusals, 0 pixel-exact attempts carrying a >32 intra block | |
| 143 | + (0 no-CFL uv_mode reads), 14 attempts carried none | |
| 144 | + (the two refusals are "an inter SB-level AB partition" and "a split intra strip whose | |
| 145 | + transform unit is 32x64" -- both other lanes' gaps, correctly named, not mismatches) | |
| 146 | +10-bit arm passes. **My step-2 claim that the half-random fixture makes the 8-bit arm carry the | |
| 147 | +shape is DISPROVEN by the gate itself.** The probe (`probe.sh`) counted a DIFFERENT quantity than | |
| 148 | +the gate: it greps `EC_AV1_TELL` for `post_is_inter is_inter=false` with `side>32`, whereas the | |
| 149 | +gate asserts `crate::decode::nocfl_uv_mode_hits()` moved. On the very same stream (8-bit cq58, | |
| 150 | +horizontal, sp=12 == gate attempt 8) the probe reports 2 and the counter reports 0, so those | |
| 151 | +8-bit >32 intra-in-inter blocks reach a decode path that never touches the counter. | |
| 152 | +NEXT: the three `NOCFL_UV_MODE_HITS` increment sites are `decode.rs:5499`, `decode.rs:8442`, | |
| 153 | +`decode.rs:18544`; instrument which intra-in-inter path an 8-bit 64x64 block actually takes | |
| 154 | +(the 10-bit ones clearly hit one of the three), then either fix the missing counter site or, if | |
| 155 | +the 8-bit path genuinely never offers CFL, narrow the gate's 8-bit assertion and say so. | |
| 156 | +No pixel mismatch is involved -- every decoded attempt compared exact. | |
| 157 | + | |
| 158 | +### (c) `a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact` -- REAL, OPEN, UNATTRIBUTED. | |
| 159 | + 8-bit: 4 named refusals, 3 carrying, 64x32=8, 32x64=2, 64-axis residual TUs=1, 9 none (0 mismatched) | |
| 160 | + 10-bit: 0 named refusals, 1 carrying, 64x32=2, 32x64=0, 64-axis residual TUs=0, 15 none (0 mismatched) | |
| 161 | + panic at stream.rs:6725: "(10-bit): no superblock-level rect strip carried a coded 64-axis | |
| 162 | + residual transform unit inside a pixel-exact attempt (horz=2, vert=0)" | |
| 163 | +This is a VACUOUS-ARM assert, NOT a pixel mismatch (`0 of them mismatched` on both depths). r1 | |
| 164 | +recorded this same gate GREEN with 10-bit `64-axis TUs=2` and `2 carrying`; it is now `0` and `1`. | |
| 165 | +Two candidate causes, NOT separated this round: (i) the `main` 18bf7dc merge (sb128 + r14 changed | |
| 166 | +partition/var-tx handling and neither r1 nor this lane ever suite-tested the merge), or (ii) this | |
| 167 | +round's gm-fill changing which attempts come out pixel-exact (only pixel-exact attempts count | |
| 168 | +toward the arm). Separate them by running this gate alone at `3a9e83e` (merge, pre-fix) in a | |
| 169 | +DETACHED worktree with its own CARGO_TARGET_DIR, then at `2b9709c`. | |
| 170 | + | |
| 171 | +### Corrected disposition | |
| 172 | +- fix-now next round: (b) the 8-bit no-CFL counter, (c) the 10-bit 64-axis vacuous arm. | |
| 173 | +- accepted/closed: (a) film_grain fixture flake. | |
| 174 | +- The gm-fill fix itself is NOT contradicted by anything in this suite: no gate reported a pixel | |
| 175 | + mismatch, and the pinned stream `b58.obu` plus all 6 probe arms are byte-exact vs ffmpeg. |
lanes/sbrect10-r2.report.mdadded+124 -0
| @@ -0,0 +1,124 @@ | ||
| 1 | +# lane-sbrect10 r2 report | |
| 2 | + | |
| 3 | +Branch `lane-sbrect10`, worktree `/home/user/Documents/Code/Rust/edith_codecs-sbrect10`. | |
| 4 | +Base: r1 tip 6fba6a6 + `main` 18bf7dc (sb128 5ea5ec8 + r14 a2e2e29) merged. | |
| 5 | + | |
| 6 | +## 1. Merge (step 1) | |
| 7 | +`git merge --no-commit main` -> clean auto-merge (decode.rs, stream.rs), commit `3a9e83e`. | |
| 8 | +- Diffstat 12 files, +1392/-147 (all of it main's; the lane contributed nothing to those files | |
| 9 | + beyond its own r1 hunks). | |
| 10 | +- `git diff main -- crates/ec-av1/src/cdf.rs` and `... refusal_inventory.rs` are BOTH EMPTY, so | |
| 11 | + the NZ_MAP / FILTER_INTRA tables and the refusal list are byte-identical to main -- nothing to | |
| 12 | + reconcile. | |
| 13 | +- The only lines the merged tree removes relative to main are the lane's own 4 r1 CFL lines in | |
| 14 | + `decode.rs` (`cdfs.uv_mode_cfl[mode]` + its `cfl_alphas` arm) and the r1 comment/`[8u32]` arm in | |
| 15 | + `stream.rs`. Main's deletions are all kept. | |
| 16 | + | |
| 17 | +## 2. Gate source swapped to the half-random fixture (step 2) | |
| 18 | +`crates/ec-av1/src/stream.rs` (gate | |
| 19 | +`a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet`): the flat | |
| 20 | +`200` half of r1's source made aomenc code the right-hand superblocks skip, so at 8 bit no | |
| 21 | +`>32` intra-in-inter block ever appeared. Both orientations now carry a deterministic | |
| 22 | +pseudo-noise half: | |
| 23 | + | |
| 24 | + horizontal: if(lt(X,128), 40+mod(floor((Y+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256)) | |
| 25 | + vertical: if(lt(Y,64), 40+mod(floor((X+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256)) | |
| 26 | + | |
| 27 | +Probe grid, `$HOME/.cache/sbrect10/probe.sh` (counts `>32` intra-in-inter blocks via | |
| 28 | +`EC_AV1_TELL`, and pixel diffs vs `ffmpeg -pix_fmt yuv420p10le`/`yuv420p`), AFTER the r2 fix: | |
| 29 | + | |
| 30 | +| depth | cq 52 | cq 58 | cq 61 | | |
| 31 | +|---|---|---|---| | |
| 32 | +| 8-bit | 5 hits, 0 diffs | 2 hits, 0 diffs | 3 hits, 0 diffs | | |
| 33 | +| 10-bit | 6 hits, 0 diffs | 7 hits, 0 diffs | 7 hits, 0 diffs | | |
| 34 | + | |
| 35 | +Both depth arms therefore carry >=1 no-CFL intra hit per compared attempt; per-attempt counters | |
| 36 | +are read on decoded+compared attempts only, every decode-order frame is compared on Y/U/V, and a | |
| 37 | +mismatch fails (never SKIPs). | |
| 38 | + | |
| 39 | +## 3. The SECOND defect this fixture exposed -- root cause and fix (step 3) | |
| 40 | + | |
| 41 | +### Pinned stream | |
| 42 | +`$HOME/.cache/sbrect10/b58.obu` (192x128, 6 frames, 10-bit, cq 58, `--sb-size=64 | |
| 43 | +--min-partition-size=32 --max-partition-size=64 --enable-rect-partitions=1 | |
| 44 | +--enable-1to4-partitions=1 --lag-in-frames=0 --cpu-used=0`), sha256 hashed twice, identical: | |
| 45 | +`00b9253b308201118e27f348c67932a0006e3077ba7a9a401854c2ee7eb1dcd2`. | |
| 46 | + | |
| 47 | +### Localisation | |
| 48 | +- First mismatching frame: DECODE-ORDER 2 (display == decode order), plane Y only, 8252 samples; | |
| 49 | + U and V exact; frames 0 and 1 exact. Per-64x64-SB wrong-pixel map: row0 `[0, 0, 4092]`, | |
| 50 | + row1 `[0, 64, 4096]` -- i.e. the whole right superblock column, plus 64 deblock-bleed pixels. | |
| 51 | +- NOT an entropy desync: the 180-TU `all_zero` range ladder is IDENTICAL between our | |
| 52 | + `EC_TRACE_COEFF` and instrumented `aomdec`'s (`diff a.az o.az` empty over the WHOLE stream), | |
| 53 | + and blocks decoded AFTER the wrong ones (mi(16,0)) are pixel-exact. | |
| 54 | +- NOT a clamp: an `EC_DBG_CLAMP` probe on both the dequant clamp | |
| 55 | + (`+-(1 << (7 + bd))`) and every `clamp_range` in `transform.rs` fired ZERO times on this stream. | |
| 56 | +- The divergence is in the MV VALUES. `EC_TRACE_MODE` diff, decode-order frame 2: | |
| 57 | + | |
| 58 | + aomdec mi(0,32) mode=24 ref0=1 ref1=4 mv0=(128,-16) ours mv0=(-1,2) | |
| 59 | + aomdec mi(0,40) mode=17 ref0=1 ref1=4 mv0=(128,-16) ours mv0=(-1,2) | |
| 60 | + aomdec mi(8,32) / mi(8,40) / mi(16,40): same (128,-16) vs (-1,2) | |
| 61 | + aomdec mi(16,32) mode=24 mv0=(-176,256) ours (-241,264) | |
| 62 | + aomdec mi(24,32) mode=16 mv0=(-128,56) ours (-193,64) | |
| 63 | + | |
| 64 | + The NEAREST_NEARESTMV blocks take stack[0] directly, so libaom's stack[0].this_mv is | |
| 65 | + `(128,-16)` where ours is `(0,0)`; the NEWMV/NEW_NEWMV blocks are off by exactly the same | |
| 66 | + predictor delta. | |
| 67 | +- Our stack for mi(0,32): two entries, `this=(0,0) comp=(0,0) w=2` -- the signature of libaom's | |
| 68 | + compound EXTENSION pass appending `comp_list[0]` and `comp_list[1]` into an empty stack. | |
| 69 | +- The temporal field is genuinely empty for that frame and this is CORRECT: a new | |
| 70 | + `EC_TRACE_TPL` field dump (`EC_TPL_FIELD`) shows oh=1 and oh=2 all-`.` and oh=3 onward all-`#`; | |
| 71 | + frame 2's LAST projection is suppressed by `is_lst_overlay` and its LAST2 is the key frame. | |
| 72 | + | |
| 73 | +### Root cause | |
| 74 | +`crates/ec-av1/src/mvstack.rs:1482` `combine_compound_candidates` filled the `comp_list` tail | |
| 75 | +slots (the ones left over after `ref_id` then `ref_diff`) with `(0, 0)`. libaom fills them with | |
| 76 | +that side's GLOBAL MOTION vector -- `setup_ref_mv_list`, `av1/common/mvref_common.c:729`: | |
| 77 | + | |
| 78 | + for (; comp_idx < MAX_MV_REF_CANDIDATES; ++comp_idx) | |
| 79 | + comp_list[comp_idx][idx] = gm_mv_candidates[idx]; | |
| 80 | + | |
| 81 | +The zero fill was only right under IDENTITY global motion, which the module's original reduction | |
| 82 | +assumed; aomenc has `--enable-global-motion` ON by default. A compound block with no usable | |
| 83 | +neighbour pair (frame top row -> no above, 64x64 INTRA block to its left, empty temporal field) | |
| 84 | +therefore took a `(0, 0)` predictor where libaom took the frame's translation. | |
| 85 | + | |
| 86 | +Class: `parsed then discarded` / reduction-assumption -- global motion is parsed and used by the | |
| 87 | +single-ref path (`gm_fallback`, mvstack.rs:1099-1100) but was dropped on the compound tail. | |
| 88 | + | |
| 89 | +### Fix | |
| 90 | +`crates/ec-av1/src/mvstack.rs`: `combine_compound_candidates` now takes | |
| 91 | +`gm_mv_candidates: [(i32,i32); 2]` and uses it as the per-side fill; the call site passes | |
| 92 | +`[gm_mv(gm, ref_frame.0), gm_mv(gm, ref_frame.1)]`. | |
| 93 | + | |
| 94 | +### Sibling sweep (same shape, whole crate) | |
| 95 | +Every `gm_mv_candidates` use in `mvref_common.c` was walked. The single-reference tail fill | |
| 96 | +(`mvref_common.c:787-788`, `mv_ref_list[idx] = gm_mv_candidates[0]`) is already ported | |
| 97 | +(`mvstack.rs:1099-1100` `gm_fallback`); the scan-row/col/corner `is_gm_block` substitutions | |
| 98 | +(`:92`, `:117`) already take `gm` through `scan_*_compound`; the `add_tpl_ref_mv` | |
| 99 | +`GLOBALMV_OFFSET` compares (`:379-410`) already use `gm_mv(gm, ...)` on both sides. This was the | |
| 100 | +only zero-filled site. | |
| 101 | + | |
| 102 | +## 4. Other change | |
| 103 | +`crates/ec-av1/src/decode.rs` `dump_stage16`: the `EC_AV1_PREFILT_DUMP16` dump wrote a fixed | |
| 104 | +`<prefix>.f0` every frame, so only the LAST frame survived and a mid-sequence divergence could | |
| 105 | +not be read out at all. It is now indexed by decode-order picture like `EC_AV1_PREFILT_DUMP`. | |
| 106 | +`crates/ec-av1/src/motion_field.rs`: `setup_motion_field` prints an `EC_TPL_FIELD` occupancy map | |
| 107 | +under the existing `EC_TRACE_TPL` rung (this is what proved frame 2's empty temporal field). | |
| 108 | + | |
| 109 | +## 5. Refusals | |
| 110 | +None lifted this round (r1 lifted none either; this lane's work is two silent-miscode fixes). | |
| 111 | +`refusal_inventory.rs` is byte-identical to main. | |
| 112 | + | |
| 113 | +## Suite (step 4) -- RED | |
| 114 | +`test result: FAILED. 368 passed; 3 failed; 32 ignored; finished in 1049.95s` | |
| 115 | +(`$HOME/.cache/sbrect10-suite-r2.log`). film_grain is a shared-`fixtures`-symlink flake and | |
| 116 | +passes alone; the other two are open and triaged in `lanes/sbrect10-r2.handoff.md` section 5c. | |
| 117 | +Section 2's probe table proves only the 6 probed points -- it does NOT prove the gate's own | |
| 118 | +counter, which still reads 0 on the 8-bit arm. | |
| 119 | + | |
| 120 | +## EVIDENCE | |
| 121 | +EVIDENCE: $HOME/.cache/sbrect10/b58.obu (sha256 00b9253b...dcd2, hashed twice) | probe.sh half-random geq, 6 arms (8/10-bit x cq 52/58/61), decode + compare vs ffmpeg | pixel diffs 0/0/0/0/0/0 (was 0/32890/39907 on the 10-bit arms), >32 intra-in-inter hits 5/2/3 (8-bit) and 6/7/7 (10-bit) | |
| 122 | +EVIDENCE: $HOME/.cache/sbrect10/{a.az,o.az} | EC_TRACE_COEFF all_zero ladder, instrumented aomdec vs ours, whole stream | 180 TUs, `diff` empty -> entropy in sync, defect is reconstruction-side | |
| 123 | +EVIDENCE: $HOME/.cache/sbrect10/{a.mode,o.mode} | EC_TRACE_MODE mv0 diff, decode-order frame 2 | aomdec mi(0,32) mv0=(128,-16), ours (-1,2); 6 blocks diverge, all in the right superblock column | |
| 124 | +EVIDENCE: $HOME/.cache/sbrect10/o.tplf | EC_TPL_FIELD occupancy dump, all 5 inter frames | oh=1,2 empty / oh=3,4,5 full -> the empty temporal field at oh=2 is correct, not the defect |
lanes/sbrect10-r3.report.mdadded+98 -0
| @@ -0,0 +1,98 @@ | ||
| 1 | +# lane-sbrect10 r3 report | |
| 2 | + | |
| 3 | +Branch `lane-sbrect10`. Round input: r2 tip `1866bd5`, suite RED with 3 failed gates. | |
| 4 | +Round output: all three root-caused and green; merged main `85887c7` (which now carries | |
| 5 | +lane-mvtwin `2e2a225`), mvstack.rs resolved to main's copy byte-for-byte. | |
| 6 | + | |
| 7 | +## 1. `a_real_aomenc_stream_with_film_grain_decodes_pixel_exact` -- ENVIRONMENT, not code | |
| 8 | + | |
| 9 | +Panic body (r2 log had none: the unit was still running when the handoff was written, my first | |
| 10 | +`systemctl --user is-active sbrect10-suite-r2` used the un-timestamped unit name and read back | |
| 11 | +`inactive` wrongly). Run alone off the r2 binary: | |
| 12 | + | |
| 13 | + stream.rs:15680: called `Result::unwrap()` on an `Err` value: | |
| 14 | + Os { code: 2, kind: NotFound, message: "No such file or directory" } | |
| 15 | + | |
| 16 | +The worktree had **no top-level `fixtures` symlink** (`fixtures` is gitignored and per-worktree). | |
| 17 | +`fixtures/golden6-mismatch.obu` was simply absent. Not a temp-path collision: this gate writes no | |
| 18 | +temp file at all -- `ffmpeg_decode_sequence` (stream.rs:1316) pipes the stream through ffmpeg's | |
| 19 | +stdin/stdout, and the two helpers that DO make scratch dirs already key them on | |
| 20 | +`{test name}-{std::process::id()}` (stream.rs:2000, 15735), which is unique per process and per test. | |
| 21 | +Same failure at the same wall-clock in lane-sb128c's suite = the same missing symlink there, not a | |
| 22 | +race. Fixed with `ln -s .../edith_codecs/fixtures fixtures`. | |
| 23 | + | |
| 24 | +SWEEP: all three `../../fixtures/*.obu` reads in `crates/ec-av1/src` (golden6-mismatch.obu, | |
| 25 | +golden7-forwarding-mismatch.obu, lr-sgr-r7.obu) now resolve. | |
| 26 | + | |
| 27 | +EVIDENCE: $HOME/.cache/sbrect10-suite-r2.log + rerun | ln -s fixtures; ec_av1 binary --exact | |
| 28 | +a_real_aomenc_stream_with_film_grain_decodes_pixel_exact | FAILED (NotFound) -> ok, 0.31s | |
| 29 | + | |
| 30 | +## 2. The other two reds: ONE cause -- r2's fixture swap landed in the sibling gate | |
| 31 | + | |
| 32 | +Neither red was a pixel mismatch; both were vacuity asserts, and both counters read 0 for the | |
| 33 | +same reason. r2's half-random lavfi source | |
| 34 | + | |
| 35 | + horizontal: if(lt(X,128), 40+mod(floor((Y+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256)) | |
| 36 | + vertical: if(lt(Y,64), 40+mod(floor((X+N*sp)/32)*90,200), mod((X*7+Y*13+N*97)*31,256)) | |
| 37 | + | |
| 38 | +was written into `a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact` | |
| 39 | +(stream.rs:6592) instead of `a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet` | |
| 40 | +(stream.rs:6791) -- the rationale comment travelled with it, so the code read consistent. Effect: | |
| 41 | + | |
| 42 | +- CFL gate kept r1's flat `200` source, whose right-hand superblocks aomenc codes skip -> | |
| 43 | + 8-bit arm decoded 0 intra blocks above 32x32: *"no attempt decoded an intra block above 32x32 | |
| 44 | + ... gate proved nothing (2 refusals, 14 attempts carried none)"*. | |
| 45 | +- rect gate got the textured source, which changed the RD's residual decisions -> its 10-bit arm | |
| 46 | + lost the coded 64-axis transform unit lane-r14 r2 had measured on the flat source | |
| 47 | + (8-bit residual TUs=1, 10-bit=0): *"no superblock-level rect strip carried a coded 64-axis | |
| 48 | + residual transform unit ... (horz=2, vert=0)"*. | |
| 49 | + | |
| 50 | +FIX (`e2d9e9e`): sources swapped back so each gate runs the source it was measured on. No assert | |
| 51 | +weakened, no grid changed, no decoder code touched. | |
| 52 | + | |
| 53 | +Result of the two gates alone at the merged tree (`--test-threads=1 --exact`): | |
| 54 | + | |
| 55 | +| gate | 8-bit | 10-bit | | |
| 56 | +|---|---|---| | |
| 57 | +| no_cfl_uv_alphabet | 4 refusals, 4 exact attempts, **15** no-CFL uv_mode reads | 0 refusals, 8 exact attempts, **43** reads | | |
| 58 | +| superblock_level_rect_partition | 2 refusals, 4 exact, 64x32=4 32x64=4, **64-axis residual TUs=2** | 2 refusals, 2 exact, 64x32=2 32x64=2, **residual TUs=2** | | |
| 59 | + | |
| 60 | +0 out-of-scope mismatches in either depth of either gate, so r2's `combine_compound_candidates` | |
| 61 | +global-motion tail fill is NOT a regression source -- every attempt that decoded compared exact. | |
| 62 | + | |
| 63 | +EVIDENCE: $HOME/.cache/sbrect10-g2-a_real_aomenc_inter_frame_with_a_64x64_intra_block_reads_the_no_cfl_uv_alphabet.log, | |
| 64 | +$HOME/.cache/sbrect10-g2-a_real_aomenc_inter_sequence_with_a_superblock_level_rect_partition_decodes_pixel_exact.log | | |
| 65 | +swap the two gates' geq sources, rebuild, run each gate alone under systemd-run MemoryMax=6G | | |
| 66 | +both `test result: ok`, counters 15/43 no-CFL reads and 2/2 64-axis residual TUs | |
| 67 | + | |
| 68 | +## 3. Merge | |
| 69 | + | |
| 70 | +`git merge --no-commit main` twice: first main `4eff3a1` (`de045b7`, clean auto-merge), then main | |
| 71 | +`85887c7` after it took lane-mvtwin mid-round. Only conflict: `crates/ec-av1/src/mvstack.rs`, | |
| 72 | +resolved to MAIN's copy byte-for-byte (`git diff main -- crates/ec-av1/src/mvstack.rs` EMPTY) -- | |
| 73 | +main carries this lane's own comp_list global-motion tail fill plus mvtwin's insertion-time | |
| 74 | +candidate cap and tile-origin clamp. `cdf.rs`, `cdf_state.rs`, `refusal_inventory.rs` all | |
| 75 | +byte-identical to main. Lines this branch drops vs main are only its own hunks (uv_mode_cfl | |
| 76 | +narrowing, indexed `dump_stage16` prefix, gate fixtures). The merge commit was recorded by the | |
| 77 | +coordinator as `10e25e3` (parents `e2d9e9e` + `85887c7`) while this round was mid-flight. | |
| 78 | + | |
| 79 | +## 4. Suite | |
| 80 | + | |
| 81 | +`EC_AV1_REQUIRE_AOMENC=1 cargo test -p ec-av1 --lib -j3` under user unit | |
| 82 | +`sbrect10-suite-r3-1788326330.service`, log `$HOME/.cache/sbrect10-suite-r3.log`. | |
| 83 | +r2 for comparison: 368 passed / 3 failed / 32 ignored (the three above). | |
| 84 | + | |
| 85 | +**GREEN: 378 passed / 0 failed / 33 ignored / 0 measured, 1229.56s.** | |
| 86 | + | |
| 87 | +EVIDENCE: $HOME/.cache/sbrect10-suite-r3.log | systemd-run --user --unit=sbrect10-suite-r3-1788326330 | |
| 88 | +-p MemoryMax=10G cargo test -p ec-av1 --lib -j3, EC_AV1_REQUIRE_AOMENC=1 | | |
| 89 | +`test result: ok. 378 passed; 0 failed; 33 ignored` (r2 was 368/3/32) | |
| 90 | + | |
| 91 | +## 5. Residue | |
| 92 | + | |
| 93 | +- accepted: the no-CFL gate's 8-bit arm still takes named refusals on other shapes | |
| 94 | + (SB-level AB partition, 32x64/64x32 split intra strips) -- other lanes' scope, and 4 attempts | |
| 95 | + decode + prove the shape regardless. | |
| 96 | +- accepted: r2's `probe.sh` counted intra-in-inter blocks through an `EC_AV1_TELL` trace grep, | |
| 97 | + not through `nocfl_uv_mode_hits`; the gate itself asserts the real counter, so the proxy is only | |
| 98 | + a probe convenience. Not worth a rewrite. |
lanes/sqdrift-r1.handoff.mdadded+40 -0
| @@ -0,0 +1,40 @@ | ||
| 1 | +# lane-sqdrift r1 -> r2 handoff | |
| 2 | + | |
| 3 | +Branch `lane-sqdrift` @ 6edd5af (off main 85887c7). Worktree | |
| 4 | +`/home/user/Documents/Code/Rust/edith_codecs-sqdrift`, `CARGO_TARGET_DIR=$HOME/.cache/cargo-target-sqdrift`. | |
| 5 | + | |
| 6 | +## Do NOT redo any of this (all measured, see lanes/sqdrift-r1.report.md for the EVIDENCE lines) | |
| 7 | +* Stream: `/home/user/.cache/sqdrift/gen.sh` -> `s.obu`, sha256 | |
| 8 | + `c6af4fb4ebdc3d74dcfa0c945c0ef2d5e1e3a0902891d9e0a97a5608776b5d55`, hashed twice. | |
| 9 | +* Frames 0-3 byte-exact pre-filter AND post-filter (both dumps). No poisoned reference. | |
| 10 | +* Frame 4 damage = exactly the last SB, mi(16,32), PARTITION_NONE at 64x64, INTRA in an | |
| 11 | + inter frame (aomdec prints neither EC_MODE nor EC_IMODE for it). | |
| 12 | +* We enter that block IN SYNC: our `pre_rng=33730` == aomdec `EC_PART ... rng=33730`. | |
| 13 | +* TX_64X64 dequant + inverse transform EXONERATED against real libaom (0/4096). | |
| 14 | +* The stream contains no rect/AB/1:4 partition at all; main's 1:4-strip refusal on it is | |
| 15 | + a phantom of this desync. | |
| 16 | +* aomdec's prediction there is none of DC/SMOOTH/SMOOTH_V/SMOOTH_H/PAETH computed from | |
| 17 | + the true neighbours, so its coefficients differ too -> a SYMBOL diverges, not a predictor. | |
| 18 | + | |
| 19 | +## The one open question | |
| 20 | +Which symbol between `partition_w64` and the end of that block. Ordered suspects: | |
| 21 | +1. `read_delta_q_params` -- delta_q IS present (base_q_idx 80/110/168) and this is the | |
| 22 | + only block in the stream with `bsize == sb_size`, libaom's own special case | |
| 23 | + (`decodemv.c`: `if (bsize != cm->seq_params->sb_size || !mbmi->skip_txfm)`), incl. the | |
| 24 | + `delta_lf` sub-read. | |
| 25 | +2. `skip` / `is_inter` ctx at a 64x64 block. | |
| 26 | +3. `y_mode[size_group_lookup[BLOCK_64X64]=3]` CDF content (adaptation drift; frames 0-3 | |
| 27 | + never crossed a decision boundary). | |
| 28 | +4. `tx_depth`: `--enable-tx-size-search=0`, so TX_64X64 must code no depth symbol. | |
| 29 | +5. The 64x64 luma coefficient read (eob_pt alphabet at TX_64X64, `all_zero` ctx). | |
| 30 | + | |
| 31 | +## Instruments already in the tree | |
| 32 | +* `EC_AV1_TRACE=1` -> `TRACE partition_w64 ... pre_rng=<range before the symbol>`. | |
| 33 | +* `EC_IIS=1` -> `TRACE iis px= py= side= w= h= sg= mode= skip=` at the square | |
| 34 | + intra-in-inter `y_mode` read (decode.rs, right after `cdfs.y_mode[size_group_wh(..)]`). | |
| 35 | +* `/home/user/.cache/sqdrift/h.c` -- libaom inverse-transform harness. Build: | |
| 36 | + `gcc -O1 -o h h.c -I$SRC -I$BUILD -I$SRC/apps $BUILD/libaom.a -lm -lpthread`. | |
| 37 | + MUST call `av1_rtcd(); aom_dsp_rtcd();` first or `av1_idct64` is a NULL fn ptr (segfault). | |
| 38 | +* The oracle has NO range print inside `read_intra_block_mode_info` / | |
| 39 | + `read_delta_q_params`. Add one via `scripts/instrument-aom-oracle.sh` into a PRIVATE | |
| 40 | + build dir; never rebuild the shared `~/.cache/aom-oracle/build/aomdec` in place. |
lanes/sqdrift-r1.report.mdadded+100 -0
| @@ -0,0 +1,100 @@ | ||
| 1 | +# lane-sqdrift r1 -- the square-only silent pixel drift, localised to ONE block | |
| 2 | + | |
| 3 | +## Verdict: RED (defect localised and bounded, not yet fixed). No refusal lifted. | |
| 4 | + | |
| 5 | +## The stream (pinned, reproducible) | |
| 6 | + | |
| 7 | +`/home/user/.cache/sqdrift/gen.sh` (kept; recipe = lane-intra14's gate recipe with | |
| 8 | +`--enable-rect-partitions=0`): 192x128 8-bit `mandelbrot start_scale=4.76 end_scale=0.004 | |
| 9 | +end_pts=8 rate=25`, hue=s=0, `-t 0.32`, real `~/.cache/aom-oracle/build/aomenc` | |
| 10 | +`--cpu-used=1 --cq-level=55 --min-partition-size=16 --max-partition-size=64 | |
| 11 | +--enable-tx-size-search=0 --kf-min/max-dist=1000 --threads=1 --row-mt=0`, order-hint / | |
| 12 | +warped / obmc / masked / interintra / dist-wtd / diff-wtd / onesided / ab / 1to4 / | |
| 13 | +filter-intra / smooth-intra / paeth-intra / directional-intra / angle-delta / cdef / | |
| 14 | +restoration / palette / intrabc / cfl / ref-frame-mvs ALL `=0`. | |
| 15 | +sha256 `c6af4fb4ebdc3d74dcfa0c945c0ef2d5e1e3a0902891d9e0a97a5608776b5d55`, hashed twice | |
| 16 | +from two independent encodes -- reproducible. | |
| 17 | + | |
| 18 | +## What is actually wrong (measured, not reasoned) | |
| 19 | + | |
| 20 | +1. `aomdec EC_TRACE=1` partition histogram over the whole stream: only | |
| 21 | + `value=0 (NONE)` and `value=3 (SPLIT)` at bsize 12/9/6. **No rect, no AB, no 1:4 | |
| 22 | + partition exists in this stream at all** -- so main's refusal | |
| 23 | + "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", which this | |
| 24 | + stream stops at on `main@85887c7`, is a PHANTOM read out of an already-diverged | |
| 25 | + bitstream (class `refusal-from-own-desync`). | |
| 26 | +2. Pre-loop-filter dumps, our `EC_AV1_PREFILT_DUMP` vs aomdec's, per decode-order frame: | |
| 27 | + f0..f3 **byte-exact (luma AND chroma)**; f4 luma 3540 samples wrong, max |d| = 6, | |
| 28 | + **chroma exact**. Post-filter reference dumps (`EC_AV1_FINAL_DUMP`) f0..f3 exact too, | |
| 29 | + so no reference frame is poisoned going into f4. | |
| 30 | +3. The f4 damage is EXACTLY one superblock: bbox x 128..191, y 64..127 -- the last SB, | |
| 31 | + mi (16,32), which frame 4 codes as `PARTITION_NONE` at 64x64. It is the ONLY | |
| 32 | + 64x64 PARTITION_NONE block in any inter frame of this stream. | |
| 33 | +4. Range ladder at that block's entry: our pre-read msac range for its `partition_w64` | |
| 34 | + symbol is **33730**, identical to aomdec's `EC_PART mi_row=16 mi_col=32 bsize=12 | |
| 35 | + ctx=15 tell=25598 rng=33730`, and the ctx matches too (aomdec prints `bsl*4+ctx` | |
| 36 | + = 12+3, ours `ctx=3`). **We enter that block bit-exactly in sync.** | |
| 37 | +5. The divergence is INSIDE that block. aomdec prints neither `EC_MODE` (= | |
| 38 | + `read_inter_block_mode_info`) nor `EC_IMODE`, i.e. libaom takes | |
| 39 | + `read_intra_block_mode_info` -- an INTRA block inside an inter frame. Our decoder | |
| 40 | + takes the same arm and reads `y_mode[size_group=3] = 0 (DC_PRED)` | |
| 41 | + (new `EC_IIS=1` rung: `TRACE iis px=128 py=64 side=64 w=64 h=64 sg=3 mode=0 skip=false`). | |
| 42 | + Our reconstruction there is a FLAT 93, which is exactly | |
| 43 | + `(sum(above 64) + sum(left 64) + 64) >> 7` -- textbook DC_PRED. aomdec's | |
| 44 | + reconstruction is not flat. | |
| 45 | +6. The luma residual is NOT the defect. The block's 5 non-zero levels were pushed | |
| 46 | + through libaom itself (`av1_inv_txfm2d_add_64x64_c`, real `libaom.a`, dequant | |
| 47 | + replicated from `decodetxb.c:361-374` with `av1_dc/ac_quant_QTX(80,0,8)` = 74/87 and | |
| 48 | + `av1_get_tx_scale` shift 2): **0 mismatches** against our own `residual` for those | |
| 49 | + levels (and 2171 with the axes swapped, so the layout is right too). Our TX_64X64 | |
| 50 | + dequant + inverse transform is exact. | |
| 51 | +7. Everything after that block drifts: frame 5's SB0 `partition_w64` still reads 3, SB1 | |
| 52 | + reads 8 where aomdec reads 3 -- a CDF-state divergence carried across the frame | |
| 53 | + boundary (frame 5 restarts its own msac, so only the adapted CDFs can carry the | |
| 54 | + damage). f5..f7 then drift to ~24k samples / max |d| ~220 as they predict from f4. | |
| 55 | + | |
| 56 | +So: **the first divergent symbol is in the mode-info or coefficient read of a 64x64 | |
| 57 | +PARTITION_NONE intra-in-inter block, after `partition_w64` and at/after `y_mode`.** | |
| 58 | +The candidate set is now tiny: `skip`, `read_delta_q_params` (this is the ONE block in | |
| 59 | +the stream where `bsize == sb_size`, the exact case libaom's | |
| 60 | +`read_delta_q_params` special-cases), `is_inter`, `y_mode[3]`, `uv_mode_cfl[0]`, | |
| 61 | +`tx_depth` (`--enable-tx-size-search=0`, so a TX_64X64 must code no depth symbol), or the | |
| 62 | +64x64 coefficient read itself. `base_q_idx` in our trace takes three values (80/110/168) | |
| 63 | +across the stream, i.e. **delta_q IS present in this stream** -- that makes the | |
| 64 | +`bsize == sb_size` delta-q exception a first-class suspect. | |
| 65 | + | |
| 66 | +## What changed (all env-gated instrumentation, no decode behaviour) | |
| 67 | + | |
| 68 | +* `crates/ec-av1/src/decode.rs` (`decode_inter_frame_tile_with_cdfs`'s `partition_w64` | |
| 69 | + read) -- the `EC_AV1_TRACE` line now carries `pre_rng=`, the msac range BEFORE the | |
| 70 | + symbol, which is what makes it directly comparable to aomdec's `EC_PART ... rng=` | |
| 71 | + (class `compare-range-not-tell`). This is the measurement that proved fact 4. | |
| 72 | +* `crates/ec-av1/src/decode.rs` (square intra-in-inter `y_mode` read) -- new `EC_IIS=1` | |
| 73 | + rung printing `px/py/side/w/h/size_group/mode/skip` for every intra block in an inter | |
| 74 | + frame. That is fact 5. | |
| 75 | + | |
| 76 | +## Gate | |
| 77 | + | |
| 78 | +None added -- there is no fix to gate yet. Adding a gate now would pin the defect, not a | |
| 79 | +capability; the reproducing recipe is `scripts`-free and lives in this report plus | |
| 80 | +`/home/user/.cache/sqdrift/gen.sh`. | |
| 81 | + | |
| 82 | +## EVIDENCE | |
| 83 | + | |
| 84 | +EVIDENCE: /home/user/.cache/sqdrift/{op,aom}.f0..f4 | our EC_AV1_PREFILT_DUMP vs aomdec EC_AV1_PREFILT_DUMP on the pinned stream, every decode-order frame compared Y/U/V | f0-f3 0 bad samples; f4 luma 3540 bad, max |d| 6, chroma 0 bad, bbox exactly x128-191 y64-127 | |
| 85 | +EVIDENCE: /home/user/.cache/sqdrift/{of,af}.f0..f4 | EC_AV1_FINAL_DUMP (post-filter reference buffers) both decoders | f0-f3 0 bad; f4 first bad (145,58), 3848 bad, max 6 -- deblocking only spreads the f4 damage, no reference is poisoned earlier | |
| 86 | +EVIDENCE: /home/user/.cache/sqdrift/aom.trace | aomdec EC_TRACE=1 partition histogram, whole stream | bsize12 {0:2, 3:46}, bsize9 {0:58, 3:126}, bsize6 {0:504} -- zero rect/AB/1:4 partitions, so main's 1:4-strip refusal on this stream is a phantom | |
| 87 | +EVIDENCE: our EC_AV1_TRACE pre_rng vs /home/user/.cache/sqdrift/aom.both | range ladder at frame 4 SB (16,32) | ours pre_rng=33730 ctx=3, aomdec rng=33730 ctx=15(=12+3) -- in sync at block entry, so the defect is inside the block | |
| 88 | +EVIDENCE: /home/user/.cache/sqdrift/{h.c,aomres1.txt,ourres.txt} | the block's 5 non-zero levels through real libaom av1_inv_txfm2d_add_64x64_c vs our residual | 0/4096 mismatches (swapped-axis control: 2171) -- TX_64X64 dequant+inverse is exact | |
| 89 | +EVIDENCE: EC_IIS=1 rung on the pinned stream | our intra-in-inter mode read at the failing block | `TRACE iis px=128 py=64 side=64 w=64 h=64 sg=3 mode=0 skip=false`, reconstruction flat 93 = DC_PRED of the true neighbours; aomdec's is not flat (SMOOTH/SMOOTH_V/SMOOTH_H/PAETH all rejected numerically too, so aomdec's coefficients differ as well -- the divergence is a SYMBOL, not a predictor) | |
| 90 | + | |
| 91 | +## Residue | |
| 92 | + | |
| 93 | +* fix-now (next round, r2): bisect the ~6 remaining symbols of that one block. The | |
| 94 | + cheapest decisive instrument is a `pre_rng` print on every symbol of | |
| 95 | + `read_inter_frame_mode_info`'s square intra arm plus an aomdec-side `rng` print at the | |
| 96 | + same points in `read_intra_block_mode_info` / `read_delta_q_params` (the oracle has no | |
| 97 | + print there today -- add one to `scripts/instrument-aom-oracle.sh`, do NOT rebuild the | |
| 98 | + shared aomdec in place). Start with `read_delta_q_params`' `bsize == sb_size` exception. | |
| 99 | +* deferred: 10-bit arm -- unblocked by the fix; there is nothing to gate yet. | |
| 100 | +* accepted: the two `EC_*` trace rungs ship as permanent debug instrumentation. |
lanes/sqdrift-r2.report.mdadded+93 -0
| @@ -0,0 +1,93 @@ | ||
| 1 | +# lane-sqdrift r2 -- the square-only silent drift is the no-CFL `uv_mode` alphabet | |
| 2 | + | |
| 3 | +## Verdict: GREEN. Root cause confirmed by ablation, gated with a new real-aomenc gate. | |
| 4 | + | |
| 5 | +Tip `2b750e6` on `lane-sqdrift` (base main `85887c7`). | |
| 6 | + | |
| 7 | +## 1. What the divergence was | |
| 8 | + | |
| 9 | +r1 had localised it to one 64x64 `PARTITION_NONE` INTRA block inside an INTER frame | |
| 10 | +(frame 4, mi(16,32) = the last superblock), entered bit-exactly in sync (`pre_rng=33730` | |
| 11 | +== aomdec's `rng=33730`), with TX_64X64 dequant+inverse already exonerated against real | |
| 12 | +libaom. The open question was "which symbol inside that block". | |
| 13 | + | |
| 14 | +Answer: `uv_mode`. libaom's `is_cfl_allowed` (`blockd.h`: `block_size_wide[bsize] <= 32 && | |
| 15 | +block_size_high[bsize] <= 32`, spec 5.11.5) excludes a 64-axis block from CFL, so its | |
| 16 | +`uv_mode` comes off the **13-symbol `uv_mode_no_cfl`** alphabet. We read the 14-symbol | |
| 17 | +`uv_mode_cfl` one: the same `DC_PRED` VALUE, a different interval narrowing, and the tile | |
| 18 | +desynced from that block on (class `wrong-alphabet-same-value`). | |
| 19 | + | |
| 20 | +The fix was found independently by lane-sbrect10 (`9f1f108`) and is merged here, not | |
| 21 | +rewritten: commit `cbcbf13` merges `lane-sbrect10` into this branch. `decode.rs` gets the | |
| 22 | +`cfl_allowed = write_w.max(write_h) <= 32` test at the intra-in-inter square arm plus the | |
| 23 | +same `is_cfl_allowed` bound enforced at the two funnels `read_intra_mode` / | |
| 24 | +`read_intra_mode_rect`, and the `nocfl_uv_mode_hits()` witness counter. No decoder line in | |
| 25 | +this round is mine; my round's contributions are the confirmation, the ablation, and the | |
| 26 | +square-only gate. | |
| 27 | + | |
| 28 | +## 2. The decisive before/after, same stream, same tree | |
| 29 | + | |
| 30 | +Pinned stream `/home/user/.cache/sqdrift/keep-s.obu`, sha256 | |
| 31 | +`c6af4fb4ebdc3d74dcfa0c945c0ef2d5e1e3a0902891d9e0a97a5608776b5d55` (r1's `gen.sh`, | |
| 32 | +hashed twice from two independent encodes), compared PRE-LOOP-FILTER, per decode-order | |
| 33 | +frame, byte for byte against instrumented aomdec's own `EC_AV1_PREFILT_DUMP`: | |
| 34 | + | |
| 35 | +| | f0 | f1 | f2 | f3 | f4 | f5 | f6 | f7 | outcome | | |
| 36 | +|---|---|---|---|---|---|---|---|---|---| | |
| 37 | +| before (`cfl_allowed = true` ablation on THIS tree) | 0 | 0 | 0 | 0 | **3540** | - | - | - | REFUSED after f4: "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path" | | |
| 38 | +| after (merged fix) | 0 | 0 | 0 | 0 | **0** | 0 | 0 | 0 | 8 frames decoded, all byte-exact | | |
| 39 | + | |
| 40 | +The "before" row is not r1's memory: it is the one-line ablation | |
| 41 | +`decode.rs:18548 let cfl_allowed = true;` rebuilt and re-run in this round, then reverted | |
| 42 | +(`git diff --stat` after revert shows stream.rs only). It also re-confirms r1's finding | |
| 43 | +that the refusal main stops at on this stream is a PHANTOM of the desync -- aomdec's | |
| 44 | +partition histogram over the stream contains no rect partition at all (class | |
| 45 | +`refusal-from-own-desync`). | |
| 46 | + | |
| 47 | +## 3. The gate (new) | |
| 48 | + | |
| 49 | +`crates/ec-av1/src/stream.rs:6900` | |
| 50 | +`a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact` | |
| 51 | + | |
| 52 | +The SQUARE-ONLY twin of lane-sbrect10's gate, pinning r1's recipe: real aomenc, | |
| 53 | +192x128 mandelbrot (`start_scale` 4.76/3.20), cq 55/45, `--cpu-used=1 --sb-size=64 | |
| 54 | +--enable-rect-partitions=0 --enable-ab-partitions=0 --enable-1to4-partitions=0 | |
| 55 | +--min-partition-size=16 --max-partition-size=64 --enable-tx-size-search=0`, 8 decode-order | |
| 56 | +frames, **both bit depths**. Rect OFF is what makes the 64x64 `PARTITION_NONE` a WHOLE | |
| 57 | +superblock (`bsize == sb_size`), a shape the sibling gate's rect-on recipe does not pin; | |
| 58 | +8 frames of drift means a desync that survives one frame still fails here. | |
| 59 | + | |
| 60 | +Asserts: every decode-order frame's Y/U/V compared against ffmpeg (a mismatch of ANY shape | |
| 61 | +is a failure, never a SKIP -- so out-of-scope mismatches are structurally 0); a decode | |
| 62 | +error must be a named `unsupported` refusal; and `nocfl_uv_mode_hits` delta per attempt | |
| 63 | +must be > 0 on at least one pixel-exact attempt per depth. | |
| 64 | + | |
| 65 | +Result (`--exact --nocapture --test-threads=1`), 10.4 s: | |
| 66 | + | |
| 67 | +* 8-bit: 0 named refusals, **4/4 pixel-exact attempts**, 6 no-CFL `uv_mode` reads, 0 carried none | |
| 68 | +* 10-bit: 0 named refusals, **4/4 pixel-exact attempts**, 6 no-CFL `uv_mode` reads, 0 carried none | |
| 69 | + | |
| 70 | +No refusal string is removed in this round: the refusal this stream used to hit was never | |
| 71 | +about this shape. | |
| 72 | + | |
| 73 | +## 4. Suite | |
| 74 | + | |
| 75 | +`cargo test -p ec-av1 --lib` under `systemd-run --user --unit=sqdrift-suite-r2-...`, | |
| 76 | +log `$HOME/.cache/sqdrift-suite-r2.log`: **379 passed, 0 failed, 33 ignored** in 958.68 s (r1 baseline on the unfixed tree never completed). | |
| 77 | + | |
| 78 | +## EVIDENCE | |
| 79 | + | |
| 80 | +EVIDENCE: /home/user/.cache/sqdrift/np.f0..f7 vs aom.f0..f7 | decode_probe with EC_AV1_PREFILT_DUMP on the pinned stream (sha256 c6af4fb4...) after merging lane-sbrect10, cmp -l per decode-order frame Y+U+V | 0 differing bytes on all 8 frames (r1: f4 3540 wrong luma samples, then refusal) | |
| 81 | +EVIDENCE: /home/user/.cache/sqdrift/ab.f0..f4 | same binary with decode.rs:18548 ablated to `cfl_allowed = true`, rebuilt, re-run, then reverted | f0-f3 0, f4 3540 differing bytes, decode then REFUSES "an intra-coded 1:4 ... rect strip on the inter block path" -- the phantom refusal is produced by this desync alone | |
| 82 | +EVIDENCE: cargo test -p ec-av1 --lib -- --exact --nocapture a_real_aomenc_square_only_inter_sequence_with_a_64x64_intra_superblock_decodes_pixel_exact | 4 attempts x 2 bit depths of real aomenc, rect partitions off, every decode-order frame vs ffmpeg | ok in 10.38s; 8-bit 4 exact/6 hits, 10-bit 4 exact/6 hits, 0 refusals, 0 attempts carried none | |
| 83 | + | |
| 84 | +## Residue | |
| 85 | + | |
| 86 | +* deferred(lane-intra14 re-runs its own gate): `lanes/intra14-r2.report.md` records its | |
| 87 | + blocker as "decode-order frame 3/4 luma ~3.7-4.5k samples at max |d| 6..17, first diff | |
| 88 | + around x=128..141, y=58..59, then frames 5-7 drift to ~24k at max |d| ~220" on the same | |
| 89 | + 192x128 mandelbrot source -- the identical signature to this lane's, at the identical | |
| 90 | + coordinates. Very likely the same defect, so its two `#[ignore]`d 1:4-strip arms should | |
| 91 | + be re-measured on a tree carrying this fix. Not measured here: its recipe (1:4 on) is | |
| 92 | + another lane's surface. | |
| 93 | +* accepted: r1's `EC_AV1_TRACE pre_rng` and `EC_IIS` rungs stay as debug instrumentation. |