From ff5f7228fda6809abf53dfd378b4a2f095a74c1d Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin <jean-marc.valin@usherbrooke.ca> Date: Fri, 29 Jul 2011 18:59:12 -0400 Subject: [PATCH] Renamed celt_word* to opus_val* --- libcelt/arch.h | 38 +++---- libcelt/bands.c | 56 +++++------ libcelt/bands.h | 6 +- libcelt/celt.c | 184 +++++++++++++++++----------------- libcelt/dump_modes.c | 4 +- libcelt/fixed_c5x.h | 2 +- libcelt/fixed_c6x.h | 2 +- libcelt/fixed_debug.h | 14 +-- libcelt/fixed_generic.h | 36 +++---- libcelt/kiss_fft.c | 2 +- libcelt/mathops.c | 36 +++---- libcelt/mathops.h | 36 +++---- libcelt/mdct.c | 16 +-- libcelt/mdct.h | 4 +- libcelt/modes.c | 6 +- libcelt/modes.h | 4 +- libcelt/pitch.c | 64 ++++++------ libcelt/pitch.h | 8 +- libcelt/plc.c | 48 ++++----- libcelt/plc.h | 20 ++-- libcelt/quant_bands.c | 100 +++++++++--------- libcelt/quant_bands.h | 20 ++-- libcelt/static_modes_fixed.c | 4 +- libcelt/static_modes_float.c | 4 +- libcelt/tests/mathops-test.c | 14 +-- libcelt/tests/mdct-test.c | 2 +- libcelt/tests/rotation-test.c | 4 +- libcelt/vq.c | 54 +++++----- libcelt/vq.h | 6 +- src/opus_decoder.c | 6 +- win32/config.h | 2 +- 31 files changed, 401 insertions(+), 401 deletions(-) diff --git a/libcelt/arch.h b/libcelt/arch.h index 470b9fbdc..35c609b22 100644 --- a/libcelt/arch.h +++ b/libcelt/arch.h @@ -90,13 +90,13 @@ static inline void _celt_fatal(const char *str, const char *file, int line) #ifdef FIXED_POINT -typedef opus_int16 celt_word16; -typedef opus_int32 celt_word32; +typedef opus_int16 opus_val16; +typedef opus_int32 opus_val32; -typedef celt_word32 celt_sig; -typedef celt_word16 celt_norm; -typedef celt_word32 celt_ener; -typedef celt_word32 celt_mask; +typedef opus_val32 celt_sig; +typedef opus_val16 celt_norm; +typedef opus_val32 celt_ener; +typedef opus_val32 celt_mask; #define Q15ONE 32767 #define Q30ONE 1073741823 @@ -119,9 +119,9 @@ typedef celt_word32 celt_mask; #define EPSILON 1 #define VERY_SMALL 0 -#define VERY_LARGE32 ((celt_word32)2147483647) -#define VERY_LARGE16 ((celt_word16)32767) -#define Q15_ONE ((celt_word16)32767) +#define VERY_LARGE32 ((opus_val32)2147483647) +#define VERY_LARGE16 ((opus_val16)32767) +#define Q15_ONE ((opus_val16)32767) #define Q15_ONE_1 (1.f/32768.f) #define SCALEIN(a) (a) @@ -150,8 +150,8 @@ typedef celt_word32 celt_mask; #else /* FIXED_POINT */ -typedef float celt_word16; -typedef float celt_word32; +typedef float opus_val16; +typedef float opus_val32; typedef float celt_sig; typedef float celt_norm; @@ -173,8 +173,8 @@ typedef float celt_mask; #define VERY_SMALL 1e-15f #define VERY_LARGE32 1e15f #define VERY_LARGE16 1e15f -#define Q15_ONE ((celt_word16)1.f) -#define Q15_ONE_1 ((celt_word16)1.f) +#define Q15_ONE ((opus_val16)1.f) +#define Q15_ONE_1 ((opus_val16)1.f) #define QCONST16(x,bits) (x) #define QCONST32(x,bits) (x) @@ -207,8 +207,8 @@ typedef float celt_mask; #define ADD32(a,b) ((a)+(b)) #define SUB32(a,b) ((a)-(b)) #define MULT16_16_16(a,b) ((a)*(b)) -#define MULT16_16(a,b) ((celt_word32)(a)*(celt_word32)(b)) -#define MAC16_16(c,a,b) ((c)+(celt_word32)(a)*(celt_word32)(b)) +#define MULT16_16(a,b) ((opus_val32)(a)*(opus_val32)(b)) +#define MAC16_16(c,a,b) ((c)+(opus_val32)(a)*(opus_val32)(b)) #define MULT16_32_Q11(a,b) ((a)*(b)) #define MULT16_32_Q13(a,b) ((a)*(b)) @@ -233,10 +233,10 @@ typedef float celt_mask; #define MULT16_16_P13(a,b) ((a)*(b)) #define MULT16_16_P14(a,b) ((a)*(b)) -#define DIV32_16(a,b) (((celt_word32)(a))/(celt_word16)(b)) -#define PDIV32_16(a,b) (((celt_word32)(a))/(celt_word16)(b)) -#define DIV32(a,b) (((celt_word32)(a))/(celt_word32)(b)) -#define PDIV32(a,b) (((celt_word32)(a))/(celt_word32)(b)) +#define DIV32_16(a,b) (((opus_val32)(a))/(opus_val16)(b)) +#define PDIV32_16(a,b) (((opus_val32)(a))/(opus_val16)(b)) +#define DIV32(a,b) (((opus_val32)(a))/(opus_val32)(b)) +#define PDIV32(a,b) (((opus_val32)(a))/(opus_val32)(b)) #define SCALEIN(a) ((a)*CELT_SIG_SCALE) #define SCALEOUT(a) ((a)*(1/CELT_SIG_SCALE)) diff --git a/libcelt/bands.c b/libcelt/bands.c index fe69265e5..40afd650b 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -87,8 +87,8 @@ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bank for (i=0;i<end;i++) { int j; - celt_word32 maxval=0; - celt_word32 sum = 0; + opus_val32 maxval=0; + opus_val32 sum = 0; j=M*eBands[i]; do { maxval = MAX32(maxval, X[j+c*N]); @@ -123,9 +123,9 @@ void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_nor N = M*m->shortMdctSize; c=0; do { i=0; do { - celt_word16 g; + opus_val16 g; int j,shift; - celt_word16 E; + opus_val16 E; shift = celt_zlog2(bank[i+c*m->nbEBands])-13; E = VSHR32(bank[i+c*m->nbEBands], shift); g = EXTRACT16(celt_rcp(SHL32(E,3))); @@ -148,7 +148,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bank for (i=0;i<end;i++) { int j; - celt_word32 sum = 1e-27f; + opus_val32 sum = 1e-27f; for (j=M*eBands[i];j<M*eBands[i+1];j++) sum += X[j+c*N]*X[j+c*N]; bank[i+c*m->nbEBands] = celt_sqrt(sum); @@ -169,7 +169,7 @@ void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_nor for (i=0;i<end;i++) { int j; - celt_word16 g = 1.f/(1e-27f+bank[i+c*m->nbEBands]); + opus_val16 g = 1.f/(1e-27f+bank[i+c*m->nbEBands]); for (j=M*eBands[i];j<M*eBands[i+1];j++) X[j+c*N] = freq[j+c*N]*g; } @@ -194,7 +194,7 @@ void denormalise_bands(const CELTMode *m, const celt_norm * restrict X, celt_sig for (i=0;i<end;i++) { int j, band_end; - celt_word32 g = SHR32(bank[i+c*m->nbEBands],1); + opus_val32 g = SHR32(bank[i+c*m->nbEBands],1); j=M*eBands[i]; band_end = M*eBands[i+1]; do { @@ -209,14 +209,14 @@ 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, opus_uint32 seed) + int start, int end, opus_val16 *logE, opus_val16 *prev1logE, + opus_val16 *prev2logE, int *pulses, opus_uint32 seed) { int c, i, j, k; for (i=start;i<end;i++) { int N0; - celt_word16 thresh, sqrt_1; + opus_val16 thresh, sqrt_1; int depth; #ifdef FIXED_POINT int shift; @@ -229,7 +229,7 @@ void anti_collapse(const CELTMode *m, celt_norm *_X, unsigned char *collapse_mas #ifdef FIXED_POINT thresh = MULT16_32_Q15(QCONST16(0.5f, 15), MIN32(32767,SHR32(celt_exp2(-SHL16(depth, 10-BITRES)),1) )); { - celt_word32 t; + opus_val32 t; t = N0<<LM; shift = celt_ilog2(t)>>1; t = SHL32(t, (7-shift)<<1); @@ -243,10 +243,10 @@ void anti_collapse(const CELTMode *m, celt_norm *_X, unsigned char *collapse_mas c=0; do { celt_norm *X; - celt_word16 prev1; - celt_word16 prev2; - celt_word16 Ediff; - celt_word16 r; + opus_val16 prev1; + opus_val16 prev2; + opus_val16 Ediff; + opus_val16 r; int renormalize=0; prev1 = prev1logE[c*m->nbEBands+i]; prev2 = prev2logE[c*m->nbEBands+i]; @@ -304,9 +304,9 @@ static void intensity_stereo(const CELTMode *m, celt_norm *X, celt_norm *Y, cons { int i = bandID; int j; - celt_word16 a1, a2; - celt_word16 left, right; - celt_word16 norm; + opus_val16 a1, a2; + opus_val16 left, right; + opus_val16 norm; #ifdef FIXED_POINT int shift = celt_zlog2(MAX32(bank[i], bank[i+m->nbEBands]))-13; #endif @@ -338,16 +338,16 @@ static void stereo_split(celt_norm *X, celt_norm *Y, int N) } } -static void stereo_merge(celt_norm *X, celt_norm *Y, celt_word16 mid, int N) +static void stereo_merge(celt_norm *X, celt_norm *Y, opus_val16 mid, int N) { int j; - celt_word32 xp=0, side=0; - celt_word32 El, Er; - celt_word16 mid2; + opus_val32 xp=0, side=0; + opus_val32 El, Er; + opus_val16 mid2; #ifdef FIXED_POINT int kl, kr; #endif - celt_word32 t, lgain, rgain; + opus_val32 t, lgain, rgain; /* Compute the norm of X+Y and X-Y as |X|^2 + |Y|^2 +/- sum(xy) */ for (j=0;j<N;j++) @@ -423,7 +423,7 @@ int spreading_decision(const CELTMode *m, celt_norm *X, int *average, /* Compute rough CDF of |x[j]| */ for (j=0;j<N;j++) { - celt_word32 x2N; /* Q13 */ + opus_val32 x2N; /* Q13 */ x2N = MULT16_16(MULT16_16_Q15(x[j], x[j]), N); if (x2N < QCONST16(0.25f,13)) @@ -634,7 +634,7 @@ static int compute_qn(int N, int b, int offset, int pulse_cap, int stereo) 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, 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) + opus_uint32 *seed, opus_val16 gain, celt_norm *lowband_scratch, int fill) { const unsigned char *cache; int q; @@ -648,7 +648,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c int time_divide=0; int recombine=0; int inv = 0; - celt_word16 mid=0, side=0; + opus_val16 mid=0, side=0; int longBlocks; unsigned cm=0; @@ -1085,7 +1085,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c /* Folded spectrum */ for (j=0;j<N;j++) { - celt_word16 tmp; + opus_val16 tmp; *seed = lcg_rand(*seed); /* About 48 dB below the "normal" folding level */ tmp = QCONST16(1.0f/256, 10); @@ -1147,7 +1147,7 @@ static unsigned quant_band(int encode, const CELTMode *m, int i, celt_norm *X, c if (lowband_out) { int j; - celt_word16 n; + opus_val16 n; n = celt_sqrt(SHL32(EXTEND32(N0),22)); for (j=0;j<N0;j++) lowband_out[j] = MULT16_16_Q15(n,X[j]); diff --git a/libcelt/bands.h b/libcelt/bands.h index cf5b1dbab..b8c3fd278 100644 --- a/libcelt/bands.h +++ b/libcelt/bands.h @@ -43,7 +43,7 @@ */ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bands, int end, int _C, int M); -/*void compute_noise_energies(const CELTMode *m, const celt_sig *X, const celt_word16 *tonality, celt_ener *bank);*/ +/*void compute_noise_energies(const CELTMode *m, const celt_sig *X, const opus_val16 *tonality, celt_ener *bank);*/ /** Normalise each band of X such that the energy in each band is equal to 1 @@ -90,8 +90,8 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end, 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, opus_uint32 seed); + int start, int end, opus_val16 *logE, opus_val16 *prev1logE, + opus_val16 *prev2logE, int *pulses, opus_uint32 seed); opus_uint32 lcg_rand(opus_uint32 seed); diff --git a/libcelt/celt.c b/libcelt/celt.c index bb1c93e23..2ab643e72 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -146,18 +146,18 @@ struct CELTEncoder { opus_uint32 rng; int spread_decision; - celt_word32 delayedIntra; + opus_val32 delayedIntra; int tonal_average; int lastCodedBands; int hf_average; int tapset_decision; int prefilter_period; - celt_word16 prefilter_gain; + opus_val16 prefilter_gain; int prefilter_tapset; #ifdef RESYNTH int prefilter_period_old; - celt_word16 prefilter_gain_old; + opus_val16 prefilter_gain_old; int prefilter_tapset_old; #endif int consec_transient; @@ -168,8 +168,8 @@ struct CELTEncoder { opus_int32 vbr_offset; opus_int32 vbr_count; - celt_word32 preemph_memE[2]; - celt_word32 preemph_memD[2]; + opus_val32 preemph_memE[2]; + opus_val32 preemph_memD[2]; #ifdef RESYNTH celt_sig syn_mem[2][2*MAX_PERIOD]; @@ -178,7 +178,7 @@ struct CELTEncoder { celt_sig in_mem[1]; /* Size = channels*mode->overlap */ /* celt_sig prefilter_mem[], Size = channels*COMBFILTER_PERIOD */ /* celt_sig overlap_mem[], Size = channels*mode->overlap */ - /* celt_word16 oldEBands[], Size = 2*channels*mode->nbEBands */ + /* opus_val16 oldEBands[], Size = 2*channels*mode->nbEBands */ }; int celt_encoder_get_size(int channels) @@ -192,7 +192,7 @@ int celt_encoder_get_size_custom(const CELTMode *mode, int channels) int size = sizeof(struct CELTEncoder) + (2*channels*mode->overlap-1)*sizeof(celt_sig) + channels*COMBFILTER_MAXPERIOD*sizeof(celt_sig) - + 3*channels*mode->nbEBands*sizeof(celt_word16); + + 3*channels*mode->nbEBands*sizeof(opus_val16); return size; } @@ -291,7 +291,7 @@ static inline opus_int16 FLOAT2INT16(float x) return (opus_int16)float2int(x); } -static inline celt_word16 SIG2WORD16(celt_sig x) +static inline opus_val16 SIG2WORD16(celt_sig x) { #ifdef FIXED_POINT x = PSHR32(x, SIG_SHIFT); @@ -299,26 +299,26 @@ static inline celt_word16 SIG2WORD16(celt_sig x) x = MIN32(x, 32767); return EXTRACT16(x); #else - return (celt_word16)x; + return (opus_val16)x; #endif } -static int transient_analysis(const celt_word32 * restrict in, int len, int C, +static int transient_analysis(const opus_val32 * restrict in, int len, int C, int overlap) { int i; - VARDECL(celt_word16, tmp); - celt_word32 mem0=0,mem1=0; + VARDECL(opus_val16, tmp); + opus_val32 mem0=0,mem1=0; int is_transient = 0; int block; int N; - VARDECL(celt_word16, bins); + VARDECL(opus_val16, bins); SAVE_STACK; - ALLOC(tmp, len, celt_word16); + ALLOC(tmp, len, opus_val16); block = overlap/2; N=len/block; - ALLOC(bins, N, celt_word16); + ALLOC(bins, N, opus_val16); if (C==1) { for (i=0;i<len;i++) @@ -331,7 +331,7 @@ static int transient_analysis(const celt_word32 * restrict in, int len, int C, /* High-pass filter: (1 - 2*z^-1 + z^-2) / (1 - z^-1 + .5*z^-2) */ for (i=0;i<len;i++) { - celt_word32 x,y; + opus_val32 x,y; x = tmp[i]; y = ADD32(mem0, x); #ifdef FIXED_POINT @@ -350,7 +350,7 @@ static int transient_analysis(const celt_word32 * restrict in, int len, int C, for (i=0;i<N;i++) { int j; - celt_word16 max_abs=0; + opus_val16 max_abs=0; for (j=0;j<block;j++) max_abs = MAX16(max_abs, ABS16(tmp[i*block+j])); bins[i] = max_abs; @@ -359,7 +359,7 @@ static int transient_analysis(const celt_word32 * restrict in, int len, int C, { int j; int conseq=0; - celt_word16 t1, t2, t3; + opus_val16 t1, t2, t3; t1 = MULT16_16_Q15(QCONST16(.15f, 15), bins[i]); t2 = MULT16_16_Q15(QCONST16(.4f, 15), bins[i]); @@ -404,7 +404,7 @@ static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig * rest int N = mode->shortMdctSize<<LM; int B = 1; int b, c; - VARDECL(celt_word32, tmp); + VARDECL(opus_val32, tmp); SAVE_STACK; if (shortBlocks) { @@ -412,7 +412,7 @@ static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig * rest N = mode->shortMdctSize; B = shortBlocks; } - ALLOC(tmp, N, celt_word32); + ALLOC(tmp, N, opus_val32); c=0; do { for (b=0;b<B;b++) { @@ -439,15 +439,15 @@ static void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X const int overlap = OVERLAP(mode); c=0; do { int j; - VARDECL(celt_word32, x); - VARDECL(celt_word32, tmp); + VARDECL(opus_val32, x); + VARDECL(opus_val32, tmp); int b; int N2 = N; int B = 1; SAVE_STACK; - ALLOC(x, N+overlap, celt_word32); - ALLOC(tmp, N, celt_word32); + ALLOC(x, N+overlap, opus_val32); + ALLOC(tmp, N, opus_val32); if (shortBlocks) { @@ -475,7 +475,7 @@ static void compute_inv_mdcts(const CELTMode *mode, int shortBlocks, celt_sig *X } while (++c<C); } -static void deemphasis(celt_sig *in[], celt_word16 *pcm, int N, int _C, int downsample, const celt_word16 *coef, celt_sig *mem) +static void deemphasis(celt_sig *in[], opus_val16 *pcm, int N, int _C, int downsample, const opus_val16 *coef, celt_sig *mem) { const int C = CHANNELS(_C); int c; @@ -483,7 +483,7 @@ static void deemphasis(celt_sig *in[], celt_word16 *pcm, int N, int _C, int down c=0; do { int j; celt_sig * restrict x; - celt_word16 * restrict y; + opus_val16 * restrict y; celt_sig m = mem[c]; x =in[c]; y = pcm+c; @@ -507,14 +507,14 @@ static void deemphasis(celt_sig *in[], celt_word16 *pcm, int N, int _C, int down } while (++c<C); } -static void comb_filter(celt_word32 *y, celt_word32 *x, int T0, int T1, int N, - celt_word16 g0, celt_word16 g1, int tapset0, int tapset1, - const celt_word16 *window, int overlap) +static void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, + opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, + const opus_val16 *window, int overlap) { int i; /* printf ("%d %d %f %f\n", T0, T1, g0, g1); */ - celt_word16 g00, g01, g02, g10, g11, g12; - static const celt_word16 gains[3][3] = { + opus_val16 g00, g01, g02, g10, g11, g12; + static const opus_val16 gains[3][3] = { {QCONST16(0.3066406250f, 15), QCONST16(0.2170410156f, 15), QCONST16(0.1296386719f, 15)}, {QCONST16(0.4638671875f, 15), QCONST16(0.2680664062f, 15), QCONST16(0.f, 15)}, {QCONST16(0.7998046875f, 15), QCONST16(0.1000976562f, 15), QCONST16(0.f, 15)}}; @@ -526,7 +526,7 @@ static void comb_filter(celt_word32 *y, celt_word32 *x, int T0, int T1, int N, g12 = MULT16_16_Q15(g1, gains[tapset1][2]); for (i=0;i<overlap;i++) { - celt_word16 f; + opus_val16 f; f = MULT16_16_Q15(window[i],window[i]); y[i] = x[i] + MULT16_32_Q15(MULT16_16_Q15((Q15ONE-f),g00),x[i-T0]) @@ -557,16 +557,16 @@ static const signed char tf_select_table[4][8] = { {0, -2, 0, -3, 3, 0, 1,-1}, }; -static celt_word32 l1_metric(const celt_norm *tmp, int N, int LM, int width) +static opus_val32 l1_metric(const celt_norm *tmp, int N, int LM, int width) { int i, j; - static const celt_word16 sqrtM_1[4] = {Q15ONE, QCONST16(.70710678f,15), QCONST16(0.5f,15), QCONST16(0.35355339f,15)}; - celt_word32 L1; - celt_word16 bias; + static const opus_val16 sqrtM_1[4] = {Q15ONE, QCONST16(.70710678f,15), QCONST16(0.5f,15), QCONST16(0.35355339f,15)}; + opus_val32 L1; + opus_val16 bias; L1=0; for (i=0;i<1<<LM;i++) { - celt_word32 L2 = 0; + opus_val32 L2 = 0; for (j=0;j<N>>LM;j++) L2 = MAC16_16(L2, tmp[(j<<LM)+i], tmp[(j<<LM)+i]); L1 += celt_sqrt(L2); @@ -582,7 +582,7 @@ static celt_word32 l1_metric(const celt_norm *tmp, int N, int LM, int width) return L1; } -static int tf_analysis(const CELTMode *m, celt_word16 *bandLogE, celt_word16 *oldBandE, +static int tf_analysis(const CELTMode *m, opus_val16 *bandLogE, opus_val16 *oldBandE, int len, int C, int isTransient, int *tf_res, int nbCompressedBytes, celt_norm *X, int N0, int LM, int *tf_sum) { @@ -622,7 +622,7 @@ static int tf_analysis(const CELTMode *m, celt_word16 *bandLogE, celt_word16 *ol for (i=0;i<len;i++) { int j, k, N; - celt_word32 L1, best_L1; + opus_val32 L1, best_L1; int best_level=0; N = (m->eBands[i+1]-m->eBands[i])<<LM; for (j=0;j<N;j++) @@ -803,20 +803,20 @@ static void init_caps(const CELTMode *m,int *cap,int LM,int C) } static int alloc_trim_analysis(const CELTMode *m, const celt_norm *X, - const celt_word16 *bandLogE, int end, int LM, int C, int N0) + const opus_val16 *bandLogE, int end, int LM, int C, int N0) { int i; - celt_word32 diff=0; + opus_val32 diff=0; int c; int trim_index = 5; if (C==2) { - celt_word16 sum = 0; /* Q10 */ + opus_val16 sum = 0; /* Q10 */ /* Compute inter-channel correlation for low frequencies */ for (i=0;i<8;i++) { int j; - celt_word32 partial = 0; + opus_val32 partial = 0; for (j=m->eBands[i]<<LM;j<m->eBands[i+1]<<LM;j++) partial = MAC16_16(partial, X[j], X[N0+j]); sum = ADD16(sum, EXTRACT16(SHR32(partial, 18))); @@ -863,7 +863,7 @@ static int stereo_analysis(const CELTMode *m, const celt_norm *X, { int i; int thetas; - celt_word32 sumLR = EPSILON, sumMS = EPSILON; + opus_val32 sumLR = EPSILON, sumMS = EPSILON; /* Use the L1 norm to model the entropy of the L/R signal vs the M/S signal */ for (i=0;i<13;i++) @@ -871,7 +871,7 @@ static int stereo_analysis(const CELTMode *m, const celt_norm *X, int j; for (j=m->eBands[i]<<LM;j<m->eBands[i+1]<<LM;j++) { - celt_word16 L, R, M, S; + opus_val16 L, R, M, S; L = X[j]; R = X[N0+j]; M = L+R; @@ -905,9 +905,9 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i VARDECL(celt_sig, freq); VARDECL(celt_norm, X); VARDECL(celt_ener, bandE); - VARDECL(celt_word16, bandLogE); + VARDECL(opus_val16, bandLogE); VARDECL(int, fine_quant); - VARDECL(celt_word16, error); + VARDECL(opus_val16, error); VARDECL(int, pulses); VARDECL(int, cap); VARDECL(int, offsets); @@ -915,7 +915,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i VARDECL(int, tf_res); VARDECL(unsigned char, collapse_masks); celt_sig *prefilter_mem; - celt_word16 *oldBandE, *oldLogE, *oldLogE2; + opus_val16 *oldBandE, *oldLogE, *oldLogE2; int shortBlocks=0; int isTransient=0; int resynth; @@ -929,11 +929,11 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i int tf_sum; int alloc_trim; int pitch_index=COMBFILTER_MINPERIOD; - celt_word16 gain1 = 0; + opus_val16 gain1 = 0; int intensity=0; int dual_stereo=0; int effectiveBytes; - celt_word16 pf_threshold; + opus_val16 pf_threshold; int dynalloc_logp; opus_int32 vbr_rate; opus_int32 total_bits; @@ -960,7 +960,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i N = M*st->mode->shortMdctSize; prefilter_mem = st->in_mem+CC*(st->overlap); - oldBandE = (celt_word16*)(st->in_mem+CC*(2*st->overlap+COMBFILTER_MAXPERIOD)); + oldBandE = (opus_val16*)(st->in_mem+CC*(2*st->overlap+COMBFILTER_MAXPERIOD)); oldLogE = oldBandE + CC*st->mode->nbEBands; oldLogE2 = oldLogE + CC*st->mode->nbEBands; @@ -1067,7 +1067,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i silence = 1; c=0; do { int count = 0; - const celt_word16 * restrict pcmp = pcm+c; + const opus_val16 * restrict pcmp = pcm+c; celt_sig * restrict inp = in+c*(N+st->overlap)+st->overlap; for (i=0;i<N;i++) @@ -1121,8 +1121,8 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i } if (nbAvailableBytes>12*C && st->start==0 && !silence && !st->disable_pf && st->complexity >= 5) { - VARDECL(celt_word16, pitch_buf); - ALLOC(pitch_buf, (COMBFILTER_MAXPERIOD+N)>>1, celt_word16); + VARDECL(opus_val16, pitch_buf); + ALLOC(pitch_buf, (COMBFILTER_MAXPERIOD+N)>>1, opus_val16); pitch_downsample(pre, pitch_buf, COMBFILTER_MAXPERIOD+N, CC); pitch_search(pitch_buf+(COMBFILTER_MAXPERIOD>>1), pitch_buf, N, @@ -1247,7 +1247,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i ALLOC(freq, CC*N, celt_sig); /**< Interleaved signal MDCTs */ ALLOC(bandE,st->mode->nbEBands*CC, celt_ener); - ALLOC(bandLogE,st->mode->nbEBands*CC, celt_word16); + ALLOC(bandLogE,st->mode->nbEBands*CC, opus_val16); /* Compute MDCTs */ compute_mdcts(st->mode, shortBlocks, in, freq, CC, LM); @@ -1282,7 +1282,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i for (i=effEnd;i<st->end;i++) tf_res[i] = tf_res[effEnd-1]; - ALLOC(error, C*st->mode->nbEBands, celt_word16); + ALLOC(error, C*st->mode->nbEBands, opus_val16); quant_coarse_energy(st->mode, st->start, st->end, effEnd, bandLogE, oldBandE, total_bits, error, enc, C, LM, nbAvailableBytes, st->force_intra, @@ -1326,7 +1326,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i } for (i=st->start+1;i<st->end-1;i++) { - celt_word32 d2; + opus_val32 d2; d2 = 2*bandLogE[i]-bandLogE[i-1]-bandLogE[i+1]; if (C==2) d2 = HALF32(d2 + 2*bandLogE[i+st->mode->nbEBands]- @@ -1383,7 +1383,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i /* Variable bitrate */ if (vbr_rate>0) { - celt_word16 alpha; + opus_val16 alpha; opus_int32 delta; /* The target rate in 8th bits per frame */ opus_int32 target; @@ -1603,7 +1603,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i st->mode->window, st->mode->overlap); } while (++c<CC); - deemphasis(out_mem, (celt_word16*)pcm, N, CC, st->upsample, st->mode->preemph, st->preemph_memD); + deemphasis(out_mem, (opus_val16*)pcm, N, CC, st->upsample, st->mode->preemph, st->preemph_memD); st->prefilter_period_old = st->prefilter_period; st->prefilter_gain_old = st->prefilter_gain; st->prefilter_tapset_old = st->prefilter_tapset; @@ -1886,19 +1886,19 @@ struct CELTDecoder { int loss_count; int postfilter_period; int postfilter_period_old; - celt_word16 postfilter_gain; - celt_word16 postfilter_gain_old; + opus_val16 postfilter_gain; + opus_val16 postfilter_gain_old; int postfilter_tapset; int postfilter_tapset_old; celt_sig preemph_memD[2]; celt_sig _decode_mem[1]; /* Size = channels*(DECODE_BUFFER_SIZE+mode->overlap) */ - /* celt_word16 lpc[], Size = channels*LPC_ORDER */ - /* celt_word16 oldEBands[], Size = 2*mode->nbEBands */ - /* celt_word16 oldLogE[], Size = 2*mode->nbEBands */ - /* celt_word16 oldLogE2[], Size = 2*mode->nbEBands */ - /* celt_word16 backgroundLogE[], Size = 2*mode->nbEBands */ + /* opus_val16 lpc[], Size = channels*LPC_ORDER */ + /* opus_val16 oldEBands[], Size = 2*mode->nbEBands */ + /* opus_val16 oldLogE[], Size = 2*mode->nbEBands */ + /* opus_val16 oldLogE2[], Size = 2*mode->nbEBands */ + /* opus_val16 backgroundLogE[], Size = 2*mode->nbEBands */ }; int celt_decoder_get_size(int channels) @@ -1911,8 +1911,8 @@ int celt_decoder_get_size_custom(const CELTMode *mode, int channels) { int size = sizeof(struct CELTDecoder) + (channels*(DECODE_BUFFER_SIZE+mode->overlap)-1)*sizeof(celt_sig) - + channels*LPC_ORDER*sizeof(celt_word16) - + 4*2*mode->nbEBands*sizeof(celt_word16); + + channels*LPC_ORDER*sizeof(opus_val16) + + 4*2*mode->nbEBands*sizeof(opus_val16); return size; } @@ -1991,21 +1991,21 @@ void celt_decoder_destroy(CELTDecoder *st) celt_free(st); } -static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict pcm, int N, int LM) +static void celt_decode_lost(CELTDecoder * restrict st, opus_val16 * restrict pcm, int N, int LM) { int c; int pitch_index; int overlap = st->mode->overlap; - celt_word16 fade = Q15ONE; + opus_val16 fade = Q15ONE; int i, len; const int C = CHANNELS(st->channels); int offset; celt_sig *out_mem[2]; celt_sig *decode_mem[2]; celt_sig *overlap_mem[2]; - celt_word16 *lpc; - celt_word32 *out_syn[2]; - celt_word16 *oldBandE, *oldLogE2, *backgroundLogE; + opus_val16 *lpc; + opus_val32 *out_syn[2]; + opus_val16 *oldBandE, *oldLogE2, *backgroundLogE; int plc=1; SAVE_STACK; @@ -2014,7 +2014,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict p out_mem[c] = decode_mem[c]+DECODE_BUFFER_SIZE-MAX_PERIOD; overlap_mem[c] = decode_mem[c]+DECODE_BUFFER_SIZE; } while (++c<C); - lpc = (celt_word16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+st->overlap)*C); + lpc = (opus_val16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+st->overlap)*C); oldBandE = lpc+C*LPC_ORDER; oldLogE2 = oldBandE + C*st->mode->nbEBands; backgroundLogE = oldLogE2 + C*st->mode->nbEBands; @@ -2084,7 +2084,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict p plc = 0; } else if (st->loss_count == 0) { - celt_word16 pitch_buf[DECODE_BUFFER_SIZE>>1]; + opus_val16 pitch_buf[DECODE_BUFFER_SIZE>>1]; /* Corresponds to a min pitch of 67 Hz. It's possible to save CPU in this search by using only part of the decode buffer */ int poffset = 720; @@ -2102,14 +2102,14 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict p if (plc) { c=0; do { - VARDECL(celt_word32, e); - celt_word16 exc[MAX_PERIOD]; - celt_word32 ac[LPC_ORDER+1]; - celt_word16 decay = 1; - celt_word32 S1=0; - celt_word16 mem[LPC_ORDER]={0}; + VARDECL(opus_val32, e); + opus_val16 exc[MAX_PERIOD]; + opus_val32 ac[LPC_ORDER+1]; + opus_val16 decay = 1; + opus_val32 S1=0; + opus_val16 mem[LPC_ORDER]={0}; - ALLOC(e, MAX_PERIOD+2*st->mode->overlap, celt_word32); + ALLOC(e, MAX_PERIOD+2*st->mode->overlap, opus_val32); offset = MAX_PERIOD-pitch_index; for (i=0;i<MAX_PERIOD;i++) @@ -2145,7 +2145,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict p /*for (i=0;i<MAX_PERIOD;i++)printf("%d ", exc[i]); printf("\n");*/ /* Check if the waveform is decaying (and if so how fast) */ { - celt_word32 E1=1, E2=1; + opus_val32 E1=1, E2=1; int period; if (pitch_index <= MAX_PERIOD/2) period = pitch_index; @@ -2164,7 +2164,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict p /* Copy excitation, taking decay into account */ for (i=0;i<len+st->mode->overlap;i++) { - celt_word16 tmp; + opus_val16 tmp; if (offset+i >= MAX_PERIOD) { offset -= pitch_index; @@ -2181,10 +2181,10 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict p iir(e, lpc+c*LPC_ORDER, e, len+st->mode->overlap, LPC_ORDER, mem); { - celt_word32 S2=0; + opus_val32 S2=0; for (i=0;i<len+overlap;i++) { - celt_word16 tmp = ROUND16(e[i],SIG_SHIFT); + opus_val16 tmp = ROUND16(e[i],SIG_SHIFT); S2 += SHR32(MULT16_16(tmp,tmp),8); } /* This checks for an "explosion" in the synthesis */ @@ -2199,7 +2199,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict p e[i] = 0; } else if (S1 < S2) { - celt_word16 ratio = celt_sqrt(frac_div32(SHR32(S1,1)+1,S2+1)); + opus_val16 ratio = celt_sqrt(frac_div32(SHR32(S1,1)+1,S2+1)); for (i=0;i<len+overlap;i++) e[i] = MULT16_32_Q15(ratio, e[i]); } @@ -2217,7 +2217,7 @@ static void celt_decode_lost(CELTDecoder * restrict st, celt_word16 * restrict p previous and next frames */ for (i=0;i<overlap/2;i++) { - celt_word32 tmp; + opus_val32 tmp; tmp = MULT16_32_Q15(st->mode->window[i], e[N+overlap-1-i]) + MULT16_32_Q15(st->mode->window[overlap-i-1], e[N+i ]); out_mem[c][MAX_PERIOD+i] = MULT16_32_Q15(st->mode->window[overlap-i-1], tmp); @@ -2269,8 +2269,8 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da celt_sig *decode_mem[2]; celt_sig *overlap_mem[2]; celt_sig *out_syn[2]; - celt_word16 *lpc; - celt_word16 *oldBandE, *oldLogE, *oldLogE2, *backgroundLogE; + opus_val16 *lpc; + opus_val16 *oldBandE, *oldLogE, *oldLogE2, *backgroundLogE; int shortBlocks; int isTransient; @@ -2281,7 +2281,7 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da int codedBands; int alloc_trim; int postfilter_pitch; - celt_word16 postfilter_gain; + opus_val16 postfilter_gain; int intensity=0; int dual_stereo=0; opus_int32 total_bits; @@ -2302,7 +2302,7 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da out_mem[c] = decode_mem[c]+DECODE_BUFFER_SIZE-MAX_PERIOD; overlap_mem[c] = decode_mem[c]+DECODE_BUFFER_SIZE; } while (++c<CC); - lpc = (celt_word16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+st->overlap)*CC); + lpc = (opus_val16*)(st->_decode_mem+(DECODE_BUFFER_SIZE+st->overlap)*CC); oldBandE = lpc+LPC_ORDER; oldLogE = oldBandE + 2*st->mode->nbEBands; oldLogE2 = oldLogE + 2*st->mode->nbEBands; diff --git a/libcelt/dump_modes.c b/libcelt/dump_modes.c index 39b3b6898..6875808a7 100644 --- a/libcelt/dump_modes.c +++ b/libcelt/dump_modes.c @@ -83,7 +83,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) fprintf(file, "#ifndef DEF_WINDOW%d\n", mode->overlap); fprintf(file, "#define DEF_WINDOW%d\n", mode->overlap); - fprintf (file, "static const celt_word16 window%d[%d] = {\n", mode->overlap, mode->overlap); + fprintf (file, "static const opus_val16 window%d[%d] = {\n", mode->overlap, mode->overlap); for (j=0;j<mode->overlap;j++) fprintf (file, WORD16 ", ", mode->window[j]); fprintf (file, "};\n"); @@ -188,7 +188,7 @@ void dump_modes(FILE *file, CELTMode **modes, int nb_modes) /* MDCT twiddles */ fprintf(file, "#ifndef MDCT_TWIDDLES%d\n", mdctSize); fprintf(file, "#define MDCT_TWIDDLES%d\n", mdctSize); - fprintf (file, "static const celt_word16 mdct_twiddles%d[%d] = {\n", + fprintf (file, "static const opus_val16 mdct_twiddles%d[%d] = {\n", mdctSize, mode->mdct.n/4+1); for (j=0;j<=mode->mdct.n/4;j++) fprintf (file, WORD16 ", ", mode->mdct.trig[j]); diff --git a/libcelt/fixed_c5x.h b/libcelt/fixed_c5x.h index 7e2aa325a..8c680d5a4 100644 --- a/libcelt/fixed_c5x.h +++ b/libcelt/fixed_c5x.h @@ -78,7 +78,7 @@ static inline long IMUL32(long i, long j) #define OVERRIDE_CELT_MAXABS16 #define OVERRIDE_FIND_MAX16 -static inline int find_max16(celt_word16 *x, int len) +static inline int find_max16(opus_val16 *x, int len) { DATA max_corr16 = -VERY_LARGE16; DATA pitch16 = 0; diff --git a/libcelt/fixed_c6x.h b/libcelt/fixed_c6x.h index 47b851acf..ce7faf296 100644 --- a/libcelt/fixed_c6x.h +++ b/libcelt/fixed_c6x.h @@ -68,7 +68,7 @@ #define OVERRIDE_CELT_MAXABS16 #define OVERRIDE_FIND_MAX16 -static inline int find_max16(celt_word16 *x, int len) +static inline int find_max16(opus_val16 *x, int len) { DATA max_corr16 = -VERY_LARGE16; DATA pitch16 = 0; diff --git a/libcelt/fixed_debug.h b/libcelt/fixed_debug.h index f7131380c..353d08059 100644 --- a/libcelt/fixed_debug.h +++ b/libcelt/fixed_debug.h @@ -42,14 +42,14 @@ extern long long celt_mips; #define MIPS_INC celt_mips++, -#define MULT16_16SU(a,b) ((celt_word32)(celt_word16)(a)*(celt_word32)(opus_uint16)(b)) +#define MULT16_16SU(a,b) ((opus_val32)(opus_val16)(a)*(opus_val32)(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 */ #define MULT16_32_Q16(a,b) ADD32(MULT16_16((a),SHR32((b),16)), SHR32(MULT16_16SU((a),((b)&0x0000ffff)),16)) -#define QCONST16(x,bits) ((celt_word16)(.5+(x)*(((celt_word32)1)<<(bits)))) -#define QCONST32(x,bits) ((celt_word32)(.5+(x)*(((celt_word32)1)<<(bits)))) +#define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits)))) +#define QCONST32(x,bits) ((opus_val32)(.5+(x)*(((opus_val32)1)<<(bits)))) #define VERIFY_SHORT(x) ((x)<=32767&&(x)>=-32768) @@ -173,7 +173,7 @@ static inline int SHL32(long long a, int shift) } #define PSHR16(a,shift) (celt_mips--,SHR16(ADD16((a),((1<<((shift))>>1))),shift)) -#define PSHR32(a,shift) (celt_mips--,SHR32(ADD32((a),(((celt_word32)(1)<<((shift))>>1))),shift)) +#define PSHR32(a,shift) (celt_mips--,SHR32(ADD32((a),(((opus_val32)(1)<<((shift))>>1))),shift)) #define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) #define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) @@ -332,7 +332,7 @@ static inline int _MULT16_32_QX(int a, long long b, int Q, char *file, int line) { fprintf (stderr, "MULT16_32_Q%d: inputs are not short+int: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line); } - if (ABS32(b)>=((celt_word32)(1)<<(15+Q))) + if (ABS32(b)>=((opus_val32)(1)<<(15+Q))) fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line); res = (((long long)a)*(long long)b) >> Q; if (!VERIFY_INT(res)) @@ -351,9 +351,9 @@ static inline int MULT16_32_PX(int a, long long b, int Q) { fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d\n", Q, (int)a, (int)b); } - if (ABS32(b)>=((celt_word32)(1)<<(15+Q))) + if (ABS32(b)>=((opus_val32)(1)<<(15+Q))) fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d\n", Q, (int)a, (int)b); - res = ((((long long)a)*(long long)b) + (((celt_word32)(1)<<Q)>>1))>> Q; + res = ((((long long)a)*(long long)b) + (((opus_val32)(1)<<Q)>>1))>> Q; if (!VERIFY_INT(res)) fprintf (stderr, "MULT16_32_P%d: output is not int: %d*%d=%d\n", Q, (int)a, (int)b,(int)res); if (Q==15) diff --git a/libcelt/fixed_generic.h b/libcelt/fixed_generic.h index 007b968db..a235ffc9a 100644 --- a/libcelt/fixed_generic.h +++ b/libcelt/fixed_generic.h @@ -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)(opus_uint16)(b)) +#define MULT16_16SU(a,b) ((opus_val32)(opus_val16)(a)*(opus_val32)(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)) @@ -49,9 +49,9 @@ #define MULT32_32_Q32(a,b) ADD32(ADD32(MULT16_16(SHR((a),16),SHR((b),16)), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),16)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),16)) /** Compile-time conversion of float constant to 16-bit value */ -#define QCONST16(x,bits) ((celt_word16)(.5+(x)*(((celt_word32)1)<<(bits)))) +#define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits)))) /** Compile-time conversion of float constant to 32-bit value */ -#define QCONST32(x,bits) ((celt_word32)(.5+(x)*(((celt_word32)1)<<(bits)))) +#define QCONST32(x,bits) ((opus_val32)(.5+(x)*(((opus_val32)1)<<(bits)))) /** Negate a 16-bit value */ #define NEG16(x) (-(x)) @@ -59,9 +59,9 @@ #define NEG32(x) (-(x)) /** Change a 32-bit value into a 16-bit value. The value is assumed to fit in 16-bit, otherwise the result is undefined */ -#define EXTRACT16(x) ((celt_word16)(x)) +#define EXTRACT16(x) ((opus_val16)(x)) /** Change a 16-bit value into a 32-bit value */ -#define EXTEND32(x) ((celt_word32)(x)) +#define EXTEND32(x) ((opus_val32)(x)) /** Arithmetic shift-right of a 16-bit value */ #define SHR16(a,shift) ((a) >> (shift)) @@ -70,7 +70,7 @@ /** Arithmetic shift-right of a 32-bit value */ #define SHR32(a,shift) ((a) >> (shift)) /** Arithmetic shift-left of a 32-bit value */ -#define SHL32(a,shift) ((celt_word32)(a) << (shift)) +#define SHL32(a,shift) ((opus_val32)(a) << (shift)) /** 16-bit arithmetic shift right with rounding-to-nearest instead of rounding down */ #define PSHR16(a,shift) (SHR16((a)+((1<<((shift))>>1)),shift)) @@ -86,7 +86,7 @@ /** "RAW" macros, should not be used outside of this header file */ #define SHR(a,shift) ((a) >> (shift)) -#define SHL(a,shift) ((celt_word32)(a) << (shift)) +#define SHL(a,shift) ((opus_val32)(a) << (shift)) #define PSHR(a,shift) (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift)) #define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) @@ -97,21 +97,21 @@ #define HALF32(x) (SHR32(x,1)) /** Add two 16-bit values */ -#define ADD16(a,b) ((celt_word16)((celt_word16)(a)+(celt_word16)(b))) +#define ADD16(a,b) ((opus_val16)((opus_val16)(a)+(opus_val16)(b))) /** Subtract two 16-bit values */ -#define SUB16(a,b) ((celt_word16)(a)-(celt_word16)(b)) +#define SUB16(a,b) ((opus_val16)(a)-(opus_val16)(b)) /** Add two 32-bit values */ -#define ADD32(a,b) ((celt_word32)(a)+(celt_word32)(b)) +#define ADD32(a,b) ((opus_val32)(a)+(opus_val32)(b)) /** Subtract two 32-bit values */ -#define SUB32(a,b) ((celt_word32)(a)-(celt_word32)(b)) +#define SUB32(a,b) ((opus_val32)(a)-(opus_val32)(b)) /** 16x16 multiplication where the result fits in 16 bits */ -#define MULT16_16_16(a,b) ((((celt_word16)(a))*((celt_word16)(b)))) +#define MULT16_16_16(a,b) ((((opus_val16)(a))*((opus_val16)(b)))) -/* (celt_word32)(celt_word16) gives TI compiler a hint that it's 16x16->32 multiply */ +/* (opus_val32)(opus_val16) gives TI compiler a hint that it's 16x16->32 multiply */ /** 16x16 multiplication where the result fits in 32 bits */ -#define MULT16_16(a,b) (((celt_word32)(celt_word16)(a))*((celt_word32)(celt_word16)(b))) +#define MULT16_16(a,b) (((opus_val32)(opus_val16)(a))*((opus_val32)(opus_val16)(b))) /** 16x16 multiply-add where the result fits in 32 bits */ #define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b)))) @@ -147,12 +147,12 @@ #define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15)) /** Divide a 32-bit value by a 16-bit value. Result fits in 16 bits */ -#define DIV32_16(a,b) ((celt_word16)(((celt_word32)(a))/((celt_word16)(b)))) +#define DIV32_16(a,b) ((opus_val16)(((opus_val32)(a))/((opus_val16)(b)))) /** Divide a 32-bit value by a 16-bit value and round to nearest. Result fits in 16 bits */ -#define PDIV32_16(a,b) ((celt_word16)(((celt_word32)(a)+((celt_word16)(b)>>1))/((celt_word16)(b)))) +#define PDIV32_16(a,b) ((opus_val16)(((opus_val32)(a)+((opus_val16)(b)>>1))/((opus_val16)(b)))) /** Divide a 32-bit value by a 32-bit value. Result fits in 32 bits */ -#define DIV32(a,b) (((celt_word32)(a))/((celt_word32)(b))) +#define DIV32(a,b) (((opus_val32)(a))/((opus_val32)(b))) /** Divide a 32-bit value by a 32-bit value and round to nearest. Result fits in 32 bits */ -#define PDIV32(a,b) (((celt_word32)(a)+((celt_word16)(b)>>1))/((celt_word32)(b))) +#define PDIV32(a,b) (((opus_val32)(a)+((opus_val16)(b)>>1))/((opus_val32)(b))) #endif diff --git a/libcelt/kiss_fft.c b/libcelt/kiss_fft.c index 3c246d031..689a85248 100644 --- a/libcelt/kiss_fft.c +++ b/libcelt/kiss_fft.c @@ -570,7 +570,7 @@ static void compute_twiddles(kiss_twiddle_cpx *twiddles, int nfft) int i; #ifdef FIXED_POINT for (i=0;i<nfft;++i) { - celt_word32 phase = -i; + opus_val32 phase = -i; kf_cexp2(twiddles+i, DIV32(SHL32(phase,17),nfft)); } #else diff --git a/libcelt/mathops.c b/libcelt/mathops.c index c0ee61ed7..a48ca76c3 100644 --- a/libcelt/mathops.c +++ b/libcelt/mathops.c @@ -66,10 +66,10 @@ unsigned isqrt32(opus_uint32 _val){ #ifdef FIXED_POINT -celt_word32 frac_div32(celt_word32 a, celt_word32 b) +opus_val32 frac_div32(opus_val32 a, opus_val32 b) { - celt_word16 rcp; - celt_word32 result, rem; + opus_val16 rcp; + opus_val32 result, rem; int shift = celt_ilog2(b)-29; a = VSHR32(a,shift); b = VSHR32(b,shift); @@ -82,12 +82,12 @@ celt_word32 frac_div32(celt_word32 a, celt_word32 b) } /** Reciprocal sqrt approximation in the range [0.25,1) (Q16 in, Q14 out) */ -celt_word16 celt_rsqrt_norm(celt_word32 x) +opus_val16 celt_rsqrt_norm(opus_val32 x) { - celt_word16 n; - celt_word16 r; - celt_word16 r2; - celt_word16 y; + opus_val16 n; + opus_val16 r; + opus_val16 r2; + opus_val16 y; /* Range of n is [-16384,32767] ([-0.5,1) in Q15). */ n = x-32768; /* Get a rough initial guess for the root. @@ -110,12 +110,12 @@ celt_word16 celt_rsqrt_norm(celt_word32 x) } /** Sqrt approximation (QX input, QX/2 output) */ -celt_word32 celt_sqrt(celt_word32 x) +opus_val32 celt_sqrt(opus_val32 x) { int k; - celt_word16 n; - celt_word32 rt; - static const celt_word16 C[5] = {23175, 11561, -3011, 1699, -664}; + opus_val16 n; + opus_val32 rt; + static const opus_val16 C[5] = {23175, 11561, -3011, 1699, -664}; if (x==0) return 0; k = (celt_ilog2(x)>>1)-7; @@ -132,9 +132,9 @@ celt_word32 celt_sqrt(celt_word32 x) #define L3 8277 #define L4 -626 -static inline celt_word16 _celt_cos_pi_2(celt_word16 x) +static inline opus_val16 _celt_cos_pi_2(opus_val16 x) { - celt_word16 x2; + opus_val16 x2; x2 = MULT16_16_P15(x,x); return ADD16(1,MIN16(32766,ADD32(SUB16(L1,x2), MULT16_16_P15(x2, ADD32(L2, MULT16_16_P15(x2, ADD32(L3, MULT16_16_P15(L4, x2 @@ -146,7 +146,7 @@ static inline celt_word16 _celt_cos_pi_2(celt_word16 x) #undef L3 #undef L4 -celt_word16 celt_cos_norm(celt_word32 x) +opus_val16 celt_cos_norm(opus_val32 x) { x = x&0x0001ffff; if (x>SHL32(EXTEND32(1), 16)) @@ -170,11 +170,11 @@ celt_word16 celt_cos_norm(celt_word32 x) } /** Reciprocal approximation (Q15 input, Q16 output) */ -celt_word32 celt_rcp(celt_word32 x) +opus_val32 celt_rcp(opus_val32 x) { int i; - celt_word16 n; - celt_word16 r; + opus_val16 n; + opus_val16 r; celt_assert2(x>0, "celt_rcp() only defined for positive values"); i = celt_ilog2(x); /* n is Q15 with range [0,1). */ diff --git a/libcelt/mathops.h b/libcelt/mathops.h index 4daf917fb..a6050f231 100644 --- a/libcelt/mathops.h +++ b/libcelt/mathops.h @@ -123,10 +123,10 @@ static inline opus_int16 celt_ilog2(opus_int32 x) #ifndef OVERRIDE_CELT_MAXABS16 -static inline celt_word16 celt_maxabs16(celt_word16 *x, int len) +static inline opus_val16 celt_maxabs16(opus_val16 *x, int len) { int i; - celt_word16 maxval = 0; + opus_val16 maxval = 0; for (i=0;i<len;i++) maxval = MAX16(maxval, ABS16(x[i])); return maxval; @@ -134,25 +134,25 @@ 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 opus_int16 celt_zlog2(celt_word32 x) +static inline opus_int16 celt_zlog2(opus_val32 x) { return x <= 0 ? 0 : celt_ilog2(x); } -celt_word16 celt_rsqrt_norm(celt_word32 x); +opus_val16 celt_rsqrt_norm(opus_val32 x); -celt_word32 celt_sqrt(celt_word32 x); +opus_val32 celt_sqrt(opus_val32 x); -celt_word16 celt_cos_norm(celt_word32 x); +opus_val16 celt_cos_norm(opus_val32 x); -static inline celt_word16 celt_log2(celt_word32 x) +static inline opus_val16 celt_log2(opus_val32 x) { int i; - celt_word16 n, frac; + opus_val16 n, frac; /* -0.41509302963303146, 0.9609890551383969, -0.31836011537636605, 0.15530808010959576, -0.08556153059057618 */ - static const celt_word16 C[5] = {-6801+(1<<13-DB_SHIFT), 15746, -5217, 2545, -1401}; + static const opus_val16 C[5] = {-6801+(1<<13-DB_SHIFT), 15746, -5217, 2545, -1401}; if (x==0) return -32767; i = celt_ilog2(x); @@ -172,10 +172,10 @@ static inline celt_word16 celt_log2(celt_word32 x) #define D2 14819 #define D3 10204 /** Base-2 exponential approximation (2^x). (Q10 input, Q16 output) */ -static inline celt_word32 celt_exp2(celt_word16 x) +static inline opus_val32 celt_exp2(opus_val16 x) { int integer; - celt_word16 frac; + opus_val16 frac; integer = SHR16(x,10); if (integer>14) return 0x7f000000; @@ -186,11 +186,11 @@ static inline celt_word32 celt_exp2(celt_word16 x) return VSHR32(EXTEND32(frac), -integer-2); } -celt_word32 celt_rcp(celt_word32 x); +opus_val32 celt_rcp(opus_val32 x); -#define celt_div(a,b) MULT32_32_Q31((celt_word32)(a),celt_rcp(b)) +#define celt_div(a,b) MULT32_32_Q31((opus_val32)(a),celt_rcp(b)) -celt_word32 frac_div32(celt_word32 a, celt_word32 b); +opus_val32 frac_div32(opus_val32 a, opus_val32 b); #define M1 32767 #define M2 -21 @@ -199,7 +199,7 @@ celt_word32 frac_div32(celt_word32 a, celt_word32 b); /* Atan approximation using a 4th order polynomial. Input is in Q15 format and normalized by pi/4. Output is in Q15 format */ -static inline celt_word16 celt_atan01(celt_word16 x) +static inline opus_val16 celt_atan01(opus_val16 x) { return MULT16_16_P15(x, ADD32(M1, MULT16_16_P15(x, ADD32(M2, MULT16_16_P15(x, ADD32(M3, MULT16_16_P15(M4, x))))))); } @@ -210,17 +210,17 @@ static inline celt_word16 celt_atan01(celt_word16 x) #undef M4 /* atan2() approximation valid for positive input values */ -static inline celt_word16 celt_atan2p(celt_word16 y, celt_word16 x) +static inline opus_val16 celt_atan2p(opus_val16 y, opus_val16 x) { if (y < x) { - celt_word32 arg; + opus_val32 arg; arg = celt_div(SHL32(EXTEND32(y),15),x); if (arg >= 32767) arg = 32767; return SHR16(celt_atan01(EXTRACT16(arg)),1); } else { - celt_word32 arg; + opus_val32 arg; arg = celt_div(SHL32(EXTEND32(x),15),y); if (arg >= 32767) arg = 32767; diff --git a/libcelt/mdct.c b/libcelt/mdct.c index b67a31bcd..e0f1ca529 100644 --- a/libcelt/mdct.c +++ b/libcelt/mdct.c @@ -103,7 +103,7 @@ void clt_mdct_clear(mdct_lookup *l) #endif /* CUSTOM_MODES */ -void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const celt_word16 *window, int overlap, int shift) +void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const opus_val16 *window, int overlap, int shift) { int i; int N, N2, N4; @@ -129,8 +129,8 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar const kiss_fft_scalar * restrict xp1 = in+(overlap>>1); const kiss_fft_scalar * restrict xp2 = in+N2-1+(overlap>>1); kiss_fft_scalar * restrict yp = out; - const celt_word16 * restrict wp1 = window+(overlap>>1); - const celt_word16 * restrict wp2 = window+(overlap>>1)-1; + const opus_val16 * restrict wp1 = window+(overlap>>1); + const opus_val16 * restrict wp2 = window+(overlap>>1)-1; for(i=0;i<(overlap>>2);i++) { /* Real part arranged as -d-cR, Imag part arranged as -b+aR*/ @@ -207,7 +207,7 @@ void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar } -void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const celt_word16 * restrict window, int overlap, int shift) +void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * restrict out, const opus_val16 * restrict window, int overlap, int shift) { int i; int N, N2, N4; @@ -288,8 +288,8 @@ void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scala kiss_fft_scalar * restrict fp1 = f2+N4-1; kiss_fft_scalar * restrict xp1 = out+N2-1; kiss_fft_scalar * restrict yp1 = out+N4-overlap/2; - const celt_word16 * restrict wp1 = window; - const celt_word16 * restrict wp2 = window+overlap-1; + const opus_val16 * restrict wp1 = window; + const opus_val16 * restrict wp2 = window+overlap-1; for(i = 0; i< N4-overlap/2; i++) { *xp1 = *fp1; @@ -310,8 +310,8 @@ void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scala kiss_fft_scalar * restrict fp2 = f2+N4; kiss_fft_scalar * restrict xp2 = out+N2; kiss_fft_scalar * restrict yp2 = out+N-1-(N4-overlap/2); - const celt_word16 * restrict wp1 = window; - const celt_word16 * restrict wp2 = window+overlap-1; + const opus_val16 * restrict wp1 = window; + const opus_val16 * restrict wp2 = window+overlap-1; for(i = 0; i< N4-overlap/2; i++) { *xp2 = *fp2; diff --git a/libcelt/mdct.h b/libcelt/mdct.h index 226e1db1d..8d0af5859 100644 --- a/libcelt/mdct.h +++ b/libcelt/mdct.h @@ -56,10 +56,10 @@ int clt_mdct_init(mdct_lookup *l,int N, int maxshift); void clt_mdct_clear(mdct_lookup *l); /** Compute a forward MDCT and scale by 4/N */ -void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const celt_word16 *window, int overlap, int shift); +void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const opus_val16 *window, int overlap, int shift); /** Compute a backward MDCT (no scaling) and performs weighted overlap-add (scales implicitly by 1/2) */ -void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const celt_word16 * restrict window, int overlap, int shift); +void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar *out, const opus_val16 * restrict window, int overlap, int shift); #endif diff --git a/libcelt/modes.c b/libcelt/modes.c index bbe592ce6..09b07a3a2 100644 --- a/libcelt/modes.c +++ b/libcelt/modes.c @@ -227,7 +227,7 @@ CELTMode *celt_mode_create(opus_int32 Fs, int frame_size, int *error) #ifdef CUSTOM_MODES CELTMode *mode=NULL; int res; - celt_word16 *window; + opus_val16 *window; opus_int16 *logN; int LM; ALLOC_STACK; @@ -358,7 +358,7 @@ CELTMode *celt_mode_create(opus_int32 Fs, int frame_size, int *error) if (mode->allocVectors==NULL) goto failure; - window = (celt_word16*)celt_alloc(mode->overlap*sizeof(celt_word16)); + window = (opus_val16*)celt_alloc(mode->overlap*sizeof(opus_val16)); if (window==NULL) goto failure; @@ -416,7 +416,7 @@ void celt_mode_destroy(CELTMode *mode) celt_free((opus_int16*)mode->eBands); celt_free((opus_int16*)mode->allocVectors); - celt_free((celt_word16*)mode->window); + celt_free((opus_val16*)mode->window); celt_free((opus_int16*)mode->logN); celt_free((opus_int16*)mode->cache.index); diff --git a/libcelt/modes.h b/libcelt/modes.h index 7e4f7c28a..1c025f5c9 100644 --- a/libcelt/modes.h +++ b/libcelt/modes.h @@ -73,7 +73,7 @@ struct CELTMode { int nbEBands; int effEBands; - celt_word16 preemph[4]; + opus_val16 preemph[4]; const opus_int16 *eBands; /**< Definition for each "pseudo-critical band" */ int nbAllocVectors; /**< Number of lines in the matrix below */ @@ -82,7 +82,7 @@ struct CELTMode { /* Stuff that could go in the {en,de}coder, but we save space this way */ mdct_lookup mdct; - const celt_word16 *window; + const opus_val16 *window; int maxLM; int nbShortMdcts; diff --git a/libcelt/pitch.c b/libcelt/pitch.c index a35131e91..3173b151e 100644 --- a/libcelt/pitch.c +++ b/libcelt/pitch.c @@ -42,13 +42,13 @@ #include "stack_alloc.h" #include "mathops.h" -static void find_best_pitch(celt_word32 *xcorr, celt_word32 maxcorr, celt_word16 *y, +static void find_best_pitch(opus_val32 *xcorr, opus_val32 maxcorr, opus_val16 *y, int yshift, int len, int max_pitch, int best_pitch[2]) { int i, j; - celt_word32 Syy=1; - celt_word16 best_num[2]; - celt_word32 best_den[2]; + opus_val32 Syy=1; + opus_val16 best_num[2]; + opus_val32 best_den[2]; #ifdef FIXED_POINT int xshift; @@ -67,8 +67,8 @@ static void find_best_pitch(celt_word32 *xcorr, celt_word32 maxcorr, celt_word16 { if (xcorr[i]>0) { - celt_word16 num; - celt_word32 xcorr16; + opus_val16 num; + opus_val32 xcorr16; xcorr16 = EXTRACT16(VSHR32(xcorr[i], xshift)); num = MULT16_16_Q15(xcorr16,xcorr16); if (MULT16_32_Q15(num,best_den[1]) > MULT16_32_Q15(best_num[1],Syy)) @@ -94,13 +94,13 @@ static void find_best_pitch(celt_word32 *xcorr, celt_word32 maxcorr, celt_word16 } #include "plc.h" -void pitch_downsample(celt_sig * restrict x[], celt_word16 * restrict x_lp, +void pitch_downsample(celt_sig * restrict x[], opus_val16 * restrict x_lp, int len, int _C) { int i; - celt_word32 ac[5]; - celt_word16 tmp=Q15ONE; - celt_word16 lpc[4], mem[4]={0,0,0,0}; + opus_val32 ac[5]; + opus_val16 tmp=Q15ONE; + opus_val16 lpc[4], mem[4]={0,0,0,0}; const int C = CHANNELS(_C); for (i=1;i<len>>1;i++) x_lp[i] = SHR32(HALF32(HALF32(x[0][(2*i-1)]+x[0][(2*i+1)])+x[0][2*i]), SIG_SHIFT+3); @@ -146,16 +146,16 @@ void pitch_downsample(celt_sig * restrict x[], celt_word16 * restrict x_lp, } -void pitch_search(const celt_word16 * restrict x_lp, celt_word16 * restrict y, +void pitch_search(const opus_val16 * restrict x_lp, opus_val16 * restrict y, int len, int max_pitch, int *pitch) { int i, j; int lag; int best_pitch[2]={0}; - VARDECL(celt_word16, x_lp4); - VARDECL(celt_word16, y_lp4); - VARDECL(celt_word32, xcorr); - celt_word32 maxcorr=1; + VARDECL(opus_val16, x_lp4); + VARDECL(opus_val16, y_lp4); + VARDECL(opus_val32, xcorr); + opus_val32 maxcorr=1; int offset; int shift=0; @@ -163,9 +163,9 @@ void pitch_search(const celt_word16 * restrict x_lp, celt_word16 * restrict y, lag = len+max_pitch; - ALLOC(x_lp4, len>>2, celt_word16); - ALLOC(y_lp4, lag>>2, celt_word16); - ALLOC(xcorr, max_pitch>>1, celt_word32); + ALLOC(x_lp4, len>>2, opus_val16); + ALLOC(y_lp4, lag>>2, opus_val16); + ALLOC(xcorr, max_pitch>>1, opus_val32); /* Downsample by 2 again */ for (j=0;j<len>>2;j++) @@ -192,7 +192,7 @@ void pitch_search(const celt_word16 * restrict x_lp, celt_word16 * restrict y, for (i=0;i<max_pitch>>2;i++) { - celt_word32 sum = 0; + opus_val32 sum = 0; for (j=0;j<len>>2;j++) sum = MAC16_16(sum, x_lp4[j],y_lp4[i+j]); xcorr[i] = MAX32(-1, sum); @@ -204,7 +204,7 @@ void pitch_search(const celt_word16 * restrict x_lp, celt_word16 * restrict y, maxcorr=1; for (i=0;i<max_pitch>>1;i++) { - celt_word32 sum=0; + opus_val32 sum=0; xcorr[i] = 0; if (abs(i-2*best_pitch[0])>2 && abs(i-2*best_pitch[1])>2) continue; @@ -218,7 +218,7 @@ void pitch_search(const celt_word16 * restrict x_lp, celt_word16 * restrict y, /* Refine by pseudo-interpolation */ if (best_pitch[0]>0 && best_pitch[0]<(max_pitch>>1)-1) { - celt_word32 a, b, c; + opus_val32 a, b, c; a = xcorr[best_pitch[0]-1]; b = xcorr[best_pitch[0]]; c = xcorr[best_pitch[0]+1]; @@ -237,15 +237,15 @@ void pitch_search(const celt_word16 * restrict x_lp, celt_word16 * restrict y, } static const int second_check[16] = {0, 0, 3, 2, 3, 2, 5, 2, 3, 2, 3, 2, 5, 2, 3, 2}; -celt_word16 remove_doubling(celt_word16 *x, int maxperiod, int minperiod, - int N, int *_T0, int prev_period, celt_word16 prev_gain) +opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, + int N, int *_T0, int prev_period, opus_val16 prev_gain) { int k, i, T, T0; - celt_word16 g, g0; - celt_word16 pg; - celt_word32 xy,xx,yy; - celt_word32 xcorr[3]; - celt_word32 best_xy, best_yy; + opus_val16 g, g0; + opus_val16 pg; + opus_val32 xy,xx,yy; + opus_val32 xcorr[3]; + opus_val32 best_xy, best_yy; int offset; int minperiod0; @@ -271,7 +271,7 @@ celt_word16 remove_doubling(celt_word16 *x, int maxperiod, int minperiod, best_yy = yy; #ifdef FIXED_POINT { - celt_word32 x2y2; + opus_val32 x2y2; int sh, t; x2y2 = 1+HALF32(MULT32_32_Q31(xx,yy)); sh = celt_ilog2(x2y2)>>1; @@ -285,8 +285,8 @@ celt_word16 remove_doubling(celt_word16 *x, int maxperiod, int minperiod, for (k=2;k<=15;k++) { int T1, T1b; - celt_word16 g1; - celt_word16 cont=0; + opus_val16 g1; + opus_val16 cont=0; T1 = (2*T0+k)/(2*k); if (T1 < minperiod) break; @@ -312,7 +312,7 @@ celt_word16 remove_doubling(celt_word16 *x, int maxperiod, int minperiod, } #ifdef FIXED_POINT { - celt_word32 x2y2; + opus_val32 x2y2; int sh, t; x2y2 = 1+MULT32_32_Q31(xx,yy); sh = celt_ilog2(x2y2)>>1; diff --git a/libcelt/pitch.h b/libcelt/pitch.h index 03e089600..291f5a698 100644 --- a/libcelt/pitch.h +++ b/libcelt/pitch.h @@ -37,13 +37,13 @@ #include "modes.h" -void pitch_downsample(celt_sig * restrict x[], celt_word16 * restrict x_lp, +void pitch_downsample(celt_sig * restrict x[], opus_val16 * restrict x_lp, int len, int _C); -void pitch_search(const celt_word16 * restrict x_lp, celt_word16 * restrict y, +void pitch_search(const opus_val16 * restrict x_lp, opus_val16 * restrict y, int len, int max_pitch, int *pitch); -celt_word16 remove_doubling(celt_word16 *x, int maxperiod, int minperiod, - int N, int *T0, int prev_period, celt_word16 prev_gain); +opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, + int N, int *T0, int prev_period, opus_val16 prev_gain); #endif diff --git a/libcelt/plc.c b/libcelt/plc.c index 74194e02f..64cb92aad 100644 --- a/libcelt/plc.c +++ b/libcelt/plc.c @@ -37,16 +37,16 @@ void _celt_lpc( - celt_word16 *_lpc, /* out: [0...p-1] LPC coefficients */ -const celt_word32 *ac, /* in: [0...p] autocorrelation values */ + opus_val16 *_lpc, /* out: [0...p-1] LPC coefficients */ +const opus_val32 *ac, /* in: [0...p] autocorrelation values */ int p ) { int i, j; - celt_word32 r; - celt_word32 error = ac[0]; + opus_val32 r; + opus_val32 error = ac[0]; #ifdef FIXED_POINT - celt_word32 lpc[LPC_ORDER]; + opus_val32 lpc[LPC_ORDER]; #else float *lpc = _lpc; #endif @@ -57,7 +57,7 @@ int p { for (i = 0; i < p; i++) { /* Sum up this iteration's reflection coefficient */ - celt_word32 rr = 0; + opus_val32 rr = 0; for (j = 0; j < i; j++) rr += MULT32_32_Q31(lpc[j],ac[i - j]); rr += SHR32(ac[i + 1],3); @@ -66,7 +66,7 @@ int p lpc[i] = SHR32(r,3); for (j = 0; j < (i+1)>>1; j++) { - celt_word32 tmp1, tmp2; + opus_val32 tmp1, tmp2; tmp1 = lpc[j]; tmp2 = lpc[i-1-j]; lpc[j] = tmp1 + MULT32_32_Q31(r,tmp2); @@ -90,18 +90,18 @@ int p #endif } -void fir(const celt_word16 *x, - const celt_word16 *num, - celt_word16 *y, +void fir(const opus_val16 *x, + const opus_val16 *num, + opus_val16 *y, int N, int ord, - celt_word16 *mem) + opus_val16 *mem) { int i,j; for (i=0;i<N;i++) { - celt_word32 sum = SHL32(EXTEND32(x[i]), SIG_SHIFT); + opus_val32 sum = SHL32(EXTEND32(x[i]), SIG_SHIFT); for (j=0;j<ord;j++) { sum += MULT16_16(num[j],mem[j]); @@ -115,17 +115,17 @@ void fir(const celt_word16 *x, } } -void iir(const celt_word32 *x, - const celt_word16 *den, - celt_word32 *y, +void iir(const opus_val32 *x, + const opus_val16 *den, + opus_val32 *y, int N, int ord, - celt_word16 *mem) + opus_val16 *mem) { int i,j; for (i=0;i<N;i++) { - celt_word32 sum = x[i]; + opus_val32 sum = x[i]; for (j=0;j<ord;j++) { sum -= MULT16_16(den[j],mem[j]); @@ -140,19 +140,19 @@ void iir(const celt_word32 *x, } void _celt_autocorr( - const celt_word16 *x, /* in: [0...n-1] samples x */ - celt_word32 *ac, /* out: [0...lag-1] ac values */ - const celt_word16 *window, + const opus_val16 *x, /* in: [0...n-1] samples x */ + opus_val32 *ac, /* out: [0...lag-1] ac values */ + const opus_val16 *window, int overlap, int lag, int n ) { - celt_word32 d; + opus_val32 d; int i; - VARDECL(celt_word16, xx); + VARDECL(opus_val16, xx); SAVE_STACK; - ALLOC(xx, n, celt_word16); + ALLOC(xx, n, opus_val16); for (i=0;i<n;i++) xx[i] = x[i]; for (i=0;i<overlap;i++) @@ -162,7 +162,7 @@ void _celt_autocorr( } #ifdef FIXED_POINT { - celt_word32 ac0=0; + opus_val32 ac0=0; int shift; for(i=0;i<n;i++) ac0 += SHR32(MULT16_16(xx[i],xx[i]),8); diff --git a/libcelt/plc.h b/libcelt/plc.h index 70a5ba240..47635183d 100644 --- a/libcelt/plc.h +++ b/libcelt/plc.h @@ -32,24 +32,24 @@ #define LPC_ORDER 24 -void _celt_lpc(celt_word16 *_lpc, const celt_word32 *ac, int p); +void _celt_lpc(opus_val16 *_lpc, const opus_val32 *ac, int p); -void fir(const celt_word16 *x, - const celt_word16 *num, - celt_word16 *y, +void fir(const opus_val16 *x, + const opus_val16 *num, + opus_val16 *y, int N, int ord, - celt_word16 *mem); + opus_val16 *mem); -void iir(const celt_word32 *x, - const celt_word16 *den, - celt_word32 *y, +void iir(const opus_val32 *x, + const opus_val16 *den, + opus_val32 *y, int N, int ord, - celt_word16 *mem); + opus_val16 *mem); -void _celt_autocorr(const celt_word16 *x, celt_word32 *ac, const celt_word16 *window, int overlap, int lag, int n); +void _celt_autocorr(const opus_val16 *x, opus_val32 *ac, const opus_val16 *window, int overlap, int lag, int n); #endif /* PLC_H */ diff --git a/libcelt/quant_bands.c b/libcelt/quant_bands.c index 42672f768..82dd8d60f 100644 --- a/libcelt/quant_bands.c +++ b/libcelt/quant_bands.c @@ -50,7 +50,7 @@ static const signed char eMeans[25] = { }; #else /* Mean energy in each band quantized in Q6 and converted back to float */ -static const celt_word16 eMeans[25] = { +static const opus_val16 eMeans[25] = { 6.437500f, 6.250000f, 5.750000f, 5.312500f, 5.062500f, 4.812500f, 4.500000f, 4.375000f, 4.875000f, 4.687500f, 4.562500f, 4.437500f, 4.875000f, 4.625000f, 4.312500f, @@ -60,13 +60,13 @@ static const celt_word16 eMeans[25] = { #endif /* prediction coefficients: 0.9, 0.8, 0.65, 0.5 */ #ifdef FIXED_POINT -static const celt_word16 pred_coef[4] = {29440, 26112, 21248, 16384}; -static const celt_word16 beta_coef[4] = {30147, 22282, 12124, 6554}; -static const celt_word16 beta_intra = 4915; +static const opus_val16 pred_coef[4] = {29440, 26112, 21248, 16384}; +static const opus_val16 beta_coef[4] = {30147, 22282, 12124, 6554}; +static const opus_val16 beta_intra = 4915; #else -static const celt_word16 pred_coef[4] = {29440/32768., 26112/32768., 21248/32768., 16384/32768.}; -static const celt_word16 beta_coef[4] = {30147/32768., 22282/32768., 12124/32768., 6554/32768.}; -static const celt_word16 beta_intra = 4915/32768.; +static const opus_val16 pred_coef[4] = {29440/32768., 26112/32768., 21248/32768., 16384/32768.}; +static const opus_val16 beta_coef[4] = {30147/32768., 22282/32768., 12124/32768., 6554/32768.}; +static const opus_val16 beta_intra = 4915/32768.; #endif /*Parameters of the Laplace-like probability models used for the coarse energy. @@ -139,14 +139,14 @@ static const unsigned char e_prob_model[4][2][42] = { static const unsigned char small_energy_icdf[3]={2,1,0}; -static celt_word32 loss_distortion(const celt_word16 *eBands, celt_word16 *oldEBands, int start, int end, int len, int C) +static opus_val32 loss_distortion(const opus_val16 *eBands, opus_val16 *oldEBands, int start, int end, int len, int C) { int c, i; - celt_word32 dist = 0; + opus_val32 dist = 0; c=0; do { for (i=start;i<end;i++) { - celt_word16 d = SHR16(SUB16(eBands[i+c*len], oldEBands[i+c*len]),2); + opus_val16 d = SHR16(SUB16(eBands[i+c*len], oldEBands[i+c*len]),2); dist = MAC16_16(dist, d,d); } } while (++c<C); @@ -154,17 +154,17 @@ 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, + const opus_val16 *eBands, opus_val16 *oldEBands, 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) + const unsigned char *prob_model, opus_val16 *error, ec_enc *enc, + int _C, int LM, int intra, opus_val16 max_decay) { const int C = CHANNELS(_C); int i, c; int badness = 0; - celt_word32 prev[2] = {0,0}; - celt_word16 coef; - celt_word16 beta; + opus_val32 prev[2] = {0,0}; + opus_val16 coef; + opus_val16 beta; if (tell+3 <= budget) ec_enc_bit_logp(enc, intra, 3); @@ -184,11 +184,11 @@ static int quant_coarse_energy_impl(const CELTMode *m, int start, int end, do { int bits_left; int qi, qi0; - celt_word32 q; - celt_word16 x; - celt_word32 f, tmp; - celt_word16 oldE; - celt_word16 decay_bound; + opus_val32 q; + opus_val16 x; + opus_val32 f, tmp; + opus_val16 oldE; + opus_val16 decay_bound; x = eBands[i+c*m->nbEBands]; oldE = MAX16(-QCONST16(9.f,DB_SHIFT), oldEBands[i+c*m->nbEBands]); #ifdef FIXED_POINT @@ -196,7 +196,7 @@ static int quant_coarse_energy_impl(const CELTMode *m, int start, int end, /* Rounding to nearest integer here is really important! */ qi = (f+QCONST32(.5f,DB_SHIFT+7))>>(DB_SHIFT+7); decay_bound = EXTRACT16(MAX32(-QCONST16(28.f,DB_SHIFT), - SUB32((celt_word32)oldEBands[i+c*m->nbEBands],max_decay))); + SUB32((opus_val32)oldEBands[i+c*m->nbEBands],max_decay))); #else f = x-coef*oldE-prev[c]; /* Rounding to nearest integer here is really important! */ @@ -258,20 +258,20 @@ 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, 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) + const opus_val16 *eBands, opus_val16 *oldEBands, opus_uint32 budget, + opus_val16 *error, ec_enc *enc, int _C, int LM, int nbAvailableBytes, + int force_intra, opus_val32 *delayedIntra, int two_pass, int loss_rate) { const int C = CHANNELS(_C); int intra; - celt_word16 max_decay; - VARDECL(celt_word16, oldEBands_intra); - VARDECL(celt_word16, error_intra); + opus_val16 max_decay; + VARDECL(opus_val16, oldEBands_intra); + VARDECL(opus_val16, error_intra); ec_enc enc_start_state; opus_uint32 tell; int badness1=0; opus_int32 intra_bias; - celt_word32 new_distortion; + opus_val32 new_distortion; SAVE_STACK; intra = force_intra || (!two_pass && *delayedIntra>2*C*(end-start) && nbAvailableBytes > (end-start)*C); @@ -293,8 +293,8 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, enc_start_state = *enc; - ALLOC(oldEBands_intra, C*m->nbEBands, celt_word16); - ALLOC(error_intra, C*m->nbEBands, celt_word16); + ALLOC(oldEBands_intra, C*m->nbEBands, opus_val16); + ALLOC(error_intra, C*m->nbEBands, opus_val16); CELT_COPY(oldEBands_intra, oldEBands, C*m->nbEBands); if (two_pass || intra) @@ -353,7 +353,7 @@ void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, RESTORE_STACK; } -void quant_fine_energy(const CELTMode *m, int start, int end, celt_word16 *oldEBands, celt_word16 *error, int *fine_quant, ec_enc *enc, int _C) +void quant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, ec_enc *enc, int _C) { int i, c; const int C = CHANNELS(_C); @@ -367,7 +367,7 @@ void quant_fine_energy(const CELTMode *m, int start, int end, celt_word16 *oldEB c=0; do { int q2; - celt_word16 offset; + opus_val16 offset; #ifdef FIXED_POINT /* Has to be without rounding */ q2 = (error[i+c*m->nbEBands]+QCONST16(.5f,DB_SHIFT))>>(DB_SHIFT-fine_quant[i]); @@ -391,7 +391,7 @@ void quant_fine_energy(const CELTMode *m, int start, int end, celt_word16 *oldEB } } -void quant_energy_finalise(const CELTMode *m, int start, int end, celt_word16 *oldEBands, celt_word16 *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int _C) +void quant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int _C) { int i, prio, c; const int C = CHANNELS(_C); @@ -406,7 +406,7 @@ void quant_energy_finalise(const CELTMode *m, int start, int end, celt_word16 *o c=0; do { int q2; - celt_word16 offset; + opus_val16 offset; q2 = error[i+c*m->nbEBands]<0 ? 0 : 1; ec_enc_bits(enc, q2, 1); #ifdef FIXED_POINT @@ -421,13 +421,13 @@ void quant_energy_finalise(const CELTMode *m, int start, int end, celt_word16 *o } } -void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_word16 *oldEBands, int intra, ec_dec *dec, int _C, int LM) +void unquant_coarse_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int intra, ec_dec *dec, int _C, int LM) { const unsigned char *prob_model = e_prob_model[LM][intra]; int i, c; - celt_word32 prev[2] = {0, 0}; - celt_word16 coef; - celt_word16 beta; + opus_val32 prev[2] = {0, 0}; + opus_val16 coef; + opus_val16 beta; const int C = CHANNELS(_C); opus_int32 budget; opus_int32 tell; @@ -450,8 +450,8 @@ void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_word16 *o c=0; do { int qi; - celt_word32 q; - celt_word32 tmp; + opus_val32 q; + opus_val32 tmp; tell = ec_tell(dec); if(budget-tell>=15) { @@ -484,7 +484,7 @@ void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_word16 *o } } -void unquant_fine_energy(const CELTMode *m, int start, int end, celt_word16 *oldEBands, int *fine_quant, ec_dec *dec, int _C) +void unquant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, ec_dec *dec, int _C) { int i, c; const int C = CHANNELS(_C); @@ -496,7 +496,7 @@ void unquant_fine_energy(const CELTMode *m, int start, int end, celt_word16 *old c=0; do { int q2; - celt_word16 offset; + opus_val16 offset; q2 = ec_dec_bits(dec, fine_quant[i]); #ifdef FIXED_POINT offset = SUB16(SHR32(SHL32(EXTEND32(q2),DB_SHIFT)+QCONST16(.5f,DB_SHIFT),fine_quant[i]),QCONST16(.5f,DB_SHIFT)); @@ -508,7 +508,7 @@ void unquant_fine_energy(const CELTMode *m, int start, int end, celt_word16 *old } } -void unquant_energy_finalise(const CELTMode *m, int start, int end, celt_word16 *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int _C) +void unquant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int _C) { int i, prio, c; const int C = CHANNELS(_C); @@ -523,7 +523,7 @@ void unquant_energy_finalise(const CELTMode *m, int start, int end, celt_word16 c=0; do { int q2; - celt_word16 offset; + opus_val16 offset; q2 = ec_dec_bits(dec, 1); #ifdef FIXED_POINT offset = SHR16(SHL16(q2,DB_SHIFT)-QCONST16(.5f,DB_SHIFT),fine_quant[i]+1); @@ -538,7 +538,7 @@ void unquant_energy_finalise(const CELTMode *m, int start, int end, celt_word16 } void log2Amp(const CELTMode *m, int start, int end, - celt_ener *eBands, celt_word16 *oldEBands, int _C) + celt_ener *eBands, opus_val16 *oldEBands, int _C) { int c, i; const int C = CHANNELS(_C); @@ -548,8 +548,8 @@ void log2Amp(const CELTMode *m, int start, int end, eBands[i+c*m->nbEBands] = 0; for (;i<end;i++) { - celt_word16 lg = ADD16(oldEBands[i+c*m->nbEBands], - SHL16((celt_word16)eMeans[i],6)); + opus_val16 lg = ADD16(oldEBands[i+c*m->nbEBands], + SHL16((opus_val16)eMeans[i],6)); eBands[i+c*m->nbEBands] = PSHR32(celt_exp2(lg),4); } for (;i<m->nbEBands;i++) @@ -558,7 +558,7 @@ void log2Amp(const CELTMode *m, int start, int end, } void amp2Log2(const CELTMode *m, int effEnd, int end, - celt_ener *bandE, celt_word16 *bandLogE, int _C) + celt_ener *bandE, opus_val16 *bandLogE, int _C) { int c, i; const int C = CHANNELS(_C); @@ -567,7 +567,7 @@ void amp2Log2(const CELTMode *m, int effEnd, int end, for (i=0;i<effEnd;i++) bandLogE[i+c*m->nbEBands] = celt_log2(SHL32(bandE[i+c*m->nbEBands],2)) - - SHL16((celt_word16)eMeans[i],6); + - SHL16((opus_val16)eMeans[i],6); for (i=effEnd;i<end;i++) bandLogE[c*m->nbEBands+i] = -QCONST16(14.f,DB_SHIFT); } while (++c < C); diff --git a/libcelt/quant_bands.h b/libcelt/quant_bands.h index 74097cade..6694cf265 100644 --- a/libcelt/quant_bands.h +++ b/libcelt/quant_bands.h @@ -36,28 +36,28 @@ #include "mathops.h" void amp2Log2(const CELTMode *m, int effEnd, int end, - celt_ener *bandE, celt_word16 *bandLogE, int _C); + celt_ener *bandE, opus_val16 *bandLogE, int _C); void log2Amp(const CELTMode *m, int start, int end, - celt_ener *eBands, celt_word16 *oldEBands, int _C); + celt_ener *eBands, opus_val16 *oldEBands, int _C); unsigned char *quant_prob_alloc(const CELTMode *m); 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, opus_uint32 budget, - celt_word16 *error, ec_enc *enc, int _C, int LM, - int nbAvailableBytes, int force_intra, celt_word32 *delayedIntra, + const opus_val16 *eBands, opus_val16 *oldEBands, opus_uint32 budget, + opus_val16 *error, ec_enc *enc, int _C, int LM, + int nbAvailableBytes, int force_intra, opus_val32 *delayedIntra, int two_pass, int loss_rate); -void quant_fine_energy(const CELTMode *m, int start, int end, celt_word16 *oldEBands, celt_word16 *error, int *fine_quant, ec_enc *enc, int _C); +void quant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, ec_enc *enc, int _C); -void quant_energy_finalise(const CELTMode *m, int start, int end, celt_word16 *oldEBands, celt_word16 *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int _C); +void quant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, opus_val16 *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int _C); -void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_word16 *oldEBands, int intra, ec_dec *dec, int _C, int LM); +void unquant_coarse_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int intra, ec_dec *dec, int _C, int LM); -void unquant_fine_energy(const CELTMode *m, int start, int end, celt_word16 *oldEBands, int *fine_quant, ec_dec *dec, int _C); +void unquant_fine_energy(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, ec_dec *dec, int _C); -void unquant_energy_finalise(const CELTMode *m, int start, int end, celt_word16 *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int _C); +void unquant_energy_finalise(const CELTMode *m, int start, int end, opus_val16 *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int _C); #endif /* QUANT_BANDS */ diff --git a/libcelt/static_modes_fixed.c b/libcelt/static_modes_fixed.c index 5b12a2688..1c984a2c9 100644 --- a/libcelt/static_modes_fixed.c +++ b/libcelt/static_modes_fixed.c @@ -5,7 +5,7 @@ #ifndef DEF_WINDOW120 #define DEF_WINDOW120 -static const celt_word16 window120[120] = { +static const opus_val16 window120[120] = { 2, 20, 55, 108, 178, 266, 372, 494, 635, 792, 966, 1157, 1365, 1590, 1831, 2089, 2362, 2651, 2956, 3276, 3611, 3961, 4325, 4703, 5094, 5499, 5916, 6346, 6788, 7241, 7705, 8179, 8663, 9156, 9657, 10167, 10684, 11207, 11736, 12271, 12810, 13353, 13899, 14447, 14997, 15547, 16098, 16648, 17197, 17744, 18287, 18827, 19363, 19893, 20418, 20936, 21447, 21950, 22445, 22931, 23407, 23874, 24330, 24774, 25208, 25629, 26039, 26435, 26819, 27190, 27548, 27893, 28224, 28541, 28845, 29135, 29411, 29674, 29924, 30160, 30384, 30594, 30792, 30977, 31151, 31313, 31463, 31602, 31731, 31849, 31958, 32057, 32148, 32229, 32303, 32370, 32429, 32481, 32528, 32568, 32604, 32634, 32661, 32683, 32701, 32717, 32729, 32740, 32748, 32754, 32758, 32762, 32764, 32766, 32767, 32767, 32767, 32767, 32767, 32767, }; #endif @@ -101,7 +101,7 @@ fft_twiddles48000_960, /* bitrev */ #ifndef MDCT_TWIDDLES960 #define MDCT_TWIDDLES960 -static const celt_word16 mdct_twiddles960[481] = { +static const opus_val16 mdct_twiddles960[481] = { 32767, 32767, 32767, 32767, 32766, 32763, 32762, 32759, 32757, 32753, 32751, 32747, 32743, 32738, 32733, 32729, 32724, 32717, 32711, 32705, 32698, 32690, 32683, 32676, 32667, 32658, 32650, 32640, 32631, 32620, 32610, 32599, 32588, 32577, 32566, 32554, 32541, 32528, 32515, 32502, 32487, 32474, 32459, 32444, 32429, 32413, 32397, 32381, 32364, 32348, 32331, 32313, 32294, 32277, 32257, 32239, 32219, 32200, 32180, 32159, 32138, 32118, 32096, 32074, 32051, 32029, 32006, 31984, 31960, 31936, 31912, 31888, 31863, 31837, 31812, 31786, 31760, 31734, 31707, 31679, 31652, 31624, 31596, 31567, 31539, 31508, 31479, 31450, 31419, 31388, 31357, 31326, 31294, 31262, 31230, 31198, 31164, 31131, 31097, 31063, 31030, 30994, 30959, 30924, 30889, 30853, 30816, 30779, 30743, 30705, 30668, 30629, 30592, 30553, 30515, 30475, 30435, 30396, 30356, 30315, 30274, 30233, 30191, 30149, 30107, 30065, 30022, 29979, 29936, 29891, 29847, 29803, 29758, 29713, 29668, 29622, 29577, 29529, 29483, 29436, 29390, 29341, 29293, 29246, 29197, 29148, 29098, 29050, 29000, 28949, 28899, 28848, 28797, 28746, 28694, 28642, 28590, 28537, 28485, 28432, 28378, 28324, 28271, 28217, 28162, 28106, 28051, 27995, 27940, 27884, 27827, 27770, 27713, 27657, 27598, 27540, 27481, 27423, 27365, 27305, 27246, 27187, 27126, 27066, 27006, 26945, 26883, 26822, 26760, 26698, 26636, 26574, 26510, 26448, 26383, 26320, 26257, 26191, 26127, 26062, 25997, 25931, 25866, 25800, 25734, 25667, 25601, 25533, 25466, 25398, 25330, 25262, 25194, 25125, 25056, 24987, 24917, 24848, 24778, 24707, 24636, 24566, 24495, 24424, 24352, 24280, 24208, 24135, 24063, 23990, 23917, 23842, 23769, 23695, 23622, 23546, 23472, 23398, 23322, 23246, 23171, 23095, 23018, 22942, 22866, 22788, 22711, 22634, 22557, 22478, 22400, 22322, 22244, 22165, 22085, 22006, 21927, 21846, 21766, 21687, 21606, 21524, 21443, 21363, 21282, 21199, 21118, 21035, 20954, 20870, 20788, 20705, 20621, 20538, 20455, 20371, 20286, 20202, 20118, 20034, 19947, 19863, 19777, 19692, 19606, 19520, 19434, 19347, 19260, 19174, 19088, 18999, 18911, 18825, 18737, 18648, 18560, 18472, 18384, 18294, 18205, 18116, 18025, 17936, 17846, 17757, 17666, 17576, 17485, 17395, 17303, 17212, 17122, 17030, 16937, 16846, 16755, 16662, 16569, 16477, 16385, 16291, 16198, 16105, 16012, 15917, 15824, 15730, 15636, 15541, 15447, 15352, 15257, 15162, 15067, 14973, 14875, 14781, 14685, 14589, 14493, 14396, 14300, 14204, 14107, 14010, 13914, 13815, 13718, 13621, 13524, 13425, 13328, 13230, 13133, 13033, 12935, 12836, 12738, 12638, 12540, 12441, 12341, 12241, 12142, 12044, 11943, 11843, 11744, 11643, 11542, 11442, 11342, 11241, 11139, 11039, 10939, 10836, 10736, 10635, 10534, 10431, 10330, 10228, 10127, 10024, 9921, 9820, 9718, 9614, 9512, 9410, 9306, 9204, 9101, 8998, 8895, 8791, 8689, 8585, 8481, 8377, 8274, 8171, 8067, 7962, 7858, 7753, 7650, 7545, 7441, 7336, 7231, 7129, 7023, 6917, 6813, 6709, 6604, 6498, 6393, 6288, 6182, 6077, 5973, 5867, 5760, 5656, 5549, 5445, 5339, 5232, 5127, 5022, 4914, 4809, 4703, 4596, 4490, 4384, 4278, 4171, 4065, 3958, 3852, 3745, 3640, 3532, 3426, 3318, 3212, 3106, 2998, 2891, 2786, 2679, 2570, 2465, 2358, 2251, 2143, 2037, 1929, 1823, 1715, 1609, 1501, 1393, 1287, 1180, 1073, 964, 858, 751, 644, 535, 429, 322, 214, 107, 0, }; #endif diff --git a/libcelt/static_modes_float.c b/libcelt/static_modes_float.c index 01b34cee2..9e21a86b7 100644 --- a/libcelt/static_modes_float.c +++ b/libcelt/static_modes_float.c @@ -5,7 +5,7 @@ #ifndef DEF_WINDOW120 #define DEF_WINDOW120 -static const celt_word16 window120[120] = { +static const opus_val16 window120[120] = { 0.000067, 0.000606, 0.001682, 0.003295, 0.005444, 0.008128, 0.011344, 0.015091, 0.019365, 0.024164, 0.029483, 0.035320, 0.041669, 0.048525, 0.055884, 0.063738, 0.072082, 0.080907, 0.090208, 0.099974, 0.110198, 0.120869, 0.131977, 0.143512, 0.155462, 0.167814, 0.180555, 0.193673, 0.207152, 0.220977, 0.235132, 0.249602, 0.264369, 0.279414, 0.294720, 0.310268, 0.326038, 0.342009, 0.358162, 0.374474, 0.390925, 0.407491, 0.424152, 0.440884, 0.457665, 0.474471, 0.491280, 0.508068, 0.524813, 0.541491, 0.558080, 0.574557, 0.590900, 0.607088, 0.623100, 0.638913, 0.654509, 0.669868, 0.684971, 0.699800, 0.714339, 0.728571, 0.742480, 0.756054, 0.769279, 0.782143, 0.794634, 0.806744, 0.818465, 0.829787, 0.840707, 0.851218, 0.861317, 0.871002, 0.880271, 0.889125, 0.897564, 0.905591, 0.913209, 0.920423, 0.927237, 0.933660, 0.939697, 0.945357, 0.950649, 0.955584, 0.960171, 0.964422, 0.968349, 0.971963, 0.975279, 0.978309, 0.981066, 0.983565, 0.985819, 0.987842, 0.989649, 0.991253, 0.992669, 0.993910, 0.994990, 0.995923, 0.996722, 0.997399, 0.997967, 0.998437, 0.998822, 0.999132, 0.999376, 0.999565, 0.999708, 0.999812, 0.999886, 0.999936, 0.999967, 0.999985, 0.999995, 0.999999, 1.000000, 1.000000, }; #endif @@ -105,7 +105,7 @@ fft_twiddles48000_960, /* bitrev */ #ifndef MDCT_TWIDDLES960 #define MDCT_TWIDDLES960 -static const celt_word16 mdct_twiddles960[481] = { +static const opus_val16 mdct_twiddles960[481] = { 1.000000, 0.999995, 0.999979, 0.999952, 0.999914, 0.999866, 0.999807, 0.999738, 0.999657, 0.999566, 0.999465, 0.999352, 0.999229, 0.999095, 0.998951, 0.998795, 0.998630, 0.998453, 0.998266, 0.998068, 0.997859, 0.997640, 0.997409, 0.997169, 0.996917, 0.996655, 0.996382, 0.996099, 0.995805, 0.995500, 0.995185, 0.994859, 0.994522, 0.994174, 0.993816, 0.993448, 0.993068, 0.992679, 0.992278, 0.991867, 0.991445, 0.991012, 0.990569, 0.990116, 0.989651, 0.989177, 0.988691, 0.988195, 0.987688, 0.987171, 0.986643, 0.986105, 0.985556, 0.984997, 0.984427, 0.983846, 0.983255, 0.982653, 0.982041, 0.981418, 0.980785, 0.980142, 0.979487, 0.978823, 0.978148, 0.977462, 0.976766, 0.976059, 0.975342, 0.974615, 0.973877, 0.973129, 0.972370, 0.971601, 0.970821, 0.970031, 0.969231, 0.968420, 0.967599, 0.966768, 0.965926, 0.965074, 0.964211, 0.963338, 0.962455, 0.961562, 0.960658, 0.959744, 0.958820, 0.957885, 0.956940, 0.955985, 0.955020, 0.954044, 0.953059, 0.952063, 0.951057, 0.950040, 0.949014, 0.947977, 0.946930, 0.945873, 0.944806, 0.943729, 0.942641, 0.941544, 0.940437, 0.939319, 0.938191, 0.937054, 0.935906, 0.934748, 0.933580, 0.932403, 0.931215, 0.930017, 0.928810, 0.927592, 0.926364, 0.925127, 0.923880, 0.922622, 0.921355, 0.920078, 0.918791, 0.917494, 0.916188, 0.914872, 0.913545, 0.912210, 0.910864, 0.909508, 0.908143, 0.906768, 0.905384, 0.903989, 0.902585, 0.901172, 0.899748, 0.898315, 0.896873, 0.895421, 0.893959, 0.892487, 0.891007, 0.889516, 0.888016, 0.886507, 0.884988, 0.883459, 0.881921, 0.880374, 0.878817, 0.877251, 0.875675, 0.874090, 0.872496, 0.870892, 0.869279, 0.867657, 0.866025, 0.864385, 0.862734, 0.861075, 0.859406, 0.857729, 0.856042, 0.854345, 0.852640, 0.850926, 0.849202, 0.847470, 0.845728, 0.843977, 0.842217, 0.840448, 0.838671, 0.836884, 0.835088, 0.833283, 0.831470, 0.829647, 0.827816, 0.825975, 0.824126, 0.822268, 0.820401, 0.818526, 0.816642, 0.814748, 0.812847, 0.810936, 0.809017, 0.807089, 0.805153, 0.803208, 0.801254, 0.799291, 0.797321, 0.795341, 0.793353, 0.791357, 0.789352, 0.787339, 0.785317, 0.783287, 0.781248, 0.779201, 0.777146, 0.775082, 0.773010, 0.770930, 0.768842, 0.766745, 0.764640, 0.762527, 0.760406, 0.758277, 0.756139, 0.753994, 0.751840, 0.749678, 0.747508, 0.745331, 0.743145, 0.740951, 0.738750, 0.736540, 0.734322, 0.732097, 0.729864, 0.727623, 0.725374, 0.723118, 0.720854, 0.718582, 0.716302, 0.714015, 0.711720, 0.709417, 0.707107, 0.704789, 0.702464, 0.700131, 0.697790, 0.695443, 0.693087, 0.690725, 0.688355, 0.685977, 0.683592, 0.681200, 0.678801, 0.676394, 0.673980, 0.671559, 0.669131, 0.666695, 0.664252, 0.661803, 0.659346, 0.656882, 0.654411, 0.651933, 0.649448, 0.646956, 0.644457, 0.641952, 0.639439, 0.636920, 0.634393, 0.631860, 0.629320, 0.626774, 0.624221, 0.621661, 0.619094, 0.616521, 0.613941, 0.611354, 0.608761, 0.606162, 0.603556, 0.600944, 0.598325, 0.595699, 0.593068, 0.590430, 0.587785, 0.585135, 0.582478, 0.579815, 0.577145, 0.574470, 0.571788, 0.569100, 0.566406, 0.563706, 0.561000, 0.558288, 0.555570, 0.552846, 0.550116, 0.547381, 0.544639, 0.541892, 0.539138, 0.536379, 0.533615, 0.530844, 0.528068, 0.525286, 0.522499, 0.519706, 0.516907, 0.514103, 0.511293, 0.508478, 0.505657, 0.502831, 0.500000, 0.497163, 0.494321, 0.491474, 0.488621, 0.485763, 0.482900, 0.480032, 0.477159, 0.474280, 0.471397, 0.468508, 0.465615, 0.462716, 0.459812, 0.456904, 0.453990, 0.451072, 0.448149, 0.445221, 0.442289, 0.439351, 0.436409, 0.433463, 0.430511, 0.427555, 0.424595, 0.421629, 0.418660, 0.415686, 0.412707, 0.409724, 0.406737, 0.403745, 0.400749, 0.397748, 0.394744, 0.391735, 0.388722, 0.385705, 0.382683, 0.379658, 0.376628, 0.373595, 0.370557, 0.367516, 0.364471, 0.361421, 0.358368, 0.355311, 0.352250, 0.349185, 0.346117, 0.343045, 0.339969, 0.336890, 0.333807, 0.330720, 0.327630, 0.324537, 0.321439, 0.318339, 0.315235, 0.312128, 0.309017, 0.305903, 0.302786, 0.299665, 0.296542, 0.293415, 0.290285, 0.287152, 0.284015, 0.280876, 0.277734, 0.274589, 0.271440, 0.268289, 0.265135, 0.261979, 0.258819, 0.255657, 0.252492, 0.249324, 0.246153, 0.242980, 0.239804, 0.236626, 0.233445, 0.230262, 0.227076, 0.223888, 0.220697, 0.217504, 0.214309, 0.211112, 0.207912, 0.204710, 0.201505, 0.198299, 0.195090, 0.191880, 0.188667, 0.185452, 0.182236, 0.179017, 0.175796, 0.172574, 0.169350, 0.166123, 0.162895, 0.159666, 0.156434, 0.153201, 0.149967, 0.146730, 0.143493, 0.140253, 0.137012, 0.133770, 0.130526, 0.127281, 0.124034, 0.120787, 0.117537, 0.114287, 0.111035, 0.107782, 0.104528, 0.101273, 0.098017, 0.094760, 0.091502, 0.088242, 0.084982, 0.081721, 0.078459, 0.075196, 0.071933, 0.068668, 0.065403, 0.062137, 0.058871, 0.055604, 0.052336, 0.049068, 0.045799, 0.042530, 0.039260, 0.035990, 0.032719, 0.029448, 0.026177, 0.022905, 0.019634, 0.016362, 0.013090, 0.009817, 0.006545, 0.003272, 0.000000, }; #endif diff --git a/libcelt/tests/mathops-test.c b/libcelt/tests/mathops-test.c index a55e7dd89..68d672e11 100644 --- a/libcelt/tests/mathops-test.c +++ b/libcelt/tests/mathops-test.c @@ -24,7 +24,7 @@ void testdiv(void) for (i=1;i<=327670;i++) { double prod; - celt_word32 val; + opus_val32 val; val = celt_rcp(i); #ifdef FIXED_POINT prod = (1./32768./65526.)*val*i; @@ -45,7 +45,7 @@ void testsqrt(void) for (i=1;i<=1000000000;i++) { double ratio; - celt_word16 val; + opus_val16 val; val = celt_sqrt(i); ratio = val/sqrt(i); if (fabs(ratio - 1) > .0005 && fabs(val-sqrt(i)) > 2) @@ -102,7 +102,7 @@ void testexp2log2(void) #else void testlog2(void) { - celt_word32 x; + opus_val32 x; for (x=8;x<1073741824;x+=(x>>3)) { float error = fabs((1.442695040888963387*log(x/16384.0))-celt_log2(x)/1024.0); @@ -116,7 +116,7 @@ void testlog2(void) void testexp2(void) { - celt_word16 x; + opus_val16 x; for (x=-32768;x<-30720;x++) { float error1 = fabs(x/2048.0-(1.442695040888963387*log(celt_exp2(x)/65536.0))); @@ -131,7 +131,7 @@ void testexp2(void) void testexp2log2(void) { - celt_word32 x; + opus_val32 x; for (x=8;x<65536;x+=(x>>3)) { float error = fabs(x-0.25*celt_exp2(celt_log2(x)<<1))/16384; @@ -145,10 +145,10 @@ void testexp2log2(void) void testilog2(void) { - celt_word32 x; + opus_val32 x; for (x=1;x<=268435455;x+=127) { - celt_word32 error = abs(celt_ilog2(x)-(int)floor(log2(x))); + opus_val32 error = abs(celt_ilog2(x)-(int)floor(log2(x))); if (error!=0) { printf("celt_ilog2 failed: celt_ilog2(x)!=floor(log2(x)) (x = %d, error = %d)\n",x,error); diff --git a/libcelt/tests/mdct-test.c b/libcelt/tests/mdct-test.c index 1b875c7b5..36844fe1e 100644 --- a/libcelt/tests/mdct-test.c +++ b/libcelt/tests/mdct-test.c @@ -94,7 +94,7 @@ void test1d(int nfft,int isinverse) kiss_fft_scalar * in = (kiss_fft_scalar*)malloc(buflen); kiss_fft_scalar * out= (kiss_fft_scalar*)malloc(buflen); - celt_word16 * window= (celt_word16*)malloc(sizeof(celt_word16)*nfft/2); + opus_val16 * window= (opus_val16*)malloc(sizeof(opus_val16)*nfft/2); int k; clt_mdct_init(&cfg, nfft, 0); diff --git a/libcelt/tests/rotation-test.c b/libcelt/tests/rotation-test.c index 164a6ea5a..08b43443b 100644 --- a/libcelt/tests/rotation-test.c +++ b/libcelt/tests/rotation-test.c @@ -14,8 +14,8 @@ void test_rotation(int N, int K) { int i; double err = 0, ener = 0, snr, snr0; - celt_word16 x0[MAX_SIZE]; - celt_word16 x1[MAX_SIZE]; + opus_val16 x0[MAX_SIZE]; + opus_val16 x1[MAX_SIZE]; int nb_rotations = (N+4*K)/(8*K); for (i=0;i<N;i++) x1[i] = x0[i] = rand()%32767-16384; diff --git a/libcelt/vq.c b/libcelt/vq.c index 74aba5391..58173d84d 100644 --- a/libcelt/vq.c +++ b/libcelt/vq.c @@ -42,7 +42,7 @@ #define M_PI 3.141592653 #endif -static void exp_rotation1(celt_norm *X, int len, int stride, celt_word16 c, celt_word16 s) +static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_val16 s) { int i; celt_norm *Xptr; @@ -70,8 +70,8 @@ static void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int { static const int SPREAD_FACTOR[3]={15,10,5}; int i; - celt_word16 c, s; - celt_word16 gain, theta; + opus_val16 c, s; + opus_val16 gain, theta; int stride2=0; int factor; /*int i; @@ -86,7 +86,7 @@ static void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int return; factor = SPREAD_FACTOR[spread-1]; - gain = celt_div((celt_word32)MULT16_16(Q15_ONE,len),(celt_word32)(len+factor*K)); + gain = celt_div((opus_val32)MULT16_16(Q15_ONE,len),(opus_val32)(len+factor*K)); theta = HALF16(MULT16_16_Q15(gain,gain)); c = celt_cos_norm(EXTEND32(theta)); @@ -129,14 +129,14 @@ static void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int /** Takes the pitch vector and the decoded residual vector, computes the gain that will give ||p+g*y||=1 and mixes the residual with the pitch. */ static void normalise_residual(int * restrict iy, celt_norm * restrict X, - int N, celt_word32 Ryy, celt_word16 gain) + int N, opus_val32 Ryy, opus_val16 gain) { int i; #ifdef FIXED_POINT int k; #endif - celt_word32 t; - celt_word16 g; + opus_val32 t; + opus_val16 g; #ifdef FIXED_POINT k = celt_ilog2(Ryy)>>1; @@ -171,17 +171,17 @@ static unsigned extract_collapse_mask(int *iy, int N, int B) } unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, - int resynth, ec_enc *enc, celt_word16 gain) + int resynth, ec_enc *enc, opus_val16 gain) { VARDECL(celt_norm, y); VARDECL(int, iy); - VARDECL(celt_word16, signx); + VARDECL(opus_val16, signx); int i, j; - celt_word16 s; + opus_val16 s; int pulsesLeft; - celt_word32 sum; - celt_word32 xy; - celt_word16 yy; + opus_val32 sum; + opus_val32 xy; + opus_val16 yy; unsigned collapse_mask; SAVE_STACK; @@ -189,7 +189,7 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ALLOC(y, N, celt_norm); ALLOC(iy, N, int); - ALLOC(signx, N, celt_word16); + ALLOC(signx, N, opus_val16); exp_rotation(X, N, 1, B, K, spread); @@ -213,7 +213,7 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, /* Do a pre-search by projecting on the pyramid */ if (K > (N>>1)) { - celt_word16 rcp; + opus_val16 rcp; j=0; do { sum += X[j]; } while (++j<N); @@ -258,7 +258,7 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, #endif if (pulsesLeft > N+3) { - celt_word16 tmp = pulsesLeft; + opus_val16 tmp = pulsesLeft; yy = MAC16_16(yy, tmp, tmp); yy = MAC16_16(yy, tmp, y[0]); iy[0] += pulsesLeft; @@ -269,8 +269,8 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, for (i=0;i<pulsesLeft;i++) { int best_id; - celt_word32 best_num = -VERY_LARGE16; - celt_word16 best_den = 0; + opus_val32 best_num = -VERY_LARGE16; + opus_val16 best_den = 0; #ifdef FIXED_POINT int rshift; #endif @@ -283,7 +283,7 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, yy = ADD32(yy, 1); j=0; do { - celt_word16 Rxy, Ryy; + opus_val16 Rxy, Ryy; /* Temporary sums of the new pulse(s) */ Rxy = EXTRACT16(SHR32(ADD32(xy, EXTEND32(X[j])),rshift)); /* We're multiplying y[j] by two so we don't have to do it here */ @@ -337,10 +337,10 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, /** Decode pulse vector and combine the result with the pitch vector to produce the final normalised signal in the current band. */ unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B, - ec_dec *dec, celt_word16 gain) + ec_dec *dec, opus_val16 gain) { int i; - celt_word32 Ryy; + opus_val32 Ryy; unsigned collapse_mask; VARDECL(int, iy); SAVE_STACK; @@ -360,15 +360,15 @@ unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B, return collapse_mask; } -void renormalise_vector(celt_norm *X, int N, celt_word16 gain) +void renormalise_vector(celt_norm *X, int N, opus_val16 gain) { int i; #ifdef FIXED_POINT int k; #endif - celt_word32 E = EPSILON; - celt_word16 g; - celt_word32 t; + opus_val32 E = EPSILON; + opus_val16 g; + opus_val32 t; celt_norm *xptr = X; for (i=0;i<N;i++) { @@ -394,8 +394,8 @@ int stereo_itheta(celt_norm *X, celt_norm *Y, int stereo, int N) { int i; int itheta; - celt_word16 mid, side; - celt_word32 Emid, Eside; + opus_val16 mid, side; + opus_val32 Emid, Eside; Emid = Eside = EPSILON; if (stereo) diff --git a/libcelt/vq.h b/libcelt/vq.h index 56a31b6f8..17d1faf9e 100644 --- a/libcelt/vq.h +++ b/libcelt/vq.h @@ -49,7 +49,7 @@ * @ret A mask indicating which blocks in the band received pulses */ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, - int resynth, ec_enc *enc, celt_word16 gain); + int resynth, ec_enc *enc, opus_val16 gain); /** Algebraic pulse decoder * @param x Decoded normalised spectrum (returned) @@ -60,9 +60,9 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, * @ret A mask indicating which blocks in the band received pulses */ unsigned alg_unquant(celt_norm *X, int N, int K, int spread, int B, - ec_dec *dec, celt_word16 gain); + ec_dec *dec, opus_val16 gain); -void renormalise_vector(celt_norm *X, int N, celt_word16 gain); +void renormalise_vector(celt_norm *X, int N, opus_val16 gain); int stereo_itheta(celt_norm *X, celt_norm *Y, int stereo, int N); diff --git a/src/opus_decoder.c b/src/opus_decoder.c index cfefaff14..5fb8ee335 100644 --- a/src/opus_decoder.c +++ b/src/opus_decoder.c @@ -112,7 +112,7 @@ OpusDecoder *opus_decoder_create(int Fs, int channels) } static void smooth_fade(const short *in1, const short *in2, short *out, - int overlap, int channels, const celt_word16 *window, int Fs) + int overlap, int channels, const opus_val16 *window, int Fs) { int i, c; int inc = 48000/Fs; @@ -120,7 +120,7 @@ static void smooth_fade(const short *in1, const short *in2, short *out, { for (i=0;i<overlap;i++) { - celt_word16 w = MULT16_16_Q15(window[i*inc], window[i*inc]); + opus_val16 w = MULT16_16_Q15(window[i*inc], window[i*inc]); out[i*channels+c] = SHR32(MAC16_16(MULT16_16(w,in2[i*channels+c]), Q15ONE-w, in1[i*channels+c]), 15); } @@ -165,7 +165,7 @@ static int opus_decode_frame(OpusDecoder *st, const unsigned char *data, short redundant_audio[240*2]; int c; int F2_5, F5, F10, F20; - const celt_word16 *window; + const opus_val16 *window; silk_dec = (char*)st+st->silk_dec_offset; celt_dec = (CELTDecoder*)((char*)st+st->celt_dec_offset); diff --git a/win32/config.h b/win32/config.h index fa9f6b5ed..ccdb8d737 100644 --- a/win32/config.h +++ b/win32/config.h @@ -16,7 +16,7 @@ /* Get rid of the CELT VS compile warnings */ #if 1 #pragma warning(disable : 4018)// signed/unsigned mismatch -#pragma warning(disable : 4244)// conversion from 'double' to 'celt_word16', possible loss of data +#pragma warning(disable : 4244)// conversion from 'double' to 'opus_val16', possible loss of data #pragma warning(disable : 4267)// conversion from 'size_t' to 'int', possible loss of data #pragma warning(disable : 4305)// truncation from 'double' to 'const float' #pragma warning(disable : 4311)// pointer truncation from 'char *' to 'long' -- GitLab