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

Latest commit

 

History

History
16216 lines (15028 loc) · 612 KB

SDL_audiotypecvt.c

File metadata and controls

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