More enums, and conditional evaluation
This commit is contained in:
parent
c2b7f7d129
commit
50accfafa1
37
08_enums.ksy
37
08_enums.ksy
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue
Block a user