Merge branch 'lane-t900' (2aa87a34): sub-8x8 GLOBALMV blocks read their interp filter, warp-sample top-right probe uses max(w,h) with libaom's rect refinements, gate ffmpeg helpers no longer deadlock; no film cut refuses any more
Browse files at this commit14 changed files +1188 -67
- crates/ec-av1/examples/decode_probe.rs +2 -0
- crates/ec-av1/fixtures/gm_small_side_witness.obu +0 -0
- crates/ec-av1/src/decode.rs +274 -30
- crates/ec-av1/src/encode.rs +26 -12
- crates/ec-av1/src/mvstack.rs +25 -5
- crates/ec-av1/src/stream.rs +207 -14
- crates/ec-av1/src/tile.rs +13 -6
- lanes/frame80-r1.handoff.md +65 -0
- lanes/midcut-r1.handoff.md +76 -0
- lanes/midcut-r2.handoff.md +71 -0
- lanes/midcut-r3.handoff.md +115 -0
- lanes/t900-r10.report.md +117 -0
- lanes/t900-r8.handoff.md +88 -0
- lanes/t900-r9.handoff.md +109 -0
crates/ec-av1/examples/decode_probe.rsmodified+2 -0
| @@ -44,6 +44,8 @@ fn main() { | |||
| 44 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); | 44 | println!("rect_inter: tu={rtu} txsplit={rsplit} obmc_leaf={robmc}"); |
| 45 | println!("sub8_inter_split: groups={}", ec_av1::decode::sub8_inter_split_hits()); | 45 | println!("sub8_inter_split: groups={}", ec_av1::decode::sub8_inter_split_hits()); |
| 46 | println!("interintra_rect: {}", ec_av1::decode::interintra_rect_hits()); | 46 | println!("interintra_rect: {}", ec_av1::decode::interintra_rect_hits()); |
| 47 | + println!("gm_nontrans_small_side: {}", ec_av1::decode::gm_nontrans_small_side_hits()); | ||
| 48 | + println!("tr_reach_longer_side: {}", ec_av1::decode::tr_reach_longer_side_hits()); | ||
| 47 | let (h84, h48) = ec_av1::decode::sub8_inter_rect_hits(); | 49 | let (h84, h48) = ec_av1::decode::sub8_inter_rect_hits(); |
| 48 | println!("sub8_inter_rect: horz8x4={h84} vert4x8={h48}"); | 50 | println!("sub8_inter_rect: horz8x4={h84} vert4x8={h48}"); |
| 49 | let si = ec_av1::stream::sub8_intra_rect_hits(); | 51 | let si = ec_av1::stream::sub8_intra_rect_hits(); |
crates/ec-av1/fixtures/gm_small_side_witness.obuadded+0 -0
Binary file changed
crates/ec-av1/src/decode.rsmodified+274 -30
| @@ -63,6 +63,46 @@ const BLOCK_MI: u32 = 8; | |||
| 63 | // *quadrant* size a 128 superblock is decoded in, which is also what the CDEF | 63 | // *quadrant* size a 128 superblock is decoded in, which is also what the CDEF |
| 64 | // grid is indexed by (libaom `read_cdef` reads one `cdef_idx` per 64x64 | 64 | // grid is indexed by (libaom `read_cdef` reads one `cdef_idx` per 64x64 |
| 65 | // inside a 128 superblock). | 65 | // inside a 128 superblock). |
| 66 | +thread_local! { | ||
| 67 | + /// lane-frame80: `EC_TRACE_COEFF_FRAME=<decode idx>` narrows the | ||
| 68 | + /// `EC_TRACE_COEFF` rungs to a single frame in DECODE order (a 4K stream | ||
| 69 | + /// prints gigabytes otherwise). Unset = every frame, as before. | ||
| 70 | + static COEFF_TRACE_FRAME: std::cell::Cell<Option<usize>> = const { std::cell::Cell::new(None) }; | ||
| 71 | + static COEFF_TRACE_CUR: std::cell::Cell<usize> = const { std::cell::Cell::new(usize::MAX) }; | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +/// Called by [`crate::stream::decode_stream`] before each frame's tiles with | ||
| 75 | +/// that frame's DECODE-order index. | ||
| 76 | +pub fn set_coeff_trace_frame(idx: usize) { | ||
| 77 | + COEFF_TRACE_FRAME.with(|c| { | ||
| 78 | + if c.get().is_none() { | ||
| 79 | + let want = match std::env::var("EC_TRACE_COEFF_FRAME") { | ||
| 80 | + Ok(v) => v.parse::<usize>().unwrap_or(usize::MAX), | ||
| 81 | + // unset: keep tracing every frame, as before this rung existed | ||
| 82 | + Err(_) => usize::MAX - 1, | ||
| 83 | + }; | ||
| 84 | + c.set(Some(want)); | ||
| 85 | + } | ||
| 86 | + }); | ||
| 87 | + COEFF_TRACE_CUR.with(|c| c.set(idx)); | ||
| 88 | + if std::env::var_os("EC_TRACE_COEFF").is_some() { | ||
| 89 | + eprintln!("EC_COEFF_FRAME decode_idx={idx}"); | ||
| 90 | + } | ||
| 91 | +} | ||
| 92 | + | ||
| 93 | +pub(crate) fn coeff_trace_on() -> bool { | ||
| 94 | + if std::env::var_os("EC_TRACE_COEFF").is_none() { | ||
| 95 | + return false; | ||
| 96 | + } | ||
| 97 | + match COEFF_TRACE_FRAME.with(|c| c.get()) { | ||
| 98 | + // no `set_coeff_trace_frame` caller (direct tile-decode tests), or the | ||
| 99 | + // env var unset: trace every frame. | ||
| 100 | + None => true, | ||
| 101 | + Some(w) if w >= usize::MAX - 1 => true, | ||
| 102 | + Some(w) => COEFF_TRACE_CUR.with(|c| c.get()) == w, | ||
| 103 | + } | ||
| 104 | +} | ||
| 105 | + | ||
| 66 | thread_local! { | 106 | thread_local! { |
| 67 | static SB128: std::cell::Cell<bool> = const { std::cell::Cell::new(false) }; | 107 | static SB128: std::cell::Cell<bool> = const { std::cell::Cell::new(false) }; |
| 68 | } | 108 | } |
| @@ -2094,6 +2134,35 @@ pub(crate) fn affine_gm_hits() -> usize { | |||
| 2094 | AFFINE_GM_HITS.with(|c| c.get()) | 2134 | AFFINE_GM_HITS.with(|c| c.get()) |
| 2095 | } | 2135 | } |
| 2096 | 2136 | ||
| 2137 | +// lane-t900 r9: rect blocks whose warp-sample top-right probe answers | ||
| 2138 | +// differently at the block's WIDTH than at libaom's | ||
| 2139 | +// `AOMMAX(xd->width, xd->height)` -- each one is a `num_proj_ref` that could | ||
| 2140 | +// pick the wrong motion_mode alphabet. | ||
| 2141 | +thread_local! { | ||
| 2142 | + static TR_REACH_LONGER_SIDE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2143 | +} | ||
| 2144 | + | ||
| 2145 | +/// Current value of [`TR_REACH_LONGER_SIDE_HITS`]. | ||
| 2146 | +pub fn tr_reach_longer_side_hits() -> usize { | ||
| 2147 | + TR_REACH_LONGER_SIDE_HITS.with(std::cell::Cell::get) | ||
| 2148 | +} | ||
| 2149 | + | ||
| 2150 | +// lane-t900 r9: libaom `is_nontrans_global_motion` (mvref_common.h) returns 0 | ||
| 2151 | +// for `AOMMIN(mi_size_wide[bsize], mi_size_high[bsize]) < 2`, i.e. any block | ||
| 2152 | +// with a 4-px side is NEVER "non-translational global" and therefore ALWAYS | ||
| 2153 | +// reads its interp-filter symbol. Counts the blocks where that guard flips | ||
| 2154 | +// our answer -- a GLOBALMV/GLOBAL_GLOBALMV block with a non-TRANSLATION model | ||
| 2155 | +// and a 4-px side, which we used to suppress the interp read on (a pre-mode | ||
| 2156 | +// entropy desync one symbol wide). | ||
| 2157 | +thread_local! { | ||
| 2158 | + static GM_NONTRANS_SMALL_SIDE_HITS: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; | ||
| 2159 | +} | ||
| 2160 | + | ||
| 2161 | +/// Current value of [`GM_NONTRANS_SMALL_SIDE_HITS`]. | ||
| 2162 | +pub fn gm_nontrans_small_side_hits() -> usize { | ||
| 2163 | + GM_NONTRANS_SMALL_SIDE_HITS.with(std::cell::Cell::get) | ||
| 2164 | +} | ||
| 2165 | + | ||
| 2097 | // lane-gmaffine r1: 8x8-leaf-only counters -- how many `BLOCK_8X8` leaves | 2166 | // lane-gmaffine r1: 8x8-leaf-only counters -- how many `BLOCK_8X8` leaves |
| 2098 | // coded `GLOBALMV` (`GLOBALMV_HITS_8`) and how many built a real | 2167 | // coded `GLOBALMV` (`GLOBALMV_HITS_8`) and how many built a real |
| 2099 | // `WARPED_CAUSAL` local-warp prediction there (`WARP_HITS_8`, incremented | 2168 | // `WARPED_CAUSAL` local-warp prediction there (`WARP_HITS_8`, incremented |
| @@ -2442,6 +2511,19 @@ pub(crate) fn intra_rect_in_inter_split_tx_hits() -> [usize; 3] { | |||
| 2442 | INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(std::cell::Cell::get) | 2511 | INTRA_RECT_IN_INTER_SPLIT_TX_HITS.with(std::cell::Cell::get) |
| 2443 | } | 2512 | } |
| 2444 | 2513 | ||
| 2514 | +// lane-midcut r2: rect intra blocks inside an inter frame whose `tx_depth` CDF | ||
| 2515 | +// ROW moved when libaom's inter-neighbour override was applied -- i.e. exactly | ||
| 2516 | +// the blocks the key frame's deblock-grid approximation used to mis-read. | ||
| 2517 | +thread_local! { | ||
| 2518 | + static INTRA_RECT_IN_INTER_TXCTX_OVERRIDE_HITS: std::cell::Cell<usize> = | ||
| 2519 | + const { std::cell::Cell::new(0) }; | ||
| 2520 | +} | ||
| 2521 | + | ||
| 2522 | +/// Current value of [`INTRA_RECT_IN_INTER_TXCTX_OVERRIDE_HITS`]. | ||
| 2523 | +pub(crate) fn intra_rect_in_inter_txctx_override_hits() -> usize { | ||
| 2524 | + INTRA_RECT_IN_INTER_TXCTX_OVERRIDE_HITS.with(std::cell::Cell::get) | ||
| 2525 | +} | ||
| 2526 | + | ||
| 2445 | // lane-intra14 r1: how many intra-coded 1:4 strips decoded on the INTER | 2527 | // lane-intra14 r1: how many intra-coded 1:4 strips decoded on the INTER |
| 2446 | // block path, per shape -- [0] 64x16, [1] 16x64, [2] 32x8, [3] 8x32. Every | 2528 | // block path, per shape -- [0] 64x16, [1] 16x64, [2] 32x8, [3] 8x32. Every |
| 2447 | // one of them was the named refusal "an intra-coded 1:4 (or other non-2:1) | 2529 | // one of them was the named refusal "an intra-coded 1:4 (or other non-2:1) |
| @@ -2515,6 +2597,22 @@ pub(crate) fn uv_mode_mi_override_hits() -> usize { | |||
| 2515 | UV_MODE_MI_OVERRIDE_HITS.with(|c| c.get()) | 2597 | UV_MODE_MI_OVERRIDE_HITS.with(|c| c.get()) |
| 2516 | } | 2598 | } |
| 2517 | 2599 | ||
| 2600 | +// lane-t900 r8: how many intra edge-filter-type reads (luma + chroma) the | ||
| 2601 | +// INTER neighbour stamp saved: the coarse SUB band still held a SMOOTH mode | ||
| 2602 | +// from an earlier block in that pixel row/column while the mi-exact map -- | ||
| 2603 | +// which an inter block only started writing this round -- correctly says the | ||
| 2604 | +// neighbour is not smooth (libaom `is_smooth`: an inter neighbour's `mode` is | ||
| 2605 | +// an INTER mode, and its `uv_mode` "is not set for inter blocks"). | ||
| 2606 | +thread_local! { | ||
| 2607 | + static INTER_NEIGHBOUR_NOT_SMOOTH_HITS: std::cell::Cell<usize> = | ||
| 2608 | + const { std::cell::Cell::new(0) }; | ||
| 2609 | +} | ||
| 2610 | + | ||
| 2611 | +/// Current value of [`INTER_NEIGHBOUR_NOT_SMOOTH_HITS`]. | ||
| 2612 | +pub(crate) fn inter_neighbour_not_smooth_hits() -> usize { | ||
| 2613 | + INTER_NEIGHBOUR_NOT_SMOOTH_HITS.with(|c| c.get()) | ||
| 2614 | +} | ||
| 2615 | + | ||
| 2518 | // lane-mtfix r1: how many times a chroma intra-edge filter-type read was | 2616 | // lane-mtfix r1: how many times a chroma intra-edge filter-type read was |
| 2519 | // suppressed at a TILE edge that is not a frame edge -- the above/left | 2617 | // suppressed at a TILE edge that is not a frame edge -- the above/left |
| 2520 | // `uv_mode` neighbour of a block on a tile's first mi row/column lives in | 2618 | // `uv_mode` neighbour of a block on a tile's first mi row/column lives in |
| @@ -4093,13 +4191,13 @@ fn read_coeffs( | |||
| 4093 | let (range, value) = dec.debug_state(); | 4191 | let (range, value) = dec.debug_state(); |
| 4094 | eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}"); | 4192 | eprintln!("EC_AV1_STATE_BEFORE_TXBSKIP range={range} value={value}"); |
| 4095 | } | 4193 | } |
| 4096 | - let dbg_txbskip = if std::env::var_os("EC_TRACE_COEFF").is_some() { | 4194 | + let dbg_txbskip = if coeff_trace_on() { |
| 4097 | coding.txb_skip[skip_ctx] | 4195 | coding.txb_skip[skip_ctx] |
| 4098 | } else { | 4196 | } else { |
| 4099 | [0; 3] | 4197 | [0; 3] |
| 4100 | }; | 4198 | }; |
| 4101 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; | 4199 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; |
| 4102 | - if std::env::var_os("EC_TRACE_COEFF").is_some() { | 4200 | + if coeff_trace_on() { |
| 4103 | let (rng, _) = dec.debug_state(); | 4201 | let (rng, _) = dec.debug_state(); |
| 4104 | eprintln!( | 4202 | eprintln!( |
| 4105 | "EC_COEFF_STEP tag=all_zero side={} ctx={skip_ctx} cdf={dbg_txbskip:?} all_zero={} rng={rng}", | 4203 | "EC_COEFF_STEP tag=all_zero side={} ctx={skip_ctx} cdf={dbg_txbskip:?} all_zero={} rng={rng}", |
| @@ -4138,7 +4236,7 @@ fn read_coeffs( | |||
| 4138 | eprintln!("EC_AV1_TXTYPE32_CDF {tx_type_cdf:?}"); | 4236 | eprintln!("EC_AV1_TXTYPE32_CDF {tx_type_cdf:?}"); |
| 4139 | } | 4237 | } |
| 4140 | let t = dec.symbol(tx_type_cdf); | 4238 | let t = dec.symbol(tx_type_cdf); |
| 4141 | - if std::env::var_os("EC_TRACE_COEFF").is_some() { | 4239 | + if coeff_trace_on() { |
| 4142 | let (rng, _) = dec.debug_state(); | 4240 | let (rng, _) = dec.debug_state(); |
| 4143 | eprintln!("EC_COEFF_STEP tag=tx_type len={len} rng={rng}"); | 4241 | eprintln!("EC_COEFF_STEP tag=tx_type len={len} rng={rng}"); |
| 4144 | } | 4242 | } |
| @@ -4167,7 +4265,7 @@ fn read_coeffs( | |||
| 4167 | if trace { | 4265 | if trace { |
| 4168 | eprintln!("TRACE eob value={eob}"); | 4266 | eprintln!("TRACE eob value={eob}"); |
| 4169 | } | 4267 | } |
| 4170 | - let ec_trace_coeff = std::env::var_os("EC_TRACE_COEFF").is_some(); | 4268 | + let ec_trace_coeff = coeff_trace_on(); |
| 4171 | if ec_trace_coeff { | 4269 | if ec_trace_coeff { |
| 4172 | let (rng, _) = dec.debug_state(); | 4270 | let (rng, _) = dec.debug_state(); |
| 4173 | let cls = match class { TxClass::TwoD => "2d", TxClass::Horiz => "horiz", TxClass::Vert => "vert" }; | 4271 | let cls = match class { TxClass::TwoD => "2d", TxClass::Horiz => "horiz", TxClass::Vert => "vert" }; |
| @@ -4309,7 +4407,7 @@ fn read_coeffs_rect( | |||
| 4309 | sign_ctx: usize, | 4407 | sign_ctx: usize, |
| 4310 | default_tx_type: TxType, | 4408 | default_tx_type: TxType, |
| 4311 | ) -> Result<(Vec<i32>, TxType)> { | 4409 | ) -> Result<(Vec<i32>, TxType)> { |
| 4312 | - let rect_trace = std::env::var_os("EC_TRACE_COEFF").is_some(); | 4410 | + let rect_trace = coeff_trace_on(); |
| 4313 | let mut grid = vec![0i32; w * h]; | 4411 | let mut grid = vec![0i32; w * h]; |
| 4314 | let entry_rng = dec.debug_state().0; | 4412 | let entry_rng = dec.debug_state().0; |
| 4315 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; | 4413 | let all_zero = dec.symbol(&mut coding.txb_skip[skip_ctx]) == 1; |
| @@ -5322,6 +5420,23 @@ impl Neighbours { | |||
| 5322 | skip_mode: bool, | 5420 | skip_mode: bool, |
| 5323 | ) { | 5421 | ) { |
| 5324 | let (r, c) = at_mi; | 5422 | let (r, c) = at_mi; |
| 5423 | + // lane-t900 r8 (class new-map-ignores-tile-edge's twin: a map NOBODY | ||
| 5424 | + // writes for a whole block class): an INTER block left the luma mode | ||
| 5425 | + // map untouched, so a later intra block's `get_intra_edge_filter_type` | ||
| 5426 | + // (spec 7.11.2, libaom `reconintra.h`'s `is_smooth`) fell back to the | ||
| 5427 | + // coarse SUB-row band, which still held a SMOOTH mode from an earlier | ||
| 5428 | + // block in that pixel row -- the directional edge filter then ran at | ||
| 5429 | + // strength 3 instead of 2. libaom reads `mbmi->mode` of the neighbour, | ||
| 5430 | + // which for an inter block is an INTER mode (>= NEARESTMV) and is | ||
| 5431 | + // never smooth; DC_PRED is this map's equivalent (the sub-8x8 groups | ||
| 5432 | + // already stamped it). | ||
| 5433 | + // The chroma twin: `is_smooth(mbmi, plane > 0)` returns 0 outright for | ||
| 5434 | + // an inter neighbour ("uv_mode is not set for inter blocks"), so the | ||
| 5435 | + // uv map must read DC_PRED over an inter block's cells too. | ||
| 5436 | + if is_inter { | ||
| 5437 | + self.record_mode_mi(r, c, w_mi, h_mi, DC_PRED); | ||
| 5438 | + self.record_uv_mode_mi(r, c, w_mi, h_mi, DC_PRED); | ||
| 5439 | + } | ||
| 5325 | let altref = is_inter && ref_frame == crate::mvstack::ALTREF_FRAME; | 5440 | let altref = is_inter && ref_frame == crate::mvstack::ALTREF_FRAME; |
| 5326 | for cell in 0..w_mi { | 5441 | for cell in 0..w_mi { |
| 5327 | self.above_skip[c + cell] = skip; | 5442 | self.above_skip[c + cell] = skip; |
| @@ -5702,6 +5817,11 @@ impl Neighbours { | |||
| 5702 | if above != self.above_uv_mode[c] || left != self.left_uv_mode[r] { | 5817 | if above != self.above_uv_mode[c] || left != self.left_uv_mode[r] { |
| 5703 | UV_MODE_MI_OVERRIDE_HITS.with(|h| h.set(h.get() + 1)); | 5818 | UV_MODE_MI_OVERRIDE_HITS.with(|h| h.set(h.get() + 1)); |
| 5704 | } | 5819 | } |
| 5820 | + if (is_smooth_mode(self.above_uv_mode[c]) && !is_smooth_mode(above)) | ||
| 5821 | + || (is_smooth_mode(self.left_uv_mode[r]) && !is_smooth_mode(left)) | ||
| 5822 | + { | ||
| 5823 | + INTER_NEIGHBOUR_NOT_SMOOTH_HITS.with(|h| h.set(h.get() + 1)); | ||
| 5824 | + } | ||
| 5705 | is_smooth_mode(above) || is_smooth_mode(left) | 5825 | is_smooth_mode(above) || is_smooth_mode(left) |
| 5706 | } | 5826 | } |
| 5707 | 5827 | ||
| @@ -5757,6 +5877,11 @@ impl Neighbours { | |||
| 5757 | if above != self.above_mode[c] || left != self.left_mode[r] { | 5877 | if above != self.above_mode[c] || left != self.left_mode[r] { |
| 5758 | MODE_MI_OVERRIDE_HITS.with(|h| h.set(h.get() + 1)); | 5878 | MODE_MI_OVERRIDE_HITS.with(|h| h.set(h.get() + 1)); |
| 5759 | } | 5879 | } |
| 5880 | + if (is_smooth_mode(self.above_mode[c]) && !is_smooth_mode(above)) | ||
| 5881 | + || (is_smooth_mode(self.left_mode[r]) && !is_smooth_mode(left)) | ||
| 5882 | + { | ||
| 5883 | + INTER_NEIGHBOUR_NOT_SMOOTH_HITS.with(|h| h.set(h.get() + 1)); | ||
| 5884 | + } | ||
| 5760 | // A neighbour the coarse band offered where the tile edge makes it | 5885 | // A neighbour the coarse band offered where the tile edge makes it |
| 5761 | // unavailable -- must never happen (see `MODE_TILE_EDGE_COARSE_LEAKS`). | 5886 | // unavailable -- must never happen (see `MODE_TILE_EDGE_COARSE_LEAKS`). |
| 5762 | if (mi_r <= self.tile_row0_mi && self.above_mode[c] != DC_PRED) | 5887 | if (mi_r <= self.tile_row0_mi && self.above_mode[c] != DC_PRED) |
| @@ -10011,7 +10136,7 @@ fn decode_block_rect64( | |||
| 10011 | // 32x16/16x32 under a 64x16/16x64 1:4 strip (lane-tx64x16). | 10136 | // 32x16/16x32 under a 64x16/16x64 1:4 strip (lane-tx64x16). |
| 10012 | let (luma_cw, luma_ch) = (bw.min(32), bh.min(32)); | 10137 | let (luma_cw, luma_ch) = (bw.min(32), bh.min(32)); |
| 10013 | let scan32 = default_scan(TX32); | 10138 | let scan32 = default_scan(TX32); |
| 10014 | - if std::env::var_os("EC_TRACE_COEFF").is_some() { | 10139 | + if coeff_trace_on() { |
| 10015 | let (rng, _) = dec.debug_state(); | 10140 | let (rng, _) = dec.debug_state(); |
| 10016 | eprintln!("EC_COEFF plane=0 row={mi_r} col={mi_c} tx_size={luma_cw}x{luma_ch} rng={rng}"); | 10141 | eprintln!("EC_COEFF plane=0 row={mi_r} col={mi_c} tx_size={luma_cw}x{luma_ch} rng={rng}"); |
| 10017 | } | 10142 | } |
| @@ -10053,7 +10178,7 @@ fn decode_block_rect64( | |||
| 10053 | TxType::DctDct, | 10178 | TxType::DctDct, |
| 10054 | )? | 10179 | )? |
| 10055 | }; | 10180 | }; |
| 10056 | - if std::env::var_os("EC_TRACE_COEFF").is_some() { | 10181 | + if coeff_trace_on() { |
| 10057 | let (rng, _) = dec.debug_state(); | 10182 | let (rng, _) = dec.debug_state(); |
| 10058 | eprintln!("EC_COEFF_VAL plane=0 row={mi_r} col={mi_c} rng={rng}"); | 10183 | eprintln!("EC_COEFF_VAL plane=0 row={mi_r} col={mi_c} rng={rng}"); |
| 10059 | } | 10184 | } |
| @@ -10127,7 +10252,7 @@ fn decode_block_rect64( | |||
| 10127 | }; | 10252 | }; |
| 10128 | let u_skip_ctx = usize::from(around[1].0) + usize::from(around[1].1); | 10253 | let u_skip_ctx = usize::from(around[1].0) + usize::from(around[1].1); |
| 10129 | let mut u_coding = cdfs.txb(chroma_set, uv_predict_mode); | 10254 | let mut u_coding = cdfs.txb(chroma_set, uv_predict_mode); |
| 10130 | - if std::env::var_os("EC_TRACE_COEFF").is_some() { | 10255 | + if coeff_trace_on() { |
| 10131 | let (rng, _) = dec.debug_state(); | 10256 | let (rng, _) = dec.debug_state(); |
| 10132 | eprintln!("EC_COEFF plane=1 row={mi_r} col={mi_c} tx_size=rect32x16 rng={rng}"); | 10257 | eprintln!("EC_COEFF plane=1 row={mi_r} col={mi_c} tx_size=rect32x16 rng={rng}"); |
| 10133 | } | 10258 | } |
| @@ -10141,7 +10266,7 @@ fn decode_block_rect64( | |||
| 10141 | dc_sign_ctx(around[1].2), | 10266 | dc_sign_ctx(around[1].2), |
| 10142 | TxType::DctDct, | 10267 | TxType::DctDct, |
| 10143 | )?; | 10268 | )?; |
| 10144 | - if std::env::var_os("EC_TRACE_COEFF").is_some() { | 10269 | + if coeff_trace_on() { |
| 10145 | let (rng, _) = dec.debug_state(); | 10270 | let (rng, _) = dec.debug_state(); |
| 10146 | eprintln!("EC_COEFF_VAL plane=1 row={mi_r} col={mi_c} rng={rng}"); | 10271 | eprintln!("EC_COEFF_VAL plane=1 row={mi_r} col={mi_c} rng={rng}"); |
| 10147 | } | 10272 | } |
| @@ -10181,7 +10306,7 @@ fn decode_block_rect64( | |||
| 10181 | ); | 10306 | ); |
| 10182 | let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1); | 10307 | let v_skip_ctx = usize::from(around[2].0) + usize::from(around[2].1); |
| 10183 | let mut v_coding = cdfs.txb(chroma_set, uv_predict_mode); | 10308 | let mut v_coding = cdfs.txb(chroma_set, uv_predict_mode); |
| 10184 | - if std::env::var_os("EC_TRACE_COEFF").is_some() { | 10309 | + if coeff_trace_on() { |
| 10185 | let (rng, _) = dec.debug_state(); | 10310 | let (rng, _) = dec.debug_state(); |
| 10186 | eprintln!("EC_COEFF plane=2 row={mi_r} col={mi_c} tx_size=rect32x16 rng={rng}"); | 10311 | eprintln!("EC_COEFF plane=2 row={mi_r} col={mi_c} tx_size=rect32x16 rng={rng}"); |
| 10187 | } | 10312 | } |
| @@ -10195,7 +10320,7 @@ fn decode_block_rect64( | |||
| 10195 | dc_sign_ctx(around[2].2), | 10320 | dc_sign_ctx(around[2].2), |
| 10196 | TxType::DctDct, | 10321 | TxType::DctDct, |
| 10197 | )?; | 10322 | )?; |
| 10198 | - if std::env::var_os("EC_TRACE_COEFF").is_some() { | 10323 | + if coeff_trace_on() { |
| 10199 | let (rng, _) = dec.debug_state(); | 10324 | let (rng, _) = dec.debug_state(); |
| 10200 | eprintln!("EC_COEFF_VAL plane=2 row={mi_r} col={mi_c} rng={rng}"); | 10325 | eprintln!("EC_COEFF_VAL plane=2 row={mi_r} col={mi_c} rng={rng}"); |
| 10201 | } | 10326 | } |
| @@ -11052,7 +11177,7 @@ impl PlaneBuf { | |||
| 11052 | let row0: Vec<u16> = prediction[..side.min(8)].to_vec(); | 11177 | let row0: Vec<u16> = prediction[..side.min(8)].to_vec(); |
| 11053 | let col0: Vec<u16> = (0..side.min(8)).map(|r| prediction[r * side]).collect(); | 11178 | let col0: Vec<u16> = (0..side.min(8)).map(|r| prediction[r * side]).collect(); |
| 11054 | eprintln!( | 11179 | eprintln!( |
| 11055 | - "@{} OUR_PRED x={x} y={y} side={side} side={side} mode={mode} ad={angle_delta} sum={sum} row0={row0:?} col0={col0:?}", std::panic::Location::caller() | 11180 | + "@{} OUR_PRED x={x} y={y} side={side} side={side} mode={mode} ad={angle_delta} ft={} sum={sum} row0={row0:?} col0={col0:?}", std::panic::Location::caller(), i32::from(smooth_neighbor) |
| 11056 | ); | 11181 | ); |
| 11057 | } | 11182 | } |
| 11058 | for row in 0..side { | 11183 | for row in 0..side { |
| @@ -13761,12 +13886,26 @@ fn tx_size_context_txfm_rect( | |||
| 13761 | n.left_side_mi[mi_r], | 13886 | n.left_side_mi[mi_r], |
| 13762 | ); | 13887 | ); |
| 13763 | } | 13888 | } |
| 13764 | - match (has_above, has_left) { | 13889 | + let ctx = match (has_above, has_left) { |
| 13765 | (true, true) => usize::from(above) + usize::from(left), | 13890 | (true, true) => usize::from(above) + usize::from(left), |
| 13766 | (true, false) => usize::from(above), | 13891 | (true, false) => usize::from(above), |
| 13767 | (false, true) => usize::from(left), | 13892 | (false, true) => usize::from(left), |
| 13768 | (false, false) => 0, | 13893 | (false, false) => 0, |
| 13894 | + }; | ||
| 13895 | + // lane-midcut r3: count only the blocks the KEY FRAME deblock-grid | ||
| 13896 | + // approximation ([`tx_size_context_rect`]) would have read off a DIFFERENT | ||
| 13897 | + // CDF row, i.e. exactly the blocks this band read fixes -- a plain "rect | ||
| 13898 | + // intra in an inter frame" tally is green on the buggy code too (class | ||
| 13899 | + // gate-blind-to-feature). | ||
| 13900 | + if INTRA_IN_INTER_MODE.with(std::cell::Cell::get).is_some() { | ||
| 13901 | + let (cw, ch) = (own_w.min(64), own_h.min(64)); | ||
| 13902 | + let stale = usize::from(has_above && tx_px_at(n, false, mi_r - 1, mi_c) as usize >= cw) | ||
| 13903 | + + usize::from(has_left && tx_h_px_at(n, false, mi_r, mi_c - 1) as usize >= ch); | ||
| 13904 | + if ctx != stale { | ||
| 13905 | + INTRA_RECT_IN_INTER_TXCTX_OVERRIDE_HITS.with(|c| c.set(c.get() + 1)); | ||
| 13906 | + } | ||
| 13769 | } | 13907 | } |
| 13908 | + ctx | ||
| 13770 | } | 13909 | } |
| 13771 | 13910 | ||
| 13772 | /// lane-intrasplit r3: `above_inter`/`left_inter` are mi-granular bands (they | 13911 | /// lane-intrasplit r3: `above_inter`/`left_inter` are mi-granular bands (they |
| @@ -16061,6 +16200,11 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 16061 | // function is ever called. | 16200 | // function is ever called. |
| 16062 | delta: DeltaParams, | 16201 | delta: DeltaParams, |
| 16063 | ) -> Result<(Picture, Cdfs)> { | 16202 | ) -> Result<(Picture, Cdfs)> { |
| 16203 | + // lane-frame80: [`TX_SELECT_INTER`] is set by the INTER tile decoder | ||
| 16204 | + // only, so a key frame decoded after an inter frame on this thread would | ||
| 16205 | + // otherwise inherit it and read its `tx_depth` context off the inter | ||
| 16206 | + // frame's stale `TXFM_CONTEXT` bands. | ||
| 16207 | + TX_SELECT_INTER.with(|c| c.set(false)); | ||
| 16064 | if mi_cols == 0 || mi_rows == 0 { | 16208 | if mi_cols == 0 || mi_rows == 0 { |
| 16065 | return Err(unsupported("a frame with no mode-info grid")); | 16209 | return Err(unsupported("a frame with no mode-info grid")); |
| 16066 | } | 16210 | } |
| @@ -18728,7 +18872,22 @@ fn find_samples( | |||
| 18728 | let up_available = mi_row > 0; | 18872 | let up_available = mi_row > 0; |
| 18729 | let left_available = mi_col > 0; | 18873 | let left_available = mi_col > 0; |
| 18730 | let mut samples = Vec::with_capacity(MAX); | 18874 | let mut samples = Vec::with_capacity(MAX); |
| 18731 | - let single_ref_match = |info: &MiInfo| info.ref_frame == ref_frame && info.ref_frame1.is_none(); | 18875 | + // lane-t900 r9: `EC_PROJ_MI=<mi_row>,<mi_col>` lists this block's warp |
| 18876 | + // sample candidates in libaom's own order (above, left, top-left, | ||
| 18877 | + // top-right) -- `num_proj_ref >= 1` is what picks the 3-symbol | ||
| 18878 | + // motion_mode alphabet over the 2-symbol obmc one. | ||
| 18879 | + let proj_dbg = std::env::var("EC_PROJ_MI") | ||
| 18880 | + .is_ok_and(|v| v == format!("{mi_row},{mi_col}")); | ||
| 18881 | + let single_ref_match = |info: &MiInfo| { | ||
| 18882 | + let m = info.ref_frame == ref_frame && info.ref_frame1.is_none(); | ||
| 18883 | + if proj_dbg { | ||
| 18884 | + eprintln!( | ||
| 18885 | + "EC_PROJ cand ref={} ref1={:?} size={} size_h={} is_inter={} want={ref_frame} match={m}", | ||
| 18886 | + info.ref_frame, info.ref_frame1, info.size, info.size_h, info.is_inter | ||
| 18887 | + ); | ||
| 18888 | + } | ||
| 18889 | + m | ||
| 18890 | + }; | ||
| 18732 | let mut do_tl = true; | 18891 | let mut do_tl = true; |
| 18733 | let mut do_tr = true; | 18892 | let mut do_tr = true; |
| 18734 | let rec = |info: &MiInfo, row_offset: i32, sign_r: i32, col_offset: i32, sign_c: i32| { | 18893 | let rec = |info: &MiInfo, row_offset: i32, sign_r: i32, col_offset: i32, sign_c: i32| { |
| @@ -18825,7 +18984,18 @@ fn find_samples( | |||
| 18825 | } | 18984 | } |
| 18826 | } | 18985 | } |
| 18827 | 18986 | ||
| 18828 | - if do_tr && has_top_right(mi_row, mi_col, bw4) { | 18987 | + // lane-t900 r9: libaom passes `AOMMAX(xd->width, xd->height)` here |
| 18988 | + // (`mvref_common.c:1235`), NOT the block's width -- a rect block's | ||
| 18989 | + // top-right reach is probed at its LONGER side. With `bw4` a 64x128 | ||
| 18990 | + // block found a top-right sample libaom never sees, so | ||
| 18991 | + // `num_proj_ref >= 1` picked the 3-symbol `motion_mode_cdf` where | ||
| 18992 | + // libaom reads the 2-symbol `obmc_cdf` (class | ||
| 18993 | + // wrong-alphabet-same-value). | ||
| 18994 | + let tr_reach = crate::mvstack::has_top_right(mi_row, mi_col, bw4, bh4); | ||
| 18995 | + if do_tr && bw4 != bh4 && tr_reach != has_top_right(mi_row, mi_col, bw4) { | ||
| 18996 | + TR_REACH_LONGER_SIDE_HITS.with(|c| c.set(c.get() + 1)); | ||
| 18997 | + } | ||
| 18998 | + if do_tr && tr_reach { | ||
| 18829 | let tr_col = mi_col + bw4; | 18999 | let tr_col = mi_col + bw4; |
| 18830 | if mi_row > 0 && tr_col < mi_cols { | 19000 | if mi_row > 0 && tr_col < mi_cols { |
| 18831 | if let Some(info) = grid.get(mi_row - 1, tr_col) { | 19001 | if let Some(info) = grid.get(mi_row - 1, tr_col) { |
| @@ -19895,6 +20065,11 @@ fn decode_inter_block( | |||
| 19895 | } | 20065 | } |
| 19896 | _ => (write_w / 2, write_h / 2), | 20066 | _ => (write_w / 2, write_h / 2), |
| 19897 | }; | 20067 | }; |
| 20068 | + // lane-midcut r3 (same rule as lane-t900 r5's `warp_plane_allowed`, one | ||
| 20069 | + // copy kept at the merge): `av1_init_warp_params` (libaom reconinter.c) | ||
| 20070 | + // bails per PLANE at `block_width < 8 || block_height < 8` -- on the | ||
| 20071 | + // block's own dims, never on the square prediction buffer this reader | ||
| 20072 | + // allocates. | ||
| 19898 | if std::env::var_os("EC_MC_TRACE").is_some() { | 20073 | if std::env::var_os("EC_MC_TRACE").is_some() { |
| 19899 | eprintln!("EC_IB px={px} py={py} side={side} w={write_w} h={write_h}"); | 20074 | eprintln!("EC_IB px={px} py={py} side={side} w={write_w} h={write_h}"); |
| 19900 | } | 20075 | } |
| @@ -20156,9 +20331,16 @@ fn decode_inter_block( | |||
| 20156 | // spec `is_nontrans_global_motion`: ALL active refs' models must | 20331 | // spec `is_nontrans_global_motion`: ALL active refs' models must |
| 20157 | // be non-TRANSLATION (IDENTITY counts) for the compound block's | 20332 | // be non-TRANSLATION (IDENTITY counts) for the compound block's |
| 20158 | // interp-filter read to be suppressed. | 20333 | // interp-filter read to be suppressed. |
| 20159 | - let gm_nontrans = is_globalmv | 20334 | + let gm_nontrans_models = is_globalmv |
| 20160 | && global_motion[(ref0 - LAST_FRAME) as usize].model != ec_av1_syntax::WarpModel::Translation | 20335 | && global_motion[(ref0 - LAST_FRAME) as usize].model != ec_av1_syntax::WarpModel::Translation |
| 20161 | && global_motion[(ref1 - LAST_FRAME) as usize].model != ec_av1_syntax::WarpModel::Translation; | 20336 | && global_motion[(ref1 - LAST_FRAME) as usize].model != ec_av1_syntax::WarpModel::Translation; |
| 20337 | + // lane-t900 r9: `is_nontrans_global_motion` bails at | ||
| 20338 | + // `AOMMIN(mi_size_wide, mi_size_high) < 2` before it looks at any | ||
| 20339 | + // model, so a 4-px-sided block still reads its interp filter. | ||
| 20340 | + let gm_nontrans = gm_nontrans_models && bw4.min(bh4) >= 2; | ||
| 20341 | + if gm_nontrans_models && !gm_nontrans { | ||
| 20342 | + GM_NONTRANS_SMALL_SIDE_HITS.with(|c| c.set(c.get() + 1)); | ||
| 20343 | + } | ||
| 20162 | let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?; | 20344 | let (py0, pu0, pv0) = ref_planes(ref0, ref_y, ref_u, ref_v, other_refs)?; |
| 20163 | let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?; | 20345 | let (py1, pu1, pv1) = ref_planes(ref1, ref_y, ref_u, ref_v, other_refs)?; |
| 20164 | // lane-cwarp r1: `is_global_mv_block` (blockd.h:421-429) is | 20346 | // lane-cwarp r1: `is_global_mv_block` (blockd.h:421-429) is |
| @@ -21509,6 +21691,24 @@ fn decode_inter_block( | |||
| 21509 | // mv reads no motion_mode/obmc symbol at all -- implicit | 21691 | // mv reads no motion_mode/obmc symbol at all -- implicit |
| 21510 | // SIMPLE_TRANSLATION. | 21692 | // SIMPLE_TRANSLATION. |
| 21511 | && !(is_global_mv_block && !force_integer_mv); | 21693 | && !(is_global_mv_block && !force_integer_mv); |
| 21694 | + // lane-t900 r9: the eligibility terms themselves, on the same rung | ||
| 21695 | + // as aomdec's `EC_ISTEP2 name=motion_mode` -- an eligibility | ||
| 21696 | + // mismatch is otherwise invisible (a skipped symbol prints | ||
| 21697 | + // nothing). | ||
| 21698 | + if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { | ||
| 21699 | + eprintln!( | ||
| 21700 | + "EC_MM mi_row={mi_row} mi_col={mi_col} w={write_w} h={write_h} elig={} \ | ||
| 21701 | + ab={} lf={} sw={} skipmode={} ii={} gmb={} rng={}", | ||
| 21702 | + motion_mode_eligible as u8, | ||
| 21703 | + overlappable_above(grid, mi_row, mi_col, bw4, mi_cols as usize, 1).len(), | ||
| 21704 | + overlappable_left(grid, mi_row, mi_col, bh4, mi_rows as usize, 1).len(), | ||
| 21705 | + switchable_motion_mode as u8, | ||
| 21706 | + skip_mode as u8, | ||
| 21707 | + interintra_mode.is_some() as u8, | ||
| 21708 | + is_global_mv_block as u8, | ||
| 21709 | + dec.debug_state().0, | ||
| 21710 | + ); | ||
| 21711 | + } | ||
| 21512 | let mut obmc_selected = false; | 21712 | let mut obmc_selected = false; |
| 21513 | // lane-warp round 2: `Some` when motion_mode == WARPED_CAUSAL | 21713 | // lane-warp round 2: `Some` when motion_mode == WARPED_CAUSAL |
| 21514 | // *and* the local warp estimate is valid (`!wm_params.invalid`, | 21714 | // *and* the local warp estimate is valid (`!wm_params.invalid`, |
| @@ -21668,6 +21868,22 @@ fn decode_inter_block( | |||
| 21668 | OBMC_HITS.with(|c| c.set(c.get() + 1)); | 21868 | OBMC_HITS.with(|c| c.set(c.get() + 1)); |
| 21669 | } | 21869 | } |
| 21670 | } | 21870 | } |
| 21871 | + // lane-t900 r9: which ALPHABET this block read (3-symbol | ||
| 21872 | + // motion_mode vs 2-symbol obmc) and the range after -- the | ||
| 21873 | + // two give the same value with a different narrowing (class | ||
| 21874 | + // wrong-alphabet-same-value). | ||
| 21875 | + if std::env::var_os("EC_TRACE_MODE_STEP").is_some() { | ||
| 21876 | + eprintln!( | ||
| 21877 | + "EC_MM2 mi_row={mi_row} mi_col={mi_col} row={bsize_idx} warp_elig={} \ | ||
| 21878 | + scaled={} fimv={} obmc={} warped={} rng={}", | ||
| 21879 | + warp_eligible as u8, | ||
| 21880 | + ref_is_scaled as u8, | ||
| 21881 | + force_integer_mv as u8, | ||
| 21882 | + obmc_selected as u8, | ||
| 21883 | + warped_selected as u8, | ||
| 21884 | + dec.debug_state().0, | ||
| 21885 | + ); | ||
| 21886 | + } | ||
| 21671 | } | 21887 | } |
| 21672 | // lane-gm r4: `allow_warp`'s `global_warp_allowed` branch | 21888 | // lane-gm r4: `allow_warp`'s `global_warp_allowed` branch |
| 21673 | // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` -- | 21889 | // (`reconinter.c:33-55`), gated INDEPENDENTLY of `motion_mode` -- |
| @@ -23525,7 +23741,14 @@ fn decode_inter_sub8_split4( | |||
| 23525 | neighbours.left_filter[rmi], | 23741 | neighbours.left_filter[rmi], |
| 23526 | ); | 23742 | ); |
| 23527 | } | 23743 | } |
| 23528 | - let gm_nontrans = is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation; | 23744 | + // lane-t900 r9: this reader's sub-blocks have a 4-px side, and libaom |
| 23745 | + // `is_nontrans_global_motion` returns 0 for | ||
| 23746 | + // `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE testing any model -- | ||
| 23747 | + // so a GLOBALMV sub-block here always reads its interp filter. | ||
| 23748 | + if is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation { | ||
| 23749 | + GM_NONTRANS_SMALL_SIDE_HITS.with(|c| c.set(c.get() + 1)); | ||
| 23750 | + } | ||
| 23751 | + let gm_nontrans = false; | ||
| 23529 | let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( | 23752 | let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( |
| 23530 | dec, | 23753 | dec, |
| 23531 | cdfs, | 23754 | cdfs, |
| @@ -24451,7 +24674,14 @@ fn decode_inter_sub8_rect2( | |||
| 24451 | } else { | 24674 | } else { |
| 24452 | [3, 3] | 24675 | [3, 3] |
| 24453 | }; | 24676 | }; |
| 24454 | - let gm_nontrans = is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation; | 24677 | + // lane-t900 r9: this reader's sub-blocks have a 4-px side, and libaom |
| 24678 | + // `is_nontrans_global_motion` returns 0 for | ||
| 24679 | + // `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE testing any model -- | ||
| 24680 | + // so a GLOBALMV sub-block here always reads its interp filter. | ||
| 24681 | + if is_globalmv && gm_ref.model != ec_av1_syntax::WarpModel::Translation { | ||
| 24682 | + GM_NONTRANS_SMALL_SIDE_HITS.with(|c| c.set(c.get() + 1)); | ||
| 24683 | + } | ||
| 24684 | + let gm_nontrans = false; | ||
| 24455 | let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( | 24685 | let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( |
| 24456 | dec, | 24686 | dec, |
| 24457 | cdfs, | 24687 | cdfs, |
| @@ -30193,13 +30423,20 @@ mod tests { | |||
| 30193 | .stderr(Stdio::piped()) | 30423 | .stderr(Stdio::piped()) |
| 30194 | .spawn() | 30424 | .spawn() |
| 30195 | .expect("ffmpeg failed to start"); | 30425 | .expect("ffmpeg failed to start"); |
| 30196 | - child | 30426 | + // lane-t900 r10: the stream goes down stdin on ITS OWN THREAD. Writing |
| 30197 | - .stdin | 30427 | + // it inline deadlocks the moment ffmpeg's stdout pipe buffer (64 KiB) |
| 30198 | - .take() | 30428 | + // fills before the last input byte is written -- which is exactly what |
| 30199 | - .expect("ffmpeg stdin") | 30429 | + // a 1.1 MB fixture decoding to 150 MB of raw 10-bit frames does |
| 30200 | - .write_all(stream) | 30430 | + // (measured: 45 min, both processes at 0% CPU). A write error here is |
| 30201 | - .expect("writing the stream to ffmpeg"); | 30431 | + // swallowed on purpose: ffmpeg's own exit status and stderr, asserted |
| 30432 | + // below, are the real diagnosis. | ||
| 30433 | + let mut stdin = child.stdin.take().expect("ffmpeg stdin"); | ||
| 30434 | + let payload = stream.to_vec(); | ||
| 30435 | + let writer = std::thread::spawn(move || { | ||
| 30436 | + let _ = stdin.write_all(&payload); | ||
| 30437 | + }); | ||
| 30202 | let out = child.wait_with_output().expect("ffmpeg failed to run"); | 30438 | let out = child.wait_with_output().expect("ffmpeg failed to run"); |
| 30439 | + writer.join().expect("ffmpeg stdin writer thread"); | ||
| 30203 | assert!( | 30440 | assert!( |
| 30204 | out.status.success(), | 30441 | out.status.success(), |
| 30205 | "ffmpeg refused the stream: {}", | 30442 | "ffmpeg refused the stream: {}", |
| @@ -30236,13 +30473,20 @@ mod tests { | |||
| 30236 | .stderr(Stdio::piped()) | 30473 | .stderr(Stdio::piped()) |
| 30237 | .spawn() | 30474 | .spawn() |
| 30238 | .expect("ffmpeg failed to start"); | 30475 | .expect("ffmpeg failed to start"); |
| 30239 | - child | 30476 | + // lane-t900 r10: the stream goes down stdin on ITS OWN THREAD. Writing |
| 30240 | - .stdin | 30477 | + // it inline deadlocks the moment ffmpeg's stdout pipe buffer (64 KiB) |
| 30241 | - .take() | 30478 | + // fills before the last input byte is written -- which is exactly what |
| 30242 | - .expect("ffmpeg stdin") | 30479 | + // a 1.1 MB fixture decoding to 150 MB of raw 10-bit frames does |
| 30243 | - .write_all(stream) | 30480 | + // (measured: 45 min, both processes at 0% CPU). A write error here is |
| 30244 | - .expect("writing the stream to ffmpeg"); | 30481 | + // swallowed on purpose: ffmpeg's own exit status and stderr, asserted |
| 30482 | + // below, are the real diagnosis. | ||
| 30483 | + let mut stdin = child.stdin.take().expect("ffmpeg stdin"); | ||
| 30484 | + let payload = stream.to_vec(); | ||
| 30485 | + let writer = std::thread::spawn(move || { | ||
| 30486 | + let _ = stdin.write_all(&payload); | ||
| 30487 | + }); | ||
| 30245 | let out = child.wait_with_output().expect("ffmpeg failed to run"); | 30488 | let out = child.wait_with_output().expect("ffmpeg failed to run"); |
| 30489 | + writer.join().expect("ffmpeg stdin writer thread"); | ||
| 30246 | assert!( | 30490 | assert!( |
| 30247 | out.status.success(), | 30491 | out.status.success(), |
| 30248 | "ffmpeg refused the stream: {}", | 30492 | "ffmpeg refused the stream: {}", |
crates/ec-av1/src/encode.rsmodified+26 -12
| @@ -3566,13 +3566,20 @@ mod tests { | |||
| 3566 | .stderr(Stdio::piped()) | 3566 | .stderr(Stdio::piped()) |
| 3567 | .spawn() | 3567 | .spawn() |
| 3568 | .expect("ffmpeg failed to start"); | 3568 | .expect("ffmpeg failed to start"); |
| 3569 | - child | 3569 | + // lane-t900 r10: the stream goes down stdin on ITS OWN THREAD. Writing |
| 3570 | - .stdin | 3570 | + // it inline deadlocks the moment ffmpeg's stdout pipe buffer (64 KiB) |
| 3571 | - .take() | 3571 | + // fills before the last input byte is written -- which is exactly what |
| 3572 | - .expect("ffmpeg stdin") | 3572 | + // a 1.1 MB fixture decoding to 150 MB of raw 10-bit frames does |
| 3573 | - .write_all(stream) | 3573 | + // (measured: 45 min, both processes at 0% CPU). A write error here is |
| 3574 | - .expect("writing the stream to ffmpeg"); | 3574 | + // swallowed on purpose: ffmpeg's own exit status and stderr, asserted |
| 3575 | + // below, are the real diagnosis. | ||
| 3576 | + let mut stdin = child.stdin.take().expect("ffmpeg stdin"); | ||
| 3577 | + let payload = stream.to_vec(); | ||
| 3578 | + let writer = std::thread::spawn(move || { | ||
| 3579 | + let _ = stdin.write_all(&payload); | ||
| 3580 | + }); | ||
| 3575 | let out = child.wait_with_output().expect("ffmpeg failed to run"); | 3581 | let out = child.wait_with_output().expect("ffmpeg failed to run"); |
| 3582 | + writer.join().expect("ffmpeg stdin writer thread"); | ||
| 3576 | assert!( | 3583 | assert!( |
| 3577 | out.status.success(), | 3584 | out.status.success(), |
| 3578 | "ffmpeg refused the stream: {}", | 3585 | "ffmpeg refused the stream: {}", |
| @@ -5008,13 +5015,20 @@ mod tests { | |||
| 5008 | .stderr(Stdio::piped()) | 5015 | .stderr(Stdio::piped()) |
| 5009 | .spawn() | 5016 | .spawn() |
| 5010 | .expect("ffmpeg failed to start"); | 5017 | .expect("ffmpeg failed to start"); |
| 5011 | - child | 5018 | + // lane-t900 r10: the stream goes down stdin on ITS OWN THREAD. Writing |
| 5012 | - .stdin | 5019 | + // it inline deadlocks the moment ffmpeg's stdout pipe buffer (64 KiB) |
| 5013 | - .take() | 5020 | + // fills before the last input byte is written -- which is exactly what |
| 5014 | - .expect("ffmpeg stdin") | 5021 | + // a 1.1 MB fixture decoding to 150 MB of raw 10-bit frames does |
| 5015 | - .write_all(stream) | 5022 | + // (measured: 45 min, both processes at 0% CPU). A write error here is |
| 5016 | - .expect("writing the stream to ffmpeg"); | 5023 | + // swallowed on purpose: ffmpeg's own exit status and stderr, asserted |
| 5024 | + // below, are the real diagnosis. | ||
| 5025 | + let mut stdin = child.stdin.take().expect("ffmpeg stdin"); | ||
| 5026 | + let payload = stream.to_vec(); | ||
| 5027 | + let writer = std::thread::spawn(move || { | ||
| 5028 | + let _ = stdin.write_all(&payload); | ||
| 5029 | + }); | ||
| 5017 | let out = child.wait_with_output().expect("ffmpeg failed to run"); | 5030 | let out = child.wait_with_output().expect("ffmpeg failed to run"); |
| 5031 | + writer.join().expect("ffmpeg stdin writer thread"); | ||
| 5018 | assert!( | 5032 | assert!( |
| 5019 | out.status.success(), | 5033 | out.status.success(), |
| 5020 | "ffmpeg refused the stream: {}", | 5034 | "ffmpeg refused the stream: {}", |
crates/ec-av1/src/mvstack.rsmodified+25 -5
| @@ -688,11 +688,13 @@ fn top_right_scan_allowed(bw4: usize, bh4: usize) -> bool { | |||
| 688 | /// (what this module did before lane-sb128 r2) cannot see. It cost frame 6 of | 688 | /// (what this module did before lane-sb128 r2) cannot see. It cost frame 6 of |
| 689 | /// the 128 inter gate 380 wrong luma bytes with the entropy stream in sync. | 689 | /// the 128 inter gate 380 wrong luma bytes with the entropy stream in sync. |
| 690 | /// | 690 | /// |
| 691 | -/// corner-cut: libaom's three shape refinements (`is_last_vertical_rect`, | 691 | +/// lane-t900 r10 ports `is_last_vertical_rect` and `is_first_horizontal_rect` |
| 692 | -/// `is_first_horizontal_rect`, the `PARTITION_VERT_A` bottom-left square) are | 692 | +/// (both derivable from `mi_row`/`mi_col`/`bw4`/`bh4` alone). |
| 693 | -/// not ported -- the ceiling is rectangular and AB-partitioned INTER leaves, | 693 | +/// corner-cut: libaom's third refinement (the `PARTITION_VERT_A` bottom-left |
| 694 | -/// which this decoder refuses by name today; port them with the rect inter | 694 | +/// SQUARE, which needs the parent partition type this port does not thread |
| 695 | -/// leaf. | 695 | +/// here) is still missing -- ceiling is a square INTER leaf inside a VERT_A |
| 696 | +/// partition whose warp-sample top-right probe may answer 1 where libaom says | ||
| 697 | +/// 0; upgrade path = thread `partition` into this call. | ||
| 696 | pub(crate) fn has_top_right(mi_row: usize, mi_col: usize, bw4: usize, bh4: usize) -> bool { | 698 | pub(crate) fn has_top_right(mi_row: usize, mi_col: usize, bw4: usize, bh4: usize) -> bool { |
| 697 | let sb_mi_size = crate::decode::sb_mi_cur() as usize; | 699 | let sb_mi_size = crate::decode::sb_mi_cur() as usize; |
| 698 | let bs0 = bw4.max(bh4); | 700 | let bs0 = bw4.max(bh4); |
| @@ -713,6 +715,24 @@ pub(crate) fn has_top_right(mi_row: usize, mi_col: usize, bw4: usize, bh4: usize | |||
| 713 | } | 715 | } |
| 714 | bs <<= 1; | 716 | bs <<= 1; |
| 715 | } | 717 | } |
| 718 | + // lane-t900 r10: two of libaom's three shape refinements, computed from | ||
| 719 | + // the block's own position and side (`av1_common_int.h:1419-1428` sets | ||
| 720 | + // `is_last_vertical_rect` / `is_first_horizontal_rect` from exactly these | ||
| 721 | + // terms, no partition context). They only bite when `bw4 != bh4`, which is | ||
| 722 | + // also the only case where `bs0` differs from the block's width -- probing | ||
| 723 | + // at the longer side WITHOUT them is half a port and moved the first | ||
| 724 | + // divergence of the 10-bit 1080p cut EARLIER (r9). | ||
| 725 | + if bw4 < bh4 { | ||
| 726 | + let is_last_vertical_rect = (mi_col + bw4) & (bh4 - 1) == 0; | ||
| 727 | + if !is_last_vertical_rect { | ||
| 728 | + has_tr = true; | ||
| 729 | + } | ||
| 730 | + } else if bw4 > bh4 { | ||
| 731 | + let is_first_horizontal_rect = mi_row & (bw4 - 1) == 0; | ||
| 732 | + if !is_first_horizontal_rect { | ||
| 733 | + has_tr = false; | ||
| 734 | + } | ||
| 735 | + } | ||
| 716 | has_tr | 736 | has_tr |
| 717 | } | 737 | } |
| 718 | 738 | ||
crates/ec-av1/src/stream.rsmodified+207 -14
| @@ -688,6 +688,35 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 688 | })?) | 688 | })?) |
| 689 | }; | 689 | }; |
| 690 | let started_from = initial_cdfs.clone(); | 690 | let started_from = initial_cdfs.clone(); |
| 691 | + // lane-frame80: narrow the EC_TRACE_COEFF rungs to one DECODE-order frame. | ||
| 692 | + decode::set_coeff_trace_frame(pictures_decoded); | ||
| 693 | + // lane-t900 r9: one line per DECODE-order frame naming the header | ||
| 694 | + // fields a desync cliff is usually keyed on (frame type, base q, | ||
| 695 | + // primary_ref, the 7 ref slots, refresh mask, order hints). | ||
| 696 | + if std::env::var_os("EC_PROBE_HDR").is_some() { | ||
| 697 | + eprintln!( | ||
| 698 | + "EC_HDR decode_idx={pictures_decoded} type={:?} show={} show_existing={} base_q={} primary_ref={} ref_idx={:?} refresh=0x{:02x} order_hint={} tiles={}x{} txmode={:?} interp={:?} reduced_tx={} allow_warp={} switchable_mo={} ref_mvs={} skip_mode={} cdef={:?} lr={:?}", | ||
| 699 | + header.frame_type, | ||
| 700 | + header.show_frame, | ||
| 701 | + header.show_existing_frame, | ||
| 702 | + header.quantization.base_q_idx, | ||
| 703 | + header.primary_ref_frame, | ||
| 704 | + header.ref_frame_idx, | ||
| 705 | + header.refresh_frame_flags, | ||
| 706 | + header.order_hint, | ||
| 707 | + header.tile_info.cols, | ||
| 708 | + header.tile_info.rows, | ||
| 709 | + header.tx_mode, | ||
| 710 | + header.interpolation_filter, | ||
| 711 | + header.reduced_tx_set, | ||
| 712 | + header.allow_warped_motion, | ||
| 713 | + header.is_motion_mode_switchable, | ||
| 714 | + header.use_ref_frame_mvs, | ||
| 715 | + header.skip_mode_present, | ||
| 716 | + header.cdef.bits, | ||
| 717 | + header.loop_restoration.frame_restoration_type, | ||
| 718 | + ); | ||
| 719 | + } | ||
| 691 | 720 | ||
| 692 | let order_hint_bits = parser | 721 | let order_hint_bits = parser |
| 693 | .sequence_header() | 722 | .sequence_header() |
| @@ -1536,13 +1565,20 @@ mod tests { | |||
| 1536 | .stderr(Stdio::piped()) | 1565 | .stderr(Stdio::piped()) |
| 1537 | .spawn() | 1566 | .spawn() |
| 1538 | .expect("ffmpeg failed to start"); | 1567 | .expect("ffmpeg failed to start"); |
| 1539 | - child | 1568 | + // lane-t900 r10: the stream goes down stdin on ITS OWN THREAD. Writing |
| 1540 | - .stdin | 1569 | + // it inline deadlocks the moment ffmpeg's stdout pipe buffer (64 KiB) |
| 1541 | - .take() | 1570 | + // fills before the last input byte is written -- which is exactly what |
| 1542 | - .expect("ffmpeg stdin") | 1571 | + // a 1.1 MB fixture decoding to 150 MB of raw 10-bit frames does |
| 1543 | - .write_all(stream) | 1572 | + // (measured: 45 min, both processes at 0% CPU). A write error here is |
| 1544 | - .expect("writing the stream to ffmpeg"); | 1573 | + // swallowed on purpose: ffmpeg's own exit status and stderr, asserted |
| 1574 | + // below, are the real diagnosis. | ||
| 1575 | + let mut stdin = child.stdin.take().expect("ffmpeg stdin"); | ||
| 1576 | + let payload = stream.to_vec(); | ||
| 1577 | + let writer = std::thread::spawn(move || { | ||
| 1578 | + let _ = stdin.write_all(&payload); | ||
| 1579 | + }); | ||
| 1545 | let out = child.wait_with_output().expect("ffmpeg failed to run"); | 1580 | let out = child.wait_with_output().expect("ffmpeg failed to run"); |
| 1581 | + writer.join().expect("ffmpeg stdin writer thread"); | ||
| 1546 | assert!( | 1582 | assert!( |
| 1547 | out.status.success(), | 1583 | out.status.success(), |
| 1548 | "ffmpeg refused the stream: {}", | 1584 | "ffmpeg refused the stream: {}", |
| @@ -1591,13 +1627,20 @@ mod tests { | |||
| 1591 | .stderr(Stdio::piped()) | 1627 | .stderr(Stdio::piped()) |
| 1592 | .spawn() | 1628 | .spawn() |
| 1593 | .expect("ffmpeg failed to start"); | 1629 | .expect("ffmpeg failed to start"); |
| 1594 | - child | 1630 | + // lane-t900 r10: the stream goes down stdin on ITS OWN THREAD. Writing |
| 1595 | - .stdin | 1631 | + // it inline deadlocks the moment ffmpeg's stdout pipe buffer (64 KiB) |
| 1596 | - .take() | 1632 | + // fills before the last input byte is written -- which is exactly what |
| 1597 | - .expect("ffmpeg stdin") | 1633 | + // a 1.1 MB fixture decoding to 150 MB of raw 10-bit frames does |
| 1598 | - .write_all(stream) | 1634 | + // (measured: 45 min, both processes at 0% CPU). A write error here is |
| 1599 | - .expect("writing the stream to ffmpeg"); | 1635 | + // swallowed on purpose: ffmpeg's own exit status and stderr, asserted |
| 1636 | + // below, are the real diagnosis. | ||
| 1637 | + let mut stdin = child.stdin.take().expect("ffmpeg stdin"); | ||
| 1638 | + let payload = stream.to_vec(); | ||
| 1639 | + let writer = std::thread::spawn(move || { | ||
| 1640 | + let _ = stdin.write_all(&payload); | ||
| 1641 | + }); | ||
| 1600 | let out = child.wait_with_output().expect("ffmpeg failed to run"); | 1642 | let out = child.wait_with_output().expect("ffmpeg failed to run"); |
| 1643 | + writer.join().expect("ffmpeg stdin writer thread"); | ||
| 1601 | assert!( | 1644 | assert!( |
| 1602 | out.status.success(), | 1645 | out.status.success(), |
| 1603 | "ffmpeg refused the stream: {}", | 1646 | "ffmpeg refused the stream: {}", |
| @@ -14001,6 +14044,10 @@ mod tests { | |||
| 14001 | return; | 14044 | return; |
| 14002 | } | 14045 | } |
| 14003 | let (width, height, frame_count) = (64usize, 64usize, 24usize); | 14046 | let (width, height, frame_count) = (64usize, 64usize, 24usize); |
| 14047 | + // lane-midcut r1: rect interintra (`write_w != write_h`) built its | ||
| 14048 | + // intra predictor at the square `side`; this gate passed with that | ||
| 14049 | + // bug, so the shape gets its own delta-counted assert below. | ||
| 14050 | + let rect_before = crate::decode::interintra_rect_hits(); | ||
| 14004 | let mut named_refusals = 0u32; | 14051 | let mut named_refusals = 0u32; |
| 14005 | let mut matched = 0u32; | 14052 | let mut matched = 0u32; |
| 14006 | let n_attempts: u32 = std::env::var("EC_INTERINTRA_GATE_ATTEMPTS") | 14053 | let n_attempts: u32 = std::env::var("EC_INTERINTRA_GATE_ATTEMPTS") |
| @@ -14156,6 +14203,61 @@ mod tests { | |||
| 14156 | decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle" | 14203 | decode-order frames, {arm_hidden} hidden, all pixel-exact vs the oracle" |
| 14157 | ); | 14204 | ); |
| 14158 | } | 14205 | } |
| 14206 | + // lane-midcut r3 RECT ARM: the recipe above spells | ||
| 14207 | + // `--enable-rect-partitions=0 --min-partition-size=32`, so it can | ||
| 14208 | + // never produce a RECT interintra block -- the delta assert at the | ||
| 14209 | + // end of this gate was unsatisfiable on it (the gate disabled the | ||
| 14210 | + // very shape it claims to prove). Re-encode the SAME source with | ||
| 14211 | + // the rect overrides APPENDED (aomenc keeps the LAST occurrence of | ||
| 14212 | + // a repeated flag) and compare every decode-order frame of that | ||
| 14213 | + // stream against aomdec, until a rect interintra block fires. | ||
| 14214 | + if crate::decode::interintra_rect_hits() == rect_before { | ||
| 14215 | + let mut rect_args = args.clone(); | ||
| 14216 | + rect_args.extend_from_slice(&[ | ||
| 14217 | + "--enable-rect-partitions=1", | ||
| 14218 | + "--min-partition-size=8", | ||
| 14219 | + "--max-partition-size=64", | ||
| 14220 | + ]); | ||
| 14221 | + let mut child = Command::new(aomenc_path()) | ||
| 14222 | + .args(&rect_args) | ||
| 14223 | + .stdin(Stdio::piped()) | ||
| 14224 | + .stdout(Stdio::piped()) | ||
| 14225 | + .stderr(Stdio::piped()) | ||
| 14226 | + .spawn() | ||
| 14227 | + .expect("aomenc failed to start"); | ||
| 14228 | + child | ||
| 14229 | + .stdin | ||
| 14230 | + .take() | ||
| 14231 | + .expect("aomenc stdin") | ||
| 14232 | + .write_all(&y4m.stdout) | ||
| 14233 | + .expect("writing y4m to aomenc"); | ||
| 14234 | + let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 14235 | + assert!( | ||
| 14236 | + out.status.success(), | ||
| 14237 | + "{NAME} RECT-ARM: aomenc refused its own recipe plus the rect overrides: {}", | ||
| 14238 | + String::from_utf8_lossy(&out.stderr) | ||
| 14239 | + ); | ||
| 14240 | + let rect_stream = out.stdout; | ||
| 14241 | + match decode_stream(&rect_stream) { | ||
| 14242 | + Err(e) => { | ||
| 14243 | + let msg = e.to_string(); | ||
| 14244 | + assert!( | ||
| 14245 | + msg.contains("unsupported"), | ||
| 14246 | + "{NAME} RECT-ARM failed outright, not a named refusal (seed {seed}): {msg}" | ||
| 14247 | + ); | ||
| 14248 | + eprintln!("{NAME} RECT-ARM: skipped on a named refusal: {msg}"); | ||
| 14249 | + } | ||
| 14250 | + Ok(_) => { | ||
| 14251 | + let (total, hidden) = | ||
| 14252 | + decode_all_frames_vs_oracle(&rect_stream, &format!("{NAME}-rect")); | ||
| 14253 | + eprintln!( | ||
| 14254 | + "{NAME} RECT-ARM: seed {seed}: {total} decode-order frames, {hidden} \ | ||
| 14255 | + hidden, all pixel-exact vs the oracle, interintra_rect_hits={}", | ||
| 14256 | + crate::decode::interintra_rect_hits() - rect_before | ||
| 14257 | + ); | ||
| 14258 | + } | ||
| 14259 | + } | ||
| 14260 | + } | ||
| 14159 | matched += 1; | 14261 | matched += 1; |
| 14160 | } | 14262 | } |
| 14161 | assert!( | 14263 | assert!( |
| @@ -14175,9 +14277,15 @@ mod tests { | |||
| 14175 | "{NAME}: {matched} matches but zero UNIDIR_COMP_REFERENCE pairs read -- \ | 14277 | "{NAME}: {matched} matches but zero UNIDIR_COMP_REFERENCE pairs read -- \ |
| 14176 | --enable-onesided-comp=1 never reached the uni_comp_ref alphabet" | 14278 | --enable-onesided-comp=1 never reached the uni_comp_ref alphabet" |
| 14177 | ); | 14279 | ); |
| 14280 | + assert!( | ||
| 14281 | + crate::decode::interintra_rect_hits() > rect_before, | ||
| 14282 | + "{NAME}: {matched} matches but zero RECTANGULAR interintra blocks fired -- the \ | ||
| 14283 | + square-only blend defect (lane-midcut r1) would pass this gate unseen" | ||
| 14284 | + ); | ||
| 14178 | eprintln!( | 14285 | eprintln!( |
| 14179 | - "{NAME}: {named_refusals} other-capability refusals, {matched} pixel-exact matches out of {n_attempts}, interintra_hits={} uni_comp_hits={}", | 14286 | + "{NAME}: {named_refusals} other-capability refusals, {matched} pixel-exact matches out of {n_attempts}, interintra_hits={} interintra_rect_hits={} uni_comp_hits={}", |
| 14180 | crate::decode::interintra_hits(), | 14287 | crate::decode::interintra_hits(), |
| 14288 | + crate::decode::interintra_rect_hits() - rect_before, | ||
| 14181 | crate::decode::uni_comp_hits() | 14289 | crate::decode::uni_comp_hits() |
| 14182 | ); | 14290 | ); |
| 14183 | } | 14291 | } |
| @@ -30358,6 +30466,11 @@ mod tests { | |||
| 30358 | crate::decode::edge_filter_mi_fix_hits(), | 30466 | crate::decode::edge_filter_mi_fix_hits(), |
| 30359 | ); | 30467 | ); |
| 30360 | let sub8tx_before = crate::decode::sub8_chroma_tx_from_ref_hits(); | 30468 | let sub8tx_before = crate::decode::sub8_chroma_tx_from_ref_hits(); |
| 30469 | + // lane-t900 r8: the intra edge-filter type an INTER neighbour keeps | ||
| 30470 | + // non-smooth (the coarse SUB band still holds an older SMOOTH mode). | ||
| 30471 | + let notsmooth_before = crate::decode::inter_neighbour_not_smooth_hits(); | ||
| 30472 | + // lane-t900 r10: the rect warp top-right reach (600 blocks here). | ||
| 30473 | + let tr_before = crate::decode::tr_reach_longer_side_hits(); | ||
| 30361 | let i16_before = crate::decode::intra16x4_in_inter_hits(); | 30474 | let i16_before = crate::decode::intra16x4_in_inter_hits(); |
| 30362 | let frames = match decode_stream(&stream) { | 30475 | let frames = match decode_stream(&stream) { |
| 30363 | Ok(frames) => frames, | 30476 | Ok(frames) => frames, |
| @@ -30373,6 +30486,8 @@ mod tests { | |||
| 30373 | crate::decode::edge_filter_mi_fix_hits() - before.6, | 30486 | crate::decode::edge_filter_mi_fix_hits() - before.6, |
| 30374 | ); | 30487 | ); |
| 30375 | let sub8tx = crate::decode::sub8_chroma_tx_from_ref_hits() - sub8tx_before; | 30488 | let sub8tx = crate::decode::sub8_chroma_tx_from_ref_hits() - sub8tx_before; |
| 30489 | + let notsmooth = crate::decode::inter_neighbour_not_smooth_hits() - notsmooth_before; | ||
| 30490 | + let tr = crate::decode::tr_reach_longer_side_hits() - tr_before; | ||
| 30376 | let i16_now = crate::decode::intra16x4_in_inter_hits(); | 30491 | let i16_now = crate::decode::intra16x4_in_inter_hits(); |
| 30377 | let i16 = ( | 30492 | let i16 = ( |
| 30378 | i16_now.0 - i16_before.0, | 30493 | i16_now.0 - i16_before.0, |
| @@ -30391,6 +30506,8 @@ mod tests { | |||
| 30391 | ("intra16x4_in_inter 4x16", i16.1), | 30506 | ("intra16x4_in_inter 4x16", i16.1), |
| 30392 | ("intra16x4_in_inter chroma_ref", i16.2), | 30507 | ("intra16x4_in_inter chroma_ref", i16.2), |
| 30393 | ("sub8_chroma_tx_from_ref", sub8tx), | 30508 | ("sub8_chroma_tx_from_ref", sub8tx), |
| 30509 | + ("inter_neighbour_not_smooth", notsmooth), | ||
| 30510 | + ("tr_reach_longer_side", tr), | ||
| 30394 | ] { | 30511 | ] { |
| 30395 | assert!( | 30512 | assert!( |
| 30396 | n > 0, | 30513 | n > 0, |
| @@ -30416,11 +30533,87 @@ mod tests { | |||
| 30416 | "{NAME}: 15 shown frames pixel-exact on every plane; warp_plane_suppress={} \ | 30533 | "{NAME}: 15 shown frames pixel-exact on every plane; warp_plane_suppress={} \ |
| 30417 | cdef_idx={} inter_sb128_vert={} interintra_rect={} non_chroma_ref_ctx_skip={} \ | 30534 | cdef_idx={} inter_sb128_vert={} interintra_rect={} non_chroma_ref_ctx_skip={} \ |
| 30418 | intra_in_inter_txctx={} edge_filter_mi_fix={} intra16x4_in_inter={:?} \ | 30535 | intra_in_inter_txctx={} edge_filter_mi_fix={} intra16x4_in_inter={:?} \ |
| 30419 | - sub8_chroma_tx_from_ref={sub8tx}", | 30536 | + sub8_chroma_tx_from_ref={sub8tx} inter_neighbour_not_smooth={notsmooth} \ |
| 30537 | + tr_reach_longer_side={tr}", | ||
| 30420 | fired.0, fired.1, fired.2, fired.3, fired.4, fired.5, fired.6, i16 | 30538 | fired.0, fired.1, fired.2, fired.3, fired.4, fired.5, fired.6, i16 |
| 30421 | ); | 30539 | ); |
| 30422 | } | 30540 | } |
| 30423 | 30541 | ||
| 30542 | + /// lane-t900 r10: the small-side GLOBALMV / rect warp-reach witness. | ||
| 30543 | + /// `crates/ec-av1/fixtures/gm_small_side_witness.obu`, 1158066 bytes, | ||
| 30544 | + /// sha256 `f1cdbcbb8d6d469c7957d70252ab42b24ab75f48a717600ffa25991458775dca`: | ||
| 30545 | + /// the first 50 frame-carrying OBUs of a 2 s cut taken 5400 s into a 10-bit | ||
| 30546 | + /// 1920x792 AV1 stream with `use_128x128_superblock=1` -- 34 decode-order | ||
| 30547 | + /// frames, 33 shown, every ARF in it coded with `allow_warped_motion=1`. | ||
| 30548 | + /// Truncated twice independently from the same source, both cuts hash | ||
| 30549 | + /// identically. All 34 DECODE-order frames (the hidden ARF included) were | ||
| 30550 | + /// compared byte-exact against instrumented aomdec with `EC_AV1_FINAL_DUMP` | ||
| 30551 | + /// -- see the lane report's EVIDENCE line; the gate itself compares the 33 | ||
| 30552 | + /// shown frames on every plane, which is all ffmpeg hands back. | ||
| 30553 | + /// | ||
| 30554 | + /// It is the only stream in this repository that fires BOTH r9/r10 paths: | ||
| 30555 | + /// | ||
| 30556 | + /// * `gm_nontrans_small_side_hits` -- libaom `is_nontrans_global_motion` | ||
| 30557 | + /// returns 0 at `AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE it looks | ||
| 30558 | + /// at any warp model, so a GLOBALMV block with a 4-px side still reads | ||
| 30559 | + /// its interp filter. We suppressed that symbol before r9. | ||
| 30560 | + /// * `tr_reach_longer_side_hits` -- `av1_findSamples` probes the top-right | ||
| 30561 | + /// warp sample at `AOMMAX(xd->width, xd->height)` (mvref_common.c:1235) | ||
| 30562 | + /// with libaom's two rect shape refinements | ||
| 30563 | + /// (`is_last_vertical_rect` / `is_first_horizontal_rect`, | ||
| 30564 | + /// av1_common_int.h:1419-1428) applied; probing at the block's WIDTH | ||
| 30565 | + /// instead picks the 3-symbol `motion_mode` alphabet where libaom reads | ||
| 30566 | + /// the 2-symbol `obmc` one -- same value, different narrowing. | ||
| 30567 | + #[test] | ||
| 30568 | + fn a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_reach_decode_pixel_exact() { | ||
| 30569 | + const NAME: &str = | ||
| 30570 | + "a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_reach_decode_pixel_exact"; | ||
| 30571 | + if !have_ffmpeg() { | ||
| 30572 | + eprintln!("SKIP {NAME}: no ffmpeg"); | ||
| 30573 | + return; | ||
| 30574 | + } | ||
| 30575 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | ||
| 30576 | + .join("fixtures/gm_small_side_witness.obu"); | ||
| 30577 | + let stream = std::fs::read(&path) | ||
| 30578 | + .unwrap_or_else(|e| panic!("{NAME}: reading {}: {e}", path.display())); | ||
| 30579 | + let (width, height) = (1920usize, 792usize); | ||
| 30580 | + let gm_before = crate::decode::gm_nontrans_small_side_hits(); | ||
| 30581 | + let tr_before = crate::decode::tr_reach_longer_side_hits(); | ||
| 30582 | + let frames = match decode_stream(&stream) { | ||
| 30583 | + Ok(frames) => frames, | ||
| 30584 | + Err(e) => panic!("{NAME}: decode_stream refused: {e}"), | ||
| 30585 | + }; | ||
| 30586 | + let gm = crate::decode::gm_nontrans_small_side_hits() - gm_before; | ||
| 30587 | + let tr = crate::decode::tr_reach_longer_side_hits() - tr_before; | ||
| 30588 | + assert!( | ||
| 30589 | + gm > 0, | ||
| 30590 | + "{NAME}: gm_nontrans_small_side never fired -- the gate would be vacuous for it" | ||
| 30591 | + ); | ||
| 30592 | + assert!( | ||
| 30593 | + tr > 0, | ||
| 30594 | + "{NAME}: tr_reach_longer_side never fired -- the gate would be vacuous for it" | ||
| 30595 | + ); | ||
| 30596 | + assert_eq!(frames.len(), 33, "{NAME}: 33 shown frames"); | ||
| 30597 | + assert_eq!((frames[0].width, frames[0].height), (width, height)); | ||
| 30598 | + let ffmpeg_frames = ffmpeg_decode_sequence_10bit(&stream, width, height, frames.len()); | ||
| 30599 | + assert_eq!( | ||
| 30600 | + ffmpeg_frames.len(), | ||
| 30601 | + frames.len(), | ||
| 30602 | + "{NAME}: ffmpeg returned {} frames, we decoded {}", | ||
| 30603 | + ffmpeg_frames.len(), | ||
| 30604 | + frames.len() | ||
| 30605 | + ); | ||
| 30606 | + for (i, (ours, theirs)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | ||
| 30607 | + assert_eq!(ours.y, theirs.y, "{NAME}: frame {i} luma vs ffmpeg"); | ||
| 30608 | + assert_eq!(ours.u, theirs.u, "{NAME}: frame {i} U vs ffmpeg"); | ||
| 30609 | + assert_eq!(ours.v, theirs.v, "{NAME}: frame {i} V vs ffmpeg"); | ||
| 30610 | + } | ||
| 30611 | + eprintln!( | ||
| 30612 | + "{NAME}: 33 shown frames pixel-exact on every plane; \ | ||
| 30613 | + gm_nontrans_small_side={gm} tr_reach_longer_side={tr}" | ||
| 30614 | + ); | ||
| 30615 | + } | ||
| 30616 | + | ||
| 30424 | 30617 | ||
| 30425 | /// lane-sub8x4 r2, the gate that lifts BOTH sub-8x8 intra refusals ("an | 30618 | /// lane-sub8x4 r2, the gate that lifts BOTH sub-8x8 intra refusals ("an |
| 30426 | /// intra 4x4 block inside an inter frame's sub-8x8 split" and "an intra | 30619 | /// intra 4x4 block inside an inter frame's sub-8x8 split" and "an intra |
crates/ec-av1/src/tile.rsmodified+13 -6
| @@ -3017,13 +3017,20 @@ mod tests { | |||
| 3017 | .stderr(Stdio::piped()) | 3017 | .stderr(Stdio::piped()) |
| 3018 | .spawn() | 3018 | .spawn() |
| 3019 | .expect("ffmpeg failed to start"); | 3019 | .expect("ffmpeg failed to start"); |
| 3020 | - child | 3020 | + // lane-t900 r10: the stream goes down stdin on ITS OWN THREAD. Writing |
| 3021 | - .stdin | 3021 | + // it inline deadlocks the moment ffmpeg's stdout pipe buffer (64 KiB) |
| 3022 | - .take() | 3022 | + // fills before the last input byte is written -- which is exactly what |
| 3023 | - .expect("ffmpeg stdin") | 3023 | + // a 1.1 MB fixture decoding to 150 MB of raw 10-bit frames does |
| 3024 | - .write_all(stream) | 3024 | + // (measured: 45 min, both processes at 0% CPU). A write error here is |
| 3025 | - .expect("writing the stream to ffmpeg"); | 3025 | + // swallowed on purpose: ffmpeg's own exit status and stderr, asserted |
| 3026 | + // below, are the real diagnosis. | ||
| 3027 | + let mut stdin = child.stdin.take().expect("ffmpeg stdin"); | ||
| 3028 | + let payload = stream.to_vec(); | ||
| 3029 | + let writer = std::thread::spawn(move || { | ||
| 3030 | + let _ = stdin.write_all(&payload); | ||
| 3031 | + }); | ||
| 3026 | let out = child.wait_with_output().expect("ffmpeg failed to run"); | 3032 | let out = child.wait_with_output().expect("ffmpeg failed to run"); |
| 3033 | + writer.join().expect("ffmpeg stdin writer thread"); | ||
| 3027 | assert!( | 3034 | assert!( |
| 3028 | out.status.success(), | 3035 | out.status.success(), |
| 3029 | "ffmpeg refused the stream: {}", | 3036 | "ffmpeg refused the stream: {}", |
lanes/frame80-r1.handoff.mdadded+65 -0
| @@ -0,0 +1,65 @@ | |||
| 1 | +# lane-frame80 r1 HANDOFF — the rect intra `tx_depth` context used the key frame's grid inside inter frames | ||
| 2 | + | ||
| 3 | +## Stream / repro | ||
| 4 | +- Cut: `~/.cache/frame80-tmp/t120.obu` = `~/.cache/hg-0-10s.obu` (10-bit 3840x1608 10 s head) | ||
| 5 | + truncated to the first **120 frame-carrying OBUs** with | ||
| 6 | + `python3 <scratchpad>/census4/trunc.py <in> 120 t120.obu` (445416 B, | ||
| 7 | + sha256 `045d81a9691540220292663cecbc9a2eeb38db6624a714d3d0150544590a9128`, hashed twice, equal). | ||
| 8 | + 120 OBUs = DECODE-order frames 0..80 (the OBU count is NOT the decode index: `show_existing_frame` | ||
| 9 | + headers count as frame OBUs; n=81 only reaches decode frame ~57). | ||
| 10 | +- Every probe on this stream needs `EC_INTRA16X4_DECODE=1 EC_INTRA128_IN_INTER=1`; without them the | ||
| 11 | + full 10 s cut stops at decode frame 62 on the 16x4-in-inter refusal (main 243f125 re-added it), | ||
| 12 | + which is NOT the golomb wall. | ||
| 13 | + | ||
| 14 | +## New instrument (committed) | ||
| 15 | +- `decode.rs` `set_coeff_trace_frame` / `coeff_trace_on`: `EC_TRACE_COEFF_FRAME=<decode idx>` narrows | ||
| 16 | + every `EC_TRACE_COEFF` rung to one DECODE-order frame; unset = every frame (old behaviour). | ||
| 17 | + Also prints `EC_COEFF_FRAME decode_idx=N` per frame under `EC_TRACE_COEFF`, which is what makes the | ||
| 18 | + our-side trace splittable. Wired from `stream.rs` (`decode::set_coeff_trace_frame(pictures_decoded)`). | ||
| 19 | +- Cross-decoder coefficient ladder recipe (`~/.cache/frame80-tmp/lad3.py`): aomdec's and our tag order | ||
| 20 | + differ inside a TU (ours prints `br` before `base_eob`, aomdec after; ours splits `sign`/`sign_rect`; | ||
| 21 | + aomdec prints `tag=tx_type` unconditionally for luma even when no symbol is read). Ladder ONLY on | ||
| 22 | + tags `{all_zero, eob, after_bases}` + rng. On that key our frames 1..62 align element-exactly inside | ||
| 23 | + aomdec's whole-stream trace by substring search of the frame's first 30 elements. | ||
| 24 | + | ||
| 25 | +## First diverging element (this is NOT in frame 80 — the charter premise was stale) | ||
| 26 | +DECODE frame **62** (not 80), frame-local ladder element 3981: | ||
| 27 | +- Block **mi_row=108 mi_col=528**, an INTRA block inside an inter frame, luma 32x8 (BLOCK_32X8), | ||
| 28 | + luma TU TX_32X8 (aomdec `tx_size=16`), chroma TX_16X4; its above neighbour mi(106,528) is an INTER | ||
| 29 | + 32x8 block whose var-tx tree split (txfm ctx 16 px wide). | ||
| 30 | +- Symbol: the block's `tx_depth` (`read_selected_tx_size`, cat=2). | ||
| 31 | + aomdec `EC_ISTEP mi_row=108 mi_col=528 name=tx_depth val=0 ctx=2 cat=2 rng=60142`; | ||
| 32 | + ours computed **ctx=1** (`EC_TXCTX ... w=32 h=8 above_px=16 left_px=64 ctx=1`) and left the range at | ||
| 33 | + 43516 where aomdec has 60142; the next luma `all_zero` then reads ctx=5/rng=41484 vs aomdec ctx=0/rng=60138. | ||
| 34 | +- Entry ranges agree (both 49400 at the end of the previous block's chroma TU), so the divergence is | ||
| 35 | + exactly this one CDF-row choice. | ||
| 36 | + | ||
| 37 | +## Root cause (fixed, committed) | ||
| 38 | +`get_tx_size_context` (libaom `av1/common/pred_common.h:342`) overrides the `TXFM_CONTEXT` bands when a | ||
| 39 | +neighbour is an INTER block: `above = block_size_wide[above_mbmi->bsize] >= max_tx_wide` | ||
| 40 | +(mirror for left/height). Our `tx_size_context_rect` (the KEY frame's deblock-grid approximation) has no | ||
| 41 | +such override and was being used for rect intra strips inside INTER frames; `tx_size_context_txfm_rect` | ||
| 42 | +(which has the override) was reachable only from `decode_intra_rect_in_inter`. | ||
| 43 | +Fix, at the two single points every caller routes through (`crates/ec-av1/src/decode.rs`): | ||
| 44 | +- `tx_size_context_rect` → delegates to `tx_size_context_txfm_rect` when `TX_SELECT_INTER` is set | ||
| 45 | + (covers `decode_block_rect`, `decode_leaf_rect`, `decode_block_rect4`, `decode_rect4_16_strip`). | ||
| 46 | +- `tx_size_context` (square, used by `read_tx_size(.., None)`) → delegates to `tx_size_context_txfm`. | ||
| 47 | +- `decode_key_frame_tile_with_cdfs` now clears `TX_SELECT_INTER` (it was set by the inter tile decoder | ||
| 48 | + only, so a key frame after an inter frame on the same thread inherited it). | ||
| 49 | + | ||
| 50 | +## State after the fix (measured) | ||
| 51 | +`EC_INTRA16X4_DECODE=1 EC_INTRA128_IN_INTER=1 EC_FRAMES=1 EC_GOLOMB=1 decode_probe ~/.cache/hg-0-10s.obu` | ||
| 52 | +→ decode-order frames 0..**84** decode (was 0..79); the wall moves to decode frame 85, still the | ||
| 53 | +"a Golomb tail longer than this decoder reads" refusal (`EC_GOLOMB_LONG w=32 h=32 pos=353 base=15 length=21`), | ||
| 54 | +i.e. still our own desync, now 5 frames later. | ||
| 55 | + | ||
| 56 | +## Exact next step | ||
| 57 | +1. Re-cut for decode frame 85 (bump the OBU count until `EC_FRAME_OK` shows 85 frames, ~n=127) and | ||
| 58 | + re-run the ladder: `python3 ~/.cache/frame80-tmp/lad3.py <aom_start_idx> <frame>` after locating the | ||
| 59 | + frame's start with the first-30-elements substring search (see lad.py/lad2.py in the same dir). | ||
| 60 | + Sweep frames 63..85 the same way — several of them failed head-alignment before the fix; re-check | ||
| 61 | + which still do. | ||
| 62 | +2. NOT DONE (owner: next round): pixel compare of the fixed frames vs ffmpeg with | ||
| 63 | + `<scratchpad>/census7/streamcmp.py`; frame 57's two tx_depth divergences; the witness fixture | ||
| 64 | + `crates/ec-av1/fixtures/reelb_head_frame80_witness.obu` + its gate; `cargo test -p ec-av1 --lib` suite. | ||
| 65 | + The fix is entropy-verified on the ladder and by the 5-frame wall move only. | ||
lanes/midcut-r1.handoff.mdadded+76 -0
| @@ -0,0 +1,76 @@ | |||
| 1 | +# lane-midcut r1 handoff (turn cap) | ||
| 2 | + | ||
| 3 | +## Verdict: (C) real reconstruction desync. NOT (A) alignment, NOT (B) film grain. | ||
| 4 | + | ||
| 5 | +Reproducer, hashed twice, 325 KB: `~/.cache/midcut-tmp/h2400.t2.obu` | ||
| 6 | += `ffmpeg -ss 2400 -t 2 -c:v copy -f obu` on the 10-bit 3840x1608 stream | ||
| 7 | +(sha256 2f62dd1f74bffe10973494404ee4d1a695d2d327b88fb1891c63452b5d47c895 for the | ||
| 8 | +full 2 s cut) truncated to its first 2 frame OBUs (census7 `trunc.py`). | ||
| 9 | +It holds the whole defect: key frame + first hidden alt-ref. | ||
| 10 | + | ||
| 11 | +### Measurements that separated A/B/C | ||
| 12 | +1. (A) ruled out. ffmpeg decodes 261 frames from the 2 s cut; our OUT16 frames | ||
| 13 | + are in display order and monotone in `order_hint` (HDR dump: 114 key, then | ||
| 14 | + 115,116(show_existing 7),117,118(se 6),119,120,121...). An 8x8 cross-compare | ||
| 15 | + of our 8 shown frames vs ffmpeg's 8 (grain off both sides) has NO near-zero | ||
| 16 | + off-diagonal: every ours[i] is 13-16 MB from every ffmpeg[j]. Frames are | ||
| 17 | + aligned; the census tool was measuring the truth. | ||
| 18 | +2. (B) ruled out. `EC_AV1_NO_GRAIN=1` (added this round, `stream.rs`) vs | ||
| 19 | + `ffmpeg -c:v libdav1d -filmgrain 0`: first_diff_frame=1, 13450726 bytes -- | ||
| 20 | + the same mismatch as grain-on/grain-on (13458423). Grain is not it. | ||
| 21 | +3. (C) located. Decode-order compare of `EC_AV1_PREFILT_DUMP16` ours vs the | ||
| 22 | + instrumented aomdec: f0 (key) EXACT, f1 (hidden ARF) 4386319 luma px wrong, | ||
| 23 | + confined to superblocks (0,17) and (0,58) at first, then spreading. | ||
| 24 | + Pre-deblock and post-deblock diffs are identical -> reconstruction, not filters. | ||
| 25 | + | ||
| 26 | +### Root cause found and FIXED (commit 43e9909) | ||
| 27 | +First bad pixel (17,1088) sat in the block aomdec reports as | ||
| 28 | +`EC_MODE_VAL mi_row=4 mi_col=272 mode=13 ref0=1 ref1=0` -- ref1=0 is INTRA_FRAME, | ||
| 29 | +i.e. an INTERINTRA block, and its footprint is 32x16. | ||
| 30 | +`decode.rs interintra_blend` took ONE `side` and used it for the edge fetch, the | ||
| 31 | +intra predictor's (bw,bh), `ii_size_scales` and the blend bounds. On a rect block | ||
| 32 | +`side` is the LONGER dimension, so a 32x16 block got a 32x32 SMOOTH/DC predictor | ||
| 33 | +built off 32 rows of left edge (16 of them not yet decoded). The error signature | ||
| 34 | +matches exactly: rank-1 (sv 90 vs 18), exactly 0 on the block's first row, growing | ||
| 35 | +downward -- the `sm_weights_h` divergence between height-32 and height-16 SMOOTH_PRED. | ||
| 36 | +Fix: `interintra_blend(plane, x, y, bw, bh, stride, ..)` -- `edges_rect`/`predict` | ||
| 37 | +at the true footprint, mask scale `128 / max(bw,bh)`, loop `bh x bw`, `pred` | ||
| 38 | +indexed at the buffer stride. New `interintra_rect_hits()` counter + `decode_probe` | ||
| 39 | +line + a delta-counted hard assert in | ||
| 40 | +`a_real_aomenc_stream_with_interintra_decodes_pixel_exact` (NOT yet run: turn cap). | ||
| 41 | +Result: superblock (0,17) is now exact; f1's first mismatch moves to (448,1152). | ||
| 42 | + | ||
| 43 | +### The NEXT defect (this is the exact next step) | ||
| 44 | +Same 2-frame reproducer, frame 1, block mi_row=112 mi_col=288, a 32x16 NEARMV | ||
| 45 | +block (`TRACE_RECT_SPLIT mi_row=108 mi_col=288 bw=32 bh=16`): | ||
| 46 | + aomdec `EC_MODE_VAL mi_row=112 mi_col=288 mode=14 ref0=1 ref1=-1 mv0=(-32,-350) stack=4` | ||
| 47 | + ours `EC_TRACE mi_row=112 mi_col=288 mv=(-40,-340) is_new_mv=false bsize=32` | ||
| 48 | +Entropy stays in sync (later blocks' rng match; the frame does not refuse), so it | ||
| 49 | +is the mv STACK content/order, not a symbol. Suspect the same class as the fix | ||
| 50 | +above: an mv-stack scan taking the square `side` instead of the block's true | ||
| 51 | +`write_w`/`write_h` (`find_mv_stack` call sites decode.rs:18005 and :30091 -- | ||
| 52 | +check the bw4/bh4 arguments there first). Ladder: aomdec `EC_TRACE_MODE=1` | ||
| 53 | +(`EC_MODE_MV` lines) vs ours for that mi; artifacts already on disk: | ||
| 54 | +`~/.cache/midcut-tmp/am.txt` (aomdec, 2-frame cut) and `tr2.txt` (ours). | ||
| 55 | + | ||
| 56 | +### Re-measured table (24 offsets, 2 s cut truncated to 4 frame OBUs, | ||
| 57 | +### decode-order bytes vs instrumented aomdec, AFTER the fix) | ||
| 58 | +`~/.cache/midcut-tmp/cen/after.tsv`. f0 is exact at EVERY offset. ss=0 is fully | ||
| 59 | +exact (0,0,0,0) -- and is the ONLY offset with `interintra_rect: 0`, which is why | ||
| 60 | +the head cut never saw this bug. Every other offset still diverges at f1 or f2 | ||
| 61 | +because of the NEARMV defect above; rect-interintra blocks per 4-frame prefix run | ||
| 62 | +1..645. Sample: 0 -> 0,0,0,0 | 300 -> 0,2362684,5576522,10902022 | | ||
| 63 | +2400 -> 0,11010633,7316581,15127483 | 4200 -> 0,607935,837,586 | | ||
| 64 | +4800 -> 0,537,5724744,14232841 | 6000 -> 0,806,6192253,13728776. | ||
| 65 | + | ||
| 66 | +### Owed / not done (turn cap) | ||
| 67 | +- deferred: run `a_real_aomenc_stream_with_interintra_decodes_pixel_exact` with the | ||
| 68 | + new rect assert (`cargo test -p ec-av1 --lib interintra`) -- unblocked by a free | ||
| 69 | + turn; `cargo check -p ec-av1 --lib` is CLEAN on this tree. | ||
| 70 | +- deferred: full suite. A run was started under unit `midcut-suite-r1-1788371174` | ||
| 71 | + on commit 43e9909 (log `$HOME/.cache/midcut-suite.log`) and had not reached | ||
| 72 | + `test result` at the cap. | ||
| 73 | +- deferred: no fixture pinned. The film prefix is NOT pixel-exact yet (the NEARMV | ||
| 74 | + defect), so a hard-counter gate on it would have to assert a mismatch; pin it | ||
| 75 | + once the mv-stack defect is fixed. | ||
| 76 | +- no refusal was lifted or moved; refusal_inventory/gate_coverage untouched. | ||
lanes/midcut-r2.handoff.mdadded+71 -0
| @@ -0,0 +1,71 @@ | |||
| 1 | +# lane-midcut r2 handoff (coordinator turn cap) | ||
| 2 | + | ||
| 3 | +Tip: lane-midcut, merged main (243f125) cleanly at STEP 0 (decode.rs/stream.rs auto-merged, `cargo check -p ec-av1` clean). | ||
| 4 | + | ||
| 5 | +## r1's named defect was STALE on both counts | ||
| 6 | +1. `find_mv_stack` call sites decode.rs:20959 and :23046 ALREADY pass | ||
| 7 | + `bw4 = write_w/4`, `bh4 = write_h/4` (lane-rect r2 did that). No `side, side` | ||
| 8 | + remains at any single-ref/compound mv-stack site; the sub-8 leaf sites pass | ||
| 9 | + the literal `1,1` / `2,2` libaom uses. Nothing to fix there. | ||
| 10 | +2. The mv stack at mi(112,288) is IDENTICAL to aomdec's, entry for entry: | ||
| 11 | + i0 (-24,-352) w=700 | i1 (-32,-350) w=664 | i2 (-40,-340) w=644 | i3 (-20,-360) w=4 | ||
| 12 | + (both decoders, both stack=4). Only the DRL index differed, because the | ||
| 13 | + entropy state at that block already differed (aomdec EC_MODE rng=56215 vs | ||
| 14 | + ours 41892) -- r1's "entropy in sync" premise was wrong. It was a downstream | ||
| 15 | + symptom, never a defect. | ||
| 16 | + | ||
| 17 | +## Root cause found and FIXED (commit cde8893) | ||
| 18 | +Reproducing this cut now needs `EC_INTRA16X4_DECODE=1` (main re-added the | ||
| 19 | +16x4-in-inter refusal); without it the probe refuses and every trace truncates. | ||
| 20 | + | ||
| 21 | +First real divergence in frame 1 (2-frame cut, decode order): the 32x8 INTRA | ||
| 22 | +strip at mi(118,280), inside an inter frame, reading its `tx_depth` symbol. | ||
| 23 | + aomdec: `EC_ISTEP mi_row=118 mi_col=280 name=tx_depth val=0 ctx=2 cat=2 rng=63652` | ||
| 24 | + ours : `EC_TXCTX mi_row=118 mi_col=280 w=32 h=8 above_px=16 left_px=16 ctx=1` | ||
| 25 | +Both entered at rng 42394 (the `use_filter_intra` rung matches exactly), so the | ||
| 26 | +ROW of `tx_size_cat2` is the whole defect (class wrong-alphabet-same-value: the | ||
| 27 | +value is 0 in both, only the range moves). | ||
| 28 | + | ||
| 29 | +`tx_size_context_rect` is the KEY FRAME approximation of libaom | ||
| 30 | +`get_tx_size_context` (`pred_common.h:342`): it reads the deblock tx grid and | ||
| 31 | +never applies "an INTER neighbour contributes its BLOCK size, not its transform | ||
| 32 | +size". The above neighbour here is the inter 32x8 at mi(116,280) whose var-tx | ||
| 33 | +tree had split to 16-wide TUs, so libaom sees 32 >= 32 (above=1) while we saw | ||
| 34 | +16 >= 32 (above=0). The 1:4 16x4 strip already branched to | ||
| 35 | +`tx_size_context_txfm_rect` at its own call site (decode.rs:9116); the other six | ||
| 36 | +rect intra readers did not. Fix = one branch inside `tx_size_context_rect` | ||
| 37 | +itself (decode.rs:6737) keyed on `INTRA_IN_INTER_MODE`, so every call site | ||
| 38 | +inherits it. | ||
| 39 | + | ||
| 40 | +### Measured effect (EVIDENCE lines) | ||
| 41 | +EVIDENCE: ~/.cache/midcut-tmp/{m_am.txt,m_o2.txt} | greedy in-order match of every | ||
| 42 | +`EC_MODE mi_row= mi_col= rng=` line, aomdec vs ours, 2-frame cut | first mismatch | ||
| 43 | +moved from aom idx 1998 (mi 120,272) to ALL MATCH 6871/6871 inter blocks. | ||
| 44 | +EVIDENCE: ~/.cache/midcut-tmp/d/{our,aom}.f{0,1} (EC_AV1_PREFILT_DUMP16, both | ||
| 45 | +decoders, regenerated this round) | numpy plane compare | f0 EXACT; f1 luma | ||
| 46 | +4386319 -> 115 wrong samples, U 342, V 860, every delta |1|, luma bbox rows | ||
| 47 | +552..1552 cols 488..969. | ||
| 48 | + | ||
| 49 | +## Also added (compiles, NOT yet gated -- next agent's first job) | ||
| 50 | +`decode::intra_rect_in_inter_txctx_override_hits()` (decode.rs, next to | ||
| 51 | +`intra_rect_in_inter_split_tx_hits`): counts ONLY the rect-intra-in-inter blocks | ||
| 52 | +whose ctx actually MOVED under the override, i.e. the blocks the bug mis-read -- | ||
| 53 | +a plain "rect intra in inter" tally is green on the buggy code too | ||
| 54 | +(class gate-blind-to-feature). | ||
| 55 | + | ||
| 56 | +## Exact next steps | ||
| 57 | +1. Print the new counter in `crates/ec-av1/examples/decode_probe.rs` (model: | ||
| 58 | + the `interintra_rect:` line at :46) and hard-assert a positive delta in | ||
| 59 | + `intra_rect_in_inter_split_tx_gate` / `intra_rect_in_inter_gate` | ||
| 60 | + (stream.rs:5639 / :29785, both bit depths). If neither arm fires the counter, | ||
| 61 | + add an aomenc arm with rect partitions + tx-size search on (the override only | ||
| 62 | + moves the row once a neighbour's var-tx tree splits). | ||
| 63 | +2. Chase the 115/342/860 |1| residue in frame 1 (entropy is now provably exact, | ||
| 64 | + so it is pure reconstruction: MC rounding or an intra edge, luma bbox above). | ||
| 65 | +3. Re-run the 24-offset decode-order table (`~/.cache/midcut-tmp/cen/`, r1's | ||
| 66 | + scripts; the r1 table `cen/after.tsv` is now stale) and report how many | ||
| 67 | + offsets have frame 1 exact. | ||
| 68 | +4. Then the named gates (mv_stack, interintra, rect, hidden_arf, | ||
| 69 | + refusal_inventory, gate_coverage) and the suite unit. None was run this round. | ||
| 70 | +5. No fixture pinned: frame 1 is not exact yet (residue above). | ||
| 71 | +6. No refusal lifted or moved; refusal_inventory/gate_coverage untouched. | ||
lanes/midcut-r3.handoff.mdadded+115 -0
| @@ -0,0 +1,115 @@ | |||
| 1 | +# lane-midcut r3 handoff -- dedup done, the rect chroma WARP guard was the residue's bulk | ||
| 2 | + | ||
| 3 | +Branch `lane-midcut`, worktree `edith_codecs-midcut`, | ||
| 4 | +`CARGO_TARGET_DIR=$HOME/.cache/cargo-target-midcut`. Tip: `d93a149b`. | ||
| 5 | +Reproduction of every cut here needs `EC_INTRA16X4_DECODE=1`. | ||
| 6 | + | ||
| 7 | +## STEP 0 -- merge + DEDUP VERDICT: my override was redundant, dropped | ||
| 8 | + | ||
| 9 | +`git merge 75b3a1d` (lane-t900 r3 tip, already containing main `243f125`): | ||
| 10 | +clean auto-merge (decode.rs / stream.rs / decode_probe.rs). | ||
| 11 | + | ||
| 12 | +lane-t900 r2 switched EVERY rect intra reader's own call site to | ||
| 13 | +`tx_size_context_txfm_rect` under `INTRA_IN_INTER_MODE`, so after the merge my | ||
| 14 | +`cde8893` branch INSIDE `tx_size_context_rect` was unreachable: all seven | ||
| 15 | +remaining `tx_size_context_rect` calls sit in the `else` arm of exactly that | ||
| 16 | +condition (grep `tx_size_context_txfm_rect|tx_size_context_rect` in decode.rs). | ||
| 17 | +Removed it (`d41cbc51`); kept the counter by moving | ||
| 18 | +`intra_rect_in_inter_txctx_override_hits` INTO `tx_size_context_txfm_rect`, | ||
| 19 | +where it still counts only blocks whose CDF row the deblock-grid approximation | ||
| 20 | +would have read differently. Kept the r1 interintra rect blend (`43e9909`). | ||
| 21 | + | ||
| 22 | +Verification with t900's fix alone (no override anywhere): the 2-frame cut | ||
| 23 | +`~/.cache/midcut-tmp/h2400.t2.obu`, decode-order PREFILT16 compare vs | ||
| 24 | +instrumented aomdec -- frame 0 EXACT, frame 1 wrong-sample count 1317 | ||
| 25 | +(Y 115, U 342, V 860), i.e. bit-identical to what my own override produced. | ||
| 26 | +No site needs both. | ||
| 27 | + | ||
| 28 | +## STEP 1 -- ROOT CAUSE of the chroma residue (fixed, `8043ad54`) | ||
| 29 | + | ||
| 30 | +`decode_inter_block` allocates a SQUARE prediction buffer and gated the warp | ||
| 31 | +per plane on `chroma_side >= 8` -- the BUFFER's side. libaom | ||
| 32 | +`av1_init_warp_params` bails per PLANE at `block_width < 8 || block_height < 8` | ||
| 33 | +on the BLOCK's dims, so the 8x4 / 4x8 chroma of a 16x8 / 8x16 luma block keeps | ||
| 34 | +the translational prediction. Every rect block with a local or global warp | ||
| 35 | +warped its chroma where libaom does not. Guards are now `warp_chroma_ok = | ||
| 36 | +write_chroma_w >= 8 && write_chroma_h >= 8` (5 sites: 4 compound + 1 | ||
| 37 | +single-ref) and `warp_luma_ok = write_w >= 8 && write_h >= 8` (3 luma sites). | ||
| 38 | +Class: rectchroma2 / narrow-block-sharp-kernel (dims read off the enclosing | ||
| 39 | +square buffer). The 8x8-leaf reader (`CHROMA_SIDE >= 8`, const-generic) was | ||
| 40 | +already correct and is untouched. | ||
| 41 | + | ||
| 42 | +Frame 1 of the 2-frame cut: **1317 -> 126 wrong samples (Y 115, U 11, V 0)**. | ||
| 43 | + | ||
| 44 | +## RESIDUE STATE (126 samples, exact coordinates -- do not re-bisect) | ||
| 45 | + | ||
| 46 | +Three luma clusters + one chroma cluster, all in decode-order frame 1 of | ||
| 47 | +`~/.cache/midcut-tmp/h2400.t2.obu` (dumps kept at `~/.cache/midcut-tmp/d2/`): | ||
| 48 | + | ||
| 49 | +| cluster | px | n | shape | | ||
| 50 | +|---|---|---|---| | ||
| 51 | +| SB(8,15) | y 552..559, x 960..969 | 18 | dithered +-1 | | ||
| 52 | +| SB(9,7) | y 576..607, x 484..500 | 79 | a DIAGONAL +-1/+-2 band | | ||
| 53 | +| SB(24,10) | y 1549..1552, x 647..658 | 18 | +1/+2 wedge | | ||
| 54 | +| U | rows 800..803, cols 1216..1219 | 11 | -1..-2 | | ||
| 55 | + | ||
| 56 | +Every one of those blocks is an INTRA block inside the INTER frame, and every | ||
| 57 | +one is RECT (`EC_TRACE_MODE_STEP` at those mi): | ||
| 58 | +* SB(8,15) -> mi(136,240) `fn=rect bw=16 bh=32`, `mode=9` (SMOOTH), tx_depth 0. | ||
| 59 | +* SB(9,7) -> mi(144,120) `fn=rect bw=8 bh=16` mode=4 angle_y=+2 (directional), | ||
| 60 | + mi(144,122) `bw=8 bh=16` filter-intra, mi(144,124) `fn=sq side=16` mode=6 | ||
| 61 | + angle_y=-2. | ||
| 62 | +The diagonal band under a directional mode plus a dithered edge under SMOOTH is | ||
| 63 | +the signature of ONE wrong edge sample, not a wrong predictor: suspect the | ||
| 64 | +edge availability / reach for a RECT intra block inside an inter frame | ||
| 65 | +(`n_top`/`n_left`, has-top-right, or the intra edge filter strength/upsample | ||
| 66 | +computed from the square side rather than `bw x bh` -- `intra.rs:483 | ||
| 67 | +directional`, `intra_edge_filter_strength`, `use_intra_edge_upsample`). | ||
| 68 | +Classes to check first: reach-is-per-transform-unit, visit-order-changes- | ||
| 69 | +availability, context-read-from-one-cell. | ||
| 70 | + | ||
| 71 | +## STEP 2 -- gate/counter wiring state | ||
| 72 | + | ||
| 73 | +* `intra_rect_in_inter_txctx_override_hits` compiles and counts in | ||
| 74 | + `tx_size_context_txfm_rect`; it is **not yet printed by decode_probe and not | ||
| 75 | + yet asserted by any gate** (turn cap). Next: print it next to | ||
| 76 | + `interintra_rect:` in `crates/ec-av1/examples/decode_probe.rs:46` and assert a | ||
| 77 | + positive delta in `intra_rect_in_inter_split_tx_gate` / `intra_rect_in_inter_gate`. | ||
| 78 | +* `a_real_aomenc_stream_with_interintra_decodes_pixel_exact` was RED on this | ||
| 79 | + branch: its recipe spells `--enable-rect-partitions=0 --min-partition-size=32`, | ||
| 80 | + so r1's `interintra_rect_hits` delta assert was UNSATISFIABLE (40 pixel-exact | ||
| 81 | + matches, counter 0). Fixed with a RECT ARM (`d93a149b`) that re-encodes the | ||
| 82 | + same source with `--enable-rect-partitions=1 --min-partition-size=8 | ||
| 83 | + --max-partition-size=64` APPENDED (last flag wins) and compares every | ||
| 84 | + decode-order frame vs aomdec; seed 46's arm fires 4 rect interintra blocks. | ||
| 85 | + Gate green (1 passed, 11.7 s). | ||
| 86 | +* NO fixture pinned: frame 1 is still 126 samples off, so | ||
| 87 | + `crates/ec-av1/fixtures/reelb_midcut_arf_witness.obu` and its decode-order gate | ||
| 88 | + must wait for exactness. No refusal lifted; `refusal_inventory.rs` / | ||
| 89 | + `gate_coverage.rs` untouched. | ||
| 90 | + | ||
| 91 | +## Gates run this round (per-name, systemd units) | ||
| 92 | + | ||
| 93 | +`$HOME/.cache/midcut-gates-r3.log` (at `d41cbc51`): `hidden_arf` 1 passed; | ||
| 94 | +`rect64_corner_tus` 1 passed; `interintra` FAILED (the vacuous assert above, | ||
| 95 | +now fixed); `1to4` / `refusal_inventory` / `gate_coverage` were still running at | ||
| 96 | +the cap -- RE-RUN THEM at the tip. Full suite NOT run (coordinator: no suite). | ||
| 97 | + | ||
| 98 | +## 24-offset decode-order table (`~/.cache/midcut-tmp/cen/after_r3.tsv`) | ||
| 99 | + | ||
| 100 | +Written by `~/.cache/midcut-tmp/cen/run_r3.sh` (adds `EC_INTRA16X4_DECODE=1`, | ||
| 101 | +which the r2 script lacked). FINISHED: 24 offsets, frame 0 EXACT at all 24, | ||
| 102 | +frame 1 EXACT at **2** (0 s and 5100 s -- 5100 s went 2300495 -> 0), 12 of 24 | ||
| 103 | +offsets improved on frame 1, the rest unchanged (their frame-1 defect is not | ||
| 104 | +warp-shaped). Best movers: 1800 s 11612125 -> 1151, 2400 s 11010633 -> 126, | ||
| 105 | +3300 s 10663109 -> 27, 3900 s 4665360 -> 522 (its frame 3 is now 0). One offset | ||
| 106 | +(1500 s) still REFUSES on the Golomb tail. Nine offsets still carry a | ||
| 107 | +multi-million-sample frame among f1..f3 (300/900/2100/6000/6300/6600 ...), i.e. | ||
| 108 | +at least one more entropy-level defect remains off this cut. | ||
| 109 | + | ||
| 110 | +## Artifacts | ||
| 111 | + | ||
| 112 | +`~/.cache/midcut-tmp/`: `h2400.t2.obu` (2-frame cut, 4K 10-bit), | ||
| 113 | +`d2/{aom,our}.f{0,1}` (PREFILT16 dumps both decoders, at the tip), | ||
| 114 | +`m5.txt`/`m6.txt` (our `EC_TRACE_MODE`+`EC_TRACE_MODE_STEP` at the residue mi), | ||
| 115 | +`cen/run_r3.sh`, `cen/after_r3.tsv`. | ||
lanes/t900-r10.report.mdadded+117 -0
| @@ -0,0 +1,117 @@ | |||
| 1 | +# lane-t900 r10 -- the r9 top-right hunk was half a port; with libaom's rect shape refinements the 1080p cut's mode stream is exact for all 264 frames | ||
| 2 | + | ||
| 3 | +Tip on `lane-t900` (see git log). Suite: see below. | ||
| 4 | + | ||
| 5 | +## STEP 0 -- verdict on the unverified r9 hunk `5c8ab7f2`: KEPT, but only after completing it | ||
| 6 | + | ||
| 7 | +Named gates at `6d2ba001` (before any r10 edit), unit `t900-named-r10b`: | ||
| 8 | +`128sb_film interintra hidden_arf rect64_corner_tus sub8 obmc mv_stack | ||
| 9 | +refusal_inventory gate_coverage` -> **34 passed, 0 failed, 1 ignored** | ||
| 10 | +(98.6 s, `$HOME/.cache/t900-named-r10.log`). So the r9 hunk reddened nothing. | ||
| 11 | + | ||
| 12 | +libaom, cited: `av1_findSamples` probes the top-right warp sample with | ||
| 13 | +`has_top_right(cm, xd, mi_row, mi_col, AOMMAX(xd->width, xd->height))` | ||
| 14 | +(`mvref_common.c:1235`) -- r9's premise is correct, and it is the ONLY place | ||
| 15 | +that uses the longer side for that probe in a way our port reaches | ||
| 16 | +(`mvstack::has_top_right` has exactly one caller, `decode::find_samples`; the | ||
| 17 | +mv-stack scan's own `bs = AOMMAX(w,h)` at `mvref_common.c:496` is served by the | ||
| 18 | +separate `top_right_scan_allowed`). For a 64x128 block `bs = 32`, and | ||
| 19 | +`has_top_right` returns 0 at once (`if (bs > mi_size_wide[BLOCK_64X64]) return 0`, | ||
| 20 | +`mvref_common.c:270`) -- so YES, libaom uses max(w,h) there and a 128-tall block | ||
| 21 | +gets no top-right warp sample. r9's mi(64,144) analysis stands. | ||
| 22 | + | ||
| 23 | +**Why it moved the divergence earlier**: our `has_top_right` port never carried | ||
| 24 | +libaom's two rect shape refinements (`av1_common_int.h:1419-1428`) | ||
| 25 | + | ||
| 26 | + is_last_vertical_rect = !((mi_col + width) & (height - 1)) [w < h] | ||
| 27 | + is_first_horizontal_rect = !( mi_row & (width - 1)) [w > h] | ||
| 28 | + | ||
| 29 | +which are applied AFTER the mask loop and only bite when `bw4 != bh4` -- i.e. | ||
| 30 | +exactly the blocks whose probe size r9 changed. Probing at the longer side | ||
| 31 | +without them is half a port. Root cause fixed in `b5e1cbde` | ||
| 32 | +(`crates/ec-av1/src/mvstack.rs:705-733`, call site | ||
| 33 | +`crates/ec-av1/src/decode.rs:18995`), NOT reverted. | ||
| 34 | + | ||
| 35 | +## Result on the 10-bit 1920x792 264-frame cut (`~/.cache/t900-tmp/cut_900.obu`) | ||
| 36 | + | ||
| 37 | +| ladder | r9 tip `5c8ab7f2` | r10 tip | | ||
| 38 | +|---|---|---| | ||
| 39 | +| first EC_MODE divergence | frame 49, mi(24,376)->mi(24,380) | **none in 264 frames** | | ||
| 40 | +| mode-ladder opcodes vs aomdec | replace at frame 48 | 915 equal / 914 insert / **0 replace, 0 delete** | | ||
| 41 | +| frames differing vs aomdec | 218 of 267 (frame 49 alone 2.26 MB) | **36 of 267, 1-3 bytes each** | | ||
| 42 | +| first differing frame | 41 | 41 (the known r8 chroma-MC bottom-row clamp, 1 byte) | | ||
| 43 | + | ||
| 44 | +The 914 "insert" runs are lines only WE emit (per-sub-block EC_MODE prints where | ||
| 45 | +libaom prints once per block, and intra blocks in inter frames); every | ||
| 46 | +`(mi_row, mi_col, rng)` triple aomdec emits is matched in order. | ||
| 47 | + | ||
| 48 | +EVIDENCE: `~/.cache/t900-tmp/o900e.mode` + `a900.mode` | `python3 lad2.py a900.mode o900e_i.mode` (difflib over (frame,mi_row,mi_col,rng)) | Counter({'equal': 915, 'insert': 914}), first delete/replace: None | ||
| 49 | +EVIDENCE: `~/.cache/t900-tmp/d_r10_900/` | `bash cmp.sh r10_900 cut_900.obu` (aomdec EC_AV1_FINAL_DUMP vs ours, 267 decode-order frames) | 231/267 bit-exact, 36 differ by 1-3 bytes, worst frame 55 = 3 bytes | ||
| 50 | + | ||
| 51 | +## STEP 2 -- witness gates | ||
| 52 | + | ||
| 53 | +* `crates/ec-av1/fixtures/gm_small_side_witness.obu`, **1158066 bytes**, sha256 | ||
| 54 | + `f1cdbcbb8d6d469c7957d70252ab42b24ab75f48a717600ffa25991458775dca` (truncated | ||
| 55 | + twice independently, identical hashes): first 50 frame-carrying OBUs of a 2 s | ||
| 56 | + 10-bit 1920x792 cut, 34 decode-order frames, 33 shown. It is the SMALLEST such | ||
| 57 | + prefix that fires `gm_nontrans_small_side` (N=49 fires 0, N=50 fires 1) and it | ||
| 58 | + is decode-exact: all 34 decode-order frames byte-identical to aomdec. | ||
| 59 | + New gate `a_10bit_film_frames_with_small_side_globalmv_and_rect_warp_reach_decode_pixel_exact` | ||
| 60 | + (`crates/ec-av1/src/stream.rs`): 33 shown frames vs ffmpeg on every plane, | ||
| 61 | + hard asserts `gm_nontrans_small_side_hits > 0` (1) and | ||
| 62 | + `tr_reach_longer_side_hits > 0` (2295). | ||
| 63 | +* The existing 128-SB witness gate now also hard-asserts | ||
| 64 | + `tr_reach_longer_side` (fires 600 on `reelc_sb128_inter_witness.obu`); | ||
| 65 | + `gm_nontrans_small_side` fires 0 there and on every other fixture in the repo, | ||
| 66 | + which is why the new fixture was needed. | ||
| 67 | + | ||
| 68 | +EVIDENCE: `~/.cache/t900-tmp/d_r10_t54w/` | `bash cmp.sh r10_t54w t54w_a.obu` | 34/34 decode-order frames exact, first differing frame: None | ||
| 69 | +EVIDENCE: `$HOME/.cache/t900-gm-r10.log` | `cargo test -p ec-av1 --lib -- small_side_globalmv 128sb_film gate_coverage refusal_inventory` | 14 passed, 0 failed, 51.46 s; gate prints "33 shown frames pixel-exact on every plane; gm_nontrans_small_side=1 tr_reach_longer_side=2295" | ||
| 70 | + | ||
| 71 | +## Film / stream table at the r10 tip (`cmp.sh`, aomdec EC_AV1_FINAL_DUMP vs ours) | ||
| 72 | + | ||
| 73 | +| stream | decode | frames differing | first bad | worst | | ||
| 74 | +|---|---|---|---|---| | ||
| 75 | +| 10-bit 1080p cut @900s (267 f) | OK 264 shown | 36 | 41 | 3 bytes | | ||
| 76 | +| 10-bit 1080p head 0-10s (241 f) | OK 240 shown | 78 | 86 (2 bytes) | f130 1143 bytes | | ||
| 77 | +| 10-bit 1080p cut @5400s (275 f) | OK 273 shown | 134 | 61 (1 byte) | f113 1942 bytes | | ||
| 78 | +| 10-bit 1080p cut @6300s (125 f) | OK 122 shown | 86 | 11 (2 bytes) | ~6 bytes | | ||
| 79 | +| 10-bit 1080p cut @8100s (96 f) | OK 95 shown | 18 | 66 (2 bytes) | ~4 bytes | | ||
| 80 | +| 10-bit 2160p head 0-10s, 148-OBU prefix (100 f) | OK 97 shown | **1** | 88 (221 bytes) | 221 bytes | | ||
| 81 | + | ||
| 82 | +No stream refuses. Every remaining 1-6 byte residue sits on a block/frame BOTTOM | ||
| 83 | +edge (the r8 chroma-MC clamp class). | ||
| 84 | + | ||
| 85 | +## Open residue | ||
| 86 | + | ||
| 87 | +* fix-now(next round): 2160p decode frame 88 of the 0-10 s head -- 221 bytes, | ||
| 88 | + 218 luma + 3 chroma, ALL in picture rows 1593-1607 / chroma rows 799-801 (the | ||
| 89 | + last rows of 1608). It is the only frame in that 100-frame prefix that is not | ||
| 90 | + exact and the only one whose header carries `lr=[Sgrproj, Sgrproj, Sgrproj]` | ||
| 91 | + on the luma plane -- prime suspect is the self-guided restoration's last | ||
| 92 | + stripe at the frame bottom, NOT the chroma-MC clamp. Independent of the r9/r10 | ||
| 93 | + warp work (the N=147 prefix, which fires no gm hit, shows the same 221 bytes). | ||
| 94 | +* deferred(a round of its own): the 1000+ byte walls at 1080p head f130 and | ||
| 95 | + @5400 f113 -- unmeasured this round. | ||
| 96 | +* accepted: the 1-3 byte bottom-edge chroma-MC clamp residue (r8, class | ||
| 97 | + `reach-is-per-transform-unit` neighbours), unchanged this round. | ||
| 98 | +* corner-cut: libaom's third `has_top_right` refinement (the PARTITION_VERT_A | ||
| 99 | + bottom-left square) still not ported -- needs the parent partition type | ||
| 100 | + threaded into `mvstack::has_top_right`; ceiling + upgrade path in its doc | ||
| 101 | + comment. | ||
| 102 | + | ||
| 103 | +## Class fixed on the way: ffmpeg pipe deadlock in every gate helper | ||
| 104 | + | ||
| 105 | +`ffmpeg_decode_sequence_10bit` (and 6 sibling helpers, one shape, in | ||
| 106 | +`stream.rs` x2, `decode.rs` x2, `tile.rs` x1, `encode.rs` x2) wrote the whole | ||
| 107 | +stream to ffmpeg's stdin INLINE and only then read stdout. With a 1.1 MB | ||
| 108 | +fixture that decodes to ~150 MB the stdout pipe fills first and both processes | ||
| 109 | +park at 0% CPU -- the new gate sat there for 45 minutes before I killed it | ||
| 110 | +(`ps` showed `ffmpeg -f obu -i -` at 0.0% and the test binary at 2.5%). | ||
| 111 | +All 7 now write on their own thread. Same run afterwards: **51.5 s**. | ||
| 112 | +EVIDENCE: `$HOME/.cache/t900-gm-r10d.log` | same test command as the 45-min hang | `test result: ok. 14 passed; 0 failed` in 51.46 s | ||
| 113 | + | ||
| 114 | +## Suite | ||
| 115 | + | ||
| 116 | +`cargo test -p ec-av1 --lib` (unit `t900-suite-r10`, log `$HOME/.cache/t900-suite-r10.log`): | ||
| 117 | +**427 passed, 0 failed, 38 ignored**, 718.4 s -- r6 baseline was 426/0/38, the +1 is this round's new gate. | ||
lanes/t900-r8.handoff.mdadded+88 -0
| @@ -0,0 +1,88 @@ | |||
| 1 | +# lane-t900 r8 handoff -- inter blocks never stamped the mode maps (edge-filter type); one U sample and a frame-49 cliff still open | ||
| 2 | + | ||
| 3 | +Branch `lane-t900`, fix commit `1d928d6e` (merged main `76b33796` first, | ||
| 4 | +fast-forward). No suite this round (turn cap); `cargo check -p ec-av1` clean and | ||
| 5 | +the 128-SB witness gate passes with the new counter. | ||
| 6 | + | ||
| 7 | +## Root cause CLOSED this round | ||
| 8 | + | ||
| 9 | +**An INTER block wrote neither luma nor chroma mi mode map**, so a later intra | ||
| 10 | +block's `get_intra_edge_filter_type` (spec 7.11.2, libaom `reconintra.h` | ||
| 11 | +`is_smooth`) found no mi-exact entry for an inter neighbour and fell back to the | ||
| 12 | +coarse SUB band, which still held a SMOOTH mode from an earlier block in that | ||
| 13 | +pixel row/column. libaom answers "not smooth" for an inter neighbour by | ||
| 14 | +construction (`mbmi->mode` is an inter mode; `is_smooth(.., plane>0)` returns 0 | ||
| 15 | +outright -- "uv_mode is not set for inter blocks"). Wrong filter type => | ||
| 16 | +`intra_edge_filter_strength` 3 instead of 2 (and `use_intra_edge_upsample` can | ||
| 17 | +flip with it). | ||
| 18 | + | ||
| 19 | +* Fix: `decode.rs` `record_inter_rect_mi` -- `if is_inter { record_mode_mi(.., | ||
| 20 | + DC_PRED); record_uv_mode_mi(.., DC_PRED); }`. The main inter path already went | ||
| 21 | + through `record_rect_mi`; the gap was every path that only called | ||
| 22 | + `record_inter_rect_mi` (notably the 8x8 leaf at decode.rs:27273). | ||
| 23 | +* Counter: `inter_neighbour_not_smooth_hits()` (decode.rs, next to | ||
| 24 | + `uv_mode_mi_override_hits`), incremented in `modes_above_left` (luma) and | ||
| 25 | + `smooth_uv_neighbour_unsnapped` (chroma) when the coarse band would have said | ||
| 26 | + SMOOTH and the mi-exact map does not. Asserted `> 0` in the witness gate | ||
| 27 | + `a_10bit_128sb_film_frames_with_warp_cdef_and_interintra_decode_pixel_exact` | ||
| 28 | + (stream.rs): **375 hits, 15 shown frames still pixel-exact**. | ||
| 29 | +* Instrument added: the SQUARE-block `OUR_PRED` print now carries `ft=` like the | ||
| 30 | + rect one (decode.rs:11055) -- that single field is what localised this | ||
| 31 | + (aomdec `EC_PRED ... ft=0` vs ours `ft=1`). | ||
| 32 | +* Evidence, `~/.cache/rectres-tmp/t6300.obu` (10-bit 1920x792, 125 decode | ||
| 33 | + frames), `cmp.sh`: frame 11 was 28 Y + 3 U + 4 V samples off; now Y and U are | ||
| 34 | + EXACT, V has 2 samples left. Whole-cut differing bytes **18108 -> 12780**, | ||
| 35 | + differing frames 87 -> 86. | ||
| 36 | + Localisation: prefilter dump identical to the final dump => reconstruction, | ||
| 37 | + not loop filter; block mi(24,348) is a 16x16 D67 intra-in-inter block, | ||
| 38 | + p_angle 61, aomdec ft=0 / ours ft=1. | ||
| 39 | + | ||
| 40 | +## Open, with what is known | ||
| 41 | + | ||
| 42 | +1. **t6300 frame 11 residue**: V only, chroma (673,394) and (674,392), both -1. | ||
| 43 | + Bottom chroma area (chroma height 396). Same shape as (2) -- treat as one | ||
| 44 | + defect. | ||
| 45 | +2. **t900 frame 41** (`~/.cache/t900-tmp/cut_900.obu`): ONE U sample. NOTE the | ||
| 46 | + coordinate moved with the loop filter: **prefilter it is chroma (353,395)**, | ||
| 47 | + post-filter (354,395), delta -1. So it is RECONSTRUCTION, not | ||
| 48 | + deblock/CDEF/LR (pf.sh proved this: `pf_r8_900` frame 41 differs the same | ||
| 49 | + way). The block is mi(192,176), 32x32, `skip=1`, INTER, ref0=5, mv0=(-4,14), | ||
| 50 | + interp SMOOTH/SMOOTH -- so a pure chroma MC value on the LAST chroma row | ||
| 51 | + (395 = 792/2 - 1). Its chroma MC call is | ||
| 52 | + `EC_MC_CALL x_q4=5646 y_q4=6140 w=16 h=16 xfrac=14 yfrac=12 hk=Smooth | ||
| 53 | + vk=Smooth tw=960 th=396 stride=960`; the vertical 8-tap reads rows 391..398 | ||
| 54 | + and rows >395 are clamped by `mc.rs::sample`. Next step: dump the 8 tap rows | ||
| 55 | + and the intermediate for column 353 from both decoders (aomdec has no MC | ||
| 56 | + rung -- either add one to `dec_build_inter_predictors` or recompute by hand | ||
| 57 | + from the aomdec dump of the reference frame) and check the clamp/rounding on | ||
| 58 | + the clamped taps. Only one column differs because the error is a rounding | ||
| 59 | + tip, not a whole-row offset -- do not conclude from "one sample" that the | ||
| 60 | + row is otherwise right. | ||
| 61 | +3. **NEW, not in the r7 handoff -- t900 cut frame 49 cliff**: `cut_900.obu` has | ||
| 62 | + 264 decode frames (not ~50). Frames 42..48 are exact, then frame 49 differs | ||
| 63 | + in 1.78 M bytes and it never recovers (every later frame 2-4 M bytes off). | ||
| 64 | + Checked: it is NOT a frame-order offset (our f49 vs aomdec f48..f52 all | ||
| 65 | + differ by >1.7 M). This is a full desync/gross mis-decode and is now the | ||
| 66 | + biggest single item on this stream -- localise it BEFORE spending more | ||
| 67 | + rounds on the single-sample residues. | ||
| 68 | + | ||
| 69 | +## Film table (decode-order first differing frame vs aomdec, this tip) | ||
| 70 | + | ||
| 71 | +| cut | first bad | size of the defect | | ||
| 72 | +|---|---|---| | ||
| 73 | +| t6300 (`~/.cache/rectres-tmp/t6300.obu`, 125 fr) | 11 | 2 V samples (was 35 bytes); whole cut 12780 bytes / 86 frames | | ||
| 74 | +| t900 (`~/.cache/t900-tmp/cut_900.obu`, 264 fr) | 41 | 1 U sample; then the frame-49 cliff above | | ||
| 75 | +| t5400 (`~/.cache/t900-tmp/cut_5400.obu`) | 33 (r7 value, NOT re-measured this round) | 1642397 bytes | | ||
| 76 | +| t8100 (`~/.cache/t900-tmp/cut_8100.obu`) | 1 (r7 value, NOT re-measured this round) | 1313 bytes | | ||
| 77 | + | ||
| 78 | +Re-run `cmp.sh <name> <cut>` for t5400/t8100 first: the r8 edge-filter fix may | ||
| 79 | +have moved both. | ||
| 80 | + | ||
| 81 | +## Instruments (unchanged from r7 unless noted) | ||
| 82 | + | ||
| 83 | +`~/.cache/t900-tmp/`: `cmp.sh`, `pf.sh`, `px.py`, `sb.py`, `lad.py`, `reg.py`; | ||
| 84 | +private aomdec `~/.cache/t900-tmp/aom-build/aomdec` (EC_TRACE_TXTYPE); oracle | ||
| 85 | +`~/.cache/aom-oracle/build/aomdec` (EC_PRED/EC_PREDND/EC_PREDOUT with | ||
| 86 | +`ft=`/`n_tr=`/`p_angle=`). Ours: `EC_PRED=1` prints OUR_PRED with `ft=` for BOTH | ||
| 87 | +rect and square now. Frame window trick used all round: | ||
| 88 | +`... 2>&1 | awk '/EC_PICT idx=<N-1>$/{f=1} /EC_PICT idx=<N>$/{exit} f'`. | ||
lanes/t900-r9.handoff.mdadded+109 -0
| @@ -0,0 +1,109 @@ | |||
| 1 | +# lane-t900 r9 handoff -- two root causes landed (sub-8x8 GLOBALMV interp, warp TR reach); the 4K head is element-exact, frame 49 of the 1080p cut still desyncs | ||
| 2 | + | ||
| 3 | +Tip `5c8ab7f2` on `lane-t900`. `cargo check -p ec-av1 --tests --examples` clean. | ||
| 4 | +No suite this round (coordinator: no suite). | ||
| 5 | + | ||
| 6 | +## STEP 0 -- consolidation (DONE, commits `cdf54852`, `a0b69fe6`) | ||
| 7 | + | ||
| 8 | +* `git merge main` = no-op (branch already carried main `76b33796`). | ||
| 9 | +* `git merge 434ac12c` (lane-midcut r3 tip): ONE conflict block in decode.rs (8 hunks), | ||
| 10 | + resolved to **our** `warp_plane_allowed(w, h)` call sites; midcut's equivalent | ||
| 11 | + `warp_luma_ok`/`warp_chroma_ok` bindings deleted (same rule, same libaom source | ||
| 12 | + `av1_init_warp_params`). Kept midcut's `intra_rect_in_inter_txctx_override_hits` | ||
| 13 | + counter, its interintra **RECT ARM** gate and its `rect_before` scaffold -- | ||
| 14 | + `interintra_rect_hits()` already exists in this tree (decode.rs:2141), so the arm | ||
| 15 | + compiled unchanged. | ||
| 16 | +* Cherry-picked lane-frame80 `c5b1020e` MINUS its two `tx_size_context*` delegations | ||
| 17 | + (frame80 r2 measured them redundant, dropped in `d79559ab`): kept the | ||
| 18 | + `EC_TRACE_COEFF_FRAME` rung + `decode_key_frame_tile_with_cdfs` clearing | ||
| 19 | + `TX_SELECT_INTER`. NOT `7ab8915b`, NOT the delegations. | ||
| 20 | +* Named tests at `a0b69fe6`: `128sb_film interintra hidden_arf rect64_corner_tus sub8 | ||
| 21 | + refusal_inventory gate_coverage` -> **26 passed, 0 failed** (96.8 s, | ||
| 22 | + `$HOME/.cache/t900-named-r9.log`). | ||
| 23 | + | ||
| 24 | +## STEP 1 -- ROOT CAUSE CLOSED (`c13d51df`): 4-px-sided GLOBALMV blocks must read interp | ||
| 25 | + | ||
| 26 | +libaom `is_nontrans_global_motion` returns 0 at | ||
| 27 | +`AOMMIN(mi_size_wide, mi_size_high) < 2` BEFORE testing any model. Our two sub-8x8 | ||
| 28 | +readers (`decode_inter_sub8_split4` ~23649, `decode_inter_sub8_rect2` ~24575) and the | ||
| 29 | +COMPOUND arm of `decode_inter_block` (~20280) lacked that guard and suppressed the | ||
| 30 | +interp-filter symbol. Sub-8x8 sites are now `gm_nontrans = false` outright (their side | ||
| 31 | +is always 4 px); the compound arm gained `bw4.min(bh4) >= 2`. The single-ref arm | ||
| 32 | +(~21508) already had it; `decode_inter_block8` cannot hit it. | ||
| 33 | +Counter `gm_nontrans_small_side_hits()` (printed by decode_probe) counts only flips. | ||
| 34 | + | ||
| 35 | +**Verified on the 4K head** (`~/.cache/frame80-tmp/t265.obu`, 170 decode frames, | ||
| 36 | +`EC_INTRA16X4_DECODE=1 EC_INTRA128_IN_INTER=1`): coefficient ladder vs `a265.f` | ||
| 37 | +(`lad5.py`, tags all_zero/eob/after_bases + rng) -- frame 99 was `DIFF at 11933`, | ||
| 38 | +now `OK` (69065 elements), and frames **100..169 are all OK, zero DIFF** (70/70). | ||
| 39 | +Counter fires 109 times on that cut. Our decode reports `OK: 176 frames decoded`. | ||
| 40 | +So the frame80 stream has NO known entropy divergence left in its 170 frames; the | ||
| 41 | +remaining work there is the pixel compare of shown frames + a witness fixture. | ||
| 42 | + | ||
| 43 | +## STEP 2 -- frame 49 of `~/.cache/t900-tmp/cut_900.obu` (PARTIAL) | ||
| 44 | + | ||
| 45 | +Header facts (`EC_PROBE_HDR=1`, new rung): decode frame 49 is a **hidden ALTREF** -- | ||
| 46 | +`type=Inter show=false refresh=0x01 base_q=38 primary_ref=0 order_hint=51 | ||
| 47 | +ref_idx=[2,0,3,2,2,1,4] allow_warp=TRUE cdef=3 lr=[Wiener,Wiener,Wiener] tiles=1x1`. | ||
| 48 | +It is the 4th `allow_warp=true` ARF (they run at decode 1,17,33,49,65,...; 1/17/33 | ||
| 49 | +decode exactly), so "ARF + warp" alone is not the trigger. | ||
| 50 | + | ||
| 51 | +First diverging element (EC_MODE ladder `lad.py a900.mode o900.mode`, mode traces of | ||
| 52 | +both decoders): decode frame 49, block **mi(64,144), 64x128, NEWMV ref0=1**. | ||
| 53 | +Both decoders reach rng 47868 after the mv. aomdec then reads `motion_mode` to | ||
| 54 | +**45539** and `interp` to 42041; we read motion_mode to **41629** and interp to 38479. | ||
| 55 | +47868*31014/32768 = 45303 (the BLOCK_64X128 **obmc** row) vs 47868*28898/32768 = 42217 | ||
| 56 | +(the **motion_mode** row) -- aomdec read the 2-symbol alphabet, we read the 3-symbol | ||
| 57 | +one. `EC_MM` showed `elig=1 ab=1 lf=1`, `EC_MM2` showed `row=14 warp_elig=1`, and | ||
| 58 | +`EC_PROJ_MI=64,144` showed the deciding sample was the **top-right** cell (a 64x16 | ||
| 59 | +neighbour, ref=1 single). | ||
| 60 | + | ||
| 61 | +Fix shipped (`5c8ab7f2`): `av1_findSamples` probes with | ||
| 62 | +`AOMMAX(xd->width, xd->height)` (mvref_common.c:1235), we passed `bw4`; now | ||
| 63 | +`bw4.max(bh4)`. Counter `tr_reach_longer_side_hits()` = **1942** on that cut. | ||
| 64 | + | ||
| 65 | +**STATE AFTER THE FIX -- READ THIS BEFORE BUILDING ON IT** | ||
| 66 | +* The fix is SOURCE-PROVEN but NOT gate-verified: the named gates were run BEFORE it | ||
| 67 | + (at `a0b69fe6`) and NOT re-run after. **Re-run them first thing.** If they red, | ||
| 68 | + `git revert 5c8ab7f2` is a clean single-hunk revert (plus its counter). | ||
| 69 | +* Pixel compare `cmp.sh r9_900 cut_900.obu` at the tip: first differing frame still | ||
| 70 | + **41** (the known 1 U sample), frame 49 now **2264240** bytes (was 1.78 M) and the | ||
| 71 | + cliff still never recovers; 218 of 267 dumped frames differ. | ||
| 72 | +* The EC_MODE ladder at the tip moves the first divergence to | ||
| 73 | + **mi(0,384) (aomdec rng 63728, ours 56480, `side=64`), last match mi(24,376) | ||
| 74 | + rng 33292** -- i.e. EARLIER inside frame 49 than mi(64,144) (mi(0,384) is in the | ||
| 75 | + same frame; the alphabet fix changed earlier rect blocks' reads). So frame 49 has | ||
| 76 | + at least one more defect ahead of the one that was fixed, and mi(64,144) is no | ||
| 77 | + longer reachable in the trace (its rng-35860 line is gone). | ||
| 78 | +* NEXT STEP, exactly: rebuild the mode traces at the tip | ||
| 79 | + (`o900d.step` already exists at the tip: `EC_MODE|EC_ISTEP|EC_IF|EC_MM` filtered), | ||
| 80 | + find `EC_MODE mi_row=0 mi_col=384` in frame 49 of `a900.step` vs `o900d.step`, and | ||
| 81 | + read the `EC_MM`/`EC_MM2` pair for the LAST MATCHING block mi(24,376) -- the | ||
| 82 | + divergence is again in the symbols between the mv and the interp filter. | ||
| 83 | + | ||
| 84 | +## Instruments added this round (all env-gated, additive) | ||
| 85 | + | ||
| 86 | +* `EC_PROBE_HDR=1` -> one `EC_HDR` line per decode-order frame (stream.rs, next to | ||
| 87 | + `set_coeff_trace_frame`). | ||
| 88 | +* `EC_TRACE_MODE_STEP` now also prints `EC_MM` (motion_mode eligibility terms: | ||
| 89 | + `elig/ab/lf/sw/skipmode/ii/gmb` + rng) and `EC_MM2` (`row=` cdf row, | ||
| 90 | + `warp_elig/scaled/fimv/obmc/warped` + rng after the read) -- a SUPPRESSED symbol | ||
| 91 | + prints nothing, which is why this defect was invisible for a round. | ||
| 92 | +* `EC_PROJ_MI=<mi_row>,<mi_col>` -> `EC_PROJ cand ...` per warp-sample candidate in | ||
| 93 | + libaom's order (above, left, top-left, top-right). | ||
| 94 | +* decode_probe prints `gm_nontrans_small_side` and `tr_reach_longer_side`. | ||
| 95 | + | ||
| 96 | +## Artifacts | ||
| 97 | + | ||
| 98 | +`~/.cache/t900-tmp/`: `a900.mode` `o900.mode` (pre-TR-fix) `o900d.mode`/`o900d.step` | ||
| 99 | +(tip), `a900.step` (aomdec EC_MODE+EC_ISTEP), `hdr900.txt` (EC_HDR per frame), | ||
| 100 | +`proj2.txt` (candidates at mi(64,144)), `d_r9_900/` (pixel dumps at the tip), | ||
| 101 | +`oall265.f` (our 4K coefficient trace, all frames), `lad265.out` (frames 100..169 OK). | ||
| 102 | +`cmp.sh` now points at `$HOME/.cache/cargo-target-t900` (was `-t900-b`). | ||
| 103 | + | ||
| 104 | +## NOT done this round (turn cap) | ||
| 105 | + | ||
| 106 | +STEP 3 (midcut 126-sample rect-intra edge residue), STEP 4 (f41 chroma MC bottom-row | ||
| 107 | +clamp, t6300 f11 2 V samples), STEP 5 (witness gate asserts for the two new counters, | ||
| 108 | +4K prefix fixture, suite, reelc/hg re-probe), and the film table refresh for | ||
| 109 | +t5400/t8100. Nothing about them was measured this round. | ||