use existing #define for FR/EFR frame length (33/31)

This commit is contained in:
Harald Welte 2016-01-09 17:53:30 +01:00
parent 601781f463
commit 6323d2e617
3 changed files with 22 additions and 18 deletions

View File

@ -30,6 +30,7 @@
#include <osmocom/codec/codec.h>
#include <osmo-bts/logging.h>
#include <osmo-bts/gsm_data.h>
#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);

View File

@ -30,6 +30,8 @@
#include <osmocom/core/bits.h>
#include <osmocom/gsm/a5.h>
#include <osmocom/netif/rtp.h>
#include <osmo-bts/gsm_data.h>
#include <osmo-bts/logging.h>
#include <osmo-bts/rsl.h>
@ -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,

View File

@ -26,6 +26,7 @@
#include <osmocom/core/bits.h>
#include <osmocom/core/utils.h>
#include <osmo-bts/gsm_data.h>
#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)