33#if __has_include("ra8_tile_cache.h") && __has_include("jof.h")
49static const char*
const s_tag =
"comic_tiles";
85 comic_tiles_pull_t* p = (comic_tiles_pull_t*)ctx;
86 const size_t remain = p->n - p->off;
87 const size_t k = (cap < remain) ? cap : remain;
89 (void)
memcpy(buf, &p->d[p->off], k);
146 uint64_t* out_decoded_bytes)
169 return (budget_bytes != 0U) && (decoded_bytes > budget_bytes);
175 uint32_t scratch_cap)
179 (void)
memset(r, 0,
sizeof(*r));
181 r->
scratch_cap = (scratch !=
nullptr) ? scratch_cap : 0U;
243 comic_tiles_pull_t pull = {.d = enc, .n = enc_len, .off = 0U};
245 .pull = internal_mem_pull,
248 .sink_ctx = &r->
store,
272 const ra8_err_t nz = internal_import_args_ok(r, enc, cfg);
280 const ra8_err_t err = internal_transcode(r, enc, enc_len, cfg);
int comic_tiles_unused_translation_unit_t
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).
@ k_comic_tiles_decoded_bpp
Bytes/pixel used for the budget estimate.
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...
ra8_err_t jof_memstore_pread(void *ctx, uint64_t offset, uint8_t *buf, size_t len, size_t *got)
Positioned read from a jof_memstore_t (reader seam).
ra8_err_t jof_read_tile(jof_pread_fn pread, void *pread_ctx, const jof_info_t *info, uint16_t tile_x, uint16_t tile_y, uint8_t *scratch, uint32_t scratch_cap, uint8_t *out_px, uint32_t out_cap, uint16_t *out_w, uint16_t *out_h)
Read + decode one tile into caller pixels, in bounded RAM.
ra8_err_t jof_parse(jof_pread_fn pread, void *pread_ctx, uint64_t total_size, jof_info_t *out_info)
Parse + validate a JOF atlas's header, footer and index bounds.
ra8_err_t jof_memstore_sink(void *ctx, const uint8_t *buf, size_t len)
Append len bytes to a jof_memstore_t (producer sink).
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.
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).
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_out_of_range
Sensor or peripheral output out of valid range.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ 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.
void * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
static ra8_err_t internal_tile_decode(void *ctx, const void *key, uint8_t *cell, uint32_t cell_bytes, void *user)
Decode trampoline: adapt ra8_tile_decode_fn to the keycache seam.
Fixed-RAM-budget image-tile cache with LRU eviction (Layer 3b, #147).
ra8_err_t ra8_tile_cache_get(ra8_tile_cache_t *tc, const ra8_tile_key_t *key, ra8_tile_t *out_tile)
Get (and pin) the decoded tile for key.
ra8_err_t ra8_tile_cache_put(ra8_tile_cache_t *tc, const uint8_t *pixels)
Release one pin on a tile previously returned by ra8_tile_cache_get.
ra8_err_t ra8_tile_cache_init(ra8_tile_cache_t *tc, const ra8_tile_cache_cfg_t *cfg)
Initialise a tile cache over caller-supplied storage.
One comic tile reader: owned tile cache, atlas store, bound page.
bool bound
True while a page atlas is imported.
uint32_t scratch_cap
Capacity of scratch.
uint32_t epoch
Import counter; the tile-cache key id.
uint8_t * scratch
Stored-tile staging for deflate atlases.
jof_memstore_t store
Atlas backing for the bound page.
ra8_tile_cache_t cache
Owned tile cache (decode wired to this).
jof_info_t info
Parsed geometry of the bound page.
Import-time transcode knobs, work arena, and destination atlas store.
uint8_t codec
jof_codec_t member.
uint16_t tile_w
Tile width, pixels (>= 1).
uint8_t * atlas
Atlas memstore backing (out-lives tile fetch).
uint16_t max_width
Width budget cap (0 = format cap).
size_t atlas_cap
Capacity of atlas in bytes.
uint16_t tile_h
Tile height, pixels (>= 1).
uint8_t * webp_work
WebP whole-frame arena, or NULL to reject WebP.
size_t work_cap
Arena size (jof_work_bytes()).
uint16_t max_height
Height budget cap (0 = format cap).
size_t webp_work_cap
WebP arena size (jof_webp_work_bytes()).
Parsed + validated geometry of one JOF atlas.
uint16_t tile_rows
Ceil(height / tile_h) tile rows.
uint16_t tile_cols
Ceil(width / tile_w) tile columns.
Append-only memory store: the simplest atlas backing (RAM/SDRAM).
size_t len
Bytes appended so far (see sink).
Producer configuration: source, sink, tile geometry and work arena.
Caller-supplied storage + decoder for ra8_tile_cache_init.
ra8_tile_decode_fn decode
Decode-on-miss callback.
void * decode_ctx
Opaque context passed to decode.
Identifies one decoded image tile.
uint16_t tile_y
Tile row index (in tile units).
uint16_t tile_x
Tile column index (in tile units).
A pinned view of a cached tile returned by ra8_tile_cache_get.