On Donnerstag 28 September 2006 00:09, Stefan Lucke wrote:
> On Mittwoch 27 September 2006 21:05, Marko Mäkelä wrote:
> > On Mon, Sep 25, 2006 at 11:24:32PM +0200, Stefan Lucke wrote:
> > > So my tv-out test is still pending, but I've a new version of the patch.
> > > If it still happens for you sometimes, there is the possibility to enable
> > > a mutex around Flip() and Blit() calls. To enable this, USE_TEST_MUTEX
> > > should be defined to 1.
> > 
> > Sorry, I haven't gotten around to testing this yet.  Should I revert the
> > -03 patch and apply this one instead?
> 
> Please don't test the -04 patch. It has still the osdMutex in. Have to test
> this on my system with tv-out first. 

So her comes -05 version of the patch. I tested this with tv-out.
My testing was fast scrolling through the channel list.
I did not see any issues with a missed flip on OSD drawing.

So I had no need for enabling the dfbFlipMutex.

The final version will have method ShowOSD() removed.

If you ask for differences between -03 and -05 ..
Upon processing events there will be never an internal OSD refresh
via ShowOSD() .

> 
> > By the way, the -03 patch does slow 
> > down my system too much from time to time, especially when watching programs
> > containing DVB subtitles, which are mapped to OSD by the subtitles plugin.

If you've still this issue, I think black bar clearing could be done after
scrSurface->Flip(NULL, DSFLIP_WAITFORSYNC); 
to clear borders of the next frame.

-- 
Stefan Lucke
Index: video.c
===================================================================
RCS file: /cvsroot/softdevice/softdevice/video.c,v
retrieving revision 1.66
diff -U3 -r1.66 video.c
--- video.c     22 Sep 2006 19:28:04 -0000      1.66
+++ video.c     28 Sep 2006 17:29:55 -0000
@@ -105,7 +105,7 @@
 
     if (
         OsdRefreshCounter > 120 || // blanks the screen after inactivity (4s)
-        (current_osdMode == OSDMODE_SOFTWARE &&
+        (IsSoftOSDMode() &&
          OsdRefreshCounter>5 && Osd_changed))
     {
       oldPictureMutex.Lock();
@@ -476,8 +476,6 @@
 void cVideoOut::ClearOSD()
 {
   OSDDEB("ClearOSD\n");
-  osdMutex.Lock();
-
   OSDpresent=false; // will automaticly be set to true on redraw ;-)
   if (OsdPy)
     memset(OsdPy,0,OSD_FULL_WIDTH*OSD_FULL_HEIGHT);
@@ -490,8 +488,13 @@
   if (OsdPAlphaUV)
     memset(OsdPAlphaUV,0,OSD_FULL_WIDTH*OSD_FULL_HEIGHT/4);
   Osd_changed=1;
+}
 
- osdMutex.Unlock();
+/* ---------------------------------------------------------------------------
+ */
+bool cVideoOut::IsSoftOSDMode()
+{
+  return current_osdMode == OSDMODE_SOFTWARE;
 }
 
 #if VDRVERSNUM >= 10307
@@ -503,10 +506,8 @@
 
 void cVideoOut::CloseOSD()
 {
-  osdMutex.Lock();
   ClearOSD();
   OSDpresent=false;
-  osdMutex.Unlock();
   OSDDEB("CloseOSD\n");
 }
 
Index: video.h
===================================================================
RCS file: /cvsroot/softdevice/softdevice/video.h,v
retrieving revision 1.43
diff -U3 -r1.43 video.h
--- video.h     22 Sep 2006 19:28:04 -0000      1.43
+++ video.h     28 Sep 2006 17:29:56 -0000
@@ -79,7 +79,9 @@
     // oldPicture is a reference to a previous decoded frame. It is used
     // when there is osd drawing activity in case of no video currently
     // available. Access to this pointer must be protected by corresponding
-    // mutex: oldPictureMutex .
+    // mutex: oldPictureMutex . This includes changeing the contens e.g.
+    // when a decoded picture will be displayed and thus will be the reference
+    // for future operation on oldPicture.
     //
     sPicBuffer  *oldPicture;
     cMutex      oldPictureMutex;
@@ -89,12 +91,8 @@
     inline double GetAspect_F()
     { return aspect_F;};
 
-protected:
     // -----------------------------------------------------------------------
-    // State changes of OSD like on / off transitions, must be proteced by
-    // osdMutex. This are changes of variable OSDpresent, as the output method
-    // may need to take some longer actions e.g clearing background for one or
-    // mutiple output buffers (double, triple buffering).
+    // Artefakt of vdr-1.2.x OSD create/delete locking
     //
     cMutex  osdMutex;
     bool    OSDpresent,
@@ -193,6 +191,8 @@
 public:
     virtual void ClearOSD();
     // clear the OSD buffer
+
+    virtual bool IsSoftOSDMode();
 
 #if VDRVERSNUM >= 10307
     virtual void OpenOSD();
Index: video-dfb.c
===================================================================
RCS file: /cvsroot/softdevice/softdevice/video-dfb.c,v
retrieving revision 1.71
diff -U3 -r1.71 video-dfb.c
--- video-dfb.c 16 Sep 2006 09:30:19 -0000      1.71
+++ video-dfb.c 28 Sep 2006 17:29:58 -0000
@@ -49,6 +49,8 @@
            }                                                         \
      }
 
