pub fn codec_thread_allocation(
request: CodecThreadRequest,
) -> CodecThreadAllocationExpand description
Divides the export CPU budget across concurrently active codec contexts.
The configured value is an export-wide cap and a context always needs one worker, so requested decoder concurrency is reduced before threads are assigned. Hardware video encoding does not consume this software budget.
The split is weighted toward the output, but only when there is an output
to weight it toward. With a software video encoder a software decode
session is sized to its own frame area rather than to an even share, and
the encoder takes the remainder above a floor, because it is the stage that
paces the run: an even split gave two 27 %-utilized decoders 14 of 22
workers and the 98 %-utilized encoder 8. With a hardware video encoder
there is nobody to hand the difference to, and taking it from decode is
pure loss: measured on the 4K fixture with nvenc, cutting each software
decoder from 11 workers to 5 moved decodeWaitMs from 250 ms to 1,340 ms,
so decode stops being ahead of the renderer. That configuration keeps the
even split.
A hardware session opens with HARDWARE_DECODER_THREADS instead. The
share is still reserved for it, because any session can fall back to
software; and with a software encoder that keeps the encoder’s worker
count, and so its output, the same whichever way the sources decode.