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.
41 #include "quant_lsp.h"
42 #include "cb_search.h"
48 #include "os_support.h"
55 EXPORT
const SpeexMode
* const speex_mode_list
[SPEEX_NB_MODES
] = {&speex_nb_mode
, &speex_wb_mode
, &speex_uwb_mode
};
57 extern const signed char hexc_table
[];
58 extern const signed char hexc_10_32_table
[];
60 #ifndef DISABLE_WIDEBAND
62 /* Split-VQ innovation for high-band wideband */
63 static const split_cb_params split_cb_high
= {
66 hexc_table
, /*shape_cb*/
72 /* Split-VQ innovation for high-band wideband */
73 static const split_cb_params split_cb_high_lbr
= {
76 hexc_10_32_table
, /*shape_cb*/
84 static const SpeexSubmode wb_submode1
= {
92 /*Pitch quantization*/
96 /*No innovation quantization*/
105 static const SpeexSubmode wb_submode2
= {
113 /*Pitch quantization*/
117 /*Innovation quantization*/
118 split_cb_search_shape_sign
,
119 split_cb_shape_sign_unquant
,
120 #ifdef DISABLE_WIDEBAND
130 static const SpeexSubmode wb_submode3
= {
138 /*Pitch quantization*/
142 /*Innovation quantization*/
143 split_cb_search_shape_sign
,
144 split_cb_shape_sign_unquant
,
145 #ifdef DISABLE_WIDEBAND
154 static const SpeexSubmode wb_submode4
= {
162 /*Pitch quantization*/
166 /*Innovation quantization*/
167 split_cb_search_shape_sign
,
168 split_cb_shape_sign_unquant
,
169 #ifdef DISABLE_WIDEBAND
179 /* Split-band wideband CELP mode*/
180 static const SpeexSBMode sb_wb_mode
= {
186 29491, 19661, /* gamma1, gamma2 */
188 0.9, 0.6, /* gamma1, gamma2 */
190 QCONST16(.0002,15), /*lpc_floor*/
192 {NULL
, &wb_submode1
, &wb_submode2
, &wb_submode3
, &wb_submode4
, NULL
, NULL
, NULL
},
194 {1, 8, 2, 3, 4, 5, 5, 6, 6, 7, 7},
195 {1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4},
203 EXPORT
const SpeexMode speex_wb_mode
= {
206 "wideband (sub-band CELP)",
221 /* "Ultra-wideband" mode stuff */
225 /* Split-band "ultra-wideband" (32 kbps) CELP mode*/
226 static const SpeexSBMode sb_uwb_mode
= {
232 29491, 19661, /* gamma1, gamma2 */
234 0.9, 0.6, /* gamma1, gamma2 */
236 QCONST16(.0002,15), /*lpc_floor*/
238 {NULL
, &wb_submode1
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
},
240 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
241 {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
248 int wb_mode_query(const void *mode
, int request
, void *ptr
)
250 const SpeexSBMode
*m
= (const SpeexSBMode
*)mode
;
254 case SPEEX_MODE_FRAME_SIZE
:
255 *((int*)ptr
)=2*m
->frameSize
;
257 case SPEEX_SUBMODE_BITS_PER_FRAME
:
259 *((int*)ptr
) = SB_SUBMODE_BITS
+1;
260 else if (m
->submodes
[*((int*)ptr
)]==NULL
)
263 *((int*)ptr
) = m
->submodes
[*((int*)ptr
)]->bits_per_frame
;
266 speex_warning_int("Unknown wb_mode_query request: ", request
);
273 EXPORT
const SpeexMode speex_uwb_mode
= {
276 "ultra-wideband (sub-band CELP)",
289 /* We have defined speex_lib_get_mode() as a macro in speex.h */
290 #undef speex_lib_get_mode
292 EXPORT
const SpeexMode
* speex_lib_get_mode (int mode
)
294 if (mode
< 0 || mode
>= SPEEX_NB_MODES
) return NULL
;
296 return speex_mode_list
[mode
];