38 if (text ==
nullptr) {
42 if (text[i] ==
'\0') {
98 uint32_t body_off = 0U;
99 uint32_t img_off = 0U;
100 uint32_t src_off = 0U;
108 const book_attr_t source = {.name_off = src_off, .value_off = page_id_off};
109 const uint32_t body = (result ==
k_ra8_ok)
112 const uint32_t image = (body != (uint32_t)
k_book_nil)
150 uint32_t page_id_off,
154 uint32_t written = 0U;
163 uint32_t recorded_offset = 0U;
175 if (recorded_offset != offset) {
204 if (metadata ==
nullptr) {
213 uint32_t fields[] = {0U, 0U, 0U, 0U};
214 const char*
const values[] = {metadata->
title,
218 for (
size_t i = 0U; i < (
sizeof(values) /
sizeof(values[0])); ++i) {
232 uint16_t max_image_edge,
233 uint8_t pixel_format)
235 if (comic ==
nullptr) {
239 if ((workspace ==
nullptr) || (image_read ==
nullptr) || (image_write ==
nullptr) ||
240 (image_ctx ==
nullptr)) {
272 const uint8_t* source,
275 if (comic ==
nullptr) {
281 if ((page_id ==
nullptr) || (source ==
nullptr) || (source_size == 0U)) {
298 uint32_t page_id_off = 0U;
322 if (comic ==
nullptr) {
329 if ((
write ==
nullptr) || (write_ctx ==
nullptr) || (out_len ==
nullptr)) {
Flat, execute-in-place container for a build-time "compiled" e-book.
@ k_book_nil
Absent index / "applies to all chapters".
@ k_book_image_gray4
4bpp gray, 2px/byte; pixel (x,y) is at flat index y*width + x.
@ k_book_pixfmt_gray4
4bpp packed grayscale, 2px/byte (default; every pre-field blob).
@ k_book_pixfmt_gray8
8bpp grayscale, 1px/byte (lossless against any grey panel).
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_empty
Container empty – nothing to retrieve.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ 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_null_ptr
Pointer was NULL where a valid pointer was required.
@ 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.
ra8_err_t ra8_rabook_comic_init(ra8_rabook_comic_t *comic, const ra8_rabook_comic_workspace_t *workspace, ra8_rabook_image_read_fn image_read, ra8_rabook_comic_write_at_fn image_write, void *image_ctx, uint16_t max_image_edge, uint8_t pixel_format)
Initialize one bounded streaming comic builder.
static bool internal_string_is_bounded(const char *text)
Return whether one bounded string has a NUL terminator.
static ra8_err_t internal_append_chapter(ra8_rabook_comic_t *comic, uint32_t page_id_off)
Append the minimal body/img DOM and one chapter row.
ra8_err_t ra8_rabook_comic_add_page(ra8_rabook_comic_t *comic, const char *page_id, const uint8_t *source, size_t source_size)
Normalize and append one source image as one comic chapter.
static ra8_err_t internal_intern(ra8_rabook_ctx_t *builder, const char *text, uint32_t *out_off)
Intern one string or classify the builder failure.
ra8_err_t ra8_rabook_comic_finish(ra8_rabook_comic_t *comic, const ra8_rabook_comic_metadata_t *metadata, ra8_rabook_write_fn write, void *write_ctx, uint32_t *out_len)
Finalize the completed comic as one canonical flat RABOOK1 stream.
static ra8_err_t internal_set_metadata(ra8_rabook_comic_t *comic, const ra8_rabook_comic_metadata_t *metadata)
Validate and intern all final metadata fields.
static ra8_err_t internal_store_image(ra8_rabook_comic_t *comic, uint32_t page_id_off, const ra8_rabook_raster_result_t *raster)
Store one normalized raster and append its image descriptor.
Streaming image-sequence builder for reader-native RABOOK comics.
ra8_err_t(* ra8_rabook_comic_write_at_fn)(void *ctx, uint32_t offset, const uint8_t *source, uint32_t requested, uint32_t *out_written)
Write normalized image bytes at one logical spool offset.
@ k_ra8_rabook_comic_string_max
Bytes including the terminating NUL.
ra8_err_t ra8_rabook_raster_encode(const uint8_t *source, size_t source_size, uint16_t max_edge, uint8_t pixel_format, ra8_rabook_raster_workspace_t *workspace, uint8_t *encoded, size_t encoded_cap, ra8_rabook_raster_result_t *result)
Decode and normalize one encoded raster into a RABOOK image payload.
uint32_t ra8_rabook_add_element(ra8_rabook_ctx_t *ctx, uint32_t name_off, const book_attr_t *attrs, uint16_t attr_count)
Append an element node with its attributes; return its node index.
ra8_err_t ra8_rabook_link_child(ra8_rabook_ctx_t *ctx, uint32_t parent, uint32_t child)
Set parent's first child to child.
uint32_t ra8_rabook_intern(ra8_rabook_ctx_t *ctx, const char *str)
Intern a NUL-terminated UTF-8 string into the pool, de-duplicated.
ra8_err_t(* ra8_rabook_image_read_fn)(void *ctx, uint32_t offset, uint8_t *dst, uint32_t requested, uint32_t *out_read)
Read bytes from an externally stored image pool.
ra8_err_t ra8_rabook_set_metadata(ra8_rabook_ctx_t *ctx, uint32_t title_off, uint32_t author_off, uint32_t language_off, uint32_t identifier_off, uint32_t cover_image_index)
Record the book metadata offsets that land in the blob header.
ra8_err_t(* ra8_rabook_write_fn)(void *ctx, const uint8_t *src, uint32_t requested, uint32_t *out_written)
Append bytes to a streaming RABOOK1 destination.
uint32_t ra8_rabook_add_image_external(ra8_rabook_ctx_t *ctx, uint32_t id_off, uint16_t width, uint16_t height, uint8_t format, uint8_t pixel_format, uint32_t data_size, uint32_t *out_data_off)
Append an image descriptor whose bytes live in a caller-owned spool.
uint32_t ra8_rabook_add_chapter(ra8_rabook_ctx_t *ctx, uint32_t title_off, uint32_t href_off, uint32_t root_node)
Append a spine chapter; return its chapter index.
ra8_err_t rabook_compile_init(ra8_rabook_ctx_t *ctx, const ra8_rabook_buffers_t *buf)
Bind a builder context to its caller-provided arenas.
ra8_err_t ra8_rabook_finalize_stream(const ra8_rabook_ctx_t *ctx, ra8_rabook_image_read_fn image_read, void *image_ctx, ra8_rabook_write_fn write, void *write_ctx, uint8_t *scratch, uint32_t scratch_cap, uint32_t *out_len)
Stream a canonical flat RABOOK1 blob without a full output arena.
One name="value" attribute on an element.
Mutable state for one image-sequence-to-RABOOK build.
void * image_ctx
Shared image-spool context.
uint8_t * normalized
One normalized page payload.
uint8_t pixel_format
Gray4 or gray8 output depth.
uint16_t max_image_edge
Optional output edge clamp.
uint32_t page_count
Successfully appended pages.
uint8_t * stream_scratch
Finalizer transfer scratch.
uint32_t stream_scratch_cap
Finalizer scratch capacity.
bool active
Build accepts more operations.
size_t normalized_cap
Normalized output capacity.
ra8_rabook_raster_workspace_t raster
Retained raster workspace.
ra8_rabook_ctx_t builder
Canonical table builder.
ra8_rabook_image_read_fn image_read
Repeatable image-spool reader.
ra8_rabook_comic_write_at_fn image_write
Image-spool random writer.
Caller-owned arenas retained for one streaming comic build.
uint8_t * stream_scratch
Finalizer transfer scratch.
size_t normalized_cap
Writable normalized bytes.
uint8_t * normalized
One normalized page payload.
uint32_t stream_scratch_cap
Finalizer scratch bytes.
ra8_rabook_raster_workspace_t raster
Codec and scaling arenas.
ra8_rabook_buffers_t builder
Resident table/string arenas.
Builder state: the arenas plus running counts and a sticky-fail flag.
bool failed
Sticky: an arena overflowed.
uint32_t image_pool_size
Image-pool bytes used.
Geometry and byte count of a normalized RABOOK raster payload.
uint16_t height
Output height in pixels.
uint32_t encoded_size
Bytes written to the encoded destination.
uint8_t pixel_format
book_image_pixfmt_t emitted.
uint16_t width
Output width in pixels.