Mpeg: Use direct pts value checks in newer FFmpeg.

This commit is contained in:
Unknown W. Brackets 2021-02-17 22:28:32 -08:00
parent 6656c8a533
commit 2b2dae60d3
2 changed files with 20 additions and 6 deletions

View File

@ -1023,10 +1023,17 @@ static bool decodePmpVideo(PSPPointer<SceMpegRingBuffer> ringbuffer, u32 pmpctxA
sws_freeContext(img_convert_ctx);
// update timestamp
if (av_frame_get_best_effort_timestamp(mediaengine->m_pFrame) != AV_NOPTS_VALUE)
mediaengine->m_videopts = av_frame_get_best_effort_timestamp(mediaengine->m_pFrame) + av_frame_get_pkt_duration(mediaengine->m_pFrame) - mediaengine->m_firstTimeStamp;
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(55, 58, 100)
int64_t bestPts = mediaengine->m_pFrame->best_effort_timestamp;
int64_t ptsDuration = mediaengine->m_pFrame->pkt_duration;
#else
int64_t bestPts = av_frame_get_best_effort_timestamp(mediaengine->m_pFrame);
int64_t ptsDuration = av_frame_get_pkt_duration(mediaengine->m_pFrame);
#endif
if (bestPts != AV_NOPTS_VALUE)
mediaengine->m_videopts = bestPts + ptsDuration - mediaengine->m_firstTimeStamp;
else
mediaengine->m_videopts += av_frame_get_pkt_duration(mediaengine->m_pFrame);
mediaengine->m_videopts += ptsDuration;
// push the decoded frame into pmp_queue
pmp_queue.push_back(pFrameRGB);

View File

@ -666,10 +666,17 @@ bool MediaEngine::stepVideo(int videoPixelMode, bool skipFrame) {
m_pCodecCtx->height, m_pFrameRGB->data, m_pFrameRGB->linesize);
}
if (av_frame_get_best_effort_timestamp(m_pFrame) != AV_NOPTS_VALUE)
m_videopts = av_frame_get_best_effort_timestamp(m_pFrame) + av_frame_get_pkt_duration(m_pFrame) - m_firstTimeStamp;
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(55, 58, 100)
int64_t bestPts = m_pFrame->best_effort_timestamp;
int64_t ptsDuration = m_pFrame->pkt_duration;
#else
int64_t bestPts = av_frame_get_best_effort_timestamp(m_pFrame);
int64_t ptsDuration = av_frame_get_pkt_duration(m_pFrame);
#endif
if (bestPts != AV_NOPTS_VALUE)
m_videopts = bestPts + ptsDuration - m_firstTimeStamp;
else
m_videopts += av_frame_get_pkt_duration(m_pFrame);
m_videopts += ptsDuration;
bGetFrame = true;
}
if (result <= 0 && dataEnd) {