wip(tiny): size-boundary sweep + trace probes for the silent-wrong-pixel defect
Browse files at this commitd931dba39a36ebc47584a5c16c4b7079714b64afParent: 6b635d62 changed files +165 -1
- crates/ec-av1/src/intra.rs +7 -1
- crates/ec-av1/src/stream.rs +158 -0
crates/ec-av1/src/intra.rsmodified+7 -1
| @@ -159,7 +159,13 @@ impl Edges { | ||
| 159 | 159 | row |
| 160 | 160 | }; |
| 161 | 161 | // Spec 7.11.2.2's no-neighbour fallback is `base = 1 << (BitDepth - 1)` |
| 162 | - // (128 at 8-bit): `base - 1` above, `base + 1` left, `base` corner. | |
| 162 | + // (128 at 8-bit): `base - 1` above, `base + 1` left, `base` corner | |
| 163 | + // (libaom `reconintra.c`'s own diagram: the shared top-left corner | |
| 164 | + // cell is literally `base`, distinct from either row's own | |
| 165 | + // replicated value -- confirmed against `av1_highbd_build_intra_predictors`'s | |
| 166 | + // comment block, lane-tiny r1; an earlier attempt at this fix used | |
| 167 | + // 127/129 for the corner instead and made a passing 16x16 fixture | |
| 168 | + // regress, which is what caught the misreading). | |
| 163 | 169 | let base = 1i32 << (crate::decode::bit_depth() - 1); |
| 164 | 170 | let above_row = match (above, left) { |
| 165 | 171 | (Some(a), _) => extend(a), |
crates/ec-av1/src/stream.rsmodified+158 -0
| @@ -6240,6 +6240,164 @@ mod tests { | ||
| 6240 | 6240 | crate::decode::cdef_idx_hits() |
| 6241 | 6241 | ); |
| 6242 | 6242 | } |
| 6243 | + /// lane-tiny r1 diagnostic (not a gate): sweeps tiny key-frame sizes | |
| 6244 | + /// against real aomenc + ffmpeg to find the exact size boundary of the | |
| 6245 | + /// silent-wrong-pixels defect the sub8 lane's r2 dead-end flagged (a | |
| 6246 | + /// plain 16x16 stream, no exotic tools). `#[ignore]`d -- prints a | |
| 6247 | + /// pass/fail table, asserts nothing; run manually with `--nocapture`. | |
| 6248 | + #[test] | |
| 6249 | + #[ignore = "diagnostic sweep, run manually with --nocapture"] | |
| 6250 | + fn probe_tiny_frame_size_boundary() { | |
| 6251 | + if !have_ffmpeg() || !have_aomenc() { | |
| 6252 | + eprintln!("SKIP: no ffmpeg/aomenc"); | |
| 6253 | + return; | |
| 6254 | + } | |
| 6255 | + let sizes: &[(usize, usize)] = | |
| 6256 | + &[(8, 8), (16, 16), (32, 32), (16, 32), (32, 16), (64, 64), (48, 48), (24, 24)]; | |
| 6257 | + for &(width, height) in sizes { | |
| 6258 | + let mut ok = 0u32; | |
| 6259 | + let mut bad = 0u32; | |
| 6260 | + let mut refused = 0u32; | |
| 6261 | + let n = 10u32; | |
| 6262 | + for attempt in 0..n { | |
| 6263 | + let seed = 42 + attempt; | |
| 6264 | + let source = format!( | |
| 6265 | + "mandelbrot=size={width}x{height}:rate=25:start_x={sx}:start_y={sy}", | |
| 6266 | + sx = -0.6 + 0.005 * (attempt as f64), | |
| 6267 | + sy = -0.4 + 0.005 * (attempt as f64) | |
| 6268 | + ); | |
| 6269 | + let y4m = Command::new("ffmpeg") | |
| 6270 | + .args([ | |
| 6271 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", "0.04", "-pix_fmt", | |
| 6272 | + "yuv420p", "-f", "yuv4mpegpipe", "-", | |
| 6273 | + ]) | |
| 6274 | + .stdin(Stdio::null()) | |
| 6275 | + .stdout(Stdio::piped()) | |
| 6276 | + .stderr(Stdio::piped()) | |
| 6277 | + .output() | |
| 6278 | + .expect("ffmpeg failed to run"); | |
| 6279 | + assert!(y4m.status.success(), "ffmpeg fixture: {}", String::from_utf8_lossy(&y4m.stderr)); | |
| 6280 | + let max_part = width.max(height).min(64).next_power_of_two(); | |
| 6281 | + let min_part = width.min(height).next_power_of_two().max(8).min(max_part); | |
| 6282 | + let max_part_arg = format!("--max-partition-size={max_part}"); | |
| 6283 | + let min_part_arg = format!("--min-partition-size={min_part}"); | |
| 6284 | + let args: Vec<&str> = vec![ | |
| 6285 | + "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32", | |
| 6286 | + "--cpu-used=4", "--kf-max-dist=0", "--limit=1", "--threads=1", | |
| 6287 | + "--row-mt=0", "--enable-rect-partitions=0", "--enable-ab-partitions=0", | |
| 6288 | + "--enable-1to4-partitions=0", | |
| 6289 | + &max_part_arg, &min_part_arg, | |
| 6290 | + "--obu", "-o", "-", "-", | |
| 6291 | + ]; | |
| 6292 | + let mut child = Command::new(aomenc_path()) | |
| 6293 | + .args(&args) | |
| 6294 | + .stdin(Stdio::piped()) | |
| 6295 | + .stdout(Stdio::piped()) | |
| 6296 | + .stderr(Stdio::piped()) | |
| 6297 | + .spawn() | |
| 6298 | + .expect("aomenc failed to start"); | |
| 6299 | + child.stdin.take().expect("aomenc stdin").write_all(&y4m.stdout).expect("write y4m"); | |
| 6300 | + let out = child.wait_with_output().expect("aomenc failed to run"); | |
| 6301 | + assert!(out.status.success(), "aomenc refused: {}", String::from_utf8_lossy(&out.stderr)); | |
| 6302 | + let stream = out.stdout; | |
| 6303 | + let frames = match decode_stream(&stream) { | |
| 6304 | + Err(e) => { | |
| 6305 | + eprintln!(" {width}x{height} seed {seed}: REFUSED {e}"); | |
| 6306 | + refused += 1; | |
| 6307 | + continue; | |
| 6308 | + } | |
| 6309 | + Ok(f) => f, | |
| 6310 | + }; | |
| 6311 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | |
| 6312 | + if frames.len() == 1 | |
| 6313 | + && frames[0].y == ffmpeg_frames[0].y | |
| 6314 | + && frames[0].u == ffmpeg_frames[0].u | |
| 6315 | + && frames[0].v == ffmpeg_frames[0].v | |
| 6316 | + { | |
| 6317 | + ok += 1; | |
| 6318 | + } else { | |
| 6319 | + bad += 1; | |
| 6320 | + let mut first = None; | |
| 6321 | + for row in 0..height { | |
| 6322 | + for col in 0..width { | |
| 6323 | + let i = row * width + col; | |
| 6324 | + if frames[0].y[i] != ffmpeg_frames[0].y[i] { | |
| 6325 | + first = Some((row, col, frames[0].y[i], ffmpeg_frames[0].y[i])); | |
| 6326 | + break; | |
| 6327 | + } | |
| 6328 | + } | |
| 6329 | + if first.is_some() { | |
| 6330 | + break; | |
| 6331 | + } | |
| 6332 | + } | |
| 6333 | + let ndiff = frames[0] | |
| 6334 | + .y | |
| 6335 | + .iter() | |
| 6336 | + .zip(&ffmpeg_frames[0].y) | |
| 6337 | + .filter(|(a, b)| a != b) | |
| 6338 | + .count(); | |
| 6339 | + eprintln!( | |
| 6340 | + " {width}x{height} seed {seed}: MISMATCH luma first_diff={first:?} ndiff_luma={ndiff}/{}", | |
| 6341 | + width * height | |
| 6342 | + ); | |
| 6343 | + } | |
| 6344 | + } | |
| 6345 | + eprintln!("{width}x{height}: {ok} ok / {bad} mismatch / {refused} refused (of {n})"); | |
| 6346 | + } | |
| 6347 | + } | |
| 6348 | + | |
| 6349 | + /// lane-tiny r1: re-decodes the known-failing 32x32 seed 45 fixture with | |
| 6350 | + /// `EC_AV1_TRACE` on to inspect what mode/tx this single-block frame | |
| 6351 | + /// picked. Diagnostic only, `#[ignore]`d, run manually with --nocapture. | |
| 6352 | + #[test] | |
| 6353 | + #[ignore = "diagnostic, run manually with --nocapture"] | |
| 6354 | + fn probe_tiny_32x32_trace() { | |
| 6355 | + if !have_ffmpeg() || !have_aomenc() { | |
| 6356 | + eprintln!("SKIP: no ffmpeg/aomenc"); | |
| 6357 | + return; | |
| 6358 | + } | |
| 6359 | + let (width, height) = (32usize, 32usize); | |
| 6360 | + let attempt = 3u32; // seed 45 | |
| 6361 | + let source = format!( | |
| 6362 | + "mandelbrot=size={width}x{height}:rate=25:start_x={sx}:start_y={sy}", | |
| 6363 | + sx = -0.6 + 0.005 * (attempt as f64), | |
| 6364 | + sy = -0.4 + 0.005 * (attempt as f64) | |
| 6365 | + ); | |
| 6366 | + let y4m = Command::new("ffmpeg") | |
| 6367 | + .args([ | |
| 6368 | + "-v", "error", "-f", "lavfi", "-i", &source, "-t", "0.04", "-pix_fmt", "yuv420p", | |
| 6369 | + "-f", "yuv4mpegpipe", "-", | |
| 6370 | + ]) | |
| 6371 | + .stdin(Stdio::null()) | |
| 6372 | + .stdout(Stdio::piped()) | |
| 6373 | + .stderr(Stdio::piped()) | |
| 6374 | + .output() | |
| 6375 | + .expect("ffmpeg failed to run"); | |
| 6376 | + assert!(y4m.status.success()); | |
| 6377 | + let args: Vec<&str> = vec![ | |
| 6378 | + "--codec=av1", "--passes=1", "--end-usage=q", "--cq-level=32", "--cpu-used=4", | |
| 6379 | + "--kf-max-dist=0", "--limit=1", "--threads=1", "--row-mt=0", | |
| 6380 | + "--enable-rect-partitions=0", "--enable-ab-partitions=0", | |
| 6381 | + "--enable-1to4-partitions=0", "--max-partition-size=32", "--min-partition-size=32", | |
| 6382 | + "--enable-filter-intra=0", | |
| 6383 | + "--obu", "-o", "-", "-", | |
| 6384 | + ]; | |
| 6385 | + let mut child = Command::new(aomenc_path()) | |
| 6386 | + .args(&args) | |
| 6387 | + .stdin(Stdio::piped()) | |
| 6388 | + .stdout(Stdio::piped()) | |
| 6389 | + .stderr(Stdio::piped()) | |
| 6390 | + .spawn() | |
| 6391 | + .expect("aomenc failed to start"); | |
| 6392 | + child.stdin.take().unwrap().write_all(&y4m.stdout).unwrap(); | |
| 6393 | + let out = child.wait_with_output().unwrap(); | |
| 6394 | + assert!(out.status.success()); | |
| 6395 | + let stream = out.stdout; | |
| 6396 | + let frames = decode_stream(&stream).expect("decode"); | |
| 6397 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, 1); | |
| 6398 | + let mismatched = frames[0].y != ffmpeg_frames[0].y; | |
| 6399 | + eprintln!("mismatched={mismatched}"); | |
| 6400 | + } | |
| 6243 | 6401 | /// Pinned streams captured by `EC_AV1_GATE_DUMP` off |
| 6244 | 6402 | /// `a_real_aomenc_stream_with_warped_motion_refuses_or_matches` -- each |
| 6245 | 6403 | /// one is a former mismatch, kept as a regression pin (warp-mismatch: |