From 627473b8f9843870b18ec1d26cc5685a833769f9 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 17 Jun 2014 13:24:49 +0200 Subject: [PATCH] support/pid-count.py: add code for cc errors --- support/pid-count.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/support/pid-count.py b/support/pid-count.py index 8646116c..3c1d79ad 100755 --- a/support/pid-count.py +++ b/support/pid-count.py @@ -7,6 +7,8 @@ import os, sys, time # Stats pids = {} +pids_cc = {} +pids_cc_err = {} # Open file fp = open(sys.argv[1]) @@ -15,17 +17,29 @@ while True: if len(tsb) < 16: break tsb = map(ord, tsb[:16]) - if tsb[0] != 0x47: continue + if tsb[0] != 0x47: + print 'sync err' + continue # TODO: should re-sync pid = ((tsb[1] & 0x1f) << 8) | tsb[2] if pid not in pids: pids[pid] = 1 else: - pids[pid] = pids[pid] + 1 + pids[pid] += 1 + cc = tsb[3] + if cc & 0x10: + cc &= 0x0f + if pid in pids_cc and pids_cc[pid] != cc: + print 'cc err 0x%x != 0x%x for pid %04X (%4d) %d' % (cc, pids_cc[pid], pid, pid, fp.tell()) + if pid not in pids_cc_err: + pids_cc_err[pid] = 1 + else: + pids_cc_err[pid] += 1 + pids_cc[pid] = (cc + 1) & 0x0f # Output ks = pids.keys() ks.sort() for k in ks: - if pids[k] <= int(sys.argv[2]): continue - print '%04X (%4d) - %d' % (k, k, pids[k]) +# if pids[k] <= int(sys.argv[2]): continue + print '%04X (%4d) - %d (err %d)' % (k, k, pids[k], k in pids_cc_err and pids_cc_err[k] or 0)