Debian Codegraph @

3rdparty/iaxclient/lib/libspeex/sb_celp.h

raw symbols SCIP
1 /* Copyright (C) 2002 Jean-Marc Valin */
2 /**
3 @file sb_celp.h
4 @brief Sub-band CELP mode used for wideband encoding
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:
10
11 - Redistributions of source code must retain the above copyright
12 notice, this list of conditions and the following disclaimer.
13
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.
17
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.
21
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.
33
34 */
35
36 #ifndef SB_CELP_H
37 #define SB_CELP_H
38
39 #include "modes.h"
40 #include <speex/speex_bits.h>
41 #include "nb_celp.h"
42
43 /**Structure representing the full state of the sub-band encoder*/
44 typedef struct SBEncState {
45 const SpeexMode *mode; /**< Pointer to the mode (containing for vtable info) */
46 void *st_low; /**< State of the low-band (narrowband) encoder */
47 int full_frame_size; /**< Length of full-band frames*/
48 int frame_size; /**< Length of high-band frames*/
49 int subframeSize; /**< Length of high-band sub-frames*/
50 int nbSubframes; /**< Number of high-band sub-frames*/
51 int windowSize; /**< Length of high-band LPC window*/
52 int lpcSize; /**< Order of high-band LPC analysis */
53 int bufSize; /**< Buffer size */
54 int first; /**< First frame? */
55 float lag_factor; /**< Lag-windowing control parameter */
56 float lpc_floor; /**< Controls LPC analysis noise floor */
57 spx_word16_t gamma1; /**< Perceptual weighting coef 1 */
58 spx_word16_t gamma2; /**< Perceptual weighting coef 2 */
59
60 char *stack; /**< Temporary allocation stack */
61 spx_sig_t *x0d, *x1d; /**< QMF filter signals*/
62 spx_sig_t *high; /**< High-band signal (buffer) */
63 spx_sig_t *y0, *y1; /**< QMF synthesis signals */
64 spx_word16_t *h0_mem, *h1_mem;
65 spx_word32_t *g0_mem, *g1_mem; /**< QMF memories */
66
67 spx_sig_t *excBuf; /**< High-band excitation */
68 spx_sig_t *exc; /**< High-band excitation (for QMF only)*/
69 spx_sig_t *buf; /**< Temporary buffer */
70 spx_sig_t *res; /**< Zero-input response (ringing) */
71 spx_sig_t *sw; /**< Perceptually weighted signal */
72 spx_sig_t *target; /**< Weighted target signal (analysis by synthesis) */
73 spx_word16_t *window; /**< LPC analysis window */
74 spx_word16_t *lagWindow; /**< Auto-correlation window */
75 spx_word16_t *autocorr; /**< Auto-correlation (for LPC analysis) */
76 spx_coef_t *lpc; /**< LPC coefficients */
77 spx_lsp_t *lsp; /**< LSP coefficients */
78 spx_lsp_t *qlsp; /**< Quantized LSPs */
79 spx_lsp_t *old_lsp; /**< LSPs of previous frame */
80 spx_lsp_t *old_qlsp; /**< Quantized LSPs of previous frame */
81 spx_lsp_t *interp_lsp; /**< Interpolated LSPs for current sub-frame */
82 spx_lsp_t *interp_qlsp; /**< Interpolated quantized LSPs for current sub-frame */
83 spx_coef_t *interp_lpc; /**< Interpolated LPCs for current sub-frame */
84 spx_coef_t *interp_qlpc; /**< Interpolated quantized LPCs for current sub-frame */
85 spx_coef_t *bw_lpc1; /**< Bandwidth-expanded version of LPCs (#1) */
86 spx_coef_t *bw_lpc2; /**< Bandwidth-expanded version of LPCs (#2) */
87
88 spx_mem_t *mem_sp; /**< Synthesis signal memory */
89 spx_mem_t *mem_sp2;
90 spx_mem_t *mem_sw; /**< Perceptual signal memory */
91 spx_word32_t *pi_gain;
92
93 float vbr_quality; /**< Quality setting for VBR encoding */
94 int vbr_enabled; /**< 1 for enabling VBR, 0 otherwise */
95 int abr_enabled; /**< ABR setting (in bps), 0 if off */
96 float abr_drift;
97 float abr_drift2;
98 float abr_count;
99 int vad_enabled; /**< 1 for enabling VAD, 0 otherwise */
100 float relative_quality;
101
102 int encode_submode;
103 const SpeexSubmode * const *submodes;
104 int submodeID;
105 int submodeSelect;
106 int complexity;
107 int sampling_rate;
108
109 } SBEncState;
110
111
112 /**Structure representing the full state of the sub-band decoder*/
113 typedef struct SBDecState {
114 const SpeexMode *mode; /**< Pointer to the mode (containing for vtable info) */
115 void *st_low; /**< State of the low-band (narrowband) encoder */
116 int full_frame_size;
117 int frame_size;
118 int subframeSize;
119 int nbSubframes;
120 int lpcSize;
121 int first;
122 int sampling_rate;
123 int lpc_enh_enabled;
124
125 char *stack;
126 spx_sig_t *x0d, *x1d;
127 spx_sig_t *high;
128 spx_sig_t *y0, *y1;
129 spx_word32_t *g0_mem, *g1_mem;
130
131 spx_sig_t *exc;
132 spx_lsp_t *qlsp;
133 spx_lsp_t *old_qlsp;
134 spx_lsp_t *interp_qlsp;
135 spx_coef_t *interp_qlpc;
136
137 spx_mem_t *mem_sp;
138 spx_word32_t *pi_gain;
139
140 int encode_submode;
141 const SpeexSubmode * const *submodes;
142 int submodeID;
143 } SBDecState;
144
145
146 /**Initializes encoder state*/
147 void *sb_encoder_init(const SpeexMode *m);
148
149 /**De-allocates encoder state resources*/
150 void sb_encoder_destroy(void *state);
151
152 /**Encodes one frame*/
153 int sb_encode(void *state, void *in, SpeexBits *bits);
154
155
156 /**Initializes decoder state*/
157 void *sb_decoder_init(const SpeexMode *m);
158
159 /**De-allocates decoder state resources*/
160 void sb_decoder_destroy(void *state);
161
162 /**Decodes one frame*/
163 int sb_decode(void *state, SpeexBits *bits, void *out);
164
165 int sb_encoder_ctl(void *state, int request, void *ptr);
166
167 int sb_decoder_ctl(void *state, int request, void *ptr);
168
169 #endif