aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2024-01-19 05:51:18 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2024-02-09 05:17:39 +0100
commitb35ce672440cd1c04afd3ad809a4317a761323a4 (patch)
treee32e87f8eea2b737b59787bff6db67a9ca083472
parentbd69253e6d84be3ad4ca33f6f02023397ec45398 (diff)
codec_mapping: add amr flags
These flags are redundant, the aim is to speed up comparisons of AMR fmtp when traversing a long list of codec variants. It can skip a lot of repetitive strcmp and fmtp string parsing when used by a loop. Change-Id: Ic2c9b4983b5374621e02389900e3622faa29cad9
-rw-r--r--include/osmocom/msc/codec_mapping.h8
-rw-r--r--src/libmsc/codec_mapping.c8
2 files changed, 16 insertions, 0 deletions
diff --git a/include/osmocom/msc/codec_mapping.h b/include/osmocom/msc/codec_mapping.h
index 84806a66a..6462fe171 100644
--- a/include/osmocom/msc/codec_mapping.h
+++ b/include/osmocom/msc/codec_mapping.h
@@ -37,6 +37,14 @@ struct codec_mapping {
/* If applicable, indicator whether this codec can work on a GERAN half-rate lchan, or whether full-rate is
* required. Leave zero when this codec does not apply to GERAN. */
enum codec_frhr frhr;
+ /* Shortcut flags for AMR: there are a lot of entries with sdp.subtype_name = "AMR". These AMR related flags
+ * duplicate the state of sdp.subtype_name and sdp.fmtp, in order to speed up some codec iterations. */
+ struct {
+ /* true iff sdp.subtype_name = "AMR". */
+ bool is_amr;
+ /* true iff is_amr and sdp.fmtp contains "octet-align=1". */
+ bool is_octet_aligned;
+ } amr;
};
const struct codec_mapping *codec_mapping_next(const struct codec_mapping *c);
diff --git a/src/libmsc/codec_mapping.c b/src/libmsc/codec_mapping.c
index e87a8f8ea..87423d8f8 100644
--- a/src/libmsc/codec_mapping.c
+++ b/src/libmsc/codec_mapping.c
@@ -135,6 +135,10 @@ static const struct codec_mapping codec_map[] = {
}, \
.perm_speech = GSM0808_PERM_FR3, \
.frhr = CODEC_FRHR_FR, \
+ .amr = { \
+ .is_amr = true, \
+ .is_octet_aligned = IS_OA, \
+ }, \
}
#define AMR_HR(IS_OA, FMTP, SPEECH_CODEC_CFG) \
@@ -157,6 +161,10 @@ static const struct codec_mapping codec_map[] = {
}, \
.perm_speech = GSM0808_PERM_HR3, \
.frhr = CODEC_FRHR_HR, \
+ .amr = { \
+ .is_amr = true, \
+ .is_octet_aligned = IS_OA, \
+ }, \
}
/* AMR rates as in 3GPP TS 28.062, Table 7.11.3.1.3-2; gsm0808_speech_codec.cfg is a bitmask of Sn bits: