1 /* Copyright (C) 2002-2006 Jean-Marc Valin
4 Describes the different modes of the codec
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
10 - Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
13 - Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
17 - Neither the name of the Xiph.org Foundation nor the names of its
18 contributors may be used to endorse or promote products derived from
19 this software without specific prior written permission.
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
25 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 #include "quant_lsp.h"
42 #include "cb_search.h"
54 /* Extern declarations for all codebooks we use here */
55 extern const signed char gain_cdbk_nb
[];
56 extern const signed char gain_cdbk_lbr
[];
57 extern const signed char exc_5_256_table
[];
58 extern const signed char exc_5_64_table
[];
59 extern const signed char exc_8_128_table
[];
60 extern const signed char exc_10_32_table
[];
61 extern const signed char exc_10_16_table
[];
62 extern const signed char exc_20_32_table
[];
65 /* Parameters for Long-Term Prediction (LTP)*/
66 static const ltp_params ltp_params_nb
= {
72 /* Parameters for Long-Term Prediction (LTP)*/
73 static const ltp_params ltp_params_vlbr
= {
79 /* Parameters for Long-Term Prediction (LTP)*/
80 static const ltp_params ltp_params_lbr
= {
86 /* Parameters for Long-Term Prediction (LTP)*/
87 static const ltp_params ltp_params_med
= {
93 /* Split-VQ innovation parameters for very low bit-rate narrowband */
94 static const split_cb_params split_cb_nb_vlbr
= {
97 exc_10_16_table
, /*shape_cb*/
102 /* Split-VQ innovation parameters for very low bit-rate narrowband */
103 static const split_cb_params split_cb_nb_ulbr
= {
106 exc_20_32_table
, /*shape_cb*/
111 /* Split-VQ innovation parameters for low bit-rate narrowband */
112 static const split_cb_params split_cb_nb_lbr
= {
115 exc_10_32_table
, /*shape_cb*/
121 /* Split-VQ innovation parameters narrowband */
122 static const split_cb_params split_cb_nb
= {
125 exc_5_64_table
, /*shape_cb*/
130 /* Split-VQ innovation parameters narrowband */
131 static const split_cb_params split_cb_nb_med
= {
134 exc_8_128_table
, /*shape_cb*/
139 /* Split-VQ innovation for low-band wideband */
140 static const split_cb_params split_cb_sb
= {
143 exc_5_256_table
, /*shape_cb*/
150 /* 2150 bps "vocoder-like" mode for comfort noise */
151 static const SpeexSubmode nb_submode1
= {
156 /* LSP quantization */
159 /* No pitch quantization */
161 forced_pitch_unquant
,
163 /* No innovation quantization (noise only) */
164 noise_codebook_quant
,
165 noise_codebook_unquant
,
171 /* 3.95 kbps very low bit-rate mode */
172 static const SpeexSubmode nb_submode8
= {
180 /*No pitch quantization*/
182 forced_pitch_unquant
,
184 /*Innovation quantization*/
185 split_cb_search_shape_sign
,
186 split_cb_shape_sign_unquant
,
192 /* 5.95 kbps very low bit-rate mode */
193 static const SpeexSubmode nb_submode2
= {
201 /*No pitch quantization*/
205 /*Innovation quantization*/
206 split_cb_search_shape_sign
,
207 split_cb_shape_sign_unquant
,
213 /* 8 kbps low bit-rate mode */
214 static const SpeexSubmode nb_submode3
= {
222 /*Pitch quantization*/
226 /*Innovation quantization*/
227 split_cb_search_shape_sign
,
228 split_cb_shape_sign_unquant
,
234 /* 11 kbps medium bit-rate mode */
235 static const SpeexSubmode nb_submode4
= {
243 /*Pitch quantization*/
247 /*Innovation quantization*/
248 split_cb_search_shape_sign
,
249 split_cb_shape_sign_unquant
,
255 /* 15 kbps high bit-rate mode */
256 static const SpeexSubmode nb_submode5
= {
264 /*Pitch quantization*/
268 /*Innovation quantization*/
269 split_cb_search_shape_sign
,
270 split_cb_shape_sign_unquant
,
276 /* 18.2 high bit-rate mode */
277 static const SpeexSubmode nb_submode6
= {
285 /*Pitch quantization*/
289 /*Innovation quantization*/
290 split_cb_search_shape_sign
,
291 split_cb_shape_sign_unquant
,
297 /* 24.6 kbps high bit-rate mode */
298 static const SpeexSubmode nb_submode7
= {
306 /*Pitch quantization*/
310 /*Innovation quantization*/
311 split_cb_search_shape_sign
,
312 split_cb_shape_sign_unquant
,
319 /* Default mode for narrowband */
320 static const SpeexNBMode nb_mode
= {
327 29491, 19661, /* gamma1, gamma2 */
329 0.9, 0.6, /* gamma1, gamma2 */
331 QCONST16(.0002,15), /*lpc_floor*/
332 {NULL
, &nb_submode1
, &nb_submode2
, &nb_submode3
, &nb_submode4
, &nb_submode5
, &nb_submode6
, &nb_submode7
,
333 &nb_submode8
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
},
335 {1, 8, 2, 3, 3, 4, 4, 5, 5, 6, 7}
339 /* Default mode for narrowband */
340 EXPORT
const SpeexMode speex_nb_mode
= {
358 EXPORT
int speex_mode_query(const SpeexMode
*mode
, int request
, void *ptr
)
360 return mode
->query(mode
->mode
, request
, ptr
);
364 long long spx_mips
=0;