[PATCH] libosmocore[master]: gsm_08_08: correct speech codec defaults

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/.

dexter gerrit-no-reply at lists.osmocom.org
Fri Mar 23 10:39:45 UTC 2018


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/7458

to look at the new patch set (#2).

gsm_08_08: correct speech codec defaults

The speech codec defaults are not correct. The defaults recommended
in 3GPP TS 28.062, Table 7.11.3.1.3-2 are limited by 3GPP TS 48.008,
Section 3.2.2.103. Some defaults are actually reserved for future
use. Also the endianess of the 16 bit values is reversed.

- correct values so that they match the specification
- transmit bytes in the correct endianess

Change-Id: I6c3a34d39a375d71c4128fd38f06629e8b98b100
---
M include/osmocom/gsm/protocol/gsm_08_08.h
M src/gsm/gsm0808_utils.c
M tests/gsm0808/gsm0808_test.c
3 files changed, 13 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/58/7458/2

diff --git a/include/osmocom/gsm/protocol/gsm_08_08.h b/include/osmocom/gsm/protocol/gsm_08_08.h
index 947f90f..4539b96 100644
--- a/include/osmocom/gsm/protocol/gsm_08_08.h
+++ b/include/osmocom/gsm/protocol/gsm_08_08.h
@@ -460,16 +460,16 @@
  *  configuration that is used on the air interface (Um).
  *
  *  Default values for FR_AMR, HR_AMR and OHR_AMR:
- *  See also: 3GPP TS 28.062, Table 7.11.3.1.3-2: Preferred
- *  Configurations for the Adaptive Multi-Rate Codec Types
+ *  See also: 3GPP TS 28.062, Table 7.11.3.1.3-2: Preferred Configurations for
+ *  the Adaptive Multi-Rate Codec Types and 3GPP TS 48.008, Section 3.2.2.103.
  *
  *  Default values for FR_AMR_WB, OFR_AMR_WB and OHR_AMR_WB:
  *  See also: 3GPP TS 26.103, Table 5.7-1: Allowed Configurations
  *  for the Adaptive Multi-Rate - Wideband Codec Types */
 enum gsm0808_speech_codec_defaults {
-	GSM0808_SC_CFG_DEFAULT_FR_AMR		= 0xffff,
+	GSM0808_SC_CFG_DEFAULT_FR_AMR		= 0x57ff,
 	GSM0808_SC_CFG_DEFAULT_HR_AMR		= 0x073f,
-	GSM0808_SC_CFG_DEFAULT_OHR_AMR		= 0xffff,
+	GSM0808_SC_CFG_DEFAULT_OHR_AMR		= 0x57ff,
 	GSM0808_SC_CFG_DEFAULT_FR_AMR_WB	= 0x01,
 	GSM0808_SC_CFG_DEFAULT_OFR_AMR_WB	= 0x3f,
 	GSM0808_SC_CFG_DEFAULT_OHR_AMR_WB	= 0x01,
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index b58a4b8..776f091 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -210,7 +210,7 @@
 	case GSM0808_SCT_FR3:
 	case GSM0808_SCT_HR3:
 	case GSM0808_SCT_HR6:
-		msgb_put_u16(msg, sc->cfg);
+		msgb_put_u16(msg, osmo_ntohs(sc->cfg));
 		break;
 	case GSM0808_SCT_FR4:
 	case GSM0808_SCT_FR5:
@@ -320,7 +320,7 @@
 	case GSM0808_SCT_HR6:
 		if (len < 2)
 			return -EINVAL;
-		sc->cfg = osmo_load16be(elem);
+		sc->cfg = osmo_load16le(elem);
 		elem += 2;
 		break;
 	default:
diff --git a/tests/gsm0808/gsm0808_test.c b/tests/gsm0808/gsm0808_test.c
index 4bd81b4..c3c86dc 100644
--- a/tests/gsm0808/gsm0808_test.c
+++ b/tests/gsm0808/gsm0808_test.c
@@ -88,7 +88,7 @@
 		0x00, 0x17, 0x57, 0x05, 0x08, 0x00, 0x77, 0x62,
 		0x83, 0x33, 0x66, 0x44, 0x88, 0x17, 0x01, 0x23,
 		GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50,
-		0xcd, 0xef, GSM0808_SCT_FR2 | 0xa0, 0x9f,
+		0xef, 0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f,
 		GSM0808_SCT_CSD | 0x90, 0xc0
 	};
 
@@ -284,7 +284,7 @@
 	    { 0x00, 0x20, 0x01, 0x0b, 0x04, 0x01, 0x0b, 0xa1, 0x25, 0x01, 0x00,
 	      0x04, GSM0808_IE_AOIP_TRASP_ADDR, 0x06, 0xc0, 0xa8, 0x64, 0x17,
 	      0x04, 0xd2, GSM0808_IE_SPEECH_CODEC_LIST, 0x07,
-	      GSM0808_SCT_FR3 | 0x50, 0xcd, 0xef, GSM0808_SCT_FR2 | 0xa0, 0x9f,
+	      GSM0808_SCT_FR3 | 0x50, 0xef, 0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f,
 	      GSM0808_SCT_CSD | 0x90, 0xc0, GSM0808_IE_CALL_ID, 0xaa, 0xbb,
 	      0xcc, 0xdd };
 
@@ -354,8 +354,8 @@
 	    { 0x00, 0x1d, 0x02, 0x15, 0x23, 0x21, 0x42, 0x2c, 0x11, 0x40, 0x22,
 	      GSM0808_IE_AOIP_TRASP_ADDR, 0x06, 0xc0, 0xa8, 0x64, 0x17, 0x04,
 	      0xd2, GSM0808_IE_SPEECH_CODEC, 0x01, GSM0808_SCT_HR1 | 0x90,
-	      GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50, 0xcd,
-	      0xef, GSM0808_SCT_FR2 | 0xa0, 0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 };
+	      GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50, 0xef,
+	      0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 };
 	struct msgb *msg;
 
 	memset(&sin, 0, sizeof(sin));
@@ -402,12 +402,12 @@
 {
 	static const uint8_t res1[] =
 	    { 0x00, 0x0d, 0x03, 0x04, 0x01, 0x23, GSM0808_IE_SPEECH_CODEC_LIST,
-	      0x07, GSM0808_SCT_FR3 | 0x50, 0xcd, 0xef, GSM0808_SCT_FR2 | 0xa0,
+	      0x07, GSM0808_SCT_FR3 | 0x50, 0xef, 0xcd, GSM0808_SCT_FR2 | 0xa0,
 	      0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 };
 	static const uint8_t res2[] =
 	    { 0x00, 0x0f, 0x03, 0x04, 0x01, 0x23, 0x15, 0x02,
-	      GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50, 0xcd,
-	      0xef, GSM0808_SCT_FR2 | 0xa0, 0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 };
+	      GSM0808_IE_SPEECH_CODEC_LIST, 0x07, GSM0808_SCT_FR3 | 0x50, 0xef,
+	      0xcd, GSM0808_SCT_FR2 | 0xa0, 0x9f, GSM0808_SCT_CSD | 0x90, 0xc0 };
 	uint8_t rr_res = 2;
 	struct msgb *msg;
 	struct gsm0808_speech_codec_list sc_list;

-- 
To view, visit https://gerrit.osmocom.org/7458
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I6c3a34d39a375d71c4128fd38f06629e8b98b100
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list