Blame libcelt/entenc.h

Packit 664db3
#if !defined(_entenc_H)
Packit 664db3
# define _entenc_H (1)
Packit 664db3
# include <stddef.h>
Packit 664db3
# include "entcode.h"
Packit 664db3
Packit 664db3
Packit 664db3
Packit 664db3
typedef struct ec_enc ec_enc;
Packit 664db3
Packit 664db3
Packit 664db3
Packit 664db3
/*The entropy encoder.*/
Packit 664db3
struct ec_enc{
Packit 664db3
   /*Buffered output.*/
Packit 664db3
   ec_byte_buffer *buf;
Packit 664db3
   /*A buffered output symbol, awaiting carry propagation.*/
Packit 664db3
   int             rem;
Packit 664db3
   /*Number of extra carry propagating symbols.*/
Packit 664db3
   size_t          ext;
Packit 664db3
   /*The number of values in the current range.*/
Packit 664db3
   ec_uint32       rng;
Packit 664db3
   /*The low end of the current range (inclusive).*/
Packit 664db3
   ec_uint32       low;
Packit 664db3
};
Packit 664db3
Packit 664db3
Packit 664db3
/*Initializes the encoder.
Packit 664db3
  _buf: The buffer to store output bytes in.
Packit 664db3
        This must have already been initialized for writing and reset.*/
Packit 664db3
void ec_enc_init(ec_enc *_this,ec_byte_buffer *_buf);
Packit 664db3
/*Encodes a symbol given its frequency information.
Packit 664db3
  The frequency information must be discernable by the decoder, assuming it
Packit 664db3
   has read only the previous symbols from the stream.
Packit 664db3
  It is allowable to change the frequency information, or even the entire
Packit 664db3
   source alphabet, so long as the decoder can tell from the context of the
Packit 664db3
   previously encoded information that it is supposed to do so as well.
Packit 664db3
  _fl: The cumulative frequency of all symbols that come before the one to be
Packit 664db3
        encoded.
Packit 664db3
  _fh: The cumulative frequency of all symbols up to and including the one to
Packit 664db3
        be encoded.
Packit 664db3
       Together with _fl, this defines the range [_fl,_fh) in which the
Packit 664db3
        decoded value will fall.
Packit 664db3
  _ft: The sum of the frequencies of all the symbols*/
Packit 664db3
void ec_encode(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _ft);
Packit 664db3
void ec_encode_bin(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned bits);
Packit 664db3
/*Encodes a sequence of raw bits in the stream.
Packit 664db3
  _fl:  The bits to encode.
Packit 664db3
  _ftb: The number of bits to encode.
Packit 664db3
        This must be at least one, and no more than 32.*/
Packit 664db3
void ec_enc_bits(ec_enc *_this,ec_uint32 _fl,int _ftb);
Packit 664db3
/*Encodes a sequence of raw bits in the stream.
Packit 664db3
  _fl:  The bits to encode.
Packit 664db3
  _ftb: The number of bits to encode.
Packit 664db3
        This must be at least one, and no more than 64.*/
Packit 664db3
void ec_enc_bits64(ec_enc *_this,ec_uint64 _fl,int _ftb);
Packit 664db3
/*Encodes a raw unsigned integer in the stream.
Packit 664db3
  _fl: The integer to encode.
Packit 664db3
  _ft: The number of integers that can be encoded (one more than the max).
Packit 664db3
       This must be at least one, and no more than 2**32-1.*/
Packit 664db3
void ec_enc_uint(ec_enc *_this,ec_uint32 _fl,ec_uint32 _ft);
Packit 664db3
/*Encodes a raw unsigned integer in the stream.
Packit 664db3
  _fl: The integer to encode.
Packit 664db3
  _ft: The number of integers that can be encoded (one more than the max).
Packit 664db3
       This must be at least one, and no more than 2**64-1.*/
Packit 664db3
void ec_enc_uint64(ec_enc *_this,ec_uint64 _fl,ec_uint64 _ft);
Packit 664db3
Packit 664db3
/*Returns the number of bits "used" by the encoded symbols so far.
Packit 664db3
  The actual number of bits may be larger, due to rounding to whole bytes, or
Packit 664db3
   smaller, due to trailing zeros that can be stripped, so this is not an
Packit 664db3
   estimate of the true packet size.
Packit 664db3
  This same number can be computed by the decoder, and is suitable for making
Packit 664db3
   coding decisions.
Packit 664db3
  _b: The number of extra bits of precision to include.
Packit 664db3
      At most 16 will be accurate.
Packit 664db3
  Return: The number of bits scaled by 2**_b.
Packit 664db3
          This will always be slightly larger than the exact value (e.g., all
Packit 664db3
           rounding error is in the positive direction).*/
Packit 664db3
long ec_enc_tell(ec_enc *_this,int _b);
Packit 664db3
Packit 664db3
/*Indicates that there are no more symbols to encode.
Packit 664db3
  All reamining output bytes are flushed to the output buffer.
Packit 664db3
  ec_enc_init() must be called before the encoder can be used again.*/
Packit 664db3
void ec_enc_done(ec_enc *_this);
Packit 664db3
Packit 664db3
#endif