1. So does IIRInit need the state to be already allocated?
2. If IIRInit does allocate State is it safe to call IIRFree on a State alloced by IIRInit?
In IIRFree's documentation in the Reference Manual it only makes mention of freeing a state allocated by IIRInitAlloc(or the _BiQuad version).
3. Is my assumption correct that to get the best performance I need to use IIRInit instead of IIRInitAlloc?
Thank you for any answers or information.
Why don't you look at IPP documentation?
IPP manual, volume 1. Chapter 6 IIR Filter Functions, page 6-94
To initialize and use an IIR filter, follow this general scheme:
- Call ippsIIRInitAlloc to allocate memory and initialize the filter as an arbitrary
order IIR filter, or call ippsIIRInitAlloc_BiQuad to allocate memory and initialize
the filter as a cascade of biquads.
Or alternatively call either ippsIIRInit to initialize the filter as an arbitrary order IIR
filter in the external buffer, or ippsIIRInit_BiQuad to initialize the filter as a cascade
of biquads in the external buffer. Size of the buffer can be computed by calling the
functions ippsIIRGetStateSize or ippsIIRGetStateSize_BiQuad, respectively.
- Call ippsIIROne repeatedly to filter a single sample through an IIR filter or call
ippsIIR to filter consecutive samples at once.
- Call ippsIIRGetDlyLine and ippsIIRSetDlyLine to get and set the delay line
values in the IIR state structure.
- Call ippsIIRSetTaps to set new tap values in the previously initialized filter state
- After all filtering is complete, call ippsIIRFree to release dynamic memory associated
with the filter state structure created by ippsIIRInitAlloc or
Alternatively, you may use the direct version of the functions. These functions perform
filtering without initializing the filter state structure. All required parameters are directly set
in the function.
I can infer an answer to my 1st question that when using IIRInit and having to use ippsIIRGetStateSize the State will be in the memory allocated with the result from GetStateSize. I can also assume that for question 2 that it is not safe to call IIRFree on a State created with IIRInit. The Reference manual could be much more explicit in the usage of IIRInit and IIRGetStateSize instead of requiring the reader to make guesses at their usage. I would prefer to not make guesses at code I develop and that is what drove me to post my questions.
As for my 3rd question the Manual makes no attempt at suggesting a difference in IIRInit and IIRInitAlloc and why one would use one over the other.
Thanks for trying to help Vladimir but I was well aware of the material you posted.
In IPP for some function family we provide two approaches, the first, function allocate memory internally, which not always might be what customer wants and second when you can allocate memory by your own way (might be important for example in kernel mode drivers). For the second case, we provide function which tell you how many memory you need to allocate and also function which initialise that memory block. Of course it is your responisbility to free that memory by appropriate function (CRT free() if you use malloc() or delete if you use new or whatever)