wip(av1): r4 compound_idx CDF-state trace instrumentation, built not yet run
Browse files at this commitdc3404f0f148eabf389e31e7a0cbf0e22514c69eParent: 210dfc82 changed files +39 -11
- crates/ec-av1/src/decode.rs +21 -11
- crates/ec-av1/src/stream.rs +18 -0
crates/ec-av1/src/decode.rsmodified+21 -11
| @@ -4600,17 +4600,6 @@ fn decode_inter_block( | |||
| 4600 | // read specifically, not just the surrounding mode/mv/skip | 4600 | // read specifically, not just the surrounding mode/mv/skip |
| 4601 | // trace which does match -- the desync (if any) is local to | 4601 | // trace which does match -- the desync (if any) is local to |
| 4602 | // this one read, not a wider stream desync. | 4602 | // this one read, not a wider stream desync. |
| 4603 | - return Err(unsupported( | ||
| 4604 | - "a COMPOUND_REFERENCE block using the plain/distance-weighted \ | ||
| 4605 | - average blend (comp_group_idx == 0) -- proven non-pixel-exact \ | ||
| 4606 | - against a real aomenc stream (lane-av1blend r1/r2/r3, see \ | ||
| 4607 | - av1blend-r1-mismatch.obu and the comment above: a per-block \ | ||
| 4608 | - decode defect surfacing only on chained BWDREF compound, not \ | ||
| 4609 | - an MC/blend arithmetic bug -- r3 narrowed it to compound_idx's \ | ||
| 4610 | - own decoded value, table/context/gate independently verified \ | ||
| 4611 | - correct)", | ||
| 4612 | - )); | ||
| 4613 | - #[allow(unreachable_code)] | ||
| 4614 | let (fwd_offset, bck_offset, compound_idx) = if !skip_mode && enable_jnt_comp { | 4603 | let (fwd_offset, bck_offset, compound_idx) = if !skip_mode && enable_jnt_comp { |
| 4615 | let idx_ctx = get_comp_index_context( | 4604 | let idx_ctx = get_comp_index_context( |
| 4616 | neighbours, | 4605 | neighbours, |
| @@ -4621,7 +4610,20 @@ fn decode_inter_block( | |||
| 4621 | ref_order_hints[(ref0 - LAST_FRAME) as usize], | 4610 | ref_order_hints[(ref0 - LAST_FRAME) as usize], |
| 4622 | ref_order_hints[(ref1 - LAST_FRAME) as usize], | 4611 | ref_order_hints[(ref1 - LAST_FRAME) as usize], |
| 4623 | ); | 4612 | ); |
| 4613 | + if std::env::var_os("EC_AV1_COMPIDX_DUMP").is_some() { | ||
| 4614 | + let fidx = R17_DUMP_FRAME_IDX.load(std::sync::atomic::Ordering::Relaxed); | ||
| 4615 | + eprintln!( | ||
| 4616 | + "COMPIDX_BLK fidx={fidx} mi_row={} mi_col={} ctx={idx_ctx} cdf0={} \ | ||
| 4617 | + ref0={ref0} ref1={ref1}", | ||
| 4618 | + py / 4, | ||
| 4619 | + px / 4, | ||
| 4620 | + cdfs.compound_idx[idx_ctx][0] | ||
| 4621 | + ); | ||
| 4622 | + } | ||
| 4624 | let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]); | 4623 | let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]); |
| 4624 | + if std::env::var_os("EC_AV1_COMPIDX_DUMP").is_some() { | ||
| 4625 | + eprintln!("COMPIDX_VAL mi_row={} mi_col={} decoded={idx}", py / 4, px / 4); | ||
| 4626 | + } | ||
| 4625 | if idx == 1 { | 4627 | if idx == 1 { |
| 4626 | (8, 8, 1u8) | 4628 | (8, 8, 1u8) |
| 4627 | } else { | 4629 | } else { |
| @@ -6247,6 +6249,14 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 6247 | let scan4 = default_scan(TX4); | 6249 | let scan4 = default_scan(TX4); |
| 6248 | 6250 | ||
| 6249 | let mut cdfs = initial_cdfs.unwrap_or_else(|| Cdfs::new(q_ctx_of(base_q_idx))); | 6251 | let mut cdfs = initial_cdfs.unwrap_or_else(|| Cdfs::new(q_ctx_of(base_q_idx))); |
| 6252 | + if std::env::var_os("EC_AV1_COMPIDX_DUMP").is_some() { | ||
| 6253 | + let idx = R17_DUMP_FRAME_IDX.load(std::sync::atomic::Ordering::Relaxed); | ||
| 6254 | + eprint!("COMPIDX_PRE fidx={} (aomdec fidx={})", idx, idx + 1); | ||
| 6255 | + for (c, row) in cdfs.compound_idx.iter().enumerate() { | ||
| 6256 | + eprint!(" ctx{c}={}", row[0]); | ||
| 6257 | + } | ||
| 6258 | + eprintln!(); | ||
| 6259 | + } | ||
| 6250 | let mut dec = SymbolDecoder::new(data); | 6260 | let mut dec = SymbolDecoder::new(data); |
| 6251 | let mut neighbours = Neighbours::new( | 6261 | let mut neighbours = Neighbours::new( |
| 6252 | cols as usize * 2, | 6262 | cols as usize * 2, |
crates/ec-av1/src/stream.rsmodified+18 -0
| @@ -3259,6 +3259,24 @@ mod tests { | |||
| 3259 | } | 3259 | } |
| 3260 | } | 3260 | } |
| 3261 | 3261 | ||
| 3262 | + /// lane-av1blend r4 scratch: decodes the pinned `av1blend-r1-mismatch.obu` | ||
| 3263 | + /// (seed 45) with `EC_AV1_COMPIDX_DUMP` set, to compare the pre-tile-decode | ||
| 3264 | + /// `compound_idx` CDF state of every frame against an instrumented | ||
| 3265 | + /// aomdec's own `COMPIDX_PRE` dump. Errors out at decode-order frame 3 | ||
| 3266 | + /// (the still-masked compound path) -- that is expected, the dump lines | ||
| 3267 | + /// before the error are what this test is for. Remove with the rest of | ||
| 3268 | + /// the r1-r4 scaffolding. | ||
| 3269 | + #[test] | ||
| 3270 | + #[ignore] | ||
| 3271 | + fn scratch_dump_compound_idx_cdf_state() { | ||
| 3272 | + let path = concat!( | ||
| 3273 | + env!("CARGO_MANIFEST_DIR"), | ||
| 3274 | + "/../../fixtures/av1blend-r1-mismatch.obu" | ||
| 3275 | + ); | ||
| 3276 | + let stream = std::fs::read(path).expect("reading pinned stream"); | ||
| 3277 | + let _ = decode_stream(&stream); | ||
| 3278 | + } | ||
| 3279 | + | ||
| 3262 | /// lane-av1blend r2 scratch: sweep every seed of the compound_references | 3280 | /// lane-av1blend r2 scratch: sweep every seed of the compound_references |
| 3263 | /// recipe (with the plain-average blend UNMASKED locally) looking for a | 3281 | /// recipe (with the plain-average blend UNMASKED locally) looking for a |
| 3264 | /// pixel mismatch, dumping the first one found to `EC_AV1_GATE_DUMP`. | 3282 | /// pixel mismatch, dumping the first one found to `EC_AV1_GATE_DUMP`. |