src/audio/SDL_audiotypecvt.c
author Ryan C. Gordon <icculus@icculus.org>
Thu, 24 Aug 2006 12:10:46 +0000
changeset 1982 3b4ce57c6215
child 1985 8055185ae4ed
permissions -rw-r--r--
First shot at new audio data types (int32 and float32).

Notable changes:
- Converters between types are autogenerated. Instead of making multiple
passes over the data with seperate filters for endianess, size, signedness,
etc, converting between data types is always one specialized filter. This
simplifies SDL_BuildAudioCVT(), which otherwise had a million edge cases
with the new types, and makes the actually conversions more CPU cache
friendly. Left a stub for adding specific optimized versions of these
routines (SSE/MMX/Altivec, assembler, etc)
- Autogenerated converters are built by SDL/src/audio/sdlgenaudiocvt.pl. This
does not need to be run unless tweaking the code, and thus doesn't need
integration into the build system.
- Went through all the drivers and tried to weed out all the "Uint16"
references that are better specified with the new SDL_AudioFormat typedef.
- Cleaned out a bunch of hardcoded bitwise magic numbers and replaced them
with new SDL_AUDIO_* macros.
- Added initial float32 and int32 support code. Theoretically, existing
drivers will push these through converters to get the data they want to
feed to the hardware.

Still TODO:
- Optimize and debug new converters.
- Update the CoreAudio backend to accept float32 data directly.
- Other backends, too?
- SDL_LoadWAV() needs to be updated to support int32 and float32 .wav files
(both of which exist and can be generated by 'sox' for testing purposes).
- Update the mixer to handle new datatypes.
- Optionally update SDL_sound and SDL_mixer, etc.
icculus@1982
     1
/* DO NOT EDIT THIS FILE! It is generated code. */
icculus@1982
     2
/* Please modify SDL/src/audio/sdlgenaudiocvt.pl instead. */
icculus@1982
     3
icculus@1982
     4
/*
icculus@1982
     5
    SDL - Simple DirectMedia Layer
icculus@1982
     6
    Copyright (C) 1997-2006 Sam Lantinga
icculus@1982
     7
icculus@1982
     8
    This library is free software; you can redistribute it and/or
icculus@1982
     9
    modify it under the terms of the GNU Lesser General Public
icculus@1982
    10
    License as published by the Free Software Foundation; either
icculus@1982
    11
    version 2.1 of the License, or (at your option) any later version.
icculus@1982
    12
icculus@1982
    13
    This library is distributed in the hope that it will be useful,
icculus@1982
    14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
icculus@1982
    15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
icculus@1982
    16
    Lesser General Public License for more details.
icculus@1982
    17
icculus@1982
    18
    You should have received a copy of the GNU Lesser General Public
icculus@1982
    19
    License along with this library; if not, write to the Free Software
icculus@1982
    20
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
icculus@1982
    21
icculus@1982
    22
    Sam Lantinga
icculus@1982
    23
    slouken@libsdl.org
icculus@1982
    24
*/
icculus@1982
    25
icculus@1982
    26
#include "SDL_config.h"
icculus@1982
    27
#include "SDL_audio.h"
icculus@1982
    28
#include "SDL_audio_c.h"
icculus@1982
    29
icculus@1982
    30
/* Now the generated code... */
icculus@1982
    31
icculus@1982
    32
#define DIVBY127 0.0078740157480315f
icculus@1982
    33
#define DIVBY255 0.00392156862745098f
icculus@1982
    34
#define DIVBY32767 3.05185094759972e-05f
icculus@1982
    35
#define DIVBY65535 1.52590218966964e-05f
icculus@1982
    36
#define DIVBY2147483647 4.6566128752458e-10f
icculus@1982
    37
icculus@1982
    38
static void SDLCALL
icculus@1982
    39
SDL_Convert_U8_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
    40
{
icculus@1982
    41
    int i;
icculus@1982
    42
    const Uint8 *src;
icculus@1982
    43
    Sint8 *dst;
icculus@1982
    44
icculus@1982
    45
#ifdef DEBUG_CONVERT
icculus@1982
    46
    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S8.\n");
icculus@1982
    47
#endif
icculus@1982
    48
icculus@1982
    49
    src = (const Uint8 *) cvt->buf;
icculus@1982
    50
    dst = (Sint8 *) cvt->buf;
icculus@1982
    51
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, ++src, ++dst) {
icculus@1982
    52
        const Sint8 val = ((*src) ^ 0x80);
icculus@1982
    53
        *dst = ((Sint8) val);
icculus@1982
    54
    }
icculus@1982
    55
icculus@1982
    56
    format = AUDIO_S8;
icculus@1982
    57
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
    58
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
    59
    }
icculus@1982
    60
}
icculus@1982
    61
icculus@1982
    62
static void SDLCALL
icculus@1982
    63
SDL_Convert_U8_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
    64
{
icculus@1982
    65
    int i;
icculus@1982
    66
    const Uint8 *src;
icculus@1982
    67
    Uint16 *dst;
icculus@1982
    68
icculus@1982
    69
#ifdef DEBUG_CONVERT
icculus@1982
    70
    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_U16LSB.\n");
icculus@1982
    71
#endif
icculus@1982
    72
icculus@1982
    73
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
    74
    dst = (Uint16 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
    75
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
    76
        const Uint16 val = (((Uint16) *src) << 8);
icculus@1982
    77
        *dst = SDL_SwapLE16(val);
icculus@1982
    78
    }
icculus@1982
    79
icculus@1982
    80
    cvt->len_cvt *= 2;
icculus@1982
    81
    format = AUDIO_U16LSB;
icculus@1982
    82
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
    83
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
    84
    }
icculus@1982
    85
}
icculus@1982
    86
icculus@1982
    87
static void SDLCALL
icculus@1982
    88
SDL_Convert_U8_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
    89
{
icculus@1982
    90
    int i;
icculus@1982
    91
    const Uint8 *src;
icculus@1982
    92
    Sint16 *dst;
icculus@1982
    93
icculus@1982
    94
#ifdef DEBUG_CONVERT
icculus@1982
    95
    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S16LSB.\n");
icculus@1982
    96
#endif
icculus@1982
    97
icculus@1982
    98
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
    99
    dst = (Sint16 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
   100
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
   101
        const Sint16 val = (((Sint16) ((*src) ^ 0x80)) << 8);
icculus@1982
   102
        *dst = ((Sint16) SDL_SwapLE16(val));
icculus@1982
   103
    }
icculus@1982
   104
icculus@1982
   105
    cvt->len_cvt *= 2;
icculus@1982
   106
    format = AUDIO_S16LSB;
icculus@1982
   107
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   108
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   109
    }
icculus@1982
   110
}
icculus@1982
   111
icculus@1982
   112
static void SDLCALL
icculus@1982
   113
SDL_Convert_U8_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   114
{
icculus@1982
   115
    int i;
icculus@1982
   116
    const Uint8 *src;
icculus@1982
   117
    Uint16 *dst;
icculus@1982
   118
icculus@1982
   119
#ifdef DEBUG_CONVERT
icculus@1982
   120
    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_U16MSB.\n");
icculus@1982
   121
#endif
icculus@1982
   122
icculus@1982
   123
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   124
    dst = (Uint16 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
   125
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
   126
        const Uint16 val = (((Uint16) *src) << 8);
icculus@1982
   127
        *dst = SDL_SwapBE16(val);
icculus@1982
   128
    }
icculus@1982
   129
icculus@1982
   130
    cvt->len_cvt *= 2;
icculus@1982
   131
    format = AUDIO_U16MSB;
icculus@1982
   132
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   133
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   134
    }
icculus@1982
   135
}
icculus@1982
   136
icculus@1982
   137
static void SDLCALL
icculus@1982
   138
SDL_Convert_U8_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   139
{
icculus@1982
   140
    int i;
icculus@1982
   141
    const Uint8 *src;
icculus@1982
   142
    Sint16 *dst;
icculus@1982
   143
icculus@1982
   144
#ifdef DEBUG_CONVERT
icculus@1982
   145
    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S16MSB.\n");
icculus@1982
   146
#endif
icculus@1982
   147
icculus@1982
   148
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   149
    dst = (Sint16 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
   150
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
   151
        const Sint16 val = (((Sint16) ((*src) ^ 0x80)) << 8);
icculus@1982
   152
        *dst = ((Sint16) SDL_SwapBE16(val));
icculus@1982
   153
    }
icculus@1982
   154
icculus@1982
   155
    cvt->len_cvt *= 2;
icculus@1982
   156
    format = AUDIO_S16MSB;
icculus@1982
   157
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   158
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   159
    }
icculus@1982
   160
}
icculus@1982
   161
icculus@1982
   162
static void SDLCALL
icculus@1982
   163
SDL_Convert_U8_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   164
{
icculus@1982
   165
    int i;
icculus@1982
   166
    const Uint8 *src;
icculus@1982
   167
    Sint32 *dst;
icculus@1982
   168
icculus@1982
   169
#ifdef DEBUG_CONVERT
icculus@1982
   170
    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S32LSB.\n");
icculus@1982
   171
#endif
icculus@1982
   172
icculus@1982
   173
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   174
    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 4);
icculus@1982
   175
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
   176
        const Sint32 val = (((Sint32) ((*src) ^ 0x80)) << 24);
icculus@1982
   177
        *dst = ((Sint32) SDL_SwapLE32(val));
icculus@1982
   178
    }
icculus@1982
   179
icculus@1982
   180
    cvt->len_cvt *= 4;
icculus@1982
   181
    format = AUDIO_S32LSB;
icculus@1982
   182
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   183
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   184
    }
icculus@1982
   185
}
icculus@1982
   186
icculus@1982
   187
static void SDLCALL
icculus@1982
   188
SDL_Convert_U8_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   189
{
icculus@1982
   190
    int i;
icculus@1982
   191
    const Uint8 *src;
icculus@1982
   192
    Sint32 *dst;
icculus@1982
   193
icculus@1982
   194
#ifdef DEBUG_CONVERT
icculus@1982
   195
    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S32MSB.\n");
icculus@1982
   196
#endif
icculus@1982
   197
icculus@1982
   198
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   199
    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 4);
icculus@1982
   200
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
   201
        const Sint32 val = (((Sint32) ((*src) ^ 0x80)) << 24);
icculus@1982
   202
        *dst = ((Sint32) SDL_SwapBE32(val));
icculus@1982
   203
    }
icculus@1982
   204
icculus@1982
   205
    cvt->len_cvt *= 4;
icculus@1982
   206
    format = AUDIO_S32MSB;
icculus@1982
   207
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   208
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   209
    }
icculus@1982
   210
}
icculus@1982
   211
icculus@1982
   212
static void SDLCALL
icculus@1982
   213
SDL_Convert_U8_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   214
{
icculus@1982
   215
    int i;
icculus@1982
   216
    const Uint8 *src;
icculus@1982
   217
    float *dst;
icculus@1982
   218
icculus@1982
   219
#ifdef DEBUG_CONVERT
icculus@1982
   220
    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_F32LSB.\n");
icculus@1982
   221
#endif
icculus@1982
   222
icculus@1982
   223
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   224
    dst = (float *) (cvt->buf + cvt->len_cvt * 4);
icculus@1982
   225
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
   226
        const float val = (((float) *src) * DIVBY255);
icculus@1982
   227
        *dst = SDL_SwapFloatLE(val);
icculus@1982
   228
    }
icculus@1982
   229
icculus@1982
   230
    cvt->len_cvt *= 4;
icculus@1982
   231
    format = AUDIO_F32LSB;
icculus@1982
   232
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   233
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   234
    }
icculus@1982
   235
}
icculus@1982
   236
icculus@1982
   237
static void SDLCALL
icculus@1982
   238
SDL_Convert_U8_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   239
{
icculus@1982
   240
    int i;
icculus@1982
   241
    const Uint8 *src;
icculus@1982
   242
    float *dst;
icculus@1982
   243
icculus@1982
   244
#ifdef DEBUG_CONVERT
icculus@1982
   245
    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_F32MSB.\n");
icculus@1982
   246
#endif
icculus@1982
   247
icculus@1982
   248
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   249
    dst = (float *) (cvt->buf + cvt->len_cvt * 4);
icculus@1982
   250
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
   251
        const float val = (((float) *src) * DIVBY255);
icculus@1982
   252
        *dst = SDL_SwapFloatBE(val);
icculus@1982
   253
    }
icculus@1982
   254
icculus@1982
   255
    cvt->len_cvt *= 4;
icculus@1982
   256
    format = AUDIO_F32MSB;
icculus@1982
   257
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   258
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   259
    }
icculus@1982
   260
}
icculus@1982
   261
icculus@1982
   262
static void SDLCALL
icculus@1982
   263
SDL_Convert_S8_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   264
{
icculus@1982
   265
    int i;
icculus@1982
   266
    const Uint8 *src;
icculus@1982
   267
    Uint8 *dst;
icculus@1982
   268
icculus@1982
   269
#ifdef DEBUG_CONVERT
icculus@1982
   270
    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U8.\n");
icculus@1982
   271
#endif
icculus@1982
   272
icculus@1982
   273
    src = (const Uint8 *) cvt->buf;
icculus@1982
   274
    dst = (Uint8 *) cvt->buf;
icculus@1982
   275
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, ++src, ++dst) {
icculus@1982
   276
        const Uint8 val = ((((Sint8) *src)) ^ 0x80);
icculus@1982
   277
        *dst = val;
icculus@1982
   278
    }
icculus@1982
   279
icculus@1982
   280
    format = AUDIO_U8;
icculus@1982
   281
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   282
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   283
    }
icculus@1982
   284
}
icculus@1982
   285
icculus@1982
   286
static void SDLCALL
icculus@1982
   287
