diff options
-rw-r--r-- | spuencoder.c | 15 | ||||
-rw-r--r-- | spuencoder.h | 13 |
2 files changed, 28 insertions, 0 deletions
diff --git a/spuencoder.c b/spuencoder.c index 965683a..d61b462 100644 --- a/spuencoder.c +++ b/spuencoder.c @@ -65,3 +65,18 @@ void cSpuEncoder::clearOsd() cDxr3Interface::instance()->WriteSpu((uchar *)&d, 10); } + +void cSpuEncoder::writeNibble(uint8_t val) { + + // look if we have an overflow + if (written == MAX_SPU_DATA) { + throw "overflow"; + } + + if (ncnt++ & 1) { + *p++ = nholder | ((val) & 0x0f); + written++; + } else { + nholder = (val << 4); + } +} diff --git a/spuencoder.h b/spuencoder.h index 56e5dee..61cda17 100644 --- a/spuencoder.h +++ b/spuencoder.h @@ -27,9 +27,22 @@ #ifndef SPUENCODER_H #define SPUENCODER_H +#include <stdint.h> + +static const int MAX_SPU_DATA = 65220; // TODO vaidate this value + class cSpuEncoder { public: void clearOsd(); + +private: + 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 + + void writeNibble(uint8_t val); }; #endif // SPUENCODER_H |