struct __attribute__ ((aligned (32)))
{ int *samplebuf[chan];
int *fcs[chan]; // Filter Coefficient Start
int len[chan];
int offset[chan];
int dec[chan];
int decount[chan];
int item[chan]; // Skip coefficient Items
}f;
int get_sa(int chan)
{
static long long y;
int l1;
int *sample;
int *cof;
int len;
int item,item4;
int *samplebuf;
samplebuf = f.samplebuf[chan];
if ( f.dec[chan] == 0 )
return samplebuf[0];
len = f.len[chan];
item = f.item[chan];
item4 = item << 2;
cof = f.fcs[chan];
sample = samplebuf + f.Offset[chan];
l1 = len - f.Offset[chan];
y = mac(l1,sample,cof,item); //multiply and accumulate filter
cof += (l1 * item);
sample = samplebuf;
l1 = len - l1;
y += mac(l1,sample,cof,item4);
y *= item;
y >>= 32;
return (int)y;
}
mac function shown below,
long long mac(int len, int *sample, int *cof, int item)
{
int i, io;
static long long y;
io = 0;
y = 0;
item /= 4;
for ( i = 0; i < len; i++ )
{
y += (long long)sample[io] * (long long)cof[0];
cof +=item;
io++;
if ( io >= len )
io = 0;
}
return y;
}