aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom
diff options
context:
space:
mode:
authorMychaela N. Falconia <falcon@freecalypso.org>2023-04-16 01:34:35 +0000
committerMychaela N. Falconia <falcon@freecalypso.org>2023-04-16 01:34:35 +0000
commitec65085d5f13e57ed486a31efc242ca9cd1b44c0 (patch)
tree69e659f50de0e92c84147fbc25a69707b525ab6e /include/osmocom
parent91f5eee672a4779b47b531d5b748ecce696514cf (diff)
codec: add SID classification functions per GSM 06.31 & 06.81
The existing osmo_{fr,efr}_check_sid() functions detect whether or not the frame of bits passed to them constitutes an absolutely perfect SID frame, with each of 95 SID code word bits set to 0 for FR or 1 for EFR. However, the rules of section 6.1.1 in GSM 06.31 & 06.81 allow up to one bit to be in error for the frame to be accepted as valid SID, and the same rules also call out a third state (invalid SID) in between valid SID frames and other frames that are classified as speech. Support for these rules cannot be patched into those familiar osmo_{fr,efr}_check_sid() functions because doing so would alter behavior of existing programs, hence new functions need to be added. The new functions that implement the exact rules of section 6.1.1 of GSM 06.31 and 06.81 will need to be used if anyone needs to construct an outgoing TRAU-UL frame (for example, as part of implementing TS 28.062 TFO), and they are expected to be useful as part of more sophisticated ECU implementations. Change-Id: Ie91a52c6f04689082d8004311517d8ce0c544916
Diffstat (limited to 'include/osmocom')
-rw-r--r--include/osmocom/codec/codec.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/osmocom/codec/codec.h b/include/osmocom/codec/codec.h
index 65de20da..2bdae606 100644
--- a/include/osmocom/codec/codec.h
+++ b/include/osmocom/codec/codec.h
@@ -81,9 +81,20 @@ static inline bool osmo_amr_is_speech(enum osmo_amr_type ft)
}
}
+/* SID ternary classification per GSM 06.31 & 06.81 section 6.1.1 */
+enum osmo_gsm631_sid_class {
+ OSMO_GSM631_SID_CLASS_SPEECH = 0,
+ OSMO_GSM631_SID_CLASS_INVALID = 1,
+ OSMO_GSM631_SID_CLASS_VALID = 2,
+};
+
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);
bool osmo_efr_check_sid(const uint8_t *rtp_payload, size_t payload_len);
+
+enum osmo_gsm631_sid_class osmo_fr_sid_classify(const uint8_t *rtp_payload);
+enum osmo_gsm631_sid_class osmo_efr_sid_classify(const uint8_t *rtp_payload);
+
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,