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. -- Dipl.-Inform. (FH) Reinhard Nissl mailto:rnissl@xxxxxx
--- ../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
_______________________________________________ vdr mailing list vdr@xxxxxxxxxxx http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr