]> git.vomp.tv Git - vompclient-marten.git/commitdiff
*** empty log message ***
authorChris Tallon <chris@vomp.tv>
Sun, 19 Nov 2006 15:50:00 +0000 (15:50 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 19 Nov 2006 15:50:00 +0000 (15:50 +0000)
command.cc
vvideolive.cc
vvideorec.cc
wwss.cc
wwss.h

index 2cbdeb586b8cd598516ebf82cdca891b52b7c29d..2eced78551619ee9ddc4b3a49a7a9b3dad7fea72 100644 (file)
@@ -127,11 +127,14 @@ void Command::run()
   doWallpaper();
 
   // End of startup. Lock the mutex and put the first view up
+//  logger->log("Command", Log::DEBUG, "WANT LOCK");
 #ifndef WIN32
   pthread_mutex_lock(&masterLock);
 #else
   WaitForSingleObject(masterLock, INFINITE );
 #endif
+  //logger->log("Command", Log::DEBUG, "LOCKED");
+
   VConnect* vconnect = new VConnect();
   viewman->add(vconnect);
   vconnect->run();
@@ -143,6 +146,7 @@ void Command::run()
   while(irun)
   {
     // unlock and wait
+    //logger->log("Command", Log::DEBUG, "UNLOCK");
 #ifndef WIN32
     pthread_mutex_unlock(&masterLock);
 #else
@@ -151,11 +155,13 @@ void Command::run()
     button = remote->getButtonPress(2);  // FIXME why is this set to 2 and not 0? so it can quit
     // something happened, lock and process
 
+    //logger->log("Command", Log::DEBUG, "WANT LOCK");
 #ifndef WIN32
     pthread_mutex_lock(&masterLock);
 #else
     WaitForSingleObject(masterLock, INFINITE );
 #endif
+    //logger->log("Command", Log::DEBUG, "LOCK");
 
     if ((button == Remote::NA_NONE) || (button == Remote::NA_UNKNOWN)) continue;
 
@@ -163,6 +169,7 @@ void Command::run()
     processMessageQueue();
   }
 
+  //logger->log("Command", Log::DEBUG, "UNLOCK");
 #ifndef WIN32
   pthread_mutex_unlock(&masterLock);
 #else
@@ -178,11 +185,13 @@ void Command::postMessage(Message* m)
   // locking the mutex ensures that the master thread is waiting on getButtonPress
 
 
+  //logger->log("Command", Log::DEBUG, "WANT LOCK");
 #ifndef WIN32
   pthread_mutex_lock(&masterLock);
 #else
   WaitForSingleObject(masterLock, INFINITE );
 #endif
+  //logger->log("Command", Log::DEBUG, "LOCK");
   MessageQueue::postMessage(m);
 
 #ifndef WIN32
@@ -192,6 +201,7 @@ void Command::postMessage(Message* m)
   ((RemoteWin*)Remote::getInstance())->Signal();
   ReleaseMutex(masterLock);
 #endif
+  //logger->log("Command", Log::DEBUG, "UNLOCK");
 }
 
 void Command::postMessageNoLock(Message* m)
@@ -207,12 +217,15 @@ bool Command::postMessageIfNotBusy(Message* m)
   // This is for the timers module
   // If the masterlock is locked then the timers module wants to
   // cancel delivery
+  //logger->log("Command", Log::DEBUG, "TRY LOCK");
 #ifndef WIN32
   if (pthread_mutex_trylock(&masterLock) != EBUSY)
   {
+    //logger->log("Command", Log::DEBUG, "LOCK");
     MessageQueue::postMessage(m);
     kill(mainPid, SIGURG);
     pthread_mutex_unlock(&masterLock);
+    //logger->log("Command", Log::DEBUG, "UNLOCK");
     return true;
   }
   else
@@ -296,7 +309,7 @@ void Command::processMessage(Message* m)
 
     // deliver timer
 
-    logger->log("Command", Log::DEBUG, "sending timer");
+    logger->log("Command", Log::DEBUG, "sending timer to %p with parameter %u", m->to, m->parameter);
     ((TimerReceiver*)m->to)->timercall(m->parameter);
 //    handleCommand(Remote::NA_NONE); // in case any timer has posted messages to viewman,
 //                                    // run viewman message queue here. FIXME improve this!
index 51babf3212cb08923b704b764fda7a3750186541..e2ab989c536180d9e2cb63fbf0ad4fd94a412e81 100644 (file)
@@ -55,6 +55,7 @@ VVideoLive::VVideoLive(ChannelList* tchanList, ULONG tstreamType, VChannelList*
   }
   Log::getInstance()->log("VVideoLive", Log::DEBUG, "Do WSS: %u", dowss);
 
