ref: 8df0891e36371b20cbdcf620bbb1385a9e4faacb
parent: c8df480d2b56da715019481fc063b6dd9958f40a
author: menno <menno>
date: Fri Jan 25 15:15:07 EST 2002
Small PNS cleanup faster 32 bit rounding
--- a/libfaad/output.c
+++ b/libfaad/output.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: output.c,v 1.1 2002/01/14 19:15:56 menno Exp $
+** $Id: output.c,v 1.2 2002/01/25 20:15:07 menno Exp $
**/
#ifdef __ICL
@@ -30,10 +30,18 @@
#define ftol(A,B) {tmp = *(int*) & A - 0x4B7F8000; \
B = (short)((tmp==(short)tmp) ? tmp : (tmp>>31)^0x7FFF);}
#ifdef __ICL
-#define ROUND(x) ((int)floorf((x) + 0.5f))
+#define ROUND(x) ((long)floorf((x) + 0.5f))
#else
-#define ROUND(x) ((int)floor((x) + 0.5))
+#define ROUND(x) ((long)floor((x) + 0.5))
#endif
+
+#define HAVE_IEEE754_FLOAT
+#ifdef HAVE_IEEE754_FLOAT
+#define ROUND32(x) (floattmp = (x) + (long)0x00FD8000L, *(long*)(&floattmp) - (long)0x4B7D8000L)
+#else
+#define ROUND32(x) ROUND(x)
+#endif
+
#define FLOAT_SCALE (1.0f/(1<<15))
@@ -74,9 +82,11 @@
case FAAD_FMT_32BIT:
for (ch = 0; ch < channels; ch++)
{
+ float floattmp;
+
for(i = 0; i < 1024; i++)
{
- int_sample_buffer[(i*channels)+ch] = ROUND(input[ch][i]*(1<<16));
+ int_sample_buffer[(i*channels)+ch] = ROUND32(input[ch][i]*(1<<16));
}
}
break;
--- 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.1 2002/01/14 19:15:56 menno Exp $
+** $Id: pns.c,v 1.2 2002/01/25 20:15:07 menno Exp $
**/
#ifdef __ICL
@@ -44,11 +44,13 @@
-static __inline long random2(long *seed)
+static __inline long random2()
{
- *seed = (1664525L * *seed) + 1013904223L; /* Numerical recipes */
+ static long state = 1;
- return *seed;
+ state = (1664525L * state) + 1013904223L; /* Numerical recipes */
+
+ return state;
}
/* The function gen_rand_vector(addr, size) generates a vector of length
@@ -56,14 +58,30 @@
value. A suitable random number generator can be realized using one
multiplication/accumulation per random value.
*/
-static __inline void gen_rand_vector(float *spec, int size, long *state)
+static __inline void gen_rand_vector(float *spec, int scale_factor, int size)
{
int i;
+ float scale;
for (i = 0; i < size; i++)
{
- spec[i] = (float)random2(state);
+ spec[i] = (float)random2();
}
+
+ /* 14496-3 says:
+ scale = 1.0f/(size * (float)sqrt(MEAN_NRG));
+ */
+#ifdef __ICL
+ scale = 1.0f/sqrtf(size * MEAN_NRG);
+ scale *= powf(2.0f, 0.25f*scale_factor);
+#else
+ scale = 1.0f/(float)sqrt(size * MEAN_NRG);
+ scale *= (float)pow(2.0, 0.25*scale_factor);
+#endif
+
+ /* Scale random vector to desired target energy */
+ for (i = 0; i < size; i++)
+ spec[i] *= scale;
}
void pns_decode(ic_stream *ics, float *spec)
@@ -70,12 +88,9 @@
{
int g, sfb, b, i;
int size, offs;
- float scale;
int group = 0;
- static int state = 1;
-
for (g = 0; g < ics->num_window_groups; g++)
{
/* Do perceptual noise substitution decoding */
@@ -102,22 +117,8 @@
size = ics->swb_offset[sfb+1] - offs;
/* Generate random vector */
- gen_rand_vector(&spec[(group*128)+offs], size, &state);
-
- /* 14496-3 says:
- scale = 1.0f/(size * (float)sqrt(MEAN_NRG));
- */
-#ifdef __ICL
- scale = 1.0f/sqrtf(size * MEAN_NRG);
- scale *= powf(2.0f, 0.25f*ics->scale_factors[g][sfb]);
-#else
- scale = 1.0f/(float)sqrt(size * MEAN_NRG);
- scale *= (float)pow(2.0, 0.25*ics->scale_factors[g][sfb]);
-#endif
-
- /* Scale random vector to desired target energy */
- for (i = 0; i < size; i++)
- spec[(group*128)+offs+i] *= scale;
+ gen_rand_vector(&spec[(group*128)+offs],
+ ics->scale_factors[g][sfb], size);
}
}
group++;
--- a/libfaad/pns.h
+++ b/libfaad/pns.h
@@ -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.h,v 1.2 2002/01/19 09:39:41 menno Exp $
+** $Id: pns.h,v 1.3 2002/01/25 20:15:07 menno Exp $
**/
#ifndef __PNS_H__
@@ -34,8 +34,8 @@
void pns_decode(ic_stream *ics, float *spec);
-static __inline long random2(long *seed);
-static void gen_rand_vector(float *spec, int size, long *state);
+static __inline long random2();
+static void gen_rand_vector(float *spec, int scale_factor, int size);
static __inline int is_noise(ic_stream *ics, int group, int sfb)
{
--- a/plugins/in_mp4/in_mp4.rc
+++ b/plugins/in_mp4/in_mp4.rc
@@ -91,8 +91,8 @@
TBS_NOTICKS | WS_TABSTOP,13,15,18,39
CONTROL "16 bits",IDC_16BITS,"Button",BS_AUTORADIOBUTTON,77,18,
37,10
- CONTROL "24 bits",IDC_24BITS,"Button",BS_AUTORADIOBUTTON,77,30,
- 37,10
+ CONTROL "24 bits",IDC_24BITS,"Button",BS_AUTORADIOBUTTON |
+ WS_DISABLED,77,30,37,10
CONTROL "32 bits",IDC_32BITS,"Button",BS_AUTORADIOBUTTON,77,42,
37,10
CONTROL "Show errors",IDC_ERROR,"Button",BS_AUTOCHECKBOX |