webp-lossless-bitstream-spec: relocate details from 5.1

Move the details given for meta prefix codes and the transforms from
"5.1. Roles of Image Data" to their corresponding sections.

Bug: webp:611
Change-Id: I750a3f45956d0a3928a22113180a2590ac1a36db
This commit is contained in:
James Zern 2023-07-14 12:51:35 -07:00
parent 84628e5611
commit e94b36d66d

View File

@ -181,7 +181,8 @@ can make the final compression more dense.
An image can go through four types of transforms. A 1 bit indicates the An image can go through four types of transforms. A 1 bit indicates the
presence of a transform. Each transform is allowed to be used only once. The presence of a transform. Each transform is allowed to be used only once. The
transforms are used only for the main-level ARGB image; the subresolution images transforms are used only for the main-level ARGB image; the subresolution images
have no transforms, not even the 0 bit indicating the end of transforms. (color transform image, entropy image, and predictor image) have no transforms,
not even the 0 bit indicating the end of transforms.
Typically, an encoder would use these transforms to reduce the Shannon entropy Typically, an encoder would use these transforms to reduce the Shannon entropy
in the residual image. Also, the transform data can be decided based on entropy in the residual image. Also, the transform data can be decided based on entropy
@ -222,9 +223,11 @@ Next, we describe the transform data for different types.
The predictor transform can be used to reduce entropy by exploiting the fact The predictor transform can be used to reduce entropy by exploiting the fact
that neighboring pixels are often correlated. In the predictor transform, the that neighboring pixels are often correlated. In the predictor transform, the
current pixel value is predicted from the pixels already decoded (in scan-line current pixel value is predicted from the pixels already decoded (in scan-line
order) and only the residual value (actual - predicted) is encoded. The order) and only the residual value (actual - predicted) is encoded. The green
_prediction mode_ determines the type of prediction to use. We divide the image component of a pixel defines which of the 14 predictors is used within a
into squares, and all the pixels in a square use the same prediction mode. particular block of the ARGB image. The _prediction mode_ determines the type of
prediction to use. We divide the image into squares, and all the pixels in a
square use the same prediction mode.
The first 3 bits of prediction data define the block width and height in number The first 3 bits of prediction data define the block width and height in number
of bits. The number of block columns, `block_xsize`, is used in two-dimension of bits. The number of block columns, `block_xsize`, is used in two-dimension
@ -238,10 +241,11 @@ int block_height = (1 << size_bits);
int block_xsize = DIV_ROUND_UP(image_width, 1 << size_bits); int block_xsize = DIV_ROUND_UP(image_width, 1 << size_bits);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The transform data contains the prediction mode for each block of the image. All The transform data contains the prediction mode for each block of the image. It
the `block_width * block_height` pixels of a block use the same prediction mode. is a subresolution image where the green component of a pixel defines which of
The prediction modes are treated as pixels of an image and encoded using the the 14 predictors is used for all the `block_width * block_height` pixels within
same techniques described in [Chapter 5](#image-data). a particular block of the ARGB image. This subresolution image is encoded using
the same techniques described in [Chapter 5](#image-data).
For a pixel _x, y_, one can compute the respective filter block address by: For a pixel _x, y_, one can compute the respective filter block address by:
@ -449,14 +453,16 @@ int block_height = 1 << size_bits;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The remaining part of the color transform data contains `ColorTransformElement` The remaining part of the color transform data contains `ColorTransformElement`
instances, corresponding to each block of the image. `ColorTransformElement` instances, corresponding to each block of the image. Each
instances are treated as pixels of an image and encoded using the methods `ColorTransformElement` `'cte'` is treated as a pixel in a subresolution image
described in [Chapter 5](#image-data). whose alpha component is `255`, red component is `cte.red_to_blue`, green
component is `cte.green_to_blue`, and blue component is `cte.green_to_red`.
During decoding, `ColorTransformElement` instances of the blocks are decoded and During decoding, `ColorTransformElement` instances of the blocks are decoded and
the inverse color transform is applied on the ARGB values of the pixels. As the inverse color transform is applied on the ARGB values of the pixels. As
mentioned earlier, that inverse color transform is just adding mentioned earlier, that inverse color transform is just adding
`ColorTransformElement` values to the red and blue channels. `ColorTransformElement` values to the red and blue channels. The alpha and green
channels are left as is.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void InverseTransform(uint8 red, uint8 green, uint8 blue, void InverseTransform(uint8 red, uint8 green, uint8 blue,
@ -603,22 +609,15 @@ We use image data in five different roles:
1. ARGB image: Stores the actual pixels of the image. 1. ARGB image: Stores the actual pixels of the image.
1. Entropy image: Stores the 1. Entropy image: Stores the
[meta prefix codes](#decoding-of-meta-prefix-codes). The red and green [meta prefix codes](#decoding-of-meta-prefix-codes).
components of a pixel define the meta prefix code used in a particular
block of the ARGB image.
1. Predictor image: Stores the metadata for the 1. Predictor image: Stores the metadata for the
[predictor transform](#predictor-transform). The green component of a pixel [predictor transform](#predictor-transform).
defines which of the 14 predictors is used within a particular block of the
ARGB image.
1. Color transform image: Created by `ColorTransformElement` values 1. Color transform image: Created by `ColorTransformElement` values
(defined in ["Color Transform"](#color-transform)) for different blocks of (defined in ["Color Transform"](#color-transform)) for different blocks of
the image. Each `ColorTransformElement` `'cte'` is treated as a pixel whose the image.
alpha component is `255`, red component is `cte.red_to_blue`, green
component is `cte.green_to_blue`, and blue component is `cte.green_to_red`.
1. Color indexing image: An array of size `color_table_size` (up to 256 1. Color indexing image: An array of size `color_table_size` (up to 256
ARGB values) storing the metadata for the ARGB values) storing the metadata for the
[color indexing transform](#color-indexing-transform). This is stored as an [color indexing transform](#color-indexing-transform).
image of width `color_table_size` and height `1`.
### 5.2 Encoding of Image Data ### 5.2 Encoding of Image Data
@ -980,6 +979,9 @@ value:
* If this bit is one, the image uses multiple meta prefix codes. These meta * If this bit is one, the image uses multiple meta prefix codes. These meta
prefix codes are stored as an _entropy image_ (described below). prefix codes are stored as an _entropy image_ (described below).
The red and green components of a pixel define a 16-bit meta prefix code used in
a particular block of the ARGB image.
##### Entropy Image ##### Entropy Image
The entropy image defines which prefix codes are used in different parts of the The entropy image defines which prefix codes are used in different parts of the