Changed all the celt*int*_t types to remove the _t suffix, which is reserved

by POSIX. The other _t types that are not part of the API are still there
for now. Also, got rid of all that was left of the 64-bit types.
This commit is contained in:
Jean-Marc Valin 2009-10-17 14:35:13 -04:00
parent d35d677543
commit 30f7f813ea
37 changed files with 323 additions and 435 deletions

View file

@ -55,7 +55,7 @@ struct kiss_fft_state{
#ifdef DOUBLE_PRECISION
# define FRACBITS 31
# define SAMPPROD celt_int64_t
# define SAMPPROD long long
#define SAMP_MAX 2147483647
#ifdef MIXED_PRECISION
#define TWID_MAX 32767
@ -69,7 +69,7 @@ struct kiss_fft_state{
#else /* DOUBLE_PRECISION */
# define FRACBITS 15
# define SAMPPROD celt_int32_t
# define SAMPPROD celt_int32
#define SAMP_MAX 32767
#define TRIG_UPSCALE 1
#define EXT32(a) EXTEND32(a)

View file

@ -49,8 +49,8 @@
#endif
#define IMUL32(a,b) ((a)*(b))
#define UMUL32(a,b) ((celt_int32_t)(a)*(celt_int32_t)(b))
#define UMUL16_16(a,b) ((celt_int32_t)(a)*(celt_int32_t)(b))
#define UMUL32(a,b) ((celt_int32)(a)*(celt_int32)(b))
#define UMUL16_16(a,b) ((celt_int32)(a)*(celt_int32)(b))
#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */
#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */
@ -68,8 +68,8 @@
#ifdef FIXED_POINT
typedef celt_int16_t celt_word16_t;
typedef celt_int32_t celt_word32_t;
typedef celt_int16 celt_word16_t;
typedef celt_int32 celt_word32_t;
typedef celt_word32_t celt_sig_t;
typedef celt_word16_t celt_norm_t;

View file

@ -49,7 +49,7 @@
void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *bank, int _C)
{
int i, c, N;
const celt_int16_t *eBands = m->eBands;
const celt_int16 *eBands = m->eBands;
const int C = CHANNELS(_C);
N = FRAMESIZE(m);
for (c=0;c<C;c++)
@ -88,7 +88,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *
void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_norm_t * restrict X, const celt_ener_t *bank, int _C)
{
int i, c, N;
const celt_int16_t *eBands = m->eBands;
const celt_int16 *eBands = m->eBands;
const int C = CHANNELS(_C);
N = FRAMESIZE(m);
for (c=0;c<C;c++)
@ -112,7 +112,7 @@ void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_n
void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *bank, int _C)
{
int i, c, N;
const celt_int16_t *eBands = m->eBands;
const celt_int16 *eBands = m->eBands;
const int C = CHANNELS(_C);
N = FRAMESIZE(m);
for (c=0;c<C;c++)
@ -134,7 +134,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *
void compute_noise_energies(const CELTMode *m, const celt_sig_t *X, const celt_word16_t *tonality, celt_ener_t *bank, int _C)
{
int i, c, N;
const celt_int16_t *eBands = m->eBands;
const celt_int16 *eBands = m->eBands;
const int C = CHANNELS(_C);
N = FRAMESIZE(m);
for (c=0;c<C;c++)
@ -157,7 +157,7 @@ void compute_noise_energies(const CELTMode *m, const celt_sig_t *X, const celt_w
void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_norm_t * restrict X, const celt_ener_t *bank, int _C)
{
int i, c, N;
const celt_int16_t *eBands = m->eBands;
const celt_int16 *eBands = m->eBands;
const int C = CHANNELS(_C);
N = FRAMESIZE(m);
for (c=0;c<C;c++)
@ -177,7 +177,7 @@ void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_n
void renormalise_bands(const CELTMode *m, celt_norm_t * restrict X, int _C)
{
int i, c;
const celt_int16_t *eBands = m->eBands;
const celt_int16 *eBands = m->eBands;
const int C = CHANNELS(_C);
for (c=0;c<C;c++)
{
@ -191,7 +191,7 @@ void renormalise_bands(const CELTMode *m, celt_norm_t * restrict X, int _C)
void denormalise_bands(const CELTMode *m, const celt_norm_t * restrict X, celt_sig_t * restrict freq, const celt_ener_t *bank, int _C)
{
int i, c, N;
const celt_int16_t *eBands = m->eBands;
const celt_int16 *eBands = m->eBands;
const int C = CHANNELS(_C);
N = FRAMESIZE(m);
if (C>2)
@ -333,7 +333,7 @@ void apply_pitch(const CELTMode *m, celt_sig_t *X, const celt_sig_t *P, int gain
static void stereo_band_mix(const CELTMode *m, celt_norm_t *X, celt_norm_t *Y, const celt_ener_t *bank, int stereo_mode, int bandID, int dir)
{
int i = bandID;
const celt_int16_t *eBands = m->eBands;
const celt_int16 *eBands = m->eBands;
int j;
celt_word16_t a1, a2;
if (stereo_mode==0)
@ -372,7 +372,7 @@ int folding_decision(const CELTMode *m, celt_norm_t *X, celt_word16_t *average,
int NR=0;
celt_word32_t ratio = EPSILON;
const int C = CHANNELS(_C);
const celt_int16_t * restrict eBands = m->eBands;
const celt_int16 * restrict eBands = m->eBands;
N0 = FRAMESIZE(m);
@ -440,7 +440,7 @@ int folding_decision(const CELTMode *m, celt_norm_t *X, celt_word16_t *average,
void quant_bands(const CELTMode *m, celt_norm_t * restrict X, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, int encode, void *enc_dec)
{
int i, j, remaining_bits, balance;
const celt_int16_t * restrict eBands = m->eBands;
const celt_int16 * restrict eBands = m->eBands;
celt_norm_t * restrict norm;
VARDECL(celt_norm_t, _norm);
int B;
@ -457,7 +457,7 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, const celt_ener_t
int N;
int q;
celt_word16_t n;
const celt_int16_t * const *BPbits;
const celt_int16 * const *BPbits;
int curr_balance, curr_bits;
@ -510,7 +510,7 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, const celt_ener_t
void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_enc *enc)
{
int i, j, remaining_bits, balance;
const celt_int16_t * restrict eBands = m->eBands;
const celt_int16 * restrict eBands = m->eBands;
celt_norm_t * restrict norm;
VARDECL(celt_norm_t, _norm);
int B;
@ -528,7 +528,7 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *b
int tell;
int q1, q2;
celt_word16_t n;
const celt_int16_t * const *BPbits;
const celt_int16 * const *BPbits;
int b, qb;
int N;
int curr_balance, curr_bits;
@ -741,7 +741,7 @@ void quant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *b
void unquant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t *bandE, int *pulses, int shortBlocks, int fold, int total_bits, ec_dec *dec)
{
int i, j, remaining_bits, balance;
const celt_int16_t * restrict eBands = m->eBands;
const celt_int16 * restrict eBands = m->eBands;
celt_norm_t * restrict norm;
VARDECL(celt_norm_t, _norm);
int B;
@ -759,7 +759,7 @@ void unquant_bands_stereo(const CELTMode *m, celt_norm_t *_X, const celt_ener_t
int tell;
int q1, q2;
celt_word16_t n;
const celt_int16_t * const *BPbits;
const celt_int16 * const *BPbits;
int b, qb;
int N;
int curr_balance, curr_bits;

View file

@ -161,7 +161,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_t *w, *iw;
celt_int16 *w, *iw;
int i, c;
@ -175,13 +175,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_t));
state->itwiddle = celt_alloc(length*2*sizeof(celt_int16_t));
state->twiddle = celt_alloc(length*2*sizeof(celt_int16));
state->itwiddle = celt_alloc(length*2*sizeof(celt_int16));
gen_twiddle16((celt_int16_t *)state->twiddle, length, 32767.0);
gen_twiddle16((celt_int16 *)state->twiddle, length, 32767.0);
w = (celt_int16_t *)state->twiddle;
iw = (celt_int16_t *)state->itwiddle;
w = (celt_int16 *)state->twiddle;
iw = (celt_int16 *)state->itwiddle;
for (i = 0; i < length; i++) {
iw[2*i+0] = w[2*i+0];
@ -212,8 +212,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_t));
state->itwiddle = celt_alloc(length*2*sizeof(celt_int32_t));
state->twiddle = celt_alloc(length*2*sizeof(celt_int32));
state->itwiddle = celt_alloc(length*2*sizeof(celt_int32));
// Generate the inverse twiddle first because it does not need scaling
gen_twiddle32(state->itwiddle, length, 2147483647.000000000);
@ -243,22 +243,22 @@ void c64_fft32_free(c64_fft_t *state)
}
void c64_fft16_inplace(c64_fft_t * restrict state, celt_int16_t *X)
void c64_fft16_inplace(c64_fft_t * restrict state, celt_int16 *X)
{
int i;
VARDECL(celt_int16_t, cin);
VARDECL(celt_int16_t, cout);
VARDECL(celt_int16, cin);
VARDECL(celt_int16, cout);
SAVE_STACK;
ALLOC(cin, state->nfft*2, celt_int16_t);
ALLOC(cout, state->nfft*2, celt_int16_t);
ALLOC(cin, state->nfft*2, celt_int16);
ALLOC(cout, state->nfft*2, celt_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_t *)state->twiddle, state->nfft, cin, cout);
DSP_fft16x16t((celt_int16 *)state->twiddle, state->nfft, cin, cout);
for (i = 0; i < state->nfft; i++) {
X[2*i+0] = cout[2*i+0];
@ -270,12 +270,12 @@ void c64_fft16_inplace(c64_fft_t * restrict state, celt_int16_t *X)
void c64_fft32(c64_fft_t * restrict state, const celt_int32_t *X, celt_int32_t *Y)
void c64_fft32(c64_fft_t * restrict state, const celt_int32 *X, celt_int32 *Y)
{
int i;
VARDECL(celt_int32_t, cin);
VARDECL(celt_int32, cin);
SAVE_STACK;
ALLOC(cin, state->nfft*2, celt_int32_t);
ALLOC(cin, state->nfft*2, celt_int32);
for (i = 0; i < state->nfft; i++) {
cin[2*i+0] = X[2*i+0] >> state->shift;
@ -288,16 +288,16 @@ void c64_fft32(c64_fft_t * restrict state, const celt_int32_t *X, celt_int32_t *
}
void c64_ifft16(c64_fft_t * restrict state, const celt_int16_t *X, celt_int16_t *Y)
void c64_ifft16(c64_fft_t * restrict state, const celt_int16 *X, celt_int16 *Y)
{
int i;
VARDECL(celt_int16_t, cin);
VARDECL(celt_int16_t, cout);
VARDECL(celt_int16, cin);
VARDECL(celt_int16, cout);
SAVE_STACK;
ALLOC(cin, state->nfft*2, celt_int16_t);
if ((celt_int32_t)Y & 7)
ALLOC(cout, state->nfft*2, celt_int16_t);
ALLOC(cin, state->nfft*2, celt_int16);
if ((celt_int32)Y & 7)
ALLOC(cout, state->nfft*2, celt_int16);
else
cout = Y;
@ -308,9 +308,9 @@ void c64_ifft16(c64_fft_t * restrict state, const celt_int16_t *X, celt_int16_t
cin[2*i+1] = X[2*i+1];
}
DSP_fft16x16t((celt_int16_t *)state->itwiddle, state->nfft, cin, cout);
DSP_fft16x16t((celt_int16 *)state->itwiddle, state->nfft, cin, cout);
if ((celt_int32_t)Y & 7)
if ((celt_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];
@ -320,12 +320,12 @@ void c64_ifft16(c64_fft_t * restrict state, const celt_int16_t *X, celt_int16_t
}
void c64_ifft32(c64_fft_t * restrict state, const celt_int32_t *X, celt_int32_t *Y)
void c64_ifft32(c64_fft_t * restrict state, const celt_int32 *X, celt_int32 *Y)
{
int i;
VARDECL(celt_int32_t, cin);
VARDECL(celt_int32, cin);
SAVE_STACK;
ALLOC(cin, state->nfft*2, celt_int32_t);
ALLOC(cin, state->nfft*2, celt_int32);
celt_assert(Y & 7 == 0);

View file

@ -41,18 +41,18 @@
typedef struct {
int nfft;
int shift;
celt_int32_t *twiddle;
celt_int32_t *itwiddle;
celt_int32 *twiddle;
celt_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_t *X);
extern void c64_ifft16(c64_fft_t *state, const celt_int16_t *X, celt_int16_t *Y);
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 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_t *X, celt_int32_t *Y);
extern void c64_ifft32(c64_fft_t *state, const celt_int32_t *X, celt_int32_t *Y);
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);
#endif

View file

@ -74,7 +74,7 @@ static const float transientWindow[16] = {
@brief Encoder state
*/
struct CELTEncoder {
celt_uint32_t marker;
celt_uint32 marker;
const CELTMode *mode; /**< Mode used by the encoder */
int frame_size;
int block_size;
@ -237,12 +237,12 @@ void celt_encoder_destroy(CELTEncoder *st)
celt_free(st);
}
static inline celt_int16_t FLOAT2INT16(float x)
static inline celt_int16 FLOAT2INT16(float x)
{
x = x*CELT_SIG_SCALE;
x = MAX32(x, -32768);
x = MIN32(x, 32767);
return (celt_int16_t)float2int(x);
return (celt_int16)float2int(x);
}
static inline celt_word16_t SIG2WORD16(celt_sig_t x)
@ -517,7 +517,7 @@ static void mdct_shape(const CELTMode *mode, celt_norm_t *X, int start, int end,
#ifdef FIXED_POINT
int celt_encode(CELTEncoder * restrict st, const celt_int16_t * pcm, celt_int16_t * optional_synthesis, unsigned char *compressed, int nbCompressedBytes)
int celt_encode(CELTEncoder * restrict st, const celt_int16 * pcm, celt_int16 * optional_synthesis, unsigned char *compressed, int nbCompressedBytes)
{
#else
int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_sig_t * optional_synthesis, unsigned char *compressed, int nbCompressedBytes)
@ -630,7 +630,7 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
compute_mdcts(st->mode, shortBlocks, in, freq, C);
norm_rate = (nbCompressedBytes-5)*8*(celt_uint32_t)st->mode->Fs/(C*N)>>10;
norm_rate = (nbCompressedBytes-5)*8*(celt_uint32)st->mode->Fs/(C*N)>>10;
/* Pitch analysis: we do it early to save on the peak stack space */
/* Don't use pitch if there isn't enough data available yet,
or if we're using shortBlocks */
@ -834,7 +834,7 @@ int celt_encode_float(CELTEncoder * restrict st, const celt_sig_t * pcm, celt_si
int celt_encode_float(CELTEncoder * restrict st, const float * pcm, float * optional_synthesis, unsigned char *compressed, int nbCompressedBytes)
{
int j, ret, C, N;
VARDECL(celt_int16_t, in);
VARDECL(celt_int16, in);
SAVE_STACK;
if (check_encoder(st) != CELT_OK)
@ -848,7 +848,7 @@ int celt_encode_float(CELTEncoder * restrict st, const float * pcm, float * opti
C = CHANNELS(st->channels);
N = st->block_size;
ALLOC(in, C*N, celt_int16_t);
ALLOC(in, C*N, celt_int16);
for (j=0;j<C*N;j++)
in[j] = FLOAT2INT16(pcm[j]);
@ -866,7 +866,7 @@ int celt_encode_float(CELTEncoder * restrict st, const float * pcm, float * opti
}
#endif /*DISABLE_FLOAT_API*/
#else
int celt_encode(CELTEncoder * restrict st, const celt_int16_t * pcm, celt_int16_t * optional_synthesis, unsigned char *compressed, int nbCompressedBytes)
int celt_encode(CELTEncoder * restrict st, const celt_int16 * pcm, celt_int16 * optional_synthesis, unsigned char *compressed, int nbCompressedBytes)
{
int j, ret, C, N;
VARDECL(celt_sig_t, in);
@ -922,7 +922,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...)
break;
case CELT_SET_COMPLEXITY_REQUEST:
{
int value = va_arg(ap, celt_int32_t);
int value = va_arg(ap, celt_int32);
if (value<0 || value>10)
goto bad_arg;
if (value<=2) {
@ -937,7 +937,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...)
break;
case CELT_SET_PREDICTION_REQUEST:
{
int value = va_arg(ap, celt_int32_t);
int value = va_arg(ap, celt_int32);
if (value<0 || value>2)
goto bad_arg;
if (value==0)
@ -955,7 +955,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...)
break;
case CELT_SET_VBR_RATE_REQUEST:
{
celt_int32_t value = va_arg(ap, celt_int32_t);
celt_int32 value = va_arg(ap, celt_int32);
if (value<0)
goto bad_arg;
if (value>3072000)
@ -1016,7 +1016,7 @@ bad_request:
@brief Decoder state
*/
struct CELTDecoder {
celt_uint32_t marker;
celt_uint32 marker;
const CELTMode *mode;
int frame_size;
int block_size;
@ -1212,7 +1212,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16_t * restrict
#endif
#ifdef FIXED_POINT
int celt_decode(CELTDecoder * restrict st, const unsigned char *data, int len, celt_int16_t * restrict pcm)
int celt_decode(CELTDecoder * restrict st, const unsigned char *data, int len, celt_int16 * restrict pcm)
{
#else
int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int len, celt_sig_t * restrict pcm)
@ -1364,7 +1364,7 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int
int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int len, float * restrict pcm)
{
int j, ret, C, N;
VARDECL(celt_int16_t, out);
VARDECL(celt_int16, out);
SAVE_STACK;
if (check_decoder(st) != CELT_OK)
@ -1379,7 +1379,7 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int
C = CHANNELS(st->channels);
N = st->block_size;
ALLOC(out, C*N, celt_int16_t);
ALLOC(out, C*N, celt_int16);
ret=celt_decode(st, data, len, out);
for (j=0;j<C*N;j++)
pcm[j]=out[j]*(1/32768.);
@ -1389,7 +1389,7 @@ int celt_decode_float(CELTDecoder * restrict st, const unsigned char *data, int
}
#endif /*DISABLE_FLOAT_API*/
#else
int celt_decode(CELTDecoder * restrict st, const unsigned char *data, int len, celt_int16_t * restrict pcm)
int celt_decode(CELTDecoder * restrict st, const unsigned char *data, int len, celt_int16 * restrict pcm)
{
int j, ret, C, N;
VARDECL(celt_sig_t, out);

View file

@ -51,7 +51,7 @@ extern "C" {
#define EXPORT
#endif
#define _celt_check_int(x) (((void)((x) == (celt_int32_t)0)), (celt_int32_t)(x))
#define _celt_check_int(x) (((void)((x) == (celt_int32)0)), (celt_int32)(x))
#define _celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (CELTMode**)(ptr)))
/* Error codes */
@ -138,7 +138,7 @@ typedef struct CELTMode CELTMode;
@param error Returned error code (if NULL, no error will be returned)
@return A newly created mode
*/
EXPORT CELTMode *celt_mode_create(celt_int32_t Fs, int frame_size, int *error);
EXPORT CELTMode *celt_mode_create(celt_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.
@ -147,7 +147,7 @@ EXPORT CELTMode *celt_mode_create(celt_int32_t Fs, int frame_size, int *error);
EXPORT void celt_mode_destroy(CELTMode *mode);
/** Query information from a mode */
EXPORT int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value);
EXPORT int celt_mode_info(const CELTMode *mode, int request, celt_int32 *value);
/* Encoder stuff */
@ -208,7 +208,7 @@ EXPORT int celt_encode_float(CELTEncoder *st, const float *pcm, float *optional_
* the length returned be somehow transmitted to the decoder. Otherwise, no
* decoding is possible.
*/
EXPORT int celt_encode(CELTEncoder *st, const celt_int16_t *pcm, celt_int16_t *optional_synthesis, unsigned char *compressed, int nbCompressedBytes);
EXPORT int celt_encode(CELTEncoder *st, const celt_int16 *pcm, celt_int16 *optional_synthesis, unsigned char *compressed, int nbCompressedBytes);
/** Query and set encoder parameters
@param st Encoder state
@ -254,7 +254,7 @@ EXPORT int celt_decode_float(CELTDecoder *st, const unsigned char *data, int len
returned here in 16-bit PCM format (native endian).
@return Error code.
*/
EXPORT int celt_decode(CELTDecoder *st, const unsigned char *data, int len, celt_int16_t *pcm);
EXPORT int celt_decode(CELTDecoder *st, const unsigned char *data, int len, celt_int16 *pcm);
/** Query and set decoder parameters
@param st Decoder state

View file

@ -45,22 +45,22 @@ extern "C" {
typedef struct {
char codec_id[8]; /**< MUST be "CELT " (four spaces) */
char codec_version[20]; /**< Version used (as string) */
celt_int32_t version_id; /**< Version id (negative for until stream is frozen) */
celt_int32_t header_size; /**< Size of this header */
celt_int32_t sample_rate; /**< Sampling rate of the original audio */
celt_int32_t nb_channels; /**< Number of channels */
celt_int32_t frame_size; /**< Samples per frame (per channel) */
celt_int32_t overlap; /**< Overlapping samples (per channel) */
celt_int32_t bytes_per_packet; /**< Number of bytes per compressed packet (0 if unknown) */
celt_int32_t extra_headers; /**< Number of additional headers that follow this header */
celt_int32 version_id; /**< Version id (negative for until stream is frozen) */
celt_int32 header_size; /**< Size of this header */
celt_int32 sample_rate; /**< Sampling rate of the original audio */
celt_int32 nb_channels; /**< Number of channels */
celt_int32 frame_size; /**< Samples per frame (per channel) */
celt_int32 overlap; /**< Overlapping samples (per channel) */
celt_int32 bytes_per_packet; /**< Number of bytes per compressed packet (0 if unknown) */
celt_int32 extra_headers; /**< Number of additional headers that follow this header */
} CELTHeader;
/** Creates a basic header struct */
EXPORT int celt_header_init(CELTHeader *header, const CELTMode *m, int channels);
EXPORT int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32_t size);
EXPORT int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32 size);
EXPORT int celt_header_from_packet(const unsigned char *packet, celt_uint32_t size, CELTHeader *header);
EXPORT int celt_header_from_packet(const unsigned char *packet, celt_uint32 size, CELTHeader *header);
#ifdef __cplusplus
}

View file

@ -26,142 +26,114 @@
#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_t;
typedef uint16_t celt_uint16_t;
typedef int32_t celt_int32_t;
typedef uint32_t celt_uint32_t;
typedef int64_t celt_int64_t;
typedef uint64_t celt_uint64_t;
typedef int16_t celt_int16;
typedef uint16_t celt_uint16;
typedef int32_t celt_int32;
typedef uint32_t celt_uint32;
#elif defined(_WIN32)
# if defined(__CYGWIN__)
# include <_G_config.h>
typedef _G_int32_t celt_int32_t;
typedef _G_uint32_t celt_uint32_t;
typedef _G_int16_t celt_int16_t;
typedef _G_uint16_t celt_uint16_t;
typedef _G_int64_t celt_int64_t;
typedef _G_uint64_t celt_uint64_t;
typedef _G_int32_t celt_int32;
typedef _G_uint32_t celt_uint32;
typedef _G_int16 celt_int16;
typedef _G_uint16 celt_uint16;
# elif defined(__MINGW32__)
typedef short celt_int16_t;
typedef unsigned short celt_uint16_t;
typedef int celt_int32_t;
typedef unsigned int celt_uint32_t;
typedef long long celt_int64_t;
typedef unsigned long long celt_uint64_t;
typedef short celt_int16;
typedef unsigned short celt_uint16;
typedef int celt_int32;
typedef unsigned int celt_uint32;
# elif defined(__MWERKS__)
typedef int celt_int32_t;
typedef unsigned int celt_uint32_t;
typedef short celt_int16_t;
typedef unsigned short celt_uint16_t;
typedef long long celt_int64_t;
typedef unsigned long long celt_uint64_t;
typedef int celt_int32;
typedef unsigned int celt_uint32;
typedef short celt_int16;
typedef unsigned short celt_uint16;
# else
/* MSVC/Borland */
typedef __int32 celt_int32_t;
typedef unsigned __int32 celt_uint32_t;
typedef __int16 celt_int16_t;
typedef unsigned __int16 celt_uint16_t;
typedef __int64 celt_int64_t;
typedef unsigned __int64 celt_uint64_t;
typedef __int32 celt_int32;
typedef unsigned __int32 celt_uint32;
typedef __int16 celt_int16;
typedef unsigned __int16 celt_uint16;
# endif
#elif defined(__MACOS__)
# include <sys/types.h>
typedef SInt16 celt_int16_t;
typedef UInt16 celt_uint16_t;
typedef SInt32 celt_int32_t;
typedef UInt32 celt_uint32_t;
typedef SInt64 celt_int64_t;
typedef UInt64 celt_uint64_t;
typedef SInt16 celt_int16;
typedef UInt16 celt_uint16;
typedef SInt32 celt_int32;
typedef UInt32 celt_uint32;
#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
# include <sys/types.h>
typedef int16_t celt_int16_t;
typedef u_int16_t celt_uint16_t;
typedef int32_t celt_int32_t;
typedef u_int32_t celt_uint32_t;
typedef int64_t celt_int64_t;
typedef u_int64_t celt_uint64_t;
typedef int16 celt_int16;
typedef u_int16 celt_uint16;
typedef int32_t celt_int32;
typedef u_int32_t celt_uint32;
#elif defined(__BEOS__)
/* Be */
# include <inttypes.h>
typedef int16_t celt_int16_t;
typedef u_int16_t celt_uint16_t;
typedef int32_t celt_int32_t;
typedef u_int32_t celt_uint32_t;
typedef int64_t celt_int64_t;
typedef u_int64_t celt_uint64_t;
typedef int16 celt_int16;
typedef u_int16 celt_uint16;
typedef int32_t celt_int32;
typedef u_int32_t celt_uint32;
#elif defined (__EMX__)
/* OS/2 GCC */
typedef short celt_int16_t;
typedef unsigned short celt_uint16_t;
typedef int celt_int32_t;
typedef unsigned int celt_uint32_t;
typedef long long celt_int64_t;
typedef unsigned long long celt_uint64_t;
typedef short celt_int16;
typedef unsigned short celt_uint16;
typedef int celt_int32;
typedef unsigned int celt_uint32;
#elif defined (DJGPP)
/* DJGPP */
typedef short celt_int16_t;
typedef int celt_int32_t;
typedef unsigned int celt_uint32_t;
typedef long long celt_int64_t;
typedef unsigned long long celt_uint64_t;
typedef short celt_int16;
typedef unsigned short celt_uint16;
typedef int celt_int32;
typedef unsigned int celt_uint32;
#elif defined(R5900)
/* PS2 EE */
typedef int celt_int32_t;
typedef unsigned celt_uint32_t;
typedef short celt_int16_t;
typedef long celt_int64_t;
typedef unsigned long celt_uint64_t;
typedef int celt_int32;
typedef unsigned celt_uint32;
typedef short celt_int16;
typedef unsigned short celt_uint16;
#elif defined(__SYMBIAN32__)
/* Symbian GCC */
typedef signed short celt_int16_t;
typedef unsigned short celt_uint16_t;
typedef signed int celt_int32_t;
typedef unsigned int celt_uint32_t;
typedef long long int celt_int64_t;
typedef unsigned long long int celt_uint64_t;
typedef signed short celt_int16;
typedef unsigned short celt_uint16;
typedef signed int celt_int32;
typedef unsigned int celt_uint32;
#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)
typedef short celt_int16_t;
typedef unsigned short celt_uint16_t;
typedef long celt_int32_t;
typedef unsigned long celt_uint32_t;
typedef long long celt_int64_t;
typedef unsigned long long celt_uint64_t;
typedef short celt_int16;
typedef unsigned short celt_uint16;
typedef long celt_int32;
typedef unsigned long celt_uint32;
#elif defined(CONFIG_TI_C6X)
typedef short celt_int16_t;
typedef unsigned short celt_uint16_t;
typedef int celt_int32_t;
typedef unsigned int celt_uint32_t;
typedef long long int celt_int64_t;
typedef unsigned long long int celt_uint64_t;
typedef short celt_int16;
typedef unsigned short celt_uint16;
typedef int celt_int32;
typedef unsigned int celt_uint32;
#else
/* Give up, take a reasonable guess */
typedef short celt_int16_t;
typedef unsigned short celt_uint16_t;
typedef int celt_int32_t;
typedef unsigned int celt_uint32_t;
typedef long long celt_int64_t;
typedef unsigned long long celt_uint64_t;
typedef short celt_int16;
typedef unsigned short celt_uint16;
typedef int celt_int32;
typedef unsigned int celt_uint32;
#endif

View file

@ -74,7 +74,7 @@ int log2_frac(ec_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_t INV_TABLE[128]={
static const celt_uint32 INV_TABLE[128]={
0x00000001,0xAAAAAAAB,0xCCCCCCCD,0xB6DB6DB7,
0x38E38E39,0xBA2E8BA3,0xC4EC4EC5,0xEEEEEEEF,
0xF0F0F0F1,0x286BCA1B,0x3CF3CF3D,0xE9BD37A7,
@ -113,8 +113,8 @@ static const celt_uint32_t INV_TABLE[128]={
_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_t imusdiv32odd(celt_uint32_t _a,celt_uint32_t _b,
celt_uint32_t _c,int _d){
static inline celt_uint32 imusdiv32odd(celt_uint32 _a,celt_uint32 _b,
celt_uint32 _c,int _d){
return (_a*_b-_c)*INV_TABLE[_d]&MASK32;
}
@ -125,9 +125,9 @@ static inline celt_uint32_t imusdiv32odd(celt_uint32_t _a,celt_uint32_t _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_t imusdiv32even(celt_uint32_t _a,celt_uint32_t _b,
celt_uint32_t _c,int _d){
celt_uint32_t inv;
static inline celt_uint32 imusdiv32even(celt_uint32 _a,celt_uint32 _b,
celt_uint32 _c,int _d){
celt_uint32 inv;
int mask;
int shift;
int one;
@ -144,7 +144,7 @@ static inline celt_uint32_t imusdiv32even(celt_uint32_t _a,celt_uint32_t _b,
/*Compute floor(sqrt(_val)) with exact arithmetic.
This has been tested on all possible 32-bit inputs.*/
static unsigned isqrt32(celt_uint32_t _val){
static unsigned isqrt32(celt_uint32 _val){
unsigned b;
unsigned g;
int bshift;
@ -156,8 +156,8 @@ static unsigned isqrt32(celt_uint32_t _val){
bshift=EC_ILOG(_val)-1>>1;
b=1U<<bshift;
do{
celt_uint32_t t;
t=((celt_uint32_t)g<<1)+b<<bshift;
celt_uint32 t;
t=((celt_uint32)g<<1)+b<<bshift;
if(t<=_val){
g+=b;
_val-=t;
@ -169,39 +169,6 @@ static unsigned isqrt32(celt_uint32_t _val){
return g;
}
#if 0
/*Compute floor(sqrt(_val)) with exact arithmetic.
This has been tested on all possible 36-bit inputs.*/
static celt_uint32_t isqrt36(celt_uint64_t _val){
celt_uint32_t val32;
celt_uint32_t b;
celt_uint32_t g;
int bshift;
g=0;
b=0x20000;
for(bshift=18;bshift-->13;){
celt_uint64_t t;
t=((celt_uint64_t)g<<1)+b<<bshift;
if(t<=_val){
g+=b;
_val-=t;
}
b>>=1;
}
val32=(celt_uint32_t)_val;
for(;bshift>=0;bshift--){
celt_uint32_t t;
t=(g<<1)+b<<bshift;
if(t<=val32){
g+=b;
val32-=t;
}
b>>=1;
}
return g;
}
#endif
/*Although derived separately, the pulse vector coding scheme is equivalent to
a Pyramid Vector Quantizer \cite{Fis86}.
Some additional notes about an early version appear at
@ -325,10 +292,10 @@ static celt_uint32_t isqrt36(celt_uint64_t _val){
N and K are themselves limited to 15 bits.*/
int fits_in32(int _n, int _k)
{
static const celt_int16_t maxN[15] = {
static const celt_int16 maxN[15] = {
32767, 32767, 32767, 1476, 283, 109, 60, 40,
29, 24, 20, 18, 16, 14, 13};
static const celt_int16_t maxK[15] = {
static const celt_int16 maxK[15] = {
32767, 32767, 32767, 32767, 1172, 238, 95, 53,
36, 27, 22, 18, 16, 15, 13};
if (_n>=14)
@ -359,46 +326,46 @@ static inline unsigned ucwrs2(unsigned _k){
}
/*Compute V(2,_k).*/
static inline celt_uint32_t ncwrs2(int _k){
return _k?4*(celt_uint32_t)_k:1;
static inline celt_uint32 ncwrs2(int _k){
return _k?4*(celt_uint32)_k:1;
}
/*Compute U(3,_k).
Note that this may be called with _k=32768 (maxK[3]+1).*/
static inline celt_uint32_t ucwrs3(unsigned _k){
return _k?(2*(celt_uint32_t)_k-2)*_k+1:0;
static inline celt_uint32 ucwrs3(unsigned _k){
return _k?(2*(celt_uint32)_k-2)*_k+1:0;
}
/*Compute V(3,_k).*/
static inline celt_uint32_t ncwrs3(int _k){
return _k?2*(2*(unsigned)_k*(celt_uint32_t)_k+1):1;
static inline celt_uint32 ncwrs3(int _k){
return _k?2*(2*(unsigned)_k*(celt_uint32)_k+1):1;
}
/*Compute U(4,_k).*/
static inline celt_uint32_t ucwrs4(int _k){
return _k?imusdiv32odd(2*_k,(2*_k-3)*(celt_uint32_t)_k+4,3,1):0;
static inline celt_uint32 ucwrs4(int _k){
return _k?imusdiv32odd(2*_k,(2*_k-3)*(celt_uint32)_k+4,3,1):0;
}
/*Compute V(4,_k).*/
static inline celt_uint32_t ncwrs4(int _k){
return _k?((_k*(celt_uint32_t)_k+2)*_k)/3<<3:1;
static inline celt_uint32 ncwrs4(int _k){
return _k?((_k*(celt_uint32)_k+2)*_k)/3<<3:1;
}
/*Compute U(5,_k).*/
static inline celt_uint32_t ucwrs5(int _k){
return _k?(((((_k-2)*(unsigned)_k+5)*(celt_uint32_t)_k-4)*_k)/3<<1)+1:0;
static inline celt_uint32 ucwrs5(int _k){
return _k?(((((_k-2)*(unsigned)_k+5)*(celt_uint32)_k-4)*_k)/3<<1)+1:0;
}
/*Compute V(5,_k).*/
static inline celt_uint32_t ncwrs5(int _k){
return _k?(((_k*(unsigned)_k+5)*(celt_uint32_t)_k*_k)/3<<2)+2:1;
static inline celt_uint32 ncwrs5(int _k){
return _k?(((_k*(unsigned)_k+5)*(celt_uint32)_k*_k)/3<<2)+2:1;
}
/*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_t *_ui,unsigned _len,celt_uint32_t _ui0){
celt_uint32_t ui1;
static inline void unext(celt_uint32 *_ui,unsigned _len,celt_uint32 _ui0){
celt_uint32 ui1;
unsigned j;
/*This do-while will overrun the array if we don't have storage for at least
2 values.*/
@ -413,8 +380,8 @@ static inline void unext(celt_uint32_t *_ui,unsigned _len,celt_uint32_t _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_t *_ui,unsigned _n,celt_uint32_t _ui0){
celt_uint32_t ui1;
static inline void uprev(celt_uint32 *_ui,unsigned _n,celt_uint32 _ui0){
celt_uint32 ui1;
unsigned j;
/*This do-while will overrun the array if we don't have storage for at least
2 values.*/
@ -428,8 +395,8 @@ static inline void uprev(celt_uint32_t *_ui,unsigned _n,celt_uint32_t _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_t ncwrs_urow(unsigned _n,unsigned _k,celt_uint32_t *_u){
celt_uint32_t um2;
static celt_uint32 ncwrs_urow(unsigned _n,unsigned _k,celt_uint32 *_u){
celt_uint32 um2;
unsigned len;
unsigned k;
len=_k+2;
@ -449,8 +416,8 @@ static celt_uint32_t ncwrs_urow(unsigned _n,unsigned _k,celt_uint32_t *_u){
for(k=2;k<_n;k++)unext(_u+1,_k+1,1);
}
else{
celt_uint32_t um1;
celt_uint32_t n2m1;
celt_uint32 um1;
celt_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)*/
@ -466,7 +433,7 @@ static celt_uint32_t ncwrs_urow(unsigned _n,unsigned _k,celt_uint32_t *_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_t _i,int *_y){
static inline void cwrsi1(int _k,celt_uint32 _i,int *_y){
int s;
s=-(int)_i;
_y[0]=_k+s^s;
@ -475,8 +442,8 @@ static inline void cwrsi1(int _k,celt_uint32_t _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_t _i,int *_y){
celt_uint32_t p;
static inline void cwrsi2(int _k,celt_uint32 _i,int *_y){
celt_uint32 p;
int s;
int yj;
p=ucwrs2(_k+1U);
@ -494,8 +461,8 @@ static inline void cwrsi2(int _k,celt_uint32_t _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_t _i,int *_y){
celt_uint32_t p;
static void cwrsi3(int _k,celt_uint32 _i,int *_y){
celt_uint32 p;
int s;
int yj;
p=ucwrs3(_k+1U);
@ -515,8 +482,8 @@ static void cwrsi3(int _k,celt_uint32_t _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_t _i,int *_y){
celt_uint32_t p;
static void cwrsi4(int _k,celt_uint32 _i,int *_y){
celt_uint32 p;
int s;
int yj;
int kl;
@ -549,21 +516,14 @@ static void cwrsi4(int _k,celt_uint32_t _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_t _i,int *_y){
celt_uint32_t p;
static void cwrsi5(int _k,celt_uint32 _i,int *_y){
celt_uint32 p;
int s;
int yj;
p=ucwrs5(_k+1);
s=-(_i>=p);
_i-=p&s;
yj=_k;
#if 0
/*Finds the maximum _k such that ucwrs5(_k)<=_i (tested for all
_i<2157192969=U(5,239)).*/
if(_i>=0x2AAAAAA9UL)_k=isqrt32(2*isqrt36(10+6*(celt_uint64_t)_i)-7)+1>>1;
else _k=_i>0?isqrt32(2*(celt_uint32_t)isqrt32(10+6*_i)-7)+1>>1:0;
p=ucwrs5(_k);
#else
/* A binary search on U(5,K) avoids the need for 64-bit arithmetic */
{
int kl=0;
@ -579,7 +539,6 @@ static void cwrsi5(int _k,celt_uint32_t _i,int *_y){
else break;
}
}
#endif
_i-=p;
yj-=_k;
_y[0]=yj+s^s;
@ -591,12 +550,12 @@ static void cwrsi5(int _k,celt_uint32_t _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_t _i,int *_y,celt_uint32_t *_u){
static void cwrsi(int _n,int _k,celt_uint32 _i,int *_y,celt_uint32 *_u){
int j;
celt_assert(_n>0);
j=0;
do{
celt_uint32_t p;
celt_uint32 p;
int s;
int yj;
p=_u[_k+1];
@ -618,7 +577,7 @@ static void cwrsi(int _n,int _k,celt_uint32_t _i,int *_y,celt_uint32_t *_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_t icwrs1(const int *_y,int *_k){
static inline celt_uint32 icwrs1(const int *_y,int *_k){
*_k=abs(_y[0]);
return _y[0]<0;
}
@ -627,8 +586,8 @@ static inline celt_uint32_t 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_t icwrs2(const int *_y,int *_k){
celt_uint32_t i;
static inline celt_uint32 icwrs2(const int *_y,int *_k){
celt_uint32 i;
int k;
i=icwrs1(_y+1,&k);
i+=ucwrs2(k);
@ -642,8 +601,8 @@ static inline celt_uint32_t 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_t icwrs3(const int *_y,int *_k){
celt_uint32_t i;
static inline celt_uint32 icwrs3(const int *_y,int *_k){
celt_uint32 i;
int k;
i=icwrs2(_y+1,&k);
i+=ucwrs3(k);
@ -657,8 +616,8 @@ static inline celt_uint32_t 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_t icwrs4(const int *_y,int *_k){
celt_uint32_t i;
static inline celt_uint32 icwrs4(const int *_y,int *_k){
celt_uint32 i;
int k;
i=icwrs3(_y+1,&k);
i+=ucwrs4(k);
@ -672,8 +631,8 @@ static inline celt_uint32_t 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_t icwrs5(const int *_y,int *_k){
celt_uint32_t i;
static inline celt_uint32 icwrs5(const int *_y,int *_k){
celt_uint32 i;
int k;
i=icwrs4(_y+1,&k);
i+=ucwrs5(k);
@ -687,9 +646,9 @@ static inline celt_uint32_t 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_t icwrs(int _n,int _k,celt_uint32_t *_nc,const int *_y,
celt_uint32_t *_u){
celt_uint32_t i;
celt_uint32 icwrs(int _n,int _k,celt_uint32 *_nc,const int *_y,
celt_uint32 *_u){
celt_uint32 i;
int j;
int k;
/*We can't unroll the first two iterations of the loop unless _n>=2.*/
@ -716,8 +675,8 @@ celt_uint32_t icwrs(int _n,int _k,celt_uint32_t *_nc,const int *_y,
_left_bits and _right_bits must contain the required bits for the left and
right sides of the split, respectively (which themselves may require
splitting).*/
static void get_required_split_bits(celt_int16_t *_bits,
const celt_int16_t *_left_bits,const celt_int16_t *_right_bits,
static void get_required_split_bits(celt_int16 *_bits,
const celt_int16 *_left_bits,const celt_int16 *_right_bits,
int _n,int _maxk,int _frac){
int k;
for(k=_maxk;k-->0;){
@ -748,9 +707,9 @@ static void get_required_split_bits(celt_int16_t *_bits,
_n1 and _n2 must either be equal or two consecutive integers.
Returns the buffer used to store the required bits for _n2, which is either
_bits1 if _n1==_n2 or _bits2 if _n1+1==_n2.*/
static celt_int16_t *get_required_bits_pair(celt_int16_t *_bits1,
celt_int16_t *_bits2,celt_int16_t *_tmp,int _n1,int _n2,int _maxk,int _frac){
celt_int16_t *tmp2;
static celt_int16 *get_required_bits_pair(celt_int16 *_bits1,
celt_int16 *_bits2,celt_int16 *_tmp,int _n1,int _n2,int _maxk,int _frac){
celt_int16 *tmp2;
/*If we only need a single set of required bits...*/
if(_n1==_n2){
/*Stop recursing if everything fits.*/
@ -796,28 +755,28 @@ static celt_int16_t *get_required_bits_pair(celt_int16_t *_bits1,
return _bits2;
}
void get_required_bits(celt_int16_t *_bits,int _n,int _maxk,int _frac){
void get_required_bits(celt_int16 *_bits,int _n,int _maxk,int _frac){
int k;
/*_maxk==0 => there's nothing to do.*/
celt_assert(_maxk>0);
if(fits_in32(_n,_maxk-1)){
_bits[0]=0;
if(_maxk>1){
VARDECL(celt_uint32_t,u);
VARDECL(celt_uint32,u);
SAVE_STACK;
ALLOC(u,_maxk+1U,celt_uint32_t);
ALLOC(u,_maxk+1U,celt_uint32);
ncwrs_urow(_n,_maxk-1,u);
for(k=1;k<_maxk;k++)_bits[k]=log2_frac(u[k]+u[k+1],_frac);
RESTORE_STACK;
}
}
else{
VARDECL(celt_int16_t,n1bits);
VARDECL(celt_int16_t,n2bits_buf);
celt_int16_t *n2bits;
VARDECL(celt_int16,n1bits);
VARDECL(celt_int16,n2bits_buf);
celt_int16 *n2bits;
SAVE_STACK;
ALLOC(n1bits,_maxk,celt_int16_t);
ALLOC(n2bits_buf,_maxk,celt_int16_t);
ALLOC(n1bits,_maxk,celt_int16);
ALLOC(n2bits_buf,_maxk,celt_int16);
n2bits=get_required_bits_pair(n1bits,n2bits_buf,_bits,
_n>>1,_n+1>>1,_maxk,_frac);
get_required_split_bits(_bits,n1bits,n2bits,_n,_maxk,_frac);
@ -827,7 +786,7 @@ void get_required_bits(celt_int16_t *_bits,int _n,int _maxk,int _frac){
static inline void encode_pulses32(int _n,int _k,const int *_y,ec_enc *_enc){
celt_uint32_t i;
celt_uint32 i;
switch(_n){
case 1:{
i=icwrs1(_y,&_k);
@ -851,10 +810,10 @@ static inline void encode_pulses32(int _n,int _k,const int *_y,ec_enc *_enc){
ec_enc_uint(_enc,i,ncwrs5(_k));
}break;
default:{
VARDECL(celt_uint32_t,u);
celt_uint32_t nc;
VARDECL(celt_uint32,u);
celt_uint32 nc;
SAVE_STACK;
ALLOC(u,_k+2U,celt_uint32_t);
ALLOC(u,_k+2U,celt_uint32);
i=icwrs(_n,_k,&nc,_y,u);
ec_enc_uint(_enc,i,nc);
RESTORE_STACK;
@ -892,9 +851,9 @@ static inline void decode_pulses32(int _n,int _k,int *_y,ec_dec *_dec){
case 4:cwrsi4(_k,ec_dec_uint(_dec,ncwrs4(_k)),_y);break;
case 5:cwrsi5(_k,ec_dec_uint(_dec,ncwrs5(_k)),_y);break;
default:{
VARDECL(celt_uint32_t,u);
VARDECL(celt_uint32,u);
SAVE_STACK;
ALLOC(u,_k+2U,celt_uint32_t);
ALLOC(u,_k+2U,celt_uint32);
cwrsi(_n,_k,ec_dec_uint(_dec,ncwrs_urow(_n,_k,u)),_y,u);
RESTORE_STACK;
}

View file

@ -41,7 +41,7 @@ int log2_frac(ec_uint32 val, int frac);
/* Whether the CWRS codebook will fit into 32 bits */
int fits_in32(int _n, int _m);
void get_required_bits(celt_int16_t *bits, int N, int K, int frac);
void get_required_bits(celt_int16 *bits, int N, int K, int frac);
void encode_pulses(int *_y, int N, int K, ec_enc *enc);

View file

@ -65,7 +65,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
CELTMode *mode = modes[i];
fprintf(file, "#ifndef DEF_EBANDS%d_%d\n", mode->Fs, mode->mdctSize);
fprintf(file, "#define DEF_EBANDS%d_%d\n", mode->Fs, mode->mdctSize);
fprintf (file, "static const celt_int16_t eBands%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands+2);
fprintf (file, "static const celt_int16 eBands%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands+2);
for (j=0;j<mode->nbEBands+2;j++)
fprintf (file, "%d, ", mode->eBands[j]);
fprintf (file, "};\n");
@ -94,7 +94,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
fprintf(file, "#ifndef DEF_ALLOC_VECTORS%d_%d\n", mode->Fs, mode->mdctSize);
fprintf(file, "#define DEF_ALLOC_VECTORS%d_%d\n", mode->Fs, mode->mdctSize);
fprintf (file, "static const celt_int16_t allocVectors%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands*mode->nbAllocVectors);
fprintf (file, "static const celt_int16 allocVectors%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands*mode->nbAllocVectors);
for (j=0;j<mode->nbAllocVectors;j++)
{
int k;
@ -113,7 +113,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
int k;
if (j==0 || (mode->bits[j] != mode->bits[j-1]))
{
fprintf (file, "static const celt_int16_t allocCache_band%d_%d_%d[MAX_PULSES] = {\n", j, mode->Fs, mode->mdctSize);
fprintf (file, "static const celt_int16 allocCache_band%d_%d_%d[MAX_PULSES] = {\n", j, mode->Fs, mode->mdctSize);
for (k=0;k<MAX_PULSES;k++)
fprintf (file, "%2d, ", mode->bits[j][k]);
fprintf (file, "};\n");
@ -121,7 +121,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes)
fprintf (file, "#define allocCache_band%d_%d_%d allocCache_band%d_%d_%d\n", j, mode->Fs, mode->mdctSize, j-1, mode->Fs, mode->mdctSize);
}
}
fprintf (file, "static const celt_int16_t *allocCache%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands);
fprintf (file, "static const celt_int16 *allocCache%d_%d[%d] = {\n", mode->Fs, mode->mdctSize, mode->nbEBands);
for (j=0;j<mode->nbEBands;j++)
{
fprintf (file, "allocCache_band%d_%d_%d, ", j, mode->Fs, mode->mdctSize);

View file

@ -38,9 +38,8 @@
typedef celt_int32_t ec_int32;
typedef celt_uint32_t ec_uint32;
typedef celt_uint64_t ec_uint64;
typedef celt_int32 ec_int32;
typedef celt_uint32 ec_uint32;
typedef struct ec_byte_buffer ec_byte_buffer;
@ -94,6 +93,5 @@ static inline unsigned char *ec_byte_get_buffer(ec_byte_buffer *_b){
}
int ec_ilog(ec_uint32 _v);
int ec_ilog64(ec_uint64 _v);
#endif

View file

@ -103,13 +103,6 @@ void ec_dec_update(ec_dec *_this,unsigned _fl,unsigned _fh,
This must be at least one, and no more than 32.
Return: The decoded bits.*/
ec_uint32 ec_dec_bits(ec_dec *_this,int _ftb);
/*Extracts a sequence of raw bits from the stream.
The bits must have been encoded with ec_enc_bits64().
No call to ec_dec_update() is necessary after this call.
_ftb: The number of bits to extract.
This must be at least one, and no more than 64.
Return: The decoded bits.*/
ec_uint64 ec_dec_bits64(ec_dec *_this,int _ftb);
/*Extracts a raw unsigned integer with a non-power-of-2 range from the stream.
The bits must have been encoded with ec_enc_uint().
No call to ec_dec_update() is necessary after this call.
@ -117,13 +110,6 @@ ec_uint64 ec_dec_bits64(ec_dec *_this,int _ftb);
This must be at least one, and no more than 2**32-1.
Return: The decoded bits.*/
ec_uint32 ec_dec_uint(ec_dec *_this,ec_uint32 _ft);
/*Extracts a raw unsigned integer with a non-power-of-2 range from the stream.
The bits must have been encoded with ec_enc_uint64().
No call to ec_dec_update() is necessary after this call.
_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**64-1.
Return: The decoded bits.*/
ec_uint64 ec_dec_uint64(ec_dec *_this,ec_uint64 _ft);
/*Returns the number of bits "used" by the decoded symbols so far.
The actual number of bits may be larger, due to rounding to whole bytes, or

View file

@ -85,21 +85,11 @@ void ec_encode_raw(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned bits);
_ftb: The number of bits to encode.
This must be at least one, and no more than 32.*/
void ec_enc_bits(ec_enc *_this,ec_uint32 _fl,int _ftb);
/*Encodes a sequence of raw bits in the stream.
_fl: The bits to encode.
_ftb: The number of bits to encode.
This must be at least one, and no more than 64.*/
void ec_enc_bits64(ec_enc *_this,ec_uint64 _fl,int _ftb);
/*Encodes a raw unsigned integer in the stream.
_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,ec_uint32 _fl,ec_uint32 _ft);
/*Encodes a raw unsigned integer in the stream.
_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**64-1.*/
void ec_enc_uint64(ec_enc *_this,ec_uint64 _fl,ec_uint64 _ft);
/*Returns the number of bits "used" by the encoded symbols so far.
The actual number of bits may be larger, due to rounding to whole bytes, or

View file

@ -45,7 +45,7 @@ extern long long celt_mips;
#define MIPS_INC celt_mips++,
#define MULT16_16SU(a,b) ((celt_word32_t)(celt_word16_t)(a)*(celt_word32_t)(celt_uint16_t)(b))
#define MULT16_16SU(a,b) ((celt_word32_t)(celt_word16_t)(a)*(celt_word32_t)(celt_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

@ -36,7 +36,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_t)(celt_word16_t)(a)*(celt_word32_t)(celt_uint16_t)(b))
#define MULT16_16SU(a,b) ((celt_word32_t)(celt_word16_t)(a)*(celt_word32_t)(celt_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

@ -37,22 +37,10 @@
#include "os_support.h"
#include "modes.h"
/*typedef struct {
char codec_id[8];
char codec_version[20];
celt_int32_t version_id;
celt_int32_t header_size;
celt_int32_t mode;
celt_int32_t sample_rate;
celt_int32_t nb_channels;
celt_int32_t bytes_per_packet;
celt_int32_t extra_headers;
} CELTHeader;*/
static celt_uint32_t
_le_32 (celt_uint32_t i)
static celt_uint32
_le_32 (celt_uint32 i)
{
celt_uint32_t ret=i;
celt_uint32 ret=i;
#if !defined(__LITTLE_ENDIAN__) && ( defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__) )
ret = (i>>24);
ret += (i>>8) & 0x0000ff00;
@ -84,9 +72,9 @@ int celt_header_init(CELTHeader *header, const CELTMode *m, int channels)
return CELT_OK;
}
int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32_t size)
int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_uint32 size)
{
celt_int32_t * h;
celt_int32 * h;
if ((size < 56) || (header==NULL) || (packet==NULL))
return CELT_BAD_ARG; /* FAIL */
@ -98,7 +86,7 @@ int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_
CELT_COPY(packet, (unsigned char*)header, 28);
/* Copy the int32 fields */
h = (celt_int32_t*)(packet+28);
h = (celt_int32*)(packet+28);
*h++ = _le_32 (header->version_id);
*h++ = _le_32 (header->header_size);
*h++ = _le_32 (header->sample_rate);
@ -111,9 +99,9 @@ int celt_header_to_packet(const CELTHeader *header, unsigned char *packet, celt_
return sizeof(*header);
}
int celt_header_from_packet(const unsigned char *packet, celt_uint32_t size, CELTHeader *header)
int celt_header_from_packet(const unsigned char *packet, celt_uint32 size, CELTHeader *header)
{
celt_int32_t * h;
celt_int32 * h;
if ((size < 56) || (header==NULL) || (packet==NULL))
return CELT_BAD_ARG; /* FAIL */
@ -125,7 +113,7 @@ int celt_header_from_packet(const unsigned char *packet, celt_uint32_t size, CEL
CELT_COPY((unsigned char*)header, packet, 28);
/* Copy the int32 fields */
h = (celt_int32_t*)(packet+28);
h = (celt_int32*)(packet+28);
header->version_id = _le_32(*h++);
header->header_size = _le_32(*h++);
header->sample_rate = _le_32(*h++);

View file

@ -61,8 +61,8 @@
#define cpx32_fft_alloc(length) (kiss_fft_cfg)(c64_fft32_alloc(length, 0, 0))
#define cpx32_fft_free(state) c64_fft32_free((c64_fft_t *)state)
#define cpx32_fft(state, X, Y, nx) c64_fft32 ((c64_fft_t *)state, (const celt_int32_t *)(X), (celt_int32_t *)(Y))
#define cpx32_ifft(state, X, Y, nx) c64_ifft32((c64_fft_t *)state, (const celt_int32_t *)(X), (celt_int32_t *)(Y))
#define cpx32_fft(state, X, Y, nx) c64_fft32 ((c64_fft_t *)state, (const celt_int32 *)(X), (celt_int32 *)(Y))
#define cpx32_ifft(state, X, Y, nx) c64_ifft32((c64_fft_t *)state, (const celt_int32 *)(X), (celt_int32 *)(Y))
#else /* ENABLE_TI_DSPLIB55/64 */

View file

@ -597,7 +597,7 @@ void kf_factor(int n,int * facbuf)
case 2: p = 3; break;
default: p += 2; break;
}
if (p>32000 || (celt_int32_t)p*(celt_int32_t)p > n)
if (p>32000 || (celt_int32)p*(celt_int32)p > n)
p = n; /* no more factors, skip to end */
}
n /= p;

View file

@ -52,12 +52,12 @@ extern "C" {
#ifdef FIXED_POINT
#include "arch.h"
#ifdef DOUBLE_PRECISION
# define kiss_fft_scalar celt_int32_t
# define kiss_twiddle_scalar celt_int32_t
# define kiss_fft_scalar celt_int32
# define kiss_twiddle_scalar celt_int32
# define KF_SUFFIX _celt_double
#else
# define kiss_fft_scalar celt_int16_t
# define kiss_twiddle_scalar celt_int16_t
# define kiss_fft_scalar celt_int16
# define kiss_twiddle_scalar celt_int16
# define KF_SUFFIX _celt_single
#endif
#else

View file

@ -41,7 +41,7 @@
#ifndef OVERRIDE_CELT_ILOG2
/** Integer log in base2. Undefined for zero and negative numbers */
static inline celt_int16_t celt_ilog2(celt_word32_t x)
static inline celt_int16 celt_ilog2(celt_word32_t x)
{
celt_assert2(x>0, "celt_ilog2() only defined for strictly positive numbers");
return EC_ILOG(x)-1;
@ -82,12 +82,12 @@ static inline int find_max32(celt_word32_t *x, int len)
}
#endif
#define FRAC_MUL16(a,b) ((16384+((celt_int32_t)(celt_int16_t)(a)*(celt_int16_t)(b)))>>15)
static inline celt_int16_t bitexact_cos(celt_int16_t x)
#define FRAC_MUL16(a,b) ((16384+((celt_int32)(celt_int16)(a)*(celt_int16)(b)))>>15)
static inline celt_int16 bitexact_cos(celt_int16 x)
{
celt_int32_t tmp;
celt_int16_t x2;
tmp = (4096+((celt_int32_t)(x)*(x)))>>13;
celt_int32 tmp;
celt_int16 x2;
tmp = (4096+((celt_int32)(x)*(x)))>>13;
if (tmp > 32767)
tmp = 32767;
x2 = tmp;
@ -122,7 +122,7 @@ static inline float celt_log2(float x)
float frac;
union {
float f;
celt_uint32_t i;
celt_uint32 i;
} in;
in.f = x;
integer = (in.i>>23)-127;
@ -140,7 +140,7 @@ static inline float celt_exp2(float x)
float frac;
union {
float f;
celt_uint32_t i;
celt_uint32 i;
} res;
integer = floor(x);
if (integer < -50)
@ -177,7 +177,7 @@ static inline celt_word16_t celt_maxabs16(celt_word16_t *x, int len)
#endif
/** Integer log in base2. Defined for zero, but not for negative numbers */
static inline celt_int16_t celt_zlog2(celt_word32_t x)
static inline celt_int16 celt_zlog2(celt_word32_t x)
{
return x <= 0 ? 0 : celt_ilog2(x);
}

View file

@ -53,7 +53,7 @@
#endif
int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value)
int celt_mode_info(const CELTMode *mode, int request, celt_int32 *value)
{
if (check_mode(mode) != CELT_OK)
return CELT_INVALID_MODE;
@ -82,7 +82,7 @@ int celt_mode_info(const CELTMode *mode, int request, celt_int32_t *value)
/* 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_t bark_freq[BARK_BANDS+1] = {
static const celt_int16 bark_freq[BARK_BANDS+1] = {
0, 100, 200, 300, 400,
510, 630, 770, 920, 1080,
1270, 1480, 1720, 2000, 2320,
@ -115,10 +115,10 @@ static const int band_allocation[BARK_BANDS*BITALLOC_SIZE] =
};
#endif
static celt_int16_t *compute_ebands(celt_int32_t Fs, int frame_size, int nbShortMdcts, int *nbEBands)
static celt_int16 *compute_ebands(celt_int32 Fs, int frame_size, int nbShortMdcts, int *nbEBands)
{
int min_bins = 3;
celt_int16_t *eBands;
celt_int16 *eBands;
int i, res, min_width, lin, low, high, nBark, offset=0;
/*if (min_bins < nbShortMdcts)
@ -139,7 +139,7 @@ static celt_int16_t *compute_ebands(celt_int32_t Fs, int frame_size, int nbShort
low = ((bark_freq[lin]/res)+(min_bins-1))/min_bins;
high = nBark-lin;
*nbEBands = low+high;
eBands = celt_alloc(sizeof(celt_int16_t)*(*nbEBands+2));
eBands = celt_alloc(sizeof(celt_int16)*(*nbEBands+2));
if (eBands==NULL)
return NULL;
@ -180,7 +180,7 @@ static celt_int16_t *compute_ebands(celt_int32_t Fs, int frame_size, int nbShort
static void compute_allocation_table(CELTMode *mode, int res)
{
int i, j, nBark;
celt_int16_t *allocVectors;
celt_int16 *allocVectors;
/* Find the number of critical bands supported by our sampling rate */
for (nBark=1;nBark<BARK_BANDS;nBark++)
@ -188,18 +188,18 @@ static void compute_allocation_table(CELTMode *mode, int res)
break;
mode->nbAllocVectors = BITALLOC_SIZE;
allocVectors = celt_alloc(sizeof(celt_int16_t)*(BITALLOC_SIZE*mode->nbEBands));
allocVectors = celt_alloc(sizeof(celt_int16)*(BITALLOC_SIZE*mode->nbEBands));
if (allocVectors==NULL)
return;
/* Compute per-codec-band allocation from per-critical-band matrix */
for (i=0;i<BITALLOC_SIZE;i++)
{
celt_int32_t current = 0;
celt_int32 current = 0;
int eband = 0;
for (j=0;j<nBark;j++)
{
int edge, low;
celt_int32_t alloc;
celt_int32 alloc;
edge = mode->eBands[eband+1]*res;
alloc = mode->mdctSize*band_allocation[i*BARK_BANDS+j];
if (edge < bark_freq[j+1])
@ -223,7 +223,7 @@ static void compute_allocation_table(CELTMode *mode, int res)
#endif /* STATIC_MODES */
CELTMode *celt_mode_create(celt_int32_t Fs, int frame_size, int *error)
CELTMode *celt_mode_create(celt_int32 Fs, int frame_size, int *error)
{
int i;
#ifdef STDIN_TUNING
@ -336,7 +336,7 @@ CELTMode *celt_mode_create(celt_int32_t Fs, int frame_size, int *error)
if (mode->eBands==NULL)
goto failure;
mode->pitchEnd = 4000*(celt_int32_t)frame_size/Fs;
mode->pitchEnd = 4000*(celt_int32)frame_size/Fs;
/* Overlap must be divisible by 4 */
if (mode->nbShortMdcts > 1)
@ -361,7 +361,7 @@ CELTMode *celt_mode_create(celt_int32_t Fs, int frame_size, int *error)
#endif
mode->window = window;
mode->bits = (const celt_int16_t **)compute_alloc_cache(mode, 1);
mode->bits = (const celt_int16 **)compute_alloc_cache(mode, 1);
if (mode->bits==NULL)
goto failure;
@ -413,7 +413,7 @@ failure:
void celt_mode_destroy(CELTMode *mode)
{
int i;
const celt_int16_t *prevPtr = NULL;
const celt_int16 *prevPtr = NULL;
if (mode == NULL)
{
celt_warning("NULL passed to celt_mode_destroy");

View file

@ -77,22 +77,22 @@
@brief Mode definition
*/
struct CELTMode {
celt_uint32_t marker_start;
celt_int32_t Fs;
celt_uint32 marker_start;
celt_int32 Fs;
int overlap;
int mdctSize;
int nbEBands;
int pitchEnd;
const celt_int16_t *eBands; /**< Definition for each "pseudo-critical band" */
const celt_int16 *eBands; /**< Definition for each "pseudo-critical band" */
celt_word16_t ePredCoef;/**< Prediction coefficient for the energy encoding */
int nbAllocVectors; /**< Number of lines in the matrix below */
const celt_int16_t *allocVectors; /**< Number of bits in each band for several rates */
const celt_int16 *allocVectors; /**< Number of bits in each band for several rates */
const celt_int16_t * const *bits; /**< Cache for pulses->bits mapping in each band */
const celt_int16 * const *bits; /**< Cache for pulses->bits mapping in each band */
/* Stuff that could go in the {en,de}coder, but we save space this way */
mdct_lookup mdct;
@ -108,7 +108,7 @@ struct CELTMode {
struct PsyDecay psy;
int *prob;
celt_uint32_t marker_end;
celt_uint32 marker_end;
};
int check_mode(const CELTMode *mode);

View file

@ -49,7 +49,7 @@
recursive filter. The filter coefficient is frequency dependent and
chosen such that we have a -10dB/Bark slope on the right side and a -25dB/Bark
slope on the left side. */
void psydecay_init(struct PsyDecay *decay, int len, celt_int32_t Fs)
void psydecay_init(struct PsyDecay *decay, int len, celt_int32 Fs)
{
int i;
celt_word16_t *decayR = (celt_word16_t*)celt_alloc(sizeof(celt_word16_t)*len);

View file

@ -40,7 +40,7 @@ struct PsyDecay {
};
/** Pre-compute the decay of the psycho-acoustic spreading function */
void psydecay_init(struct PsyDecay *decay, int len, celt_int32_t Fs);
void psydecay_init(struct PsyDecay *decay, int len, celt_int32 Fs);
/** Free the memory allocated for the spreading function */
void psydecay_clear(struct PsyDecay *decay);

View file

@ -152,7 +152,7 @@ void quant_fine_energy(const CELTMode *m, celt_ener_t *eBands, celt_word16_t *ol
/* Encode finer resolution */
for (i=0;i<m->nbEBands;i++)
{
celt_int16_t frac = 1<<fine_quant[i];
celt_int16 frac = 1<<fine_quant[i];
if (fine_quant[i] <= 0)
continue;
c=0;

View file

@ -45,14 +45,14 @@
#ifndef STATIC_MODES
celt_int16_t **compute_alloc_cache(CELTMode *m, int C)
celt_int16 **compute_alloc_cache(CELTMode *m, int C)
{
int i, prevN;
int error = 0;
celt_int16_t **bits;
const celt_int16_t *eBands = m->eBands;
celt_int16 **bits;
const celt_int16 *eBands = m->eBands;
bits = celt_alloc(m->nbEBands*sizeof(celt_int16_t*));
bits = celt_alloc(m->nbEBands*sizeof(celt_int16*));
if (bits==NULL)
return NULL;
@ -64,10 +64,10 @@ celt_int16_t **compute_alloc_cache(CELTMode *m, int C)
{
bits[i] = bits[i-1];
} else {
bits[i] = celt_alloc(MAX_PSEUDO*sizeof(celt_int16_t));
bits[i] = celt_alloc(MAX_PSEUDO*sizeof(celt_int16));
if (bits[i]!=NULL) {
int j;
celt_int16_t tmp[MAX_PULSES];
celt_int16 tmp[MAX_PULSES];
get_required_bits(tmp, N, MAX_PULSES, BITRES);
for (j=0;j<MAX_PSEUDO;j++)
bits[i][j] = tmp[get_pulses(j)];
@ -79,7 +79,7 @@ celt_int16_t **compute_alloc_cache(CELTMode *m, int C)
}
if (error)
{
const celt_int16_t *prevPtr = NULL;
const celt_int16 *prevPtr = NULL;
if (bits!=NULL)
{
for (i=0;i<m->nbEBands;i++)

View file

@ -51,7 +51,7 @@ static inline int get_pulses(int i)
return i<8 ? i : (8 + (i&7)) << ((i>>3)-1);
}
static inline int bits2pulses(const CELTMode *m, const celt_int16_t *cache, int N, int bits)
static inline int bits2pulses(const CELTMode *m, const celt_int16 *cache, int N, int bits)
{
int i;
int lo, hi;
@ -131,7 +131,7 @@ static inline int bits2pulses(const CELTMode *m, const celt_int16_t *cache, int
}
static inline int pulses2bits(const celt_int16_t *cache, int N, int pulses)
static inline int pulses2bits(const celt_int16 *cache, int N, int pulses)
{
#if 0 /* Use of more than MAX_PULSES is disabled until we are able to cwrs that decently */
if (pulses > 127)
@ -154,7 +154,7 @@ static inline int pulses2bits(const celt_int16_t *cache, int N, int pulses)
}
/** Computes a cache of the pulses->bits mapping in each band */
celt_int16_t **compute_alloc_cache(CELTMode *m, int C);
celt_int16 **compute_alloc_cache(CELTMode *m, int C);
/** Compute the pulse allocation, i.e. how many pulses will go in each
* band.

View file

@ -51,7 +51,7 @@ int main(int argc, char *argv[])
CELTEncoder *enc;
CELTDecoder *dec;
int len;
celt_int32_t frame_size, channels;
celt_int32 frame_size, channels;
int bytes_per_packet;
unsigned char data[MAX_PACKET];
int rate;
@ -61,8 +61,8 @@ int main(int argc, char *argv[])
double rmsd = 0;
#endif
int count = 0;
celt_int32_t skip;
celt_int16_t *in, *out;
celt_int32 skip;
celt_int16 *in, *out;
if (argc != 9 && argc != 8 && argc != 7)
{
fprintf (stderr, "Usage: testcelt <rate> <channels> <frame size> "
@ -126,8 +126,8 @@ int main(int argc, char *argv[])
}
celt_mode_info(mode, CELT_GET_FRAME_SIZE, &frame_size);
in = (celt_int16_t*)malloc(frame_size*channels*sizeof(celt_int16_t));
out = (celt_int16_t*)malloc(frame_size*channels*sizeof(celt_int16_t));
in = (celt_int16*)malloc(frame_size*channels*sizeof(celt_int16));
out = (celt_int16*)malloc(frame_size*channels*sizeof(celt_int16));
while (!feof(fin))
{
err = fread(in, sizeof(short), frame_size*channels, fin);

View file

@ -33,21 +33,21 @@ int main(int _argc,char **_argv){
dk=kmax[n]>7?kmax[n]/7:1;
k=1-dk;
do{
celt_uint32_t uu[KMAX+2U];
celt_uint32_t inc;
celt_uint32_t nc;
celt_uint32_t i;
celt_uint32 uu[KMAX+2U];
celt_uint32 inc;
celt_uint32 nc;
celt_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_t u[KMAX+2U];
celt_uint32 u[KMAX+2U];
int y[NMAX];
int yy[5];
celt_uint32_t v;
celt_uint32_t ii;
celt_uint32 v;
celt_uint32 ii;
int kk;
int j;
memcpy(u,uu,(k+2U)*sizeof(*u));

View file

@ -19,7 +19,7 @@ int ret = 0;
void testdiv(void)
{
celt_int32_t i;
celt_int32 i;
for (i=1;i<=327670;i++)
{
double prod;
@ -40,7 +40,7 @@ void testdiv(void)
void testsqrt(void)
{
celt_int32_t i;
celt_int32 i;
for (i=1;i<=1000000000;i++)
{
double ratio;
@ -58,7 +58,7 @@ void testsqrt(void)
void testrsqrt(void)
{
celt_int32_t i;
celt_int32 i;
for (i=1;i<=2000000;i++)
{
double ratio;

View file

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

View file

@ -286,7 +286,7 @@ void version_short(void)
printf ("Copyright (C) 2008 Jean-Marc Valin\n");
}
static CELTDecoder *process_header(ogg_packet *op, celt_int32_t enh_enabled, celt_int32_t *frame_size, int *granule_frame_size, celt_int32_t *rate, int *nframes, int forceMode, int *channels, int *overlap, int *extra_headers, int quiet, CELTMode **mode)
static CELTDecoder *process_header(ogg_packet *op, celt_int32 enh_enabled, celt_int32 *frame_size, int *granule_frame_size, celt_int32 *rate, int *nframes, int forceMode, int *channels, int *overlap, int *extra_headers, int quiet, CELTMode **mode)
{
CELTDecoder *st;
CELTHeader header;
@ -581,7 +581,7 @@ int main(int argc, char **argv)
}
if (print_bitrate) {
celt_int32_t tmp=op.bytes;
celt_int32 tmp=op.bytes;
char ch=13;
fputc (ch, stderr);
fprintf (stderr, "Bitrate in use: %d bytes/packet ", tmp);

View file

@ -85,7 +85,7 @@ int oe_write_page(ogg_page *page, FILE *fp)
#define IMAX(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum int value. */
/* Convert input audio bits, endians and channels */
static int read_samples(FILE *fin,int frame_size, int bits, int channels, int lsb, short * input, char *buff, celt_int32_t *size)
static int read_samples(FILE *fin,int frame_size, int bits, int channels, int lsb, short * input, char *buff, celt_int32 *size)
{
unsigned char in[MAX_FRAME_SIZE*2];
int i;
@ -167,7 +167,7 @@ void add_fishead_packet (ogg_stream_state *os) {
/*
* Adds the fishead packets in the skeleton output stream along with the e_o_s packet
*/
void add_fisbone_packet (ogg_stream_state *os, celt_int32_t serialno, CELTHeader *header) {
void add_fisbone_packet (ogg_stream_state *os, celt_int32 serialno, CELTHeader *header) {
fisbone_packet fp;
@ -247,7 +247,7 @@ int main(int argc, char **argv)
char *inFile, *outFile;
FILE *fin, *fout;
short input[MAX_FRAME_SIZE];
celt_int32_t frame_size = 256;
celt_int32 frame_size = 256;
int quiet=0;
int nbBytes;
CELTMode *mode;
@ -283,8 +283,8 @@ int main(int argc, char **argv)
{0, 0, 0, 0}
};
int print_bitrate=0;
celt_int32_t rate=44100;
celt_int32_t size;
celt_int32 rate=44100;
celt_int32 size;
int chan=1;
int fmt=16;
int lsb=1;
@ -303,7 +303,7 @@ int main(int argc, char **argv)
float bitrate=-1;
char first_bytes[12];
int wave_input=0;
celt_int32_t lookahead = 0;
celt_int32 lookahead = 0;
int bytes_per_packet=48;
int complexity=-127;
int prediction=2;

View file

@ -40,13 +40,13 @@
#include "wav_io.h"
int read_wav_header(FILE *file, int *rate, int *channels, int *format, celt_int32_t *size)
int read_wav_header(FILE *file, int *rate, int *channels, int *format, celt_int32 *size)
{
char ch[5];
celt_int32_t itmp;
celt_int16_t stmp;
celt_int32_t bpersec;
celt_int16_t balign;
celt_int32 itmp;
celt_int16 stmp;
celt_int32 bpersec;
celt_int16 balign;
int skip_bytes;
int i;
@ -185,8 +185,8 @@ int read_wav_header(FILE *file, int *rate, int *channels, int *format, celt_int3
void write_wav_header(FILE *file, int rate, int channels, int format, int size)
{
char ch[5];
celt_int32_t itmp;
celt_int16_t stmp;
celt_int32 itmp;
celt_int16 stmp;
ch[4]=0;

View file

@ -44,10 +44,10 @@
#endif
/** Convert little endian */
static inline celt_int32_t le_int(celt_int32_t i)
static inline celt_int32 le_int(celt_int32 i)
{
#if !defined(__LITTLE_ENDIAN__) && ( defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__) )
celt_uint32_t ui, ret;
celt_uint32 ui, ret;
ui = i;
ret = ui>>24;
ret |= (ui>>8)&0x0000ff00;
@ -59,7 +59,7 @@ static inline celt_int32_t le_int(celt_int32_t i)
#endif
}
int read_wav_header(FILE *file, int *rate, int *channels, int *format, celt_int32_t *size);
int read_wav_header(FILE *file, int *rate, int *channels, int *format, celt_int32 *size);
void write_wav_header(FILE *file, int rate, int channels, int format, int size);