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