]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Support Quarter Video Mode
authorMarten Richter <marten.richter@freenet.de>
Sun, 9 Sep 2012 12:57:59 +0000 (14:57 +0200)
committerMarten Richter <marten.richter@freenet.de>
Sun, 9 Sep 2012 12:57:59 +0000 (14:57 +0200)
osdwin.cc
videoomx.cc
videoomx.h

index 4f90c5bab6d2ab7e4262700733952c51096cb550..83560b905c5179f5106152324d138e43cee23049 100644 (file)
--- a/osdwin.cc
+++ b/osdwin.cc
@@ -105,7 +105,7 @@ int OsdWin::getFD()
   return fdOsd;\r
 }\r
 \r
-Surface * OsdWin::createNewSurface();{\r
+Surface * OsdWin::createNewSurface(){\r
        return (Surface*)new SurfaceWin();\r
 }\r
 \r
index e1014e51d14666cacae84ca0640cec8b5f181cc2..56e35e3e40dfb0890bd25798d9dfcd1a331e8972 100644 (file)
@@ -48,6 +48,9 @@ VideoOMX::VideoOMX() {
        lastreftimePTS = 0;
        firstsynched = false;
 
+       mode=NORMAL;
+       xpos=ypos=0.f;
+
 }
 
 VideoOMX::~VideoOMX()
@@ -240,15 +243,99 @@ int VideoOMX::setAspectRatio(UCHAR taspectRatio)
 int VideoOMX::setMode(UCHAR tmode)
 {
   if (!initted) return 0;
+  mode=tmode;
+  updateMode();
+  return 1;
+}
+
 
-  if ((tmode == LETTERBOX) && (tvsize == ASPECT16X9)) return 0; // invalid mode
+void VideoOMX::updateMode()
+{
+       clock_mutex.Lock();
+       if (omx_running) {
+               OMX_ERRORTYPE error;
+               OMX_CONFIG_DISPLAYREGIONTYPE dispconf;
+               memset(&dispconf, 0, sizeof(dispconf));
+               dispconf.nSize = sizeof(dispconf);
+               dispconf.nVersion.nVersion = OMX_VERSION;
+               dispconf.nPortIndex = omx_rend_input_port;
+               dispconf.layer = 1;
+               dispconf.set = OMX_DISPLAY_SET_LAYER;
+               error = OMX_SetParameter(omx_vid_rend, OMX_IndexConfigDisplayRegion,
+                               &dispconf);
+               if (error != OMX_ErrorNone) {
+                       Log::getInstance()->log("Video", Log::DEBUG,
+                                       "Set OMX_IndexConfigDisplayRegion1 failed %x", error);
+                       clock_mutex.Unlock();
+                       return;
+               }
+               dispconf.set = OMX_DISPLAY_SET_FULLSCREEN;
+               if (mode != QUARTER && mode != EIGHTH) {
+                       //Set Fullscreen
+                       dispconf.fullscreen = OMX_TRUE;
+               } else {
+                       dispconf.fullscreen = OMX_FALSE;
+               }
+               error = OMX_SetParameter(omx_vid_rend, OMX_IndexConfigDisplayRegion,
+                               &dispconf);
+               if (error != OMX_ErrorNone) {
+                       Log::getInstance()->log("Video", Log::DEBUG,
+                                       "Set OMX_IndexConfigDisplayRegion2 failed %x", error);
+                       clock_mutex.Unlock();
+                       return;
+               }
 
-  if ((tmode != NORMAL) && (tmode != LETTERBOX) && (tmode != UNKNOWN2) && (tmode != QUARTER) && (tmode != EIGHTH)
-      && (tmode != ZOOM) && (tmode != UNKNOWN6)) return 0;
-  mode = tmode;
+               dispconf.set = OMX_DISPLAY_SET_MODE;
+               if (mode != QUARTER && mode != EIGHTH) {
+                       dispconf.mode = (mode == NORMAL) ? OMX_DISPLAY_MODE_FILL
+                                       : OMX_DISPLAY_MODE_LETTERBOX;
+               } else {
+                       dispconf.mode = OMX_DISPLAY_MODE_LETTERBOX;
+               }
+               error = OMX_SetParameter(omx_vid_rend, OMX_IndexConfigDisplayRegion,
+                               &dispconf);
+               if (error != OMX_ErrorNone) {
+                       Log::getInstance()->log("Video", Log::DEBUG,
+                                       "Set OMX_IndexConfigDisplayRegion3 failed %x", error);
+                       clock_mutex.Unlock();
+                       return;
+               }
 
-//  if (ioctl(fdVideo, AV_SET_VID_MODE, mode) != 0) return 0;
-  return 1;
+               if (mode == QUARTER || mode == EIGHTH) {
+                       unsigned int display_width, display_height;
+                       display_width = display_height = 0;
+                       if (graphics_get_display_size(0, &display_width, &display_height)
+                                       < 0) {
+                               Log::getInstance()->log("OSD", Log::WARN,
+                                               "Getting display size failed! (BCM API) ");
+                               clock_mutex.Unlock();
+                               return;
+                       }
+                       //UnSetFullscreen with window
+                       dispconf.set = OMX_DISPLAY_SET_DEST_RECT;
+                       dispconf.dest_rect.x_offset
+                                       = (int) (xpos * ((float) display_width));
+                       dispconf.dest_rect.y_offset = (int) (ypos
+                                       * ((float) display_height));
+                       if (mode == QUARTER) {
+                               dispconf.dest_rect.width = display_width >> 1;
+                               dispconf.dest_rect.height = display_height >> 1;
+                       } else if (mode == EIGHTH) {
+                               dispconf.dest_rect.width = display_width >> 2;
+                               dispconf.dest_rect.height = display_height >> 2;
+                       }
+                       error = OMX_SetParameter(omx_vid_rend,
+                                       OMX_IndexConfigDisplayRegion, &dispconf);
+                       if (error != OMX_ErrorNone) {
+                               Log::getInstance()->log("Video", Log::DEBUG,
+                                               "Set OMX_IndexConfigDisplayRegion failed %x", error);
+                               clock_mutex.Unlock();
+                               return;
+                       }
+               }
+
+       }
+       clock_mutex.Unlock();
 }
 
 int VideoOMX::signalOff()
@@ -272,52 +359,14 @@ int VideoOMX::setSource()
   return 1;
 }
 
