Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
2265 lines (1894 loc) · 63 KB

SDL_audiotypecvt.c

File metadata and controls

2265 lines (1894 loc) · 63 KB
 
Aug 28, 2006
Aug 28, 2006
1
/* DO NOT EDIT! This file is generated by sdlgenaudiocvt.pl */
2
3
/*
SDL - Simple DirectMedia Layer
Dec 8, 2008
Dec 8, 2008
4
Copyright (C) 1997-2009 Sam Lantinga
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_audio.h"
#include "SDL_audio_c.h"
Aug 28, 2006
Aug 28, 2006
28
/* *INDENT-OFF* */
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#define DIVBY127 0.0078740157480315f
#define DIVBY32767 3.05185094759972e-05f
#define DIVBY2147483647 4.6566128752458e-10f
static void SDLCALL
SDL_Convert_U8_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
Sint8 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S8.\n");
#endif
src = (const Uint8 *) cvt->buf;
dst = (Sint8 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, ++src, ++dst) {
const Sint8 val = ((*src) ^ 0x80);
*dst = ((Sint8) val);
}
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
53
cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
54
55
56
57
58
59
60
61
62
63
64
65
66
67
}
}
static void SDLCALL
SDL_Convert_U8_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
Uint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U8 to AUDIO_U16LSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
68
69
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
70
71
72
73
74
75
76
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
const Uint16 val = (((Uint16) *src) << 8);
*dst = SDL_SwapLE16(val);
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
77
cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
78
79
80
81
82
83
84
85
86
87
88
89
90
91
}
}
static void SDLCALL
SDL_Convert_U8_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
Sint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S16LSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
92
93
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
94
95
96
97
98
99
100
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
const Sint16 val = (((Sint16) ((*src) ^ 0x80)) << 8);
*dst = ((Sint16) SDL_SwapLE16(val));
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
101
cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
102
103
104
105
106
107
108
109
110
111
112
113
114
115
}
}
static void SDLCALL
SDL_Convert_U8_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
Uint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U8 to AUDIO_U16MSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
116
117
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
118
119
120
121
122
123
124
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
const Uint16 val = (((Uint16) *src) << 8);
*dst = SDL_SwapBE16(val);
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
125
cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
126
127
128
129
130
131
132
133
134
135
136
137
138
139
}
}
static void SDLCALL
SDL_Convert_U8_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
Sint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S16MSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
140
141
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
142
143
144
145
146
147
148
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
const Sint16 val = (((Sint16) ((*src) ^ 0x80)) << 8);
*dst = ((Sint16) SDL_SwapBE16(val));
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
149
cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
150
151
152
153
154
155
156
157
158
159
160
161
162
163
}
}
static void SDLCALL
SDL_Convert_U8_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
Sint32 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S32LSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
164
165
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
166
167
168
169
170
171
172
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
const Sint32 val = (((Sint32) ((*src) ^ 0x80)) << 24);
*dst = ((Sint32) SDL_SwapLE32(val));
}
cvt->len_cvt *= 4;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
173
cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
174
175
176
177
178
179
180
181
182
183
184
185
186
187
}
}
static void SDLCALL
SDL_Convert_U8_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
Sint32 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S32MSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
188
189
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
190
191
192
193
194
195
196
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
const Sint32 val = (((Sint32) ((*src) ^ 0x80)) << 24);
*dst = ((Sint32) SDL_SwapBE32(val));
}
cvt->len_cvt *= 4;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
197
cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
198
199
200
201
202
203
204
205
206
207
208
209
210
211
}
}
static void SDLCALL
SDL_Convert_U8_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
float *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U8 to AUDIO_F32LSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
212
213
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
214
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
Sep 1, 2006
Sep 1, 2006
215
const float val = ((((float) *src) * DIVBY127) - 1.0f);
216
217
218
219
220
*dst = SDL_SwapFloatLE(val);
}
cvt->len_cvt *= 4;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
221
cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
222
223
224
225
226
227
228
229
230
231
232
233
234
235
}
}
static void SDLCALL
SDL_Convert_U8_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
float *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U8 to AUDIO_F32MSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
236
237
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
238
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
Sep 1, 2006
Sep 1, 2006
239
const float val = ((((float) *src) * DIVBY127) - 1.0f);
240
241
242
243
244
*dst = SDL_SwapFloatBE(val);
}
cvt->len_cvt *= 4;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
245
cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
}
}
static void SDLCALL
SDL_Convert_S8_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
Uint8 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U8.\n");
#endif
src = (const Uint8 *) cvt->buf;
dst = (Uint8 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, ++src, ++dst) {
const Uint8 val = ((((Sint8) *src)) ^ 0x80);
*dst = val;
}
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
268
cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
269
270
271
272
273
274
275
276
277
278
279
280
281
282
}
}
static void SDLCALL
SDL_Convert_S8_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
Uint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U16LSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
283
284
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
285
286
287
288
289
290
291
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
const Uint16 val = (((Uint16) ((((Sint8) *src)) ^ 0x80)) << 8);
*dst = SDL_SwapLE16(val);
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
292
cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
293
294
295
296
297
298
299
300
301
302
303
304
305
306
}
}
static void SDLCALL
SDL_Convert_S8_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
Sint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S16LSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
307
308
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
309
310
311
312
313
314
315
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
const Sint16 val = (((Sint16) ((Sint8) *src)) << 8);
*dst = ((Sint16) SDL_SwapLE16(val));
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
316
cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
317
318
319
320
321
322
323
324
325
326
327
328
329
330
}
}
static void SDLCALL
SDL_Convert_S8_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
Uint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U16MSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
331
332
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
333
334
335
336
337
338
339
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
const Uint16 val = (((Uint16) ((((Sint8) *src)) ^ 0x80)) << 8);
*dst = SDL_SwapBE16(val);
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
340
cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
341
342
343
344
345
346
347
348
349
350
351
352
353
354
}
}
static void SDLCALL
SDL_Convert_S8_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
Sint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S16MSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
355
356
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
357
358
359
360
361
362
363
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
const Sint16 val = (((Sint16) ((Sint8) *src)) << 8);
*dst = ((Sint16) SDL_SwapBE16(val));
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
364
cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
365
366
367
368
369
370
371
372
373
374
375
376
377
378
}
}
static void SDLCALL
SDL_Convert_S8_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
Sint32 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S32LSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
379
380
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
381
382
383
384
385
386
387
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
const Sint32 val = (((Sint32) ((Sint8) *src)) << 24);
*dst = ((Sint32) SDL_SwapLE32(val));
}
cvt->len_cvt *= 4;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
388
cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
389
390
391
392
393
394
395
396
397
398
399
400
401
402
}
}
static void SDLCALL
SDL_Convert_S8_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
Sint32 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S32MSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
403
404
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
405
406
407
408
409
410
411
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
const Sint32 val = (((Sint32) ((Sint8) *src)) << 24);
*dst = ((Sint32) SDL_SwapBE32(val));
}
cvt->len_cvt *= 4;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
412
cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
413
414
415
416
417
418
419
420
421
422
423
424
425
426
}
}
static void SDLCALL
SDL_Convert_S8_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
float *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S8 to AUDIO_F32LSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
427
428
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
429
430
431
432
433
434
435
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
const float val = (((float) ((Sint8) *src)) * DIVBY127);
*dst = SDL_SwapFloatLE(val);
}
cvt->len_cvt *= 4;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
436
cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
437
438
439
440
441
442
443
444
445
446
447
448
449
450
}
}
static void SDLCALL
SDL_Convert_S8_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint8 *src;
float *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S8 to AUDIO_F32MSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
451
452
src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
453
454
455
456
457
458
459
for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
const float val = (((float) ((Sint8) *src)) * DIVBY127);
*dst = SDL_SwapFloatBE(val);
}
cvt->len_cvt *= 4;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
460
cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
}
}
static void SDLCALL
SDL_Convert_U16LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Uint8 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_U8.\n");
#endif
src = (const Uint16 *) cvt->buf;
dst = (Uint8 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
const Uint8 val = ((Uint8) (SDL_SwapLE16(*src) >> 8));
*dst = val;
}
cvt->len_cvt /= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
484
cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
}
}
static void SDLCALL
SDL_Convert_U16LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Sint8 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S8.\n");
#endif
src = (const Uint16 *) cvt->buf;
dst = (Sint8 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
const Sint8 val = ((Sint8) (((SDL_SwapLE16(*src)) ^ 0x8000) >> 8));
*dst = ((Sint8) val);
}
cvt->len_cvt /= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
508
cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
}
}
static void SDLCALL
SDL_Convert_U16LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Sint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S16LSB.\n");
#endif
src = (const Uint16 *) cvt->buf;
dst = (Sint16 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
const Sint16 val = ((SDL_SwapLE16(*src)) ^ 0x8000);
*dst = ((Sint16) SDL_SwapLE16(val));
}
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
531
cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
}
}
static void SDLCALL
SDL_Convert_U16LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Uint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_U16MSB.\n");
#endif
src = (const Uint16 *) cvt->buf;
dst = (Uint16 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
const Uint16 val = SDL_SwapLE16(*src);
*dst = SDL_SwapBE16(val);
}
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
554
cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
}
}
static void SDLCALL
SDL_Convert_U16LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Sint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S16MSB.\n");
#endif
src = (const Uint16 *) cvt->buf;
dst = (Sint16 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
const Sint16 val = ((SDL_SwapLE16(*src)) ^ 0x8000);
*dst = ((Sint16) SDL_SwapBE16(val));
}
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
577
cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
578
579
580
581
582
583
584
585
586
587
588
589
590
591
}
}
static void SDLCALL
SDL_Convert_U16LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Sint32 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S32LSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
592
593
src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
594
595
596
597
598
599
600
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
const Sint32 val = (((Sint32) ((SDL_SwapLE16(*src)) ^ 0x8000)) << 16);
*dst = ((Sint32) SDL_SwapLE32(val));
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
601
cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
602
603
604
605
606
607
608
609
610
611
612
613
614
615
}
}
static void SDLCALL
SDL_Convert_U16LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Sint32 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S32MSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
616
617
src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
618
619
620
621
622
623
624
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
const Sint32 val = (((Sint32) ((SDL_SwapLE16(*src)) ^ 0x8000)) << 16);
*dst = ((Sint32) SDL_SwapBE32(val));
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
625
cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
626
627
628
629
630
631
632
633
634
635
636
637
638
639
}
}
static void SDLCALL
SDL_Convert_U16LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
float *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_F32LSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
640
641
src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
642
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
Sep 1, 2006
Sep 1, 2006
643
const float val = ((((float) SDL_SwapLE16(*src)) * DIVBY32767) - 1.0f);
644
645
646
647
648
*dst = SDL_SwapFloatLE(val);
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
649
cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
650
651
652
653
654
655
656
657
658
659
660
661
662
663
}
}
static void SDLCALL
SDL_Convert_U16LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
float *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_F32MSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
664
665
src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
666
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
Sep 1, 2006
Sep 1, 2006
667
const float val = ((((float) SDL_SwapLE16(*src)) * DIVBY32767) - 1.0f);
668
669
670
671
672
*dst = SDL_SwapFloatBE(val);
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
673
cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
}
}
static void SDLCALL
SDL_Convert_S16LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Uint8 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U8.\n");
#endif
src = (const Uint16 *) cvt->buf;
dst = (Uint8 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
const Uint8 val = ((Uint8) (((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000) >> 8));
*dst = val;
}
cvt->len_cvt /= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
697
cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
}
}
static void SDLCALL
SDL_Convert_S16LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Sint8 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S8.\n");
#endif
src = (const Uint16 *) cvt->buf;
dst = (Sint8 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
const Sint8 val = ((Sint8) (((Sint16) SDL_SwapLE16(*src)) >> 8));
*dst = ((Sint8) val);
}
cvt->len_cvt /= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
721
cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
}
}
static void SDLCALL
SDL_Convert_S16LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Uint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U16LSB.\n");
#endif
src = (const Uint16 *) cvt->buf;
dst = (Uint16 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
const Uint16 val = ((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000);
*dst = SDL_SwapLE16(val);
}
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
744
cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
}
}
static void SDLCALL
SDL_Convert_S16LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Uint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U16MSB.\n");
#endif
src = (const Uint16 *) cvt->buf;
dst = (Uint16 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
const Uint16 val = ((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000);
*dst = SDL_SwapBE16(val);
}
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
767
cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
}
}
static void SDLCALL
SDL_Convert_S16LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Sint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S16MSB.\n");
#endif
src = (const Uint16 *) cvt->buf;
dst = (Sint16 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
const Sint16 val = ((Sint16) SDL_SwapLE16(*src));
*dst = ((Sint16) SDL_SwapBE16(val));
}
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
790
cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
791
792
793
794
795
796
797
798
799
800
801
802
803
804
}
}
static void SDLCALL
SDL_Convert_S16LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Sint32 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S32LSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
805
806
src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
807
808
809
810
811
812
813
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
const Sint32 val = (((Sint32) ((Sint16) SDL_SwapLE16(*src))) << 16);
*dst = ((Sint32) SDL_SwapLE32(val));
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
814
cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
815
816
817
818
819
820
821
822
823
824
825
826
827
828
}
}
static void SDLCALL
SDL_Convert_S16LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Sint32 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S32MSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
829
830
src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
831
832
833
834
835
836
837
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
const Sint32 val = (((Sint32) ((Sint16) SDL_SwapLE16(*src))) << 16);
*dst = ((Sint32) SDL_SwapBE32(val));
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
838
cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
839
840
841
842
843
844
845
846
847
848
849
850
851
852
}
}
static void SDLCALL
SDL_Convert_S16LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
float *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_F32LSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
853
854
src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
855
856
857
858
859
860
861
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
const float val = (((float) ((Sint16) SDL_SwapLE16(*src))) * DIVBY32767);
*dst = SDL_SwapFloatLE(val);
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
862
cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
863
864
865
866
867
868
869
870
871
872
873
874
875
876
}
}
static void SDLCALL
SDL_Convert_S16LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
float *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_F32MSB.\n");
#endif
Jan 2, 2009
Jan 2, 2009
877
878
src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
879
880
881
882
883
884
885
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
const float val = (((float) ((Sint16) SDL_SwapLE16(*src))) * DIVBY32767);
*dst = SDL_SwapFloatBE(val);
}
cvt->len_cvt *= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
886
cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
}
}
static void SDLCALL
SDL_Convert_U16MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Uint8 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_U8.\n");
#endif
src = (const Uint16 *) cvt->buf;
dst = (Uint8 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
const Uint8 val = ((Uint8) (SDL_SwapBE16(*src) >> 8));
*dst = val;
}
cvt->len_cvt /= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
910
cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
}
}
static void SDLCALL
SDL_Convert_U16MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Sint8 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S8.\n");
#endif
src = (const Uint16 *) cvt->buf;
dst = (Sint8 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
const Sint8 val = ((Sint8) (((SDL_SwapBE16(*src)) ^ 0x8000) >> 8));
*dst = ((Sint8) val);
}
cvt->len_cvt /= 2;
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
934
cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
}
}
static void SDLCALL
SDL_Convert_U16MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Uint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_U16LSB.\n");
#endif
src = (const Uint16 *) cvt->buf;
dst = (Uint16 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
const Uint16 val = SDL_SwapBE16(*src);
*dst = SDL_SwapLE16(val);
}
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
957
cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
}
}
static void SDLCALL
SDL_Convert_U16MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Sint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S16LSB.\n");
#endif
src = (const Uint16 *) cvt->buf;
dst = (Sint16 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
const Sint16 val = ((SDL_SwapBE16(*src)) ^ 0x8000);
*dst = ((Sint16) SDL_SwapLE16(val));
}
if (cvt->filters[++cvt->filter_index]) {
Jan 2, 2009
Jan 2, 2009
980
cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
}
}
static void SDLCALL
SDL_Convert_U16MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
{
int i;
const Uint16 *src;
Sint16 *dst;
#ifdef DEBUG_CONVERT
fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S16MSB.\n");
#endif
src = (const Uint16 *) cvt->buf;
dst = (Sint16 *) cvt->buf;
for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
const Sint16 val = ((SDL_SwapBE16(*src)) ^ 0x8000);
*dst = ((Sint16) SDL_SwapBE16(val));
}