version 1.7, 2014/08/13 08:42:46 |
version 1.8, 2014/10/12 21:52:27 |
|
|
{ |
{ |
unsigned int f; |
unsigned int f; |
adata_t *idata; |
adata_t *idata; |
int s; |
unsigned int s; |
unsigned int oshift; |
unsigned int oshift; |
int osigbit; |
unsigned int obias; |
unsigned int obps; |
unsigned int obps; |
unsigned int i; |
unsigned int i; |
unsigned char *odata; |
unsigned char *odata; |
|
|
idata = (adata_t *)in; |
idata = (adata_t *)in; |
odata = out; |
odata = out; |
oshift = p->shift; |
oshift = p->shift; |
osigbit = p->sigbit; |
obias = p->bias; |
obps = p->bps; |
obps = p->bps; |
obnext = p->bnext; |
obnext = p->bnext; |
osnext = p->snext; |
osnext = p->snext; |
|
|
*/ |
*/ |
odata += p->bfirst; |
odata += p->bfirst; |
for (f = todo * p->nch; f > 0; f--) { |
for (f = todo * p->nch; f > 0; f--) { |
s = *idata++; |
/* convert adata to u32 */ |
|
s = (int)*idata++ + ADATA_UNIT; |
s <<= 32 - ADATA_BITS; |
s <<= 32 - ADATA_BITS; |
|
/* convert u32 to uN */ |
s >>= oshift; |
s >>= oshift; |
s ^= osigbit; |
/* convert uN to sN */ |
|
s -= obias; |
|
/* packetize sN */ |
for (i = obps; i > 0; i--) { |
for (i = obps; i > 0; i--) { |
*odata = (unsigned char)s; |
*odata = (unsigned char)s; |
s >>= 8; |
s >>= 8; |
|
|
enc_sil_do(struct conv *p, unsigned char *out, int todo) |
enc_sil_do(struct conv *p, unsigned char *out, int todo) |
{ |
{ |
unsigned int f; |
unsigned int f; |
int s; |
unsigned int s; |
int osigbit; |
unsigned int oshift; |
|
int obias; |
unsigned int obps; |
unsigned int obps; |
unsigned int i; |
unsigned int i; |
unsigned char *odata; |
unsigned char *odata; |
|
|
* order local variables more "cache-friendly". |
* order local variables more "cache-friendly". |
*/ |
*/ |
odata = out; |
odata = out; |
osigbit = p->sigbit; |
oshift = p->shift; |
|
obias = p->bias; |
obps = p->bps; |
obps = p->bps; |
obnext = p->bnext; |
obnext = p->bnext; |
osnext = p->snext; |
osnext = p->snext; |
|
|
*/ |
*/ |
odata += p->bfirst; |
odata += p->bfirst; |
for (f = todo * p->nch; f > 0; f--) { |
for (f = todo * p->nch; f > 0; f--) { |
s = osigbit; |
s = ((1U << 31) >> oshift) - obias; |
for (i = obps; i > 0; i--) { |
for (i = obps; i > 0; i--) { |
*odata = (unsigned char)s; |
*odata = (unsigned char)s; |
s >>= 8; |
s >>= 8; |
|
|
{ |
{ |
p->nch = nch; |
p->nch = nch; |
p->bps = par->bps; |
p->bps = par->bps; |
p->sigbit = par->sig ? 0 : 1 << (par->bits - 1); |
|
if (par->msb) { |
if (par->msb) { |
p->shift = 32 - par->bps * 8; |
p->shift = 32 - par->bps * 8; |
} else { |
} else { |
p->shift = 32 - par->bits; |
p->shift = 32 - par->bits; |
} |
} |
|
if (par->sig) { |
|
p->bias = (1U << 31) >> p->shift; |
|
} else { |
|
p->bias = 0; |
|
} |
if (!par->le) { |
if (!par->le) { |
p->bfirst = par->bps - 1; |
p->bfirst = par->bps - 1; |
p->bnext = -1; |
p->bnext = -1; |
|
|
unsigned int f; |
unsigned int f; |
unsigned int ibps; |
unsigned int ibps; |
unsigned int i; |
unsigned int i; |
int s = 0xdeadbeef; |
unsigned int s = 0xdeadbeef; |
unsigned char *idata; |
unsigned char *idata; |
int ibnext; |
int ibnext; |
int isnext; |
int isnext; |
int isigbit; |
unsigned int ibias; |
unsigned int ishift; |
unsigned int ishift; |
adata_t *odata; |
adata_t *odata; |
|
|
|
|
odata = (adata_t *)out; |
odata = (adata_t *)out; |
ibps = p->bps; |
ibps = p->bps; |
ibnext = p->bnext; |
ibnext = p->bnext; |
isigbit = p->sigbit; |
ibias = p->bias; |
ishift = p->shift; |
ishift = p->shift; |
isnext = p->snext; |
isnext = p->snext; |
|
|
|
|
idata += ibnext; |
idata += ibnext; |
} |
} |
idata += isnext; |
idata += isnext; |
s ^= isigbit; |
s += ibias; |
s <<= ishift; |
s <<= ishift; |
s >>= 32 - ADATA_BITS; |
s >>= 32 - ADATA_BITS; |
*odata++ = s; |
*odata++ = s - ADATA_UNIT; |
} |
} |
} |
} |
|
|
|
|
dec_init(struct conv *p, struct aparams *par, int nch) |
dec_init(struct conv *p, struct aparams *par, int nch) |
{ |
{ |
p->bps = par->bps; |
p->bps = par->bps; |
p->sigbit = par->sig ? 0 : 1 << (par->bits - 1); |
|
p->nch = nch; |
p->nch = nch; |
if (par->msb) { |
if (par->msb) { |
p->shift = 32 - par->bps * 8; |
p->shift = 32 - par->bps * 8; |
} else { |
} else { |
p->shift = 32 - par->bits; |
p->shift = 32 - par->bits; |
} |
} |
|
if (par->sig) { |
|
p->bias = (1U << 31) >> p->shift; |
|
} else { |
|
p->bias = 0; |
|
} |
if (par->le) { |
if (par->le) { |
p->bfirst = par->bps - 1; |
p->bfirst = par->bps - 1; |
p->bnext = -1; |
p->bnext = -1; |