Streamlined SIZ parsing. #130
This commit is contained in:
parent
28a131797e
commit
576571fa85
1 changed files with 4 additions and 5 deletions
|
|
@ -670,8 +670,8 @@ class Codestream(object):
|
||||||
read_buffer = fptr.read(2)
|
read_buffer = fptr.read(2)
|
||||||
length, = struct.unpack('>H', read_buffer)
|
length, = struct.unpack('>H', read_buffer)
|
||||||
|
|
||||||
xy_buffer = fptr.read(36)
|
read_buffer = fptr.read(length - 2)
|
||||||
data = struct.unpack('>HIIIIIIIIH', xy_buffer)
|
data = struct.unpack_from('>HIIIIIIIIH', read_buffer)
|
||||||
|
|
||||||
rsiz = data[0]
|
rsiz = data[0]
|
||||||
if rsiz not in _KNOWN_PROFILES:
|
if rsiz not in _KNOWN_PROFILES:
|
||||||
|
|
@ -685,9 +685,8 @@ class Codestream(object):
|
||||||
# Csiz is the number of components
|
# Csiz is the number of components
|
||||||
Csiz = data[9]
|
Csiz = data[9]
|
||||||
|
|
||||||
component_buffer = fptr.read(Csiz * 3)
|
data = struct.unpack_from('>' + 'B' * (length - 36 - 2),
|
||||||
data = struct.unpack('>' + 'B' * len(component_buffer),
|
read_buffer, offset=36)
|
||||||
component_buffer)
|
|
||||||
|
|
||||||
bitdepth = tuple(((x & 0x7f) + 1) for x in data[0::3])
|
bitdepth = tuple(((x & 0x7f) + 1) for x in data[0::3])
|
||||||
signed = tuple(((x & 0x80) > 0) for x in data[0::3])
|
signed = tuple(((x & 0x80) > 0) for x in data[0::3])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue