mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-24 14:00:03 +00:00
Improve psmf seek perf and audio sync.
This commit is contained in:
parent
a429e5f8d6
commit
e522eea2b4
@ -367,10 +367,19 @@ bool MediaEngine::seekTo(s64 timestamp, int videoPixelMode) {
|
||||
// Just doing it the not so great way to be sure audio is in sync.
|
||||
int timeout = 1000;
|
||||
while (getVideoTimeStamp() < timestamp - 3003) {
|
||||
if (getAudioTimeStamp() < getVideoTimeStamp()) {
|
||||
if (getAudioTimeStamp() < getVideoTimeStamp() - 4180 * 2) {
|
||||
getNextAudioFrame(NULL, NULL, NULL);
|
||||
}
|
||||
if (!stepVideo(videoPixelMode)) {
|
||||
if (!stepVideo(videoPixelMode, true)) {
|
||||
return false;
|
||||
}
|
||||
if (--timeout <= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
while (getAudioTimeStamp() < getVideoTimeStamp() - 4180 * 2) {
|
||||
if (getNextAudioFrame(NULL, NULL, NULL) == 0) {
|
||||
return false;
|
||||
}
|
||||
if (--timeout <= 0) {
|
||||
@ -479,7 +488,7 @@ void MediaEngine::updateSwsFormat(int videoPixelMode) {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool MediaEngine::stepVideo(int videoPixelMode) {
|
||||
bool MediaEngine::stepVideo(int videoPixelMode, bool skipFrame) {
|
||||
#ifdef USE_FFMPEG
|
||||
auto codecIter = m_pCodecCtxs.find(m_videoStream);
|
||||
AVCodecContext *m_pCodecCtx = codecIter == m_pCodecCtxs.end() ? 0 : codecIter->second;
|
||||
@ -511,8 +520,10 @@ bool MediaEngine::stepVideo(int videoPixelMode) {
|
||||
|
||||
int result = avcodec_decode_video2(m_pCodecCtx, m_pFrame, &frameFinished, &packet);
|
||||
if (frameFinished) {
|
||||
sws_scale(m_sws_ctx, m_pFrame->data, m_pFrame->linesize, 0,
|
||||
m_pCodecCtx->height, m_pFrameRGB->data, m_pFrameRGB->linesize);
|
||||
if (!skipFrame) {
|
||||
sws_scale(m_sws_ctx, m_pFrame->data, m_pFrame->linesize, 0,
|
||||
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;
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
int getRemainSize();
|
||||
int getAudioRemainSize();
|
||||
|
||||
bool stepVideo(int videoPixelMode);
|
||||
bool stepVideo(int videoPixelMode, bool skipFrame = false);
|
||||
int writeVideoImage(u32 bufferPtr, int frameWidth = 512, int videoPixelMode = 3);
|
||||
int writeVideoImageWithRange(u32 bufferPtr, int frameWidth, int videoPixelMode,
|
||||
int xpos, int ypos, int width, int height);
|
||||
|
Loading…
Reference in New Issue
Block a user