libosmocoding 1.10.0.27-aec32
Osmocom GSM/GPRS/EGPRS L1 channel coding library
Coding

GSM TS 05.03 coding. More...

Files

file  gsm0503_amr_dtx.h
 GSM TS 05.03 coding.
 
file  gsm0503_coding.h
 GSM TS 05.03 coding.
 
file  gsm0503_coding.c
 

Data Structures

union  gprs_rlc_ul_hdr_egprs
 union across the three different EGPRS Uplink header types More...
 
union  gprs_rlc_dl_hdr_egprs
 union across the three different EGPRS Downlink header types More...
 
struct  gsm0503_mcs_code
 Structure describing a Modulation and Coding Scheme. More...
 

Macros

#define GSM0503_GPRS_BURSTS_NBITS   (116 * 4)
 
#define GSM0503_EGPRS_BURSTS_NBITS   (348 * 4)
 
#define EGPRS_HDR_UPP_MAX   54
 
#define EGPRS_HDR_C_MAX   162
 
#define EGPRS_HDR_HC_MAX   160
 
#define EGPRS_DATA_U_MAX   612
 
#define EGPRS_DATA_C_MAX   1836
 
#define EGPRS_DATA_DC_MAX   1248
 
#define EGPRS_DATA_C1   612
 
#define EGPRS_DATA_C2   EGPRS_DATA_C1
 

Enumerations

enum  gsm0503_amr_dtx_frames {
  AMR_OTHER ,
  AFS_SID_FIRST ,
  AFS_SID_UPDATE ,
  AFS_SID_UPDATE_CN ,
  AFS_ONSET ,
  AHS_SID_UPDATE ,
  AHS_SID_UPDATE_CN ,
  AHS_SID_FIRST_P1 ,
  AHS_SID_FIRST_P2 ,
  AHS_ONSET ,
  AHS_SID_FIRST_INH ,
  AHS_SID_UPDATE_INH
}
 
enum  gsm0503_egprs_mcs {
  EGPRS_MCS0 ,
  EGPRS_MCS1 ,
  EGPRS_MCS2 ,
  EGPRS_MCS3 ,
  EGPRS_MCS4 ,
  EGPRS_MCS5 ,
  EGPRS_MCS6 ,
  EGPRS_MCS7 ,
  EGPRS_MCS8 ,
  EGPRS_MCS9 ,
  EGPRS_NUM_MCS
}
 

Functions

static const char * gsm0503_amr_dtx_frame_name (enum gsm0503_amr_dtx_frames frame)
 
enum gsm0503_amr_dtx_frames gsm0503_detect_afs_dtx_frame (int *n_errors, int *n_bits_total, const ubit_t *ubits) OSMO_DEPRECATED("Use gsm0503_detect_afs_dtx_frame2() instead")
 Detect FR AMR DTX frame in unmapped, deinterleaved frame bits. More...
 
enum gsm0503_amr_dtx_frames gsm0503_detect_ahs_dtx_frame (int *n_errors, int *n_bits_total, const ubit_t *ubits) OSMO_DEPRECATED("Use gsm0503_detect_ahs_dtx_frame2() instead")
 Detect HR AMR DTX frame in unmapped, deinterleaved frame bits. More...
 
enum gsm0503_amr_dtx_frames gsm0503_detect_afs_dtx_frame2 (int *n_errors, int *n_bits_total, int *mode_id, const sbit_t *sbits)
 Detect FR AMR DTX frame in unmapped, deinterleaved frame bits. More...
 
enum gsm0503_amr_dtx_frames gsm0503_detect_ahs_dtx_frame2 (int *n_errors, int *n_bits_total, int *mode_id, const sbit_t *sbits)
 Detect HR AMR DTX frame in unmapped, deinterleaved frame bits. More...
 
int gsm0503_xcch_encode (ubit_t *bursts, const uint8_t *l2_data)
 Encoding of xCCH data from L2 frame to bursts. More...
 
int gsm0503_xcch_decode (uint8_t *l2_data, const sbit_t *bursts, int *n_errors, int *n_bits_total)
 Decoding of xCCH data from bursts to L2 frame. More...
 
int gsm0503_pdtch_encode (ubit_t *bursts, const uint8_t *l2_data, uint8_t l2_len)
 GPRS DL message encoding. More...
 
int gsm0503_pdtch_decode (uint8_t *l2_data, const sbit_t *bursts, uint8_t *usf_p, int *n_errors, int *n_bits_total)
 Decode GPRS PDTCH. More...
 
int gsm0503_pdtch_egprs_encode (ubit_t *bursts, const uint8_t *l2_data, uint8_t l2_len)
 EGPRS DL message encoding. More...
 
int gsm0503_pdtch_egprs_decode (uint8_t *l2_data, const sbit_t *bursts, uint16_t nbits, uint8_t *usf_p, int *n_errors, int *n_bits_total)
 Decode EGPRS UL message. More...
 
int gsm0503_tch_fr_encode (ubit_t *bursts, const uint8_t *tch_data, int len, int net_order)
 Perform channel encoding on a TCH/FS channel according to TS 05.03. More...
 
int gsm0503_tch_fr_decode (uint8_t *tch_data, const sbit_t *bursts, int net_order, int efr, int *n_errors, int *n_bits_total)
 Perform channel decoding of a FR/EFR channel according TS 05.03. More...
 
int gsm0503_tch_hr_encode (ubit_t *bursts, const uint8_t *tch_data, int len)
 Perform channel encoding on a TCH/HS channel according to TS 05.03. More...
 
int gsm0503_tch_hr_decode (uint8_t *tch_data, const sbit_t *bursts, int odd, int *n_errors, int *n_bits_total)
 Perform channel decoding of a HR(v1) channel according TS 05.03, deprecated legacy API. More...
 
int gsm0503_tch_hr_decode2 (uint8_t *tch_data, const sbit_t *bursts, int odd, int *n_errors, int *n_bits_total)
 Perform channel decoding of a HR(v1) channel according TS 05.03. More...
 
int gsm0503_tch_afs_encode (ubit_t *bursts, const uint8_t *tch_data, int len, int codec_mode_req, const uint8_t *codec, int codecs, uint8_t ft, uint8_t cmr)
 Perform channel encoding on a TCH/AFS channel according to TS 05.03. More...
 
int gsm0503_tch_afs_decode (uint8_t *tch_data, const sbit_t *bursts, int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft, uint8_t *cmr, int *n_errors, int *n_bits_total)
 Perform channel decoding of a TCH/AFS channel according TS 05.03. More...
 
int gsm0503_tch_afs_decode_dtx (uint8_t *tch_data, const sbit_t *bursts, int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft, uint8_t *cmr, int *n_errors, int *n_bits_total, uint8_t *dtx)
 Perform channel decoding of a TCH/AFS channel according TS 05.03. More...
 
int gsm0503_tch_ahs_encode (ubit_t *bursts, const uint8_t *tch_data, int len, int codec_mode_req, const uint8_t *codec, int codecs, uint8_t ft, uint8_t cmr)
 Perform channel encoding on a TCH/AHS channel according to TS 05.03. More...
 
int gsm0503_tch_ahs_decode (uint8_t *tch_data, const sbit_t *bursts, int odd, int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft, uint8_t *cmr, int *n_errors, int *n_bits_total)
 Perform channel decoding of a TCH/AHS channel according TS 05.03. More...
 
int gsm0503_tch_ahs_decode_dtx (uint8_t *tch_data, const sbit_t *bursts, int odd, int codec_mode_req, uint8_t *codec, int codecs, uint8_t *ft, uint8_t *cmr, int *n_errors, int *n_bits_total, uint8_t *dtx)
 Perform channel decoding of a TCH/AHS channel according TS 05.03. More...
 
int gsm0503_rach_ext_encode (ubit_t *burst, uint16_t ra11, uint8_t bsic, bool is_11bit)
 Encode the Extended (11-bit) or regular (8-bit) RACH according to 3GPP TS 45.003. More...
 
int gsm0503_rach_encode (ubit_t *burst, const uint8_t *ra, uint8_t bsic)
 Encode the (8-bit) RACH according to TS 05.03. More...
 
int gsm0503_rach_decode (uint8_t *ra, const sbit_t *burst, uint8_t bsic)
 Decode the (8-bit) RACH according to TS 05.03. More...
 
int gsm0503_rach_decode_ber (uint8_t *ra, const sbit_t *burst, uint8_t bsic, int *n_errors, int *n_bits_total)
 Decode the (8-bit) RACH according to TS 05.03. More...
 
int gsm0503_rach_ext_decode (uint16_t *ra, const sbit_t *burst, uint8_t bsic)
 Decode the Extended (11-bit) RACH according to 3GPP TS 45.003. More...
 
int gsm0503_rach_ext_decode_ber (uint16_t *ra, const sbit_t *burst, uint8_t bsic, int *n_errors, int *n_bits_total)
 Decode the Extended (11-bit) RACH according to 3GPP TS 45.003. More...
 
int gsm0503_sch_encode (ubit_t *burst, const uint8_t *sb_info)
 Encode the SCH according to TS 05.03. More...
 
int gsm0503_sch_decode (uint8_t *sb_info, const sbit_t *burst)
 Decode the SCH according to TS 05.03. More...
 
