Skip to content
heliaDSP
API reference
HELIA HUB

helia_dwt.h

Periodic discrete wavelet transform (DWT), f32.

Multi-level forward (analysis) and inverse (synthesis) DWT of one frame of N real samples with periodic boundary extension, matching PyWavelets wavedec / waverec with mode="periodization" for the wavelets listed in helia_dwt_wavelet_t.

Each direction has three entry points with one contract:

Entry point Implementation
helia_dwt_forward_f32() MVE when the build targets floating-point MVE (__ARM_FEATURE_MVE & 2) and ARM_MATH_AUTOVECTORIZE is not defined, optimized scalar otherwise
helia_dwt_forward_scalar_f32() optimized scalar, on every target
helia_dwt_reference_forward_f32() readable scalar reference (the test oracle)

and likewise helia_dwt_inverse_f32(), helia_dwt_inverse_scalar_f32() and helia_dwt_reference_inverse_f32(). The implementation behind helia_dwt_forward_f32() is fixed by the preprocessor when the library is compiled; no entry point chooses among implementations at run time, so an application that calls one entry point links one implementation.

Every entry point evaluates each output as the reference does, without fused multiply-add. A forward output is a sum, starting at +0.0f, of the products of one tap and one sample, added in tap order. An inverse output starts at +0.0f; for each input i in increasing order and each tap t in increasing order it accumulates lo[t] * a[i] + hi[t] * d[i], the two products added together first. Under that rule the optimized and MVE implementations are required to return results identical bit for bit to the reference on the library’s test corpus, which is a test gate, not a proof for all finite inputs. The library compiles these sources without fast-math and without floating-point contraction whatever flags the application uses.

Signed zero: in the qualified domain every zero output is +0.0f, from every entry point, and an input of -0.0f gives the same result as an input of +0.0f. Every sum starts at +0.0f, and under round to nearest adding a zero leaves a sum’s value, and an exact cancellation gives +0.0f. This follows from the evaluation rule; the library’s tests check it with each zero sample of three input patterns as +0.0f and as -0.0f.

Reconstruction is not exact: an inverse following a forward transform returns the input up to f32 rounding (see the library’s test report for measured errors).

The entry points do not check for NaN or infinity. Such inputs are outside the qualified domain, and no result is specified for them.

Machine-readable model

struct

Configuration of a DWT of fixed frame size and depth.

helia/include/helia/helia_dwt.h:165

struct helia_dwt_instance_f32

Configuration of a DWT of fixed frame size and depth.

Created by helia_dwt_init_f32() and read-only afterwards. The layout is the same in every build configuration. Process functions do not check the fields; an instance not produced by helia_dwt_init_f32() is undefined behaviour.

enum

Wavelet and boundary convention.

helia/include/helia/helia_dwt.h:151

enum helia_dwt_wavelet_t

Wavelet and boundary convention.

A deployed bitstream identifies one transform, including its boundary extension; the values of this enumeration are stable.

function

Initialize a DWT configuration.

helia/include/helia/helia_dwt.h:190

arm_status helia_dwt_init_f32(
helia_dwt_instance_f32 *S,
uint32_t frame_size,
uint32_t levels,
helia_dwt_wavelet_t wavelet
)

Initialize a DWT configuration.

Supported configurations: 1 <= levels <= 30, frame_size a nonzero multiple of 2^levels and at most UINT32_MAX / 2, and wavelet one of helia_dwt_wavelet_t. The coarsest stage therefore filters 2 or more samples; stages shorter than the filter wrap periodically as PyWavelets does. No implicit padding is applied.

Stack: 8 bytes (ATfE 22.1.0), 4 bytes (GCC 14.2.1).

Parameters of helia_dwt_init_f32
NameTypeDirectionDescription
Shelia_dwt_instance_f32 *outInstance to initialize.
frame_sizeuint32_tinN, samples per frame.
levelsuint32_tinL, decomposition levels.
wavelethelia_dwt_wavelet_tinWavelet and boundary convention.
Returns of helia_dwt_init_f32
Description
ARM_MATH_SUCCESS, or ARM_MATH_ARGUMENT_ERROR (and `S` unmodified) for a NULL `S` or an unsupported configuration.
function

