summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c43
1 files changed, 42 insertions, 1 deletions
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)