Intel® Integrated Performance Primitives (Intel® IPP) Developer Guide and Reference
Wavelet Transforms Example
The delay line paradigm is well-known interface solution for functions that require some pre-history in the streaming processing. In such application the use of the Intel IPP wavelet transform functions is similar to the use of the FIR, IIR, or multi-rate filters. (See also the discussion on the synchronization of low-pass and high-pass filter delays in this chapter.) But very often the wavelet transforms are used to process entire non-streaming data by extending with borders that are suitable for filter bank type that are used in transforms.
The following code examples demonstrate how to implement this approach using the Intel IPP functions. They perform forward and inverse wavelet transforms of the same data with Daubechies filter banks (that allow the perfect reconstruction) and periodical data extension by wrapping. Each example is a complete program that checks the status returned by every Intel IPP function and prints the result on the console.
They may also be useful as an illustration of how to fill delay line, if you need non-zero pre-history of signal in streaming applications.
The examples differ in the order of the filter bank and in the way the periodical extension is provided:
Example |
Data |
Filter bank |
Extension by wrapping |
|---|---|---|---|
c_wtfwd_db2.c |
signal of 12 elements, ipps functions |
Daubechies 2 (four taps) |
substituted in place, without additional buffers |
c_wtfwd_db3.c |
signal of 12 elements, ipps functions |
Daubechies 3 (six taps) |
staged in explicit delay line arrays |
One-Dimensional Transform, Daubechies 2 Filter Bank
This example performs the forward and inverse wavelet transform of a short vector containing 12 elements, decomposing it into the approximation and the details components. The wrapping extension is simulated without any auxiliary buffer: the delay line of the forward transform points directly to the tail of the source vector, and the inverse transform is split into two calls, the last of which feeds the beginning of the subbands back to the state to reconstruct the last samples.
/*******************************************************************************
* Copyright 2026 Intel Corporation.
*
*
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by
* the express license under which they were provided to you ('License'). Unless the License provides otherwise,
* you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related
* documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than
* those that are expressly stated in the License.
*******************************************************************************/
// A simple example of forward/inverse wavelet Daubechies 2 (db2) transform of a
// one-dimensional signal, implemented with Intel(R) Integrated Performance
// Primitives (Intel(R) IPP) functions:
// ippsWTFwdGetSize
// ippsWTFwdInit_32f
// ippsWTFwdSetDlyLine_32f
// ippsWTFwd_32f
// ippsWTInvGetSize
// ippsWTInvInit_32f
// ippsWTInvSetDlyLine_32f
// ippsWTInv_32f
//
// How this example differs from the other wavelet examples:
// - it uses the one-dimensional signal processing API (ipps), so the signal is
// decomposed into two subbands only: "approximation" and "details";
// - the filter bank is Daubechies 2 (db2), that is four taps per filter;
// - the periodic (wrapping) extension of the signal is simulated in place: no
// auxiliary buffer is allocated and no data is copied. The delay line of the
// forward transform points directly to the tail of the source vector, and the
// inverse transform is performed by two calls - the first one reconstructs all
// samples but the last two, the second one feeds the beginning of the subband
// data back to the state to produce them.
// See c_wtfwd_db3.c for the variant that stages the same extension in explicit
// delay line arrays sized after the filter bank.
#include <stdio.h>
#include "ipp.h"
// Filter bank for Daubechies, order 2
#define FILTER_LENGTH 4
static const int fwdFltLenL = FILTER_LENGTH;
static const int fwdFltLenH = FILTER_LENGTH;
static const float fwdFltL[FILTER_LENGTH] = {/* Pointer to lowpass filter taps */
-1.294095225509215e-001f, 2.241438680418574e-001f, 8.365163037374690e-001f, 4.829629131446903e-001f};
static const float fwdFltH[FILTER_LENGTH] = {/* Pointer to highpass filter taps */
-4.829629131446903e-001f, 8.365163037374690e-001f, -2.241438680418574e-001f, -1.294095225509215e-001f};
static const int invFltLenL = FILTER_LENGTH;
static const int invFltLenH = FILTER_LENGTH;
static const float invFltL[FILTER_LENGTH] = {/* Pointer to lowpass filter taps */
4.829629131446903e-001f, 8.365163037374690e-001f, 2.241438680418574e-001f, -1.294095225509215e-001f};
static const float invFltH[FILTER_LENGTH] = {/* Pointer to highpass filter taps */
-1.294095225509215e-001f, -2.241438680418574e-001f, 8.365163037374690e-001f, -4.829629131446903e-001f};
/* minimal values */
static const int fwdFltOffsL = -1; /* Input delay of lowpass filter */
static const int fwdFltOffsH = -1; /* Input delay of highpass filter */
/* minimal values, that corresponds to perfect reconstruction */
static const int invFltOffsL = 0; /* Input delay of lowpass filter */
static const int invFltOffsH = 0; /* Input delay of highpass filter */
#define SRC_LENGTH 12 /* Length of the source vector */
#define DST_LENGTH (SRC_LENGTH / 2) /* Length of every subband of the wavelet decomposition */
#define EXIT_MAIN \
exitLine: /* Label for Exit */
#define check_sts(st) \
if ((st) != ippStsNoErr) \
goto exitLine; /* Go to Exit if Intel(R) IPP function returned status different from ippStsNoErr */
int main(void)
{
int i;
IppStatus status = ippStsNoErr;
IppsWTFwdState_32f *pStateFwd = NULL; /* Pointer to allocated ippsWTFwd state structure */
IppsWTInvState_32f *pStateInv = NULL; /* Pointer to allocated ippsWTInv state structure */
int pStateSize;
IppDataType srcType = ipp32f; /* Data type of the source vector */
Ipp32f src[SRC_LENGTH] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; /* Source block of data */
Ipp32f dst[SRC_LENGTH]; /* Destination block of reconstructed data */
Ipp32f low[DST_LENGTH]; /* Destination block of "low-frequency" component */
Ipp32f high[DST_LENGTH]; /* Destination block of "high-frequency" component */
printf("original:\n");
for (i = 0; i < SRC_LENGTH; i++)
printf("%.0f; ", src[i]);
printf("\n");
/* Forward transform: create and initialize the state */
check_sts(status = ippsWTFwdGetSize(srcType, fwdFltLenL, fwdFltOffsL, fwdFltLenH, fwdFltOffsH, &pStateSize));
pStateFwd = (IppsWTFwdState_32f *)ippsMalloc_8u(pStateSize);
if (NULL == pStateFwd) {
status = ippStsNoMemErr;
goto exitLine;
}
check_sts(status = ippsWTFwdInit_32f(pStateFwd, fwdFltL, fwdFltLenL, fwdFltOffsL, fwdFltH, fwdFltLenH, fwdFltOffsH));
/* We substitute wrapping extension in "the beginning of stream"
Here should be the same pointers for this offsets, but in the general case it may be different */
check_sts(status = ippsWTFwdSetDlyLine_32f(pStateFwd, &src[SRC_LENGTH - 2], &src[SRC_LENGTH - 2]));
/* Forward transform */
check_sts(status = ippsWTFwd_32f(src, low, high, DST_LENGTH, pStateFwd));
/* print decomposition result */
printf("approx:\n");
for (i = 0; i < DST_LENGTH; i++)
printf("%.4f; ", low[i]);
printf("\n");
printf("details:\n");
for (i = 0; i < DST_LENGTH; i++)
printf("%.4f; ", high[i]);
printf("\n");
/* Inverse transform: create and initialize the state */
check_sts(status = ippsWTInvGetSize(srcType, invFltLenL, invFltOffsL, invFltLenH, invFltOffsH, &pStateSize));
pStateInv = (IppsWTInvState_32f *)ippsMalloc_8u(pStateSize);
if (NULL == pStateInv) {
status = ippStsNoMemErr;
goto exitLine;
}
check_sts(status = ippsWTInvInit_32f(pStateInv, invFltL, invFltLenL, invFltOffsL, invFltH, invFltLenH, invFltOffsH));
/* For this particular case (non-shifted reconstruction)
here is first data itself,
that we need to place to delay line
[(invFltLenL + invFltOffsL - 1) / 2] elements for l. filtering
[(invFltLenH + invFltOffsH - 1) / 2] elements for h. filtering
*/
check_sts(status = ippsWTInvSetDlyLine_32f(pStateInv, low, high));
/* Inverse transform */
check_sts(status = ippsWTInv_32f(&low[1], &high[1], DST_LENGTH - 1, dst, pStateInv));
/* Here are the substitution of the wrapping extension
at the "end of stream" and calculation of last samples of reconstruction
We do not use additional buffer and do not copy any data externally,
just substitute beginning of input data itself to simulate wrapping
*/
check_sts(status = ippsWTInv_32f(low, high, 1, &dst[SRC_LENGTH - 2], pStateInv));
/* print reconstruction result */
printf("reconstruction:\n");
for (i = 0; i < SRC_LENGTH; i++)
printf("%.0f; ", dst[i]);
printf("\n");
EXIT_MAIN
ippsFree(pStateFwd);
ippsFree(pStateInv);
printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
return (int)status;
}
After compiling and running it gives the following console output:
original:
1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12;
approx:
15.3161; 2.3108; 5.1392; 7.9676; 10.7961; 13.6245;
details:
-4.2426; 0.0000; 0.0000; 0.0000; 0.0000; -0.0000;
reconstruction:
1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12;
Exit status 0 (ippStsNoErr: No errors)
One-Dimensional Transform, Daubechies 3 Filter Bank
This example performs the same transform of the same vector with the Daubechies filter bank of the order 3. A longer filter requires a longer delay line, so the wrapping extension is staged in explicit delay line arrays, whose sizes are derived from the length and the offset of the filters. It shows how the code of the previous example scales to filter banks of a higher order.
/*******************************************************************************
* Copyright 2026 Intel Corporation.
*
*
* This software and the related documents are Intel copyrighted materials, and your use of them is governed by
* the express license under which they were provided to you ('License'). Unless the License provides otherwise,
* you may not use, modify, copy, publish, distribute, disclose or transmit this software or the related
* documents without Intel's prior written permission.
* This software and the related documents are provided as is, with no express or implied warranties, other than
* those that are expressly stated in the License.
*******************************************************************************/
// A simple example of forward/inverse wavelet Daubechies 3 (db3) transform of a
// one-dimensional signal, implemented with Intel(R) Integrated Performance
// Primitives (Intel(R) IPP) functions:
// ippsWTFwdGetSize
// ippsWTFwdInit_32f
// ippsWTFwdSetDlyLine_32f
// ippsWTFwd_32f
// ippsWTInvGetSize
// ippsWTInvInit_32f
// ippsWTInvSetDlyLine_32f
// ippsWTInv_32f
//
// How this example differs from the other wavelet examples:
// - it uses the one-dimensional signal processing API (ipps), like c_wtfwd_db2.c,
// but with the Daubechies 3 (db3) filter bank, that is six taps per filter.
// A longer filter needs a longer delay line, which is the only part of the
// code that depends on the order of the wavelet;
// - the periodic (wrapping) extension of the signal is staged in explicit delay
// line arrays whose sizes are derived from the filter length and the filter
// offset, instead of being substituted in place by a pointer to the source
// data. This shows how the delay line grows with the order of the wavelet.
// See c_wtfwd_db2.c for the db2 variant that avoids these buffers.
#include <stdio.h>
#include "ipp.h"
// Filter bank for Daubechies 3 (db3)
#define FILTER_LENGTH 6
static const int fwdFltLenL = FILTER_LENGTH;
static const int fwdFltLenH = FILTER_LENGTH;
static const float fwdFltL[FILTER_LENGTH] = {/* Pointer to lowpass filter taps */
0.035226291882100656f, -0.08544127388224149f, -0.13501102001039084f,
0.4598775021193313f, 0.8068915093133388f, 0.3326705529509569f};
static const float fwdFltH[FILTER_LENGTH] = {/* Pointer to highpass filter taps */
-0.3326705529509569f, 0.8068915093133388f, -0.4598775021193313f,
-0.13501102001039084f, 0.08544127388224149f, 0.035226291882100656f};
static const int invFltLenL = FILTER_LENGTH;
static const int invFltLenH = FILTER_LENGTH;
static const float invFltL[FILTER_LENGTH] = {/* Pointer to lowpass filter taps */
0.3326705529509569f, 0.8068915093133388f, 0.4598775021193313f,
-0.13501102001039084f, -0.08544127388224149f, 0.035226291882100656f};
static const float invFltH[FILTER_LENGTH] = {/* Pointer to highpass filter taps */
0.035226291882100656f, 0.08544127388224149f, -0.13501102001039084f,
-0.4598775021193313f, 0.8068915093133388f, -0.3326705529509569f};
/* minimal values */
static const int fwdFltOffsL = -1; /* Input delay of lowpass filter */
static const int fwdFltOffsH = -1; /* Input delay of highpass filter */
/* minimal values, that corresponds to perfect reconstruction */
static const int invFltOffsL = 0; /* Input delay of lowpass filter */
static const int invFltOffsH = 0; /* Input delay of highpass filter */
#define SRC_LENGTH 12 /* Length of the source vector */
#define DST_LENGTH (SRC_LENGTH / 2) /* Length of every subband of the wavelet decomposition */
#define DLY_FWD_LENGTH (FILTER_LENGTH + (-1) - 1) /* fwdFltLen + fwdFltOffs - 1 samples of the wrapping extension */
#define DLY_INV_LENGTH (DLY_FWD_LENGTH / 2) /* (invFltLen + invFltOffs - 1) / 2 samples of every subband */
#define EXIT_MAIN \
exitLine: /* Label for Exit */
#define check_sts(st) \
if ((st) != ippStsNoErr) \
goto exitLine; /* Go to Exit if Intel(R) IPP function returned status different from ippStsNoErr */
int main(void)
{
int i;
IppStatus status = ippStsNoErr;
IppsWTFwdState_32f *pStateFwd = NULL; /* Pointer to allocated ippsWTFwd state structure */
IppsWTInvState_32f *pStateInv = NULL; /* Pointer to allocated ippsWTInv state structure */
int pStateSize;
IppDataType srcType = ipp32f; /* Data type of the source vector */
Ipp32f src[SRC_LENGTH] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; /* Source block of data */
Ipp32f dst[SRC_LENGTH]; /* Destination block of reconstructed data */
Ipp32f low[DST_LENGTH]; /* Destination block of "low-frequency" component */
Ipp32f high[DST_LENGTH]; /* Destination block of "high-frequency" component */
Ipp32f dLineFwdL[DLY_FWD_LENGTH]; /* Delay lines of the forward transform: */
Ipp32f dLineFwdH[DLY_FWD_LENGTH]; /* the tail of the source vector */
Ipp32f dLineInvL[DLY_INV_LENGTH]; /* Delay lines of the inverse transform: */
Ipp32f dLineInvH[DLY_INV_LENGTH]; /* the tail of the subbands */
printf("original:\n");
for (i = 0; i < SRC_LENGTH; i++)
printf("%.0f; ", src[i]);
printf("\n");
/* Forward transform: create and initialize the state */
check_sts(status = ippsWTFwdGetSize(srcType, fwdFltLenL, fwdFltOffsL, fwdFltLenH, fwdFltOffsH, &pStateSize));
pStateFwd = (IppsWTFwdState_32f *)ippsMalloc_8u(pStateSize);
if (NULL == pStateFwd) {
status = ippStsNoMemErr;
goto exitLine;
}
check_sts(status = ippsWTFwdInit_32f(pStateFwd, fwdFltL, fwdFltLenL, fwdFltOffsL, fwdFltH, fwdFltLenH, fwdFltOffsH));
/* We substitute wrapping extension in "the beginning of stream":
the last [fwdFltLen + fwdFltOffs - 1] samples of the source vector.
Here should be the same data for this offsets, but in the general case it may be different */
for (i = 0; i < DLY_FWD_LENGTH; i++) {
dLineFwdL[i] = src[SRC_LENGTH - DLY_FWD_LENGTH + i];
dLineFwdH[i] = src[SRC_LENGTH - DLY_FWD_LENGTH + i];
}
check_sts(status = ippsWTFwdSetDlyLine_32f(pStateFwd, dLineFwdL, dLineFwdH));
/* Forward transform */
check_sts(status = ippsWTFwd_32f(src, low, high, DST_LENGTH, pStateFwd));
/* print decomposition result */
printf("approx:\n");
for (i = 0; i < DST_LENGTH; i++)
printf("%.4f; ", low[i]);
printf("\ndetails:\n");
for (i = 0; i < DST_LENGTH; i++)
printf("%.4f; ", high[i]);
printf("\n");
/* Inverse transform: create and initialize the state */
check_sts(status = ippsWTInvGetSize(srcType, invFltLenL, invFltOffsL, invFltLenH, invFltOffsH, &pStateSize));
pStateInv = (IppsWTInvState_32f *)ippsMalloc_8u(pStateSize);
if (NULL == pStateInv) {
status = ippStsNoMemErr;
goto exitLine;
}
check_sts(status = ippsWTInvInit_32f(pStateInv, invFltL, invFltLenL, invFltOffsL, invFltH, invFltLenH, invFltOffsH));
/* For this particular case (non-shifted reconstruction)
here is the beginning of the subbands, that we need to place to delay line
[(invFltLenL + invFltOffsL - 1) / 2] elements for l. filtering
[(invFltLenH + invFltOffsH - 1) / 2] elements for h. filtering
*/
for (i = 0; i < DLY_INV_LENGTH; i++) {
dLineInvL[i] = low[i];
dLineInvH[i] = high[i];
}
check_sts(status = ippsWTInvSetDlyLine_32f(pStateInv, dLineInvL, dLineInvH));
/* Inverse transform */
check_sts(status = ippsWTInv_32f(&low[DLY_INV_LENGTH], &high[DLY_INV_LENGTH], DST_LENGTH - DLY_INV_LENGTH, dst, pStateInv));
/* Substitution of the wrapping extension at the "end of stream":
the beginning of the subbands is fed back to the state to calculate
the last 2 * [(invFltLen + invFltOffs - 1) / 2] samples of the reconstruction */
check_sts(status = ippsWTInv_32f(low, high, DLY_INV_LENGTH, &dst[SRC_LENGTH - 2 * DLY_INV_LENGTH], pStateInv));
/* print reconstruction result */
printf("reconstruction:\n");
for (i = 0; i < SRC_LENGTH; i++)
printf("%.0f; ", dst[i]);
printf("\n");
EXIT_MAIN
ippsFree(pStateFwd);
ippsFree(pStateInv);
printf("Exit status %d (%s)\n", (int)status, ippGetStatusString(status));
return (int)status;
}
After compiling and running it gives the following console output:
original:
1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12;
approx:
14.4865; 13.4165; 2.5702; 5.3986; 8.2270; 11.0555;
details:
-5.6907; 1.4480; 0.0000; 0.0000; 0.0000; 0.0000;
reconstruction:
1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12;
Exit status 0 (ippStsNoErr: No errors)
Every program prints on console the original data, the approximation and details components computed by the forward transform, the perfect reconstruction of the original data obtained after the inverse transform, and the status of the last Intel IPP function that it called.
For the two-dimensional counterparts of these examples, which process an image and provide the periodical extension with image borders instead of a delay line, see Wavelet Transforms Example in the image processing volume.