comparison libgsmhr1/tw_gsmhr.h @ 489:f036e1de5b05

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