Renamed celt_[u]int* to opus_[u]int*

This commit is contained in:
Jean-Marc Valin 2011-07-29 17:33:06 -04:00
parent 3f0962cc1e
commit d77d6a58fc
43 changed files with 459 additions and 459 deletions

View file

@ -50,7 +50,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
#else /* DOUBLE_PRECISION */
# define FRACBITS 15
# define SAMPPROD celt_int32
# define SAMPPROD opus_int32
#define SAMP_MAX 32767
#define TRIG_UPSCALE 1
#define EXT32(a) EXTEND32(a)

View file

@ -34,7 +34,7 @@
#ifndef ARCH_H
#define ARCH_H
#include "celt_types.h"
#include "opus_types.h"
# if !defined(__GNUC_PREREQ)
# if defined(__GNUC__)&&defined(__GNUC_MINOR__)
@ -71,8 +71,8 @@ static inline void _celt_fatal(const char *str, const char *file, int line)
#endif
#define IMUL32(a,b) ((a)*(b))
#define UMUL32(a,b) ((celt_int32)(a)*(celt_int32)(b))
#define UMUL16_16(a,b) ((celt_int32)(a)*(celt_int32)(b))
#define UMUL32(a,b) ((opus_int32)(a)*(opus_int32)(b))
#define UMUL16_16(a,b) ((opus_int32)(a)*(opus_int32)(b))
#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */
#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */
@ -90,8 +90,8 @@ static inline void _celt_fatal(const char *str, const char *file, int line)
#ifdef FIXED_POINT
typedef celt_int16 celt_word16;
typedef celt_int32 celt_word32;
typedef opus_int16 celt_word16;
typedef opus_int32 celt_word32;
typedef celt_word32 celt_sig;
typedef celt_word16 celt_norm;

View file

