ec-av1: lane-av1444edge -- the inter-frame pre-filter rung did not exist, and its counter restarted
Browse files at this commit689d3e06c0c3de84f2b61bf36812d9dc64f039abParent: e772a721 changed file +49 -21
- crates/ec-av1/src/decode.rs +49 -21
crates/ec-av1/src/decode.rsmodified+49 -21
| @@ -19155,6 +19155,48 @@ fn dump_stage(var: &str, y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { | |||
| 19155 | } | 19155 | } |
| 19156 | } | 19156 | } |
| 19157 | 19157 | ||
| 19158 | +/// `EC_AV1_PREFILT_WIDE_DUMP=<prefix>` -> `<prefix>.f<N>`, the pre-loop-filter | ||
| 19159 | +/// reconstruction cropped to each plane's mi-ALIGNED true extent, byte for | ||
| 19160 | +/// byte the shape aomdec's own rung 7 writes (`y_width`/`y_height`, | ||
| 19161 | +/// `uv_width`/`uv_height`), so the two can be diffed directly. | ||
| 19162 | +/// | ||
| 19163 | +/// lane-av1444edge: this used to be an inline block in the KEY-frame tile path | ||
| 19164 | +/// only, with a FUNCTION-LOCAL `static IDX2` as its counter. Both facts were | ||
| 19165 | +/// measurement traps, and the second one is why the first went unnoticed: | ||
| 19166 | +/// the inter-frame path (`decode_inter_frame_tile_with_cdfs`) had no wide | ||
| 19167 | +/// prefilter dump at all, so every 4:4:4 lossy divergence localized to an | ||
| 19168 | +/// inter frame had no pre-filter rung to compare against and got attributed to | ||
| 19169 | +/// reconstruction when the oracle could not see it. The `static` also restarted | ||
| 19170 | +/// per monomorphisation, so every frame after the first overwrote `.f0` -- a | ||
| 19171 | +/// per-frame bisection silently compared the LAST decoded frame. The counter | ||
| 19172 | +/// is now the shared per-var [`dump_stage_idx`] map, and the call also sits on | ||
| 19173 | +/// the inter path (skipped when the filter pipeline is active, which has | ||
| 19174 | +/// already deblocked by the time the tile tail runs -- same condition | ||
| 19175 | +/// `capture_filter_replay` guards itself with). | ||
| 19176 | +fn dump_prefilter_wide(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { | ||
| 19177 | + let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_WIDE_DUMP") else { | ||
| 19178 | + return; | ||
| 19179 | + }; | ||
| 19180 | + use std::io::Write; | ||
| 19181 | + let idx = dump_stage_idx("EC_AV1_PREFILT_WIDE_DUMP"); | ||
| 19182 | + let crop = |plane: &PlaneBuf<'_>| -> Vec<u8> { | ||
| 19183 | + let mut out = Vec::with_capacity(plane.true_width * plane.true_height); | ||
| 19184 | + for row in 0..plane.true_height { | ||
| 19185 | + out.extend( | ||
| 19186 | + plane.data[row * plane.width..][..plane.true_width] | ||
| 19187 | + .iter() | ||
| 19188 | + .map(|&s| s as u8), | ||
| 19189 | + ); | ||
| 19190 | + } | ||
| 19191 | + out | ||
| 19192 | + }; | ||
| 19193 | + if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) { | ||
| 19194 | + let _ = f.write_all(&crop(y)); | ||
| 19195 | + let _ = f.write_all(&crop(u)); | ||
| 19196 | + let _ = f.write_all(&crop(v)); | ||
| 19197 | + } | ||
| 19198 | +} | ||
| 19199 | + | ||
| 19158 | /// The value [`fresh_plane`] fills with under `EC_AV1_PLANE_SENTINEL`: no | 19200 | /// The value [`fresh_plane`] fills with under `EC_AV1_PLANE_SENTINEL`: no |
| 19159 | /// legal sample can equal it (reconstruction clamps to `(1 << bit_depth) - 1`, | 19201 | /// legal sample can equal it (reconstruction clamps to `(1 << bit_depth) - 1`, |
| 19160 | /// at most 4095), so a decode that hashes identically under the flag proves | 19202 | /// at most 4095), so a decode that hashes identically under the flag proves |
| @@ -34513,27 +34555,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 34513 | } else { | 34555 | } else { |
| 34514 | PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); | 34556 | PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); |
| 34515 | } | 34557 | } |
| 34516 | - if let Ok(path) = crate::envflags::var("EC_AV1_PREFILT_WIDE_DUMP") { | 34558 | + dump_prefilter_wide(&y, &u, &v); |
| 34517 | - use std::io::Write; | ||
| 34518 | - static IDX2: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); | ||
| 34519 | - let idx = IDX2.fetch_add(1, std::sync::atomic::Ordering::SeqCst); | ||
| 34520 | - let crop_wide = |plane: &PlaneBuf<'_>| -> Vec<u8> { | ||
| 34521 | - let mut out = Vec::with_capacity(plane.true_width * plane.true_height); | ||
| 34522 | - for row in 0..plane.true_height { | ||
| 34523 | - out.extend( | ||
| 34524 | - plane.data[row * plane.width..][..plane.true_width] | ||
| 34525 | - .iter() | ||
| 34526 | - .map(|&s| s as u8), | ||
| 34527 | - ); | ||
| 34528 | - } | ||
| 34529 | - out | ||
| 34530 | - }; | ||
| 34531 | - if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) { | ||
| 34532 | - let _ = f.write_all(&crop_wide(&y)); | ||
| 34533 | - let _ = f.write_all(&crop_wide(&u)); | ||
| 34534 | - let _ = f.write_all(&crop_wide(&v)); | ||
| 34535 | - } | ||
| 34536 | - } | ||
| 34537 | // lane-av1fwd: the encoder's filter search re-decodes this same key | 34559 | // lane-av1fwd: the encoder's filter search re-decodes this same key |
| 34538 | // frame tile per candidate -- capture it once (see [`FilterReplay`]), | 34560 | // frame tile per candidate -- capture it once (see [`FilterReplay`]), |
| 34539 | // on the shape whose tail is the two filter calls and nothing else. | 34561 | // on the shape whose tail is the two filter calls and nothing else. |
| @@ -52079,6 +52101,12 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 52079 | } else { | 52101 | } else { |
| 52080 | PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); | 52102 | PREFILT_PICTURE_IDX.fetch_add(1, std::sync::atomic::Ordering::SeqCst); |
| 52081 | } | 52103 | } |
| 52104 | + // lane-av1444edge: the inter-frame path's mi-aligned pre-loop-filter | ||
| 52105 | + // dump, the rung the key-frame path has always had (see | ||
| 52106 | + // `dump_prefilter_wide`). Placed beside the padded `EC_AV1_PREFILT_DUMP` | ||
| 52107 | + // above, i.e. before the filter pipeline is released, so the two agree on | ||
| 52108 | + // the point in the sequence they sample. | ||
| 52109 | + dump_prefilter_wide(&y, &u, &v); | ||
| 52082 | // lane-pipefilt: release the rows still pending and wait the pipeline | 52110 | // lane-pipefilt: release the rows still pending and wait the pipeline |
| 52083 | // out; from here the picture is deblocked and CDEF-filtered exactly as | 52111 | // out; from here the picture is deblocked and CDEF-filtered exactly as |
| 52084 | // the whole-frame path leaves it. | 52112 | // the whole-frame path leaves it. |