Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: vdr cuts recordings with ugly artifacts at cutting-points



On 15 Apr 2003 s.huelswitt@gmx.de (Stefan Huelswitt) wrote:

> OK, find the attached patch which sets the broken link flag on
> every "cuttIn" frame. I did only a short test. It still cuts

I have modified the patch, so that the broken link flag is set
in the first video packet in a recording too.

The patch is available here too:
<http://www.muempf.de/down/vdr-1.1.27-cutter2.diff.gz>

diff -uN vdr-1.1.27-orig/cutter.c vdr-1.1.27-cutter/cutter.c
--- vdr-1.1.27-orig/cutter.c	2002-08-11 13:09:23.000000000 +0200
+++ vdr-1.1.27-cutter/cutter.c	2003-04-16 12:55:11.000000000 +0200
@@ -77,6 +77,7 @@
      toMarks.Add(0);
      toMarks.Save();
      uchar buffer[MAXFRAMESIZE];
+     bool cuttIn = true;
      while (active) {
            uchar FileNumber;
            int FileOffset, Length;
@@ -126,6 +127,11 @@
                  FileSize = 0;
                  }
               LastIFrame = 0;
+
+              if(cuttIn) {
+                cRemux::SetBrokenLink(buffer, Length);
+                cuttIn=false;
+                }
               }
            if (safe_write(toFile, buffer, Length) < 0) {
               error = "safe_write";
@@ -151,6 +157,7 @@
                  Index = Mark->position;
                  Mark = fromMarks.Next(Mark);
                  CurrentFileNumber = 0; // triggers SetOffset before reading next frame
+                 cuttIn = true;
                  if (Setup.SplitEditedFiles) {
                     toFile = toFileName->NextFile();
                     if (toFile < 0) {
diff -uN vdr-1.1.27-orig/remux.c vdr-1.1.27-cutter/remux.c
--- vdr-1.1.27-orig/remux.c	2003-01-24 18:22:29.000000000 +0100
+++ vdr-1.1.27-cutter/remux.c	2003-04-16 13:07:41.000000000 +0200
@@ -511,6 +511,24 @@
   return -1;
 }
 
+void cRemux::SetBrokenLink(uchar *data, int len)
+{
+  if(data[0]==0 && data[1]==0 && data[2]==1 && (data[3]&0xE0)==0xE0) {
+    int index=9+data[8]; // skip video packet header
+    for( ; index<len ; index++) {
+      if(data[index]==0 && data[index+1]==0 && data[index+2]==1 && data[index+3]==0xB8) {
+        if(!(data[index+7]&0x40)) { // set flag only if GOP is not closed
+          data[index+7] |= 0x20;
+          dsyslog("SetBrokenLink: setting broken link flag");
+          }
+        return;
+        }
+      }
+    dsyslog("SetBrokenLink: no GOP header found in video packet");
+    }
+  else dsyslog("SetBrokenLink: no video packet in frame");
+}
+
 #define TS_SYNC_BYTE 0x47
 
 uchar *cRemux::Process(const uchar *Data, int &Count, int &Result, uchar *PictureType)
@@ -622,6 +640,7 @@
                            if (pt == I_FRAME) {
                               resultDelivered = i; // will drop everything before this position
                               synced = true;
+                              SetBrokenLink(resultBuffer+i,l);
                               }
                            else {
                               resultDelivered = i + l; // will drop everything before and including this packet
diff -uN vdr-1.1.27-orig/remux.h vdr-1.1.27-cutter/remux.h
--- vdr-1.1.27-orig/remux.h	2002-11-01 11:06:46.000000000 +0100
+++ vdr-1.1.27-cutter/remux.h	2003-04-16 12:50:54.000000000 +0200
@@ -44,6 +44,7 @@
   cRemux(int VPid, int APid1, int APid2, int DPid1, int DPid2, bool ExitOnFailure = false);
   ~cRemux();
   uchar *Process(const uchar *Data, int &Count, int &Result, uchar *PictureType = NULL);
+  static void SetBrokenLink(uchar *data, int len);
   };
 
 #endif // __REMUX_H

-- 
Stefan Huelswitt
huels@iname.com  | http://home.pages.de/~nathan


-- 
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe vdr" as subject.



Home | Main Index | Thread Index