summaryrefslogtreecommitdiff
path: root/codec2_internal.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 /codec2_internal.h
stripdown of version 0.9
Diffstat (limited to 'codec2_internal.h')
-rw-r--r--codec2_internal.h106
1 files changed, 106 insertions, 0 deletions
diff --git a/codec2_internal.h b/codec2_internal.h
new file mode 100644
index 0000000..498a6c4
--- /dev/null
+++ b/codec2_internal.h
@@ -0,0 +1,106 @@
1/*---------------------------------------------------------------------------*\
2
3 FILE........: codec2_internal.h
4 AUTHOR......: David Rowe
5 DATE CREATED: April 16 2012
6
7 Header file for Codec2 internal states, exposed via this header
8 file to assist in testing.
9
10\*---------------------------------------------------------------------------*/
11
12/*
13 Copyright (C) 2012 David Rowe
14
15 All rights reserved.
16
17 This program is free software; you can redistribute it and/or modify
18 it under the terms of the GNU Lesser General Public License version 2.1, as
19 published by the Free Software Foundation. This program is
20 distributed in the hope that it will be useful, but WITHOUT ANY
21 WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
23 License for more details.
24
25 You should have received a copy of the GNU Lesser General Public License
26 along with this program; if not, see <http://www.gnu.org/licenses/>.
27*/
28
29#ifndef __CODEC2_INTERNAL__
30#define __CODEC2_INTERNAL__
31
32#include "codec2_fft.h"
33#include "newamp1.h"
34#include "newamp2.h"
35
36struct CODEC2 {
37 int mode;
38 C2CONST c2const;
39 int Fs;
40 int n_samp;
41 int m_pitch;
42 codec2_fft_cfg fft_fwd_cfg; /* forward FFT config */
43 codec2_fftr_cfg fftr_fwd_cfg; /* forward real FFT config */
44 float *w; /* [m_pitch] time domain hamming window */
45 COMP W[FFT_ENC]; /* DFT of w[] */
46 float *Pn; /* [2*n_samp] trapezoidal synthesis window */
47 float *bpf_buf; /* buffer for band pass filter */
48 float *Sn; /* [m_pitch] input speech */
49 float hpf_states[2]; /* high pass filter states */
50 void *nlp; /* pitch predictor states */
51 int gray; /* non-zero for gray encoding */
52
53 codec2_fftr_cfg fftr_inv_cfg; /* inverse FFT config */
54 float *Sn_; /* [2*n_samp] synthesised output speech */
55 float ex_phase; /* excitation model phase track */
56 float bg_est; /* background noise estimate for post filter */
57 float prev_f0_enc; /* previous frame's f0 estimate */
58 MODEL prev_model_dec; /* previous frame's model parameters */
59 float prev_lsps_dec[LPC_ORD]; /* previous frame's LSPs */
60 float prev_e_dec; /* previous frame's LPC energy */
61
62 int lpc_pf; /* LPC post filter on */
63 int bass_boost; /* LPC post filter bass boost */
64 float beta; /* LPC post filter parameters */
65 float gamma;
66
67 float xq_enc[2]; /* joint pitch and energy VQ states */
68 float xq_dec[2];
69
70 int smoothing; /* enable smoothing for channels with errors */
71 float *softdec; /* optional soft decn bits from demod */
72
73 /* newamp1 states */
74
75 float rate_K_sample_freqs_kHz[NEWAMP1_K];
76 float prev_rate_K_vec_[NEWAMP1_K];
77 float Wo_left;
78 int voicing_left;
79 codec2_fft_cfg phase_fft_fwd_cfg;
80 codec2_fft_cfg phase_fft_inv_cfg;
81 float se; /* running sum of squared error */
82 unsigned int nse; /* number of terms in sum */
83 float *user_rate_K_vec_no_mean_; /* optional, user supplied vector for quantisation experiments */
84 int post_filter_en;
85
86 /*newamp2 states (also uses newamp1 states )*/
87 float energy_prev;
88 float n2_rate_K_sample_freqs_kHz[NEWAMP2_K];
89 float n2_prev_rate_K_vec_[NEWAMP2_K];
90 float n2_pwb_rate_K_sample_freqs_kHz[NEWAMP2_16K_K];
91 float n2_pwb_prev_rate_K_vec_[NEWAMP2_16K_K];
92
93 /* used to dump features for deep learning experiments */
94 FILE *fmlfeat;
95
96 /* encode/decode function pointers for the selected mode */
97 void (*encode)(struct CODEC2 *c2, unsigned char * bits, short speech[]);
98 void (*decode)(struct CODEC2 *c2, short speech[], const unsigned char * bits);
99 void (*decode_ber)(struct CODEC2 *c2, short speech[], const unsigned char * bits, float ber_est);
100};
101
102// test and debug
103void analyse_one_frame(struct CODEC2 *c2, MODEL *model, short speech[]);
104void synthesise_one_frame(struct CODEC2 *c2, short speech[], MODEL *model,
105 COMP Aw[], float gain);
106#endif