summaryrefslogtreecommitdiff
path: root/doc/html/format.html
blob: ce1e483d14d916000746f12d8951edd483d092a3 (plain)
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Copyright (c) 2000-2009  Josh Coalson -->
<!-- Copyright (c) 2011-2016  Xiph.Org Foundation -->
<!-- Permission is granted to copy, distribute and/or modify this document -->
<!-- under the terms of the GNU Free Documentation License, Version 1.1 -->
<!-- or any later version published by the Free Software Foundation; -->
<!-- with no invariant sections. -->
<!-- A copy of the license can be found at http://www.gnu.org/copyleft/fdl.html -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<meta name="author" content="Josh Coalson" />
	<meta name="description" content="A free, open source codec for lossless audio compression and decompression" />
	<meta name="keywords" content="free,lossless,audio,codec,encoder,decoder,compression,compressor,archival,archive,archiving,backup,music" />
	<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
	<link rel="stylesheet" type="text/css" href="flac.css" />
	<title>FLAC - format</title>
</head>

<body>

<div class="logo">
	<a href="index.html"><img src="images/logo130.gif" alt="FLAC Logo" align="middle" border="0" hspace="0" /></a>
</div>

<div class="above_nav"></div>

<div class="navbar">
	&nbsp;<a href="index.html">home</a>&nbsp;&nbsp;|
	&nbsp;<a href="faq.html">faq</a>&nbsp;&nbsp;|
	&nbsp;<a href="documentation.html">documentation</a>&nbsp;&nbsp;|
	&nbsp;<a href="developers.html">developers</a>&nbsp;&nbsp;|
	&nbsp;<a href="changelog.html">changelog</a>&nbsp;&nbsp;|
	&nbsp;<a href="http://xiph.org/flac">more</a>
</div>

<div class="below_nav"></div>

