File wfm_time.h¶
FileList > inc > wfm > wfm_time.h
Go to the source code of this file
#include <stdint.h>
Public Static Functions¶
| Type | Name |
|---|---|
| int | wfm_j1950_to_unix_ns (double t_j1950, uint64_t * out_ns) |
| double | wfm_j1950_to_unix_sec (double t_j1950) |
| int | wfm_timecode_is_set (double timecode) |
| double | wfm_unix_to_j1950_sec (double t_unix) |
Macros¶
| Type | Name |
|---|---|
| define | WFM_J1950_UNIX_OFFSET_SEC 631152000.0 |
| define | WFM_TIMECODE_UNSET 0.0 |
Public Static Functions Documentation¶
function wfm_j1950_to_unix_ns¶
Convert a BLUE timecode to UNIX nanoseconds, the form dp_sample_clock_track() takes.
Fails rather than wrapping for the two cases a uint64_t cannot express: an unset timecode, and any instant before 1970. A 1950s capture is real BLUE data, so this returning nonzero is a normal answer, not an error to paper over — the caller has an epoch it simply cannot hand to the sample clock.
Note:
Nanosecond precision is not available from BLUE. The timecode is a double of seconds, so near the present its own resolution is about half a microsecond (2^-52 * 2^31). The nanosecond result is exact arithmetic on an input that is not itself nanosecond-accurate; treat the bottom three digits as padding.
Parameters:
t_j1950Seconds since 1950-01-01T00:00:00Z.out_nsReceives nanoseconds since the UNIX epoch; untouched on failure.
Returns:
0 on success, -1 if the timecode is unset or predates 1970.
function wfm_j1950_to_unix_sec¶
Convert a BLUE timecode to seconds since the UNIX epoch.
No range check: the result is simply shifted, and a pre-1970 capture is a legitimate negative. Guard with wfm_timecode_is_set first if a zero would be meaningless to the caller.
Parameters:
t_j1950Seconds since 1950-01-01T00:00:00Z.
Returns:
Seconds since 1970-01-01T00:00:00Z.
function wfm_timecode_is_set¶
Nonzero if timecode carries a real capture time.
Parameters:
timecodeRaw BLUE header timecode, J1950 seconds.
function wfm_unix_to_j1950_sec¶
Convert seconds since the UNIX epoch to a BLUE timecode.
Parameters:
t_unixSeconds since 1970-01-01T00:00:00Z.
Returns:
Seconds since 1950-01-01T00:00:00Z.
Macro Definition Documentation¶
define WFM_J1950_UNIX_OFFSET_SEC¶
Seconds from the J1950 epoch to the UNIX epoch.
20 years, of which 1952/56/60/64/68 were leap: 20*365 + 5 = 7305 days, 7305 * 86400 = 631152000.
define WFM_TIMECODE_UNSET¶
The value a BLUE header carries when nothing set a capture time.
A zero timecode is "unset", not 1950-01-01. doppler's own writer leaves the field zero (wfm_writer_core.c zeroes bytes 54-96), and so do many producers, so converting a zero straight through would date every such capture to 1950 — confidently, and wrongly. Same ambiguity wfm_fc_source_t exists to resolve for centre frequency: ask whether it was set before trusting what it says.
The documentation for this class was generated from the following file native/inc/wfm/wfm_time.h