Loading...
Searching...
No Matches
codec.h
Go to the documentation of this file.
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/bits.h>
/* TS 101318 Chapter 5.1: 260 bits + 4bit sig */
#define GSM_FR_BYTES 33
/* TS 101318 Chapter 5.2: 112 bits, no sig */
#define GSM_HR_BYTES 14
/* TS 101318 Chapter 5.3: 244 bits + 4bit sig */
#define GSM_EFR_BYTES 31
extern const uint16_t gsm610_bitorder[]; /* FR */
extern const uint16_t gsm620_unvoiced_bitorder[]; /* HR unvoiced */
extern const uint16_t gsm620_voiced_bitorder[]; /* HR voiced */
extern const uint16_t gsm660_bitorder[]; /* EFR */
extern const uint16_t gsm690_12_2_bitorder[]; /* AMR 12.2 kbits */
extern const uint16_t gsm690_10_2_bitorder[]; /* AMR 10.2 kbits */
extern const uint16_t gsm690_7_95_bitorder[]; /* AMR 7.95 kbits */
extern const uint16_t gsm690_7_4_bitorder[]; /* AMR 7.4 kbits */
extern const uint16_t gsm690_6_7_bitorder[]; /* AMR 6.7 kbits */
extern const uint16_t gsm690_5_9_bitorder[]; /* AMR 5.9 kbits */
extern const uint16_t gsm690_5_15_bitorder[]; /* AMR 5.15 kbits */
extern const uint16_t gsm690_4_75_bitorder[]; /* AMR 4.75 kbits */
extern const struct value_string osmo_amr_type_names[];
enum osmo_amr_type {
AMR_4_75 = 0,
AMR_5_15 = 1,
AMR_5_90 = 2,
AMR_6_70 = 3,
AMR_7_40 = 4,
AMR_7_95 = 5,
AMR_10_2 = 6,
AMR_12_2 = 7,
AMR_SID = 8,
AMR_GSM_EFR_SID = 9,
AMR_TDMA_EFR_SID = 10,
AMR_PDC_EFR_SID = 11,
AMR_NO_DATA = 15,
};
static inline const char *osmo_amr_type_name(enum osmo_amr_type type)
{ return get_value_string(osmo_amr_type_names, type); }
enum osmo_amr_quality {
AMR_BAD = 0,
AMR_GOOD = 1
};
extern const uint8_t gsm690_bitlength[AMR_NO_DATA+1];
int osmo_amr_s_to_d(ubit_t *out, const ubit_t *in, uint16_t n_bits, enum osmo_amr_type amr_mode);
int osmo_amr_d_to_s(ubit_t *out, const ubit_t *in, uint16_t n_bits, enum osmo_amr_type amr_mode);
static inline bool osmo_amr_is_speech(enum osmo_amr_type ft)
{
switch (ft) {
case AMR_4_75:
case AMR_5_15:
case AMR_5_90:
case AMR_6_70:
case AMR_7_40:
case AMR_7_95:
case AMR_10_2:
case AMR_12_2:
return true;
default:
return false;
}
}
bool osmo_fr_check_sid(const uint8_t *rtp_payload, size_t payload_len);
bool osmo_hr_check_sid(const uint8_t *rtp_payload, size_t payload_len);
int osmo_amr_rtp_enc(uint8_t *payload, uint8_t cmr, enum osmo_amr_type ft,
enum osmo_amr_quality bfi);
int osmo_amr_rtp_dec(const uint8_t *payload, int payload_len, uint8_t *cmr,
int8_t *cmi, enum osmo_amr_type *ft,
enum osmo_amr_quality *bfi, int8_t *sti);
bits.h
gsm690_10_2_bitorder
const uint16_t gsm690_10_2_bitorder[]
Definition gsm690.c:73
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.
Definition gsm610.c:305
gsm690_bitlength
const uint8_t gsm690_bitlength[AMR_NO_DATA+1]
These constants refer to the length of one "AMR core frame" as per TS 26.101 Section 4....
Definition gsm690.c:219
gsm690_7_4_bitorder
const uint16_t gsm690_7_4_bitorder[]
Definition gsm690.c:124
gsm690_5_9_bitorder
const uint16_t gsm690_5_9_bitorder[]
Definition gsm690.c:167
gsm690_4_75_bitorder
const uint16_t gsm690_4_75_bitorder[]
Definition gsm690.c:204
gsm690_5_15_bitorder
const uint16_t gsm690_5_15_bitorder[]
Definition gsm690.c:186
osmo_amr_type_name
static const char * osmo_amr_type_name(enum osmo_amr_type type)
Definition codec.h:50
osmo_amr_d_to_s
int osmo_amr_d_to_s(ubit_t *out, const ubit_t *in, uint16_t n_bits, enum osmo_amr_type amr_mode)
Convert from d-bits to s-bits (codec input).
Definition gsm690.c:304
osmo_amr_rtp_enc
int osmo_amr_rtp_enc(uint8_t *payload, uint8_t cmr, enum osmo_amr_type ft, enum osmo_amr_quality bfi)
Encode various AMR parameters from RTP payload (RFC 4867)
Definition gsm690.c:408
osmo_amr_type
osmo_amr_type
Definition codec.h:34
AMR_NO_DATA
@ AMR_NO_DATA
Definition codec.h:47
AMR_4_75
@ AMR_4_75
Definition codec.h:35
AMR_12_2
@ AMR_12_2
Definition codec.h:42
AMR_7_40
@ AMR_7_40
Definition codec.h:39
AMR_10_2
@ AMR_10_2
Definition codec.h:41
AMR_6_70
@ AMR_6_70
Definition codec.h:38
AMR_GSM_EFR_SID
@ AMR_GSM_EFR_SID
Definition codec.h:44
AMR_PDC_EFR_SID
@ AMR_PDC_EFR_SID
Definition codec.h:46
AMR_SID
@ AMR_SID
Definition codec.h:43
AMR_5_90
@ AMR_5_90
Definition codec.h:37
AMR_5_15
@ AMR_5_15
Definition codec.h:36
AMR_7_95
@ AMR_7_95
Definition codec.h:40
AMR_TDMA_EFR_SID
@ AMR_TDMA_EFR_SID
Definition codec.h:45
osmo_amr_is_speech
static bool osmo_amr_is_speech(enum osmo_amr_type ft)
Check if given AMR Frame Type is a speech frame.
Definition codec.h:67
osmo_amr_rtp_dec
int osmo_amr_rtp_dec(const uint8_t *payload, int payload_len, uint8_t *cmr, int8_t *cmi, enum osmo_amr_type *ft, enum osmo_amr_quality *bfi, int8_t *sti)
Decode various AMR parameters from RTP payload (RFC 4867) acording to 3GPP TS 26.101.
Definition gsm690.c:360
osmo_amr_type_names
const struct value_string osmo_amr_type_names[]
Definition gsm690.c:330
gsm690_7_95_bitorder
const uint16_t gsm690_7_95_bitorder[]
Definition gsm690.c:101
osmo_amr_s_to_d
int osmo_amr_s_to_d(ubit_t *out, const ubit_t *in, uint16_t n_bits, enum osmo_amr_type amr_mode)
Convert from S-bits (codec output) to d-bits.
Definition gsm690.c:278
gsm620_unvoiced_bitorder
const uint16_t gsm620_unvoiced_bitorder[]
Definition gsm620.c:33
gsm610_bitorder
const uint16_t gsm610_bitorder[]
Definition gsm610.c:36
gsm690_12_2_bitorder
const uint16_t gsm690_12_2_bitorder[]
Definition gsm690.c:41
gsm690_6_7_bitorder
const uint16_t gsm690_6_7_bitorder[]
Definition gsm690.c:146
osmo_amr_quality
osmo_amr_quality
Definition codec.h:53
AMR_BAD
@ AMR_BAD
Definition codec.h:54
AMR_GOOD
@ AMR_GOOD
Definition codec.h:55
osmo_hr_check_sid
bool osmo_hr_check_sid(const uint8_t *rtp_payload, size_t payload_len)
Check whether RTP frame contains HR SID code word according to TS 101 318 §5.2.2.
Definition gsm620.c:273
gsm620_voiced_bitorder
const uint16_t gsm620_voiced_bitorder[]
Definition gsm620.c:152
gsm660_bitorder
const uint16_t gsm660_bitorder[]
Definition gsm660.c:34
ubit_t
uint8_t ubit_t
get_value_string
const char * get_value_string(const struct value_string *vs, uint32_t val)
type
uint8_t type
value_string
utils.h