diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 3eff8bff..3c7e1b2a 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -25130,6 +25130,16 @@ fn pipe_run_lr( if lp.next == r_lo { continue; } + if r_lo == 0 { + // lane-av1lrflush: RU row 0 just entered this plane's + // processed range -- the band release flushed the frame's + // first restoration row through the pipeline. Process-global + // (not a `thread_local!` gate counter): the witnessing gate + // decodes on its own thread while this bump fires on a + // filter-pool worker, and frame 0's whole-frame LR runs on + // the gate's thread and must not satisfy the delta. + LR_PIPELINE_ROW0.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + } let (src, deb) = match lp.p { 0 => (&y.data, &sy2.data), 1 => (&u.data, &su2.data), @@ -25268,6 +25278,19 @@ pub(crate) fn pipeline_taken_frames() -> u64 { PIPELINE_TAKEN.load(std::sync::atomic::Ordering::Relaxed) } +/// lane-av1lrflush: RU-row-0 flushes the pipeline actually performed, one per +/// LR-active plane whose first restoration unit row enters `pipe_run_lr`'s +/// processed range. Process-global on purpose -- the filter-pool worker bumps +/// it, the gate's thread reads it -- unlike the `thread_local!` gate counters, +/// which a gate's own thread can satisfy from the whole-frame path alone. +static LR_PIPELINE_ROW0: AtomicU64 = AtomicU64::new(0); + +/// Current value of [`LR_PIPELINE_ROW0`], for a gate's before/after delta. +#[allow(dead_code)] // read only from the `#[cfg(test)]` gates +pub(crate) fn lr_pipeline_row0_flushes() -> u64 { + LR_PIPELINE_ROW0.load(std::sync::atomic::Ordering::Relaxed) +} + /// Whether this frame's filters may run per superblock row. Everything that /// reads the picture out of band order, or the pipeline's own inputs out of /// row order, keeps the whole-frame path: superres (a between-CDEF-and-LR diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index afffb7c0..7dbe1503 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -5905,9 +5905,11 @@ pub(crate) mod tests { /// Non-vacuity, twice over: the `PIPELINE_TAKEN` delta proves the second /// decode really constructed the pipeline on both inter frames (frame 0 /// is a key frame and the key-frame path runs whole-frame filters by - /// construction), and the `LR_STRIPE0_HITS` delta proves a real filter - /// ran on stripe 0 -- RU row 0's own first stripe, the span the named - /// defect left un-restored. Frames 0/1 are additionally asserted + /// construction), and the `LR_PIPELINE_ROW0` delta proves the pipeline's + /// band release itself flushed RU row 0 -- a process-global counter + /// bumped by `pipe_run_lr`'s worker, so frame 0's whole-frame LR (which + /// runs on the gate's own thread and satisfies the thread-local + /// `LR_STRIPE0_HITS`) cannot fake it. Frames 0/1 are additionally asserted /// byte-exact against BOTH the oracle aomdec and ffmpeg THROUGH the /// pipeline. (Frame 2's own residual is the entropy lane's inter /// rect-strip recon defect -- see lanes/av1lrflush.report.md r3 -- and @@ -5942,7 +5944,7 @@ pub(crate) mod tests { assert_eq!(serial.len(), FRAMES, "{NAME}: frame count"); let pipe_before = crate::decode::pipeline_taken_frames(); - let stripe0_before = crate::restoration::lr_stripe0_hits(); + let row0_before = crate::decode::lr_pipeline_row0_flushes(); let piped = { let _bands = crate::par::override_filter_threads(4); decode_stream(&stream) @@ -5956,10 +5958,18 @@ pub(crate) mod tests { arm decoded serial and proves nothing (class \ gate-blind-to-feature)" ); - assert!( - crate::restoration::lr_stripe0_hits() - stripe0_before > 0, - "{NAME}: no stripe-0 (RU row 0's first stripe) filter ran -- RU row \ - 0 was never restored in this arm (class gate-blind-to-feature)" + // f1 restores all three planes, f2 all but U -> 3 + 2 row-0 flushes. + // `LR_PIPELINE_ROW0` is process-global and bumped by the pipeline's + // own worker, so this delta cannot be satisfied by frame 0's + // whole-frame LR (which runs on this test's thread and never touches + // the counter). + assert_eq!( + crate::decode::lr_pipeline_row0_flushes() - row0_before, + 5, + "{NAME}: the pipeline never flushed RU row 0 ({} planes' worth \ + expected) -- the named defect class is present (class \ + lr-band-release)", + 5 ); // The refutation itself: pipeline == serial, byte for byte, on every diff --git a/lanes/av1lrflush.report.md b/lanes/av1lrflush.report.md index 385f1142..f5e58f0e 100644 --- a/lanes/av1lrflush.report.md +++ b/lanes/av1lrflush.report.md @@ -49,12 +49,17 @@ pinned fixture, asserting (a) `PIPELINE_TAKEN` delta == 2 (the arm really pipelined both inter frames; robust against the once-per-process `filter_threads()` env cache that would otherwise silently serialise the arm), - (b) `LR_STRIPE0_HITS` delta > 0 (a real filter ran on RU row 0's own first stripe - through the pipeline), (c) pipelined == serial byte-exact on every frame, and - (d) frames 0/1 byte-exact vs oracle aomdec AND ffmpeg THROUGH the pipeline. - Mutation-verified: hard-disabling the RU-row-0 release in `pipe_run_lr`'s band - walk turns the gate red at assert (c) ("pipelined frame 1 plane 0 differs", - class lr-band-release); reverted, green. + (b) `LR_PIPELINE_ROW0` delta == 5 (f1 restores all three planes, f2 all but U: + the pipeline's band release flushed RU row 0 that many times), (c) pipelined == + serial byte-exact on every frame, and (d) frames 0/1 byte-exact vs oracle + aomdec AND ffmpeg THROUGH the pipeline. r4 review hole, fixed: the original (b) + used the thread-local `LR_STRIPE0_HITS`, which the gate's own thread can + satisfy from frame 0's whole-frame LR alone — vacuous as a pipeline witness; + the replacement is a process-global counter bumped by `pipe_run_lr`'s + filter-pool worker itself, so only a real pipeline row-0 flush can move it. + Mutation-verified: hard-disabling the RU-row-0 release in `pipe_run_lr`'s + band walk turns the gate red (row-0 delta 0 and "pipelined frame 1 plane 0 + differs", class lr-band-release); reverted, green. 6. Gate-extension status for the original acceptance item: extending `a_444_sb128_root_rect_stream_with_restoration_decodes_pixel_exact` to assert f2 byte-exact vs aomdec/ffmpeg is **deferred** — f2 is not green and its fix belongs