mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 06:08:21 +01:00
webp-lossless-bitstream-spec: convert BNF to ABNF
this has a better canonical reference [1] and is preferred in IETF docs [1] https://www.rfc-editor.org/rfc/rfc5234 Bug: webp:448 Change-Id: I3f0bd34d3ca4c62b255d5d6cbae0c55e2940dfb5
This commit is contained in:
parent
87e36c485a
commit
72776530d8
@ -1076,33 +1076,41 @@ The interpretation of S depends on its value:
|
|||||||
7 Overall Structure of the Format
|
7 Overall Structure of the Format
|
||||||
---------------------------------
|
---------------------------------
|
||||||
|
|
||||||
Below is a view into the format in Backus-Naur form. It does not cover
|
Below is a view into the format in Augmented Backus-Naur Form ([ABNF]). It does
|
||||||
all details. End-of-image (EOI) is only implicitly coded into the number
|
not cover all details. End-of-image (EOI) is only implicitly coded into the
|
||||||
of pixels (xsize * ysize).
|
number of pixels (xsize * ysize).
|
||||||
|
|
||||||
|
|
||||||
#### 7.1 Basic Structure
|
#### 7.1 Basic Structure
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
<format> ::= <RIFF header><image size><image stream>
|
format = RIFF-header image-size image-stream
|
||||||
<image stream> ::= <optional-transform><spatially-coded image>
|
RIFF-header = "RIFF" 4OCTET "WEBP" "VP8L" 4OCTET %x2F
|
||||||
|
image-size = 14BIT 14BIT ; width - 1, height - 1
|
||||||
|
image-stream = optional-transform spatially-coded-image
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
#### 7.2 Structure of Transforms
|
#### 7.2 Structure of Transforms
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
<optional-transform> ::=
|
optional-transform = (%b1 transform optional-transform) / %b0
|
||||||
(1-bit value 1; <transform> <optional-transform>) | 1-bit value 0
|
transform = predictor-tx / color-tx / subtract-green-tx
|
||||||
<transform> ::= <predictor-tx> | <color-tx> | <subtract-green-tx> |
|
transform =/ color-indexing-tx
|
||||||
<color-indexing-tx>
|
|
||||||
<predictor-tx> ::= 2-bit value 0; <predictor image>
|
predictor-tx = %b00 predictor-image
|
||||||
<predictor image> ::= 3-bit sub-pixel code ; <entropy-coded image>
|
predictor-image = 3BIT ; sub-pixel code
|
||||||
<color-tx> ::= 2-bit value 1; <color image>
|
entropy-coded-image
|
||||||
<color image> ::= 3-bit sub-pixel code ; <entropy-coded image>
|
|
||||||
<subtract-green-tx> ::= 2-bit value 2
|
color-tx = %b01 color-image
|
||||||
<color-indexing-tx> ::= 2-bit value 3; <color-indexing image>
|
color-image = 3BIT ; sub-pixel code
|
||||||
<color-indexing image> ::= 8-bit color count; <entropy-coded image>
|
entropy-coded-image
|
||||||
|
|
||||||
|
subtract-green-tx = %b10
|
||||||
|
|
||||||
|
color-indexing-tx = %b11 color-indexing-image
|
||||||
|
color-indexing-image = 8BIT ; color count
|
||||||
|
entropy-coded-image
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
||||||
@ -1111,35 +1119,40 @@ of pixels (xsize * ysize).
|
|||||||
\[AMENDED2\]
|
\[AMENDED2\]
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
<spatially-coded image> ::= <color cache info><meta prefix><data>
|
spatially-coded-image = color-cache-info meta-prefix data
|
||||||
<entropy-coded image> ::= <color cache info><data>
|
entropy-coded-image = color-cache-info data
|
||||||
<color cache info> ::=
|
|
||||||
1 bit value 0 | (1-bit value 1; 4-bit value for color cache size)
|
color-cache-info = %b0
|
||||||
<meta prefix> ::= 1-bit value 0 |
|
color-cache-info =/ (%b1 4BIT) ; 1 followed by color cache size
|
||||||
(1-bit value 1; <entropy image>)
|
|
||||||
<data> ::= <prefix codes><lz77-coded image>
|
meta-prefix = %b0 / (%b1 entropy-image)
|
||||||
<entropy image> ::= 3-bit subsample value; <entropy-coded image>
|
|
||||||
<prefix codes> ::= <prefix code group> |
|
data = prefix-codes lz77-coded-image
|
||||||
<prefix code group><prefix codes>
|
entropy-image = 3BIT ; subsample value
|
||||||
<prefix code group> ::= <prefix code><prefix code><prefix code>
|
entropy-coded-image
|
||||||
<prefix code><prefix code>
|
|
||||||
See "Interpretation of Meta Prefix Codes" to
|
prefix-codes = prefix-code-group *prefix-codes
|
||||||
understand what each of these five prefix
|
prefix-code-group =
|
||||||
codes are for.
|
5prefix-code ; See "Interpretation of Meta Prefix Codes" to
|
||||||
<prefix code> ::= <simple prefix code> | <normal prefix code>
|
; understand what each of these five prefix
|
||||||
<simple prefix code> ::= see "Simple code length code" for details
|
; codes are for.
|
||||||
<normal prefix code> ::= <code length code>; encoded code lengths
|
|
||||||
<code length code> ::= see section "Normal code length code"
|
prefix-code = simple-prefix-code / normal-prefix-code
|
||||||
<lz77-coded image> ::= ((<argb-pixel> | <lz77-copy> |
|
simple-prefix-code = ; see "Simple code length code" for details
|
||||||
<color-cache-code>) <lz77-coded image>) | ""
|
normal-prefix-code = code-length-code encoded-code-lengths
|
||||||
|
code-length-code = ; see section "Normal code length code"
|
||||||
|
|
||||||
|
lz77-coded-image =
|
||||||
|
*((argb-pixel / lz77-copy / color-cache-code) lz77-coded-image)
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
A possible example sequence:
|
A possible example sequence:
|
||||||
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
<RIFF header><image size>1-bit value 1<subtract-green-tx>
|
RIFF-header image-size %b1 subtract-green-tx
|
||||||
1-bit value 1<predictor-tx>1-bit value 0<color cache info>
|
%b1 predictor-tx %b0 color-cache-info
|
||||||
1-bit value 0<prefix codes><lz77-coded image>
|
%b0 prefix-codes lz77-coded-image
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
[ABNF]: https://www.rfc-editor.org/rfc/rfc5234
|
||||||
[canonical_huff]: https://en.wikipedia.org/wiki/Canonical_Huffman_code
|
[canonical_huff]: https://en.wikipedia.org/wiki/Canonical_Huffman_code
|
||||||
|
Loading…
Reference in New Issue
Block a user