summaryrefslogtreecommitdiff
path: root/remux.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2011-06-11 11:28:13 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2011-06-11 11:28:13 +0200
commitb226ab46d6de31746665997fe79c165521e793af (patch)
treed17c0846a90998f676780fe24edf9a1db3aed649 /remux.c
parent1afb2cf1c288a41b07c96d26d2a386ecee2326eb (diff)
downloadvdr-b226ab46d6de31746665997fe79c165521e793af.tar.gz
vdr-b226ab46d6de31746665997fe79c165521e793af.tar.bz2
Fixed detecting frames in case the Picture Start Code or Access Unit Delimiter extends over TS packet boundaries
Diffstat (limited to 'remux.c')
-rw-r--r--remux.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/remux.c b/remux.c
index f7ef87a9..a62c36cd 100644
--- a/remux.c
+++ b/remux.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: remux.c 2.53 2011/03/20 10:21:14 kls Exp $
+ * $Id: remux.c 2.54 2011/06/11 11:20:06 kls Exp $
*/
#include "remux.h"
@@ -906,9 +906,20 @@ int cFrameDetector::Analyze(const uchar *Data, int Length)
if (DebugFrames && !synced)
dbgframes("/");
}
+ int PacketsForFrameDetector = MIN_TS_PACKETS_FOR_FRAME_DETECTOR;
for (int i = PayloadOffset; scanning && i < TS_SIZE; i++) {
scanner <<= 8;
scanner |= Data[i];
+ if (i == TS_SIZE - 1) { // it was the last byte in this TS packet
+ if (SeenPayloadStart && --PacketsForFrameDetector > 0) {
+ Data += TS_SIZE;
+ Length -= TS_SIZE;
+ Processed += TS_SIZE;
+ if (Length < TS_SIZE)
+ return Processed;
+ i = TsPayloadOffset(Data) - 1; // one before the first payload byte of the next TS packet
+ }
+ }
switch (type) {
case 0x01: // MPEG 1 video
case 0x02: // MPEG 2 video