Expand description
JPEG hardware codec.
Async encoder + decoder for the STM32 hardware JPEG peripheral (jpeg_v1).
Encode emits the JFIF/baseline JPEG header in software (using the standard
Annex K quantization and Huffman tables), then runs the codec for the
entropy-coded segment. Decode uses hardware header parsing (HDR=1) so any
standard baseline JPEG with a JFIF header is handled.
Supported color spaces: Grayscale and YCbCr (4:4:4 / 4:2:2 / 4:2:0).
RGB and CMYK source are not yet supported. Decode of progressive or 12-bit
JPEGs returns Error::Unsupported.
Encode runs end-to-end via DMA on both DMA channels passed to Jpeg::new:
input is fed via write_raw while output is drained via read_raw,
awaiting the codec’s end-of-conversion (EOC) interrupt to release the
task. After EOC the driver tail-drains any words still in the codec’s
output FIFO via CPU before returning. Decode is CPU-driven for now (the
per-MCU plane scatter is naive — see the limitation below).
For setups where DMA channels are scarce, Jpeg::new_blocking constructs
the driver without DMA channels (and without the JPEG interrupt). Pair it
with Jpeg::encode_blocking / Jpeg::decode_blocking, which busy-wait
on the codec FIFO flags instead of awaiting on EOC.
v1 limitations:
- The decode plane scatter is naive: bytes are written sequentially into Y, then Cb, then Cr without per-MCU geometric remapping. Round-trip dimensions and grayscale are correct; YCbCr planes are MCU-ordered.
Structs§
- Decode
Info - Decode result describing the decoded image.
- Encode
Config - Encode parameters.
- Interrupt
Handler - JPEG codec interrupt handler.
- Jpeg
- JPEG codec driver.
- PlanarY
CbCr - Planar YCbCr input for
Jpeg::encode_planar. - PlanarY
CbCr Mut - Planar YCbCr output for
Jpeg::decode.
Enums§
- Chroma
Subsampling - Chroma subsampling for YCbCr color space. Ignored for grayscale.
- Color
Space - Color space.
- Error
- JPEG driver errors.