mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-20 19:12:03 +00:00
some debugging checks in the resampler
This commit is contained in:
parent
31651088f8
commit
2d4649f183
1 changed files with 47 additions and 33 deletions
|
@ -29,48 +29,62 @@ void *Snd_Resample(int inrate, int inwidth, int innumsamples, int channels, cons
|
||||||
exit(5);
|
exit(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call the resampler
|
// See if we need to resample
|
||||||
static SpeexResamplerState *st = NULL;
|
if (inrate == outrate)
|
||||||
if (st == NULL)
|
|
||||||
{
|
{
|
||||||
st = speex_resampler_init(channels, inrate, outrate, 5, NULL);
|
memcpy(outdata, in16bit, innumsamples * channels * 2);
|
||||||
|
*outnumsamples = innumsamples;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
speex_resampler_reset_mem(st);
|
|
||||||
}
|
|
||||||
speex_resampler_set_rate(st, inrate, outrate);
|
|
||||||
|
|
||||||
*outnumsamples = 0;
|
|
||||||
unsigned int consumedtotal = 0;
|
|
||||||
unsigned int outputtotal = 0;
|
|
||||||
unsigned int loops = 0;
|
|
||||||
unsigned int consumed, output;
|
|
||||||
while (consumedtotal < innumsamples)
|
|
||||||
{
|
|
||||||
int roomToConsume, roomToOutput;
|
|
||||||
|
|
||||||
consumed = innumsamples - consumedtotal;
|
// Call the resampler
|
||||||
output = maxsamples - outputtotal;
|
static SpeexResamplerState *st = NULL;
|
||||||
|
if (st == NULL)
|
||||||
roomToConsume = consumed;
|
|
||||||
roomToOutput = output;
|
|
||||||
|
|
||||||
speex_resampler_process_interleaved_int(st, in16bit + consumedtotal, &consumed, outdata + outputtotal, &output);
|
|
||||||
consumedtotal += consumed;
|
|
||||||
outputtotal += output;
|
|
||||||
|
|
||||||
loops++;
|
|
||||||
if (loops > 100)
|
|
||||||
{
|
{
|
||||||
Con_Printf("Infinite loop\n");
|
st = speex_resampler_init(channels, inrate, outrate, 0, NULL);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
speex_resampler_reset_mem(st);
|
||||||
|
}
|
||||||
|
speex_resampler_set_rate(st, inrate, outrate);
|
||||||
|
|
||||||
|
*outnumsamples = 0;
|
||||||
|
unsigned int consumedtotal = 0;
|
||||||
|
unsigned int outputtotal = 0;
|
||||||
|
unsigned int loops = 0;
|
||||||
|
unsigned int consumed, output;
|
||||||
|
while (consumedtotal < innumsamples)
|
||||||
|
{
|
||||||
|
int roomToConsume, roomToOutput;
|
||||||
|
|
||||||
|
consumed = innumsamples - consumedtotal;
|
||||||
|
output = maxsamples - outputtotal;
|
||||||
|
|
||||||
|
roomToConsume = consumed;
|
||||||
|
roomToOutput = output;
|
||||||
|
|
||||||
|
speex_resampler_process_interleaved_int(st, in16bit + consumedtotal, &consumed, outdata + outputtotal, &output);
|
||||||
|
consumedtotal += consumed;
|
||||||
|
outputtotal += output;
|
||||||
|
|
||||||
|
loops++;
|
||||||
|
if (loops > 100)
|
||||||
|
{
|
||||||
|
Con_Printf("Infinite loop\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*outnumsamples = outputtotal;
|
||||||
|
|
||||||
|
if (*outnumsamples != (innumsamples / frac))
|
||||||
|
{
|
||||||
|
Con_Printf("Output %d, predicted %d\n", *outnumsamples, (innumsamples / frac));
|
||||||
|
}
|
||||||
|
//speex_resampler_destroy(resampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
*outnumsamples = outputtotal;
|
|
||||||
|
|
||||||
//speex_resampler_destroy(resampler);
|
|
||||||
|
|
||||||
if (in16bit != indata)
|
if (in16bit != indata)
|
||||||
{
|
{
|
||||||
free(in16bit);
|
free(in16bit);
|
||||||
|
|
Loading…
Reference in a new issue