Skip to content

Commit

Permalink
Playback: Fix DVD and Blu Ray seeking.
Browse files Browse the repository at this point in the history
The main problem here was that when paused, the seek position would
fallback to the current speed (i.e. 0) and playback would resume from
the beginning of the title.

With DVD playback, we were also asking the dvdnav object to seek to the
nearest cell - which led to some sizeable search discrepancies depending
where playback was relative to the nearest cell. We now ask for a more
accurate search.

N.B. I also tried to use a relative time search to the nearest cell
followed by a smaller absolute time search (as outline in the dvdnav
api) but this seemed to be even less accurate.

Refs #9305
  • Loading branch information
Mark Kendall committed Nov 9, 2011
1 parent 99483d6 commit 4b0803b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
14 changes: 5 additions & 9 deletions mythtv/libs/libmythtv/avformatdecoderbd.cpp
Expand Up @@ -34,9 +34,8 @@ bool AvFormatDecoderBD::DoRewindSeek(long long desiredFrame)
if (!ringBuffer->IsBD())
return false;

long long pos = BDFindPosition(desiredFrame);
ringBuffer->Seek(pos, SEEK_SET);
lastKey = desiredFrame + 1;
ringBuffer->Seek(BDFindPosition(desiredFrame), SEEK_SET);
framesPlayed = framesRead = lastKey = desiredFrame + 1;
return true;
}

Expand All @@ -45,12 +44,9 @@ void AvFormatDecoderBD::DoFastForwardSeek(long long desiredFrame, bool &needflus
if (!ringBuffer->IsBD())
return;

long long pos = BDFindPosition(desiredFrame);
ringBuffer->Seek(pos,SEEK_SET);
ringBuffer->Seek(BDFindPosition(desiredFrame), SEEK_SET);
needflush = true;
lastKey = desiredFrame+1;
framesPlayed = lastKey;
framesRead = lastKey;
framesPlayed = framesRead = lastKey = desiredFrame + 1;
}

void AvFormatDecoderBD::StreamChangeCheck(void)
Expand Down Expand Up @@ -98,7 +94,7 @@ long long AvFormatDecoderBD::BDFindPosition(long long desiredFrame)
current_speed = (int)m_parent->GetNextPlaySpeed();
}

if (ffrewSkip == 1)
if (ffrewSkip == 1 || ffrewSkip == 0)
{
diffTime = (int)ceil((desiredFrame - framesPlayed) / fps);
desiredTimePos = ringBuffer->BD()->GetCurrentTime() +
Expand Down
14 changes: 5 additions & 9 deletions mythtv/libs/libmythtv/avformatdecoderdvd.cpp
Expand Up @@ -89,9 +89,8 @@ bool AvFormatDecoderDVD::DoRewindSeek(long long desiredFrame)
if (!ringBuffer->IsDVD())
return false;

long long pos = DVDFindPosition(desiredFrame);
ringBuffer->Seek(pos, SEEK_SET);
lastKey = desiredFrame + 1;
ringBuffer->Seek(DVDFindPosition(desiredFrame), SEEK_SET);
framesPlayed = framesRead = lastKey = desiredFrame + 1;
return true;
}

Expand All @@ -100,12 +99,9 @@ void AvFormatDecoderDVD::DoFastForwardSeek(long long desiredFrame, bool &needflu
if (!ringBuffer->IsDVD())
return;

long long pos = DVDFindPosition(desiredFrame);
ringBuffer->Seek(pos,SEEK_SET);
ringBuffer->Seek(DVDFindPosition(desiredFrame),SEEK_SET);
needflush = true;
lastKey = desiredFrame+1;
framesPlayed = lastKey;
framesRead = lastKey;
framesPlayed = framesRead = lastKey = desiredFrame + 1;
}

void AvFormatDecoderDVD::StreamChangeCheck(void)
Expand Down Expand Up @@ -157,7 +153,7 @@ long long AvFormatDecoderDVD::DVDFindPosition(long long desiredFrame)
current_speed = (int)m_parent->GetNextPlaySpeed();
}

if (ffrewSkip == 1)
if (ffrewSkip == 1 || ffrewSkip == 0)
{
diffTime = (int)ceil((desiredFrame - framesPlayed) / fps);
desiredTimePos = ringBuffer->DVD()->GetCurrentTime() +
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/dvdringbuffer.cpp
Expand Up @@ -244,7 +244,7 @@ long long DVDRingBuffer::Seek(long long time)
if (m_parent)
ffrewSkip = m_parent->GetFFRewSkip();

if (ffrewSkip != 1 && time != 0)
if (ffrewSkip != 1 && ffrewSkip != 0 && time != 0)
{
QMap<uint, uint>::const_iterator it = m_seekSpeedMap.lowerBound(labs(time));
if (it == m_seekSpeedMap.end())
Expand All @@ -258,7 +258,7 @@ long long DVDRingBuffer::Seek(long long time)
else
{
m_seektime = (uint64_t)time;
dvdRet = dvdnav_absolute_time_search(m_dvdnav, m_seektime, 1);
dvdRet = dvdnav_absolute_time_search(m_dvdnav, m_seektime, 0);
}

LOG(VB_PLAYBACK, LOG_DEBUG,
Expand Down

0 comments on commit 4b0803b

Please sign in to comment.