134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)/* Copyright (C) 2002 Jean-Marc Valin
234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   File: speex.c
334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   Basic Speex functions
534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   Redistribution and use in source and binary forms, with or without
734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   modification, are permitted provided that the following conditions
834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   are met:
934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
1034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   - Redistributions of source code must retain the above copyright
1134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   notice, this list of conditions and the following disclaimer.
1234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
1334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   - Redistributions in binary form must reproduce the above copyright
1434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   notice, this list of conditions and the following disclaimer in the
1534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   documentation and/or other materials provided with the distribution.
1634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
1734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   - Neither the name of the Xiph.org Foundation nor the names of its
1834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   contributors may be used to endorse or promote products derived from
1934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   this software without specific prior written permission.
2034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
2134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
2534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
2934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
3334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)*/
3434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
3534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#ifdef HAVE_CONFIG_H
3634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#include "config.h"
3734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#endif
3834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
3934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#include "modes.h"
4034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#include <math.h>
4134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#include "os_support.h"
4234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
4334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#ifndef NULL
4434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#define NULL 0
4534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#endif
4634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
4734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#define MAX_IN_SAMPLES 640
4834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
4934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
5034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
5134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)EXPORT void *speex_encoder_init(const SpeexMode *mode)
5234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
5334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return mode->enc_init(mode);
5434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
5534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
5634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)EXPORT void *speex_decoder_init(const SpeexMode *mode)
5734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
5834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return mode->dec_init(mode);
5934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
6034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
6134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)EXPORT void speex_encoder_destroy(void *state)
6234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
6334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   (*((SpeexMode**)state))->enc_destroy(state);
6434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
6534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
6634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)EXPORT void speex_decoder_destroy(void *state)
6734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
6834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   (*((SpeexMode**)state))->dec_destroy(state);
6934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
7034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
7134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
7234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
7334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)int speex_encode_native(void *state, spx_word16_t *in, SpeexBits *bits)
7434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
7534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return (*((SpeexMode**)state))->enc(state, in, bits);
7634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
7734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
7834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)int speex_decode_native(void *state, SpeexBits *bits, spx_word16_t *out)
7934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
8034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return (*((SpeexMode**)state))->dec(state, bits, out);
8134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
8234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
8334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
8434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
8534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#ifdef FIXED_POINT
8634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
8734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#ifndef DISABLE_FLOAT_API
8834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)EXPORT int speex_encode(void *state, float *in, SpeexBits *bits)
8934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
9034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   int i;
9134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   spx_int32_t N;
9234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   spx_int16_t short_in[MAX_IN_SAMPLES];
9334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N);
9434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   for (i=0;i<N;i++)
9534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   {
9634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      if (in[i]>32767.f)
9734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         short_in[i] = 32767;
9834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      else if (in[i]<-32768.f)
9934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         short_in[i] = -32768;
10034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      else
10134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         short_in[i] = (spx_int16_t)floor(.5+in[i]);
10234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   }
10334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return (*((SpeexMode**)state))->enc(state, short_in, bits);
10434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
10534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#endif /* #ifndef DISABLE_FLOAT_API */
10634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
10734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)EXPORT int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits)
10834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
10934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   SpeexMode *mode;
11034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   mode = *(SpeexMode**)state;
11134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return (mode)->enc(state, in, bits);
11234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
11334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
11434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#ifndef DISABLE_FLOAT_API
11534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)EXPORT int speex_decode(void *state, SpeexBits *bits, float *out)
11634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
11734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   int i, ret;
11834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   spx_int32_t N;
11934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   spx_int16_t short_out[MAX_IN_SAMPLES];
12034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   speex_decoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N);
12134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   ret = (*((SpeexMode**)state))->dec(state, bits, short_out);
12234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   for (i=0;i<N;i++)
12334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      out[i] = short_out[i];
12434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return ret;
12534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
12634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#endif /* #ifndef DISABLE_FLOAT_API */
12734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
12834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)EXPORT int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out)
12934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
13034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   SpeexMode *mode = *(SpeexMode**)state;
13134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return (mode)->dec(state, bits, out);
13234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
13334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
13434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#else
13534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
13634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)EXPORT int speex_encode(void *state, float *in, SpeexBits *bits)
13734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
13834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return (*((SpeexMode**)state))->enc(state, in, bits);
13934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
14034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
14134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)EXPORT int speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits)
14234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
14334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   int i;
14434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   spx_int32_t N;
14534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   float float_in[MAX_IN_SAMPLES];
14634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   speex_encoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N);
14734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   for (i=0;i<N;i++)
14834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      float_in[i] = in[i];
14934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return (*((SpeexMode**)state))->enc(state, float_in, bits);
15034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
15134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
15234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)EXPORT int speex_decode(void *state, SpeexBits *bits, float *out)
15334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
15434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return (*((SpeexMode**)state))->dec(state, bits, out);
15534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
15634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
15734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)EXPORT int speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out)
15834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
15934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   int i;
16034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   spx_int32_t N;
16134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   float float_out[MAX_IN_SAMPLES];
16234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   int ret;
16334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   speex_decoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N);
16434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   ret = (*((SpeexMode**)state))->dec(state, bits, float_out);
16534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   for (i=0;i<N;i++)
16634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   {
16734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      if (float_out[i]>32767.f)
16834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         out[i] = 32767;
16934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      else if (float_out[i]<-32768.f)
17034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         out[i] = -32768;
17134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      else
17234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         out[i] = (spx_int16_t)floor(.5+float_out[i]);
17334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   }
17434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return ret;
17534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
17634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)#endif
17734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
17834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
17934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
18034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)EXPORT int speex_encoder_ctl(void *state, int request, void *ptr)
18134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
18234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return (*((SpeexMode**)state))->enc_ctl(state, request, ptr);
18334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
18434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
18534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)EXPORT int speex_decoder_ctl(void *state, int request, void *ptr)
18634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
18734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return (*((SpeexMode**)state))->dec_ctl(state, request, ptr);
18834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
18934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
19034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
19134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
19234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)int nb_mode_query(const void *mode, int request, void *ptr)
19334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
19434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   const SpeexNBMode *m = (const SpeexNBMode*)mode;
19534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
19634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   switch (request)
19734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   {
19834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   case SPEEX_MODE_FRAME_SIZE:
19934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      *((int*)ptr)=m->frameSize;
20034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      break;
20134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   case SPEEX_SUBMODE_BITS_PER_FRAME:
20234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      if (*((int*)ptr)==0)
20334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         *((int*)ptr) = NB_SUBMODE_BITS+1;
20434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      else if (m->submodes[*((int*)ptr)]==NULL)
20534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         *((int*)ptr) = -1;
20634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      else
20734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         *((int*)ptr) = m->submodes[*((int*)ptr)]->bits_per_frame;
20834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      break;
20934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   default:
21034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      speex_warning_int("Unknown nb_mode_query request: ", request);
21134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      return -1;
21234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   }
21334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return 0;
21434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
21534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
21634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
21734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)
21834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)EXPORT int speex_lib_ctl(int request, void *ptr)
21934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles){
22034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   switch (request)
22134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   {
22234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      case SPEEX_LIB_GET_MAJOR_VERSION:
22334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         *((int*)ptr) = SPEEX_MAJOR_VERSION;
22434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         break;
22534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      case SPEEX_LIB_GET_MINOR_VERSION:
22634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         *((int*)ptr) = SPEEX_MINOR_VERSION;
22734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         break;
22834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      case SPEEX_LIB_GET_MICRO_VERSION:
22934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         *((int*)ptr) = SPEEX_MICRO_VERSION;
23034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         break;
23134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      case SPEEX_LIB_GET_EXTRA_VERSION:
23234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         *((const char**)ptr) = SPEEX_EXTRA_VERSION;
23334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         break;
23434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      case SPEEX_LIB_GET_VERSION_STRING:
23534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         *((const char**)ptr) = SPEEX_VERSION;
23634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         break;
23734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      /*case SPEEX_LIB_SET_ALLOC_FUNC:
23834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         break;
23934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      case SPEEX_LIB_GET_ALLOC_FUNC:
24034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         break;
24134680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      case SPEEX_LIB_SET_FREE_FUNC:
24234680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         break;
24334680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      case SPEEX_LIB_GET_FREE_FUNC:
24434680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         break;*/
24534680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)      default:
24634680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         speex_warning_int("Unknown wb_mode_query request: ", request);
24734680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)         return -1;
24834680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   }
24934680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)   return 0;
25034680572440d7894ef8dafce81d8039ed80726a2Torne (Richard Coles)}
251