Expand description
Sigma / Foveon X3F entropy coders.
X3F raw images come in three families:
- TRUE (DP1/DP2/SD14/SD15 “TRUE I/II”, Merrill “TRUE II”, Quattro “TRUE III”): each of the three sensor layers is an independent bit stream (planes start at 16-byte aligned offsets) coded with one shared prefix code whose symbols are the bit length of a JPEG-style difference. Prediction works on 2x2 phases: the first two columns of a row predict from the same phase two rows above, all other samples from the same phase two columns to the left. Planes decode in parallel; within a plane the stream is strictly sequential.
- Huffman 10-bit (SD9/SD10/SD14, Polaroid x530): interleaved R,G,B difference codes per row (independent rows via a row-offset table), each symbol mapped through a 1024-entry difference table. Running sums are 16-bit signed; if any sum goes negative the whole image is offset so the minimum is zero.
- Uncompressed “simple” variant of the above: one 32-bit word per pixel holding three 10-bit mapping-table indices.
Prefix codes in X3F are not canonical (they are given as explicit codes), so
PrefixCode builds a binary tree plus a 12-bit lookup table on top of it.
Structs§
- Camf
Stream - Incremental decoder of an X3F
SECc(CAMF calibration) section. - Prefix
Code - A (possibly non-canonical, possibly incomplete) binary prefix code.
- True
Header - Parsed header of a TRUE-engine raw image section (after the 28-byte image header).
- True
Table - TRUE-engine decoding table: one probe yields the code and its difference bits
whenever both fit in
TT_BITS(almost always), falling back to the tree.
Constants§
- CAMF_
MAX_ DECODED - Largest decoded CAMF block accepted (real files hold up to a few MiB).
Functions§
- decode_
camf - Decode a whole CAMF section (see
CamfStream). - decode_
huffman - Decode a row-indexed 10-bit Huffman image (3 interleaved colours) into
out(cols * rows * 3samples).datais the entropy-coded area,row_offsetsthe per-row start offsets into it. - decode_
simple - Decode the uncompressed variant: one little-endian 32-bit word per pixel holding
three
bits-bit indices intomapping(differences), running sums per colour. - decode_
true_ plane - Decode one TRUE plane of
cols x rowssamples intoout(out_colssamples per row,out_cols <= cols; extra columns on the right are decoded and discarded). - huffman_
code - Code table of the 10-bit Huffman format: entries are
length << 27 | code, the symbol of entryiismapping[i]when a full mapping table is present, elsei.