lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

August 2024

  • 1 participants
  • 1478 discussions
[XS] Change in ...osmo-python-tests[master]: osmotestconfig: fix return value of write_config()
by jolly 12 Aug '24

12 Aug '24
jolly has uploaded this change for review. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/37799?usp=email ) Change subject: osmotestconfig: fix return value of write_config() ...................................................................... osmotestconfig: fix return value of write_config() This patch fixes the following exception, if the received string does not match. The calling function just expects an integer. ---- TypeError: '>' not supported between instances of 'tuple' and 'int' ---- Change-Id: I24adfd344937bab1ab641327e59a25bf76e18591 --- M scripts/osmotestconfig.py 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/99/37799/1 diff --git a/scripts/osmotestconfig.py b/scripts/osmotestconfig.py index aa926f1..c56849d 100755 --- a/scripts/osmotestconfig.py +++ b/scripts/osmotestconfig.py @@ -86,7 +86,7 @@ new_config = vty.enabled_command("write") if not new_config.startswith("Configuration saved to "): print(new_config) - return 1, [new_config] + return 1 return 0 -- To view, visit https://gerrit.osmocom.org/c/python/osmo-python-tests/+/37799?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: python/osmo-python-tests Gerrit-Branch: master Gerrit-Change-Id: I24adfd344937bab1ab641327e59a25bf76e18591 Gerrit-Change-Number: 37799 Gerrit-PatchSet: 1 Gerrit-Owner: jolly <andreas(a)eversberg.eu>
1 0
0 0
[M] Change in libosmocore[master]: After writing VTY config, run sync() in a different thread
by Jenkins Builder 12 Aug '24

12 Aug '24
Jenkins Builder has posted comments on this change by jolly. ( https://gerrit.osmocom.org/c/libosmocore/+/37798?usp=email ) Change subject: After writing VTY config, run sync() in a different thread ...................................................................... Patch Set 1: (1 comment) File src/vty/command.c: Robot Comment from checkpatch (run ID jenkins-gerrit-lint-17678): https://gerrit.osmocom.org/c/libosmocore/+/37798/comment/efaaf00c_adb5fbe2?… : PS1, Line 3402: static void *sync_thread(void* arg) "foo* bar" should be "foo *bar" -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/37798?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I3cb2ee68b2e4c730f96522208c4abf00d0f49a44 Gerrit-Change-Number: 37798 Gerrit-PatchSet: 1 Gerrit-Owner: jolly <andreas(a)eversberg.eu> Gerrit-CC: Jenkins Builder Gerrit-Comment-Date: Mon, 12 Aug 2024 14:28:49 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No
1 0
0 0
[M] Change in libosmocore[master]: After writing VTY config, run sync() in a different thread
by jolly 12 Aug '24

12 Aug '24
jolly has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/37798?usp=email ) Change subject: After writing VTY config, run sync() in a different thread ...................................................................... After writing VTY config, run sync() in a different thread Running sync() after writing VTY config causes the process to stop for a fraction of a second. This may results in delayed processing that causes buffer underruns, overflows and delays. After writing VTY configuration to the config file, a new thread is created. This thread runs the sync() command. Once it returns, the thread will signal through a pipe to the main thread that the sync process is complete. The main process will then output the completion message on the VTY. Related: OS#6438 Change-Id: I3cb2ee68b2e4c730f96522208c4abf00d0f49a44 --- M src/vty/command.c 1 file changed, 87 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/98/37798/1 diff --git a/src/vty/command.c b/src/vty/command.c index 1719690..a6c5d94 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -39,6 +39,7 @@ #include <time.h> #include <limits.h> #include <signal.h> +#include <pthread.h> #include <sys/time.h> #include <sys/stat.h> #include <sys/types.h> @@ -51,6 +52,7 @@ #include <osmocom/core/talloc.h> #include <osmocom/core/timer.h> #include <osmocom/core/utils.h> +#include <osmocom/core/select.h> #ifndef MAXPATHLEN #define MAXPATHLEN 4096 @@ -3372,7 +3374,85 @@ return CMD_SUCCESS; } -static int write_config_file(const char *config_file, char **outpath) +static struct osmo_fd sync_fd; +static int sync_pipe_fd[2]; + +static int sync_complete(struct osmo_fd *fd, unsigned int what) +{ + struct vty *vty = fd->data; + + if (sync_pipe_fd[0]) + close(sync_pipe_fd[0]); + if (sync_pipe_fd[1]) + close(sync_pipe_fd[1]); + if (osmo_fd_is_registered(fd)) + osmo_fd_unregister(fd); + + /* Check if pointer to VTY session is still valid. + * If session closes before completion, prevent use-after-free condition. + */ + if (vty && vty_is_active(vty)) { + vty_out(vty, "%s", VTY_NEWLINE); + vty_out(vty, "Configuration saved to %s%s", host.config, VTY_NEWLINE); + } + + return 0; +} + +static void *sync_thread(void* arg) +{ + sync(); + write(sync_pipe_fd[1], "", 1); + + return NULL; +} + +/* Run sync thread and setup pipe to signal completion. */ +static void do_sync(struct vty *vty) +{ + int rc; + pthread_t thread; + + sync_pipe_fd[0] = 0; + sync_pipe_fd[1] = 0; + + if (osmo_fd_is_registered(&sync_fd)) { + LOGP(DLGLOBAL, LOGL_INFO, "There is another ongoing sync, syncing without thread.\n"); + sync(); + sync_complete(&sync_fd, 0); + return; + } + + rc = pipe(sync_pipe_fd); + if (rc < 0) { + LOGP(DLGLOBAL, LOGL_INFO, "Failed to create pipe, syncing without thread.\n"); + sync(); + sync_complete(&sync_fd, 0); + return; + } + + sync_fd.data = vty; + sync_fd.fd = sync_pipe_fd[0]; + sync_fd.when = OSMO_FD_READ; + sync_fd.cb = sync_complete; + rc = osmo_fd_register(&sync_fd); + if (rc < 0) { + LOGP(DLGLOBAL, LOGL_INFO, "Failed to register fd, syncing without thread.\n"); + sync(); + sync_complete(&sync_fd, 0); + return; + } + + rc = pthread_create(&thread, NULL, sync_thread, NULL); + if (rc < 0) { + LOGP(DLGLOBAL, LOGL_INFO, "Failed to create thread, syncing without thread.\n"); + sync(); + sync_complete(&sync_fd, 0); + return; + } +} + +static int write_config_file(struct vty *vty, const char *config_file, char **outpath) { unsigned int i; int fd; @@ -3451,12 +3531,12 @@ unlink(config_file_tmp); return -3; } - sync(); if (unlink(config_file) != 0) { *outpath = talloc_strdup(tall_vty_cmd_ctx, config_file); talloc_free(config_file_sav); talloc_free(config_file_tmp); unlink(config_file_tmp); + do_sync(NULL); return -4; } } @@ -3465,10 +3545,11 @@ talloc_free(config_file_sav); talloc_free(config_file_tmp); unlink(config_file_tmp); + do_sync(NULL); return -5; } unlink(config_file_tmp); - sync(); + do_sync(vty); talloc_free(config_file_sav); talloc_free(config_file_tmp); @@ -3511,7 +3592,7 @@ return CMD_WARNING; } - rc = write_config_file(host.config, &failed_file); + rc = write_config_file(vty, host.config, &failed_file); switch (rc) { case -1: vty_out(vty, "Can't open configuration file %s.%s", @@ -3544,7 +3625,6 @@ rc = CMD_WARNING; break; default: - vty_out(vty, "Configuration saved to %s%s", host.config, VTY_NEWLINE); rc = CMD_SUCCESS; break; } @@ -4377,7 +4457,7 @@ char *failed_file; int rc; - rc = write_config_file(filename, &failed_file); + rc = write_config_file(NULL, filename, &failed_file); talloc_free(failed_file); return rc; } @@ -4398,7 +4478,7 @@ if (host.config == NULL) return -7; - rc = write_config_file(host.config, &failed_file); + rc = write_config_file(NULL, host.config, &failed_file); talloc_free(failed_file); return rc; } -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/37798?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I3cb2ee68b2e4c730f96522208c4abf00d0f49a44 Gerrit-Change-Number: 37798 Gerrit-PatchSet: 1 Gerrit-Owner: jolly <andreas(a)eversberg.eu>
1 0
0 0
[M] Change in pysim[master]: pySim-shell: improve fsdump
by dexter 12 Aug '24

