From patchwork Fri Nov 8 23:57:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWFya28gTcOka2Vsw6Q=?= X-Patchwork-Id: 20702 Received: from localhost ([127.0.0.1] helo=www.linuxtv.org) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1VevwJ-0002KG-AV; Sat, 09 Nov 2013 00:58:11 +0100 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1Vevvp-0002Jq-Vj for vdr@linuxtv.org; Sat, 09 Nov 2013 00:58:07 +0100 X-tubIT-Incoming-IP: 62.142.5.116 Received: from emh06.mail.saunalahti.fi ([62.142.5.116]) by mail.tu-berlin.de (exim-4.72/mailfrontend-6) with esmtps [TLSv1:AES256-SHA:256] for id 1Vevvo-0003en-4Y; Sat, 09 Nov 2013 00:57:41 +0100 Received: from localhost (a88-115-111-196.elisa-laajakaista.fi [88.115.111.196]) by emh06.mail.saunalahti.fi (Postfix) with ESMTP id 5979A69973 for ; Sat, 9 Nov 2013 01:57:37 +0200 (EET) Date: Sat, 9 Nov 2013 01:57:37 +0200 From: Marko =?iso-8859-1?B?TeRrZWzk?= To: VDR Mailing List Message-ID: <20131108235737.GA3937@x220> References: <20131101211948.GB4509@x220> <20131103200154.GA3987@x220> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2013.11.8.234814 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' RCVD_FROM_IP_DATE 0.1, HTML_00_01 0.05, HTML_00_10 0.05, MIME_TEXT_ONLY_MP_MIXED 0.05, MSGID_ADDED_BY_MTA 0.05, BODY_SIZE_10000_PLUS 0, INVALID_MSGID_NO_FQDN 0, NO_URI_FOUND 0, __CD 0, __CP_MEDIA_BODY 0, __CT 0, __CTE 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_MIXED 0, __HAS_FROM 0, __HAS_MSGID 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __USER_AGENT 0' X-LSpam-Score: -1.1 (-) X-LSpam-Report: No, score=-1.1 required=5.0 tests=BAYES_00=-1.9, RDNS_NONE=0.793 autolearn=no Subject: [vdr] OSD and subtitles trouble X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: vdr-bounces@linuxtv.org Errors-To: vdr-bounces@linuxtv.org 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 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(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; yDrawPort().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 // 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 -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