Commit d77d6a58 authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

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

parent 3f0962cc
......@@ -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)
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 */
......@@ -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);
......
......@@ -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
......@@ -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;