12 Aug '24
Attention is currently required from: laforge. dexter has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/37786?usp=email ) Change subject: pySim-shell: improve fsdump ...................................................................... Patch Set 2: (1 comment) Commit Message: https://gerrit.osmocom.org/c/pysim/+/37786/comment/fcfce20c_6b74011a?usp=em… : PS1, Line 9: Th > somehow this sentence doesn't make sense. At least I can't parse it, please rephrase. Done -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37786?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I4d2ef7b383025a5bbf122f18ecd51b7d73aaba14 Gerrit-Change-Number: 37786 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Comment-Date: Mon, 12 Aug 2024 10:45:07 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
1 0
0 0
[M] Change in pysim[master]: pySim-shell: improve fsdump
by dexter 12 Aug '24

12 Aug '24
Attention is currently required from: dexter, laforge. Hello Jenkins Builder, laforge, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/pysim/+/37786?usp=email to look at the new patch set (#2). The following approvals got outdated and were removed: Code-Review+1 by laforge Change subject: pySim-shell: improve fsdump ...................................................................... pySim-shell: improve fsdump In the previous patch we have improved the export command. Since the implementation of the fsdump command is very similar to the implementation of the export command we can now apply the same improvements to the fsdump command as well. Change-Id: I4d2ef7b383025a5bbf122f18ecd51b7d73aaba14 Related: OS#6092 --- M pySim-shell.py 1 file changed, 63 insertions(+), 101 deletions(-) git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/86/37786/2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37786?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newpatchset Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I4d2ef7b383025a5bbf122f18ecd51b7d73aaba14 Gerrit-Change-Number: 37786 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
1 0
0 0
[M] Change in pysim[master]: runtime: integrate escape route for applications without ADF support
by dexter 12 Aug '24

12 Aug '24
Attention is currently required from: fixeria. dexter has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/37774?usp=email ) Change subject: runtime: integrate escape route for applications without ADF support ...................................................................... Patch Set 3: (1 comment) File pySim/runtime.py: https://gerrit.osmocom.org/c/pysim/+/37774/comment/30583c3a_624651a6?usp=em… : PS3, Line 338: self.select(selectable[1].name, cmd_app) I have checked this again in the GlobalPlatform spec. We may leave the class byte as it is. -- To view, visit https://gerrit.osmocom.org/c/pysim/+/37774?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Ie6f37d13af880d24a9c7a8a95cef436b603587c7 Gerrit-Change-Number: 37774 Gerrit-PatchSet: 3 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Mon, 12 Aug 2024 10:28:11 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No
1 0
0 0
[L] Change in libosmocore[master]: tests: add unit test for osmo_hr_sid_classify()
by fixeria 12 Aug '24

