embassy-stm32

Crates

git

Versions

stm32n647a0

Flavors

Jpeg

Struct Jpeg 

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

Source

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>

Source

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>

Source

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, exactly width*height bytes.
  • 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

Returns the number of bytes written to dst.

Source

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.

Source

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.

Source§

impl<'d, T: Instance, M: Mode> Jpeg<'d, T, M>

Source

pub fn encode_blocking( &mut self, src: &[u8], cfg: &EncodeConfig, dst: &mut [u8], ) -> Result<usize, Error>

Blocking variant of encode — drives the codec FIFOs with the CPU. Available in both Async and Blocking modes; useful when no DMA channel is available.

Source

pub fn decode_blocking( &mut self, src: &[u8], dst: PlanarYCbCrMut<'_>, ) -> Result<DecodeInfo, Error>

Blocking variant of decode. The async decode is already CPU-driven; this version simply doesn’t yield to the executor. Available in both Async and Blocking modes.

Auto Trait Implementations§

§

impl<'d, T, M> Freeze for Jpeg<'d, T, M>
where T: Freeze,

§

impl<'d, T, M> RefUnwindSafe for Jpeg<'d, T, M>

§

impl<'d, T, M> Send for Jpeg<'d, T, M>
where M: Send,

§

impl<'d, T, M> Sync for Jpeg<'d, T, M>
where T: Sync, M: Sync,

§

impl<'d, T, M> Unpin for Jpeg<'d, T, M>
where T: Unpin, M: Unpin,

§

impl<'d, T, M> !UnwindSafe for Jpeg<'d, T, M>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.