Number of f32 elements in the packed coefficients of S.

helia/include/helia/helia_dwt.h:201

uint32_t helia_dwt_packed_size_f32(const helia_dwt_instance_f32 *S)

Number of f32 elements in the packed coefficients of S.

Stack: 0 bytes (ATfE 22.1.0), 0 bytes (GCC 14.2.1).

Parameters of helia_dwt_packed_size_f32
NameTypeDescription
Sconst helia_dwt_instance_f32 *
Returns of helia_dwt_packed_size_f32
Description
N, or 0 for a NULL `S`.
function

Number of f32 workspace elements every forward and inverse entry point requires for S.

helia/include/helia/helia_dwt.h:214

uint32_t helia_dwt_workspace_size_f32(const helia_dwt_instance_f32 *S)

Number of f32 workspace elements every forward and inverse entry point requires for S.

The value is max(2N, N + 10) for bior4.4 and max(2N, N + 30) for Coif5, which is 2N for N >= 10 (bior4.4) and N >= 30 (Coif5).

Stack: 8 bytes (ATfE 22.1.0), 8 bytes (GCC 14.2.1).

Parameters of helia_dwt_workspace_size_f32
NameTypeDescription
Sconst helia_dwt_instance_f32 *
Returns of helia_dwt_workspace_size_f32
Description
The workspace size in elements, or 0 for a NULL `S`.
function

Forward DWT: MVE implementation on targets with floating-point MVE, unless the library is built with ARMMATHAUTOVECTORIZE (CMake AUTOVECTORIZE=ON), optimized s…

helia/include/helia/helia_dwt.h:234

arm_status helia_dwt_forward_f32(
const helia_dwt_instance_f32 *S,
const float32_t *pSrc,
float32_t *pPackedCoeffs,
float32_t *pWorkspace,
uint32_t workspaceSize
)

Forward DWT: MVE implementation on targets with floating-point MVE, unless the library is built with ARM_MATH_AUTOVECTORIZE (CMake AUTOVECTORIZE=ON), optimized scalar implementation otherwise.

Stack: 124 to 128 bytes (ATfE 22.1.0), 136 bytes (GCC 14.2.1).

Parameters of helia_dwt_forward_f32
NameTypeDirectionDescription
Sconst helia_dwt_instance_f32 *inInstance from `helia_dwt_init_f32()`.
pSrcconst float32_t *inN input samples; not modified.
pPackedCoeffsfloat32_t *outN coefficients, `[A_L | D_L | ... | D_1]`.
pWorkspacefloat32_t *in, outScratch of `workspaceSize` elements; its contents on entry are ignored and on return are unspecified.
workspaceSizeuint32_tinCapacity of `pWorkspace` in f32 elements (not bytes); at least helia_dwt_workspace_size_f32(S).
Returns of helia_dwt_forward_f32
Description
ARM_MATH_SUCCESS, or ARM_MATH_ARGUMENT_ERROR without writing any buffer when a pointer is NULL or `workspaceSize` is too small.
function

Forward DWT, optimized scalar implementation on every target.

helia/include/helia/helia_dwt.h:247

arm_status helia_dwt_forward_scalar_f32(
const helia_dwt_instance_f32 *S,
const float32_t *pSrc,
float32_t *pPackedCoeffs,
float32_t *pWorkspace,
uint32_t workspaceSize
)

Forward DWT, optimized scalar implementation on every target.

Same contract as helia_dwt_forward_f32().

Stack: 136 bytes (ATfE 22.1.0), 108 bytes (GCC 14.2.1).

Parameters of helia_dwt_forward_scalar_f32
NameTypeDescription
Sconst helia_dwt_instance_f32 *
pSrcconst float32_t *
pPackedCoeffsfloat32_t *
pWorkspacefloat32_t *
workspaceSizeuint32_t
function

Forward DWT, reference implementation.

helia/include/helia/helia_dwt.h:261

