summaryrefslogtreecommitdiff
path: root/remux.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2012-11-13 10:00:00 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2012-11-13 10:00:00 +0100
commit5b4e1fa793506405d0d8bac47a36640a06340c80 (patch)
tree4786b2bbb8ca0234f4b0924e967f326096a55c06 /remux.c
parente24aa0aa1adf4c60539be41170145b58cf9c8683 (diff)
downloadvdr-5b4e1fa793506405d0d8bac47a36640a06340c80.tar.gz
vdr-5b4e1fa793506405d0d8bac47a36640a06340c80.tar.bz2
Fixed detecting frames in case there are multiple frames per payload unit
Diffstat (limited to 'remux.c')
-rw-r--r--remux.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/remux.c b/remux.c
index 285ec582..bc7cd0de 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.69 2012/11/06 10:59:39 kls Exp $
+ * $Id: remux.c 2.70 2012/11/13 10:00:00 kls Exp $
*/
#include "remux.h"
@@ -991,16 +991,25 @@ cMpeg2Parser::cMpeg2Parser(void)
int cMpeg2Parser::Parse(const uchar *Data, int Length, int Pid)
{
newFrame = independentFrame = false;
+ bool SeenPayloadStart = false;
cTsPayload tsPayload(const_cast<uchar *>(Data), Length, Pid);
if (TsPayloadStart(Data)) {
+ SeenPayloadStart = true;
tsPayload.SkipPesHeader();
scanner = EMPTY_SCANNER;
if (debug && seenIndependentFrame)
dbgframes("/");
}
+ uint32_t OldScanner = scanner; // need to remember it in case of multiple frames per payload
for (;;) {
+ if (!SeenPayloadStart && tsPayload.AtTsStart())
+ OldScanner = scanner;
scanner = (scanner << 8) | tsPayload.GetByte();
if (scanner == 0x00000100) { // Picture Start Code
+ if (!SeenPayloadStart && tsPayload.GetLastIndex() > TS_SIZE) {
+ scanner = OldScanner;
+ return tsPayload.Used() - TS_SIZE;
+ }
newFrame = true;
tsPayload.GetByte();
uchar FrameType = (tsPayload.GetByte() >> 3) & 0x07;
@@ -1314,11 +1323,10 @@ int cFrameDetector::Analyze(const uchar *Data, int Length)
if (TsHasPayload(Data) && !TsIsScrambled(Data)) {
int Pid = TsPid(Data);
if (Pid == pid) {
- if (TsPayloadStart(Data)) {
- if (Processed)
- return Processed;
+ if (Processed)
+ return Processed;
+ if (TsPayloadStart(Data))
scanning = true;
- }
if (scanning) {
// Detect the beginning of a new frame:
if (TsPayloadStart(Data)) {