diff --git a/lib/src/phy/ch_estimation/test/chest_nbiot_test_dl.c b/lib/src/phy/ch_estimation/test/chest_nbiot_test_dl.c index 1b1f885d6..b88e5a001 100644 --- a/lib/src/phy/ch_estimation/test/chest_nbiot_test_dl.c +++ b/lib/src/phy/ch_estimation/test/chest_nbiot_test_dl.c @@ -145,7 +145,7 @@ int main(int argc, char** argv) for (int n_port = 0; n_port < cell.base.nof_ports; n_port++) { srsran_vec_cf_zero(input, num_re); for (int i = 0; i < num_re; i++) { - input[i] = 0.5 - rand() / RAND_MAX + I * (0.5 - rand() / RAND_MAX); + input[i] = 0.5 - rand() / (float)RAND_MAX + I * (0.5 - rand() / (float)RAND_MAX); } srsran_vec_cf_zero(ce, num_re); diff --git a/lib/src/phy/ch_estimation/test/chest_test_dl.c b/lib/src/phy/ch_estimation/test/chest_test_dl.c index 96385c15d..79e358ff4 100644 --- a/lib/src/phy/ch_estimation/test/chest_test_dl.c +++ b/lib/src/phy/ch_estimation/test/chest_test_dl.c @@ -137,7 +137,7 @@ int main(int argc, char** argv) for (uint32_t n_port = 0; n_port < cell.nof_ports; n_port++) { srsran_vec_cf_zero(input, num_re); for (i = 0; i < num_re; i++) { - input[i] = 0.5 - rand() / RAND_MAX + I * (0.5 - rand() / RAND_MAX); + input[i] = 0.5 - rand() / (float)RAND_MAX + I * (0.5 - rand() / (float)RAND_MAX); } srsran_vec_cf_zero(ce, num_re); diff --git a/lib/src/phy/dft/dft_fftw.c b/lib/src/phy/dft/dft_fftw.c index 6c57ff843..b3f83a8d4 100644 --- a/lib/src/phy/dft/dft_fftw.c +++ b/lib/src/phy/dft/dft_fftw.c @@ -209,6 +209,7 @@ int srsran_dft_plan_guru_c(srsran_dft_plan_t* plan, plan->p = fftwf_plan_guru_dft(1, &iodim, 1, &howmany_dims, in_buffer, out_buffer, sign, FFTW_TYPE); if (!plan->p) { + pthread_mutex_unlock(&fft_mutex); return -1; } pthread_mutex_unlock(&fft_mutex); diff --git a/lib/src/phy/resampling/resampler.c b/lib/src/phy/resampling/resampler.c index 00223d6f3..7cef7dcba 100644 --- a/lib/src/phy/resampling/resampler.c +++ b/lib/src/phy/resampling/resampler.c @@ -234,31 +234,27 @@ static void resampler_fft_decimate(srsran_resampler_fft_t* q, const cf_t* input, while (count < nsamples) { uint32_t n = SRSRAN_MIN(q->window_sz, nsamples - count); - if (input) { - // Copy input samples - srsran_vec_cf_copy(q->in_buffer, &input[count], n); - - // Pad zeroes - srsran_vec_cf_zero(&q->in_buffer[n], q->fft.size - n); + // Copy input samples + srsran_vec_cf_copy(q->in_buffer, &input[count], n); - // Execute FFT - srsran_dft_run_guru_c(&q->fft); + // Pad zeroes + srsran_vec_cf_zero(&q->in_buffer[n], q->fft.size - n); - // Apply filter - srsran_vec_prod_ccc(q->out_buffer, q->filter, q->out_buffer, q->fft.size); + // Execute FFT + srsran_dft_run_guru_c(&q->fft); - // Decimate - srsran_vec_cf_copy(q->in_buffer, q->out_buffer, q->ifft.size); - for (uint32_t i = 1; i < q->ratio; i++) { - srsran_vec_sum_ccc(&q->out_buffer[q->ifft.size * i], q->in_buffer, q->in_buffer, q->ifft.size); - } + // Apply filter + srsran_vec_prod_ccc(q->out_buffer, q->filter, q->out_buffer, q->fft.size); - // Execute iFFT - srsran_dft_run_guru_c(&q->ifft); - } else { - srsran_vec_cf_zero(q->out_buffer, q->ifft.size); + // Decimate + srsran_vec_cf_copy(q->in_buffer, q->out_buffer, q->ifft.size); + for (uint32_t i = 1; i < q->ratio; i++) { + srsran_vec_sum_ccc(&q->out_buffer[q->ifft.size * i], q->in_buffer, q->in_buffer, q->ifft.size); } + // Execute iFFT + srsran_dft_run_guru_c(&q->ifft); + // Add previous state srsran_vec_sum_ccc(q->out_buffer, q->state, q->out_buffer, q->state_len);