26 #define INTERLACE_LOOP(TYPE) \
27 for (int c = 0; c < channels; c ++) \
29 const TYPE * get = in[c]; \
30 const TYPE * end = get + frames; \
31 TYPE * set = (TYPE *) out + c; \
40 void * out,
int frames)
73 #define FROM_INT_LOOP(NAME, TYPE, SWAP, OFFSET, RANGE) \
74 static void NAME (const TYPE * in, float * out, int samples) \
76 const TYPE * end = in + samples; \
78 * out ++ = (TYPE) (SWAP (* in ++) - OFFSET) * (1.0 / (RANGE + 1.0)); \
81 #define TO_INT_LOOP(NAME, TYPE, SWAP, OFFSET, RANGE) \
82 static void NAME (const float * in, TYPE * out, int samples) \
84 const float * end = in + samples; \
87 double f = (* in ++) * (RANGE + 1.0); \
88 * out ++ = SWAP (OFFSET + (TYPE) round (CLAMP (f, -RANGE - 1, RANGE))); \
105 TO_INT_LOOP (to_s24, int32_t, , 0x000000, 0x7fffff)
106 TO_INT_LOOP (to_u24, int32_t, , 0x800000, 0x7fffff)
107 TO_INT_LOOP (to_s32, int32_t, , 0x00000000, 0x7fffffff)
108 TO_INT_LOOP (to_u32, int32_t, , 0x80000000, 0x7fffffff)
110 static inline int16_t
SWAP16 (int16_t i) {
return GUINT16_SWAP_LE_BE (i);}
111 static inline int32_t
SWAP32 (int32_t i) {
return GUINT32_SWAP_LE_BE (i);}
116 FROM_INT_LOOP (from_u24_swap, int32_t, SWAP32, 0x800000, 0x7fffff)
117 FROM_INT_LOOP (from_s32_swap, int32_t, SWAP32, 0x00000000, 0x7fffffff)
118 FROM_INT_LOOP (from_u32_swap, int32_t, SWAP32, 0x80000000, 0x7fffffff)
120 TO_INT_LOOP (to_s16_swap, int16_t, SWAP16, 0x0000, 0x7fff)
121 TO_INT_LOOP (to_u16_swap, int16_t, SWAP16, 0x8000, 0x7fff)
122 TO_INT_LOOP (to_s24_swap, int32_t, SWAP32, 0x000000, 0x7fffff)
123 TO_INT_LOOP (to_u24_swap, int32_t, SWAP32, 0x800000, 0x7fffff)
124 TO_INT_LOOP (to_s32_swap, int32_t, SWAP32, 0x00000000, 0x7fffffff)
125 TO_INT_LOOP (to_u32_swap, int32_t, SWAP32, 0x80000000, 0x7fffffff)
127 typedef
void (*
FromFunc) (const
void * in,
float * out,
int samples);
128 typedef
void (*
ToFunc) (const
float * in,
void * out,
int samples);
141 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
176 for (entry = 0; entry < G_N_ELEMENTS (
convert_table); entry ++)
190 for (entry = 0; entry < G_N_ELEMENTS (
convert_table); entry ++)
202 float * end = data + channels * frames;
207 for (channel = 0; channel <
channels; channel ++)
209 * data = * data * factors[channel];
219 float * end = data + samples;
235 y = 0.15 * y + 0.775;
239 * data ++ = (x > 0) ? y : -y;