OSD and subtitles trouble

Message ID 20131108235737.GA3937@x220
State New
Headers

Commit Message

Marko Mäkelä Nov. 8, 2013, 11:57 p.m. UTC
  I did some more hacking and got softdevice to a useable state on VDR 
2.0.4. My patch against softdevice cvs is attached.

The TL;DR version is that I suspect 2 bugs in VDR 2.0.4:

(1) The bottom 1% lines of the OSD are not being cleared when the OSD 
extends that low. (I can choose up to 99% height and 0% vertical 
offset.)

(2) Changes in DVB subtitles will flash the OSD layer (make it empty for 
a very short time) if an OSD is active. I suppose that DVB subtitles 
should not be displayed at all when OSD layer is active.

On Mon, Nov 04, 2013 at 10:30:14PM +1000, Torgeir Veimo wrote:
>Softdevice had transparency 'dithering' for when there's only 1-bit 
>transparency, did you look at that option?

I am a bit unsure if it really is using 1-bit transparency. The 
background inside the LCARS main menu is darker (but still translucent) 
than the area outside the menu borders. Everything else in the OSD layer 
is opaque.

With "perf top" I noticed that Softdevice was spending a lot of time, 
scaling the OSD layer down from 1920×1080 to 720×576 that is my video 
output resolution. So, I hardcoded the OSD size back to 720×576. OSD 
updates became snappy (fewer pixels to copy to the 
cSoftOsd::OSD_Bitmap[], and from there it would be a straight memcpy to 
the video memory). The following problem was unaffected by this fix.

If I set the OSD size to 100% height, then VDR will never clear the very 
bottom lines at the screen. If I set it to 99% height, everything will 
be erased properly when I leave the main menu, or the program info at 
the bottom of the screen is cleared. If I set it to 99% height and 1% 
vertical offset, the garbage will appear again. My current understanding 
is that it is VDR 2.0.4 that fails to post a proper draw request to 
clear the bottom of the screen.

The next problem was related to my patch. It turned out that 
cSoftOsd::Flush() has to check cOsd::IsTrueColor() and render pixmaps or 
bitmaps accordingly. This would also explain why I previously never saw 
any output from the Classic VDR OSD (it is the only non-TrueColor 
built-in theme).

The garbage-at-bottom problem also affects DVB subtitles. If I move the 
"Setup.DVB$Subtitle offset" too low, the pixels from the last 4 or so of 
the 576 lines will never be cleared (only drawn when there is some "y" 
or "p" or "q" character that extends to to the "garbage area").

A small (old) problem with the Softdevice OSD/subtitles remains. When 
the OSD is active while the current stream is showing DVB subtitles, the 
OSD layer will be cleared, but no subtitles will be displayed.  
Eventually, parts of the OSD will be repainted. It turns out that this 
problem was emphasized by the cSoftOsd::dirty_lines[] array. If I commit 
out the dirty_lines[] checks, the OSD will be properly repainted, but 
the entire OSD layer will be cleared for a few frames whenever the 
subtitles are about to display. (No subtitles will be actually 
displayed, because the OSD layer is active.) How to avoid this short OSD 
flash? I tried commenting out all cSoftOsd::Clear() calls, but that did 
not help (other than leaving DVB subtitles garbage on the screen when 
the OSD layer was not active).

Note: I understand that the non-truecolor DVB subtitles are not being 
alpha-blended to the truecolor OSD layer. It is OK for me not to see 
subtitles when the OSD is active. But it is not OK that the active OSD 
layer gets cleared whenever subtitles are attempting to display or clear 
themselves.

Best regards,

	Marko
  

Comments

Klaus Schmidinger Nov. 9, 2013, 10:36 a.m. UTC | #1
On 09.11.2013 00:57, Marko Mäkelä wrote:
> ...
> If I set the OSD size to 100% height, then VDR will never clear the very bottom lines at the screen. If I set it to 99% height, everything will be erased properly when I leave the main menu, or the program info at the bottom of the screen is cleared. If I set it to 99% height and 1% vertical offset,
> the garbage will appear again. My current understanding is that it is VDR 2.0.4 that fails to post a proper draw request to clear the bottom of the screen.

I just tried this on my VDR with a TT S2-6400 and there was no such problem.
I assume that this is related to the softdevice OSD implementation and not
the core VDR.

Klaus
  
Marko Mäkelä Nov. 9, 2013, 11:59 a.m. UTC | #2
On Sat, Nov 09, 2013 at 11:36:55AM +0100, Klaus Schmidinger wrote:
>I just tried this on my VDR with a TT S2-6400 and there was no such 
>problem. I assume that this is related to the softdevice OSD 
>implementation and not the core VDR.

Thank you for testing, Klaus!

