Asterisk - The Open Source Telephony Project  18.5.0
Macros
fixed_generic.h File Reference

Generic fixed-point operations. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ADD16(a, b)   ((spx_word16_t)((spx_word16_t)(a)+(spx_word16_t)(b)))
 
#define ADD32(a, b)   ((spx_word32_t)(a)+(spx_word32_t)(b))
 
#define DIV32(a, b)   (((spx_word32_t)(a))/((spx_word32_t)(b)))
 
#define DIV32_16(a, b)   ((spx_word16_t)(((spx_word32_t)(a))/((spx_word16_t)(b))))
 
#define EXTEND32(x)   ((spx_word32_t)(x))
 
#define EXTRACT16(x)   ((spx_word16_t)(x))
 
#define MAC16_16(c, a, b)   (ADD32((c),MULT16_16((a),(b))))
 
#define MAC16_16_P13(c, a, b)   (ADD32((c),SHR(ADD32(4096,MULT16_16((a),(b))),13)))
 
#define MAC16_16_Q11(c, a, b)   (ADD32((c),SHR(MULT16_16((a),(b)),11)))
 
#define MAC16_16_Q13(c, a, b)   (ADD32((c),SHR(MULT16_16((a),(b)),13)))
 
#define MAC16_32_Q11(c, a, b)   ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)))
 
#define MAC16_32_Q15(c, a, b)   ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)))
 
#define MUL_16_32_R15(a, bh, bl)   ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15))
 
#define MULT16_16(a, b)   (((spx_word32_t)(spx_word16_t)(a))*((spx_word32_t)(spx_word16_t)(b)))
 
#define MULT16_16_16(a, b)   ((((spx_word16_t)(a))*((spx_word16_t)(b))))
 
#define MULT16_16_P13(a, b)   (SHR(ADD32(4096,MULT16_16((a),(b))),13))
 
#define MULT16_16_P14(a, b)   (SHR(ADD32(8192,MULT16_16((a),(b))),14))
 
#define MULT16_16_P15(a, b)   (SHR(ADD32(16384,MULT16_16((a),(b))),15))
 
#define MULT16_16_Q11_32(a, b)   (SHR(MULT16_16((a),(b)),11))
 
#define MULT16_16_Q13(a, b)   (SHR(MULT16_16((a),(b)),13))
 
#define MULT16_16_Q14(a, b)   (SHR(MULT16_16((a),(b)),14))
 
#define MULT16_16_Q15(a, b)   (SHR(MULT16_16((a),(b)),15))
 
#define MULT16_32_P15(a, b)   ADD32(MULT16_16((a),SHR((b),15)), PSHR(MULT16_16((a),((b)&0x00007fff)),15))
 
#define MULT16_32_Q11(a, b)   ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))
 
#define MULT16_32_Q12(a, b)   ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12))
 
#define MULT16_32_Q13(a, b)   ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13))
 
#define MULT16_32_Q14(a, b)   ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14))
 
#define MULT16_32_Q15(a, b)   ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))
 
#define NEG16(x)   (-(x))
 
#define NEG32(x)   (-(x))
 
#define PDIV32(a, b)   (((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word32_t)(b)))
 
#define PDIV32_16(a, b)   ((spx_word16_t)(((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word16_t)(b))))
 
#define PSHR(a, shift)   (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift))
 
#define PSHR16(a, shift)   (SHR16((a)+((1<<((shift))>>1)),shift))
 
#define PSHR32(a, shift)   (SHR32((a)+((EXTEND32(1)<<((shift))>>1)),shift))
 
#define QCONST16(x, bits)   ((spx_word16_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
 
#define QCONST32(x, bits)   ((spx_word32_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))
 
#define SATURATE(x, a)   (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
 
#define SATURATE16(x, a)   (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
 
#define SATURATE32(x, a)   (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))
 
#define SATURATE32PSHR(x, shift, a)
 
#define SHL(a, shift)   ((spx_word32_t)(a) << (shift))
 
#define SHL16(a, shift)   ((a) << (shift))
 
#define SHL32(a, shift)   ((a) << (shift))
 
#define SHR(a, shift)   ((a) >> (shift))
 
#define SHR16(a, shift)   ((a) >> (shift))
 
#define SHR32(a, shift)   ((a) >> (shift))
 
#define SUB16(a, b)   ((spx_word16_t)(a)-(spx_word16_t)(b))
 
#define SUB32(a, b)   ((spx_word32_t)(a)-(spx_word32_t)(b))
 
#define VSHR32(a, shift)   (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift)))
 

Detailed Description

Generic fixed-point operations.

Definition in file fixed_generic.h.

Macro Definition Documentation

◆ ADD16

#define ADD16 (   a,
  b 
)    ((spx_word16_t)((spx_word16_t)(a)+(spx_word16_t)(b)))

Definition at line 65 of file fixed_generic.h.

◆ ADD32

#define ADD32 (   a,
  b 
)    ((spx_word32_t)(a)+(spx_word32_t)(b))

