From 015b4a579be6b7944fbbd1479e7e3937105c1ce7 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 19 Jun 2015 02:23:31 +0000 Subject: [PATCH] tweaked test frames support git-svn-id: https://svn.code.sf.net/p/freetel/code@2208 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/CMakeLists.txt | 2 +- codec2-dev/src/freedv_api.c | 9 +++- codec2-dev/unittest/tcohpsk.c | 13 +----- codec2-dev/unittest/test_cohpsk_ch.c | 70 ++++------------------------ 4 files changed, 19 insertions(+), 75 deletions(-) diff --git a/codec2-dev/CMakeLists.txt b/codec2-dev/CMakeLists.txt index f74643f2..2745e116 100644 --- a/codec2-dev/CMakeLists.txt +++ b/codec2-dev/CMakeLists.txt @@ -53,7 +53,7 @@ endif() # Set default C++ flags. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2") # -fPIC is implied on MinGW... if(NOT WIN32) diff --git a/codec2-dev/src/freedv_api.c b/codec2-dev/src/freedv_api.c index 04726d87..9b870162 100644 --- a/codec2-dev/src/freedv_api.c +++ b/codec2-dev/src/freedv_api.c @@ -502,6 +502,7 @@ int freedv_comprx(struct freedv *f, short speech_out[], COMP demod_in[]) { } codeword1 = golay23_decode(recd_codeword); f->total_bit_errors += golay23_count_errors(recd_codeword, codeword1); + f->total_bits += 23; //codeword1 = recd_codeword; //fprintf(stderr, "received codeword1: 0x%x decoded codeword1: 0x%x\n", recd_codeword, codeword1); @@ -549,7 +550,7 @@ int freedv_comprx(struct freedv *f, short speech_out[], COMP demod_in[]) { else { int test_frame_sync, bit_errors, ntest_bits, k; short error_pattern[fdmdv_error_pattern_size(f->fdmdv)]; - + for(k=0; k<2; k++) { /* test frames, so lets sync up to the test frames and count any errors */ fdmdv_put_test_bits(f->fdmdv, &test_frame_sync, error_pattern, &bit_errors, &ntest_bits, &f->rx_bits[k*bits_per_fdmdv_frame]); @@ -655,11 +656,15 @@ int freedv_comprx(struct freedv *f, short speech_out[], COMP demod_in[]) { f->total_bit_errors += bit_errors; f->total_bits += COHPSK_BITS_PER_FRAME; } + + for(i=0; in_speech_samples; i++) + speech_out[i] = 0; + nout = f->n_speech_samples; } } - if ((sync == 0) || f->test_frames) { + if (sync == 0) { float t,a,b,s; int t1,t2; diff --git a/codec2-dev/unittest/tcohpsk.c b/codec2-dev/unittest/tcohpsk.c index 83dbc93b..6459946e 100644 --- a/codec2-dev/unittest/tcohpsk.c +++ b/codec2-dev/unittest/tcohpsk.c @@ -39,7 +39,6 @@ #include "codec2_cohpsk.h" #include "cohpsk_defs.h" #include "cohpsk_internal.h" -#include "test_bits_coh.h" #include "octave.h" #include "comp_prim.h" #include "noise_samples.h" @@ -82,7 +81,6 @@ int main(int argc, char *argv[]) FILE *fout; int f, r, c, log_r, log_data_r, noise_r, ff_log_r, i; - int *ptest_bits_coh, *ptest_bits_coh_end; double foff; COMP foff_rect, phase_ch; @@ -124,10 +122,6 @@ int main(int argc, char *argv[]) /* init stuff */ log_r = log_data_r = noise_r = log_bits = ff_log_r = f_est_samples = 0; - ptest_bits_coh = (int*)test_bits_coh; - ptest_bits_coh_end = (int*)test_bits_coh + sizeof(test_bits_coh)/sizeof(int); - memcpy(tx_bits, test_bits_coh, sizeof(int)*COHPSK_BITS_PER_FRAME); - phase_ch.real = 1.0; phase_ch.imag = 0.0; foff = FOFF; @@ -147,12 +141,7 @@ int main(int argc, char *argv[]) Mod \*---------------------------------------------------------*/ - memcpy(tx_bits, ptest_bits_coh, sizeof(int)*COHPSK_BITS_PER_FRAME); - ptest_bits_coh += COHPSK_BITS_PER_FRAME; - if (ptest_bits_coh >= ptest_bits_coh_end) { - ptest_bits_coh = (int*)test_bits_coh; - } - + cohpsk_get_test_bits(coh, tx_bits); bits_to_qpsk_symbols(tx_symb, (int*)tx_bits, COHPSK_BITS_PER_FRAME); for(r=0; r #include "codec2_cohpsk.h" -#include "test_bits_coh.h" #include "octave.h" #include "comp_prim.h" #include "noise_samples.h" @@ -68,18 +67,16 @@ int main(int argc, char *argv[]) COMP tx_fdm[COHPSK_NOM_SAMPLES_PER_FRAME]; COMP ch_fdm[COHPSK_NOM_SAMPLES_PER_FRAME]; COMP ch_buf[CH_BUF_SZ]; - int rx_bits[COHPSK_BITS_PER_FRAME]; float rx_bits_sd[COHPSK_BITS_PER_FRAME]; float *rx_amp_log; float *rx_phi_log; COMP *rx_symb_log; int f, r, i; - int *ptest_bits_coh, *ptest_bits_coh_end, *ptest_bits_coh_rx; COMP phase_ch; int noise_r, noise_end; - int errors; - int state, next_state, nerrors, nbits, reliable_sync_bit; + int bit_errors; + int state, nerrors, nbits, reliable_sync_bit; float EsNo, variance; COMP scaled_noise; float EsNodB, foff_hz; @@ -89,12 +86,9 @@ int main(int argc, char *argv[]) FILE *ffading, *fout; int ch_buf_n; float tx_pwr, rx_pwr, noise_pwr; - int error_positions_hist[COHPSK_BITS_PER_FRAME]; + short error_pattern[COHPSK_BITS_PER_FRAME]; int log_data_r, c, j, tmp; - - for(i=0; i= ptest_bits_coh_end) { - ptest_bits_coh = (int*)test_bits_coh; - //fprintf(stderr, " [%d] tx test bits wrap\n", f); - } - + cohpsk_get_test_bits(coh, tx_bits); cohpsk_mod(coh, tx_fdm, tx_bits); cohpsk_clip(tx_fdm); @@ -251,9 +236,7 @@ int main(int argc, char *argv[]) coh->frame = f; tmp = nin_frame; cohpsk_demod(coh, rx_bits_sd, &reliable_sync_bit, ch_buf, &tmp); - for(i=0; i 0.0; - + ch_buf_n -= nin_frame; //printf("nin_frame: %d tmp: %d ch_buf_n: %d\n", nin_frame, tmp, ch_buf_n); assert(ch_buf_n >= 0); @@ -261,40 +244,11 @@ int main(int argc, char *argv[]) memcpy(ch_buf, &ch_buf[nin_frame], sizeof(COMP)*ch_buf_n); nin_frame = tmp; - //fprintf(stderr, " [%d] nin_frame: %d\n", f, nin_frame); - errors = 0; - for(i=0; i= ptest_bits_coh_end) { - ptest_bits_coh_rx = (int*)test_bits_coh; - //fprintf(stderr, " [%d] rx test bits wrap\n", f); - } + cohpsk_put_test_bits(coh, &state, error_pattern, &bit_errors, rx_bits_sd); + nerrors += bit_errors; + nbits += COHPSK_BITS_PER_FRAME; + if (state) { for(r=0; ramp_[r][c]; @@ -304,7 +258,6 @@ int main(int argc, char *argv[]) } } - state = next_state; } printf("%4.3f %d %d\n", (float)nerrors/nbits, nbits, nerrors); @@ -319,9 +272,6 @@ int main(int argc, char *argv[]) } cohpsk_destroy(coh); - //for(i=0; ich_symb_log, coh->ch_symb_log_r, COHPSK_NC*ND, COHPSK_NC*ND); octave_save_float(fout, "rx_amp_log_c", (float*)rx_amp_log, log_data_r, COHPSK_NC*ND, COHPSK_NC*ND); -- 2.25.1