osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-dev/+/41212?usp=email )
Change subject: gen_makefile: erlang: fix missing clone and deps
......................................................................
gen_makefile: erlang: fix missing clone and deps
Add a dummy configure target for erlang that ensures the git clone and
building of dependencies is done before attempting to build erlang
projects. A dummy target is used to make the logic consistent with
autotools and meson.
This is in preparation for building python libraries for pyhss, which
will work similarly.
Change-Id: I627e78f9317d99755cfad5d5c8526c3b7f1b3a27
---
M gen_makefile.py
1 file changed, 5 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-dev refs/changes/12/41212/1
diff --git a/gen_makefile.py b/gen_makefile.py
index 3885e10..e5f07ab 100755
--- a/gen_makefile.py
+++ b/gen_makefile.py
@@ -382,7 +382,10 @@
touch $@
'''
elif buildsystem == "erlang":
- return ""
+ return f'''
+.make.{proj}.configure: .make.{proj}.clone {deps_installed}
+ touch $@
+ '''
else:
assert False, f"unknown buildsystem: {buildsystem}"
@@ -414,7 +417,7 @@
'''
elif buildsystem == "erlang":
return f'''
-.make.{proj}.build: $({proj}_files)
+.make.{proj}.build: .make.{proj}.configure $({proj}_files)
@echo "\\n\\n\\n===== $@\\n"
set -x && \\
export REBAR_BASE_DIR="$$PWD/{build_proj}" && \\
--
To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/41212?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-Change-Id: I627e78f9317d99755cfad5d5c8526c3b7f1b3a27
Gerrit-Change-Number: 41212
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/41208?usp=email )
Change subject: osmo_trau_frame_encode(): fix encoding of 16k O&M frames
......................................................................
osmo_trau_frame_encode(): fix encoding of 16k O&M frames
The behavior of osmo_trau_frame_encode() for OSMO_TRAU16_FT_OAM
has the same unfortunate (but now officially documented) design
quirk as all other 16k frame types: bits C1..C5 are set internally
by the encoding function and not from caller-supplied fr->c_bits[].
However, there was also a bug: bits C6..C15, which are taken from
fr->c_bits[] for all frame types, were copied from the wrong part
of this fr->c_bits[] array. Fix the latter bug.
Change-Id: Ia366d5b0385b764c492bbed9a030ca27db71fcff
---
M src/trau/trau_frame.c
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/08/41208/1
diff --git a/src/trau/trau_frame.c b/src/trau/trau_frame.c
index 652c703..ad7a102 100644
--- a/src/trau/trau_frame.c
+++ b/src/trau/trau_frame.c
@@ -397,7 +397,7 @@
/* C1 .. C5 */
memcpy(trau_bits + 17, cbits5, 5);
/* C6 .. C15 */
- memcpy(trau_bits + 17 + 5, fr->c_bits, 15 - 5);
+ memcpy(trau_bits + 17 + 5, fr->c_bits + 5, 15 - 5);
/* D1 .. D255 */
for (i = 32, d_idx = 0; i < 304; i += 16, d_idx += 15) {
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/41208?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: Ia366d5b0385b764c492bbed9a030ca27db71fcff
Gerrit-Change-Number: 41208
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/41209?usp=email )
Change subject: osmo_trau_frame_encode(): reduce space requirement in common case
......................................................................
osmo_trau_frame_encode(): reduce space requirement in common case
Since its introduction in 2020, osmo_trau_frame_encode() API has had
the ability to emit TRAU-DL frames that are either lengthened or
shortened for timing adjustment, like real TRAUs do. However, this
capability was never exercised in OsmoMGW-E1, nor is it used in the
new tw-e1abis-mgw: given the constraint of having to submit 160-byte
blocks to the E1 stack every 20 ms, it is not really feasible for
our current sw-only implementation to achieve the same 125 us timing
optimizations that are possible and desirable in a hardware or FPGA
implementation.
Since all current users of osmo_trau_frame_encode() API call it with
fr->dl_ta_usec set to 0, the doubled output space requirement imposed
by the function becomes an unnecessary burden and an API design bug
in need of fixing. Solution: check fr->dir and fr->dl_ta_usec to see
if frame output lengthening is actually possible for each given
invocation of this function, and require doubled output space only
in those cases.
Change-Id: I9f3541b0618ebef26e53b69041e5b74abefd3b85
---
M src/trau/trau_frame.c
1 file changed, 14 insertions(+), 11 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/09/41209/1
diff --git a/src/trau/trau_frame.c b/src/trau/trau_frame.c
index ad7a102..d0cf3d1 100644
--- a/src/trau/trau_frame.c
+++ b/src/trau/trau_frame.c
@@ -1268,6 +1268,8 @@
*/
int osmo_trau_frame_encode(ubit_t *bits, size_t n_bits, const struct osmo_trau_frame *fr)
{
+ size_t space_req;
+
/* check for sufficient space provided by caller in output buffer */
switch (fr->type) {
case OSMO_TRAU16_FT_FR:
@@ -1276,35 +1278,37 @@
case OSMO_TRAU16_FT_AMR:
case OSMO_TRAU16_FT_IDLE:
/* timing alignment may happen: increased space requirement */
- if (n_bits < 2 * 40 * 8 - 1)
- return -ENOSPC;
+ if (fr->dir == OSMO_TRAU_DIR_DL && fr->dl_ta_usec > 0)
+ space_req = 2 * 40 * 8 - 1;
+ else
+ space_req = 1 * 40 * 8;
break;
case OSMO_TRAU16_FT_OAM:
case OSMO_TRAU16_FT_DATA_HR:
case OSMO_TRAU16_FT_DATA:
case OSMO_TRAU16_FT_D145_SYNC:
case OSMO_TRAU16_FT_EDATA:
- if (n_bits < 1 * 40 * 8)
- return -ENOSPC;
+ space_req = 1 * 40 * 8;
break;
case OSMO_TRAU8_SPEECH:
case OSMO_TRAU8_AMR_LOW:
case OSMO_TRAU8_AMR_6k7:
case OSMO_TRAU8_AMR_7k4:
/* timing alignment may happen: increased space requirement */
- if (n_bits < 2 * 20 * 8 - 1)
- return -ENOSPC;
+ if (fr->dir == OSMO_TRAU_DIR_DL && fr->dl_ta_usec > 0)
+ space_req = 2 * 20 * 8 - 1;
+ else
+ space_req = 1 * 20 * 8;
break;
case OSMO_TRAU8_DATA:
case OSMO_TRAU8_OAM:
- if (n_bits < 1 * 20 * 8)
- return -ENOSPC;
- break;
- case OSMO_TRAU_FT_NONE:
+ space_req = 1 * 20 * 8;
break;
default:
return -EINVAL;
}
+ if (n_bits < space_req)
+ return -ENOSPC;
switch (fr->type) {
case OSMO_TRAU16_FT_FR:
@@ -1338,7 +1342,6 @@
return encode8_amr_67(bits, fr);
case OSMO_TRAU8_AMR_7k4:
return encode8_amr_74(bits, fr);
- case OSMO_TRAU_FT_NONE:
default:
return -EINVAL;
}
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/41209?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I9f3541b0618ebef26e53b69041e5b74abefd3b85
Gerrit-Change-Number: 41209
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
falconia has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-abis/+/41158?usp=email )
Change subject: trau/clearmode.h: add OSMO_CLEARMODE_20MS definition
......................................................................
trau/clearmode.h: add OSMO_CLEARMODE_20MS definition
RFC4040_RTP_PLEN was previously defined privately in OsmoBTS and
in trau_rtp_conv.c module in this library, but there was no official
definition in any of Osmocom headers. Add <osmocom/trau/clearmode.h>
header with OSMO_CLEARMODE_20MS definition.
Change-Id: I4b2e49b085574336820468dc8cfb8e32377788bf
---
M include/Makefile.am
A include/osmocom/trau/clearmode.h
M src/trau/trau_rtp_conv.c
3 files changed, 38 insertions(+), 16 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/include/Makefile.am b/include/Makefile.am
index e9820c8..565e3cb 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -24,6 +24,7 @@
osmocom/abis/trau_frame.h \
osmocom/abis/unixsocket_proto.h \
osmocom/abis/version.h \
+ osmocom/trau/clearmode.h \
osmocom/trau/csd_ra2.h \
osmocom/trau/csd_raa_prime.h \
osmocom/trau/tfo_frame.h \
diff --git a/include/osmocom/trau/clearmode.h b/include/osmocom/trau/clearmode.h
new file mode 100644
index 0000000..60fbc5a
--- /dev/null
+++ b/include/osmocom/trau/clearmode.h
@@ -0,0 +1,23 @@
+/*
+ * This header file contains some definitions for CSD in CLEARMODE RTP
+ * representation.
+ *
+ * Author: Mychaela N. Falconia <falcon(a)freecalypso.org>, 2025 - 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
+
+/* RFC4040 CLEARMODE RTP payload length for 20 ms as specified in TS 48.103 */
+#define OSMO_CLEARMODE_20MS 160
diff --git a/src/trau/trau_rtp_conv.c b/src/trau/trau_rtp_conv.c
index f2e0022..f670578 100644
--- a/src/trau/trau_rtp_conv.c
+++ b/src/trau/trau_rtp_conv.c
@@ -30,12 +30,10 @@
#include <osmocom/trau/trau_frame.h>
#include <osmocom/trau/trau_rtp.h>
+#include <osmocom/trau/clearmode.h>
#include <osmocom/trau/csd_ra2.h>
#include <osmocom/trau/csd_raa_prime.h>
-/* RFC4040 "clearmode" RTP payload length */
-#define RFC4040_RTP_PLEN 160
-
/* this corresponds to the bit-lengths of the individual codec
* parameters as indicated in Table 1.1 of TS 46.010 */
static const uint8_t gsm_fr_map[] = {
@@ -1304,7 +1302,7 @@
/* function interface preliminaries */
if (tf->type != OSMO_TRAU16_FT_DATA)
return -EINVAL;
- if (out_len < RFC4040_RTP_PLEN)
+ if (out_len < OSMO_CLEARMODE_20MS)
return -ENOSPC;
/* Is it TCH/F9.6 with 16 kbit/s IR,
@@ -1319,7 +1317,7 @@
trau2v110_ir8(out + 80, tf->d_bits + 63 * 2);
}
- return RFC4040_RTP_PLEN;
+ return OSMO_CLEARMODE_20MS;
}
static int trau2rtp_data_hr16(uint8_t *out, size_t out_len,
@@ -1328,7 +1326,7 @@
/* function interface preliminaries */
if (tf->type != OSMO_TRAU16_FT_DATA_HR)
return -EINVAL;
- if (out_len < RFC4040_RTP_PLEN)
+ if (out_len < OSMO_CLEARMODE_20MS)
return -ENOSPC;
/* Note that Osmocom trau_frame decoding and encoding API
@@ -1338,7 +1336,7 @@
trau2v110_ir8(out, tf->d_bits);
trau2v110_ir8(out + 80, tf->d_bits + 63);
- return RFC4040_RTP_PLEN;
+ return OSMO_CLEARMODE_20MS;
}
static int trau2rtp_data_hr8(uint8_t *out, size_t out_len,
@@ -1347,13 +1345,13 @@
/* function interface preliminaries */
if (tf->type != OSMO_TRAU8_DATA)
return -EINVAL;
- if (out_len < RFC4040_RTP_PLEN)
+ if (out_len < OSMO_CLEARMODE_20MS)
return -ENOSPC;
trau2v110_ir8(out, tf->d_bits);
trau2v110_ir8(out + 80, tf->d_bits + 63);
- return RFC4040_RTP_PLEN;
+ return OSMO_CLEARMODE_20MS;
}
static int trau2rtp_edata(uint8_t *out, size_t out_len,
@@ -1362,7 +1360,7 @@
/* function interface preliminaries */
if (tf->type != OSMO_TRAU16_FT_EDATA)
return -EINVAL;
- if (out_len < RFC4040_RTP_PLEN)
+ if (out_len < OSMO_CLEARMODE_20MS)
return -ENOSPC;
/* Per TS 48.020 section 11.1:
@@ -1370,7 +1368,7 @@
* A-TRAU bit C5 comes from E-TRAU bit C6 */
osmo_csd144_to_atrau_ra2(out, tf->m_bits, tf->d_bits, 1, tf->c_bits[5]);
- return RFC4040_RTP_PLEN;
+ return OSMO_CLEARMODE_20MS;
}
/*
@@ -1436,11 +1434,11 @@
{
ubit_t ra_bits[80 * 2];
- if (data_len != RFC4040_RTP_PLEN)
+ if (data_len != OSMO_CLEARMODE_20MS)
goto idle_fill;
/* reverse RA2 first */
- osmo_csd_ra2_8k_unpack(ra_bits, data, RFC4040_RTP_PLEN);
+ osmo_csd_ra2_8k_unpack(ra_bits, data, OSMO_CLEARMODE_20MS);
/* enforce two properly aligned V.110 frames */
if (!check_v110_align(ra_bits))
@@ -1464,11 +1462,11 @@
{
ubit_t ra_bits[80 * 4];
- if (data_len != RFC4040_RTP_PLEN)
+ if (data_len != OSMO_CLEARMODE_20MS)
goto idle_fill;
/* reverse RA2 first */
- osmo_csd_ra2_16k_unpack(ra_bits, data, RFC4040_RTP_PLEN);
+ osmo_csd_ra2_16k_unpack(ra_bits, data, OSMO_CLEARMODE_20MS);
/* enforce 4 properly aligned V.110 frames */
if (!check_v110_align(ra_bits))
@@ -1606,7 +1604,7 @@
/* set C6=0: indicate good reception of TRAU-UL frames */
tf->c_bits[5] = 0;
- if (data_len == RFC4040_RTP_PLEN &&
+ if (data_len == OSMO_CLEARMODE_20MS &&
osmo_csd144_from_atrau_ra2(tf->m_bits, tf->d_bits, &atrau_c4, NULL,
data) >= 0) {
/* We got good A-TRAU input. 3GPP specs define the following
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/41158?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: I4b2e49b085574336820468dc8cfb8e32377788bf
Gerrit-Change-Number: 41158
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: laforge <laforge(a)osmocom.org>
falconia has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-abis/+/41159?usp=email )
Change subject: trau: factor out V.110 frame conversion functions
......................................................................
trau: factor out V.110 frame conversion functions
Implementation of CSD conversion between TRAU frames and CLEARMODE
inside osmo_trau2rtp() and osmo_rtp2trau() contains lower-level
functions for conversion of individual V.110 frames and for alignment
checking. Factor these functions out into API, as they are useful
for other applications besides TRAU<->RTP conversion:
* Compression and decompression functions that convert between
standard (but inefficient) CLEARMODE and compressed-CSD RTP format
of TW-TS-007;
* Implementations of IWFs that terminate CSD RTP streams at the CN
and support both CLEARMODE and TW-TS-007.
Change-Id: I3f51254b4b985a0f8499c375b61069ca24f77ae8
---
M include/Makefile.am
A include/osmocom/trau/csd_v110.h
M src/Makefile.am
A src/trau/csd_v110.c
4 files changed, 160 insertions(+), 0 deletions(-)
Approvals:
laforge: Looks good to me, approved
fixeria: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/include/Makefile.am b/include/Makefile.am
index 565e3cb..862292e 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -27,6 +27,7 @@
osmocom/trau/clearmode.h \
osmocom/trau/csd_ra2.h \
osmocom/trau/csd_raa_prime.h \
+ osmocom/trau/csd_v110.h \
osmocom/trau/tfo_frame.h \
osmocom/trau/trau_frame.h \
osmocom/trau/trau_pcu_ericsson.h \
diff --git a/include/osmocom/trau/csd_v110.h b/include/osmocom/trau/csd_v110.h
new file mode 100644
index 0000000..05d4ed5
--- /dev/null
+++ b/include/osmocom/trau/csd_v110.h
@@ -0,0 +1,40 @@
+/*
+ * This header file defines the public API for some helper functions that
+ * work with CSD V.110 frames represented in the standard 64 kbit/s CLEARMODE
+ * format of 3GPP TS 48.103, _without_ compression per TW-TS-007, but _with_
+ * Osmocom-introduced constraint that the pair or quadruple of V.110 frames
+ * in RA2 encoding has to be naturally aligned within each 20 ms RTP packet.
+ *
+ * Author: Mychaela N. Falconia <falcon(a)freecalypso.org>, 2025 - 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 <stdbool.h>
+#include <osmocom/core/bits.h>
+
+/* conversion from distilled 63-bit format (as used in TRAU frames) to full
+ * 80-bit V.110 format, with or without RA2. */
+
+void osmo_csd_63bits_to_v110_bits(ubit_t *out, const ubit_t *in);
+void osmo_csd_63bits_to_v110_ir8(uint8_t *out, const ubit_t *in);
+void osmo_csd_63bits_to_v110_ir16(uint8_t *out, const ubit_t *in);
+
+/* functions to verify V.110 frame alignment after RA2 decoding, and to convert
+ * to our distilled 63-bit format. */
+
+bool osmo_csd_check_v110_align(const ubit_t *ra_bits);
+void osmo_csd_v110_to_63bits(ubit_t *out, const ubit_t *ra_bits);
diff --git a/src/Makefile.am b/src/Makefile.am
index fc5b59b..6683d44 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -53,6 +53,7 @@
$(NULL)
libosmotrau_la_LIBADD = $(COMMONLIBS) $(LIBOSMOCODEC_LIBS) $(ORTP_LIBS)
libosmotrau_la_SOURCES = trau/csd_ra2.c \
+ trau/csd_v110.c \
trau/raa_prime_decode.c \
trau/raa_prime_encode.c \
trau/tfo_frame.c \
diff --git a/src/trau/csd_v110.c b/src/trau/csd_v110.c
new file mode 100644
index 0000000..431073c
--- /dev/null
+++ b/src/trau/csd_v110.c
@@ -0,0 +1,118 @@
+/*
+ * This C module contains the implementation of CSD V.110 helper functions
+ * for CLEARMODE defined in <osmocom/trau/csd_v110.h>.
+ *
+ * Author: Mychaela N. Falconia <falcon(a)freecalypso.org>, 2025 - 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 <stdbool.h>
+#include <string.h>
+
+#include <osmocom/core/bits.h>
+#include <osmocom/trau/csd_ra2.h>
+#include <osmocom/trau/csd_v110.h>
+
+/*! Convert V.110 frame from distilled 63-bit form (as it appears in TRAU
+ * frames) to full 80-bit form by adding sync pattern bits.
+ * \param[out] out buffer of size 80 ubit_t
+ * \param[in] in 63-bit distilled V.110 frame
+ */
+void osmo_csd_63bits_to_v110_bits(ubit_t *out, const ubit_t *in)
+{
+ int i;
+
+ /* the first 8 bits are sync zeros */
+ memset(out, 0, 8);
+ out += 8;
+ /* for the rest, we have to expand 63 bits into 72 */
+ for (i = 0; i < 9; i++) {
+ *out++ = 1;
+ memcpy(out, in, 7);
+ in += 7;
+ out += 7;
+ }
+}
+
+/*! Convert V.110 frame from distilled 63-bit form (as it appears in TRAU
+ * frames) to external octet form (RA2 with 8 kbit/s IR) form by adding
+ * sync pattern bits and applying RA2.
+ * \param[out] out buffer of size 80 octets
+ * \param[in] in 63-bit distilled V.110 frame
+ */
+void osmo_csd_63bits_to_v110_ir8(uint8_t *out, const ubit_t *in)
+{
+ ubit_t ra_bits[80];
+
+ osmo_csd_63bits_to_v110_bits(ra_bits, in);
+ /* RA2: 1 bit per output byte */
+ osmo_csd_ra2_8k_pack(out, ra_bits, 80);
+}
+
+/*! Convert V.110 frame from distilled 63-bit form (as it appears in TRAU
+ * frames) to external octet form (RA2 with 16 kbit/s IR) form by adding
+ * sync pattern bits and applying RA2.
+ * \param[out] out buffer of size 40 octets
+ * \param[in] in 63-bit distilled V.110 frame
+ */
+void osmo_csd_63bits_to_v110_ir16(uint8_t *out, const ubit_t *in)
+{
+ ubit_t ra_bits[80];
+
+ osmo_csd_63bits_to_v110_bits(ra_bits, in);
+ /* RA2: 2 bits per output byte */
+ osmo_csd_ra2_16k_pack(out, ra_bits, 40);
+}
+
+/*! Check alignment of unpacked 80-bit V.110 frame.
+ * \param[in] ra_bits candidate V.110 frame in standard 80-bit form
+ * \returns true if V.110 alignment pattern is correct, false otherwise
+ */
+bool osmo_csd_check_v110_align(const ubit_t *ra_bits)
+{
+ int i;
+
+ for (i = 0; i < 8; i++) {
+ if (ra_bits[i])
+ return false;
+ }
+ for (i = 1; i < 10; i++) {
+ if (!ra_bits[i * 8])
+ return false;
+ }
+ return true;
+}
+
+/*! Convert V.110 frame from standard 80-bit form (unpacked) to
+ * our distilled 63-bit form (as it appears in TRAU frames).
+ * \param[out] out buffer of size 63 ubit_t
+ * \param[in] in 80-bit standard V.110 frame
+ *
+ * This function ignores all 17 sync pattern bits and assumes that the
+ * V.110 frame is correctly aligned. Therefore, this function should
+ * be called after osmo_csd_check_v110_align().
+ */
+void osmo_csd_v110_to_63bits(ubit_t *out, const ubit_t *ra_bits)
+{
+ memcpy(out, ra_bits + 9, 7);
+ memcpy(out + 7, ra_bits + 17, 7);
+ memcpy(out + 14, ra_bits + 25, 7);
+ memcpy(out + 21, ra_bits + 33, 7);
+ memcpy(out + 28, ra_bits + 41, 7);
+ memcpy(out + 35, ra_bits + 49, 7);
+ memcpy(out + 42, ra_bits + 57, 7);
+ memcpy(out + 49, ra_bits + 65, 7);
+ memcpy(out + 56, ra_bits + 73, 7);
+}
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/41159?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: I3f51254b4b985a0f8499c375b61069ca24f77ae8
Gerrit-Change-Number: 41159
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: laforge <laforge(a)osmocom.org>