diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2010-11-12 17:48:45 +0100 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2010-11-12 20:47:30 +0100 |
commit | a0c4d21bf60ecd77069a7f7e0203e46f133bfbfa (patch) | |
tree | 4cdd2755f28e2cc290e96ecd6499f5024111ffa3 | |
parent | f7d6f3c82836011ed05259a2c47c7ab106328c87 (diff) |
[4/4] HR support: Add hooks in gapk to use libgsmhr for encoding/decoding
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/codec_hr.c | 45 |
2 files changed, 49 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index dcecac4..f7a5b44 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,3 +8,7 @@ gapk_SOURCES = main.c \ formats.c fmt_amr.c fmt_gsm.c fmt_hr_ref.c fmt_racal.c \ fmt_rawpcm.c \ codecs.c codec_pcm.c codec_hr.c codec_fr.c codec_efr.c + +if ENABLE_GSMHR +gapk_LDADD = $(top_builddir)/libgsmhr/libgsmhr.la +endif diff --git a/src/codec_hr.c b/src/codec_hr.c index ac77ade..26a75a5 100644 --- a/src/codec_hr.c +++ b/src/codec_hr.c @@ -19,9 +19,54 @@ #include <gapk/codecs.h> +#include "config.h" + + +#ifdef HAVE_LIBGSMHR + +#include <gsmhr/gsmhr.h> + +static void * +codec_hr_init(void) +{ + return (void *)gsmhr_init(); +} + +static void +codec_hr_exit(void *_state) +{ + struct gsmhr *state = _state; + gsmhr_exit(state); +} + +static int +codec_hr_encode(void *_state, uint8_t *cod, const uint8_t *pcm) +{ + struct gsmhr *state = _state; + return gsmhr_encode(state, (int16_t *)cod, (const int16_t *)pcm); +} + +static int +codec_hr_decode(void *_state, uint8_t *pcm, const uint8_t *cod) +{ + struct gsmhr *state = _state; + return gsmhr_decode(state, (int16_t *)pcm, (const int16_t *)cod); +} + +#endif /* HAVE_LIBGSMHR */ + + const struct codec_desc codec_hr_desc = { .type = CODEC_HR, .name = "hr", .description = "GSM 06.20 Half Rate codec", .canon_frame_len = 14, +#ifdef HAVE_LIBGSMHR + .codec_enc_format_type = FMT_HR_REF_ENC, + .codec_dec_format_type = FMT_HR_REF_DEC, + .codec_init = codec_hr_init, + .codec_exit = codec_hr_exit, + .codec_encode = codec_hr_encode, + .codec_decode = codec_hr_decode, +#endif }; |