Definition at line 67 of file fixed_generic.h.

◆ DIV32

#define DIV32 (   a,
  b 
)    (((spx_word32_t)(a))/((spx_word32_t)(b)))

Definition at line 107 of file fixed_generic.h.

◆ DIV32_16

#define DIV32_16 (   a,
  b 
)    ((spx_word16_t)(((spx_word32_t)(a))/((spx_word16_t)(b))))

Definition at line 105 of file fixed_generic.h.

◆ EXTEND32

#define EXTEND32 (   x)    ((spx_word32_t)(x))

Definition at line 44 of file fixed_generic.h.

Referenced by cubic_coef().

◆ EXTRACT16

#define EXTRACT16 (   x)    ((spx_word16_t)(x))

Definition at line 43 of file fixed_generic.h.

Referenced by cubic_coef().

◆ MAC16_16

#define MAC16_16 (   c,
  a,
  b 
)    (ADD32((c),MULT16_16((a),(b))))

Definition at line 77 of file fixed_generic.h.

◆ MAC16_16_P13

#define MAC16_16_P13 (   c,
  a,
  b 
)    (ADD32((c),SHR(ADD32(4096,MULT16_16((a),(b))),13)))

Definition at line 92 of file fixed_generic.h.

◆ MAC16_16_Q11

#define MAC16_16_Q11 (   c,
  a,
  b 
)    (ADD32((c),SHR(MULT16_16((a),(b)),11)))

Definition at line 90 of file fixed_generic.h.

◆ MAC16_16_Q13

#define MAC16_16_Q13 (   c,
  a,
  b 
)    (ADD32((c),SHR(MULT16_16((a),(b)),13)))

Definition at line 91 of file fixed_generic.h.

◆ MAC16_32_Q11

#define MAC16_32_Q11 (   c,
  a,
  b 
)    ADD32(c,ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11)))

Definition at line 83 of file fixed_generic.h.

◆ MAC16_32_Q15

#define MAC16_32_Q15 (   c,
  a,
  b 
)    ADD32(c,ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15)))

Definition at line 87 of file fixed_generic.h.

◆ MUL_16_32_R15

#define MUL_16_32_R15 (   a,
  bh,
  bl 
)    ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15))

Definition at line 103 of file fixed_generic.h.

◆ MULT16_16

#define MULT16_16 (   a,
  b 
)    (((spx_word32_t)(spx_word16_t)(a))*((spx_word32_t)(spx_word16_t)(b)))

◆ MULT16_16_16

#define MULT16_16_16 (   a,
  b 
)    ((((spx_word16_t)(a))*((spx_word16_t)(b))))

Definition at line 72 of file fixed_generic.h.

◆ MULT16_16_P13

#define MULT16_16_P13 (   a,
  b 
)    (SHR(ADD32(4096,MULT16_16((a),(b))),13))

Definition at line 99 of file fixed_generic.h.

◆ MULT16_16_P14

#define MULT16_16_P14 (   a,
  b 
)    (SHR(ADD32(8192,MULT16_16((a),(b))),14))

Definition at line 100 of file fixed_generic.h.

◆ MULT16_16_P15

#define MULT16_16_P15 (   a,
  b 
)    (SHR(ADD32(16384,MULT16_16((a),(b))),15))

Definition at line 101 of file fixed_generic.h.

Referenced by cubic_coef().

◆ MULT16_16_Q11_32

#define MULT16_16_Q11_32 (   a,
  b 
)    (SHR(MULT16_16((a),(b)),11))

Definition at line 94 of file fixed_generic.h.

◆ MULT16_16_Q13

#define MULT16_16_Q13 (   a,
  b 
)    (SHR(MULT16_16((a),(b)),13))

Definition at line 95 of file fixed_generic.h.

◆ MULT16_16_Q14

#define MULT16_16_Q14 (   a,
  b 
)    (SHR(MULT16_16((a),(b)),14))

Definition at line 96 of file fixed_generic.h.

◆ MULT16_16_Q15

#define MULT16_16_Q15 (   a,
  b 
)    (SHR(MULT16_16((a),(b)),15))

Definition at line 97 of file fixed_generic.h.

◆ MULT16_32_P15

#define MULT16_32_P15 (   a,
  b 
)    ADD32(MULT16_16((a),SHR((b),15)), PSHR(MULT16_16((a),((b)&0x00007fff)),15))

Definition at line 85 of file fixed_generic.h.

◆ MULT16_32_Q11

#define MULT16_32_Q11 (   a,
  b 
)    ADD32(MULT16_16((a),SHR((b),11)), SHR(MULT16_16((a),((b)&0x000007ff)),11))

Definition at line 82 of file fixed_generic.h.

◆ MULT16_32_Q12

#define MULT16_32_Q12 (   a,
  b 
)    ADD32(MULT16_16((a),SHR((b),12)), SHR(MULT16_16((a),((b)&0x00000fff)),12))

