Commit 9bac8c17 authored by Timothy B. Terriberry's avatar Timothy B. Terriberry Committed by Jean-Marc Valin
Browse files

Eliminate the ec_int32 and ec_uint32 typedefs.

These were used because the entropy coder originally came from
 outside libcelt, and thus did not have a common type system.
It's now undergone enough modification that it's not ever likely to
 be used as-is in another codec without some porting effort, so
 there's no real reason to maintain the typedefs separately.
Hopefully we'll replace these all again somedate with a common set
 of Opus typedefs, but for now this will do.

This fixes an issue caused by commit 6c8acbf1, which moved the
 ec_ilog() prototype from entcode.h to ecintrin.h, where the
 ec_uint32 typedef was not yet available.
Thanks to John Ridges for the report.
parent 115fa35a
...@@ -1161,7 +1161,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c ...@@ -1161,7 +1161,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c
void quant_all_bands(int encode, const CELTMode *m, int start, int end, void quant_all_bands(int encode, const CELTMode *m, int start, int end,
celt_norm *_X, celt_norm *_Y, unsigned char *collapse_masks, const celt_ener *bandE, int *pulses, celt_norm *_X, celt_norm *_Y, unsigned char *collapse_masks, const celt_ener *bandE, int *pulses,
int shortBlocks, int spread, int dual_stereo, int intensity, int *tf_res, int resynth, int shortBlocks, int spread, int dual_stereo, int intensity, int *tf_res, int resynth,
celt_int32 total_bits, celt_int32 balance, ec_ctx *ec, int LM, int codedBands, ec_uint32 *seed) celt_int32 total_bits, celt_int32 balance, ec_ctx *ec, int LM, int codedBands, celt_uint32 *seed)
{ {
int i; int i;
celt_int32 remaining_bits; celt_int32 remaining_bits;
......
...@@ -84,7 +84,7 @@ void haar1(celt_norm *X, int N0, int stride); ...@@ -84,7 +84,7 @@ void haar1(celt_norm *X, int N0, int stride);
void quant_all_bands(int encode, const CELTMode *m, int start, int end, void quant_all_bands(int encode, const CELTMode *m, int start, int end,
celt_norm * X, celt_norm * Y, unsigned char *collapse_masks, const celt_ener *bandE, int *pulses, celt_norm * X, celt_norm * Y, unsigned char *collapse_masks, const celt_ener *bandE, int *pulses,
int time_domain, int fold, int dual_stereo, int intensity, int *tf_res, int resynth, int time_domain, int fold, int dual_stereo, int intensity, int *tf_res, int resynth,
celt_int32 total_bits, celt_int32 balance, ec_ctx *ec, int M, int codedBands, ec_uint32 *seed); celt_int32 total_bits, celt_int32 balance, ec_ctx *ec, int M, int codedBands, celt_uint32 *seed);
void stereo_decision(const CELTMode *m, celt_norm * restrict X, int *stereo_mode, int len, int M); void stereo_decision(const CELTMode *m, celt_norm * restrict X, int *stereo_mode, int len, int M);
......
...@@ -113,7 +113,7 @@ struct CELTEncoder { ...@@ -113,7 +113,7 @@ struct CELTEncoder {
/* Everything beyond this point gets cleared on a reset */ /* Everything beyond this point gets cleared on a reset */
#define ENCODER_RESET_START rng #define ENCODER_RESET_START rng
ec_uint32 rng; celt_uint32 rng;
int spread_decision; int spread_decision;
int delayedIntra; int delayedIntra;
int tonal_average; int tonal_average;
...@@ -687,8 +687,8 @@ static void tf_encode(int start, int end, int isTransient, int *tf_res, int LM, ...@@ -687,8 +687,8 @@ static void tf_encode(int start, int end, int isTransient, int *tf_res, int LM,
int tf_select_rsv; int tf_select_rsv;
int tf_changed; int tf_changed;
int logp; int logp;
ec_uint32 budget; celt_uint32 budget;
ec_uint32 tell; celt_uint32 tell;
budget = enc->storage*8; budget = enc->storage*8;
tell = ec_tell(enc); tell = ec_tell(enc);
logp = isTransient ? 2 : 4; logp = isTransient ? 2 : 4;
...@@ -727,8 +727,8 @@ static void tf_decode(int start, int end, int isTransient, int *tf_res, int LM, ...@@ -727,8 +727,8 @@ static void tf_decode(int start, int end, int isTransient, int *tf_res, int LM,
int tf_select_rsv; int tf_select_rsv;
int tf_changed; int tf_changed;
int logp; int logp;
ec_uint32 budget; celt_uint32 budget;
ec_uint32 tell; celt_uint32 tell;
budget = dec->storage*8; budget = dec->storage*8;
tell = ec_tell(dec); tell = ec_tell(dec);
...@@ -1810,7 +1810,7 @@ struct CELTDecoder { ...@@ -1810,7 +1810,7 @@ struct CELTDecoder {
/* Everything beyond this point gets cleared on a reset */ /* Everything beyond this point gets cleared on a reset */
#define DECODER_RESET_START rng #define DECODER_RESET_START rng
ec_uint32 rng; celt_uint32 rng;
int last_pitch_index; int last_pitch_index;
int loss_count; int loss_count;
int postfilter_period; int postfilter_period;
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
with frac bits of fractional precision. with frac bits of fractional precision.
Tested for all possible 32-bit inputs with frac=4, where the maximum Tested for all possible 32-bit inputs with frac=4, where the maximum
overestimation is 0.06254243 bits.*/ overestimation is 0.06254243 bits.*/
int log2_frac(ec_uint32 val, int frac) int log2_frac(celt_uint32 val, int frac)
{ {
int l; int l;
l=EC_ILOG(val); l=EC_ILOG(val);
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "entenc.h" #include "entenc.h"
#include "entdec.h" #include "entdec.h"
int log2_frac(ec_uint32 val, int frac); int log2_frac(celt_uint32 val, int frac);
void get_required_bits(celt_int16 *bits, int N, int K, int frac); void get_required_bits(celt_int16 *bits, int N, int K, int frac);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
*/ */
/*Some common macros for potential platform-specific optimization.*/ /*Some common macros for potential platform-specific optimization.*/
#include "celt_types.h"
#include <math.h> #include <math.h>
#include <limits.h> #include <limits.h>
#if !defined(_ecintrin_H) #if !defined(_ecintrin_H)
...@@ -114,7 +115,7 @@ static __inline int ec_bsr(unsigned long _x){ ...@@ -114,7 +115,7 @@ static __inline int ec_bsr(unsigned long _x){
When we need to, it can be special cased.*/ When we need to, it can be special cased.*/
# define EC_ILOG(_x) (EC_CLZ0-EC_CLZ(_x)) # define EC_ILOG(_x) (EC_CLZ0-EC_CLZ(_x))
#else #else
int ec_ilog(ec_uint32 _v); int ec_ilog(celt_uint32 _v);
# define EC_ILOG(_x) (ec_ilog(_x)) # define EC_ILOG(_x) (ec_ilog(_x))
#endif #endif
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#if !defined(EC_CLZ) #if !defined(EC_CLZ)
int ec_ilog(ec_uint32 _v){ int ec_ilog(celt_uint32 _v){
/*On a Pentium M, this branchless version tested as the fastest on /*On a Pentium M, this branchless version tested as the fastest on
1,000,000,000 random 32-bit integers, edging out a similar version with 1,000,000,000 random 32-bit integers, edging out a similar version with
branches, and a 256-entry LUT version.*/ branches, and a 256-entry LUT version.*/
...@@ -59,11 +59,11 @@ int ec_ilog(ec_uint32 _v){ ...@@ -59,11 +59,11 @@ int ec_ilog(ec_uint32 _v){
#endif #endif
ec_uint32 ec_tell_frac(ec_ctx *_this){ celt_uint32 ec_tell_frac(ec_ctx *_this){
ec_uint32 nbits; celt_uint32 nbits;
ec_uint32 r; celt_uint32 r;
int l; int l;
int i; int i;
/*To handle the non-integral number of bits still left in the encoder/decoder /*To handle the non-integral number of bits still left in the encoder/decoder
state, we compute the worst-case number of bits of val that must be state, we compute the worst-case number of bits of val that must be
encoded to ensure that the value is inside the range for any possible encoded to ensure that the value is inside the range for any possible
......
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
typedef celt_int32 ec_int32; /*OPT: ec_window must be at least 32 bits, but if you have fast arithmetic on a
typedef celt_uint32 ec_uint32; larger type, you can speed up the decoder by using it here.*/
typedef celt_uint32 ec_window; typedef celt_uint32 ec_window;
typedef struct ec_ctx ec_ctx; typedef struct ec_ctx ec_ctx;
typedef struct ec_ctx ec_enc; typedef struct ec_ctx ec_enc;
...@@ -44,8 +44,6 @@ typedef struct ec_ctx ec_dec; ...@@ -44,8 +44,6 @@ typedef struct ec_ctx ec_dec;
/*OPT: This must be at least 32 bits, but if you have fast arithmetic on a
larger type, you can speed up the decoder by using it for ec_window.*/
# define EC_WINDOW_SIZE ((int)sizeof(ec_window)*CHAR_BIT) # define EC_WINDOW_SIZE ((int)sizeof(ec_window)*CHAR_BIT)
/*The number of bits to use for the range-coded part of unsigned integers.*/ /*The number of bits to use for the range-coded part of unsigned integers.*/
...@@ -64,9 +62,9 @@ struct ec_ctx{ ...@@ -64,9 +62,9 @@ struct ec_ctx{
/*Buffered input/output.*/ /*Buffered input/output.*/
unsigned char *buf; unsigned char *buf;
/*The size of the buffer.*/ /*The size of the buffer.*/
ec_uint32 storage; celt_uint32 storage;
/*The offset at which the last byte containing raw bits was read/written.*/ /*The offset at which the last byte containing raw bits was read/written.*/
ec_uint32 end_offs; celt_uint32 end_offs;
/*Bits that will be read from/written at the end.*/ /*Bits that will be read from/written at the end.*/
ec_window end_window; ec_window end_window;
/*Number of valid bits in end_window.*/ /*Number of valid bits in end_window.*/
...@@ -75,16 +73,16 @@ struct ec_ctx{ ...@@ -75,16 +73,16 @@ struct ec_ctx{
This does not include partial bits currently in the range coder.*/ This does not include partial bits currently in the range coder.*/
int nbits_total; int nbits_total;
/*The offset at which the next range coder byte will be read/written.*/ /*The offset at which the next range coder byte will be read/written.*/
ec_uint32 offs; celt_uint32 offs;
/*The number of values in the current range.*/ /*The number of values in the current range.*/
ec_uint32 rng; celt_uint32 rng;
/*In the decoder: the difference between the top of the current range and /*In the decoder: the difference between the top of the current range and
the input value, minus one. the input value, minus one.
In the encoder: the low end of the current range.*/ In the encoder: the low end of the current range.*/
ec_uint32 val; celt_uint32 val;
/*In the decoder: the saved normalization factor from ec_decode(). /*In the decoder: the saved normalization factor from ec_decode().
In the encoder: the number of oustanding carry propagating symbols.*/ In the encoder: the number of oustanding carry propagating symbols.*/
ec_uint32 ext; celt_uint32 ext;
/*A buffered input/output symbol, awaiting carry propagation.*/ /*A buffered input/output symbol, awaiting carry propagation.*/
int rem; int rem;
/*Nonzero if an error occurred.*/ /*Nonzero if an error occurred.*/
...@@ -97,7 +95,7 @@ static inline void ec_reset(ec_ctx *_this){ ...@@ -97,7 +95,7 @@ static inline void ec_reset(ec_ctx *_this){
_this->offs=_this->end_offs=0; _this->offs=_this->end_offs=0;
} }
static inline ec_uint32 ec_range_bytes(ec_ctx *_this){ static inline celt_uint32 ec_range_bytes(ec_ctx *_this){
return _this->offs; return _this->offs;
} }
...@@ -125,6 +123,6 @@ static inline int ec_tell(ec_ctx *_this){ ...@@ -125,6 +123,6 @@ static inline int ec_tell(ec_ctx *_this){
Return: The number of bits scaled by 2**BITRES. Return: The number of bits scaled by 2**BITRES.
This will always be slightly larger than the exact value (e.g., all This will always be slightly larger than the exact value (e.g., all
rounding error is in the positive direction).*/ rounding error is in the positive direction).*/
ec_uint32 ec_tell_frac(ec_ctx *_this); celt_uint32 ec_tell_frac(ec_ctx *_this);
#endif #endif
...@@ -125,7 +125,7 @@ static void ec_dec_normalize(ec_dec *_this){ ...@@ -125,7 +125,7 @@ static void ec_dec_normalize(ec_dec *_this){
} }
} }
void ec_dec_init(ec_dec *_this,unsigned char *_buf,ec_uint32 _storage){ void ec_dec_init(ec_dec *_this,unsigned char *_buf,celt_uint32 _storage){
_this->buf=_buf; _this->buf=_buf;
_this->storage=_storage; _this->storage=_storage;
_this->end_offs=0; _this->end_offs=0;
...@@ -160,7 +160,7 @@ unsigned ec_decode_bin(ec_dec *_this,unsigned _bits){ ...@@ -160,7 +160,7 @@ unsigned ec_decode_bin(ec_dec *_this,unsigned _bits){
} }
void ec_dec_update(ec_dec *_this,unsigned _fl,unsigned _fh,unsigned _ft){ void ec_dec_update(ec_dec *_this,unsigned _fl,unsigned _fh,unsigned _ft){
ec_uint32 s; celt_uint32 s;
s=IMUL32(_this->ext,_ft-_fh); s=IMUL32(_this->ext,_ft-_fh);
_this->val-=s; _this->val-=s;
_this->rng=_fl>0?IMUL32(_this->ext,_fh-_fl):_this->rng-s; _this->rng=_fl>0?IMUL32(_this->ext,_fh-_fl):_this->rng-s;
...@@ -169,10 +169,10 @@ void ec_dec_update(ec_dec *_this,unsigned _fl,unsigned _fh,unsigned _ft){ ...@@ -169,10 +169,10 @@ void ec_dec_update(ec_dec *_this,unsigned _fl,unsigned _fh,unsigned _ft){
/*The probability of having a "one" is 1/(1<<_logp).*/ /*The probability of having a "one" is 1/(1<<_logp).*/
int ec_dec_bit_logp(ec_dec *_this,unsigned _logp){ int ec_dec_bit_logp(ec_dec *_this,unsigned _logp){
ec_uint32 r; celt_uint32 r;
ec_uint32 d; celt_uint32 d;
ec_uint32 s; celt_uint32 s;
int ret; int ret;
r=_this->rng; r=_this->rng;
d=_this->val; d=_this->val;
s=r>>_logp; s=r>>_logp;
...@@ -184,11 +184,11 @@ int ec_dec_bit_logp(ec_dec *_this,unsigned _logp){ ...@@ -184,11 +184,11 @@ int ec_dec_bit_logp(ec_dec *_this,unsigned _logp){
} }
int ec_dec_icdf(ec_dec *_this,const unsigned char *_icdf,unsigned _ftb){ int ec_dec_icdf(ec_dec *_this,const unsigned char *_icdf,unsigned _ftb){
ec_uint32 r; celt_uint32 r;
ec_uint32 d; celt_uint32 d;
ec_uint32 s; celt_uint32 s;
ec_uint32 t; celt_uint32 t;
int ret; int ret;
s=_this->rng; s=_this->rng;
d=_this->val; d=_this->val;
r=s>>_ftb; r=s>>_ftb;
...@@ -204,7 +204,7 @@ int ec_dec_icdf(ec_dec *_this,const unsigned char *_icdf,unsigned _ftb){ ...@@ -204,7 +204,7 @@ int ec_dec_icdf(ec_dec *_this,const unsigned char *_icdf,unsigned _ftb){
return ret; return ret;
} }
ec_uint32 ec_dec_uint(ec_dec *_this,ec_uint32 _ft){ celt_uint32 ec_dec_uint(ec_dec *_this,celt_uint32 _ft){
unsigned ft; unsigned ft;
unsigned s; unsigned s;
int ftb; int ftb;
...@@ -213,12 +213,12 @@ ec_uint32 ec_dec_uint(ec_dec *_this,ec_uint32 _ft){ ...@@ -213,12 +213,12 @@ ec_uint32 ec_dec_uint(ec_dec *_this,ec_uint32 _ft){
_ft--; _ft--;
ftb=EC_ILOG(_ft); ftb=EC_ILOG(_ft);
if(ftb>EC_UINT_BITS){ if(ftb>EC_UINT_BITS){
ec_uint32 t; celt_uint32 t;
ftb-=EC_UINT_BITS; ftb-=EC_UINT_BITS;
ft=(unsigned)(_ft>>ftb)+1; ft=(unsigned)(_ft>>ftb)+1;
s=ec_decode(_this,ft); s=ec_decode(_this,ft);
ec_dec_update(_this,s,s+1,ft); ec_dec_update(_this,s,s+1,ft);
t=(ec_uint32)s<<ftb|ec_dec_bits(_this,ftb); t=(celt_uint32)s<<ftb|ec_dec_bits(_this,ftb);
if(t<=_ft)return t; if(t<=_ft)return t;
_this->error=1; _this->error=1;
return _ft; return _ft;
...@@ -231,10 +231,10 @@ ec_uint32 ec_dec_uint(ec_dec *_this,ec_uint32 _ft){ ...@@ -231,10 +231,10 @@ ec_uint32 ec_dec_uint(ec_dec *_this,ec_uint32 _ft){
} }
} }
ec_uint32 ec_dec_bits(ec_dec *_this,unsigned _bits){ celt_uint32 ec_dec_bits(ec_dec *_this,unsigned _bits){
ec_window window; ec_window window;
int available; int available;
ec_uint32 ret; celt_uint32 ret;
window=_this->end_window; window=_this->end_window;
available=_this->nend_bits; available=_this->nend_bits;
if(available<_bits){ if(available<_bits){
...@@ -244,7 +244,7 @@ ec_uint32 ec_dec_bits(ec_dec *_this,unsigned _bits){ ...@@ -244,7 +244,7 @@ ec_uint32 ec_dec_bits(ec_dec *_this,unsigned _bits){
} }
while(available<=EC_WINDOW_SIZE-EC_SYM_BITS); while(available<=EC_WINDOW_SIZE-EC_SYM_BITS);
} }
ret=(ec_uint32)window&((ec_uint32)1<<_bits)-1; ret=(celt_uint32)window&((celt_uint32)1<<_bits)-1;
window>>=_bits; window>>=_bits;
available-=_bits; available-=_bits;
_this->end_window=window; _this->end_window=window;
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
/*Initializes the decoder. /*Initializes the decoder.
_buf: The input buffer to use. _buf: The input buffer to use.
Return: 0 on success, or a negative value on error.*/ Return: 0 on success, or a negative value on error.*/
void ec_dec_init(ec_dec *_this,unsigned char *_buf,ec_uint32 _storage); void ec_dec_init(ec_dec *_this,unsigned char *_buf,celt_uint32 _storage);
/*Calculates the cumulative frequency for the next symbol. /*Calculates the cumulative frequency for the next symbol.
This can then be fed into the probability model to determine what that This can then be fed into the probability model to determine what that
...@@ -89,7 +89,7 @@ int ec_dec_icdf(ec_dec *_this,const unsigned char *_icdf,unsigned _ftb); ...@@ -89,7 +89,7 @@ int ec_dec_icdf(ec_dec *_this,const unsigned char *_icdf,unsigned _ftb);
_ft: The number of integers that can be decoded (one more than the max). _ft: The number of integers that can be decoded (one more than the max).
This must be at least one, and no more than 2**32-1. This must be at least one, and no more than 2**32-1.
Return: The decoded bits.*/ Return: The decoded bits.*/
ec_uint32 ec_dec_uint(ec_dec *_this,ec_uint32 _ft); celt_uint32 ec_dec_uint(ec_dec *_this,celt_uint32 _ft);
/*Extracts a sequence of raw bits from the stream. /*Extracts a sequence of raw bits from the stream.
The bits must have been encoded with ec_enc_bits(). The bits must have been encoded with ec_enc_bits().
...@@ -97,6 +97,6 @@ ec_uint32 ec_dec_uint(ec_dec *_this,ec_uint32 _ft); ...@@ -97,6 +97,6 @@ ec_uint32 ec_dec_uint(ec_dec *_this,ec_uint32 _ft);
_ftb: The number of bits to extract. _ftb: The number of bits to extract.
This must be between 0 and 25, inclusive. This must be between 0 and 25, inclusive.
Return: The decoded bits.*/ Return: The decoded bits.*/
ec_uint32 ec_dec_bits(ec_dec *_this,unsigned _ftb); celt_uint32 ec_dec_bits(ec_dec *_this,unsigned _ftb);
#endif #endif
...@@ -114,7 +114,7 @@ static void ec_enc_normalize(ec_enc *_this){ ...@@ -114,7 +114,7 @@ static void ec_enc_normalize(ec_enc *_this){
} }
} }
void ec_enc_init(ec_enc *_this,unsigned char *_buf,ec_uint32 _size){ void ec_enc_init(ec_enc *_this,unsigned char *_buf,celt_uint32 _size){
_this->buf=_buf; _this->buf=_buf;
_this->end_offs=0; _this->end_offs=0;
_this->end_window=0; _this->end_window=0;
...@@ -131,7 +131,7 @@ void ec_enc_init(ec_enc *_this,unsigned char *_buf,ec_uint32 _size){ ...@@ -131,7 +131,7 @@ void ec_enc_init(ec_enc *_this,unsigned char *_buf,ec_uint32 _size){
} }
void ec_encode(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _ft){ void ec_encode(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _ft){
ec_uint32 r; celt_uint32 r;
r=_this->rng/_ft; r=_this->rng/_ft;
if(_fl>0){ if(_fl>0){
_this->val+=_this->rng-IMUL32(r,(_ft-_fl)); _this->val+=_this->rng-IMUL32(r,(_ft-_fl));
...@@ -142,7 +142,7 @@ void ec_encode(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _ft){ ...@@ -142,7 +142,7 @@ void ec_encode(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _ft){
} }
void ec_encode_bin(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _bits){ void ec_encode_bin(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _bits){
ec_uint32 r; celt_uint32 r;
r=_this->rng>>_bits; r=_this->rng>>_bits;
if(_fl>0){ if(_fl>0){
_this->val+=_this->rng-IMUL32(r,((1<<_bits)-_fl)); _this->val+=_this->rng-IMUL32(r,((1<<_bits)-_fl));
...@@ -154,9 +154,9 @@ void ec_encode_bin(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _bits){ ...@@ -154,9 +154,9 @@ void ec_encode_bin(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _bits){
/*The probability of having a "one" is 1/(1<<_logp).*/ /*The probability of having a "one" is 1/(1<<_logp).*/
void ec_enc_bit_logp(ec_enc *_this,int _val,unsigned _logp){ void ec_enc_bit_logp(ec_enc *_this,int _val,unsigned _logp){
ec_uint32 r; celt_uint32 r;
ec_uint32 s; celt_uint32 s;
ec_uint32 l; celt_uint32 l;
r=_this->rng; r=_this->rng;
l=_this->val; l=_this->val;
s=r>>_logp; s=r>>_logp;
...@@ -167,7 +167,7 @@ void ec_enc_bit_logp(ec_enc *_this,int _val,unsigned _logp){ ...@@ -167,7 +167,7 @@ void ec_enc_bit_logp(ec_enc *_this,int _val,unsigned _logp){
} }
void ec_enc_icdf(ec_enc *_this,int _s,const unsigned char *_icdf,unsigned _ftb){ void ec_enc_icdf(ec_enc *_this,int _s,const unsigned char *_icdf,unsigned _ftb){
ec_uint32 r; celt_uint32 r;
r=_this->rng>>_ftb; r=_this->rng>>_ftb;
if(_s>0){ if(_s>0){
_this->val+=_this->rng-IMUL32(r,_icdf[_s-1]); _this->val+=_this->rng-IMUL32(r,_icdf[_s-1]);
...@@ -177,7 +177,7 @@ void ec_enc_icdf(ec_enc *_this,int _s,const unsigned char *_icdf,unsigned _ftb){ ...@@ -177,7 +177,7 @@ void ec_enc_icdf(ec_enc *_this,int _s,const unsigned char *_icdf,unsigned _ftb){
ec_enc_normalize(_this); ec_enc_normalize(_this);
} }
void ec_enc_uint(ec_enc *_this,ec_uint32 _fl,ec_uint32 _ft){ void ec_enc_uint(ec_enc *_this,celt_uint32 _fl,celt_uint32 _ft){
unsigned ft; unsigned ft;
unsigned fl; unsigned fl;
int ftb; int ftb;
...@@ -190,12 +190,12 @@ void ec_enc_uint(ec_enc *_this,ec_uint32 _fl,ec_uint32 _ft){ ...@@ -190,12 +190,12 @@ void ec_enc_uint(ec_enc *_this,ec_uint32 _fl,ec_uint32 _ft){
ft=(_ft>>ftb)+1; ft=(_ft>>ftb)+1;
fl=(unsigned)(_fl>>ftb); fl=(unsigned)(_fl>>ftb);
ec_encode(_this,fl,fl+1,ft); ec_encode(_this,fl,fl+1,ft);
ec_enc_bits(_this,_fl&((ec_uint32)1<<ftb)-1,ftb); ec_enc_bits(_this,_fl&((celt_uint32)1<<ftb)-1,ftb);
} }
else ec_encode(_this,_fl,_fl+1,_ft+1); else ec_encode(_this,_fl,_fl+1,_ft+1);
} }
void ec_enc_bits(ec_enc *_this,ec_uint32 _fl,unsigned _bits){ void ec_enc_bits(ec_enc *_this,celt_uint32 _fl,unsigned _bits){
ec_window window; ec_window window;
int used; int used;
window=_this->end_window; window=_this->end_window;
...@@ -231,14 +231,14 @@ void ec_enc_patch_initial_bits(ec_enc *_this,unsigned _val,unsigned _nbits){ ...@@ -231,14 +231,14 @@ void ec_enc_patch_initial_bits(ec_enc *_this,unsigned _val,unsigned _nbits){
} }
else if(_this->rng<=EC_CODE_TOP>>shift){ else if(_this->rng<=EC_CODE_TOP>>shift){
/*The renormalization loop has never been run.*/ /*The renormalization loop has never been run.*/
_this->val=_this->val&~((ec_uint32)mask<<EC_CODE_SHIFT)| _this->val=_this->val&~((celt_uint32)mask<<EC_CODE_SHIFT)|
(ec_uint32)_val<<EC_CODE_SHIFT+shift; (celt_uint32)_val<<EC_CODE_SHIFT+shift;
} }
/*The encoder hasn't even encoded _nbits of data yet.*/ /*The encoder hasn't even encoded _nbits of data yet.*/
else _this->error=-1; else _this->error=-1;
} }
void ec_enc_shrink(ec_enc *_this,ec_uint32 _size){ void ec_enc_shrink(ec_enc *_this,celt_uint32 _size){
celt_assert(_this->offs+_this->end_offs<=_size); celt_assert(_this->offs+_this->end_offs<=_size);
CELT_MOVE(_this->buf+_size-_this->end_offs, CELT_MOVE(_this->buf+_size-_this->end_offs,
_this->buf+_this->storage-_this->end_offs,_this->end_offs); _this->buf+_this->storage-_this->end_offs,_this->end_offs);
...@@ -246,11 +246,11 @@ void ec_enc_shrink(ec_enc *_this,ec_uint32 _size){ ...@@ -246,11 +246,11 @@ void ec_enc_shrink(ec_enc *_this,ec_uint32 _size){
} }
void ec_enc_done(ec_enc *_this){ void ec_enc_done(ec_enc *_this){
ec_window window; ec_window window;
int used; int used;
ec_uint32 msk; celt_uint32 msk;
ec_uint32 end; celt_uint32 end;
int l; int l;
/*We output the minimum number of bits that ensures that the symbols encoded /*We output the minimum number of bits that ensures that the symbols encoded
thus far will be decoded correctly regardless of the bits that follow.*/ thus far will be decoded correctly regardless of the bits that follow.*/
l=EC_CODE_BITS-EC_ILOG(_this->rng); l=EC_CODE_BITS-EC_ILOG(_this->rng);
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
/*Initializes the encoder. /*Initializes the encoder.
_buf: The buffer to store output bytes in. _buf: The buffer to store output bytes in.
_size: The size of the buffer, in chars.*/ _size: The size of the buffer, in chars.*/
void ec_enc_init(ec_enc *_this,unsigned char *_buf,ec_uint32 _size); void ec_enc_init(ec_enc *_this,unsigned char *_buf,celt_uint32 _size);
/*Encodes a symbol given its frequency information. /*Encodes a symbol given its frequency information.
The frequency information must be discernable by the decoder, assuming it The frequency information must be discernable by the decoder, assuming it
has read only the previous symbols from the stream. has read only the previous symbols from the stream.
...@@ -70,13 +70,13 @@ void ec_enc_icdf(ec_enc *_this,int _s,const unsigned char *_icdf,unsigned _ftb); ...@@ -70,13 +70,13 @@ void ec_enc_icdf(ec_enc *_this,int _s,const unsigned char *_icdf,unsigned _ftb);