Intra-coded 1:4 rect strips on the inter block path decode through the key-frame readers
Browse files at this commit44c4697a4026e1a0f663349972f133438d4fd22cParent: a13d4a2- feat
- intra-coded 1:4 rect strips on the inter block path decode through the key-frame readers
5 changed files +531 -5
- crates/ec-av1/examples/decode_probe.rs +5 -0
- crates/ec-av1/src/decode.rs +120 -4
- crates/ec-av1/src/refusal_inventory.rs +1 -1
- crates/ec-av1/src/stream.rs +300 -0
- lanes/intra14-r1.report.md +105 -0
crates/ec-av1/examples/decode_probe.rsmodified+5 -0
| @@ -33,6 +33,11 @@ fn main() { | |||
| 33 | println!("rect4_32: horz={h} vert={v} coded={c}"); | 33 | println!("rect4_32: horz={h} vert={v} coded={c}"); |
| 34 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); | 34 | let (rtu, rsplit, robmc) = ec_av1::stream::rect_inter_tu_counters(); |
| 35 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); | 35 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); |
| 36 | + let i4 = ec_av1::stream::intra_rect4_in_inter_counters(); | ||
| 37 | + println!( | ||
| 38 | + "intra_rect4_in_inter: 64x16={} 16x64={} 32x8={} 8x32={}", | ||
| 39 | + i4.0, i4.1, i4.2, i4.3 | ||
| 40 | + ); | ||
| 36 | let ir = ec_av1::stream::inter_rect_counters(); | 41 | let ir = ec_av1::stream::inter_rect_counters(); |
| 37 | println!( | 42 | println!( |
| 38 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", | 43 | "inter_rect: 32x8={} 8x32={} 64x32={} 32x64={} 64x16={} 16x64={}", |
crates/ec-av1/src/decode.rsmodified+120 -4
| @@ -1882,6 +1882,33 @@ pub(crate) fn intra_rect_strip_in_inter_hits(class: usize) -> usize { | |||
| 1882 | INTRA_RECT_IN_INTER_HITS.with(|c| c.get()[class]) | 1882 | INTRA_RECT_IN_INTER_HITS.with(|c| c.get()[class]) |
| 1883 | } | 1883 | } |
| 1884 | 1884 | ||
| 1885 | +// lane-intra14 r1: how many intra-coded 1:4 strips decoded on the INTER | ||
| 1886 | +// block path, per shape -- [0] 64x16, [1] 16x64, [2] 32x8, [3] 8x32. Every | ||
| 1887 | +// one of them was the named refusal "an intra-coded 1:4 (or other non-2:1) | ||
| 1888 | +// rect strip on the inter block path" before this round. | ||
| 1889 | +thread_local! { | ||
| 1890 | + static INTRA_RECT4_IN_INTER_HITS: std::cell::Cell<[usize; 4]> = | ||
| 1891 | + const { std::cell::Cell::new([0; 4]) }; | ||
| 1892 | +} | ||
| 1893 | + | ||
| 1894 | +/// Current value of [`INTRA_RECT4_IN_INTER_HITS`] for one shape | ||
| 1895 | +/// (0 = 64x16, 1 = 16x64, 2 = 32x8, 3 = 8x32). | ||
| 1896 | +pub(crate) fn intra_rect4_strip_in_inter_hits(shape: usize) -> usize { | ||
| 1897 | + INTRA_RECT4_IN_INTER_HITS.with(|c| c.get()[shape]) | ||
| 1898 | +} | ||
| 1899 | + | ||
| 1900 | +// lane-intra14 r1: set while an INTRA block of an INTER frame is decoded | ||
| 1901 | +// through one of the key-frame rect readers ([`decode_block_rect4`], | ||
| 1902 | +// [`decode_block_rect64`]). `Some((size_group, skip))` tells | ||
| 1903 | +// [`read_intra_mode_rect`] that (a) `skip`/segment id/cdef/delta-q were | ||
| 1904 | +// already read by [`decode_inter_block`] and (b) the luma mode comes off | ||
| 1905 | +// `y_mode_cdf[size_group_lookup[bsize]]` (libaom `read_intra_block_mode_info`, | ||
| 1906 | +// decodemv.c:1189), never the key frame's above/left `kf_y_mode` pair. | ||
| 1907 | +thread_local! { | ||
| 1908 | + static INTRA_IN_INTER_MODE: std::cell::Cell<Option<(usize, bool)>> = | ||
| 1909 | + const { std::cell::Cell::new(None) }; | ||
| 1910 | +} | ||
| 1911 | + | ||
| 1885 | // lane-rectx r5: how many times a NON-strip `kf_y_mode` reader | 1912 | // lane-rectx r5: how many times a NON-strip `kf_y_mode` reader |
| 1886 | // ([`decode_block`], [`decode_block_rect`], [`decode_block_rect64`]) took an | 1913 | // ([`decode_block`], [`decode_block_rect`], [`decode_block_rect64`]) took an |
| 1887 | // above/left mode from the mi-exact map that DIFFERS from its coarse 16x16 | 1914 | // above/left mode from the mi-exact map that DIFFERS from its coarse 16x16 |
| @@ -5312,6 +5339,13 @@ fn read_intra_mode_rect( | |||
| 5312 | } | 5339 | } |
| 5313 | }; | 5340 | }; |
| 5314 | } | 5341 | } |
| 5342 | + // lane-intra14 r1: on the INTER block path everything up to and including | ||
| 5343 | + // `is_inter` was already read by [`decode_inter_block`], so this reader | ||
| 5344 | + // starts at the mode syntax with the `skip` that caller read. | ||
| 5345 | + let inter = INTRA_IN_INTER_MODE.with(std::cell::Cell::get); | ||
| 5346 | + let skip = if let Some((_, skip)) = inter { | ||
| 5347 | + skip | ||
| 5348 | + } else { | ||
| 5315 | // Same `intra_segment_id` placement as the square reader above. | 5349 | // Same `intra_segment_id` placement as the square reader above. |
| 5316 | let (seg_w_mi, seg_h_mi) = (bw / 4, bh / 4); | 5350 | let (seg_w_mi, seg_h_mi) = (bw / 4, bh / 4); |
| 5317 | if seg_id_pre_skip() { | 5351 | if seg_id_pre_skip() { |
| @@ -5330,9 +5364,18 @@ fn read_intra_mode_rect( | |||
| 5330 | maybe_read_delta_q(dec, cdfs, mi_r, mi_c, false, skip); | 5364 | maybe_read_delta_q(dec, cdfs, mi_r, mi_c, false, skip); |
| 5331 | maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, false, skip); | 5365 | maybe_read_delta_lf(dec, cdfs, mi_r, mi_c, false, skip); |
| 5332 | istep!("dq", 0); | 5366 | istep!("dq", 0); |
| 5333 | - let above_ctx = INTRA_MODE_CTX[above_mode]; | 5367 | + skip |
| 5334 | - let left_ctx = INTRA_MODE_CTX[left_mode]; | 5368 | + }; |
| 5335 | - let mode = dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx]); | 5369 | + // libaom `read_intra_block_mode_info` (decodemv.c:1189) vs the key |
| 5370 | + // frame's `read_intra_frame_mode_info` (decodemv.c:1065 `read_intra_mode` | ||
| 5371 | + // off `kf_y_mode_cdf[above][left]`). | ||
| 5372 | + let mode = if let Some((size_group, _)) = inter { | ||
| 5373 | + dec.symbol(&mut cdfs.y_mode[size_group]) | ||
| 5374 | + } else { | ||
| 5375 | + let above_ctx = INTRA_MODE_CTX[above_mode]; | ||
| 5376 | + let left_ctx = INTRA_MODE_CTX[left_mode]; | ||
| 5377 | + dec.symbol(&mut cdfs.kf_y_mode[above_ctx][left_ctx]) | ||
| 5378 | + }; | ||
| 5336 | istep!("mode", mode as i32); | 5379 | istep!("mode", mode as i32); |
| 5337 | let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) { | 5380 | let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) { |
| 5338 | read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED]) | 5381 | read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED]) |
| @@ -5982,9 +6025,18 @@ fn decode_intra_rect_in_inter( | |||
| 5982 | (8, 16) => (1usize, 1usize), | 6025 | (8, 16) => (1usize, 1usize), |
| 5983 | (16, 32) => (2, 2), | 6026 | (16, 32) => (2, 2), |
| 5984 | (32, 64) => (3, 3), | 6027 | (32, 64) => (3, 3), |
| 6028 | + // lane-intra14 r1: the 1:4 strips, read off libaom's own tables -- | ||
| 6029 | + // `size_group_lookup` (common_data.h:61) gives BLOCK_8X32/32X8 group | ||
| 6030 | + // 1 and BLOCK_16X64/64X16 group 2, while | ||
| 6031 | + // `bsize_to_tx_size_depth_table` (blockd.h:1347) gives them depth | ||
| 6032 | + // 3 and 4, i.e. tx categories 2 and 3 -- the diagonal a 2:1 strip | ||
| 6033 | + // keeps is genuinely broken here, which is why the shape was refused | ||
| 6034 | + // rather than read from the 2:1 row. | ||
| 6035 | + (8, 32) => (1, 2), | ||
| 6036 | + (16, 64) => (2, 3), | ||
| 5985 | _ => { | 6037 | _ => { |
| 5986 | return Err(unsupported( | 6038 | return Err(unsupported( |
| 5987 | - "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", | 6039 | + "an intra-coded 16x4/4x16 strip on the inter block path (the 16x16-level 1:4 inter partition is refused before this point)", |
| 5988 | )) | 6040 | )) |
| 5989 | } | 6041 | } |
| 5990 | }; | 6042 | }; |
| @@ -5997,6 +6049,70 @@ fn decode_intra_rect_in_inter( | |||
| 5997 | is consumed for square blocks only)", | 6049 | is consumed for square blocks only)", |
| 5998 | )); | 6050 | )); |
| 5999 | } | 6051 | } |
| 6052 | + // lane-intra14 r1: a 1:4 strip decodes through the very readers the KEY | ||
| 6053 | + // FRAME path already proves for this shape ([`decode_block_rect4`] at the | ||
| 6054 | + // 32 level, [`decode_block_rect64`] at 64 -- both already handle the 1:4 | ||
| 6055 | + // luma/chroma transform tables, the per-unit split walk and the strip's | ||
| 6056 | + // own neighbour records). The ONLY difference on an inter frame is the | ||
| 6057 | + // mode-info read, which [`INTRA_IN_INTER_MODE`] switches to | ||
| 6058 | + // `read_intra_block_mode_info`'s `y_mode[size_group]` plus the `skip` | ||
| 6059 | + // this caller already read. `tx_cat` above is the same category those | ||
| 6060 | + // readers hardcode (cat 2 in `decode_block_rect4`, cat 3 in | ||
| 6061 | + // `decode_block_rect64`), asserted here so a future shape cannot drift. | ||
| 6062 | + if bw.max(bh) == 4 * bw.min(bh) { | ||
| 6063 | + debug_assert_eq!(tx_cat, if bw.max(bh) == 64 { 3 } else { 2 }); | ||
| 6064 | + INTRA_IN_INTER_MODE.with(|c| c.set(Some((size_group, skip)))); | ||
| 6065 | + let res = if bw.max(bh) == 64 { | ||
| 6066 | + decode_block_rect64( | ||
| 6067 | + dec, | ||
| 6068 | + cdfs, | ||
| 6069 | + neighbours, | ||
| 6070 | + (mi_r / (SUB / MI), mi_c / (SUB / MI)), | ||
| 6071 | + bw, | ||
| 6072 | + bh, | ||
| 6073 | + y, | ||
| 6074 | + u, | ||
| 6075 | + v, | ||
| 6076 | + ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get), | ||
| 6077 | + allow_screen_content_tools, | ||
| 6078 | + base_q_idx, | ||
| 6079 | + TX_SELECT_INTER.with(std::cell::Cell::get), | ||
| 6080 | + REDUCED_TX_SET_INTER.with(std::cell::Cell::get), | ||
| 6081 | + ) | ||
| 6082 | + } else { | ||
| 6083 | + decode_block_rect4( | ||
| 6084 | + dec, | ||
| 6085 | + cdfs, | ||
| 6086 | + neighbours, | ||
| 6087 | + (mi_r, mi_c), | ||
| 6088 | + bw, | ||
| 6089 | + bh, | ||
| 6090 | + None, | ||
| 6091 | + y, | ||
| 6092 | + u, | ||
| 6093 | + v, | ||
| 6094 | + ENABLE_FILTER_INTRA_INTER.with(std::cell::Cell::get), | ||
| 6095 | + allow_screen_content_tools, | ||
| 6096 | + base_q_idx, | ||
| 6097 | + TX_SELECT_INTER.with(std::cell::Cell::get), | ||
| 6098 | + ) | ||
| 6099 | + .map(|_| ()) | ||
| 6100 | + }; | ||
| 6101 | + INTRA_IN_INTER_MODE.with(|c| c.set(None)); | ||
| 6102 | + res?; | ||
| 6103 | + let shape = match (bw, bh) { | ||
| 6104 | + (64, 16) => 0, | ||
| 6105 | + (16, 64) => 1, | ||
| 6106 | + (32, 8) => 2, | ||
| 6107 | + _ => 3, | ||
| 6108 | + }; | ||
| 6109 | + INTRA_RECT4_IN_INTER_HITS.with(|h| { | ||
| 6110 | + let mut v = h.get(); | ||
| 6111 | + v[shape] += 1; | ||
| 6112 | + h.set(v); | ||
| 6113 | + }); | ||
| 6114 | + return Ok(()); | ||
| 6115 | + } | ||
| 6000 | let mode = dec.symbol(&mut cdfs.y_mode[size_group]); | 6116 | let mode = dec.symbol(&mut cdfs.y_mode[size_group]); |
| 6001 | if mode >= 13 { | 6117 | if mode >= 13 { |
| 6002 | return Err(unsupported( | 6118 | return Err(unsupported( |
crates/ec-av1/src/refusal_inventory.rsmodified+1 -1
| @@ -73,7 +73,7 @@ const REFUSALS: &[&str] = &[ | |||
| 73 | // inter path's intra arm now routes 2:1 strips through `decode_rect_split`); | 73 | // inter path's intra arm now routes 2:1 strips through `decode_rect_split`); |
| 74 | // what is left is the 1:4 shape, whose `bsize_to_tx_size_cat` breaks the | 74 | // what is left is the 1:4 shape, whose `bsize_to_tx_size_cat` breaks the |
| 75 | // size-group/category diagonal the 2:1 shapes share. | 75 | // size-group/category diagonal the 2:1 shapes share. |
| 76 | - "an intra-coded 1:4 (or other non-2:1) rect strip on the inter block path", | 76 | + "an intra-coded 16x4/4x16 strip on the inter block path (the 16x16-level 1:4 inter partition is refused before this point)", |
| 77 | "a split (nonzero tx_depth) transform on an intra HORZ/VERT strip in an inter frame", | 77 | "a split (nonzero tx_depth) transform on an intra HORZ/VERT strip in an inter frame", |
| 78 | // The same arm's screen-content gate: palette/intrabc syntax is consumed | 78 | // The same arm's screen-content gate: palette/intrabc syntax is consumed |
| 79 | // for square blocks only, so a strip in such a frame would skip symbols. | 79 | // for square blocks only, so a strip in such a frame would skip symbols. |
crates/ec-av1/src/stream.rsmodified+300 -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 | pub fn rect4_32_counters() -> (usize, usize, usize) { | 83 | pub fn rect4_32_counters() -> (usize, usize, usize) { |
| 72 | ( | 84 | ( |
| 73 | crate::decode::rect4_32_horz_hits(), | 85 | crate::decode::rect4_32_horz_hits(), |
| @@ -4570,6 +4582,294 @@ mod tests { | |||
| 4570 | ); | 4582 | ); |
| 4571 | } | 4583 | } |
| 4572 | 4584 | ||
| 4585 | + /// lane-intra14 r1's decisive gate: a real aomenc INTER sequence with | ||
| 4586 | + /// `--enable-1to4-partitions=1`, whose fast-zooming content makes aomenc | ||
| 4587 | + /// code INTRA blocks inside inter frames on 1:4 strip shapes (32x8/8x32 at | ||
| 4588 | + /// the 32 level, 64x16/16x64 at the superblock level). Every such block | ||
| 4589 | + /// was the named refusal "an intra-coded 1:4 (or other non-2:1) rect strip | ||
| 4590 | + /// on the inter block path" until this round; they now decode through the | ||
| 4591 | + /// same `decode_block_rect4` / `decode_block_rect64` readers the KEY FRAME | ||
| 4592 | + /// 1:4 paths already prove, with only the mode-info read switched to | ||
| 4593 | + /// `read_intra_block_mode_info` (libaom decodemv.c:1189). | ||
| 4594 | + /// | ||
| 4595 | + /// Hard-asserts `intra_rect4_strip_in_inter_hits` (0 = 64x16, 1 = 16x64, | ||
| 4596 | + /// 2 = 32x8, 3 = 8x32) summed over the attempts that were actually | ||
| 4597 | + /// pixel-compared, and every decode-order frame is compared. A decode that | ||
| 4598 | + /// succeeds is ALWAYS pixel-compared (class | ||
| 4599 | + /// [[gate-skips-on-its-own-failure]]); exhausting every attempt without a | ||
| 4600 | + /// counted strip is a FAILURE, never a SKIP. | ||
| 4601 | + #[test] | ||
| 4602 | + // MEASURED (r1, 40 gate attempts + 150 recipe-sweep attempts, see | ||
| 4603 | + // lanes/intra14-r1.report.md): on THIS tree every aomenc stream that | ||
| 4604 | + // carries an intra 1:4 strip inside an inter frame ALSO carries a | ||
| 4605 | + // non-skip INTER 2:1 rect strip / SB-level AB partition / sub-8 inter | ||
| 4606 | + // partition, each refused by name by another lane's surface before the | ||
| 4607 | + // frame completes -- so no attempt can be pixel-compared yet and this | ||
| 4608 | + // gate cannot pass. It is `#[ignore]`d rather than weakened; un-ignore | ||
| 4609 | + // it (and re-run) once the inter rect-leaf lane lands. | ||
| 4610 | + #[ignore = "blocked: every stream with an intra 1:4 strip also hits the inter rect-strip refusal"] | ||
| 4611 | + fn a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact() { | ||
| 4612 | + intra_rect4_in_inter_gate(8); | ||
| 4613 | + } | ||
| 4614 | + | ||
| 4615 | + /// The 10-bit arm (both of the user's films are `yuv420p10le`). | ||
| 4616 | + #[test] | ||
| 4617 | + // MEASURED (r1, 40 gate attempts + 150 recipe-sweep attempts, see | ||
| 4618 | + // lanes/intra14-r1.report.md): on THIS tree every aomenc stream that | ||
| 4619 | + // carries an intra 1:4 strip inside an inter frame ALSO carries a | ||
| 4620 | + // non-skip INTER 2:1 rect strip / SB-level AB partition / sub-8 inter | ||
| 4621 | + // partition, each refused by name by another lane's surface before the | ||
| 4622 | + // frame completes -- so no attempt can be pixel-compared yet and this | ||
| 4623 | + // gate cannot pass. It is `#[ignore]`d rather than weakened; un-ignore | ||
| 4624 | + // it (and re-run) once the inter rect-leaf lane lands. | ||
| 4625 | + #[ignore = "blocked: every stream with an intra 1:4 strip also hits the inter rect-strip refusal"] | ||
| 4626 | + fn a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact_10bit() { | ||
| 4627 | + intra_rect4_in_inter_gate(10); | ||
| 4628 | + } | ||
| 4629 | + | ||
| 4630 | + fn intra_rect4_in_inter_gate(bit_depth: u32) { | ||
| 4631 | + const NAME: &str = | ||
| 4632 | + "a_real_aomenc_inter_sequence_with_an_intra_1to4_strip_decodes_pixel_exact"; | ||
| 4633 | + if !have_ffmpeg() { | ||
| 4634 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 4635 | + return; | ||
| 4636 | + } | ||
| 4637 | + if !have_aomenc() { | ||
| 4638 | + eprintln!("SKIP {NAME}: no aomenc at {}", aomenc_path().display()); | ||
| 4639 | + return; | ||
| 4640 | + } | ||
| 4641 | + let (width, height, frame_count) = (192usize, 128usize, 8usize); | ||
| 4642 | + let mut refusals: Vec<String> = Vec::new(); | ||
| 4643 | + let mut uncounted_exact = 0u32; | ||
| 4644 | + let mut compared = 0u32; | ||
| 4645 | + let mut shapes = [0usize; 4]; | ||
| 4646 | + for attempt in 0..40u32 { | ||
| 4647 | + let seed = 42 + attempt; | ||
| 4648 | + // Same source class as the 2:1 sibling gate: a FAST mandelbrot | ||
| 4649 | + // zoom (`end_scale`/`end_pts`) so consecutive frames share almost | ||
| 4650 | + // no content and aomenc's RD codes blocks INTRA inside INTER | ||
| 4651 | + // frames, with `--kf-min-dist=1000` forbidding a new key frame. | ||
| 4652 | + let source = format!( | ||
| 4653 | + "mandelbrot=size={width}x{height}:start_scale={}:end_scale=0.004:end_pts=8:rate=25", | ||
| 4654 | + 5.0 - f64::from(attempt) * 0.06 | ||
| 4655 | + ); | ||
| 4656 | + let y4m = Command::new("ffmpeg") | ||
| 4657 | + .args([ | ||
| 4658 | + "-v", "error", "-f", "lavfi", "-i", &source, "-vf", "hue=s=0", "-pix_fmt", | ||
| 4659 | + if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, | ||
| 4660 | + "-strict", "-1", "-t", "0.32", "-f", "yuv4mpegpipe", "-strict", "-1", "-", | ||
| 4661 | + ]) | ||
| 4662 | + .stdin(Stdio::null()) | ||
| 4663 | + .stdout(Stdio::piped()) | ||
| 4664 | + .stderr(Stdio::piped()) | ||
| 4665 | + .output() | ||
| 4666 | + .expect("ffmpeg failed to run"); | ||
| 4667 | + assert!( | ||
| 4668 | + y4m.status.success(), | ||
| 4669 | + "ffmpeg fixture: {}", | ||
| 4670 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 4671 | + ); | ||
| 4672 | + let depth_args: &[&str] = if bit_depth == 10 { | ||
| 4673 | + &["-b", "10", "--input-bit-depth=10"] | ||
| 4674 | + } else { | ||
| 4675 | + &[] | ||
| 4676 | + }; | ||
| 4677 | + // MEASURED (r1, 40 attempts): `--cpu-used=0` makes aomenc pick | ||
| 4678 | + // 128x128 superblocks on this frame size, which decode_stream | ||
| 4679 | + // refuses by name, so the preset sweep starts at 1. | ||
| 4680 | + let cpu = format!("--cpu-used={}", 1 + attempt % 4); | ||
| 4681 | + // The higher the quantiser the more 1:4 intra strips inside inter | ||
| 4682 | + // frames, so the sweep walks cq 63 first. | ||
| 4683 | + let cq = format!("--cq-level={}", [63u32, 55, 45, 35][(attempt / 4) as usize % 4]); | ||
| 4684 | + let mut child = Command::new(aomenc_path()) | ||
| 4685 | + .args(depth_args) | ||
| 4686 | + .arg(&cpu) | ||
| 4687 | + .arg(&cq) | ||
| 4688 | + .args([ | ||
| 4689 | + // Every flag spelled exactly once (class | ||
| 4690 | + // [[aomenc-last-flag-wins]]). These are what the gate is | ||
| 4691 | + // about: 1:4 partitions ON, min size 16 so the 16x16-level | ||
| 4692 | + // 1:4 (refused elsewhere) is out of reach. | ||
| 4693 | + "--enable-rect-partitions=1", | ||
| 4694 | + "--enable-1to4-partitions=1", | ||
| 4695 | + // MEASURED (r1): at `--min-partition-size=16` aomenc codes | ||
| 4696 | + // 16x16-level 1:4 partitions (16x4/4x16 strips), which the | ||
| 4697 | + // inter partition path refuses by name (another lane's | ||
| 4698 | + // surface) in 12/40 attempts. 32 keeps this gate's two | ||
| 4699 | + // reachable levels -- the 32-level 32x8/8x32 and the | ||
| 4700 | + // superblock-level 64x16/16x64 -- and nothing else. | ||
| 4701 | + "--min-partition-size=32", | ||
| 4702 | + "--max-partition-size=64", | ||
| 4703 | + // MEASURED (r1): with tx-size search ON, 8/40 attempts stop | ||
| 4704 | + // at the 2:1 strip's own split-tx refusal (merge-cross-product, | ||
| 4705 | + // another lane's surface) before a 1:4 strip is reached. | ||
| 4706 | + "--enable-tx-size-search=0", | ||
| 4707 | + "--enable-filter-intra=1", | ||
| 4708 | + "--enable-intra-edge-filter=1", | ||
| 4709 | + "--codec=av1", | ||
| 4710 | + "--passes=1", | ||
| 4711 | + "--end-usage=q", | ||
| 4712 | + "--lag-in-frames=0", | ||
| 4713 | + "--auto-alt-ref=0", | ||
| 4714 | + "--kf-min-dist=1000", | ||
| 4715 | + "--kf-max-dist=1000", | ||
| 4716 | + "--threads=1", | ||
| 4717 | + "--row-mt=0", | ||
| 4718 | + "--enable-order-hint=0", | ||
| 4719 | + "--enable-warped-motion=0", | ||
| 4720 | + "--enable-obmc=0", | ||
| 4721 | + "--enable-masked-comp=0", | ||
| 4722 | + "--enable-interintra-comp=0", | ||
| 4723 | + "--enable-dist-wtd-comp=0", | ||
| 4724 | + "--enable-diff-wtd-comp=0", | ||
| 4725 | + "--enable-onesided-comp=0", | ||
| 4726 | + "--enable-interintra-wedge=0", | ||
| 4727 | + "--enable-smooth-interintra=0", | ||
| 4728 | + "--enable-ab-partitions=0", | ||
| 4729 | + "--enable-smooth-intra=0", | ||
| 4730 | + "--enable-paeth-intra=0", | ||
| 4731 | + "--enable-directional-intra=0", | ||
| 4732 | + "--enable-angle-delta=0", | ||
| 4733 | + "--enable-cdef=0", | ||
| 4734 | + "--enable-restoration=0", | ||
| 4735 | + // Ledger dead-end (lane-r14): a NEW gate spelling | ||
| 4736 | + // `--enable-cfl-intra=1` retires that tool from | ||
| 4737 | + // `NEVER_EXERCISED_8BIT` on the flag alone while no CfL | ||
| 4738 | + // hit counter exists to assert -- so it stays 0 here. | ||
| 4739 | + // Palette stays 0 for the same class of reason: this arm | ||
| 4740 | + // refuses a screen-content frame whole, so a palette flag | ||
| 4741 | + // would buy no coverage. | ||
| 4742 | + "--enable-palette=0", | ||
| 4743 | + "--enable-intrabc=0", | ||
| 4744 | + "--enable-cfl-intra=0", | ||
| 4745 | + "--enable-ref-frame-mvs=0", | ||
| 4746 | + "--obu", | ||
| 4747 | + "-o", | ||
| 4748 | + "-", | ||
| 4749 | + "-", | ||
| 4750 | + ]) | ||
| 4751 | + .stdin(Stdio::piped()) | ||
| 4752 | + .stdout(Stdio::piped()) | ||
| 4753 | + .stderr(Stdio::piped()) | ||
| 4754 | + .spawn() | ||
| 4755 | + .expect("aomenc failed to start"); | ||
| 4756 | + child | ||
| 4757 | + .stdin | ||
| 4758 | + .take() | ||
| 4759 | + .expect("aomenc stdin") | ||
| 4760 | + .write_all(&y4m.stdout) | ||
| 4761 | + .expect("writing y4m to aomenc"); | ||
| 4762 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 4763 | + assert!( | ||
| 4764 | + out.status.success(), | ||
| 4765 | + "aomenc refused the fixture: {}", | ||
| 4766 | + String::from_utf8_lossy(&out.stderr) | ||
| 4767 | + ); | ||
| 4768 | + let stream = out.stdout; | ||
| 4769 | + let before: Vec<usize> = | ||
| 4770 | + (0..4).map(decode::intra_rect4_strip_in_inter_hits).collect(); | ||
| 4771 | + let frames = match decode_stream(&stream) { | ||
| 4772 | + Ok(frames) => frames, | ||
| 4773 | + Err(e) => { | ||
| 4774 | + let msg = e.to_string(); | ||
| 4775 | + assert!( | ||
| 4776 | + msg.contains("unsupported"), | ||
| 4777 | + "intra-1:4-in-inter decode failed outright (seed {seed}): {msg}" | ||
| 4778 | + ); | ||
| 4779 | + refusals.push(format!("seed {seed} {cpu} {cq}: {msg}")); | ||
| 4780 | + continue; | ||
| 4781 | + } | ||
| 4782 | + }; | ||
| 4783 | + let delta: Vec<usize> = (0..4) | ||
| 4784 | + .map(|k| decode::intra_rect4_strip_in_inter_hits(k) - before[k]) | ||
| 4785 | + .collect(); | ||
| 4786 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 4787 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 4788 | + } else { | ||
| 4789 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 4790 | + }; | ||
| 4791 | + assert_eq!(frames.len(), frame_count); | ||
| 4792 | + eprintln!( | ||
| 4793 | + "intra14 gate {bit_depth}-bit seed={seed} {cpu} {cq}: intra 1:4 strips in inter \ | ||
| 4794 | + frames 64x16={} 16x64={} 32x8={} 8x32={}", | ||
| 4795 | + delta[0], delta[1], delta[2], delta[3] | ||
| 4796 | + ); | ||
| 4797 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 4798 | + for (plane, (g, w)) in [ | ||
| 4799 | + ("Y", (&got.y, &want.y)), | ||
| 4800 | + ("U", (&got.u, &want.u)), | ||
| 4801 | + ("V", (&got.v, &want.v)), | ||
| 4802 | + ] { | ||
| 4803 | + let stride = if plane == "Y" { width } else { width / 2 }; | ||
| 4804 | + if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { | ||
| 4805 | + let maxd = g | ||
| 4806 | + .iter() | ||
| 4807 | + .zip(w.iter()) | ||
| 4808 | + .map(|(a, b)| i32::from(*a).abs_diff(i32::from(*b))) | ||
| 4809 | + .max() | ||
| 4810 | + .unwrap_or(0); | ||
| 4811 | + eprintln!( | ||
| 4812 | + "intra14 gate {bit_depth}-bit seed={seed}: frame {i} {plane} first \ | ||
| 4813 | + diff at ({}, {}) got {} want {} ({} samples differ, max |d|={maxd})", | ||
| 4814 | + at % stride, | ||
| 4815 | + at / stride, | ||
| 4816 | + g[at], | ||
| 4817 | + w[at], | ||
| 4818 | + g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), | ||
| 4819 | + ); | ||
| 4820 | + } | ||
| 4821 | + assert_eq!(g, w, "{plane} vs ffmpeg (seed {seed}, frame {i})"); | ||
| 4822 | + } | ||
| 4823 | + } | ||
| 4824 | + compared += 1; | ||
| 4825 | + if delta.iter().all(|d| *d == 0) { | ||
| 4826 | + uncounted_exact += 1; | ||
| 4827 | + refusals.push(format!( | ||
| 4828 | + "seed {seed} {cpu} {cq}: decoded and pixel-compared, but no intra 1:4 strip on \ | ||
| 4829 | + the inter path" | ||
| 4830 | + )); | ||
| 4831 | + } | ||
| 4832 | + for k in 0..4 { | ||
| 4833 | + shapes[k] += delta[k]; | ||
| 4834 | + } | ||
| 4835 | + // Both LEVELS (32 and 64) is the bar; orientation is whichever the | ||
| 4836 | + // encoder picks. | ||
| 4837 | + if shapes[0] + shapes[1] > 0 && shapes[2] + shapes[3] > 0 { | ||
| 4838 | + break; | ||
| 4839 | + } | ||
| 4840 | + } | ||
| 4841 | + gate_buckets( | ||
| 4842 | + NAME, | ||
| 4843 | + compared - uncounted_exact, | ||
| 4844 | + uncounted_exact, | ||
| 4845 | + refusals.len() - uncounted_exact as usize, | ||
| 4846 | + ); | ||
| 4847 | + eprintln!( | ||
| 4848 | + "{NAME} ({bit_depth}-bit): compared {compared} streams, intra 1:4 strips in inter \ | ||
| 4849 | + frames: 64x16={} 16x64={} 32x8={} 8x32={}; refusals:\n{}", | ||
| 4850 | + shapes[0], | ||
| 4851 | + shapes[1], | ||
| 4852 | + shapes[2], | ||
| 4853 | + shapes[3], | ||
| 4854 | + refusals.join("\n") | ||
| 4855 | + ); | ||
| 4856 | + assert!( | ||
| 4857 | + compared > 0, | ||
| 4858 | + "{NAME} ({bit_depth}-bit): every attempt hit a named refusal -- nothing was \ | ||
| 4859 | + pixel-compared:\n{}", | ||
| 4860 | + refusals.join("\n") | ||
| 4861 | + ); | ||
| 4862 | + assert!( | ||
| 4863 | + shapes[2] + shapes[3] > 0, | ||
| 4864 | + "{NAME} ({bit_depth}-bit): no 32-level intra 1:4 strip (32x8/8x32) fired over \ | ||
| 4865 | + {compared} compared streams (64x16={} 16x64={} 32x8={} 8x32={})", | ||
| 4866 | + shapes[0], | ||
| 4867 | + shapes[1], | ||
| 4868 | + shapes[2], | ||
| 4869 | + shapes[3] | ||
| 4870 | + ); | ||
| 4871 | + } | ||
| 4872 | + | ||
| 4573 | fn tx_select_inter_gate(bit_depth: u32) { | 4873 | fn tx_select_inter_gate(bit_depth: u32) { |
| 4574 | if !have_ffmpeg() { | 4874 | if !have_ffmpeg() { |
| 4575 | eprintln!( | 4875 | 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 | see totals below | ||
| 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. | ||