|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Module-private declarations shared by the two PNG decoder units. More...
#include <stddef.h>#include <stdint.h>#include "jof_internal.h"#include "miniz.h"#include "ra8_attributes.h"#include "ra8_err.h"Go to the source code of this file.
Data Structures | |
| struct | ra8_png_state_t |
| Whole streaming PNG decode state (module-static instance). More... | |
Functions | |
| 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). | |
| 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). | |
| 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_pre_idat (ra8_png_state_t *st, uint32_t len, uint32_t type) |
| Dispatch one pre-IDAT chunk (PLTE / tRNS / ancillary / stray IEND). | |
| 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.
The streaming PNG decoder is split to stay under the maintainability line cap:
This header carries the shared decode-state type, the structural constants, and the chunk-layer prototypes the pixel layer drives.
Definition in file jof_png_internal.h.
| enum ra8_png_const_t : uint32_t |
PNG structural sizes and caps (PNG sec 5 "Datastream structure").
Definition at line 42 of file jof_png_internal.h.
| enum ra8_png_field_t : uint8_t |
IHDR field offsets and legal values (PNG sec 11.2.2 "IHDR").
Definition at line 73 of file jof_png_internal.h.
| enum ra8_png_signature_t : uint8_t |
Fixed non-ASCII bytes in the PNG signature.
| Enumerator | |
|---|---|
| k_ra8_png_sig_high | High-bit signature byte. |
| k_ra8_png_sig_cr | Carriage return byte. |
| k_ra8_png_sig_lf | Line feed byte. |
| k_ra8_png_sig_sub | DOS EOF byte. |
Definition at line 62 of file jof_png_internal.h.
| 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).
Assembles the fields and enforces the spec length cap.
| [in,out] | st | Decoder state (source position advances). |
| [out] | out_len | Receives the payload length. |
| [out] | out_type | Receives the chunk type value. |
| k_ra8_ok | Header read; length within the spec cap. |
| k_ra8_err_protocol_error | Truncated header or oversize length. |
| other | Propagated from the pull callback. |
Assembles the big-endian length and type fields and enforces the spec length cap.
| [in,out] | st | Decoder state (source position advances). |
| [out] | out_len | Receives the payload length. |
| [out] | out_type | Receives the chunk type value. |
| k_ra8_ok | Header read; length within the spec cap. |
| k_ra8_err_protocol_error | Truncated header or oversize length. |
| other | Propagated from the pull callback. |
Definition at line 113 of file jof_png_chunk.c.
References k_ra8_err_protocol_error, k_ra8_ok, k_ra8_png_be_sh16, k_ra8_png_be_sh24, k_ra8_png_be_sh8, k_ra8_png_chunk_hdr, k_ra8_png_max_len, priv_jof_png_pull_exact(), and RA8_PRIV.
Referenced by internal_png_parse_ihdr(), internal_png_refill_input(), internal_png_walk_chunks(), and priv_jof_png_finish().
| ra8_err_t priv_jof_png_finish | ( | ra8_png_state_t * | st | ) |
Walk the post-IDAT chunks until IEND (ancillary chunks skipped).
When the zlib stream ended inside the last IDAT (no pending chunk parked by the refill path), that IDAT's trailing CRC is still unread: consume it, then resume the chunk walk.
| [in,out] | st | Decoder state (pending chunk consumed first). |
| k_ra8_ok | IEND reached. |
| k_ra8_err_protocol_error | Chunk budget exhausted / truncation / a stray IDAT after the stream ended. |
| other | Propagated from the pull callback. |
Definition at line 426 of file jof_png_chunk.c.
References k_ra8_err_protocol_error, k_ra8_ok, k_ra8_png_crc_bytes, k_ra8_png_max_chunks, k_ra8_png_type_idat, k_ra8_png_type_iend, ra8_png_state_t::pending_len, ra8_png_state_t::pending_type, ra8_png_state_t::pending_valid, priv_jof_png_chunk_hdr(), priv_jof_png_skip(), and RA8_PRIV.
Referenced by internal_png_run_idat().
| 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).
PLTE and tRNS bind the palette tables; unknown chunks skip.
| [in,out] | st | Decoder state. |
| [in] | len | Chunk payload length. |
| [in] | type | Chunk type value. |
| k_ra8_ok | Chunk consumed; keep walking. |
| k_ra8_err_protocol_error | IEND arrived before any IDAT. |
| other | Propagated from the chunk parsers. |
len came from a validated chunk header. | [in,out] | st | Decoder state. |
| [in] | len | Chunk payload length. |
| [in] | type | Chunk type value. |
| k_ra8_ok | Chunk consumed; keep walking. |
| k_ra8_err_protocol_error | IEND arrived before any IDAT. |
| other | Propagated from the chunk parsers. |
len came from a validated chunk header. Definition at line 394 of file jof_png_chunk.c.
References internal_png_parse_plte(), internal_png_parse_trns(), k_ra8_err_protocol_error, k_ra8_png_crc_bytes, k_ra8_png_type_iend, k_ra8_png_type_plte, k_ra8_png_type_trns, priv_jof_png_skip(), and RA8_PRIV.
Referenced by internal_png_walk_chunks().
| 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.
Fail-closed prologue for the untrusted stream.
| [in,out] | st | Decoder state (geometry fields written). |
| [in] | max_w | Fail-closed width cap. |
| [in] | max_h | Fail-closed height cap. |
| k_ra8_ok | Prologue accepted; chunk walk may start. |
| k_ra8_err_protocol_error | Bad signature / IHDR structure. |
| other | Propagated from the IHDR validation. |
st holds the bound callbacks. | [in,out] | st | Decoder state (geometry fields written). |
| [in] | max_w | Fail-closed width cap. |
| [in] | max_h | Fail-closed height cap. |
| k_ra8_ok | Prologue accepted; chunk walk may start. |
| k_ra8_err_protocol_error | Bad signature / IHDR structure. |
| other | Propagated from the IHDR validation. |
st holds the bound callbacks. Definition at line 357 of file jof_png_chunk.c.
References internal_png_parse_ihdr(), k_ra8_err_protocol_error, k_ra8_ok, k_ra8_png_sig_bytes, k_ra8_png_sig_cr, k_ra8_png_sig_high, k_ra8_png_sig_lf, k_ra8_png_sig_sub, memcmp(), priv_jof_png_pull_exact(), and RA8_PRIV.
Referenced by internal_png_walk_chunks().
| 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.
Bounded by len (each non-EOF pull delivers >= 1 byte).
| [in,out] | st | Decoder state (source position advances). |
| [out] | buf | Destination buffer. |
| [in] | len | Bytes required. |
| k_ra8_ok | Exactly len bytes delivered. |
| k_ra8_err_protocol_error | The source ended early. |
| other | Propagated from the pull callback. |
buf holds len writable bytes. len bytes. Bounded by len (each non-EOF pull delivers >= 1 byte).
| [in,out] | st | Decoder state (source position advances). |
| [out] | buf | Destination buffer. |
| [in] | len | Bytes required. |
| k_ra8_ok | Exactly len bytes delivered. |
| k_ra8_err_protocol_error | The source ended early. |
| other | Propagated from the pull callback. |
buf holds len writable bytes. st->pull is bound. len bytes. Definition at line 47 of file jof_png_chunk.c.
References k_ra8_err_protocol_error, k_ra8_ok, ra8_png_state_t::pull, ra8_png_state_t::pull_ctx, and RA8_PRIV.
Referenced by internal_png_parse_ihdr(), internal_png_parse_plte(), internal_png_parse_trns(), internal_png_refill_input(), priv_jof_png_chunk_hdr(), priv_jof_png_prologue(), and priv_jof_png_skip().
| ra8_err_t priv_jof_png_skip | ( | ra8_png_state_t * | st, |
| uint32_t | len ) |
Discard exactly len source bytes (unknown / ancillary chunks).
Bounded by len over a fixed-size stack scratch.
| [in,out] | st | Decoder state (source position advances). |
| [in] | len | Bytes to discard. |
| k_ra8_ok | Bytes discarded. |
| k_ra8_err_protocol_error | The source ended early. |
| other | Propagated from the pull callback. |
len came from a validated chunk-length field. len bytes. Bounded by len over a fixed-size stack scratch.
| [in,out] | st | Decoder state (source position advances). |
| [in] | len | Bytes to discard. |
| k_ra8_ok | Bytes discarded. |
| k_ra8_err_protocol_error | The source ended early. |
| other | Propagated from the pull callback. |
st->pull is bound. len came from a validated chunk-length field. len bytes. Definition at line 80 of file jof_png_chunk.c.
References k_ra8_ok, k_ra8_png_skip_chunk, priv_jof_png_pull_exact(), and RA8_PRIV.
Referenced by internal_png_parse_ihdr(), internal_png_parse_plte(), internal_png_parse_trns(), internal_png_refill_input(), priv_jof_png_finish(), and priv_jof_png_pre_idat().