diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index 7ff2255bcb..8c3f2f4e98 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -929,16 +929,14 @@ static bool decodePmpVideo(PSPPointer ringbuffer, u32 pmpctxA avcodec_send_packet(pCodecCtx, &packet); int len = avcodec_receive_frame(pCodecCtx, pFrame); if (len == 0) { - len = pFrame->pkt_size; got_picture = 1; } else if (len == AVERROR(EAGAIN)) { - len = 0; got_picture = 0; } else { got_picture = 0; } #else - int len = avcodec_decode_video2(pCodecCtx, pFrame, &got_picture, &packet); + avcodec_decode_video2(pCodecCtx, pFrame, &got_picture, &packet); #endif DEBUG_LOG(Log::Mpeg, "got_picture %d", got_picture); if (got_picture){ diff --git a/Core/HW/MediaEngine.cpp b/Core/HW/MediaEngine.cpp index fb5c61087b..94f17c8e2d 100644 --- a/Core/HW/MediaEngine.cpp +++ b/Core/HW/MediaEngine.cpp @@ -369,7 +369,11 @@ void MediaEngine::closeContext() { m_pCodecCtxs.clear(); // These are streams allocated from avformat_new_stream. for (auto &it : m_codecsToClose) { +#if LIBAVCODEC_VERSION_MAJOR >= 62 + avcodec_free_context(&it); +#else avcodec_close(it); +#endif } m_codecsToClose.clear(); if (m_pFormatCtx) @@ -690,7 +694,7 @@ bool MediaEngine::stepVideo(int videoPixelMode, bool skipFrame) { avcodec_send_packet(m_pCodecCtx, &packet); int result = avcodec_receive_frame(m_pCodecCtx, m_pFrame); if (result == 0) { - result = m_pFrame->pkt_size; + result = 1; frameFinished = 1; } else if (result == AVERROR(EAGAIN)) { result = 0; diff --git a/Core/HW/SimpleAudioDec.cpp b/Core/HW/SimpleAudioDec.cpp index 61e89aa274..3a32d3c833 100644 --- a/Core/HW/SimpleAudioDec.cpp +++ b/Core/HW/SimpleAudioDec.cpp @@ -327,7 +327,7 @@ bool FFmpegAudioDecoder::Decode(const uint8_t *inbuf, int inbytes, int *inbytesC int err = avcodec_receive_frame(codecCtx_, frame_); int len = 0; if (err >= 0) { - len = frame_->pkt_size; + len = packet.size; got_frame = 1; } else if (err != AVERROR(EAGAIN)) { len = err; @@ -392,7 +392,11 @@ bool FFmpegAudioDecoder::Decode(const uint8_t *inbuf, int inbytes, int *inbytesC if (!swrCtx_ || swr_init(swrCtx_) < 0) { ERROR_LOG(Log::ME, "swr_init: Failed to initialize the resampling context"); +#if LIBAVCODEC_VERSION_MAJOR >= 62 + avcodec_free_context(&codecCtx_); +#else avcodec_close(codecCtx_); +#endif codec_ = 0; return false; }