From 9d5bc71ad197f4850360388d3eb6972a3ab2b37f Mon Sep 17 00:00:00 2001 From: drowe67 Date: Sun, 19 Mar 2017 09:45:36 +0000 Subject: [PATCH] ldpc_dec modified to read in half frames and perform FEC frame sync, cohpsk and unit tests modified to work with non-diversity, next step verify cohpsk with AWGN and test on cmd line with LDPC decoder git-svn-id: https://svn.code.sf.net/p/freetel/code@3072 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/codec2_cohpsk.h | 2 +- codec2-dev/src/cohpsk.c | 40 +++++++++++++------- codec2-dev/src/cohpsk_defs.h | 6 +-- codec2-dev/src/cohpsk_demod.c | 48 ++++++++++++++++++++---- codec2-dev/src/cohpsk_mod.c | 38 +++++++++++++++---- codec2-dev/src/freedv_api.c | 2 +- codec2-dev/src/ldpc_dec.c | 67 ++++++++++++++++++++++++++-------- 7 files changed, 152 insertions(+), 51 deletions(-) diff --git a/codec2-dev/src/codec2_cohpsk.h b/codec2-dev/src/codec2_cohpsk.h index 27d35cd2..a0ad488c 100644 --- a/codec2-dev/src/codec2_cohpsk.h +++ b/codec2-dev/src/codec2_cohpsk.h @@ -46,7 +46,7 @@ extern const int test_bits_coh[]; struct COHPSK *cohpsk_create(void); void cohpsk_destroy(struct COHPSK *coh); -void cohpsk_mod(struct COHPSK *cohpsk, COMP tx_fdm[], int tx_bits[]); +void cohpsk_mod(struct COHPSK *cohpsk, COMP tx_fdm[], int tx_bits[], int nbits); void cohpsk_clip(COMP tx_fdm[]); void cohpsk_demod(struct COHPSK *cohpsk, float rx_bits[], int *sync, COMP rx_fdm[], int *nin_frame); void cohpsk_get_demod_stats(struct COHPSK *cohpsk, struct MODEM_STATS *stats); diff --git a/codec2-dev/src/cohpsk.c b/codec2-dev/src/cohpsk.c index 2cdf0123..303db045 100644 --- a/codec2-dev/src/cohpsk.c +++ b/codec2-dev/src/cohpsk.c @@ -222,12 +222,22 @@ void cohpsk_destroy(struct COHPSK *coh) void bits_to_qpsk_symbols(COMP tx_symb[][COHPSK_NC*ND], int tx_bits[], int nbits) { - int i, r, c, p_r, data_r, d; + int i, r, c, p_r, data_r, d, diversity; short bits; - /* check number of bits supplied matchs number of QPSK symbols in the frame */ + /* check allowed number of bits supplied matches number of QPSK + symbols in the frame */ - assert((NSYMROW*COHPSK_NC)*2 == nbits); + assert( (NSYMROW*COHPSK_NC*2 == nbits) || (NSYMROW*COHPSK_NC*2*ND == nbits)); + + /* if we input twice as many bits we don't do diversity */ + + if (NSYMROW*COHPSK_NC*2 == nbits) { + diversity = 1; /* diversity mode */ + } + else { + diversity = 2; /* twice as many bits, non diversity mode */ + } /* Insert two rows of Nc pilots at beginning of data frame. @@ -244,15 +254,14 @@ void bits_to_qpsk_symbols(COMP tx_symb[][COHPSK_NC*ND], int tx_bits[], int nbits r = 0; for(p_r=0; p_r<2; p_r++) { - for(c=0; cfdmdv; COMP tx_symb[NSYMROWPILOT][COHPSK_NC*ND]; COMP tx_onesym[COHPSK_NC*ND]; int r,c; - bits_to_qpsk_symbols(tx_symb, tx_bits, COHPSK_BITS_PER_FRAME); + bits_to_qpsk_symbols(tx_symb, tx_bits, nbits); for(r=0; rrx_bits_lower[i] < 0.0; + fwrite(rx_bits_char, sizeof(char), COHPSK_BITS_PER_FRAME, fout); + for(i=0; irx_bits_upper[i] < 0.0; + fwrite(rx_bits_char, sizeof(char), COHPSK_BITS_PER_FRAME, fout); + } if (oct) { for(r=0; rcohpsk, tx_fdm, f->codec_bits); + cohpsk_mod(f->cohpsk, tx_fdm, f->codec_bits, COHPSK_BITS_PER_FRAME); if (f->clip) cohpsk_clip(tx_fdm); for(i=0; in_nat_modem_samples; i++) diff --git a/codec2-dev/src/ldpc_dec.c b/codec2-dev/src/ldpc_dec.c index 5931a229..529f8041 100644 --- a/codec2-dev/src/ldpc_dec.c +++ b/codec2-dev/src/ldpc_dec.c @@ -54,6 +54,16 @@ #include "H2064_516_sparse.h" #endif +int opt_exists(char *argv[], int argc, char opt[]) { + int i; + for (i=0; i