Skip to content

Commit d0abe22

Browse files
committed
Merge remote-tracking branch 'mediaarea/Ballot_Robert'
* mediaarea/Ballot_Robert: Link from Quantization Table Sets to Coding of the Sample Difference Move ESC definition to the place where it is used. Introduction line for State Transition Table Replace [()] by (()) Split formulae of color space transformations when RGB is used Move exceptions in a specific sub-section of the section describing the normal behavior
2 parents 32cb9ea + fe32ba8 commit d0abe22

File tree

1 file changed

+45
-22
lines changed

1 file changed

+45
-22
lines changed

ffv1.md

+45-22
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "S
3939

4040
`Pixel`: The smallest addressable representation of a color in a Frame. It is composed of one or more Samples.
4141

42-
`ESC`: An ESCape Symbol to indicate that the Symbol to be stored is too large for normal storage and that an alternate storage method is used.
43-
4442
`MSB`: Most Significant Bit, the bit that can cause the largest change in magnitude of the Symbol.
4543

4644
`VLC`: Variable Length Code, a code that maps source symbols to a variable number of bits.
@@ -261,8 +259,9 @@ median(l, t, l + t - tl)
261259
262260
Note, this prediction template is also used in [@ISO.14495-1.1999] and [@HuffYUV].
263261
264-
Exception for the median predictor:
265-
if `colorspace_type == 0 && bits_per_raw_sample == 16 && ( coder_type == 1 || coder_type == 2 )` (see (#colorspace-type), (#bits-per-raw-sample) and (#colorspace-type)), the following median predictor MUST be used:
262+
### Exception
263+
264+
If `colorspace_type == 0 && bits_per_raw_sample == 16 && ( coder_type == 1 || coder_type == 2 )` (see (#colorspace-type), (#bits-per-raw-sample) and (#colorspace-type)), the following median predictor MUST be used:
266265
267266
```
268267
median(left16s, top16s, left16s + top16s - diag16s)
@@ -280,6 +279,8 @@ Background: a two's complement 16-bit signed integer was used for storing Sample
280279
281280
## Quantization Table Sets
282281
282+
Quantization Tables are used on Sample Differences (see (#coding-of-the-sample-difference)), so Quantized Sample Differences are stored in the bitstream.
283+
283284
The FFV1 bitstream contains one or more Quantization Table Sets. Each Quantization Table Set contains exactly 5 Quantization Tables with each Quantization Table corresponding to one of the five Quantized Sample Differences. For each Quantization Table, both the number of quantization steps and their distribution are stored in the FFV1 bitstream; each Quantization Table has exactly 256 entries, and the 8 least significant bits of the Quantized Sample Difference are used as index:
284285
285286
SVGI:!---
@@ -351,28 +352,20 @@ JPEG2000-RCT is a Reversible Color Transform that codes RGB (red, green, blue) P
351352
SVGI:!---
352353
SVGI:![svg](rgb1.svg "rgb 1")
353354
SVGI:!---
354-
SVGC:rgb1.svg=$$\\\\begin{array}{ccccccc}Cb & = & b - g \\\\\\ Cr & = & r - g \\\\\\ Y & = & g + ( Cb + Cr)>>2 \\\\\\ g & = & Y - ( Cb + Cr ) >> 2 \\\\\\ r & = & Cr + g \\\\\\ b & = & Cb + g \\\\end{array}$$
355+
SVGC:rgb1.svg=$$\\\\begin{array}{ccccccc}Cb & = & b - g \\\\\\ Cr & = & r - g \\\\\\ Y & = & g + ( Cb + Cr)>>2 \\\\end{array}$$
355356
AART:Cb = b - g
356357
AART:Cr = r - g
357358
AART:Y = g + (Cb + Cr) >> 2
358-
AART:g = Y - (Cb + Cr) >> 2
359-
AART:r = Cr + g
360-
AART:b = Cb + g
361-
362-
Exception for the JPEG2000-RCT conversion: if `bits_per_raw_sample` is between 9 and 15 inclusive and `extra_plane` is 0, the following formulae for reversible conversions between YCbCr and RGB MUST be used instead of the ones above:
359+
Figure: Description of the transformation of pixels from RGB color space to coded modified YCbCr color space. {#figureRgbYcbcr}
363360
364361
SVGI:!---
365362
SVGI:![svg](rgb2.svg "rgb 2")
366363
SVGI:!---
367-
SVGC:rgb2.svg=$$\\\\begin{array}{ccccccc}Cb & = & g - b \\\\\\ Cr & = & r - b \\\\\\ Y & = & b + (Cb + Cr)>>2 \\\\\\ b & = & Y - (Cb + Cr)>>2 \\\\\\ r & = & Cr + b \\\\\\ g & = & Cb + b \\\\end{array}$$
368-
AART:Cb = g - b
369-
AART:Cr = r - b
370-
AART:Y = b +(Cb + Cr) >> 2
371-
AART:b = Y -(Cb + Cr) >> 2
372-
AART:r = Cr + b
373-
AART:g = Cb + b
374-
375-
Background: At the time of this writing, in all known implementations of FFV1 bitstream, when `bits_per_raw_sample` was between 9 and 15 inclusive and `extra_plane` is 0, GBR Planes were used as BGR Planes during both encoding and decoding. In the meanwhile, 16-bit JPEG2000-RCT was implemented without this issue in one implementation and validated by one conformance checker. Methods to address this exception for the transform are under consideration for the next version of the FFV1 bitstream.
364+
SVGC:rgb2.svg=$$\\\\begin{array}{ccccccc}g & = & Y - ( Cb + Cr ) >> 2 \\\\\\ r & = & Cr + g \\\\\\ b & = & Cb + g \\\\end{array}$$
365+
AART:g = Y - (Cb + Cr) >> 2
366+
AART:r = Cr + g
367+
AART:b = Cb + g
368+
Figure: Description of the transformation of pixels from coded modified YCbCr color space to RGB color space. {#figureYcbcrRgb}
376369
377370
Cb and Cr are positively offset by `1 << bits_per_raw_sample` after the conversion from RGB to the modified YCbCr and are negatively offseted by the same value before the conversion from the modified YCbCr to RGB, in order to have only non-negative values after the conversion.
378371
@@ -394,16 +387,40 @@ In JPEG2000-RCT, the coding order would be left to right and then top to bottom,
394387
395388
Y(1,1) Y(2,1) Cb(1,1) Cb(2,1) Cr(1,1) Cr(2,1) Y(1,2) Y(2,2) Cb(1,2) Cb(2,2) Cr(1,2) Cr(2,2)
396389
390+
#### Exception
391+
392+
If `bits_per_raw_sample` is between 9 and 15 inclusive and `extra_plane` is 0, the following formulae for reversible conversions between YCbCr and RGB MUST be used instead of the ones above:
393+
394+
SVGI:!---
395+
SVGI:![svg](rgb3.svg "rgb 3")
396+
SVGI:!---
397+
SVGC:rgb3.svg=$$\\\\begin{array}{ccccccc}Cb & = & g - b \\\\\\ Cr & = & r - b \\\\\\ Y & = & b + (Cb + Cr)>>2 \\\\end{array}$$
398+
AART:Cb = g - b
399+
AART:Cr = r - b
400+
AART:Y = b + (Cb + Cr) >> 2
401+
Figure: Description of the transformation of pixels from RGB color space to coded modified YCbCr color space (in case of exception). {#figureRgbYcbcrException}
402+
403+
SVGI:!---
404+
SVGI:![svg](rgb4.svg "rgb 4")
405+
SVGI:!---
406+
SVGC:rgb4.svg=$$\\\\begin{array}{ccccccc}b & = & Y - (Cb + Cr)>>2 \\\\\\ r & = & Cr + b \\\\\\ g & = & Cb + b \\\\end{array}$$
407+
AART:b = Y - (Cb + Cr) >> 2
408+
AART:r = Cr + b
409+
AART:g = Cb + b
410+
Figure: Description of the transformation of pixels from coded modified YCbCr color space to RGB color space (in case of exception). {#figureYcbcrRgbException}
411+
412+
Background: At the time of this writing, in all known implementations of FFV1 bitstream, when `bits_per_raw_sample` was between 9 and 15 inclusive and `extra_plane` is 0, GBR Planes were used as BGR Planes during both encoding and decoding. In the meanwhile, 16-bit JPEG2000-RCT was implemented without this issue in one implementation and validated by one conformance checker. Methods to address this exception for the transform are under consideration for the next version of the FFV1 bitstream.
413+
397414
## Coding of the Sample Difference
398415
399416
Instead of coding the n+1 bits of the Sample Difference with Huffman or Range coding (or n+2 bits, in the case of JPEG2000-RCT), only the n (or n+1, in the case of JPEG2000-RCT) least significant bits are used, since this is sufficient to recover the original Sample. In the equation below, the term "bits" represents `bits_per_raw_sample + 1` for JPEG2000-RCT or `bits_per_raw_sample` otherwise:
400417
401418
SVGI:!---
402419
SVGI:![svg](samplediff.svg "coding of the sample difference")
403420
SVGI:!---
404-
SVGC:samplediff.svg=$$coder\\_input=[(sample\\_difference+2^{bits-1})\\&(2^{bits}-1)]-2^{bits-1}$$
405-
AART:coder_input = [(sample_difference + 2 ^ (bits - 1)) &
406-
AART: (2 ^ bits - 1)] - 2 ^ (bits - 1)
421+
SVGC:samplediff.svg=$$coder\\_input=((sample\\_difference+2^{bits-1})\\&(2^{bits}-1))-2^{bits-1}$$
422+
AART:coder_input = ((sample_difference + 2 ^ (bits - 1)) &
423+
AART: (2 ^ bits - 1)) - 2 ^ (bits - 1)
407424
Figure: Description of the coding of the Sample Difference in the bitstream. {#figureSampleDifference}
408425
409426
### Range Coding Mode
@@ -586,6 +603,8 @@ When `keyframe` (see (#frame)) value is 1, all Range coder state variables are s
586603

587604
#### State Transition Table
588605

606+
In this mode a State Transition Table is used, indicating in which state the decoder will move to, based on the current state and the value extracted from [@figureGetRacPseudoCode].
607+
589608
SVGI:!---
590609
SVGI:![svg](statetransitiontable1.svg "state transition table 1")
591610
SVGI:!---
@@ -601,6 +620,8 @@ AART:zero_state_(i) = 256 - one_state_(256-i)
601620

602621
#### default\_state\_transition
603622

623+
By default, the following State Transition Table is used:
624+
604625
```
605626
0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27,
606627
@@ -715,6 +736,8 @@ Figure: A pseudo-code description of the read of a signed integer in Golomb Rice
715736
|0000 0000 0001 | 11 |
716737
|0000 0000 0000 | ESC |
717738

739+
`ESC` is an ESCape Symbol to indicate that the Symbol to be stored is too large for normal storage and that an alternate storage method is used.
740+
718741
##### Suffix
719742

720743
| | |

0 commit comments

Comments
 (0)