Reworked audio converter code.
authorRyan C. Gordon <icculus@icculus.org>
Sat, 05 Nov 2016 02:34:38 -0400
changeset 10575bb99dede0675
parent 10574 3cc0fe7f98d7
child 10576 4f6ab0d2cc3b
Reworked audio converter code.

This no longer uses a script to generate code for every possible type
conversion or resampler. This caused a bloat in binary size and and compile
times. Now we use a handful of more generic functions and assume staying in
the CPU cache is the most important thing anyhow.

This shrinks the size of the final build (in this case: macOS X amd64, -Os to
optimize for size) by 15%. When compiling on a single core, build times drop
by about 15% too (although the previous cost was largely hidden by multicore
builds).
src/audio/SDL_audio_c.h
src/audio/SDL_audiocvt.c
src/audio/SDL_audiotypecvt.c
src/audio/sdlgenaudiocvt.pl
     1.1 --- a/src/audio/SDL_audio_c.h	Thu Nov 03 11:10:52 2016 -0400
     1.2 +++ b/src/audio/SDL_audio_c.h	Sat Nov 05 02:34:38 2016 -0400
     1.3 @@ -20,6 +20,16 @@
     1.4  */
     1.5  #include "../SDL_internal.h"
     1.6  
     1.7 +#ifndef DEBUG_CONVERT
     1.8 +#define DEBUG_CONVERT 0
     1.9 +#endif
    1.10 +
    1.11 +#if DEBUG_CONVERT
    1.12 +#define LOG_DEBUG_CONVERT(from, to) fprintf(stderr, "Converting %s to %s.\n", from, to);
    1.13 +#else
    1.14 +#define LOG_DEBUG_CONVERT(from, to)
    1.15 +#endif
    1.16 +
    1.17  /* Functions and variables exported from SDL_audio.c for SDL_sysaudio.c */
    1.18  
    1.19  /* Functions to get a list of "close" audio formats */
    1.20 @@ -29,24 +39,20 @@
    1.21  /* Function to calculate the size and silence for a SDL_AudioSpec */
    1.22  extern void SDL_CalculateAudioSpec(SDL_AudioSpec * spec);
    1.23  
    1.24 -/* this is used internally to access some autogenerated code. */
    1.25 -typedef struct
    1.26 -{
    1.27 -    SDL_AudioFormat src_fmt;
    1.28 -    SDL_AudioFormat dst_fmt;
    1.29 -    SDL_AudioFilter filter;
    1.30 -} SDL_AudioTypeFilters;
    1.31 -extern const SDL_AudioTypeFilters sdl_audio_type_filters[];
    1.32 -
    1.33 -/* this is used internally to access some autogenerated code. */
    1.34 -typedef struct
    1.35 -{
    1.36 -    SDL_AudioFormat fmt;
    1.37 -    int channels;
    1.38 -    int upsample;
    1.39 -    int multiple;
    1.40 -    SDL_AudioFilter filter;
    1.41 -} SDL_AudioRateFilters;
    1.42 -extern const SDL_AudioRateFilters sdl_audio_rate_filters[];
    1.43 +void SDLCALL SDL_Convert_S8_to_F32(SDL_AudioCVT *cvt, SDL_AudioFormat format);
    1.44 +void SDLCALL SDL_Convert_U8_to_F32(SDL_AudioCVT *cvt, SDL_AudioFormat format);
    1.45 +void SDLCALL SDL_Convert_S16_to_F32(SDL_AudioCVT *cvt, SDL_AudioFormat format);
    1.46 +void SDLCALL SDL_Convert_U16_to_F32(SDL_AudioCVT *cvt, SDL_AudioFormat format);
    1.47 +void SDLCALL SDL_Convert_S32_to_F32(SDL_AudioCVT *cvt, SDL_AudioFormat format);
    1.48 +void SDLCALL SDL_Convert_F32_to_S8(SDL_AudioCVT *cvt, SDL_AudioFormat format);
    1.49 +void SDLCALL SDL_Convert_F32_to_U8(SDL_AudioCVT *cvt, SDL_AudioFormat format);
    1.50 +void SDLCALL SDL_Convert_F32_to_S16(SDL_AudioCVT *cvt, SDL_AudioFormat format);
    1.51 +void SDLCALL SDL_Convert_F32_to_U16(SDL_AudioCVT *cvt, SDL_AudioFormat format);
    1.52 +void SDLCALL SDL_Convert_F32_to_S32(SDL_AudioCVT *cvt, SDL_AudioFormat format);
    1.53 +void SDL_Upsample_Arbitrary(SDL_AudioCVT *cvt, const int channels);
    1.54 +void SDL_Downsample_Arbitrary(SDL_AudioCVT *cvt, const int channels);
    1.55 +void SDL_Upsample_x2(SDL_AudioCVT *cvt, const int channels);
    1.56 +void SDL_Upsample_x4(SDL_AudioCVT *cvt, const int channels);
    1.57 +void SDL_Downsample_Multiple(SDL_AudioCVT *cvt, const int multiple, const int channels);
    1.58  
    1.59  /* vi: set ts=4 sw=4 expandtab: */
     2.1 --- a/src/audio/SDL_audiocvt.c	Thu Nov 03 11:10:52 2016 -0400
     2.2 +++ b/src/audio/SDL_audiocvt.c	Sat Nov 05 02:34:38 2016 -0400
     2.3 @@ -27,160 +27,20 @@
     2.4  
     2.5  #include "SDL_assert.h"
     2.6  
     2.7 -/* #define DEBUG_CONVERT */
     2.8  
     2.9  /* Effectively mix right and left channels into a single channel */
    2.10  static void SDLCALL
    2.11  SDL_ConvertMono(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    2.12  {
    2.13 +    float *dst = (float *) cvt->buf;
    2.14 +    const float *src = dst;
    2.15      int i;
    2.16 -    Sint32 sample;
    2.17  
    2.18 -#ifdef DEBUG_CONVERT
    2.19 -    fprintf(stderr, "Converting to mono\n");
    2.20 -#endif
    2.21 -	switch (format & (SDL_AUDIO_MASK_SIGNED |
    2.22 -                      SDL_AUDIO_MASK_BITSIZE |
    2.23 -                      SDL_AUDIO_MASK_DATATYPE)) {
    2.24 -    case AUDIO_U8:
    2.25 -        {
    2.26 -            Uint8 *src, *dst;
    2.27 +    LOG_DEBUG_CONVERT("stereo", "mono");
    2.28 +    SDL_assert(format == AUDIO_F32SYS);
    2.29  
    2.30 -            src = cvt->buf;
    2.31 -            dst = cvt->buf;
    2.32 -            for (i = cvt->len_cvt / 2; i; --i) {
    2.33 -                sample = src[0] + src[1];
    2.34 -                *dst = (Uint8) (sample / 2);
    2.35 -                src += 2;
    2.36 -                dst += 1;
    2.37 -            }
    2.38 -        }
    2.39 -        break;
    2.40 -
    2.41 -    case AUDIO_S8:
    2.42 -        {
    2.43 -            Sint8 *src, *dst;
    2.44 -
    2.45 -            src = (Sint8 *) cvt->buf;
    2.46 -            dst = (Sint8 *) cvt->buf;
    2.47 -            for (i = cvt->len_cvt / 2; i; --i) {
    2.48 -                sample = src[0] + src[1];
    2.49 -                *dst = (Sint8) (sample / 2);
    2.50 -                src += 2;
    2.51 -                dst += 1;
    2.52 -            }
    2.53 -        }
    2.54 -        break;
    2.55 -
    2.56 -    case AUDIO_U16:
    2.57 -        {
    2.58 -            Uint8 *src, *dst;
    2.59 -
    2.60 -            src = cvt->buf;
    2.61 -            dst = cvt->buf;
    2.62 -            if (SDL_AUDIO_ISBIGENDIAN(format)) {
    2.63 -                for (i = cvt->len_cvt / 4; i; --i) {
    2.64 -                    sample = (Uint16) ((src[0] << 8) | src[1]) +
    2.65 -                        (Uint16) ((src[2] << 8) | src[3]);
    2.66 -                    sample /= 2;
    2.67 -                    dst[1] = (sample & 0xFF);
    2.68 -                    sample >>= 8;
    2.69 -                    dst[0] = (sample & 0xFF);
    2.70 -                    src += 4;
    2.71 -                    dst += 2;
    2.72 -                }
    2.73 -            } else {
    2.74 -                for (i = cvt->len_cvt / 4; i; --i) {
    2.75 -                    sample = (Uint16) ((src[1] << 8) | src[0]) +
    2.76 -                        (Uint16) ((src[3] << 8) | src[2]);
    2.77 -                    sample /= 2;
    2.78 -                    dst[0] = (sample & 0xFF);
    2.79 -                    sample >>= 8;
    2.80 -                    dst[1] = (sample & 0xFF);
    2.81 -                    src += 4;
    2.82 -                    dst += 2;
    2.83 -                }
    2.84 -            }
    2.85 -        }
    2.86 -        break;
    2.87 -
    2.88 -    case AUDIO_S16:
    2.89 -        {
    2.90 -            Uint8 *src, *dst;
    2.91 -
    2.92 -            src = cvt->buf;
    2.93 -            dst = cvt->buf;
    2.94 -            if (SDL_AUDIO_ISBIGENDIAN(format)) {
    2.95 -                for (i = cvt->len_cvt / 4; i; --i) {
    2.96 -                    sample = (Sint16) ((src[0] << 8) | src[1]) +
    2.97 -                        (Sint16) ((src[2] << 8) | src[3]);
    2.98 -                    sample /= 2;
    2.99 -                    dst[1] = (sample & 0xFF);
   2.100 -                    sample >>= 8;
   2.101 -                    dst[0] = (sample & 0xFF);
   2.102 -                    src += 4;
   2.103 -                    dst += 2;
   2.104 -                }
   2.105 -            } else {
   2.106 -                for (i = cvt->len_cvt / 4; i; --i) {
   2.107 -                    sample = (Sint16) ((src[1] << 8) | src[0]) +
   2.108 -                        (Sint16) ((src[3] << 8) | src[2]);
   2.109 -                    sample /= 2;
   2.110 -                    dst[0] = (sample & 0xFF);
   2.111 -                    sample >>= 8;
   2.112 -                    dst[1] = (sample & 0xFF);
   2.113 -                    src += 4;
   2.114 -                    dst += 2;
   2.115 -                }
   2.116 -            }
   2.117 -        }
   2.118 -        break;
   2.119 -
   2.120 -    case AUDIO_S32:
   2.121 -        {
   2.122 -            const Uint32 *src = (const Uint32 *) cvt->buf;
   2.123 -            Uint32 *dst = (Uint32 *) cvt->buf;
   2.124 -            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   2.125 -                for (i = cvt->len_cvt / 8; i; --i, src += 2) {
   2.126 -                    const Sint64 added =
   2.127 -                        (((Sint64) (Sint32) SDL_SwapBE32(src[0])) +
   2.128 -                         ((Sint64) (Sint32) SDL_SwapBE32(src[1])));
   2.129 -                    *(dst++) = SDL_SwapBE32((Uint32) ((Sint32) (added / 2)));
   2.130 -                }
   2.131 -            } else {
   2.132 -                for (i = cvt->len_cvt / 8; i; --i, src += 2) {
   2.133 -                    const Sint64 added =
   2.134 -                        (((Sint64) (Sint32) SDL_SwapLE32(src[0])) +
   2.135 -                         ((Sint64) (Sint32) SDL_SwapLE32(src[1])));
   2.136 -                    *(dst++) = SDL_SwapLE32((Uint32) ((Sint32) (added / 2)));
   2.137 -                }
   2.138 -            }
   2.139 -        }
   2.140 -        break;
   2.141 -
   2.142 -    case AUDIO_F32:
   2.143 -        {
   2.144 -            const float *src = (const float *) cvt->buf;
   2.145 -            float *dst = (float *) cvt->buf;
   2.146 -            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   2.147 -                for (i = cvt->len_cvt / 8; i; --i, src += 2) {
   2.148 -                    const float src1 = SDL_SwapFloatBE(src[0]);
   2.149 -                    const float src2 = SDL_SwapFloatBE(src[1]);
   2.150 -                    const double added = ((double) src1) + ((double) src2);
   2.151 -                    const float halved = (float) (added * 0.5);
   2.152 -                    *(dst++) = SDL_SwapFloatBE(halved);
   2.153 -                }
   2.154 -            } else {
   2.155 -                for (i = cvt->len_cvt / 8; i; --i, src += 2) {
   2.156 -                    const float src1 = SDL_SwapFloatLE(src[0]);
   2.157 -                    const float src2 = SDL_SwapFloatLE(src[1]);
   2.158 -                    const double added = ((double) src1) + ((double) src2);
   2.159 -                    const float halved = (float) (added * 0.5);
   2.160 -                    *(dst++) = SDL_SwapFloatLE(halved);
   2.161 -                }
   2.162 -            }
   2.163 -        }
   2.164 -        break;
   2.165 +    for (i = cvt->len_cvt / 8; i; --i, src += 2) {
   2.166 +        *(dst++) = (float) ((((double) src[0]) + ((double) src[1])) * 0.5);
   2.167      }
   2.168  
   2.169      cvt->len_cvt /= 2;
   2.170 @@ -194,39 +54,18 @@
   2.171  static void SDLCALL
   2.172  SDL_ConvertStrip(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2.173  {
   2.174 +    float *dst = (float *) cvt->buf;
   2.175 +    const float *src = dst;
   2.176      int i;
   2.177  
   2.178 -#ifdef DEBUG_CONVERT
   2.179 -    fprintf(stderr, "Converting down from 6 channels to stereo\n");
   2.180 -#endif
   2.181 +    LOG_DEBUG_CONVERT("6 channels", "stereo");
   2.182 +    SDL_assert(format == AUDIO_F32SYS);
   2.183  
   2.184 -#define strip_chans_6_to_2(type) \
   2.185 -    { \
   2.186 -        const type *src = (const type *) cvt->buf; \
   2.187 -        type *dst = (type *) cvt->buf; \
   2.188 -        for (i = cvt->len_cvt / (sizeof (type) * 6); i; --i) { \
   2.189 -            dst[0] = src[0]; \
   2.190 -            dst[1] = src[1]; \
   2.191 -            src += 6; \
   2.192 -            dst += 2; \
   2.193 -        } \
   2.194 +    for (i = cvt->len_cvt / (sizeof (float) * 6); i; --i, src += 6, dst += 2) {
   2.195 +        dst[0] = src[0];
   2.196 +        dst[1] = src[1];
   2.197      }
   2.198  
   2.199 -    /* this function only cares about typesize, and data as a block of bits. */
   2.200 -    switch (SDL_AUDIO_BITSIZE(format)) {
   2.201 -    case 8:
   2.202 -        strip_chans_6_to_2(Uint8);
   2.203 -        break;
   2.204 -    case 16:
   2.205 -        strip_chans_6_to_2(Uint16);
   2.206 -        break;
   2.207 -    case 32:
   2.208 -        strip_chans_6_to_2(Uint32);
   2.209 -        break;
   2.210 -    }
   2.211 -
   2.212 -#undef strip_chans_6_to_2
   2.213 -
   2.214      cvt->len_cvt /= 3;
   2.215      if (cvt->filters[++cvt->filter_index]) {
   2.216          cvt->filters[cvt->filter_index] (cvt, format);
   2.217 @@ -238,41 +77,20 @@
   2.218  static void SDLCALL
   2.219  SDL_ConvertStrip_2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2.220  {
   2.221 +    float *dst = (float *) cvt->buf;
   2.222 +    const float *src = dst;
   2.223      int i;
   2.224  
   2.225 -#ifdef DEBUG_CONVERT
   2.226 -    fprintf(stderr, "Converting 6 down to quad\n");
   2.227 -#endif
   2.228 +    LOG_DEBUG_CONVERT("6 channels", "quad");
   2.229 +    SDL_assert(format == AUDIO_F32SYS);
   2.230  
   2.231 -#define strip_chans_6_to_4(type) \
   2.232 -    { \
   2.233 -        const type *src = (const type *) cvt->buf; \
   2.234 -        type *dst = (type *) cvt->buf; \
   2.235 -        for (i = cvt->len_cvt / (sizeof (type) * 6); i; --i) { \
   2.236 -            dst[0] = src[0]; \
   2.237 -            dst[1] = src[1]; \
   2.238 -            dst[2] = src[2]; \
   2.239 -            dst[3] = src[3]; \
   2.240 -            src += 6; \
   2.241 -            dst += 4; \
   2.242 -        } \
   2.243 +    for (i = cvt->len_cvt / (sizeof (float) * 6); i; --i, src += 6, dst += 4) {
   2.244 +        dst[0] = src[0];
   2.245 +        dst[1] = src[1];
   2.246 +        dst[2] = src[2];
   2.247 +        dst[3] = src[3];
   2.248      }
   2.249  
   2.250 -    /* this function only cares about typesize, and data as a block of bits. */
   2.251 -    switch (SDL_AUDIO_BITSIZE(format)) {
   2.252 -    case 8:
   2.253 -        strip_chans_6_to_4(Uint8);
   2.254 -        break;
   2.255 -    case 16:
   2.256 -        strip_chans_6_to_4(Uint16);
   2.257 -        break;
   2.258 -    case 32:
   2.259 -        strip_chans_6_to_4(Uint32);
   2.260 -        break;
   2.261 -    }
   2.262 -
   2.263 -#undef strip_chans_6_to_4
   2.264 -
   2.265      cvt->len_cvt /= 6;
   2.266      cvt->len_cvt *= 4;
   2.267      if (cvt->filters[++cvt->filter_index]) {
   2.268 @@ -284,38 +102,19 @@
   2.269  static void SDLCALL
   2.270  SDL_ConvertStereo(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2.271  {
   2.272 +    const float *src = (const float *) (cvt->buf + cvt->len_cvt);
   2.273 +    float *dst = (float *) (cvt->buf + cvt->len_cvt * 2);
   2.274      int i;
   2.275  
   2.276 -#ifdef DEBUG_CONVERT
   2.277 -    fprintf(stderr, "Converting to stereo\n");
   2.278 -#endif
   2.279 +    LOG_DEBUG_CONVERT("mono", "stereo");
   2.280 +    SDL_assert(format == AUDIO_F32SYS);
   2.281  
   2.282 -#define dup_chans_1_to_2(type) \
   2.283 -    { \
   2.284 -        const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
   2.285 -        type *dst = (type *) (cvt->buf + cvt->len_cvt * 2); \
   2.286 -        for (i = cvt->len_cvt / sizeof(type); i; --i) { \
   2.287 -            src -= 1; \
   2.288 -            dst -= 2; \
   2.289 -            dst[0] = dst[1] = *src; \
   2.290 -        } \
   2.291 +    for (i = cvt->len_cvt / sizeof (float); i; --i) {
   2.292 +        src--;
   2.293 +        dst -= 2;
   2.294 +        dst[0] = dst[1] = *src;
   2.295      }
   2.296  
   2.297 -    /* this function only cares about typesize, and data as a block of bits. */
   2.298 -    switch (SDL_AUDIO_BITSIZE(format)) {
   2.299 -    case 8:
   2.300 -        dup_chans_1_to_2(Uint8);
   2.301 -        break;
   2.302 -    case 16:
   2.303 -        dup_chans_1_to_2(Uint16);
   2.304 -        break;
   2.305 -    case 32:
   2.306 -        dup_chans_1_to_2(Uint32);
   2.307 -        break;
   2.308 -    }
   2.309 -
   2.310 -#undef dup_chans_1_to_2
   2.311 -
   2.312      cvt->len_cvt *= 2;
   2.313      if (cvt->filters[++cvt->filter_index]) {
   2.314          cvt->filters[cvt->filter_index] (cvt, format);
   2.315 @@ -328,253 +127,26 @@
   2.316  SDL_ConvertSurround(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2.317  {
   2.318      int i;
   2.319 +    float lf, rf, ce;
   2.320 +    const float *src = (const float *) (cvt->buf + cvt->len_cvt);
   2.321 +    float *dst = (float *) (cvt->buf + cvt->len_cvt * 3);
   2.322  
   2.323 -#ifdef DEBUG_CONVERT
   2.324 -    fprintf(stderr, "Converting stereo to surround\n");
   2.325 -#endif
   2.326 +    LOG_DEBUG_CONVERT("stereo", "5.1");
   2.327 +    SDL_assert(format == AUDIO_F32SYS);
   2.328  
   2.329 -    switch (format & (SDL_AUDIO_MASK_SIGNED  |
   2.330 -                      SDL_AUDIO_MASK_BITSIZE |
   2.331 -                      SDL_AUDIO_MASK_DATATYPE)) {
   2.332 -    case AUDIO_U8:
   2.333 -        {
   2.334 -            Uint8 *src, *dst, lf, rf, ce;
   2.335 +    for (i = cvt->len_cvt / 8; i; --i) {
   2.336 +        dst -= 6;
   2.337 +        src -= 2;
   2.338 +        lf = src[0];
   2.339 +        rf = src[1];
   2.340 +        ce = (lf * 0.5f) + (rf * 0.5f);
   2.341 +        dst[0] = src[0];
   2.342 +        dst[1] = src[1];
   2.343 +        dst[2] = lf - ce;
   2.344 +        dst[3] = rf - ce;
   2.345 +        dst[4] = dst[5] = ce;
   2.346 +    }
   2.347  
   2.348 -            src = (Uint8 *) (cvt->buf + cvt->len_cvt);
   2.349 -            dst = (Uint8 *) (cvt->buf + cvt->len_cvt * 3);
   2.350 -            for (i = cvt->len_cvt; i; --i) {
   2.351 -                dst -= 6;
   2.352 -                src -= 2;
   2.353 -                lf = src[0];
   2.354 -                rf = src[1];
   2.355 -                ce = (lf / 2) + (rf / 2);
   2.356 -                dst[0] = lf;
   2.357 -                dst[1] = rf;
   2.358 -                dst[2] = lf - ce;
   2.359 -                dst[3] = rf - ce;
   2.360 -                dst[4] = ce;
   2.361 -                dst[5] = ce;
   2.362 -            }
   2.363 -        }
   2.364 -        break;
   2.365 -
   2.366 -    case AUDIO_S8:
   2.367 -        {
   2.368 -            Sint8 *src, *dst, lf, rf, ce;
   2.369 -
   2.370 -            src = (Sint8 *) cvt->buf + cvt->len_cvt;
   2.371 -            dst = (Sint8 *) cvt->buf + cvt->len_cvt * 3;
   2.372 -            for (i = cvt->len_cvt; i; --i) {
   2.373 -                dst -= 6;
   2.374 -                src -= 2;
   2.375 -                lf = src[0];
   2.376 -                rf = src[1];
   2.377 -                ce = (lf / 2) + (rf / 2);
   2.378 -                dst[0] = lf;
   2.379 -                dst[1] = rf;
   2.380 -                dst[2] = lf - ce;
   2.381 -                dst[3] = rf - ce;
   2.382 -                dst[4] = ce;
   2.383 -                dst[5] = ce;
   2.384 -            }
   2.385 -        }
   2.386 -        break;
   2.387 -
   2.388 -    case AUDIO_U16:
   2.389 -        {
   2.390 -            Uint8 *src, *dst;
   2.391 -            Uint16 lf, rf, ce, lr, rr;
   2.392 -
   2.393 -            src = cvt->buf + cvt->len_cvt;
   2.394 -            dst = cvt->buf + cvt->len_cvt * 3;
   2.395 -
   2.396 -            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   2.397 -                for (i = cvt->len_cvt / 4; i; --i) {
   2.398 -                    dst -= 12;
   2.399 -                    src -= 4;
   2.400 -                    lf = (Uint16) ((src[0] << 8) | src[1]);
   2.401 -                    rf = (Uint16) ((src[2] << 8) | src[3]);
   2.402 -                    ce = (lf / 2) + (rf / 2);
   2.403 -                    rr = lf - ce;
   2.404 -                    lr = rf - ce;
   2.405 -                    dst[1] = (lf & 0xFF);
   2.406 -                    dst[0] = ((lf >> 8) & 0xFF);
   2.407 -                    dst[3] = (rf & 0xFF);
   2.408 -                    dst[2] = ((rf >> 8) & 0xFF);
   2.409 -
   2.410 -                    dst[1 + 4] = (lr & 0xFF);
   2.411 -                    dst[0 + 4] = ((lr >> 8) & 0xFF);
   2.412 -                    dst[3 + 4] = (rr & 0xFF);
   2.413 -                    dst[2 + 4] = ((rr >> 8) & 0xFF);
   2.414 -
   2.415 -                    dst[1 + 8] = (ce & 0xFF);
   2.416 -                    dst[0 + 8] = ((ce >> 8) & 0xFF);
   2.417 -                    dst[3 + 8] = (ce & 0xFF);
   2.418 -                    dst[2 + 8] = ((ce >> 8) & 0xFF);
   2.419 -                }
   2.420 -            } else {
   2.421 -                for (i = cvt->len_cvt / 4; i; --i) {
   2.422 -                    dst -= 12;
   2.423 -                    src -= 4;
   2.424 -                    lf = (Uint16) ((src[1] << 8) | src[0]);
   2.425 -                    rf = (Uint16) ((src[3] << 8) | src[2]);
   2.426 -                    ce = (lf / 2) + (rf / 2);
   2.427 -                    rr = lf - ce;
   2.428 -                    lr = rf - ce;
   2.429 -                    dst[0] = (lf & 0xFF);
   2.430 -                    dst[1] = ((lf >> 8) & 0xFF);
   2.431 -                    dst[2] = (rf & 0xFF);
   2.432 -                    dst[3] = ((rf >> 8) & 0xFF);
   2.433 -
   2.434 -                    dst[0 + 4] = (lr & 0xFF);
   2.435 -                    dst[1 + 4] = ((lr >> 8) & 0xFF);
   2.436 -                    dst[2 + 4] = (rr & 0xFF);
   2.437 -                    dst[3 + 4] = ((rr >> 8) & 0xFF);
   2.438 -
   2.439 -                    dst[0 + 8] = (ce & 0xFF);
   2.440 -                    dst[1 + 8] = ((ce >> 8) & 0xFF);
   2.441 -                    dst[2 + 8] = (ce & 0xFF);
   2.442 -                    dst[3 + 8] = ((ce >> 8) & 0xFF);
   2.443 -                }
   2.444 -            }
   2.445 -        }
   2.446 -        break;
   2.447 -
   2.448 -    case AUDIO_S16:
   2.449 -        {
   2.450 -            Uint8 *src, *dst;
   2.451 -            Sint16 lf, rf, ce, lr, rr;
   2.452 -
   2.453 -            src = cvt->buf + cvt->len_cvt;
   2.454 -            dst = cvt->buf + cvt->len_cvt * 3;
   2.455 -
   2.456 -            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   2.457 -                for (i = cvt->len_cvt / 4; i; --i) {
   2.458 -                    dst -= 12;
   2.459 -                    src -= 4;
   2.460 -                    lf = (Sint16) ((src[0] << 8) | src[1]);
   2.461 -                    rf = (Sint16) ((src[2] << 8) | src[3]);
   2.462 -                    ce = (lf / 2) + (rf / 2);
   2.463 -                    rr = lf - ce;
   2.464 -                    lr = rf - ce;
   2.465 -                    dst[1] = (lf & 0xFF);
   2.466 -                    dst[0] = ((lf >> 8) & 0xFF);
   2.467 -                    dst[3] = (rf & 0xFF);
   2.468 -                    dst[2] = ((rf >> 8) & 0xFF);
   2.469 -
   2.470 -                    dst[1 + 4] = (lr & 0xFF);
   2.471 -                    dst[0 + 4] = ((lr >> 8) & 0xFF);
   2.472 -                    dst[3 + 4] = (rr & 0xFF);
   2.473 -                    dst[2 + 4] = ((rr >> 8) & 0xFF);
   2.474 -
   2.475 -                    dst[1 + 8] = (ce & 0xFF);
   2.476 -                    dst[0 + 8] = ((ce >> 8) & 0xFF);
   2.477 -                    dst[3 + 8] = (ce & 0xFF);
   2.478 -                    dst[2 + 8] = ((ce >> 8) & 0xFF);
   2.479 -                }
   2.480 -            } else {
   2.481 -                for (i = cvt->len_cvt / 4; i; --i) {
   2.482 -                    dst -= 12;
   2.483 -                    src -= 4;
   2.484 -                    lf = (Sint16) ((src[1] << 8) | src[0]);
   2.485 -                    rf = (Sint16) ((src[3] << 8) | src[2]);
   2.486 -                    ce = (lf / 2) + (rf / 2);
   2.487 -                    rr = lf - ce;
   2.488 -                    lr = rf - ce;
   2.489 -                    dst[0] = (lf & 0xFF);
   2.490 -                    dst[1] = ((lf >> 8) & 0xFF);
   2.491 -                    dst[2] = (rf & 0xFF);
   2.492 -                    dst[3] = ((rf >> 8) & 0xFF);
   2.493 -
   2.494 -                    dst[0 + 4] = (lr & 0xFF);
   2.495 -                    dst[1 + 4] = ((lr >> 8) & 0xFF);
   2.496 -                    dst[2 + 4] = (rr & 0xFF);
   2.497 -                    dst[3 + 4] = ((rr >> 8) & 0xFF);
   2.498 -
   2.499 -                    dst[0 + 8] = (ce & 0xFF);
   2.500 -                    dst[1 + 8] = ((ce >> 8) & 0xFF);
   2.501 -                    dst[2 + 8] = (ce & 0xFF);
   2.502 -                    dst[3 + 8] = ((ce >> 8) & 0xFF);
   2.503 -                }
   2.504 -            }
   2.505 -        }
   2.506 -        break;
   2.507 -
   2.508 -    case AUDIO_S32:
   2.509 -        {
   2.510 -            Sint32 lf, rf, ce;
   2.511 -            const Uint32 *src = (const Uint32 *) (cvt->buf + cvt->len_cvt);
   2.512 -            Uint32 *dst = (Uint32 *) (cvt->buf + cvt->len_cvt * 3);
   2.513 -
   2.514 -            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   2.515 -                for (i = cvt->len_cvt / 8; i; --i) {
   2.516 -                    dst -= 6;
   2.517 -                    src -= 2;
   2.518 -                    lf = (Sint32) SDL_SwapBE32(src[0]);
   2.519 -                    rf = (Sint32) SDL_SwapBE32(src[1]);
   2.520 -                    ce = (lf / 2) + (rf / 2);
   2.521 -                    dst[0] = SDL_SwapBE32((Uint32) lf);
   2.522 -                    dst[1] = SDL_SwapBE32((Uint32) rf);
   2.523 -                    dst[2] = SDL_SwapBE32((Uint32) (lf - ce));
   2.524 -                    dst[3] = SDL_SwapBE32((Uint32) (rf - ce));
   2.525 -                    dst[4] = SDL_SwapBE32((Uint32) ce);
   2.526 -                    dst[5] = SDL_SwapBE32((Uint32) ce);
   2.527 -                }
   2.528 -            } else {
   2.529 -                for (i = cvt->len_cvt / 8; i; --i) {
   2.530 -                    dst -= 6;
   2.531 -                    src -= 2;
   2.532 -                    lf = (Sint32) SDL_SwapLE32(src[0]);
   2.533 -                    rf = (Sint32) SDL_SwapLE32(src[1]);
   2.534 -                    ce = (lf / 2) + (rf / 2);
   2.535 -                    dst[0] = src[0];
   2.536 -                    dst[1] = src[1];
   2.537 -                    dst[2] = SDL_SwapLE32((Uint32) (lf - ce));
   2.538 -                    dst[3] = SDL_SwapLE32((Uint32) (rf - ce));
   2.539 -                    dst[4] = SDL_SwapLE32((Uint32) ce);
   2.540 -                    dst[5] = SDL_SwapLE32((Uint32) ce);
   2.541 -                }
   2.542 -            }
   2.543 -        }
   2.544 -        break;
   2.545 -
   2.546 -    case AUDIO_F32:
   2.547 -        {
   2.548 -            float lf, rf, ce;
   2.549 -            const float *src = (const float *) (cvt->buf + cvt->len_cvt);
   2.550 -            float *dst = (float *) (cvt->buf + cvt->len_cvt * 3);
   2.551 -
   2.552 -            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   2.553 -                for (i = cvt->len_cvt / 8; i; --i) {
   2.554 -                    dst -= 6;
   2.555 -                    src -= 2;
   2.556 -                    lf = SDL_SwapFloatBE(src[0]);
   2.557 -                    rf = SDL_SwapFloatBE(src[1]);
   2.558 -                    ce = (lf * 0.5f) + (rf * 0.5f);
   2.559 -                    dst[0] = src[0];
   2.560 -                    dst[1] = src[1];
   2.561 -                    dst[2] = SDL_SwapFloatBE(lf - ce);
   2.562 -                    dst[3] = SDL_SwapFloatBE(rf - ce);
   2.563 -                    dst[4] = dst[5] = SDL_SwapFloatBE(ce);
   2.564 -                }
   2.565 -            } else {
   2.566 -                for (i = cvt->len_cvt / 8; i; --i) {
   2.567 -                    dst -= 6;
   2.568 -                    src -= 2;
   2.569 -                    lf = SDL_SwapFloatLE(src[0]);
   2.570 -                    rf = SDL_SwapFloatLE(src[1]);
   2.571 -                    ce = (lf * 0.5f) + (rf * 0.5f);
   2.572 -                    dst[0] = src[0];
   2.573 -                    dst[1] = src[1];
   2.574 -                    dst[2] = SDL_SwapFloatLE(lf - ce);
   2.575 -                    dst[3] = SDL_SwapFloatLE(rf - ce);
   2.576 -                    dst[4] = dst[5] = SDL_SwapFloatLE(ce);
   2.577 -                }
   2.578 -            }
   2.579 -        }
   2.580 -        break;
   2.581 -
   2.582 -    }
   2.583      cvt->len_cvt *= 3;
   2.584      if (cvt->filters[++cvt->filter_index]) {
   2.585          cvt->filters[cvt->filter_index] (cvt, format);
   2.586 @@ -586,223 +158,26 @@
   2.587  static void SDLCALL
   2.588  SDL_ConvertSurround_4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2.589  {
   2.590 +    const float *src = (const float *) (cvt->buf + cvt->len_cvt);
   2.591 +    float *dst = (float *) (cvt->buf + cvt->len_cvt * 2);
   2.592 +    float lf, rf, ce;
   2.593      int i;
   2.594  
   2.595 -#ifdef DEBUG_CONVERT
   2.596 -    fprintf(stderr, "Converting stereo to quad\n");
   2.597 -#endif
   2.598 +    LOG_DEBUG_CONVERT("stereo", "quad");
   2.599 +    SDL_assert(format == AUDIO_F32SYS);
   2.600  
   2.601 -    switch (format & (SDL_AUDIO_MASK_SIGNED |
   2.602 -                      SDL_AUDIO_MASK_BITSIZE |
   2.603 -                      SDL_AUDIO_MASK_DATATYPE)) {
   2.604 -    case AUDIO_U8:
   2.605 -        {
   2.606 -            Uint8 *src, *dst, lf, rf, ce;
   2.607 +    for (i = cvt->len_cvt / 8; i; --i) {
   2.608 +        dst -= 4;
   2.609 +        src -= 2;
   2.610 +        lf = src[0];
   2.611 +        rf = src[1];
   2.612 +        ce = (lf / 2) + (rf / 2);
   2.613 +        dst[0] = src[0];
   2.614 +        dst[1] = src[1];
   2.615 +        dst[2] = lf - ce;
   2.616 +        dst[3] = rf - ce;
   2.617 +    }
   2.618  
   2.619 -            src = (Uint8 *) (cvt->buf + cvt->len_cvt);
   2.620 -            dst = (Uint8 *) (cvt->buf + cvt->len_cvt * 2);
   2.621 -            for (i = cvt->len_cvt; i; --i) {
   2.622 -                dst -= 4;
   2.623 -                src -= 2;
   2.624 -                lf = src[0];
   2.625 -                rf = src[1];
   2.626 -                ce = (lf / 2) + (rf / 2);
   2.627 -                dst[0] = lf;
   2.628 -                dst[1] = rf;
   2.629 -                dst[2] = lf - ce;
   2.630 -                dst[3] = rf - ce;
   2.631 -            }
   2.632 -        }
   2.633 -        break;
   2.634 -
   2.635 -    case AUDIO_S8:
   2.636 -        {
   2.637 -            Sint8 *src, *dst, lf, rf, ce;
   2.638 -
   2.639 -            src = (Sint8 *) cvt->buf + cvt->len_cvt;
   2.640 -            dst = (Sint8 *) cvt->buf + cvt->len_cvt * 2;
   2.641 -            for (i = cvt->len_cvt; i; --i) {
   2.642 -                dst -= 4;
   2.643 -                src -= 2;
   2.644 -                lf = src[0];
   2.645 -                rf = src[1];
   2.646 -                ce = (lf / 2) + (rf / 2);
   2.647 -                dst[0] = lf;
   2.648 -                dst[1] = rf;
   2.649 -                dst[2] = lf - ce;
   2.650 -                dst[3] = rf - ce;
   2.651 -            }
   2.652 -        }
   2.653 -        break;
   2.654 -
   2.655 -    case AUDIO_U16:
   2.656 -        {
   2.657 -            Uint8 *src, *dst;
   2.658 -            Uint16 lf, rf, ce, lr, rr;
   2.659 -
   2.660 -            src = cvt->buf + cvt->len_cvt;
   2.661 -            dst = cvt->buf + cvt->len_cvt * 2;
   2.662 -
   2.663 -            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   2.664 -                for (i = cvt->len_cvt / 4; i; --i) {
   2.665 -                    dst -= 8;
   2.666 -                    src -= 4;
   2.667 -                    lf = (Uint16) ((src[0] << 8) | src[1]);
   2.668 -                    rf = (Uint16) ((src[2] << 8) | src[3]);
   2.669 -                    ce = (lf / 2) + (rf / 2);
   2.670 -                    rr = lf - ce;
   2.671 -                    lr = rf - ce;
   2.672 -                    dst[1] = (lf & 0xFF);
   2.673 -                    dst[0] = ((lf >> 8) & 0xFF);
   2.674 -                    dst[3] = (rf & 0xFF);
   2.675 -                    dst[2] = ((rf >> 8) & 0xFF);
   2.676 -
   2.677 -                    dst[1 + 4] = (lr & 0xFF);
   2.678 -                    dst[0 + 4] = ((lr >> 8) & 0xFF);
   2.679 -                    dst[3 + 4] = (rr & 0xFF);
   2.680 -                    dst[2 + 4] = ((rr >> 8) & 0xFF);
   2.681 -                }
   2.682 -            } else {
   2.683 -                for (i = cvt->len_cvt / 4; i; --i) {
   2.684 -                    dst -= 8;
   2.685 -                    src -= 4;
   2.686 -                    lf = (Uint16) ((src[1] << 8) | src[0]);
   2.687 -                    rf = (Uint16) ((src[3] << 8) | src[2]);
   2.688 -                    ce = (lf / 2) + (rf / 2);
   2.689 -                    rr = lf - ce;
   2.690 -                    lr = rf - ce;
   2.691 -                    dst[0] = (lf & 0xFF);
   2.692 -                    dst[1] = ((lf >> 8) & 0xFF);
   2.693 -                    dst[2] = (rf & 0xFF);
   2.694 -                    dst[3] = ((rf >> 8) & 0xFF);
   2.695 -
   2.696 -                    dst[0 + 4] = (lr & 0xFF);
   2.697 -                    dst[1 + 4] = ((lr >> 8) & 0xFF);
   2.698 -                    dst[2 + 4] = (rr & 0xFF);
   2.699 -                    dst[3 + 4] = ((rr >> 8) & 0xFF);
   2.700 -                }
   2.701 -            }
   2.702 -        }
   2.703 -        break;
   2.704 -
   2.705 -    case AUDIO_S16:
   2.706 -        {
   2.707 -            Uint8 *src, *dst;
   2.708 -            Sint16 lf, rf, ce, lr, rr;
   2.709 -
   2.710 -            src = cvt->buf + cvt->len_cvt;
   2.711 -            dst = cvt->buf + cvt->len_cvt * 2;
   2.712 -
   2.713 -            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   2.714 -                for (i = cvt->len_cvt / 4; i; --i) {
   2.715 -                    dst -= 8;
   2.716 -                    src -= 4;
   2.717 -                    lf = (Sint16) ((src[0] << 8) | src[1]);
   2.718 -                    rf = (Sint16) ((src[2] << 8) | src[3]);
   2.719 -                    ce = (lf / 2) + (rf / 2);
   2.720 -                    rr = lf - ce;
   2.721 -                    lr = rf - ce;
   2.722 -                    dst[1] = (lf & 0xFF);
   2.723 -                    dst[0] = ((lf >> 8) & 0xFF);
   2.724 -                    dst[3] = (rf & 0xFF);
   2.725 -                    dst[2] = ((rf >> 8) & 0xFF);
   2.726 -
   2.727 -                    dst[1 + 4] = (lr & 0xFF);
   2.728 -                    dst[0 + 4] = ((lr >> 8) & 0xFF);
   2.729 -                    dst[3 + 4] = (rr & 0xFF);
   2.730 -                    dst[2 + 4] = ((rr >> 8) & 0xFF);
   2.731 -                }
   2.732 -            } else {
   2.733 -                for (i = cvt->len_cvt / 4; i; --i) {
   2.734 -                    dst -= 8;
   2.735 -                    src -= 4;
   2.736 -                    lf = (Sint16) ((src[1] << 8) | src[0]);
   2.737 -                    rf = (Sint16) ((src[3] << 8) | src[2]);
   2.738 -                    ce = (lf / 2) + (rf / 2);
   2.739 -                    rr = lf - ce;
   2.740 -                    lr = rf - ce;
   2.741 -                    dst[0] = (lf & 0xFF);
   2.742 -                    dst[1] = ((lf >> 8) & 0xFF);
   2.743 -                    dst[2] = (rf & 0xFF);
   2.744 -                    dst[3] = ((rf >> 8) & 0xFF);
   2.745 -
   2.746 -                    dst[0 + 4] = (lr & 0xFF);
   2.747 -                    dst[1 + 4] = ((lr >> 8) & 0xFF);
   2.748 -                    dst[2 + 4] = (rr & 0xFF);
   2.749 -                    dst[3 + 4] = ((rr >> 8) & 0xFF);
   2.750 -                }
   2.751 -            }
   2.752 -        }
   2.753 -        break;
   2.754 -
   2.755 -    case AUDIO_S32:
   2.756 -        {
   2.757 -            const Uint32 *src = (const Uint32 *) (cvt->buf + cvt->len_cvt);
   2.758 -            Uint32 *dst = (Uint32 *) (cvt->buf + cvt->len_cvt * 2);
   2.759 -            Sint32 lf, rf, ce;
   2.760 -
   2.761 -            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   2.762 -                for (i = cvt->len_cvt / 8; i; --i) {
   2.763 -                    dst -= 4;
   2.764 -                    src -= 2;
   2.765 -                    lf = (Sint32) SDL_SwapBE32(src[0]);
   2.766 -                    rf = (Sint32) SDL_SwapBE32(src[1]);
   2.767 -                    ce = (lf / 2) + (rf / 2);
   2.768 -                    dst[0] = src[0];
   2.769 -                    dst[1] = src[1];
   2.770 -                    dst[2] = SDL_SwapBE32((Uint32) (lf - ce));
   2.771 -                    dst[3] = SDL_SwapBE32((Uint32) (rf - ce));
   2.772 -                }
   2.773 -            } else {
   2.774 -                for (i = cvt->len_cvt / 8; i; --i) {
   2.775 -                    dst -= 4;
   2.776 -                    src -= 2;
   2.777 -                    lf = (Sint32) SDL_SwapLE32(src[0]);
   2.778 -                    rf = (Sint32) SDL_SwapLE32(src[1]);
   2.779 -                    ce = (lf / 2) + (rf / 2);
   2.780 -                    dst[0] = src[0];
   2.781 -                    dst[1] = src[1];
   2.782 -                    dst[2] = SDL_SwapLE32((Uint32) (lf - ce));
   2.783 -                    dst[3] = SDL_SwapLE32((Uint32) (rf - ce));
   2.784 -                }
   2.785 -            }
   2.786 -        }
   2.787 -        break;
   2.788 -
   2.789 -    case AUDIO_F32:
   2.790 -        {
   2.791 -            const float *src = (const float *) (cvt->buf + cvt->len_cvt);
   2.792 -            float *dst = (float *) (cvt->buf + cvt->len_cvt * 2);
   2.793 -            float lf, rf, ce;
   2.794 -
   2.795 -            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   2.796 -                for (i = cvt->len_cvt / 8; i; --i) {
   2.797 -                    dst -= 4;
   2.798 -                    src -= 2;
   2.799 -                    lf = SDL_SwapFloatBE(src[0]);
   2.800 -                    rf = SDL_SwapFloatBE(src[1]);
   2.801 -                    ce = (lf / 2) + (rf / 2);
   2.802 -                    dst[0] = src[0];
   2.803 -                    dst[1] = src[1];
   2.804 -                    dst[2] = SDL_SwapFloatBE(lf - ce);
   2.805 -                    dst[3] = SDL_SwapFloatBE(rf - ce);
   2.806 -                }
   2.807 -            } else {
   2.808 -                for (i = cvt->len_cvt / 8; i; --i) {
   2.809 -                    dst -= 4;
   2.810 -                    src -= 2;
   2.811 -                    lf = SDL_SwapFloatLE(src[0]);
   2.812 -                    rf = SDL_SwapFloatLE(src[1]);
   2.813 -                    ce = (lf / 2) + (rf / 2);
   2.814 -                    dst[0] = src[0];
   2.815 -                    dst[1] = src[1];
   2.816 -                    dst[2] = SDL_SwapFloatLE(lf - ce);
   2.817 -                    dst[3] = SDL_SwapFloatLE(rf - ce);
   2.818 -                }
   2.819 -            }
   2.820 -        }
   2.821 -        break;
   2.822 -    }
   2.823      cvt->len_cvt *= 2;
   2.824      if (cvt->filters[++cvt->filter_index]) {
   2.825          cvt->filters[cvt->filter_index] (cvt, format);
   2.826 @@ -818,67 +193,86 @@
   2.827  
   2.828      /* Make sure there's data to convert */
   2.829      if (cvt->buf == NULL) {
   2.830 -        SDL_SetError("No buffer allocated for conversion");
   2.831 -        return (-1);
   2.832 +        return SDL_SetError("No buffer allocated for conversion");
   2.833      }
   2.834 +
   2.835      /* Return okay if no conversion is necessary */
   2.836      cvt->len_cvt = cvt->len;
   2.837      if (cvt->filters[0] == NULL) {
   2.838 -        return (0);
   2.839 +        return 0;
   2.840      }
   2.841  
   2.842      /* Set up the conversion and go! */
   2.843      cvt->filter_index = 0;
   2.844      cvt->filters[0] (cvt, cvt->src_format);
   2.845 -    return (0);
   2.846 +    return 0;
   2.847  }
   2.848  
   2.849 +static void SDLCALL
   2.850 +SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat format)
   2.851 +{
   2.852 +    #if DEBUG_CONVERT
   2.853 +    fprintf(stderr, "Converting byte order\n");
   2.854 +    #endif
   2.855  
   2.856 -static SDL_AudioFilter
   2.857 -SDL_HandTunedTypeCVT(SDL_AudioFormat src_fmt, SDL_AudioFormat dst_fmt)
   2.858 -{
   2.859 -    /*
   2.860 -     * Fill in any future conversions that are specialized to a
   2.861 -     *  processor, platform, compiler, or library here.
   2.862 -     */
   2.863 +    switch (SDL_AUDIO_BITSIZE(format)) {
   2.864 +        #define CASESWAP(b) \
   2.865 +            case b: { \
   2.866 +                Uint##b *ptr = (Uint##b *) cvt->buf; \
   2.867 +                int i; \
   2.868 +                for (i = cvt->len_cvt / sizeof (*ptr); i; --i, ++ptr) { \
   2.869 +                    *ptr = SDL_Swap##b(*ptr); \
   2.870 +                } \
   2.871 +                break; \
   2.872 +            }
   2.873  
   2.874 -    return NULL;                /* no specialized converter code available. */
   2.875 +        CASESWAP(16);
   2.876 +        CASESWAP(32);
   2.877 +        CASESWAP(64);
   2.878 +
   2.879 +        #undef CASESWAP
   2.880 +
   2.881 +        default: SDL_assert(!"unhandled byteswap datatype!"); break;
   2.882 +    }
   2.883 +
   2.884 +    if (cvt->filters[++cvt->filter_index]) {
   2.885 +        /* flip endian flag for data. */
   2.886 +        if (format & SDL_AUDIO_MASK_ENDIAN) {
   2.887 +            format &= ~SDL_AUDIO_MASK_ENDIAN;
   2.888 +        } else {
   2.889 +            format |= SDL_AUDIO_MASK_ENDIAN;
   2.890 +        }
   2.891 +        cvt->filters[cvt->filter_index](cvt, format);
   2.892 +    }
   2.893  }
   2.894  
   2.895  
   2.896 -/*
   2.897 - * Find a converter between two data types. We try to select a hand-tuned
   2.898 - *  asm/vectorized/optimized function first, and then fallback to an
   2.899 - *  autogenerated function that is customized to convert between two
   2.900 - *  specific data types.
   2.901 - */
   2.902  static int
   2.903 -SDL_BuildAudioTypeCVT(SDL_AudioCVT * cvt,
   2.904 -                      SDL_AudioFormat src_fmt, SDL_AudioFormat dst_fmt)
   2.905 +SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat src_fmt)
   2.906  {
   2.907 -    if (src_fmt != dst_fmt) {
   2.908 -        const Uint16 src_bitsize = SDL_AUDIO_BITSIZE(src_fmt);
   2.909 -        const Uint16 dst_bitsize = SDL_AUDIO_BITSIZE(dst_fmt);
   2.910 -        SDL_AudioFilter filter = SDL_HandTunedTypeCVT(src_fmt, dst_fmt);
   2.911 +    int retval = 0;  /* 0 == no conversion necessary. */
   2.912  
   2.913 -        /* No hand-tuned converter? Try the autogenerated ones. */
   2.914 -        if (filter == NULL) {
   2.915 -            int i;
   2.916 -            for (i = 0; sdl_audio_type_filters[i].filter != NULL; i++) {
   2.917 -                const SDL_AudioTypeFilters *filt = &sdl_audio_type_filters[i];
   2.918 -                if ((filt->src_fmt == src_fmt) && (filt->dst_fmt == dst_fmt)) {
   2.919 -                    filter = filt->filter;
   2.920 -                    break;
   2.921 -                }
   2.922 -            }
   2.923 +    if ((SDL_AUDIO_ISBIGENDIAN(src_fmt) != 0) == (SDL_BYTEORDER == SDL_LIL_ENDIAN)) {
   2.924 +        cvt->filters[cvt->filter_index++] = SDL_Convert_Byteswap;
   2.925 +        retval = 1;  /* added a converter. */
   2.926 +    }
   2.927  
   2.928 -            if (filter == NULL) {
   2.929 -                SDL_SetError("No conversion available for these formats");
   2.930 -                return -1;
   2.931 -            }
   2.932 +    if (!SDL_AUDIO_ISFLOAT(src_fmt)) {
   2.933 +        SDL_AudioFilter filter = NULL;
   2.934 +        switch (src_fmt & ~SDL_AUDIO_MASK_ENDIAN) {
   2.935 +            case AUDIO_S8: filter = SDL_Convert_S8_to_F32; break;
   2.936 +            case AUDIO_U8: filter = SDL_Convert_U8_to_F32; break;
   2.937 +            case AUDIO_S16: filter = SDL_Convert_S16_to_F32; break;
   2.938 +            case AUDIO_S32: filter = SDL_Convert_S32_to_F32; break;
   2.939 +            default: SDL_assert(!"Unexpected audio format!"); break;
   2.940          }
   2.941  
   2.942 -        /* Update (cvt) with filter details... */
   2.943 +        if (!filter) {
   2.944 +            return SDL_SetError("No conversion available for these formats");
   2.945 +        }
   2.946 +
   2.947 +        const Uint16 src_bitsize = SDL_AUDIO_BITSIZE(src_fmt);
   2.948 +        const Uint16 dst_bitsize = 32;
   2.949          cvt->filters[cvt->filter_index++] = filter;
   2.950          if (src_bitsize < dst_bitsize) {
   2.951              const int mult = (dst_bitsize / src_bitsize);
   2.952 @@ -887,24 +281,50 @@
   2.953          } else if (src_bitsize > dst_bitsize) {
   2.954              cvt->len_ratio /= (src_bitsize / dst_bitsize);
   2.955          }
   2.956 -
   2.957 -        return 1;               /* added a converter. */
   2.958 +        retval = 1;  /* added a converter. */
   2.959      }
   2.960  
   2.961 -    return 0;                   /* no conversion necessary. */
   2.962 +    return retval;
   2.963  }
   2.964  
   2.965 +static int
   2.966 +SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat dst_fmt)
   2.967 +{
   2.968 +    int retval = 0;  /* 0 == no conversion necessary. */
   2.969  
   2.970 -static SDL_AudioFilter
   2.971 -SDL_HandTunedResampleCVT(SDL_AudioCVT * cvt, int dst_channels,
   2.972 -                         int src_rate, int dst_rate)
   2.973 -{
   2.974 -    /*
   2.975 -     * Fill in any future conversions that are specialized to a
   2.976 -     *  processor, platform, compiler, or library here.
   2.977 -     */
   2.978 +    if (!SDL_AUDIO_ISFLOAT(dst_fmt)) {
   2.979 +        SDL_AudioFilter filter = NULL;
   2.980 +        switch (dst_fmt & ~SDL_AUDIO_MASK_ENDIAN) {
   2.981 +            case AUDIO_S8: filter = SDL_Convert_F32_to_S8; break;
   2.982 +            case AUDIO_U8: filter = SDL_Convert_F32_to_U8; break;
   2.983 +            case AUDIO_S16: filter = SDL_Convert_F32_to_S16; break;
   2.984 +            case AUDIO_S32: filter = SDL_Convert_F32_to_S32; break;
   2.985 +            default: SDL_assert(!"Unexpected audio format!"); break;
   2.986 +        }
   2.987  
   2.988 -    return NULL;                /* no specialized converter code available. */
   2.989 +        if (!filter) {
   2.990 +            return SDL_SetError("No conversion available for these formats");
   2.991 +        }
   2.992 +
   2.993 +        const Uint16 dst_bitsize = SDL_AUDIO_BITSIZE(dst_fmt);
   2.994 +        const Uint16 src_bitsize = 32;
   2.995 +        cvt->filters[cvt->filter_index++] = filter;
   2.996 +        if (src_bitsize < dst_bitsize) {
   2.997 +            const int mult = (dst_bitsize / src_bitsize);
   2.998 +            cvt->len_mult *= mult;
   2.999 +            cvt->len_ratio *= mult;
  2.1000 +        } else if (src_bitsize > dst_bitsize) {
  2.1001 +            cvt->len_ratio /= (src_bitsize / dst_bitsize);
  2.1002 +        }
  2.1003 +        retval = 1;  /* added a converter. */
  2.1004 +    }
  2.1005 +
  2.1006 +    if ((SDL_AUDIO_ISBIGENDIAN(dst_fmt) != 0) == (SDL_BYTEORDER == SDL_LIL_ENDIAN)) {
  2.1007 +        cvt->filters[cvt->filter_index++] = SDL_Convert_Byteswap;
  2.1008 +        retval = 1;  /* added a converter. */
  2.1009 +    }
  2.1010 +
  2.1011 +    return retval;
  2.1012  }
  2.1013  
  2.1014  static int
  2.1015 @@ -913,7 +333,6 @@
  2.1016      int retval = 0;
  2.1017  
  2.1018      /* If we only built with the arbitrary resamplers, ignore multiples. */
  2.1019 -#if !LESS_RESAMPLERS
  2.1020      int lo, hi;
  2.1021      int div;
  2.1022  
  2.1023 @@ -935,41 +354,88 @@
  2.1024  
  2.1025      div = hi / lo;
  2.1026      retval = ((div == 2) || (div == 4)) ? div : 0;
  2.1027 -#endif
  2.1028  
  2.1029      return retval;
  2.1030  }
  2.1031  
  2.1032 +#define RESAMPLER_FUNCS(chans) \
  2.1033 +    static void SDLCALL \
  2.1034 +    SDL_Upsample_Arbitrary_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) { \
  2.1035 +        SDL_assert(format == AUDIO_F32SYS); \
  2.1036 +        SDL_Upsample_Arbitrary(cvt, chans); \
  2.1037 +    }\
  2.1038 +    static void SDLCALL \
  2.1039 +    SDL_Downsample_Arbitrary_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) { \
  2.1040 +        SDL_assert(format == AUDIO_F32SYS); \
  2.1041 +        SDL_Downsample_Arbitrary(cvt, chans); \
  2.1042 +    } \
  2.1043 +    static void SDLCALL \
  2.1044 +    SDL_Upsample_x2_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) { \
  2.1045 +        SDL_assert(format == AUDIO_F32SYS); \
  2.1046 +        SDL_Upsample_x2(cvt, chans); \
  2.1047 +    } \
  2.1048 +    static void SDLCALL \
  2.1049 +    SDL_Downsample_x2_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) { \
  2.1050 +        SDL_assert(format == AUDIO_F32SYS); \
  2.1051 +        SDL_Downsample_Multiple(cvt, 2, chans); \
  2.1052 +    } \
  2.1053 +    static void SDLCALL \
  2.1054 +    SDL_Upsample_x4_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) { \
  2.1055 +        SDL_assert(format == AUDIO_F32SYS); \
  2.1056 +        SDL_Upsample_x4(cvt, chans); \
  2.1057 +    } \
  2.1058 +    static void SDLCALL \
  2.1059 +    SDL_Downsample_x4_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) { \
  2.1060 +        SDL_assert(format == AUDIO_F32SYS); \
  2.1061 +        SDL_Downsample_Multiple(cvt, 4, chans); \
  2.1062 +    }
  2.1063 +RESAMPLER_FUNCS(1)
  2.1064 +RESAMPLER_FUNCS(2)
  2.1065 +RESAMPLER_FUNCS(4)
  2.1066 +RESAMPLER_FUNCS(6)
  2.1067 +RESAMPLER_FUNCS(8)
  2.1068 +#undef RESAMPLER_FUNCS
  2.1069 +
  2.1070  static int
  2.1071  SDL_BuildAudioResampleCVT(SDL_AudioCVT * cvt, int dst_channels,
  2.1072                            int src_rate, int dst_rate)
  2.1073  {
  2.1074      if (src_rate != dst_rate) {
  2.1075 -        SDL_AudioFilter filter = SDL_HandTunedResampleCVT(cvt, dst_channels,
  2.1076 -                                                          src_rate, dst_rate);
  2.1077 +        const int upsample = (src_rate < dst_rate) ? 1 : 0;
  2.1078 +        const int multiple = SDL_FindFrequencyMultiple(src_rate, dst_rate);
  2.1079 +        SDL_AudioFilter filter = NULL;
  2.1080  
  2.1081 -        /* No hand-tuned converter? Try the autogenerated ones. */
  2.1082 +        #define PICK_CHANNEL_FILTER(upordown, resampler) switch (dst_channels) { \
  2.1083 +            case 1: filter = SDL_##upordown##_##resampler##_c1; break; \
  2.1084 +            case 2: filter = SDL_##upordown##_##resampler##_c2; break; \
  2.1085 +            case 4: filter = SDL_##upordown##_##resampler##_c4; break; \
  2.1086 +            case 6: filter = SDL_##upordown##_##resampler##_c6; break; \
  2.1087 +            case 8: filter = SDL_##upordown##_##resampler##_c8; break; \
  2.1088 +            default: break; \
  2.1089 +        }
  2.1090 +
  2.1091 +        if (upsample) {
  2.1092 +            if (multiple == 0) {
  2.1093 +                PICK_CHANNEL_FILTER(Upsample, Arbitrary);
  2.1094 +            } else if (multiple == 2) {
  2.1095 +                PICK_CHANNEL_FILTER(Upsample, x2);
  2.1096 +            } else if (multiple == 4) {
  2.1097 +                PICK_CHANNEL_FILTER(Upsample, x4);
  2.1098 +            }
  2.1099 +        } else {
  2.1100 +            if (multiple == 0) {
  2.1101 +                PICK_CHANNEL_FILTER(Downsample, Arbitrary);
  2.1102 +            } else if (multiple == 2) {
  2.1103 +                PICK_CHANNEL_FILTER(Downsample, x2);
  2.1104 +            } else if (multiple == 4) {
  2.1105 +                PICK_CHANNEL_FILTER(Downsample, x4);
  2.1106 +            }
  2.1107 +        }
  2.1108 +
  2.1109 +        #undef PICK_CHANNEL_FILTER
  2.1110 +
  2.1111          if (filter == NULL) {
  2.1112 -            int i;
  2.1113 -            const int upsample = (src_rate < dst_rate) ? 1 : 0;
  2.1114 -            const int multiple =
  2.1115 -                SDL_FindFrequencyMultiple(src_rate, dst_rate);
  2.1116 -
  2.1117 -            for (i = 0; sdl_audio_rate_filters[i].filter != NULL; i++) {
  2.1118 -                const SDL_AudioRateFilters *filt = &sdl_audio_rate_filters[i];
  2.1119 -                if ((filt->fmt == cvt->dst_format) &&
  2.1120 -                    (filt->channels == dst_channels) &&
  2.1121 -                    (filt->upsample == upsample) &&
  2.1122 -                    (filt->multiple == multiple)) {
  2.1123 -                    filter = filt->filter;
  2.1124 -                    break;
  2.1125 -                }
  2.1126 -            }
  2.1127 -
  2.1128 -            if (filter == NULL) {
  2.1129 -                SDL_SetError("No conversion available for these rates");
  2.1130 -                return -1;
  2.1131 -            }
  2.1132 +            return SDL_SetError("No conversion available for these rates");
  2.1133          }
  2.1134  
  2.1135          /* Update (cvt) with filter details... */
  2.1136 @@ -999,14 +465,6 @@
  2.1137                    SDL_AudioFormat src_fmt, Uint8 src_channels, int src_rate,
  2.1138                    SDL_AudioFormat dst_fmt, Uint8 dst_channels, int dst_rate)
  2.1139  {
  2.1140 -    /*
  2.1141 -     * !!! FIXME: reorder filters based on which grow/shrink the buffer.
  2.1142 -     * !!! FIXME: ideally, we should do everything that shrinks the buffer
  2.1143 -     * !!! FIXME: first, so we don't have to process as many bytes in a given
  2.1144 -     * !!! FIXME: filter and abuse the CPU cache less. This might not be as
  2.1145 -     * !!! FIXME: good in practice as it sounds in theory, though.
  2.1146 -     */
  2.1147 -
  2.1148      /* Sanity check target pointer */
  2.1149      if (cvt == NULL) {
  2.1150          return SDL_InvalidParamError("cvt");
  2.1151 @@ -1043,8 +501,31 @@
  2.1152      cvt->len_ratio = 1.0;
  2.1153      cvt->rate_incr = ((double) dst_rate) / ((double) src_rate);
  2.1154  
  2.1155 +    /* Type conversion goes like this now:
  2.1156 +        - byteswap to CPU native format first if necessary.
  2.1157 +        - convert to native Float32 if necessary.
  2.1158 +        - resample and change channel count if necessary.
  2.1159 +        - convert back to native format.
  2.1160 +        - byteswap back to foreign format if necessary.
  2.1161 +
  2.1162 +       The expectation is we can process data faster in float32
  2.1163 +       (possibly with SIMD), and making several passes over the same
  2.1164 +       buffer in is likely to be CPU cache-friendly, avoiding the
  2.1165 +       biggest performance hit in modern times. Previously we had
  2.1166 +       (script-generated) custom converters for every data type and
  2.1167 +       it was a bloat on SDL compile times and final library size. */
  2.1168 +
  2.1169 +    /* see if we can skip float conversion entirely (just a byteswap needed). */
  2.1170 +    if ((src_rate == dst_rate) && (src_channels == dst_channels) &&
  2.1171 +        ((src_fmt != dst_fmt) &&
  2.1172 +         ((src_fmt & ~SDL_AUDIO_MASK_ENDIAN) == (dst_fmt & ~SDL_AUDIO_MASK_ENDIAN)))) {
  2.1173 +        cvt->filters[cvt->filter_index++] = SDL_Convert_Byteswap;
  2.1174 +        cvt->needed = 1;
  2.1175 +        return 1;
  2.1176 +    }
  2.1177 +
  2.1178      /* Convert data types, if necessary. Updates (cvt). */
  2.1179 -    if (SDL_BuildAudioTypeCVT(cvt, src_fmt, dst_fmt) == -1) {
  2.1180 +    if (SDL_BuildAudioTypeCVTToFloat(cvt, src_fmt) == -1) {
  2.1181          return -1;              /* shouldn't happen, but just in case... */
  2.1182      }
  2.1183  
  2.1184 @@ -1105,17 +586,13 @@
  2.1185          return -1;              /* shouldn't happen, but just in case... */
  2.1186      }
  2.1187  
  2.1188 -    /* Set up the filter information */
  2.1189 -    if (cvt->filter_index != 0) {
  2.1190 -        cvt->needed = 1;
  2.1191 -        cvt->src_format = src_fmt;
  2.1192 -        cvt->dst_format = dst_fmt;
  2.1193 -        cvt->len = 0;
  2.1194 -        cvt->buf = NULL;
  2.1195 -        cvt->filters[cvt->filter_index] = NULL;
  2.1196 +    if (SDL_BuildAudioTypeCVTFromFloat(cvt, dst_fmt) == -1) {
  2.1197 +        return -1;              /* shouldn't happen, but just in case... */
  2.1198      }
  2.1199 +
  2.1200 +    cvt->needed = (cvt->filter_index != 0);
  2.1201      return (cvt->needed);
  2.1202  }
  2.1203  
  2.1204 +/* vi: set ts=4 sw=4 expandtab: */
  2.1205  
  2.1206 -/* vi: set ts=4 sw=4 expandtab: */
     3.1 --- a/src/audio/SDL_audiotypecvt.c	Thu Nov 03 11:10:52 2016 -0400
     3.2 +++ b/src/audio/SDL_audiotypecvt.c	Sat Nov 05 02:34:38 2016 -0400
     3.3 @@ -1,4 +1,3 @@
     3.4 -/* DO NOT EDIT!  This file is generated by sdlgenaudiocvt.pl */
     3.5  /*
     3.6    Simple DirectMedia Layer
     3.7    Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
     3.8 @@ -23,15993 +22,396 @@
     3.9  #include "../SDL_internal.h"
    3.10  #include "SDL_audio.h"
    3.11  #include "SDL_audio_c.h"
    3.12 -
    3.13 -#ifndef DEBUG_CONVERT
    3.14 -#define DEBUG_CONVERT 0
    3.15 -#endif
    3.16 -
    3.17 -
    3.18 -/* If you can guarantee your data and need space, you can eliminate code... */
    3.19 -
    3.20 -/* Just build the arbitrary resamplers if you're saving code space. */
    3.21 -#ifndef LESS_RESAMPLERS
    3.22 -#define LESS_RESAMPLERS 0
    3.23 -#endif
    3.24 -
    3.25 -/* Don't build any resamplers if you're REALLY saving code space. */
    3.26 -#ifndef NO_RESAMPLERS
    3.27 -#define NO_RESAMPLERS 0
    3.28 -#endif
    3.29 -
    3.30 -/* Don't build any type converters if you're saving code space. */
    3.31 -#ifndef NO_CONVERTERS
    3.32 -#define NO_CONVERTERS 0
    3.33 -#endif
    3.34 -
    3.35 -
    3.36 -/* *INDENT-OFF* */
    3.37 +#include "SDL_assert.h"
    3.38  
    3.39  #define DIVBY127 0.0078740157480315f
    3.40  #define DIVBY32767 3.05185094759972e-05f
    3.41  #define DIVBY2147483647 4.6566128752458e-10f
    3.42  
    3.43 -#if !NO_CONVERTERS
    3.44 +void SDLCALL
    3.45 +SDL_Convert_S8_to_F32(SDL_AudioCVT *cvt, SDL_AudioFormat format)
    3.46 +{
    3.47 +    const Uint8 *src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    3.48 +    float *dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
    3.49 +    int i;
    3.50  
    3.51 -static void SDLCALL
    3.52 -SDL_Convert_U8_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    3.53 -{
    3.54 -    int i;
    3.55 -    const Uint8 *src;
    3.56 -    Sint8 *dst;
    3.57 +    LOG_DEBUG_CONVERT("AUDIO_S8", "AUDIO_F32");
    3.58  
    3.59 -#if DEBUG_CONVERT
    3.60 -    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S8.\n");
    3.61 -#endif
    3.62 -
    3.63 -    src = (const Uint8 *) cvt->buf;
    3.64 -    dst = (Sint8 *) cvt->buf;
    3.65 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, ++src, ++dst) {
    3.66 -        const Sint8 val = ((*src) ^ 0x80);
    3.67 -        *dst = ((Sint8) val);
    3.68 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    3.69 +        *dst = (((float) ((Sint8) *src)) * DIVBY127);
    3.70      }
    3.71  
    3.72 +    cvt->len_cvt *= 4;
    3.73      if (cvt->filters[++cvt->filter_index]) {
    3.74 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
    3.75 +        cvt->filters[cvt->filter_index](cvt, AUDIO_F32SYS);
    3.76      }
    3.77  }
    3.78  
    3.79 -static void SDLCALL
    3.80 -SDL_Convert_U8_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    3.81 +void SDLCALL
    3.82 +SDL_Convert_U8_to_F32(SDL_AudioCVT *cvt, SDL_AudioFormat format)
    3.83  {
    3.84 +    const Uint8 *src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    3.85 +    float *dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
    3.86      int i;
    3.87 -    const Uint8 *src;
    3.88 -    Uint16 *dst;
    3.89  
    3.90 -#if DEBUG_CONVERT
    3.91 -    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_U16LSB.\n");
    3.92 -#endif
    3.93 +    LOG_DEBUG_CONVERT("AUDIO_U8", "AUDIO_F32");
    3.94  
    3.95 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    3.96 -    dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    3.97      for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    3.98 -        const Uint16 val = (((Uint16) *src) << 8);
    3.99 -        *dst = SDL_SwapLE16(val);
   3.100 +        *dst = ((((float) *src) * DIVBY127) - 1.0f);
   3.101 +    }
   3.102 +
   3.103 +    cvt->len_cvt *= 4;
   3.104 +    if (cvt->filters[++cvt->filter_index]) {
   3.105 +        cvt->filters[cvt->filter_index](cvt, AUDIO_F32SYS);
   3.106 +    }
   3.107 +}
   3.108 +
   3.109 +void SDLCALL
   3.110 +SDL_Convert_S16_to_F32(SDL_AudioCVT *cvt, SDL_AudioFormat format)
   3.111 +{
   3.112 +    const Sint16 *src = ((const Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.113 +    float *dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.114 +    int i;
   3.115 +
   3.116 +    LOG_DEBUG_CONVERT("AUDIO_S16", "AUDIO_F32");
   3.117 +
   3.118 +    for (i = cvt->len_cvt / sizeof (Sint16); i; --i, --src, --dst) {
   3.119 +        *dst = (((float) *src) * DIVBY32767);
   3.120      }
   3.121  
   3.122      cvt->len_cvt *= 2;
   3.123      if (cvt->filters[++cvt->filter_index]) {
   3.124 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
   3.125 +        cvt->filters[cvt->filter_index](cvt, AUDIO_F32SYS);
   3.126      }
   3.127  }
   3.128  
   3.129 -static void SDLCALL
   3.130 -SDL_Convert_U8_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.131 +void SDLCALL
   3.132 +SDL_Convert_U16_to_F32(SDL_AudioCVT *cvt, SDL_AudioFormat format)
   3.133  {
   3.134 +    const Uint16 *src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.135 +    float *dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.136      int i;
   3.137 -    const Uint8 *src;
   3.138 -    Sint16 *dst;
   3.139  
   3.140 -#if DEBUG_CONVERT
   3.141 -    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S16LSB.\n");
   3.142 -#endif
   3.143 +    LOG_DEBUG_CONVERT("AUDIO_U16", "AUDIO_F32");
   3.144  
   3.145 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.146 -    dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.147 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   3.148 -        const Sint16 val = (((Sint16) ((*src) ^ 0x80)) << 8);
   3.149 -        *dst = ((Sint16) SDL_SwapLE16(val));
   3.150 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   3.151 +        *dst = ((((float) *src) * DIVBY32767) - 1.0f);
   3.152      }
   3.153  
   3.154      cvt->len_cvt *= 2;
   3.155      if (cvt->filters[++cvt->filter_index]) {
   3.156 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
   3.157 +        cvt->filters[cvt->filter_index](cvt, AUDIO_F32SYS);
   3.158      }
   3.159  }
   3.160  
   3.161 -static void SDLCALL
   3.162 -SDL_Convert_U8_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.163 +void SDLCALL
   3.164 +SDL_Convert_S32_to_F32(SDL_AudioCVT *cvt, SDL_AudioFormat format)
   3.165  {
   3.166 +    const Uint32 *src = (const Uint32 *) cvt->buf;
   3.167 +    float *dst = (float *) cvt->buf;
   3.168      int i;
   3.169 -    const Uint8 *src;
   3.170 -    Uint16 *dst;
   3.171  
   3.172 -#if DEBUG_CONVERT
   3.173 -    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_U16MSB.\n");
   3.174 -#endif
   3.175 +    LOG_DEBUG_CONVERT("AUDIO_S32", "AUDIO_F32");
   3.176  
   3.177 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.178 -    dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.179 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   3.180 -        const Uint16 val = (((Uint16) *src) << 8);
   3.181 -        *dst = SDL_SwapBE16(val);
   3.182 +    for (i = cvt->len_cvt / sizeof (Sint32); i; --i, ++src, ++dst) {
   3.183 +        *dst = (((float) *src) * DIVBY2147483647);
   3.184      }
   3.185  
   3.186 -    cvt->len_cvt *= 2;
   3.187      if (cvt->filters[++cvt->filter_index]) {
   3.188 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
   3.189 +        cvt->filters[cvt->filter_index](cvt, AUDIO_F32SYS);
   3.190      }
   3.191  }
   3.192  
   3.193 -static void SDLCALL
   3.194 -SDL_Convert_U8_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.195 +void SDLCALL
   3.196 +SDL_Convert_F32_to_S8(SDL_AudioCVT *cvt, SDL_AudioFormat format)
   3.197  {
   3.198 +    const float *src = (const float *) cvt->buf;
   3.199 +    Sint8 *dst = (Sint8 *) cvt->buf;
   3.200      int i;
   3.201 -    const Uint8 *src;
   3.202 -    Sint16 *dst;
   3.203  
   3.204 -#if DEBUG_CONVERT
   3.205 -    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S16MSB.\n");
   3.206 -#endif
   3.207 +    LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S8");
   3.208  
   3.209 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.210 -    dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.211 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   3.212 -        const Sint16 val = (((Sint16) ((*src) ^ 0x80)) << 8);
   3.213 -        *dst = ((Sint16) SDL_SwapBE16(val));
   3.214 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   3.215 +        *dst = (Sint8) (*src * 127.0f);
   3.216      }
   3.217  
   3.218 -    cvt->len_cvt *= 2;
   3.219 +    cvt->len_cvt /= 4;
   3.220      if (cvt->filters[++cvt->filter_index]) {
   3.221 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
   3.222 +        cvt->filters[cvt->filter_index](cvt, AUDIO_S8);
   3.223      }
   3.224  }
   3.225  
   3.226 -static void SDLCALL
   3.227 -SDL_Convert_U8_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.228 +void SDLCALL
   3.229 +SDL_Convert_F32_to_U8(SDL_AudioCVT *cvt, SDL_AudioFormat format)
   3.230  {
   3.231 +    const float *src = (const float *) cvt->buf;
   3.232 +    Uint8 *dst = (Uint8 *) cvt->buf;
   3.233      int i;
   3.234 -    const Uint8 *src;
   3.235 -    Sint32 *dst;
   3.236  
   3.237 -#if DEBUG_CONVERT
   3.238 -    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S32LSB.\n");
   3.239 -#endif
   3.240 +    LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_U8");
   3.241  
   3.242 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.243 -    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
   3.244 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   3.245 -        const Sint32 val = (((Sint32) ((*src) ^ 0x80)) << 24);
   3.246 -        *dst = ((Sint32) SDL_SwapLE32(val));
   3.247 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   3.248 +        *dst = (Uint8) ((*src + 1.0f) * 127.0f);
   3.249      }
   3.250  
   3.251 -    cvt->len_cvt *= 4;
   3.252 +    cvt->len_cvt /= 4;
   3.253      if (cvt->filters[++cvt->filter_index]) {
   3.254 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
   3.255 +        cvt->filters[cvt->filter_index](cvt, AUDIO_U8);
   3.256      }
   3.257  }
   3.258  
   3.259 -static void SDLCALL
   3.260 -SDL_Convert_U8_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.261 +void SDLCALL
   3.262 +SDL_Convert_F32_to_S16(SDL_AudioCVT *cvt, SDL_AudioFormat format)
   3.263  {
   3.264 +    const float *src = (const float *) cvt->buf;
   3.265 +    Sint16 *dst = (Sint16 *) cvt->buf;
   3.266      int i;
   3.267 -    const Uint8 *src;
   3.268 -    Sint32 *dst;
   3.269  
   3.270 -#if DEBUG_CONVERT
   3.271 -    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S32MSB.\n");
   3.272 -#endif
   3.273 +    LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S16");
   3.274  
   3.275 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.276 -    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
   3.277 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   3.278 -        const Sint32 val = (((Sint32) ((*src) ^ 0x80)) << 24);
   3.279 -        *dst = ((Sint32) SDL_SwapBE32(val));
   3.280 -    }
   3.281 -
   3.282 -    cvt->len_cvt *= 4;
   3.283 -    if (cvt->filters[++cvt->filter_index]) {
   3.284 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
   3.285 -    }
   3.286 -}
   3.287 -
   3.288 -static void SDLCALL
   3.289 -SDL_Convert_U8_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.290 -{
   3.291 -    int i;
   3.292 -    const Uint8 *src;
   3.293 -    float *dst;
   3.294 -
   3.295 -#if DEBUG_CONVERT
   3.296 -    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_F32LSB.\n");
   3.297 -#endif
   3.298 -
   3.299 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.300 -    dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
   3.301 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   3.302 -        const float val = ((((float) *src) * DIVBY127) - 1.0f);
   3.303 -        *dst = SDL_SwapFloatLE(val);
   3.304 -    }
   3.305 -
   3.306 -    cvt->len_cvt *= 4;
   3.307 -    if (cvt->filters[++cvt->filter_index]) {
   3.308 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
   3.309 -    }
   3.310 -}
   3.311 -
   3.312 -static void SDLCALL
   3.313 -SDL_Convert_U8_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.314 -{
   3.315 -    int i;
   3.316 -    const Uint8 *src;
   3.317 -    float *dst;
   3.318 -
   3.319 -#if DEBUG_CONVERT
   3.320 -    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_F32MSB.\n");
   3.321 -#endif
   3.322 -
   3.323 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.324 -    dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
   3.325 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   3.326 -        const float val = ((((float) *src) * DIVBY127) - 1.0f);
   3.327 -        *dst = SDL_SwapFloatBE(val);
   3.328 -    }
   3.329 -
   3.330 -    cvt->len_cvt *= 4;
   3.331 -    if (cvt->filters[++cvt->filter_index]) {
   3.332 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
   3.333 -    }
   3.334 -}
   3.335 -
   3.336 -static void SDLCALL
   3.337 -SDL_Convert_S8_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.338 -{
   3.339 -    int i;
   3.340 -    const Uint8 *src;
   3.341 -    Uint8 *dst;
   3.342 -
   3.343 -#if DEBUG_CONVERT
   3.344 -    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U8.\n");
   3.345 -#endif
   3.346 -
   3.347 -    src = (const Uint8 *) cvt->buf;
   3.348 -    dst = (Uint8 *) cvt->buf;
   3.349 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, ++src, ++dst) {
   3.350 -        const Uint8 val = ((((Sint8) *src)) ^ 0x80);
   3.351 -        *dst = val;
   3.352 -    }
   3.353 -
   3.354 -    if (cvt->filters[++cvt->filter_index]) {
   3.355 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
   3.356 -    }
   3.357 -}
   3.358 -
   3.359 -static void SDLCALL
   3.360 -SDL_Convert_S8_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.361 -{
   3.362 -    int i;
   3.363 -    const Uint8 *src;
   3.364 -    Uint16 *dst;
   3.365 -
   3.366 -#if DEBUG_CONVERT
   3.367 -    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U16LSB.\n");
   3.368 -#endif
   3.369 -
   3.370 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.371 -    dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.372 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   3.373 -        const Uint16 val = (((Uint16) ((((Sint8) *src)) ^ 0x80)) << 8);
   3.374 -        *dst = SDL_SwapLE16(val);
   3.375 -    }
   3.376 -
   3.377 -    cvt->len_cvt *= 2;
   3.378 -    if (cvt->filters[++cvt->filter_index]) {
   3.379 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
   3.380 -    }
   3.381 -}
   3.382 -
   3.383 -static void SDLCALL
   3.384 -SDL_Convert_S8_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.385 -{
   3.386 -    int i;
   3.387 -    const Uint8 *src;
   3.388 -    Sint16 *dst;
   3.389 -
   3.390 -#if DEBUG_CONVERT
   3.391 -    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S16LSB.\n");
   3.392 -#endif
   3.393 -
   3.394 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.395 -    dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.396 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   3.397 -        const Sint16 val = (((Sint16) ((Sint8) *src)) << 8);
   3.398 -        *dst = ((Sint16) SDL_SwapLE16(val));
   3.399 -    }
   3.400 -
   3.401 -    cvt->len_cvt *= 2;
   3.402 -    if (cvt->filters[++cvt->filter_index]) {
   3.403 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
   3.404 -    }
   3.405 -}
   3.406 -
   3.407 -static void SDLCALL
   3.408 -SDL_Convert_S8_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.409 -{
   3.410 -    int i;
   3.411 -    const Uint8 *src;
   3.412 -    Uint16 *dst;
   3.413 -
   3.414 -#if DEBUG_CONVERT
   3.415 -    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U16MSB.\n");
   3.416 -#endif
   3.417 -
   3.418 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.419 -    dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.420 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   3.421 -        const Uint16 val = (((Uint16) ((((Sint8) *src)) ^ 0x80)) << 8);
   3.422 -        *dst = SDL_SwapBE16(val);
   3.423 -    }
   3.424 -
   3.425 -    cvt->len_cvt *= 2;
   3.426 -    if (cvt->filters[++cvt->filter_index]) {
   3.427 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
   3.428 -    }
   3.429 -}
   3.430 -
   3.431 -static void SDLCALL
   3.432 -SDL_Convert_S8_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.433 -{
   3.434 -    int i;
   3.435 -    const Uint8 *src;
   3.436 -    Sint16 *dst;
   3.437 -
   3.438 -#if DEBUG_CONVERT
   3.439 -    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S16MSB.\n");
   3.440 -#endif
   3.441 -
   3.442 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.443 -    dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.444 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   3.445 -        const Sint16 val = (((Sint16) ((Sint8) *src)) << 8);
   3.446 -        *dst = ((Sint16) SDL_SwapBE16(val));
   3.447 -    }
   3.448 -
   3.449 -    cvt->len_cvt *= 2;
   3.450 -    if (cvt->filters[++cvt->filter_index]) {
   3.451 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
   3.452 -    }
   3.453 -}
   3.454 -
   3.455 -static void SDLCALL
   3.456 -SDL_Convert_S8_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.457 -{
   3.458 -    int i;
   3.459 -    const Uint8 *src;
   3.460 -    Sint32 *dst;
   3.461 -
   3.462 -#if DEBUG_CONVERT
   3.463 -    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S32LSB.\n");
   3.464 -#endif
   3.465 -
   3.466 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.467 -    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
   3.468 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   3.469 -        const Sint32 val = (((Sint32) ((Sint8) *src)) << 24);
   3.470 -        *dst = ((Sint32) SDL_SwapLE32(val));
   3.471 -    }
   3.472 -
   3.473 -    cvt->len_cvt *= 4;
   3.474 -    if (cvt->filters[++cvt->filter_index]) {
   3.475 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
   3.476 -    }
   3.477 -}
   3.478 -
   3.479 -static void SDLCALL
   3.480 -SDL_Convert_S8_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.481 -{
   3.482 -    int i;
   3.483 -    const Uint8 *src;
   3.484 -    Sint32 *dst;
   3.485 -
   3.486 -#if DEBUG_CONVERT
   3.487 -    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S32MSB.\n");
   3.488 -#endif
   3.489 -
   3.490 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.491 -    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
   3.492 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   3.493 -        const Sint32 val = (((Sint32) ((Sint8) *src)) << 24);
   3.494 -        *dst = ((Sint32) SDL_SwapBE32(val));
   3.495 -    }
   3.496 -
   3.497 -    cvt->len_cvt *= 4;
   3.498 -    if (cvt->filters[++cvt->filter_index]) {
   3.499 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
   3.500 -    }
   3.501 -}
   3.502 -
   3.503 -static void SDLCALL
   3.504 -SDL_Convert_S8_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.505 -{
   3.506 -    int i;
   3.507 -    const Uint8 *src;
   3.508 -    float *dst;
   3.509 -
   3.510 -#if DEBUG_CONVERT
   3.511 -    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_F32LSB.\n");
   3.512 -#endif
   3.513 -
   3.514 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.515 -    dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
   3.516 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   3.517 -        const float val = (((float) ((Sint8) *src)) * DIVBY127);
   3.518 -        *dst = SDL_SwapFloatLE(val);
   3.519 -    }
   3.520 -
   3.521 -    cvt->len_cvt *= 4;
   3.522 -    if (cvt->filters[++cvt->filter_index]) {
   3.523 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
   3.524 -    }
   3.525 -}
   3.526 -
   3.527 -static void SDLCALL
   3.528 -SDL_Convert_S8_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.529 -{
   3.530 -    int i;
   3.531 -    const Uint8 *src;
   3.532 -    float *dst;
   3.533 -
   3.534 -#if DEBUG_CONVERT
   3.535 -    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_F32MSB.\n");
   3.536 -#endif
   3.537 -
   3.538 -    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.539 -    dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
   3.540 -    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   3.541 -        const float val = (((float) ((Sint8) *src)) * DIVBY127);
   3.542 -        *dst = SDL_SwapFloatBE(val);
   3.543 -    }
   3.544 -
   3.545 -    cvt->len_cvt *= 4;
   3.546 -    if (cvt->filters[++cvt->filter_index]) {
   3.547 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
   3.548 -    }
   3.549 -}
   3.550 -
   3.551 -static void SDLCALL
   3.552 -SDL_Convert_U16LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.553 -{
   3.554 -    int i;
   3.555 -    const Uint16 *src;
   3.556 -    Uint8 *dst;
   3.557 -
   3.558 -#if DEBUG_CONVERT
   3.559 -    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_U8.\n");
   3.560 -#endif
   3.561 -
   3.562 -    src = (const Uint16 *) cvt->buf;
   3.563 -    dst = (Uint8 *) cvt->buf;
   3.564 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   3.565 -        const Uint8 val = ((Uint8) (SDL_SwapLE16(*src) >> 8));
   3.566 -        *dst = val;
   3.567 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   3.568 +        *dst = (Sint16) (*src * 32767.0f);
   3.569      }
   3.570  
   3.571      cvt->len_cvt /= 2;
   3.572      if (cvt->filters[++cvt->filter_index]) {
   3.573 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
   3.574 +        cvt->filters[cvt->filter_index](cvt, AUDIO_S16SYS);
   3.575      }
   3.576  }
   3.577  
   3.578 -static void SDLCALL
   3.579 -SDL_Convert_U16LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.580 +void SDLCALL
   3.581 +SDL_Convert_F32_to_U16(SDL_AudioCVT *cvt, SDL_AudioFormat format)
   3.582  {
   3.583 +    const float *src = (const float *) cvt->buf;
   3.584 +    Uint16 *dst = (Uint16 *) cvt->buf;
   3.585      int i;
   3.586 -    const Uint16 *src;
   3.587 -    Sint8 *dst;
   3.588  
   3.589 -#if DEBUG_CONVERT
   3.590 -    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S8.\n");
   3.591 -#endif
   3.592 +    LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_U16");
   3.593  
   3.594 -    src = (const Uint16 *) cvt->buf;
   3.595 -    dst = (Sint8 *) cvt->buf;
   3.596 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   3.597 -        const Sint8 val = ((Sint8) (((SDL_SwapLE16(*src)) ^ 0x8000) >> 8));
   3.598 -        *dst = ((Sint8) val);
   3.599 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   3.600 +        *dst = (Uint16) ((*src + 1.0f) * 32767.0f);
   3.601      }
   3.602  
   3.603      cvt->len_cvt /= 2;
   3.604      if (cvt->filters[++cvt->filter_index]) {
   3.605 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
   3.606 +        cvt->filters[cvt->filter_index](cvt, AUDIO_U16SYS);
   3.607      }
   3.608  }
   3.609  
   3.610 -static void SDLCALL
   3.611 -SDL_Convert_U16LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.612 +void SDLCALL
   3.613 +SDL_Convert_F32_to_S32(SDL_AudioCVT *cvt, SDL_AudioFormat format)
   3.614  {
   3.615 +    const float *src = (const float *) cvt->buf;
   3.616 +    Sint32 *dst = (Sint32 *) cvt->buf;
   3.617      int i;
   3.618 -    const Uint16 *src;
   3.619 -    Sint16 *dst;
   3.620  
   3.621 -#if DEBUG_CONVERT
   3.622 -    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S16LSB.\n");
   3.623 -#endif
   3.624 +    LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S32");
   3.625  
   3.626 -    src = (const Uint16 *) cvt->buf;
   3.627 -    dst = (Sint16 *) cvt->buf;
   3.628 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   3.629 -        const Sint16 val = ((SDL_SwapLE16(*src)) ^ 0x8000);
   3.630 -        *dst = ((Sint16) SDL_SwapLE16(val));
   3.631 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   3.632 +        *dst = (Sint32) (*src * 2147483647.0);
   3.633      }
   3.634  
   3.635      if (cvt->filters[++cvt->filter_index]) {
   3.636 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
   3.637 +        cvt->filters[cvt->filter_index](cvt, AUDIO_S32SYS);
   3.638      }
   3.639  }
   3.640  
   3.641 -static void SDLCALL
   3.642 -SDL_Convert_U16LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.643 +void
   3.644 +SDL_Upsample_Arbitrary(SDL_AudioCVT *cvt, const int channels)
   3.645  {
   3.646 +    const int srcsize = cvt->len_cvt - (64 * channels);
   3.647 +    const int dstsize = (int) (((double)(cvt->len_cvt/(channels*4))) * cvt->rate_incr) * (channels*4);
   3.648 +    register int eps = 0;
   3.649 +    float *dst = ((float *) (cvt->buf + dstsize)) - 8;
   3.650 +    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
   3.651 +    const float *target = ((const float *) cvt->buf);
   3.652 +    const size_t cpy = sizeof (float) * channels;
   3.653 +    float last_sample[8];
   3.654 +    float sample[8];
   3.655      int i;
   3.656 -    const Uint16 *src;
   3.657 -    Uint16 *dst;
   3.658  
   3.659  #if DEBUG_CONVERT
   3.660 -    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_U16MSB.\n");
   3.661 +    fprintf(stderr, "Upsample arbitrary (x%f), %d channels.\n", cvt->rate_incr, channels);
   3.662  #endif
   3.663  
   3.664 -    src = (const Uint16 *) cvt->buf;
   3.665 -    dst = (Uint16 *) cvt->buf;
   3.666 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   3.667 -        const Uint16 val = SDL_SwapLE16(*src);
   3.668 -        *dst = SDL_SwapBE16(val);
   3.669 -    }
   3.670 +    SDL_assert(channels <= 8);
   3.671  
   3.672 -    if (cvt->filters[++cvt->filter_index]) {
   3.673 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
   3.674 -    }
   3.675 -}
   3.676 +    SDL_memcpy(sample, src, cpy);
   3.677 +    SDL_memcpy(last_sample, src, cpy);
   3.678  
   3.679 -static void SDLCALL
   3.680 -SDL_Convert_U16LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.681 -{
   3.682 -    int i;
   3.683 -    const Uint16 *src;
   3.684 -    Sint16 *dst;
   3.685 -
   3.686 -#if DEBUG_CONVERT
   3.687 -    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S16MSB.\n");
   3.688 -#endif
   3.689 -
   3.690 -    src = (const Uint16 *) cvt->buf;
   3.691 -    dst = (Sint16 *) cvt->buf;
   3.692 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   3.693 -        const Sint16 val = ((SDL_SwapLE16(*src)) ^ 0x8000);
   3.694 -        *dst = ((Sint16) SDL_SwapBE16(val));
   3.695 -    }
   3.696 -
   3.697 -    if (cvt->filters[++cvt->filter_index]) {
   3.698 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
   3.699 -    }
   3.700 -}
   3.701 -
   3.702 -static void SDLCALL
   3.703 -SDL_Convert_U16LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.704 -{
   3.705 -    int i;
   3.706 -    const Uint16 *src;
   3.707 -    Sint32 *dst;
   3.708 -
   3.709 -#if DEBUG_CONVERT
   3.710 -    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S32LSB.\n");
   3.711 -#endif
   3.712 -
   3.713 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.714 -    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.715 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   3.716 -        const Sint32 val = (((Sint32) ((SDL_SwapLE16(*src)) ^ 0x8000)) << 16);
   3.717 -        *dst = ((Sint32) SDL_SwapLE32(val));
   3.718 -    }
   3.719 -
   3.720 -    cvt->len_cvt *= 2;
   3.721 -    if (cvt->filters[++cvt->filter_index]) {
   3.722 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
   3.723 -    }
   3.724 -}
   3.725 -
   3.726 -static void SDLCALL
   3.727 -SDL_Convert_U16LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.728 -{
   3.729 -    int i;
   3.730 -    const Uint16 *src;
   3.731 -    Sint32 *dst;
   3.732 -
   3.733 -#if DEBUG_CONVERT
   3.734 -    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S32MSB.\n");
   3.735 -#endif
   3.736 -
   3.737 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.738 -    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.739 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   3.740 -        const Sint32 val = (((Sint32) ((SDL_SwapLE16(*src)) ^ 0x8000)) << 16);
   3.741 -        *dst = ((Sint32) SDL_SwapBE32(val));
   3.742 -    }
   3.743 -
   3.744 -    cvt->len_cvt *= 2;
   3.745 -    if (cvt->filters[++cvt->filter_index]) {
   3.746 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
   3.747 -    }
   3.748 -}
   3.749 -
   3.750 -static void SDLCALL
   3.751 -SDL_Convert_U16LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.752 -{
   3.753 -    int i;
   3.754 -    const Uint16 *src;
   3.755 -    float *dst;
   3.756 -
   3.757 -#if DEBUG_CONVERT
   3.758 -    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_F32LSB.\n");
   3.759 -#endif
   3.760 -
   3.761 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.762 -    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.763 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   3.764 -        const float val = ((((float) SDL_SwapLE16(*src)) * DIVBY32767) - 1.0f);
   3.765 -        *dst = SDL_SwapFloatLE(val);
   3.766 -    }
   3.767 -
   3.768 -    cvt->len_cvt *= 2;
   3.769 -    if (cvt->filters[++cvt->filter_index]) {
   3.770 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
   3.771 -    }
   3.772 -}
   3.773 -
   3.774 -static void SDLCALL
   3.775 -SDL_Convert_U16LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.776 -{
   3.777 -    int i;
   3.778 -    const Uint16 *src;
   3.779 -    float *dst;
   3.780 -
   3.781 -#if DEBUG_CONVERT
   3.782 -    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_F32MSB.\n");
   3.783 -#endif
   3.784 -
   3.785 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.786 -    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.787 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   3.788 -        const float val = ((((float) SDL_SwapLE16(*src)) * DIVBY32767) - 1.0f);
   3.789 -        *dst = SDL_SwapFloatBE(val);
   3.790 -    }
   3.791 -
   3.792 -    cvt->len_cvt *= 2;
   3.793 -    if (cvt->filters[++cvt->filter_index]) {
   3.794 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
   3.795 -    }
   3.796 -}
   3.797 -
   3.798 -static void SDLCALL
   3.799 -SDL_Convert_S16LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.800 -{
   3.801 -    int i;
   3.802 -    const Uint16 *src;
   3.803 -    Uint8 *dst;
   3.804 -
   3.805 -#if DEBUG_CONVERT
   3.806 -    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U8.\n");
   3.807 -#endif
   3.808 -
   3.809 -    src = (const Uint16 *) cvt->buf;
   3.810 -    dst = (Uint8 *) cvt->buf;
   3.811 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   3.812 -        const Uint8 val = ((Uint8) (((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000) >> 8));
   3.813 -        *dst = val;
   3.814 -    }
   3.815 -
   3.816 -    cvt->len_cvt /= 2;
   3.817 -    if (cvt->filters[++cvt->filter_index]) {
   3.818 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
   3.819 -    }
   3.820 -}
   3.821 -
   3.822 -static void SDLCALL
   3.823 -SDL_Convert_S16LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.824 -{
   3.825 -    int i;
   3.826 -    const Uint16 *src;
   3.827 -    Sint8 *dst;
   3.828 -
   3.829 -#if DEBUG_CONVERT
   3.830 -    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S8.\n");
   3.831 -#endif
   3.832 -
   3.833 -    src = (const Uint16 *) cvt->buf;
   3.834 -    dst = (Sint8 *) cvt->buf;
   3.835 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   3.836 -        const Sint8 val = ((Sint8) (((Sint16) SDL_SwapLE16(*src)) >> 8));
   3.837 -        *dst = ((Sint8) val);
   3.838 -    }
   3.839 -
   3.840 -    cvt->len_cvt /= 2;
   3.841 -    if (cvt->filters[++cvt->filter_index]) {
   3.842 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
   3.843 -    }
   3.844 -}
   3.845 -
   3.846 -static void SDLCALL
   3.847 -SDL_Convert_S16LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.848 -{
   3.849 -    int i;
   3.850 -    const Uint16 *src;
   3.851 -    Uint16 *dst;
   3.852 -
   3.853 -#if DEBUG_CONVERT
   3.854 -    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U16LSB.\n");
   3.855 -#endif
   3.856 -
   3.857 -    src = (const Uint16 *) cvt->buf;
   3.858 -    dst = (Uint16 *) cvt->buf;
   3.859 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   3.860 -        const Uint16 val = ((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000);
   3.861 -        *dst = SDL_SwapLE16(val);
   3.862 -    }
   3.863 -
   3.864 -    if (cvt->filters[++cvt->filter_index]) {
   3.865 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
   3.866 -    }
   3.867 -}
   3.868 -
   3.869 -static void SDLCALL
   3.870 -SDL_Convert_S16LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.871 -{
   3.872 -    int i;
   3.873 -    const Uint16 *src;
   3.874 -    Uint16 *dst;
   3.875 -
   3.876 -#if DEBUG_CONVERT
   3.877 -    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U16MSB.\n");
   3.878 -#endif
   3.879 -
   3.880 -    src = (const Uint16 *) cvt->buf;
   3.881 -    dst = (Uint16 *) cvt->buf;
   3.882 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   3.883 -        const Uint16 val = ((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000);
   3.884 -        *dst = SDL_SwapBE16(val);
   3.885 -    }
   3.886 -
   3.887 -    if (cvt->filters[++cvt->filter_index]) {
   3.888 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
   3.889 -    }
   3.890 -}
   3.891 -
   3.892 -static void SDLCALL
   3.893 -SDL_Convert_S16LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.894 -{
   3.895 -    int i;
   3.896 -    const Uint16 *src;
   3.897 -    Sint16 *dst;
   3.898 -
   3.899 -#if DEBUG_CONVERT
   3.900 -    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S16MSB.\n");
   3.901 -#endif
   3.902 -
   3.903 -    src = (const Uint16 *) cvt->buf;
   3.904 -    dst = (Sint16 *) cvt->buf;
   3.905 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   3.906 -        const Sint16 val = ((Sint16) SDL_SwapLE16(*src));
   3.907 -        *dst = ((Sint16) SDL_SwapBE16(val));
   3.908 -    }
   3.909 -
   3.910 -    if (cvt->filters[++cvt->filter_index]) {
   3.911 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
   3.912 -    }
   3.913 -}
   3.914 -
   3.915 -static void SDLCALL
   3.916 -SDL_Convert_S16LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.917 -{
   3.918 -    int i;
   3.919 -    const Uint16 *src;
   3.920 -    Sint32 *dst;
   3.921 -
   3.922 -#if DEBUG_CONVERT
   3.923 -    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S32LSB.\n");
   3.924 -#endif
   3.925 -
   3.926 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.927 -    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.928 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   3.929 -        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapLE16(*src))) << 16);
   3.930 -        *dst = ((Sint32) SDL_SwapLE32(val));
   3.931 -    }
   3.932 -
   3.933 -    cvt->len_cvt *= 2;
   3.934 -    if (cvt->filters[++cvt->filter_index]) {
   3.935 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
   3.936 -    }
   3.937 -}
   3.938 -
   3.939 -static void SDLCALL
   3.940 -SDL_Convert_S16LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.941 -{
   3.942 -    int i;
   3.943 -    const Uint16 *src;
   3.944 -    Sint32 *dst;
   3.945 -
   3.946 -#if DEBUG_CONVERT
   3.947 -    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S32MSB.\n");
   3.948 -#endif
   3.949 -
   3.950 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.951 -    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.952 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   3.953 -        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapLE16(*src))) << 16);
   3.954 -        *dst = ((Sint32) SDL_SwapBE32(val));
   3.955 -    }
   3.956 -
   3.957 -    cvt->len_cvt *= 2;
   3.958 -    if (cvt->filters[++cvt->filter_index]) {
   3.959 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
   3.960 -    }
   3.961 -}
   3.962 -
   3.963 -static void SDLCALL
   3.964 -SDL_Convert_S16LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.965 -{
   3.966 -    int i;
   3.967 -    const Uint16 *src;
   3.968 -    float *dst;
   3.969 -
   3.970 -#if DEBUG_CONVERT
   3.971 -    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_F32LSB.\n");
   3.972 -#endif
   3.973 -
   3.974 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.975 -    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   3.976 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   3.977 -        const float val = (((float) ((Sint16) SDL_SwapLE16(*src))) * DIVBY32767);
   3.978 -        *dst = SDL_SwapFloatLE(val);
   3.979 -    }
   3.980 -
   3.981 -    cvt->len_cvt *= 2;
   3.982 -    if (cvt->filters[++cvt->filter_index]) {
   3.983 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
   3.984 -    }
   3.985 -}
   3.986 -
   3.987 -static void SDLCALL
   3.988 -SDL_Convert_S16LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.989 -{
   3.990 -    int i;
   3.991 -    const Uint16 *src;
   3.992 -    float *dst;
   3.993 -
   3.994 -#if DEBUG_CONVERT
   3.995 -    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_F32MSB.\n");
   3.996 -#endif
   3.997 -
   3.998 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   3.999 -    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
  3.1000 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  3.1001 -        const float val = (((float) ((Sint16) SDL_SwapLE16(*src))) * DIVBY32767);
  3.1002 -        *dst = SDL_SwapFloatBE(val);
  3.1003 -    }
  3.1004 -
  3.1005 -    cvt->len_cvt *= 2;
  3.1006 -    if (cvt->filters[++cvt->filter_index]) {
  3.1007 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
  3.1008 -    }
  3.1009 -}
  3.1010 -
  3.1011 -static void SDLCALL
  3.1012 -SDL_Convert_U16MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1013 -{
  3.1014 -    int i;
  3.1015 -    const Uint16 *src;
  3.1016 -    Uint8 *dst;
  3.1017 -
  3.1018 -#if DEBUG_CONVERT
  3.1019 -    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_U8.\n");
  3.1020 -#endif
  3.1021 -
  3.1022 -    src = (const Uint16 *) cvt->buf;
  3.1023 -    dst = (Uint8 *) cvt->buf;
  3.1024 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  3.1025 -        const Uint8 val = ((Uint8) (SDL_SwapBE16(*src) >> 8));
  3.1026 -        *dst = val;
  3.1027 -    }
  3.1028 -
  3.1029 -    cvt->len_cvt /= 2;
  3.1030 -    if (cvt->filters[++cvt->filter_index]) {
  3.1031 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
  3.1032 -    }
  3.1033 -}
  3.1034 -
  3.1035 -static void SDLCALL
  3.1036 -SDL_Convert_U16MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1037 -{
  3.1038 -    int i;
  3.1039 -    const Uint16 *src;
  3.1040 -    Sint8 *dst;
  3.1041 -
  3.1042 -#if DEBUG_CONVERT
  3.1043 -    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S8.\n");
  3.1044 -#endif
  3.1045 -
  3.1046 -    src = (const Uint16 *) cvt->buf;
  3.1047 -    dst = (Sint8 *) cvt->buf;
  3.1048 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  3.1049 -        const Sint8 val = ((Sint8) (((SDL_SwapBE16(*src)) ^ 0x8000) >> 8));
  3.1050 -        *dst = ((Sint8) val);
  3.1051 -    }
  3.1052 -
  3.1053 -    cvt->len_cvt /= 2;
  3.1054 -    if (cvt->filters[++cvt->filter_index]) {
  3.1055 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
  3.1056 -    }
  3.1057 -}
  3.1058 -
  3.1059 -static void SDLCALL
  3.1060 -SDL_Convert_U16MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1061 -{
  3.1062 -    int i;
  3.1063 -    const Uint16 *src;
  3.1064 -    Uint16 *dst;
  3.1065 -
  3.1066 -#if DEBUG_CONVERT
  3.1067 -    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_U16LSB.\n");
  3.1068 -#endif
  3.1069 -
  3.1070 -    src = (const Uint16 *) cvt->buf;
  3.1071 -    dst = (Uint16 *) cvt->buf;
  3.1072 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  3.1073 -        const Uint16 val = SDL_SwapBE16(*src);
  3.1074 -        *dst = SDL_SwapLE16(val);
  3.1075 -    }
  3.1076 -
  3.1077 -    if (cvt->filters[++cvt->filter_index]) {
  3.1078 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
  3.1079 -    }
  3.1080 -}
  3.1081 -
  3.1082 -static void SDLCALL
  3.1083 -SDL_Convert_U16MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1084 -{
  3.1085 -    int i;
  3.1086 -    const Uint16 *src;
  3.1087 -    Sint16 *dst;
  3.1088 -
  3.1089 -#if DEBUG_CONVERT
  3.1090 -    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S16LSB.\n");
  3.1091 -#endif
  3.1092 -
  3.1093 -    src = (const Uint16 *) cvt->buf;
  3.1094 -    dst = (Sint16 *) cvt->buf;
  3.1095 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  3.1096 -        const Sint16 val = ((SDL_SwapBE16(*src)) ^ 0x8000);
  3.1097 -        *dst = ((Sint16) SDL_SwapLE16(val));
  3.1098 -    }
  3.1099 -
  3.1100 -    if (cvt->filters[++cvt->filter_index]) {
  3.1101 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
  3.1102 -    }
  3.1103 -}
  3.1104 -
  3.1105 -static void SDLCALL
  3.1106 -SDL_Convert_U16MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1107 -{
  3.1108 -    int i;
  3.1109 -    const Uint16 *src;
  3.1110 -    Sint16 *dst;
  3.1111 -
  3.1112 -#if DEBUG_CONVERT
  3.1113 -    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S16MSB.\n");
  3.1114 -#endif
  3.1115 -
  3.1116 -    src = (const Uint16 *) cvt->buf;
  3.1117 -    dst = (Sint16 *) cvt->buf;
  3.1118 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  3.1119 -        const Sint16 val = ((SDL_SwapBE16(*src)) ^ 0x8000);
  3.1120 -        *dst = ((Sint16) SDL_SwapBE16(val));
  3.1121 -    }
  3.1122 -
  3.1123 -    if (cvt->filters[++cvt->filter_index]) {
  3.1124 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
  3.1125 -    }
  3.1126 -}
  3.1127 -
  3.1128 -static void SDLCALL
  3.1129 -SDL_Convert_U16MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1130 -{
  3.1131 -    int i;
  3.1132 -    const Uint16 *src;
  3.1133 -    Sint32 *dst;
  3.1134 -
  3.1135 -#if DEBUG_CONVERT
  3.1136 -    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S32LSB.\n");
  3.1137 -#endif
  3.1138 -
  3.1139 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.1140 -    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
  3.1141 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  3.1142 -        const Sint32 val = (((Sint32) ((SDL_SwapBE16(*src)) ^ 0x8000)) << 16);
  3.1143 -        *dst = ((Sint32) SDL_SwapLE32(val));
  3.1144 -    }
  3.1145 -
  3.1146 -    cvt->len_cvt *= 2;
  3.1147 -    if (cvt->filters[++cvt->filter_index]) {
  3.1148 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
  3.1149 -    }
  3.1150 -}
  3.1151 -
  3.1152 -static void SDLCALL
  3.1153 -SDL_Convert_U16MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1154 -{
  3.1155 -    int i;
  3.1156 -    const Uint16 *src;
  3.1157 -    Sint32 *dst;
  3.1158 -
  3.1159 -#if DEBUG_CONVERT
  3.1160 -    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S32MSB.\n");
  3.1161 -#endif
  3.1162 -
  3.1163 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.1164 -    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
  3.1165 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  3.1166 -        const Sint32 val = (((Sint32) ((SDL_SwapBE16(*src)) ^ 0x8000)) << 16);
  3.1167 -        *dst = ((Sint32) SDL_SwapBE32(val));
  3.1168 -    }
  3.1169 -
  3.1170 -    cvt->len_cvt *= 2;
  3.1171 -    if (cvt->filters[++cvt->filter_index]) {
  3.1172 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
  3.1173 -    }
  3.1174 -}
  3.1175 -
  3.1176 -static void SDLCALL
  3.1177 -SDL_Convert_U16MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1178 -{
  3.1179 -    int i;
  3.1180 -    const Uint16 *src;
  3.1181 -    float *dst;
  3.1182 -
  3.1183 -#if DEBUG_CONVERT
  3.1184 -    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_F32LSB.\n");
  3.1185 -#endif
  3.1186 -
  3.1187 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.1188 -    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
  3.1189 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  3.1190 -        const float val = ((((float) SDL_SwapBE16(*src)) * DIVBY32767) - 1.0f);
  3.1191 -        *dst = SDL_SwapFloatLE(val);
  3.1192 -    }
  3.1193 -
  3.1194 -    cvt->len_cvt *= 2;
  3.1195 -    if (cvt->filters[++cvt->filter_index]) {
  3.1196 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
  3.1197 -    }
  3.1198 -}
  3.1199 -
  3.1200 -static void SDLCALL
  3.1201 -SDL_Convert_U16MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1202 -{
  3.1203 -    int i;
  3.1204 -    const Uint16 *src;
  3.1205 -    float *dst;
  3.1206 -
  3.1207 -#if DEBUG_CONVERT
  3.1208 -    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_F32MSB.\n");
  3.1209 -#endif
  3.1210 -
  3.1211 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.1212 -    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
  3.1213 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  3.1214 -        const float val = ((((float) SDL_SwapBE16(*src)) * DIVBY32767) - 1.0f);
  3.1215 -        *dst = SDL_SwapFloatBE(val);
  3.1216 -    }
  3.1217 -
  3.1218 -    cvt->len_cvt *= 2;
  3.1219 -    if (cvt->filters[++cvt->filter_index]) {
  3.1220 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
  3.1221 -    }
  3.1222 -}
  3.1223 -
  3.1224 -static void SDLCALL
  3.1225 -SDL_Convert_S16MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1226 -{
  3.1227 -    int i;
  3.1228 -    const Uint16 *src;
  3.1229 -    Uint8 *dst;
  3.1230 -
  3.1231 -#if DEBUG_CONVERT
  3.1232 -    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U8.\n");
  3.1233 -#endif
  3.1234 -
  3.1235 -    src = (const Uint16 *) cvt->buf;
  3.1236 -    dst = (Uint8 *) cvt->buf;
  3.1237 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  3.1238 -        const Uint8 val = ((Uint8) (((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000) >> 8));
  3.1239 -        *dst = val;
  3.1240 -    }
  3.1241 -
  3.1242 -    cvt->len_cvt /= 2;
  3.1243 -    if (cvt->filters[++cvt->filter_index]) {
  3.1244 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
  3.1245 -    }
  3.1246 -}
  3.1247 -
  3.1248 -static void SDLCALL
  3.1249 -SDL_Convert_S16MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1250 -{
  3.1251 -    int i;
  3.1252 -    const Uint16 *src;
  3.1253 -    Sint8 *dst;
  3.1254 -
  3.1255 -#if DEBUG_CONVERT
  3.1256 -    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S8.\n");
  3.1257 -#endif
  3.1258 -
  3.1259 -    src = (const Uint16 *) cvt->buf;
  3.1260 -    dst = (Sint8 *) cvt->buf;
  3.1261 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  3.1262 -        const Sint8 val = ((Sint8) (((Sint16) SDL_SwapBE16(*src)) >> 8));
  3.1263 -        *dst = ((Sint8) val);
  3.1264 -    }
  3.1265 -
  3.1266 -    cvt->len_cvt /= 2;
  3.1267 -    if (cvt->filters[++cvt->filter_index]) {
  3.1268 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
  3.1269 -    }
  3.1270 -}
  3.1271 -
  3.1272 -static void SDLCALL
  3.1273 -SDL_Convert_S16MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1274 -{
  3.1275 -    int i;
  3.1276 -    const Uint16 *src;
  3.1277 -    Uint16 *dst;
  3.1278 -
  3.1279 -#if DEBUG_CONVERT
  3.1280 -    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U16LSB.\n");
  3.1281 -#endif
  3.1282 -
  3.1283 -    src = (const Uint16 *) cvt->buf;
  3.1284 -    dst = (Uint16 *) cvt->buf;
  3.1285 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  3.1286 -        const Uint16 val = ((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000);
  3.1287 -        *dst = SDL_SwapLE16(val);
  3.1288 -    }
  3.1289 -
  3.1290 -    if (cvt->filters[++cvt->filter_index]) {
  3.1291 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
  3.1292 -    }
  3.1293 -}
  3.1294 -
  3.1295 -static void SDLCALL
  3.1296 -SDL_Convert_S16MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1297 -{
  3.1298 -    int i;
  3.1299 -    const Uint16 *src;
  3.1300 -    Sint16 *dst;
  3.1301 -
  3.1302 -#if DEBUG_CONVERT
  3.1303 -    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S16LSB.\n");
  3.1304 -#endif
  3.1305 -
  3.1306 -    src = (const Uint16 *) cvt->buf;
  3.1307 -    dst = (Sint16 *) cvt->buf;
  3.1308 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  3.1309 -        const Sint16 val = ((Sint16) SDL_SwapBE16(*src));
  3.1310 -        *dst = ((Sint16) SDL_SwapLE16(val));
  3.1311 -    }
  3.1312 -
  3.1313 -    if (cvt->filters[++cvt->filter_index]) {
  3.1314 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
  3.1315 -    }
  3.1316 -}
  3.1317 -
  3.1318 -static void SDLCALL
  3.1319 -SDL_Convert_S16MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1320 -{
  3.1321 -    int i;
  3.1322 -    const Uint16 *src;
  3.1323 -    Uint16 *dst;
  3.1324 -
  3.1325 -#if DEBUG_CONVERT
  3.1326 -    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U16MSB.\n");
  3.1327 -#endif
  3.1328 -
  3.1329 -    src = (const Uint16 *) cvt->buf;
  3.1330 -    dst = (Uint16 *) cvt->buf;
  3.1331 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  3.1332 -        const Uint16 val = ((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000);
  3.1333 -        *dst = SDL_SwapBE16(val);
  3.1334 -    }
  3.1335 -
  3.1336 -    if (cvt->filters[++cvt->filter_index]) {
  3.1337 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
  3.1338 -    }
  3.1339 -}
  3.1340 -
  3.1341 -static void SDLCALL
  3.1342 -SDL_Convert_S16MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1343 -{
  3.1344 -    int i;
  3.1345 -    const Uint16 *src;
  3.1346 -    Sint32 *dst;
  3.1347 -
  3.1348 -#if DEBUG_CONVERT
  3.1349 -    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S32LSB.\n");
  3.1350 -#endif
  3.1351 -
  3.1352 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.1353 -    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
  3.1354 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  3.1355 -        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapBE16(*src))) << 16);
  3.1356 -        *dst = ((Sint32) SDL_SwapLE32(val));
  3.1357 -    }
  3.1358 -
  3.1359 -    cvt->len_cvt *= 2;
  3.1360 -    if (cvt->filters[++cvt->filter_index]) {
  3.1361 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
  3.1362 -    }
  3.1363 -}
  3.1364 -
  3.1365 -static void SDLCALL
  3.1366 -SDL_Convert_S16MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1367 -{
  3.1368 -    int i;
  3.1369 -    const Uint16 *src;
  3.1370 -    Sint32 *dst;
  3.1371 -
  3.1372 -#if DEBUG_CONVERT
  3.1373 -    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S32MSB.\n");
  3.1374 -#endif
  3.1375 -
  3.1376 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.1377 -    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
  3.1378 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  3.1379 -        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapBE16(*src))) << 16);
  3.1380 -        *dst = ((Sint32) SDL_SwapBE32(val));
  3.1381 -    }
  3.1382 -
  3.1383 -    cvt->len_cvt *= 2;
  3.1384 -    if (cvt->filters[++cvt->filter_index]) {
  3.1385 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
  3.1386 -    }
  3.1387 -}
  3.1388 -
  3.1389 -static void SDLCALL
  3.1390 -SDL_Convert_S16MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1391 -{
  3.1392 -    int i;
  3.1393 -    const Uint16 *src;
  3.1394 -    float *dst;
  3.1395 -
  3.1396 -#if DEBUG_CONVERT
  3.1397 -    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_F32LSB.\n");
  3.1398 -#endif
  3.1399 -
  3.1400 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.1401 -    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
  3.1402 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  3.1403 -        const float val = (((float) ((Sint16) SDL_SwapBE16(*src))) * DIVBY32767);
  3.1404 -        *dst = SDL_SwapFloatLE(val);
  3.1405 -    }
  3.1406 -
  3.1407 -    cvt->len_cvt *= 2;
  3.1408 -    if (cvt->filters[++cvt->filter_index]) {
  3.1409 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
  3.1410 -    }
  3.1411 -}
  3.1412 -
  3.1413 -static void SDLCALL
  3.1414 -SDL_Convert_S16MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1415 -{
  3.1416 -    int i;
  3.1417 -    const Uint16 *src;
  3.1418 -    float *dst;
  3.1419 -
  3.1420 -#if DEBUG_CONVERT
  3.1421 -    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_F32MSB.\n");
  3.1422 -#endif
  3.1423 -
  3.1424 -    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.1425 -    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
  3.1426 -    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  3.1427 -        const float val = (((float) ((Sint16) SDL_SwapBE16(*src))) * DIVBY32767);
  3.1428 -        *dst = SDL_SwapFloatBE(val);
  3.1429 -    }
  3.1430 -
  3.1431 -    cvt->len_cvt *= 2;
  3.1432 -    if (cvt->filters[++cvt->filter_index]) {
  3.1433 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
  3.1434 -    }
  3.1435 -}
  3.1436 -
  3.1437 -static void SDLCALL
  3.1438 -SDL_Convert_S32LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1439 -{
  3.1440 -    int i;
  3.1441 -    const Uint32 *src;
  3.1442 -    Uint8 *dst;
  3.1443 -
  3.1444 -#if DEBUG_CONVERT
  3.1445 -    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U8.\n");
  3.1446 -#endif
  3.1447 -
  3.1448 -    src = (const Uint32 *) cvt->buf;
  3.1449 -    dst = (Uint8 *) cvt->buf;
  3.1450 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1451 -        const Uint8 val = ((Uint8) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 24));
  3.1452 -        *dst = val;
  3.1453 -    }
  3.1454 -
  3.1455 -    cvt->len_cvt /= 4;
  3.1456 -    if (cvt->filters[++cvt->filter_index]) {
  3.1457 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
  3.1458 -    }
  3.1459 -}
  3.1460 -
  3.1461 -static void SDLCALL
  3.1462 -SDL_Convert_S32LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1463 -{
  3.1464 -    int i;
  3.1465 -    const Uint32 *src;
  3.1466 -    Sint8 *dst;
  3.1467 -
  3.1468 -#if DEBUG_CONVERT
  3.1469 -    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S8.\n");
  3.1470 -#endif
  3.1471 -
  3.1472 -    src = (const Uint32 *) cvt->buf;
  3.1473 -    dst = (Sint8 *) cvt->buf;
  3.1474 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1475 -        const Sint8 val = ((Sint8) (((Sint32) SDL_SwapLE32(*src)) >> 24));
  3.1476 -        *dst = ((Sint8) val);
  3.1477 -    }
  3.1478 -
  3.1479 -    cvt->len_cvt /= 4;
  3.1480 -    if (cvt->filters[++cvt->filter_index]) {
  3.1481 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
  3.1482 -    }
  3.1483 -}
  3.1484 -
  3.1485 -static void SDLCALL
  3.1486 -SDL_Convert_S32LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1487 -{
  3.1488 -    int i;
  3.1489 -    const Uint32 *src;
  3.1490 -    Uint16 *dst;
  3.1491 -
  3.1492 -#if DEBUG_CONVERT
  3.1493 -    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U16LSB.\n");
  3.1494 -#endif
  3.1495 -
  3.1496 -    src = (const Uint32 *) cvt->buf;
  3.1497 -    dst = (Uint16 *) cvt->buf;
  3.1498 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1499 -        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 16));
  3.1500 -        *dst = SDL_SwapLE16(val);
  3.1501 -    }
  3.1502 -
  3.1503 -    cvt->len_cvt /= 2;
  3.1504 -    if (cvt->filters[++cvt->filter_index]) {
  3.1505 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
  3.1506 -    }
  3.1507 -}
  3.1508 -
  3.1509 -static void SDLCALL
  3.1510 -SDL_Convert_S32LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1511 -{
  3.1512 -    int i;
  3.1513 -    const Uint32 *src;
  3.1514 -    Sint16 *dst;
  3.1515 -
  3.1516 -#if DEBUG_CONVERT
  3.1517 -    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S16LSB.\n");
  3.1518 -#endif
  3.1519 -
  3.1520 -    src = (const Uint32 *) cvt->buf;
  3.1521 -    dst = (Sint16 *) cvt->buf;
  3.1522 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1523 -        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapLE32(*src)) >> 16));
  3.1524 -        *dst = ((Sint16) SDL_SwapLE16(val));
  3.1525 -    }
  3.1526 -
  3.1527 -    cvt->len_cvt /= 2;
  3.1528 -    if (cvt->filters[++cvt->filter_index]) {
  3.1529 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
  3.1530 -    }
  3.1531 -}
  3.1532 -
  3.1533 -static void SDLCALL
  3.1534 -SDL_Convert_S32LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1535 -{
  3.1536 -    int i;
  3.1537 -    const Uint32 *src;
  3.1538 -    Uint16 *dst;
  3.1539 -
  3.1540 -#if DEBUG_CONVERT
  3.1541 -    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U16MSB.\n");
  3.1542 -#endif
  3.1543 -
  3.1544 -    src = (const Uint32 *) cvt->buf;
  3.1545 -    dst = (Uint16 *) cvt->buf;
  3.1546 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1547 -        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 16));
  3.1548 -        *dst = SDL_SwapBE16(val);
  3.1549 -    }
  3.1550 -
  3.1551 -    cvt->len_cvt /= 2;
  3.1552 -    if (cvt->filters[++cvt->filter_index]) {
  3.1553 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
  3.1554 -    }
  3.1555 -}
  3.1556 -
  3.1557 -static void SDLCALL
  3.1558 -SDL_Convert_S32LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1559 -{
  3.1560 -    int i;
  3.1561 -    const Uint32 *src;
  3.1562 -    Sint16 *dst;
  3.1563 -
  3.1564 -#if DEBUG_CONVERT
  3.1565 -    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S16MSB.\n");
  3.1566 -#endif
  3.1567 -
  3.1568 -    src = (const Uint32 *) cvt->buf;
  3.1569 -    dst = (Sint16 *) cvt->buf;
  3.1570 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1571 -        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapLE32(*src)) >> 16));
  3.1572 -        *dst = ((Sint16) SDL_SwapBE16(val));
  3.1573 -    }
  3.1574 -
  3.1575 -    cvt->len_cvt /= 2;
  3.1576 -    if (cvt->filters[++cvt->filter_index]) {
  3.1577 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
  3.1578 -    }
  3.1579 -}
  3.1580 -
  3.1581 -static void SDLCALL
  3.1582 -SDL_Convert_S32LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1583 -{
  3.1584 -    int i;
  3.1585 -    const Uint32 *src;
  3.1586 -    Sint32 *dst;
  3.1587 -
  3.1588 -#if DEBUG_CONVERT
  3.1589 -    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S32MSB.\n");
  3.1590 -#endif
  3.1591 -
  3.1592 -    src = (const Uint32 *) cvt->buf;
  3.1593 -    dst = (Sint32 *) cvt->buf;
  3.1594 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1595 -        const Sint32 val = ((Sint32) SDL_SwapLE32(*src));
  3.1596 -        *dst = ((Sint32) SDL_SwapBE32(val));
  3.1597 -    }
  3.1598 -
  3.1599 -    if (cvt->filters[++cvt->filter_index]) {
  3.1600 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
  3.1601 -    }
  3.1602 -}
  3.1603 -
  3.1604 -static void SDLCALL
  3.1605 -SDL_Convert_S32LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1606 -{
  3.1607 -    int i;
  3.1608 -    const Uint32 *src;
  3.1609 -    float *dst;
  3.1610 -
  3.1611 -#if DEBUG_CONVERT
  3.1612 -    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_F32LSB.\n");
  3.1613 -#endif
  3.1614 -
  3.1615 -    src = (const Uint32 *) cvt->buf;
  3.1616 -    dst = (float *) cvt->buf;
  3.1617 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1618 -        const float val = (((float) ((Sint32) SDL_SwapLE32(*src))) * DIVBY2147483647);
  3.1619 -        *dst = SDL_SwapFloatLE(val);
  3.1620 -    }
  3.1621 -
  3.1622 -    if (cvt->filters[++cvt->filter_index]) {
  3.1623 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
  3.1624 -    }
  3.1625 -}
  3.1626 -
  3.1627 -static void SDLCALL
  3.1628 -SDL_Convert_S32LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1629 -{
  3.1630 -    int i;
  3.1631 -    const Uint32 *src;
  3.1632 -    float *dst;
  3.1633 -
  3.1634 -#if DEBUG_CONVERT
  3.1635 -    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_F32MSB.\n");
  3.1636 -#endif
  3.1637 -
  3.1638 -    src = (const Uint32 *) cvt->buf;
  3.1639 -    dst = (float *) cvt->buf;
  3.1640 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1641 -        const float val = (((float) ((Sint32) SDL_SwapLE32(*src))) * DIVBY2147483647);
  3.1642 -        *dst = SDL_SwapFloatBE(val);
  3.1643 -    }
  3.1644 -
  3.1645 -    if (cvt->filters[++cvt->filter_index]) {
  3.1646 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
  3.1647 -    }
  3.1648 -}
  3.1649 -
  3.1650 -static void SDLCALL
  3.1651 -SDL_Convert_S32MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1652 -{
  3.1653 -    int i;
  3.1654 -    const Uint32 *src;
  3.1655 -    Uint8 *dst;
  3.1656 -
  3.1657 -#if DEBUG_CONVERT
  3.1658 -    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U8.\n");
  3.1659 -#endif
  3.1660 -
  3.1661 -    src = (const Uint32 *) cvt->buf;
  3.1662 -    dst = (Uint8 *) cvt->buf;
  3.1663 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1664 -        const Uint8 val = ((Uint8) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 24));
  3.1665 -        *dst = val;
  3.1666 -    }
  3.1667 -
  3.1668 -    cvt->len_cvt /= 4;
  3.1669 -    if (cvt->filters[++cvt->filter_index]) {
  3.1670 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
  3.1671 -    }
  3.1672 -}
  3.1673 -
  3.1674 -static void SDLCALL
  3.1675 -SDL_Convert_S32MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1676 -{
  3.1677 -    int i;
  3.1678 -    const Uint32 *src;
  3.1679 -    Sint8 *dst;
  3.1680 -
  3.1681 -#if DEBUG_CONVERT
  3.1682 -    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S8.\n");
  3.1683 -#endif
  3.1684 -
  3.1685 -    src = (const Uint32 *) cvt->buf;
  3.1686 -    dst = (Sint8 *) cvt->buf;
  3.1687 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1688 -        const Sint8 val = ((Sint8) (((Sint32) SDL_SwapBE32(*src)) >> 24));
  3.1689 -        *dst = ((Sint8) val);
  3.1690 -    }
  3.1691 -
  3.1692 -    cvt->len_cvt /= 4;
  3.1693 -    if (cvt->filters[++cvt->filter_index]) {
  3.1694 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
  3.1695 -    }
  3.1696 -}
  3.1697 -
  3.1698 -static void SDLCALL
  3.1699 -SDL_Convert_S32MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1700 -{
  3.1701 -    int i;
  3.1702 -    const Uint32 *src;
  3.1703 -    Uint16 *dst;
  3.1704 -
  3.1705 -#if DEBUG_CONVERT
  3.1706 -    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U16LSB.\n");
  3.1707 -#endif
  3.1708 -
  3.1709 -    src = (const Uint32 *) cvt->buf;
  3.1710 -    dst = (Uint16 *) cvt->buf;
  3.1711 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1712 -        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 16));
  3.1713 -        *dst = SDL_SwapLE16(val);
  3.1714 -    }
  3.1715 -
  3.1716 -    cvt->len_cvt /= 2;
  3.1717 -    if (cvt->filters[++cvt->filter_index]) {
  3.1718 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
  3.1719 -    }
  3.1720 -}
  3.1721 -
  3.1722 -static void SDLCALL
  3.1723 -SDL_Convert_S32MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1724 -{
  3.1725 -    int i;
  3.1726 -    const Uint32 *src;
  3.1727 -    Sint16 *dst;
  3.1728 -
  3.1729 -#if DEBUG_CONVERT
  3.1730 -    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S16LSB.\n");
  3.1731 -#endif
  3.1732 -
  3.1733 -    src = (const Uint32 *) cvt->buf;
  3.1734 -    dst = (Sint16 *) cvt->buf;
  3.1735 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1736 -        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapBE32(*src)) >> 16));
  3.1737 -        *dst = ((Sint16) SDL_SwapLE16(val));
  3.1738 -    }
  3.1739 -
  3.1740 -    cvt->len_cvt /= 2;
  3.1741 -    if (cvt->filters[++cvt->filter_index]) {
  3.1742 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
  3.1743 -    }
  3.1744 -}
  3.1745 -
  3.1746 -static void SDLCALL
  3.1747 -SDL_Convert_S32MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1748 -{
  3.1749 -    int i;
  3.1750 -    const Uint32 *src;
  3.1751 -    Uint16 *dst;
  3.1752 -
  3.1753 -#if DEBUG_CONVERT
  3.1754 -    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U16MSB.\n");
  3.1755 -#endif
  3.1756 -
  3.1757 -    src = (const Uint32 *) cvt->buf;
  3.1758 -    dst = (Uint16 *) cvt->buf;
  3.1759 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1760 -        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 16));
  3.1761 -        *dst = SDL_SwapBE16(val);
  3.1762 -    }
  3.1763 -
  3.1764 -    cvt->len_cvt /= 2;
  3.1765 -    if (cvt->filters[++cvt->filter_index]) {
  3.1766 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
  3.1767 -    }
  3.1768 -}
  3.1769 -
  3.1770 -static void SDLCALL
  3.1771 -SDL_Convert_S32MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1772 -{
  3.1773 -    int i;
  3.1774 -    const Uint32 *src;
  3.1775 -    Sint16 *dst;
  3.1776 -
  3.1777 -#if DEBUG_CONVERT
  3.1778 -    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S16MSB.\n");
  3.1779 -#endif
  3.1780 -
  3.1781 -    src = (const Uint32 *) cvt->buf;
  3.1782 -    dst = (Sint16 *) cvt->buf;
  3.1783 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1784 -        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapBE32(*src)) >> 16));
  3.1785 -        *dst = ((Sint16) SDL_SwapBE16(val));
  3.1786 -    }
  3.1787 -
  3.1788 -    cvt->len_cvt /= 2;
  3.1789 -    if (cvt->filters[++cvt->filter_index]) {
  3.1790 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
  3.1791 -    }
  3.1792 -}
  3.1793 -
  3.1794 -static void SDLCALL
  3.1795 -SDL_Convert_S32MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1796 -{
  3.1797 -    int i;
  3.1798 -    const Uint32 *src;
  3.1799 -    Sint32 *dst;
  3.1800 -
  3.1801 -#if DEBUG_CONVERT
  3.1802 -    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S32LSB.\n");
  3.1803 -#endif
  3.1804 -
  3.1805 -    src = (const Uint32 *) cvt->buf;
  3.1806 -    dst = (Sint32 *) cvt->buf;
  3.1807 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1808 -        const Sint32 val = ((Sint32) SDL_SwapBE32(*src));
  3.1809 -        *dst = ((Sint32) SDL_SwapLE32(val));
  3.1810 -    }
  3.1811 -
  3.1812 -    if (cvt->filters[++cvt->filter_index]) {
  3.1813 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
  3.1814 -    }
  3.1815 -}
  3.1816 -
  3.1817 -static void SDLCALL
  3.1818 -SDL_Convert_S32MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1819 -{
  3.1820 -    int i;
  3.1821 -    const Uint32 *src;
  3.1822 -    float *dst;
  3.1823 -
  3.1824 -#if DEBUG_CONVERT
  3.1825 -    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_F32LSB.\n");
  3.1826 -#endif
  3.1827 -
  3.1828 -    src = (const Uint32 *) cvt->buf;
  3.1829 -    dst = (float *) cvt->buf;
  3.1830 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1831 -        const float val = (((float) ((Sint32) SDL_SwapBE32(*src))) * DIVBY2147483647);
  3.1832 -        *dst = SDL_SwapFloatLE(val);
  3.1833 -    }
  3.1834 -
  3.1835 -    if (cvt->filters[++cvt->filter_index]) {
  3.1836 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
  3.1837 -    }
  3.1838 -}
  3.1839 -
  3.1840 -static void SDLCALL
  3.1841 -SDL_Convert_S32MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1842 -{
  3.1843 -    int i;
  3.1844 -    const Uint32 *src;
  3.1845 -    float *dst;
  3.1846 -
  3.1847 -#if DEBUG_CONVERT
  3.1848 -    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_F32MSB.\n");
  3.1849 -#endif
  3.1850 -
  3.1851 -    src = (const Uint32 *) cvt->buf;
  3.1852 -    dst = (float *) cvt->buf;
  3.1853 -    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  3.1854 -        const float val = (((float) ((Sint32) SDL_SwapBE32(*src))) * DIVBY2147483647);
  3.1855 -        *dst = SDL_SwapFloatBE(val);
  3.1856 -    }
  3.1857 -
  3.1858 -    if (cvt->filters[++cvt->filter_index]) {
  3.1859 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
  3.1860 -    }
  3.1861 -}
  3.1862 -
  3.1863 -static void SDLCALL
  3.1864 -SDL_Convert_F32LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1865 -{
  3.1866 -    int i;
  3.1867 -    const float *src;
  3.1868 -    Uint8 *dst;
  3.1869 -
  3.1870 -#if DEBUG_CONVERT
  3.1871 -    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U8.\n");
  3.1872 -#endif
  3.1873 -
  3.1874 -    src = (const float *) cvt->buf;
  3.1875 -    dst = (Uint8 *) cvt->buf;
  3.1876 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.1877 -        const Uint8 val = ((Uint8) ((SDL_SwapFloatLE(*src) + 1.0f) * 127.0f));
  3.1878 -        *dst = val;
  3.1879 -    }
  3.1880 -
  3.1881 -    cvt->len_cvt /= 4;
  3.1882 -    if (cvt->filters[++cvt->filter_index]) {
  3.1883 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
  3.1884 -    }
  3.1885 -}
  3.1886 -
  3.1887 -static void SDLCALL
  3.1888 -SDL_Convert_F32LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1889 -{
  3.1890 -    int i;
  3.1891 -    const float *src;
  3.1892 -    Sint8 *dst;
  3.1893 -
  3.1894 -#if DEBUG_CONVERT
  3.1895 -    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S8.\n");
  3.1896 -#endif
  3.1897 -
  3.1898 -    src = (const float *) cvt->buf;
  3.1899 -    dst = (Sint8 *) cvt->buf;
  3.1900 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.1901 -        const Sint8 val = ((Sint8) (SDL_SwapFloatLE(*src) * 127.0f));
  3.1902 -        *dst = ((Sint8) val);
  3.1903 -    }
  3.1904 -
  3.1905 -    cvt->len_cvt /= 4;
  3.1906 -    if (cvt->filters[++cvt->filter_index]) {
  3.1907 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
  3.1908 -    }
  3.1909 -}
  3.1910 -
  3.1911 -static void SDLCALL
  3.1912 -SDL_Convert_F32LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1913 -{
  3.1914 -    int i;
  3.1915 -    const float *src;
  3.1916 -    Uint16 *dst;
  3.1917 -
  3.1918 -#if DEBUG_CONVERT
  3.1919 -    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U16LSB.\n");
  3.1920 -#endif
  3.1921 -
  3.1922 -    src = (const float *) cvt->buf;
  3.1923 -    dst = (Uint16 *) cvt->buf;
  3.1924 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.1925 -        const Uint16 val = ((Uint16) ((SDL_SwapFloatLE(*src) + 1.0f) * 32767.0f));
  3.1926 -        *dst = SDL_SwapLE16(val);
  3.1927 -    }
  3.1928 -
  3.1929 -    cvt->len_cvt /= 2;
  3.1930 -    if (cvt->filters[++cvt->filter_index]) {
  3.1931 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
  3.1932 -    }
  3.1933 -}
  3.1934 -
  3.1935 -static void SDLCALL
  3.1936 -SDL_Convert_F32LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1937 -{
  3.1938 -    int i;
  3.1939 -    const float *src;
  3.1940 -    Sint16 *dst;
  3.1941 -
  3.1942 -#if DEBUG_CONVERT
  3.1943 -    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S16LSB.\n");
  3.1944 -#endif
  3.1945 -
  3.1946 -    src = (const float *) cvt->buf;
  3.1947 -    dst = (Sint16 *) cvt->buf;
  3.1948 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.1949 -        const Sint16 val = ((Sint16) (SDL_SwapFloatLE(*src) * 32767.0f));
  3.1950 -        *dst = ((Sint16) SDL_SwapLE16(val));
  3.1951 -    }
  3.1952 -
  3.1953 -    cvt->len_cvt /= 2;
  3.1954 -    if (cvt->filters[++cvt->filter_index]) {
  3.1955 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
  3.1956 -    }
  3.1957 -}
  3.1958 -
  3.1959 -static void SDLCALL
  3.1960 -SDL_Convert_F32LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1961 -{
  3.1962 -    int i;
  3.1963 -    const float *src;
  3.1964 -    Uint16 *dst;
  3.1965 -
  3.1966 -#if DEBUG_CONVERT
  3.1967 -    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U16MSB.\n");
  3.1968 -#endif
  3.1969 -
  3.1970 -    src = (const float *) cvt->buf;
  3.1971 -    dst = (Uint16 *) cvt->buf;
  3.1972 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.1973 -        const Uint16 val = ((Uint16) ((SDL_SwapFloatLE(*src) + 1.0f) * 32767.0f));
  3.1974 -        *dst = SDL_SwapBE16(val);
  3.1975 -    }
  3.1976 -
  3.1977 -    cvt->len_cvt /= 2;
  3.1978 -    if (cvt->filters[++cvt->filter_index]) {
  3.1979 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
  3.1980 -    }
  3.1981 -}
  3.1982 -
  3.1983 -static void SDLCALL
  3.1984 -SDL_Convert_F32LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1985 -{
  3.1986 -    int i;
  3.1987 -    const float *src;
  3.1988 -    Sint16 *dst;
  3.1989 -
  3.1990 -#if DEBUG_CONVERT
  3.1991 -    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S16MSB.\n");
  3.1992 -#endif
  3.1993 -
  3.1994 -    src = (const float *) cvt->buf;
  3.1995 -    dst = (Sint16 *) cvt->buf;
  3.1996 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.1997 -        const Sint16 val = ((Sint16) (SDL_SwapFloatLE(*src) * 32767.0f));
  3.1998 -        *dst = ((Sint16) SDL_SwapBE16(val));
  3.1999 -    }
  3.2000 -
  3.2001 -    cvt->len_cvt /= 2;
  3.2002 -    if (cvt->filters[++cvt->filter_index]) {
  3.2003 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
  3.2004 -    }
  3.2005 -}
  3.2006 -
  3.2007 -static void SDLCALL
  3.2008 -SDL_Convert_F32LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2009 -{
  3.2010 -    int i;
  3.2011 -    const float *src;
  3.2012 -    Sint32 *dst;
  3.2013 -
  3.2014 -#if DEBUG_CONVERT
  3.2015 -    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S32LSB.\n");
  3.2016 -#endif
  3.2017 -
  3.2018 -    src = (const float *) cvt->buf;
  3.2019 -    dst = (Sint32 *) cvt->buf;
  3.2020 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.2021 -        const Sint32 val = ((Sint32) (SDL_SwapFloatLE(*src) * 2147483647.0));
  3.2022 -        *dst = ((Sint32) SDL_SwapLE32(val));
  3.2023 -    }
  3.2024 -
  3.2025 -    if (cvt->filters[++cvt->filter_index]) {
  3.2026 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
  3.2027 -    }
  3.2028 -}
  3.2029 -
  3.2030 -static void SDLCALL
  3.2031 -SDL_Convert_F32LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2032 -{
  3.2033 -    int i;
  3.2034 -    const float *src;
  3.2035 -    Sint32 *dst;
  3.2036 -
  3.2037 -#if DEBUG_CONVERT
  3.2038 -    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S32MSB.\n");
  3.2039 -#endif
  3.2040 -
  3.2041 -    src = (const float *) cvt->buf;
  3.2042 -    dst = (Sint32 *) cvt->buf;
  3.2043 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.2044 -        const Sint32 val = ((Sint32) (SDL_SwapFloatLE(*src) * 2147483647.0));
  3.2045 -        *dst = ((Sint32) SDL_SwapBE32(val));
  3.2046 -    }
  3.2047 -
  3.2048 -    if (cvt->filters[++cvt->filter_index]) {
  3.2049 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
  3.2050 -    }
  3.2051 -}
  3.2052 -
  3.2053 -static void SDLCALL
  3.2054 -SDL_Convert_F32LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2055 -{
  3.2056 -    int i;
  3.2057 -    const float *src;
  3.2058 -    float *dst;
  3.2059 -
  3.2060 -#if DEBUG_CONVERT
  3.2061 -    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_F32MSB.\n");
  3.2062 -#endif
  3.2063 -
  3.2064 -    src = (const float *) cvt->buf;
  3.2065 -    dst = (float *) cvt->buf;
  3.2066 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.2067 -        const float val = SDL_SwapFloatLE(*src);
  3.2068 -        *dst = SDL_SwapFloatBE(val);
  3.2069 -    }
  3.2070 -
  3.2071 -    if (cvt->filters[++cvt->filter_index]) {
  3.2072 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
  3.2073 -    }
  3.2074 -}
  3.2075 -
  3.2076 -static void SDLCALL
  3.2077 -SDL_Convert_F32MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2078 -{
  3.2079 -    int i;
  3.2080 -    const float *src;
  3.2081 -    Uint8 *dst;
  3.2082 -
  3.2083 -#if DEBUG_CONVERT
  3.2084 -    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U8.\n");
  3.2085 -#endif
  3.2086 -
  3.2087 -    src = (const float *) cvt->buf;
  3.2088 -    dst = (Uint8 *) cvt->buf;
  3.2089 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.2090 -        const Uint8 val = ((Uint8) ((SDL_SwapFloatBE(*src) + 1.0f) * 127.0f));
  3.2091 -        *dst = val;
  3.2092 -    }
  3.2093 -
  3.2094 -    cvt->len_cvt /= 4;
  3.2095 -    if (cvt->filters[++cvt->filter_index]) {
  3.2096 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
  3.2097 -    }
  3.2098 -}
  3.2099 -
  3.2100 -static void SDLCALL
  3.2101 -SDL_Convert_F32MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2102 -{
  3.2103 -    int i;
  3.2104 -    const float *src;
  3.2105 -    Sint8 *dst;
  3.2106 -
  3.2107 -#if DEBUG_CONVERT
  3.2108 -    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S8.\n");
  3.2109 -#endif
  3.2110 -
  3.2111 -    src = (const float *) cvt->buf;
  3.2112 -    dst = (Sint8 *) cvt->buf;
  3.2113 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.2114 -        const Sint8 val = ((Sint8) (SDL_SwapFloatBE(*src) * 127.0f));
  3.2115 -        *dst = ((Sint8) val);
  3.2116 -    }
  3.2117 -
  3.2118 -    cvt->len_cvt /= 4;
  3.2119 -    if (cvt->filters[++cvt->filter_index]) {
  3.2120 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
  3.2121 -    }
  3.2122 -}
  3.2123 -
  3.2124 -static void SDLCALL
  3.2125 -SDL_Convert_F32MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2126 -{
  3.2127 -    int i;
  3.2128 -    const float *src;
  3.2129 -    Uint16 *dst;
  3.2130 -
  3.2131 -#if DEBUG_CONVERT
  3.2132 -    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U16LSB.\n");
  3.2133 -#endif
  3.2134 -
  3.2135 -    src = (const float *) cvt->buf;
  3.2136 -    dst = (Uint16 *) cvt->buf;
  3.2137 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.2138 -        const Uint16 val = ((Uint16) ((SDL_SwapFloatBE(*src) + 1.0f) * 32767.0f));
  3.2139 -        *dst = SDL_SwapLE16(val);
  3.2140 -    }
  3.2141 -
  3.2142 -    cvt->len_cvt /= 2;
  3.2143 -    if (cvt->filters[++cvt->filter_index]) {
  3.2144 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
  3.2145 -    }
  3.2146 -}
  3.2147 -
  3.2148 -static void SDLCALL
  3.2149 -SDL_Convert_F32MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2150 -{
  3.2151 -    int i;
  3.2152 -    const float *src;
  3.2153 -    Sint16 *dst;
  3.2154 -
  3.2155 -#if DEBUG_CONVERT
  3.2156 -    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S16LSB.\n");
  3.2157 -#endif
  3.2158 -
  3.2159 -    src = (const float *) cvt->buf;
  3.2160 -    dst = (Sint16 *) cvt->buf;
  3.2161 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.2162 -        const Sint16 val = ((Sint16) (SDL_SwapFloatBE(*src) * 32767.0f));
  3.2163 -        *dst = ((Sint16) SDL_SwapLE16(val));
  3.2164 -    }
  3.2165 -
  3.2166 -    cvt->len_cvt /= 2;
  3.2167 -    if (cvt->filters[++cvt->filter_index]) {
  3.2168 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
  3.2169 -    }
  3.2170 -}
  3.2171 -
  3.2172 -static void SDLCALL
  3.2173 -SDL_Convert_F32MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2174 -{
  3.2175 -    int i;
  3.2176 -    const float *src;
  3.2177 -    Uint16 *dst;
  3.2178 -
  3.2179 -#if DEBUG_CONVERT
  3.2180 -    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U16MSB.\n");
  3.2181 -#endif
  3.2182 -
  3.2183 -    src = (const float *) cvt->buf;
  3.2184 -    dst = (Uint16 *) cvt->buf;
  3.2185 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.2186 -        const Uint16 val = ((Uint16) ((SDL_SwapFloatBE(*src) + 1.0f) * 32767.0f));
  3.2187 -        *dst = SDL_SwapBE16(val);
  3.2188 -    }
  3.2189 -
  3.2190 -    cvt->len_cvt /= 2;
  3.2191 -    if (cvt->filters[++cvt->filter_index]) {
  3.2192 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
  3.2193 -    }
  3.2194 -}
  3.2195 -
  3.2196 -static void SDLCALL
  3.2197 -SDL_Convert_F32MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2198 -{
  3.2199 -    int i;
  3.2200 -    const float *src;
  3.2201 -    Sint16 *dst;
  3.2202 -
  3.2203 -#if DEBUG_CONVERT
  3.2204 -    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S16MSB.\n");
  3.2205 -#endif
  3.2206 -
  3.2207 -    src = (const float *) cvt->buf;
  3.2208 -    dst = (Sint16 *) cvt->buf;
  3.2209 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.2210 -        const Sint16 val = ((Sint16) (SDL_SwapFloatBE(*src) * 32767.0f));
  3.2211 -        *dst = ((Sint16) SDL_SwapBE16(val));
  3.2212 -    }
  3.2213 -
  3.2214 -    cvt->len_cvt /= 2;
  3.2215 -    if (cvt->filters[++cvt->filter_index]) {
  3.2216 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
  3.2217 -    }
  3.2218 -}
  3.2219 -
  3.2220 -static void SDLCALL
  3.2221 -SDL_Convert_F32MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2222 -{
  3.2223 -    int i;
  3.2224 -    const float *src;
  3.2225 -    Sint32 *dst;
  3.2226 -
  3.2227 -#if DEBUG_CONVERT
  3.2228 -    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S32LSB.\n");
  3.2229 -#endif
  3.2230 -
  3.2231 -    src = (const float *) cvt->buf;
  3.2232 -    dst = (Sint32 *) cvt->buf;
  3.2233 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.2234 -        const Sint32 val = ((Sint32) (SDL_SwapFloatBE(*src) * 2147483647.0));
  3.2235 -        *dst = ((Sint32) SDL_SwapLE32(val));
  3.2236 -    }
  3.2237 -
  3.2238 -    if (cvt->filters[++cvt->filter_index]) {
  3.2239 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
  3.2240 -    }
  3.2241 -}
  3.2242 -
  3.2243 -static void SDLCALL
  3.2244 -SDL_Convert_F32MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2245 -{
  3.2246 -    int i;
  3.2247 -    const float *src;
  3.2248 -    Sint32 *dst;
  3.2249 -
  3.2250 -#if DEBUG_CONVERT
  3.2251 -    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S32MSB.\n");
  3.2252 -#endif
  3.2253 -
  3.2254 -    src = (const float *) cvt->buf;
  3.2255 -    dst = (Sint32 *) cvt->buf;
  3.2256 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.2257 -        const Sint32 val = ((Sint32) (SDL_SwapFloatBE(*src) * 2147483647.0));
  3.2258 -        *dst = ((Sint32) SDL_SwapBE32(val));
  3.2259 -    }
  3.2260 -
  3.2261 -    if (cvt->filters[++cvt->filter_index]) {
  3.2262 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
  3.2263 -    }
  3.2264 -}
  3.2265 -
  3.2266 -static void SDLCALL
  3.2267 -SDL_Convert_F32MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2268 -{
  3.2269 -    int i;
  3.2270 -    const float *src;
  3.2271 -    float *dst;
  3.2272 -
  3.2273 -#if DEBUG_CONVERT
  3.2274 -    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_F32LSB.\n");
  3.2275 -#endif
  3.2276 -
  3.2277 -    src = (const float *) cvt->buf;
  3.2278 -    dst = (float *) cvt->buf;
  3.2279 -    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  3.2280 -        const float val = SDL_SwapFloatBE(*src);
  3.2281 -        *dst = SDL_SwapFloatLE(val);
  3.2282 -    }
  3.2283 -
  3.2284 -    if (cvt->filters[++cvt->filter_index]) {
  3.2285 -        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
  3.2286 -    }
  3.2287 -}
  3.2288 -
  3.2289 -#endif  /* !NO_CONVERTERS */
  3.2290 -
  3.2291 -
  3.2292 -const SDL_AudioTypeFilters sdl_audio_type_filters[] =
  3.2293 -{
  3.2294 -#if !NO_CONVERTERS
  3.2295 -    { AUDIO_U8, AUDIO_S8, SDL_Convert_U8_to_S8 },
  3.2296 -    { AUDIO_U8, AUDIO_U16LSB, SDL_Convert_U8_to_U16LSB },
  3.2297 -    { AUDIO_U8, AUDIO_S16LSB, SDL_Convert_U8_to_S16LSB },
  3.2298 -    { AUDIO_U8, AUDIO_U16MSB, SDL_Convert_U8_to_U16MSB },
  3.2299 -    { AUDIO_U8, AUDIO_S16MSB, SDL_Convert_U8_to_S16MSB },
  3.2300 -    { AUDIO_U8, AUDIO_S32LSB, SDL_Convert_U8_to_S32LSB },
  3.2301 -    { AUDIO_U8, AUDIO_S32MSB, SDL_Convert_U8_to_S32MSB },
  3.2302 -    { AUDIO_U8, AUDIO_F32LSB, SDL_Convert_U8_to_F32LSB },
  3.2303 -    { AUDIO_U8, AUDIO_F32MSB, SDL_Convert_U8_to_F32MSB },
  3.2304 -    { AUDIO_S8, AUDIO_U8, SDL_Convert_S8_to_U8 },
  3.2305 -    { AUDIO_S8, AUDIO_U16LSB, SDL_Convert_S8_to_U16LSB },
  3.2306 -    { AUDIO_S8, AUDIO_S16LSB, SDL_Convert_S8_to_S16LSB },
  3.2307 -    { AUDIO_S8, AUDIO_U16MSB, SDL_Convert_S8_to_U16MSB },
  3.2308 -    { AUDIO_S8, AUDIO_S16MSB, SDL_Convert_S8_to_S16MSB },
  3.2309 -    { AUDIO_S8, AUDIO_S32LSB, SDL_Convert_S8_to_S32LSB },
  3.2310 -    { AUDIO_S8, AUDIO_S32MSB, SDL_Convert_S8_to_S32MSB },
  3.2311 -    { AUDIO_S8, AUDIO_F32LSB, SDL_Convert_S8_to_F32LSB },
  3.2312 -    { AUDIO_S8, AUDIO_F32MSB, SDL_Convert_S8_to_F32MSB },
  3.2313 -    { AUDIO_U16LSB, AUDIO_U8, SDL_Convert_U16LSB_to_U8 },
  3.2314 -    { AUDIO_U16LSB, AUDIO_S8, SDL_Convert_U16LSB_to_S8 },
  3.2315 -    { AUDIO_U16LSB, AUDIO_S16LSB, SDL_Convert_U16LSB_to_S16LSB },
  3.2316 -    { AUDIO_U16LSB, AUDIO_U16MSB, SDL_Convert_U16LSB_to_U16MSB },
  3.2317 -    { AUDIO_U16LSB, AUDIO_S16MSB, SDL_Convert_U16LSB_to_S16MSB },
  3.2318 -    { AUDIO_U16LSB, AUDIO_S32LSB, SDL_Convert_U16LSB_to_S32LSB },
  3.2319 -    { AUDIO_U16LSB, AUDIO_S32MSB, SDL_Convert_U16LSB_to_S32MSB },
  3.2320 -    { AUDIO_U16LSB, AUDIO_F32LSB, SDL_Convert_U16LSB_to_F32LSB },
  3.2321 -    { AUDIO_U16LSB, AUDIO_F32MSB, SDL_Convert_U16LSB_to_F32MSB },
  3.2322 -    { AUDIO_S16LSB, AUDIO_U8, SDL_Convert_S16LSB_to_U8 },
  3.2323 -    { AUDIO_S16LSB, AUDIO_S8, SDL_Convert_S16LSB_to_S8 },
  3.2324 -    { AUDIO_S16LSB, AUDIO_U16LSB, SDL_Convert_S16LSB_to_U16LSB },
  3.2325 -    { AUDIO_S16LSB, AUDIO_U16MSB, SDL_Convert_S16LSB_to_U16MSB },
  3.2326 -    { AUDIO_S16LSB, AUDIO_S16MSB, SDL_Convert_S16LSB_to_S16MSB },
  3.2327 -    { AUDIO_S16LSB, AUDIO_S32LSB, SDL_Convert_S16LSB_to_S32LSB },
  3.2328 -    { AUDIO_S16LSB, AUDIO_S32MSB, SDL_Convert_S16LSB_to_S32MSB },
  3.2329 -    { AUDIO_S16LSB, AUDIO_F32LSB, SDL_Convert_S16LSB_to_F32LSB },
  3.2330 -    { AUDIO_S16LSB, AUDIO_F32MSB, SDL_Convert_S16LSB_to_F32MSB },
  3.2331 -    { AUDIO_U16MSB, AUDIO_U8, SDL_Convert_U16MSB_to_U8 },
  3.2332 -    { AUDIO_U16MSB, AUDIO_S8, SDL_Convert_U16MSB_to_S8 },
  3.2333 -    { AUDIO_U16MSB, AUDIO_U16LSB, SDL_Convert_U16MSB_to_U16LSB },
  3.2334 -    { AUDIO_U16MSB, AUDIO_S16LSB, SDL_Convert_U16MSB_to_S16LSB },
  3.2335 -    { AUDIO_U16MSB, AUDIO_S16MSB, SDL_Convert_U16MSB_to_S16MSB },
  3.2336 -    { AUDIO_U16MSB, AUDIO_S32LSB, SDL_Convert_U16MSB_to_S32LSB },
  3.2337 -    { AUDIO_U16MSB, AUDIO_S32MSB, SDL_Convert_U16MSB_to_S32MSB },
  3.2338 -    { AUDIO_U16MSB, AUDIO_F32LSB, SDL_Convert_U16MSB_to_F32LSB },
  3.2339 -    { AUDIO_U16MSB, AUDIO_F32MSB, SDL_Convert_U16MSB_to_F32MSB },
  3.2340 -    { AUDIO_S16MSB, AUDIO_U8, SDL_Convert_S16MSB_to_U8 },
  3.2341 -    { AUDIO_S16MSB, AUDIO_S8, SDL_Convert_S16MSB_to_S8 },
  3.2342 -    { AUDIO_S16MSB, AUDIO_U16LSB, SDL_Convert_S16MSB_to_U16LSB },
  3.2343 -    { AUDIO_S16MSB, AUDIO_S16LSB, SDL_Convert_S16MSB_to_S16LSB },
  3.2344 -    { AUDIO_S16MSB, AUDIO_U16MSB, SDL_Convert_S16MSB_to_U16MSB },
  3.2345 -    { AUDIO_S16MSB, AUDIO_S32LSB, SDL_Convert_S16MSB_to_S32LSB },
  3.2346 -    { AUDIO_S16MSB, AUDIO_S32MSB, SDL_Convert_S16MSB_to_S32MSB },
  3.2347 -    { AUDIO_S16MSB, AUDIO_F32LSB, SDL_Convert_S16MSB_to_F32LSB },
  3.2348 -    { AUDIO_S16MSB, AUDIO_F32MSB, SDL_Convert_S16MSB_to_F32MSB },
  3.2349 -    { AUDIO_S32LSB, AUDIO_U8, SDL_Convert_S32LSB_to_U8 },
  3.2350 -    { AUDIO_S32LSB, AUDIO_S8, SDL_Convert_S32LSB_to_S8 },
  3.2351 -    { AUDIO_S32LSB, AUDIO_U16LSB, SDL_Convert_S32LSB_to_U16LSB },
  3.2352 -    { AUDIO_S32LSB, AUDIO_S16LSB, SDL_Convert_S32LSB_to_S16LSB },
  3.2353 -    { AUDIO_S32LSB, AUDIO_U16MSB, SDL_Convert_S32LSB_to_U16MSB },
  3.2354 -    { AUDIO_S32LSB, AUDIO_S16MSB, SDL_Convert_S32LSB_to_S16MSB },
  3.2355 -    { AUDIO_S32LSB, AUDIO_S32MSB, SDL_Convert_S32LSB_to_S32MSB },
  3.2356 -    { AUDIO_S32LSB, AUDIO_F32LSB, SDL_Convert_S32LSB_to_F32LSB },
  3.2357 -    { AUDIO_S32LSB, AUDIO_F32MSB, SDL_Convert_S32LSB_to_F32MSB },
  3.2358 -    { AUDIO_S32MSB, AUDIO_U8, SDL_Convert_S32MSB_to_U8 },
  3.2359 -    { AUDIO_S32MSB, AUDIO_S8, SDL_Convert_S32MSB_to_S8 },
  3.2360 -    { AUDIO_S32MSB, AUDIO_U16LSB, SDL_Convert_S32MSB_to_U16LSB },
  3.2361 -    { AUDIO_S32MSB, AUDIO_S16LSB, SDL_Convert_S32MSB_to_S16LSB },
  3.2362 -    { AUDIO_S32MSB, AUDIO_U16MSB, SDL_Convert_S32MSB_to_U16MSB },
  3.2363 -    { AUDIO_S32MSB, AUDIO_S16MSB, SDL_Convert_S32MSB_to_S16MSB },
  3.2364 -    { AUDIO_S32MSB, AUDIO_S32LSB, SDL_Convert_S32MSB_to_S32LSB },
  3.2365 -    { AUDIO_S32MSB, AUDIO_F32LSB, SDL_Convert_S32MSB_to_F32LSB },
  3.2366 -    { AUDIO_S32MSB, AUDIO_F32MSB, SDL_Convert_S32MSB_to_F32MSB },
  3.2367 -    { AUDIO_F32LSB, AUDIO_U8, SDL_Convert_F32LSB_to_U8 },
  3.2368 -    { AUDIO_F32LSB, AUDIO_S8, SDL_Convert_F32LSB_to_S8 },
  3.2369 -    { AUDIO_F32LSB, AUDIO_U16LSB, SDL_Convert_F32LSB_to_U16LSB },
  3.2370 -    { AUDIO_F32LSB, AUDIO_S16LSB, SDL_Convert_F32LSB_to_S16LSB },
  3.2371 -    { AUDIO_F32LSB, AUDIO_U16MSB, SDL_Convert_F32LSB_to_U16MSB },
  3.2372 -    { AUDIO_F32LSB, AUDIO_S16MSB, SDL_Convert_F32LSB_to_S16MSB },
  3.2373 -    { AUDIO_F32LSB, AUDIO_S32LSB, SDL_Convert_F32LSB_to_S32LSB },
  3.2374 -    { AUDIO_F32LSB, AUDIO_S32MSB, SDL_Convert_F32LSB_to_S32MSB },
  3.2375 -    { AUDIO_F32LSB, AUDIO_F32MSB, SDL_Convert_F32LSB_to_F32MSB },
  3.2376 -    { AUDIO_F32MSB, AUDIO_U8, SDL_Convert_F32MSB_to_U8 },
  3.2377 -    { AUDIO_F32MSB, AUDIO_S8, SDL_Convert_F32MSB_to_S8 },
  3.2378 -    { AUDIO_F32MSB, AUDIO_U16LSB, SDL_Convert_F32MSB_to_U16LSB },
  3.2379 -    { AUDIO_F32MSB, AUDIO_S16LSB, SDL_Convert_F32MSB_to_S16LSB },
  3.2380 -    { AUDIO_F32MSB, AUDIO_U16MSB, SDL_Convert_F32MSB_to_U16MSB },
  3.2381 -    { AUDIO_F32MSB, AUDIO_S16MSB, SDL_Convert_F32MSB_to_S16MSB },
  3.2382 -    { AUDIO_F32MSB, AUDIO_S32LSB, SDL_Convert_F32MSB_to_S32LSB },
  3.2383 -    { AUDIO_F32MSB, AUDIO_S32MSB, SDL_Convert_F32MSB_to_S32MSB },
  3.2384 -    { AUDIO_F32MSB, AUDIO_F32LSB, SDL_Convert_F32MSB_to_F32LSB },
  3.2385 -#endif  /* !NO_CONVERTERS */
  3.2386 -    { 0, 0, NULL }
  3.2387 -};
  3.2388 -
  3.2389 -
  3.2390 -#if !NO_RESAMPLERS
  3.2391 -
  3.2392 -static void SDLCALL
  3.2393 -SDL_Upsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2394 -{
  3.2395 -#if DEBUG_CONVERT
  3.2396 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 1 channels.\n", cvt->rate_incr);
  3.2397 -#endif
  3.2398 -
  3.2399 -    const int srcsize = cvt->len_cvt - 16;
  3.2400 -    const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
  3.2401 -    register int eps = 0;
  3.2402 -    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1;
  3.2403 -    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.2404 -    const Uint8 *target = ((const Uint8 *) cvt->buf);
  3.2405 -    Uint8 sample0 = src[0];
  3.2406 -    Uint8 last_sample0 = sample0;
  3.2407      while (dst >= target) {
  3.2408 -        dst[0] = sample0;
  3.2409 -        dst--;
  3.2410 -        eps += srcsize;
  3.2411 -        if ((eps << 1) >= dstsize) {
  3.2412 -            src--;
  3.2413 -            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
  3.2414 -            last_sample0 = sample0;
  3.2415 -            eps -= dstsize;
  3.2416 -        }
  3.2417 -    }
  3.2418 -    cvt->len_cvt = dstsize;
  3.2419 -    if (cvt->filters[++cvt->filter_index]) {
  3.2420 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.2421 -    }
  3.2422 -}
  3.2423 -
  3.2424 -static void SDLCALL
  3.2425 -SDL_Downsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2426 -{
  3.2427 -#if DEBUG_CONVERT
  3.2428 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 1 channels.\n", cvt->rate_incr);
  3.2429 -#endif
  3.2430 -
  3.2431 -    const int srcsize = cvt->len_cvt - 16;
  3.2432 -    const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
  3.2433 -    register int eps = 0;
  3.2434 -    Uint8 *dst = (Uint8 *) cvt->buf;
  3.2435 -    const Uint8 *src = (Uint8 *) cvt->buf;
  3.2436 -    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
  3.2437 -    Uint8 sample0 = src[0];
  3.2438 -    Uint8 last_sample0 = sample0;
  3.2439 -    while (dst < target) {
  3.2440 -        src++;
  3.2441 -        eps += dstsize;
  3.2442 -        if ((eps << 1) >= srcsize) {
  3.2443 -            dst[0] = sample0;
  3.2444 -            dst++;
  3.2445 -            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
  3.2446 -            last_sample0 = sample0;
  3.2447 -            eps -= srcsize;
  3.2448 -        }
  3.2449 -    }
  3.2450 -    cvt->len_cvt = dstsize;
  3.2451 -    if (cvt->filters[++cvt->filter_index]) {
  3.2452 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.2453 -    }
  3.2454 -}
  3.2455 -
  3.2456 -static void SDLCALL
  3.2457 -SDL_Upsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2458 -{
  3.2459 -#if DEBUG_CONVERT
  3.2460 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 2 channels.\n", cvt->rate_incr);
  3.2461 -#endif
  3.2462 -
  3.2463 -    const int srcsize = cvt->len_cvt - 32;
  3.2464 -    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
  3.2465 -    register int eps = 0;
  3.2466 -    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2;
  3.2467 -    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
  3.2468 -    const Uint8 *target = ((const Uint8 *) cvt->buf);
  3.2469 -    Uint8 sample1 = src[1];
  3.2470 -    Uint8 sample0 = src[0];
  3.2471 -    Uint8 last_sample1 = sample1;
  3.2472 -    Uint8 last_sample0 = sample0;
  3.2473 -    while (dst >= target) {
  3.2474 -        dst[1] = sample1;
  3.2475 -        dst[0] = sample0;
  3.2476 -        dst -= 2;
  3.2477 -        eps += srcsize;
  3.2478 -        if ((eps << 1) >= dstsize) {
  3.2479 -            src -= 2;
  3.2480 -            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
  3.2481 -            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
  3.2482 -            last_sample1 = sample1;
  3.2483 -            last_sample0 = sample0;
  3.2484 -            eps -= dstsize;
  3.2485 -        }
  3.2486 -    }
  3.2487 -    cvt->len_cvt = dstsize;
  3.2488 -    if (cvt->filters[++cvt->filter_index]) {
  3.2489 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.2490 -    }
  3.2491 -}
  3.2492 -
  3.2493 -static void SDLCALL
  3.2494 -SDL_Downsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2495 -{
  3.2496 -#if DEBUG_CONVERT
  3.2497 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 2 channels.\n", cvt->rate_incr);
  3.2498 -#endif
  3.2499 -
  3.2500 -    const int srcsize = cvt->len_cvt - 32;
  3.2501 -    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
  3.2502 -    register int eps = 0;
  3.2503 -    Uint8 *dst = (Uint8 *) cvt->buf;
  3.2504 -    const Uint8 *src = (Uint8 *) cvt->buf;
  3.2505 -    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
  3.2506 -    Uint8 sample0 = src[0];
  3.2507 -    Uint8 sample1 = src[1];
  3.2508 -    Uint8 last_sample0 = sample0;
  3.2509 -    Uint8 last_sample1 = sample1;
  3.2510 -    while (dst < target) {
  3.2511 -        src += 2;
  3.2512 -        eps += dstsize;
  3.2513 -        if ((eps << 1) >= srcsize) {
  3.2514 -            dst[0] = sample0;
  3.2515 -            dst[1] = sample1;
  3.2516 -            dst += 2;
  3.2517 -            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
  3.2518 -            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
  3.2519 -            last_sample0 = sample0;
  3.2520 -            last_sample1 = sample1;
  3.2521 -            eps -= srcsize;
  3.2522 -        }
  3.2523 -    }
  3.2524 -    cvt->len_cvt = dstsize;
  3.2525 -    if (cvt->filters[++cvt->filter_index]) {
  3.2526 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.2527 -    }
  3.2528 -}
  3.2529 -
  3.2530 -static void SDLCALL
  3.2531 -SDL_Upsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2532 -{
  3.2533 -#if DEBUG_CONVERT
  3.2534 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 4 channels.\n", cvt->rate_incr);
  3.2535 -#endif
  3.2536 -
  3.2537 -    const int srcsize = cvt->len_cvt - 64;
  3.2538 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.2539 -    register int eps = 0;
  3.2540 -    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4;
  3.2541 -    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
  3.2542 -    const Uint8 *target = ((const Uint8 *) cvt->buf);
  3.2543 -    Uint8 sample3 = src[3];
  3.2544 -    Uint8 sample2 = src[2];
  3.2545 -    Uint8 sample1 = src[1];
  3.2546 -    Uint8 sample0 = src[0];
  3.2547 -    Uint8 last_sample3 = sample3;
  3.2548 -    Uint8 last_sample2 = sample2;
  3.2549 -    Uint8 last_sample1 = sample1;
  3.2550 -    Uint8 last_sample0 = sample0;
  3.2551 -    while (dst >= target) {
  3.2552 -        dst[3] = sample3;
  3.2553 -        dst[2] = sample2;
  3.2554 -        dst[1] = sample1;
  3.2555 -        dst[0] = sample0;
  3.2556 -        dst -= 4;
  3.2557 -        eps += srcsize;
  3.2558 -        if ((eps << 1) >= dstsize) {
  3.2559 -            src -= 4;
  3.2560 -            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
  3.2561 -            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
  3.2562 -            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
  3.2563 -            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
  3.2564 -            last_sample3 = sample3;
  3.2565 -            last_sample2 = sample2;
  3.2566 -            last_sample1 = sample1;
  3.2567 -            last_sample0 = sample0;
  3.2568 -            eps -= dstsize;
  3.2569 -        }
  3.2570 -    }
  3.2571 -    cvt->len_cvt = dstsize;
  3.2572 -    if (cvt->filters[++cvt->filter_index]) {
  3.2573 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.2574 -    }
  3.2575 -}
  3.2576 -
  3.2577 -static void SDLCALL
  3.2578 -SDL_Downsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2579 -{
  3.2580 -#if DEBUG_CONVERT
  3.2581 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 4 channels.\n", cvt->rate_incr);
  3.2582 -#endif
  3.2583 -
  3.2584 -    const int srcsize = cvt->len_cvt - 64;
  3.2585 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.2586 -    register int eps = 0;
  3.2587 -    Uint8 *dst = (Uint8 *) cvt->buf;
  3.2588 -    const Uint8 *src = (Uint8 *) cvt->buf;
  3.2589 -    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
  3.2590 -    Uint8 sample0 = src[0];
  3.2591 -    Uint8 sample1 = src[1];
  3.2592 -    Uint8 sample2 = src[2];
  3.2593 -    Uint8 sample3 = src[3];
  3.2594 -    Uint8 last_sample0 = sample0;
  3.2595 -    Uint8 last_sample1 = sample1;
  3.2596 -    Uint8 last_sample2 = sample2;
  3.2597 -    Uint8 last_sample3 = sample3;
  3.2598 -    while (dst < target) {
  3.2599 -        src += 4;
  3.2600 -        eps += dstsize;
  3.2601 -        if ((eps << 1) >= srcsize) {
  3.2602 -            dst[0] = sample0;
  3.2603 -            dst[1] = sample1;
  3.2604 -            dst[2] = sample2;
  3.2605 -            dst[3] = sample3;
  3.2606 -            dst += 4;
  3.2607 -            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
  3.2608 -            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
  3.2609 -            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
  3.2610 -            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
  3.2611 -            last_sample0 = sample0;
  3.2612 -            last_sample1 = sample1;
  3.2613 -            last_sample2 = sample2;
  3.2614 -            last_sample3 = sample3;
  3.2615 -            eps -= srcsize;
  3.2616 -        }
  3.2617 -    }
  3.2618 -    cvt->len_cvt = dstsize;
  3.2619 -    if (cvt->filters[++cvt->filter_index]) {
  3.2620 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.2621 -    }
  3.2622 -}
  3.2623 -
  3.2624 -static void SDLCALL
  3.2625 -SDL_Upsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2626 -{
  3.2627 -#if DEBUG_CONVERT
  3.2628 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 6 channels.\n", cvt->rate_incr);
  3.2629 -#endif
  3.2630 -
  3.2631 -    const int srcsize = cvt->len_cvt - 96;
  3.2632 -    const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
  3.2633 -    register int eps = 0;
  3.2634 -    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6;
  3.2635 -    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
  3.2636 -    const Uint8 *target = ((const Uint8 *) cvt->buf);
  3.2637 -    Uint8 sample5 = src[5];
  3.2638 -    Uint8 sample4 = src[4];
  3.2639 -    Uint8 sample3 = src[3];
  3.2640 -    Uint8 sample2 = src[2];
  3.2641 -    Uint8 sample1 = src[1];
  3.2642 -    Uint8 sample0 = src[0];
  3.2643 -    Uint8 last_sample5 = sample5;
  3.2644 -    Uint8 last_sample4 = sample4;
  3.2645 -    Uint8 last_sample3 = sample3;
  3.2646 -    Uint8 last_sample2 = sample2;
  3.2647 -    Uint8 last_sample1 = sample1;
  3.2648 -    Uint8 last_sample0 = sample0;
  3.2649 -    while (dst >= target) {
  3.2650 -        dst[5] = sample5;
  3.2651 -        dst[4] = sample4;
  3.2652 -        dst[3] = sample3;
  3.2653 -        dst[2] = sample2;
  3.2654 -        dst[1] = sample1;
  3.2655 -        dst[0] = sample0;
  3.2656 -        dst -= 6;
  3.2657 -        eps += srcsize;
  3.2658 -        if ((eps << 1) >= dstsize) {
  3.2659 -            src -= 6;
  3.2660 -            sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
  3.2661 -            sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
  3.2662 -            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
  3.2663 -            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
  3.2664 -            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
  3.2665 -            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
  3.2666 -            last_sample5 = sample5;
  3.2667 -            last_sample4 = sample4;
  3.2668 -            last_sample3 = sample3;
  3.2669 -            last_sample2 = sample2;
  3.2670 -            last_sample1 = sample1;
  3.2671 -            last_sample0 = sample0;
  3.2672 -            eps -= dstsize;
  3.2673 -        }
  3.2674 -    }
  3.2675 -    cvt->len_cvt = dstsize;
  3.2676 -    if (cvt->filters[++cvt->filter_index]) {
  3.2677 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.2678 -    }
  3.2679 -}
  3.2680 -
  3.2681 -static void SDLCALL
  3.2682 -SDL_Downsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2683 -{
  3.2684 -#if DEBUG_CONVERT
  3.2685 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 6 channels.\n", cvt->rate_incr);
  3.2686 -#endif
  3.2687 -
  3.2688 -    const int srcsize = cvt->len_cvt - 96;
  3.2689 -    const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
  3.2690 -    register int eps = 0;
  3.2691 -    Uint8 *dst = (Uint8 *) cvt->buf;
  3.2692 -    const Uint8 *src = (Uint8 *) cvt->buf;
  3.2693 -    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
  3.2694 -    Uint8 sample0 = src[0];
  3.2695 -    Uint8 sample1 = src[1];
  3.2696 -    Uint8 sample2 = src[2];
  3.2697 -    Uint8 sample3 = src[3];
  3.2698 -    Uint8 sample4 = src[4];
  3.2699 -    Uint8 sample5 = src[5];
  3.2700 -    Uint8 last_sample0 = sample0;
  3.2701 -    Uint8 last_sample1 = sample1;
  3.2702 -    Uint8 last_sample2 = sample2;
  3.2703 -    Uint8 last_sample3 = sample3;
  3.2704 -    Uint8 last_sample4 = sample4;
  3.2705 -    Uint8 last_sample5 = sample5;
  3.2706 -    while (dst < target) {
  3.2707 -        src += 6;
  3.2708 -        eps += dstsize;
  3.2709 -        if ((eps << 1) >= srcsize) {
  3.2710 -            dst[0] = sample0;
  3.2711 -            dst[1] = sample1;
  3.2712 -            dst[2] = sample2;
  3.2713 -            dst[3] = sample3;
  3.2714 -            dst[4] = sample4;
  3.2715 -            dst[5] = sample5;
  3.2716 -            dst += 6;
  3.2717 -            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
  3.2718 -            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
  3.2719 -            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
  3.2720 -            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
  3.2721 -            sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
  3.2722 -            sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
  3.2723 -            last_sample0 = sample0;
  3.2724 -            last_sample1 = sample1;
  3.2725 -            last_sample2 = sample2;
  3.2726 -            last_sample3 = sample3;
  3.2727 -            last_sample4 = sample4;
  3.2728 -            last_sample5 = sample5;
  3.2729 -            eps -= srcsize;
  3.2730 -        }
  3.2731 -    }
  3.2732 -    cvt->len_cvt = dstsize;
  3.2733 -    if (cvt->filters[++cvt->filter_index]) {
  3.2734 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.2735 -    }
  3.2736 -}
  3.2737 -
  3.2738 -static void SDLCALL
  3.2739 -SDL_Upsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2740 -{
  3.2741 -#if DEBUG_CONVERT
  3.2742 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 8 channels.\n", cvt->rate_incr);
  3.2743 -#endif
  3.2744 -
  3.2745 -    const int srcsize = cvt->len_cvt - 128;
  3.2746 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.2747 -    register int eps = 0;
  3.2748 -    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8;
  3.2749 -    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
  3.2750 -    const Uint8 *target = ((const Uint8 *) cvt->buf);
  3.2751 -    Uint8 sample7 = src[7];
  3.2752 -    Uint8 sample6 = src[6];
  3.2753 -    Uint8 sample5 = src[5];
  3.2754 -    Uint8 sample4 = src[4];
  3.2755 -    Uint8 sample3 = src[3];
  3.2756 -    Uint8 sample2 = src[2];
  3.2757 -    Uint8 sample1 = src[1];
  3.2758 -    Uint8 sample0 = src[0];
  3.2759 -    Uint8 last_sample7 = sample7;
  3.2760 -    Uint8 last_sample6 = sample6;
  3.2761 -    Uint8 last_sample5 = sample5;
  3.2762 -    Uint8 last_sample4 = sample4;
  3.2763 -    Uint8 last_sample3 = sample3;
  3.2764 -    Uint8 last_sample2 = sample2;
  3.2765 -    Uint8 last_sample1 = sample1;
  3.2766 -    Uint8 last_sample0 = sample0;
  3.2767 -    while (dst >= target) {
  3.2768 -        dst[7] = sample7;
  3.2769 -        dst[6] = sample6;
  3.2770 -        dst[5] = sample5;
  3.2771 -        dst[4] = sample4;
  3.2772 -        dst[3] = sample3;
  3.2773 -        dst[2] = sample2;
  3.2774 -        dst[1] = sample1;
  3.2775 -        dst[0] = sample0;
  3.2776 +        SDL_memcpy(dst, sample, cpy);
  3.2777          dst -= 8;
  3.2778          eps += srcsize;
  3.2779          if ((eps << 1) >= dstsize) {
  3.2780              src -= 8;
  3.2781 -            sample7 = (Uint8) ((((Sint16) src[7]) + ((Sint16) last_sample7)) >> 1);
  3.2782 -            sample6 = (Uint8) ((((Sint16) src[6]) + ((Sint16) last_sample6)) >> 1);
  3.2783 -            sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
  3.2784 -            sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
  3.2785 -            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
  3.2786 -            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
  3.2787 -            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
  3.2788 -            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
  3.2789 -            last_sample7 = sample7;
  3.2790 -            last_sample6 = sample6;
  3.2791 -            last_sample5 = sample5;
  3.2792 -            last_sample4 = sample4;
  3.2793 -            last_sample3 = sample3;
  3.2794 -            last_sample2 = sample2;
  3.2795 -            last_sample1 = sample1;
  3.2796 -            last_sample0 = sample0;
  3.2797 +            for (i = 0; i < channels; i++) {
  3.2798 +                sample[i] = (float) ((((double) src[i]) + ((double) last_sample[i])) * 0.5);
  3.2799 +            }
  3.2800 +            SDL_memcpy(last_sample, sample, cpy);
  3.2801              eps -= dstsize;
  3.2802          }
  3.2803      }
  3.2804 +
  3.2805      cvt->len_cvt = dstsize;
  3.2806      if (cvt->filters[++cvt->filter_index]) {
  3.2807 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.2808 +        cvt->filters[cvt->filter_index](cvt, AUDIO_F32SYS);
  3.2809      }
  3.2810  }
  3.2811  
  3.2812 -static void SDLCALL
  3.2813 -SDL_Downsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2814 +void
  3.2815 +SDL_Downsample_Arbitrary(SDL_AudioCVT *cvt, const int channels)
  3.2816  {
  3.2817 +    const int srcsize = cvt->len_cvt - (64 * channels);
  3.2818 +    const int dstsize = (int) (((double)(cvt->len_cvt/(channels*4))) * cvt->rate_incr) * (channels*4);
  3.2819 +    register int eps = 0;
  3.2820 +    float *dst = (float *) cvt->buf;
  3.2821 +    const float *src = (float *) cvt->buf;
  3.2822 +    const float *target = (const float *) (cvt->buf + dstsize);
  3.2823 +    const size_t cpy = sizeof (float) * channels;
  3.2824 +    float last_sample[8];
  3.2825 +    float sample[8];
  3.2826 +    int i;
  3.2827 +
  3.2828  #if DEBUG_CONVERT
  3.2829 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 8 channels.\n", cvt->rate_incr);
  3.2830 +    fprintf(stderr, "Downsample arbitrary (x%f), %d channels.\n", cvt->rate_incr, channels);
  3.2831  #endif
  3.2832  
  3.2833 -    const int srcsize = cvt->len_cvt - 128;
  3.2834 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.2835 -    register int eps = 0;
  3.2836 -    Uint8 *dst = (Uint8 *) cvt->buf;
  3.2837 -    const Uint8 *src = (Uint8 *) cvt->buf;
  3.2838 -    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
  3.2839 -    Uint8 sample0 = src[0];
  3.2840 -    Uint8 sample1 = src[1];
  3.2841 -    Uint8 sample2 = src[2];
  3.2842 -    Uint8 sample3 = src[3];
  3.2843 -    Uint8 sample4 = src[4];
  3.2844 -    Uint8 sample5 = src[5];
  3.2845 -    Uint8 sample6 = src[6];
  3.2846 -    Uint8 sample7 = src[7];
  3.2847 -    Uint8 last_sample0 = sample0;
  3.2848 -    Uint8 last_sample1 = sample1;
  3.2849 -    Uint8 last_sample2 = sample2;
  3.2850 -    Uint8 last_sample3 = sample3;
  3.2851 -    Uint8 last_sample4 = sample4;
  3.2852 -    Uint8 last_sample5 = sample5;
  3.2853 -    Uint8 last_sample6 = sample6;
  3.2854 -    Uint8 last_sample7 = sample7;
  3.2855 +    SDL_assert(channels <= 8);
  3.2856 +
  3.2857 +    SDL_memcpy(sample, src, cpy);
  3.2858 +    SDL_memcpy(last_sample, src, cpy);
  3.2859 +
  3.2860      while (dst < target) {
  3.2861          src += 8;
  3.2862          eps += dstsize;
  3.2863          if ((eps << 1) >= srcsize) {
  3.2864 -            dst[0] = sample0;
  3.2865 -            dst[1] = sample1;
  3.2866 -            dst[2] = sample2;
  3.2867 -            dst[3] = sample3;
  3.2868 -            dst[4] = sample4;
  3.2869 -            dst[5] = sample5;
  3.2870 -            dst[6] = sample6;
  3.2871 -            dst[7] = sample7;
  3.2872 +            SDL_memcpy(dst, sample, cpy);
  3.2873              dst += 8;
  3.2874 -            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
  3.2875 -            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
  3.2876 -            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
  3.2877 -            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
  3.2878 -            sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
  3.2879 -            sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
  3.2880 -            sample6 = (Uint8) ((((Sint16) src[6]) + ((Sint16) last_sample6)) >> 1);
  3.2881 -            sample7 = (Uint8) ((((Sint16) src[7]) + ((Sint16) last_sample7)) >> 1);
  3.2882 -            last_sample0 = sample0;
  3.2883 -            last_sample1 = sample1;
  3.2884 -            last_sample2 = sample2;
  3.2885 -            last_sample3 = sample3;
  3.2886 -            last_sample4 = sample4;
  3.2887 -            last_sample5 = sample5;
  3.2888 -            last_sample6 = sample6;
  3.2889 -            last_sample7 = sample7;
  3.2890 +            for (i = 0; i < channels; i++) {
  3.2891 +                sample[i] = (float) ((((double) src[i]) + ((double) last_sample[i])) * 0.5);
  3.2892 +            }
  3.2893 +            SDL_memcpy(last_sample, sample, cpy);
  3.2894              eps -= srcsize;
  3.2895          }
  3.2896      }
  3.2897 -    cvt->len_cvt = dstsize;
  3.2898 -    if (cvt->filters[++cvt->filter_index]) {
  3.2899 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.2900 -    }
  3.2901 -}
  3.2902 -
  3.2903 -static void SDLCALL
  3.2904 -SDL_Upsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2905 -{
  3.2906 -#if DEBUG_CONVERT
  3.2907 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 1 channels.\n", cvt->rate_incr);
  3.2908 -#endif
  3.2909 -
  3.2910 -    const int srcsize = cvt->len_cvt - 16;
  3.2911 -    const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
  3.2912 -    register int eps = 0;
  3.2913 -    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1;
  3.2914 -    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.2915 -    const Sint8 *target = ((const Sint8 *) cvt->buf);
  3.2916 -    Sint8 sample0 = ((Sint8) src[0]);
  3.2917 -    Sint8 last_sample0 = sample0;
  3.2918 -    while (dst >= target) {
  3.2919 -        dst[0] = ((Sint8) sample0);
  3.2920 -        dst--;
  3.2921 -        eps += srcsize;
  3.2922 -        if ((eps << 1) >= dstsize) {
  3.2923 -            src--;
  3.2924 -            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
  3.2925 -            last_sample0 = sample0;
  3.2926 -            eps -= dstsize;
  3.2927 -        }
  3.2928 -    }
  3.2929 -    cvt->len_cvt = dstsize;
  3.2930 -    if (cvt->filters[++cvt->filter_index]) {
  3.2931 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.2932 -    }
  3.2933 -}
  3.2934 -
  3.2935 -static void SDLCALL
  3.2936 -SDL_Downsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2937 -{
  3.2938 -#if DEBUG_CONVERT
  3.2939 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 1 channels.\n", cvt->rate_incr);
  3.2940 -#endif
  3.2941 -
  3.2942 -    const int srcsize = cvt->len_cvt - 16;
  3.2943 -    const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
  3.2944 -    register int eps = 0;
  3.2945 -    Sint8 *dst = (Sint8 *) cvt->buf;
  3.2946 -    const Sint8 *src = (Sint8 *) cvt->buf;
  3.2947 -    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
  3.2948 -    Sint8 sample0 = ((Sint8) src[0]);
  3.2949 -    Sint8 last_sample0 = sample0;
  3.2950 -    while (dst < target) {
  3.2951 -        src++;
  3.2952 -        eps += dstsize;
  3.2953 -        if ((eps << 1) >= srcsize) {
  3.2954 -            dst[0] = ((Sint8) sample0);
  3.2955 -            dst++;
  3.2956 -            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
  3.2957 -            last_sample0 = sample0;
  3.2958 -            eps -= srcsize;
  3.2959 -        }
  3.2960 -    }
  3.2961 -    cvt->len_cvt = dstsize;
  3.2962 -    if (cvt->filters[++cvt->filter_index]) {
  3.2963 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.2964 -    }
  3.2965 -}
  3.2966 -
  3.2967 -static void SDLCALL
  3.2968 -SDL_Upsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.2969 -{
  3.2970 -#if DEBUG_CONVERT
  3.2971 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 2 channels.\n", cvt->rate_incr);
  3.2972 -#endif
  3.2973 -
  3.2974 -    const int srcsize = cvt->len_cvt - 32;
  3.2975 -    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
  3.2976 -    register int eps = 0;
  3.2977 -    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2;
  3.2978 -    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
  3.2979 -    const Sint8 *target = ((const Sint8 *) cvt->buf);
  3.2980 -    Sint8 sample1 = ((Sint8) src[1]);
  3.2981 -    Sint8 sample0 = ((Sint8) src[0]);
  3.2982 -    Sint8 last_sample1 = sample1;
  3.2983 -    Sint8 last_sample0 = sample0;
  3.2984 -    while (dst >= target) {
  3.2985 -        dst[1] = ((Sint8) sample1);
  3.2986 -        dst[0] = ((Sint8) sample0);
  3.2987 -        dst -= 2;
  3.2988 -        eps += srcsize;
  3.2989 -        if ((eps << 1) >= dstsize) {
  3.2990 -            src -= 2;
  3.2991 -            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
  3.2992 -            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
  3.2993 -            last_sample1 = sample1;
  3.2994 -            last_sample0 = sample0;
  3.2995 -            eps -= dstsize;
  3.2996 -        }
  3.2997 -    }
  3.2998 -    cvt->len_cvt = dstsize;
  3.2999 -    if (cvt->filters[++cvt->filter_index]) {
  3.3000 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3001 -    }
  3.3002 -}
  3.3003 -
  3.3004 -static void SDLCALL
  3.3005 -SDL_Downsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3006 -{
  3.3007 -#if DEBUG_CONVERT
  3.3008 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 2 channels.\n", cvt->rate_incr);
  3.3009 -#endif
  3.3010 -
  3.3011 -    const int srcsize = cvt->len_cvt - 32;
  3.3012 -    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
  3.3013 -    register int eps = 0;
  3.3014 -    Sint8 *dst = (Sint8 *) cvt->buf;
  3.3015 -    const Sint8 *src = (Sint8 *) cvt->buf;
  3.3016 -    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
  3.3017 -    Sint8 sample0 = ((Sint8) src[0]);
  3.3018 -    Sint8 sample1 = ((Sint8) src[1]);
  3.3019 -    Sint8 last_sample0 = sample0;
  3.3020 -    Sint8 last_sample1 = sample1;
  3.3021 -    while (dst < target) {
  3.3022 -        src += 2;
  3.3023 -        eps += dstsize;
  3.3024 -        if ((eps << 1) >= srcsize) {
  3.3025 -            dst[0] = ((Sint8) sample0);
  3.3026 -            dst[1] = ((Sint8) sample1);
  3.3027 -            dst += 2;
  3.3028 -            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
  3.3029 -            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
  3.3030 -            last_sample0 = sample0;
  3.3031 -            last_sample1 = sample1;
  3.3032 -            eps -= srcsize;
  3.3033 -        }
  3.3034 -    }
  3.3035 -    cvt->len_cvt = dstsize;
  3.3036 -    if (cvt->filters[++cvt->filter_index]) {
  3.3037 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3038 -    }
  3.3039 -}
  3.3040 -
  3.3041 -static void SDLCALL
  3.3042 -SDL_Upsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3043 -{
  3.3044 -#if DEBUG_CONVERT
  3.3045 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 4 channels.\n", cvt->rate_incr);
  3.3046 -#endif
  3.3047 -
  3.3048 -    const int srcsize = cvt->len_cvt - 64;
  3.3049 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.3050 -    register int eps = 0;
  3.3051 -    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4;
  3.3052 -    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
  3.3053 -    const Sint8 *target = ((const Sint8 *) cvt->buf);
  3.3054 -    Sint8 sample3 = ((Sint8) src[3]);
  3.3055 -    Sint8 sample2 = ((Sint8) src[2]);
  3.3056 -    Sint8 sample1 = ((Sint8) src[1]);
  3.3057 -    Sint8 sample0 = ((Sint8) src[0]);
  3.3058 -    Sint8 last_sample3 = sample3;
  3.3059 -    Sint8 last_sample2 = sample2;
  3.3060 -    Sint8 last_sample1 = sample1;
  3.3061 -    Sint8 last_sample0 = sample0;
  3.3062 -    while (dst >= target) {
  3.3063 -        dst[3] = ((Sint8) sample3);
  3.3064 -        dst[2] = ((Sint8) sample2);
  3.3065 -        dst[1] = ((Sint8) sample1);
  3.3066 -        dst[0] = ((Sint8) sample0);
  3.3067 -        dst -= 4;
  3.3068 -        eps += srcsize;
  3.3069 -        if ((eps << 1) >= dstsize) {
  3.3070 -            src -= 4;
  3.3071 -            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
  3.3072 -            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
  3.3073 -            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
  3.3074 -            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
  3.3075 -            last_sample3 = sample3;
  3.3076 -            last_sample2 = sample2;
  3.3077 -            last_sample1 = sample1;
  3.3078 -            last_sample0 = sample0;
  3.3079 -            eps -= dstsize;
  3.3080 -        }
  3.3081 -    }
  3.3082 -    cvt->len_cvt = dstsize;
  3.3083 -    if (cvt->filters[++cvt->filter_index]) {
  3.3084 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3085 -    }
  3.3086 -}
  3.3087 -
  3.3088 -static void SDLCALL
  3.3089 -SDL_Downsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3090 -{
  3.3091 -#if DEBUG_CONVERT
  3.3092 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 4 channels.\n", cvt->rate_incr);
  3.3093 -#endif
  3.3094 -
  3.3095 -    const int srcsize = cvt->len_cvt - 64;
  3.3096 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.3097 -    register int eps = 0;
  3.3098 -    Sint8 *dst = (Sint8 *) cvt->buf;
  3.3099 -    const Sint8 *src = (Sint8 *) cvt->buf;
  3.3100 -    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
  3.3101 -    Sint8 sample0 = ((Sint8) src[0]);
  3.3102 -    Sint8 sample1 = ((Sint8) src[1]);
  3.3103 -    Sint8 sample2 = ((Sint8) src[2]);
  3.3104 -    Sint8 sample3 = ((Sint8) src[3]);
  3.3105 -    Sint8 last_sample0 = sample0;
  3.3106 -    Sint8 last_sample1 = sample1;
  3.3107 -    Sint8 last_sample2 = sample2;
  3.3108 -    Sint8 last_sample3 = sample3;
  3.3109 -    while (dst < target) {
  3.3110 -        src += 4;
  3.3111 -        eps += dstsize;
  3.3112 -        if ((eps << 1) >= srcsize) {
  3.3113 -            dst[0] = ((Sint8) sample0);
  3.3114 -            dst[1] = ((Sint8) sample1);
  3.3115 -            dst[2] = ((Sint8) sample2);
  3.3116 -            dst[3] = ((Sint8) sample3);
  3.3117 -            dst += 4;
  3.3118 -            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
  3.3119 -            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
  3.3120 -            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
  3.3121 -            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
  3.3122 -            last_sample0 = sample0;
  3.3123 -            last_sample1 = sample1;
  3.3124 -            last_sample2 = sample2;
  3.3125 -            last_sample3 = sample3;
  3.3126 -            eps -= srcsize;
  3.3127 -        }
  3.3128 -    }
  3.3129 -    cvt->len_cvt = dstsize;
  3.3130 -    if (cvt->filters[++cvt->filter_index]) {
  3.3131 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3132 -    }
  3.3133 -}
  3.3134 -
  3.3135 -static void SDLCALL
  3.3136 -SDL_Upsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3137 -{
  3.3138 -#if DEBUG_CONVERT
  3.3139 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 6 channels.\n", cvt->rate_incr);
  3.3140 -#endif
  3.3141 -
  3.3142 -    const int srcsize = cvt->len_cvt - 96;
  3.3143 -    const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
  3.3144 -    register int eps = 0;
  3.3145 -    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6;
  3.3146 -    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
  3.3147 -    const Sint8 *target = ((const Sint8 *) cvt->buf);
  3.3148 -    Sint8 sample5 = ((Sint8) src[5]);
  3.3149 -    Sint8 sample4 = ((Sint8) src[4]);
  3.3150 -    Sint8 sample3 = ((Sint8) src[3]);
  3.3151 -    Sint8 sample2 = ((Sint8) src[2]);
  3.3152 -    Sint8 sample1 = ((Sint8) src[1]);
  3.3153 -    Sint8 sample0 = ((Sint8) src[0]);
  3.3154 -    Sint8 last_sample5 = sample5;
  3.3155 -    Sint8 last_sample4 = sample4;
  3.3156 -    Sint8 last_sample3 = sample3;
  3.3157 -    Sint8 last_sample2 = sample2;
  3.3158 -    Sint8 last_sample1 = sample1;
  3.3159 -    Sint8 last_sample0 = sample0;
  3.3160 -    while (dst >= target) {
  3.3161 -        dst[5] = ((Sint8) sample5);
  3.3162 -        dst[4] = ((Sint8) sample4);
  3.3163 -        dst[3] = ((Sint8) sample3);
  3.3164 -        dst[2] = ((Sint8) sample2);
  3.3165 -        dst[1] = ((Sint8) sample1);
  3.3166 -        dst[0] = ((Sint8) sample0);
  3.3167 -        dst -= 6;
  3.3168 -        eps += srcsize;
  3.3169 -        if ((eps << 1) >= dstsize) {
  3.3170 -            src -= 6;
  3.3171 -            sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
  3.3172 -            sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
  3.3173 -            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
  3.3174 -            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
  3.3175 -            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
  3.3176 -            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
  3.3177 -            last_sample5 = sample5;
  3.3178 -            last_sample4 = sample4;
  3.3179 -            last_sample3 = sample3;
  3.3180 -            last_sample2 = sample2;
  3.3181 -            last_sample1 = sample1;
  3.3182 -            last_sample0 = sample0;
  3.3183 -            eps -= dstsize;
  3.3184 -        }
  3.3185 -    }
  3.3186 -    cvt->len_cvt = dstsize;
  3.3187 -    if (cvt->filters[++cvt->filter_index]) {
  3.3188 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3189 -    }
  3.3190 -}
  3.3191 -
  3.3192 -static void SDLCALL
  3.3193 -SDL_Downsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3194 -{
  3.3195 -#if DEBUG_CONVERT
  3.3196 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 6 channels.\n", cvt->rate_incr);
  3.3197 -#endif
  3.3198 -
  3.3199 -    const int srcsize = cvt->len_cvt - 96;
  3.3200 -    const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
  3.3201 -    register int eps = 0;
  3.3202 -    Sint8 *dst = (Sint8 *) cvt->buf;
  3.3203 -    const Sint8 *src = (Sint8 *) cvt->buf;
  3.3204 -    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
  3.3205 -    Sint8 sample0 = ((Sint8) src[0]);
  3.3206 -    Sint8 sample1 = ((Sint8) src[1]);
  3.3207 -    Sint8 sample2 = ((Sint8) src[2]);
  3.3208 -    Sint8 sample3 = ((Sint8) src[3]);
  3.3209 -    Sint8 sample4 = ((Sint8) src[4]);
  3.3210 -    Sint8 sample5 = ((Sint8) src[5]);
  3.3211 -    Sint8 last_sample0 = sample0;
  3.3212 -    Sint8 last_sample1 = sample1;
  3.3213 -    Sint8 last_sample2 = sample2;
  3.3214 -    Sint8 last_sample3 = sample3;
  3.3215 -    Sint8 last_sample4 = sample4;
  3.3216 -    Sint8 last_sample5 = sample5;
  3.3217 -    while (dst < target) {
  3.3218 -        src += 6;
  3.3219 -        eps += dstsize;
  3.3220 -        if ((eps << 1) >= srcsize) {
  3.3221 -            dst[0] = ((Sint8) sample0);
  3.3222 -            dst[1] = ((Sint8) sample1);
  3.3223 -            dst[2] = ((Sint8) sample2);
  3.3224 -            dst[3] = ((Sint8) sample3);
  3.3225 -            dst[4] = ((Sint8) sample4);
  3.3226 -            dst[5] = ((Sint8) sample5);
  3.3227 -            dst += 6;
  3.3228 -            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
  3.3229 -            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
  3.3230 -            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
  3.3231 -            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
  3.3232 -            sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
  3.3233 -            sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
  3.3234 -            last_sample0 = sample0;
  3.3235 -            last_sample1 = sample1;
  3.3236 -            last_sample2 = sample2;
  3.3237 -            last_sample3 = sample3;
  3.3238 -            last_sample4 = sample4;
  3.3239 -            last_sample5 = sample5;
  3.3240 -            eps -= srcsize;
  3.3241 -        }
  3.3242 -    }
  3.3243 -    cvt->len_cvt = dstsize;
  3.3244 -    if (cvt->filters[++cvt->filter_index]) {
  3.3245 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3246 -    }
  3.3247 -}
  3.3248 -
  3.3249 -static void SDLCALL
  3.3250 -SDL_Upsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3251 -{
  3.3252 -#if DEBUG_CONVERT
  3.3253 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 8 channels.\n", cvt->rate_incr);
  3.3254 -#endif
  3.3255 -
  3.3256 -    const int srcsize = cvt->len_cvt - 128;
  3.3257 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.3258 -    register int eps = 0;
  3.3259 -    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8;
  3.3260 -    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
  3.3261 -    const Sint8 *target = ((const Sint8 *) cvt->buf);
  3.3262 -    Sint8 sample7 = ((Sint8) src[7]);
  3.3263 -    Sint8 sample6 = ((Sint8) src[6]);
  3.3264 -    Sint8 sample5 = ((Sint8) src[5]);
  3.3265 -    Sint8 sample4 = ((Sint8) src[4]);
  3.3266 -    Sint8 sample3 = ((Sint8) src[3]);
  3.3267 -    Sint8 sample2 = ((Sint8) src[2]);
  3.3268 -    Sint8 sample1 = ((Sint8) src[1]);
  3.3269 -    Sint8 sample0 = ((Sint8) src[0]);
  3.3270 -    Sint8 last_sample7 = sample7;
  3.3271 -    Sint8 last_sample6 = sample6;
  3.3272 -    Sint8 last_sample5 = sample5;
  3.3273 -    Sint8 last_sample4 = sample4;
  3.3274 -    Sint8 last_sample3 = sample3;
  3.3275 -    Sint8 last_sample2 = sample2;
  3.3276 -    Sint8 last_sample1 = sample1;
  3.3277 -    Sint8 last_sample0 = sample0;
  3.3278 -    while (dst >= target) {
  3.3279 -        dst[7] = ((Sint8) sample7);
  3.3280 -        dst[6] = ((Sint8) sample6);
  3.3281 -        dst[5] = ((Sint8) sample5);
  3.3282 -        dst[4] = ((Sint8) sample4);
  3.3283 -        dst[3] = ((Sint8) sample3);
  3.3284 -        dst[2] = ((Sint8) sample2);
  3.3285 -        dst[1] = ((Sint8) sample1);
  3.3286 -        dst[0] = ((Sint8) sample0);
  3.3287 -        dst -= 8;
  3.3288 -        eps += srcsize;
  3.3289 -        if ((eps << 1) >= dstsize) {
  3.3290 -            src -= 8;
  3.3291 -            sample7 = (Sint8) ((((Sint16) ((Sint8) src[7])) + ((Sint16) last_sample7)) >> 1);
  3.3292 -            sample6 = (Sint8) ((((Sint16) ((Sint8) src[6])) + ((Sint16) last_sample6)) >> 1);
  3.3293 -            sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
  3.3294 -            sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
  3.3295 -            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
  3.3296 -            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
  3.3297 -            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
  3.3298 -            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
  3.3299 -            last_sample7 = sample7;
  3.3300 -            last_sample6 = sample6;
  3.3301 -            last_sample5 = sample5;
  3.3302 -            last_sample4 = sample4;
  3.3303 -            last_sample3 = sample3;
  3.3304 -            last_sample2 = sample2;
  3.3305 -            last_sample1 = sample1;
  3.3306 -            last_sample0 = sample0;
  3.3307 -            eps -= dstsize;
  3.3308 -        }
  3.3309 -    }
  3.3310 -    cvt->len_cvt = dstsize;
  3.3311 -    if (cvt->filters[++cvt->filter_index]) {
  3.3312 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3313 -    }
  3.3314 -}
  3.3315 -
  3.3316 -static void SDLCALL
  3.3317 -SDL_Downsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3318 -{
  3.3319 -#if DEBUG_CONVERT
  3.3320 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 8 channels.\n", cvt->rate_incr);
  3.3321 -#endif
  3.3322 -
  3.3323 -    const int srcsize = cvt->len_cvt - 128;
  3.3324 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.3325 -    register int eps = 0;
  3.3326 -    Sint8 *dst = (Sint8 *) cvt->buf;
  3.3327 -    const Sint8 *src = (Sint8 *) cvt->buf;
  3.3328 -    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
  3.3329 -    Sint8 sample0 = ((Sint8) src[0]);
  3.3330 -    Sint8 sample1 = ((Sint8) src[1]);
  3.3331 -    Sint8 sample2 = ((Sint8) src[2]);
  3.3332 -    Sint8 sample3 = ((Sint8) src[3]);
  3.3333 -    Sint8 sample4 = ((Sint8) src[4]);
  3.3334 -    Sint8 sample5 = ((Sint8) src[5]);
  3.3335 -    Sint8 sample6 = ((Sint8) src[6]);
  3.3336 -    Sint8 sample7 = ((Sint8) src[7]);
  3.3337 -    Sint8 last_sample0 = sample0;
  3.3338 -    Sint8 last_sample1 = sample1;
  3.3339 -    Sint8 last_sample2 = sample2;
  3.3340 -    Sint8 last_sample3 = sample3;
  3.3341 -    Sint8 last_sample4 = sample4;
  3.3342 -    Sint8 last_sample5 = sample5;
  3.3343 -    Sint8 last_sample6 = sample6;
  3.3344 -    Sint8 last_sample7 = sample7;
  3.3345 -    while (dst < target) {
  3.3346 -        src += 8;
  3.3347 -        eps += dstsize;
  3.3348 -        if ((eps << 1) >= srcsize) {
  3.3349 -            dst[0] = ((Sint8) sample0);
  3.3350 -            dst[1] = ((Sint8) sample1);
  3.3351 -            dst[2] = ((Sint8) sample2);
  3.3352 -            dst[3] = ((Sint8) sample3);
  3.3353 -            dst[4] = ((Sint8) sample4);
  3.3354 -            dst[5] = ((Sint8) sample5);
  3.3355 -            dst[6] = ((Sint8) sample6);
  3.3356 -            dst[7] = ((Sint8) sample7);
  3.3357 -            dst += 8;
  3.3358 -            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
  3.3359 -            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
  3.3360 -            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
  3.3361 -            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
  3.3362 -            sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
  3.3363 -            sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
  3.3364 -            sample6 = (Sint8) ((((Sint16) ((Sint8) src[6])) + ((Sint16) last_sample6)) >> 1);
  3.3365 -            sample7 = (Sint8) ((((Sint16) ((Sint8) src[7])) + ((Sint16) last_sample7)) >> 1);
  3.3366 -            last_sample0 = sample0;
  3.3367 -            last_sample1 = sample1;
  3.3368 -            last_sample2 = sample2;
  3.3369 -            last_sample3 = sample3;
  3.3370 -            last_sample4 = sample4;
  3.3371 -            last_sample5 = sample5;
  3.3372 -            last_sample6 = sample6;
  3.3373 -            last_sample7 = sample7;
  3.3374 -            eps -= srcsize;
  3.3375 -        }
  3.3376 -    }
  3.3377 -    cvt->len_cvt = dstsize;
  3.3378 -    if (cvt->filters[++cvt->filter_index]) {
  3.3379 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3380 -    }
  3.3381 -}
  3.3382 -
  3.3383 -static void SDLCALL
  3.3384 -SDL_Upsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3385 -{
  3.3386 -#if DEBUG_CONVERT
  3.3387 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 1 channels.\n", cvt->rate_incr);
  3.3388 -#endif
  3.3389 -
  3.3390 -    const int srcsize = cvt->len_cvt - 32;
  3.3391 -    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
  3.3392 -    register int eps = 0;
  3.3393 -    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
  3.3394 -    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.3395 -    const Uint16 *target = ((const Uint16 *) cvt->buf);
  3.3396 -    Uint16 sample0 = SDL_SwapLE16(src[0]);
  3.3397 -    Uint16 last_sample0 = sample0;
  3.3398 -    while (dst >= target) {
  3.3399 -        dst[0] = SDL_SwapLE16(sample0);
  3.3400 -        dst--;
  3.3401 -        eps += srcsize;
  3.3402 -        if ((eps << 1) >= dstsize) {
  3.3403 -            src--;
  3.3404 -            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.3405 -            last_sample0 = sample0;
  3.3406 -            eps -= dstsize;
  3.3407 -        }
  3.3408 -    }
  3.3409 -    cvt->len_cvt = dstsize;
  3.3410 -    if (cvt->filters[++cvt->filter_index]) {
  3.3411 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3412 -    }
  3.3413 -}
  3.3414 -
  3.3415 -static void SDLCALL
  3.3416 -SDL_Downsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3417 -{
  3.3418 -#if DEBUG_CONVERT
  3.3419 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 1 channels.\n", cvt->rate_incr);
  3.3420 -#endif
  3.3421 -
  3.3422 -    const int srcsize = cvt->len_cvt - 32;
  3.3423 -    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
  3.3424 -    register int eps = 0;
  3.3425 -    Uint16 *dst = (Uint16 *) cvt->buf;
  3.3426 -    const Uint16 *src = (Uint16 *) cvt->buf;
  3.3427 -    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  3.3428 -    Uint16 sample0 = SDL_SwapLE16(src[0]);
  3.3429 -    Uint16 last_sample0 = sample0;
  3.3430 -    while (dst < target) {
  3.3431 -        src++;
  3.3432 -        eps += dstsize;
  3.3433 -        if ((eps << 1) >= srcsize) {
  3.3434 -            dst[0] = SDL_SwapLE16(sample0);
  3.3435 -            dst++;
  3.3436 -            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.3437 -            last_sample0 = sample0;
  3.3438 -            eps -= srcsize;
  3.3439 -        }
  3.3440 -    }
  3.3441 -    cvt->len_cvt = dstsize;
  3.3442 -    if (cvt->filters[++cvt->filter_index]) {
  3.3443 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3444 -    }
  3.3445 -}
  3.3446 -
  3.3447 -static void SDLCALL
  3.3448 -SDL_Upsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3449 -{
  3.3450 -#if DEBUG_CONVERT
  3.3451 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 2 channels.\n", cvt->rate_incr);
  3.3452 -#endif
  3.3453 -
  3.3454 -    const int srcsize = cvt->len_cvt - 64;
  3.3455 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.3456 -    register int eps = 0;
  3.3457 -    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
  3.3458 -    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
  3.3459 -    const Uint16 *target = ((const Uint16 *) cvt->buf);
  3.3460 -    Uint16 sample1 = SDL_SwapLE16(src[1]);
  3.3461 -    Uint16 sample0 = SDL_SwapLE16(src[0]);
  3.3462 -    Uint16 last_sample1 = sample1;
  3.3463 -    Uint16 last_sample0 = sample0;
  3.3464 -    while (dst >= target) {
  3.3465 -        dst[1] = SDL_SwapLE16(sample1);
  3.3466 -        dst[0] = SDL_SwapLE16(sample0);
  3.3467 -        dst -= 2;
  3.3468 -        eps += srcsize;
  3.3469 -        if ((eps << 1) >= dstsize) {
  3.3470 -            src -= 2;
  3.3471 -            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.3472 -            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.3473 -            last_sample1 = sample1;
  3.3474 -            last_sample0 = sample0;
  3.3475 -            eps -= dstsize;
  3.3476 -        }
  3.3477 -    }
  3.3478 -    cvt->len_cvt = dstsize;
  3.3479 -    if (cvt->filters[++cvt->filter_index]) {
  3.3480 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3481 -    }
  3.3482 -}
  3.3483 -
  3.3484 -static void SDLCALL
  3.3485 -SDL_Downsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3486 -{
  3.3487 -#if DEBUG_CONVERT
  3.3488 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 2 channels.\n", cvt->rate_incr);
  3.3489 -#endif
  3.3490 -
  3.3491 -    const int srcsize = cvt->len_cvt - 64;
  3.3492 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.3493 -    register int eps = 0;
  3.3494 -    Uint16 *dst = (Uint16 *) cvt->buf;
  3.3495 -    const Uint16 *src = (Uint16 *) cvt->buf;
  3.3496 -    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  3.3497 -    Uint16 sample0 = SDL_SwapLE16(src[0]);
  3.3498 -    Uint16 sample1 = SDL_SwapLE16(src[1]);
  3.3499 -    Uint16 last_sample0 = sample0;
  3.3500 -    Uint16 last_sample1 = sample1;
  3.3501 -    while (dst < target) {
  3.3502 -        src += 2;
  3.3503 -        eps += dstsize;
  3.3504 -        if ((eps << 1) >= srcsize) {
  3.3505 -            dst[0] = SDL_SwapLE16(sample0);
  3.3506 -            dst[1] = SDL_SwapLE16(sample1);
  3.3507 -            dst += 2;
  3.3508 -            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.3509 -            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.3510 -            last_sample0 = sample0;
  3.3511 -            last_sample1 = sample1;
  3.3512 -            eps -= srcsize;
  3.3513 -        }
  3.3514 -    }
  3.3515 -    cvt->len_cvt = dstsize;
  3.3516 -    if (cvt->filters[++cvt->filter_index]) {
  3.3517 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3518 -    }
  3.3519 -}
  3.3520 -
  3.3521 -static void SDLCALL
  3.3522 -SDL_Upsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3523 -{
  3.3524 -#if DEBUG_CONVERT
  3.3525 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 4 channels.\n", cvt->rate_incr);
  3.3526 -#endif
  3.3527 -
  3.3528 -    const int srcsize = cvt->len_cvt - 128;
  3.3529 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.3530 -    register int eps = 0;
  3.3531 -    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
  3.3532 -    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
  3.3533 -    const Uint16 *target = ((const Uint16 *) cvt->buf);
  3.3534 -    Uint16 sample3 = SDL_SwapLE16(src[3]);
  3.3535 -    Uint16 sample2 = SDL_SwapLE16(src[2]);
  3.3536 -    Uint16 sample1 = SDL_SwapLE16(src[1]);
  3.3537 -    Uint16 sample0 = SDL_SwapLE16(src[0]);
  3.3538 -    Uint16 last_sample3 = sample3;
  3.3539 -    Uint16 last_sample2 = sample2;
  3.3540 -    Uint16 last_sample1 = sample1;
  3.3541 -    Uint16 last_sample0 = sample0;
  3.3542 -    while (dst >= target) {
  3.3543 -        dst[3] = SDL_SwapLE16(sample3);
  3.3544 -        dst[2] = SDL_SwapLE16(sample2);
  3.3545 -        dst[1] = SDL_SwapLE16(sample1);
  3.3546 -        dst[0] = SDL_SwapLE16(sample0);
  3.3547 -        dst -= 4;
  3.3548 -        eps += srcsize;
  3.3549 -        if ((eps << 1) >= dstsize) {
  3.3550 -            src -= 4;
  3.3551 -            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  3.3552 -            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  3.3553 -            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.3554 -            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.3555 -            last_sample3 = sample3;
  3.3556 -            last_sample2 = sample2;
  3.3557 -            last_sample1 = sample1;
  3.3558 -            last_sample0 = sample0;
  3.3559 -            eps -= dstsize;
  3.3560 -        }
  3.3561 -    }
  3.3562 -    cvt->len_cvt = dstsize;
  3.3563 -    if (cvt->filters[++cvt->filter_index]) {
  3.3564 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3565 -    }
  3.3566 -}
  3.3567 -
  3.3568 -static void SDLCALL
  3.3569 -SDL_Downsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3570 -{
  3.3571 -#if DEBUG_CONVERT
  3.3572 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 4 channels.\n", cvt->rate_incr);
  3.3573 -#endif
  3.3574 -
  3.3575 -    const int srcsize = cvt->len_cvt - 128;
  3.3576 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.3577 -    register int eps = 0;
  3.3578 -    Uint16 *dst = (Uint16 *) cvt->buf;
  3.3579 -    const Uint16 *src = (Uint16 *) cvt->buf;
  3.3580 -    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  3.3581 -    Uint16 sample0 = SDL_SwapLE16(src[0]);
  3.3582 -    Uint16 sample1 = SDL_SwapLE16(src[1]);
  3.3583 -    Uint16 sample2 = SDL_SwapLE16(src[2]);
  3.3584 -    Uint16 sample3 = SDL_SwapLE16(src[3]);
  3.3585 -    Uint16 last_sample0 = sample0;
  3.3586 -    Uint16 last_sample1 = sample1;
  3.3587 -    Uint16 last_sample2 = sample2;
  3.3588 -    Uint16 last_sample3 = sample3;
  3.3589 -    while (dst < target) {
  3.3590 -        src += 4;
  3.3591 -        eps += dstsize;
  3.3592 -        if ((eps << 1) >= srcsize) {
  3.3593 -            dst[0] = SDL_SwapLE16(sample0);
  3.3594 -            dst[1] = SDL_SwapLE16(sample1);
  3.3595 -            dst[2] = SDL_SwapLE16(sample2);
  3.3596 -            dst[3] = SDL_SwapLE16(sample3);
  3.3597 -            dst += 4;
  3.3598 -            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.3599 -            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.3600 -            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  3.3601 -            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  3.3602 -            last_sample0 = sample0;
  3.3603 -            last_sample1 = sample1;
  3.3604 -            last_sample2 = sample2;
  3.3605 -            last_sample3 = sample3;
  3.3606 -            eps -= srcsize;
  3.3607 -        }
  3.3608 -    }
  3.3609 -    cvt->len_cvt = dstsize;
  3.3610 -    if (cvt->filters[++cvt->filter_index]) {
  3.3611 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3612 -    }
  3.3613 -}
  3.3614 -
  3.3615 -static void SDLCALL
  3.3616 -SDL_Upsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3617 -{
  3.3618 -#if DEBUG_CONVERT
  3.3619 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 6 channels.\n", cvt->rate_incr);
  3.3620 -#endif
  3.3621 -
  3.3622 -    const int srcsize = cvt->len_cvt - 192;
  3.3623 -    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
  3.3624 -    register int eps = 0;
  3.3625 -    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
  3.3626 -    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
  3.3627 -    const Uint16 *target = ((const Uint16 *) cvt->buf);
  3.3628 -    Uint16 sample5 = SDL_SwapLE16(src[5]);
  3.3629 -    Uint16 sample4 = SDL_SwapLE16(src[4]);
  3.3630 -    Uint16 sample3 = SDL_SwapLE16(src[3]);
  3.3631 -    Uint16 sample2 = SDL_SwapLE16(src[2]);
  3.3632 -    Uint16 sample1 = SDL_SwapLE16(src[1]);
  3.3633 -    Uint16 sample0 = SDL_SwapLE16(src[0]);
  3.3634 -    Uint16 last_sample5 = sample5;
  3.3635 -    Uint16 last_sample4 = sample4;
  3.3636 -    Uint16 last_sample3 = sample3;
  3.3637 -    Uint16 last_sample2 = sample2;
  3.3638 -    Uint16 last_sample1 = sample1;
  3.3639 -    Uint16 last_sample0 = sample0;
  3.3640 -    while (dst >= target) {
  3.3641 -        dst[5] = SDL_SwapLE16(sample5);
  3.3642 -        dst[4] = SDL_SwapLE16(sample4);
  3.3643 -        dst[3] = SDL_SwapLE16(sample3);
  3.3644 -        dst[2] = SDL_SwapLE16(sample2);
  3.3645 -        dst[1] = SDL_SwapLE16(sample1);
  3.3646 -        dst[0] = SDL_SwapLE16(sample0);
  3.3647 -        dst -= 6;
  3.3648 -        eps += srcsize;
  3.3649 -        if ((eps << 1) >= dstsize) {
  3.3650 -            src -= 6;
  3.3651 -            sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  3.3652 -            sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  3.3653 -            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  3.3654 -            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  3.3655 -            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.3656 -            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.3657 -            last_sample5 = sample5;
  3.3658 -            last_sample4 = sample4;
  3.3659 -            last_sample3 = sample3;
  3.3660 -            last_sample2 = sample2;
  3.3661 -            last_sample1 = sample1;
  3.3662 -            last_sample0 = sample0;
  3.3663 -            eps -= dstsize;
  3.3664 -        }
  3.3665 -    }
  3.3666 -    cvt->len_cvt = dstsize;
  3.3667 -    if (cvt->filters[++cvt->filter_index]) {
  3.3668 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3669 -    }
  3.3670 -}
  3.3671 -
  3.3672 -static void SDLCALL
  3.3673 -SDL_Downsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3674 -{
  3.3675 -#if DEBUG_CONVERT
  3.3676 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 6 channels.\n", cvt->rate_incr);
  3.3677 -#endif
  3.3678 -
  3.3679 -    const int srcsize = cvt->len_cvt - 192;
  3.3680 -    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
  3.3681 -    register int eps = 0;
  3.3682 -    Uint16 *dst = (Uint16 *) cvt->buf;
  3.3683 -    const Uint16 *src = (Uint16 *) cvt->buf;
  3.3684 -    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  3.3685 -    Uint16 sample0 = SDL_SwapLE16(src[0]);
  3.3686 -    Uint16 sample1 = SDL_SwapLE16(src[1]);
  3.3687 -    Uint16 sample2 = SDL_SwapLE16(src[2]);
  3.3688 -    Uint16 sample3 = SDL_SwapLE16(src[3]);
  3.3689 -    Uint16 sample4 = SDL_SwapLE16(src[4]);
  3.3690 -    Uint16 sample5 = SDL_SwapLE16(src[5]);
  3.3691 -    Uint16 last_sample0 = sample0;
  3.3692 -    Uint16 last_sample1 = sample1;
  3.3693 -    Uint16 last_sample2 = sample2;
  3.3694 -    Uint16 last_sample3 = sample3;
  3.3695 -    Uint16 last_sample4 = sample4;
  3.3696 -    Uint16 last_sample5 = sample5;
  3.3697 -    while (dst < target) {
  3.3698 -        src += 6;
  3.3699 -        eps += dstsize;
  3.3700 -        if ((eps << 1) >= srcsize) {
  3.3701 -            dst[0] = SDL_SwapLE16(sample0);
  3.3702 -            dst[1] = SDL_SwapLE16(sample1);
  3.3703 -            dst[2] = SDL_SwapLE16(sample2);
  3.3704 -            dst[3] = SDL_SwapLE16(sample3);
  3.3705 -            dst[4] = SDL_SwapLE16(sample4);
  3.3706 -            dst[5] = SDL_SwapLE16(sample5);
  3.3707 -            dst += 6;
  3.3708 -            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.3709 -            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.3710 -            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  3.3711 -            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  3.3712 -            sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  3.3713 -            sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  3.3714 -            last_sample0 = sample0;
  3.3715 -            last_sample1 = sample1;
  3.3716 -            last_sample2 = sample2;
  3.3717 -            last_sample3 = sample3;
  3.3718 -            last_sample4 = sample4;
  3.3719 -            last_sample5 = sample5;
  3.3720 -            eps -= srcsize;
  3.3721 -        }
  3.3722 -    }
  3.3723 -    cvt->len_cvt = dstsize;
  3.3724 -    if (cvt->filters[++cvt->filter_index]) {
  3.3725 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3726 -    }
  3.3727 -}
  3.3728 -
  3.3729 -static void SDLCALL
  3.3730 -SDL_Upsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3731 -{
  3.3732 -#if DEBUG_CONVERT
  3.3733 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 8 channels.\n", cvt->rate_incr);
  3.3734 -#endif
  3.3735 -
  3.3736 -    const int srcsize = cvt->len_cvt - 256;
  3.3737 -    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
  3.3738 -    register int eps = 0;
  3.3739 -    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
  3.3740 -    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
  3.3741 -    const Uint16 *target = ((const Uint16 *) cvt->buf);
  3.3742 -    Uint16 sample7 = SDL_SwapLE16(src[7]);
  3.3743 -    Uint16 sample6 = SDL_SwapLE16(src[6]);
  3.3744 -    Uint16 sample5 = SDL_SwapLE16(src[5]);
  3.3745 -    Uint16 sample4 = SDL_SwapLE16(src[4]);
  3.3746 -    Uint16 sample3 = SDL_SwapLE16(src[3]);
  3.3747 -    Uint16 sample2 = SDL_SwapLE16(src[2]);
  3.3748 -    Uint16 sample1 = SDL_SwapLE16(src[1]);
  3.3749 -    Uint16 sample0 = SDL_SwapLE16(src[0]);
  3.3750 -    Uint16 last_sample7 = sample7;
  3.3751 -    Uint16 last_sample6 = sample6;
  3.3752 -    Uint16 last_sample5 = sample5;
  3.3753 -    Uint16 last_sample4 = sample4;
  3.3754 -    Uint16 last_sample3 = sample3;
  3.3755 -    Uint16 last_sample2 = sample2;
  3.3756 -    Uint16 last_sample1 = sample1;
  3.3757 -    Uint16 last_sample0 = sample0;
  3.3758 -    while (dst >= target) {
  3.3759 -        dst[7] = SDL_SwapLE16(sample7);
  3.3760 -        dst[6] = SDL_SwapLE16(sample6);
  3.3761 -        dst[5] = SDL_SwapLE16(sample5);
  3.3762 -        dst[4] = SDL_SwapLE16(sample4);
  3.3763 -        dst[3] = SDL_SwapLE16(sample3);
  3.3764 -        dst[2] = SDL_SwapLE16(sample2);
  3.3765 -        dst[1] = SDL_SwapLE16(sample1);
  3.3766 -        dst[0] = SDL_SwapLE16(sample0);
  3.3767 -        dst -= 8;
  3.3768 -        eps += srcsize;
  3.3769 -        if ((eps << 1) >= dstsize) {
  3.3770 -            src -= 8;
  3.3771 -            sample7 = (Uint16) ((((Sint32) SDL_SwapLE16(src[7])) + ((Sint32) last_sample7)) >> 1);
  3.3772 -            sample6 = (Uint16) ((((Sint32) SDL_SwapLE16(src[6])) + ((Sint32) last_sample6)) >> 1);
  3.3773 -            sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  3.3774 -            sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  3.3775 -            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  3.3776 -            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  3.3777 -            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.3778 -            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.3779 -            last_sample7 = sample7;
  3.3780 -            last_sample6 = sample6;
  3.3781 -            last_sample5 = sample5;
  3.3782 -            last_sample4 = sample4;
  3.3783 -            last_sample3 = sample3;
  3.3784 -            last_sample2 = sample2;
  3.3785 -            last_sample1 = sample1;
  3.3786 -            last_sample0 = sample0;
  3.3787 -            eps -= dstsize;
  3.3788 -        }
  3.3789 -    }
  3.3790 -    cvt->len_cvt = dstsize;
  3.3791 -    if (cvt->filters[++cvt->filter_index]) {
  3.3792 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3793 -    }
  3.3794 -}
  3.3795 -
  3.3796 -static void SDLCALL
  3.3797 -SDL_Downsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3798 -{
  3.3799 -#if DEBUG_CONVERT
  3.3800 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 8 channels.\n", cvt->rate_incr);
  3.3801 -#endif
  3.3802 -
  3.3803 -    const int srcsize = cvt->len_cvt - 256;
  3.3804 -    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
  3.3805 -    register int eps = 0;
  3.3806 -    Uint16 *dst = (Uint16 *) cvt->buf;
  3.3807 -    const Uint16 *src = (Uint16 *) cvt->buf;
  3.3808 -    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  3.3809 -    Uint16 sample0 = SDL_SwapLE16(src[0]);
  3.3810 -    Uint16 sample1 = SDL_SwapLE16(src[1]);
  3.3811 -    Uint16 sample2 = SDL_SwapLE16(src[2]);
  3.3812 -    Uint16 sample3 = SDL_SwapLE16(src[3]);
  3.3813 -    Uint16 sample4 = SDL_SwapLE16(src[4]);
  3.3814 -    Uint16 sample5 = SDL_SwapLE16(src[5]);
  3.3815 -    Uint16 sample6 = SDL_SwapLE16(src[6]);
  3.3816 -    Uint16 sample7 = SDL_SwapLE16(src[7]);
  3.3817 -    Uint16 last_sample0 = sample0;
  3.3818 -    Uint16 last_sample1 = sample1;
  3.3819 -    Uint16 last_sample2 = sample2;
  3.3820 -    Uint16 last_sample3 = sample3;
  3.3821 -    Uint16 last_sample4 = sample4;
  3.3822 -    Uint16 last_sample5 = sample5;
  3.3823 -    Uint16 last_sample6 = sample6;
  3.3824 -    Uint16 last_sample7 = sample7;
  3.3825 -    while (dst < target) {
  3.3826 -        src += 8;
  3.3827 -        eps += dstsize;
  3.3828 -        if ((eps << 1) >= srcsize) {
  3.3829 -            dst[0] = SDL_SwapLE16(sample0);
  3.3830 -            dst[1] = SDL_SwapLE16(sample1);
  3.3831 -            dst[2] = SDL_SwapLE16(sample2);
  3.3832 -            dst[3] = SDL_SwapLE16(sample3);
  3.3833 -            dst[4] = SDL_SwapLE16(sample4);
  3.3834 -            dst[5] = SDL_SwapLE16(sample5);
  3.3835 -            dst[6] = SDL_SwapLE16(sample6);
  3.3836 -            dst[7] = SDL_SwapLE16(sample7);
  3.3837 -            dst += 8;
  3.3838 -            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.3839 -            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.3840 -            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  3.3841 -            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  3.3842 -            sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  3.3843 -            sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  3.3844 -            sample6 = (Uint16) ((((Sint32) SDL_SwapLE16(src[6])) + ((Sint32) last_sample6)) >> 1);
  3.3845 -            sample7 = (Uint16) ((((Sint32) SDL_SwapLE16(src[7])) + ((Sint32) last_sample7)) >> 1);
  3.3846 -            last_sample0 = sample0;
  3.3847 -            last_sample1 = sample1;
  3.3848 -            last_sample2 = sample2;
  3.3849 -            last_sample3 = sample3;
  3.3850 -            last_sample4 = sample4;
  3.3851 -            last_sample5 = sample5;
  3.3852 -            last_sample6 = sample6;
  3.3853 -            last_sample7 = sample7;
  3.3854 -            eps -= srcsize;
  3.3855 -        }
  3.3856 -    }
  3.3857 -    cvt->len_cvt = dstsize;
  3.3858 -    if (cvt->filters[++cvt->filter_index]) {
  3.3859 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3860 -    }
  3.3861 -}
  3.3862 -
  3.3863 -static void SDLCALL
  3.3864 -SDL_Upsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3865 -{
  3.3866 -#if DEBUG_CONVERT
  3.3867 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 1 channels.\n", cvt->rate_incr);
  3.3868 -#endif
  3.3869 -
  3.3870 -    const int srcsize = cvt->len_cvt - 32;
  3.3871 -    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
  3.3872 -    register int eps = 0;
  3.3873 -    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
  3.3874 -    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.3875 -    const Sint16 *target = ((const Sint16 *) cvt->buf);
  3.3876 -    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  3.3877 -    Sint16 last_sample0 = sample0;
  3.3878 -    while (dst >= target) {
  3.3879 -        dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  3.3880 -        dst--;
  3.3881 -        eps += srcsize;
  3.3882 -        if ((eps << 1) >= dstsize) {
  3.3883 -            src--;
  3.3884 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.3885 -            last_sample0 = sample0;
  3.3886 -            eps -= dstsize;
  3.3887 -        }
  3.3888 -    }
  3.3889 -    cvt->len_cvt = dstsize;
  3.3890 -    if (cvt->filters[++cvt->filter_index]) {
  3.3891 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3892 -    }
  3.3893 -}
  3.3894 -
  3.3895 -static void SDLCALL
  3.3896 -SDL_Downsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3897 -{
  3.3898 -#if DEBUG_CONVERT
  3.3899 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 1 channels.\n", cvt->rate_incr);
  3.3900 -#endif
  3.3901 -
  3.3902 -    const int srcsize = cvt->len_cvt - 32;
  3.3903 -    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
  3.3904 -    register int eps = 0;
  3.3905 -    Sint16 *dst = (Sint16 *) cvt->buf;
  3.3906 -    const Sint16 *src = (Sint16 *) cvt->buf;
  3.3907 -    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  3.3908 -    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  3.3909 -    Sint16 last_sample0 = sample0;
  3.3910 -    while (dst < target) {
  3.3911 -        src++;
  3.3912 -        eps += dstsize;
  3.3913 -        if ((eps << 1) >= srcsize) {
  3.3914 -            dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  3.3915 -            dst++;
  3.3916 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.3917 -            last_sample0 = sample0;
  3.3918 -            eps -= srcsize;
  3.3919 -        }
  3.3920 -    }
  3.3921 -    cvt->len_cvt = dstsize;
  3.3922 -    if (cvt->filters[++cvt->filter_index]) {
  3.3923 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3924 -    }
  3.3925 -}
  3.3926 -
  3.3927 -static void SDLCALL
  3.3928 -SDL_Upsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3929 -{
  3.3930 -#if DEBUG_CONVERT
  3.3931 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 2 channels.\n", cvt->rate_incr);
  3.3932 -#endif
  3.3933 -
  3.3934 -    const int srcsize = cvt->len_cvt - 64;
  3.3935 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.3936 -    register int eps = 0;
  3.3937 -    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
  3.3938 -    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
  3.3939 -    const Sint16 *target = ((const Sint16 *) cvt->buf);
  3.3940 -    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  3.3941 -    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  3.3942 -    Sint16 last_sample1 = sample1;
  3.3943 -    Sint16 last_sample0 = sample0;
  3.3944 -    while (dst >= target) {
  3.3945 -        dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  3.3946 -        dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  3.3947 -        dst -= 2;
  3.3948 -        eps += srcsize;
  3.3949 -        if ((eps << 1) >= dstsize) {
  3.3950 -            src -= 2;
  3.3951 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.3952 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.3953 -            last_sample1 = sample1;
  3.3954 -            last_sample0 = sample0;
  3.3955 -            eps -= dstsize;
  3.3956 -        }
  3.3957 -    }
  3.3958 -    cvt->len_cvt = dstsize;
  3.3959 -    if (cvt->filters[++cvt->filter_index]) {
  3.3960 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3961 -    }
  3.3962 -}
  3.3963 -
  3.3964 -static void SDLCALL
  3.3965 -SDL_Downsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.3966 -{
  3.3967 -#if DEBUG_CONVERT
  3.3968 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 2 channels.\n", cvt->rate_incr);
  3.3969 -#endif
  3.3970 -
  3.3971 -    const int srcsize = cvt->len_cvt - 64;
  3.3972 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.3973 -    register int eps = 0;
  3.3974 -    Sint16 *dst = (Sint16 *) cvt->buf;
  3.3975 -    const Sint16 *src = (Sint16 *) cvt->buf;
  3.3976 -    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  3.3977 -    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  3.3978 -    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  3.3979 -    Sint16 last_sample0 = sample0;
  3.3980 -    Sint16 last_sample1 = sample1;
  3.3981 -    while (dst < target) {
  3.3982 -        src += 2;
  3.3983 -        eps += dstsize;
  3.3984 -        if ((eps << 1) >= srcsize) {
  3.3985 -            dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  3.3986 -            dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  3.3987 -            dst += 2;
  3.3988 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.3989 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.3990 -            last_sample0 = sample0;
  3.3991 -            last_sample1 = sample1;
  3.3992 -            eps -= srcsize;
  3.3993 -        }
  3.3994 -    }
  3.3995 -    cvt->len_cvt = dstsize;
  3.3996 -    if (cvt->filters[++cvt->filter_index]) {
  3.3997 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.3998 -    }
  3.3999 -}
  3.4000 -
  3.4001 -static void SDLCALL
  3.4002 -SDL_Upsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4003 -{
  3.4004 -#if DEBUG_CONVERT
  3.4005 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 4 channels.\n", cvt->rate_incr);
  3.4006 -#endif
  3.4007 -
  3.4008 -    const int srcsize = cvt->len_cvt - 128;
  3.4009 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.4010 -    register int eps = 0;
  3.4011 -    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
  3.4012 -    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
  3.4013 -    const Sint16 *target = ((const Sint16 *) cvt->buf);
  3.4014 -    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
  3.4015 -    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
  3.4016 -    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  3.4017 -    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  3.4018 -    Sint16 last_sample3 = sample3;
  3.4019 -    Sint16 last_sample2 = sample2;
  3.4020 -    Sint16 last_sample1 = sample1;
  3.4021 -    Sint16 last_sample0 = sample0;
  3.4022 -    while (dst >= target) {
  3.4023 -        dst[3] = ((Sint16) SDL_SwapLE16(sample3));
  3.4024 -        dst[2] = ((Sint16) SDL_SwapLE16(sample2));
  3.4025 -        dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  3.4026 -        dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  3.4027 -        dst -= 4;
  3.4028 -        eps += srcsize;
  3.4029 -        if ((eps << 1) >= dstsize) {
  3.4030 -            src -= 4;
  3.4031 -            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  3.4032 -            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  3.4033 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.4034 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.4035 -            last_sample3 = sample3;
  3.4036 -            last_sample2 = sample2;
  3.4037 -            last_sample1 = sample1;
  3.4038 -            last_sample0 = sample0;
  3.4039 -            eps -= dstsize;
  3.4040 -        }
  3.4041 -    }
  3.4042 -    cvt->len_cvt = dstsize;
  3.4043 -    if (cvt->filters[++cvt->filter_index]) {
  3.4044 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4045 -    }
  3.4046 -}
  3.4047 -
  3.4048 -static void SDLCALL
  3.4049 -SDL_Downsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4050 -{
  3.4051 -#if DEBUG_CONVERT
  3.4052 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 4 channels.\n", cvt->rate_incr);
  3.4053 -#endif
  3.4054 -
  3.4055 -    const int srcsize = cvt->len_cvt - 128;
  3.4056 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.4057 -    register int eps = 0;
  3.4058 -    Sint16 *dst = (Sint16 *) cvt->buf;
  3.4059 -    const Sint16 *src = (Sint16 *) cvt->buf;
  3.4060 -    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  3.4061 -    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  3.4062 -    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  3.4063 -    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
  3.4064 -    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
  3.4065 -    Sint16 last_sample0 = sample0;
  3.4066 -    Sint16 last_sample1 = sample1;
  3.4067 -    Sint16 last_sample2 = sample2;
  3.4068 -    Sint16 last_sample3 = sample3;
  3.4069 -    while (dst < target) {
  3.4070 -        src += 4;
  3.4071 -        eps += dstsize;
  3.4072 -        if ((eps << 1) >= srcsize) {
  3.4073 -            dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  3.4074 -            dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  3.4075 -            dst[2] = ((Sint16) SDL_SwapLE16(sample2));
  3.4076 -            dst[3] = ((Sint16) SDL_SwapLE16(sample3));
  3.4077 -            dst += 4;
  3.4078 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.4079 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.4080 -            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  3.4081 -            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  3.4082 -            last_sample0 = sample0;
  3.4083 -            last_sample1 = sample1;
  3.4084 -            last_sample2 = sample2;
  3.4085 -            last_sample3 = sample3;
  3.4086 -            eps -= srcsize;
  3.4087 -        }
  3.4088 -    }
  3.4089 -    cvt->len_cvt = dstsize;
  3.4090 -    if (cvt->filters[++cvt->filter_index]) {
  3.4091 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4092 -    }
  3.4093 -}
  3.4094 -
  3.4095 -static void SDLCALL
  3.4096 -SDL_Upsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4097 -{
  3.4098 -#if DEBUG_CONVERT
  3.4099 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 6 channels.\n", cvt->rate_incr);
  3.4100 -#endif
  3.4101 -
  3.4102 -    const int srcsize = cvt->len_cvt - 192;
  3.4103 -    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
  3.4104 -    register int eps = 0;
  3.4105 -    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
  3.4106 -    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
  3.4107 -    const Sint16 *target = ((const Sint16 *) cvt->buf);
  3.4108 -    Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
  3.4109 -    Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
  3.4110 -    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
  3.4111 -    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
  3.4112 -    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  3.4113 -    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  3.4114 -    Sint16 last_sample5 = sample5;
  3.4115 -    Sint16 last_sample4 = sample4;
  3.4116 -    Sint16 last_sample3 = sample3;
  3.4117 -    Sint16 last_sample2 = sample2;
  3.4118 -    Sint16 last_sample1 = sample1;
  3.4119 -    Sint16 last_sample0 = sample0;
  3.4120 -    while (dst >= target) {
  3.4121 -        dst[5] = ((Sint16) SDL_SwapLE16(sample5));
  3.4122 -        dst[4] = ((Sint16) SDL_SwapLE16(sample4));
  3.4123 -        dst[3] = ((Sint16) SDL_SwapLE16(sample3));
  3.4124 -        dst[2] = ((Sint16) SDL_SwapLE16(sample2));
  3.4125 -        dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  3.4126 -        dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  3.4127 -        dst -= 6;
  3.4128 -        eps += srcsize;
  3.4129 -        if ((eps << 1) >= dstsize) {
  3.4130 -            src -= 6;
  3.4131 -            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  3.4132 -            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  3.4133 -            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  3.4134 -            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  3.4135 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.4136 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.4137 -            last_sample5 = sample5;
  3.4138 -            last_sample4 = sample4;
  3.4139 -            last_sample3 = sample3;
  3.4140 -            last_sample2 = sample2;
  3.4141 -            last_sample1 = sample1;
  3.4142 -            last_sample0 = sample0;
  3.4143 -            eps -= dstsize;
  3.4144 -        }
  3.4145 -    }
  3.4146 -    cvt->len_cvt = dstsize;
  3.4147 -    if (cvt->filters[++cvt->filter_index]) {
  3.4148 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4149 -    }
  3.4150 -}
  3.4151 -
  3.4152 -static void SDLCALL
  3.4153 -SDL_Downsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4154 -{
  3.4155 -#if DEBUG_CONVERT
  3.4156 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 6 channels.\n", cvt->rate_incr);
  3.4157 -#endif
  3.4158 -
  3.4159 -    const int srcsize = cvt->len_cvt - 192;
  3.4160 -    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
  3.4161 -    register int eps = 0;
  3.4162 -    Sint16 *dst = (Sint16 *) cvt->buf;
  3.4163 -    const Sint16 *src = (Sint16 *) cvt->buf;
  3.4164 -    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  3.4165 -    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  3.4166 -    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  3.4167 -    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
  3.4168 -    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
  3.4169 -    Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
  3.4170 -    Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
  3.4171 -    Sint16 last_sample0 = sample0;
  3.4172 -    Sint16 last_sample1 = sample1;
  3.4173 -    Sint16 last_sample2 = sample2;
  3.4174 -    Sint16 last_sample3 = sample3;
  3.4175 -    Sint16 last_sample4 = sample4;
  3.4176 -    Sint16 last_sample5 = sample5;
  3.4177 -    while (dst < target) {
  3.4178 -        src += 6;
  3.4179 -        eps += dstsize;
  3.4180 -        if ((eps << 1) >= srcsize) {
  3.4181 -            dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  3.4182 -            dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  3.4183 -            dst[2] = ((Sint16) SDL_SwapLE16(sample2));
  3.4184 -            dst[3] = ((Sint16) SDL_SwapLE16(sample3));
  3.4185 -            dst[4] = ((Sint16) SDL_SwapLE16(sample4));
  3.4186 -            dst[5] = ((Sint16) SDL_SwapLE16(sample5));
  3.4187 -            dst += 6;
  3.4188 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.4189 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.4190 -            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  3.4191 -            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  3.4192 -            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  3.4193 -            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  3.4194 -            last_sample0 = sample0;
  3.4195 -            last_sample1 = sample1;
  3.4196 -            last_sample2 = sample2;
  3.4197 -            last_sample3 = sample3;
  3.4198 -            last_sample4 = sample4;
  3.4199 -            last_sample5 = sample5;
  3.4200 -            eps -= srcsize;
  3.4201 -        }
  3.4202 -    }
  3.4203 -    cvt->len_cvt = dstsize;
  3.4204 -    if (cvt->filters[++cvt->filter_index]) {
  3.4205 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4206 -    }
  3.4207 -}
  3.4208 -
  3.4209 -static void SDLCALL
  3.4210 -SDL_Upsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4211 -{
  3.4212 -#if DEBUG_CONVERT
  3.4213 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 8 channels.\n", cvt->rate_incr);
  3.4214 -#endif
  3.4215 -
  3.4216 -    const int srcsize = cvt->len_cvt - 256;
  3.4217 -    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
  3.4218 -    register int eps = 0;
  3.4219 -    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
  3.4220 -    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
  3.4221 -    const Sint16 *target = ((const Sint16 *) cvt->buf);
  3.4222 -    Sint16 sample7 = ((Sint16) SDL_SwapLE16(src[7]));
  3.4223 -    Sint16 sample6 = ((Sint16) SDL_SwapLE16(src[6]));
  3.4224 -    Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
  3.4225 -    Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
  3.4226 -    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
  3.4227 -    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
  3.4228 -    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  3.4229 -    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  3.4230 -    Sint16 last_sample7 = sample7;
  3.4231 -    Sint16 last_sample6 = sample6;
  3.4232 -    Sint16 last_sample5 = sample5;
  3.4233 -    Sint16 last_sample4 = sample4;
  3.4234 -    Sint16 last_sample3 = sample3;
  3.4235 -    Sint16 last_sample2 = sample2;
  3.4236 -    Sint16 last_sample1 = sample1;
  3.4237 -    Sint16 last_sample0 = sample0;
  3.4238 -    while (dst >= target) {
  3.4239 -        dst[7] = ((Sint16) SDL_SwapLE16(sample7));
  3.4240 -        dst[6] = ((Sint16) SDL_SwapLE16(sample6));
  3.4241 -        dst[5] = ((Sint16) SDL_SwapLE16(sample5));
  3.4242 -        dst[4] = ((Sint16) SDL_SwapLE16(sample4));
  3.4243 -        dst[3] = ((Sint16) SDL_SwapLE16(sample3));
  3.4244 -        dst[2] = ((Sint16) SDL_SwapLE16(sample2));
  3.4245 -        dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  3.4246 -        dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  3.4247 -        dst -= 8;
  3.4248 -        eps += srcsize;
  3.4249 -        if ((eps << 1) >= dstsize) {
  3.4250 -            src -= 8;
  3.4251 -            sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
  3.4252 -            sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
  3.4253 -            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  3.4254 -            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  3.4255 -            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  3.4256 -            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  3.4257 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.4258 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.4259 -            last_sample7 = sample7;
  3.4260 -            last_sample6 = sample6;
  3.4261 -            last_sample5 = sample5;
  3.4262 -            last_sample4 = sample4;
  3.4263 -            last_sample3 = sample3;
  3.4264 -            last_sample2 = sample2;
  3.4265 -            last_sample1 = sample1;
  3.4266 -            last_sample0 = sample0;
  3.4267 -            eps -= dstsize;
  3.4268 -        }
  3.4269 -    }
  3.4270 -    cvt->len_cvt = dstsize;
  3.4271 -    if (cvt->filters[++cvt->filter_index]) {
  3.4272 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4273 -    }
  3.4274 -}
  3.4275 -
  3.4276 -static void SDLCALL
  3.4277 -SDL_Downsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4278 -{
  3.4279 -#if DEBUG_CONVERT
  3.4280 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 8 channels.\n", cvt->rate_incr);
  3.4281 -#endif
  3.4282 -
  3.4283 -    const int srcsize = cvt->len_cvt - 256;
  3.4284 -    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
  3.4285 -    register int eps = 0;
  3.4286 -    Sint16 *dst = (Sint16 *) cvt->buf;
  3.4287 -    const Sint16 *src = (Sint16 *) cvt->buf;
  3.4288 -    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  3.4289 -    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  3.4290 -    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  3.4291 -    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
  3.4292 -    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
  3.4293 -    Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
  3.4294 -    Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
  3.4295 -    Sint16 sample6 = ((Sint16) SDL_SwapLE16(src[6]));
  3.4296 -    Sint16 sample7 = ((Sint16) SDL_SwapLE16(src[7]));
  3.4297 -    Sint16 last_sample0 = sample0;
  3.4298 -    Sint16 last_sample1 = sample1;
  3.4299 -    Sint16 last_sample2 = sample2;
  3.4300 -    Sint16 last_sample3 = sample3;
  3.4301 -    Sint16 last_sample4 = sample4;
  3.4302 -    Sint16 last_sample5 = sample5;
  3.4303 -    Sint16 last_sample6 = sample6;
  3.4304 -    Sint16 last_sample7 = sample7;
  3.4305 -    while (dst < target) {
  3.4306 -        src += 8;
  3.4307 -        eps += dstsize;
  3.4308 -        if ((eps << 1) >= srcsize) {
  3.4309 -            dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  3.4310 -            dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  3.4311 -            dst[2] = ((Sint16) SDL_SwapLE16(sample2));
  3.4312 -            dst[3] = ((Sint16) SDL_SwapLE16(sample3));
  3.4313 -            dst[4] = ((Sint16) SDL_SwapLE16(sample4));
  3.4314 -            dst[5] = ((Sint16) SDL_SwapLE16(sample5));
  3.4315 -            dst[6] = ((Sint16) SDL_SwapLE16(sample6));
  3.4316 -            dst[7] = ((Sint16) SDL_SwapLE16(sample7));
  3.4317 -            dst += 8;
  3.4318 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.4319 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.4320 -            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  3.4321 -            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  3.4322 -            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  3.4323 -            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  3.4324 -            sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
  3.4325 -            sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
  3.4326 -            last_sample0 = sample0;
  3.4327 -            last_sample1 = sample1;
  3.4328 -            last_sample2 = sample2;
  3.4329 -            last_sample3 = sample3;
  3.4330 -            last_sample4 = sample4;
  3.4331 -            last_sample5 = sample5;
  3.4332 -            last_sample6 = sample6;
  3.4333 -            last_sample7 = sample7;
  3.4334 -            eps -= srcsize;
  3.4335 -        }
  3.4336 -    }
  3.4337 -    cvt->len_cvt = dstsize;
  3.4338 -    if (cvt->filters[++cvt->filter_index]) {
  3.4339 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4340 -    }
  3.4341 -}
  3.4342 -
  3.4343 -static void SDLCALL
  3.4344 -SDL_Upsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4345 -{
  3.4346 -#if DEBUG_CONVERT
  3.4347 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 1 channels.\n", cvt->rate_incr);
  3.4348 -#endif
  3.4349 -
  3.4350 -    const int srcsize = cvt->len_cvt - 32;
  3.4351 -    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
  3.4352 -    register int eps = 0;
  3.4353 -    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
  3.4354 -    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.4355 -    const Uint16 *target = ((const Uint16 *) cvt->buf);
  3.4356 -    Uint16 sample0 = SDL_SwapBE16(src[0]);
  3.4357 -    Uint16 last_sample0 = sample0;
  3.4358 -    while (dst >= target) {
  3.4359 -        dst[0] = SDL_SwapBE16(sample0);
  3.4360 -        dst--;
  3.4361 -        eps += srcsize;
  3.4362 -        if ((eps << 1) >= dstsize) {
  3.4363 -            src--;
  3.4364 -            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.4365 -            last_sample0 = sample0;
  3.4366 -            eps -= dstsize;
  3.4367 -        }
  3.4368 -    }
  3.4369 -    cvt->len_cvt = dstsize;
  3.4370 -    if (cvt->filters[++cvt->filter_index]) {
  3.4371 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4372 -    }
  3.4373 -}
  3.4374 -
  3.4375 -static void SDLCALL
  3.4376 -SDL_Downsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4377 -{
  3.4378 -#if DEBUG_CONVERT
  3.4379 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 1 channels.\n", cvt->rate_incr);
  3.4380 -#endif
  3.4381 -
  3.4382 -    const int srcsize = cvt->len_cvt - 32;
  3.4383 -    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
  3.4384 -    register int eps = 0;
  3.4385 -    Uint16 *dst = (Uint16 *) cvt->buf;
  3.4386 -    const Uint16 *src = (Uint16 *) cvt->buf;
  3.4387 -    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  3.4388 -    Uint16 sample0 = SDL_SwapBE16(src[0]);
  3.4389 -    Uint16 last_sample0 = sample0;
  3.4390 -    while (dst < target) {
  3.4391 -        src++;
  3.4392 -        eps += dstsize;
  3.4393 -        if ((eps << 1) >= srcsize) {
  3.4394 -            dst[0] = SDL_SwapBE16(sample0);
  3.4395 -            dst++;
  3.4396 -            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.4397 -            last_sample0 = sample0;
  3.4398 -            eps -= srcsize;
  3.4399 -        }
  3.4400 -    }
  3.4401 -    cvt->len_cvt = dstsize;
  3.4402 -    if (cvt->filters[++cvt->filter_index]) {
  3.4403 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4404 -    }
  3.4405 -}
  3.4406 -
  3.4407 -static void SDLCALL
  3.4408 -SDL_Upsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4409 -{
  3.4410 -#if DEBUG_CONVERT
  3.4411 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 2 channels.\n", cvt->rate_incr);
  3.4412 -#endif
  3.4413 -
  3.4414 -    const int srcsize = cvt->len_cvt - 64;
  3.4415 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.4416 -    register int eps = 0;
  3.4417 -    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
  3.4418 -    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
  3.4419 -    const Uint16 *target = ((const Uint16 *) cvt->buf);
  3.4420 -    Uint16 sample1 = SDL_SwapBE16(src[1]);
  3.4421 -    Uint16 sample0 = SDL_SwapBE16(src[0]);
  3.4422 -    Uint16 last_sample1 = sample1;
  3.4423 -    Uint16 last_sample0 = sample0;
  3.4424 -    while (dst >= target) {
  3.4425 -        dst[1] = SDL_SwapBE16(sample1);
  3.4426 -        dst[0] = SDL_SwapBE16(sample0);
  3.4427 -        dst -= 2;
  3.4428 -        eps += srcsize;
  3.4429 -        if ((eps << 1) >= dstsize) {
  3.4430 -            src -= 2;
  3.4431 -            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.4432 -            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.4433 -            last_sample1 = sample1;
  3.4434 -            last_sample0 = sample0;
  3.4435 -            eps -= dstsize;
  3.4436 -        }
  3.4437 -    }
  3.4438 -    cvt->len_cvt = dstsize;
  3.4439 -    if (cvt->filters[++cvt->filter_index]) {
  3.4440 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4441 -    }
  3.4442 -}
  3.4443 -
  3.4444 -static void SDLCALL
  3.4445 -SDL_Downsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4446 -{
  3.4447 -#if DEBUG_CONVERT
  3.4448 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 2 channels.\n", cvt->rate_incr);
  3.4449 -#endif
  3.4450 -
  3.4451 -    const int srcsize = cvt->len_cvt - 64;
  3.4452 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.4453 -    register int eps = 0;
  3.4454 -    Uint16 *dst = (Uint16 *) cvt->buf;
  3.4455 -    const Uint16 *src = (Uint16 *) cvt->buf;
  3.4456 -    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  3.4457 -    Uint16 sample0 = SDL_SwapBE16(src[0]);
  3.4458 -    Uint16 sample1 = SDL_SwapBE16(src[1]);
  3.4459 -    Uint16 last_sample0 = sample0;
  3.4460 -    Uint16 last_sample1 = sample1;
  3.4461 -    while (dst < target) {
  3.4462 -        src += 2;
  3.4463 -        eps += dstsize;
  3.4464 -        if ((eps << 1) >= srcsize) {
  3.4465 -            dst[0] = SDL_SwapBE16(sample0);
  3.4466 -            dst[1] = SDL_SwapBE16(sample1);
  3.4467 -            dst += 2;
  3.4468 -            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.4469 -            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.4470 -            last_sample0 = sample0;
  3.4471 -            last_sample1 = sample1;
  3.4472 -            eps -= srcsize;
  3.4473 -        }
  3.4474 -    }
  3.4475 -    cvt->len_cvt = dstsize;
  3.4476 -    if (cvt->filters[++cvt->filter_index]) {
  3.4477 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4478 -    }
  3.4479 -}
  3.4480 -
  3.4481 -static void SDLCALL
  3.4482 -SDL_Upsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4483 -{
  3.4484 -#if DEBUG_CONVERT
  3.4485 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 4 channels.\n", cvt->rate_incr);
  3.4486 -#endif
  3.4487 -
  3.4488 -    const int srcsize = cvt->len_cvt - 128;
  3.4489 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.4490 -    register int eps = 0;
  3.4491 -    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
  3.4492 -    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
  3.4493 -    const Uint16 *target = ((const Uint16 *) cvt->buf);
  3.4494 -    Uint16 sample3 = SDL_SwapBE16(src[3]);
  3.4495 -    Uint16 sample2 = SDL_SwapBE16(src[2]);
  3.4496 -    Uint16 sample1 = SDL_SwapBE16(src[1]);
  3.4497 -    Uint16 sample0 = SDL_SwapBE16(src[0]);
  3.4498 -    Uint16 last_sample3 = sample3;
  3.4499 -    Uint16 last_sample2 = sample2;
  3.4500 -    Uint16 last_sample1 = sample1;
  3.4501 -    Uint16 last_sample0 = sample0;
  3.4502 -    while (dst >= target) {
  3.4503 -        dst[3] = SDL_SwapBE16(sample3);
  3.4504 -        dst[2] = SDL_SwapBE16(sample2);
  3.4505 -        dst[1] = SDL_SwapBE16(sample1);
  3.4506 -        dst[0] = SDL_SwapBE16(sample0);
  3.4507 -        dst -= 4;
  3.4508 -        eps += srcsize;
  3.4509 -        if ((eps << 1) >= dstsize) {
  3.4510 -            src -= 4;
  3.4511 -            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  3.4512 -            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  3.4513 -            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.4514 -            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.4515 -            last_sample3 = sample3;
  3.4516 -            last_sample2 = sample2;
  3.4517 -            last_sample1 = sample1;
  3.4518 -            last_sample0 = sample0;
  3.4519 -            eps -= dstsize;
  3.4520 -        }
  3.4521 -    }
  3.4522 -    cvt->len_cvt = dstsize;
  3.4523 -    if (cvt->filters[++cvt->filter_index]) {
  3.4524 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4525 -    }
  3.4526 -}
  3.4527 -
  3.4528 -static void SDLCALL
  3.4529 -SDL_Downsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4530 -{
  3.4531 -#if DEBUG_CONVERT
  3.4532 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 4 channels.\n", cvt->rate_incr);
  3.4533 -#endif
  3.4534 -
  3.4535 -    const int srcsize = cvt->len_cvt - 128;
  3.4536 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.4537 -    register int eps = 0;
  3.4538 -    Uint16 *dst = (Uint16 *) cvt->buf;
  3.4539 -    const Uint16 *src = (Uint16 *) cvt->buf;
  3.4540 -    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  3.4541 -    Uint16 sample0 = SDL_SwapBE16(src[0]);
  3.4542 -    Uint16 sample1 = SDL_SwapBE16(src[1]);
  3.4543 -    Uint16 sample2 = SDL_SwapBE16(src[2]);
  3.4544 -    Uint16 sample3 = SDL_SwapBE16(src[3]);
  3.4545 -    Uint16 last_sample0 = sample0;
  3.4546 -    Uint16 last_sample1 = sample1;
  3.4547 -    Uint16 last_sample2 = sample2;
  3.4548 -    Uint16 last_sample3 = sample3;
  3.4549 -    while (dst < target) {
  3.4550 -        src += 4;
  3.4551 -        eps += dstsize;
  3.4552 -        if ((eps << 1) >= srcsize) {
  3.4553 -            dst[0] = SDL_SwapBE16(sample0);
  3.4554 -            dst[1] = SDL_SwapBE16(sample1);
  3.4555 -            dst[2] = SDL_SwapBE16(sample2);
  3.4556 -            dst[3] = SDL_SwapBE16(sample3);
  3.4557 -            dst += 4;
  3.4558 -            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.4559 -            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.4560 -            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  3.4561 -            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  3.4562 -            last_sample0 = sample0;
  3.4563 -            last_sample1 = sample1;
  3.4564 -            last_sample2 = sample2;
  3.4565 -            last_sample3 = sample3;
  3.4566 -            eps -= srcsize;
  3.4567 -        }
  3.4568 -    }
  3.4569 -    cvt->len_cvt = dstsize;
  3.4570 -    if (cvt->filters[++cvt->filter_index]) {
  3.4571 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4572 -    }
  3.4573 -}
  3.4574 -
  3.4575 -static void SDLCALL
  3.4576 -SDL_Upsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4577 -{
  3.4578 -#if DEBUG_CONVERT
  3.4579 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 6 channels.\n", cvt->rate_incr);
  3.4580 -#endif
  3.4581 -
  3.4582 -    const int srcsize = cvt->len_cvt - 192;
  3.4583 -    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
  3.4584 -    register int eps = 0;
  3.4585 -    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
  3.4586 -    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
  3.4587 -    const Uint16 *target = ((const Uint16 *) cvt->buf);
  3.4588 -    Uint16 sample5 = SDL_SwapBE16(src[5]);
  3.4589 -    Uint16 sample4 = SDL_SwapBE16(src[4]);
  3.4590 -    Uint16 sample3 = SDL_SwapBE16(src[3]);
  3.4591 -    Uint16 sample2 = SDL_SwapBE16(src[2]);
  3.4592 -    Uint16 sample1 = SDL_SwapBE16(src[1]);
  3.4593 -    Uint16 sample0 = SDL_SwapBE16(src[0]);
  3.4594 -    Uint16 last_sample5 = sample5;
  3.4595 -    Uint16 last_sample4 = sample4;
  3.4596 -    Uint16 last_sample3 = sample3;
  3.4597 -    Uint16 last_sample2 = sample2;
  3.4598 -    Uint16 last_sample1 = sample1;
  3.4599 -    Uint16 last_sample0 = sample0;
  3.4600 -    while (dst >= target) {
  3.4601 -        dst[5] = SDL_SwapBE16(sample5);
  3.4602 -        dst[4] = SDL_SwapBE16(sample4);
  3.4603 -        dst[3] = SDL_SwapBE16(sample3);
  3.4604 -        dst[2] = SDL_SwapBE16(sample2);
  3.4605 -        dst[1] = SDL_SwapBE16(sample1);
  3.4606 -        dst[0] = SDL_SwapBE16(sample0);
  3.4607 -        dst -= 6;
  3.4608 -        eps += srcsize;
  3.4609 -        if ((eps << 1) >= dstsize) {
  3.4610 -            src -= 6;
  3.4611 -            sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  3.4612 -            sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  3.4613 -            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  3.4614 -            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  3.4615 -            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.4616 -            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.4617 -            last_sample5 = sample5;
  3.4618 -            last_sample4 = sample4;
  3.4619 -            last_sample3 = sample3;
  3.4620 -            last_sample2 = sample2;
  3.4621 -            last_sample1 = sample1;
  3.4622 -            last_sample0 = sample0;
  3.4623 -            eps -= dstsize;
  3.4624 -        }
  3.4625 -    }
  3.4626 -    cvt->len_cvt = dstsize;
  3.4627 -    if (cvt->filters[++cvt->filter_index]) {
  3.4628 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4629 -    }
  3.4630 -}
  3.4631 -
  3.4632 -static void SDLCALL
  3.4633 -SDL_Downsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4634 -{
  3.4635 -#if DEBUG_CONVERT
  3.4636 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 6 channels.\n", cvt->rate_incr);
  3.4637 -#endif
  3.4638 -
  3.4639 -    const int srcsize = cvt->len_cvt - 192;
  3.4640 -    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
  3.4641 -    register int eps = 0;
  3.4642 -    Uint16 *dst = (Uint16 *) cvt->buf;
  3.4643 -    const Uint16 *src = (Uint16 *) cvt->buf;
  3.4644 -    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  3.4645 -    Uint16 sample0 = SDL_SwapBE16(src[0]);
  3.4646 -    Uint16 sample1 = SDL_SwapBE16(src[1]);
  3.4647 -    Uint16 sample2 = SDL_SwapBE16(src[2]);
  3.4648 -    Uint16 sample3 = SDL_SwapBE16(src[3]);
  3.4649 -    Uint16 sample4 = SDL_SwapBE16(src[4]);
  3.4650 -    Uint16 sample5 = SDL_SwapBE16(src[5]);
  3.4651 -    Uint16 last_sample0 = sample0;
  3.4652 -    Uint16 last_sample1 = sample1;
  3.4653 -    Uint16 last_sample2 = sample2;
  3.4654 -    Uint16 last_sample3 = sample3;
  3.4655 -    Uint16 last_sample4 = sample4;
  3.4656 -    Uint16 last_sample5 = sample5;
  3.4657 -    while (dst < target) {
  3.4658 -        src += 6;
  3.4659 -        eps += dstsize;
  3.4660 -        if ((eps << 1) >= srcsize) {
  3.4661 -            dst[0] = SDL_SwapBE16(sample0);
  3.4662 -            dst[1] = SDL_SwapBE16(sample1);
  3.4663 -            dst[2] = SDL_SwapBE16(sample2);
  3.4664 -            dst[3] = SDL_SwapBE16(sample3);
  3.4665 -            dst[4] = SDL_SwapBE16(sample4);
  3.4666 -            dst[5] = SDL_SwapBE16(sample5);
  3.4667 -            dst += 6;
  3.4668 -            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.4669 -            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.4670 -            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  3.4671 -            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  3.4672 -            sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  3.4673 -            sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  3.4674 -            last_sample0 = sample0;
  3.4675 -            last_sample1 = sample1;
  3.4676 -            last_sample2 = sample2;
  3.4677 -            last_sample3 = sample3;
  3.4678 -            last_sample4 = sample4;
  3.4679 -            last_sample5 = sample5;
  3.4680 -            eps -= srcsize;
  3.4681 -        }
  3.4682 -    }
  3.4683 -    cvt->len_cvt = dstsize;
  3.4684 -    if (cvt->filters[++cvt->filter_index]) {
  3.4685 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4686 -    }
  3.4687 -}
  3.4688 -
  3.4689 -static void SDLCALL
  3.4690 -SDL_Upsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4691 -{
  3.4692 -#if DEBUG_CONVERT
  3.4693 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 8 channels.\n", cvt->rate_incr);
  3.4694 -#endif
  3.4695 -
  3.4696 -    const int srcsize = cvt->len_cvt - 256;
  3.4697 -    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
  3.4698 -    register int eps = 0;
  3.4699 -    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
  3.4700 -    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
  3.4701 -    const Uint16 *target = ((const Uint16 *) cvt->buf);
  3.4702 -    Uint16 sample7 = SDL_SwapBE16(src[7]);
  3.4703 -    Uint16 sample6 = SDL_SwapBE16(src[6]);
  3.4704 -    Uint16 sample5 = SDL_SwapBE16(src[5]);
  3.4705 -    Uint16 sample4 = SDL_SwapBE16(src[4]);
  3.4706 -    Uint16 sample3 = SDL_SwapBE16(src[3]);
  3.4707 -    Uint16 sample2 = SDL_SwapBE16(src[2]);
  3.4708 -    Uint16 sample1 = SDL_SwapBE16(src[1]);
  3.4709 -    Uint16 sample0 = SDL_SwapBE16(src[0]);
  3.4710 -    Uint16 last_sample7 = sample7;
  3.4711 -    Uint16 last_sample6 = sample6;
  3.4712 -    Uint16 last_sample5 = sample5;
  3.4713 -    Uint16 last_sample4 = sample4;
  3.4714 -    Uint16 last_sample3 = sample3;
  3.4715 -    Uint16 last_sample2 = sample2;
  3.4716 -    Uint16 last_sample1 = sample1;
  3.4717 -    Uint16 last_sample0 = sample0;
  3.4718 -    while (dst >= target) {
  3.4719 -        dst[7] = SDL_SwapBE16(sample7);
  3.4720 -        dst[6] = SDL_SwapBE16(sample6);
  3.4721 -        dst[5] = SDL_SwapBE16(sample5);
  3.4722 -        dst[4] = SDL_SwapBE16(sample4);
  3.4723 -        dst[3] = SDL_SwapBE16(sample3);
  3.4724 -        dst[2] = SDL_SwapBE16(sample2);
  3.4725 -        dst[1] = SDL_SwapBE16(sample1);
  3.4726 -        dst[0] = SDL_SwapBE16(sample0);
  3.4727 -        dst -= 8;
  3.4728 -        eps += srcsize;
  3.4729 -        if ((eps << 1) >= dstsize) {
  3.4730 -            src -= 8;
  3.4731 -            sample7 = (Uint16) ((((Sint32) SDL_SwapBE16(src[7])) + ((Sint32) last_sample7)) >> 1);
  3.4732 -            sample6 = (Uint16) ((((Sint32) SDL_SwapBE16(src[6])) + ((Sint32) last_sample6)) >> 1);
  3.4733 -            sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  3.4734 -            sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  3.4735 -            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  3.4736 -            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  3.4737 -            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.4738 -            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.4739 -            last_sample7 = sample7;
  3.4740 -            last_sample6 = sample6;
  3.4741 -            last_sample5 = sample5;
  3.4742 -            last_sample4 = sample4;
  3.4743 -            last_sample3 = sample3;
  3.4744 -            last_sample2 = sample2;
  3.4745 -            last_sample1 = sample1;
  3.4746 -            last_sample0 = sample0;
  3.4747 -            eps -= dstsize;
  3.4748 -        }
  3.4749 -    }
  3.4750 -    cvt->len_cvt = dstsize;
  3.4751 -    if (cvt->filters[++cvt->filter_index]) {
  3.4752 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4753 -    }
  3.4754 -}
  3.4755 -
  3.4756 -static void SDLCALL
  3.4757 -SDL_Downsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4758 -{
  3.4759 -#if DEBUG_CONVERT
  3.4760 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 8 channels.\n", cvt->rate_incr);
  3.4761 -#endif
  3.4762 -
  3.4763 -    const int srcsize = cvt->len_cvt - 256;
  3.4764 -    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
  3.4765 -    register int eps = 0;
  3.4766 -    Uint16 *dst = (Uint16 *) cvt->buf;
  3.4767 -    const Uint16 *src = (Uint16 *) cvt->buf;
  3.4768 -    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  3.4769 -    Uint16 sample0 = SDL_SwapBE16(src[0]);
  3.4770 -    Uint16 sample1 = SDL_SwapBE16(src[1]);
  3.4771 -    Uint16 sample2 = SDL_SwapBE16(src[2]);
  3.4772 -    Uint16 sample3 = SDL_SwapBE16(src[3]);
  3.4773 -    Uint16 sample4 = SDL_SwapBE16(src[4]);
  3.4774 -    Uint16 sample5 = SDL_SwapBE16(src[5]);
  3.4775 -    Uint16 sample6 = SDL_SwapBE16(src[6]);
  3.4776 -    Uint16 sample7 = SDL_SwapBE16(src[7]);
  3.4777 -    Uint16 last_sample0 = sample0;
  3.4778 -    Uint16 last_sample1 = sample1;
  3.4779 -    Uint16 last_sample2 = sample2;
  3.4780 -    Uint16 last_sample3 = sample3;
  3.4781 -    Uint16 last_sample4 = sample4;
  3.4782 -    Uint16 last_sample5 = sample5;
  3.4783 -    Uint16 last_sample6 = sample6;
  3.4784 -    Uint16 last_sample7 = sample7;
  3.4785 -    while (dst < target) {
  3.4786 -        src += 8;
  3.4787 -        eps += dstsize;
  3.4788 -        if ((eps << 1) >= srcsize) {
  3.4789 -            dst[0] = SDL_SwapBE16(sample0);
  3.4790 -            dst[1] = SDL_SwapBE16(sample1);
  3.4791 -            dst[2] = SDL_SwapBE16(sample2);
  3.4792 -            dst[3] = SDL_SwapBE16(sample3);
  3.4793 -            dst[4] = SDL_SwapBE16(sample4);
  3.4794 -            dst[5] = SDL_SwapBE16(sample5);
  3.4795 -            dst[6] = SDL_SwapBE16(sample6);
  3.4796 -            dst[7] = SDL_SwapBE16(sample7);
  3.4797 -            dst += 8;
  3.4798 -            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  3.4799 -            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  3.4800 -            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  3.4801 -            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  3.4802 -            sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  3.4803 -            sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  3.4804 -            sample6 = (Uint16) ((((Sint32) SDL_SwapBE16(src[6])) + ((Sint32) last_sample6)) >> 1);
  3.4805 -            sample7 = (Uint16) ((((Sint32) SDL_SwapBE16(src[7])) + ((Sint32) last_sample7)) >> 1);
  3.4806 -            last_sample0 = sample0;
  3.4807 -            last_sample1 = sample1;
  3.4808 -            last_sample2 = sample2;
  3.4809 -            last_sample3 = sample3;
  3.4810 -            last_sample4 = sample4;
  3.4811 -            last_sample5 = sample5;
  3.4812 -            last_sample6 = sample6;
  3.4813 -            last_sample7 = sample7;
  3.4814 -            eps -= srcsize;
  3.4815 -        }
  3.4816 -    }
  3.4817 -    cvt->len_cvt = dstsize;
  3.4818 -    if (cvt->filters[++cvt->filter_index]) {
  3.4819 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4820 -    }
  3.4821 -}
  3.4822 -
  3.4823 -static void SDLCALL
  3.4824 -SDL_Upsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4825 -{
  3.4826 -#if DEBUG_CONVERT
  3.4827 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 1 channels.\n", cvt->rate_incr);
  3.4828 -#endif
  3.4829 -
  3.4830 -    const int srcsize = cvt->len_cvt - 32;
  3.4831 -    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
  3.4832 -    register int eps = 0;
  3.4833 -    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
  3.4834 -    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.4835 -    const Sint16 *target = ((const Sint16 *) cvt->buf);
  3.4836 -    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  3.4837 -    Sint16 last_sample0 = sample0;
  3.4838 -    while (dst >= target) {
  3.4839 -        dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  3.4840 -        dst--;
  3.4841 -        eps += srcsize;
  3.4842 -        if ((eps << 1) >= dstsize) {
  3.4843 -            src--;
  3.4844 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.4845 -            last_sample0 = sample0;
  3.4846 -            eps -= dstsize;
  3.4847 -        }
  3.4848 -    }
  3.4849 -    cvt->len_cvt = dstsize;
  3.4850 -    if (cvt->filters[++cvt->filter_index]) {
  3.4851 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4852 -    }
  3.4853 -}
  3.4854 -
  3.4855 -static void SDLCALL
  3.4856 -SDL_Downsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4857 -{
  3.4858 -#if DEBUG_CONVERT
  3.4859 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 1 channels.\n", cvt->rate_incr);
  3.4860 -#endif
  3.4861 -
  3.4862 -    const int srcsize = cvt->len_cvt - 32;
  3.4863 -    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
  3.4864 -    register int eps = 0;
  3.4865 -    Sint16 *dst = (Sint16 *) cvt->buf;
  3.4866 -    const Sint16 *src = (Sint16 *) cvt->buf;
  3.4867 -    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  3.4868 -    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  3.4869 -    Sint16 last_sample0 = sample0;
  3.4870 -    while (dst < target) {
  3.4871 -        src++;
  3.4872 -        eps += dstsize;
  3.4873 -        if ((eps << 1) >= srcsize) {
  3.4874 -            dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  3.4875 -            dst++;
  3.4876 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.4877 -            last_sample0 = sample0;
  3.4878 -            eps -= srcsize;
  3.4879 -        }
  3.4880 -    }
  3.4881 -    cvt->len_cvt = dstsize;
  3.4882 -    if (cvt->filters[++cvt->filter_index]) {
  3.4883 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4884 -    }
  3.4885 -}
  3.4886 -
  3.4887 -static void SDLCALL
  3.4888 -SDL_Upsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4889 -{
  3.4890 -#if DEBUG_CONVERT
  3.4891 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 2 channels.\n", cvt->rate_incr);
  3.4892 -#endif
  3.4893 -
  3.4894 -    const int srcsize = cvt->len_cvt - 64;
  3.4895 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.4896 -    register int eps = 0;
  3.4897 -    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
  3.4898 -    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
  3.4899 -    const Sint16 *target = ((const Sint16 *) cvt->buf);
  3.4900 -    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  3.4901 -    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  3.4902 -    Sint16 last_sample1 = sample1;
  3.4903 -    Sint16 last_sample0 = sample0;
  3.4904 -    while (dst >= target) {
  3.4905 -        dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  3.4906 -        dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  3.4907 -        dst -= 2;
  3.4908 -        eps += srcsize;
  3.4909 -        if ((eps << 1) >= dstsize) {
  3.4910 -            src -= 2;
  3.4911 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.4912 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.4913 -            last_sample1 = sample1;
  3.4914 -            last_sample0 = sample0;
  3.4915 -            eps -= dstsize;
  3.4916 -        }
  3.4917 -    }
  3.4918 -    cvt->len_cvt = dstsize;
  3.4919 -    if (cvt->filters[++cvt->filter_index]) {
  3.4920 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4921 -    }
  3.4922 -}
  3.4923 -
  3.4924 -static void SDLCALL
  3.4925 -SDL_Downsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4926 -{
  3.4927 -#if DEBUG_CONVERT
  3.4928 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 2 channels.\n", cvt->rate_incr);
  3.4929 -#endif
  3.4930 -
  3.4931 -    const int srcsize = cvt->len_cvt - 64;
  3.4932 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.4933 -    register int eps = 0;
  3.4934 -    Sint16 *dst = (Sint16 *) cvt->buf;
  3.4935 -    const Sint16 *src = (Sint16 *) cvt->buf;
  3.4936 -    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  3.4937 -    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  3.4938 -    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  3.4939 -    Sint16 last_sample0 = sample0;
  3.4940 -    Sint16 last_sample1 = sample1;
  3.4941 -    while (dst < target) {
  3.4942 -        src += 2;
  3.4943 -        eps += dstsize;
  3.4944 -        if ((eps << 1) >= srcsize) {
  3.4945 -            dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  3.4946 -            dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  3.4947 -            dst += 2;
  3.4948 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.4949 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.4950 -            last_sample0 = sample0;
  3.4951 -            last_sample1 = sample1;
  3.4952 -            eps -= srcsize;
  3.4953 -        }
  3.4954 -    }
  3.4955 -    cvt->len_cvt = dstsize;
  3.4956 -    if (cvt->filters[++cvt->filter_index]) {
  3.4957 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.4958 -    }
  3.4959 -}
  3.4960 -
  3.4961 -static void SDLCALL
  3.4962 -SDL_Upsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.4963 -{
  3.4964 -#if DEBUG_CONVERT
  3.4965 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 4 channels.\n", cvt->rate_incr);
  3.4966 -#endif
  3.4967 -
  3.4968 -    const int srcsize = cvt->len_cvt - 128;
  3.4969 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.4970 -    register int eps = 0;
  3.4971 -    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
  3.4972 -    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
  3.4973 -    const Sint16 *target = ((const Sint16 *) cvt->buf);
  3.4974 -    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
  3.4975 -    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
  3.4976 -    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  3.4977 -    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  3.4978 -    Sint16 last_sample3 = sample3;
  3.4979 -    Sint16 last_sample2 = sample2;
  3.4980 -    Sint16 last_sample1 = sample1;
  3.4981 -    Sint16 last_sample0 = sample0;
  3.4982 -    while (dst >= target) {
  3.4983 -        dst[3] = ((Sint16) SDL_SwapBE16(sample3));
  3.4984 -        dst[2] = ((Sint16) SDL_SwapBE16(sample2));
  3.4985 -        dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  3.4986 -        dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  3.4987 -        dst -= 4;
  3.4988 -        eps += srcsize;
  3.4989 -        if ((eps << 1) >= dstsize) {
  3.4990 -            src -= 4;
  3.4991 -            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  3.4992 -            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  3.4993 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.4994 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.4995 -            last_sample3 = sample3;
  3.4996 -            last_sample2 = sample2;
  3.4997 -            last_sample1 = sample1;
  3.4998 -            last_sample0 = sample0;
  3.4999 -            eps -= dstsize;
  3.5000 -        }
  3.5001 -    }
  3.5002 -    cvt->len_cvt = dstsize;
  3.5003 -    if (cvt->filters[++cvt->filter_index]) {
  3.5004 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5005 -    }
  3.5006 -}
  3.5007 -
  3.5008 -static void SDLCALL
  3.5009 -SDL_Downsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5010 -{
  3.5011 -#if DEBUG_CONVERT
  3.5012 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 4 channels.\n", cvt->rate_incr);
  3.5013 -#endif
  3.5014 -
  3.5015 -    const int srcsize = cvt->len_cvt - 128;
  3.5016 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.5017 -    register int eps = 0;
  3.5018 -    Sint16 *dst = (Sint16 *) cvt->buf;
  3.5019 -    const Sint16 *src = (Sint16 *) cvt->buf;
  3.5020 -    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  3.5021 -    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  3.5022 -    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  3.5023 -    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
  3.5024 -    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
  3.5025 -    Sint16 last_sample0 = sample0;
  3.5026 -    Sint16 last_sample1 = sample1;
  3.5027 -    Sint16 last_sample2 = sample2;
  3.5028 -    Sint16 last_sample3 = sample3;
  3.5029 -    while (dst < target) {
  3.5030 -        src += 4;
  3.5031 -        eps += dstsize;
  3.5032 -        if ((eps << 1) >= srcsize) {
  3.5033 -            dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  3.5034 -            dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  3.5035 -            dst[2] = ((Sint16) SDL_SwapBE16(sample2));
  3.5036 -            dst[3] = ((Sint16) SDL_SwapBE16(sample3));
  3.5037 -            dst += 4;
  3.5038 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.5039 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.5040 -            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  3.5041 -            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  3.5042 -            last_sample0 = sample0;
  3.5043 -            last_sample1 = sample1;
  3.5044 -            last_sample2 = sample2;
  3.5045 -            last_sample3 = sample3;
  3.5046 -            eps -= srcsize;
  3.5047 -        }
  3.5048 -    }
  3.5049 -    cvt->len_cvt = dstsize;
  3.5050 -    if (cvt->filters[++cvt->filter_index]) {
  3.5051 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5052 -    }
  3.5053 -}
  3.5054 -
  3.5055 -static void SDLCALL
  3.5056 -SDL_Upsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5057 -{
  3.5058 -#if DEBUG_CONVERT
  3.5059 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 6 channels.\n", cvt->rate_incr);
  3.5060 -#endif
  3.5061 -
  3.5062 -    const int srcsize = cvt->len_cvt - 192;
  3.5063 -    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
  3.5064 -    register int eps = 0;
  3.5065 -    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
  3.5066 -    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
  3.5067 -    const Sint16 *target = ((const Sint16 *) cvt->buf);
  3.5068 -    Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
  3.5069 -    Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
  3.5070 -    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
  3.5071 -    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
  3.5072 -    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  3.5073 -    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  3.5074 -    Sint16 last_sample5 = sample5;
  3.5075 -    Sint16 last_sample4 = sample4;
  3.5076 -    Sint16 last_sample3 = sample3;
  3.5077 -    Sint16 last_sample2 = sample2;
  3.5078 -    Sint16 last_sample1 = sample1;
  3.5079 -    Sint16 last_sample0 = sample0;
  3.5080 -    while (dst >= target) {
  3.5081 -        dst[5] = ((Sint16) SDL_SwapBE16(sample5));
  3.5082 -        dst[4] = ((Sint16) SDL_SwapBE16(sample4));
  3.5083 -        dst[3] = ((Sint16) SDL_SwapBE16(sample3));
  3.5084 -        dst[2] = ((Sint16) SDL_SwapBE16(sample2));
  3.5085 -        dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  3.5086 -        dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  3.5087 -        dst -= 6;
  3.5088 -        eps += srcsize;
  3.5089 -        if ((eps << 1) >= dstsize) {
  3.5090 -            src -= 6;
  3.5091 -            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  3.5092 -            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  3.5093 -            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  3.5094 -            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  3.5095 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.5096 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.5097 -            last_sample5 = sample5;
  3.5098 -            last_sample4 = sample4;
  3.5099 -            last_sample3 = sample3;
  3.5100 -            last_sample2 = sample2;
  3.5101 -            last_sample1 = sample1;
  3.5102 -            last_sample0 = sample0;
  3.5103 -            eps -= dstsize;
  3.5104 -        }
  3.5105 -    }
  3.5106 -    cvt->len_cvt = dstsize;
  3.5107 -    if (cvt->filters[++cvt->filter_index]) {
  3.5108 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5109 -    }
  3.5110 -}
  3.5111 -
  3.5112 -static void SDLCALL
  3.5113 -SDL_Downsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5114 -{
  3.5115 -#if DEBUG_CONVERT
  3.5116 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 6 channels.\n", cvt->rate_incr);
  3.5117 -#endif
  3.5118 -
  3.5119 -    const int srcsize = cvt->len_cvt - 192;
  3.5120 -    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
  3.5121 -    register int eps = 0;
  3.5122 -    Sint16 *dst = (Sint16 *) cvt->buf;
  3.5123 -    const Sint16 *src = (Sint16 *) cvt->buf;
  3.5124 -    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  3.5125 -    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  3.5126 -    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  3.5127 -    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
  3.5128 -    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
  3.5129 -    Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
  3.5130 -    Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
  3.5131 -    Sint16 last_sample0 = sample0;
  3.5132 -    Sint16 last_sample1 = sample1;
  3.5133 -    Sint16 last_sample2 = sample2;
  3.5134 -    Sint16 last_sample3 = sample3;
  3.5135 -    Sint16 last_sample4 = sample4;
  3.5136 -    Sint16 last_sample5 = sample5;
  3.5137 -    while (dst < target) {
  3.5138 -        src += 6;
  3.5139 -        eps += dstsize;
  3.5140 -        if ((eps << 1) >= srcsize) {
  3.5141 -            dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  3.5142 -            dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  3.5143 -            dst[2] = ((Sint16) SDL_SwapBE16(sample2));
  3.5144 -            dst[3] = ((Sint16) SDL_SwapBE16(sample3));
  3.5145 -            dst[4] = ((Sint16) SDL_SwapBE16(sample4));
  3.5146 -            dst[5] = ((Sint16) SDL_SwapBE16(sample5));
  3.5147 -            dst += 6;
  3.5148 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.5149 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.5150 -            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  3.5151 -            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  3.5152 -            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  3.5153 -            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  3.5154 -            last_sample0 = sample0;
  3.5155 -            last_sample1 = sample1;
  3.5156 -            last_sample2 = sample2;
  3.5157 -            last_sample3 = sample3;
  3.5158 -            last_sample4 = sample4;
  3.5159 -            last_sample5 = sample5;
  3.5160 -            eps -= srcsize;
  3.5161 -        }
  3.5162 -    }
  3.5163 -    cvt->len_cvt = dstsize;
  3.5164 -    if (cvt->filters[++cvt->filter_index]) {
  3.5165 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5166 -    }
  3.5167 -}
  3.5168 -
  3.5169 -static void SDLCALL
  3.5170 -SDL_Upsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5171 -{
  3.5172 -#if DEBUG_CONVERT
  3.5173 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 8 channels.\n", cvt->rate_incr);
  3.5174 -#endif
  3.5175 -
  3.5176 -    const int srcsize = cvt->len_cvt - 256;
  3.5177 -    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
  3.5178 -    register int eps = 0;
  3.5179 -    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
  3.5180 -    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
  3.5181 -    const Sint16 *target = ((const Sint16 *) cvt->buf);
  3.5182 -    Sint16 sample7 = ((Sint16) SDL_SwapBE16(src[7]));
  3.5183 -    Sint16 sample6 = ((Sint16) SDL_SwapBE16(src[6]));
  3.5184 -    Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
  3.5185 -    Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
  3.5186 -    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
  3.5187 -    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
  3.5188 -    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  3.5189 -    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  3.5190 -    Sint16 last_sample7 = sample7;
  3.5191 -    Sint16 last_sample6 = sample6;
  3.5192 -    Sint16 last_sample5 = sample5;
  3.5193 -    Sint16 last_sample4 = sample4;
  3.5194 -    Sint16 last_sample3 = sample3;
  3.5195 -    Sint16 last_sample2 = sample2;
  3.5196 -    Sint16 last_sample1 = sample1;
  3.5197 -    Sint16 last_sample0 = sample0;
  3.5198 -    while (dst >= target) {
  3.5199 -        dst[7] = ((Sint16) SDL_SwapBE16(sample7));
  3.5200 -        dst[6] = ((Sint16) SDL_SwapBE16(sample6));
  3.5201 -        dst[5] = ((Sint16) SDL_SwapBE16(sample5));
  3.5202 -        dst[4] = ((Sint16) SDL_SwapBE16(sample4));
  3.5203 -        dst[3] = ((Sint16) SDL_SwapBE16(sample3));
  3.5204 -        dst[2] = ((Sint16) SDL_SwapBE16(sample2));
  3.5205 -        dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  3.5206 -        dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  3.5207 -        dst -= 8;
  3.5208 -        eps += srcsize;
  3.5209 -        if ((eps << 1) >= dstsize) {
  3.5210 -            src -= 8;
  3.5211 -            sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
  3.5212 -            sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
  3.5213 -            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  3.5214 -            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  3.5215 -            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  3.5216 -            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  3.5217 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.5218 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.5219 -            last_sample7 = sample7;
  3.5220 -            last_sample6 = sample6;
  3.5221 -            last_sample5 = sample5;
  3.5222 -            last_sample4 = sample4;
  3.5223 -            last_sample3 = sample3;
  3.5224 -            last_sample2 = sample2;
  3.5225 -            last_sample1 = sample1;
  3.5226 -            last_sample0 = sample0;
  3.5227 -            eps -= dstsize;
  3.5228 -        }
  3.5229 -    }
  3.5230 -    cvt->len_cvt = dstsize;
  3.5231 -    if (cvt->filters[++cvt->filter_index]) {
  3.5232 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5233 -    }
  3.5234 -}
  3.5235 -
  3.5236 -static void SDLCALL
  3.5237 -SDL_Downsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5238 -{
  3.5239 -#if DEBUG_CONVERT
  3.5240 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 8 channels.\n", cvt->rate_incr);
  3.5241 -#endif
  3.5242 -
  3.5243 -    const int srcsize = cvt->len_cvt - 256;
  3.5244 -    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
  3.5245 -    register int eps = 0;
  3.5246 -    Sint16 *dst = (Sint16 *) cvt->buf;
  3.5247 -    const Sint16 *src = (Sint16 *) cvt->buf;
  3.5248 -    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  3.5249 -    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  3.5250 -    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  3.5251 -    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
  3.5252 -    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
  3.5253 -    Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
  3.5254 -    Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
  3.5255 -    Sint16 sample6 = ((Sint16) SDL_SwapBE16(src[6]));
  3.5256 -    Sint16 sample7 = ((Sint16) SDL_SwapBE16(src[7]));
  3.5257 -    Sint16 last_sample0 = sample0;
  3.5258 -    Sint16 last_sample1 = sample1;
  3.5259 -    Sint16 last_sample2 = sample2;
  3.5260 -    Sint16 last_sample3 = sample3;
  3.5261 -    Sint16 last_sample4 = sample4;
  3.5262 -    Sint16 last_sample5 = sample5;
  3.5263 -    Sint16 last_sample6 = sample6;
  3.5264 -    Sint16 last_sample7 = sample7;
  3.5265 -    while (dst < target) {
  3.5266 -        src += 8;
  3.5267 -        eps += dstsize;
  3.5268 -        if ((eps << 1) >= srcsize) {
  3.5269 -            dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  3.5270 -            dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  3.5271 -            dst[2] = ((Sint16) SDL_SwapBE16(sample2));
  3.5272 -            dst[3] = ((Sint16) SDL_SwapBE16(sample3));
  3.5273 -            dst[4] = ((Sint16) SDL_SwapBE16(sample4));
  3.5274 -            dst[5] = ((Sint16) SDL_SwapBE16(sample5));
  3.5275 -            dst[6] = ((Sint16) SDL_SwapBE16(sample6));
  3.5276 -            dst[7] = ((Sint16) SDL_SwapBE16(sample7));
  3.5277 -            dst += 8;
  3.5278 -            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  3.5279 -            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  3.5280 -            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  3.5281 -            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  3.5282 -            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  3.5283 -            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  3.5284 -            sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
  3.5285 -            sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
  3.5286 -            last_sample0 = sample0;
  3.5287 -            last_sample1 = sample1;
  3.5288 -            last_sample2 = sample2;
  3.5289 -            last_sample3 = sample3;
  3.5290 -            last_sample4 = sample4;
  3.5291 -            last_sample5 = sample5;
  3.5292 -            last_sample6 = sample6;
  3.5293 -            last_sample7 = sample7;
  3.5294 -            eps -= srcsize;
  3.5295 -        }
  3.5296 -    }
  3.5297 -    cvt->len_cvt = dstsize;
  3.5298 -    if (cvt->filters[++cvt->filter_index]) {
  3.5299 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5300 -    }
  3.5301 -}
  3.5302 -
  3.5303 -static void SDLCALL
  3.5304 -SDL_Upsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5305 -{
  3.5306 -#if DEBUG_CONVERT
  3.5307 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 1 channels.\n", cvt->rate_incr);
  3.5308 -#endif
  3.5309 -
  3.5310 -    const int srcsize = cvt->len_cvt - 64;
  3.5311 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.5312 -    register int eps = 0;
  3.5313 -    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
  3.5314 -    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.5315 -    const Sint32 *target = ((const Sint32 *) cvt->buf);
  3.5316 -    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  3.5317 -    Sint32 last_sample0 = sample0;
  3.5318 -    while (dst >= target) {
  3.5319 -        dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  3.5320 -        dst--;
  3.5321 -        eps += srcsize;
  3.5322 -        if ((eps << 1) >= dstsize) {
  3.5323 -            src--;
  3.5324 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5325 -            last_sample0 = sample0;
  3.5326 -            eps -= dstsize;
  3.5327 -        }
  3.5328 -    }
  3.5329 -    cvt->len_cvt = dstsize;
  3.5330 -    if (cvt->filters[++cvt->filter_index]) {
  3.5331 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5332 -    }
  3.5333 -}
  3.5334 -
  3.5335 -static void SDLCALL
  3.5336 -SDL_Downsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5337 -{
  3.5338 -#if DEBUG_CONVERT
  3.5339 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 1 channels.\n", cvt->rate_incr);
  3.5340 -#endif
  3.5341 -
  3.5342 -    const int srcsize = cvt->len_cvt - 64;
  3.5343 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.5344 -    register int eps = 0;
  3.5345 -    Sint32 *dst = (Sint32 *) cvt->buf;
  3.5346 -    const Sint32 *src = (Sint32 *) cvt->buf;
  3.5347 -    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  3.5348 -    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  3.5349 -    Sint32 last_sample0 = sample0;
  3.5350 -    while (dst < target) {
  3.5351 -        src++;
  3.5352 -        eps += dstsize;
  3.5353 -        if ((eps << 1) >= srcsize) {
  3.5354 -            dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  3.5355 -            dst++;
  3.5356 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5357 -            last_sample0 = sample0;
  3.5358 -            eps -= srcsize;
  3.5359 -        }
  3.5360 -    }
  3.5361 -    cvt->len_cvt = dstsize;
  3.5362 -    if (cvt->filters[++cvt->filter_index]) {
  3.5363 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5364 -    }
  3.5365 -}
  3.5366 -
  3.5367 -static void SDLCALL
  3.5368 -SDL_Upsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5369 -{
  3.5370 -#if DEBUG_CONVERT
  3.5371 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 2 channels.\n", cvt->rate_incr);
  3.5372 -#endif
  3.5373 -
  3.5374 -    const int srcsize = cvt->len_cvt - 128;
  3.5375 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.5376 -    register int eps = 0;
  3.5377 -    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
  3.5378 -    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
  3.5379 -    const Sint32 *target = ((const Sint32 *) cvt->buf);
  3.5380 -    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  3.5381 -    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  3.5382 -    Sint32 last_sample1 = sample1;
  3.5383 -    Sint32 last_sample0 = sample0;
  3.5384 -    while (dst >= target) {
  3.5385 -        dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  3.5386 -        dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  3.5387 -        dst -= 2;
  3.5388 -        eps += srcsize;
  3.5389 -        if ((eps << 1) >= dstsize) {
  3.5390 -            src -= 2;
  3.5391 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.5392 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5393 -            last_sample1 = sample1;
  3.5394 -            last_sample0 = sample0;
  3.5395 -            eps -= dstsize;
  3.5396 -        }
  3.5397 -    }
  3.5398 -    cvt->len_cvt = dstsize;
  3.5399 -    if (cvt->filters[++cvt->filter_index]) {
  3.5400 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5401 -    }
  3.5402 -}
  3.5403 -
  3.5404 -static void SDLCALL
  3.5405 -SDL_Downsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5406 -{
  3.5407 -#if DEBUG_CONVERT
  3.5408 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 2 channels.\n", cvt->rate_incr);
  3.5409 -#endif
  3.5410 -
  3.5411 -    const int srcsize = cvt->len_cvt - 128;
  3.5412 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.5413 -    register int eps = 0;
  3.5414 -    Sint32 *dst = (Sint32 *) cvt->buf;
  3.5415 -    const Sint32 *src = (Sint32 *) cvt->buf;
  3.5416 -    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  3.5417 -    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  3.5418 -    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  3.5419 -    Sint32 last_sample0 = sample0;
  3.5420 -    Sint32 last_sample1 = sample1;
  3.5421 -    while (dst < target) {
  3.5422 -        src += 2;
  3.5423 -        eps += dstsize;
  3.5424 -        if ((eps << 1) >= srcsize) {
  3.5425 -            dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  3.5426 -            dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  3.5427 -            dst += 2;
  3.5428 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5429 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.5430 -            last_sample0 = sample0;
  3.5431 -            last_sample1 = sample1;
  3.5432 -            eps -= srcsize;
  3.5433 -        }
  3.5434 -    }
  3.5435 -    cvt->len_cvt = dstsize;
  3.5436 -    if (cvt->filters[++cvt->filter_index]) {
  3.5437 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5438 -    }
  3.5439 -}
  3.5440 -
  3.5441 -static void SDLCALL
  3.5442 -SDL_Upsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5443 -{
  3.5444 -#if DEBUG_CONVERT
  3.5445 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 4 channels.\n", cvt->rate_incr);
  3.5446 -#endif
  3.5447 -
  3.5448 -    const int srcsize = cvt->len_cvt - 256;
  3.5449 -    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
  3.5450 -    register int eps = 0;
  3.5451 -    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
  3.5452 -    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
  3.5453 -    const Sint32 *target = ((const Sint32 *) cvt->buf);
  3.5454 -    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
  3.5455 -    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
  3.5456 -    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  3.5457 -    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  3.5458 -    Sint32 last_sample3 = sample3;
  3.5459 -    Sint32 last_sample2 = sample2;
  3.5460 -    Sint32 last_sample1 = sample1;
  3.5461 -    Sint32 last_sample0 = sample0;
  3.5462 -    while (dst >= target) {
  3.5463 -        dst[3] = ((Sint32) SDL_SwapLE32(sample3));
  3.5464 -        dst[2] = ((Sint32) SDL_SwapLE32(sample2));
  3.5465 -        dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  3.5466 -        dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  3.5467 -        dst -= 4;
  3.5468 -        eps += srcsize;
  3.5469 -        if ((eps << 1) >= dstsize) {
  3.5470 -            src -= 4;
  3.5471 -            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  3.5472 -            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  3.5473 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.5474 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5475 -            last_sample3 = sample3;
  3.5476 -            last_sample2 = sample2;
  3.5477 -            last_sample1 = sample1;
  3.5478 -            last_sample0 = sample0;
  3.5479 -            eps -= dstsize;
  3.5480 -        }
  3.5481 -    }
  3.5482 -    cvt->len_cvt = dstsize;
  3.5483 -    if (cvt->filters[++cvt->filter_index]) {
  3.5484 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5485 -    }
  3.5486 -}
  3.5487 -
  3.5488 -static void SDLCALL
  3.5489 -SDL_Downsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5490 -{
  3.5491 -#if DEBUG_CONVERT
  3.5492 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 4 channels.\n", cvt->rate_incr);
  3.5493 -#endif
  3.5494 -
  3.5495 -    const int srcsize = cvt->len_cvt - 256;
  3.5496 -    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
  3.5497 -    register int eps = 0;
  3.5498 -    Sint32 *dst = (Sint32 *) cvt->buf;
  3.5499 -    const Sint32 *src = (Sint32 *) cvt->buf;
  3.5500 -    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  3.5501 -    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  3.5502 -    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  3.5503 -    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
  3.5504 -    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
  3.5505 -    Sint32 last_sample0 = sample0;
  3.5506 -    Sint32 last_sample1 = sample1;
  3.5507 -    Sint32 last_sample2 = sample2;
  3.5508 -    Sint32 last_sample3 = sample3;
  3.5509 -    while (dst < target) {
  3.5510 -        src += 4;
  3.5511 -        eps += dstsize;
  3.5512 -        if ((eps << 1) >= srcsize) {
  3.5513 -            dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  3.5514 -            dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  3.5515 -            dst[2] = ((Sint32) SDL_SwapLE32(sample2));
  3.5516 -            dst[3] = ((Sint32) SDL_SwapLE32(sample3));
  3.5517 -            dst += 4;
  3.5518 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5519 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.5520 -            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  3.5521 -            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  3.5522 -            last_sample0 = sample0;
  3.5523 -            last_sample1 = sample1;
  3.5524 -            last_sample2 = sample2;
  3.5525 -            last_sample3 = sample3;
  3.5526 -            eps -= srcsize;
  3.5527 -        }
  3.5528 -    }
  3.5529 -    cvt->len_cvt = dstsize;
  3.5530 -    if (cvt->filters[++cvt->filter_index]) {
  3.5531 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5532 -    }
  3.5533 -}
  3.5534 -
  3.5535 -static void SDLCALL
  3.5536 -SDL_Upsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5537 -{
  3.5538 -#if DEBUG_CONVERT
  3.5539 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 6 channels.\n", cvt->rate_incr);
  3.5540 -#endif
  3.5541 -
  3.5542 -    const int srcsize = cvt->len_cvt - 384;
  3.5543 -    const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
  3.5544 -    register int eps = 0;
  3.5545 -    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
  3.5546 -    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
  3.5547 -    const Sint32 *target = ((const Sint32 *) cvt->buf);
  3.5548 -    Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
  3.5549 -    Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
  3.5550 -    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
  3.5551 -    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
  3.5552 -    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  3.5553 -    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  3.5554 -    Sint32 last_sample5 = sample5;
  3.5555 -    Sint32 last_sample4 = sample4;
  3.5556 -    Sint32 last_sample3 = sample3;
  3.5557 -    Sint32 last_sample2 = sample2;
  3.5558 -    Sint32 last_sample1 = sample1;
  3.5559 -    Sint32 last_sample0 = sample0;
  3.5560 -    while (dst >= target) {
  3.5561 -        dst[5] = ((Sint32) SDL_SwapLE32(sample5));
  3.5562 -        dst[4] = ((Sint32) SDL_SwapLE32(sample4));
  3.5563 -        dst[3] = ((Sint32) SDL_SwapLE32(sample3));
  3.5564 -        dst[2] = ((Sint32) SDL_SwapLE32(sample2));
  3.5565 -        dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  3.5566 -        dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  3.5567 -        dst -= 6;
  3.5568 -        eps += srcsize;
  3.5569 -        if ((eps << 1) >= dstsize) {
  3.5570 -            src -= 6;
  3.5571 -            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  3.5572 -            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  3.5573 -            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  3.5574 -            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  3.5575 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.5576 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5577 -            last_sample5 = sample5;
  3.5578 -            last_sample4 = sample4;
  3.5579 -            last_sample3 = sample3;
  3.5580 -            last_sample2 = sample2;
  3.5581 -            last_sample1 = sample1;
  3.5582 -            last_sample0 = sample0;
  3.5583 -            eps -= dstsize;
  3.5584 -        }
  3.5585 -    }
  3.5586 -    cvt->len_cvt = dstsize;
  3.5587 -    if (cvt->filters[++cvt->filter_index]) {
  3.5588 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5589 -    }
  3.5590 -}
  3.5591 -
  3.5592 -static void SDLCALL
  3.5593 -SDL_Downsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5594 -{
  3.5595 -#if DEBUG_CONVERT
  3.5596 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 6 channels.\n", cvt->rate_incr);
  3.5597 -#endif
  3.5598 -
  3.5599 -    const int srcsize = cvt->len_cvt - 384;
  3.5600 -    const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
  3.5601 -    register int eps = 0;
  3.5602 -    Sint32 *dst = (Sint32 *) cvt->buf;
  3.5603 -    const Sint32 *src = (Sint32 *) cvt->buf;
  3.5604 -    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  3.5605 -    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  3.5606 -    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  3.5607 -    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
  3.5608 -    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
  3.5609 -    Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
  3.5610 -    Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
  3.5611 -    Sint32 last_sample0 = sample0;
  3.5612 -    Sint32 last_sample1 = sample1;
  3.5613 -    Sint32 last_sample2 = sample2;
  3.5614 -    Sint32 last_sample3 = sample3;
  3.5615 -    Sint32 last_sample4 = sample4;
  3.5616 -    Sint32 last_sample5 = sample5;
  3.5617 -    while (dst < target) {
  3.5618 -        src += 6;
  3.5619 -        eps += dstsize;
  3.5620 -        if ((eps << 1) >= srcsize) {
  3.5621 -            dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  3.5622 -            dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  3.5623 -            dst[2] = ((Sint32) SDL_SwapLE32(sample2));
  3.5624 -            dst[3] = ((Sint32) SDL_SwapLE32(sample3));
  3.5625 -            dst[4] = ((Sint32) SDL_SwapLE32(sample4));
  3.5626 -            dst[5] = ((Sint32) SDL_SwapLE32(sample5));
  3.5627 -            dst += 6;
  3.5628 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5629 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.5630 -            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  3.5631 -            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  3.5632 -            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  3.5633 -            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  3.5634 -            last_sample0 = sample0;
  3.5635 -            last_sample1 = sample1;
  3.5636 -            last_sample2 = sample2;
  3.5637 -            last_sample3 = sample3;
  3.5638 -            last_sample4 = sample4;
  3.5639 -            last_sample5 = sample5;
  3.5640 -            eps -= srcsize;
  3.5641 -        }
  3.5642 -    }
  3.5643 -    cvt->len_cvt = dstsize;
  3.5644 -    if (cvt->filters[++cvt->filter_index]) {
  3.5645 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5646 -    }
  3.5647 -}
  3.5648 -
  3.5649 -static void SDLCALL
  3.5650 -SDL_Upsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5651 -{
  3.5652 -#if DEBUG_CONVERT
  3.5653 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 8 channels.\n", cvt->rate_incr);
  3.5654 -#endif
  3.5655 -
  3.5656 -    const int srcsize = cvt->len_cvt - 512;
  3.5657 -    const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
  3.5658 -    register int eps = 0;
  3.5659 -    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
  3.5660 -    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
  3.5661 -    const Sint32 *target = ((const Sint32 *) cvt->buf);
  3.5662 -    Sint32 sample7 = ((Sint32) SDL_SwapLE32(src[7]));
  3.5663 -    Sint32 sample6 = ((Sint32) SDL_SwapLE32(src[6]));
  3.5664 -    Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
  3.5665 -    Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
  3.5666 -    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
  3.5667 -    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
  3.5668 -    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  3.5669 -    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  3.5670 -    Sint32 last_sample7 = sample7;
  3.5671 -    Sint32 last_sample6 = sample6;
  3.5672 -    Sint32 last_sample5 = sample5;
  3.5673 -    Sint32 last_sample4 = sample4;
  3.5674 -    Sint32 last_sample3 = sample3;
  3.5675 -    Sint32 last_sample2 = sample2;
  3.5676 -    Sint32 last_sample1 = sample1;
  3.5677 -    Sint32 last_sample0 = sample0;
  3.5678 -    while (dst >= target) {
  3.5679 -        dst[7] = ((Sint32) SDL_SwapLE32(sample7));
  3.5680 -        dst[6] = ((Sint32) SDL_SwapLE32(sample6));
  3.5681 -        dst[5] = ((Sint32) SDL_SwapLE32(sample5));
  3.5682 -        dst[4] = ((Sint32) SDL_SwapLE32(sample4));
  3.5683 -        dst[3] = ((Sint32) SDL_SwapLE32(sample3));
  3.5684 -        dst[2] = ((Sint32) SDL_SwapLE32(sample2));
  3.5685 -        dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  3.5686 -        dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  3.5687 -        dst -= 8;
  3.5688 -        eps += srcsize;
  3.5689 -        if ((eps << 1) >= dstsize) {
  3.5690 -            src -= 8;
  3.5691 -            sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
  3.5692 -            sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
  3.5693 -            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  3.5694 -            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  3.5695 -            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  3.5696 -            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  3.5697 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.5698 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5699 -            last_sample7 = sample7;
  3.5700 -            last_sample6 = sample6;
  3.5701 -            last_sample5 = sample5;
  3.5702 -            last_sample4 = sample4;
  3.5703 -            last_sample3 = sample3;
  3.5704 -            last_sample2 = sample2;
  3.5705 -            last_sample1 = sample1;
  3.5706 -            last_sample0 = sample0;
  3.5707 -            eps -= dstsize;
  3.5708 -        }
  3.5709 -    }
  3.5710 -    cvt->len_cvt = dstsize;
  3.5711 -    if (cvt->filters[++cvt->filter_index]) {
  3.5712 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5713 -    }
  3.5714 -}
  3.5715 -
  3.5716 -static void SDLCALL
  3.5717 -SDL_Downsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5718 -{
  3.5719 -#if DEBUG_CONVERT
  3.5720 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 8 channels.\n", cvt->rate_incr);
  3.5721 -#endif
  3.5722 -
  3.5723 -    const int srcsize = cvt->len_cvt - 512;
  3.5724 -    const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
  3.5725 -    register int eps = 0;
  3.5726 -    Sint32 *dst = (Sint32 *) cvt->buf;
  3.5727 -    const Sint32 *src = (Sint32 *) cvt->buf;
  3.5728 -    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  3.5729 -    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  3.5730 -    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  3.5731 -    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
  3.5732 -    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
  3.5733 -    Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
  3.5734 -    Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
  3.5735 -    Sint32 sample6 = ((Sint32) SDL_SwapLE32(src[6]));
  3.5736 -    Sint32 sample7 = ((Sint32) SDL_SwapLE32(src[7]));
  3.5737 -    Sint32 last_sample0 = sample0;
  3.5738 -    Sint32 last_sample1 = sample1;
  3.5739 -    Sint32 last_sample2 = sample2;
  3.5740 -    Sint32 last_sample3 = sample3;
  3.5741 -    Sint32 last_sample4 = sample4;
  3.5742 -    Sint32 last_sample5 = sample5;
  3.5743 -    Sint32 last_sample6 = sample6;
  3.5744 -    Sint32 last_sample7 = sample7;
  3.5745 -    while (dst < target) {
  3.5746 -        src += 8;
  3.5747 -        eps += dstsize;
  3.5748 -        if ((eps << 1) >= srcsize) {
  3.5749 -            dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  3.5750 -            dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  3.5751 -            dst[2] = ((Sint32) SDL_SwapLE32(sample2));
  3.5752 -            dst[3] = ((Sint32) SDL_SwapLE32(sample3));
  3.5753 -            dst[4] = ((Sint32) SDL_SwapLE32(sample4));
  3.5754 -            dst[5] = ((Sint32) SDL_SwapLE32(sample5));
  3.5755 -            dst[6] = ((Sint32) SDL_SwapLE32(sample6));
  3.5756 -            dst[7] = ((Sint32) SDL_SwapLE32(sample7));
  3.5757 -            dst += 8;
  3.5758 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5759 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.5760 -            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  3.5761 -            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  3.5762 -            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  3.5763 -            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  3.5764 -            sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
  3.5765 -            sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
  3.5766 -            last_sample0 = sample0;
  3.5767 -            last_sample1 = sample1;
  3.5768 -            last_sample2 = sample2;
  3.5769 -            last_sample3 = sample3;
  3.5770 -            last_sample4 = sample4;
  3.5771 -            last_sample5 = sample5;
  3.5772 -            last_sample6 = sample6;
  3.5773 -            last_sample7 = sample7;
  3.5774 -            eps -= srcsize;
  3.5775 -        }
  3.5776 -    }
  3.5777 -    cvt->len_cvt = dstsize;
  3.5778 -    if (cvt->filters[++cvt->filter_index]) {
  3.5779 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5780 -    }
  3.5781 -}
  3.5782 -
  3.5783 -static void SDLCALL
  3.5784 -SDL_Upsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5785 -{
  3.5786 -#if DEBUG_CONVERT
  3.5787 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 1 channels.\n", cvt->rate_incr);
  3.5788 -#endif
  3.5789 -
  3.5790 -    const int srcsize = cvt->len_cvt - 64;
  3.5791 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.5792 -    register int eps = 0;
  3.5793 -    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
  3.5794 -    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
  3.5795 -    const Sint32 *target = ((const Sint32 *) cvt->buf);
  3.5796 -    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  3.5797 -    Sint32 last_sample0 = sample0;
  3.5798 -    while (dst >= target) {
  3.5799 -        dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  3.5800 -        dst--;
  3.5801 -        eps += srcsize;
  3.5802 -        if ((eps << 1) >= dstsize) {
  3.5803 -            src--;
  3.5804 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5805 -            last_sample0 = sample0;
  3.5806 -            eps -= dstsize;
  3.5807 -        }
  3.5808 -    }
  3.5809 -    cvt->len_cvt = dstsize;
  3.5810 -    if (cvt->filters[++cvt->filter_index]) {
  3.5811 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5812 -    }
  3.5813 -}
  3.5814 -
  3.5815 -static void SDLCALL
  3.5816 -SDL_Downsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5817 -{
  3.5818 -#if DEBUG_CONVERT
  3.5819 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 1 channels.\n", cvt->rate_incr);
  3.5820 -#endif
  3.5821 -
  3.5822 -    const int srcsize = cvt->len_cvt - 64;
  3.5823 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.5824 -    register int eps = 0;
  3.5825 -    Sint32 *dst = (Sint32 *) cvt->buf;
  3.5826 -    const Sint32 *src = (Sint32 *) cvt->buf;
  3.5827 -    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  3.5828 -    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  3.5829 -    Sint32 last_sample0 = sample0;
  3.5830 -    while (dst < target) {
  3.5831 -        src++;
  3.5832 -        eps += dstsize;
  3.5833 -        if ((eps << 1) >= srcsize) {
  3.5834 -            dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  3.5835 -            dst++;
  3.5836 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5837 -            last_sample0 = sample0;
  3.5838 -            eps -= srcsize;
  3.5839 -        }
  3.5840 -    }
  3.5841 -    cvt->len_cvt = dstsize;
  3.5842 -    if (cvt->filters[++cvt->filter_index]) {
  3.5843 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5844 -    }
  3.5845 -}
  3.5846 -
  3.5847 -static void SDLCALL
  3.5848 -SDL_Upsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5849 -{
  3.5850 -#if DEBUG_CONVERT
  3.5851 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 2 channels.\n", cvt->rate_incr);
  3.5852 -#endif
  3.5853 -
  3.5854 -    const int srcsize = cvt->len_cvt - 128;
  3.5855 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.5856 -    register int eps = 0;
  3.5857 -    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
  3.5858 -    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
  3.5859 -    const Sint32 *target = ((const Sint32 *) cvt->buf);
  3.5860 -    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  3.5861 -    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  3.5862 -    Sint32 last_sample1 = sample1;
  3.5863 -    Sint32 last_sample0 = sample0;
  3.5864 -    while (dst >= target) {
  3.5865 -        dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  3.5866 -        dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  3.5867 -        dst -= 2;
  3.5868 -        eps += srcsize;
  3.5869 -        if ((eps << 1) >= dstsize) {
  3.5870 -            src -= 2;
  3.5871 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.5872 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5873 -            last_sample1 = sample1;
  3.5874 -            last_sample0 = sample0;
  3.5875 -            eps -= dstsize;
  3.5876 -        }
  3.5877 -    }
  3.5878 -    cvt->len_cvt = dstsize;
  3.5879 -    if (cvt->filters[++cvt->filter_index]) {
  3.5880 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5881 -    }
  3.5882 -}
  3.5883 -
  3.5884 -static void SDLCALL
  3.5885 -SDL_Downsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5886 -{
  3.5887 -#if DEBUG_CONVERT
  3.5888 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 2 channels.\n", cvt->rate_incr);
  3.5889 -#endif
  3.5890 -
  3.5891 -    const int srcsize = cvt->len_cvt - 128;
  3.5892 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.5893 -    register int eps = 0;
  3.5894 -    Sint32 *dst = (Sint32 *) cvt->buf;
  3.5895 -    const Sint32 *src = (Sint32 *) cvt->buf;
  3.5896 -    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  3.5897 -    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  3.5898 -    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  3.5899 -    Sint32 last_sample0 = sample0;
  3.5900 -    Sint32 last_sample1 = sample1;
  3.5901 -    while (dst < target) {
  3.5902 -        src += 2;
  3.5903 -        eps += dstsize;
  3.5904 -        if ((eps << 1) >= srcsize) {
  3.5905 -            dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  3.5906 -            dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  3.5907 -            dst += 2;
  3.5908 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5909 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.5910 -            last_sample0 = sample0;
  3.5911 -            last_sample1 = sample1;
  3.5912 -            eps -= srcsize;
  3.5913 -        }
  3.5914 -    }
  3.5915 -    cvt->len_cvt = dstsize;
  3.5916 -    if (cvt->filters[++cvt->filter_index]) {
  3.5917 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5918 -    }
  3.5919 -}
  3.5920 -
  3.5921 -static void SDLCALL
  3.5922 -SDL_Upsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5923 -{
  3.5924 -#if DEBUG_CONVERT
  3.5925 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 4 channels.\n", cvt->rate_incr);
  3.5926 -#endif
  3.5927 -
  3.5928 -    const int srcsize = cvt->len_cvt - 256;
  3.5929 -    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
  3.5930 -    register int eps = 0;
  3.5931 -    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
  3.5932 -    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
  3.5933 -    const Sint32 *target = ((const Sint32 *) cvt->buf);
  3.5934 -    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
  3.5935 -    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
  3.5936 -    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  3.5937 -    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  3.5938 -    Sint32 last_sample3 = sample3;
  3.5939 -    Sint32 last_sample2 = sample2;
  3.5940 -    Sint32 last_sample1 = sample1;
  3.5941 -    Sint32 last_sample0 = sample0;
  3.5942 -    while (dst >= target) {
  3.5943 -        dst[3] = ((Sint32) SDL_SwapBE32(sample3));
  3.5944 -        dst[2] = ((Sint32) SDL_SwapBE32(sample2));
  3.5945 -        dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  3.5946 -        dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  3.5947 -        dst -= 4;
  3.5948 -        eps += srcsize;
  3.5949 -        if ((eps << 1) >= dstsize) {
  3.5950 -            src -= 4;
  3.5951 -            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  3.5952 -            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  3.5953 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.5954 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5955 -            last_sample3 = sample3;
  3.5956 -            last_sample2 = sample2;
  3.5957 -            last_sample1 = sample1;
  3.5958 -            last_sample0 = sample0;
  3.5959 -            eps -= dstsize;
  3.5960 -        }
  3.5961 -    }
  3.5962 -    cvt->len_cvt = dstsize;
  3.5963 -    if (cvt->filters[++cvt->filter_index]) {
  3.5964 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.5965 -    }
  3.5966 -}
  3.5967 -
  3.5968 -static void SDLCALL
  3.5969 -SDL_Downsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.5970 -{
  3.5971 -#if DEBUG_CONVERT
  3.5972 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 4 channels.\n", cvt->rate_incr);
  3.5973 -#endif
  3.5974 -
  3.5975 -    const int srcsize = cvt->len_cvt - 256;
  3.5976 -    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
  3.5977 -    register int eps = 0;
  3.5978 -    Sint32 *dst = (Sint32 *) cvt->buf;
  3.5979 -    const Sint32 *src = (Sint32 *) cvt->buf;
  3.5980 -    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  3.5981 -    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  3.5982 -    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  3.5983 -    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
  3.5984 -    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
  3.5985 -    Sint32 last_sample0 = sample0;
  3.5986 -    Sint32 last_sample1 = sample1;
  3.5987 -    Sint32 last_sample2 = sample2;
  3.5988 -    Sint32 last_sample3 = sample3;
  3.5989 -    while (dst < target) {
  3.5990 -        src += 4;
  3.5991 -        eps += dstsize;
  3.5992 -        if ((eps << 1) >= srcsize) {
  3.5993 -            dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  3.5994 -            dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  3.5995 -            dst[2] = ((Sint32) SDL_SwapBE32(sample2));
  3.5996 -            dst[3] = ((Sint32) SDL_SwapBE32(sample3));
  3.5997 -            dst += 4;
  3.5998 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.5999 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.6000 -            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  3.6001 -            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  3.6002 -            last_sample0 = sample0;
  3.6003 -            last_sample1 = sample1;
  3.6004 -            last_sample2 = sample2;
  3.6005 -            last_sample3 = sample3;
  3.6006 -            eps -= srcsize;
  3.6007 -        }
  3.6008 -    }
  3.6009 -    cvt->len_cvt = dstsize;
  3.6010 -    if (cvt->filters[++cvt->filter_index]) {
  3.6011 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.6012 -    }
  3.6013 -}
  3.6014 -
  3.6015 -static void SDLCALL
  3.6016 -SDL_Upsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.6017 -{
  3.6018 -#if DEBUG_CONVERT
  3.6019 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 6 channels.\n", cvt->rate_incr);
  3.6020 -#endif
  3.6021 -
  3.6022 -    const int srcsize = cvt->len_cvt - 384;
  3.6023 -    const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
  3.6024 -    register int eps = 0;
  3.6025 -    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
  3.6026 -    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
  3.6027 -    const Sint32 *target = ((const Sint32 *) cvt->buf);
  3.6028 -    Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
  3.6029 -    Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
  3.6030 -    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
  3.6031 -    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
  3.6032 -    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  3.6033 -    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  3.6034 -    Sint32 last_sample5 = sample5;
  3.6035 -    Sint32 last_sample4 = sample4;
  3.6036 -    Sint32 last_sample3 = sample3;
  3.6037 -    Sint32 last_sample2 = sample2;
  3.6038 -    Sint32 last_sample1 = sample1;
  3.6039 -    Sint32 last_sample0 = sample0;
  3.6040 -    while (dst >= target) {
  3.6041 -        dst[5] = ((Sint32) SDL_SwapBE32(sample5));
  3.6042 -        dst[4] = ((Sint32) SDL_SwapBE32(sample4));
  3.6043 -        dst[3] = ((Sint32) SDL_SwapBE32(sample3));
  3.6044 -        dst[2] = ((Sint32) SDL_SwapBE32(sample2));
  3.6045 -        dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  3.6046 -        dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  3.6047 -        dst -= 6;
  3.6048 -        eps += srcsize;
  3.6049 -        if ((eps << 1) >= dstsize) {
  3.6050 -            src -= 6;
  3.6051 -            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  3.6052 -            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  3.6053 -            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  3.6054 -            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  3.6055 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.6056 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.6057 -            last_sample5 = sample5;
  3.6058 -            last_sample4 = sample4;
  3.6059 -            last_sample3 = sample3;
  3.6060 -            last_sample2 = sample2;
  3.6061 -            last_sample1 = sample1;
  3.6062 -            last_sample0 = sample0;
  3.6063 -            eps -= dstsize;
  3.6064 -        }
  3.6065 -    }
  3.6066 -    cvt->len_cvt = dstsize;
  3.6067 -    if (cvt->filters[++cvt->filter_index]) {
  3.6068 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.6069 -    }
  3.6070 -}
  3.6071 -
  3.6072 -static void SDLCALL
  3.6073 -SDL_Downsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.6074 -{
  3.6075 -#if DEBUG_CONVERT
  3.6076 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 6 channels.\n", cvt->rate_incr);
  3.6077 -#endif
  3.6078 -
  3.6079 -    const int srcsize = cvt->len_cvt - 384;
  3.6080 -    const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
  3.6081 -    register int eps = 0;
  3.6082 -    Sint32 *dst = (Sint32 *) cvt->buf;
  3.6083 -    const Sint32 *src = (Sint32 *) cvt->buf;
  3.6084 -    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  3.6085 -    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  3.6086 -    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  3.6087 -    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
  3.6088 -    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
  3.6089 -    Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
  3.6090 -    Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
  3.6091 -    Sint32 last_sample0 = sample0;
  3.6092 -    Sint32 last_sample1 = sample1;
  3.6093 -    Sint32 last_sample2 = sample2;
  3.6094 -    Sint32 last_sample3 = sample3;
  3.6095 -    Sint32 last_sample4 = sample4;
  3.6096 -    Sint32 last_sample5 = sample5;
  3.6097 -    while (dst < target) {
  3.6098 -        src += 6;
  3.6099 -        eps += dstsize;
  3.6100 -        if ((eps << 1) >= srcsize) {
  3.6101 -            dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  3.6102 -            dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  3.6103 -            dst[2] = ((Sint32) SDL_SwapBE32(sample2));
  3.6104 -            dst[3] = ((Sint32) SDL_SwapBE32(sample3));
  3.6105 -            dst[4] = ((Sint32) SDL_SwapBE32(sample4));
  3.6106 -            dst[5] = ((Sint32) SDL_SwapBE32(sample5));
  3.6107 -            dst += 6;
  3.6108 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.6109 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.6110 -            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  3.6111 -            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  3.6112 -            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  3.6113 -            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  3.6114 -            last_sample0 = sample0;
  3.6115 -            last_sample1 = sample1;
  3.6116 -            last_sample2 = sample2;
  3.6117 -            last_sample3 = sample3;
  3.6118 -            last_sample4 = sample4;
  3.6119 -            last_sample5 = sample5;
  3.6120 -            eps -= srcsize;
  3.6121 -        }
  3.6122 -    }
  3.6123 -    cvt->len_cvt = dstsize;
  3.6124 -    if (cvt->filters[++cvt->filter_index]) {
  3.6125 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.6126 -    }
  3.6127 -}
  3.6128 -
  3.6129 -static void SDLCALL
  3.6130 -SDL_Upsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.6131 -{
  3.6132 -#if DEBUG_CONVERT
  3.6133 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 8 channels.\n", cvt->rate_incr);
  3.6134 -#endif
  3.6135 -
  3.6136 -    const int srcsize = cvt->len_cvt - 512;
  3.6137 -    const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
  3.6138 -    register int eps = 0;
  3.6139 -    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
  3.6140 -    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
  3.6141 -    const Sint32 *target = ((const Sint32 *) cvt->buf);
  3.6142 -    Sint32 sample7 = ((Sint32) SDL_SwapBE32(src[7]));
  3.6143 -    Sint32 sample6 = ((Sint32) SDL_SwapBE32(src[6]));
  3.6144 -    Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
  3.6145 -    Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
  3.6146 -    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
  3.6147 -    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
  3.6148 -    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  3.6149 -    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  3.6150 -    Sint32 last_sample7 = sample7;
  3.6151 -    Sint32 last_sample6 = sample6;
  3.6152 -    Sint32 last_sample5 = sample5;
  3.6153 -    Sint32 last_sample4 = sample4;
  3.6154 -    Sint32 last_sample3 = sample3;
  3.6155 -    Sint32 last_sample2 = sample2;
  3.6156 -    Sint32 last_sample1 = sample1;
  3.6157 -    Sint32 last_sample0 = sample0;
  3.6158 -    while (dst >= target) {
  3.6159 -        dst[7] = ((Sint32) SDL_SwapBE32(sample7));
  3.6160 -        dst[6] = ((Sint32) SDL_SwapBE32(sample6));
  3.6161 -        dst[5] = ((Sint32) SDL_SwapBE32(sample5));
  3.6162 -        dst[4] = ((Sint32) SDL_SwapBE32(sample4));
  3.6163 -        dst[3] = ((Sint32) SDL_SwapBE32(sample3));
  3.6164 -        dst[2] = ((Sint32) SDL_SwapBE32(sample2));
  3.6165 -        dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  3.6166 -        dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  3.6167 -        dst -= 8;
  3.6168 -        eps += srcsize;
  3.6169 -        if ((eps << 1) >= dstsize) {
  3.6170 -            src -= 8;
  3.6171 -            sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
  3.6172 -            sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
  3.6173 -            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  3.6174 -            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  3.6175 -            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  3.6176 -            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  3.6177 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.6178 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.6179 -            last_sample7 = sample7;
  3.6180 -            last_sample6 = sample6;
  3.6181 -            last_sample5 = sample5;
  3.6182 -            last_sample4 = sample4;
  3.6183 -            last_sample3 = sample3;
  3.6184 -            last_sample2 = sample2;
  3.6185 -            last_sample1 = sample1;
  3.6186 -            last_sample0 = sample0;
  3.6187 -            eps -= dstsize;
  3.6188 -        }
  3.6189 -    }
  3.6190 -    cvt->len_cvt = dstsize;
  3.6191 -    if (cvt->filters[++cvt->filter_index]) {
  3.6192 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.6193 -    }
  3.6194 -}
  3.6195 -
  3.6196 -static void SDLCALL
  3.6197 -SDL_Downsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.6198 -{
  3.6199 -#if DEBUG_CONVERT
  3.6200 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 8 channels.\n", cvt->rate_incr);
  3.6201 -#endif
  3.6202 -
  3.6203 -    const int srcsize = cvt->len_cvt - 512;
  3.6204 -    const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
  3.6205 -    register int eps = 0;
  3.6206 -    Sint32 *dst = (Sint32 *) cvt->buf;
  3.6207 -    const Sint32 *src = (Sint32 *) cvt->buf;
  3.6208 -    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  3.6209 -    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  3.6210 -    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  3.6211 -    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
  3.6212 -    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
  3.6213 -    Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
  3.6214 -    Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
  3.6215 -    Sint32 sample6 = ((Sint32) SDL_SwapBE32(src[6]));
  3.6216 -    Sint32 sample7 = ((Sint32) SDL_SwapBE32(src[7]));
  3.6217 -    Sint32 last_sample0 = sample0;
  3.6218 -    Sint32 last_sample1 = sample1;
  3.6219 -    Sint32 last_sample2 = sample2;
  3.6220 -    Sint32 last_sample3 = sample3;
  3.6221 -    Sint32 last_sample4 = sample4;
  3.6222 -    Sint32 last_sample5 = sample5;
  3.6223 -    Sint32 last_sample6 = sample6;
  3.6224 -    Sint32 last_sample7 = sample7;
  3.6225 -    while (dst < target) {
  3.6226 -        src += 8;
  3.6227 -        eps += dstsize;
  3.6228 -        if ((eps << 1) >= srcsize) {
  3.6229 -            dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  3.6230 -            dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  3.6231 -            dst[2] = ((Sint32) SDL_SwapBE32(sample2));
  3.6232 -            dst[3] = ((Sint32) SDL_SwapBE32(sample3));
  3.6233 -            dst[4] = ((Sint32) SDL_SwapBE32(sample4));
  3.6234 -            dst[5] = ((Sint32) SDL_SwapBE32(sample5));
  3.6235 -            dst[6] = ((Sint32) SDL_SwapBE32(sample6));
  3.6236 -            dst[7] = ((Sint32) SDL_SwapBE32(sample7));
  3.6237 -            dst += 8;
  3.6238 -            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  3.6239 -            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  3.6240 -            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  3.6241 -            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  3.6242 -            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  3.6243 -            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  3.6244 -            sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
  3.6245 -            sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
  3.6246 -            last_sample0 = sample0;
  3.6247 -            last_sample1 = sample1;
  3.6248 -            last_sample2 = sample2;
  3.6249 -            last_sample3 = sample3;
  3.6250 -            last_sample4 = sample4;
  3.6251 -            last_sample5 = sample5;
  3.6252 -            last_sample6 = sample6;
  3.6253 -            last_sample7 = sample7;
  3.6254 -            eps -= srcsize;
  3.6255 -        }
  3.6256 -    }
  3.6257 -    cvt->len_cvt = dstsize;
  3.6258 -    if (cvt->filters[++cvt->filter_index]) {
  3.6259 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.6260 -    }
  3.6261 -}
  3.6262 -
  3.6263 -static void SDLCALL
  3.6264 -SDL_Upsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.6265 -{
  3.6266 -#if DEBUG_CONVERT
  3.6267 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 1 channels.\n", cvt->rate_incr);
  3.6268 -#endif
  3.6269 -
  3.6270 -    const int srcsize = cvt->len_cvt - 64;
  3.6271 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.6272 -    register int eps = 0;
  3.6273 -    float *dst = ((float *) (cvt->buf + dstsize)) - 1;
  3.6274 -    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
  3.6275 -    const float *target = ((const float *) cvt->buf);
  3.6276 -    float sample0 = SDL_SwapFloatLE(src[0]);
  3.6277 -    float last_sample0 = sample0;
  3.6278 -    while (dst >= target) {
  3.6279 -        dst[0] = SDL_SwapFloatLE(sample0);
  3.6280 -        dst--;
  3.6281 -        eps += srcsize;
  3.6282 -        if ((eps << 1) >= dstsize) {
  3.6283 -            src--;
  3.6284 -            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  3.6285 -            last_sample0 = sample0;
  3.6286 -            eps -= dstsize;
  3.6287 -        }
  3.6288 -    }
  3.6289 -    cvt->len_cvt = dstsize;
  3.6290 -    if (cvt->filters[++cvt->filter_index]) {
  3.6291 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.6292 -    }
  3.6293 -}
  3.6294 -
  3.6295 -static void SDLCALL
  3.6296 -SDL_Downsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.6297 -{
  3.6298 -#if DEBUG_CONVERT
  3.6299 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 1 channels.\n", cvt->rate_incr);
  3.6300 -#endif
  3.6301 -
  3.6302 -    const int srcsize = cvt->len_cvt - 64;
  3.6303 -    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
  3.6304 -    register int eps = 0;
  3.6305 -    float *dst = (float *) cvt->buf;
  3.6306 -    const float *src = (float *) cvt->buf;
  3.6307 -    const float *target = (const float *) (cvt->buf + dstsize);
  3.6308 -    float sample0 = SDL_SwapFloatLE(src[0]);
  3.6309 -    float last_sample0 = sample0;
  3.6310 -    while (dst < target) {
  3.6311 -        src++;
  3.6312 -        eps += dstsize;
  3.6313 -        if ((eps << 1) >= srcsize) {
  3.6314 -            dst[0] = SDL_SwapFloatLE(sample0);
  3.6315 -            dst++;
  3.6316 -            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  3.6317 -            last_sample0 = sample0;
  3.6318 -            eps -= srcsize;
  3.6319 -        }
  3.6320 -    }
  3.6321 -    cvt->len_cvt = dstsize;
  3.6322 -    if (cvt->filters[++cvt->filter_index]) {
  3.6323 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.6324 -    }
  3.6325 -}
  3.6326 -
  3.6327 -static void SDLCALL
  3.6328 -SDL_Upsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.6329 -{
  3.6330 -#if DEBUG_CONVERT
  3.6331 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 2 channels.\n", cvt->rate_incr);
  3.6332 -#endif
  3.6333 -
  3.6334 -    const int srcsize = cvt->len_cvt - 128;
  3.6335 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.6336 -    register int eps = 0;
  3.6337 -    float *dst = ((float *) (cvt->buf + dstsize)) - 2;
  3.6338 -    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
  3.6339 -    const float *target = ((const float *) cvt->buf);
  3.6340 -    float sample1 = SDL_SwapFloatLE(src[1]);
  3.6341 -    float sample0 = SDL_SwapFloatLE(src[0]);
  3.6342 -    float last_sample1 = sample1;
  3.6343 -    float last_sample0 = sample0;
  3.6344 -    while (dst >= target) {
  3.6345 -        dst[1] = SDL_SwapFloatLE(sample1);
  3.6346 -        dst[0] = SDL_SwapFloatLE(sample0);
  3.6347 -        dst -= 2;
  3.6348 -        eps += srcsize;
  3.6349 -        if ((eps << 1) >= dstsize) {
  3.6350 -            src -= 2;
  3.6351 -            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
  3.6352 -            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  3.6353 -            last_sample1 = sample1;
  3.6354 -            last_sample0 = sample0;
  3.6355 -            eps -= dstsize;
  3.6356 -        }
  3.6357 -    }
  3.6358 -    cvt->len_cvt = dstsize;
  3.6359 -    if (cvt->filters[++cvt->filter_index]) {
  3.6360 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.6361 -    }
  3.6362 -}
  3.6363 -
  3.6364 -static void SDLCALL
  3.6365 -SDL_Downsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.6366 -{
  3.6367 -#if DEBUG_CONVERT
  3.6368 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 2 channels.\n", cvt->rate_incr);
  3.6369 -#endif
  3.6370 -
  3.6371 -    const int srcsize = cvt->len_cvt - 128;
  3.6372 -    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
  3.6373 -    register int eps = 0;
  3.6374 -    float *dst = (float *) cvt->buf;
  3.6375 -    const float *src = (float *) cvt->buf;
  3.6376 -    const float *target = (const float *) (cvt->buf + dstsize);
  3.6377 -    float sample0 = SDL_SwapFloatLE(src[0]);
  3.6378 -    float sample1 = SDL_SwapFloatLE(src[1]);
  3.6379 -    float last_sample0 = sample0;
  3.6380 -    float last_sample1 = sample1;
  3.6381 -    while (dst < target) {
  3.6382 -        src += 2;
  3.6383 -        eps += dstsize;
  3.6384 -        if ((eps << 1) >= srcsize) {
  3.6385 -            dst[0] = SDL_SwapFloatLE(sample0);
  3.6386 -            dst[1] = SDL_SwapFloatLE(sample1);
  3.6387 -            dst += 2;
  3.6388 -            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  3.6389 -            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
  3.6390 -            last_sample0 = sample0;
  3.6391 -            last_sample1 = sample1;
  3.6392 -            eps -= srcsize;
  3.6393 -        }
  3.6394 -    }
  3.6395 -    cvt->len_cvt = dstsize;
  3.6396 -    if (cvt->filters[++cvt->filter_index]) {
  3.6397 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.6398 -    }
  3.6399 -}
  3.6400 -
  3.6401 -static void SDLCALL
  3.6402 -SDL_Upsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.6403 -{
  3.6404 -#if DEBUG_CONVERT
  3.6405 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 4 channels.\n", cvt->rate_incr);
  3.6406 -#endif
  3.6407 -
  3.6408 -    const int srcsize = cvt->len_cvt - 256;
  3.6409 -    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
  3.6410 -    register int eps = 0;
  3.6411 -    float *dst = ((float *) (cvt->buf + dstsize)) - 4;
  3.6412 -    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
  3.6413 -    const float *target = ((const float *) cvt->buf);
  3.6414 -    float sample3 = SDL_SwapFloatLE(src[3]);
  3.6415 -    float sample2 = SDL_SwapFloatLE(src[2]);
  3.6416 -    float sample1 = SDL_SwapFloatLE(src[1]);
  3.6417 -    float sample0 = SDL_SwapFloatLE(src[0]);
  3.6418 -    float last_sample3 = sample3;
  3.6419 -    float last_sample2 = sample2;
  3.6420 -    float last_sample1 = sample1;
  3.6421 -    float last_sample0 = sample0;
  3.6422 -    while (dst >= target) {
  3.6423 -        dst[3] = SDL_SwapFloatLE(sample3);
  3.6424 -        dst[2] = SDL_SwapFloatLE(sample2);
  3.6425 -        dst[1] = SDL_SwapFloatLE(sample1);
  3.6426 -        dst[0] = SDL_SwapFloatLE(sample0);
  3.6427 -        dst -= 4;
  3.6428 -        eps += srcsize;
  3.6429 -        if ((eps << 1) >= dstsize) {
  3.6430 -            src -= 4;
  3.6431 -            sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
  3.6432 -            sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
  3.6433 -            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
  3.6434 -            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  3.6435 -            last_sample3 = sample3;
  3.6436 -            last_sample2 = sample2;
  3.6437 -            last_sample1 = sample1;
  3.6438 -            last_sample0 = sample0;
  3.6439 -            eps -= dstsize;
  3.6440 -        }
  3.6441 -    }
  3.6442 -    cvt->len_cvt = dstsize;
  3.6443 -    if (cvt->filters[++cvt->filter_index]) {
  3.6444 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.6445 -    }
  3.6446 -}
  3.6447 -
  3.6448 -static void SDLCALL
  3.6449 -SDL_Downsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.6450 -{
  3.6451 -#if DEBUG_CONVERT
  3.6452 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 4 channels.\n", cvt->rate_incr);
  3.6453 -#endif
  3.6454 -
  3.6455 -    const int srcsize = cvt->len_cvt - 256;
  3.6456 -    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
  3.6457 -    register int eps = 0;
  3.6458 -    float *dst = (float *) cvt->buf;
  3.6459 -    const float *src = (float *) cvt->buf;
  3.6460 -    const float *target = (const float *) (cvt->buf + dstsize);
  3.6461 -    float sample0 = SDL_SwapFloatLE(src[0]);
  3.6462 -    float sample1 = SDL_SwapFloatLE(src[1]);
  3.6463 -    float sample2 = SDL_SwapFloatLE(src[2]);
  3.6464 -    float sample3 = SDL_SwapFloatLE(src[3]);
  3.6465 -    float last_sample0 = sample0;
  3.6466 -    float last_sample1 = sample1;
  3.6467 -    float last_sample2 = sample2;
  3.6468 -    float last_sample3 = sample3;
  3.6469 -    while (dst < target) {
  3.6470 -        src += 4;
  3.6471 -        eps += dstsize;
  3.6472 -        if ((eps << 1) >= srcsize) {
  3.6473 -            dst[0] = SDL_SwapFloatLE(sample0);
  3.6474 -            dst[1] = SDL_SwapFloatLE(sample1);
  3.6475 -            dst[2] = SDL_SwapFloatLE(sample2);
  3.6476 -            dst[3] = SDL_SwapFloatLE(sample3);
  3.6477 -            dst += 4;
  3.6478 -            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  3.6479 -            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
  3.6480 -            sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
  3.6481 -            sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
  3.6482 -            last_sample0 = sample0;
  3.6483 -            last_sample1 = sample1;
  3.6484 -            last_sample2 = sample2;
  3.6485 -            last_sample3 = sample3;
  3.6486 -            eps -= srcsize;
  3.6487 -        }
  3.6488 -    }
  3.6489 -    cvt->len_cvt = dstsize;
  3.6490 -    if (cvt->filters[++cvt->filter_index]) {
  3.6491 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.6492 -    }
  3.6493 -}
  3.6494 -
  3.6495 -static void SDLCALL
  3.6496 -SDL_Upsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.6497 -{
  3.6498 -#if DEBUG_CONVERT
  3.6499 -    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 6 channels.\n", cvt->rate_incr);
  3.6500 -#endif
  3.6501 -
  3.6502 -    const int srcsize = cvt->len_cvt - 384;
  3.6503 -    const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
  3.6504 -    register int eps = 0;
  3.6505 -    float *dst = ((float *) (cvt->buf + dstsize)) - 6;
  3.6506 -    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
  3.6507 -    const float *target = ((const float *) cvt->buf);
  3.6508 -    float sample5 = SDL_SwapFloatLE(src[5]);
  3.6509 -    float sample4 = SDL_SwapFloatLE(src[4]);
  3.6510 -    float sample3 = SDL_SwapFloatLE(src[3]);
  3.6511 -    float sample2 = SDL_SwapFloatLE(src[2]);
  3.6512 -    float sample1 = SDL_SwapFloatLE(src[1]);
  3.6513 -    float sample0 = SDL_SwapFloatLE(src[0]);
  3.6514 -    float last_sample5 = sample5;
  3.6515 -    float last_sample4 = sample4;
  3.6516 -    float last_sample3 = sample3;
  3.6517 -    float last_sample2 = sample2;
  3.6518 -    float last_sample1 = sample1;
  3.6519 -    float last_sample0 = sample0;
  3.6520 -    while (dst >= target) {
  3.6521 -        dst[5] = SDL_SwapFloatLE(sample5);
  3.6522 -        dst[4] = SDL_SwapFloatLE(sample4);
  3.6523 -        dst[3] = SDL_SwapFloatLE(sample3);
  3.6524 -        dst[2] = SDL_SwapFloatLE(sample2);
  3.6525 -        dst[1] = SDL_SwapFloatLE(sample1);
  3.6526 -        dst[0] = SDL_SwapFloatLE(sample0);
  3.6527 -        dst -= 6;
  3.6528 -        eps += srcsize;
  3.6529 -        if ((eps << 1) >= dstsize) {
  3.6530 -            src -= 6;
  3.6531 -            sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
  3.6532 -            sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
  3.6533 -            sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
  3.6534 -            sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
  3.6535 -            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
  3.6536 -            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  3.6537 -            last_sample5 = sample5;
  3.6538 -            last_sample4 = sample4;
  3.6539 -            last_sample3 = sample3;
  3.6540 -            last_sample2 = sample2;
  3.6541 -            last_sample1 = sample1;
  3.6542 -            last_sample0 = sample0;
  3.6543 -            eps -= dstsize;
  3.6544 -        }
  3.6545 -    }
  3.6546 -    cvt->len_cvt = dstsize;
  3.6547 -    if (cvt->filters[++cvt->filter_index]) {
  3.6548 -        cvt->filters[cvt->filter_index] (cvt, format);
  3.6549 -    }
  3.6550 -}
  3.6551 -
  3.6552 -static void SDLCALL
  3.6553 -SDL_Downsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.6554 -{
  3.6555 -#if DEBUG_CONVERT
  3.6556 -    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 6 channels.\n", cvt->rate_incr);
  3.6557 -#endif
  3.6558 -
  3.6559 -    const int srcsize = cvt->len_cvt - 384;
  3.6560 -    const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
  3.6561 -    register int eps = 0;
  3.6562 -    float *dst = (float *) cvt->buf;
  3.6563 -    const float *src = (float *) cvt->buf;
  3.6564 -    const float *target = (const float *) (cvt->buf + dstsize);
  3.6565 -    float sample0 = SDL_SwapFloatLE(src[0]);
  3.6566 -    float sample1 = SDL_SwapFloatLE(src[1]);
  3.6567 -    float sample2 = SDL_SwapFloatLE(src[2]);
  3.6568 -    float sample3 = SDL_SwapFloatLE(src[3]);
  3.6569 -    float sample4 = SDL_SwapFloatLE(src[4]);
  3.6570 -    float sample5 = SDL_SwapFloatLE(src[5]);
  3.6571 -    float last_sample0 = sample0;
  3.6572 -    float last_sample1 = sample1;
  3.6573 -    float last_sample2 = sample2;
  3.6574 -    float last_sample3 = sample3;
  3.6575 -    float last_sample4 = sample4;
  3.6576 -    float last_sample5 = sample5;
  3.6577 -