pub struct Encoder<'d> { /* private fields */ }unstable only.Expand description
A blocking baseline JPEG encoder.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Implementations§
Source§impl<'d> Encoder<'d>
impl<'d> Encoder<'d>
Sourcepub fn new(
peripheral: JPEG<'d>,
tx: DMA2D_TX_CH0<'d>,
rx: impl Into<AnyDma2dRxChannel<'d>>,
) -> Self
pub fn new( peripheral: JPEG<'d>, tx: DMA2D_TX_CH0<'d>, rx: impl Into<AnyDma2dRxChannel<'d>>, ) -> Self
Creates a new JPEG encoder using DMA2D TX0 for macroblock reordering.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn set_timeout(&mut self, timeout: Option<Duration>)
pub fn set_timeout(&mut self, timeout: Option<Duration>)
Sets the software timeout for JPEG completion.
The timeout is disabled by default (None).
DMA cleanup can extend past this limit.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn encode(
&mut self,
input: &[u8],
output: &mut [u8],
config: EncodeConfig,
) -> Result<usize, Error>
pub fn encode( &mut self, input: &[u8], output: &mut [u8], config: EncodeConfig, ) -> Result<usize, Error>
Encodes a tightly packed image and returns the JPEG length in bytes.
See supported formats for valid format combinations
and PixelFormat for input layout requirements.
The input must be in SRAM or initialized PSRAM. RGB565, BGR565, and YCbCr 4:2:2 input must be aligned to two bytes.
The output address and length must be multiples of 4 bytes in SRAM or 64 bytes in PSRAM. PSRAM configurations that require strictly aligned memory transactions, such as encryption or ECC, are unsupported. Output contents are unspecified on error.
§Errors
Error::InvalidInputwhen dimensions or quality are invalid, or the input is too short.Error::UnsupportedFormatwhen the input format and subsampling are incompatible.Error::InvalidBufferwhen a buffer is inaccessible or unaligned, or the output payload capacity exceeds the DMA descriptor limit.Error::OutputTooSmallwhen the JPEG does not fit.Error::Timeoutwhen the configured completion wait expires.Error::Hardwareon a JPEG or DMA2D error.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.