SDL_Convert_S8_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   288
{
icculus@1982
   289
    int i;
icculus@1982
   290
    const Uint8 *src;
icculus@1982
   291
    Uint16 *dst;
icculus@1982
   292
icculus@1982
   293
#ifdef DEBUG_CONVERT
icculus@1982
   294
    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U16LSB.\n");
icculus@1982
   295
#endif
icculus@1982
   296
icculus@1982
   297
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   298
    dst = (Uint16 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
   299
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
   300
        const Uint16 val = (((Uint16) ((((Sint8) *src)) ^ 0x80)) << 8);
icculus@1982
   301
        *dst = SDL_SwapLE16(val);
icculus@1982
   302
    }
icculus@1982
   303
icculus@1982
   304
    cvt->len_cvt *= 2;
icculus@1982
   305
    format = AUDIO_U16LSB;
icculus@1982
   306
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   307
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   308
    }
icculus@1982
   309
}
icculus@1982
   310
icculus@1982
   311
static void SDLCALL
icculus@1982
   312
SDL_Convert_S8_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   313
{
icculus@1982
   314
    int i;
icculus@1982
   315
    const Uint8 *src;
icculus@1982
   316
    Sint16 *dst;
icculus@1982
   317
icculus@1982
   318
#ifdef DEBUG_CONVERT
icculus@1982
   319
    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S16LSB.\n");
icculus@1982
   320
#endif
icculus@1982
   321
icculus@1982
   322
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   323
    dst = (Sint16 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
   324
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
   325
        const Sint16 val = (((Sint16) ((Sint8) *src)) << 8);
icculus@1982
   326
        *dst = ((Sint16) SDL_SwapLE16(val));
icculus@1982
   327
    }
icculus@1982
   328
icculus@1982
   329
    cvt->len_cvt *= 2;
icculus@1982
   330
    format = AUDIO_S16LSB;
icculus@1982
   331
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   332
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   333
    }
icculus@1982
   334
}
icculus@1982
   335
icculus@1982
   336
static void SDLCALL
icculus@1982
   337
SDL_Convert_S8_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   338
{
icculus@1982
   339
    int i;
icculus@1982
   340
    const Uint8 *src;
icculus@1982
   341
    Uint16 *dst;
icculus@1982
   342
icculus@1982
   343
#ifdef DEBUG_CONVERT
icculus@1982
   344
    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U16MSB.\n");
icculus@1982
   345
#endif
icculus@1982
   346
icculus@1982
   347
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   348
    dst = (Uint16 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
   349
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
   350
        const Uint16 val = (((Uint16) ((((Sint8) *src)) ^ 0x80)) << 8);
icculus@1982
   351
        *dst = SDL_SwapBE16(val);
icculus@1982
   352
    }
icculus@1982
   353
icculus@1982
   354
    cvt->len_cvt *= 2;
icculus@1982
   355
    format = AUDIO_U16MSB;
icculus@1982
   356
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   357
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   358
    }
icculus@1982
   359
}
icculus@1982
   360
icculus@1982
   361
static void SDLCALL
icculus@1982
   362
SDL_Convert_S8_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   363
{
icculus@1982
   364
    int i;
icculus@1982
   365
    const Uint8 *src;
icculus@1982
   366
    Sint16 *dst;
icculus@1982
   367
icculus@1982
   368
#ifdef DEBUG_CONVERT
icculus@1982
   369
    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S16MSB.\n");
icculus@1982
   370
#endif
icculus@1982
   371
icculus@1982
   372
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   373
    dst = (Sint16 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
   374
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
   375
        const Sint16 val = (((Sint16) ((Sint8) *src)) << 8);
icculus@1982
   376
        *dst = ((Sint16) SDL_SwapBE16(val));
icculus@1982
   377
    }
icculus@1982
   378
icculus@1982
   379
    cvt->len_cvt *= 2;
icculus@1982
   380
    format = AUDIO_S16MSB;
icculus@1982
   381
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   382
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   383
    }
icculus@1982
   384
}
icculus@1982
   385
icculus@1982
   386
static void SDLCALL
icculus@1982
   387
SDL_Convert_S8_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   388
{
icculus@1982
   389
    int i;
icculus@1982
   390
    const Uint8 *src;
icculus@1982
   391
    Sint32 *dst;
icculus@1982
   392
icculus@1982
   393
#ifdef DEBUG_CONVERT
icculus@1982
   394
    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S32LSB.\n");
icculus@1982
   395
#endif
icculus@1982
   396
icculus@1982
   397
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   398
    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 4);
icculus@1982
   399
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
   400
        const Sint32 val = (((Sint32) ((Sint8) *src)) << 24);
icculus@1982
   401
        *dst = ((Sint32) SDL_SwapLE32(val));
icculus@1982
   402
    }
icculus@1982
   403
icculus@1982
   404
    cvt->len_cvt *= 4;
icculus@1982
   405
    format = AUDIO_S32LSB;
icculus@1982
   406
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   407
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   408
    }
icculus@1982
   409
}
icculus@1982
   410
icculus@1982
   411
static void SDLCALL
icculus@1982
   412
SDL_Convert_S8_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   413
{
icculus@1982
   414
    int i;
icculus@1982
   415
    const Uint8 *src;
icculus@1982
   416
    Sint32 *dst;
icculus@1982
   417
icculus@1982
   418
#ifdef DEBUG_CONVERT
icculus@1982
   419
    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S32MSB.\n");
icculus@1982
   420
#endif
icculus@1982
   421
icculus@1982
   422
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   423
    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 4);
icculus@1982
   424
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
   425
        const Sint32 val = (((Sint32) ((Sint8) *src)) << 24);
icculus@1982
   426
        *dst = ((Sint32) SDL_SwapBE32(val));
icculus@1982
   427
    }
icculus@1982
   428
icculus@1982
   429
    cvt->len_cvt *= 4;
icculus@1982
   430
    format = AUDIO_S32MSB;
icculus@1982
   431
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   432
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   433
    }
icculus@1982
   434
}
icculus@1982
   435
icculus@1982
   436
static void SDLCALL
icculus@1982
   437
SDL_Convert_S8_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   438
{
icculus@1982
   439
    int i;
icculus@1982
   440
    const Uint8 *src;
icculus@1982
   441
    float *dst;
icculus@1982
   442
icculus@1982
   443
#ifdef DEBUG_CONVERT
icculus@1982
   444
    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_F32LSB.\n");
icculus@1982
   445
#endif
icculus@1982
   446
icculus@1982
   447
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   448
    dst = (float *) (cvt->buf + cvt->len_cvt * 4);
icculus@1982
   449
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
   450
        const float val = (((float) ((Sint8) *src)) * DIVBY127);
icculus@1982
   451
        *dst = SDL_SwapFloatLE(val);
icculus@1982
   452
    }
icculus@1982
   453
icculus@1982
   454
    cvt->len_cvt *= 4;
icculus@1982
   455
    format = AUDIO_F32LSB;
icculus@1982
   456
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   457
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   458
    }
icculus@1982
   459
}
icculus@1982
   460
icculus@1982
   461
static void SDLCALL
icculus@1982
   462
SDL_Convert_S8_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   463
{
icculus@1982
   464
    int i;
icculus@1982
   465
    const Uint8 *src;
icculus@1982
   466
    float *dst;
icculus@1982
   467
icculus@1982
   468
#ifdef DEBUG_CONVERT
icculus@1982
   469
    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_F32MSB.\n");
icculus@1982
   470
#endif
icculus@1982
   471
icculus@1982
   472
    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   473
    dst = (float *) (cvt->buf + cvt->len_cvt * 4);
icculus@1982
   474
    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
icculus@1982
   475
        const float val = (((float) ((Sint8) *src)) * DIVBY127);
icculus@1982
   476
        *dst = SDL_SwapFloatBE(val);
icculus@1982
   477
    }
icculus@1982
   478
icculus@1982
   479
    cvt->len_cvt *= 4;
icculus@1982
   480
    format = AUDIO_F32MSB;
icculus@1982
   481
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   482
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   483
    }
icculus@1982
   484
}
icculus@1982
   485
icculus@1982
   486
static void SDLCALL
icculus@1982
   487
SDL_Convert_U16LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   488
{
icculus@1982
   489
    int i;
icculus@1982
   490
    const Uint16 *src;
icculus@1982
   491
    Uint8 *dst;
icculus@1982
   492
icculus@1982
   493
#ifdef DEBUG_CONVERT
icculus@1982
   494
    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_U8.\n");
icculus@1982
   495
#endif
icculus@1982
   496
icculus@1982
   497
    src = (const Uint16 *) cvt->buf;
icculus@1982
   498
    dst = (Uint8 *) cvt->buf;
icculus@1982
   499
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
   500
        const Uint8 val = ((Uint8) (SDL_SwapLE16(*src) >> 8));
icculus@1982
   501
        *dst = val;
icculus@1982
   502
    }
icculus@1982
   503
icculus@1982
   504
    cvt->len_cvt /= 2;
icculus@1982
   505
    format = AUDIO_U8;
icculus@1982
   506
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   507
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   508
    }
icculus@1982
   509
}
icculus@1982
   510
icculus@1982
   511
static void SDLCALL
icculus@1982
   512
SDL_Convert_U16LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   513
{
icculus@1982
   514
    int i;
icculus@1982
   515
    const Uint16 *src;
icculus@1982
   516
    Sint8 *dst;
icculus@1982
   517
icculus@1982
   518
#ifdef DEBUG_CONVERT
icculus@1982
   519
    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S8.\n");
icculus@1982
   520
#endif
icculus@1982
   521
icculus@1982
   522
    src = (const Uint16 *) cvt->buf;
icculus@1982
   523
    dst = (Sint8 *) cvt->buf;
icculus@1982
   524
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
   525
        const Sint8 val = ((Sint8) (((SDL_SwapLE16(*src)) ^ 0x8000) >> 8));
icculus@1982
   526
        *dst = ((Sint8) val);
icculus@1982
   527
    }
icculus@1982
   528
icculus@1982
   529
    cvt->len_cvt /= 2;
icculus@1982
   530
    format = AUDIO_S8;
icculus@1982
   531
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   532
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   533
    }
icculus@1982
   534
}
icculus@1982
   535
icculus@1982
   536
static void SDLCALL
icculus@1982
   537
SDL_Convert_U16LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   538
{
icculus@1982
   539
    int i;
icculus@1982
   540
    const Uint16 *src;
icculus@1982
   541
    Sint16 *dst;
icculus@1982
   542
icculus@1982
   543
#ifdef DEBUG_CONVERT
icculus@1982
   544
    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S16LSB.\n");
icculus@1982
   545
#endif
icculus@1982
   546
icculus@1982
   547
    src = (const Uint16 *) cvt->buf;
icculus@1982
   548
    dst = (Sint16 *) cvt->buf;
icculus@1982
   549
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
   550
        const Sint16 val = ((SDL_SwapLE16(*src)) ^ 0x8000);
icculus@1982
   551
        *dst = ((Sint16) SDL_SwapLE16(val));
icculus@1982
   552
    }
icculus@1982
   553
icculus@1982
   554
    format = AUDIO_S16LSB;
icculus@1982
   555
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   556
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   557
    }
icculus@1982
   558
}
icculus@1982
   559
icculus@1982
   560
static void SDLCALL
icculus@1982
   561
SDL_Convert_U16LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   562
{
icculus@1982
   563
    int i;
icculus@1982
   564
    const Uint16 *src;
icculus@1982
   565
    Uint16 *dst;
icculus@1982
   566
icculus@1982
   567
#ifdef DEBUG_CONVERT
icculus@1982
   568
    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_U16MSB.\n");
icculus@1982
   569
#endif
icculus@1982
   570
icculus@1982
   571
    src = (const Uint16 *) cvt->buf;
icculus@1982
   572
    dst = (Uint16 *) cvt->buf;
icculus@1982
   573
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
   574
        const Uint16 val = SDL_SwapLE16(*src);
icculus@1982
   575
        *dst = SDL_SwapBE16(val);
icculus@1982
   576
    }
icculus@1982
   577
icculus@1982
   578
    format = AUDIO_U16MSB;
icculus@1982
   579
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   580
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   581
    }
icculus@1982
   582
}
icculus@1982
   583
icculus@1982
   584
static void SDLCALL
icculus@1982
   585
SDL_Convert_U16LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   586
{
icculus@1982
   587
    int i;
icculus@1982
   588
    const Uint16 *src;
icculus@1982
   589
    Sint16 *dst;
icculus@1982
   590
icculus@1982
   591
#ifdef DEBUG_CONVERT
icculus@1982
   592
    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S16MSB.\n");
icculus@1982
   593
#endif
icculus@1982
   594
icculus@1982
   595
    src = (const Uint16 *) cvt->buf;
icculus@1982
   596
    dst = (Sint16 *) cvt->buf;
icculus@1982
   597
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
   598
        const Sint16 val = ((SDL_SwapLE16(*src)) ^ 0x8000);
icculus@1982
   599
        *dst = ((Sint16) SDL_SwapBE16(val));
icculus@1982
   600
    }
icculus@1982
   601
icculus@1982
   602
    format = AUDIO_S16MSB;
icculus@1982
   603
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   604
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   605
    }
icculus@1982
   606
}
icculus@1982
   607
icculus@1982
   608
static void SDLCALL
icculus@1982
   609
SDL_Convert_U16LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   610
{
icculus@1982
   611
    int i;
icculus@1982
   612
    const Uint16 *src;
icculus@1982
   613
    Sint32 *dst;
icculus@1982
   614
icculus@1982
   615
#ifdef DEBUG_CONVERT
icculus@1982
   616
    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S32LSB.\n");
icculus@1982
   617
#endif
icculus@1982
   618
icculus@1982
   619
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   620
    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
   621
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
   622
        const Sint32 val = (((Sint32) ((SDL_SwapLE16(*src)) ^ 0x8000)) << 16);
icculus@1982
   623
        *dst = ((Sint32) SDL_SwapLE32(val));
icculus@1982
   624
    }