int gsm0503_tch_fr96_encode (ubit_t *bursts, const ubit_t *data)
 Perform channel encoding of a TCH/F9.6 channel as per section 3.3. More...
 
int gsm0503_tch_fr96_decode (ubit_t *data, const sbit_t *bursts, int *n_errors, int *n_bits_total)
 Perform channel decoding of a TCH/F9.6 channel as per section 3.3. More...
 
int gsm0503_tch_fr48_encode (ubit_t *bursts, const ubit_t *data)
 Perform channel encoding of a TCH/F4.8 channel as per section 3.4. More...
 
int gsm0503_tch_fr48_decode (ubit_t *data, const sbit_t *bursts, int *n_errors, int *n_bits_total)
 Perform channel decoding of a TCH/F4.8 channel as per section 3.4. More...
 
int gsm0503_tch_hr48_encode (ubit_t *bursts, const ubit_t *data)
 Perform channel encoding of a TCH/H4.8 channel as per section 3.5. More...
 
int gsm0503_tch_hr48_decode (ubit_t *data, const sbit_t *bursts, int *n_errors, int *n_bits_total)
 Perform channel decoding of a TCH/H4.8 channel as per section 3.5. More...
 
int gsm0503_tch_fr24_encode (ubit_t *bursts, const ubit_t *data)
 Perform channel encoding of a TCH/F2.4 channel as per section 3.6. More...
 
int gsm0503_tch_fr24_decode (ubit_t *data, const sbit_t *bursts, int *n_errors, int *n_bits_total)
 Perform channel decoding of a TCH/F2.4 channel as per section 3.6. More...
 
int gsm0503_tch_hr24_encode (ubit_t *bursts, const ubit_t *data)
 Perform channel encoding of a TCH/H2.4 channel as per section 3.7. More...
 
int gsm0503_tch_hr24_decode (ubit_t *data, const sbit_t *bursts, int *n_errors, int *n_bits_total)
 Perform channel decoding of a TCH/H2.4 channel as per section 3.7. More...
 
int gsm0503_tch_fr144_encode (ubit_t *bursts, const ubit_t *data)
 Perform channel encoding of a TCH/F14.4 channel as per section 3.8. More...
 
int gsm0503_tch_fr144_decode (ubit_t *data, const sbit_t *bursts, int *n_errors, int *n_bits_total)
 Perform channel decoding of a TCH/14.4 channel as per section 3.8. More...
 
int gsm0503_tch_fr_facch_encode (ubit_t *bursts, const uint8_t *data)
 Perform channel encoding of a FACCH/F data as per section 4.2. More...
 
int gsm0503_tch_fr_facch_decode (uint8_t *data, const sbit_t *bursts, int *n_errors, int *n_bits_total)
 Perform channel decoding of a FACCH/F data as per section 4.2. More...
 
int gsm0503_tch_hr_facch_encode (ubit_t *bursts, const uint8_t *data)
 Perform channel encoding of a FACCH/H data as per section 4.3. More...
 
int gsm0503_tch_hr_facch_decode (uint8_t *data, const sbit_t *bursts, int *n_errors, int *n_bits_total)
 Perform channel decoding of a FACCH/H data as per section 4.3. More...
 
static int osmo_conv_decode_ber_punctured (const struct osmo_conv_code *code, const sbit_t *input, ubit_t *output, int *n_errors, int *n_bits_total, const uint8_t *data_punc)
 Convolutional Decode + compute BER for punctured codes. More...
 
static int osmo_conv_decode_ber (const struct osmo_conv_code *code, const sbit_t *input, ubit_t *output, int *n_errors, int *n_bits_total)
 Convolutional Decode + compute BER for non-punctured codes. More...
 
static int _xcch_decode_cB (uint8_t *l2_data, const sbit_t *cB, int *n_errors, int *n_bits_total)
 convenience wrapper for decoding coded bits More...
 
static int _xcch_encode_cB (ubit_t *cB, const uint8_t *l2_data)
 convenience wrapper for encoding to coded bits More...
 
static int egprs_type3_unmap (const sbit_t *bursts, sbit_t *hc, sbit_t *dc)
 
static int egprs_type2_unmap (const sbit_t *bursts, sbit_t *hc, sbit_t *dc)
 
static int egprs_type1_unmap (const sbit_t *bursts, sbit_t *hc, sbit_t *c1, sbit_t *c2, int msc)
 
static int _egprs_decode_hdr (const sbit_t *hc, int mcs, union gprs_rlc_ul_hdr_egprs *hdr)
 
static int egprs_decode_hdr (union gprs_rlc_ul_hdr_egprs *hdr, const sbit_t *bursts, uint16_t nbits)
 
static int egprs_parse_ul_cps (struct egprs_cps *cps, union gprs_rlc_ul_hdr_egprs *hdr, int type)
 
static int egprs_decode_data (uint8_t *l2_data, const sbit_t *c, int mcs, int p, int blk, int *n_errors, int *n_bits_total)
 
static int egprs_type3_map (ubit_t *bursts, const ubit_t *hc, const ubit_t *dc, int usf)
 
static int egprs_type2_map (ubit_t *bursts, const ubit_t *hc, const ubit_t *dc, int usf)
 
static int egprs_type1_map (ubit_t *bursts, const ubit_t *hc, const ubit_t *c1, const ubit_t *c2, int usf, int mcs)
 
static int egprs_encode_hdr (ubit_t *hc, const uint8_t *l2_data, int mcs)
 
static int egprs_encode_data (ubit_t *c, const uint8_t *l2_data, int mcs, int p, int blk)
 
static int egprs_parse_dl_cps (struct egprs_cps *cps, const union gprs_rlc_dl_hdr_egprs *hdr, int type)
 
static void tch_fr_reassemble (uint8_t *tch_data, const ubit_t *b_bits, int net_order)
 assemble a FR codec frame in format as used inside RTP More...
 
static void tch_fr_disassemble (ubit_t *b_bits, const uint8_t *tch_data, int net_order)
 
static void tch_hr_reassemble (uint8_t *tch_data, const ubit_t *b_bits)
 
static void tch_hr_disassemble (ubit_t *b_bits, const uint8_t *tch_data)
 
static void tch_efr_reassemble (uint8_t *tch_data, const ubit_t *b_bits)
 
static void tch_efr_disassemble (ubit_t *b_bits, const uint8_t *tch_data)
 
static void tch_amr_reassemble (uint8_t *tch_data, const ubit_t *d_bits, int len)
 
static void tch_amr_disassemble (ubit_t *d_bits, const uint8_t *tch_data, int len)
 
static void tch_amr_sid_update_append (ubit_t *sid_update, uint8_t sti, uint8_t mi)
 
static void extract_afs_sid_update (sbit_t *sid_update, const sbit_t *sbits)
 
static void tch_fr_d_to_b (ubit_t *b_bits, const ubit_t *d_bits)
 
static void tch_fr_b_to_d (ubit_t *d_bits, const ubit_t *b_bits)
 
static void tch_hr_d_to_b (ubit_t *b_bits, const ubit_t *d_bits)
 
static void tch_hr_b_to_d (ubit_t *d_bits, const ubit_t *b_bits)
 
static void tch_efr_d_to_w (ubit_t *b_bits, const ubit_t *d_bits)
 
static void tch_efr_w_to_d (ubit_t *d_bits, const ubit_t *b_bits)
 
static void tch_efr_protected (const ubit_t *s_bits, ubit_t *b_bits)
 
static void tch_fr_unreorder (ubit_t *d, ubit_t *p, const ubit_t *u)
 
static void tch_fr_reorder (ubit_t *u, const ubit_t *d, const ubit_t *p)
 
static void tch_hr_unreorder (ubit_t *d, ubit_t *p, const ubit_t *u)
 
static void tch_hr_reorder (ubit_t *u, const ubit_t *d, const ubit_t *p)
 
static void tch_efr_reorder (ubit_t *w, const ubit_t *s, const ubit_t *p)
 
static void tch_efr_unreorder (ubit_t *s, ubit_t *p, const ubit_t *w)
 
static void tch_amr_merge (ubit_t *u, const ubit_t *d, const ubit_t *p, int len, int prot)
 
static void tch_amr_unmerge (ubit_t *d, ubit_t *p, const ubit_t *u, int len, int prot)
 
static uint8_t gsm0503_tch_afs_decode_inband (const sbit_t *cB)
 
static uint8_t gsm0503_tch_ahs_decode_inband (const sbit_t *cB)
 
static void rach_apply_bsic (ubit_t *d, uint8_t bsic, uint8_t start)
 
static int16_t rach_decode_ber (const sbit_t *burst, uint8_t bsic, bool is_11bit, int *n_errors, int *n_bits_total)
 
static void _tch_csd_burst_map (ubit_t *burst, const ubit_t *iB)
 

Variables

const struct value_string gsm0503_amr_dtx_frame_names []
 
const struct gsm0503_mcs_code gsm0503_mcs_ul_codes [EGPRS_NUM_MCS]
 
const struct gsm0503_mcs_code gsm0503_mcs_dl_codes [EGPRS_NUM_MCS]
 

Detailed Description

GSM TS 05.03 coding.

