mirror of
https://github.com/nu774/fdkaac.git
synced 2025-02-03 00:47:41 +01:00
change inline->static inline to follow C99 semantics (for Clang)
This commit is contained in:
parent
9ad6264b3c
commit
01993d6774
26
src/lpcm.c
26
src/lpcm.c
@ -34,6 +34,7 @@ inline int lrint(double x)
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static
|
||||||
inline double pcm_clip(double n, double min_value, double max_value)
|
inline double pcm_clip(double n, double min_value, double max_value)
|
||||||
{
|
{
|
||||||
if (n < min_value)
|
if (n < min_value)
|
||||||
@ -42,6 +43,7 @@ inline double pcm_clip(double n, double min_value, double max_value)
|
|||||||
return max_value;
|
return max_value;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline float pcm_i2f(int32_t n)
|
inline float pcm_i2f(int32_t n)
|
||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
@ -51,6 +53,7 @@ inline float pcm_i2f(int32_t n)
|
|||||||
u.ivalue = n;
|
u.ivalue = n;
|
||||||
return u.fvalue;
|
return u.fvalue;
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline double pcm_i2d(int64_t n)
|
inline double pcm_i2d(int64_t n)
|
||||||
{
|
{
|
||||||
union {
|
union {
|
||||||
@ -60,83 +63,103 @@ inline double pcm_i2d(int64_t n)
|
|||||||
u.ivalue = n;
|
u.ivalue = n;
|
||||||
return u.fvalue;
|
return u.fvalue;
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_quantize_s32(int32_t n)
|
inline int16_t pcm_quantize_s32(int32_t n)
|
||||||
{
|
{
|
||||||
n = ((n >> 15) + 1) >> 1;
|
n = ((n >> 15) + 1) >> 1;
|
||||||
return (n == 0x8000) ? 0x7fff : n;
|
return (n == 0x8000) ? 0x7fff : n;
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_quantize_f64(double v)
|
inline int16_t pcm_quantize_f64(double v)
|
||||||
{
|
{
|
||||||
return (int16_t)lrint(pcm_clip(v * 32768.0, -32768.0, 32767.0));
|
return (int16_t)lrint(pcm_clip(v * 32768.0, -32768.0, 32767.0));
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_s8_to_s16(int8_t n)
|
inline int16_t pcm_s8_to_s16(int8_t n)
|
||||||
{
|
{
|
||||||
return n << 8;
|
return n << 8;
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_u8_to_s16(uint8_t n)
|
inline int16_t pcm_u8_to_s16(uint8_t n)
|
||||||
{
|
{
|
||||||
return (n << 8) ^ 0x8000;
|
return (n << 8) ^ 0x8000;
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_s16le_to_s16(int16_t n)
|
inline int16_t pcm_s16le_to_s16(int16_t n)
|
||||||
{
|
{
|
||||||
return m4af_ltoh16(n);
|
return m4af_ltoh16(n);
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_s16be_to_s16(int16_t n)
|
inline int16_t pcm_s16be_to_s16(int16_t n)
|
||||||
{
|
{
|
||||||
return m4af_btoh16(n);
|
return m4af_btoh16(n);
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_u16le_to_s16(uint16_t n)
|
inline int16_t pcm_u16le_to_s16(uint16_t n)
|
||||||
{
|
{
|
||||||
return m4af_ltoh16(n) ^ 0x8000;
|
return m4af_ltoh16(n) ^ 0x8000;
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_u16be_to_s16(uint16_t n)
|
inline int16_t pcm_u16be_to_s16(uint16_t n)
|
||||||
{
|
{
|
||||||
return m4af_btoh16(n) ^ 0x8000;
|
return m4af_btoh16(n) ^ 0x8000;
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int32_t pcm_s24le_to_s32(uint8_t *p)
|
inline int32_t pcm_s24le_to_s32(uint8_t *p)
|
||||||
{
|
{
|
||||||
return p[0]<<8 | p[1]<<16 | p[2]<<24;
|
return p[0]<<8 | p[1]<<16 | p[2]<<24;
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int32_t pcm_s24be_to_s32(uint8_t *p)
|
inline int32_t pcm_s24be_to_s32(uint8_t *p)
|
||||||
{
|
{
|
||||||
return p[0]<<24 | p[1]<<16 | p[2]<<8;
|
return p[0]<<24 | p[1]<<16 | p[2]<<8;
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int32_t pcm_u24le_to_s32(uint8_t *p)
|
inline int32_t pcm_u24le_to_s32(uint8_t *p)
|
||||||
{
|
{
|
||||||
return pcm_s24le_to_s32(p) ^ 0x80000000;
|
return pcm_s24le_to_s32(p) ^ 0x80000000;
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int32_t pcm_u24be_to_s32(uint8_t *p)
|
inline int32_t pcm_u24be_to_s32(uint8_t *p)
|
||||||
{
|
{
|
||||||
return pcm_s24be_to_s32(p) ^ 0x80000000;
|
return pcm_s24be_to_s32(p) ^ 0x80000000;
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_s24le_to_s16(uint8_t *p)
|
inline int16_t pcm_s24le_to_s16(uint8_t *p)
|
||||||
{
|
{
|
||||||
return pcm_quantize_s32(pcm_s24le_to_s32(p));
|
return pcm_quantize_s32(pcm_s24le_to_s32(p));
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_s24be_to_s16(uint8_t *p)
|
inline int16_t pcm_s24be_to_s16(uint8_t *p)
|
||||||
{
|
{
|
||||||
return pcm_quantize_s32(pcm_s24be_to_s32(p));
|
return pcm_quantize_s32(pcm_s24be_to_s32(p));
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_u24le_to_s16(uint8_t *p)
|
inline int16_t pcm_u24le_to_s16(uint8_t *p)
|
||||||
{
|
{
|
||||||
return pcm_quantize_s32(pcm_u24le_to_s32(p));
|
return pcm_quantize_s32(pcm_u24le_to_s32(p));
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_u24be_to_s16(uint8_t *p)
|
inline int16_t pcm_u24be_to_s16(uint8_t *p)
|
||||||
{
|
{
|
||||||
return pcm_quantize_s32(pcm_u24be_to_s32(p));
|
return pcm_quantize_s32(pcm_u24be_to_s32(p));
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_s32le_to_s16(int32_t n)
|
inline int16_t pcm_s32le_to_s16(int32_t n)
|
||||||
{
|
{
|
||||||
return pcm_quantize_s32(m4af_ltoh32(n));
|
return pcm_quantize_s32(m4af_ltoh32(n));
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_s32be_to_s16(int32_t n)
|
inline int16_t pcm_s32be_to_s16(int32_t n)
|
||||||
{
|
{
|
||||||
return pcm_quantize_s32(m4af_btoh32(n));
|
return pcm_quantize_s32(m4af_btoh32(n));
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_u32le_to_s16(int32_t n)
|
inline int16_t pcm_u32le_to_s16(int32_t n)
|
||||||
{
|
{
|
||||||
return pcm_quantize_s32(m4af_ltoh32(n) ^ 0x80000000);
|
return pcm_quantize_s32(m4af_ltoh32(n) ^ 0x80000000);
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_u32be_to_s16(int32_t n)
|
inline int16_t pcm_u32be_to_s16(int32_t n)
|
||||||
{
|
{
|
||||||
return pcm_quantize_s32(m4af_btoh32(n) ^ 0x80000000);
|
return pcm_quantize_s32(m4af_btoh32(n) ^ 0x80000000);
|
||||||
@ -145,14 +168,17 @@ inline int16_t pcm_f32le_to_s16(int32_t n)
|
|||||||
{
|
{
|
||||||
return pcm_quantize_f64(pcm_i2f(m4af_ltoh32(n)));
|
return pcm_quantize_f64(pcm_i2f(m4af_ltoh32(n)));
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_f32be_to_s16(int32_t n)
|
inline int16_t pcm_f32be_to_s16(int32_t n)
|
||||||
{
|
{
|
||||||
return pcm_quantize_f64(pcm_i2f(m4af_btoh32(n)));
|
return pcm_quantize_f64(pcm_i2f(m4af_btoh32(n)));
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_f64le_to_s16(int64_t n)
|
inline int16_t pcm_f64le_to_s16(int64_t n)
|
||||||
{
|
{
|
||||||
return pcm_quantize_f64(pcm_i2d(m4af_ltoh64(n)));
|
return pcm_quantize_f64(pcm_i2d(m4af_ltoh64(n)));
|
||||||
}
|
}
|
||||||
|
static
|
||||||
inline int16_t pcm_f64be_to_s16(int64_t n)
|
inline int16_t pcm_f64be_to_s16(int64_t n)
|
||||||
{
|
{
|
||||||
return pcm_quantize_f64(pcm_i2d(m4af_btoh64(n)));
|
return pcm_quantize_f64(pcm_i2d(m4af_btoh64(n)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user