icculus@1982
   625
icculus@1982
   626
    cvt->len_cvt *= 2;
icculus@1982
   627
    format = AUDIO_S32LSB;
icculus@1982
   628
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   629
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   630
    }
icculus@1982
   631
}
icculus@1982
   632
icculus@1982
   633
static void SDLCALL
icculus@1982
   634
SDL_Convert_U16LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   635
{
icculus@1982
   636
    int i;
icculus@1982
   637
    const Uint16 *src;
icculus@1982
   638
    Sint32 *dst;
icculus@1982
   639
icculus@1982
   640
#ifdef DEBUG_CONVERT
icculus@1982
   641
    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S32MSB.\n");
icculus@1982
   642
#endif
icculus@1982
   643
icculus@1982
   644
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   645
    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
   646
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
   647
        const Sint32 val = (((Sint32) ((SDL_SwapLE16(*src)) ^ 0x8000)) << 16);
icculus@1982
   648
        *dst = ((Sint32) SDL_SwapBE32(val));
icculus@1982
   649
    }
icculus@1982
   650
icculus@1982
   651
    cvt->len_cvt *= 2;
icculus@1982
   652
    format = AUDIO_S32MSB;
icculus@1982
   653
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   654
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   655
    }
icculus@1982
   656
}
icculus@1982
   657
icculus@1982
   658
static void SDLCALL
icculus@1982
   659
SDL_Convert_U16LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   660
{
icculus@1982
   661
    int i;
icculus@1982
   662
    const Uint16 *src;
icculus@1982
   663
    float *dst;
icculus@1982
   664
icculus@1982
   665
#ifdef DEBUG_CONVERT
icculus@1982
   666
    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_F32LSB.\n");
icculus@1982
   667
#endif
icculus@1982
   668
icculus@1982
   669
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   670
    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
   671
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
   672
        const float val = (((float) SDL_SwapLE16(*src)) * DIVBY65535);
icculus@1982
   673
        *dst = SDL_SwapFloatLE(val);
icculus@1982
   674
    }
icculus@1982
   675
icculus@1982
   676
    cvt->len_cvt *= 2;
icculus@1982
   677
    format = AUDIO_F32LSB;
icculus@1982
   678
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   679
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   680
    }
icculus@1982
   681
}
icculus@1982
   682
icculus@1982
   683
static void SDLCALL
icculus@1982
   684
SDL_Convert_U16LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   685
{
icculus@1982
   686
    int i;
icculus@1982
   687
    const Uint16 *src;
icculus@1982
   688
    float *dst;
icculus@1982
   689
icculus@1982
   690
#ifdef DEBUG_CONVERT
icculus@1982
   691
    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_F32MSB.\n");
icculus@1982
   692
#endif
icculus@1982
   693
icculus@1982
   694
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   695
    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
   696
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
   697
        const float val = (((float) SDL_SwapLE16(*src)) * DIVBY65535);
icculus@1982
   698
        *dst = SDL_SwapFloatBE(val);
icculus@1982
   699
    }
icculus@1982
   700
icculus@1982
   701
    cvt->len_cvt *= 2;
icculus@1982
   702
    format = AUDIO_F32MSB;
icculus@1982
   703
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   704
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   705
    }
icculus@1982
   706
}
icculus@1982
   707
icculus@1982
   708
static void SDLCALL
icculus@1982
   709
SDL_Convert_S16LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   710
{
icculus@1982
   711
    int i;
icculus@1982
   712
    const Uint16 *src;
icculus@1982
   713
    Uint8 *dst;
icculus@1982
   714
icculus@1982
   715
#ifdef DEBUG_CONVERT
icculus@1982
   716
    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U8.\n");
icculus@1982
   717
#endif
icculus@1982
   718
icculus@1982
   719
    src = (const Uint16 *) cvt->buf;
icculus@1982
   720
    dst = (Uint8 *) cvt->buf;
icculus@1982
   721
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
   722
        const Uint8 val = ((Uint8) (((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000) >> 8));
icculus@1982
   723
        *dst = val;
icculus@1982
   724
    }
icculus@1982
   725
icculus@1982
   726
    cvt->len_cvt /= 2;
icculus@1982
   727
    format = AUDIO_U8;
icculus@1982
   728
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   729
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   730
    }
icculus@1982
   731
}
icculus@1982
   732
icculus@1982
   733
static void SDLCALL
icculus@1982
   734
SDL_Convert_S16LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   735
{
icculus@1982
   736
    int i;
icculus@1982
   737
    const Uint16 *src;
icculus@1982
   738
    Sint8 *dst;
icculus@1982
   739
icculus@1982
   740
#ifdef DEBUG_CONVERT
icculus@1982
   741
    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S8.\n");
icculus@1982
   742
#endif
icculus@1982
   743
icculus@1982
   744
    src = (const Uint16 *) cvt->buf;
icculus@1982
   745
    dst = (Sint8 *) cvt->buf;
icculus@1982
   746
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
   747
        const Sint8 val = ((Sint8) (((Sint16) SDL_SwapLE16(*src)) >> 8));
icculus@1982
   748
        *dst = ((Sint8) val);
icculus@1982
   749
    }
icculus@1982
   750
icculus@1982
   751
    cvt->len_cvt /= 2;
icculus@1982
   752
    format = AUDIO_S8;
icculus@1982
   753
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   754
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   755
    }
icculus@1982
   756
}
icculus@1982
   757
icculus@1982
   758
static void SDLCALL
icculus@1982
   759
SDL_Convert_S16LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   760
{
icculus@1982
   761
    int i;
icculus@1982
   762
    const Uint16 *src;
icculus@1982
   763
    Uint16 *dst;
icculus@1982
   764
icculus@1982
   765
#ifdef DEBUG_CONVERT
icculus@1982
   766
    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U16LSB.\n");
icculus@1982
   767
#endif
icculus@1982
   768
icculus@1982
   769
    src = (const Uint16 *) cvt->buf;
icculus@1982
   770
    dst = (Uint16 *) cvt->buf;
icculus@1982
   771
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
   772
        const Uint16 val = ((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000);
icculus@1982
   773
        *dst = SDL_SwapLE16(val);
icculus@1982
   774
    }
icculus@1982
   775
icculus@1982
   776
    format = AUDIO_U16LSB;
icculus@1982
   777
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   778
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   779
    }
icculus@1982
   780
}
icculus@1982
   781
icculus@1982
   782
static void SDLCALL
icculus@1982
   783
SDL_Convert_S16LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   784
{
icculus@1982
   785
    int i;
icculus@1982
   786
    const Uint16 *src;
icculus@1982
   787
    Uint16 *dst;
icculus@1982
   788
icculus@1982
   789
#ifdef DEBUG_CONVERT
icculus@1982
   790
    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U16MSB.\n");
icculus@1982
   791
#endif
icculus@1982
   792
icculus@1982
   793
    src = (const Uint16 *) cvt->buf;
icculus@1982
   794
    dst = (Uint16 *) cvt->buf;
icculus@1982
   795
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
   796
        const Uint16 val = ((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000);
icculus@1982
   797
        *dst = SDL_SwapBE16(val);
icculus@1982
   798
    }
icculus@1982
   799
icculus@1982
   800
    format = AUDIO_U16MSB;
icculus@1982
   801
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   802
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   803
    }
icculus@1982
   804
}
icculus@1982
   805
icculus@1982
   806
static void SDLCALL
icculus@1982
   807
SDL_Convert_S16LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   808
{
icculus@1982
   809
    int i;
icculus@1982
   810
    const Uint16 *src;
icculus@1982
   811
    Sint16 *dst;
icculus@1982
   812
icculus@1982
   813
#ifdef DEBUG_CONVERT
icculus@1982
   814
    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S16MSB.\n");
icculus@1982
   815
#endif
icculus@1982
   816
icculus@1982
   817
    src = (const Uint16 *) cvt->buf;
icculus@1982
   818
    dst = (Sint16 *) cvt->buf;
icculus@1982
   819
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
   820
        const Sint16 val = ((Sint16) SDL_SwapLE16(*src));
icculus@1982
   821
        *dst = ((Sint16) SDL_SwapBE16(val));
icculus@1982
   822
    }
icculus@1982
   823
icculus@1982
   824
    format = AUDIO_S16MSB;
icculus@1982
   825
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   826
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   827
    }
icculus@1982
   828
}
icculus@1982
   829
icculus@1982
   830
static void SDLCALL
icculus@1982
   831
SDL_Convert_S16LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   832
{
icculus@1982
   833
    int i;
icculus@1982
   834
    const Uint16 *src;
icculus@1982
   835
    Sint32 *dst;
icculus@1982
   836
icculus@1982
   837
#ifdef DEBUG_CONVERT
icculus@1982
   838
    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S32LSB.\n");
icculus@1982
   839
#endif
icculus@1982
   840
icculus@1982
   841
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   842
    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
   843
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
   844
        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapLE16(*src))) << 16);
icculus@1982
   845
        *dst = ((Sint32) SDL_SwapLE32(val));
icculus@1982
   846
    }
icculus@1982
   847
icculus@1982
   848
    cvt->len_cvt *= 2;
icculus@1982
   849
    format = AUDIO_S32LSB;
icculus@1982
   850
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   851
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   852
    }
icculus@1982
   853
}
icculus@1982
   854
icculus@1982
   855
static void SDLCALL
icculus@1982
   856
SDL_Convert_S16LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   857
{
icculus@1982
   858
    int i;
icculus@1982
   859
    const Uint16 *src;
icculus@1982
   860
    Sint32 *dst;
icculus@1982
   861
icculus@1982
   862
#ifdef DEBUG_CONVERT
icculus@1982
   863
    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S32MSB.\n");
icculus@1982
   864
#endif
icculus@1982
   865
icculus@1982
   866
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   867
    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
   868
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
   869
        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapLE16(*src))) << 16);
icculus@1982
   870
        *dst = ((Sint32) SDL_SwapBE32(val));
icculus@1982
   871
    }
icculus@1982
   872
icculus@1982
   873
    cvt->len_cvt *= 2;
icculus@1982
   874
    format = AUDIO_S32MSB;
icculus@1982
   875
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   876
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   877
    }
icculus@1982
   878
}
icculus@1982
   879
icculus@1982
   880
static void SDLCALL
icculus@1982
   881
SDL_Convert_S16LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   882
{
icculus@1982
   883
    int i;
icculus@1982
   884
    const Uint16 *src;
icculus@1982
   885
    float *dst;
icculus@1982
   886
icculus@1982
   887
#ifdef DEBUG_CONVERT
icculus@1982
   888
    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_F32LSB.\n");
icculus@1982
   889
#endif
icculus@1982
   890
icculus@1982
   891
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   892
    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
   893
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
   894
        const float val = (((float) ((Sint16) SDL_SwapLE16(*src))) * DIVBY32767);
icculus@1982
   895
        *dst = SDL_SwapFloatLE(val);
icculus@1982
   896
    }
icculus@1982
   897
icculus@1982
   898
    cvt->len_cvt *= 2;
icculus@1982
   899
    format = AUDIO_F32LSB;
icculus@1982
   900
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   901
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   902
    }
icculus@1982
   903
}
icculus@1982
   904
icculus@1982
   905
static void SDLCALL
icculus@1982
   906
SDL_Convert_S16LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   907
{
icculus@1982
   908
    int i;
icculus@1982
   909
    const Uint16 *src;
icculus@1982
   910
    float *dst;
icculus@1982
   911
icculus@1982
   912
#ifdef DEBUG_CONVERT
icculus@1982
   913
    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_F32MSB.\n");
icculus@1982
   914
#endif
icculus@1982
   915
icculus@1982
   916
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
   917
    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
   918
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
   919
        const float val = (((float) ((Sint16) SDL_SwapLE16(*src))) * DIVBY32767);
icculus@1982
   920
        *dst = SDL_SwapFloatBE(val);
icculus@1982
   921
    }
icculus@1982
   922
icculus@1982
   923
    cvt->len_cvt *= 2;
icculus@1982
   924
    format = AUDIO_F32MSB;
icculus@1982
   925
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   926
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   927
    }
icculus@1982
   928
}
icculus@1982
   929
icculus@1982
   930
static void SDLCALL
icculus@1982
   931
SDL_Convert_U16MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   932
{
icculus@1982
   933
    int i;
icculus@1982
   934
    const Uint16 *src;
icculus@1982
   935
    Uint8 *dst;
icculus@1982
   936
icculus@1982
   937
#ifdef DEBUG_CONVERT
icculus@1982
   938
    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_U8.\n");
icculus@1982
   939
#endif
icculus@1982
   940
icculus@1982
   941
    src = (const Uint16 *) cvt->buf;
icculus@1982
   942
    dst = (Uint8 *) cvt->buf;
icculus@1982
   943
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
   944
        const Uint8 val = ((Uint8) (SDL_SwapBE16(*src) >> 8));
icculus@1982
   945
        *dst = val;
icculus@1982
   946
    }
icculus@1982
   947
icculus@1982
   948
    cvt->len_cvt /= 2;
icculus@1982
   949
    format = AUDIO_U8;
icculus@1982
   950
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   951
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   952
    }
icculus@1982
   953
}
icculus@1982
   954
icculus@1982
   955
static void SDLCALL
icculus@1982
   956
SDL_Convert_U16MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   957
{
icculus@1982
   958
    int i;
icculus@1982
   959
    const Uint16 *src;
icculus@1982
   960
    Sint8 *dst;
icculus@1982
   961
icculus@1982
   962
#ifdef DEBUG_CONVERT
icculus@1982
   963
    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S8.\n");
icculus@1982
   964
#endif
icculus@1982
   965
icculus@1982
   966
    src = (const Uint16 *) cvt->buf;
icculus@1982
   967
    dst = (Sint8 *) cvt->buf;
icculus@1982
   968
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
   969
        const Sint8 val = ((Sint8) (((SDL_SwapBE16(*src)) ^ 0x8000) >> 8));
icculus@1982
   970
        *dst = ((Sint8) val);
icculus@1982
   971
    }
