Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Smart preview pixmap offset.
Calculate the default preview pixmap offset, taking into account program duration and actual recording start time (including start early and time to record before start of show), as well as commercial flag list and cut list.

Removes redundant MythXML code that calculated the default offset and instead relies on the code in the preview generator.  This, plus the recent changes to MythWeb, means there's only one location in MythTV where the default preview pixmap offset is calculated.

Removes the PreviewPixmapOffset setting, which is no longer useful, now that each recording gets a customized offset.  In my testing, the new algorithm was significantly more reliable at finding good previews than the one-size-fits-all setting we used previously (whether at the default value or "tuned"), which used the exact same offset for every recording.


git-svn-id: http://svn.mythtv.org/svn/trunk@23993 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
sphery committed Apr 5, 2010
1 parent 3909478 commit edb680f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 28 deletions.
15 changes: 13 additions & 2 deletions mythtv/libs/libmythtv/NuppelVideoPlayer.cpp
Expand Up @@ -5752,9 +5752,11 @@ char *NuppelVideoPlayer::GetScreenGrabAtFrame(long long frameNum, bool absolute,
if (player_ctx->playingInfo)
player_ctx->playingInfo->GetCommBreakList(commBreakMap);

while ((FrameIsInMap(number, commBreakMap) ||
(FrameIsInMap(number, deleteMap))))
bool started_in_break_map = false;
while (FrameIsInMap(number, commBreakMap) ||
FrameIsInMap(number, deleteMap))
{
started_in_break_map = true;
number += (long long) (30 * video_frame_rate);
if (number >= totalFrames)
{
Expand All @@ -5765,6 +5767,15 @@ char *NuppelVideoPlayer::GetScreenGrabAtFrame(long long frameNum, bool absolute,

commBreakMapLock.unlock();
player_ctx->UnlockPlayingInfo(__FILE__, __LINE__);

// Advance a few seconds from the end of the break
if (started_in_break_map)
{
oldnumber = number;
number += (long long) (10 * video_frame_rate);
if (number >= totalFrames)
number = oldnumber;
}
}
}
}
Expand Down
24 changes: 22 additions & 2 deletions mythtv/libs/libmythtv/previewgenerator.cpp
Expand Up @@ -512,8 +512,28 @@ bool PreviewGenerator::LocalPreviewRun(void)
if (captime < 0)
{
timeInSeconds = true;
captime = (gContext->GetNumSetting("PreviewPixmapOffset", 64) +
gContext->GetNumSetting("RecordPreRoll", 0));
int startEarly = 0;
int programDuration = 0;
int preroll = gContext->GetNumSetting("RecordPreRoll", 0);
if (programInfo.startts.isValid() &&
programInfo.endts.isValid() &&
(programInfo.startts != programInfo.endts))
{
programDuration = programInfo.startts.secsTo(programInfo.endts);
}
if (programInfo.recstartts.isValid() &&
programInfo.startts.isValid() &&
(programInfo.recstartts != programInfo.startts))
{
startEarly = programInfo.recstartts.secsTo(programInfo.startts);
}
if (programDuration > 0)
{
captime = startEarly + (programDuration / 3);
}
if (captime < 0)
captime = 600;
captime += preroll;
}

len = width = height = sz = 0;
Expand Down
13 changes: 2 additions & 11 deletions mythtv/programs/mythbackend/mythxml.cpp
Expand Up @@ -1098,23 +1098,14 @@ void MythXML::GetPreviewImage( HTTPRequest *pRequest )
}

QString sFileName = GetPlaybackURL(pInfo);
int defaultOffset = gContext->GetNumSetting("PreviewPixmapOffset", 64);
int preRoll = gContext->GetNumSetting("RecordPreRoll", 0);

if (preRoll > 0)
defaultOffset += preRoll;

if (nSecsIn <= 0)
{
nSecsIn = defaultOffset;
}

// ----------------------------------------------------------------------
// check to see if default preview image is already created.
// ----------------------------------------------------------------------
QString sPreviewFileName;
if ((nSecsIn == defaultOffset))
if (nSecsIn <= 0)
{
nSecsIn = -1;
sPreviewFileName = sFileName + ".png";
}
else
Expand Down
13 changes: 0 additions & 13 deletions mythtv/programs/mythfrontend/globalsettings.cpp
Expand Up @@ -2147,18 +2147,6 @@ static HostSpinBox *LiveTVIdleTimeout()
return gs;
}

static GlobalSpinBox *PreviewPixmapOffset()
{
GlobalSpinBox *bs = new GlobalSpinBox("PreviewPixmapOffset", 0, 600, 1);
bs->setLabel(QObject::tr("Time offset for thumbnail preview images"));
bs->setHelpText(QObject::tr("MythTV will use this offset to make a "
"thumbnail image this many seconds from the beginning "
"of the recording, unless this offset happens to be "
"between cutpoints or inside a flagged advertisement."));
bs->setValue(64);
return bs;
}

static HostCheckBox *PlaybackPreview()
{
HostCheckBox *gc = new HostCheckBox("PlaybackPreview");
Expand Down Expand Up @@ -4358,7 +4346,6 @@ PlaybackSettings::PlaybackSettings()
pbox->addChild(PlayBoxOrdering());
pbox->addChild(PlayBoxEpisodeSort());
pbox->addChild(GeneratePreviewRemotely());
pbox->addChild(PreviewPixmapOffset());
pbox->addChild(PlaybackPreview());
pbox->addChild(HWAccelPlaybackPreview());
pbox->addChild(PBBStartInTitle());
Expand Down

0 comments on commit edb680f

Please sign in to comment.