27 #define FROM_INT_LOOP(NAME, TYPE, SWAP, OFFSET, RANGE) \
28 static void NAME (const TYPE * in, float * out, int samples) \
30 const TYPE * end = in + samples; \
32 * out ++ = (TYPE) (SWAP (* in ++) - OFFSET) * (1.0 / (RANGE + 1.0)); \
35 #define TO_INT_LOOP(NAME, TYPE, SWAP, OFFSET, RANGE) \
36 static void NAME (const float * in, TYPE * out, int samples) \
38 const float * end = in + samples; \
41 double f = (* in ++) * (RANGE + 1.0); \
42 * out ++ = SWAP (OFFSET + (TYPE) round (CLAMP (f, -RANGE - 1, RANGE))); \
46 static inline int8_t
NOOP8 (int8_t i) {
return i;}
47 static inline int16_t
NOOP16 (int16_t i) {
return i;}
48 static inline int32_t
NOOP32 (int32_t i) {
return i;}
56 FROM_INT_LOOP (from_s32, int32_t, NOOP32, 0x00000000, 0x7fffffff)
57 FROM_INT_LOOP (from_u32, int32_t, NOOP32, 0x80000000, 0x7fffffff)
61 TO_INT_LOOP (to_s16, int16_t, NOOP16, 0x0000, 0x7fff)
62 TO_INT_LOOP (to_u16, int16_t, NOOP16, 0x8000, 0x7fff)
63 TO_INT_LOOP (to_s24, int32_t, NOOP32, 0x000000, 0x7fffff)
64 TO_INT_LOOP (to_u24, int32_t, NOOP32, 0x800000, 0x7fffff)
65 TO_INT_LOOP (to_s32, int32_t, NOOP32, 0x00000000, 0x7fffffff)
66 TO_INT_LOOP (to_u32, int32_t, NOOP32, 0x80000000, 0x7fffffff)
68 static inline int16_t
SWAP16 (int16_t i) {
return GUINT16_SWAP_LE_BE (i);}
69 static inline int32_t
SWAP32 (int32_t i) {
return GUINT32_SWAP_LE_BE (i);}
74 FROM_INT_LOOP (from_u24_swap, int32_t, SWAP32, 0x800000, 0x7fffff)
75 FROM_INT_LOOP (from_s32_swap, int32_t, SWAP32, 0x00000000, 0x7fffffff)
76 FROM_INT_LOOP (from_u32_swap, int32_t, SWAP32, 0x80000000, 0x7fffffff)
78 TO_INT_LOOP (to_s16_swap, int16_t, SWAP16, 0x0000, 0x7fff)
79 TO_INT_LOOP (to_u16_swap, int16_t, SWAP16, 0x8000, 0x7fff)
80 TO_INT_LOOP (to_s24_swap, int32_t, SWAP32, 0x000000, 0x7fffff)
81 TO_INT_LOOP (to_u24_swap, int32_t, SWAP32, 0x800000, 0x7fffff)
82 TO_INT_LOOP (to_s32_swap, int32_t, SWAP32, 0x00000000, 0x7fffffff)
83 TO_INT_LOOP (to_u32_swap, int32_t, SWAP32, 0x80000000, 0x7fffffff)
85 typedef
void (*
FromFunc) (const
void * in,
float * out,
int samples);
86 typedef
void (*
ToFunc) (const
float * in,
void * out,
int samples);
99 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
134 for (entry = 0; entry < G_N_ELEMENTS (
convert_table); entry ++)
148 for (entry = 0; entry < G_N_ELEMENTS (
convert_table); entry ++)
160 float * end = data + channels * frames;
165 for (channel = 0; channel <
channels; channel ++)
167 * data = * data * factors[channel];
177 float * end = data + samples;
193 y = 0.15 * y + 0.775;
197 * data ++ = (x > 0) ? y : -y;