From dbf38b7c68911187b6a48688b738c31612d35984 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 14 Oct 2007 18:00:00 +0200 Subject: =?UTF-8?q?Version=201.5.10=20-=20Implemented=20handling=20DVB=20s?= =?UTF-8?q?ubtitles=20(thanks=20to=20Marco=20Schl=C3=BC=C3=9Fler,=20and=20?= =?UTF-8?q?also=20to=20=20=20Pekka=20Virtanen=20for=20writing=20the=20subt?= =?UTF-8?q?itle=20plugin,=20which=20helped=20in=20implementing=20=20=20sub?= =?UTF-8?q?title=20handling=20in=20VDR).=20-=20The=20new=20remote=20contro?= =?UTF-8?q?l=20key=20"Subtitles"=20can=20be=20used=20to=20bring=20up=20the?= =?UTF-8?q?=20list=20=20=20of=20available=20subtitles.=20-=20The=20new=20s?= =?UTF-8?q?etup=20option=20"DVB/Subtitle=20languages"=20can=20be=20used=20?= =?UTF-8?q?to=20define=20the=20=20=20preferred=20languages=20for=20subtitl?= =?UTF-8?q?es.=20-=20Fixed=20selecting=20the=20audio=20track=20when=20pres?= =?UTF-8?q?sing=20Ok=20in=20the=20Audio=20menu=20(thanks=20=20=20to=20Marc?= =?UTF-8?q?o=20Schl=C3=BC=C3=9Fler).=20-=20Implemented=20display=20of=20DV?= =?UTF-8?q?B=20subtitles=20in=20live=20viewing=20mode.=20-=20Implemented?= =?UTF-8?q?=20subtitle=20track=20selection.=20-=20Implemented=20bitmap=20c?= =?UTF-8?q?olor=20reduction=20and=20shrinking=20to=20display=20subtitles?= =?UTF-8?q?=20even=20=20=20on=20devices=20that=20can't=20display=20the=20n?= =?UTF-8?q?ecessary=20number=20of=20colors.=20-=20Added=20compatibility=20?= =?UTF-8?q?mode=20for=20playback=20of=20recordings=20made=20with=20the=20s?= =?UTF-8?q?ubtitles=20=20=20plugin=20(with=20some=20help=20from=20Rolf=20A?= =?UTF-8?q?hrenberg).=20-=20The=20new=20setup=20option=20"DVB/Subtitle=20o?= =?UTF-8?q?ffset"=20can=20be=20used=20to=20shift=20the=20location=20=20=20?= =?UTF-8?q?of=20the=20subtitles=20in=20the=20vertical=20direction.=20-=20T?= =?UTF-8?q?he=20new=20setup=20options=20"DVB/Subtitle=20foreground/backgro?= =?UTF-8?q?und=20transparency"=20=20=20define=20an=20additional=20level=20?= =?UTF-8?q?of=20transparency=20for=20the=20foreground=20and=20background?= =?UTF-8?q?=20=20=20color=20of=20subtitles.=20-=20Existing=20recordings=20?= =?UTF-8?q?made=20with=20the=20subtitle=20plugin=20can=20be=20given=20an?= =?UTF-8?q?=20'X'=20record=20=20=20in=20their=20info.vdr=20file,=20so=20th?= =?UTF-8?q?at=20subtitles=20can=20be=20automatically=20selected=20upon=20?= =?UTF-8?q?=20=20replay,=20according=20to=20the=20preferred=20language=20s?= =?UTF-8?q?etup,=20as=20in=20=20=20X=203=2003=20ger=20deutsch=20=20=20(see?= =?UTF-8?q?=20vdr.5).=20Note=20that=20these=20entries=20need=20to=20be=20a?= =?UTF-8?q?dded=20in=20the=20proper=20sequence,=20=20=20so=20that=20they?= =?UTF-8?q?=20correspond=20with=20the=20actual=20track=20languages=20in=20?= =?UTF-8?q?the=20recording.=20-=20Now=20generating=20translation=20files?= =?UTF-8?q?=20without=20line=20numbers=20to=20avoid=20unnecessarily=20=20?= =?UTF-8?q?=20large=20diffs.=20Plugin=20authors=20may=20want=20to=20replac?= =?UTF-8?q?e=20the=20-F=20option=20with=20=20=20--no-location=20in=20the?= =?UTF-8?q?=20xgettext=20and=20msgmerge=20calls=20in=20their=20Makefiles.?= =?UTF-8?q?=20-=20Updated=20the=20Finnish=20OSD=20texts=20(thanks=20to=20R?= =?UTF-8?q?olf=20Ahrenberg).=20-=20Added=20a=20missing=20Channels.SetModif?= =?UTF-8?q?ied(true)=20call=20when=20deleting=20or=20moving=20a=20=20=20ch?= =?UTF-8?q?annel=20in=20the=20Channels=20menu=20(reported=20by=20Halim=20S?= =?UTF-8?q?ahin).=20-=20Fixed=20a=20missing=20'-'=20at=20the=20next=20to?= =?UTF-8?q?=20last=20line=20of=20SVDRP=20help=20texts=20(reported=20by=20?= =?UTF-8?q?=20=20Denis=20Knauf).=20-=20Added=20a=20missing=20SetVolumeDevi?= =?UTF-8?q?ce()=20call=20in=20cDevice::SetPrimaryDevice()=20(reported=20?= =?UTF-8?q?=20=20by=20Reinhard=20Nissl).=20-=20Fixed=20a=20crash=20when=20?= =?UTF-8?q?pressing=20Left=20while=20at=20the=20first=20character=20of=20a?= =?UTF-8?q?=20cMenuEditStrItem=20=20=20(thanks=20to=20Christian=20Wieninge?= =?UTF-8?q?r).=20-=20Only=20creating=20a=20new=20cDvbOsdProvider=20in=20cD?= =?UTF-8?q?vbDevice::MakePrimaryDevice()=20if=20'On'=20=20=20is=20true=20(?= =?UTF-8?q?i.e.=20this=20device=20is=20being=20made=20the=20primary=20devi?= =?UTF-8?q?ce).=20-=20Updated=20the=20Italian=20OSD=20texts=20(thanks=20to?= =?UTF-8?q?=20Diego=20Pierotto).=20-=20Fixed=20handling=20reallocated=20me?= =?UTF-8?q?mory=20in=20cCharSetConv::Convert()=20(reported=20by=20Udo=20?= =?UTF-8?q?=20=20Richter).=20-=20Fixed=20a=20new[]/delete=20mismatch=20in?= =?UTF-8?q?=20cMenuEditStrItem::LeaveEditMode()=20(thanks=20to=20=20=20Udo?= =?UTF-8?q?=20Richter).=20-=20Implemented=20sending=20all=20frames=20to=20?= =?UTF-8?q?devices=20that=20can=20handle=20them=20in=20fast=20forward=20?= =?UTF-8?q?=20=20trick=20speeds=20(thanks=20to=20Timo=20Eskola).=20-=20Upd?= =?UTF-8?q?ated=20the=20Hungarian=20language=20texts=20(thanks=20to=20Thom?= =?UTF-8?q?as=20G=C3=BCnther).=20-=20Fixed=20description=20of=20DeviceSetA?= =?UTF-8?q?vailableTrack()=20and=20cReceiver(),=20and=20added=20an=20=20?= =?UTF-8?q?=20example=20~cMyReceiver()=20in=20PLUGINS.html=20(thanks=20to?= =?UTF-8?q?=20Marco=20Schl=C3=BC=C3=9Fler).=20-=20Improved=20the=20descrip?= =?UTF-8?q?tion=20of=20where=20logging=20goes=20in=20the=20INSTALL=20file?= =?UTF-8?q?=20(thanks=20to=20=20=20Elias=20Luttinen).=20-=20Added=20a=20no?= =?UTF-8?q?te=20about=20how=20to=20initiate=20internationalization=20suppo?= =?UTF-8?q?rt=20to=20the=20=20=20README.i18n=20file.=20The=20Makefile=20ge?= =?UTF-8?q?nerated=20by=20the=20'newplugin'=20script=20now=20has=20the=20?= =?UTF-8?q?=20=20'i18n'=20target=20automatically=20create=20an=20initial?= =?UTF-8?q?=20'po/pluginname.pot'=20file.=20=20=20Plugin=20authors=20may?= =?UTF-8?q?=20want=20to=20add=20the=20'$(I18Npot)'=20dependency=20to=20the?= =?UTF-8?q?=20'i18n'=20=20=20target=20in=20their=20Makefiles,=20as=20in=20?= =?UTF-8?q?=20=20i18n:=20$(I18Npot)=20$(I18Nmo)=20=20=20(based=20on=20a=20?= =?UTF-8?q?suggestion=20by=20Torsten=20Kunkel).=20-=20Removed=20a=20duplic?= =?UTF-8?q?ate=20','=20from=20the=20ca=5FES.po=20file=20(thanks=20to=20Tho?= =?UTF-8?q?mas=20G=C3=BCnther).=20-=20Added=20the=20'=C3=9F'=20character?= =?UTF-8?q?=20to=20the=20"allowed=20characters"=20in=20the=20de=5FDE.po=20?= =?UTF-8?q?file=20=20=20(suggested=20by=20Thomas=20G=C3=BCnther).=20-=20Ma?= =?UTF-8?q?de=20the=20default=20copy=20ctor=20of=20cRecording=20private=20?= =?UTF-8?q?(thanks=20to=20Markus=20Hahn).=20=20=20Same=20for=20the=20assig?= =?UTF-8?q?n=20operator.=20-=20Added=20cRecording::Undelete()=20(based=20o?= =?UTF-8?q?n=20a=20patch=20from=20Markus=20Hahn).=20-=20Added=20cDevice::C?= =?UTF-8?q?loseFilter()=20to=20allow=20a=20device=20to=20have=20complete?= =?UTF-8?q?=20control=20over=20=20=20both=20opening=20and=20closing=20sect?= =?UTF-8?q?ion=20filters=20(thanks=20to=20Rolf=20Ahrenberg).=20-=20Some=20?= =?UTF-8?q?fixes=20to=20PLUGINS.html=20(thanks=20to=20Rolf=20Ahrenberg).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- osd.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 89 insertions(+), 17 deletions(-) (limited to 'osd.c') diff --git a/osd.c b/osd.c index 1c91184..47a11b2 100644 --- a/osd.c +++ b/osd.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: osd.c 1.74 2007/08/26 09:44:50 kls Exp $ + * $Id: osd.c 1.75 2007/10/12 12:38:36 kls Exp $ */ #include "osd.h" @@ -82,7 +82,7 @@ void cPalette::SetColor(int Index, tColor Color) } } -const tColor *cPalette::Colors(int &NumColors) +const tColor *cPalette::Colors(int &NumColors) const { NumColors = numColors; return numColors ? color : NULL; @@ -112,7 +112,7 @@ void cPalette::Replace(const cPalette &Palette) antiAliasGranularity = Palette.antiAliasGranularity; } -tColor cPalette::Blend(tColor ColorFg, tColor ColorBg, uint8_t Level) +tColor cPalette::Blend(tColor ColorFg, tColor ColorBg, uint8_t Level) const { if (antiAliasGranularity > 0) Level = uint8_t(int(Level / antiAliasGranularity + 0.5) * antiAliasGranularity); @@ -131,7 +131,7 @@ tColor cPalette::Blend(tColor ColorFg, tColor ColorBg, uint8_t Level) return (A << 24) | (R << 16) | (G << 8) | B; } -int cPalette::ClosestColor(tColor Color, int MaxDiff) +int cPalette::ClosestColor(tColor Color, int MaxDiff) const { int n = 0; int d = INT_MAX; @@ -640,6 +640,79 @@ const tIndex *cBitmap::Data(int x, int y) return &bitmap[y * width + x]; } +void cBitmap::ReduceBpp(const cPalette &Palette) +{ + int NewBpp = Palette.Bpp(); + if (Bpp() == 4 && NewBpp == 2) { + for (int i = width * height; i--; ) { + tIndex p = bitmap[i]; + bitmap[i] = (p >> 2) | ((p & 0x03) != 0); + } + } + else if (Bpp() == 8) { + if (NewBpp == 2) { + for (int i = width * height; i--; ) { + tIndex p = bitmap[i]; + bitmap[i] = (p >> 6) | ((p & 0x30) != 0); + } + } + else if (NewBpp == 4) { + for (int i = width * height; i--; ) { + tIndex p = bitmap[i]; + bitmap[i] = p >> 4; + } + } + else + return; + } + else + return; + SetBpp(NewBpp); + Replace(Palette); +} + +void cBitmap::ShrinkBpp(int NewBpp) +{ + int NumOldColors; + const tColor *Colors = this->Colors(NumOldColors); + if (Colors) { + // Find the most frequently used colors and create a map table: + int Used[MAXNUMCOLORS] = { 0 }; + int Map[MAXNUMCOLORS] = { 0 }; + for (int i = width * height; i--; ) + Used[bitmap[i]]++; + int MaxNewColors = (NewBpp == 4) ? 16 : 4; + cPalette NewPalette(NewBpp); + for (int i = 0; i < MaxNewColors; i++) { + int Max = 0; + int Index = -1; + for (int n = 0; n < NumOldColors; n++) { + if (Used[n] > Max) { + Max = Used[n]; + Index = n; + } + } + if (Index >= 0) { + Used[Index] = 0; + Map[Index] = i; + NewPalette.SetColor(i, Colors[Index]); + } + else + break; + } + // Complete the map table for all other colors (will be set to closest match): + for (int n = 0; n < NumOldColors; n++) { + if (Used[n]) + Map[n] = NewPalette.Index(Colors[n]); + } + // Do the actual index mapping: + for (int i = width * height; i--; ) + bitmap[i] = Map[bitmap[i]]; + SetBpp(NewBpp); + Replace(NewPalette); + } +} + // --- cOsd ------------------------------------------------------------------ int cOsd::osdLeft = 0; @@ -720,19 +793,18 @@ eOsdError cOsd::CanHandleAreas(const tArea *Areas, int NumAreas) eOsdError cOsd::SetAreas(const tArea *Areas, int NumAreas) { - eOsdError Result = oeUnknown; - if (numBitmaps == 0) { - Result = CanHandleAreas(Areas, NumAreas); - if (Result == oeOk) { - width = height = 0; - for (int i = 0; i < NumAreas; i++) { - bitmaps[numBitmaps++] = new cBitmap(Areas[i].Width(), Areas[i].Height(), Areas[i].bpp, Areas[i].x1, Areas[i].y1); - width = max(width, Areas[i].x2 + 1); - height = max(height, Areas[i].y2 + 1); - } - } + eOsdError Result = CanHandleAreas(Areas, NumAreas); + if (Result == oeOk) { + while (numBitmaps) + delete bitmaps[--numBitmaps]; + width = height = 0; + for (int i = 0; i < NumAreas; i++) { + bitmaps[numBitmaps++] = new cBitmap(Areas[i].Width(), Areas[i].Height(), Areas[i].bpp, Areas[i].x1, Areas[i].y1); + width = max(width, Areas[i].x2 + 1); + height = max(height, Areas[i].y2 + 1); + } } - if (Result != oeOk) + else esyslog("ERROR: cOsd::SetAreas returned %d", Result); return Result; } @@ -818,7 +890,7 @@ cOsdProvider::~cOsdProvider() cOsd *cOsdProvider::NewOsd(int Left, int Top, uint Level) { - if (Level == 0 && cOsd::IsOpen()) + if (Level == OSD_LEVEL_DEFAULT && cOsd::IsOpen()) esyslog("ERROR: attempt to open OSD while it is already open - using dummy OSD!"); else if (osdProvider) { cOsd *ActiveOsd = cOsd::Osds.Size() ? cOsd::Osds[0] : NULL; -- cgit v1.2.3