Enabled multi-threading decoding and encoding with libavcodec, setting the thread_count property. This make a huge improvement in CPU performance, for codecs that support this property.

This commit is contained in:
Jonathan Thomas
2012-08-28 22:53:12 -05:00
parent 0f3758bc29
commit 8831dd0c49
3 changed files with 15 additions and 3 deletions

View File

@@ -90,6 +90,9 @@ void FFmpegReader::Open()
pStream = pFormatCtx->streams[videoStream];
pCodecCtx = pFormatCtx->streams[videoStream]->codec;
// Set number of threads equal to number of processors + 1
pCodecCtx->thread_count = omp_get_num_procs() + 1;
// Find the decoder for the video stream
AVCodec *pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
if (pCodec == NULL) {
@@ -113,6 +116,9 @@ void FFmpegReader::Open()
aStream = pFormatCtx->streams[audioStream];
aCodecCtx = pFormatCtx->streams[audioStream]->codec;
// Set number of threads equal to number of processors + 1
aCodecCtx->thread_count = omp_get_num_procs() + 1;
// Find the decoder for the audio stream
AVCodec *aCodec = avcodec_find_decoder(aCodecCtx->codec_id);
if (aCodec == NULL) {