icculus@1982
   972
icculus@1982
   973
    cvt->len_cvt /= 2;
icculus@1982
   974
    format = AUDIO_S8;
icculus@1982
   975
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
   976
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
   977
    }
icculus@1982
   978
}
icculus@1982
   979
icculus@1982
   980
static void SDLCALL
icculus@1982
   981
SDL_Convert_U16MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
   982
{
icculus@1982
   983
    int i;
icculus@1982
   984
    const Uint16 *src;
icculus@1982
   985
    Uint16 *dst;
icculus@1982
   986
icculus@1982
   987
#ifdef DEBUG_CONVERT
icculus@1982
   988
    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_U16LSB.\n");
icculus@1982
   989
#endif
icculus@1982
   990
icculus@1982
   991
    src = (const Uint16 *) cvt->buf;
icculus@1982
   992
    dst = (Uint16 *) cvt->buf;
icculus@1982
   993
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
   994
        const Uint16 val = SDL_SwapBE16(*src);
icculus@1982
   995
        *dst = SDL_SwapLE16(val);
icculus@1982
   996
    }
icculus@1982
   997
icculus@1982
   998
    format = AUDIO_U16LSB;
icculus@1982
   999
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1000
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1001
    }
icculus@1982
  1002
}
icculus@1982
  1003
icculus@1982
  1004
static void SDLCALL
icculus@1982
  1005
SDL_Convert_U16MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1006
{
icculus@1982
  1007
    int i;
icculus@1982
  1008
    const Uint16 *src;
icculus@1982
  1009
    Sint16 *dst;
icculus@1982
  1010
icculus@1982
  1011
#ifdef DEBUG_CONVERT
icculus@1982
  1012
    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S16LSB.\n");
icculus@1982
  1013
#endif
icculus@1982
  1014
icculus@1982
  1015
    src = (const Uint16 *) cvt->buf;
icculus@1982
  1016
    dst = (Sint16 *) cvt->buf;
icculus@1982
  1017
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
  1018
        const Sint16 val = ((SDL_SwapBE16(*src)) ^ 0x8000);
icculus@1982
  1019
        *dst = ((Sint16) SDL_SwapLE16(val));
icculus@1982
  1020
    }
icculus@1982
  1021
icculus@1982
  1022
    format = AUDIO_S16LSB;
icculus@1982
  1023
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1024
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1025
    }
icculus@1982
  1026
}
icculus@1982
  1027
icculus@1982
  1028
static void SDLCALL
icculus@1982
  1029
SDL_Convert_U16MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1030
{
icculus@1982
  1031
    int i;
icculus@1982
  1032
    const Uint16 *src;
icculus@1982
  1033
    Sint16 *dst;
icculus@1982
  1034
icculus@1982
  1035
#ifdef DEBUG_CONVERT
icculus@1982
  1036
    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S16MSB.\n");
icculus@1982
  1037
#endif
icculus@1982
  1038
icculus@1982
  1039
    src = (const Uint16 *) cvt->buf;
icculus@1982
  1040
    dst = (Sint16 *) cvt->buf;
icculus@1982
  1041
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
  1042
        const Sint16 val = ((SDL_SwapBE16(*src)) ^ 0x8000);
icculus@1982
  1043
        *dst = ((Sint16) SDL_SwapBE16(val));
icculus@1982
  1044
    }
icculus@1982
  1045
icculus@1982
  1046
    format = AUDIO_S16MSB;
icculus@1982
  1047
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1048
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1049
    }
icculus@1982
  1050
}
icculus@1982
  1051
icculus@1982
  1052
static void SDLCALL
icculus@1982
  1053
SDL_Convert_U16MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1054
{
icculus@1982
  1055
    int i;
icculus@1982
  1056
    const Uint16 *src;
icculus@1982
  1057
    Sint32 *dst;
icculus@1982
  1058
icculus@1982
  1059
#ifdef DEBUG_CONVERT
icculus@1982
  1060
    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S32LSB.\n");
icculus@1982
  1061
#endif
icculus@1982
  1062
icculus@1982
  1063
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
  1064
    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
  1065
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
  1066
        const Sint32 val = (((Sint32) ((SDL_SwapBE16(*src)) ^ 0x8000)) << 16);
icculus@1982
  1067
        *dst = ((Sint32) SDL_SwapLE32(val));
icculus@1982
  1068
    }
icculus@1982
  1069
icculus@1982
  1070
    cvt->len_cvt *= 2;
icculus@1982
  1071
    format = AUDIO_S32LSB;
icculus@1982
  1072
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1073
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1074
    }
icculus@1982
  1075
}
icculus@1982
  1076
icculus@1982
  1077
static void SDLCALL
icculus@1982
  1078
SDL_Convert_U16MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1079
{
icculus@1982
  1080
    int i;
icculus@1982
  1081
    const Uint16 *src;
icculus@1982
  1082
    Sint32 *dst;
icculus@1982
  1083
icculus@1982
  1084
#ifdef DEBUG_CONVERT
icculus@1982
  1085
    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S32MSB.\n");
icculus@1982
  1086
#endif
icculus@1982
  1087
icculus@1982
  1088
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
  1089
    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
  1090
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
  1091
        const Sint32 val = (((Sint32) ((SDL_SwapBE16(*src)) ^ 0x8000)) << 16);
icculus@1982
  1092
        *dst = ((Sint32) SDL_SwapBE32(val));
icculus@1982
  1093
    }
icculus@1982
  1094
icculus@1982
  1095
    cvt->len_cvt *= 2;
icculus@1982
  1096
    format = AUDIO_S32MSB;
icculus@1982
  1097
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1098
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1099
    }
icculus@1982
  1100
}
icculus@1982
  1101
icculus@1982
  1102
static void SDLCALL
icculus@1982
  1103
SDL_Convert_U16MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1104
{
icculus@1982
  1105
    int i;
icculus@1982
  1106
    const Uint16 *src;
icculus@1982
  1107
    float *dst;
icculus@1982
  1108
icculus@1982
  1109
#ifdef DEBUG_CONVERT
icculus@1982
  1110
    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_F32LSB.\n");
icculus@1982
  1111
#endif
icculus@1982
  1112
icculus@1982
  1113
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
  1114
    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
  1115
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
  1116
        const float val = (((float) SDL_SwapBE16(*src)) * DIVBY65535);
icculus@1982
  1117
        *dst = SDL_SwapFloatLE(val);
icculus@1982
  1118
    }
icculus@1982
  1119
icculus@1982
  1120
    cvt->len_cvt *= 2;
icculus@1982
  1121
    format = AUDIO_F32LSB;
icculus@1982
  1122
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1123
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1124
    }
icculus@1982
  1125
}
icculus@1982
  1126
icculus@1982
  1127
static void SDLCALL
icculus@1982
  1128
SDL_Convert_U16MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1129
{
icculus@1982
  1130
    int i;
icculus@1982
  1131
    const Uint16 *src;
icculus@1982
  1132
    float *dst;
icculus@1982
  1133
icculus@1982
  1134
#ifdef DEBUG_CONVERT
icculus@1982
  1135
    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_F32MSB.\n");
icculus@1982
  1136
#endif
icculus@1982
  1137
icculus@1982
  1138
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
  1139
    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
  1140
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
  1141
        const float val = (((float) SDL_SwapBE16(*src)) * DIVBY65535);
icculus@1982
  1142
        *dst = SDL_SwapFloatBE(val);
icculus@1982
  1143
    }
icculus@1982
  1144
icculus@1982
  1145
    cvt->len_cvt *= 2;
icculus@1982
  1146
    format = AUDIO_F32MSB;
icculus@1982
  1147
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1148
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1149
    }
icculus@1982
  1150
}
icculus@1982
  1151
icculus@1982
  1152
static void SDLCALL
icculus@1982
  1153
SDL_Convert_S16MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1154
{
icculus@1982
  1155
    int i;
icculus@1982
  1156
    const Uint16 *src;
icculus@1982
  1157
    Uint8 *dst;
icculus@1982
  1158
icculus@1982
  1159
#ifdef DEBUG_CONVERT
icculus@1982
  1160
    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U8.\n");
icculus@1982
  1161
#endif
icculus@1982
  1162
icculus@1982
  1163
    src = (const Uint16 *) cvt->buf;
icculus@1982
  1164
    dst = (Uint8 *) cvt->buf;
icculus@1982
  1165
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
  1166
        const Uint8 val = ((Uint8) (((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000) >> 8));
icculus@1982
  1167
        *dst = val;
icculus@1982
  1168
    }
icculus@1982
  1169
icculus@1982
  1170
    cvt->len_cvt /= 2;
icculus@1982
  1171
    format = AUDIO_U8;
icculus@1982
  1172
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1173
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1174
    }
icculus@1982
  1175
}
icculus@1982
  1176
icculus@1982
  1177
static void SDLCALL
icculus@1982
  1178
SDL_Convert_S16MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1179
{
icculus@1982
  1180
    int i;
icculus@1982
  1181
    const Uint16 *src;
icculus@1982
  1182
    Sint8 *dst;
icculus@1982
  1183
icculus@1982
  1184
#ifdef DEBUG_CONVERT
icculus@1982
  1185
    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S8.\n");
icculus@1982
  1186
#endif
icculus@1982
  1187
icculus@1982
  1188
    src = (const Uint16 *) cvt->buf;
icculus@1982
  1189
    dst = (Sint8 *) cvt->buf;
icculus@1982
  1190
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
  1191
        const Sint8 val = ((Sint8) (((Sint16) SDL_SwapBE16(*src)) >> 8));
icculus@1982
  1192
        *dst = ((Sint8) val);
icculus@1982
  1193
    }
icculus@1982
  1194
icculus@1982
  1195
    cvt->len_cvt /= 2;
icculus@1982
  1196
    format = AUDIO_S8;
icculus@1982
  1197
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1198
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1199
    }
icculus@1982
  1200
}
icculus@1982
  1201
icculus@1982
  1202
static void SDLCALL
icculus@1982
  1203
SDL_Convert_S16MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1204
{
icculus@1982
  1205
    int i;
icculus@1982
  1206
    const Uint16 *src;
icculus@1982
  1207
    Uint16 *dst;
icculus@1982
  1208
icculus@1982
  1209
#ifdef DEBUG_CONVERT
icculus@1982
  1210
    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U16LSB.\n");
icculus@1982
  1211
#endif
icculus@1982
  1212
icculus@1982
  1213
    src = (const Uint16 *) cvt->buf;
icculus@1982
  1214
    dst = (Uint16 *) cvt->buf;
icculus@1982
  1215
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
  1216
        const Uint16 val = ((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000);
icculus@1982
  1217
        *dst = SDL_SwapLE16(val);
icculus@1982
  1218
    }
icculus@1982
  1219
icculus@1982
  1220
    format = AUDIO_U16LSB;
icculus@1982
  1221
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1222
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1223
    }
icculus@1982
  1224
}
icculus@1982
  1225
icculus@1982
  1226
static void SDLCALL
icculus@1982
  1227
SDL_Convert_S16MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1228
{
icculus@1982
  1229
    int i;
icculus@1982
  1230
    const Uint16 *src;
icculus@1982
  1231
    Sint16 *dst;
icculus@1982
  1232
icculus@1982
  1233
#ifdef DEBUG_CONVERT
icculus@1982
  1234
    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S16LSB.\n");
icculus@1982
  1235
#endif
icculus@1982
  1236
icculus@1982
  1237
    src = (const Uint16 *) cvt->buf;
icculus@1982
  1238
    dst = (Sint16 *) cvt->buf;
icculus@1982
  1239
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
  1240
        const Sint16 val = ((Sint16) SDL_SwapBE16(*src));
icculus@1982
  1241
        *dst = ((Sint16) SDL_SwapLE16(val));
icculus@1982
  1242
    }
icculus@1982
  1243
icculus@1982
  1244
    format = AUDIO_S16LSB;
icculus@1982
  1245
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1246
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1247
    }
icculus@1982
  1248
}
icculus@1982
  1249
icculus@1982
  1250
static void SDLCALL
icculus@1982
  1251
SDL_Convert_S16MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1252
{
icculus@1982
  1253
    int i;
icculus@1982
  1254
    const Uint16 *src;
icculus@1982
  1255
    Uint16 *dst;
icculus@1982
  1256
icculus@1982
  1257
#ifdef DEBUG_CONVERT
icculus@1982
  1258
    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U16MSB.\n");
icculus@1982
  1259
#endif
icculus@1982
  1260
icculus@1982
  1261
    src = (const Uint16 *) cvt->buf;
icculus@1982
  1262
    dst = (Uint16 *) cvt->buf;
icculus@1982
  1263
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
icculus@1982
  1264
        const Uint16 val = ((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000);
icculus@1982
  1265
        *dst = SDL_SwapBE16(val);
icculus@1982
  1266
    }
icculus@1982
  1267
icculus@1982
  1268
    format = AUDIO_U16MSB;
icculus@1982
  1269
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1270
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1271
    }
icculus@1982
  1272
}
icculus@1982
  1273
icculus@1982
  1274
static void SDLCALL
icculus@1982
  1275
SDL_Convert_S16MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1276
{
icculus@1982
  1277
    int i;
icculus@1982
  1278
    const Uint16 *src;
icculus@1982
  1279
    Sint32 *dst;
icculus@1982
  1280
icculus@1982
  1281
#ifdef DEBUG_CONVERT
icculus@1982
  1282
    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S32LSB.\n");
icculus@1982
  1283
#endif
icculus@1982
  1284
icculus@1982
  1285
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
  1286
    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
  1287
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
  1288
        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapBE16(*src))) << 16);
