summaryrefslogtreecommitdiff
path: root/quantise.h
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2025-08-15 12:42:40 +0200
committererdgeist <erdgeist@erdgeist.org>2025-08-15 12:42:40 +0200
commit30325d24d107dbf133da39f7c96d1510fd1c9449 (patch)
tree932baa5b2a4475821f16dccf9e3e05011daa6d92 /quantise.h
parent9022d768021bbe15c7815cc6f8b64218b46f0e10 (diff)
Bump to codec2 version 1.2.0erdgeist-bump-to-1.2.0
Diffstat (limited to 'quantise.h')
-rw-r--r--quantise.h116
1 files changed, 39 insertions, 77 deletions
diff --git a/quantise.h b/quantise.h
index 4baa87c..08d5532 100644
--- a/quantise.h
+++ b/quantise.h
@@ -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
56void quantise_init();
57float lpc_model_amplitudes(float Sn[], float w[], MODEL *model, int order, 50float lpc_model_amplitudes(float Sn[], float w[], MODEL *model, int order,
58 int lsp,float ak[]); 51 int lsp, float ak[]);
59void aks_to_M2(codec2_fftr_cfg fftr_fwd_cfg, float ak[], int order, MODEL *model, 52void 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
63int encode_Wo(C2CONST *c2const, float Wo, int bits); 56int encode_Wo(C2CONST *c2const, float Wo, int bits);
64float decode_Wo(C2CONST *c2const, int index, int bits); 57float decode_Wo(C2CONST *c2const, int index, int bits);
65int encode_log_Wo(C2CONST *c2const, float Wo, int bits); 58int encode_log_Wo(C2CONST *c2const, float Wo, int bits);
66float decode_log_Wo(C2CONST *c2const, int index, int bits); 59float decode_log_Wo(C2CONST *c2const, int index, int bits);
67#if 0 60void encode_lsps_scalar(int indexes[], float lsp[], int order);
68int encode_Wo_dt(C2CONST *c2const, float Wo, float prev_Wo); 61void decode_lsps_scalar(float lsp[], int indexes[], int order);
69float decode_Wo_dt(C2CONST *c2const, int index, float prev_Wo); 62void encode_lspds_scalar(int indexes[], float lsp[], int order);
70#endif 63void decode_lspds_scalar(float lsp[], int indexes[], int order);
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 64
86void encode_lsps_vq(int *indexes, float *x, float *xq, int order); 65void encode_lsps_vq(int *indexes, float *x, float *xq, int order);
87void decode_lsps_vq(int *indexes, float *xq, int order, int stages); 66void decode_lsps_vq(int *indexes, float *xq, int order, int stages);
88 67
89long quantise(const float * cb, float vec[], float w[], int k, int m, float *se); 68long quantise(const float *cb, float vec[], float w[], int k, int m, float *se);
90void lspvq_quantise(float lsp[], float lsp_[], int order); 69void lspvq_quantise(float lsp[], float lsp_[], int order);
91void lspjnd_quantise(float lsp[], float lsp_[], int order); 70void lspjmv_quantise(float lsps[], float lsps_[], 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 71
103void quantise_WoE(C2CONST *c2const, MODEL *model, float *e, float xq[]); 72void quantise_WoE(C2CONST *c2const, MODEL *model, float *e, float xq[]);
104int encode_WoE(MODEL *model, float e, float xq[]); 73int encode_WoE(MODEL *model, float e, float xq[]);
105void decode_WoE(C2CONST *c2const, MODEL *model, float *e, float xq[], int n1); 74void decode_WoE(C2CONST *c2const, MODEL *model, float *e, float xq[], int n1);
106 75
107int encode_energy(float e, int bits); 76int encode_energy(float e, int bits);
108float decode_energy(int index, int bits); 77float decode_energy(int index, int bits);
109 78
110void pack(unsigned char * bits, unsigned int *nbit, int index, unsigned int index_bits); 79void pack(unsigned char *bits, unsigned int *nbit, int index,
111void pack_natural_or_gray(unsigned char * bits, unsigned int *nbit, int index, unsigned int index_bits, unsigned int gray); 80 unsigned int index_bits);
112int unpack(const unsigned char * bits, unsigned int *nbit, unsigned int index_bits); 81void pack_natural_or_gray(unsigned char *bits, unsigned int *nbit, int index,
113int 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);
83int unpack(const unsigned char *bits, unsigned int *nbit,
84 unsigned int index_bits);
85int unpack_natural_or_gray(const unsigned char *bits, unsigned int *nbit,
86 unsigned int index_bits, unsigned int gray);
114 87
115int lsp_bits(int i); 88int lsp_bits(int i);
116int lspd_bits(int i); 89int lspd_bits(int i);
117int lspdt_bits(int i);
118int lsp_pred_vq_bits(int i); 90int lsp_pred_vq_bits(int i);
119int mel_bits(int i);
120int lspmelvq_cb_bits(int i);
121 91
122void apply_lpc_correction(MODEL *model); 92void apply_lpc_correction(MODEL *model);
123float speech_to_uq_lsps(float lsp[], 93float 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 );
130int check_lsp_order(float lsp[], int lpc_order); 95int check_lsp_order(float lsp[], int lpc_order);
131void bw_expand_lsps(float lsp[], int order, float min_sep_low, float min_sep_high); 96void bw_expand_lsps(float lsp[], int order, float min_sep_low,
97 float min_sep_high);
132void bw_expand_lsps2(float lsp[], int order); 98void bw_expand_lsps2(float lsp[], int order);
133void locate_lsps_jnd_steps(float lsp[], int order); 99void locate_lsps_jnd_steps(float lsp[], int order);
134float decode_amplitudes(MODEL *model, 100float 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