Exact thermal evidence in JPEG containers, independent of analysis. More...
#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <stdio.h>

Go to the source code of this file.
Data Structures | |
| struct | lwir_saved_geometry |
| Native geometry and identity recovered from the APP14 "LWIREV02" text. More... | |
Macros | |
| #define | LWIR_THERMAL_SENSOR_SIGNATURE "LWIRRAW1" |
| Signature of a temperature plane read from the live camera. | |
| #define | LWIR_THERMAL_SYNTHETIC_SIGNATURE "LWIRSIM1" |
| Signature of a temperature plane produced by synthetic replay. | |
Enumerations | |
| enum | lwir_thermal_layout { LWIR_THERMAL_APP_MARKER = 0xef , LWIR_THERMAL_SIGNATURE_BYTES = 8 , LWIR_THERMAL_WIDTH_OFFSET = 8 , LWIR_THERMAL_HEIGHT_OFFSET = 12 , LWIR_THERMAL_DATA_OFFSET = 16 , LWIR_THERMAL_HEADER_BYTES = 20 , LWIR_THERMAL_CHUNK_CAPACITY = 65000 } |
| Existing APP15 wire layout, shared by the reader and image writer. More... | |
Functions | |
| int | lwir_read_temperature_evidence (const char *filename, uint8_t *destination, size_t capacity, struct lwir_saved_geometry *geometry) |
| Extract the temperature plane plus its recorded provenance geometry. | |
| int | lwir_read_temperature_layer (const char *filename, uint8_t *destination, size_t capacity, unsigned *width, unsigned *height, bool *synthetic) |
| Extract native little-endian Kelvin*64 samples without decoding pixels. | |
| int | lwir_read_temperature_stream (FILE *input, uint8_t *destination, size_t capacity, unsigned *width, unsigned *height, bool *synthetic) |
| Extract thermal evidence from an already-open regular JPEG stream. | |
Detailed Description
Exact thermal evidence in JPEG containers, independent of analysis.
Read side of the format written by lwir_image.c. A saved LWIR JPEG keeps the native temperature plane, little-endian Kelvin*64 per sample, in APP15 chunks signed "LWIRRAW1" (live camera) or "LWIRSIM1" (synthetic replay). Because those bytes bypass the lossy DCT path, temperatures read back here are bit-identical to the captured plane at any JPEG quality.
Used after capture by analysis, geolocation and validation tools that need temperatures from a stored photo. Only marker segments up to the first scan are parsed; compressed pixels are never decoded.
Invariants enforced by the reader:
- Chunks share one signature kind and one width/height, and their offsets are contiguous from zero; the layer must be complete.
- Native dimensions are independent of display orientation.
- The file must be a regular file that does not change while being read.
- Image-only JPEGs (TDK layout) have no layer: the layer/stream readers return 0 for them.
Definition in file lwir_container.h.
Macro Definition Documentation
◆ LWIR_THERMAL_SENSOR_SIGNATURE
| #define LWIR_THERMAL_SENSOR_SIGNATURE "LWIRRAW1" |
Signature of a temperature plane read from the live camera.
Definition at line 67 of file lwir_container.h.
◆ LWIR_THERMAL_SYNTHETIC_SIGNATURE
| #define LWIR_THERMAL_SYNTHETIC_SIGNATURE "LWIRSIM1" |
Signature of a temperature plane produced by synthetic replay.
Definition at line 69 of file lwir_container.h.
Enumeration Type Documentation
◆ lwir_thermal_layout
| enum lwir_thermal_layout |
Existing APP15 wire layout, shared by the reader and image writer.
The eight-byte signature is followed by little-endian uint32 width, height and byte offset into the native temperature plane. Samples start at byte 20. Chunk capacity is the writer's policy, not a reader acceptance limit.
Definition at line 56 of file lwir_container.h.
Function Documentation
◆ lwir_read_temperature_evidence()
| int lwir_read_temperature_evidence | ( | const char * | filename, |
| uint8_t * | destination, | ||
| size_t | capacity, | ||
| struct lwir_saved_geometry * | geometry ) |
Extract the temperature plane plus its recorded provenance geometry.
- Parameters
-
filename Regular JPEG path; symlinks are refused (O_NOFOLLOW). destination Caller-owned sample storage; ignore on failure. capacity Writable bytes in destination. geometry Written only on a complete, consistent result.
- Returns
- 1 for a complete layer with matching APP14 evidence, otherwise -1 (invalid input, missing or duplicate APP14 evidence, any inconsistency, or I/O failure).
Stricter than lwir_read_temperature_layer(): exactly one LWIREV02 record with all eleven geometry keys must be present; its native size must equal the layer, its source must match the signature kind, and the JPEG dimensions must equal the native size after the recorded rotation.
- Note
- Never returns 0: without a layer the geometry cross-checks cannot pass, so image-only or layer-less JPEGs report -1 here.
Extract the temperature plane plus its recorded provenance geometry.
O_NOFOLLOW refuses a symlinked final component; O_NONBLOCK keeps a FIFO from blocking the open so the regular-file check can reject it. Results go through locals and are copied out only on success.
Definition at line 250 of file lwir_container.c.
◆ lwir_read_temperature_layer()
| int lwir_read_temperature_layer | ( | const char * | filename, |
| uint8_t * | destination, | ||
| size_t | capacity, | ||
| unsigned * | width, | ||
| unsigned * | height, | ||
| bool * | synthetic ) |
Extract native little-endian Kelvin*64 samples without decoding pixels.
- Parameters
-
filename Regular JPEG containing LWIRRAW1 or LWIRSIM1 APP15 chunks. destination Caller-owned temperature storage; no intermediate plane is kept. capacity Writable bytes in destination. width Native thermal width, written only when a complete layer is found. height Native thermal height, independent of JPEG display orientation. synthetic True for simulated evidence, written only on success.
- Returns
- 1 for a complete layer, 0 when absent, -1 for invalid input or I/O failure.
- Warning
- Ignore destination on failure; a partial layer may have been written.
Chunk order, dimensions, provenance and file stability are checked. This validates the container header, not the compressed display's pixel content.
Extract native little-endian Kelvin*64 samples without decoding pixels.
Same open flags as lwir_read_temperature_evidence(). Outputs are written only when the result is 1 and the stream closed cleanly.
Definition at line 272 of file lwir_container.c.
◆ lwir_read_temperature_stream()
| int lwir_read_temperature_stream | ( | FILE * | input, |
| uint8_t * | destination, | ||
| size_t | capacity, | ||
| unsigned * | width, | ||
| unsigned * | height, | ||
| bool * | synthetic ) |
Extract thermal evidence from an already-open regular JPEG stream.
- Parameters
-
input Borrowed seekable stream; rewound to SOI, never closed here. destination Caller-owned sample storage; ignore on failure. capacity Available writable bytes. width Native width, written on success only. height Native height, written on success only. synthetic Native versus simulated evidence, written on success only.
- Returns
- Same 1/0/-1 contract as lwir_read_temperature_layer.
Reusing an owned stream avoids reopening a path after identity checks.
Extract thermal evidence from an already-open regular JPEG stream.
Definition at line 239 of file lwir_container.c.