summaryrefslogtreecommitdiff
path: root/spuencoder.c
diff options
context:
space:
mode:
authorChristian Gmeiner <christian.gmeiner@gmail.com>2009-09-01 21:33:17 +0200
committerChristian Gmeiner <christian.gmeiner@gmail.com>2009-09-01 21:33:17 +0200
commit78aeb8440ef4a734bb0836ef65c65fff43ca61df (patch)
treec37623c2276f665ce129468b9c491c4941d68a2a /spuencoder.c
parent40ff1a1bca9b4b1c3f1e361fc85e652e010bc15a (diff)
downloadvdr-plugin-dxr3-78aeb8440ef4a734bb0836ef65c65fff43ca61df.tar.gz
vdr-plugin-dxr3-78aeb8440ef4a734bb0836ef65c65fff43ca61df.tar.bz2
add basic implementaion of generateSpuData
Diffstat (limited to 'spuencoder.c')
-rw-r--r--spuencoder.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/spuencoder.c b/spuencoder.c
index 88b9550..bb88f4c 100644
--- a/spuencoder.c
+++ b/spuencoder.c
@@ -143,4 +143,79 @@ void cSpuEncoder::generateColorPalette()
void cSpuEncoder::generateSpuData(bool topAndBottom) throw (char const* )
{
+ // reset pointer
+ p = &spu[4];
+
+ int bottomStart;
+
+ // copy rle encoded data into spu buffer
+ if (topAndBottom) {
+
+ memcpy(p, rleData.top, rleData.topLen);
+ p += rleData.topLen;
+
+ memcpy(p, rleData.bottom, rleData.bottomLen);
+ p += rleData.bottomLen;
+
+ bottomStart = 4 + rleData.topLen;
+ written = bottomStart + rleData.bottomLen;
+
+ } else {
+
+ memcpy(p, rleData.top, rleData.topLen);
+ p += rleData.topLen;
+
+ bottomStart = 4;
+ written = bottomStart + rleData.topLen;
+ }
+
+ // update size of pixel block
+ spu[2] = written >> 8;
+ spu[3] = written & 0xff;
+
+ int x1 = written;
+
+ // display duration
+ spu[written++] = 0x00;
+ spu[written++] = 0x00; // duration before turn on command occurs (will not be used)
+
+ // x1
+ spu[written++] = x1 >> 8; // since this is the last command block, this
+ spu[written++] = x1 & 0xff; // points back to itself
+
+ // 0x00: force displaying
+ spu[written++] = CMD_FORCE_DISPLAYING;
+
+ // 0x05: coordinates
+ uint32_t right = left + bitmap->Width() - 1;
+ uint32_t bottom = top + bitmap->Height() - 1;
+
+ dsyslog("top %d left %d", top, left);
+
+ spu[written++] = CMD_SET_DISPLAYAREA;
+ spu[written++] = left >> 4;
+ spu[written++] = ((left & 0xf) << 4) + (right >> 8);
+ spu[written++] = (right & 0xff);
+ spu[written++] = top >> 4;
+ spu[written++] = ((top & 0xf) << 4) + (bottom >> 8);
+ spu[written++] = (bottom & 0xff);
+
+ // 0x06: both fields' offsets
+ spu[written++] = CMD_SET_PIXEL_ADDRESES;
+ spu[written++] = 0x00; // even start at index 4
+ spu[written++] = 0x04;
+ spu[written++] = bottomStart >> 8;
+ spu[written++] = bottomStart & 0xff;
+
+ // TODO write color-> palette index and alpha data
+
+ // 0xff: end sequence
+ spu[written++] = 0xff;
+ if (!(written & 1)) {
+ spu[written++] = 0xff;
+ }
+
+ // write overall packet size
+ spu[0] = written >> 8;
+ spu[1] = written & 0xff;
}