summaryrefslogtreecommitdiff
path: root/cutter.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2012-06-10 14:33:36 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2012-06-10 14:33:36 +0200
commit478027b5e99c87238a149382bd0b512fbf395882 (patch)
tree2ac87daca8aff9c22ee35a8fe533e56ca089a5e7 /cutter.c
parent6dec09a376802cffaf719ec1d87e31cf02afc22d (diff)
downloadvdr-478027b5e99c87238a149382bd0b512fbf395882.tar.gz
vdr-478027b5e99c87238a149382bd0b512fbf395882.tar.bz2
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
Diffstat (limited to 'cutter.c')
-rw-r--r--cutter.c32
1 files changed, 29 insertions, 3 deletions
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