diff --git a/doc/webp-container-spec.txt b/doc/webp-container-spec.txt index 6e4bc399..ae68565d 100644 --- a/doc/webp-container-spec.txt +++ b/doc/webp-container-spec.txt @@ -93,11 +93,21 @@ _uint32_ : A 32-bit, little-endian, unsigned integer. +_FourCC_ + +: A _FourCC_ (four-character code) is a _uint32_ created by concatenating four + ASCII characters in little-endian order. + _1-based_ : An unsigned integer field storing values offset by `-1`. e.g., Such a field would store value _25_ as _24_. +RIFF file format +---------------- +The WebP file format is based on the RIFF (resource interchange file format) +document format. + The basic element of a RIFF file is a _chunk_. It consists of: 0 1 2 3 @@ -112,12 +122,12 @@ The basic element of a RIFF file is a _chunk_. It consists of: Chunk FourCC: 32 bits -: ASCII four character code or _chunk tag_ used for chunk identification. +: ASCII four-character code used for chunk identification. Chunk Size: 32 bits (_uint32_) -: The size of the chunk (_ckSize_) not including this field, the chunk - identifier and padding. +: The size of the chunk not including this field, the chunk identifier or + padding. Chunk Payload: _Chunk Size_ bytes @@ -126,43 +136,13 @@ Chunk Payload: _Chunk Size_ bytes _ChunkHeader('ABCD')_ -: This is used to describe the fourcc and size header of individual - chunks, where 'ABCD' is the fourcc for the chunk. This element's +: This is used to describe the _FourCC_ and _Chunk Size_ header of individual + chunks, where 'ABCD' is the FourCC for the chunk. This element's size is 8 bytes. -: Note that, in this specification, all chunk tag characters are in - file order, not in byte order of a uint32 of any particular - architecture. - -_list of chunks_ - -: A concatenation of multiple chunks. - -: We will refer to the first chunk as having _position_ 0, the second - as position 1, etc. By _chunk with index 0 among "ABCD"_ we mean - the first chunk among the chunks of type "ABCD" in the list, the - _chunk with index 1 among "ABCD"_ is the second such chunk, etc. - -A WebP file MUST begin with a single chunk with a tag 'RIFF'. All -other defined chunks are contained within this chunk. The file SHOULD -NOT contain anything after it. - -The maximum size of RIFF's _ckSize_ is 2^32 minus 10 bytes. The size -of the whole file is at most 4GiB minus 2 bytes. - -**Note:** some RIFF libraries are said to have bugs when handling files -larger than 1GiB or 2GiB. If you are using an existing library, check -that it handles large files correctly. - -The first four bytes of the RIFF chunk contents (i.e., bytes 8-11 of the file) -MUST be the ASCII string "WEBP". They are followed by a list of chunks. As the -size of any chunk is even, the size of the RIFF chunk is also even. The -contents of the chunks in that list will be described in the following sections. - -**Note:** RIFF has a convention that all-uppercase chunks are standard -chunks that apply to any RIFF file format, while chunks specific to a -file format are all lowercase. WebP does not follow this convention. - +**Note:** RIFF has a convention that all-uppercase chunk FourCCs are standard +chunks that apply to any RIFF file format, while FourCCs specific to a file +format are all lowercase. WebP does not follow this convention. WebP file header ---------------- @@ -183,12 +163,20 @@ WebP file header File Size: 32 bits (_uint32_) -: The size of the file in bytes starting at offset 8. +: The size of the file in bytes starting at offset 8. The maximum value of +this field is 2^32 minus 10 bytes and thus the size of the whole file is at +most 4GiB minus 2 bytes. 'WEBP': 32 bits : The ASCII characters 'W' 'E' 'B' 'P'. +A WebP file MUST begin with a RIFF header with the FourCC 'WEBP'. The file size +in the header is the total size of the chunks that follow plus `4` bytes for +the 'WEBP' FourCC. The file SHOULD NOT contain anything after it. As the size +of any chunk is even, the size given by the RIFF header is also even. The +contents of individual chunks will be described in the following sections. + Simple file format (lossy) --------------------------