U3: delete the census and source-scan tests (the_split_census_buckets..., pricer_error_census_by_block_class, the_probe_arms_the_gates_source; they read census tables and the gate source text), and probe::dims/gate_crop that only the source test used. Test-only, no output path. cargo check -p ec-av1 --all-targets clean
Browse files at this commitea929a7ff51a84d8c3dc3b1f4f777cdd1df223ffParent: 4c53cca3 changed files +0 -184
- crates/ec-av1/src/encode/more_tests.rs +0 -121
- crates/ec-av1/src/encode/tests.rs +0 -22
- crates/ec-av1/src/probe.rs +0 -41
crates/ec-av1/src/encode/more_tests.rsmodified+0 -121
| @@ -172,50 +172,6 @@ fn predicted_coeff_bits_track_the_tile_the_writer_wrote() { | ||
| 172 | 172 | ); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | -/// The census behind step (1) of the pricer lane: for every transform | |
| 176 | -/// block the writer really codes, what the search priced those levels at | |
| 177 | -/// against what the writer spent on them, split by table set and non-zero | |
| 178 | -/// count. One average hides the interesting part -- the classes the | |
| 179 | -/// estimate is systematically wrong about (all-zero blocks, the | |
| 180 | -/// one-coefficient blocks the inter search lives on) -- so the split is | |
| 181 | -/// printed and only the total is asserted on. | |
| 182 | -#[test] | |
| 183 | -fn pricer_error_census_by_block_class() { | |
| 184 | - let _knobs = crate::speed::knob_read(); | |
| 185 | - let fctx = &crate::decode::FrameCtx::for_encoder(); | |
| 186 | - let (width, height) = (256usize, 128usize); | |
| 187 | - let pictures: Vec<Picture> = (0..5) | |
| 188 | - .map(|i| panned_test_card(width, height, i * 2)) | |
| 189 | - .collect(); | |
| 190 | - crate::tile::pricer_census_on(); | |
| 191 | - let _ = encode_sequence_with_ctx(&pictures, 100, 0.5, fctx).unwrap(); | |
| 192 | - let rows = crate::tile::take_pricer_census(); | |
| 193 | - assert!(!rows.is_empty(), "the census saw no transform block"); | |
| 194 | - | |
| 195 | - println!("| set | nz | blocks | priced bits | written bits | error |"); | |
| 196 | - println!("|---|---|---|---|---|---|"); | |
| 197 | - let (mut priced_all, mut written_all) = (0.0, 0.0); | |
| 198 | - for ((set, bucket), (blocks, priced, written)) in &rows { | |
| 199 | - priced_all += priced; | |
| 200 | - written_all += written; | |
| 201 | - println!( | |
| 202 | - "| {set} | {} | {blocks} | {priced:.0} | {written:.0} | {:+.1}% |", | |
| 203 | - crate::tile::census_bucket_label(*bucket), | |
| 204 | - if *written > 0.0 { | |
| 205 | - (priced - written) / written * 100.0 | |
| 206 | - } else { | |
| 207 | - 0.0 | |
| 208 | - } | |
| 209 | - ); | |
| 210 | - } | |
| 211 | - println!( | |
| 212 | - "| ALL | | {} | {priced_all:.0} | {written_all:.0} | {:+.1}% |", | |
| 213 | - rows.values().map(|r| r.0).sum::<u64>(), | |
| 214 | - (priced_all - written_all) / written_all * 100.0 | |
| 215 | - ); | |
| 216 | - assert!(written_all > 0.0); | |
| 217 | -} | |
| 218 | - | |
| 219 | 175 | /// Low motion has to actually buy something: at least one inter frame of |
| 220 | 176 | /// a panning sequence has to cost fewer bytes than the key frame that |
| 221 | 177 | /// starts it, and the inter-block share it prints has to be non-zero -- |
| @@ -490,83 +446,6 @@ fn the_encoders_own_streams_are_byte_identical_to_their_pins() { | ||
| 490 | 446 | } |
| 491 | 447 | } |
| 492 | 448 | |
| 493 | -/// The probe arms the gate's source (lane-probe, class `instrument | |
| 494 | -/// disagrees with the gate`). `examples/enc_probe` built its own ffmpeg | |
| 495 | -/// command line and had no `-ss`, so it read film B from frame 0 -- a | |
| 496 | -/// black leader -- and coded 59 kB where the gate's own ladder point | |
| 497 | -/// coded 89 kB of the same title; every census taken through it was | |
| 498 | -/// probe-relative. Both now call [`crate::probe::source`]; this pins that | |
| 499 | -/// the shared loader honours the seek (arming the probe's way and the | |
| 500 | -/// gate's way gives byte-identical streams, and dropping the seek does | |
| 501 | -/// not), on a synthetic clip whose content moves over time. | |
| 502 | -#[test] | |
| 503 | -fn the_probe_arms_the_gates_source() { | |
| 504 | - let _knobs = crate::speed::knob_write(); | |
| 505 | - let dir = std::env::temp_dir().join(format!("ec-av1-probe-{}", std::process::id())); | |
| 506 | - std::fs::create_dir_all(&dir).unwrap(); | |
| 507 | - let clip = dir.join("testsrc2.y4m"); | |
| 508 | - // 384x202: neither side is a multiple of 128, so the gate's centre | |
| 509 | - // window is a real derivation and not the frame itself -- exactly the | |
| 510 | - // shape film B has (3840x1608, never 3840x2160). | |
| 511 | - let ok = ec_testkit::ffmpeg() | |
| 512 | - .args([ | |
| 513 | - "-v", | |
| 514 | - "error", | |
| 515 | - "-y", | |
| 516 | - "-f", | |
| 517 | - "lavfi", | |
| 518 | - "-i", | |
| 519 | - "testsrc2=size=384x202:rate=10", | |
| 520 | - ]) | |
| 521 | - .args(["-frames:v", "20", "-pix_fmt", "yuv420p"]) | |
| 522 | - .arg(&clip) | |
| 523 | - .status() | |
| 524 | - .expect("ffmpeg failed to run") | |
| 525 | - .success(); | |
| 526 | - assert!(ok, "ffmpeg could not write the synthetic clip"); | |
| 527 | - let path = clip.to_str().unwrap(); | |
| 528 | - | |
| 529 | - // The window: superblock-aligned, centred, even offsets. | |
| 530 | - let (vf, w, h) = crate::probe::gate_crop(path); | |
| 531 | - assert_eq!((vf.as_str(), w, h), ("crop=384:128:0:36", 384, 128)); | |
| 532 | - | |
| 533 | - let (seek, q) = ("00:00:01", 150u8); | |
| 534 | - let gate = clip_frames_vf(path, seek, &vf, w, h, 6); | |
| 535 | - let probe = crate::probe::source(path, seek, &vf, w, h, 6); | |
| 536 | - assert!( | |
| 537 | - gate.iter() | |
| 538 | - .zip(&probe) | |
| 539 | - .all(|(a, b)| a.y == b.y && a.u == b.u && a.v == b.v), | |
| 540 | - "the probe's source differs from the gate's at the same window" | |
| 541 | - ); | |
| 542 | - let bytes = |src: &[Picture]| { | |
| 543 | - encode_sequence_with_ctx(src, q, 0.5, &crate::decode::FrameCtx::for_encoder()) | |
| 544 | - .unwrap() | |
| 545 | - .stream | |
| 546 | - }; | |
| 547 | - assert_eq!( | |
| 548 | - bytes(&gate), | |
| 549 | - bytes(&probe), | |
| 550 | - "probe and gate code different bytes" | |
| 551 | - ); | |
| 552 | - // The two witnesses that both halves of the arming reach ffmpeg: the | |
| 553 | - // seek, and the crop's own offset (the film-B defect in miniature -- | |
| 554 | - // the probe was reading `crop=..:568` of a 1608-high frame). | |
| 555 | - let unseeked = crate::probe::source(path, "0", &vf, w, h, 6); | |
| 556 | - assert_ne!( | |
| 557 | - bytes(&gate), | |
| 558 | - bytes(&unseeked), | |
| 559 | - "seeked and unseeked arming coded the same bytes -- the seek is inert" | |
| 560 | - ); | |
| 561 | - let offset = crate::probe::source(path, seek, "crop=384:128:0:0", w, h, 6); | |
| 562 | - assert_ne!( | |
| 563 | - bytes(&gate), | |
| 564 | - bytes(&offset), | |
| 565 | - "centred and top-aligned windows coded the same bytes -- the crop is inert" | |
| 566 | - ); | |
| 567 | - std::fs::remove_dir_all(&dir).ok(); | |
| 568 | -} | |
| 569 | - | |
| 570 | 449 | /// lane-refs: THE FRAME FILTER REACHES THE PIXELS. `mc::predict` used to |
| 571 | 450 | /// hardwire the REGULAR kernel, so the encoder could not have coded a |
| 572 | 451 | /// SMOOTH or SHARP frame even if the header had said so -- the search, |
crates/ec-av1/src/encode/tests.rsmodified+0 -22
| @@ -1,26 +1,4 @@ | ||
| 1 | 1 | |
| 2 | -/// Every (site, frame type, block side) the census can be called with | |
| 3 | -/// lands in its own ten-counter bucket, inside the array (class | |
| 4 | -/// `enumerate-table-domain`: an off-by-one here would silently add two | |
| 5 | -/// sites' trials together). | |
| 6 | -#[test] | |
| 7 | -fn the_split_census_buckets_are_distinct_and_in_bounds() { | |
| 8 | - let mut seen = std::collections::BTreeSet::new(); | |
| 9 | - for site in 0..2 { | |
| 10 | - for key in [true, false] { | |
| 11 | - for side in [8usize, 16, 32, 64] { | |
| 12 | - let base = super::split_census_base(site, key, side); | |
| 13 | - assert!( | |
| 14 | - base + 10 <= super::SPLIT_CENSUS.len(), | |
| 15 | - "{site} {key} {side}" | |
| 16 | - ); | |
| 17 | - assert!(seen.insert(base), "{site} {key} {side} collides"); | |
| 18 | - } | |
| 19 | - } | |
| 20 | - } | |
| 21 | - assert_eq!(seen.len(), 16); | |
| 22 | -} | |
| 23 | - | |
| 24 | 2 | /// An [`crate::mvstack::MvStack`] with every context at zero and no |
| 25 | 3 | /// neighbours, for the pricer tests below to fill the one band each of |
| 26 | 4 | /// them is about. |
crates/ec-av1/src/probe.rsmodified+0 -41
| @@ -12,47 +12,6 @@ use crate::encode::Picture; | ||
| 12 | 12 | #[cfg(test)] |
| 13 | 13 | use std::process::Command; |
| 14 | 14 | |
| 15 | -/// The video stream's coded size, from ffprobe. | |
| 16 | -#[must_use] | |
| 17 | -pub fn dims(clip: &str) -> Option<(usize, usize)> { | |
| 18 | - let out = ec_testkit::ffprobe() | |
| 19 | - .args(["-v", "error", "-select_streams", "v:0"]) | |
| 20 | - .args(["-show_entries", "stream=width,height", "-of", "csv=p=0"]) | |
| 21 | - .arg(clip) | |
| 22 | - .output() | |
| 23 | - .ok()?; | |
| 24 | - let text = String::from_utf8_lossy(&out.stdout); | |
| 25 | - let mut f = text.trim().split(','); | |
| 26 | - Some(( | |
| 27 | - f.next()?.trim().parse().ok()?, | |
| 28 | - f.next()?.trim().parse().ok()?, | |
| 29 | - )) | |
| 30 | -} | |
| 31 | - | |
| 32 | -/// The native BD gate's window on `clip`: a whole number of 128-wide | |
| 33 | -/// superblocks, at most 1920x1024, out of the MIDDLE of the coded frame, with | |
| 34 | -/// even offsets for 4:2:0 -- as an ffmpeg `crop` filter plus its size. | |
| 35 | -/// | |
| 36 | -/// This lives here because the probe used to be handed the crop by hand, and | |
| 37 | -/// a hand-written `crop=1920:1024:960:568` (a 2160-high frame that film B, | |
| 38 | -/// coded 3840x1608, is not) put the instrument on different pixels than the | |
| 39 | -/// gate: 60 kB where the gate's own q=150 point coded 90 kB. | |
| 40 | -/// | |
| 41 | -/// # Panics | |
| 42 | -/// When ffprobe cannot read the size, or the frame is under one superblock. | |
| 43 | -#[must_use] | |
| 44 | -pub fn gate_crop(clip: &str) -> (String, usize, usize) { | |
| 45 | - let (nw, nh) = dims(clip).expect("ffprobe gave no size"); | |
| 46 | - let cw = nw.min(1920) / 128 * 128; | |
| 47 | - let ch = nh.min(1024) / 128 * 128; | |
| 48 | - assert!( | |
| 49 | - cw >= 128 && ch >= 128, | |
| 50 | - "{nw}x{nh} is smaller than a superblock" | |
| 51 | - ); | |
| 52 | - let (x, y) = (((nw - cw) / 2) & !1, ((nh - ch) / 2) & !1); | |
| 53 | - (format!("crop={cw}:{ch}:{x}:{y}"), cw, ch) | |
| 54 | -} | |
| 55 | - | |
| 56 | 15 | /// `frames` pictures of `clip` from `skip` through the filter chain `vf`, as |
| 57 | 16 | /// planar 8-bit 4:2:0 at `width`x`height` -- the BD gate's loader recipe. |
| 58 | 17 | /// |