From 6323d2e61707ac96d1f4c5c0218c0efe6c203697 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 9 Jan 2016 17:53:30 +0100 Subject: use existing #define for FR/EFR frame length (33/31) --- src/osmo-bts-trx/gsm0503_coding.c | 9 +++++---- src/osmo-bts-trx/scheduler.c | 24 +++++++++++++----------- tests/bursts/bursts_test.c | 7 ++++--- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/osmo-bts-trx/gsm0503_coding.c b/src/osmo-bts-trx/gsm0503_coding.c index fea25f9..c56be5a 100644 --- a/src/osmo-bts-trx/gsm0503_coding.c +++ b/src/osmo-bts-trx/gsm0503_coding.c @@ -30,6 +30,7 @@ #include #include +#include #include "gsm0503_conv.h" #include "gsm0503_parity.h" @@ -722,13 +723,13 @@ int tch_fr_decode(uint8_t *tch_data, sbit_t *bursts, int net_order, int efr, tch_efr_reassemble(tch_data, s); - len = 31; + len = GSM_EFR_BYTES; } else { tch_fr_d_to_b(w, d); tch_fr_reassemble(tch_data, w, net_order); - len = 33; + len = GSM_FR_BYTES; } return len; @@ -741,7 +742,7 @@ int tch_fr_encode(ubit_t *bursts, uint8_t *tch_data, int len, int net_order) int i; switch (len) { - case 31: /* TCH EFR */ + case GSM_EFR_BYTES: /* TCH EFR */ tch_efr_disassemble(s, tch_data); @@ -754,7 +755,7 @@ int tch_fr_encode(ubit_t *bursts, uint8_t *tch_data, int len, int net_order) tch_efr_w_to_d(d, w); goto coding_efr_fr; - case 33: /* TCH FR */ + case GSM_FR_BYTES: /* TCH FR */ tch_fr_disassemble(w, tch_data, net_order); tch_fr_b_to_d(d, w); diff --git a/src/osmo-bts-trx/scheduler.c b/src/osmo-bts-trx/scheduler.c index 2edcae2..5be5f38 100644 --- a/src/osmo-bts-trx/scheduler.c +++ b/src/osmo-bts-trx/scheduler.c @@ -30,6 +30,8 @@ #include #include +#include + #include #include #include @@ -801,7 +803,7 @@ static void tx_tch_common(struct trx_l1h *l1h, uint8_t tn, uint32_t fn, /* handle loss detection of received TCH frames */ if (rsl_cmode == RSL_CMOD_SPD_SPEECH && ++(l1h->chan_states[tn][chan].lost) > 5) { - uint8_t tch_data[33]; + uint8_t tch_data[GSM_FR_BYTES]; int len; LOGP(DL1C, LOGL_NOTICE, "Missing TCH bursts detected, sending " @@ -816,14 +818,14 @@ static void tx_tch_common(struct trx_l1h *l1h, uint8_t tn, uint32_t fn, len = 15; break; } - memset(tch_data, 0, 33); - len = 33; + memset(tch_data, 0, GSM_FR_BYTES); + len = GSM_FR_BYTES; break; case GSM48_CMODE_SPEECH_EFR: /* EFR */ if (chan != TRXC_TCHF) goto inval_mode1; - memset(tch_data, 0, 31); - len = 31; + memset(tch_data, 0, GSM_EFR_BYTES); + len = GSM_EFR_BYTES; break; case GSM48_CMODE_SPEECH_AMR: /* AMR */ len = amr_compose_payload(tch_data, @@ -919,7 +921,7 @@ inval_mode1: } break; } - len = 33; + len = GSM_FR_BYTES; if (msgb_l2len(msg_tch) >= 1 && (msg_tch->l2h[0] >> 4) != 0xd) { LOGP(DL1C, LOGL_NOTICE, "%s Transmitting 'bad " @@ -932,7 +934,7 @@ inval_mode1: case GSM48_CMODE_SPEECH_EFR: /* EFR */ if (chan != TRXC_TCHF) goto inval_mode2; - len = 31; + len = GSM_EFR_BYTES; if (msgb_l2len(msg_tch) >= 1 && (msg_tch->l2h[0] >> 4) != 0xc) { LOGP(DL1C, LOGL_NOTICE, "%s Transmitting 'bad " @@ -1524,12 +1526,12 @@ bfi: /* indicate bad frame */ switch (tch_mode) { case GSM48_CMODE_SPEECH_V1: /* FR */ - memset(tch_data, 0, 33); - rc = 33; + memset(tch_data, 0, GSM_FR_BYTES); + rc = GSM_FR_BYTES; break; case GSM48_CMODE_SPEECH_EFR: /* EFR */ - memset(tch_data, 0, 31); - rc = 31; + memset(tch_data, 0, GSM_EFR_BYTES); + rc = GSM_EFR_BYTES; break; case GSM48_CMODE_SPEECH_AMR: /* AMR */ rc = amr_compose_payload(tch_data, diff --git a/tests/bursts/bursts_test.c b/tests/bursts/bursts_test.c index cc0eacf..43764ab 100644 --- a/tests/bursts/bursts_test.c +++ b/tests/bursts/bursts_test.c @@ -26,6 +26,7 @@ #include #include +#include #include "../../src/osmo-bts-trx/gsm0503_coding.h" @@ -184,7 +185,7 @@ static void test_sch(uint8_t *info) static void test_fr(uint8_t *speech, int len) { - uint8_t result[33]; + uint8_t result[GSM_FR_BYTES]; ubit_t bursts_u[116 * 8]; sbit_t bursts_s[116 * 8]; int n_errors, n_bits_total; @@ -438,8 +439,8 @@ uint8_t test_macblock[][54] = { 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }, }; -uint8_t test_speech_fr[33]; -uint8_t test_speech_efr[31]; +uint8_t test_speech_fr[GSM_FR_BYTES]; +uint8_t test_speech_efr[GSM_EFR_BYTES]; uint8_t test_speech_hr[15]; int main(int argc, char **argv) -- cgit v1.2.3