59 done += (uint32_t)got;
153 switch (color_type) {
199 if ((w32 == 0U) || (w32 > (uint32_t)max_w)) {
202 if ((h32 == 0U) || (h32 > (uint32_t)max_h)) {
221 st->
w = (uint16_t)w32;
222 st->
h = (uint16_t)h32;
372 if (
memcmp(sig, s_png_sig,
sizeof(sig)) != 0) {
Module-private seams shared by the producer translation units.
static ra8_err_t internal_png_parse_ihdr(ra8_png_state_t *st, uint16_t max_w, uint16_t max_h)
Read the IHDR chunk (must be first) and validate its payload.
ra8_err_t priv_jof_png_chunk_hdr(ra8_png_state_t *st, uint32_t *out_len, uint32_t *out_type)
Read one 8-byte chunk header (length + type, both big-endian).
static ra8_err_t internal_png_check_ihdr(ra8_png_state_t *st, const uint8_t *ihdr, uint16_t max_w, uint16_t max_h)
Validate the 13 IHDR payload bytes and bind the geometry fields.
ra8_err_t priv_jof_png_pre_idat(ra8_png_state_t *st, uint32_t len, uint32_t type)
Dispatch one pre-IDAT chunk (PLTE / tRNS / ancillary / stray IEND).
static ra8_err_t internal_png_parse_plte(ra8_png_state_t *st, uint32_t len)
Parse a PLTE chunk into the palette table (colour type 3).
static ra8_err_t internal_png_parse_trns(ra8_png_state_t *st, uint32_t len)
Parse a tRNS chunk (palette alpha; colour type 3 only).
ra8_err_t priv_jof_png_prologue(ra8_png_state_t *st, uint16_t max_w, uint16_t max_h)
Verify the 8-byte signature, then parse + validate the IHDR.
ra8_err_t priv_jof_png_pull_exact(ra8_png_state_t *st, uint8_t *buf, uint32_t len)
Pull exactly len bytes; EOF mid-read is a protocol error.
ra8_err_t priv_jof_png_skip(ra8_png_state_t *st, uint32_t len)
Discard exactly len source bytes (unknown / ancillary chunks).
static uint8_t internal_png_src_channels(uint8_t color_type)
Map an IHDR colour type to its source bytes-per-pixel, or 0.
ra8_err_t priv_jof_png_finish(ra8_png_state_t *st)
Walk the post-IDAT chunks until IEND (ancillary chunks skipped).
Module-private declarations shared by the two PNG decoder units.
@ k_ra8_png_color_rgba
Truecolour + alpha.
@ k_ra8_png_ch_3
3 bytes per pixel.
@ k_ra8_png_color_gray
Grayscale.
@ k_ra8_png_ihdr_ofs_filter
Filter-method offset.
@ k_ra8_png_ihdr_ofs_compress
Compression-method offset.
@ k_ra8_png_be_sh24
Big-endian assembly shifts.
@ k_ra8_png_ihdr_ofs_depth
Bit-depth byte offset.
@ k_ra8_png_color_ga
Grayscale + alpha.
@ k_ra8_png_ihdr_ofs_interlace
Interlace-method offset.
@ k_ra8_png_be_sh16
Big-endian assembly shifts.
@ k_ra8_png_color_pal
Indexed-colour.
@ k_ra8_png_depth_8
Only supported bit depth.
@ k_ra8_png_ch_2
2 bytes per pixel.
@ k_ra8_png_color_rgb
Truecolour.
@ k_ra8_png_ihdr_ofs_color
Colour-type byte offset.
@ k_ra8_png_ch_1
1 byte per pixel.
@ k_ra8_png_ch_4
4 bytes per pixel.
@ k_ra8_png_be_sh8
Big-endian assembly shifts.
@ k_ra8_png_sig_lf
Line feed byte.
@ k_ra8_png_sig_cr
Carriage return byte.
@ k_ra8_png_sig_sub
DOS EOF byte.
@ k_ra8_png_sig_high
High-bit signature byte.
@ k_ra8_png_type_trns
"tRNS" big-endian.
@ k_ra8_png_sig_bytes
Signature length.
@ k_ra8_png_type_ihdr
"IHDR" big-endian.
@ k_ra8_png_skip_chunk
Discard-buffer granularity.
@ k_ra8_png_type_plte
"PLTE" big-endian.
@ k_ra8_png_ihdr_len
IHDR payload length.
@ k_ra8_png_max_chunks
Chunk-walk budget (hostile cap).
@ k_ra8_png_type_idat
"IDAT" big-endian.
@ k_ra8_png_plte_max
Max PLTE payload (256 * 3).
@ k_ra8_png_type_iend
"IEND" big-endian.
@ k_ra8_png_chunk_hdr
Chunk length + type fields.
@ k_ra8_png_trns_max
Max palette tRNS payload.
@ k_ra8_png_max_len
Max legal chunk length.
@ k_ra8_png_crc_bytes
Trailing chunk CRC field.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Error Code Definitions for ra8-firmware.
@ k_ra8_err_not_supported
Requested feature not compiled in, not wired, or not supported by this MCU variant.
@ k_ra8_err_validation_failed
Validation rule failed (caller-supplied invariant not satisfied).
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_protocol_error
Protocol-level error (e.g.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
int memcmp(const void *a, const void *b, size_t n)
Compare bytes in two memory areas.
Whole streaming PNG decode state (module-static instance).
uint16_t trns_count
tRNS entries present.
uint32_t pending_type
Pending chunk type (big-endian value).
uint8_t pending_valid
1 when a pending chunk header is held.
uint8_t src_ch
Source bytes per pixel (filter bpp).
void * pull_ctx
Context for pull.
uint32_t pending_len
Pending chunk payload length.
jof_pull_fn pull
Sequential byte source.
uint8_t trns[k_ra8_png_trns_max]
Palette alpha (tRNS).
uint8_t has_trns
1 once tRNS parsed.
uint16_t h
Image height, pixels.
uint16_t plte_count
Palette entries present.
uint8_t palette[k_ra8_png_plte_max]
PLTE payload (RGB triples).
uint8_t has_plte
1 once PLTE parsed.
uint8_t color_type
IHDR colour type.
uint16_t w
Image width, pixels.