Mailing List archive

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

[vdr] Re: SPEEDUP: processing audio in transfer thread



Hi,

C.Y.M. wrote:

I have applied your patch to vdr-1.3.11 (using a Nexus-S) and it seems to
help my A/V desync problem on many of my recorded shows.  What seems to
happen is when the audio becomes desynced, the video speeds up for a split
second and comes back up to sync with the audio.  Is this what is supposed
to happen?
Strange is, that I didn't change anything in the last patch, that would have had any influence on replaying recordings.

The attached patch now also addresses replaying recordings and includes the padding stream optimization, because it was the only way to reduce CPU load when replaying dolby recordings with vdr-xine.

Let's see, if it works for full featured cards.

Bye.
--
Dipl.-Inform. (FH) Reinhard Nissl
mailto:rnissl@gmx.de
--- ../vdr-1.3.11-orig/dvbplayer.c	2004-06-19 10:55:49.000000000 +0200
+++ dvbplayer.c	2004-06-24 23:28:27.345513318 +0200
@@ -202,7 +202,7 @@ private:
   cFrame *playFrame;
   void TrickSpeed(int Increment);
   void Empty(void);
-  void StripAudioPackets(uchar *b, int Length, uchar Except = 0x00);
+  bool StripAudioPackets(uchar *b, int Length, uchar Except = 0x00);
   bool NextFile(uchar FileNumber = 0, int FileOffset = -1);
   int Resume(void);
   bool Save(void);
@@ -314,7 +314,7 @@ void cDvbPlayer::Empty(void)
   firstPacket = true;
 }
 
-void cDvbPlayer::StripAudioPackets(uchar *b, int Length, uchar Except)
+bool cDvbPlayer::StripAudioPackets(uchar *b, int Length, uchar Except)
 {
   if (index) {
      for (int i = 0; i < Length - 6; i++) {
@@ -329,8 +329,12 @@ void cDvbPlayer::StripAudioPackets(uchar
               case 0xC0 ... 0xC1: // audio
                    if (c == 0xC1)
                       canToggleAudioTrack = true;
-                   if (!Except || c != Except)
-                      memset(&b[i], 0x00, min(l, Length-i));
+                   if (!Except || c != Except) {
+                      if (i == 0 && l == Length) 
+                         return true; // drop complete frame
+                      b[ i + 3 ] = 0xBE; // padding stream
+                      memset(&b[i + 6], 0xFF, min(l, Length-i)-6);
+                      }
                    break;
               case 0xE0 ... 0xEF: // video
                    break;
@@ -347,6 +351,7 @@ void cDvbPlayer::StripAudioPackets(uchar
             XXX*/
          }
      }
+  return false;
 }
 
 bool cDvbPlayer::NextFile(uchar FileNumber, int FileOffset)
@@ -481,9 +486,14 @@ void cDvbPlayer::Action(void)
                  int r = nonBlockingFileReader->Read(replayFile, b, Length);
                  if (r > 0) {
                     if (AudioTrack == 0)
-                       StripAudioPackets(b, r);
-                    readFrame = new cFrame(b, -r, ftUnknown, readIndex); // hands over b to the ringBuffer
-                    b = NULL;
+                       if (StripAudioPackets(b, r)) {
+                          free(b); //drop complete frame
+                          b = NULL;
+                          }
+                    if (b) {
+                       readFrame = new cFrame(b, -r, ftUnknown, readIndex); // hands over b to the ringBuffer
+                       b = NULL;
+                       }
                     }
                  else if (r == 0)
                     eof = true;
@@ -523,7 +533,10 @@ void cDvbPlayer::Action(void)
                        firstPacket = false;
                        }
                     if (AudioTrack > 0)
-                       StripAudioPackets(p, pc, AudioTrack);
+                       if (StripAudioPackets(p, pc, AudioTrack)) {
+                          p = NULL; // drop complete frame
+                          pc = 0;
+                          }
                     }
                  }
               if (p) {
@@ -719,8 +732,8 @@ void cDvbPlayer::Goto(int Index, bool St
         if (r > 0) {
            if (playMode == pmPause)
               DevicePlay();
-           StripAudioPackets(b, r);
-           DeviceStillPicture(b, r);
+           if (!StripAudioPackets(b, r))
+              DeviceStillPicture(b, r);
            }
         playMode = pmStill;
         }
--- ../vdr-1.3.11-orig/transfer.c	2004-03-07 15:40:15.000000000 +0100
+++ transfer.c	2004-06-24 23:27:13.373523100 +0200
@@ -96,7 +98,8 @@ void cTransfer::Action(void)
            uchar *p = remux->Process(b, Count, Result);
            ringBuffer->Del(Count);
            if (p) {
-              StripAudioPackets(p, Result, audioTrack);
+              if (StripAudioPackets(p, Result, audioTrack))
+                 continue; // drop complete frame
               while (Result > 0 && active) {
                     cPoller Poller;
                     if (DevicePoll(Poller, 100)) {
@@ -126,7 +129,7 @@ void cTransfer::Action(void)
         }
 }
 
-void cTransfer::StripAudioPackets(uchar *b, int Length, uchar Except)
+bool cTransfer::StripAudioPackets(uchar *b, int Length, uchar Except)
 {
   for (int i = 0; i < Length - 6; i++) {
       if (b[i] == 0x00 && b[i + 1] == 0x00 && b[i + 2] == 0x01) {
@@ -140,8 +143,12 @@ void cTransfer::StripAudioPackets(uchar 
            case 0xC0 ... 0xC1: // audio
                 if (c == 0xC1)
                    canToggleAudioTrack = true;
-                if (!Except || c != Except)
-                   memset(&b[i], 0x00, min(l, Length-i));
+                if (!Except || c != Except) {
+                   if (i == 0 && l == Length)
+                      return true; // drop complete frame
+                   b[ i + 3 ] = 0xBE; // padding stream
+                   memset(&b[i + 6], 0xFF, min(l, Length-i)-6);
+                   }
                 break;
            case 0xE0 ... 0xEF: // video
                 break;
@@ -157,6 +164,7 @@ void cTransfer::StripAudioPackets(uchar 
          esyslog("ERROR: broken packet header");
          XXX*/
       }
+  return false;
 }
 
 int cTransfer::NumAudioTracks(void) const
--- ../vdr-1.3.11-orig/transfer.h	2003-05-11 10:48:36.000000000 +0200
+++ transfer.h	2004-06-23 21:43:56.000000000 +0200
@@ -24,7 +24,7 @@ private:
   uchar audioTrack;
   bool gotBufferReserve;
   bool active;
-  void StripAudioPackets(uchar *b, int Length, uchar Except = 0x00);
+  bool StripAudioPackets(uchar *b, int Length, uchar Except = 0x00);
 protected:
   virtual void Activate(bool On);
   virtual void Receive(uchar *Data, int Length);

Home | Main Index | Thread Index