GNSS-SDR 0.0.21
An Open Source GNSS Software Defined Receiver
Loading...
Searching...
No Matches
ion_gsms_stream_encodings.h
Go to the documentation of this file.
1/*!
2 * \file ion_gsms_stream_encodings.h
3 * \brief Implements look up tables for all encodings in the standard
4 * \author Víctor Castillo Agüero, 2024. victorcastilloaguero(at)gmail.com
5 *
6 * These tables are taken from the stardard's official document.
7 *
8 * -----------------------------------------------------------------------------
9 *
10 * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
11 * This file is part of GNSS-SDR.
12 *
13 * Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors)
14 * SPDX-License-Identifier: GPL-3.0-or-later
15 *
16 * -----------------------------------------------------------------------------
17 */
18
19#ifndef GNSS_SDR_ION_GSMS_STREAM_ENCODINGS_H
20#define GNSS_SDR_ION_GSMS_STREAM_ENCODINGS_H
21
22#include <string>
23
24/** \addtogroup Signal_Source
25 * \{ */
26/** \addtogroup Signal_Source_libs
27 * \{ */
28
29namespace GnssMetadata
30{
31
32using StreamEncoding = unsigned char;
33
34namespace StreamEncodings
35{
36
37constexpr unsigned char SIGN = 0;
38constexpr unsigned char OB = 1;
39constexpr unsigned char SM = 2;
40constexpr unsigned char MS = 3;
41constexpr unsigned char TC = 4;
42constexpr unsigned char OG = 5;
43constexpr unsigned char OBA = 6;
44constexpr unsigned char SMA = 7;
45constexpr unsigned char MSA = 8;
46constexpr unsigned char TCA = 9;
47constexpr unsigned char OGA = 10;
48constexpr unsigned char FP = 11;
49
50} // namespace StreamEncodings
51
52inline StreamEncoding encoding_from_string(const std::string& str)
53{
54 if (str == "SIGN")
55 {
56 return StreamEncodings::SIGN;
57 }
58 if (str == "OB")
59 {
60 return StreamEncodings::OB;
61 }
62 if (str == "SM")
63 {
64 return StreamEncodings::SM;
65 }
66 if (str == "MS")
67 {
68 return StreamEncodings::MS;
69 }
70 if (str == "TC")
71 {
72 return StreamEncodings::TC;
73 }
74 if (str == "OG")
75 {
76 return StreamEncodings::OG;
77 }
78 if (str == "OBA")
79 {
80 return StreamEncodings::OBA;
81 }
82 if (str == "SMA")
83 {
84 return StreamEncodings::SMA;
85 }
86 if (str == "MSA")
87 {
88 return StreamEncodings::MSA;
89 }
90 if (str == "TCA")
91 {
92 return StreamEncodings::TCA;
93 }
94 if (str == "OGA")
95 {
96 return StreamEncodings::OGA;
97 }
98 if (str == "FP")
99 {
100 return StreamEncodings::FP;
101 }
102 return 0;
103}
104
105template <typename T>
106inline T two_bit_look_up[11][4]{
107 {}, // [0]
108 {-2, -1, 0, 1}, // [1 /*OB*/]
109 {0, 1, 0, -1}, // [2 /*SM*/]
110 {0, 0, 1, -1}, // [3 /*MS*/]
111 {0, 1, -2, -1}, // [4 /*TC*/]
112 {-2, -1, 1, 0}, // [5 /*OG*/]
113 {-3, -1, 1, 3}, // [6 /*OBA*/]
114 {1, 3, -1, -3}, // [7 /*SMA*/]
115 {1, -1, 3, -3}, // [8 /*MSA*/]
116 {1, 3, -3, -1}, // [9 /*TCA*/]
117 {-3, -1, 3, 1}, // [10 /*OGA*/]
118};
119
120template <typename T>
121inline T three_bit_look_up[11][8]{
122 {}, // [0]
123 {-4, -3, -2, -1, 0, 1, 2, 3}, // [1 /*OB*/]
124 {0, 1, 2, 3, 0, -1, -2, -3}, // [2 /*SM*/]
125 {0, 0, 1, -1, 0, 0, 1, -1}, // [3 /*MS*/]
126 {0, 1, 2, 3, -4, -3, -2, -1}, // [4 /*TC*/]
127 {-4, -3, -1, -2, 3, 2, 0, 1}, // [5 /*OG*/]
128 {-7, -5, -3, -1, 1, 3, 5, 7}, // [6 /*OBA*/]
129 {1, 3, 5, 7, -1, -3, -5, -7}, // [7 /*SMA*/]
130 {1, -1, 3, -3, 5, -5, 7, -7}, // [8 /*MSA*/]
131 {1, 3, 5, 7, -7, -5, -3, -1}, // [9 /*TCA*/]
132 {-7, -5, -1, -3, 7, 5, 1, 3}, // [10 /*OGA*/]
133};
134
135template <typename T>
136inline T four_bit_look_up[11][16]{
137 {}, // [0]
138 {-8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7}, // [1 /*OB*/]
139 {0, 1, 2, 3, 4, 5, 6, 7, 0, -1, -2, -3, -4, -5, -6, -7}, // [2 /*SM*/]
140 {0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1}, // [3 /*MS*/]
141 {0, 1, 2, 3, 4, 5, 6, 7, -8, -7, -6, -5, -4, -3, -2, -1}, // [4 /*TC*/]
142 {-8, -7, -5, -6, -1, -2, -4, -3, 7, 6, 4, 5, 0, 1, 3, 2}, // [5 /*OG*/]
143 {-15, -13, -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15}, // [6 /*OBA*/]
144 {1, 3, 5, 7, 9, 11, 13, 15, -1, -3, -5, -7, -9, -11, -13, -15}, // [7 /*SMA*/]
145 {1, -1, 3, -3, 5, -5, 7, -7, 9, -9, 11, -11, 13, -13, 15, -15}, // [8 /*MSA*/]
146 {1, 3, 5, 7, 9, 11, 13, 15, -15, -13, -11, -9, -7, -5, -3, -1}, // [9 /*TCA*/]
147 {-15, -13, -9, -11, -1, -3, -7, -5, 15, 13, 9, 11, 1, 3, 7, 5}, // [10 /*OGA*/]
148};
149
150template <typename T>
151inline T five_bit_look_up[11][32]{
152 {}, // [0]
153 {-16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, // [1 /*OB*/]
154 {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}, // [2 /*SM*/]
155 {0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1, 0, 0, 1, -1}, // [3 /*MS*/]
156 {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1}, // [4 /*TC*/]
157 {-16, -15, -13, -14, -9, -10, -12, -11, -1, -2, -4, -3, -8, -7, -5, -6, 15, 14, 12, 13, 8, 9, 11, 10, 0, 1, 3, 2, 7, 6, 4, 5}, // [5 /*OG*/]
158 {-31, -29, -27, -25, -23, -21, -19, -17, -15, -13, -11, -9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31}, // [6 /*OBA*/]
159 {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, -1, -3, -5, -7, -9, -11, -13, -15, -17, -19, -21, -23, -25, -27, -29, -31}, // [7 /*SMA*/]
160 {1, -1, 3, -3, 5, -5, 7, -7, 9, -9, 11, -11, 13, -13, 15, -15, 17, -17, 19, -19, 21, -21, 23, -23, 25, -25, 27, -27, 29, -29, 31, -31}, // [8 /*MSA*/]
161 {1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, -31, -29, -27, -25, -23, -21, -19, -17, -15, -13, -11, -9, -7, -5, -3, -1}, // [9 /*TCA*/]
162 {-31, -29, -25, -27, -17, -19, -23, -21, -1, -3, -7, -5, -15, -13, -9, -11, 31, 29, 25, 27, 17, 19, 23, 21, 1, 3, 7, 5, 15, 13, 9, 11}, // [10 /*OGA*/]
163};
164
165} // namespace GnssMetadata
166
167
168/** \} */
169/** \} */
170#endif // GNSS_SDR_ION_GSMS_STREAM_ENCODINGS_H