Move time-stamp printing to misc.h.

This commit is contained in:
Johns 2012-03-05 17:34:10 +01:00
parent 3812fa8d38
commit 4cc98d7937
3 changed files with 28 additions and 31 deletions

25
misc.h
View File

@ -107,6 +107,31 @@ static inline void Syslog(const int level, const char *format, ...)
#define Debug(level, fmt...) /* disabled */ #define Debug(level, fmt...) /* disabled */
#endif #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. ** Get ticks in ms.
** **

View File

@ -43,7 +43,7 @@ extern "C"
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
static const char *const VERSION = "0.4.9" static const char *const VERSION = "0.5.0"
#ifdef GIT_REV #ifdef GIT_REV
"-GIT" GIT_REV "-GIT" GIT_REV
#endif #endif

32
video.c
View File

@ -369,34 +369,6 @@ static void VideoThreadLock(void); ///< lock video thread
static void VideoThreadUnlock(void); ///< unlock video thread static void VideoThreadUnlock(void); ///< unlock video thread
static void VideoThreadExit(void); ///< exit/kill video thread static void VideoThreadExit(void); ///< exit/kill video thread
#if defined(DEBUG) || defined(AV_INFO)
///
/// Nice time-stamp string.
///
static const char *VideoTimeStampString(int64_t ts)
{
static char buf[2][32];
static int idx;
int hh;
int mm;
int ss;
int uu;
if (ts == (int64_t) AV_NOPTS_VALUE) {
return "--:--:--.---";
}
idx ^= 1; // support two static buffers
ts = ts / 90;
uu = ts % 1000;
ss = (ts / 1000) % 60;
mm = (ts / 60000) % 60;
hh = ts / 3600000;
snprintf(buf[idx], sizeof(buf[idx]), "%2d:%02d:%02d.%03d", hh, mm, ss, uu);
return buf[idx];
}
#endif
/// ///
/// Update video pts. /// Update video pts.
/// ///
@ -4422,7 +4394,7 @@ static void VaapiSyncDisplayFrame(VaapiDecoder * decoder)
if (decoder->DupNextFrame || decoder->DropNextFrame if (decoder->DupNextFrame || decoder->DropNextFrame
|| !(decoder->FramesDisplayed % AV_INFO_TIME)) { || !(decoder->FramesDisplayed % AV_INFO_TIME)) {
Info("video: %s%+5" PRId64 " %4" PRId64 " %3d/\\ms %3d v-buf\n", Info("video: %s%+5" PRId64 " %4" PRId64 " %3d/\\ms %3d v-buf\n",
VideoTimeStampString(video_clock), Timestamp2String(video_clock),
abs((video_clock - audio_clock) / 90) < abs((video_clock - audio_clock) / 90) <
9999 ? ((video_clock - audio_clock) / 90) : 88888, 9999 ? ((video_clock - audio_clock) / 90) : 88888,
AudioGetDelay() / 90, (int)VideoDeltaPTS / 90, VideoGetBuffers()); AudioGetDelay() / 90, (int)VideoDeltaPTS / 90, VideoGetBuffers());
@ -7479,7 +7451,7 @@ static void VdpauSyncDisplayFrame(VdpauDecoder * decoder)
if (decoder->DupNextFrame || decoder->DropNextFrame if (decoder->DupNextFrame || decoder->DropNextFrame
|| !(decoder->FramesDisplayed % AV_INFO_TIME)) { || !(decoder->FramesDisplayed % AV_INFO_TIME)) {
Info("video: %s%+5" PRId64 " %4" PRId64 " %3d/\\ms %3d v-buf\n", Info("video: %s%+5" PRId64 " %4" PRId64 " %3d/\\ms %3d v-buf\n",
VideoTimeStampString(video_clock), Timestamp2String(video_clock),
abs((video_clock - audio_clock) / 90) < abs((video_clock - audio_clock) / 90) <
9999 ? ((video_clock - audio_clock) / 90) : 88888, 9999 ? ((video_clock - audio_clock) / 90) : 88888,
AudioGetDelay() / 90, (int)VideoDeltaPTS / 90, VideoGetBuffers()); AudioGetDelay() / 90, (int)VideoDeltaPTS / 90, VideoGetBuffers());