[Speex-dev] speex corrupting input buffer?

Jean-Marc Valin Jean-Marc.Valin at USherbrooke.ca
Wed Apr 27 17:21:17 PDT 2005


Actually, it's an undocumented feature that returns the synthesized
signal (like decode, but no perceptual enhancement) in place of the
input. Why exactly you're getting garbage there (assuming the decoder
works fine), I'm not sure.

	Jean-Marc

Le mercredi 27 avril 2005 à 15:56 -0700, Steve Dekorte a écrit :
> 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
> 
> _______________________________________________
> Speex-dev mailing list
> Speex-dev at xiph.org
> http://lists.xiph.org/mailman/listinfo/speex-dev
> 
-- 
Jean-Marc Valin <Jean-Marc.Valin at USherbrooke.ca>
Université de Sherbrooke



More information about the Speex-dev mailing list