#ifndef __LC3_COMMON_H
#define __LC3_COMMON_H
#include <lc3.h>
#include "fastmath.h"
#include <stdalign.h>
#include <limits.h>
#include <string.h>
#ifdef __ARM_ARCH
#include <arm_acle.h>
#endif
#ifndef LC3_PLUS
#define LC3_PLUS 1
#endif
#ifndef LC3_PLUS_HR
#define LC3_PLUS_HR 1
#endif
#if LC3_PLUS
#define LC3_IF_PLUS(a, b) (a)
#else
#define LC3_IF_PLUS(a, b) (b)
#endif
#if LC3_PLUS_HR
#define LC3_IF_PLUS_HR(a, b) (a)
#else
#define LC3_IF_PLUS_HR(a, b) (b)
#endif
#ifdef __clang__
#define LC3_HOT \
__attribute__((no_sanitize("bounds"))) \
__attribute__((no_sanitize("integer")))
#else
#define LC3_HOT
#endif
#define LC3_MIN(a, b) ( (a) < (b) ? (a) : (b) )
#define LC3_MAX(a, b) ( (a) > (b) ? (a) : (b) )
#define LC3_CLIP(v, min, max) LC3_MIN(LC3_MAX(v, min), max)
#define LC3_SAT16(v) LC3_CLIP(v, -(1 << 15), (1 << 15) - 1)
#define LC3_SAT24(v) LC3_CLIP(v, -(1 << 23), (1 << 23) - 1)
#define LC3_ABS(v) ( (v) < 0 ? -(v) : (v) )
#if defined(__ARM_FEATURE_SAT) && !(__GNUC__ < 10)
#undef LC3_SAT16
#define LC3_SAT16(v) __ssat(v, 16)
#undef LC3_SAT24
#define LC3_SAT24(v) __ssat(v, 24)
#endif
static inline bool lc3_hr(enum lc3_srate sr) {
return LC3_PLUS_HR && (sr >= LC3_SRATE_48K_HR);
}
enum lc3_bandwidth {
LC3_BANDWIDTH_NB = LC3_SRATE_8K,
LC3_BANDWIDTH_WB = LC3_SRATE_16K,
LC3_BANDWIDTH_SSWB = LC3_SRATE_24K,
LC3_BANDWIDTH_SWB = LC3_SRATE_32K,
LC3_BANDWIDTH_FB = LC3_SRATE_48K,
LC3_BANDWIDTH_FB_HR = LC3_SRATE_48K_HR,
LC3_BANDWIDTH_UB_HR = LC3_SRATE_96K_HR,
LC3_NUM_BANDWIDTH,
};
struct lc3_complex
{
float re, im;
};
#endif