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

s/ROUND/ROUND16/

parent 83006eec
......@@ -170,7 +170,7 @@ typedef float celt_mask_t;
#define SHL(a,shift) (a)
#define SATURATE(x,a) (x)
#define ROUND(a,shift) (a)
#define ROUND16(a,shift) (a)
#define HALF32(x) (.5f*(x))
#define ADD16(a,b) ((a)+(b))
......
......@@ -174,7 +174,7 @@ static inline int SHL32(long long a, int shift)
#define SATURATE16(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
#define SATURATE32(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
#define ROUND(x,a) (EXTRACT16(PSHR32((x),(a))))
#define ROUND16(x,a) (EXTRACT16(PSHR32((x),(a))))
#define HALF32(x) (SHR32(x,1))
//#define SHR(a,shift) ((a) >> (shift))
......
......@@ -90,7 +90,7 @@
#define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
/** Shift by a and round-to-neareast 32-bit value. Result is a 16-bit value */
#define ROUND(x,a) (EXTRACT16(PSHR32((x),(a))))
#define ROUND16(x,a) (EXTRACT16(PSHR32((x),(a))))
/** Divide by two */
#define HALF32(x) (SHR32(x,1))
......
......@@ -166,7 +166,7 @@ void find_spectral_pitch(kiss_fftr_cfg fft, const struct PsyDecay *decay, const
celt_word32_t tmp;
/*printf ("%d %d ", X[2*i]*X[2*i]+X[2*i+1]*X[2*i+1], Y[2*i]*Y[2*i]+Y[2*i+1]*Y[2*i+1]);*/
/*n = DIV32_16(Q15ONE,celt_sqrt(EPSILON+curve[i]));*/
n = ROUND(celt_rcp(celt_sqrt(EPSILON+curve[i])),16);
n = ROUND16(celt_rcp(celt_sqrt(EPSILON+curve[i])),16);
/*printf ("%f ", n);*/
tmp = X[2*i];
X[2*i] = MULT16_32_Q15(n, ADD32(MULT16_16(X[2*i ],Y[2*i ]), MULT16_16(X[2*i+1],Y[2*i+1])));
......
......@@ -64,7 +64,7 @@ static inline celt_ener_t dB2Amp(celt_ener_t dB)
static inline celt_word16_t amp2dB(celt_ener_t amp)
{
/* equivalent to return 6.0207*log2(.3+amp) */
return ROUND(MULT16_16(24661,celt_log2(ADD32(QCONST32(.3f,14),amp))),12);
return ROUND16(MULT16_16(24661,celt_log2(ADD32(QCONST32(.3f,14),amp))),12);
/* return DB_SCALING*20*log10(.3+ENER_SCALING_1*amp); */
}
#else
......
......@@ -71,7 +71,7 @@ static void mix_pitch_and_residual(int *iy, celt_norm_t *X, int N, int K, const
the encoded (int) one */
for (i=0;i<N;i++)
y[i] = SUB16(SHL16(iy[i],yshift),
MULT16_16_Q15(alpha,MULT16_16_Q14(ROUND(Ryp,14),P[i])));
MULT16_16_Q15(alpha,MULT16_16_Q14(ROUND16(Ryp,14),P[i])));
/* Recompute after the projection (I think it's right) */
Ryp = 0;
......@@ -84,13 +84,13 @@ static void mix_pitch_and_residual(int *iy, celt_norm_t *X, int N, int K, const
/* g = (sqrt(Ryp^2 + Ryy - Rpp*Ryy)-Ryp)/Ryy */
g = MULT16_32_Q15(
celt_sqrt(MULT16_16(ROUND(Ryp,14),ROUND(Ryp,14)) + Ryy -
MULT16_16(ROUND(Ryy,14),ROUND(Rpp,14)))
- ROUND(Ryp,14),
celt_sqrt(MULT16_16(ROUND16(Ryp,14),ROUND16(Ryp,14)) + Ryy -
MULT16_16(ROUND16(Ryy,14),ROUND16(Rpp,14)))
- ROUND16(Ryp,14),
celt_rcp(SHR32(Ryy,9)));
for (i=0;i<N;i++)
X[i] = P[i] + ROUND(MULT16_16(y[i], g),11);
X[i] = P[i] + ROUND16(MULT16_16(y[i], g),11);
RESTORE_STACK;
}
......@@ -165,8 +165,8 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, const celt_norm_t *
Rpp = MAC16_16(Rpp, P[j],P[j]);
Rxp = MAC16_16(Rxp, X[j],P[j]);
}
Rpp = ROUND(Rpp, NORM_SHIFT);
Rxp = ROUND(Rxp, NORM_SHIFT);
Rpp = ROUND16(Rpp, NORM_SHIFT);
Rxp = ROUND16(Rxp, NORM_SHIFT);
celt_assert2(Rpp<=NORM_SCALING, "Rpp should never have a norm greater than unity");
/* We only need to initialise the zero because the first iteration only uses that */
......@@ -228,15 +228,15 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, const celt_norm_t *
/* Compute the gain such that ||p + g*y|| = 1 */
g = MULT16_32_Q15(
celt_sqrt(MULT16_16(ROUND(Ryp,14),ROUND(Ryp,14)) + Ryy -
MULT16_16(ROUND(Ryy,14),Rpp))
- ROUND(Ryp,14),
celt_sqrt(MULT16_16(ROUND16(Ryp,14),ROUND16(Ryp,14)) + Ryy -
MULT16_16(ROUND16(Ryy,14),Rpp))
- ROUND16(Ryp,14),
celt_rcp(SHR32(Ryy,12)));
/* Knowing that gain, what's the error: (x-g*y)^2
(result is negated and we discard x^2 because it's constant) */
/*score = 2.f*g*Rxy - 1.f*g*g*Ryy*NORM_SCALING_1;*/
score = 2*MULT16_32_Q14(ROUND(Rxy,14),g)
- MULT16_32_Q14(EXTRACT16(MULT16_32_Q14(ROUND(Ryy,14),g)),g);
score = 2*MULT16_32_Q14(ROUND16(Rxy,14),g)
- MULT16_32_Q14(EXTRACT16(MULT16_32_Q14(ROUND16(Ryy,14),g)),g);
if (score>nbest[Lupdate-1]->score)
{
......@@ -378,7 +378,7 @@ void intra_prediction(celt_norm_t *x, celt_mask_t *W, int N, int K, celt_norm_t
xy = MAC16_16(xy, x[j], Y[i+N-j-1]);
yy = MAC16_16(yy, Y[i+N-j-1], Y[i+N-j-1]);
}
score = DIV32(MULT16_16(ROUND(xy,14),ROUND(xy,14)), ROUND(yy,14));
score = DIV32(MULT16_16(ROUND16(xy,14),ROUND16(xy,14)), ROUND16(yy,14));
if (score > best_score)
{
best_score = score;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment