summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Gmeiner <christian.gmeiner@gmail.com>2009-09-01 20:59:28 +0200
committerChristian Gmeiner <christian.gmeiner@gmail.com>2009-09-01 20:59:28 +0200
commit38d8d30328100fc192050a5d2ad0098e6ab19b84 (patch)
treea3b6582f347b2d33c22c43f7bf934156283dae90
parent3bd41879d4a8929ff0686ebb53c9c7c4016c9d32 (diff)
downloadvdr-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
-rw-r--r--spuencoder.c38
-rw-r--r--spuencoder.h8
2 files changed, 45 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);
+}
diff --git a/spuencoder.h b/spuencoder.h
index 61cda17..3ee8fa1 100644
--- a/spuencoder.h
+++ b/spuencoder.h
@@ -28,21 +28,29 @@
#define SPUENCODER_H
#include <stdint.h>
+#include <vdr/osd.h>
static const int MAX_SPU_DATA = 65220; // TODO vaidate this value
class cSpuEncoder {
public:
void clearOsd();
+ void encode(cBitmap *bmap, int top, int left);
private:
+ cBitmap *bitmap;
+
uint8_t spu[MAX_SPU_DATA];
uint8_t *p; // pointer to current spu data
uint8_t nholder; // nibble holder
uint32_t ncnt; // nibble count
int32_t written; // how much data are written
+ tColor opacity[16];
+ tColor palcolors[16];
+
void writeNibble(uint8_t val);
+ void generateColorPalette();
};
#endif // SPUENCODER_H