Community
cancel
Showing results for 
Search instead for 
Did you mean: 
jenni80
Beginner
63 Views

RS & GF(2) functions usage

Hi i'm trying to use the Reed Solomon Decoder Functions. But unfortunately there is absolutly no example code for all of these functions.

The problem i have is the following:
When i want to use e.g. the function GFInit_8u
The documentation says:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
GFInit_8u
Initializes user-supplied memory as
IppsGFSpec_8u context for future use.

Syntax

IppStatus ippsGFInit_8u(int feBitSize, const Ipp8u* pPolynomial, IppsGFSpec_8u* pGF);

Parameters

feBitSize Size of the field element (in bits).
pPolynomial Pointer to the polynomial generating the finite field.
pGF Pointer to the finite field context to be initialized.

Description

This function is declared in the ippdi.h file. The function initializes the user-supplied
buffer as the context of the finite field GF(2feBitzise). The context is necessary for each
operation over the field.
The buffer for the context must have size that the function GFGetSize_8u returns.
The polynomial is represented as an array of elements having type Ipp8u and length
(feBitSize+1). In Intel IPP, the lower index of an array corresponds to the lower power of
the independent variable. For example, to define the polynomial f(x) = x3 + x + 1, use the
array {1,1,0,1}.
Return Values
ippStsNoErr Indicates no error. Any other value indicates an error or warning.
ippStsNullPtrErr Indicates an error condition if any of the specified pointers is NULL.
ippStsRangeErr Indicates an error condition if the value of the parameter
feBitSize is less than 1 or greater than 8.
ippStsBadArgErr Indicates an error condition if the value of the parameter pointed
by pPolynomial is not irreducible.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

The underlined text says, that i have to alloate memory for the "IppsGFSpec_8u".
But how? Is there any function that allocates memory for that type, or do i have to allocate an
Ipp8u array and cast it to IppsGFSpec_8u ? Anyhow the normal ippsMalloc_8u function don't work for the IppsGFSpec_8u type.
Thanks in advance for help.

Btw. there's an issue about the documentation of the ippsMalloc function.
In the code snipped that shows the usage is an mistake (in my opinion).
The code is:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
void func_malloc(void)
{
Ipp8u* pBuf = ippsMalloc_8u(8*sizeof(Ipp8u));
if(NULL == pBuf)
// not enough memory
ippsFree(pBuf);
}
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Why do i have to multiply the size of the Ipp8u type (in my code it was Ipp64fc) with the number of elements if the function only allocates memory for the Ipp8u type ? I deleted the "*sizeof(Ipp64fc)" part and my code still worked. So i assume that the memory allocator just needs the number of elements to be allocated.
0 Kudos
1 Reply
Vladimir_Dudnik
Employee
63 Views


Hello,

there are two ways to use context (or state) in IPP functions. They are InitAlloc kind of functions, which takes care on structure allocation and initialization in one step and separate GetBufSize, alloc and Init functions. For the last case you determine number of bytes required to keep the particular structure with GetBufSize function, then you allocate this memory either with IPP mem allocation function or any other way and finaly you initialize that memory with Init function.

To be honest, I do not see any issue with piece of code you refer to (8*sizeof(Ipp8u)). You may not need to specify size of element you if you allocate bytes with ippMalloc_8u function, that's correct although there is ni mistake if you do that. But when you allocate for example memory for array of 32-bit integers with ippMalloc_8u function you just have to specify size of element and the best way to do that is - sizeof(elelment type). So the piece of code in IPP is just good rule in programming for general case. I basically meanit is a good habbit if you write code in that way because this is kind of error free style of code writing.

Regards,
Vladimir
Reply