Skip to main content

Module x3f

Module x3f 

Source
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§

CamfStream
Incremental decoder of an X3F SECc (CAMF calibration) section.
PrefixCode
A (possibly non-canonical, possibly incomplete) binary prefix code.
TrueHeader
Parsed header of a TRUE-engine raw image section (after the 28-byte image header).
TrueTable
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 * 3 samples). data is the entropy-coded area, row_offsets the 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 into mapping (differences), running sums per colour.
decode_true_plane
Decode one TRUE plane of cols x rows samples into out (out_cols samples 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 entry i is mapping[i] when a full mapping table is present, else i.