mirror of
https://github.com/webmproject/libwebp.git
synced 2025-04-08 18:06:48 +02:00
Merge changes Id56ca4fd,I662bd1d7 into main
* changes: webp-lossless-bitstream-spec: add validity note for max_symbol webp-lossless-bitstream-spec: fix max_symbol definition
This commit is contained in:
commit
29b9eb1517
@ -925,14 +925,24 @@ for (i = 0; i < num_code_lengths; ++i) {
|
|||||||
}
|
}
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Next, if `ReadBits(1) == 0`, the maximum number of different read symbols is
|
Next, if `ReadBits(1) == 0`, the maximum number of different read symbols
|
||||||
`num_code_lengths`. Otherwise, it is defined as:
|
(`max_symbol`) for each symbol type (A, R, G, B, and distance) is set to its
|
||||||
|
alphabet size:
|
||||||
|
|
||||||
|
* G channel: 256 + 24 + `color_cache_size`
|
||||||
|
* Other literals (A, R, and B): 256
|
||||||
|
* Distance code: 40
|
||||||
|
|
||||||
|
Otherwise, it is defined as:
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
int length_nbits = 2 + 2 * ReadBits(3);
|
int length_nbits = 2 + 2 * ReadBits(3);
|
||||||
int max_symbol = 2 + ReadBits(length_nbits);
|
int max_symbol = 2 + ReadBits(length_nbits);
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
If `max_symbol` is larger than the size of the alphabet for the symbol type, the
|
||||||
|
bitstream is invalid.
|
||||||
|
|
||||||
A prefix table is then built from `code_length_code_lengths` and used to read up
|
A prefix table is then built from `code_length_code_lengths` and used to read up
|
||||||
to `max_symbol` code lengths.
|
to `max_symbol` code lengths.
|
||||||
|
|
||||||
@ -948,11 +958,7 @@ to `max_symbol` code lengths.
|
|||||||
`11 + ReadBits(7)` times.
|
`11 + ReadBits(7)` times.
|
||||||
|
|
||||||
Once code lengths are read, a prefix code for each symbol type (A, R, G, B, and
|
Once code lengths are read, a prefix code for each symbol type (A, R, G, B, and
|
||||||
distance) is formed using their respective alphabet sizes:
|
distance) is formed using their respective alphabet sizes.
|
||||||
|
|
||||||
* G channel: 256 + 24 + `color_cache_size`
|
|
||||||
* Other literals (A, R, and B): 256
|
|
||||||
* Distance code: 40
|
|
||||||
|
|
||||||
The Normal Code Length Code must code a full decision tree, that is, the sum of
|
The Normal Code Length Code must code a full decision tree, that is, the sum of
|
||||||
`2 ^ (-length)` for all non-zero codes must be exactly one. There is however
|
`2 ^ (-length)` for all non-zero codes must be exactly one. There is however
|
||||||
|
Loading…
x
Reference in New Issue
Block a user