+#define USE_TEST_MUTEX 0
+
 typedef struct
 {
   const char            *shortName;
@@ -661,8 +663,8 @@
     }
   }
 
-  if (OsdRefreshCounter && (OsdRefreshCounter % 3) == 0)
-    ShowOSD();
+  //if (OsdRefreshCounter && (OsdRefreshCounter % 3) == 0)
+    //ShowOSD();
 }
 
 /* ---------------------------------------------------------------------------
@@ -1072,7 +1074,7 @@
   try
   {
     dirtyLines=DirtyLines=new bool[Yres];
-    memset(dirtyLines,false,sizeof(dirtyLines));
+    memset(dirtyLines,false,sizeof(bool)*Yres);
 
     tmpOsdSurface = (useStretchBlit) ? osdSurface : scrSurface;
     tmpOsdSurface->Lock(DSLF_WRITE, (void **)&dst, &pitch) ;
@@ -1100,7 +1102,13 @@
     DFBRectangle      osdsrc;
 
     tmpOsdSurface->Unlock();
+#if USE_TEST_MUTEX
+    dfbFlipMutex.Lock();
+#endif
     tmpOsdSurface->Flip();
+#if USE_TEST_MUTEX
+    dfbFlipMutex.Unlock();
+#endif
 
     int miny=0;
     int maxy=0;
@@ -1137,6 +1145,7 @@
   delete[] dirtyLines;
   dirtyLines=NULL;
   tmpOsdSurface=NULL;
+  clearBackground = 0;
   cVideoOut::CommitUnlockOsdSurface();
 }
 
@@ -1203,6 +1212,14 @@
 
 /* ---------------------------------------------------------------------------
  */
