annotate libgsmhr1/tw_gsmhr.h @ 500:66fb1fd032e6

libgsmhr1/mathhalf.[ch]: import original
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 19 Jun 2024 00:51:26 +0000
parents af70bf42eb1b
children 5bf71b091323
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
489
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This header file is the external public interface to libgsmhr1:
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * Themyscira Wireless implementation of GSM HRv1 speech codec
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * based on the original ETSI code of GSM 06.06.
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 *
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 * This header file should be installed in some system include directory
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 * such that it can be included by C sources as <tw_gsmhr.h>.
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 */
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #ifndef __THEMWI_GSMHR_H
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #define __THEMWI_GSMHR_H
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <stdint.h>
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #define GSMHR_NUM_PARAMS 18 /* actual codec parameters */
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #define GSMHR_NUM_PARAMS_ENC 20 /* output from the encoder */
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 #define GSMHR_NUM_PARAMS_DEC 22 /* input to the decoder */
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 #define GSMHR_FRAME_LEN_RPF 14 /* raw packed format */
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 #define GSMHR_FRAME_LEN_5993 15 /* RFC 5993 and TW-TS-002 */
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 /* stateful encoder and decoder engines */
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 struct gsmhr_encoder_state; /* opaque to external users */
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 struct gsmhr_decoder_state; /* ditto */
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 struct gsmhr_encoder_state *gsmhr_encoder_create(int dtx);
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 struct gsmhr_decoder_state *gsmhr_decoder_create(void);
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 /* use standard free() call to free both afterward */
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 /* reset state to initial */
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 void gsmhr_encoder_reset(struct gsmhr_encoder_state *st, int dtx);
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 void gsmhr_decoder_reset(struct gsmhr_decoder_state *st);
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 /* encoder and decoder main functions */
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 void gsmhr_encode_frame(struct gsmhr_encoder_state *st, const int16_t *pcm,
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 int16_t *param);
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 void gsmhr_decode_frame(struct gsmhr_decoder_state *st, const int16_t *param,
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 int16_t *pcm);
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 /* stateless format conversion functions */
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 void gsmhr_pack_ts101318(const int16_t *param, uint8_t *payload);
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 void gsmhr_unpack_ts101318(const uint8_t *payload, int16_t *param);
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 void gsmhr_encoder_twts002_out(const int16_t *param, uint8_t *payload);
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 int gsmhr_decoder_twts002_in(const uint8_t *payload, int16_t *param);
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48
492
cc3a831712a4 libgsmhr1: implement arbitrary RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 489
diff changeset
49 int gsmhr_rtp_in_preen(const uint8_t *rtp_in, unsigned rtp_in_len,
cc3a831712a4 libgsmhr1: implement arbitrary RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 489
diff changeset
50 uint8_t *canon_pl);
cc3a831712a4 libgsmhr1: implement arbitrary RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 489
diff changeset
51
489
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 /* perfect SID detection and regeneration */
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 int gsmhr_ts101318_is_perfect_sid(const uint8_t *payload);
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 void gsmhr_ts101318_set_sid_codeword(uint8_t *payload);
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56
496
af70bf42eb1b libgsmhr1: implement DHF const array
Mychaela Falconia <falcon@freecalypso.org>
parents: 492
diff changeset
57 /* public const data items */
489
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58
496
af70bf42eb1b libgsmhr1: implement DHF const array
Mychaela Falconia <falcon@freecalypso.org>
parents: 492
diff changeset
59 extern const int16_t gsmhr_dhf_params[GSMHR_NUM_PARAMS];
af70bf42eb1b libgsmhr1: implement DHF const array
Mychaela Falconia <falcon@freecalypso.org>
parents: 492
diff changeset
60 extern const uint8_t gsmhr_dhf_ts101318[GSMHR_FRAME_LEN_RPF];
489
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 #endif /* include guard */