From ac7c48b4dee99d4c772f133d70d8d1b38262fcd2 Mon Sep 17 00:00:00 2001 From: Author Name Date: Fri, 7 Jul 2023 12:20:59 +0930 Subject: shallow zip-file copy from codec2 e9d726bf20 --- src/ldpc_dec_test.c | 356 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 356 insertions(+) create mode 100644 src/ldpc_dec_test.c (limited to 'src/ldpc_dec_test.c') diff --git a/src/ldpc_dec_test.c b/src/ldpc_dec_test.c new file mode 100644 index 0000000..d26fd52 --- /dev/null +++ b/src/ldpc_dec_test.c @@ -0,0 +1,356 @@ +/* + FILE...: ldpc_dec.c + AUTHOR.: Matthew C. Valenti, Rohit Iyer Seshadri, David Rowe + CREATED: Sep 2016 + + Command line C LDPC decoder derived from MpDecode.c in the CML + library. Allows us to run the same decoder in Octave and C. The + code is defined by the parameters and array stored in the include + file below, which can be machine generated from the Octave function + ldpc_fsk_lib.m:ldpc_decode() + + The include file also contains test input/output vectors for the LDPC + decoder for testing this program. + + Build: + + $ gcc -O2 -o ldpc_dec ldpc_dec.c mpdecode_core.c -Wall -lm -g + + Note: -O2 option was required to get identical results to MpDecode, + which is also compiled with -O2. Without it the number of bit errors + between C and Octave was different, especially when the code did + not converge and hit max_iters. + +*/ + +#include +#include +#include +#include +#include +#include +#include "mpdecode_core_test.h" +#include "ofdm_internal.h" + +/* Machine generated consts, H_rows, H_cols, test input/output data to + change LDPC code regenerate this file. */ + +/* TODO: Better octave/C support for multuple codes */ + +#include "H2064_516_sparse_test.h" +#include "HRA_112_112_test.h" + +int opt_exists(char *argv[], int argc, char opt[]) { + int i; + for (i=0; i 0) { + ldpc.max_iter = atoi(argv[i+1]); + fprintf(stderr, "max_iter: %d\n", ldpc.max_iter); + } + + 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]; + char out_char[CodeLength]; + + testframes = 0; + total_iters = 0; + Tbits = Terrs = Tbits_raw = Terrs_raw = 0; + + if (!strcmp(argv[1],"--test")) { + + /* test mode --------------------------------------------------------*/ + + fprintf(stderr, "Starting test using pre-compiled test data .....\n"); + fprintf(stderr, "Codeword length: %d\n", CodeLength); + fprintf(stderr, "Parity Bits....: %d\n", NumberParityBits); + + num_runs = 1; num_ok = 0; + + for(r=0; r 16384; + } + encode(&ldpc, ibits, pbits); + } + + double *input_double = calloc(CodeLength, sizeof(double)); + float *input_float = calloc(CodeLength, sizeof(float)); + + nread = CodeLength; + offset = 0; + if (readhalfframe) { + nread = CodeLength/2; + offset = CodeLength/2; + for(i=0; i