Skip to content

Commit 3a5dce3

Browse files
Add Color Filter Array (Bayer) support
1 parent 92b9868 commit 3a5dce3

File tree

1 file changed

+41
-7
lines changed

1 file changed

+41
-7
lines changed

ffv1.md

+41-7
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ Background: in first implementations of FFV1 bitstream, the index for Cb and Cr
294294

295295
## Color spaces
296296

297-
FFV1 supports two color spaces: YCbCr and RGB. Both color spaces allow an optional Alpha `Plane` that can be used to code transparency data.
297+
FFV1 supports several color spaces. Both color spaces allow an optional Alpha `Plane` that can be used to code transparency data.
298298

299299
The FFV1 bitstream interleaves data in an order determined by the color space. In YCbCr for each `Plane`, each `Line` is coded from top to bottom and for each `Line`, each `Sample` is coded from left to right. In JPEG2000-RCT for each `Line` from top to bottom, each `Plane` is coded and for each `Plane`, each `Sample` is encoded from left to right.
300300

@@ -395,6 +395,10 @@ In JPEG2000-RCT, the coding order would be left to right and then top to bottom,
395395

396396
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]
397397

398+
### Color Filter Array
399+
400+
(TODO)
401+
398402
## Coding of the Sample Difference
399403

400404
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:
@@ -722,6 +726,10 @@ Parameters( ) { |
722726
for (i = 1; i < 256; i++) |
723727
state_transition_delta[ i ] | sr
724728
colorspace_type | ur
729+
if (colorspace_type == 2) { |
730+
for ( i = 0; i < 4; i++ ) { |
731+
cfa_pattern [ i ] | ur
732+
} |
725733
if (version >= 1) |
726734
bits_per_raw_sample | ur
727735
chroma_planes | br
@@ -810,16 +818,42 @@ If state_transition_delta is not present in the FFV1 bitstream, all Range coder
810818

811819
### colorspace_type
812820

813-
`colorspace_type` specifies the color space losslessly encoded, the Pixel transformation used by the encoder, as well as interleave method.
821+
`colorspace_type` specifies the color space encoded, the pixel transformation used by the encoder, the extra plane content, as well as interleave method.
814822

815-
|value | color space losslessly encoded | transformation | interleave method |
816-
|-------|:--------------------------------|:--------------------------------|:--------------------------------|
817-
| 0 | YCbCr | No Pixel transformation | `Plane` then `Line` |
818-
| 1 | RGB | JPEG2000-RCT | `Line` then `Plane` |
819-
| Other | reserved for future use | reserved for future use | reserved for future use |
823+
|value | color space encoded | pixel transformation | extra plane content | interleave method |
824+
|-------|:------------------------|:------------------------|:------------------------|:------------------------|
825+
| 0 | YCbCr | None | Transparency | `Plane` then `Line` |
826+
| 1 | RGB | JPEG2000-RCT | Transparency | `Line` then `Plane` |
827+
| 2 | Color Filter Array | JPEG2000-RCT | Color difference | `Line` then `Plane` |
828+
| Other | reserved for future use | reserved for future use | reserved for future use | reserved for future use |
820829

821830
Restrictions:
822831
If `colorspace_type` is 1, then `chroma_planes` MUST be 1, `log2_h_chroma_subsample` MUST be 0, and `log2_v_chroma_subsample` MUST be 0.
832+
If `colorspace_type` is 2, then `chroma_planes` MUST be 1, `log2_h_chroma_subsample` MUST be 0, and `log2_v_chroma_subsample` MUST be 0, transparency MUST be 1.
833+
834+
### cfa_pattern
835+
836+
`cfa_pattern` indicates the actual color filter array geometric pattern of the image sensor used to capture the single sensor color image.
837+
The pattern has a fixed size of 4 values (fixed width of 2, fixed height of 2) and is provided per line top to bottom, and for each line left to right.
838+
839+
|value | color |
840+
|-------|:--------------------------------|
841+
|0 | red |
842+
|1 | green |
843+
|2 | blue |
844+
845+
Restrictions:
846+
At least 1 component of each color MUST be present.
847+
848+
As an example, a typical pattern is 0112, which implies:
849+
850+
```
851+
+---+---+
852+
| R | G |
853+
+---+---+
854+
| G | B |
855+
+---+---+
856+
```
823857

824858
### chroma_planes
825859

0 commit comments

Comments
 (0)