aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom
diff options
context:
space:
mode:
authorneels <nhofmeyr@sysmocom.de>2020-05-14 23:22:54 +0000
committerneels <nhofmeyr@sysmocom.de>2020-05-14 23:22:54 +0000
commit8b77ad940a68e98f789d810bc30bdc2c6af01cbc (patch)
tree75970c959ab43fd5ac917a531c0c28ffe69084e1 /include/osmocom
parent002a51e2180cf19bf5e11e16d78271998d0b3f5c (diff)
Revert "amr: Fix OA<->BWE conversion."
This reverts commit 002a51e2180cf19bf5e11e16d78271998d0b3f5c. Reason for revert: amr_test fails with sanitizer build: Sample No.: 6 bw-efficient: a7bfc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03fc03f 1010011110111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111 ../../../src/libosmo-netif/src/amr.c:63:24: runtime error: index 15 out of bounds for type 'size_t [9]' ../../../src/libosmo-netif/src/amr.c:63:24: runtime error: load of address 0x7f69498e56b8 with insufficient space for an object of type 'size_t' 0x7f69498e56b8: note: pointer points here 00 00 00 00 00 00 00 00 00 00 00 00 5f 00 00 00 00 00 00 00 67 00 00 00 00 00 00 00 76 00 00 00 ^ ================================================================= ==489935==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7f69498e56b8 at pc 0x7f69498abec7 bp 0x7ffeafb35330 sp 0x7ffeafb35328 READ of size 8 at 0x7f69498e56b8 thread T0 #0 0x7f69498abec6 in osmo_amr_bytes ../../../src/libosmo-netif/src/amr.c:63 #1 0x7f69498ac661 in osmo_amr_bwe_to_oa ../../../src/libosmo-netif/src/amr.c:193 #2 0x5648b11afb96 in osmo_amr_bwe_to_oa_test ../../../src/libosmo-netif/tests/amr/amr_test.c:134 #3 0x5648b11af31d in main ../../../src/libosmo-netif/tests/amr/amr_test.c:235 #4 0x7f6948d5de0a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26e0a) #5 0x5648b11af3d9 in _start (/n/s/dev/make/libosmo-netif/tests/amr/amr_test+0x43d9) 0x7f69498e56b8 is located 8 bytes to the left of global variable 'amr_ft_to_bits' defined in '../../../src/libosmo-netif/src/amr.c:32:15' (0x7f69498e56c0) of size 72 0x7f69498e56b8 is located 48 bytes to the right of global variable 'amr_ft_to_bytes' defined in '../../../src/libosmo-netif/src/amr.c:44:15' (0x7f69498e5640) of size 72 SUMMARY: AddressSanitizer: global-buffer-overflow ../../../src/libosmo-netif/src/amr.c:63 in osmo_amr_bytes Change-Id: I8232521c513722435e71dc90bdbfee10f8f83496
Diffstat (limited to 'include/osmocom')
-rw-r--r--include/osmocom/netif/amr.h38
1 files changed, 12 insertions, 26 deletions
diff --git a/include/osmocom/netif/amr.h b/include/osmocom/netif/amr.h
index c5a8e28..6e37c99 100644
--- a/include/osmocom/netif/amr.h
+++ b/include/osmocom/netif/amr.h
@@ -78,34 +78,20 @@ 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 bits).
- * See also RFC 3267, chapter 3.6.
- *
- * NOTE: These constants refer to the length of one AMR speech frame-block,
- * not counting CMR, TOC. */
-#define AMR_FT_0_LEN_BITS 95 /* 4.75 */
-#define AMR_FT_1_LEN_BITS 103 /* 5.15 */
-#define AMR_FT_2_LEN_BITS 118 /* 5.90 */
-#define AMR_FT_3_LEN_BITS 134 /* 6.70 */
-#define AMR_FT_4_LEN_BITS 148 /* 7.40 */
-#define AMR_FT_5_LEN_BITS 159 /* 7.95 */
-#define AMR_FT_6_LEN_BITS 204 /* 10.2 */
-#define AMR_FT_7_LEN_BITS 244 /* 12.2 */
-#define AMR_FT_SID_LEN_BITS 39 /* SID */
+/* 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 */
-/* AMR voice frame length (in bytes, rounded).
- *
- * NOTE: These constants refer to the length of one AMR speech frame-block,
+/* NOTE: the above constant refers to the length of one AMR speech frame-block,
* not counting CMR, TOC. */
-#define AMR_FT_0_LEN ((AMR_FT_0_LEN_BITS+7)/8) /* 4.75 */
-#define AMR_FT_1_LEN ((AMR_FT_1_LEN_BITS+7)/8) /* 5.15 */
-#define AMR_FT_2_LEN ((AMR_FT_2_LEN_BITS+7)/8) /* 5.90 */
-#define AMR_FT_3_LEN ((AMR_FT_3_LEN_BITS+7)/8) /* 6.70 */
-#define AMR_FT_4_LEN ((AMR_FT_4_LEN_BITS+7)/8) /* 7.40 */
-#define AMR_FT_5_LEN ((AMR_FT_5_LEN_BITS+7)/8) /* 7.95 */
-#define AMR_FT_6_LEN ((AMR_FT_6_LEN_BITS+7)/8) /* 10.2 */
-#define AMR_FT_7_LEN ((AMR_FT_7_LEN_BITS+7)/8) /* 12.2 */
-#define AMR_FT_SID_LEN ((AMR_FT_SID_LEN_BITS+7)/8) /* SID */
int osmo_amr_ft_valid(uint8_t amr_ft);
size_t osmo_amr_bytes(uint8_t amr_cmr);