12 Aug '24
Attention is currently required from: falconia. fixeria has posted comments on this change by falconia. ( https://gerrit.osmocom.org/c/libosmocore/+/37797?usp=email ) Change subject: tests: add unit test for osmo_hr_sid_classify() ...................................................................... Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/37797?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I9944bb7d49b6fe004d4bfc7a3f70cfdb03d62614 Gerrit-Change-Number: 37797 Gerrit-PatchSet: 2 Gerrit-Owner: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: falconia <falcon(a)freecalypso.org> Gerrit-Comment-Date: Mon, 12 Aug 2024 09:07:24 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[M] Change in osmo-ttcn3-hacks[master]: SGSN: add paging a whole routing area with multiple cells
by fixeria 11 Aug '24

11 Aug '24
Attention is currently required from: lynxis lazus. fixeria has posted comments on this change by lynxis lazus. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37796?usp=email ) Change subject: SGSN: add paging a whole routing area with multiple cells ...................................................................... Patch Set 1: (1 comment) File sgsn/SGSN_Tests.ttcn: https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37796/comment/3db57480_438a… : PS1, Line 2618: var default d; unused? -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/37796?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I88dc95669d57278a96e05ec84f934ebf70b319e5 Gerrit-Change-Number: 37796 Gerrit-PatchSet: 1 Gerrit-Owner: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Comment-Date: Sun, 11 Aug 2024 20:46:12 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No
1 0
0 0
[M] Change in libosmocore[master]: codec: add osmo_hr_sid_classify()
by falconia 11 Aug '24

