From 03bb623280276979de938da5cdb4ab8c59159666 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 14 Mar 2012 19:49:59 +0100 Subject: [PATCH] dvbsub: fix scaling Scale subtitles to full FB size, disregard OSD setup area. Reason: the video decoder plane also does not consider OSD setup and subtitles should align with video. Additionally, subtitles were too narrow. TODO: what about letterboxed formats? Not handled yet. Code is experimental, thus the original is #if 0'ed out only. Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/b6eb045c9bdb19549331b1c47c550540a02658b5 Author: Stefan Seyfried Date: 2012-03-14 (Wed, 14 Mar 2012) ------------------ This commit was generated by Migit --- lib/libdvbsub/dvbsubtitle.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/libdvbsub/dvbsubtitle.cpp b/lib/libdvbsub/dvbsubtitle.cpp index 961884b1a..340e91d05 100644 --- a/lib/libdvbsub/dvbsubtitle.cpp +++ b/lib/libdvbsub/dvbsubtitle.cpp @@ -110,10 +110,14 @@ void cDvbSubtitleBitmaps::Draw(int &min_x, int &min_y, int &max_x, int &max_y) // dbgconverter("cDvbSubtitleBitmaps::Draw: %d bitmaps, x= %d, width= %d yend=%d stride %d\n", Count(), xstart, wd, yend, stride); + int sw = CFrameBuffer::getInstance()->getScreenWidth(true); + int sh = CFrameBuffer::getInstance()->getScreenHeight(true); +#if 0 double xc = (double) CFrameBuffer::getInstance()->getScreenWidth(true)/(double) 720; double yc = (double) CFrameBuffer::getInstance()->getScreenHeight(true)/(double) 576; xc = yc; //FIXME should we scale also to full width ? int xf = xc * (double) 720; +#endif for (i = 0; i < Count(); i++) { uint32_t * colors = (uint32_t *) sub.rects[i]->pict.data[1]; @@ -121,6 +125,7 @@ void cDvbSubtitleBitmaps::Draw(int &min_x, int &min_y, int &max_x, int &max_y) int height = sub.rects[i]->h; int xoff, yoff; +#if 0 int nw = width == 1280 ? ((double) width / xc) : ((double) width * xc); int nh = (double) height * yc; @@ -133,6 +138,12 @@ void cDvbSubtitleBitmaps::Draw(int &min_x, int &min_y, int &max_x, int &max_y) if(yoff < ystart) yoff = ystart; } +#endif + int h2 = (width == 1280) ? 720 : 576; + xoff = sub.rects[i]->x * sw / width; + yoff = sub.rects[i]->y * sh / h2; + int nw = width * sw / width; + int nh = height * sh / h2; // dbgconverter("cDvbSubtitleBitmaps::Draw: #%d at %d,%d size %dx%d colors %d (x=%d y=%d w=%d h=%d) \n", i+1, // sub.rects[i]->x, sub.rects[i]->y, sub.rects[i]->w, sub.rects[i]->h, sub.rects[i]->nb_colors, xoff, yoff, nw, nh);