From patchwork Sun Mar 13 11:47:24 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinhard Nissl X-Patchwork-Id: 11806 Received: from pop.gmx.de ([213.165.64.20] helo=mail.gmx.net) by www.linuxtv.org with smtp (Exim 4.34) id 1DARZU-0003zy-5r for vdr@linuxtv.org; Sun, 13 Mar 2005 12:47:48 +0100 Received: (qmail invoked by alias); 13 Mar 2005 11:47:25 -0000 Received: from D102e.d.pppool.de (EHLO [192.168.101.15]) (80.184.16.46) by mail.gmx.net (mp016) with SMTP; 13 Mar 2005 12:47:25 +0100 X-Authenticated: #527675 Message-ID: <4234284C.5010706@gmx.de> Date: Sun, 13 Mar 2005 12:47:24 +0100 From: Reinhard Nissl User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Klaus Schmidinger's VDR X-Priority: 1 (Highest) X-Y-GMX-Trusted: 0 Subject: [vdr] VDR-1.3.22: Bug in cDolbyRepacker concerns today's HDTV event on ProSieben HD X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Klaus Schmidinger's VDR List-Id: Klaus Schmidinger's VDR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Mar 2005 11:47:49 -0000 Status: O X-Status: X-Keywords: X-UID: 678 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. --- ../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 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;