|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Transcode producer: whole-frame WebP arm (#290 normalize-on-import). More...
#include <stddef.h>#include <stdint.h>#include "jof_internal.h"#include "jof_produce.h"#include "ra8_attributes.h"#include "ra8_err.h"#include "ra8_webp.h"#include "ra8_webp_arena.h"Go to the source code of this file.
Enumerations | |
| enum | jof_webp_const_t : uint32_t { k_jof_webp_bpp = 4U , k_jof_webp_scratch_mult = 2U , k_jof_webp_scratch_slack = 1U * 1024U * 1024U } |
| WebP whole-frame arena sizing constants (webp_work layout). More... | |
Functions | |
| uint32_t | jof_webp_work_bytes (uint16_t max_width, uint16_t max_height, uint32_t max_src_bytes) |
| Compute the whole-frame webp_work arena a WebP source needs (#290). | |
| static ra8_err_t | internal_webp_pull_all (jof_prefix_pull_t *pfx, uint8_t *dst, size_t cap, size_t *out_len) |
| Pull the whole compressed WebP source into the webp_work arena. | |
| static ra8_err_t | internal_webp_feed (jof_prod_state_t *st, const uint8_t *frame, uint16_t w, uint16_t h) |
| Band a decoded RGBA frame through the shared tile path. | |
| ra8_err_t | priv_jof_webp_transcode (jof_prod_state_t *st, jof_prefix_pull_t *pfx) |
| Transcode a WebP source into the JOF tile path (whole-frame, #290). | |
Transcode producer: whole-frame WebP arm (#290 normalize-on-import).
The producer normalises WebP manifest images to the one on-device JOF band-tile format alongside JPEG and PNG, so the reader consumes a single format regardless of source. WebP is not stripe-decodable (its lossless VP8L mode back-references the whole frame), so – unlike the streaming JPEG/PNG arms – it carries an honest whole-frame memory cost isolated in the caller's separate webp_work arena: the compressed source, the decoded RGBA frame and libwebp's scratch are all resident at once, fail-closed on any shortfall, no downscaling. Once decoded the frame is banded out through the shared band accumulator (priv_jof_on_rows()), so the emitted atlas bytes are identical to the streaming arms for the same pixels. This arm is dispatched from jof_produce.c and shares the producer state and geometry / rows / prefix-pull seams through jof_internal.h; it allocates nothing on the heap (libwebp scratch is drawn from webp_work through the ra8_webp bump arena).
[Ring 4 / Domain] {World: NS}
Definition in file jof_produce_webp.c.
| enum jof_webp_const_t : uint32_t |
WebP whole-frame arena sizing constants (webp_work layout).
The WebP decode holds the compressed source, the decoded RGBA frame and libwebp's scratch simultaneously; the scratch bound is a whole- frame-scale over-estimate (libwebp's VP8L path reconstructs the full image internally) plus a fixed slack. Under-sizing merely fails the decode closed – it can never overrun.
| Enumerator | |
|---|---|
| k_jof_webp_bpp | WebP decodes to RGBA8888. |
| k_jof_webp_scratch_mult | Scratch >= this * frame bytes. |
| k_jof_webp_scratch_slack | Fixed scratch slack (bytes). |
Definition at line 48 of file jof_produce_webp.c.
|
static |
Band a decoded RGBA frame through the shared tile path.
Feeds the whole-frame RGBA buffer to priv_jof_on_rows in tile_h slices, so the WebP path reuses the identical band/cut/encode/sink machinery as the streaming decoders (byte-identical output).
| [in,out] | st | Producer state (geometry already bound). |
| [in] | frame | Decoded RGBA8888 pixels, h rows of w * 4 bytes. |
| [in] | w | Frame width, pixels. |
| [in] | h | Frame height, pixels. |
| k_ra8_ok | Every row was fed; bands flushed as they filled. |
| other | Propagated from priv_jof_on_rows. |
frame holds h * w * 4 readable bytes. Definition at line 137 of file jof_produce_webp.c.
References jof_prod_state_t::cfg, k_jof_webp_bpp, k_ra8_ok, priv_jof_on_rows(), and jof_produce_cfg_t::tile_h.
Referenced by priv_jof_webp_transcode().
|
static |
Pull the whole compressed WebP source into the webp_work arena.
WebP is not stripe-decodable (its lossless mode back-references the whole frame), so libwebp needs the entire compressed source contiguous. Fills dst front to back; a source longer than the arena affords fails closed (k_ra8_err_invalid_size).
| [in] | pfx | Prefix-replay pull adapter over the source. |
| [out] | dst | Arena front (receives the source bytes). |
| [in] | cap | Bytes available at dst. |
| [out] | out_len | Receives the source byte count. |
| k_ra8_ok | Whole source resident in dst. |
| k_ra8_err_invalid_size | The source exceeds cap (fail-closed). |
| other | Propagated from the pull callback. |
dst holds cap writable bytes. pfx replays the sniffed head before the live source. Definition at line 94 of file jof_produce_webp.c.
References k_ra8_err_invalid_size, k_ra8_ok, and priv_jof_prefix_pull().
Referenced by priv_jof_webp_transcode().
|
nodiscard |
Compute the whole-frame webp_work arena a WebP source needs (#290).
A WebP transcode cannot stream (its lossless mode back-references the whole frame), so it holds three regions at once, all carved from webp_work: the compressed source (up to max_src_bytes), the decoded RGBA8888 frame (max_width * max_height * 4) and libwebp's decode scratch (a further whole-frame-scale allocation plus slack). Sizing with the same caps used in the produce config guarantees jof_produce() never fails on WebP arena exhaustion for an in-cap WebP source. This is separate from jof_work_bytes(): that arena stays small (the streaming tile path); only WebP-capable callers pay the whole-frame cost here.
| [in] | max_width | Largest WebP source width to support (>= 1). |
| [in] | max_height | Largest WebP source height to support (>= 1). |
| [in] | max_src_bytes | Largest compressed WebP byte length to support (>= 1). |
| 0 | A dimension is zero or exceeds the WebP per-axis cap (8192), the source-byte cap is zero, or the total exceeds the u32 arena cap. |
| >0 | Byte size to allocate for webp_work. |
max_src_bytes compressed bytes. Definition at line 54 of file jof_produce_webp.c.
References k_jof_carve_slack, k_jof_webp_bpp, k_jof_webp_scratch_mult, k_jof_webp_scratch_slack, and k_ra8_webp_max_dim.
Referenced by internal_jof_carve_webp(), ra8_fmt_jof_convert_requirements(), and worker_alloc_webp().
| ra8_err_t priv_jof_webp_transcode | ( | jof_prod_state_t * | st, |
| jof_prefix_pull_t * | pfx ) |
Transcode a WebP source into the JOF tile path (whole-frame, #290).
Pulls the whole compressed source into cfg->webp_work, reads its geometry, binds it as a 4-bpp source through priv_jof_on_geom, carves the decoded RGBA frame and libwebp scratch after the source bytes, decodes heap-free through the ra8_webp facade, and bands the frame out through priv_jof_on_rows. Every carve is bounds-checked; any shortfall fails closed. WebP is not stripe-decodable (its lossless mode back-references the whole frame), so it carries an honest whole-frame memory cost isolated in webp_work; the emitted atlas bytes are identical to the streaming arms for the same pixels.
| [in,out] | st | Producer state (priv_init_state() succeeded). |
| [in,out] | pfx | Prefix-replay pull adapter over the source. |
| k_ra8_ok | Whole WebP decoded and accumulated. |
| k_ra8_err_not_supported | No webp_work arena, or an axis over cap. |
| k_ra8_err_invalid_size | The arena cannot fit source + frame + scratch. |
| k_ra8_err_validation_failed | Corrupt WebP or the scratch exhausted. |
| other | Propagated from the pull / facade / rows. |
Definition at line 158 of file jof_produce_webp.c.
References jof_prod_state_t::cfg, internal_webp_feed(), internal_webp_pull_all(), k_jof_bump_align, k_jof_webp_bpp, k_ra8_err_invalid_size, k_ra8_err_not_supported, k_ra8_ok, priv_jof_on_geom(), RA8_PRIV, ra8_webp_decode_rgba(), ra8_webp_get_info(), jof_produce_cfg_t::webp_work, and jof_produce_cfg_t::webp_work_cap.
Referenced by internal_dispatch().