arm_status helia_dwt_reference_forward_f32(
const helia_dwt_instance_f32 *S,
const float32_t *pSrc,
float32_t *pPackedCoeffs,
float32_t *pWorkspace,
uint32_t workspaceSize
)

Forward DWT, reference implementation.

Same contract as helia_dwt_forward_f32(). Written for review rather than speed; the other forward entry points are tested against it.

Stack: 136 bytes (ATfE 22.1.0), 112 bytes (GCC 14.2.1).

Parameters of helia_dwt_reference_forward_f32
NameTypeDescription
Sconst helia_dwt_instance_f32 *
pSrcconst float32_t *
pPackedCoeffsfloat32_t *
pWorkspacefloat32_t *
workspaceSizeuint32_t
function

Inverse DWT: MVE implementation on targets with floating-point MVE, unless the library is built with ARMMATHAUTOVECTORIZE (CMake AUTOVECTORIZE=ON), optimized s…

helia/include/helia/helia_dwt.h:286

arm_status helia_dwt_inverse_f32(
const helia_dwt_instance_f32 *S,
const float32_t *pPackedCoeffs,
float32_t *pDst,
float32_t *pWorkspace,
uint32_t workspaceSize
)

Inverse DWT: MVE implementation on targets with floating-point MVE, unless the library is built with ARM_MATH_AUTOVECTORIZE (CMake AUTOVECTORIZE=ON), optimized scalar implementation otherwise.

Stack: 124 bytes (ATfE 22.1.0), 140 bytes (GCC 14.2.1).

Parameters of helia_dwt_inverse_f32
NameTypeDirectionDescription
Sconst helia_dwt_instance_f32 *inInstance from `helia_dwt_init_f32()`.
pPackedCoeffsconst float32_t *inN coefficients, `[A_L | D_L | ... | D_1]`; not modified.
pDstfloat32_t *outN reconstructed samples.
pWorkspacefloat32_t *in, outScratch of `workspaceSize` elements; its contents on entry are ignored and on return are unspecified.
workspaceSizeuint32_tinCapacity of `pWorkspace` in f32 elements (not bytes); at least helia_dwt_workspace_size_f32(S).
Returns of helia_dwt_inverse_f32
Description
ARM_MATH_SUCCESS, or ARM_MATH_ARGUMENT_ERROR without writing any buffer when a pointer is NULL or `workspaceSize` is too small.
function

Inverse DWT, optimized scalar implementation on every target.

helia/include/helia/helia_dwt.h:299

arm_status helia_dwt_inverse_scalar_f32(
const helia_dwt_instance_f32 *S,
const float32_t *pPackedCoeffs,
float32_t *pDst,
float32_t *pWorkspace,
uint32_t workspaceSize
)

Inverse DWT, optimized scalar implementation on every target.

Same contract as helia_dwt_inverse_f32().

Stack: 124 bytes (ATfE 22.1.0), 116 bytes (GCC 14.2.1).

Parameters of helia_dwt_inverse_scalar_f32
NameTypeDescription
Sconst helia_dwt_instance_f32 *
pPackedCoeffsconst float32_t *
pDstfloat32_t *
pWorkspacefloat32_t *
workspaceSizeuint32_t
function

Inverse DWT, reference implementation.

helia/include/helia/helia_dwt.h:313

arm_status helia_dwt_reference_inverse_f32(
const helia_dwt_instance_f32 *S,
const float32_t *pPackedCoeffs,
float32_t *pDst,
float32_t *pWorkspace,
uint32_t workspaceSize
)

Inverse DWT, reference implementation.

Same contract as helia_dwt_inverse_f32(). Written for review rather than speed; the other inverse entry points are tested against it.

Stack: 124 bytes (ATfE 22.1.0), 108 bytes (GCC 14.2.1).

Parameters of helia_dwt_reference_inverse_f32
NameTypeDescription
Sconst helia_dwt_instance_f32 *
pPackedCoeffsconst float32_t *
pDstfloat32_t *
pWorkspacefloat32_t *
workspaceSizeuint32_t