From 7a7e4ed23f5f56b2dbb1a89b6a04e41a0399a37f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 22 Mar 2017 20:36:42 -0700 Subject: [PATCH] Video: Enable threads for video decoding. This was previously getting (accidentally?) enabled by the call to `avformat_find_stream_info()`. See #9262. --- Core/HW/MediaEngine.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Core/HW/MediaEngine.cpp b/Core/HW/MediaEngine.cpp index eb28583565..d9398cf8be 100644 --- a/Core/HW/MediaEngine.cpp +++ b/Core/HW/MediaEngine.cpp @@ -458,14 +458,18 @@ bool MediaEngine::setVideoStream(int streamNum, bool force) { // Find the decoder for the video stream AVCodec *pCodec = avcodec_find_decoder(m_pCodecCtx->codec_id); - if (pCodec == NULL) { + if (pCodec == nullptr) { return false; } - // Open codec - if (avcodec_open2(m_pCodecCtx, pCodec, nullptr) < 0) { - return false; // Could not open codec + AVDictionary *opt = nullptr; + av_dict_set(&opt, "threads", "0", 0); + int openResult = avcodec_open2(m_pCodecCtx, pCodec, &opt); + av_dict_free(&opt); + if (openResult < 0) { + return false; } + m_pCodecCtxs[streamNum] = m_pCodecCtx; } #endif