diff --git a/srslte/include/srslte/sync/pss.h b/srslte/include/srslte/sync/pss.h index c805870b9..e3ee6fc99 100644 --- a/srslte/include/srslte/sync/pss.h +++ b/srslte/include/srslte/sync/pss.h @@ -82,7 +82,8 @@ typedef struct SRSLTE_API { uint32_t frame_size; uint32_t N_id_2; uint32_t fft_size; - + cf_t pss_signal_freq_full; + cf_t *pss_signal_time[3]; cf_t pss_signal_freq[3][SRSLTE_PSS_LEN]; // One sequence for each N_id_2 cf_t *tmp_input; diff --git a/srslte/include/srslte/utils/convolution.h b/srslte/include/srslte/utils/convolution.h index fbbf06bce..0b239ea20 100644 --- a/srslte/include/srslte/utils/convolution.h +++ b/srslte/include/srslte/utils/convolution.h @@ -50,7 +50,7 @@ typedef struct SRSLTE_API { srslte_dft_plan_t filter_plan; srslte_dft_plan_t output_plan; cf_t *pss_signal_time_fft[3]; // One sequence for each N_id_2 - cf_t *pss_signal_time[3]; + //cf_t *pss_signal_time[3]; }srslte_conv_fft_cc_t; diff --git a/srslte/lib/sync/pss.c b/srslte/lib/sync/pss.c index 661dd94a7..f6c49ac86 100644 --- a/srslte/lib/sync/pss.c +++ b/srslte/lib/sync/pss.c @@ -179,10 +179,12 @@ int srslte_pss_synch_init_fft_offset(srslte_pss_synch_t *q, uint32_t frame_size, } #ifdef CONVOLUTION_FFT - for(N_id_2 = 0; N_id_2<3; N_id_2++) - q->conv_fft.pss_signal_time[N_id_2] = q->pss_signal_time[N_id_2]; + //for(N_id_2 = 0; N_id_2<3; N_id_2++) + // q->conv_fft.pss_signal_time[N_id_2] = q->pss_signal_time[N_id_2]; + + - if (srslte_conv_fft_cc_init(&q->conv_fft, frame_size, fft_size)) { + if (srslte_conv_fft_cc_init(&q->conv_fft, frame_size, fft_size, q->pss_signal_time, )) { fprintf(stderr, "Error initiating convolution FFT\n"); goto clean_and_exit; } diff --git a/srslte/lib/utils/convolution.c b/srslte/lib/utils/convolution.c index 908e1b29a..797cbd655 100644 --- a/srslte/lib/utils/convolution.c +++ b/srslte/lib/utils/convolution.c @@ -31,15 +31,20 @@ #include "srslte/dft/dft.h" #include "srslte/utils/vector.h" #include "srslte/utils/convolution.h" +int srslte_conv_fft_cc_init(srslte_conv_fft_cc_t *q, uint32_t input_len, uint32_t filter_len) +{ + srslte_conv_fft_cc_init_opt(q, input_len, filter_len, NULL, NULL); +} - -int srslte_conv_fft_cc_init(srslte_conv_fft_cc_t *q, uint32_t input_len, uint32_t filter_len) { +int srslte_conv_fft_cc_init_opt(srslte_conv_fft_cc_t *q, uint32_t input_len, uint32_t filter_len, cf_t **filter_time, cf_t **filter_freq) { q->input_len = input_len; q->filter_len = filter_len; q->output_len = input_len+filter_len; q->input_fft = srslte_vec_malloc(sizeof(cf_t)*q->output_len); q->filter_fft = srslte_vec_malloc(sizeof(cf_t)*q->output_len); q->output_fft = srslte_vec_malloc(sizeof(cf_t)*q->output_len); + + if (!q->input_fft || !q->filter_fft || !q->output_fft) { return SRSLTE_ERROR; } @@ -59,14 +64,13 @@ int srslte_conv_fft_cc_init(srslte_conv_fft_cc_t *q, uint32_t input_len, uint32_ srslte_dft_plan_set_norm(&q->filter_plan, true); srslte_dft_plan_set_norm(&q->output_plan, false); - for(int i =0; i< 3; i++) + if(filter_time != NULL) { - q->pss_signal_time_fft[i] = srslte_vec_malloc(sizeof(cf_t)*q->output_len); - - srslte_dft_run_c(&q->filter_plan, q->pss_signal_time[i], q->pss_signal_time_fft[i]); - + for(int i =0; i< 3; i++) + { + srslte_dft_run_c(&q->filter_plan, filter_time[i], filter_freq[i]); + } } - return SRSLTE_SUCCESS; } @@ -93,11 +97,11 @@ void srslte_conv_fft_cc_free(srslte_conv_fft_cc_t *q) { } -uint32_t srslte_conv_fft_cc_run_opt(srslte_conv_fft_cc_t *q, cf_t *input, int N_id_2, cf_t *output) +uint32_t srslte_conv_fft_cc_run_opt(srslte_conv_fft_cc_t *q, cf_t *input,cf_t *filter_freq, cf_t *output) { srslte_dft_run_c(&q->input_plan, input, q->input_fft); - srslte_vec_prod_ccc(q->input_fft,q->pss_signal_time_fft[N_id_2],q->output_fft,q->output_len); - srslte_dft_run_c(&q->output_plan, q->output_fft, output); + srslte_vec_prod_ccc(q->input_fft, filter_freq, q->output_fft, q->output_len); + srslte_dft_run_c(&q->output_plan, q->output_fft, output); return (q->output_len-1); // divide output length by dec factor