From patchwork Sun Sep 11 18:52:28 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Lucke X-Patchwork-Id: 12019 Received: from einhorn.in-berlin.de ([192.109.42.8] ident=root) by www.linuxtv.org with esmtp (Exim 4.34) id 1EEWwL-0006So-M4 for vdr@linuxtv.org; Sun, 11 Sep 2005 20:52:33 +0200 X-Envelope-From: stefan@lucke.in-berlin.de X-Envelope-To: Received: from jarada.farpoint.de (p54BF732C.dip.t-dialin.net [84.191.115.44]) by einhorn.in-berlin.de (8.12.10/8.12.10/Debian-4) with ESMTP id j8BIqWt7015323 for ; Sun, 11 Sep 2005 20:52:32 +0200 Received: from localhost (localhost [127.0.0.1]) by jarada.farpoint.de (Postfix) with ESMTP id 336CF6A6B5 for ; Sun, 11 Sep 2005 20:52:29 +0200 (CEST) From: Stefan Lucke To: vdr@linuxtv.org Date: Sun, 11 Sep 2005 20:52:28 +0200 User-Agent: KMail/1.5.4 MIME-Version: 1.0 Message-Id: <200509112052.28353.stefan@lucke.in-berlin.de> X-Spam-Score: (-0.872) AWL,BAYES_20,FORGED_RCVD_HELO X-Scanned-By: MIMEDefang_at_IN-Berlin_e.V. on 192.109.42.8 Subject: [vdr] ac3 of old (pre1.3.19) cannot detected/decoded with ffmpeg 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, 11 Sep 2005 18:52:33 -0000 Status: O X-Status: X-Keywords: X-UID: 4879 Hi, software decoding/detection of old ac3 streams seems to be impossible with ffmpeg. To fix this I made a modification so that recognition works. Can someone with more ac3 stream knowledge can have a look at this diff ? This vdr-1.3.22 apply with some offset to vdr-1.3.32 and still works. diff -U 3 vdr-1.3.22/device.c vdr-1.3.22.jarada/device.c --- vdr-1.3.22/device.c 2005-02-27 14:55:15.000000000 +0100 +++ vdr-1.3.22.jarada/device.c 2005-04-29 12:56:59.000000000 +0200 @@ -895,12 +905,41 @@ return -1; } +// 0 1 2 3 4 5 6 7 8 9 +// 00 00 01 BD ph pl xx xx hd si +// +// ph packet length high +// pl packet length low +// hd header length +// si substream id +// 00 00 01 bd 07 fa 84 80 05 23 cc 3d 21 df 0b 77 +// 00 00 01 bd 07 fa 80 00 00 60 6a 67 c9 7f c5 d3 +// 00 00 01 bd 00 20 80 00 05 80 01 00 01 60 6a 67 +// 00 00 01 bd 07 fa 80 00 00 94 6b 98 e8 b3 81 18 +// 00 00 01 bd 00 20 80 00 f9 80 01 00 01 94 6b 98 +// 00 00 01 bd 07 fa 80 00 00 c4 0e ca 39 4a 34 37 +// 00 00 01 bd 00 20 80 00 f9 80 01 00 01 c4 0e ca +// 00 00 01 bd 03 2c 80 00 00 8d 88 e5 b8 6a c9 c9 +// 00 00 01 bd 00 04 80 00 0f 80 01 00 01 8d 88 e5 +// 00 00 01 bd 07 fa 84 80 05 23 cc 3d 92 5f 0b 77 +// 00 00 01 bd 07 fa 80 00 00 1a bb a5 4f 61 be 7b + +// pro7 ac3 2.0: +// 00 00 01 bd 07 0c 84 81 05 2f 96 ed 89 1f 80 00 00 00 0b 77 2e 8c 1e 30 42 ff 70 80 01 00 00 7e +// 00 00 01 bd 07 07 80 00 00 80 00 00 00 0b 77 5e c1 1e 30 42 ff 70 80 01 00 00 7e fb fb 86 0a 63 +// 00 00 01 bd 07 07 80 00 00 80 00 00 00 0b 77 bb 8c 1e 30 42 ff 70 80 01 00 00 7e fb ff 86 0d 29 +// 00 00 01 bd 07 07 80 00 00 80 00 00 00 0b 77 8c 6e 1e 30 42 ff 70 80 01 00 00 7e fb f5 86 0b 17 +// 00 00 01 bd 07 07 80 00 00 80 00 00 00 0b 77 fa 28 1e 30 42 ff 70 80 01 00 00 7e fb f5 86 0a c7 +// 00 00 01 bd 07 0c 84 81 05 2f 96 ed f9 9f 80 00 00 00 0b 77 9c c8 1e 30 42 ff 70 80 01 00 00 7e + int cDevice::PlayPesPacket(const uchar *Data, int Length, bool VideoOnly) { bool FirstLoop = true; uchar c = Data[3]; const uchar *Start = Data; const uchar *End = Start + Length; + uchar *fixData = NULL; + while (Start < End) { int d = End - Start; int w = d; @@ -922,10 +961,40 @@ uchar SubStreamId = Data[PayloadOffset]; uchar SubStreamType = SubStreamId & 0xF0; uchar SubStreamIndex = SubStreamId & 0x1F; - // Compatibility mode for old VDR recordings, where 0xBD was only AC3: pre_1_3_19_PrivateStreamDeteced: if (pre_1_3_19_PrivateStream) { + if (FirstLoop) { + if (!fixData && (fixData = (uchar *) malloc (Length+4))) { + uchar *e = fixData; + const uchar *s = Data; + int l = Length, i, k; + + k = (Data[4] << 8) + Data[5]; + k += 4; + memcpy (e, s, 8); + e += 8; + s += 8; + l -= 8; + i = (*s) + 1; + memcpy (e, s, i); + e += i; + s += i; + l -= i; + fixData[4] = k >> 8; + fixData[5] = k & 0x00ff; + Length += 4; + *e++ = 0x80; //substream id + *e++ = 0x00; // nr of ac3 frames (sea AppendSubStream + *e++ = 0x00; + *e++ = 0x00; //?? + memcpy (e, s, l); + Start = Data = (const uchar *) fixData; + End = Start + Length; + d = End - Start; + w = d; + } + } SubStreamId = c; SubStreamType = 0x80; SubStreamIndex = 0; @@ -971,10 +1040,17 @@ else { if (Start != Data) esyslog("ERROR: incomplete PES packet write!"); + if (fixData) + free(fixData); return Start == Data ? w : Start - Data; } FirstLoop = false; } + if (fixData) { + free(fixData); + Length -=4; + } + return Length; }