26 #define FROM_INT_LOOP(NAME, TYPE, SWAP, OFFSET, RANGE) \
27 static void NAME (const TYPE * in, float * out, int samples) \
29 const TYPE * end = in + samples; \
31 * out ++ = (TYPE) (SWAP (* in ++) - OFFSET) * (1.0 / (RANGE + 1.0)); \
34 #define TO_INT_LOOP(NAME, TYPE, SWAP, OFFSET, RANGE) \
35 static void NAME (const float * in, TYPE * out, int samples) \
37 const float * end = in + samples; \
40 double f = (* in ++) * (RANGE + 1.0); \
41 * out ++ = SWAP (OFFSET + (TYPE) round (CLAMP (f, -RANGE - 1, RANGE))); \
45 static inline int8_t
NOOP8 (int8_t i) {
return i;}
46 static inline int16_t
NOOP16 (int16_t i) {
return i;}
47 static inline int32_t
NOOP32 (int32_t i) {
return i;}
55 FROM_INT_LOOP (from_s32, int32_t, NOOP32, 0x00000000, 0x7fffffff)
56 FROM_INT_LOOP (from_u32, int32_t, NOOP32, 0x80000000, 0x7fffffff)
60 TO_INT_LOOP (to_s16, int16_t, NOOP16, 0x0000, 0x7fff)
61 TO_INT_LOOP (to_u16, int16_t, NOOP16, 0x8000, 0x7fff)
62 TO_INT_LOOP (to_s24, int32_t, NOOP32, 0x000000, 0x7fffff)
63 TO_INT_LOOP (to_u24, int32_t, NOOP32, 0x800000, 0x7fffff)
64 TO_INT_LOOP (to_s32, int32_t, NOOP32, 0x00000000, 0x7fffffff)
65 TO_INT_LOOP (to_u32, int32_t, NOOP32, 0x80000000, 0x7fffffff)
67 static inline int16_t
SWAP16 (int16_t i) {
return GUINT16_SWAP_LE_BE (i);}
68 static inline int32_t
SWAP32 (int32_t i) {
return GUINT32_SWAP_LE_BE (i);}
73 FROM_INT_LOOP (from_u24_swap, int32_t, SWAP32, 0x800000, 0x7fffff)
74 FROM_INT_LOOP (from_s32_swap, int32_t, SWAP32, 0x00000000, 0x7fffffff)
75 FROM_INT_LOOP (from_u32_swap, int32_t, SWAP32, 0x80000000, 0x7fffffff)
77 TO_INT_LOOP (to_s16_swap, int16_t, SWAP16, 0x0000, 0x7fff)
78 TO_INT_LOOP (to_u16_swap, int16_t, SWAP16, 0x8000, 0x7fff)
79 TO_INT_LOOP (to_s24_swap, int32_t, SWAP32, 0x000000, 0x7fffff)
80 TO_INT_LOOP (to_u24_swap, int32_t, SWAP32, 0x800000, 0x7fffff)
81 TO_INT_LOOP (to_s32_swap, int32_t, SWAP32, 0x00000000, 0x7fffffff)
82 TO_INT_LOOP (to_u32_swap, int32_t, SWAP32, 0x80000000, 0x7fffffff)
84 typedef
void (*
FromFunc) (const
void * in,
float * out,
int samples);
85 typedef
void (*
ToFunc) (const
float * in,
void * out,
int samples);
98 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
133 for (entry = 0; entry < G_N_ELEMENTS (
convert_table); entry ++)
147 for (entry = 0; entry < G_N_ELEMENTS (
convert_table); entry ++)
159 float * end = data + channels * frames;
164 for (channel = 0; channel <
channels; channel ++)
166 * data = * data * factors[channel];
176 float * end = data + samples;
192 y = 0.15 * y + 0.775;
196 * data ++ = (x > 0) ? y : -y;