mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2026-01-02 18:00:41 +00:00
Style tweaks
Style stuff
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import struct
|
import struct
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from . import riff_parser
|
from . import riff_parser
|
||||||
|
|
||||||
RF64Context = namedtuple('RF64Context','sample_count bigchunk_table')
|
RF64Context = namedtuple('RF64Context','sample_count bigchunk_table')
|
||||||
|
|
||||||
@@ -8,33 +8,33 @@ RF64Context = namedtuple('RF64Context','sample_count bigchunk_table')
|
|||||||
def parse_rf64(stream):
|
def parse_rf64(stream):
|
||||||
#print("starting parse_rf64")
|
#print("starting parse_rf64")
|
||||||
start = stream.tell()
|
start = stream.tell()
|
||||||
assert( stream.read(4) == b'WAVE' )
|
assert( stream.read(4) == b'WAVE' )
|
||||||
|
|
||||||
ds64_chunk = riff_parser.parse_chunk(stream)
|
ds64_chunk = riff_parser.parse_chunk(stream)
|
||||||
|
|
||||||
ds64_field_spec = "<QQQI"
|
ds64_field_spec = "<QQQI"
|
||||||
ds64_fields_size = struct.calcsize(ds64_field_spec)
|
ds64_fields_size = struct.calcsize(ds64_field_spec)
|
||||||
assert(ds64_chunk.ident == b'ds64')
|
assert(ds64_chunk.ident == b'ds64')
|
||||||
|
|
||||||
ds64_data = ds64_chunk.read_data(stream)
|
ds64_data = ds64_chunk.read_data(stream)
|
||||||
assert(len(ds64_data) >= ds64_fields_size )
|
assert(len(ds64_data) >= ds64_fields_size )
|
||||||
|
|
||||||
#print("Read ds64 chunk: len()",len(ds64_data))
|
#print("Read ds64 chunk: len()",len(ds64_data))
|
||||||
riff_size, data_size, sample_count, length_lookup_table = struct.unpack( ds64_field_spec , ds64_data[0:ds64_fields_size] )
|
riff_size, data_size, sample_count, length_lookup_table = struct.unpack( ds64_field_spec , ds64_data[0:ds64_fields_size] )
|
||||||
|
|
||||||
bigchunk_table = {}
|
bigchunk_table = {}
|
||||||
chunksize64format = "<4sL"
|
chunksize64format = "<4sL"
|
||||||
chunksize64size = struct.calcsize(chunksize64format)
|
chunksize64size = struct.calcsize(chunksize64format)
|
||||||
#print("Found chunks64s:", length_lookup_table)
|
#print("Found chunks64s:", length_lookup_table)
|
||||||
|
|
||||||
for n in range(length_lookup_table):
|
for n in range(length_lookup_table):
|
||||||
bigname, bigsize = struct.unpack_from( chunksize64format , ds64data, offset= ds64_fields_size )
|
bigname, bigsize = struct.unpack_from( chunksize64format , ds64_data, offset= ds64_fields_size )
|
||||||
bigchunk_table[bigname] = bigsize
|
bigchunk_table[bigname] = bigsize
|
||||||
|
|
||||||
bigchunk_table[b'data'] = data_size
|
bigchunk_table[b'data'] = data_size
|
||||||
bigchunk_table[b'RF64'] = riff_size
|
bigchunk_table[b'RF64'] = riff_size
|
||||||
|
|
||||||
stream.seek(start, 0)
|
stream.seek(start, 0)
|
||||||
#print("returning from parse_rf64, context: ",RF64Context( sample_count=sample_count, bigchunk_table=bigchunk_table ) )
|
#print("returning from parse_rf64, context: ",RF64Context( sample_count=sample_count, bigchunk_table=bigchunk_table ) )
|
||||||
return RF64Context( sample_count=sample_count, bigchunk_table=bigchunk_table )
|
return RF64Context( sample_count=sample_count, bigchunk_table=bigchunk_table )
|
||||||
|
|
||||||
|
|||||||
@@ -58,11 +58,11 @@ def parse_chunk(stream, rf64_context=None):
|
|||||||
if data_size == 0xFFFFFFFF:
|
if data_size == 0xFFFFFFFF:
|
||||||
if rf64_context is None and ident == b'RF64':
|
if rf64_context is None and ident == b'RF64':
|
||||||
rf64_context = parse_rf64(stream=stream)
|
rf64_context = parse_rf64(stream=stream)
|
||||||
|
|
||||||
data_size = rf64_context.bigchunk_table[ident]
|
data_size = rf64_context.bigchunk_table[ident]
|
||||||
|
|
||||||
displacement = data_size
|
displacement = data_size
|
||||||
if displacement % 2 is not 0:
|
if (displacement % 2) != 0:
|
||||||
displacement = displacement + 1
|
displacement = displacement + 1
|
||||||
|
|
||||||
if ident in [b'RIFF', b'LIST', b'RF64']:
|
if ident in [b'RIFF', b'LIST', b'RF64']:
|
||||||
|
|||||||
Reference in New Issue
Block a user