sanity check of 48 to 8 kHz routines and stopping timing adjustment when out of sync
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 3 Nov 2012 22:06:51 +0000 (22:06 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 3 Nov 2012 22:06:51 +0000 (22:06 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@925 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/src/fdmdv.c
codec2-dev/src/quantise.c

index 9f1b20cd2623676739ef5fbf20c4ba7b615a81cd..b3cae9d2e02695af06b464946020916ece7e3705 100644 (file)
@@ -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<n; i++) {
        for(j=0; j<FDMDV_OS; j++) {
            out48k[i*FDMDV_OS+j] = 0.0;
index 1c98afd42325567aed10a6a8c988ceda88a3d3c7..47601ac7d3c4e66592c291242c688d4d60f22905 100644 (file)
@@ -1967,7 +1967,8 @@ int encode_WoE(MODEL *model, float e, float xq[])
   int          ndim = ge_cb[0].k;
 
   assert((1<<WO_E_BITS) == nb_entries);
-  assert(e >= 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);