[Speex-dev] speex corrupting input buffer?
Steve Dekorte
steve at dekorte.com
Wed Apr 27 15:56:07 PDT 2005
It seems that speex (speex 1.0.4 on OSX 10.3.9) is writing over the
input buffer (with what looks like a sine wave). Included below is a
short program that demonstrates the problem. Is this a bug, or am I
doing something wrong? I don't see this behavior mentioned in the docs.
I don't really need the input buffer, but I'm guessing this problem is
related to a high pitched sound I'm getting after decoding since I get
a similar sound if I just play the corrupted input buffer.
Thanks,
Steve
// ------------------------------------
#include <speex.h>
#include <stdio.h>
int main(int argc, const char *argv[])
{
void *speexState;
int frame_size;
SpeexBits bits;
float *buf;
int i;
speex_bits_init(&(bits));
speexState = speex_encoder_init(&speex_wb_mode);
speex_encoder_ctl(speexState, SPEEX_GET_FRAME_SIZE, &(frame_size));
buf = (float *)calloc(1, frame_size * sizeof(float));
for (i = 0; i < frame_size; i ++)
{
if (buf[i] != 0.0)
{
printf("error, input buf not all zeros\n");
exit(1);
}
}
speex_bits_reset(&(bits));
speex_encode(speexState, buf, &(bits));
for (i = 0; i < frame_size; i ++)
{
if (buf[i] != 0.0)
{
printf("speex changed input buf[%i] of %i from 0.0 to %f\n", i,
frame_size, buf[i]);
}
}
free(buf);
}
// cc test.c -Iinclude -Llibspeex/.libs -lspeex -o test
// ./test
More information about the Speex-dev
mailing list