#ifndef RC_ENCODER_H
#define RC_ENCODER_H
#include "types.h"
#include "rcmodel.h"
class RCencoder {
public:
RCencoder() : error(false), low(0), range(-1u) {}
virtual ~RCencoder() {}
void finish();
void encode(bool s);
template <typename UINT>
void encode(UINT s, uint n);
template <typename UINT>
void encode(UINT s, UINT l, UINT h);
void encode(uint s, RCmodel* rm);
virtual void putbyte(uint byte) = 0;
virtual void flush() {}
virtual size_t bytes() const = 0;
bool error;
private:
void encode_shift(uint s, uint n);
void encode_ratio(uint s, uint n);
void put(uint n);
void normalize();
uint low; uint range; };
#include "rcencoder.inl"
#endif