From 33d4699674f649d74e0261dd6310aee07df00b79 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Sat, 3 Nov 2012 22:06:51 +0000 Subject: [PATCH] sanity check of 48 to 8 kHz routines and stopping timing adjustment when out of sync git-svn-id: https://svn.code.sf.net/p/freetel/code@925 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/fdmdv.c | 19 ++++++++++++++----- codec2-dev/src/quantise.c | 3 ++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/codec2-dev/src/fdmdv.c b/codec2-dev/src/fdmdv.c index 9f1b20cd..b3cae9d2 100644 --- a/codec2-dev/src/fdmdv.c +++ b/codec2-dev/src/fdmdv.c @@ -1224,15 +1224,19 @@ void CODEC2_WIN32SUPPORT fdmdv_demod(struct FDMDV *fdmdv, int rx_bits[], rx_filter(rx_filt, rx_baseband, fdmdv->rx_filter_memory, *nin); fdmdv->rx_timing = rx_est_timing(rx_symbols, rx_filt, rx_baseband, fdmdv->rx_filter_mem_timing, env, fdmdv->rx_baseband_mem_timing, *nin); - /* adjust number of input samples to keep timing within bounds */ + /* if we have qcquired pilot adjust number of input samples to + keep timing within bounds. Avoid adjusting number of samples + before acquisition as it will jump about based on noise.*/ *nin = M; - if (fdmdv->rx_timing > 2*M/P) - *nin += M/P; + if (fdmdv->coarse_fine == FINE) { + if (fdmdv->rx_timing > 2*M/P) + *nin += M/P; - if (fdmdv->rx_timing < 0) - *nin -= M/P; + if (fdmdv->rx_timing < 0) + *nin -= M/P; + } foff_fine = qpsk_to_bits(rx_bits, sync_bit, fdmdv->phase_difference, fdmdv->prev_rx_symbols, rx_symbols); memcpy(fdmdv->prev_rx_symbols, rx_symbols, sizeof(COMP)*(NC+1)); @@ -1344,6 +1348,11 @@ void CODEC2_WIN32SUPPORT fdmdv_8_to_48(float out48k[], float in8k[], int n) { int i,j,k,l; + /* make sure n is an integer multiple of the oversampling rate, ow + this function breaks */ + + assert((n % FDMDV_OS) == 0); + for(i=0; i= 0.0); + + if (e < 0.0) e = 0; /* occasional small negative energies due LPC round off I guess */ x[0] = log10((model->Wo/PI)*4000.0/50.0)/log10(2); x[1] = 10.0*log10(1e-4 + e); -- 2.25.1