From 543ff5f80f7e76b350d8d4fc9129b222192edb63 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Wed, 18 Oct 2006 22:45:11 +0000 Subject: [PATCH] WSS files added, and now working on live tv as well --- timers.cc | 2 +- vvideolive.cc | 18 ++++++++- vvideolive.h | 4 ++ vvideorec.cc | 11 ++--- wwss.cc | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++ wwss.h | 46 +++++++++++++++++++++ 6 files changed, 180 insertions(+), 11 deletions(-) create mode 100644 wwss.cc create mode 100644 wwss.h diff --git a/timers.cc b/timers.cc index 11fb3af..2980105 100755 --- a/timers.cc +++ b/timers.cc @@ -305,7 +305,7 @@ void Timers::threadMethod() threadUnlock(); //logger->log("Timers", Log::DEBUG, "un-LOCKED -TIMERS- MUTEX (3)"); //printf("\n\n\n WOOOOO \n\n\n The anti deadlock code is working!!! \n\n\n"); - MILLISLEEP(10); // 10ms - too long? + MILLISLEEP(20); // 10ms - too long? too short? //logger->log("Timers", Log::DEBUG, "Waiting for LOCK -TIMERS- MUTEX 7"); threadLock(); //logger->log("Timers", Log::DEBUG, "LOCKED -TIMERS- MUTEX 7"); diff --git a/vvideolive.cc b/vvideolive.cc index 4d274a4..e515664 100644 --- a/vvideolive.cc +++ b/vvideolive.cc @@ -45,6 +45,14 @@ VVideoLive::VVideoLive(ChannelList* tchanList, ULONG tstreamType, VChannelList* create(video->getScreenWidth(), video->getScreenHeight()); Colour transparent(0, 0, 0, 0); setBackgroundColour(transparent); + + wss.setSurface(surface); + wss.setWide(true); + + wssRegion.x = 0; + wssRegion.y = 6; + wssRegion.w = video->getScreenWidth(); + wssRegion.h = 2; } VVideoLive::~VVideoLive() @@ -268,12 +276,18 @@ void VVideoLive::processMessage(Message* m) } case Player::ASPECT43: { - Log::getInstance()->log("VVideoLive", Log::DEBUG, "Received do WSS 43"); + Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 43"); + wss.setWide(false); + wss.draw(); + ViewMan::getInstance()->updateView(this, &wssRegion); break; } case Player::ASPECT169: { - Log::getInstance()->log("VVideoLive", Log::DEBUG, "Received do WSS 169"); + Log::getInstance()->log("VVideoRec", Log::DEBUG, "Received do WSS 169"); + wss.setWide(true); + wss.draw(); + ViewMan::getInstance()->updateView(this, &wssRegion); break; } } diff --git a/vvideolive.h b/vvideolive.h index f4de463..da90bfd 100644 --- a/vvideolive.h +++ b/vvideolive.h @@ -38,6 +38,7 @@ #include "i18n.h" #include "vepg.h" #include "wtextbox.h" +#include "wwss.h" class VEpg; class VChannelList; @@ -93,6 +94,9 @@ class VVideoLive : public View void toggleChopSides(); int videoMode; int saveUnavailable; + + Wwss wss; + Region wssRegion; }; #endif diff --git a/vvideorec.cc b/vvideorec.cc index 656b9f9..2f48e3c 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -86,9 +86,9 @@ VVideoRec::VVideoRec(Recording* rec) wss.setWide(true); wssRegion.x = 0; - wssRegion.y = 0; + wssRegion.y = 6; wssRegion.w = video->getScreenWidth(); - wssRegion.h = 10; + wssRegion.h = 2; } VVideoRec::~VVideoRec() @@ -108,7 +108,6 @@ VVideoRec::~VVideoRec() void VVideoRec::draw() { View::draw(); - wss.draw(); } void VVideoRec::go(ULONG startFrameNum) @@ -252,7 +251,6 @@ int VVideoRec::handleCommand(int command) case Remote::RED: { //player->test1(); - Video::getInstance()->setAspectRatio(Video::ASPECT4X3); /* @@ -269,7 +267,6 @@ int VVideoRec::handleCommand(int command) } case Remote::GREEN: { - Video::getInstance()->setAspectRatio(Video::ASPECT16X9); //player->test2(); return 2; } @@ -300,7 +297,7 @@ void VVideoRec::processMessage(Message* m) } case Player::STOP_PLAYBACK: { - // Obselete ish - improve this + // FIXME Obselete ish - improve this Message* m = new Message(); // Must be done after this thread finishes, and must break into master mutex m->to = Command::getInstance(); m->message = Message::STOP_PLAYBACK; @@ -313,7 +310,6 @@ void VVideoRec::processMessage(Message* m) wss.setWide(false); wss.draw(); ViewMan::getInstance()->updateView(this, &wssRegion); - Log::getInstance()->log("VVideoRec", Log::DEBUG, "WSS done"); break; } case Player::ASPECT169: @@ -322,7 +318,6 @@ void VVideoRec::processMessage(Message* m) wss.setWide(true); wss.draw(); ViewMan::getInstance()->updateView(this, &wssRegion); - Log::getInstance()->log("VVideoRec", Log::DEBUG, "WSS done"); break; } } diff --git a/wwss.cc b/wwss.cc new file mode 100644 index 0000000..ed57efc --- /dev/null +++ b/wwss.cc @@ -0,0 +1,110 @@ +/* + Copyright 2006 Chris Tallon + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "wwss.h" + +Wwss::Wwss() +{ +} + +Wwss::~Wwss() +{ +} + +UINT Wwss::gcd(UINT a, UINT b) +{ + UINT t; + while (b != 0) + { + t = b; + b = a % b; + a = t; + } + return a; +} + +UINT Wwss::lcm(UINT a, UINT b) +{ + return (a / gcd(a, b)) * b; +} + +void Wwss::setWide(bool twide) +{ + wide = twide; +} + +void Wwss::draw() +{ + // The aspect43 and aspect169 codes are not what they should be according to the docs, but these are what work... + // (1 = 111000, = 0 000111) + static UCHAR runIn[] = {1,1,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1}; // 29 pos 0 + static UCHAR startCode[] = {0,0,0,1,1,1,1,0,0,0,1,1,1,1,0,0,0,0,0,1,1,1,1,1}; // 24 pos 29 + static UCHAR aspect43[] = {0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,0,0,0}; // = 0001 4:3 full frame // 24 pos 53 + static UCHAR aspect169[] = {1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,1,1,1}; // = 1110 16:9 anamorphic // 24 pos 53 + static UCHAR theRest[] = {0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1, // 60 pos 77 + 0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1, + 0,0,0,1,1,1,0,0,0,1,1,1}; + /* + Real PAL pixel frequency: 13.5 MHz + WSS element frequency: 5 MHz + = 2.7 pal pixels per wss element + * 137 wss elements = 369.9 pal pixels (total code width) (round to 370..) + + There is also a 11us 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 = 137; // Num pix src + const UINT Nd = 370; // Num pix dst 359->395 does something. not the right thing, but something. + 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], runIn, 29); + memcpy(&src[29], startCode, 24); + if (wide) memcpy(&src[53], aspect169, 24); + else memcpy(&src[53], aspect43, 24); + memcpy(&src[77], theRest, 60); + + 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); + } +} diff --git a/wwss.h b/wwss.h new file mode 100644 index 0000000..606f12d --- /dev/null +++ b/wwss.h @@ -0,0 +1,46 @@ +/* + Copyright 2006 Chris Tallon + + This file is part of VOMP. + + VOMP is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + VOMP is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with VOMP; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef WWSS_H +#define WWSS_H + +#include +#include + +#include "defines.h" +#include "widget.h" +#include "colour.h" + +class Wwss : public Widget +{ + public: + Wwss(); + ~Wwss(); + void draw(); + void setWide(bool wide); + + private: + UINT gcd(UINT a, UINT b); + UINT lcm(UINT a, UINT b); + + bool wide; +}; + +#endif -- 2.39.2