diff options
Diffstat (limited to 'src/common/timing.c')
| -rw-r--r-- | src/common/timing.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/common/timing.c b/src/common/timing.c index b5e342f..3e3a705 100644 --- a/src/common/timing.c +++ b/src/common/timing.c @@ -5,8 +5,8 @@ uint64_t yasl_clock_extend_ms(uint32_t ms, uint64_t now_ns) uint64_t now_ms = now_ns / 1000000; int64_t ahead = (int32_t)(ms - (uint32_t)now_ms); if (ahead < 0 && (uint64_t)-ahead > now_ms) - return (uint64_t)ms * 1000000; - return (now_ms + (uint64_t)ahead) * 1000000; + return (uint64_t)ms * 1000000ull; + return (uint64_t)((int64_t)now_ms + ahead) * 1000000ull; } void yasl_clock_presented(struct yasl_frame_clock *c, uint64_t now, bool sample) @@ -45,9 +45,8 @@ double yasl_clock_refresh_ms(const struct yasl_frame_clock *c) uint64_t yasl_clock_next_present_ns(const struct yasl_frame_clock *c) { - return c->last_present_ns - ? c->last_present_ns + (uint64_t)c->refresh_ns - : 0; + uint64_t next = c->last_present_ns + (uint64_t)c->refresh_ns; + return (uint64_t)-(c->last_present_ns != 0) & next; } uint64_t yasl_clock_frame_timestamp_ns(struct yasl_frame_clock *c, uint64_t now) |
