}
} break;
+ case Message::NEW_PICTURE_STATIC:
+ {
+ OsdVector *osdv=dynamic_cast<OsdVector*>(Osd::getInstance());
+ if (osdv) {
+ osdv->informPicture(((long long)m->tag)<<32LL,m->parameter);
+ }
+
+ } break;
}
}
else
OMX_ERRORTYPE error;
static OMX_CALLBACKTYPE callbacks= {&VideoOMX::EventHandler_OMX,&EmptyBufferDone_OMX,&FillBufferDone_OMX};
- Log::getInstance()->log("Image", Log::NOTICE, "Allocate Codecs OMX");
+ //Log::getInstance()->log("Image", Log::NOTICE, "Allocate Codecs OMX");
//Clock, move later to Image
VideoOMX *video=(VideoOMX*)Video::getInstance();
- Log::getInstance()->log("Image", Log::NOTICE, "Allocate Codecs OMX finished");
+ //Log::getInstance()->log("Image", Log::NOTICE, "Allocate Codecs OMX finished");
return 1;
}
-bool ImageOMX::decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length)
+bool ImageOMX::decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length, bool freemem)
{
if (pictInfValid) return false; // does support only one image at a Time;
// Log::getInstance()->log("Image", Log::DEBUG,
DeAllocateCodecsOMX();
pthread_setcancelstate(oldcancelstate, NULL);
pthread_setcanceltype(oldcanceltype, NULL);
- if (ret) free(buffer);
+ if (ret && freemem) free(buffer);
return ret;
}
void init();
void shutdown();
- bool decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length);
+ bool decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length, bool freemem);
bool getDecodedPicture(struct OsdVector::PictureInfo& pict_inf);
void freeReference(void * ref);
const static ULONG SUBTITLE_CHANGE_CHANNEL = 34;
const static ULONG MOUSE_ANDROID_SCROLL = 35;
const static ULONG NEW_PICTURE = 36;
+ const static ULONG NEW_PICTURE_STATIC = 37;
};
#endif
#include "mtd.h"
#include "videoomx.h"
#include "surface.h"
-#include <Magick++.h>
+//#include <Magick++.h>
#include "message.h"
#include "command.h"
#include <math.h>
#include <bcm_host.h>
-using namespace Magick;
+//using namespace Magick;
extern uint8_t vdr_data[] asm("_binary_other_vdrhires_jpg_start");
extern uint8_t vdr_data_end[] asm("_binary_other_vdrhires_jpg_end");
/*if (((VideoOMX*)Video::getInstance())->initUsingOSDObjects()!=1) { //call Video for init stuff
return 0;
}*/
- InitializeMagick("");
+ // InitializeMagick("");
processTasks();
return 1;
}
-
+/*
void OsdOpenVG::purgeAllReferences()
{
images_ref.clear();
}
monobitmaps.clear();
- map<string,ImageIndex>::iterator jitty=jpegs.begin();
+ /*map<string,ImageIndex>::iterator jitty=jpegs.begin();
while (jitty!=jpegs.end()) {
vgDestroyImage((VGImage)(*jitty).second);
jitty++;
}
- jpegs.clear();
+ jpegs.clear();*
+
+ map<TVMediaInfo,ImageIndex>::iterator titty=tvmedias.begin();
+ while (titty!=tvmedias.end()) {
+ vgDestroyImage((VGImage)(*titty).second);
+ titty++;
+ }
+ tvmedias.clear();
map<pair<Colour*,unsigned int>,unsigned int>::iterator sitty=styles.begin();
while (sitty!=styles.end()) {
}
styles.clear();
-}
+}*/
int OsdOpenVG::shutdown()
{
} break;
case OVGdestroyImageRef: {
+ //Log::getInstance()->log("OSD", Log::DEBUG, "TVMedia Draw Image Destroy %d ",command.param1);
vgDestroyImage((VGImage)command.param1);
return 0;
} break;
case OVGdestroyPaint: {
- Log::getInstance()->log("OSD", Log::DEBUG, "Draw Paint Destroy %d ",command.param1);
+ //Log::getInstance()->log("OSD", Log::DEBUG, "Draw Paint Destroy %d ",command.param1);
vgDestroyPaint((VGPaint)command.param1);
return 0;
} break;
// Log::getInstance()->log("OSD", Log::DEBUG, "Draw create mono2 %d %d %x %d",command.param1,command.param2,vgGetError(),handle);
return handle;
} break;
- case OVGcreateImageFile: {
+ /*case OVGcreateImageFile: {
VGImage handle;
try{
Image *imagefile=(Image*)command.data;
//Log::getInstance()->log("OSD", Log::DEBUG, "Draw create file %d %d %x %d",command.param1,command.param2,vgGetError(),handle);
return handle;
- } break;
+ } break;*/
case OVGcreateImageMemory: {
PictureInfo *info = (PictureInfo*) command.data;
VGImage handle;
vgImageSubData(handle,info->image,info->width*4,
VG_sXBGR_8888,0,0,info->width,info->height);
info->decoder->freeReference(info->reference);
+
+ bool static_image=true;
+ if (info->lindex & 0xffffffff) static_image=false;
+
Message* m = new Message();
// We have a pictures! send a message to ourself, to switch to gui thread
- m->message=Message::NEW_PICTURE;
m->from=this;
m->to=Command::getInstance();
m->parameter = handle;
+ if (!static_image) {
+ m->message=Message::NEW_PICTURE;
+ m->tag = info->lindex;
+ } else {
+ m->message=Message::NEW_PICTURE_STATIC;
+ m->tag = info->lindex>> 32LL;
+ }
m->tag = info->lindex;
Command::getInstance()->postMessageFromOuterSpace(m); // inform command about new picture
case OVGreadyEGLImage: {
PictureInfo *info = (PictureInfo*) command.data;
eglDestroyImageKHR(egl_display,info->reference);
+ bool static_image=true;
+ if (info->lindex & 0xffffffff) static_image=false;
Message* m = new Message();
- m->message=Message::NEW_PICTURE;
m->from=this;
m->to=Command::getInstance();
m->parameter = info->handle;
- m->tag = info->lindex;
+ if (!static_image) {
+ m->message=Message::NEW_PICTURE;
+ m->tag = info->lindex;
+ } else {
+ m->message=Message::NEW_PICTURE_STATIC;
+ m->tag = info->lindex>> 32LL;
+ }
Command::getInstance()->postMessageFromOuterSpace(m); // inform command about new picture
delete info;
comm.param1=index;
putOpenVGCommand(comm,false);
}
-
+/*
ImageIndex OsdOpenVG::createJpeg(const char* fileName, int *width,int *height)
{
Image* magicimage=NULL;
}
comm.data=magicimage;
return putOpenVGCommand(comm,true);
+}*/
+
+bool OsdOpenVG::getStaticImageData(unsigned int static_id, UCHAR **userdata, ULONG *length)
+{
+ switch (static_id) {
+ case 1: {
+ *userdata = vdr_data;
+ *length = vdr_data_end-vdr_data;
+ return true;
+ } break;
+ case 2: {
+ *userdata = wallpaper_data;
+ *length = wallpaper_data_end-wallpaper_data;
+ return true;
+ } break;
+ default: {
+ *userdata = NULL;
+ *length = 0;
+ return false;
+ } break;
+ };
}
void OsdOpenVG::createPicture(struct PictureInfo& pict_inf)
OVGcreateMonoBitmap,
OVGcreateColorRef,
OVGimageUploadLine,
- OVGcreateImageFile,
+ //OVGcreateImageFile,
OVGreplacefont,
OVGcreateImageMemory,
OVGcreateEGLImage,
/*osd vector implementation*/
void destroyImageRef(ImageIndex index);
- ImageIndex createJpeg(const char* fileName, int *width,int *height);
+ // ImageIndex createJpeg(const char* fileName, int *width,int *height);
ImageIndex createMonoBitmap(void *base,int width,int height);
ImageIndex createImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data);
void createPicture(struct PictureInfo& pict_inf);
void destroyStyleRef(unsigned int index);
unsigned int createStyleRef(const DrawStyle &c);
unsigned int createColorRef(const Colour &c);
+ bool getStaticImageData(unsigned int static_id, UCHAR **userdata, ULONG *length);
void drawSetTrans(SurfaceCommands & sc);
void executeDrawCommand(SVGCommand & command);
bool haveOpenVGResponse(unsigned int id,unsigned int * resp);
unsigned int putOpenVGCommand(OpenVGCommand& comm,bool wait);
unsigned int handleTask(OpenVGCommand& command);
- void purgeAllReferences();
+ //void purgeAllReferences();
unsigned int wait_id;
FT_Library ft_library;
public:
MagickDecoder(OsdVector::PictureReader* treader): OsdVector::PictureDecoder(treader) {pictInfValid=false;};
- bool decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length);
+ bool decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length, bool freemem);
bool getDecodedPicture( struct OsdVector::PictureInfo& pict_inf);
bool pictInfValid;
};
-bool MagickDecoder::decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length)
+bool MagickDecoder::decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length, bool freemem)
{
if (pictInfValid) return false; // does support only one image at a Time;
Image magicimage;
try{
Log::getInstance()->log("MagickDecoder", Log::DEBUG, "decodePicture");
Blob myblob;
- myblob.updateNoCopy(buffer,length,Blob::MallocAllocator);
+ if (freemem) myblob.updateNoCopy(buffer,length,Blob::MallocAllocator);
+ else myblob.update(buffer,length);
magicimage.read(myblob);
magicimage.write(imageblob,"RGBA");
//also clear all handles, they are now invalid, no need to release them
images_ref.clear();
monobitmaps.clear();
- jpegs.clear();
+ //jpegs.clear();
styles.clear();
styles_ref.clear();
+ tvmedias.clear();
+ loadindex_ref.clear();
+ tvmedias_load.clear();
+ tvmedias_load_inv.clear();
+ tvmedias_loaded.clear();
+
surfaces_mutex.Unlock();
return 1;
}
(*itty).commands.clear();
(*itty).commands=commands;
//increase the references
- list<SVGCommand>::iterator sitty=(*itty).commands.begin();
- while (sitty!=(*itty).commands.end())
- {
- incStyleRef((*sitty).getRef());
- ImageIndex ii=(*sitty).getImageIndex();
- if (ii) incImageRef(ii);
- LoadIndex li=(*sitty).getLoadIndex();
- if (li) incLoadIndexRef(li);
- sitty++;
- }
+ referenceSVGCommand((*itty).commands);
cleanupOrphanedRefs();
surfaces_mutex.Unlock();
} else ++mitty;
}
- map<string,ImageIndex>::iterator jitty=jpegs.begin();
+ /*map<string,ImageIndex>::iterator jitty=jpegs.begin();
while (jitty!=jpegs.end()) {
map<ImageIndex,int>::iterator curitty=images_ref.find((*jitty).second);
int count=(*curitty).second;
images_ref.erase(curitty++);
destroyImageRef(ref);
} else ++jitty;
- }
+ }*/
map<TVMediaInfo,ImageIndex>::iterator titty=tvmedias.begin();
while (titty!=tvmedias.end()) {
if (count==0) {
ImageIndex ref=(*curitty).first;
tvmedias.erase(titty++);
- images_ref.erase(curitty++);
+ images_ref.erase(curitty);
destroyImageRef(ref);
} else ++titty;
}
+ map<TVMediaInfo,LoadIndex>::iterator litty=tvmedias_load.begin();
+ while (litty!=tvmedias_load.end()) {
+ map<LoadIndex,int>::iterator curitty=loadindex_ref.find((*litty).second);
+ int count=(*curitty).second;
+ if (count==0) {
+ tvmedias_load_inv.erase((*litty).second);
+ tvmedias_loaded.erase((*litty).second);
+ tvmedias_load.erase(litty++);
+ } else ++litty;
+ }
+
+
map<pair<Colour*,unsigned int>,unsigned int>::iterator sitty=styles.begin();
while (sitty!=styles.end()) {
map<unsigned int,int>::iterator curitty=styles_ref.find((*sitty).second);
case 3:
index=VDR::getInstance()->loadTVMediaRecThumb(tvmedia);
break;
+ case 4: {
+ index = ((long long) tvmedia.getPrimaryID()) << 32LL;
+ reader.addStaticImage(tvmedia.getPrimaryID());
+ } break;
default:
index=VDR::getInstance()->loadTVMedia(tvmedia);
break;
tvmedias_load[tvmedia]=index;
tvmedias_load_inv[index]=tvmedia;
} else {
+
index=tvmedias_load[tvmedia];
}
ImageIndex image_index=0;
TVMediaInfo tvmedia=tvmedias_load_inv[index];
- Log::getInstance()->log("OsdVector", Log::DEBUG, "TVMedia Picture for request id %d arrived",index);
+ Log::getInstance()->log("OsdVector", Log::DEBUG, "TVMedia Picture for request id %llx arrived %d",index, imageIndex);
if (imageIndex) {
image_index=tvmedias[tvmedia]=imageIndex;
tvmedias_loaded[index]=image_index;
-
+/*
ImageIndex OsdVector::getJpegRef(const char* fileName, int *width,int *height)
{
ImageIndex image_handle=0;
incImageRef(image_handle);
return image_handle;
}
+*/
ImageIndex OsdVector::getMonoBitmapRef(void *base,int width,int height)
{
threadSignal();
}
+
+void OsdVector::PictureReader::addStaticImage(unsigned int id)
+{
+ pict_lock_incoming.Lock();
+ pict_incoming_static.push(id);
+ invalid_loadindex.erase(((long long) id) << 32LL);
+ pict_lock_incoming.Unlock();
+ threadSignal();
+}
+
bool OsdVector::PictureReader::processReceivedPictures()
{
bool decoded = false;
}
//else osd->informPicture(vresp->getStreamID(), 0);
delete vresp;
+ } else if (pict_incoming_static.size()){
+ unsigned int static_id = pict_incoming_static.front();
+ pict_incoming_static.pop();
+ set<LoadIndex>::iterator setpos = invalid_loadindex.find(((long long) static_id) << 32LL);
+ if (setpos != invalid_loadindex.end()) {
+ valid = false;
+ invalid_loadindex.erase(setpos);
+ }
+ pict_lock_incoming.Unlock();
+ if (!valid) { // we do not want it anymore skip it;
+ return true;
+ }
+
+ UCHAR *userdata;
+ ULONG length;
+ if (((OsdVector*)Osd::getInstance())->getStaticImageData(static_id, &userdata, &length))
+ {
+ std::list<PictureDecoder*>::iterator itty=decoders.begin();
+ while (itty!=decoders.end()) {
+ if ((*itty)->decodePicture(((long long) static_id) << 32LL,userdata, length, false)){
+ decoded=true;
+ break;
+ }
+ itty++;
+ }
+ }
} else {
pict_lock_incoming.Unlock();
}
};
typedef unsigned int ImageIndex;
-typedef unsigned int LoadIndex;
+typedef unsigned long long LoadIndex;
class SVGCommand
{
if (instr!=DrawImage) return 0;
else return target.image;
};
- ImageIndex getLoadIndex() {
+ LoadIndex getLoadIndex() {
if (instr!=DrawImageLoading) return 0;
else return target.loadindex;
};
virtual float getFontHeight()=0;
virtual float getCharWidth(wchar_t c)=0;
- virtual ImageIndex getJpegRef(const char* fileName, int *width,int *height);
+ //virtual ImageIndex getJpegRef(const char* fileName, int *width,int *height);
virtual LoadIndex getTVMediaRef(TVMediaInfo& tvmedia,ImageIndex& image);
virtual ImageIndex getMonoBitmapRef(void *base,int width,int height);
virtual ImageIndex getImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data);
virtual void imageUploadLine(ImageIndex index,unsigned int j,unsigned int width,void *data)=0;
+
+
+ virtual bool getStaticImageData(unsigned int static_id, UCHAR **userdata, ULONG *length)=0;
+
void removeImageRef(const ImageIndex ref);
void removeLoadIndexRef(const LoadIndex ref);
unsigned int getColorRef(const Colour &c); //internally this is the same as getStyleRef
virtual ~PictureDecoder() {};
// its is always guaranted, that after getDecodedPicture a call to decodePicture follows, if the return value was true;
- virtual bool decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length)=0;
+ virtual bool decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length, bool freemem=true)=0;
virtual bool getDecodedPicture(struct PictureInfo& pict_inf)=0;
virtual void freeReference(void * ref)=0;
// should be called from command thread
void receivePicture(VDR_ResponsePacket *vresp);
+ void addStaticImage(unsigned int id);
+
void invalidateLoadIndex(LoadIndex index);
Mutex pict_lock_incoming; //locks
Mutex decoders_lock;
std::queue<VDR_ResponsePacket*> pict_incoming;
+ std::queue<unsigned int> pict_incoming_static;
std::list<PictureDecoder*> decoders;
set<LoadIndex> invalid_loadindex;
int getLoadIndexRef(LoadIndex index);
- virtual ImageIndex createJpeg(const char* fileName, int *width,int *height)=0;
+ //virtual ImageIndex createJpeg(const char* fileName, int *width,int *height)=0;
virtual ImageIndex createMonoBitmap(void *base,int width,int height)=0;
virtual ImageIndex createImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data)=0;
virtual void createPicture(struct PictureInfo& pict_inf)=0;
map<ImageIndex,int> images_ref;
map<void *,ImageIndex> monobitmaps;
- map<string,ImageIndex> jpegs;
+ //map<string,ImageIndex> jpegs;
map<TVMediaInfo,ImageIndex> tvmedias;
#include "bitmap.h"
#include <wchar.h>
#include <stdlib.h>
+#include <math.h>
SurfaceVector::SurfaceVector(OsdVector* vosd)
{
return drawText(text, x-shift/2., y, c);
}
+void SurfaceVector::drawJpeg(const char *fileName,int x, int y,int *width, int *height)
+{
+ int jpeg_index=-1; // This is for compatibility only
+ if (strcmp(fileName,"/vdr.jpg")==0) {
+ jpeg_index=1;
+ *height=100; // this is faked so that the system does use the old coordinate system
+ *width=ceil(190.f*osd->getPixelAspect());
+ } else if (strcmp(fileName,"/wallpaperPAL.jpg")==0) {
+ jpeg_index=2;
+ *width=720; // this is faked so that the system does use the old coordinate system
+ *height=576;
+ }
+ if (jpeg_index>0) {
+ TVMediaInfo info;
+ info.setDefaultJpeg(jpeg_index);
+ drawTVMedia(info,x,y,*width,*height,TopLeft);
+ }
+}
+
+/*
void SurfaceVector::drawJpeg(const char *fileName,int x, int y,int *width, int *height)
{
command_mutex.Lock();
commands.push_back(SVGCommand::PaintImage(x,y,*width,*height,image,0));
command_mutex.Unlock();
}
+*/
void SurfaceVector::drawTVMedia(TVMediaInfo & tvmedia,float x, float y, float width, float height, Corner corner)
{
primary_name=recname;
}
+void TVMediaInfo::setDefaultJpeg(int jpeg_index)
+{
+ type=4;
+ primary_id=jpeg_index;
+}
+
bool operator<(const TVMediaInfo& rhs, const TVMediaInfo& lhs)
{
if (rhs.type==lhs.type) {
void setMovieInfo(const MovieInfo * mi);
void setSeriesInfo(const SeriesInfo * si);
void setPosterThumb(const char* recname);
+ void setDefaultJpeg(int jpeg_index);
int getType() {return type;};
+ int getPrimaryID() {return primary_id;};
private:
- int type; // movie or series or unknown recording
+ int type; // 1 movie or 2 series or 3 unknown recording or 4 static artwork
int primary_id; //movie or series_id
int secondary_id; //0 or episode id
int type_pict; // 0 full info, 1 poster thumb, 2 season thumb
#include "osd.h"
#include "movieinfo.h"
#include "seriesinfo.h"
+#include "osdvector.h"
#define VOMP_PROTOCOLL_VERSION 0x00000302
#include "eventdispatcher.h"
#include "i18n.h"
#include "log.h"
-#include "osdvector.h"
+#include "tvmedia.h"
class TCP;
class Log;