summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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