[Freeswitch-trunk] [commit] r6704 - freeswitch/trunk/src/mod/formats/mod_shout
Freeswitch SVN
anthm at freeswitch.org
Wed Dec 12 15:50:58 EST 2007
Author: anthm
Date: Wed Dec 12 15:50:58 2007
New Revision: 6704
Modified:
freeswitch/trunk/src/mod/formats/mod_shout/decode_ntom.c
freeswitch/trunk/src/mod/formats/mod_shout/interface.c
freeswitch/trunk/src/mod/formats/mod_shout/mpglib.h
Log:
make mpglib more not threadsafe
Modified: freeswitch/trunk/src/mod/formats/mod_shout/decode_ntom.c
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_shout/decode_ntom.c (original)
+++ freeswitch/trunk/src/mod/formats/mod_shout/decode_ntom.c Wed Dec 12 15:50:58 2007
@@ -20,12 +20,12 @@
else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
else { *(samples) = sum; }
-#define NTOM_MUL (32768)
-static unsigned long ntom_val[2] = { NTOM_MUL >> 1, NTOM_MUL >> 1 };
-static unsigned long ntom_step = NTOM_MUL;
+//static unsigned long ntom_val[2] = { NTOM_MUL >> 1, NTOM_MUL >> 1 };
+//static unsigned long ntom_step = NTOM_MUL;
-int synth_ntom_set_step(long m, long n)
+
+int synth_ntom_set_step(struct mpstr *mp, long m, long n)
{
if (param.verbose > 1)
debug_printf("Init rate converter: %ld->%ld\n", m, n);
@@ -36,14 +36,14 @@
}
n *= NTOM_MUL;
- ntom_step = n / m;
+ mp->ntom_step = n / m;
- if (ntom_step > 8 * NTOM_MUL) {
+ if (mp->ntom_step > 8 * NTOM_MUL) {
debug_printf("%d max. 1:8 conversion allowed!\n", __LINE__);
return (1);
}
- ntom_val[0] = ntom_val[1] = NTOM_MUL >> 1;
+ mp->ntom_val[0] = mp->ntom_val[1] = NTOM_MUL >> 1;
return (0);
@@ -89,12 +89,12 @@
bo--;
bo &= 0xf;
buf = mp->synth_buffs[0];
- ntom = ntom_val[1] = ntom_val[0];
+ ntom = mp->ntom_val[1] = mp->ntom_val[0];
} else {
samples++;
out += 2; /* to compute the right *pnt value */
buf = mp->synth_buffs[1];
- ntom = ntom_val[1];
+ ntom = mp->ntom_val[1];
}
if (bo & 0x1) {
@@ -116,7 +116,7 @@
for (j = 16; j; j--, window += 0x10) {
real sum;
- ntom += ntom_step;
+ ntom += mp->ntom_step;
if (ntom < NTOM_MUL) {
window += 16;
b0 += 16;
@@ -147,7 +147,7 @@
}
}
- ntom += ntom_step;
+ ntom += mp->ntom_step;
if (ntom >= NTOM_MUL) {
real sum;
sum = window[0x0] * b0[0x0];
@@ -172,7 +172,7 @@
for (j = 15; j; j--, b0 -= 0x20, window -= 0x10) {
real sum;
- ntom += ntom_step;
+ ntom += mp->ntom_step;
if (ntom < NTOM_MUL) {
window -= 16;
b0 += 16;
@@ -204,7 +204,7 @@
}
}
- ntom_val[channel] = ntom;
+ mp->ntom_val[channel] = ntom;
*pnt = ((unsigned char *) samples - out);
return clip;
Modified: freeswitch/trunk/src/mod/formats/mod_shout/interface.c
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_shout/interface.c (original)
+++ freeswitch/trunk/src/mod/formats/mod_shout/interface.c Wed Dec 12 15:50:58 2007
@@ -27,6 +27,9 @@
mp->bsnum = 0;
mp->synth_bo = 1;
mp->outsamplerate = samplerate;
+ mp->ntom_val[0] = NTOM_MUL >> 1;
+ mp->ntom_val[1] = NTOM_MUL >> 1;
+ mp->ntom_step = NTOM_MUL;
make_decode_tables_scale(mp, outscale);
@@ -241,7 +244,7 @@
m = n;
}
- if (synth_ntom_set_step(n, m))
+ if (synth_ntom_set_step(mp, n, m))
return MP3_ERR;
Modified: freeswitch/trunk/src/mod/formats/mod_shout/mpglib.h
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_shout/mpglib.h (original)
+++ freeswitch/trunk/src/mod/formats/mod_shout/mpglib.h Wed Dec 12 15:50:58 2007
@@ -3,6 +3,7 @@
#else
#define debug_printf(fmt,...)
#endif
+#define NTOM_MUL (32768)
struct buf {
unsigned char *pnt;
@@ -39,7 +40,8 @@
int longLimit[9][23]; /*sample limits re setting volume */
int shortLimit[9][14];
real decwin[512 + 32]; /* scale table */
-
+ unsigned long ntom_val[2];
+ unsigned long ntom_step;
};
#define BOOL int
@@ -54,7 +56,7 @@
int decodeMP3(struct mpstr *mp, char *inmemory, int inmemsize, char *outmemory, int outmemsize, int *done);
void ExitMP3(struct mpstr *mp);
-extern int synth_ntom_set_step(long, long);
+extern int synth_ntom_set_step(struct mpstr *mp, long, long);
extern int synth_ntom(struct mpstr *mp, real * bandPtr, int channel, unsigned char *out, int *pnt);
extern int synth_ntom_mono(struct mpstr *mp, real * bandPtr, unsigned char *samples, int *pnt);
extern int synth_ntom_8bit(real *, int, unsigned char *, int *);
More information about the Freeswitch-trunk
mailing list