This module is the "master module" of libosmocoding. It uses the various other modules (mapping, parity, interleaving) in order to implement the complete channel coding (and decoding) chain for the various channel types as defined in TS 05.03 / 45.003.

Macro Definition Documentation

◆ EGPRS_DATA_C1

#define EGPRS_DATA_C1   612

◆ EGPRS_DATA_C2

#define EGPRS_DATA_C2   EGPRS_DATA_C1

◆ EGPRS_DATA_C_MAX

#define EGPRS_DATA_C_MAX   1836

◆ EGPRS_DATA_DC_MAX

#define EGPRS_DATA_DC_MAX   1248

◆ EGPRS_DATA_U_MAX

#define EGPRS_DATA_U_MAX   612

◆ EGPRS_HDR_C_MAX

#define EGPRS_HDR_C_MAX   162

◆ EGPRS_HDR_HC_MAX

#define EGPRS_HDR_HC_MAX   160

◆ EGPRS_HDR_UPP_MAX

#define EGPRS_HDR_UPP_MAX   54

◆ GSM0503_EGPRS_BURSTS_NBITS

#define GSM0503_EGPRS_BURSTS_NBITS   (348 * 4)

◆ GSM0503_GPRS_BURSTS_NBITS

#define GSM0503_GPRS_BURSTS_NBITS   (116 * 4)

Enumeration Type Documentation

◆ gsm0503_amr_dtx_frames

Enumerator
AMR_OTHER 
AFS_SID_FIRST 
AFS_SID_UPDATE 
AFS_SID_UPDATE_CN 
AFS_ONSET 
AHS_SID_UPDATE 
AHS_SID_UPDATE_CN 
AHS_SID_FIRST_P1 
AHS_SID_FIRST_P2 
AHS_ONSET 
AHS_SID_FIRST_INH 
AHS_SID_UPDATE_INH 

◆ gsm0503_egprs_mcs

Enumerator
EGPRS_MCS0 
EGPRS_MCS1 
EGPRS_MCS2 
EGPRS_MCS3 
EGPRS_MCS4 
EGPRS_MCS5 
EGPRS_MCS6 
EGPRS_MCS7 
EGPRS_MCS8 
EGPRS_MCS9 
EGPRS_NUM_MCS 

Function Documentation

◆ _egprs_decode_hdr()

◆ _tch_csd_burst_map()

static void _tch_csd_burst_map ( ubit_t burst,
const ubit_t iB 
)
inlinestatic

◆ _xcch_decode_cB()

static int _xcch_decode_cB ( uint8_t *  l2_data,
const sbit_t cB,
int *  n_errors,
int *  n_bits_total 
)
static

convenience wrapper for decoding coded bits

Parameters
[out]l2_datacaller-allocated buffer for L2 Frame
[in]cB456 coded (soft) bits as per TS 05.03 4.1.3
[out]n_errorsNumber of detected errors
[out]n_bits_totalNumber of total coded bits
Returns
0 on success; -1 on CRC error

References gsm0503_fire_crc40, gsm0503_xcch, osmo_conv_decode_ber(), osmo_crc64gen_check_bits(), and osmo_ubit2pbit_ext().

Referenced by gsm0503_tch_afs_decode_dtx(), gsm0503_tch_ahs_decode_dtx(), gsm0503_tch_fr_decode(), gsm0503_tch_fr_facch_decode(), gsm0503_tch_hr_decode2(), gsm0503_tch_hr_facch_decode(), and gsm0503_xcch_decode().

◆ _xcch_encode_cB()

static int _xcch_encode_cB ( ubit_t cB,
const uint8_t *  l2_data 
)
static

convenience wrapper for encoding to coded bits

Parameters
[out]cBcaller-allocated buffer for 456 coded bits as per TS 05.03 4.1.3
[in]l2_datato-be-encoded L2 Frame
Returns
0

References gsm0503_fire_crc40, gsm0503_xcch, osmo_conv_encode(), osmo_crc64gen_set_bits(), and osmo_pbit2ubit_ext().

Referenced by gsm0503_tch_afs_encode(), gsm0503_tch_ahs_encode(), gsm0503_tch_fr_encode(), gsm0503_tch_fr_facch_encode(), gsm0503_tch_hr_encode(), gsm0503_tch_hr_facch_encode(), and gsm0503_xcch_encode().

◆ egprs_decode_data()

◆ egprs_decode_hdr()

◆ egprs_encode_data()

◆ egprs_encode_hdr()

◆ egprs_parse_dl_cps()

static int egprs_parse_dl_cps ( struct egprs_cps cps,
const union gprs_rlc_dl_hdr_egprs hdr,
int  type 
)
static

◆ egprs_parse_ul_cps()

static int egprs_parse_ul_cps ( struct egprs_cps cps,
union gprs_rlc_ul_hdr_egprs hdr,
int  type 
)
static

◆ egprs_type1_map()

static int egprs_type1_map ( ubit_t bursts,
const ubit_t hc,
const ubit_t c1,
const ubit_t c2,
int  usf,
int  mcs 
)
static

◆ egprs_type1_unmap()

static int egprs_type1_unmap ( const sbit_t bursts,
sbit_t hc,
sbit_t c1,
sbit_t c2,
int  msc 
)
static

◆ egprs_type2_map()

static int egprs_type2_map ( ubit_t bursts,
const ubit_t hc,
const ubit_t dc,
int  usf 
)
static

◆ egprs_type2_unmap()

static int egprs_type2_unmap ( const sbit_t bursts,
sbit_t hc,
sbit_t dc 
)
static

◆ egprs_type3_map()

static int egprs_type3_map ( ubit_t bursts,
const ubit_t hc,
const ubit_t dc,
int  usf 
)
static

◆ egprs_type3_unmap()

static int egprs_type3_unmap ( const sbit_t bursts,
sbit_t hc,
sbit_t dc 
)
static

◆ extract_afs_sid_update()

static void extract_afs_sid_update ( sbit_t sid_update,
const sbit_t sbits 
)
static

◆ gsm0503_amr_dtx_frame_name()

static const char * gsm0503_amr_dtx_frame_name ( enum gsm0503_amr_dtx_frames  frame)
inlinestatic

◆ gsm0503_detect_afs_dtx_frame()

enum gsm0503_amr_dtx_frames gsm0503_detect_afs_dtx_frame ( int *  n_errors,
int *  n_bits_total,
const ubit_t ubits 
)

Detect FR AMR DTX frame in unmapped, deinterleaved frame bits.

DEPRECATED: use gsm0503_detect_afs_dtx_frame2() instead.

Parameters
[out]n_errorsnumber of errornous bits.
[out]n_bits_totalnumber of checked bits.
[in]ubitsinput bits (456 bit).
Returns
dtx frame type.

References gsm0503_detect_afs_dtx_frame2(), and osmo_ubit2sbit().

◆ gsm0503_detect_afs_dtx_frame2()

enum gsm0503_amr_dtx_frames gsm0503_detect_afs_dtx_frame2 ( int *  n_errors,
int *  n_bits_total,
int *  mode_id,
const sbit_t sbits 
)

Detect FR AMR DTX frame in unmapped, deinterleaved frame bits.

Parameters
[out]n_errorsnumber of errornous bits.
[out]n_bits_totalnumber of checked bits.
[out]mode_idcodec mode ID (0..3 or -1).
[in]sbitsinput soft-bits (456 bit).
Returns
dtx frame type.

References AFS_ONSET, AFS_SID_FIRST, AFS_SID_UPDATE, AMR_OTHER, detect_afs_onset(), detect_afs_sid_first(), and detect_afs_sid_update().

Referenced by gsm0503_detect_afs_dtx_frame(), and gsm0503_tch_afs_decode_dtx().

◆ gsm0503_detect_ahs_dtx_frame()

enum gsm0503_amr_dtx_frames gsm0503_detect_ahs_dtx_frame ( int *  n_errors,
int *  n_bits_total,
const ubit_t ubits 
)

Detect HR AMR DTX frame in unmapped, deinterleaved frame bits.

DEPRECATED: use gsm0503_detect_ahs_dtx_frame2() instead.

Parameters
[out]n_errorsnumber of errornous bits.
[out]n_bits_totalnumber of checked bits.
[in]ubitsinput bits (456 bit).
Returns
dtx frame type,

References gsm0503_detect_ahs_dtx_frame2(), and osmo_ubit2sbit().

◆ gsm0503_detect_ahs_dtx_frame2()

enum gsm0503_amr_dtx_frames gsm0503_detect_ahs_dtx_frame2 ( int *  n_errors,
int *  n_bits_total,
int *  mode_id,
const sbit_t sbits 
)

Detect HR AMR DTX frame in unmapped, deinterleaved frame bits.

Parameters
[out]n_errorsnumber of errornous bits.
[out]n_bits_totalnumber of checked bits.
[out]mode_idcodec ID (CMI or CMC/CMR).
[out]mode_idcodec mode ID (0..3 or -1).
[in]sbitsinput soft-bits (456 bit).
Returns
dtx frame type,

References AHS_ONSET, AHS_SID_FIRST_INH, AHS_SID_FIRST_P1, AHS_SID_FIRST_P2, AHS_SID_UPDATE, AHS_SID_UPDATE_INH, AMR_OTHER, detect_ahs_onset(), detect_ahs_sid_first_inh(), detect_ahs_sid_first_p1(), detect_ahs_sid_first_p2(), detect_ahs_sid_update(), and detect_ahs_sid_update_inh().

