From patchwork Sun Aug 28 21:02: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: 11998 Received: from mail.gmx.de ([213.165.64.20] helo=mail.gmx.net) by www.linuxtv.org with smtp (Exim 4.34) id 1E9UIt-0000R9-Q0 for vdr@linuxtv.org; Sun, 28 Aug 2005 23:02:59 +0200 Received: (qmail invoked by alias); 28 Aug 2005 21:02:28 -0000 Received: from dialin-145-254-230-025.arcor-ip.net (EHLO [192.168.101.15]) [145.254.230.25] by mail.gmx.net (mp020) with SMTP; 28 Aug 2005 23:02:28 +0200 X-Authenticated: #527675 Message-ID: <43122660.3010703@gmx.de> Date: Sun, 28 Aug 2005 23:02:24 +0200 From: Reinhard Nissl User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Klaus Schmidinger's VDR X-Y-GMX-Trusted: 0 Subject: [vdr] VDR-1.3.26-31: BUG in cVideo/AudioRepacker while syncing 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, 28 Aug 2005 21:02:59 -0000 Status: O X-Status: X-Keywords: X-UID: 4547 Hi, while looking at the code of cRepacker::Reset() for adding a comment why I was initializing variable "packetTodo" with the maximum value for MPEG2, I've discovered a bug in cVideo/AudioRepacker::Repack(): When resyncing took longer than packetTodo bytes then a result packet could have been generated with the data collected while syncing, which actually should have been omited. The other changes address the BreatAt() methods which shall do nothing while initially syncing to allow the packet buffer to fill to it's maximum size before it is repacked. As a result there is nolonger the need to initialize "packetTodo" to a certain value. I sincerely apologize for causing such difficulties and hope that the code is stable now. Bye. --- ../vdr-1.3.31-orig/remux.c 2005-08-28 13:46:44.000000000 +0200 +++ remux.c 2005-08-28 22:34:50.000000000 +0200 @@ -142,7 +142,7 @@ void cCommonRepacker::Reset(void) { cRepacker::Reset(); skippedBytes = 0; - packetTodo = maxPacketSize - 6 - 3; + packetTodo = 0; fragmentLen = 0; pesHeaderLen = 0; pesHeaderBackupLen = 0; @@ -361,7 +361,7 @@ void cVideoRepacker::Repack(cRingBufferL done++; todo--; // do we have to start a new packet as there is no more space left? - if (--packetTodo <= 0) { + if (state != syncing && --packetTodo <= 0) { // we connot start a new packet here if the current might end in a start // code and this start code shall possibly be put in the next packet. So // overfill the current packet until we can safely detect that we won't @@ -468,6 +468,9 @@ void cVideoRepacker::Repack(cRingBufferL int cVideoRepacker::BreakAt(const uchar *Data, int Count) { + if (initiallySyncing) + return -1; // fill the packet buffer completely until we have synced once + int PesPayloadOffset = 0; if (AnalyzePesHeader(Data, Count, PesPayloadOffset) <= phInvalid) @@ -732,7 +735,7 @@ void cAudioRepacker::Repack(cRingBufferL done++; todo--; // do we have to start a new packet as there is no more space left? - if (--packetTodo <= 0) { + if (state != syncing && --packetTodo <= 0) { // We connot start a new packet here if the current might end in an audio // frame header and this header shall possibly be put in the next packet. So // overfill the current packet until we can safely detect that we won't @@ -836,6 +839,9 @@ void cAudioRepacker::Repack(cRingBufferL int cAudioRepacker::BreakAt(const uchar *Data, int Count) { + if (initiallySyncing) + return -1; // fill the packet buffer completely until we have synced once + int PesPayloadOffset = 0; ePesHeader MpegLevel = AnalyzePesHeader(Data, Count, PesPayloadOffset); @@ -1189,6 +1195,9 @@ void cDolbyRepacker::Repack(cRingBufferL int cDolbyRepacker::BreakAt(const uchar *Data, int Count) { + if (initiallySyncing) + return -1; // fill the packet buffer completely until we have synced once + // enough data for test? if (Count < 6 + 3) return -1;