forge
Explore
Log in

Don't you dare go Hollow

wip(av1): r4 compound_idx CDF-state trace instrumentation, built not yet run

Browse files at this commit

dc3404f0f148eabf389e31e7a0cbf0e22514c69eAhmet Kaan GümüşParent: 210dfc8
COMPIDX_PRE dumps per-frame pre-tile compound_idx CDF words; COMPIDX_BLK/VAL
trace every read. scratch_dump_compound_idx_cdf_state pins the fixture run.
crates/ec-av1/src/decode.rsmodified+21 -11
@@ -4600,17 +4600,6 @@ fn decode_inter_block(
46004600 // read specifically, not just the surrounding mode/mv/skip
46014601 // trace which does match -- the desync (if any) is local to
46024602 // 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)]
46144603 let (fwd_offset, bck_offset, compound_idx) = if !skip_mode && enable_jnt_comp {
46154604 let idx_ctx = get_comp_index_context(
46164605 neighbours,
@@ -4621,7 +4610,20 @@ fn decode_inter_block(
46214610 ref_order_hints[(ref0 - LAST_FRAME) as usize],
46224611 ref_order_hints[(ref1 - LAST_FRAME) as usize],
46234612 );
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+ }
46244623 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+ }
46254627 if idx == 1 {
46264628 (8, 8, 1u8)
46274629 } else {
@@ -6247,6 +6249,14 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
62476249 let scan4 = default_scan(TX4);
62486250
62496251 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+ }
62506260 let mut dec = SymbolDecoder::new(data);
62516261 let mut neighbours = Neighbours::new(
62526262 cols as usize * 2,
crates/ec-av1/src/stream.rsmodified+18 -0
@@ -3259,6 +3259,24 @@ mod tests {
32593259 }
32603260 }
32613261
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+
32623280 /// lane-av1blend r2 scratch: sweep every seed of the compound_references
32633281 /// recipe (with the plain-average blend UNMASKED locally) looking for a
32643282 /// pixel mismatch, dumping the first one found to `EC_AV1_GATE_DUMP`.