Ticket #1 - add software IMBE decoding to block.
git-svn-id: http://op25.osmocom.org/svn/trunk@173 65a5c917-d112-43f1-993d-58c26a4786be
This commit is contained in:
parent
f6fb14a119
commit
cc64164725
|
@ -72,15 +72,18 @@ _op25_la_SOURCES = \
|
|||
snapshot_du_handler.cc \
|
||||
sniffer_du_handler.cc \
|
||||
imbe_decoder.cc \
|
||||
imbe_decoder_factory.cc \
|
||||
dummy_imbe_decoder.cc \
|
||||
offline_imbe_decoder.cc \
|
||||
voice_data_unit.cc \
|
||||
voice_du_handler.cc \
|
||||
op25.cc \
|
||||
op25_decoder_ff.cc \
|
||||
software_imbe_decoder.cc \
|
||||
vc55_imbe_decoder.cc \
|
||||
value_string.cc
|
||||
|
||||
value_string.cc \
|
||||
golay.cc \
|
||||
hamming.cc
|
||||
|
||||
# magic flags
|
||||
_op25_la_LDFLAGS = $(NO_UNDEFINED) -module -avoid-version
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
#include "golay.h"
|
||||
|
||||
uint32_t
|
||||
golay_24_encode(uint32_t code_word_in)
|
||||
{
|
||||
static const uint32_t encoding[12] = {
|
||||
040006165,
|
||||
020003073,
|
||||
010007550,
|
||||
04003664,
|
||||
02001732,
|
||||
01006631,
|
||||
0403315,
|
||||
0201547,
|
||||
0106706,
|
||||
045227,
|
||||
024476,
|
||||
014353
|
||||
};
|
||||
|
||||
uint32_t code_word_out = 0;
|
||||
for(uint16_t i = 0; i < 12; i++) {
|
||||
uint32_t temp_word = code_word_in & (1 << (11 - i));
|
||||
if(temp_word >= 1) {
|
||||
code_word_out = code_word_out ^ encoding[i];
|
||||
}
|
||||
}
|
||||
return(code_word_out);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
golay_23_encode(uint32_t code_word_in)
|
||||
{
|
||||
return golay_24_encode(code_word_in) >> 1;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
golay_23_syndrome(uint32_t pattern)
|
||||
{
|
||||
uint32_t aux = 0x400000;
|
||||
while(pattern & 0xFFFFF800) {
|
||||
while((aux & pattern) == 0) {
|
||||
aux >>= 1;
|
||||
}
|
||||
pattern ^= (aux >> 11) * 0xC75;
|
||||
}
|
||||
return pattern;
|
||||
}
|
||||
|
||||
size_t
|
||||
golay_23_decode(uint32_t& cw)
|
||||
{
|
||||
static const uint32_t decoding[2048] = {
|
||||
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 147459,
|
||||
1, 2, 2, 3, 2, 3, 3, 4268035, 2, 3, 3, 1574915, 3, 2097155, 294915, 4099,
|
||||
1, 2, 2, 3, 2, 3, 3, 147459, 2, 3, 3, 147459, 3, 147459, 147459, 147458,
|
||||
2, 3, 3, 32771, 3, 2051, 3149827, 786435, 3, 274435, 4194307, 2162691, 589827, 5275651, 10243, 147459,
|
||||
1, 2, 2, 3, 2, 3, 3, 2621443, 2, 3, 3, 8195, 3, 1118211, 294915, 4196355,
|
||||
2, 3, 3, 135171, 3, 2051, 294915, 1064963, 3, 4210691, 294915, 2162691, 294915, 663555, 294914, 294915,
|
||||
2, 3, 3, 5505027, 3, 2051, 65539, 45059, 3, 557059, 6147, 2162691, 6299651, 262147, 1572867, 147459,
|
||||
3, 2051, 548867, 2162691, 2051, 2050, 4325379, 2051, 1179651, 2162691, 2162691, 2162690, 20483, 2051, 294915, 2162691,
|
||||
1, 2, 2, 3, 2, 3, 3, 2621443, 2, 3, 3, 327683, 3, 43011, 5242883, 4099,
|
||||
2, 3, 3, 32771, 3, 1441795, 18435, 4099, 3, 4210691, 2236419, 4099, 589827, 4099, 4099, 4098,
|
||||
2, 3, 3, 32771, 3, 4198403, 270339, 1116163, 3, 3145731, 6147, 4726787, 589827, 262147, 2129923, 147459,
|
||||
3, 32771, 32771, 32770, 589827, 2121731, 4325379, 32771, 589827, 133123, 1327107, 32771, 589826, 589827, 589827, 4099,
|
||||
2, 3, 3, 2621443, 3, 2621443, 2621443, 2621442, 3, 4210691, 6147, 1212419, 131075, 262147, 90115, 2621443,
|
||||
3, 4210691, 1114115, 272387, 12291, 98307, 4325379, 2621443, 4210691, 4210690, 524291, 4210691, 3147779, 4210691, 294915, 4099,
|
||||
3, 204803, 6147, 16387, 1097731, 262147, 4325379, 2621443, 6147, 262147, 6146, 6147, 262147, 262146, 6147, 262147,
|
||||
2359299, 1576963, 4325379, 32771, 4325379, 2051, 4325378, 4325379, 40963, 4210691, 6147, 2162691, 589827, 262147, 4325379, 1056771,
|
||||
1, 2, 2, 3, 2, 3, 3, 268291, 2, 3, 3, 8195, 3, 2097155, 5242883, 622595,
|
||||
2, 3, 3, 32771, 3, 2097155, 655363, 1064963, 3, 2097155, 86019, 4587523, 2097155, 2097154, 10243, 2097155,
|
||||
2, 3, 3, 32771, 3, 1581059, 65539, 6291459, 3, 4261891, 2883587, 1052675, 36867, 262147, 10243, 147459,
|
||||
3, 32771, 32771, 32770, 4472835, 200707, 10243, 32771, 1179651, 540675, 10243, 32771, 10243, 2097155, 10242, 10243,
|
||||
2, 3, 3, 8195, 3, 4358147, 65539, 1064963, 3, 8195, 8195, 8194, 542723, 262147, 2232323, 8195,
|
||||
3, 851971, 6293507, 1064963, 12291, 1064963, 1064963, 1064962, 1179651, 38915, 524291, 8195, 4259843, 2097155, 294915, 1064963,
|
||||
3, 2117635, 65539, 657411, 65539, 262147, 65538, 65539, 1179651, 262147, 4243459, 8195, 262147, 262146, 65539, 262147,
|
||||
1179651, 4202499, 266243, 32771, 2654211, 2051, 65539, 1064963, 1179650, 1179651, 1179651, 2162691, 1179651, 262147, 10243, 4722691,
|
||||
2, 3, 3, 32771, 3, 81923, 5242883, 139267, 3, 659459, 5242883, 2115587, 5242883, 262147, 5242882, 5242883,
|
||||
3, 32771, 32771, 32770, 12291, 4720643, 2424835, 32771, 264195, 1122307, 524291, 32771, 180227, 2097155, 5242883, 4099,
|
||||
3, 32771, 32771, 32770, 2230275, 262147, 544771, 32771, 24579, 262147, 196611, 32771, 262147, 262146, 5242883, 262147,
|
||||
32771, 32770, 32770, 32769, 1048579, 32771, 32771, 32770, 6295555, 32771, 32771, 32770, 589827, 262147, 10243, 32771,
|
||||
3, 1050627, 409603, 4263939, 12291, 262147, 34819, 2621443, 2195459, 262147, 524291, 8195, 262147, 262146, 5242883, 262147,
|
||||
12291, 2228227, 524291, 32771, 12290, 12291, 12291, 1064963, 524291, 4210691, 524290, 524291, 12291, 262147, 524291, 198659,
|
||||
4718595, 262147, 3153923, 32771, 262147, 262146, 65539, 262147, 262147, 262146, 6147, 262147, 262146, 262145, 262147, 262146,
|
||||
83971, 32771, 32771, 32770, 12291, 262147, 4325379, 32771, 1179651, 262147, 524291, 32771, 262147, 262146, 2113539, 262147,
|
||||
1, 2, 2, 3, 2, 3, 3, 1081347, 2, 3, 3, 327683, 3, 2097155, 536579, 4196355,
|
||||
2, 3, 3, 135171, 3, 2097155, 18435, 786435, 3, 2097155, 4194307, 57347, 2097155, 2097154, 1245187, 2097155,
|
||||
2, 3, 3, 2107395, 3, 4198403, 65539, 786435, 3, 557059, 4194307, 1052675, 1312771, 73731, 2129923, 147459,
|
||||
3, 1130499, 4194307, 786435, 172035, 786435, 786435, 786434, 4194307, 133123, 4194306, 4194307, 20483, 2097155, 4194307, 786435,
|
||||
2, 3, 3, 135171, 3, 286723, 65539, 4196355, 3, 557059, 3162115, 4196355, 131075, 4196355, 4196355, 4196354,
|
||||
3, 135171, 135171, 135170, 5767171, 98307, 2105347, 135171, 75779, 1310723, 524291, 135171, 20483, 2097155, 294915, 4196355,
|
||||
3, 557059, 65539, 16387, 65539, 3276803, 65538, 65539, 557059, 557058, 401411, 557059, 20483, 557059, 65539, 4196355,
|
||||
2359299, 4202499, 1083395, 135171, 20483, 2051, 65539, 786435, 20483, 557059, 4194307, 2162691, 20482, 20483, 20483, 1056771,
|
||||
2, 3, 3, 327683, 3, 4198403, 18435, 139267, 3, 327683, 327683, 327682, 131075, 1589251, 2129923, 327683,
|
||||
3, 532483, 18435, 7340035, 18435, 98307, 18434, 18435, 1085443, 133123, 524291, 327683, 4464643, 2097155, 18435, 4099,
|
||||
3, 4198403, 1703939, 16387, 4198403, 4198402, 2129923, 4198403, 24579, 133123, 2129923, 327683, 2129923, 4198403, 2129922, 2129923,
|
||||
2359299, 133123, 77827, 32771, 1048579, 4198403, 18435, 786435, 133123, 133122, 4194307, 133123, 589827, 133123, 2129923, 1056771,
|
||||
3, 1050627, 4235267, 16387, 131075, 98307, 1314819, 2621443, 131075, 2109443, 524291, 327683, 131074, 131075, 131075, 4196355,
|
||||
2359299, 98307, 524291, 135171, 98307, 98306, 18435, 98307, 524291, 4210691, 524290, 524291, 131075, 98307, 524291, 1056771,
|
||||
2359299, 16387, 16387, 16386, 534531, 4198403, 65539, 16387, 5308419, 557059, 6147, 16387, 131075, 262147, 2129923, 1056771,
|
||||
2359298, 2359299, 2359299, 16387, 2359299, 98307, 4325379, 1056771, 2359299, 133123, 524291, 1056771, 20483, 1056771, 1056771, 1056770,
|
||||
2, 3, 3, 4734979, 3, 2097155, 65539, 139267, 3, 2097155, 165891, 1052675, 2097155, 2097154, 278531, 2097155,
|
||||
3, 2097155, 1318915, 67587, 2097155, 2097154, 4231171, 2097155, 2097155, 2097154, 524291, 2097155, 2097154, 2097153, 2097155, 2097154,
|
||||
3, 393219, 65539, 1052675, 65539, 51203, 65538, 65539, 24579, 1052675, 1052675, 1052674, 4849667, 2097155, 65539, 1052675,
|
||||
530435, 4202499, 2244611, 32771, 1048579, 2097155, 65539, 786435, 360451, 2097155, 4194307, 1052675, 2097155, 2097154, 10243, 2097155,
|
||||
3, 1050627, 65539, 2392067, 65539, 528387, 65538, 65539, 4460547, 212995, 524291, 8195, 1089539, 2097155, 65539, 4196355,
|
||||
49155, 4202499, 524291, 135171, 395267, 2097155, 65539, 1064963, 524291, 2097155, 524290, 524291, 2097155, 2097154, 524291, 2097155,
|
||||
65539, 4202499, 65538, 65539, 65538, 65539, 65537, 65538, 2099203, 557059, 65539, 1052675, 65539, 262147, 65538, 65539,
|
||||
4202499, 4202498, 65539, 4202499, 65539, 4202499, 65538, 65539, 1179651, 4202499, 524291, 280579, 20483, 2097155, 65539, 163843,
|
||||
3, 1050627, 2101251, 139267, 819203, 139267, 139267, 139266, 24579, 4227075, 524291, 327683, 71683, 2097155, 5242883, 139267,
|
||||
4390915, 282627, 524291, 32771, 1048579, 2097155, 18435, 139267, 524291, 2097155, 524290, 524291, 2097155, 2097154, 524291, 2097155,
|
||||
24579, 2686979, 4458499, 32771, 1048579, 4198403, 65539, 139267, 24578, 24579, 24579, 1052675, 24579, 262147, 2129923, 526339,
|
||||
1048579, 32771, 32771, 32770, 1048578, 1048579, 1048579, 32771, 24579, 133123, 524291, 32771, 1048579, 2097155, 397315, 4276227,
|
||||
1050627, 1050626, 524291, 1050627, 6307843, 1050627, 65539, 139267, 524291, 1050627, 524290, 524291, 131075, 262147, 524291, 53251,
|
||||
524291, 1050627, 524290, 524291, 12291, 98307, 524291, 4456451, 524290, 524291, 524289, 524290, 524291, 2097155, 524290, 524291,
|
||||
167939, 1050627, 65539, 16387, 65539, 262147, 65538, 65539, 24579, 262147, 524291, 6422531, 262147, 262146, 65539, 262147,
|
||||
2359299, 4202499, 524291, 32771, 1048579, 671747, 65539, 2103299, 524291, 69635, 524290, 524291, 4229123, 262147, 524291, 1056771,
|
||||
1, 2, 2, 3, 2, 3, 3, 1081347, 2, 3, 3, 8195, 3, 4980739, 2164739, 4099,
|
||||
2, 3, 3, 2375683, 3, 2051, 655363, 4099, 3, 229379, 4194307, 4099, 1073155, 4099, 4099, 4098,
|
||||
2, 3, 3, 593923, 3, 2051, 270339, 6291459, 3, 3145731, 4194307, 296963, 36867, 73731, 1572867, 147459,
|
||||
3, 2051, 4194307, 1187843, 2051, 2050, 114691, 2051, 4194307, 540675, 4194306, 4194307, 2490371, 2051, 4194307, 4099,
|
||||
2, 3, 3, 8195, 3, 2051, 4214787, 458755, 3, 8195, 8195, 8194, 131075, 2146307, 1572867, 8195,
|
||||
3, 2051, 1114115, 4751363, 2051, 2050, 2105347, 2051, 2625539, 1310723, 149507, 8195, 4259843, 2051, 294915, 4099,
|
||||
3, 2051, 2260995, 16387, 2051, 2050, 1572867, 2051, 344067, 4329475, 1572867, 8195, 1572867, 2051, 1572866, 1572867,
|
||||
2051, 2050, 266243, 2051, 2050, 2049, 2051, 2050, 40963, 2051, 4194307, 2162691, 2051, 2050, 1572867, 2051,
|
||||
2, 3, 3, 4327427, 3, 81923, 270339, 4099, 3, 3145731, 573443, 4099, 131075, 4099, 4099, 4098,
|
||||
3, 532483, 1114115, 4099, 6324227, 4099, 4099, 4098, 264195, 4099, 4099, 4098, 4099, 4098, 4098, 4097,
|
||||
3, 3145731, 270339, 16387, 270339, 688131, 270338, 270339, 3145731, 3145730, 196611, 3145731, 4212739, 3145731, 270339, 4099,
|
||||
151555, 4521987, 2623491, 32771, 1048579, 2051, 270339, 4099, 40963, 3145731, 4194307, 4099, 589827, 4099, 4099, 4098,
|
||||
3, 299011, 1114115, 16387, 131075, 5251075, 34819, 2621443, 131075, 591875, 6553603, 8195, 131074, 131075, 131075, 4099,
|
||||
1114115, 2228227, 1114114, 1114115, 802819, 2051, 1114115, 4099, 40963, 4210691, 1114115, 4099, 131075, 4099, 4099, 4098,
|
||||
4718595, 16387, 16387, 16386, 2166787, 2051, 270339, 16387, 40963, 3145731, 6147, 16387, 131075, 262147, 1572867, 4292611,
|
||||
40963, 2051, 1114115, 16387, 2051, 2050, 4325379, 2051, 40962, 40963, 40963, 917507, 40963, 2051, 2113539, 4099,
|
||||
2, 3, 3, 8195, 3, 81923, 655363, 6291459, 3, 8195, 8195, 8194, 36867, 1181699, 278531, 8195,
|
||||
3, 5246979, 655363, 67587, 655363, 303107, 655362, 655363, 264195, 540675, 3178499, 8195, 4259843, 2097155, 655363, 4099,
|
||||
3, 393219, 1067011, 6291459, 36867, 6291459, 6291459, 6291458, 36867, 540675, 196611, 8195, 36866, 36867, 36867, 6291459,
|
||||
2170883, 540675, 266243, 32771, 1048579, 2051, 655363, 6291459, 540675, 540674, 4194307, 540675, 36867, 540675, 10243, 1376259,
|
||||
3, 8195, 8195, 8194, 3407875, 528387, 34819, 8195, 8195, 8194, 8194, 8193, 4259843, 8195, 8195, 8194,
|
||||
49155, 2228227, 266243, 8195, 4259843, 2051, 655363, 1064963, 4259843, 8195, 8195, 8194, 4259842, 4259843, 4259843, 8195,
|
||||
4718595, 1146883, 266243, 8195, 155651, 2051, 65539, 6291459, 2099203, 8195, 8195, 8194, 36867, 262147, 1572867, 8195,
|
||||
266243, 2051, 266242, 266243, 2051, 2050, 266243, 2051, 1179651, 540675, 266243, 8195, 4259843, 2051, 2113539, 163843,
|
||||
3, 81923, 2101251, 1835011, 81923, 81922, 34819, 81923, 264195, 4227075, 196611, 8195, 2629635, 81923, 5242883, 4099,
|
||||
264195, 2228227, 4218883, 32771, 1048579, 81923, 655363, 4099, 264194, 264195, 264195, 4099, 264195, 4099, 4099, 4098,
|
||||
4718595, 14339, 196611, 32771, 1048579, 81923, 270339, 6291459, 196611, 3145731, 196610, 196611, 36867, 262147, 196611, 526339,
|
||||
1048579, 32771, 32771, 32770, 1048578, 1048579, 1048579, 32771, 264195, 540675, 196611, 32771, 1048579, 4333571, 2113539, 4099,
|
||||
4718595, 2228227, 34819, 8195, 34819, 81923, 34818, 34819, 1069059, 8195, 8195, 8194, 131075, 262147, 34819, 8195,
|
||||
2228227, 2228226, 1114115, 2228227, 12291, 2228227, 34819, 4456451, 264195, 2228227, 524291, 8195, 4259843, 1605635, 2113539, 4099,
|
||||
4718594, 4718595, 4718595, 16387, 4718595, 262147, 34819, 1183747, 4718595, 262147, 196611, 8195, 262147, 262146, 2113539, 262147,
|
||||
4718595, 2228227, 266243, 32771, 1048579, 2051, 2113539, 598019, 40963, 69635, 2113539, 5244931, 2113539, 262147, 2113538, 2113539,
|
||||
2, 3, 3, 1081347, 3, 1081347, 1081347, 1081346, 3, 22531, 4194307, 2752515, 131075, 73731, 278531, 1081347,
|
||||
3, 532483, 4194307, 67587, 331779, 4341763, 2105347, 1081347, 4194307, 1310723, 4194306, 4194307, 559107, 2097155, 4194307, 4099,
|
||||
3, 393219, 4194307, 16387, 2637827, 73731, 137219, 1081347, 4194307, 73731, 4194306, 4194307, 73731, 73730, 4194307, 73731,
|
||||
4194307, 2134019, 4194306, 4194307, 1048579, 2051, 4194307, 786435, 4194306, 4194307, 4194305, 4194306, 4194307, 73731, 4194306, 4194307,
|
||||
3, 6356995, 788483, 16387, 131075, 528387, 2105347, 1081347, 131075, 1310723, 102403, 8195, 131074, 131075, 131075, 4196355,
|
||||
49155, 1310723, 2105347, 135171, 2105347, 2051, 2105346, 2105347, 1310723, 1310722, 4194307, 1310723, 131075, 1310723, 2105347, 606211,
|
||||
1060867, 16387, 16387, 16386, 4489219, 2051, 65539, 16387, 2099203, 557059, 4194307, 16387, 131075, 73731, 1572867, 2363395,
|
||||
720899, 2051, 4194307, 16387, 2051, 2050, 2105347, 2051, 4194307, 1310723, 4194306, 4194307, 20483, 2051, 4194307, 163843,
|
||||
3, 532483, 2101251, 16387, 131075, 2361347, 4784131, 1081347, 131075, 4227075, 1058819, 327683, 131074, 131075, 131075, 4099,
|
||||
532483, 532482, 425987, 532483, 1048579, 532483, 18435, 4099, 2179075, 532483, 4194307, 4099, 131075, 4099, 4099, 4098,
|
||||
100355, 16387, 16387, 16386, 1048579, 4198403, 270339, 16387, 790531, 3145731, 4194307, 16387, 131075, 73731, 2129923, 526339,
|
||||
1048579, 532483, 4194307, 16387, 1048578, 1048579, 1048579, 2293763, 4194307, 133123, 4194306, 4194307, 1048579, 311299, 4194307, 4099,
|
||||
131075, 16387, 16387, 16386, 131074, 131075, 131075, 16387, 131074, 131075, 131075, 16387, 131073, 131074, 131074, 131075,
|
||||
4200451, 532483, 1114115, 16387, 131075, 98307, 2105347, 4456451, 131075, 1310723, 524291, 2131971, 131074, 131075, 131075, 4099,
|
||||
16387, 16386, 16386, 16385, 131075, 16387, 16387, 16386, 131075, 16387, 16387, 16386, 131074, 131075, 131075, 16387,
|
||||
2359299, 16387, 16387, 16386, 1048579, 2051, 561155, 16387, 40963, 69635, 4194307, 16387, 131075, 6815747, 329731, 1056771,
|
||||
3, 393219, 2101251, 67587, 4204547, 528387, 278531, 1081347, 1638403, 4227075, 278531, 8195, 278531, 2097155, 278530, 278531,
|
||||
49155, 67587, 67587, 67586, 1048579, 2097155, 655363, 67587, 143363, 2097155, 4194307, 67587, 2097155, 2097154, 278531, 2097155,
|
||||
393219, 393218, 565251, 393219, 1048579, 393219, 65539, 6291459, 2099203, 393219, 4194307, 1052675, 36867, 73731, 278531, 526339,
|
||||
1048579, 393219, 4194307, 67587, 1048578, 1048579, 1048579, 28675, 4194307, 540675, 4194306, 4194307, 1048579, 2097155, 4194307, 163843,
|
||||
49155, 528387, 5373955, 8195, 528387, 528386, 65539, 528387, 2099203, 8195, 8195, 8194, 131075, 528387, 278531, 8195,
|
||||
49154, 49155, 49155, 67587, 49155, 528387, 2105347, 4456451, 49155, 1310723, 524291, 8195, 4259843, 2097155, 1054723, 163843,
|
||||
2099203, 393219, 65539, 16387, 65539, 528387, 65538, 65539, 2099202, 2099203, 2099203, 8195, 2099203, 5259267, 65539, 163843,
|
||||
49155, 4202499, 266243, 3670019, 1048579, 2051, 65539, 163843, 2099203, 69635, 4194307, 163843, 794627, 163843, 163843, 163842,
|
||||
2101251, 4227075, 2101250, 2101251, 1048579, 81923, 2101251, 139267, 4227075, 4227074, 2101251, 4227075, 131075, 4227075, 278531, 526339,
|
||||
1048579, 532483, 2101251, 67587, 1048578, 1048579, 1048579, 4456451, 264195, 4227075, 524291, 1196035, 1048579, 2097155, 106499, 4099,
|
||||
1048579, 393219, 2101251, 16387, 1048578, 1048579, 1048579, 526339, 24579, 4227075, 196611, 526339, 1048579, 526339, 526339, 526338,
|
||||
1048578, 1048579, 1048579, 32771, 1048577, 1048578, 1048578, 1048579, 1048579, 69635, 4194307, 2367491, 1048578, 1048579, 1048579, 526339,
|
||||
335875, 1050627, 2101251, 16387, 131075, 528387, 34819, 4456451, 131075, 4227075, 524291, 8195, 131074, 131075, 131075, 3211267,
|
||||
49155, 2228227, 524291, 4456451, 1048579, 4456451, 4456451, 4456450, 524291, 69635, 524290, 524291, 131075, 26627, 524291, 4456451,
|
||||
4718595, 16387, 16387, 16386, 1048579, 2138115, 65539, 16387, 2099203, 69635, 1343491, 16387, 131075, 262147, 4206595, 526339,
|
||||
1048579, 69635, 141315, 16387, 1048578, 1048579, 1048579, 4456451, 69635, 69634, 524291, 69635, 1048579, 69635, 2113539, 163843
|
||||
};
|
||||
|
||||
cw &= 0x007fffff;
|
||||
unsigned int correction = decoding[golay_23_syndrome(cw)];
|
||||
cw ^= correction;
|
||||
cw >>= 11;
|
||||
return correction & 3;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef INCLUDED_GOLAY_H
|
||||
#define INCLUDED_GOLAY_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <stdint.h>
|
||||
|
||||
/* APCO Golay(23,11,7) ecoder.
|
||||
*
|
||||
* \param val The 12-bit value to encode.
|
||||
* \return The encoded codeword.
|
||||
*/
|
||||
extern uint32_t golay_23_encode(uint32_t);
|
||||
|
||||
/* APCO Golay(23,11,7) decoder.
|
||||
*
|
||||
* \param cw The 23-bit codeword to decode.
|
||||
* \return The number of errors detected.
|
||||
*/
|
||||
extern size_t golay_23_decode(uint32_t& cw);
|
||||
|
||||
#endif /* INCLUDED_GOLAY_H */
|
|
@ -0,0 +1,168 @@
|
|||
#include "hamming.h"
|
||||
|
||||
uint16_t
|
||||
hamming_15_encode(uint16_t code_word_in)
|
||||
{
|
||||
static long int encoding[11] = {
|
||||
0x400f, 0x200e, 0x100d, 0x080c, 0x040b, 0x020a, 0x0109,
|
||||
0x0087, 0x0046, 0x0025, 0x0013
|
||||
};
|
||||
|
||||
uint16_t code_word_out = 0u;
|
||||
for(uint8_t i = 0; i < 11; ++i) {
|
||||
if(code_word_in & (1u << (10 - i))) {
|
||||
code_word_out ^= encoding[i];
|
||||
}
|
||||
}
|
||||
return code_word_out;
|
||||
}
|
||||
|
||||
size_t
|
||||
hamming_15_decode(uint16_t& cw)
|
||||
{
|
||||
static const int encoding[2048] = {
|
||||
0, 3, 5, 6, 6, 5, 3, 0, 7, 4, 2, 1, 1, 2, 4, 7,
|
||||
9, 10, 12, 15, 15, 12, 10, 9, 14, 13, 11, 8, 8, 11, 13, 14,
|
||||
10, 9, 15, 12, 12, 15, 9, 10, 13, 14, 8, 11, 11, 8, 14, 13,
|
||||
3, 0, 6, 5, 5, 6, 0, 3, 4, 7, 1, 2, 2, 1, 7, 4,
|
||||
11, 8, 14, 13, 13, 14, 8, 11, 12, 15, 9, 10, 10, 9, 15, 12,
|
||||
2, 1, 7, 4, 4, 7, 1, 2, 5, 6, 0, 3, 3, 0, 6, 5,
|
||||
1, 2, 4, 7, 7, 4, 2, 1, 6, 5, 3, 0, 0, 3, 5, 6,
|
||||
8, 11, 13, 14, 14, 13, 11, 8, 15, 12, 10, 9, 9, 10, 12, 15,
|
||||
12, 15, 9, 10, 10, 9, 15, 12, 11, 8, 14, 13, 13, 14, 8, 11,
|
||||
5, 6, 0, 3, 3, 0, 6, 5, 2, 1, 7, 4, 4, 7, 1, 2,
|
||||
6, 5, 3, 0, 0, 3, 5, 6, 1, 2, 4, 7, 7, 4, 2, 1,
|
||||
15, 12, 10, 9, 9, 10, 12, 15, 8, 11, 13, 14, 14, 13, 11, 8,
|
||||
7, 4, 2, 1, 1, 2, 4, 7, 0, 3, 5, 6, 6, 5, 3, 0,
|
||||
14, 13, 11, 8, 8, 11, 13, 14, 9, 10, 12, 15, 15, 12, 10, 9,
|
||||
13, 14, 8, 11, 11, 8, 14, 13, 10, 9, 15, 12, 12, 15, 9, 10,
|
||||
4, 7, 1, 2, 2, 1, 7, 4, 3, 0, 6, 5, 5, 6, 0, 3,
|
||||
13, 14, 8, 11, 11, 8, 14, 13, 10, 9, 15, 12, 12, 15, 9, 10,
|
||||
4, 7, 1, 2, 2, 1, 7, 4, 3, 0, 6, 5, 5, 6, 0, 3,
|
||||
7, 4, 2, 1, 1, 2, 4, 7, 0, 3, 5, 6, 6, 5, 3, 0,
|
||||
14, 13, 11, 8, 8, 11, 13, 14, 9, 10, 12, 15, 15, 12, 10, 9,
|
||||
6, 5, 3, 0, 0, 3, 5, 6, 1, 2, 4, 7, 7, 4, 2, 1,
|
||||
15, 12, 10, 9, 9, 10, 12, 15, 8, 11, 13, 14, 14, 13, 11, 8,
|
||||
12, 15, 9, 10, 10, 9, 15, 12, 11, 8, 14, 13, 13, 14, 8, 11,
|
||||
5, 6, 0, 3, 3, 0, 6, 5, 2, 1, 7, 4, 4, 7, 1, 2,
|
||||
1, 2, 4, 7, 7, 4, 2, 1, 6, 5, 3, 0, 0, 3, 5, 6,
|
||||
8, 11, 13, 14, 14, 13, 11, 8, 15, 12, 10, 9, 9, 10, 12, 15,
|
||||
11, 8, 14, 13, 13, 14, 8, 11, 12, 15, 9, 10, 10, 9, 15, 12,
|
||||
2, 1, 7, 4, 4, 7, 1, 2, 5, 6, 0, 3, 3, 0, 6, 5,
|
||||
10, 9, 15, 12, 12, 15, 9, 10, 13, 14, 8, 11, 11, 8, 14, 13,
|
||||
3, 0, 6, 5, 5, 6, 0, 3, 4, 7, 1, 2, 2, 1, 7, 4,
|
||||
0, 3, 5, 6, 6, 5, 3, 0, 7, 4, 2, 1, 1, 2, 4, 7,
|
||||
9, 10, 12, 15, 15, 12, 10, 9, 14, 13, 11, 8, 8, 11, 13, 14,
|
||||
14, 13, 11, 8, 8, 11, 13, 14, 9, 10, 12, 15, 15, 12, 10, 9,
|
||||
7, 4, 2, 1, 1, 2, 4, 7, 0, 3, 5, 6, 6, 5, 3, 0,
|
||||
4, 7, 1, 2, 2, 1, 7, 4, 3, 0, 6, 5, 5, 6, 0, 3,
|
||||
13, 14, 8, 11, 11, 8, 14, 13, 10, 9, 15, 12, 12, 15, 9, 10,
|
||||
5, 6, 0, 3, 3, 0, 6, 5, 2, 1, 7, 4, 4, 7, 1, 2,
|
||||
12, 15, 9, 10, 10, 9, 15, 12, 11, 8, 14, 13, 13, 14, 8, 11,
|
||||
15, 12, 10, 9, 9, 10, 12, 15, 8, 11, 13, 14, 14, 13, 11, 8,
|
||||
6, 5, 3, 0, 0, 3, 5, 6, 1, 2, 4, 7, 7, 4, 2, 1,
|
||||
2, 1, 7, 4, 4, 7, 1, 2, 5, 6, 0, 3, 3, 0, 6, 5,
|
||||
11, 8, 14, 13, 13, 14, 8, 11, 12, 15, 9, 10, 10, 9, 15, 12,
|
||||
8, 11, 13, 14, 14, 13, 11, 8, 15, 12, 10, 9, 9, 10, 12, 15,
|
||||
1, 2, 4, 7, 7, 4, 2, 1, 6, 5, 3, 0, 0, 3, 5, 6,
|
||||
9, 10, 12, 15, 15, 12, 10, 9, 14, 13, 11, 8, 8, 11, 13, 14,
|
||||
0, 3, 5, 6, 6, 5, 3, 0, 7, 4, 2, 1, 1, 2, 4, 7,
|
||||
3, 0, 6, 5, 5, 6, 0, 3, 4, 7, 1, 2, 2, 1, 7, 4,
|
||||
10, 9, 15, 12, 12, 15, 9, 10, 13, 14, 8, 11, 11, 8, 14, 13,
|
||||
3, 0, 6, 5, 5, 6, 0, 3, 4, 7, 1, 2, 2, 1, 7, 4,
|
||||
10, 9, 15, 12, 12, 15, 9, 10, 13, 14, 8, 11, 11, 8, 14, 13,
|
||||
9, 10, 12, 15, 15, 12, 10, 9, 14, 13, 11, 8, 8, 11, 13, 14,
|
||||
0, 3, 5, 6, 6, 5, 3, 0, 7, 4, 2, 1, 1, 2, 4, 7,
|
||||
8, 11, 13, 14, 14, 13, 11, 8, 15, 12, 10, 9, 9, 10, 12, 15,
|
||||
1, 2, 4, 7, 7, 4, 2, 1, 6, 5, 3, 0, 0, 3, 5, 6,
|
||||
2, 1, 7, 4, 4, 7, 1, 2, 5, 6, 0, 3, 3, 0, 6, 5,
|
||||
11, 8, 14, 13, 13, 14, 8, 11, 12, 15, 9, 10, 10, 9, 15, 12,
|
||||
15, 12, 10, 9, 9, 10, 12, 15, 8, 11, 13, 14, 14, 13, 11, 8,
|
||||
6, 5, 3, 0, 0, 3, 5, 6, 1, 2, 4, 7, 7, 4, 2, 1,
|
||||
5, 6, 0, 3, 3, 0, 6, 5, 2, 1, 7, 4, 4, 7, 1, 2,
|
||||
12, 15, 9, 10, 10, 9, 15, 12, 11, 8, 14, 13, 13, 14, 8, 11,
|
||||
4, 7, 1, 2, 2, 1, 7, 4, 3, 0, 6, 5, 5, 6, 0, 3,
|
||||
13, 14, 8, 11, 11, 8, 14, 13, 10, 9, 15, 12, 12, 15, 9, 10,
|
||||
14, 13, 11, 8, 8, 11, 13, 14, 9, 10, 12, 15, 15, 12, 10, 9,
|
||||
7, 4, 2, 1, 1, 2, 4, 7, 0, 3, 5, 6, 6, 5, 3, 0,
|
||||
15, 12, 10, 9, 9, 10, 12, 15, 8, 11, 13, 14, 14, 13, 11, 8,
|
||||
6, 5, 3, 0, 0, 3, 5, 6, 1, 2, 4, 7, 7, 4, 2, 1,
|
||||
5, 6, 0, 3, 3, 0, 6, 5, 2, 1, 7, 4, 4, 7, 1, 2,
|
||||
12, 15, 9, 10, 10, 9, 15, 12, 11, 8, 14, 13, 13, 14, 8, 11,
|
||||
4, 7, 1, 2, 2, 1, 7, 4, 3, 0, 6, 5, 5, 6, 0, 3,
|
||||
13, 14, 8, 11, 11, 8, 14, 13, 10, 9, 15, 12, 12, 15, 9, 10,
|
||||
14, 13, 11, 8, 8, 11, 13, 14, 9, 10, 12, 15, 15, 12, 10, 9,
|
||||
7, 4, 2, 1, 1, 2, 4, 7, 0, 3, 5, 6, 6, 5, 3, 0,
|
||||
3, 0, 6, 5, 5, 6, 0, 3, 4, 7, 1, 2, 2, 1, 7, 4,
|
||||
10, 9, 15, 12, 12, 15, 9, 10, 13, 14, 8, 11, 11, 8, 14, 13,
|
||||
9, 10, 12, 15, 15, 12, 10, 9, 14, 13, 11, 8, 8, 11, 13, 14,
|
||||
0, 3, 5, 6, 6, 5, 3, 0, 7, 4, 2, 1, 1, 2, 4, 7,
|
||||
8, 11, 13, 14, 14, 13, 11, 8, 15, 12, 10, 9, 9, 10, 12, 15,
|
||||
1, 2, 4, 7, 7, 4, 2, 1, 6, 5, 3, 0, 0, 3, 5, 6,
|
||||
2, 1, 7, 4, 4, 7, 1, 2, 5, 6, 0, 3, 3, 0, 6, 5,
|
||||
11, 8, 14, 13, 13, 14, 8, 11, 12, 15, 9, 10, 10, 9, 15, 12,
|
||||
2, 1, 7, 4, 4, 7, 1, 2, 5, 6, 0, 3, 3, 0, 6, 5,
|
||||
11, 8, 14, 13, 13, 14, 8, 11, 12, 15, 9, 10, 10, 9, 15, 12,
|
||||
8, 11, 13, 14, 14, 13, 11, 8, 15, 12, 10, 9, 9, 10, 12, 15,
|
||||
1, 2, 4, 7, 7, 4, 2, 1, 6, 5, 3, 0, 0, 3, 5, 6,
|
||||
9, 10, 12, 15, 15, 12, 10, 9, 14, 13, 11, 8, 8, 11, 13, 14,
|
||||
0, 3, 5, 6, 6, 5, 3, 0, 7, 4, 2, 1, 1, 2, 4, 7,
|
||||
3, 0, 6, 5, 5, 6, 0, 3, 4, 7, 1, 2, 2, 1, 7, 4,
|
||||
10, 9, 15, 12, 12, 15, 9, 10, 13, 14, 8, 11, 11, 8, 14, 13,
|
||||
14, 13, 11, 8, 8, 11, 13, 14, 9, 10, 12, 15, 15, 12, 10, 9,
|
||||
7, 4, 2, 1, 1, 2, 4, 7, 0, 3, 5, 6, 6, 5, 3, 0,
|
||||
4, 7, 1, 2, 2, 1, 7, 4, 3, 0, 6, 5, 5, 6, 0, 3,
|
||||
13, 14, 8, 11, 11, 8, 14, 13, 10, 9, 15, 12, 12, 15, 9, 10,
|
||||
5, 6, 0, 3, 3, 0, 6, 5, 2, 1, 7, 4, 4, 7, 1, 2,
|
||||
12, 15, 9, 10, 10, 9, 15, 12, 11, 8, 14, 13, 13, 14, 8, 11,
|
||||
15, 12, 10, 9, 9, 10, 12, 15, 8, 11, 13, 14, 14, 13, 11, 8,
|
||||
6, 5, 3, 0, 0, 3, 5, 6, 1, 2, 4, 7, 7, 4, 2, 1,
|
||||
1, 2, 4, 7, 7, 4, 2, 1, 6, 5, 3, 0, 0, 3, 5, 6,
|
||||
8, 11, 13, 14, 14, 13, 11, 8, 15, 12, 10, 9, 9, 10, 12, 15,
|
||||
11, 8, 14, 13, 13, 14, 8, 11, 12, 15, 9, 10, 10, 9, 15, 12,
|
||||
2, 1, 7, 4, 4, 7, 1, 2, 5, 6, 0, 3, 3, 0, 6, 5,
|
||||
10, 9, 15, 12, 12, 15, 9, 10, 13, 14, 8, 11, 11, 8, 14, 13,
|
||||
3, 0, 6, 5, 5, 6, 0, 3, 4, 7, 1, 2, 2, 1, 7, 4,
|
||||
0, 3, 5, 6, 6, 5, 3, 0, 7, 4, 2, 1, 1, 2, 4, 7,
|
||||
9, 10, 12, 15, 15, 12, 10, 9, 14, 13, 11, 8, 8, 11, 13, 14,
|
||||
13, 14, 8, 11, 11, 8, 14, 13, 10, 9, 15, 12, 12, 15, 9, 10,
|
||||
4, 7, 1, 2, 2, 1, 7, 4, 3, 0, 6, 5, 5, 6, 0, 3,
|
||||
7, 4, 2, 1, 1, 2, 4, 7, 0, 3, 5, 6, 6, 5, 3, 0,
|
||||
14, 13, 11, 8, 8, 11, 13, 14, 9, 10, 12, 15, 15, 12, 10, 9,
|
||||
6, 5, 3, 0, 0, 3, 5, 6, 1, 2, 4, 7, 7, 4, 2, 1,
|
||||
15, 12, 10, 9, 9, 10, 12, 15, 8, 11, 13, 14, 14, 13, 11, 8,
|
||||
12, 15, 9, 10, 10, 9, 15, 12, 11, 8, 14, 13, 13, 14, 8, 11,
|
||||
5, 6, 0, 3, 3, 0, 6, 5, 2, 1, 7, 4, 4, 7, 1, 2,
|
||||
12, 15, 9, 10, 10, 9, 15, 12, 11, 8, 14, 13, 13, 14, 8, 11,
|
||||
5, 6, 0, 3, 3, 0, 6, 5, 2, 1, 7, 4, 4, 7, 1, 2,
|
||||
6, 5, 3, 0, 0, 3, 5, 6, 1, 2, 4, 7, 7, 4, 2, 1,
|
||||
15, 12, 10, 9, 9, 10, 12, 15, 8, 11, 13, 14, 14, 13, 11, 8,
|
||||
7, 4, 2, 1, 1, 2, 4, 7, 0, 3, 5, 6, 6, 5, 3, 0,
|
||||
14, 13, 11, 8, 8, 11, 13, 14, 9, 10, 12, 15, 15, 12, 10, 9,
|
||||
13, 14, 8, 11, 11, 8, 14, 13, 10, 9, 15, 12, 12, 15, 9, 10,
|
||||
4, 7, 1, 2, 2, 1, 7, 4, 3, 0, 6, 5, 5, 6, 0, 3,
|
||||
0, 3, 5, 6, 6, 5, 3, 0, 7, 4, 2, 1, 1, 2, 4, 7,
|
||||
9, 10, 12, 15, 15, 12, 10, 9, 14, 13, 11, 8, 8, 11, 13, 14,
|
||||
10, 9, 15, 12, 12, 15, 9, 10, 13, 14, 8, 11, 11, 8, 14, 13,
|
||||
3, 0, 6, 5, 5, 6, 0, 3, 4, 7, 1, 2, 2, 1, 7, 4,
|
||||
11, 8, 14, 13, 13, 14, 8, 11, 12, 15, 9, 10, 10, 9, 15, 12,
|
||||
2, 1, 7, 4, 4, 7, 1, 2, 5, 6, 0, 3, 3, 0, 6, 5,
|
||||
1, 2, 4, 7, 7, 4, 2, 1, 6, 5, 3, 0, 0, 3, 5, 6,
|
||||
8, 11, 13, 14, 14, 13, 11, 8, 15, 12, 10, 9, 9, 10, 12, 15
|
||||
};
|
||||
|
||||
static const int decoding[16] = {
|
||||
0, 0, 0, 1, 0, 2, 4, 8, 0, 16, 32, 64, 128, 256, 512, 1024
|
||||
};
|
||||
|
||||
size_t errs = 0;
|
||||
uint16_t par = cw & 0xf;
|
||||
cw &= 0xffff;
|
||||
cw >>= 4;
|
||||
uint16_t correction = decoding[encoding[cw] ^ par];
|
||||
if(correction) {
|
||||
cw ^= correction;
|
||||
++errs;
|
||||
}
|
||||
return errs;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef INCLUDED_HAMMING_H
|
||||
#define INCLUDED_HAMMING_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* APCO Hamming(15,11,3) ecoder.
|
||||
*
|
||||
* \param val The 11-bit value to encode.
|
||||
* \return The encoded codeword.
|
||||
*/
|
||||
extern uint16_t hamming_15_encode(uint16_t val);
|
||||
|
||||
/*
|
||||
* APCO Hamming(15,11,3) decoder.
|
||||
*
|
||||
* \param cw The 15-bit codeword to decode.
|
||||
* \return The number of errors detected.
|
||||
*/
|
||||
extern size_t hamming_15_decode(uint16_t& cw);
|
||||
|
||||
#endif /* INCLUDED_HAMMING_H */
|
|
@ -1,14 +1,4 @@
|
|||
// #include <dummy_imbe_decoder.h>
|
||||
#include <imbe_decoder.h>
|
||||
#include <offline_imbe_decoder.h>
|
||||
// #include <software_imbe_decoder.h>
|
||||
// #include <vc55_imbe_decoder.h>
|
||||
|
||||
imbe_decoder_sptr
|
||||
imbe_decoder::make_imbe_decoder()
|
||||
{
|
||||
return imbe_decoder_sptr(new offline_imbe_decoder());
|
||||
}
|
||||
|
||||
imbe_decoder::~imbe_decoder()
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
*
|
||||
* \return A shared_ptr to an imbe_decoder.
|
||||
*/
|
||||
static imbe_decoder_sptr make_imbe_decoder();
|
||||
static imbe_decoder_sptr make();
|
||||
|
||||
/**
|
||||
* imbe_decoder (virtual) destructor.
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#include <dummy_imbe_decoder.h>
|
||||
#include <imbe_decoder.h>
|
||||
#include <offline_imbe_decoder.h>
|
||||
#include <software_imbe_decoder.h>
|
||||
#include <vc55_imbe_decoder.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
imbe_decoder_sptr
|
||||
imbe_decoder::make()
|
||||
{
|
||||
imbe_decoder_sptr imbe;
|
||||
const char *imbe_type = getenv("IMBE");
|
||||
if(imbe_type) {
|
||||
if(strcasecmp(imbe_type, "offline") == 0) {
|
||||
imbe = imbe_decoder_sptr(new offline_imbe_decoder());
|
||||
} else if(strcasecmp(imbe_type, "soft") == 0) {
|
||||
imbe = imbe_decoder_sptr(new software_imbe_decoder());
|
||||
} else if(strcasecmp(imbe_type, "vc55") == 0) {
|
||||
imbe = imbe_decoder_sptr(new vc55_imbe_decoder());
|
||||
} else {
|
||||
imbe = imbe_decoder_sptr(new dummy_imbe_decoder());
|
||||
}
|
||||
} else {
|
||||
imbe = imbe_decoder_sptr(new dummy_imbe_decoder());
|
||||
}
|
||||
return imbe;
|
||||
}
|
|
@ -52,7 +52,8 @@ void
|
|||
op25_decoder_ff::forecast(int nof_output_items, gr_vector_int &nof_input_items_reqd)
|
||||
{
|
||||
const size_t nof_inputs = nof_input_items_reqd.size();
|
||||
fill(&nof_input_items_reqd[0], &nof_input_items_reqd[nof_inputs], nof_output_items);
|
||||
const int nof_samples_reqd = 3 * nof_output_items; // guesstimate to minimize audio under-runs
|
||||
fill(&nof_input_items_reqd[0], &nof_input_items_reqd[nof_inputs], nof_samples_reqd);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -60,7 +61,7 @@ op25_decoder_ff::general_work(int nof_output_items, gr_vector_int& nof_input_ite
|
|||
{
|
||||
try {
|
||||
|
||||
// process symbol
|
||||
// process input
|
||||
const float *in = reinterpret_cast<const float*>(input_items[0]);
|
||||
for(int i = 0; i < nof_input_items[0]; ++i) {
|
||||
dibit d;
|
||||
|
@ -75,13 +76,24 @@ op25_decoder_ff::general_work(int nof_output_items, gr_vector_int& nof_input_ite
|
|||
}
|
||||
receive_symbol(d);
|
||||
}
|
||||
consume_each(nof_input_items[0]);
|
||||
|
||||
// produce audio (even if silence)
|
||||
consume(0, nof_input_items[0]);
|
||||
// produce audio
|
||||
audio_samples *samples = d_imbe->audio();
|
||||
float *out = reinterpret_cast<float*>(output_items[0]);
|
||||
fill(out, out + nof_output_items, 0.0);
|
||||
const int n = min(static_cast<int>(samples->size()), nof_output_items);
|
||||
if(0 < n) {
|
||||
copy(samples->begin(), samples->begin() + n, out);
|
||||
samples->erase(samples->begin(), samples->begin() + n);
|
||||
}
|
||||
#if 1
|
||||
return n;
|
||||
#else
|
||||
if(n < nof_output_items) {
|
||||
fill(out + n, out + nof_output_items, 0.0);
|
||||
}
|
||||
return nof_output_items;
|
||||
|
||||
#endif
|
||||
} catch(const std::exception& x) {
|
||||
cerr << x.what() << endl;
|
||||
exit(1);
|
||||
|
@ -101,7 +113,7 @@ op25_decoder_ff::op25_decoder_ff(gr_msg_queue_sptr msgq) :
|
|||
d_data_unit(),
|
||||
d_data_unit_handler(),
|
||||
d_frame_hdr(),
|
||||
d_imbe(new offline_imbe_decoder()),
|
||||
d_imbe(imbe_decoder::make()),
|
||||
d_state(SYNCHRONIZING),
|
||||
d_sniffer_du_handler(NULL)
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,104 @@
|
|||
/* -*- C++ -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2008-2009 Steve Glass
|
||||
*
|
||||
* This file is part of OP25.
|
||||
*
|
||||
* OP25 is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or(at your option)
|
||||
* any later version.
|
||||
*
|
||||
* OP25 is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OP25; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_SOFTWARE_IMBE_DECODER_H
|
||||
#define INCLUDED_SOFTWARE_IMBE_DECODER_H
|
||||
|
||||
#include <imbe_decoder.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* A software implementation of the imbe_decoder interface.
|
||||
*/
|
||||
class software_imbe_decoder : public imbe_decoder {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default constructor for the software_imbe_decoder.
|
||||
*/
|
||||
software_imbe_decoder();
|
||||
|
||||
/**
|
||||
* Destructor for the software_imbe_decoder.
|
||||
*/
|
||||
virtual ~software_imbe_decoder();
|
||||
|
||||
/**
|
||||
* Decode the compressed audio.
|
||||
*
|
||||
* \cw in IMBE codeword (including parity check bits).
|
||||
*/
|
||||
virtual void decode(const voice_codeword& cw);
|
||||
|
||||
private:
|
||||
|
||||
FILE *out;
|
||||
|
||||
//NOTE: Single-letter variable names are upper case only; Lower
|
||||
// case if needed is spelled. e.g. L, ell
|
||||
|
||||
// global Seq ER ?
|
||||
|
||||
int bee[58]; //Encoded Spectral Amplitudes
|
||||
float M[57][2]; //Enhanced Spectral Amplitudes
|
||||
float Mu[57][2]; //Unenhanced Spectral Amplitudes
|
||||
int vee[57][2]; //V/UV decisions
|
||||
float suv[160]; //Unvoiced samples
|
||||
float sv[160]; //Voiced samples
|
||||
float log2Mu[58][2];
|
||||
float Olduw[256];
|
||||
float psi1;
|
||||
float phi[57][2];
|
||||
|
||||
int Old;
|
||||
int New;
|
||||
int L;
|
||||
int OldL;
|
||||
float w0;
|
||||
float Oldw0;
|
||||
float Luv; //number of unvoiced spectral amplitudes
|
||||
|
||||
char sym_b[4096];
|
||||
char RxData[4096];
|
||||
int sym_bp;
|
||||
int ErFlag;
|
||||
|
||||
uint32_t pngen15(uint32_t& pn);
|
||||
uint32_t pngen23(uint32_t& pn);
|
||||
void correct(const voice_codeword& cw, uint32_t& u0, uint32_t& u1, uint32_t& u2, uint32_t& u3, uint32_t& u4, uint32_t& u5, uint32_t& u6, uint32_t& u7, uint32_t& E0, uint32_t& ET);
|
||||
void decode_audio(uint8_t *);
|
||||
void decode_spectral_amplitudes(int, int );
|
||||
void decode_vuv(int );
|
||||
void adaptive_smoothing(float, float, float );
|
||||
void fft(float i[], float q[]);
|
||||
void enhance_spectral_amplitudes(float&);
|
||||
void ifft(float i[], float q[], float[]);
|
||||
uint16_t rearrange(uint32_t u0, uint32_t u1, uint32_t u2, uint32_t u3, uint32_t u4, uint32_t u5, uint32_t u6, uint32_t u7);
|
||||
void synth_unvoiced();
|
||||
void synth_voiced();
|
||||
void unpack(uint8_t *buf, uint32_t& u0, uint32_t& u1, uint32_t& u2, uint32_t& u3, uint32_t& u4, uint32_t& u5, uint32_t& u6, uint32_t& u7, uint32_t& E0, uint32_t& ET);
|
||||
};
|
||||
|
||||
|
||||
#endif /* INCLUDED_SOFTWARE_IMBE_DECODER_H */
|
|
@ -0,0 +1,47 @@
|
|||
/* -*- C++ -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2008 Steve Glass
|
||||
*
|
||||
* This file is part of OP25.
|
||||
*
|
||||
* OP25 is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* OP25 is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OP25; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <voice_du_handler.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <stdint.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
voice_du_handler::voice_du_handler(data_unit_handler_sptr next, imbe_decoder_sptr decoder) :
|
||||
data_unit_handler(next),
|
||||
d_decoder(decoder)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
voice_du_handler::~voice_du_handler()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
voice_du_handler::handle(data_unit_sptr du)
|
||||
{
|
||||
du->decode_audio(*d_decoder);
|
||||
data_unit_handler::handle(du);
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/* -*- C++ -*- */
|
||||
|
||||
/*
|
||||
* Copyright 2009 Steve Glass
|
||||
*
|
||||
* This file is part of OP25.
|
||||
*
|
||||
* OP25 is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* OP25 is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OP25; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_VOICE_DU_HANDLER_H
|
||||
#define INCLUDED_VOICE_DU_HANDLER_H
|
||||
|
||||
#include <data_unit_handler.h>
|
||||
#include <imbe_decoder.h>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
/**
|
||||
* voice_data_unit_handler performs IMBE decoding.
|
||||
*/
|
||||
class voice_du_handler : public data_unit_handler
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* voice_du_handler constructor.
|
||||
*
|
||||
* \param next The next data_unit_handler in the chain.
|
||||
* \param decoder An imbe_decoder_sptr to the IMBE decoder to use.
|
||||
*/
|
||||
voice_du_handler(data_unit_handler_sptr next, imbe_decoder_sptr decoder);
|
||||
|
||||
/**
|
||||
* voice_du_handler virtual destructor.
|
||||
*/
|
||||
virtual ~voice_du_handler();
|
||||
|
||||
/**
|
||||
* Handle a received P25 frame.
|
||||
*
|
||||
* \param next The next data_unit_handler in this chain.
|
||||
*/
|
||||
virtual void handle(data_unit_sptr du);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* The IMBE decder to use.
|
||||
*/
|
||||
imbe_decoder_sptr d_decoder;
|
||||
|
||||
};
|
||||
|
||||
#endif /* INCLUDED_VOICE_DU_HANDLER_H */
|
Reference in New Issue