Were you able to test the other problem (the OSD menu becomes fully 
transparent and then normal again when subtitles would want to update 
the OSD)? I can provide a short recording if needed. I guess that these 
bitmap-based subtitles are not too widespread functionality. Even here 
in Finland, only the state-owned YLE is using them; the commercial 
broadcasters are burning the subtitles into the video layer.

In any case, these are very minor problems now; I have an acceptable 
workaround for both. I just thought that I would go the last mile and 
polish a bit more, to prepare for a proper release of softdevice.

While I now understand the VDR and softdevice OSD implementation a 
little better, I still do not fully understand it. Currently, it is a 
bit of a mystery for me what happens when the OSD is closed and the 
screen is cleared. In osd.c I understood that there could be a 
transparent "background pixmap" whose relevant part would be invalidated 
when upper-layer pixmaps or bitmaps get removed. But, will this also 
happen when the whole OSD is closed, or only for closing individual 
"windows"?

Based on the SoftOsd.c debug output and some gdb sessions, it seems to 
me that the cSoftOsd object gets created and destroyed repeatedly, maybe 
every time something is displayed and then hidden again. Is this the 
correct object life cycle? Is there some wiki page or other 
documentation than the source code?

Best regards and thank you for the great work,

	Marko
  
Klaus Schmidinger Nov. 9, 2013, 12:08 p.m. UTC | #3
On 09.11.2013 12:59, Marko Mäkelä wrote:
> On Sat, Nov 09, 2013 at 11:36:55AM +0100, Klaus Schmidinger wrote:
>> I just tried this on my VDR with a TT S2-6400 and there was no such problem. I assume that this is related to the softdevice OSD implementation and not the core VDR.
>
> Thank you for testing, Klaus!
>
> Were you able to test the other problem (the OSD menu becomes fully transparent and then normal again when subtitles would want to update the OSD)?

I have no such problem here. If I open the menu of the channel/progress display while
subtitles are active, no subtitles are displayed while the menu is open and they
continue to be displayed once the menu has been closed again.

>  I can provide a short recording if needed. I guess that these bitmap-based subtitles are not too widespread functionality. Even here in Finland, only
> the state-owned YLE is using them; the commercial broadcasters are burning the subtitles into the video layer.

"burning the subtitles into the video layer" is probably the worst idea ever.
This totally deprives the viewer of the possibility to choose between different
language subtitles or turn them off altogether.
Almost all of the test samples I have here use proper DVB subtitle bitmaps.

> In any case, these are very minor problems now; I have an acceptable workaround for both. I just thought that I would go the last mile and polish a bit more, to prepare for a proper release of softdevice.
>
> While I now understand the VDR and softdevice OSD implementation a little better, I still do not fully understand it. Currently, it is a bit of a mystery for me what happens when the OSD is closed and the screen is cleared. In osd.c I understood that there could be a transparent "background pixmap"
> whose relevant part would be invalidated when upper-layer pixmaps or bitmaps get removed. But, will this also happen when the whole OSD is closed, or only for closing individual "windows"?

When the whole OSD is closed, ther is nothing that gets displayed.

> Based on the SoftOsd.c debug output and some gdb sessions, it seems to me that the cSoftOsd object gets created and destroyed repeatedly, maybe every time something is displayed and then hidden again. Is this the correct object life cycle?

Yes.

> Is there some wiki page or other documentation than the
> source code?

Not to my knowledge.

Klaus
  
Marko Mäkelä Nov. 9, 2013, 1:37 p.m. UTC | #4
Hi Klaus,

>I have no such problem here. If I open the menu of the channel/progress 
>display while subtitles are active, no subtitles are displayed while 
>the menu is open and they continue to be displayed once the menu has 
>been closed again.

OK. The only difference that I am seeing (after disabling the 
dirty_lines[] optimization) that the OSD menu will disappear for less 
than half a second when the subtitles would want to do something. The 
menu would reappear again, and no subtitles are displayed until I close 
the OSD menu. As soon as I close the OSD menu, the subtitles (if any are 
active at that time) would be displayed immediately.

>"burning the subtitles into the video layer" is probably the worst idea 
>ever.

I fully agree. I guess that the commercial broadcasters try to avoid 
"leaking" too much metadata. Or they are just lazy, such as never 
showing the episode number of name of a series in the EPG data. If they 
sent proper subtitles and VPS signals and what not, then commercial 
breaks could be detected easier, without having to decompress and 
interpret the video stream. (Well, I guess there are VDR plugins for 
this; another reason to use VDR instead of some proprietary product.)

Also the state-owned broadcaster YLE is bending the rules a little.  
There usually is a "Dutch" language audio track that contains the 
original audio mixed with a speech synthesizer that is reading the 
Finnish subtitles. More recently, they have started to introduce "Dutch" 
language subtitles that actually are Finnish transcript of the Finnish 
audio track for the hearing impaired.

In any case, this is good service: The same video broadcast can serve 
all audiences. For example, a program that has original audio in N 
languages can be sent with N+M audio tracks and N+M sets of subtitles.  
In the times of the analog TV, the program could be sent in 2 channels, 
once in Swedish and once in Finnish, and that is it.

>When the whole OSD is closed, ther is nothing that gets displayed.

OK, I think I will have to check what is happening around cOsd::~cOsd().  
It could be that Softdevice is simply clearing the OSD layer at wrong 
points of the object lifecycle, in a way that happens to work for 
everything else than subtitles.

Best regards,

	Marko
  
Sami Ketola Nov. 10, 2013, 2:44 p.m. UTC | #5
On Sat, 9 Nov 2013 13:59:51 +0200
Marko Mäkelä <marko.makela@iki.fi> wrote:

> Were you able to test the other problem (the OSD menu becomes fully 
> transparent and then normal again when subtitles would want to update 
> the OSD)? I can provide a short recording if needed. I guess that these 
> bitmap-based subtitles are not too widespread functionality. Even here 
> in Finland, only the state-owned YLE is using them; the commercial 
> broadcasters are burning the subtitles into the video layer.

This is not entirely true. All broadcasters in Finland are using DVB
subtitles except "Nelonen Media" on all their channels and MTV Media 
on "Sub" channel. Yes even MTV3 seems to be DVB subtitled now.

Sami
  
Marko Mäkelä Nov. 10, 2013, 7:34 p.m. UTC | #6
On Sun, Nov 10, 2013 at 04:44:44PM +0200, Sami Ketola wrote:
>This is not entirely true. All broadcasters in Finland are using DVB 
>subtitles except "Nelonen Media" on all their channels and MTV Media on 
>"Sub" channel. Yes even MTV3 seems to be DVB subtitled now.

I must admit that I do not watch TV that much, except now when debugging 
softdevice. :) I was not aware of these very welcome news.

However, I am still seeing "burned" subtitles on the commercial DVB-T 
channels, for example in the currently active MTV3 program 
"Selviytyjät".

	Marko
  
Antti Hartikainen Nov. 10, 2013, 8:31 p.m. UTC | #7
On Sun, Nov 10, 2013 at 09:34:12PM +0200, Marko Mäkelä wrote:
> On Sun, Nov 10, 2013 at 04:44:44PM +0200, Sami Ketola wrote:
> >This is not entirely true. All broadcasters in Finland are using DVB 
> >subtitles except "Nelonen Media" on all their channels and MTV Media on 
> >"Sub" channel. Yes even MTV3 seems to be DVB subtitled now.
> 
> I must admit that I do not watch TV that much, except now when debugging 
> softdevice. :) I was not aware of these very welcome news.
> 
> However, I am still seeing "burned" subtitles on the commercial DVB-T 
> channels, for example in the currently active MTV3 program 
> "Selviytyjät".
> 

Programs spoken in finnish, MTV3 has an option for DVB subtitles in finnish.
  
Marko Mäkelä Nov. 12, 2013, 11:46 a.m. UTC | #8
On Sat, Nov 09, 2013 at 01:57:37AM +0200, Marko Mäkelä wrote:
>(1) The bottom 1% lines of the OSD are not being cleared when the OSD 
>extends that low. (I can choose up to 99% height and 0% vertical 
>offset.)

This looks like a bug in DirectFB or the way how softdevice is using it.  
There is a comment related to Matrox in video-dfb.c, AFAIU related to 
the video layer, not the OSD layer.

I did a short test recording of a 4:3 program. Depending on the 
softdevice crop mode, the garbage area at the bottom shrinks (from about 
3 lines to 1 or even 0).

>(2) Changes in DVB subtitles will flash the OSD layer (make it empty 
>for a very short time) if an OSD is active. I suppose that DVB 
>subtitles should not be displayed at all when OSD layer is active.

This is a bug in SoftOsd.c or in video-dfb.c. The OpenOSD call in the 
cSoftOsd constructor was clearing the OSD layer on the physical screen, 
even when !cOsd::Active(). To fix this, I made cDFBVideoOut::OpenOSD() a 
no-op, or renamed it to cDFBVideoOut::ClearOSD(), which is where this 
clearing should have been done.

I also moved some of the initialization to cSoftOsd::Action(), which 
seems to be a more appropriate place. cSoftOsd derives from both cOsd 
and cThread, to do the intensive work in a background thread.

Now I have some trouble with VDR crashing every now and then when I 
press Recordings or Menu. I fixed most Valgrind warnings in Softdevice, 
so that it is silent when I press buttons to hide or show the OSD. There 
are some warnings left in cRect::Intersects() or similar, seemingly not 
related to softdevice code. I will investigate further.

