fixeria has uploaded this change for review.
coding: simplify detect_ahs_id_marker()
Change-Id: I240bac2725d6544b609f7f288071d3a431132fd8
Related: SYS#5853
---
M src/coding/gsm0503_amr_dtx.c
1 file changed, 5 insertions(+), 18 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/39/27939/1
diff --git a/src/coding/gsm0503_amr_dtx.c b/src/coding/gsm0503_amr_dtx.c
index 56056eb..d752be8 100644
--- a/src/coding/gsm0503_amr_dtx.c
+++ b/src/coding/gsm0503_amr_dtx.c
@@ -94,33 +94,20 @@
static bool detect_ahs_id_marker(int *n_errors, int *n_bits_total, const ubit_t * ubits, const ubit_t * id_marker)
{
- unsigned int i, k;
+ unsigned int i;
int errors = 0;
- int bits = 0;
/* Override coded in-band data */
ubits += 16;
- /* Check first identification marker bits (23*9 bits) */
- for (i = 0; i < 23; i++) {
- for (k = 0; k < 9; k++) {
- if (id_marker[k] != *ubits)
- errors++;
- ubits++;
- bits++;
- }
- }
-
- /* Check remaining identification marker bits (5 bits) */
- for (k = 0; k < 5; k++) {
- if (id_marker[k] != *ubits)
+ /* Check the identification marker bits (212 bits) */
+ for (i = 0; i < 212; i++) {
+ if (ubits[i] != id_marker[k % 9])
errors++;
- ubits++;
- bits++;
}
*n_errors = errors;
- *n_bits_total = bits;
+ *n_bits_total = 212;
/* Tolerate up to 1/8 errornous bits */
return *n_errors < *n_bits_total / 8;
To view, visit change 27939. To unsubscribe, or for help writing mail filters, visit settings.