summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libspeex/sb_celp.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libspeex/sb_celp.h')
-rw-r--r--lib/rbcodec/codecs/libspeex/sb_celp.h160
1 files changed, 160 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libspeex/sb_celp.h b/lib/rbcodec/codecs/libspeex/sb_celp.h
new file mode 100644
index 0000000000..5a65d1ff8d
--- /dev/null
+++ b/lib/rbcodec/codecs/libspeex/sb_celp.h
@@ -0,0 +1,160 @@
1/* Copyright (C) 2002-2006 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*/
44typedef 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 first; /**< First frame? */
54 spx_word16_t lpc_floor; /**< Controls LPC analysis noise floor */
55 spx_word16_t gamma1; /**< Perceptual weighting coef 1 */
56 spx_word16_t gamma2; /**< Perceptual weighting coef 2 */
57
58 char *stack; /**< Temporary allocation stack */
59 spx_word16_t *high; /**< High-band signal (buffer) */
60 spx_word16_t *h0_mem, *h1_mem;
61
62 const spx_word16_t *window; /**< LPC analysis window */
63 const spx_word16_t *lagWindow; /**< Auto-correlation window */
64 spx_lsp_t *old_lsp; /**< LSPs of previous frame */
65 spx_lsp_t *old_qlsp; /**< Quantized LSPs of previous frame */
66 spx_coef_t *interp_qlpc; /**< Interpolated quantized LPCs for current sub-frame */
67
68 spx_mem_t *mem_sp; /**< Synthesis signal memory */
69 spx_mem_t *mem_sp2;
70 spx_mem_t *mem_sw; /**< Perceptual signal memory */
71 spx_word32_t *pi_gain;
72 spx_word16_t *exc_rms;
73 spx_word16_t *innov_rms_save; /**< If non-NULL, innovation is copied here */
74
75#ifndef DISABLE_VBR
76 float vbr_quality; /**< Quality setting for VBR encoding */
77 int vbr_enabled; /**< 1 for enabling VBR, 0 otherwise */
78 spx_int32_t vbr_max; /**< Max bit-rate allowed in VBR mode (total) */
79 spx_int32_t vbr_max_high; /**< Max bit-rate allowed in VBR mode for the high-band */
80 spx_int32_t abr_enabled; /**< ABR setting (in bps), 0 if off */
81 float abr_drift;
82 float abr_drift2;
83 float abr_count;
84 int vad_enabled; /**< 1 for enabling VAD, 0 otherwise */
85 float relative_quality;
86#endif /* #ifndef DISABLE_VBR */
87
88 int encode_submode;
89 const SpeexSubmode * const *submodes;
90 int submodeID;
91 int submodeSelect;
92 int complexity;
93 spx_int32_t sampling_rate;
94
95} SBEncState;
96
97
98/**Structure representing the full state of the sub-band decoder*/
99typedef struct SBDecState {
100 const SpeexMode *mode; /**< Pointer to the mode (containing for vtable info) */
101 void *st_low; /**< State of the low-band (narrowband) encoder */
102 int full_frame_size;
103 int frame_size;
104 int subframeSize;
105 int nbSubframes;
106 int lpcSize;
107 int first;
108 spx_int32_t sampling_rate;
109 int lpc_enh_enabled;
110
111 char *stack;
112 spx_word16_t g0_mem[64], g1_mem[64];
113
114/* Voice codec files will be WB mode, which has sub frame size of 40 */
115#ifndef ROCKBOX_VOICE_CODEC
116 spx_word16_t excBuf[80];
117#else
118 spx_word16_t excBuf[40];
119#endif
120 spx_lsp_t old_qlsp[8];
121 spx_coef_t interp_qlpc[8];
122
123 spx_mem_t mem_sp[16];
124 spx_word32_t pi_gain[4];
125 spx_word16_t exc_rms[4];
126 spx_word16_t *innov_save; /** If non-NULL, innovation is copied here */
127
128 spx_word16_t last_ener;
129 spx_int32_t seed;
130
131 int encode_submode;
132 const SpeexSubmode * const *submodes;
133 int submodeID;
134} SBDecState;
135
136
137/**Initializes encoder state*/
138void *sb_encoder_init(const SpeexMode *m);
139
140/**De-allocates encoder state resources*/
141void sb_encoder_destroy(void *state);
142
143/**Encodes one frame*/
144int sb_encode(void *state, void *in, SpeexBits *bits);
145
146
147/**Initializes decoder state*/
148void *sb_decoder_init(const SpeexMode *m);
149
150/**De-allocates decoder state resources*/
151void sb_decoder_destroy(void *state);
152
153/**Decodes one frame*/
154int sb_decode(void *state, SpeexBits *bits, void *out);
155
156int sb_encoder_ctl(void *state, int request, void *ptr);
157
158int sb_decoder_ctl(void *state, int request, void *ptr);
159
160#endif