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