falconia has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32962 )
Change subject: gsm0503_tch_hr_decode2(): new function, emits TS101318 format
......................................................................
gsm0503_tch_hr_decode2(): new function, emits TS101318 format
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 decoding
direction, create a new function that emits TS 101 318 format, and
turn the legacy gsm0503_tch_hr_decode() API into a wrapper function
for backward compatibility.
Related: OS#5688
Change-Id: If28ddb20789e8993b7558ca08020478615b4c708
---
M TODO-RELEASE
M include/osmocom/coding/gsm0503_coding.h
M src/coding/gsm0503_coding.c
3 files changed, 62 insertions(+), 10 deletions(-)
Approvals:
pespin: Looks good to me, but someone else must approve
Jenkins Builder: Verified
fixeria: Looks good to me, approved
diff --git a/TODO-RELEASE b/TODO-RELEASE
index 7270257..ebda4c5 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -11,3 +11,5 @@
libosmocore ADD new defines in osmocom/gsm/protocol/gsm_04_08.h (old ones marked deprecated)
libosmovty drop API drop struct vty_parent_node from public API, it should never have been public
libosmocore ADD new API osmo_io_*()
+libosmocoding ADD new gsm0503_tch_hr_decode2() public API, previous API
+ gsm0503_tch_hr_decode() marked as deprecated
diff --git a/include/osmocom/coding/gsm0503_coding.h b/include/osmocom/coding/gsm0503_coding.h
index 2afa049..2112b0f 100644
--- a/include/osmocom/coding/gsm0503_coding.h
+++ b/include/osmocom/coding/gsm0503_coding.h
@@ -50,6 +50,9 @@
int gsm0503_tch_hr_encode(ubit_t *bursts, const uint8_t *tch_data, int len);
int gsm0503_tch_hr_decode(uint8_t *tch_data, const sbit_t *bursts, int odd,
+ int *n_errors, int *n_bits_total)
+ OSMO_DEPRECATED("Use gsm0503_tch_hr_decode2() instead");
+int gsm0503_tch_hr_decode2(uint8_t *tch_data, const sbit_t *bursts, int odd,
int *n_errors, int *n_bits_total);
int gsm0503_tch_afs_encode(ubit_t *bursts, const uint8_t *tch_data, int len,
diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
index 4f1ac79..6f76824 100644
--- a/src/coding/gsm0503_coding.c
+++ b/src/coding/gsm0503_coding.c
@@ -1572,16 +1572,14 @@
}
}
-/* assemble a HR codec frame in format as used inside RTP */
+/* assemble a HR codec frame in the canonical format of ETSI TS 101 318 */
static void tch_hr_reassemble(uint8_t *tch_data, const ubit_t *b_bits)
{
- int i, j;
+ int i;
- tch_data[0] = 0x00; /* F = 0, FT = 000 */
- memset(tch_data + 1, 0, 14);
-
- for (i = 0, j = 8; i < 112; i++, j++)
- tch_data[j >> 3] |= (b_bits[i] << (7 - (j & 7)));
+ memset(tch_data, 0, GSM_HR_BYTES);
+ for (i = 0; i < 112; i++)
+ tch_data[i >> 3] |= (b_bits[i] << (7 - (i & 7)));
}
static void tch_hr_disassemble(ubit_t *b_bits, const uint8_t *tch_data)
@@ -1977,13 +1975,13 @@
}
/*! Perform channel decoding of a HR(v1) channel according TS 05.03
- * \param[out] tch_data Codec frame in RTP payload format
+ * \param[out] tch_data Codec frame in TS 101 318 canonical format
* \param[in] bursts buffer containing the symbols of 8 bursts
* \param[in] odd Odd (1) or even (0) frame number
* \param[out] n_errors Number of detected bit errors
* \param[out] n_bits_total Total number of bits
* \returns length of bytes used in \a tch_data output buffer; negative on error */
-int gsm0503_tch_hr_decode(uint8_t *tch_data, const sbit_t *bursts, int odd,
+int gsm0503_tch_hr_decode2(uint8_t *tch_data, const sbit_t *bursts, int odd,
int *n_errors, int *n_bits_total)
{
sbit_t iB[912], cB[456], h;
@@ -2050,7 +2048,35 @@
tch_hr_reassemble(tch_data, b);
- return 15;
+ return GSM_HR_BYTES;
+}
+
+/*! Perform channel decoding of a HR(v1) channel according TS 05.03,
+ * deprecated legacy API.
+ * \param[out] tch_data Codec frame in pseudo-RFC5993 format
+ * \param[in] bursts buffer containing the symbols of 8 bursts
+ * \param[in] odd Odd (1) or even (0) frame number
+ * \param[out] n_errors Number of detected bit errors
+ * \param[out] n_bits_total Total number of bits
+ * \returns length of bytes used in \a tch_data output buffer; negative on error
+ *
+ * The HR1 codec frame format returned by this function is pseudo-RFC5993,
+ * not true RFC 5993, as there is no SID classification being done
+ * and the FT bits in the ToC octet are always set to 0 - but this
+ * arguably-bogus format is the legacy public API.
+ */
+int gsm0503_tch_hr_decode(uint8_t *tch_data, const sbit_t *bursts, int odd,
+ int *n_errors, int *n_bits_total)
+{
+ int rc;
+
+ rc = gsm0503_tch_hr_decode2(tch_data, bursts, odd, n_errors,
+ n_bits_total);
+ if (rc != GSM_HR_BYTES)
+ return rc;
+ memmove(tch_data + 1, tch_data, GSM_HR_BYTES);
+ tch_data[0] = 0x00; /* FT=0, note absence of SID classification */
+ return GSM_HR_BYTES_RTP_RFC5993;
}
/*! Perform channel encoding on a TCH/HS channel according to TS 05.03
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32962
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If28ddb20789e8993b7558ca08020478615b4c708
Gerrit-Change-Number: 32962
Gerrit-PatchSet: 3
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
falconia has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32960 )
Change subject: gsm0503_tch_hr_decode(): look at all 8 stealing bits
......................................................................
gsm0503_tch_hr_decode(): look at all 8 stealing bits
This function needs to look at hl and hu stealing bits in order to
decide if it should decode FACCH/H instead of TCH/HS traffic.
However, out of the 8 (in total) hl and hu bits that get set when
FACCH/H stealing takes place, the function only looked at 7 of them
- one was missed. Fix this bug.
Change-Id: I08c4358b26d69910190f89a53b654bc58c2efea9
---
M src/coding/gsm0503_coding.c
1 file changed, 16 insertions(+), 1 deletion(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
index 3fd440f..ce24650 100644
--- a/src/coding/gsm0503_coding.c
+++ b/src/coding/gsm0503_coding.c
@@ -1997,7 +1997,7 @@
steal -= h;
}
- for (i = 2; i < 5; i++) {
+ for (i = 2; i < 6; i++) {
gsm0503_tch_burst_unmap(NULL, &bursts[i * 116], &h, 1);
steal -= h;
}
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32960
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I08c4358b26d69910190f89a53b654bc58c2efea9
Gerrit-Change-Number: 32960
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
Attention is currently required from: falconia, pespin.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32962 )
Change subject: gsm0503_tch_hr_decode2(): new function, emits TS101318 format
......................................................................
Patch Set 3: Code-Review+2
(1 comment)
File src/coding/gsm0503_coding.c:
https://gerrit.osmocom.org/c/libosmocore/+/32962/comment/96b979e9_f29c0d7f
PS3, Line 1979: symbols of 8 bursts
Not related to this patch, but worth mentioning: this is incorrect and probably was copy-pasted from `gsm0503_tch_fr_decode()`. For TCH/H (to be precise, for FACCH/H) the interleaving buffer is 6 bursts wide. I will submit a patch fixing this on top of your patchset to avoid conflicts.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32962
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If28ddb20789e8993b7558ca08020478615b4c708
Gerrit-Change-Number: 32962
Gerrit-PatchSet: 3
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: falconia <falcon(a)freecalypso.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Tue, 23 May 2023 18:06:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: falconia, pespin.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32961 )
Change subject: gsm0503_tch_hr_encode(): accept both TS101318 and RFC5993 payloads
......................................................................
Patch Set 3: Code-Review+2
(2 comments)
File src/coding/gsm0503_coding.c:
https://gerrit.osmocom.org/c/libosmocore/+/32961/comment/2930de3d_9835b280
PS1, Line 1591: for (i = 0; i < 112; i++)
> Yes, I am changing the internal static function to take unprefixed 14-byte payloads as input, rather […]
Ack
File src/coding/gsm0503_coding.c:
https://gerrit.osmocom.org/c/libosmocore/+/32961/comment/c71c17d5_db61597a
PS2, Line 2093:
> I see your point - I'll make a new version without those spaces.
Done
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32961
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I13eaad366f9f68615b9e9e4a5f87396a0e9dea0f
Gerrit-Change-Number: 32961
Gerrit-PatchSet: 3
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: falconia <falcon(a)freecalypso.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Tue, 23 May 2023 17:53:45 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: falconia <falcon(a)freecalypso.org>
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: comment
Attention is currently required from: falconia.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/32960 )
Change subject: gsm0503_tch_hr_decode(): look at all 8 stealing bits
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
Good catch! Might be worth back-porting this patch to latest release.
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/32960
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I08c4358b26d69910190f89a53b654bc58c2efea9
Gerrit-Change-Number: 32960
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: falconia <falcon(a)freecalypso.org>
Gerrit-Comment-Date: Tue, 23 May 2023 17:47:57 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment