| 1 | #[path = "it/ivf.rs"] |
| 2 | mod ivf; |
| 3 | use ec_vp9::decode::Decoder; |
| 4 | #[test] |
| 5 | fn sweep() { |
| 6 | std::panic::set_hook(Box::new(|_| {})); |
| 7 | let mut p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); |
| 8 | p.pop(); p.pop(); |
| 9 | p = p.join("fixtures/vp9/lossless-64.ivf"); |
| 10 | let bytes = std::fs::read(&p).unwrap(); |
| 11 | let (_, w, h, frames) = ivf::parse_ivf(&bytes); |
| 12 | let refout = std::process::Command::new("ffmpeg") |
| 13 | .args(["-v","error","-i", p.to_str().unwrap(), "-frames:v","1","-f","rawvideo","-pix_fmt","yuv420p","-"]) |
| 14 | .output().unwrap().stdout; |
| 15 | let ylen = w as usize * h as usize; |
| 16 | let mut best = (0usize, 0usize); |
| 17 | for t in (100..260).step_by(1) { |
| 18 | let _tail = ec_vp9::knobs::set_force_tail(Some(t)); |
| 19 | let mut d = Decoder::new(); |
| 20 | let r = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| d.decode(&frames[0].data))); |
| 21 | let Ok(Ok(Some(pic))) = r else { continue }; |
| 22 | let m = (0..ylen).filter(|&i| pic.y[i] as u8 == refout[i]).count(); |
| 23 | if m > best.0 { best = (m, t); } |
| 24 | } |
| 25 | println!("BEST matches {} at tail_start {}", best.0, best.1); |
| 26 | } |