FreeCalypso > hg > ice1-trau-tester
comparison ater8/out_frame.c @ 42:ff94d7fc5891
new program itt-ater-8
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 30 Aug 2024 19:02:42 +0000 |
parents | ater/out_frame.c@bacc590ec839 |
children |
comparison
equal
deleted
inserted
replaced
41:50a72d4ff498 | 42:ff94d7fc5891 |
---|---|
1 /* | |
2 * Here we implement our TRAU-UL bit filling function for HRv1 8 kbit/s format. | |
3 * | |
4 * This code is based (very loosely) on trau_rtp_conv.c in libosmo-abis. | |
5 */ | |
6 | |
7 #include <stdint.h> | |
8 #include <stdbool.h> | |
9 #include <string.h> | |
10 | |
11 #include <osmocom/core/bits.h> | |
12 #include <osmocom/core/crc8gen.h> | |
13 #include <osmocom/core/utils.h> | |
14 #include <osmocom/trau/trau_frame.h> | |
15 #include "../libhr/tw_gsmhr.h" | |
16 | |
17 #include "out_frame.h" | |
18 | |
19 /* | |
20 * EFR TRAU parity (also used for HR) | |
21 * | |
22 * g(x) = x^3 + x^1 + 1 | |
23 */ | |
24 static const struct osmo_crc8gen_code gsm0860_efr_crc3 = { | |
25 .bits = 3, | |
26 .poly = 0x3, | |
27 .init = 0x0, | |
28 .remainder = 0x7, | |
29 }; | |
30 | |
31 void trau_frame_from_record(const int16_t *rec, struct osmo_trau_frame *tf, | |
32 bool *has_taf) | |
33 { | |
34 uint8_t ts101318[GSMHR_FRAME_LEN_RPF]; | |
35 int16_t bfi, sid; | |
36 | |
37 /* payload transformation is straightforward */ | |
38 gsmhr_pack_ts101318(rec, ts101318); | |
39 osmo_pbit2ubit(tf->d_bits, ts101318, 14 * 8); | |
40 osmo_crc8gen_set_bits(&gsm0860_efr_crc3, tf->d_bits, 44, tf->crc_bits); | |
41 | |
42 /* transformation of metadata flags is the messy part */ | |
43 bfi = rec[18]; | |
44 sid = rec[20]; | |
45 switch (sid) { | |
46 case 0: | |
47 if (bfi) { | |
48 tf->xc_bits[1] = 1; | |
49 tf->xc_bits[2] = 1; | |
50 *has_taf = true; | |
51 } else { | |
52 tf->xc_bits[1] = 0; | |
53 tf->xc_bits[2] = 0; | |
54 tf->xc_bits[3] = 0; | |
55 *has_taf = false; | |
56 } | |
57 break; | |
58 case 1: | |
59 tf->xc_bits[1] = 1; | |
60 tf->xc_bits[2] = 0; | |
61 *has_taf = true; | |
62 break; | |
63 case 2: | |
64 if (bfi) { | |
65 tf->xc_bits[1] = 1; | |
66 tf->xc_bits[2] = 0; | |
67 *has_taf = true; | |
68 } else { | |
69 tf->xc_bits[1] = 0; | |
70 tf->xc_bits[2] = 0; | |
71 tf->xc_bits[3] = 1; | |
72 *has_taf = false; | |
73 } | |
74 break; | |
75 default: | |
76 OSMO_ASSERT(0); | |
77 } | |
78 /* XC5 is always UFI */ | |
79 tf->xc_bits[4] = rec[19]; | |
80 } |