summaryrefslogtreecommitdiff
path: root/quantise.h
diff options
context:
space:
mode:
authorerdgeist@erdgeist.org <erdgeist@bauklotz.fritz.box>2019-07-04 23:26:09 +0200
committererdgeist@erdgeist.org <erdgeist@bauklotz.fritz.box>2019-07-04 23:26:09 +0200
commitf02dfce6e6c34b3d8a7b8a0e784b506178e331fa (patch)
tree45556e6104242d4702689760433d7321ae74ec17 /quantise.h
stripdown of version 0.9
Diffstat (limited to 'quantise.h')
-rw-r--r--quantise.h141
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
56void quantise_init();
57float lpc_model_amplitudes(float Sn[], float w[], MODEL *model, int order,
58 int lsp,float ak[]);
59void 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
63int encode_Wo(C2CONST *c2const, float Wo, int bits);
64float decode_Wo(C2CONST *c2const, int index, int bits);
65int encode_log_Wo(C2CONST *c2const, float Wo, int bits);
66float decode_log_Wo(C2CONST *c2const, int index, int bits);
67#if 0
68int encode_Wo_dt(C2CONST *c2const, float Wo, float prev_Wo);
69float decode_Wo_dt(C2CONST *c2const, int index, float prev_Wo);
70#endif
71void encode_lsps_scalar(int indexes[], float lsp[], int order);
72void decode_lsps_scalar(float lsp[], int indexes[], int order);
73void encode_lspds_scalar(int indexes[], float lsp[], int order);
74void decode_lspds_scalar(float lsp[], int indexes[], int order);
75void encode_lsps_diff_freq_vq(int indexes[], float lsp[], int order);
76void decode_lsps_diff_freq_vq(float lsp_[], int indexes[], int order);
77void encode_lsps_diff_time(int indexes[],
78 float lsp[],
79 float lsp__prev[],
80 int order);
81void decode_lsps_diff_time(float lsp_[],
82 int indexes[],
83 float lsp__prev[],
84 int order);
85
86void encode_lsps_vq(int *indexes, float *x, float *xq, int order);
87void decode_lsps_vq(int *indexes, float *xq, int order, int stages);
88
89long quantise(const float * cb, float vec[], float w[], int k, int m, float *se);
90void lspvq_quantise(float lsp[], float lsp_[], int order);
91void lspjnd_quantise(float lsp[], float lsp_[], int order);
92void lspdt_quantise(float lsps[], float lsps_[], float lsps__prev[], int mode);
93void lspjvm_quantise(float lsps[], float lsps_[], int order);
94void lspanssi_quantise(float lsps[], float lsps_[], int order, int mbest_entries);
95float lspmelvq_quantise(float *x, float *xq, int order);
96
97float lspmelvq_mbest_encode(int *indexes, float *x, float *xq, int ndim, int mbest_entries);
98void lspmelvq_decode(int *indexes, float *xq, int ndim);
99
100void encode_mels_scalar(int mel_indexes[], float mels[], int order);
101void decode_mels_scalar(float mels[], int mel_indexes[], int order);
102
103void quantise_WoE(C2CONST *c2const, MODEL *model, float *e, float xq[]);
104int encode_WoE(MODEL *model, float e, float xq[]);
105void decode_WoE(C2CONST *c2const, MODEL *model, float *e, float xq[], int n1);
106
107int encode_energy(float e, int bits);
108float decode_energy(int index, int bits);
109
110void pack(unsigned char * bits, unsigned int *nbit, int index, unsigned int index_bits);
111void pack_natural_or_gray(unsigned char * bits, unsigned int *nbit, int index, unsigned int index_bits, unsigned int gray);
112int unpack(const unsigned char * bits, unsigned int *nbit, unsigned int index_bits);
113int unpack_natural_or_gray(const unsigned char * bits, unsigned int *nbit, unsigned int index_bits, unsigned int gray);
114
115int lsp_bits(int i);
116int lspd_bits(int i);
117int lspdt_bits(int i);
118int lsp_pred_vq_bits(int i);
119int mel_bits(int i);
120int lspmelvq_cb_bits(int i);
121
122void apply_lpc_correction(MODEL *model);
123float speech_to_uq_lsps(float lsp[],
124 float ak[],
125 float Sn[],
126 float w[],
127 int m_pitch,
128 int order
129 );
130int check_lsp_order(float lsp[], int lpc_order);
131void bw_expand_lsps(float lsp[], int order, float min_sep_low, float min_sep_high);
132void bw_expand_lsps2(float lsp[], int order);
133void locate_lsps_jnd_steps(float lsp[], int order);
134float decode_amplitudes(MODEL *model,
135 float ak[],
136 int lsp_indexes[],
137 int energy_index,
138 float lsps[],
139 float *e);
140
141#endif