mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
2.8 KiB
C
104 lines
2.8 KiB
C
4 years ago
|
/**
|
||
4 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
4 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
4 years ago
|
*
|
||
4 years ago
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
4 years ago
|
*
|
||
|
*/
|
||
|
|
||
|
/******************************************************************************
|
||
|
* File: resampler.h
|
||
|
*
|
||
|
* Description: Linear and vector interpolation
|
||
|
*
|
||
|
* Reference:
|
||
|
*****************************************************************************/
|
||
|
|
||
4 years ago
|
#ifndef SRSRAN_RESAMPLER_H
|
||
|
#define SRSRAN_RESAMPLER_H
|
||
4 years ago
|
|
||
|
#include <stdbool.h>
|
||
|
#include <stdint.h>
|
||
|
|
||
4 years ago
|
#include "srsran/config.h"
|
||
|
#include "srsran/phy/dft/dft.h"
|
||
4 years ago
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
/**
|
||
|
* Resampler operating modes
|
||
|
*/
|
||
|
typedef enum {
|
||
4 years ago
|
SRSRAN_RESAMPLER_MODE_INTERPOLATE = 0,
|
||
|
SRSRAN_RESAMPLER_MODE_DECIMATE,
|
||
|
} srsran_resampler_mode_t;
|
||
4 years ago
|
|
||
|
/**
|
||
|
* Resampler internal buffers and subcomponents
|
||
|
*/
|
||
|
typedef struct {
|
||
4 years ago
|
srsran_resampler_mode_t mode;
|
||
4 years ago
|
uint32_t ratio;
|
||
|
uint32_t window_sz;
|
||
4 years ago
|
srsran_dft_plan_t fft;
|
||
|
srsran_dft_plan_t ifft;
|
||
4 years ago
|
uint32_t state_len;
|
||
|
cf_t* in_buffer;
|
||
|
cf_t* out_buffer;
|
||
|
cf_t* state;
|
||
|
cf_t* filter;
|
||
4 years ago
|
} srsran_resampler_fft_t;
|
||
4 years ago
|
|
||
|
/**
|
||
|
* Initialise an FFT based resampler which can be configured as decimator or interpolator.
|
||
|
* @param q Object pointer
|
||
|
* @param mode Determines whether the operation mode is decimation or interpolation
|
||
|
* @param ratio Operational ratio
|
||
4 years ago
|
* @return SRSRAN_SUCCES if no error, otherwise an SRSRAN error code
|
||
4 years ago
|
*/
|
||
4 years ago
|
SRSRAN_API int srsran_resampler_fft_init(srsran_resampler_fft_t* q, srsran_resampler_mode_t mode, uint32_t ratio);
|
||
4 years ago
|
|
||
4 years ago
|
/**
|
||
|
* @brief resets internal re-sampler state
|
||
|
* @param q Object pointer
|
||
|
*/
|
||
4 years ago
|
SRSRAN_API void srsran_resampler_fft_reset_state(srsran_resampler_fft_t* q);
|
||
4 years ago
|
|
||
4 years ago
|
/**
|
||
|
* Get delay from the FFT based resampler.
|
||
|
* @param q Object pointer
|
||
|
* @return the delay in number of samples
|
||
|
*/
|
||
4 years ago
|
SRSRAN_API uint32_t srsran_resampler_fft_get_delay(srsran_resampler_fft_t* q);
|
||
4 years ago
|
|
||
|
/**
|
||
4 years ago
|
* @brief Run FFT based resampler in the initiated mode.
|
||
|
*
|
||
|
* @note Setting the input to NULL is equivalent of feeding zeroes
|
||
|
* @note Setting the output to NULL is equivalent of dropping output samples
|
||
|
*
|
||
4 years ago
|
* @param q Object pointer, make sure it has been initialised
|
||
|
* @param input Points at the input complex buffer
|
||
|
* @param output Points at the output complex buffer
|
||
|
* @param nsamples Number of samples to apply the processing
|
||
|
*/
|
||
4 years ago
|
SRSRAN_API void srsran_resampler_fft_run(srsran_resampler_fft_t* q, const cf_t* input, cf_t* output, uint32_t nsamples);
|
||
4 years ago
|
|
||
|
/**
|
||
|
* Free FFT based resampler buffers and subcomponents
|
||
|
* @param q Object pointer
|
||
|
*/
|
||
4 years ago
|
SRSRAN_API void srsran_resampler_fft_free(srsran_resampler_fft_t* q);
|
||
4 years ago
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
4 years ago
|
#endif // SRSRAN_RESAMPLER_H
|