VideoCodec/Encoder/BinaryStreamBuilder.h
#ifndef BINARYSTREAMBUILDER_H_
#define BINARYSTREAMBUILDER_H_
#include "../Logger.h"
#include "../Data/Constants.h"
namespace VideoCodec
{
// Builds a byte array out of data which can be of single-bit precision.
class BinaryStreamBuilder
{
public:
BinaryStreamBuilder();
virtual ~BinaryStreamBuilder();
// Methods to put values into the stream.
void PutValue(unsigned short int value, unsigned char bitCount);
// Allocates a new stream with the specified number of bits.
void AllocateStream(FrameDataBitLength streamSizeBits);
// Writes out any outstanding bits required so that the marker is on a boundary of the underlying type.
void AlignStream();
// Get the underlying stream and its metadata.
unsigned char* GetStream();
long int GetWrittenBitCount();
long int GetStreamCapacity();
private:
bool isInitialized;
long int writtenBitCount;
long int streamCapacity;
unsigned char* data;
unsigned char workingValue;
unsigned char workingPosition;
long int dataIndex;
};
}
#endif /*BINARYSTREAMBUILDER_H_*/