aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2019-02-27 12:17:02 +0100
committerPhilipp Maier <pmaier@sysmocom.de>2019-03-01 09:12:20 +0100
commit0fe9b3664a8d0b74d5e1c67593b350d67de3f98f (patch)
treefcffd779321005375fcd1139e0a53f6445ad8d45
parent05db1909c8c299a58538b664d60c2ce2b0993cbe (diff)
AMR: add define constants for AMR payload length
AMR uses different payload sizes, those sizes are well defined in RFC 3267. Lets add define constants and replace the magic values with the define constants. Also correct the value for AMR_FT_SID in amr_ft_to_bytes from 6 to 5 (39bits / 8 = 4.875 bytes ==> 5 byte, see also RFC 3267, chapter 3.6) Change-Id: I65b5da920d58015b875d6dcf17aacdc04b58955e
-rw-r--r--include/osmocom/netif/amr.h12
-rw-r--r--src/amr.c18
2 files changed, 21 insertions, 9 deletions
diff --git a/include/osmocom/netif/amr.h b/include/osmocom/netif/amr.h
index 5b48bcb..1f048b1 100644
--- a/include/osmocom/netif/amr.h
+++ b/include/osmocom/netif/amr.h
@@ -83,6 +83,18 @@ static inline void *osmo_amr_get_payload(struct amr_hdr *amrh)
#define AMR_FT_SID 8 /* SID */
#define AMR_FT_MAX 9
+/* AMR voice frame length (in bytes, rounded),
+ * See also RFC 3267, chapter 3.6 */
+#define AMR_FT_0_LEN 12 /* 4.75 */
+#define AMR_FT_1_LEN 13 /* 5.15 */
+#define AMR_FT_2_LEN 15 /* 5.90 */
+#define AMR_FT_3_LEN 17 /* 6.70 */
+#define AMR_FT_4_LEN 19 /* 7.40 */
+#define AMR_FT_5_LEN 20 /* 7.95 */
+#define AMR_FT_6_LEN 26 /* 10.2 */
+#define AMR_FT_7_LEN 31 /* 12.2 */
+#define AMR_FT_SID_LEN 5 /* SID */
+
int osmo_amr_ft_valid(uint8_t amr_ft);
size_t osmo_amr_bytes(uint8_t amr_cmr);
diff --git a/src/amr.c b/src/amr.c
index 6f94a69..06cf429 100644
--- a/src/amr.c
+++ b/src/amr.c
@@ -28,15 +28,15 @@
*/
static size_t amr_ft_to_bytes[AMR_FT_MAX] = {
- [AMR_FT_0] = 12,
- [AMR_FT_1] = 13,
- [AMR_FT_2] = 15,
- [AMR_FT_3] = 17,
- [AMR_FT_4] = 19,
- [AMR_FT_5] = 20,
- [AMR_FT_6] = 26,
- [AMR_FT_7] = 31,
- [AMR_FT_SID] = 6,
+ [AMR_FT_0] = AMR_FT_0_LEN,
+ [AMR_FT_1] = AMR_FT_1_LEN,
+ [AMR_FT_2] = AMR_FT_2_LEN,
+ [AMR_FT_3] = AMR_FT_3_LEN,
+ [AMR_FT_4] = AMR_FT_4_LEN,
+ [AMR_FT_5] = AMR_FT_5_LEN,
+ [AMR_FT_6] = AMR_FT_6_LEN,
+ [AMR_FT_7] = AMR_FT_7_LEN,
+ [AMR_FT_SID] = AMR_FT_SID_LEN,
};
size_t osmo_amr_bytes(uint8_t amr_ft)