Bug 1237962: [ffmpeg] Do not create extra threads when decoding small videos. r=kentuckyfriedtakahe

Instead we use our current decoding's taskqueue.
This commit is contained in:
Jean-Yves Avenard 2016-01-09 00:44:13 +11:00
parent abeea93b9e
commit e2ca8ba782

View File

@ -125,17 +125,20 @@ FFmpegH264Decoder<LIBAV_VER>::InitCodecContext()
// We use the same logic as libvpx in determining the number of threads to use
// so that we end up behaving in the same fashion when using ffmpeg as
// we would otherwise cause various crashes (see bug 1236167)
int decode_threads = 2;
if (mCodecID != AV_CODEC_ID_VP8) {
if (mDisplay.width >= 2048) {
decode_threads = 8;
} else if (mDisplay.width >= 1024) {
decode_threads = 4;
}
int decode_threads = 1;
if (mDisplay.width >= 2048) {
decode_threads = 8;
} else if (mDisplay.width >= 1024) {
decode_threads = 4;
} else if (mDisplay.width >= 320) {
decode_threads = 2;
}
decode_threads = std::min(decode_threads, PR_GetNumberOfProcessors());
mCodecContext->thread_count = decode_threads;
mCodecContext->thread_type = FF_THREAD_SLICE | FF_THREAD_FRAME;
if (decode_threads > 1) {
mCodecContext->thread_type = FF_THREAD_SLICE | FF_THREAD_FRAME;
}
// FFmpeg will call back to this to negotiate a video pixel format.
mCodecContext->get_format = ChoosePixelFormat;