From a648830a100839cb95548cffe2a6cd291f8da19c Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 17 Aug 2010 10:18:13 +0200 Subject: Playback/Skipping fixes / cleanup by A. Holst * Jumping between marks in the movie, with "<" and ">", doesn't work well when there are cut marks in the movie. Especially jumping backwards will fail if there is a mark in a cut out region that is to be jumped over. (InfoBarGenerics.py, chunks 3 and 4) * Now when rewind works at all platforms also at low speeds, the rewind speeds x2 and x4 should be added again to the default. (UsageConfig.py, chunk 1) * Cleanup some obsolete code: SeekBackHack and non-smooth winding. None of these can be used anymore, but remnants were left in the code and in the configuration alternatives. It is high time to clean these out. (setup.xml, UsageConfig.py chunk 2, InfoBarGenerics.py chunks 1 and 2, DVDPlayer) * In the position gauge of the movie player, marks in the movie are shown as red dots. Long time ago the last position was also shown as a red dot, which was bad because it was confused with the marks, so it was removed. However, jumping between marks in the movie with "<" and ">" also stops at the last position, which is useful e.g. if you don't automatically start playing from the last position. The code below adds the last position back to the position gauge as a green dot, to distinguish it from the red ones. (epositiongauge.cpp) refs bug #570 --- data/setup.xml | 25 +++------------- lib/dvb/pvrparse.cpp | 2 +- lib/gui/epositiongauge.cpp | 22 +++++++++----- lib/python/Components/UsageConfig.py | 4 +-- lib/python/Plugins/Extensions/DVDPlayer/plugin.py | 8 +---- lib/python/Screens/InfoBarGenerics.py | 36 ++++++++++------------- 6 files changed, 37 insertions(+), 60 deletions(-) diff --git a/data/setup.xml b/data/setup.xml index 9425afda..fa8ff3f9 100644 --- a/data/setup.xml +++ b/data/setup.xml @@ -45,27 +45,10 @@ config.seek.speeds_forward config.seek.speeds_backward config.seek.speeds_slowmotion - - config.seek.enter_forward - config.seek.enter_backward - - config.seek.stepwise_minspeed - config.seek.stepwise_repeat + + config.seek.enter_forward + config.seek.enter_backward config.seek.on_pause config.usage.pip_zero_button config.usage.alternatives_priority diff --git a/lib/dvb/pvrparse.cpp b/lib/dvb/pvrparse.cpp index 5cdecbd6..e19dd1e4 100644 --- a/lib/dvb/pvrparse.cpp +++ b/lib/dvb/pvrparse.cpp @@ -123,7 +123,7 @@ void eMPEGStreamInformation::fixupDiscontinuties() pts_t current = i->second - currentDelta; pts_t diff = current - lastpts_t; - if (llabs(diff) > (90000*5)) // 5sec diff + if (llabs(diff) > (90000*10)) // 10sec diff { // eDebug("%llx < %llx, have discont. new timestamp is %llx (diff is %llx)!", current, lastpts_t, i->second, diff); currentDelta = i->second - lastpts_t; /* FIXME: should be the extrapolated new timestamp, based on the current rate */ diff --git a/lib/gui/epositiongauge.cpp b/lib/gui/epositiongauge.cpp index ff98c080..e45d4a6c 100644 --- a/lib/gui/epositiongauge.cpp +++ b/lib/gui/epositiongauge.cpp @@ -112,6 +112,7 @@ int ePositionGauge::event(int event, void *data, void *data2) // painter.fill(eRect(0, 10, s.width(), s.height()-20)); pts_t in = 0, out = 0; + int xm, xm_last = -1; std::multiset::iterator i(m_cue_entries.begin()); @@ -126,17 +127,22 @@ int ePositionGauge::event(int event, void *data, void *data2) continue; } else if (i->what == 1) /* out */ out = i++->where; - else if (i->what == 2) /* mark */ + else /* mark or last */ { - int xm = scale(i->where); - painter.setForegroundColor(gRGB(0xFF8080)); - painter.fill(eRect(xm - 2, 0, 4, s.height())); + xm = scale(i->where); + if (i->what == 2) { + painter.setForegroundColor(gRGB(0xFF8080)); + if (xm - 2 < xm_last) /* Make sure last is not overdrawn */ + painter.fill(eRect(xm_last, 0, 2 + xm - xm_last, s.height())); + else + painter.fill(eRect(xm - 2, 0, 4, s.height())); + } else if (i->what == 3) { + painter.setForegroundColor(gRGB(0x80FF80)); + painter.fill(eRect(xm - 1, 0, 3, s.height())); + xm_last = xm + 2; + } i++; continue; - } else /* other marker, like last position */ - { - ++i; - continue; } } diff --git a/lib/python/Components/UsageConfig.py b/lib/python/Components/UsageConfig.py index 60827107..c0213d99 100644 --- a/lib/python/Components/UsageConfig.py +++ b/lib/python/Components/UsageConfig.py @@ -93,13 +93,11 @@ def InitUsageConfig(): config.seek.selfdefined_79 = ConfigNumber(default=300) config.seek.speeds_forward = ConfigSet(default=[2, 4, 8, 16, 32, 64, 128], choices=[2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128]) - config.seek.speeds_backward = ConfigSet(default=[8, 16, 32, 64, 128], choices=[1, 2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128]) + config.seek.speeds_backward = ConfigSet(default=[2, 4, 8, 16, 32, 64, 128], choices=[1, 2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128]) config.seek.speeds_slowmotion = ConfigSet(default=[2, 4, 8], choices=[2, 4, 6, 8, 12, 16, 25]) config.seek.enter_forward = ConfigSelection(default = "2", choices = ["2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"]) config.seek.enter_backward = ConfigSelection(default = "1", choices = ["1", "2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"]) - config.seek.stepwise_minspeed = ConfigSelection(default = "16", choices = ["Never", "2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"]) - config.seek.stepwise_repeat = ConfigSelection(default = "3", choices = ["2", "3", "4", "5", "6"]) config.seek.on_pause = ConfigSelection(default = "play", choices = [ ("play", _("Play")), diff --git a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py index e092e82f..3d262c92 100755 --- a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py @@ -222,8 +222,6 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP self.saved_config_speeds_backward = config.seek.speeds_backward.value self.saved_config_enter_forward = config.seek.enter_forward.value self.saved_config_enter_backward = config.seek.enter_backward.value - self.saved_config_seek_stepwise_minspeed = config.seek.stepwise_minspeed.value - self.saved_config_seek_stepwise_repeat = config.seek.stepwise_repeat.value self.saved_config_seek_on_pause = config.seek.on_pause.value self.saved_config_seek_speeds_slowmotion = config.seek.speeds_slowmotion.value @@ -233,8 +231,6 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP config.seek.speeds_slowmotion.value = [ ] config.seek.enter_forward.value = "2" config.seek.enter_backward.value = "2" - config.seek.stepwise_minspeed.value = "Never" - config.seek.stepwise_repeat.value = "3" config.seek.on_pause.value = "play" def restore_infobar_seek_config(self): @@ -243,8 +239,6 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP config.seek.speeds_slowmotion.value = self.saved_config_seek_speeds_slowmotion config.seek.enter_forward.value = self.saved_config_enter_forward config.seek.enter_backward.value = self.saved_config_enter_backward - config.seek.stepwise_minspeed.value = self.saved_config_seek_stepwise_minspeed - config.seek.stepwise_repeat.value = self.saved_config_seek_stepwise_repeat config.seek.on_pause.value = self.saved_config_seek_on_pause def __init__(self, session, dvd_device = None, dvd_filelist = [ ], args = None): @@ -256,7 +250,7 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP HelpableScreen.__init__(self) self.save_infobar_seek_config() self.change_infobar_seek_config() - InfoBarSeek.__init__(self, useSeekBackHack=False) + InfoBarSeek.__init__(self) InfoBarPVRState.__init__(self) self.dvdScreen = self.session.instantiateDialog(DVDOverlay) diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index f98d4c33..4bcadef9 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -716,7 +716,7 @@ class InfoBarSeek: SEEK_STATE_PAUSE = (1, 0, 0, "||") SEEK_STATE_EOF = (1, 0, 0, "END") - def __init__(self, actionmap = "InfobarSeekActions", useSeekBackHack=True): + def __init__(self, actionmap = "InfobarSeekActions"): self.__event_tracker = ServiceEventTracker(screen=self, eventmap= { iPlayableService.evSeekableStatusChanged: self.__seekableStatusChanged, @@ -773,20 +773,10 @@ class InfoBarSeek: self.__seekableStatusChanged() def makeStateForward(self, n): -# minspeed = config.seek.stepwise_minspeed.value -# repeat = int(config.seek.stepwise_repeat.value) -# if minspeed != "Never" and n >= int(minspeed) and repeat > 1: -# return (0, n * repeat, repeat, ">> %dx" % n) -# else: - return (0, n, 0, ">> %dx" % n) + return (0, n, 0, ">> %dx" % n) def makeStateBackward(self, n): -# minspeed = config.seek.stepwise_minspeed.value -# repeat = int(config.seek.stepwise_repeat.value) -# if minspeed != "Never" and n >= int(minspeed) and repeat > 1: -# return (0, -n * repeat, repeat, "<< %dx" % n) -# else: - return (0, -n, 0, "<< %dx" % n) + return (0, -n, 0, "<< %dx" % n) def makeStateSlowMotion(self, n): return (0, 0, n, "/%d" % n) @@ -2084,20 +2074,21 @@ class InfoBarCueSheetSupport: return True def jumpPreviousMark(self): - # we add 2 seconds, so if the play position is <2s after + # we add 5 seconds, so if the play position is <5s after # the mark, the mark before will be used self.jumpPreviousNextMark(lambda x: -x-5*90000, start=True) def jumpNextMark(self): - if not self.jumpPreviousNextMark(lambda x: x): + if not self.jumpPreviousNextMark(lambda x: x-90000): self.doSeek(-1) def getNearestCutPoint(self, pts, cmp=abs, start=False): # can be optimized - beforecut = False + beforecut = True nearest = None + bestdiff = -1 + instate = True if start: - beforecut = True bestdiff = cmp(0 - pts) if bestdiff >= 0: nearest = [0, False] @@ -2106,14 +2097,19 @@ class InfoBarCueSheetSupport: beforecut = False if cp[1] == self.CUT_TYPE_IN: # Start is here, disregard previous marks diff = cmp(cp[0] - pts) - if diff >= 0: + if start and diff >= 0: nearest = cp bestdiff = diff else: nearest = None - if cp[1] in (self.CUT_TYPE_MARK, self.CUT_TYPE_LAST): + bestdiff = -1 + if cp[1] == self.CUT_TYPE_IN: + instate = True + elif cp[1] == self.CUT_TYPE_OUT: + instate = False + elif cp[1] in (self.CUT_TYPE_MARK, self.CUT_TYPE_LAST): diff = cmp(cp[0] - pts) - if diff >= 0 and (nearest is None or bestdiff > diff): + if instate and diff >= 0 and (nearest is None or bestdiff > diff): nearest = cp bestdiff = diff return nearest -- cgit v1.2.3 From 16902de6f4215ccd425622b92e8ae6be1ae4a97f Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 27 Aug 2010 10:42:16 +0200 Subject: Another seek fix by Aholst from the enigma2-devel ml ------------------------------------------------------------------ And one more fix on this theme: rewind and higher than 8 times forward doesn't work for some movies. It turns out that when I and Felix communicated about the "accurate speed winding" that he eventually implemented, introducing the .sc files, we both made a false assumption (sorry if I lead you into it), that it was enough to jump to an I-frame picture start. However, it appears that (for an SD-movie that is) one should jump to the sequence start instead. (This is actually what the c++-code already does when dealing with the .ap-file, but not for the .sc) Since most movies have the sequence and picture start in the same ts-frame it usually doesn't matter. But there are movies out there with the sequence start in a ts-frame before the picture start, and for them rewind and very fast forward currently just freezes playback instead. The below patch fixes that. It just backs up through .sc to the previous sequence start once the picture start is found. Also, alignment has to be done here again and not in dvb.cpp, to get the right winding speed. Please ask me for the full technical details if something is unclear. ------------------------------------------------------------------ refs bug #570 --- lib/dvb/tstools.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/dvb/tstools.cpp b/lib/dvb/tstools.cpp index d5ad2494..a0e4eb15 100644 --- a/lib/dvb/tstools.cpp +++ b/lib/dvb/tstools.cpp @@ -698,9 +698,23 @@ int eDVBTSTools::findFrame(off_t &_offset, size_t &len, int &direction, int fram else if (direction == +1) direction = 0; } - /* let's find the next frame after the given offset */ off_t start = offset; + /* backtrack to find the previous sequence start, in case of MPEG2 */ + if ((data & 0xFF) == 0x00) { + do { + --start; + if (m_streaminfo.getStructureEntry(start, data, 0)) + { + eDebug("get previous failed"); + return -1; + } + } while (((data & 0xFF) != 9) && ((data & 0xFF) != 0x00) && ((data & 0xFF) != 0xB3)); /* sequence start or previous frame */ + if ((data & 0xFF) != 0xB3) + start = offset; /* Failed to find corresponding sequence start, so never mind */ + } + + /* let's find the next frame after the given offset */ do { if (m_streaminfo.getStructureEntry(offset, data, 1)) { @@ -716,8 +730,8 @@ int eDVBTSTools::findFrame(off_t &_offset, size_t &len, int &direction, int fram } while (((data & 0xFF) != 9) && ((data & 0xFF) != 0x00)); /* next frame */ /* align to TS pkt start */ -// start = start - (start % 188); -// offset = offset - (offset % 188); + start = start - (start % 188); + offset = offset - (offset % 188); len = offset - start; _offset = start; -- cgit v1.2.3 From 0c264458b72ac77a0129c8a702d3e8dad70f0e49 Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 30 Nov 2010 01:51:02 +0100 Subject: disable backtrack to prev sequence start code this code have to be reviewed.. it breaks fast forward winding with speed > 32x refs #570 --- lib/dvb/tstools.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/dvb/tstools.cpp b/lib/dvb/tstools.cpp index a0e4eb15..438f6d60 100644 --- a/lib/dvb/tstools.cpp +++ b/lib/dvb/tstools.cpp @@ -700,6 +700,7 @@ int eDVBTSTools::findFrame(off_t &_offset, size_t &len, int &direction, int fram } off_t start = offset; +#if 0 /* backtrack to find the previous sequence start, in case of MPEG2 */ if ((data & 0xFF) == 0x00) { do { @@ -714,6 +715,8 @@ int eDVBTSTools::findFrame(off_t &_offset, size_t &len, int &direction, int fram start = offset; /* Failed to find corresponding sequence start, so never mind */ } +#endif + /* let's find the next frame after the given offset */ do { if (m_streaminfo.getStructureEntry(offset, data, 1)) @@ -729,9 +732,11 @@ int eDVBTSTools::findFrame(off_t &_offset, size_t &len, int &direction, int fram // eDebug("%08llx@%llx (next)", data, offset); } while (((data & 0xFF) != 9) && ((data & 0xFF) != 0x00)); /* next frame */ +#if 0 /* align to TS pkt start */ start = start - (start % 188); offset = offset - (offset % 188); +#endif len = offset - start; _offset = start; -- cgit v1.2.3