Converted a few double-precision constants to single precision

This commit is contained in:
Jean-Marc Valin 2010-04-16 20:57:56 -04:00
parent 3ff5e4c2dc
commit 628c025373
6 changed files with 31 additions and 31 deletions

View file

@ -222,11 +222,11 @@ struct kiss_fft_state{
#elif defined(USE_SIMD) #elif defined(USE_SIMD)
# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) ) # define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) )
# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) ) # define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) )
# define HALF_OF(x) ((x)*_mm_set1_ps(.5)) # define HALF_OF(x) ((x)*_mm_set1_ps(.5f))
#else #else
# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase) # define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase)
# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase) # define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase)
# define HALF_OF(x) ((x)*.5) # define HALF_OF(x) ((x)*.5f)
#endif #endif
#define kf_cexp(x,phase) \ #define kf_cexp(x,phase) \

View file

@ -40,7 +40,7 @@
#include "celt_types.h" #include "celt_types.h"
#define CELT_SIG_SCALE 32768. #define CELT_SIG_SCALE 32768.f
#define celt_fatal(str) _celt_fatal(str, __FILE__, __LINE__); #define celt_fatal(str) _celt_fatal(str, __FILE__, __LINE__);
#ifdef ENABLE_ASSERTIONS #ifdef ENABLE_ASSERTIONS

View file

@ -167,7 +167,7 @@ void normalise_bands(const CELTMode *m, const celt_sig * restrict freq, celt_nor
for (i=0;i<m->nbEBands;i++) for (i=0;i<m->nbEBands;i++)
{ {
int j; int j;
celt_word16 g = 1.f/(1e-10+bank[i+c*m->nbEBands]); celt_word16 g = 1.f/(1e-10f+bank[i+c*m->nbEBands]);
for (j=eBands[i];j<eBands[i+1];j++) for (j=eBands[i];j<eBands[i+1];j++)
X[j+c*N] = freq[j+c*N]*g; X[j+c*N] = freq[j+c*N]*g;
} }
@ -264,11 +264,11 @@ int compute_pitch_gain(const CELTMode *m, const celt_sig *X, const celt_sig *P,
{ {
celt_word32 num, den; celt_word32 num, den;
celt_word16 fact; celt_word16 fact;
fact = MULT16_16(QCONST16(.04, 14), norm_rate); fact = MULT16_16(QCONST16(.04f, 14), norm_rate);
if (fact < QCONST16(1., 14)) if (fact < QCONST16(1.f, 14))
fact = QCONST16(1., 14); fact = QCONST16(1.f, 14);
num = Sxy; num = Sxy;
den = EPSILON+Sxx+MULT16_32_Q15(QCONST16(.03,15),Syy); den = EPSILON+Sxx+MULT16_32_Q15(QCONST16(.03f,15),Syy);
shift = celt_zlog2(Sxy)-16; shift = celt_zlog2(Sxy)-16;
if (shift < 0) if (shift < 0)
shift = 0; shift = 0;
@ -278,28 +278,28 @@ int compute_pitch_gain(const CELTMode *m, const celt_sig *X, const celt_sig *P,
g = DIV32(SHL32(SHR32(num,shift),14),ADD32(EPSILON,SHR32(den,shift))); g = DIV32(SHL32(SHR32(num,shift),14),ADD32(EPSILON,SHR32(den,shift)));
/* This MUST round down so that we don't over-estimate the gain */ /* This MUST round down so that we don't over-estimate the gain */
*gain_id = EXTRACT16(SHR32(MULT16_16(20,(g-QCONST16(.5,14))),14)); *gain_id = EXTRACT16(SHR32(MULT16_16(20,(g-QCONST16(.5f,14))),14));
} }
#else #else
{ {
float fact = .04*norm_rate; float fact = .04f*norm_rate;
if (fact < 1) if (fact < 1)
fact = 1; fact = 1;
g = Sxy/(.1+Sxx+.03*Syy); g = Sxy/(.1f+Sxx+.03f*Syy);
if (Sxy < .5*fact*celt_sqrt(1+Sxx*Syy)) if (Sxy < .5f*fact*celt_sqrt(1+Sxx*Syy))
g = 0; g = 0;
/* This MUST round down so that we don't over-estimate the gain */ /* This MUST round down so that we don't over-estimate the gain */
*gain_id = floor(20*(g-.5)); *gain_id = floor(20*(g-.5f));
} }
#endif #endif
/* This prevents the pitch gain from being above 1.0 for too long by bounding the /* This prevents the pitch gain from being above 1.0 for too long by bounding the
maximum error amplification factor to 2.0 */ maximum error amplification factor to 2.0 */
g = ADD16(QCONST16(.5,14), MULT16_16_16(QCONST16(.05,14),*gain_id)); g = ADD16(QCONST16(.5f,14), MULT16_16_16(QCONST16(.05f,14),*gain_id));
*gain_prod = MAX16(QCONST32(1., 13), MULT16_16_Q14(*gain_prod,g)); *gain_prod = MAX16(QCONST32(1.f, 13), MULT16_16_Q14(*gain_prod,g));
if (*gain_prod>QCONST32(2., 13)) if (*gain_prod>QCONST32(2.f, 13))
{ {
*gain_id=9; *gain_id=9;
*gain_prod = QCONST32(2., 13); *gain_prod = QCONST32(2.f, 13);
} }
if (*gain_id < 0) if (*gain_id < 0)
@ -322,7 +322,7 @@ void apply_pitch(const CELTMode *m, celt_sig *X, const celt_sig *P, int gain_id,
int len = m->pitchEnd; int len = m->pitchEnd;
N = FRAMESIZE(m); N = FRAMESIZE(m);
gain = ADD16(QCONST16(.5,14), MULT16_16_16(QCONST16(.05,14),gain_id)); gain = ADD16(QCONST16(.5f,14), MULT16_16_16(QCONST16(.05f,14),gain_id));
delta = PDIV32_16(gain, len); delta = PDIV32_16(gain, len);
if (pred) if (pred)
gain = -gain; gain = -gain;
@ -427,7 +427,7 @@ int folding_decision(const CELTMode *m, celt_norm *X, celt_word16 *average, int
{ {
celt_word16 r; celt_word16 r;
celt_word16 den = celt_sqrt(floor_ener); celt_word16 den = celt_sqrt(floor_ener);
den = MAX32(QCONST16(.02, 15), den); den = MAX32(QCONST16(.02f, 15), den);
r = DIV32_16(SHL32(EXTEND32(max_val),8),den); r = DIV32_16(SHL32(EXTEND32(max_val),8),den);
ratio = ADD32(ratio, EXTEND32(r)); ratio = ADD32(ratio, EXTEND32(r));
NR++; NR++;
@ -439,9 +439,9 @@ int folding_decision(const CELTMode *m, celt_norm *X, celt_word16 *average, int
ratio = ADD32(HALF32(ratio), HALF32(*average)); ratio = ADD32(HALF32(ratio), HALF32(*average));
if (!*last_decision) if (!*last_decision)
{ {
*last_decision = (ratio < QCONST16(1.8,8)); *last_decision = (ratio < QCONST16(1.8f,8));
} else { } else {
*last_decision = (ratio < QCONST16(3.,8)); *last_decision = (ratio < QCONST16(3.f,8));
} }
*average = EXTRACT16(ratio); *average = EXTRACT16(ratio);
return *last_decision; return *last_decision;
@ -577,9 +577,9 @@ void quant_bands_stereo(const CELTMode *m, int start, celt_norm *_X, const celt_
mid = renormalise_vector(X, Q15ONE, N, 1); mid = renormalise_vector(X, Q15ONE, N, 1);
side = renormalise_vector(Y, Q15ONE, N, 1); side = renormalise_vector(Y, Q15ONE, N, 1);
#ifdef FIXED_POINT #ifdef FIXED_POINT
itheta = MULT16_16_Q15(QCONST16(0.63662,15),celt_atan2p(side, mid)); itheta = MULT16_16_Q15(QCONST16(0.63662f,15),celt_atan2p(side, mid));
#else #else
itheta = floor(.5+16384*0.63662*atan2(side,mid)); itheta = floor(.5f+16384*0.63662f*atan2(side,mid));
#endif #endif
qalloc = log2_frac((1<<qb)+1,BITRES); qalloc = log2_frac((1<<qb)+1,BITRES);
if (qb==0) if (qb==0)
@ -728,8 +728,8 @@ void quant_bands_stereo(const CELTMode *m, int start, celt_norm *_X, const celt_
mid = imid; mid = imid;
side = iside; side = iside;
#else #else
mid = (1./32768)*imid; mid = (1.f/32768)*imid;
side = (1./32768)*iside; side = (1.f/32768)*iside;
#endif #endif
for (j=0;j<N;j++) for (j=0;j<N;j++)
norm[eBands[i]+j] = MULT16_16_Q15(n,X[j]); norm[eBands[i]+j] = MULT16_16_Q15(n,X[j]);
@ -936,8 +936,8 @@ void unquant_bands_stereo(const CELTMode *m, int start, celt_norm *_X, const cel
mid = imid; mid = imid;
side = iside; side = iside;
#else #else
mid = (1./32768)*imid; mid = (1.f/32768)*imid;
side = (1./32768)*iside; side = (1.f/32768)*iside;
#endif #endif
for (j=0;j<N;j++) for (j=0;j<N;j++)
norm[eBands[i]+j] = MULT16_16_Q15(n,X[j]); norm[eBands[i]+j] = MULT16_16_Q15(n,X[j]);

View file

@ -182,7 +182,7 @@ CELTEncoder *celt_encoder_create(const CELTMode *mode, int channels, int *error)
st->pitch_available = 1; st->pitch_available = 1;
st->force_intra = 0; st->force_intra = 0;
st->delayedIntra = 1; st->delayedIntra = 1;
st->tonal_average = QCONST16(1.,8); st->tonal_average = QCONST16(1.f,8);
st->fold_decision = 1; st->fold_decision = 1;
st->in_mem = celt_alloc(st->overlap*C*sizeof(celt_sig)); st->in_mem = celt_alloc(st->overlap*C*sizeof(celt_sig));
@ -1049,7 +1049,7 @@ int celt_encoder_ctl(CELTEncoder * restrict st, int request, ...)
st->delayedIntra = 1; st->delayedIntra = 1;
st->fold_decision = 1; st->fold_decision = 1;
st->tonal_average = QCONST16(1.,8); st->tonal_average = QCONST16(1.f,8);
st->gain_prod = 0; st->gain_prod = 0;
st->vbr_reservoir = 0; st->vbr_reservoir = 0;
st->vbr_drift = 0; st->vbr_drift = 0;

View file

@ -83,7 +83,7 @@ void clt_mdct_init(mdct_lookup *l,int N)
#endif #endif
#else #else
for (i=0;i<N2;i++) for (i=0;i<N2;i++)
l->trig[i] = cos(2*M_PI*(i+1./8.)/N); l->trig[i] = cos(2*M_PI*(i+.125f)/N);
#endif #endif
} }

View file

@ -118,7 +118,7 @@ static void exp_rotation(celt_norm *X, int len, int dir, int stride, int K)
/* This should help a little bit with the transients */ /* This should help a little bit with the transients */
if (transient) if (transient)
c[0] = s[0] = QCONST16(.7071068, 15); c[0] = s[0] = QCONST16(.7071068f, 15);
/* Needs to be < 0 to prevent gaps on the side of the spreading */ /* Needs to be < 0 to prevent gaps on the side of the spreading */
if (dir < 0) if (dir < 0)