forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-intra14' (f4b5419) into lane-intrasplit: intra 1:4 strips on the inter path, narrowed refusal kept, this lane's split-tx refusal stays lifted

Browse files at this commit

e8291f8d1fc8f93879c71ad97357d669cb243deaAhmet Kaan GümüşParent: 368cbf4c3a622f
crates/ec-av1/examples/decode_probe.rsmodified+5 -0
@@ -46,6 +46,11 @@ fn main() {
46 println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}");46 println!("inter16_1to4: horz4={h4} vert4={v4} chroma_pairs={pairs} sub8_pieces={sub8}");
47 let leaf = ec_av1::stream::vartx_rect_leaf_hits();47 let leaf = ec_av1::stream::vartx_rect_leaf_hits();
48 println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]);48 println!("vartx_rect_leaf: 32x16={} 16x32={}", leaf[0], leaf[1]);
49+ let i4 = ec_av1::stream::intra_rect4_in_inter_counters();
50+ println!(
51+ "intra_rect4_in_inter: 64x16={} 16x64={} 32x8={} 8x32={}",
52+ i4.0, i4.1, i4.2, i4.3
53+ );
49 let ir = ec_av1::stream::inter_rect_counters();54 let ir = ec_av1::stream::inter_rect_counters();
50 println!(55 println!(
51 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",56 "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}",
crates/ec-av1/src/decode.rsmodified+118 -2
@@ -2012,6 +2012,33 @@ pub(crate) fn intra_rect_in_inter_split_tx_hits() -> [usize; 3] {
2012 INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(std::cell::Cell::get)2012 INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(std::cell::Cell::get)
2013 }2013 }
2014 2014
2015+// lane-intra14 r1: how many intra-coded 1:4 strips decoded on the INTER
2016+// block path, per shape -- [0] 64x16, [1] 16x64, [2] 32x8, [3] 8x32. Every
2017+// one of them was the named refusal "an intra-coded 1:4 (or other non-2:1)
2018+// rect strip on the inter block path" before this round.
2019+thread_local! {
2020+ static INTRA_RECT4_IN_INTER_HITS: std::cell::Cell<[usize; 4]> =
2021+ const { std::cell::Cell::new([0; 4]) };
2022+}
2023+
2024+/// Current value of [`INTRA_RECT4_IN_INTER_HITS`] for one shape
2025+/// (0 = 64x16, 1 = 16x64, 2 = 32x8, 3 = 8x32).
2026+pub(crate) fn intra_rect4_strip_in_inter_hits(shape: usize) -> usize {
2027+ INTRA_RECT4_IN_INTER_HITS.with(|c| c.get()[shape])
2028+}
2029+
2030+// lane-intra14 r1: set while an INTRA block of an INTER frame is decoded
2031+// through one of the key-frame rect readers ([`decode_block_rect4`],
2032+// [`decode_block_rect64`]). `Some((size_group, skip))` tells
2033+// [`read_intra_mode_rect`] that (a) `skip`/segment id/cdef/delta-q were
2034+// already read by [`decode_inter_block`] and (b) the luma mode comes off
2035+// `y_mode_cdf[size_group_lookup[bsize]]` (libaom `read_intra_block_mode_info`,
2036+// decodemv.c:1189), never the key frame's above/left `kf_y_mode` pair.
2037+thread_local! {
2038+ static INTRA_IN_INTER_MODE: std::cell::Cell<Option<(usize, bool)>> =
2039+ const { std::cell::Cell::new(None) };
2040+}
2041+
2015 // lane-rectx r5: how many times a NON-strip `kf_y_mode` reader2042 // lane-rectx r5: how many times a NON-strip `kf_y_mode` reader
2016 // ([`decode_block`], [`decode_block_rect`], [`decode_block_rect64`]) took an2043 // ([`decode_block`], [`decode_block_rect`], [`decode_block_rect64`]) took an
2017 // above/left mode from the mi-exact map that DIFFERS from its coarse 16x162044 // above/left mode from the mi-exact map that DIFFERS from its coarse 16x16
@@ -5652,6 +5679,13 @@ fn read_intra_mode_rect(
5652 } else {5679 } else {
5653 cfl5680 cfl
5654 };5681 };
5682+ // lane-intra14 r1: on the INTER block path everything up to and including
5683+ // `is_inter` was already read by [`decode_inter_block`], so this reader
5684+ // starts at the mode syntax with the `skip` that caller read.
5685+ let inter = INTRA_IN_INTER_MODE.with(std::cell::Cell::get);
5686+ let skip = if let Some((_, skip)) = inter {
5687+ skip
5688+ } else {
5655 // Same `intra_segment_id` placement as the square reader above.5689 // Same `intra_segment_id` placement as the square reader above.
5656 let (seg_w_mi, seg_h_mi) = (bw / 4, bh / 4);5690 let (seg_w_mi, seg_h_mi) = (bw / 4, bh / 4);
5657 if seg_id_pre_skip() {5691 if seg_id_pre_skip() {
@@ -5670,9 +5704,18 @@ fn read_intra_mode_rect(
5670 maybe_read_delta_q(dec, cdfs, mi_r, mi_c, false, skip);5704 maybe_read_delta_q(dec, cdfs, mi_r, mi_c, false, skip);
5671 maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, false, skip);5705 maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, false, skip);
5672 istep!("dq", 0);5706 istep!("dq", 0);
5707+ skip
5708+ };
5709+ // libaom `read_intra_block_mode_info` (decodemv.c:1189) vs the key
5710+ // frame's `read_intra_frame_mode_info` (decodemv.c:1065 `read_intra_mode`
5711+ // off `kf_y_mode_cdf[above][left]`).
5712+ let mode = if let Some((size_group, _)) = inter {
5713+ dec.symbol(&mut cdfs.y_mode[size_group])
5714+ } else {
5673 let above_ctx = INTRA_MODE_CTX[above_mode];5715 let above_ctx = INTRA_MODE_CTX[above_mode];
5674 let left_ctx = INTRA_MODE_CTX[left_mode];5716 let left_ctx = INTRA_MODE_CTX[left_mode];
5675- let mode = dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx]);5717+ dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx])
5718+ };
5676 istep!("mode", mode as i32);5719 istep!("mode", mode as i32);
5677 let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) {5720 let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) {
5678 read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED])5721 read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED])
@@ -6328,9 +6371,18 @@ fn decode_intra_rect_in_inter(
6328 (8, 16) => (1usize, 1usize),6371 (8, 16) => (1usize, 1usize),
6329 (16, 32) => (2, 2),6372 (16, 32) => (2, 2),
6330 (32, 64) => (3, 3),6373 (32, 64) => (3, 3),
6374+ // lane-intra14 r1: the 1:4 strips, read off libaom's own tables --
6375+ // `size_group_lookup` (common_data.h:61) gives BLOCK_8X32/32X8 group
6376+ // 1 and BLOCK_16X64/64X16 group 2, while
6377+ // `bsize_to_tx_size_depth_table` (blockd.h:1347) gives them depth
6378+ // 3 and 4, i.e. tx categories 2 and 3 -- the diagonal a 2:1 strip
6379+ // keeps is genuinely broken here, which is why the shape was refused
6380+ // rather than read from the 2:1 row.
6381+ (8, 32) => (1, 2),
6382+ (16, 64) => (2, 3),
6331 _ => {6383 _ => {
6332 return Err(unsupported(6384 return Err(unsupported(
6333- "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path",6385+ "an intra-coded 16x4/4x16 strip on the inter block path (the 16x16-level 1:4 inter partition is refused before this point)",
6334 ))6386 ))
6335 }6387 }
6336 };6388 };
@@ -6343,6 +6395,70 @@ fn decode_intra_rect_in_inter(
6343 is consumed for square blocks only)",6395 is consumed for square blocks only)",
6344 ));6396 ));
6345 }6397 }
6398+ // lane-intra14 r1: a 1:4 strip decodes through the very readers the KEY
6399+ // FRAME path already proves for this shape ([`decode_block_rect4`] at the
6400+ // 32 level, [`decode_block_rect64`] at 64 -- both already handle the 1:4
6401+ // luma/chroma transform tables, the per-unit split walk and the strip's
6402+ // own neighbour records). The ONLY difference on an inter frame is the
6403+ // mode-info read, which [`INTRA_IN_INTER_MODE`] switches to
6404+ // `read_intra_block_mode_info`'s `y_mode[size_group]` plus the `skip`
6405+ // this caller already read. `tx_cat` above is the same category those
6406+ // readers hardcode (cat 2 in `decode_block_rect4`, cat 3 in
6407+ // `decode_block_rect64`), asserted here so a future shape cannot drift.
6408+ if bw.max(bh) == 4 * bw.min(bh) {
6409+ debug_assert_eq!(tx_cat, if bw.max(bh) == 64 { 3 } else { 2 });
6410+ INTRA_IN_INTER_MODE.with(|c| c.set(Some((size_group, skip))));
6411+ let res = if bw.max(bh) == 64 {
6412+ decode_block_rect64(
6413+ dec,
6414+ cdfs,
6415+ neighbours,
6416+ (mi_r / (SUB / MI), mi_c / (SUB / MI)),
6417+ bw,
6418+ bh,
6419+ y,
6420+ u,
6421+ v,
6422+ ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get),
6423+ allow_screen_content_tools,
6424+ base_q_idx,
6425+ TX_SELECT_INTER.with(std::cell::Cell::get),
6426+ REDUCED_TX_SET_INTER.with(std::cell::Cell::get),
6427+ )
6428+ } else {
6429+ decode_block_rect4(
6430+ dec,
6431+ cdfs,
6432+ neighbours,
6433+ (mi_r, mi_c),
6434+ bw,
6435+ bh,
6436+ None,
6437+ y,
6438+ u,
6439+ v,
6440+ ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get),
6441+ allow_screen_content_tools,
6442+ base_q_idx,
6443+ TX_SELECT_INTER.with(std::cell::Cell::get),
6444+ )
6445+ .map(|_| ())
6446+ };
6447+ INTRA_IN_INTER_MODE.with(|c| c.set(None));
6448+ res?;
6449+ let shape = match (bw, bh) {
6450+ (64, 16) => 0,
6451+ (16, 64) => 1,
6452+ (32, 8) => 2,
6453+ _ => 3,
6454+ };
6455+ INTRA_RECT4_IN_INTER_HITS.with(|h| {
6456+ let mut v = h.get();
6457+ v[shape] += 1;
6458+ h.set(v);
6459+ });
6460+ return Ok(());
6461+ }
6346 let mode = dec.symbol(&mut cdfs.y_mode[size_group]);6462 let mode = dec.symbol(&mut cdfs.y_mode[size_group]);
6347 if mode >= 13 {6463 if mode >= 13 {
6348 return Err(unsupported(6464 return Err(unsupported(
crates/ec-av1/src/refusal_inventory.rsmodified+1 -1
@@ -88,7 +88,7 @@ const REFUSALS: &[&str] = &[
88 // inter path's intra arm now routes 2:1 strips through `decode_rect_split`);88 // inter path's intra arm now routes 2:1 strips through `decode_rect_split`);
89 // what is left is the 1:4 shape, whose `bsize_to_tx_size_cat` breaks the89 // what is left is the 1:4 shape, whose `bsize_to_tx_size_cat` breaks the
90 // size-group/category diagonal the 2:1 shapes share.90 // size-group/category diagonal the 2:1 shapes share.
91- "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path",91+ "an intra-coded 16x4/4x16 strip on the inter block path (the 16x16-level 1:4 inter partition is refused before this point)",
92 // The same arm's screen-content gate: palette/intrabc syntax is consumed92 // The same arm's screen-content gate: palette/intrabc syntax is consumed
93 // for square blocks only, so a strip in such a frame would skip symbols.93 // for square blocks only, so a strip in such a frame would skip symbols.
94 "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)",94 "a HORZ/VERT intra strip in a screen-content frame (palette syntax is consumed for square blocks only)",
crates/ec-av1/src/stream.rsmodified+326 -0
@@ -68,6 +68,18 @@ pub fn inter_rect_counters() -> (usize, usize, usize, usize, usize, usize) {
68 )68 )
69 }69 }
70 70
71+/// lane-intra14 r1: INTRA-coded 1:4 strips decoded on the INTER block path
72+/// (64x16, 16x64, 32x8, 8x32) -- the counters a recipe sweep needs from
73+/// outside the crate.
74+pub fn intra_rect4_in_inter_counters() -> (usize, usize, usize, usize) {
75+ (
76+ crate::decode::intra_rect4_strip_in_inter_hits(0),
77+ crate::decode::intra_rect4_strip_in_inter_hits(1),
78+ crate::decode::intra_rect4_strip_in_inter_hits(2),
79+ crate::decode::intra_rect4_strip_in_inter_hits(3),
80+ )
81+}
82+
71 /// lane-r14 r2: luma transform units of an inter strip with a 64-px axis,83 /// lane-r14 r2: luma transform units of an inter strip with a 64-px axis,
72 /// coded as the truncated low-32 coefficient corner.84 /// coded as the truncated low-32 coefficient corner.
73 pub fn rect64_inter_tu_hits() -> usize {85 pub fn rect64_inter_tu_hits() -> usize {
@@ -4677,6 +4689,320 @@ mod tests {
4677 );4689 );
4678 }4690 }
4679 4691
4692+ /// lane-intra14 r1's decisive gate: a real aomenc INTER sequence with
4693+ /// `--enable-1to4-partitions=1`, whose fast-zooming content makes aomenc
4694+ /// code INTRA blocks inside inter frames on 1:4 strip shapes (32x8/8x32 at
4695+ /// the 32 level, 64x16/16x64 at the superblock level). Every such block
4696+ /// was the named refusal "an intra-coded 1:4 (or other non-2:1) rect strip
4697+ /// on the inter block path" until this round; they now decode through the
4698+ /// same `decode_block_rect4` / `decode_block_rect64` readers the KEY FRAME
4699+ /// 1:4 paths already prove, with only the mode-info read switched to
4700+ /// `read_intra_block_mode_info` (libaom decodemv.c:1189).
4701+ ///
4702+ /// Hard-asserts `intra_rect4_strip_in_inter_hits` (0 = 64x16, 1 = 16x64,
4703+ /// 2 = 32x8, 3 = 8x32) summed over the attempts that were actually
4704+ /// pixel-compared, and every decode-order frame is compared. A decode that
4705+ /// succeeds is ALWAYS pixel-compared (class
4706+ /// [[gate-skips-on-its-own-failure]]); exhausting every attempt without a
4707+ /// counted strip is a FAILURE, never a SKIP.
4708+ #[test]
4709+ // r1 `#[ignore]`d this gate on "every stream with an intra 1:4 strip also
4710+ // hits the inter rect-strip refusal". r2 merged main 18bf7dc (lane-r14
4711+ // a2e2e29 lifts exactly that refusal) and re-ran it: 3 of 40 attempts now
4712+ // decode whole and reach the pixel compare (0 before), one of them firing
4713+ // 64x16=4 16x64=3. But the compare fails on a defect this lane does not
4714+ // own -- MEASURED (r2, $HOME/.cache/intra14-r2-*.log):
4715+ // * seeds 46 and 54 fire ZERO 1:4 strips (`intra_rect4_strip_in_inter_hits`
4716+ // delta 0/0/0/0) and mismatch ffmpeg the same way as the firing seed 52:
4717+ // decode-order frame 3/4 luma ~3.7-4.5k samples, max |d| 6..17, then
4718+ // frames 5-7 drift to ~24k samples, max |d| ~220 as the references
4719+ // carry the error forward.
4720+ // * with `--enable-1to4-partitions=0` aomenc emits a BYTE-IDENTICAL
4721+ // stream at this recipe (same hits, same per-frame diff counts), so
4722+ // the 1:4 shape is not the discriminator either.
4723+ // i.e. this mandelbrot 192x128 source has a pre-existing INTER-frame
4724+ // pixel defect on this tree (r1 already recorded it as "open, NOT mine"
4725+ // with rect partitions off; it is now this gate's blocker). testsrc2 at
4726+ // 192x128 decodes pixel-exact on the same recipe but fires no 1:4 strip
4727+ // in 4 of 12 attempts that decode whole. So the gate stays `#[ignore]`d
4728+ // rather than weakened: a source whose baseline is exact AND that fires
4729+ // an intra 1:4 strip has not been found yet.
4730+ #[ignore = "blocked: the mandelbrot gate source has a pre-existing inter-frame pixel defect on this tree (zero-hit streams mismatch identically) -- see the MEASURED note above"]
4731+ fn a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact() {
4732+ intra_rect4_in_inter_gate(8);
4733+ }
4734+
4735+ /// The 10-bit arm (both of the user's films are `yuv420p10le`).
4736+ #[test]
4737+ // r1 `#[ignore]`d this gate on "every stream with an intra 1:4 strip also
4738+ // hits the inter rect-strip refusal". r2 merged main 18bf7dc (lane-r14
4739+ // a2e2e29 lifts exactly that refusal) and re-ran it: 3 of 40 attempts now
4740+ // decode whole and reach the pixel compare (0 before), one of them firing
4741+ // 64x16=4 16x64=3. But the compare fails on a defect this lane does not
4742+ // own -- MEASURED (r2, $HOME/.cache/intra14-r2-*.log):
4743+ // * seeds 46 and 54 fire ZERO 1:4 strips (`intra_rect4_strip_in_inter_hits`
4744+ // delta 0/0/0/0) and mismatch ffmpeg the same way as the firing seed 52:
4745+ // decode-order frame 3/4 luma ~3.7-4.5k samples, max |d| 6..17, then
4746+ // frames 5-7 drift to ~24k samples, max |d| ~220 as the references
4747+ // carry the error forward.
4748+ // * with `--enable-1to4-partitions=0` aomenc emits a BYTE-IDENTICAL
4749+ // stream at this recipe (same hits, same per-frame diff counts), so
4750+ // the 1:4 shape is not the discriminator either.
4751+ // i.e. this mandelbrot 192x128 source has a pre-existing INTER-frame
4752+ // pixel defect on this tree (r1 already recorded it as "open, NOT mine"
4753+ // with rect partitions off; it is now this gate's blocker). testsrc2 at
4754+ // 192x128 decodes pixel-exact on the same recipe but fires no 1:4 strip
4755+ // in 4 of 12 attempts that decode whole. So the gate stays `#[ignore]`d
4756+ // rather than weakened: a source whose baseline is exact AND that fires
4757+ // an intra 1:4 strip has not been found yet.
4758+ #[ignore = "blocked: the mandelbrot gate source has a pre-existing inter-frame pixel defect on this tree (zero-hit streams mismatch identically) -- see the MEASURED note above"]
4759+ fn a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact_10bit() {
4760+ intra_rect4_in_inter_gate(10);
4761+ }
4762+
4763+ fn intra_rect4_in_inter_gate(bit_depth: u32) {
4764+ const NAME: &str =
4765+ "a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact";
4766+ if !have_ffmpeg() {
4767+ eprintln!("SKIP {NAME}: no ffmpeg");
4768+ return;
4769+ }
4770+ if !have_aomenc() {
4771+ eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display());
4772+ return;
4773+ }
4774+ let (width, height, frame_count) = (192usize, 128usize, 8usize);
4775+ let mut refusals: Vec<String> = Vec::new();
4776+ let mut uncounted_exact = 0u32;
4777+ let mut compared = 0u32;
4778+ let mut shapes = [0usize; 4];
4779+ for attempt in 0..40u32 {
4780+ let seed = 42 + attempt;
4781+ // Same source class as the 2:1 sibling gate: a FAST mandelbrot
4782+ // zoom (`end_scale`/`end_pts`) so consecutive frames share almost
4783+ // no content and aomenc's RD codes blocks INTRA inside INTER
4784+ // frames, with `--kf-min-dist=1000` forbidding a new key frame.
4785+ let source = format!(
4786+ "mandelbrot=size={width}x{height}:start_scale={}:end_scale=0.004:end_pts=8:rate=25",
4787+ 5.0 - f64::from(attempt) * 0.06
4788+ );
4789+ let y4m = Command::new("ffmpeg")
4790+ .args([
4791+ "-v", "error", "-f", "lavfi", "-i", &source, "-vf", "hue=s=0", "-pix_fmt",
4792+ if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" },
4793+ "-strict", "-1", "-t", "0.32", "-f", "yuv4mpegpipe", "-strict", "-1", "-",
4794+ ])
4795+ .stdin(Stdio::null())
4796+ .stdout(Stdio::piped())
4797+ .stderr(Stdio::piped())
4798+ .output()
4799+ .expect("ffmpeg failed to run");
4800+ assert!(
4801+ y4m.status.success(),
4802+ "ffmpeg fixture: {}",
4803+ String::from_utf8_lossy(&y4m.stderr)
4804+ );
4805+ let depth_args: &[&str] = if bit_depth == 10 {
4806+ &["-b", "10", "--input-bit-depth=10"]
4807+ } else {
4808+ &[]
4809+ };
4810+ // MEASURED (r1, 40 attempts): `--cpu-used=0` makes aomenc pick
4811+ // 128x128 superblocks on this frame size, which decode_stream
4812+ // refuses by name, so the preset sweep starts at 1.
4813+ let cpu = format!("--cpu-used={}", 1 + attempt % 4);
4814+ // The higher the quantiser the more 1:4 intra strips inside inter
4815+ // frames, so the sweep walks cq 63 first.
4816+ let cq = format!("--cq-level={}", [63u32, 55, 45, 35][(attempt / 4) as usize % 4]);
4817+ let mut child = Command::new(aomenc_path())
4818+ .args(depth_args)
4819+ .arg(&cpu)
4820+ .arg(&cq)
4821+ .args([
4822+ // Every flag spelled exactly once (class
4823+ // [[aomenc-last-flag-wins]]). These are what the gate is
4824+ // about: 1:4 partitions ON, min size 16 so the 16x16-level
4825+ // 1:4 (refused elsewhere) is out of reach.
4826+ "--enable-rect-partitions=1",
4827+ "--enable-1to4-partitions=1",
4828+ // MEASURED (r1): at `--min-partition-size=16` aomenc codes
4829+ // 16x16-level 1:4 partitions (16x4/4x16 strips), which the
4830+ // inter partition path refuses by name (another lane's
4831+ // surface) in 12/40 attempts. 32 keeps this gate's two
4832+ // reachable levels -- the 32-level 32x8/8x32 and the
4833+ // superblock-level 64x16/16x64 -- and nothing else.
4834+ "--min-partition-size=32",
4835+ "--max-partition-size=64",
4836+ // MEASURED (r1): with tx-size search ON, 8/40 attempts stop
4837+ // at the 2:1 strip's own split-tx refusal (merge-cross-product,
4838+ // another lane's surface) before a 1:4 strip is reached.
4839+ "--enable-tx-size-search=0",
4840+ "--enable-filter-intra=1",
4841+ "--enable-intra-edge-filter=1",
4842+ "--codec=av1",
4843+ "--passes=1",
4844+ "--end-usage=q",
4845+ "--lag-in-frames=0",
4846+ "--auto-alt-ref=0",
4847+ "--kf-min-dist=1000",
4848+ "--kf-max-dist=1000",
4849+ "--threads=1",
4850+ "--row-mt=0",
4851+ "--enable-order-hint=0",
4852+ "--enable-warped-motion=0",
4853+ "--enable-obmc=0",
4854+ "--enable-masked-comp=0",
4855+ "--enable-interintra-comp=0",
4856+ "--enable-dist-wtd-comp=0",
4857+ "--enable-diff-wtd-comp=0",
4858+ "--enable-onesided-comp=0",
4859+ "--enable-interintra-wedge=0",
4860+ "--enable-smooth-interintra=0",
4861+ "--enable-ab-partitions=0",
4862+ "--enable-smooth-intra=0",
4863+ "--enable-paeth-intra=0",
4864+ "--enable-directional-intra=0",
4865+ "--enable-angle-delta=0",
4866+ "--enable-cdef=0",
4867+ "--enable-restoration=0",
4868+ // Ledger dead-end (lane-r14): a NEW gate spelling
4869+ // `--enable-cfl-intra=1` retires that tool from
4870+ // `NEVER_EXERCISED_8BIT` on the flag alone while no CfL
4871+ // hit counter exists to assert -- so it stays 0 here.
4872+ // Palette stays 0 for the same class of reason: this arm
4873+ // refuses a screen-content frame whole, so a palette flag
4874+ // would buy no coverage.
4875+ "--enable-palette=0",
4876+ "--enable-intrabc=0",
4877+ "--enable-cfl-intra=0",
4878+ "--enable-ref-frame-mvs=0",
4879+ "--obu",
4880+ "-o",
4881+ "-",
4882+ "-",
4883+ ])
4884+ .stdin(Stdio::piped())
4885+ .stdout(Stdio::piped())
4886+ .stderr(Stdio::piped())
4887+ .spawn()
4888+ .expect("aomenc failed to start");
4889+ child
4890+ .stdin
4891+ .take()
4892+ .expect("aomenc stdin")
4893+ .write_all(&y4m.stdout)
4894+ .expect("writing y4m to aomenc");
4895+ let out = child.wait_with_output().expect("aomenc failed to run");
4896+ assert!(
4897+ out.status.success(),
4898+ "aomenc refused the fixture: {}",
4899+ String::from_utf8_lossy(&out.stderr)
4900+ );
4901+ let stream = out.stdout;
4902+ let before: Vec<usize> =
4903+ (0..4).map(decode::intra_rect4_strip_in_inter_hits).collect();
4904+ let frames = match decode_stream(&stream) {
4905+ Ok(frames) => frames,
4906+ Err(e) => {
4907+ let msg = e.to_string();
4908+ assert!(
4909+ msg.contains("unsupported"),
4910+ "intra-1:4-in-inter decode failed outright (seed {seed}): {msg}"
4911+ );
4912+ refusals.push(format!("seed {seed} {cpu} {cq}: {msg}"));
4913+ continue;
4914+ }
4915+ };
4916+ let delta: Vec<usize> = (0..4)
4917+ .map(|k| decode::intra_rect4_strip_in_inter_hits(k) - before[k])
4918+ .collect();
4919+ let ffmpeg_frames = if bit_depth == 10 {
4920+ ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count)
4921+ } else {
4922+ ffmpeg_decode_sequence(&stream, width, height, frame_count)
4923+ };
4924+ assert_eq!(frames.len(), frame_count);
4925+ eprintln!(
4926+ "intra14 gate {bit_depth}-bit seed={seed} {cpu} {cq}: intra 1:4 strips in inter \
4927+ frames 64x16={} 16x64={} 32x8={} 8x32={}",
4928+ delta[0], delta[1], delta[2], delta[3]
4929+ );
4930+ for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() {
4931+ for (plane, (g, w)) in [
4932+ ("Y", (&got.y, &want.y)),
4933+ ("U", (&got.u, &want.u)),
4934+ ("V", (&got.v, &want.v)),
4935+ ] {
4936+ let stride = if plane == "Y" { width } else { width / 2 };
4937+ if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) {
4938+ let maxd = g
4939+ .iter()
4940+ .zip(w.iter())
4941+ .map(|(a, b)| i32::from(*a).abs_diff(i32::from(*b)))
4942+ .max()
4943+ .unwrap_or(0);
4944+ eprintln!(
4945+ "intra14 gate {bit_depth}-bit seed={seed}: frame {i} {plane} first \
4946+ diff at ({}, {}) got {} want {} ({} samples differ, max |d|={maxd})",
4947+ at % stride,
4948+ at / stride,
4949+ g[at],
4950+ w[at],
4951+ g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(),
4952+ );
4953+ }
4954+ assert_eq!(g, w, "{plane} vs ffmpeg (seed {seed}, frame {i})");
4955+ }
4956+ }
4957+ compared += 1;
4958+ if delta.iter().all(|d| *d == 0) {
4959+ uncounted_exact += 1;
4960+ refusals.push(format!(
4961+ "seed {seed} {cpu} {cq}: decoded and pixel-compared, but no intra 1:4 strip on \
4962+ the inter path"
4963+ ));
4964+ }
4965+ for k in 0..4 {
4966+ shapes[k] += delta[k];
4967+ }
4968+ // Both LEVELS (32 and 64) is the bar; orientation is whichever the
4969+ // encoder picks.
4970+ if shapes[0] + shapes[1] > 0 && shapes[2] + shapes[3] > 0 {
4971+ break;
4972+ }
4973+ }
4974+ gate_buckets(
4975+ NAME,
4976+ compared - uncounted_exact,
4977+ uncounted_exact,
4978+ refusals.len() - uncounted_exact as usize,
4979+ );
4980+ eprintln!(
4981+ "{NAME} ({bit_depth}-bit): compared {compared} streams, intra 1:4 strips in inter \
4982+ frames: 64x16={} 16x64={} 32x8={} 8x32={}; refusals:\n{}",
4983+ shapes[0],
4984+ shapes[1],
4985+ shapes[2],
4986+ shapes[3],
4987+ refusals.join("\n")
4988+ );
4989+ assert!(
4990+ compared > 0,
4991+ "{NAME} ({bit_depth}-bit): every attempt hit a named refusal -- nothing was \
4992+ pixel-compared:\n{}",
4993+ refusals.join("\n")
4994+ );
4995+ assert!(
4996+ shapes[2] + shapes[3] > 0,
4997+ "{NAME} ({bit_depth}-bit): no 32-level intra 1:4 strip (32x8/8x32) fired over \
4998+ {compared} compared streams (64x16={} 16x64={} 32x8={} 8x32={})",
4999+ shapes[0],
5000+ shapes[1],
5001+ shapes[2],
5002+ shapes[3]
5003+ );
5004+ }
5005+
4680 fn tx_select_inter_gate(bit_depth: u32) {5006 fn tx_select_inter_gate(bit_depth: u32) {
4681 if !have_ffmpeg() {5007 if !have_ffmpeg() {
4682 eprintln!(5008 eprintln!(
lanes/intra14-r1.report.mdadded+105 -0
@@ -0,0 +1,105 @@
1+# lane-intra14 r1 -- intra-coded 1:4 rect strips on the INTER block path
2+
3+Branch `lane-intra14` off main `7a47fc1`. **RED**: the decoder work is done and
4+demonstrably fires, but NO real-aomenc attempt on this tree can be
5+pixel-compared, so the lifted refusal is **ungated** and this branch MUST NOT
6+merge as-is.
7+
8+## What changed
9+
10+* `crates/ec-av1/src/decode.rs:5987` (`decode_intra_rect_in_inter`) -- the
11+ `(size_group, tx_cat)` table gains the 1:4 rows `(8,32) -> (1,2)` and
12+ `(16,64) -> (2,3)`, read off libaom `size_group_lookup`
13+ (common_data.h:61) and `bsize_to_tx_size_depth_table` (blockd.h:1347). A 1:4
14+ strip then decodes through the KEY-FRAME readers that already prove the
15+ shape: `decode_block_rect4` (32-level 32x8/8x32) and `decode_block_rect64`
16+ (SB-level 64x16/16x64) -- transform tables, per-unit split walk, chroma,
17+ Reach, neighbour records, palette/filter-intra refusals all reused unchanged.
18+* `crates/ec-av1/src/decode.rs` `INTRA_IN_INTER_MODE` (thread-local) -- the one
19+ genuine difference on an inter frame is the mode-info read.
20+ `read_intra_mode_rect` now, when it is set, (a) takes the `skip` the inter
21+ path already read instead of re-reading skip/segment id/cdef/delta-q and
22+ (b) reads the luma mode off `y_mode[size_group]`
23+ (libaom `read_intra_block_mode_info`, decodemv.c:1189) instead of
24+ `kf_y_mode[above][left]` (decodemv.c's key-frame reader). Everything after
25+ that -- angle deltas (decodemv.c:1191/1203), uv_mode + CfL (1196-1201),
26+ palette (1215), filter intra (the `read_filter_intra_mode_info` tail) -- is
27+ bit-identical between the two libaom readers, which is why no other symbol
28+ needed a branch.
29+* Counters `INTRA_RECT4_IN_INTER_HITS` (0=64x16, 1=16x64, 2=32x8, 3=8x32),
30+ exported as `stream::intra_rect4_in_inter_counters()` and printed by
31+ `examples/decode_probe`.
32+* `refusal_inventory.rs:76` -- "an intra-coded 1:4 (or other non-2:1) rect
33+ strip on the inter block path" replaced by the narrower
34+ "an intra-coded 16x4/4x16 strip on the inter block path (the 16x16-level 1:4
35+ inter partition is refused before this point)": 16x4/4x16 is unreachable
36+ because `decode.rs:20332` refuses the 16x16-level 1:4 inter partition first,
37+ and `decode_block_rect4`'s tables are 32x8-specific.
38+* `stream.rs` -- gate `a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact`
39+ (+ `_10bit`), currently `#[ignore]`d with the blocker named (see below).
40+
41+## Why the gate cannot pass on this tree (MEASURED)
42+
43+40 gate attempts per depth + ~150 recipe-sweep attempts (frame sizes 64x64,
44+96x96, 128x128, 192x128, 256x192; mandelbrot fast-zoom, static-background +
45+moving overlay, 64x16/16x64/32x8/8x32 moving bars, testsrc2; cq 35..63;
46+cpu-used 1..4; min/max-partition-size 32/32, 32/64, 64/64):
47+
48+* Every stream in which an intra 1:4 strip actually fires (counters 1..4 per
49+ stream, e.g. `32x8=4`, `64x16=2`, `16x64=3`, `8x32=4`) ALSO carries a
50+ non-skip INTER 2:1 rect strip ("a non-skip rectangular (HORZ/VERT/HORZ_B)
51+ strip needs rectangular residual coding"), an SB-level AB partition, or a
52+ sub-8 inter partition -- each another lane's named refusal, hit before the
53+ frame completes, so the attempt is never pixel-compared.
54+* Every recipe under which all attempts decode whole (`--max-partition-size=32`,
55+ or a static background with a moving overlay) fires ZERO 1:4 intra strips:
56+ aomenc only reaches for 1:4 partitions in the same neighbourhoods where it
57+ also picks the SB-level rect/AB shapes this decoder still refuses.
58+* Class [[counter-from-refused-stream]] applies: the counters above come from
59+ REFUSED streams and prove only that the new code path is entered, never that
60+ its pixels are right. The gate counts deltas on decoded+compared attempts
61+ only, which is why it currently fails/ignores rather than reading green.
62+
63+So: **un-ignore and re-run this gate once the inter rect-leaf lane (lane-r14 r3,
64+`decode.rs` var-tx leaves) lands** -- that is the refusal that aborts every
65+candidate stream.
66+
67+## Film check (his ReelB extract)
68+
69+`decode_probe scratchpad/census3/kf/seg_4500.obu` (3840x1608 yuv420p10le,
70+213 frame headers):
71+
72+* BEFORE (charter premise): stops at "an intra-coded 1:4 (or other non-2:1)
73+ rect strip on the inter block path".
74+* AFTER: `intra_rect4_in_inter: 64x16=0 16x64=4 32x8=0 8x32=0` -- four intra
75+ 16x64 strips decode -- and the stop string is now
76+ "a split intra strip whose transform unit is 64x32 (no luma coefficient
77+ tables for that shape here)" (`decode_rect_split`'s luma-shape guard: the
78+ SB-level 2:1 strip at tx depth 0, i.e. a TX_64X32 luma transform, which no
79+ path here codes). Frames decoded (EC_AV1_FINAL_DUMP file count): 1 (the head
80+ key frame) -- the new stop is still inside decode-order frame 1.
81+
82+EVIDENCE: /tmp/claude-1000/.../scratchpad/census3/kf/seg_4500.obu | decode_probe before/after the change, EC_AV1_FINAL_DUMP file count | 4 intra 16x64 strips decoded; stop string moved from the 1:4 refusal to "transform unit is 64x32"; 1 frame dumped
83+EVIDENCE: $HOME/.cache/intra14-suite-r1.log | `cargo test -p ec-av1 --lib` under a systemd unit (MemoryMax=10G) | test result: ok. 367 passed; 0 failed; 33 ignored (2 of them this lane's gate arms); 616.84s
84+
85+## Residue
86+
87+* fix-now (next round / successor lane): the gate is `#[ignore]`d. deferred --
88+ what unblocks it: the inter rect-strip refusal ("a non-skip rectangular
89+ (HORZ/VERT/HORZ_B) strip needs rectangular residual coding"), lane-r14 r3.
90+* deferred: pixel-byte compare of the film's pre-stop frames through
91+ EC_PROBE_OUT16 -- only ONE frame decodes before the stop, and it is the key
92+ frame already proven bit-exact by lane-hgkf; what unblocks a meaningful
93+ compare is the 64x32 luma transform above.
94+* accepted: `--enable-cfl-intra=0` and `--enable-palette=0` in the new gate
95+ (ledger dead-end: a new gate spelling `--enable-cfl-intra=1` retires the tool
96+ from `NEVER_EXERCISED_8BIT` on the flag alone with no CfL counter to assert;
97+ the screen-content frame is refused whole on this path, so a palette flag
98+ would buy no coverage). Deviation from the charter's flag list, stated here.
99+* accepted: `--enable-tx-size-search=0` and `--min-partition-size=32` in the
100+ gate recipe -- measured, both named in the source comments.
101+* open (NOT mine, found here): at 192x128 mandelbrot start_scale 4.76, cq 55,
102+ cpu-used 1, WITHOUT any rect/1:4 partition (`--enable-rect-partitions=0`),
103+ decode-order frame 4 mismatches ffmpeg by 3729 luma samples (max |d| = 6) and
104+ frames 5-7 drift (24k samples, max |d| ~220). Pre-existing square-path defect
105+ on this tree, unrelated to this lane.
lanes/intra14-r2.report.mdadded+101 -0
@@ -0,0 +1,101 @@
1+# lane-intra14 r2 -- merge main, un-ignore the gate, re-measure
2+
3+Branch `lane-intra14`, base main `18bf7dc`. **RED**: the r1 blocker refusal is
4+gone and the gate now reaches the pixel compare, but every compared attempt
5+mismatches on a defect this lane does not own, so the lifted refusal is still
6+**ungated** and this branch MUST NOT merge as-is.
7+
8+## 1. Merge (commit 4672212)
9+
10+`git merge --no-commit main` -- one conflict (stream.rs counter accessors,
11+resolved keeping BOTH lanes' functions: `intra_rect4_in_inter_counters` and
12+lane-r14's `rect64_inter_tu_hits`). md5 of the merged files vs main:
13+
14+| file | main | merged |
15+|---|---|---|
16+| cdf.rs (incl. NZ_MAP / FILTER_INTRA regions) | a3fb168e | a3fb168e |
17+| cdf_state.rs | 6faaa22c | 6faaa22c |
18+| encode.rs | 6c9f9f66 | 6c9f9f66 |
19+| mvstack.rs | 3ff196a2 | 3ff196a2 |
20+
21+i.e. every file this lane does not own came through byte-identical to main;
22+`decode.rs` / `refusal_inventory.rs` / `decode_probe.rs` carry only this lane's
23+additions on top of main's text (`git diff main -- <file>` reviewed hunk by hunk).
24+
25+## 2. The gate, un-ignored and re-run (8-bit, 40 attempts)
26+
27+`--exact stream::tests::a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact --nocapture`
28+
29+Before (r1 tree): 40/40 attempts refused, 0 pixel-compared.
30+After the merge: **3 attempts decode whole**, one of them firing the feature:
31+
32+* seed 52 (`--cpu-used=3 --cq-level=45`): `64x16=4 16x64=3 32x8=0 8x32=0`
33+* seed 46 (`--cpu-used=1 --cq-level=55`): `0 0 0 0`
34+* seed 54 (`--cpu-used=1 --cq-level=35`): `0 0 0 0`
35+
36+All three MISMATCH ffmpeg, and **the two zero-hit attempts mismatch exactly like
37+the firing one**: decode-order frame 3/4 luma ~3.7-4.5k samples at max |d| 6..17
38+(first diff around x=128..141, y=58..59), then frames 5-7 drift to ~24k samples
39+at max |d| ~220 as the references carry the error. So the failure is NOT the 1:4
40+strip path: it is a pre-existing INTER-frame defect of this mandelbrot 192x128
41+source on this tree -- the same one r1 already recorded as "open, NOT mine"
42+(3729 samples, max |d| = 6, with rect partitions off). Control: re-encoding the
43+seed-52 recipe with `--enable-1to4-partitions=0` yields a byte-identical stream
44+(same hits, same per-frame diff counts), so aomenc ignores that flag here and
45+the shape is not the discriminator either.
46+
47+Remaining refusals over the 40 attempts (37 of them, all other lanes' surfaces):
48+inter SB-level AB (12), inter 16x16-level AB or 1:4 (6), non-skip rect strip
49+needs rect residual coding (5), split intra strip whose TU is 32x64 / 64x32 (5),
50+inter partition below 8x8 (4), sub-8 angle delta / other (5).
51+
52+The two gate arms are therefore **`#[ignore]`d again, with the new blocker
53+measured and named in the source** (stream.rs, above both arms) instead of the
54+stale r1 reason. The gate itself is unchanged and unweakened: counters are
55+per-attempt deltas on decoded+compared attempts only, every decode-order frame
56+compared, a decode error is never a SKIP.
57+
58+### Recipe hunt for a clean-baseline source (240-recipe matrix + a 4-source probe)
59+* matrix 192x128/256x192/128x128 x min-part 16/32 x tx-size-search 0/1 x
60+ cq 63/55/45/35/25 x cpu 1..4 (98 recipes ran before the 10-min bound): exactly
61+ ONE fired 1:4 strips (192x128, min=32, txs=1, cq35, cpu2 -> `64x16=2 16x64=4`)
62+ and it mismatches (118035 samples); 7 more decoded with zero hits.
63+* `testsrc2=192x128` on the same recipe: 4 of 12 attempts decode **pixel-exact**
64+ (clean baseline) but fire zero 1:4 strips; the other 8 hit named refusals.
65+* `--enable-cfl-intra=1` was NOT re-measured -- the run budget went to the
66+ mismatch triage. deferred.
67+
68+## 3. Film check (his ReelB extract, unchanged by the merge)
69+
70+`decode_probe scratchpad/census3/kf/seg_4500.obu` (3840x1608 yuv420p10le, 213
71+frame headers): still stops at "a split intra strip whose transform unit is
72+64x32 (no luma coefficient tables for that shape here)", still decodes
73+`intra_rect4_in_inter: 64x16=0 16x64=4 32x8=0 8x32=0`. `EC_AV1_FINAL_DUMP` file
74+count is 0 (r1 measured 1 on the pre-merge tree) -- the stop is inside
75+decode-order frame 1 either way.
76+
77+EVIDENCE: $HOME/.cache/intra14-r2-fi0.log, $HOME/.cache/intra14-r2-sweep.log, $HOME/.cache/intra14-r2-src.log | un-ignored gate + 240-recipe matrix + 4-source probe under systemd-run scopes | 3/40 attempts pixel-compared (0 before the merge), seed 52 fires 64x16=4 16x64=3, and the two zero-hit attempts mismatch identically
78+EVIDENCE: scratchpad/census3/kf/seg_4500.obu | decode_probe under a 6G scope, EC_AV1_FINAL_DUMP file count | stop string unchanged ("transform unit is 64x32"), 4 intra 16x64 strips decoded, 0 frames completed
79+
80+## 4. Suite
81+
82+`cargo test -p ec-av1 --lib` under a user systemd unit (MemoryMax=10G):
83+**370 passed; 0 failed; 34 ignored** (2 of the ignored are this lane's gate
84+arms); 889.13s.
85+
86+EVIDENCE: $HOME/.cache/intra14-suite-r2.log | systemd-run --user --unit ... MemoryMax=10G, EC_NOMEMGUARD=1 EC_AV1_REQUIRE_AOMENC=1, nice -n 10 -j3 | test result: ok. 370 passed; 0 failed; 34 ignored; 889.13s
87+
88+## Residue
89+
90+* fix-now (successor / another lane): the pre-existing inter-frame pixel defect
91+ on 192x128 mandelbrot at cq 35..55, cpu 1..3 -- reproducible with ZERO 1:4
92+ strips and zero rect partitions, first divergence decode-order frame 3/4 luma
93+ around (130,58) with max |d| < 20. It is unrefused (silent), so every gate on
94+ mandelbrot inter content is measuring it. deferred -- what unblocks this lane:
95+ either that fix, or a source whose inter baseline is exact AND that fires an
96+ intra 1:4 strip.
97+* deferred: `--enable-cfl-intra=1` arm -- what unblocks it: a green gate to add
98+ it to.
99+* accepted: `--enable-filter-intra=1` stays in the recipe. An earlier r2 run with
100+ it at 0 showed zero mismatches, but only ONE stream was compared in that run,
101+ so it proves nothing; the claim is withdrawn.