From b86e88413d4c6ec428aaedb147f7675f28882fe4 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 14 Jul 2023 12:36:50 +0930 Subject: clang-format -i applied to src unittest misc --- src/ldpc_dec.c | 430 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 231 insertions(+), 199 deletions(-) (limited to 'src/ldpc_dec.c') diff --git a/src/ldpc_dec.c b/src/ldpc_dec.c index 94d5c33..82bdacb 100644 --- a/src/ldpc_dec.c +++ b/src/ldpc_dec.c @@ -1,4 +1,4 @@ -/* +/* FILE...: ldpc_dec.c AUTHOR.: Matthew C. Valenti, Rohit Iyer Seshadri, David Rowe CREATED: Sep 2016 @@ -10,227 +10,259 @@ #include #include #include -#include #include -#include #include +#include +#include -#include "mpdecode_core.h" #include "ldpc_codes.h" +#include "mpdecode_core.h" #include "ofdm_internal.h" int opt_exists(char *argv[], int argc, char opt[]) { - int i; - for (i=0; i 16384; } - - if ((codename = opt_exists(argv, argc, "--listcodes")) != 0) { - ldpc_codes_list(); - exit(0); + for (i = data_bits_per_frame - unused_data_bits; i < data_bits_per_frame; + i++) { + ibits[i] = 1; } + encode(&ldpc, ibits, pbits); + } - /* set up LDPC code */ - - int code_index = 0; - if ((codename = opt_exists(argv, argc, "--code")) != 0) - code_index = ldpc_codes_find(argv[codename+1]); - memcpy(&ldpc,&ldpc_codes[code_index],sizeof(struct LDPC)); - fprintf(stderr, "Using: %s\n", ldpc.name); - - CodeLength = ldpc.CodeLength; /* length of entire codeword */ - NumberParityBits = ldpc.NumberParityBits; - data_bits_per_frame = ldpc.NumberRowsHcols; - unsigned char ibits[data_bits_per_frame]; - unsigned char pbits[NumberParityBits]; - uint8_t out_char[CodeLength]; - - testframes = 0; - total_iters = 0; - Tbits = Terrs = Tbits_raw = Terrs_raw = Tpackets = Tpacketerrs = 0; - - FILE *fin, *fout; - int sdinput, nread, offset=0; - - /* File I/O mode ------------------------------------------------*/ - - if (strcmp(argv[1], "-") == 0) fin = stdin; - else if ( (fin = fopen(argv[1],"rb")) == NULL ) { - fprintf(stderr, "Error opening input SD file: %s: %s.\n", - argv[1], strerror(errno)); - exit(1); - } - - if (strcmp(argv[2], "-") == 0) fout = stdout; - else if ( (fout = fopen(argv[2],"wb")) == NULL ) { - fprintf(stderr, "Error opening output bit file: %s: %s.\n", - argv[2], strerror(errno)); - exit(1); - } + float *input_float = calloc(CodeLength, sizeof(float)); - sdinput = 0; mute = 0; testframes = 0; - if (opt_exists(argv, argc, "--sd")) { - sdinput = 1; - } - if (opt_exists(argv, argc, "--mute")) { - mute = 1; - } - unused_data_bits = 0; int arg; - if ((arg = opt_exists(argv, argc, "--unused"))) { - unused_data_bits = atoi(argv[arg+1]); - } - if (opt_exists(argv, argc, "--testframes")) { - testframes = 1; - uint16_t r[data_bits_per_frame]; - ofdm_rand(r, data_bits_per_frame); + nread = CodeLength - unused_data_bits; + fprintf(stderr, "CodeLength: %d offset: %d\n", CodeLength, offset); - for(i=0; i 16384; + while (fread(input_float, sizeof(float), nread, fin) == nread) { + if (testframes) { + /* BPSK SD and bit LLRs get mapped roughly the same way so this just + * happens to work for both */ + char in_char; + for (i = 0; i < data_bits_per_frame - unused_data_bits; i++) { + in_char = input_float[i] < 0; + if (in_char != ibits[i]) { + Terrs_raw++; } - for(i=data_bits_per_frame-unused_data_bits; i