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 14 Apr 2003 "Wiljo Heinen" <wiljo@offeryn.de> wrote:
>> > >
>> > > broken_GOP (it's called "broken link" in the standard) is exactly for
> the
>> > > purposes you have in mind:
>> > [...]
>> >
>> > Thanks. I'll try to modify the cutter and provide a patch in the
>> > next days.
>>
>> ... maybe also a seperate program or a change in dvbplayer.c for fixing
>> existing cuts would be a nice option.
>>
> 
> But still the Q remains, wether the player (driver ?) will honour the broken
> link flag. IMHO the method of removing the broken B-frames and adjusting the
> tempref values is still more reliable.

OK, find the attached patch which sets the broken link flag on
every "cuttIn" frame. I did only a short test. It still cuts
fine and it seems that the decoder honors the broken link flag.
The cutting points are smoother.

The problem of missing audio packets due to audio-video delay
still has to be solved.

Let me know what you (all) think.

Disclaimer: this is experimental code, not well tested. Don't
blame me, if it ruins a cut. Backup before testing!

diff -urN 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-15 10:53:56.000000000 +0200
@@ -23,6 +23,8 @@
   cFileName *fromFileName, *toFileName;
   cIndexFile *fromIndex, *toIndex;
   cMarks fromMarks, toMarks;
+  //
+  void BrokenLink(uchar *data, int len);
 protected:
   virtual void Action(void);
 public:
@@ -60,6 +62,26 @@
   delete toIndex;
 }
 
+void cCuttingThread::BrokenLink(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)) {
+          data[index+7] |= 0x20;
+          printf("setting broken link flag in CuttIn GOP\n");
+          }
+        else
+          printf("cuttIn GOP is closed\n");
+        return;
+        }
+      }
+    printf("no GOP header found in cuttIn video packet\n");
+    }
+  else printf("no video packet in cuttIn frame\n");
+}
+
 void cCuttingThread::Action(void)
 {
   dsyslog("video cutting thread started (pid=%d)", getpid());
@@ -77,6 +99,7 @@
      toMarks.Add(0);
      toMarks.Save();
      uchar buffer[MAXFRAMESIZE];
+     bool cuttIn = true;
      while (active) {
            uchar FileNumber;
            int FileOffset, Length;
@@ -126,6 +149,11 @@
                  FileSize = 0;
                  }
               LastIFrame = 0;
+
+              if(cuttIn) {
+                BrokenLink(buffer, Length);
+                cuttIn=false;
+                }
               }
            if (safe_write(toFile, buffer, Length) < 0) {
               error = "safe_write";
@@ -151,6 +179,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) {


-- 
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