icculus@1982
  1289
        *dst = ((Sint32) SDL_SwapLE32(val));
icculus@1982
  1290
    }
icculus@1982
  1291
icculus@1982
  1292
    cvt->len_cvt *= 2;
icculus@1982
  1293
    format = AUDIO_S32LSB;
icculus@1982
  1294
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1295
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1296
    }
icculus@1982
  1297
}
icculus@1982
  1298
icculus@1982
  1299
static void SDLCALL
icculus@1982
  1300
SDL_Convert_S16MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1301
{
icculus@1982
  1302
    int i;
icculus@1982
  1303
    const Uint16 *src;
icculus@1982
  1304
    Sint32 *dst;
icculus@1982
  1305
icculus@1982
  1306
#ifdef DEBUG_CONVERT
icculus@1982
  1307
    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S32MSB.\n");
icculus@1982
  1308
#endif
icculus@1982
  1309
icculus@1982
  1310
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
  1311
    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
  1312
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
  1313
        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapBE16(*src))) << 16);
icculus@1982
  1314
        *dst = ((Sint32) SDL_SwapBE32(val));
icculus@1982
  1315
    }
icculus@1982
  1316
icculus@1982
  1317
    cvt->len_cvt *= 2;
icculus@1982
  1318
    format = AUDIO_S32MSB;
icculus@1982
  1319
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1320
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1321
    }
icculus@1982
  1322
}
icculus@1982
  1323
icculus@1982
  1324
static void SDLCALL
icculus@1982
  1325
SDL_Convert_S16MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1326
{
icculus@1982
  1327
    int i;
icculus@1982
  1328
    const Uint16 *src;
icculus@1982
  1329
    float *dst;
icculus@1982
  1330
icculus@1982
  1331
#ifdef DEBUG_CONVERT
icculus@1982
  1332
    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_F32LSB.\n");
icculus@1982
  1333
#endif
icculus@1982
  1334
icculus@1982
  1335
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
  1336
    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
  1337
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
  1338
        const float val = (((float) ((Sint16) SDL_SwapBE16(*src))) * DIVBY32767);
icculus@1982
  1339
        *dst = SDL_SwapFloatLE(val);
icculus@1982
  1340
    }
icculus@1982
  1341
icculus@1982
  1342
    cvt->len_cvt *= 2;
icculus@1982
  1343
    format = AUDIO_F32LSB;
icculus@1982
  1344
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1345
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1346
    }
icculus@1982
  1347
}
icculus@1982
  1348
icculus@1982
  1349
static void SDLCALL
icculus@1982
  1350
SDL_Convert_S16MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1351
{
icculus@1982
  1352
    int i;
icculus@1982
  1353
    const Uint16 *src;
icculus@1982
  1354
    float *dst;
icculus@1982
  1355
icculus@1982
  1356
#ifdef DEBUG_CONVERT
icculus@1982
  1357
    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_F32MSB.\n");
icculus@1982
  1358
#endif
icculus@1982
  1359
icculus@1982
  1360
    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
icculus@1982
  1361
    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
icculus@1982
  1362
    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
icculus@1982
  1363
        const float val = (((float) ((Sint16) SDL_SwapBE16(*src))) * DIVBY32767);
icculus@1982
  1364
        *dst = SDL_SwapFloatBE(val);
icculus@1982
  1365
    }
icculus@1982
  1366
icculus@1982
  1367
    cvt->len_cvt *= 2;
icculus@1982
  1368
    format = AUDIO_F32MSB;
icculus@1982
  1369
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1370
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1371
    }
icculus@1982
  1372
}
icculus@1982
  1373
icculus@1982
  1374
static void SDLCALL
icculus@1982
  1375
SDL_Convert_S32LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1376
{
icculus@1982
  1377
    int i;
icculus@1982
  1378
    const Uint32 *src;
icculus@1982
  1379
    Uint8 *dst;
icculus@1982
  1380
icculus@1982
  1381
#ifdef DEBUG_CONVERT
icculus@1982
  1382
    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U8.\n");
icculus@1982
  1383
#endif
icculus@1982
  1384
icculus@1982
  1385
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1386
    dst = (Uint8 *) cvt->buf;
icculus@1982
  1387
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1388
        const Uint8 val = ((Uint8) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 24));
icculus@1982
  1389
        *dst = val;
icculus@1982
  1390
    }
icculus@1982
  1391
icculus@1982
  1392
    cvt->len_cvt /= 4;
icculus@1982
  1393
    format = AUDIO_U8;
icculus@1982
  1394
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1395
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1396
    }
icculus@1982
  1397
}
icculus@1982
  1398
icculus@1982
  1399
static void SDLCALL
icculus@1982
  1400
SDL_Convert_S32LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1401
{
icculus@1982
  1402
    int i;
icculus@1982
  1403
    const Uint32 *src;
icculus@1982
  1404
    Sint8 *dst;
icculus@1982
  1405
icculus@1982
  1406
#ifdef DEBUG_CONVERT
icculus@1982
  1407
    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S8.\n");
icculus@1982
  1408
#endif
icculus@1982
  1409
icculus@1982
  1410
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1411
    dst = (Sint8 *) cvt->buf;
icculus@1982
  1412
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1413
        const Sint8 val = ((Sint8) (((Sint32) SDL_SwapLE32(*src)) >> 24));
icculus@1982
  1414
        *dst = ((Sint8) val);
icculus@1982
  1415
    }
icculus@1982
  1416
icculus@1982
  1417
    cvt->len_cvt /= 4;
icculus@1982
  1418
    format = AUDIO_S8;
icculus@1982
  1419
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1420
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1421
    }
icculus@1982
  1422
}
icculus@1982
  1423
icculus@1982
  1424
static void SDLCALL
icculus@1982
  1425
SDL_Convert_S32LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1426
{
icculus@1982
  1427
    int i;
icculus@1982
  1428
    const Uint32 *src;
icculus@1982
  1429
    Uint16 *dst;
icculus@1982
  1430
icculus@1982
  1431
#ifdef DEBUG_CONVERT
icculus@1982
  1432
    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U16LSB.\n");
icculus@1982
  1433
#endif
icculus@1982
  1434
icculus@1982
  1435
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1436
    dst = (Uint16 *) cvt->buf;
icculus@1982
  1437
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1438
        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 16));
icculus@1982
  1439
        *dst = SDL_SwapLE16(val);
icculus@1982
  1440
    }
icculus@1982
  1441
icculus@1982
  1442
    cvt->len_cvt /= 2;
icculus@1982
  1443
    format = AUDIO_U16LSB;
icculus@1982
  1444
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1445
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1446
    }
icculus@1982
  1447
}
icculus@1982
  1448
icculus@1982
  1449
static void SDLCALL
icculus@1982
  1450
SDL_Convert_S32LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1451
{
icculus@1982
  1452
    int i;
icculus@1982
  1453
    const Uint32 *src;
icculus@1982
  1454
    Sint16 *dst;
icculus@1982
  1455
icculus@1982
  1456
#ifdef DEBUG_CONVERT
icculus@1982
  1457
    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S16LSB.\n");
icculus@1982
  1458
#endif
icculus@1982
  1459
icculus@1982
  1460
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1461
    dst = (Sint16 *) cvt->buf;
icculus@1982
  1462
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1463
        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapLE32(*src)) >> 16));
icculus@1982
  1464
        *dst = ((Sint16) SDL_SwapLE16(val));
icculus@1982
  1465
    }
icculus@1982
  1466
icculus@1982
  1467
    cvt->len_cvt /= 2;
icculus@1982
  1468
    format = AUDIO_S16LSB;
icculus@1982
  1469
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1470
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1471
    }
icculus@1982
  1472
}
icculus@1982
  1473
icculus@1982
  1474
static void SDLCALL
icculus@1982
  1475
SDL_Convert_S32LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1476
{
icculus@1982
  1477
    int i;
icculus@1982
  1478
    const Uint32 *src;
icculus@1982
  1479
    Uint16 *dst;
icculus@1982
  1480
icculus@1982
  1481
#ifdef DEBUG_CONVERT
icculus@1982
  1482
    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U16MSB.\n");
icculus@1982
  1483
#endif
icculus@1982
  1484
icculus@1982
  1485
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1486
    dst = (Uint16 *) cvt->buf;
icculus@1982
  1487
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1488
        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 16));
icculus@1982
  1489
        *dst = SDL_SwapBE16(val);
icculus@1982
  1490
    }
icculus@1982
  1491
icculus@1982
  1492
    cvt->len_cvt /= 2;
icculus@1982
  1493
    format = AUDIO_U16MSB;
icculus@1982
  1494
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1495
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1496
    }
icculus@1982
  1497
}
icculus@1982
  1498
icculus@1982
  1499
static void SDLCALL
icculus@1982
  1500
SDL_Convert_S32LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1501
{
icculus@1982
  1502
    int i;
icculus@1982
  1503
    const Uint32 *src;
icculus@1982
  1504
    Sint16 *dst;
icculus@1982
  1505
icculus@1982
  1506
#ifdef DEBUG_CONVERT
icculus@1982
  1507
    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S16MSB.\n");
icculus@1982
  1508
#endif
icculus@1982
  1509
icculus@1982
  1510
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1511
    dst = (Sint16 *) cvt->buf;
icculus@1982
  1512
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1513
        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapLE32(*src)) >> 16));
icculus@1982
  1514
        *dst = ((Sint16) SDL_SwapBE16(val));
icculus@1982
  1515
    }
icculus@1982
  1516
icculus@1982
  1517
    cvt->len_cvt /= 2;
icculus@1982
  1518
    format = AUDIO_S16MSB;
icculus@1982
  1519
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1520
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1521
    }
icculus@1982
  1522
}
icculus@1982
  1523
icculus@1982
  1524
static void SDLCALL
icculus@1982
  1525
SDL_Convert_S32LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1526
{
icculus@1982
  1527
    int i;
icculus@1982
  1528
    const Uint32 *src;
icculus@1982
  1529
    Sint32 *dst;
icculus@1982
  1530
icculus@1982
  1531
#ifdef DEBUG_CONVERT
icculus@1982
  1532
    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S32MSB.\n");
icculus@1982
  1533
#endif
icculus@1982
  1534
icculus@1982
  1535
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1536
    dst = (Sint32 *) cvt->buf;
icculus@1982
  1537
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1538
        const Sint32 val = ((Sint32) SDL_SwapLE32(*src));
icculus@1982
  1539
        *dst = ((Sint32) SDL_SwapBE32(val));
icculus@1982
  1540
    }
icculus@1982
  1541
icculus@1982
  1542
    format = AUDIO_S32MSB;
icculus@1982
  1543
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1544
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1545
    }
icculus@1982
  1546
}
icculus@1982
  1547
icculus@1982
  1548
static void SDLCALL
icculus@1982
  1549
SDL_Convert_S32LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1550
{
icculus@1982
  1551
    int i;
icculus@1982
  1552
    const Uint32 *src;
icculus@1982
  1553
    float *dst;
icculus@1982
  1554
icculus@1982
  1555
#ifdef DEBUG_CONVERT
icculus@1982
  1556
    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_F32LSB.\n");
icculus@1982
  1557
#endif
icculus@1982
  1558
icculus@1982
  1559
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1560
    dst = (float *) cvt->buf;
icculus@1982
  1561
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1562
        const float val = (((float) ((Sint32) SDL_SwapLE32(*src))) * DIVBY2147483647);
icculus@1982
  1563
        *dst = SDL_SwapFloatLE(val);
icculus@1982
  1564
    }
icculus@1982
  1565
icculus@1982
  1566
    format = AUDIO_F32LSB;
icculus@1982
  1567
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1568
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1569
    }
icculus@1982
  1570
}
icculus@1982
  1571
icculus@1982
  1572
static void SDLCALL
icculus@1982
  1573
SDL_Convert_S32LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1574
{
icculus@1982
  1575
    int i;
icculus@1982
  1576
    const Uint32 *src;
icculus@1982
  1577
    float *dst;
icculus@1982
  1578
icculus@1982
  1579
#ifdef DEBUG_CONVERT
icculus@1982
  1580
    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_F32MSB.\n");
icculus@1982
  1581
#endif
icculus@1982
  1582
icculus@1982
  1583
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1584
    dst = (float *) cvt->buf;
icculus@1982
  1585
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1586
        const float val = (((float) ((Sint32) SDL_SwapLE32(*src))) * DIVBY2147483647);
icculus@1982
  1587
        *dst = SDL_SwapFloatBE(val);
icculus@1982
  1588
    }
icculus@1982
  1589
icculus@1982
  1590
    format = AUDIO_F32MSB;
icculus@1982
  1591
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1592
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1593
    }
icculus@1982
  1594
}
icculus@1982
  1595
icculus@1982
  1596
static void SDLCALL
icculus@1982
  1597
SDL_Convert_S32MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1598
{
icculus@1982
  1599
    int i;
icculus@1982
  1600
    const Uint32 *src;
icculus@1982
  1601
    Uint8 *dst;
icculus@1982
  1602
icculus@1982
  1603
#ifdef DEBUG_CONVERT
icculus@1982
  1604
    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U8.\n");
icculus@1982
  1605
#endif
icculus@1982
  1606
icculus@1982
  1607
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1608
    dst = (Uint8 *) cvt->buf;
icculus@1982
  1609
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1610
        const Uint8 val = ((Uint8) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 24));
icculus@1982
  1611
        *dst = val;
icculus@1982
  1612
    }
icculus@1982
  1613
icculus@1982
  1614
    cvt->len_cvt /= 4;
icculus@1982
  1615
    format = AUDIO_U8;
icculus@1982
  1616
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1617
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1618
    }
icculus@1982
  1619
}
icculus@1982
  1620
icculus@1982
  1621
