shithub: opus

Download patch

ref: 628c025373296bb68569b18a27f936ca6a70bcd3
parent: 3ff5e4c2dc147acee2dc1b9c3bcb2c8d7b76b1f1
author: Jean-Marc Valin <[email protected]>
date: Fri Apr 16 16:57:56 EDT 2010

Converted a few double-precision constants to single precision

--- a/libcelt/_kiss_fft_guts.h
+++ b/libcelt/_kiss_fft_guts.h
@@ -222,11 +222,11 @@
 #elif defined(USE_SIMD)
 #  define KISS_FFT_COS(phase) _mm_set1_ps( cos(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
 #  define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase)
 #  define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase)
-#  define HALF_OF(x) ((x)*.5)
+#  define HALF_OF(x) ((x)*.5f)
 #endif
 
 #define  kf_cexp(x,phase) \
--- a/libcelt/arch.h
+++ b/libcelt/arch.h
@@ -40,7 +40,7 @@
 
 #include "celt_types.h"
 
-#define CELT_SIG_SCALE 32768.
+#define CELT_SIG_SCALE 32768.f
 
 #define celt_fatal(str) _celt_fatal(str, __FILE__, __LINE__);
 #ifdef ENABLE_ASSERTIONS
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -167,7 +167,7 @@
       for (i=0;i<m->nbEBands;i++)
       {
          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++)
             X[j+c*N] = freq[j+c*N]*g;
       }
@@ -264,11 +264,11 @@
    {
       celt_word32 num, den;
       celt_word16 fact;
-      fact = MULT16_16(QCONST16(.04, 14), norm_rate);
-      if (fact < QCONST16(1., 14))
-         fact = QCONST16(1., 14);
+      fact = MULT16_16(QCONST16(.04f, 14), norm_rate);
+      if (fact < QCONST16(1.f, 14))
+         fact = QCONST16(1.f, 14);
       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;
       if (shift < 0)
          shift = 0;
@@ -278,28 +278,28 @@
          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 */
-      *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
    {
-      float fact = .04*norm_rate;
+      float fact = .04f*norm_rate;
       if (fact < 1)
          fact = 1;
-      g = Sxy/(.1+Sxx+.03*Syy);
-      if (Sxy < .5*fact*celt_sqrt(1+Sxx*Syy))
+      g = Sxy/(.1f+Sxx+.03f*Syy);
+      if (Sxy < .5f*fact*celt_sqrt(1+Sxx*Syy))
          g = 0;
       /* 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
    /* This prevents the pitch gain from being above 1.0 for too long by bounding the 
       maximum error amplification factor to 2.0 */
-   g = ADD16(QCONST16(.5,14), MULT16_16_16(QCONST16(.05,14),*gain_id));
-   *gain_prod = MAX16(QCONST32(1., 13), MULT16_16_Q14(*gain_prod,g));
-   if (*gain_prod>QCONST32(2., 13))
+   g = ADD16(QCONST16(.5f,14), MULT16_16_16(QCONST16(.05f,14),*gain_id));
+   *gain_prod = MAX16(QCONST32(1.f, 13), MULT16_16_Q14(*gain_prod,g));
+   if (*gain_prod>QCONST32(2.f, 13))
    {
       *gain_id=9;
-      *gain_prod = QCONST32(2., 13);
+      *gain_prod = QCONST32(2.f, 13);
    }
 
    if (*gain_id < 0)
@@ -322,7 +322,7 @@
    int len = m->pitchEnd;
 
    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);
    if (pred)
       gain = -gain;
@@ -427,7 +427,7 @@
       {
          celt_word16 r;
          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);
          ratio = ADD32(ratio, EXTEND32(r));
          NR++;
@@ -439,9 +439,9 @@
    ratio = ADD32(HALF32(ratio), HALF32(*average));
    if (!*last_decision)
    {
-      *last_decision = (ratio < QCONST16(1.8,8));
+      *last_decision = (ratio < QCONST16(1.8f,8));
    } else {
-      *last_decision = (ratio < QCONST16(3.,8));
+      *last_decision = (ratio < QCONST16(3.f,8));
    }
    *average = EXTRACT16(ratio);
    return *last_decision;
@@ -577,9 +577,9 @@
       mid = renormalise_vector(X, Q15ONE, N, 1);
       side = renormalise_vector(Y, Q15ONE, N, 1);
 #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
-      itheta = floor(.5+16384*0.63662*atan2(side,mid));
+      itheta = floor(.5f+16384*0.63662f*atan2(side,mid));
 #endif
       qalloc = log2_frac((1<<qb)+1,BITRES);
       if (qb==0)
@@ -728,8 +728,8 @@
       mid = imid;
       side = iside;
 #else
-      mid = (1./32768)*imid;
-      side = (1./32768)*iside;
+      mid = (1.f/32768)*imid;
+      side = (1.f/32768)*iside;
 #endif
       for (j=0;j<N;j++)
          norm[eBands[i]+j] = MULT16_16_Q15(n,X[j]);
@@ -936,8 +936,8 @@
       mid = imid;
       side = iside;
 #else
-      mid = (1./32768)*imid;
-      side = (1./32768)*iside;
+      mid = (1.f/32768)*imid;
+      side = (1.f/32768)*iside;
 #endif
       for (j=0;j<N;j++)
          norm[eBands[i]+j] = MULT16_16_Q15(n,X[j]);
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -182,7 +182,7 @@
    st->pitch_available = 1;
    st->force_intra  = 0;
    st->delayedIntra = 1;
-   st->tonal_average = QCONST16(1.,8);
+   st->tonal_average = QCONST16(1.f,8);
    st->fold_decision = 1;
 
    st->in_mem = celt_alloc(st->overlap*C*sizeof(celt_sig));
@@ -1049,7 +1049,7 @@
          st->delayedIntra = 1;
 
          st->fold_decision = 1;
-         st->tonal_average = QCONST16(1.,8);
+         st->tonal_average = QCONST16(1.f,8);
          st->gain_prod = 0;
          st->vbr_reservoir = 0;
          st->vbr_drift = 0;
--- a/libcelt/mdct.c
+++ b/libcelt/mdct.c
@@ -83,7 +83,7 @@
 #endif
 #else
    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
 }
 
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -118,7 +118,7 @@
 
    /* This should help a little bit with the transients */
    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 */
    if (dir < 0)