diff options
author | Christian Gmeiner <christian.gmeiner@gmail.com> | 2009-09-01 20:59:28 +0200 |
---|---|---|
committer | Christian Gmeiner <christian.gmeiner@gmail.com> | 2009-09-01 20:59:28 +0200 |
commit | 38d8d30328100fc192050a5d2ad0098e6ab19b84 (patch) | |
tree | a3b6582f347b2d33c22c43f7bf934156283dae90 /spuencoder.c | |
parent | 3bd41879d4a8929ff0686ebb53c9c7c4016c9d32 (diff) | |
download | vdr-plugin-dxr3-38d8d30328100fc192050a5d2ad0098e6ab19b84.tar.gz vdr-plugin-dxr3-38d8d30328100fc192050a5d2ad0098e6ab19b84.tar.bz2 |
add generateColorPalette and encode methods with needed members
generateColorPalette will use vdrs color values and parse them and
set new color values for the spu.
encode is at the moment almost a stub
Diffstat (limited to 'spuencoder.c')
-rw-r--r-- | spuencoder.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/spuencoder.c b/spuencoder.c index d61b462..7295e62 100644 --- a/spuencoder.c +++ b/spuencoder.c @@ -26,6 +26,7 @@ #include "spuencoder.h" #include "dxr3interface.h" +#include "dxr3tools.h" static const uint8_t CMD_FORCE_DISPLAYING = 0x00; static const uint8_t CMD_STOP_DISPLAYING = 0x02; @@ -66,8 +67,20 @@ void cSpuEncoder::clearOsd() cDxr3Interface::instance()->WriteSpu((uchar *)&d, 10); } -void cSpuEncoder::writeNibble(uint8_t val) { +void cSpuEncoder::encode(cBitmap *bmap, int top, int left) +{ + // store internaly + bitmap = bmap; + + // prepare datastructures + memset(&spu, 0, sizeof(spu)); + + // generate and upload color palette + generateColorPalette(); +} +void cSpuEncoder::writeNibble(uint8_t val) +{ // look if we have an overflow if (written == MAX_SPU_DATA) { throw "overflow"; @@ -80,3 +93,26 @@ void cSpuEncoder::writeNibble(uint8_t val) { nholder = (val << 4); } } + +void cSpuEncoder::generateColorPalette() +{ + // we need to convert the color we get from + // vdr, because it is stored in AARRGGBB + // and we need AA and RRGGBB separated to + // be able to convert color to yuv and set + // wanted opacity vales later on. + + int num; + const tColor *colors = bitmap->Colors(num); + + memset(&palcolors, 0, sizeof(palcolors)); + + for (int i = 0; i < num; i++) { + // separate AA and RRGGBB values + opacity[i] = (colors[i] & 0xff000000) >> 24; + palcolors[i] = Tools::Rgb2YCrCb(colors[i] & 0x00ffffff); + } + + // upload color palette + cDxr3Interface::instance()->SetPalette(palcolors); +} |