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