From: drowe67 Date: Tue, 8 May 2018 21:33:51 +0000 (+0000) Subject: C version modified to have UW distributed across frame, works OK, should hopefully... X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=7e41ede7558e1d2d762be8a2b8e7300cf49b0769;p=freetel-svn-tracking.git C version modified to have UW distributed across frame, works OK, should hopefully make sync faster and prevent false syncs git-svn-id: https://svn.code.sf.net/p/freetel/code@3586 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/src/interldpc.c b/codec2-dev/src/interldpc.c index 71845281..49322deb 100644 --- a/codec2-dev/src/interldpc.c +++ b/codec2-dev/src/interldpc.c @@ -188,6 +188,30 @@ int count_errors(int tx_bits[], char rx_bits[], int n) { } +#ifdef NOT_USED +/* UW never changes so we can pre-load tx_symbols with modulated UW */ + +void build_modulated_uw(struct OFDM *ofdm, complex float tx_symbols[], uint8_t txt_bits[]) +{ + int uw_txt_bits[OFDM_NUWBITS+OFDM_NTXTBITS]; + COMP uw_txt_syms[(OFDM_NUWBITS+OFDM_NTXTBITS)/OFDM_BPS]; + int i,j; + + for(i=0; itx_uw[i]; + } + /* clear txt bits for now, they can be added in later */ + for(j=0; jtx_uw[i]; - } - /* clear txt bits for now, they can be added in later */ - for(j=0; jrx_np[s], dibit); + rx_uw[OFDM_BPS*u] = dibit[1]; + rx_uw[OFDM_BPS*u+1] = dibit[0]; + u++; + } else { + codeword_syms[p].real = crealf(ofdm->rx_np[s]); + codeword_syms[p].imag = cimagf(ofdm->rx_np[s]); + codeword_amps[p] = ofdm->rx_amp[s]; + p++; + } + } + assert(u == Nuwsyms); + assert(p == (Nsymsperframe-Nuwsyms-Ntxtsyms)); + + int t; + + for (t=0; srx_np[s], dibit); + txt_bits[t] = dibit[1]; + txt_bits[t+1] = dibit[0]; + } + assert(t == OFDM_NTXTBITS); +} + diff --git a/codec2-dev/src/ofdm_demod.c b/codec2-dev/src/ofdm_demod.c index 0ee5f0d4..e60f6c8a 100644 --- a/codec2-dev/src/ofdm_demod.c +++ b/codec2-dev/src/ofdm_demod.c @@ -181,6 +181,7 @@ int main(int argc, char *argv[]) int rx_bits[Nbitsperframe]; char rx_bits_char[Nbitsperframe]; int rx_uw[OFDM_NUWBITS]; + int txt_bits[OFDM_NTXTBITS]; f = 0; Nerrs = Terrs = Tbits = Terrs2 = Tbits2 = Terrs_coded = Tbits_coded = frame_count = 0; float EsNo = 3; @@ -188,6 +189,8 @@ int main(int argc, char *argv[]) float snr_est_smoothed_dB = 0.0; + COMP payload_syms[coded_syms_per_frame]; + float payload_amps[coded_syms_per_frame]; COMP codeword_symbols[interleave_frames*coded_syms_per_frame]; float codeword_amps[interleave_frames*coded_syms_per_frame]; for (i=0; isync_state,"synced") == 0) || (strcmp(ofdm->sync_state,"trial") == 0) ) { ofdm_demod(ofdm, rx_bits, rxbuf_in); + ofdm_disassemble_modem_frame(ofdm, rx_uw, payload_syms, payload_amps, txt_bits); if (llr_en) { @@ -229,13 +233,11 @@ int main(int argc, char *argv[]) codeword_amps[i] = codeword_amps[j]; } - /* newest symbols at end of buffer (uses final i from last loop), note we - change COMP formats from what modem uses internally */ + /* newest symbols at end of buffer (uses final i from last loop) */ - for(i=(interleave_frames-1)*coded_syms_per_frame,j=(OFDM_NUWBITS+OFDM_NTXTBITS)/OFDM_BPS; irx_np[j]); - codeword_symbols[i].imag = cimagf(ofdm->rx_np[j]); - codeword_amps[i] = ofdm->rx_amp[j]; + for(i=(interleave_frames-1)*coded_syms_per_frame,j=0; i #include +#include #include "codec2_ofdm.h" @@ -155,7 +156,12 @@ struct OFDM { complex float qpsk_mod(int *); void qpsk_demod(complex float, int *); void ofdm_txframe(struct OFDM *, complex float tx_samples[OFDM_SAMPLESPERFRAME], complex float tx_symbols_lin[]); - +void ofdm_assemble_modem_frame(complex float modem_frame[], COMP payload_syms[], uint8_t txt_bits[]); +void ofdm_disassemble_modem_frame(struct OFDM *ofdm, + int rx_uw[], + COMP codeword_syms[], + float codeword_amps[], + int txt_bits[]); #ifdef __cplusplus } #endif diff --git a/codec2-dev/src/test_bits_ofdm.h b/codec2-dev/src/test_bits_ofdm.h index 423626e5..9dacb514 100644 --- a/codec2-dev/src/test_bits_ofdm.h +++ b/codec2-dev/src/test_bits_ofdm.h @@ -2,29 +2,17 @@ const int test_bits_ofdm[]={ 1, - 0, - 0, 1, 0, 1, - 0, - 0, 1, 0, - 0, - 0, - 0, - 0, - 1, 1, 0, - 1, - 1, 0, 1, 0, 0, - 1, 0, 0, 0, @@ -53,6 +41,8 @@ const int test_bits_ofdm[]={ 0, 0, 0, + 0, + 0, 1, 0, 0, @@ -66,6 +56,8 @@ const int test_bits_ofdm[]={ 1, 0, 0, + 0, + 0, 1, 1, 1, @@ -82,6 +74,8 @@ const int test_bits_ofdm[]={ 1, 0, 0, + 0, + 0, 1, 0, 0, @@ -100,6 +94,8 @@ const int test_bits_ofdm[]={ 0, 0, 0, + 0, + 0, 1, 0, 0, @@ -238,7 +234,11 @@ const int test_bits_ofdm[]={ 0, 0, 0, - 1 + 1, + 0, + 0, + 0, + 0 }; const int payload_data_bits[]={