From: okcsampson Date: Sat, 31 Mar 2018 17:44:56 +0000 (+0000) Subject: Update carrier table generation X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=b096ac044b30996c49a103b371b540cb17460214;p=freetel-svn-tracking.git Update carrier table generation git-svn-id: https://svn.code.sf.net/p/freetel/code@3443 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/src/ofdm.c b/codec2-dev/src/ofdm.c index 3631f982..e47b18ed 100644 --- a/codec2-dev/src/ofdm.c +++ b/codec2-dev/src/ofdm.c @@ -307,15 +307,20 @@ static void ofdm_txframe(struct OFDM *ofdm, complex float tx[OFDM_SAMPLESPERFRAM * Return NULL on fail */ -struct OFDM *ofdm_create(const struct OFDM_CONFIG * config) { +struct OFDM *ofdm_create(const struct OFDM_CONFIG *config) { struct OFDM *ofdm; - int i, j; + int i, j, n; if ((ofdm = (struct OFDM *) malloc(sizeof (struct OFDM))) == NULL) { return NULL; } /* Copy config structure */ + + if (config == NULL) { /* prevent segmentation error */ + return NULL; + } + memcpy((void*)&ofdm->config,(void*)config,sizeof(struct OFDM_CONFIG)); /* store complex BPSK pilot symbols */ @@ -326,20 +331,14 @@ struct OFDM *ofdm_create(const struct OFDM_CONFIG * config) { /* carrier tables for up and down conversion */ - int Nlower = floorf((OFDM_CENTRE - OFDM_RS * (OFDM_NC / 2)) / OFDM_RS); + float lower = OFDM_CENTRE - OFDM_RS * (OFDM_NC / 2); + int Nlower = floorf(lower / OFDM_RS); - for (i = 0, j = Nlower; i < (OFDM_NC + 2); i++, j++) { - /* - * 2 * pi * j/144 j=19..36 - * j = 1 kHz to 2 kHz (1.5 kHz center) - */ - - ofdm->w[i] = TAU * (float) j / (OFDM_FS / OFDM_RS); - } + for (i = 0, n = Nlower; i < (OFDM_NC + 2); i++, n++) { + float w = (TAU * (float) n) / (OFDM_FS / OFDM_RS); - for (i = 0; i < (OFDM_NC + 2); i++) { for (j = 0; j < OFDM_M; j++) { - ofdm->W[i][j] = cexpf(I * ofdm->w[i] * j); + ofdm->W[i][j] = cexpf(I * w * j); } } diff --git a/codec2-dev/src/ofdm_internal.h b/codec2-dev/src/ofdm_internal.h index 162cf334..5d37a322 100644 --- a/codec2-dev/src/ofdm_internal.h +++ b/codec2-dev/src/ofdm_internal.h @@ -106,7 +106,6 @@ struct OFDM { complex float W[OFDM_NC + 2][OFDM_M]; complex float rxbuf[OFDM_RXBUF]; complex float pilots[OFDM_NC + 2]; - float w[OFDM_NC + 2]; /* Demodulator data */