mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-26 15:20:21 +01:00
Update twolame to 0.3.13.
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* $Id: psycho_0.c,v 1.3 2008-02-01 19:44:33 richardash1981 Exp $
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -52,81 +52,80 @@
|
||||
logs, whatever. Fiddle with the numbers until we get a good SMR output */
|
||||
|
||||
|
||||
static psycho_0_mem *psycho_0_init (twolame_options *glopts, int sfreq)
|
||||
static psycho_0_mem *psycho_0_init(twolame_options * glopts, int sfreq)
|
||||
{
|
||||
FLOAT freqperline = (FLOAT)sfreq/1024.0;
|
||||
psycho_0_mem *mem = (psycho_0_mem *)TWOLAME_MALLOC(sizeof(psycho_0_mem));
|
||||
int sb, i;
|
||||
|
||||
for (sb=0;sb<SBLIMIT;sb++) {
|
||||
mem->ath_min[sb] = 1000; /* set it huge */
|
||||
}
|
||||
FLOAT freqperline = (FLOAT) sfreq / 1024.0;
|
||||
psycho_0_mem *mem = (psycho_0_mem *) TWOLAME_MALLOC(sizeof(psycho_0_mem));
|
||||
int sb, i;
|
||||
|
||||
/* Find the minimum ATH in each subband */
|
||||
for (i=0;i<512;i++) {
|
||||
FLOAT thisfreq = i * freqperline;
|
||||
FLOAT ath_val = ath_db(thisfreq, 0);
|
||||
if (ath_val < mem->ath_min[i>>4])
|
||||
mem->ath_min[i>>4] = ath_val;
|
||||
}
|
||||
for (sb = 0; sb < SBLIMIT; sb++) {
|
||||
mem->ath_min[sb] = 1000; /* set it huge */
|
||||
}
|
||||
|
||||
return mem;
|
||||
/* Find the minimum ATH in each subband */
|
||||
for (i = 0; i < 512; i++) {
|
||||
FLOAT thisfreq = i * freqperline;
|
||||
FLOAT ath_val = ath_db(thisfreq, 0);
|
||||
if (ath_val < mem->ath_min[i >> 4])
|
||||
mem->ath_min[i >> 4] = ath_val;
|
||||
}
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void psycho_0(twolame_options *glopts, FLOAT SMR[2][SBLIMIT], unsigned int scalar[2][3][SBLIMIT])
|
||||
void psycho_0(twolame_options * glopts, FLOAT SMR[2][SBLIMIT], unsigned int scalar[2][3][SBLIMIT])
|
||||
{
|
||||
psycho_0_mem *mem;
|
||||
int nch = glopts->num_channels_out;
|
||||
int sfreq = glopts->samplerate_out;
|
||||
int ch, sb, gr;
|
||||
unsigned int minscaleindex[2][SBLIMIT]; /* Smaller scale indexes mean bigger scalefactors */
|
||||
psycho_0_mem *mem;
|
||||
int nch = glopts->num_channels_out;
|
||||
int sfreq = glopts->samplerate_out;
|
||||
int ch, sb, gr;
|
||||
unsigned int minscaleindex[2][SBLIMIT]; /* Smaller scale indexes mean bigger scalefactors */
|
||||
|
||||
if (!glopts->p0mem) {
|
||||
glopts->p0mem = psycho_0_init(glopts, sfreq);
|
||||
}
|
||||
mem = glopts->p0mem;
|
||||
if (!glopts->p0mem) {
|
||||
glopts->p0mem = psycho_0_init(glopts, sfreq);
|
||||
}
|
||||
mem = glopts->p0mem;
|
||||
|
||||
|
||||
/* call functions for critical boundaries, freq. */
|
||||
if (!glopts->p0mem) { /* bands, bark values, and mapping */
|
||||
|
||||
} else {
|
||||
|
||||
mem = glopts->p0mem;
|
||||
|
||||
}
|
||||
/* call functions for critical boundaries, freq. */
|
||||
if (!glopts->p0mem) { /* bands, bark values, and mapping */
|
||||
|
||||
} else {
|
||||
|
||||
mem = glopts->p0mem;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Find the minimum scalefactor index for each ch/sb */
|
||||
for (ch=0;ch<nch;ch++)
|
||||
for (sb=0;sb<SBLIMIT;sb++)
|
||||
minscaleindex[ch][sb] = scalar[ch][0][sb];
|
||||
/* Find the minimum scalefactor index for each ch/sb */
|
||||
for (ch = 0; ch < nch; ch++)
|
||||
for (sb = 0; sb < SBLIMIT; sb++)
|
||||
minscaleindex[ch][sb] = scalar[ch][0][sb];
|
||||
|
||||
for (ch=0;ch<nch;ch++)
|
||||
for (gr=1;gr<3;gr++)
|
||||
for (sb=0;sb<SBLIMIT;sb++)
|
||||
if (minscaleindex[ch][sb] > scalar[ch][gr][sb])
|
||||
minscaleindex[ch][sb] = scalar[ch][gr][sb];
|
||||
for (ch = 0; ch < nch; ch++)
|
||||
for (gr = 1; gr < 3; gr++)
|
||||
for (sb = 0; sb < SBLIMIT; sb++)
|
||||
if (minscaleindex[ch][sb] > scalar[ch][gr][sb])
|
||||
minscaleindex[ch][sb] = scalar[ch][gr][sb];
|
||||
|
||||
/* Oh yeah. Fudge the hell out of the SMR calculations
|
||||
by combining the scalefactor table index and the min ATH in that subband
|
||||
There are probably more elegant/correct ways of combining these values,
|
||||
but who cares? It works pretty well
|
||||
MFC Mar 03 */
|
||||
for (ch=0;ch<nch;ch++)
|
||||
for (sb=0;sb<SBLIMIT;sb++)
|
||||
SMR[ch][sb] = 2.0 * (30.0 - minscaleindex[ch][sb]) - mem->ath_min[sb];
|
||||
/* Oh yeah. Fudge the hell out of the SMR calculations by combining the scalefactor table index
|
||||
and the min ATH in that subband There are probably more elegant/correct ways of combining
|
||||
these values, but who cares? It works pretty well MFC Mar 03 */
|
||||
for (ch = 0; ch < nch; ch++)
|
||||
for (sb = 0; sb < SBLIMIT; sb++)
|
||||
SMR[ch][sb] = 2.0 * (30.0 - minscaleindex[ch][sb]) - mem->ath_min[sb];
|
||||
}
|
||||
|
||||
|
||||
void psycho_0_deinit(psycho_0_mem **mem)
|
||||
void psycho_0_deinit(psycho_0_mem ** mem)
|
||||
{
|
||||
|
||||
if (mem==NULL||*mem==NULL) return;
|
||||
if (mem == NULL || *mem == NULL)
|
||||
return;
|
||||
|
||||
TWOLAME_FREE( *mem );
|
||||
TWOLAME_FREE(*mem);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user