I was trying to optimize this in another language (failed so far), but
did notice that it could be refreshed a bit for C, as it computes
sqrt(2) * sqrt(2) / 2 which can be simplified.

Saves 960 * sizeof(float) - 960 * sizeof(char) = 2880 bytes

The pilot_lut[] table was checked using both original and modified
versions and all 640 values come out the same.
diff -ruN freetel-code-orig/codec2-dev/src/fdmdv.c 
freetel-code-new/codec2-dev/src/fdmdv.c
--- freetel-code-orig/codec2-dev/src/fdmdv.c    2014-11-17 08:50:17.912563270 
-0600
+++ freetel-code-new/codec2-dev/src/fdmdv.c     2014-11-17 09:27:37.924497085 
-0600
@@ -666,8 +666,8 @@
 
 \*---------------------------------------------------------------------------*/
 
-void generate_pilot_fdm(COMP *pilot_fdm, int *bit, float *symbol, 
-                       float *filter_mem, COMP *phase, COMP *freq)
+void generate_pilot_fdm(COMP *pilot_fdm, char *bit, char *symbol, 
+                       int *filter_mem, COMP *phase, COMP *freq)
 {
     int   i,j,k;
     float tx_baseband[M];
@@ -675,17 +675,13 @@
     /* +1 -1 +1 -1 DBPSK sync carrier, once filtered becomes (roughly)
        two spectral lines at +/- RS/2 */
  
-    if (*bit)
-       *symbol = -*symbol;
-
-    if (*bit) 
-       *bit = 0;
-    else
-       *bit = 1;
+    *symbol = (*bit) ? -*symbol : *symbol;
+    *bit = !*bit;
 
     /* filter DPSK symbol to create M baseband samples */
 
-    filter_mem[NFILTER-1] = (sqrtf(2)/2) * *symbol;
+    filter_mem[NFILTER-1] = *symbol;
+
     for(i=0; i<M; i++) {
        tx_baseband[i] = 0.0; 
        for(j=M-1,k=M-i-1; j<NFILTER; j+=M,k+=M)
@@ -698,7 +694,7 @@
        filter_mem[i] = filter_mem[i+M];
 
     for(i=NFILTER-M; i<NFILTER; i++)
-       filter_mem[i] = 0.0;
+       filter_mem[i] = 0;
 
     /* upconvert */
 
@@ -723,15 +719,15 @@
 
 void generate_pilot_lut(COMP pilot_lut[], COMP *pilot_freq)
 {
-    int   pilot_rx_bit = 0;
-    float pilot_symbol = sqrtf(2.0);
     COMP  pilot_phase  = {1.0, 0.0};
-    float pilot_filter_mem[NFILTER];
     COMP  pilot[M];
-    int   i,f;
+    int   pilot_rx_bit = 0;
+    int   i, f;
+    char  pilot_symbol = 1;
+    char  pilot_filter_mem[NFILTER];
 
     for(i=0; i<NFILTER; i++)
-       pilot_filter_mem[i] = 0.0;
+       pilot_filter_mem[i] = 0;
 
     /* discard first 4 symbols as filter memory is filling, just keep
        last four symbols */
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Freetel-codec2 mailing list
Freetel-codec2@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freetel-codec2

Reply via email to