From a9ba797ce574f82fb5d1042aaa5640bd6e745ae6 Mon Sep 17 00:00:00 2001 From: oioitff Date: Mon, 3 Jun 2013 17:00:58 +0800 Subject: [PATCH] Improve mpeg pts. A real PSP return a value start from 0. --- Core/HLE/sceMpeg.cpp | 8 ++++---- Core/HW/MediaEngine.cpp | 15 +++++---------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index 4fde020ddf..8eb4d21da0 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -975,8 +975,8 @@ int sceMpegGetAvcAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr) int result = 0; sceAu.pts = ctx->mediaengine->getVideoTimeStamp(); - if (sceAu.pts >= ctx->mpegLastTimestamp) { - INFO_LOG(HLE, "video end reach. pts: %i dts: %i", (int)sceAu.pts, (int)ctx->mpegLastTimestamp); + if (sceAu.pts >= ctx->mediaengine->getLastTimeStamp()) { + INFO_LOG(HLE, "video end reach. pts: %i dts: %i", (int)sceAu.pts, (int)ctx->mediaengine->getLastTimeStamp()); mpegRingbuffer.packetsFree = mpegRingbuffer.packets; Memory::WriteStruct(ctx->mpegRingbufferAddr, &mpegRingbuffer); @@ -1039,8 +1039,8 @@ int sceMpegGetAtracAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr) int result = 0; sceAu.pts = ctx->mediaengine->getAudioTimeStamp(); - if (sceAu.pts >= ctx->mpegLastTimestamp) { - INFO_LOG(HLE, "video end reach. pts: %i dts: %i", (int)sceAu.pts, (int)ctx->mpegLastTimestamp); + if (sceAu.pts >= ctx->mediaengine->getLastTimeStamp()) { + INFO_LOG(HLE, "video end reach. pts: %i dts: %i", (int)sceAu.pts, (int)ctx->mediaengine->getLastTimeStamp()); mpegRingbuffer.packetsFree = mpegRingbuffer.packets; Memory::WriteStruct(ctx->mpegRingbufferAddr, &mpegRingbuffer); diff --git a/Core/HW/MediaEngine.cpp b/Core/HW/MediaEngine.cpp index d32b186689..2b98f1a905 100644 --- a/Core/HW/MediaEngine.cpp +++ b/Core/HW/MediaEngine.cpp @@ -361,20 +361,14 @@ bool MediaEngine::stepVideo(int videoPixelMode) { pCodecCtx->height, m_pFrameRGB->data, m_pFrameRGB->linesize); if(frameFinished) { - if (m_videopts == 3003) { - m_audiopts = packet.pts; - } - m_videopts = packet.pts + packet.duration; + int firstTimeStamp = bswap32(*(int*)(m_pdata + 86)); + m_videopts = packet.pts + packet.duration - firstTimeStamp; bGetFrame = true; } } av_free_packet(&packet); if (bGetFrame) break; } - if (m_audiopts > 0) { - if (m_audiopts - m_videopts > 5000) - return stepVideo(videoPixelMode); - } return bGetFrame; #else return true; @@ -557,7 +551,7 @@ s64 MediaEngine::getVideoTimeStamp() { } s64 MediaEngine::getAudioTimeStamp() { - if (m_audiopts > 0) + if (m_demux) return m_audiopts; return m_videopts; } @@ -565,7 +559,8 @@ s64 MediaEngine::getAudioTimeStamp() { s64 MediaEngine::getLastTimeStamp() { if (!m_pdata) return 0; + int firstTimeStamp = bswap32(*(int*)(m_pdata + 86)); int lastTimeStamp = bswap32(*(int*)(m_pdata + 92)); - return lastTimeStamp; + return lastTimeStamp - firstTimeStamp; }