diff --git a/crates/ec-av1/src/encoder.rs b/crates/ec-av1/src/encoder.rs index 909c8a9c..52125ab0 100644 --- a/crates/ec-av1/src/encoder.rs +++ b/crates/ec-av1/src/encoder.rs @@ -1496,8 +1496,16 @@ mod tests { if !have_ffmpeg() { return None; } - let clip = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) - .join("../../fixtures/video/h264-1080p-23.976-8bit.mp4"); + // lane-av1speed3: the wall tables below are read on REAL film as + // well as on the colour-bar fixture (`bars` vs `film` in the BD + // gate's own vocabulary), and the film crop lives outside the repo -- + // `EC_AV1_WALL_CLIP` names it. Unset everywhere else, so every other + // caller still gets the fixture. + let clip = match std::env::var("EC_AV1_WALL_CLIP") { + Ok(p) => std::path::PathBuf::from(p), + Err(_) => std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../../fixtures/video/h264-1080p-23.976-8bit.mp4"), + }; if !clip.exists() { return None; } @@ -2168,6 +2176,16 @@ mod tests { filter_stage_wall(3840, 1608, 4, (2, 1), &[8, 12]); } + /// The same breakdown at the real films' own crop size. With + /// `EC_AV1_WALL_CLIP` pointing at a film window this is the film row; with + /// it unset it is the colour-bar fixture at the same size, which is what + /// makes the pair a comparison rather than a number. + #[test] + #[ignore = "wall measurement: minutes, run it with --ignored --nocapture"] + fn filter_stage_wall_film() { + filter_stage_wall(1920, 768, 4, (2, 1), &[8]); + } + fn filter_stage_wall( width: usize, height: usize, diff --git a/crates/ec-av1/src/tile.rs b/crates/ec-av1/src/tile.rs index 1234fad1..afbb022a 100644 --- a/crates/ec-av1/src/tile.rs +++ b/crates/ec-av1/src/tile.rs @@ -4543,9 +4543,14 @@ fn write_coeffs( write_eob(enc, coding, eob, plane); + // lane-av1speed3: `side` is 4, 8, 16 or 32, but it is a runtime value -- + // `pos / side` compiles to a real integer division, once per coefficient, + // in the encoder's largest self-time symbol. Same row and column. + debug_assert!(side.is_power_of_two(), "the scan splits a position by shifting"); + let (shift, mask) = (side.trailing_zeros(), side - 1); for scan_idx in (0..eob).rev() { let pos = scan[scan_idx] as usize; - let (row, col) = (pos / side, pos % side); + let (row, col) = (pos >> shift, pos & mask); let level = grid[pos].abs(); if scan_idx == eob - 1 { let ctx = eob_coeff_ctx(scan_idx, side * side);