ec-av1: lane-av1lrflush -- honest pipeline row-0 witness (r4 review)
Browse files at this commit4c110250eba2f8988fa4e13d137c04b86156f7f1Parent: 32748253 changed files +52 -14
- crates/ec-av1/src/decode.rs +23 -0
- crates/ec-av1/src/stream.rs +18 -8
- lanes/av1lrflush.report.md +11 -6
crates/ec-av1/src/decode.rsmodified+23 -0
| @@ -25130,6 +25130,16 @@ fn pipe_run_lr( | |||
| 25130 | if lp.next == r_lo { | 25130 | if lp.next == r_lo { |
| 25131 | continue; | 25131 | continue; |
| 25132 | } | 25132 | } |
| 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 | + } | ||
| 25133 | let (src, deb) = match lp.p { | 25143 | let (src, deb) = match lp.p { |
| 25134 | 0 => (&y.data, &sy2.data), | 25144 | 0 => (&y.data, &sy2.data), |
| 25135 | 1 => (&u.data, &su2.data), | 25145 | 1 => (&u.data, &su2.data), |
| @@ -25268,6 +25278,19 @@ pub(crate) fn pipeline_taken_frames() -> u64 { | |||
| 25268 | PIPELINE_TAKEN.load(std::sync::atomic::Ordering::Relaxed) | 25278 | PIPELINE_TAKEN.load(std::sync::atomic::Ordering::Relaxed) |
| 25269 | } | 25279 | } |
| 25270 | 25280 | ||
| 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 | + | ||
| 25271 | /// Whether this frame's filters may run per superblock row. Everything that | 25294 | /// Whether this frame's filters may run per superblock row. Everything that |
| 25272 | /// reads the picture out of band order, or the pipeline's own inputs out of | 25295 | /// reads the picture out of band order, or the pipeline's own inputs out of |
| 25273 | /// row order, keeps the whole-frame path: superres (a between-CDEF-and-LR | 25296 | /// 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 { | |||
| 5905 | /// Non-vacuity, twice over: the `PIPELINE_TAKEN` delta proves the second | 5905 | /// Non-vacuity, twice over: the `PIPELINE_TAKEN` delta proves the second |
| 5906 | /// decode really constructed the pipeline on both inter frames (frame 0 | 5906 | /// decode really constructed the pipeline on both inter frames (frame 0 |
| 5907 | /// is a key frame and the key-frame path runs whole-frame filters by | 5907 | /// 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 | 5908 | + /// construction), and the `LR_PIPELINE_ROW0` delta proves the pipeline's |
| 5909 | - /// ran on stripe 0 -- RU row 0's own first stripe, the span the named | 5909 | + /// band release itself flushed RU row 0 -- a process-global counter |
| 5910 | - /// defect left un-restored. Frames 0/1 are additionally asserted | 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 | ||
| 5911 | /// byte-exact against BOTH the oracle aomdec and ffmpeg THROUGH the | 5913 | /// byte-exact against BOTH the oracle aomdec and ffmpeg THROUGH the |
| 5912 | /// pipeline. (Frame 2's own residual is the entropy lane's inter | 5914 | /// pipeline. (Frame 2's own residual is the entropy lane's inter |
| 5913 | /// rect-strip recon defect -- see lanes/av1lrflush.report.md r3 -- and | 5915 | /// rect-strip recon defect -- see lanes/av1lrflush.report.md r3 -- and |
| @@ -5942,7 +5944,7 @@ pub(crate) mod tests { | |||
| 5942 | assert_eq!(serial.len(), FRAMES, "{NAME}: frame count"); | 5944 | assert_eq!(serial.len(), FRAMES, "{NAME}: frame count"); |
| 5943 | 5945 | ||
| 5944 | let pipe_before = crate::decode::pipeline_taken_frames(); | 5946 | 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(); |
| 5946 | let piped = { | 5948 | let piped = { |
| 5947 | let _bands = crate::par::override_filter_threads(4); | 5949 | let _bands = crate::par::override_filter_threads(4); |
| 5948 | decode_stream(&stream) | 5950 | decode_stream(&stream) |
| @@ -5956,10 +5958,18 @@ pub(crate) mod tests { | |||
| 5956 | arm decoded serial and proves nothing (class \ | 5958 | arm decoded serial and proves nothing (class \ |
| 5957 | gate-blind-to-feature)" | 5959 | gate-blind-to-feature)" |
| 5958 | ); | 5960 | ); |
| 5959 | - assert!( | 5961 | + // f1 restores all three planes, f2 all but U -> 3 + 2 row-0 flushes. |
| 5960 | - crate::restoration::lr_stripe0_hits() - stripe0_before > 0, | 5962 | + // `LR_PIPELINE_ROW0` is process-global and bumped by the pipeline's |
| 5961 | - "{NAME}: no stripe-0 (RU row 0's first stripe) filter ran -- RU row \ | 5963 | + // own worker, so this delta cannot be satisfied by frame 0's |
| 5962 | - 0 was never restored in this arm (class gate-blind-to-feature)" | 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 | ||
| 5963 | ); | 5973 | ); |
| 5964 | 5974 | ||
| 5965 | // The refutation itself: pipeline == serial, byte for byte, on every | 5975 | // The refutation itself: pipeline == serial, byte for byte, on every |
lanes/av1lrflush.report.mdmodified+11 -6
| @@ -49,12 +49,17 @@ | |||
| 49 | pinned fixture, asserting (a) `PIPELINE_TAKEN` delta == 2 (the arm really | 49 | pinned fixture, asserting (a) `PIPELINE_TAKEN` delta == 2 (the arm really |
| 50 | pipelined both inter frames; robust against the once-per-process | 50 | pipelined both inter frames; robust against the once-per-process |
| 51 | `filter_threads()` env cache that would otherwise silently serialise the arm), | 51 | `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 | 52 | + (b) `LR_PIPELINE_ROW0` delta == 5 (f1 restores all three planes, f2 all but U: |
| 53 | - through the pipeline), (c) pipelined == serial byte-exact on every frame, and | 53 | + the pipeline's band release flushed RU row 0 that many times), (c) pipelined == |
| 54 | - (d) frames 0/1 byte-exact vs oracle aomdec AND ffmpeg THROUGH the pipeline. | 54 | + serial byte-exact on every frame, and (d) frames 0/1 byte-exact vs oracle |
| 55 | - Mutation-verified: hard-disabling the RU-row-0 release in `pipe_run_lr`'s band | 55 | + aomdec AND ffmpeg THROUGH the pipeline. r4 review hole, fixed: the original (b) |
| 56 | - walk turns the gate red at assert (c) ("pipelined frame 1 plane 0 differs", | 56 | + used the thread-local `LR_STRIPE0_HITS`, which the gate's own thread can |
| 57 | - class lr-band-release); reverted, green. | 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. | ||
| 58 | 6. Gate-extension status for the original acceptance item: extending | 63 | 6. Gate-extension status for the original acceptance item: extending |
| 59 | `a_444_sb128_root_rect_stream_with_restoration_decodes_pixel_exact` to assert f2 | 64 | `a_444_sb128_root_rect_stream_with_restoration_decodes_pixel_exact` to assert f2 |
| 60 | byte-exact vs aomdec/ffmpeg is **deferred** — f2 is not green and its fix belongs | 65 | byte-exact vs aomdec/ffmpeg is **deferred** — f2 is not green and its fix belongs |