IFF file parser.
Files "IFFByteStream.h" and "IFFByteStream.cpp" implement a parser for files structured according the Electronic Arts ``EA IFF 85 Interchange File Format''. IFF files are composed of a sequence of data chunks. Each chunk is identified by a four character chunk identifier describing the type of the data stored in the chunk. A few special chunk identifiers, for instance "FORM", are reserved for composite chunks which themselves contain a sequence of data chunks. This conventions effectively provides IFF files with a convenient hierarchical structure. Composite chunks are further identified by a secondary chunk identifier.We found convenient to define a extended chunk identifier. In the case of a regular chunk, the extended chunk identifier is simply the chunk identifier, as in "PM44". In the case of a composite chunk, the extended chunk identifier is composed by concatenating the main chunk identifier, a colon, and the secondary chunk identifier, as in "FORM:DJVU".
Class IFFByteStream provides a way to read or write IFF structured files. Member functions provide an easy mean to position the underlying ByteStream at the beginning of each chunk and to read or write the data until reaching the end of the chunk. The utility program djvuinfo demonstrates how to use class IFFByteStream.
IFF Files and ZP-Coder --- Class IFFByteStream repositions the underlying ByteStream whenever a new chunk is accessed. It is possible to code chunk data with the ZP-Coder without worrying about the final file position. See class ZPCodec for more details.
DjVu IFF Files --- We had initially planned to exactly follow the IFF specifications. Then we realized that certain versions of MSIE recognize any IFF file as a Microsoft AIFF sound file and pop a message box "Cannot play that sound". It appears that the structure of AIFF files is entirely modeled after the IFF standard, with small variations regarding the endianness of numbers and the padding rules. We eliminate this problem by casting an octet protection spell. Our IFF files always start with the four octets 0x41, 0x54, 0x26, 0x54 followed by the fully conformant IFF byte stream. Class IFFByteStream silently skips these four octets when it encounters them.
References --- EA IFF 85 Interchange File Format specification:
http://www.cica.indiana.edu/graphics/image_specs/ilbm.format.txt or http://www.tnt.uni-hannover.de/soft/compgraph/fileformats/docs/iff.pre
Alphabetic index Hierarchy of classes