falconia has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-abis/+/38290?usp=email )
Change subject: libosmotrau: add CSD RA2 functions
......................................................................
libosmotrau: add CSD RA2 functions
Rate adaption function RA2 for GSM CSD calls is defined in 3GPP TS
48.020 chapter 13. While it is nothing but one special case of I.460
submultiplexing and we do have i460_mux infrastructure in Osmocom,
that fully-general I.460 infra is too heaviweight for CSD encoding
and decoding functions that need simple, single-input and single-output
RA2 packing and unpacking functions.
Right now ad hoc RA2 functions are used in the trau_rtp_conv module
and in OsmoBTS csd_v110; same functions will also be needed for the
upcoming RAA' unit test addition. Add proper RA2 packing and unpacking
functions that can be used in all of these places.
Change-Id: I7b98b958651b3fc1a814d119d1b8644c91f98676
---
M include/Makefile.am
A include/osmocom/trau/csd_ra2.h
M src/Makefile.am
A src/trau/csd_ra2.c
4 files changed, 140 insertions(+), 1 deletion(-)
Approvals:
fixeria: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/include/Makefile.am b/include/Makefile.am
index 88d66dc..2832541 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -4,6 +4,7 @@
osmocom/abis/ipa_proxy.h osmocom/abis/ipaccess.h osmocom/abis/abis.h \
osmocom/abis/subchan_demux.h osmocom/abis/e1_input.h \
osmocom/abis/lapd.h osmocom/abis/lapd_pcap.h osmocom/abis/unixsocket_proto.h \
+ osmocom/trau/csd_ra2.h \
osmocom/trau/trau_frame.h \
osmocom/trau/trau_sync.h \
osmocom/trau/trau_pcu_ericsson.h \
diff --git a/include/osmocom/trau/csd_ra2.h b/include/osmocom/trau/csd_ra2.h
new file mode 100644
index 0000000..113ab6d
--- /dev/null
+++ b/include/osmocom/trau/csd_ra2.h
@@ -0,0 +1,67 @@
+/*
+ * Rate adaption function RA2 for GSM CSD calls is defined in 3GPP TS
+ * 48.020 chapter 13. While it is nothing but one special case of I.460
+ * submultiplexing and we do have i460_mux infrastructure in Osmocom,
+ * that fully-general I.460 infra is too heaviweight for CSD encoding
+ * and decoding functions that need simple, single-input and single-output
+ * RA2 packing and unpacking functions.
+ *
+ * This header file defines the API to CSD-oriented RA2 packing and unpacking
+ * functions that support intermediate rates of 8 and 16 kbit/s: the two IRs
+ * that occur in "plain" single-slot CSD without EDGE.
+ *
+ * Author: Mychaela N. Falconia <falcon(a)freecalypso.org>rg>, 2024 - however,
+ * Mother Mychaela's contributions are NOT subject to copyright.
+ * No rights reserved, all rights relinquished.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#pragma once
+
+#include <stdint.h>
+#include <osmocom/core/bits.h>
+
+/*! pack bits into octets per RA2 with 8 kbit/s IR
+ * param[out] out_bytes caller-provided buffer of size nbytes
+ * param[in] in_bits source bits to be packed, size nbytes
+ * param[in] n_out_bytes number of output bytes to pack, equals
+ * number of source bits with 8 kbit/s IR
+ */
+void osmo_csd_ra2_8k_pack(uint8_t *out_bytes, const ubit_t *in_bits,
+ unsigned n_out_bytes);
+
+/*! unpack bits from octets per RA2 with 8 kbit/s IR
+ * param[out] out_bits caller-provided buffer of size nbytes
+ * param[in] in_bytes received 64 kbit/s octets to unpack, size nbytes
+ * param[in] n_in_bytes number of received octets to unpack, equals
+ * number of output bits with 8 kbit/s IR
+ */
+void osmo_csd_ra2_8k_unpack(ubit_t *out_bits, const uint8_t *in_bytes,
+ unsigned n_in_bytes);
+
+/*! pack bits into octets per RA2 with 16 kbit/s IR
+ * param[out] out_bytes caller-provided buffer of size nbytes
+ * param[in] in_bits source bits to be packed, size nbytes*2
+ * param[in] n_out_bytes number of output bytes to pack; the number
+ * of source bits is double this number
+ */
+void osmo_csd_ra2_16k_pack(uint8_t *out_bytes, const ubit_t *in_bits,
+ unsigned n_out_bytes);
+
+/*! unpack bits from octets per RA2 with 16 kbit/s IR
+ * param[out] out_bits caller-provided buffer of size nbytes*2
+ * param[in] in_bytes received 64 kbit/s octets to unpack, size nbytes
+ * param[in] n_in_bytes number of received octets to unpack; the number
+ * of output bits is double this number
+ */
+void osmo_csd_ra2_16k_unpack(ubit_t *out_bits, const uint8_t *in_bytes,
+ unsigned n_in_bytes);
diff --git a/src/Makefile.am b/src/Makefile.am
index 7c59ec3..1df7f4c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -41,7 +41,8 @@
-no-undefined \
$(NULL)
libosmotrau_la_LIBADD = $(COMMONLIBS) $(LIBOSMOCODEC_LIBS) $(ORTP_LIBS)
-libosmotrau_la_SOURCES = trau/trau_frame.c \
+libosmotrau_la_SOURCES = trau/csd_ra2.c \
+ trau/trau_frame.c \
trau/trau_pcu_ericsson.c \
trau/trau_sync.c \
trau/trau_rtp_conv.c
diff --git a/src/trau/csd_ra2.c b/src/trau/csd_ra2.c
new file mode 100644
index 0000000..65deab5
--- /dev/null
+++ b/src/trau/csd_ra2.c
@@ -0,0 +1,70 @@
+/*
+ * This C module contains the implementation of CSD RA2 functions
+ * defined in <osmocom/trau/csd_ra2.h>.
+ *
+ * Author: Mychaela N. Falconia <falcon(a)freecalypso.org>rg>, 2024 - however,
+ * Mother Mychaela's contributions are NOT subject to copyright.
+ * No rights reserved, all rights relinquished.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <stdint.h>
+
+#include <osmocom/core/bits.h>
+#include <osmocom/trau/csd_ra2.h>
+
+void osmo_csd_ra2_8k_pack(uint8_t *out_bytes, const ubit_t *in_bits,
+ unsigned n_out_bytes)
+{
+ unsigned i;
+
+ /* RA2: 1 bit per output byte */
+ for (i = 0; i < n_out_bytes; i++)
+ out_bytes[i] = 0x7F | (in_bits[i] << 7);
+}
+
+void osmo_csd_ra2_8k_unpack(ubit_t *out_bits, const uint8_t *in_bytes,
+ unsigned n_in_bytes)
+{
+ unsigned i;
+
+ for (i = 0; i < n_in_bytes; i++)
+ out_bits[i] = (in_bytes[i] >> 7) & 1;
+}
+
+void osmo_csd_ra2_16k_pack(uint8_t *out_bytes, const ubit_t *in_bits,
+ unsigned n_out_bytes)
+{
+ unsigned i, o;
+ uint8_t b;
+
+ /* RA2: 2 bits per output byte */
+ i = 0;
+ for (o = 0; o < n_out_bytes; o++) {
+ b = 0x3F;
+ b |= (in_bits[i++] << 7);
+ b |= (in_bits[i++] << 6);
+ out_bytes[o] = b;
+ }
+}
+
+void osmo_csd_ra2_16k_unpack(ubit_t *out_bits, const uint8_t *in_bytes,
+ unsigned n_in_bytes)
+{
+ unsigned i, o;
+
+ o = 0;
+ for (i = 0; i < n_in_bytes; i++) {
+ out_bits[o++] = (in_bytes[i] >> 7) & 1;
+ out_bits[o++] = (in_bytes[i] >> 6) & 1;
+ }
+}
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-abis/+/38290?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I7b98b958651b3fc1a814d119d1b8644c91f98676
Gerrit-Change-Number: 38290
Gerrit-PatchSet: 3
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>