-int VideoOMX::setPosition(int x, int y)
-{
-  if (!initted) return 0;
-
-//  vid_pos_regs_t pos_d;
-//  pos_d.x = x;
-//  pos_d.y = y;
-
-/*  vid_pos_regs_t pos_d;
-
-  memset(&pos_d, 0, sizeof(pos_d));
-
-  pos_d.dest.y = y;
-  pos_d.dest.x = x;
-/*
-typedef struct {
-  int w;
-  int h;
-  int scale;
-  int x1;
-  int y;
-  int x;
-  int y2;
-  int x3;
-  int y3;
-  int x4;
-  int y4;
-} vid_pos_regs_t;
-*/
-
-/*
-  pos_d.w = 100;
-  pos_d.h = 30;
-  pos_d.scale = 2;
-  pos_d.x1 = 0;
-  pos_d.y = 100;            // Top left X
-  pos_d.x = 50;            // Top left Y
-  pos_d.y2 = 30;
-  pos_d.x3 = 60;
-  pos_d.y3 = 90;
-  pos_d.x4 = 120;
-  pos_d.y4 = 150;
-*/
+int VideoOMX::setPosition(int x, int y) {
+       if (!initted)
+               return 0;
+       xpos = ((float) x*2.f) / ((float) screenWidth);
+       ypos = ((float) y*2.f) / ((float) screenHeight);
 
-//  if (ioctl(fdVideo, AV_SET_VID_POSITION, &pos_d) != 0) return 0;
-  return 1;
+       updateMode();
+       return 1;
 }
 
 int VideoOMX::sync()
@@ -759,7 +808,7 @@ int VideoOMX::AllocateCodecsOMX()
                DeAllocateCodecsOMX();
                return 0;
        }
-       clock_mutex.Unlock();
+
 
 
        Log::getInstance()->log("Video", Log::DEBUG, "mark1b ");
@@ -888,7 +937,7 @@ int VideoOMX::AllocateCodecsOMX()
        }
 
        //raspbi specifif
-       OMX_CONFIG_DISPLAYREGIONTYPE dispconf;
+       /*OMX_CONFIG_DISPLAYREGIONTYPE dispconf;
        memset(&dispconf,0,sizeof(dispconf));
        dispconf.nSize=sizeof(dispconf);
        dispconf.nVersion.nVersion=OMX_VERSION;
@@ -903,7 +952,7 @@ int VideoOMX::AllocateCodecsOMX()
                clock_mutex.Unlock();
                DeAllocateCodecsOMX();
                return 0;
-       }
+       }*/
 
 /*     dispconf.set=OMX_DISPLAY_SET_FULLSCREEN ;
        dispconf.fullscreen=OMX_FALSE;
@@ -934,6 +983,7 @@ int VideoOMX::AllocateCodecsOMX()
        iframemode=false;
        omx_running=true;
        clock_mutex.Unlock();
+       updateMode();
        threadStart();
 
        setClockExecutingandRunning();
index 86954383ccba29c227ea686226cd05079ffc8ddb..260774a5449caf460212c930fd15559ec09927e9 100644 (file)
@@ -239,6 +239,9 @@ class VideoOMX : public Video, public Thread_TYPE
 \r
           bool omx_mpeg2;\r
           bool omx_h264;\r
+          UCHAR mode;\r
+          float xpos,ypos;\r
+          void updateMode();//called internally to adjust for different parameters\r
 \r
 \r
 \r