From patchwork Sat Nov 10 20:13:56 2007 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinhard Nissl X-Patchwork-Id: 12546 Received: from mail.gmx.net ([213.165.64.20]) by www.linuxtv.org with smtp (Exim 4.63) (envelope-from ) id 1Iqwis-0007B6-4I for vdr@linuxtv.org; Sat, 10 Nov 2007 21:14:30 +0100 Received: (qmail invoked by alias); 10 Nov 2007 20:13:57 -0000 Received: from p549305CA.dip0.t-ipconnect.de (EHLO [192.168.101.15]) [84.147.5.202] by mail.gmx.net (mp016) with SMTP; 10 Nov 2007 21:13:57 +0100 X-Authenticated: #527675 X-Provags-ID: V01U2FsdGVkX18uwCkhaNwuhFXvhsd8io8EuKJ1yoZRcXU5XgWmKX Gh0fQJzfxS367b Message-ID: <47361104.8000709@gmx.de> Date: Sat, 10 Nov 2007 21:13:56 +0100 From: Reinhard Nissl User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.8.1.6) Gecko/20070801 SUSE/2.0.0.6-22 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: VDR Mailing List References: <4730C741.8030503@gmx.de> <4735B35E.7030801@cadsoft.de> <4735BEB7.8020608@gmx.de> <4735C1CF.7000100@cadsoft.de> <4735DB4A.1080808@gmx.de> In-Reply-To: <4735DB4A.1080808@gmx.de> X-Y-GMX-Trusted: 0 Subject: Re: [vdr] vdr-1.5.11 & subtitling problems X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.9 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Nov 2007 20:14:30 -0000 Status: O X-Status: X-Keywords: X-UID: 14496 Hi, Reinhard Nissl schrieb: >>> Though, a cleaner solution would be to fix the result buffer to allow >>> retrieving any packet as soon as it is completely available in the >>> buffer (final subtitle packets are about 100 bytes in size). >> >> That sounds like the right thing to do. >> Can you suggest a patch for this? > > I hope to get something ready till tomorrow 12:00. See attachment. Tested in transfer mode with audio packets only (= radio), as there is no broadcast running which would provide subtitles. Bye. --- ../vdr-1.5.11-orig/ringbuffer.h 2005-12-10 11:54:51.000000000 +0100 +++ ringbuffer.h 2007-11-10 21:05:47.000000000 +0100 @@ -60,12 +60,17 @@ private: int gotten; uchar *buffer; char *description; + bool assumePesContent; + bool HasPesPacket(int &Count); public: - cRingBufferLinear(int Size, int Margin = 0, bool Statistics = false, const char *Description = NULL); + cRingBufferLinear(int Size, int Margin = 0, bool Statistics = false, const char *Description = NULL, bool AssumePesContent = false); ///< Creates a linear ring buffer. ///< The buffer will be able to hold at most Size-Margin-1 bytes of data, and will ///< be guaranteed to return at least Margin bytes in one consecutive block. ///< The optional Description is used for debugging only. + ///< AssumePesContent specializes the buffer and changes its behavior when less + ///< than Margin bytes are available. The buffer is then allowed to return at + ///< least a complete PES packet. virtual ~cRingBufferLinear(); virtual int Available(void); virtual int Free(void) { return Size() - Available() - 1 - margin; } --- ../vdr-1.5.11-orig/ringbuffer.c 2006-06-16 11:32:13.000000000 +0200 +++ ringbuffer.c 2007-11-10 21:05:47.000000000 +0100 @@ -151,9 +151,10 @@ void cRingBufferLinear::PrintDebugRBL(vo } #endif -cRingBufferLinear::cRingBufferLinear(int Size, int Margin, bool Statistics, const char *Description) +cRingBufferLinear::cRingBufferLinear(int Size, int Margin, bool Statistics, const char *Description, bool AssumePesContent) :cRingBuffer(Size, Statistics) { + assumePesContent = AssumePesContent; description = Description ? strdup(Description) : NULL; tail = head = margin = Margin; gotten = 0; @@ -299,7 +300,7 @@ uchar *cRingBufferLinear::Get(int &Count int cont = (diff >= 0) ? diff : Size() + diff - margin; if (cont > rest) cont = rest; - if (cont >= margin) { + if (cont >= margin || assumePesContent && HasPesPacket(cont)) { p = buffer + tail; Count = gotten = cont; } @@ -308,6 +309,19 @@ uchar *cRingBufferLinear::Get(int &Count return p; } +bool cRingBufferLinear::HasPesPacket(int &Count) +{ + uchar *p = buffer + tail; + if (Count >= 6 && !p[0] && !p[1] && p[2] == 0x01) { + int Length = 6 + p[4] * 256 + p[5]; + if (Length <= Count) { + Count = Length; + return true; + } + } + return false; +} + void cRingBufferLinear::Del(int Count) { if (Count > gotten) { --- ../vdr-1.5.11-orig/remux.c 2007-11-03 15:18:07.000000000 +0100 +++ remux.c 2007-11-10 21:05:47.000000000 +0100 @@ -1883,7 +1883,7 @@ cRemux::cRemux(int VPid, const int *APid skipped = 0; numTracks = 0; resultSkipped = 0; - resultBuffer = new cRingBufferLinear(RESULTBUFFERSIZE, IPACKS, false, "Result"); + resultBuffer = new cRingBufferLinear(RESULTBUFFERSIZE, IPACKS, false, "Result", true); resultBuffer->SetTimeouts(0, 100); if (VPid) #define TEST_cVideoRepacker