From 3cc2babe0c80453f38a9db6d20be06219f7b5cbe Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 19 Nov 2006 15:50:00 +0000 Subject: [PATCH] *** empty log message *** --- command.cc | 15 +++- vvideolive.cc | 1 + vvideorec.cc | 7 ++ wwss.cc | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++ wwss.h | 5 ++ 5 files changed, 228 insertions(+), 1 deletion(-) diff --git a/command.cc b/command.cc index 2cbdeb5..2eced78 100644 --- a/command.cc +++ b/command.cc @@ -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! diff --git a/vvideolive.cc b/vvideolive.cc index 51babf3..e2ab989 100644 --- a/vvideolive.cc +++ b/vvideolive.cc @@ -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); diff --git a/vvideorec.cc b/vvideorec.cc index 8e9dabc..d9c4425 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -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 ed57efc..9bc81d6 100644 --- a/wwss.cc +++ b/wwss.cc @@ -22,12 +22,18 @@ Wwss::Wwss() { + format = Video::NTSC; } Wwss::~Wwss() { } +void Wwss::setFormat(UCHAR tformat) +{ + format = tformat; +} + UINT Wwss::gcd(UINT a, UINT b) { UINT t; @@ -51,6 +57,12 @@ void Wwss::setWide(bool twide) } void Wwss::draw() +{ + if (format == Video::PAL) drawPAL(); +// else if (format == Video::NTSC) drawNTSC(); +} + +void Wwss::drawPAL() { // The aspect43 and aspect169 codes are not what they should be according to the docs, but these are what work... // (1 = 111000, = 0 000111) @@ -108,3 +120,192 @@ void Wwss::draw() drawPixel(q, 6, c); } } + +void Wwss::drawNTSC() +{ + static UCHAR startCode[] = {1,0}; + static UCHAR aspect43[] = {0,0}; + static UCHAR aspect169[] = {1,0}; + static UCHAR theRest[] = {0,0,0,0,0,0,0,0,0,0,0,0}; + static UCHAR crc43[] = {0,0,0,0,0,0}; + static UCHAR crc169[] = {1,0,0,1,0,1}; + + /* + Real NTSC pixel frequency: 13.5 MHz + WSS bit frequency: 447.443125 kHz + = 30.1714 NTSC pixels per wss bit + * 22 wss bits = 663.7715 NTSC pixels (total code width) (round to 664..) + + There is also a 11.2us gap at the start of the pal raster, but since I don't really have any + idea where our 720 pixels start in the raster I can't calculate an offset. + + PAL line 23 seems to be MVP line 6. + */ + + const UINT Ns = 22; // Num pix src + const UINT Nd = 664; // Num pix dst + UINT Nl = lcm(Ns, Nd); // Num pix in lcm + UINT Ss = Nl / Ns; // Source split (how many lcm px = 1 src px) + UINT Sd = Nl / Nd; // Dst split + UCHAR src[Ns]; + + memcpy(&src[0], startCode, 2); + if (wide) memcpy(&src[2], aspect169, 2); + else memcpy(&src[2], aspect43, 2); + memcpy(&src[4], theRest, 12); + if (wide) memcpy(&src[16], crc169, 6); + else memcpy(&src[16], crc43, 6); + + float dst[Nd]; + UINT lcmpxbase = 0; + + for(UINT t = 0; t < Nd; t++) // for every destination pixel + { + dst[t] = 0; + for(UINT lcmpx = lcmpxbase; lcmpx < (lcmpxbase + Sd); lcmpx++) + { + if (src[lcmpx / Ss]) dst[t] += (float)1/Sd; + } + lcmpxbase += Sd; + } + + Colour c; + UINT value; + +/* + for(UINT q = 0; q < Nd; q++) + { + value = (UINT)(dst[q] * 182); // Apparently this is a better number than 255 for the colour value + c.set(value, value, value); + drawPixel(q, 6, c); + } +*/ + +for(int yy = 0; yy < 100; yy++) +{ + for(UINT q = 0; q < Nd; q++) + { + value = (UINT)(dst[q] * 182); // Apparently this is a better number than 255 for the colour value + c.set(value, value, value); + drawPixel(q+20, yy, c); + } +} + + + +} + +/* +x6 + x + 1 + +1x6 + 0x5 + 0x4 + 0x3 + 0x2 + 1x1 + 1x0 += +1 0 0 0 0 1 1 += +1000011 +key width = 6 + +static UCHAR startCode[] = {1,0}; +static UCHAR aspect43[] = {0,0}; +static UCHAR aspect169[] = {1,0}; +static UCHAR theRest[] = {0,0,0,0,0,0,0,0,0,0,0,0}; +static UCHAR crc43[] = {0,0,0,0,0,0}; +static UCHAR crc169[] = {1,0,0,1,0,1}; + +Message 4:3 + +1000000000000000 + +Message 4:3 augmented + +1000000000000000000000 + +Key + +1000011 + + +Ho ho, polynomial long division. Yeeeeaaahhh I remember +doing *that*. Of course I do. If you know of a faster, +easier, more reliable way of doing this, please let me know. + + + 100 + ________________________ +1000011 ) 1000000000000000000000 + 1000011 + ------- + 0000110 + 0000000 + ------- + 0001100 + + + + + + +Message 16:9 + +1010000000000000 + +Message 4:3 augmented + +1010000000000000000000 + +Key + +1000011 + + 1010011110100011 + ________________________ +1000011 ) 1010000000000000000000 + 1000011 + ------- + 0100110 + 0000000 + ------- + 1001100 + 1000011 + ------- + 0011110 + 0000000 + ------- + 0111100 + 0000000 + ------- + 1111000 + 1000011 + ------- + 1110110 + 1000011 + ------- + 1101010 + 1000011 + ------- + 1010010 + 1000011 + ------- + 0100010 + 0000000 + ------- + 1000100 + 1000011 + ------- + 0001110 + 0000000 + ------- + 0011100 + 0000000 + ------- + 0111000 + 0000000 + ------- + 1110000 + 1000011 + ------- + 1100110 + 1000011 + ------- + 100101 +*/ diff --git a/wwss.h b/wwss.h index 606f12d..feff7a8 100644 --- 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 -- 2.39.2