fork/rust-sdks
git clone https://git.julia.blue/fork/rust-sdks
2e4d385
main
1/* SoX Resampler Library Copyright (c) 2007-16 robs@users.sourceforge.net 2* Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 4/* Resample using a non-interpolated poly-phase FIR with length LEN. */ 5/* Input must be followed by FIR_LENGTH-1 samples. */ 6 7#if SIMD_AVX || SIMD_SSE || SIMD_NEON 8#define N (FIR_LENGTH>>2) 9#define BEGINNING v4_t sum = vZero(); \ 10 v4_t const * const __restrict coefs = (v4_t *)COEFS + N * rem; 11#define _ sum = vMac(vLdu(at+j*4), coefs[j], sum), ++j; 12#define END vStorSum(output+i, sum) 13#define cc (n ) case n: core(n); break 14#define CORE (n ) switch (n) {cc(2); cc(3); cc(4); cc(5); cc(6); default: core(n);} 15#else 16#define N FIR_LENGTH 17#define BEGINNING sample_t sum = 0; \ 18 sample_t const * const __restrict coefs = (sample_t *)COEFS + N * rem; 19#define _ sum += coefs[j]*at[j], ++j; 20#define END output[i] = sum 21#define CORE (n ) core(n) 22#endif 23 24#define core (n ) \ 25 for (i = 0; at < num_in * p->L; ++i, at += step) { \ 26 int const div = at / p->L, rem = at % p->L; \ 27 sample_t const * const __restrict at = input + div; \ 28 int j = 0; BEGINNING; CONVOLVE(n); END;} 29 30static void FUNCTION (stage_t * p ,fifo_t * output_fifo ) 31{ 32int num_in = min (stage_occupancy (p ),p -> input_size ); 33if (num_in ) { 34sample_t const * input = stage_read_p (p ); 35int at = p -> at .integer ,step = p -> step .integer ; 36int i ,num_out = (num_in * p -> L - at + step - 1 ) /step ; 37sample_t * __restrictoutput = fifo_reserve (output_fifo ,num_out ); 38 39CORE (N ); 40assert (i == num_out ); 41fifo_read (& p -> fifo ,at /p -> L ,NULL ); 42p -> at .integer = at %p -> L ; 43 } 44} 45 46#undef _ 47#undef CORE 48#undef cc 49#undef core 50#undef N 51#undef BEGINNING 52#undef MIDDLE 53#undef END 54#undef CONVOLVE 55#undef FIR_LENGTH 56#undef FUNCTION