The 128 residual arm's parking comment closes its filter bug and the native gate prints the arm's residual fires -- bars 2160p re-measures three-way exact through the cdef owner map, long-GOP BD -0.1/+0.1 and 12-frame rows within 0.1 at 0.7-1.9 writer fires/frame, so EC_AV1_B128RES stays off
Browse files at this commit2ed5165b574012e5ce0ee831f0fd9c476255c78dParent: 4b37b0c- fix
- the 128 residual arm's parking comment closes its filter bug and the native gate prints the arm's residual fires -- bars 2160p re-measures three-way exact through the cdef owner map, long-GOP BD -0.1/+0.1 and 12-frame rows within 0.1 at 0.7-1.9 writer fires/frame, so EC_AV1_B128RES stays off
- the pan residual witness re-vitalizes at q=60 after lane-rectdq's delta_q pricing made the forced root lose every partition
1 changed file +30 -17
- crates/ec-av1/src/encode.rs +30 -17
crates/ec-av1/src/encode.rsmodified+30 -17
| @@ -738,22 +738,23 @@ fn b128_root() -> bool { | |||
| 738 | /// pair per 64x64 mu chunk, var-tx depth 0 (the shape | 738 | /// pair per 64x64 mu chunk, var-tx depth 0 (the shape |
| 739 | /// [`crate::tile::write_inter_block_128`] codes and `decode_inter_block` | 739 | /// [`crate::tile::write_inter_block_128`] codes and `decode_inter_block` |
| 740 | /// reads). Written, witnessed and byte-exact through both decoders, and | 740 | /// reads). Written, witnessed and byte-exact through both decoders, and |
| 741 | -/// **off by default** (`EC_AV1_B128RES=1` turns it on) for two measured | 741 | +/// **off by default** (`EC_AV1_B128RES=1` turns it on) because it is INERT |
| 742 | -/// reasons: | 742 | +/// on content: the RD takes it 0.7-1.9 times per frame against thousands of |
| 743 | +/// whole 128 roots (lane-b128res census, native 12-frame gate, every clip), | ||
| 744 | +/// and the BD effect is inside the noise on both gates -- long-GOP films | ||
| 745 | +/// -0.1/+0.1 and all five 12-frame rows within 0.1 of the off default. | ||
| 743 | /// | 746 | /// |
| 744 | -/// * it is INERT on content: over the native 12-frame gate the RD takes it | 747 | +/// The historical reason for the parking is CLOSED: the bars 2160p q=90 |
| 745 | -/// 0-2 times per frame against ~90 whole 128 roots, so the BD effect is | 748 | +/// frame 11 disagreement with ffmpeg (8 luma samples at the rows above a |
| 746 | -/// inside the noise either way; | 749 | +/// 128-superblock horizontal edge) was the CDEF search pricing a preset per |
| 747 | -/// * with it on, `bd_rate_screen_native`'s bars 2160p row q=90 frame 11 | 750 | +/// 64x64 unit under a root that codes ONE literal for all four -- lane- |
| 748 | -/// reads 8 luma samples (rows 126..127, cols 1611..1616 -- the two rows | 751 | +/// edge128's `crate::tile::cdef_unit_owner` collapses the four to the one |
| 749 | -/// above a 128-superblock horizontal edge) where ffmpeg and this | 752 | +/// the decoder derives, and on this HEAD the same row re-measures three-way |
| 750 | -/// encoder's own reconstruction disagree. The residual arm's own witness | 753 | +/// EXACT (encoder reconstruction == ffmpeg == `decode_stream`, every frame, |
| 751 | -/// clip is byte-exact through ffmpeg over 420 forced blocks at 1280x768, | 754 | +/// every plane, both gates). The knob stays as the arm's gate, not as a |
| 752 | -/// so the open half is a FILTER-stage interaction (deblock/CDEF at a 128 | 755 | +/// defect flag; the residual arm is also what |
| 753 | -/// block's own edge), not the coefficient path. | 756 | +/// [`crate::tile::write_inter_block_128_rect`]'s skip-only halves would |
| 754 | -/// | 757 | +/// share if they ever carry one. |
| 755 | -/// An inert candidate does not buy a live filter mismatch, so the default | ||
| 756 | -/// stays off until that is root-caused; the knob is the gate for it. | ||
| 757 | fn b128_residual() -> bool { | 758 | fn b128_residual() -> bool { |
| 758 | static ENV: std::sync::LazyLock<Option<bool>> = std::sync::LazyLock::new(|| { | 759 | static ENV: std::sync::LazyLock<Option<bool>> = std::sync::LazyLock::new(|| { |
| 759 | crate::envflags::var("EC_AV1_B128RES").ok().map(|v| v != "0") | 760 | crate::envflags::var("EC_AV1_B128RES").ok().map(|v| v != "0") |
| @@ -17095,6 +17096,15 @@ mod tests { | |||
| 17095 | /// `skip = true` for a block that carries a residual -- the next root's | 17096 | /// `skip = true` for a block that carries a residual -- the next root's |
| 17096 | /// `skip` symbol then took CDF row 1 where the reader takes row 0. | 17097 | /// `skip` symbol then took CDF row 1 where the reader takes row 0. |
| 17097 | /// | 17098 | /// |
| 17099 | + /// lane-b128res: the fixture's q moved 150 -> 60. The forced arm replaces | ||
| 17100 | + /// the skip arm's cost unconditionally (that is what makes the writer see | ||
| 17101 | + /// the residual), and the cost model moved under it since lane-b128r -- | ||
| 17102 | + /// lane-rectdq made every non-skipped root pay its delta_q group and the | ||
| 17103 | + /// pyramid re-prices the leaves -- so at q=150, then q=90, the NONE root | ||
| 17104 | + /// lost its partition at ALL 420 roots and the writer coded none. q=60 | ||
| 17105 | + /// puts 52 written blocks back on this clip; the `coded > 0` assert below | ||
| 17106 | + /// is the guard that catches the next such drift. | ||
| 17107 | + /// | ||
| 17098 | /// cargo test -p ec-av1 --release --lib -- --ignored \ | 17108 | /// cargo test -p ec-av1 --release --lib -- --ignored \ |
| 17099 | /// a_128_root_block_with_a_real_residual --nocapture | 17109 | /// a_128_root_block_with_a_real_residual --nocapture |
| 17100 | #[test] | 17110 | #[test] |
| @@ -17125,7 +17135,7 @@ mod tests { | |||
| 17125 | let _ = take_b128_residual_hits(); | 17135 | let _ = take_b128_residual_hits(); |
| 17126 | let _ = crate::tile::take_sb128_residual_hits(); | 17136 | let _ = crate::tile::take_sb128_residual_hits(); |
| 17127 | force_b128_residual(true); | 17137 | force_b128_residual(true); |
| 17128 | - let encoded = encode_sequence(&pictures, 150, 0.5).unwrap(); | 17138 | + let encoded = encode_sequence(&pictures, 60, 0.5).unwrap(); |
| 17129 | let (won, coded) = | 17139 | let (won, coded) = |
| 17130 | (take_b128_residual_hits(), crate::tile::take_sb128_residual_hits()); | 17140 | (take_b128_residual_hits(), crate::tile::take_sb128_residual_hits()); |
| 17131 | eprintln!("128x128 blocks WITH a residual: search won {won}, writer coded {coded}"); | 17141 | eprintln!("128x128 blocks WITH a residual: search won {won}, writer coded {coded}"); |
| @@ -20239,9 +20249,12 @@ mod tests { | |||
| 20239 | 100.0 * i64_whole as f64 / i64_offered.max(1) as f64, | 20249 | 100.0 * i64_whole as f64 / i64_offered.max(1) as f64, |
| 20240 | ); | 20250 | ); |
| 20241 | eprintln!( | 20251 | eprintln!( |
| 20242 | - "{name}: 128x128 roots {} (search) / {} (writer)", | 20252 | + "{name}: 128x128 roots {} (search) / {} (writer), with a residual \ |
| 20253 | + {} (search) / {} (writer)", | ||
| 20243 | take_b128_none_hits(), | 20254 | take_b128_none_hits(), |
| 20244 | crate::tile::take_sb128_none_hits(), | 20255 | crate::tile::take_sb128_none_hits(), |
| 20256 | + take_b128_residual_hits(), | ||
| 20257 | + crate::tile::take_sb128_residual_hits(), | ||
| 20245 | ); | 20258 | ); |
| 20246 | eprintln!( | 20259 | eprintln!( |
| 20247 | "{name}: 64x64 roots {} (with a residual {}, split luma {}, compound {})", | 20260 | "{name}: 64x64 roots {} (with a residual {}, split luma {}, compound {})", |