Files
marshiyar 90c26b3b63 h264enc: pay back single-pass VBR/CBR overshoot within a short clip (#3200)
The 1-pass rate controller corrects its qscale by the bits spent over the
target divided by one second of bits. A clip that starts over target (the
opening I frame, a model that is still learning) then settles at a constant
excess instead of paying it back: 2 s of a 1080p mandelbrot zoom with the
export defaults (High, Balanced, VBR 20 Mbit/s, max 30, two B-frames) came
out at +9.8% at 30 fps and +13.5% at 60 fps.

The correction horizon is now a quarter second of bits (still clamped to
0.5..2x). Measured on the same clips: +4.1% and +4.0%; an 8 s clip goes from
+3.4% to +0.6%; clips that were already on target or under are unchanged
within 1%. Single-pass CBR/VBR streams change, so the two pinned slice hashes
that use them are updated.

Tested with a new ffmpeg-generated 2 s 1080p test (skipped without ffmpeg)
asserting the bitrate lands within 6% of target at 30 and 60 fps; it failed
before.

Fixes #3200
2026-10-30 06:02:56 -07:00
..