forge
Explore
Log in

Don't you dare go Hollow

R17 bisect -- falsify loop-filter hypothesis for the masked compound blend

Browse files at this commit

80caed57ac349992e54c1d30d9a009e0510c5365Ahmet Kaan GümüşParent: 232e604
  • fix
    • r17 bisect -- falsify loop-filter hypothesis for the masked compound blend
Show full message
fix(av1): r17 bisect -- falsify loop-filter hypothesis for the masked compound blend

r16 called the plain-average COMPOUND_REFERENCE blend defect
"loop-filter-shaped". r17 adds an env-gated pre/post-deblock frame dump
(decode.rs's r17_dump, EC_AV1_PREFILT_DUMP/EC_AV1_POSTFILT_DUMP, matching
aomdec's own hooks of the same name) and a one-shot pinned-stream decode
test (stream.rs's scratch_decode_pinned_stream_once, needed so this
decoder's own frame-index counter lines up with aomdec's numbering).

Result: the 32x32-quadrant mismatch (898/1024 px, rows 32-63 cols 32-63 of
a 64x64 luma plane) is already present *before* this decoder's own loop
filter runs, at parity with aomdec's own pre-deblock buffer for the same
frame -- this falsifies "loop-filter-shaped, not a desync" from r16. It is
a predict_compound_intermediate/combine_compound reconstruction defect.
Root cause still not isolated within that arithmetic (out of this round's
budget); both refusal sites stay masked, with the comment corrected to
this finding and the exact fixture location so the next round can bisect
predict_compound_intermediate itself instead of the loop filter.

Task B (cdf_forwarding-gate flake) not reached this round -- no budget
left after the bisect; the flake did not fire in 3x full-suite runs here
either (214 passed/0 failed/17 ignored each), consistent with its known
low reproduction rate.
crates/ec-av1/src/decode.rsmodified+50 -14
@@ -2495,6 +2495,27 @@ fn cdef_filter_block(
2495 ///2495 ///
2496 /// Ported from libaom's `av1/common/av1_loopfilter.c` (edge/level decision)2496 /// Ported from libaom's `av1/common/av1_loopfilter.c` (edge/level decision)
2497 /// and `aom_dsp/loopfilter.c` (the `aom_lpf_*` pixel kernels).2497 /// and `aom_dsp/loopfilter.c` (the `aom_lpf_*` pixel kernels).
2498+// r17 bisect scratch: dump this frame's true-extent Y/U/V (same layout as
2499+// aomdec's EC_AV1_PREFILT_DUMP/EC_AV1_POSTFILT_DUMP) to `$var.f$idx` when
2500+// `var` is set. Remove with the rest of the r17 bisect scaffolding.
2501+static R17_DUMP_FRAME_IDX: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0);
2502+fn r17_dump(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, idx: usize) {
2503+ let Ok(base) = std::env::var(var) else {
2504+ return;
2505+ };
2506+ let mut out = Vec::new();
2507+ for r in 0..y.true_height {
2508+ out.extend_from_slice(&y.data[r * y.width..r * y.width + y.true_width]);
2509+ }
2510+ for r in 0..u.true_height {
2511+ out.extend_from_slice(&u.data[r * u.width..r * u.width + u.true_width]);
2512+ }
2513+ for r in 0..v.true_height {
2514+ out.extend_from_slice(&v.data[r * v.width..r * v.width + v.true_width]);
2515+ }
2516+ let _ = std::fs::write(format!("{base}.f{idx}"), out);
2517+}
2518+
2498 fn apply_deblock(2519 fn apply_deblock(
2499 y: &mut PlaneBuf,2520 y: &mut PlaneBuf,
2500 u: &mut PlaneBuf,2521 u: &mut PlaneBuf,
@@ -4445,18 +4466,28 @@ fn decode_inter_block(
4445 weighted/simple-average combine only, lane-av1comp",4466 weighted/simple-average combine only, lane-av1comp",
4446 ));4467 ));
4447 }4468 }
4448- // corner-cut (lane-av1comp r16): a real aomenc stream (fixtures/4469+ // corner-cut (lane-av1comp r16/r17): a real aomenc stream
4449- // av1comp-r16-compound-mismatch.obu, seed 42) proved4470+ // (fixtures/av1comp-r16-compound-mismatch.obu, seed 42) proved
4450 // predict_compound_intermediate/combine_compound wrong by up to4471 // predict_compound_intermediate/combine_compound wrong by up to
4451- // 4/255 in a ~30x32 patch of one 32x32 quadrant, spilling a few4472+ // 4/255 in a 32x32 quadrant, spilling a few pixels into
4452- // pixels into neighbours (loop-filter-shaped, not a desync --4473+ // neighbours. r16 called this "loop-filter-shaped"; r17
4453- // DRL/assign_compound_mv/dist_wtd_comp_weight_assign all cross-4474+ // FALSIFIED that -- dumping this decoder's own pre-deblock
4454- // checked bit-for-bit against libaom decodemv.c/reconinter.c and4475+ // frame buffer (`r17_dump`, `EC_AV1_PREFILT_DUMP`) against
4455- // matched). Root cause not yet isolated; refuse by name rather4476+ // aomdec's own `EC_AV1_PREFILT_DUMP` shows the same 32x32-
4456- // than ship a non-pixel-exact compound blend. Ceiling: r13/r14's4477+ // quadrant mismatch already present *before* either decoder's
4457- // MC plumbing above this line stays -- only the plain-average4478+ // loop filter runs (898/1024 px, rows 32-63 cols 32-63 of a
4458- // reconstruct is masked off again. Upgrade: bisect against the4479+ // 64x64 luma plane, frame index 2 zero-based / this decoder's
4459- // pinned fixture (frame 1, rows 16-31 cols 32-63).4480+ // 3rd frame) -- this is a `predict_compound_intermediate`/
4481+ // `combine_compound` reconstruction defect, not a deblock
4482+ // interaction. DRL/assign_compound_mv/dist_wtd_comp_weight_assign
4483+ // stay cross-checked bit-for-bit against libaom decodemv.c/
4484+ // reconinter.c (r16). Root cause still not isolated within this
4485+ // arithmetic; refuse by name rather than ship a non-pixel-exact
4486+ // compound blend. Ceiling: r13/r14's MC plumbing above this line
4487+ // stays -- only the plain-average reconstruct is masked off
4488+ // again. Upgrade: bisect predict_compound_intermediate itself
4489+ // (subpel filter taps / rounding) against the pinned fixture's
4490+ // 3rd frame, quadrant rows 32-63 cols 32-63.
4460 return Err(unsupported(4491 return Err(unsupported(
4461 "a COMPOUND_REFERENCE block using the plain/distance-weighted \4492 "a COMPOUND_REFERENCE block using the plain/distance-weighted \
4462 average blend (comp_group_idx == 0) -- proven non-pixel-exact \4493 average blend (comp_group_idx == 0) -- proven non-pixel-exact \
@@ -5296,9 +5327,11 @@ fn decode_inter_block8(
5296 weighted/simple-average combine only, lane-av1comp",5327 weighted/simple-average combine only, lane-av1comp",
5297 ));5328 ));
5298 }5329 }
5299- // corner-cut (lane-av1comp r16): same non-pixel-exact plain-5330+ // corner-cut (lane-av1comp r16/r17): same non-pixel-exact
5300- // average defect as the 16x16 leaf's own mask above -- see5331+ // plain-average reconstruction defect as the 16x16 leaf's
5301- // that comment.5332+ // own mask above (r17: falsified as loop-filter-shaped,
5333+ // isolated to predict_compound_intermediate/combine_compound
5334+ // itself) -- see that comment.
5302 return Err(unsupported(5335 return Err(unsupported(
5303 "a COMPOUND_REFERENCE 8x8 leaf using the plain/distance-weighted \5336 "a COMPOUND_REFERENCE 8x8 leaf using the plain/distance-weighted \
5304 average blend (comp_group_idx == 0) -- proven non-pixel-exact \5337 average blend (comp_group_idx == 0) -- proven non-pixel-exact \
@@ -6348,7 +6381,10 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
6348 }6381 }
6349 }6382 }
6350 6383
6384+ let r17_idx = R17_DUMP_FRAME_IDX.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
6385+ r17_dump("EC_AV1_PREFILT_DUMP", &y, &u, &v, r17_idx);
6351 apply_deblock(&mut y, &mut u, &mut v, loop_filter, &neighbours);6386 apply_deblock(&mut y, &mut u, &mut v, loop_filter, &neighbours);
6387+ r17_dump("EC_AV1_POSTFILT_DUMP", &y, &u, &v, r17_idx);
6352 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);6388 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);
6353 6389
6354 let motion_field = build_motion_field(6390 let motion_field = build_motion_field(
crates/ec-av1/src/stream.rsmodified+16 -0
@@ -3090,6 +3090,22 @@ mod tests {
3090 a_real_aomenc_temporal_mv_gate(42, 40);3090 a_real_aomenc_temporal_mv_gate(42, 40);
3091 }3091 }
3092 3092
3093+ /// r17 bisect scratch: decode a pinned stream exactly once, so
3094+ /// `decode::r17_dump`'s frame index (a process-wide counter) lines up
3095+ /// with `aomdec`'s own per-frame `EC_AV1_PREFILT_DUMP`/
3096+ /// `EC_AV1_POSTFILT_DUMP` numbering. Remove with the rest of the r17
3097+ /// scaffolding.
3098+ #[test]
3099+ #[ignore]
3100+ fn scratch_decode_pinned_stream_once() {
3101+ let path = std::env::var("EC_AV1_PIN").expect("set EC_AV1_PIN to the .obu path");
3102+ let stream = std::fs::read(&path).expect("read pinned stream");
3103+ match decode_stream(&stream) {
3104+ Ok(frames) => eprintln!("OK: {} frames", frames.len()),
3105+ Err(e) => eprintln!("ERR: {e}"),
3106+ }
3107+ }
3108+
3093 /// scratch: decode a pinned stream end to end and report where/why it3109 /// scratch: decode a pinned stream end to end and report where/why it
3094 /// refuses, plus `non_last_ref_hits` progression.3110 /// refuses, plus `non_last_ref_hits` progression.
3095 #[test]3111 #[test]