Referenced by gsm0503_detect_ahs_dtx_frame(), and gsm0503_tch_ahs_decode_dtx().

◆ gsm0503_pdtch_decode()

int gsm0503_pdtch_decode ( uint8_t *  l2_data,
const sbit_t bursts,
uint8_t *  usf_p,
int *  n_errors,
int *  n_bits_total 
)

Decode GPRS PDTCH.

Parameters
[out]l2_datacaller-allocated buffer for L2 Frame
[in]burstsburst input data as soft unpacked bits
[out]usf_pUplink State Flag, only relevant for DL blocks
[out]n_errorsnumber of detected bit-errors
[out]n_bits_totaltotal number of decoded bits
Returns
number of bytes decoded; negative on error

References gsm0503_cs234_crc16, gsm0503_cs2_np, gsm0503_cs3_np, gsm0503_fire_crc40, gsm0503_pdtch_hl_hn_sbit, gsm0503_puncture_cs2, gsm0503_puncture_cs3, gsm0503_usf2six, gsm0503_usf2twelve_sbit, gsm0503_xcch, gsm0503_xcch_burst_unmap(), gsm0503_xcch_deinterleave(), k, osmo_conv_decode_ber(), osmo_conv_decode_ber_punctured(), osmo_crc16gen_check_bits(), osmo_crc64gen_check_bits(), and osmo_ubit2pbit_ext().

◆ gsm0503_pdtch_egprs_decode()

int gsm0503_pdtch_egprs_decode ( uint8_t *  l2_data,
const sbit_t bursts,
uint16_t  nbits,
uint8_t *  usf_p,
int *  n_errors,
int *  n_bits_total 
)

Decode EGPRS UL message.

  1. Header section decoding
  2. Extract CPS settings
  3. Burst unmapping and deinterleaving
  4. Data section decoding
    Parameters
    [out]l2_datacaller-allocated buffer for L2 Frame
    [in]burstsburst input data as soft unpacked bits
    [in]nbitsnumber of bits in bursts
    usf_pUplink State Flag, FIXME: not implemented
    [out]n_errorsnumber of detected bit-errors
    [out]n_bits_totaltotal number of decoded bits
    Returns
    number of bytes decoded; negative on error

References EGPRS_DATA_C1, EGPRS_DATA_C2, EGPRS_DATA_DC_MAX, egprs_decode_data(), egprs_decode_hdr(), EGPRS_MCS0, EGPRS_MCS1, EGPRS_MCS2, EGPRS_MCS3, EGPRS_MCS4, EGPRS_MCS5, EGPRS_MCS6, EGPRS_MCS7, EGPRS_MCS8, EGPRS_MCS9, egprs_parse_ul_cps(), egprs_type1_unmap(), egprs_type2_unmap(), egprs_type3_unmap(), ENOTSUP, GSM0503_EGPRS_BURSTS_NBITS, GSM0503_GPRS_BURSTS_NBITS, hdr, egprs_cps::mcs, egprs_cps::p, and type.

◆ gsm0503_pdtch_egprs_encode()

int gsm0503_pdtch_egprs_encode ( ubit_t bursts,
const uint8_t *  l2_data,
uint8_t  l2_len 
)

EGPRS DL message encoding.

Parameters
[out]burstscaller-allocated buffer for unpacked burst bits
[in]l2_dataL2 (MAC) block to be encoded
[in]l2_lenlength of l2_data in bytes, used to determine MCS
Returns
number of bits encoded; negative on error

References EGPRS_DATA_C1, EGPRS_DATA_C2, EGPRS_DATA_C_MAX, EGPRS_DATA_DC_MAX, egprs_encode_data(), egprs_encode_hdr(), EGPRS_HDR_TYPE1, EGPRS_HDR_TYPE2, EGPRS_HDR_TYPE3, EGPRS_MCS1, EGPRS_MCS2, EGPRS_MCS3, EGPRS_MCS4, EGPRS_MCS5, EGPRS_MCS6, EGPRS_MCS7, EGPRS_MCS8, EGPRS_MCS9, egprs_parse_dl_cps(), egprs_type1_map(), egprs_type2_map(), egprs_type3_map(), GSM0503_EGPRS_BURSTS_NBITS, GSM0503_GPRS_BURSTS_NBITS, hdr, egprs_cps::mcs, gsm0503_mcs_code::mcs, and egprs_cps::p.

◆ gsm0503_pdtch_encode()

int gsm0503_pdtch_encode ( ubit_t bursts,
const uint8_t *  l2_data,
uint8_t  l2_len 
)

GPRS DL message encoding.

Parameters
[out]burstscaller-allocated buffer for unpacked burst bits
[in]l2_dataL2 (MAC) block to be encoded
[in]l2_lenlength of l2_data in bytes, used to determine CS
Returns
number of bits encoded; negative on error

References gsm0503_cs234_crc16, gsm0503_cs2_np, gsm0503_cs3_np, gsm0503_fire_crc40, GSM0503_GPRS_BURSTS_NBITS, gsm0503_pdtch_hl_hn_ubit, gsm0503_puncture_cs2, gsm0503_puncture_cs3, gsm0503_usf2six, gsm0503_usf2twelve_ubit, gsm0503_xcch, gsm0503_xcch_burst_map(), gsm0503_xcch_interleave(), osmo_conv_encode(), osmo_crc16gen_set_bits(), osmo_crc64gen_set_bits(), and osmo_pbit2ubit_ext().

◆ gsm0503_rach_decode()

int gsm0503_rach_decode ( uint8_t *  ra,
const sbit_t burst,
uint8_t  bsic 
)

Decode the (8-bit) RACH according to TS 05.03.

Parameters
[out]raoutput buffer for RACH data
[in]burstInput burst data
[in]bsicBSIC used in this cell
Returns
0 on success; negative on error (e.g. CRC error)

References rach_decode_ber().

◆ gsm0503_rach_decode_ber()

int gsm0503_rach_decode_ber ( uint8_t *  ra,
const sbit_t burst,
uint8_t  bsic,
int *  n_errors,
int *  n_bits_total 
)

Decode the (8-bit) RACH according to TS 05.03.

Parameters
[out]raoutput buffer for RACH data
[in]burstInput burst data
[in]bsicBSIC used in this cell
[out]n_errorsNumber of detected bit errors
[out]n_bits_totalTotal number of bits
Returns
0 on success; negative on error (e.g. CRC error)

References rach_decode_ber().

◆ gsm0503_rach_encode()

int gsm0503_rach_encode ( ubit_t burst,
const uint8_t *  ra,
uint8_t  bsic 
)

Encode the (8-bit) RACH according to TS 05.03.

Parameters
[out]burstCaller-allocated output burst buffer
[in]raInput RACH data
[in]bsicBSIC used in this cell
Returns
0 on success; negative on error

References gsm0503_rach_ext_encode().

◆ gsm0503_rach_ext_decode()

int gsm0503_rach_ext_decode ( uint16_t *  ra,
const sbit_t burst,
uint8_t  bsic 
)

Decode the Extended (11-bit) RACH according to 3GPP TS 45.003.

Parameters
[out]raoutput buffer for RACH data
[in]burstInput burst data
[in]bsicBSIC used in this cell
Returns
0 on success; negative on error (e.g. CRC error)

References rach_decode_ber().

◆ gsm0503_rach_ext_decode_ber()

int gsm0503_rach_ext_decode_ber ( uint16_t *  ra,
const sbit_t burst,
uint8_t  bsic,
int *  n_errors,
int *  n_bits_total 
)

Decode the Extended (11-bit) RACH according to 3GPP TS 45.003.

Parameters
[out]raoutput buffer for RACH data
[in]burstInput burst data
[in]bsicBSIC used in this cell
[out]n_errorsNumber of detected bit errors
[out]n_bits_totalTotal number of bits
Returns
0 on success; negative on error (e.g. CRC error)

References rach_decode_ber().

◆ gsm0503_rach_ext_encode()

int gsm0503_rach_ext_encode ( ubit_t burst,
uint16_t  ra11,
uint8_t  bsic,
bool  is_11bit 
)

Encode the Extended (11-bit) or regular (8-bit) RACH according to 3GPP TS 45.003.

Parameters
[out]burstCaller-allocated output burst buffer
[in]ra11Input RACH data
[in]bsicBSIC used in this cell
[in]is_11bitwhether given RA is 11 bit or not
Returns
0 on success; negative on error

References gsm0503_rach, gsm0503_rach_crc6, gsm0503_rach_ext, osmo_conv_encode(), osmo_crc8gen_set_bits(), osmo_pbit2ubit_ext(), and rach_apply_bsic().

Referenced by gsm0503_rach_encode().

◆ gsm0503_sch_decode()

int gsm0503_sch_decode ( uint8_t *  sb_info,
const sbit_t burst 
)

Decode the SCH according to TS 05.03.

Parameters
[out]sb_infooutput buffer for SCH data
[in]burstInput burst data
Returns
0 on success; negative on error (e.g. CRC error)

References gsm0503_sch, gsm0503_sch_crc10, osmo_conv_decode(), osmo_crc16gen_check_bits(), and osmo_ubit2pbit_ext().

