mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 01:26:58 +00:00
update speex to 1.2rc1
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11979 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -43,28 +43,23 @@
|
||||
#include "sb_celp.h"
|
||||
#include "nb_celp.h"
|
||||
#include "vbr.h"
|
||||
#include "misc.h"
|
||||
#include "arch.h"
|
||||
#include <math.h>
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#define MAX_IN_SAMPLES 640
|
||||
|
||||
const SpeexMode * const speex_mode_list[SPEEX_NB_MODES] = {&speex_nb_mode, &speex_wb_mode, &speex_uwb_mode};
|
||||
|
||||
/* Extern declarations for all codebooks we use here */
|
||||
extern const signed char gain_cdbk_nb[];
|
||||
extern const signed char gain_cdbk_lbr[];
|
||||
extern const signed char hexc_table[];
|
||||
extern const signed char exc_5_256_table[];
|
||||
extern const signed char exc_5_64_table[];
|
||||
extern const signed char exc_8_128_table[];
|
||||
extern const signed char exc_10_32_table[];
|
||||
extern const signed char exc_10_16_table[];
|
||||
extern const signed char exc_20_32_table[];
|
||||
extern const signed char hexc_10_32_table[];
|
||||
|
||||
|
||||
/* Parameters for Long-Term Prediction (LTP)*/
|
||||
@@ -150,28 +145,7 @@ static const split_cb_params split_cb_sb = {
|
||||
0,
|
||||
};
|
||||
|
||||
#ifndef DISABLE_WIDEBAND
|
||||
|
||||
/* Split-VQ innovation for high-band wideband */
|
||||
static const split_cb_params split_cb_high = {
|
||||
8, /*subvect_size*/
|
||||
5, /*nb_subvect*/
|
||||
hexc_table, /*shape_cb*/
|
||||
7, /*shape_bits*/
|
||||
1,
|
||||
};
|
||||
|
||||
|
||||
/* Split-VQ innovation for high-band wideband */
|
||||
static const split_cb_params split_cb_high_lbr = {
|
||||
10, /*subvect_size*/
|
||||
4, /*nb_subvect*/
|
||||
hexc_10_32_table, /*shape_cb*/
|
||||
5, /*shape_bits*/
|
||||
0,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/* 2150 bps "vocoder-like" mode for comfort noise */
|
||||
static const SpeexSubmode nb_submode1 = {
|
||||
@@ -354,11 +328,7 @@ static const SpeexNBMode nb_mode = {
|
||||
#else
|
||||
0.9, 0.6, /* gamma1, gamma2 */
|
||||
#endif
|
||||
.012, /*lag_factor*/
|
||||
QCONST16(.0002,15), /*lpc_floor*/
|
||||
#ifdef EPIC_48K
|
||||
0,
|
||||
#endif
|
||||
{NULL, &nb_submode1, &nb_submode2, &nb_submode3, &nb_submode4, &nb_submode5, &nb_submode6, &nb_submode7,
|
||||
&nb_submode8, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
5,
|
||||
@@ -367,7 +337,7 @@ static const SpeexNBMode nb_mode = {
|
||||
|
||||
|
||||
/* Default mode for narrowband */
|
||||
const SpeexMode speex_nb_mode = {
|
||||
EXPORT const SpeexMode speex_nb_mode = {
|
||||
&nb_mode,
|
||||
nb_mode_query,
|
||||
"narrowband",
|
||||
@@ -384,290 +354,13 @@ const SpeexMode speex_nb_mode = {
|
||||
};
|
||||
|
||||
|
||||
/* Wideband part */
|
||||
|
||||
static const SpeexSubmode wb_submode1 = {
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_high,
|
||||
lsp_unquant_high,
|
||||
/*Pitch quantization*/
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
/*No innovation quantization*/
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
-1,
|
||||
36
|
||||
};
|
||||
|
||||
|
||||
static const SpeexSubmode wb_submode2 = {
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_high,
|
||||
lsp_unquant_high,
|
||||
/*Pitch quantization*/
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
/*Innovation quantization*/
|
||||
split_cb_search_shape_sign,
|
||||
split_cb_shape_sign_unquant,
|
||||
#ifdef DISABLE_WIDEBAND
|
||||
NULL,
|
||||
#else
|
||||
&split_cb_high_lbr,
|
||||
#endif
|
||||
-1,
|
||||
112
|
||||
};
|
||||
|
||||
|
||||
static const SpeexSubmode wb_submode3 = {
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_high,
|
||||
lsp_unquant_high,
|
||||
/*Pitch quantization*/
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
/*Innovation quantization*/
|
||||
split_cb_search_shape_sign,
|
||||
split_cb_shape_sign_unquant,
|
||||
#ifdef DISABLE_WIDEBAND
|
||||
NULL,
|
||||
#else
|
||||
&split_cb_high,
|
||||
#endif
|
||||
-1,
|
||||
192
|
||||
};
|
||||
|
||||
static const SpeexSubmode wb_submode4 = {
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_high,
|
||||
lsp_unquant_high,
|
||||
/*Pitch quantization*/
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
/*Innovation quantization*/
|
||||
split_cb_search_shape_sign,
|
||||
split_cb_shape_sign_unquant,
|
||||
#ifdef DISABLE_WIDEBAND
|
||||
NULL,
|
||||
#else
|
||||
&split_cb_high,
|
||||
#endif
|
||||
-1,
|
||||
352
|
||||
};
|
||||
|
||||
|
||||
/* Split-band wideband CELP mode*/
|
||||
static const SpeexSBMode sb_wb_mode = {
|
||||
&speex_nb_mode,
|
||||
160, /*frameSize*/
|
||||
40, /*subframeSize*/
|
||||
8, /*lpcSize*/
|
||||
640, /*bufSize*/
|
||||
#ifdef FIXED_POINT
|
||||
29491, 19661, /* gamma1, gamma2 */
|
||||
#else
|
||||
0.9, 0.6, /* gamma1, gamma2 */
|
||||
#endif
|
||||
.012, /*lag_factor*/
|
||||
QCONST16(.0002,15), /*lpc_floor*/
|
||||
0.9,
|
||||
{NULL, &wb_submode1, &wb_submode2, &wb_submode3, &wb_submode4, NULL, NULL, NULL},
|
||||
3,
|
||||
{1, 8, 2, 3, 4, 5, 5, 6, 6, 7, 7},
|
||||
{1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4},
|
||||
vbr_hb_thresh,
|
||||
5
|
||||
};
|
||||
|
||||
|
||||
const SpeexMode speex_wb_mode = {
|
||||
&sb_wb_mode,
|
||||
wb_mode_query,
|
||||
"wideband (sub-band CELP)",
|
||||
1,
|
||||
4,
|
||||
&sb_encoder_init,
|
||||
&sb_encoder_destroy,
|
||||
&sb_encode,
|
||||
&sb_decoder_init,
|
||||
&sb_decoder_destroy,
|
||||
&sb_decode,
|
||||
&sb_encoder_ctl,
|
||||
&sb_decoder_ctl,
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* "Ultra-wideband" mode stuff */
|
||||
|
||||
|
||||
|
||||
/* Split-band "ultra-wideband" (32 kbps) CELP mode*/
|
||||
static const SpeexSBMode sb_uwb_mode = {
|
||||
&speex_wb_mode,
|
||||
320, /*frameSize*/
|
||||
80, /*subframeSize*/
|
||||
8, /*lpcSize*/
|
||||
1280, /*bufSize*/
|
||||
#ifdef FIXED_POINT
|
||||
29491, 19661, /* gamma1, gamma2 */
|
||||
#else
|
||||
0.9, 0.6, /* gamma1, gamma2 */
|
||||
#endif
|
||||
.012, /*lag_factor*/
|
||||
QCONST16(.0002,15), /*lpc_floor*/
|
||||
0.7,
|
||||
{NULL, &wb_submode1, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
1,
|
||||
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
|
||||
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
|
||||
vbr_uhb_thresh,
|
||||
2
|
||||
};
|
||||
|
||||
|
||||
const SpeexMode speex_uwb_mode = {
|
||||
&sb_uwb_mode,
|
||||
wb_mode_query,
|
||||
"ultra-wideband (sub-band CELP)",
|
||||
2,
|
||||
4,
|
||||
&sb_encoder_init,
|
||||
&sb_encoder_destroy,
|
||||
&sb_encode,
|
||||
&sb_decoder_init,
|
||||
&sb_decoder_destroy,
|
||||
&sb_decode,
|
||||
&sb_encoder_ctl,
|
||||
&sb_decoder_ctl,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef EPIC_48K
|
||||
|
||||
extern const signed char gain_cdbk_ulbr[];
|
||||
extern const signed char exc_12_32_table[];
|
||||
|
||||
/* Parameters for Long-Term Prediction (LTP)*/
|
||||
static const ltp_params ltp_params_48k = {
|
||||
gain_cdbk_ulbr,
|
||||
3,
|
||||
0
|
||||
};
|
||||
|
||||
static const split_cb_params split_cb_nb_48k = {
|
||||
12, /*subvect_size*/
|
||||
4, /*nb_subvect*/
|
||||
exc_12_32_table, /*shape_cb*/
|
||||
5, /*shape_bits*/
|
||||
0,
|
||||
};
|
||||
|
||||
|
||||
/* 4.8 kbps very low bit-rate mode */
|
||||
static const SpeexSubmode nb_48k_submode = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
/*LSP quantization*/
|
||||
lsp_quant_48k,
|
||||
lsp_unquant_48k,
|
||||
/*No pitch quantization*/
|
||||
pitch_search_3tap,
|
||||
pitch_unquant_3tap,
|
||||
<p_params_48k,
|
||||
/*Innovation quantization*/
|
||||
split_cb_search_shape_sign,
|
||||
split_cb_shape_sign_unquant,
|
||||
&split_cb_nb_48k,
|
||||
#ifdef FIXED_POINT
|
||||
22938, 16384, 11796, 18022,
|
||||
#else
|
||||
0.7, 0.5, .36, .55,
|
||||
#endif
|
||||
144
|
||||
};
|
||||
|
||||
|
||||
/* Special, non-standard 4.8 kbps mode */
|
||||
static const SpeexNBMode nb_48k_mode = {
|
||||
240, /*frameSize*/
|
||||
48, /*subframeSize*/
|
||||
10, /*lpcSize*/
|
||||
640, /*bufSize*/
|
||||
17, /*pitchStart*/
|
||||
144, /*pitchEnd*/
|
||||
0.9, /*gamma1*/
|
||||
0.6, /*gamma2*/
|
||||
.01, /*lag_factor*/
|
||||
QCONST16(.0003,15), /*lpc_floor*/
|
||||
1,
|
||||
{NULL, NULL, &nb_48k_submode, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL},
|
||||
2,
|
||||
{2,2,2,2,2,2,2,2,2,2,2}
|
||||
};
|
||||
|
||||
|
||||
/* Default mode for narrowband */
|
||||
const SpeexMode speex_nb_48k_mode = {
|
||||
&nb_48k_mode,
|
||||
nb_mode_query,
|
||||
"narrowband 4.8 kbps",
|
||||
1000,
|
||||
4,
|
||||
&nb_encoder_init,
|
||||
&nb_encoder_destroy,
|
||||
&nb_encode,
|
||||
&nb_decoder_init,
|
||||
&nb_decoder_destroy,
|
||||
&nb_decode,
|
||||
&nb_encoder_ctl,
|
||||
&nb_decoder_ctl,
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
int speex_mode_query(const SpeexMode *mode, int request, void *ptr)
|
||||
EXPORT int speex_mode_query(const SpeexMode *mode, int request, void *ptr)
|
||||
{
|
||||
return mode->query(mode->mode, request, ptr);
|
||||
}
|
||||
|
||||
const SpeexMode * speex_lib_get_mode (int mode)
|
||||
{
|
||||
#ifdef EPIC_48K
|
||||
if (mode == SPEEX_MODEID_NB_48K) return &speex_nb_48k_mode;
|
||||
#ifdef FIXED_DEBUG
|
||||
long long spx_mips=0;
|
||||
#endif
|
||||
|
||||
if (mode < 0 || mode > SPEEX_NB_MODES) return NULL;
|
||||
|
||||
return speex_mode_list[mode];
|
||||
}
|
||||
|
Reference in New Issue
Block a user