void sync_free(sync_t *q) { if (q) { pss_synch_free(&q->pss); sss_synch_free(&q->sss); cfo_free(&q->cfocorr); } }
void sync_free(sync_t *q) { int N_id_2; for (N_id_2=0;N_id_2<3;N_id_2++) { pss_synch_free(&q->pss[N_id_2]); sss_synch_free(&q->sss[N_id_2]); } }
/* Initializes the PSS synchronization object. * * It correlates a signal of frame_size samples with the PSS sequence in the frequency * domain. The PSS sequence is transformed using fft_size samples. */ int pss_synch_init_fft(pss_synch_t *q, uint32_t frame_size, uint32_t fft_size) { int ret = LIBLTE_ERROR_INVALID_INPUTS; if (q != NULL) { uint32_t N_id_2; uint32_t buffer_size; bzero(q, sizeof(pss_synch_t)); q->N_id_2 = 10; q->fft_size = fft_size; q->frame_size = frame_size; buffer_size = fft_size + frame_size + 1; q->tmp_input = vec_malloc(buffer_size * sizeof(cf_t)); if (!q->tmp_input) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; } q->conv_output = vec_malloc(buffer_size * sizeof(cf_t)); if (!q->conv_output) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; } for (N_id_2=0;N_id_2<3;N_id_2++) { q->pss_signal_freq[N_id_2] = vec_malloc(buffer_size * sizeof(cf_t)); if (!q->pss_signal_freq[N_id_2]) { fprintf(stderr, "Error allocating memory\n"); goto clean_and_exit; } /* The PSS is translated into the frequency domain for each N_id_2 */ if (pss_synch_init_N_id_2(q->pss_signal_freq[N_id_2], N_id_2, fft_size)) { fprintf(stderr, "Error initiating PSS detector for N_id_2=%d fft_size=%d\n", N_id_2, fft_size); goto clean_and_exit; } } #ifdef CONVOLUTION_FFT if (conv_fft_cc_init(&q->conv_fft, frame_size, fft_size)) { fprintf(stderr, "Error initiating convolution FFT\n"); goto clean_and_exit; } #endif ret = LIBLTE_SUCCESS; } clean_and_exit: if (ret == LIBLTE_ERROR) { pss_synch_free(q); } return ret; }