◆ gsm0503_sch_encode()

int gsm0503_sch_encode ( ubit_t burst,
const uint8_t *  sb_info 
)

Encode the SCH according to TS 05.03.

Parameters
[out]burstCaller-allocated output burst buffer
[in]sb_infoInput SCH data
Returns
0 on success; negative on error

References gsm0503_sch, gsm0503_sch_crc10, osmo_conv_encode(), osmo_crc16gen_set_bits(), and osmo_pbit2ubit_ext().

◆ gsm0503_tch_afs_decode()

int gsm0503_tch_afs_decode ( uint8_t *  tch_data,
const sbit_t bursts,
int  codec_mode_req,
uint8_t *  codec,
int  codecs,
uint8_t *  ft,
uint8_t *  cmr,
int *  n_errors,
int *  n_bits_total 
)

Perform channel decoding of a TCH/AFS channel according TS 05.03.

Parameters
[out]tch_dataCodec frame in RTP payload format
[in]burstsbuffer containing the symbols of 8 bursts
[in]codec_mode_reqis this CMR (1) or CMC (0)
[in]codecarray of active codecs (active codec set)
[in]codecsnumber of codecs in codec
ftFrame Type; Input if codec_mode_req = 1, Output * otherwise
[out]cmrOutput in codec_mode_req = 1
[out]n_errorsNumber of detected bit errors
[out]n_bits_totalTotal number of bits
Returns
(>=4) length of bytes used in tch_data output buffer; ([0,3]) codec out of range; negative on error

References gsm0503_tch_afs_decode_dtx().

◆ gsm0503_tch_afs_decode_dtx()

int gsm0503_tch_afs_decode_dtx ( uint8_t *  tch_data,
const sbit_t bursts,
int  codec_mode_req,
uint8_t *  codec,
int  codecs,
uint8_t *  ft,
uint8_t *  cmr,
int *  n_errors,
int *  n_bits_total,
uint8_t *  dtx 
)

Perform channel decoding of a TCH/AFS channel according TS 05.03.

Parameters
[out]tch_dataCodec frame in RTP payload format
[in]burstsbuffer containing the symbols of 8 bursts
[in]codec_mode_reqis this CMR (1) or CMC (0)
[in]codecarray of active codecs (active codec set)
[in]codecsnumber of codecs in codec
ftFrame Type; Input if codec_mode_req = 1, Output * otherwise
[out]cmrOutput in codec_mode_req = 1
[out]n_errorsNumber of detected bit errors
[out]n_bits_totalTotal number of bits
[in,out]dtxDTX frame type output, previous DTX frame type input
Returns
(>=4) length of bytes used in tch_data output buffer; ([0,3]) codec out of range; negative on error

References _xcch_decode_cB(), AFS_ONSET, AFS_SID_FIRST, AFS_SID_UPDATE, AFS_SID_UPDATE_CN, AMR_OTHER, extract_afs_sid_update(), gsm0503_amr_crc14, gsm0503_amr_crc6, gsm0503_detect_afs_dtx_frame2(), gsm0503_tch_afs_10_2, gsm0503_tch_afs_12_2, gsm0503_tch_afs_4_75, gsm0503_tch_afs_5_15, gsm0503_tch_afs_5_9, gsm0503_tch_afs_6_7, gsm0503_tch_afs_7_4, gsm0503_tch_afs_7_95, gsm0503_tch_afs_decode_inband(), gsm0503_tch_axs_sid_update, gsm0503_tch_burst_unmap(), gsm0503_tch_fr_deinterleave(), GSM_MACBLOCK_LEN, h, len(), osmo_conv_decode_ber(), osmo_crc16gen_check_bits(), osmo_crc8gen_check_bits(), tch_amr_reassemble(), tch_amr_sid_update_append(), and tch_amr_unmerge().

Referenced by gsm0503_tch_afs_decode().

◆ gsm0503_tch_afs_decode_inband()

static uint8_t gsm0503_tch_afs_decode_inband ( const sbit_t cB)
static

References gsm0503_afs_ic_sbit, and k.

Referenced by gsm0503_tch_afs_decode_dtx().

◆ gsm0503_tch_afs_encode()

int gsm0503_tch_afs_encode ( ubit_t bursts,
const uint8_t *  tch_data,
int  len,
int  codec_mode_req,
const uint8_t *  codec,
int  codecs,
uint8_t  ft,
uint8_t  cmr 
)

Perform channel encoding on a TCH/AFS channel according to TS 05.03.

Parameters
[out]burstscaller-allocated output buffer for bursts bits
[in]tch_dataCodec input data in RTP payload format
[in]lenLength of tch_data in bytes or 0 to generate a bad frame
[in]codec_mode_reqUse CMR (1) or FT (0)
[in]codecArray of codecs (active codec set)
[in]codecsNumber of entries in codec
[in]ftFrame Type to be used for encoding (index to codec)
[in]cmrCodec Mode Request (used in codec_mode_req = 1 only)
Returns
0 in case of success; negative on error

References _xcch_encode_cB(), ARRAY_SIZE, gsm0503_afs_ic_ubit, gsm0503_amr_crc6, gsm0503_tch_afs_10_2, gsm0503_tch_afs_12_2, gsm0503_tch_afs_4_75, gsm0503_tch_afs_5_15, gsm0503_tch_afs_5_9, gsm0503_tch_afs_6_7, gsm0503_tch_afs_7_4, gsm0503_tch_afs_7_95, gsm0503_tch_burst_map(), gsm0503_tch_fr_interleave(), GSM_MACBLOCK_LEN, h, len(), osmo_conv_encode(), osmo_crc8gen_set_bits(), OSMO_UNLIKELY, tch_amr_disassemble(), and tch_amr_merge().

◆ gsm0503_tch_ahs_decode()

int gsm0503_tch_ahs_decode ( uint8_t *  tch_data,
const sbit_t bursts,
int  odd,
int  codec_mode_req,
uint8_t *  codec,
int  codecs,
uint8_t *  ft,
uint8_t *  cmr,
int *  n_errors,
int *  n_bits_total 
)

Perform channel decoding of a TCH/AHS channel according TS 05.03.

Parameters
[out]tch_dataCodec frame in RTP payload format
[in]burstsbuffer containing the symbols of 6 bursts
[in]oddIs this an odd (1) or even (0) frame number?
[in]codec_mode_reqis this CMR (1) or CMC (0)
[in]codecarray of active codecs (active codec set)
[in]codecsnumber of codecs in codec
ftFrame Type; Input if codec_mode_req = 1, Output * otherwise
[out]cmrOutput in codec_mode_req = 1
[out]n_errorsNumber of detected bit errors
[out]n_bits_totalTotal number of bits
Returns
(>=4) length of bytes used in tch_data output buffer; ([0,3]) codec out of range; negative on error

References gsm0503_tch_ahs_decode_dtx().

◆ gsm0503_tch_ahs_decode_dtx()

int gsm0503_tch_ahs_decode_dtx ( uint8_t *  tch_data,
const sbit_t bursts,
int  odd,
int  codec_mode_req,
uint8_t *  codec,
int  codecs,
uint8_t *  ft,
uint8_t *  cmr,
int *  n_errors,
int *  n_bits_total,
uint8_t *  dtx 
)

Perform channel decoding of a TCH/AHS channel according TS 05.03.

Parameters
[out]tch_dataCodec frame in RTP payload format
[in]burstsbuffer containing the symbols of 6 bursts
[in]oddIs this an odd (1) or even (0) frame number?
[in]codec_mode_reqis this CMR (1) or CMC (0)
[in]codecarray of active codecs (active codec set)
[in]codecsnumber of codecs in codec
ftFrame Type; Input if codec_mode_req = 1, Output * otherwise
[out]cmrOutput in codec_mode_req = 1
[out]n_errorsNumber of detected bit errors
[out]n_bits_totalTotal number of bits
[in,out]dtxDTX frame type output, previous DTX frame type input
Returns
(>=4) length of bytes used in tch_data output buffer; ([0,3]) codec out of range; negative on error

References _xcch_decode_cB(), AHS_ONSET, AHS_SID_FIRST_INH, AHS_SID_FIRST_P1, AHS_SID_FIRST_P2, AHS_SID_UPDATE, AHS_SID_UPDATE_CN, AHS_SID_UPDATE_INH, AMR_OTHER, gsm0503_amr_crc14, gsm0503_amr_crc6, gsm0503_detect_ahs_dtx_frame2(), gsm0503_tch_ahs_4_75, gsm0503_tch_ahs_5_15, gsm0503_tch_ahs_5_9, gsm0503_tch_ahs_6_7, gsm0503_tch_ahs_7_4, gsm0503_tch_ahs_7_95, gsm0503_tch_ahs_decode_inband(), gsm0503_tch_axs_sid_update, gsm0503_tch_burst_unmap(), gsm0503_tch_fr_deinterleave(), gsm0503_tch_hr_deinterleave(), GSM_MACBLOCK_LEN, h, len(), osmo_conv_decode_ber(), osmo_crc16gen_check_bits(), osmo_crc8gen_check_bits(), tch_amr_reassemble(), tch_amr_sid_update_append(), and tch_amr_unmerge().