Definition at line 78 of file fixed_generic.h.

◆ MULT16_32_Q13

#define MULT16_32_Q13 (   a,
  b 
)    ADD32(MULT16_16((a),SHR((b),13)), SHR(MULT16_16((a),((b)&0x00001fff)),13))

Definition at line 79 of file fixed_generic.h.

◆ MULT16_32_Q14

#define MULT16_32_Q14 (   a,
  b 
)    ADD32(MULT16_16((a),SHR((b),14)), SHR(MULT16_16((a),((b)&0x00003fff)),14))

Definition at line 80 of file fixed_generic.h.

◆ MULT16_32_Q15

#define MULT16_32_Q15 (   a,
  b 
)    ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))

Definition at line 86 of file fixed_generic.h.

Referenced by resampler_basic_interpolate_single().

◆ NEG16

#define NEG16 (   x)    (-(x))

Definition at line 41 of file fixed_generic.h.

◆ NEG32

#define NEG32 (   x)    (-(x))

Definition at line 42 of file fixed_generic.h.

◆ PDIV32

#define PDIV32 (   a,
  b 
)    (((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word32_t)(b)))

Definition at line 108 of file fixed_generic.h.

Referenced by resampler_basic_interpolate_single().

◆ PDIV32_16

#define PDIV32_16 (   a,
  b 
)    ((spx_word16_t)(((spx_word32_t)(a)+((spx_word16_t)(b)>>1))/((spx_word16_t)(b))))

Definition at line 106 of file fixed_generic.h.

◆ PSHR

#define PSHR (   a,
  shift 
)    (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift))

Definition at line 61 of file fixed_generic.h.

◆ PSHR16

#define PSHR16 (   a,
  shift 
)    (SHR16((a)+((1<<((shift))>>1)),shift))

Definition at line 49 of file fixed_generic.h.

◆ PSHR32

#define PSHR32 (   a,
  shift 
)    (SHR32((a)+((EXTEND32(1)<<((shift))>>1)),shift))

◆ QCONST16

#define QCONST16 (   x,
  bits 
)    ((spx_word16_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))

Definition at line 38 of file fixed_generic.h.

Referenced by cubic_coef().

◆ QCONST32

#define QCONST32 (   x,
  bits 
)    ((spx_word32_t)(.5+(x)*(((spx_word32_t)1)<<(bits))))

Definition at line 39 of file fixed_generic.h.

◆ SATURATE

#define SATURATE (   x,
  a 
)    (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))

Definition at line 62 of file fixed_generic.h.

◆ SATURATE16

#define SATURATE16 (   x,
  a 
)    (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))

Definition at line 52 of file fixed_generic.h.

◆ SATURATE32

#define SATURATE32 (   x,
  a 
)    (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x)))

Definition at line 53 of file fixed_generic.h.

◆ SATURATE32PSHR

#define SATURATE32PSHR (   x,
  shift,
  a 
)
Value:
(((x)>=(SHL32(a,shift))) ? (a) : \
(x)<=-(SHL32(a,shift)) ? -(a) : \
(PSHR32(x, shift)))
#define PSHR32(a, shift)
Definition: fixed_generic.h:50
#define SHL32(a, shift)
Definition: fixed_generic.h:48
static struct test_val a

Definition at line 55 of file fixed_generic.h.

Referenced by resampler_basic_direct_single(), and resampler_basic_interpolate_single().

◆ SHL

#define SHL (   a,
  shift 
)    ((spx_word32_t)(a) << (shift))

Definition at line 60 of file fixed_generic.h.

◆ SHL16

#define SHL16 (   a,
  shift 
)    ((a) << (shift))

Definition at line 46 of file fixed_generic.h.

◆ SHL32

#define SHL32 (   a,
  shift 
)    ((a) << (shift))

Definition at line 48 of file fixed_generic.h.

Referenced by resampler_basic_interpolate_single().

◆ SHR

#define SHR (   a,
  shift 
)    ((a) >> (shift))

Definition at line 59 of file fixed_generic.h.

◆ SHR16

#define SHR16 (   a,
  shift 
)    ((a) >> (shift))

Definition at line 45 of file fixed_generic.h.

◆ SHR32

#define SHR32 (   a,
  shift 
)    ((a) >> (shift))

Definition at line 47 of file fixed_generic.h.

Referenced by cubic_coef(), and resampler_basic_interpolate_single().

◆ SUB16

#define SUB16 (   a,
  b 
)    ((spx_word16_t)(a)-(spx_word16_t)(b))

Definition at line 66 of file fixed_generic.h.

◆ SUB32

#define SUB32 (   a,
  b 
)    ((spx_word32_t)(a)-(spx_word32_t)(b))

Definition at line 68 of file fixed_generic.h.

Referenced by cubic_coef().

◆ VSHR32

#define VSHR32 (   a,
  shift 
)    (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift)))

Definition at line 51 of file fixed_generic.h.