html/ 0000755 0001750 0001750 00000000000 14721467000 011003 5 ustar build build html/doxygen.svg 0000644 0001750 0001750 00000036026 14721466775 013232 0 ustar build build html/iqbal_8c.html 0000644 0001750 0001750 00000035213 14721467000 013357 0 ustar build build
libosmodsp 0.4.0.8-9128
Osmocom DSP library
|
IQ balance utils implementation. More...
Data Structures | |
struct | _iqbal_estimate_state |
Cache for _osmo_iqbal_estimate when doing lots of calls. More... | |
struct | _iqbal_state |
Internal state structure for the IQ balance optimization algorithm. More... | |
Functions | |
void | osmo_iqbal_fix (float complex *out, float complex *in, unsigned int len, float mag, float phase) |
Apply IQ balance correction to a given complex buffer. More... | |
struct osmo_cxvec * | osmo_iqbal_cxvec_fix (const struct osmo_cxvec *in, float mag, float phase, struct osmo_cxvec *out) |
Apply IQ balance correction to a given complex vector. More... | |
static void | _osmo_iqbal_estimate_release (struct _iqbal_estimate_state *state) |
Release a cache object created by _osmo_iqbal_estimate. | |
static float | _osmo_iqbal_estimate (const float complex *data, int fft_size, int fft_count, struct _iqbal_estimate_state **state_p) |
Objectively estimate IQ balance in a given complex buffer. More... | |
float | osmo_iqbal_estimate (const float complex *data, int fft_size, int fft_count) |
Objectively estimate IQ balance in a given complex buffer. More... | |
float | osmo_iqbal_cxvec_estimate (const struct osmo_cxvec *sig, int fft_size, int fft_count) |
Objectively estimate IQ balance in a given complex vector. More... | |
static float | _iqbal_objfn_value (struct _iqbal_state *state, float x[2]) |
Optimization objective function - Value. More... | |
static void | _iqbal_objfn_gradient (struct _iqbal_state *state, float x[2], float v, float grad[2]) |
Optimization objective function - Gradient estimation. More... | |
static float | _iqbal_objfn_val_gradient (struct _iqbal_state *state, float x[2], float grad[2]) |
Optimization objective function - Value & Gradient estimation. More... | |
int | osmo_iqbal_cxvec_optimize (const struct osmo_cxvec *sig, float *mag, float *phase, const struct osmo_iqbal_opts *opts) |
Finds the best IQ balance correction parameters for a given signal. More... | |
Variables | |
const struct osmo_iqbal_opts | osmo_iqbal_default_opts |
Default values for the optimization algorithm. More... | |
IQ balance utils implementation.
The actual algorithm used for estimation of the imbalance and its optimization is inspired by the IQ balancer of SDR# by Youssef Touil and described here :
http://sdrsharp.com/index.php/automatic-iq-correction-algorithm
The main differences are:
libosmodsp 0.4.0.8-9128
Osmocom DSP library
|
Processing options for the IQ balance optimization algorithm. More...
#include <iqbal.h>
Data Fields | |
int | fft_size |
FFT size to use. | |
int | fft_count |
Number of FFT to use. | |
int | max_iter |
Max # iterations per pass. | |
int | start_at_prev |
Use prev values as starting point. | |
Processing options for the IQ balance optimization algorithm.
libosmodsp 0.4.0.8-9128
Osmocom DSP library
|
Files | |
file | cxvec_math.h |
Osmocom Complex vectors math header. | |
file | cxvec_math.c |
Osmocom Complex vectors math implementation. | |
Enumerations | |
enum | osmo_cxvec_conv_type { CONV_FULL_SPAN , CONV_OVERLAP_ONLY , CONV_NO_DELAY } |
Various possible types of convolution span. More... | |
enum | osmo_cxvec_peak_alg { PEAK_WEIGH_WIN , PEAK_WEIGH_WIN_CENTER , PEAK_EARLY_LATE } |
Various possible peak finding algorithms. More... | |
Functions | |
static float | osmo_sinc (float x) |
Unnormalized sinc function. More... | |
static float | osmo_normsqf (float complex c) |
Squared norm of a given complex. More... | |
struct osmo_cxvec * | osmo_cxvec_scale (const struct osmo_cxvec *in, float complex scale, struct osmo_cxvec *out) |
Scale a complex vector (multiply by a constant) More... | |
struct osmo_cxvec * | osmo_cxvec_rotate (const struct osmo_cxvec *in, float rps, struct osmo_cxvec *out) |
Rotate a complex vector (frequency shift) More... | |
struct osmo_cxvec * | osmo_cxvec_delay (const struct osmo_cxvec *in, float delay, struct osmo_cxvec *out) |
Fractionally delay a vector while maintaining its length. More... | |
struct osmo_cxvec * | osmo_cxvec_convolve (const struct osmo_cxvec *f, const struct osmo_cxvec *g, enum osmo_cxvec_conv_type type, struct osmo_cxvec *out) |
Convolve two complex vectors. More... | |
struct osmo_cxvec * | osmo_cxvec_correlate (const struct osmo_cxvec *f, const struct osmo_cxvec *g, int g_corr_step, struct osmo_cxvec *out) |
Cross-correlate two complex vectors. More... | |
float complex | osmo_cxvec_interpolate_point (const struct osmo_cxvec *cv, float pos) |
Interpolate any fractional position in a vector using sinc filtering. More... | |
int | osmo_cxvec_peaks_scan (const struct osmo_cxvec *cv, int *peaks_idx, int N) |
Find the index of the N highest energy ( ) peaks. More... | |
float | osmo_cxvec_peak_energy_find (const struct osmo_cxvec *cv, int win_size, enum osmo_cxvec_peak_alg alg, float complex *peak_val_p) |
Find the maximum energy ( ) peak in a sequence. More... | |
struct osmo_cxvec * | osmo_cxvec_sig_normalize (const struct osmo_cxvec *sig, int decim, float freq_shift, struct osmo_cxvec *out) |
'Normalize' an IQ signal and apply decimation/frequency shift More... | |
enum osmo_cxvec_conv_type |
enum osmo_cxvec_peak_alg |
struct osmo_cxvec * osmo_cxvec_convolve | ( | const struct osmo_cxvec * | f, |
const struct osmo_cxvec * | g, | ||
enum osmo_cxvec_conv_type | type, | ||
struct osmo_cxvec * | out | ||
) |
Convolve two complex vectors.
[in] | f | First input complex vector |
[in] | g | Second input complex vector |
[in] | type | The convolution span type |
[out] | out | Output complex vector |
The convolution of discrete sequences is defined as :
Altough the mathematical operation is commutative, the constraint of implementation limit this method. Depending on the type of span chosen, it might not be and it's always recommended that 'g' be the longer sequence. It should not be much of a limitation when this methos is used for filtering or pulseshaping : use 'f' as the filter and 'g' as the signal.
The output vector parameter 'out' can be NULL to allocate a new vector. If it's not NULL, it must be long enough to contain the result (length depends on the exact convolution type)
References CONV_FULL_SPAN, CONV_NO_DELAY, CONV_OVERLAP_ONLY, osmo_cxvec::data, osmo_cxvec::flags, osmo_cxvec::len, osmo_cxvec::max_len, and osmo_cxvec_alloc().
Referenced by osmo_cxvec_delay().
struct osmo_cxvec * osmo_cxvec_correlate | ( | const struct osmo_cxvec * | f, |
const struct osmo_cxvec * | g, | ||
int | g_corr_step, | ||
struct osmo_cxvec * | out | ||
) |
Cross-correlate two complex vectors.
[in] | f | First input complex vector |
[in] | g | Second input complex vector |
[in] | g_corr_step | Allow for oversampling of 'g' compared to 'f' |
[out] | out | Output complex vector |
The cross-correlation of discrete sequences is defined as :
In this implementation, the output vector will be for every n value between 0 and (g->len - f->len + 1). This assumes that g is the longer sequence and we 'fit' f at every positition inside it.
With the parameter g_corr_step, it's also possible to have a g sequence that is oversampled with regard to f. (if g_corr_step > 1)
The output vector parameter 'out' can be NULL to allocate a new vector. If it's not NULL, it must be long enough to contain the result (i.e. g->len - f->len + 1)
References osmo_cxvec::data, osmo_cxvec::flags, osmo_cxvec::len, osmo_cxvec::max_len, and osmo_cxvec_alloc().
struct osmo_cxvec * osmo_cxvec_delay | ( | const struct osmo_cxvec * | in, |
float | delay, | ||
struct osmo_cxvec * | out | ||
) |
Fractionally delay a vector while maintaining its length.
[in] | in | Input complex vector |
[in] | delay | The fractional delay to apply |
[out] | out | Output complex vector |
The output always has the same length. Samples pushed out by the delays are lost and new ones filled with zeroes are pushed in.
The output vector parameter 'out' can be NULL to allocate a new vector, or can be equal to the 'in' input vector to perform the transform in-place. If it's different, it must be long enough to contain the result (i.e. in->len)
References CONV_NO_DELAY, osmo_cxvec::data, osmo_cxvec::flags, osmo_cxvec::len, osmo_cxvec::max_len, osmo_cxvec_alloc(), osmo_cxvec_convolve(), osmo_cxvec_free(), osmo_cxvec_init_from_data(), and osmo_sinc().
float complex osmo_cxvec_interpolate_point | ( | const struct osmo_cxvec * | cv, |
float | pos | ||
) |
Interpolate any fractional position in a vector using sinc filtering.
[in] | cv | Input complex vector |
[in] | pos | Position to interpolate |
pos must be >= 0 and < cv->len
References osmo_cxvec::data, osmo_cxvec::flags, osmo_cxvec::len, and osmo_sinc().
Referenced by osmo_cxvec_peak_energy_find().
float osmo_cxvec_peak_energy_find | ( | const struct osmo_cxvec * | cv, |
int | win_size, | ||
enum osmo_cxvec_peak_alg | alg, | ||
float complex * | peak_val_p | ||
) |
Find the maximum energy ( ) peak in a sequence.
[in] | cv | Input complex vector |
[in] | win_size | Size of the window (for algorithms using windows) |
[in] | alg | Peak detection algorithm to use |
[out] | peak_val_p | Returns interpolated peak value if non-NULL |
References osmo_cxvec::data, osmo_cxvec::len, osmo_cxvec_interpolate_point(), osmo_normsqf(), PEAK_EARLY_LATE, PEAK_WEIGH_WIN, and PEAK_WEIGH_WIN_CENTER.
int osmo_cxvec_peaks_scan | ( | const struct osmo_cxvec * | cv, |
int * | peaks_idx, | ||
int | N | ||
) |
Find the index of the N highest energy ( ) peaks.
[in] | cv | Input complex vector |
[out] | peaks_idx | Return array of the peak indexes |
[in] | Size | of the peaks_idx return array |
References osmo_cxvec::data, osmo_cxvec::len, and osmo_normsqf().
struct osmo_cxvec * osmo_cxvec_rotate | ( | const struct osmo_cxvec * | in, |
float | rps, | ||
struct osmo_cxvec * | out | ||
) |
Rotate a complex vector (frequency shift)
[in] | in | Input complex vector |
[in] | rps | Rotation to apply in radian per sample |
[out] | out | Output complex vector |
The output vector parameter 'out' can be NULL to allocate a new vector, or can be equal to the 'in' input vector to perform the transform in-place. If it's different, it must be long enough to contain the result (i.e. in->len)
References osmo_cxvec::data, osmo_cxvec::flags, osmo_cxvec::len, osmo_cxvec::max_len, and osmo_cxvec_alloc().
struct osmo_cxvec * osmo_cxvec_scale | ( | const struct osmo_cxvec * | in, |
float complex | scale, | ||
struct osmo_cxvec * | out | ||
) |
Scale a complex vector (multiply by a constant)
[in] | in | Input complex vector |
[in] | scale | Factor to apply to each sample |
[out] | out | Output complex vector |
The output vector parameter 'out' can be NULL to allocate a new vector, or can be equal to the 'in' input vector to perform the transform in-place. If it's different, it must be long enough to contain the result (i.e. in->len)
References osmo_cxvec::data, osmo_cxvec::flags, osmo_cxvec::len, osmo_cxvec::max_len, and osmo_cxvec_alloc().
struct osmo_cxvec * osmo_cxvec_sig_normalize | ( | const struct osmo_cxvec * | sig, |
int | decim, | ||
float | freq_shift, | ||
struct osmo_cxvec * | out | ||
) |
'Normalize' an IQ signal and apply decimation/frequency shift
[in] | sig | Input complex signal |
[in] | decim | Decimation factor |
[in] | freq_shift | Frequency shift in radian per output sample |
[out] | out | Output complex vector |
The operation performed are DC removal, amplitude normalization (divided by the standard deviation), decimation, frequency shift.
The output vector parameter 'out' can be NULL to allocate a new vector, or can be equal to the 'in' input vector to perform the transform in-place. If it's different, it must be long enough to contain the result (i.e. (sig->len + decim - 1) / decim)
References osmo_cxvec::data, osmo_cxvec::flags, osmo_cxvec::len, osmo_cxvec::max_len, osmo_cxvec_alloc(), and osmo_normsqf().
|
inlinestatic |
Squared norm of a given complex.
[in] | c | Complex number for which to compute the squared norm |
Referenced by _osmo_iqbal_estimate(), osmo_cxvec_peak_energy_find(), osmo_cxvec_peaks_scan(), and osmo_cxvec_sig_normalize().
|
inlinestatic |
Unnormalized sinc function.
[in] | x | Value for which to compute the sinc function. |
The function is defined as
Referenced by osmo_cxvec_delay(), and osmo_cxvec_interpolate_point().