From 0a13c787885ff8e04fd90e0548ab75429f70b15b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 12 Jan 2023 16:21:41 +0100 Subject: [PATCH] Revert "ffmpeg: Don't ask for multi-threaded decoding" This reverts commit b173e0f4a4d17cfbb5fe7bc134e51925778a9f1b. Turns out it's not actually known to fix anything, should have closed that old PR. --- Core/HW/MediaEngine.cpp | 6 +++++- Core/HW/SimpleAudioDec.cpp | 4 +++- Core/MemFault.cpp | 1 - 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Core/HW/MediaEngine.cpp b/Core/HW/MediaEngine.cpp index f1dd803e8a..fa4b8191c4 100644 --- a/Core/HW/MediaEngine.cpp +++ b/Core/HW/MediaEngine.cpp @@ -521,7 +521,11 @@ bool MediaEngine::setVideoStream(int streamNum, bool force) { m_pCodecCtx->flags |= AV_CODEC_FLAG_OUTPUT_CORRUPT | AV_CODEC_FLAG_LOW_DELAY; - int openResult = avcodec_open2(m_pCodecCtx, pCodec, nullptr); + AVDictionary *opt = nullptr; + // Allow ffmpeg to use any number of threads it wants. Without this, it doesn't use threads. + av_dict_set(&opt, "threads", "0", 0); + int openResult = avcodec_open2(m_pCodecCtx, pCodec, &opt); + av_dict_free(&opt); if (openResult < 0) { return false; } diff --git a/Core/HW/SimpleAudioDec.cpp b/Core/HW/SimpleAudioDec.cpp index 168d2eefd5..8f250abdd8 100644 --- a/Core/HW/SimpleAudioDec.cpp +++ b/Core/HW/SimpleAudioDec.cpp @@ -107,10 +107,12 @@ bool SimpleAudio::OpenCodec(int block_align) { codecCtx_->block_align = block_align; } - int retval = avcodec_open2(codecCtx_, codec_, nullptr); + AVDictionary *opts = 0; + int retval = avcodec_open2(codecCtx_, codec_, &opts); if (retval < 0) { ERROR_LOG(ME, "Failed to open codec: retval = %i", retval); } + av_dict_free(&opts); codecOpen_ = true; return retval >= 0; #else diff --git a/Core/MemFault.cpp b/Core/MemFault.cpp index d3b0dfc77c..5cedc51738 100644 --- a/Core/MemFault.cpp +++ b/Core/MemFault.cpp @@ -268,7 +268,6 @@ bool HandleFault(uintptr_t hostAddress, void *ctx) { } } else { type = MemoryExceptionType::UNKNOWN; - } g_lastMemoryExceptionType = type;