From 38e040ad831dd9ac4c7356f02847ea2c5641b541 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Thu, 7 Jan 2016 16:06:29 -0500 Subject: [PATCH] misc: Add scripts to report VMS tile offsets --- misc/vms-dump-opt.py | 19 +++++++++++++++ misc/vms-jpeg-find-tiles.py | 58 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 misc/vms-dump-opt.py create mode 100644 misc/vms-jpeg-find-tiles.py diff --git a/misc/vms-dump-opt.py b/misc/vms-dump-opt.py new file mode 100644 index 00000000..b0ff3cb1 --- /dev/null +++ b/misc/vms-dump-opt.py @@ -0,0 +1,19 @@ +import struct +import sys + +jpeg = 0 +last = float('inf') + +with open(sys.argv[1]) as fh: + while True: + buf = fh.read(40) + if not buf: + break + val = struct.unpack('H')[0] + fh.seek(count - 2, 1) + + # Walk entropy-coded data + base = fh.tell() + print base + while True: + buf = fh.read(4 << 10) + if not buf: + break + off = 0 + while True: + off = buf.find('\xff', off) + if off == -1: + break + elif off == len(buf) - 1: + ch = fh.read(1) + if len(ch) != 1: + raise IOError('Short read') + buf += ch + marker_byte = struct.unpack('B', buf[off + 1])[0] + if marker_byte >= 0xd0 and marker_byte <= 0xd7: + print base + off + 2 + off += 2 + base += len(buf) + except EOFError: + pass + except Exception: + print 'At {}:'.format(fh.tell()) + raise