|
libosmocodec 1.11.0.52-28973f
Osmocom codec library
|
GSM 06.90 - GSM AMR Codec. More...
#include <stdint.h>#include <errno.h>#include <stdio.h>#include <stdlib.h>#include <osmocom/core/utils.h>#include <osmocom/core/bits.h>#include <osmocom/codec/codec.h>Data Structures | |
| struct | ts26101_reorder_table |
Functions | |
| 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. More... | |
| 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). More... | |
| int | osmo_amr_param_to_sbits (ubit_t *s_bits, const uint16_t *param, enum osmo_amr_type mode) |
| Convert AMR codec frame from parameters to s-bits. More... | |
| int | osmo_amr_sbits_to_param (uint16_t *param, const ubit_t *s_bits, enum osmo_amr_type mode) |
| Convert AMR codec frame from s-bits to parameters. More... | |
| int | osmo_amr_rtp_dec (const uint8_t *rtppayload, 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. More... | |
| 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) More... | |
Variables | |
| const uint16_t | gsm690_12_2_bitorder [244] |
| const uint16_t | gsm690_10_2_bitorder [204] |
| const uint16_t | gsm690_7_95_bitorder [159] |
| const uint16_t | gsm690_7_4_bitorder [148] |
| const uint16_t | gsm690_6_7_bitorder [134] |
| const uint16_t | gsm690_5_9_bitorder [118] |
| const uint16_t | gsm690_5_15_bitorder [103] |
| const uint16_t | gsm690_4_75_bitorder [95] |
| 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.2.2 / Table 2. More... | |
| static const struct ts26101_reorder_table | ts26101_reorder_tables [8] |
| const uint8_t | osmo_amr_sbits_per_mode [AMR_NO_DATA+1] |
| This table provides the number of s-bits (as defined in TS 26.090 and TS 26.092, clause 7 in each spec) for every possible speech or SID mode in AMR. More... | |
| const uint8_t | osmo_amr_params_per_mode [AMR_NO_DATA+1] |
| This table provides the number of distinct codec parameters (groupings of s-bits into 16-bit parameter words as implemented in 3GPP reference C code and assumed in TS 26.073 definition of decoder homing frames) that exist for every possible speech or SID mode in AMR. More... | |
| static const uint8_t | bit_counts_4_75 [17] |
| static const uint8_t | bit_counts_5_15 [19] |
| static const uint8_t | bit_counts_5_90 [19] |
| static const uint8_t | bit_counts_6_70 [19] |
| static const uint8_t | bit_counts_7_40 [19] |
| static const uint8_t | bit_counts_7_95 [23] |
| static const uint8_t | bit_counts_10_2 [39] |
| static const uint8_t | bit_counts_12_2 [57] |
| static const uint8_t | bit_counts_sid [5] = { 3, 8, 9, 9, 6 } |
| static const uint8_t *const | bit_counts_per_mode [AMR_SID+1] |
| const uint16_t | osmo_amr_dhf_4_75 [17] |
| const uint16_t | osmo_amr_dhf_5_15 [19] |
| const uint16_t | osmo_amr_dhf_5_90 [19] |
| const uint16_t | osmo_amr_dhf_6_70 [19] |
| const uint16_t | osmo_amr_dhf_7_40 [19] |
| const uint16_t | osmo_amr_dhf_7_95 [23] |
| const uint16_t | osmo_amr_dhf_10_2 [39] |
| const uint16_t | osmo_amr_dhf_12_2 [57] |
| static const uint8_t | amr_len_by_ft [16] |
| const struct value_string | osmo_amr_type_names [] |
GSM 06.90 - GSM AMR Codec.
| 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).
| [out] | out | user-provided output buffer for generated unpacked s-bits |
| [in] | in | input buffer for unpacked d-bits |
| [in] | n_bits | number of bits (in both in and out) |
| [in] | AMR | mode (0..7) |
References ARRAY_SIZE, ts26101_reorder_table::len, n, ts26101_reorder_table::s_to_d, and ts26101_reorder_tables.
| int osmo_amr_param_to_sbits | ( | ubit_t * | s_bits, |
| const uint16_t * | param, | ||
| enum osmo_amr_type | mode | ||
| ) |
Convert AMR codec frame from parameters to s-bits.
| [out] | s_bits | Caller-provided array of unpacked bits to be filled with s-bits of the converted codec frame. |
| [in] | param | Array of AMR codec speech or SID parameters. |
| [in] | mode | Speech or SID mode according to which conversion shall be performed. |
References AMR_SID, bit_counts_per_mode, mode, n, and osmo_amr_params_per_mode.
| int osmo_amr_rtp_dec | ( | const uint8_t * | rtppayload, |
| 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.
| [in] | rtppayload | Payload from RTP packet |
| [in] | payload_len | length of rtppayload |
| [out] | cmr | AMR Codec Mode Request, not filled if NULL |
| [out] | cmi | AMR Codec Mode Indicator, -1 if not applicable for this type, not filled if NULL |
| [out] | ft | AMR Frame Type, not filled if NULL |
| [out] | bfi | AMR Bad Frame Indicator, not filled if NULL |
| [out] | sti | AMR SID Type Indicator, -1 if not applicable for this type, not filled if NULL |
References amr_len_by_ft, AMR_SID, ENOTSUP, and type.
| 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)
| [out] | payload | Payload for RTP packet, contains speech data (if any) except for have 2 first bytes where header will be built |
| [in] | cmr | AMR codec Mode Request |
| [in] | ft | AMR Frame Type |
| [in] | bfi | AMR Bad Frame Indicator |
Note: only octet-aligned mode is supported so the header occupies 2 full bytes. Optional interleaving header is not supported.
References amr_len_by_ft, and ENOTSUP.
| 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.
| [out] | out | user-provided output buffer for generated unpacked d-bits |
| [in] | in | input buffer for unpacked s-bits |
| [in] | n_bits | number of bits (in both in and out) |
| [in] | AMR | mode (0..7) |
References ARRAY_SIZE, ts26101_reorder_table::len, n, ts26101_reorder_table::s_to_d, and ts26101_reorder_tables.
| int osmo_amr_sbits_to_param | ( | uint16_t * | param, |
| const ubit_t * | s_bits, | ||
| enum osmo_amr_type | mode | ||
| ) |
Convert AMR codec frame from s-bits to parameters.
| [out] | param | Caller-provided buffer for array of AMR codec speech or SID parameters. |
| [in] | s_bits | Unpacked s-bits of the frame to be converted. |
| [in] | mode | Speech or SID mode according to which conversion shall be performed. |
References AMR_SID, bit_counts_per_mode, mode, n, and osmo_amr_params_per_mode.
|
static |
Referenced by osmo_amr_rtp_dec(), and osmo_amr_rtp_enc().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Referenced by osmo_amr_param_to_sbits(), and osmo_amr_sbits_to_param().
|
static |
| const uint16_t gsm690_10_2_bitorder[204] |
| const uint16_t gsm690_12_2_bitorder[244] |
| const uint16_t gsm690_4_75_bitorder[95] |
| const uint16_t gsm690_5_15_bitorder[103] |
| const uint16_t gsm690_5_9_bitorder[118] |
| const uint16_t gsm690_6_7_bitorder[134] |
| const uint16_t gsm690_7_4_bitorder[148] |
| const uint16_t gsm690_7_95_bitorder[159] |
| const uint8_t gsm690_bitlength[AMR_NO_DATA+1] |
| const uint16_t osmo_amr_dhf_10_2[39] |
| const uint16_t osmo_amr_dhf_12_2[57] |
| const uint16_t osmo_amr_dhf_4_75[17] |
| const uint16_t osmo_amr_dhf_5_15[19] |
| const uint16_t osmo_amr_dhf_5_90[19] |
| const uint16_t osmo_amr_dhf_6_70[19] |
| const uint16_t osmo_amr_dhf_7_40[19] |
| const uint16_t osmo_amr_dhf_7_95[23] |
| const uint8_t osmo_amr_params_per_mode[AMR_NO_DATA+1] |
This table provides the number of distinct codec parameters (groupings of s-bits into 16-bit parameter words as implemented in 3GPP reference C code and assumed in TS 26.073 definition of decoder homing frames) that exist for every possible speech or SID mode in AMR.
The array is allocated up to AMR_NO_DATA in order to reduce the probability of buggy code making an out-of-bounds read access.
Referenced by osmo_amr_param_to_sbits(), and osmo_amr_sbits_to_param().
| const uint8_t osmo_amr_sbits_per_mode[AMR_NO_DATA+1] |
This table provides the number of s-bits (as defined in TS 26.090 and TS 26.092, clause 7 in each spec) for every possible speech or SID mode in AMR.
It differs from gsm690_bitlength[] in the case of SID: there are 35 s-bits in the original 2G definition that started out as GSM 06.92, captured in this table, whereas 3G-oriented TS 26.101 AMR Core Frame definition captured in gsm690_bitlength[] has 39 d-bits for SID instead.
The array is allocated up to AMR_NO_DATA in order to reduce the probability of buggy code making an out-of-bounds read access.
| const struct value_string osmo_amr_type_names[] |
Referenced by osmo_amr_type_name().
|
static |
Referenced by osmo_amr_d_to_s(), and osmo_amr_s_to_d().