tnt has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/33641 )

Change subject: gsm: Improve the TCH/H2.4 coding routines
......................................................................

gsm: Improve the TCH/H2.4 coding routines

The spec isn't super clear, but basically the conv coding is done
in two blocks of 72 bits.

The way it's currently implemented isn't "wrong" in the sense it will
produce correct output given no bit errors, but it's better to do the
decoding in two blocks because this then it makes use of the fact we
know the state of the encoder after the 72 bits, which improves the
corrective ability of the code.

Signed-off-by: Sylvain Munaut <t...@246tnt.com>
Change-Id: Id2551ffe2a0ebfd0a6df0e1d288a6f0af7e1eda7
---
M src/coding/gsm0503_coding.c
M src/gsm/libosmogsm.map
M tests/conv/conv_gsm0503_test.ok
M utils/conv_codes_gsm.py
4 files changed, 58 insertions(+), 14 deletions(-)

Approvals:
  fixeria: Looks good to me, but someone else must approve
  pespin: Looks good to me, but someone else must approve
  tnt: Looks good to me, approved; Verified




diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
index 286981e..1249ce9 100644
--- a/src/coding/gsm0503_coding.c
+++ b/src/coding/gsm0503_coding.c
@@ -3480,15 +3480,10 @@
 int gsm0503_tch_hr24_encode(ubit_t *bursts, const ubit_t *data)
 {
        ubit_t iB[22 * 114], cB[4 * 114];
-       ubit_t conv[2 * 72 + 8];

-       /* 3.7.2 Block code: d1(72) + pad(4) + d2(72) + pad(4) */
-       memset(&conv[0], 0, sizeof(conv));
-       memcpy(&conv[0], &data[0], 72);
-       memcpy(&conv[76], &data[72], 72);
-
-       /* 3.7.3 Convolutional encoder: as specified for the TCH/F4.8 in 
subclause 3.4.3 */
-       osmo_conv_encode(&gsm0503_tch_f48, &conv[0], &cB[0]);
+       /* 3.7.{1-3} Block code and Convolutional encoder */
+       osmo_conv_encode(&gsm0503_tch_h24, &data[ 0], &cB[  0]);
+       osmo_conv_encode(&gsm0503_tch_h24, &data[72], &cB[228]);

        /* 3.7.4 Interleaving: as specified for the TCH/F9.6 in subclause 3.3.4 
*/
        memset(&iB[0], 0, sizeof(iB));
@@ -3511,8 +3506,8 @@
 int gsm0503_tch_hr24_decode(ubit_t *data, const sbit_t *bursts,
                            int *n_errors, int *n_bits_total)
 {
+       int n_errors_l[2], n_bits_total_l[2];
        sbit_t iB[22 * 114], cB[4 * 114];
-       ubit_t conv[120 + 32];

        /* 3.7.5 Mapping on a burst: as specified for TCH/FS in subclause 3.1.4 
*/
        for (unsigned int i = 0; i < 22; i++) {
@@ -3523,12 +3518,15 @@
        /* 3.7.4 Interleaving: as specified for the TCH/F9.6 in subclause 3.3.4 
*/
        gsm0503_tch_f96_deinterleave(&cB[0], &iB[0]);

-       /* 3.7.3 Convolutional encoder: as specified for the TCH/F4.8 in 
subclause 3.4.3 */
-       osmo_conv_decode_ber(&gsm0503_tch_f48, &cB[0], &conv[0], n_errors, 
n_bits_total);
+       /* 3.7.{1-3} Block code and Convolutional encoder */
+       osmo_conv_decode_ber(&gsm0503_tch_h24, &cB[  0], &data[ 0], 
&n_errors_l[0], &n_bits_total_l[0]);
+       osmo_conv_decode_ber(&gsm0503_tch_h24, &cB[228], &data[72], 
&n_errors_l[1], &n_bits_total_l[1]);

-       /* 3.7.2 Block code: d1(72) + pad(4) + d2(72) + pad(4) */
-       memcpy(&data[0], &conv[0], 72);
-       memcpy(&data[72], &conv[76], 72);
+       if (n_errors)
+               *n_errors = n_errors_l[0] + n_errors_l[1];
+
+       if (n_bits_total)
+               *n_bits_total = n_bits_total_l[0] + n_bits_total_l[1];

        return 2 * 72;
 }
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 609ee7e..0dfffd3 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -123,6 +123,7 @@
 gsm0503_cs3_np;
 gsm0503_tch_fr;
 gsm0503_tch_f24;
+gsm0503_tch_h24;
 gsm0503_tch_f48;
 gsm0503_tch_f96;
 gsm0503_tch_f144;
diff --git a/tests/conv/conv_gsm0503_test.ok b/tests/conv/conv_gsm0503_test.ok
index 6fd3793..dba52bd 100644
--- a/tests/conv/conv_gsm0503_test.ok
+++ b/tests/conv/conv_gsm0503_test.ok
@@ -14,6 +14,14 @@
 [..] Encoding / Decoding cycle : OK
 [..] Encoding / Decoding cycle : OK

+[+] Testing: gsm0503_tch_h24
+[.] Input length  : ret =  72  exp =  72 -> OK
+[.] Output length : ret = 228  exp = 228 -> OK
+[.] Random vector checks:
+[..] Encoding / Decoding cycle : OK
+[..] Encoding / Decoding cycle : OK
+[..] Encoding / Decoding cycle : OK
+
 [+] Testing: gsm0503_tch_f48
 [.] Input length  : ret = 148  exp = 148 -> OK
 [.] Output length : ret = 456  exp = 456 -> OK
diff --git a/utils/conv_codes_gsm.py b/utils/conv_codes_gsm.py
index 62b5a0b..24a8ee2 100644
--- a/utils/conv_codes_gsm.py
+++ b/utils/conv_codes_gsm.py
@@ -66,6 +66,24 @@
                ]
        ),

+       # TCH/H2.4 definition
+       ConvolutionalCode(
+               72,
+               [
+                   (G1, 1),
+                   (G2, 1),
+                   (G3, 1),
+               ],
+               name = "tch_h24",
+               description = [
+                       "TCH/H2.4 convolutional code:",
+                       "72 bits blocks, rate 1/3, k = 5",
+                       "G1 = 1 + D + D3 + D4",
+                       "G2 = 1 + D2 + D4",
+                       "G3 = 1 + D + D2 + D3 + D4",
+               ]
+       ),
+
        # TCH/F4.8 definition
        ConvolutionalCode(
                148,

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id2551ffe2a0ebfd0a6df0e1d288a6f0af7e1eda7
Gerrit-Change-Number: 33641
Gerrit-PatchSet: 2
Gerrit-Owner: tnt <t...@246tnt.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>
Gerrit-Reviewer: tnt <t...@246tnt.com>
Gerrit-MessageType: merged

Reply via email to