+  wss.setFormat(video->getFormat());
   wss.setSurface(surface);
   wss.setWide(true);
 
index 8e9dabcdf1e7bf6abadaea73c43b40b48e35607a..d9c44255fce912313e7e93adcaaa7db3e8102db8 100644 (file)
@@ -93,13 +93,20 @@ VVideoRec::VVideoRec(Recording* rec)
   }
   Log::getInstance()->log("VVideoRec", Log::DEBUG, "Do WSS: %u", dowss);
 
+  wss.setFormat(video->getFormat());
   wss.setSurface(surface);
   wss.setWide(true);
 
+/*
   wssRegion.x = 0;
   wssRegion.y = 6;
   wssRegion.w = video->getScreenWidth();
   wssRegion.h = 2;
+*/
+  wssRegion.x = 0;
+  wssRegion.y = 0;
+  wssRegion.w = video->getScreenWidth();
+  wssRegion.h = 300;
 }
 
 VVideoRec::~VVideoRec()
diff --git a/wwss.cc b/wwss.cc
index ed57efccbf0cde3105108df9ffcd16763f017404..9bc81d628afee4aca165632e8a7b32231268e096 100644 (file)
--- a/wwss.cc
+++ b/wwss.cc
 \r
 Wwss::Wwss()\r
 {\r
+  format = Video::NTSC;\r
 }\r
 \r
 Wwss::~Wwss()\r
 {\r
 }\r
 \r
+void Wwss::setFormat(UCHAR tformat)\r
+{\r
+  format = tformat;\r
+}\r
+\r
 UINT Wwss::gcd(UINT a, UINT b)\r
 {\r
   UINT t;\r
@@ -51,6 +57,12 @@ void Wwss::setWide(bool twide)
 }\r
 \r
 void Wwss::draw()\r
+{\r
+  if (format == Video::PAL) drawPAL();\r
+//  else if (format == Video::NTSC) drawNTSC();\r
+}\r
+\r
+void Wwss::drawPAL()\r
 {\r
   // The aspect43 and aspect169 codes are not what they should be according to the docs, but these are what work...\r
   // (1 = 111000, = 0 000111)\r
@@ -108,3 +120,192 @@ void Wwss::draw()
     drawPixel(q, 6, c);\r
   }\r
 }\r