@ -41,18 +41,18 @@
#include "mathops.h"
#include "rate.h"
celt_uint32 lcg_rand(celt_uint32 seed)
opus_uint32 lcg_rand(opus_uint32 seed)
{
return 1664525 * seed + 1013904223;
}
/* This is a cos() approximation designed to be bit-exact on any platform. Bit exactness
with this approximation is important because it has an impact on the bit allocation */
static celt_int16 bitexact_cos(celt_int16 x)
static opus_int16 bitexact_cos(opus_int16 x)
{
celt_int32 tmp;
celt_int16 x2;
tmp = (4096+((celt_int32)(x)*(x)))>>13;
opus_int32 tmp;
opus_int16 x2;
tmp = (4096+((opus_int32)(x)*(x)))>>13;
if (tmp > 32767)
tmp = 32767;
x2 = tmp;
@ -80,7 +80,7 @@ static int bitexact_log2tan(int isin,int icos)
void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bank, int end, int _C, int M)
{
int i, c, N;
const celt_int16 *eBands = m->eBands;
const opus_int16 *eBands = m->eBands;
const int C = CHANNELS(_C);
N = M*m->shortMdctSize;
c=0; do {
@ -118,7 +118,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bank
void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_norm * restrict X, const celt_ener *bank, int end, int _C, int M)
{
int i, c, N;
const celt_int16 *eBands = m->eBands;
const opus_int16 *eBands = m->eBands;
const int C = CHANNELS(_C);
N = M*m->shortMdctSize;
c=0; do {
@ -141,7 +141,7 @@ void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_nor
void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bank, int end, int _C, int M)
{
int i, c, N;
const celt_int16 *eBands = m->eBands;
const opus_int16 *eBands = m->eBands;
const int C = CHANNELS(_C);
N = M*m->shortMdctSize;
c=0; do {
@ -162,7 +162,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bank
void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_norm * restrict X, const celt_ener *bank, int end, int _C, int M)
{
int i, c, N;
const celt_int16 *eBands = m->eBands;
const opus_int16 *eBands = m->eBands;
const int C = CHANNELS(_C);
N = M*m->shortMdctSize;
c=0; do {
@ -182,7 +182,7 @@ void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_nor
void denormalise_bands(const CELTMode *m, const celt_norm * restrict X, celt_sig * restrict freq, const celt_ener *bank, int end, int _C, int M)
{
int i, c, N;
const celt_int16 *eBands = m->eBands;
const opus_int16 *eBands = m->eBands;
const int C = CHANNELS(_C);
N = M*m->shortMdctSize;
celt_assert2(C<=2, "denormalise_bands() not implemented for >2 channels");
@ -210,7 +210,7 @@ void denormalise_bands(const CELTMode *m, const celt_norm * restrict X, celt_sig
/* This prevents energy collapse for transients with multiple short MDCTs */
void anti_collapse(const CELTMode *m, celt_norm *_X, unsigned char *collapse_masks, int LM, int C, int CC, int size,
int start, int end, celt_word16 *logE, celt_word16 *prev1logE,
celt_word16 *prev2logE, int *pulses, celt_uint32 seed)
celt_word16 *prev2logE, int *pulses, opus_uint32 seed)
{
int c, i, j, k;
for (i=start;i<end;i++)
@ -403,7 +403,7 @@ int spreading_decision(const CELTMode *m, celt_norm *X, int *average,
int i, c, N0;
int sum = 0, nbBands=0;
const int C = CHANNELS(_C);
const celt_int16 * restrict eBands = m->eBands;
const opus_int16 * restrict eBands = m->eBands;
int decision;
int hf_sum=0;
@ -604,7 +604,7 @@ void haar1(celt_norm *X, int N0, int stride)
static int compute_qn(int N, int b, int offset, int pulse_cap, int stereo)
{
static const celt_int16 exp2_table8[8] =
static const opus_int16 exp2_table8[8] =
{16384, 17866, 19483, 21247, 23170, 25267, 27554, 30048};
int qn, qb;
int N2 = 2*N-1;
@ -633,8 +633,8 @@ static int compute_qn(int N, int b, int offset, int pulse_cap, int stereo)
can be called recursively so bands can end up being split in 8 parts. */
static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, celt_norm *Y,
int N, int b, int spread, int B, int intensity, int tf_change, celt_norm *lowband, int resynth, ec_ctx *ec,
celt_int32 *remaining_bits, int LM, celt_norm *lowband_out, const celt_ener *bandE, int level,
celt_uint32 *seed, celt_word16 gain, celt_norm *lowband_scratch, int fill)
opus_int32 *remaining_bits, int LM, celt_norm *lowband_out, const celt_ener *bandE, int level,
opus_uint32 *seed, celt_word16 gain, celt_norm *lowband_scratch, int fill)
{
const unsigned char *cache;
int q;
@ -767,7 +767,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c
int pulse_cap;
int offset;
int orig_fill;
celt_int32 tell;
opus_int32 tell;
/* Decide on the resolution to give to the split parameter theta */
pulse_cap = m->logN[i]+(LM<<BITRES);
@ -837,14 +837,14 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c
if (fm < ((qn>>1)*((qn>>1) + 1)>>1))
{
itheta = (isqrt32(8*(celt_uint32)fm + 1) - 1)>>1;
itheta = (isqrt32(8*(opus_uint32)fm + 1) - 1)>>1;
fs = itheta + 1;
fl = itheta*(itheta + 1)>>1;
}
else
{
itheta = (2*(qn + 1)
- isqrt32(8*(celt_uint32)(ft - fm - 1) + 1))>>1;
- isqrt32(8*(opus_uint32)(ft - fm - 1) + 1))>>1;
fs = qn + 1 - itheta;
fl = ft - ((qn + 1 - itheta)*(qn + 2 - itheta)>>1);
}
@ -852,7 +852,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c
ec_dec_update(ec, fl, fl+fs, ft);
}
}
itheta = (celt_int32)itheta*16384/qn;
itheta = (opus_int32)itheta*16384/qn;
if (encode && stereo)
{
if (itheta==0)
@ -973,7 +973,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c
celt_norm *next_lowband2=NULL;
celt_norm *next_lowband_out1=NULL;
int next_level=0;
celt_int32 rebalance;
opus_int32 rebalance;
/* Give more bits to low-energy MDCTs than they would otherwise deserve */
if (B0>1 && !stereo && (itheta&0x3fff))
@ -1078,7 +1078,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c
for (j=0;j<N;j++)
{
*seed = lcg_rand(*seed);
X[j] = (celt_int32)(*seed)>>20;
X[j] = (opus_int32)(*seed)>>20;
}
cm = cm_mask;
} else {
@ -1161,11 +1161,11 @@ 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,
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,
celt_int32 total_bits, celt_int32 balance, ec_ctx *ec, int LM, int codedBands, celt_uint32 *seed)
opus_int32 total_bits, opus_int32 balance, ec_ctx *ec, int LM, int codedBands, opus_uint32 *seed)
{
int i;
celt_int32 remaining_bits;
const celt_int16 * restrict eBands = m->eBands;
opus_int32 remaining_bits;
const opus_int16 * restrict eBands = m->eBands;
celt_norm * restrict norm, * restrict norm2;
VARDECL(celt_norm, _norm);
VARDECL(celt_norm, lowband_scratch);
@ -1186,10 +1186,10 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end,
lowband_offset = 0;
for (i=start;i<end;i++)
{
celt_int32 tell;
opus_int32 tell;
int b;
int N;
celt_int32 curr_balance;
opus_int32 curr_balance;
int effective_lowband=-1;
celt_norm * restrict X, * restrict Y;
int tf_change=0;

View file

@ -84,15 +84,15 @@ void haar1(celt_norm *X, int N0, int stride);
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,
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, celt_uint32 *seed);
opus_int32 total_bits, opus_int32 balance, ec_ctx *ec, int M, int codedBands, opus_uint32 *seed);
void stereo_decision(const CELTMode *m, celt_norm * restrict X, int *stereo_mode, int len, int M);
void anti_collapse(const CELTMode *m, celt_norm *_X, unsigned char *collapse_masks, int LM, int C, int CC, int size,
int start, int end, celt_word16 *logE, celt_word16 *prev1logE,
celt_word16 *prev2logE, int *pulses, celt_uint32 seed);
celt_word16 *prev2logE, int *pulses, opus_uint32 seed);
celt_uint32 lcg_rand(celt_uint32 seed);
opus_uint32 lcg_rand(opus_uint32 seed);
#endif /* BANDS_H */

View file

@ -157,7 +157,7 @@ static c64_fft_t *cache32[NBCACHE] = {NULL,};
c64_fft_t *c64_fft16_alloc(int length, int x, int y)
{
c64_fft_t *state;
celt_int16 *w, *iw;
opus_int16 *w, *iw;
int i, c;
@ -171,13 +171,13 @@ c64_fft_t *c64_fft16_alloc(int length, int x, int y)
state = (c64_fft_t *)celt_alloc(sizeof(c64_fft_t));
state->shift = log(length)/log(2) - ceil(log(length)/log(4)-1);
state->nfft = length;
state->twiddle = celt_alloc(length*2*sizeof(celt_int16));
state->itwiddle = celt_alloc(length*2*sizeof(celt_int16));
state->twiddle = celt_alloc(length*2*sizeof(opus_int16));
state->itwiddle = celt_alloc(length*2*sizeof(opus_int16));
gen_twiddle16((celt_int16 *)state->twiddle, length, 32767.0);
gen_twiddle16((opus_int16 *)state->twiddle, length, 32767.0);
w = (celt_int16 *)state->twiddle;
iw = (celt_int16 *)state->itwiddle;
w = (opus_int16 *)state->twiddle;
iw = (opus_int16 *)state->itwiddle;
for (i = 0; i < length; i++) {
iw[2*i+0] = w[2*i+0];
@ -208,8 +208,8 @@ c64_fft_t *c64_fft32_alloc(int length, int x, int y)
state = (c64_fft_t *)celt_alloc(sizeof(c64_fft_t));
state->shift = log(length)/log(2) - ceil(log(length)/log(4)-1);
state->nfft = length;
state->twiddle = celt_alloc(length*2*sizeof(celt_int32));
state->itwiddle = celt_alloc(length*2*sizeof(celt_int32));
state->twiddle = celt_alloc(length*2*sizeof(opus_int32));
state->itwiddle = celt_alloc(length*2*sizeof(opus_int32));
// Generate the inverse twiddle first because it does not need scaling
gen_twiddle32(state->itwiddle, length, 2147483647.000000000);
@ -239,22 +239,22 @@ void c64_fft32_free(c64_fft_t *state)
}
void c64_fft16_inplace(c64_fft_t * restrict state, celt_int16 *X)
void c64_fft16_inplace(c64_fft_t * restrict state, opus_int16 *X)
{
int i;
VARDECL(celt_int16, cin);
VARDECL(celt_int16, cout);
VARDECL(opus_int16, cin);
VARDECL(opus_int16, cout);
SAVE_STACK;
ALLOC(cin, state->nfft*2, celt_int16);
ALLOC(cout, state->nfft*2, celt_int16);
ALLOC(cin, state->nfft*2, opus_int16);
ALLOC(cout, state->nfft*2, opus_int16);
for (i = 0; i < state->nfft; i++) {
cin[2*i+0] = X[2*i+0];
cin[2*i+1] = X[2*i+1];
}
DSP_fft16x16t((celt_int16 *)state->twiddle, state->nfft, cin, cout);
DSP_fft16x16t((opus_int16 *)state->twiddle, state->nfft, cin, cout);
for (i = 0; i < state->nfft; i++) {
X[2*i+0] = cout[2*i+0];
@ -266,12 +266,12 @@ void c64_fft16_inplace(c64_fft_t * restrict state, celt_int16 *X)
void c64_fft32(c64_fft_t * restrict state, const celt_int32 *X, celt_int32 *Y)
void c64_fft32(c64_fft_t * restrict state, const opus_int32 *X, opus_int32 *Y)
{
int i;
VARDECL(celt_int32, cin);
VARDECL(opus_int32, cin);
SAVE_STACK;
ALLOC(cin, state->nfft*2, celt_int32);
ALLOC(cin, state->nfft*2, opus_int32);
for (i = 0; i < state->nfft; i++) {
cin[2*i+0] = X[2*i+0] >> state->shift;
@ -284,16 +284,16 @@ void c64_fft32(c64_fft_t * restrict state, const celt_int32 *X, celt_int32 *Y)
}
void c64_ifft16(c64_fft_t * restrict state, const celt_int16 *X, celt_int16 *Y)
void c64_ifft16(c64_fft_t * restrict state, const opus_int16 *X, opus_int16 *Y)
{
int i;
VARDECL(celt_int16, cin);
VARDECL(celt_int16, cout);
VARDECL(opus_int16, cin);
VARDECL(opus_int16, cout);
SAVE_STACK;
ALLOC(cin, state->nfft*2, celt_int16);
if ((celt_int32)Y & 7)
ALLOC(cout, state->nfft*2, celt_int16);
ALLOC(cin, state->nfft*2, opus_int16);
if ((opus_int32)Y & 7)
ALLOC(cout, state->nfft*2, opus_int16);
else
cout = Y;
@ -304,9 +304,9 @@ void c64_ifft16(c64_fft_t * restrict state, const celt_int16 *X, celt_int16 *Y)
cin[2*i+1] = X[2*i+1];
}
DSP_fft16x16t((celt_int16 *)state->itwiddle, state->nfft, cin, cout);
DSP_fft16x16t((opus_int16 *)state->itwiddle, state->nfft, cin, cout);
if ((celt_int32)Y & 7)
if ((opus_int32)Y & 7)
for (i = 0; i < state->nfft; i++) {
Y[2*i+0] = cout[2*i+0];
Y[2*i+1] = cout[2*i+1];
@ -316,12 +316,12 @@ void c64_ifft16(c64_fft_t * restrict state, const celt_int16 *X, celt_int16 *Y)
}
void c64_ifft32(c64_fft_t * restrict state, const celt_int32 *X, celt_int32 *Y)
void c64_ifft32(c64_fft_t * restrict state, const opus_int32 *X, opus_int32 *Y)
{
int i;
VARDECL(celt_int32, cin);
VARDECL(opus_int32, cin);
SAVE_STACK;
ALLOC(cin, state->nfft*2, celt_int32);
ALLOC(cin, state->nfft*2, opus_int32);
celt_assert(Y & 7 == 0);

View file

@ -37,18 +37,18 @@
typedef struct {
int nfft;
int shift;
celt_int32 *twiddle;
celt_int32 *itwiddle;
opus_int32 *twiddle;
opus_int32 *itwiddle;
} c64_fft_t;
extern c64_fft_t *c64_fft16_alloc(int length, int x, int y);
extern void c64_fft16_free(c64_fft_t *state);
extern void c64_fft16_inplace(c64_fft_t *state, celt_int16 *X);
extern void c64_ifft16(c64_fft_t *state, const celt_int16 *X, celt_int16 *Y);
extern void c64_fft16_inplace(c64_fft_t *state, opus_int16 *X);
extern void c64_ifft16(c64_fft_t *state, const opus_int16 *X, opus_int16 *Y);
extern c64_fft_t *c64_fft32_alloc(int length, int x, int y);
extern void c64_fft32_free(c64_fft_t *state);
extern void c64_fft32(c64_fft_t *state, const celt_int32 *X, celt_int32 *Y);
extern void c64_ifft32(c64_fft_t *state, const celt_int32 *X, celt_int32 *Y);
extern void c64_fft32(c64_fft_t *state, const opus_int32 *X, opus_int32 *Y);
extern void c64_ifft32(c64_fft_t *state, const opus_int32 *X, opus_int32 *Y);
#endif

View file

@ -93,7 +93,7 @@ static inline int fromOpus(unsigned char c)
#define COMBFILTER_MAXPERIOD 1024
#define COMBFILTER_MINPERIOD 15
static int resampling_factor(celt_int32 rate)
static int resampling_factor(opus_int32 rate)
{
int ret;
switch (rate)
@ -135,7 +135,7 @@ struct CELTEncoder {
int upsample;
int start, end;
celt_int32 bitrate;
opus_int32 bitrate;
int vbr;
int signalling;
int constrained_vbr; /* If zero, VBR can do whatever it likes with the rate */
@ -144,7 +144,7 @@ struct CELTEncoder {
/* Everything beyond this point gets cleared on a reset */
#define ENCODER_RESET_START rng
celt_uint32 rng;
opus_uint32 rng;
int spread_decision;
celt_word32 delayedIntra;
int tonal_average;
@ -163,10 +163,10 @@ struct CELTEncoder {
int consec_transient;
/* VBR-related parameters */
celt_int32 vbr_reservoir;
celt_int32 vbr_drift;
celt_int32 vbr_offset;
celt_int32 vbr_count;
opus_int32 vbr_reservoir;
opus_int32 vbr_drift;
opus_int32 vbr_offset;
opus_int32 vbr_count;
celt_word32 preemph_memE[2];
celt_word32 preemph_memD[2];
@ -283,12 +283,12 @@ void celt_encoder_destroy(CELTEncoder *st)
celt_free(st);
}
static inline celt_int16 FLOAT2INT16(float x)
static inline opus_int16 FLOAT2INT16(float x)
{
x = x*CELT_SIG_SCALE;
x = MAX32(x, -32768);
x = MIN32(x, 32767);
return (celt_int16)float2int(x);
return (opus_int16)float2int(x);
}
static inline celt_word16 SIG2WORD16(celt_sig x)
@ -718,8 +718,8 @@ static void tf_encode(int start, int end, int isTransient, int *tf_res, int LM,
int tf_select_rsv;
int tf_changed;
int logp;
celt_uint32 budget;
celt_uint32 tell;
opus_uint32 budget;
opus_uint32 tell;
budget = enc->storage*8;
tell = ec_tell(enc);
logp = isTransient ? 2 : 4;
@ -758,8 +758,8 @@ static void tf_decode(int start, int end, int isTransient, int *tf_res, int LM,
int tf_select_rsv;
int tf_changed;
int logp;
celt_uint32 budget;
celt_uint32 tell;
opus_uint32 budget;
opus_uint32 tell;
budget = dec->storage*8;
tell = ec_tell(dec);
@ -837,7 +837,7 @@ static int alloc_trim_analysis(const CELTMode *m, const celt_norm *X,
c=0; do {
for (i=0;i<end-1;i++)
{
diff += bandLogE[i+c*m->nbEBands]*(celt_int32)(2+2*i-m->nbEBands);
diff += bandLogE[i+c*m->nbEBands]*(opus_int32)(2+2*i-m->nbEBands);
}
} while (++c<0);
diff /= C*(end-1);
@ -891,7 +891,7 @@ static int stereo_analysis(const CELTMode *m, const celt_norm *X,
#ifdef FIXED_POINT
CELT_STATIC
int celt_encode_with_ec(CELTEncoder * restrict st, const celt_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc)
int celt_encode_with_ec(CELTEncoder * restrict st, const opus_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc)
{
#else
CELT_STATIC
@ -899,7 +899,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
{
#endif
int i, c, N;
celt_int32 bits;
opus_int32 bits;
ec_enc _enc;
VARDECL(celt_sig, in);
VARDECL(celt_sig, freq);
@ -935,11 +935,11 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
int effectiveBytes;
celt_word16 pf_threshold;
int dynalloc_logp;
celt_int32 vbr_rate;
celt_int32 total_bits;
celt_int32 total_boost;
celt_int32 balance;
celt_int32 tell;
opus_int32 vbr_rate;
opus_int32 total_bits;
opus_int32 total_boost;
opus_int32 balance;
opus_int32 tell;
int prefilter_tapset=0;
int pf_on;
int anti_collapse_rsv;
@ -998,13 +998,13 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
if (st->vbr)
{
celt_int32 den=st->mode->Fs>>BITRES;
opus_int32 den=st->mode->Fs>>BITRES;
vbr_rate=(st->bitrate*frame_size+(den>>1))/den;
if (st->signalling)
vbr_rate -= 8<<BITRES;
effectiveBytes = vbr_rate>>(3+BITRES);
} else {
celt_int32 tmp;
opus_int32 tmp;
vbr_rate = 0;
tmp = st->bitrate*frame_size;
if (tell>1)
@ -1028,8 +1028,8 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
correctly if we don't have enough bits. */
if (st->constrained_vbr)
{
celt_int32 vbr_bound;
celt_int32 max_allowed;
opus_int32 vbr_bound;
opus_int32 max_allowed;
/* We could use any multiple of vbr_rate as bound (depending on the
delay).
This is clamped to ensure we use at least two bytes if the encoder
@ -1384,10 +1384,10 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
if (vbr_rate>0)
{
celt_word16 alpha;
celt_int32 delta;
opus_int32 delta;
/* The target rate in 8th bits per frame */
celt_int32 target;
celt_int32 min_allowed;
opus_int32 target;
opus_int32 min_allowed;
target = vbr_rate + st->vbr_offset - ((40*C+20)<<BITRES);
@ -1443,7 +1443,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
/*printf ("%d\n", st->vbr_reservoir);*/
/* Compute the offset we need to apply in order to reach the target */
st->vbr_drift += (celt_int32)MULT16_32_Q15(alpha,delta-st->vbr_offset-st->vbr_drift);
st->vbr_drift += (opus_int32)MULT16_32_Q15(alpha,delta-st->vbr_offset-st->vbr_drift);
st->vbr_offset = -st->vbr_drift;
/*printf ("%d\n", st->vbr_drift);*/
@ -1496,7 +1496,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
ALLOC(fine_priority, st->mode->nbEBands, int);
/* bits = packet size - where we are - safety*/
bits = ((celt_int32)nbCompressedBytes*8<<BITRES) - ec_tell_frac(enc) - 1;
bits = ((opus_int32)nbCompressedBytes*8<<BITRES) - ec_tell_frac(enc) - 1;
anti_collapse_rsv = isTransient&&LM>=2&&bits>=(LM+2<<BITRES) ? (1<<BITRES) : 0;
bits -= anti_collapse_rsv;
codedBands = compute_allocation(st->mode, st->start, st->end, offsets, cap,
@ -1671,7 +1671,7 @@ CELT_STATIC
int celt_encode_with_ec_float(CELTEncoder * restrict st, const float * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc)
{
int j, ret, C, N;
VARDECL(celt_int16, in);
VARDECL(opus_int16, in);
ALLOC_STACK;
if (pcm==NULL)
@ -1679,7 +1679,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const float * pcm, int
C = CHANNELS(st->channels);
N = frame_size;
ALLOC(in, C*N, celt_int16);
ALLOC(in, C*N, opus_int16);
for (j=0;j<C*N;j++)
in[j] = FLOAT2INT16(pcm[j]);
@ -1696,7 +1696,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const float * pcm, int
#endif /*DISABLE_FLOAT_API*/
#else
CELT_STATIC
int celt_encode_with_ec(CELTEncoder * restrict st, const celt_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc)
int celt_encode_with_ec(CELTEncoder * restrict st, const opus_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc)
{
int j, ret, C, N;
VARDECL(celt_sig, in);
@ -1715,14 +1715,14 @@ int celt_encode_with_ec(CELTEncoder * restrict st, const celt_int16 * pcm, int f
ret = celt_encode_with_ec_float(st,in,frame_size,compressed,nbCompressedBytes, enc);
#ifdef RESYNTH
for (j=0;j<C*N;j++)
((celt_int16*)pcm)[j] = FLOAT2INT16(in[j]);
((opus_int16*)pcm)[j] = FLOAT2INT16(in[j]);
#endif
RESTORE_STACK;
return ret;
}
#endif
int celt_encode(CELTEncoder * restrict st, const celt_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes)
int celt_encode(CELTEncoder * restrict st, const opus_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes)
{
return celt_encode_with_ec(st, pcm, frame_size, compressed, nbCompressedBytes, NULL);
}
@ -1743,7 +1743,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...)
{
case CELT_SET_COMPLEXITY_REQUEST:
{
int value = va_arg(ap, celt_int32);
int value = va_arg(ap, opus_int32);
if (value<0 || value>10)
goto bad_arg;
st->complexity = value;
@ -1751,7 +1751,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...)
break;
case CELT_SET_START_BAND_REQUEST:
{
celt_int32 value = va_arg(ap, celt_int32);
opus_int32 value = va_arg(ap, opus_int32);
if (value<0 || value>=st->mode->nbEBands)
goto bad_arg;
st->start = value;
@ -1759,7 +1759,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...)
break;
case CELT_SET_END_BAND_REQUEST:
{
celt_int32 value = va_arg(ap, celt_int32);
opus_int32 value = va_arg(ap, opus_int32);
if (value<1 || value>st->mode->nbEBands)
goto bad_arg;
st->end = value;
@ -1767,7 +1767,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...)
break;
case CELT_SET_PREDICTION_REQUEST:
{
int value = va_arg(ap, celt_int32);
int value = va_arg(ap, opus_int32);
if (value<0 || value>2)
goto bad_arg;
st->disable_pf = value<=1;
@ -1776,7 +1776,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...)
break;
case CELT_SET_LOSS_PERC_REQUEST:
{
int value = va_arg(ap, celt_int32);
int value = va_arg(ap, opus_int32);
if (value<0 || value>100)
goto bad_arg;
st->loss_rate = value;
@ -1784,19 +1784,19 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...)
break;
case CELT_SET_VBR_CONSTRAINT_REQUEST:
{
celt_int32 value = va_arg(ap, celt_int32);
opus_int32 value = va_arg(ap, opus_int32);
st->constrained_vbr = value;
}
break;
case CELT_SET_VBR_REQUEST:
{
celt_int32 value = va_arg(ap, celt_int32);
opus_int32 value = va_arg(ap, opus_int32);
st->vbr = value;
}
break;
case CELT_SET_BITRATE_REQUEST:
{
celt_int32 value = va_arg(ap, celt_int32);
opus_int32 value = va_arg(ap, opus_int32);
if (value<=500)
goto bad_arg;
value = IMIN(value, 260000*st->channels);
@ -1805,7 +1805,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...)
break;
case CELT_SET_CHANNELS_REQUEST:
{
celt_int32 value = va_arg(ap, celt_int32);
opus_int32 value = va_arg(ap, opus_int32);
if (value<1 || value>2)
goto bad_arg;
st->stream_channels = value;
@ -1824,14 +1824,14 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...)
break;
case CELT_SET_INPUT_CLIPPING_REQUEST:
{
celt_int32 value = va_arg(ap, celt_int32);
opus_int32 value = va_arg(ap, opus_int32);
st->clip = value;
}
break;
#ifdef OPUS_BUILD
case CELT_SET_SIGNALLING_REQUEST:
{
celt_int32 value = va_arg(ap, celt_int32);
opus_int32 value = va_arg(ap, opus_int32);
st->signalling = value;
}
break;
@ -1880,7 +1880,7 @@ struct CELTDecoder {
/* Everything beyond this point gets cleared on a reset */
#define DECODER_RESET_START rng
celt_uint32 rng;
opus_uint32 rng;
int error;
int last_pitch_index;
int loss_count;
@ -2030,7 +2030,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict p
VARDECL(celt_sig, freq);
VARDECL(celt_norm, X);
VARDECL(celt_ener, bandE);
celt_uint32 seed;
opus_uint32 seed;
int effEnd;
effEnd = st->end;
@ -2058,7 +2058,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict p
for (j=0;j<blen;j++)
{
seed = lcg_rand(seed);
X[boffs+j] = (celt_int32)(seed)>>20;
X[boffs+j] = (opus_int32)(seed)>>20;
}
renormalise_vector(X+boffs, blen, Q15ONE);
}
@ -2244,7 +2244,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict p
#ifdef FIXED_POINT
CELT_STATIC
int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, int len, celt_int16 * restrict pcm, int frame_size, ec_dec *dec)
int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, int len, opus_int16 * restrict pcm, int frame_size, ec_dec *dec)
{
#else
CELT_STATIC
@ -2253,7 +2253,7 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
#endif
int c, i, N;
int spread_decision;
celt_int32 bits;
opus_int32 bits;
ec_dec _dec;
VARDECL(celt_sig, freq);
VARDECL(celt_norm, X);
@ -2284,9 +2284,9 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
celt_word16 postfilter_gain;
int intensity=0;
int dual_stereo=0;
celt_int32 total_bits;
celt_int32 balance;
celt_int32 tell;
opus_int32 total_bits;
opus_int32 balance;
opus_int32 tell;
int dynalloc_logp;
int postfilter_tapset;
int anti_collapse_rsv;
@ -2485,7 +2485,7 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
alloc_trim = tell+(6<<BITRES) <= total_bits ?
ec_dec_icdf(dec, trim_icdf, 7) : 5;
bits = ((celt_int32)len*8<<BITRES) - ec_tell_frac(dec) - 1;
bits = ((opus_int32)len*8<<BITRES) - ec_tell_frac(dec) - 1;
anti_collapse_rsv = isTransient&&LM>=2&&bits>=(LM+2<<BITRES) ? (1<<BITRES) : 0;
bits -= anti_collapse_rsv;
codedBands = compute_allocation(st->mode, st->start, st->end, offsets, cap,
@ -2627,7 +2627,7 @@ CELT_STATIC
int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *data, int len, float * restrict pcm, int frame_size, ec_dec *dec)
{
int j, ret, C, N;
VARDECL(celt_int16, out);
VARDECL(opus_int16, out);
ALLOC_STACK;
if (pcm==NULL)
@ -2636,7 +2636,7 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
C = CHANNELS(st->channels);
N = frame_size;
ALLOC(out, C*N, celt_int16);
ALLOC(out, C*N, opus_int16);
ret=celt_decode_with_ec(st, data, len, out, frame_size, dec);
if (ret>0)
for (j=0;j<C*ret;j++)
@ -2648,7 +2648,7 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
#endif /*DISABLE_FLOAT_API*/
#else
CELT_STATIC
int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, int len, celt_int16 * restrict pcm, int frame_size, ec_dec *dec)
int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, int len, opus_int16 * restrict pcm, int frame_size, ec_dec *dec)
{
int j, ret, C, N;
VARDECL(celt_sig, out);
@ -2672,7 +2672,7 @@ int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, in
}
#endif
int celt_decode(CELTDecoder * restrict st, const unsigned char *data, int len, celt_int16 * restrict pcm, int frame_size)
int celt_decode(CELTDecoder * restrict st, const unsigned char *data, int len, opus_int16 * restrict pcm, int frame_size)
{
return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL);
}
@ -2693,7 +2693,7 @@ int celt_decoder_ctl(CELTDecoder * restrict st, int request, ...)
{
case CELT_SET_START_BAND_REQUEST:
{
celt_int32 value = va_arg(ap, celt_int32);
opus_int32 value = va_arg(ap, opus_int32);
if (value<0 || value>=st->mode->nbEBands)
goto bad_arg;
st->start = value;
@ -2701,7 +2701,7 @@ int celt_decoder_ctl(CELTDecoder * restrict st, int request, ...)
break;
case CELT_SET_END_BAND_REQUEST:
{
celt_int32 value = va_arg(ap, celt_int32);
opus_int32 value = va_arg(ap, opus_int32);
if (value<1 || value>st->mode->nbEBands)
goto bad_arg;
st->end = value;
@ -2709,7 +2709,7 @@ int celt_decoder_ctl(CELTDecoder * restrict st, int request, ...)
break;
case CELT_SET_CHANNELS_REQUEST:
{
celt_int32 value = va_arg(ap, celt_int32);
opus_int32 value = va_arg(ap, opus_int32);
if (value<1 || value>2)
goto bad_arg;
st->stream_channels = value;
@ -2750,7 +2750,7 @@ int celt_decoder_ctl(CELTDecoder * restrict st, int request, ...)
break;
case CELT_SET_SIGNALLING_REQUEST:
{
celt_int32 value = va_arg(ap, celt_int32);
opus_int32 value = va_arg(ap, opus_int32);
st->signalling = value;
}
break;

View file

@ -35,7 +35,7 @@
#ifndef CELT_H
#define CELT_H
#include "celt_types.h"
#include "opus_types.h"
#ifdef __cplusplus
extern "C" {
@ -49,7 +49,7 @@ extern "C" {
#define CELT_EXPORT
#endif
#define _celt_check_int(x) (((void)((x) == (celt_int32)0)), (celt_int32)(x))
#define _celt_check_int(x) (((void)((x) == (opus_int32)0)), (opus_int32)(x))
#define _celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (const CELTMode**)(ptr)))
#define _celt_check_int_ptr(ptr) ((ptr) + ((ptr) - (int*)(ptr)))
@ -157,7 +157,7 @@ typedef struct CELTMode CELTMode;
@param error Returned error code (if NULL, no error will be returned)
@return A newly created mode
*/
CELT_EXPORT CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error);
CELT_EXPORT CELTMode *celt_mode_create(opus_int32 Fs, int frame_size, int *error);
/** Destroys a mode struct. Only call this after all encoders and
decoders using this mode are destroyed as well.
@ -233,7 +233,7 @@ CELT_EXPORT int celt_encode_float(CELTEncoder *st, const float *pcm, int frame_s
* the length returned be somehow transmitted to the decoder. Otherwise, no
* decoding is possible.
*/
CELT_EXPORT int celt_encode(CELTEncoder *st, const celt_int16 *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes);
CELT_EXPORT int celt_encode(CELTEncoder *st, const opus_int16 *pcm, int frame_size, unsigned char *compressed, int maxCompressedBytes);
/** Query and set encoder parameters
@param st Encoder state
@ -298,7 +298,7 @@ CELT_EXPORT int celt_decode_float(CELTDecoder *st, const unsigned char *data, in
returned here in 16-bit PCM format (native endian).
@return Error code.
*/
CELT_EXPORT int celt_decode(CELTDecoder *st, const unsigned char *data, int len, celt_int16 *pcm, int frame_size);
CELT_EXPORT int celt_decode(CELTDecoder *st, const unsigned char *data, int len, opus_int16 *pcm, int frame_size);
/** Query and set decoder parameters
@param st Decoder state

View file

@ -42,7 +42,7 @@
with frac bits of fractional precision.
Tested for all possible 32-bit inputs with frac=4, where the maximum
overestimation is 0.06254243 bits.*/
int log2_frac(celt_uint32 val, int frac)
int log2_frac(opus_uint32 val, int frac)
{
int l;
l=EC_ILOG(val);
@ -75,7 +75,7 @@ int log2_frac(celt_uint32 val, int frac)
#define MASK32 (0xFFFFFFFF)
/*INV_TABLE[i] holds the multiplicative inverse of (2*i+1) mod 2**32.*/
static const celt_uint32 INV_TABLE[64]={
static const opus_uint32 INV_TABLE[64]={
0x00000001,0xAAAAAAAB,0xCCCCCCCD,0xB6DB6DB7,
0x38E38E39,0xBA2E8BA3,0xC4EC4EC5,0xEEEEEEEF,
0xF0F0F0F1,0x286BCA1B,0x3CF3CF3D,0xE9BD37A7,
@ -115,8 +115,8 @@ static const celt_uint32 INV_TABLE[64]={
_a, _b, _c, and _d may be arbitrary so long as the arbitrary precision result
fits in 32 bits, but currently the table for multiplicative inverses is only
valid for _d<128.*/
static inline celt_uint32 imusdiv32odd(celt_uint32 _a,celt_uint32 _b,
celt_uint32 _c,int _d){
static inline opus_uint32 imusdiv32odd(opus_uint32 _a,opus_uint32 _b,
opus_uint32 _c,int _d){
return (_a*_b-_c)*INV_TABLE[_d]&MASK32;
}
@ -127,9 +127,9 @@ static inline celt_uint32 imusdiv32odd(celt_uint32 _a,celt_uint32 _b,
table for multiplicative inverses is only valid for _d<=256).
_b and _c may be arbitrary so long as the arbitrary precision reuslt fits in
32 bits.*/
static inline celt_uint32 imusdiv32even(celt_uint32 _a,celt_uint32 _b,
celt_uint32 _c,int _d){
celt_uint32 inv;
static inline opus_uint32 imusdiv32even(opus_uint32 _a,opus_uint32 _b,
opus_uint32 _c,int _d){
opus_uint32 inv;
int mask;
int shift;
int one;
@ -284,39 +284,39 @@ static inline unsigned ucwrs2(unsigned _k){
}
/*Compute V(2,_k).*/
static inline celt_uint32 ncwrs2(int _k){
return _k?4*(celt_uint32)_k:1;
static inline opus_uint32 ncwrs2(int _k){
return _k?4*(opus_uint32)_k:1;
}
/*Compute U(3,_k).
Note that this may be called with _k=32768 (maxK[3]+1).*/
static inline celt_uint32 ucwrs3(unsigned _k){
return _k?(2*(celt_uint32)_k-2)*_k+1:0;
static inline opus_uint32 ucwrs3(unsigned _k){
return _k?(2*(opus_uint32)_k-2)*_k+1:0;
}
/*Compute V(3,_k).*/
static inline celt_uint32 ncwrs3(int _k){
return _k?2*(2*(unsigned)_k*(celt_uint32)_k+1):1;
static inline opus_uint32 ncwrs3(int _k){
return _k?2*(2*(unsigned)_k*(opus_uint32)_k+1):1;
}
/*Compute U(4,_k).*/
static inline celt_uint32 ucwrs4(int _k){
return _k?imusdiv32odd(2*_k,(2*_k-3)*(celt_uint32)_k+4,3,1):0;
static inline opus_uint32 ucwrs4(int _k){
return _k?imusdiv32odd(2*_k,(2*_k-3)*(opus_uint32)_k+4,3,1):0;
}
/*Compute V(4,_k).*/
static inline celt_uint32 ncwrs4(int _k){
return _k?((_k*(celt_uint32)_k+2)*_k)/3<<3:1;
static inline opus_uint32 ncwrs4(int _k){
return _k?((_k*(opus_uint32)_k+2)*_k)/3<<3:1;
}
/*Compute U(5,_k).*/
static inline celt_uint32 ucwrs5(int _k){
return _k?(((((_k-2)*(unsigned)_k+5)*(celt_uint32)_k-4)*_k)/3<<1)+1:0;
static inline opus_uint32 ucwrs5(int _k){
return _k?(((((_k-2)*(unsigned)_k+5)*(opus_uint32)_k-4)*_k)/3<<1)+1:0;
}
/*Compute V(5,_k).*/
static inline celt_uint32 ncwrs5(int _k){
return _k?(((_k*(unsigned)_k+5)*(celt_uint32)_k*_k)/3<<2)+2:1;
static inline opus_uint32 ncwrs5(int _k){
return _k?(((_k*(unsigned)_k+5)*(opus_uint32)_k*_k)/3<<2)+2:1;
}
#endif /* SMALL_FOOTPRINT */
@ -324,8 +324,8 @@ static inline celt_uint32 ncwrs5(int _k){
/*Computes the next row/column of any recurrence that obeys the relation
u[i][j]=u[i-1][j]+u[i][j-1]+u[i-1][j-1].
_ui0 is the base case for the new row/column.*/
static inline void unext(celt_uint32 *_ui,unsigned _len,celt_uint32 _ui0){
celt_uint32 ui1;
static inline void unext(opus_uint32 *_ui,unsigned _len,opus_uint32 _ui0){
opus_uint32 ui1;
unsigned j;
/*This do-while will overrun the array if we don't have storage for at least
2 values.*/
@ -340,8 +340,8 @@ static inline void unext(celt_uint32 *_ui,unsigned _len,celt_uint32 _ui0){
/*Computes the previous row/column of any recurrence that obeys the relation
u[i-1][j]=u[i][j]-u[i][j-1]-u[i-1][j-1].
_ui0 is the base case for the new row/column.*/
static inline void uprev(celt_uint32 *_ui,unsigned _n,celt_uint32 _ui0){
celt_uint32 ui1;
static inline void uprev(opus_uint32 *_ui,unsigned _n,opus_uint32 _ui0){
opus_uint32 ui1;
unsigned j;
/*This do-while will overrun the array if we don't have storage for at least
2 values.*/
@ -355,8 +355,8 @@ static inline void uprev(celt_uint32 *_ui,unsigned _n,celt_uint32 _ui0){
/*Compute V(_n,_k), as well as U(_n,0..._k+1).
_u: On exit, _u[i] contains U(_n,i) for i in [0..._k+1].*/
static celt_uint32 ncwrs_urow(unsigned _n,unsigned _k,celt_uint32 *_u){
celt_uint32 um2;
static opus_uint32 ncwrs_urow(unsigned _n,unsigned _k,opus_uint32 *_u){
opus_uint32 um2;
unsigned len;
unsigned k;
len=_k+2;
@ -380,8 +380,8 @@ static celt_uint32 ncwrs_urow(unsigned _n,unsigned _k,celt_uint32 *_u){
}
#ifndef SMALL_FOOTPRINT
else{
celt_uint32 um1;
celt_uint32 n2m1;
opus_uint32 um1;
opus_uint32 n2m1;
_u[2]=n2m1=um1=(_n<<1)-1;
for(k=3;k<len;k++){
/*U(N,K) = ((2*N-1)*U(N,K-1)-U(N,K-2))/(K-1) + U(N,K-2)*/
@ -397,7 +397,7 @@ static celt_uint32 ncwrs_urow(unsigned _n,unsigned _k,celt_uint32 *_u){
/*Returns the _i'th combination of _k elements (at most 32767) chosen from a
set of size 1 with associated sign bits.
_y: Returns the vector of pulses.*/
static inline void cwrsi1(int _k,celt_uint32 _i,int *_y){
static inline void cwrsi1(int _k,opus_uint32 _i,int *_y){
int s;
s=-(int)_i;
_y[0]=_k+s^s;
@ -408,8 +408,8 @@ static inline void cwrsi1(int _k,celt_uint32 _i,int *_y){
/*Returns the _i'th combination of _k elements (at most 32767) chosen from a
set of size 2 with associated sign bits.
_y: Returns the vector of pulses.*/
static inline void cwrsi2(int _k,celt_uint32 _i,int *_y){
celt_uint32 p;
static inline void cwrsi2(int _k,opus_uint32 _i,int *_y){
opus_uint32 p;
int s;
int yj;
p=ucwrs2(_k+1U);
@ -427,8 +427,8 @@ static inline void cwrsi2(int _k,celt_uint32 _i,int *_y){
/*Returns the _i'th combination of _k elements (at most 32767) chosen from a
set of size 3 with associated sign bits.
_y: Returns the vector of pulses.*/
static void cwrsi3(int _k,celt_uint32 _i,int *_y){
celt_uint32 p;
static void cwrsi3(int _k,opus_uint32 _i,int *_y){
opus_uint32 p;
int s;
int yj;
p=ucwrs3(_k+1U);
@ -448,8 +448,8 @@ static void cwrsi3(int _k,celt_uint32 _i,int *_y){
/*Returns the _i'th combination of _k elements (at most 1172) chosen from a set
of size 4 with associated sign bits.
_y: Returns the vector of pulses.*/
static void cwrsi4(int _k,celt_uint32 _i,int *_y){
celt_uint32 p;
static void cwrsi4(int _k,opus_uint32 _i,int *_y){
opus_uint32 p;
int s;
int yj;
int kl;
@ -482,8 +482,8 @@ static void cwrsi4(int _k,celt_uint32 _i,int *_y){
/*Returns the _i'th combination of _k elements (at most 238) chosen from a set
of size 5 with associated sign bits.
_y: Returns the vector of pulses.*/
static void cwrsi5(int _k,celt_uint32 _i,int *_y){
celt_uint32 p;
static void cwrsi5(int _k,opus_uint32 _i,int *_y){
opus_uint32 p;
int s;
int yj;
p=ucwrs5(_k+1);
@ -517,12 +517,12 @@ static void cwrsi5(int _k,celt_uint32 _i,int *_y){
_y: Returns the vector of pulses.
_u: Must contain entries [0..._k+1] of row _n of U() on input.
Its contents will be destructively modified.*/
static void cwrsi(int _n,int _k,celt_uint32 _i,int *_y,celt_uint32 *_u){
static void cwrsi(int _n,int _k,opus_uint32 _i,int *_y,opus_uint32 *_u){
int j;
celt_assert(_n>0);
j=0;
do{
celt_uint32 p;
opus_uint32 p;
int s;
int yj;
p=_u[_k+1];
@ -544,7 +544,7 @@ static void cwrsi(int _n,int _k,celt_uint32 _i,int *_y,celt_uint32 *_u){
of size 1 with associated sign bits.
_y: The vector of pulses, whose sum of absolute values is K.
_k: Returns K.*/
static inline celt_uint32 icwrs1(const int *_y,int *_k){
static inline opus_uint32 icwrs1(const int *_y,int *_k){
*_k=abs(_y[0]);
return _y[0]<0;
}
@ -555,8 +555,8 @@ static inline celt_uint32 icwrs1(const int *_y,int *_k){
of size 2 with associated sign bits.
_y: The vector of pulses, whose sum of absolute values is K.
_k: Returns K.*/
static inline celt_uint32 icwrs2(const int *_y,int *_k){
celt_uint32 i;
static inline opus_uint32 icwrs2(const int *_y,int *_k){
opus_uint32 i;
int k;
i=icwrs1(_y+1,&k);
i+=ucwrs2(k);
@ -570,8 +570,8 @@ static inline celt_uint32 icwrs2(const int *_y,int *_k){
of size 3 with associated sign bits.
_y: The vector of pulses, whose sum of absolute values is K.
_k: Returns K.*/
static inline celt_uint32 icwrs3(const int *_y,int *_k){
celt_uint32 i;
static inline opus_uint32 icwrs3(const int *_y,int *_k){
opus_uint32 i;
int k;
i=icwrs2(_y+1,&k);
i+=ucwrs3(k);
@ -585,8 +585,8 @@ static inline celt_uint32 icwrs3(const int *_y,int *_k){
of size 4 with associated sign bits.
_y: The vector of pulses, whose sum of absolute values is K.
_k: Returns K.*/
static inline celt_uint32 icwrs4(const int *_y,int *_k){
celt_uint32 i;
static inline opus_uint32 icwrs4(const int *_y,int *_k){
opus_uint32 i;
int k;
i=icwrs3(_y+1,&k);
i+=ucwrs4(k);
@ -600,8 +600,8 @@ static inline celt_uint32 icwrs4(const int *_y,int *_k){
of size 5 with associated sign bits.
_y: The vector of pulses, whose sum of absolute values is K.
_k: Returns K.*/
static inline celt_uint32 icwrs5(const int *_y,int *_k){
celt_uint32 i;
static inline opus_uint32 icwrs5(const int *_y,int *_k){
opus_uint32 i;
int k;
i=icwrs4(_y+1,&k);
i+=ucwrs5(k);
@ -616,9 +616,9 @@ static inline celt_uint32 icwrs5(const int *_y,int *_k){
of size _n with associated sign bits.
_y: The vector of pulses, whose sum of absolute values must be _k.
_nc: Returns V(_n,_k).*/
celt_uint32 icwrs(int _n,int _k,celt_uint32 *_nc,const int *_y,
celt_uint32 *_u){
celt_uint32 i;
opus_uint32 icwrs(int _n,int _k,opus_uint32 *_nc,const int *_y,
opus_uint32 *_u){
opus_uint32 i;
int j;
int k;
/*We can't unroll the first two iterations of the loop unless _n>=2.*/
@ -641,7 +641,7 @@ celt_uint32 icwrs(int _n,int _k,celt_uint32 *_nc,const int *_y,
}
#ifdef CUSTOM_MODES
void get_required_bits(celt_int16 *_bits,int _n,int _maxk,int _frac){
void get_required_bits(opus_int16 *_bits,int _n,int _maxk,int _frac){
int k;
/*_maxk==0 => there's nothing to do.*/
celt_assert(_maxk>0);
@ -652,9 +652,9 @@ void get_required_bits(celt_int16 *_bits,int _n,int _maxk,int _frac){
_bits[k] = 1<<_frac;
}
else {
VARDECL(celt_uint32,u);
VARDECL(opus_uint32,u);
SAVE_STACK;
ALLOC(u,_maxk+2U,celt_uint32);
ALLOC(u,_maxk+2U,opus_uint32);
ncwrs_urow(_n,_maxk,u);
for(k=1;k<=_maxk;k++)
_bits[k]=log2_frac(u[k]+u[k+1],_frac);
@ -664,7 +664,7 @@ void get_required_bits(celt_int16 *_bits,int _n,int _maxk,int _frac){
#endif /* CUSTOM_MODES */
void encode_pulses(const int *_y,int _n,int _k,ec_enc *_enc){
celt_uint32 i;
opus_uint32 i;
if (_k==0)
return;
switch(_n){
@ -693,10 +693,10 @@ void encode_pulses(const int *_y,int _n,int _k,ec_enc *_enc){
#endif
default:
{
VARDECL(celt_uint32,u);
celt_uint32 nc;
VARDECL(opus_uint32,u);
opus_uint32 nc;
SAVE_STACK;
ALLOC(u,_k+2U,celt_uint32);
ALLOC(u,_k+2U,opus_uint32);
i=icwrs(_n,_k,&nc,_y,u);
ec_enc_uint(_enc,i,nc);
RESTORE_STACK;
@ -725,9 +725,9 @@ void decode_pulses(int *_y,int _n,int _k,ec_dec *_dec)
#endif
default:
{
VARDECL(celt_uint32,u);
VARDECL(opus_uint32,u);
SAVE_STACK;
ALLOC(u,_k+2U,celt_uint32);
ALLOC(u,_k+2U,opus_uint32);
cwrsi(_n,_k,ec_dec_uint(_dec,ncwrs_urow(_n,_k,u)),_y,u);
RESTORE_STACK;
}

View file

@ -35,9 +35,9 @@
#include "entenc.h"
#include "entdec.h"
int log2_frac(celt_uint32 val, int frac);
int log2_frac(opus_uint32 val, int frac);
void get_required_bits(celt_int16 *bits, int N, int K, int frac);
void get_required_bits(opus_int16 *bits, int N, int K, int frac);
void encode_pulses(const int *_y, int N, int K, ec_enc *enc);

View file

@ -66,14 +66,14 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
int standard, framerate;
mdctSize = mode->shortMdctSize*mode->nbShortMdcts;
standard = (mode->Fs == 400*(celt_int32)mode->shortMdctSize);
standard = (mode->Fs == 400*(opus_int32)mode->shortMdctSize);
framerate = mode->Fs/mode->shortMdctSize;
if (!standard)
{
fprintf(file, "#ifndef DEF_EBANDS%d_%d\n", mode->Fs, mdctSize);
fprintf(file, "#define DEF_EBANDS%d_%d\n", mode->Fs, mdctSize);
fprintf (file, "static const celt_int16 eBands%d_%d[%d] = {\n", mode->Fs, mdctSize, mode->nbEBands+2);
fprintf (file, "static const opus_int16 eBands%d_%d[%d] = {\n", mode->Fs, mdctSize, mode->nbEBands+2);
for (j=0;j<mode->nbEBands+2;j++)
fprintf (file, "%d, ", mode->eBands[j]);
fprintf (file, "};\n");
@ -108,7 +108,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
fprintf(file, "#ifndef DEF_LOGN%d\n", framerate);
fprintf(file, "#define DEF_LOGN%d\n", framerate);
fprintf (file, "static const celt_int16 logN%d[%d] = {\n", framerate, mode->nbEBands);
fprintf (file, "static const opus_int16 logN%d[%d] = {\n", framerate, mode->nbEBands);
for (j=0;j<mode->nbEBands;j++)
fprintf (file, "%d, ", mode->logN[j]);
fprintf (file, "};\n");
@ -118,7 +118,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
/* Pulse cache */
fprintf(file, "#ifndef DEF_PULSE_CACHE%d\n", mode->Fs/mdctSize);
fprintf(file, "#define DEF_PULSE_CACHE%d\n", mode->Fs/mdctSize);
fprintf (file, "static const celt_int16 cache_index%d[%d] = {\n", mode->Fs/mdctSize, (mode->maxLM+2)*mode->nbEBands);
fprintf (file, "static const opus_int16 cache_index%d[%d] = {\n", mode->Fs/mdctSize, (mode->maxLM+2)*mode->nbEBands);
for (j=0;j<mode->nbEBands*(mode->maxLM+2);j++)
fprintf (file, "%d, ", mode->cache.index[j]);
fprintf (file, "};\n");
@ -148,7 +148,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
{
fprintf(file, "#ifndef FFT_BITREV%d\n", mode->mdct.kfft[k]->nfft);
fprintf(file, "#define FFT_BITREV%d\n", mode->mdct.kfft[k]->nfft);
fprintf (file, "static const celt_int16 fft_bitrev%d[%d] = {\n",
fprintf (file, "static const opus_int16 fft_bitrev%d[%d] = {\n",
mode->mdct.kfft[k]->nfft, mode->mdct.kfft[k]->nfft);
for (j=0;j<mode->mdct.kfft[k]->nfft;j++)
fprintf (file, "%d, ", mode->mdct.kfft[k]->bitrev[j]);

View file

@ -26,7 +26,7 @@
*/
/*Some common macros for potential platform-specific optimization.*/
#include "celt_types.h"
#include "opus_types.h"
#include <math.h>
#include <limits.h>
#if !defined(_ecintrin_H)
@ -115,7 +115,7 @@ static __inline int ec_bsr(unsigned long _x){
When we need to, it can be special cased.*/
# define EC_ILOG(_x) (EC_CLZ0-EC_CLZ(_x))
#else
int ec_ilog(celt_uint32 _v);
int ec_ilog(opus_uint32 _v);
# define EC_ILOG(_x) (ec_ilog(_x))
#endif

View file

@ -35,7 +35,7 @@
#if !defined(EC_CLZ)
int ec_ilog(celt_uint32 _v){
int ec_ilog(opus_uint32 _v){
/*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
branches, and a 256-entry LUT version.*/
@ -60,9 +60,9 @@ int ec_ilog(celt_uint32 _v){
#endif
celt_uint32 ec_tell_frac(ec_ctx *_this){
celt_uint32 nbits;
celt_uint32 r;
opus_uint32 ec_tell_frac(ec_ctx *_this){
opus_uint32 nbits;
opus_uint32 r;
int l;
int i;
/*To handle the non-integral number of bits still left in the encoder/decoder

View file

@ -25,7 +25,7 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "celt_types.h"
#include "opus_types.h"
#if !defined(_entcode_H)
# define _entcode_H (1)
@ -37,7 +37,7 @@
/*OPT: ec_window 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 here.*/
typedef celt_uint32 ec_window;
typedef opus_uint32 ec_window;
typedef struct ec_ctx ec_ctx;
typedef struct ec_ctx ec_enc;
typedef struct ec_ctx ec_dec;
@ -62,9 +62,9 @@ struct ec_ctx{
/*Buffered input/output.*/
unsigned char *buf;
/*The size of the buffer.*/
celt_uint32 storage;
opus_uint32 storage;
/*The offset at which the last byte containing raw bits was read/written.*/
celt_uint32 end_offs;
opus_uint32 end_offs;
/*Bits that will be read from/written at the end.*/
ec_window end_window;
/*Number of valid bits in end_window.*/
@ -73,16 +73,16 @@ struct ec_ctx{
This does not include partial bits currently in the range coder.*/
int nbits_total;
/*The offset at which the next range coder byte will be read/written.*/
celt_uint32 offs;
opus_uint32 offs;
/*The number of values in the current range.*/
celt_uint32 rng;
opus_uint32 rng;
/*In the decoder: the difference between the top of the current range and
the input value, minus one.
In the encoder: the low end of the current range.*/
celt_uint32 val;
opus_uint32 val;
/*In the decoder: the saved normalization factor from ec_decode().
In the encoder: the number of oustanding carry propagating symbols.*/
celt_uint32 ext;
opus_uint32 ext;
/*A buffered input/output symbol, awaiting carry propagation.*/
int rem;
/*Nonzero if an error occurred.*/
@ -95,7 +95,7 @@ static inline void ec_reset(ec_ctx *_this){
_this->offs=_this->end_offs=0;
}
static inline celt_uint32 ec_range_bytes(ec_ctx *_this){
static inline opus_uint32 ec_range_bytes(ec_ctx *_this){
return _this->offs;
}
@ -123,6 +123,6 @@ static inline int ec_tell(ec_ctx *_this){
Return: The number of bits scaled by 2**BITRES.
This will always be slightly larger than the exact value (e.g., all
rounding error is in the positive direction).*/
celt_uint32 ec_tell_frac(ec_ctx *_this);
opus_uint32 ec_tell_frac(ec_ctx *_this);
#endif

View file

@ -125,7 +125,7 @@ static void ec_dec_normalize(ec_dec *_this){
}
}
void ec_dec_init(ec_dec *_this,unsigned char *_buf,celt_uint32 _storage){
void ec_dec_init(ec_dec *_this,unsigned char *_buf,opus_uint32 _storage){
_this->buf=_buf;
_this->storage=_storage;
_this->end_offs=0;
@ -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){
celt_uint32 s;
opus_uint32 s;
s=IMUL32(_this->ext,_ft-_fh);
_this->val-=s;
_this->rng=_fl>0?IMUL32(_this->ext,_fh-_fl):_this->rng-s;
@ -169,9 +169,9 @@ void ec_dec_update(ec_dec *_this,unsigned _fl,unsigned _fh,unsigned _ft){
/*The probability of having a "one" is 1/(1<<_logp).*/
int ec_dec_bit_logp(ec_dec *_this,unsigned _logp){
celt_uint32 r;
celt_uint32 d;
celt_uint32 s;
opus_uint32 r;
opus_uint32 d;
opus_uint32 s;
int ret;
r=_this->rng;
d=_this->val;
@ -184,10 +184,10 @@ int ec_dec_bit_logp(ec_dec *_this,unsigned _logp){
}
int ec_dec_icdf(ec_dec *_this,const unsigned char *_icdf,unsigned _ftb){
celt_uint32 r;
celt_uint32 d;
celt_uint32 s;
celt_uint32 t;
opus_uint32 r;
opus_uint32 d;
opus_uint32 s;
opus_uint32 t;
int ret;
s=_this->rng;
d=_this->val;
@ -204,7 +204,7 @@ int ec_dec_icdf(ec_dec *_this,const unsigned char *_icdf,unsigned _ftb){
return ret;
}
celt_uint32 ec_dec_uint(ec_dec *_this,celt_uint32 _ft){
opus_uint32 ec_dec_uint(ec_dec *_this,opus_uint32 _ft){
unsigned ft;
unsigned s;
int ftb;
@ -213,12 +213,12 @@ celt_uint32 ec_dec_uint(ec_dec *_this,celt_uint32 _ft){
_ft--;
ftb=EC_ILOG(_ft);
if(ftb>EC_UINT_BITS){
celt_uint32 t;
opus_uint32 t;
ftb-=EC_UINT_BITS;
ft=(unsigned)(_ft>>ftb)+1;
s=ec_decode(_this,ft);
ec_dec_update(_this,s,s+1,ft);
t=(celt_uint32)s<<ftb|ec_dec_bits(_this,ftb);
t=(opus_uint32)s<<ftb|ec_dec_bits(_this,ftb);
if(t<=_ft)return t;
_this->error=1;
return _ft;
@ -231,10 +231,10 @@ celt_uint32 ec_dec_uint(ec_dec *_this,celt_uint32 _ft){
}
}
celt_uint32 ec_dec_bits(ec_dec *_this,unsigned _bits){
opus_uint32 ec_dec_bits(ec_dec *_this,unsigned _bits){
ec_window window;
int available;
celt_uint32 ret;
opus_uint32 ret;
window=_this->end_window;
available=_this->nend_bits;
if(available<_bits){
@ -244,7 +244,7 @@ celt_uint32 ec_dec_bits(ec_dec *_this,unsigned _bits){
}
while(available<=EC_WINDOW_SIZE-EC_SYM_BITS);
}
ret=(celt_uint32)window&((celt_uint32)1<<_bits)-1;
ret=(opus_uint32)window&((opus_uint32)1<<_bits)-1;
window>>=_bits;
available-=_bits;
_this->end_window=window;

View file

@ -35,7 +35,7 @@
/*Initializes the decoder.
_buf: The input buffer to use.
Return: 0 on success, or a negative value on error.*/
void ec_dec_init(ec_dec *_this,unsigned char *_buf,celt_uint32 _storage);
void ec_dec_init(ec_dec *_this,unsigned char *_buf,opus_uint32 _storage);
/*Calculates the cumulative frequency for the next symbol.
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);
_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.
Return: The decoded bits.*/
celt_uint32 ec_dec_uint(ec_dec *_this,celt_uint32 _ft);
opus_uint32 ec_dec_uint(ec_dec *_this,opus_uint32 _ft);
/*Extracts a sequence of raw bits from the stream.
The bits must have been encoded with ec_enc_bits().
@ -97,6 +97,6 @@ celt_uint32 ec_dec_uint(ec_dec *_this,celt_uint32 _ft);
_ftb: The number of bits to extract.
This must be between 0 and 25, inclusive.
Return: The decoded bits.*/
celt_uint32 ec_dec_bits(ec_dec *_this,unsigned _ftb);
opus_uint32 ec_dec_bits(ec_dec *_this,unsigned _ftb);
#endif

View file

@ -114,7 +114,7 @@ static void ec_enc_normalize(ec_enc *_this){
}
}
void ec_enc_init(ec_enc *_this,unsigned char *_buf,celt_uint32 _size){
void ec_enc_init(ec_enc *_this,unsigned char *_buf,opus_uint32 _size){
_this->buf=_buf;
_this->end_offs=0;
_this->end_window=0;
@ -131,7 +131,7 @@ void ec_enc_init(ec_enc *_this,unsigned char *_buf,celt_uint32 _size){
}
void ec_encode(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _ft){
celt_uint32 r;
opus_uint32 r;
r=_this->rng/_ft;
if(_fl>0){
_this->val+=_this->rng-IMUL32(r,(_ft-_fl));
@ -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){
celt_uint32 r;
opus_uint32 r;
r=_this->rng>>_bits;
if(_fl>0){
_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){
/*The probability of having a "one" is 1/(1<<_logp).*/
void ec_enc_bit_logp(ec_enc *_this,int _val,unsigned _logp){
celt_uint32 r;
celt_uint32 s;
celt_uint32 l;
opus_uint32 r;
opus_uint32 s;
opus_uint32 l;
r=_this->rng;
l=_this->val;
s=r>>_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){
celt_uint32 r;
opus_uint32 r;
r=_this->rng>>_ftb;
if(_s>0){
_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){
ec_enc_normalize(_this);
}
void ec_enc_uint(ec_enc *_this,celt_uint32 _fl,celt_uint32 _ft){
void ec_enc_uint(ec_enc *_this,opus_uint32 _fl,opus_uint32 _ft){
unsigned ft;
unsigned fl;
int ftb;
@ -190,12 +190,12 @@ void ec_enc_uint(ec_enc *_this,celt_uint32 _fl,celt_uint32 _ft){
ft=(_ft>>ftb)+1;
fl=(unsigned)(_fl>>ftb);
ec_encode(_this,fl,fl+1,ft);
ec_enc_bits(_this,_fl&((celt_uint32)1<<ftb)-1,ftb);
ec_enc_bits(_this,_fl&((opus_uint32)1<<ftb)-1,ftb);
}
else ec_encode(_this,_fl,_fl+1,_ft+1);
}
void ec_enc_bits(ec_enc *_this,celt_uint32 _fl,unsigned _bits){
void ec_enc_bits(ec_enc *_this,opus_uint32 _fl,unsigned _bits){
ec_window window;
int used;
window=_this->end_window;
@ -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){
/*The renormalization loop has never been run.*/
_this->val=_this->val&~((celt_uint32)mask<<EC_CODE_SHIFT)|
(celt_uint32)_val<<EC_CODE_SHIFT+shift;
_this->val=_this->val&~((opus_uint32)mask<<EC_CODE_SHIFT)|
(opus_uint32)_val<<EC_CODE_SHIFT+shift;
}
/*The encoder hasn't even encoded _nbits of data yet.*/
else _this->error=-1;
}
void ec_enc_shrink(ec_enc *_this,celt_uint32 _size){
void ec_enc_shrink(ec_enc *_this,opus_uint32 _size){
celt_assert(_this->offs+_this->end_offs<=_size);
CELT_MOVE(_this->buf+_size-_this->end_offs,
_this->buf+_this->storage-_this->end_offs,_this->end_offs);
@ -248,8 +248,8 @@ void ec_enc_shrink(ec_enc *_this,celt_uint32 _size){
void ec_enc_done(ec_enc *_this){
ec_window window;
int used;
celt_uint32 msk;
celt_uint32 end;
opus_uint32 msk;
opus_uint32 end;
int l;
/*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.*/

View file

@ -35,7 +35,7 @@
/*Initializes the encoder.
_buf: The buffer to store output bytes in.
_size: The size of the buffer, in chars.*/
void ec_enc_init(ec_enc *_this,unsigned char *_buf,celt_uint32 _size);
void ec_enc_init(ec_enc *_this,unsigned char *_buf,opus_uint32 _size);
/*Encodes a symbol given its frequency information.
The frequency information must be discernable by the decoder, assuming it
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);
_fl: The integer to encode.
_ft: The number of integers that can be encoded (one more than the max).
This must be at least one, and no more than 2**32-1.*/
void ec_enc_uint(ec_enc *_this,celt_uint32 _fl,celt_uint32 _ft);
void ec_enc_uint(ec_enc *_this,opus_uint32 _fl,opus_uint32 _ft);
/*Encodes a sequence of raw bits in the stream.
_fl: The bits to encode.
_ftb: The number of bits to encode.
This must be between 0 and 25, inclusive.*/
void ec_enc_bits(ec_enc *_this,celt_uint32 _fl,unsigned _ftb);
void ec_enc_bits(ec_enc *_this,opus_uint32 _fl,unsigned _ftb);
/*Overwrites a few bits at the very start of an existing stream, after they
have already been encoded.
@ -102,7 +102,7 @@ void ec_enc_patch_initial_bits(ec_enc *_this,unsigned _val,unsigned _nbits);
_size: The number of bytes in the new buffer.
This must be large enough to contain the bits already written, and
must be no larger than the existing size.*/
void ec_enc_shrink(ec_enc *_this,celt_uint32 _size);
void ec_enc_shrink(ec_enc *_this,opus_uint32 _size);
/*Indicates that there are no more symbols to encode.
All reamining output bytes are flushed to the output buffer.

View file

@ -42,7 +42,7 @@ extern long long celt_mips;
#define MIPS_INC celt_mips++,
#define MULT16_16SU(a,b) ((celt_word32)(celt_word16)(a)*(celt_word32)(celt_uint16)(b))
#define MULT16_16SU(a,b) ((celt_word32)(celt_word16)(a)*(celt_word32)(opus_uint16)(b))
#define MULT32_32_Q31(a,b) ADD32(ADD32(SHL32(MULT16_16(SHR32((a),16),SHR((b),16)),1), SHR32(MULT16_16SU(SHR32((a),16),((b)&0x0000ffff)),15)), SHR32(MULT16_16SU(SHR32((b),16),((a)&0x0000ffff)),15))
/** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */

View file

@ -34,7 +34,7 @@
#define FIXED_GENERIC_H
/** Multiply a 16-bit signed value by a 16-bit unsigned value. The result is a 32-bit signed value */
#define MULT16_16SU(a,b) ((celt_word32)(celt_word16)(a)*(celt_word32)(celt_uint16)(b))
#define MULT16_16SU(a,b) ((celt_word32)(celt_word16)(a)*(celt_word32)(opus_uint16)(b))
/** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */
#define MULT16_32_Q16(a,b) ADD32(MULT16_16((a),SHR((b),16)), SHR(MULT16_16SU((a),((b)&0x0000ffff)),16))

View file

@ -437,7 +437,7 @@ static void kf_work(
const kiss_fft_cpx * f,
size_t fstride,
int in_stride,
const celt_int16 * factors,
const opus_int16 * factors,
const kiss_fft_state *st,
int N,
int m2
@ -468,7 +468,7 @@ static void ki_work(
const kiss_fft_cpx * f,
size_t fstride,
int in_stride,
const celt_int16 * factors,
const opus_int16 * factors,
const kiss_fft_state *st,
int N,
int m2
@ -499,10 +499,10 @@ static void ki_work(
static
void compute_bitrev_table(
int Fout,
celt_int16 *f,
opus_int16 *f,
const size_t fstride,
int in_stride,
celt_int16 * factors,
opus_int16 * factors,
const kiss_fft_state *st
)
{
@ -535,7 +535,7 @@ void compute_bitrev_table(
p[i] * m[i] = m[i-1]
m0 = n */
static
int kf_factor(int n,celt_int16 * facbuf)
int kf_factor(int n,opus_int16 * facbuf)
{
int p=4;
@ -547,7 +547,7 @@ int kf_factor(int n,celt_int16 * facbuf)
case 2: p = 3; break;
default: p += 2; break;
}
if (p>32000 || (celt_int32)p*(celt_int32)p > n)
if (p>32000 || (opus_int32)p*(opus_int32)p > n)
p = n; /* no more factors, skip to end */
}
n /= p;
@ -603,7 +603,7 @@ kiss_fft_state *kiss_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem, co
*lenmem = memneeded;
}
if (st) {
celt_int16 *bitrev;
opus_int16 *bitrev;
kiss_twiddle_cpx *twiddles;
st->nfft=nfft;
@ -630,7 +630,7 @@ kiss_fft_state *kiss_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem, co
}
/* bitrev */
st->bitrev = bitrev = (celt_int16*)KISS_FFT_MALLOC(sizeof(celt_int16)*nfft);
st->bitrev = bitrev = (opus_int16*)KISS_FFT_MALLOC(sizeof(opus_int16)*nfft);
if (st->bitrev==NULL)
goto fail;
compute_bitrev_table(0, bitrev, 1,1, st->factors,st);
@ -650,7 +650,7 @@ void kiss_fft_free(const kiss_fft_state *cfg)
{
if (cfg)
{
celt_free((celt_int16*)cfg->bitrev);
celt_free((opus_int16*)cfg->bitrev);
if (cfg->shift < 0)
celt_free((kiss_twiddle_cpx*)cfg->twiddles);
celt_free((kiss_fft_state*)cfg);

View file

@ -53,12 +53,12 @@ extern "C" {
#define DOUBLE_PRECISION
#ifdef DOUBLE_PRECISION
# define kiss_fft_scalar celt_int32
# define kiss_twiddle_scalar celt_int16
# define kiss_fft_scalar opus_int32
# define kiss_twiddle_scalar opus_int16
# define KF_SUFFIX _celt_double
#else
# define kiss_fft_scalar celt_int16
# define kiss_twiddle_scalar celt_int16
# define kiss_fft_scalar opus_int16
# define kiss_twiddle_scalar opus_int16
# define KF_SUFFIX _celt_single
#endif
#else
@ -108,8 +108,8 @@ typedef struct kiss_fft_state{
kiss_fft_scalar scale;
#endif
int shift;
celt_int16 factors[2*MAXFACTORS];
const celt_int16 *bitrev;
opus_int16 factors[2*MAXFACTORS];
const opus_int16 *bitrev;
const kiss_twiddle_cpx *twiddles;
} kiss_fft_state;

View file

@ -42,7 +42,7 @@
static int ec_laplace_get_freq1(int fs0, int decay)
{
celt_int32 ft;
opus_int32 ft;
ft = 32768 - LAPLACE_MINP*(2*LAPLACE_NMIN) - fs0;
return ft*(16384-decay)>>15;
}
@ -65,7 +65,7 @@ void ec_laplace_encode(ec_enc *enc, int *value, int fs, int decay)
{
fs *= 2;
fl += fs+2*LAPLACE_MINP;
fs = (fs*(celt_int32)decay)>>15;
fs = (fs*(opus_int32)decay)>>15;
}
/* Everything beyond that has probability LAPLACE_MINP. */
if (fs <= 0)
@ -108,7 +108,7 @@ int ec_laplace_decode(ec_dec *dec, int fs, int decay)
{
fs *= 2;
fl += fs;
fs = ((fs-2*LAPLACE_MINP)*(celt_int32)decay)>>15;
fs = ((fs-2*LAPLACE_MINP)*(opus_int32)decay)>>15;
fs += LAPLACE_MINP;
val++;
}

View file

@ -39,7 +39,7 @@
/*Compute floor(sqrt(_val)) with exact arithmetic.
This has been tested on all possible 32-bit inputs.*/
unsigned isqrt32(celt_uint32 _val){
unsigned isqrt32(opus_uint32 _val){
unsigned b;
unsigned g;
int bshift;
@ -51,8 +51,8 @@ unsigned isqrt32(celt_uint32 _val){
bshift=EC_ILOG(_val)-1>>1;
b=1U<<bshift;
do{
celt_uint32 t;
t=((celt_uint32)g<<1)+b<<bshift;
opus_uint32 t;
t=((opus_uint32)g<<1)+b<<bshift;
if(t<=_val){
g+=b;
_val-=t;

View file

@ -39,9 +39,9 @@
#include "os_support.h"
/* Multiplies two 16-bit fractional values. Bit-exactness of this macro is important */
#define FRAC_MUL16(a,b) ((16384+((celt_int32)(celt_int16)(a)*(celt_int16)(b)))>>15)
#define FRAC_MUL16(a,b) ((16384+((opus_int32)(opus_int16)(a)*(opus_int16)(b)))>>15)
unsigned isqrt32(celt_uint32 _val);
unsigned isqrt32(opus_uint32 _val);
#ifndef FIXED_POINT
@ -68,7 +68,7 @@ static inline float celt_log2(float x)
float frac;
union {
float f;
celt_uint32 i;
opus_uint32 i;
} in;
in.f = x;
integer = (in.i>>23)-127;
@ -86,7 +86,7 @@ static inline float celt_exp2(float x)
float frac;
union {
float f;
celt_uint32 i;
opus_uint32 i;
} res;
integer = floor(x);
if (integer < -50)
@ -114,7 +114,7 @@ static inline float celt_exp2(float x)
#ifndef OVERRIDE_CELT_ILOG2
/** Integer log in base2. Undefined for zero and negative numbers */
static inline celt_int16 celt_ilog2(celt_int32 x)
static inline opus_int16 celt_ilog2(opus_int32 x)
{
celt_assert2(x>0, "celt_ilog2() only defined for strictly positive numbers");
return EC_ILOG(x)-1;
@ -134,7 +134,7 @@ static inline celt_word16 celt_maxabs16(celt_word16 *x, int len)
#endif
/** Integer log in base2. Defined for zero, but not for negative numbers */
static inline celt_int16 celt_zlog2(celt_word32 x)
static inline opus_int16 celt_zlog2(celt_word32 x)
{
return x <= 0 ? 0 : celt_ilog2(x);
}

View file

@ -40,17 +40,17 @@
/*Bits to shift by to move a symbol into the high-order position.*/
# define EC_CODE_SHIFT (EC_CODE_BITS-EC_SYM_BITS-1)
/*Carry bit of the high-order range symbol.*/
# define EC_CODE_TOP (((celt_uint32)1U)<<EC_CODE_BITS-1)
# define EC_CODE_TOP (((opus_uint32)1U)<<EC_CODE_BITS-1)
/*Low-order bit of the high-order range symbol.*/
# define EC_CODE_BOT (EC_CODE_TOP>>EC_SYM_BITS)
/*Code for which propagating carries are possible.*/
# define EC_CODE_CARRY (((celt_uint32)EC_SYM_MAX)<<EC_CODE_SHIFT)
# define EC_CODE_CARRY (((opus_uint32)EC_SYM_MAX)<<EC_CODE_SHIFT)
/*The number of bits available for the last, partial symbol in the code field.*/
# define EC_CODE_EXTRA ((EC_CODE_BITS-2)%EC_SYM_BITS+1)
/*A mask for the bits available in the coding buffer.
This allows different platforms to use a variable with more bits, if it is
convenient.
We will only use EC_CODE_BITS of it.*/
# define EC_CODE_MASK ((((celt_uint32)1U)<<EC_CODE_BITS-1)-1<<1|1)
# define EC_CODE_MASK ((((opus_uint32)1U)<<EC_CODE_BITS-1)-1<<1|1)
#endif

View file

@ -38,7 +38,7 @@
#include "stack_alloc.h"
#include "quant_bands.h"
static const celt_int16 eband5ms[] = {
static const opus_int16 eband5ms[] = {
/*0 200 400 600 800 1k 1.2 1.4 1.6 2k 2.4 2.8 3.2 4k 4.8 5.6 6.8 8k 9.6 12k 15.6 */
0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 34, 40, 48, 60, 78, 100
};
@ -79,7 +79,7 @@ static const unsigned char band_allocation[] = {
/* Defining 25 critical bands for the full 0-20 kHz audio bandwidth
Taken from http://ccrma.stanford.edu/~jos/bbt/Bark_Frequency_Scale.html */
#define BARK_BANDS 25
static const celt_int16 bark_freq[BARK_BANDS+1] = {
static const opus_int16 bark_freq[BARK_BANDS+1] = {
0, 100, 200, 300, 400,
510, 630, 770, 920, 1080,
1270, 1480, 1720, 2000, 2320,
@ -87,16 +87,16 @@ static const celt_int16 bark_freq[BARK_BANDS+1] = {
6400, 7700, 9500, 12000, 15500,
20000};
static celt_int16 *compute_ebands(celt_int32 Fs, int frame_size, int res, int *nbEBands)
static opus_int16 *compute_ebands(opus_int32 Fs, int frame_size, int res, int *nbEBands)
{
celt_int16 *eBands;
opus_int16 *eBands;
int i, j, lin, low, high, nBark, offset=0;
/* All modes that have 2.5 ms short blocks use the same definition */
if (Fs == 400*(celt_int32)frame_size)
if (Fs == 400*(opus_int32)frame_size)
{
*nbEBands = sizeof(eband5ms)/sizeof(eband5ms[0])-1;
eBands = celt_alloc(sizeof(celt_int16)*(*nbEBands+1));
eBands = celt_alloc(sizeof(opus_int16)*(*nbEBands+1));
for (i=0;i<*nbEBands+1;i++)
eBands[i] = eband5ms[i];
return eBands;
@ -114,7 +114,7 @@ static celt_int16 *compute_ebands(celt_int32 Fs, int frame_size, int res, int *n
low = (bark_freq[lin]+res/2)/res;
high = nBark-lin;
*nbEBands = low+high;
eBands = celt_alloc(sizeof(celt_int16)*(*nbEBands+2));
eBands = celt_alloc(sizeof(opus_int16)*(*nbEBands+2));
if (eBands==NULL)
return NULL;
@ -176,7 +176,7 @@ static void compute_allocation_table(CELTMode *mode)
return;
/* Check for standard mode */
if (mode->Fs == 400*(celt_int32)mode->shortMdctSize)
if (mode->Fs == 400*(opus_int32)mode->shortMdctSize)
{
for (i=0;i<BITALLOC_SIZE*mode->nbEBands;i++)
allocVectors[i] = band_allocation[i];
@ -192,15 +192,15 @@ static void compute_allocation_table(CELTMode *mode)
int k;
for (k=0;k<maxBands;k++)
{
if (400*(celt_int32)eband5ms[k] > mode->eBands[j]*(celt_int32)mode->Fs/mode->shortMdctSize)
if (400*(opus_int32)eband5ms[k] > mode->eBands[j]*(opus_int32)mode->Fs/mode->shortMdctSize)
break;
}
if (k>maxBands-1)
allocVectors[i*mode->nbEBands+j] = band_allocation[i*maxBands + maxBands-1];
else {
celt_int32 a0, a1;
a1 = mode->eBands[j]*(celt_int32)mode->Fs/mode->shortMdctSize - 400*(celt_int32)eband5ms[k-1];
a0 = 400*(celt_int32)eband5ms[k] - mode->eBands[j]*(celt_int32)mode->Fs/mode->shortMdctSize;
opus_int32 a0, a1;
a1 = mode->eBands[j]*(opus_int32)mode->Fs/mode->shortMdctSize - 400*(opus_int32)eband5ms[k-1];
a0 = 400*(opus_int32)eband5ms[k] - mode->eBands[j]*(opus_int32)mode->Fs/mode->shortMdctSize;
allocVectors[i*mode->nbEBands+j] = (a0*band_allocation[i*maxBands+k-1]
+ a1*band_allocation[i*maxBands+k])/(a0+a1);
}
@ -221,14 +221,14 @@ static void compute_allocation_table(CELTMode *mode)
#endif /* CUSTOM_MODES */
CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error)
CELTMode *celt_mode_create(opus_int32 Fs, int frame_size, int *error)
{
int i;
#ifdef CUSTOM_MODES
CELTMode *mode=NULL;
int res;
celt_word16 *window;
celt_int16 *logN;
opus_int16 *logN;
int LM;
ALLOC_STACK;
#if !defined(VAR_ARRAYS) && !defined(USE_ALLOCA)
@ -275,20 +275,20 @@ CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error)
return NULL;
}
/* Frames of less than 1ms are not supported. */
if ((celt_int32)frame_size*1000 < Fs)
if ((opus_int32)frame_size*1000 < Fs)
{
if (error)
*error = CELT_BAD_ARG;
return NULL;
}
if ((celt_int32)frame_size*75 >= Fs && (frame_size%16)==0)
if ((opus_int32)frame_size*75 >= Fs && (frame_size%16)==0)
{
LM = 3;
} else if ((celt_int32)frame_size*150 >= Fs && (frame_size%8)==0)
} else if ((opus_int32)frame_size*150 >= Fs && (frame_size%8)==0)
{
LM = 2;
} else if ((celt_int32)frame_size*300 >= Fs && (frame_size%4)==0)
} else if ((opus_int32)frame_size*300 >= Fs && (frame_size%4)==0)
{
LM = 1;
} else
@ -297,7 +297,7 @@ CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error)
}
/* Shorts longer than 3.3ms are not supported. */
if ((celt_int32)(frame_size>>LM)*300 > Fs)
if ((opus_int32)(frame_size>>LM)*300 > Fs)
{
if (error)
*error = CELT_BAD_ARG;
@ -371,7 +371,7 @@ CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error)
#endif
mode->window = window;
logN = (celt_int16*)celt_alloc(mode->nbEBands*sizeof(celt_int16));
logN = (opus_int16*)celt_alloc(mode->nbEBands*sizeof(opus_int16));
if (logN==NULL)
goto failure;
@ -413,13 +413,13 @@ void celt_mode_destroy(CELTMode *mode)
}
}
#endif /* CUSTOM_MODES_ONLY */
celt_free((celt_int16*)mode->eBands);
celt_free((celt_int16*)mode->allocVectors);
celt_free((opus_int16*)mode->eBands);
celt_free((opus_int16*)mode->allocVectors);
celt_free((celt_word16*)mode->window);
celt_free((celt_int16*)mode->logN);
celt_free((opus_int16*)mode->logN);
celt_free((celt_int16*)mode->cache.index);
celt_free((opus_int16*)mode->cache.index);
celt_free((unsigned char*)mode->cache.bits);
celt_free((unsigned char*)mode->cache.caps);
clt_mdct_clear(&mode->mdct);

View file

@ -30,7 +30,7 @@
#ifndef MODES_H
#define MODES_H
#include "celt_types.h"
#include "opus_types.h"
#include "celt.h"
#include "arch.h"
#include "mdct.h"
@ -59,7 +59,7 @@
typedef struct {
int size;
const celt_int16 *index;
const opus_int16 *index;
const unsigned char *bits;
const unsigned char *caps;
} PulseCache;
@ -68,13 +68,13 @@ typedef struct {
@brief Mode definition
*/
struct CELTMode {
celt_int32 Fs;
opus_int32 Fs;
int overlap;
int nbEBands;
int effEBands;
celt_word16 preemph[4];
const celt_int16 *eBands; /**< Definition for each "pseudo-critical band" */
const opus_int16 *eBands; /**< Definition for each "pseudo-critical band" */
int nbAllocVectors; /**< Number of lines in the matrix below */
const unsigned char *allocVectors; /**< Number of bits in each band for several rates */
@ -88,7 +88,7 @@ struct CELTMode {
int nbShortMdcts;
int shortMdctSize;
const celt_int16 *logN;
const opus_int16 *logN;
PulseCache cache;
};
@ -108,9 +108,9 @@ struct CELTMode {
#define CELT_GET_MODE(x) CELT_GET_MODE_REQUEST, _celt_check_mode_ptr_ptr(x)
/* Prototypes for _ec versions of the encoder/decoder calls (not public) */
int celt_encode_with_ec(CELTEncoder * restrict st, const celt_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc);
int celt_encode_with_ec(CELTEncoder * restrict st, const opus_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc);
int celt_encode_with_ec_float(CELTEncoder * restrict st, const float * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc);
int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, int len, celt_int16 * restrict pcm, int frame_size, ec_dec *dec);
int celt_decode_with_ec(CELTDecoder * restrict st, const unsigned char *data, int len, opus_int16 * restrict pcm, int frame_size, ec_dec *dec);
int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *data, int len, float * restrict pcm, int frame_size, ec_dec *dec);
#endif /* OPUS_BUILD */

View file

@ -24,128 +24,128 @@
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* celt_types.h taken from libogg */
/* opus_types.h taken from libogg */
/**
@file celt_types.h
@brief CELT types
@file opus_types.h
@brief OPUS types
*/
#ifndef _CELT_TYPES_H
#define _CELT_TYPES_H
#ifndef _OPUS_TYPES_H
#define _OPUS_TYPES_H
/* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */
#if (defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H))
#include <stdint.h>
typedef int16_t celt_int16;
typedef uint16_t celt_uint16;
typedef int32_t celt_int32;
typedef uint32_t celt_uint32;
typedef int16_t opus_int16;
typedef uint16_t opus_uint16;
typedef int32_t opus_int32;
typedef uint32_t opus_uint32;
#elif defined(_WIN32)
# if defined(__CYGWIN__)
# include <_G_config.h>
typedef _G_int32_t celt_int32;
typedef _G_uint32_t celt_uint32;
typedef _G_int16 celt_int16;
typedef _G_uint16 celt_uint16;
typedef _G_int32_t opus_int32;
typedef _G_uint32_t opus_uint32;
typedef _G_int16 opus_int16;
typedef _G_uint16 opus_uint16;
# elif defined(__MINGW32__)
typedef short celt_int16;
typedef unsigned short celt_uint16;
typedef int celt_int32;
typedef unsigned int celt_uint32;
typedef short opus_int16;
typedef unsigned short opus_uint16;
typedef int opus_int32;
typedef unsigned int opus_uint32;
# elif defined(__MWERKS__)
typedef int celt_int32;
typedef unsigned int celt_uint32;
typedef short celt_int16;
typedef unsigned short celt_uint16;
typedef int opus_int32;
typedef unsigned int opus_uint32;
typedef short opus_int16;
typedef unsigned short opus_uint16;
# else
/* MSVC/Borland */
typedef __int32 celt_int32;
typedef unsigned __int32 celt_uint32;
typedef __int16 celt_int16;
typedef unsigned __int16 celt_uint16;
typedef __int32 opus_int32;
typedef unsigned __int32 opus_uint32;
typedef __int16 opus_int16;
typedef unsigned __int16 opus_uint16;
# endif
#elif defined(__MACOS__)
# include <sys/types.h>
typedef SInt16 celt_int16;
typedef UInt16 celt_uint16;
typedef SInt32 celt_int32;
typedef UInt32 celt_uint32;
typedef SInt16 opus_int16;
typedef UInt16 opus_uint16;
typedef SInt32 opus_int32;
typedef UInt32 opus_uint32;
#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
# include <sys/types.h>
typedef int16_t celt_int16;
typedef u_int16_t celt_uint16;
typedef int32_t celt_int32;
typedef u_int32_t celt_uint32;
typedef int16_t opus_int16;
typedef u_int16_t opus_uint16;
typedef int32_t opus_int32;
typedef u_int32_t opus_uint32;
#elif defined(__BEOS__)
/* Be */
# include <inttypes.h>
typedef int16 celt_int16;
typedef u_int16 celt_uint16;
typedef int32_t celt_int32;
typedef u_int32_t celt_uint32;
typedef int16 opus_int16;
typedef u_int16 opus_uint16;
typedef int32_t opus_int32;
typedef u_int32_t opus_uint32;
#elif defined (__EMX__)
/* OS/2 GCC */
typedef short celt_int16;
typedef unsigned short celt_uint16;
typedef int celt_int32;
typedef unsigned int celt_uint32;
typedef short opus_int16;
typedef unsigned short opus_uint16;
typedef int opus_int32;
typedef unsigned int opus_uint32;
#elif defined (DJGPP)
/* DJGPP */
typedef short celt_int16;
typedef unsigned short celt_uint16;
typedef int celt_int32;
typedef unsigned int celt_uint32;
typedef short opus_int16;
typedef unsigned short opus_uint16;
typedef int opus_int32;
typedef unsigned int opus_uint32;
#elif defined(R5900)
/* PS2 EE */
typedef int celt_int32;
typedef unsigned celt_uint32;
typedef short celt_int16;
typedef unsigned short celt_uint16;
typedef int opus_int32;
typedef unsigned opus_uint32;
typedef short opus_int16;
typedef unsigned short opus_uint16;
#elif defined(__SYMBIAN32__)
/* Symbian GCC */
typedef signed short celt_int16;
typedef unsigned short celt_uint16;
typedef signed int celt_int32;
typedef unsigned int celt_uint32;
typedef signed short opus_int16;
typedef unsigned short opus_uint16;
typedef signed int opus_int32;
typedef unsigned int opus_uint32;
#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
typedef short celt_int16;
typedef unsigned short celt_uint16;
typedef long celt_int32;
typedef unsigned long celt_uint32;
typedef short opus_int16;
typedef unsigned short opus_uint16;
typedef long opus_int32;
typedef unsigned long opus_uint32;
#elif defined(CONFIG_TI_C6X)
typedef short celt_int16;
typedef unsigned short celt_uint16;
typedef int celt_int32;
typedef unsigned int celt_uint32;
typedef short opus_int16;
typedef unsigned short opus_uint16;
typedef int opus_int32;
typedef unsigned int opus_uint32;
#else
/* Give up, take a reasonable guess */
typedef short celt_int16;
typedef unsigned short celt_uint16;
typedef int celt_int32;
typedef unsigned int celt_uint32;
typedef short opus_int16;
typedef unsigned short opus_uint16;
typedef int opus_int32;
typedef unsigned int opus_uint32;
#endif
#endif /* _CELT_TYPES_H */
#endif /* _OPUS_TYPES_H */

View file

@ -155,7 +155,7 @@ static celt_word32 loss_distortion(const celt_word16 *eBands, celt_word16 *oldEB
static int quant_coarse_energy_impl(const CELTMode *m, int start, int end,
const celt_word16 *eBands, celt_word16 *oldEBands,
celt_int32 budget, celt_int32 tell,
opus_int32 budget, opus_int32 tell,
const unsigned char *prob_model, celt_word16 *error, ec_enc *enc,
int _C, int LM, int intra, celt_word16 max_decay)
{
@ -258,7 +258,7 @@ static int quant_coarse_energy_impl(const CELTMode *m, int start, int end,
}
void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
const celt_word16 *eBands, celt_word16 *oldEBands, celt_uint32 budget,
const celt_word16 *eBands, celt_word16 *oldEBands, opus_uint32 budget,
celt_word16 *error, ec_enc *enc, int _C, int LM, int nbAvailableBytes,
int force_intra, celt_word32 *delayedIntra, int two_pass, int loss_rate)
{
@ -268,9 +268,9 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
VARDECL(celt_word16, oldEBands_intra);
VARDECL(celt_word16, error_intra);
ec_enc enc_start_state;
celt_uint32 tell;
opus_uint32 tell;
int badness1=0;
celt_int32 intra_bias;
opus_int32 intra_bias;
celt_word32 new_distortion;
SAVE_STACK;
@ -307,8 +307,8 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
{
ec_enc enc_intra_state;
int tell_intra;
celt_uint32 nstart_bytes;
celt_uint32 nintra_bytes;
opus_uint32 nstart_bytes;
opus_uint32 nintra_bytes;
int badness2;
VARDECL(unsigned char, intra_bits);
@ -361,7 +361,7 @@ void quant_fine_energy(const CELTMode *m, int start, int end, celt_word16 *oldEB
/* Encode finer resolution */
for (i=start;i<end;i++)
{
celt_int16 frac = 1<<fine_quant[i];
opus_int16 frac = 1<<fine_quant[i];
if (fine_quant[i] <= 0)
continue;
c=0;
@ -429,8 +429,8 @@ void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_word16 *o
celt_word16 coef;
celt_word16 beta;
const int C = CHANNELS(_C);
celt_int32 budget;
celt_int32 tell;
opus_int32 budget;
opus_int32 tell;
if (intra)

View file

@ -42,10 +42,10 @@ void log2Amp(const CELTMode *m, int start, int end,
celt_ener *eBands, celt_word16 *oldEBands, int _C);
unsigned char *quant_prob_alloc(const CELTMode *m);
void quant_prob_free(const celt_int16 *freq);
void quant_prob_free(const opus_int16 *freq);
void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd,
const celt_word16 *eBands, celt_word16 *oldEBands, celt_uint32 budget,
const celt_word16 *eBands, celt_word16 *oldEBands, opus_uint32 budget,
celt_word16 *error, ec_enc *enc, int _C, int LM,
int nbAvailableBytes, int force_intra, celt_word32 *delayedIntra,
int two_pass, int loss_rate);

View file

@ -54,10 +54,10 @@ static const unsigned char LOG2_FRAC_TABLE[24]={
N and K are themselves limited to 15 bits.*/
static int fits_in32(int _n, int _k)
{
static const celt_int16 maxN[15] = {
static const opus_int16 maxN[15] = {
32767, 32767, 32767, 1476, 283, 109, 60, 40,
29, 24, 20, 18, 16, 14, 13};
static const celt_int16 maxK[15] = {
static const opus_int16 maxK[15] = {
32767, 32767, 32767, 32767, 1172, 238, 95, 53,
36, 27, 22, 18, 16, 15, 13};
if (_n>=14)
@ -79,9 +79,9 @@ void compute_pulse_cache(CELTMode *m, int LM)
int curr=0;
int nbEntries=0;
int entryN[100], entryK[100], entryI[100];
const celt_int16 *eBands = m->eBands;
const opus_int16 *eBands = m->eBands;
PulseCache *cache = &m->cache;
celt_int16 *cindex;
opus_int16 *cindex;
unsigned char *bits;
unsigned char *cap;
@ -132,7 +132,7 @@ void compute_pulse_cache(CELTMode *m, int LM)
for (i=0;i<nbEntries;i++)
{
unsigned char *ptr = bits+entryI[i];
celt_int16 tmp[MAX_PULSES+1];
opus_int16 tmp[MAX_PULSES+1];
get_required_bits(tmp, entryN[i], get_pulses(entryK[i]), BITRES);
for (j=1;j<=entryK[i];j++)
ptr[j] = tmp[get_pulses(j)]-1;
@ -157,8 +157,8 @@ void compute_pulse_cache(CELTMode *m, int LM)
else
{
const unsigned char *pcache;
celt_int32 num;
celt_int32 den;
opus_int32 num;
opus_int32 den;
int LM0;
int N;
int offset;
@ -195,8 +195,8 @@ void compute_pulse_cache(CELTMode *m, int LM)
is to be max_bits.
The average measured cost for theta is 0.89701 times qb,
approximated here as 459/512. */
num=459*(celt_int32)((2*N-1)*offset+max_bits);
den=((celt_int32)(2*N-1)<<9)-459;
num=459*(opus_int32)((2*N-1)*offset+max_bits);
den=((opus_int32)(2*N-1)<<9)-459;
qb = IMIN((num+(den>>1))/den, 57);
celt_assert(qb >= 0);
max_bits += qb;
@ -210,8 +210,8 @@ void compute_pulse_cache(CELTMode *m, int LM)
ndof = 2*N-1-(N==2);
/* The average measured cost for theta with the step PDF is
0.95164 times qb, approximated here as 487/512. */
num = (N==2?512:487)*(celt_int32)(max_bits+ndof*offset);
den = ((celt_int32)ndof<<9)-(N==2?512:487);
num = (N==2?512:487)*(opus_int32)(max_bits+ndof*offset);
den = ((opus_int32)ndof<<9)-(N==2?512:487);
qb = IMIN((num+(den>>1))/den, (N==2?64:61));
celt_assert(qb >= 0);
max_bits += qb;
@ -248,11 +248,11 @@ void compute_pulse_cache(CELTMode *m, int LM)
#define ALLOC_STEPS 6
static inline int interp_bits2pulses(const CELTMode *m, int start, int end, int skip_start,
const int *bits1, const int *bits2, const int *thresh, const int *cap, celt_int32 total, celt_int32 *_balance,
const int *bits1, const int *bits2, const int *thresh, const int *cap, opus_int32 total, opus_int32 *_balance,
int skip_rsv, int *intensity, int intensity_rsv, int *dual_stereo, int dual_stereo_rsv, int *bits,
int *ebits, int *fine_priority, int _C, int LM, ec_ctx *ec, int encode, int prev)
{
celt_int32 psum;
opus_int32 psum;
int lo, hi;
int i, j;
int logM;
@ -260,7 +260,7 @@ static inline int interp_bits2pulses(const CELTMode *m, int start, int end, int
int stereo;
int codedBands=-1;
int alloc_floor;
celt_int32 left, percoeff;
opus_int32 left, percoeff;
int done;
int balance;
SAVE_STACK;
@ -278,7 +278,7 @@ static inline int interp_bits2pulses(const CELTMode *m, int start, int end, int
done = 0;
for (j=end;j-->start;)
{
int tmp = bits1[j] + (mid*(celt_int32)bits2[j]>>ALLOC_STEPS);
int tmp = bits1[j] + (mid*(opus_int32)bits2[j]>>ALLOC_STEPS);
if (tmp >= thresh[j] || done)
{
done = 1;
@ -523,7 +523,7 @@ static inline int interp_bits2pulses(const CELTMode *m, int start, int end, int
}
int compute_allocation(const CELTMode *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, int *intensity, int *dual_stereo,
celt_int32 total, celt_int32 *balance, int *pulses, int *ebits, int *fine_priority, int _C, int LM, ec_ctx *ec, int encode, int prev)
opus_int32 total, opus_int32 *balance, int *pulses, int *ebits, int *fine_priority, int _C, int LM, ec_ctx *ec, int encode, int prev)
{
int lo, hi, len, j;
const int C = CHANNELS(_C);

View file

@ -89,7 +89,7 @@ static inline int pulses2bits(const CELTMode *m, int band, int LM, int pulses)
}
/** Computes a cache of the pulses->bits mapping in each band */
celt_int16 **compute_alloc_cache(CELTMode *m, int M);
opus_int16 **compute_alloc_cache(CELTMode *m, int M);
/** Compute the pulse allocation, i.e. how many pulses will go in each
* band.
@ -101,7 +101,7 @@ celt_int16 **compute_alloc_cache(CELTMode *m, int M);
@return Total number of bits allocated
*/
int compute_allocation(const CELTMode *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, int *intensity, int *dual_stero,
celt_int32 total, celt_int32 *balance, int *pulses, int *ebits, int *fine_priority, int _C, int LM, ec_ctx *ec, int encode, int prev);
opus_int32 total, opus_int32 *balance, int *pulses, int *ebits, int *fine_priority, int _C, int LM, ec_ctx *ec, int encode, int prev);
#endif

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -48,7 +48,7 @@ int main(int argc, char *argv[])
CELTEncoder *enc;
CELTDecoder *dec;
int len;
celt_int32 frame_size, channels;
opus_int32 frame_size, channels;
int bytes_per_packet;
unsigned char data[MAX_PACKET];
int rate;
@ -58,8 +58,8 @@ int main(int argc, char *argv[])
double rmsd = 0;
#endif
int count = 0;
celt_int32 skip;
celt_int16 *in, *out;
opus_int32 skip;
opus_int16 *in, *out;
if (argc != 9 && argc != 8 && argc != 7)
{
fprintf (stderr, "Usage: testcelt <rate> <channels> <frame size> "
@ -121,8 +121,8 @@ int main(int argc, char *argv[])
celt_encoder_ctl(enc,CELT_SET_COMPLEXITY(complexity));
}
in = (celt_int16*)malloc(frame_size*channels*sizeof(celt_int16));
out = (celt_int16*)malloc(frame_size*channels*sizeof(celt_int16));
in = (opus_int16*)malloc(frame_size*channels*sizeof(opus_int16));
out = (opus_int16*)malloc(frame_size*channels*sizeof(opus_int16));
while (!feof(fin))
{

View file

@ -32,21 +32,21 @@ int main(int _argc,char **_argv){
dk=kmax[n]>7?kmax[n]/7:1;
k=1-dk;
do{
celt_uint32 uu[KMAX+2U];
celt_uint32 inc;
celt_uint32 nc;
celt_uint32 i;
opus_uint32 uu[KMAX+2U];
opus_uint32 inc;
opus_uint32 nc;
opus_uint32 i;
k=kmax[n]-dk<k?kmax[n]:k+dk;
printf("Testing CWRS with N=%i, K=%i...\n",n,k);
nc=ncwrs_urow(n,k,uu);
inc=nc/10000;
if(inc<1)inc=1;
for(i=0;i<nc;i+=inc){
celt_uint32 u[KMAX+2U];
opus_uint32 u[KMAX+2U];
int y[NMAX];
int yy[5];
celt_uint32 v;
celt_uint32 ii;
opus_uint32 v;
opus_uint32 ii;
int kk;
int j;
memcpy(u,uu,(k+2U)*sizeof(*u));

View file

@ -17,7 +17,7 @@
int ec_laplace_get_start_freq(int decay)
{
celt_uint32 ft = 32768 - LAPLACE_MINP*(2*LAPLACE_NMIN+1);
opus_uint32 ft = 32768 - LAPLACE_MINP*(2*LAPLACE_NMIN+1);
int fs = (ft*(16384-decay))/(16384+decay);
return fs+LAPLACE_MINP;
}

View file

@ -20,7 +20,7 @@ int ret = 0;
void testdiv(void)
{
celt_int32 i;
opus_int32 i;
for (i=1;i<=327670;i++)
{
double prod;
@ -41,7 +41,7 @@ void testdiv(void)
void testsqrt(void)
{
celt_int32 i;
opus_int32 i;
for (i=1;i<=1000000000;i++)
{
double ratio;

View file

@ -7,14 +7,14 @@
int main(void)
{
celt_int16 i = 1;
opus_int16 i = 1;
i <<= 14;
if (i>>14 != 1)
{
fprintf(stderr, "celt_int16 isn't 16 bits\n");
return 1;
}
if (sizeof(celt_int16)*2 != sizeof(celt_int32))
if (sizeof(opus_int16)*2 != sizeof(opus_int32))
{
fprintf(stderr, "16*2 != 32\n");
return 1;

View file

@ -184,7 +184,7 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
short pcm_buf[60*48*2];
int nb_compr_bytes;
int to_celt = 0;
celt_int32 mono_rate;
opus_int32 mono_rate;
if (400*frame_size != st->Fs && 200*frame_size != st->Fs && 100*frame_size != st->Fs &&
50*frame_size != st->Fs && 25*frame_size != st->Fs && 50*frame_size != 3*st->Fs)
@ -203,7 +203,7 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
st->stream_channels = 1;
} else if (st->mode == MODE_CELT_ONLY && st->channels == 2)
{
celt_int32 decision_rate;
opus_int32 decision_rate;
decision_rate = st->bitrate_bps + st->voice_ratio*st->voice_ratio;
/* Add some hysteresis */
if (st->stream_channels == 2)
@ -228,7 +228,7 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
/* Mode selection depending on application and signal type */
if (st->user_mode==OPUS_APPLICATION_VOIP)
{
celt_int32 threshold = 20000;
opus_int32 threshold = 20000;
/* Hysteresis */
if (st->prev_mode == MODE_CELT_ONLY)
threshold -= 4000;
@ -241,7 +241,7 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
else
st->mode = MODE_SILK_ONLY;
} else {/* OPUS_APPLICATION_AUDIO */
celt_int32 threshold;
opus_int32 threshold;
/* SILK/CELT threshold is higher for voice than for music */
threshold = 36000;
if (st->signal_type == OPUS_SIGNAL_MUSIC)

View file

@ -36,7 +36,7 @@
#include <string.h>
#include "opus.h"
#include "silk_debug.h"
#include "celt_types.h"
#include "opus_types.h"
#define MAX_PACKET 1500
@ -66,7 +66,7 @@ void print_usage( char* argv[] )
# define STR_CASEINSENSITIVE_COMPARE(x, y) strcasecmp(x, y)
#endif
static void int_to_char(celt_uint32 i, unsigned char ch[4])
static void int_to_char(opus_uint32 i, unsigned char ch[4])
{
ch[0] = i>>24;
ch[1] = (i>>16)&0xFF;
@ -74,10 +74,10 @@ static void int_to_char(celt_uint32 i, unsigned char ch[4])
ch[3] = i&0xFF;
}
static celt_uint32 char_to_int(unsigned char ch[4])
static opus_uint32 char_to_int(unsigned char ch[4])
{
return ((celt_uint32)ch[0]<<24) | ((celt_uint32)ch[1]<<16)
| ((celt_uint32)ch[2]<< 8) | (celt_uint32)ch[3];
return ((opus_uint32)ch[0]<<24) | ((opus_uint32)ch[1]<<16)
| ((opus_uint32)ch[2]<< 8) | (opus_uint32)ch[3];
}
int main(int argc, char *argv[])

View file

@ -48,7 +48,7 @@ int main(int argc, char *argv[])
CELTEncoder *enc;
CELTDecoder *dec;
int len;
celt_int32 frame_size, channels;
opus_int32 frame_size, channels;
int bytes_per_packet;
unsigned char data[MAX_PACKET];
int rate;
@ -58,8 +58,8 @@ int main(int argc, char *argv[])
double rmsd = 0;
#endif
int count = 0;
celt_int32 skip;
celt_int16 *in, *out;
opus_int32 skip;
opus_int16 *in, *out;
if (argc != 9 && argc != 8 && argc != 7)
{
fprintf (stderr, "Usage: testcelt <rate> <channels> <frame size> "
@ -121,8 +121,8 @@ int main(int argc, char *argv[])
opus_custom_encoder_ctl(enc,CELT_SET_COMPLEXITY(complexity));
}
in = (celt_int16*)malloc(frame_size*channels*sizeof(celt_int16));
out = (celt_int16*)malloc(frame_size*channels*sizeof(celt_int16));
in = (opus_int16*)malloc(frame_size*channels*sizeof(opus_int16));
out = (opus_int16*)malloc(frame_size*channels*sizeof(opus_int16));
while (!feof(fin))
{