summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-08-31 00:20:11 +0100
committerCarl Hetherington <cth@carlh.net>2017-08-31 00:20:11 +0100
commit43d0cdf4bea250692367357b852a018196f12f0d (patch)
tree28d026b76d13cc50a34e826507b7aa8139e6beb3
parent01b35c34a36f35a29899db2fd6c4759de89a8860 (diff)
Add new script to partially dump DPX headers.
-rw-r--r--hacks/dump_dpx.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/hacks/dump_dpx.py b/hacks/dump_dpx.py
new file mode 100644
index 000000000..1cab96e25
--- /dev/null
+++ b/hacks/dump_dpx.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python3
+
+import sys
+import struct
+
+f = open(sys.argv[1], 'rb')
+
+dpx = f.read(768)
+magic = dpx[0:4]
+if magic == b'XPDS':
+ print('Little-endian')
+ endian = '<'
+elif magic == b'SDPX':
+ print('Big-endian')
+ endian = '>'
+else:
+ print('Unrecognised magic word', file=sys.stderr)
+ sys.exit(1)
+
+image = f.read(640)
+im = dict()
+(im['orientation'],
+ im['number_elements'],
+ im['pixels_per_line'],
+ im['lines_per_element'],
+ im['data_sign'],
+ im['low_data'],
+ im['low_quantity'],
+ im['high_data'],
+ im['high_quantity'],
+ im['descriptor'],
+ im['transfer'],
+ im['colorimetric']) = struct.unpack('%shhiiiififBBB' % endian, image[0:35])
+
+transfer = { 0: 'user-defined', 1: 'printing density', 2: 'linear', 3: 'logarithmic', 4: 'unspecified video', 5: 'SMPTE 240M', 6: 'CCIR 709-1', 7: 'CCIR601-2 system B or G',
+ 8: 'CCIR 601-2 system M', 9: 'NTSC composite video', 10: 'PAL composite video', 11: 'Z linear', 12: 'Z homogeneous' }
+
+for k, v in im.items():
+ if k == 'transfer':
+ v = transfer[v]
+ print('%s: %s' % (k, v))