From d800cf56f53e5c00610d8ed1b4cd08533b3f00a0 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Fri, 17 Oct 2003 13:47:03 +0200 Subject: Fixed extracting the ES data and added MPEG1 handling to cDvbDevice::StillPicture() --- CONTRIBUTORS | 2 ++ HISTORY | 6 +++++- config.h | 6 +++--- dvbdevice.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++-------------- 4 files changed, 56 insertions(+), 18 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 4c34fb73..990793cd 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -176,6 +176,7 @@ Stefan Huelswitt for fixing a memory leak in cNonBlockingFileReader for fixing an uninitialized variable in cDisplayChannel for fixing a possible access of invalid file handles in cSIProcessor::Action() + for fixing extracting the ES data in cDvbDevice::StillPicture() Ulrich Röder for pointing out that there are channels that have a symbol rate higher than @@ -267,6 +268,7 @@ Andy Grobb Thomas Heiligenmann for implementing the SVDRP commands LSTR and DELR + for adding MPEG1 handling to cDvbDevice::StillPicture() Norbert Schmidt for filling in some missing teletext PIDs diff --git a/HISTORY b/HISTORY index 0418d04d..61fb6089 100644 --- a/HISTORY +++ b/HISTORY @@ -2403,7 +2403,7 @@ Video Disk Recorder Revision History - Updated 'channels.conf.cable' (thanks to Stefan Hußfeldt). -2003-10-03: Version 1.3.0 +2003-10-17: Version 1.2.6pre1 - Updated the required driver version in INSTALL (thanks to Jens Groth for reporting this one). @@ -2420,3 +2420,7 @@ Video Disk Recorder Revision History - Now trying to get a timer's channel without RID when loading 'timers.conf' (thanks to Thomas Rausch). - Removed the unused 0x73 (TOT) filter in eit.c (thanks to Andreas Trauer). +- Fixed extracting the ES data in cDvbDevice::StillPicture() (thanks to Stefan + Huelswitt). +- Added MPEG1 handling to cDvbDevice::StillPicture() (thanks to Thomas + Heiligenmann). diff --git a/config.h b/config.h index 0bf7efd3..a5b33541 100644 --- a/config.h +++ b/config.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.h 1.175 2003/10/03 11:49:31 kls Exp $ + * $Id: config.h 1.176 2003/10/17 12:35:23 kls Exp $ */ #ifndef __CONFIG_H @@ -19,8 +19,8 @@ #include "device.h" #include "tools.h" -#define VDRVERSION "1.3.0" -#define VDRVERSNUM 10300 // Version * 10000 + Major * 100 + Minor +#define VDRVERSION "1.2.6pre1" +#define VDRVERSNUM 10206 // Version * 10000 + Major * 100 + Minor #define MAXPRIORITY 99 #define MAXLIFETIME 99 diff --git a/dvbdevice.c b/dvbdevice.c index 8c4c7264..e3335850 100644 --- a/dvbdevice.c +++ b/dvbdevice.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbdevice.c 1.65 2003/10/04 12:31:15 kls Exp $ + * $Id: dvbdevice.c 1.66 2003/10/17 13:31:06 kls Exp $ */ #include "dvbdevice.h" @@ -947,21 +947,53 @@ void cDvbDevice::StillPicture(const uchar *Data, int Length) return; int i = 0; int blen = 0; - while (i < Length - 4) { - if (Data[i] == 0x00 && Data[i + 1] == 0x00 && Data[i + 2] == 0x01 && (Data[i + 3] & 0xF0) == 0xE0) { - // skip PES header - int offs = i + 6; + while (i < Length - 6) { + if (Data[i] == 0x00 && Data[i + 1] == 0x00 && Data[i + 2] == 0x01) { int len = Data[i + 4] * 256 + Data[i + 5]; - // skip header extension - if ((Data[i + 6] & 0xC0) == 0x80) { - offs += 3; - offs += Data[i + 8]; - len -= 3; - len -= Data[i + 8]; + if ((Data[i + 3] & 0xF0) == 0xE0) { // video packet + // skip PES header + int offs = i + 6; + // skip header extension + if ((Data[i + 6] & 0xC0) == 0x80) { + // MPEG-2 PES header + offs += 3; + offs += Data[i + 8]; + len -= 3; + len -= Data[i + 8]; + } + else { + // MPEG-1 PES header + while (offs < Length && len > 0 && Data[offs] == 0xFF) { + offs++; + len--; + } + if ((Data[offs] & 0xC0) == 0x40) { + offs += 2; + len -= 2; + } + if ((Data[offs] & 0xF0) == 0x20) { + offs += 5; + len -= 5; + } + else if ((Data[offs] & 0xF0) == 0x30) { + offs += 10; + len -= 10; + } + else if (Data[offs] == 0x0F) { + offs++; + len--; + } + } + if (blen + len > Length) // invalid PES length field + break; + memcpy(&buf[blen], &Data[offs], len); + i = offs + len; + blen += len; } - memcpy(&buf[blen], &Data[offs], len); - i = offs + len; - blen += len; + else if (Data[i + 3] >= 0xBD && Data[i + 3] <= 0xDF) // other PES packets + i += len + 6; + else + i++; } else i++; -- cgit v1.2.3