From 8b9350c091bc5ae8c9bb30b83a1fb567c3a7cb7f Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 17 Apr 2011 16:50:00 +0200 Subject: =?UTF-8?q?Version=201.7.18=20-=20Changed=20-O2=20to=20-O3=20in=20?= =?UTF-8?q?Make.config.template=20(reported=20by=20Matti=20Lehtim=C3=A4ki)?= =?UTF-8?q?.=20-=20Added=20a=20missing=20'default'=20case=20in=20cPixmapMe?= =?UTF-8?q?mory::DrawEllipse().=20-=20Fixed=20some=20direct=20comparisons?= =?UTF-8?q?=20of=20double=20values.=20-=20Fixed=20detecting=20frames=20on?= =?UTF-8?q?=20channels=20that=20broadcast=20with=20separate=20"fields"=20i?= =?UTF-8?q?nstead=20=20=20of=20complete=20frames.=20-=20Made=20updating=20?= =?UTF-8?q?the=20editing=20marks=20during=20replay=20react=20faster=20in?= =?UTF-8?q?=20case=20the=20marks=20=20=20file=20has=20just=20been=20writte?= =?UTF-8?q?n=20(with=20a=20patch=20from=20Udo=20Richter).=20-=20Fixed=20ho?= =?UTF-8?q?rizontal=20scaling=20of=20subtitles=20(reported=20by=20Reinhard?= =?UTF-8?q?=20Nissl).=20-=20Stripped=20the=20note=20"The=20data=20returned?= =?UTF-8?q?=20by=20this=20function=20is=20only=20used=20for=20informationa?= =?UTF-8?q?l=20=20=20purposes=20(if=20any)"=20from=20the=20description=20o?= =?UTF-8?q?f=20cDevice::GetVideoSize().=20The=20VideoAspect=20=20=20is=20n?= =?UTF-8?q?ow=20used=20to=20properly=20scale=20subtitles.=20-=20Fixed=20cU?= =?UTF-8?q?nbufferedFile::Seek()=20in=20case=20it=20is=20compiled=20withou?= =?UTF-8?q?t=20USE=5FFADVISE=20(thanks=20=20=20to=20Juergen=20Lock).=20-?= =?UTF-8?q?=20Fixed=20the=20Language=20header=20of=20the=20Serbian=20trans?= =?UTF-8?q?lation=20file=20(thanks=20to=20Ville=20Skytt=C3=A4).=20-=20Adde?= =?UTF-8?q?d=20anti-aliasing=20when=20upscaling=20bitmaps,=20which=20impro?= =?UTF-8?q?ves=20the=20display=20of=20SD=20subtitles=20=20=20when=20replay?= =?UTF-8?q?ed=20on=20an=20HD=20OSD=20(thanks=20to=20Reinhard=20Nissl=20for?= =?UTF-8?q?=20his=20help=20in=20debugging).=20-=20Renamed=20cBitmap::Scale?= =?UTF-8?q?()=20to=20Scaled(),=20because=20it=20doesn't=20modify=20the=20b?= =?UTF-8?q?itmap=20itself,=20=20=20but=20rather=20returns=20a=20scaled=20c?= =?UTF-8?q?opy.=20-=20Fixed=20the=20description=20of=20cReceiver=20in=20PL?= =?UTF-8?q?UGINS.html,=20regarding=20detaching=20a=20receiver=20=20=20from?= =?UTF-8?q?=20its=20device=20before=20deleting=20it=20(reported=20by=20Win?= =?UTF-8?q?fried=20K=C3=B6hler).=20This=20change=20in=20=20=20behavior=20w?= =?UTF-8?q?as=20introduced=20in=20version=201.5.7.=20-=20Fixed=20scaling?= =?UTF-8?q?=20subtitles=20in=20case=20the=20OSD=20size=20is=20exactly=20th?= =?UTF-8?q?e=20same=20as=20the=20display=20=20=20size=20of=20the=20subtitl?= =?UTF-8?q?es.=20-=20Added=20a=20missing=20initialization=20to=20sDvbSpuRe?= =?UTF-8?q?ct=20(reported=20by=20Sergiu=20Dotenco).=20-=20Replaced=20"%lld?= =?UTF-8?q?"=20and=20"%llX"=20print=20format=20specifiers=20with=20"PRId64?= =?UTF-8?q?"=20and=20"PRIX64"=20to=20=20=20avoid=20compiler=20warnings=20w?= =?UTF-8?q?ith=20gcc=204.5.2=20(thanks=20to=20Sergiu=20Dotenco).=20=20=20O?= =?UTF-8?q?n=20a=20personal=20note:=20I=20find=20it=20a=20step=20in=20the?= =?UTF-8?q?=20totally=20wrong=20direction=20that=20there=20=20=20have=20be?= =?UTF-8?q?en=20macros=20introduced=20to=20work=20around=20this=20problem?= =?UTF-8?q?=20in=20the=20first=20place.=20There=20=20=20should=20have=20be?= =?UTF-8?q?en=20"real"=20format=20specifiers=20defined=20that=20address=20?= =?UTF-8?q?this.=20These=20macros=20=20=20are=20nothing=20but=20an=20ugly?= =?UTF-8?q?=20workaround.=20-=20Added=20Cancel(3)=20to=20~cTrueColorDemo()?= =?UTF-8?q?=20in=20the=20"osddemo"=20plugin=20(thanks=20to=20Reinhard=20Ni?= =?UTF-8?q?ssl).=20-=20Added=20a=20missing=20font=20deletion=20in=20cTrueC?= =?UTF-8?q?olorDemo::Action()=20in=20the=20"osddemo"=20plugin=20=20=20(tha?= =?UTF-8?q?nks=20to=20Reinhard=20Nissl).=20-=20Fixed=20a=20buffer=20overfl?= =?UTF-8?q?ow=20in=20cFont::Bidi()=20(thanks=20to=20Reinhard=20Nissl).=20-?= =?UTF-8?q?=20Added=20HD=20stream=20content=20identifiers=20to=20vdr.5=20(?= =?UTF-8?q?thanks=20to=20Christoph=20Haubrich).=20-=20Made=20cRecordingInf?= =?UTF-8?q?o::Read(FILE=20*f)=20private=20to=20avoid=20calls=20to=20it=20f?= =?UTF-8?q?rom=20outside=20=20=20cRecordingInfo=20or=20cRecording=20(repor?= =?UTF-8?q?ted=20by=20Mika=20Laitio).=20-=20The=20dvbhddevice=20plugin=20i?= =?UTF-8?q?s=20now=20part=20of=20the=20VDR=20distribution=20archive=20(tha?= =?UTF-8?q?nks=20to=20=20=20Andreas=20Regel).=20-=20Removed=20an=20obsolet?= =?UTF-8?q?e=20local=20variable=20in=20dvbsdffosd.c=20(thanks=20to=20Paul?= =?UTF-8?q?=20Menzel).=20-=20Fixed=20a=20possible=20NULL=20pointer=20deref?= =?UTF-8?q?erence=20in=20osddemo.c=20(reported=20by=20Paul=20Menzel).=20-?= =?UTF-8?q?=20Now=20using=20pkg-config=20to=20get=20fribidi,=20freetype=20?= =?UTF-8?q?and=20fontconfig=20cflags=20and=20libs=20(thanks=20=20=20to=20V?= =?UTF-8?q?ille=20Skytt=C3=A4).=20-=20The=20Makefile=20now=20also=20instal?= =?UTF-8?q?ls=20the=20include=20files=20(thanks=20to=20Ville=20Skytt=C3=A4?= =?UTF-8?q?).=20-=20Added=20handling=20of=20"ANSI/SCTE=2057"=20descriptors?= =?UTF-8?q?=20(thanks=20too=20Rolf=20Ahrenberg).=20-=20Avoiding=20an=20une?= =?UTF-8?q?cessary=20call=20to=20Recordings.ResetResume()=20(thanks=20to?= =?UTF-8?q?=20Reinhard=20=20=20Nissl).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dvbsubtitle.c | 84 ++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 32 deletions(-) (limited to 'dvbsubtitle.c') diff --git a/dvbsubtitle.c b/dvbsubtitle.c index c1a0a0c..de1cd1c 100644 --- a/dvbsubtitle.c +++ b/dvbsubtitle.c @@ -7,10 +7,13 @@ * Original author: Marco Schlüßler * With some input from the "subtitle plugin" by Pekka Virtanen * - * $Id: dvbsubtitle.c 2.11 2011/03/12 15:13:03 kls Exp $ + * $Id: dvbsubtitle.c 2.17 2011/04/17 14:34:05 kls Exp $ */ + #include "dvbsubtitle.h" +#define __STDC_FORMAT_MACROS // Required for format specifiers +#include #include "device.h" #define PAGE_COMPOSITION_SEGMENT 0x10 @@ -420,7 +423,7 @@ public: int PageId(void) { return pageId; } int Version(void) { return version; } int State(void) { return state; } - tArea *GetAreas(double Factor); + tArea *GetAreas(double FactorX, double FactorY); cSubtitleClut *GetClutById(int ClutId, bool New = false); cSubtitleObject *GetObjectById(int ObjectId); cSubtitleRegion *GetRegionById(int RegionId, bool New = false); @@ -446,16 +449,16 @@ cDvbSubtitlePage::~cDvbSubtitlePage() { } -tArea *cDvbSubtitlePage::GetAreas(double Factor) +tArea *cDvbSubtitlePage::GetAreas(double FactorX, double FactorY) { if (regions.Count() > 0) { tArea *Areas = new tArea[regions.Count()]; tArea *a = Areas; for (cSubtitleRegion *sr = regions.First(); sr; sr = regions.Next(sr)) { - a->x1 = int(round(Factor * sr->HorizontalAddress())); - a->y1 = int(round(Factor * sr->VerticalAddress())); - a->x2 = int(round(Factor * (sr->HorizontalAddress() + sr->Width() - 1))); - a->y2 = int(round(Factor * (sr->VerticalAddress() + sr->Height() - 1))); + a->x1 = int(round(FactorX * sr->HorizontalAddress())); + a->y1 = int(round(FactorY * sr->VerticalAddress())); + a->x2 = int(round(FactorX * (sr->HorizontalAddress() + sr->Width() - 1))); + a->y2 = int(round(FactorY * (sr->VerticalAddress() + sr->Height() - 1))); a->bpp = sr->Bpp(); while ((a->Width() & 3) != 0) a->x2++; // aligns width to a multiple of 4, so 2, 4 and 8 bpp will work @@ -616,10 +619,11 @@ private: int timeout; tArea *areas; int numAreas; - double osdFactor; + double osdFactorX; + double osdFactorY; cVector bitmaps; public: - cDvbSubtitleBitmaps(int64_t Pts, int Timeout, tArea *Areas, int NumAreas, double OsdFactor); + cDvbSubtitleBitmaps(int64_t Pts, int Timeout, tArea *Areas, int NumAreas, double OsdFactorX, double OsdFactorY); ~cDvbSubtitleBitmaps(); int64_t Pts(void) { return pts; } int Timeout(void) { return timeout; } @@ -627,13 +631,14 @@ public: void Draw(cOsd *Osd); }; -cDvbSubtitleBitmaps::cDvbSubtitleBitmaps(int64_t Pts, int Timeout, tArea *Areas, int NumAreas, double OsdFactor) +cDvbSubtitleBitmaps::cDvbSubtitleBitmaps(int64_t Pts, int Timeout, tArea *Areas, int NumAreas, double OsdFactorX, double OsdFactorY) { pts = Pts; timeout = Timeout; areas = Areas; numAreas = NumAreas; - osdFactor = OsdFactor; + osdFactorX = OsdFactorX; + osdFactorY = OsdFactorY; } cDvbSubtitleBitmaps::~cDvbSubtitleBitmaps() @@ -650,12 +655,27 @@ void cDvbSubtitleBitmaps::AddBitmap(cBitmap *Bitmap) void cDvbSubtitleBitmaps::Draw(cOsd *Osd) { + bool Scale = !(DoubleEqual(osdFactorX, 1.0) && DoubleEqual(osdFactorY, 1.0)); + bool AntiAlias = true; + if (Scale && osdFactorX > 1.0 || osdFactorY > 1.0) { + // Upscaling requires 8bpp: + int Bpp[MAXOSDAREAS]; + for (int i = 0; i < numAreas; i++) { + Bpp[i] = areas[i].bpp; + areas[i].bpp = 8; + } + if (Osd->CanHandleAreas(areas, numAreas) != oeOk) { + for (int i = 0; i < numAreas; i++) + Bpp[i] = areas[i].bpp = Bpp[i]; + AntiAlias = false; + } + } if (Osd->SetAreas(areas, numAreas) == oeOk) { for (int i = 0; i < bitmaps.Size(); i++) { cBitmap *b = bitmaps[i]; - if (osdFactor != 1.0) - b = b->Scale(osdFactor, osdFactor); - Osd->DrawBitmap(int(round(b->X0() * osdFactor)), int(round(b->Y0() * osdFactor)), *b); + if (Scale) + b = b->Scaled(osdFactorX, osdFactorY, AntiAlias); + Osd->DrawBitmap(int(round(b->X0() * osdFactorX)), int(round(b->Y0() * osdFactorY)), *b); if (b != bitmaps[i]) delete b; } @@ -733,7 +753,7 @@ int cDvbSubtitleConverter::ConvertFragments(const uchar *Data, int Length) if (Length > PayloadOffset + SubstreamHeaderLength) { int64_t pts = PesHasPts(Data) ? PesGetPts(Data) : 0; if (pts) - dbgconverter("Converter PTS: %lld\n", pts); + dbgconverter("Converter PTS: %"PRId64"\n", pts); const uchar *data = Data + PayloadOffset + SubstreamHeaderLength; // skip substream header int length = Length - PayloadOffset - SubstreamHeaderLength; // skip substream header if (ResetSubtitleAssembler) @@ -769,7 +789,7 @@ int cDvbSubtitleConverter::Convert(const uchar *Data, int Length) if (Length > PayloadOffset) { int64_t pts = PesGetPts(Data); if (pts) - dbgconverter("Converter PTS: %lld\n", pts); + dbgconverter("Converter PTS: %"PRId64"\n", pts); const uchar *data = Data + PayloadOffset; int length = Length - PayloadOffset; if (length > 3) { @@ -828,7 +848,7 @@ void cDvbSubtitleConverter::Action(void) if (AssertOsd()) { sb->Draw(osd); Timeout.Set(sb->Timeout() * 1000); - dbgconverter("PTS: %lld STC: %lld (%lld) timeout: %d\n", sb->Pts(), cDevice::PrimaryDevice()->GetSTC(), Delta, sb->Timeout()); + dbgconverter("PTS: %"PRId64" STC: %"PRId64" (%"PRId64") timeout: %d\n", sb->Pts(), cDevice::PrimaryDevice()->GetSTC(), Delta, sb->Timeout()); } bitmaps->Del(sb); } @@ -862,27 +882,27 @@ tColor cDvbSubtitleConverter::yuv2rgb(int Y, int Cb, int Cr) void cDvbSubtitleConverter::SetOsdData(void) { - int OsdWidth; - int OsdHeight; + int OsdWidth, OsdHeight; double OsdAspect; + int VideoWidth, VideoHeight; + double VideoAspect; cDevice::PrimaryDevice()->GetOsdSize(OsdWidth, OsdHeight, OsdAspect); - osdDeltaX = osdDeltaY = 0; - osdFactor = 1.0; - double fw = double(OsdWidth) / displayWidth; - double fh = double(OsdHeight) / displayHeight; - if (fw >= fh) { - osdFactor = fh; - osdDeltaX = (OsdWidth - displayWidth * osdFactor) / 2; + cDevice::PrimaryDevice()->GetVideoSize(VideoWidth, VideoHeight, VideoAspect); + if (OsdWidth == displayWidth && OsdHeight == displayHeight) { + osdFactorX = osdFactorY = 1.0; + osdDeltaX = osdDeltaY = 0; } else { - osdFactor = fw; - osdDeltaY = (OsdHeight - displayHeight * osdFactor) / 2; + osdFactorX = VideoAspect * OsdHeight / displayWidth; + osdFactorY = double(OsdHeight) / displayHeight; + osdDeltaX = (OsdWidth - displayWidth * osdFactorX) / 2; + osdDeltaY = (OsdHeight - displayHeight * osdFactorY) / 2; } } bool cDvbSubtitleConverter::AssertOsd(void) { - return osd || (osd = cOsdProvider::NewOsd(int(round(osdFactor * windowHorizontalOffset + osdDeltaX)), int(round(osdFactor * windowVerticalOffset + osdDeltaY)) + Setup.SubtitleOffset, OSD_LEVEL_SUBTITLES)); + return osd || (osd = cOsdProvider::NewOsd(int(round(osdFactorX * windowHorizontalOffset + osdDeltaX)), int(round(osdFactorY * windowVerticalOffset + osdDeltaY)) + Setup.SubtitleOffset, OSD_LEVEL_SUBTITLES)); } int cDvbSubtitleConverter::ExtractSegment(const uchar *Data, int Length, int64_t Pts) @@ -918,7 +938,7 @@ int cDvbSubtitleConverter::ExtractSegment(const uchar *Data, int Length, int64_t page->SetTimeout(Data[6]); page->SetState((Data[6 + 1] & 0x0C) >> 2); page->regions.Clear(); - dbgpages("Update page id %d version %d pts %lld timeout %d state %d\n", pageId, page->Version(), page->Pts(), page->Timeout(), page->State()); + dbgpages("Update page id %d version %d pts %"PRId64" timeout %d state %d\n", pageId, page->Version(), page->Pts(), page->Timeout(), page->State()); for (int i = 6 + 2; i < segmentLength; i += 6) { cSubtitleRegion *region = page->GetRegionById(Data[i], true); region->SetHorizontalAddress((Data[i + 2] << 8) + Data[i + 3]); @@ -1079,7 +1099,7 @@ void cDvbSubtitleConverter::FinishPage(cDvbSubtitlePage *Page) { if (!AssertOsd()) return; - tArea *Areas = Page->GetAreas(osdFactor); + tArea *Areas = Page->GetAreas(osdFactorX, osdFactorY); int NumAreas = Page->regions.Count(); int Bpp = 8; bool Reduced = false; @@ -1116,7 +1136,7 @@ void cDvbSubtitleConverter::FinishPage(cDvbSubtitlePage *Page) } } } - cDvbSubtitleBitmaps *Bitmaps = new cDvbSubtitleBitmaps(Page->Pts(), Page->Timeout(), Areas, NumAreas, osdFactor); + cDvbSubtitleBitmaps *Bitmaps = new cDvbSubtitleBitmaps(Page->Pts(), Page->Timeout(), Areas, NumAreas, osdFactorX, osdFactorY); bitmaps->Add(Bitmaps); for (cSubtitleRegion *sr = Page->regions.First(); sr; sr = Page->regions.Next(sr)) { int posX = sr->HorizontalAddress(); -- cgit v1.2.3