VDR-1.3.22: Bug in cDolbyRepacker concerns today's HDTV event on ProSieben HD

Message ID 4234284C.5010706@gmx.de
State New
Headers

Commit Message

Reinhard Nissl March 13, 2005, 11:47 a.m. UTC
  Hi,

while looking forward to this evenings HDTV event 'Spiderman' on 
ProSieben HD I've just discovered a bug in my cDolbyRepacker which drops 
almost every audio PTS.

Some more details:
ProSieben HD broadcasts audio PES packets which may contain incomplete 
AC3 frames (dolby audio). The remainder of such a frame will then be at 
the beginning of the   n e x t   audio PES packet and afterwards the (a 
fragment) of the   n e x t   AC3 frame will follow.

If such a next audio PES packet had a PTS, it got dropped instead of 
beeing applied to the next AC3 frame.

The result was that AC3 frames didn't have PTS for several seconds and 
thus made e. g. xine think of audio discontinueties.

Bye.
  

Comments

Grégoire Favre March 13, 2005, 1:57 p.m. UTC | #1
On Sun, Mar 13, 2005 at 12:47:24PM +0100, Reinhard Nissl wrote:

Hello :-)

> while looking forward to this evenings HDTV event 'Spiderman' on 
> ProSieben HD I've just discovered a bug in my cDolbyRepacker which drops 
> almost every audio PTS.

Thank you very much for your patch, that I have just applied to my vdr!

Where could I find info about when they are events on ProSieben HD ?
  
Gerald Raaf March 13, 2005, 2:24 p.m. UTC | #2
Am Sonntag, 13. März 2005 14:57 schrieb Grégoire Favre:
> On Sun, Mar 13, 2005 at 12:47:24PM +0100, Reinhard Nissl wrote:
>
> Hello :-)
>
> > while looking forward to this evenings HDTV event 'Spiderman' on
> > ProSieben HD I've just discovered a bug in my cDolbyRepacker which drops
> > almost every audio PTS.
>
> Thank you very much for your patch, that I have just applied to my vdr!
>
> Where could I find info about when they are events on ProSieben HD ?

Hi,

that latest Info about HDTV Events i found, was on "Heise Newsticker"
here's the link

http://www.heise.de/newsticker/result.xhtml?url=/newsticker/meldung/56988&words=pro%20sieben
  
Grégoire Favre March 13, 2005, 2:30 p.m. UTC | #3
On Sun, Mar 13, 2005 at 03:24:09PM +0100, Gerald Raaf wrote:

Hello,

> that latest Info about HDTV Events i found, was on "Heise Newsticker"
> here's the link
> 
> http://www.heise.de/newsticker/result.xhtml?url=/newsticker/meldung/56988&words=pro%20sieben

I should have put that link I also found on vdr wiki, but unfortunately
it don't tell us when they boradcast it exactly...

Anyway, thank for your answer,
  

Patch

--- ../vdr-1.3.22-orig/remux.c	2005-02-13 15:36:23.000000000 +0100
+++ remux.c	2005-03-13 12:03:43.243312676 +0100
@@ -46,6 +46,8 @@  private:
   int fragmentTodo;
   uchar pesHeader[6 + 3 + 255 + 4 + 4];
   int pesHeaderLen;
+  uchar pesHeaderBackup[6 + 3 + 255];
+  int pesHeaderBackupLen;
   uchar chk1;
   uchar chk2;
   int ac3todo;
@@ -131,6 +133,7 @@  void cDolbyRepacker::Reset(void)
   chk2 = 0;
   fragmentLen = 0;
   fragmentTodo = 0;
+  pesHeaderBackupLen = 0;
 }
 
 bool cDolbyRepacker::FinishRemainder(cRingBufferLinear *ResultBuffer, const uchar *const Data, const int Todo, int &Done, int &Bite)
@@ -229,12 +232,17 @@  int cDolbyRepacker::Put(cRingBufferLinea
   if ((Data[6] & 0xC0) != 0x80)
      return 0;
 
+  // backup PES header
+  if (Data[6] != 0x80 || Data[7] != 0x00 || Data[8] != 0x00) {
+     pesHeaderBackupLen = 6 + 3 + Data[8];
+     memcpy(pesHeaderBackup, Data, pesHeaderBackupLen);
+     }
+
   // skip PES header
   int done = 6 + 3 + Data[8];
   int todo = Count - done;
   const uchar *data = Data + done;
-  bool headerCopied = false;
-  
+
   // look for 0x0B 0x77 <chk1> <chk2> <frameSize>
   while (todo > 0) {
         switch (state) {
@@ -242,10 +250,10 @@  int cDolbyRepacker::Put(cRingBufferLinea
                if (*data == 0x0B) {
                   ++(int &)state;
                   // copy header information once for later use
-                  if (!headerCopied) {
-                     headerCopied = true;
-                     pesHeaderLen = 6 + 3 + Data[8];
-                     memcpy(pesHeader, Data, pesHeaderLen);
+                  if (pesHeaderBackupLen > 0) {
+                     pesHeaderLen = pesHeaderBackupLen;
+                     pesHeaderBackupLen = 0;
+                     memcpy(pesHeader, pesHeaderBackup, pesHeaderLen);
                      AppendSubStreamID();
                      }
                   }
@@ -279,9 +287,8 @@  int cDolbyRepacker::Put(cRingBufferLinea
                ac3todo = 2 * frameSizes[*data];
                // frameSizeCode was invalid => restart searching
                if (ac3todo <= 0) {
-                  // reset PES header instead of using/copying a wrong one
+                  // reset PES header instead of using a wrong one
                   ResetPesHeader();
-                  headerCopied = true;
                   if (chk1 == 0x0B) {
                      if (chk2 == 0x77) {
                         state = store_chk1;