Splitting FF_NUM_PROCESSORS into a VIDEO and AUDIO constant. Also limiting VIDEO encoders to 16 threads and audio encoders to 2 threads.

This commit is contained in:
Jonathan Thomas
2025-06-06 15:28:28 -05:00
parent 57a0bae9ac
commit 7ee4643a60
3 changed files with 11 additions and 9 deletions

View File

@@ -278,7 +278,7 @@ void FFmpegReader::Open() {
retry_decode_open = 0;
// Set number of threads equal to number of processors (not to exceed 16)
pCodecCtx->thread_count = std::min(FF_NUM_PROCESSORS, 16);
pCodecCtx->thread_count = std::min(FF_VIDEO_NUM_PROCESSORS, 16);
if (pCodec == NULL) {
throw InvalidCodec("A valid video codec could not be found for this file.", path);
@@ -524,8 +524,8 @@ void FFmpegReader::Open() {
const AVCodec *aCodec = avcodec_find_decoder(codecId);
aCodecCtx = AV_GET_CODEC_CONTEXT(aStream, aCodec);
// Set number of threads equal to number of processors (not to exceed 16)
aCodecCtx->thread_count = std::min(FF_NUM_PROCESSORS, 16);
// Audio encoding does not typically use more than 2 threads (most codecs use 1 thread)
aCodecCtx->thread_count = std::min(FF_AUDIO_NUM_PROCESSORS, 2);
if (aCodec == NULL) {
throw InvalidCodec("A valid audio codec could not be found for this file.", path);