Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Upsampling and downsampling, powers of 2

piet_de_weer
Beginner
996 Views

What is the fastest way to upsample or downsample a signal, given that both block sizes and up/downsample ratios are all powers of 2? For some audio processing filter I need to upsample and downsamplte my signal 16 (!) times, and I need to repeat this a lot of times per block of audio - my current method doesn't even run in realtime on my i7 system. Most important restriction: After downsampling the upsampled signal, the result must be identical to the original (except for rounding errors of course).

I currently use 2 FFTs for this: For example, downsampling looks like this (block size is 2^n): Typical block size: 4096 floats (n=12).

ippsFFTFwd_RToCCS_32f_I(in, pFFTSpec[n+downsampleratio], buf);
ippsFFTInv_CCSToR_32f(in, out, pFFTSpec, buf);

Upsampling:

ippsFFTFwd_RToCCS_32f(in, out, pFFTSpec, buf);
__m128 zero_mm = _mm_setzero_ps();
for (int count=number/4+1; count<=number*times/4+1; count++)
{
((__m128*)out)[count] = zero_mm;
}
ippsFFTInv_CCSToR_32f_I(out, pFFTSpec[n+newplus], buf);

 

0 Kudos
6 Replies
SergeyKostrov
Valued Contributor II
996 Views
>>... After downsampling the upsampled signal... Do you need to smooth the signal when upsampling?
0 Kudos
piet_de_weer
Beginner
996 Views

Yes, sorry I wasn't clear about that. I need to clip inter-sample peaks, then downsample again.

So what I actually need is: Upsample (x4) -> Clip -> Downsample (/4). For blocks of floats where the number of values is a power of 2 (usually 16384, 8192 or 4096). If clipping is not perfectly accurate (1% too much or too little) that would be acceptable.

Maybe also important: I know that there are no very high frequencies present (typical values are a maximum signal frequency of 60 kHz, for a sampling frequency of 176.4 or 192 kHz).

0 Kudos
SergeyKostrov
Valued Contributor II
996 Views
>>...Yes, sorry I wasn't clear about that. I need to clip inter-sample peaks... It looks like Not Upsamling and it looks like a Dynamic Range ( DR ) change with Cutting values when they over some Limit and the length of the signal stays the same, correct? Consider a signal with 3 samples 1, 4 and 7: [ Case 1 ] Input: 1 4 7 Upsample ( x3 / no smoothing / no DR change ): 1 1 1 4 4 4 7 7 7 [ Case 2 ] Input: 1 4 7 Upsample ( x3 / with smoothing / no DR change ): 1 2 3 4 5 6 7 8 9 [ Case 3 ] Input: 1 4 7 Upsample ( x3 / no smoothing / DR change x3 ): 3 3 3 12 12 12 21 21 21 [ Case 4 ] Input: 1 4 7 Upsample ( x3 / with smoothing / DR change x3 ): 3 6 9 12 15 18 21 24 27 What case is matching to what you need?
0 Kudos
piet_de_weer
Beginner
996 Views

There's no difference for me between 2 and 4, and they look like what I need.

Example set:
Input: -6 0 6 10 10 6 0 -6 -10 ...
With oversampling, that would give something like: -6 -3 0 3 6 8 10 11 10 8 6 3 0 -3 -6 -8 -10 .... (Note: Actual upsampling should result in something that looks much smoother than this it's just an example). The 11 is higher than any of the input values.
Now, say we clip at level 10. That leads to: -6 -3 0 3 6 8 10 10 10 8 6 3 0 -3 -6 -8 -10
After downsampling, that would lead to a reduction of the 2 '10' values in the input, and probably some other small effects. And that's what I need.

0 Kudos
SergeyKostrov
Valued Contributor II
996 Views
>>...What is the fastest way to upsample or downsample a signal... Consider resize and scaling ( with thresholding ) IPP functions but you need to compare performance of a new solution with FFT based ( your current one ).
0 Kudos
Igor_A_Intel
Employee
996 Views

Did you have a look at Multi-Rate FIRs? or ResamplePolyphaseFixed?

IPPAPI( IppStatus, ippsFIRMRInit_32f,( IppsFIRState_32f** ppState,
                   const Ipp32f* pTaps, int tapsLen, int upFactor, int upPhase,
      int downFactor, int downPhase, const Ipp32f* pDlyLine, Ipp8u* pBuffer ))

IPPAPI(IppStatus, ippsResamplePolyphaseFixed_32f,(const Ipp32f *pSrc, int len, Ipp32f *pDst,
                                       Ipp32f norm, Ipp64f *pTime, int *pOutlen,
                                       const IppsResamplingPolyphaseFixed_32f *pState))

regards, Igor

0 Kudos
Reply