Also, on VDR 2.0.4 startup, cRecordings::ScanVideoDir() is calling 
cRecording::cRecording(), which according to Valgrind is reading past 
some strdup() buffer. I do have libc6-dbg installed, so I hope it is not 
a false alarm. I only had 2 short test recordings in my video directory, 
so this should be easy to debug, once I rebuild vdr in debug mode. I 
only had debug symbols for softdevice in my session, and I did not yet 
try vgdb-server, which is better for multi-threaded programs.

Best regards,

	Marko
  

Patch

Index: Makefile
===================================================================
RCS file: /cvsroot/softdevice/softdevice/Makefile,v
retrieving revision 1.42
diff -p -u -r1.42 Makefile
--- Makefile	14 Apr 2008 02:52:10 -0000	1.42
+++ Makefile	8 Nov 2013 23:45:33 -0000
@@ -124,7 +124,7 @@  FFMPEGLIBS = -lavcodec -lavformat -lz
 DEFINES	   += -DUSE_MMX
 
 # uncomment this line if you do not have MMX2
-DEFINES	   += -DUSE_MMX2
+#DEFINES	   += -DUSE_MMX2
 
 ### Allow user defined options to overwrite defaults:
 
Index: SoftOsd.c
===================================================================
RCS file: /cvsroot/softdevice/softdevice/SoftOsd.c,v
retrieving revision 1.37
diff -p -u -r1.37 SoftOsd.c
--- SoftOsd.c	17 Apr 2011 16:06:31 -0000	1.37
+++ SoftOsd.c	8 Nov 2013 23:45:34 -0000
@@ -25,7 +25,6 @@ 
 //#define SCALEDEBV(out...) printf(out)
 //#define SCALEDEBH(out...) printf(out)
 
-
 #ifndef OSDDEB
 #define OSDDEB(out...)
 #endif
@@ -55,16 +54,17 @@ 
 #define COLOR_64BIT(x) ( ((x)<<32) | (x) )
 #define ALPHA_VALUE(x) ( (x) << 24 )
 
-// the same constants for MMX mode
+//#undef USE_MMX
+//#undef USE_MMX2
+
+#ifdef USE_MMX2
 static uint64_t transparent_thr= COLOR_64BIT(ALPHA_VALUE(TRANSPARENT_THRESHOLD>>1));
 static uint64_t opacity_thr= COLOR_64BIT(ALPHA_VALUE(OPACITY_THRESHOLD>>1));
 static uint64_t pseudo_transparent = COLOR_64BIT(COLOR_KEY);
+#endif // USE_MMX2
 
 int cSoftOsd::colorkey;
 
-//#undef USE_MMX
-//#undef USE_MMX2
-
 #undef SPLAT_U16
 #ifdef USE_MMX2
 #define SPLAT_U16(X)   " pshufw $0b0, " X ", " X " \n"
