|
|
static int16_t | add (int16_t a, int16_t b) |
| Return (a+b) saturated (16-bit). More...
|
|
static void | add_I (int16_t &a, int16_t b) |
| Perform (a+=b) saturated (16-bit). More...
|
|
static int32_t | add (int32_t a, int32_t b) |
| Return (a+b) saturated (32-bit). More...
|
|
static void | add_I (int32_t &a, int32_t b) |
| Perform (a+=b) saturated (32-bit). More...
|
|
static void | addMul_I (int32_t &a, int16_t b, int16_t c) |
| Perform (a+=b*c) saturated (32-bit accumulator, 16-bit operands). More...
|
|
static int16_t | abs (int16_t a) |
| Perform absolute value calculation with saturation. More...
|
|
static int16_t | minimum (int16_t a, int16_t b) |
| Perform minimum value calculation. More...
|
|
static int16_t | maximum (int16_t a, int16_t b) |
| Perform maximum value calculation. More...
|
|
static int32_t | abs (int32_t a) |
| Perform absolute value calculation with saturation. More...
|
|
static int32_t | minimum (int32_t a, int32_t b) |
| Perform minimum value calculation. More...
|
|
static int32_t | maximum (int32_t a, int32_t b) |
| Perform maximum value calculation. More...
|
|
static uint32_t | sqrt (uint32_t val) |
| Integer square root. More...
|
|
|
static int | compareSerials (uint32_t val1, uint32_t val2) |
| Is val1 bigger, equal or lesser then val2 . More...
|
|
static int | compareSerials (uint16_t val1, uint16_t val2) |
| Is val1 bigger, equal or lesser then val2 . More...
|
|
|
static void | shl16_I (int32_t &a, unsigned scale) |
|
static int32_t | shl16 (int32_t a, unsigned scale) |
|
static void | shl32_I (int32_t &a, unsigned scale) |
|
static int32_t | shl32 (int32_t a, unsigned scale) |
|
|
static MP_DSP_VECTOR_API OsStatus | add_I (const int16_t *pSrc1, int32_t *pSrc2Dst, int dataLength) |
| Add source vector to accumulator. More...
|
|
static MP_DSP_VECTOR_API OsStatus | add_IGain (const int16_t *pSrc1, int32_t *pSrc2Dst, int dataLength, unsigned src1ScaleFactor) |
| Gain source vector by 2^src1ScaleFactor factor and add it to accumulator. More...
|
|
static MP_DSP_VECTOR_API OsStatus | add_IAtt (const int16_t *pSrc1, int32_t *pSrc2Dst, int dataLength, unsigned src1ScaleFactor) |
| Attenuate source vector by 2^src1ScaleFactor factor and add it to accumulator. More...
|
|
static MP_DSP_VECTOR_API OsStatus | add (const int32_t *pSrc1, const int32_t *pSrc2, int32_t *pDst, int dataLength) |
| Add two vectors. More...
|
|
static MP_DSP_VECTOR_API OsStatus | addMul_I (const int16_t *pSrc1, int16_t val, int32_t *pSrc2Dst, int dataLength) |
| Multiply source vector by given val and add it to accumulator vector. More...
|
|
static MP_DSP_VECTOR_API OsStatus | addMulLinear_I (const int16_t *pSrc1, int16_t valStart, int16_t valEnd, int32_t *pSrc2Dst, int dataLength) |
| Multiply source vector by values linearly changing from valStart to valEnd and add it to accumulator vector. More...
|
|
static MP_DSP_VECTOR_API OsStatus | mul (const int16_t *pSrc, const int16_t val, int32_t *pDst, int dataLength) |
| Multiply vector by constant. More...
|
|
static MP_DSP_VECTOR_API OsStatus | mul_I (int16_t *pSrcDst, const int16_t val, int dataLength) |
| Multiply vector by constant with saturation. More...
|
|
static MP_DSP_VECTOR_API OsStatus | mulLinear (const int16_t *pSrc, int16_t valStart, int16_t valEnd, int32_t *pDst, int dataLength) |
| Multiply source vector by values linearly changing from valStart to valEnd and add it to accumulator vector. More...
|
|
static int | maxAbs (const int16_t *pSrc, int dataLength) |
| Calculate absolute maximum value of array. More...
|
|
static int16_t | maximum (const int16_t *pSrc, int dataLength) |
| Calculate maximum value of array. More...
|
|
static int32_t | maximum (const int32_t *pSrc, int dataLength) |
| Calculate maximum value of array. More...
|
|
static int16_t | minimum (const int16_t *pSrc, int dataLength) |
| Calculate maximum value of array. More...
|
|
static int32_t | minimum (const int32_t *pSrc, int dataLength) |
| Calculate maximum value of array. More...
|
|
static int32_t | countClippedValues (const int16_t *pSrc, int dataLength) |
| Find the number of values in vector that are at maximum or minimum 16 bit value. More...
|
|
|
static MP_DSP_VECTOR_API OsStatus | convert (const int32_t *pSrc, int16_t *pDst, int dataLength) |
| Convert vector of 32-bit integers to 16-bit integers. More...
|
|
static MP_DSP_VECTOR_API OsStatus | convert_Gain (const int32_t *pSrc, int16_t *pDst, int dataLength, unsigned srcScaleFactor) |
| Gain vector of 32-bit integers and convert them to 16-bit integers. More...
|
|
static MP_DSP_VECTOR_API OsStatus | convert_Att (const int32_t *pSrc, int16_t *pDst, int dataLength, unsigned srcScaleFactor) |
| Attenuate vector of 32-bit integers and convert them to 16-bit integers. More...
|
|
static MP_DSP_VECTOR_API OsStatus | convert (const int16_t *pSrc, int32_t *pDst, int dataLength) |
| Convert vector of 16-bit integers to 32-bit integers. More...
|
|
static MP_DSP_VECTOR_API OsStatus | convert_Gain (const int16_t *pSrc, int32_t *pDst, int dataLength, unsigned srcScaleFactor) |
| Gain vector of 16-bit integers and convert them to 32-bit integers. More...
|
|
static MP_DSP_VECTOR_API OsStatus | convert_Att (const int16_t *pSrc, int32_t *pDst, int dataLength, unsigned srcScaleFactor) |
| Attenuate vector of 16-bit integers and convert them to 32-bit integers. More...
|
|
Class for generic DSP functions.
This is utils class, containing only static functions. It provide all DSP processing primitives we need, and meant to be good optimized. In fact, we want this to be only place, which will contain hardware specific speed optimizations. If you could not find what you need here - feel free to add it. But do not forget to add generic C-version of each function, so it will be available if there is no optimized version.
Namig conventions.
If function ends with I
it is in-place function. That is its destination is one of source vectors (usually second). If function ends with Gain
or Att
and its source is integers, it is scaling function. That is it scale source vector up or down (gain or attenuate, respectively) before operation. Functions, where source vector is float never scale values, even with Gain
or Att
suffix. Their Gain
and Att
versions are provided to simplify writing of universal floating/fixed-point code.
Saturation.
All arithmetic functions saturate result if destination is integer value (that is for 8-bit unsigned data type 200+200=255
). Functions do not saturate result if destination is floating point.
Unittest coverage.
All functions should be covered by unittests. If you implemented optimized version of some function, run unittests to check does your optimized version behave as expected. If unittests does not cover all paths inside your optimized function, add or modify unittests to cover all of them and check does your function behave the same as original one. If optimized version behave differently from original function and this is wanted behaviour, this is different function in fact. And so you should give it different name. When creating new function, do not forget to provide clean C implementation for convenience.
- Warning
- Please, keep all methods of this class static and stateless!