From: okcsampson Date: Sat, 17 Jun 2017 15:58:42 +0000 (+0000) Subject: Update ofdm.c demod X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=1101d5295f4d75a6bfb8085b487db279532aa671;p=freetel-svn-tracking.git Update ofdm.c demod git-svn-id: https://svn.code.sf.net/p/freetel/code@3209 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/src/ofdm.c b/codec2-dev/src/ofdm.c index 06ea6b9c..e8a310dd 100644 --- a/codec2-dev/src/ofdm.c +++ b/codec2-dev/src/ofdm.c @@ -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 ------------------------------------ */