diff --git a/lib/libdvbsub/dvbsubtitle.cpp b/lib/libdvbsub/dvbsubtitle.cpp index 09c18b127..821ad4476 100644 --- a/lib/libdvbsub/dvbsubtitle.cpp +++ b/lib/libdvbsub/dvbsubtitle.cpp @@ -8,7 +8,7 @@ * With some input from the "subtitle plugin" by Pekka Virtanen * * $Id: dvbsubtitle.cpp,v 1.1 2009/02/23 19:46:44 rhabarber1848 Exp $ - * dvbsubtitle for HD1 ported by Coolstream LTD + * dvbsubtitle for HD1 ported by Coolstream LTD */ #include "dvbsubtitle.h" @@ -72,27 +72,27 @@ public: cSubtitleClut(int ClutId); int ClutId(void) { return clutId; } int Version(void) { return version; } - void SetVersion(int Version) { version = Version; } + void SetVersion(int pVersion) { version = pVersion; } void SetColor(int Bpp, int Index, tColor Color); const cPalette *GetPalette(int Bpp); }; -cSubtitleClut::cSubtitleClut(int ClutId) +cSubtitleClut::cSubtitleClut(int pClutId) :palette2(2) ,palette4(4) ,palette8(8) { - clutId = ClutId; + clutId = pClutId; version = -1; } -void cSubtitleClut::SetColor(int Bpp, int Index, tColor Color) +void cSubtitleClut::SetColor(int Bpp, int pIndex, tColor Color) { switch (Bpp) { - case 2: palette2.SetColor(Index, Color); break; - case 4: palette4.SetColor(Index, Color); break; - case 8: palette8.SetColor(Index, Color); break; - default: esyslog("ERROR: wrong Bpp in cSubtitleClut::SetColor(%d, %d, %08X)", Bpp, Index, Color); + case 2: palette2.SetColor(pIndex, Color); break; + case 4: palette4.SetColor(pIndex, Color); break; + case 8: palette8.SetColor(pIndex, Color); break; + default: esyslog("ERROR: wrong Bpp in cSubtitleClut::SetColor(%d, %d, %08X)", Bpp, pIndex, Color); } } @@ -135,18 +135,18 @@ public: int CodingMethod(void) { return codingMethod; } bool NonModifyingColorFlag(void) { return nonModifyingColorFlag; } void DecodeSubBlock(const uchar *Data, int Length, bool Even); - void SetVersion(int Version) { version = Version; } + void SetVersion(int pVersion) { version = pVersion; } void SetBackgroundColor(uchar BackgroundColor) { backgroundColor = BackgroundColor; } void SetForegroundColor(uchar ForegroundColor) { foregroundColor = ForegroundColor; } - void SetNonModifyingColorFlag(bool NonModifyingColorFlag) { nonModifyingColorFlag = NonModifyingColorFlag; } - void SetCodingMethod(int CodingMethod) { codingMethod = CodingMethod; } + void SetNonModifyingColorFlag(bool pNonModifyingColorFlag) { nonModifyingColorFlag = pNonModifyingColorFlag; } + void SetCodingMethod(int pCodingMethod) { codingMethod = pCodingMethod; } void SetPosition(int x, int y) { px = x; py = y; } - void SetProviderFlag(int ProviderFlag) { providerFlag = ProviderFlag; } + void SetProviderFlag(int pProviderFlag) { providerFlag = pProviderFlag; } }; -cSubtitleObject::cSubtitleObject(int ObjectId, cBitmap *Bitmap) +cSubtitleObject::cSubtitleObject(int pObjectId, cBitmap *pBitmap) { - objectId = ObjectId; + objectId = pObjectId; version = -1; codingMethod = -1; nonModifyingColorFlag = false; @@ -155,7 +155,7 @@ cSubtitleObject::cSubtitleObject(int ObjectId, cBitmap *Bitmap) foregroundColor = 0; providerFlag = -1; px = py = 0; - bitmap = Bitmap; + bitmap = pBitmap; } void cSubtitleObject::DecodeSubBlock(const uchar *Data, int Length, bool Even) @@ -204,32 +204,32 @@ void cSubtitleObject::DecodeSubBlock(const uchar *Data, int Length, bool Even) } } -void cSubtitleObject::DrawLine(int x, int y, tIndex Index, int Length) +void cSubtitleObject::DrawLine(int x, int y, tIndex pIndex, int Length) { - if (nonModifyingColorFlag && Index == 1) + if (nonModifyingColorFlag && pIndex == 1) return; x += px; y += py; for (int pos = x; pos < x + Length; pos++) - bitmap->SetIndex(pos, y, Index); + bitmap->SetIndex(pos, y, pIndex); } -uchar cSubtitleObject::Get2Bits(const uchar *Data, int &Index) +uchar cSubtitleObject::Get2Bits(const uchar *Data, int &pIndex) { - uchar result = Data[Index]; + uchar result = Data[pIndex]; if (!nibblePos) { - Index++; + pIndex++; nibblePos = 8; } nibblePos -= 2; return (result >> nibblePos) & 0x03; } -uchar cSubtitleObject::Get4Bits(const uchar *Data, int &Index) +uchar cSubtitleObject::Get4Bits(const uchar *Data, int &pIndex) { - uchar result = Data[Index]; + uchar result = Data[pIndex]; if (!nibblePos) { - Index++; + pIndex++; nibblePos = 4; } else { @@ -239,25 +239,25 @@ uchar cSubtitleObject::Get4Bits(const uchar *Data, int &Index) return result & 0x0F; } -bool cSubtitleObject::Decode2BppCodeString(const uchar *Data, int &Index, int &x, int y) +bool cSubtitleObject::Decode2BppCodeString(const uchar *Data, int &pIndex, int &x, int y) { int rl = 0; int color = 0; - uchar code = Get2Bits(Data, Index); + uchar code = Get2Bits(Data, pIndex); if (code) { color = code; rl = 1; } else { - code = Get2Bits(Data, Index); + code = Get2Bits(Data, pIndex); if (code & 2) { // switch_1 - rl = ((code & 1) << 2) + Get2Bits(Data, Index) + 3; - color = Get2Bits(Data, Index); + rl = ((code & 1) << 2) + Get2Bits(Data, pIndex) + 3; + color = Get2Bits(Data, pIndex); } else if (code & 1) rl = 1; //color 0 else { - code = Get2Bits(Data, Index); + code = Get2Bits(Data, pIndex); switch (code & 0x3) { //switch_3 case 0: return false; @@ -265,12 +265,12 @@ bool cSubtitleObject::Decode2BppCodeString(const uchar *Data, int &Index, int &x rl = 2; //color 0 break; case 2: - rl = (Get2Bits(Data, Index) << 2) + Get2Bits(Data, Index) + 12; - color = Get2Bits(Data, Index); + rl = (Get2Bits(Data, pIndex) << 2) + Get2Bits(Data, pIndex) + 12; + color = Get2Bits(Data, pIndex); break; case 3: - rl = (Get2Bits(Data, Index) << 6) + (Get2Bits(Data, Index) << 4) + (Get2Bits(Data, Index) << 2) + Get2Bits(Data, Index) + 29; - color = Get2Bits(Data, Index); + rl = (Get2Bits(Data, pIndex) << 6) + (Get2Bits(Data, pIndex) << 4) + (Get2Bits(Data, pIndex) << 2) + Get2Bits(Data, pIndex) + 29; + color = Get2Bits(Data, pIndex); break; } } @@ -280,17 +280,17 @@ bool cSubtitleObject::Decode2BppCodeString(const uchar *Data, int &Index, int &x return true; } -bool cSubtitleObject::Decode4BppCodeString(const uchar *Data, int &Index, int &x, int y) +bool cSubtitleObject::Decode4BppCodeString(const uchar *Data, int &pIndex, int &x, int y) { int rl = 0; int color = 0; - uchar code = Get4Bits(Data, Index); + uchar code = Get4Bits(Data, pIndex); if (code) { color = code; rl = 1; } else { - code = Get4Bits(Data, Index); + code = Get4Bits(Data, pIndex); if (code & 8) { // switch_1 if (code & 4) { //switch_2 switch (code & 3) { //switch_3 @@ -301,18 +301,18 @@ bool cSubtitleObject::Decode4BppCodeString(const uchar *Data, int &Index, int &x rl = 2; break; case 2: - rl = Get4Bits(Data, Index) + 9; - color = Get4Bits(Data, Index); + rl = Get4Bits(Data, pIndex) + 9; + color = Get4Bits(Data, pIndex); break; case 3: - rl = (Get4Bits(Data, Index) << 4) + Get4Bits(Data, Index) + 25; - color = Get4Bits(Data, Index); + rl = (Get4Bits(Data, pIndex) << 4) + Get4Bits(Data, pIndex) + 25; + color = Get4Bits(Data, pIndex); break; } } else { rl = (code & 3) + 4; - color = Get4Bits(Data, Index); + color = Get4Bits(Data, pIndex); } } else { // color 0 @@ -326,20 +326,20 @@ bool cSubtitleObject::Decode4BppCodeString(const uchar *Data, int &Index, int &x return true; } -bool cSubtitleObject::Decode8BppCodeString(const uchar *Data, int &Index, int &x, int y) +bool cSubtitleObject::Decode8BppCodeString(const uchar *Data, int &pIndex, int &x, int y) { int rl = 0; int color = 0; - uchar code = Data[Index++]; + uchar code = Data[pIndex++]; if (code) { color = code; rl = 1; } else { - code = Data[Index++]; + code = Data[pIndex++]; rl = code & 0x63; if (code & 0x80) - color = Data[Index++]; + color = Data[pIndex++]; else if (!rl) return false; //else color 0 } @@ -370,18 +370,18 @@ public: cSubtitleObject *GetObjectById(int ObjectId, bool New = false); int HorizontalAddress(void) { return horizontalAddress; } int VerticalAddress(void) { return verticalAddress; } - void SetVersion(int Version) { version = Version; } - void SetClutId(int ClutId) { clutId = ClutId; } + void SetVersion(int pVersion) { version = pVersion; } + void SetClutId(int pClutId) { clutId = pClutId; } void SetLevel(int Level); void SetDepth(int Depth); - void SetHorizontalAddress(int HorizontalAddress) { horizontalAddress = HorizontalAddress; } - void SetVerticalAddress(int VerticalAddress) { verticalAddress = VerticalAddress; } + void SetHorizontalAddress(int pHorizontalAddress) { horizontalAddress = pHorizontalAddress; } + void SetVerticalAddress(int pVerticalAddress) { verticalAddress = pVerticalAddress; } }; -cSubtitleRegion::cSubtitleRegion(int RegionId) +cSubtitleRegion::cSubtitleRegion(int pRegionId) :cBitmap(1, 1, 4) { - regionId = RegionId; + regionId = pRegionId; version = -1; clutId = -1; horizontalAddress = 0; @@ -389,12 +389,12 @@ cSubtitleRegion::cSubtitleRegion(int RegionId) level = 0; } -void cSubtitleRegion::FillRegion(tIndex Index) +void cSubtitleRegion::FillRegion(tIndex pIndex) { - dbgregions("FillRegion %d\n", Index); + dbgregions("FillRegion %d\n", pIndex); for (int y = 0; y < Height(); y++) { for (int x = 0; x < Width(); x++) - SetIndex(x, y, Index); + SetIndex(x, y, pIndex); } } @@ -412,16 +412,16 @@ cSubtitleObject *cSubtitleRegion::GetObjectById(int ObjectId, bool New) return result; } -void cSubtitleRegion::SetLevel(int Level) +void cSubtitleRegion::SetLevel(int pLevel) { - if (Level > 0 && Level < 4) - level = 1 << Level; + if (pLevel > 0 && pLevel < 4) + level = 1 << pLevel; } -void cSubtitleRegion::SetDepth(int Depth) +void cSubtitleRegion::SetDepth(int pDepth) { - if (Depth > 0 && Depth < 4) - SetBpp(1 << Depth); + if (pDepth > 0 && pDepth < 4) + SetBpp(1 << pDepth); } // --- cDvbSubtitlePage ------------------------------------------------------ @@ -447,16 +447,16 @@ public: cSubtitleRegion *GetRegionById(int RegionId, bool New = false); int64_t Pts(void) const { return pts; } int Timeout(void) { return timeout; } - void SetVersion(int Version) { version = Version; } - void SetPts(int64_t Pts) { pts = Pts; } + void SetVersion(int pVersion) { version = pVersion; } + void SetPts(int64_t pPts) { pts = pPts; } void SetState(int State); - void SetTimeout(int Timeout) { timeout = Timeout; } + void SetTimeout(int pTimeout) { timeout = pTimeout; } void UpdateRegionPalette(cSubtitleClut *Clut); }; -cDvbSubtitlePage::cDvbSubtitlePage(int PageId) +cDvbSubtitlePage::cDvbSubtitlePage(int pPageId) { - pageId = PageId; + pageId = pPageId; version = -1; state = -1; pts = 0; @@ -523,9 +523,9 @@ cSubtitleObject *cDvbSubtitlePage::GetObjectById(int ObjectId) return result; } -void cDvbSubtitlePage::SetState(int State) +void cDvbSubtitlePage::SetState(int pState) { - state = State; + state = pState; switch (state) { case 0: // normal case - page update dbgpages("page update\n"); @@ -643,12 +643,12 @@ public: void Clear(void); }; -cDvbSubtitleBitmaps::cDvbSubtitleBitmaps(int64_t Pts, int Timeout, tArea *Areas, int NumAreas) +cDvbSubtitleBitmaps::cDvbSubtitleBitmaps(int64_t pPts, int pTimeout, tArea *pAreas, int pNumAreas) { - pts = Pts; - timeout = Timeout; - areas = Areas; - numAreas = NumAreas; + pts = pPts; + timeout = pTimeout; + areas = pAreas; + numAreas = pNumAreas; // max_x = max_y = 0; // min_x = min_y = 0xFFFF; //dbgconverter("cDvbSubtitleBitmaps::new: PTS: %lld\n", pts); @@ -708,7 +708,7 @@ void cDvbSubtitleBitmaps::Draw() int yoff = (yend - (576-bitmaps[i]->Y0()))*stride; int ys = yend - (576-bitmaps[i]->Y0()); - dbgconverter("cDvbSubtitleBitmaps::Draw %d colors= %d at %d,%d (x=%d y=%d) size %dx%d\n", + dbgconverter("cDvbSubtitleBitmaps::Draw %d colors= %d at %d,%d (x=%d y=%d) size %dx%d\n", i, NumColors, bitmaps[i]->X0(), bitmaps[i]->Y0(), xoff, ys, bitmaps[i]->Width(), bitmaps[i]->Height()); for (int y2 = 0; y2 < bitmaps[i]->Height(); y2++) { diff --git a/lib/libdvbsub/osd.cpp b/lib/libdvbsub/osd.cpp index 3607e6901..897388b02 100644 --- a/lib/libdvbsub/osd.cpp +++ b/lib/libdvbsub/osd.cpp @@ -18,9 +18,9 @@ // --- cPalette -------------------------------------------------------------- -cPalette::cPalette(int Bpp) +cPalette::cPalette(int pBpp) { - SetBpp(Bpp); + SetBpp(pBpp); SetAntiAliasGranularity(10, 10); } @@ -41,44 +41,44 @@ void cPalette::Reset(void) modified = false; } -int cPalette::Index(tColor Color) +int cPalette::Index(tColor pColor) { // Check if color is already defined: for (int i = 0; i < numColors; i++) { - if (color[i] == Color) + if (color[i] == pColor) return i; } // No exact color, try a close one: - int i = ClosestColor(Color, 4); + int i = ClosestColor(pColor, 4); if (i >= 0) return i; // No close one, try to define a new one: if (numColors < maxColors) { - color[numColors++] = Color; + color[numColors++] = pColor; modified = true; return numColors - 1; } // Out of colors, so any close color must do: - return ClosestColor(Color); + return ClosestColor(pColor); } -void cPalette::SetBpp(int Bpp) +void cPalette::SetBpp(int pBpp) { - bpp = Bpp; + bpp = pBpp; maxColors = 1 << bpp; Reset(); } -void cPalette::SetColor(int Index, tColor Color) +void cPalette::SetColor(int pIndex, tColor pColor) { - if (Index < maxColors) { - if (numColors <= Index) { - numColors = Index + 1; + if (pIndex < maxColors) { + if (numColors <= pIndex) { + numColors = pIndex + 1; modified = true; } else - modified |= color[Index] != Color; - color[Index] = Color; + modified |= color[pIndex] != pColor; + color[pIndex] = pColor; } } @@ -91,14 +91,14 @@ const tColor *cPalette::Colors(int &NumColors) const void cPalette::Take(const cPalette &Palette, tIndexes *Indexes, tColor ColorFg, tColor ColorBg) { for (int i = 0; i < Palette.numColors; i++) { - tColor Color = Palette.color[i]; + tColor pColor = Palette.color[i]; if (ColorFg || ColorBg) { switch (i) { - case 0: Color = ColorBg; break; - case 1: Color = ColorFg; break; + case 0: pColor = ColorBg; break; + case 1: pColor = ColorFg; break; } } - int n = Index(Color); + int n = Index(pColor); if (Indexes) (*Indexes)[i] = n; } @@ -131,14 +131,14 @@ tColor cPalette::Blend(tColor ColorFg, tColor ColorBg, uint8_t Level) const return (A << 24) | (R << 16) | (G << 8) | B; } -int cPalette::ClosestColor(tColor Color, int MaxDiff) const +int cPalette::ClosestColor(tColor pColor, int MaxDiff) const { int n = 0; int d = INT_MAX; - int A1 = (Color & 0xFF000000) >> 24; - int R1 = (Color & 0x00FF0000) >> 16; - int G1 = (Color & 0x0000FF00) >> 8; - int B1 = (Color & 0x000000FF); + int A1 = (pColor & 0xFF000000) >> 24; + int R1 = (pColor & 0x00FF0000) >> 16; + int G1 = (pColor & 0x0000FF00) >> 8; + int B1 = (pColor & 0x000000FF); for (int i = 0; i < numColors; i++) { int A2 = (color[i] & 0xFF000000) >> 24; int R2 = (color[i] & 0x00FF0000) >> 16; @@ -153,13 +153,13 @@ int cPalette::ClosestColor(tColor Color, int MaxDiff) const return d <= MaxDiff ? n : -1; } -cBitmap::cBitmap(int Width, int Height, int Bpp, int X0, int Y0) -:cPalette(Bpp) +cBitmap::cBitmap(int pWidth, int pHeight, int pBpp, int pX0, int pY0) +:cPalette(pBpp) { bitmap = NULL; - x0 = X0; - y0 = Y0; - SetSize(Width, Height); + x0 = pX0; + y0 = pY0; + SetSize(pWidth, pHeight); } cBitmap::~cBitmap() @@ -167,12 +167,12 @@ cBitmap::~cBitmap() free(bitmap); } -void cBitmap::SetIndex(int x, int y, tIndex Index) +void cBitmap::SetIndex(int x, int y, tIndex pIndex) { if (bitmap) { if (0 <= x && x < width && 0 <= y && y < height) { - if (bitmap[width * y + x] != Index) { - bitmap[width * y + x] = Index; + if (bitmap[width * y + x] != pIndex) { + bitmap[width * y + x] = pIndex; if (dirtyX1 > x) dirtyX1 = x; if (dirtyY1 > y) dirtyY1 = y; if (dirtyX2 < x) dirtyX2 = x; @@ -182,12 +182,12 @@ void cBitmap::SetIndex(int x, int y, tIndex Index) } } -void cBitmap::SetSize(int Width, int Height) +void cBitmap::SetSize(int pWidth, int pHeight) { - if (bitmap && Width == width && Height == height) + if (bitmap && pWidth == width && pHeight == height) return; - width = Width; - height = Height; + width = pWidth; + height = pHeight; free(bitmap); bitmap = NULL; dirtyX1 = 0; diff --git a/lib/libdvbsub/osd.h b/lib/libdvbsub/osd.h index 9ac555e05..daf38dab0 100644 --- a/lib/libdvbsub/osd.h +++ b/lib/libdvbsub/osd.h @@ -50,7 +50,7 @@ public: ///< If Color is not yet contained in this palette, it will be added if ///< there is a free slot. If the color can't be added to this palette, ///< the closest existing color will be returned. - tColor Color(int Index) const { return Index < maxColors ? color[Index] : 0; } + tColor Color(int pIndex) const { return pIndex < maxColors ? color[pIndex] : 0; } ///< Returns the color at the given Index. If Index is outside the valid ///< range, 0 will be returned. void SetBpp(int Bpp);