Referenced by gsm0503_tch_ahs_decode().

◆ gsm0503_tch_ahs_decode_inband()

static uint8_t gsm0503_tch_ahs_decode_inband ( const sbit_t cB)
static

References gsm0503_ahs_ic_sbit, and k.

Referenced by gsm0503_tch_ahs_decode_dtx().

◆ gsm0503_tch_ahs_encode()

int gsm0503_tch_ahs_encode ( ubit_t bursts,
const uint8_t *  tch_data,
int  len,
int  codec_mode_req,
const uint8_t *  codec,
int  codecs,
uint8_t  ft,
uint8_t  cmr 
)

Perform channel encoding on a TCH/AHS channel according to TS 05.03.

Parameters
[out]burstscaller-allocated output buffer for bursts bits
[in]tch_dataCodec input data in RTP payload format
[in]lenLength of tch_data in bytes or 0 to generate a bad frame
[in]codec_mode_reqUse CMR (1) or FT (0)
[in]codecArray of codecs (active codec set)
[in]codecsNumber of entries in codec
[in]ftFrame Type to be used for encoding (index to codec)
[in]cmrCodec Mode Request (used in codec_mode_req = 1 only)
Returns
0 in case of success; negative on error

References _xcch_encode_cB(), ARRAY_SIZE, gsm0503_ahs_ic_ubit, gsm0503_amr_crc6, gsm0503_tch_ahs_4_75, gsm0503_tch_ahs_5_15, gsm0503_tch_ahs_5_9, gsm0503_tch_ahs_6_7, gsm0503_tch_ahs_7_4, gsm0503_tch_ahs_7_95, gsm0503_tch_burst_map(), gsm0503_tch_fr_interleave(), gsm0503_tch_hr_interleave(), GSM_MACBLOCK_LEN, h, len(), osmo_conv_encode(), osmo_crc8gen_set_bits(), OSMO_UNLIKELY, tch_amr_disassemble(), and tch_amr_merge().

◆ gsm0503_tch_fr144_decode()

int gsm0503_tch_fr144_decode ( ubit_t data,
const sbit_t bursts,
int *  n_errors,
int *  n_bits_total 
)

Perform channel decoding of a TCH/14.4 channel as per section 3.8.

Parameters
[out]dataCaller-allocated buffer for decoded data (290 unpacked bits).
[in]burstsBuffer containing the symbols of 22 bursts, 22 * 2 * 58 == 2552 bits total.
[out]n_errorsNumber of detected bit errors.
[out]n_bits_totalTotal number of bits.
Returns
Number of unpacked bits used in the output buffer; negative on error.

References data, gsm0503_tch_f144, gsm0503_tch_f96_deinterleave(), and osmo_conv_decode_ber().

◆ gsm0503_tch_fr144_encode()

int gsm0503_tch_fr144_encode ( ubit_t bursts,
const ubit_t data 
)

Perform channel encoding of a TCH/F14.4 channel as per section 3.8.

Parameters
[out]burstsCaller-allocated buffer for symbols of 22 bursts, 22 * 2 * 58 == 2552 bits total.
[in]dataData to be encoded (290 unpacked bits).
Returns
0 in case of success; negative on error

References _tch_csd_burst_map(), data, gsm0503_tch_f144, gsm0503_tch_f96_interleave(), and osmo_conv_encode().

◆ gsm0503_tch_fr24_decode()

int gsm0503_tch_fr24_decode ( ubit_t data,
const sbit_t bursts,
int *  n_errors,
int *  n_bits_total 
)

Perform channel decoding of a TCH/F2.4 channel as per section 3.6.

Parameters
[out]dataCaller-allocated buffer for decoded data (72 unpacked bits).
[in]burstsBuffer containing the symbols of 8 bursts, 8 * 2 * 58 == 928 bits total.
[out]n_errorsNumber of detected bit errors.
[out]n_bits_totalTotal number of bits.
Returns
Number of unpacked bits used in the output buffer; negative on error.

References data, gsm0503_tch_burst_unmap(), gsm0503_tch_f24, gsm0503_tch_fr_deinterleave(), and osmo_conv_decode_ber().

◆ gsm0503_tch_fr24_encode()

int gsm0503_tch_fr24_encode ( ubit_t bursts,
const ubit_t data 
)

Perform channel encoding of a TCH/F2.4 channel as per section 3.6.

Parameters
[out]burstsCaller-allocated buffer for symbols of 8 bursts, 8 * 2 * 58 == 928 bits total.
[in]dataData to be encoded (72 unpacked bits).
Returns
0 in case of success; negative on error

References data, gsm0503_tch_burst_map(), gsm0503_tch_f24, gsm0503_tch_fr_interleave(), h, and osmo_conv_encode().

◆ gsm0503_tch_fr48_decode()

int gsm0503_tch_fr48_decode ( ubit_t data,
const sbit_t bursts,
int *  n_errors,
int *  n_bits_total 
)

Perform channel decoding of a TCH/F4.8 channel as per section 3.4.

Parameters
[out]dataCaller-allocated buffer for decoded data (120 unpacked bits).
[in]burstsBuffer containing the symbols of 22 bursts, 22 * 2 * 58 == 2552 bits total.
[out]n_errorsNumber of detected bit errors.
[out]n_bits_totalTotal number of bits.
Returns
Number of unpacked bits used in the output buffer; negative on error.

References data, gsm0503_tch_f48, gsm0503_tch_f96_deinterleave(), k, and osmo_conv_decode_ber().

◆ gsm0503_tch_fr48_encode()

int gsm0503_tch_fr48_encode ( ubit_t bursts,
const ubit_t data 
)

Perform channel encoding of a TCH/F4.8 channel as per section 3.4.

Parameters
[out]burstsCaller-allocated buffer for symbols of 22 bursts, 22 * 2 * 58 == 2552 bits total.
[in]dataData to be encoded (120 unpacked bits).
Returns
0 in case of success; negative on error

References _tch_csd_burst_map(), data, gsm0503_tch_f48, gsm0503_tch_f96_interleave(), k, and osmo_conv_encode().

◆ gsm0503_tch_fr96_decode()

int gsm0503_tch_fr96_decode ( ubit_t data,
const sbit_t bursts,
int *  n_errors,
int *  n_bits_total 
)

Perform channel decoding of a TCH/F9.6 channel as per section 3.3.

Parameters
[out]dataCaller-allocated buffer for decoded data (240 unpacked bits).
[in]burstsBuffer containing the symbols of 22 bursts, 22 * 2 * 58 == 2552 bits total.
[out]n_errorsNumber of detected bit errors.
[out]n_bits_totalTotal number of bits.
Returns
Number of unpacked bits used in the output buffer; negative on error.

References data, gsm0503_tch_f96, gsm0503_tch_f96_deinterleave(), and osmo_conv_decode_ber().

Referenced by gsm0503_tch_hr48_decode().

◆ gsm0503_tch_fr96_encode()

int gsm0503_tch_fr96_encode ( ubit_t bursts,
const ubit_t data 
)

Perform channel encoding of a TCH/F9.6 channel as per section 3.3.

Parameters
[out]burstsCaller-allocated buffer for symbols of 22 bursts, 22 * 2 * 58 == 2552 bits total.
[in]dataData to be encoded (240 unpacked bits).
Returns
0 in case of success; negative on error.

References _tch_csd_burst_map(), data, gsm0503_tch_f96, gsm0503_tch_f96_interleave(), and osmo_conv_encode().

Referenced by gsm0503_tch_hr48_encode().

◆ gsm0503_tch_fr_decode()

int gsm0503_tch_fr_decode ( uint8_t *  tch_data,
const sbit_t bursts,
int  net_order,
int  efr,
int *  n_errors,
int *  n_bits_total 
)

Perform channel decoding of a FR/EFR channel according TS 05.03.

Parameters
[out]tch_dataCodec frame in RTP payload format
[in]burstsbuffer containing the symbols of 8 bursts
[in]net_orderFIXME
[in]efrIs this channel using EFR (1) or FR (0)
[out]n_errorsNumber of detected bit errors
[out]n_bits_totalTotal number of bits
Returns
length of bytes used in tch_data output buffer; negative on error

References _xcch_decode_cB(), gsm0503_tch_burst_unmap(), gsm0503_tch_efr_crc8, gsm0503_tch_fr, gsm0503_tch_fr_crc3, gsm0503_tch_fr_deinterleave(), GSM_EFR_BYTES, GSM_FR_BYTES, GSM_MACBLOCK_LEN, h, len(), osmo_conv_decode_ber(), osmo_crc8gen_check_bits(), tch_efr_d_to_w(), tch_efr_protected(), tch_efr_reassemble(), tch_efr_unreorder(), tch_fr_d_to_b(), tch_fr_reassemble(), and tch_fr_unreorder().

◆ gsm0503_tch_fr_encode()

int gsm0503_tch_fr_encode ( ubit_t bursts,
const uint8_t *  tch_data,
int  len,
int  net_order 
)

Perform channel encoding on a TCH/FS channel according to TS 05.03.

Parameters
[out]burstscaller-allocated output buffer for bursts bits
[in]tch_dataCodec input data in RTP payload format
[in]lenLength of tch_data in bytes
[in]net_orderFIXME
Returns
0 in case of success; negative on error

References _xcch_encode_cB(), gsm0503_tch_burst_map(), gsm0503_tch_efr_crc8, gsm0503_tch_fr, gsm0503_tch_fr_crc3, gsm0503_tch_fr_interleave(), GSM_EFR_BYTES, GSM_FR_BYTES, GSM_MACBLOCK_LEN, h, len(), osmo_conv_encode(), osmo_crc8gen_set_bits(), tch_efr_disassemble(), tch_efr_protected(), tch_efr_reorder(), tch_efr_w_to_d(), tch_fr_b_to_d(), tch_fr_disassemble(), and tch_fr_reorder().

◆ gsm0503_tch_fr_facch_decode()

int gsm0503_tch_fr_facch_decode ( uint8_t *  data,
const sbit_t bursts,
int *  n_errors,
int *  n_bits_total 
)

Perform channel decoding of a FACCH/F data as per section 4.2.

Parameters
[out]dataCaller-allocated buffer for decoded FACCH (GSM_MACBLOCK_LEN).
[in]burstsBuffer containing the symbols of 8 bursts, 8 * 2 * 58 == 928 bits total.
[out]n_errorsNumber of detected bit errors.
[out]n_bits_totalTotal number of bits.
Returns
Number of bytes used in the output buffer; negative on error.

References _xcch_decode_cB(), data, gsm0503_tch_burst_unmap(), gsm0503_tch_fr_deinterleave(), and GSM_MACBLOCK_LEN.

◆ gsm0503_tch_fr_facch_encode()

int gsm0503_tch_fr_facch_encode ( ubit_t bursts,
const uint8_t *  data 
)

Perform channel encoding of a FACCH/F data as per section 4.2.

Parameters
[out]burstsCaller-allocated buffer for symbols of 8 bursts, 8 * 2 * 58 == 928 bits total.
[in]dataFACCH MAC block to be encoded (GSM_MACBLOCK_LEN).
Returns
0 in case of success; negative on error

References _xcch_encode_cB(), data, gsm0503_tch_burst_map(), gsm0503_tch_fr_interleave(), and h.

◆ gsm0503_tch_hr24_decode()

int gsm0503_tch_hr24_decode ( ubit_t data,
const sbit_t bursts,
int *  n_errors,
int *  n_bits_total 
)

Perform channel decoding of a TCH/H2.4 channel as per section 3.7.

Parameters
[out]dataCaller-allocated buffer for decoded data (144 unpacked bits).
[in]burstsBuffer containing the symbols of 22 bursts, 22 * 2 * 58 == 2552 bits total.
[out]n_errorsNumber of detected bit errors.
[out]n_bits_totalTotal number of bits.
Returns
Number of unpacked bits used in the output buffer; negative on error.

References data, gsm0503_tch_f96_deinterleave(), gsm0503_tch_h24, and osmo_conv_decode_ber().

◆ gsm0503_tch_hr24_encode()

int gsm0503_tch_hr24_encode ( ubit_t bursts,
const ubit_t data 
)

Perform channel encoding of a TCH/H2.4 channel as per section 3.7.

Parameters
[out]burstsCaller-allocated buffer for symbols of 22 bursts, 22 * 2 * 58 == 2552 bits total.
[in]dataData to be encoded (144 unpacked bits).
Returns
0 in case of success; negative on error

References _tch_csd_burst_map(), data, gsm0503_tch_f96_interleave(), gsm0503_tch_h24, and osmo_conv_encode().

◆ gsm0503_tch_hr48_decode()

int gsm0503_tch_hr48_decode ( ubit_t data,
const sbit_t bursts,
int *  n_errors,
int *  n_bits_total 
)

Perform channel decoding of a TCH/H4.8 channel as per section 3.5.

The algorithm is identical to TCH/F9.6, so it's just a wrapper.

Parameters
[out]dataCaller-allocated buffer for decoded data (240 unpacked bits).
[in]burstsBuffer containing the symbols of 22 bursts, 22 * 2 * 58 == 2552 bits total.
[out]n_errorsNumber of detected bit errors.
[out]n_bits_totalTotal number of bits.
Returns
Number of unpacked bits used in the output buffer; negative on error.

References data, and gsm0503_tch_fr96_decode().

◆ gsm0503_tch_hr48_encode()

int gsm0503_tch_hr48_encode ( ubit_t bursts,
const ubit_t data 
)

Perform channel encoding of a TCH/H4.8 channel as per section 3.5.

The algorithm is identical to TCH/F9.6, so it's just a wrapper.

Parameters
[out]burstsCaller-allocated buffer for symbols of 22 bursts, 22 * 2 * 58 == 2552 bits total.
[in]dataData to be encoded (240 unpacked bits).
Returns
0 in case of success; negative on error

References data, and gsm0503_tch_fr96_encode().

◆ gsm0503_tch_hr_decode()

int gsm0503_tch_hr_decode ( uint8_t *  tch_data,
const sbit_t bursts,
int  odd,
int *  n_errors,
int *  n_bits_total 
)

Perform channel decoding of a HR(v1) channel according TS 05.03, deprecated legacy API.

Parameters
[out]tch_dataCodec frame in pseudo-RFC5993 format
[in]burstsbuffer containing the symbols of 6 bursts
[in]oddOdd (1) or even (0) frame number
[out]n_errorsNumber of detected bit errors
[out]n_bits_totalTotal number of bits
Returns
length of bytes used in tch_data output buffer; negative on error

The HR1 codec frame format returned by this function is pseudo-RFC5993, not true RFC 5993, as there is no SID classification being done and the FT bits in the ToC octet are always set to 0 - but this arguably-bogus format is the legacy public API.

References gsm0503_tch_hr_decode2(), GSM_HR_BYTES, and GSM_HR_BYTES_RTP_RFC5993.

◆ gsm0503_tch_hr_decode2()

int gsm0503_tch_hr_decode2 ( uint8_t *  tch_data,
const sbit_t bursts,
int  odd,
int *  n_errors,
int *  n_bits_total 
)

Perform channel decoding of a HR(v1) channel according TS 05.03.

Parameters
[out]tch_dataCodec frame in TS 101 318 canonical format
[in]burstsbuffer containing the symbols of 6 bursts
[in]oddOdd (1) or even (0) frame number
[out]n_errorsNumber of detected bit errors
[out]n_bits_totalTotal number of bits
Returns
length of bytes used in tch_data output buffer; negative on error

References _xcch_decode_cB(), gsm0503_tch_burst_unmap(), gsm0503_tch_fr_crc3, gsm0503_tch_fr_deinterleave(), gsm0503_tch_hr, gsm0503_tch_hr_deinterleave(), GSM_HR_BYTES, GSM_MACBLOCK_LEN, h, osmo_conv_decode_ber(), osmo_crc8gen_check_bits(), tch_hr_d_to_b(), tch_hr_reassemble(), and tch_hr_unreorder().

Referenced by gsm0503_tch_hr_decode().

◆ gsm0503_tch_hr_encode()

int gsm0503_tch_hr_encode ( ubit_t bursts,
const uint8_t *  tch_data,
int  len 
)

Perform channel encoding on a TCH/HS channel according to TS 05.03.

Parameters
[out]burstscaller-allocated output buffer for bursts bits
[in]tch_dataCodec input data in RTP payload format
[in]lenLength of tch_data in bytes
Returns
0 in case of success; negative on error

References _xcch_encode_cB(), gsm0503_tch_burst_map(), gsm0503_tch_fr_crc3, gsm0503_tch_fr_interleave(), gsm0503_tch_hr, gsm0503_tch_hr_interleave(), GSM_HR_BYTES, GSM_HR_BYTES_RTP_RFC5993, GSM_MACBLOCK_LEN, h, len(), osmo_conv_encode(), osmo_crc8gen_set_bits(), tch_hr_b_to_d(), tch_hr_disassemble(), and tch_hr_reorder().

◆ gsm0503_tch_hr_facch_decode()

int gsm0503_tch_hr_facch_decode ( uint8_t *  data,
const sbit_t bursts,
int *  n_errors,
int *  n_bits_total 
)

Perform channel decoding of a FACCH/H data as per section 4.3.

Parameters
[out]dataCaller-allocated buffer for decoded FACCH (GSM_MACBLOCK_LEN).
[in]burstsBuffer containing the symbols of 6 bursts, 6 * 2 * 58 == 696 bits total.
[out]n_errorsNumber of detected bit errors.
[out]n_bits_totalTotal number of bits.
Returns
Number of bytes used in the output buffer; negative on error.

References _xcch_decode_cB(), data, gsm0503_tch_burst_unmap(), gsm0503_tch_fr_deinterleave(), and GSM_MACBLOCK_LEN.

◆ gsm0503_tch_hr_facch_encode()

int gsm0503_tch_hr_facch_encode ( ubit_t bursts,
const uint8_t *  data 
)

Perform channel encoding of a FACCH/H data as per section 4.3.

Parameters
[out]burstsCaller-allocated buffer for symbols of 6 bursts, 6 * 2 * 58 == 696 bits total.
[in]dataFACCH MAC block to be encoded (GSM_MACBLOCK_LEN).
Returns
0 in case of success; negative on error

