1. What to do with the last frame that is smaller then frame size? During encoding, the last frame is often smaller than the required frame size. In the sample code, proper number of zeros are padded at the end. So if I don't want those padded zero after decoding, I assume that it is up to me to keep track of the number of zeros. Is it right? 2. What does SPEEX_GET_LOOKAHEAD do? How to use it? In speexenc.c, there is following code: ... speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &lookahead); ... nb_encoded = -lookahead; Can someone explain what this means? Thanks. j.p.
Jean-Marc Valin
2006-Oct-31 03:35 UTC
[Speex-dev] 2 questions, frame size and SPEEX_GET_LOOKAHEAD
Jia Pu a ?crit :> 1. What to do with the last frame that is smaller then frame size? > During encoding, the last frame is often smaller than the required frame > size. In the sample code, proper number of zeros are padded at the end. > So if I don't want those padded zero after decoding, I assume that it is > up to me to keep track of the number of zeros. Is it right?Right.> 2. What does SPEEX_GET_LOOKAHEAD do? How to use it? > In speexenc.c, there is following code: > > ... > speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &lookahead); > ... > nb_encoded = -lookahead; > > Can someone explain what this means?The lookahead is the number of samples you need to discard at the start. Jean-Marc
> >> 2. What does SPEEX_GET_LOOKAHEAD do? How to use it? >> In speexenc.c, there is following code: >> >> ... >> speex_encoder_ctl(st, SPEEX_GET_LOOKAHEAD, &lookahead); >> ... >> nb_encoded = -lookahead; >> >> Can someone explain what this means? > > The lookahead is the number of samples you need to discard at the > start. > > Jean-MarcIn my application, even 5ms (110 samples at 22KHz) matters. So what should I do to avoid discarding samples at the beginning? 1. Turning off look ahead? 2. Padding 0's at the beginning.