[speex-dev] SPEEX_GET_SAMPLING_RATE of encoder is wrong

Chris Flerackers
Fri, 06 Aug 2004 15:02:00 -0000

Hi,

I'm using speex 1.1.4 and when I query SPEEX_GET_SAMPLING_RATE
as in
speex_encoder_ctl ( m_pEncoderState, SPEEX_GET_SAMPLING_RATE,
&m_SampleRate );
I get
2
The encoder is initialized with
m_pEncoderState = speex_encoder_init ( &speex_wb_mode );

On the decoder side, the correct sampling rate is returned:
m_pDecoderState = speex_decoder_init ( &speex_wb_mode );
speex_decoder_ctl ( m_pDecoderState, SPEEX_GET_SAMPLING_RATE,
&m_SampleRate );

I debugged the encoder and the stack trace is as follows:
-> speex_encoder_ctl ( m_pEncoderState, SPEEX_GET_SAMPLING_RATE,
&m_SampleRate );
-> int speex_encoder_ctl(void *state, int request, void *ptr)
    return (*((SpeexMode**)state))->enc_ctl(state, request, ptr);
-> int sb_encoder_ctl(void *state, int request, void *ptr)
...
case SPEEX_GET_SAMPLING_RATE:
      (*(int*)ptr)=st->sampling_rate;
      break;
...
And st->sampling_rate is 2.

I debugged some further and it seems:
sb_encoder_init
calls
speex_decoder_ctl(st->st_low, SPEEX_GET_SAMPLING_RATE,
&st->sampling_rate);
to get the sampling rate. I think it should be speex_encoder_ctl (otherwise
SBEncState * is
interpreted as SBDecState *).

Best regards,
Chris