diff options
-rw-r--r-- | spuencoder.c | 55 | ||||
-rw-r--r-- | spuencoder.h | 5 | ||||
-rw-r--r-- | spuregion.c | 8 | ||||
-rw-r--r-- | spuregion.h | 2 |
4 files changed, 63 insertions, 7 deletions
diff --git a/spuencoder.c b/spuencoder.c index 2fbce2a..71ba6c0 100644 --- a/spuencoder.c +++ b/spuencoder.c @@ -97,7 +97,7 @@ void cSpuEncoder::encode(cBitmap *bmap, int top, int left) reg->addColIndex(bitmap->Index(colors[i])); } - regions.push(reg); + regions.push_back(reg); dsyslog("[dxr3-spuencoder] rle data"); @@ -157,6 +157,52 @@ void cSpuEncoder::writeColorAndAlpha(sSection &sec, bool withCMD) spu[written++] = (opacity[sec.colIndex[2]] << 4) | (opacity[sec.colIndex[3]] & 0x0f); } +void cSpuEncoder::writeRegionInformation() +{ + dsyslog("writting region definitions"); + + spu[written++] = CMD_CHG_COLCON; + + int32_t size_fill = written; + + spu[written++] = 0x00; // total size of parameter area + spu[written++] = 0x00; // will be filled later + + for (size_t i = 1; i < regions.size(); i++) { + cSpuRegion *reg = regions[i]; + + // define region (LN_CTLI) + spu[written++] = (reg->startLine >> 8); + spu[written++] = reg->startLine & 0xff; + spu[written++] = (((reg->openSections() & 0x0f) << 4)| ((reg->endLine >> 8) & 0x0f)); + spu[written++] = reg->endLine & 0xff; + + for (size_t j = 0; j <= reg->openSections(); j++) { + + sSection sec = reg->sections[i]; + + // define section (PXCTLI) + spu[written++] = (sec.startColumn >> 8) & 0x0f; + spu[written++] = sec.startColumn & 0xff; + + // write color and alpha + writeColorAndAlpha(sec, false); + } + } + + spu[written++] = 0x0f; // end of parameter area + spu[written++] = 0xff; + spu[written++] = 0xff; + spu[written++] = 0xff; + + // update size of 0x07 command + int32_t s = written - size_fill - 1; + dsyslog("size of 07 command %d", s); + + spu[size_fill++] = s >> 8; + spu[size_fill++] = s & 0xff; +} + void cSpuEncoder::generateColorPalette() { // we need to convert the color we get from @@ -259,11 +305,10 @@ void cSpuEncoder::generateSpuData(bool topAndBottom) throw (char const* ) void cSpuEncoder::clearRegions() { - while (!regions.empty()) { - cSpuRegion *reg = regions.front(); - delete reg; - regions.pop(); + for (size_t i = 0; i < regions.size(); i++) { + delete regions[i]; } + regions.clear(); } void cSpuEncoder::rle4colors() diff --git a/spuencoder.h b/spuencoder.h index 7ef0b10..149ee5c 100644 --- a/spuencoder.h +++ b/spuencoder.h @@ -29,7 +29,7 @@ #include <stdint.h> #include <vdr/osd.h> -#include <queue> +#include <vector> #include "dxr3singleton.h" #include "spuregion.h" @@ -58,7 +58,7 @@ private: int32_t written; // how much data are written sRle rleData; // storage for encoded data - std::queue<cSpuRegion *> regions; + std::vector<cSpuRegion *> regions; int numColors; // len of tColor array of current bitmap const tColor* colors; // pointer to tColor array from current bitmap @@ -67,6 +67,7 @@ private: void writeNibble(uint8_t val); void writeColorAndAlpha(sSection &sec, bool withCMD); + void writeRegionInformation(); void generateColorPalette(); void generateSpuData(bool topAndBottom) throw (char const* ); diff --git a/spuregion.c b/spuregion.c index 4b25147..6055ec3 100644 --- a/spuregion.c +++ b/spuregion.c @@ -31,6 +31,14 @@ cSpuRegion::cSpuRegion() : startLine(0), endLine(0), usedSections(0) memset(sections, 0, sizeof(sections)); } +uint8_t cSpuRegion::openSections() +{ + // return the count of open sections. + // keep in mind that it will return usedSections + 1 + // to allow easy for-looping like used in stl containers. + return usedSections + 1; +} + bool cSpuRegion::addColIndex(tIndex idx) { sSection *sec = §ions[usedSections]; diff --git a/spuregion.h b/spuregion.h index b94c65f..0af9996 100644 --- a/spuregion.h +++ b/spuregion.h @@ -47,6 +47,8 @@ public: uint16_t endLine; sSection sections[15]; // sections per region + uint8_t openSections(); + bool addColIndex(tIndex idx); bool containsColIndex(tIndex idx); |