46typedef enum : uint32_t {
107static size_t cm_ct_read(
void* ctx, uint64_t off,
void* buf,
size_t len)
110 if ((s ==
nullptr) || (buf ==
nullptr) || (off >= (uint64_t)s->
n)) {
113 const uint64_t avail = (uint64_t)s->
n - off;
114 const size_t k = (len > (size_t)avail) ? (
size_t)avail : len;
115 (void)
memcpy(buf, &s->
d[off], k);
120static uint32_t
cm_ct_fnv(uint32_t h,
const uint8_t* p,
size_t n)
122 for (
size_t i = 0U; i < n; ++i) {
179 for (uint16_t ty = 0U; ty < info->
tile_rows; ++ty) {
180 for (uint16_t tx = 0U; tx < info->
tile_cols; ++tx) {
185 const size_t n = (size_t)tile.
width * (
size_t)tile.
height * (size_t)info->
bpp;
209 .decode_ctx =
nullptr,
244 .webp_work =
nullptr,
260 r.
w = (uint32_t)info.
width;
263 r.
crc = r.
ok ? crc : 0U;
static comic_t s_ct_comic
SDRAM: the open comic reader.
cm_tiled_result_t cm_comic_tiled_selfcheck(void)
Open the baked oversized page through the tile path and digest it.
static comic_page_t s_ct_pages[k_ct_page_cap]
SDRAM: comic page-index storage.
static uint8_t s_ct_pagebuf[k_ct_pagebuf]
SDRAM: encoded page scratch (the tile producer's input).
static char s_ct_names[k_ct_name_cap]
SDRAM: comic name arena.
static int32_t s_ct_buckets[k_ct_buckets]
Tile-cache hash buckets.
static cm_ct_blob_t s_ct_blob
Blob backing bound into the read seam.
static comic_tile_reader_t s_ct_reader
SDRAM: the comic tile reader.
static ra8_keycache_cell_t s_ct_meta[k_ct_cells]
Tile-cache link metadata.
static bool cm_ct_open(size_t *out_got)
Open the baked oversized CBZ and read page 0's encoded bytes.
static uint8_t s_ct_atlas[k_ct_atlas]
SDRAM: produced JOF atlas backing store.
static uint8_t s_ct_scratch[k_ct_scratch]
SDRAM: stored-tile staging for deflate tiles.
static uint32_t cm_ct_fnv(uint32_t h, const uint8_t *p, size_t n)
FNV-1a-32 folding n bytes of p into the running hash h.
cm_tiled_cfg_t
Tile geometry, cache budget, and hashing constants for the self-check.
@ k_ct_buckets
Tile-cache hash buckets.
@ k_ct_name_cap
Comic name-arena bytes.
@ k_ct_cell_bytes
Bytes per cache cell.
@ k_ct_work
Producer work arena, bytes.
@ k_ct_page_cap
Comic page-index capacity.
@ k_ct_fnv_offset
FNV-1a-32 offset basis.
@ k_ct_bpp_gray
Grayscale atlas bytes per pixel.
@ k_ct_cells
Tile-cache cell budget.
@ k_ct_atlas
Atlas memstore backing, bytes.
@ k_ct_budget
Whole-decode budget (threshold).
@ k_ct_tile
Square tile edge, pixels.
@ k_ct_pagebuf
Encoded page scratch, bytes.
@ k_ct_fnv_prime
FNV-1a-32 prime.
@ k_ct_scratch
Stored-tile staging, bytes.
static bool cm_ct_hash_tiles(const jof_info_t *info, uint32_t *out_crc)
Decode every tile of the bound atlas, FNV-hashing the pixels.
static ra8_tile_key_t s_ct_keys[k_ct_cells]
Tile-cache key storage.
static uint8_t s_ct_cells[(size_t) k_ct_cells *(size_t) k_ct_cell_bytes]
SDRAM: tile-cache cell storage.
static ra8_tile_cache_cfg_t cm_ct_cache_cfg(void)
Tile-cache storage config over the file-static cache buffers.
static uint8_t s_ct_work[k_ct_work]
SDRAM: producer streaming work arena.
static ra8_tile_dims_t s_ct_dims[k_ct_cells]
Tile-cache dimension descriptors.
static size_t cm_ct_read(void *ctx, uint64_t off, void *buf, size_t len)
comic_read_fn over the resident CBZ blob (bounds-clamped).
Boot-time self-check that opens an oversized comic page via the JOF tile path and reports a determini...
Unified demand-paged reader for comic-book archives – CBZ (ZIP) and CBR (RAR).
ra8_err_t comic_page_read(comic_t *c, uint32_t page, uint8_t *buf, size_t cap, size_t *got)
Extract one page's encoded image bytes for the decoder.
ra8_err_t comic_close(comic_t *c)
Release an open comic's backend resources.
ra8_err_t comic_open(comic_t *c, comic_read_fn read, void *ctx, uint64_t size, comic_page_t *pages, uint32_t page_cap, char *names, uint32_t names_cap)
Open a comic archive (CBZ or CBR) and build its sorted page index.
static uint32_t comic_page_count(const comic_t *c)
Number of pages in an open comic.
Baked oversized single-page CBZ for the ereader_comic tile self-check (#344; generated by scripts/gen...
@ k_comic_large_h
Decoded height in pixels.
@ k_comic_large_w
Decoded width in pixels.
static const uint8_t k_comic_large_cbz[]
Baked 423-byte single-page oversized CBZ.
static const uint32_t k_comic_large_cbz_len
Length of k_comic_large_cbz in bytes.
Tile an oversized comic page through the JOF atlas + ra8_tile_cache so a CBZ/CBR page larger than the...
ra8_err_t comic_tiles_tile(comic_tile_reader_t *r, uint16_t tile_x, uint16_t tile_y, ra8_tile_t *out_tile)
Get (and pin) one decoded tile of the bound page (#344).
ra8_err_t comic_tiles_import(comic_tile_reader_t *r, const uint8_t *enc, size_t enc_len, const comic_tiles_import_cfg_t *cfg)
Transcode one encoded comic page to a JOF atlas and bind it for tiling.
ra8_err_t comic_tiles_info(const comic_tile_reader_t *r, jof_info_t *out_info)
Report the bound page's parsed atlas geometry (#344).
ra8_err_t comic_tiles_footprint(const uint8_t *enc, size_t len, uint16_t *out_w, uint16_t *out_h, uint64_t *out_decoded_bytes)
Read a comic page's decoded footprint from its encoded header (#344).
bool comic_tiles_over_budget(uint64_t decoded_bytes, uint64_t budget_bytes)
Decide whether a page's decoded footprint exceeds the resident budget.
ra8_err_t comic_tiles_init(comic_tile_reader_t *r, const ra8_tile_cache_cfg_t *storage, uint8_t *scratch, uint32_t scratch_cap)
Initialise a comic tile reader over caller-supplied tile-cache storage.
ra8_err_t comic_tiles_release(comic_tile_reader_t *r, const uint8_t *pixels)
Release one pin taken by comic_tiles_tile (#344).
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.
Import-time transcode producer: JPEG/PNG/WebP -> JOF band-tile atlas in bounded RAM (#231,...
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
Fixed-RAM-budget image-tile cache with LRU eviction (Layer 3b, #147).
Resident-buffer backing for the comic reader's seek+read seam.
const uint8_t * d
Archive bytes.
Outcome of the oversized-page tile self-check.
uint32_t w
Decoded page width, pixels.
uint32_t h
Decoded page height, pixels.
bool ok
True when the oversized page tiled cleanly.
uint32_t tiles
Tile count in the produced JOF atlas.
uint32_t crc
FNV-1a-32 over the concatenated tile bytes.
One entry in the resident, sorted page index.
One open comic archive: backing, kind, page index, and backend state.
One comic tile reader: owned tile cache, atlas store, bound page.
Import-time transcode knobs, work arena, and destination atlas store.
Parsed + validated geometry of one JOF atlas.
uint8_t bpp
Bytes per pixel (1, 3 or 4).
uint16_t width
Image width, pixels.
uint16_t tile_rows
Ceil(height / tile_h) tile rows.
uint32_t tile_count
Total tiles (== cols * rows).
uint16_t height
Image height, pixels.
uint16_t tile_cols
Ceil(width / tile_w) tile columns.
Per-cell link metadata (one caller-owned array entry per cell).
Caller-supplied storage + decoder for ra8_tile_cache_init.
Per-cell user descriptor: the decoded tile dimensions.
Identifies one decoded image tile.
A pinned view of a cached tile returned by ra8_tile_cache_get.
const uint8_t * pixels
Decoded tile pixels (cell payload).
uint16_t height
Decoded tile height in pixels.
uint16_t width
Decoded tile width in pixels.