Loading...
Searching...
No Matches
lwir_container.c
Go to the documentation of this file.
91 const size_t limit = index == 9 ? sizeof(fields->value.boot_id) : sizeof(fields->value.frame_sha256);
92 if (!length || length >= limit || (index == 10 && (length != 64 || strspn(value, "0123456789abcdef") != 64))) return false;
93 for (size_t character = 0; character <= length; ++character) output[character] = value[character];
140 /* Quarter-turn rotation swaps display axes, so either native maximum may be the display width. */
141 const unsigned display_limit = LWIR_MAX_WIDTH > LWIR_MAX_HEIGHT ? LWIR_MAX_WIDTH : LWIR_MAX_HEIGHT;
147 if (valid) valid = fread(soi, 1, sizeof(soi), input) == sizeof(soi) && soi[0] == 0xff && soi[1] == 0xd8;
169 if (segment_length < 2 || segment_length - 2 > sizeof(marker_payload)) { valid = false; break; }
175 const bool is_synthetic = !memcmp(marker_payload, LWIR_THERMAL_SYNTHETIC_SIGNATURE, LWIR_THERMAL_SIGNATURE_BYTES);
176 const bool is_sensor = !memcmp(marker_payload, LWIR_THERMAL_SENSOR_SIGNATURE, LWIR_THERMAL_SIGNATURE_BYTES);
184 if (!marker_width || !marker_height || marker_width > LWIR_MAX_WIDTH || marker_height > LWIR_MAX_HEIGHT) {
208 if (found_geometry || !ini_parse((char *)marker_payload + 9, payload_size - 9, geometry_field, &fields)) {
225 if (fstat(fileno(input), &after) != 0 || before.st_dev != after.st_dev || before.st_ino != after.st_ino
261 int status = read_temperature_stream(input, destination, capacity, &width, &height, &synthetic, &result);
Allocation-free flat key=value mechanics; callers own schemas and storage.
static bool ini_uint(const char *text, uint64_t *number)
Parse digits-only uint64; overflow and signs are rejected.
Definition bounded_ini.h:52
static bool ini_parse(char *buffer, size_t length, ini_field_handler handler, void *context)
Destructively parse flat fields with blank lines and #/; comment lines.
Definition bounded_ini.h:132
Bounded C11 EXIF metadata and JPEG streaming interfaces.
int exif_jpeg_dimensions(FILE *input, uint32_t *width, uint32_t *height, unsigned *components)
Inspect the frame header without allocating or decoding image pixels.
Definition exifite.c:1309
int lwir_read_temperature_layer(const char *filename, uint8_t *destination, size_t capacity, unsigned *width, unsigned *height, bool *synthetic)
Open filename safely and read the layer only; see lwir_container.h.
Definition lwir_container.c:272
static int read_temperature_stream(FILE *input, uint8_t *destination, size_t capacity, unsigned *width, unsigned *height, bool *synthetic, struct lwir_saved_geometry *geometry)
Walk JPEG markers, reassemble the APP15 plane and optionally check APP14.
Definition lwir_container.c:128
int lwir_read_temperature_stream(FILE *input, uint8_t *destination, size_t capacity, unsigned *width, unsigned *height, bool *synthetic)
Public stream reader without geometry; see lwir_container.h.
Definition lwir_container.c:239
int lwir_read_temperature_evidence(const char *filename, uint8_t *destination, size_t capacity, struct lwir_saved_geometry *geometry)
Open filename safely and read layer plus geometry; see lwir_container.h.
Definition lwir_container.c:250
static bool geometry_field(void *context, const char *key, const char *value)
ini_parse() callback that extracts the eleven geometry keys.
Definition lwir_container.c:72
static uint32_t read_u32_le(const uint8_t *bytes)
Decode a little-endian uint32 from four bytes.
Definition lwir_container.c:48
Exact thermal evidence in JPEG containers, independent of analysis.
#define LWIR_THERMAL_SENSOR_SIGNATURE
Signature of a temperature plane read from the live camera.
Definition lwir_container.h:67
#define LWIR_THERMAL_SYNTHETIC_SIGNATURE
Signature of a temperature plane produced by synthetic replay.
Definition lwir_container.h:69
Native frame arithmetic and camera measurements; no codec or flight dependencies.
uint8_t marker[LWIR_THERMAL_HEADER_BYTES+LWIR_THERMAL_CHUNK_CAPACITY]
Definition lwir_image.c:62
Accumulator for the INI callback over the APP14 provenance text.
Definition lwir_container.c:55
Native geometry and identity recovered from the APP14 "LWIREV02" text.
Definition lwir_container.h:80