ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
jof.h
Go to the documentation of this file.
1
120
121#pragma once
122
123#ifdef __cplusplus
124extern "C" {
125#endif
126
127#include <stddef.h>
128#include <stdint.h>
129
130#include "ra8_err.h"
131
164
175typedef enum : uint32_t {
176 k_jof_max_dim = 32768U,
180
190typedef enum : uint8_t {
194
208typedef struct {
209 uint16_t width;
210 uint16_t height;
211 uint16_t tile_w;
212 uint16_t tile_h;
213 uint16_t tile_cols;
214 uint16_t tile_rows;
215 uint8_t bpp;
216 uint8_t codec;
217 uint32_t tile_count;
218 uint32_t index_off;
219 uint32_t total_size;
220} jof_info_t;
221
240typedef ra8_err_t (
241 *jof_pread_fn)(void* ctx, uint64_t offset, uint8_t* buf, size_t len, size_t* got);
242
256typedef struct {
257 uint8_t* buf;
258 size_t cap;
259 size_t len;
261
285[[nodiscard]] ra8_err_t jof_memstore_sink(void* ctx, const uint8_t* buf, size_t len);
286
311[[nodiscard]] ra8_err_t
312jof_memstore_pread(void* ctx, uint64_t offset, uint8_t* buf, size_t len, size_t* got);
313
349[[nodiscard]] ra8_err_t
350jof_parse(jof_pread_fn pread, void* pread_ctx, uint64_t total_size, jof_info_t* out_info);
351
373[[nodiscard]] ra8_err_t jof_tile_dims(const jof_info_t* info,
374 uint16_t tile_x,
375 uint16_t tile_y,
376 uint16_t* out_w,
377 uint16_t* out_h);
378
400[[nodiscard]] uint32_t jof_stored_bound(uint32_t raw_bytes);
401
448[[nodiscard]] ra8_err_t jof_read_tile(jof_pread_fn pread,
449 void* pread_ctx,
450 const jof_info_t* info,
451 uint16_t tile_x,
452 uint16_t tile_y,
453 uint8_t* scratch,
454 uint32_t scratch_cap,
455 uint8_t* out_px,
456 uint32_t out_cap,
457 uint16_t* out_w,
458 uint16_t* out_h);
459
460#ifdef __cplusplus
461}
462#endif
jof_layout_t
Fixed byte sizes and offsets of the JOF on-disk structures.
Definition jof.h:142
@ k_jof_ofs_tile_count
Header: u32 tile count.
Definition jof.h:155
@ k_jof_index_entry
Bytes per tile-index entry.
Definition jof.h:145
@ k_jof_ofs_magic
Header: magic "JOF1".
Definition jof.h:147
@ k_jof_ofs_reserved
Header: first reserved byte.
Definition jof.h:154
@ k_jof_magic_len
Magic string length (both ends).
Definition jof.h:146
@ k_jof_footer_bytes
Footer length.
Definition jof.h:144
@ k_jof_ftr_total_size
Footer: u32 total atlas size.
Definition jof.h:159
@ k_jof_hdr_bytes
Header length.
Definition jof.h:143
@ k_jof_ftr_magic
Footer: magic "JOFE".
Definition jof.h:160
@ k_jof_ftr_index_off
Footer: u32 index offset.
Definition jof.h:157
@ k_jof_ofs_reserved2
Header: second reserved run.
Definition jof.h:156
@ k_jof_ofs_tile_h
Header: u16 tile height.
Definition jof.h:151
@ k_jof_ofs_codec
Header: u8 tile codec.
Definition jof.h:153
@ k_jof_idx_ofs_length
Index entry: u32 tile length.
Definition jof.h:162
@ k_jof_ofs_height
Header: u16 image height.
Definition jof.h:149
@ k_jof_ofs_tile_w
Header: u16 tile width.
Definition jof.h:150
@ k_jof_ofs_width
Header: u16 image width.
Definition jof.h:148
@ k_jof_ftr_tile_count
Footer: u32 tile count.
Definition jof.h:158
@ k_jof_ofs_bpp
Header: u8 bytes per pixel.
Definition jof.h:152
@ k_jof_idx_ofs_offset
Index entry: u32 tile offset.
Definition jof.h:161
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).
Definition jof.c:177
jof_limits_t
Hard caps every JOF atlas must satisfy (fail-closed validation).
Definition jof.h:175
@ k_jof_bpp_max
Max bytes per pixel.
Definition jof.h:178
@ k_jof_max_dim
Max image width/height, pixels.
Definition jof.h:176
@ k_jof_max_tiles
Max tiles per atlas.
Definition jof.h:177
ra8_err_t(* jof_pread_fn)(void *ctx, uint64_t offset, uint8_t *buf, size_t len, size_t *got)
Positioned-read seam over an atlas backing store (DIP).
Definition jof.h:241
ra8_err_t jof_tile_dims(const jof_info_t *info, uint16_t tile_x, uint16_t tile_y, uint16_t *out_w, uint16_t *out_h)
Report the true (edge-clamped) pixel dimensions of one tile.
Definition jof.c:414
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.
Definition jof.c:637
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.
Definition jof.c:379
jof_codec_t
Per-atlas tile codec selector (header byte 13).
Definition jof.h:190
@ k_jof_codec_deflate
Tile stream is one raw-DEFLATE run.
Definition jof.h:192
@ k_jof_codec_raw
Tile stream is the packed pixels.
Definition jof.h:191
uint32_t jof_stored_bound(uint32_t raw_bytes)
Worst-case stored-tile byte bound for scratch/cell sizing.
Definition jof.c:439
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).
Definition jof.c:163
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Parsed + validated geometry of one JOF atlas.
Definition jof.h:208
uint8_t bpp
Bytes per pixel (1, 3 or 4).
Definition jof.h:215
uint8_t codec
jof_codec_t member.
Definition jof.h:216
uint16_t tile_w
Tile width, pixels.
Definition jof.h:211
uint16_t width
Image width, pixels.
Definition jof.h:209
uint32_t index_off
Absolute byte offset of the tile index.
Definition jof.h:218
uint16_t tile_rows
Ceil(height / tile_h) tile rows.
Definition jof.h:214
uint16_t tile_h
Tile height, pixels.
Definition jof.h:212
uint32_t tile_count
Total tiles (== cols * rows).
Definition jof.h:217
uint16_t height
Image height, pixels.
Definition jof.h:210
uint32_t total_size
Whole atlas byte length (footer included).
Definition jof.h:219
uint16_t tile_cols
Ceil(width / tile_w) tile columns.
Definition jof.h:213
Append-only memory store: the simplest atlas backing (RAM/SDRAM).
Definition jof.h:256
uint8_t * buf
Caller-owned backing bytes.
Definition jof.h:257
size_t cap
Capacity of buf.
Definition jof.h:258
size_t len
Bytes appended so far (see sink).
Definition jof.h:259