comparison libgsmfr2/tw_gsmfr.h @ 256:a33edf624061

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