Checkin of validated codec used during development
[opal.git] / plugins / audio / Speex / libspeex / modes.h
blob0a94357c80d243f37d85137741c8cb178138716a
1 /* Copyright (C) 2002 Jean-Marc Valin */
2 /**
3 @file modes.h
4 @brief Describes the different modes of the codec
5 */
6 /*
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions
9 are met:
11 - Redistributions of source code must retain the above copyright
12 notice, this list of conditions and the following disclaimer.
14 - Redistributions in binary form must reproduce the above copyright
15 notice, this list of conditions and the following disclaimer in the
16 documentation and/or other materials provided with the distribution.
18 - Neither the name of the Xiph.org Foundation nor the names of its
19 contributors may be used to endorse or promote products derived from
20 this software without specific prior written permission.
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
26 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #ifndef MODES_H
37 #define MODES_H
39 #include "speex.h"
40 #include "speex_bits.h"
43 #define NB_SUBMODES 16
44 #define NB_SUBMODE_BITS 4
46 #define SB_SUBMODES 8
47 #define SB_SUBMODE_BITS 3
50 /** Quantizes LSPs */
51 typedef void (*lsp_quant_func)(float *, float *, int, SpeexBits *);
53 /** Decodes quantized LSPs */
54 typedef void (*lsp_unquant_func)(float *, int, SpeexBits *);
57 /** Long-term predictor quantization */
58 typedef int (*ltp_quant_func)(float *, float *, float *, float *,
59 float *, float *, void *, int, int, float,
60 int, int, SpeexBits*, char *, float *, float *, int);
62 /** Long-term un-quantize */
63 typedef void (*ltp_unquant_func)(float *, int, int, float, void *, int, int *,
64 float *, SpeexBits*, char*, int, int, float);
67 /** Innovation quantization function */
68 typedef void (*innovation_quant_func)(float *, float *, float *, float *, void *, int, int,
69 float *, float *, SpeexBits *, char *, int);
71 /** Innovation unquantization function */
72 typedef void (*innovation_unquant_func)(float *, void *, int, SpeexBits*, char *);
74 /** Description of a Speex sub-mode (wither narrowband or wideband */
75 typedef struct SpeexSubmode {
76 int lbr_pitch; /**< Set to -1 for "normal" modes, otherwise encode pitch using a global pitch and allowing a +- lbr_pitch variation (for low not-rates)*/
77 int forced_pitch_gain; /**< Use the same (forced) pitch gain for all sub-frames */
78 int have_subframe_gain; /**< Number of bits to use as sub-frame innovation gain */
79 int double_codebook; /**< Apply innovation quantization twice for higher quality (and higher bit-rate)*/
80 /*LSP functions*/
81 lsp_quant_func lsp_quant; /**< LSP quantization function */
82 lsp_unquant_func lsp_unquant; /**< LSP unquantization function */
84 /*Lont-term predictor functions*/
85 ltp_quant_func ltp_quant; /**< Long-term predictor (pitch) quantizer */
86 ltp_unquant_func ltp_unquant; /**< Long-term predictor (pitch) un-quantizer */
87 void *ltp_params; /**< Pitch parameters (options) */
89 /*Quantization of innovation*/
90 innovation_quant_func innovation_quant; /**< Innovation quantization */
91 innovation_unquant_func innovation_unquant; /**< Innovation un-quantization */
92 void *innovation_params; /**< Innovation quantization parameters*/
94 /*Synthesis filter enhancement*/
95 float lpc_enh_k1; /**< Enhancer constant */
96 float lpc_enh_k2; /**< Enhancer constant */
97 float comb_gain; /**< Gain of enhancer comb filter */
99 int bits_per_frame; /**< Number of bits per frame after encoding*/
100 } SpeexSubmode;
102 /** Struct defining the encoding/decoding mode*/
103 typedef struct SpeexNBMode {
104 int frameSize; /**< Size of frames used for encoding */
105 int subframeSize; /**< Size of sub-frames used for encoding */
106 int lpcSize; /**< Order of LPC filter */
107 int bufSize; /**< Size of signal buffer to use in encoder */
108 int pitchStart; /**< Smallest pitch value allowed */
109 int pitchEnd; /**< Largest pitch value allowed */
111 float gamma1; /**< Perceptual filter parameter #1 */
112 float gamma2; /**< Perceptual filter parameter #2 */
113 float lag_factor; /**< Lag-windowing parameter */
114 float lpc_floor; /**< Noise floor for LPC analysis */
115 float preemph; /**< Pre-emphasis */
117 SpeexSubmode *submodes[NB_SUBMODES]; /**< Sub-mode data for the mode */
118 int defaultSubmode; /**< Default sub-mode to use when encoding */
119 int quality_map[11]; /**< Mode corresponding to each quality setting */
120 } SpeexNBMode;
123 /** Struct defining the encoding/decoding mode for SB-CELP (wideband) */
124 typedef struct SpeexSBMode {
125 SpeexMode *nb_mode; /**< Embedded narrowband mode */
126 int frameSize; /**< Size of frames used for encoding */
127 int subframeSize; /**< Size of sub-frames used for encoding */
128 int lpcSize; /**< Order of LPC filter */
129 int bufSize; /**< Signal buffer size in encoder */
130 float gamma1; /**< Perceptual filter parameter #1 */
131 float gamma2; /**< Perceptual filter parameter #1 */
132 float lag_factor; /**< Lag-windowing parameter */
133 float lpc_floor; /**< Noise floor for LPC analysis */
134 float preemph; /**< Pre-emphasis */
135 float folding_gain;
137 SpeexSubmode *submodes[SB_SUBMODES]; /**< Sub-mode data for the mode */
138 int defaultSubmode; /**< Default sub-mode to use when encoding */
139 int low_quality_map[11]; /**< Mode corresponding to each quality setting */
140 int quality_map[11]; /**< Mode corresponding to each quality setting */
141 float (*vbr_thresh)[11];
142 int nb_modes;
143 } SpeexSBMode;
146 #endif