pub struct Jpeg<'d, T: Instance, M: Mode> { /* private fields */ }Expand description
JPEG codec driver.
Implementations§
Source§impl<'d, T: Instance> Jpeg<'d, T, Async>
impl<'d, T: Instance> Jpeg<'d, T, Async>
Sourcepub fn new<DIn: DmaIn<T>, DOut: DmaOut<T>>(
peri: Peri<'d, T>,
indma: Peri<'d, DIn>,
outdma: Peri<'d, DOut>,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + Binding<DIn::Interrupt, InterruptHandler<DIn>> + Binding<DOut::Interrupt, InterruptHandler<DOut>> + 'd,
) -> Self
pub fn new<DIn: DmaIn<T>, DOut: DmaOut<T>>( peri: Peri<'d, T>, indma: Peri<'d, DIn>, outdma: Peri<'d, DOut>, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + Binding<DIn::Interrupt, InterruptHandler<DIn>> + Binding<DOut::Interrupt, InterruptHandler<DOut>> + 'd, ) -> Self
Create a new JPEG driver with DMA-driven async encode/decode.
Source§impl<'d, T: Instance> Jpeg<'d, T, Blocking>
impl<'d, T: Instance> Jpeg<'d, T, Blocking>
Sourcepub fn new_blocking(peri: Peri<'d, T>) -> Self
pub fn new_blocking(peri: Peri<'d, T>) -> Self
Create a new JPEG driver without DMA channels for blocking-only use.
Pair with encode_blocking /
decode_blocking. Saves two DMA channels and
the JPEG interrupt slot at the cost of busy-waiting on the FIFOs.
Source§impl<'d, T: Instance> Jpeg<'d, T, Async>
impl<'d, T: Instance> Jpeg<'d, T, Async>
Sourcepub async fn encode(
&mut self,
src: &[u8],
cfg: &EncodeConfig,
dst: &mut [u8],
) -> Result<usize, Error>
pub async fn encode( &mut self, src: &[u8], cfg: &EncodeConfig, dst: &mut [u8], ) -> Result<usize, Error>
Encode a raw, MCU-ordered pixel buffer into a JPEG (with full JFIF header) in dst.
src layout depends on cfg:
Grayscale: tightly packed Y bytes, row-major, exactlywidth*heightbytes.YCbCr: per-MCU, all 8×8 luma blocks in raster order followed by the Cb 8×8 block then the Cr 8×8 block. Total size:- 4:2:0 →
width*height*3/2 - 4:2:2 →
width*height*2 - 4:4:4 →
width*height*3
- 4:2:0 →
Returns the number of bytes written to dst.
Sourcepub async fn encode_planar(
&mut self,
planes: PlanarYCbCr<'_>,
scratch: &mut [u8],
cfg: &EncodeConfig,
dst: &mut [u8],
) -> Result<usize, Error>
pub async fn encode_planar( &mut self, planes: PlanarYCbCr<'_>, scratch: &mut [u8], cfg: &EncodeConfig, dst: &mut [u8], ) -> Result<usize, Error>
Encode planar Y/Cb/Cr into a JPEG. The driver shuffles planes into MCU
order in the caller-supplied scratch buffer (which must be exactly the
MCU-ordered input size for cfg), then runs encode.
Sourcepub async fn decode(
&mut self,
src: &[u8],
dst: PlanarYCbCrMut<'_>,
) -> Result<DecodeInfo, Error>
pub async fn decode( &mut self, src: &[u8], dst: PlanarYCbCrMut<'_>, ) -> Result<DecodeInfo, Error>
Decode a JPEG bitstream into planar Y/Cb/Cr.
The peripheral parses the JFIF header in hardware (HDR=1); after the
HPDF interrupt the driver reads back the image dimensions and color
space, then runs the codec into an MCU-row staging buffer that gets
scattered into the caller’s plane buffers.