-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathflac.grammar
183 lines (183 loc) · 10.3 KB
/
flac.grammar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?xml version="1.0" encoding="UTF-8"?>
<ufwb version="1.18">
<grammar name="FLAC" start="id:944" author="cooode" email="[email protected]" fileextension="flac" uti="pulic.flac" complete="yes">
<description>Grammar for FLAC files</description>
<structure name="FLAC" id="944" length="0" encoding="ISO_8859-1:1987" endian="big" signed="no">
<structure name="ID3" id="945" repeatmin="0">
<binary name="id3header" mustmatch="yes" id="946" length="3">
<fixedvalues>
<fixedvalue name="header" value="494433"/>
</fixedvalues>
</binary>
<number name="version" id="947" type="integer" length="1"/>
<number name="revision" id="948" type="integer" length="1"/>
<number name="Flag" id="949" type="integer" length="1"/>
<number name="id3Size1" id="950" type="integer" length="1"/>
<number name="id3Size2" id="951" type="integer" length="1"/>
<number name="id3Size3" id="952" type="integer" length="1"/>
<number name="id3Size4" id="953" type="integer" length="1"/>
<binary name="id3Data" id="954" length="id3Size1*2097152 + id3Size2*16384+id3Size3*128+id3Size4"/>
</structure>
<string name="fLaC" id="956" type="fixed-length" length="4">
<fixedvalues>
<fixedvalue name="fLaC" value="fLaC"/>
</fixedvalues>
</string>
<structure name="METADATA_BLOCKS" id="957" repeatmax="-1" consists-of="id:958" order="variable">
<structref name="METADATA_BLOCK_STREAMINFO" id="960" repeatmin="0" structure="id:959"/>
<structref name="METADATA_BLOCK_PADDING" id="962" repeatmin="0" structure="id:961"/>
<structref name="METADATA_BLOCK_APPLICATION" id="964" repeatmin="0" structure="id:963"/>
<structref name="METADATA_BLOCK_SEEKTABLE" id="966" repeatmin="0" structure="id:965"/>
<structref name="METADATA_BLOCK_VORBIS_COMMENT" id="968" repeatmin="0" structure="id:967"/>
<structref name="METADATA_BLOCK_CUESHEET" id="970" repeatmin="0" structure="id:969"/>
<structref name="METADATA_BLOCK_PICTURE" id="972" repeatmin="0" structure="id:971"/>
</structure>
<structref name="FRAME_HEADER" id="975" structure="id:974"/>
</structure>
<structure name="METADATA_BLOCK_BASE" id="958" length="0" encoding="ISO_8859-1:1987" endian="big" signed="no">
<number name="IS_LAST_BLOCK" id="977" type="integer" length="1" lengthunit="bit"/>
<number name="BLOCK_TYPE" id="978" type="integer" length="7" lengthunit="bit"/>
<number name="BLOCK_LENGTH" id="979" type="integer" length="24" lengthunit="bit"/>
<structure name="BLOCK_DATA" id="980" length="BLOCK_LENGTH"/>
</structure>
<structure name="SEEK_POINT" id="983" encoding="ISO_8859-1:1987" endian="big" signed="no">
<number name="SampleIndex" id="984" type="integer" length="8"/>
<number name="Offset" id="985" type="integer" length="8"/>
<number name="SampleCount" id="986" type="integer" length="2"/>
</structure>
<structure name="FRAME_HEADER" id="974" encoding="ISO_8859-1:1987" endian="big" signed="no">
<number name="SyncCode3FFE" id="988" type="integer" length="14" lengthunit="bit" display="hex">
<description>Sync code '11111111111110'</description>
</number>
<number name="Reserved" id="989" type="integer" length="1" lengthunit="bit">
<description>Reserved: [1]
0 : mandatory value
1 : reserved for future use</description>
</number>
<number name="BlockingStrategy" id="990" type="integer" length="1" lengthunit="bit">
<description>Blocking strategy: [2] [3]
0 : fixed-blocksize stream; frame header encodes the frame number
1 : variable-blocksize stream; frame header encodes the sample number</description>
</number>
<number name="BlockSize" id="991" type="integer" length="4" lengthunit="bit">
<description>Block size in inter-channel samples:
0000 : reserved
0001 : 192 samples
0010-0101 : 576 * (2^(n-2)) samples, i.e. 576/1152/2304/4608
0110 : get 8 bit (blocksize-1) from end of header
0111 : get 16 bit (blocksize-1) from end of header
1000-1111 : 256 * (2^(n-8)) samples, i.e. 256/512/1024/2048/4096/8192/16384/32768</description>
</number>
<number name="SampleRate" id="992" type="integer" length="4" lengthunit="bit">
<description>Sample rate:
0000 : get from STREAMINFO metadata block
0001 : 88.2kHz
0010 : 176.4kHz
0011 : 192kHz
0100 : 8kHz
0101 : 16kHz
0110 : 22.05kHz
0111 : 24kHz
1000 : 32kHz
1001 : 44.1kHz
1010 : 48kHz
1011 : 96kHz
1100 : get 8 bit sample rate (in kHz) from end of header
1101 : get 16 bit sample rate (in Hz) from end of header
1110 : get 16 bit sample rate (in tens of Hz) from end of header
1111 : invalid, to prevent sync-fooling string of 1s</description>
</number>
<number name="ChannelAssignment" id="993" type="integer" length="4" lengthunit="bit">
<description>Channel assignment
0000-0111 : (number of independent channels)-1. Where defined, the channel order follows SMPTE/ITU-R recommendations. The assignments are as follows:
1 channel: mono
2 channels: left, right
3 channels: left, right, center
4 channels: front left, front right, back left, back right
5 channels: front left, front right, front center, back/surround left, back/surround right
6 channels: front left, front right, front center, LFE, back/surround left, back/surround right
7 channels: front left, front right, front center, LFE, back center, side left, side right
8 channels: front left, front right, front center, LFE, back left, back right, side left, side right
1000 : left/side stereo: channel 0 is the left channel, channel 1 is the side(difference) channel
1001 : right/side stereo: channel 0 is the side(difference) channel, channel 1 is the right channel
1010 : mid/side stereo: channel 0 is the mid(average) channel, channel 1 is the side(difference) channel
1011-1111 : reserved</description>
</number>
<number name="SampleSizeInBits" id="994" type="integer" length="3" lengthunit="bit">
<description>Sample size in bits:
000 : get from STREAMINFO metadata block
001 : 8 bits per sample
010 : 12 bits per sample
011 : reserved
100 : 16 bits per sample
101 : 20 bits per sample
110 : 24 bits per sample
111 : reserved</description>
</number>
<number name="Reserved2" id="995" type="integer" length="1" lengthunit="bit"/>
</structure>
<structure name="METADATA_BLOCK_STREAMINFO" id="959" extends="id:958" encoding="ISO_8859-1:1987" endian="big" signed="no">
<number name="BLOCK_TYPE" mustmatch="yes" id="998" type="integer" length="7" lengthunit="bit">
<fixedvalues>
<fixedvalue name="type" value="0"/>
</fixedvalues>
</number>
<structure name="BLOCK_DATA" id="999" length="BLOCK_LENGTH">
<number name="MIN_BLOCK_SIZE" id="1001" type="integer" length="16" lengthunit="bit"/>
<number name="MAX_BLOCK_SIZE" id="1002" type="integer" length="16" lengthunit="bit"/>
<number name="MIN_FRAME_SIZE" id="1003" type="integer" length="24" lengthunit="bit"/>
<number name="MAX_FRAME_SIZE" id="1004" type="integer" length="24" lengthunit="bit"/>
<number name="SAMPLE_RATE" id="1005" type="integer" length="20" lengthunit="bit"/>
<number name="CHANNELS" id="1006" type="integer" length="3" lengthunit="bit"/>
<number name="BITS_PER_SAMPLE" id="1007" type="integer" length="5" lengthunit="bit"/>
<number name="TOTAL_SAMPLES" id="1008" type="integer" length="36" lengthunit="bit"/>
<binary name="MD5" id="1009" length="128" lengthunit="bit"/>
</structure>
</structure>
<structure name="METADATA_BLOCK_PADDING" id="961" extends="id:958">
<number name="BLOCK_TYPE" mustmatch="yes" id="1013" type="integer" length="7" lengthunit="bit">
<fixedvalues>
<fixedvalue name="type" value="1"/>
</fixedvalues>
</number>
</structure>
<structure name="METADATA_BLOCK_APPLICATION" id="963" extends="id:958">
<number name="BLOCK_TYPE" mustmatch="yes" id="1019" type="integer" length="7" lengthunit="bit">
<fixedvalues>
<fixedvalue name="type" value="2"/>
</fixedvalues>
</number>
</structure>
<structure name="METADATA_BLOCK_SEEKTABLE" id="965" extends="id:958">
<number name="BLOCK_TYPE" mustmatch="yes" id="1025" type="integer" length="7" lengthunit="bit">
<fixedvalues>
<fixedvalue name="type" value="3"/>
</fixedvalues>
</number>
<structure name="BLOCK_DATA" id="1026" length="BLOCK_LENGTH">
<structref name="SEEK_POINT" id="1028" repeatmin="0" repeatmax="-1" structure="id:983"/>
</structure>
</structure>
<structure name="METADATA_BLOCK_VORBIS_COMMENT" id="967" extends="id:958">
<number name="BLOCK_TYPE" mustmatch="yes" id="1032" type="integer" length="7" lengthunit="bit">
<fixedvalues>
<fixedvalue name="type" value="4"/>
</fixedvalues>
</number>
</structure>
<structure name="METADATA_BLOCK_CUESHEET" id="969" extends="id:958">
<number name="BLOCK_TYPE" mustmatch="yes" id="1038" type="integer" length="7" lengthunit="bit">
<fixedvalues>
<fixedvalue name="type" value="5"/>
</fixedvalues>
</number>
</structure>
<structure name="METADATA_BLOCK_PICTURE" id="971" extends="id:958">
<number name="BLOCK_TYPE" mustmatch="yes" id="1044" type="integer" length="7" lengthunit="bit">
<fixedvalues>
<fixedvalue name="type" value="6"/>
</fixedvalues>
</number>
</structure>
</grammar>
</ufwb>