From f5e02793293af042d7064a125bb39efb0ec0644f Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 11 Jun 2006 15:52:59 +0000 Subject: [PATCH] HMSF struct. Draw end bar clock by frames --- player.cc | 5 +++++ player.h | 1 + video.cc | 25 +++++++++++++++++++++++++ video.h | 10 ++++++++++ vvideorec.cc | 14 +++++++------- 5 files changed, 48 insertions(+), 7 deletions(-) diff --git a/player.cc b/player.cc index bd7585d..2409bba 100644 --- a/player.cc +++ b/player.cc @@ -153,6 +153,11 @@ ULLONG Player::getEndTS() // used internally (jump to percent) return (ULLONG)rendTS; } +hmsf Player::getEndHMSF() +{ + return video->framesToHMSF(lengthFrames); +} + ULLONG Player::getPositionTS() // used internall (skip fw/bw) { if (startup) return 0ULL; diff --git a/player.h b/player.h index 915b0db..23a79e3 100644 --- a/player.h +++ b/player.h @@ -66,6 +66,7 @@ class Player : public Thread_TYPE, public Callback bool isFbwd() { return fbwd; } ULLONG getPositionTS(); ULLONG getEndTS(); + hmsf getEndHMSF(); void call(void*); // for callback interface diff --git a/video.cc b/video.cc index 7d3ad02..d01bbf1 100644 --- a/video.cc +++ b/video.cc @@ -49,3 +49,28 @@ Video* Video::getInstance() { return instance; } + +hmsf Video::framesToHMSF(ULONG frames) +{ + hmsf ret; + + if (format == NTSC) + { + ret.hours = frames / 108000; + frames %= 108000; + ret.minutes = frames / 1800; + frames %= 1800; + ret.seconds = frames / 30; + ret.frames = frames % 30; + } + else + { + ret.hours = frames / 90000; + frames %= 90000; + ret.minutes = frames / 1500; + frames %= 1500; + ret.seconds = frames / 25; + ret.frames = frames % 25; + } + return ret; +} diff --git a/video.h b/video.h index dbb20d5..7f54b95 100644 --- a/video.h +++ b/video.h @@ -25,6 +25,14 @@ #include "defines.h" #include "draintarget.h" +typedef struct _hmsf +{ + UINT hours; + UINT minutes; + UINT seconds; + UINT frames; +} hmsf; + class Video: public DrainTarget { public: @@ -76,6 +84,8 @@ class Video: public DrainTarget UINT getScreenHeight() { return screenHeight; } UCHAR getTVsize() { return tvsize; } + hmsf framesToHMSF(ULONG frames); + // Video formats - AV_SET_VID_DISP_FMT const static UCHAR NTSC = 0; const static UCHAR PAL = 1; diff --git a/vvideorec.cc b/vvideorec.cc index 5f3eb47..6c5b9e4 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -385,23 +385,23 @@ void VVideoRec::drawBarClocks() int cseconds = currentTS - (chours * 3600) - (cminutes * 60); ULONG endTS = (player->getEndTS() / 90000); - int ehours = endTS / 3600; - int eminutes = (endTS - (ehours * 3600)) / 60; - int eseconds = endTS - (ehours * 3600) - (eminutes * 60); +// int ehours = endTS / 3600; +// int eminutes = (endTS - (ehours * 3600)) / 60; +// int eseconds = endTS - (ehours * 3600) - (eminutes * 60); + + hmsf endHMSF = player->getEndHMSF(); char buffer[100]; if ((currentTS > 95441) // it's at the 33bit rollover point where the calc doesn't work because of the 1s diff // between demuxer values and video chip return values ... ? - || (!endTS)) // No values yet + || (!endTS) ) // No values yet { strcpy(buffer, "-:--:-- / -:--:--"); } else { - SNPRINTF(buffer, 99, "%01i:%02i:%02i / %01i:%02i:%02i", chours, cminutes, cseconds, ehours, eminutes, eseconds); + SNPRINTF(buffer, 99, "%01i:%02i:%02i / %01i:%02i:%02i", chours, cminutes, cseconds, endHMSF.hours, endHMSF.minutes, endHMSF.seconds); logger->log("VVideoRec", Log::DEBUG, buffer); - -// if (chours > 0) abort(); } drawText(buffer, clocksRegion.x, clocksRegion.y, Colour::LIGHTTEXT); -- 2.39.5