Static arrays for CML LDPC, generated by ldpc_gen_h_file.m.
*/
-#define NUMBERPARITYBITS 112
-#define MAX_ROW_WEIGHT 3
-#define CODELENGTH 224
-#define NUMBERROWSHCOLS 112
-#define MAX_COL_WEIGHT 3
-#define DEC_TYPE 0
-#define MAX_ITER 100
+#define HRA_112_112_NUMBERPARITYBITS 112
+#define HRA_112_112_MAX_ROW_WEIGHT 3
+#define HRA_112_112_CODELENGTH 224
+#define HRA_112_112_NUMBERROWSHCOLS 112
+#define HRA_112_112_MAX_COL_WEIGHT 3
+#define HRA_112_112_DEC_TYPE 0
+#define HRA_112_112_MAX_ITER 100
-double H_rows[] = {
+double HRA_112_112_H_rows[] = {
22, 18, 15, 63, 16, 13, 1, 2, 29, 25, 28, 4, 36, 10, 38, 7, 60, 23, 11, 38, 28, 1, 12, 31, 57, 45, 57, 30, 23, 59, 67, 14, 16, 4, 14, 62, 15, 50, 7, 70, 64, 6, 42, 48, 9, 31, 19, 40, 49, 2, 25, 3, 41, 49, 36, 9, 29, 39, 31, 5, 17, 1, 29, 25, 11, 21, 18, 2, 8, 22, 39, 15, 8, 22, 13, 3, 19, 4, 21, 62, 34, 43, 6, 24, 17, 60, 8, 74, 6, 44, 60, 10, 33, 12, 26, 24, 45, 81, 69, 80, 41, 28, 23, 5, 10, 20, 52, 18, 13, 86, 3, 7, 59, 21, 65, 72, 34, 37, 26, 55, 47, 48, 34, 5, 44, 47, 68, 96, 82, 111, 61, 74, 30, 17, 55, 98, 81, 66, 89, 35, 74, 82, 91, 51, 55, 51, 30, 89, 61, 75, 40, 71, 73, 11, 56, 54, 19, 47, 94, 69, 64, 20, 64, 12, 54, 77, 42, 88, 36, 52, 90, 63, 70, 27, 32, 73, 91, 32, 56, 46, 9, 78, 51, 68, 88, 67, 20, 43, 40, 14, 66, 86, 39, 97, 38, 27, 50, 84, 54, 92, 61, 46, 67, 24, 58, 35, 58, 37, 98, 85, 73, 84, 48, 35, 57, 16, 26, 37, 65, 32, 72, 95, 107, 33, 77, 33, 85, 105, 106, 75, 56, 71, 79, 59, 52, 105, 79, 90, 93, 100, 88, 112, 86, 80, 65, 42, 106, 100, 93, 94, 99, 97, 93, 101, 111, 99, 83, 53, 85, 95, 108, 107, 41, 109, 84, 78, 104, 101, 69, 110, 98, 103, 80, 83, 77, 71, 76, 78, 87, 102, 104, 95, 96, 83, 87, 50, 110, 103, 112, 45, 58, 70, 94, 91, 89, 81, 101, 82, 63, 72, 100, 97, 76, 112, 53, 105, 49, 75, 109, 102, 66, 111, 68, 87, 92, 79, 96, 43, 90, 44, 110, 99, 102, 92, 103, 106, 62, 53, 27, 46, 108, 104, 107, 108, 109, 76
};
-double H_cols[] = {
+double HRA_112_112_H_cols[] = {
7, 8, 52, 12, 12, 42, 16, 69, 45, 14, 19, 23, 6, 32, 3, 5, 22, 2, 45, 50, 2, 1, 18, 84, 10, 7, 62, 11, 9, 21, 24, 63, 2, 5, 28, 13, 6, 15, 58, 39, 39, 22, 76, 13, 26, 68, 9, 10, 49, 38, 32, 11, 34, 44, 8, 7, 25, 67, 1, 17, 19, 36, 4, 41, 3, 26, 31, 15, 45, 40, 8, 4, 41, 20, 6, 53, 1, 42, 9, 20, 25, 17, 33, 41, 3, 19, 55, 17, 27, 14, 31, 88, 15, 26, 36, 16, 28, 24, 27, 16, 30, 56, 48, 43, 4, 5, 38, 37, 40, 46, 18, 18, 22, 50, 76, 34, 60, 83, 39, 73, 56, 92, 42, 52, 75, 35, 37, 33, 61, 67, 47, 75, 66, 70, 29, 92, 51, 95, 84, 21, 57, 28, 46, 66, 93, 11, 94, 55, 96, 20, 71, 48, 53, 43, 82, 90, 66, 90, 14, 44, 54, 62, 34, 58, 81, 53, 23, 43, 27, 93, 10, 86, 37, 80, 60, 49, 21, 79, 74, 72, 48, 61, 40, 76, 64, 29, 38, 79, 51, 54, 13, 49, 72, 30, 50, 86, 35, 80, 61, 56, 36, 59, 65, 91, 25, 47, 58, 59, 78, 47, 32, 24, 44, 86, 64, 57, 12, 23, 109, 107, 85, 63, 31, 65, 62, 68, 111, 78, 104, 89, 112, 87, 69, 105, 65, 94, 109, 78, 72, 104, 85, 108, 77, 106, 79, 74, 103, 96, 64, 105, 105, 102, 63, 35, 59, 108, 112, 81, 102, 57, 106, 83, 81, 77, 101, 55, 94, 96, 97, 106, 46, 101, 83, 85, 71, 107, 104, 87, 33, 67, 103, 95, 30, 91, 89, 103, 75, 51, 107, 87, 91, 89, 99, 68, 52, 109, 99, 88, 84, 112, 54, 70, 92, 100, 98, 74, 60, 100, 98, 110, 90, 73, 71, 95, 70, 100, 29, 69, 110, 93, 82, 97, 98, 77, 73, 99, 101, 108, 82, 102, 111, 110, 111, 97, 88, 80
};
-double input[] = {
+double HRA_112_112_input[] = {
-5.7868467875518395, -6.340739523388657, 3.6654768375589399, 4.1452438183910827, -4.6746135252043111, -4.8353634065473701, -6.0729133999971285, 4.0335561282226271, -6.1114855315699135, 4.1029513876344916, -4.6481634503883624, 5.7650915278538646, 6.5567610490570312, 5.1810523550761207, 3.4789051916752669, 4.2678848515507122, 4.0314705275547089, 6.0297078342283799, 4.9101169653222163, -6.4577297598332324, -7.4273487270443095, 3.472130985267488, -6.5346233967202254, 7.5312028458762414, -5.2618748211985915, 6.4198074556254969, 3.7500207659511484, 5.4040878141701141, 5.7554260586578803, 3.3973620625026886, 7.1815269888532907, 5.0031747952824963, 5.1377243276145599, 5.385229914081755, -0.61384230253605643, 0.46954911161835722, 3.5182611493679663, 3.393698829567279, 6.147483866535171, 3.8374563885989228, 1.3663773773557015, -4.0917661778352352, -3.2968298202652835, -6.0371912041431148, -8.4279246895331781, -0.98556788606912304, -3.515442879601625, 4.2642476942514875, -5.5905016743156972, 3.6920101668161727, -4.035860013856472, 5.3290190966269995, -2.9729656070594057, -2.5054371041338537, 6.8683150013190115, -7.1109038108500098, 6.7301890172695158, 2.5782062882356374, 4.4161464916633282, 2.2692851122935322, -1.3682527221025034, 3.0794629981237631, -7.8655412763279973, 1.1479897597156494, 0.22370696314520414, 1.1222453403894148, -3.1335220808128219, -3.8352985265277089, -1.2463521619727009, 2.9511814015293218, -8.668811041413111, 3.0185610517830548, -6.9592962351476091, 3.9653416636625414, -3.9384322074229408, 1.6789027505247516, 2.9579632055145502, -2.1212672699995125, -3.8892168640945193, 7.516114544807583, -0.84285604179011253, 4.1295390817792512, 0.26093278495228162, -3.6071666499996047, -0.065323173773821908, -1.9146584862100915, 4.7951161310834367, 5.5440002982088803, 3.5917539980319364, -0.81416023563684481, -2.6588977758747721, -3.0404494660606227, 4.5389936536649662, 2.7870543501114082, 3.5622966707453889, 5.1982116994791161, 2.4775319712999302, 0.70541080068007755, 0.89622787904518464, 4.3789020039207758, -2.4976040580619445, -0.7201255450933205, 4.2071986295109394, -5.2418379271657001, -4.092365654835163, -4.3510198326542557, 3.7404138637596001, 1.2496890930262492, -7.1053909336149728, -4.8888279905256748, -6.3523901926735249, -1.8757980409249277, 3.6256343910366273, -3.6165398844758228, -0.38322352317510561, -0.84747550047769449, -1.2717892264620718, -2.3899810721111154, 4.1368500898628637, 3.0440159002314924, 3.4235543074310728, -2.146097053557551, -1.7537615307751735, -1.0280987119225686, 4.9009275359419204, 5.0046047156368116, -0.47700833783807428, -4.5989492891875567, 1.4154839158712684, 0.33410724822249849, -4.771937854508927, -1.1817007924012972, -2.5960865023249302, 0.30422629502493687, -2.2097849377516763, -4.343244940878872, 1.9464288912612249, -9.0976989032526809, -8.6454142547592685, -1.8164317522989997, 2.2780845702169961, -4.8775405042023356, -0.61834757216625769, -1.985554501661331, -0.87599558657596699, -8.0610201531782124, -5.9847574894882554, -10.365536404711067, 2.9782191161319376, -6.9443820217795169, 0.72935566343949876, -4.5326632961380664, 1.1307250622386897, -4.0853969692041314, 5.4926924507347596, 5.6722555096362042, -2.5069992226180222, 2.0460084066662092, 2.5375899018238197, -3.5264293517823679, 3.2103083878487557, 5.793713046583183, -2.7633653287377995, 6.482851815629938, -1.2471646528152021, 3.0010491047486085, 0.29072399293868856, -4.0686659405747738, -2.6253508133431289, -6.3896590677017171, 5.7054076607727886, 4.3053292399977092, 2.2372599539047151, -4.8975607398431897, 5.8124794005531406, -0.69648233429781359, 5.5509723605410004, 2.0900652762982923, -4.7944253330785118, -2.9224693872108287, 6.0218579796888303, 4.7027436964063387, -4.1564871824868659, -1.324779121305123, 0.38031612697724176, -0.69335927945709175, -0.4028295686263082, 2.0967669774299189, 2.7947186736855909, 2.1473880039026203, 6.368702510367898, -3.0691782325684049, 1.6125827087903837, 3.5925359669662518, 5.178224480471127, -2.5070763799556617, 4.4280512389456632, -6.5385259627250134, 2.8047951999607603, -3.0185715385981151, -0.33348983718789993, -4.3285127692183556, -7.9609407359365134, 7.064973172264966, 0.95714371675898213, -5.5481272272415545, -1.6024149180708045, -4.5740915350065992, -1.5117120929647263, 1.9996824689403947, 5.9527526663437724, 5.0239857792804967, 6.2677418491798784, -1.9758548902654505, 2.1709284879472324, 2.5054563138111572, 4.4483685492445115, 3.2098357106645676, -4.5306213859481099, 1.1291114493451548, 1.5827945023160555, -5.2733490015732292, 5.0664709821503457, 1.9652801880230106
};
-char detected_data[] = {
+char HRA_112_112_detected_data[] = {
1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0
};
/* Machine generated consts, H_rows, H_cols, test input/output data to\r
change LDPC code regenerate this file. */\r
\r
-#ifdef HRA_112_112\r
-#include "HRA_112_112.h" \r
-#else\r
+/* TODO: Better octave/C support for multuple codes */\r
+\r
#include "H2064_516_sparse.h" \r
-#endif\r
+#include "HRA_112_112.h" \r
\r
int opt_exists(char *argv[], int argc, char opt[]) {\r
int i;\r
for (i=0; i<argc; i++) {\r
if (strcmp(argv[i], opt) == 0) {\r
- return 1;\r
+ return i;\r
}\r
}\r
return 0;\r
int main(int argc, char *argv[])\r
{ \r
int CodeLength, NumberParityBits;\r
- int i, r, num_ok, num_runs;\r
- char out_char[CODELENGTH];\r
+ int i, r, num_ok, num_runs, codename;\r
+ char out_char[CODELENGTH], *adetected_data;\r
struct LDPC ldpc;\r
-\r
- /* derive some parameters */\r
-\r
- CodeLength = CODELENGTH; /* length of entire codeword */\r
- NumberParityBits = NUMBERPARITYBITS;\r
+ double *ainput;\r
\r
if (argc < 2) {\r
fprintf(stderr, "\n");\r
- fprintf(stderr, "usage: %s --test\n\n", argv[0]);\r
- fprintf(stderr, " Run internal self test and print code parameters.\n\n");\r
- fprintf(stderr, "usage: %s InOneSymbolPerDouble OutOneBitPerByte [--sd] [--half]\n\n", argv[0]);\r
+ fprintf(stderr, "usage: %s --test [--code CodeName]\n\n", argv[0]);\r
+ fprintf(stderr, " Run internal self test and print code parameters.\n");\r
+ fprintf(stderr, "\n");\r
+ fprintf(stderr, "usage: %s --listcodes\n\n", argv[0]);\r
+ fprintf(stderr, " List supported codes (more can be added via using Octave ldpc scripts)\n");\r
+ fprintf(stderr, "\n");\r
+ fprintf(stderr, "usage: %s InOneSymbolPerDouble OutOneBitPerByte [--sd] [--half] [--code CodeName]\n\n", argv[0]);\r
fprintf(stderr, " InOneSymbolPerDouble Input file of double LLRs, use - for the \n"); \r
fprintf(stderr, " file names to use stdin/stdout\n");\r
+ fprintf(stderr, " --code Treat input file samples as Soft Decision\n");\r
+ fprintf(stderr, " demod outputs rather than LLRs\n");\r
fprintf(stderr, " --sd Treat input file samples as Soft Decision\n");\r
fprintf(stderr, " demod outputs rather than LLRs\n");\r
fprintf(stderr, " --half Load framesize/2 input samples for each decode\n");\r
exit(0);\r
}\r
\r
- /* set up LDPC code from include file constants */\r
+\r
+ if ((codename = opt_exists(argv, argc, "--listcodes")) != 0) {\r
+ fprintf(stderr,"\n");\r
+ fprintf(stderr,"H2064_516_sparse\n");\r
+ fprintf(stderr,"HRA_112_112\n");\r
+ fprintf(stderr,"\n");\r
+ exit(0);\r
+ }\r
+\r
+ /* default Wenet High Alitiude Balloon rate 0.8 code */\r
\r
ldpc.max_iter = MAX_ITER;\r
ldpc.dec_type = 0;\r
ldpc.max_col_weight = MAX_COL_WEIGHT;\r
ldpc.H_rows = H_rows;\r
ldpc.H_cols = H_cols;\r
+ ainput = input;\r
+ adetected_data = detected_data;\r
+\r
+ if ((codename = opt_exists(argv, argc, "--code")) != 0) {\r
+\r
+ /* short rate 1/2 code for FreeDV HF digital voice */\r
+ \r
+ if (strcmp(argv[codename+1], "HRA_112_112") == 0) {\r
+ fprintf(stderr, "code: %s\n", argv[codename+1]);\r
+ ldpc.max_iter = HRA_112_112_MAX_ITER;\r
+ ldpc.dec_type = 0;\r
+ ldpc.q_scale_factor = 1;\r
+ ldpc.r_scale_factor = 1;\r
+ ldpc.CodeLength = HRA_112_112_CODELENGTH;\r
+ ldpc.NumberParityBits = HRA_112_112_NUMBERPARITYBITS;\r
+ ldpc.NumberRowsHcols = HRA_112_112_NUMBERROWSHCOLS;\r
+ ldpc.max_row_weight = HRA_112_112_MAX_ROW_WEIGHT;\r
+ ldpc.max_col_weight = HRA_112_112_MAX_COL_WEIGHT;\r
+ ldpc.H_rows = HRA_112_112_H_rows;\r
+ ldpc.H_cols = HRA_112_112_H_cols;\r
+ ainput = HRA_112_112_input;\r
+ adetected_data = HRA_112_112_detected_data;\r
+ }\r
+ }\r
+\r
+ CodeLength = ldpc.CodeLength; /* length of entire codeword */\r
+ NumberParityBits = ldpc.NumberParityBits;\r
\r
if (!strcmp(argv[1],"--test")) {\r
\r
\r
for(r=0; r<num_runs; r++) {\r
\r
- run_ldpc_decoder(&ldpc, out_char, input);\r
+ run_ldpc_decoder(&ldpc, out_char, ainput);\r
\r
int ok = 0;\r
for (i=0; i<CodeLength; i++) {\r
- if (out_char[i] == detected_data[i]) \r
+ if (out_char[i] == adetected_data[i]) \r
ok++;\r
}\r
\r
// output data bits if decoder converged\r
\r
if (iter != MAX_ITER) {\r
- fwrite(out_char, sizeof(char), NUMBERROWSHCOLS, fout);\r
+ fwrite(out_char, sizeof(char), ldpc.NumberRowsHcols, fout);\r
}\r
\r
for(i=0; i<offset; i++) {\r