]> git.vomp.tv Git - vompclient.git/commitdiff
Commit towards hardware accelarated jpegs, does not work, crashes and freezes, use...
authorMarten Richter <marten.richter@freenet.de>
Sun, 27 Jul 2014 18:14:14 +0000 (20:14 +0200)
committerMarten Richter <marten.richter@freenet.de>
Sun, 27 Jul 2014 18:14:14 +0000 (20:14 +0200)
GNUmakefile
defines.h
osdopenvg.cc
osdopenvg.h
osdvector.cc
osdvector.h
videoomx.h

index 435d644e3f7c799fc5dea75211ec4639cfa0c677..d0c518ef405eb3af37678a76029f4926f683dbc7 100644 (file)
@@ -63,7 +63,7 @@ $(info Raspberry pi flags)
 LDFLAGS = -Wall -Wl,--format=binary -Wl,other/vdrhires.jpg -Wl,other/wallpaper720p.jpg -Wl,--format=default 
 LIBS = -L/opt/vc/lib -lpthread -lrt -lEGL -lOpenVG -lopenmaxil -lbcm_host   -lavformat -lavcodec -lavutil
 
-OBJECTS += main.o threadp.o  osdvector.o surfacevector.o osdopenvg.o ledraspberry.o mtdraspberry.o videoomx.o audioomx.o wjpegsimple.o remotelinux.o  
+OBJECTS += main.o threadp.o  osdvector.o surfacevector.o osdopenvg.o ledraspberry.o mtdraspberry.o videoomx.o audioomx.o imageomx.o wjpegsimple.o remotelinux.o  
 LIBS+=  -lfreetype -lMagick++ 
 CROSSLIBS = 
 INCLUDES = -DVOMP_PLATTFORM_RASPBERRY   -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads  -I/usr/include/freetype2 -I/usr/include/ImageMagick
@@ -77,7 +77,7 @@ $(info Raspberry pi flags cross compiler)
 LDFLAGS = -Wall -Wl,--format=binary -Wl,other/vdrhires.jpg -Wl,other/wallpaper720p.jpg -Wl,--format=default -Wl,--verbose -Xlinker --rpath-link=rpi-root/usr/lib/arm-linux-gnueabihf -Xlinker --rpath-link=rpi-root/lib/arm-linux-gnueabihf -Xlinker --rpath-link=rpi-root/opt/vc/lib
 LIBS = -Lrpi-root/opt/vc/lib -Lrpi-root/lib -Lrpi-root/usr/lib -Lrpi-root/lib/arm-linux-gnueabihf -Lrpi-root/usr/lib/arm-linux-gnueabihf -Lrpi-root/usr/local/lib -lpthread -lrt -lEGL -lOpenVG -lopenmaxil -lbcm_host -lavformat -lavcodec -lavutil -ldl -lfontconfig
 
-OBJECTS += main.o threadp.o osdvector.o surfacevector.o osdopenvg.o ledraspberry.o mtdraspberry.o videoomx.o audioomx.o wjpegsimple.o remotelinux.o
+OBJECTS += main.o threadp.o osdvector.o surfacevector.o osdopenvg.o ledraspberry.o mtdraspberry.o videoomx.o audioomx.o imageomx.o wjpegsimple.o remotelinux.o
 LIBS+=  -lfreetype -lMagick++
 CROSSLIBS =
 INCLUDES = -DVOMP_PLATTFORM_RASPBERRY   -Irpi-root/opt/vc/include -Irpi-root/opt/vc/include/interface/vcos/pthreads -Irpi-root/usr/include -Irpi-root/usr/include/freetype2 -Irpi-root/usr/include/ImageMagick
index 8b62f5da5f1e80deabc1ac5d8cd1bcaeeacfc566..14d0e4c680f26e8a2116c61ee17ef6b194b3c7c0 100644 (file)
--- a/defines.h
+++ b/defines.h
@@ -111,6 +111,8 @@ long long getTimeMS();
    #define VPE_OMX_CLOCK "OMX.broadcom.clock"
    #define VPE_OMX_AUDIO_DECODER "OMX.broadcom.audio_decode"
    #define VPE_OMX_AUDIO_REND "OMX.broadcom.audio_render"
+   #define VPE_OMX_IMAGE_DECODER "OMX.broadcom.image_decode"
+   #define VPE_OMX_EGL_REND "OMX.broadcom.egl_render"
 
    //#define  VPE_LIBAV_SUPPORT
   // #define  VPE_LIBAV_MPEG2_TRANSCODING
index 12a0e6d81d5211d4d961153e262b85c2a11bd791..ece11cd34d882916cd699475345cd256477d5595 100644 (file)
@@ -301,6 +301,11 @@ int OsdOpenVG::init(void* device)
   taskmutex.Unlock();
   vgmutex.Unlock();
 
+#ifdef PICTURE_DECODER_OMX
+    imageomx=new ImageOMX(&reader);
+       reader.addDecoder(imageomx);
+#endif
+
 
   return 1;
 }
@@ -397,6 +402,11 @@ void OsdOpenVG::purgeAllReferences()
 int OsdOpenVG::shutdown()
 {
   reader.shutdown();
+#ifdef PICTURE_DECODER_OMX
+       if (imageomx) reader.removeDecoder(imageomx);
+       imageomx=NULL;
+#endif
+
   if (!initted) return 0;
 
   initted = 0;
@@ -1107,6 +1117,35 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command)
                delete info;
 
        } break;
+       case OVGcreateEGLImage: {
+               PictureInfo *info = (PictureInfo*) command.data;
+               VGImage handle;
+               //Log::getInstance()->log("OSD", Log::DEBUG, "TVMedia OVGcreateImageMemory");
+               handle=vgCreateImage(VG_sXBGR_8888,info->width,info->height,VG_IMAGE_QUALITY_BETTER);
+
+               info->handle = handle;
+               info->reference =  eglCreateImageKHR(egl_display, egl_context, EGL_VG_PARENT_IMAGE_KHR, (EGLClientBuffer)handle, NULL);
+               if (info->reference) return true;
+               else return false;
+
+       } break;
+
+       case OVGreadyEGLImage: {
+               PictureInfo *info = (PictureInfo*) command.data;
+               eglDestroyImageKHR(egl_display,info->reference);
+
+               Message* m = new  Message();
+               m->message=Message::NEW_PICTURE;
+               m->from=this;
+               m->to=Command::getInstance();
+               m->parameter = info->handle;
+               m->tag = info->lindex;
+               Command::getInstance()->postMessageFromOuterSpace(m); // inform command about new picture
+
+               delete info;
+       } break;
+
+
 
        case OVGcreateColorRef :{
                VGPaint handle;
@@ -1323,6 +1362,10 @@ void  OsdOpenVG::createPicture(struct PictureInfo& pict_inf)
                comm.task = OVGcreateImageMemory;
                comm.data =  new PictureInfo(pict_inf);
                putOpenVGCommand(comm,false);
+       } else if (pict_inf.type == PictureInfo::EGLImage) {
+               comm.task = OVGreadyEGLImage;
+               comm.data =  new PictureInfo(pict_inf);
+               putOpenVGCommand(comm,false);
        } else {
                // unsupported
                pict_inf.decoder->freeReference(pict_inf.reference);
@@ -1331,6 +1374,16 @@ void  OsdOpenVG::createPicture(struct PictureInfo& pict_inf)
        }
 }
 
+bool OsdOpenVG::getEGLPicture(struct OsdVector::PictureInfo & info , EGLDisplay * display)
+{
+       struct OpenVGCommand comm;
+       info.type = PictureInfo::EGLImage;
+       comm.task = OVGcreateEGLImage;
+       comm.data = &info;
+       *display = egl_display;
+       return  putOpenVGCommand(comm,true);
+}
+
 
 
 ImageIndex OsdOpenVG::createMonoBitmap(void *base,int width,int height)
index afcaebc0b4f06044208a3073b80c95ee08eb1f78..ff657f3cfb6dc60509b8c7404a905c8a694a15fa 100644 (file)
@@ -37,6 +37,9 @@
 #include "threadp.h"
 #include "mutex.h"
 #include "videoomx.h"
