49typedef enum : uint16_t {
61typedef enum : uint8_t {
68typedef enum : uint32_t {
134 size_t n = s->
len - s->
pos;
164 if (len > UINT32_MAX) {
216 if (mem ==
nullptr) {
220 *out_cap = (size_t)need;
271 if (work ==
nullptr) {
274 uint8_t* webp_work =
nullptr;
275 size_t webp_cap = 0U;
291 .work_cap = work_cap,
292 .webp_work = webp_work,
293 .webp_work_cap = webp_cap};
344 if (src ==
nullptr) {
379 const char* out_path,
382 uint8_t* src =
nullptr;
397 if (work_cap == 0U) {
409 return (aborted ==
k_ra8_ok) ? rc : aborted;
411 bool published =
false;
421 const size_t page_mark = ws->
used;
423 for (
size_t i = 0U; (rc ==
k_ra8_ok) && (i < count); ++i) {
429 char* dot =
strrchr(stem,
'.');
430 if (dot !=
nullptr) {
434 const int written = snprintf(output_leaf,
sizeof(output_leaf),
"%s.jof", stem);
440 ws->
used = page_mark;
ra8_err_t fw_fs_stat(const fw_fs_namespace_t *names, const char *path, fw_fs_stat_t *out)
Query a path; a miss is success with out->exists == false.
@ k_fw_fs_node_file
Regular byte stream.
@ k_fw_fs_path_cap
Largest portable path including its NUL.
JOF band-tile atlas: the display-native normalized image format (#231, shared with the longstrip scro...
@ k_jof_codec_deflate
Tile stream is one raw-DEFLATE run.
@ k_jof_webp_fourcc_ofs
Offset of the "WEBP" fourCC.
Import-time transcode producer: JPEG/PNG/WebP -> JOF band-tile atlas in bounded RAM (#231,...
ra8_err_t jof_probe_dims(const uint8_t *data, size_t len, uint16_t *out_w, uint16_t *out_h)
Read a source image's pixel dimensions without decoding its body.
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).
uint32_t jof_work_bytes(uint16_t max_width, uint16_t max_height, uint16_t tile_w, uint16_t tile_h)
Compute the work-arena size the producer needs for given caps.
ra8_err_t jof_produce(const jof_produce_cfg_t *cfg, jof_info_t *out_info)
Transcode one encoded JPEG/PNG/WebP source into a JOF atlas (#231, #290).
Package a downloaded chapter folder into a reader-openable container.
void * mdl_export_workspace_take(mdl_export_workspace_t *ws, size_t bytes, size_t alignment)
Reserve aligned bytes from an exporter arena.
struct mdl_export_workspace mdl_export_workspace_t
Caller-owned bounded arena for all exporter scratch state.
Module-private contracts shared by chapter export writers.
@ k_name_max
Maximum entry-name bytes.
bool priv_mdl_export_snprintf_fit(int written, size_t cap)
Report whether an snprintf result fit its destination.
ra8_err_t priv_mdl_export_path_join(char *out, size_t capacity, const char *directory, const char *leaf)
Join a canonical directory and leaf without truncation.
ra8_err_t priv_mdl_export_output_abort(mdl_export_output_t *output)
Abort one unpublished export stage, retaining cleanup failure.
ra8_err_t priv_mdl_export_output_commit(mdl_export_output_t *output, mdl_export_workspace_t *workspace, bool *out_published)
Structurally validate and publish one completed export stage.
ra8_err_t priv_mdl_export_output_begin(mdl_export_output_t *output, mdl_storage_t *storage, const char *destination, mdl_format_t format)
Bind a validated publication transaction to one destination.
ra8_err_t priv_mdl_export_output_write(mdl_export_output_t *output, const uint8_t *bytes, uint32_t length)
Append one complete byte span to an active export stage.
ra8_err_t priv_mdl_export_source_slurp(mdl_storage_t *storage, const char *path, uint8_t *destination, size_t capacity, size_t *out_length)
Read one complete bounded portable source into caller storage.
static const uint8_t s_jof_webp_riff[k_jof_webp_tag_len]
WebP RIFF container tag (page head bytes 0..3).
static bool internal_jof_is_webp(const uint8_t *data, size_t len)
Test whether a page's bytes carry the WebP RIFF container head.
static ra8_err_t internal_jof_load_source(mdl_storage_t *storage, const char *in_path, mdl_export_workspace_t *ws, uint8_t **out_src, size_t *out_slen)
Stat, bound-check, arena-claim, and slurp one source image.
ra8_err_t priv_mdl_export_jof(mdl_storage_t *storage, const char *dir, const char names[][k_name_max], size_t count, mdl_export_workspace_t *ws)
Convert every page in a chapter directory to a sibling .jof atlas.
static const uint8_t s_jof_webp_webp[k_jof_webp_tag_len]
WebP form-type fourCC (page head bytes 8..11).
static ra8_err_t internal_jof_produce_page(const uint8_t *src, size_t slen, uint16_t w, uint16_t h, uint16_t tile_h, uint32_t work_cap, mdl_export_output_t *output, mdl_export_workspace_t *ws)
Produce one page's atlas into an already-open output file.
static ra8_err_t internal_jof_pull(void *ctx, uint8_t *buf, size_t cap, size_t *got)
Copy the next encoded source span into a producer buffer.
static ra8_err_t internal_jof_carve_webp(const uint8_t *src, size_t slen, uint16_t w, uint16_t h, uint8_t **out_work, size_t *out_cap, mdl_export_workspace_t *ws)
Carve the whole-frame WebP work arena for a WebP page (no-op otherwise).
static ra8_err_t internal_jof_sink(void *ctx, const uint8_t *buf, size_t len)
Append producer output bytes to the active publication transaction.
mdl_jof_geom_t
JOF atlas tiling geometry for a long-strip page.
@ k_jof_band_h
Tile-band height in pixels.
mdl_jof_webp_t
WebP container-head offsets for the whole-frame-arena decision.
@ k_jof_webp_head_len
Bytes needed to sniff both fourCCs.
@ k_jof_webp_riff_ofs
Offset of the "RIFF" fourCC.
@ k_jof_webp_tag_len
Length of one fourCC tag.
static ra8_err_t internal_jof_one(mdl_storage_t *storage, const char *in_path, const char *out_path, mdl_export_workspace_t *ws)
Transcode one JPEG, PNG, or WebP page to a JOF band atlas.
mdl_jof_workspace_t
Hard memory ceilings for the non-reentrant transcode workspace.
@ k_jof_webp_work_cap
Maximum WebP frame workspace.
@ k_jof_work_cap
Maximum streaming work bytes.
@ k_jof_source_cap
Maximum encoded source bytes.
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_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_not_found
Requested item not found (lookup / search missed).
@ 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.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
char * strrchr(const char *s, int c)
Locate last occurrence of character in string.
Result of a portable metadata query.
uint64_t size_bytes
File length; zero for a directory.
bool exists
False means a clean lookup miss.
fw_fs_node_type_t type
Kind of node at the path.
fw_fs_namespace_t names
Namespace operations.
bool active
Begin succeeded.
Parsed + validated geometry of one JOF atlas.
Producer configuration: source, sink, tile geometry and work arena.
Pull cursor over an in-RAM encoded image.
const uint8_t * data
Encoded bytes.
One validated staged publication, including random ZIP backfill.
mdl_storage_txn_t writer
Active storage transaction.
size_t used
Current allocation high edge.
One non-reentrant downloader filesystem dependency bundle.
const fw_fs_t * fs
Injected portable filesystem.
fw_fs_transaction_t transaction
Active private filesystem stage.