wip(av1): r2's skip_mode-desync theory FALSIFIED; real defect is decode-order
Browse files at this commit8d878fe6f28b599e7c3cc7349cefcc7f393211b5Parent: 15f253d2 changed files +34 -0
- crates/ec-av1/src/decode.rs +15 -0
- crates/ec-av1/src/stream.rs +19 -0
crates/ec-av1/src/decode.rsmodified+15 -0
| @@ -4622,7 +4622,22 @@ fn decode_inter_block( | |||
| 4622 | 4622 | ||
| 4623 | let skip_mode_ctx = | 4623 | let skip_mode_ctx = |
| 4624 | usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]); | 4624 | usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]); |
| 4625 | + // lane-comppin r3: skip_mode desync isolation -- dump ctx + the pre-read | ||
| 4626 | + // MSAC tell so it can be diffed against an equivalent hook in libaom's | ||
| 4627 | + // own `read_skip_mode`/`av1_get_skip_mode_context`. | ||
| 4628 | + if std::env::var_os("EC_AV1_SKIPMODE_DUMP").is_some() { | ||
| 4629 | + eprintln!( | ||
| 4630 | + "EC_SKIPMODE r={r} c={c} ctx={skip_mode_ctx} skip_mode_present={skip_mode_present} tell_before={}", | ||
| 4631 | + dec.debug_bitpos() | ||
| 4632 | + ); | ||
| 4633 | + } | ||
| 4625 | let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; | 4634 | let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; |
| 4635 | + if std::env::var_os("EC_AV1_SKIPMODE_DUMP").is_some() { | ||
| 4636 | + eprintln!( | ||
| 4637 | + "EC_SKIPMODE r={r} c={c} result={skip_mode} tell_after={}", | ||
| 4638 | + dec.debug_bitpos() | ||
| 4639 | + ); | ||
| 4640 | + } | ||
| 4626 | if skip_mode { | 4641 | if skip_mode { |
| 4627 | SKIP_MODE_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | 4642 | SKIP_MODE_HITS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); |
| 4628 | } | 4643 | } |
crates/ec-av1/src/stream.rsmodified+19 -0
| @@ -46,6 +46,7 @@ use crate::encode::Picture; | |||
| 46 | pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | 46 | pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { |
| 47 | let mut parser = Av1Parser::new(); | 47 | let mut parser = Av1Parser::new(); |
| 48 | let mut pictures = Vec::new(); | 48 | let mut pictures = Vec::new(); |
| 49 | + let mut pictures_decoded: usize = 0; | ||
| 49 | // Spec 7.20/7.4: each of the 8 reference slots remembers the picture a | 50 | // Spec 7.20/7.4: each of the 8 reference slots remembers the picture a |
| 50 | // previous frame's `refresh_frame_flags` stored into it, exactly like the | 51 | // previous frame's `refresh_frame_flags` stored into it, exactly like the |
| 51 | // CDF slots below -- `LAST_FRAME` names a slot via `ref_frame_idx[0]`, | 52 | // CDF slots below -- `LAST_FRAME` names a slot via `ref_frame_idx[0]`, |
| @@ -421,6 +422,24 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 421 | let _ = writeln!(f, "mv_joint {:?}", stored_cdfs.mv_joint); | 422 | let _ = writeln!(f, "mv_joint {:?}", stored_cdfs.mv_joint); |
| 422 | } | 423 | } |
| 423 | } | 424 | } |
| 425 | + // lane-comppin r3: decode-order (not display-order) dump of every | ||
| 426 | + // frame's own post-deblock buffer -- the pre-existing pixel diff | ||
| 427 | + // (`scratch_isolate_pinned_mismatch`) only ever compares *shown* | ||
| 428 | + // frames, so a hidden reference (altref/bwdref) that DPB-corrupts a | ||
| 429 | + // later shown frame is otherwise invisible; diff this byte-for-byte | ||
| 430 | + // against `EC_AV1_POSTFILT_DUMP.fN` from the instrumented aomdec | ||
| 431 | + // build to isolate whether the defect is in a hidden frame's own | ||
| 432 | + // reconstruction or downstream of it. | ||
| 433 | + if let Ok(path) = std::env::var("EC_AV1_DECODE_ORDER_DUMP") { | ||
| 434 | + use std::io::Write; | ||
| 435 | + let idx = pictures_decoded; | ||
| 436 | + if let Ok(mut f) = std::fs::File::create(format!("{path}.f{idx}")) { | ||
| 437 | + let _ = f.write_all(&picture.y); | ||
| 438 | + let _ = f.write_all(&picture.u); | ||
| 439 | + let _ = f.write_all(&picture.v); | ||
| 440 | + } | ||
| 441 | + } | ||
| 442 | + pictures_decoded += 1; | ||
| 424 | for i in 0..NUM_REF_FRAMES { | 443 | for i in 0..NUM_REF_FRAMES { |
| 425 | if header.refresh_frame_flags & (1 << i) != 0 { | 444 | if header.refresh_frame_flags & (1 << i) != 0 { |
| 426 | cdf_slots[i] = Some(stored_cdfs.clone()); | 445 | cdf_slots[i] = Some(stored_cdfs.clone()); |