static void SDLCALL
icculus@1982
  1622
SDL_Convert_S32MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1623
{
icculus@1982
  1624
    int i;
icculus@1982
  1625
    const Uint32 *src;
icculus@1982
  1626
    Sint8 *dst;
icculus@1982
  1627
icculus@1982
  1628
#ifdef DEBUG_CONVERT
icculus@1982
  1629
    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S8.\n");
icculus@1982
  1630
#endif
icculus@1982
  1631
icculus@1982
  1632
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1633
    dst = (Sint8 *) cvt->buf;
icculus@1982
  1634
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1635
        const Sint8 val = ((Sint8) (((Sint32) SDL_SwapBE32(*src)) >> 24));
icculus@1982
  1636
        *dst = ((Sint8) val);
icculus@1982
  1637
    }
icculus@1982
  1638
icculus@1982
  1639
    cvt->len_cvt /= 4;
icculus@1982
  1640
    format = AUDIO_S8;
icculus@1982
  1641
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1642
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1643
    }
icculus@1982
  1644
}
icculus@1982
  1645
icculus@1982
  1646
static void SDLCALL
icculus@1982
  1647
SDL_Convert_S32MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1648
{
icculus@1982
  1649
    int i;
icculus@1982
  1650
    const Uint32 *src;
icculus@1982
  1651
    Uint16 *dst;
icculus@1982
  1652
icculus@1982
  1653
#ifdef DEBUG_CONVERT
icculus@1982
  1654
    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U16LSB.\n");
icculus@1982
  1655
#endif
icculus@1982
  1656
icculus@1982
  1657
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1658
    dst = (Uint16 *) cvt->buf;
icculus@1982
  1659
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1660
        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 16));
icculus@1982
  1661
        *dst = SDL_SwapLE16(val);
icculus@1982
  1662
    }
icculus@1982
  1663
icculus@1982
  1664
    cvt->len_cvt /= 2;
icculus@1982
  1665
    format = AUDIO_U16LSB;
icculus@1982
  1666
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1667
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1668
    }
icculus@1982
  1669
}
icculus@1982
  1670
icculus@1982
  1671
static void SDLCALL
icculus@1982
  1672
SDL_Convert_S32MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1673
{
icculus@1982
  1674
    int i;
icculus@1982
  1675
    const Uint32 *src;
icculus@1982
  1676
    Sint16 *dst;
icculus@1982
  1677
icculus@1982
  1678
#ifdef DEBUG_CONVERT
icculus@1982
  1679
    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S16LSB.\n");
icculus@1982
  1680
#endif
icculus@1982
  1681
icculus@1982
  1682
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1683
    dst = (Sint16 *) cvt->buf;
icculus@1982
  1684
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1685
        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapBE32(*src)) >> 16));
icculus@1982
  1686
        *dst = ((Sint16) SDL_SwapLE16(val));
icculus@1982
  1687
    }
icculus@1982
  1688
icculus@1982
  1689
    cvt->len_cvt /= 2;
icculus@1982
  1690
    format = AUDIO_S16LSB;
icculus@1982
  1691
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1692
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1693
    }
icculus@1982
  1694
}
icculus@1982
  1695
icculus@1982
  1696
static void SDLCALL
icculus@1982
  1697
SDL_Convert_S32MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1698
{
icculus@1982
  1699
    int i;
icculus@1982
  1700
    const Uint32 *src;
icculus@1982
  1701
    Uint16 *dst;
icculus@1982
  1702
icculus@1982
  1703
#ifdef DEBUG_CONVERT
icculus@1982
  1704
    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U16MSB.\n");
icculus@1982
  1705
#endif
icculus@1982
  1706
icculus@1982
  1707
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1708
    dst = (Uint16 *) cvt->buf;
icculus@1982
  1709
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1710
        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 16));
icculus@1982
  1711
        *dst = SDL_SwapBE16(val);
icculus@1982
  1712
    }
icculus@1982
  1713
icculus@1982
  1714
    cvt->len_cvt /= 2;
icculus@1982
  1715
    format = AUDIO_U16MSB;
icculus@1982
  1716
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1717
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1718
    }
icculus@1982
  1719
}
icculus@1982
  1720
icculus@1982
  1721
static void SDLCALL
icculus@1982
  1722
SDL_Convert_S32MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1723
{
icculus@1982
  1724
    int i;
icculus@1982
  1725
    const Uint32 *src;
icculus@1982
  1726
    Sint16 *dst;
icculus@1982
  1727
icculus@1982
  1728
#ifdef DEBUG_CONVERT
icculus@1982
  1729
    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S16MSB.\n");
icculus@1982
  1730
#endif
icculus@1982
  1731
icculus@1982
  1732
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1733
    dst = (Sint16 *) cvt->buf;
icculus@1982
  1734
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1735
        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapBE32(*src)) >> 16));
icculus@1982
  1736
        *dst = ((Sint16) SDL_SwapBE16(val));
icculus@1982
  1737
    }
icculus@1982
  1738
icculus@1982
  1739
    cvt->len_cvt /= 2;
icculus@1982
  1740
    format = AUDIO_S16MSB;
icculus@1982
  1741
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1742
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1743
    }
icculus@1982
  1744
}
icculus@1982
  1745
icculus@1982
  1746
static void SDLCALL
icculus@1982
  1747
SDL_Convert_S32MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1748
{
icculus@1982
  1749
    int i;
icculus@1982
  1750
    const Uint32 *src;
icculus@1982
  1751
    Sint32 *dst;
icculus@1982
  1752
icculus@1982
  1753
#ifdef DEBUG_CONVERT
icculus@1982
  1754
    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S32LSB.\n");
icculus@1982
  1755
#endif
icculus@1982
  1756
icculus@1982
  1757
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1758
    dst = (Sint32 *) cvt->buf;
icculus@1982
  1759
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1760
        const Sint32 val = ((Sint32) SDL_SwapBE32(*src));
icculus@1982
  1761
        *dst = ((Sint32) SDL_SwapLE32(val));
icculus@1982
  1762
    }
icculus@1982
  1763
icculus@1982
  1764
    format = AUDIO_S32LSB;
icculus@1982
  1765
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1766
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1767
    }
icculus@1982
  1768
}
icculus@1982
  1769
icculus@1982
  1770
static void SDLCALL
icculus@1982
  1771
SDL_Convert_S32MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1772
{
icculus@1982
  1773
    int i;
icculus@1982
  1774
    const Uint32 *src;
icculus@1982
  1775
    float *dst;
icculus@1982
  1776
icculus@1982
  1777
#ifdef DEBUG_CONVERT
icculus@1982
  1778
    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_F32LSB.\n");
icculus@1982
  1779
#endif
icculus@1982
  1780
icculus@1982
  1781
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1782
    dst = (float *) cvt->buf;
icculus@1982
  1783
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1784
        const float val = (((float) ((Sint32) SDL_SwapBE32(*src))) * DIVBY2147483647);
icculus@1982
  1785
        *dst = SDL_SwapFloatLE(val);
icculus@1982
  1786
    }
icculus@1982
  1787
icculus@1982
  1788
    format = AUDIO_F32LSB;
icculus@1982
  1789
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1790
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1791
    }
icculus@1982
  1792
}
icculus@1982
  1793
icculus@1982
  1794
static void SDLCALL
icculus@1982
  1795
SDL_Convert_S32MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1796
{
icculus@1982
  1797
    int i;
icculus@1982
  1798
    const Uint32 *src;
icculus@1982
  1799
    float *dst;
icculus@1982
  1800
icculus@1982
  1801
#ifdef DEBUG_CONVERT
icculus@1982
  1802
    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_F32MSB.\n");
icculus@1982
  1803
#endif
icculus@1982
  1804
icculus@1982
  1805
    src = (const Uint32 *) cvt->buf;
icculus@1982
  1806
    dst = (float *) cvt->buf;
icculus@1982
  1807
    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
icculus@1982
  1808
        const float val = (((float) ((Sint32) SDL_SwapBE32(*src))) * DIVBY2147483647);
icculus@1982
  1809
        *dst = SDL_SwapFloatBE(val);
icculus@1982
  1810
    }
icculus@1982
  1811
icculus@1982
  1812
    format = AUDIO_F32MSB;
icculus@1982
  1813
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1814
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1815
    }
icculus@1982
  1816
}
icculus@1982
  1817
icculus@1982
  1818
static void SDLCALL
icculus@1982
  1819
SDL_Convert_F32LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1820
{
icculus@1982
  1821
    int i;
icculus@1982
  1822
    const float *src;
icculus@1982
  1823
    Uint8 *dst;
icculus@1982
  1824
icculus@1982
  1825
#ifdef DEBUG_CONVERT
icculus@1982
  1826
    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U8.\n");
icculus@1982
  1827
#endif
icculus@1982
  1828
icculus@1982
  1829
    src = (const float *) cvt->buf;
icculus@1982
  1830
    dst = (Uint8 *) cvt->buf;
icculus@1982
  1831
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  1832
        const Uint8 val = ((Uint8) (SDL_SwapFloatLE(*src) * 255.0f));
icculus@1982
  1833
        *dst = val;
icculus@1982
  1834
    }
icculus@1982
  1835
icculus@1982
  1836
    cvt->len_cvt /= 4;
icculus@1982
  1837
    format = AUDIO_U8;
icculus@1982
  1838
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1839
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1840
    }
icculus@1982
  1841
}
icculus@1982
  1842
icculus@1982
  1843
static void SDLCALL
icculus@1982
  1844
SDL_Convert_F32LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1845
{
icculus@1982
  1846
    int i;
icculus@1982
  1847
    const float *src;
icculus@1982
  1848
    Sint8 *dst;
icculus@1982
  1849
icculus@1982
  1850
#ifdef DEBUG_CONVERT
icculus@1982
  1851
    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S8.\n");
icculus@1982
  1852
#endif
icculus@1982
  1853
icculus@1982
  1854
    src = (const float *) cvt->buf;
icculus@1982
  1855
    dst = (Sint8 *) cvt->buf;
icculus@1982
  1856
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  1857
        const Sint8 val = ((Sint8) (SDL_SwapFloatLE(*src) * 127.0f));
icculus@1982
  1858
        *dst = ((Sint8) val);
icculus@1982
  1859
    }
icculus@1982
  1860
icculus@1982
  1861
    cvt->len_cvt /= 4;
icculus@1982
  1862
    format = AUDIO_S8;
icculus@1982
  1863
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1864
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1865
    }
icculus@1982
  1866
}
icculus@1982
  1867
icculus@1982
  1868
static void SDLCALL
icculus@1982
  1869
SDL_Convert_F32LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1870
{
icculus@1982
  1871
    int i;
icculus@1982
  1872
    const float *src;
icculus@1982
  1873
    Uint16 *dst;
icculus@1982
  1874
icculus@1982
  1875
#ifdef DEBUG_CONVERT
icculus@1982
  1876
    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U16LSB.\n");
icculus@1982
  1877
#endif
icculus@1982
  1878
icculus@1982
  1879
    src = (const float *) cvt->buf;
icculus@1982
  1880
    dst = (Uint16 *) cvt->buf;
icculus@1982
  1881
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  1882
        const Uint16 val = ((Uint16) (SDL_SwapFloatLE(*src) * 65535.0f));
icculus@1982
  1883
        *dst = SDL_SwapLE16(val);
icculus@1982
  1884
    }
icculus@1982
  1885
icculus@1982
  1886
    cvt->len_cvt /= 2;
icculus@1982
  1887
    format = AUDIO_U16LSB;
icculus@1982
  1888
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1889
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1890
    }
icculus@1982
  1891
}
icculus@1982
  1892
icculus@1982
  1893
static void SDLCALL
icculus@1982
  1894
SDL_Convert_F32LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1895
{
icculus@1982
  1896
    int i;
icculus@1982
  1897
    const float *src;
icculus@1982
  1898
    Sint16 *dst;
icculus@1982
  1899
icculus@1982
  1900
#ifdef DEBUG_CONVERT
icculus@1982
  1901
    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S16LSB.\n");
icculus@1982
  1902
#endif
icculus@1982
  1903
icculus@1982
  1904
    src = (const float *) cvt->buf;
icculus@1982
  1905
    dst = (Sint16 *) cvt->buf;
icculus@1982
  1906
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  1907
        const Sint16 val = ((Sint16) (SDL_SwapFloatLE(*src) * 32767.0f));
icculus@1982
  1908
        *dst = ((Sint16) SDL_SwapLE16(val));
icculus@1982
  1909
    }
icculus@1982
  1910
icculus@1982
  1911
    cvt->len_cvt /= 2;
icculus@1982
  1912
    format = AUDIO_S16LSB;
icculus@1982
  1913
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1914
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1915
    }
icculus@1982
  1916
}
icculus@1982
  1917
icculus@1982
  1918
static void SDLCALL
icculus@1982
  1919
SDL_Convert_F32LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1920
{
icculus@1982
  1921
    int i;
icculus@1982
  1922
    const float *src;
icculus@1982
  1923
    Uint16 *dst;
icculus@1982
  1924
icculus@1982
  1925
#ifdef DEBUG_CONVERT
icculus@1982
  1926
    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U16MSB.\n");
icculus@1982
  1927
#endif
icculus@1982
  1928
icculus@1982
  1929
    src = (const float *) cvt->buf;
icculus@1982
  1930
    dst = (Uint16 *) cvt->buf;
icculus@1982
  1931
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  1932
        const Uint16 val = ((Uint16) (SDL_SwapFloatLE(*src) * 65535.0f));
icculus@1982
  1933
        *dst = SDL_SwapBE16(val);
icculus@1982
  1934
    }
icculus@1982
  1935
icculus@1982
  1936
    cvt->len_cvt /= 2;
icculus@1982
  1937
    format = AUDIO_U16MSB;
icculus@1982
  1938
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1939
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1940
    }
