forge
Explore
Log in

Don't you dare go Hollow

ec-av1: lane-av1lrflush -- honest pipeline row-0 witness (r4 review)

Browse files at this commit

4c110250eba2f8988fa4e13d137c04b86156f7f1Ahmet Kaan GümüşParent: 3274825
Replace the gate's LR_STRIPE0_HITS delta with a new process-global
LR_PIPELINE_ROW0 counter bumped by pipe_run_lr's own worker when a plane's
RU row 0 enters the processed range: the thread-local stripe counter was
satisfiable by frame 0's whole-frame LR on the gate's thread alone, so it
witnessed nothing about the pipeline. Expected delta is 5 (frame 1 restores
all three planes, frame 2 all but U). Mutation re-verified: disabling the
RU-row-0 band release now goes red at the row-0 assert itself (0 vs 5);
reverted, green. Report updated. cargo check 0 warnings; both a_444_sb128
gates and the EC_AV1_REQUIRE_AOMENC=1 restoration battery (10/10) green.
crates/ec-av1/src/decode.rsmodified+23 -0
@@ -25130,6 +25130,16 @@ fn pipe_run_lr(
2513025130 if lp.next == r_lo {
2513125131 continue;
2513225132 }
25133+ if r_lo == 0 {
25134+ // lane-av1lrflush: RU row 0 just entered this plane's
25135+ // processed range -- the band release flushed the frame's
25136+ // first restoration row through the pipeline. Process-global
25137+ // (not a `thread_local!` gate counter): the witnessing gate
25138+ // decodes on its own thread while this bump fires on a
25139+ // filter-pool worker, and frame 0's whole-frame LR runs on
25140+ // the gate's thread and must not satisfy the delta.
25141+ LR_PIPELINE_ROW0.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
25142+ }
2513325143 let (src, deb) = match lp.p {
2513425144 0 => (&y.data, &sy2.data),
2513525145 1 => (&u.data, &su2.data),
@@ -25268,6 +25278,19 @@ pub(crate) fn pipeline_taken_frames() -> u64 {
2526825278 PIPELINE_TAKEN.load(std::sync::atomic::Ordering::Relaxed)
2526925279 }
2527025280
25281+/// lane-av1lrflush: RU-row-0 flushes the pipeline actually performed, one per
25282+/// LR-active plane whose first restoration unit row enters `pipe_run_lr`'s
25283+/// processed range. Process-global on purpose -- the filter-pool worker bumps
25284+/// it, the gate's thread reads it -- unlike the `thread_local!` gate counters,
25285+/// which a gate's own thread can satisfy from the whole-frame path alone.
25286+static LR_PIPELINE_ROW0: AtomicU64 = AtomicU64::new(0);
25287+
25288+/// Current value of [`LR_PIPELINE_ROW0`], for a gate's before/after delta.
25289+#[allow(dead_code)] // read only from the `#[cfg(test)]` gates
25290+pub(crate) fn lr_pipeline_row0_flushes() -> u64 {
25291+ LR_PIPELINE_ROW0.load(std::sync::atomic::Ordering::Relaxed)
25292+}
25293+
2527125294 /// Whether this frame's filters may run per superblock row. Everything that
2527225295 /// reads the picture out of band order, or the pipeline's own inputs out of
2527325296 /// row order, keeps the whole-frame path: superres (a between-CDEF-and-LR
crates/ec-av1/src/stream.rsmodified+18 -8
@@ -5905,9 +5905,11 @@ pub(crate) mod tests {
59055905 /// Non-vacuity, twice over: the `PIPELINE_TAKEN` delta proves the second
59065906 /// decode really constructed the pipeline on both inter frames (frame 0
59075907 /// is a key frame and the key-frame path runs whole-frame filters by
5908- /// construction), and the `LR_STRIPE0_HITS` delta proves a real filter
5909- /// ran on stripe 0 -- RU row 0's own first stripe, the span the named
5910- /// defect left un-restored. Frames 0/1 are additionally asserted
5908+ /// construction), and the `LR_PIPELINE_ROW0` delta proves the pipeline's
5909+ /// band release itself flushed RU row 0 -- a process-global counter
5910+ /// bumped by `pipe_run_lr`'s worker, so frame 0's whole-frame LR (which
5911+ /// runs on the gate's own thread and satisfies the thread-local
5912+ /// `LR_STRIPE0_HITS`) cannot fake it. Frames 0/1 are additionally asserted
59115913 /// byte-exact against BOTH the oracle aomdec and ffmpeg THROUGH the
59125914 /// pipeline. (Frame 2's own residual is the entropy lane's inter
59135915 /// rect-strip recon defect -- see lanes/av1lrflush.report.md r3 -- and
@@ -5942,7 +5944,7 @@ pub(crate) mod tests {
59425944 assert_eq!(serial.len(), FRAMES, "{NAME}: frame count");
59435945
59445946 let pipe_before = crate::decode::pipeline_taken_frames();
5945- let stripe0_before = crate::restoration::lr_stripe0_hits();
5947+ let row0_before = crate::decode::lr_pipeline_row0_flushes();
59465948 let piped = {
59475949 let _bands = crate::par::override_filter_threads(4);
59485950 decode_stream(&stream)
@@ -5956,10 +5958,18 @@ pub(crate) mod tests {
59565958 arm decoded serial and proves nothing (class \
59575959 gate-blind-to-feature)"
59585960 );
5959- assert!(
5960- crate::restoration::lr_stripe0_hits() - stripe0_before > 0,
5961- "{NAME}: no stripe-0 (RU row 0's first stripe) filter ran -- RU row \
5962- 0 was never restored in this arm (class gate-blind-to-feature)"
5961+ // f1 restores all three planes, f2 all but U -> 3 + 2 row-0 flushes.
5962+ // `LR_PIPELINE_ROW0` is process-global and bumped by the pipeline's
5963+ // own worker, so this delta cannot be satisfied by frame 0's
5964+ // whole-frame LR (which runs on this test's thread and never touches
5965+ // the counter).
5966+ assert_eq!(
5967+ crate::decode::lr_pipeline_row0_flushes() - row0_before,
5968+ 5,
5969+ "{NAME}: the pipeline never flushed RU row 0 ({} planes' worth \
5970+ expected) -- the named defect class is present (class \
5971+ lr-band-release)",
5972+ 5
59635973 );
59645974
59655975 // The refutation itself: pipeline == serial, byte for byte, on every
lanes/av1lrflush.report.mdmodified+11 -6
@@ -49,12 +49,17 @@
4949 pinned fixture, asserting (a) `PIPELINE_TAKEN` delta == 2 (the arm really
5050 pipelined both inter frames; robust against the once-per-process
5151 `filter_threads()` env cache that would otherwise silently serialise the arm),
52- (b) `LR_STRIPE0_HITS` delta > 0 (a real filter ran on RU row 0's own first stripe
53- through the pipeline), (c) pipelined == serial byte-exact on every frame, and
54- (d) frames 0/1 byte-exact vs oracle aomdec AND ffmpeg THROUGH the pipeline.
55- Mutation-verified: hard-disabling the RU-row-0 release in `pipe_run_lr`'s band
56- walk turns the gate red at assert (c) ("pipelined frame 1 plane 0 differs",
57- class lr-band-release); reverted, green.
52+ (b) `LR_PIPELINE_ROW0` delta == 5 (f1 restores all three planes, f2 all but U:
53+ the pipeline's band release flushed RU row 0 that many times), (c) pipelined ==
54+ serial byte-exact on every frame, and (d) frames 0/1 byte-exact vs oracle
55+ aomdec AND ffmpeg THROUGH the pipeline. r4 review hole, fixed: the original (b)
56+ used the thread-local `LR_STRIPE0_HITS`, which the gate's own thread can
57+ satisfy from frame 0's whole-frame LR alone — vacuous as a pipeline witness;
58+ the replacement is a process-global counter bumped by `pipe_run_lr`'s
59+ filter-pool worker itself, so only a real pipeline row-0 flush can move it.
60+ Mutation-verified: hard-disabling the RU-row-0 release in `pipe_run_lr`'s
61+ band walk turns the gate red (row-0 delta 0 and "pipelined frame 1 plane 0
62+ differs", class lr-band-release); reverted, green.
5863 6. Gate-extension status for the original acceptance item: extending
5964 `a_444_sb128_root_rect_stream_with_restoration_decodes_pixel_exact` to assert f2
6065 byte-exact vs aomdec/ffmpeg is **deferred** — f2 is not green and its fix belongs