Definition in file dsp16_resampling.c.
#include "dsp.h"
Go to the source code of this file.
Defines | |
#define | DSP16_RESAMPLING_FILTER(x_num, data) sum += ph[(x_num+data)] * pvect2[-(x_num+data)]; |
#define | DSP16_RESAMPLING_FUNCTION_NAME(x_num, data) TPASTE2(dsp16_resampling_kernel_x, x_num), |
#define | DSP16_RESAMPLING_KERNEL_X_FCT(x_num, data) |
#define | DSP16_RESAMPLING_NO_LOOP_FUNCTION_NAME(x_num, data) TPASTE2(dsp16_resampling_no_loop_kernel_x, x_num), |
#define | DSP16_RESAMPLING_NO_LOOP_KERNEL_X_FCT(x_num, data) |
#define | LOOP_UNROLL 6 |
#define | LOOP_UNROLL_PLUS_ONE 7 |
#define | NB_PTS_TO_INTERPOLATE 3 |
Functions | |
void | dsp16_resampling_compute (dsp_resampling_t *dsp_resampling, dsp16_t *output, dsp16_t *input, int channel) |
The re-sampling computation function. | |
void | dsp16_resampling_free (dsp_resampling_t *dsp_resampling, free_fct_t free_fct) |
Function used to free the previously allocted structure issued by the dsp16_resampling_setup function. | |
int | dsp16_resampling_get_output_current_buffer_size (dsp_resampling_t *dsp_resampling) |
Returns the current length in sample of the output signal. | |
int | dsp16_resampling_get_output_max_buffer_size (dsp_resampling_t *dsp_resampling) |
Returns the maximal length in sample of the output signal. | |
bool | dsp16_resampling_link (dsp_resampling_t *dsp_resampling_output, dsp_resampling_t *dsp_resampling_input) |
Link a stream previously re-sampled using the dsp_resampling_input resampling structure with the new re-sampling structure dsp_resampling_output. This is used to keep the continuity with two pieces of a stream re-sampled using two different re-sampling parameters. | |
static int | dsp16_resampling_no_loop_kernel_x0 (dsp16_t *vect1, dsp16_t *vect2, int vect2_size, dsp16_t *h, int n_tap, int interpolation_ratio, int decimation_ratio, int *pcounter, int *pn) |
static void | dsp16_resampling_polynomial_interpolation (dsp16_t y[4], dsp16_t output_y[NB_PTS_TO_INTERPOLATE]) |
dsp_resampling_t * | dsp16_resampling_setup (int input_sample_rate, int output_sample_rate, int buffer_size, int filter_order, int nb_channels, malloc_fct_t malloc_fct, dsp_resampling_options_t options) |
This function is the 16-bit signal resampling setup function. It has to be called only once at the initialization of the resampling process. | |
static int | dsp_op_gcd (int m, int n) |
static void | resampling_windowing (dsp16_t *vect1, int size) |
#define DSP16_RESAMPLING_FILTER | ( | x_num, | |||
data | ) | sum += ph[(x_num+data)] * pvect2[-(x_num+data)]; |
Definition at line 62 of file dsp16_resampling.c.
#define DSP16_RESAMPLING_FUNCTION_NAME | ( | x_num, | |||
data | ) | TPASTE2(dsp16_resampling_kernel_x, x_num), |
#define DSP16_RESAMPLING_KERNEL_X_FCT | ( | x_num, | |||
data | ) |
Definition at line 207 of file dsp16_resampling.c.
#define DSP16_RESAMPLING_NO_LOOP_FUNCTION_NAME | ( | x_num, | |||
data | ) | TPASTE2(dsp16_resampling_no_loop_kernel_x, x_num), |
#define DSP16_RESAMPLING_NO_LOOP_KERNEL_X_FCT | ( | x_num, | |||
data | ) |
Definition at line 295 of file dsp16_resampling.c.
#define LOOP_UNROLL 6 |
Definition at line 49 of file dsp16_resampling.c.
Referenced by dsp16_filt_interpolation(), and dsp16_resampling_compute().
#define LOOP_UNROLL_PLUS_ONE 7 |
Definition at line 50 of file dsp16_resampling.c.
Referenced by dsp16_filt_interpolation(), and dsp16_resampling_compute().
#define NB_PTS_TO_INTERPOLATE 3 |
Definition at line 54 of file dsp16_resampling.c.
Referenced by dsp16_resampling_compute(), and dsp16_resampling_setup().
static int dsp16_resampling_no_loop_kernel_x0 | ( | dsp16_t * | vect1, | |
dsp16_t * | vect2, | |||
int | vect2_size, | |||
dsp16_t * | h, | |||
int | n_tap, | |||
int | interpolation_ratio, | |||
int | decimation_ratio, | |||
int * | pcounter, | |||
int * | pn | |||
) | [static] |
Definition at line 332 of file dsp16_resampling.c.
00333 { 00334 int k, n; 00335 dsp16_t *pvect1; 00336 dsp16_t *pvect2; 00337 int counter; 00338 int size = 0; 00339 00340 pvect1 = vect1; 00341 00342 n = *pn; 00343 counter = *pcounter; 00344 while(n < vect2_size) 00345 { 00346 pvect2 = &vect2[n]; 00347 for(k=counter; k<interpolation_ratio; k += decimation_ratio) 00348 { 00349 *pvect1++ = *pvect2; 00350 size++; 00351 } 00352 counter = k / interpolation_ratio; 00353 n += counter; 00354 counter = k - counter * interpolation_ratio; 00355 } 00356 *pcounter = counter; 00357 *pn = n - vect2_size; 00358 00359 return size; 00360 }
static void dsp16_resampling_polynomial_interpolation | ( | dsp16_t | y[4], | |
dsp16_t | output_y[NB_PTS_TO_INTERPOLATE] | |||
) | [static] |
Definition at line 375 of file dsp16_resampling.c.
Referenced by dsp16_resampling_compute().
00376 { 00377 dsp32_t f_x0_x1, f_x1_x2, f_x2_x3; 00378 dsp32_t f_x0_x1_x2, f_x1_x2_x3; 00379 dsp32_t f_x0_x1_x2_x3; 00380 int i; 00381 const int x0 = 0; 00382 const int x1 = 1; 00383 const int x2 = NB_PTS_TO_INTERPOLATE + 1; 00384 const int x3 = NB_PTS_TO_INTERPOLATE + 2; 00385 00386 // Compute the interpolation coefficients using the Newton method 00387 f_x0_x1 = ((dsp32_t) y[1] - y[0]) / (x1 - x0); 00388 f_x1_x2 = ((dsp32_t) y[2] - y[1]) / (x2 - x1); 00389 f_x2_x3 = ((dsp32_t) y[3] - y[2]) / (x3 - x2); 00390 00391 f_x0_x1_x2 = (f_x1_x2 - f_x0_x1) / (x2 - x0); 00392 f_x1_x2_x3 = (f_x2_x3 - f_x1_x2) / (x3 - x1); 00393 00394 f_x0_x1_x2_x3 = (f_x1_x2_x3 - f_x0_x1_x2) / (x3 - x0); 00395 00396 // The polynom equals: 00397 // P = x0 + f_x0_x1 * e1(x) + f_x0_x1_x2 * e2(x) + f_x0_x1_x2_x3 * e3(x) 00398 // Where: 00399 // e1(x) = (x - x0) 00400 // e2(x) = (x - x0) * (x - x1) 00401 // e3(x) = (x - x0) * (x - x1) * (x - x2) 00402 00403 for (i=0; i<NB_PTS_TO_INTERPOLATE; i++) 00404 { 00405 int e1, e2, e3; 00406 int x = i + 2; 00407 dsp32_t temp_y; 00408 00409 e1 = (x - x0); 00410 e2 = e1 * (x - x1); 00411 e3 = e2 * (x - x2); 00412 00413 temp_y = y[0] + f_x0_x1 * e1 + f_x0_x1_x2 * e2 + f_x0_x1_x2_x3 * e3; 00414 output_y[i] = (dsp16_t) temp_y; 00415 } 00416 }
static int dsp_op_gcd | ( | int | m, | |
int | n | |||
) | [static] |
Definition at line 67 of file dsp16_resampling.c.
Referenced by dsp16_resampling_setup().
00068 { 00069 int r; 00070 if (m < n) 00071 { 00072 int temp; 00073 temp = m; 00074 m = n; 00075 n = temp; 00076 } 00077 r = m - (m / n) * n; 00078 while(r != 0) 00079 { 00080 m = n; 00081 n = r; 00082 r = m - (m / n) * n; 00083 } 00084 return n; 00085 }
static void resampling_windowing | ( | dsp16_t * | vect1, | |
int | size | |||
) | [static] |
Definition at line 87 of file dsp16_resampling.c.
References dsp16_win_hann().
Referenced by dsp16_resampling_setup().
00088 { 00089 dsp16_win_hann(vect1, size); 00090 }