Mercurial > mplayer.hg
annotate libaf/af_format.c @ 14345:c49569461eec
alphabetical order
author | diego |
---|---|
date | Mon, 03 Jan 2005 23:31:07 +0000 |
parents | 8380694ba14f |
children | 1a882e2a419b |
rev | line source |
---|---|
7568 | 1 /* This audio output filter changes the format of a data block. Valid |
2 formats are: AFMT_U8, AFMT_S8, AFMT_S16_LE, AFMT_S16_BE | |
3 AFMT_U16_LE, AFMT_U16_BE, AFMT_S32_LE and AFMT_S32_BE. | |
4 */ | |
5 | |
6 #include <stdio.h> | |
7 #include <stdlib.h> | |
8 #include <string.h> | |
9 #include <unistd.h> | |
10 #include <inttypes.h> | |
11 #include <limits.h> | |
12 | |
13 #include "af.h" | |
12486 | 14 #include "../bswap.h" |
14272 | 15 #include "../libvo/fastmemcpy.h" |
7568 | 16 |
8180
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
17 // Integer to float conversion through lrintf() |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
18 #ifdef HAVE_LRINTF |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
19 #define __USE_ISOC99 1 |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
20 #include <math.h> |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
21 #else |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
22 #define lrintf(x) ((int)(x)) |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
23 #endif |
8167 | 24 |
25 /* Functions used by play to convert the input audio to the correct | |
26 format */ | |
7568 | 27 |
8167 | 28 /* The below includes retrives functions for converting to and from |
29 ulaw and alaw */ | |
30 #include "af_format_ulaw.c" | |
31 #include "af_format_alaw.c" | |
7568 | 32 |
8167 | 33 // Switch endianess |
34 static void endian(void* in, void* out, int len, int bps); | |
35 // From singed to unsigned | |
36 static void si2us(void* in, void* out, int len, int bps); | |
37 // From unsinged to signed | |
38 static void us2si(void* in, void* out, int len, int bps); | |
39 // Change the number of bits per sample | |
40 static void change_bps(void* in, void* out, int len, int inbps, int outbps); | |
41 // From float to int signed | |
42 static void float2int(void* in, void* out, int len, int bps); | |
43 // From signed int to float | |
44 static void int2float(void* in, void* out, int len, int bps); | |
7719
41e8d0916c60
Fix for audio filters on big endian cpus. It's working now on Solaris SPARC &
jkeil
parents:
7711
diff
changeset
|
45 |
14272 | 46 static af_data_t* play(struct af_instance_s* af, af_data_t* data); |
47 static af_data_t* play_swapendian(struct af_instance_s* af, af_data_t* data); | |
48 static af_data_t* play_float_s16(struct af_instance_s* af, af_data_t* data); | |
49 static af_data_t* play_s16_float(struct af_instance_s* af, af_data_t* data); | |
50 | |
8167 | 51 // Convert from string to format |
14245 | 52 int af_str2fmt(char* str) |
7568 | 53 { |
8167 | 54 int format=0; |
55 // Scan for endianess | |
56 if(strstr(str,"be") || strstr(str,"BE")) | |
57 format |= AF_FORMAT_BE; | |
58 else if(strstr(str,"le") || strstr(str,"LE")) | |
59 format |= AF_FORMAT_LE; | |
60 else | |
61 format |= AF_FORMAT_NE; | |
62 | |
63 // Scan for special formats | |
64 if(strstr(str,"mulaw") || strstr(str,"MULAW")){ | |
65 format |= AF_FORMAT_MU_LAW; return format; | |
66 } | |
67 if(strstr(str,"alaw") || strstr(str,"ALAW")){ | |
68 format |= AF_FORMAT_A_LAW; return format; | |
69 } | |
70 if(strstr(str,"ac3") || strstr(str,"AC3")){ | |
71 format |= AF_FORMAT_AC3; return format; | |
72 } | |
73 if(strstr(str,"mpeg2") || strstr(str,"MPEG2")){ | |
74 format |= AF_FORMAT_MPEG2; return format; | |
75 } | |
76 if(strstr(str,"imaadpcm") || strstr(str,"IMAADPCM")){ | |
77 format |= AF_FORMAT_IMA_ADPCM; return format; | |
78 } | |
79 | |
80 // Scan for int/float | |
81 if(strstr(str,"float") || strstr(str,"FLOAT")){ | |
82 format |= AF_FORMAT_F; return format; | |
7568 | 83 } |
8167 | 84 else |
85 format |= AF_FORMAT_I; | |
7568 | 86 |
8167 | 87 // Scan for signed/unsigned |
88 if(strstr(str,"unsigned") || strstr(str,"UNSIGNED")) | |
89 format |= AF_FORMAT_US; | |
90 else | |
91 format |= AF_FORMAT_SI; | |
92 | |
93 return format; | |
94 } | |
95 | |
14245 | 96 inline int af_fmt2bits(int format) |
97 { | |
98 return (format & AF_FORMAT_BITS_MASK)+8; | |
99 // return (((format & AF_FORMAT_BITS_MASK)>>3)+1) * 8; | |
100 #if 0 | |
101 switch(format & AF_FORMAT_BITS_MASK) | |
102 { | |
103 case AF_FORMAT_8BIT: return 8; | |
104 case AF_FORMAT_16BIT: return 16; | |
105 case AF_FORMAT_24BIT: return 24; | |
106 case AF_FORMAT_32BIT: return 32; | |
107 case AF_FORMAT_48BIT: return 48; | |
108 } | |
109 #endif | |
110 return -1; | |
111 } | |
112 | |
14335
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
113 inline int af_bits2fmt(int bits) |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
114 { |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
115 return (bits/8 - 1) << 3; |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
116 } |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
117 |
8167 | 118 /* Convert format to str input str is a buffer for the |
119 converted string, size is the size of the buffer */ | |
14245 | 120 char* af_fmt2str(int format, char* str, int size) |
8167 | 121 { |
122 int i=0; | |
14245 | 123 |
14256
27002dcf0a70
ensure af_fmt2str always return a 0 terminated string
reimar
parents:
14245
diff
changeset
|
124 if (size < 1) |
27002dcf0a70
ensure af_fmt2str always return a 0 terminated string
reimar
parents:
14245
diff
changeset
|
125 return NULL; |
27002dcf0a70
ensure af_fmt2str always return a 0 terminated string
reimar
parents:
14245
diff
changeset
|
126 size--; // reserve one for terminating 0 |
27002dcf0a70
ensure af_fmt2str always return a 0 terminated string
reimar
parents:
14245
diff
changeset
|
127 |
14245 | 128 // Endianess |
8167 | 129 if(AF_FORMAT_LE == (format & AF_FORMAT_END_MASK)) |
14272 | 130 i+=snprintf(str,size-i,"little-endian "); |
8167 | 131 else |
14272 | 132 i+=snprintf(str,size-i,"big-endian "); |
8167 | 133 |
134 if(format & AF_FORMAT_SPECIAL_MASK){ | |
135 switch(format & AF_FORMAT_SPECIAL_MASK){ | |
136 case(AF_FORMAT_MU_LAW): | |
14272 | 137 i+=snprintf(&str[i],size-i,"mu-law "); break; |
8167 | 138 case(AF_FORMAT_A_LAW): |
14272 | 139 i+=snprintf(&str[i],size-i,"A-law "); break; |
8167 | 140 case(AF_FORMAT_MPEG2): |
14272 | 141 i+=snprintf(&str[i],size-i,"MPEG-2 "); break; |
8167 | 142 case(AF_FORMAT_AC3): |
143 i+=snprintf(&str[i],size-i,"AC3 "); break; | |
14263 | 144 case(AF_FORMAT_IMA_ADPCM): |
14272 | 145 i+=snprintf(&str[i],size-i,"IMA-ADPCM "); break; |
14245 | 146 default: |
147 printf("Unknown special\n"); | |
8167 | 148 } |
149 } | |
150 else{ | |
14245 | 151 // Bits |
152 i+=snprintf(&str[i],size-i,"%d-bit ", af_fmt2bits(format)); | |
153 | |
8167 | 154 // Point |
155 if(AF_FORMAT_F == (format & AF_FORMAT_POINT_MASK)) | |
14245 | 156 i+=snprintf(&str[i],size-i,"float "); |
8167 | 157 else{ |
158 // Sign | |
159 if(AF_FORMAT_US == (format & AF_FORMAT_SIGN_MASK)) | |
160 i+=snprintf(&str[i],size-i,"unsigned "); | |
161 else | |
162 i+=snprintf(&str[i],size-i,"signed "); | |
163 | |
14245 | 164 i+=snprintf(&str[i],size-i,"int "); |
8167 | 165 } |
166 } | |
14256
27002dcf0a70
ensure af_fmt2str always return a 0 terminated string
reimar
parents:
14245
diff
changeset
|
167 str[i] = 0; // make sure it is 0 terminated. |
8167 | 168 return str; |
7568 | 169 } |
170 | |
14263 | 171 char *af_fmt2str_short(int format) |
172 { | |
173 switch(format) | |
174 { | |
175 // special | |
176 case AF_FORMAT_MU_LAW: return "mulaw"; | |
177 case AF_FORMAT_A_LAW: return "alaw"; | |
178 case AF_FORMAT_MPEG2: return "mpeg2"; | |
179 case AF_FORMAT_AC3: return "ac3"; | |
180 case AF_FORMAT_IMA_ADPCM: return "imaadpcm"; | |
181 // ordinary | |
182 case AF_FORMAT_U8: return "u8"; | |
183 case AF_FORMAT_S8: return "s8"; | |
184 case AF_FORMAT_U16_LE: return "u16le"; | |
185 case AF_FORMAT_U16_BE: return "u16be"; | |
186 case AF_FORMAT_S16_LE: return "s16le"; | |
187 case AF_FORMAT_S16_BE: return "s16be"; | |
188 case AF_FORMAT_U24_LE: return "u24le"; | |
189 case AF_FORMAT_U24_BE: return "u24be"; | |
190 case AF_FORMAT_S24_LE: return "s24le"; | |
191 case AF_FORMAT_S24_BE: return "s24be"; | |
192 case AF_FORMAT_U32_LE: return "u32le"; | |
193 case AF_FORMAT_U32_BE: return "u32be"; | |
194 case AF_FORMAT_S32_LE: return "s32le"; | |
195 case AF_FORMAT_S32_BE: return "s32be"; | |
196 case AF_FORMAT_FLOAT_LE: return "floatle"; | |
197 case AF_FORMAT_FLOAT_BE: return "floatbe"; | |
198 } | |
199 return "??"; | |
200 } | |
201 | |
14335
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
202 int af_str2fmt_short(char* str) |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
203 { |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
204 int i; |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
205 static struct { |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
206 const char *name; |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
207 const int format; |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
208 } table[] = { |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
209 { "mulaw", AF_FORMAT_MU_LAW }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
210 { "alaw", AF_FORMAT_A_LAW }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
211 { "mpeg2", AF_FORMAT_MPEG2 }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
212 { "ac3", AF_FORMAT_AC3 }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
213 { "imaadpcm", AF_FORMAT_IMA_ADPCM }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
214 |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
215 { "u8", AF_FORMAT_U8 }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
216 { "s8", AF_FORMAT_S8 }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
217 { "u16le", AF_FORMAT_U16_LE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
218 { "u16be", AF_FORMAT_U16_BE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
219 { "u16ne", AF_FORMAT_U16_NE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
220 { "s16le", AF_FORMAT_S16_LE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
221 { "s16be", AF_FORMAT_S16_BE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
222 { "s16ne", AF_FORMAT_S16_NE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
223 { "u24le", AF_FORMAT_U24_LE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
224 { "u24be", AF_FORMAT_U24_BE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
225 { "u24ne", AF_FORMAT_U24_NE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
226 { "s24le", AF_FORMAT_S24_LE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
227 { "s24be", AF_FORMAT_S24_BE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
228 { "s24ne", AF_FORMAT_S24_NE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
229 { "u32le", AF_FORMAT_U32_LE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
230 { "u32be", AF_FORMAT_U32_BE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
231 { "u32ne", AF_FORMAT_U32_NE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
232 { "s32le", AF_FORMAT_S32_LE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
233 { "s32be", AF_FORMAT_S32_BE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
234 { "s32ne", AF_FORMAT_S32_NE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
235 { "floatle", AF_FORMAT_FLOAT_LE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
236 { "floatbe", AF_FORMAT_FLOAT_BE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
237 { "floatne", AF_FORMAT_FLOAT_NE }, |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
238 |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
239 { NULL, 0 } |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
240 }; |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
241 |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
242 for (i = 0; table[i].name; i++) |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
243 if (!strcasecmp(str, table[i].name)) |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
244 return table[i].format; |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
245 |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
246 return -1; |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
247 } |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
248 |
8607 | 249 // Helper functions to check sanity for input arguments |
250 | |
251 // Sanity check for bytes per sample | |
13989
dcb6b4a33aaa
declare check_format and check_bps static, they are used nowhere else.
reimar
parents:
12486
diff
changeset
|
252 static int check_bps(int bps) |
8607 | 253 { |
12478 | 254 if(bps != 4 && bps != 3 && bps != 2 && bps != 1){ |
8607 | 255 af_msg(AF_MSG_ERROR,"[format] The number of bytes per sample" |
12478 | 256 " must be 1, 2, 3 or 4. Current value is %i \n",bps); |
8607 | 257 return AF_ERROR; |
258 } | |
259 return AF_OK; | |
260 } | |
261 | |
262 // Check for unsupported formats | |
13989
dcb6b4a33aaa
declare check_format and check_bps static, they are used nowhere else.
reimar
parents:
12486
diff
changeset
|
263 static int check_format(int format) |
8180
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
264 { |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
265 char buf[256]; |
8607 | 266 switch(format & AF_FORMAT_SPECIAL_MASK){ |
14335
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
267 case(AF_FORMAT_IMA_ADPCM): |
8180
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
268 case(AF_FORMAT_MPEG2): |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
269 case(AF_FORMAT_AC3): |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
270 af_msg(AF_MSG_ERROR,"[format] Sample format %s not yet supported \n", |
14245 | 271 af_fmt2str(format,buf,255)); |
8180
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
272 return AF_ERROR; |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
273 } |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
274 return AF_OK; |
8607 | 275 } |
8180
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
276 |
7568 | 277 // Initialization and runtime control |
278 static int control(struct af_instance_s* af, int cmd, void* arg) | |
279 { | |
280 switch(cmd){ | |
8167 | 281 case AF_CONTROL_REINIT:{ |
282 char buf1[256]; | |
283 char buf2[256]; | |
14272 | 284 af_data_t *data = arg; |
285 | |
7568 | 286 // Make sure this filter isn't redundant |
8167 | 287 if(af->data->format == ((af_data_t*)arg)->format && |
288 af->data->bps == ((af_data_t*)arg)->bps) | |
7568 | 289 return AF_DETACH; |
8607 | 290 |
8180
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
291 // Check for errors in configuraton |
8607 | 292 if((AF_OK != check_bps(((af_data_t*)arg)->bps)) || |
293 (AF_OK != check_format(((af_data_t*)arg)->format)) || | |
294 (AF_OK != check_bps(af->data->bps)) || | |
295 (AF_OK != check_format(af->data->format))) | |
8167 | 296 return AF_ERROR; |
297 | |
14245 | 298 af_msg(AF_MSG_VERBOSE,"[format] Changing sample format from %sto %s \n", |
299 af_fmt2str(((af_data_t*)arg)->format,buf1,255), | |
300 af_fmt2str(af->data->format,buf2,255)); | |
7568 | 301 |
302 af->data->rate = ((af_data_t*)arg)->rate; | |
303 af->data->nch = ((af_data_t*)arg)->nch; | |
304 af->mul.n = af->data->bps; | |
305 af->mul.d = ((af_data_t*)arg)->bps; | |
14272 | 306 |
307 af->play = play; // set default | |
308 | |
309 // look whether only endianess differences are there | |
310 if ((af->data->format & ~AF_FORMAT_END_MASK) == | |
311 (data->format & ~AF_FORMAT_END_MASK)) | |
312 { | |
313 af_msg(AF_MSG_VERBOSE,"[format] Accelerated endianess conversion only\n"); | |
314 af->play = play_swapendian; | |
315 } | |
316 if ((data->format == AF_FORMAT_FLOAT_NE) && | |
317 (af->data->format == AF_FORMAT_S16_NE)) | |
318 { | |
319 af_msg(AF_MSG_VERBOSE,"[format] Accelerated %sto %sconversion\n", | |
320 af_fmt2str(((af_data_t*)arg)->format,buf1,255), | |
321 af_fmt2str(af->data->format,buf2,255)); | |
322 af->play = play_float_s16; | |
323 } | |
324 if ((data->format == AF_FORMAT_S16_NE) && | |
325 (af->data->format == AF_FORMAT_FLOAT_NE)) | |
326 { | |
327 af_msg(AF_MSG_VERBOSE,"[format] Accelerated %sto %sconversion\n", | |
328 af_fmt2str(((af_data_t*)arg)->format,buf1,255), | |
329 af_fmt2str(af->data->format,buf2,255)); | |
330 af->play = play_s16_float; | |
331 } | |
7568 | 332 return AF_OK; |
8167 | 333 } |
7998
d48a06d07afb
Adding commandline options for filters and fixing stupid bug in cfg
anders
parents:
7719
diff
changeset
|
334 case AF_CONTROL_COMMAND_LINE:{ |
14335
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
335 int format = af_str2fmt_short(arg); |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
336 if(AF_OK != af->control(af,AF_CONTROL_FORMAT_FMT | AF_CONTROL_SET,&format)) |
8607 | 337 return AF_ERROR; |
338 return AF_OK; | |
8167 | 339 } |
14335
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
340 case AF_CONTROL_FORMAT_FMT | AF_CONTROL_SET:{ |
8607 | 341 // Check for errors in configuraton |
342 if(AF_OK != check_format(*(int*)arg)) | |
343 return AF_ERROR; | |
344 | |
345 af->data->format = *(int*)arg; | |
14335
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
346 af->data->bps = af_fmt2bits(af->data->format)/8; |
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
347 |
7568 | 348 return AF_OK; |
349 } | |
14335
8380694ba14f
af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents:
14272
diff
changeset
|
350 } |
7568 | 351 return AF_UNKNOWN; |
352 } | |
353 | |
354 // Deallocate memory | |
355 static void uninit(struct af_instance_s* af) | |
356 { | |
357 if(af->data) | |
358 free(af->data); | |
12386 | 359 af->setup = 0; |
7568 | 360 } |
361 | |
14272 | 362 static af_data_t* play_swapendian(struct af_instance_s* af, af_data_t* data) |
363 { | |
364 af_data_t* l = af->data; // Local data | |
365 af_data_t* c = data; // Current working data | |
366 int len = c->len/c->bps; // Lenght in samples of current audio block | |
367 | |
368 if(AF_OK != RESIZE_LOCAL_BUFFER(af,data)) | |
369 return NULL; | |
370 | |
371 endian(c->audio,l->audio,len,c->bps); | |
372 | |
373 c->audio = l->audio; | |
374 c->format = l->format; | |
375 | |
376 return c; | |
377 } | |
378 | |
379 static af_data_t* play_float_s16(struct af_instance_s* af, af_data_t* data) | |
380 { | |
381 af_data_t* l = af->data; // Local data | |
382 af_data_t* c = data; // Current working data | |
383 int len = c->len/4; // Lenght in samples of current audio block | |
384 | |
385 if(AF_OK != RESIZE_LOCAL_BUFFER(af,data)) | |
386 return NULL; | |
387 | |
388 float2int(c->audio, l->audio, len, 2); | |
389 | |
390 c->audio = l->audio; | |
391 c->len = len*2; | |
392 c->bps = 2; | |
393 c->format = l->format; | |
394 | |
395 return c; | |
396 } | |
397 | |
398 static af_data_t* play_s16_float(struct af_instance_s* af, af_data_t* data) | |
399 { | |
400 af_data_t* l = af->data; // Local data | |
401 af_data_t* c = data; // Current working data | |
402 int len = c->len/2; // Lenght in samples of current audio block | |
403 | |
404 if(AF_OK != RESIZE_LOCAL_BUFFER(af,data)) | |
405 return NULL; | |
406 | |
407 int2float(c->audio, l->audio, len, 2); | |
408 | |
409 c->audio = l->audio; | |
410 c->len = len*4; | |
411 c->bps = 4; | |
412 c->format = l->format; | |
413 | |
414 return c; | |
415 } | |
416 | |
7568 | 417 // Filter data through filter |
418 static af_data_t* play(struct af_instance_s* af, af_data_t* data) | |
419 { | |
8167 | 420 af_data_t* l = af->data; // Local data |
421 af_data_t* c = data; // Current working data | |
422 int len = c->len/c->bps; // Lenght in samples of current audio block | |
7568 | 423 |
424 if(AF_OK != RESIZE_LOCAL_BUFFER(af,data)) | |
425 return NULL; | |
426 | |
8167 | 427 // Change to cpu native endian format |
428 if((c->format&AF_FORMAT_END_MASK)!=AF_FORMAT_NE) | |
429 endian(c->audio,c->audio,len,c->bps); | |
7719
41e8d0916c60
Fix for audio filters on big endian cpus. It's working now on Solaris SPARC &
jkeil
parents:
7711
diff
changeset
|
430 |
8167 | 431 // Conversion table |
14261
710b223604fa
100l use right mask type when checking for input format
rtognimp
parents:
14256
diff
changeset
|
432 if((c->format & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_MU_LAW) { |
8167 | 433 from_ulaw(c->audio, l->audio, len, l->bps, l->format&AF_FORMAT_POINT_MASK); |
434 if(AF_FORMAT_A_LAW == (l->format&AF_FORMAT_SPECIAL_MASK)) | |
435 to_ulaw(l->audio, l->audio, len, 1, AF_FORMAT_SI); | |
436 if((l->format&AF_FORMAT_SIGN_MASK) == AF_FORMAT_US) | |
437 si2us(l->audio,l->audio,len,l->bps); | |
14261
710b223604fa
100l use right mask type when checking for input format
rtognimp
parents:
14256
diff
changeset
|
438 } else if((c->format & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_A_LAW) { |
8167 | 439 from_alaw(c->audio, l->audio, len, l->bps, l->format&AF_FORMAT_POINT_MASK); |
440 if(AF_FORMAT_A_LAW == (l->format&AF_FORMAT_SPECIAL_MASK)) | |
441 to_alaw(l->audio, l->audio, len, 1, AF_FORMAT_SI); | |
442 if((l->format&AF_FORMAT_SIGN_MASK) == AF_FORMAT_US) | |
443 si2us(l->audio,l->audio,len,l->bps); | |
14261
710b223604fa
100l use right mask type when checking for input format
rtognimp
parents:
14256
diff
changeset
|
444 } else if((c->format & AF_FORMAT_POINT_MASK) == AF_FORMAT_F) { |
8167 | 445 switch(l->format&AF_FORMAT_SPECIAL_MASK){ |
446 case(AF_FORMAT_MU_LAW): | |
447 to_ulaw(c->audio, l->audio, len, c->bps, c->format&AF_FORMAT_POINT_MASK); | |
448 break; | |
449 case(AF_FORMAT_A_LAW): | |
450 to_alaw(c->audio, l->audio, len, c->bps, c->format&AF_FORMAT_POINT_MASK); | |
7568 | 451 break; |
8180
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
452 default: |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
453 float2int(c->audio, l->audio, len, l->bps); |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
454 if((l->format&AF_FORMAT_SIGN_MASK) == AF_FORMAT_US) |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
455 si2us(l->audio,l->audio,len,l->bps); |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
456 break; |
8167 | 457 } |
14261
710b223604fa
100l use right mask type when checking for input format
rtognimp
parents:
14256
diff
changeset
|
458 } else { |
8167 | 459 // Input must be int |
460 | |
461 // Change signed/unsigned | |
462 if((c->format&AF_FORMAT_SIGN_MASK) != (l->format&AF_FORMAT_SIGN_MASK)){ | |
463 if((c->format&AF_FORMAT_SIGN_MASK) == AF_FORMAT_US) | |
464 us2si(c->audio,c->audio,len,c->bps); | |
465 else | |
466 si2us(c->audio,c->audio,len,c->bps); | |
467 } | |
468 // Convert to special formats | |
8180
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
469 switch(l->format&(AF_FORMAT_SPECIAL_MASK|AF_FORMAT_POINT_MASK)){ |
8167 | 470 case(AF_FORMAT_MU_LAW): |
471 to_ulaw(c->audio, l->audio, len, c->bps, c->format&AF_FORMAT_POINT_MASK); | |
472 break; | |
473 case(AF_FORMAT_A_LAW): | |
474 to_alaw(c->audio, l->audio, len, c->bps, c->format&AF_FORMAT_POINT_MASK); | |
475 break; | |
8180
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
476 case(AF_FORMAT_F): |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
477 int2float(c->audio, l->audio, len, c->bps); |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
478 break; |
8167 | 479 default: |
8180
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
480 // Change the number of bits |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
481 if(c->bps != l->bps) |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
482 change_bps(c->audio,l->audio,len,c->bps,l->bps); |
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
483 else |
8185 | 484 memcpy(l->audio,c->audio,len*c->bps); |
7568 | 485 break; |
486 } | |
487 } | |
7719
41e8d0916c60
Fix for audio filters on big endian cpus. It's working now on Solaris SPARC &
jkeil
parents:
7711
diff
changeset
|
488 |
41e8d0916c60
Fix for audio filters on big endian cpus. It's working now on Solaris SPARC &
jkeil
parents:
7711
diff
changeset
|
489 // Switch from cpu native endian to the correct endianess |
8167 | 490 if((l->format&AF_FORMAT_END_MASK)!=AF_FORMAT_NE) |
491 endian(l->audio,l->audio,len,l->bps); | |
7568 | 492 |
493 // Set output data | |
494 c->audio = l->audio; | |
8167 | 495 c->len = len*l->bps; |
7568 | 496 c->bps = l->bps; |
497 c->format = l->format; | |
498 return c; | |
499 } | |
500 | |
501 // Allocate memory and set function pointers | |
502 static int open(af_instance_t* af){ | |
503 af->control=control; | |
504 af->uninit=uninit; | |
505 af->play=play; | |
506 af->mul.n=1; | |
507 af->mul.d=1; | |
508 af->data=calloc(1,sizeof(af_data_t)); | |
509 if(af->data == NULL) | |
510 return AF_ERROR; | |
511 return AF_OK; | |
512 } | |
513 | |
514 // Description of this filter | |
515 af_info_t af_info_format = { | |
516 "Sample format conversion", | |
517 "format", | |
518 "Anders", | |
519 "", | |
7615 | 520 AF_FLAGS_REENTRANT, |
7568 | 521 open |
522 }; | |
8167 | 523 |
12478 | 524 static inline uint32_t load24bit(void* data, int pos) { |
525 #if WORDS_BIGENDIAN | |
526 return (((uint32_t)((uint8_t*)data)[3*pos])<<24) | | |
527 (((uint32_t)((uint8_t*)data)[3*pos+1])<<16) | | |
528 (((uint32_t)((uint8_t*)data)[3*pos+2])<<8); | |
529 #else | |
530 return (((uint32_t)((uint8_t*)data)[3*pos])<<8) | | |
531 (((uint32_t)((uint8_t*)data)[3*pos+1])<<16) | | |
532 (((uint32_t)((uint8_t*)data)[3*pos+2])<<24); | |
533 #endif | |
534 } | |
535 | |
536 static inline void store24bit(void* data, int pos, uint32_t expanded_value) { | |
537 #if WORDS_BIGENDIAN | |
538 ((uint8_t*)data)[3*pos]=expanded_value>>24; | |
539 ((uint8_t*)data)[3*pos+1]=expanded_value>>16; | |
540 ((uint8_t*)data)[3*pos+2]=expanded_value>>8; | |
541 #else | |
542 ((uint8_t*)data)[3*pos]=expanded_value>>8; | |
543 ((uint8_t*)data)[3*pos+1]=expanded_value>>16; | |
544 ((uint8_t*)data)[3*pos+2]=expanded_value>>24; | |
545 #endif | |
546 } | |
547 | |
8167 | 548 // Function implementations used by play |
549 static void endian(void* in, void* out, int len, int bps) | |
550 { | |
551 register int i; | |
552 switch(bps){ | |
553 case(2):{ | |
554 for(i=0;i<len;i++){ | |
12486 | 555 ((uint16_t*)out)[i]=bswap_16(((uint16_t*)in)[i]); |
8167 | 556 } |
557 break; | |
558 } | |
12478 | 559 case(3):{ |
560 register uint8_t s; | |
561 for(i=0;i<len;i++){ | |
562 s=((uint8_t*)in)[3*i]; | |
563 ((uint8_t*)out)[3*i]=((uint8_t*)in)[3*i+2]; | |
12481
dbbc25ea6403
fix endian conversion for (curently unused) case where in buffer != out buffer
reimar
parents:
12478
diff
changeset
|
564 if (in != out) |
dbbc25ea6403
fix endian conversion for (curently unused) case where in buffer != out buffer
reimar
parents:
12478
diff
changeset
|
565 ((uint8_t*)out)[3*i+1]=((uint8_t*)in)[3*i+1]; |
12478 | 566 ((uint8_t*)out)[3*i+2]=s; |
567 } | |
568 break; | |
569 } | |
8167 | 570 case(4):{ |
571 for(i=0;i<len;i++){ | |
12486 | 572 ((uint32_t*)out)[i]=bswap_32(((uint32_t*)in)[i]); |
8167 | 573 } |
574 break; | |
575 } | |
576 } | |
577 } | |
578 | |
579 static void si2us(void* in, void* out, int len, int bps) | |
580 { | |
581 register int i; | |
582 switch(bps){ | |
583 case(1): | |
584 for(i=0;i<len;i++) | |
585 ((uint8_t*)out)[i]=(uint8_t)(SCHAR_MAX+((int)((int8_t*)in)[i])); | |
586 break; | |
587 case(2): | |
588 for(i=0;i<len;i++) | |
589 ((uint16_t*)out)[i]=(uint16_t)(SHRT_MAX+((int)((int16_t*)in)[i])); | |
590 break; | |
12478 | 591 case(3): |
592 for(i=0;i<len;i++) | |
593 store24bit(out, i, (uint32_t)(INT_MAX+(int32_t)load24bit(in, i))); | |
594 break; | |
8167 | 595 case(4): |
596 for(i=0;i<len;i++) | |
597 ((uint32_t*)out)[i]=(uint32_t)(INT_MAX+((int32_t*)in)[i]); | |
598 break; | |
599 } | |
600 } | |
601 | |
602 static void us2si(void* in, void* out, int len, int bps) | |
603 { | |
604 register int i; | |
605 switch(bps){ | |
606 case(1): | |
607 for(i=0;i<len;i++) | |
608 ((int8_t*)out)[i]=(int8_t)(SCHAR_MIN+((int)((uint8_t*)in)[i])); | |
609 break; | |
610 case(2): | |
611 for(i=0;i<len;i++) | |
612 ((int16_t*)out)[i]=(int16_t)(SHRT_MIN+((int)((uint16_t*)in)[i])); | |
613 break; | |
12478 | 614 case(3): |
615 for(i=0;i<len;i++) | |
616 store24bit(out, i, (int32_t)(INT_MIN+(uint32_t)load24bit(in, i))); | |
617 break; | |
8167 | 618 case(4): |
619 for(i=0;i<len;i++) | |
620 ((int32_t*)out)[i]=(int32_t)(INT_MIN+((uint32_t*)in)[i]); | |
621 break; | |
622 } | |
623 } | |
624 | |
625 static void change_bps(void* in, void* out, int len, int inbps, int outbps) | |
626 { | |
627 register int i; | |
628 switch(inbps){ | |
629 case(1): | |
630 switch(outbps){ | |
631 case(2): | |
632 for(i=0;i<len;i++) | |
633 ((uint16_t*)out)[i]=((uint16_t)((uint8_t*)in)[i])<<8; | |
634 break; | |
12478 | 635 case(3): |
636 for(i=0;i<len;i++) | |
637 store24bit(out, i, ((uint32_t)((uint8_t*)in)[i])<<24); | |
638 break; | |
8167 | 639 case(4): |
640 for(i=0;i<len;i++) | |
641 ((uint32_t*)out)[i]=((uint32_t)((uint8_t*)in)[i])<<24; | |
642 break; | |
643 } | |
644 break; | |
645 case(2): | |
646 switch(outbps){ | |
647 case(1): | |
648 for(i=0;i<len;i++) | |
649 ((uint8_t*)out)[i]=(uint8_t)((((uint16_t*)in)[i])>>8); | |
650 break; | |
12478 | 651 case(3): |
652 for(i=0;i<len;i++) | |
653 store24bit(out, i, ((uint32_t)((uint16_t*)in)[i])<<16); | |
654 break; | |
8167 | 655 case(4): |
656 for(i=0;i<len;i++) | |
657 ((uint32_t*)out)[i]=((uint32_t)((uint16_t*)in)[i])<<16; | |
658 break; | |
659 } | |
660 break; | |
12478 | 661 case(3): |
662 switch(outbps){ | |
663 case(1): | |
664 for(i=0;i<len;i++) | |
665 ((uint8_t*)out)[i]=(uint8_t)(load24bit(in, i)>>24); | |
666 break; | |
667 case(2): | |
668 for(i=0;i<len;i++) | |
669 ((uint16_t*)out)[i]=(uint16_t)(load24bit(in, i)>>16); | |
670 break; | |
671 case(4): | |
672 for(i=0;i<len;i++) | |
673 ((uint32_t*)out)[i]=(uint32_t)load24bit(in, i); | |
674 break; | |
675 } | |
676 break; | |
8167 | 677 case(4): |
678 switch(outbps){ | |
679 case(1): | |
680 for(i=0;i<len;i++) | |
681 ((uint8_t*)out)[i]=(uint8_t)((((uint32_t*)in)[i])>>24); | |
682 break; | |
683 case(2): | |
684 for(i=0;i<len;i++) | |
685 ((uint16_t*)out)[i]=(uint16_t)((((uint32_t*)in)[i])>>16); | |
686 break; | |
12478 | 687 case(3): |
688 for(i=0;i<len;i++) | |
689 store24bit(out, i, ((uint32_t*)in)[i]); | |
690 break; | |
8167 | 691 } |
692 break; | |
693 } | |
694 } | |
695 | |
696 static void float2int(void* in, void* out, int len, int bps) | |
697 { | |
698 register int i; | |
699 switch(bps){ | |
700 case(1): | |
701 for(i=0;i<len;i++) | |
8180
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
702 ((int8_t*)out)[i]=(int8_t)lrintf(SCHAR_MAX*((float*)in)[i]); |
8167 | 703 break; |
704 case(2): | |
705 for(i=0;i<len;i++) | |
8180
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
706 ((int16_t*)out)[i]=(int16_t)lrintf(SHRT_MAX*((float*)in)[i]); |
8167 | 707 break; |
12478 | 708 case(3): |
709 for(i=0;i<len;i++) | |
710 store24bit(out, i, (int32_t)lrintf(INT_MAX*((float*)in)[i])); | |
711 break; | |
8167 | 712 case(4): |
713 for(i=0;i<len;i++) | |
8180
4ba9aed295f2
Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents:
8167
diff
changeset
|
714 ((int32_t*)out)[i]=(int32_t)lrintf(INT_MAX*((float*)in)[i]); |
8167 | 715 break; |
716 } | |
717 } | |
718 | |
719 static void int2float(void* in, void* out, int len, int bps) | |
720 { | |
721 register int i; | |
722 switch(bps){ | |
723 case(1): | |
724 for(i=0;i<len;i++) | |
725 ((float*)out)[i]=(1.0/SCHAR_MAX)*((float)((int8_t*)in)[i]); | |
726 break; | |
727 case(2): | |
728 for(i=0;i<len;i++) | |
729 ((float*)out)[i]=(1.0/SHRT_MAX)*((float)((int16_t*)in)[i]); | |
730 break; | |
12478 | 731 case(3): |
732 for(i=0;i<len;i++) | |
733 ((float*)out)[i]=(1.0/INT_MAX)*((float)((int32_t)load24bit(in, i))); | |
734 break; | |
8167 | 735 case(4): |
736 for(i=0;i<len;i++) | |
737 ((float*)out)[i]=(1.0/INT_MAX)*((float)((int32_t*)in)[i]); | |
738 break; | |
739 } | |
740 } |