summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2018-09-25 15:57:49 +0200
committerHarald Welte <laforge@gnumonks.org>2018-09-25 15:32:29 +0000
commit8515d035ae09edf3ad4d6e0dcbe526eee8bce3eb (patch)
tree7d2aa142f40d85f6ae1766de11ccd04153c8a214 /src
parentb066305016141606e7f031065dc71c2002a6af0a (diff)
gsm0808: add function to convert AMR S15-S0 to gsm0408 settings
Add a function to convert S0-S15 bits to struct gsm48_multi_rate_conf, which hold the codec settings for AMR. Change-Id: I973736273c236eee84decf15868190e339c3fed4 Related: OS#3548
Diffstat (limited to 'src')
-rw-r--r--src/gsm/gsm0808_utils.c41
-rw-r--r--src/gsm/libosmogsm.map1
2 files changed, 42 insertions, 0 deletions
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 0d6938ef..886f546a 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -1204,6 +1204,47 @@ uint16_t gsm0808_sc_cfg_from_gsm48_mr_cfg(const struct gsm48_multi_rate_conf *cf
return s15_s0;
}
+/*! Determine a GSM 04.08 AMR configuration struct from a set of speech codec
+ * configuration bits (S0-S15)
+ * \param[out] cfg AMR configuration in GSM 04.08 format.
+ * \param[in] s15_s0 configuration bits (S0-S15). */
+void gsm48_mr_cfg_from_gsm0808_sc_cfg(struct gsm48_multi_rate_conf *cfg,
+ uint16_t s15_s0)
+{
+ memset(cfg, 0, sizeof(*cfg));
+
+ /* Strip option bits */
+ s15_s0 &= 0x00ff;
+
+ /* Rate 5,15k must always be present */
+ cfg->m5_15 = 1;
+
+ if ((s15_s0 & GSM0808_SC_CFG_DEFAULT_AMR_4_75 & 0xff) ==
+ (GSM0808_SC_CFG_DEFAULT_AMR_4_75 & 0xff))
+ cfg->m4_75 = 1;
+ if ((s15_s0 & GSM0808_SC_CFG_DEFAULT_AMR_5_90 & 0xff) ==
+ (GSM0808_SC_CFG_DEFAULT_AMR_5_90 & 0xff))
+ cfg->m5_90 = 1;
+ if ((s15_s0 & GSM0808_SC_CFG_DEFAULT_AMR_6_70 & 0xff) ==
+ (GSM0808_SC_CFG_DEFAULT_AMR_6_70 & 0xff))
+ cfg->m6_70 = 1;
+ if ((s15_s0 & GSM0808_SC_CFG_DEFAULT_AMR_7_40 & 0xff) ==
+ (GSM0808_SC_CFG_DEFAULT_AMR_7_40 & 0xff))
+ cfg->m7_40 = 1;
+ if ((s15_s0 & GSM0808_SC_CFG_DEFAULT_AMR_7_95 & 0xff) ==
+ (GSM0808_SC_CFG_DEFAULT_AMR_7_95 & 0xff))
+ cfg->m7_95 = 1;
+ if ((s15_s0 & GSM0808_SC_CFG_DEFAULT_AMR_10_2 & 0xff) ==
+ (GSM0808_SC_CFG_DEFAULT_AMR_10_2 & 0xff))
+ cfg->m10_2 = 1;
+ if ((s15_s0 & GSM0808_SC_CFG_DEFAULT_AMR_12_2 & 0xff) ==
+ (GSM0808_SC_CFG_DEFAULT_AMR_12_2 & 0xff))
+ cfg->m12_2 = 1;
+
+ cfg->ver = 1;
+ cfg->icmi = 1;
+}
+
/*! Print a human readable name of the cell identifier to the char buffer.
* This is useful both for struct gsm0808_cell_id and struct gsm0808_cell_id_list2.
* See also gsm0808_cell_id_name() and gsm0808_cell_id_list_name().
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 3d08232c..dcc491d7 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -206,6 +206,7 @@ gsm0808_cell_id_u_name;
gsm0808_chan_type_to_speech_codec;
gsm0808_speech_codec_from_chan_type;
gsm0808_sc_cfg_from_gsm48_mr_cfg;
+gsm48_mr_cfg_from_gsm0808_sc_cfg;
gsm0808_speech_codec_type_names;
gsm0808_permitted_speech_names;
gsm0808_chosen_enc_alg_names;