forge
Explore
Log in

Don't you dare go Hollow

Exercise the 16x16 straddle-leaf inter path on real content

Browse files at this commit

cdf385826b075f40d294a0fc955e99623976f4deAhmet Kaan GümüşParent: 3ac79d5
  • test
    • exercise the 16x16 straddle-leaf inter path on real content
Show full message
test(av1): exercise the 16x16 straddle-leaf inter path on real content

real_clip_encodes_within_its_quality_and_size_budget uses 640x384 (both
axes 32-aligned), so Quadrant::Split never fires and the e19bb47
NEARESTMV leaf path was untouched by real, mixed intra/inter content.
Add a sibling at 704x400 (400 mod 32 == 16, the exactly-half straddle
class), same three gates: dav1d decodes every frame, mean luma PSNR
floor, byte ceiling.
crates/ec-av1/src/encode.rsmodified+62 -0
@@ -4420,6 +4420,68 @@ mod tests {
4420 );4420 );
4421 }4421 }
4422 4422
4423+ /// Sibling of `real_clip_encodes_within_its_quality_and_size_budget` at a
4424+ /// straddle size: 640x384 is exact on both axes (32-aligned), so
4425+ /// `Quadrant::Split` never fires there and the 16x16 `NEARESTMV` leaf
4426+ /// path landed in e19bb47 goes unexercised by real, mixed intra/inter
4427+ /// content. 704x400 has 400 mod 32 == 16 -- the same "exactly half
4428+ /// straddle" class as `a_sequence_round_trips_at_the_exactly_half_
4429+ /// straddle_size`'s 1280x720, but that test is a synthetic panned test
4430+ /// card; this one is the real-clip gate, same three floors.
4431+ ///
4432+ /// Measured 2026-08-27 at q=100, 8 frames: stream 54525 bytes, average
4433+ /// luma PSNR 45.48 dB across the 8 decoded frames vs the source.
4434+ /// Floor/ceiling below carry the same margin as the sibling test (PSNR
4435+ /// floor = measured - 0.5 dB; byte ceiling = measured * 1.15).
4436+ #[test]
4437+ fn real_clip_encodes_within_its_quality_and_size_budget_at_a_straddle_size() {
4438+ if !have_ffmpeg() {
4439+ eprintln!(
4440+ "SKIP real_clip_encodes_within_its_quality_and_size_budget_at_a_straddle_size: \
4441+ no ffmpeg"
4442+ );
4443+ return;
4444+ }
4445+ let clip = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
4446+ .join("../../fixtures/video/h264-1080p-23.976-8bit.mp4");
4447+ if !clip.exists() {
4448+ eprintln!(
4449+ "SKIP real_clip_encodes_within_its_quality_and_size_budget_at_a_straddle_size: \
4450+ {} missing",
4451+ clip.display()
4452+ );
4453+ return;
4454+ }
4455+ let (width, height, frame_count) = (704usize, 400usize, 8usize);
4456+ let source = clip_frames(clip.to_str().unwrap(), "0", width, height, frame_count);
4457+ let encoded = encode_sequence(&source, 100, 0.5).unwrap();
4458+ assert_eq!(encoded.frames.len(), frame_count);
4459+
4460+ // Gate 1: a real AV1 decoder (dav1d, via ffmpeg) accepts the whole
4461+ // stream and hands back every frame.
4462+ let decoded = ffmpeg_decode_sequence(&encoded.stream, width, height, frame_count);
4463+ assert_eq!(decoded.len(), frame_count, "dav1d decoded every frame");
4464+
4465+ // Gate 2: quality vs the source did not silently collapse.
4466+ let mean_psnr: f64 = decoded
4467+ .iter()
4468+ .zip(&source)
4469+ .map(|(d, s)| psnr(&d.y, &s.y))
4470+ .sum::<f64>()
4471+ / frame_count as f64;
4472+ assert!(
4473+ mean_psnr >= 44.98,
4474+ "mean luma PSNR {mean_psnr:.2} dB fell below the 44.98 dB floor"
4475+ );
4476+
4477+ // Gate 3: the stream did not silently bloat.
4478+ assert!(
4479+ encoded.stream.len() <= 62_703,
4480+ "stream grew to {} bytes, over the 62703-byte ceiling",
4481+ encoded.stream.len()
4482+ );
4483+ }
4484+
4423 /// The replica-shaped path: 24 frames, 1280x720, one key frame followed4485 /// The replica-shaped path: 24 frames, 1280x720, one key frame followed
4424 /// by inter frames -- the same GOP shape [`encode_sequence`] gives the4486 /// by inter frames -- the same GOP shape [`encode_sequence`] gives the
4425 /// facade -- timed end to end, so the edith export-time projection is a4487 /// facade -- timed end to end, so the edith export-time projection is a