icculus@1982
  1941
}
icculus@1982
  1942
icculus@1982
  1943
static void SDLCALL
icculus@1982
  1944
SDL_Convert_F32LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1945
{
icculus@1982
  1946
    int i;
icculus@1982
  1947
    const float *src;
icculus@1982
  1948
    Sint16 *dst;
icculus@1982
  1949
icculus@1982
  1950
#ifdef DEBUG_CONVERT
icculus@1982
  1951
    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S16MSB.\n");
icculus@1982
  1952
#endif
icculus@1982
  1953
icculus@1982
  1954
    src = (const float *) cvt->buf;
icculus@1982
  1955
    dst = (Sint16 *) cvt->buf;
icculus@1982
  1956
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  1957
        const Sint16 val = ((Sint16) (SDL_SwapFloatLE(*src) * 32767.0f));
icculus@1982
  1958
        *dst = ((Sint16) SDL_SwapBE16(val));
icculus@1982
  1959
    }
icculus@1982
  1960
icculus@1982
  1961
    cvt->len_cvt /= 2;
icculus@1982
  1962
    format = AUDIO_S16MSB;
icculus@1982
  1963
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1964
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1965
    }
icculus@1982
  1966
}
icculus@1982
  1967
icculus@1982
  1968
static void SDLCALL
icculus@1982
  1969
SDL_Convert_F32LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1970
{
icculus@1982
  1971
    int i;
icculus@1982
  1972
    const float *src;
icculus@1982
  1973
    Sint32 *dst;
icculus@1982
  1974
icculus@1982
  1975
#ifdef DEBUG_CONVERT
icculus@1982
  1976
    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S32LSB.\n");
icculus@1982
  1977
#endif
icculus@1982
  1978
icculus@1982
  1979
    src = (const float *) cvt->buf;
icculus@1982
  1980
    dst = (Sint32 *) cvt->buf;
icculus@1982
  1981
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  1982
        const Sint32 val = ((Sint32) (SDL_SwapFloatLE(*src) * 2147483647.0));
icculus@1982
  1983
        *dst = ((Sint32) SDL_SwapLE32(val));
icculus@1982
  1984
    }
icculus@1982
  1985
icculus@1982
  1986
    format = AUDIO_S32LSB;
icculus@1982
  1987
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  1988
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  1989
    }
icculus@1982
  1990
}
icculus@1982
  1991
icculus@1982
  1992
static void SDLCALL
icculus@1982
  1993
SDL_Convert_F32LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  1994
{
icculus@1982
  1995
    int i;
icculus@1982
  1996
    const float *src;
icculus@1982
  1997
    Sint32 *dst;
icculus@1982
  1998
icculus@1982
  1999
#ifdef DEBUG_CONVERT
icculus@1982
  2000
    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S32MSB.\n");
icculus@1982
  2001
#endif
icculus@1982
  2002
icculus@1982
  2003
    src = (const float *) cvt->buf;
icculus@1982
  2004
    dst = (Sint32 *) cvt->buf;
icculus@1982
  2005
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  2006
        const Sint32 val = ((Sint32) (SDL_SwapFloatLE(*src) * 2147483647.0));
icculus@1982
  2007
        *dst = ((Sint32) SDL_SwapBE32(val));
icculus@1982
  2008
    }
icculus@1982
  2009
icculus@1982
  2010
    format = AUDIO_S32MSB;
icculus@1982
  2011
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  2012
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  2013
    }
icculus@1982
  2014
}
icculus@1982
  2015
icculus@1982
  2016
static void SDLCALL
icculus@1982
  2017
SDL_Convert_F32LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  2018
{
icculus@1982
  2019
    int i;
icculus@1982
  2020
    const float *src;
icculus@1982
  2021
    float *dst;
icculus@1982
  2022
icculus@1982
  2023
#ifdef DEBUG_CONVERT
icculus@1982
  2024
    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_F32MSB.\n");
icculus@1982
  2025
#endif
icculus@1982
  2026
icculus@1982
  2027
    src = (const float *) cvt->buf;
icculus@1982
  2028
    dst = (float *) cvt->buf;
icculus@1982
  2029
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  2030
        const float val = SDL_SwapFloatLE(*src);
icculus@1982
  2031
        *dst = SDL_SwapFloatBE(val);
icculus@1982
  2032
    }
icculus@1982
  2033
icculus@1982
  2034
    format = AUDIO_F32MSB;
icculus@1982
  2035
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  2036
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  2037
    }
icculus@1982
  2038
}
icculus@1982
  2039
icculus@1982
  2040
static void SDLCALL
icculus@1982
  2041
SDL_Convert_F32MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  2042
{
icculus@1982
  2043
    int i;
icculus@1982
  2044
    const float *src;
icculus@1982
  2045
    Uint8 *dst;
icculus@1982
  2046
icculus@1982
  2047
#ifdef DEBUG_CONVERT
icculus@1982
  2048
    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U8.\n");
icculus@1982
  2049
#endif
icculus@1982
  2050
icculus@1982
  2051
    src = (const float *) cvt->buf;
icculus@1982
  2052
    dst = (Uint8 *) cvt->buf;
icculus@1982
  2053
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  2054
        const Uint8 val = ((Uint8) (SDL_SwapFloatBE(*src) * 255.0f));
icculus@1982
  2055
        *dst = val;
icculus@1982
  2056
    }
icculus@1982
  2057
icculus@1982
  2058
    cvt->len_cvt /= 4;
icculus@1982
  2059
    format = AUDIO_U8;
icculus@1982
  2060
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  2061
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  2062
    }
icculus@1982
  2063
}
icculus@1982
  2064
icculus@1982
  2065
static void SDLCALL
icculus@1982
  2066
SDL_Convert_F32MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  2067
{
icculus@1982
  2068
    int i;
icculus@1982
  2069
    const float *src;
icculus@1982
  2070
    Sint8 *dst;
icculus@1982
  2071
icculus@1982
  2072
#ifdef DEBUG_CONVERT
icculus@1982
  2073
    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S8.\n");
icculus@1982
  2074
#endif
icculus@1982
  2075
icculus@1982
  2076
    src = (const float *) cvt->buf;
icculus@1982
  2077
    dst = (Sint8 *) cvt->buf;
icculus@1982
  2078
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  2079
        const Sint8 val = ((Sint8) (SDL_SwapFloatBE(*src) * 127.0f));
icculus@1982
  2080
        *dst = ((Sint8) val);
icculus@1982
  2081
    }
icculus@1982
  2082
icculus@1982
  2083
    cvt->len_cvt /= 4;
icculus@1982
  2084
    format = AUDIO_S8;
icculus@1982
  2085
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  2086
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  2087
    }
icculus@1982
  2088
}
icculus@1982
  2089
icculus@1982
  2090
static void SDLCALL
icculus@1982
  2091
SDL_Convert_F32MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  2092
{
icculus@1982
  2093
    int i;
icculus@1982
  2094
    const float *src;
icculus@1982
  2095
    Uint16 *dst;
icculus@1982
  2096
icculus@1982
  2097
#ifdef DEBUG_CONVERT
icculus@1982
  2098
    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U16LSB.\n");
icculus@1982
  2099
#endif
icculus@1982
  2100
icculus@1982
  2101
    src = (const float *) cvt->buf;
icculus@1982
  2102
    dst = (Uint16 *) cvt->buf;
icculus@1982
  2103
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  2104
        const Uint16 val = ((Uint16) (SDL_SwapFloatBE(*src) * 65535.0f));
icculus@1982
  2105
        *dst = SDL_SwapLE16(val);
icculus@1982
  2106
    }
icculus@1982
  2107
icculus@1982
  2108
    cvt->len_cvt /= 2;
icculus@1982
  2109
    format = AUDIO_U16LSB;
icculus@1982
  2110
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  2111
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  2112
    }
icculus@1982
  2113
}
icculus@1982
  2114
icculus@1982
  2115
static void SDLCALL
icculus@1982
  2116
SDL_Convert_F32MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  2117
{
icculus@1982
  2118
    int i;
icculus@1982
  2119
    const float *src;
icculus@1982
  2120
    Sint16 *dst;
icculus@1982
  2121
icculus@1982
  2122
#ifdef DEBUG_CONVERT
icculus@1982
  2123
    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S16LSB.\n");
icculus@1982
  2124
#endif
icculus@1982
  2125
icculus@1982
  2126
    src = (const float *) cvt->buf;
icculus@1982
  2127
    dst = (Sint16 *) cvt->buf;
icculus@1982
  2128
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  2129
        const Sint16 val = ((Sint16) (SDL_SwapFloatBE(*src) * 32767.0f));
icculus@1982
  2130
        *dst = ((Sint16) SDL_SwapLE16(val));
icculus@1982
  2131
    }
icculus@1982
  2132
icculus@1982
  2133
    cvt->len_cvt /= 2;
icculus@1982
  2134
    format = AUDIO_S16LSB;
icculus@1982
  2135
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  2136
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  2137
    }
icculus@1982
  2138
}
icculus@1982
  2139
icculus@1982
  2140
static void SDLCALL
icculus@1982
  2141
SDL_Convert_F32MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  2142
{
icculus@1982
  2143
    int i;
icculus@1982
  2144
    const float *src;
icculus@1982
  2145
    Uint16 *dst;
icculus@1982
  2146
icculus@1982
  2147
#ifdef DEBUG_CONVERT
icculus@1982
  2148
    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U16MSB.\n");
icculus@1982
  2149
#endif
icculus@1982
  2150
icculus@1982
  2151
    src = (const float *) cvt->buf;
icculus@1982
  2152
    dst = (Uint16 *) cvt->buf;
icculus@1982
  2153
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  2154
        const Uint16 val = ((Uint16) (SDL_SwapFloatBE(*src) * 65535.0f));
icculus@1982
  2155
        *dst = SDL_SwapBE16(val);
icculus@1982
  2156
    }
icculus@1982
  2157
icculus@1982
  2158
    cvt->len_cvt /= 2;
icculus@1982
  2159
    format = AUDIO_U16MSB;
icculus@1982
  2160
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  2161
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  2162
    }
icculus@1982
  2163
}
icculus@1982
  2164
icculus@1982
  2165
static void SDLCALL
icculus@1982
  2166
SDL_Convert_F32MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  2167
{
icculus@1982
  2168
    int i;
icculus@1982
  2169
    const float *src;
icculus@1982
  2170
    Sint16 *dst;
icculus@1982
  2171
icculus@1982
  2172
#ifdef DEBUG_CONVERT
icculus@1982
  2173
    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S16MSB.\n");
icculus@1982
  2174
#endif
icculus@1982
  2175
icculus@1982
  2176
    src = (const float *) cvt->buf;
icculus@1982
  2177
    dst = (Sint16 *) cvt->buf;
icculus@1982
  2178
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  2179
        const Sint16 val = ((Sint16) (SDL_SwapFloatBE(*src) * 32767.0f));
icculus@1982
  2180
        *dst = ((Sint16) SDL_SwapBE16(val));
icculus@1982
  2181
    }
icculus@1982
  2182
icculus@1982
  2183
    cvt->len_cvt /= 2;
icculus@1982
  2184
    format = AUDIO_S16MSB;
icculus@1982
  2185
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  2186
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  2187
    }
icculus@1982
  2188
}
icculus@1982
  2189
icculus@1982
  2190
static void SDLCALL
icculus@1982
  2191
SDL_Convert_F32MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  2192
{
icculus@1982
  2193
    int i;
icculus@1982
  2194
    const float *src;
icculus@1982
  2195
    Sint32 *dst;
icculus@1982
  2196
icculus@1982
  2197
#ifdef DEBUG_CONVERT
icculus@1982
  2198
    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S32LSB.\n");
icculus@1982
  2199
#endif
icculus@1982
  2200
icculus@1982
  2201
    src = (const float *) cvt->buf;
icculus@1982
  2202
    dst = (Sint32 *) cvt->buf;
icculus@1982
  2203
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  2204
        const Sint32 val = ((Sint32) (SDL_SwapFloatBE(*src) * 2147483647.0));
icculus@1982
  2205
        *dst = ((Sint32) SDL_SwapLE32(val));
icculus@1982
  2206
    }
icculus@1982
  2207
icculus@1982
  2208
    format = AUDIO_S32LSB;
icculus@1982
  2209
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  2210
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  2211
    }
icculus@1982
  2212
}
icculus@1982
  2213
icculus@1982
  2214
static void SDLCALL
icculus@1982
  2215
SDL_Convert_F32MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  2216
{
icculus@1982
  2217
    int i;
icculus@1982
  2218
    const float *src;
icculus@1982
  2219
    Sint32 *dst;
icculus@1982
  2220
icculus@1982
  2221
#ifdef DEBUG_CONVERT
icculus@1982
  2222
    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S32MSB.\n");
icculus@1982
  2223
#endif
icculus@1982
  2224
icculus@1982
  2225
    src = (const float *) cvt->buf;
icculus@1982
  2226
    dst = (Sint32 *) cvt->buf;
icculus@1982
  2227
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  2228
        const Sint32 val = ((Sint32) (SDL_SwapFloatBE(*src) * 2147483647.0));
icculus@1982
  2229
        *dst = ((Sint32) SDL_SwapBE32(val));
icculus@1982
  2230
    }
icculus@1982
  2231
icculus@1982
  2232
    format = AUDIO_S32MSB;
icculus@1982
  2233
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  2234
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  2235
    }
icculus@1982
  2236
}
icculus@1982
  2237
icculus@1982
  2238
static void SDLCALL
icculus@1982
  2239
