Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dvdplayer: fixes for ff #7041

Merged
merged 4 commits into from May 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
Expand Up @@ -893,7 +893,11 @@ unsigned CDVDVideoCodecFFmpeg::GetAllowedReferences()

bool CDVDVideoCodecFFmpeg::GetCodecStats(double &pts, int &droppedPics)
{
pts = m_decoderPts;
if (m_decoderPts != DVD_NOPTS_VALUE)
pts = m_decoderPts;
else
pts = m_dts;

if (m_skippedDeint)
droppedPics = m_skippedDeint;
else
Expand Down
5 changes: 4 additions & 1 deletion xbmc/cores/dvdplayer/DVDPlayer.cpp
Expand Up @@ -1840,7 +1840,10 @@ void CDVDPlayer::HandlePlaySpeed()
// the the bigger is the error we allow
if (m_playSpeed > DVD_PLAYSPEED_NORMAL)
{
error /= m_playSpeed / DVD_PLAYSPEED_NORMAL;
int errorwin = m_playSpeed / DVD_PLAYSPEED_NORMAL;
if (errorwin > 8)
errorwin = 8;
error /= errorwin;
}

if(error > DVD_MSEC_TO_TIME(1000))
Expand Down
30 changes: 25 additions & 5 deletions xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
Expand Up @@ -465,7 +465,13 @@ void CDVDPlayerVideo::Process()
CDVDPlayer::SPlayerState& state = ((CDVDMsgType<CDVDPlayer::SPlayerState>*)pMsg)->m_value;

if(state.time_src == CDVDPlayer::ETIMESOURCE_CLOCK)
state.time = DVD_TIME_TO_MSEC(m_pClock->GetClock(state.timestamp) + state.time_offset);
{
double pts = GetCurrentPts();
if (pts == DVD_NOPTS_VALUE)
pts = m_pClock->GetClock();
state.time = DVD_TIME_TO_MSEC(pts + state.time_offset);
state.timestamp = CDVDClock::GetAbsoluteClock();
}
else
state.timestamp = CDVDClock::GetAbsoluteClock();
state.player = DVDPLAYER_VIDEO;
Expand Down Expand Up @@ -1086,7 +1092,7 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts)
CalcFrameRate();

// remember original pts, we need it later for overlaying subtitles
double ptsovl = pts;
double pts_org = pts;

// signal to clock what our framerate is, it may want to adjust it's
// speed to better match with our video renderer's output speed
Expand All @@ -1107,7 +1113,7 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts)
{
double inputPts = m_droppingStats.m_lastPts;
double renderPts = m_droppingStats.m_lastRenderPts;
if (pts > renderPts)
if (pts_org > renderPts)
{
if (inputPts >= renderPts)
{
Expand All @@ -1116,6 +1122,20 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts)
return result | EOS_DROPPED;
}
}
else if (m_speed > DVD_PLAYSPEED_NORMAL)
{
double iSleepTime, iRenderPts;
int iBufferLevel;
g_renderManager.GetStats(iSleepTime, iRenderPts, iBufferLevel);

double diff = pts_org - iRenderPts;
double mindiff = DVD_SEC_TO_TIME(1/m_fFrameRate * m_speed / DVD_PLAYSPEED_NORMAL) * (iBufferLevel +1);
if (diff < mindiff)
{
m_droppingStats.AddOutputDropGain(pts, 1/m_fFrameRate);
return result | EOS_DROPPED;
}
}

// calculate the time we need to delay this picture before displaying
double iSleepTime, iClockSleep, iFrameSleep, iPlayingClock, iCurrentClock;
Expand Down Expand Up @@ -1179,7 +1199,7 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts)
return EOS_DROPPED;
}

ProcessOverlays(pPicture, ptsovl);
ProcessOverlays(pPicture, pts_org);

int index = g_renderManager.AddVideoPicture(*pPicture);

Expand All @@ -1197,7 +1217,7 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts)
return EOS_DROPPED;
}

g_renderManager.FlipPage(CThread::m_bStop, (iCurrentClock + iSleepTime) / DVD_TIME_BASE, pts, -1, mDisplayField);
g_renderManager.FlipPage(CThread::m_bStop, (iCurrentClock + iSleepTime) / DVD_TIME_BASE, pts_org, -1, mDisplayField);

return result;
#else
Expand Down