]> git.vomp.tv Git - vompclient.git/commitdiff
HMSF struct. Draw end bar clock by frames
authorChris Tallon <chris@vomp.tv>
Sun, 11 Jun 2006 15:52:59 +0000 (15:52 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 11 Jun 2006 15:52:59 +0000 (15:52 +0000)
player.cc
player.h
video.cc
video.h
vvideorec.cc

index bd7585de9fba6362b54249b5a6ca40383e9066ff..2409bbad99811e7620d218167987bc66e4a831ca 100644 (file)
--- 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;
index 915b0db8ccd6bfbb1059009ab20bcf5d13eb618f..23a79e3a40c31d89a4832f873b1b7a527c16804b 100644 (file)
--- 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
 
index 7d3ad02102b1914d5e1c0b522053eb3ae62cad92..d01bbf110dfa563a666b64caaabc2f7029238330 100644 (file)
--- 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 dbb20d52a51fd6dd3ffab3ab337b5129d3ecb11c..7f54b958b2597a29ffecbb42b40c945f14d7047e 100644 (file)
--- a/video.h
+++ b/video.h
 #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;
index 5f3eb47a5d77a884ee5ce1b6a3de3d4275c5d724..6c5b9e44c82f7c7ce8fa55da07efcb24a3506bbb 100644 (file)
@@ -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);