Sound Open Firmware
Loading...
Searching...
No Matches
numbers.h File Reference

Fixed-point arithmetic, saturation, rounding, and number format conversions. More...

Include dependency graph for numbers.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ABS(a)
 
#define SGN(a)
 
#define USE_SOF_GCD   1
 
#define merge_16b16b(high, low)
 
#define merge_4b4b(high, low)
 
#define INT_MAX_FOR_NUMBER_OF_BITS(N)   ((int64_t)((1ULL << ((N) - 1)) - 1))
 
#define INT_MIN_FOR_NUMBER_OF_BITS(N)   ((int64_t)(-((1ULL << ((N) - 1)) - 1) - 1))
 
#define SPEED_OF_SOUND   343
 
#define RECIPROCAL_SPEED_OF_SOUND_Q31   6260885 /* Q1.31 */
 

Functions

int gcd (int a, int b)
 
static int ceil_divide (int a, int b)
 
static void cross_product_s16 (int32_t *px, int32_t *py, int32_t *pz, int16_t a, int16_t b, int16_t c, int16_t d, int16_t e, int16_t f)
 Cross product function.
 
int find_equal_int16 (int16_t idx[], int16_t vec[], int n, int vec_length, int max_results)
 
int16_t find_min_int16 (int16_t vec[], int vec_length)
 
int32_t find_max_abs_int32 (int32_t vec[], int vec_length)
 
int norm_int32 (int32_t val)
 
uint32_t crc32 (uint32_t base, const void *data, uint32_t bytes)
 

Detailed Description

Fixed-point arithmetic, saturation, rounding, and number format conversions.

Macro Definition Documentation

◆ ABS

#define ABS (   a)
Value:
({ \
__typeof__(a) __a = (a); \
__a < 0 ? -__a : __a; \
})

◆ INT_MAX_FOR_NUMBER_OF_BITS

#define INT_MAX_FOR_NUMBER_OF_BITS (   N)    ((int64_t)((1ULL << ((N) - 1)) - 1))

◆ INT_MIN_FOR_NUMBER_OF_BITS

#define INT_MIN_FOR_NUMBER_OF_BITS (   N)    ((int64_t)(-((1ULL << ((N) - 1)) - 1) - 1))

◆ merge_16b16b

#define merge_16b16b (   high,
  low 
)
Value:
(((uint32_t)(high) << 16) | \
((low) & 0xFFFF))

◆ merge_4b4b

#define merge_4b4b (   high,
  low 
)
Value:
(((uint8_t)(high) << 4) | \
((low) & 0xF))

◆ RECIPROCAL_SPEED_OF_SOUND_Q31

#define RECIPROCAL_SPEED_OF_SOUND_Q31   6260885 /* Q1.31 */

◆ SGN

#define SGN (   a)
Value:
({ \
__typeof__(a) __a = (a); \
__a < 0 ? -1 : \
__a > 0 ? 1 : 0; \
})

◆ SPEED_OF_SOUND

#define SPEED_OF_SOUND   343

◆ USE_SOF_GCD

#define USE_SOF_GCD   1

Function Documentation

◆ ceil_divide()

static int ceil_divide ( int  a,
int  b 
)
inlinestatic

◆ crc32()

uint32_t crc32 ( uint32_t  base,
const void *  data,
uint32_t  bytes 
)

◆ cross_product_s16()

static void cross_product_s16 ( int32_t *  px,
int32_t *  py,
int32_t *  pz,
int16_t  a,
int16_t  b,
int16_t  c,
int16_t  d,
int16_t  e,
int16_t  f 
)
inlinestatic

Cross product function.

Calculate cross product for vectors AB(a, b, c) and AC(d, e, f), where A, B, and C are points of a triangle in 3D space. Cross product is used in computational geometry. Cross product AB x AC is (b * f - c * e, c * d - a * f, a * e - b * d)

Parameters
[out]pxx-axis component of cross product vector
[out]pyy-axis component of cross product vector
[out]pzz-axis component of cross product vector
[in]ax-axis component of vector AB
[in]by-axis component of vector AB
[in]cz-axis component of vector AB
[in]dx-axis component of vector AC
[in]ey-axis component of vector AC
[in]fz-axis component of vector AC

◆ find_equal_int16()

int find_equal_int16 ( int16_t  idx[],
int16_t  vec[],
int  n,
int  vec_length,
int  max_results 
)

◆ find_max_abs_int32()

int32_t find_max_abs_int32 ( int32_t  vec[],
int  vec_length 
)

◆ find_min_int16()

int16_t find_min_int16 ( int16_t  vec[],
int  vec_length 
)

◆ gcd()

int gcd ( int  a,
int  b 
)

◆ norm_int32()

int norm_int32 ( int32_t  val)