SDL_Convert_F32MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
icculus@1982
  2240
{
icculus@1982
  2241
    int i;
icculus@1982
  2242
    const float *src;
icculus@1982
  2243
    float *dst;
icculus@1982
  2244
icculus@1982
  2245
#ifdef DEBUG_CONVERT
icculus@1982
  2246
    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_F32LSB.\n");
icculus@1982
  2247
#endif
icculus@1982
  2248
icculus@1982
  2249
    src = (const float *) cvt->buf;
icculus@1982
  2250
    dst = (float *) cvt->buf;
icculus@1982
  2251
    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
icculus@1982
  2252
        const float val = SDL_SwapFloatBE(*src);
icculus@1982
  2253
        *dst = SDL_SwapFloatLE(val);
icculus@1982
  2254
    }
icculus@1982
  2255
icculus@1982
  2256
    format = AUDIO_F32LSB;
icculus@1982
  2257
    if (cvt->filters[++cvt->filter_index]) {
icculus@1982
  2258
        cvt->filters[cvt->filter_index] (cvt, format);
icculus@1982
  2259
    }
icculus@1982
  2260
}
icculus@1982
  2261
icculus@1982
  2262
const SDL_AudioTypeFilters sdl_audio_type_filters[] =
icculus@1982
  2263
{
icculus@1982
  2264
    { AUDIO_U8, AUDIO_S8, SDL_Convert_U8_to_S8 },
icculus@1982
  2265
    { AUDIO_U8, AUDIO_U16LSB, SDL_Convert_U8_to_U16LSB },
icculus@1982
  2266
    { AUDIO_U8, AUDIO_S16LSB, SDL_Convert_U8_to_S16LSB },
icculus@1982
  2267
    { AUDIO_U8, AUDIO_U16MSB, SDL_Convert_U8_to_U16MSB },
icculus@1982
  2268
    { AUDIO_U8, AUDIO_S16MSB, SDL_Convert_U8_to_S16MSB },
icculus@1982
  2269
    { AUDIO_U8, AUDIO_S32LSB, SDL_Convert_U8_to_S32LSB },
icculus@1982
  2270
    { AUDIO_U8, AUDIO_S32MSB, SDL_Convert_U8_to_S32MSB },
icculus@1982
  2271
    { AUDIO_U8, AUDIO_F32LSB, SDL_Convert_U8_to_F32LSB },
icculus@1982
  2272
    { AUDIO_U8, AUDIO_F32MSB, SDL_Convert_U8_to_F32MSB },
icculus@1982
  2273
    { AUDIO_S8, AUDIO_U8, SDL_Convert_S8_to_U8 },
icculus@1982
  2274
    { AUDIO_S8, AUDIO_U16LSB, SDL_Convert_S8_to_U16LSB },
icculus@1982
  2275
    { AUDIO_S8, AUDIO_S16LSB, SDL_Convert_S8_to_S16LSB },
icculus@1982
  2276
    { AUDIO_S8, AUDIO_U16MSB, SDL_Convert_S8_to_U16MSB },
icculus@1982
  2277
    { AUDIO_S8, AUDIO_S16MSB, SDL_Convert_S8_to_S16MSB },
icculus@1982
  2278
    { AUDIO_S8, AUDIO_S32LSB, SDL_Convert_S8_to_S32LSB },
icculus@1982
  2279
    { AUDIO_S8, AUDIO_S32MSB, SDL_Convert_S8_to_S32MSB },
icculus@1982
  2280
    { AUDIO_S8, AUDIO_F32LSB, SDL_Convert_S8_to_F32LSB },
icculus@1982
  2281
    { AUDIO_S8, AUDIO_F32MSB, SDL_Convert_S8_to_F32MSB },
icculus@1982
  2282
    { AUDIO_U16LSB, AUDIO_U8, SDL_Convert_U16LSB_to_U8 },
icculus@1982
  2283
    { AUDIO_U16LSB, AUDIO_S8, SDL_Convert_U16LSB_to_S8 },
icculus@1982
  2284
    { AUDIO_U16LSB, AUDIO_S16LSB, SDL_Convert_U16LSB_to_S16LSB },
icculus@1982
  2285
    { AUDIO_U16LSB, AUDIO_U16MSB, SDL_Convert_U16LSB_to_U16MSB },
icculus@1982
  2286
    { AUDIO_U16LSB, AUDIO_S16MSB, SDL_Convert_U16LSB_to_S16MSB },
icculus@1982
  2287
    { AUDIO_U16LSB, AUDIO_S32LSB, SDL_Convert_U16LSB_to_S32LSB },
icculus@1982
  2288
    { AUDIO_U16LSB, AUDIO_S32MSB, SDL_Convert_U16LSB_to_S32MSB },
icculus@1982
  2289
    { AUDIO_U16LSB, AUDIO_F32LSB, SDL_Convert_U16LSB_to_F32LSB },
icculus@1982
  2290
    { AUDIO_U16LSB, AUDIO_F32MSB, SDL_Convert_U16LSB_to_F32MSB },
icculus@1982
  2291
    { AUDIO_S16LSB, AUDIO_U8, SDL_Convert_S16LSB_to_U8 },
icculus@1982
  2292
    { AUDIO_S16LSB, AUDIO_S8, SDL_Convert_S16LSB_to_S8 },
icculus@1982
  2293
    { AUDIO_S16LSB, AUDIO_U16LSB, SDL_Convert_S16LSB_to_U16LSB },
icculus@1982
  2294
    { AUDIO_S16LSB, AUDIO_U16MSB, SDL_Convert_S16LSB_to_U16MSB },
icculus@1982
  2295
    { AUDIO_S16LSB, AUDIO_S16MSB, SDL_Convert_S16LSB_to_S16MSB },
icculus@1982
  2296
    { AUDIO_S16LSB, AUDIO_S32LSB, SDL_Convert_S16LSB_to_S32LSB },
icculus@1982
  2297
    { AUDIO_S16LSB, AUDIO_S32MSB, SDL_Convert_S16LSB_to_S32MSB },
icculus@1982
  2298
    { AUDIO_S16LSB, AUDIO_F32LSB, SDL_Convert_S16LSB_to_F32LSB },
icculus@1982
  2299
    { AUDIO_S16LSB, AUDIO_F32MSB, SDL_Convert_S16LSB_to_F32MSB },
icculus@1982
  2300
    { AUDIO_U16MSB, AUDIO_U8, SDL_Convert_U16MSB_to_U8 },
icculus@1982
  2301
    { AUDIO_U16MSB, AUDIO_S8, SDL_Convert_U16MSB_to_S8 },
icculus@1982
  2302
    { AUDIO_U16MSB, AUDIO_U16LSB, SDL_Convert_U16MSB_to_U16LSB },
icculus@1982
  2303
    { AUDIO_U16MSB, AUDIO_S16LSB, SDL_Convert_U16MSB_to_S16LSB },
icculus@1982
  2304
    { AUDIO_U16MSB, AUDIO_S16MSB, SDL_Convert_U16MSB_to_S16MSB },
icculus@1982
  2305
    { AUDIO_U16MSB, AUDIO_S32LSB, SDL_Convert_U16MSB_to_S32LSB },
icculus@1982
  2306
    { AUDIO_U16MSB, AUDIO_S32MSB, SDL_Convert_U16MSB_to_S32MSB },
icculus@1982
  2307
    { AUDIO_U16MSB, AUDIO_F32LSB, SDL_Convert_U16MSB_to_F32LSB },
icculus@1982
  2308
    { AUDIO_U16MSB, AUDIO_F32MSB, SDL_Convert_U16MSB_to_F32MSB },
icculus@1982
  2309
    { AUDIO_S16MSB, AUDIO_U8, SDL_Convert_S16MSB_to_U8 },
icculus@1982
  2310
    { AUDIO_S16MSB, AUDIO_S8, SDL_Convert_S16MSB_to_S8 },
icculus@1982
  2311
    { AUDIO_S16MSB, AUDIO_U16LSB, SDL_Convert_S16MSB_to_U16LSB },
icculus@1982
  2312
    { AUDIO_S16MSB, AUDIO_S16LSB, SDL_Convert_S16MSB_to_S16LSB },
icculus@1982
  2313
    { AUDIO_S16MSB, AUDIO_U16MSB, SDL_Convert_S16MSB_to_U16MSB },
icculus@1982
  2314
    { AUDIO_S16MSB, AUDIO_S32LSB, SDL_Convert_S16MSB_to_S32LSB },
icculus@1982
  2315
    { AUDIO_S16MSB, AUDIO_S32MSB, SDL_Convert_S16MSB_to_S32MSB },
icculus@1982
  2316
    { AUDIO_S16MSB, AUDIO_F32LSB, SDL_Convert_S16MSB_to_F32LSB },
icculus@1982
  2317
    { AUDIO_S16MSB, AUDIO_F32MSB, SDL_Convert_S16MSB_to_F32MSB },
icculus@1982
  2318
    { AUDIO_S32LSB, AUDIO_U8, SDL_Convert_S32LSB_to_U8 },
icculus@1982
  2319
    { AUDIO_S32LSB, AUDIO_S8, SDL_Convert_S32LSB_to_S8 },
icculus@1982
  2320
    { AUDIO_S32LSB, AUDIO_U16LSB, SDL_Convert_S32LSB_to_U16LSB },
icculus@1982
  2321
    { AUDIO_S32LSB, AUDIO_S16LSB, SDL_Convert_S32LSB_to_S16LSB },
icculus@1982
  2322
    { AUDIO_S32LSB, AUDIO_U16MSB, SDL_Convert_S32LSB_to_U16MSB },
icculus@1982
  2323
    { AUDIO_S32LSB, AUDIO_S16MSB, SDL_Convert_S32LSB_to_S16MSB },
icculus@1982
  2324
    { AUDIO_S32LSB, AUDIO_S32MSB, SDL_Convert_S32LSB_to_S32MSB },
icculus@1982
  2325
    { AUDIO_S32LSB, AUDIO_F32LSB, SDL_Convert_S32LSB_to_F32LSB },
icculus@1982
  2326
    { AUDIO_S32LSB, AUDIO_F32MSB, SDL_Convert_S32LSB_to_F32MSB },
icculus@1982
  2327
    { AUDIO_S32MSB, AUDIO_U8, SDL_Convert_S32MSB_to_U8 },
icculus@1982
  2328
    { AUDIO_S32MSB, AUDIO_S8, SDL_Convert_S32MSB_to_S8 },
icculus@1982
  2329
    { AUDIO_S32MSB, AUDIO_U16LSB, SDL_Convert_S32MSB_to_U16LSB },
icculus@1982
  2330
    { AUDIO_S32MSB, AUDIO_S16LSB, SDL_Convert_S32MSB_to_S16LSB },
icculus@1982
  2331
    { AUDIO_S32MSB, AUDIO_U16MSB, SDL_Convert_S32MSB_to_U16MSB },
icculus@1982
  2332
    { AUDIO_S32MSB, AUDIO_S16MSB, SDL_Convert_S32MSB_to_S16MSB },
icculus@1982
  2333
    { AUDIO_S32MSB, AUDIO_S32LSB, SDL_Convert_S32MSB_to_S32LSB },
icculus@1982
  2334
    { AUDIO_S32MSB, AUDIO_F32LSB, SDL_Convert_S32MSB_to_F32LSB },
icculus@1982
  2335
    { AUDIO_S32MSB, AUDIO_F32MSB, SDL_Convert_S32MSB_to_F32MSB },
icculus@1982
  2336
    { AUDIO_F32LSB, AUDIO_U8, SDL_Convert_F32LSB_to_U8 },
icculus@1982
  2337
    { AUDIO_F32LSB, AUDIO_S8, SDL_Convert_F32LSB_to_S8 },
icculus@1982
  2338
    { AUDIO_F32LSB, AUDIO_U16LSB, SDL_Convert_F32LSB_to_U16LSB },
icculus@1982
  2339
    { AUDIO_F32LSB, AUDIO_S16LSB, SDL_Convert_F32LSB_to_S16LSB },
icculus@1982
  2340
    { AUDIO_F32LSB, AUDIO_U16MSB, SDL_Convert_F32LSB_to_U16MSB },
icculus@1982
  2341
    { AUDIO_F32LSB, AUDIO_S16MSB, SDL_Convert_F32LSB_to_S16MSB },
icculus@1982
  2342
    { AUDIO_F32LSB, AUDIO_S32LSB, SDL_Convert_F32LSB_to_S32LSB },
icculus@1982
  2343
    { AUDIO_F32LSB, AUDIO_S32MSB, SDL_Convert_F32LSB_to_S32MSB },
icculus@1982
  2344
    { AUDIO_F32LSB, AUDIO_F32MSB, SDL_Convert_F32LSB_to_F32MSB },
icculus@1982
  2345
    { AUDIO_F32MSB, AUDIO_U8, SDL_Convert_F32MSB_to_U8 },
icculus@1982
  2346
    { AUDIO_F32MSB, AUDIO_S8, SDL_Convert_F32MSB_to_S8 },
icculus@1982
  2347
    { AUDIO_F32MSB, AUDIO_U16LSB, SDL_Convert_F32MSB_to_U16LSB },
icculus@1982
  2348
    { AUDIO_F32MSB, AUDIO_S16LSB, SDL_Convert_F32MSB_to_S16LSB },
icculus@1982
  2349
    { AUDIO_F32MSB, AUDIO_U16MSB, SDL_Convert_F32MSB_to_U16MSB },
icculus@1982
  2350
    { AUDIO_F32MSB, AUDIO_S16MSB, SDL_Convert_F32MSB_to_S16MSB },
icculus@1982
  2351
    { AUDIO_F32MSB, AUDIO_S32LSB, SDL_Convert_F32MSB_to_S32LSB },
icculus@1982
  2352
    { AUDIO_F32MSB, AUDIO_S32MSB, SDL_Convert_F32MSB_to_S32MSB },
icculus@1982
  2353
    { AUDIO_F32MSB, AUDIO_F32LSB, SDL_Convert_F32MSB_to_F32LSB },
icculus@1982
  2354
};
icculus@1982
  2355
icculus@1982
  2356