ref: 77614c45fa3647a1bd927a8c7bd5d7599376d584
parent: 28139279d1c1df736e0db341f30b70ab080e1326
author: menno <menno>
date: Sat Aug 17 07:15:32 EDT 2002
divide checks
--- a/libfaad/filtbank.c
+++ b/libfaad/filtbank.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: filtbank.c,v 1.12 2002/08/17 10:03:13 menno Exp $
+** $Id: filtbank.c,v 1.13 2002/08/17 11:15:31 menno Exp $
**/
#include "common.h"
@@ -50,9 +50,9 @@
/* calculate the sine windows */
for (i = 0; i < frame_len; i++)
- fb->long_window[0][i] = (real_t)sin(M_PI / (2.0 * frame_len) * (i + 0.5));
+ fb->long_window[0][i] = (real_t)sin(M_PI / (2.0 * (real_t)frame_len) * ((real_t)i + 0.5));
for (i = 0; i < nshort; i++)
- fb->short_window[0][i] = (real_t)sin(M_PI / (2.0 * nshort) * (i + 0.5));
+ fb->short_window[0][i] = (real_t)sin(M_PI / (2.0 * (real_t)nshort) * ((real_t)i + 0.5));
#ifdef LD_DEC
/* LD */
@@ -69,7 +69,7 @@
for (i = 0; i < 3*(frame_len_ld>>3); i++)
fb->ld_window[1][i] = 0.0;
for (; i < 5*(frame_len_ld>>3); i++)
- fb->ld_window[1][i] = (real_t)sin((i-3*(frame_len_ld>>3)+0.5) * M_PI / (frame_len_ld>>1));
+ fb->ld_window[1][i] = (real_t)sin((i-3*(frame_len_ld>>3)+0.5) * M_PI / (real_t)(frame_len_ld>>1));
for (; i < frame_len_ld; i++)
fb->ld_window[1][i] = 1.0;
#endif
--- a/libfaad/ic_predict.c
+++ b/libfaad/ic_predict.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: ic_predict.c,v 1.6 2002/06/13 11:03:27 menno Exp $
+** $Id: ic_predict.c,v 1.7 2002/08/17 11:15:31 menno Exp $
**/
#include "common.h"
@@ -63,12 +63,18 @@
KOR = state->KOR; /* correlations */
VAR = state->VAR; /* variances */
- k1 = KOR[0]/VAR[0]*B;
+ if (VAR[0] == 0.0)
+ k1 = 0.0;
+ else
+ k1 = KOR[0]/VAR[0]*B;
if (pred)
{
/* only needed for the actual predicted value, k1 is always needed */
- k2 = KOR[1]/VAR[1]*B;
+ if (VAR[1] == 0.0)
+ k2 = 0.0;
+ else
+ k2 = KOR[1]/VAR[1]*B;
predictedvalue = MUL(k1, r[0]) + MUL(k2, r[1]);
flt_round_inf(&predictedvalue);
--- a/libfaad/mdct.c
+++ b/libfaad/mdct.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: mdct.c,v 1.13 2002/08/17 10:03:15 menno Exp $
+** $Id: mdct.c,v 1.14 2002/08/17 11:15:31 menno Exp $
**/
/*
@@ -72,7 +72,7 @@
for (k = 0; k < N/4; k++)
{
- real_t angle = 2.0 * M_PI * (k + 1.0/8.0)/(real_t)N;
+ real_t angle = 2.0 * M_PI * ((real_t)k + 1.0/8.0)/(real_t)N;
mdct->sincos[k].sin = -sin(angle);
mdct->sincos[k].cos = -cos(angle);
}
@@ -138,8 +138,8 @@
Z1[k].re = MUL(fac, MUL(x1, sincos[k].cos) - MUL(x0, sincos[k].sin));
Z1[k].im = MUL(fac, MUL(x0, sincos[k].cos) + MUL(x1, sincos[k].sin));
#else
- Z1[2*k] = MUL(fac, MUL(x1, sincos[k].cos) - MUL(x0, sincos[k].sin));
- Z1[2*k+1] = MUL(fac, MUL(x0, sincos[k].cos) + MUL(x1, sincos[k].sin));
+ Z1[n] = MUL(fac, MUL(x1, sincos[k].cos) - MUL(x0, sincos[k].sin));
+ Z1[n+1] = MUL(fac, MUL(x0, sincos[k].cos) + MUL(x1, sincos[k].sin));
#endif
}
@@ -157,8 +157,9 @@
real_t zr = Z2[k].re;
real_t zi = Z2[k].im;
#else
- real_t zr = Z1[2*k];
- real_t zi = Z1[2*k+1];
+ uint16_t n = k << 1;
+ real_t zr = Z1[n];
+ real_t zi = Z1[n+1];
#endif
Z2[k].re = MUL(zr, sincos[k].cos) - MUL(zi, sincos[k].sin);
Z2[k].im = MUL(zi, sincos[k].cos) + MUL(zr, sincos[k].sin);
@@ -209,8 +210,8 @@
Z1[k ].re = -MUL(zr, sincos[k ].cos) - MUL(zi, sincos[k ].sin);
Z1[k ].im = -MUL(zi, sincos[k ].cos) + MUL(zr, sincos[k ].sin);
#else
- Z1[k*2 ] = -MUL(zr, sincos[k ].cos) - MUL(zi, sincos[k ].sin);
- Z1[k*2+1 ] = -MUL(zi, sincos[k ].cos) + MUL(zr, sincos[k ].sin);
+ Z1[n ] = -MUL(zr, sincos[k ].cos) - MUL(zi, sincos[k ].sin);
+ Z1[n+1 ] = -MUL(zi, sincos[k ].cos) + MUL(zr, sincos[k ].sin);
#endif
zr = X_in[ N2 - 1 - n] - X_in[ n];
@@ -220,8 +221,8 @@
Z1[k + N8].re = -MUL(zr, sincos[k + N8].cos) - MUL(zi, sincos[k + N8].sin);
Z1[k + N8].im = -MUL(zi, sincos[k + N8].cos) + MUL(zr, sincos[k + N8].sin);
#else
- Z1[k*2 + N8] = -MUL(zr, sincos[k + N8].cos) - MUL(zi, sincos[k + N8].sin);
- Z1[k*2+1 + N8] = -MUL(zi, sincos[k + N8].cos) + MUL(zr, sincos[k + N8].sin);
+ Z1[n + N8] = -MUL(zr, sincos[k + N8].cos) - MUL(zi, sincos[k + N8].sin);
+ Z1[n+1 + N8] = -MUL(zi, sincos[k + N8].cos) + MUL(zr, sincos[k + N8].sin);
#endif
}
@@ -240,8 +241,8 @@
real_t zr = MUL(2.0, MUL(Z2[k].re, sincos[k].cos) + MUL(Z2[k].im, sincos[k].sin));
real_t zi = MUL(2.0, MUL(Z2[k].im, sincos[k].cos) - MUL(Z2[k].re, sincos[k].sin));
#else
- real_t zr = MUL(2.0, MUL(Z1[k*2], sincos[k].cos) + MUL(Z1[k*2+1], sincos[k].sin));
- real_t zi = MUL(2.0, MUL(Z1[k*2+1], sincos[k].cos) - MUL(Z1[k*2], sincos[k].sin));
+ real_t zr = MUL(2.0, MUL(Z1[n], sincos[k].cos) + MUL(Z1[n+1], sincos[k].sin));
+ real_t zi = MUL(2.0, MUL(Z1[n+1], sincos[k].cos) - MUL(Z1[n], sincos[k].sin));
#endif
X_out[ n] = -zr;
--- a/libfaad/pns.c
+++ b/libfaad/pns.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: pns.c,v 1.8 2002/08/14 10:55:03 menno Exp $
+** $Id: pns.c,v 1.9 2002/08/17 11:15:32 menno Exp $
**/
#include "common.h"
@@ -84,8 +84,10 @@
/* 14496-3 says:
scale = 1.0f/(size * (real_t)sqrt(MEAN_NRG));
*/
- scale = 1.0f/(real_t)sqrt(size * MEAN_NRG);
- scale = MUL(scale, (real_t)exp(LN2 * 0.25 * scale_factor));
+ scale = sqrt(size * MEAN_NRG);
+ if (scale != 0.0)
+ scale = 1.0/scale;
+ scale = MUL(scale, exp(LN2 * 0.25 * scale_factor));
/* Scale random vector to desired target energy */
for (i = 0; i < size; i++)
@@ -98,7 +100,7 @@
uint16_t size, offs;
uint8_t group = 0;
- uint16_t nshort = frame_len/8;
+ uint16_t nshort = frame_len >> 3;
for (g = 0; g < ics->num_window_groups; g++)
{