embassy-stm32

Crates

git

Versions

stm32n645a0

Flavors

Module jpeg

Module jpeg 

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

DecodeInfo
Decode result describing the decoded image.
EncodeConfig
Encode parameters.
InterruptHandler
JPEG codec interrupt handler.
Jpeg
JPEG codec driver.
PlanarYCbCr
Planar YCbCr input for Jpeg::encode_planar.
PlanarYCbCrMut
Planar YCbCr output for Jpeg::decode.

Enums§

ChromaSubsampling
Chroma subsampling for YCbCr color space. Ignored for grayscale.
ColorSpace
Color space.
Error
JPEG driver errors.

Traits§

DmaIn
DmaIn DMA request trait
DmaOut
DmaOut DMA request trait
Instance
JPEG instance trait.