+\r
+void Wwss::drawNTSC()\r
+{\r
+  static UCHAR startCode[] = {1,0};\r
+  static UCHAR aspect43[]  = {0,0};\r
+  static UCHAR aspect169[] = {1,0};\r
+  static UCHAR theRest[]   = {0,0,0,0,0,0,0,0,0,0,0,0};\r
+  static UCHAR crc43[]     = {0,0,0,0,0,0};\r
+  static UCHAR crc169[]    = {1,0,0,1,0,1};\r
+\r
+  /*\r
+  Real NTSC pixel frequency: 13.5 MHz\r
+  WSS bit frequency: 447.443125 kHz\r
+  = 30.1714 NTSC pixels per wss bit\r
+  * 22 wss bits = 663.7715 NTSC pixels (total code width) (round to 664..)\r
+\r
+  There is also a 11.2us gap at the start of the pal raster, but since I don't really have any\r
+  idea where our 720 pixels start in the raster I can't calculate an offset.\r
+\r
+  PAL line 23 seems to be MVP line 6.\r
+  */\r
+\r
+  const UINT   Ns = 22;            // Num pix src\r
+  const UINT   Nd = 664;           // Num pix dst\r
+  UINT         Nl = lcm(Ns, Nd);   // Num pix in lcm\r
+  UINT         Ss = Nl / Ns;       // Source split (how many lcm px = 1 src px)\r
+  UINT         Sd = Nl / Nd;       // Dst split\r
+  UCHAR src[Ns];\r
+\r
+  memcpy(&src[0], startCode, 2);\r
+  if (wide) memcpy(&src[2], aspect169, 2);\r
+  else      memcpy(&src[2], aspect43, 2);\r
+  memcpy(&src[4], theRest, 12);\r
+  if (wide) memcpy(&src[16], crc169, 6);\r
+  else      memcpy(&src[16], crc43, 6);\r
+\r
+  float dst[Nd];\r
+  UINT lcmpxbase = 0;\r
+\r
+  for(UINT t = 0; t < Nd; t++) // for every destination pixel\r
+  {\r
+    dst[t] = 0;\r
+    for(UINT lcmpx = lcmpxbase; lcmpx < (lcmpxbase + Sd); lcmpx++)\r
+    {\r
+      if (src[lcmpx / Ss]) dst[t] += (float)1/Sd;\r
+    }\r
+    lcmpxbase += Sd;\r
+  }\r
+\r
+  Colour c;\r
+  UINT value;\r
+\r
+/*\r
+  for(UINT q = 0; q < Nd; q++)\r
+  {\r
+    value = (UINT)(dst[q] * 182); // Apparently this is a better number than 255 for the colour value\r
+    c.set(value, value, value);\r
+    drawPixel(q, 6, c);\r
+  }\r
+*/\r
+\r
+for(int yy = 0; yy < 100; yy++)\r
+{\r
+  for(UINT q = 0; q < Nd; q++)\r
+  {\r
+    value = (UINT)(dst[q] * 182); // Apparently this is a better number than 255 for the colour value\r
+    c.set(value, value, value);\r
+    drawPixel(q+20, yy, c);\r
+  }\r
+}\r
+\r
+\r
+\r
+}\r
+\r
+/*\r
+x6 + x + 1\r
+\r
+1x6 + 0x5 + 0x4 + 0x3 + 0x2 + 1x1 + 1x0\r
+=\r
+1      0     0     0     0     1     1\r
+=\r
+1000011\r
+key width = 6\r
+\r
+static UCHAR startCode[] = {1,0};\r
+static UCHAR aspect43[]  = {0,0};\r
+static UCHAR aspect169[] = {1,0};\r
+static UCHAR theRest[]   = {0,0,0,0,0,0,0,0,0,0,0,0};\r
+static UCHAR crc43[]     = {0,0,0,0,0,0};\r
+static UCHAR crc169[]    = {1,0,0,1,0,1};\r
+\r
+Message 4:3\r
+\r
+1000000000000000\r
+\r
+Message 4:3 augmented\r
+\r
+1000000000000000000000\r
+\r
+Key\r
+\r
+1000011\r
+\r
+\r
+Ho ho, polynomial long division. Yeeeeaaahhh I remember\r
+doing *that*. Of course I do. If you know of a faster,\r
+easier, more reliable way of doing this, please let me know.\r
+\r
+\r
+                 100\r
+         ________________________\r
+1000011  ) 1000000000000000000000\r
+           1000011\r
+           -------\r
+            0000110\r
+            0000000\r
+            -------\r
+             0001100\r
+\r
+\r
+\r
+\r
+\r
+\r
+Message 16:9\r
+\r
+1010000000000000\r
+\r
+Message 4:3 augmented\r
+\r
+1010000000000000000000\r
+\r
+Key\r
+\r
+1000011\r
+\r
+                 1010011110100011\r
+         ________________________\r
+1000011  ) 1010000000000000000000\r
+           1000011\r
+            -------\r
+            0100110\r
+            0000000\r
+             -------\r
+             1001100\r
+             1000011\r
+              -------\r
+              0011110\r
+              0000000\r
+               -------\r
+               0111100\r
+               0000000\r
+                -------\r
+                1111000\r
+                1000011\r
+                 -------\r
+                 1110110\r
+                 1000011\r
+                  -------\r
+                  1101010\r
+                  1000011\r
+                   -------\r
+                   1010010\r
+                   1000011\r
+                    -------\r
+                    0100010\r
+                    0000000\r
+                     -------\r
+                     1000100\r
+                     1000011\r
+                      -------\r
+                      0001110\r
+                      0000000\r
+                       -------\r
+                       0011100\r
+                       0000000\r
+                        -------\r
+                        0111000\r
+                        0000000\r
+                         -------\r
+                         1110000\r
+                         1000011\r
+                          -------\r
+                          1100110\r
+                          1000011\r
+                          -------\r
+                           100101\r
+*/\r
diff --git a/wwss.h b/wwss.h
index 606f12def41c9b5b66073fafbaceea3fa2bad656..feff7a85e745f5402f36fc2a48233e7ac8f977d1 100644 (file)
--- a/wwss.h
+++ b/wwss.h
@@ -27,6 +27,7 @@
 #include "defines.h"
 #include "widget.h"
 #include "colour.h"
+#include "video.h"
 
 class Wwss : public Widget
 {
@@ -35,12 +36,16 @@ class Wwss : public Widget
     ~Wwss();
     void draw();
     void setWide(bool wide);
+    void setFormat(UCHAR tformat);
 
   private:
     UINT gcd(UINT a, UINT b);
     UINT lcm(UINT a, UINT b);
+    void drawNTSC();
+    void drawPAL();
 
     bool wide;
+    UCHAR format;  // same as video - 0=NTSC,1=PAL
 };
 
 #endif