annotate libgsmfr2/tw_gsmfr.h @ 382:693ea1d5cf1e

libtwamr: integrate int_lsf.c
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 May 2024 05:45:31 +0000
parents bebae251e5ee
children c95e89367321
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
256
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This header file is the external public interface to libgsmfr2:
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * Themyscira Wireless implementation of GSM FRv1 speech codec
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * that includes not only the core transcoding functions of GSM 06.10,
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * but also Rx DTX functions (substitution and muting per GSM 06.11,
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * comfort noise per GSM 06.12, overall Rx DTX control per GSM 06.31)
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 * in the decoder direction and the optional homing frame mechanism.
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 *
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 * This header file should be installed in some system include directory
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 * such that it can be included by C sources as <tw_gsmfr.h>.
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #ifndef __THEMWI_GSMFR_H
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #define __THEMWI_GSMFR_H
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #include <stdint.h>
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 #define GSMFR_RTP_FRAME_LEN 33
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 #define GSMFR_NUM_PARAMS 76
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 /*
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 * GSM 06.10 encoder & decoder portion of the library
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 *
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 * This part is peculiar in that the same state structure is used for
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 * both the encoder and the decoder - however, each given instance
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 * of this state structure must be used for only one of the two.
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 struct gsmfr_0610_state; /* opaque to external users */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 struct gsmfr_0610_state *gsmfr_0610_create(void);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 /* use standard free() call to free it afterward */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 /* reset state to initial */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 void gsmfr_0610_reset(struct gsmfr_0610_state *state);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 /* interface structure for passing frames of codec parameters */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 struct gsmfr_param_frame {
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 int16_t LARc[8];
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 int16_t Nc[4];
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 int16_t bc[4];
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 int16_t Mc[4];
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 int16_t xmaxc[4];
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 int16_t xMc[4][13];
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 };
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 /* encoder public functions */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 void gsmfr_0610_encode_params(struct gsmfr_0610_state *st, const int16_t *pcm,
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 struct gsmfr_param_frame *param);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 void gsmfr_0610_encode_frame(struct gsmfr_0610_state *st, const int16_t *pcm,
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 uint8_t *frame);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 void gsmfr_0610_encoder_homing(struct gsmfr_0610_state *st, const int16_t *pcm);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 /* decoder public functions */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 void gsmfr_0610_decode_params(struct gsmfr_0610_state *st,
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 const struct gsmfr_param_frame *param,
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 int16_t *pcm);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 void gsmfr_0610_decode_frame(struct gsmfr_0610_state *st, const uint8_t *frame,
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 int16_t *pcm);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 /* conversion between RTP packed format and struct gsmfr_param_frame */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 void gsmfr_pack_frame(const struct gsmfr_param_frame *param, uint8_t *frame);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 void gsmfr_unpack_frame(const uint8_t *frame, struct gsmfr_param_frame *param);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68
259
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 256
diff changeset
69 /* similar conversions with a linear array of params */
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 256
diff changeset
70
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 256
diff changeset
71 void gsmfr_pack_from_array(const int16_t *params, uint8_t *frame);
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 256
diff changeset
72 void gsmfr_unpack_to_array(const uint8_t *frame, int16_t *params);
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 256
diff changeset
73
256
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 /* Rx DTX handler preprocessor portion of the library */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 struct gsmfr_preproc_state; /* opaque to external users */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 struct gsmfr_preproc_state *gsmfr_preproc_create(void);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 /* use standard free() call to free it afterward */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 /* reset state to initial */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 void gsmfr_preproc_reset(struct gsmfr_preproc_state *state);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 /* main processing functions */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 void gsmfr_preproc_good_frame(struct gsmfr_preproc_state *state,
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 uint8_t *frame);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 void gsmfr_preproc_bfi(struct gsmfr_preproc_state *state, int taf,
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 uint8_t *frame_out);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 /* utility function */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 int gsmfr_preproc_sid_classify(const uint8_t *frame);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 /* utility datum */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 extern const uint8_t gsmfr_preproc_silence_frame[GSMFR_RTP_FRAME_LEN];
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 /*
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 * Full GSM-FR decoder: Rx DTX handler followed by 06.10 decoder,
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 * plus the decoder homing function.
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 struct gsmfr_fulldec_state; /* opaque to external users */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 struct gsmfr_fulldec_state *gsmfr_fulldec_create(void);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 /* use standard free() call to free it afterward */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 /* reset state to initial */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 void gsmfr_fulldec_reset(struct gsmfr_fulldec_state *state);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 /* main processing functions */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 void gsmfr_fulldec_good_frame(struct gsmfr_fulldec_state *state,
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 const uint8_t *frame, int16_t *pcm);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 void gsmfr_fulldec_bfi(struct gsmfr_fulldec_state *state, int taf,
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 int16_t *pcm);
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 /* utility datum */
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 extern const uint8_t gsmfr_decoder_homing_frame[GSMFR_RTP_FRAME_LEN];
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117
a33edf624061 libgsmfr2: start with API definition and port of libgsmfrp code
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 #endif /* include guard */