aboutsummaryrefslogtreecommitdiffstats
path: root/src/codec_hr.c
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2010-11-12 17:48:45 +0100
committerSylvain Munaut <tnt@246tNt.com>2010-11-12 20:47:30 +0100
commita0c4d21bf60ecd77069a7f7e0203e46f133bfbfa (patch)
tree4cdd2755f28e2cc290e96ecd6499f5024111ffa3 /src/codec_hr.c
parentf7d6f3c82836011ed05259a2c47c7ab106328c87 (diff)
[4/4] HR support: Add hooks in gapk to use libgsmhr for encoding/decoding
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src/codec_hr.c')
-rw-r--r--src/codec_hr.c45
1 files changed, 45 insertions, 0 deletions
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
};