From patchwork Mon Feb 19 21:01:20 2007 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinhard Nissl X-Patchwork-Id: 12439 Received: from mail.gmx.net ([213.165.64.20]) by www.linuxtv.org with smtp (Exim 4.50) id 1HJFf6-0002hQ-Jx for vdr@linuxtv.org; Mon, 19 Feb 2007 22:03:04 +0100 Received: (qmail invoked by alias); 19 Feb 2007 21:01:43 -0000 X-Provags-ID: V01U2FsdGVkX1/1bDMFwgL1mFOPbB910aQddf92xnqfqbd8PT6h2Z 9LtQ== Message-ID: <45DA1020.3090901@gmx.de> Date: Mon, 19 Feb 2007 22:01:20 +0100 From: Reinhard Nissl User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.9) Gecko/20060911 SUSE/1.5.0.9-0.1 Thunderbird/1.5.0.9 Mnenhy/0.7.4.666 MIME-Version: 1.0 To: VDR Mailing List Subject: Re: [vdr] FF card AV sync problems, possible fix to VDR (fwd) References: <45C24A06.60502@kniivila.com> <45C256AF.6@gmx.de> <45C260B6.7070309@kniivila.com> <45C270FA.7040804@gmx.de> <45D8AD0F.50600@kniivila.com> <45D8DD9A.6050602@gmx.de> <45D97DC8.3030505@kniivila.com> In-Reply-To: <45D97DC8.3030505@kniivila.com> X-Y-GMX-Trusted: 0 X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 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: Mon, 19 Feb 2007 21:03:04 -0000 Status: O X-Status: X-Keywords: X-UID: 12233 Hi, Kartsa wrote: > My log is actually full of these. The attached patch adds a TS packet logger to cAudioRepacker, which stores the last 1000 TS packets that led to synchronization of cAudioRepacker into a file to /video. In your logfile you'll then find lines like the following: Feb 19 21:41:36 video vdr: [9413] cAudioRepacker(0xC1): skipped 24 bytes to sync on next audio frame Feb 19 21:41:36 video vdr: [9413] cTSLogger: dumping to file '/video/ts_9353_9413_0xC1_000_12_12.log' Please provide me some of these files which were dumped in the "middle" of a recording. If size matters, you may reduce the number of packets to 100. Bye. --- ../vdr-1.4.5-orig/remux.c 2006-12-01 15:46:25.000000000 +0100 +++ remux.c 2007-02-19 21:39:41.000000000 +0100 @@ -86,6 +86,65 @@ ePesHeader AnalyzePesHeader(const uchar return phMPEG1; // MPEG 1 } +// --- cTSLogger ------------------------------------------------------------- + +class cTSLogger +{ + cMutex mutex; + uchar *buffer; + int size; + int fill; + int64_t count; + int dumps; + int cid; + +public: + cTSLogger(int Cid); + ~cTSLogger(); + void Put(const uchar *Data); + void Dump(); +}; + +cTSLogger::cTSLogger(int Cid) +{ + size = 1000; // number of TS packets to log + buffer = new uchar[size * 188]; + fill = 0; + count = 0; + dumps = 0; + cid = Cid; +} + +cTSLogger::~cTSLogger() +{ + delete [] buffer; +} + +void cTSLogger::Put(const uchar *Data) +{ + cMutexLock MutexLock(&mutex); + + memcpy(&buffer[(count++ % size) * 188], Data, 188); + if (fill < size) + fill++; +} + +void cTSLogger::Dump() +{ + cMutexLock MutexLock(&mutex); + + char name[200]; + sprintf(name, "/video/ts_%d_%d_0x%02X_%03d_%lld_%d.log", getpid(), cThread::ThreadId(), cid, dumps++, count, fill); + esyslog("cTSLogger: dumping to file '%s'", name); + + FILE *f = fopen(name, "wb"); + for (int64_t n = count - fill; n < count; n++) + fwrite(&buffer[(n % size) * 188], 188, 1, f); + fclose(f); + + fill = 0; +} + // --- cRepacker ------------------------------------------------------------- #define MIN_LOG_INTERVAL 10 // min. # of seconds between two consecutive log messages of a cRepacker @@ -110,6 +169,7 @@ public: virtual int QuerySnoopSize(void) { return 0; } void SetMaxPacketSize(int MaxPacketSize) { maxPacketSize = MaxPacketSize; } void SetSubStreamId(uint8_t SubStreamId) { subStreamId = SubStreamId; } + virtual void LogTSPacket(const uchar *Data) {} }; cRepacker::cRepacker(void) @@ -691,6 +837,8 @@ private: int frameSize; int cid; static bool IsValidAudioHeader(uint32_t Header, bool Mpeg2, int *FrameSize = NULL); + cTSLogger tsLogger; + virtual void LogTSPacket(const uchar *Data) { tsLogger.Put(Data); } public: cAudioRepacker(int Cid); virtual void Reset(void); @@ -712,6 +861,7 @@ int cAudioRepacker::bitRates[2][3][16] = }; cAudioRepacker::cAudioRepacker(int Cid) + : tsLogger(Cid) { cid = Cid; Reset(); @@ -842,8 +1302,10 @@ void cAudioRepacker::Repack(cRingBufferL if (state == syncing) { if (initiallySyncing) // omit report for the typical initial case initiallySyncing = false; - else if (skippedBytes > SkippedBytesLimit) // report that syncing dropped some bytes + else if (skippedBytes > SkippedBytesLimit) { // report that syncing dropped some bytes LOG("cAudioRepacker(0x%02X): skipped %d bytes to sync on next audio frame", cid, skippedBytes - SkippedBytesLimit); + tsLogger.Dump(); + } skippedBytes = 0; // if there is a PES header available, then use it ... if (pesHeaderBackupLen > 0) { @@ -1803,6 +2278,8 @@ void cTS2PES::instant_repack(const uint8 void cTS2PES::ts_to_pes(const uint8_t *Buf) // don't need count (=188) { + if (Buf && repacker) repacker->LogTSPacket(Buf); + if (!Buf) return;