From 066728b9a0a1c0c94a6e92767860393488648338 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Mon, 21 Apr 2014 22:31:30 +0100 Subject: [PATCH] mpegts: attempt to avoid unecessary reporting of CRC failure on CC error I've also hidden the PSI CC error output, put in debug, so it doesn't flood logs and generally annoy people. --- src/input/mpegts.h | 2 +- src/input/mpegts/mpegts_input.c | 11 ++++++++--- src/input/mpegts/mpegts_table.c | 5 ++++- src/input/mpegts/tsdemux.c | 6 ++++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/input/mpegts.h b/src/input/mpegts.h index 3ac69db9..321c22ae 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -202,7 +202,7 @@ struct mpegts_table_feed { * Assemble SI section */ void mpegts_psi_section_reassemble - ( mpegts_psi_section_t *ps, const uint8_t *tsb, int crc, + ( mpegts_psi_section_t *ps, const uint8_t *tsb, int crc, int ccerr, mpegts_psi_section_callback_t cb, void *opaque ); /* ************************************************************************** diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index e60ff43d..22540799 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -676,10 +676,15 @@ mpegts_input_table_dispatch ( mpegts_mux_t *mm, mpegts_table_feed_t *mtf ) mt = vec[i]; if (!mt->mt_destroyed && mt->mt_pid == pid) { if (mtf->mtf_tsb[3] & 0x10) { - if (mt->mt_cc != -1 && mt->mt_cc != cc) - tvhwarn("psi", "PID %04X CC error %d != %d", pid, mt->mt_cc, cc); + int ccerr = 0; + if (mt->mt_cc != -1 && mt->mt_cc != cc) { + ccerr = 1; + /* Ignore dupes (shouldn't have payload set, but some seem to) */ + //if (((mt->mt_cc + 15) & 0xf) != cc) + tvhdebug("psi", "PID %04X CC error %d != %d", pid, cc, mt->mt_cc); + } mt->mt_cc = (cc + 1) & 0xF; - mpegts_psi_section_reassemble(&mt->mt_sect, mtf->mtf_tsb, 0, + mpegts_psi_section_reassemble(&mt->mt_sect, mtf->mtf_tsb, 0, ccerr, mpegts_table_dispatch, mt); } } diff --git a/src/input/mpegts/mpegts_table.c b/src/input/mpegts/mpegts_table.c index 2d8d0e96..b3eb8094 100644 --- a/src/input/mpegts/mpegts_table.c +++ b/src/input/mpegts/mpegts_table.c @@ -219,13 +219,16 @@ mpegts_psi_section_reassemble0 */ void mpegts_psi_section_reassemble - (mpegts_psi_section_t *ps, const uint8_t *tsb, int crc, + (mpegts_psi_section_t *ps, const uint8_t *tsb, int crc, int ccerr, mpegts_psi_section_callback_t cb, void *opaque) { int off = tsb[3] & 0x20 ? tsb[4] + 5 : 4; int pusi = tsb[1] & 0x40; int r; + if (ccerr) + ps->ps_lock = 0; + if(off >= 188) { ps->ps_lock = 0; return; diff --git a/src/input/mpegts/tsdemux.c b/src/input/mpegts/tsdemux.c index 685d4c96..42434d3a 100644 --- a/src/input/mpegts/tsdemux.c +++ b/src/input/mpegts/tsdemux.c @@ -66,7 +66,7 @@ static void ts_recv_packet0 (mpegts_service_t *t, elementary_stream_t *st, const uint8_t *tsb) { - int off, pusi, cc, error; + int off, pusi, cc, error, ccerr; service_set_streaming_status_flags((service_t*)t, TSS_MUX_PACKETS); @@ -84,6 +84,7 @@ ts_recv_packet0 if(tsb[3] & 0x10) { cc = tsb[3] & 0xf; if(st->es_cc != -1 && cc != st->es_cc) { + ccerr = 1; /* Incorrect CC */ limitedlog(&st->es_loglimit_cc, "TS", service_component_nicename(st), "Continuity counter error"); @@ -104,7 +105,8 @@ ts_recv_packet0 case SCT_CA: if(st->es_section == NULL) st->es_section = calloc(1, sizeof(mpegts_psi_section_t)); - mpegts_psi_section_reassemble(st->es_section, tsb, 0, got_ca_section, st); + mpegts_psi_section_reassemble(st->es_section, tsb, 0, ccerr, + got_ca_section, st); break; default: