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
This commit is contained in:
Neels Hofmeyr 2024-01-19 05:51:18 +01:00
parent 3083b970b3
commit 64475fc6d8
2 changed files with 16 additions and 0 deletions

View File

@ -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);

View File

@ -136,6 +136,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) \
@ -158,6 +162,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: