FreeCalypso > hg > gsm-codec-lib
annotate libgsmefr/enc_state.h @ 242:f081a6850fb5
libgsmfrp: new refined implementation
The previous implementation exhibited the following defects,
which are now fixed:
1) The last received valid SID was cached forever for the purpose of
handling future invalid SIDs - we could have received some valid
SID ages ago, then lots of speech or NO_DATA, and if we then get
an invalid SID, we would resurrect the last valid SID from ancient
history - a bad design. In our new design, we handle invalid SID
based on the current state, much like BFI.
2) GSM 06.11 spec says clearly that after the second lost SID
(received BFI=1 && TAF=1 in CN state) we need to gradually decrease
the output level, rather than jump directly to emitting silence
frames - we previously failed to implement such logic.
3) Per GSM 06.12 section 5.2, Xmaxc should be the same in all 4 subframes
in a SID frame. What should we do if we receive an otherwise valid
SID frame with different Xmaxc? Our previous approach would
replicate this Xmaxc oddity in every subsequent generated CN frame,
which is rather bad. In our new design, the very first CN frame
(which can be seen as a transformation of the SID frame itself)
retains the original 4 distinct Xmaxc, but all subsequent CN frames
are based on the Xmaxc from the last subframe of the most recent SID.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 09 May 2023 05:16:31 +0000 |
parents | 77803ce2cc22 |
children |
rev | line source |
---|---|
42
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this header file we define our encoder state structure. |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * This encoder state structure is internal to libgsmefr, |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * NOT part of our external public interface! |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 struct EFR_encoder_state { |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 /* from coder.c */ |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 Word16 dtx_mode; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 /* from cod_12k2.c */ |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 Word16 old_speech[L_TOTAL]; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 Word16 old_wsp[L_FRAME + PIT_MAX]; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 Word16 old_exc[L_FRAME + PIT_MAX + L_INTERPOL]; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 Word16 ai_zero[L_SUBFR + MP1]; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 Word16 hvec[L_SUBFR * 2]; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 Word16 lsp_old[M]; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 Word16 lsp_old_q[M]; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 Word16 mem_syn[M]; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 Word16 mem_w0[M]; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 Word16 mem_w[M]; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 Word16 mem_err[M + L_SUBFR]; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 /* from levinson.c */ |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 Word16 old_A[M + 1]; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 /* from pre_proc.c */ |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 struct preproc_state { |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 Word16 y2_hi; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 Word16 y2_lo; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 Word16 y1_hi; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 Word16 y1_lo; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 Word16 x0; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 Word16 x1; |
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 } pre_proc; |
48
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
33 /* from q_plsf_5.c */ |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
34 Word16 past_r2_q[M]; |
89
77803ce2cc22
libgsmefr: q_plsf_5.c compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
88
diff
changeset
|
35 Word16 lsf_p_CN[M]; |
48
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
36 /* from q_gains.c */ |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
37 Word16 past_qua_en[4]; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
38 Word16 pred[4]; |
88
03599300d2db
libgsmefr: q_gains.c compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
48
diff
changeset
|
39 Word16 gcode0_CN; |
48
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
40 /* from dtx.c */ |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
41 Word16 txdtx_ctrl; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
42 Word16 CN_excitation_gain; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
43 Word32 L_pn_seed_tx; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
44 Word16 txdtx_hangover; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
45 Word16 txdtx_N_elapsed; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
46 Word16 old_CN_mem_tx[6]; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
47 Word16 buf_p_tx; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
48 Word16 lsf_old_tx[DTX_HANGOVER][M]; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
49 Word16 gain_code_old_tx[4 * DTX_HANGOVER]; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
50 /* from vad.c */ |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
51 struct vad_state { |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
52 Word16 rvad[9]; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
53 Word16 scal_rvad; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
54 Pfloat thvad; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
55 Word32 L_sacf[27]; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
56 Word32 L_sav0[36]; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
57 Word16 pt_sacf; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
58 Word16 pt_sav0; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
59 Word32 L_lastdm; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
60 Word16 adaptcount; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
61 Word16 burstcount; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
62 Word16 hangcount; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
63 Word16 oldlagcount; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
64 Word16 veryoldlagcount; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
65 Word16 oldlag; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
66 } vad; |
af4b075d0313
libgsmefr: encoder state structure finished in first pass
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
67 Word16 ptch; |
42
ba044871c9dd
libgsmefr: beginning of encoder and decoder state structures
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 }; |