Update ofdm.c demod
authorokcsampson <okcsampson@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 17 Jun 2017 15:58:42 +0000 (15:58 +0000)
committerokcsampson <okcsampson@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 17 Jun 2017 15:58:42 +0000 (15:58 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3209 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/src/ofdm.c

index 06ea6b9c400cb05fefd6dfc3dc52d19bc9112598..e8a310dd9428db1efe68dd903fc6da1511ef7ecb 100644 (file)
@@ -41,7 +41,7 @@
 /* Static Prototypes */
 
 static void matrix_vector_multiply(struct OFDM *, complex float *, complex float *);
-static void matrix_vector_conjugate_multiply(struct OFDM *, complex float *, int, complex float *);
+static void matrix_vector_conjugate_multiply(struct OFDM *, complex float *, complex float *);
 static complex float vector_sum(complex float *, int, int);
 static complex float vector_conjugate_sum(complex float *, int, int);
 static complex float qpsk_mod(int *);
@@ -91,8 +91,8 @@ static complex float qpsk_mod(int *bits) {
 
 static void qpsk_demod(complex float symbol, int *bits) {
     complex float rotate = symbol * cexpf(I * (M_PI / 4.0f));
-    bits[1] = crealf(rotate) < 0.0f;
-    bits[0] = cimagf(rotate) < 0.0f;
+    bits[0] = crealf(rotate) < 0.0f;
+    bits[1] = cimagf(rotate) < 0.0f;
 }
 
 /* convert frequency domain into time domain */
@@ -111,14 +111,14 @@ static void matrix_vector_multiply(struct OFDM *ofdm, complex float *result, com
 
 /* convert time domain into frequency domain */
 
-static void matrix_vector_conjugate_multiply(struct OFDM *ofdm, complex float *result, int index, complex float *vector) {
+static void matrix_vector_conjugate_multiply(struct OFDM *ofdm, complex float *result, complex float *vector) {
     int row, col;
 
     for (col = 0; col < (OFDM_NC + 2); col++) {
         result[col] = 0.0f + 0.0f * I;
 
         for (row = 0; row < OFDM_M; row++) {
-            result[col] += (vector[row] * conjf(ofdm->W[index][row])); /* complex result */
+            result[col] += (vector[row] * conjf(ofdm->W[col][row])); /* complex result */
         }
     }
 }
@@ -448,7 +448,6 @@ void ofdm_mod(struct OFDM *ofdm, COMP result[OFDM_SAMPLESPERFRAME], const int *t
 // UNTESTED
 
 void ofdm_demod(struct OFDM *ofdm, int *rx_bits, COMP *rxbuf_in) {
-    complex float acarrier[OFDM_NC + 2];
     complex float aphase_est_pilot_rect;
     float aphase_est_pilot[OFDM_NC + 2];
     float aamp_est_pilot[OFDM_NC + 2];
@@ -522,10 +521,7 @@ void ofdm_demod(struct OFDM *ofdm, int *rx_bits, COMP *rxbuf_in) {
         work[k] = ofdm->rxbuf[j] * cexpf(-I * woff_est * j);
     }
 
-    for (i = 0; i < (OFDM_NC + 2); i++) {
-        matrix_vector_conjugate_multiply(ofdm, acarrier, i, work);        
-        ofdm->rx_sym[0][i] = vector_sum(acarrier, 0, (OFDM_NC + 2));
-    }
+    matrix_vector_conjugate_multiply(ofdm, ofdm->rx_sym[0], work);        
 
     /* pilot - this frame - pilot */
 
@@ -537,10 +533,7 @@ void ofdm_demod(struct OFDM *ofdm, int *rx_bits, COMP *rxbuf_in) {
             work[k] = ofdm->rxbuf[j] * cexpf(-I * woff_est * j);
         }
         
-        for (i = 0; i < (OFDM_NC + 2); i++) {
-            matrix_vector_conjugate_multiply(ofdm, acarrier, i, work);        
-            ofdm->rx_sym[rr + 1][i] = vector_sum(acarrier, 0, (OFDM_NC + 2));
-        }
+        matrix_vector_conjugate_multiply(ofdm, ofdm->rx_sym[rr + 1], work);        
     }
 
     /* next pilot */
@@ -552,10 +545,7 @@ void ofdm_demod(struct OFDM *ofdm, int *rx_bits, COMP *rxbuf_in) {
         work[k] = ofdm->rxbuf[j] * cexpf(-I * woff_est * j);
     }
 
-    for (i = 0; i < (OFDM_NC + 2); i++) {
-        matrix_vector_conjugate_multiply(ofdm, acarrier, i, work);        
-        ofdm->rx_sym[(OFDM_NS + 2)][i] = vector_sum(acarrier, 0, (OFDM_NC + 2));
-    }
+    matrix_vector_conjugate_multiply(ofdm, ofdm->rx_sym[OFDM_NS + 2], work);        
 
     /* est freq err based on all carriers ------------------------------------ */