From 7dd5a773876629e2bf028b13ac2e274c354ce7b8 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Mon, 8 Feb 2010 14:56:34 +0000 Subject: [PATCH] HDTV for Windows (1) --- osddirectfb.cc | 106 ++++++++++++++ osddirectfb.h | 58 ++++++++ remotelirc.cc | 297 ++++++++++++++++++++++++++++++++++++++++ remotelirc.h | 60 ++++++++ surfacedirectfb.cc | 304 +++++++++++++++++++++++++++++++++++++++++ surfacedirectfb.h | 73 ++++++++++ wwinvideoh264filter.cc | 232 +++++++++++++++++++++++++++++++ wwinvideoh264filter.h | 55 ++++++++ 8 files changed, 1185 insertions(+) create mode 100644 osddirectfb.cc create mode 100644 osddirectfb.h create mode 100644 remotelirc.cc create mode 100644 remotelirc.h create mode 100644 surfacedirectfb.cc create mode 100644 surfacedirectfb.h create mode 100644 wwinvideoh264filter.cc create mode 100644 wwinvideoh264filter.h diff --git a/osddirectfb.cc b/osddirectfb.cc new file mode 100644 index 0000000..8273643 --- /dev/null +++ b/osddirectfb.cc @@ -0,0 +1,106 @@ +/* + Copyright 2004-2005 Chris Tallon 2009 Marten Richter + portions 2008 Jon Gettler, Martin Vallevand + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +// Many thanks to Martin Vallevand for help + + +#include "osddirectfb.h" +#include "videonmt.h" //TODO abstract base calss for more directfb devices +#include + + + +OsdDirectFB::OsdDirectFB() +{ + if (instance) return; + dfb=NULL; + osd_layer=NULL; +} + +OsdDirectFB::~OsdDirectFB() +{ + if (initted) shutdown(); +} + +int OsdDirectFB::getFD() +{ + if (!initted) return 0; + return 0; +} + +int OsdDirectFB::init(void* device) +{ + + if (initted) return 0; + + if ( DirectFBInit(NULL,NULL)!=DFB_OK) + { + Log::getInstance()->log("OSD", Log::DEBUG, "Could not find init DirectFB"); + + return 0; + } + + if (!((VideoNMT*)Video::getInstance())->directFBsetOptions()) return 0; + + if (DirectFBCreate(&dfb) != DFB_OK) + { + Log::getInstance()->log("OSD", Log::DEBUG, + "Could not set create DirectFB"); + return 0; + } + dfb->SetCooperativeLevel(dfb,DFSCL_FULLSCREEN); + + if (dfb->GetDisplayLayer(dfb,DLID_PRIMARY, &osd_layer) != DFB_OK) + { + Log::getInstance()->log("OSD", Log::DEBUG, + "Could not get display layer DirectFB"); + return 0; + } + + osd_layer->SetCooperativeLevel(osd_layer,DLSCL_EXCLUSIVE); + osd_layer->GetConfiguration(osd_layer,&layer_config); + + + initted = 1; // must set this here or create surface won't work + /* TODO clean up sizes */ + Video* video = Video::getInstance(); + + screen = new SurfaceDirectFB(Surface::SCREEN); + screen->create(video->getScreenWidth(), video->getScreenHeight()); + screen->display(); + + return 1; +} + +int OsdDirectFB::shutdown() +{ + if (!initted) return 0; + initted = 0; + delete screen; + if (osd_layer) osd_layer->Release(osd_layer); + if (dfb) dfb->Release(dfb); + //dlclose(dl_handle); + return 1; +} + +void OsdDirectFB::screenShot(char* fileName) +{ + screen->screenShot(fileName); +} diff --git a/osddirectfb.h b/osddirectfb.h new file mode 100644 index 0000000..0b555b3 --- /dev/null +++ b/osddirectfb.h @@ -0,0 +1,58 @@ +/* + Copyright 2004-2005 Chris Tallon 2009 Marten Richter + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef OSDDirectFB_H +#define OSDDirectFB_H + +#include +#include +#include + +#include + +#include "osd.h" +#include "defines.h" +#include "log.h" +#include "surfacedirectfb.h" +#include "video.h" + +class OsdDirectFB : public Osd +{ + public: + OsdDirectFB(); + ~OsdDirectFB(); + + int init(void* device); + int shutdown(); + + int getFD(); + + void screenShot(char* fileName); + + IDirectFB* getDfb() {return dfb;}; + IDirectFBDisplayLayer* getOsdLayer(){return osd_layer;}; + + private: + IDirectFB * dfb; + DFBDisplayLayerConfig layer_config; + IDirectFBDisplayLayer * osd_layer; +}; + +#endif diff --git a/remotelirc.cc b/remotelirc.cc new file mode 100644 index 0000000..7138dde --- /dev/null +++ b/remotelirc.cc @@ -0,0 +1,297 @@ +/* + Copyright 2004-2005 Chris Tallon 2009 Marten Richter + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +#include + +#include "remotelirc.h" +#include "i18n.h" + +#include "log.h" + +#define LIRC_BUFFER_SIZE 128 + + +RemoteLirc::RemoteLirc() +{ + if (instance) return; + initted = 0; + tv.tv_sec = 0; + tv.tv_usec = 0; + device = -1; +} + +RemoteLirc::~RemoteLirc() +{ +} + +int RemoteLirc::init(char* devName) +{ + if (initted) return 0; + initted = 1; + + address.sun_family = AF_UNIX; + + strcpy(address.sun_path, devName); + if (!sockConnect()) return 0; +/* + device = open(devName, O_RDONLY); + if (device < 0) + { + initted = 0; + return 0; + } +*/ + return 1; +} + +int RemoteLirc::shutdown() +{ + if (!initted) return 0; + initted = 0; + close(device); + device = 0; + return 1; +} + +int RemoteLirc::sockConnect() +{ + if ((device = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0) { + if (connect(device, (struct sockaddr *)&address, sizeof(address)) >= 0) + return 1; + Log::getInstance()->log("Remote", Log::INFO, "Connecting lircd failed %s", address.sun_path); + close(device); + device = -1; + } + else + Log::getInstance()->log("Remote", Log::INFO, "Creating socket failed"); + + Log::getInstance()->log("Remote", Log::DEBUG, "Creating socket successfull"); + + return 0; +} + +int RemoteLirc::getDevice() +{ + if (!initted) return 0; + return device; +} + +UCHAR RemoteLirc::getButtonPress(int waitType) +{ + /* how = 0 - block + how = 1 - start new wait + how = 2 - continue wait + how = 3 - no wait + */ + + unsigned long input; + struct timeval* passToSelect = NULL; + char buffer[LIRC_BUFFER_SIZE]; + int retval; + fd_set readfds; + + if (waitType == 0) + { + passToSelect = NULL; + } + else if (waitType == 1) + { + tv.tv_sec = 1; + tv.tv_usec = 000000; + passToSelect = &tv; + } + else if (waitType == 2) + { + if ((tv.tv_sec == 0) && (tv.tv_usec == 0)) // protection in case timer = 0 + { + tv.tv_sec = 1; + tv.tv_usec = 000000; + } + passToSelect = &tv; + } + else if (waitType == 3) + { + tv.tv_sec = 0; + tv.tv_usec = 0; + passToSelect = &tv; + } + FD_ZERO(&readfds); + FD_SET(device, &readfds); + + retval = select(device + 1, &readfds, NULL, NULL, &tv); + // 0 = nothing happened + // 1 = data arrived (actually num of descriptors that changed) + // other value = signal or error + if (retval == 0) return NA_NONE; + if (retval == -1) return NA_SIGNAL; + + int count = read(device, &buffer, sizeof(LIRC_BUFFER_SIZE)); + if (count > 0) + { + int input=NA_UNKNOWN; + if (sscanf(buffer, "%d", &input) != 1) { + Log::getInstance()->log("Remote", Log::DEBUG, "ERROR: unparseable lirc command: %s", buffer); + return NA_UNKNOWN; + } + + Log::getInstance()->log("Remote", Log::DEBUG, "Button %x", input); + + return (UCHAR) TranslateHWC(input); + } + return NA_UNKNOWN; +} + +void RemoteLirc::clearBuffer() +{ +// while(getButtonPress(3) != NA_NONE); +} + +UCHAR RemoteLirc::TranslateHWCFixed(ULLONG code) +{ + switch (code) + { + case 0xa9: + return DOWN; + case 0xa8: + return UP; + case 0xaa: + return LEFT; + case 0xab: + return RIGHT; + case 0x09: + return MENU; + case 0x8d: + return BACK; + case 0x0d: + return OK; + case 0xd2: + return POWER; + default: + return NA_UNKNOWN; + }; +} + + +void RemoteLirc::InitHWCListwithDefaults() +{ + translist[0x9e] = VOLUMEUP; + translist[0x9f] = VOLUMEDOWN; + translist[0x94] = CHANNELUP; + translist[0x90] = CHANNELDOWN; + + // Common buttons + translist[0xf1] = ZERO; + translist[0xf2] = ONE; + translist[0xf3] = TWO; + translist[0xf4] = THREE; + translist[0xf5] = FOUR; + translist[0xf6] = FIVE; + translist[0xf7] = SIX; + translist[0xf8] = SEVEN; + translist[0xf9] = EIGHT; + translist[0xfa] = NINE; + translist[0xd2] = POWER; + translist[0x91] = GO; + translist[0xde] = RED; + translist[0xdf] = GREEN; + translist[0xe0] = YELLOW; + translist[0xe2] = BLUE; + + translist[0xe1] = MUTE; + translist[0xd5] = REVERSE; + translist[0xd6] = FORWARD; + translist[0x1b] = STOP; + translist[0xea] = PAUSE; + translist[0xe9] = PLAY; + translist[0xdb] = SKIPBACK; + translist[0xdc] = SKIPFORWARD; + + // Old remote only + translist[0xda] = FULL; + + +} + + +char* RemoteLirc::HCWDesc(ULLONG hcw) +{ + + char *ret=NULL; + + ret=new char[20]; + + switch(hcw) + { + case 0x01: strncpy(ret,tr("Suspend") ,20);break; + case 0x09: strncpy(ret,tr("Menu") ,20);break; + case 0x0d: strncpy(ret,tr("Enter") ,20);break; + case 0x1b: strncpy(ret,tr("Stop") ,20);break; + case 0x8A: strncpy(ret,tr("TV mode") ,20);break; + case 0x8c: strncpy(ret,tr("Setup") ,20);break; + case 0x8D: strncpy(ret,tr("Return") ,20);break; + case 0x90: strncpy(ret,tr("Repeat") ,20);break; + case 0x91: strncpy(ret,tr("Time Seek"),20);break; + case 0x94: strncpy(ret,tr("Title") ,20);break; + case 0x95: strncpy(ret,tr("Info") ,20);break; + case 0x9e: strncpy(ret,tr("Volume up") ,20);break; + case 0x9f: strncpy(ret,tr("Volume down") ,20);break; + case 0xa8: strncpy(ret,tr("up") ,20);break; + case 0xaa: strncpy(ret,tr("Left") ,20);break; + case 0xab: strncpy(ret,tr("Right") ,20);break; + case 0xa9: strncpy(ret,tr("Down") ,20);break; + case 0xd0: strncpy(ret,tr("Home") ,20);break; + case 0xd2: strncpy(ret,tr("Stand by") ,20);break; + case 0xd5: strncpy(ret,tr("Backward") ,20);break; + case 0xd6: strncpy(ret,tr("Forward") ,20);break; + case 0xd8: strncpy(ret,tr("Audio") ,20);break; + case 0xd9: strncpy(ret,tr("Slow") ,20);break; + case 0xda: strncpy(ret,tr("Zoom") ,20);break; + case 0xdb: strncpy(ret,tr("Previous") ,20);break; + case 0xde: strncpy(ret,tr("Red") ,20);break; + case 0xdc: strncpy(ret,tr("Next") ,20);break; + case 0xdf: strncpy(ret,tr("Green") ,20);break; + case 0xe0: strncpy(ret,tr("Yellow") ,20);break; + case 0xe1: strncpy(ret,tr("Mute") ,20);break; + case 0xe2: strncpy(ret,tr("Blue") ,20);break; + case 0xe9: strncpy(ret,tr("Play") ,20);break; + case 0xea: strncpy(ret,tr("Pause") ,20);break; + case 0xeb: strncpy(ret,tr("Subtitle") ,20);break; + case 0xec: strncpy(ret,tr("Angle") ,20);break; + case 0xef: strncpy(ret,tr("Eject") ,20);break; + case 0xf1: strncpy(ret,tr("0") ,20);break; + case 0xf2: strncpy(ret,tr("1") ,20);break; + case 0xf3: strncpy(ret,tr("2") ,20);break; + case 0xf4: strncpy(ret,tr("3") ,20);break; + case 0xf5: strncpy(ret,tr("4") ,20);break; + case 0xf6: strncpy(ret,tr("5") ,20);break; + case 0xf7: strncpy(ret,tr("6") ,20);break; + case 0xf8: strncpy(ret,tr("7") ,20);break; + case 0xf9: strncpy(ret,tr("8") ,20);break; + case 0xfA: strncpy(ret,tr("9") ,20);break; + case 0xFC: strncpy(ret,tr("Caps") ,20);break; + case 0xFD: strncpy(ret,tr("File mode") ,20);break; + + + default:{ + ULONG ri=(ULONG)hcw; + sprintf(ret,"R: %X",ri); + }break; + }; + return ret; +} diff --git a/remotelirc.h b/remotelirc.h new file mode 100644 index 0000000..d681b61 --- /dev/null +++ b/remotelirc.h @@ -0,0 +1,60 @@ +/* + Copyright 2004-2005 Chris Tallon 2009 Marten Richter + Inspired from code from vdr by Klaus Schmidinger + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef REMOTELIRC_H +#define REMOTELIRC_H + +#include +#include +#include +#include + +#include "remote.h" +#include "defines.h" + +class RemoteLirc : public Remote +{ + public: + RemoteLirc(); + ~RemoteLirc(); + + int init(char *devName); + int shutdown(); + int getDevice(); + UCHAR getButtonPress(int how); + void clearBuffer(); + int sockConnect(); + + virtual void InitHWCListwithDefaults(); + virtual char* HCWDesc(ULLONG hcw); + + private: + + virtual UCHAR TranslateHWCFixed(ULLONG code); + + int initted; + int device; + + struct sockaddr_un address; + struct timeval tv; +}; + +#endif diff --git a/surfacedirectfb.cc b/surfacedirectfb.cc new file mode 100644 index 0000000..f89770d --- /dev/null +++ b/surfacedirectfb.cc @@ -0,0 +1,304 @@ +/* + Copyright 2004-2005 Chris Tallon, 2009 Marten Richter + Portions copyright 2008 Jon Gettler + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "surfacedirectfb.h" + +#include "osd.h" +#include "bitmap.h" +#include "log.h" + +#include "osddirectfb.h" + + + +SurfaceDirectFB::SurfaceDirectFB(int id) +: Surface(id) +{ + surface=NULL; +} + +SurfaceDirectFB::~SurfaceDirectFB() +{ + if (surface) surface->Release(surface); + +} + +int SurfaceDirectFB::create(UINT width, UINT height) +{ + int counter=0; + while (!Osd::getInstance()->isInitted() && counter<2000) { + MILLISLEEP(50); //Wait for Grafiksystem initialization + counter++; + } + if (!Osd::getInstance()->isInitted()) return -1; + + IDirectFB*dfb=((OsdDirectFB*)Osd::getInstance())->getDfb(); +printf("ich bin doof");fflush(stdout); + if (screen == this) + { + IDirectFBDisplayLayer *osd_layer=((OsdDirectFB*)Osd::getInstance())->getOsdLayer(); + if (osd_layer->GetSurface(osd_layer,&surface)!=DFB_OK) + { + + return 0; + } + surface->Clear(surface,0x0,0x0,0x0,0xFF); + } else { + DFBSurfaceDescription dsc; + memset(&dsc,0,sizeof(dsc)); + *((int*)&dsc.flags)=DSDESC_CAPS | DSDESC_WIDTH | DSDESC_HEIGHT; + + dsc.width=width; + dsc.height=height; + dsc.caps= DSCAPS_NONE; + if (dfb->CreateSurface(dfb,&dsc,&surface)!=DFB_OK) + { + return 0; + } + } + return 1; +} + +void SurfaceDirectFB::display() +{ +// unsigned long fb_descriptor[2]; +/* + fb_descriptor[0] = surface.sfc.handle; + fb_descriptor[1] = 1; +*/ +// ioctl(fdOsd, GFX_FB_ATTACH, fb_descriptor); +} + + +// ---------------------------------------------------------------------------- + +// Now for the drawing functions + + +int SurfaceDirectFB::fillblt(int x, int y, int width, int height, unsigned int c) +{ + int sw,sh; + unsigned char r,g,b,a; + int nx,ny,nw,nh; + nx=x; + ny=y; + nw=width; + nh=height; + surface->GetSize(surface,&sw,&sh); + + if (nx >sw) nx=sw-1; + if (ny >sh) ny=sh-1; + + if ((nx+nw) >= sw) nw=sw-nx; + if ((ny+nh) >= sh) nh=sh-ny; + + if ((nx<0) || (ny < 0) || (nh <=0) || (nw <=0)) { + return 0; + } + + a= (c &0xff000000)>>24; + r= (c &0x00ff0000)>>16; + g= (c &0x0000ff00)>>8; + b= (c &0x000000ff); + + + surface->SetColor(surface,r,g,b,a); + surface->FillRectangle(surface,nx,ny,nw,nh); + return 0; +} + +void SurfaceDirectFB::drawPixel(int x, int y, unsigned int c, bool fastdraw) +{ + int sw,sh; + unsigned char r,g,b,a; + char *dst=NULL; + int offset=0; + int pitch; + surface->GetSize(surface,&sw,&sh); + if (x>=sw) return; + if (y>=sh) return; + + + + a= (c &0xff000000)>>24; + r= (c &0x00ff0000)>>16; + g= (c &0x0000ff00)>>8; + b= (c &0x000000ff); + + //TODO Fastdraw + if (surface->Lock(surface,DSLF_WRITE,(void**)(void*)&dst,&pitch) == DFB_OK) { + offset= y* pitch+x*4; + dst[offset++]=b; + dst[offset++]=g; + dst[offset++]=r; + dst[offset]=a; + surface->Unlock(surface); + } + +} + +void SurfaceDirectFB::drawPixel(int x, int y, Colour& c, bool fastdraw) +{ + int sw,sh; + char *dst=NULL; + int offset=0; + int pitch; + surface->GetSize(surface,&sw,&sh); + if (x>=sw) return; + if (y>=sh) return; + + //TODO Fastdraw + if (surface->Lock(surface,DSLF_WRITE,(void**)(void*)&dst,&pitch) == DFB_OK) { + offset= y* pitch+x*4; + dst[offset++]=c.blue; + dst[offset++]=c.green; + dst[offset++]=c.red; + dst[offset]=c.alpha; + surface->Unlock(surface); + } + +} + +void SurfaceDirectFB::drawHorzLine(int x1, int x2, int y, unsigned int c) +{ + fillblt(x1, y, x2-x1, 1, c); +} + +void SurfaceDirectFB::drawVertLine(int x, int y1, int y2, unsigned int c) +{ + fillblt(x, y1, 1, y2-y1, c); +} + +void SurfaceDirectFB::drawBitmap(int x, int y, const Bitmap& bm) +{/* + UINT bmw = bm.getWidth(); UINT bmh = bm.getHeight(); + if (bmw == 0 || bmh == 0) return; + if ((x >= (int)surface.sfc.width) || (y >= (int)surface.sfc.height)) return; + int remainder = (surface.sfc.width % 4); + UINT line; + if (remainder == 0) + line = surface.sfc.width; + else + line = surface.sfc.width + (4 - remainder); + const std::vector& bmdata = bm.rawData(); + const std::vector& Y = bm.palette.getYVector(); + const std::vector& Cr = bm.palette.getCrVector(); + const std::vector& Cb = bm.palette.getCbVector(); + const std::vector& A = bm.palette.getAVector(); + UINT b_offset = 0; + UINT s_offset = x + y*line; + UINT plotWidth = bmw; + UINT plotHeight = bmh; + if (x + plotWidth - 1 > surface.sfc.width) + plotWidth = surface.sfc.width - x + 1; + if (y + plotHeight - 1 > surface.sfc.height) + plotHeight = surface.sfc.height - y + 1; + for (UINT j = 0; j < plotHeight; ++j) + { + UINT i = 0; + if (x & 1) // odd x - need to plot first column separately + { + UCHAR index = bmdata[b_offset]; + *(surface.base[0] + s_offset) = Y[index]; + *(surface.base[1] + s_offset - 1) = Cb[index]; + *(surface.base[1] + s_offset) = Cr[index]; + *(surface.base[2] + s_offset) = A[index]; + i = 1; + } + // Now, plot pairs of pixels with averaged chroma values + while (i < plotWidth - 1) + { + UCHAR index1 = bmdata[b_offset + i]; + UCHAR index2 = bmdata[b_offset + i + 1]; + *(surface.base[0] + s_offset + i) = Y[index1]; + *(surface.base[0] + s_offset + i + 1) = Y[index2]; + *(surface.base[1] + s_offset + i) = (Cb[index1] + Cb[index2]) / 2; + *(surface.base[1] + s_offset + i + 1) = (Cr[index1] + Cr[index2]) / 2; + *(surface.base[2] + s_offset + i) = A[index1]; + *(surface.base[2] + s_offset + i + 1) = A[index2]; + i += 2; + } + if (i == plotWidth - 1) // One column left to do + { + UCHAR index = bmdata[b_offset + i]; + *(surface.base[0] + s_offset + i) = Y[index]; + *(surface.base[1] + s_offset + i) = Cb[index]; + *(surface.base[1] + s_offset + i + 1) = Cr[index]; + *(surface.base[2] + s_offset + i) = A[index]; + } + s_offset += line; + b_offset += bmw; + }*/ +} + + /* surface update to screen needs: + source x distance into this surface + source y distance into this surface + width of update + height of update + destination x on screen + destination y on screen + */ +int SurfaceDirectFB::updateToScreen(int sx, int sy, int w, int h, int dx, int dy) // FIXME new, replace others with this FIXME +{ + IDirectFBSurface* screensurf=((SurfaceDirectFB*)screen)->getSurfaceDFB(); + if (!screensurf) return 0; + if (this==screen) return 0; + + DFBRectangle rect; + int sw,sh; + + screensurf->GetSize(screensurf,&sw,&sh); +// screensurf->Clear(screensurf,0x0,0x0,0x0,0xFF); + rect.x = sx; + rect.y=sy; + rect.w=w; + rect.h=h; + + DFBRectangle drect; //TODO make osd HD + drect.x=dx*sw/720; + drect.y=dy*sh/576; + drect.w=w*sw/720; + drect.h=h*sh/576; + +// screensurf->Blit(screensurf,surface,&rect,dx,dy); + screensurf->StretchBlit(screensurf,surface,&rect,&drect); + + return 0;//blt(fdOsd, surface.sfc.handle, sx, sy, w, h, ((SurfaceDirectFB*)screen)->getSurfaceHandle(), dx, dy); +} + +int SurfaceDirectFB::blt(int fd, unsigned long shandle, int sx, int sy, int width, int height, unsigned long dhandle, int dx, int dy) +{//Skip it, noone uses this! + + return 0; +} + +void SurfaceDirectFB::screenShot(char* fileName) +{ + return; + +} + +void SurfaceDirectFB::readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b) +{ + +} + diff --git a/surfacedirectfb.h b/surfacedirectfb.h new file mode 100644 index 0000000..1171f32 --- /dev/null +++ b/surfacedirectfb.h @@ -0,0 +1,73 @@ +/* + Copyright 2004-2005 Chris Tallon, 2009 Marten Richter + Portions copyright 2004 Jon Gettler + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef SURFACEDirectFB_H +#define SURFACEDirectFB_H + +#include +#include +#include +#include +#include + +extern "C" +{ + #include +} + +#include "defines.h" +#include "surface.h" + +#include + + + +class SurfaceDirectFB : public Surface +{ + public: + SurfaceDirectFB(int id = 0); + ~SurfaceDirectFB(); + + int create(UINT width, UINT height); + void display(); + + int fillblt(int x, int y, int width, int height, unsigned int rgba); + void drawPixel(int x, int y, unsigned int c, bool fastdraw=false); + void drawPixel(int x, int y, Colour& c, bool fastdraw=false); + void drawHorzLine(int x1, int x2, int y, unsigned int c); + void drawVertLine(int x, int y1, int y2, unsigned int c); + void drawBitmap(int x, int y, const Bitmap& bm); + int updateToScreen(int sx, int sy, int w, int h, int dx, int dy); + void readPixel(int x, int y, unsigned char* r, unsigned char* g, unsigned char* b); + void screenShot(char* fileName); + IDirectFBSurface* getSurfaceDFB(){return surface;}; + + + int blt(int fd, unsigned long shandle, int sx, int sy, int width, int height, unsigned long dhandle, int dx, int dy); + + private: + IDirectFBSurface *surface; + + + +}; + +#endif diff --git a/wwinvideoh264filter.cc b/wwinvideoh264filter.cc new file mode 100644 index 0000000..a4a67da --- /dev/null +++ b/wwinvideoh264filter.cc @@ -0,0 +1,232 @@ +/* + Copyright 2004-2007 Chris Tallon, Marten Richter + + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#include "wwinvideoh264filter.h" +#include "videowin.h" +#include "i18n.h" +#include "remote.h" +#include "boxstack.h" + +WWinVideoH264Filter::WWinVideoH264Filter() +{ + add(&sl); + initSelectList(true); + sl.setShowSelOption(false); + sl.setPosition(15,30+15); +} + +WWinVideoH264Filter::~WWinVideoH264Filter() +{ + +} + +void WWinVideoH264Filter::initSelectList(bool startup) +{ + ULONG selection=0; + ULONG top=0; + if (!startup) + { + selection=sl.getCurrentOption(); + top=sl.getTopOption(); + } + + sl.addColumn(0); + + ULONG i; + VideoWin *vw=(VideoWin*) Video::getInstance(); + int filselected; + const VideoFilterDescList *list=vw->getVideoH264FilterList(filselected); + for (i = 0; i < list->size();i++) + { + const char * name = (*list)[i].friendlyname; + if (name!=NULL) + { + char * desc=new char [strlen(name)+1]; + strcpy(desc,name); + sl.addOption(desc,i,0); + } + + } + if (!startup) + { + sl.hintSetCurrent(selection); + sl.hintSetTop(top); + } +} + +void WWinVideoH264Filter::setSize(UINT w, UINT h) +{ + Boxx::setSize(w, h); + sl.setSize(area.w - 240, area.h - 30-15-30); +} + +void WWinVideoH264Filter::draw() +{ + Boxx::draw(); + + drawText(tr("Selected Filter:"), 15, 15, Colour::LIGHTTEXT); + int filselected; + VideoWin *vw=(VideoWin*) Video::getInstance(); + const VideoFilterDescList *list=vw->getVideoH264FilterList(filselected); + if (filselected!=-1) drawText((*list)[filselected].friendlyname,215,15,Colour::LIGHTTEXT); + sl.draw(); + + if (!(*list)[sl.getCurrentOptionData()].vmr9tested) + { + rectangle(area.w - 220, 160, 200, 20, Colour::YELLOW); + drawText(tr("VMR 9 support: ?"), area.w - 220, 160, Colour::DARKTEXT); + } + else if ((*list)[sl.getCurrentOptionData()].vmr9) + { + rectangle(area.w - 220, 160, 200, 20, Colour::GREEN); + drawText(tr("VMR 9 support: yes"), area.w - 220, 160, Colour::DARKTEXT); + } + else + { + rectangle(area.w - 220, 160, 200, 20, Colour::RED); + drawText(tr("VMR 9 support: no"), area.w - 220, 160, Colour::DARKTEXT); + } + + drawText(tr("Press [ok] to select filter! "), 15, area.h - 30, Colour::LIGHTTEXT); + +} + +bool WWinVideoH264Filter::mouseLBDOWN(int x, int y) +{ + if (sl.mouseLBDOWN(x,y)) + { + BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press + return true; + } + return false; +} + +bool WWinVideoH264Filter::mouseMove(int x, int y) +{ + if (sl.mouseMove(x,y)) + { + sl.setShowSelOption(true); + sl.draw(); + return true; + } + return false; +} + +/* +void WWinVideoH264Filter::processMessage(Message* m) +{ + Log::getInstance()->log("VRecordingList", Log::DEBUG, "Got message value %lu", m->message); + + if (m->message == Message::MOUSE_MOVE) + { + if (sl.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) + { + sl.setShowSelOption(true); + sl.draw(); + draw(); + viewman->updateView(this); + } + } + else if (m->message == Message::MOUSE_LBDOWN) + { + if (sl.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) + { + ViewMan::getInstance()->handleCommand(Remote::OK); //simulate OK press + } + else + { + //check if press is outside this view! then simulate cancel + int x=(m->parameter>>16)-getScreenX(); + int y=(m->parameter&0xFFFF)-getScreenY(); + if (x<0 || y <0 || x>getWidth() || y>getHeight()) + { + ViewMan::getInstance()->handleCommand(Remote::BACK); //simulate cancel press + } + } + } + +}*/ + +/* +void WWinVideoH264Filter::doSave() +{ + Message* m = new Message(); + m->message = Message::CHANGED_DEVICEOPTIONS; + m->to = parent; + m->parameter = 0; + Command::getInstance()->postMessageNoLock(m); + +}*/ + + +int WWinVideoH264Filter::handleCommand(int command) +{ + + switch(command) + { + case Remote::DF_UP: + case Remote::UP: + { + if (sl.getCurrentOption() != 0) + { + sl.up(); + sl.setShowSelOption(true); + return 1; + } + else + { + sl.setShowSelOption(false); + return 4; //Control to vopts control + } + } + case Remote::DF_DOWN: + case Remote::DOWN: + { + sl.down(); + sl.setShowSelOption(true); + return 1; + } + case Remote::SKIPBACK: + { + sl.pageUp(); + return 1; + } + case Remote::SKIPFORWARD: + { + sl.pageDown(); + return 1; + } + case Remote::OK: + { + VideoWin*vw=(VideoWin*)Video::getInstance(); + vw->selectVideoH264Filter(sl.getCurrentOptionData()); + return 1; + } + case Remote::BACK: + { + return 0; + + } + + } + + return 0; +} + diff --git a/wwinvideoh264filter.h b/wwinvideoh264filter.h new file mode 100644 index 0000000..c130491 --- /dev/null +++ b/wwinvideoh264filter.h @@ -0,0 +1,55 @@ +/* + Copyright 2004-2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#ifndef WWINVIDEOH264FILTER_H +#define WWINVIDEOH264FILTER_H + +#include +#include +#include + + +#include "boxx.h" +#include "wselectlist.h" + +class WWinVideoH264Filter : public Boxx +{ + public: + WWinVideoH264Filter (); + ~WWinVideoH264Filter (); + + void setSize(UINT w, UINT h); + + int handleCommand(int command); + bool mouseMove(int x, int y) ; + bool mouseLBDOWN(int x, int y); + void draw(); + + + private: + WSelectList sl; + + void initSelectList(bool startup); + + + +}; + +#endif -- 2.39.2