Tool Libs
UMIT-TIROL Institute of Automation and Control Engineering library collection
 
Loading...
Searching...
No Matches
bitstream.h
Go to the documentation of this file.
1
5#pragma once
6#include <stdint.h>
7
12struct BitStream {
13 uint8_t *base;
15 template<typename T>
16 T range(int start, int end) {
17 T dest{};
18 int len = end-start;
19 int i = 1;
20 while (start < end) {
21 dest |= (base[start/8] & 0x80>>start%8) >> (7 - start%8) << (len - i);
22 ++start;
23 ++i;
24 }
25 return dest;
26 }
27};
Wrapper for extracting bitwise data from a stream of bytes.
Definition bitstream.h:12
T range(int start, int end)
return bitrange from stream as T
Definition bitstream.h:16
uint8_t * base
pointer to first byte of stream
Definition bitstream.h:13