Mpeg: Update videos to latest FFmpeg packet pump.

This commit is contained in:
Unknown W. Brackets
2021-02-18 00:20:27 -08:00
parent e3be3d5f7b
commit 0ab6f1d080
2 changed files with 30 additions and 2 deletions
+14
View File
@@ -993,7 +993,21 @@ static bool decodePmpVideo(PSPPointer<SceMpegRingBuffer> ringbuffer, u32 pmpctxA
// decode video frame
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 101)
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);
#endif
DEBUG_LOG(ME, "got_picture %d", got_picture);
if (got_picture){
SwsContext *img_convert_ctx = NULL;
+16 -2
View File
@@ -664,9 +664,9 @@ bool MediaEngine::stepVideo(int videoPixelMode, bool skipFrame) {
while (!bGetFrame) {
bool dataEnd = av_read_frame(m_pFormatCtx, &packet) < 0;
// Even if we've read all frames, some may have been re-ordered frames at the end.
// Still need to decode those, so keep calling avcodec_decode_video2().
// Still need to decode those, so keep calling avcodec_decode_video2() / avcodec_receive_frame().
if (dataEnd || packet.stream_index == m_videoStream) {
// avcodec_decode_video2() gives us the re-ordered frames with a NULL packet.
// avcodec_decode_video2() / avcodec_send_packet() gives us the re-ordered frames with a NULL packet.
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
if (dataEnd)
av_packet_unref(&packet);
@@ -675,7 +675,21 @@ bool MediaEngine::stepVideo(int videoPixelMode, bool skipFrame) {
av_free_packet(&packet);
#endif
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 101)
avcodec_send_packet(m_pCodecCtx, &packet);
int result = avcodec_receive_frame(m_pCodecCtx, m_pFrame);
if (result == 0) {
result = m_pFrame->pkt_size;
frameFinished = 1;
} else if (result == AVERROR(EAGAIN)) {
result = 0;
frameFinished = 0;
} else {
frameFinished = 0;
}
#else
int result = avcodec_decode_video2(m_pCodecCtx, m_pFrame, &frameFinished, &packet);
#endif
if (frameFinished) {
if (!m_pFrameRGB) {
setVideoDim();