1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Added TS error checking to remux.c

This commit is contained in:
Klaus Schmidinger 2003-01-24 17:22:29 +01:00
parent a3d9b92615
commit 54eb58e1eb
3 changed files with 33 additions and 4 deletions

View File

@ -529,3 +529,4 @@ Paul Gohn <pgohn@nexgo.de>
Teemu Rantanen <tvr@iki.fi>
for increased the maximum possible packet size in remux.c to avoid corrupted streams
with broadcasters that send extremely large PES packets
for adding TS error checking to remux.c

View File

@ -1927,3 +1927,4 @@ Video Disk Recorder Revision History
class to make sure replay remains smooth even under heavy system load.
- Increased the maximum possible packet size in remux.c to avoid corrupted streams
with broadcasters that send extremely large PES packets (thanks to Teemu Rantanen).
- Added TS error checking to remux.c (thanks to Teemu Rantanen).

35
remux.c
View File

@ -8,7 +8,7 @@
* the Linux DVB driver's 'tuxplayer' example and were rewritten to suit
* VDR's needs.
*
* $Id: remux.c 1.13 2003/01/24 14:21:17 kls Exp $
* $Id: remux.c 1.14 2003/01/24 17:22:29 kls Exp $
*/
/* The calling interface of the 'cRemux::Process()' function is defined
@ -97,11 +97,13 @@
#define PTS_ONLY 0x80
#define TS_SIZE 188
#define PAY_START 0x40
#define PID_MASK_HI 0x1F
//flags
#define CONT_CNT_MASK 0x0F
// Flags:
#define PAY_START 0x40
#define TS_ERROR 0x80
#define ADAPT_FIELD 0x20
//XXX TODO
#define MAX_PLENGTH 0xFFFF // the maximum PES packet length (theoretically)
#define MMAX_PLENGTH (8*MAX_PLENGTH) // some stations send PES packets that are extremely large, e.g. DVB-T in Finland
@ -132,6 +134,9 @@ private:
bool done;
uint8_t *resultBuffer;
int *resultCount;
int tsErrors;
int ccErrors;
int ccCounter;
static uint8_t headr[];
void store(uint8_t *Data, int Count);
void reset_ipack(void);
@ -154,6 +159,10 @@ cTS2PES::cTS2PES(uint8_t *ResultBuffer, int *ResultCount, int Size, uint8_t Audi
size = Size;
audioCid = AudioCid;
tsErrors = 0;
ccErrors = 0;
ccCounter = -1;
if (!(buf = MALLOC(uint8_t, size)))
esyslog("Not enough memory for ts_transform");
@ -162,6 +171,8 @@ cTS2PES::cTS2PES(uint8_t *ResultBuffer, int *ResultCount, int Size, uint8_t Audi
cTS2PES::~cTS2PES()
{
if (tsErrors || ccErrors)
dsyslog("cTS2PES got %d TS errors, %d TS continuity errors", tsErrors, ccErrors);
free(buf);
}
@ -400,6 +411,22 @@ void cTS2PES::ts_to_pes(const uint8_t *Buf) // don't need count (=188)
if (!Buf)
return;
if (Buf[1] & TS_ERROR)
tsErrors++;
if ((Buf[3] ^ ccCounter) & CONT_CNT_MASK) {
// This should check duplicates and packets which do not increase the counter.
// But as the errors usually come in bursts this should be enough to
// show you there is something wrong with signal quality.
if (ccCounter != -1 && ((Buf[3] ^ (ccCounter + 1)) & CONT_CNT_MASK)) {
ccErrors++;
// Enable this if you are having problems with signal quality.
// These are the errors I used to get with Nova-T when antenna
// was not positioned correcly (not transport errors). //tvr
//dsyslog("TS continuity error (%d)", ccCounter);
}
ccCounter = Buf[3] & CONT_CNT_MASK;
}
if (Buf[1] & PAY_START) {
if (plength == MMAX_PLENGTH - 6 && found > 6) {
plength = found - 6;