From patchwork Tue Apr 29 04:13:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Tsou X-Patchwork-Id: 343663 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [213.95.27.120]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5DC4C1400AD for ; Tue, 29 Apr 2014 14:28:30 +1000 (EST) Received: from localhost ([127.0.0.1] helo=ganesha.gnumonks.org) by ganesha.gnumonks.org with esmtp (Exim 4.72) (envelope-from ) id 1WezTB-00082R-Ub; Tue, 29 Apr 2014 06:16:38 +0200 Received: from mail-qa0-f46.google.com ([209.85.216.46]) by ganesha.gnumonks.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.72) (envelope-from ) id 1WezQF-0007g8-GP for openbsc@lists.osmocom.org; Tue, 29 Apr 2014 06:13:41 +0200 Received: by mail-qa0-f46.google.com with SMTP id w8so97645qac.5 for ; Mon, 28 Apr 2014 21:13:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=H1rg5VGWPUsE8IUiaq684WZ9mNswQRCvg0n6mkqjK6I=; b=PVZS7XJ0jChbasoKYbo77K7EueYgYrRCV34qjUgTl8ZlbV39RkH5I2aQD5YsICBIBr tXbCe/izx9M5moMRuaoCX/xOzOV2MDiS9BPh0r7DhUtW0jhOVZdAZKYhyfVGSjFOSngl XYFOlBvaXH7zAYdv4/XeEKwXHDUSJon13QnClapIHQO+g4oLitwqvrkMxvYcmgmaufDW KedC4CpUFbyRWfoQRybcIApY1ADjgrV0R+cptzDYG7PIJyrAbxATi5kC8POIUP3Mu9Gd 6wPy6VISzfGucIfWmHSJJAh86HNujKZ5617lQjtT8xOifMzcvezdmAwJkyC5/XVjxZ7a CFDQ== X-Gm-Message-State: ALoCoQmCN/LBqY7eYHGluF92gFzDLjZxJ00QNW4f/9J1uz1zEIB+uFjp46YHaAn2UC/rEi6AMpr0 X-Received: by 10.224.137.1 with SMTP id u1mr38308295qat.73.1398744813144; Mon, 28 Apr 2014 21:13:33 -0700 (PDT) Received: from localhost ([2601:8:1f00:292:96de:80ff:fe6f:b37e]) by mx.google.com with ESMTPSA id r16sm24919274qgd.9.2014.04.28.21.13.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Apr 2014 21:13:32 -0700 (PDT) Date: Tue, 29 Apr 2014 00:13:32 -0400 From: Thomas Tsou To: 246tnt@gmail.com, alexander.chemeris@gmail.com, openbsc@lists.osmocom.org Subject: [PATCH 4/4] conv/test: Extended convolutional decoding tests Message-ID: <20140429041332.GA5194@phenom.hsd1.va.comcast.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -0.6 (/) X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: openbsc-bounces@lists.osmocom.org Errors-To: openbsc-bounces@lists.osmocom.org Add 20 additional convolutional test cases for commonly used codes. These include 16 codes for various cases of GSM TCH handing and an additional tail-biting case for LTE broadcast channels. Signed-off-by: Thomas Tsou --- tests/Makefile.am | 2 +- tests/conv/codes.c | 1034 +++++++++++++++++++++++++++++++++++++++++++++++ tests/conv/codes.h | 30 ++ tests/conv/conv_test.c | 378 +++++++---------- tests/conv/conv_test.ok | 128 ++++++ 5 files changed, 1344 insertions(+), 228 deletions(-) create mode 100644 tests/conv/codes.c create mode 100644 tests/conv/codes.h diff --git a/tests/Makefile.am b/tests/Makefile.am index c6216d5..42fea46 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -28,7 +28,7 @@ auth_milenage_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/sr bits_bitrev_test_SOURCES = bits/bitrev_test.c bits_bitrev_test_LDADD = $(top_builddir)/src/libosmocore.la -conv_conv_test_SOURCES = conv/conv_test.c +conv_conv_test_SOURCES = conv/conv_test.c conv/codes.c conv_conv_test_LDADD = $(top_builddir)/src/libosmocore.la gsm0808_gsm0808_test_SOURCES = gsm0808/gsm0808_test.c diff --git a/tests/conv/codes.c b/tests/conv/codes.c new file mode 100644 index 0000000..703946b --- /dev/null +++ b/tests/conv/codes.c @@ -0,0 +1,1034 @@ +#include +#include "codes.h" + +static const uint8_t xcch_next_output[][2] = { + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 3, 0 }, { 2, 1 }, { 3, 0 }, { 2, 1 }, + { 3, 0 }, { 2, 1 }, { 3, 0 }, { 2, 1 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, +}; + +static const uint8_t xcch_next_state[][2] = { + { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, + { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, + { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, + { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, +}; + +/* GSM XCCH */ +const struct osmo_conv_code gsm_conv_xcch = { + .N = 2, + .K = 5, + .len = 224, + .next_output = xcch_next_output, + .next_state = xcch_next_state, +}; + +/* GPRS CS2 */ +const struct osmo_conv_code gsm_conv_cs2 = { + .N = 2, + .K = 5, + .len = 290, + .next_output = xcch_next_output, + .next_state = xcch_next_state, +}; + +/* GPRS CS3 */ +const struct osmo_conv_code gsm_conv_cs3 = { + .N = 2, + .K = 5, + .len = 334, + .next_output = xcch_next_output, + .next_state = xcch_next_state, +}; + +/* GSM RACH */ +const struct osmo_conv_code gsm_conv_rach = { + .N = 2, + .K = 5, + .len = 14, + .next_output = xcch_next_output, + .next_state = xcch_next_state, +}; + +/* GSM SCH */ +const struct osmo_conv_code gsm_conv_sch = { + .N = 2, + .K = 5, + .len = 35, + .next_output = xcch_next_output, + .next_state = xcch_next_state, +}; + +/* GSM TCH-FR */ +const struct osmo_conv_code gsm_conv_tch_fr = { + .N = 2, + .K = 5, + .len = 185, + .next_output = xcch_next_output, + .next_state = xcch_next_state, +}; + +static const uint8_t tch_hr_next_output[][2] = { + { 0, 7 }, { 3, 4 }, { 5, 2 }, { 6, 1 }, + { 5, 2 }, { 6, 1 }, { 0, 7 }, { 3, 4 }, + { 3, 4 }, { 0, 7 }, { 6, 1 }, { 5, 2 }, + { 6, 1 }, { 5, 2 }, { 3, 4 }, { 0, 7 }, + { 4, 3 }, { 7, 0 }, { 1, 6 }, { 2, 5 }, + { 1, 6 }, { 2, 5 }, { 4, 3 }, { 7, 0 }, + { 7, 0 }, { 4, 3 }, { 2, 5 }, { 1, 6 }, + { 2, 5 }, { 1, 6 }, { 7, 0 }, { 4, 3 }, + { 7, 0 }, { 4, 3 }, { 2, 5 }, { 1, 6 }, + { 2, 5 }, { 1, 6 }, { 7, 0 }, { 4, 3 }, + { 4, 3 }, { 7, 0 }, { 1, 6 }, { 2, 5 }, + { 1, 6 }, { 2, 5 }, { 4, 3 }, { 7, 0 }, + { 3, 4 }, { 0, 7 }, { 6, 1 }, { 5, 2 }, + { 6, 1 }, { 5, 2 }, { 3, 4 }, { 0, 7 }, + { 0, 7 }, { 3, 4 }, { 5, 2 }, { 6, 1 }, + { 5, 2 }, { 6, 1 }, { 0, 7 }, { 3, 4 }, +}; + +static const uint8_t tch_hr_next_state[][2] = { + { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, + { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, + { 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 }, + { 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 }, + { 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 }, + { 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 }, + { 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 }, + { 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 }, + { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, + { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, + { 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 }, + { 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 }, + { 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 }, + { 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 }, + { 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 }, + { 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 }, +}; + +static const int tch_hr_puncture[] = { + 1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, + 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, + 73, 76, 79, 82, 85, 88, 91, 94, 97, 100, 103, 106, + 109, 112, 115, 118, 121, 124, 127, 130, 133, 136, 139, 142, + 145, 148, 151, 154, 157, 160, 163, 166, 169, 172, 175, 178, + 181, 184, 187, 190, 193, 196, 199, 202, 205, 208, 211, 214, + 217, 220, 223, 226, 229, 232, 235, 238, 241, 244, 247, 250, + 253, 256, 259, 262, 265, 268, 271, 274, 277, 280, 283, 295, + 298, 301, 304, 307, 310, 313, -1, +}; + +/* GSM TCH-HR */ +const struct osmo_conv_code gsm_conv_tch_hr = { + .N = 3, + .K = 7, + .len = 98, + .next_output = tch_hr_next_output, + .next_state = tch_hr_next_state, + .puncture = tch_hr_puncture, +}; + +/* GSM TCH-AFS12.2 */ +static const uint8_t tch_afs_12_2_next_output[][2] = { + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, +}; + +static const uint8_t tch_afs_12_2_next_state[][2] = { + { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, + { 9, 8 }, { 11, 10 }, { 13, 12 }, { 15, 14 }, + { 1, 0 }, { 3, 2 }, { 5, 4 }, { 7, 6 }, + { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, +}; + +static const uint8_t tch_afs_12_2_next_term_output[] = { + 0, 1, 0, 1, 3, 2, 3, 2, 3, 2, 3, 2, 0, 1, 0, 1, +}; + +static const uint8_t tch_afs_12_2_next_term_state[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14, +}; + +static int tch_afs_12_2_puncture[] = { + 321, 325, 329, 333, 337, 341, 345, 349, 353, 357, 361, 363, + 365, 369, 373, 377, 379, 381, 385, 389, 393, 395, 397, 401, + 405, 409, 411, 413, 417, 421, 425, 427, 429, 433, 437, 441, + 443, 445, 449, 453, 457, 459, 461, 465, 469, 473, 475, 477, + 481, 485, 489, 491, 493, 495, 497, 499, 501, 503, 505, 507, + -1, +}; + +/* GSM TCH-AFS12.2 */ +const struct osmo_conv_code gsm_conv_tch_afs_12_2 = { + .N = 2, + .K = 5, + .len = 250, + .next_output = tch_afs_12_2_next_output, + .next_state = tch_afs_12_2_next_state, + .next_term_output = tch_afs_12_2_next_term_output, + .next_term_state = tch_afs_12_2_next_term_state, + .puncture = tch_afs_12_2_puncture, +}; + +static const uint8_t tch_afs_10_2_next_output[][2] = { + { 0, 7 }, { 2, 5 }, { 4, 3 }, { 6, 1 }, + { 2, 5 }, { 0, 7 }, { 6, 1 }, { 4, 3 }, + { 0, 7 }, { 2, 5 }, { 4, 3 }, { 6, 1 }, + { 2, 5 }, { 0, 7 }, { 6, 1 }, { 4, 3 }, +}; + +static const uint8_t tch_afs_10_2_next_state[][2] = { + { 0, 1 }, { 3, 2 }, { 5, 4 }, { 6, 7 }, + { 9, 8 }, { 10, 11 }, { 12, 13 }, { 15, 14 }, + { 1, 0 }, { 2, 3 }, { 4, 5 }, { 7, 6 }, + { 8, 9 }, { 11, 10 }, { 13, 12 }, { 14, 15 }, +}; + +static const uint8_t tch_afs_10_2_next_term_output[] = { + 0, 5, 3, 6, 5, 0, 6, 3, 7, 2, 4, 1, 2, 7, 1, 4, +}; + +static const uint8_t tch_afs_10_2_next_term_state[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14, +}; + +static int tch_afs_10_2_puncture[] = { + 1, 4, 7, 10, 16, 19, 22, 28, 31, 34, 40, 43, + 46, 52, 55, 58, 64, 67, 70, 76, 79, 82, 88, 91, + 94, 100, 103, 106, 112, 115, 118, 124, 127, 130, 136, 139, + 142, 148, 151, 154, 160, 163, 166, 172, 175, 178, 184, 187, + 190, 196, 199, 202, 208, 211, 214, 220, 223, 226, 232, 235, + 238, 244, 247, 250, 256, 259, 262, 268, 271, 274, 280, 283, + 286, 292, 295, 298, 304, 307, 310, 316, 319, 322, 325, 328, + 331, 334, 337, 340, 343, 346, 349, 352, 355, 358, 361, 364, + 367, 370, 373, 376, 379, 382, 385, 388, 391, 394, 397, 400, + 403, 406, 409, 412, 415, 418, 421, 424, 427, 430, 433, 436, + 439, 442, 445, 448, 451, 454, 457, 460, 463, 466, 469, 472, + 475, 478, 481, 484, 487, 490, 493, 496, 499, 502, 505, 508, + 511, 514, 517, 520, 523, 526, 529, 532, 535, 538, 541, 544, + 547, 550, 553, 556, 559, 562, 565, 568, 571, 574, 577, 580, + 583, 586, 589, 592, 595, 598, 601, 604, 607, 609, 610, 613, + 616, 619, 621, 622, 625, 627, 628, 631, 633, 634, 636, 637, + 639, 640, -1, +}; + +/* GSM TCH-AFS10.2 */ +const struct osmo_conv_code gsm_conv_tch_afs_10_2 = { + .N = 3, + .K = 5, + .len = 210, + .next_output = tch_afs_10_2_next_output, + .next_state = tch_afs_10_2_next_state, + .next_term_output = tch_afs_10_2_next_term_output, + .next_term_state = tch_afs_10_2_next_term_state, + .puncture = tch_afs_10_2_puncture, +}; + +static const uint8_t tch_afs_7_95_next_output[][2] = { + { 0, 7 }, { 3, 4 }, { 2, 5 }, { 1, 6 }, + { 2, 5 }, { 1, 6 }, { 0, 7 }, { 3, 4 }, + { 3, 4 }, { 0, 7 }, { 1, 6 }, { 2, 5 }, + { 1, 6 }, { 2, 5 }, { 3, 4 }, { 0, 7 }, + { 3, 4 }, { 0, 7 }, { 1, 6 }, { 2, 5 }, + { 1, 6 }, { 2, 5 }, { 3, 4 }, { 0, 7 }, + { 0, 7 }, { 3, 4 }, { 2, 5 }, { 1, 6 }, + { 2, 5 }, { 1, 6 }, { 0, 7 }, { 3, 4 }, + { 0, 7 }, { 3, 4 }, { 2, 5 }, { 1, 6 }, + { 2, 5 }, { 1, 6 }, { 0, 7 }, { 3, 4 }, + { 3, 4 }, { 0, 7 }, { 1, 6 }, { 2, 5 }, + { 1, 6 }, { 2, 5 }, { 3, 4 }, { 0, 7 }, + { 3, 4 }, { 0, 7 }, { 1, 6 }, { 2, 5 }, + { 1, 6 }, { 2, 5 }, { 3, 4 }, { 0, 7 }, + { 0, 7 }, { 3, 4 }, { 2, 5 }, { 1, 6 }, + { 2, 5 }, { 1, 6 }, { 0, 7 }, { 3, 4 }, +}; + +static const uint8_t tch_afs_7_95_next_state[][2] = { + { 0, 1 }, { 2, 3 }, { 5, 4 }, { 7, 6 }, + { 9, 8 }, { 11, 10 }, { 12, 13 }, { 14, 15 }, + { 16, 17 }, { 18, 19 }, { 21, 20 }, { 23, 22 }, + { 25, 24 }, { 27, 26 }, { 28, 29 }, { 30, 31 }, + { 33, 32 }, { 35, 34 }, { 36, 37 }, { 38, 39 }, + { 40, 41 }, { 42, 43 }, { 45, 44 }, { 47, 46 }, + { 49, 48 }, { 51, 50 }, { 52, 53 }, { 54, 55 }, + { 56, 57 }, { 58, 59 }, { 61, 60 }, { 63, 62 }, + { 1, 0 }, { 3, 2 }, { 4, 5 }, { 6, 7 }, + { 8, 9 }, { 10, 11 }, { 13, 12 }, { 15, 14 }, + { 17, 16 }, { 19, 18 }, { 20, 21 }, { 22, 23 }, + { 24, 25 }, { 26, 27 }, { 29, 28 }, { 31, 30 }, + { 32, 33 }, { 34, 35 }, { 37, 36 }, { 39, 38 }, + { 41, 40 }, { 43, 42 }, { 44, 45 }, { 46, 47 }, + { 48, 49 }, { 50, 51 }, { 53, 52 }, { 55, 54 }, + { 57, 56 }, { 59, 58 }, { 60, 61 }, { 62, 63 }, +}; + +static const uint8_t tch_afs_7_95_next_term_output[] = { + 0, 3, 5, 6, 5, 6, 0, 3, 3, 0, 6, 5, 6, 5, 3, 0, + 4, 7, 1, 2, 1, 2, 4, 7, 7, 4, 2, 1, 2, 1, 7, 4, + 7, 4, 2, 1, 2, 1, 7, 4, 4, 7, 1, 2, 1, 2, 4, 7, + 3, 0, 6, 5, 6, 5, 3, 0, 0, 3, 5, 6, 5, 6, 0, 3, +}; + +static const uint8_t tch_afs_7_95_next_term_state[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, + 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, + 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, +}; + +static int tch_afs_7_95_puncture[] = { + 1, 2, 4, 5, 8, 22, 70, 118, 166, 214, 262, 310, + 317, 319, 325, 332, 334, 341, 343, 349, 356, 358, 365, 367, + 373, 380, 382, 385, 389, 391, 397, 404, 406, 409, 413, 415, + 421, 428, 430, 433, 437, 439, 445, 452, 454, 457, 461, 463, + 469, 476, 478, 481, 485, 487, 490, 493, 500, 502, 503, 505, + 506, 508, 509, 511, 512, -1, +}; + +/* GSM TCH-AFS7.95 */ +const struct osmo_conv_code gsm_conv_tch_afs_7_95 = { + .N = 3, + .K = 7, + .len = 165, + .next_output = tch_afs_7_95_next_output, + .next_state = tch_afs_7_95_next_state, + .next_term_output = tch_afs_7_95_next_term_output, + .next_term_state = tch_afs_7_95_next_term_state, + .puncture = tch_afs_7_95_puncture, +}; + +static const uint8_t tch_afs_7_4_next_output[][2] = { + { 0, 7 }, { 2, 5 }, { 4, 3 }, { 6, 1 }, + { 2, 5 }, { 0, 7 }, { 6, 1 }, { 4, 3 }, + { 0, 7 }, { 2, 5 }, { 4, 3 }, { 6, 1 }, + { 2, 5 }, { 0, 7 }, { 6, 1 }, { 4, 3 }, +}; + +static const uint8_t tch_afs_7_4_next_state[][2] = { + { 0, 1 }, { 3, 2 }, { 5, 4 }, { 6, 7 }, + { 9, 8 }, { 10, 11 }, { 12, 13 }, { 15, 14 }, + { 1, 0 }, { 2, 3 }, { 4, 5 }, { 7, 6 }, + { 8, 9 }, { 11, 10 }, { 13, 12 }, { 14, 15 }, +}; + +static const uint8_t tch_afs_7_4_next_term_output[] = { + 0, 5, 3, 6, 5, 0, 6, 3, 7, 2, 4, 1, 2, 7, 1, 4, +}; + +static const uint8_t tch_afs_7_4_next_term_state[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14, +}; + +static int tch_afs_7_4_puncture[] = { + 0, 355, 361, 367, 373, 379, 385, 391, 397, 403, 409, 415, + 421, 427, 433, 439, 445, 451, 457, 460, 463, 466, 468, 469, + 471, 472, -1, +}; + +/* GSM TCH-AFS7.4 */ +const struct osmo_conv_code gsm_conv_tch_afs_7_4 = { + .N = 3, + .K = 5, + .len = 154, + .next_output = tch_afs_7_4_next_output, + .next_state = tch_afs_7_4_next_state, + .next_term_output = tch_afs_7_4_next_term_output, + .next_term_state = tch_afs_7_4_next_term_state, + .puncture = tch_afs_7_4_puncture, +}; + +static const uint8_t tch_afs_6_7_next_output[][2] = { + { 0, 15 }, { 4, 11 }, { 8, 7 }, { 12, 3 }, + { 4, 11 }, { 0, 15 }, { 12, 3 }, { 8, 7 }, + { 0, 15 }, { 4, 11 }, { 8, 7 }, { 12, 3 }, + { 4, 11 }, { 0, 15 }, { 12, 3 }, { 8, 7 }, +}; + +static const uint8_t tch_afs_6_7_next_state[][2] = { + { 0, 1 }, { 3, 2 }, { 5, 4 }, { 6, 7 }, + { 9, 8 }, { 10, 11 }, { 12, 13 }, { 15, 14 }, + { 1, 0 }, { 2, 3 }, { 4, 5 }, { 7, 6 }, + { 8, 9 }, { 11, 10 }, { 13, 12 }, { 14, 15 }, +}; + +static int tch_afs_6_7_puncture[] = { + 1, 3, 7, 11, 15, 27, 39, 55, 67, 79, 95, 107, + 119, 135, 147, 159, 175, 187, 199, 215, 227, 239, 255, 267, + 279, 287, 291, 295, 299, 303, 307, 311, 315, 319, 323, 327, + 331, 335, 339, 343, 347, 351, 355, 359, 363, 367, 369, 371, + 375, 377, 379, 383, 385, 387, 391, 393, 395, 399, 401, 403, + 407, 409, 411, 415, 417, 419, 423, 425, 427, 431, 433, 435, + 439, 441, 443, 447, 449, 451, 455, 457, 459, 463, 465, 467, + 471, 473, 475, 479, 481, 483, 487, 489, 491, 495, 497, 499, + 503, 505, 507, 511, 513, 515, 519, 521, 523, 527, 529, 531, + 535, 537, 539, 543, 545, 547, 549, 551, 553, 555, 557, 559, + 561, 563, 565, 567, 569, 571, 573, 575, + -1, +}; + +static const uint8_t tch_afs_6_7_next_term_output[] = { + 0, 11, 7, 12, 11, 0, 12, 7, 15, 4, 8, 3, 4, 15, 3, 8, +}; + +static const uint8_t tch_afs_6_7_next_term_state[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14, +}; + +/* GSM TCH-AFS6.7 */ +const struct osmo_conv_code gsm_conv_tch_afs_6_7 = { + .N = 4, + .K = 5, + .len = 140, + .next_output = tch_afs_6_7_next_output, + .next_state = tch_afs_6_7_next_state, + .next_term_output = tch_afs_6_7_next_term_output, + .next_term_state = tch_afs_6_7_next_term_state, + .puncture = tch_afs_6_7_puncture, +}; + +static const uint8_t tch_afs_5_9_next_output[][2] = { + { 0, 15 }, { 8, 7 }, { 4, 11 }, { 12, 3 }, + { 4, 11 }, { 12, 3 }, { 0, 15 }, { 8, 7 }, + { 8, 7 }, { 0, 15 }, { 12, 3 }, { 4, 11 }, + { 12, 3 }, { 4, 11 }, { 8, 7 }, { 0, 15 }, + { 8, 7 }, { 0, 15 }, { 12, 3 }, { 4, 11 }, + { 12, 3 }, { 4, 11 }, { 8, 7 }, { 0, 15 }, + { 0, 15 }, { 8, 7 }, { 4, 11 }, { 12, 3 }, + { 4, 11 }, { 12, 3 }, { 0, 15 }, { 8, 7 }, + { 0, 15 }, { 8, 7 }, { 4, 11 }, { 12, 3 }, + { 4, 11 }, { 12, 3 }, { 0, 15 }, { 8, 7 }, + { 8, 7 }, { 0, 15 }, { 12, 3 }, { 4, 11 }, + { 12, 3 }, { 4, 11 }, { 8, 7 }, { 0, 15 }, + { 8, 7 }, { 0, 15 }, { 12, 3 }, { 4, 11 }, + { 12, 3 }, { 4, 11 }, { 8, 7 }, { 0, 15 }, + { 0, 15 }, { 8, 7 }, { 4, 11 }, { 12, 3 }, + { 4, 11 }, { 12, 3 }, { 0, 15 }, { 8, 7 }, +}; + +static const uint8_t tch_afs_5_9_next_state[][2] = { + { 0, 1 }, { 3, 2 }, { 5, 4 }, { 6, 7 }, + { 9, 8 }, { 10, 11 }, { 12, 13 }, { 15, 14 }, + { 17, 16 }, { 18, 19 }, { 20, 21 }, { 23, 22 }, + { 24, 25 }, { 27, 26 }, { 29, 28 }, { 30, 31 }, + { 32, 33 }, { 35, 34 }, { 37, 36 }, { 38, 39 }, + { 41, 40 }, { 42, 43 }, { 44, 45 }, { 47, 46 }, + { 49, 48 }, { 50, 51 }, { 52, 53 }, { 55, 54 }, + { 56, 57 }, { 59, 58 }, { 61, 60 }, { 62, 63 }, + { 1, 0 }, { 2, 3 }, { 4, 5 }, { 7, 6 }, + { 8, 9 }, { 11, 10 }, { 13, 12 }, { 14, 15 }, + { 16, 17 }, { 19, 18 }, { 21, 20 }, { 22, 23 }, + { 25, 24 }, { 26, 27 }, { 28, 29 }, { 31, 30 }, + { 33, 32 }, { 34, 35 }, { 36, 37 }, { 39, 38 }, + { 40, 41 }, { 43, 42 }, { 45, 44 }, { 46, 47 }, + { 48, 49 }, { 51, 50 }, { 53, 52 }, { 54, 55 }, + { 57, 56 }, { 58, 59 }, { 60, 61 }, { 63, 62 }, +}; + +static const uint8_t tch_afs_5_9_next_term_output[] = { + 0, 7, 11, 12, 11, 12, 0, 7, 7, 0, 12, 11, 12, 11, 7, 0, + 8, 15, 3, 4, 3, 4, 8, 15, 15, 8, 4, 3, 4, 3, 15, 8, + 15, 8, 4, 3, 4, 3, 15, 8, 8, 15, 3, 4, 3, 4, 8, 15, + 7, 0, 12, 11, 12, 11, 7, 0, 0, 7, 11, 12, 11, 12, 0, 7, +}; + +static const uint8_t tch_afs_5_9_next_term_state[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, + 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, + 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, +}; + +static int tch_afs_5_9_puncture[] = { + 0, 1, 3, 5, 7, 11, 15, 31, 47, 63, 79, 95, + 111, 127, 143, 159, 175, 191, 207, 223, 239, 255, 271, 287, + 303, 319, 327, 331, 335, 343, 347, 351, 359, 363, 367, 375, + 379, 383, 391, 395, 399, 407, 411, 415, 423, 427, 431, 439, + 443, 447, 455, 459, 463, 467, 471, 475, 479, 483, 487, 491, + 495, 499, 503, 507, 509, 511, 512, 513, 515, 516, 517, 519, + -1, +}; + +/* GSM TCH-AFS5.9 */ +const struct osmo_conv_code gsm_conv_tch_afs_5_9 = { + .N = 4, + .K = 7, + .len = 124, + .next_output = tch_afs_5_9_next_output, + .next_state = tch_afs_5_9_next_state, + .next_term_output = tch_afs_5_9_next_term_output, + .next_term_state = tch_afs_5_9_next_term_state, + .puncture = tch_afs_5_9_puncture, +}; + +static const uint8_t tch_afs_5_15_next_output[][2] = { + { 0, 31 }, { 4, 27 }, { 24, 7 }, { 28, 3 }, + { 4, 27 }, { 0, 31 }, { 28, 3 }, { 24, 7 }, + { 0, 31 }, { 4, 27 }, { 24, 7 }, { 28, 3 }, + { 4, 27 }, { 0, 31 }, { 28, 3 }, { 24, 7 }, +}; + +static const uint8_t tch_afs_5_15_next_state[][2] = { + { 0, 1 }, { 3, 2 }, { 5, 4 }, { 6, 7 }, + { 9, 8 }, { 10, 11 }, { 12, 13 }, { 15, 14 }, + { 1, 0 }, { 2, 3 }, { 4, 5 }, { 7, 6 }, + { 8, 9 }, { 11, 10 }, { 13, 12 }, { 14, 15 }, +}; + +static const uint8_t tch_afs_5_15_next_term_output[] = { + 0, 27, 7, 28, 27, 0, 28, 7, 31, 4, 24, 3, 4, 31, 3, 24, +}; + +static const uint8_t tch_afs_5_15_next_term_state[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14, +}; + +static int tch_afs_5_15_puncture[] = { + 0, 4, 5, 9, 10, 14, 15, 20, 25, 30, 35, 40, + 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, + 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, + 290, 300, 310, 315, 320, 325, 330, 334, 335, 340, 344, 345, + 350, 354, 355, 360, 364, 365, 370, 374, 375, 380, 384, 385, + 390, 394, 395, 400, 404, 405, 410, 414, 415, 420, 424, 425, + 430, 434, 435, 440, 444, 445, 450, 454, 455, 460, 464, 465, + 470, 474, 475, 480, 484, 485, 490, 494, 495, 500, 504, 505, + 510, 514, 515, 520, 524, 525, 529, 530, 534, 535, 539, 540, + 544, 545, 549, 550, 554, 555, 559, 560, 564, -1, +}; + +/* GSM TCH-AFS5.15 */ +const struct osmo_conv_code gsm_conv_tch_afs_5_15 = { + .N = 5, + .K = 5, + .len = 109, + .next_output = tch_afs_5_15_next_output, + .next_state = tch_afs_5_15_next_state, + .next_term_output = tch_afs_5_15_next_term_output, + .next_term_state = tch_afs_5_15_next_term_state, + .puncture = tch_afs_5_15_puncture, +}; + +static const uint8_t tch_afs_4_75_next_output[][2] = { + { 0, 31 }, { 24, 7 }, { 4, 27 }, { 28, 3 }, + { 4, 27 }, { 28, 3 }, { 0, 31 }, { 24, 7 }, + { 24, 7 }, { 0, 31 }, { 28, 3 }, { 4, 27 }, + { 28, 3 }, { 4, 27 }, { 24, 7 }, { 0, 31 }, + { 24, 7 }, { 0, 31 }, { 28, 3 }, { 4, 27 }, + { 28, 3 }, { 4, 27 }, { 24, 7 }, { 0, 31 }, + { 0, 31 }, { 24, 7 }, { 4, 27 }, { 28, 3 }, + { 4, 27 }, { 28, 3 }, { 0, 31 }, { 24, 7 }, + { 0, 31 }, { 24, 7 }, { 4, 27 }, { 28, 3 }, + { 4, 27 }, { 28, 3 }, { 0, 31 }, { 24, 7 }, + { 24, 7 }, { 0, 31 }, { 28, 3 }, { 4, 27 }, + { 28, 3 }, { 4, 27 }, { 24, 7 }, { 0, 31 }, + { 24, 7 }, { 0, 31 }, { 28, 3 }, { 4, 27 }, + { 28, 3 }, { 4, 27 }, { 24, 7 }, { 0, 31 }, + { 0, 31 }, { 24, 7 }, { 4, 27 }, { 28, 3 }, + { 4, 27 }, { 28, 3 }, { 0, 31 }, { 24, 7 }, +}; + +static const uint8_t tch_afs_4_75_next_state[][2] = { + { 0, 1 }, { 3, 2 }, { 5, 4 }, { 6, 7 }, + { 9, 8 }, { 10, 11 }, { 12, 13 }, { 15, 14 }, + { 17, 16 }, { 18, 19 }, { 20, 21 }, { 23, 22 }, + { 24, 25 }, { 27, 26 }, { 29, 28 }, { 30, 31 }, + { 32, 33 }, { 35, 34 }, { 37, 36 }, { 38, 39 }, + { 41, 40 }, { 42, 43 }, { 44, 45 }, { 47, 46 }, + { 49, 48 }, { 50, 51 }, { 52, 53 }, { 55, 54 }, + { 56, 57 }, { 59, 58 }, { 61, 60 }, { 62, 63 }, + { 1, 0 }, { 2, 3 }, { 4, 5 }, { 7, 6 }, + { 8, 9 }, { 11, 10 }, { 13, 12 }, { 14, 15 }, + { 16, 17 }, { 19, 18 }, { 21, 20 }, { 22, 23 }, + { 25, 24 }, { 26, 27 }, { 28, 29 }, { 31, 30 }, + { 33, 32 }, { 34, 35 }, { 36, 37 }, { 39, 38 }, + { 40, 41 }, { 43, 42 }, { 45, 44 }, { 46, 47 }, + { 48, 49 }, { 51, 50 }, { 53, 52 }, { 54, 55 }, + { 57, 56 }, { 58, 59 }, { 60, 61 }, { 63, 62 }, +}; + +static const uint8_t tch_afs_4_75_next_term_output[] = { + 0, 7, 27, 28, 27, 28, 0, 7, 7, 0, 28, 27, 28, 27, 7, 0, + 24, 31, 3, 4, 3, 4, 24, 31, 31, 24, 4, 3, 4, 3, 31, 24, + 31, 24, 4, 3, 4, 3, 31, 24, 24, 31, 3, 4, 3, 4, 24, 31, + 7, 0, 28, 27, 28, 27, 7, 0, 0, 7, 27, 28, 27, 28, 0, 7, +}; + +static const uint8_t tch_afs_4_75_next_term_state[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, + 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, + 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, +}; + +static int tch_afs_4_75_puncture[] = { + 0, 1, 2, 4, 5, 7, 9, 15, 25, 35, 45, 55, + 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, + 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295, + 305, 315, 325, 335, 345, 355, 365, 375, 385, 395, 400, 405, + 410, 415, 420, 425, 430, 435, 440, 445, 450, 455, 459, 460, + 465, 470, 475, 479, 480, 485, 490, 495, 499, 500, 505, 509, + 510, 515, 517, 519, 520, 522, 524, 525, 526, 527, 529, 530, + 531, 532, 534, -1, +}; + +/* GSM TCH-AFS4.75 */ +const struct osmo_conv_code gsm_conv_tch_afs_4_75 = { + .N = 5, + .K = 7, + .len = 101, + .next_output = tch_afs_4_75_next_output, + .next_state = tch_afs_4_75_next_state, + .next_term_output = tch_afs_4_75_next_term_output, + .next_term_state = tch_afs_4_75_next_term_state, + .puncture = tch_afs_4_75_puncture, +}; + +static const uint8_t tch_ahs_7_95_next_output[][2] = { + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, +}; + +static const uint8_t tch_ahs_7_95_next_state[][2] = { + { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, + { 9, 8 }, { 11, 10 }, { 13, 12 }, { 15, 14 }, + { 1, 0 }, { 3, 2 }, { 5, 4 }, { 7, 6 }, + { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, +}; + +static const uint8_t tch_ahs_7_95_next_term_output[] = { + 0, 1, 0, 1, 3, 2, 3, 2, 3, 2, 3, 2, 0, 1, 0, 1, +}; + +static const uint8_t tch_ahs_7_95_next_term_state[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14, +}; + +static int tch_ahs_7_95_puncture[] = { + 1, 3, 5, 7, 11, 15, 19, 23, 27, 31, 35, 43, + 47, 51, 55, 59, 63, 67, 71, 79, 83, 87, 91, 95, + 99, 103, 107, 115, 119, 123, 127, 131, 135, 139, 143, 151, + 155, 159, 163, 167, 171, 175, 177, 179, 183, 185, 187, 191, + 193, 195, 197, 199, 203, 205, 207, 211, 213, 215, 219, 221, + 223, 227, 229, 231, 233, 235, 239, 241, 243, 247, 249, 251, + 255, 257, 259, 261, 263, 265, + -1, +}; + +/* GSM TCH-AHS7.95 */ +const struct osmo_conv_code gsm_conv_tch_ahs_7_95 = { + .N = 2, + .K = 5, + .len = 129, + .next_output = tch_ahs_7_95_next_output, + .next_state = tch_ahs_7_95_next_state, + .next_term_output = tch_ahs_7_95_next_term_output, + .next_term_state = tch_ahs_7_95_next_term_state, + .puncture = tch_ahs_7_95_puncture, +}; + +static const uint8_t tch_ahs_7_4_next_output[][2] = { + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, +}; + +static const uint8_t tch_ahs_7_4_next_state[][2] = { + { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, + { 9, 8 }, { 11, 10 }, { 13, 12 }, { 15, 14 }, + { 1, 0 }, { 3, 2 }, { 5, 4 }, { 7, 6 }, + { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, +}; + +static const uint8_t tch_ahs_7_4_next_term_output[] = { + 0, 1, 0, 1, 3, 2, 3, 2, 3, 2, 3, 2, 0, 1, 0, 1, +}; + +static const uint8_t tch_ahs_7_4_next_term_state[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14, +}; + +static int tch_ahs_7_4_puncture[] = { + 1, 3, 7, 11, 19, 23, 27, 35, 39, 43, 51, 55, + 59, 67, 71, 75, 83, 87, 91, 99, 103, 107, 115, 119, + 123, 131, 135, 139, 143, 147, 151, 155, 159, 163, 167, 171, + 175, 179, 183, 187, 191, 195, 199, 203, 207, 211, 215, 219, + 221, 223, 227, 229, 231, 235, 237, 239, 243, 245, 247, 251, + 253, 255, 257, 259, -1, +}; + +/* GSM TCH-AHS7.4 */ +const struct osmo_conv_code gsm_conv_tch_ahs_7_4 = { + .N = 2, + .K = 5, + .len = 126, + .next_output = tch_ahs_7_4_next_output, + .next_state = tch_ahs_7_4_next_state, + .next_term_output = tch_ahs_7_4_next_term_output, + .next_term_state = tch_ahs_7_4_next_term_state, + .puncture = tch_ahs_7_4_puncture, +}; + +static const uint8_t tch_ahs_6_7_next_output[][2] = { + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, +}; + +static const uint8_t tch_ahs_6_7_next_state[][2] = { + { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, + { 9, 8 }, { 11, 10 }, { 13, 12 }, { 15, 14 }, + { 1, 0 }, { 3, 2 }, { 5, 4 }, { 7, 6 }, + { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, +}; + +static const uint8_t tch_ahs_6_7_next_term_output[] = { + 0, 1, 0, 1, 3, 2, 3, 2, 3, 2, 3, 2, 0, 1, 0, 1, +}; + +static const uint8_t tch_ahs_6_7_next_term_state[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14, +}; + +static int tch_ahs_6_7_puncture[] = { + 1, 3, 9, 19, 29, 39, 49, 59, 69, 79, 89, 99, + 109, 119, 129, 139, 149, 159, 167, 169, 177, 179, 187, 189, + 197, 199, 203, 207, 209, 213, 217, 219, 223, 227, 229, 231, + 233, 235, 237, 239, -1, +}; + +/* GSM TCH-AHS6.7 */ +const struct osmo_conv_code gsm_conv_tch_ahs_6_7 = { + .N = 2, + .K = 5, + .len = 116, + .next_output = tch_ahs_6_7_next_output, + .next_state = tch_ahs_6_7_next_state, + .next_term_output = tch_ahs_6_7_next_term_output, + .next_term_state = tch_ahs_6_7_next_term_state, + .puncture = tch_ahs_6_7_puncture, +}; + +static const uint8_t tch_ahs_5_9_next_output[][2] = { + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, +}; + +static const uint8_t tch_ahs_5_9_next_state[][2] = { + { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, + { 9, 8 }, { 11, 10 }, { 13, 12 }, { 15, 14 }, + { 1, 0 }, { 3, 2 }, { 5, 4 }, { 7, 6 }, + { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, +}; + +static const uint8_t tch_ahs_5_9_next_term_output[] = { + 0, 1, 0, 1, 3, 2, 3, 2, 3, 2, 3, 2, 0, 1, 0, 1, +}; + +static const uint8_t tch_ahs_5_9_next_term_state[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14, +}; + +static int tch_ahs_5_9_puncture[] = { + 1, 15, 71, 127, 139, 151, 163, 175, 187, 195, 203, 211, + 215, 219, 221, 223, -1, +}; + +/* GSM TCH-AHS5.9 */ +const struct osmo_conv_code gsm_conv_tch_ahs_5_9 = { + .N = 2, + .K = 5, + .len = 108, + .next_output = tch_ahs_5_9_next_output, + .next_state = tch_ahs_5_9_next_state, + .next_term_output = tch_ahs_5_9_next_term_output, + .next_term_state = tch_ahs_5_9_next_term_state, + .puncture = tch_ahs_5_9_puncture, +}; + +static const uint8_t tch_ahs_5_15_next_output[][2] = { + { 0, 7 }, { 2, 5 }, { 4, 3 }, { 6, 1 }, + { 2, 5 }, { 0, 7 }, { 6, 1 }, { 4, 3 }, + { 0, 7 }, { 2, 5 }, { 4, 3 }, { 6, 1 }, + { 2, 5 }, { 0, 7 }, { 6, 1 }, { 4, 3 }, +}; + +static const uint8_t tch_ahs_5_15_next_state[][2] = { + { 0, 1 }, { 3, 2 }, { 5, 4 }, { 6, 7 }, + { 9, 8 }, { 10, 11 }, { 12, 13 }, { 15, 14 }, + { 1, 0 }, { 2, 3 }, { 4, 5 }, { 7, 6 }, + { 8, 9 }, { 11, 10 }, { 13, 12 }, { 14, 15 }, +}; + +static const uint8_t tch_ahs_5_15_next_term_output[] = { + 0, 5, 3, 6, 5, 0, 6, 3, 7, 2, 4, 1, 2, 7, 1, 4, +}; + +static const uint8_t tch_ahs_5_15_next_term_state[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14, +}; + +static int tch_ahs_5_15_puncture[] = { + 0, 1, 3, 4, 6, 9, 12, 15, 18, 21, 27, 33, + 39, 45, 51, 54, 57, 63, 69, 75, 81, 87, 90, 93, + 99, 105, 111, 117, 123, 126, 129, 135, 141, 147, 153, 159, + 162, 165, 168, 171, 174, 177, 180, 183, 186, 189, 192, 195, + 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231, + 234, 237, 240, 243, 244, 246, 249, 252, 255, 256, 258, 261, + 264, 267, 268, 270, 273, 276, 279, 280, 282, 285, 288, 289, + 291, 294, 295, 297, 298, 300, 301, -1, +}; + +/* GSM TCH-AHS5.15 */ +const struct osmo_conv_code gsm_conv_tch_ahs_5_15 = { + .N = 3, + .K = 5, + .len = 97, + .next_output = tch_ahs_5_15_next_output, + .next_state = tch_ahs_5_15_next_state, + .next_term_output = tch_ahs_5_15_next_term_output, + .next_term_state = tch_ahs_5_15_next_term_state, + .puncture = tch_ahs_5_15_puncture, +}; + +static const uint8_t tch_ahs_4_75_next_output[][2] = { + { 0, 7 }, { 3, 4 }, { 2, 5 }, { 1, 6 }, + { 2, 5 }, { 1, 6 }, { 0, 7 }, { 3, 4 }, + { 3, 4 }, { 0, 7 }, { 1, 6 }, { 2, 5 }, + { 1, 6 }, { 2, 5 }, { 3, 4 }, { 0, 7 }, + { 3, 4 }, { 0, 7 }, { 1, 6 }, { 2, 5 }, + { 1, 6 }, { 2, 5 }, { 3, 4 }, { 0, 7 }, + { 0, 7 }, { 3, 4 }, { 2, 5 }, { 1, 6 }, + { 2, 5 }, { 1, 6 }, { 0, 7 }, { 3, 4 }, + { 0, 7 }, { 3, 4 }, { 2, 5 }, { 1, 6 }, + { 2, 5 }, { 1, 6 }, { 0, 7 }, { 3, 4 }, + { 3, 4 }, { 0, 7 }, { 1, 6 }, { 2, 5 }, + { 1, 6 }, { 2, 5 }, { 3, 4 }, { 0, 7 }, + { 3, 4 }, { 0, 7 }, { 1, 6 }, { 2, 5 }, + { 1, 6 }, { 2, 5 }, { 3, 4 }, { 0, 7 }, + { 0, 7 }, { 3, 4 }, { 2, 5 }, { 1, 6 }, + { 2, 5 }, { 1, 6 }, { 0, 7 }, { 3, 4 }, +}; + +static const uint8_t tch_ahs_4_75_next_state[][2] = { + { 0, 1 }, { 2, 3 }, { 5, 4 }, { 7, 6 }, + { 9, 8 }, { 11, 10 }, { 12, 13 }, { 14, 15 }, + { 16, 17 }, { 18, 19 }, { 21, 20 }, { 23, 22 }, + { 25, 24 }, { 27, 26 }, { 28, 29 }, { 30, 31 }, + { 33, 32 }, { 35, 34 }, { 36, 37 }, { 38, 39 }, + { 40, 41 }, { 42, 43 }, { 45, 44 }, { 47, 46 }, + { 49, 48 }, { 51, 50 }, { 52, 53 }, { 54, 55 }, + { 56, 57 }, { 58, 59 }, { 61, 60 }, { 63, 62 }, + { 1, 0 }, { 3, 2 }, { 4, 5 }, { 6, 7 }, + { 8, 9 }, { 10, 11 }, { 13, 12 }, { 15, 14 }, + { 17, 16 }, { 19, 18 }, { 20, 21 }, { 22, 23 }, + { 24, 25 }, { 26, 27 }, { 29, 28 }, { 31, 30 }, + { 32, 33 }, { 34, 35 }, { 37, 36 }, { 39, 38 }, + { 41, 40 }, { 43, 42 }, { 44, 45 }, { 46, 47 }, + { 48, 49 }, { 50, 51 }, { 53, 52 }, { 55, 54 }, + { 57, 56 }, { 59, 58 }, { 60, 61 }, { 62, 63 }, +}; + +static const uint8_t tch_ahs_4_75_next_term_output[] = { + 0, 3, 5, 6, 5, 6, 0, 3, 3, 0, 6, 5, 6, 5, 3, 0, + 4, 7, 1, 2, 1, 2, 4, 7, 7, 4, 2, 1, 2, 1, 7, 4, + 7, 4, 2, 1, 2, 1, 7, 4, 4, 7, 1, 2, 1, 2, 4, 7, + 3, 0, 6, 5, 6, 5, 3, 0, 0, 3, 5, 6, 5, 6, 0, 3, +}; + +static const uint8_t tch_ahs_4_75_next_term_state[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, + 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, + 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, +}; + +static int tch_ahs_4_75_puncture[] = { + 1, 2, 4, 5, 7, 8, 10, 13, 16, 22, 28, 34, + 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 100, 106, + 112, 118, 124, 130, 136, 142, 148, 151, 154, 160, 163, 166, + 172, 175, 178, 184, 187, 190, 196, 199, 202, 208, 211, 214, + 220, 223, 226, 232, 235, 238, 241, 244, 247, 250, 253, 256, + 259, 262, 265, 268, 271, 274, 275, 277, 278, 280, 281, 283, + 284, -1, +}; + +/* GSM TCH-AHS4.75 */ +const struct osmo_conv_code gsm_conv_tch_ahs_4_75 = { + .N = 3, + .K = 7, + .len = 89, + .next_output = tch_ahs_4_75_next_output, + .next_state = tch_ahs_4_75_next_state, + .next_term_output = tch_ahs_4_75_next_term_output, + .next_term_state = tch_ahs_4_75_next_term_state, + .puncture = tch_ahs_4_75_puncture, +}; + +static const uint8_t wimax_fch_next_output[][2] = { + { 0, 3 }, { 2, 1 }, { 3, 0 }, { 1, 2 }, + { 3, 0 }, { 1, 2 }, { 0, 3 }, { 2, 1 }, + { 0, 3 }, { 2, 1 }, { 3, 0 }, { 1, 2 }, + { 3, 0 }, { 1, 2 }, { 0, 3 }, { 2, 1 }, + { 1, 2 }, { 3, 0 }, { 2, 1 }, { 0, 3 }, + { 2, 1 }, { 0, 3 }, { 1, 2 }, { 3, 0 }, + { 1, 2 }, { 3, 0 }, { 2, 1 }, { 0, 3 }, + { 2, 1 }, { 0, 3 }, { 1, 2 }, { 3, 0 }, + { 3, 0 }, { 1, 2 }, { 0, 3 }, { 2, 1 }, + { 0, 3 }, { 2, 1 }, { 3, 0 }, { 1, 2 }, + { 3, 0 }, { 1, 2 }, { 0, 3 }, { 2, 1 }, + { 0, 3 }, { 2, 1 }, { 3, 0 }, { 1, 2 }, + { 2, 1 }, { 0, 3 }, { 1, 2 }, { 3, 0 }, + { 1, 2 }, { 3, 0 }, { 2, 1 }, { 0, 3 }, + { 2, 1 }, { 0, 3 }, { 1, 2 }, { 3, 0 }, + { 1, 2 }, { 3, 0 }, { 2, 1 }, { 0, 3 }, +}; + +static const uint8_t wimax_fch_next_state[][2] = { + { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, + { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, + { 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 }, + { 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 }, + { 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 }, + { 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 }, + { 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 }, + { 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 }, + { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, + { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, + { 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 }, + { 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 }, + { 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 }, + { 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 }, + { 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 }, + { 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 }, +}; + +/* WiMax FCH */ +const struct osmo_conv_code wimax_conv_fch = { + .N = 2, + .K = 7, + .len = 48, + .term = CONV_TERM_TAIL_BITING, + .next_output = wimax_fch_next_output, + .next_state = wimax_fch_next_state, +}; + +static const uint8_t gmr1_tch3_speech_next_output[][2] = { + { 0, 3 }, { 1, 2 }, { 3, 0 }, { 2, 1 }, + { 3, 0 }, { 2, 1 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 3, 0 }, { 2, 1 }, + { 3, 0 }, { 2, 1 }, { 0, 3 }, { 1, 2 }, + { 2, 1 }, { 3, 0 }, { 1, 2 }, { 0, 3 }, + { 1, 2 }, { 0, 3 }, { 2, 1 }, { 3, 0 }, + { 2, 1 }, { 3, 0 }, { 1, 2 }, { 0, 3 }, + { 1, 2 }, { 0, 3 }, { 2, 1 }, { 3, 0 }, + { 3, 0 }, { 2, 1 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 3, 0 }, { 2, 1 }, + { 3, 0 }, { 2, 1 }, { 0, 3 }, { 1, 2 }, + { 0, 3 }, { 1, 2 }, { 3, 0 }, { 2, 1 }, + { 1, 2 }, { 0, 3 }, { 2, 1 }, { 3, 0 }, + { 2, 1 }, { 3, 0 }, { 1, 2 }, { 0, 3 }, + { 1, 2 }, { 0, 3 }, { 2, 1 }, { 3, 0 }, + { 2, 1 }, { 3, 0 }, { 1, 2 }, { 0, 3 }, +}; + +static const uint8_t gmr1_tch3_speech_next_state[][2] = { + { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, + { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, + { 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 }, + { 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 }, + { 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 }, + { 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 }, + { 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 }, + { 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 }, + { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, + { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, + { 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 }, + { 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 }, + { 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 }, + { 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 }, + { 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 }, + { 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 }, +}; + +static const int gmr1_tch3_speech_puncture[] = { + 3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, + 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, + -1, +}; + +/* GMR-1 TCH3 */ +const struct osmo_conv_code gmr1_conv_tch3_speech = { + .N = 2, + .K = 7, + .len = 48, + .term = CONV_TERM_TAIL_BITING, + .next_output = gmr1_tch3_speech_next_output, + .next_state = gmr1_tch3_speech_next_state, + .puncture = gmr1_tch3_speech_puncture, +}; + +static const uint8_t lte_pbch_next_output[][2] = { + { 0, 7 }, { 3, 4 }, { 7, 0 }, { 4 , 3 }, + { 6, 1 }, { 5, 2 }, { 1, 6 }, { 2 , 5 }, + { 1, 6 }, { 2, 5 }, { 6, 1 }, { 5 , 2 }, + { 7, 0 }, { 4, 3 }, { 0, 7 }, { 3 , 4 }, + { 4, 3 }, { 7, 0 }, { 3, 4 }, { 0 , 7 }, + { 2, 5 }, { 1, 6 }, { 5, 2 }, { 6 , 1 }, + { 5, 2 }, { 6, 1 }, { 2, 5 }, { 1 , 6 }, + { 3, 4 }, { 0, 7 }, { 4, 3 }, { 7 , 0 }, + { 7, 0 }, { 4, 3 }, { 0, 7 }, { 3 , 4 }, + { 1, 6 }, { 2, 5 }, { 6, 1 }, { 5 , 2 }, + { 6, 1 }, { 5, 2 }, { 1, 6 }, { 2 , 5 }, + { 0, 7 }, { 3, 4 }, { 7, 0 }, { 4 , 3 }, + { 3, 4 }, { 0, 7 }, { 4, 3 }, { 7 , 0 }, + { 5, 2 }, { 6, 1 }, { 2, 5 }, { 1 , 6 }, + { 2, 5 }, { 1, 6 }, { 5, 2 }, { 6 , 1 }, + { 4, 3 }, { 7, 0 }, { 3, 4 }, { 0 , 7 }, +}; + +static const uint8_t lte_pbch_next_state[][2] = { + { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, + { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, + { 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 }, + { 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 }, + { 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 }, + { 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 }, + { 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 }, + { 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 }, + { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, + { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, + { 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 }, + { 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 }, + { 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 }, + { 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 }, + { 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 }, + { 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 }, +}; + +/* LTE PBCH */ +const struct osmo_conv_code lte_conv_pbch = { + .N = 3, + .K = 7, + .len = 40, + .term = CONV_TERM_TAIL_BITING, + .next_output = lte_pbch_next_output, + .next_state = lte_pbch_next_state, +}; + +/* Truncated code */ +const struct osmo_conv_code conv_trunc = { + .N = 2, + .K = 5, + .len = 224, + .term = CONV_TERM_TRUNCATION, + .next_output = xcch_next_output, + .next_state = xcch_next_state, +}; diff --git a/tests/conv/codes.h b/tests/conv/codes.h new file mode 100644 index 0000000..e7c06cb --- /dev/null +++ b/tests/conv/codes.h @@ -0,0 +1,30 @@ +#ifndef TEST_CODES_H +#define TEST_CODES_H + +const struct osmo_conv_code gsm_conv_xcch; +const struct osmo_conv_code gsm_conv_cs2; +const struct osmo_conv_code gsm_conv_cs3; +const struct osmo_conv_code gsm_conv_rach; +const struct osmo_conv_code gsm_conv_sch; +const struct osmo_conv_code gsm_conv_tch_fr; +const struct osmo_conv_code gsm_conv_tch_hr; +const struct osmo_conv_code gsm_conv_tch_afs_12_2; +const struct osmo_conv_code gsm_conv_tch_afs_10_2; +const struct osmo_conv_code gsm_conv_tch_afs_7_95; +const struct osmo_conv_code gsm_conv_tch_afs_7_4; +const struct osmo_conv_code gsm_conv_tch_afs_6_7; +const struct osmo_conv_code gsm_conv_tch_afs_5_9; +const struct osmo_conv_code gsm_conv_tch_afs_5_15; +const struct osmo_conv_code gsm_conv_tch_afs_4_75; +const struct osmo_conv_code gsm_conv_tch_ahs_7_95; +const struct osmo_conv_code gsm_conv_tch_ahs_7_4; +const struct osmo_conv_code gsm_conv_tch_ahs_6_7; +const struct osmo_conv_code gsm_conv_tch_ahs_5_9; +const struct osmo_conv_code gsm_conv_tch_ahs_5_15; +const struct osmo_conv_code gsm_conv_tch_ahs_4_75; +const struct osmo_conv_code wimax_conv_fch; +const struct osmo_conv_code gmr1_conv_tch3_speech; +const struct osmo_conv_code lte_conv_pbch; +const struct osmo_conv_code conv_trunc; + +#endif /* TEST_CODES_H */ diff --git a/tests/conv/conv_test.c b/tests/conv/conv_test.c index d9440f9..89ffdb8 100644 --- a/tests/conv/conv_test.c +++ b/tests/conv/conv_test.c @@ -7,230 +7,10 @@ #include #include -#define MAX_LEN_BITS 512 -#define MAX_LEN_BYTES (512/8) - - -/* ------------------------------------------------------------------------ */ -/* Test codes */ -/* ------------------------------------------------------------------------ */ - -/* GSM xCCH -> Non-recursive code, flushed, not punctured */ -static const uint8_t conv_gsm_xcch_next_output[][2] = { - { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, - { 3, 0 }, { 2, 1 }, { 3, 0 }, { 2, 1 }, - { 3, 0 }, { 2, 1 }, { 3, 0 }, { 2, 1 }, - { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, -}; - -static const uint8_t conv_gsm_xcch_next_state[][2] = { - { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, - { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, - { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, - { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, -}; - -static const struct osmo_conv_code conv_gsm_xcch = { - .N = 2, - .K = 5, - .len = 224, - .term = CONV_TERM_FLUSH, - .next_output = conv_gsm_xcch_next_output, - .next_state = conv_gsm_xcch_next_state, -}; - - -/* GSM TCH/AFS 7.95 -> Recursive code, flushed, with puncturing */ -static const uint8_t conv_gsm_tch_afs_7_95_next_output[][2] = { - { 0, 7 }, { 3, 4 }, { 2, 5 }, { 1, 6 }, - { 2, 5 }, { 1, 6 }, { 0, 7 }, { 3, 4 }, - { 3, 4 }, { 0, 7 }, { 1, 6 }, { 2, 5 }, - { 1, 6 }, { 2, 5 }, { 3, 4 }, { 0, 7 }, - { 3, 4 }, { 0, 7 }, { 1, 6 }, { 2, 5 }, - { 1, 6 }, { 2, 5 }, { 3, 4 }, { 0, 7 }, - { 0, 7 }, { 3, 4 }, { 2, 5 }, { 1, 6 }, - { 2, 5 }, { 1, 6 }, { 0, 7 }, { 3, 4 }, - { 0, 7 }, { 3, 4 }, { 2, 5 }, { 1, 6 }, - { 2, 5 }, { 1, 6 }, { 0, 7 }, { 3, 4 }, - { 3, 4 }, { 0, 7 }, { 1, 6 }, { 2, 5 }, - { 1, 6 }, { 2, 5 }, { 3, 4 }, { 0, 7 }, - { 3, 4 }, { 0, 7 }, { 1, 6 }, { 2, 5 }, - { 1, 6 }, { 2, 5 }, { 3, 4 }, { 0, 7 }, - { 0, 7 }, { 3, 4 }, { 2, 5 }, { 1, 6 }, - { 2, 5 }, { 1, 6 }, { 0, 7 }, { 3, 4 }, -}; - -static const uint8_t conv_gsm_tch_afs_7_95_next_state[][2] = { - { 0, 1 }, { 2, 3 }, { 5, 4 }, { 7, 6 }, - { 9, 8 }, { 11, 10 }, { 12, 13 }, { 14, 15 }, - { 16, 17 }, { 18, 19 }, { 21, 20 }, { 23, 22 }, - { 25, 24 }, { 27, 26 }, { 28, 29 }, { 30, 31 }, - { 33, 32 }, { 35, 34 }, { 36, 37 }, { 38, 39 }, - { 40, 41 }, { 42, 43 }, { 45, 44 }, { 47, 46 }, - { 49, 48 }, { 51, 50 }, { 52, 53 }, { 54, 55 }, - { 56, 57 }, { 58, 59 }, { 61, 60 }, { 63, 62 }, - { 1, 0 }, { 3, 2 }, { 4, 5 }, { 6, 7 }, - { 8, 9 }, { 10, 11 }, { 13, 12 }, { 15, 14 }, - { 17, 16 }, { 19, 18 }, { 20, 21 }, { 22, 23 }, - { 24, 25 }, { 26, 27 }, { 29, 28 }, { 31, 30 }, - { 32, 33 }, { 34, 35 }, { 37, 36 }, { 39, 38 }, - { 41, 40 }, { 43, 42 }, { 44, 45 }, { 46, 47 }, - { 48, 49 }, { 50, 51 }, { 53, 52 }, { 55, 54 }, - { 57, 56 }, { 59, 58 }, { 60, 61 }, { 62, 63 }, -}; - -static const uint8_t conv_gsm_tch_afs_7_95_next_term_output[] = { - 0, 3, 5, 6, 5, 6, 0, 3, 3, 0, 6, 5, 6, 5, 3, 0, - 4, 7, 1, 2, 1, 2, 4, 7, 7, 4, 2, 1, 2, 1, 7, 4, - 7, 4, 2, 1, 2, 1, 7, 4, 4, 7, 1, 2, 1, 2, 4, 7, - 3, 0, 6, 5, 6, 5, 3, 0, 0, 3, 5, 6, 5, 6, 0, 3, -}; - -static const uint8_t conv_gsm_tch_afs_7_95_next_term_state[] = { - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, - 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, - 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, - 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, -}; - -static int conv_gsm_tch_afs_7_95_puncture[] = { - 1, 2, 4, 5, 8, 22, 70, 118, 166, 214, 262, 310, - 317, 319, 325, 332, 334, 341, 343, 349, 356, 358, 365, 367, - 373, 380, 382, 385, 389, 391, 397, 404, 406, 409, 413, 415, - 421, 428, 430, 433, 437, 439, 445, 452, 454, 457, 461, 463, - 469, 476, 478, 481, 485, 487, 490, 493, 500, 502, 503, 505, - 506, 508, 509, 511, 512, - -1, /* end */ -}; - -static const struct osmo_conv_code conv_gsm_tch_afs_7_95 = { - .N = 3, - .K = 7, - .len = 165, - .term = CONV_TERM_FLUSH, - .next_output = conv_gsm_tch_afs_7_95_next_output, - .next_state = conv_gsm_tch_afs_7_95_next_state, - .next_term_output = conv_gsm_tch_afs_7_95_next_term_output, - .next_term_state = conv_gsm_tch_afs_7_95_next_term_state, - .puncture = conv_gsm_tch_afs_7_95_puncture, -}; - - -/* GMR-1 TCH3 Speech -> Non recursive code, tail-biting, punctured */ -static const uint8_t conv_gmr1_tch3_speech_next_output[][2] = { - { 0, 3 }, { 1, 2 }, { 3, 0 }, { 2, 1 }, - { 3, 0 }, { 2, 1 }, { 0, 3 }, { 1, 2 }, - { 0, 3 }, { 1, 2 }, { 3, 0 }, { 2, 1 }, - { 3, 0 }, { 2, 1 }, { 0, 3 }, { 1, 2 }, - { 2, 1 }, { 3, 0 }, { 1, 2 }, { 0, 3 }, - { 1, 2 }, { 0, 3 }, { 2, 1 }, { 3, 0 }, - { 2, 1 }, { 3, 0 }, { 1, 2 }, { 0, 3 }, - { 1, 2 }, { 0, 3 }, { 2, 1 }, { 3, 0 }, - { 3, 0 }, { 2, 1 }, { 0, 3 }, { 1, 2 }, - { 0, 3 }, { 1, 2 }, { 3, 0 }, { 2, 1 }, - { 3, 0 }, { 2, 1 }, { 0, 3 }, { 1, 2 }, - { 0, 3 }, { 1, 2 }, { 3, 0 }, { 2, 1 }, - { 1, 2 }, { 0, 3 }, { 2, 1 }, { 3, 0 }, - { 2, 1 }, { 3, 0 }, { 1, 2 }, { 0, 3 }, - { 1, 2 }, { 0, 3 }, { 2, 1 }, { 3, 0 }, - { 2, 1 }, { 3, 0 }, { 1, 2 }, { 0, 3 }, -}; - -static const uint8_t conv_gmr1_tch3_speech_next_state[][2] = { - { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, - { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, - { 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 }, - { 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 }, - { 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 }, - { 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 }, - { 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 }, - { 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 }, - { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, - { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, - { 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 }, - { 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 }, - { 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 }, - { 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 }, - { 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 }, - { 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 }, -}; - -static const int conv_gmr1_tch3_speech_puncture[] = { - 3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, - 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, - -1, /* end */ -}; - -static const struct osmo_conv_code conv_gmr1_tch3_speech = { - .N = 2, - .K = 7, - .len = 48, - .term = CONV_TERM_TAIL_BITING, - .next_output = conv_gmr1_tch3_speech_next_output, - .next_state = conv_gmr1_tch3_speech_next_state, - .puncture = conv_gmr1_tch3_speech_puncture, -}; - - -/* WiMax FCH -> Non recursive code, tail-biting, non-punctured */ -static const uint8_t conv_wimax_fch_next_output[][2] = { - { 0, 3 }, { 2, 1 }, { 3, 0 }, { 1, 2 }, - { 3, 0 }, { 1, 2 }, { 0, 3 }, { 2, 1 }, - { 0, 3 }, { 2, 1 }, { 3, 0 }, { 1, 2 }, - { 3, 0 }, { 1, 2 }, { 0, 3 }, { 2, 1 }, - { 1, 2 }, { 3, 0 }, { 2, 1 }, { 0, 3 }, - { 2, 1 }, { 0, 3 }, { 1, 2 }, { 3, 0 }, - { 1, 2 }, { 3, 0 }, { 2, 1 }, { 0, 3 }, - { 2, 1 }, { 0, 3 }, { 1, 2 }, { 3, 0 }, - { 3, 0 }, { 1, 2 }, { 0, 3 }, { 2, 1 }, - { 0, 3 }, { 2, 1 }, { 3, 0 }, { 1, 2 }, - { 3, 0 }, { 1, 2 }, { 0, 3 }, { 2, 1 }, - { 0, 3 }, { 2, 1 }, { 3, 0 }, { 1, 2 }, - { 2, 1 }, { 0, 3 }, { 1, 2 }, { 3, 0 }, - { 1, 2 }, { 3, 0 }, { 2, 1 }, { 0, 3 }, - { 2, 1 }, { 0, 3 }, { 1, 2 }, { 3, 0 }, - { 1, 2 }, { 3, 0 }, { 2, 1 }, { 0, 3 }, -}; - -static const uint8_t conv_wimax_fch_next_state[][2] = { - { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, - { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, - { 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 }, - { 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 }, - { 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 }, - { 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 }, - { 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 }, - { 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 }, - { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, - { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, - { 16, 17 }, { 18, 19 }, { 20, 21 }, { 22, 23 }, - { 24, 25 }, { 26, 27 }, { 28, 29 }, { 30, 31 }, - { 32, 33 }, { 34, 35 }, { 36, 37 }, { 38, 39 }, - { 40, 41 }, { 42, 43 }, { 44, 45 }, { 46, 47 }, - { 48, 49 }, { 50, 51 }, { 52, 53 }, { 54, 55 }, - { 56, 57 }, { 58, 59 }, { 60, 61 }, { 62, 63 }, -}; - -static const struct osmo_conv_code conv_wimax_fch = { - .N = 2, - .K = 7, - .len = 48, - .term = CONV_TERM_TAIL_BITING, - .next_output = conv_wimax_fch_next_output, - .next_state = conv_wimax_fch_next_state, -}; - - -/* Random code -> Non recursive code, direct truncation, non-punctured */ -static const struct osmo_conv_code conv_trunc = { - .N = 2, - .K = 5, - .len = 224, - .term = CONV_TERM_TRUNCATION, - .next_output = conv_gsm_xcch_next_output, - .next_state = conv_gsm_xcch_next_state, -}; +#include "codes.h" +#define MAX_LEN_BITS 1024 +#define MAX_LEN_BYTES (1024/8) /* ------------------------------------------------------------------------ */ /* Test vectors */ @@ -249,7 +29,7 @@ struct conv_test_vector { static const struct conv_test_vector tests[] = { { .name = "GSM xCCH (non-recursive, flushed, not punctured)", - .code = &conv_gsm_xcch, + .code = &gsm_conv_xcch, .in_len = 224, .out_len = 456, .has_vec = 1, @@ -267,8 +47,62 @@ static const struct conv_test_vector tests[] = { 0x8f }, }, { + .name = "GPRS CS2 (non-recursive, flushed, not punctured)", + .code = &gsm_conv_cs2, + .in_len = 290, + .out_len = 588, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { + .name = "GPRS CS3 (non-recursive, flushed, not punctured)", + .code = &gsm_conv_cs3, + .in_len = 334, + .out_len = 676, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { + .name = "GSM RACH (non-recursive, flushed, not punctured)", + .code = &gsm_conv_rach, + .in_len = 14, + .out_len = 36, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { + .name = "GSM TCH/FR (non-recursive, flushed, not punctured)", + .code = &gsm_conv_tch_fr, + .in_len = 185, + .out_len = 378, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { + .name = "GSM TCH/AFS 12.2 (recursive, flushed, punctured)", + .code = &gsm_conv_tch_afs_12_2, + .in_len = 250, + .out_len = 448, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { + .name = "GSM TCH/AFS 10.2 (recursive, flushed, punctured)", + .code = &gsm_conv_tch_afs_10_2, + .in_len = 210, + .out_len = 448, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { .name = "GSM TCH/AFS 7.95 (recursive, flushed, punctured)", - .code = &conv_gsm_tch_afs_7_95, + .code = &gsm_conv_tch_afs_7_95, .in_len = 165, .out_len = 448, .has_vec = 1, @@ -284,8 +118,89 @@ static const struct conv_test_vector tests[] = { 0xa1, 0x5f, 0x45, 0x4a, 0xfb, 0xe6, 0x5a, 0x9c }, }, { + .name = "GSM TCH/AFS 7.4 (recursive, flushed, punctured)", + .code = &gsm_conv_tch_afs_7_4, + .in_len = 154, + .out_len = 448, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { + .name = "GSM TCH/AFS 6.7 (recursive, flushed, punctured)", + .code = &gsm_conv_tch_afs_6_7, + .in_len = 140, + .out_len = 448, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { + .name = "GSM TCH/AFS 5.9 (recursive, flushed, punctured)", + .code = &gsm_conv_tch_afs_5_9, + .in_len = 124, + .out_len = 448, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { + .name = "GSM TCH/AHS 7.95 (recursive, flushed, punctured)", + .code = &gsm_conv_tch_ahs_7_95, + .in_len = 129, + .out_len = 188, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { + .name = "GSM TCH/AHS 7.4 (recursive, flushed, punctured)", + .code = &gsm_conv_tch_ahs_7_4, + .in_len = 126, + .out_len = 196, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { + .name = "GSM TCH/AHS 6.7 (recursive, flushed, punctured)", + .code = &gsm_conv_tch_ahs_6_7, + .in_len = 116, + .out_len = 200, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { + .name = "GSM TCH/AHS 5.9 (recursive, flushed, punctured)", + .code = &gsm_conv_tch_ahs_5_9, + .in_len = 108, + .out_len = 208, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { + .name = "GSM TCH/AHS 5.15 (recursive, flushed, punctured)", + .code = &gsm_conv_tch_ahs_5_15, + .in_len = 97, + .out_len = 212, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { + .name = "GSM TCH/AHS 4.75 (recursive, flushed, punctured)", + .code = &gsm_conv_tch_ahs_4_75, + .in_len = 89, + .out_len = 212, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { .name = "GMR-1 TCH3 Speech (non-recursive, tail-biting, punctured)", - .code = &conv_gmr1_tch3_speech, + .code = &gmr1_conv_tch3_speech, .in_len = 48, .out_len = 72, .has_vec = 1, @@ -294,7 +209,7 @@ static const struct conv_test_vector tests[] = { }, { .name = "WiMax FCH (non-recursive, tail-biting, not punctured)", - .code = &conv_wimax_fch, + .code = &wimax_conv_fch, .in_len = 48, .out_len = 96, .has_vec = 1, @@ -303,6 +218,15 @@ static const struct conv_test_vector tests[] = { 0x8a, 0xed, 0x21, 0xed }, }, { + .name = "LTE PBCH (non-recursive, tail-biting, non-punctured)", + .code = <e_conv_pbch, + .in_len = 40, + .out_len = 120, + .has_vec = 0, + .vec_in = { }, + .vec_out = { }, + }, + { .name = "??? (non-recursive, direct truncation, not punctured)", .code = &conv_trunc, .in_len = 224, diff --git a/tests/conv/conv_test.ok b/tests/conv/conv_test.ok index 2122961..95ea671 100644 --- a/tests/conv/conv_test.ok +++ b/tests/conv/conv_test.ok @@ -9,6 +9,54 @@ [..] Encoding / Decoding cycle : OK [..] Encoding / Decoding cycle : OK +[+] Testing: GPRS CS2 (non-recursive, flushed, not punctured) +[.] Input length : ret = 290 exp = 290 -> OK +[.] Output length : ret = 588 exp = 588 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: GPRS CS3 (non-recursive, flushed, not punctured) +[.] Input length : ret = 334 exp = 334 -> OK +[.] Output length : ret = 676 exp = 676 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: GSM RACH (non-recursive, flushed, not punctured) +[.] Input length : ret = 14 exp = 14 -> OK +[.] Output length : ret = 36 exp = 36 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: GSM TCH/FR (non-recursive, flushed, not punctured) +[.] Input length : ret = 185 exp = 185 -> OK +[.] Output length : ret = 378 exp = 378 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: GSM TCH/AFS 12.2 (recursive, flushed, punctured) +[.] Input length : ret = 250 exp = 250 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: GSM TCH/AFS 10.2 (recursive, flushed, punctured) +[.] Input length : ret = 210 exp = 210 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + [+] Testing: GSM TCH/AFS 7.95 (recursive, flushed, punctured) [.] Input length : ret = 165 exp = 165 -> OK [.] Output length : ret = 448 exp = 448 -> OK @@ -20,6 +68,78 @@ [..] Encoding / Decoding cycle : OK [..] Encoding / Decoding cycle : OK +[+] Testing: GSM TCH/AFS 7.4 (recursive, flushed, punctured) +[.] Input length : ret = 154 exp = 154 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: GSM TCH/AFS 6.7 (recursive, flushed, punctured) +[.] Input length : ret = 140 exp = 140 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: GSM TCH/AFS 5.9 (recursive, flushed, punctured) +[.] Input length : ret = 124 exp = 124 -> OK +[.] Output length : ret = 448 exp = 448 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: GSM TCH/AHS 7.95 (recursive, flushed, punctured) +[.] Input length : ret = 129 exp = 129 -> OK +[.] Output length : ret = 188 exp = 188 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: GSM TCH/AHS 7.4 (recursive, flushed, punctured) +[.] Input length : ret = 126 exp = 126 -> OK +[.] Output length : ret = 196 exp = 196 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: GSM TCH/AHS 6.7 (recursive, flushed, punctured) +[.] Input length : ret = 116 exp = 116 -> OK +[.] Output length : ret = 200 exp = 200 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: GSM TCH/AHS 5.9 (recursive, flushed, punctured) +[.] Input length : ret = 108 exp = 108 -> OK +[.] Output length : ret = 208 exp = 208 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: GSM TCH/AHS 5.15 (recursive, flushed, punctured) +[.] Input length : ret = 97 exp = 97 -> OK +[.] Output length : ret = 212 exp = 212 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + +[+] Testing: GSM TCH/AHS 4.75 (recursive, flushed, punctured) +[.] Input length : ret = 89 exp = 89 -> OK +[.] Output length : ret = 212 exp = 212 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + [+] Testing: GMR-1 TCH3 Speech (non-recursive, tail-biting, punctured) [.] Input length : ret = 48 exp = 48 -> OK [.] Output length : ret = 72 exp = 72 -> OK @@ -42,6 +162,14 @@ [..] Encoding / Decoding cycle : OK [..] Encoding / Decoding cycle : OK +[+] Testing: LTE PBCH (non-recursive, tail-biting, non-punctured) +[.] Input length : ret = 40 exp = 40 -> OK +[.] Output length : ret = 120 exp = 120 -> OK +[.] Random vector checks: +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK +[..] Encoding / Decoding cycle : OK + [+] Testing: ??? (non-recursive, direct truncation, not punctured) [.] Input length : ret = 224 exp = 224 -> OK [.] Output length : ret = 448 exp = 448 -> OK