diff --git a/CONTRIBUTORS b/CONTRIBUTORS index eb8cf682..7353542a 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2873,6 +2873,8 @@ Torsten Lang for reporting a bug in checking for UTF-8 support in cFont::Bidi() for a patch that was used to implement caching the information whether a recording is stored on the video directory file system within the cRecording data + for suppressing setting the "broken link" or "TEI" flags when cutting recordings + if the editing point merges two seamlessly fitting parts of the same stream Christian Ruppert for some improvements to the Makefiles diff --git a/HISTORY b/HISTORY index ad8992e4..cd0b2a70 100644 --- a/HISTORY +++ b/HISTORY @@ -7179,3 +7179,6 @@ Video Disk Recorder Revision History - Fixed handling recording with more than two bonded devices. - Fixed the type of MBperMinute in cVideoDiskUsage::HasChanged() (thanks to Andreas Mair). +- Setting the "broken link" or "TEI" flags when cutting recordings is now suppressed + if the editing point merges two seamlessly fitting parts of the same stream (thanks + to Torsten Lang). diff --git a/cutter.c b/cutter.c index eb8f8206..62eae822 100644 --- a/cutter.c +++ b/cutter.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: cutter.c 2.12 2012/06/02 13:46:55 kls Exp $ + * $Id: cutter.c 2.13 2012/06/10 14:33:36 kls Exp $ */ #include "cutter.h" @@ -83,7 +83,9 @@ void cCuttingThread::Action(void) int LastIFrame = 0; toMarks.Add(0); toMarks.Save(); - uchar buffer[MAXFRAMESIZE]; + uchar buffer[MAXFRAMESIZE], buffer2[MAXFRAMESIZE]; + int Length2; + bool CheckForSeamlessStream = false; bool LastMark = false; bool cutIn = true; while (Running()) { @@ -142,7 +144,21 @@ void cCuttingThread::Action(void) FileSize = 0; } LastIFrame = 0; - + // Compare the current frame with the previously stored one, to see if this is a seamlessly merged recording of the same stream: + if (CheckForSeamlessStream) { + if (Length == Length2) { + int diffs = 0; + for (int i = 0; i < Length; i++) { + if (buffer[i] != buffer2[i]) { + if (diffs++ > 10) + break; + } + } + if (diffs < 10) // the continuity counters of the PAT/PMT packets may differ + cutIn = false; // it's apparently a seamless stream, so no need for "broken" handling + } + CheckForSeamlessStream = false; + } if (cutIn) { if (isPesRecording) cRemux::SetBrokenLink(buffer, Length); @@ -172,6 +188,16 @@ void cCuttingThread::Action(void) toMarks.Add(toIndex->Last() + 1); toMarks.Save(); if (Mark) { + // Read the next frame, for later comparison with the first frame at this mark: + if (fromIndex->Get(Index, &FileNumber, &FileOffset, &Independent, &Length2)) { + if (FileNumber != CurrentFileNumber) + fromFile = fromFileName->SetOffset(FileNumber, FileOffset); + if (fromFile) { + int len = ReadFrame(fromFile, buffer2, Length2, sizeof(buffer2)); + if (len >= 0 && len == Length2) + CheckForSeamlessStream = true; + } + } Index = Mark->Position(); Mark = fromMarks.Next(Mark); CurrentFileNumber = 0; // triggers SetOffset before reading next frame