C implementation of frame-clock conversion and capture EXIF setup. More...
#include "usher_frame_timing.h"#include "boot_id.h"#include "sensor_capture.h"#include <sys/types.h>#include <time.h>#include <unistd.h>
Go to the source code of this file.
Macros | |
| #define | _POSIX_C_SOURCE 200809L |
Enumerations | |
| enum | { maximum_exposure_us = 100000 , maximum_frame_duration_us = 200000 , maximum_clock_sample_ns = 1000000 , maximum_sensor_age_ns = 500000000 , unqualified_time_error_us = 100001 } |
Functions | |
| static bool | timespec_to_nanoseconds (const struct timespec *value, uint64_t *result) |
| Convert a validated POSIX clock sample to nanoseconds without overflow. | |
| struct usher_frame_timing | usher_frame_timing_estimate (uint64_t sequence, uint64_t sensor_ns, int64_t exposure_us, int64_t duration_us) |
| Translate fresh sensor evidence into a cautious pose-alignment time. | |
| bool | usher_frame_document (const struct usher_frame_timing *timing, unsigned width, unsigned height, struct exif_document *document) |
| Initialize capture EXIF for the JPEG encoded from this exposure. | |
Detailed Description
C implementation of frame-clock conversion and capture EXIF setup.
Sampling MONOTONIC on both sides of BOOTTIME bounds offset-read latency. Implausible sensor age, duration or sampling cost leaves the original evidence available but keeps its alignment timestamp explicitly unqualified.
Definition in file usher_frame_timing.c.
Macro Definition Documentation
◆ _POSIX_C_SOURCE
| #define _POSIX_C_SOURCE 200809L |
Definition at line 20 of file usher_frame_timing.c.
Enumeration Type Documentation
◆ anonymous enum
| anonymous enum |
| Enumerator | |
|---|---|
| maximum_exposure_us | |
| maximum_frame_duration_us | |
| maximum_clock_sample_ns | |
| maximum_sensor_age_ns | |
| unqualified_time_error_us | |
Definition at line 38 of file usher_frame_timing.c.
Function Documentation
◆ timespec_to_nanoseconds()
|
static |
Convert a validated POSIX clock sample to nanoseconds without overflow.
- Parameters
-
[in] value Clock sample returned by clock_gettime(). [out] result Nanoseconds from that clock's origin.
- Returns
- True only for normalized, nonnegative values representable in uint64_t.
- Note
- A malformed sample must invalidate alignment rather than wrap the age.
Definition at line 52 of file usher_frame_timing.c.
◆ usher_frame_document()
| bool usher_frame_document | ( | const struct usher_frame_timing * | timing, |
| unsigned | width, | ||
| unsigned | height, | ||
| struct exif_document * | document ) |
Initialize capture EXIF for the JPEG encoded from this exposure.
- Parameters
-
[in] timing Same-exposure evidence, qualified or not. width Actual encoded image width. height Actual encoded image height. [out] document Caller-owned bounded destination; previous contents are replaced.
- Returns
- False for a null argument, invalid boot identity/dimensions or failed reservation.
The capture owner may add model-specific tags before serializing one APP1 payload. No filesystem operation, sidecar or feature-sized allocation is performed here. The consumer still checks boot, dimensions and timing bounds.
- Warning
- Embedded identity is not a checksum or calibrated timing measurement.
Definition at line 114 of file usher_frame_timing.c.
◆ usher_frame_timing_estimate()
| struct usher_frame_timing usher_frame_timing_estimate | ( | uint64_t | sequence, |
| uint64_t | sensor_ns, | ||
| int64_t | exposure_us, | ||
| int64_t | duration_us ) |
Translate fresh sensor evidence into a cautious pose-alignment time.
- Parameters
-
sequence Camera sequence belonging to this exposure. sensor_ns Sensor timestamp in the local BOOTTIME domain. exposure_us Exposure duration in microseconds; accepted range 0..100000. duration_us Frame duration in microseconds; accepted range 1..200000.
- Returns
- Original evidence plus an estimated midpoint and uncertainty, or unqualified defaults when clock sampling or plausibility checks fail.
Bracketing BOOTTIME with MONOTONIC samples avoids assuming equal clock origins, including after suspend. The returned record is a value, so callers can retain it with the exact frame without allocation or shared state.
- Warning
- Sensor timestamps must follow BOOTTIME. Frame duration is not a measured rolling-shutter readout time; this estimate alone proves neither shutter synchronization nor geolocation accuracy.
Definition at line 67 of file usher_frame_timing.c.