<div class="box">
	<div class="box_title">
		format
	</div>
	<div class="box_header"></div>
	<div class="box_body">
		This is a detailed description of the FLAC format.  There is also a companion document that describes <a href="ogg_mapping.html">FLAC-to-Ogg mapping</a>.<br />
		<br />
		For a user-oriented overview, see <a href="documentation_format_overview.html">About the FLAC Format</a>.<br />
		<br />
		<a name="toc"><font size="+1"><b><u>Table of Contents</u></b></font></a>
		<ul>
			<li><a href="#acknowledgments">Acknowledgments</a></li>
			<li><a href="#scope">Scope</a></li>
			<li><a href="#architecture">Architecture</a></li>
			<li><a href="#definitions">Definitions</a></li>
			<li><a href="#blocking">Blocking</a></li>
			<li><a href="#interchannel">Interchannel Decorrelation</a></li>
			<li><a href="#prediction">Prediction</a></li>
			<li><a href="#residualcoding">Residual Coding</a></li>
			<li><a href="#format_overview">Format</a></li>
			<li><a href="#subset">FLAC Subset</a></li>
			<li>Specification
				<ul>
					<li><a href="#stream">STREAM</a>
						<ul>
							<li><a href="#metadata_block">METADATA_BLOCK</a>
								<ul>
									<li><a href="#metadata_block_header">METADATA_BLOCK_HEADER</a></li>
									<li><a href="#metadata_block_data">METADATA_BLOCK_DATA</a>
										<ul>
											<li><a href="#metadata_block_streaminfo">METADATA_BLOCK_STREAMINFO</a></li>
											<li><a href="#metadata_block_padding">METADATA_BLOCK_PADDING</a></li>
											<li><a href="#metadata_block_application">METADATA_BLOCK_APPLICATION</a></li>
											<li><a href="#metadata_block_seektable">METADATA_BLOCK_SEEKTABLE</a>
												<ul>
													<li><a href="#seekpoint">SEEKPOINT</a></li>
												</ul>
											</li>
											<li><a href="#metadata_block_vorbis_comment">METADATA_BLOCK_VORBIS_COMMENT</a></li>
											<li><a href="#metadata_block_cuesheet">METADATA_BLOCK_CUESHEET</a>
												<ul>
													<li><a href="#cuesheet_track">CUESHEET_TRACK</a>
														<ul>
															<li><a href="#cuesheet_track_index">CUESHEET_TRACK_INDEX</a></li>
														</ul>
													</li>
												</ul>
											</li>
											<li><a href="#metadata_block_picture">METADATA_BLOCK_PICTURE</a></li>
										</ul>
									</li>
								</ul>
							</li>
						</ul>
					</li>
					<li>
						<ul>
							<li><a href="#frame">FRAME</a>
								<ul>
									<li><a href="#frame_header">FRAME_HEADER</a></li>
									<li><a href="#frame_footer">FRAME_FOOTER</a></li>
									<li><a href="#subframe">SUBFRAME</a>
										<ul>
											<li><a href="#subframe_header">SUBFRAME_HEADER</a></li>
											<li><a href="#subframe_constant">SUBFRAME_CONSTANT</a></li>
											<li><a href="#subframe_fixed">SUBFRAME_FIXED</a></li>
											<li><a href="#subframe_lpc">SUBFRAME_LPC</a></li>
											<li><a href="#subframe_verbatim">SUBFRAME_VERBATIM</a>
												<ul>
													<li><a href="#residual">RESIDUAL</a>
														<ul>
															<li><a href="#partitioned_rice">RESIDUAL_CODING_METHOD_PARTITIONED_RICE</a>
																<ul>
																	<li><a href="#rice_partition">RICE_PARTITION</a></li>
																</ul>
															</li>
															<li><a href="#partitioned_rice2">RESIDUAL_CODING_METHOD_PARTITIONED_RICE2</a>
																<ul>
																	<li><a href="#rice2_partition">RICE2_PARTITION</a></li>
																</ul>
															</li>
														</ul>
													</li>
												</ul>
											</li>
										</ul>
									</li>
								</ul>
							</li>
						</ul>
					</li>
				</ul>
			</li>
		</ul>
		<a name="acknowledgments"><font size="+1"><b><u>Acknowledgments</u></b></font></a><br />
		<br />
		FLAC owes much to the many people who have advanced the audio compression field so freely.  For instance:
		<ul>
			<li>
				<a href="http://svr-www.eng.cam.ac.uk/~ajr/">A. J. Robinson</a> for his work on <a href="http://svr-www.eng.cam.ac.uk/reports/abstracts/robinson_tr156.html">Shorten</a>; his paper is a good starting point on some of the basic methods used by FLAC.  FLAC trivially extends and improves the fixed predictors, LPC coefficient quantization, and Rice coding used in Shorten.
			</li>
			<li>
				<a href="https://web.archive.org/web/20040215005354/http://csi.usc.edu/faculty/golomb.html">S. W. Golomb</a> and Robert F. Rice; their universal codes are used by FLAC's entropy coder.
			</li>
			<li>
				N. Levinson and J. Durbin; the reference encoder uses an algorithm developed and refined by them for determining the LPC coefficients from the autocorrelation coefficients.
			</li>
			<li>
				And of course, <a href="http://en.wikipedia.org/wiki/Claude_Shannon">Claude Shannon</a>
			</li>
		</ul>
		<a name="scope"><font size="+1"><b><u>Scope</u></b></font></a><br />
		<br />
		It is a known fact that no algorithm can losslessly compress all possible input, so most compressors restrict themselves to a useful domain and try to work as well as possible within that domain.  FLAC's domain is audio data.  Though it can losslessly <b>code</b> any input, only certain kinds of input will get smaller.  FLAC exploits the fact that audio data typically has a high degree of sample-to-sample correlation.<br />
		<br />
		Within the audio domain, there are many possible subdomains.  For example: low bitrate speech, high-bitrate multi-channel music, etc.  FLAC itself does not target a specific subdomain but many of the default parameters of the reference encoder are tuned to CD-quality music data (i.e. 44.1kHz, 2 channel, 16 bits per sample).  The effect of the encoding parameters on different kinds of audio data will be examined later.<br />
		<br />
		<a name="architecture"><font size="+1"><b><u>Architecture</u></b></font></a><br />
		<br />
		Similar to many audio coders, a FLAC encoder has the following stages:
		<ul>
			<li>
				<a href="#blocking">Blocking</a>.  The input is broken up into many contiguous blocks.  With FLAC, the blocks may vary in size.  The optimal size of the block is usually affected by many factors, including the sample rate, spectral characteristics over time, etc.  Though FLAC allows the block size to vary within a stream, the reference encoder uses a fixed block size.
			</li>
			<li>
				<a href="#interchannel">Interchannel Decorrelation</a>.  In the case of stereo streams, the encoder will create mid and side signals based on the average and difference (respectively) of the left and right channels.  The encoder will then pass the best form of the signal to the next stage.
			</li>
			<li>
				<a href="#prediction">Prediction</a>.  The block is passed through a prediction stage where the encoder tries to find a mathematical description (usually an approximate one) of the signal.  This description is typically much smaller than the raw signal itself.  Since the methods of prediction are known to both the encoder and decoder, only the parameters of the predictor need be included in the compressed stream.  FLAC currently uses four different classes of predictors (described in the <a href="#prediction">prediction</a> section), but the format has reserved space for additional methods.  FLAC allows the class of predictor to change from block to block, or even within the channels of a block.
			</li>
			<li>
				<a href="#residualcoding">Residual coding</a>.  If the predictor does not describe the signal exactly, the difference between the original signal and the predicted signal (called the error or residual signal) must be coded losslessy.  If the predictor is effective, the residual signal will require fewer bits per sample than the original signal.  FLAC currently uses only one method for encoding the residual (see the <a href="#residualcoding">Residual coding</a> section), but the format has reserved space for additional methods.  FLAC allows the residual coding method to change from block to block, or even within the channels of a block.
			</li>
		</ul>
		In addition, FLAC specifies a metadata system, which allows arbitrary information about the stream to be included at the beginning of the stream.<br />
		<br />
		<a name="definitions"><font size="+1"><b><u>Definitions</u></b></font></a><br />
		<br />
		Many terms like "block" and "frame" are used to mean different things in different encoding schemes.  For example, a frame in MP3 corresponds to many samples across several channels, whereas an S/PDIF frame represents just one sample for each channel.  The definitions we use for FLAC follow.  Note that when we talk about blocks and subblocks we are referring to the raw unencoded audio data that is the input to the encoder, and when we talk about frames and subframes, we are referring to the FLAC-encoded data.
		<ul>
			<li>
				<b>Block</b>: One or more audio samples that span several channels.
			</li>
			<li>
				<b>Subblock</b>: One or more audio samples within a channel.  So a block contains one subblock for each channel, and all subblocks contain the same number of samples.
			</li>
			<li>
				<b>Blocksize</b>: The number of samples in any of a block's subblocks.  For example, a one second block sampled at 44.1KHz has a blocksize of 44100, regardless of the number of channels.
			</li>
			<li>
				<b>Frame</b>: A frame header plus one or more subframes.
			</li>
			<li>
				<b>Subframe</b>: A subframe header plus one or more encoded samples from a given channel.  All subframes within a frame will contain the same number of samples.
			</li>
		</ul>
		<a name="blocking"><font size="+1"><b><u>Blocking</u></b></font></a><br />
		<br />
		The size used for blocking the audio data has a direct effect on the compression ratio.  If the block size is too small, the resulting large number of frames mean that excess bits will be wasted on frame headers.  If the block size is too large, the characteristics of the signal may vary so much that the encoder will be unable to find a good predictor.  In order to simplify encoder/decoder design, FLAC imposes a minimum block size of 16 samples, and a maximum block size of 65535 samples.  This range covers the optimal size for all of the audio data FLAC supports.<br />
		<br />
		Currently the reference encoder uses a fixed block size, optimized on the sample rate of the input.  Future versions may vary the block size depending on the characteristics of the signal.<br />
		<br />
		Blocked data is passed to the predictor stage one subblock (channel) at a time.  Each subblock is independently coded into a subframe, and the subframes are concatenated into a frame.  Because each channel is coded separately, it means that one channel of a stereo frame may be encoded as a constant subframe, and the other an LPC subframe.<br />
		<br />
		<a name="interchannel"><font size="+1"><b><u>Interchannel Decorrelation</u></b></font></a><br />
		<br />
		In stereo streams, many times there is an exploitable amount of correlation between the left and right channels.  FLAC allows the frames of stereo streams to have different channel assignments, and an encoder may choose to use the best representation on a frame-by-frame basis.
		<ul>
			<li>
				<b>Independent</b>.  The left and right channels are coded independently.
			</li>
			<li>
				<b>Mid-side</b>.  The left and right channels are transformed into mid and side channels.  The mid channel is the midpoint (average) of the left and right signals, and the side is the difference signal (left minus right).
			</li>
			<li>
				<b>Left-side</b>.  The left channel and side channel are coded.
			</li>
			<li>
				<b>Right-side</b>.  The right channel and side channel are coded
			</li>
		</ul>
		Surprisingly, the left-side and right-side forms can be the most efficient in many frames, even though the raw number of bits per sample needed for the original signal is slightly more than that needed for independent or mid-side coding.<br />
		<br />
		<a name="prediction"><font size="+1"><b><u>Prediction</u></b></font></a><br />
		<br />
		FLAC uses four methods for modeling the input signal:
		<ul>
			<li>
				<b>Verbatim</b>.  This is essentially a zero-order predictor of the signal.  The predicted signal is zero, meaning the residual is the signal itself, and the compression is zero.  This is the baseline against which the other predictors are measured.  If you feed random data to the encoder, the verbatim predictor will probably be used for every subblock.  Since the raw signal is not actually passed through the residual coding stage (it is added to the stream 'verbatim'), the encoding results will not be the same as a zero-order linear predictor.
			</li>
			<li>
				<b>Constant</b>.  This predictor is used whenever the subblock is pure DC ("digital silence"), i.e. a constant value throughout.  The signal is run-length encoded and added to the stream.
			</li>
			<li>
				<b>Fixed linear predictor</b>.  FLAC uses a class of computationally-efficient fixed linear predictors (for a good description, see <a href="http://www.hpl.hp.com/techreports/1999/HPL-1999-144.pdf">audiopak</a> and <a href="http://svr-www.eng.cam.ac.uk/reports/abstracts/robinson_tr156.html">shorten</a>).  FLAC adds a fourth-order predictor to the zero-to-third-order predictors used by Shorten.  Since the predictors are fixed, the predictor order is the only parameter that needs to be stored in the compressed stream.  The error signal is then passed to the residual coder.
			</li>
			<li>
				<b>FIR Linear prediction</b>.  For more accurate modeling (at a cost of slower encoding), FLAC supports up to 32nd order FIR linear prediction (again, for information on linear prediction, see <a href="http://www.hpl.hp.com/techreports/1999/HPL-1999-144.pdf">audiopak</a> and <a href="http://svr-www.eng.cam.ac.uk/reports/abstracts/robinson_tr156.html">shorten</a>).  The reference encoder uses the Levinson-Durbin method for calculating the LPC coefficients from the autocorrelation coefficients, and the coefficients are quantized before computing the residual.  Whereas encoders such as Shorten used a fixed quantization for the entire input, FLAC allows the quantized coefficient precision to vary from subframe to subframe.  The FLAC reference encoder estimates the optimal precision to use based on the block size and dynamic range of the original signal.
			</li>
		</ul>
		<a name="residualcoding"><font size="+1"><b><u>Residual Coding</u></b></font></a><br />
		<br />
		FLAC currently defines two similar methods for the coding of the error signal from the prediction stage.  The error signal is coded using Rice codes in one of two ways: 1) the encoder estimates a single Rice parameter based on the variance of the residual and Rice codes the entire residual using this parameter; 2) the residual is partitioned into several equal-length regions of contiguous samples, and each region is coded with its own Rice parameter based on the region's mean.  (Note that the first method is a special case of the second method with one partition, except the Rice parameter is based on the residual variance instead of the mean.)<br />
		<br />
		The FLAC format has reserved space for other coding methods.  Some possibilities for volunteers would be to explore better context-modeling of the Rice parameter, or Huffman coding.  See <a href="http://www.hpl.hp.com/techreports/98/HPL-98-193.html">LOCO-I</a> and <a href="http://www.cs.tut.fi/~albert/Dev/pucrunch/packing.html">pucrunch</a> for descriptions of several universal codes.<br />
		<br />
		<a name="format_overview"><font size="+1"><b><u>Format</u></b></font></a><br />
		<br />
		This section specifies the FLAC bitstream format.  FLAC has no format version information, but it does contain reserved space in several places.  Future versions of the format may use this reserved space safely without breaking the format of older streams.  Older decoders may choose to abort decoding or skip data encoded with newer methods.  Apart from reserved patterns, in places the format specifies invalid patterns, meaning that the patterns may never appear in any valid bitstream, in any prior, present, or future versions of the format.  These invalid patterns are usually used to make the synchronization mechanism more robust.<br />
		<br />
		All numbers used in a FLAC bitstream are integers; there are no floating-point representations.  All numbers are big-endian coded.  All numbers are unsigned unless otherwise specified.<br />
		<br />
		Before the formal description of the stream, an overview might be helpful.
		<ul>
			<li>
				A FLAC bitstream consists of the "fLaC" marker at the beginning of the stream, followed by a mandatory metadata block (called the STREAMINFO block), any number of other metadata blocks, then the audio frames.
			</li>
			<li>
				FLAC supports up to 128 kinds of metadata blocks; currently the following are defined:
				<ul>
					<li><a name="def_STREAMINFO"><b>STREAMINFO</b></a>: This block has information about the whole stream, like sample rate, number of channels, total number of samples, etc.  It must be present as the first metadata block in the stream.  Other metadata blocks may follow, and ones that the decoder doesn't understand, it will skip.</li>
					<li><a name="def_APPLICATION"><b>APPLICATION</b></a>: This block is for use by third-party applications.  The only mandatory field is a 32-bit identifier.  This ID is granted upon request to an application by the FLAC maintainers.  The remainder is of the block is defined by the registered application.  Visit the <a href="id.html">registration page</a> if you would like to register an ID for your application with FLAC.</li>
					<li><a name="def_PADDING"><b>PADDING</b></a>: This block allows for an arbitrary amount of padding.  The contents of a PADDING block have no meaning.  This block is useful when it is known that metadata will be edited after encoding; the user can instruct the encoder to reserve a PADDING block of sufficient size so that when metadata is added, it will simply overwrite the padding (which is relatively quick) instead of having to insert it into the right place in the existing file (which would normally require rewriting the entire file).</li>
					<li><a name="def_SEEKTABLE"><b>SEEKTABLE</b></a>: This is an optional block for storing seek points.  It is possible to seek to any given sample in a FLAC stream without a seek table, but the delay can be unpredictable since the bitrate may vary widely within a stream.  By adding seek points to a stream, this delay can be significantly reduced.  Each seek point takes 18 bytes, so 1% resolution within a stream adds less than 2k.  There can be only one SEEKTABLE in a stream, but the table can have any number of seek points.  There is also a special 'placeholder' seekpoint which will be ignored by decoders but which can be used to reserve space for future seek point insertion.</li>
					<li><a name="def_VORBIS_COMMENT"><b>VORBIS_COMMENT</b></a>: This block is for storing a list of human-readable name/value pairs.  Values are encoded using UTF-8.  It is an implementation of the <a href="http://xiph.org/vorbis/doc/v-comment.html">Vorbis comment specification</a> (without the framing bit).  This is the only officially supported tagging mechanism in FLAC.  There may be only one VORBIS_COMMENT block in a stream.  In some external documentation, Vorbis comments are called FLAC tags to lessen confusion.</li>
					<li><a name="def_CUESHEET"><b>CUESHEET</b></a>: This block is for storing various information that can be used in a cue sheet.  It supports track and index points, compatible with Red Book CD digital audio discs, as well as other CD-DA metadata such as media catalog number and track ISRCs.  The CUESHEET block is especially useful for backing up CD-DA discs, but it can be used as a general purpose cueing mechanism for playback.</li>
					<li><a name="def_PICTURE"><b>PICTURE</b></a>: This block is for storing pictures associated with the file, most commonly cover art from CDs.  There may be more than one PICTURE block in a file.  The picture format is similar to the <a href="http://www.id3.org/id3v2.4.0-frames">APIC frame in ID3v2</a>.  The PICTURE block has a type, MIME type, and UTF-8 description like ID3v2, and supports external linking via URL (though this is discouraged).  The differences are that there is no uniqueness constraint on the description field, and the MIME type is mandatory.  The FLAC PICTURE block also includes the resolution, color depth, and palette size so that the client can search for a suitable picture without having to scan them all.</li>
				</ul>
			</li>
			<li>
				The audio data is composed of one or more audio frames.  Each frame consists of a frame header, which contains a sync code, information about the frame like the block size, sample rate, number of channels, et cetera, and an 8-bit CRC.  The frame header also contains either the sample number of the first sample in the frame (for variable-blocksize streams), or the frame number (for fixed-blocksize streams).  This allows for fast, sample-accurate seeking to be performed.  Following the frame header are encoded subframes, one for each channel, and finally, the frame is zero-padded to a byte boundary.  Each subframe has its own header that specifies how the subframe is encoded.
			</li>
			<li>
				Since a decoder may start decoding in the middle of a stream, there must be a method to determine the start of a frame.  A 14-bit sync code begins each frame.  The sync code will not appear anywhere else in the frame header.  However, since it may appear in the subframes, the decoder has two other ways of ensuring a correct sync.  The first is to check that the rest of the frame header contains no invalid data.  Even this is not foolproof since valid header patterns can still occur within the subframes.  The decoder's final check is to generate an 8-bit CRC of the frame header and compare this to the CRC stored at the end of the frame header.
			</li>
			<li>
				Again, since a decoder may start decoding at an arbitrary frame in the stream, each frame header must contain some basic information about the stream because the decoder may not have access to the STREAMINFO metadata block at the start of the stream.  This information includes sample rate, bits per sample, number of channels, etc.  Since the frame header is pure overhead, it has a direct effect on the compression ratio.  To keep the frame header as small as possible, FLAC uses lookup tables for the most commonly used values for frame parameters.  For instance, the sample rate part of the frame header is specified using 4 bits.  Eight of the bit patterns correspond to the commonly used sample rates of 8/16/22.05/24/32/44.1/48/96 kHz.  However, odd sample rates can be specified by using one of the 'hint' bit patterns, directing the decoder to find the exact sample rate at the end of the frame header.  The same method is used for specifying the block size and bits per sample.  In this way, the frame header size stays small for all of the most common forms of audio data.
			</li>
			<li>
				Individual subframes (one for each channel) are coded separately within a frame, and appear serially in the stream.  In other words, the encoded audio data is NOT channel-interleaved.  This reduces decoder complexity at the cost of requiring larger decode buffers.  Each subframe has its own header specifying the attributes of the subframe, like prediction method and order, residual coding parameters, etc.  The header is followed by the encoded audio data for that channel.
			</li>
			<li>
				<a name="subset">FLAC</a> specifies a subset of itself as the Subset format.  The purpose of this is to ensure that any streams encoded according to the Subset are truly "streamable", meaning that a decoder that cannot seek within the stream can still pick up in the middle of the stream and start decoding.  It also makes hardware decoder implementations more practical by limiting the encoding parameters such that decoder buffer sizes and other resource requirements can be easily determined.  <span class="commandname">flac</span> generates Subset streams by default unless the "--lax" command-line option is used.  The Subset makes the following limitations on what may be used in the stream:
				<ul>
				<li>
					The blocksize bits in the <a href="#frame_header">frame header</a> must be 0001-1110.  The blocksize must be &lt;=16384; if the sample rate is &lt;= 48000Hz, the blocksize must be &lt;=4608.
				</li>
				<li>
					The sample rate bits in the <a href="#frame_header">frame header</a> must be 0001-1110.
				</li>
				<li>
					The bits-per-sample bits in the <a href="#frame_header">frame header</a> must be 001-111.
				</li>
				<li>
					If the sample rate is &lt;= 48000Hz, the filter order in <a href="#subframe_lpc">LPC subframes</a> must be less than or equal to 12, i.e. the subframe type bits in the <a href="#subframe_header">subframe header</a> may not be 101100-111111.
				</li>
				<li>
					The Rice partition order in a <a href="#partitioned_rice">Rice-coded residual section</a> must be less than or equal to 8.
				</li>
				</ul>
			</li>
		</ul>

		The following tables constitute a formal description of the FLAC format.  Numbers in angle brackets indicate how many bits are used for a given field.<br />
	</div>
	<div class="box_footer"></div>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="stream"><font size="+1"><b>STREAM</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;32&gt;
			</td>
			<td>
				"fLaC", the FLAC stream marker in ASCII, meaning byte 0 of the stream is 0x66, followed by 0x4C 0x61 0x43
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#metadata_block_streaminfo"><i>METADATA_BLOCK</i></a>
			</td>
			<td>
				This is the mandatory STREAMINFO metadata block that has the basic properties of the stream
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#metadata_block"><i>METADATA_BLOCK</i></a>*
			</td>
			<td>
				Zero or more metadata blocks
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#frame"><i>FRAME</i></a>+
			</td>
			<td>
				One or more audio frames
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="metadata_block"><font size="+1"><b>METADATA_BLOCK</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#metadata_block_header"><i>METADATA_BLOCK_HEADER</i></a>
			</td>
			<td>
				A block header that specifies the type and size of the metadata block data.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#metadata_block_data"><i>METADATA_BLOCK_DATA</i></a>
			</td>
			<td>
				&nbsp;
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="metadata_block_header"><font size="+1"><b>METADATA_BLOCK_HEADER</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;1&gt;
			</td>
			<td>
				Last-metadata-block flag: '1' if this block is the last metadata block before the audio blocks, '0' otherwise.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;7&gt;
			</td>
			<td>
				BLOCK_TYPE<br />
				<ul>
				<li>
					<tt>0</tt> : STREAMINFO
				</li>
				<li>
					<tt>1</tt> : PADDING
				</li>
				<li>
					<tt>2</tt> : APPLICATION
				</li>
				<li>
					<tt>3</tt> : SEEKTABLE
				</li>
				<li>
					<tt>4</tt> : VORBIS_COMMENT
				</li>
				<li>
					<tt>5</tt> : CUESHEET
				</li>
				<li>
					<tt>6</tt> : PICTURE
				</li>
				<li>
					<tt>7-126</tt> : reserved
				</li>
				<li>
					<tt>127</tt> : invalid, to avoid confusion with a frame sync code
				</li>
				</ul>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;24&gt;
			</td>
			<td>
				Length (in bytes) of metadata to follow (does not include the size of the METADATA_BLOCK_HEADER)
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="metadata_block_data"><font size="+1"><b>METADATA_BLOCK_DATA</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#metadata_block_streaminfo"><i>METADATA_BLOCK_STREAMINFO</i></a><br />
				|| <a href="#metadata_block_padding"><i>METADATA_BLOCK_PADDING</i></a><br />
				|| <a href="#metadata_block_application"><i>METADATA_BLOCK_APPLICATION</i></a><br />
				|| <a href="#metadata_block_seektable"><i>METADATA_BLOCK_SEEKTABLE</i></a><br />
				|| <a href="#metadata_block_vorbis_comment"><i>METADATA_BLOCK_VORBIS_COMMENT</i></a><br />
				|| <a href="#metadata_block_cuesheet"><i>METADATA_BLOCK_CUESHEET</i></a><br />
				|| <a href="#metadata_block_picture"><i>METADATA_BLOCK_PICTURE</i></a>
			</td>
			<td>
				The block data must match the block type in the block header.
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="metadata_block_streaminfo"><font size="+1"><b>METADATA_BLOCK_STREAMINFO</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;16&gt;
			</td>
			<td>
				The minimum block size (in samples) used in the stream.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;16&gt;
			</td>
			<td>
				The maximum block size (in samples) used in the stream.  (Minimum blocksize == maximum blocksize) implies a fixed-blocksize stream.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;24&gt;
			</td>
			<td>
				The minimum frame size (in bytes) used in the stream.  May be 0 to imply the value is not known.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;24&gt;
			</td>
			<td>
				The maximum frame size (in bytes) used in the stream.  May be 0 to imply the value is not known.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;20&gt;
			</td>
			<td>
				Sample rate in Hz.  Though 20 bits are available, the maximum sample rate is limited by the structure of frame headers to 655350Hz.  Also, a value of 0 is invalid.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;3&gt;
			</td>
			<td>
				(number of channels)-1.  FLAC supports from 1 to 8 channels
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;5&gt;
			</td>
			<td>
				(bits per sample)-1.  FLAC supports from 4 to 32 bits per sample.  Currently the reference encoder and decoders only support up to 24 bits per sample.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;36&gt;
			</td>
			<td>
				Total samples in stream.  'Samples' means inter-channel sample, i.e. one second of 44.1Khz audio will have 44100 samples regardless of the number of channels.  A value of zero here means the number of total samples is unknown.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;128&gt;
			</td>
			<td>
				MD5 signature of the unencoded audio data.  This allows the decoder to determine if an error exists in the audio data even when the error does not result in an invalid bitstream.
			</td>
		</tr>
		<tr>
			<td>
			</td>
			<td bgcolor="#F4F4CC">
				<font size="+1">NOTES</font><br />
				<ul>
				<li>
					FLAC specifies a minimum block size of 16 and a maximum block size of 65535, meaning the bit patterns corresponding to the numbers 0-15 in the minimum blocksize and maximum blocksize fields are invalid.
				</li>
				</ul>
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="metadata_block_padding"><font size="+1"><b>METADATA_BLOCK_PADDING</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;n&gt;
			</td>
			<td>
				n '0' bits (n must be a multiple of 8)
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="metadata_block_application"><font size="+1"><b>METADATA_BLOCK_APPLICATION</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;32&gt;
			</td>
			<td>
				Registered application ID.  (Visit the <a href="id.html">registration page</a> to register an ID with FLAC.)
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;n&gt;
			</td>
			<td>
				Application data (n must be a multiple of 8)
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="metadata_block_seektable"><font size="+1"><b>METADATA_BLOCK_SEEKTABLE</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#seekpoint"><i>SEEKPOINT</i></a>+
			</td>
			<td>
				One or more seek points.
			</td>
		</tr>
		<tr>
			<td>
			</td>
			<td bgcolor="#F4F4CC">
				<font size="+1">NOTE</font><br />
				<ul>
				<li>
					The number of seek points is implied by the metadata header 'length' field, i.e. equal to length / 18.
				</li>
				</ul>
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="seekpoint"><font size="+1"><b>SEEKPOINT</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;64&gt;
			</td>
			<td>
				Sample number of first sample in the target frame, or 0xFFFFFFFFFFFFFFFF for a placeholder point.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;64&gt;
			</td>
			<td>
				Offset (in bytes) from the first byte of the first frame header to the first byte of the target frame's header.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;16&gt;
			</td>
			<td>
				Number of samples in the target frame.
			</td>
		</tr>
		<tr>
			<td>
			</td>
			<td bgcolor="#F4F4CC">
				<font size="+1">NOTES</font><br />
				<ul>
				<li>
					For placeholder points, the second and third field values are undefined.
				</li>
				<li>
					Seek points within a table must be sorted in ascending order by sample number.
				</li>
				<li>
					Seek points within a table must be unique by sample number, with the exception of placeholder points.
				</li>
				<li>
					The previous two notes imply that there may be any number of placeholder points, but they must all occur at the end of the table.
				</li>
				</ul>
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="metadata_block_vorbis_comment"><font size="+1"><b>METADATA_BLOCK_VORBIS_COMMENT</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;n&gt;
			</td>
			<td>
				Also known as FLAC tags, the contents of a vorbis comment packet as specified <a href="http://www.xiph.org/vorbis/doc/v-comment.html">here</a> (without the framing bit).  Note that the vorbis comment spec allows for on the order of 2 ^ 64 bytes of data where as the FLAC metadata block is limited to 2 ^ 24 bytes.  Given the stated purpose of vorbis comments, i.e. human-readable textual information, this limit is unlikely to be restrictive.  Also note that the 32-bit field lengths are little-endian coded according to the vorbis spec, as opposed to the usual big-endian coding of fixed-length integers in the rest of FLAC.
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="metadata_block_cuesheet"><font size="+1"><b>METADATA_BLOCK_CUESHEET</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;128*8&gt;
			</td>
			<td>
				Media catalog number, in ASCII printable characters 0x20-0x7e.  In general, the media catalog number may be 0 to 128 bytes long; any unused characters should be right-padded with NUL characters.  For CD-DA, this is a thirteen digit number, followed by 115 NUL bytes.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;64&gt;
			</td>
			<td>
				The number of lead-in samples.  This field has meaning only for CD-DA cuesheets; for other uses it should be 0.  For CD-DA, the lead-in is the TRACK 00 area where the table of contents is stored; more precisely, it is the number of samples from the first sample of the media to the first sample of the first index point of the first track.  According to the Red Book, the lead-in must be silence and CD grabbing software does not usually store it; additionally, the lead-in must be at least two seconds but may be longer.  For these reasons the lead-in length is stored here so that the absolute position of the first track can be computed.  Note that the lead-in stored here is the number of samples up to the first index point of the first track, not necessarily to INDEX 01 of the first track; even the first track may have INDEX 00 data.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;1&gt;
			</td>
			<td>
				<tt>1</tt> if the CUESHEET corresponds to a Compact Disc, else <tt>0</tt>.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;7+258*8&gt;
			</td>
			<td>
				Reserved.  All bits must be set to zero.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;8&gt;
			</td>
			<td>
				The number of tracks.  Must be at least 1 (because of the requisite lead-out track).  For CD-DA, this number must be no more than 100 (99 regular tracks and one lead-out track).
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#cuesheet_track"><i>CUESHEET_TRACK</i></a>+
			</td>
			<td>
				One or more tracks.  A CUESHEET block is required to have a lead-out track; it is always the last track in the CUESHEET.  For CD-DA, the lead-out track number must be 170 as specified by the Red Book, otherwise is must be 255.
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="cuesheet_track"><font size="+1"><b>CUESHEET_TRACK</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;64&gt;
			</td>
			<td>
				Track offset in samples, relative to the beginning of the FLAC audio stream.  It is the offset to the first index point of the track.  (Note how this differs from CD-DA, where the track's offset in the TOC is that of the track's INDEX 01 even if there is an INDEX 00.)  For CD-DA, the offset must be evenly divisible by 588 samples (588 samples = 44100 samples/sec * 1/75th of a sec).
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;8&gt;
			</td>
			<td>
				Track number.  A track number of 0 is not allowed to avoid conflicting with the CD-DA spec, which reserves this for the lead-in.  For CD-DA the number must be 1-99, or 170 for the lead-out; for non-CD-DA, the track number must for 255 for the lead-out.  It is not required but encouraged to start with track 1 and increase sequentially.  Track numbers must be unique within a CUESHEET.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;12*8&gt;
			</td>
			<td>
				Track ISRC.  This is a 12-digit alphanumeric code; see <a href="http://isrc.ifpi.org/">here</a> and <a href="http://www.disctronics.co.uk/technology/cdaudio/cdaud_isrc.htm">here</a>.  A value of 12 ASCII NUL characters may be used to denote absence of an ISRC.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;1&gt;
			</td>
			<td>
				The track type: 0 for audio, 1 for non-audio.  This corresponds to the CD-DA Q-channel control bit 3.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;1&gt;
			</td>
			<td>
				The pre-emphasis flag: 0 for no pre-emphasis, 1 for pre-emphasis.  This corresponds to the CD-DA Q-channel control bit 5; see <a href="http://www.chipchapin.com/CDMedia/cdda9.php3">here</a>.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;6+13*8&gt;
			</td>
			<td>
				Reserved.  All bits must be set to zero.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;8&gt;
			</td>
			<td>
				The number of track index points.  There must be at least one index in every track in a CUESHEET except for the lead-out track, which must have zero.  For CD-DA, this number may be no more than 100.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#cuesheet_track_index"><i>CUESHEET_TRACK_INDEX</i></a>+
			</td>
			<td>
				For all tracks except the lead-out track, one or more track index points.
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="cuesheet_track_index"><font size="+1"><b>CUESHEET_TRACK_INDEX</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;64&gt;
			</td>
			<td>
				Offset in samples, relative to the track offset, of the index point.  For CD-DA, the offset must be evenly divisible by 588 samples (588 samples = 44100 samples/sec * 1/75th of a sec).  Note that the offset is from the beginning of the track, not the beginning of the audio data.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;8&gt;
			</td>
			<td>
				The index point number.  For CD-DA, an index number of 0 corresponds to the track pre-gap.  The first index in a track must have a number of 0 or 1, and subsequently, index numbers must increase by 1.  Index numbers must be unique within a track.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;3*8&gt;
			</td>
			<td>
				Reserved.  All bits must be set to zero.
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="metadata_block_picture"><font size="+1"><b>METADATA_BLOCK_PICTURE</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;32&gt;
			</td>
			<td>
				The picture type according to the ID3v2 APIC frame:<br />
				<ul>
					<li>0 - Other</li>
					<li>1 - 32x32 pixels 'file icon' (PNG only)</li>
					<li>2 - Other file icon</li>
					<li>3 - Cover (front)</li>
					<li>4 - Cover (back)</li>
					<li>5 - Leaflet page</li>
					<li>6 - Media (e.g. label side of CD)</li>
					<li>7 - Lead artist/lead performer/soloist</li>
					<li>8 - Artist/performer</li>
					<li>9 - Conductor</li>
					<li>10 - Band/Orchestra</li>
					<li>11 - Composer</li>
					<li>12 - Lyricist/text writer</li>
					<li>13 - Recording Location</li>
					<li>14 - During recording</li>
					<li>15 - During performance</li>
					<li>16 - Movie/video screen capture</li>
					<li>17 - A bright coloured fish</li>
					<li>18 - Illustration</li>
					<li>19 - Band/artist logotype</li>
					<li>20 - Publisher/Studio logotype</li>
				</ul>
				Others are reserved and should not be used.  There may only be one each of picture type 1 and 2 in a file.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;32&gt;
			</td>
			<td>
				The length of the MIME type string in bytes.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;n*8&gt;
			</td>
			<td>
				The MIME type string, in printable ASCII characters 0x20-0x7e.  The MIME type may also be <tt>--&gt;</tt> to signify that the data part is a URL of the picture instead of the picture data itself.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;32&gt;
			</td>
			<td>
				The length of the description string in bytes.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;n*8&gt;
			</td>
			<td>
				The description of the picture, in UTF-8.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;32&gt;
			</td>
			<td>
				The width of the picture in pixels.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;32&gt;
			</td>
			<td>
				The height of the picture in pixels.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;32&gt;
			</td>
			<td>
				The color depth of the picture in bits-per-pixel.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;32&gt;
			</td>
			<td>
				For indexed-color pictures (e.g. GIF), the number of colors used, or <tt>0</tt> for non-indexed pictures.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;32&gt;
			</td>
			<td>
				The length of the picture data in bytes.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;n*8&gt;
			</td>
			<td>
				The binary picture data.
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="frame"><font size="+1"><b>FRAME</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#frame_header"><i>FRAME_HEADER</i></a>
			</td>
			<td>
				&nbsp;
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#subframe"><i>SUBFRAME</i></a>+
			</td>
			<td>
				One SUBFRAME per channel.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;?&gt;
			</td>
			<td>
				Zero-padding to byte alignment.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#frame_footer"><i>FRAME_FOOTER</i></a>
			</td>
			<td>
				&nbsp;
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="frame_header"><font size="+1"><b>FRAME_HEADER</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;14&gt;
			</td>
			<td>
				Sync code '<tt>11111111111110</tt>'
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;1&gt;
			</td>
			<td>
				Reserved: <a href="#frame_header_notes">[1]</a><br />
				<ul>
				<li>
					<tt>0</tt> : mandatory value
				</li>
				<li>
					<tt>1</tt> : reserved for future use
				</li>
				</ul>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;1&gt;
			</td>
			<td>
				Blocking strategy: <a href="#frame_header_notes">[2]</a> <a href="#frame_header_notes">[3]</a><br />
				<ul>
				<li>
					<tt>0</tt> : fixed-blocksize stream; frame header encodes the frame number
				</li>
				<li>
					<tt>1</tt> : variable-blocksize stream; frame header encodes the sample number
				</li>
				</ul>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;4&gt;
			</td>
			<td>
				Block size in inter-channel samples:<br />
				<ul>
				<li>
					<tt>0000</tt> : reserved
				</li>
				<li>
					<tt>0001</tt> : 192 samples
				</li>
				<li>
					<tt>0010-0101</tt> : 576 * (2^(n-2)) samples, i.e. 576/1152/2304/4608
				</li>
				<li>
					<tt>0110</tt> : get 8 bit (blocksize-1) from end of header
				</li>
				<li>
					<tt>0111</tt> : get 16 bit (blocksize-1) from end of header
				</li>
				<li>
					<tt>1000-1111</tt> : 256 * (2^(n-8)) samples, i.e. 256/512/1024/2048/4096/8192/16384/32768
				</li>
				</ul>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;4&gt;
			</td>
			<td>
				Sample rate:<br />
				<ul>
				<li>
					<tt>0000</tt> : get from STREAMINFO metadata block
				</li>
				<li>
					<tt>0001</tt> : 88.2kHz
				</li>
				<li>
					<tt>0010</tt> : 176.4kHz
				</li>
				<li>
					<tt>0011</tt> : 192kHz
				</li>
				<li>
					<tt>0100</tt> : 8kHz
				</li>
				<li>
					<tt>0101</tt> : 16kHz
				</li>
				<li>
					<tt>0110</tt> : 22.05kHz
				</li>
				<li>
					<tt>0111</tt> : 24kHz
				</li>
				<li>
					<tt>1000</tt> : 32kHz
				</li>
				<li>
					<tt>1001</tt> : 44.1kHz
				</li>
				<li>
					<tt>1010</tt> : 48kHz
				</li>
				<li>
					<tt>1011</tt> : 96kHz
				</li>
				<li>
					<tt>1100</tt> : get 8 bit sample rate (in kHz) from end of header
				</li>
				<li>
					<tt>1101</tt> : get 16 bit sample rate (in Hz) from end of header
				</li>
				<li>
					<tt>1110</tt> : get 16 bit sample rate (in tens of Hz) from end of header
				</li>
				<li>
					<tt>1111</tt> : invalid, to prevent sync-fooling string of 1s
				</li>
				</ul>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;4&gt;
			</td>
			<td>
				Channel assignment
				<ul>
				<li>
					<tt>0000-0111</tt> : (number of independent channels)-1.  Where defined, the channel order follows SMPTE/ITU-R recommendations.  The assignments are as follows:
					<ul>
						<li>1 channel: mono</li>
						<li>2 channels: left, right</li>
						<li>3 channels: left, right, center</li>
						<li>4 channels: front left, front right, back left, back right</li>
						<li>5 channels: front left, front right, front center, back/surround left, back/surround right</li>
						<li>6 channels: front left, front right, front center, LFE, back/surround left, back/surround right</li>
						<li>7 channels: front left, front right, front center, LFE, back center, side left, side right</li>
						<li>8 channels: front left, front right, front center, LFE, back left, back right, side left, side right</li>
					</ul>
				</li>
				<li>
					<tt>1000</tt> : left/side stereo: channel 0 is the left channel, channel 1 is the side(difference) channel
				</li>
				<li>
					<tt>1001</tt> : right/side stereo: channel 0 is the side(difference) channel, channel 1 is the right channel
				</li>
				<li>
					<tt>1010</tt> : mid/side stereo: channel 0 is the mid(average) channel, channel 1 is the side(difference) channel
				</li>
				<li>
					<tt>1011-1111</tt> : reserved
				</li>
				</ul>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;3&gt;
			</td>
			<td>
				Sample size in bits: <a href="#frame_header_notes">[5]</a><br />
				<ul>
				<li>
					<tt>000</tt> : get from STREAMINFO metadata block
				</li>
				<li>
					<tt>001</tt> : 8 bits per sample
				</li>
				<li>
					<tt>010</tt> : 12 bits per sample
				</li>
				<li>
					<tt>011</tt> : reserved
				</li>
				<li>
					<tt>100</tt> : 16 bits per sample
				</li>
				<li>
					<tt>101</tt> : 20 bits per sample
				</li>
				<li>
					<tt>110</tt> : 24 bits per sample
				</li>
				<li>
					<tt>111</tt> : reserved
				</li>
				</ul>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;1&gt;
			</td>
			<td>
				Reserved:<br />
				<ul>
				<li>
					<tt>0</tt> : mandatory value
				</li>
				<li>
					<tt>1</tt> : reserved for future use
				</li>
				</ul>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;?&gt;
			</td>
			<td>
				if(variable blocksize)<br />
				&nbsp;&nbsp;&nbsp;&lt;8-56&gt;:"UTF-8" coded sample number (decoded number is 36 bits) <a href="#frame_header_notes">[4]</a><br />
				else<br />
				&nbsp;&nbsp;&nbsp;&lt;8-48&gt;:"UTF-8" coded frame number (decoded number is 31 bits) <a href="#frame_header_notes">[4]</a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;?&gt;
			</td>
			<td>
				if(blocksize bits == 011x)<br />
				&nbsp;&nbsp;&nbsp;8/16 bit (blocksize-1)
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;?&gt;
			</td>
			<td>
				if(sample rate bits == 11xx)<br />
				&nbsp;&nbsp;&nbsp;8/16 bit sample rate
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;8&gt;
			</td>
			<td>
				CRC-8 (polynomial = x^8 + x^2 + x^1 + x^0, initialized with 0) of everything before the crc, including the sync code
			</td>
		</tr>
		<tr>
			<td>
			</td>
			<td bgcolor="#F4F4CC">
				<a name="frame_header_notes"><font size="+1">NOTES</font></a><br />
				<ol>
				<li>
					This bit must remain reserved for <tt>0</tt> in order for a FLAC frame's initial 15 bits to be distinguishable from the start of an MPEG audio frame (<a href="http://lists.xiph.org/pipermail/flac-dev/2008-December/002607.html">see also</a>).
				</li>
				<li>
					The "blocking strategy" bit must be the same throughout the entire stream.
				</li>
				<li>
					The "blocking strategy" bit determines how to calculate the sample number of the first sample in the frame.  If the bit is <tt>0</tt> (fixed-blocksize), the frame header encodes the frame number as above, and the frame's starting sample number will be the frame number times the blocksize.  If it is <tt>1</tt> (variable-blocksize), the frame header encodes the frame's starting sample number itself.  (In the case of a fixed-blocksize stream, only the last block may be shorter than the stream blocksize; its starting sample number will be calculated as the frame number times the previous frame's blocksize, or zero if it is the first frame).
				</li>
				<li>
					The "UTF-8" coding used for the sample/frame number is the same variable length code used to store compressed UCS-2, extended to handle larger input.
				</li>
				<li>
					For subframes that encode a difference channel,
					the sample size is one bit larger than the sample size of the frame,
					in order to be able to encode the difference between extreme values.
				</li>
				</ol>
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="frame_footer"><font size="+1"><b>FRAME_FOOTER</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;16&gt;
			</td>
			<td>
				CRC-16 (polynomial = x^16 + x^15 + x^2 + x^0, initialized with 0) of everything before the crc, back to and including the frame header sync code
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="subframe"><font size="+1"><b>SUBFRAME</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#subframe_header"><i>SUBFRAME_HEADER</i></a>
			</td>
			<td>
				&nbsp;
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#subframe_constant"><i>SUBFRAME_CONSTANT</i></a><br />|| <a href="#subframe_fixed"><i>SUBFRAME_FIXED</i></a><br />|| <a href="#subframe_lpc"><i>SUBFRAME_LPC</i></a><br />|| <a href="#subframe_verbatim"><i>SUBFRAME_VERBATIM</i></a>
			</td>
			<td valign="top">
				The SUBFRAME_HEADER specifies which one.
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="subframe_header"><font size="+1"><b>SUBFRAME_HEADER</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;1&gt;
			</td>
			<td>
				Zero bit padding, to prevent sync-fooling string of 1s
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;6&gt;
			</td>
			<td>
				Subframe type:
				<ul>
				<li>
					<tt>000000</tt> : <a href="#subframe_constant">SUBFRAME_CONSTANT</a>
				</li>
				<li>
					<tt>000001</tt> : <a href="#subframe_verbatim">SUBFRAME_VERBATIM</a>
				</li>
				<li>
					<tt>00001x</tt> : reserved
				</li>
				<li>
					<tt>0001xx</tt> : reserved
				</li>
				<li>
					<tt>001xxx</tt> : if(xxx &lt;= 4) <a href="#subframe_fixed">SUBFRAME_FIXED</a>, xxx=order ; else reserved
				</li>
				<li>
					<tt>01xxxx</tt> : reserved
				</li>
				<li>
					<tt>1xxxxx</tt> : <a href="#subframe_lpc">SUBFRAME_LPC</a>, xxxxx=order-1
				</li>
				</ul>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;1+k&gt;
			</td>
			<td>
				'Wasted bits-per-sample' flag:
				<ul>
				<li>
					<tt>0</tt> : no wasted bits-per-sample in source subblock, k=0
				</li>
				<li>
					<tt>1</tt> : k wasted bits-per-sample in source subblock, k-1 follows, unary coded; e.g. k=3 =&gt; 001 follows, k=7 =&gt; 0000001 follows.
				</li>
				</ul>
				The size of the samples stored in the subframe is the subframe sample size reduced by k bits.
				Decoded samples must be shifted left by k bits.
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="subframe_constant"><font size="+1"><b>SUBFRAME_CONSTANT</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;n&gt;
			</td>
			<td>
				Unencoded constant value of the subblock, n = frame's bits-per-sample.
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="subframe_fixed"><font size="+1"><b>SUBFRAME_FIXED</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;n&gt;
			</td>
			<td>
				Unencoded warm-up samples (n = frame's bits-per-sample * predictor order).
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#residual"><i>RESIDUAL</i></a>
			</td>
			<td>
				Encoded residual
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="subframe_lpc"><font size="+1"><b>SUBFRAME_LPC</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;n&gt;
			</td>
			<td>
				Unencoded warm-up samples (n = frame's bits-per-sample * lpc order).
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;4&gt;
			</td>
			<td>
				(Quantized linear predictor coefficients' precision in bits)-1 (1111 = invalid).
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;5&gt;
			</td>
			<td>
				Quantized linear predictor coefficient shift needed in bits (NOTE: this number is signed two's-complement;
				but, due to implementation details, must be non-negative).
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;n&gt;
			</td>
			<td>
				Unencoded predictor coefficients (n = qlp coeff precision * lpc order) (NOTE: the coefficients are signed two's-complement).
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#residual"><i>RESIDUAL</i></a>
			</td>
			<td>
				Encoded residual
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="subframe_verbatim"><font size="+1"><b>SUBFRAME_VERBATIM</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;n*i&gt;
			</td>
			<td>
				Unencoded subblock; n = frame's bits-per-sample, i = frame's blocksize.
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="residual"><font size="+1"><b>RESIDUAL</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;2&gt;
			</td>
			<td>
				Residual coding method:<br />
				<ul>
				<li>
					<tt>00</tt> : partitioned Rice coding with 4-bit Rice parameter; RESIDUAL_CODING_METHOD_PARTITIONED_RICE follows
				</li>
				<li>
					<tt>01</tt> : partitioned Rice coding with 5-bit Rice parameter; RESIDUAL_CODING_METHOD_PARTITIONED_RICE2 follows
				</li>
				<li>
					<tt>10-11</tt> : reserved
				</li>
				</ul>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#partitioned_rice"><i>RESIDUAL_CODING_METHOD_PARTITIONED_RICE</i></a>&nbsp;||<br />
				<a href="#partitioned_rice2"><i>RESIDUAL_CODING_METHOD_PARTITIONED_RICE2</i></a>
			</td>
			<td>
				&nbsp;
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="partitioned_rice"><font size="+1"><b>RESIDUAL_CODING_METHOD_PARTITIONED_RICE</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;4&gt;
			</td>
			<td>
				Partition order.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#rice_partition"><i>RICE_PARTITION</i></a>+
			</td>
			<td>
				There will be 2^order partitions.
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="rice_partition"><font size="+1"><b>RICE_PARTITION</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;4(+5)&gt;
			</td>
			<td>
				Encoding parameter:<br />
				<ul>
				<li>
					<tt>0000-1110</tt> : Rice parameter.
				</li>
				<li>
					<tt>1111</tt> : Escape code, meaning the partition is in unencoded binary form using n bits per sample; n follows as a 5-bit number.
				</li>
				</ul>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;?&gt;
			</td>
			<td>
				Encoded residual.  The number of samples (n) in the partition is determined as follows:<br />
				<ul>
				<li>
					partition size = (frame's blocksize / (2^partition order))
				</li>
				<li>
					for first partition of the subframe, n = partition size - predictor
				</li>
				<li>
					for remaining partitions, n = partition size
				</li>
				</ul>
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="partitioned_rice2"><font size="+1"><b>RESIDUAL_CODING_METHOD_PARTITIONED_RICE2</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;4&gt;
			</td>
			<td>
				Partition order.
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				<a href="#rice2_partition"><i>RICE2_PARTITION</i></a>+
			</td>
			<td>
				There will be 2^order partitions.
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>

<br />

<div class="box">
	<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EEEED4"><tr><td>
	<table width="100%" border="1" bgcolor="#EEEED4">
		<tr>
			<td colspan="2" bgcolor="#D3D4C5">
				<a name="rice2_partition"><font size="+1"><b>RICE2_PARTITION</b></font></a>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;5(+5)&gt;
			</td>
			<td>
				Encoding parameter:<br />
				<ul>
				<li>
					<tt>00000-11110</tt> : Rice parameter.
				</li>
				<li>
					<tt>11111</tt> : Escape code, meaning the partition is in unencoded binary form using n bits per sample; n follows as a 5-bit number.
				</li>
				</ul>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" bgcolor="#F4F4CC">
				&lt;?&gt;
			</td>
			<td>
				Encoded residual.  The number of samples (n) in the partition is determined as follows:<br />
				<ul>
				<li>
					partition size = (frame's blocksize / (2^partition order))
				</li>
				<li>
					for first partition of the subframe, n = partition size - predictor
				</li>
				<li>
					for remaining partitions, n = partition size
				</li>
				</ul>
			</td>
		</tr>
	</table>
	</td></tr></table>
</div>


<div class="copyright">
	<!-- @@@ oh so hacky -->
	<table>
		<tr>
			<td align="left">
				Copyright (c) 2000-2009  Josh Coalson
				<br/>
				Copyright (c) 2011-2016  Xiph.Org Foundation
			</td>
		</tr>
	</table>
</div>

</body>
</html>