24typedef enum : uint8_t {
77 const uint8_t* pixels,
78 uint16_t source_width,
79 uint16_t source_height,
81 int32_t destination_x,
82 int32_t destination_y)
85 const int32_t target_width = (int32_t)reader->
rt_w;
86 const int32_t target_height = (int32_t)reader->
rt_h;
87 for (int32_t row = 0; row < (int32_t)source_height; ++row) {
88 const int32_t y = destination_y + row;
89 if ((y < 0) || (y >= target_height)) {
92 for (int32_t column = 0; column < (int32_t)source_width; ++column) {
93 const int32_t x = destination_x + column + reader->
jof.
x_off;
94 if ((x < 0) || (x >= target_width)) {
97 const size_t source_index =
98 (((size_t)row * (size_t)source_width) + (size_t)column) * (
size_t)bpp;
99 const size_t target_index = ((size_t)y * (size_t)target_width) + (
size_t)x;
126 .cell_mem = jof->
cells,
127 .cell_bytes = (uint32_t)band_bytes,
135 .decode_ctx = &jof->
dctx,
145 .pread_ctx = &reader->
file,
147 .cache = &jof->
cache,
176 const uint32_t remaining = (canvas > top) ? (canvas - top) : 0U;
197 if ((error ==
k_ra8_ok) && (band == 0U)) {
225 ((int32_t)reader->
rt_w > strip_width) ? (((int32_t)reader->
rt_w - strip_width) / 2) : 0;
228 (
size_t)reader->
rt_w * (
size_t)reader->
rt_h *
sizeof(*reader->
fb));
245 const uint32_t native_width = reader->
tile_wpx[index];
246 const uint32_t native_height = reader->
tile_hpx[index];
247 const size_t required = (size_t)native_width * (
size_t)native_height *
sizeof(*pixels);
248 if ((native_width == 0U) || (native_height == 0U) || (pixel_bytes < required)) {
251 reader->
rt565 = pixels;
252 reader->
rt_w = native_width;
253 reader->
rt_h = native_height;
265 *width = native_width;
266 *height = native_height;
276 for (uint32_t index = 0U; index < count; ++index) {
277 const uint32_t top = index * viewport;
278 uint32_t height = (canvas > top) ? (canvas - top) : 0U;
279 if (height > viewport) {
JOF band-tile atlas: the display-native normalized image format (#231, shared with the longstrip scro...
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.
@ k_jof_codec_raw
Tile stream is the packed pixels.
uint32_t jof_stored_bound(uint32_t raw_bytes)
Worst-case stored-tile byte bound for scratch/cell sizing.
Continuous vertical-scroll (longstrip / manhwa) reading mode over an JOF band-tile atlas (#289).
ra8_err_t longstrip_tile_decode(void *ctx, const ra8_tile_key_t *key, uint8_t *cell, uint32_t cell_bytes, uint16_t *out_w, uint16_t *out_h)
JOF-backed ra8_tile_decode_fn: page one band in on a cache miss.
ra8_err_t longstrip_scroll_by(longstrip_t *wt, int32_t delta)
Scroll by a signed pixel delta (a finger drag), clamping at the ends.
ra8_err_t longstrip_render(longstrip_t *wt, longstrip_render_stats_t *stats)
Composite every visible band at the current scroll position.
ra8_err_t longstrip_set_viewport(longstrip_t *wt, uint16_t viewport_w, uint16_t viewport_h)
Resize the viewport of an open strip and re-derive the scroll clamp.
ra8_err_t longstrip_open(longstrip_t *wt, const longstrip_cfg_t *cfg)
Open a longstrip strip over a parsed + validated JOF atlas.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Unified decompression-limits policy: one bound set for every decoder.
ra8_decomp_limits_t ra8_decomp_limits_default(void)
The owner-approved default decompression policy.
ra8_err_t ra8_decomp_check_declared(const ra8_decomp_limits_t *limits, uint64_t comp_size, uint64_t out_size)
Header-level check of a member's declared sizes against a policy.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_out_of_range
Sensor or peripheral output out of valid range.
@ 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.
Fixed-RAM-budget image-tile cache with LRU eviction (Layer 3b, #147).
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.
static ra8_err_t internal_seek(viewer_jof_t *jof, uint32_t page)
Seek to a viewport, including the short final page.
static ra8_err_t internal_jof_blit(void *ctx, const uint8_t *pixels, uint16_t source_width, uint16_t source_height, uint8_t bpp, int32_t destination_x, int32_t destination_y)
Composite one decoded band window into the active RGB565 target.
viewer_pixel_t
Supported source pixel widths and channel indices.
@ k_viewer_px_r
Red, gray, or RGB565 low byte.
@ k_viewer_bpp_gray
8-bit grayscale.
@ k_viewer_px_b
Blue byte.
@ k_viewer_bpp_rgb565
Little-endian RGB565.
@ k_viewer_px_g
Green or RGB565 high byte.
static uint16_t internal_band_pixel(const uint8_t *source, uint8_t bpp)
Convert one source pixel to native RGB565.
void priv_viewer_size_jof_tiles(ra8_viewer_reader_t *reader, uint32_t count)
Populate native tile dimensions after the strip opens.
ra8_err_t priv_viewer_tile_jof(ra8_viewer_reader_t *reader, uint32_t index, uint16_t *pixels, size_t pixel_bytes, uint32_t *width, uint32_t *height)
Render one JOF viewport into caller-owned RGB565 output.
ra8_err_t priv_viewer_open_jof(ra8_viewer_reader_t *reader)
Open and wire the JOF engine over a bound reader.
static ra8_err_t internal_wire(ra8_viewer_reader_t *reader, size_t band_bytes)
Wire the one-cell cache and long-strip engine.
ra8_err_t priv_viewer_render_jof(ra8_viewer_reader_t *reader, uint32_t page)
Render one JOF viewport into the fixed framebuffer.
Caller-owned host JOF/comic reader and RGB565 render surface.
@ k_ra8_viewer_fb_height
Framebuffer height in pixels.
@ k_ra8_viewer_fb_width
Framebuffer width in pixels.
uint16_t ra8_viewer_pack565(uint8_t rr, uint8_t gg, uint8_t bb)
Pack 8-bit RGB channels into one RGB565 word.
struct ra8_viewer_reader ra8_viewer_reader_t
Opaque state bound inside caller-owned workspace.
uint16_t ra8_viewer_pack565_le_pair(uint8_t low, uint8_t high)
Reassemble one little-endian RGB565 word.
Cross-translation-unit state for the bounded JOF/comic viewer.
ra8_err_t priv_viewer_pread(void *ctx, uint64_t offset, uint8_t *buffer, size_t length, size_t *out_read)
JOF positional-reader seam over viewer_file_ctx_t.
@ k_viewer_white_byte
Byte fill for white RGB565.
@ k_viewer_jof_buckets
Power-of-two cache bucket count.
@ k_viewer_jof_cells
One decoded band resident.
uint8_t bpp
Bytes per pixel (1, 3 or 4).
uint8_t codec
jof_codec_t member.
uint16_t tile_w
Tile width, pixels.
uint16_t width
Image width, pixels.
uint16_t tile_h
Tile height, pixels.
uint16_t height
Image height, pixels.
One-shot configuration handed to longstrip_open.
uint8_t * scratch
Deflate staging (codec 1 only).
void * pread_ctx
Context for pread.
jof_pread_fn pread
Atlas backing read seam.
jof_info_t info
Parsed atlas geometry.
uint32_t scratch_cap
Capacity of scratch.
Per-frame render accounting returned by longstrip_render.
int32_t scroll_y
Viewport top on the canvas, clamped.
One decompression policy: the five resource bounds decoders enforce.
Caller-supplied storage + decoder for ra8_tile_cache_init.
uint32_t * tile_hpx
Native height per viewport tile.
uint32_t * tile_wpx
Native width per viewport tile.
uint16_t * rt565
Current composite target.
viewer_jof_t jof
JOF engine and caller-bound cache.
uint32_t rt_w
Current target width.
uint16_t * fb
Fixed headless framebuffer.
viewer_file_ctx_t file
Raw source descriptor.
uint32_t rt_h
Current target height.
uint64_t size
Document length in bytes.
Caller-bound JOF engine and one-band cache backing.
size_t scratch_cap
Bound compressed staging bytes.
longstrip_t strip
Scroll/composite engine.
uint8_t * scratch
Compressed-band staging.
uint32_t viewport_h
Page height on the strip.
longstrip_decode_ctx_t dctx
JOF decoder callback state.
ra8_tile_dims_t * dims
Single cache dimensions entry.
ra8_tile_cache_t cache
One-band keyed cache.
uint8_t * cells
One decoded-band buffer.
ra8_tile_key_t * keys
Single cache key.
int32_t * buckets
Hash bucket heads.
ra8_keycache_cell_t * meta
Single cache metadata entry.
size_t cell_cap
Bound decoded-band bytes.
int32_t x_off
Horizontal target centring.