diff options
author | erdgeist <erdgeist@erdgeist.org> | 2025-08-15 12:42:40 +0200 |
---|---|---|
committer | erdgeist <erdgeist@erdgeist.org> | 2025-08-15 12:42:40 +0200 |
commit | 30325d24d107dbf133da39f7c96d1510fd1c9449 (patch) | |
tree | 932baa5b2a4475821f16dccf9e3e05011daa6d92 /quantise.h | |
parent | 9022d768021bbe15c7815cc6f8b64218b46f0e10 (diff) |
Bump to codec2 version 1.2.0erdgeist-bump-to-1.2.0
Diffstat (limited to 'quantise.h')
-rw-r--r-- | quantise.h | 116 |
1 files changed, 39 insertions, 77 deletions
@@ -29,113 +29,75 @@ | |||
29 | #include "codec2_fft.h" | 29 | #include "codec2_fft.h" |
30 | #include "comp.h" | 30 | #include "comp.h" |
31 | 31 | ||
32 | #define WO_BITS 7 | 32 | #define WO_BITS 7 |
33 | #define WO_LEVELS (1<<WO_BITS) | 33 | #define WO_LEVELS (1 << WO_BITS) |
34 | #define WO_DT_BITS 3 | 34 | #define WO_DT_BITS 3 |
35 | 35 | ||
36 | #define E_BITS 5 | 36 | #define E_BITS 5 |
37 | #define E_LEVELS (1<<E_BITS) | 37 | #define E_LEVELS (1 << E_BITS) |
38 | #define E_MIN_DB -10.0 | 38 | #define E_MIN_DB -10.0 |
39 | #define E_MAX_DB 40.0 | 39 | #define E_MAX_DB 40.0 |
40 | 40 | ||
41 | #define LSP_SCALAR_INDEXES 10 | 41 | #define LSP_SCALAR_INDEXES 10 |
42 | #define LSPD_SCALAR_INDEXES 10 | 42 | #define LSPD_SCALAR_INDEXES 10 |
43 | #define LSP_PRED_VQ_INDEXES 3 | 43 | #define LSP_PRED_VQ_INDEXES 3 |
44 | #define LSP_DIFF_FREQ_INDEXES 5 | ||
45 | #define LSP_DIFF_TIME_BITS 7 | ||
46 | 44 | ||
47 | #define LSPDT_ALL 0 | 45 | #define WO_E_BITS 8 |
48 | #define LSPDT_LOW 1 | ||
49 | #define LSPDT_HIGH 2 | ||
50 | |||
51 | #define WO_E_BITS 8 | ||
52 | 46 | ||
53 | #define LPCPF_GAMMA 0.5 | 47 | #define LPCPF_GAMMA 0.5 |
54 | #define LPCPF_BETA 0.2 | 48 | #define LPCPF_BETA 0.2 |
55 | 49 | ||
56 | void quantise_init(); | ||
57 | float lpc_model_amplitudes(float Sn[], float w[], MODEL *model, int order, | 50 | float lpc_model_amplitudes(float Sn[], float w[], MODEL *model, int order, |
58 | int lsp,float ak[]); | 51 | int lsp, float ak[]); |
59 | void aks_to_M2(codec2_fftr_cfg fftr_fwd_cfg, float ak[], int order, MODEL *model, | 52 | void aks_to_M2(codec2_fftr_cfg fftr_fwd_cfg, float ak[], int order, |
60 | float E, float *snr, int dump, int sim_pf, | 53 | MODEL *model, float E, float *snr, int dump, int sim_pf, int pf, |
61 | int pf, int bass_boost, float beta, float gamma, COMP Aw[]); | 54 | int bass_boost, float beta, float gamma, COMP Aw[]); |
62 | 55 | ||
63 | int encode_Wo(C2CONST *c2const, float Wo, int bits); | 56 | int encode_Wo(C2CONST *c2const, float Wo, int bits); |
64 | float decode_Wo(C2CONST *c2const, int index, int bits); | 57 | float decode_Wo(C2CONST *c2const, int index, int bits); |
65 | int encode_log_Wo(C2CONST *c2const, float Wo, int bits); | 58 | int encode_log_Wo(C2CONST *c2const, float Wo, int bits); |
66 | float decode_log_Wo(C2CONST *c2const, int index, int bits); | 59 | float decode_log_Wo(C2CONST *c2const, int index, int bits); |
67 | #if 0 | 60 | void encode_lsps_scalar(int indexes[], float lsp[], int order); |
68 | int encode_Wo_dt(C2CONST *c2const, float Wo, float prev_Wo); | 61 | void decode_lsps_scalar(float lsp[], int indexes[], int order); |
69 | float decode_Wo_dt(C2CONST *c2const, int index, float prev_Wo); | 62 | void encode_lspds_scalar(int indexes[], float lsp[], int order); |
70 | #endif | 63 | void decode_lspds_scalar(float lsp[], int indexes[], int order); |
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 | 64 | ||
86 | void encode_lsps_vq(int *indexes, float *x, float *xq, int order); | 65 | 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); | 66 | void decode_lsps_vq(int *indexes, float *xq, int order, int stages); |
88 | 67 | ||
89 | long quantise(const float * cb, float vec[], float w[], int k, int m, float *se); | 68 | 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); | 69 | void lspvq_quantise(float lsp[], float lsp_[], int order); |
91 | void lspjnd_quantise(float lsp[], float lsp_[], int order); | 70 | void lspjmv_quantise(float lsps[], float lsps_[], 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 | 71 | ||
103 | void quantise_WoE(C2CONST *c2const, MODEL *model, float *e, float xq[]); | 72 | void quantise_WoE(C2CONST *c2const, MODEL *model, float *e, float xq[]); |
104 | int encode_WoE(MODEL *model, float e, float xq[]); | 73 | int encode_WoE(MODEL *model, float e, float xq[]); |
105 | void decode_WoE(C2CONST *c2const, MODEL *model, float *e, float xq[], int n1); | 74 | void decode_WoE(C2CONST *c2const, MODEL *model, float *e, float xq[], int n1); |
106 | 75 | ||
107 | int encode_energy(float e, int bits); | 76 | int encode_energy(float e, int bits); |
108 | float decode_energy(int index, int bits); | 77 | float decode_energy(int index, int bits); |
109 | 78 | ||
110 | void pack(unsigned char * bits, unsigned int *nbit, int index, unsigned int index_bits); | 79 | void pack(unsigned char *bits, unsigned int *nbit, int index, |
111 | void pack_natural_or_gray(unsigned char * bits, unsigned int *nbit, int index, unsigned int index_bits, unsigned int gray); | 80 | unsigned int index_bits); |
112 | int unpack(const unsigned char * bits, unsigned int *nbit, unsigned int index_bits); | 81 | void pack_natural_or_gray(unsigned char *bits, unsigned int *nbit, int index, |
113 | int unpack_natural_or_gray(const unsigned char * bits, unsigned int *nbit, unsigned int index_bits, unsigned int gray); | 82 | unsigned int index_bits, unsigned int gray); |
83 | int unpack(const unsigned char *bits, unsigned int *nbit, | ||
84 | unsigned int index_bits); | ||
85 | int unpack_natural_or_gray(const unsigned char *bits, unsigned int *nbit, | ||
86 | unsigned int index_bits, unsigned int gray); | ||
114 | 87 | ||
115 | int lsp_bits(int i); | 88 | int lsp_bits(int i); |
116 | int lspd_bits(int i); | 89 | int lspd_bits(int i); |
117 | int lspdt_bits(int i); | ||
118 | int lsp_pred_vq_bits(int i); | 90 | int lsp_pred_vq_bits(int i); |
119 | int mel_bits(int i); | ||
120 | int lspmelvq_cb_bits(int i); | ||
121 | 91 | ||
122 | void apply_lpc_correction(MODEL *model); | 92 | void apply_lpc_correction(MODEL *model); |
123 | float speech_to_uq_lsps(float lsp[], | 93 | float speech_to_uq_lsps(float lsp[], float ak[], float Sn[], float w[], |
124 | float ak[], | 94 | int m_pitch, int order); |
125 | float Sn[], | ||
126 | float w[], | ||
127 | int m_pitch, | ||
128 | int order | ||
129 | ); | ||
130 | int check_lsp_order(float lsp[], int lpc_order); | 95 | 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); | 96 | void bw_expand_lsps(float lsp[], int order, float min_sep_low, |
97 | float min_sep_high); | ||
132 | void bw_expand_lsps2(float lsp[], int order); | 98 | void bw_expand_lsps2(float lsp[], int order); |
133 | void locate_lsps_jnd_steps(float lsp[], int order); | 99 | void locate_lsps_jnd_steps(float lsp[], int order); |
134 | float decode_amplitudes(MODEL *model, | 100 | float decode_amplitudes(MODEL *model, float ak[], int lsp_indexes[], |
135 | float ak[], | 101 | int energy_index, float lsps[], float *e); |
136 | int lsp_indexes[], | ||
137 | int energy_index, | ||
138 | float lsps[], | ||
139 | float *e); | ||
140 | 102 | ||
141 | #endif | 103 | #endif |