#include
#include "ipp.h"
// Filter bank for Db, order 2, filter
static const int fwdFltLenL = 4;
static const int fwdFltLenH = 4;
static const float fwdFltL[4] =
{
-1.294095225509215e-001f,
2.241438680418574e-001f,
8.365163037374690e-001f,
4.829629131446903e-001f
};
static const float fwdFltH[4] =
{
-4.829629131446903e-001f,
8.365163037374690e-001f,
-2.241438680418574e-001f,
-1.294095225509215e-001f
};
static const int invFltLenL = 4;
static const int invFltLenH = 4;
static const float invFltL[4] =
{
4.829629131446903e-001f,
8.365163037374690e-001f,
2.241438680418574e-001f,
-1.294095225509215e-001
};
static const float invFltH[4] =
{
-1.294095225509215e-001,
-2.241438680418574e-001,
8.365163037374690e-001,
-4.829629131446903e-001
};
// minimal values, that corresponds to MATLAB calculations
static const int fwdFltOffsL = -1;
static const int fwdFltOffsH = -1;
// minimal values, that corresponds to MATLAB calculations
static const int invFltOffsL = 0;
static const int invFltOffsH = 0;
void main(void)
{
Ipp32f src[] = {1, -10, 324, 48, -483, 4, 7, -5532, 34, 8889, -57, 54};
Ipp32f low[7];
Ipp32f high[7];
int i;
printf("original:\\n");
for(i = 0; i < 12; i++) printf("%.0f; ", src);
printf("\\n");
{
// actually it can be single pointer for this offsets,
// but in general case it need to be different
Ipp32f srcExtBegL[2] = {src[10], src[11]}; // wrap [fwdFltLenL + fwdFltOffsL - 1] elements
Ipp32f srcExtBegH[2] = {src[10], src[11]}; // wrap [fwdFltLenH + fwdFltOffsH - 1] elements
Ipp32f srcExtEnd[] = { src[0], src[1] }; // to emulate MATLAB excessive 7's element, that repeat first
IppsWTFwdState_32f* state;
ippsWTFwdInitAlloc_32f (&state, fwdFltL, fwdFltLenL, fwdFltOffsL, fwdFltH, fwdFltLenH, fwdFltOffsH);
ippsWTFwdSetDlyLine_32f( state, srcExtBegL, srcExtBegH);
ippsWTFwd_32f (src, low, high, 6, state);
ippsWTFwd_32f (srcExtEnd, &low[6], &high[6], 1, state);
ippsWTFwdFree_32f (state);
// the forward part is relatively clear. still some questions: (1) the delay-lines lengths seems to follow from the fact thata 0 offset in ippsWTFwdInitAlloc_32f() for the low (high) filter means that the last sample of the filter is placed on the first sample of the data for the first convolution. is that right? (2) the ippsWTFwdSetDlyLine_32f() sets the "prehistory" of the data, that is set the extension on the beginning of the data. do I need laso to worry about the extension on the end? if not, why?
// print decomposition result
printf("approx:\\n");
for(i = 0; i < 7; i++) printf("%.4f; ", low);
printf("\\n");
printf("details:\\n");
for(i = 0; i < 7; i++) printf("%.4f; ", high);
printf("\\n");
}
// note actually we simply do not need to keep MATLAB excessive low[6] & high[6] elements
// it can be applied as wrapped extension from first element
// let's change it to 'trash' to check it
low[6] = 1e20f;
high[6] = -1e10f;
{
// here is first data itself, that we need to place to delay line
// this is for non-shifted reconstruction for given conditions
// (filt. len. and offs.)
// see ippsWTInv_32f first call with &low[1] and &high[1]
// but in other conditions you may need to place wrapped data here also
Ipp32f extBegL[1] = {low[0]}; // [(invFltLenL + invFltOffsL - 1) / 2] elements
Ipp32f extBegH[1] = {high[0]}; // [(invFltLenH + invFltOffsH - 1) / 2] elements
// why are the "beginning extensions" (infered by their names and usage) are initialized with the beginning of the data and not the end like in the forward case above?
// we decide do not use low[6] and high[6], so
// we need to extend borders honestly by wrapping
// and, please, note
// we do not use BIG buffer and copying, just input data itself
// and little extension in other memory place
Ipp32f extEndL[1] = {low[0]};
Ipp32f extEndH[1] = {high[0]};
// how do I determine the end extension lengths (for the beginning extensions I have the above formula) ?
Ipp32f dst[12];
IppsWTInvState_32f* state;
ippsWTInvInitAlloc_32f (&state, invFltL, invFltLenL, invFltOffsL, invFltH, invFltLenH, invFltOffsH);
ippsWTInvSetDlyLine_32f( state, extBegL, extBegH);
ippsWTInv_32f (&low[1], &high[1], 5, dst, state);
ippsWTInv_32f (extEndL, extEndH, 1, &dst[10], state);
// why do we have to call ippsWTInv_32f() twice? is it always with teh end extensions in the second call? how do I determine the data offset (in the above case the offset is 1) in teh first call?
ippsWTInvFree_32f (state);
// print reconstruction result
int i;
printf("reconstruction:\\n");
for(i = 0; i < 12; i++) printf("%.0f; ", dst);
printf("\\n");
}
}
Link Copied
Hi,
Refre to PP User Manual for wavelet Example,i hope this will help you understand the parameter settings.
Thanks,
Naveen Gv
For more complete information about compiler optimizations, see our Optimization Notice.