diff --git a/crates/ec-h264/src/enc/mb.rs b/crates/ec-h264/src/enc/mb.rs index 724168be..4b36ebb0 100644 --- a/crates/ec-h264/src/enc/mb.rs +++ b/crates/ec-h264/src/enc/mb.rs @@ -50,10 +50,10 @@ use super::{ /// the two edith actually picks between. #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] pub enum Preset { - /// Diamond motion search, 16x16 partitions, intra 4x4 in I pictures only. + /// Diamond motion search, 16x16 partitions. #[default] Fast, - /// Wider search with a hexagon refinement and intra 4x4 everywhere. + /// Wider search with a hexagon refinement and half-macroblock partitions. Balanced, } @@ -434,7 +434,15 @@ fn intra_pre_cost( IntraCost { i16_mode: best.1, i16_cost: best.0, - allow_i4: e.slice_type == SliceType::I || e.preset == Preset::Balanced, + // Intra_4x4 is tried in P pictures too, at every preset. Measured + // against x264 on a 3840x1608 clip from the library (BD-PSNR over QP + // 22/26/30/34, matched features): restricting it to I pictures cost + // -2.992 dB against x264 where allowing it everywhere reads -1.557 dB, + // for 5% more encode time. Nothing else in the Fast/Balanced split + // came close -- a 48-sample search range read -3.039 dB and the + // half-macroblock partitions -3.009 dB, both inside the noise of the + // -2.992 dB baseline. + allow_i4: true, } } diff --git a/crates/ec-h264/tests/encode.rs b/crates/ec-h264/tests/encode.rs index 3bd099be..1160b090 100644 --- a/crates/ec-h264/tests/encode.rs +++ b/crates/ec-h264/tests/encode.rs @@ -863,12 +863,14 @@ fn real_clip_t8x8_bd_psnr() { // --------------------------------------------------------------------------- /// Floor for [`bd_psnr_vs_x264`] on the synthetic clip. Our encoder measured -/// -5.202 dB against x264 there on 2026-08-23 (352x288, 24 pictures of +/// -5.140 dB against x264 there on 2026-08-23 (352x288, 24 pictures of /// `Clip::render_smooth`, both encoders at their own default effort: our /// `Preset::Fast`, x264's `-preset medium`). The floor is that number with /// room for platform noise, so the distance can shrink but not grow -/// unnoticed; it is not a claim that -5.2 dB is fine. -const BD_PSNR_VS_X264_FLOOR: f64 = -5.40; +/// unnoticed; it is not a claim that -5.1 dB is fine. On a 3840x1608 clip +/// from the library the same measurement reads -1.557 dB, so this synthetic +/// number is the pessimistic end of the range, not the typical one. +const BD_PSNR_VS_X264_FLOOR: f64 = -5.25; fn have_x264() -> bool { std::process::Command::new("ffmpeg")