aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding/gsm0503_coding.c
diff options
context:
space:
mode:
authorMychaela N. Falconia <falcon@freecalypso.org>2023-05-23 16:41:05 +0000
committerMychaela N. Falconia <falcon@freecalypso.org>2023-05-23 16:41:05 +0000
commit8d8d5af957dd0abecc9f77d311f59a9076c2585a (patch)
treed81729b220b19f22e009624062264c77cee9fb97 /src/coding/gsm0503_coding.c
parent920c0ed86f643cb0abd2ff24d55027d1d7195771 (diff)
gsm0503_tch_hr_encode(): accept both TS101318 and RFC5993 payloads
The original design of gsm0503_tch_hr_{en,de}code() functions contains a mistake in that a pseudo-RFC5993 format was chosen for HR codec frame input and output, instead of "pure" (agnostic to outer RTP encoding) form of 14 bytes. We would like to change this design so that we can feed pure 14-byte HR codec frames to the channel coding function and get such frames back from the channel decoding function - however, we cannot break libosmocoding API for existing users. In the encoding direction, make the new format our preferred one, but support the extra-octet format for backward compatibility. Related: OS#5688 Change-Id: I13eaad366f9f68615b9e9e4a5f87396a0e9dea0f
Diffstat (limited to 'src/coding/gsm0503_coding.c')
-rw-r--r--src/coding/gsm0503_coding.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
index ce246508..4f1ac79d 100644
--- a/src/coding/gsm0503_coding.c
+++ b/src/coding/gsm0503_coding.c
@@ -1586,10 +1586,10 @@ static void tch_hr_reassemble(uint8_t *tch_data, const ubit_t *b_bits)
static void tch_hr_disassemble(ubit_t *b_bits, const uint8_t *tch_data)
{
- int i, j;
+ int i;
- for (i = 0, j = 8; i < 112; i++, j++)
- b_bits[i] = (tch_data[j >> 3] >> (7 - (j & 7))) & 1;
+ for (i = 0; i < 112; i++)
+ b_bits[i] = (tch_data[i >> 3] >> (7 - (i & 7))) & 1;
}
/* assemble a EFR codec frame in format as used inside RTP */
@@ -2065,7 +2065,10 @@ int gsm0503_tch_hr_encode(ubit_t *bursts, const uint8_t *tch_data, int len)
int i;
switch (len) {
- case 15: /* TCH HR */
+ case GSM_HR_BYTES_RTP_RFC5993: /* TCH HR with RFC 5993 prefix */
+ tch_data++;
+ /* fall-through */
+ case GSM_HR_BYTES: /* TCH HR in "pure" form */
tch_hr_disassemble(b, tch_data);
tch_hr_b_to_d(d, b);
@@ -2086,7 +2089,6 @@ int gsm0503_tch_hr_encode(ubit_t *bursts, const uint8_t *tch_data, int len)
gsm0503_tch_burst_map(&iB[i * 114],
&bursts[i * 116], &h, i >> 1);
}
-
break;
case GSM_MACBLOCK_LEN: /* FACCH */
_xcch_encode_cB(cB, tch_data);
@@ -2104,7 +2106,6 @@ int gsm0503_tch_hr_encode(ubit_t *bursts, const uint8_t *tch_data, int len)
gsm0503_tch_burst_map(&iB[i * 114 + 456],
&bursts[i * 116], &h, 1);
}
-
break;
default:
return -1;