11 Aug '24
falconia has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/37558?usp=email ) Change subject: codec: add osmo_hr_sid_classify() ...................................................................... codec: add osmo_hr_sid_classify() In order to support DTX, each frame coming out of the channel decoder for TCH/FS, TCH/HS and TCH/EFS needs to be classified as valid SID, invalid SID or non-SID speech as specified in GSM 06.31, 06.41 and 06.81, respectively. However, the case of TCH/HS (GSM 06.41) is more difficult than FR & EFR: ETSI provided an example implementation instead of a stipulation, and because they failed to document the BCI error flag they relied upon, ETSI's reference implementation of HR SID classification defied understanding for a long time. But now this mystery has been cracked: https://osmocom.org/projects/retro-gsm/wiki/HRv1_error_flags Add a function to libosmocodec that implements the same logic as ETSI's swSidDetection(), including support for BCI flag. This function is intended to be used in OsmoBTS (it can post-process the output of sysmoBTS PHY) when TW-TS-002 output is requested, and it can also be used in implementations of SDR-based GSM MS when feeding TCH/HS Rx to a proper speech decoder and Rx DTX handler for HRv1 codec. Related: OS#6036 Change-Id: I5f4eb65379646125b966cf182775b6e9348900bd --- M include/osmocom/codec/codec.h M src/codec/Makefile.am A src/codec/hr_sid_class.c 3 files changed, 180 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve diff --git a/include/osmocom/codec/codec.h b/include/osmocom/codec/codec.h index c5981f8..7a23e7f 100644 --- a/include/osmocom/codec/codec.h +++ b/include/osmocom/codec/codec.h @@ -100,6 +100,9 @@ enum osmo_gsm631_sid_class osmo_fr_sid_classify(const uint8_t *rtp_payload); enum osmo_gsm631_sid_class osmo_efr_sid_classify(const uint8_t *rtp_payload); +enum osmo_gsm631_sid_class osmo_hr_sid_classify(const uint8_t *rtp_payload, + bool bci_flag, + bool *bfi_from_bci); /*! Check if given FR codec frame is any kind of SID, valid or invalid * \param[in] rtp_payload Buffer with RTP payload diff --git a/src/codec/Makefile.am b/src/codec/Makefile.am index 51968d2..17227b6 100644 --- a/src/codec/Makefile.am +++ b/src/codec/Makefile.am @@ -18,6 +18,7 @@ gsm620.c \ gsm660.c \ gsm690.c \ + hr_sid_class.c \ ecu.c \ ecu_fr.c \ ecu_fr_old.c \ diff --git a/src/codec/hr_sid_class.c b/src/codec/hr_sid_class.c new file mode 100644 index 0000000..6c5ba3d --- /dev/null +++ b/src/codec/hr_sid_class.c @@ -0,0 +1,176 @@ +/* + * This module implements osmo_hr_sid_classify() function - an independent + * reimplementation of the logic that was recommended (but not stipulated + * as normative) by ETSI for classifying received TCH/HS frames as + * valid SID, invalid SID or non-SID speech. + * + * Author: Mychaela N. Falconia <falcon(a)freecalypso.org>, 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 <stdbool.h> + +#include <osmocom/codec/codec.h> + +/* + * Input to the table: any 4-bit nibble. + * Output from the table: number of 1 bits in that nibble. + */ +static const uint8_t ones_in_nibble[16] = {0, 1, 1, 2, 1, 2, 2, 3, + 1, 2, 2, 3, 2, 3, 3, 4}; + +/* + * This helper function takes two byte arrays of equal length (data and mask), + * applies the mask to the data, then counts how many bits are set to 1 + * under the mask, and returns that number. + */ +static unsigned count_ones_under_mask(const uint8_t *data, const uint8_t *mask, + unsigned nbytes) +{ + unsigned n, accum; + uint8_t and; + + accum = 0; + for (n = 0; n < nbytes; n++) { + and = *data++ & *mask++; + accum += ones_in_nibble[and >> 4] + ones_in_nibble[and & 0xF]; + } + return accum; +} + +/* + * When a GSM-HR SID frame has been decoded correctly in voiced mode, + * the 79 bits of the SID field will be the last bits in the frame. + * In the packed format of TS 101 318, the bits of interest will be + * in the last 10 bytes. The following array is the mask to be applied. + */ +static const uint8_t sid_field_last10_mask[10] = { + 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF +}; + +/* + * When a GSM-HR SID frame has been incorrectly decoded in unvoiced mode + * (both mode bits got flipped to 0 by channel errors), the 79 bits + * of the SID field will be badly misordered all over the frame. + * However, they can still be counted for the purpose of SID detection. + * The following array is the mask to be applied to the whole frame + * (14 bytes) to locate the misordered SID field. + */ +static const uint8_t sid_field_misordered[14] = { + 0x08, 0xEF, 0x1F, 0x3F, 0xF3, 0xFC, 0xA4, + 0xFF, 0xFA, 0x3F, 0xFF, 0x47, 0xFF, 0xEC +}; + +/* + * In the channel coding scheme on TCH/HS, the HR codec frame of 112 bits + * is divided into 95 class 1 bits and 17 class 2 bits. In the packed + * format of TS 101 318, all 17 class 2 bits will always be in the last + * 4 bytes; however, the specific bits will be different depending on + * whether the frame was decoded in voiced or unvoiced mode. + * The following two arrays are masks to be applied to the last 4 bytes. + */ +static const uint8_t class2_mask_voiced[4] = {0x7F, 0x80, 0x3F, 0xE0}; +static const uint8_t class2_mask_unvoiced[4] = {0x07, 0x07, 0xFF, 0xE0}; + +/* + * osmo_hr_sid_classify() - this function is an independent reimplementation + * of the logic that was recommended (but not stipulated as normative) by ETSI + * for classifying received TCH/HS frames as valid SID, invalid SID or non-SID + * speech. ETSI's original version is swSidDetection() function in reid.c + * in GSM 06.06 source; the present version implements exactly the same + * logic (same inputs will produce same output), but differs in the following + * ways: + * + * - The frame of channel-decoded 112 payload bits was passed in the form + * of an array of 18 codec parameters in ETSI's version; the present version + * uses the packed format of TS 101 318 instead. + * + * - The C code implementation was written anew by Mother Mychaela; no code + * in this file has been copied directly from GSM 06.06 code drop. + * + * This function is meant to be used only in the same network element + * that performs GSM 05.03 channel decoding (OsmoBTS, new implementations + * of GSM MS), _*NOT*_ in programs or network elements that receive + * HRv1 codec frames from other elements via RTP or Abis-E1 etc! + * + * The BCI logic recommended by ETSI and implemented in practice by at least + * one vendor whose implementation has been reverse-engineered (TI Calypso) + * is included in this function. To understand this logic, please refer + * to this wiki description: + * + * https://osmocom.org/projects/retro-gsm/wiki/HRv1_error_flags + */ +enum osmo_gsm631_sid_class osmo_hr_sid_classify(const uint8_t *rtp_payload, + bool bci_flag, + bool *bfi_from_bci) +{ + uint8_t mode_bits = rtp_payload[4] & 0x30; + unsigned sid_field_ones, class1_ones, class2_ones; + unsigned sid_field_zeros, class1_zeros; + unsigned invalid_sid_threshold; + enum osmo_gsm631_sid_class sidc; + + if (mode_bits != 0) { /* decoded as voiced */ + sid_field_ones = count_ones_under_mask(rtp_payload + 4, + sid_field_last10_mask, 10); + class2_ones = count_ones_under_mask(rtp_payload + 10, + class2_mask_voiced, 4); + } else { /* decoded as unvoiced */ + sid_field_ones = count_ones_under_mask(rtp_payload, + sid_field_misordered, 14); + class2_ones = count_ones_under_mask(rtp_payload + 10, + class2_mask_unvoiced, 4); + } + /* All class 2 bits are in SID field, hence class2_ones can never + * be greater than sid_field_ones. */ + class1_ones = sid_field_ones - class2_ones; + /* 79 is the total number of bits in the SID field */ + sid_field_zeros = 79 - sid_field_ones; + /* 62 is the total number of class 1 bits in TCH/HS frame */ + class1_zeros = 62 - class1_ones; + + /* frame classification logic recommended by ETSI */ + if (bci_flag) + invalid_sid_threshold = 16; + else + invalid_sid_threshold = 11; + + if (class1_zeros < 3) + sidc = OSMO_GSM631_SID_CLASS_VALID; + else if (sid_field_zeros < invalid_sid_threshold) + sidc = OSMO_GSM631_SID_CLASS_INVALID; + else + sidc = OSMO_GSM631_SID_CLASS_SPEECH; + + /* If the mode bits got corrupted and the frame was channel-decoded + * as unvoiced, it cannot be taken as valid SID because the bits + * that hold CN parameters have been misordered. Therefore, + * we have to turn it into invalid SID classification. + */ + if (mode_bits == 0 && sidc == OSMO_GSM631_SID_CLASS_VALID) + sidc = OSMO_GSM631_SID_CLASS_INVALID; + + /* ETSI's peculiar logic that "upgrades" BCI error flag to BFI + * (from lowest to highest error severity) when the decoded bit + * pattern matches a set criterion. We leave it up to applications + * whether they choose to apply this logic or not. If this logic + * is not wanted, pass NULL pointer as the last argument. + */ + if (bci_flag && bfi_from_bci && + sid_field_zeros >= 16 && sid_field_zeros <= 25) + *bfi_from_bci = true; + + return sidc; +} -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/37558?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I5f4eb65379646125b966cf182775b6e9348900bd Gerrit-Change-Number: 37558 Gerrit-PatchSet: 4 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> Gerrit-CC: osmith <osmith(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de>
1 0
0 0
[L] Change in libosmocore[master]: tests: add unit test for osmo_hr_sid_classify()
by laforge 11 Aug '24

11 Aug '24
Attention is currently required from: falconia. laforge has posted comments on this change by falconia. ( https://gerrit.osmocom.org/c/libosmocore/+/37797?usp=email ) Change subject: tests: add unit test for osmo_hr_sid_classify() ...................................................................... Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/37797?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I9944bb7d49b6fe004d4bfc7a3f70cfdb03d62614 Gerrit-Change-Number: 37797 Gerrit-PatchSet: 2 Gerrit-Owner: falconia <falcon(a)freecalypso.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: falconia <falcon(a)freecalypso.org> Gerrit-Comment-Date: Sun, 11 Aug 2024 18:40:55 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • ...
  • 148
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.