References _xcch_encode_cB(), data, gsm0503_tch_burst_map(), gsm0503_tch_fr_interleave(), and h.

◆ gsm0503_xcch_decode()

int gsm0503_xcch_decode ( uint8_t *  l2_data,
const sbit_t bursts,
int *  n_errors,
int *  n_bits_total 
)

Decoding of xCCH data from bursts to L2 frame.

Parameters
[out]l2_datacaller-allocated output data buffer
[in]burstsfour GSM bursts in soft-bits
[out]n_errorsNumber of detected errors
[out]n_bits_totalNumber of total coded bits

References _xcch_decode_cB(), gsm0503_xcch_burst_unmap(), and gsm0503_xcch_deinterleave().

◆ gsm0503_xcch_encode()

int gsm0503_xcch_encode ( ubit_t bursts,
const uint8_t *  l2_data 
)

Encoding of xCCH data from L2 frame to bursts.

Parameters
[out]burstscaller-allocated burst data (unpacked bits)
[in]l2_dataL2 input data (MAC block)
Returns
0

References _xcch_encode_cB(), gsm0503_xcch_burst_map(), and gsm0503_xcch_interleave().

◆ osmo_conv_decode_ber()

static int osmo_conv_decode_ber ( const struct osmo_conv_code code,
const sbit_t input,
ubit_t output,
int *  n_errors,
int *  n_bits_total 
)
static

Convolutional Decode + compute BER for non-punctured codes.

Parameters
[in]codeDescription of Convolutional Code
[in]inputInput soft-bits (-127...127)
[out]outputbits
[out]n_errorsNumber of bit-errors
[out]n_bits_totalNumber of bits

References osmo_conv_decode_ber_punctured().

Referenced by _egprs_decode_hdr(), _xcch_decode_cB(), gsm0503_pdtch_decode(), gsm0503_tch_afs_decode_dtx(), gsm0503_tch_ahs_decode_dtx(), gsm0503_tch_fr144_decode(), gsm0503_tch_fr24_decode(), gsm0503_tch_fr48_decode(), gsm0503_tch_fr96_decode(), gsm0503_tch_fr_decode(), gsm0503_tch_hr24_decode(), gsm0503_tch_hr_decode2(), and rach_decode_ber().

◆ osmo_conv_decode_ber_punctured()

static int osmo_conv_decode_ber_punctured ( const struct osmo_conv_code code,
const sbit_t input,
ubit_t output,
int *  n_errors,
int *  n_bits_total,
const uint8_t *  data_punc 
)
static

Convolutional Decode + compute BER for punctured codes.

Parameters
[in]codeDescription of Convolutional Code
[in]inputInput soft-bits (-127...127)
[out]outputbits
[out]n_errorsNumber of bit-errors
[out]n_bits_totalNumber of bits
[in]data_puncPuncturing mask array. Can be NULL.

References ARRAY_SIZE, gsm0503_mcs_code::data_punc, EGPRS_DATA_C_MAX, OSMO_ASSERT, osmo_conv_decode(), osmo_conv_encode(), and res.

Referenced by egprs_decode_data(), gsm0503_pdtch_decode(), and osmo_conv_decode_ber().

◆ rach_apply_bsic()

static void rach_apply_bsic ( ubit_t d,
uint8_t  bsic,
uint8_t  start 
)
inlinestatic

References start.

Referenced by gsm0503_rach_ext_encode(), and rach_decode_ber().

◆ rach_decode_ber()

static int16_t rach_decode_ber ( const sbit_t burst,
uint8_t  bsic,
bool  is_11bit,
int *  n_errors,
int *  n_bits_total 
)
inlinestatic

◆ tch_amr_disassemble()

static void tch_amr_disassemble ( ubit_t d_bits,
const uint8_t *  tch_data,
int  len 
)
static

References len().

Referenced by gsm0503_tch_afs_encode(), and gsm0503_tch_ahs_encode().

◆ tch_amr_merge()

static void tch_amr_merge ( ubit_t u,
const ubit_t d,
const ubit_t p,
int  len,
int  prot 
)
static

References len(), and u.

Referenced by gsm0503_tch_afs_encode(), and gsm0503_tch_ahs_encode().

◆ tch_amr_reassemble()

static void tch_amr_reassemble ( uint8_t *  tch_data,
const ubit_t d_bits,
int  len 
)
static

◆ tch_amr_sid_update_append()

static void tch_amr_sid_update_append ( ubit_t sid_update,
uint8_t  sti,
uint8_t  mi 
)
static

◆ tch_amr_unmerge()

static void tch_amr_unmerge ( ubit_t d,
ubit_t p,
const ubit_t u,
int  len,
int  prot 
)
static

References len(), and u.

Referenced by gsm0503_tch_afs_decode_dtx(), and gsm0503_tch_ahs_decode_dtx().

◆ tch_efr_d_to_w()

static void tch_efr_d_to_w ( ubit_t b_bits,
const ubit_t d_bits 
)
static

References gsm660_bitorder.

Referenced by gsm0503_tch_fr_decode().

◆ tch_efr_disassemble()

static void tch_efr_disassemble ( ubit_t b_bits,
const uint8_t *  tch_data 
)
static

Referenced by gsm0503_tch_fr_encode().

◆ tch_efr_protected()

static void tch_efr_protected ( const ubit_t s_bits,
ubit_t b_bits 
)
static

◆ tch_efr_reassemble()

static void tch_efr_reassemble ( uint8_t *  tch_data,
const ubit_t b_bits 
)
static

Referenced by gsm0503_tch_fr_decode().

◆ tch_efr_reorder()

static void tch_efr_reorder ( ubit_t w,
const ubit_t s,
const ubit_t p 
)
static

Referenced by gsm0503_tch_fr_encode().

◆ tch_efr_unreorder()

static void tch_efr_unreorder ( ubit_t s,
ubit_t p,
const ubit_t w 
)
static

Referenced by gsm0503_tch_fr_decode().

◆ tch_efr_w_to_d()

static void tch_efr_w_to_d ( ubit_t d_bits,
const ubit_t b_bits 
)
static

References gsm660_bitorder.

Referenced by gsm0503_tch_fr_encode().

◆ tch_fr_b_to_d()

static void tch_fr_b_to_d ( ubit_t d_bits,
const ubit_t b_bits 
)
static

References gsm610_bitorder.

Referenced by gsm0503_tch_fr_encode().

◆ tch_fr_d_to_b()

static void tch_fr_d_to_b ( ubit_t b_bits,
const ubit_t d_bits 
)
static

References gsm610_bitorder.

Referenced by gsm0503_tch_fr_decode().

◆ tch_fr_disassemble()

static void tch_fr_disassemble ( ubit_t b_bits,
const uint8_t *  tch_data,
int  net_order 
)
static

References gsm0503_gsm_fr_map, k, and l.

Referenced by gsm0503_tch_fr_encode().

◆ tch_fr_reassemble()

static void tch_fr_reassemble ( uint8_t *  tch_data,
const ubit_t b_bits,
int  net_order 
)
static

assemble a FR codec frame in format as used inside RTP

Parameters
[out]tch_dataCodec frame in RTP format
[in]b_bitsCodec frame in 'native' format
[in]net_orderFIXME

References gsm0503_gsm_fr_map, k, and l.

Referenced by gsm0503_tch_fr_decode().

◆ tch_fr_reorder()

static void tch_fr_reorder ( ubit_t u,
const ubit_t d,
const ubit_t p 
)
static

References u.

Referenced by gsm0503_tch_fr_encode().

◆ tch_fr_unreorder()

static void tch_fr_unreorder ( ubit_t d,
ubit_t p,
const ubit_t u 
)
static

References u.

Referenced by gsm0503_tch_fr_decode().

◆ tch_hr_b_to_d()

static void tch_hr_b_to_d ( ubit_t d_bits,
const ubit_t b_bits 
)
static

◆ tch_hr_d_to_b()

static void tch_hr_d_to_b ( ubit_t b_bits,
const ubit_t d_bits 
)
static

◆ tch_hr_disassemble()

static void tch_hr_disassemble ( ubit_t b_bits,
const uint8_t *  tch_data 
)
static

Referenced by gsm0503_tch_hr_encode().

◆ tch_hr_reassemble()

static void tch_hr_reassemble ( uint8_t *  tch_data,
const ubit_t b_bits 
)
static

References GSM_HR_BYTES.

Referenced by gsm0503_tch_hr_decode2().

◆ tch_hr_reorder()

static void tch_hr_reorder ( ubit_t u,
const ubit_t d,
const ubit_t p 
)
static

References u.

Referenced by gsm0503_tch_hr_encode().

◆ tch_hr_unreorder()

static void tch_hr_unreorder ( ubit_t d,
ubit_t p,
const ubit_t u 
)
static

References u.

Referenced by gsm0503_tch_hr_decode2().

Variable Documentation

◆ gsm0503_amr_dtx_frame_names

const struct value_string gsm0503_amr_dtx_frame_names[]
extern

◆ gsm0503_mcs_dl_codes

const struct gsm0503_mcs_code gsm0503_mcs_dl_codes[EGPRS_NUM_MCS]

◆ gsm0503_mcs_ul_codes

const struct gsm0503_mcs_code gsm0503_mcs_ul_codes[EGPRS_NUM_MCS]