-
Notifications
You must be signed in to change notification settings - Fork 205
Open
Description
I'm trying to read a format that has a quite dumb layout. One of its TLV blocks has fields that you must read from the start and the end of the block, and then there's a single field in the middle that is all the left over space. Here's what I've got that works:
block_vcdata:
seq:
- id: start_time
type: u8
- id: end_time
type: u8
- id: memory_required
type: u8
- id: bits_uncompressed_length
type: vlq_base128_le
- id: bits_compressed_length
type: vlq_base128_le
- id: bits_count
type: vlq_base128_le
- id: bits_data
size: bits_compressed_length.value
- id: waves_count
type: vlq_base128_le
- id: waves_packtype
type: u1
- id: waves_data
size: _parent.block_length - 8 - (_io.pos + 32 + position_length + time_compressed_length)
# The other fields have to awkwardly be instances because you need to
# read them backwards from the end. Weird format.
instances:
position_data:
pos: _io.size - 8 - 8 - 8 - time_compressed_length - 8 - position_length
size: position_length
position_length:
pos: _io.size - 8 - 8 - 8 - time_compressed_length - 8
type: u8
time_data:
pos: _io.size - 8 - 8 - 8 - time_compressed_length
size: time_compressed_length
time_uncompressed_length:
pos: _io.size - 8 - 8 - 8
type: u8
time_compressed_length:
pos: _io.size - 8 - 8
type: u8
time_count:
pos: _io.size - 8
type: u8
As you can see waves_data is "the left over space in the middle". (The block_length - 8 btw is because the length inexplicably includes itself.)
To be honest I'm amazed that this works, what with all the crazy dependencies. But I thought I'd better just ask if there is a better way to do this?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels