summaryrefslogtreecommitdiff
path: root/command/demux.cpp
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2011-03-14 23:08:40 +0100
committerJochen Dolze <vdr@dolze.de>2011-03-14 23:08:40 +0100
commit0662afd6d8816713ebeef519b38456d0f57a837b (patch)
treed16c991b8677d6c068d9b20281951097256310cd /command/demux.cpp
parentad13e186a657a6d2488dcc608ef670804107f4a7 (diff)
downloadvdr-plugin-markad-0662afd6d8816713ebeef519b38456d0f57a837b.tar.gz
vdr-plugin-markad-0662afd6d8816713ebeef519b38456d0f57a837b.tar.bz2
Added -O3 and -funroll-loops in Makefile
Reverted cutval to 127, adding commandline argument later Fixed demux error with TS files Added more info messages
Diffstat (limited to 'command/demux.cpp')
-rw-r--r--command/demux.cpp59
1 files changed, 47 insertions, 12 deletions
diff --git a/command/demux.cpp b/command/demux.cpp
index addc95f..88f3048 100644
--- a/command/demux.cpp
+++ b/command/demux.cpp
@@ -352,7 +352,19 @@ int cPaketQueue::findaudioheader(int start, int *framesize, int *headersize, boo
}
}
-int cPaketQueue::FindPesHeader(int Start)
+int cPaketQueue::FindTSHeader(int Start)
+{
+ int start=outptr+Start;
+ int i=0;
+ for (i=start; i<inptr; i++)
+ {
+ if (buffer[i]==0x47) break;
+ }
+ if (i==inptr) return -1;
+ return i;
+}
+
+int cPaketQueue::FindPESHeader(int Start)
{
int start=outptr+Start;
int ssize,hsize;
@@ -580,6 +592,7 @@ void cTS2Pkt::Clear()
noticeFILLER=false;
noticeSEQUENCE=false;
noticeSTREAM=false;
+ noticeTSERR=false;
if (queue) queue->Clear();
}
@@ -638,6 +651,12 @@ bool cTS2Pkt::Process(uchar *TSData, int TSSize, AvPacket *Pkt)
return true;
}
+ if ((tshdr->TError) && (!noticeTSERR))
+ {
+ noticeTSERR=true;
+ isyslog("stream error bit set");
+ }
+
int buflen=TS_SIZE+1;
uchar *buf=NULL;
@@ -912,13 +931,14 @@ bool cDemux::isvideopes(uchar *data, int count)
int cDemux::checkts(uchar *data, int count, int &pid)
{
+ pid=-1;
if (count<(int) sizeof(struct TSHDR)) return -1;
if (data[0]!=0x47) return 1;
struct TSHDR *tshdr = (struct TSHDR *) data;
+ pid = (tshdr->PidH << 8) | tshdr->PidL;
if ((tshdr->AFC<=0) || (tshdr->AFC>3)) return 1;
- pid = (tshdr->PidH << 8) | tshdr->PidL;
return 0;
}
@@ -952,19 +972,19 @@ int cDemux::fillqueue(uchar *data, int count, int &stream_or_pid, int &packetsiz
skipped++;
stream_or_pid=0;
packetsize=1;
- return 0;
+ return 0; // no useable data found, try next byte!
}
}
else
{
- int error_skipbytes=checkts(qData,PEEKBUF,stream_or_pid);
- if (error_skipbytes==-1) return -1;
- if (error_skipbytes)
+ int ret=checkts(qData,PEEKBUF,stream_or_pid);
+ if (ret==-1) return -1;
+ if (ret)
{
- skipped+=error_skipbytes;
+ skipped++;
stream_or_pid=0;
packetsize=1;
- return error_skipbytes; // no useable data found, try next!
+ return 0; // no useable data found, try next byte!
}
packetsize=TS_SIZE;
}
@@ -989,8 +1009,8 @@ int cDemux::fillqueue(uchar *data, int count, int &stream_or_pid, int &packetsiz
int start=packetsize;
if ((qData[start]!=0) || (qData[start+1]!=0) || (qData[start+2]!=1) || (qData[start+3]<0xBC))
{
- int start=queue->FindPesHeader(1);
- if (start)
+ int start=queue->FindPESHeader(1);
+ if (start>0)
{
// broken PES in queue, skip it
packetsize=start;
@@ -1000,7 +1020,8 @@ int cDemux::fillqueue(uchar *data, int count, int &stream_or_pid, int &packetsiz
}
else
{
- return -1;
+ // try to use the first packet
+ return 0;
}
}
}
@@ -1019,7 +1040,21 @@ int cDemux::fillqueue(uchar *data, int count, int &stream_or_pid, int &packetsiz
}
if (ret)
{
- return -1;
+ if (pid!=-1) return 0; // next packet is broken!
+ int start=queue->FindTSHeader(1);
+ if (start>0)
+ {
+ // broken TS in queue, skip it
+ packetsize=start;
+ skipped+=start;
+ stream_or_pid=0;
+ return 0;
+ }
+ else
+ {
+ // try to use the first packet
+ return 0;
+ }
}
}
}