laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/26787 ) Change subject: amr: Fix FormatType from parsing BWE AMR header ...................................................................... amr: Fix FormatType from parsing BWE AMR header The proper order is CMR(4)+F(1)+FT(4)+Q(1). Hence, FT is 3 least significant bits of first byte and 1 most significant bit of secont byte. Change-Id: I66f39d3b9a608f07c202e7a5084a8537e9978a94 --- M src/amr.c M tests/amr/amr_test.c 2 files changed, 3 insertions(+), 2 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/src/amr.c b/src/amr.c index 1cb2ccc..2df6967 100644 --- a/src/amr.c +++ b/src/amr.c @@ -236,7 +236,7 @@ return -1; /* Calculate new payload length */ - ft = (payload[0] & 0xf0) >> 4; + ft = ((payload[0] & 0x07) << 1) | ((payload[1] & 0x80) >> 7); if (!osmo_amr_ft_valid(ft)) return -1; diff --git a/tests/amr/amr_test.c b/tests/amr/amr_test.c index fc579e9..802fbee 100644 --- a/tests/amr/amr_test.c +++ b/tests/amr/amr_test.c @@ -230,7 +230,8 @@ OSMO_ASSERT(rc == len + 2); printf(" BE: %d bytes (%s),", rc, osmo_hexdump(buf, rc)); - buf[0] = (ft << 4) & 0xf0; + buf[0] = (ft >> 1) & 0x07; + buf[1] = ((ft & 0x01) << 7) | (buf[1] & 0x3f); rc = osmo_amr_bwe_to_iuup(buf, rc); printf(" IuUP: %d bytes\n", rc); OSMO_ASSERT(rc > 0); -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/26787 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: I66f39d3b9a608f07c202e7a5084a8537e9978a94 Gerrit-Change-Number: 26787 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge@osmocom.org> Gerrit-Reviewer: lynxis lazus <lynxis@fe80.eu> Gerrit-MessageType: merged