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.
- Ljpeg
Header - A parsed lossless JPEG stream (headers only; decoding is on demand).
- Ljpeg
Options - Decoder options.
- Unstuffed
- Entropy-coded data with
FF 00stuffing removed, split at restart markers.
Functions§
- decode_
frame_ parallel - Decode the whole frame of a restart-free scan into
frame(heightrows ofLjpegHeader::row_lensamples) 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_intothat may decode large restart-free streams on all threads (seedecode_rows_par).- decode_
rows - Decode all rows of
data(a complete lossless JPEG stream), invokingsink(jpeg_row, samples)for each row in order. - decode_
rows_ par decode_rowsthat first decodes large scans on all threads whenparallelis set (decode_frame_parallel; scans with restart markers one interval per task). Rows reachsinkin order either way with identical values; corrupt streams always take the sequential path, so errors are identical too.- decode_
rows_ par_ limit decode_rows_parfor callers that only need the firstrowsrows 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 00becomesFF;FF D0..D7(restart) starts a new segment; any other marker (or a lone trailingFF) ends the scan, exactly where the byte-wise JPEG pump would stop feeding data. - unstuff_
scan unstuff; withoutrestartsa restart marker ends the scan like any other marker (a decoder reading one restart interval must not pull in the rest of the stream).