Loading...
Searching...
No Matches
gsm610.c File Reference

GSM 06.10 - GSM FR codec. More...

`#include <stdint.h>`
`#include <stdbool.h>`
`#include <osmocom/core/bitvec.h>`
`#include <osmocom/core/utils.h>`
`#include <osmocom/codec/codec.h>`

## Functions

bool | osmo_fr_check_sid (const uint8_t *rtp_payload, size_t payload_len)
| Check whether RTP frame contains FR SID code word according to TS 101 318 §5.1.2.
enum osmo_gsm631_sid_class | osmo_fr_sid_classify (const uint8_t *rtp_payload)
| Classify potentially-SID FR codec frame in RTP format according to the rules of GSM 06.31 §6.1.1.
void | osmo_fr_sid_reset (uint8_t *rtp_payload)
| Reset the SID field and the unused bits of a potentially corrupted, but still valid GSM-FR SID frame in RTP encoding to their pristine state.
bool | osmo_fr_sid_preen (uint8_t *rtp_payload)
| Preen potentially-SID FR codec frame in RTP format, ensuring that it is either a speech frame or a valid SID, and if the latter, making it a perfect, error-free SID frame.

## Variables

const uint16_t | gsm610_bitorder [260]
const uint8_t | osmo_gsm611_silence_frame [GSM_FR_BYTES]
static const uint16_t | sid_code_word_bits [95]

## Detailed Description

GSM 06.10 - GSM FR codec.

## Function Documentation

## osmo_fr_check_sid()

bool osmo_fr_check_sid | ( | const uint8_t * | rtp_payload,
|  | size_t | payload_len )

Check whether RTP frame contains FR SID code word according to TS 101 318 §5.1.2.

Parameters

  [in] | rtp_payload | Buffer with RTP payload
  [in] | payload_len | Length of payload

Returns
  true if code word is found, false otherwise

References bitvec::data, bitvec::data_len, and sid_code_word_bits.

Referenced by conceal_frame().

## osmo_fr_sid_classify()

enum osmo_gsm631_sid_class osmo_fr_sid_classify | ( | const uint8_t * | rtp_payload | ) |

Classify potentially-SID FR codec frame in RTP format according to the rules of GSM 06.31 §6.1.1.

Parameters

  [in] | rtp_payload | Buffer with RTP payload

Returns
  enum osmo_gsm631_sid_class, with symbolic values OSMO_GSM631_SID_CLASS_SPEECH, OSMO_GSM631_SID_CLASS_INVALID or OSMO_GSM631_SID_CLASS_VALID corresponding to the 3 possible bit-counting classifications prescribed by the spec.

Differences between the more familiar osmo_fr_check_sid() and the present function are:

1. osmo_fr_check_sid() returns true only if the SID frame is absolutely perfect, with all 95 bits of the SID code word zeroed. However, the rules of GSM 06.31 §6.1.1 allow up to one bit to be in error, and the frame is still accepted as valid SID.
2. The third possible state of invalid SID is not handled at all by the simpler osmo_fr_check_sid() function.
3. osmo_fr_check_sid() includes a check for 0xD RTP signature, and returns false if that signature nibble is wrong. That check is not included in the present version because there is no place for it in the ETSI-prescribed classification, it is neither speech nor SID. The assumption is that this function is used to classify the bit content of received codec frames, not their RTP encoding - the latter needs to be validated beforehand.

Which function should one use? The answer depends on the specific circumstances, and needs to be addressed on a case-by-case basis.

References bitvec::data, bitvec::data_len, GSM_FR_BYTES, OSMO_GSM631_SID_CLASS_INVALID, OSMO_GSM631_SID_CLASS_SPEECH, OSMO_GSM631_SID_CLASS_VALID, and sid_code_word_bits.

Referenced by fr_ecu_input(), osmo_fr_is_any_sid(), and osmo_fr_sid_preen().

## osmo_fr_sid_preen()

bool osmo_fr_sid_preen | ( | uint8_t * | rtp_payload | ) |

Preen potentially-SID FR codec frame in RTP format, ensuring that it is either a speech frame or a valid SID, and if the latter, making it a perfect, error-free SID frame.

Parameters

  [in] | rtp_payload | Buffer with RTP payload - must be writable!

Returns
  true if the frame is good, false otherwise

References osmo_fr_sid_classify(), osmo_fr_sid_reset(), OSMO_GSM631_SID_CLASS_INVALID, OSMO_GSM631_SID_CLASS_SPEECH, and OSMO_GSM631_SID_CLASS_VALID.

## osmo_fr_sid_reset()

void osmo_fr_sid_reset | ( | uint8_t * | rtp_payload | ) |

Reset the SID field and the unused bits of a potentially corrupted, but still valid GSM-FR SID frame in RTP encoding to their pristine state.

Parameters

  [in] | rtp_payload | Buffer with RTP payload - must be writable!

Per GSM 06.12 section 5.2, a freshly minted SID frame carries 60 bits of comfort noise parameters (LARc and 4 times Xmaxc), while the remaining 200 bits are all zeros; the latter 200 all-0 bits further break down into 95 bits of SID field (checked by receivers to detect SID) and 105 unused bits which receivers are told to ignore. Network elements that receive SID frames from call leg A uplink and need to retransmit them on leg B downlink should "rejuvenate" received SID frames prior to retransmission; this function does the job.

Referenced by osmo_fr_sid_preen().

## Variable Documentation

## gsm610_bitorder

const uint16_t gsm610_bitorder[260]

## osmo_gsm611_silence_frame

const uint8_t osmo_gsm611_silence_frame[GSM_FR_BYTES]

Initial value:
= {
0xDA, 0xA7, 0xAA, 0xA5, 0x1A,
0x50, 0x20, 0x38, 0xE4, 0x6D, 0xB9, 0x1B,
0x50, 0x20, 0x38, 0xE4, 0x6D, 0xB9, 0x1B,
0x50, 0x20, 0x38, 0xE4, 0x6D, 0xB9, 0x1B,
0x50, 0x20, 0x38, 0xE4, 0x6D, 0xB9, 0x1B,
}

Referenced by fr_ecu_output().

## sid_code_word_bits

const uint16_t sid_code_word_bits[95]

static

Initial value:
= {
57, 58, 60, 61, 63, 64, 66, 67, 69, 70, 72, 73,
75, 76, 78, 79, 81, 82, 84, 85, 87, 88, 90, 91,
93, 94, 113, 114, 116, 117, 119, 120, 122, 123,
125, 126, 128, 129, 131, 132, 134, 135, 137,
138, 140, 141, 143, 144, 146, 147, 149, 150,
169, 170, 172, 173, 175, 176, 178, 179, 181,
182, 184, 185, 187, 188, 190, 191, 193, 194,
196, 197, 199, 200, 202, 203, 205, 206, 225,
226, 228, 229, 231, 232, 234, 235, 237, 240,
243, 246, 249, 252, 255, 258, 261
}

Referenced by osmo_efr_check_sid(), osmo_efr_sid_classify(), osmo_fr_check_sid(), and osmo_fr_sid_classify().