summaryrefslogtreecommitdiffstats
path: root/src/fmt_ti.c
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2011-02-25 16:58:36 +0100
committerSylvain Munaut <tnt@246tNt.com>2011-02-25 16:58:36 +0100
commitb1525d67fe7d60da9207330ddeaaefacf2dd8c2c (patch)
tree2a45593346db2cf983d30d56860e458ea265d472 /src/fmt_ti.c
parentcfaec3a2f6590bafcaecbc580eba798988a9a2fa (diff)
format/fmt_ti: Add support for HR variant
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src/fmt_ti.c')
-rw-r--r--src/fmt_ti.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/fmt_ti.c b/src/fmt_ti.c
index 862d694..e2bb14a 100644
--- a/src/fmt_ti.c
+++ b/src/fmt_ti.c
@@ -35,6 +35,62 @@
static int
+ti_hr_from_canon(uint8_t *dst, const uint8_t *src)
+{
+ int i, voiced;
+ const uint16_t *bit_mapping;
+
+ memset(dst, 0x00, 33); /* Not even half the bits are written, so we pre-clear */
+
+ voiced = (msb_get_bit(src, 34) << 1) | msb_get_bit(src, 35);
+
+ bit_mapping = voiced ?
+ &gsm620_voiced_bitorder[0] :
+ &gsm620_unvoiced_bitorder[0] ;
+
+ for (i=0; i<112; i++) {
+ int si = bit_mapping[i];
+ int di = i >= 95 ? i+4 : i;
+ lsb_put_bit(dst, di, msb_get_bit(src, si));
+ }
+
+ return 0;
+}
+
+static int
+ti_hr_to_canon(uint8_t *dst, const uint8_t *src)
+{
+ int i, voiced;
+ const uint16_t *bit_mapping;
+
+ voiced = (msb_get_bit(src, 94) << 1) | msb_get_bit(src, 93);
+
+ bit_mapping = voiced ?
+ &gsm620_voiced_bitorder[0] :
+ &gsm620_unvoiced_bitorder[0] ;
+
+ for (i=0; i<112; i++) {
+ int si = i >= 95 ? i+4 : i;
+ int di = bit_mapping[i];
+ msb_put_bit(dst, di, msb_get_bit(src, si));
+ }
+
+ return 0;
+}
+
+const struct format_desc fmt_ti_hr = {
+ .type = FMT_TI_HR,
+ .codec_type = CODEC_HR,
+ .name = "ti-hr",
+ .description = "Texas Instrument HR TCH/H buffer format",
+
+ .frame_len = 33,
+ .conv_from_canon = ti_hr_from_canon,
+ .conv_to_canon = ti_hr_to_canon,
+};
+
+
+static int
ti_fr_from_canon(uint8_t *dst, const uint8_t *src)
{
int i;