1 /* Copyright (C) 2002-2007 Jean-Marc Valin
4 Describes the wideband 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.
36 #include "config-speex.h"
41 #include "quant_lsp.h"
42 #include "cb_search.h"
48 #include "os_support.h"
55 #ifndef ROCKBOX_VOICE_CODEC
56 const SpeexMode
* const speex_mode_list
[SPEEX_NB_MODES
] = {&speex_nb_mode
, &speex_wb_mode
, &speex_uwb_mode
};
58 const SpeexMode
* const speex_mode_list
[SPEEX_NB_MODES
] = {&speex_nb_mode
, &speex_wb_mode
, NULL
};
61 extern const signed char hexc_table
[];
62 extern const signed char hexc_10_32_table
[];
64 #ifndef DISABLE_WIDEBAND
66 /* Split-VQ innovation for high-band wideband */
67 static const split_cb_params split_cb_high
= {
70 hexc_table
, /*shape_cb*/
76 /* Split-VQ innovation for high-band wideband */
77 static const split_cb_params split_cb_high_lbr
= {
80 hexc_10_32_table
, /*shape_cb*/
88 static const SpeexSubmode wb_submode1
= {
94 #ifndef SPEEX_DISABLE_ENCODER
101 /*Pitch quantization*/
105 /*No innovation quantization*/
114 static const SpeexSubmode wb_submode2
= {
119 #ifndef SPEEX_DISABLE_ENCODER
123 /*Pitch quantization*/
127 /*Innovation quantization*/
128 split_cb_search_shape_sign
,
129 split_cb_shape_sign_unquant
,
134 /*Pitch quantization*/
138 /*Innovation quantization*/
140 split_cb_shape_sign_unquant
,
142 #ifdef DISABLE_WIDEBAND
152 static const SpeexSubmode wb_submode3
= {
157 #ifndef SPEEX_DISABLE_ENCODER
161 /*Pitch quantization*/
165 /*Innovation quantization*/
166 split_cb_search_shape_sign
,
167 split_cb_shape_sign_unquant
,
172 /*Pitch quantization*/
176 /*Innovation quantization*/
178 split_cb_shape_sign_unquant
,
180 #ifdef DISABLE_WIDEBAND
189 static const SpeexSubmode wb_submode4
= {
194 #ifndef SPEEX_DISABLE_ENCODER
198 /*Pitch quantization*/
202 /*Innovation quantization*/
203 split_cb_search_shape_sign
,
204 split_cb_shape_sign_unquant
,
209 /*Pitch quantization*/
213 /*Innovation quantization*/
215 split_cb_shape_sign_unquant
,
217 #ifdef DISABLE_WIDEBAND
227 /* Split-band wideband CELP mode*/
228 static const SpeexSBMode sb_wb_mode
= {
234 29491, 19661, /* gamma1, gamma2 */
236 0.9, 0.6, /* gamma1, gamma2 */
238 QCONST16(.0002,15), /*lpc_floor*/
240 {NULL
, &wb_submode1
, &wb_submode2
, &wb_submode3
, &wb_submode4
, NULL
, NULL
, NULL
},
242 {1, 8, 2, 3, 4, 5, 5, 6, 6, 7, 7},
243 {1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4},
251 const SpeexMode speex_wb_mode
= {
254 "wideband (sub-band CELP)",
257 #ifndef SPEEX_DISABLE_ENCODER
280 /* "Ultra-wideband" mode stuff */
284 #ifndef ROCKBOX_VOICE_CODEC
285 /* Split-band "ultra-wideband" (32 kbps) CELP mode*/
286 static const SpeexSBMode sb_uwb_mode
= {
292 29491, 19661, /* gamma1, gamma2 */
294 0.9, 0.6, /* gamma1, gamma2 */
296 QCONST16(.0002,15), /*lpc_floor*/
298 {NULL
, &wb_submode1
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
},
300 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
301 {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
309 int wb_mode_query(const void *mode
, int request
, void *ptr
)
311 const SpeexSBMode
*m
= (const SpeexSBMode
*)mode
;
315 case SPEEX_MODE_FRAME_SIZE
:
316 *((int*)ptr
)=2*m
->frameSize
;
318 case SPEEX_SUBMODE_BITS_PER_FRAME
:
320 *((int*)ptr
) = SB_SUBMODE_BITS
+1;
321 else if (m
->submodes
[*((int*)ptr
)]==NULL
)
324 *((int*)ptr
) = m
->submodes
[*((int*)ptr
)]->bits_per_frame
;
327 speex_warning_int("Unknown wb_mode_query request: ", request
);
334 #ifndef ROCKBOX_VOICE_CODEC
335 const SpeexMode speex_uwb_mode
= {
338 "ultra-wideband (sub-band CELP)",
341 #ifndef SPEEX_DISABLE_ENCODER
363 /* We have defined speex_lib_get_mode() as a macro in speex.h */
364 #undef speex_lib_get_mode
366 const SpeexMode
* speex_lib_get_mode (int mode
)
368 if (mode
< 0 || mode
>= SPEEX_NB_MODES
) return NULL
;
370 return speex_mode_list
[mode
];