U3: delete obmc_skip_chroma_tests and tx4x8_table_tests (listed), and tests/real_library.rs (needs the private library, not in the keep list)
Browse files at this commitefec3ce517cc6e999853d8a54272b9379effbbd1Parent: 61fd2af4 changed files +0 -408
- crates/ec-av1/src/decode/mod.rs +0 -5
- crates/ec-av1/src/decode/obmc_skip_chroma_tests.rs +0 -27
- crates/ec-av1/src/decode/tx4x8_table_tests.rs +0 -89
- crates/ec-av1/tests/real_library.rs +0 -287
crates/ec-av1/src/decode/mod.rsmodified+0 -5
| @@ -100,9 +100,6 @@ pub use key_tile::*; | ||
| 100 | 100 | mod inter_ctx; |
| 101 | 101 | pub(crate) use inter_ctx::*; |
| 102 | 102 | |
| 103 | -#[cfg(test)] | |
| 104 | -mod obmc_skip_chroma_tests; | |
| 105 | - | |
| 106 | 103 | mod sub8_inter; |
| 107 | 104 | pub(crate) use frame_tile::*; |
| 108 | 105 | use sub8_inter::*; |
| @@ -3793,5 +3790,3 @@ pub(crate) fn decode_key_frame_tile( | ||
| 3793 | 3790 | #[cfg(test)] |
| 3794 | 3791 | mod tests; |
| 3795 | 3792 | |
| 3796 | -#[cfg(test)] | |
| 3797 | -mod tx4x8_table_tests; |
crates/ec-av1/src/decode/obmc_skip_chroma_tests.rsdeleted+0 -27
| @@ -1,27 +0,0 @@ | ||
| 1 | -use super::obmc_skip_chroma_above; | |
| 2 | - | |
| 3 | -/// lane-av1-llpred2: the above-chroma skip keys off the PLANE block | |
| 4 | -/// under the frame's own ss pair. At 4:2:0 a 16x8/8x16 rect strip's | |
| 5 | -/// plane block is 8x4/4x8 and MUST still skip (the old `chroma_side` | |
| 6 | -/// ratio read ss=(1,0) off a 16x8 strip and made it blend); at 4:4:4 | |
| 7 | -/// the plane block is the luma block, so only true 4-wide/high shapes | |
| 8 | -/// skip and the shift never leaves `usize` range (the old ratio's | |
| 9 | -/// `trailing_zeros(0)` = 64 panicked a debug build). | |
| 10 | -#[test] | |
| 11 | -fn rect_strips_skip_above_chroma_at_420_and_shift_never_overflows() { | |
| 12 | - // 4:2:0 (ss 1,1): 8x8 -> 4x4, 16x8 -> 8x4, 8x16 -> 4x8 all skip. | |
| 13 | - assert!(obmc_skip_chroma_above(8, 8, 1, 1)); | |
| 14 | - assert!(obmc_skip_chroma_above(16, 8, 1, 1)); | |
| 15 | - assert!(obmc_skip_chroma_above(8, 16, 1, 1)); | |
| 16 | - // ... larger plane blocks blend, exactly libaom's own list. | |
| 17 | - assert!(!obmc_skip_chroma_above(16, 16, 1, 1)); | |
| 18 | - assert!(!obmc_skip_chroma_above(32, 16, 1, 1)); | |
| 19 | - assert!(!obmc_skip_chroma_above(16, 32, 1, 1)); | |
| 20 | - // 4:4:4 (ss 0,0): the plane block is the luma block itself. | |
| 21 | - assert!(obmc_skip_chroma_above(4, 4, 0, 0)); | |
| 22 | - assert!(obmc_skip_chroma_above(8, 4, 0, 0)); | |
| 23 | - assert!(obmc_skip_chroma_above(4, 8, 0, 0)); | |
| 24 | - assert!(!obmc_skip_chroma_above(8, 8, 0, 0)); | |
| 25 | - assert!(!obmc_skip_chroma_above(16, 8, 0, 0)); | |
| 26 | - assert!(!obmc_skip_chroma_above(8, 16, 0, 0)); | |
| 27 | -} |
crates/ec-av1/src/decode/tx4x8_table_tests.rsdeleted+0 -89
| @@ -1,89 +0,0 @@ | ||
| 1 | -use super::*; | |
| 2 | - | |
| 3 | -/// Asymmetric gate on the two new scan tables (class | |
| 4 | -/// `reference-layout-not-spec`): a transposed pair of tables passes any | |
| 5 | -/// "is a permutation" check, so this pins the pair AGAINST each other -- | |
| 6 | -/// `SCAN_8X4[k]` must be `SCAN_4X8[k]` reflected across the diagonal, and | |
| 7 | -/// both must be bijections of `0..32` in our own row-major indexing. | |
| 8 | -#[test] | |
| 9 | -fn the_rect_4x8_scans_are_each_other_transposed() { | |
| 10 | - let mut seen_a = [false; 32]; | |
| 11 | - let mut seen_b = [false; 32]; | |
| 12 | - for k in 0..32usize { | |
| 13 | - let a = SCAN_4X8[k] as usize; | |
| 14 | - let b = SCAN_8X4[k] as usize; | |
| 15 | - assert!(!seen_a[a] && !seen_b[b], "scan position {k} repeats"); | |
| 16 | - seen_a[a] = true; | |
| 17 | - seen_b[b] = true; | |
| 18 | - let (row, col) = (a / 4, a % 4); | |
| 19 | - assert_eq!( | |
| 20 | - b, | |
| 21 | - col * 8 + row, | |
| 22 | - "SCAN_8X4[{k}] is not SCAN_4X8[{k}] transposed" | |
| 23 | - ); | |
| 24 | - } | |
| 25 | - assert!(seen_a.iter().all(|&s| s) && seen_b.iter().all(|&s| s)); | |
| 26 | -} | |
| 27 | - | |
| 28 | -/// `mrow_scan_4x8`/`mcol_scan_4x8`/`mrow_scan_8x4`/`mcol_scan_8x4` | |
| 29 | -/// (libaom `scan.c`), converted out of their column-major encoding by | |
| 30 | -/// `(p % h) * w + p / h` -- the head of each, pinned so the rect | |
| 31 | -/// `V_DCT`/`H_DCT` walk cannot silently transpose. | |
| 32 | -#[test] | |
| 33 | -fn the_rect_class1_scans_match_libaom() { | |
| 34 | - assert_eq!( | |
| 35 | - class_scan_table_wh(4, 8, TxClass::Vert), | |
| 36 | - (0..32u16).collect::<Vec<_>>() | |
| 37 | - ); | |
| 38 | - assert_eq!( | |
| 39 | - &class_scan_table_wh(4, 8, TxClass::Horiz)[..8], | |
| 40 | - &[0u16, 4, 8, 12, 16, 20, 24, 28] | |
| 41 | - ); | |
| 42 | - assert_eq!( | |
| 43 | - class_scan_table_wh(8, 4, TxClass::Vert), | |
| 44 | - (0..32u16).collect::<Vec<_>>() | |
| 45 | - ); | |
| 46 | - assert_eq!( | |
| 47 | - &class_scan_table_wh(8, 4, TxClass::Horiz)[..8], | |
| 48 | - &[0u16, 8, 16, 24, 1, 9, 17, 25] | |
| 49 | - ); | |
| 50 | -} | |
| 51 | - | |
| 52 | -/// The 32-position `eob_pt` alphabet: six symbols (one more than the | |
| 53 | -/// 16-position table, one fewer than the 64-position one), strictly | |
| 54 | -/// increasing, terminated at 32768 with the adaptation counter after it. | |
| 55 | -#[test] | |
| 56 | -fn the_32_position_eob_tables_are_well_formed() { | |
| 57 | - for table in [ | |
| 58 | - &cdf::EOB_PT_32_LUMA_Q0, | |
| 59 | - &cdf::EOB_PT_32_LUMA_Q1, | |
| 60 | - &cdf::EOB_PT_32_LUMA, | |
| 61 | - &cdf::EOB_PT_32_LUMA_Q3, | |
| 62 | - &cdf::EOB_PT_32_LUMA_CLASS1_Q0, | |
| 63 | - &cdf::EOB_PT_32_LUMA_CLASS1_Q1, | |
| 64 | - &cdf::EOB_PT_32_LUMA_CLASS1, | |
| 65 | - &cdf::EOB_PT_32_LUMA_CLASS1_Q3, | |
| 66 | - ] { | |
| 67 | - assert_eq!(table.len(), 7); | |
| 68 | - assert_eq!(table[5], 32768); | |
| 69 | - assert_eq!(table[6], 0); | |
| 70 | - for w in table[..6].windows(2) { | |
| 71 | - assert!(w[0] < w[1], "{table:?} is not increasing"); | |
| 72 | - } | |
| 73 | - } | |
| 74 | -} | |
| 75 | - | |
| 76 | -/// `Reach::of_rect` must read libaom's own `has_tr_4x8`/`has_tr_8x4` | |
| 77 | -/// rows, not the 32x16 pair the two existing rect strips use: the two | |
| 78 | -/// shapes disagree at a position inside the superblock, which is what | |
| 79 | -/// makes this an asymmetric check rather than a tautology. | |
| 80 | -#[test] | |
| 81 | -fn the_sub8_rect_reach_tables_are_shape_specific() { | |
| 82 | - let fctx = &crate::decode::FrameCtx::new(); | |
| 83 | - let a = Reach::of_rect(4, 8, 4, 8, 64, 64, fctx); | |
| 84 | - let b = Reach::of_rect(8, 4, 8, 4, 64, 64, fctx); | |
| 85 | - assert!( | |
| 86 | - a.above_right != b.above_right || a.below_left != b.below_left, | |
| 87 | - "4x8 and 8x4 reach identically at mirrored positions -- one table is unused" | |
| 88 | - ); | |
| 89 | -} |
crates/ec-av1/tests/real_library.rsdeleted+0 -287
| @@ -1,287 +0,0 @@ | ||
| 1 | -use std::io::Read; | |
| 2 | -use std::path::{Path, PathBuf}; | |
| 3 | -use std::process::{Child, ChildStdout, Stdio}; | |
| 4 | - | |
| 5 | -use ec_av1::encode::Picture; | |
| 6 | - | |
| 7 | -const FRAMES: usize = 300; | |
| 8 | - | |
| 9 | -const IN_SCOPE_PIX_FMTS: [&str; 2] = ["yuv420p", "yuv420p10le"]; | |
| 10 | - | |
| 11 | -fn scratch(tag: &str) -> PathBuf { | |
| 12 | - let base = std::env::var_os("TMPDIR").map_or_else(std::env::temp_dir, PathBuf::from); | |
| 13 | - let dir = base.join(format!("ec-av1-{tag}-{}", std::process::id())); | |
| 14 | - std::fs::create_dir_all(&dir).expect("scratch dir"); | |
| 15 | - dir | |
| 16 | -} | |
| 17 | - | |
| 18 | -struct Entry { | |
| 19 | - path: PathBuf, | |
| 20 | - container: String, | |
| 21 | - width: String, | |
| 22 | - height: String, | |
| 23 | - pix_fmt: String, | |
| 24 | -} | |
| 25 | - | |
| 26 | -fn open_entries() -> Vec<Entry> { | |
| 27 | - vec![Entry { | |
| 28 | - path: ec_testkit::fixture("derived/sintel720-svtav1.ivf"), | |
| 29 | - container: "ivf".to_string(), | |
| 30 | - width: "1280".to_string(), | |
| 31 | - height: "720".to_string(), | |
| 32 | - pix_fmt: "yuv420p".to_string(), | |
| 33 | - }] | |
| 34 | -} | |
| 35 | - | |
| 36 | -fn frame_bytes(pic: &Picture, bps: usize) -> Vec<u8> { | |
| 37 | - let mut out = Vec::with_capacity((pic.y.len() + pic.u.len() + pic.v.len()) * bps); | |
| 38 | - for plane in [&pic.y, &pic.u, &pic.v] { | |
| 39 | - for &s in plane.iter() { | |
| 40 | - if bps == 1 { | |
| 41 | - out.push(s as u8); | |
| 42 | - } else { | |
| 43 | - out.extend_from_slice(&s.to_le_bytes()); | |
| 44 | - } | |
| 45 | - } | |
| 46 | - } | |
| 47 | - out | |
| 48 | -} | |
| 49 | - | |
| 50 | -fn locate(offset: usize, bps: usize, pic: &Picture) -> (&'static str, usize, usize) { | |
| 51 | - let s = offset / bps; | |
| 52 | - let (w, cw) = (pic.width, pic.u.len() / pic.height.div_ceil(2).max(1)); | |
| 53 | - let luma = pic.y.len(); | |
| 54 | - if s < luma { | |
| 55 | - ("Y", s % w, s / w) | |
| 56 | - } else if s < luma + pic.u.len() { | |
| 57 | - let c = s - luma; | |
| 58 | - ("U", c % cw.max(1), c / cw.max(1)) | |
| 59 | - } else { | |
| 60 | - let c = s - luma - pic.u.len(); | |
| 61 | - ("V", c % cw.max(1), c / cw.max(1)) | |
| 62 | - } | |
| 63 | -} | |
| 64 | - | |
| 65 | -struct Sweep { | |
| 66 | - out: ChildStdout, | |
| 67 | - child: Child, | |
| 68 | - open: bool, | |
| 69 | - compared: usize, | |
| 70 | - differing_frames: usize, | |
| 71 | - first_diff: Option<String>, | |
| 72 | - oracle_short: bool, | |
| 73 | - index: usize, | |
| 74 | - frame_len: usize, | |
| 75 | - bps: usize, | |
| 76 | - max_sample: u16, | |
| 77 | -} | |
| 78 | - | |
| 79 | -impl Sweep { | |
| 80 | - fn take(&mut self, pic: &Picture) { | |
| 81 | - let index = self.index; | |
| 82 | - self.index += 1; | |
| 83 | - if !self.open || self.index > FRAMES { | |
| 84 | - return; | |
| 85 | - } | |
| 86 | - if let Some(&s) = pic.y.iter().chain(&pic.u).chain(&pic.v).max() | |
| 87 | - && s > self.max_sample | |
| 88 | - { | |
| 89 | - self.differing_frames += 1; | |
| 90 | - self.first_diff.get_or_insert(format!( | |
| 91 | - "frame {index}: sample {s} above the maximum {}", | |
| 92 | - self.max_sample | |
| 93 | - )); | |
| 94 | - } | |
| 95 | - let want = frame_bytes(pic, self.bps); | |
| 96 | - self.frame_len = want.len(); | |
| 97 | - let mut oracle = vec![0u8; want.len()]; | |
| 98 | - if self.out.read_exact(&mut oracle).is_err() { | |
| 99 | - self.open = false; | |
| 100 | - self.oracle_short = true; | |
| 101 | - return; | |
| 102 | - } | |
| 103 | - self.compared += 1; | |
| 104 | - if want != oracle { | |
| 105 | - self.differing_frames += 1; | |
| 106 | - if self.first_diff.is_none() { | |
| 107 | - let at = want | |
| 108 | - .iter() | |
| 109 | - .zip(&oracle) | |
| 110 | - .position(|(a, b)| a != b) | |
| 111 | - .unwrap_or(0); | |
| 112 | - let (plane, x, y) = locate(at, self.bps, pic); | |
| 113 | - self.first_diff = Some(format!("frame {index} plane {plane} x={x} y={y}")); | |
| 114 | - } | |
| 115 | - } | |
| 116 | - } | |
| 117 | - | |
| 118 | - fn finish(mut self) -> Sweep { | |
| 119 | - if self.open && self.frame_len > 0 { | |
| 120 | - let mut probe = vec![0u8; self.frame_len]; | |
| 121 | - if self.out.read_exact(&mut probe).is_ok() { | |
| 122 | - self.first_diff.get_or_insert(format!( | |
| 123 | - "decoder produced {} frames, ffmpeg produced more", | |
| 124 | - self.index | |
| 125 | - )); | |
| 126 | - self.differing_frames += 1; | |
| 127 | - } | |
| 128 | - } | |
| 129 | - let _ = self.child.kill(); | |
| 130 | - let _ = self.child.wait(); | |
| 131 | - self | |
| 132 | - } | |
| 133 | -} | |
| 134 | - | |
| 135 | -fn short_name(path: &Path) -> String { | |
| 136 | - path.file_name() | |
| 137 | - .map(|n| n.to_string_lossy().chars().take(38).collect()) | |
| 138 | - .unwrap_or_default() | |
| 139 | -} | |
| 140 | - | |
| 141 | -fn extract(src: &Path, dst: &Path) -> bool { | |
| 142 | - ec_testkit::ffmpeg() | |
| 143 | - .args(["-v", "error", "-y", "-i"]) | |
| 144 | - .arg(src) | |
| 145 | - .args([ | |
| 146 | - "-map", | |
| 147 | - "0:v:0", | |
| 148 | - "-c", | |
| 149 | - "copy", | |
| 150 | - "-frames:v", | |
| 151 | - &FRAMES.to_string(), | |
| 152 | - "-f", | |
| 153 | - "obu", | |
| 154 | - ]) | |
| 155 | - .arg(dst) | |
| 156 | - .status() | |
| 157 | - .is_ok_and(|s| s.success()) | |
| 158 | -} | |
| 159 | - | |
| 160 | -fn sweep_file(es: &Path, pix_fmt: &str, bit_depth: u32) -> Result<Sweep, String> { | |
| 161 | - let bps = if bit_depth > 8 { 2 } else { 1 }; | |
| 162 | - let mut child = ec_testkit::ffmpeg() | |
| 163 | - .args(["-v", "error", "-c:v", "libdav1d", "-i"]) | |
| 164 | - .arg(es) | |
| 165 | - .args([ | |
| 166 | - "-frames:v", | |
| 167 | - &FRAMES.to_string(), | |
| 168 | - "-f", | |
| 169 | - "rawvideo", | |
| 170 | - "-pix_fmt", | |
| 171 | - pix_fmt, | |
| 172 | - "-", | |
| 173 | - ]) | |
| 174 | - .stdout(Stdio::piped()) | |
| 175 | - .stderr(Stdio::null()) | |
| 176 | - .spawn() | |
| 177 | - .map_err(|e| e.to_string())?; | |
| 178 | - let out = child.stdout.take().expect("piped stdout"); | |
| 179 | - let mut sweep = Sweep { | |
| 180 | - out, | |
| 181 | - child, | |
| 182 | - open: true, | |
| 183 | - compared: 0, | |
| 184 | - differing_frames: 0, | |
| 185 | - first_diff: None, | |
| 186 | - oracle_short: false, | |
| 187 | - index: 0, | |
| 188 | - frame_len: 0, | |
| 189 | - bps, | |
| 190 | - max_sample: ((1u32 << bit_depth) - 1) as u16, | |
| 191 | - }; | |
| 192 | - let data = std::fs::read(es).map_err(|e| e.to_string())?; | |
| 193 | - let result = ec_av1::stream::decode_stream_with(&data, |pic, _decode_index, shown| { | |
| 194 | - if shown { | |
| 195 | - sweep.take(pic); | |
| 196 | - } | |
| 197 | - Ok(()) | |
| 198 | - }); | |
| 199 | - let sweep = sweep.finish(); | |
| 200 | - if let Err(e) = result { | |
| 201 | - return Err(format!("{e}")); | |
| 202 | - } | |
| 203 | - Ok(sweep) | |
| 204 | -} | |
| 205 | - | |
| 206 | -#[test] | |
| 207 | -fn sintel_av1_stream_matches_ffmpeg() { | |
| 208 | - let entries = open_entries(); | |
| 209 | - let dir = scratch("real-library-av1"); | |
| 210 | - let mut table = String::new(); | |
| 211 | - let mut decoded = 0usize; | |
| 212 | - let mut refused = 0usize; | |
| 213 | - let mut failures = Vec::new(); | |
| 214 | - | |
| 215 | - for entry in &entries { | |
| 216 | - let name = short_name(&entry.path); | |
| 217 | - let res = format!("{}x{}", entry.width, entry.height); | |
| 218 | - let bit_depth: u32 = if entry.pix_fmt == "yuv420p10le" { | |
| 219 | - 10 | |
| 220 | - } else { | |
| 221 | - 8 | |
| 222 | - }; | |
| 223 | - if !IN_SCOPE_PIX_FMTS.contains(&entry.pix_fmt.as_str()) { | |
| 224 | - refused += 1; | |
| 225 | - table.push_str(&format!( | |
| 226 | - "{name:<38} {:<12} {res:>10} {bit_depth:>2}-bit {:>4} refused: pixel format {} is outside 4:2:0 8/10-bit\n", | |
| 227 | - entry.container, "-", entry.pix_fmt | |
| 228 | - )); | |
| 229 | - continue; | |
| 230 | - } | |
| 231 | - let es = dir.join("stream.obu"); | |
| 232 | - if !extract(&entry.path, &es) { | |
| 233 | - failures.push(format!("{name}: extraction failed")); | |
| 234 | - table.push_str(&format!( | |
| 235 | - "{name:<38} {:<12} {res:>10} {bit_depth:>2}-bit {:>4} ERROR extraction\n", | |
| 236 | - entry.container, "-" | |
| 237 | - )); | |
| 238 | - continue; | |
| 239 | - } | |
| 240 | - match sweep_file(&es, &entry.pix_fmt, bit_depth) { | |
| 241 | - Ok(s) if s.differing_frames > 0 => { | |
| 242 | - failures.push(format!("{name}: {} frames differ", s.differing_frames)); | |
| 243 | - table.push_str(&format!( | |
| 244 | - "{name:<38} {:<12} {res:>10} {bit_depth:>2}-bit {:>4} MISMATCH {} of {} frames; first: {}\n", | |
| 245 | - entry.container, s.compared, s.differing_frames, s.compared, | |
| 246 | - s.first_diff.clone().unwrap_or_default() | |
| 247 | - )); | |
| 248 | - } | |
| 249 | - Ok(s) => { | |
| 250 | - decoded += 1; | |
| 251 | - table.push_str(&format!( | |
| 252 | - "{name:<38} {:<12} {res:>10} {bit_depth:>2}-bit {:>4} bit-exact{}\n", | |
| 253 | - entry.container, | |
| 254 | - s.compared, | |
| 255 | - if s.oracle_short { | |
| 256 | - " (ffmpeg stopped early)" | |
| 257 | - } else { | |
| 258 | - "" | |
| 259 | - } | |
| 260 | - )); | |
| 261 | - } | |
| 262 | - Err(e) if e.contains("unsupported") => { | |
| 263 | - refused += 1; | |
| 264 | - table.push_str(&format!( | |
| 265 | - "{name:<38} {:<12} {res:>10} {bit_depth:>2}-bit {:>4} refused: {e}\n", | |
| 266 | - entry.container, "-" | |
| 267 | - )); | |
| 268 | - } | |
| 269 | - Err(e) => { | |
| 270 | - failures.push(format!("{name}: {e}")); | |
| 271 | - table.push_str(&format!( | |
| 272 | - "{name:<38} {:<12} {res:>10} {bit_depth:>2}-bit {:>4} ERROR {e}\n", | |
| 273 | - entry.container, "-" | |
| 274 | - )); | |
| 275 | - } | |
| 276 | - } | |
| 277 | - let _ = std::fs::remove_file(&es); | |
| 278 | - } | |
| 279 | - let _ = std::fs::remove_dir_all(&dir); | |
| 280 | - eprintln!("{table}"); | |
| 281 | - eprintln!( | |
| 282 | - "real library av1: {decoded} bit-exact, {refused} refused by name, {} failed", | |
| 283 | - failures.len() | |
| 284 | - ); | |
| 285 | - assert!(failures.is_empty(), "{failures:#?}"); | |
| 286 | - assert!(decoded >= 1, "no real AV1 file was swept end to end"); | |
| 287 | -} |