From 4cc98d7937de1d3594209e34136515619a6b87f8 Mon Sep 17 00:00:00 2001 From: Johns Date: Mon, 5 Mar 2012 17:34:10 +0100 Subject: Move time-stamp printing to misc.h. --- misc.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'misc.h') diff --git a/misc.h b/misc.h index 1cfa88d..5e32e39 100644 --- a/misc.h +++ b/misc.h @@ -107,6 +107,31 @@ static inline void Syslog(const int level, const char *format, ...) #define Debug(level, fmt...) /* disabled */ #endif +#ifdef AV_NOPTS_VALUE + +/** +** Nice time-stamp string. +** +** @param ts dvb time stamp +*/ +static inline const char *Timestamp2String(int64_t ts) +{ + static char buf[4][16]; + static int idx; + + if (ts == (int64_t) AV_NOPTS_VALUE) { + return "--:--:--.---"; + } + idx = (idx + 1) % 3; + snprintf(buf[idx], sizeof(buf[idx]), "%2d:%02d:%02d.%03d", + (int)(ts / (90 * 3600000)), (int)((ts / (90 * 60000)) % 60), + (int)((ts / (90 * 1000)) % 60), (int)((ts / 90) % 1000)); + + return buf[idx]; +} + +#endif + /** ** Get ticks in ms. ** -- cgit v1.2.3