mirror of
https://github.com/google/liblc3.git
synced 2026-05-01 02:58:01 +00:00
Add intrinsics saturation feature
This commit is contained in:
14
src/common.h
14
src/common.h
@@ -29,11 +29,16 @@
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __ARM_ARCH
|
||||
#include <arm_acle.h>
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Macros
|
||||
* MIN/MAX Minimum and maximum between 2 values
|
||||
* CLIP Clip a value between low and high limits
|
||||
* SATXX Saturation on 'xx' bits
|
||||
* ABS Return the absolute value
|
||||
*/
|
||||
|
||||
@@ -41,9 +46,18 @@
|
||||
#define LC3_MAX(a, b) ( (a) > (b) ? (a) : (b) )
|
||||
#define LC3_CLIP(v, min, max) LC3_MIN(LC3_MAX(v, min), max)
|
||||
|
||||
#ifdef __ARM_FEATURE_SAT
|
||||
#define LC3_SAT16(v) __ssat(v, 16)
|
||||
#define LC3_SAT24(v) __ssat(v, 24)
|
||||
#else
|
||||
#define LC3_SAT16(v) LC3_CLIP(v, -(1 << 15), (1 << 15) - 1)
|
||||
#define LC3_SAT24(v) LC3_CLIP(v, -(1 << 23), (1 << 23) - 1)
|
||||
#endif
|
||||
|
||||
#define LC3_ABS(n) ( (n) < 0 ? -(n) : (n) )
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert `dt` in us and `sr` in KHz
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user