38 lines
1018 B
C++
38 lines
1018 B
C++
#ifndef DECODINGBITSTREAM_H
|
|
#define DECODINGBITSTREAM_H
|
|
|
|
#include "SD.h"
|
|
|
|
class DecodingBitStream
|
|
{
|
|
public:
|
|
DecodingBitStream(File* _stream, uint8_t _bytesAvailable, uint16_t _numberOfBitsInCode) :
|
|
stream(_stream), bytesAvailable(_bytesAvailable), numberOfBitsInCode(_numberOfBitsInCode),
|
|
bitBuffer(0), bitsAvailable(0) {}
|
|
~DecodingBitStream() {}
|
|
|
|
void setNumberOfBitsInCode(uint16_t _numberOfBitsInCode) { numberOfBitsInCode = _numberOfBitsInCode; }
|
|
void setBytesAvailable(uint8_t _bytesAvailable) { bytesAvailable = _bytesAvailable; }
|
|
|
|
uint16_t getCode();
|
|
uint16_t getNumberOfBitsInCode() { return numberOfBitsInCode; }
|
|
|
|
bool dataRemainingInBlock() { return bytesAvailable > 0 || bitsAvailable > 0; }
|
|
|
|
static uint16_t getNumberOfBitsToRepresentValue(uint16_t value);
|
|
|
|
private:
|
|
void
|
|
verifyEnoughBits(void);
|
|
uint16_t
|
|
bitBuffer;
|
|
uint8_t
|
|
bytesAvailable,
|
|
bitsAvailable,
|
|
numberOfBitsInCode;
|
|
File*
|
|
stream;
|
|
};
|
|
|
|
#endif
|