diff options
author | erdgeist@erdgeist.org <erdgeist@bauklotz.fritz.box> | 2019-07-04 23:26:09 +0200 |
---|---|---|
committer | erdgeist@erdgeist.org <erdgeist@bauklotz.fritz.box> | 2019-07-04 23:26:09 +0200 |
commit | f02dfce6e6c34b3d8a7b8a0e784b506178e331fa (patch) | |
tree | 45556e6104242d4702689760433d7321ae74ec17 /quantise.h |
stripdown of version 0.9
Diffstat (limited to 'quantise.h')
-rw-r--r-- | quantise.h | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/quantise.h b/quantise.h new file mode 100644 index 0000000..4baa87c --- /dev/null +++ b/quantise.h | |||
@@ -0,0 +1,141 @@ | |||
1 | /*---------------------------------------------------------------------------*\ | ||
2 | |||
3 | FILE........: quantise.h | ||
4 | AUTHOR......: David Rowe | ||
5 | DATE CREATED: 31/5/92 | ||
6 | |||
7 | Quantisation functions for the sinusoidal coder. | ||
8 | |||
9 | \*---------------------------------------------------------------------------*/ | ||
10 | |||
11 | /* | ||
12 | All rights reserved. | ||
13 | |||
14 | This program is free software; you can redistribute it and/or modify | ||
15 | it under the terms of the GNU Lesser General Public License version 2.1, as | ||
16 | published by the Free Software Foundation. This program is | ||
17 | distributed in the hope that it will be useful, but WITHOUT ANY | ||
18 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
19 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | ||
20 | License for more details. | ||
21 | |||
22 | You should have received a copy of the GNU Lesser General Public License | ||
23 | along with this program; if not, see <http://www.gnu.org/licenses/>. | ||
24 | */ | ||
25 | |||
26 | #ifndef __QUANTISE__ | ||
27 | #define __QUANTISE__ | ||
28 | |||
29 | #include "codec2_fft.h" | ||
30 | #include "comp.h" | ||
31 | |||
32 | #define WO_BITS 7 | ||
33 | #define WO_LEVELS (1<<WO_BITS) | ||
34 | #define WO_DT_BITS 3 | ||
35 | |||
36 | #define E_BITS 5 | ||
37 | #define E_LEVELS (1<<E_BITS) | ||
38 | #define E_MIN_DB -10.0 | ||
39 | #define E_MAX_DB 40.0 | ||
40 | |||
41 | #define LSP_SCALAR_INDEXES 10 | ||
42 | #define LSPD_SCALAR_INDEXES 10 | ||
43 | #define LSP_PRED_VQ_INDEXES 3 | ||
44 | #define LSP_DIFF_FREQ_INDEXES 5 | ||
45 | #define LSP_DIFF_TIME_BITS 7 | ||
46 | |||
47 | #define LSPDT_ALL 0 | ||
48 | #define LSPDT_LOW 1 | ||
49 | #define LSPDT_HIGH 2 | ||
50 | |||
51 | #define WO_E_BITS 8 | ||
52 | |||
53 | #define LPCPF_GAMMA 0.5 | ||
54 | #define LPCPF_BETA 0.2 | ||
55 | |||
56 | void quantise_init(); | ||
57 | float lpc_model_amplitudes(float Sn[], float w[], MODEL *model, int order, | ||
58 | int lsp,float ak[]); | ||
59 | void aks_to_M2(codec2_fftr_cfg fftr_fwd_cfg, float ak[], int order, MODEL *model, | ||
60 | float E, float *snr, int dump, int sim_pf, | ||
61 | int pf, int bass_boost, float beta, float gamma, COMP Aw[]); | ||
62 | |||
63 | int encode_Wo(C2CONST *c2const, float Wo, int bits); | ||
64 | float decode_Wo(C2CONST *c2const, int index, int bits); | ||
65 | int encode_log_Wo(C2CONST *c2const, float Wo, int bits); | ||
66 | float decode_log_Wo(C2CONST *c2const, int index, int bits); | ||
67 | #if 0 | ||
68 | int encode_Wo_dt(C2CONST *c2const, float Wo, float prev_Wo); | ||
69 | float decode_Wo_dt(C2CONST *c2const, int index, float prev_Wo); | ||
70 | #endif | ||
71 | void encode_lsps_scalar(int indexes[], float lsp[], int order); | ||
72 | void decode_lsps_scalar(float lsp[], int indexes[], int order); | ||
73 | void encode_lspds_scalar(int indexes[], float lsp[], int order); | ||
74 | void decode_lspds_scalar(float lsp[], int indexes[], int order); | ||
75 | void encode_lsps_diff_freq_vq(int indexes[], float lsp[], int order); | ||
76 | void decode_lsps_diff_freq_vq(float lsp_[], int indexes[], int order); | ||
77 | void encode_lsps_diff_time(int indexes[], | ||
78 | float lsp[], | ||
79 | float lsp__prev[], | ||
80 | int order); | ||
81 | void decode_lsps_diff_time(float lsp_[], | ||
82 | int indexes[], | ||
83 | float lsp__prev[], | ||
84 | int order); | ||
85 | |||
86 | void encode_lsps_vq(int *indexes, float *x, float *xq, int order); | ||
87 | void decode_lsps_vq(int *indexes, float *xq, int order, int stages); | ||
88 | |||
89 | long quantise(const float * cb, float vec[], float w[], int k, int m, float *se); | ||
90 | void lspvq_quantise(float lsp[], float lsp_[], int order); | ||
91 | void lspjnd_quantise(float lsp[], float lsp_[], int order); | ||
92 | void lspdt_quantise(float lsps[], float lsps_[], float lsps__prev[], int mode); | ||
93 | void lspjvm_quantise(float lsps[], float lsps_[], int order); | ||
94 | void lspanssi_quantise(float lsps[], float lsps_[], int order, int mbest_entries); | ||
95 | float lspmelvq_quantise(float *x, float *xq, int order); | ||
96 | |||
97 | float lspmelvq_mbest_encode(int *indexes, float *x, float *xq, int ndim, int mbest_entries); | ||
98 | void lspmelvq_decode(int *indexes, float *xq, int ndim); | ||
99 | |||
100 | void encode_mels_scalar(int mel_indexes[], float mels[], int order); | ||
101 | void decode_mels_scalar(float mels[], int mel_indexes[], int order); | ||
102 | |||
103 | void quantise_WoE(C2CONST *c2const, MODEL *model, float *e, float xq[]); | ||
104 | int encode_WoE(MODEL *model, float e, float xq[]); | ||
105 | void decode_WoE(C2CONST *c2const, MODEL *model, float *e, float xq[], int n1); | ||
106 | |||
107 | int encode_energy(float e, int bits); | ||
108 | float decode_energy(int index, int bits); | ||
109 | |||
110 | void pack(unsigned char * bits, unsigned int *nbit, int index, unsigned int index_bits); | ||
111 | void pack_natural_or_gray(unsigned char * bits, unsigned int *nbit, int index, unsigned int index_bits, unsigned int gray); | ||
112 | int unpack(const unsigned char * bits, unsigned int *nbit, unsigned int index_bits); | ||
113 | int unpack_natural_or_gray(const unsigned char * bits, unsigned int *nbit, unsigned int index_bits, unsigned int gray); | ||
114 | |||
115 | int lsp_bits(int i); | ||
116 | int lspd_bits(int i); | ||
117 | int lspdt_bits(int i); | ||
118 | int lsp_pred_vq_bits(int i); | ||
119 | int mel_bits(int i); | ||
120 | int lspmelvq_cb_bits(int i); | ||
121 | |||
122 | void apply_lpc_correction(MODEL *model); | ||
123 | float speech_to_uq_lsps(float lsp[], | ||
124 | float ak[], | ||
125 | float Sn[], | ||
126 | float w[], | ||
127 | int m_pitch, | ||
128 | int order | ||
129 | ); | ||
130 | int check_lsp_order(float lsp[], int lpc_order); | ||
131 | void bw_expand_lsps(float lsp[], int order, float min_sep_low, float min_sep_high); | ||
132 | void bw_expand_lsps2(float lsp[], int order); | ||
133 | void locate_lsps_jnd_steps(float lsp[], int order); | ||
134 | float decode_amplitudes(MODEL *model, | ||
135 | float ak[], | ||
136 | int lsp_indexes[], | ||
137 | int energy_index, | ||
138 | float lsps[], | ||
139 | float *e); | ||
140 | |||
141 | #endif | ||