summaryrefslogtreecommitdiff
path: root/remux.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2017-03-26 13:07:01 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2017-03-26 13:07:01 +0200
commitb313d88db13d1e90f81f9967af1fba8c8f84e59d (patch)
tree7f97ed5e6ca7727bb52ff4ca016125b60e96fe8b /remux.c
parent9e808255f842067e0c0c9ee2344f6c1aa2860e08 (diff)
downloadvdr-b313d88db13d1e90f81f9967af1fba8c8f84e59d.tar.gz
vdr-b313d88db13d1e90f81f9967af1fba8c8f84e59d.tar.bz2
Improved clearing the MTD buffer and syncing on TS packets
Diffstat (limited to 'remux.c')
-rw-r--r--remux.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/remux.c b/remux.c
index cb694760..a2d2dd6c 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 4.4 2017/01/09 15:05:05 kls Exp $
+ * $Id: remux.c 4.5 2017/03/26 13:07:01 kls Exp $
*/
#include "remux.h"
@@ -144,6 +144,19 @@ void TsSetPcr(uchar *p, int64_t Pcr)
}
}
+int TsSync(const uchar *Data, int Length, const char *File, const char *Function, int Line)
+{
+ int Skipped = 0;
+ while (Length > 0 && (*Data != TS_SYNC_BYTE || Length > TS_SIZE && Data[TS_SIZE] != TS_SYNC_BYTE)) {
+ Data++;
+ Length--;
+ Skipped++;
+ }
+ if (Skipped && File && Function && Line)
+ esyslog("ERROR: skipped %d bytes to sync on start of TS packet at %s/%s(%d)", Skipped, File, Function, Line);
+ return Skipped;
+}
+
int64_t TsGetPts(const uchar *p, int l)
{
// Find the first packet with a PTS and use it:
@@ -1557,13 +1570,8 @@ int cFrameDetector::Analyze(const uchar *Data, int Length)
newFrame = independentFrame = false;
while (Length >= MIN_TS_PACKETS_FOR_FRAME_DETECTOR * TS_SIZE) { // makes sure we are looking at enough data, in case the frame type is not stored in the first TS packet
// Sync on TS packet borders:
- if (Data[0] != TS_SYNC_BYTE) {
- int Skipped = 1;
- while (Skipped < Length && (Data[Skipped] != TS_SYNC_BYTE || Length - Skipped > TS_SIZE && Data[Skipped + TS_SIZE] != TS_SYNC_BYTE))
- Skipped++;
- esyslog("ERROR: skipped %d bytes to sync on start of TS packet", Skipped);
+ if (int Skipped = TS_SYNC(Data, Length))
return Processed + Skipped;
- }
// Handle one TS packet:
int Handled = TS_SIZE;
if (TsHasPayload(Data) && !TsIsScrambled(Data)) {