The coefficient writer splits a scan position by shifting, and a wall table for the film crop
Browse files at this commit65aa140813b4411cc5f3db440a0a0c0d9e5761fcParent: 3847d87- perf
- the coefficient writer splits a scan position by shifting, and a wall table for the film crop
2 changed files +26 -3
crates/ec-av1/src/encoder.rsmodified+20 -2
| @@ -1496,8 +1496,16 @@ mod tests { | |||
| 1496 | if !have_ffmpeg() { | 1496 | if !have_ffmpeg() { |
| 1497 | return None; | 1497 | return None; |
| 1498 | } | 1498 | } |
| 1499 | - let clip = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | 1499 | + // lane-av1speed3: the wall tables below are read on REAL film as |
| 1500 | - .join("../../fixtures/video/h264-1080p-23.976-8bit.mp4"); | 1500 | + // well as on the colour-bar fixture (`bars` vs `film` in the BD |
| 1501 | + // gate's own vocabulary), and the film crop lives outside the repo -- | ||
| 1502 | + // `EC_AV1_WALL_CLIP` names it. Unset everywhere else, so every other | ||
| 1503 | + // caller still gets the fixture. | ||
| 1504 | + let clip = match std::env::var("EC_AV1_WALL_CLIP") { | ||
| 1505 | + Ok(p) => std::path::PathBuf::from(p), | ||
| 1506 | + Err(_) => std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | ||
| 1507 | + .join("../../fixtures/video/h264-1080p-23.976-8bit.mp4"), | ||
| 1508 | + }; | ||
| 1501 | if !clip.exists() { | 1509 | if !clip.exists() { |
| 1502 | return None; | 1510 | return None; |
| 1503 | } | 1511 | } |
| @@ -2168,6 +2176,16 @@ mod tests { | |||
| 2168 | filter_stage_wall(3840, 1608, 4, (2, 1), &[8, 12]); | 2176 | filter_stage_wall(3840, 1608, 4, (2, 1), &[8, 12]); |
| 2169 | } | 2177 | } |
| 2170 | 2178 | ||
| 2179 | + /// The same breakdown at the real films' own crop size. With | ||
| 2180 | + /// `EC_AV1_WALL_CLIP` pointing at a film window this is the film row; with | ||
| 2181 | + /// it unset it is the colour-bar fixture at the same size, which is what | ||
| 2182 | + /// makes the pair a comparison rather than a number. | ||
| 2183 | + #[test] | ||
| 2184 | + #[ignore = "wall measurement: minutes, run it with --ignored --nocapture"] | ||
| 2185 | + fn filter_stage_wall_film() { | ||
| 2186 | + filter_stage_wall(1920, 768, 4, (2, 1), &[8]); | ||
| 2187 | + } | ||
| 2188 | + | ||
| 2171 | fn filter_stage_wall( | 2189 | fn filter_stage_wall( |
| 2172 | width: usize, | 2190 | width: usize, |
| 2173 | height: usize, | 2191 | height: usize, |
crates/ec-av1/src/tile.rsmodified+6 -1
| @@ -4543,9 +4543,14 @@ fn write_coeffs( | |||
| 4543 | 4543 | ||
| 4544 | write_eob(enc, coding, eob, plane); | 4544 | write_eob(enc, coding, eob, plane); |
| 4545 | 4545 | ||
| 4546 | + // lane-av1speed3: `side` is 4, 8, 16 or 32, but it is a runtime value -- | ||
| 4547 | + // `pos / side` compiles to a real integer division, once per coefficient, | ||
| 4548 | + // in the encoder's largest self-time symbol. Same row and column. | ||
| 4549 | + debug_assert!(side.is_power_of_two(), "the scan splits a position by shifting"); | ||
| 4550 | + let (shift, mask) = (side.trailing_zeros(), side - 1); | ||
| 4546 | for scan_idx in (0..eob).rev() { | 4551 | for scan_idx in (0..eob).rev() { |
| 4547 | let pos = scan[scan_idx] as usize; | 4552 | let pos = scan[scan_idx] as usize; |
| 4548 | - let (row, col) = (pos / side, pos % side); | 4553 | + let (row, col) = (pos >> shift, pos & mask); |
| 4549 | let level = grid[pos].abs(); | 4554 | let level = grid[pos].abs(); |
| 4550 | if scan_idx == eob - 1 { | 4555 | if scan_idx == eob - 1 { |
| 4551 | let ctx = eob_coeff_ctx(scan_idx, side * side); | 4556 | let ctx = eob_coeff_ctx(scan_idx, side * side); |