annotate libgsmhr1/tw_gsmhr.h @ 553:ebcf414b7d99

doc/TFO-transform: describe details for FRv1, both modes
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 07 Oct 2024 08:24:24 +0000
parents 4f0ab833bec0
children
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);
510
5bf71b091323 libgsmhr1: add direct conversion from RTP input to decoder params
Mychaela Falconia <falcon@freecalypso.org>
parents: 496
diff changeset
51 int gsmhr_rtp_in_direct(const uint8_t *rtp_in, unsigned rtp_in_len,
5bf71b091323 libgsmhr1: add direct conversion from RTP input to decoder params
Mychaela Falconia <falcon@freecalypso.org>
parents: 496
diff changeset
52 int16_t *param);
492
cc3a831712a4 libgsmhr1: implement arbitrary RTP input
Mychaela Falconia <falcon@freecalypso.org>
parents: 489
diff changeset
53
512
4f0ab833bec0 libgsmhr1: add parameter validation function
Mychaela Falconia <falcon@freecalypso.org>
parents: 510
diff changeset
54 /* reading parameter arrays from files: validation functions */
4f0ab833bec0 libgsmhr1: add parameter validation function
Mychaela Falconia <falcon@freecalypso.org>
parents: 510
diff changeset
55
4f0ab833bec0 libgsmhr1: add parameter validation function
Mychaela Falconia <falcon@freecalypso.org>
parents: 510
diff changeset
56 int gsmhr_check_common_params(const int16_t *params);
4f0ab833bec0 libgsmhr1: add parameter validation function
Mychaela Falconia <falcon@freecalypso.org>
parents: 510
diff changeset
57 int gsmhr_check_encoder_params(const int16_t *params);
4f0ab833bec0 libgsmhr1: add parameter validation function
Mychaela Falconia <falcon@freecalypso.org>
parents: 510
diff changeset
58 int gsmhr_check_decoder_params(const int16_t *params);
4f0ab833bec0 libgsmhr1: add parameter validation function
Mychaela Falconia <falcon@freecalypso.org>
parents: 510
diff changeset
59
489
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 /* perfect SID detection and regeneration */
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 int gsmhr_ts101318_is_perfect_sid(const uint8_t *payload);
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 void gsmhr_ts101318_set_sid_codeword(uint8_t *payload);
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64
496
af70bf42eb1b libgsmhr1: implement DHF const array
Mychaela Falconia <falcon@freecalypso.org>
parents: 492
diff changeset
65 /* public const data items */
489
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66
496
af70bf42eb1b libgsmhr1: implement DHF const array
Mychaela Falconia <falcon@freecalypso.org>
parents: 492
diff changeset
67 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
68 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
69
f036e1de5b05 libgsmhr1: starting with API definition
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 #endif /* include guard */