From 16902de6f4215ccd425622b92e8ae6be1ae4a97f Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 27 Aug 2010 10:42:16 +0200 Subject: [PATCH] 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; -- 2.30.2