wip(av1): warp fixture found + decisive pinned mismatch -- COMPILING WIP
Browse files at this commitfefaafbc6c2157a37a3b10b75bca481ac89d82b6Parent: efe3e651 changed file +65 -2
- crates/ec-av1/src/stream.rs +65 -2
crates/ec-av1/src/stream.rsmodified+65 -2
| @@ -3322,7 +3322,11 @@ mod tests { | ||
| 3322 | 3322 | let (width, height, frame_count) = (64usize, 64usize, 24usize); |
| 3323 | 3323 | let mut named_refusals = 0u32; |
| 3324 | 3324 | let mut matched = 0u32; |
| 3325 | - for attempt in 0..40u32 { | |
| 3325 | + let n_attempts: u32 = std::env::var("EC_WARP_GATE_ATTEMPTS") | |
| 3326 | + .ok() | |
| 3327 | + .and_then(|s| s.parse().ok()) | |
| 3328 | + .unwrap_or(40); | |
| 3329 | + for attempt in 0..n_attempts { | |
| 3326 | 3330 | let seed = 42 + attempt; |
| 3327 | 3331 | let duration = frame_count as f64 / 25.0; |
| 3328 | 3332 | let source = |
| @@ -3366,6 +3370,7 @@ mod tests { | ||
| 3366 | 3370 | "--enable-order-hint=1", |
| 3367 | 3371 | "--enable-warped-motion=1", |
| 3368 | 3372 | "--enable-obmc=1", |
| 3373 | + "--tune-content=default", | |
| 3369 | 3374 | "--enable-masked-comp=0", |
| 3370 | 3375 | "--enable-interintra-comp=0", |
| 3371 | 3376 | "--enable-onesided-comp=0", |
| @@ -3421,12 +3426,21 @@ mod tests { | ||
| 3421 | 3426 | "{NAME} failed outright, not a named refusal (seed {seed}): {msg}" |
| 3422 | 3427 | ); |
| 3423 | 3428 | named_refusals += 1; |
| 3429 | + eprintln!("seed {seed} refusal: {msg}"); | |
| 3424 | 3430 | continue; |
| 3425 | 3431 | } |
| 3426 | 3432 | Ok(frames) => frames, |
| 3427 | 3433 | }; |
| 3428 | 3434 | let ffmpeg_frames = ffmpeg_decode_sequence(&stream, width, height, frame_count); |
| 3429 | 3435 | assert_eq!(frames.len(), frame_count); |
| 3436 | + let mismatched = frames | |
| 3437 | + .iter() | |
| 3438 | + .zip(&ffmpeg_frames) | |
| 3439 | + .any(|(got, want)| got.y != want.y || got.u != want.u || got.v != want.v); | |
| 3440 | + if mismatched && let Ok(path) = std::env::var("EC_AV1_GATE_DUMP") { | |
| 3441 | + std::fs::write(&path, &stream).expect("writing pinned stream"); | |
| 3442 | + eprintln!("EC_AV1_GATE_DUMP: wrote mismatching stream (seed {seed}) to {path}"); | |
| 3443 | + } | |
| 3430 | 3444 | for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { |
| 3431 | 3445 | assert_eq!( |
| 3432 | 3446 | got.y, want.y, |
| @@ -3439,10 +3453,59 @@ mod tests { | ||
| 3439 | 3453 | matched += 1; |
| 3440 | 3454 | } |
| 3441 | 3455 | eprintln!( |
| 3442 | - "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of 40" | |
| 3456 | + "{NAME}: {named_refusals} named refusals, {matched} pixel-exact matches out of {n_attempts}, warp_selected_hits={}", | |
| 3457 | + crate::decode::warp_selected_hits() | |
| 3443 | 3458 | ); |
| 3444 | 3459 | } |
| 3445 | 3460 | |
| 3461 | + /// lane-warp round 3: reproduces the pinned mismatch bytes captured by | |
| 3462 | + /// `EC_AV1_GATE_DUMP=$SP/warp-mismatch.obu` off | |
| 3463 | + /// `a_real_aomenc_stream_with_warped_motion_refuses_or_matches` (seed 49, | |
| 3464 | + /// frame 1). Deterministic and static -- `#[ignore]`d, run manually. | |
| 3465 | + #[test] | |
| 3466 | + #[ignore = "reads a pinned fixture path outside the repo; run manually"] | |
| 3467 | + fn pinned_warp_stream_decodes_pixel_exact() { | |
| 3468 | + use crate::decode::warp_selected_hits; | |
| 3469 | + let path = std::env::var("EC_AV1_GATE_DUMP_PIN").unwrap_or_else(|_| { | |
| 3470 | + "/tmp/claude-1000/-home-user-Documents-Code-Rust-edith-codecs/\ | |
| 3471 | + 51b5f611-f998-43a8-b975-e64cb643a3e1/scratchpad/warp-mismatch.obu" | |
| 3472 | + .to_string() | |
| 3473 | + }); | |
| 3474 | + let stream = std::fs::read(&path).expect("reading pinned stream"); | |
| 3475 | + if !have_ffmpeg() { | |
| 3476 | + eprintln!("SKIP pinned_warp_stream_decodes_pixel_exact: no ffmpeg"); | |
| 3477 | + return; | |
| 3478 | + } | |
| 3479 | + let before = warp_selected_hits(); | |
| 3480 | + let frames = decode_stream(&stream).expect("pinned stream must decode"); | |
| 3481 | + eprintln!( | |
| 3482 | + "warp_selected_hits before={before} after={}", | |
| 3483 | + warp_selected_hits() | |
| 3484 | + ); | |
| 3485 | + let ffmpeg_frames = ffmpeg_decode_sequence(&stream, 64, 64, 24); | |
| 3486 | + for (i, (got, want)) in frames.iter().zip(&ffmpeg_frames).enumerate() { | |
| 3487 | + if got.y != want.y { | |
| 3488 | + for row in 0..64 { | |
| 3489 | + let mut line = String::new(); | |
| 3490 | + for col in 0..64 { | |
| 3491 | + let d = got.y[row * 64 + col] as i32 - want.y[row * 64 + col] as i32; | |
| 3492 | + line.push(if d == 0 { | |
| 3493 | + '.' | |
| 3494 | + } else if d.abs() < 4 { | |
| 3495 | + 'o' | |
| 3496 | + } else { | |
| 3497 | + 'X' | |
| 3498 | + }); | |
| 3499 | + } | |
| 3500 | + eprintln!("{line}"); | |
| 3501 | + } | |
| 3502 | + } | |
| 3503 | + assert_eq!(got.y, want.y, "frame {i} luma vs ffmpeg (pinned)"); | |
| 3504 | + assert_eq!(got.u, want.u, "frame {i} U vs ffmpeg (pinned)"); | |
| 3505 | + assert_eq!(got.v, want.v, "frame {i} V vs ffmpeg (pinned)"); | |
| 3506 | + } | |
| 3507 | + } | |
| 3508 | + | |
| 3446 | 3509 | /// `LAST2_FRAME`/`LAST3_FRAME` are just older slots in the same forward |
| 3447 | 3510 | /// reference-buffer ring `LAST_FRAME`/`GOLDEN_FRAME` already prove -- |
| 3448 | 3511 | /// dropping the golden gate's `--max-reference-frames=3 |