FreeCalypso > hg > gsm-codec-lib
changeset 489:f036e1de5b05
libgsmhr1: starting with API definition
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 15 Jun 2024 04:51:30 +0000 |
parents | 6724fbb01a09 |
children | 4d80730683d4 |
files | libgsmhr1/tw_gsmhr.h |
diffstat | 1 files changed, 58 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgsmhr1/tw_gsmhr.h Sat Jun 15 04:51:30 2024 +0000 @@ -0,0 +1,58 @@ +/* + * This header file is the external public interface to libgsmhr1: + * Themyscira Wireless implementation of GSM HRv1 speech codec + * based on the original ETSI code of GSM 06.06. + * + * This header file should be installed in some system include directory + * such that it can be included by C sources as <tw_gsmhr.h>. + */ + +#ifndef __THEMWI_GSMHR_H +#define __THEMWI_GSMHR_H + +#include <stdint.h> + +#define GSMHR_NUM_PARAMS 18 /* actual codec parameters */ +#define GSMHR_NUM_PARAMS_ENC 20 /* output from the encoder */ +#define GSMHR_NUM_PARAMS_DEC 22 /* input to the decoder */ + +#define GSMHR_FRAME_LEN_RPF 14 /* raw packed format */ +#define GSMHR_FRAME_LEN_5993 15 /* RFC 5993 and TW-TS-002 */ + +/* stateful encoder and decoder engines */ + +struct gsmhr_encoder_state; /* opaque to external users */ +struct gsmhr_decoder_state; /* ditto */ + +struct gsmhr_encoder_state *gsmhr_encoder_create(int dtx); +struct gsmhr_decoder_state *gsmhr_decoder_create(void); +/* use standard free() call to free both afterward */ + +/* reset state to initial */ +void gsmhr_encoder_reset(struct gsmhr_encoder_state *st, int dtx); +void gsmhr_decoder_reset(struct gsmhr_decoder_state *st); + +/* encoder and decoder main functions */ +void gsmhr_encode_frame(struct gsmhr_encoder_state *st, const int16_t *pcm, + int16_t *param); +void gsmhr_decode_frame(struct gsmhr_decoder_state *st, const int16_t *param, + int16_t *pcm); + +/* stateless format conversion functions */ + +void gsmhr_pack_ts101318(const int16_t *param, uint8_t *payload); +void gsmhr_unpack_ts101318(const uint8_t *payload, int16_t *param); + +void gsmhr_encoder_twts002_out(const int16_t *param, uint8_t *payload); +int gsmhr_decoder_twts002_in(const uint8_t *payload, int16_t *param); + +/* perfect SID detection and regeneration */ + +int gsmhr_ts101318_is_perfect_sid(const uint8_t *payload); +void gsmhr_ts101318_set_sid_codeword(uint8_t *payload); + +/* public const data item */ + +extern const int16_t gsmhr_decoder_homing_frame[GSMHR_NUM_PARAMS]; + +#endif /* include guard */