Enable multi-threading on decode

This commit is contained in:
Isaac Connor 2021-11-17 14:43:13 -05:00
parent 4945a016cf
commit 96b4af6255
1 changed files with 11 additions and 0 deletions

View File

@ -458,6 +458,17 @@ int FfmpegCamera::OpenFfmpeg() {
#endif #endif
} // end if hwaccel_name } // end if hwaccel_name
// set codec to automatically determine how many threads suits best for the decoding job
mVideoCodecContext->thread_count = 0;
if (mVideoCodec->capabilities | AV_CODEC_CAP_FRAME_THREADS) {
mVideoCodecContext->thread_type = FF_THREAD_FRAME;
} else if (mVideoCodec->capabilities | AV_CODEC_CAP_SLICE_THREADS) {
mVideoCodecContext->thread_type = FF_THREAD_SLICE;
} else {
mVideoCodecContext->thread_count = 1; //don't use multithreading
}
ret = avcodec_open2(mVideoCodecContext, mVideoCodec, &opts); ret = avcodec_open2(mVideoCodecContext, mVideoCodec, &opts);
e = nullptr; e = nullptr;