mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-10-24 02:09:03 +03:00
A slice still over budget at max_quant searches for a quantizer that fits by estimating each quantizer above it in turn, up to 127. With the 4:2:2 profiles' budgets on detailed content many slices take dozens of steps, and since the loop is subgroup-uniform every lane of the subgroup waits for the slowest slice. On a Tesla T4, 1080p HQ ran slower than 4444. Gallop upwards until an estimate fits, then bisect between the highest quantizer known to overshoot and the lowest known to fit, in about 2 * log2(distance) estimates. When bits fall monotonically with the quantizer, this finds the same quantizer as the linear search. The DC and run/level estimates are context-adaptive, so occasionally they don't, and the search settles on a higher quantizer that also fits. 1080p, steady state, fps, on a Tesla T4 (NVIDIA 580.159.04), measured with 9.0.2 plus this shader's fixes from master (e54f60ed,ddc140eb,444564d5,03e58384): linear bisect HQ, SMPTE bars 17.9 73.6 HQ, noise 14.8 56.2 Proxy, noise 16.5 71.0 4444, SMPTE bars 30.9 63.1 4444, noise 24.4 47.8 Output was byte-identical there for every row. On master with KosmicKrisp (Apple M4), 1080p testsrc2, smptebars, mandelbrot, a camera recording and a screen recording in all six profiles, 27 of 30 encodes were byte-identical. The other three were Proxy, the tightest budget: each changed by a few bytes, and average PSNR moved by at most 0.0003 dB.