#!/usr/bin/env python3 ######################################################################## ## ## cap_check.py ## ## Copyright (C) 2024 Herbert Poetzl ## ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License version 2 as ## published by the Free Software Foundation. ## ######################################################################## import sys import struct capw = 1920 caph = 1080 fmax = None if len(sys.argv) > 2: fmax = int(sys.argv[2], 0) def fletcher4(data): a = b = c = d = 0 for val in struct.iter_unpack('I', data): a += val[0]; b += a; c += b; d += c; a &= 0xFFFFFFFF b &= 0xFFFFFFFF c &= 0xFFFFFFFF d &= 0xFFFFFFFF return ((a ^ c) << 32) ^ b ^ d flsd = {} fcnt = 0 prev = None with open(sys.argv[1], "rb") as f: while True: data = f.read(capw*caph*3) if len(data) < capw*caph*3: break if fmax and fcnt >= fmax: break data = bytearray(data) corn = [] for y in [0, caph-1]: for x in [0, capw-1]: idx = (x + y*capw)*3 val = data[idx] val = (val << 8) | data[idx+1] val = (val << 8) | data[idx+2] corn.append(val) data[idx:idx+3] = b"\0\0\0" out = False fl4 = fletcher4(data) fls = f"{fl4:016X}" hcor = [f"{_:06X}" for _ in corn] print(f"{fcnt:06X}", fls, \ " ".join(hcor), f"# [{len(data):d}]") fcnt += 1 print(flsd)