mirror of
https://github.com/xiph/opus.git
synced 2025-05-31 07:37:42 +00:00
fixed-point: fixing two overflows that didn't really affect quality
This commit is contained in:
parent
7c422653f3
commit
cd29b02773
3 changed files with 16 additions and 6 deletions
|
@ -233,6 +233,8 @@ int compute_pitch_gain(const CELTMode *m, const celt_norm_t *X, const celt_norm_
|
|||
Sxy = MAC16_16(Sxy, X[j], P[j]);
|
||||
Sxx = MAC16_16(Sxx, X[j], X[j]);
|
||||
}
|
||||
Sxy = SHR32(Sxy,2);
|
||||
Sxx = SHR32(Sxx,2);
|
||||
/* No negative gain allowed */
|
||||
if (Sxy < 0)
|
||||
Sxy = 0;
|
||||
|
|
|
@ -427,18 +427,20 @@ static inline short MULT16_16_Q14(int a, int b)
|
|||
celt_mips+=3;
|
||||
return res;
|
||||
}
|
||||
static inline short MULT16_16_Q15(int a, int b)
|
||||
|
||||
#define MULT16_16_Q15(a, b) _MULT16_16_Q15(a, b, __FILE__, __LINE__)
|
||||
static inline short _MULT16_16_Q15(int a, int b, char *file, int line)
|
||||
{
|
||||
long long res;
|
||||
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b))
|
||||
{
|
||||
fprintf (stderr, "MULT16_16_Q15: inputs are not short: %d %d\n", a, b);
|
||||
fprintf (stderr, "MULT16_16_Q15: inputs are not short: %d %d in %s: line %d\n", a, b, file, line);
|
||||
}
|
||||
res = ((long long)a)*b;
|
||||
res >>= 15;
|
||||
if (!VERIFY_SHORT(res))
|
||||
{
|
||||
fprintf (stderr, "MULT16_16_Q15: output is not short: %d\n", (int)res);
|
||||
fprintf (stderr, "MULT16_16_Q15: output is not short: %d in %s: line %d\n", (int)res, file, line);
|
||||
}
|
||||
celt_mips+=1;
|
||||
return res;
|
||||
|
@ -547,6 +549,6 @@ static inline int _DIV32(long long a, long long b, char *file, int line)
|
|||
#define PDIV32_16(a,b) DIV32_16(ADD32((a),(b)>>1),b)
|
||||
|
||||
#undef PRINT_MIPS
|
||||
#define PRINT_MIPS(file) do {fprintf (file, "total complexity = %d MIPS\n", celt_mips);} while (0);
|
||||
#define PRINT_MIPS(file) do {fprintf (file, "total complexity = %llu MIPS\n", celt_mips);} while (0);
|
||||
|
||||
#endif
|
||||
|
|
10
libcelt/vq.c
10
libcelt/vq.c
|
@ -335,7 +335,14 @@ celt_word16_t renormalise_vector(celt_norm_t *X, celt_word16_t value, int N, int
|
|||
}
|
||||
|
||||
rE = celt_sqrt(E);
|
||||
g = MULT16_16_Q15(value,celt_rcp(SHL32(rE,9)));
|
||||
/*if (celt_rcp(SHL32(rE,9))>32767)
|
||||
fprintf (stderr, "celt_rcp: %d %d\n",rE, E); */
|
||||
#ifdef FIXED_POINT
|
||||
if (rE <= 128)
|
||||
g = Q15ONE;
|
||||
else
|
||||
#endif
|
||||
g = MULT16_16_Q15(value,celt_rcp(SHL32(rE,9)));
|
||||
xptr = X;
|
||||
for (i=0;i<N;i++)
|
||||
{
|
||||
|
@ -374,7 +381,6 @@ void intra_fold(const CELTMode *m, celt_norm_t * restrict x, int N, int K, celt_
|
|||
pred_gain = celt_div((celt_word32_t)MULT16_16(Q15_ONE,N),(celt_word32_t)(N+KGAIN*K));
|
||||
|
||||
fold(m, N, Y, P, N0, B);
|
||||
|
||||
renormalise_vector(P, pred_gain, C*N, 1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue