Merge branch 'lane-angleinter': intra blocks in inter frames read and apply angle deltas (the 'encoder never writes one' claim was false)
Browse files at this commit5 changed files +455 -34
- crates/ec-av1/src/decode.rs +82 -25
- crates/ec-av1/src/gate_coverage.rs +0 -8
- crates/ec-av1/src/refusal_inventory.rs +1 -1
- crates/ec-av1/src/stream.rs +267 -0
- lanes/angleinter-r1.report.md +105 -0
crates/ec-av1/src/decode.rsmodified+82 -25
| @@ -85,6 +85,27 @@ pub(crate) fn intra_in_inter_filter_intra_hits() -> usize { | |||
| 85 | INTRA_IN_INTER_FILTER_INTRA_HITS.with(|c| c.get()) | 85 | INTRA_IN_INTER_FILTER_INTRA_HITS.with(|c| c.get()) |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | +// lane-angleinter r1: how many INTRA blocks inside an INTER frame carried a | ||
| 89 | +// nonzero `angle_delta_y` / `angle_delta_uv` (`read_intra_angle_info`). Both | ||
| 90 | +// arms refused a nonzero luma delta before this round, and no inter gate | ||
| 91 | +// enabled `--enable-angle-delta` (aomenc's own default is 1). | ||
| 92 | +thread_local! { | ||
| 93 | + static INTRA_IN_INTER_ANGLE_DELTA_Y_HITS: std::cell::Cell<usize> = | ||
| 94 | + const { std::cell::Cell::new(0) }; | ||
| 95 | + static INTRA_IN_INTER_ANGLE_DELTA_UV_HITS: std::cell::Cell<usize> = | ||
| 96 | + const { std::cell::Cell::new(0) }; | ||
| 97 | +} | ||
| 98 | + | ||
| 99 | +/// Current value of [`INTRA_IN_INTER_ANGLE_DELTA_Y_HITS`]. | ||
| 100 | +pub(crate) fn intra_in_inter_angle_delta_y_hits() -> usize { | ||
| 101 | + INTRA_IN_INTER_ANGLE_DELTA_Y_HITS.with(|c| c.get()) | ||
| 102 | +} | ||
| 103 | + | ||
| 104 | +/// Current value of [`INTRA_IN_INTER_ANGLE_DELTA_UV_HITS`]. | ||
| 105 | +pub(crate) fn intra_in_inter_angle_delta_uv_hits() -> usize { | ||
| 106 | + INTRA_IN_INTER_ANGLE_DELTA_UV_HITS.with(|c| c.get()) | ||
| 107 | +} | ||
| 108 | + | ||
| 88 | // lane-realworld r1: this frame's `cdef.bits` (spec 5.9.19), threaded into | 109 | // lane-realworld r1: this frame's `cdef.bits` (spec 5.9.19), threaded into |
| 89 | // [`maybe_read_cdef_idx`] the same way [`ENABLE_EDGE_FILTER`] threads a | 110 | // [`maybe_read_cdef_idx`] the same way [`ENABLE_EDGE_FILTER`] threads a |
| 90 | // frame-level flag through the recursive block decode -- `0` (the default) | 111 | // frame-level flag through the recursive block decode -- `0` (the default) |
| @@ -16081,14 +16102,29 @@ fn decode_inter_block( | |||
| 16081 | "an intra mode this decoder does not code (round 2)", | 16102 | "an intra mode this decoder does not code (round 2)", |
| 16082 | )); | 16103 | )); |
| 16083 | } | 16104 | } |
| 16084 | - if (V_PRED..=D67_PRED).contains(&mode) { | 16105 | + // lane-angleinter r1: `read_intra_angle_info` (libaom `decodemv.c`, |
| 16085 | - let angle = dec.symbol(&mut cdfs.angle_delta[mode - V_PRED]); | 16106 | + // inside `read_intra_block_mode_info`) -- an intra block in an inter |
| 16086 | - if angle != ANGLE_DELTA_ZERO { | 16107 | + // frame reads `angle_delta_y` off the same |
| 16087 | - return Err(unsupported( | 16108 | + // `angle_delta_cdf[mode - V_PRED]` row a key-frame block does, and |
| 16088 | - "a nonzero angle delta (this encoder never writes one)", | 16109 | + // the delta feeds the directional predictor (and the edge |
| 16089 | - )); | 16110 | + // filter/upsample decision derived from the delta'd angle) unchanged. |
| 16090 | - } | 16111 | + // The symbol was read and then refused before this round even though |
| 16091 | - } | 16112 | + // aomenc enables `--enable-angle-delta` by default. |
| 16113 | + let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) { | ||
| 16114 | + read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED]) | ||
| 16115 | + } else { | ||
| 16116 | + 0 | ||
| 16117 | + }; | ||
| 16118 | + if angle_delta_y != 0 { | ||
| 16119 | + INTRA_IN_INTER_ANGLE_DELTA_Y_HITS.with(|c| c.set(c.get() + 1)); | ||
| 16120 | + } | ||
| 16121 | + // The delta'd angle decides whether the intra edge filter runs at | ||
| 16122 | + // all, so this block needs the same luma edge-filter-type neighbour | ||
| 16123 | + // check a key-frame block does (`get_intra_edge_filter_type`, spec | ||
| 16124 | + // 7.11.2) -- this arm passed a hardcoded `false` while every | ||
| 16125 | + // directional intra-in-inter block was refused above. | ||
| 16126 | + let (nb_above_mode, nb_left_mode) = neighbours.modes_above_left(r, c); | ||
| 16127 | + let smooth_neighbor = is_smooth_mode(nb_above_mode) || is_smooth_mode(nb_left_mode); | ||
| 16092 | let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]); | 16128 | let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]); |
| 16093 | if (9..=12).contains(&uv_mode) { | 16129 | if (9..=12).contains(&uv_mode) { |
| 16094 | SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); | 16130 | SMOOTH_UV_HITS.with(|c| c.set(c.get() + 1)); |
| @@ -16112,6 +16148,7 @@ fn decode_inter_block( | |||
| 16112 | }; | 16148 | }; |
| 16113 | if angle_delta_uv != 0 { | 16149 | if angle_delta_uv != 0 { |
| 16114 | UV_ANGLE_DELTA_HITS.with(|c| c.set(c.get() + 1)); | 16150 | UV_ANGLE_DELTA_HITS.with(|c| c.set(c.get() + 1)); |
| 16151 | + INTRA_IN_INTER_ANGLE_DELTA_UV_HITS.with(|c| c.set(c.get() + 1)); | ||
| 16115 | } | 16152 | } |
| 16116 | uv_predict_mode = if uv_mode == UV_CFL_PRED { | 16153 | uv_predict_mode = if uv_mode == UV_CFL_PRED { |
| 16117 | DC_PRED | 16154 | DC_PRED |
| @@ -16223,12 +16260,12 @@ fn decode_inter_block( | |||
| 16223 | tu_py, | 16260 | tu_py, |
| 16224 | tx_px, | 16261 | tx_px, |
| 16225 | mode, | 16262 | mode, |
| 16226 | - 0, | 16263 | + angle_delta_y, |
| 16227 | tu_reach, | 16264 | tu_reach, |
| 16228 | &vec![0i32; tx_px * tx_px], | 16265 | &vec![0i32; tx_px * tx_px], |
| 16229 | None, | 16266 | None, |
| 16230 | filter_intra, | 16267 | filter_intra, |
| 16231 | - false, | 16268 | + smooth_neighbor, |
| 16232 | ); | 16269 | ); |
| 16233 | vec![0i32; tx_px * tx_px] | 16270 | vec![0i32; tx_px * tx_px] |
| 16234 | } else { | 16271 | } else { |
| @@ -16245,7 +16282,7 @@ fn decode_inter_block( | |||
| 16245 | neighbours.around_mi(tu_mi, tx_px)[0], | 16282 | neighbours.around_mi(tu_mi, tx_px)[0], |
| 16246 | mode, | 16283 | mode, |
| 16247 | mode, | 16284 | mode, |
| 16248 | - 0, | 16285 | + angle_delta_y, |
| 16249 | tu_reach, | 16286 | tu_reach, |
| 16250 | y, | 16287 | y, |
| 16251 | tu_px, | 16288 | tu_px, |
| @@ -16256,7 +16293,7 @@ fn decode_inter_block( | |||
| 16256 | None, | 16293 | None, |
| 16257 | filter_intra, | 16294 | filter_intra, |
| 16258 | Some(tu_skip_ctx), | 16295 | Some(tu_skip_ctx), |
| 16259 | - false, | 16296 | + smooth_neighbor, |
| 16260 | )? | 16297 | )? |
| 16261 | }; | 16298 | }; |
| 16262 | neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid); | 16299 | neighbours.record_mi_luma(tu_mi, tx_px, &tu_grid); |
| @@ -16269,12 +16306,12 @@ fn decode_inter_block( | |||
| 16269 | py, | 16306 | py, |
| 16270 | side, | 16307 | side, |
| 16271 | mode, | 16308 | mode, |
| 16272 | - 0, | 16309 | + angle_delta_y, |
| 16273 | reach, | 16310 | reach, |
| 16274 | &vec![0i32; side * side], | 16311 | &vec![0i32; side * side], |
| 16275 | None, | 16312 | None, |
| 16276 | filter_intra, | 16313 | filter_intra, |
| 16277 | - false, | 16314 | + smooth_neighbor, |
| 16278 | ); | 16315 | ); |
| 16279 | } | 16316 | } |
| 16280 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | 16317 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); |
| @@ -16322,7 +16359,7 @@ fn decode_inter_block( | |||
| 16322 | around[0], | 16359 | around[0], |
| 16323 | mode, | 16360 | mode, |
| 16324 | mode, | 16361 | mode, |
| 16325 | - 0, | 16362 | + angle_delta_y, |
| 16326 | reach, | 16363 | reach, |
| 16327 | y, | 16364 | y, |
| 16328 | px, | 16365 | px, |
| @@ -16333,7 +16370,7 @@ fn decode_inter_block( | |||
| 16333 | None, | 16370 | None, |
| 16334 | filter_intra, | 16371 | filter_intra, |
| 16335 | None, | 16372 | None, |
| 16336 | - false, | 16373 | + smooth_neighbor, |
| 16337 | )? | 16374 | )? |
| 16338 | }; | 16375 | }; |
| 16339 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); | 16376 | let ac = alpha.map(|_| cfl_ac_q3(y, px, py, side)); |
| @@ -17722,13 +17759,33 @@ fn decode_inter_block8( | |||
| 17722 | "an intra mode this decoder does not code (round 2)", | 17759 | "an intra mode this decoder does not code (round 2)", |
| 17723 | )); | 17760 | )); |
| 17724 | } | 17761 | } |
| 17725 | - if (V_PRED..=D67_PRED).contains(&mode) { | 17762 | + // lane-angleinter r1: `read_intra_angle_info` (libaom `decodemv.c`, |
| 17726 | - let angle = dec.symbol(&mut cdfs.angle_delta[mode - V_PRED]); | 17763 | + // inside `read_intra_block_mode_info`) -- an intra block in an inter |
| 17727 | - if angle != ANGLE_DELTA_ZERO { | 17764 | + // frame reads `angle_delta_y` off the same |
| 17728 | - return Err(unsupported( | 17765 | + // `angle_delta_cdf[mode - V_PRED]` row a key-frame block does, and |
| 17729 | - "a nonzero angle delta (this encoder never writes one)", | 17766 | + // the delta feeds the directional predictor (and the edge |
| 17730 | - )); | 17767 | + // filter/upsample decision derived from the delta'd angle) unchanged. |
| 17731 | - } | 17768 | + // The symbol was read and then refused before this round even though |
| 17769 | + // aomenc enables `--enable-angle-delta` by default. | ||
| 17770 | + let angle_delta_y = if (V_PRED..=D67_PRED).contains(&mode) { | ||
| 17771 | + read_angle_delta(dec, &mut cdfs.angle_delta[mode - V_PRED]) | ||
| 17772 | + } else { | ||
| 17773 | + 0 | ||
| 17774 | + }; | ||
| 17775 | + if angle_delta_y != 0 { | ||
| 17776 | + INTRA_IN_INTER_ANGLE_DELTA_Y_HITS.with(|c| c.set(c.get() + 1)); | ||
| 17777 | + // lane-angleinter r1: the >=16x16 arm's lift is gated by a real | ||
| 17778 | + // aomenc stream; this leaf's is NOT -- 80 attempts across two | ||
| 17779 | + // sizes and five quantisers never produced an 8x8 intra leaf with | ||
| 17780 | + // a nonzero delta (the leaf's own sibling refusals -- non-DC | ||
| 17781 | + // chroma, the TX_4X4 split, sub-16 rect inter leaves -- fire | ||
| 17782 | + // first). The prediction below would handle it; refusing keeps | ||
| 17783 | + // the rule that no lift ships ungated. Note the claim is about | ||
| 17784 | + // THIS DECODER's gate coverage, not about what an encoder writes. | ||
| 17785 | + return Err(unsupported( | ||
| 17786 | + "a nonzero angle delta on an 8x8 intra leaf in an inter frame (no gate reaches \ | ||
| 17787 | + this leaf with one; the >=16x16 arm decodes deltas)", | ||
| 17788 | + )); | ||
| 17732 | } | 17789 | } |
| 17733 | let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]); | 17790 | let uv_mode = dec.symbol(&mut cdfs.uv_mode_cfl[mode]); |
| 17734 | if uv_mode != DC_PRED { | 17791 | if uv_mode != DC_PRED { |
| @@ -17823,7 +17880,7 @@ fn decode_inter_block8( | |||
| 17823 | py, | 17880 | py, |
| 17824 | SIDE, | 17881 | SIDE, |
| 17825 | mode, | 17882 | mode, |
| 17826 | - 0, | 17883 | + angle_delta_y, |
| 17827 | reach, | 17884 | reach, |
| 17828 | &vec![0i32; SIDE * SIDE], | 17885 | &vec![0i32; SIDE * SIDE], |
| 17829 | None, | 17886 | None, |
| @@ -17868,7 +17925,7 @@ fn decode_inter_block8( | |||
| 17868 | around[0], | 17925 | around[0], |
| 17869 | mode, | 17926 | mode, |
| 17870 | mode, | 17927 | mode, |
| 17871 | - 0, | 17928 | + angle_delta_y, |
| 17872 | reach, | 17929 | reach, |
| 17873 | y, | 17930 | y, |
| 17874 | px, | 17931 | px, |
crates/ec-av1/src/gate_coverage.rsmodified+0 -8
| @@ -148,10 +148,6 @@ const ALIASES: &[(&str, &str)] = &[("superres-mode", "enable-superres")]; | |||
| 148 | /// depth retires the entry, and this test fails until it is deleted. | 148 | /// depth retires the entry, and this test fails until it is deleted. |
| 149 | #[cfg(test)] | 149 | #[cfg(test)] |
| 150 | const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[ | 150 | const NEVER_EXERCISED_8BIT: &[(&str, &str)] = &[ |
| 151 | - ( | ||
| 152 | - "enable-angle-delta", | ||
| 153 | - "off in 36 gates, on in none: the directional-intra gates pin it off to isolate the base modes", | ||
| 154 | - ), | ||
| 155 | ( | 151 | ( |
| 156 | "enable-cfl-intra", | 152 | "enable-cfl-intra", |
| 157 | "off in 41 gates, on in none: chroma-from-luma prediction is unimplemented", | 153 | "off in 41 gates, on in none: chroma-from-luma prediction is unimplemented", |
| @@ -214,10 +210,6 @@ const NEVER_EXERCISED_10BIT: &[(&str, &str)] = &[ // lane-cwarp's 10-bit comp | |||
| 214 | // gate passes `=1` for both. `enable-1to4-partitions` left it on 2026-09-02: | 210 | // gate passes `=1` for both. `enable-1to4-partitions` left it on 2026-09-02: |
| 215 | // lane-tx64x16 r4's 32-level 1:4 gate has a 10-bit arm that asserts both | 211 | // lane-tx64x16 r4's 32-level 1:4 gate has a 10-bit arm that asserts both |
| 216 | // orientations and coded strips inside pixel-exact attempts. | 212 | // orientations and coded strips inside pixel-exact attempts. |
| 217 | - ( | ||
| 218 | - "enable-angle-delta", | ||
| 219 | - "hole at both depths, see the 8-bit list", | ||
| 220 | - ), | ||
| 221 | ( | 213 | ( |
| 222 | "enable-cfl-intra", | 214 | "enable-cfl-intra", |
| 223 | "hole at both depths, see the 8-bit list", | 215 | "hole at both depths, see the 8-bit list", |
crates/ec-av1/src/refusal_inventory.rsmodified+1 -1
| @@ -26,11 +26,11 @@ | |||
| 26 | const CAPABILITY_CLAIMS: &[&str] = &[ | 26 | const CAPABILITY_CLAIMS: &[&str] = &[ |
| 27 | "filter intra on a superblock-level HORZ/VERT strip (never expected -- av1_filter_intra_allowed_bsize caps at 32x32)", | 27 | "filter intra on a superblock-level HORZ/VERT strip (never expected -- av1_filter_intra_allowed_bsize caps at 32x32)", |
| 28 | "a non-DC chroma mode on an 8x8 inter-frame leaf (this encoder never writes one)", | 28 | "a non-DC chroma mode on an 8x8 inter-frame leaf (this encoder never writes one)", |
| 29 | - "a nonzero angle delta (this encoder never writes one)", | ||
| 30 | ]; | 29 | ]; |
| 31 | 30 | ||
| 32 | #[cfg(test)] | 31 | #[cfg(test)] |
| 33 | const REFUSALS: &[&str] = &[ | 32 | const REFUSALS: &[&str] = &[ |
| 33 | + "a nonzero angle delta on an 8x8 intra leaf in an inter frame (no gate reaches this leaf with one; the >=16x16 arm decodes deltas)", | ||
| 34 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", | 34 | "a coded HORZ/VERT strip whose chroma transform has no rect coefficient tables here", |
| 35 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", | 35 | "a split intra strip whose transform unit is {tx_w}x{tx_h} (no luma coefficient tables for that shape here)", |
| 36 | "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", | 36 | "an inter partition below 8x8 (this decoder codes no inter leaf smaller than 8x8; lane-sub8 scoped to intra)", |
crates/ec-av1/src/stream.rsmodified+267 -0
| @@ -4686,6 +4686,273 @@ mod tests { | |||
| 4686 | ); | 4686 | ); |
| 4687 | } | 4687 | } |
| 4688 | 4688 | ||
| 4689 | + /// lane-angleinter r1 (class [[refusal-strings-are-claims]] + | ||
| 4690 | + /// [[tool-disabled-in-every-gate]]): a real aomenc inter sequence with | ||
| 4691 | + /// `--enable-angle-delta=1` and `--enable-directional-intra=1` (aomenc's | ||
| 4692 | + /// own defaults; every inter gate before this one pinned BOTH off) in | ||
| 4693 | + /// which the RD gives an INTRA block inside an inter frame a directional | ||
| 4694 | + /// luma mode with a nonzero `angle_delta_y`. Both intra-in-inter arms | ||
| 4695 | + /// read that symbol and then REFUSED it as "this encoder never writes | ||
| 4696 | + /// one" -- the claim is false, `read_intra_angle_info` writes it exactly | ||
| 4697 | + /// as a key frame does. Hard-asserts | ||
| 4698 | + /// [`decode::intra_in_inter_angle_delta_y_hits`]; an attempt that never | ||
| 4699 | + /// produced one proves nothing, and exhausting every attempt is a | ||
| 4700 | + /// FAILURE, not a SKIP. | ||
| 4701 | + #[test] | ||
| 4702 | + fn a_real_aomenc_inter_sequence_with_a_directional_intra_block_with_angle_delta_decodes_pixel_exact() | ||
| 4703 | + { | ||
| 4704 | + angle_delta_in_inter_gate(8, "--min-partition-size=16"); | ||
| 4705 | + } | ||
| 4706 | + | ||
| 4707 | + /// The 10-bit arm (both of the user's films are `yuv420p10le`). | ||
| 4708 | + #[test] | ||
| 4709 | + fn a_real_aomenc_10bit_inter_sequence_with_a_directional_intra_block_with_angle_delta_decodes_pixel_exact() | ||
| 4710 | + { | ||
| 4711 | + angle_delta_in_inter_gate(10, "--min-partition-size=16"); | ||
| 4712 | + } | ||
| 4713 | + | ||
| 4714 | + fn angle_delta_in_inter_gate(bit_depth: u32, min_partition: &str) { | ||
| 4715 | + let name = format!("angle_delta_in_inter_gate({bit_depth}, min={min_partition})"); | ||
| 4716 | + let leaf8 = min_partition.ends_with('8'); | ||
| 4717 | + assert!(!leaf8, "the 8x8-leaf arm keeps its refusal; see the module note"); | ||
| 4718 | + if !have_ffmpeg() { | ||
| 4719 | + eprintln!("SKIP {name}: no ffmpeg"); | ||
| 4720 | + return; | ||
| 4721 | + } | ||
| 4722 | + if !have_aomenc() { | ||
| 4723 | + eprintln!("SKIP {name}: no aomenc at {}", aomenc_path().display()); | ||
| 4724 | + return; | ||
| 4725 | + } | ||
| 4726 | + let (width, height, frame_count) = (64usize, 64usize, 8usize); | ||
| 4727 | + let mut refusals = Vec::new(); | ||
| 4728 | + let mut uncounted_exact = 0u32; | ||
| 4729 | + for attempt in 0..40u32 { | ||
| 4730 | + let seed = 42 + attempt; | ||
| 4731 | + // A zooming fractal: every frame moves (so the sequence is | ||
| 4732 | + // genuinely inter-coded) and keeps sharp new detail entering at | ||
| 4733 | + // the borders, which is what makes aomenc's RD choose an INTRA | ||
| 4734 | + // block inside an inter frame -- and then split its transform. | ||
| 4735 | + // A zooming fractal with a hard CUT halfway (`overlay` switching | ||
| 4736 | + // a second, unrelated fractal on at frame 4): after the cut every | ||
| 4737 | + // block is unpredictable from the reference, which is what makes | ||
| 4738 | + // aomenc code INTRA blocks inside an inter frame -- and at this | ||
| 4739 | + // cq the RD then splits their transforms. | ||
| 4740 | + let source = format!( | ||
| 4741 | + "mandelbrot=size={width}x{height}:start_scale={}:rate=25[a];\ | ||
| 4742 | + mandelbrot=size={width}x{height}:start_scale={}:rate=25[b];\ | ||
| 4743 | + [a][b]overlay=enable='gte(n,4)'", | ||
| 4744 | + 5.0 - f64::from(attempt) * 0.06, | ||
| 4745 | + 0.9 + f64::from(attempt) * 0.11 | ||
| 4746 | + ); | ||
| 4747 | + let y4m = Command::new("ffmpeg") | ||
| 4748 | + .args([ | ||
| 4749 | + "-v", | ||
| 4750 | + "error", | ||
| 4751 | + "-f", | ||
| 4752 | + "lavfi", | ||
| 4753 | + "-i", | ||
| 4754 | + &source, | ||
| 4755 | + // Desaturated chroma keeps `uv_mode` on DC_PRED, so the | ||
| 4756 | + // still-refused directional-chroma gaps never fire and | ||
| 4757 | + // luma detail alone drives the transform split. | ||
| 4758 | + "-vf", | ||
| 4759 | + "hue=s=0", | ||
| 4760 | + "-pix_fmt", | ||
| 4761 | + if bit_depth == 10 { "yuv420p10le" } else { "yuv420p" }, | ||
| 4762 | + "-strict", | ||
| 4763 | + "-1", | ||
| 4764 | + "-t", | ||
| 4765 | + "0.32", | ||
| 4766 | + "-f", | ||
| 4767 | + "yuv4mpegpipe", | ||
| 4768 | + "-strict", | ||
| 4769 | + "-1", | ||
| 4770 | + "-", | ||
| 4771 | + ]) | ||
| 4772 | + .stdin(Stdio::null()) | ||
| 4773 | + .stdout(Stdio::piped()) | ||
| 4774 | + .stderr(Stdio::piped()) | ||
| 4775 | + .output() | ||
| 4776 | + .expect("ffmpeg failed to run"); | ||
| 4777 | + assert!( | ||
| 4778 | + y4m.status.success(), | ||
| 4779 | + "ffmpeg fixture: {}", | ||
| 4780 | + String::from_utf8_lossy(&y4m.stderr) | ||
| 4781 | + ); | ||
| 4782 | + // The 8x8-leaf arm is fenced by three sibling refusals (non-DC | ||
| 4783 | + // chroma on an 8x8 leaf, its TX_4X4 split, sub-16 rect inter | ||
| 4784 | + // leaves), so it sweeps the quantiser as well as the source: a | ||
| 4785 | + // coarser q is what pushes the RD to directional intra at 8x8. | ||
| 4786 | + let cq = if leaf8 { | ||
| 4787 | + format!("--cq-level={}", 20 + (attempt % 5) * 10) | ||
| 4788 | + } else { | ||
| 4789 | + "--cq-level=30".to_string() | ||
| 4790 | + }; | ||
| 4791 | + let depth_args: &[&str] = if bit_depth == 10 { | ||
| 4792 | + &["-b", "10", "--input-bit-depth=10"] | ||
| 4793 | + } else { | ||
| 4794 | + &[] | ||
| 4795 | + }; | ||
| 4796 | + let mut child = Command::new(aomenc_path()) | ||
| 4797 | + .args(depth_args) | ||
| 4798 | + .args([ | ||
| 4799 | + "--codec=av1", | ||
| 4800 | + "--passes=1", | ||
| 4801 | + "--end-usage=q", | ||
| 4802 | + &cq, | ||
| 4803 | + "--cpu-used=0", | ||
| 4804 | + "--lag-in-frames=0", | ||
| 4805 | + "--auto-alt-ref=0", | ||
| 4806 | + // One key frame only: every later frame is an inter frame, | ||
| 4807 | + // which is where this gate's intra blocks must sit. The | ||
| 4808 | + // MIN distance is what stops aomenc's scene-cut detector | ||
| 4809 | + // from inserting a second key frame at the cut this gate's | ||
| 4810 | + // source deliberately contains. | ||
| 4811 | + "--kf-max-dist=1000", | ||
| 4812 | + "--kf-min-dist=1000", | ||
| 4813 | + "--threads=1", | ||
| 4814 | + "--row-mt=0", | ||
| 4815 | + "--enable-order-hint=0", | ||
| 4816 | + "--enable-warped-motion=0", | ||
| 4817 | + "--enable-obmc=0", | ||
| 4818 | + "--enable-masked-comp=0", | ||
| 4819 | + "--enable-interintra-comp=0", | ||
| 4820 | + "--enable-dist-wtd-comp=0", | ||
| 4821 | + "--enable-diff-wtd-comp=0", | ||
| 4822 | + "--enable-onesided-comp=0", | ||
| 4823 | + "--enable-interintra-wedge=0", | ||
| 4824 | + "--enable-smooth-interintra=0", | ||
| 4825 | + "--enable-ab-partitions=0", | ||
| 4826 | + "--enable-1to4-partitions=0", | ||
| 4827 | + "--enable-smooth-intra=0", | ||
| 4828 | + "--enable-paeth-intra=0", | ||
| 4829 | + "--enable-directional-intra=1", | ||
| 4830 | + "--enable-angle-delta=1", | ||
| 4831 | + "--enable-cdef=0", | ||
| 4832 | + "--enable-restoration=0", | ||
| 4833 | + "--enable-palette=0", | ||
| 4834 | + "--enable-intrabc=0", | ||
| 4835 | + "--enable-cfl-intra=0", | ||
| 4836 | + "--enable-ref-frame-mvs=0", | ||
| 4837 | + // Per-arm overrides go LAST (aomenc keeps the last | ||
| 4838 | + // occurrence of a repeated --enable-* flag): the intra | ||
| 4839 | + // tx_depth symbol only exists under TX_MODE_SELECT, and | ||
| 4840 | + // rect partitions are a separate named refusal. | ||
| 4841 | + "--enable-filter-intra=1", | ||
| 4842 | + "--enable-tx-size-search=1", | ||
| 4843 | + "--enable-rect-partitions=0", | ||
| 4844 | + "--max-partition-size=32", | ||
| 4845 | + // Sub-16 inter partitions are a separate named refusal, | ||
| 4846 | + // as is the 8x8 intra leaf's own TX_4X4 split. | ||
| 4847 | + min_partition, | ||
| 4848 | + "--obu", | ||
| 4849 | + "-o", | ||
| 4850 | + "-", | ||
| 4851 | + "-", | ||
| 4852 | + ]) | ||
| 4853 | + .stdin(Stdio::piped()) | ||
| 4854 | + .stdout(Stdio::piped()) | ||
| 4855 | + .stderr(Stdio::piped()) | ||
| 4856 | + .spawn() | ||
| 4857 | + .expect("aomenc failed to start"); | ||
| 4858 | + child | ||
| 4859 | + .stdin | ||
| 4860 | + .take() | ||
| 4861 | + .expect("aomenc stdin") | ||
| 4862 | + .write_all(&y4m.stdout) | ||
| 4863 | + .expect("writing y4m to aomenc"); | ||
| 4864 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 4865 | + assert!( | ||
| 4866 | + out.status.success(), | ||
| 4867 | + "aomenc refused the fixture: {}", | ||
| 4868 | + String::from_utf8_lossy(&out.stderr) | ||
| 4869 | + ); | ||
| 4870 | + let stream = out.stdout; | ||
| 4871 | + let before = decode::intra_in_inter_angle_delta_y_hits(); | ||
| 4872 | + let before_uv = decode::intra_in_inter_angle_delta_uv_hits(); | ||
| 4873 | + let frames = match decode_stream(&stream) { | ||
| 4874 | + Ok(frames) => frames, | ||
| 4875 | + Err(e) => { | ||
| 4876 | + let msg = e.to_string(); | ||
| 4877 | + assert!( | ||
| 4878 | + msg.contains("unsupported"), | ||
| 4879 | + "{name} decode failed outright (seed {seed}): {msg}" | ||
| 4880 | + ); | ||
| 4881 | + refusals.push(format!("seed {seed}: {msg}")); | ||
| 4882 | + continue; | ||
| 4883 | + } | ||
| 4884 | + }; | ||
| 4885 | + let fired = decode::intra_in_inter_angle_delta_y_hits() - before; | ||
| 4886 | + let fired_uv = decode::intra_in_inter_angle_delta_uv_hits() - before_uv; | ||
| 4887 | + // class [[gate-skips-on-its-own-failure]]: a decode that | ||
| 4888 | + // succeeded is ALWAYS pixel-compared below; the counter only | ||
| 4889 | + // decides whether the attempt counts as firing. | ||
| 4890 | + let counted = fired != 0; | ||
| 4891 | + if !counted { | ||
| 4892 | + uncounted_exact += 1; | ||
| 4893 | + refusals.push(format!( | ||
| 4894 | + "seed {seed}: decoded and pixel-compared, but no intra block in an inter \ | ||
| 4895 | + frame carried a nonzero angle_delta_y" | ||
| 4896 | + )); | ||
| 4897 | + } | ||
| 4898 | + let ffmpeg_frames = if bit_depth == 10 { | ||
| 4899 | + ffmpeg_decode_sequence_10bit(&stream, width, height, frame_count) | ||
| 4900 | + } else { | ||
| 4901 | + ffmpeg_decode_sequence(&stream, width, height, frame_count) | ||
| 4902 | + }; | ||
| 4903 | + assert_eq!(frames.len(), frame_count); | ||
| 4904 | + eprintln!( | ||
| 4905 | + "{name} seed={seed}: intra-in-inter blocks with a nonzero angle_delta_y = \ | ||
| 4906 | + {fired}, angle_delta_uv = {fired_uv}" | ||
| 4907 | + ); | ||
| 4908 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 4909 | + for (plane, (g, w)) in [ | ||
| 4910 | + ("Y", (&got.y, &want.y)), | ||
| 4911 | + ("U", (&got.u, &want.u)), | ||
| 4912 | + ("V", (&got.v, &want.v)), | ||
| 4913 | + ] { | ||
| 4914 | + let stride = if plane == "Y" { width } else { width / 2 }; | ||
| 4915 | + if let Some(at) = g.iter().zip(w.iter()).position(|(a, b)| a != b) { | ||
| 4916 | + eprintln!( | ||
| 4917 | + "{name} seed={seed}: frame {i} {plane} first diff at ({}, {}) got {} \ | ||
| 4918 | + want {} ({} samples differ)", | ||
| 4919 | + at % stride, | ||
| 4920 | + at / stride, | ||
| 4921 | + g[at], | ||
| 4922 | + w[at], | ||
| 4923 | + g.iter().zip(w.iter()).filter(|(a, b)| a != b).count(), | ||
| 4924 | + ); | ||
| 4925 | + } | ||
| 4926 | + } | ||
| 4927 | + } | ||
| 4928 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 4929 | + assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (seed {seed})"); | ||
| 4930 | + assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (seed {seed})"); | ||
| 4931 | + assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (seed {seed})"); | ||
| 4932 | + } | ||
| 4933 | + if counted { | ||
| 4934 | + gate_buckets( | ||
| 4935 | + &name, | ||
| 4936 | + 1, | ||
| 4937 | + uncounted_exact, | ||
| 4938 | + refusals.len() - uncounted_exact as usize, | ||
| 4939 | + ); | ||
| 4940 | + return; | ||
| 4941 | + } | ||
| 4942 | + } | ||
| 4943 | + gate_buckets( | ||
| 4944 | + &name, | ||
| 4945 | + 0, | ||
| 4946 | + uncounted_exact, | ||
| 4947 | + refusals.len() - uncounted_exact as usize, | ||
| 4948 | + ); | ||
| 4949 | + panic!( | ||
| 4950 | + "{name} never observed a nonzero angle delta on an intra block in an inter \ | ||
| 4951 | + frame:\n{}", | ||
| 4952 | + refusals.join("\n") | ||
| 4953 | + ); | ||
| 4954 | + } | ||
| 4955 | + | ||
| 4689 | /// lane-chroma r2 stage 1: a real aomenc key frame with | 4956 | /// lane-chroma r2 stage 1: a real aomenc key frame with |
| 4690 | /// `--enable-smooth-intra=1` (opposite of every sibling recipe's `=0`) | 4957 | /// `--enable-smooth-intra=1` (opposite of every sibling recipe's `=0`) |
| 4691 | /// and `--enable-paeth-intra=0` -- paeth chroma stays off so the still- | 4958 | /// and `--enable-paeth-intra=0` -- paeth chroma stays off so the still- |
lanes/angleinter-r1.report.mdadded+105 -0
| @@ -0,0 +1,105 @@ | |||
| 1 | +# lane-angleinter r1 — a nonzero angle delta on an intra block inside an inter frame | ||
| 2 | + | ||
| 3 | +Branch `lane-angleinter` off `lane-fiinter` 6b82994. Class: | ||
| 4 | +[[refusal-strings-are-claims]] + [[tool-disabled-in-every-gate]]. | ||
| 5 | + | ||
| 6 | +## The claim, tested | ||
| 7 | + | ||
| 8 | +Both intra-in-inter arms read `angle_delta_y` and then refused it as | ||
| 9 | +"a nonzero angle delta (this encoder never writes one)". The claim is FALSE: | ||
| 10 | +aomenc's `--enable-angle-delta` defaults to 1 and libaom's | ||
| 11 | +`read_intra_angle_info` (inside `read_intra_block_mode_info`, decodemv.c) | ||
| 12 | +writes the symbol for any directional `y_mode` at bsize >= 8x8 exactly as a | ||
| 13 | +key frame does. A real default-settings inter stream desynced there. | ||
| 14 | + | ||
| 15 | +Confirmed by the gate below on the FIRST attempt (seed 42, 8-bit): 4 intra | ||
| 16 | +blocks inside inter frames carry a nonzero `angle_delta_y`. | ||
| 17 | + | ||
| 18 | +## What changed | ||
| 19 | + | ||
| 20 | +- `crates/ec-av1/src/decode.rs:15542` (`decode_inter_block`, >=16x16 arm): | ||
| 21 | + refusal replaced by `read_angle_delta`; the delta is threaded into every | ||
| 22 | + luma prediction of the block — the split-transform per-TU | ||
| 23 | + `reconstruct`/`read_plane` pair and the block-level pair — where a literal | ||
| 24 | + `0` used to go. | ||
| 25 | +- `crates/ec-av1/src/decode.rs:15555`: the same arm derived | ||
| 26 | + `smooth_neighbor` (`get_intra_edge_filter_type`, spec 7.11.2) via the | ||
| 27 | + existing `Neighbours::modes_above_left` helper; it passed a hardcoded | ||
| 28 | + `false` before, which was unobservable while every directional | ||
| 29 | + intra-in-inter block was refused, and decides the intra edge filter's | ||
| 30 | + strength once a delta'd angle reaches it. | ||
| 31 | +- `crates/ec-av1/src/decode.rs:82` (+ around): counters | ||
| 32 | + `intra_in_inter_angle_delta_y_hits` / `intra_in_inter_angle_delta_uv_hits`. | ||
| 33 | +- `crates/ec-av1/src/decode.rs:17191` (`decode_inter_block8`, 8x8 leaf): | ||
| 34 | + the refusal STAYS, reworded to a claim about this decoder's gate coverage | ||
| 35 | + instead of about the encoder — see "Not lifted" below. | ||
| 36 | +- `crates/ec-av1/src/stream.rs`: gate `angle_delta_in_inter_gate` + its 8-bit | ||
| 37 | + and 10-bit tests. | ||
| 38 | +- `refusal_inventory.rs`: the capability claim is gone; the 8x8-leaf refusal | ||
| 39 | + is listed as a decoder-scoped refusal. `gate_coverage.rs`: | ||
| 40 | + `enable-angle-delta` deleted from `NEVER_EXERCISED_8BIT` and `_10BIT`. | ||
| 41 | + | ||
| 42 | +## Gate | ||
| 43 | + | ||
| 44 | +`a_real_aomenc_inter_sequence_with_a_directional_intra_block_with_angle_delta_decodes_pixel_exact` | ||
| 45 | +(+ `..._10bit_...`). Recipe = the intrainter/fiinter one (64x64 mandelbrot | ||
| 46 | +zoom with a hard overlay cut at frame 4, `--cq-level=30`, `--kf-min-dist=1000` | ||
| 47 | +`--kf-max-dist=1000`, `--min-partition-size=16`) with | ||
| 48 | +`--enable-directional-intra=1` and `--enable-angle-delta=1` — each flag | ||
| 49 | +spelled ONCE in the arg list (the base recipe's `=0` entries were edited in | ||
| 50 | +place, so flag precedence cannot silently invert the arm). Every frame's Y, U | ||
| 51 | +and V are compared against ffmpeg; a decode error or mismatch is a FAILURE, | ||
| 52 | +never a SKIP; the hit counter is a hard assert. | ||
| 53 | + | ||
| 54 | +``` | ||
| 55 | +cargo test -p ec-av1 --lib with_a_directional_intra_block_with_angle_delta -- --nocapture | ||
| 56 | +``` | ||
| 57 | + | ||
| 58 | +EVIDENCE: $HOME/.cache/angleinter-suite.log | aomenc --enable-angle-delta=1 --enable-directional-intra=1, 8 frames decoded and Y/U/V-compared vs ffmpeg | 8-bit seed 42: 4 nonzero-angle_delta_y intra-in-inter blocks, 0 sample mismatches; 10-bit seed 47: 4 blocks, 0 mismatches (buckets counted-exact=1 uncounted-exact=0) | ||
| 59 | + | ||
| 60 | +EVIDENCE: negative control (scratchpad decode.rs.bak diff) | re-inserted `return Err(unsupported("NEGATIVE CONTROL: a nonzero angle delta"))` at decode.rs:15549, reran both gates | 2 passed -> 2 FAILED, all 40 attempts refused with that string; lift reverted afterwards | ||
| 61 | + | ||
| 62 | +## Mutation sweep (task 3) | ||
| 63 | + | ||
| 64 | +All 56 `--enable-angle-delta=0` spellings in `stream.rs` flipped to `=1`, then | ||
| 65 | +the 17 `inter_sequence` gates rerun: **17 passed / 0 failed** — no hidden | ||
| 66 | +defect behind the flag. stream.rs restored from the scratchpad copy | ||
| 67 | +afterwards (only the new gate's own two spellings are `=1` on the branch). | ||
| 68 | + | ||
| 69 | +EVIDENCE: mutation run | sed -i 's/--enable-angle-delta=0/=1/g' + `cargo test -p ec-av1 --lib inter_sequence` | test result: ok. 17 passed; 0 failed; 2 ignored | ||
| 70 | + | ||
| 71 | +## Not lifted (disposition) | ||
| 72 | + | ||
| 73 | +`deferred: the 8x8-leaf arm's nonzero-delta case (decode.rs:17205) — 80 | ||
| 74 | +attempts (64x64 and 128x128 sources, cq 20/30/40/50/60, seeds 42..81) never | ||
| 75 | +produced an 8x8 intra leaf with a nonzero angle_delta_y, nor even one with a | ||
| 76 | +directional luma mode: the leaf's three sibling refusals ("a non-DC chroma | ||
| 77 | +mode on an 8x8 inter-frame leaf", "an 8x8 intra leaf ... whose tx_depth | ||
| 78 | +splits it into 4x4 transform units", "an inter partition below 16x16 other | ||
| 79 | +than SPLIT") fire first on 37/40 attempts. Lifting it would ship an ungated | ||
| 80 | +capability claim (class refusal-lifted-without-a-gate), so the refusal stays, | ||
| 81 | +reworded to be about this decoder. — unblocked by: lifting the non-DC-chroma | ||
| 82 | +and TX_4X4-split refusals on that leaf, which then makes a directional 8x8 | ||
| 83 | +intra leaf reachable.` | ||
| 84 | + | ||
| 85 | +`accepted: angle_delta_uv fired 0 times in every passing attempt — the | ||
| 86 | +recipe's `hue=s=0` desaturation is what keeps uv_mode on DC and the transform | ||
| 87 | +split luma-driven. The uv delta path was already read AND already threaded | ||
| 88 | +into both chroma predictions before this round (decode.rs:15556 ff.), so the | ||
| 89 | +lift did not touch it; the counter is in place for a future chroma gate.` | ||
| 90 | + | ||
| 91 | +`accepted: decode_inter_block8 still passes a hardcoded `false` for its luma | ||
| 92 | +edge-filter neighbour type. Unobservable while its directional-mode | ||
| 93 | +population is empty (see above); reverted rather than shipped ungated.` | ||
| 94 | + | ||
| 95 | +## Suite + film | ||
| 96 | + | ||
| 97 | +`cargo test -p ec-av1 --lib` (systemd unit, log `$HOME/.cache/angleinter-suite.log`): | ||
| 98 | +**348 passed / 0 failed / 32 ignored**, 384 s. | ||
| 99 | + | ||
| 100 | +Film probe (`hg-head.obu`, 0.4 s of the ReelB 2160p10 film, 18 frame | ||
| 101 | +headers): now stops at `filter intra on a HORZ/VERT strip (this decoder | ||
| 102 | +predicts square-only)` — a different, rect-prediction refusal; the angle-delta | ||
| 103 | +refusal is no longer on its path. | ||
| 104 | + | ||
| 105 | +EVIDENCE: $HOME/.cache/angleinter-suite.log | `cargo test -p ec-av1 --lib` under a systemd unit + `cargo run --example decode_probe -- hg-head.obu` | 348 passed / 0 failed; film refusal string = "filter intra on a HORZ/VERT strip" | ||