+bool cDFBVideoOut::IsSoftOSDMode()
+{
+  return cVideoOut::IsSoftOSDMode() ||
+         useStretchBlit;
+}
+
+/* ---------------------------------------------------------------------------
+ */
 void cDFBVideoOut::CloseOSD()
 {
     IDirectFBSurface  *tmpSurface;
@@ -1210,16 +1227,14 @@
   if (!videoInitialized)
     return;
 
+  cVideoOut::CloseOSD();
   tmpSurface = (useStretchBlit) ? osdSurface : scrSurface;
-
   try
   {
     if (useStretchBlit)
     {
-      osdMutex.Lock();
       OSDpresent  = false;
-      osdClrBack = true;
-      osdMutex.Unlock();
+      clearBackground = clearBackCount;
       tmpSurface->Clear(COLORKEY,clearAlpha); //clear and
     }
     else
@@ -1248,7 +1263,7 @@
   if (!videoInitialized)
     return;
 
-  if (useStretchBlit && (OSDpresent || osdClrBack)) {
+  if (useStretchBlit && OSDpresent) {
     // do image and OSD mix here
       DFBRectangle  src, dst, osdsrc;
 
@@ -1261,12 +1276,6 @@
     dst.w = lwidth;
     dst.h = lheight;
 
-    osdMutex.Lock();
-    if (osdClrBack) {
-      clearBackground = clearBackCount;
-      osdClrBack = false;
-    }
-
     try
     {
       if (clearBackground) {
@@ -1274,6 +1283,32 @@
         clearBackground--;
       }
 
+      /* ---------------------------------------------------------------------
+       * clear parts of screen when OSD is present and which are not
+       * covered by video. This avoids fading effects when 16:9 video
+       * is shown on 4:3 screen (top & bottom) or when 4:3 video is shown
+       * on 16:9 screen (left & right).
+       */
+      if (OSDpresent) {
+          scrSurface->SetColor(0,0,0,0);
+
+        /* -------------------------------------------------------------------
+         * clear top & bottom black bar area
+         */
+        if (lyoff) {
+          scrSurface->FillRectangle(0,0,            dwidth,lyoff);
+          scrSurface->FillRectangle(0,lyoff+lheight,dwidth,lyoff);
+        }
+
+        /* -------------------------------------------------------------------
+         * clear left & right black bar area
+         */
+        if (lxoff) {
+          scrSurface->FillRectangle(0,0,           lxoff,dheight);
+          scrSurface->FillRectangle(lxoff+lwidth,0,lxoff,dheight);
+        }
+      }
+
       scrSurface->SetBlittingFlags(DSBLIT_NOFX);
       scrSurface->StretchBlit(videoSurface, &src, &dst);
       if (OSDpresent)
@@ -1292,7 +1327,6 @@
                ex->GetAction(), ex->GetResult());
       delete ex;
     }
-    osdMutex.Unlock();
   }
 }
 
@@ -1436,9 +1470,7 @@
       //fprintf (stderr, "src (%d,%d %dx%d)\n", sxoff,syoff,swidth,sheight);
       //fprintf (stderr, "dst (%d,%d %dx%d)\n", lxoff,lyoff,lwidth,lheight);
 
-      osdMutex.Lock();
-      clearBackground = (aspect_changed || osdClrBack) ? clearBackCount: 
clearBackground;
-      osdClrBack = false;
+      clearBackground = (aspect_changed) ? clearBackCount: clearBackground;
 
       if (clearBackground)
       {
@@ -1446,7 +1478,32 @@
         clearBackground--;
       }
 
-      osdMutex.Unlock();
+
+      /* ---------------------------------------------------------------------
+       * clear parts of screen when OSD is present and which are not
+       * covered by video. This avoids fading effects when 16:9 video
+       * is shown on 4:3 screen (top & bottom) or when 4:3 video is shown
+       * on 16:9 screen (left & right).
+       */
+      if (OSDpresent) {
+          scrSurface->SetColor(0,0,0,0);
+
+        /* -------------------------------------------------------------------
+         * clear top & bottom black bar area
+         */
+        if (lyoff) {
+          scrSurface->FillRectangle(0,0,            dwidth,lyoff);
+          scrSurface->FillRectangle(0,lyoff+lheight,dwidth,lyoff);
+        }
+
+        /* -------------------------------------------------------------------
+         * clear left & right black bar area
+         */
+        if (lxoff) {
+          scrSurface->FillRectangle(0,0,           lxoff,dheight);
+          scrSurface->FillRectangle(lxoff+lwidth,0,lxoff,dheight);
+        }
+      }
 
       scrSurface->SetBlittingFlags(DSBLIT_NOFX);
       scrSurface->StretchBlit(videoSurface, &src, &dst);
@@ -1457,6 +1514,11 @@
         osdsrc.x = osdsrc.y = 0;
         osdsrc.w = Xres;osdsrc.h=Yres;
         scrSurface->SetBlittingFlags(DSBLIT_BLEND_ALPHACHANNEL);
+
+#if USE_TEST_MUTEX
+        dfbFlipMutex.Lock();
+#endif
+
 #if 0
         /* --------------------------------------------------------------------
          * test for OSD scaleinf to 4:3 aspect on a 16:9 tv
@@ -1467,6 +1529,10 @@
         scrSurface->StretchBlit(osdSurface, &osdsrc, &osddest);
 #else
         scrSurface->Blit(osdSurface, &osdsrc, 0, 0);
+#endif
+
+#if USE_TEST_MUTEX
+        dfbFlipMutex.Unlock();
 #endif
 
       }
Index: video-dfb.h
===================================================================
RCS file: /cvsroot/softdevice/softdevice/video-dfb.h,v
retrieving revision 1.22
diff -U3 -r1.22 video-dfb.h
--- video-dfb.h 17 Jun 2006 16:27:35 -0000      1.22
+++ video-dfb.h 28 Sep 2006 17:29:59 -0000
@@ -50,6 +50,8 @@
     void SetParams();
     void EnableFieldParity(IDirectFBDisplayLayer *layer);
 
+    cMutex  dfbFlipMutex;
+
 #ifdef HAVE_CLE266_MPEG_DECODER
     IDirectFBSurface* mpegfb[LAST_PICBUF];
     int               mpegfb_ofs[4];
@@ -62,6 +64,7 @@
     void ProcessEvents ();
     void ShowOSD ();
     void GetDisplayFrameTime();
+    virtual bool IsSoftOSDMode();
 
 #if VDRVERSNUM >= 10307
     bool *dirtyLines;
_______________________________________________
Softdevice-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/softdevice-devel

Reply via email to