+#ifdef PICTURE_DECODER_OMX
+#include "imageomx.h"
+#endif
 
 #include <deque>
 
@@ -52,7 +55,9 @@ enum OpenVGTask {
        OVGimageUploadLine,
        OVGcreateImageFile,
        OVGreplacefont,
-       OVGcreateImageMemory
+       OVGcreateImageMemory,
+       OVGcreateEGLImage,
+       OVGreadyEGLImage
 };
 
 struct OpenVGCommand
@@ -70,7 +75,7 @@ struct OpenVGResponse{
 };
 
 
-class OsdOpenVG : public OsdVector, public Thread_TYPE
+class OsdOpenVG : public OsdVector, public Thread_TYPE, public EGLPictureCreator
 {
   public:
     OsdOpenVG();
@@ -93,6 +98,8 @@ class OsdOpenVG : public OsdVector, public Thread_TYPE
 
     virtual float getPixelAspect() {return aspect_correction;};
 
+    bool getEGLPicture(struct OsdVector::PictureInfo & info, EGLDisplay * display);
+
 
 protected:
 
@@ -175,6 +182,9 @@ protected:
        float aspect_correction;
        bool freetype_inited;
 
+#ifdef PICTURE_DECODER_OMX
+       ImageOMX *imageomx;
+#endif
 
 };
 
index 1b1bd769ddb7c5947e699b1cf80e9cbb56e7eb94..bacb245c25503a7f1e5ff2b9ca80685587210386 100644 (file)
@@ -647,10 +647,29 @@ void OsdVector::PictureReader::shutdown()
 void OsdVector::PictureReader::addDecoder(PictureDecoder* decoder)
 {
        decoders_lock.Lock();
+       decoder->init();
        decoders.push_front(decoder);
        decoders_lock.Unlock();
 }
 
+void OsdVector::PictureReader::removeDecoder(PictureDecoder* decoder)
+{
+       decoders_lock.Lock();
+       std::list<PictureDecoder*>::iterator itty=decoders.begin();
+       while (itty!=decoders.end()) {
+               if ((*itty) == decoder)
+               {
+                       decoders.erase(itty);
+                       break;
+               }
+               itty++;
+       }
+       Log::getInstance()->log("OsdVector", Log::DEBUG, "removeDecoder");
+       decoder->shutdown();
+       delete decoder;
+       decoders_lock.Unlock();
+}
+
 void OsdVector::PictureReader::threadMethod()
 {
        OsdVector *osdvector = dynamic_cast<OsdVector*>(Osd::getInstance());
index 57d449b499baf38810aae433c43528bf0a1898cd..a91d63cf4a4c5a7277d2238b4bfcac44ff6b63ae 100644 (file)
@@ -258,7 +258,10 @@ class OsdVector : public Osd
        ULONG width;
        ULONG height;
        LoadIndex lindex;
+    union {
        const void * image;
+       unsigned int handle;
+    };
        void *reference;
        PictureDecoder* decoder;
     };
@@ -270,6 +273,7 @@ class OsdVector : public Osd
     {
     public:
        PictureDecoder(PictureReader * treader) {reader=treader;};
+       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;
@@ -277,6 +281,9 @@ class OsdVector : public Osd
        virtual bool getDecodedPicture(struct PictureInfo& pict_inf)=0;
        virtual void freeReference(void * ref)=0;
 
+       virtual void init() {};
+       virtual void shutdown() {};
+
     protected:
        PictureReader * reader;
     };
@@ -288,6 +295,7 @@ class OsdVector : public Osd
 
        void init();
        void addDecoder(PictureDecoder*);
+       void removeDecoder(PictureDecoder*);
 
        void shutdown();
 
index 66a901c94cc7fd0763bb42331be839471a128e5e..67914307de6f3fb999c73cdd53a0596ab4cfba96 100644 (file)
@@ -65,6 +65,7 @@ class AudioVPE;
 class VideoOMX : public Video
 {
   friend class AudioOMX;
+  friend class ImageOMX;
   public:
     VideoOMX();
     virtual ~VideoOMX();