Skip to main content

Module ljpeg

Module ljpeg 

Source
Expand description

Lossless JPEG (ITU T.81 process 14, SOF3) decoder.

This is the workhorse codec of the RAW world: CR2, most DNGs, Sony lossless ARW, Hasselblad, Leaf, Kodak, Pentax K-1 DNG, Phase One (some), etc.

Output model: the frame is decoded row by row into an L1-resident row buffer of width * clrs samples, which is handed to a sink. Callers map JPEG rows to their final layout (CR2 vertical slices, DNG tile placement, …) in the sink, so no full-size intermediate image is ever allocated.

Canon sRAW/mRAW frames (component 0 with sampling factors > 1) are decoded as clrs = ncomp + sraw interleaved values per MCU, where luma samples chain-predict from the previous luma sample (matching Canon’s encoder).

Modules§

encoder
Minimal lossless JPEG encoder, used to build synthetic fixtures for tests, fuzzing seeds and malformed-input suites (not optimised).

Structs§

Component
Frame component.
LjpegHeader
A parsed lossless JPEG stream (headers only; decoding is on demand).
LjpegOptions
Decoder options.
Unstuffed
Entropy-coded data with FF 00 stuffing removed, split at restart markers.

Functions§

decode_frame_parallel
Decode the whole frame of a restart-free scan into frame (height rows of LjpegHeader::row_len samples) using all worker threads.
decode_into
Decode a lossless JPEG stream whose rows map 1:1 onto width-sample image rows.
decode_into_par
decode_into that may decode large restart-free streams on all threads (see decode_rows_par).
decode_rows
Decode all rows of data (a complete lossless JPEG stream), invoking sink(jpeg_row, samples) for each row in order.
decode_rows_par
decode_rows that first decodes large scans on all threads when parallel is set (decode_frame_parallel; scans with restart markers one interval per task). Rows reach sink in order either way with identical values; corrupt streams always take the sequential path, so errors are identical too.
decode_rows_par_limit
decode_rows_par for callers that only need the first rows rows and ignore what the stream holds after them (the parallel path then stops there; the sequential one still delivers every row).
decode_tile
Decode a lossless JPEG tile into a destination buffer.
unstuff
Strip byte stuffing from a JPEG scan. FF 00 becomes FF; FF D0..D7 (restart) starts a new segment; any other marker (or a lone trailing FF) ends the scan, exactly where the byte-wise JPEG pump would stop feeding data.
unstuff_scan
unstuff; without restarts a restart marker ends the scan like any other marker (a decoder reading one restart interval must not pull in the rest of the stream).