Attention is currently required from: falconia.
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-abis/+/37250?usp=email )
Change subject: rtp2trau_hr16: use osmo_hr_check_sid()
......................................................................
Patch Set 1:
(1 comment)
File TODO-RELEASE:
https://gerrit.osmocom.org/c/libosmo-abis/+/37250/comment/c5f0a1ff_5ef8a4b5
PS1, Line 12: libosmocodec >1.9.0 bugfix in osmo_hr_check_sid() in case length=0
the useful hint here is actually ABI/API related, so the interesting info you should add here in decription is "use osmo_hr_check_sid() API".
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/37250?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: Ia8fe7e9ea65fadf7f5c136355ca8c24c89f09ef2
Gerrit-Change-Number: 37250
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: falconia <falcon(a)freecalypso.org>
Gerrit-Comment-Date: Tue, 18 Jun 2024 18:52:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/37251?usp=email )
Change subject: trau_rtp_conv.c cosmetic: fix typo in name of static function
......................................................................
trau_rtp_conv.c cosmetic: fix typo in name of static function
Change I7a6d13d406484c01210594bb6d2f0aff7c1341ab introduced
a static function in src/trau/trau_rtp_conv.c that was intended
to be named twts002_hr16_set_extra_flags(). However, a typo
crept in unnoticed, and the patch was merged with this function
name misspelled as twtw002_hr16_set_extra_flags(). Fix it.
Related: OS#6448
Change-Id: I63bb678f7a1f26fefba070ddc10850db24cb88b3
---
M src/trau/trau_rtp_conv.c
1 file changed, 19 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/51/37251/1
diff --git a/src/trau/trau_rtp_conv.c b/src/trau/trau_rtp_conv.c
index f347cca..91bf228 100644
--- a/src/trau/trau_rtp_conv.c
+++ b/src/trau/trau_rtp_conv.c
@@ -162,7 +162,7 @@
FT_NO_DATA = 7,
};
-static void twtw002_hr16_set_extra_flags(uint8_t *out, const struct osmo_trau_frame *tf)
+static void twts002_hr16_set_extra_flags(uint8_t *out, const struct osmo_trau_frame *tf)
{
if (tf->c_bits[16]) /* DTXd */
out[0] |= 0x08;
@@ -223,7 +223,7 @@
if (emit_twts002) {
if (tf->c_bits[11] && sidc == OSMO_GSM631_SID_CLASS_SPEECH)
out[0] = FT_BFI_WITH_DATA << 4;
- twtw002_hr16_set_extra_flags(out, tf);
+ twts002_hr16_set_extra_flags(out, tf);
/* invalid SID frames are truncated in TW-TS-002 */
if (sidc == OSMO_GSM631_SID_CLASS_INVALID)
return 1;
@@ -243,7 +243,7 @@
bad_frame:
if (emit_twts002) {
out[0] = FT_NO_DATA << 4;
- twtw002_hr16_set_extra_flags(out, tf);
+ twts002_hr16_set_extra_flags(out, tf);
return 1;
} else
return 0;
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/37251?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I63bb678f7a1f26fefba070ddc10850db24cb88b3
Gerrit-Change-Number: 37251
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-MessageType: newchange
falconia has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-abis/+/37250?usp=email )
Change subject: rtp2trau_hr16: use osmo_hr_check_sid()
......................................................................
rtp2trau_hr16: use osmo_hr_check_sid()
The code in libosmotrau previously used its own local function
to check incoming 112-bit HRv1 frames against the possibility of
perfect SID (all 79 bits of SID field set to 1). However, there is
a public API function in libosmocodec that does the exact same job
- use the common library function.
Until recently, the implementation of osmo_hr_check_sid() in
libosmocodec was quite inefficient (the local version in libosmotrau
was faster) and contained a logic error in the handling of zero-length
input in the place of a received frame. However, both of these
defects in osmo_hr_check_sid() have now been fixed in libosmocore,
clearing the way for this common library function to be used.
Depends: Ib14204102c03c14d6c5aab42b0ffbef2c3dda3fd (libosmocore)
Change-Id: Ia8fe7e9ea65fadf7f5c136355ca8c24c89f09ef2
---
M TODO-RELEASE
M src/trau/trau_rtp_conv.c
2 files changed, 26 insertions(+), 19 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/50/37250/1
diff --git a/TODO-RELEASE b/TODO-RELEASE
index e3ad20a..515adef 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -9,3 +9,4 @@
#library what description / commit summary line
libosmotrau struct osmo_trau2rtp_state extended (ABI break)
libosmogsm >1.9.0 rtp_extensions.h new header
+libosmocodec >1.9.0 bugfix in osmo_hr_check_sid() in case length=0
diff --git a/src/trau/trau_rtp_conv.c b/src/trau/trau_rtp_conv.c
index 15d5a08..f347cca 100644
--- a/src/trau/trau_rtp_conv.c
+++ b/src/trau/trau_rtp_conv.c
@@ -162,8 +162,6 @@
FT_NO_DATA = 7,
};
-static const uint8_t rtp_hr_sid[14] = { 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-
static void twtw002_hr16_set_extra_flags(uint8_t *out, const struct osmo_trau_frame *tf)
{
if (tf->c_bits[16]) /* DTXd */
@@ -446,21 +444,6 @@
return 0;
}
-/* does the RTP HR payload resemble a SID frame or not */
-static bool is_rtp_hr_sid(const uint8_t *data, const uint8_t data_len)
-{
- int i;
-
- if (data_len < GSM_HR_BYTES)
- return false;
-
- for (i = 0; i < GSM_HR_BYTES; i++) {
- if ((data[i] & rtp_hr_sid[i]) != rtp_hr_sid[i])
- return false;
- }
- return true;
-}
-
static int rtp2trau_hr16(struct osmo_trau_frame *tf, const uint8_t *data, size_t data_len)
{
/* accept both TS 101 318 and RFC 5993 payloads */
@@ -503,7 +486,7 @@
tf->c_bits[11] = 1;
else
tf->c_bits[11] = 0;
- if (is_rtp_hr_sid(data, data_len)) {
+ if (osmo_hr_check_sid(data, data_len)) {
/* SID=2 is a valid SID frame */
tf->c_bits[12] = 1;
tf->c_bits[13] = 0;
@@ -519,7 +502,7 @@
tf->c_bits[12] = 1; /* C13: spare */
tf->c_bits[13] = 1; /* C14: spare */
tf->c_bits[14] = 1; /* C15: spare */
- if (is_rtp_hr_sid(data, data_len))
+ if (osmo_hr_check_sid(data, data_len))
tf->c_bits[15] = 0; /* C16: SP */
else
tf->c_bits[15] = 1; /* C16: SP */
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/37250?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: Ia8fe7e9ea65fadf7f5c136355ca8c24c89f09ef2
Gerrit-Change-Number: 37250
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-MessageType: newchange
falconia has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/37227?usp=email )
Change subject: codec: make osmo_hr_check_sid() more efficient
......................................................................
codec: make osmo_hr_check_sid() more efficient
The operation of checking an HRv1 codec frame for the possibility
of a perfect, error-free SID entails checking the last 79 bits
out of 112, to see if they are all 1s. This operation can be done
much more efficiently without using bitvec.
This change also affects the logic of what osmo_hr_check_sid() does
when the payload length argument is 0, or otherwise less than the
expected 14. The old code had a surely-unintended effect of
returning true on a 0-length payload; the new version returns false
(the input is not a perfect SID frame) if the payload length is 0
or otherwise shorter than GSM_HR_BYTES.
Change-Id: Ib14204102c03c14d6c5aab42b0ffbef2c3dda3fd
---
M src/codec/gsm620.c
1 file changed, 42 insertions(+), 12 deletions(-)
Approvals:
pespin: Looks good to me, approved
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/codec/gsm620.c b/src/codec/gsm620.c
index ef1d3b9..49ee724 100644
--- a/src/codec/gsm620.c
+++ b/src/codec/gsm620.c
@@ -23,8 +23,6 @@
#include <stdbool.h>
#include <string.h>
-#include <osmocom/core/bitvec.h>
-#include <osmocom/core/utils.h>
#include <osmocom/codec/codec.h>
/* GSM HR unvoiced (mode=0) frames - subjective importance bit ordering */
@@ -270,21 +268,32 @@
* \param[in] rtp_payload Buffer with RTP payload
* \param[in] payload_len Length of payload
* \returns true if code word is found, false otherwise
+ *
+ * Note that this function checks only for a perfect, error-free SID.
+ * Unlike GSM 06.31 for FR or GSM 06.81 for EFR, GSM 06.41 spec for HR
+ * does not prescribe exact bit counting rules, hence detection of
+ * partially corrupted SID frames in downstream network elements
+ * without out-of-band indication is not possible.
*/
bool osmo_hr_check_sid(const uint8_t *rtp_payload, size_t payload_len)
{
- struct bitvec bv = {
- .data = (uint8_t *)rtp_payload,
- .data_len = payload_len,
- };
+ static const uint8_t all_ff_bytes[9] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF};
- /* A SID frame is identified by a SID codeword consisting of 79 bits which are all 1,
- * so we basically check if all bits in range r34..r112 (inclusive) are 1. */
- for (bv.cur_bit = 33; bv.cur_bit < bv.data_len * 8; bv.cur_bit++)
- if (bitvec_get_bit_pos(&bv, bv.cur_bit) != ONE)
- return false;
+ if (payload_len < GSM_HR_BYTES)
+ return false;
- return true;
+ /* A SID frame is identified by a SID codeword consisting of 79 bits
+ * which are all 1, so we basically check if all bits in range
+ * r34..r112 (inclusive) are 1. However, given the position of
+ * these bits in the frame, the most efficient way to perform
+ * this check does not use any bit-level operations. */
+ if ((rtp_payload[4] & 0x7F) != 0x7F)
+ return false;
+ if (memcmp(rtp_payload + 5, all_ff_bytes, 9) == 0)
+ return true;
+ else
+ return false;
}
/*! Reset the SID field of a potentially corrupted, but still valid GSM-HR
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/37227?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ib14204102c03c14d6c5aab42b0ffbef2c3dda3fd
Gerrit-Change-Number: 37227
Gerrit-PatchSet: 3
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged