forge
Explore
Log in

Don't you dare go Hollow

Remove bisect scratch instrumentation (SREF/COMPIDX/COMPOUND_DEBUG/r17 dump)

Browse files at this commit

d6ab49e877c98f4b576cd677a084aeece5f8e38cAhmet Kaan GümüşParent: a3b0b8a
  • chore
    • remove bisect scratch instrumentation (SREF/COMPIDX/COMPOUND_DEBUG/r17 dump)
Show full message
chore(av1): remove bisect scratch instrumentation (SREF/COMPIDX/COMPOUND_DEBUG/r17 dump)

Strips the env-gated dump machinery (EC_AV1_SREF_DUMP, EC_AV1_COMPIDX_DUMP,
EC_AV1_COMPOUND_DEBUG, BITPOS_BLK_START, IFILTER_RS prints) and the r17_dump
frame-counter/PREFILT/POSTFILT scaffolding from decode.rs/stream.rs, plus the
three scratch #[ignore] tests that depended on it in stream.rs
(scratch_decode_pinned_stream, scratch_dump_compound_idx_cdf_state,
scratch_sweep_compound_mismatch). Keeps scratch_isolate_pinned_mismatch and
scratch_decode_pinned_stream_once as generic pin-repro tools, GATE_COUNTER_LOCK,
the hardened cdf gate, pin fixtures, tile.rs's own EC_RNG trace, and the
comp_group_idx==1 wedge/diffwtd refusal untouched.
crates/ec-av1/src/decode.rsmodified+10 -161
@@ -2495,33 +2495,6 @@ fn cdef_filter_block(
24952495 ///
24962496 /// Ported from libaom's `av1/common/av1_loopfilter.c` (edge/level decision)
24972497 /// 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-
25252498 fn apply_deblock(
25262499 y: &mut PlaneBuf,
25272500 u: &mut PlaneBuf,
@@ -3712,21 +3685,9 @@ fn resolve_interp_filter(
37123685 // `h_kind`/`v_kind` argument order, which is why this function returns
37133686 // `(h, v, ..)` but reads `dir0` (`v`) before `dir1` (`h`).
37143687 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- }
37213688 let sym0 = dec.symbol(&mut cdfs.switchable_interp[ctx0]) as u8;
37223689 let sym1 = if enable_dual_filter {
37233690 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- }
37303691 dec.symbol(&mut cdfs.switchable_interp[ctx1]) as u8
37313692 } else {
37323693 sym0
@@ -4340,14 +4301,6 @@ fn decode_inter_block(
43404301 let (cpx, cpy) = (px / 2, py / 2);
43414302 let chroma_side = side / 2;
43424303
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- }
43514304 let skip_mode_ctx =
43524305 usize::from(neighbours.above_skip_mode[c]) + usize::from(neighbours.left_skip_mode[r]);
43534306 let skip_mode = skip_mode_present && dec.symbol(&mut cdfs.skip_mode[skip_mode_ctx]) == 1;
@@ -4536,8 +4489,8 @@ fn decode_inter_block(
45364489 // (av1_dist_wtd_convolve_2d_c, convolve.c:402-415) for every
45374490 // input, and a whole-pel zero-MV compound block (mv0=mv1=(0,0),
45384491 // the common case a lag-in-frames GOP's hidden altref frames
4539- // hit) reproduces aomdec's own pre-deblock `EC_AV1_PREFILT_DUMP`
4540- // byte-for-byte for several consecutive frames.
4492+ // hit) reproduces aomdec's own pre-deblock dump byte-for-byte
4493+ // for several consecutive frames.
45414494 //
45424495 // The real defect a live gate run isolated (seed 49,
45434496 // `fixtures/av1blend-r1-mismatch.obu`): decode-order frame 0
@@ -4599,15 +4552,15 @@ fn decode_inter_block(
45994552 // synced `EC_TOK`/`EC_PART` trace from the instrumented aomdec
46004553 // build (`/tmp/libaom-src/build/decoder-debug/aomdec`) on
46014554 // `fixtures/av1blend-r1-mismatch.obu` (seed 45 now, not seed 49)
4602- // -- the pre-deblock `EC_AV1_PREFILT_DUMP` frame-index alignment
4603- // between this crate and that aomdec build is NOT 1:1 on this
4604- // fixture (23 dumps here vs 24 there), so calibrate that first.
4555+ // -- the pre-deblock dump frame-index alignment between this
4556+ // crate and that aomdec build is NOT 1:1 on this fixture (23
4557+ // dumps here vs 24 there), so calibrate that first.
46054558 // r3 (this round): pre-deblock buffers were bisected byte-for-byte
4606- // against an instrumented aomdec build (EC_AV1_PREFILT_DUMP,
4607- // frame-index alignment recalibrated via content-hash matching
4608- // rather than the raw dump count -- the keyframe never calls this
4609- // crate's own `r17_dump` at all, since only `decode_inter_frame_
4610- // tile` does, which is the whole "23 vs 24" gap, not a real bug).
4559+ // against an instrumented aomdec build (frame-index alignment
4560+ // recalibrated via content-hash matching rather than the raw
4561+ // dump count -- the keyframe never calls a pre-deblock dump at
4562+ // all, since only `decode_inter_frame_tile` does, which is the
4563+ // whole "23 vs 24" gap, not a real bug).
46114564 // Decode-order frame 3 (`fixtures/av1blend-r1-mismatch.obu`,
46124565 // seed 45) is still the first divergence: PRE-deblock differs
46134566 // from aomdec's own pre-deblock dump by up to 1, on ~20% of
@@ -4726,25 +4679,7 @@ fn decode_inter_block(
47264679 ref_order_hints[(ref0 - LAST_FRAME) as usize],
47274680 ref_order_hints[(ref1 - LAST_FRAME) as usize],
47284681 );
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- }
47394682 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- }
47484683 if idx == 1 {
47494684 (8, 8, 1u8)
47504685 } else {
@@ -4767,28 +4702,6 @@ fn decode_inter_block(
47674702 // (lane-av1blend r5) from its old position ahead of those reads,
47684703 // which stole their bits for a Switchable-filter compound block
47694704 // 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- }
47924705 let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
47934706 dec,
47944707 cdfs,
@@ -4800,14 +4713,6 @@ fn decode_inter_block(
48004713 true,
48014714 );
48024715 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- }
48114716
48124717 let mut inter0_y = vec![0i32; side * side];
48134718 mc::predict_compound_intermediate(
@@ -4840,20 +4745,6 @@ fn decode_inter_block(
48404745 let mut pred_y = vec![0u8; side * side];
48414746 mc::combine_compound(&inter0_y, &inter1_y, fwd_offset, bck_offset, &mut pred_y);
48424747
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-
48574748 let mut inter0_u = vec![0i32; chroma_side * chroma_side];
48584749 mc::predict_compound_intermediate(
48594750 &pu0.data,
@@ -5128,20 +5019,6 @@ fn decode_inter_block(
51285019 } else {
51295020 [3, 3]
51305021 };
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- }
51455022 let (h_filter, v_filter, resolved_filter) = resolve_interp_filter(
51465023 dec,
51475024 cdfs,
@@ -5152,14 +5029,6 @@ fn decode_inter_block(
51525029 left_filter_ctx,
51535030 false,
51545031 );
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- }
51635032 block_filter = resolved_filter;
51645033 globalmv_for_lf = is_globalmv;
51655034 if std::env::var_os("EC_AV1_TRACE").is_some() {
@@ -5763,15 +5632,6 @@ fn decode_inter_block8(
57635632 let mut pred_y = vec![0u8; SIDE * SIDE];
57645633 mc::combine_compound(&inter0_y, &inter1_y, fwd_offset, bck_offset, &mut pred_y);
57655634
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-
57755635 let mut inter0_u = vec![0i32; CHROMA_SIDE * CHROMA_SIDE];
57765636 mc::predict_compound_intermediate(
57775637 &pu0.data,
@@ -6453,14 +6313,6 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
64536313 let scan4 = default_scan(TX4);
64546314
64556315 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- }
64646316 let mut dec = SymbolDecoder::new(data);
64656317 let mut neighbours = Neighbours::new(
64666318 cols as usize * 2,
@@ -6737,10 +6589,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs(
67376589 }
67386590 }
67396591
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);
67426592 apply_deblock(&mut y, &mut u, &mut v, loop_filter, &neighbours);
6743- r17_dump("EC_AV1_POSTFILT_DUMP", &y, &u, &v, r17_idx);
67446593 apply_cdef(&mut y, &mut u, &mut v, cdef, &neighbours);
67456594
67466595 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>> {
7474 let mut cdf_slots: [Option<Cdfs>; NUM_REF_FRAMES] = std::array::from_fn(|_| None);
7575
7676 let mut pos = 0usize;
77- let mut decode_idx = 0u32;
7877 while pos < data.len() {
7978 let obu = parser.parse_obu(&data[pos..])?;
8079 let obu_offset = pos;
@@ -115,12 +114,6 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
115114 picture
116115 };
117116 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- }
124117 continue;
125118 }
126119 let ObuKind::Frame(header, tiles) = obu.kind else {
@@ -266,19 +259,6 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
266259 ec_av1_syntax::InterpolationFilter::Switchable => None,
267260 fixed => Some(crate::mc::InterpFilterKind::from_header(fixed)),
268261 };
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-
282262 // Spec 7.20 `load_cdfs`: a frame naming a `primary_ref_frame` resumes
283263 // from that reference slot's saved CDF state instead of the spec 8.4
284264 // defaults `decode_key/inter_frame_tile_with_cdfs`'s `None` case
@@ -307,19 +287,6 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
307287 let ref_order_hints: [u32; 7] =
308288 std::array::from_fn(|i| order_hint_slots[header.ref_frame_idx[i] as usize]);
309289
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-
323290 let (picture, end_cdfs, motion_field) = if header.frame_type == FrameType::Key {
324291 let (picture, end_cdfs) = decode_key_frame_tile_with_cdfs(
325292 tile_bytes,
@@ -466,18 +433,6 @@ pub fn decode_stream(data: &[u8]) -> Result<Vec<Picture>> {
466433 picture
467434 };
468435 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- );
481436 }
482437 }
483438 Ok(pictures)
@@ -3201,11 +3156,8 @@ mod tests {
32013156 a_real_aomenc_temporal_mv_gate(42, 40);
32023157 }
32033158
3204- /// r17 bisect scratch: decode a pinned stream exactly once, so
3205- /// `decode::r17_dump`'s frame index (a process-wide counter) lines up
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.
3159+ /// bisect scratch: decode a pinned stream exactly once -- generic
3160+ /// pin-repro tool, kept for manual use.
32093161 #[test]
32103162 #[ignore]
32113163 fn scratch_decode_pinned_stream_once() {
@@ -3217,46 +3169,6 @@ mod tests {
32173169 }
32183170 }
32193171
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-
32603172 /// scratch: isolate a pinned mismatching stream's first divergent pixel.
32613173 #[test]
32623174 #[ignore]
@@ -3338,109 +3250,6 @@ mod tests {
33383250 }
33393251 }
33403252
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-
34443253 /// Final round of the TX4/tx-class lane's own gate: `--min-partition-size=8
34453254 /// --max-partition-size=8` pins every leaf to exactly 8x8 (spec
34463255 /// 5.11.4's own boundary carve-out aside, which a multiple-of-8 frame