More enums, and conditional evaluation

master
Valentin Ochs 2020-12-30 07:47:22 +01:00
parent c2b7f7d129
commit 50accfafa1
1 changed files with 25 additions and 12 deletions

View File

@ -5,23 +5,28 @@ meta:
endian: le
seq:
- id: magic
contents: "RIFF"
size: 4
# Could assert using contents here, but
# just make sections conditional later
#contents: "RIFF"
type: u4be
enum: fourcc
- id: size
type: u4
- id: wave_str
contents: "WAVE"
size: 4
#contents: "WAVE"
type: u4be
enum: fourcc
- id: sections
type: section
repeat: eos
if: 'magic == fourcc::riff and wave_str == fourcc::wave'
instances: {}
types:
section:
seq:
- id: name
type: str
size: 4
type: u4be # Big endian!
enum: fourcc
- id: size
type: u4
- id: content
@ -29,11 +34,11 @@ types:
type:
switch-on: name
cases:
'"fmt "': fmt
'"data"': data
'"fact"': fact
'"PEAK"': peak
'"LIST"': list
'fourcc::fmt': fmt
'fourcc::data': data
'fourcc::fact': fact
'fourcc::peak': peak
'fourcc::list': list
fmt:
seq:
- id: type
@ -56,7 +61,7 @@ types:
type:
switch-on: _root.sections[0].name
cases:
'"fmt "': sample(_root.sections[0].content.as<fmt>.type, _root.sections[0].content.as<fmt>.bits_per_unit)
'fourcc::fmt': sample(_root.sections[0].content.as<fmt>.type, _root.sections[0].content.as<fmt>.bits_per_unit)
_: u1
repeat: eos
types:
@ -129,6 +134,14 @@ types:
type: strz
size: size
enums:
fourcc:
0x52494646: 'riff'
0x57415645: 'wave'
0x666d7420: 'fmt'
0x66616374: 'fact'
0x5045414b: 'peak'
0x64617461: 'data'
0x4c495354: 'list'
encoding_type_enum:
1: 'int'
3: 'float'