Expand description
§TJpgDec-rs - Tiny JPEG Decompressor
A lightweight JPEG decoder optimized for embedded systems.
Based on TJpgDec R0.03 (C)ChaN, 2021
§Key Features
- Memory pool allocation - Predictable memory usage
- Small decoder struct - Only ~120 bytes
- no_std compatible - Works in embedded environments
- Three optimization levels - Balance speed vs memory (fast-decode-0/1/2)
- No heap allocation - All memory from user-provided pool
§Example Usage
use tjpgdec_rs::{JpegDecoder, MemoryPool, RECOMMENDED_POOL_SIZE, Result};
fn decode_jpeg(jpeg_data: &[u8]) -> Result<()> {
// Allocate memory pool
let mut pool_buffer = vec![0u8; RECOMMENDED_POOL_SIZE];
let mut pool = MemoryPool::new(&mut pool_buffer);
// Create decoder
let mut decoder = JpegDecoder::new();
// Prepare decoder
decoder.prepare(jpeg_data, &mut pool)?;
// Get image info
let width = decoder.width();
let height = decoder.height();
// Decode image...
Ok(())
}Structs§
- BitStream
- Bit stream reader
- Huffman
Table - Huffman coding table
- Jpeg
Decoder - JPEG decoder
- Memory
Pool - Memory pool for workspace allocation
- Rectangle
- Rectangular region in the output image
Enums§
- Error
- Error codes for JPEG decompression
- Output
Format - Output pixel format
Constants§
- BUFFER_
SIZE - Size of stream input buffer
- MINIMUM_
POOL_ SIZE - Minimum workspace size
- MIN_
WORKSPACE_ SIZE - RECOMMENDED_
POOL_ SIZE - Recommended workspace size
Functions§
- calculate_
pool_ size - Calculate required workspace memory pool size
- fastdecode_
level - Query the current optimization level
Type Aliases§
- Output
Callback - Output callback function
- Result
- Result type for JPEG operations