Remove bisect scratch instrumentation (SREF/COMPIDX/COMPOUND_DEBUG/r17 dump)
Browse files at this commitd6ab49e877c98f4b576cd677a084aeece5f8e38cParent: a3b0b8a- chore
- remove bisect scratch instrumentation (SREF/COMPIDX/COMPOUND_DEBUG/r17 dump)
2 changed files +12 -354
- crates/ec-av1/src/decode.rs +10 -161
- crates/ec-av1/src/stream.rs +2 -193
crates/ec-av1/src/decode.rsmodified+10 -161
| @@ -2495,33 +2495,6 @@ 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 | -// r17 bisect scratch accessor for stream.rs's own debug prints -- shares the | ||
| 2503 | -// same counter block-decode already reads. Remove with the rest of the r17 | ||
| 2504 | -// bisect scaffolding. | ||
| 2505 | -pub fn r17_dump_frame_idx() -> usize { | ||
| 2506 | - R17_DUMP_FRAME_IDX.load(std::sync::atomic::Ordering::Relaxed) | ||
| 2507 | -} | ||
| 2508 | -fn r17_dump(var: &str, y: &PlaneBuf, u: &PlaneBuf, v: &PlaneBuf, idx: usize) { | ||
| 2509 | - let Ok(base) = std::env::var(var) else { | ||
| 2510 | - return; | ||
| 2511 | - }; | ||
| 2512 | - let mut out = Vec::new(); | ||
| 2513 | - for r in 0..y.true_height { | ||
| 2514 | - out.extend_from_slice(&y.data[r * y.width..r * y.width + y.true_width]); | ||
| 2515 | - } | ||
| 2516 | - for r in 0..u.true_height { | ||
| 2517 | - out.extend_from_slice(&u.data[r * u.width..r * u.width + u.true_width]); | ||
| 2518 | - } | ||
| 2519 | - for r in 0..v.true_height { | ||
| 2520 | - out.extend_from_slice(&v.data[r * v.width..r * v.width + v.true_width]); | ||
| 2521 | - } | ||
| 2522 | - let _ = std::fs::write(format!("{base}.f{idx}"), out); | ||
| 2523 | -} | ||
| 2524 | - | ||
| 2525 | fn apply_deblock( | 2498 | fn apply_deblock( |
| 2526 | y: &mut PlaneBuf, | 2499 | y: &mut PlaneBuf, |
| 2527 | u: &mut PlaneBuf, | 2500 | u: &mut PlaneBuf, |
| @@ -3712,21 +3685,9 @@ fn resolve_interp_filter( | |||
| 3712 | // `h_kind`/`v_kind` argument order, which is why this function returns | 3685 | // `h_kind`/`v_kind` argument order, which is why this function returns |
| 3713 | // `(h, v, ..)` but reads `dir0` (`v`) before `dir1` (`h`). | 3686 | // `(h, v, ..)` but reads `dir0` (`v`) before `dir1` (`h`). |
| 3714 | let ctx0 = switchable_interp_ctx(above[0], left[0], 0, is_compound); | 3687 | let ctx0 = switchable_interp_ctx(above[0], left[0], 0, is_compound); |
| 3715 | - if std::env::var_os("EC_AV1_SREF_DUMP").is_some() { | ||
| 3716 | - eprintln!( | ||
| 3717 | - "IFILTER_RS dir=0 ctx={ctx0} cdf={:?}", | ||
| 3718 | - &cdfs.switchable_interp[ctx0][..3] | ||
| 3719 | - ); | ||
| 3720 | - } | ||
| 3721 | let sym0 = dec.symbol(&mut cdfs.switchable_interp[ctx0]) as u8; | 3688 | let sym0 = dec.symbol(&mut cdfs.switchable_interp[ctx0]) as u8; |
| 3722 | let sym1 = if enable_dual_filter { | 3689 | let sym1 = if enable_dual_filter { |
| 3723 | let ctx1 = switchable_interp_ctx(above[1], left[1], 1, is_compound); | 3690 | let ctx1 = switchable_interp_ctx(above[1], left[1], 1, is_compound); |
| 3724 | - if std::env::var_os("EC_AV1_SREF_DUMP").is_some() { | ||
| 3725 | - eprintln!( | ||
| 3726 | - "IFILTER_RS dir=1 ctx={ctx1} cdf={:?}", | ||
| 3727 | - &cdfs.switchable_interp[ctx1][..3] | ||
| 3728 | - ); | ||
| 3729 | - } | ||
| 3730 | dec.symbol(&mut cdfs.switchable_interp[ctx1]) as u8 | 3691 | dec.symbol(&mut cdfs.switchable_interp[ctx1]) as u8 |
| 3731 | } else { | 3692 | } else { |
| 3732 | sym0 | 3693 | sym0 |
| @@ -4340,14 +4301,6 @@ fn decode_inter_block( | |||
| 4340 | let (cpx, cpy) = (px / 2, py / 2); | 4301 | let (cpx, cpy) = (px / 2, py / 2); |
| 4341 | let chroma_side = side / 2; | 4302 | let chroma_side = side / 2; |
| 4342 | 4303 | ||
| 4343 | - if std::env::var_os("EC_AV1_COMPIDX_DUMP").is_some() { | ||
| 4344 | - eprintln!( | ||
| 4345 | - "BITPOS_BLK_START mi_row={} mi_col={} bitpos={}", | ||
| 4346 | - py / 4, | ||
| 4347 | - px / 4, | ||
| 4348 | - dec.debug_bitpos() | ||
| 4349 | - ); | ||
| 4350 | - } | ||
| 4351 | let skip_mode_ctx = | 4304 | let skip_mode_ctx = |
| 4352 | usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]); | 4305 | usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]); |
| 4353 | let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; | 4306 | let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1; |
| @@ -4536,8 +4489,8 @@ fn decode_inter_block( | |||
| 4536 | // (av1_dist_wtd_convolve_2d_c, convolve.c:402-415) for every | 4489 | // (av1_dist_wtd_convolve_2d_c, convolve.c:402-415) for every |
| 4537 | // input, and a whole-pel zero-MV compound block (mv0=mv1=(0,0), | 4490 | // input, and a whole-pel zero-MV compound block (mv0=mv1=(0,0), |
| 4538 | // the common case a lag-in-frames GOP's hidden altref frames | 4491 | // the common case a lag-in-frames GOP's hidden altref frames |
| 4539 | - // hit) reproduces aomdec's own pre-deblock `EC_AV1_PREFILT_DUMP` | 4492 | + // hit) reproduces aomdec's own pre-deblock dump byte-for-byte |
| 4540 | - // byte-for-byte for several consecutive frames. | 4493 | + // for several consecutive frames. |
| 4541 | // | 4494 | // |
| 4542 | // The real defect a live gate run isolated (seed 49, | 4495 | // The real defect a live gate run isolated (seed 49, |
| 4543 | // `fixtures/av1blend-r1-mismatch.obu`): decode-order frame 0 | 4496 | // `fixtures/av1blend-r1-mismatch.obu`): decode-order frame 0 |
| @@ -4599,15 +4552,15 @@ fn decode_inter_block( | |||
| 4599 | // synced `EC_TOK`/`EC_PART` trace from the instrumented aomdec | 4552 | // synced `EC_TOK`/`EC_PART` trace from the instrumented aomdec |
| 4600 | // build (`/tmp/libaom-src/build/decoder-debug/aomdec`) on | 4553 | // build (`/tmp/libaom-src/build/decoder-debug/aomdec`) on |
| 4601 | // `fixtures/av1blend-r1-mismatch.obu` (seed 45 now, not seed 49) | 4554 | // `fixtures/av1blend-r1-mismatch.obu` (seed 45 now, not seed 49) |
| 4602 | - // -- the pre-deblock `EC_AV1_PREFILT_DUMP` frame-index alignment | 4555 | + // -- the pre-deblock dump frame-index alignment between this |
| 4603 | - // between this crate and that aomdec build is NOT 1:1 on this | 4556 | + // crate and that aomdec build is NOT 1:1 on this fixture (23 |
| 4604 | - // fixture (23 dumps here vs 24 there), so calibrate that first. | 4557 | + // dumps here vs 24 there), so calibrate that first. |
| 4605 | // r3 (this round): pre-deblock buffers were bisected byte-for-byte | 4558 | // r3 (this round): pre-deblock buffers were bisected byte-for-byte |
| 4606 | - // against an instrumented aomdec build (EC_AV1_PREFILT_DUMP, | 4559 | + // against an instrumented aomdec build (frame-index alignment |
| 4607 | - // frame-index alignment recalibrated via content-hash matching | 4560 | + // recalibrated via content-hash matching rather than the raw |
| 4608 | - // rather than the raw dump count -- the keyframe never calls this | 4561 | + // dump count -- the keyframe never calls a pre-deblock dump at |
| 4609 | - // crate's own `r17_dump` at all, since only `decode_inter_frame_ | 4562 | + // all, since only `decode_inter_frame_tile` does, which is the |
| 4610 | - // tile` does, which is the whole "23 vs 24" gap, not a real bug). | 4563 | + // whole "23 vs 24" gap, not a real bug). |
| 4611 | // Decode-order frame 3 (`fixtures/av1blend-r1-mismatch.obu`, | 4564 | // Decode-order frame 3 (`fixtures/av1blend-r1-mismatch.obu`, |
| 4612 | // seed 45) is still the first divergence: PRE-deblock differs | 4565 | // seed 45) is still the first divergence: PRE-deblock differs |
| 4613 | // from aomdec's own pre-deblock dump by up to 1, on ~20% of | 4566 | // from aomdec's own pre-deblock dump by up to 1, on ~20% of |
| @@ -4726,25 +4679,7 @@ fn decode_inter_block( | |||
| 4726 | ref_order_hints[(ref0 - LAST_FRAME) as usize], | 4679 | ref_order_hints[(ref0 - LAST_FRAME) as usize], |
| 4727 | ref_order_hints[(ref1 - LAST_FRAME) as usize], | 4680 | ref_order_hints[(ref1 - LAST_FRAME) as usize], |
| 4728 | ); | 4681 | ); |
| 4729 | - if std::env::var_os("EC_AV1_COMPIDX_DUMP").is_some() { | ||
| 4730 | - let fidx = R17_DUMP_FRAME_IDX.load(std::sync::atomic::Ordering::Relaxed); | ||
| 4731 | - eprintln!( | ||
| 4732 | - "COMPIDX_BLK fidx={fidx} mi_row={} mi_col={} ctx={idx_ctx} cdf0={} \ | ||
| 4733 | - ref0={ref0} ref1={ref1}", | ||
| 4734 | - py / 4, | ||
| 4735 | - px / 4, | ||
| 4736 | - cdfs.compound_idx[idx_ctx][0] | ||
| 4737 | - ); | ||
| 4738 | - } | ||
| 4739 | let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]); | 4682 | let idx = dec.symbol(&mut cdfs.compound_idx[idx_ctx]); |
| 4740 | - if std::env::var_os("EC_AV1_COMPIDX_DUMP").is_some() { | ||
| 4741 | - eprintln!( | ||
| 4742 | - "COMPIDX_VAL mi_row={} mi_col={} decoded={idx} bitpos={}", | ||
| 4743 | - py / 4, | ||
| 4744 | - px / 4, | ||
| 4745 | - dec.debug_bitpos() | ||
| 4746 | - ); | ||
| 4747 | - } | ||
| 4748 | if idx == 1 { | 4683 | if idx == 1 { |
| 4749 | (8, 8, 1u8) | 4684 | (8, 8, 1u8) |
| 4750 | } else { | 4685 | } else { |
| @@ -4767,28 +4702,6 @@ fn decode_inter_block( | |||
| 4767 | // (lane-av1blend r5) from its old position ahead of those reads, | 4702 | // (lane-av1blend r5) from its old position ahead of those reads, |
| 4768 | // which stole their bits for a Switchable-filter compound block | 4703 | // which stole their bits for a Switchable-filter compound block |
| 4769 | // and desynced every symbol read after it in the tile. | 4704 | // and desynced every symbol read after it in the tile. |
| 4770 | - if std::env::var_os("EC_AV1_COMPIDX_DUMP").is_some() { | ||
| 4771 | - eprintln!( | ||
| 4772 | - "IFILTER_PRE mi_row={} mi_col={} interp_fixed={:?} is_globalmv={is_globalmv}", | ||
| 4773 | - py / 4, | ||
| 4774 | - px / 4, | ||
| 4775 | - interp_fixed | ||
| 4776 | - ); | ||
| 4777 | - } | ||
| 4778 | - if std::env::var_os("EC_AV1_SREF_DUMP").is_some() { | ||
| 4779 | - let fidx = R17_DUMP_FRAME_IDX.load(std::sync::atomic::Ordering::Relaxed); | ||
| 4780 | - eprintln!( | ||
| 4781 | - "CREF fidx={fidx} mi_row={} mi_col={} side={side} ref0={ref0} ref1={ref1} \ | ||
| 4782 | - above_ref={} left_ref={} above_ref1={:?} left_ref1={:?} \ | ||
| 4783 | - above_filter_ctx={above_filter_ctx:?} left_filter_ctx={left_filter_ctx:?}", | ||
| 4784 | - py / 4, | ||
| 4785 | - px / 4, | ||
| 4786 | - neighbours.above_ref[c], | ||
| 4787 | - neighbours.left_ref[r], | ||
| 4788 | - neighbours.above_ref1[c], | ||
| 4789 | - neighbours.left_ref1[r], | ||
| 4790 | - ); | ||
| 4791 | - } | ||
| 4792 | let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( | 4705 | let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( |
| 4793 | dec, | 4706 | dec, |
| 4794 | cdfs, | 4707 | cdfs, |
| @@ -4800,14 +4713,6 @@ fn decode_inter_block( | |||
| 4800 | true, | 4713 | true, |
| 4801 | ); | 4714 | ); |
| 4802 | block_filter = resolved_filter; | 4715 | block_filter = resolved_filter; |
| 4803 | - if std::env::var_os("EC_AV1_SREF_DUMP").is_some() { | ||
| 4804 | - let fidx = R17_DUMP_FRAME_IDX.load(std::sync::atomic::Ordering::Relaxed); | ||
| 4805 | - eprintln!( | ||
| 4806 | - "CREF_RESOLVED fidx={fidx} mi_row={} mi_col={} resolved={resolved_filter:?}", | ||
| 4807 | - py / 4, | ||
| 4808 | - px / 4, | ||
| 4809 | - ); | ||
| 4810 | - } | ||
| 4811 | 4716 | ||
| 4812 | let mut inter0_y = vec![0i32; side * side]; | 4717 | let mut inter0_y = vec![0i32; side * side]; |
| 4813 | mc::predict_compound_intermediate( | 4718 | mc::predict_compound_intermediate( |
| @@ -4840,20 +4745,6 @@ fn decode_inter_block( | |||
| 4840 | let mut pred_y = vec![0u8; side * side]; | 4745 | let mut pred_y = vec![0u8; side * side]; |
| 4841 | mc::combine_compound(&inter0_y, &inter1_y, fwd_offset, bck_offset, &mut pred_y); | 4746 | mc::combine_compound(&inter0_y, &inter1_y, fwd_offset, bck_offset, &mut pred_y); |
| 4842 | 4747 | ||
| 4843 | - // r17 bisect scratch: dump per-block compound state when this | ||
| 4844 | - // block overlaps the pinned fixture's bad quadrant (frame 2, | ||
| 4845 | - // rows 32-63 cols 32-63). Remove with the rest of the scaffolding. | ||
| 4846 | - if std::env::var("EC_AV1_COMPOUND_DEBUG").is_ok() { | ||
| 4847 | - let fidx = R17_DUMP_FRAME_IDX.load(std::sync::atomic::Ordering::Relaxed); | ||
| 4848 | - eprintln!( | ||
| 4849 | - "leaf16 fidx={fidx} px={px} py={py} side={side} ref0={ref0} ref1={ref1} \ | ||
| 4850 | - mv0={mv0:?} mv1={mv1:?} filter={resolved_filter:?} \ | ||
| 4851 | - fwd={fwd_offset} bck={bck_offset} compound_idx={compound_idx} \ | ||
| 4852 | - pred_y[0..4]={:?}", | ||
| 4853 | - &pred_y[0..4.min(pred_y.len())] | ||
| 4854 | - ); | ||
| 4855 | - } | ||
| 4856 | - | ||
| 4857 | let mut inter0_u = vec![0i32; chroma_side * chroma_side]; | 4748 | let mut inter0_u = vec![0i32; chroma_side * chroma_side]; |
| 4858 | mc::predict_compound_intermediate( | 4749 | mc::predict_compound_intermediate( |
| 4859 | &pu0.data, | 4750 | &pu0.data, |
| @@ -5128,20 +5019,6 @@ fn decode_inter_block( | |||
| 5128 | } else { | 5019 | } else { |
| 5129 | [3, 3] | 5020 | [3, 3] |
| 5130 | }; | 5021 | }; |
| 5131 | - if std::env::var_os("EC_AV1_SREF_DUMP").is_some() { | ||
| 5132 | - let fidx = R17_DUMP_FRAME_IDX.load(std::sync::atomic::Ordering::Relaxed); | ||
| 5133 | - eprintln!( | ||
| 5134 | - "SREF fidx={fidx} mi_row={} mi_col={} side={side} ref_frame={ref_frame} \ | ||
| 5135 | - above_ref={} left_ref={} above_ref1={:?} left_ref1={:?} \ | ||
| 5136 | - above_filter_ctx={above_filter_ctx:?} left_filter_ctx={left_filter_ctx:?}", | ||
| 5137 | - py / 4, | ||
| 5138 | - px / 4, | ||
| 5139 | - neighbours.above_ref[c], | ||
| 5140 | - neighbours.left_ref[r], | ||
| 5141 | - neighbours.above_ref1[c], | ||
| 5142 | - neighbours.left_ref1[r], | ||
| 5143 | - ); | ||
| 5144 | - } | ||
| 5145 | let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( | 5022 | let (h_filter, v_filter, resolved_filter) = resolve_interp_filter( |
| 5146 | dec, | 5023 | dec, |
| 5147 | cdfs, | 5024 | cdfs, |
| @@ -5152,14 +5029,6 @@ fn decode_inter_block( | |||
| 5152 | left_filter_ctx, | 5029 | left_filter_ctx, |
| 5153 | false, | 5030 | false, |
| 5154 | ); | 5031 | ); |
| 5155 | - if std::env::var_os("EC_AV1_SREF_DUMP").is_some() { | ||
| 5156 | - let fidx = R17_DUMP_FRAME_IDX.load(std::sync::atomic::Ordering::Relaxed); | ||
| 5157 | - eprintln!( | ||
| 5158 | - "SREF_RESOLVED fidx={fidx} mi_row={} mi_col={} resolved={resolved_filter:?}", | ||
| 5159 | - py / 4, | ||
| 5160 | - px / 4, | ||
| 5161 | - ); | ||
| 5162 | - } | ||
| 5163 | block_filter = resolved_filter; | 5032 | block_filter = resolved_filter; |
| 5164 | globalmv_for_lf = is_globalmv; | 5033 | globalmv_for_lf = is_globalmv; |
| 5165 | if std::env::var_os("EC_AV1_TRACE").is_some() { | 5034 | if std::env::var_os("EC_AV1_TRACE").is_some() { |
| @@ -5763,15 +5632,6 @@ fn decode_inter_block8( | |||
| 5763 | let mut pred_y = vec![0u8; SIDE * SIDE]; | 5632 | let mut pred_y = vec![0u8; SIDE * SIDE]; |
| 5764 | mc::combine_compound(&inter0_y, &inter1_y, fwd_offset, bck_offset, &mut pred_y); | 5633 | mc::combine_compound(&inter0_y, &inter1_y, fwd_offset, bck_offset, &mut pred_y); |
| 5765 | 5634 | ||
| 5766 | - if std::env::var("EC_AV1_COMPOUND_DEBUG").is_ok() { | ||
| 5767 | - let fidx = R17_DUMP_FRAME_IDX.load(std::sync::atomic::Ordering::Relaxed); | ||
| 5768 | - eprintln!( | ||
| 5769 | - "leaf8 fidx={fidx} px={px} py={py} ref0={ref0} ref1={ref1} \ | ||
| 5770 | - mv0={mv0:?} mv1={mv1:?} fwd={fwd_offset} bck={bck_offset} \ | ||
| 5771 | - compound_idx={compound_idx} pred_y={pred_y:?}" | ||
| 5772 | - ); | ||
| 5773 | - } | ||
| 5774 | - | ||
| 5775 | let mut inter0_u = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; | 5635 | let mut inter0_u = vec![0i32; CHROMA_SIDE * CHROMA_SIDE]; |
| 5776 | mc::predict_compound_intermediate( | 5636 | mc::predict_compound_intermediate( |
| 5777 | &pu0.data, | 5637 | &pu0.data, |
| @@ -6453,14 +6313,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 6453 | let scan4 = default_scan(TX4); | 6313 | let scan4 = default_scan(TX4); |
| 6454 | 6314 | ||
| 6455 | let mut cdfs = initial_cdfs.unwrap_or_else(|| Cdfs::new(q_ctx_of(base_q_idx))); | 6315 | let mut cdfs = initial_cdfs.unwrap_or_else(|| Cdfs::new(q_ctx_of(base_q_idx))); |
| 6456 | - if std::env::var_os("EC_AV1_COMPIDX_DUMP").is_some() { | ||
| 6457 | - let idx = R17_DUMP_FRAME_IDX.load(std::sync::atomic::Ordering::Relaxed); | ||
| 6458 | - eprint!("COMPIDX_PRE fidx={} (aomdec fidx={})", idx, idx + 1); | ||
| 6459 | - for (c, row) in cdfs.compound_idx.iter().enumerate() { | ||
| 6460 | - eprint!(" ctx{c}={}", row[0]); | ||
| 6461 | - } | ||
| 6462 | - eprintln!(); | ||
| 6463 | - } | ||
| 6464 | let mut dec = SymbolDecoder::new(data); | 6316 | let mut dec = SymbolDecoder::new(data); |
| 6465 | let mut neighbours = Neighbours::new( | 6317 | let mut neighbours = Neighbours::new( |
| 6466 | cols as usize * 2, | 6318 | cols as usize * 2, |
| @@ -6737,10 +6589,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 6737 | } | 6589 | } |
| 6738 | } | 6590 | } |
| 6739 | 6591 | ||
| 6740 | - let r17_idx = R17_DUMP_FRAME_IDX.fetch_add(1, std::sync::atomic::Ordering::Relaxed); | ||
| 6741 | - r17_dump("EC_AV1_PREFILT_DUMP", &y, &u, &v, r17_idx); | ||
| 6742 | apply_deblock(&mut y, &mut u, &mut v, loop_filter, &neighbours); | 6592 | apply_deblock(&mut y, &mut u, &mut v, loop_filter, &neighbours); |
| 6743 | - r17_dump("EC_AV1_POSTFILT_DUMP", &y, &u, &v, r17_idx); | ||
| 6744 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); | 6593 | apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours); |
| 6745 | 6594 | ||
| 6746 | let motion_field = build_motion_field( | 6595 | let motion_field = build_motion_field( |
crates/ec-av1/src/stream.rsmodified+2 -193
| @@ -74,7 +74,6 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 74 | let mut cdf_slots: [Option<Cdfs>; NUM_REF_FRAMES] = std::array::from_fn(|_| None); | 74 | let mut cdf_slots: [Option<Cdfs>; NUM_REF_FRAMES] = std::array::from_fn(|_| None); |
| 75 | 75 | ||
| 76 | let mut pos = 0usize; | 76 | let mut pos = 0usize; |
| 77 | - let mut decode_idx = 0u32; | ||
| 78 | while pos < data.len() { | 77 | while pos < data.len() { |
| 79 | let obu = parser.parse_obu(&data[pos..])?; | 78 | let obu = parser.parse_obu(&data[pos..])?; |
| 80 | let obu_offset = pos; | 79 | let obu_offset = pos; |
| @@ -115,12 +114,6 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 115 | picture | 114 | picture |
| 116 | }; | 115 | }; |
| 117 | pictures.push(output); | 116 | pictures.push(output); |
| 118 | - if std::env::var("EC_AV1_COMPOUND_DEBUG").is_ok() { | ||
| 119 | - eprintln!( | ||
| 120 | - "PUSH (show_existing_frame slot {slot}) pictures.len()={}", | ||
| 121 | - pictures.len() | ||
| 122 | - ); | ||
| 123 | - } | ||
| 124 | continue; | 117 | continue; |
| 125 | } | 118 | } |
| 126 | let ObuKind::Frame(header, tiles) = obu.kind else { | 119 | let ObuKind::Frame(header, tiles) = obu.kind else { |
| @@ -266,19 +259,6 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 266 | ec_av1_syntax::InterpolationFilter::Switchable => None, | 259 | ec_av1_syntax::InterpolationFilter::Switchable => None, |
| 267 | fixed => Some(crate::mc::InterpFilterKind::from_header(fixed)), | 260 | fixed => Some(crate::mc::InterpFilterKind::from_header(fixed)), |
| 268 | }; | 261 | }; |
| 269 | - if std::env::var_os("EC_AV1_SREF_DUMP").is_some() { | ||
| 270 | - eprintln!( | ||
| 271 | - "STREAM_HEADER r17_before={} interpolation_filter={:?} interp_fixed={interp_fixed:?} is_motion_mode_switchable={} enable_interintra_compound={:?} allow_warped_motion={} reference_select={} primary_ref_frame={}", | ||
| 272 | - crate::decode::r17_dump_frame_idx(), | ||
| 273 | - header.interpolation_filter, | ||
| 274 | - header.is_motion_mode_switchable, | ||
| 275 | - parser.sequence_header().map(|s| s.enable_interintra_compound), | ||
| 276 | - header.allow_warped_motion, | ||
| 277 | - header.reference_select, | ||
| 278 | - header.primary_ref_frame, | ||
| 279 | - ); | ||
| 280 | - } | ||
| 281 | - | ||
| 282 | // Spec 7.20 `load_cdfs`: a frame naming a `primary_ref_frame` resumes | 262 | // Spec 7.20 `load_cdfs`: a frame naming a `primary_ref_frame` resumes |
| 283 | // from that reference slot's saved CDF state instead of the spec 8.4 | 263 | // from that reference slot's saved CDF state instead of the spec 8.4 |
| 284 | // defaults `decode_key/inter_frame_tile_with_cdfs`'s `None` case | 264 | // defaults `decode_key/inter_frame_tile_with_cdfs`'s `None` case |
| @@ -307,19 +287,6 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 307 | let ref_order_hints: [u32; 7] = | 287 | let ref_order_hints: [u32; 7] = |
| 308 | std::array::from_fn(|i| order_hint_slots[header.ref_frame_idx[i] as usize]); | 288 | std::array::from_fn(|i| order_hint_slots[header.ref_frame_idx[i] as usize]); |
| 309 | 289 | ||
| 310 | - if std::env::var("EC_AV1_COMPOUND_DEBUG").is_ok() { | ||
| 311 | - eprintln!( | ||
| 312 | - "FRAME decode_idx={decode_idx} type={:?} show={} order_hint={} refresh_frame_flags={:#04x} ref_frame_idx={:?} order_hint_slots={:?}", | ||
| 313 | - header.frame_type, | ||
| 314 | - header.show_frame, | ||
| 315 | - header.order_hint, | ||
| 316 | - header.refresh_frame_flags, | ||
| 317 | - header.ref_frame_idx, | ||
| 318 | - order_hint_slots, | ||
| 319 | - ); | ||
| 320 | - } | ||
| 321 | - decode_idx += 1; | ||
| 322 | - | ||
| 323 | let (picture, end_cdfs, motion_field) = if header.frame_type == FrameType::Key { | 290 | let (picture, end_cdfs, motion_field) = if header.frame_type == FrameType::Key { |
| 324 | let (picture, end_cdfs) = decode_key_frame_tile_with_cdfs( | 291 | let (picture, end_cdfs) = decode_key_frame_tile_with_cdfs( |
| 325 | tile_bytes, | 292 | tile_bytes, |
| @@ -466,18 +433,6 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> { | |||
| 466 | picture | 433 | picture |
| 467 | }; | 434 | }; |
| 468 | pictures.push(output); | 435 | pictures.push(output); |
| 469 | - if std::env::var("EC_AV1_COMPOUND_DEBUG").is_ok() { | ||
| 470 | - eprintln!( | ||
| 471 | - "PUSH (shown-direct) pictures.len()={} <- decode.rs r17 fidx {}", | ||
| 472 | - pictures.len(), | ||
| 473 | - crate::decode::r17_dump_frame_idx() | ||
| 474 | - ); | ||
| 475 | - } | ||
| 476 | - } else if std::env::var("EC_AV1_COMPOUND_DEBUG").is_ok() { | ||
| 477 | - eprintln!( | ||
| 478 | - "HIDDEN frame decoded, not pushed <- decode.rs r17 fidx {}", | ||
| 479 | - crate::decode::r17_dump_frame_idx() | ||
| 480 | - ); | ||
| 481 | } | 436 | } |
| 482 | } | 437 | } |
| 483 | Ok(pictures) | 438 | Ok(pictures) |
| @@ -3201,11 +3156,8 @@ mod tests { | |||
| 3201 | a_real_aomenc_temporal_mv_gate(42, 40); | 3156 | a_real_aomenc_temporal_mv_gate(42, 40); |
| 3202 | } | 3157 | } |
| 3203 | 3158 | ||
| 3204 | - /// r17 bisect scratch: decode a pinned stream exactly once, so | 3159 | + /// bisect scratch: decode a pinned stream exactly once -- generic |
| 3205 | - /// `decode::r17_dump`'s frame index (a process-wide counter) lines up | 3160 | + /// pin-repro tool, kept for manual use. |
| 3206 | - /// with `aomdec`'s own per-frame `EC_AV1_PREFILT_DUMP`/ | ||
| 3207 | - /// `EC_AV1_POSTFILT_DUMP` numbering. Remove with the rest of the r17 | ||
| 3208 | - /// scaffolding. | ||
| 3209 | #[test] | 3161 | #[test] |
| 3210 | #[ignore] | 3162 | #[ignore] |
| 3211 | fn scratch_decode_pinned_stream_once() { | 3163 | fn scratch_decode_pinned_stream_once() { |
| @@ -3217,46 +3169,6 @@ mod tests { | |||
| 3217 | } | 3169 | } |
| 3218 | } | 3170 | } |
| 3219 | 3171 | ||
| 3220 | - /// scratch: decode a pinned stream end to end and report where/why it | ||
| 3221 | - /// refuses, plus `non_last_ref_hits` progression. | ||
| 3222 | - #[test] | ||
| 3223 | - #[ignore] | ||
| 3224 | - fn scratch_decode_pinned_stream() { | ||
| 3225 | - let path = std::env::var("EC_AV1_PIN").expect("set EC_AV1_PIN to the .obu path"); | ||
| 3226 | - let stream = std::fs::read(&path).expect("read pinned stream"); | ||
| 3227 | - let before = decode::non_last_ref_hits(); | ||
| 3228 | - match decode_stream(&stream) { | ||
| 3229 | - Ok(frames) => eprintln!( | ||
| 3230 | - "OK: {} frames, non_last_ref_hits {} -> {}", | ||
| 3231 | - frames.len(), | ||
| 3232 | - before, | ||
| 3233 | - decode::non_last_ref_hits() | ||
| 3234 | - ), | ||
| 3235 | - Err(e) => eprintln!( | ||
| 3236 | - "ERR: {} (non_last_ref_hits {} -> {})", | ||
| 3237 | - e, | ||
| 3238 | - before, | ||
| 3239 | - decode::non_last_ref_hits() | ||
| 3240 | - ), | ||
| 3241 | - } | ||
| 3242 | - // Truncate at each Frame OBU boundary and re-decode from scratch, to | ||
| 3243 | - // see which frame index first fails. | ||
| 3244 | - let mut p = Av1Parser::new(); | ||
| 3245 | - let mut pos = 0usize; | ||
| 3246 | - let mut frame_idx = 0; | ||
| 3247 | - while pos < stream.len() { | ||
| 3248 | - let obu = p.parse_obu(&stream[pos..]).expect("parse"); | ||
| 3249 | - pos += obu.total_size; | ||
| 3250 | - if matches!(obu.kind, ObuKind::Frame(_, _)) { | ||
| 3251 | - match decode_stream(&stream[..pos]) { | ||
| 3252 | - Ok(_) => eprintln!("through frame {frame_idx}: OK"), | ||
| 3253 | - Err(e) => eprintln!("through frame {frame_idx}: ERR {e}"), | ||
| 3254 | - } | ||
| 3255 | - frame_idx += 1; | ||
| 3256 | - } | ||
| 3257 | - } | ||
| 3258 | - } | ||
| 3259 | - | ||
| 3260 | /// scratch: isolate a pinned mismatching stream's first divergent pixel. | 3172 | /// scratch: isolate a pinned mismatching stream's first divergent pixel. |
| 3261 | #[test] | 3173 | #[test] |
| 3262 | #[ignore] | 3174 | #[ignore] |
| @@ -3338,109 +3250,6 @@ mod tests { | |||
| 3338 | } | 3250 | } |
| 3339 | } | 3251 | } |
| 3340 | 3252 | ||
| 3341 | - /// lane-av1blend r4 scratch: decodes the pinned `av1blend-r1-mismatch.obu` | ||
| 3342 | - /// (seed 45) with `EC_AV1_COMPIDX_DUMP` set, to compare the pre-tile-decode | ||
| 3343 | - /// `compound_idx` CDF state of every frame against an instrumented | ||
| 3344 | - /// aomdec's own `COMPIDX_PRE` dump. Errors out at decode-order frame 3 | ||
| 3345 | - /// (the still-masked compound path) -- that is expected, the dump lines | ||
| 3346 | - /// before the error are what this test is for. Remove with the rest of | ||
| 3347 | - /// the r1-r4 scaffolding. | ||
| 3348 | - #[test] | ||
| 3349 | - #[ignore] | ||
| 3350 | - fn scratch_dump_compound_idx_cdf_state() { | ||
| 3351 | - let path = concat!( | ||
| 3352 | - env!("CARGO_MANIFEST_DIR"), | ||
| 3353 | - "/../../fixtures/av1blend-r1-mismatch.obu" | ||
| 3354 | - ); | ||
| 3355 | - let stream = std::fs::read(path).expect("reading pinned stream"); | ||
| 3356 | - let _ = decode_stream(&stream); | ||
| 3357 | - } | ||
| 3358 | - | ||
| 3359 | - /// lane-av1blend r2 scratch: sweep every seed of the compound_references | ||
| 3360 | - /// recipe (with the plain-average blend UNMASKED locally) looking for a | ||
| 3361 | - /// pixel mismatch, dumping the first one found to `EC_AV1_GATE_DUMP`. | ||
| 3362 | - /// Remove with the rest of the r1/r2 scaffolding. | ||
| 3363 | - #[test] | ||
| 3364 | - #[ignore] | ||
| 3365 | - fn scratch_sweep_compound_mismatch() { | ||
| 3366 | - if !have_ffmpeg() || !have_aomenc() { | ||
| 3367 | - eprintln!("SKIP: missing ffmpeg/aomenc"); | ||
| 3368 | - return; | ||
| 3369 | - } | ||
| 3370 | - let (width, height, frame_count) = (64usize, 64usize, 24usize); | ||
| 3371 | - for seed in 42..82u32 { | ||
| 3372 | - let duration = frame_count as f64 / 25.0; | ||
| 3373 | - let source = | ||
| 3374 | - format!("gradients=size={width}x{height}:seed={seed}:duration={duration}:rate=25"); | ||
| 3375 | - let y4m = Command::new("ffmpeg") | ||
| 3376 | - .args([ | ||
| 3377 | - "-v", "error", "-f", "lavfi", "-i", &source, "-pix_fmt", "yuv420p", "-f", | ||
| 3378 | - "yuv4mpegpipe", "-", | ||
| 3379 | - ]) | ||
| 3380 | - .stdin(Stdio::null()) | ||
| 3381 | - .stdout(Stdio::piped()) | ||
| 3382 | - .stderr(Stdio::piped()) | ||
| 3383 | - .output() | ||
| 3384 | - .expect("ffmpeg failed to run"); | ||
| 3385 | - assert!(y4m.status.success()); | ||
| 3386 | - let args: Vec<&str> = vec![ | ||
| 3387 | - "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=45", "--cpu-used=0", | ||
| 3388 | - "--kf-max-dist=1000", "--threads=1", "--row-mt=0", "--auto-alt-ref=1", | ||
| 3389 | - "--lag-in-frames=16", "--enable-fwd-kf=0", "--enable-order-hint=1", | ||
| 3390 | - "--enable-warped-motion=0", "--enable-obmc=0", "--enable-masked-comp=0", | ||
| 3391 | - "--enable-interintra-comp=0", "--enable-onesided-comp=0", | ||
| 3392 | - "--enable-interintra-wedge=0", "--enable-smooth-interintra=0", | ||
| 3393 | - "--enable-rect-partitions=0", "--enable-ab-partitions=0", | ||
| 3394 | - "--enable-1to4-partitions=0", "--enable-filter-intra=0", | ||
| 3395 | - "--enable-smooth-intra=0", "--enable-paeth-intra=0", | ||
| 3396 | - "--enable-directional-intra=0", "--enable-angle-delta=0", | ||
| 3397 | - "--enable-tx-size-search=0", "--enable-cdef=0", "--enable-restoration=0", | ||
| 3398 | - "--max-partition-size=32", "--min-partition-size=32", "--enable-palette=0", | ||
| 3399 | - "--enable-intrabc=0", "--enable-cfl-intra=0", "--enable-ref-frame-mvs=0", | ||
| 3400 | - "--obu", "-o", "-", "-", | ||
| 3401 | - ]; | ||
| 3402 | - let mut child = Command::new(aomenc_path()) | ||
| 3403 | - .args(&args) | ||
| 3404 | - .stdin(Stdio::piped()) | ||
| 3405 | - .stdout(Stdio::piped()) | ||
| 3406 | - .stderr(Stdio::piped()) | ||
| 3407 | - .spawn() | ||
| 3408 | - .expect("aomenc failed to start"); | ||
| 3409 | - child | ||
| 3410 | - .stdin | ||
| 3411 | - .take() | ||
| 3412 | - .expect("aomenc stdin") | ||
| 3413 | - .write_all(&y4m.stdout) | ||
| 3414 | - .expect("writing y4m to aomenc"); | ||
| 3415 | - let out = child.wait_with_output().expect("aomenc failed to run"); | ||
| 3416 | - assert!(out.status.success()); | ||
| 3417 | - let stream = out.stdout; | ||
| 3418 | - let frames = match decode_stream(&stream) { | ||
| 3419 | - Err(_) => continue, | ||
| 3420 | - Ok(frames) => frames, | ||
| 3421 | - }; | ||
| 3422 | - if frames.len() != frame_count { | ||
| 3423 | - continue; | ||
| 3424 | - } | ||
| 3425 | - let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); | ||
| 3426 | - let mismatched = frames | ||
| 3427 | - .iter() | ||
| 3428 | - .zip(&ffmpeg_frames) | ||
| 3429 | - .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | ||
| 3430 | - if mismatched { | ||
| 3431 | - eprintln!("MISMATCH seed {seed}"); | ||
| 3432 | - if let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { | ||
| 3433 | - std::fs::write(&path, &stream).expect("writing pinned stream"); | ||
| 3434 | - eprintln!("wrote {path}"); | ||
| 3435 | - } | ||
| 3436 | - return; | ||
| 3437 | - } else { | ||
| 3438 | - eprintln!("seed {seed}: bit-exact"); | ||
| 3439 | - } | ||
| 3440 | - } | ||
| 3441 | - eprintln!("no mismatch found in sweep"); | ||
| 3442 | - } | ||
| 3443 | - | ||
| 3444 | /// Final round of the TX4/tx-class lane's own gate: `--min-partition-size=8 | 3253 | /// Final round of the TX4/tx-class lane's own gate: `--min-partition-size=8 |
| 3445 | /// --max-partition-size=8` pins every leaf to exactly 8x8 (spec | 3254 | /// --max-partition-size=8` pins every leaf to exactly 8x8 (spec |
| 3446 | /// 5.11.4's own boundary carve-out aside, which a multiple-of-8 frame | 3255 | /// 5.11.4's own boundary carve-out aside, which a multiple-of-8 frame |