summaryrefslogtreecommitdiffstats
path: root/src
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
parentcfaec3a2f6590bafcaecbc580eba798988a9a2fa (diff)
format/fmt_ti: Add support for HR variant
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src')
-rw-r--r--src/fmt_ti.c56
-rw-r--r--src/formats.c2
2 files changed, 58 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;
diff --git a/src/formats.c b/src/formats.c
index 997ea05..af21705 100644
--- a/src/formats.c
+++ b/src/formats.c
@@ -31,6 +31,7 @@ extern const struct format_desc fmt_racal_hr;
extern const struct format_desc fmt_racal_fr;
extern const struct format_desc fmt_racal_efr;
extern const struct format_desc fmt_rawpcm_s16le;
+extern const struct format_desc fmt_ti_hr;
extern const struct format_desc fmt_ti_fr;
static const struct format_desc *supported_formats[_FMT_MAX] = {
@@ -43,6 +44,7 @@ static const struct format_desc *supported_formats[_FMT_MAX] = {
[FMT_RACAL_FR] = &fmt_racal_fr,
[FMT_RACAL_EFR] = &fmt_racal_efr,
[FMT_RAWPCM_S16LE] = &fmt_rawpcm_s16le,
+ [FMT_TI_HR] = &fmt_ti_hr,
[FMT_TI_FR] = &fmt_ti_fr,
};