@@ -85,7 +85,7 @@  cSoftOsd::cSoftOsd(cVideoOut *VideoOut, 
         OSDDEB("cSoftOsd constructor\n");
         OutputConvert=&cSoftOsd::ARGB_to_ARGB32;
         bitmap_Format=PF_None; // forces a clear after first SetMode
-        OSD_Bitmap=new uint32_t[OSD_STRIDE*(OSD_HEIGHT+4)];
+        OSD_Bitmap=new tColor[OSD_STRIDE*(OSD_HEIGHT+4)];
 
         videoOut = VideoOut;
         xPan = yPan = 0;
@@ -93,9 +93,10 @@  cSoftOsd::cSoftOsd(cVideoOut *VideoOut, 
         voutMutex.Lock();
         videoOut->OpenOSD();
         colorkey=videoOut->GetOSDColorkey();
+#ifdef USE_MMX2
         pseudo_transparent=(uint64_t)colorkey | ((uint64_t) colorkey)<<32;
+#endif // USE_MMX2
 
-        xOfs=X;yOfs=Y;
         ScreenOsdWidth=ScreenOsdHeight=0;
         int Depth=16; bool HasAlpha=false; bool AlphaInversed=false;
         bool IsYUV=false;
@@ -108,16 +109,21 @@  cSoftOsd::cSoftOsd(cVideoOut *VideoOut, 
 /*--------------------------------------------------------------------------*/
 void cSoftOsd::Clear() {
         OSDDEB("Clear\n");
-        uint32_t blank=0x00000000; //COLOR_KEY;
+        tColor blank=tColor(COLOR_KEY);
         ConvertPalette((tColor *)&blank,(tColor *)&blank,1);
 
         register uint32_t fill=blank;
-        for (int i=OSD_STRIDE*(OSD_HEIGHT+2)-1; i!=0; i--)
-                OSD_Bitmap[i]=fill;
-        OSD_Bitmap[0]=fill;
 
-        // no dirty lines, everything has to be redrawn anyway
-        memset(dirty_lines,false,sizeof(dirty_lines));
+        if (fill == (fill & 0xff) * 0x1010101) {
+                memset(OSD_Bitmap, fill,
+                       OSD_STRIDE*(OSD_HEIGHT+4) * sizeof *OSD_Bitmap);
+        } else {
+                register tColor *b=OSD_Bitmap;
+                register const tColor *const e=b + OSD_STRIDE*(OSD_HEIGHT+4);
+                while (b < e) *b++=fill;
+        }
+
+        memset(dirty_lines,true,sizeof(dirty_lines));
 }
 
 /* --------------------------------------------------------------------------*/
@@ -385,8 +391,16 @@  bool cSoftOsd::FlushBitmaps(bool OnlyDir
         bool OSD_changed=false;
         OSDDEB("FlushBitmaps (OnlyDirty: %d)\n",OnlyDirty);
 
-        for (int i = 0; (Bitmap = GetBitmap(i)) != NULL; i++) {
-                OSD_changed |= DrawConvertBitmap(Bitmap,OnlyDirty);
+        if (IsTrueColor()) {
+                LOCK_PIXMAPS;
+                while (cPixmapMemory *pm = RenderPixmaps()) {
+                        OSD_changed |= DrawConvertPixmap(pm);
+                        delete pm;
+                }
+        } else {
+                for (int i = 0; (Bitmap = GetBitmap(i)) != NULL; i++) {
+                        OSD_changed |= DrawConvertBitmap(Bitmap,OnlyDirty);
+                }
         }
         return OSD_changed;
 };
@@ -435,7 +449,7 @@  bool cSoftOsd::DrawConvertBitmap(cBitmap
         cMutexLock dirty(&dirty_Mutex);
         OSDDEB("DrawConvertBitmap %p, OnlyDirty %d\n",bitmap,OnlyDirty);
 
-        if ( !bitmap->Dirty(x1,y1,x2,y2) && OnlyDirty)
+        if (OnlyDirty && !bitmap->Dirty(x1,y1,x2,y2))
                 return false;
 
         if (!OnlyDirty) {
@@ -458,14 +472,14 @@  bool cSoftOsd::DrawConvertBitmap(cBitmap
 
         y2++;
         x2++;
-        y2= yOfs+y2+bitmap->Y0() > OSD_HEIGHT ?
-                OSD_HEIGHT-bitmap->Y0()-yOfs : y2;
-        x2= xOfs+x2+bitmap->X0() > OSD_WIDTH ?
-                OSD_WIDTH-bitmap->X0()-xOfs : x2;
+        y2= Top()+y2+bitmap->Y0() > OSD_HEIGHT ?
+                OSD_HEIGHT-bitmap->Y0()-Top() : y2;
+        x2= Left()+x2+bitmap->X0() > OSD_WIDTH ?
+                OSD_WIDTH-bitmap->X0()-Left() : x2;
 
-        int bitmap_yOfs=yOfs+bitmap->Y0()+Y_OFFSET;
+        int bitmap_yOfs=Top()+bitmap->Y0();
         uint32_t *OSD_pointer=&OSD_Bitmap[(bitmap_yOfs+y1)*OSD_STRIDE+
-                xOfs+bitmap->X0()+x1+X_OFFSET];
+                Left()+bitmap->X0()+x1];
         int missing_line_length=OSD_STRIDE-(x2-x1);
         bool *dirty_line=&dirty_lines[bitmap_yOfs+y1];
 
@@ -480,6 +494,42 @@  bool cSoftOsd::DrawConvertBitmap(cBitmap
         return true;
 };
 
+bool cSoftOsd::DrawConvertPixmap(cPixmapMemory *pm)
+{
+        int x1,x2,y1,y2;
+        const tColor *src=reinterpret_cast<const tColor*>(pm->Data());
+        OSDDEB("DrawConvertPixmap %p\n",pm);
+
+        x1=Left();
+        y1=Top();
+
+        x1+=pm->ViewPort().X();
+        x2=x1 + pm->ViewPort().Width();
+        y1+=pm->ViewPort().Y();
+        y2=y1 + pm->ViewPort().Height();
+        src+=pm->DrawPort().X() + pm->DrawPort().Y() * pm->DrawPort().Width();
+
+        OSDDEB("drawing pixmap %p from (%d,%d) to (%d,%d)\n",
+                        pm,x1,y1,x2,y2);
+
+        if (y1 > OSD_HEIGHT) y1=OSD_HEIGHT;
+        if (x1 > OSD_WIDTH) x1=OSD_WIDTH;
+        if (y2 > OSD_HEIGHT) y2=OSD_HEIGHT;
+        if (x2 > OSD_WIDTH) x2=OSD_WIDTH;
+
+        cMutexLock dirty(&dirty_Mutex);
+
+        tColor *dst=&OSD_Bitmap[y1*OSD_STRIDE+x1];
+
+        for (int y=y1; y<y2; dirty_lines[y++] = true) {
+                memcpy(dst, src, (x2 - x1) * sizeof(tColor));
+                src += pm->DrawPort().Width();
+                dst += OSD_STRIDE;
+        }
+
+        return y1 != y2;
+}
+
 /*----------------------------------------------------------------------*/
 
 void cSoftOsd::ARGB_to_AYUV(uint32_t * dest, color * pixmap, int Pixel) {
@@ -1149,13 +1199,13 @@  void cSoftOsd::NoVScaleCopyToBitmap(uint
                 dest_Stride=OSD_STRIDE;
 
         for (int y=0; y<dest_Height; y+=2) {
-
+#if 0
                 int is_dirty=RefreshAll;
                 is_dirty |= dirty_lines[y] || dirty_lines[y+1];
 
                 if (!is_dirty)
                         continue;
-
+#endif
                 if (dest_Width==OSD_WIDTH) {
                         tmp_pixmap=&pixmap[y*OSD_STRIDE];
                 } else {
@@ -1202,7 +1252,6 @@  void cSoftOsd::ScaleVDownCopyToBitmap(ui
                 FlushBitmaps(false);
         };
 
-        cMutexLock dirty(&dirty_Mutex);
         color *pixmap=(color*) OSD_Bitmap;
         color tmp_pixmap[2*OSD_STRIDE];
         uint8_t *pY;uint8_t *pU;uint8_t *pV;
@@ -1227,14 +1276,14 @@  void cSoftOsd::ScaleVDownCopyToBitmap(ui
                 int start_row=new_pixel_height*y/ScaleFactor;
                 int32_t start_pos=new_pixel_height*y%ScaleFactor-ScaleFactor;
                 //int32_t start_pos=new_pixel_height*y-ScaleFactor*(start_row+1);
-
+#if 0
                 int is_dirty=RefreshAll;
                 for (int i=0; i<lines_count; i++)
                         is_dirty|=dirty_lines[start_row+i];
 
                 if (!is_dirty)
                         continue;
-
+#endif
                 scaleH_strtIdx=SCALEH_IDX(lines_count-2);
                 for (int i=0; i<lines_count; i++) {
                         scaleH_Reference[i]=&scaleH_pixmap[SCALEH_IDX(i)*OSD_STRIDE];
@@ -1322,7 +1371,6 @@  void cSoftOsd::ScaleVUpCopyToBitmap(uint
                 FlushBitmaps(false);
         };
 
-        cMutexLock dirty(&dirty_Mutex);
         const int dest_stride=(dest_Width+32)&~0xF;
         void (cSoftOsd::*ScaleHoriz)(uint32_t * dest, int dest_Width, color * pixmap,int Pixel);
         ScaleHoriz= dest_Width<OSD_WIDTH ? &cSoftOsd::ScaleDownHoriz_MMX :
@@ -1348,13 +1396,13 @@  void cSoftOsd::ScaleVUpCopyToBitmap(uint
 
         for (int y=0; y<dest_Height; y++) {
                 int start_row=new_pixel_height*y/ScaleFactor;
-
+#if 0
                 int is_dirty=RefreshAll;
                 is_dirty|=dirty_lines[start_row] | dirty_lines[start_row+1];
 
                 if (!is_dirty)
                         continue;
-
+#endif
                 int32_t start_pos=new_pixel_height*y%ScaleFactor;
                 //int32_t start_pos=new_pixel_height*y-ScaleFactor*(start_row+1);
                 //printf("Scaling to line %d from start_row: %d start_pos %d\n",
@@ -1434,10 +1482,10 @@  void cSoftOsd::NoVScaleCopyToBitmap(uint
                 &cSoftOsd::ScaleUpHoriz_MMX;
 
         for (int y=0; y<OSD_HEIGHT; y++) {
-
+#if 0
                 if (!RefreshAll && !dirty_lines[y])
                         continue;
-
+#endif
                 if (dest_Width==OSD_WIDTH) {
                         tmp_pixmap=&pixmap[y*OSD_STRIDE];
                 } else {
@@ -1495,14 +1543,14 @@  void cSoftOsd::ScaleVDownCopyToBitmap(ui
 
         for (int y=0; y<dest_Height; y++) {
                 int start_row=new_pixel_height*y/ScaleFactor;
-
+#if 0
                 int is_dirty=RefreshAll;
                 for (int i=0; i<lines_count; i++)
                         is_dirty|=dirty_lines[start_row+i];
 
                 if (!is_dirty)
                         continue;
-
+#endif
                 int32_t start_pos=new_pixel_height*y%ScaleFactor-ScaleFactor;
                 //int32_t start_pos=new_pixel_height*y-ScaleFactor*(start_row+1);
                 //printf("Scaling to line %d from start_row: %d lines_count %d\n",
Index: SoftOsd.h
===================================================================
RCS file: /cvsroot/softdevice/softdevice/SoftOsd.h,v
retrieving revision 1.21
diff -p -u -r1.21 SoftOsd.h
--- SoftOsd.h	17 Apr 2011 17:22:18 -0000	1.21
+++ SoftOsd.h	8 Nov 2013 23:45:34 -0000
@@ -17,11 +17,11 @@ 
 #include <vdr/thread.h>
 
 // osd some constants and macros
-#define OPACITY_THRESHOLD 0x9FLL
-#define TRANSPARENT_THRESHOLD 0x1FLL
+#define OPACITY_THRESHOLD 0x1FLL
+#define TRANSPARENT_THRESHOLD 0x0FLL
 #define COLOR_KEY 0x00000000LL
 
-#if VDRVERSNUM <= 10707
+#if 1//VDRVERSNUM <= 10707
 
 #define OSD_WIDTH   720
 #define OSD_HEIGHT  576
@@ -35,18 +35,11 @@ 
 
 #endif
 
-#define IS_BACKGROUND(a) (((a) < OPACITY_THRESHOLD) && ((a) > TRANSPARENT_THRESHOLD))
+#define IS_BACKGROUND(a) (((a) < OPACITY_THRESHOLD) && ((a) >= TRANSPARENT_THRESHOLD))
 #define IS_TRANSPARENT(a) ((a) < TRANSPARENT_THRESHOLD)
-#define IS_OPAQUE(a) ((a) > OPACITY_THRESHOLD)
 
 #include "video.h"
 
-#define X_OFFSET 0
-#define Y_OFFSET 0
-
-
-#define COLOR_RGB16(r,g,b) (((b >> 3)& 0x1F) | ((g & 0xF8) << 2)| ((r & 0xF8)<<10) )
-
 #define GET_A(x) ((x) >> 24 & 0xFF)
 #define GET_R(x) ((x) >> 16 & 0xFF)
 #define GET_G(x) ((x) >>  8 & 0xFF)
@@ -56,15 +49,8 @@ 
 #define SET_R(x) ((x) << 16 & 0x00FF0000)
 #define SET_G(x) ((x) <<  8 & 0x0000FF00)
 #define SET_B(x) ((x) <<  0 & 0x000000FF)
-/*
-struct color {
-    unsigned char b;
-    unsigned char g;
-    unsigned char r;
-    unsigned char a;
-};
-*/
-typedef uint32_t color;
+
+typedef tColor color;
 
 class cVideoOut;
 
@@ -76,11 +62,10 @@  private:
     cVideoOut *videoOut;
 protected:
     static int colorkey;
-    int      xOfs, yOfs;
     int      xPan, yPan;
-    uint32_t *OSD_Bitmap;
     bool dirty_lines[OSD_HEIGHT+10];
     cMutex dirty_Mutex;
+    tColor*  OSD_Bitmap;
 
     void (*OutputConvert)(uint8_t * dest, color * pixmap, int Pixel, int odd);
     enum PixFormat {
@@ -126,6 +111,7 @@  protected:
 
     bool FlushBitmaps(bool OnlyDirty);
     bool DrawConvertBitmap(cBitmap *Bitmap, bool OnlyDirty);
+    bool DrawConvertPixmap(cPixmapMemory* pm);
 
     void OsdCommit(bool forced = false);
     // may only be called if the caller holds voutMutex
Index: VideoFilter.c
===================================================================
RCS file: /cvsroot/softdevice/softdevice/VideoFilter.c,v
retrieving revision 1.11
diff -p -u -r1.11 VideoFilter.c
--- VideoFilter.c	18 Apr 2008 15:10:35 -0000	1.11
+++ VideoFilter.c	8 Nov 2013 23:45:34 -0000
@@ -286,7 +286,7 @@  void cImageConvert::Filter(sPicBuffer *&
 #ifdef USE_SWSCALE
        sws_scale(img_convert_ctx, avpic_src.data, avpic_src.linesize,
                         0, orig->height, avpic_dest.data, avpic_dest.linesize);
-#else
+#elif 0
         if (img_convert(&avpic_dest,PIX_FMT_YUV420P,
                                 &avpic_src, orig->format,
                                 orig->width, orig->height) < 0) {
@@ -295,6 +295,9 @@  void cImageConvert::Filter(sPicBuffer *&
                                 "[softdevice] error, libavcodec img_convert failure\n");
                 return;
         }
+#else
+	dest = orig;
+	return;
 #endif
         CopyPicBufferContext(dest,orig);
 }
Index: configure
===================================================================
RCS file: /cvsroot/softdevice/softdevice/configure,v
retrieving revision 1.50
diff -p -u -r1.50 configure
--- configure	21 Sep 2008 12:55:57 -0000	1.50
+++ configure	8 Nov 2013 23:45:34 -0000
@@ -218,7 +218,7 @@  if test "${use_pkgconfig}" = "yes" ; the
   if test "${ffmpeg_use_path}" = "no" ; then
 
 echo "try to use pkg-config." >> config.log
-ffmpeg_l1="libavformat libavcodec"
+ffmpeg_l1="libavformat libavcodec libavutil zlib"
 
 pkg-config --libs libpostproc >> config.log 2>&1 && { ffmpeg_l1="$ffmpeg_l1 libpostproc";libpostproc="yes"; }
 
Index: i18n.c
===================================================================
RCS file: /cvsroot/softdevice/softdevice/i18n.c,v
retrieving revision 1.25
diff -p -u -r1.25 i18n.c
--- i18n.c	14 Apr 2008 02:28:09 -0000	1.25
+++ i18n.c	8 Nov 2013 23:45:35 -0000
@@ -7,6 +7,7 @@ 
  */
 
 #include "i18n.h"
+#if 0
 
 const tI18nPhrase Phrases[] = {
   { "Softdevice",   //  1
@@ -1343,3 +1344,4 @@  const tI18nPhrase Phrases[] = {
   },
   { NULL }
   };
+#endif
Index: i18n.h
===================================================================
RCS file: /cvsroot/softdevice/softdevice/i18n.h,v
retrieving revision 1.1.1.1
diff -p -u -r1.1.1.1 i18n.h
--- i18n.h	1 Aug 2004 05:07:04 -0000	1.1.1.1
+++ i18n.h	8 Nov 2013 23:45:35 -0000
@@ -11,6 +11,4 @@ 
 
 #include <vdr/i18n.h>
 
-extern const tI18nPhrase Phrases[];
-
 #endif //_I18N__H
Index: mpeg2decoder.c
===================================================================
RCS file: /cvsroot/softdevice/softdevice/mpeg2decoder.c,v
retrieving revision 1.90
diff -p -u -r1.90 mpeg2decoder.c
--- mpeg2decoder.c	17 Apr 2011 17:22:18 -0000	1.90
+++ mpeg2decoder.c	8 Nov 2013 23:45:35 -0000
@@ -162,7 +162,7 @@  cStreamDecoder::cStreamDecoder(AVCodecCo
 #if HAS_ERROR_RECOGNITION
         context->error_recognition=1;
 #else
-        context->error_resilience=1;
+        context->error_concealment=1;
 #endif
   CMDDEB("Neuer StreamDecoder Pid: %d context %p type %d\n",
         getpid(),context,context->codec_type );
Index: shm-common.h
===================================================================
RCS file: /cvsroot/softdevice/softdevice/shm-common.h,v
retrieving revision 1.9
diff -p -u -r1.9 shm-common.h
--- shm-common.h	10 May 2007 19:49:51 -0000	1.9
+++ shm-common.h	8 Nov 2013 23:45:35 -0000
@@ -81,14 +81,14 @@  struct ShmCtlBlock {
         int setup_shmid;
 };
 
-inline void sem_wait_lock(int semid, int idx, int flag=0) 
+inline void sem_wait_lock(int semid, unsigned short idx, short int flag=0) 
 {
         struct sembuf sem_op = { idx, -1, flag };
         
         semop(semid, &sem_op,1);
 };
 
-inline void sem_sig_unlock(int semid, int idx,int flag=0) 
+inline void sem_sig_unlock(int semid, unsigned short idx, short int flag=0) 
 {
         struct sembuf sem_op = { idx, 1, flag };
         
Index: softdevice.c
===================================================================
RCS file: /cvsroot/softdevice/softdevice/softdevice.c,v
retrieving revision 1.99
diff -p -u -r1.99 softdevice.c
--- softdevice.c	17 Apr 2011 17:22:19 -0000	1.99
+++ softdevice.c	8 Nov 2013 23:45:36 -0000
@@ -1306,7 +1306,7 @@  bool cPluginSoftDevice::Service(const ch
 bool cPluginSoftDevice::Start(void)
 {
   // Start any background activities the plugin shall perform.
-  RegisterI18n(Phrases);
+  I18nRegister("softdevice");
   return true;
 }
 
Index: video.h
===================================================================
RCS file: /cvsroot/softdevice/softdevice/video.h,v
retrieving revision 1.60
diff -p -u -r1.60 video.h
--- video.h	17 Apr 2011 17:22:19 -0000	1.60
+++ video.h	8 Nov 2013 23:45:36 -0000
@@ -28,7 +28,7 @@ 
 #define DV_FORMAT_NORMAL  1
 #define DV_FORMAT_WIDE    2
 
-#if  VDRVERSNUM <= 10707
+#if 1//VDRVERSNUM <= 10707
 
 #define OSD_FULL_WIDTH    736
 #define OSD_FULL_HEIGHT   576