Skip to content

Commit fe11f97

Browse files
committed
extend colorspace descriptions
TO DO: remove redundancies with the ‘General Description’ section which mostly focuses on colorspace
1 parent fbe6a27 commit fe11f97

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

ffv1.md

+29
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,21 @@ $$Q_{i}[a-b]=Table_{i}[(a-b)\&255]$$
198198

199199
## Colorspace
200200

201+
FFV1 supports two colorspaces: YCbCr and JPEG2000-RCT. In YCbCr, the Cb and Cr planes are optional, but MUST be used together if used. Omitting the Cb and Cr planes would code frames in grayscale without color data. For both YCbCr and JPEG2000-RCT, an optional Alpha plane can be used to code transparency data. In either colorspace, an FFV1 frame is composed of 1 to 4 planes that MUST use one of the following arragements:
202+
203+
- Y
204+
- Y, Alpha
205+
- Y, Cb, Cr
206+
- Y, Cb, Cr, Alpha
207+
208+
### YCbCr
209+
210+
When FFV1 uses the YCbCr colorspace, the Y plane MUST be coded first. If the Cb and Cr planes are used then they MUST be coded after the Y plane. If an Alpha (transparency) plane is used, then it MUST be coded last.
211+
201212
### JPEG2000-RCT
202213

214+
JPEG2000-RCT is a Reversible Color Transform that stores RGB (red, green, blue) planes losslessly in a modified YCbCr colorspace. Reversible conversions between YCbCr and RGB use the following formulae.
215+
203216
$$Y=g+(Cb+Cr)>>2$$
204217

205218
$$Cb=b-g$$
@@ -214,6 +227,22 @@ $$b=Cb+g$$
214227

215228
[@!ISO.15444-1.2016]
216229

230+
When FFV1 uses the JPEG2000-RCT colorspace, the horizontal lines are interleaved to improve caching efficiency since it is most likely that the RCT will immediately be converted to RGB during decoding. The interleaved coding order is also Y, and then Cb and Cr (if used), and then Alpha.
231+
232+
As an example, a frame that is two pixels wide and two pixels high, could be comprised of the following structure:
233+
234+
+------------------------+------------------------+
235+
| Pixel[1,1] | Pixel[2,1] |
236+
| Y[1,1] Cb[1,1] Cr[1,1] | Y[2,1] Cb[2,1] Cr[2,1] |
237+
+------------------------+------------------------+
238+
| Pixel[1,2] | Pixel[2,2] |
239+
| Y[1,2] Cb[1,2] Cr[1,2] | Y[2,2] Cb[2,2] Cr[2,2] |
240+
+------------------------+------------------------+
241+
242+
In JPEG2000-RCT colorspace, the coding order would be left to right and then top to bottom, with values interleaved by lines and stored in this order:
243+
244+
Y[1,1] Y[2,1] U[1,1] U[2,1] V[1,1] V[2,1] Y[1,2] Y[2,2] U[1,2] U[2,2] V[1,2] V[2,2]
245+
217246
## Coding of the sample difference
218247

219248
Instead of coding the n+1 bits of the sample difference with Huffman-, or Range coding (or n+2 bits, in the case of RCT), only the n (or n+1) 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 RCT or bits_per_raw_sample otherwise:

0 commit comments

Comments
 (0)