From d8e3bae2da1a81dc821ed2e0c01f28c5673b1584 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 20 Feb 2021 15:12:37 -0800 Subject: [PATCH] Mpeg: Prevent sending flush packets to decode. --- Core/HLE/sceMpeg.cpp | 3 ++- Core/HW/MediaEngine.cpp | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index 3701f08a47..37e500ebb9 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -994,7 +994,8 @@ static bool decodePmpVideo(PSPPointer ringbuffer, u32 pmpctxA // decode video frame #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 101) - avcodec_send_packet(pCodecCtx, &packet); + if (packet.size != 0) + avcodec_send_packet(pCodecCtx, &packet); int len = avcodec_receive_frame(pCodecCtx, pFrame); if (len == 0) { len = pFrame->pkt_size; diff --git a/Core/HW/MediaEngine.cpp b/Core/HW/MediaEngine.cpp index 4f7b213e5d..e162ffd725 100644 --- a/Core/HW/MediaEngine.cpp +++ b/Core/HW/MediaEngine.cpp @@ -314,7 +314,7 @@ bool MediaEngine::openContext(bool keepReadPos) { if (!SetupStreams()) { // Fallback to old behavior. Reads too much and corrupts when game doesn't read fast enough. - // SetupStreams should work for newer FFmpeg 3.1+ now. + // SetupStreams sometimes work for newer FFmpeg 3.1+ now, but sometimes framerate is missing. WARN_LOG_REPORT_ONCE(setupStreams, ME, "Failed to read valid video stream data from header"); if (avformat_find_stream_info(m_pFormatCtx, nullptr) < 0) { closeContext(); @@ -677,7 +677,8 @@ bool MediaEngine::stepVideo(int videoPixelMode, bool skipFrame) { #endif #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 101) - avcodec_send_packet(m_pCodecCtx, &packet); + if (packet.size != 0) + avcodec_send_packet(m_pCodecCtx, &packet); int result = avcodec_receive_frame(m_pCodecCtx, m_pFrame); if (result == 0) { result = m_pFrame->pkt_size;