From 0ecf6b00d43a2f2a372ff0b8b0abd8a75b3c0f0e Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 18 Sep 2011 11:36:38 +0200 Subject: Fixed handling DVB subtitles and implemented decoding textual DVB subtitles --- tools.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'tools.c') diff --git a/tools.c b/tools.c index c9a3a44e..35693821 100644 --- a/tools.c +++ b/tools.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 2.17 2011/08/15 13:35:23 kls Exp $ + * $Id: tools.c 2.18 2011/09/18 11:22:21 kls Exp $ */ #include "tools.h" @@ -1196,6 +1196,47 @@ const char *cBase64Encoder::NextLine(void) return NULL; } +// --- cBitStream ------------------------------------------------------------ + +int cBitStream::GetBit(void) +{ + if (index >= length) + return 1; + int r = (data[index >> 3] >> (7 - (index & 7))) & 1; + ++index; + return r; +} + +uint32_t cBitStream::GetBits(int n) +{ + uint32_t r = 0; + while (n--) + r |= GetBit() << n; + return r; +} + +void cBitStream::ByteAlign(void) +{ + int n = index % 8; + if (n > 0) + SkipBits(8 - n); +} + +void cBitStream::WordAlign(void) +{ + int n = index % 16; + if (n > 0) + SkipBits(16 - n); +} + +bool cBitStream::SetLength(int Length) +{ + if (Length > length) + return false; + length = Length; + return true; +} + // --- cReadLine ------------------------------------------------------------- cReadLine::cReadLine(void) -- cgit v1.2.3