Change in libosmo-netif[master]: AMR: add define constants for AMR payload length

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Mar 11 13:19:43 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/13078 )

Change subject: AMR: add define constants for AMR payload length
......................................................................

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
---
M include/osmocom/netif/amr.h
M src/amr.c
2 files changed, 21 insertions(+), 9 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



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

-- 
To view, visit https://gerrit.osmocom.org/13078
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I65b5da920d58015b875d6dcf17aacdc04b58955e
Gerrit-Change-Number: 13078
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190311/819d50df/attachment.htm>


More information about the gerrit-log mailing list