First shot at new audio resampling code.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 11 Jan 2009 04:46:42 +0000
changeset 3021f3dcf04412cf
parent 3020 70d876a0b90e
child 3022 db20dde98dd3
First shot at new audio resampling code.
include/SDL_audio.h
src/audio/SDL_audio.c
src/audio/SDL_audio_c.h
src/audio/SDL_audiocvt.c
src/audio/SDL_audiotypecvt.c
     1.1 --- a/include/SDL_audio.h	Sun Jan 11 04:46:14 2009 +0000
     1.2 +++ b/include/SDL_audio.h	Sun Jan 11 04:46:42 2009 +0000
     1.3 @@ -147,15 +147,10 @@
     1.4      SDL_AudioFormat dst_format; /* Target audio format */
     1.5      double rate_incr;           /* Rate conversion increment */
     1.6      Uint8 *buf;                 /* Buffer to hold entire audio data */
     1.7 -    Uint8 *coeff;               /* Filter coefficients: either big windowed sinc filter, or 6 IIR lowpass coefficients */
     1.8 -    Uint8 *state_buf;           /* Sample history for either the FIR or IIR filter. For IIR filter, first two elements are X, second two are Y, and state_pos toggles the order */
     1.9 -    int state_pos;              /* Position in the state */
    1.10 -    int len_sinc;               /* Length of windowed sinc filter, in appropriate units (not necessarily bytes) */
    1.11      int len;                    /* Length of original audio buffer */
    1.12      int len_cvt;                /* Length of converted audio buffer */
    1.13      int len_mult;               /* buffer must be len*len_mult big */
    1.14 -    int len_div;                /* destination length = len_mult / len_div * src length */
    1.15 -    double len_ratio;           /* Given len, final size is len*len_ratio ( len_ratio = len_mult / len_div ) */
    1.16 +    double len_ratio;           /* Given len, final size is len*len_ratio */
    1.17      SDL_AudioFilter filters[10];        /* Filter list */
    1.18      int filter_index;           /* Current audio conversion function */
    1.19  } SDL_AudioCVT;
     2.1 --- a/src/audio/SDL_audio.c	Sun Jan 11 04:46:14 2009 +0000
     2.2 +++ b/src/audio/SDL_audio.c	Sun Jan 11 04:46:42 2009 +0000
     2.3 @@ -371,6 +371,7 @@
     2.4              silence = 0;
     2.5          }
     2.6  
     2.7 +#if 0  /* !!! FIXME: I took len_div out of the structure. Use rate_incr instead? */
     2.8          /* If the result of the conversion alters the length, i.e. resampling is being used, use the streamer */
     2.9          if (device->convert.len_mult != 1 || device->convert.len_div != 1) {
    2.10              /* The streamer's maximum length should be twice whichever is larger: spec.size or len_cvt */
    2.11 @@ -391,6 +392,7 @@
    2.12                  device->spec.size * device->convert.len_div /
    2.13                  device->convert.len_mult;
    2.14          }
    2.15 +#endif
    2.16  
    2.17          /* stream_len = device->convert.len; */
    2.18          stream_len = device->spec.size;
     3.1 --- a/src/audio/SDL_audio_c.h	Sun Jan 11 04:46:14 2009 +0000
     3.2 +++ b/src/audio/SDL_audio_c.h	Sun Jan 11 04:46:42 2009 +0000
     3.3 @@ -42,4 +42,15 @@
     3.4  } SDL_AudioTypeFilters;
     3.5  extern const SDL_AudioTypeFilters sdl_audio_type_filters[];
     3.6  
     3.7 +/* this is used internally to access some autogenerated code. */
     3.8 +typedef struct
     3.9 +{
    3.10 +    SDL_AudioFormat fmt;
    3.11 +    int channels;
    3.12 +    int upsample;
    3.13 +    int multiple;
    3.14 +    SDL_AudioFilter filter;
    3.15 +} SDL_AudioRateFilters;
    3.16 +extern const SDL_AudioRateFilters sdl_audio_rate_filters[];
    3.17 +
    3.18  /* vi: set ts=4 sw=4 expandtab: */
     4.1 --- a/src/audio/SDL_audiocvt.c	Sun Jan 11 04:46:14 2009 +0000
     4.2 +++ b/src/audio/SDL_audiocvt.c	Sun Jan 11 04:46:42 2009 +0000
     4.3 @@ -26,37 +26,12 @@
     4.4  #include "SDL_audio.h"
     4.5  #include "SDL_audio_c.h"
     4.6  
     4.7 -//#define DEBUG_CONVERT
     4.8 +/* #define DEBUG_CONVERT */
     4.9  
    4.10 -/* These are fractional multiplication routines. That is, their inputs
    4.11 -   are two numbers in the range [-1, 1) and the result falls in that
    4.12 -   same range. The output is the same size as the inputs, i.e.
    4.13 -   32-bit x 32-bit = 32-bit.
    4.14 - */
    4.15 -
    4.16 -/* We hope here that the right shift includes sign extension */
    4.17 -#ifdef SDL_HAS_64BIT_Type
    4.18 -#define SDL_FixMpy32(a, b) ((((Sint64)a * (Sint64)b) >> 31) & 0xffffffff)
    4.19 -#else
    4.20 -/* If we don't have the 64-bit type, do something more complicated. See http://www.8052.com/mul16.phtml or http://www.cs.uaf.edu/~cs301/notes/Chapter5/node5.html */
    4.21 -#define SDL_FixMpy32(a, b) ((((Sint64)a * (Sint64)b) >> 31) & 0xffffffff)
    4.22 +/* !!! FIXME */
    4.23 +#ifndef assert
    4.24 +#define assert(x)
    4.25  #endif
    4.26 -#define SDL_FixMpy16(a, b) ((((Sint32)a * (Sint32)b) >> 14) & 0xffff)
    4.27 -#define SDL_FixMpy8(a, b) ((((Sint16)a * (Sint16)b) >> 7) & 0xff)
    4.28 -/* This macro just makes the floating point filtering code not have to be a special case. */
    4.29 -#define SDL_FloatMpy(a, b) (a * b)
    4.30 -
    4.31 -/* These macros take floating point numbers in the range [-1.0f, 1.0f) and
    4.32 -   represent them as fixed-point numbers in that same range. There's no
    4.33 -   checking that the floating point argument is inside the appropriate range.
    4.34 - */
    4.35 -
    4.36 -#define SDL_Make_1_7(a) (Sint8)(a * 128.0f)
    4.37 -#define SDL_Make_1_15(a) (Sint16)(a * 32768.0f)
    4.38 -#define SDL_Make_1_31(a) (Sint32)(a * 2147483648.0f)
    4.39 -#define SDL_Make_2_6(a) (Sint8)(a * 64.0f)
    4.40 -#define SDL_Make_2_14(a) (Sint16)(a * 16384.0f)
    4.41 -#define SDL_Make_2_30(a) (Sint32)(a * 1073741824.0f)
    4.42  
    4.43  /* Effectively mix right and left channels into a single channel */
    4.44  static void SDLCALL
    4.45 @@ -798,472 +773,13 @@
    4.46      }
    4.47  }
    4.48  
    4.49 -/* Convert rate up by multiple of 2 */
    4.50 -static void SDLCALL
    4.51 -SDL_RateMUL2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    4.52 -{
    4.53 -    int i;
    4.54 -
    4.55 -#ifdef DEBUG_CONVERT
    4.56 -    fprintf(stderr, "Converting audio rate * 2 (mono)\n");
    4.57 -#endif
    4.58 -
    4.59 -#define mul2_mono(type) { \
    4.60 -        const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
    4.61 -        type *dst = (type *) (cvt->buf + (cvt->len_cvt * 2)); \
    4.62 -        for (i = cvt->len_cvt / sizeof (type); i; --i) { \
    4.63 -            src--; \
    4.64 -            dst[-1] = dst[-2] = src[0]; \
    4.65 -            dst -= 2; \
    4.66 -        } \
    4.67 -    }
    4.68 -
    4.69 -    switch (SDL_AUDIO_BITSIZE(format)) {
    4.70 -    case 8:
    4.71 -        mul2_mono(Uint8);
    4.72 -        break;
    4.73 -    case 16:
    4.74 -        mul2_mono(Uint16);
    4.75 -        break;
    4.76 -    case 32:
    4.77 -        mul2_mono(Uint32);
    4.78 -        break;
    4.79 -    }
    4.80 -
    4.81 -#undef mul2_mono
    4.82 -
    4.83 -    cvt->len_cvt *= 2;
    4.84 -    if (cvt->filters[++cvt->filter_index]) {
    4.85 -        cvt->filters[cvt->filter_index] (cvt, format);
    4.86 -    }
    4.87 -}
    4.88 -
    4.89 -
    4.90 -/* Convert rate up by multiple of 2, for stereo */
    4.91 -static void SDLCALL
    4.92 -SDL_RateMUL2_c2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    4.93 -{
    4.94 -    int i;
    4.95 -
    4.96 -#ifdef DEBUG_CONVERT
    4.97 -    fprintf(stderr, "Converting audio rate * 2 (stereo)\n");
    4.98 -#endif
    4.99 -
   4.100 -#define mul2_stereo(type) { \
   4.101 -        const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
   4.102 -        type *dst = (type *) (cvt->buf + (cvt->len_cvt * 2)); \
   4.103 -        for (i = cvt->len_cvt / (sizeof (type) * 2); i; --i) { \
   4.104 -            const type r = src[-1]; \
   4.105 -            const type l = src[-2]; \
   4.106 -            src -= 2; \
   4.107 -            dst[-1] = r; \
   4.108 -            dst[-2] = l; \
   4.109 -            dst[-3] = r; \
   4.110 -            dst[-4] = l; \
   4.111 -            dst -= 4; \
   4.112 -        } \
   4.113 -    }
   4.114 -
   4.115 -    switch (SDL_AUDIO_BITSIZE(format)) {
   4.116 -    case 8:
   4.117 -        mul2_stereo(Uint8);
   4.118 -        break;
   4.119 -    case 16:
   4.120 -        mul2_stereo(Uint16);
   4.121 -        break;
   4.122 -    case 32:
   4.123 -        mul2_stereo(Uint32);
   4.124 -        break;
   4.125 -    }
   4.126 -
   4.127 -#undef mul2_stereo
   4.128 -
   4.129 -    cvt->len_cvt *= 2;
   4.130 -    if (cvt->filters[++cvt->filter_index]) {
   4.131 -        cvt->filters[cvt->filter_index] (cvt, format);
   4.132 -    }
   4.133 -}
   4.134 -
   4.135 -/* Convert rate up by multiple of 2, for quad */
   4.136 -static void SDLCALL
   4.137 -SDL_RateMUL2_c4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.138 -{
   4.139 -    int i;
   4.140 -
   4.141 -#ifdef DEBUG_CONVERT
   4.142 -    fprintf(stderr, "Converting audio rate * 2 (quad)\n");
   4.143 -#endif
   4.144 -
   4.145 -#define mul2_quad(type) { \
   4.146 -        const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
   4.147 -        type *dst = (type *) (cvt->buf + (cvt->len_cvt * 2)); \
   4.148 -        for (i = cvt->len_cvt / (sizeof (type) * 4); i; --i) { \
   4.149 -            const type c1 = src[-1]; \
   4.150 -            const type c2 = src[-2]; \
   4.151 -            const type c3 = src[-3]; \
   4.152 -            const type c4 = src[-4]; \
   4.153 -            src -= 4; \
   4.154 -            dst[-1] = c1; \
   4.155 -            dst[-2] = c2; \
   4.156 -            dst[-3] = c3; \
   4.157 -            dst[-4] = c4; \
   4.158 -            dst[-5] = c1; \
   4.159 -            dst[-6] = c2; \
   4.160 -            dst[-7] = c3; \
   4.161 -            dst[-8] = c4; \
   4.162 -            dst -= 8; \
   4.163 -        } \
   4.164 -    }
   4.165 -
   4.166 -    switch (SDL_AUDIO_BITSIZE(format)) {
   4.167 -    case 8:
   4.168 -        mul2_quad(Uint8);
   4.169 -        break;
   4.170 -    case 16:
   4.171 -        mul2_quad(Uint16);
   4.172 -        break;
   4.173 -    case 32:
   4.174 -        mul2_quad(Uint32);
   4.175 -        break;
   4.176 -    }
   4.177 -
   4.178 -#undef mul2_quad
   4.179 -
   4.180 -    cvt->len_cvt *= 2;
   4.181 -    if (cvt->filters[++cvt->filter_index]) {
   4.182 -        cvt->filters[cvt->filter_index] (cvt, format);
   4.183 -    }
   4.184 -}
   4.185 -
   4.186 -
   4.187 -/* Convert rate up by multiple of 2, for 5.1 */
   4.188 -static void SDLCALL
   4.189 -SDL_RateMUL2_c6(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.190 -{
   4.191 -    int i;
   4.192 -
   4.193 -#ifdef DEBUG_CONVERT
   4.194 -    fprintf(stderr, "Converting audio rate * 2 (six channels)\n");
   4.195 -#endif
   4.196 -
   4.197 -#define mul2_chansix(type) { \
   4.198 -        const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
   4.199 -        type *dst = (type *) (cvt->buf + (cvt->len_cvt * 2)); \
   4.200 -        for (i = cvt->len_cvt / (sizeof (type) * 6); i; --i) { \
   4.201 -            const type c1 = src[-1]; \
   4.202 -            const type c2 = src[-2]; \
   4.203 -            const type c3 = src[-3]; \
   4.204 -            const type c4 = src[-4]; \
   4.205 -            const type c5 = src[-5]; \
   4.206 -            const type c6 = src[-6]; \
   4.207 -            src -= 6; \
   4.208 -            dst[-1] = c1; \
   4.209 -            dst[-2] = c2; \
   4.210 -            dst[-3] = c3; \
   4.211 -            dst[-4] = c4; \
   4.212 -            dst[-5] = c5; \
   4.213 -            dst[-6] = c6; \
   4.214 -            dst[-7] = c1; \
   4.215 -            dst[-8] = c2; \
   4.216 -            dst[-9] = c3; \
   4.217 -            dst[-10] = c4; \
   4.218 -            dst[-11] = c5; \
   4.219 -            dst[-12] = c6; \
   4.220 -            dst -= 12; \
   4.221 -        } \
   4.222 -    }
   4.223 -
   4.224 -    switch (SDL_AUDIO_BITSIZE(format)) {
   4.225 -    case 8:
   4.226 -        mul2_chansix(Uint8);
   4.227 -        break;
   4.228 -    case 16:
   4.229 -        mul2_chansix(Uint16);
   4.230 -        break;
   4.231 -    case 32:
   4.232 -        mul2_chansix(Uint32);
   4.233 -        break;
   4.234 -    }
   4.235 -
   4.236 -#undef mul2_chansix
   4.237 -
   4.238 -    cvt->len_cvt *= 2;
   4.239 -    if (cvt->filters[++cvt->filter_index]) {
   4.240 -        cvt->filters[cvt->filter_index] (cvt, format);
   4.241 -    }
   4.242 -}
   4.243 -
   4.244 -/* Convert rate down by multiple of 2 */
   4.245 -static void SDLCALL
   4.246 -SDL_RateDIV2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.247 -{
   4.248 -    int i;
   4.249 -
   4.250 -#ifdef DEBUG_CONVERT
   4.251 -    fprintf(stderr, "Converting audio rate / 2 (mono)\n");
   4.252 -#endif
   4.253 -
   4.254 -#define div2_mono(type) { \
   4.255 -        const type *src = (const type *) cvt->buf; \
   4.256 -        type *dst = (type *) cvt->buf; \
   4.257 -        for (i = cvt->len_cvt / (sizeof (type) * 2); i; --i) { \
   4.258 -            dst[0] = src[0]; \
   4.259 -            src += 2; \
   4.260 -            dst++; \
   4.261 -        } \
   4.262 -    }
   4.263 -
   4.264 -    switch (SDL_AUDIO_BITSIZE(format)) {
   4.265 -    case 8:
   4.266 -        div2_mono(Uint8);
   4.267 -        break;
   4.268 -    case 16:
   4.269 -        div2_mono(Uint16);
   4.270 -        break;
   4.271 -    case 32:
   4.272 -        div2_mono(Uint32);
   4.273 -        break;
   4.274 -    }
   4.275 -
   4.276 -#undef div2_mono
   4.277 -
   4.278 -    cvt->len_cvt /= 2;
   4.279 -    if (cvt->filters[++cvt->filter_index]) {
   4.280 -        cvt->filters[cvt->filter_index] (cvt, format);
   4.281 -    }
   4.282 -}
   4.283 -
   4.284 -
   4.285 -/* Convert rate down by multiple of 2, for stereo */
   4.286 -static void SDLCALL
   4.287 -SDL_RateDIV2_c2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.288 -{
   4.289 -    int i;
   4.290 -
   4.291 -#ifdef DEBUG_CONVERT
   4.292 -    fprintf(stderr, "Converting audio rate / 2 (stereo)\n");
   4.293 -#endif
   4.294 -
   4.295 -#define div2_stereo(type) { \
   4.296 -        const type *src = (const type *) cvt->buf; \
   4.297 -        type *dst = (type *) cvt->buf; \
   4.298 -        for (i = cvt->len_cvt / (sizeof (type) * 4); i; --i) { \
   4.299 -            dst[0] = src[0]; \
   4.300 -            dst[1] = src[1]; \
   4.301 -            src += 4; \
   4.302 -            dst += 2; \
   4.303 -        } \
   4.304 -    }
   4.305 -
   4.306 -    switch (SDL_AUDIO_BITSIZE(format)) {
   4.307 -    case 8:
   4.308 -        div2_stereo(Uint8);
   4.309 -        break;
   4.310 -    case 16:
   4.311 -        div2_stereo(Uint16);
   4.312 -        break;
   4.313 -    case 32:
   4.314 -        div2_stereo(Uint32);
   4.315 -        break;
   4.316 -    }
   4.317 -
   4.318 -#undef div2_stereo
   4.319 -
   4.320 -    cvt->len_cvt /= 2;
   4.321 -    if (cvt->filters[++cvt->filter_index]) {
   4.322 -        cvt->filters[cvt->filter_index] (cvt, format);
   4.323 -    }
   4.324 -}
   4.325 -
   4.326 -
   4.327 -/* Convert rate down by multiple of 2, for quad */
   4.328 -static void SDLCALL
   4.329 -SDL_RateDIV2_c4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.330 -{
   4.331 -    int i;
   4.332 -
   4.333 -#ifdef DEBUG_CONVERT
   4.334 -    fprintf(stderr, "Converting audio rate / 2 (quad)\n");
   4.335 -#endif
   4.336 -
   4.337 -#define div2_quad(type) { \
   4.338 -        const type *src = (const type *) cvt->buf; \
   4.339 -        type *dst = (type *) cvt->buf; \
   4.340 -        for (i = cvt->len_cvt / (sizeof (type) * 8); i; --i) { \
   4.341 -            dst[0] = src[0]; \
   4.342 -            dst[1] = src[1]; \
   4.343 -            dst[2] = src[2]; \
   4.344 -            dst[3] = src[3]; \
   4.345 -            src += 8; \
   4.346 -            dst += 4; \
   4.347 -        } \
   4.348 -    }
   4.349 -
   4.350 -    switch (SDL_AUDIO_BITSIZE(format)) {
   4.351 -    case 8:
   4.352 -        div2_quad(Uint8);
   4.353 -        break;
   4.354 -    case 16:
   4.355 -        div2_quad(Uint16);
   4.356 -        break;
   4.357 -    case 32:
   4.358 -        div2_quad(Uint32);
   4.359 -        break;
   4.360 -    }
   4.361 -
   4.362 -#undef div2_quad
   4.363 -
   4.364 -    cvt->len_cvt /= 2;
   4.365 -    if (cvt->filters[++cvt->filter_index]) {
   4.366 -        cvt->filters[cvt->filter_index] (cvt, format);
   4.367 -    }
   4.368 -}
   4.369 -
   4.370 -/* Convert rate down by multiple of 2, for 5.1 */
   4.371 -static void SDLCALL
   4.372 -SDL_RateDIV2_c6(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.373 -{
   4.374 -    int i;
   4.375 -
   4.376 -#ifdef DEBUG_CONVERT
   4.377 -    fprintf(stderr, "Converting audio rate / 2 (six channels)\n");
   4.378 -#endif
   4.379 -
   4.380 -#define div2_chansix(type) { \
   4.381 -        const type *src = (const type *) cvt->buf; \
   4.382 -        type *dst = (type *) cvt->buf; \
   4.383 -        for (i = cvt->len_cvt / (sizeof (type) * 12); i; --i) { \
   4.384 -            dst[0] = src[0]; \
   4.385 -            dst[1] = src[1]; \
   4.386 -            dst[2] = src[2]; \
   4.387 -            dst[3] = src[3]; \
   4.388 -            dst[4] = src[4]; \
   4.389 -            dst[5] = src[5]; \
   4.390 -            src += 12; \
   4.391 -            dst += 6; \
   4.392 -        } \
   4.393 -    }
   4.394 -
   4.395 -    switch (SDL_AUDIO_BITSIZE(format)) {
   4.396 -    case 8:
   4.397 -        div2_chansix(Uint8);
   4.398 -        break;
   4.399 -    case 16:
   4.400 -        div2_chansix(Uint16);
   4.401 -        break;
   4.402 -    case 32:
   4.403 -        div2_chansix(Uint32);
   4.404 -        break;
   4.405 -    }
   4.406 -
   4.407 -#undef div_chansix
   4.408 -
   4.409 -    cvt->len_cvt /= 2;
   4.410 -    if (cvt->filters[++cvt->filter_index]) {
   4.411 -        cvt->filters[cvt->filter_index] (cvt, format);
   4.412 -    }
   4.413 -}
   4.414 -
   4.415 -/* Very slow rate conversion routine */
   4.416 -static void SDLCALL
   4.417 -SDL_RateSLOW(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.418 -{
   4.419 -    double ipos;
   4.420 -    int i, clen;
   4.421 -
   4.422 -#ifdef DEBUG_CONVERT
   4.423 -    fprintf(stderr, "Converting audio rate * %4.4f\n", 1.0 / cvt->rate_incr);
   4.424 -#endif
   4.425 -    clen = (int) ((double) cvt->len_cvt / cvt->rate_incr);
   4.426 -    if (cvt->rate_incr > 1.0) {
   4.427 -        switch (SDL_AUDIO_BITSIZE(format)) {
   4.428 -        case 8:
   4.429 -            {
   4.430 -                Uint8 *output;
   4.431 -
   4.432 -                output = cvt->buf;
   4.433 -                ipos = 0.0;
   4.434 -                for (i = clen; i; --i) {
   4.435 -                    *output = cvt->buf[(int) ipos];
   4.436 -                    ipos += cvt->rate_incr;
   4.437 -                    output += 1;
   4.438 -                }
   4.439 -            }
   4.440 -            break;
   4.441 -
   4.442 -        case 16:
   4.443 -            {
   4.444 -                Uint16 *output;
   4.445 -
   4.446 -                clen &= ~1;
   4.447 -                output = (Uint16 *) cvt->buf;
   4.448 -                ipos = 0.0;
   4.449 -                for (i = clen / 2; i; --i) {
   4.450 -                    *output = ((Uint16 *) cvt->buf)[(int) ipos];
   4.451 -                    ipos += cvt->rate_incr;
   4.452 -                    output += 1;
   4.453 -                }
   4.454 -            }
   4.455 -            break;
   4.456 -
   4.457 -        case 32:
   4.458 -            {
   4.459 -                /* !!! FIXME: need 32-bit converter here! */
   4.460 -#ifdef DEBUG_CONVERT
   4.461 -                fprintf(stderr, "FIXME: need 32-bit converter here!\n");
   4.462 -#endif
   4.463 -            }
   4.464 -        }
   4.465 -    } else {
   4.466 -        switch (SDL_AUDIO_BITSIZE(format)) {
   4.467 -        case 8:
   4.468 -            {
   4.469 -                Uint8 *output;
   4.470 -
   4.471 -                output = cvt->buf + clen;
   4.472 -                ipos = (double) cvt->len_cvt;
   4.473 -                for (i = clen; i; --i) {
   4.474 -                    ipos -= cvt->rate_incr;
   4.475 -                    output -= 1;
   4.476 -                    *output = cvt->buf[(int) ipos];
   4.477 -                }
   4.478 -            }
   4.479 -            break;
   4.480 -
   4.481 -        case 16:
   4.482 -            {
   4.483 -                Uint16 *output;
   4.484 -
   4.485 -                clen &= ~1;
   4.486 -                output = (Uint16 *) (cvt->buf + clen);
   4.487 -                ipos = (double) cvt->len_cvt / 2;
   4.488 -                for (i = clen / 2; i; --i) {
   4.489 -                    ipos -= cvt->rate_incr;
   4.490 -                    output -= 1;
   4.491 -                    *output = ((Uint16 *) cvt->buf)[(int) ipos];
   4.492 -                }
   4.493 -            }
   4.494 -            break;
   4.495 -
   4.496 -        case 32:
   4.497 -            {
   4.498 -                /* !!! FIXME: need 32-bit converter here! */
   4.499 -#ifdef DEBUG_CONVERT
   4.500 -                fprintf(stderr, "FIXME: need 32-bit converter here!\n");
   4.501 -#endif
   4.502 -            }
   4.503 -        }
   4.504 -    }
   4.505 -
   4.506 -    cvt->len_cvt = clen;
   4.507 -    if (cvt->filters[++cvt->filter_index]) {
   4.508 -        cvt->filters[cvt->filter_index] (cvt, format);
   4.509 -    }
   4.510 -}
   4.511  
   4.512  int
   4.513  SDL_ConvertAudio(SDL_AudioCVT * cvt)
   4.514  {
   4.515 +    /* !!! FIXME: (cvt) should be const; stack-copy it here. */
   4.516 +    /* !!! FIXME: (actually, we can't...len_cvt needs to be updated. Grr.) */
   4.517 +
   4.518      /* Make sure there's data to convert */
   4.519      if (cvt->buf == NULL) {
   4.520          SDL_SetError("No buffer allocated for conversion");
   4.521 @@ -1341,478 +857,96 @@
   4.522      return 0;                   /* no conversion necessary. */
   4.523  }
   4.524  
   4.525 -/* Generate the necessary IIR lowpass coefficients for resampling.
   4.526 -   Assume that the SDL_AudioCVT struct is already set up with
   4.527 -   the correct values for len_mult and len_div, and use the
   4.528 -   type of dst_format. Also assume the buffer is allocated.
   4.529 -   Note the buffer needs to be 6 units long.
   4.530 -   For now, use RBJ's cookbook coefficients. It might be more
   4.531 -   optimal to create a Butterworth filter, but this is more difficult.
   4.532 -*/
   4.533 -#if 0
   4.534 -int
   4.535 -SDL_BuildIIRLowpass(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.536 -{
   4.537 -    float fc;                   /* cutoff frequency */
   4.538 -    float coeff[6];             /* floating point iir coefficients b0, b1, b2, a0, a1, a2 */
   4.539 -    float scale;
   4.540 -    float w0, alpha, cosw0;
   4.541 -    int i;
   4.542 -
   4.543 -    /* The higher Q is, the higher CUTOFF can be. Need to find a good balance to avoid aliasing */
   4.544 -    static const float Q = 5.0f;
   4.545 -    static const float CUTOFF = 0.4f;
   4.546 -
   4.547 -    fc = (cvt->len_mult >
   4.548 -          cvt->len_div) ? CUTOFF / (float) cvt->len_mult : CUTOFF /
   4.549 -        (float) cvt->len_div;
   4.550 -
   4.551 -    w0 = 2.0f * M_PI * fc;
   4.552 -    cosw0 = cosf(w0);
   4.553 -    alpha = sinf(w0) / (2.0f * Q);
   4.554 -
   4.555 -    /* Compute coefficients, normalizing by a0 */
   4.556 -    scale = 1.0f / (1.0f + alpha);
   4.557 -
   4.558 -    coeff[0] = (1.0f - cosw0) / 2.0f * scale;
   4.559 -    coeff[1] = (1.0f - cosw0) * scale;
   4.560 -    coeff[2] = coeff[0];
   4.561 -
   4.562 -    coeff[3] = 1.0f;            /* a0 is normalized to 1 */
   4.563 -    coeff[4] = -2.0f * cosw0 * scale;
   4.564 -    coeff[5] = (1.0f - alpha) * scale;
   4.565 -
   4.566 -    /* Copy the coefficients to the struct. If necessary, convert coefficients to fixed point, using the range (-2.0, 2.0) */
   4.567 -#define convert_fixed(type, fix) { \
   4.568 -            type *cvt_coeff = (type *)cvt->coeff; \
   4.569 -            for(i = 0; i < 6; ++i) { \
   4.570 -                cvt_coeff[i] = fix(coeff[i]); \
   4.571 -            } \
   4.572 -        }
   4.573 -
   4.574 -    if (SDL_AUDIO_ISFLOAT(format) && SDL_AUDIO_BITSIZE(format) == 32) {
   4.575 -        float *cvt_coeff = (float *) cvt->coeff;
   4.576 -        for (i = 0; i < 6; ++i) {
   4.577 -            cvt_coeff[i] = coeff[i];
   4.578 -        }
   4.579 -    } else {
   4.580 -        switch (SDL_AUDIO_BITSIZE(format)) {
   4.581 -        case 8:
   4.582 -            convert_fixed(Uint8, SDL_Make_2_6);
   4.583 -            break;
   4.584 -        case 16:
   4.585 -            convert_fixed(Uint16, SDL_Make_2_14);
   4.586 -            break;
   4.587 -        case 32:
   4.588 -            convert_fixed(Uint32, SDL_Make_2_30);
   4.589 -            break;
   4.590 -        }
   4.591 -    }
   4.592 -
   4.593 -#ifdef DEBUG_CONVERT
   4.594 -#define debug_iir(type) { \
   4.595 -            type *cvt_coeff = (type *)cvt->coeff; \
   4.596 -            for(i = 0; i < 6; ++i) { \
   4.597 -                printf("coeff[%u] = %f = 0x%x\n", i, coeff[i], cvt_coeff[i]); \
   4.598 -            } \
   4.599 -        }
   4.600 -    if (SDL_AUDIO_ISFLOAT(format) && SDL_AUDIO_BITSIZE(format) == 32) {
   4.601 -        float *cvt_coeff = (float *) cvt->coeff;
   4.602 -        for (i = 0; i < 6; ++i) {
   4.603 -            printf("coeff[%u] = %f = %f\n", i, coeff[i], cvt_coeff[i]);
   4.604 -        }
   4.605 -    } else {
   4.606 -        switch (SDL_AUDIO_BITSIZE(format)) {
   4.607 -        case 8:
   4.608 -            debug_iir(Uint8);
   4.609 -            break;
   4.610 -        case 16:
   4.611 -            debug_iir(Uint16);
   4.612 -            break;
   4.613 -        case 32:
   4.614 -            debug_iir(Uint32);
   4.615 -            break;
   4.616 -        }
   4.617 -    }
   4.618 -#undef debug_iir
   4.619 -#endif
   4.620  
   4.621 -    /* Initialize the state buffer to all zeroes, and set initial position */
   4.622 -    SDL_memset(cvt->state_buf, 0, 4 * SDL_AUDIO_BITSIZE(format) / 4);
   4.623 -    cvt->state_pos = 0;
   4.624 -#undef convert_fixed
   4.625 -
   4.626 -    return 0;
   4.627 -}
   4.628 -#endif
   4.629 -
   4.630 -/* Apply the lowpass IIR filter to the given SDL_AudioCVT struct */
   4.631 -/* This was implemented because it would be much faster than the fir filter, 
   4.632 -   but it doesn't seem to have a steep enough cutoff so we'd need several
   4.633 -   cascaded biquads, which probably isn't a great idea. Therefore, this
   4.634 -   function can probably be discarded.
   4.635 -*/
   4.636 -static void
   4.637 -SDL_FilterIIR(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.638 +static SDL_AudioFilter
   4.639 +SDL_HandTunedResampleCVT(SDL_AudioCVT * cvt, int dst_channels,
   4.640 +                         int src_rate, int dst_rate)
   4.641  {
   4.642 -    Uint32 i, n;
   4.643 -
   4.644 -    /* TODO: Check that n is calculated right */
   4.645 -    n = 8 * cvt->len_cvt / SDL_AUDIO_BITSIZE(format);
   4.646 +    /*
   4.647 +     * Fill in any future conversions that are specialized to a
   4.648 +     *  processor, platform, compiler, or library here.
   4.649 +     */
   4.650  
   4.651 -    /* Note that the coefficients are 2_x and the input is 1_x. Do we need to shift left at the end here? The right shift temp = buf[n] >> 1 needs to depend on whether the type is signed or not for sign extension. */
   4.652 -    /* cvt->state_pos = 1: state[0] = x_n-1, state[1] = x_n-2, state[2] = y_n-1, state[3] - y_n-2 */
   4.653 -#define iir_fix(type, mult) {\
   4.654 -            type *coeff = (type *)cvt->coeff; \
   4.655 -            type *state = (type *)cvt->state_buf; \
   4.656 -            type *buf = (type *)cvt->buf; \
   4.657 -            type temp; \
   4.658 -            for(i = 0; i < n; ++i) { \
   4.659 -                    temp = buf[i] >> 1; \
   4.660 -                    if(cvt->state_pos) { \
   4.661 -                        buf[i] = mult(coeff[0], temp) + mult(coeff[1], state[0]) + mult(coeff[2], state[1]) - mult(coeff[4], state[2]) - mult(coeff[5], state[3]); \
   4.662 -                        state[1] = temp; \
   4.663 -                        state[3] = buf[i]; \
   4.664 -                        cvt->state_pos = 0; \
   4.665 -                    } else { \
   4.666 -                        buf[i] = mult(coeff[0], temp) + mult(coeff[1], state[1]) + mult(coeff[2], state[0]) - mult(coeff[4], state[3]) - mult(coeff[5], state[2]); \
   4.667 -                        state[0] = temp; \
   4.668 -                        state[2] = buf[i]; \
   4.669 -                        cvt->state_pos = 1; \
   4.670 -                    } \
   4.671 -                } \
   4.672 -        }
   4.673 -/* Need to test to see if the previous method or this one is faster */
   4.674 -/*#define iir_fix(type, mult) {\
   4.675 -            type *coeff = (type *)cvt->coeff; \
   4.676 -            type *state = (type *)cvt->state_buf; \
   4.677 -            type *buf = (type *)cvt->buf; \
   4.678 -            type temp; \
   4.679 -            for(i = 0; i < n; ++i) { \
   4.680 -                    temp = buf[i] >> 1; \
   4.681 -                    buf[i] = mult(coeff[0], temp) + mult(coeff[1], state[0]) + mult(coeff[2], state[1]) - mult(coeff[4], state[2]) - mult(coeff[5], state[3]); \
   4.682 -                    state[1] = state[0]; \
   4.683 -                    state[0] = temp; \
   4.684 -                    state[3] = state[2]; \
   4.685 -                    state[2] = buf[i]; \
   4.686 -                } \
   4.687 -        }*/
   4.688 -
   4.689 -    if (SDL_AUDIO_ISFLOAT(format) && SDL_AUDIO_BITSIZE(format) == 32) {
   4.690 -        float *coeff = (float *) cvt->coeff;
   4.691 -        float *state = (float *) cvt->state_buf;
   4.692 -        float *buf = (float *) cvt->buf;
   4.693 -        float temp;
   4.694 -
   4.695 -        for (i = 0; i < n; ++i) {
   4.696 -            /* y[n] = b0 * x[n] + b1 * x[n-1] + b2 * x[n-2] - a1 * y[n-1] - a[2] * y[n-2] */
   4.697 -            temp = buf[i];
   4.698 -            if (cvt->state_pos) {
   4.699 -                buf[i] =
   4.700 -                    coeff[0] * buf[n] + coeff[1] * state[0] +
   4.701 -                    coeff[2] * state[1] - coeff[4] * state[2] -
   4.702 -                    coeff[5] * state[3];
   4.703 -                state[1] = temp;
   4.704 -                state[3] = buf[i];
   4.705 -                cvt->state_pos = 0;
   4.706 -            } else {
   4.707 -                buf[i] =
   4.708 -                    coeff[0] * buf[n] + coeff[1] * state[1] +
   4.709 -                    coeff[2] * state[0] - coeff[4] * state[3] -
   4.710 -                    coeff[5] * state[2];
   4.711 -                state[0] = temp;
   4.712 -                state[2] = buf[i];
   4.713 -                cvt->state_pos = 1;
   4.714 -            }
   4.715 -        }
   4.716 -    } else {
   4.717 -        /* Treat everything as signed! */
   4.718 -        switch (SDL_AUDIO_BITSIZE(format)) {
   4.719 -        case 8:
   4.720 -            iir_fix(Sint8, SDL_FixMpy8);
   4.721 -            break;
   4.722 -        case 16:
   4.723 -            iir_fix(Sint16, SDL_FixMpy16);
   4.724 -            break;
   4.725 -        case 32:
   4.726 -            iir_fix(Sint32, SDL_FixMpy32);
   4.727 -            break;
   4.728 -        }
   4.729 -    }
   4.730 -#undef iir_fix
   4.731 +    return NULL;                /* no specialized converter code available. */
   4.732  }
   4.733  
   4.734 -/* Apply the windowed sinc FIR filter to the given SDL_AudioCVT struct.
   4.735 -*/
   4.736 -static void
   4.737 -SDL_FilterFIR(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.738 +static int
   4.739 +SDL_FindFrequencyMultiple(const int src_rate, const int dst_rate)
   4.740  {
   4.741 -    /* !!! FIXME: (n) is incorrect, or my allocation of state_buf is wrong. */
   4.742 -    const int n = 8 * cvt->len_cvt / SDL_AUDIO_BITSIZE(format);
   4.743 -    int m = cvt->len_sinc;
   4.744 -    int i, j;
   4.745 +    int retval = 0;
   4.746  
   4.747 -    /* 
   4.748 -       Note: We can make a big optimization here by taking advantage
   4.749 -       of the fact that the signal is zero stuffed, so we can do
   4.750 -       significantly fewer multiplications and additions. However, this
   4.751 -       depends on the zero stuffing ratio, so it may not pay off. This would
   4.752 -       basically be a polyphase filter.
   4.753 -     */
   4.754 -    /* One other way to do this fast is to look at the fir filter from a different angle:
   4.755 -       After we zero stuff, we have input of all zeroes, except for every len_mult
   4.756 -       sample. If we choose a sinc length equal to len_mult, then the fir filter becomes
   4.757 -       much more simple: we're just taking a windowed sinc, shifting it to start at each
   4.758 -       len_mult sample, and scaling it by the value of that sample. If we do this, then
   4.759 -       we don't even need to worry about the sample histories, and the inner loop here is
   4.760 -       unnecessary. This probably sacrifices some quality but could really speed things up as well.
   4.761 -     */
   4.762 -    /* We only calculate the values of samples which are 0 (mod len_div) because
   4.763 -       those are the only ones used. All the other ones are discarded in the
   4.764 -       third step of resampling. This is a huge speedup. As a warning, though,
   4.765 -       if for some reason this is used elsewhere where there are no samples discarded,
   4.766 -       the output will not be corrrect if len_div is not 1. To make this filter a
   4.767 -       generic FIR filter, simply remove the if statement "if(i % cvt->len_div == 0)"
   4.768 -       around the inner loop so that every sample is processed.
   4.769 -     */
   4.770 -    /* This is basically just a FIR filter. i.e. for input x_n and m coefficients,
   4.771 -       y_n = x_n*sinc_0 + x_(n-1)*sinc_1 +  x_(n-2)*sinc_2 + ... + x_(n-m+1)*sinc_(m-1)
   4.772 -     */
   4.773 -#define filter_sinc(type, mult) { \
   4.774 -            type *sinc = (type *)cvt->coeff; \
   4.775 -            type *state = (type *)cvt->state_buf; \
   4.776 -            type *buf = (type *)cvt->buf; \
   4.777 -            for(i = 0; i < n; ++i) { \
   4.778 -                state[cvt->state_pos] = buf[i]; \
   4.779 -                buf[i] = 0; \
   4.780 -                if( i % cvt->len_div == 0 ) { \
   4.781 -                    for(j = 0; j < m;  ++j) { \
   4.782 -                        buf[i] += mult(sinc[j], state[(cvt->state_pos + j) % m]); \
   4.783 -                    } \
   4.784 -                }\
   4.785 -                cvt->state_pos = (cvt->state_pos + 1) % m; \
   4.786 -            } \
   4.787 -        }
   4.788 +    /* If we only built with the arbitrary resamplers, ignore multiples. */
   4.789 +#if !LESS_RESAMPLERS
   4.790 +    int lo, hi;
   4.791 +    int div;
   4.792  
   4.793 -    if (SDL_AUDIO_ISFLOAT(format) && SDL_AUDIO_BITSIZE(format) == 32) {
   4.794 -        filter_sinc(float, SDL_FloatMpy);
   4.795 +    assert(src_rate != 0);
   4.796 +    assert(dst_rate != 0);
   4.797 +    assert(src_rate != dst_rate);
   4.798 +
   4.799 +    if (src_rate < dst_rate) {
   4.800 +        lo = src_rate;
   4.801 +        hi = dst_rate;
   4.802      } else {
   4.803 -        switch (SDL_AUDIO_BITSIZE(format)) {
   4.804 -        case 8:
   4.805 -            filter_sinc(Sint8, SDL_FixMpy8);
   4.806 -            break;
   4.807 -        case 16:
   4.808 -            filter_sinc(Sint16, SDL_FixMpy16);
   4.809 -            break;
   4.810 -        case 32:
   4.811 -            filter_sinc(Sint32, SDL_FixMpy32);
   4.812 -            break;
   4.813 -        }
   4.814 -    }
   4.815 -
   4.816 -#undef filter_sinc
   4.817 -
   4.818 -}
   4.819 -
   4.820 -/* Generate the necessary windowed sinc filter for resampling.
   4.821 -   Assume that the SDL_AudioCVT struct is already set up with
   4.822 -   the correct values for len_mult and len_div, and use the
   4.823 -   type of dst_format. Also assume the buffer is allocated.
   4.824 -   Note the buffer needs to be m+1 units long.
   4.825 -*/
   4.826 -int
   4.827 -SDL_BuildWindowedSinc(SDL_AudioCVT * cvt, SDL_AudioFormat format,
   4.828 -                      unsigned int m)
   4.829 -{
   4.830 -    float *fSinc;               /* floating point sinc buffer, to be converted to fixed point */
   4.831 -    float fc;                   /* cutoff frequency */
   4.832 -    float two_pi_fc, two_pi_over_m, four_pi_over_m, m_over_two;
   4.833 -    float norm_sum, norm_fact;
   4.834 -    unsigned int i;
   4.835 -
   4.836 -    /* Set the length */
   4.837 -    cvt->len_sinc = m + 1;
   4.838 -
   4.839 -    /* Allocate the floating point windowed sinc. */
   4.840 -    fSinc = SDL_stack_alloc(float, (m + 1));
   4.841 -    if (fSinc == NULL) {
   4.842 -        return -1;
   4.843 -    }
   4.844 -
   4.845 -    /* Set up the filter parameters */
   4.846 -    fc = (cvt->len_mult >
   4.847 -          cvt->len_div) ? 0.5f / (float) cvt->len_mult : 0.5f /
   4.848 -        (float) cvt->len_div;
   4.849 -#ifdef DEBUG_CONVERT
   4.850 -    printf("Lowpass cutoff frequency = %f\n", fc);
   4.851 -#endif
   4.852 -    two_pi_fc = 2.0f * M_PI * fc;
   4.853 -    two_pi_over_m = 2.0f * M_PI / (float) m;
   4.854 -    four_pi_over_m = 2.0f * two_pi_over_m;
   4.855 -    m_over_two = (float) m / 2.0f;
   4.856 -    norm_sum = 0.0f;
   4.857 -
   4.858 -    for (i = 0; i <= m; ++i) {
   4.859 -        if (i == m / 2) {
   4.860 -            fSinc[i] = two_pi_fc;
   4.861 -        } else {
   4.862 -            fSinc[i] = SDL_sinf(two_pi_fc * ((float) i - m_over_two)) / ((float) i - m_over_two);
   4.863 -            /* Apply blackman window */
   4.864 -            fSinc[i] *= 0.42f - 0.5f * SDL_cosf(two_pi_over_m * (float) i) + 0.08f * SDL_cosf(four_pi_over_m * (float) i);
   4.865 -        }
   4.866 -        norm_sum += fSinc[i] < 0 ? -fSinc[i] : fSinc[i];        /* fabs(fSinc[i]); */
   4.867 -    }
   4.868 -
   4.869 -    norm_fact = 1.0f / norm_sum;
   4.870 -
   4.871 -#define convert_fixed(type, fix) { \
   4.872 -        type *dst = (type *)cvt->coeff; \
   4.873 -        for( i = 0; i <= m; ++i ) { \
   4.874 -            dst[i] = fix(fSinc[i] * norm_fact); \
   4.875 -        } \
   4.876 +        lo = dst_rate;
   4.877 +        hi = src_rate;
   4.878      }
   4.879  
   4.880 -    /* !!! FIXME: this memory leaks. */
   4.881 -    cvt->coeff =
   4.882 -        (Uint8 *) SDL_malloc((SDL_AUDIO_BITSIZE(format) / 8) * (m + 1));
   4.883 -    if (cvt->coeff == NULL) {
   4.884 -        return -1;
   4.885 -    }
   4.886 -
   4.887 -    /* If we're using floating point, we only need to normalize */
   4.888 -    if (SDL_AUDIO_ISFLOAT(format) && SDL_AUDIO_BITSIZE(format) == 32) {
   4.889 -        float *fDest = (float *) cvt->coeff;
   4.890 -        for (i = 0; i <= m; ++i) {
   4.891 -            fDest[i] = fSinc[i] * norm_fact;
   4.892 -        }
   4.893 -    } else {
   4.894 -        switch (SDL_AUDIO_BITSIZE(format)) {
   4.895 -        case 8:
   4.896 -            convert_fixed(Uint8, SDL_Make_1_7);
   4.897 -            break;
   4.898 -        case 16:
   4.899 -            convert_fixed(Uint16, SDL_Make_1_15);
   4.900 -            break;
   4.901 -        case 32:
   4.902 -            convert_fixed(Uint32, SDL_Make_1_31);
   4.903 -            break;
   4.904 -        }
   4.905 -    }
   4.906 +    /* zero means "not a supported multiple" ... we only do 2x and 4x. */
   4.907 +    if ((hi % lo) != 0)
   4.908 +        return 0;   /* not a multiple. */
   4.909  
   4.910 -    /* Initialize the state buffer to all zeroes, and set initial position */
   4.911 -    /* !!! FIXME: this memory leaks. */
   4.912 -    cvt->state_buf =
   4.913 -        (Uint8 *) SDL_malloc(cvt->len_sinc * SDL_AUDIO_BITSIZE(format) / 4);
   4.914 -    if (cvt->state_buf == NULL) {
   4.915 -        return -1;
   4.916 -    }
   4.917 -    SDL_memset(cvt->state_buf, 0,
   4.918 -               cvt->len_sinc * SDL_AUDIO_BITSIZE(format) / 4);
   4.919 -    cvt->state_pos = 0;
   4.920 -
   4.921 -    /* Clean up */
   4.922 -#undef convert_fixed
   4.923 -    SDL_stack_free(fSinc);
   4.924 -
   4.925 -    return 0;
   4.926 -}
   4.927 -
   4.928 -/* This is used to reduce the resampling ratio */
   4.929 -static __inline__ int
   4.930 -SDL_GCD(int a, int b)
   4.931 -{
   4.932 -    int temp;
   4.933 -    while (b != 0) {
   4.934 -        temp = a % b;
   4.935 -        a = b;
   4.936 -        b = temp;
   4.937 -    }
   4.938 -    return a;
   4.939 -}
   4.940 -
   4.941 -/* Perform proper resampling. This is pretty slow but it's the best-sounding method. */
   4.942 -static void SDLCALL
   4.943 -SDL_Resample(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.944 -{
   4.945 -    int i;
   4.946 -
   4.947 -#ifdef DEBUG_CONVERT
   4.948 -    printf("Converting audio rate via proper resampling (mono)\n");
   4.949 +    div = hi / lo;
   4.950 +    retval = ((div == 2) || (div == 4)) ? div : 0;
   4.951  #endif
   4.952  
   4.953 -#define zerostuff_mono(type) { \
   4.954 -        const type *src = (const type *) (cvt->buf + cvt->len); \
   4.955 -        type *dst = (type *) (cvt->buf + (cvt->len * cvt->len_mult)); \
   4.956 -        for (i = cvt->len / sizeof (type); i; --i) { \
   4.957 -            src--; \
   4.958 -            dst[-1] = src[0]; \
   4.959 -            if (cvt->len_mult > 1) { \
   4.960 -                SDL_memset(dst-cvt->len_mult, 0, cvt->len_mult-1); \
   4.961 -            } \
   4.962 -            dst -= cvt->len_mult; \
   4.963 -        } \
   4.964 -    }
   4.965 +    return retval;
   4.966 +}
   4.967 +
   4.968 +static int
   4.969 +SDL_BuildAudioResampleCVT(SDL_AudioCVT * cvt, int dst_channels,
   4.970 +                          int src_rate, int dst_rate)
   4.971 +{
   4.972 +    if (src_rate != dst_rate) {
   4.973 +        SDL_AudioFilter filter = SDL_HandTunedResampleCVT(cvt, dst_channels,
   4.974 +                                                          src_rate, dst_rate);
   4.975 +
   4.976 +        /* No hand-tuned converter? Try the autogenerated ones. */
   4.977 +        if (filter == NULL) {
   4.978 +            int i;
   4.979 +            const int upsample = (src_rate < dst_rate) ? 1 : 0;
   4.980 +            const int multiple = SDL_FindFrequencyMultiple(src_rate, dst_rate);
   4.981  
   4.982 -#define discard_mono(type) { \
   4.983 -        const type *src = (const type *) (cvt->buf); \
   4.984 -        type *dst = (type *) (cvt->buf); \
   4.985 -        for (i = 0; i < (cvt->len_cvt / sizeof(type)) / cvt->len_div; ++i) { \
   4.986 -            dst[0] = src[0]; \
   4.987 -            src += cvt->len_div; \
   4.988 -            ++dst; \
   4.989 -        } \
   4.990 +            for (i = 0; sdl_audio_rate_filters[i].filter != NULL; i++) {
   4.991 +                const SDL_AudioRateFilters *filt = &sdl_audio_rate_filters[i];
   4.992 +                if ((filt->fmt == cvt->dst_format) &&
   4.993 +                    (filt->channels == dst_channels) &&
   4.994 +                    (filt->upsample == upsample) &&
   4.995 +                    (filt->multiple == multiple)) {
   4.996 +                    filter = filt->filter;
   4.997 +                    break;
   4.998 +                }
   4.999 +            }
  4.1000 +
  4.1001 +            if (filter == NULL) {
  4.1002 +                return -1;      /* Still no matching converter?! */
  4.1003 +            }
  4.1004 +        }
  4.1005 +
  4.1006 +        /* Update (cvt) with filter details... */
  4.1007 +        cvt->filters[cvt->filter_index++] = filter;
  4.1008 +        if (src_rate < dst_rate) {
  4.1009 +            const double mult = ((double) dst_rate) / ((double) src_rate);
  4.1010 +            cvt->len_mult *= (int) ceil(mult);  /* !!! FIXME: C runtime dependency. */
  4.1011 +            cvt->len_ratio *= mult;
  4.1012 +        } else {
  4.1013 +            cvt->len_ratio /= ((double) src_rate) / ((double) dst_rate);
  4.1014 +        }
  4.1015 +
  4.1016 +        return 1;               /* added a converter. */
  4.1017      }
  4.1018  
  4.1019 -    /* Step 1: Zero stuff the conversion buffer. This upsamples by a factor of len_mult,
  4.1020 -       creating aliasing at frequencies above the original nyquist frequency.
  4.1021 -     */
  4.1022 -#ifdef DEBUG_CONVERT
  4.1023 -    printf("Zero-stuffing by a factor of %u\n", cvt->len_mult);
  4.1024 -#endif
  4.1025 -    switch (SDL_AUDIO_BITSIZE(format)) {
  4.1026 -    case 8:
  4.1027 -        zerostuff_mono(Uint8);
  4.1028 -        break;
  4.1029 -    case 16:
  4.1030 -        zerostuff_mono(Uint16);
  4.1031 -        break;
  4.1032 -    case 32:
  4.1033 -        zerostuff_mono(Uint32);
  4.1034 -        break;
  4.1035 -    }
  4.1036 -
  4.1037 -    cvt->len_cvt *= cvt->len_mult;
  4.1038 -
  4.1039 -    /* Step 2: Use a windowed sinc FIR filter (lowpass filter) to remove the alias
  4.1040 -       frequencies. This is the slow part.
  4.1041 -     */
  4.1042 -    SDL_FilterFIR(cvt, format);
  4.1043 -
  4.1044 -    /* Step 3: Now downsample by discarding samples. */
  4.1045 -
  4.1046 -#ifdef DEBUG_CONVERT
  4.1047 -    printf("Discarding samples by a factor of %u\n", cvt->len_div);
  4.1048 -#endif
  4.1049 -    switch (SDL_AUDIO_BITSIZE(format)) {
  4.1050 -    case 8:
  4.1051 -        discard_mono(Uint8);
  4.1052 -        break;
  4.1053 -    case 16:
  4.1054 -        discard_mono(Uint16);
  4.1055 -        break;
  4.1056 -    case 32:
  4.1057 -        discard_mono(Uint32);
  4.1058 -        break;
  4.1059 -    }
  4.1060 -
  4.1061 -#undef zerostuff_mono
  4.1062 -#undef discard_mono
  4.1063 -
  4.1064 -    cvt->len_cvt /= cvt->len_div;
  4.1065 -
  4.1066 -    if (cvt->filters[++cvt->filter_index]) {
  4.1067 -        cvt->filters[cvt->filter_index] (cvt, format);
  4.1068 -    }
  4.1069 +    return 0;                   /* no conversion necessary. */
  4.1070  }
  4.1071  
  4.1072  
  4.1073 @@ -1826,6 +960,14 @@
  4.1074                    SDL_AudioFormat src_fmt, Uint8 src_channels, int src_rate,
  4.1075                    SDL_AudioFormat dst_fmt, Uint8 dst_channels, int dst_rate)
  4.1076  {
  4.1077 +    /*
  4.1078 +     * !!! FIXME: reorder filters based on which grow/shrink the buffer.
  4.1079 +     * !!! FIXME: ideally, we should do everything that shrinks the buffer
  4.1080 +     * !!! FIXME: first, so we don't have to process as many bytes in a given
  4.1081 +     * !!! FIXME: filter and abuse the CPU cache less. This might not be as
  4.1082 +     * !!! FIXME: good in practice as it sounds in theory, though.
  4.1083 +     */
  4.1084 +
  4.1085      /* there are no unsigned types over 16 bits, so catch this upfront. */
  4.1086      if ((SDL_AUDIO_BITSIZE(src_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(src_fmt))) {
  4.1087          return -1;
  4.1088 @@ -1833,6 +975,12 @@
  4.1089      if ((SDL_AUDIO_BITSIZE(dst_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(dst_fmt))) {
  4.1090          return -1;
  4.1091      }
  4.1092 +
  4.1093 +    /* prevent possible divisions by zero, etc. */
  4.1094 +    if ((src_rate == 0) || (dst_rate == 0)) {
  4.1095 +        return -1;
  4.1096 +    }
  4.1097 +
  4.1098  #ifdef DEBUG_CONVERT
  4.1099      printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
  4.1100             src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate);
  4.1101 @@ -1847,10 +995,12 @@
  4.1102      cvt->filters[0] = NULL;
  4.1103      cvt->len_mult = 1;
  4.1104      cvt->len_ratio = 1.0;
  4.1105 +    cvt->rate_incr = ((double) dst_rate) / ((double) src_rate);
  4.1106  
  4.1107      /* Convert data types, if necessary. Updates (cvt). */
  4.1108 -    if (SDL_BuildAudioTypeCVT(cvt, src_fmt, dst_fmt) == -1)
  4.1109 +    if (SDL_BuildAudioTypeCVT(cvt, src_fmt, dst_fmt) == -1) {
  4.1110          return -1;              /* shouldn't happen, but just in case... */
  4.1111 +    }
  4.1112  
  4.1113      /* Channel conversion */
  4.1114      if (src_channels != dst_channels) {
  4.1115 @@ -1903,100 +1053,11 @@
  4.1116          }
  4.1117      }
  4.1118  
  4.1119 -    /* Do rate conversion */
  4.1120 -    if (src_rate != dst_rate) {
  4.1121 -        int rate_gcd;
  4.1122 -        rate_gcd = SDL_GCD(src_rate, dst_rate);
  4.1123 -        cvt->len_mult = dst_rate / rate_gcd;
  4.1124 -        cvt->len_div = src_rate / rate_gcd;
  4.1125 -        cvt->len_ratio = (double) cvt->len_mult / (double) cvt->len_div;
  4.1126 -        cvt->filters[cvt->filter_index++] = SDL_Resample;
  4.1127 -        /* !!! FIXME: check return value. */
  4.1128 -        SDL_BuildWindowedSinc(cvt, dst_fmt, 768);
  4.1129 +    /* Do rate conversion, if necessary. Updates (cvt). */
  4.1130 +    if (SDL_BuildAudioResampleCVT(cvt, dst_channels, src_rate, dst_rate) == -1) {
  4.1131 +        return -1;              /* shouldn't happen, but just in case... */
  4.1132      }
  4.1133  
  4.1134 -/*
  4.1135 -    cvt->rate_incr = 0.0;
  4.1136 -    if ((src_rate / 100) != (dst_rate / 100)) {
  4.1137 -        Uint32 hi_rate, lo_rate;
  4.1138 -        int len_mult;
  4.1139 -        double len_ratio;
  4.1140 -        SDL_AudioFilter rate_cvt = NULL;
  4.1141 -
  4.1142 -        if (src_rate > dst_rate) {
  4.1143 -            hi_rate = src_rate;
  4.1144 -            lo_rate = dst_rate;
  4.1145 -            switch (src_channels) {
  4.1146 -            case 1:
  4.1147 -                rate_cvt = SDL_RateDIV2;
  4.1148 -                break;
  4.1149 -            case 2:
  4.1150 -                rate_cvt = SDL_RateDIV2_c2;
  4.1151 -                break;
  4.1152 -            case 4:
  4.1153 -                rate_cvt = SDL_RateDIV2_c4;
  4.1154 -                break;
  4.1155 -            case 6:
  4.1156 -                rate_cvt = SDL_RateDIV2_c6;
  4.1157 -                break;
  4.1158 -            default:
  4.1159 -                return -1;
  4.1160 -            }
  4.1161 -            len_mult = 1;
  4.1162 -            len_ratio = 0.5;
  4.1163 -        } else {
  4.1164 -            hi_rate = dst_rate;
  4.1165 -            lo_rate = src_rate;
  4.1166 -            switch (src_channels) {
  4.1167 -            case 1:
  4.1168 -                rate_cvt = SDL_RateMUL2;
  4.1169 -                break;
  4.1170 -            case 2:
  4.1171 -                rate_cvt = SDL_RateMUL2_c2;
  4.1172 -                break;
  4.1173 -            case 4:
  4.1174 -                rate_cvt = SDL_RateMUL2_c4;
  4.1175 -                break;
  4.1176 -            case 6:
  4.1177 -                rate_cvt = SDL_RateMUL2_c6;
  4.1178 -                break;
  4.1179 -            default:
  4.1180 -                return -1;
  4.1181 -            }
  4.1182 -            len_mult = 2;
  4.1183 -            len_ratio = 2.0;
  4.1184 -        }*/
  4.1185 -    /* If hi_rate = lo_rate*2^x then conversion is easy */
  4.1186 -    /*   while (((lo_rate * 2) / 100) <= (hi_rate / 100)) {
  4.1187 -       cvt->filters[cvt->filter_index++] = rate_cvt;
  4.1188 -       cvt->len_mult *= len_mult;
  4.1189 -       lo_rate *= 2;
  4.1190 -       cvt->len_ratio *= len_ratio;
  4.1191 -       } */
  4.1192 -    /* We may need a slow conversion here to finish up */
  4.1193 -    /*    if ((lo_rate / 100) != (hi_rate / 100)) {
  4.1194 -       #if 1 */
  4.1195 -    /* The problem with this is that if the input buffer is
  4.1196 -       say 1K, and the conversion rate is say 1.1, then the
  4.1197 -       output buffer is 1.1K, which may not be an acceptable
  4.1198 -       buffer size for the audio driver (not a power of 2)
  4.1199 -     */
  4.1200 -    /* For now, punt and hope the rate distortion isn't great.
  4.1201 -     */
  4.1202 -/*#else
  4.1203 -            if (src_rate < dst_rate) {
  4.1204 -                cvt->rate_incr = (double) lo_rate / hi_rate;
  4.1205 -                cvt->len_mult *= 2;
  4.1206 -                cvt->len_ratio /= cvt->rate_incr;
  4.1207 -            } else {
  4.1208 -                cvt->rate_incr = (double) hi_rate / lo_rate;
  4.1209 -                cvt->len_ratio *= cvt->rate_incr;
  4.1210 -            }
  4.1211 -            cvt->filters[cvt->filter_index++] = SDL_RateSLOW;
  4.1212 -#endif
  4.1213 -        }
  4.1214 -    }*/
  4.1215 -
  4.1216      /* Set up the filter information */
  4.1217      if (cvt->filter_index != 0) {
  4.1218          cvt->needed = 1;
  4.1219 @@ -2009,15 +1070,5 @@
  4.1220      return (cvt->needed);
  4.1221  }
  4.1222  
  4.1223 -#undef SDL_FixMpy8
  4.1224 -#undef SDL_FixMpy16
  4.1225 -#undef SDL_FixMpy32
  4.1226 -#undef SDL_FloatMpy
  4.1227 -#undef SDL_Make_1_7
  4.1228 -#undef SDL_Make_1_15
  4.1229 -#undef SDL_Make_1_31
  4.1230 -#undef SDL_Make_2_6
  4.1231 -#undef SDL_Make_2_14
  4.1232 -#undef SDL_Make_2_30
  4.1233  
  4.1234  /* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/audio/SDL_audiotypecvt.c	Sun Jan 11 04:46:14 2009 +0000
     5.2 +++ b/src/audio/SDL_audiotypecvt.c	Sun Jan 11 04:46:42 2009 +0000
     5.3 @@ -25,12 +25,37 @@
     5.4  #include "SDL_audio.h"
     5.5  #include "SDL_audio_c.h"
     5.6  
     5.7 +#ifndef DEBUG_CONVERT
     5.8 +#define DEBUG_CONVERT 0
     5.9 +#endif
    5.10 +
    5.11 +
    5.12 +/* If you can guarantee your data and need space, you can eliminate code... */
    5.13 +
    5.14 +/* Just build the arbitrary resamplers if you're saving code space. */
    5.15 +#ifndef LESS_RESAMPLERS
    5.16 +#define LESS_RESAMPLERS 0
    5.17 +#endif
    5.18 +
    5.19 +/* Don't build any resamplers if you're REALLY saving code space. */
    5.20 +#ifndef NO_RESAMPLERS
    5.21 +#define NO_RESAMPLERS 0
    5.22 +#endif
    5.23 +
    5.24 +/* Don't build any type converters if you're saving code space. */
    5.25 +#ifndef NO_CONVERTERS
    5.26 +#define NO_CONVERTERS 0
    5.27 +#endif
    5.28 +
    5.29 +
    5.30  /* *INDENT-OFF* */
    5.31  
    5.32  #define DIVBY127 0.0078740157480315f
    5.33  #define DIVBY32767 3.05185094759972e-05f
    5.34  #define DIVBY2147483647 4.6566128752458e-10f
    5.35  
    5.36 +#if !NO_CONVERTERS
    5.37 +
    5.38  static void SDLCALL
    5.39  SDL_Convert_U8_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    5.40  {
    5.41 @@ -2165,8 +2190,12 @@
    5.42      }
    5.43  }
    5.44  
    5.45 +#endif  /* !NO_CONVERTERS */
    5.46 +
    5.47 +
    5.48  const SDL_AudioTypeFilters sdl_audio_type_filters[] =
    5.49  {
    5.50 +#if !NO_CONVERTERS
    5.51      { AUDIO_U8, AUDIO_S8, SDL_Convert_U8_to_S8 },
    5.52      { AUDIO_U8, AUDIO_U16LSB, SDL_Convert_U8_to_U16LSB },
    5.53      { AUDIO_U8, AUDIO_S16LSB, SDL_Convert_U8_to_S16LSB },
    5.54 @@ -2257,9 +2286,13931 @@
    5.55      { AUDIO_F32MSB, AUDIO_S32LSB, SDL_Convert_F32MSB_to_S32LSB },
    5.56      { AUDIO_F32MSB, AUDIO_S32MSB, SDL_Convert_F32MSB_to_S32MSB },
    5.57      { AUDIO_F32MSB, AUDIO_F32LSB, SDL_Convert_F32MSB_to_F32LSB },
    5.58 +#endif  /* !NO_CONVERTERS */
    5.59 +    { 0, 0, NULL }
    5.60  };
    5.61  
    5.62  
    5.63 +#if !NO_RESAMPLERS
    5.64 +
    5.65 +static void SDLCALL
    5.66 +SDL_Upsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    5.67 +{
    5.68 +#ifdef DEBUG_CONVERT
    5.69 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 1 channels.\n", cvt->rate_incr);
    5.70 +#endif
    5.71 +
    5.72 +    const int srcsize = cvt->len_cvt - 16;
    5.73 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
    5.74 +    register int eps = 0;
    5.75 +    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1;
    5.76 +    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    5.77 +    const Uint8 *target = ((const Uint8 *) cvt->buf) - 1;
    5.78 +    Uint8 sample0 = src[0];
    5.79 +    Uint8 last_sample0 = sample0;
    5.80 +    while (dst != target) {
    5.81 +        dst[0] = sample0;
    5.82 +        dst--;
    5.83 +        eps += srcsize;
    5.84 +        if ((eps << 1) >= dstsize) {
    5.85 +            src--;
    5.86 +            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
    5.87 +            last_sample0 = sample0;
    5.88 +            eps -= dstsize;
    5.89 +        }
    5.90 +    }
    5.91 +    cvt->len_cvt = dstsize;
    5.92 +    if (cvt->filters[++cvt->filter_index]) {
    5.93 +        cvt->filters[cvt->filter_index] (cvt, format);
    5.94 +    }
    5.95 +}
    5.96 +
    5.97 +static void SDLCALL
    5.98 +SDL_Downsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    5.99 +{
   5.100 +#ifdef DEBUG_CONVERT
   5.101 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 1 channels.\n", cvt->rate_incr);
   5.102 +#endif
   5.103 +
   5.104 +    const int srcsize = cvt->len_cvt - 16;
   5.105 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.106 +    register int eps = 0;
   5.107 +    Uint8 *dst = (Uint8 *) cvt->buf;
   5.108 +    const Uint8 *src = (Uint8 *) cvt->buf;
   5.109 +    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   5.110 +    Uint8 sample0 = src[0];
   5.111 +    Uint8 last_sample0 = sample0;
   5.112 +    while (dst != target) {
   5.113 +        src++;
   5.114 +        eps += dstsize;
   5.115 +        if ((eps << 1) >= srcsize) {
   5.116 +            dst[0] = sample0;
   5.117 +            dst++;
   5.118 +            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   5.119 +            last_sample0 = sample0;
   5.120 +            eps -= srcsize;
   5.121 +        }
   5.122 +    }
   5.123 +    cvt->len_cvt = dstsize;
   5.124 +    if (cvt->filters[++cvt->filter_index]) {
   5.125 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.126 +    }
   5.127 +}
   5.128 +
   5.129 +static void SDLCALL
   5.130 +SDL_Upsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.131 +{
   5.132 +#ifdef DEBUG_CONVERT
   5.133 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 2 channels.\n", cvt->rate_incr);
   5.134 +#endif
   5.135 +
   5.136 +    const int srcsize = cvt->len_cvt - 32;
   5.137 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.138 +    register int eps = 0;
   5.139 +    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2;
   5.140 +    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
   5.141 +    const Uint8 *target = ((const Uint8 *) cvt->buf) - 2;
   5.142 +    Uint8 sample1 = src[1];
   5.143 +    Uint8 sample0 = src[0];
   5.144 +    Uint8 last_sample1 = sample1;
   5.145 +    Uint8 last_sample0 = sample0;
   5.146 +    while (dst != target) {
   5.147 +        dst[1] = sample1;
   5.148 +        dst[0] = sample0;
   5.149 +        dst -= 2;
   5.150 +        eps += srcsize;
   5.151 +        if ((eps << 1) >= dstsize) {
   5.152 +            src -= 2;
   5.153 +            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   5.154 +            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   5.155 +            last_sample1 = sample1;
   5.156 +            last_sample0 = sample0;
   5.157 +            eps -= dstsize;
   5.158 +        }
   5.159 +    }
   5.160 +    cvt->len_cvt = dstsize;
   5.161 +    if (cvt->filters[++cvt->filter_index]) {
   5.162 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.163 +    }
   5.164 +}
   5.165 +
   5.166 +static void SDLCALL
   5.167 +SDL_Downsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.168 +{
   5.169 +#ifdef DEBUG_CONVERT
   5.170 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 2 channels.\n", cvt->rate_incr);
   5.171 +#endif
   5.172 +
   5.173 +    const int srcsize = cvt->len_cvt - 32;
   5.174 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.175 +    register int eps = 0;
   5.176 +    Uint8 *dst = (Uint8 *) cvt->buf;
   5.177 +    const Uint8 *src = (Uint8 *) cvt->buf;
   5.178 +    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   5.179 +    Uint8 sample0 = src[0];
   5.180 +    Uint8 sample1 = src[1];
   5.181 +    Uint8 last_sample0 = sample0;
   5.182 +    Uint8 last_sample1 = sample1;
   5.183 +    while (dst != target) {
   5.184 +        src += 2;
   5.185 +        eps += dstsize;
   5.186 +        if ((eps << 1) >= srcsize) {
   5.187 +            dst[0] = sample0;
   5.188 +            dst[1] = sample1;
   5.189 +            dst += 2;
   5.190 +            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   5.191 +            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   5.192 +            last_sample0 = sample0;
   5.193 +            last_sample1 = sample1;
   5.194 +            eps -= srcsize;
   5.195 +        }
   5.196 +    }
   5.197 +    cvt->len_cvt = dstsize;
   5.198 +    if (cvt->filters[++cvt->filter_index]) {
   5.199 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.200 +    }
   5.201 +}
   5.202 +
   5.203 +static void SDLCALL
   5.204 +SDL_Upsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.205 +{
   5.206 +#ifdef DEBUG_CONVERT
   5.207 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 4 channels.\n", cvt->rate_incr);
   5.208 +#endif
   5.209 +
   5.210 +    const int srcsize = cvt->len_cvt - 64;
   5.211 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.212 +    register int eps = 0;
   5.213 +    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4;
   5.214 +    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
   5.215 +    const Uint8 *target = ((const Uint8 *) cvt->buf) - 4;
   5.216 +    Uint8 sample3 = src[3];
   5.217 +    Uint8 sample2 = src[2];
   5.218 +    Uint8 sample1 = src[1];
   5.219 +    Uint8 sample0 = src[0];
   5.220 +    Uint8 last_sample3 = sample3;
   5.221 +    Uint8 last_sample2 = sample2;
   5.222 +    Uint8 last_sample1 = sample1;
   5.223 +    Uint8 last_sample0 = sample0;
   5.224 +    while (dst != target) {
   5.225 +        dst[3] = sample3;
   5.226 +        dst[2] = sample2;
   5.227 +        dst[1] = sample1;
   5.228 +        dst[0] = sample0;
   5.229 +        dst -= 4;
   5.230 +        eps += srcsize;
   5.231 +        if ((eps << 1) >= dstsize) {
   5.232 +            src -= 4;
   5.233 +            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
   5.234 +            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
   5.235 +            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   5.236 +            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   5.237 +            last_sample3 = sample3;
   5.238 +            last_sample2 = sample2;
   5.239 +            last_sample1 = sample1;
   5.240 +            last_sample0 = sample0;
   5.241 +            eps -= dstsize;
   5.242 +        }
   5.243 +    }
   5.244 +    cvt->len_cvt = dstsize;
   5.245 +    if (cvt->filters[++cvt->filter_index]) {
   5.246 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.247 +    }
   5.248 +}
   5.249 +
   5.250 +static void SDLCALL
   5.251 +SDL_Downsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.252 +{
   5.253 +#ifdef DEBUG_CONVERT
   5.254 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 4 channels.\n", cvt->rate_incr);
   5.255 +#endif
   5.256 +
   5.257 +    const int srcsize = cvt->len_cvt - 64;
   5.258 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.259 +    register int eps = 0;
   5.260 +    Uint8 *dst = (Uint8 *) cvt->buf;
   5.261 +    const Uint8 *src = (Uint8 *) cvt->buf;
   5.262 +    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   5.263 +    Uint8 sample0 = src[0];
   5.264 +    Uint8 sample1 = src[1];
   5.265 +    Uint8 sample2 = src[2];
   5.266 +    Uint8 sample3 = src[3];
   5.267 +    Uint8 last_sample0 = sample0;
   5.268 +    Uint8 last_sample1 = sample1;
   5.269 +    Uint8 last_sample2 = sample2;
   5.270 +    Uint8 last_sample3 = sample3;
   5.271 +    while (dst != target) {
   5.272 +        src += 4;
   5.273 +        eps += dstsize;
   5.274 +        if ((eps << 1) >= srcsize) {
   5.275 +            dst[0] = sample0;
   5.276 +            dst[1] = sample1;
   5.277 +            dst[2] = sample2;
   5.278 +            dst[3] = sample3;
   5.279 +            dst += 4;
   5.280 +            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   5.281 +            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   5.282 +            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
   5.283 +            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
   5.284 +            last_sample0 = sample0;
   5.285 +            last_sample1 = sample1;
   5.286 +            last_sample2 = sample2;
   5.287 +            last_sample3 = sample3;
   5.288 +            eps -= srcsize;
   5.289 +        }
   5.290 +    }
   5.291 +    cvt->len_cvt = dstsize;
   5.292 +    if (cvt->filters[++cvt->filter_index]) {
   5.293 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.294 +    }
   5.295 +}
   5.296 +
   5.297 +static void SDLCALL
   5.298 +SDL_Upsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.299 +{
   5.300 +#ifdef DEBUG_CONVERT
   5.301 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 6 channels.\n", cvt->rate_incr);
   5.302 +#endif
   5.303 +
   5.304 +    const int srcsize = cvt->len_cvt - 96;
   5.305 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.306 +    register int eps = 0;
   5.307 +    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6;
   5.308 +    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
   5.309 +    const Uint8 *target = ((const Uint8 *) cvt->buf) - 6;
   5.310 +    Uint8 sample5 = src[5];
   5.311 +    Uint8 sample4 = src[4];
   5.312 +    Uint8 sample3 = src[3];
   5.313 +    Uint8 sample2 = src[2];
   5.314 +    Uint8 sample1 = src[1];
   5.315 +    Uint8 sample0 = src[0];
   5.316 +    Uint8 last_sample5 = sample5;
   5.317 +    Uint8 last_sample4 = sample4;
   5.318 +    Uint8 last_sample3 = sample3;
   5.319 +    Uint8 last_sample2 = sample2;
   5.320 +    Uint8 last_sample1 = sample1;
   5.321 +    Uint8 last_sample0 = sample0;
   5.322 +    while (dst != target) {
   5.323 +        dst[5] = sample5;
   5.324 +        dst[4] = sample4;
   5.325 +        dst[3] = sample3;
   5.326 +        dst[2] = sample2;
   5.327 +        dst[1] = sample1;
   5.328 +        dst[0] = sample0;
   5.329 +        dst -= 6;
   5.330 +        eps += srcsize;
   5.331 +        if ((eps << 1) >= dstsize) {
   5.332 +            src -= 6;
   5.333 +            sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
   5.334 +            sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
   5.335 +            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
   5.336 +            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
   5.337 +            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   5.338 +            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   5.339 +            last_sample5 = sample5;
   5.340 +            last_sample4 = sample4;
   5.341 +            last_sample3 = sample3;
   5.342 +            last_sample2 = sample2;
   5.343 +            last_sample1 = sample1;
   5.344 +            last_sample0 = sample0;
   5.345 +            eps -= dstsize;
   5.346 +        }
   5.347 +    }
   5.348 +    cvt->len_cvt = dstsize;
   5.349 +    if (cvt->filters[++cvt->filter_index]) {
   5.350 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.351 +    }
   5.352 +}
   5.353 +
   5.354 +static void SDLCALL
   5.355 +SDL_Downsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.356 +{
   5.357 +#ifdef DEBUG_CONVERT
   5.358 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 6 channels.\n", cvt->rate_incr);
   5.359 +#endif
   5.360 +
   5.361 +    const int srcsize = cvt->len_cvt - 96;
   5.362 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.363 +    register int eps = 0;
   5.364 +    Uint8 *dst = (Uint8 *) cvt->buf;
   5.365 +    const Uint8 *src = (Uint8 *) cvt->buf;
   5.366 +    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   5.367 +    Uint8 sample0 = src[0];
   5.368 +    Uint8 sample1 = src[1];
   5.369 +    Uint8 sample2 = src[2];
   5.370 +    Uint8 sample3 = src[3];
   5.371 +    Uint8 sample4 = src[4];
   5.372 +    Uint8 sample5 = src[5];
   5.373 +    Uint8 last_sample0 = sample0;
   5.374 +    Uint8 last_sample1 = sample1;
   5.375 +    Uint8 last_sample2 = sample2;
   5.376 +    Uint8 last_sample3 = sample3;
   5.377 +    Uint8 last_sample4 = sample4;
   5.378 +    Uint8 last_sample5 = sample5;
   5.379 +    while (dst != target) {
   5.380 +        src += 6;
   5.381 +        eps += dstsize;
   5.382 +        if ((eps << 1) >= srcsize) {
   5.383 +            dst[0] = sample0;
   5.384 +            dst[1] = sample1;
   5.385 +            dst[2] = sample2;
   5.386 +            dst[3] = sample3;
   5.387 +            dst[4] = sample4;
   5.388 +            dst[5] = sample5;
   5.389 +            dst += 6;
   5.390 +            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   5.391 +            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   5.392 +            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
   5.393 +            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
   5.394 +            sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
   5.395 +            sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
   5.396 +            last_sample0 = sample0;
   5.397 +            last_sample1 = sample1;
   5.398 +            last_sample2 = sample2;
   5.399 +            last_sample3 = sample3;
   5.400 +            last_sample4 = sample4;
   5.401 +            last_sample5 = sample5;
   5.402 +            eps -= srcsize;
   5.403 +        }
   5.404 +    }
   5.405 +    cvt->len_cvt = dstsize;
   5.406 +    if (cvt->filters[++cvt->filter_index]) {
   5.407 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.408 +    }
   5.409 +}
   5.410 +
   5.411 +static void SDLCALL
   5.412 +SDL_Upsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.413 +{
   5.414 +#ifdef DEBUG_CONVERT
   5.415 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 8 channels.\n", cvt->rate_incr);
   5.416 +#endif
   5.417 +
   5.418 +    const int srcsize = cvt->len_cvt - 128;
   5.419 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.420 +    register int eps = 0;
   5.421 +    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8;
   5.422 +    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
   5.423 +    const Uint8 *target = ((const Uint8 *) cvt->buf) - 8;
   5.424 +    Uint8 sample7 = src[7];
   5.425 +    Uint8 sample6 = src[6];
   5.426 +    Uint8 sample5 = src[5];
   5.427 +    Uint8 sample4 = src[4];
   5.428 +    Uint8 sample3 = src[3];
   5.429 +    Uint8 sample2 = src[2];
   5.430 +    Uint8 sample1 = src[1];
   5.431 +    Uint8 sample0 = src[0];
   5.432 +    Uint8 last_sample7 = sample7;
   5.433 +    Uint8 last_sample6 = sample6;
   5.434 +    Uint8 last_sample5 = sample5;
   5.435 +    Uint8 last_sample4 = sample4;
   5.436 +    Uint8 last_sample3 = sample3;
   5.437 +    Uint8 last_sample2 = sample2;
   5.438 +    Uint8 last_sample1 = sample1;
   5.439 +    Uint8 last_sample0 = sample0;
   5.440 +    while (dst != target) {
   5.441 +        dst[7] = sample7;
   5.442 +        dst[6] = sample6;
   5.443 +        dst[5] = sample5;
   5.444 +        dst[4] = sample4;
   5.445 +        dst[3] = sample3;
   5.446 +        dst[2] = sample2;
   5.447 +        dst[1] = sample1;
   5.448 +        dst[0] = sample0;
   5.449 +        dst -= 8;
   5.450 +        eps += srcsize;
   5.451 +        if ((eps << 1) >= dstsize) {
   5.452 +            src -= 8;
   5.453 +            sample7 = (Uint8) ((((Sint16) src[7]) + ((Sint16) last_sample7)) >> 1);
   5.454 +            sample6 = (Uint8) ((((Sint16) src[6]) + ((Sint16) last_sample6)) >> 1);
   5.455 +            sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
   5.456 +            sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
   5.457 +            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
   5.458 +            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
   5.459 +            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   5.460 +            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   5.461 +            last_sample7 = sample7;
   5.462 +            last_sample6 = sample6;
   5.463 +            last_sample5 = sample5;
   5.464 +            last_sample4 = sample4;
   5.465 +            last_sample3 = sample3;
   5.466 +            last_sample2 = sample2;
   5.467 +            last_sample1 = sample1;
   5.468 +            last_sample0 = sample0;
   5.469 +            eps -= dstsize;
   5.470 +        }
   5.471 +    }
   5.472 +    cvt->len_cvt = dstsize;
   5.473 +    if (cvt->filters[++cvt->filter_index]) {
   5.474 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.475 +    }
   5.476 +}
   5.477 +
   5.478 +static void SDLCALL
   5.479 +SDL_Downsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.480 +{
   5.481 +#ifdef DEBUG_CONVERT
   5.482 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 8 channels.\n", cvt->rate_incr);
   5.483 +#endif
   5.484 +
   5.485 +    const int srcsize = cvt->len_cvt - 128;
   5.486 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.487 +    register int eps = 0;
   5.488 +    Uint8 *dst = (Uint8 *) cvt->buf;
   5.489 +    const Uint8 *src = (Uint8 *) cvt->buf;
   5.490 +    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   5.491 +    Uint8 sample0 = src[0];
   5.492 +    Uint8 sample1 = src[1];
   5.493 +    Uint8 sample2 = src[2];
   5.494 +    Uint8 sample3 = src[3];
   5.495 +    Uint8 sample4 = src[4];
   5.496 +    Uint8 sample5 = src[5];
   5.497 +    Uint8 sample6 = src[6];
   5.498 +    Uint8 sample7 = src[7];
   5.499 +    Uint8 last_sample0 = sample0;
   5.500 +    Uint8 last_sample1 = sample1;
   5.501 +    Uint8 last_sample2 = sample2;
   5.502 +    Uint8 last_sample3 = sample3;
   5.503 +    Uint8 last_sample4 = sample4;
   5.504 +    Uint8 last_sample5 = sample5;
   5.505 +    Uint8 last_sample6 = sample6;
   5.506 +    Uint8 last_sample7 = sample7;
   5.507 +    while (dst != target) {
   5.508 +        src += 8;
   5.509 +        eps += dstsize;
   5.510 +        if ((eps << 1) >= srcsize) {
   5.511 +            dst[0] = sample0;
   5.512 +            dst[1] = sample1;
   5.513 +            dst[2] = sample2;
   5.514 +            dst[3] = sample3;
   5.515 +            dst[4] = sample4;
   5.516 +            dst[5] = sample5;
   5.517 +            dst[6] = sample6;
   5.518 +            dst[7] = sample7;
   5.519 +            dst += 8;
   5.520 +            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   5.521 +            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   5.522 +            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
   5.523 +            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
   5.524 +            sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
   5.525 +            sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
   5.526 +            sample6 = (Uint8) ((((Sint16) src[6]) + ((Sint16) last_sample6)) >> 1);
   5.527 +            sample7 = (Uint8) ((((Sint16) src[7]) + ((Sint16) last_sample7)) >> 1);
   5.528 +            last_sample0 = sample0;
   5.529 +            last_sample1 = sample1;
   5.530 +            last_sample2 = sample2;
   5.531 +            last_sample3 = sample3;
   5.532 +            last_sample4 = sample4;
   5.533 +            last_sample5 = sample5;
   5.534 +            last_sample6 = sample6;
   5.535 +            last_sample7 = sample7;
   5.536 +            eps -= srcsize;
   5.537 +        }
   5.538 +    }
   5.539 +    cvt->len_cvt = dstsize;
   5.540 +    if (cvt->filters[++cvt->filter_index]) {
   5.541 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.542 +    }
   5.543 +}
   5.544 +
   5.545 +static void SDLCALL
   5.546 +SDL_Upsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.547 +{
   5.548 +#ifdef DEBUG_CONVERT
   5.549 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 1 channels.\n", cvt->rate_incr);
   5.550 +#endif
   5.551 +
   5.552 +    const int srcsize = cvt->len_cvt - 16;
   5.553 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.554 +    register int eps = 0;
   5.555 +    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1;
   5.556 +    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   5.557 +    const Sint8 *target = ((const Sint8 *) cvt->buf) - 1;
   5.558 +    Sint8 sample0 = ((Sint8) src[0]);
   5.559 +    Sint8 last_sample0 = sample0;
   5.560 +    while (dst != target) {
   5.561 +        dst[0] = ((Sint8) sample0);
   5.562 +        dst--;
   5.563 +        eps += srcsize;
   5.564 +        if ((eps << 1) >= dstsize) {
   5.565 +            src--;
   5.566 +            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   5.567 +            last_sample0 = sample0;
   5.568 +            eps -= dstsize;
   5.569 +        }
   5.570 +    }
   5.571 +    cvt->len_cvt = dstsize;
   5.572 +    if (cvt->filters[++cvt->filter_index]) {
   5.573 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.574 +    }
   5.575 +}
   5.576 +
   5.577 +static void SDLCALL
   5.578 +SDL_Downsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.579 +{
   5.580 +#ifdef DEBUG_CONVERT
   5.581 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 1 channels.\n", cvt->rate_incr);
   5.582 +#endif
   5.583 +
   5.584 +    const int srcsize = cvt->len_cvt - 16;
   5.585 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.586 +    register int eps = 0;
   5.587 +    Sint8 *dst = (Sint8 *) cvt->buf;
   5.588 +    const Sint8 *src = (Sint8 *) cvt->buf;
   5.589 +    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   5.590 +    Sint8 sample0 = ((Sint8) src[0]);
   5.591 +    Sint8 last_sample0 = sample0;
   5.592 +    while (dst != target) {
   5.593 +        src++;
   5.594 +        eps += dstsize;
   5.595 +        if ((eps << 1) >= srcsize) {
   5.596 +            dst[0] = ((Sint8) sample0);
   5.597 +            dst++;
   5.598 +            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   5.599 +            last_sample0 = sample0;
   5.600 +            eps -= srcsize;
   5.601 +        }
   5.602 +    }
   5.603 +    cvt->len_cvt = dstsize;
   5.604 +    if (cvt->filters[++cvt->filter_index]) {
   5.605 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.606 +    }
   5.607 +}
   5.608 +
   5.609 +static void SDLCALL
   5.610 +SDL_Upsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.611 +{
   5.612 +#ifdef DEBUG_CONVERT
   5.613 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 2 channels.\n", cvt->rate_incr);
   5.614 +#endif
   5.615 +
   5.616 +    const int srcsize = cvt->len_cvt - 32;
   5.617 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.618 +    register int eps = 0;
   5.619 +    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2;
   5.620 +    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
   5.621 +    const Sint8 *target = ((const Sint8 *) cvt->buf) - 2;
   5.622 +    Sint8 sample1 = ((Sint8) src[1]);
   5.623 +    Sint8 sample0 = ((Sint8) src[0]);
   5.624 +    Sint8 last_sample1 = sample1;
   5.625 +    Sint8 last_sample0 = sample0;
   5.626 +    while (dst != target) {
   5.627 +        dst[1] = ((Sint8) sample1);
   5.628 +        dst[0] = ((Sint8) sample0);
   5.629 +        dst -= 2;
   5.630 +        eps += srcsize;
   5.631 +        if ((eps << 1) >= dstsize) {
   5.632 +            src -= 2;
   5.633 +            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
   5.634 +            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   5.635 +            last_sample1 = sample1;
   5.636 +            last_sample0 = sample0;
   5.637 +            eps -= dstsize;
   5.638 +        }
   5.639 +    }
   5.640 +    cvt->len_cvt = dstsize;
   5.641 +    if (cvt->filters[++cvt->filter_index]) {
   5.642 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.643 +    }
   5.644 +}
   5.645 +
   5.646 +static void SDLCALL
   5.647 +SDL_Downsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.648 +{
   5.649 +#ifdef DEBUG_CONVERT
   5.650 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 2 channels.\n", cvt->rate_incr);
   5.651 +#endif
   5.652 +
   5.653 +    const int srcsize = cvt->len_cvt - 32;
   5.654 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.655 +    register int eps = 0;
   5.656 +    Sint8 *dst = (Sint8 *) cvt->buf;
   5.657 +    const Sint8 *src = (Sint8 *) cvt->buf;
   5.658 +    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   5.659 +    Sint8 sample0 = ((Sint8) src[0]);
   5.660 +    Sint8 sample1 = ((Sint8) src[1]);
   5.661 +    Sint8 last_sample0 = sample0;
   5.662 +    Sint8 last_sample1 = sample1;
   5.663 +    while (dst != target) {
   5.664 +        src += 2;
   5.665 +        eps += dstsize;
   5.666 +        if ((eps << 1) >= srcsize) {
   5.667 +            dst[0] = ((Sint8) sample0);
   5.668 +            dst[1] = ((Sint8) sample1);
   5.669 +            dst += 2;
   5.670 +            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   5.671 +            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
   5.672 +            last_sample0 = sample0;
   5.673 +            last_sample1 = sample1;
   5.674 +            eps -= srcsize;
   5.675 +        }
   5.676 +    }
   5.677 +    cvt->len_cvt = dstsize;
   5.678 +    if (cvt->filters[++cvt->filter_index]) {
   5.679 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.680 +    }
   5.681 +}
   5.682 +
   5.683 +static void SDLCALL
   5.684 +SDL_Upsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.685 +{
   5.686 +#ifdef DEBUG_CONVERT
   5.687 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 4 channels.\n", cvt->rate_incr);
   5.688 +#endif
   5.689 +
   5.690 +    const int srcsize = cvt->len_cvt - 64;
   5.691 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.692 +    register int eps = 0;
   5.693 +    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4;
   5.694 +    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
   5.695 +    const Sint8 *target = ((const Sint8 *) cvt->buf) - 4;
   5.696 +    Sint8 sample3 = ((Sint8) src[3]);
   5.697 +    Sint8 sample2 = ((Sint8) src[2]);
   5.698 +    Sint8 sample1 = ((Sint8) src[1]);
   5.699 +    Sint8 sample0 = ((Sint8) src[0]);
   5.700 +    Sint8 last_sample3 = sample3;
   5.701 +    Sint8 last_sample2 = sample2;
   5.702 +    Sint8 last_sample1 = sample1;
   5.703 +    Sint8 last_sample0 = sample0;
   5.704 +    while (dst != target) {
   5.705 +        dst[3] = ((Sint8) sample3);
   5.706 +        dst[2] = ((Sint8) sample2);
   5.707 +        dst[1] = ((Sint8) sample1);
   5.708 +        dst[0] = ((Sint8) sample0);
   5.709 +        dst -= 4;
   5.710 +        eps += srcsize;
   5.711 +        if ((eps << 1) >= dstsize) {
   5.712 +            src -= 4;
   5.713 +            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
   5.714 +            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
   5.715 +            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
   5.716 +            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   5.717 +            last_sample3 = sample3;
   5.718 +            last_sample2 = sample2;
   5.719 +            last_sample1 = sample1;
   5.720 +            last_sample0 = sample0;
   5.721 +            eps -= dstsize;
   5.722 +        }
   5.723 +    }
   5.724 +    cvt->len_cvt = dstsize;
   5.725 +    if (cvt->filters[++cvt->filter_index]) {
   5.726 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.727 +    }
   5.728 +}
   5.729 +
   5.730 +static void SDLCALL
   5.731 +SDL_Downsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.732 +{
   5.733 +#ifdef DEBUG_CONVERT
   5.734 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 4 channels.\n", cvt->rate_incr);
   5.735 +#endif
   5.736 +
   5.737 +    const int srcsize = cvt->len_cvt - 64;
   5.738 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.739 +    register int eps = 0;
   5.740 +    Sint8 *dst = (Sint8 *) cvt->buf;
   5.741 +    const Sint8 *src = (Sint8 *) cvt->buf;
   5.742 +    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   5.743 +    Sint8 sample0 = ((Sint8) src[0]);
   5.744 +    Sint8 sample1 = ((Sint8) src[1]);
   5.745 +    Sint8 sample2 = ((Sint8) src[2]);
   5.746 +    Sint8 sample3 = ((Sint8) src[3]);
   5.747 +    Sint8 last_sample0 = sample0;
   5.748 +    Sint8 last_sample1 = sample1;
   5.749 +    Sint8 last_sample2 = sample2;
   5.750 +    Sint8 last_sample3 = sample3;
   5.751 +    while (dst != target) {
   5.752 +        src += 4;
   5.753 +        eps += dstsize;
   5.754 +        if ((eps << 1) >= srcsize) {
   5.755 +            dst[0] = ((Sint8) sample0);
   5.756 +            dst[1] = ((Sint8) sample1);
   5.757 +            dst[2] = ((Sint8) sample2);
   5.758 +            dst[3] = ((Sint8) sample3);
   5.759 +            dst += 4;
   5.760 +            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   5.761 +            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
   5.762 +            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
   5.763 +            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
   5.764 +            last_sample0 = sample0;
   5.765 +            last_sample1 = sample1;
   5.766 +            last_sample2 = sample2;
   5.767 +            last_sample3 = sample3;
   5.768 +            eps -= srcsize;
   5.769 +        }
   5.770 +    }
   5.771 +    cvt->len_cvt = dstsize;
   5.772 +    if (cvt->filters[++cvt->filter_index]) {
   5.773 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.774 +    }
   5.775 +}
   5.776 +
   5.777 +static void SDLCALL
   5.778 +SDL_Upsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.779 +{
   5.780 +#ifdef DEBUG_CONVERT
   5.781 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 6 channels.\n", cvt->rate_incr);
   5.782 +#endif
   5.783 +
   5.784 +    const int srcsize = cvt->len_cvt - 96;
   5.785 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.786 +    register int eps = 0;
   5.787 +    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6;
   5.788 +    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
   5.789 +    const Sint8 *target = ((const Sint8 *) cvt->buf) - 6;
   5.790 +    Sint8 sample5 = ((Sint8) src[5]);
   5.791 +    Sint8 sample4 = ((Sint8) src[4]);
   5.792 +    Sint8 sample3 = ((Sint8) src[3]);
   5.793 +    Sint8 sample2 = ((Sint8) src[2]);
   5.794 +    Sint8 sample1 = ((Sint8) src[1]);
   5.795 +    Sint8 sample0 = ((Sint8) src[0]);
   5.796 +    Sint8 last_sample5 = sample5;
   5.797 +    Sint8 last_sample4 = sample4;
   5.798 +    Sint8 last_sample3 = sample3;
   5.799 +    Sint8 last_sample2 = sample2;
   5.800 +    Sint8 last_sample1 = sample1;
   5.801 +    Sint8 last_sample0 = sample0;
   5.802 +    while (dst != target) {
   5.803 +        dst[5] = ((Sint8) sample5);
   5.804 +        dst[4] = ((Sint8) sample4);
   5.805 +        dst[3] = ((Sint8) sample3);
   5.806 +        dst[2] = ((Sint8) sample2);
   5.807 +        dst[1] = ((Sint8) sample1);
   5.808 +        dst[0] = ((Sint8) sample0);
   5.809 +        dst -= 6;
   5.810 +        eps += srcsize;
   5.811 +        if ((eps << 1) >= dstsize) {
   5.812 +            src -= 6;
   5.813 +            sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
   5.814 +            sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
   5.815 +            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
   5.816 +            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
   5.817 +            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
   5.818 +            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   5.819 +            last_sample5 = sample5;
   5.820 +            last_sample4 = sample4;
   5.821 +            last_sample3 = sample3;
   5.822 +            last_sample2 = sample2;
   5.823 +            last_sample1 = sample1;
   5.824 +            last_sample0 = sample0;
   5.825 +            eps -= dstsize;
   5.826 +        }
   5.827 +    }
   5.828 +    cvt->len_cvt = dstsize;
   5.829 +    if (cvt->filters[++cvt->filter_index]) {
   5.830 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.831 +    }
   5.832 +}
   5.833 +
   5.834 +static void SDLCALL
   5.835 +SDL_Downsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.836 +{
   5.837 +#ifdef DEBUG_CONVERT
   5.838 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 6 channels.\n", cvt->rate_incr);
   5.839 +#endif
   5.840 +
   5.841 +    const int srcsize = cvt->len_cvt - 96;
   5.842 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.843 +    register int eps = 0;
   5.844 +    Sint8 *dst = (Sint8 *) cvt->buf;
   5.845 +    const Sint8 *src = (Sint8 *) cvt->buf;
   5.846 +    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   5.847 +    Sint8 sample0 = ((Sint8) src[0]);
   5.848 +    Sint8 sample1 = ((Sint8) src[1]);
   5.849 +    Sint8 sample2 = ((Sint8) src[2]);
   5.850 +    Sint8 sample3 = ((Sint8) src[3]);
   5.851 +    Sint8 sample4 = ((Sint8) src[4]);
   5.852 +    Sint8 sample5 = ((Sint8) src[5]);
   5.853 +    Sint8 last_sample0 = sample0;
   5.854 +    Sint8 last_sample1 = sample1;
   5.855 +    Sint8 last_sample2 = sample2;
   5.856 +    Sint8 last_sample3 = sample3;
   5.857 +    Sint8 last_sample4 = sample4;
   5.858 +    Sint8 last_sample5 = sample5;
   5.859 +    while (dst != target) {
   5.860 +        src += 6;
   5.861 +        eps += dstsize;
   5.862 +        if ((eps << 1) >= srcsize) {
   5.863 +            dst[0] = ((Sint8) sample0);
   5.864 +            dst[1] = ((Sint8) sample1);
   5.865 +            dst[2] = ((Sint8) sample2);
   5.866 +            dst[3] = ((Sint8) sample3);
   5.867 +            dst[4] = ((Sint8) sample4);
   5.868 +            dst[5] = ((Sint8) sample5);
   5.869 +            dst += 6;
   5.870 +            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   5.871 +            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
   5.872 +            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
   5.873 +            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
   5.874 +            sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
   5.875 +            sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
   5.876 +            last_sample0 = sample0;
   5.877 +            last_sample1 = sample1;
   5.878 +            last_sample2 = sample2;
   5.879 +            last_sample3 = sample3;
   5.880 +            last_sample4 = sample4;
   5.881 +            last_sample5 = sample5;
   5.882 +            eps -= srcsize;
   5.883 +        }
   5.884 +    }
   5.885 +    cvt->len_cvt = dstsize;
   5.886 +    if (cvt->filters[++cvt->filter_index]) {
   5.887 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.888 +    }
   5.889 +}
   5.890 +
   5.891 +static void SDLCALL
   5.892 +SDL_Upsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.893 +{
   5.894 +#ifdef DEBUG_CONVERT
   5.895 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 8 channels.\n", cvt->rate_incr);
   5.896 +#endif
   5.897 +
   5.898 +    const int srcsize = cvt->len_cvt - 128;
   5.899 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.900 +    register int eps = 0;
   5.901 +    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8;
   5.902 +    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
   5.903 +    const Sint8 *target = ((const Sint8 *) cvt->buf) - 8;
   5.904 +    Sint8 sample7 = ((Sint8) src[7]);
   5.905 +    Sint8 sample6 = ((Sint8) src[6]);
   5.906 +    Sint8 sample5 = ((Sint8) src[5]);
   5.907 +    Sint8 sample4 = ((Sint8) src[4]);
   5.908 +    Sint8 sample3 = ((Sint8) src[3]);
   5.909 +    Sint8 sample2 = ((Sint8) src[2]);
   5.910 +    Sint8 sample1 = ((Sint8) src[1]);
   5.911 +    Sint8 sample0 = ((Sint8) src[0]);
   5.912 +    Sint8 last_sample7 = sample7;
   5.913 +    Sint8 last_sample6 = sample6;
   5.914 +    Sint8 last_sample5 = sample5;
   5.915 +    Sint8 last_sample4 = sample4;
   5.916 +    Sint8 last_sample3 = sample3;
   5.917 +    Sint8 last_sample2 = sample2;
   5.918 +    Sint8 last_sample1 = sample1;
   5.919 +    Sint8 last_sample0 = sample0;
   5.920 +    while (dst != target) {
   5.921 +        dst[7] = ((Sint8) sample7);
   5.922 +        dst[6] = ((Sint8) sample6);
   5.923 +        dst[5] = ((Sint8) sample5);
   5.924 +        dst[4] = ((Sint8) sample4);
   5.925 +        dst[3] = ((Sint8) sample3);
   5.926 +        dst[2] = ((Sint8) sample2);
   5.927 +        dst[1] = ((Sint8) sample1);
   5.928 +        dst[0] = ((Sint8) sample0);
   5.929 +        dst -= 8;
   5.930 +        eps += srcsize;
   5.931 +        if ((eps << 1) >= dstsize) {
   5.932 +            src -= 8;
   5.933 +            sample7 = (Sint8) ((((Sint16) ((Sint8) src[7])) + ((Sint16) last_sample7)) >> 1);
   5.934 +            sample6 = (Sint8) ((((Sint16) ((Sint8) src[6])) + ((Sint16) last_sample6)) >> 1);
   5.935 +            sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
   5.936 +            sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
   5.937 +            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
   5.938 +            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
   5.939 +            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
   5.940 +            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   5.941 +            last_sample7 = sample7;
   5.942 +            last_sample6 = sample6;
   5.943 +            last_sample5 = sample5;
   5.944 +            last_sample4 = sample4;
   5.945 +            last_sample3 = sample3;
   5.946 +            last_sample2 = sample2;
   5.947 +            last_sample1 = sample1;
   5.948 +            last_sample0 = sample0;
   5.949 +            eps -= dstsize;
   5.950 +        }
   5.951 +    }
   5.952 +    cvt->len_cvt = dstsize;
   5.953 +    if (cvt->filters[++cvt->filter_index]) {
   5.954 +        cvt->filters[cvt->filter_index] (cvt, format);
   5.955 +    }
   5.956 +}
   5.957 +
   5.958 +static void SDLCALL
   5.959 +SDL_Downsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5.960 +{
   5.961 +#ifdef DEBUG_CONVERT
   5.962 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 8 channels.\n", cvt->rate_incr);
   5.963 +#endif
   5.964 +
   5.965 +    const int srcsize = cvt->len_cvt - 128;
   5.966 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
   5.967 +    register int eps = 0;
   5.968 +    Sint8 *dst = (Sint8 *) cvt->buf;
   5.969 +    const Sint8 *src = (Sint8 *) cvt->buf;
   5.970 +    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   5.971 +    Sint8 sample0 = ((Sint8) src[0]);
   5.972 +    Sint8 sample1 = ((Sint8) src[1]);
   5.973 +    Sint8 sample2 = ((Sint8) src[2]);
   5.974 +    Sint8 sample3 = ((Sint8) src[3]);
   5.975 +    Sint8 sample4 = ((Sint8) src[4]);
   5.976 +    Sint8 sample5 = ((Sint8) src[5]);
   5.977 +    Sint8 sample6 = ((Sint8) src[6]);
   5.978 +    Sint8 sample7 = ((Sint8) src[7]);
   5.979 +    Sint8 last_sample0 = sample0;
   5.980 +    Sint8 last_sample1 = sample1;
   5.981 +    Sint8 last_sample2 = sample2;
   5.982 +    Sint8 last_sample3 = sample3;
   5.983 +    Sint8 last_sample4 = sample4;
   5.984 +    Sint8 last_sample5 = sample5;
   5.985 +    Sint8 last_sample6 = sample6;
   5.986 +    Sint8 last_sample7 = sample7;
   5.987 +    while (dst != target) {
   5.988 +        src += 8;
   5.989 +        eps += dstsize;
   5.990 +        if ((eps << 1) >= srcsize) {
   5.991 +            dst[0] = ((Sint8) sample0);
   5.992 +            dst[1] = ((Sint8) sample1);
   5.993 +            dst[2] = ((Sint8) sample2);
   5.994 +            dst[3] = ((Sint8) sample3);
   5.995 +            dst[4] = ((Sint8) sample4);
   5.996 +            dst[5] = ((Sint8) sample5);
   5.997 +            dst[6] = ((Sint8) sample6);
   5.998 +            dst[7] = ((Sint8) sample7);
   5.999 +            dst += 8;
  5.1000 +            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
  5.1001 +            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
  5.1002 +            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
  5.1003 +            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
  5.1004 +            sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
  5.1005 +            sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
  5.1006 +            sample6 = (Sint8) ((((Sint16) ((Sint8) src[6])) + ((Sint16) last_sample6)) >> 1);
  5.1007 +            sample7 = (Sint8) ((((Sint16) ((Sint8) src[7])) + ((Sint16) last_sample7)) >> 1);
  5.1008 +            last_sample0 = sample0;
  5.1009 +            last_sample1 = sample1;
  5.1010 +            last_sample2 = sample2;
  5.1011 +            last_sample3 = sample3;
  5.1012 +            last_sample4 = sample4;
  5.1013 +            last_sample5 = sample5;
  5.1014 +            last_sample6 = sample6;
  5.1015 +            last_sample7 = sample7;
  5.1016 +            eps -= srcsize;
  5.1017 +        }
  5.1018 +    }
  5.1019 +    cvt->len_cvt = dstsize;
  5.1020 +    if (cvt->filters[++cvt->filter_index]) {
  5.1021 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1022 +    }
  5.1023 +}
  5.1024 +
  5.1025 +static void SDLCALL
  5.1026 +SDL_Upsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1027 +{
  5.1028 +#ifdef DEBUG_CONVERT
  5.1029 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 1 channels.\n", cvt->rate_incr);
  5.1030 +#endif
  5.1031 +
  5.1032 +    const int srcsize = cvt->len_cvt - 32;
  5.1033 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1034 +    register int eps = 0;
  5.1035 +    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
  5.1036 +    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  5.1037 +    const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
  5.1038 +    Uint16 sample0 = SDL_SwapLE16(src[0]);
  5.1039 +    Uint16 last_sample0 = sample0;
  5.1040 +    while (dst != target) {
  5.1041 +        dst[0] = SDL_SwapLE16(sample0);
  5.1042 +        dst--;
  5.1043 +        eps += srcsize;
  5.1044 +        if ((eps << 1) >= dstsize) {
  5.1045 +            src--;
  5.1046 +            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.1047 +            last_sample0 = sample0;
  5.1048 +            eps -= dstsize;
  5.1049 +        }
  5.1050 +    }
  5.1051 +    cvt->len_cvt = dstsize;
  5.1052 +    if (cvt->filters[++cvt->filter_index]) {
  5.1053 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1054 +    }
  5.1055 +}
  5.1056 +
  5.1057 +static void SDLCALL
  5.1058 +SDL_Downsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1059 +{
  5.1060 +#ifdef DEBUG_CONVERT
  5.1061 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 1 channels.\n", cvt->rate_incr);
  5.1062 +#endif
  5.1063 +
  5.1064 +    const int srcsize = cvt->len_cvt - 32;
  5.1065 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1066 +    register int eps = 0;
  5.1067 +    Uint16 *dst = (Uint16 *) cvt->buf;
  5.1068 +    const Uint16 *src = (Uint16 *) cvt->buf;
  5.1069 +    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  5.1070 +    Uint16 sample0 = SDL_SwapLE16(src[0]);
  5.1071 +    Uint16 last_sample0 = sample0;
  5.1072 +    while (dst != target) {
  5.1073 +        src++;
  5.1074 +        eps += dstsize;
  5.1075 +        if ((eps << 1) >= srcsize) {
  5.1076 +            dst[0] = SDL_SwapLE16(sample0);
  5.1077 +            dst++;
  5.1078 +            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.1079 +            last_sample0 = sample0;
  5.1080 +            eps -= srcsize;
  5.1081 +        }
  5.1082 +    }
  5.1083 +    cvt->len_cvt = dstsize;
  5.1084 +    if (cvt->filters[++cvt->filter_index]) {
  5.1085 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1086 +    }
  5.1087 +}
  5.1088 +
  5.1089 +static void SDLCALL
  5.1090 +SDL_Upsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1091 +{
  5.1092 +#ifdef DEBUG_CONVERT
  5.1093 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 2 channels.\n", cvt->rate_incr);
  5.1094 +#endif
  5.1095 +
  5.1096 +    const int srcsize = cvt->len_cvt - 64;
  5.1097 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1098 +    register int eps = 0;
  5.1099 +    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
  5.1100 +    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
  5.1101 +    const Uint16 *target = ((const Uint16 *) cvt->buf) - 2;
  5.1102 +    Uint16 sample1 = SDL_SwapLE16(src[1]);
  5.1103 +    Uint16 sample0 = SDL_SwapLE16(src[0]);
  5.1104 +    Uint16 last_sample1 = sample1;
  5.1105 +    Uint16 last_sample0 = sample0;
  5.1106 +    while (dst != target) {
  5.1107 +        dst[1] = SDL_SwapLE16(sample1);
  5.1108 +        dst[0] = SDL_SwapLE16(sample0);
  5.1109 +        dst -= 2;
  5.1110 +        eps += srcsize;
  5.1111 +        if ((eps << 1) >= dstsize) {
  5.1112 +            src -= 2;
  5.1113 +            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.1114 +            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.1115 +            last_sample1 = sample1;
  5.1116 +            last_sample0 = sample0;
  5.1117 +            eps -= dstsize;
  5.1118 +        }
  5.1119 +    }
  5.1120 +    cvt->len_cvt = dstsize;
  5.1121 +    if (cvt->filters[++cvt->filter_index]) {
  5.1122 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1123 +    }
  5.1124 +}
  5.1125 +
  5.1126 +static void SDLCALL
  5.1127 +SDL_Downsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1128 +{
  5.1129 +#ifdef DEBUG_CONVERT
  5.1130 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 2 channels.\n", cvt->rate_incr);
  5.1131 +#endif
  5.1132 +
  5.1133 +    const int srcsize = cvt->len_cvt - 64;
  5.1134 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1135 +    register int eps = 0;
  5.1136 +    Uint16 *dst = (Uint16 *) cvt->buf;
  5.1137 +    const Uint16 *src = (Uint16 *) cvt->buf;
  5.1138 +    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  5.1139 +    Uint16 sample0 = SDL_SwapLE16(src[0]);
  5.1140 +    Uint16 sample1 = SDL_SwapLE16(src[1]);
  5.1141 +    Uint16 last_sample0 = sample0;
  5.1142 +    Uint16 last_sample1 = sample1;
  5.1143 +    while (dst != target) {
  5.1144 +        src += 2;
  5.1145 +        eps += dstsize;
  5.1146 +        if ((eps << 1) >= srcsize) {
  5.1147 +            dst[0] = SDL_SwapLE16(sample0);
  5.1148 +            dst[1] = SDL_SwapLE16(sample1);
  5.1149 +            dst += 2;
  5.1150 +            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.1151 +            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.1152 +            last_sample0 = sample0;
  5.1153 +            last_sample1 = sample1;
  5.1154 +            eps -= srcsize;
  5.1155 +        }
  5.1156 +    }
  5.1157 +    cvt->len_cvt = dstsize;
  5.1158 +    if (cvt->filters[++cvt->filter_index]) {
  5.1159 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1160 +    }
  5.1161 +}
  5.1162 +
  5.1163 +static void SDLCALL
  5.1164 +SDL_Upsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1165 +{
  5.1166 +#ifdef DEBUG_CONVERT
  5.1167 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 4 channels.\n", cvt->rate_incr);
  5.1168 +#endif
  5.1169 +
  5.1170 +    const int srcsize = cvt->len_cvt - 128;
  5.1171 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1172 +    register int eps = 0;
  5.1173 +    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
  5.1174 +    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
  5.1175 +    const Uint16 *target = ((const Uint16 *) cvt->buf) - 4;
  5.1176 +    Uint16 sample3 = SDL_SwapLE16(src[3]);
  5.1177 +    Uint16 sample2 = SDL_SwapLE16(src[2]);
  5.1178 +    Uint16 sample1 = SDL_SwapLE16(src[1]);
  5.1179 +    Uint16 sample0 = SDL_SwapLE16(src[0]);
  5.1180 +    Uint16 last_sample3 = sample3;
  5.1181 +    Uint16 last_sample2 = sample2;
  5.1182 +    Uint16 last_sample1 = sample1;
  5.1183 +    Uint16 last_sample0 = sample0;
  5.1184 +    while (dst != target) {
  5.1185 +        dst[3] = SDL_SwapLE16(sample3);
  5.1186 +        dst[2] = SDL_SwapLE16(sample2);
  5.1187 +        dst[1] = SDL_SwapLE16(sample1);
  5.1188 +        dst[0] = SDL_SwapLE16(sample0);
  5.1189 +        dst -= 4;
  5.1190 +        eps += srcsize;
  5.1191 +        if ((eps << 1) >= dstsize) {
  5.1192 +            src -= 4;
  5.1193 +            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  5.1194 +            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  5.1195 +            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.1196 +            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.1197 +            last_sample3 = sample3;
  5.1198 +            last_sample2 = sample2;
  5.1199 +            last_sample1 = sample1;
  5.1200 +            last_sample0 = sample0;
  5.1201 +            eps -= dstsize;
  5.1202 +        }
  5.1203 +    }
  5.1204 +    cvt->len_cvt = dstsize;
  5.1205 +    if (cvt->filters[++cvt->filter_index]) {
  5.1206 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1207 +    }
  5.1208 +}
  5.1209 +
  5.1210 +static void SDLCALL
  5.1211 +SDL_Downsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1212 +{
  5.1213 +#ifdef DEBUG_CONVERT
  5.1214 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 4 channels.\n", cvt->rate_incr);
  5.1215 +#endif
  5.1216 +
  5.1217 +    const int srcsize = cvt->len_cvt - 128;
  5.1218 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1219 +    register int eps = 0;
  5.1220 +    Uint16 *dst = (Uint16 *) cvt->buf;
  5.1221 +    const Uint16 *src = (Uint16 *) cvt->buf;
  5.1222 +    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  5.1223 +    Uint16 sample0 = SDL_SwapLE16(src[0]);
  5.1224 +    Uint16 sample1 = SDL_SwapLE16(src[1]);
  5.1225 +    Uint16 sample2 = SDL_SwapLE16(src[2]);
  5.1226 +    Uint16 sample3 = SDL_SwapLE16(src[3]);
  5.1227 +    Uint16 last_sample0 = sample0;
  5.1228 +    Uint16 last_sample1 = sample1;
  5.1229 +    Uint16 last_sample2 = sample2;
  5.1230 +    Uint16 last_sample3 = sample3;
  5.1231 +    while (dst != target) {
  5.1232 +        src += 4;
  5.1233 +        eps += dstsize;
  5.1234 +        if ((eps << 1) >= srcsize) {
  5.1235 +            dst[0] = SDL_SwapLE16(sample0);
  5.1236 +            dst[1] = SDL_SwapLE16(sample1);
  5.1237 +            dst[2] = SDL_SwapLE16(sample2);
  5.1238 +            dst[3] = SDL_SwapLE16(sample3);
  5.1239 +            dst += 4;
  5.1240 +            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.1241 +            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.1242 +            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  5.1243 +            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  5.1244 +            last_sample0 = sample0;
  5.1245 +            last_sample1 = sample1;
  5.1246 +            last_sample2 = sample2;
  5.1247 +            last_sample3 = sample3;
  5.1248 +            eps -= srcsize;
  5.1249 +        }
  5.1250 +    }
  5.1251 +    cvt->len_cvt = dstsize;
  5.1252 +    if (cvt->filters[++cvt->filter_index]) {
  5.1253 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1254 +    }
  5.1255 +}
  5.1256 +
  5.1257 +static void SDLCALL
  5.1258 +SDL_Upsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1259 +{
  5.1260 +#ifdef DEBUG_CONVERT
  5.1261 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 6 channels.\n", cvt->rate_incr);
  5.1262 +#endif
  5.1263 +
  5.1264 +    const int srcsize = cvt->len_cvt - 192;
  5.1265 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1266 +    register int eps = 0;
  5.1267 +    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
  5.1268 +    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
  5.1269 +    const Uint16 *target = ((const Uint16 *) cvt->buf) - 6;
  5.1270 +    Uint16 sample5 = SDL_SwapLE16(src[5]);
  5.1271 +    Uint16 sample4 = SDL_SwapLE16(src[4]);
  5.1272 +    Uint16 sample3 = SDL_SwapLE16(src[3]);
  5.1273 +    Uint16 sample2 = SDL_SwapLE16(src[2]);
  5.1274 +    Uint16 sample1 = SDL_SwapLE16(src[1]);
  5.1275 +    Uint16 sample0 = SDL_SwapLE16(src[0]);
  5.1276 +    Uint16 last_sample5 = sample5;
  5.1277 +    Uint16 last_sample4 = sample4;
  5.1278 +    Uint16 last_sample3 = sample3;
  5.1279 +    Uint16 last_sample2 = sample2;
  5.1280 +    Uint16 last_sample1 = sample1;
  5.1281 +    Uint16 last_sample0 = sample0;
  5.1282 +    while (dst != target) {
  5.1283 +        dst[5] = SDL_SwapLE16(sample5);
  5.1284 +        dst[4] = SDL_SwapLE16(sample4);
  5.1285 +        dst[3] = SDL_SwapLE16(sample3);
  5.1286 +        dst[2] = SDL_SwapLE16(sample2);
  5.1287 +        dst[1] = SDL_SwapLE16(sample1);
  5.1288 +        dst[0] = SDL_SwapLE16(sample0);
  5.1289 +        dst -= 6;
  5.1290 +        eps += srcsize;
  5.1291 +        if ((eps << 1) >= dstsize) {
  5.1292 +            src -= 6;
  5.1293 +            sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  5.1294 +            sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  5.1295 +            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  5.1296 +            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  5.1297 +            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.1298 +            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.1299 +            last_sample5 = sample5;
  5.1300 +            last_sample4 = sample4;
  5.1301 +            last_sample3 = sample3;
  5.1302 +            last_sample2 = sample2;
  5.1303 +            last_sample1 = sample1;
  5.1304 +            last_sample0 = sample0;
  5.1305 +            eps -= dstsize;
  5.1306 +        }
  5.1307 +    }
  5.1308 +    cvt->len_cvt = dstsize;
  5.1309 +    if (cvt->filters[++cvt->filter_index]) {
  5.1310 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1311 +    }
  5.1312 +}
  5.1313 +
  5.1314 +static void SDLCALL
  5.1315 +SDL_Downsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1316 +{
  5.1317 +#ifdef DEBUG_CONVERT
  5.1318 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 6 channels.\n", cvt->rate_incr);
  5.1319 +#endif
  5.1320 +
  5.1321 +    const int srcsize = cvt->len_cvt - 192;
  5.1322 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1323 +    register int eps = 0;
  5.1324 +    Uint16 *dst = (Uint16 *) cvt->buf;
  5.1325 +    const Uint16 *src = (Uint16 *) cvt->buf;
  5.1326 +    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  5.1327 +    Uint16 sample0 = SDL_SwapLE16(src[0]);
  5.1328 +    Uint16 sample1 = SDL_SwapLE16(src[1]);
  5.1329 +    Uint16 sample2 = SDL_SwapLE16(src[2]);
  5.1330 +    Uint16 sample3 = SDL_SwapLE16(src[3]);
  5.1331 +    Uint16 sample4 = SDL_SwapLE16(src[4]);
  5.1332 +    Uint16 sample5 = SDL_SwapLE16(src[5]);
  5.1333 +    Uint16 last_sample0 = sample0;
  5.1334 +    Uint16 last_sample1 = sample1;
  5.1335 +    Uint16 last_sample2 = sample2;
  5.1336 +    Uint16 last_sample3 = sample3;
  5.1337 +    Uint16 last_sample4 = sample4;
  5.1338 +    Uint16 last_sample5 = sample5;
  5.1339 +    while (dst != target) {
  5.1340 +        src += 6;
  5.1341 +        eps += dstsize;
  5.1342 +        if ((eps << 1) >= srcsize) {
  5.1343 +            dst[0] = SDL_SwapLE16(sample0);
  5.1344 +            dst[1] = SDL_SwapLE16(sample1);
  5.1345 +            dst[2] = SDL_SwapLE16(sample2);
  5.1346 +            dst[3] = SDL_SwapLE16(sample3);
  5.1347 +            dst[4] = SDL_SwapLE16(sample4);
  5.1348 +            dst[5] = SDL_SwapLE16(sample5);
  5.1349 +            dst += 6;
  5.1350 +            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.1351 +            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.1352 +            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  5.1353 +            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  5.1354 +            sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  5.1355 +            sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  5.1356 +            last_sample0 = sample0;
  5.1357 +            last_sample1 = sample1;
  5.1358 +            last_sample2 = sample2;
  5.1359 +            last_sample3 = sample3;
  5.1360 +            last_sample4 = sample4;
  5.1361 +            last_sample5 = sample5;
  5.1362 +            eps -= srcsize;
  5.1363 +        }
  5.1364 +    }
  5.1365 +    cvt->len_cvt = dstsize;
  5.1366 +    if (cvt->filters[++cvt->filter_index]) {
  5.1367 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1368 +    }
  5.1369 +}
  5.1370 +
  5.1371 +static void SDLCALL
  5.1372 +SDL_Upsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1373 +{
  5.1374 +#ifdef DEBUG_CONVERT
  5.1375 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 8 channels.\n", cvt->rate_incr);
  5.1376 +#endif
  5.1377 +
  5.1378 +    const int srcsize = cvt->len_cvt - 256;
  5.1379 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1380 +    register int eps = 0;
  5.1381 +    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
  5.1382 +    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
  5.1383 +    const Uint16 *target = ((const Uint16 *) cvt->buf) - 8;
  5.1384 +    Uint16 sample7 = SDL_SwapLE16(src[7]);
  5.1385 +    Uint16 sample6 = SDL_SwapLE16(src[6]);
  5.1386 +    Uint16 sample5 = SDL_SwapLE16(src[5]);
  5.1387 +    Uint16 sample4 = SDL_SwapLE16(src[4]);
  5.1388 +    Uint16 sample3 = SDL_SwapLE16(src[3]);
  5.1389 +    Uint16 sample2 = SDL_SwapLE16(src[2]);
  5.1390 +    Uint16 sample1 = SDL_SwapLE16(src[1]);
  5.1391 +    Uint16 sample0 = SDL_SwapLE16(src[0]);
  5.1392 +    Uint16 last_sample7 = sample7;
  5.1393 +    Uint16 last_sample6 = sample6;
  5.1394 +    Uint16 last_sample5 = sample5;
  5.1395 +    Uint16 last_sample4 = sample4;
  5.1396 +    Uint16 last_sample3 = sample3;
  5.1397 +    Uint16 last_sample2 = sample2;
  5.1398 +    Uint16 last_sample1 = sample1;
  5.1399 +    Uint16 last_sample0 = sample0;
  5.1400 +    while (dst != target) {
  5.1401 +        dst[7] = SDL_SwapLE16(sample7);
  5.1402 +        dst[6] = SDL_SwapLE16(sample6);
  5.1403 +        dst[5] = SDL_SwapLE16(sample5);
  5.1404 +        dst[4] = SDL_SwapLE16(sample4);
  5.1405 +        dst[3] = SDL_SwapLE16(sample3);
  5.1406 +        dst[2] = SDL_SwapLE16(sample2);
  5.1407 +        dst[1] = SDL_SwapLE16(sample1);
  5.1408 +        dst[0] = SDL_SwapLE16(sample0);
  5.1409 +        dst -= 8;
  5.1410 +        eps += srcsize;
  5.1411 +        if ((eps << 1) >= dstsize) {
  5.1412 +            src -= 8;
  5.1413 +            sample7 = (Uint16) ((((Sint32) SDL_SwapLE16(src[7])) + ((Sint32) last_sample7)) >> 1);
  5.1414 +            sample6 = (Uint16) ((((Sint32) SDL_SwapLE16(src[6])) + ((Sint32) last_sample6)) >> 1);
  5.1415 +            sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  5.1416 +            sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  5.1417 +            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  5.1418 +            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  5.1419 +            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.1420 +            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.1421 +            last_sample7 = sample7;
  5.1422 +            last_sample6 = sample6;
  5.1423 +            last_sample5 = sample5;
  5.1424 +            last_sample4 = sample4;
  5.1425 +            last_sample3 = sample3;
  5.1426 +            last_sample2 = sample2;
  5.1427 +            last_sample1 = sample1;
  5.1428 +            last_sample0 = sample0;
  5.1429 +            eps -= dstsize;
  5.1430 +        }
  5.1431 +    }
  5.1432 +    cvt->len_cvt = dstsize;
  5.1433 +    if (cvt->filters[++cvt->filter_index]) {
  5.1434 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1435 +    }
  5.1436 +}
  5.1437 +
  5.1438 +static void SDLCALL
  5.1439 +SDL_Downsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1440 +{
  5.1441 +#ifdef DEBUG_CONVERT
  5.1442 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 8 channels.\n", cvt->rate_incr);
  5.1443 +#endif
  5.1444 +
  5.1445 +    const int srcsize = cvt->len_cvt - 256;
  5.1446 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1447 +    register int eps = 0;
  5.1448 +    Uint16 *dst = (Uint16 *) cvt->buf;
  5.1449 +    const Uint16 *src = (Uint16 *) cvt->buf;
  5.1450 +    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  5.1451 +    Uint16 sample0 = SDL_SwapLE16(src[0]);
  5.1452 +    Uint16 sample1 = SDL_SwapLE16(src[1]);
  5.1453 +    Uint16 sample2 = SDL_SwapLE16(src[2]);
  5.1454 +    Uint16 sample3 = SDL_SwapLE16(src[3]);
  5.1455 +    Uint16 sample4 = SDL_SwapLE16(src[4]);
  5.1456 +    Uint16 sample5 = SDL_SwapLE16(src[5]);
  5.1457 +    Uint16 sample6 = SDL_SwapLE16(src[6]);
  5.1458 +    Uint16 sample7 = SDL_SwapLE16(src[7]);
  5.1459 +    Uint16 last_sample0 = sample0;
  5.1460 +    Uint16 last_sample1 = sample1;
  5.1461 +    Uint16 last_sample2 = sample2;
  5.1462 +    Uint16 last_sample3 = sample3;
  5.1463 +    Uint16 last_sample4 = sample4;
  5.1464 +    Uint16 last_sample5 = sample5;
  5.1465 +    Uint16 last_sample6 = sample6;
  5.1466 +    Uint16 last_sample7 = sample7;
  5.1467 +    while (dst != target) {
  5.1468 +        src += 8;
  5.1469 +        eps += dstsize;
  5.1470 +        if ((eps << 1) >= srcsize) {
  5.1471 +            dst[0] = SDL_SwapLE16(sample0);
  5.1472 +            dst[1] = SDL_SwapLE16(sample1);
  5.1473 +            dst[2] = SDL_SwapLE16(sample2);
  5.1474 +            dst[3] = SDL_SwapLE16(sample3);
  5.1475 +            dst[4] = SDL_SwapLE16(sample4);
  5.1476 +            dst[5] = SDL_SwapLE16(sample5);
  5.1477 +            dst[6] = SDL_SwapLE16(sample6);
  5.1478 +            dst[7] = SDL_SwapLE16(sample7);
  5.1479 +            dst += 8;
  5.1480 +            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.1481 +            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.1482 +            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  5.1483 +            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  5.1484 +            sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  5.1485 +            sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  5.1486 +            sample6 = (Uint16) ((((Sint32) SDL_SwapLE16(src[6])) + ((Sint32) last_sample6)) >> 1);
  5.1487 +            sample7 = (Uint16) ((((Sint32) SDL_SwapLE16(src[7])) + ((Sint32) last_sample7)) >> 1);
  5.1488 +            last_sample0 = sample0;
  5.1489 +            last_sample1 = sample1;
  5.1490 +            last_sample2 = sample2;
  5.1491 +            last_sample3 = sample3;
  5.1492 +            last_sample4 = sample4;
  5.1493 +            last_sample5 = sample5;
  5.1494 +            last_sample6 = sample6;
  5.1495 +            last_sample7 = sample7;
  5.1496 +            eps -= srcsize;
  5.1497 +        }
  5.1498 +    }
  5.1499 +    cvt->len_cvt = dstsize;
  5.1500 +    if (cvt->filters[++cvt->filter_index]) {
  5.1501 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1502 +    }
  5.1503 +}
  5.1504 +
  5.1505 +static void SDLCALL
  5.1506 +SDL_Upsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1507 +{
  5.1508 +#ifdef DEBUG_CONVERT
  5.1509 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 1 channels.\n", cvt->rate_incr);
  5.1510 +#endif
  5.1511 +
  5.1512 +    const int srcsize = cvt->len_cvt - 32;
  5.1513 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1514 +    register int eps = 0;
  5.1515 +    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
  5.1516 +    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  5.1517 +    const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
  5.1518 +    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  5.1519 +    Sint16 last_sample0 = sample0;
  5.1520 +    while (dst != target) {
  5.1521 +        dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  5.1522 +        dst--;
  5.1523 +        eps += srcsize;
  5.1524 +        if ((eps << 1) >= dstsize) {
  5.1525 +            src--;
  5.1526 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.1527 +            last_sample0 = sample0;
  5.1528 +            eps -= dstsize;
  5.1529 +        }
  5.1530 +    }
  5.1531 +    cvt->len_cvt = dstsize;
  5.1532 +    if (cvt->filters[++cvt->filter_index]) {
  5.1533 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1534 +    }
  5.1535 +}
  5.1536 +
  5.1537 +static void SDLCALL
  5.1538 +SDL_Downsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1539 +{
  5.1540 +#ifdef DEBUG_CONVERT
  5.1541 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 1 channels.\n", cvt->rate_incr);
  5.1542 +#endif
  5.1543 +
  5.1544 +    const int srcsize = cvt->len_cvt - 32;
  5.1545 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1546 +    register int eps = 0;
  5.1547 +    Sint16 *dst = (Sint16 *) cvt->buf;
  5.1548 +    const Sint16 *src = (Sint16 *) cvt->buf;
  5.1549 +    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  5.1550 +    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  5.1551 +    Sint16 last_sample0 = sample0;
  5.1552 +    while (dst != target) {
  5.1553 +        src++;
  5.1554 +        eps += dstsize;
  5.1555 +        if ((eps << 1) >= srcsize) {
  5.1556 +            dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  5.1557 +            dst++;
  5.1558 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.1559 +            last_sample0 = sample0;
  5.1560 +            eps -= srcsize;
  5.1561 +        }
  5.1562 +    }
  5.1563 +    cvt->len_cvt = dstsize;
  5.1564 +    if (cvt->filters[++cvt->filter_index]) {
  5.1565 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1566 +    }
  5.1567 +}
  5.1568 +
  5.1569 +static void SDLCALL
  5.1570 +SDL_Upsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1571 +{
  5.1572 +#ifdef DEBUG_CONVERT
  5.1573 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 2 channels.\n", cvt->rate_incr);
  5.1574 +#endif
  5.1575 +
  5.1576 +    const int srcsize = cvt->len_cvt - 64;
  5.1577 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1578 +    register int eps = 0;
  5.1579 +    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
  5.1580 +    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
  5.1581 +    const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
  5.1582 +    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  5.1583 +    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  5.1584 +    Sint16 last_sample1 = sample1;
  5.1585 +    Sint16 last_sample0 = sample0;
  5.1586 +    while (dst != target) {
  5.1587 +        dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  5.1588 +        dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  5.1589 +        dst -= 2;
  5.1590 +        eps += srcsize;
  5.1591 +        if ((eps << 1) >= dstsize) {
  5.1592 +            src -= 2;
  5.1593 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.1594 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.1595 +            last_sample1 = sample1;
  5.1596 +            last_sample0 = sample0;
  5.1597 +            eps -= dstsize;
  5.1598 +        }
  5.1599 +    }
  5.1600 +    cvt->len_cvt = dstsize;
  5.1601 +    if (cvt->filters[++cvt->filter_index]) {
  5.1602 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1603 +    }
  5.1604 +}
  5.1605 +
  5.1606 +static void SDLCALL
  5.1607 +SDL_Downsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1608 +{
  5.1609 +#ifdef DEBUG_CONVERT
  5.1610 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 2 channels.\n", cvt->rate_incr);
  5.1611 +#endif
  5.1612 +
  5.1613 +    const int srcsize = cvt->len_cvt - 64;
  5.1614 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1615 +    register int eps = 0;
  5.1616 +    Sint16 *dst = (Sint16 *) cvt->buf;
  5.1617 +    const Sint16 *src = (Sint16 *) cvt->buf;
  5.1618 +    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  5.1619 +    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  5.1620 +    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  5.1621 +    Sint16 last_sample0 = sample0;
  5.1622 +    Sint16 last_sample1 = sample1;
  5.1623 +    while (dst != target) {
  5.1624 +        src += 2;
  5.1625 +        eps += dstsize;
  5.1626 +        if ((eps << 1) >= srcsize) {
  5.1627 +            dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  5.1628 +            dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  5.1629 +            dst += 2;
  5.1630 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.1631 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.1632 +            last_sample0 = sample0;
  5.1633 +            last_sample1 = sample1;
  5.1634 +            eps -= srcsize;
  5.1635 +        }
  5.1636 +    }
  5.1637 +    cvt->len_cvt = dstsize;
  5.1638 +    if (cvt->filters[++cvt->filter_index]) {
  5.1639 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1640 +    }
  5.1641 +}
  5.1642 +
  5.1643 +static void SDLCALL
  5.1644 +SDL_Upsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1645 +{
  5.1646 +#ifdef DEBUG_CONVERT
  5.1647 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 4 channels.\n", cvt->rate_incr);
  5.1648 +#endif
  5.1649 +
  5.1650 +    const int srcsize = cvt->len_cvt - 128;
  5.1651 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1652 +    register int eps = 0;
  5.1653 +    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
  5.1654 +    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
  5.1655 +    const Sint16 *target = ((const Sint16 *) cvt->buf) - 4;
  5.1656 +    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
  5.1657 +    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
  5.1658 +    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  5.1659 +    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  5.1660 +    Sint16 last_sample3 = sample3;
  5.1661 +    Sint16 last_sample2 = sample2;
  5.1662 +    Sint16 last_sample1 = sample1;
  5.1663 +    Sint16 last_sample0 = sample0;
  5.1664 +    while (dst != target) {
  5.1665 +        dst[3] = ((Sint16) SDL_SwapLE16(sample3));
  5.1666 +        dst[2] = ((Sint16) SDL_SwapLE16(sample2));
  5.1667 +        dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  5.1668 +        dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  5.1669 +        dst -= 4;
  5.1670 +        eps += srcsize;
  5.1671 +        if ((eps << 1) >= dstsize) {
  5.1672 +            src -= 4;
  5.1673 +            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  5.1674 +            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  5.1675 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.1676 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.1677 +            last_sample3 = sample3;
  5.1678 +            last_sample2 = sample2;
  5.1679 +            last_sample1 = sample1;
  5.1680 +            last_sample0 = sample0;
  5.1681 +            eps -= dstsize;
  5.1682 +        }
  5.1683 +    }
  5.1684 +    cvt->len_cvt = dstsize;
  5.1685 +    if (cvt->filters[++cvt->filter_index]) {
  5.1686 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1687 +    }
  5.1688 +}
  5.1689 +
  5.1690 +static void SDLCALL
  5.1691 +SDL_Downsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1692 +{
  5.1693 +#ifdef DEBUG_CONVERT
  5.1694 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 4 channels.\n", cvt->rate_incr);
  5.1695 +#endif
  5.1696 +
  5.1697 +    const int srcsize = cvt->len_cvt - 128;
  5.1698 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1699 +    register int eps = 0;
  5.1700 +    Sint16 *dst = (Sint16 *) cvt->buf;
  5.1701 +    const Sint16 *src = (Sint16 *) cvt->buf;
  5.1702 +    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  5.1703 +    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  5.1704 +    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  5.1705 +    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
  5.1706 +    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
  5.1707 +    Sint16 last_sample0 = sample0;
  5.1708 +    Sint16 last_sample1 = sample1;
  5.1709 +    Sint16 last_sample2 = sample2;
  5.1710 +    Sint16 last_sample3 = sample3;
  5.1711 +    while (dst != target) {
  5.1712 +        src += 4;
  5.1713 +        eps += dstsize;
  5.1714 +        if ((eps << 1) >= srcsize) {
  5.1715 +            dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  5.1716 +            dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  5.1717 +            dst[2] = ((Sint16) SDL_SwapLE16(sample2));
  5.1718 +            dst[3] = ((Sint16) SDL_SwapLE16(sample3));
  5.1719 +            dst += 4;
  5.1720 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.1721 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.1722 +            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  5.1723 +            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  5.1724 +            last_sample0 = sample0;
  5.1725 +            last_sample1 = sample1;
  5.1726 +            last_sample2 = sample2;
  5.1727 +            last_sample3 = sample3;
  5.1728 +            eps -= srcsize;
  5.1729 +        }
  5.1730 +    }
  5.1731 +    cvt->len_cvt = dstsize;
  5.1732 +    if (cvt->filters[++cvt->filter_index]) {
  5.1733 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1734 +    }
  5.1735 +}
  5.1736 +
  5.1737 +static void SDLCALL
  5.1738 +SDL_Upsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1739 +{
  5.1740 +#ifdef DEBUG_CONVERT
  5.1741 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 6 channels.\n", cvt->rate_incr);
  5.1742 +#endif
  5.1743 +
  5.1744 +    const int srcsize = cvt->len_cvt - 192;
  5.1745 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1746 +    register int eps = 0;
  5.1747 +    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
  5.1748 +    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
  5.1749 +    const Sint16 *target = ((const Sint16 *) cvt->buf) - 6;
  5.1750 +    Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
  5.1751 +    Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
  5.1752 +    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
  5.1753 +    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
  5.1754 +    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  5.1755 +    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  5.1756 +    Sint16 last_sample5 = sample5;
  5.1757 +    Sint16 last_sample4 = sample4;
  5.1758 +    Sint16 last_sample3 = sample3;
  5.1759 +    Sint16 last_sample2 = sample2;
  5.1760 +    Sint16 last_sample1 = sample1;
  5.1761 +    Sint16 last_sample0 = sample0;
  5.1762 +    while (dst != target) {
  5.1763 +        dst[5] = ((Sint16) SDL_SwapLE16(sample5));
  5.1764 +        dst[4] = ((Sint16) SDL_SwapLE16(sample4));
  5.1765 +        dst[3] = ((Sint16) SDL_SwapLE16(sample3));
  5.1766 +        dst[2] = ((Sint16) SDL_SwapLE16(sample2));
  5.1767 +        dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  5.1768 +        dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  5.1769 +        dst -= 6;
  5.1770 +        eps += srcsize;
  5.1771 +        if ((eps << 1) >= dstsize) {
  5.1772 +            src -= 6;
  5.1773 +            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  5.1774 +            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  5.1775 +            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  5.1776 +            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  5.1777 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.1778 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.1779 +            last_sample5 = sample5;
  5.1780 +            last_sample4 = sample4;
  5.1781 +            last_sample3 = sample3;
  5.1782 +            last_sample2 = sample2;
  5.1783 +            last_sample1 = sample1;
  5.1784 +            last_sample0 = sample0;
  5.1785 +            eps -= dstsize;
  5.1786 +        }
  5.1787 +    }
  5.1788 +    cvt->len_cvt = dstsize;
  5.1789 +    if (cvt->filters[++cvt->filter_index]) {
  5.1790 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1791 +    }
  5.1792 +}
  5.1793 +
  5.1794 +static void SDLCALL
  5.1795 +SDL_Downsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1796 +{
  5.1797 +#ifdef DEBUG_CONVERT
  5.1798 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 6 channels.\n", cvt->rate_incr);
  5.1799 +#endif
  5.1800 +
  5.1801 +    const int srcsize = cvt->len_cvt - 192;
  5.1802 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1803 +    register int eps = 0;
  5.1804 +    Sint16 *dst = (Sint16 *) cvt->buf;
  5.1805 +    const Sint16 *src = (Sint16 *) cvt->buf;
  5.1806 +    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  5.1807 +    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  5.1808 +    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  5.1809 +    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
  5.1810 +    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
  5.1811 +    Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
  5.1812 +    Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
  5.1813 +    Sint16 last_sample0 = sample0;
  5.1814 +    Sint16 last_sample1 = sample1;
  5.1815 +    Sint16 last_sample2 = sample2;
  5.1816 +    Sint16 last_sample3 = sample3;
  5.1817 +    Sint16 last_sample4 = sample4;
  5.1818 +    Sint16 last_sample5 = sample5;
  5.1819 +    while (dst != target) {
  5.1820 +        src += 6;
  5.1821 +        eps += dstsize;
  5.1822 +        if ((eps << 1) >= srcsize) {
  5.1823 +            dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  5.1824 +            dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  5.1825 +            dst[2] = ((Sint16) SDL_SwapLE16(sample2));
  5.1826 +            dst[3] = ((Sint16) SDL_SwapLE16(sample3));
  5.1827 +            dst[4] = ((Sint16) SDL_SwapLE16(sample4));
  5.1828 +            dst[5] = ((Sint16) SDL_SwapLE16(sample5));
  5.1829 +            dst += 6;
  5.1830 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.1831 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.1832 +            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  5.1833 +            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  5.1834 +            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  5.1835 +            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  5.1836 +            last_sample0 = sample0;
  5.1837 +            last_sample1 = sample1;
  5.1838 +            last_sample2 = sample2;
  5.1839 +            last_sample3 = sample3;
  5.1840 +            last_sample4 = sample4;
  5.1841 +            last_sample5 = sample5;
  5.1842 +            eps -= srcsize;
  5.1843 +        }
  5.1844 +    }
  5.1845 +    cvt->len_cvt = dstsize;
  5.1846 +    if (cvt->filters[++cvt->filter_index]) {
  5.1847 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1848 +    }
  5.1849 +}
  5.1850 +
  5.1851 +static void SDLCALL
  5.1852 +SDL_Upsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1853 +{
  5.1854 +#ifdef DEBUG_CONVERT
  5.1855 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 8 channels.\n", cvt->rate_incr);
  5.1856 +#endif
  5.1857 +
  5.1858 +    const int srcsize = cvt->len_cvt - 256;
  5.1859 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1860 +    register int eps = 0;
  5.1861 +    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
  5.1862 +    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
  5.1863 +    const Sint16 *target = ((const Sint16 *) cvt->buf) - 8;
  5.1864 +    Sint16 sample7 = ((Sint16) SDL_SwapLE16(src[7]));
  5.1865 +    Sint16 sample6 = ((Sint16) SDL_SwapLE16(src[6]));
  5.1866 +    Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
  5.1867 +    Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
  5.1868 +    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
  5.1869 +    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
  5.1870 +    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  5.1871 +    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  5.1872 +    Sint16 last_sample7 = sample7;
  5.1873 +    Sint16 last_sample6 = sample6;
  5.1874 +    Sint16 last_sample5 = sample5;
  5.1875 +    Sint16 last_sample4 = sample4;
  5.1876 +    Sint16 last_sample3 = sample3;
  5.1877 +    Sint16 last_sample2 = sample2;
  5.1878 +    Sint16 last_sample1 = sample1;
  5.1879 +    Sint16 last_sample0 = sample0;
  5.1880 +    while (dst != target) {
  5.1881 +        dst[7] = ((Sint16) SDL_SwapLE16(sample7));
  5.1882 +        dst[6] = ((Sint16) SDL_SwapLE16(sample6));
  5.1883 +        dst[5] = ((Sint16) SDL_SwapLE16(sample5));
  5.1884 +        dst[4] = ((Sint16) SDL_SwapLE16(sample4));
  5.1885 +        dst[3] = ((Sint16) SDL_SwapLE16(sample3));
  5.1886 +        dst[2] = ((Sint16) SDL_SwapLE16(sample2));
  5.1887 +        dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  5.1888 +        dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  5.1889 +        dst -= 8;
  5.1890 +        eps += srcsize;
  5.1891 +        if ((eps << 1) >= dstsize) {
  5.1892 +            src -= 8;
  5.1893 +            sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
  5.1894 +            sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
  5.1895 +            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  5.1896 +            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  5.1897 +            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  5.1898 +            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  5.1899 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.1900 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.1901 +            last_sample7 = sample7;
  5.1902 +            last_sample6 = sample6;
  5.1903 +            last_sample5 = sample5;
  5.1904 +            last_sample4 = sample4;
  5.1905 +            last_sample3 = sample3;
  5.1906 +            last_sample2 = sample2;
  5.1907 +            last_sample1 = sample1;
  5.1908 +            last_sample0 = sample0;
  5.1909 +            eps -= dstsize;
  5.1910 +        }
  5.1911 +    }
  5.1912 +    cvt->len_cvt = dstsize;
  5.1913 +    if (cvt->filters[++cvt->filter_index]) {
  5.1914 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1915 +    }
  5.1916 +}
  5.1917 +
  5.1918 +static void SDLCALL
  5.1919 +SDL_Downsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1920 +{
  5.1921 +#ifdef DEBUG_CONVERT
  5.1922 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 8 channels.\n", cvt->rate_incr);
  5.1923 +#endif
  5.1924 +
  5.1925 +    const int srcsize = cvt->len_cvt - 256;
  5.1926 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1927 +    register int eps = 0;
  5.1928 +    Sint16 *dst = (Sint16 *) cvt->buf;
  5.1929 +    const Sint16 *src = (Sint16 *) cvt->buf;
  5.1930 +    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  5.1931 +    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
  5.1932 +    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
  5.1933 +    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
  5.1934 +    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
  5.1935 +    Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
  5.1936 +    Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
  5.1937 +    Sint16 sample6 = ((Sint16) SDL_SwapLE16(src[6]));
  5.1938 +    Sint16 sample7 = ((Sint16) SDL_SwapLE16(src[7]));
  5.1939 +    Sint16 last_sample0 = sample0;
  5.1940 +    Sint16 last_sample1 = sample1;
  5.1941 +    Sint16 last_sample2 = sample2;
  5.1942 +    Sint16 last_sample3 = sample3;
  5.1943 +    Sint16 last_sample4 = sample4;
  5.1944 +    Sint16 last_sample5 = sample5;
  5.1945 +    Sint16 last_sample6 = sample6;
  5.1946 +    Sint16 last_sample7 = sample7;
  5.1947 +    while (dst != target) {
  5.1948 +        src += 8;
  5.1949 +        eps += dstsize;
  5.1950 +        if ((eps << 1) >= srcsize) {
  5.1951 +            dst[0] = ((Sint16) SDL_SwapLE16(sample0));
  5.1952 +            dst[1] = ((Sint16) SDL_SwapLE16(sample1));
  5.1953 +            dst[2] = ((Sint16) SDL_SwapLE16(sample2));
  5.1954 +            dst[3] = ((Sint16) SDL_SwapLE16(sample3));
  5.1955 +            dst[4] = ((Sint16) SDL_SwapLE16(sample4));
  5.1956 +            dst[5] = ((Sint16) SDL_SwapLE16(sample5));
  5.1957 +            dst[6] = ((Sint16) SDL_SwapLE16(sample6));
  5.1958 +            dst[7] = ((Sint16) SDL_SwapLE16(sample7));
  5.1959 +            dst += 8;
  5.1960 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.1961 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.1962 +            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  5.1963 +            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  5.1964 +            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  5.1965 +            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  5.1966 +            sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
  5.1967 +            sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
  5.1968 +            last_sample0 = sample0;
  5.1969 +            last_sample1 = sample1;
  5.1970 +            last_sample2 = sample2;
  5.1971 +            last_sample3 = sample3;
  5.1972 +            last_sample4 = sample4;
  5.1973 +            last_sample5 = sample5;
  5.1974 +            last_sample6 = sample6;
  5.1975 +            last_sample7 = sample7;
  5.1976 +            eps -= srcsize;
  5.1977 +        }
  5.1978 +    }
  5.1979 +    cvt->len_cvt = dstsize;
  5.1980 +    if (cvt->filters[++cvt->filter_index]) {
  5.1981 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.1982 +    }
  5.1983 +}
  5.1984 +
  5.1985 +static void SDLCALL
  5.1986 +SDL_Upsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.1987 +{
  5.1988 +#ifdef DEBUG_CONVERT
  5.1989 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 1 channels.\n", cvt->rate_incr);
  5.1990 +#endif
  5.1991 +
  5.1992 +    const int srcsize = cvt->len_cvt - 32;
  5.1993 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.1994 +    register int eps = 0;
  5.1995 +    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
  5.1996 +    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  5.1997 +    const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
  5.1998 +    Uint16 sample0 = SDL_SwapBE16(src[0]);
  5.1999 +    Uint16 last_sample0 = sample0;
  5.2000 +    while (dst != target) {
  5.2001 +        dst[0] = SDL_SwapBE16(sample0);
  5.2002 +        dst--;
  5.2003 +        eps += srcsize;
  5.2004 +        if ((eps << 1) >= dstsize) {
  5.2005 +            src--;
  5.2006 +            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.2007 +            last_sample0 = sample0;
  5.2008 +            eps -= dstsize;
  5.2009 +        }
  5.2010 +    }
  5.2011 +    cvt->len_cvt = dstsize;
  5.2012 +    if (cvt->filters[++cvt->filter_index]) {
  5.2013 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2014 +    }
  5.2015 +}
  5.2016 +
  5.2017 +static void SDLCALL
  5.2018 +SDL_Downsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2019 +{
  5.2020 +#ifdef DEBUG_CONVERT
  5.2021 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 1 channels.\n", cvt->rate_incr);
  5.2022 +#endif
  5.2023 +
  5.2024 +    const int srcsize = cvt->len_cvt - 32;
  5.2025 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2026 +    register int eps = 0;
  5.2027 +    Uint16 *dst = (Uint16 *) cvt->buf;
  5.2028 +    const Uint16 *src = (Uint16 *) cvt->buf;
  5.2029 +    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  5.2030 +    Uint16 sample0 = SDL_SwapBE16(src[0]);
  5.2031 +    Uint16 last_sample0 = sample0;
  5.2032 +    while (dst != target) {
  5.2033 +        src++;
  5.2034 +        eps += dstsize;
  5.2035 +        if ((eps << 1) >= srcsize) {
  5.2036 +            dst[0] = SDL_SwapBE16(sample0);
  5.2037 +            dst++;
  5.2038 +            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.2039 +            last_sample0 = sample0;
  5.2040 +            eps -= srcsize;
  5.2041 +        }
  5.2042 +    }
  5.2043 +    cvt->len_cvt = dstsize;
  5.2044 +    if (cvt->filters[++cvt->filter_index]) {
  5.2045 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2046 +    }
  5.2047 +}
  5.2048 +
  5.2049 +static void SDLCALL
  5.2050 +SDL_Upsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2051 +{
  5.2052 +#ifdef DEBUG_CONVERT
  5.2053 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 2 channels.\n", cvt->rate_incr);
  5.2054 +#endif
  5.2055 +
  5.2056 +    const int srcsize = cvt->len_cvt - 64;
  5.2057 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2058 +    register int eps = 0;
  5.2059 +    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
  5.2060 +    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
  5.2061 +    const Uint16 *target = ((const Uint16 *) cvt->buf) - 2;
  5.2062 +    Uint16 sample1 = SDL_SwapBE16(src[1]);
  5.2063 +    Uint16 sample0 = SDL_SwapBE16(src[0]);
  5.2064 +    Uint16 last_sample1 = sample1;
  5.2065 +    Uint16 last_sample0 = sample0;
  5.2066 +    while (dst != target) {
  5.2067 +        dst[1] = SDL_SwapBE16(sample1);
  5.2068 +        dst[0] = SDL_SwapBE16(sample0);
  5.2069 +        dst -= 2;
  5.2070 +        eps += srcsize;
  5.2071 +        if ((eps << 1) >= dstsize) {
  5.2072 +            src -= 2;
  5.2073 +            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.2074 +            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.2075 +            last_sample1 = sample1;
  5.2076 +            last_sample0 = sample0;
  5.2077 +            eps -= dstsize;
  5.2078 +        }
  5.2079 +    }
  5.2080 +    cvt->len_cvt = dstsize;
  5.2081 +    if (cvt->filters[++cvt->filter_index]) {
  5.2082 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2083 +    }
  5.2084 +}
  5.2085 +
  5.2086 +static void SDLCALL
  5.2087 +SDL_Downsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2088 +{
  5.2089 +#ifdef DEBUG_CONVERT
  5.2090 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 2 channels.\n", cvt->rate_incr);
  5.2091 +#endif
  5.2092 +
  5.2093 +    const int srcsize = cvt->len_cvt - 64;
  5.2094 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2095 +    register int eps = 0;
  5.2096 +    Uint16 *dst = (Uint16 *) cvt->buf;
  5.2097 +    const Uint16 *src = (Uint16 *) cvt->buf;
  5.2098 +    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  5.2099 +    Uint16 sample0 = SDL_SwapBE16(src[0]);
  5.2100 +    Uint16 sample1 = SDL_SwapBE16(src[1]);
  5.2101 +    Uint16 last_sample0 = sample0;
  5.2102 +    Uint16 last_sample1 = sample1;
  5.2103 +    while (dst != target) {
  5.2104 +        src += 2;
  5.2105 +        eps += dstsize;
  5.2106 +        if ((eps << 1) >= srcsize) {
  5.2107 +            dst[0] = SDL_SwapBE16(sample0);
  5.2108 +            dst[1] = SDL_SwapBE16(sample1);
  5.2109 +            dst += 2;
  5.2110 +            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.2111 +            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.2112 +            last_sample0 = sample0;
  5.2113 +            last_sample1 = sample1;
  5.2114 +            eps -= srcsize;
  5.2115 +        }
  5.2116 +    }
  5.2117 +    cvt->len_cvt = dstsize;
  5.2118 +    if (cvt->filters[++cvt->filter_index]) {
  5.2119 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2120 +    }
  5.2121 +}
  5.2122 +
  5.2123 +static void SDLCALL
  5.2124 +SDL_Upsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2125 +{
  5.2126 +#ifdef DEBUG_CONVERT
  5.2127 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 4 channels.\n", cvt->rate_incr);
  5.2128 +#endif
  5.2129 +
  5.2130 +    const int srcsize = cvt->len_cvt - 128;
  5.2131 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2132 +    register int eps = 0;
  5.2133 +    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
  5.2134 +    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
  5.2135 +    const Uint16 *target = ((const Uint16 *) cvt->buf) - 4;
  5.2136 +    Uint16 sample3 = SDL_SwapBE16(src[3]);
  5.2137 +    Uint16 sample2 = SDL_SwapBE16(src[2]);
  5.2138 +    Uint16 sample1 = SDL_SwapBE16(src[1]);
  5.2139 +    Uint16 sample0 = SDL_SwapBE16(src[0]);
  5.2140 +    Uint16 last_sample3 = sample3;
  5.2141 +    Uint16 last_sample2 = sample2;
  5.2142 +    Uint16 last_sample1 = sample1;
  5.2143 +    Uint16 last_sample0 = sample0;
  5.2144 +    while (dst != target) {
  5.2145 +        dst[3] = SDL_SwapBE16(sample3);
  5.2146 +        dst[2] = SDL_SwapBE16(sample2);
  5.2147 +        dst[1] = SDL_SwapBE16(sample1);
  5.2148 +        dst[0] = SDL_SwapBE16(sample0);
  5.2149 +        dst -= 4;
  5.2150 +        eps += srcsize;
  5.2151 +        if ((eps << 1) >= dstsize) {
  5.2152 +            src -= 4;
  5.2153 +            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  5.2154 +            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  5.2155 +            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.2156 +            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.2157 +            last_sample3 = sample3;
  5.2158 +            last_sample2 = sample2;
  5.2159 +            last_sample1 = sample1;
  5.2160 +            last_sample0 = sample0;
  5.2161 +            eps -= dstsize;
  5.2162 +        }
  5.2163 +    }
  5.2164 +    cvt->len_cvt = dstsize;
  5.2165 +    if (cvt->filters[++cvt->filter_index]) {
  5.2166 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2167 +    }
  5.2168 +}
  5.2169 +
  5.2170 +static void SDLCALL
  5.2171 +SDL_Downsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2172 +{
  5.2173 +#ifdef DEBUG_CONVERT
  5.2174 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 4 channels.\n", cvt->rate_incr);
  5.2175 +#endif
  5.2176 +
  5.2177 +    const int srcsize = cvt->len_cvt - 128;
  5.2178 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2179 +    register int eps = 0;
  5.2180 +    Uint16 *dst = (Uint16 *) cvt->buf;
  5.2181 +    const Uint16 *src = (Uint16 *) cvt->buf;
  5.2182 +    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  5.2183 +    Uint16 sample0 = SDL_SwapBE16(src[0]);
  5.2184 +    Uint16 sample1 = SDL_SwapBE16(src[1]);
  5.2185 +    Uint16 sample2 = SDL_SwapBE16(src[2]);
  5.2186 +    Uint16 sample3 = SDL_SwapBE16(src[3]);
  5.2187 +    Uint16 last_sample0 = sample0;
  5.2188 +    Uint16 last_sample1 = sample1;
  5.2189 +    Uint16 last_sample2 = sample2;
  5.2190 +    Uint16 last_sample3 = sample3;
  5.2191 +    while (dst != target) {
  5.2192 +        src += 4;
  5.2193 +        eps += dstsize;
  5.2194 +        if ((eps << 1) >= srcsize) {
  5.2195 +            dst[0] = SDL_SwapBE16(sample0);
  5.2196 +            dst[1] = SDL_SwapBE16(sample1);
  5.2197 +            dst[2] = SDL_SwapBE16(sample2);
  5.2198 +            dst[3] = SDL_SwapBE16(sample3);
  5.2199 +            dst += 4;
  5.2200 +            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.2201 +            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.2202 +            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  5.2203 +            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  5.2204 +            last_sample0 = sample0;
  5.2205 +            last_sample1 = sample1;
  5.2206 +            last_sample2 = sample2;
  5.2207 +            last_sample3 = sample3;
  5.2208 +            eps -= srcsize;
  5.2209 +        }
  5.2210 +    }
  5.2211 +    cvt->len_cvt = dstsize;
  5.2212 +    if (cvt->filters[++cvt->filter_index]) {
  5.2213 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2214 +    }
  5.2215 +}
  5.2216 +
  5.2217 +static void SDLCALL
  5.2218 +SDL_Upsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2219 +{
  5.2220 +#ifdef DEBUG_CONVERT
  5.2221 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 6 channels.\n", cvt->rate_incr);
  5.2222 +#endif
  5.2223 +
  5.2224 +    const int srcsize = cvt->len_cvt - 192;
  5.2225 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2226 +    register int eps = 0;
  5.2227 +    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
  5.2228 +    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
  5.2229 +    const Uint16 *target = ((const Uint16 *) cvt->buf) - 6;
  5.2230 +    Uint16 sample5 = SDL_SwapBE16(src[5]);
  5.2231 +    Uint16 sample4 = SDL_SwapBE16(src[4]);
  5.2232 +    Uint16 sample3 = SDL_SwapBE16(src[3]);
  5.2233 +    Uint16 sample2 = SDL_SwapBE16(src[2]);
  5.2234 +    Uint16 sample1 = SDL_SwapBE16(src[1]);
  5.2235 +    Uint16 sample0 = SDL_SwapBE16(src[0]);
  5.2236 +    Uint16 last_sample5 = sample5;
  5.2237 +    Uint16 last_sample4 = sample4;
  5.2238 +    Uint16 last_sample3 = sample3;
  5.2239 +    Uint16 last_sample2 = sample2;
  5.2240 +    Uint16 last_sample1 = sample1;
  5.2241 +    Uint16 last_sample0 = sample0;
  5.2242 +    while (dst != target) {
  5.2243 +        dst[5] = SDL_SwapBE16(sample5);
  5.2244 +        dst[4] = SDL_SwapBE16(sample4);
  5.2245 +        dst[3] = SDL_SwapBE16(sample3);
  5.2246 +        dst[2] = SDL_SwapBE16(sample2);
  5.2247 +        dst[1] = SDL_SwapBE16(sample1);
  5.2248 +        dst[0] = SDL_SwapBE16(sample0);
  5.2249 +        dst -= 6;
  5.2250 +        eps += srcsize;
  5.2251 +        if ((eps << 1) >= dstsize) {
  5.2252 +            src -= 6;
  5.2253 +            sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  5.2254 +            sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  5.2255 +            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  5.2256 +            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  5.2257 +            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.2258 +            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.2259 +            last_sample5 = sample5;
  5.2260 +            last_sample4 = sample4;
  5.2261 +            last_sample3 = sample3;
  5.2262 +            last_sample2 = sample2;
  5.2263 +            last_sample1 = sample1;
  5.2264 +            last_sample0 = sample0;
  5.2265 +            eps -= dstsize;
  5.2266 +        }
  5.2267 +    }
  5.2268 +    cvt->len_cvt = dstsize;
  5.2269 +    if (cvt->filters[++cvt->filter_index]) {
  5.2270 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2271 +    }
  5.2272 +}
  5.2273 +
  5.2274 +static void SDLCALL
  5.2275 +SDL_Downsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2276 +{
  5.2277 +#ifdef DEBUG_CONVERT
  5.2278 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 6 channels.\n", cvt->rate_incr);
  5.2279 +#endif
  5.2280 +
  5.2281 +    const int srcsize = cvt->len_cvt - 192;
  5.2282 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2283 +    register int eps = 0;
  5.2284 +    Uint16 *dst = (Uint16 *) cvt->buf;
  5.2285 +    const Uint16 *src = (Uint16 *) cvt->buf;
  5.2286 +    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  5.2287 +    Uint16 sample0 = SDL_SwapBE16(src[0]);
  5.2288 +    Uint16 sample1 = SDL_SwapBE16(src[1]);
  5.2289 +    Uint16 sample2 = SDL_SwapBE16(src[2]);
  5.2290 +    Uint16 sample3 = SDL_SwapBE16(src[3]);
  5.2291 +    Uint16 sample4 = SDL_SwapBE16(src[4]);
  5.2292 +    Uint16 sample5 = SDL_SwapBE16(src[5]);
  5.2293 +    Uint16 last_sample0 = sample0;
  5.2294 +    Uint16 last_sample1 = sample1;
  5.2295 +    Uint16 last_sample2 = sample2;
  5.2296 +    Uint16 last_sample3 = sample3;
  5.2297 +    Uint16 last_sample4 = sample4;
  5.2298 +    Uint16 last_sample5 = sample5;
  5.2299 +    while (dst != target) {
  5.2300 +        src += 6;
  5.2301 +        eps += dstsize;
  5.2302 +        if ((eps << 1) >= srcsize) {
  5.2303 +            dst[0] = SDL_SwapBE16(sample0);
  5.2304 +            dst[1] = SDL_SwapBE16(sample1);
  5.2305 +            dst[2] = SDL_SwapBE16(sample2);
  5.2306 +            dst[3] = SDL_SwapBE16(sample3);
  5.2307 +            dst[4] = SDL_SwapBE16(sample4);
  5.2308 +            dst[5] = SDL_SwapBE16(sample5);
  5.2309 +            dst += 6;
  5.2310 +            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.2311 +            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.2312 +            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  5.2313 +            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  5.2314 +            sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  5.2315 +            sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  5.2316 +            last_sample0 = sample0;
  5.2317 +            last_sample1 = sample1;
  5.2318 +            last_sample2 = sample2;
  5.2319 +            last_sample3 = sample3;
  5.2320 +            last_sample4 = sample4;
  5.2321 +            last_sample5 = sample5;
  5.2322 +            eps -= srcsize;
  5.2323 +        }
  5.2324 +    }
  5.2325 +    cvt->len_cvt = dstsize;
  5.2326 +    if (cvt->filters[++cvt->filter_index]) {
  5.2327 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2328 +    }
  5.2329 +}
  5.2330 +
  5.2331 +static void SDLCALL
  5.2332 +SDL_Upsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2333 +{
  5.2334 +#ifdef DEBUG_CONVERT
  5.2335 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 8 channels.\n", cvt->rate_incr);
  5.2336 +#endif
  5.2337 +
  5.2338 +    const int srcsize = cvt->len_cvt - 256;
  5.2339 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2340 +    register int eps = 0;
  5.2341 +    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
  5.2342 +    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
  5.2343 +    const Uint16 *target = ((const Uint16 *) cvt->buf) - 8;
  5.2344 +    Uint16 sample7 = SDL_SwapBE16(src[7]);
  5.2345 +    Uint16 sample6 = SDL_SwapBE16(src[6]);
  5.2346 +    Uint16 sample5 = SDL_SwapBE16(src[5]);
  5.2347 +    Uint16 sample4 = SDL_SwapBE16(src[4]);
  5.2348 +    Uint16 sample3 = SDL_SwapBE16(src[3]);
  5.2349 +    Uint16 sample2 = SDL_SwapBE16(src[2]);
  5.2350 +    Uint16 sample1 = SDL_SwapBE16(src[1]);
  5.2351 +    Uint16 sample0 = SDL_SwapBE16(src[0]);
  5.2352 +    Uint16 last_sample7 = sample7;
  5.2353 +    Uint16 last_sample6 = sample6;
  5.2354 +    Uint16 last_sample5 = sample5;
  5.2355 +    Uint16 last_sample4 = sample4;
  5.2356 +    Uint16 last_sample3 = sample3;
  5.2357 +    Uint16 last_sample2 = sample2;
  5.2358 +    Uint16 last_sample1 = sample1;
  5.2359 +    Uint16 last_sample0 = sample0;
  5.2360 +    while (dst != target) {
  5.2361 +        dst[7] = SDL_SwapBE16(sample7);
  5.2362 +        dst[6] = SDL_SwapBE16(sample6);
  5.2363 +        dst[5] = SDL_SwapBE16(sample5);
  5.2364 +        dst[4] = SDL_SwapBE16(sample4);
  5.2365 +        dst[3] = SDL_SwapBE16(sample3);
  5.2366 +        dst[2] = SDL_SwapBE16(sample2);
  5.2367 +        dst[1] = SDL_SwapBE16(sample1);
  5.2368 +        dst[0] = SDL_SwapBE16(sample0);
  5.2369 +        dst -= 8;
  5.2370 +        eps += srcsize;
  5.2371 +        if ((eps << 1) >= dstsize) {
  5.2372 +            src -= 8;
  5.2373 +            sample7 = (Uint16) ((((Sint32) SDL_SwapBE16(src[7])) + ((Sint32) last_sample7)) >> 1);
  5.2374 +            sample6 = (Uint16) ((((Sint32) SDL_SwapBE16(src[6])) + ((Sint32) last_sample6)) >> 1);
  5.2375 +            sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  5.2376 +            sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  5.2377 +            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  5.2378 +            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  5.2379 +            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.2380 +            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.2381 +            last_sample7 = sample7;
  5.2382 +            last_sample6 = sample6;
  5.2383 +            last_sample5 = sample5;
  5.2384 +            last_sample4 = sample4;
  5.2385 +            last_sample3 = sample3;
  5.2386 +            last_sample2 = sample2;
  5.2387 +            last_sample1 = sample1;
  5.2388 +            last_sample0 = sample0;
  5.2389 +            eps -= dstsize;
  5.2390 +        }
  5.2391 +    }
  5.2392 +    cvt->len_cvt = dstsize;
  5.2393 +    if (cvt->filters[++cvt->filter_index]) {
  5.2394 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2395 +    }
  5.2396 +}
  5.2397 +
  5.2398 +static void SDLCALL
  5.2399 +SDL_Downsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2400 +{
  5.2401 +#ifdef DEBUG_CONVERT
  5.2402 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 8 channels.\n", cvt->rate_incr);
  5.2403 +#endif
  5.2404 +
  5.2405 +    const int srcsize = cvt->len_cvt - 256;
  5.2406 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2407 +    register int eps = 0;
  5.2408 +    Uint16 *dst = (Uint16 *) cvt->buf;
  5.2409 +    const Uint16 *src = (Uint16 *) cvt->buf;
  5.2410 +    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  5.2411 +    Uint16 sample0 = SDL_SwapBE16(src[0]);
  5.2412 +    Uint16 sample1 = SDL_SwapBE16(src[1]);
  5.2413 +    Uint16 sample2 = SDL_SwapBE16(src[2]);
  5.2414 +    Uint16 sample3 = SDL_SwapBE16(src[3]);
  5.2415 +    Uint16 sample4 = SDL_SwapBE16(src[4]);
  5.2416 +    Uint16 sample5 = SDL_SwapBE16(src[5]);
  5.2417 +    Uint16 sample6 = SDL_SwapBE16(src[6]);
  5.2418 +    Uint16 sample7 = SDL_SwapBE16(src[7]);
  5.2419 +    Uint16 last_sample0 = sample0;
  5.2420 +    Uint16 last_sample1 = sample1;
  5.2421 +    Uint16 last_sample2 = sample2;
  5.2422 +    Uint16 last_sample3 = sample3;
  5.2423 +    Uint16 last_sample4 = sample4;
  5.2424 +    Uint16 last_sample5 = sample5;
  5.2425 +    Uint16 last_sample6 = sample6;
  5.2426 +    Uint16 last_sample7 = sample7;
  5.2427 +    while (dst != target) {
  5.2428 +        src += 8;
  5.2429 +        eps += dstsize;
  5.2430 +        if ((eps << 1) >= srcsize) {
  5.2431 +            dst[0] = SDL_SwapBE16(sample0);
  5.2432 +            dst[1] = SDL_SwapBE16(sample1);
  5.2433 +            dst[2] = SDL_SwapBE16(sample2);
  5.2434 +            dst[3] = SDL_SwapBE16(sample3);
  5.2435 +            dst[4] = SDL_SwapBE16(sample4);
  5.2436 +            dst[5] = SDL_SwapBE16(sample5);
  5.2437 +            dst[6] = SDL_SwapBE16(sample6);
  5.2438 +            dst[7] = SDL_SwapBE16(sample7);
  5.2439 +            dst += 8;
  5.2440 +            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
  5.2441 +            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
  5.2442 +            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
  5.2443 +            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
  5.2444 +            sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
  5.2445 +            sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
  5.2446 +            sample6 = (Uint16) ((((Sint32) SDL_SwapBE16(src[6])) + ((Sint32) last_sample6)) >> 1);
  5.2447 +            sample7 = (Uint16) ((((Sint32) SDL_SwapBE16(src[7])) + ((Sint32) last_sample7)) >> 1);
  5.2448 +            last_sample0 = sample0;
  5.2449 +            last_sample1 = sample1;
  5.2450 +            last_sample2 = sample2;
  5.2451 +            last_sample3 = sample3;
  5.2452 +            last_sample4 = sample4;
  5.2453 +            last_sample5 = sample5;
  5.2454 +            last_sample6 = sample6;
  5.2455 +            last_sample7 = sample7;
  5.2456 +            eps -= srcsize;
  5.2457 +        }
  5.2458 +    }
  5.2459 +    cvt->len_cvt = dstsize;
  5.2460 +    if (cvt->filters[++cvt->filter_index]) {
  5.2461 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2462 +    }
  5.2463 +}
  5.2464 +
  5.2465 +static void SDLCALL
  5.2466 +SDL_Upsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2467 +{
  5.2468 +#ifdef DEBUG_CONVERT
  5.2469 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 1 channels.\n", cvt->rate_incr);
  5.2470 +#endif
  5.2471 +
  5.2472 +    const int srcsize = cvt->len_cvt - 32;
  5.2473 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2474 +    register int eps = 0;
  5.2475 +    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
  5.2476 +    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  5.2477 +    const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
  5.2478 +    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  5.2479 +    Sint16 last_sample0 = sample0;
  5.2480 +    while (dst != target) {
  5.2481 +        dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  5.2482 +        dst--;
  5.2483 +        eps += srcsize;
  5.2484 +        if ((eps << 1) >= dstsize) {
  5.2485 +            src--;
  5.2486 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.2487 +            last_sample0 = sample0;
  5.2488 +            eps -= dstsize;
  5.2489 +        }
  5.2490 +    }
  5.2491 +    cvt->len_cvt = dstsize;
  5.2492 +    if (cvt->filters[++cvt->filter_index]) {
  5.2493 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2494 +    }
  5.2495 +}
  5.2496 +
  5.2497 +static void SDLCALL
  5.2498 +SDL_Downsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2499 +{
  5.2500 +#ifdef DEBUG_CONVERT
  5.2501 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 1 channels.\n", cvt->rate_incr);
  5.2502 +#endif
  5.2503 +
  5.2504 +    const int srcsize = cvt->len_cvt - 32;
  5.2505 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2506 +    register int eps = 0;
  5.2507 +    Sint16 *dst = (Sint16 *) cvt->buf;
  5.2508 +    const Sint16 *src = (Sint16 *) cvt->buf;
  5.2509 +    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  5.2510 +    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  5.2511 +    Sint16 last_sample0 = sample0;
  5.2512 +    while (dst != target) {
  5.2513 +        src++;
  5.2514 +        eps += dstsize;
  5.2515 +        if ((eps << 1) >= srcsize) {
  5.2516 +            dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  5.2517 +            dst++;
  5.2518 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.2519 +            last_sample0 = sample0;
  5.2520 +            eps -= srcsize;
  5.2521 +        }
  5.2522 +    }
  5.2523 +    cvt->len_cvt = dstsize;
  5.2524 +    if (cvt->filters[++cvt->filter_index]) {
  5.2525 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2526 +    }
  5.2527 +}
  5.2528 +
  5.2529 +static void SDLCALL
  5.2530 +SDL_Upsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2531 +{
  5.2532 +#ifdef DEBUG_CONVERT
  5.2533 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 2 channels.\n", cvt->rate_incr);
  5.2534 +#endif
  5.2535 +
  5.2536 +    const int srcsize = cvt->len_cvt - 64;
  5.2537 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2538 +    register int eps = 0;
  5.2539 +    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
  5.2540 +    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
  5.2541 +    const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
  5.2542 +    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  5.2543 +    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  5.2544 +    Sint16 last_sample1 = sample1;
  5.2545 +    Sint16 last_sample0 = sample0;
  5.2546 +    while (dst != target) {
  5.2547 +        dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  5.2548 +        dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  5.2549 +        dst -= 2;
  5.2550 +        eps += srcsize;
  5.2551 +        if ((eps << 1) >= dstsize) {
  5.2552 +            src -= 2;
  5.2553 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.2554 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.2555 +            last_sample1 = sample1;
  5.2556 +            last_sample0 = sample0;
  5.2557 +            eps -= dstsize;
  5.2558 +        }
  5.2559 +    }
  5.2560 +    cvt->len_cvt = dstsize;
  5.2561 +    if (cvt->filters[++cvt->filter_index]) {
  5.2562 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2563 +    }
  5.2564 +}
  5.2565 +
  5.2566 +static void SDLCALL
  5.2567 +SDL_Downsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2568 +{
  5.2569 +#ifdef DEBUG_CONVERT
  5.2570 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 2 channels.\n", cvt->rate_incr);
  5.2571 +#endif
  5.2572 +
  5.2573 +    const int srcsize = cvt->len_cvt - 64;
  5.2574 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2575 +    register int eps = 0;
  5.2576 +    Sint16 *dst = (Sint16 *) cvt->buf;
  5.2577 +    const Sint16 *src = (Sint16 *) cvt->buf;
  5.2578 +    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  5.2579 +    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  5.2580 +    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  5.2581 +    Sint16 last_sample0 = sample0;
  5.2582 +    Sint16 last_sample1 = sample1;
  5.2583 +    while (dst != target) {
  5.2584 +        src += 2;
  5.2585 +        eps += dstsize;
  5.2586 +        if ((eps << 1) >= srcsize) {
  5.2587 +            dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  5.2588 +            dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  5.2589 +            dst += 2;
  5.2590 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.2591 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.2592 +            last_sample0 = sample0;
  5.2593 +            last_sample1 = sample1;
  5.2594 +            eps -= srcsize;
  5.2595 +        }
  5.2596 +    }
  5.2597 +    cvt->len_cvt = dstsize;
  5.2598 +    if (cvt->filters[++cvt->filter_index]) {
  5.2599 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2600 +    }
  5.2601 +}
  5.2602 +
  5.2603 +static void SDLCALL
  5.2604 +SDL_Upsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2605 +{
  5.2606 +#ifdef DEBUG_CONVERT
  5.2607 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 4 channels.\n", cvt->rate_incr);
  5.2608 +#endif
  5.2609 +
  5.2610 +    const int srcsize = cvt->len_cvt - 128;
  5.2611 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2612 +    register int eps = 0;
  5.2613 +    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
  5.2614 +    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
  5.2615 +    const Sint16 *target = ((const Sint16 *) cvt->buf) - 4;
  5.2616 +    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
  5.2617 +    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
  5.2618 +    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  5.2619 +    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  5.2620 +    Sint16 last_sample3 = sample3;
  5.2621 +    Sint16 last_sample2 = sample2;
  5.2622 +    Sint16 last_sample1 = sample1;
  5.2623 +    Sint16 last_sample0 = sample0;
  5.2624 +    while (dst != target) {
  5.2625 +        dst[3] = ((Sint16) SDL_SwapBE16(sample3));
  5.2626 +        dst[2] = ((Sint16) SDL_SwapBE16(sample2));
  5.2627 +        dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  5.2628 +        dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  5.2629 +        dst -= 4;
  5.2630 +        eps += srcsize;
  5.2631 +        if ((eps << 1) >= dstsize) {
  5.2632 +            src -= 4;
  5.2633 +            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  5.2634 +            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  5.2635 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.2636 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.2637 +            last_sample3 = sample3;
  5.2638 +            last_sample2 = sample2;
  5.2639 +            last_sample1 = sample1;
  5.2640 +            last_sample0 = sample0;
  5.2641 +            eps -= dstsize;
  5.2642 +        }
  5.2643 +    }
  5.2644 +    cvt->len_cvt = dstsize;
  5.2645 +    if (cvt->filters[++cvt->filter_index]) {
  5.2646 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2647 +    }
  5.2648 +}
  5.2649 +
  5.2650 +static void SDLCALL
  5.2651 +SDL_Downsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2652 +{
  5.2653 +#ifdef DEBUG_CONVERT
  5.2654 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 4 channels.\n", cvt->rate_incr);
  5.2655 +#endif
  5.2656 +
  5.2657 +    const int srcsize = cvt->len_cvt - 128;
  5.2658 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2659 +    register int eps = 0;
  5.2660 +    Sint16 *dst = (Sint16 *) cvt->buf;
  5.2661 +    const Sint16 *src = (Sint16 *) cvt->buf;
  5.2662 +    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  5.2663 +    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  5.2664 +    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  5.2665 +    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
  5.2666 +    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
  5.2667 +    Sint16 last_sample0 = sample0;
  5.2668 +    Sint16 last_sample1 = sample1;
  5.2669 +    Sint16 last_sample2 = sample2;
  5.2670 +    Sint16 last_sample3 = sample3;
  5.2671 +    while (dst != target) {
  5.2672 +        src += 4;
  5.2673 +        eps += dstsize;
  5.2674 +        if ((eps << 1) >= srcsize) {
  5.2675 +            dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  5.2676 +            dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  5.2677 +            dst[2] = ((Sint16) SDL_SwapBE16(sample2));
  5.2678 +            dst[3] = ((Sint16) SDL_SwapBE16(sample3));
  5.2679 +            dst += 4;
  5.2680 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.2681 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.2682 +            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  5.2683 +            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  5.2684 +            last_sample0 = sample0;
  5.2685 +            last_sample1 = sample1;
  5.2686 +            last_sample2 = sample2;
  5.2687 +            last_sample3 = sample3;
  5.2688 +            eps -= srcsize;
  5.2689 +        }
  5.2690 +    }
  5.2691 +    cvt->len_cvt = dstsize;
  5.2692 +    if (cvt->filters[++cvt->filter_index]) {
  5.2693 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2694 +    }
  5.2695 +}
  5.2696 +
  5.2697 +static void SDLCALL
  5.2698 +SDL_Upsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2699 +{
  5.2700 +#ifdef DEBUG_CONVERT
  5.2701 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 6 channels.\n", cvt->rate_incr);
  5.2702 +#endif
  5.2703 +
  5.2704 +    const int srcsize = cvt->len_cvt - 192;
  5.2705 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2706 +    register int eps = 0;
  5.2707 +    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
  5.2708 +    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
  5.2709 +    const Sint16 *target = ((const Sint16 *) cvt->buf) - 6;
  5.2710 +    Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
  5.2711 +    Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
  5.2712 +    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
  5.2713 +    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
  5.2714 +    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  5.2715 +    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  5.2716 +    Sint16 last_sample5 = sample5;
  5.2717 +    Sint16 last_sample4 = sample4;
  5.2718 +    Sint16 last_sample3 = sample3;
  5.2719 +    Sint16 last_sample2 = sample2;
  5.2720 +    Sint16 last_sample1 = sample1;
  5.2721 +    Sint16 last_sample0 = sample0;
  5.2722 +    while (dst != target) {
  5.2723 +        dst[5] = ((Sint16) SDL_SwapBE16(sample5));
  5.2724 +        dst[4] = ((Sint16) SDL_SwapBE16(sample4));
  5.2725 +        dst[3] = ((Sint16) SDL_SwapBE16(sample3));
  5.2726 +        dst[2] = ((Sint16) SDL_SwapBE16(sample2));
  5.2727 +        dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  5.2728 +        dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  5.2729 +        dst -= 6;
  5.2730 +        eps += srcsize;
  5.2731 +        if ((eps << 1) >= dstsize) {
  5.2732 +            src -= 6;
  5.2733 +            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  5.2734 +            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  5.2735 +            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  5.2736 +            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  5.2737 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.2738 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.2739 +            last_sample5 = sample5;
  5.2740 +            last_sample4 = sample4;
  5.2741 +            last_sample3 = sample3;
  5.2742 +            last_sample2 = sample2;
  5.2743 +            last_sample1 = sample1;
  5.2744 +            last_sample0 = sample0;
  5.2745 +            eps -= dstsize;
  5.2746 +        }
  5.2747 +    }
  5.2748 +    cvt->len_cvt = dstsize;
  5.2749 +    if (cvt->filters[++cvt->filter_index]) {
  5.2750 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2751 +    }
  5.2752 +}
  5.2753 +
  5.2754 +static void SDLCALL
  5.2755 +SDL_Downsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2756 +{
  5.2757 +#ifdef DEBUG_CONVERT
  5.2758 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 6 channels.\n", cvt->rate_incr);
  5.2759 +#endif
  5.2760 +
  5.2761 +    const int srcsize = cvt->len_cvt - 192;
  5.2762 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2763 +    register int eps = 0;
  5.2764 +    Sint16 *dst = (Sint16 *) cvt->buf;
  5.2765 +    const Sint16 *src = (Sint16 *) cvt->buf;
  5.2766 +    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  5.2767 +    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  5.2768 +    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  5.2769 +    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
  5.2770 +    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
  5.2771 +    Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
  5.2772 +    Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
  5.2773 +    Sint16 last_sample0 = sample0;
  5.2774 +    Sint16 last_sample1 = sample1;
  5.2775 +    Sint16 last_sample2 = sample2;
  5.2776 +    Sint16 last_sample3 = sample3;
  5.2777 +    Sint16 last_sample4 = sample4;
  5.2778 +    Sint16 last_sample5 = sample5;
  5.2779 +    while (dst != target) {
  5.2780 +        src += 6;
  5.2781 +        eps += dstsize;
  5.2782 +        if ((eps << 1) >= srcsize) {
  5.2783 +            dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  5.2784 +            dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  5.2785 +            dst[2] = ((Sint16) SDL_SwapBE16(sample2));
  5.2786 +            dst[3] = ((Sint16) SDL_SwapBE16(sample3));
  5.2787 +            dst[4] = ((Sint16) SDL_SwapBE16(sample4));
  5.2788 +            dst[5] = ((Sint16) SDL_SwapBE16(sample5));
  5.2789 +            dst += 6;
  5.2790 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.2791 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.2792 +            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  5.2793 +            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  5.2794 +            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  5.2795 +            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  5.2796 +            last_sample0 = sample0;
  5.2797 +            last_sample1 = sample1;
  5.2798 +            last_sample2 = sample2;
  5.2799 +            last_sample3 = sample3;
  5.2800 +            last_sample4 = sample4;
  5.2801 +            last_sample5 = sample5;
  5.2802 +            eps -= srcsize;
  5.2803 +        }
  5.2804 +    }
  5.2805 +    cvt->len_cvt = dstsize;
  5.2806 +    if (cvt->filters[++cvt->filter_index]) {
  5.2807 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2808 +    }
  5.2809 +}
  5.2810 +
  5.2811 +static void SDLCALL
  5.2812 +SDL_Upsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2813 +{
  5.2814 +#ifdef DEBUG_CONVERT
  5.2815 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 8 channels.\n", cvt->rate_incr);
  5.2816 +#endif
  5.2817 +
  5.2818 +    const int srcsize = cvt->len_cvt - 256;
  5.2819 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2820 +    register int eps = 0;
  5.2821 +    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
  5.2822 +    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
  5.2823 +    const Sint16 *target = ((const Sint16 *) cvt->buf) - 8;
  5.2824 +    Sint16 sample7 = ((Sint16) SDL_SwapBE16(src[7]));
  5.2825 +    Sint16 sample6 = ((Sint16) SDL_SwapBE16(src[6]));
  5.2826 +    Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
  5.2827 +    Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
  5.2828 +    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
  5.2829 +    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
  5.2830 +    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  5.2831 +    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  5.2832 +    Sint16 last_sample7 = sample7;
  5.2833 +    Sint16 last_sample6 = sample6;
  5.2834 +    Sint16 last_sample5 = sample5;
  5.2835 +    Sint16 last_sample4 = sample4;
  5.2836 +    Sint16 last_sample3 = sample3;
  5.2837 +    Sint16 last_sample2 = sample2;
  5.2838 +    Sint16 last_sample1 = sample1;
  5.2839 +    Sint16 last_sample0 = sample0;
  5.2840 +    while (dst != target) {
  5.2841 +        dst[7] = ((Sint16) SDL_SwapBE16(sample7));
  5.2842 +        dst[6] = ((Sint16) SDL_SwapBE16(sample6));
  5.2843 +        dst[5] = ((Sint16) SDL_SwapBE16(sample5));
  5.2844 +        dst[4] = ((Sint16) SDL_SwapBE16(sample4));
  5.2845 +        dst[3] = ((Sint16) SDL_SwapBE16(sample3));
  5.2846 +        dst[2] = ((Sint16) SDL_SwapBE16(sample2));
  5.2847 +        dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  5.2848 +        dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  5.2849 +        dst -= 8;
  5.2850 +        eps += srcsize;
  5.2851 +        if ((eps << 1) >= dstsize) {
  5.2852 +            src -= 8;
  5.2853 +            sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
  5.2854 +            sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
  5.2855 +            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  5.2856 +            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  5.2857 +            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  5.2858 +            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  5.2859 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.2860 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.2861 +            last_sample7 = sample7;
  5.2862 +            last_sample6 = sample6;
  5.2863 +            last_sample5 = sample5;
  5.2864 +            last_sample4 = sample4;
  5.2865 +            last_sample3 = sample3;
  5.2866 +            last_sample2 = sample2;
  5.2867 +            last_sample1 = sample1;
  5.2868 +            last_sample0 = sample0;
  5.2869 +            eps -= dstsize;
  5.2870 +        }
  5.2871 +    }
  5.2872 +    cvt->len_cvt = dstsize;
  5.2873 +    if (cvt->filters[++cvt->filter_index]) {
  5.2874 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2875 +    }
  5.2876 +}
  5.2877 +
  5.2878 +static void SDLCALL
  5.2879 +SDL_Downsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2880 +{
  5.2881 +#ifdef DEBUG_CONVERT
  5.2882 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 8 channels.\n", cvt->rate_incr);
  5.2883 +#endif
  5.2884 +
  5.2885 +    const int srcsize = cvt->len_cvt - 256;
  5.2886 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2887 +    register int eps = 0;
  5.2888 +    Sint16 *dst = (Sint16 *) cvt->buf;
  5.2889 +    const Sint16 *src = (Sint16 *) cvt->buf;
  5.2890 +    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  5.2891 +    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
  5.2892 +    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
  5.2893 +    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
  5.2894 +    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
  5.2895 +    Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
  5.2896 +    Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
  5.2897 +    Sint16 sample6 = ((Sint16) SDL_SwapBE16(src[6]));
  5.2898 +    Sint16 sample7 = ((Sint16) SDL_SwapBE16(src[7]));
  5.2899 +    Sint16 last_sample0 = sample0;
  5.2900 +    Sint16 last_sample1 = sample1;
  5.2901 +    Sint16 last_sample2 = sample2;
  5.2902 +    Sint16 last_sample3 = sample3;
  5.2903 +    Sint16 last_sample4 = sample4;
  5.2904 +    Sint16 last_sample5 = sample5;
  5.2905 +    Sint16 last_sample6 = sample6;
  5.2906 +    Sint16 last_sample7 = sample7;
  5.2907 +    while (dst != target) {
  5.2908 +        src += 8;
  5.2909 +        eps += dstsize;
  5.2910 +        if ((eps << 1) >= srcsize) {
  5.2911 +            dst[0] = ((Sint16) SDL_SwapBE16(sample0));
  5.2912 +            dst[1] = ((Sint16) SDL_SwapBE16(sample1));
  5.2913 +            dst[2] = ((Sint16) SDL_SwapBE16(sample2));
  5.2914 +            dst[3] = ((Sint16) SDL_SwapBE16(sample3));
  5.2915 +            dst[4] = ((Sint16) SDL_SwapBE16(sample4));
  5.2916 +            dst[5] = ((Sint16) SDL_SwapBE16(sample5));
  5.2917 +            dst[6] = ((Sint16) SDL_SwapBE16(sample6));
  5.2918 +            dst[7] = ((Sint16) SDL_SwapBE16(sample7));
  5.2919 +            dst += 8;
  5.2920 +            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
  5.2921 +            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
  5.2922 +            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
  5.2923 +            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
  5.2924 +            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
  5.2925 +            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
  5.2926 +            sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
  5.2927 +            sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
  5.2928 +            last_sample0 = sample0;
  5.2929 +            last_sample1 = sample1;
  5.2930 +            last_sample2 = sample2;
  5.2931 +            last_sample3 = sample3;
  5.2932 +            last_sample4 = sample4;
  5.2933 +            last_sample5 = sample5;
  5.2934 +            last_sample6 = sample6;
  5.2935 +            last_sample7 = sample7;
  5.2936 +            eps -= srcsize;
  5.2937 +        }
  5.2938 +    }
  5.2939 +    cvt->len_cvt = dstsize;
  5.2940 +    if (cvt->filters[++cvt->filter_index]) {
  5.2941 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2942 +    }
  5.2943 +}
  5.2944 +
  5.2945 +static void SDLCALL
  5.2946 +SDL_Upsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2947 +{
  5.2948 +#ifdef DEBUG_CONVERT
  5.2949 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 1 channels.\n", cvt->rate_incr);
  5.2950 +#endif
  5.2951 +
  5.2952 +    const int srcsize = cvt->len_cvt - 64;
  5.2953 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2954 +    register int eps = 0;
  5.2955 +    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
  5.2956 +    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
  5.2957 +    const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
  5.2958 +    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  5.2959 +    Sint32 last_sample0 = sample0;
  5.2960 +    while (dst != target) {
  5.2961 +        dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  5.2962 +        dst--;
  5.2963 +        eps += srcsize;
  5.2964 +        if ((eps << 1) >= dstsize) {
  5.2965 +            src--;
  5.2966 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.2967 +            last_sample0 = sample0;
  5.2968 +            eps -= dstsize;
  5.2969 +        }
  5.2970 +    }
  5.2971 +    cvt->len_cvt = dstsize;
  5.2972 +    if (cvt->filters[++cvt->filter_index]) {
  5.2973 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.2974 +    }
  5.2975 +}
  5.2976 +
  5.2977 +static void SDLCALL
  5.2978 +SDL_Downsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.2979 +{
  5.2980 +#ifdef DEBUG_CONVERT
  5.2981 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 1 channels.\n", cvt->rate_incr);
  5.2982 +#endif
  5.2983 +
  5.2984 +    const int srcsize = cvt->len_cvt - 64;
  5.2985 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.2986 +    register int eps = 0;
  5.2987 +    Sint32 *dst = (Sint32 *) cvt->buf;
  5.2988 +    const Sint32 *src = (Sint32 *) cvt->buf;
  5.2989 +    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  5.2990 +    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  5.2991 +    Sint32 last_sample0 = sample0;
  5.2992 +    while (dst != target) {
  5.2993 +        src++;
  5.2994 +        eps += dstsize;
  5.2995 +        if ((eps << 1) >= srcsize) {
  5.2996 +            dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  5.2997 +            dst++;
  5.2998 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.2999 +            last_sample0 = sample0;
  5.3000 +            eps -= srcsize;
  5.3001 +        }
  5.3002 +    }
  5.3003 +    cvt->len_cvt = dstsize;
  5.3004 +    if (cvt->filters[++cvt->filter_index]) {
  5.3005 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3006 +    }
  5.3007 +}
  5.3008 +
  5.3009 +static void SDLCALL
  5.3010 +SDL_Upsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3011 +{
  5.3012 +#ifdef DEBUG_CONVERT
  5.3013 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 2 channels.\n", cvt->rate_incr);
  5.3014 +#endif
  5.3015 +
  5.3016 +    const int srcsize = cvt->len_cvt - 128;
  5.3017 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3018 +    register int eps = 0;
  5.3019 +    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
  5.3020 +    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
  5.3021 +    const Sint32 *target = ((const Sint32 *) cvt->buf) - 2;
  5.3022 +    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  5.3023 +    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  5.3024 +    Sint32 last_sample1 = sample1;
  5.3025 +    Sint32 last_sample0 = sample0;
  5.3026 +    while (dst != target) {
  5.3027 +        dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  5.3028 +        dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  5.3029 +        dst -= 2;
  5.3030 +        eps += srcsize;
  5.3031 +        if ((eps << 1) >= dstsize) {
  5.3032 +            src -= 2;
  5.3033 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3034 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3035 +            last_sample1 = sample1;
  5.3036 +            last_sample0 = sample0;
  5.3037 +            eps -= dstsize;
  5.3038 +        }
  5.3039 +    }
  5.3040 +    cvt->len_cvt = dstsize;
  5.3041 +    if (cvt->filters[++cvt->filter_index]) {
  5.3042 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3043 +    }
  5.3044 +}
  5.3045 +
  5.3046 +static void SDLCALL
  5.3047 +SDL_Downsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3048 +{
  5.3049 +#ifdef DEBUG_CONVERT
  5.3050 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 2 channels.\n", cvt->rate_incr);
  5.3051 +#endif
  5.3052 +
  5.3053 +    const int srcsize = cvt->len_cvt - 128;
  5.3054 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3055 +    register int eps = 0;
  5.3056 +    Sint32 *dst = (Sint32 *) cvt->buf;
  5.3057 +    const Sint32 *src = (Sint32 *) cvt->buf;
  5.3058 +    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  5.3059 +    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  5.3060 +    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  5.3061 +    Sint32 last_sample0 = sample0;
  5.3062 +    Sint32 last_sample1 = sample1;
  5.3063 +    while (dst != target) {
  5.3064 +        src += 2;
  5.3065 +        eps += dstsize;
  5.3066 +        if ((eps << 1) >= srcsize) {
  5.3067 +            dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  5.3068 +            dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  5.3069 +            dst += 2;
  5.3070 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3071 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3072 +            last_sample0 = sample0;
  5.3073 +            last_sample1 = sample1;
  5.3074 +            eps -= srcsize;
  5.3075 +        }
  5.3076 +    }
  5.3077 +    cvt->len_cvt = dstsize;
  5.3078 +    if (cvt->filters[++cvt->filter_index]) {
  5.3079 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3080 +    }
  5.3081 +}
  5.3082 +
  5.3083 +static void SDLCALL
  5.3084 +SDL_Upsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3085 +{
  5.3086 +#ifdef DEBUG_CONVERT
  5.3087 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 4 channels.\n", cvt->rate_incr);
  5.3088 +#endif
  5.3089 +
  5.3090 +    const int srcsize = cvt->len_cvt - 256;
  5.3091 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3092 +    register int eps = 0;
  5.3093 +    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
  5.3094 +    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
  5.3095 +    const Sint32 *target = ((const Sint32 *) cvt->buf) - 4;
  5.3096 +    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
  5.3097 +    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
  5.3098 +    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  5.3099 +    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  5.3100 +    Sint32 last_sample3 = sample3;
  5.3101 +    Sint32 last_sample2 = sample2;
  5.3102 +    Sint32 last_sample1 = sample1;
  5.3103 +    Sint32 last_sample0 = sample0;
  5.3104 +    while (dst != target) {
  5.3105 +        dst[3] = ((Sint32) SDL_SwapLE32(sample3));
  5.3106 +        dst[2] = ((Sint32) SDL_SwapLE32(sample2));
  5.3107 +        dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  5.3108 +        dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  5.3109 +        dst -= 4;
  5.3110 +        eps += srcsize;
  5.3111 +        if ((eps << 1) >= dstsize) {
  5.3112 +            src -= 4;
  5.3113 +            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  5.3114 +            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  5.3115 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3116 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3117 +            last_sample3 = sample3;
  5.3118 +            last_sample2 = sample2;
  5.3119 +            last_sample1 = sample1;
  5.3120 +            last_sample0 = sample0;
  5.3121 +            eps -= dstsize;
  5.3122 +        }
  5.3123 +    }
  5.3124 +    cvt->len_cvt = dstsize;
  5.3125 +    if (cvt->filters[++cvt->filter_index]) {
  5.3126 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3127 +    }
  5.3128 +}
  5.3129 +
  5.3130 +static void SDLCALL
  5.3131 +SDL_Downsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3132 +{
  5.3133 +#ifdef DEBUG_CONVERT
  5.3134 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 4 channels.\n", cvt->rate_incr);
  5.3135 +#endif
  5.3136 +
  5.3137 +    const int srcsize = cvt->len_cvt - 256;
  5.3138 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3139 +    register int eps = 0;
  5.3140 +    Sint32 *dst = (Sint32 *) cvt->buf;
  5.3141 +    const Sint32 *src = (Sint32 *) cvt->buf;
  5.3142 +    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  5.3143 +    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  5.3144 +    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  5.3145 +    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
  5.3146 +    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
  5.3147 +    Sint32 last_sample0 = sample0;
  5.3148 +    Sint32 last_sample1 = sample1;
  5.3149 +    Sint32 last_sample2 = sample2;
  5.3150 +    Sint32 last_sample3 = sample3;
  5.3151 +    while (dst != target) {
  5.3152 +        src += 4;
  5.3153 +        eps += dstsize;
  5.3154 +        if ((eps << 1) >= srcsize) {
  5.3155 +            dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  5.3156 +            dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  5.3157 +            dst[2] = ((Sint32) SDL_SwapLE32(sample2));
  5.3158 +            dst[3] = ((Sint32) SDL_SwapLE32(sample3));
  5.3159 +            dst += 4;
  5.3160 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3161 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3162 +            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  5.3163 +            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  5.3164 +            last_sample0 = sample0;
  5.3165 +            last_sample1 = sample1;
  5.3166 +            last_sample2 = sample2;
  5.3167 +            last_sample3 = sample3;
  5.3168 +            eps -= srcsize;
  5.3169 +        }
  5.3170 +    }
  5.3171 +    cvt->len_cvt = dstsize;
  5.3172 +    if (cvt->filters[++cvt->filter_index]) {
  5.3173 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3174 +    }
  5.3175 +}
  5.3176 +
  5.3177 +static void SDLCALL
  5.3178 +SDL_Upsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3179 +{
  5.3180 +#ifdef DEBUG_CONVERT
  5.3181 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 6 channels.\n", cvt->rate_incr);
  5.3182 +#endif
  5.3183 +
  5.3184 +    const int srcsize = cvt->len_cvt - 384;
  5.3185 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3186 +    register int eps = 0;
  5.3187 +    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
  5.3188 +    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
  5.3189 +    const Sint32 *target = ((const Sint32 *) cvt->buf) - 6;
  5.3190 +    Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
  5.3191 +    Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
  5.3192 +    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
  5.3193 +    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
  5.3194 +    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  5.3195 +    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  5.3196 +    Sint32 last_sample5 = sample5;
  5.3197 +    Sint32 last_sample4 = sample4;
  5.3198 +    Sint32 last_sample3 = sample3;
  5.3199 +    Sint32 last_sample2 = sample2;
  5.3200 +    Sint32 last_sample1 = sample1;
  5.3201 +    Sint32 last_sample0 = sample0;
  5.3202 +    while (dst != target) {
  5.3203 +        dst[5] = ((Sint32) SDL_SwapLE32(sample5));
  5.3204 +        dst[4] = ((Sint32) SDL_SwapLE32(sample4));
  5.3205 +        dst[3] = ((Sint32) SDL_SwapLE32(sample3));
  5.3206 +        dst[2] = ((Sint32) SDL_SwapLE32(sample2));
  5.3207 +        dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  5.3208 +        dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  5.3209 +        dst -= 6;
  5.3210 +        eps += srcsize;
  5.3211 +        if ((eps << 1) >= dstsize) {
  5.3212 +            src -= 6;
  5.3213 +            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  5.3214 +            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  5.3215 +            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  5.3216 +            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  5.3217 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3218 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3219 +            last_sample5 = sample5;
  5.3220 +            last_sample4 = sample4;
  5.3221 +            last_sample3 = sample3;
  5.3222 +            last_sample2 = sample2;
  5.3223 +            last_sample1 = sample1;
  5.3224 +            last_sample0 = sample0;
  5.3225 +            eps -= dstsize;
  5.3226 +        }
  5.3227 +    }
  5.3228 +    cvt->len_cvt = dstsize;
  5.3229 +    if (cvt->filters[++cvt->filter_index]) {
  5.3230 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3231 +    }
  5.3232 +}
  5.3233 +
  5.3234 +static void SDLCALL
  5.3235 +SDL_Downsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3236 +{
  5.3237 +#ifdef DEBUG_CONVERT
  5.3238 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 6 channels.\n", cvt->rate_incr);
  5.3239 +#endif
  5.3240 +
  5.3241 +    const int srcsize = cvt->len_cvt - 384;
  5.3242 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3243 +    register int eps = 0;
  5.3244 +    Sint32 *dst = (Sint32 *) cvt->buf;
  5.3245 +    const Sint32 *src = (Sint32 *) cvt->buf;
  5.3246 +    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  5.3247 +    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  5.3248 +    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  5.3249 +    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
  5.3250 +    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
  5.3251 +    Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
  5.3252 +    Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
  5.3253 +    Sint32 last_sample0 = sample0;
  5.3254 +    Sint32 last_sample1 = sample1;
  5.3255 +    Sint32 last_sample2 = sample2;
  5.3256 +    Sint32 last_sample3 = sample3;
  5.3257 +    Sint32 last_sample4 = sample4;
  5.3258 +    Sint32 last_sample5 = sample5;
  5.3259 +    while (dst != target) {
  5.3260 +        src += 6;
  5.3261 +        eps += dstsize;
  5.3262 +        if ((eps << 1) >= srcsize) {
  5.3263 +            dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  5.3264 +            dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  5.3265 +            dst[2] = ((Sint32) SDL_SwapLE32(sample2));
  5.3266 +            dst[3] = ((Sint32) SDL_SwapLE32(sample3));
  5.3267 +            dst[4] = ((Sint32) SDL_SwapLE32(sample4));
  5.3268 +            dst[5] = ((Sint32) SDL_SwapLE32(sample5));
  5.3269 +            dst += 6;
  5.3270 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3271 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3272 +            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  5.3273 +            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  5.3274 +            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  5.3275 +            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  5.3276 +            last_sample0 = sample0;
  5.3277 +            last_sample1 = sample1;
  5.3278 +            last_sample2 = sample2;
  5.3279 +            last_sample3 = sample3;
  5.3280 +            last_sample4 = sample4;
  5.3281 +            last_sample5 = sample5;
  5.3282 +            eps -= srcsize;
  5.3283 +        }
  5.3284 +    }
  5.3285 +    cvt->len_cvt = dstsize;
  5.3286 +    if (cvt->filters[++cvt->filter_index]) {
  5.3287 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3288 +    }
  5.3289 +}
  5.3290 +
  5.3291 +static void SDLCALL
  5.3292 +SDL_Upsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3293 +{
  5.3294 +#ifdef DEBUG_CONVERT
  5.3295 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 8 channels.\n", cvt->rate_incr);
  5.3296 +#endif
  5.3297 +
  5.3298 +    const int srcsize = cvt->len_cvt - 512;
  5.3299 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3300 +    register int eps = 0;
  5.3301 +    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
  5.3302 +    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
  5.3303 +    const Sint32 *target = ((const Sint32 *) cvt->buf) - 8;
  5.3304 +    Sint32 sample7 = ((Sint32) SDL_SwapLE32(src[7]));
  5.3305 +    Sint32 sample6 = ((Sint32) SDL_SwapLE32(src[6]));
  5.3306 +    Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
  5.3307 +    Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
  5.3308 +    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
  5.3309 +    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
  5.3310 +    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  5.3311 +    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  5.3312 +    Sint32 last_sample7 = sample7;
  5.3313 +    Sint32 last_sample6 = sample6;
  5.3314 +    Sint32 last_sample5 = sample5;
  5.3315 +    Sint32 last_sample4 = sample4;
  5.3316 +    Sint32 last_sample3 = sample3;
  5.3317 +    Sint32 last_sample2 = sample2;
  5.3318 +    Sint32 last_sample1 = sample1;
  5.3319 +    Sint32 last_sample0 = sample0;
  5.3320 +    while (dst != target) {
  5.3321 +        dst[7] = ((Sint32) SDL_SwapLE32(sample7));
  5.3322 +        dst[6] = ((Sint32) SDL_SwapLE32(sample6));
  5.3323 +        dst[5] = ((Sint32) SDL_SwapLE32(sample5));
  5.3324 +        dst[4] = ((Sint32) SDL_SwapLE32(sample4));
  5.3325 +        dst[3] = ((Sint32) SDL_SwapLE32(sample3));
  5.3326 +        dst[2] = ((Sint32) SDL_SwapLE32(sample2));
  5.3327 +        dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  5.3328 +        dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  5.3329 +        dst -= 8;
  5.3330 +        eps += srcsize;
  5.3331 +        if ((eps << 1) >= dstsize) {
  5.3332 +            src -= 8;
  5.3333 +            sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
  5.3334 +            sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
  5.3335 +            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  5.3336 +            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  5.3337 +            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  5.3338 +            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  5.3339 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3340 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3341 +            last_sample7 = sample7;
  5.3342 +            last_sample6 = sample6;
  5.3343 +            last_sample5 = sample5;
  5.3344 +            last_sample4 = sample4;
  5.3345 +            last_sample3 = sample3;
  5.3346 +            last_sample2 = sample2;
  5.3347 +            last_sample1 = sample1;
  5.3348 +            last_sample0 = sample0;
  5.3349 +            eps -= dstsize;
  5.3350 +        }
  5.3351 +    }
  5.3352 +    cvt->len_cvt = dstsize;
  5.3353 +    if (cvt->filters[++cvt->filter_index]) {
  5.3354 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3355 +    }
  5.3356 +}
  5.3357 +
  5.3358 +static void SDLCALL
  5.3359 +SDL_Downsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3360 +{
  5.3361 +#ifdef DEBUG_CONVERT
  5.3362 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 8 channels.\n", cvt->rate_incr);
  5.3363 +#endif
  5.3364 +
  5.3365 +    const int srcsize = cvt->len_cvt - 512;
  5.3366 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3367 +    register int eps = 0;
  5.3368 +    Sint32 *dst = (Sint32 *) cvt->buf;
  5.3369 +    const Sint32 *src = (Sint32 *) cvt->buf;
  5.3370 +    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  5.3371 +    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
  5.3372 +    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
  5.3373 +    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
  5.3374 +    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
  5.3375 +    Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
  5.3376 +    Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
  5.3377 +    Sint32 sample6 = ((Sint32) SDL_SwapLE32(src[6]));
  5.3378 +    Sint32 sample7 = ((Sint32) SDL_SwapLE32(src[7]));
  5.3379 +    Sint32 last_sample0 = sample0;
  5.3380 +    Sint32 last_sample1 = sample1;
  5.3381 +    Sint32 last_sample2 = sample2;
  5.3382 +    Sint32 last_sample3 = sample3;
  5.3383 +    Sint32 last_sample4 = sample4;
  5.3384 +    Sint32 last_sample5 = sample5;
  5.3385 +    Sint32 last_sample6 = sample6;
  5.3386 +    Sint32 last_sample7 = sample7;
  5.3387 +    while (dst != target) {
  5.3388 +        src += 8;
  5.3389 +        eps += dstsize;
  5.3390 +        if ((eps << 1) >= srcsize) {
  5.3391 +            dst[0] = ((Sint32) SDL_SwapLE32(sample0));
  5.3392 +            dst[1] = ((Sint32) SDL_SwapLE32(sample1));
  5.3393 +            dst[2] = ((Sint32) SDL_SwapLE32(sample2));
  5.3394 +            dst[3] = ((Sint32) SDL_SwapLE32(sample3));
  5.3395 +            dst[4] = ((Sint32) SDL_SwapLE32(sample4));
  5.3396 +            dst[5] = ((Sint32) SDL_SwapLE32(sample5));
  5.3397 +            dst[6] = ((Sint32) SDL_SwapLE32(sample6));
  5.3398 +            dst[7] = ((Sint32) SDL_SwapLE32(sample7));
  5.3399 +            dst += 8;
  5.3400 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3401 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3402 +            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  5.3403 +            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  5.3404 +            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  5.3405 +            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  5.3406 +            sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
  5.3407 +            sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
  5.3408 +            last_sample0 = sample0;
  5.3409 +            last_sample1 = sample1;
  5.3410 +            last_sample2 = sample2;
  5.3411 +            last_sample3 = sample3;
  5.3412 +            last_sample4 = sample4;
  5.3413 +            last_sample5 = sample5;
  5.3414 +            last_sample6 = sample6;
  5.3415 +            last_sample7 = sample7;
  5.3416 +            eps -= srcsize;
  5.3417 +        }
  5.3418 +    }
  5.3419 +    cvt->len_cvt = dstsize;
  5.3420 +    if (cvt->filters[++cvt->filter_index]) {
  5.3421 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3422 +    }
  5.3423 +}
  5.3424 +
  5.3425 +static void SDLCALL
  5.3426 +SDL_Upsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3427 +{
  5.3428 +#ifdef DEBUG_CONVERT
  5.3429 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 1 channels.\n", cvt->rate_incr);
  5.3430 +#endif
  5.3431 +
  5.3432 +    const int srcsize = cvt->len_cvt - 64;
  5.3433 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3434 +    register int eps = 0;
  5.3435 +    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
  5.3436 +    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
  5.3437 +    const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
  5.3438 +    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  5.3439 +    Sint32 last_sample0 = sample0;
  5.3440 +    while (dst != target) {
  5.3441 +        dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  5.3442 +        dst--;
  5.3443 +        eps += srcsize;
  5.3444 +        if ((eps << 1) >= dstsize) {
  5.3445 +            src--;
  5.3446 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3447 +            last_sample0 = sample0;
  5.3448 +            eps -= dstsize;
  5.3449 +        }
  5.3450 +    }
  5.3451 +    cvt->len_cvt = dstsize;
  5.3452 +    if (cvt->filters[++cvt->filter_index]) {
  5.3453 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3454 +    }
  5.3455 +}
  5.3456 +
  5.3457 +static void SDLCALL
  5.3458 +SDL_Downsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3459 +{
  5.3460 +#ifdef DEBUG_CONVERT
  5.3461 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 1 channels.\n", cvt->rate_incr);
  5.3462 +#endif
  5.3463 +
  5.3464 +    const int srcsize = cvt->len_cvt - 64;
  5.3465 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3466 +    register int eps = 0;
  5.3467 +    Sint32 *dst = (Sint32 *) cvt->buf;
  5.3468 +    const Sint32 *src = (Sint32 *) cvt->buf;
  5.3469 +    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  5.3470 +    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  5.3471 +    Sint32 last_sample0 = sample0;
  5.3472 +    while (dst != target) {
  5.3473 +        src++;
  5.3474 +        eps += dstsize;
  5.3475 +        if ((eps << 1) >= srcsize) {
  5.3476 +            dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  5.3477 +            dst++;
  5.3478 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3479 +            last_sample0 = sample0;
  5.3480 +            eps -= srcsize;
  5.3481 +        }
  5.3482 +    }
  5.3483 +    cvt->len_cvt = dstsize;
  5.3484 +    if (cvt->filters[++cvt->filter_index]) {
  5.3485 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3486 +    }
  5.3487 +}
  5.3488 +
  5.3489 +static void SDLCALL
  5.3490 +SDL_Upsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3491 +{
  5.3492 +#ifdef DEBUG_CONVERT
  5.3493 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 2 channels.\n", cvt->rate_incr);
  5.3494 +#endif
  5.3495 +
  5.3496 +    const int srcsize = cvt->len_cvt - 128;
  5.3497 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3498 +    register int eps = 0;
  5.3499 +    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
  5.3500 +    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
  5.3501 +    const Sint32 *target = ((const Sint32 *) cvt->buf) - 2;
  5.3502 +    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  5.3503 +    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  5.3504 +    Sint32 last_sample1 = sample1;
  5.3505 +    Sint32 last_sample0 = sample0;
  5.3506 +    while (dst != target) {
  5.3507 +        dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  5.3508 +        dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  5.3509 +        dst -= 2;
  5.3510 +        eps += srcsize;
  5.3511 +        if ((eps << 1) >= dstsize) {
  5.3512 +            src -= 2;
  5.3513 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3514 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3515 +            last_sample1 = sample1;
  5.3516 +            last_sample0 = sample0;
  5.3517 +            eps -= dstsize;
  5.3518 +        }
  5.3519 +    }
  5.3520 +    cvt->len_cvt = dstsize;
  5.3521 +    if (cvt->filters[++cvt->filter_index]) {
  5.3522 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3523 +    }
  5.3524 +}
  5.3525 +
  5.3526 +static void SDLCALL
  5.3527 +SDL_Downsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3528 +{
  5.3529 +#ifdef DEBUG_CONVERT
  5.3530 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 2 channels.\n", cvt->rate_incr);
  5.3531 +#endif
  5.3532 +
  5.3533 +    const int srcsize = cvt->len_cvt - 128;
  5.3534 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3535 +    register int eps = 0;
  5.3536 +    Sint32 *dst = (Sint32 *) cvt->buf;
  5.3537 +    const Sint32 *src = (Sint32 *) cvt->buf;
  5.3538 +    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  5.3539 +    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  5.3540 +    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  5.3541 +    Sint32 last_sample0 = sample0;
  5.3542 +    Sint32 last_sample1 = sample1;
  5.3543 +    while (dst != target) {
  5.3544 +        src += 2;
  5.3545 +        eps += dstsize;
  5.3546 +        if ((eps << 1) >= srcsize) {
  5.3547 +            dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  5.3548 +            dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  5.3549 +            dst += 2;
  5.3550 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3551 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3552 +            last_sample0 = sample0;
  5.3553 +            last_sample1 = sample1;
  5.3554 +            eps -= srcsize;
  5.3555 +        }
  5.3556 +    }
  5.3557 +    cvt->len_cvt = dstsize;
  5.3558 +    if (cvt->filters[++cvt->filter_index]) {
  5.3559 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3560 +    }
  5.3561 +}
  5.3562 +
  5.3563 +static void SDLCALL
  5.3564 +SDL_Upsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3565 +{
  5.3566 +#ifdef DEBUG_CONVERT
  5.3567 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 4 channels.\n", cvt->rate_incr);
  5.3568 +#endif
  5.3569 +
  5.3570 +    const int srcsize = cvt->len_cvt - 256;
  5.3571 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3572 +    register int eps = 0;
  5.3573 +    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
  5.3574 +    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
  5.3575 +    const Sint32 *target = ((const Sint32 *) cvt->buf) - 4;
  5.3576 +    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
  5.3577 +    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
  5.3578 +    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  5.3579 +    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  5.3580 +    Sint32 last_sample3 = sample3;
  5.3581 +    Sint32 last_sample2 = sample2;
  5.3582 +    Sint32 last_sample1 = sample1;
  5.3583 +    Sint32 last_sample0 = sample0;
  5.3584 +    while (dst != target) {
  5.3585 +        dst[3] = ((Sint32) SDL_SwapBE32(sample3));
  5.3586 +        dst[2] = ((Sint32) SDL_SwapBE32(sample2));
  5.3587 +        dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  5.3588 +        dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  5.3589 +        dst -= 4;
  5.3590 +        eps += srcsize;
  5.3591 +        if ((eps << 1) >= dstsize) {
  5.3592 +            src -= 4;
  5.3593 +            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  5.3594 +            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  5.3595 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3596 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3597 +            last_sample3 = sample3;
  5.3598 +            last_sample2 = sample2;
  5.3599 +            last_sample1 = sample1;
  5.3600 +            last_sample0 = sample0;
  5.3601 +            eps -= dstsize;
  5.3602 +        }
  5.3603 +    }
  5.3604 +    cvt->len_cvt = dstsize;
  5.3605 +    if (cvt->filters[++cvt->filter_index]) {
  5.3606 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3607 +    }
  5.3608 +}
  5.3609 +
  5.3610 +static void SDLCALL
  5.3611 +SDL_Downsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3612 +{
  5.3613 +#ifdef DEBUG_CONVERT
  5.3614 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 4 channels.\n", cvt->rate_incr);
  5.3615 +#endif
  5.3616 +
  5.3617 +    const int srcsize = cvt->len_cvt - 256;
  5.3618 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3619 +    register int eps = 0;
  5.3620 +    Sint32 *dst = (Sint32 *) cvt->buf;
  5.3621 +    const Sint32 *src = (Sint32 *) cvt->buf;
  5.3622 +    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  5.3623 +    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  5.3624 +    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  5.3625 +    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
  5.3626 +    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
  5.3627 +    Sint32 last_sample0 = sample0;
  5.3628 +    Sint32 last_sample1 = sample1;
  5.3629 +    Sint32 last_sample2 = sample2;
  5.3630 +    Sint32 last_sample3 = sample3;
  5.3631 +    while (dst != target) {
  5.3632 +        src += 4;
  5.3633 +        eps += dstsize;
  5.3634 +        if ((eps << 1) >= srcsize) {
  5.3635 +            dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  5.3636 +            dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  5.3637 +            dst[2] = ((Sint32) SDL_SwapBE32(sample2));
  5.3638 +            dst[3] = ((Sint32) SDL_SwapBE32(sample3));
  5.3639 +            dst += 4;
  5.3640 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3641 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3642 +            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  5.3643 +            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  5.3644 +            last_sample0 = sample0;
  5.3645 +            last_sample1 = sample1;
  5.3646 +            last_sample2 = sample2;
  5.3647 +            last_sample3 = sample3;
  5.3648 +            eps -= srcsize;
  5.3649 +        }
  5.3650 +    }
  5.3651 +    cvt->len_cvt = dstsize;
  5.3652 +    if (cvt->filters[++cvt->filter_index]) {
  5.3653 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3654 +    }
  5.3655 +}
  5.3656 +
  5.3657 +static void SDLCALL
  5.3658 +SDL_Upsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3659 +{
  5.3660 +#ifdef DEBUG_CONVERT
  5.3661 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 6 channels.\n", cvt->rate_incr);
  5.3662 +#endif
  5.3663 +
  5.3664 +    const int srcsize = cvt->len_cvt - 384;
  5.3665 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3666 +    register int eps = 0;
  5.3667 +    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
  5.3668 +    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
  5.3669 +    const Sint32 *target = ((const Sint32 *) cvt->buf) - 6;
  5.3670 +    Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
  5.3671 +    Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
  5.3672 +    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
  5.3673 +    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
  5.3674 +    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  5.3675 +    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  5.3676 +    Sint32 last_sample5 = sample5;
  5.3677 +    Sint32 last_sample4 = sample4;
  5.3678 +    Sint32 last_sample3 = sample3;
  5.3679 +    Sint32 last_sample2 = sample2;
  5.3680 +    Sint32 last_sample1 = sample1;
  5.3681 +    Sint32 last_sample0 = sample0;
  5.3682 +    while (dst != target) {
  5.3683 +        dst[5] = ((Sint32) SDL_SwapBE32(sample5));
  5.3684 +        dst[4] = ((Sint32) SDL_SwapBE32(sample4));
  5.3685 +        dst[3] = ((Sint32) SDL_SwapBE32(sample3));
  5.3686 +        dst[2] = ((Sint32) SDL_SwapBE32(sample2));
  5.3687 +        dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  5.3688 +        dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  5.3689 +        dst -= 6;
  5.3690 +        eps += srcsize;
  5.3691 +        if ((eps << 1) >= dstsize) {
  5.3692 +            src -= 6;
  5.3693 +            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  5.3694 +            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  5.3695 +            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  5.3696 +            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  5.3697 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3698 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3699 +            last_sample5 = sample5;
  5.3700 +            last_sample4 = sample4;
  5.3701 +            last_sample3 = sample3;
  5.3702 +            last_sample2 = sample2;
  5.3703 +            last_sample1 = sample1;
  5.3704 +            last_sample0 = sample0;
  5.3705 +            eps -= dstsize;
  5.3706 +        }
  5.3707 +    }
  5.3708 +    cvt->len_cvt = dstsize;
  5.3709 +    if (cvt->filters[++cvt->filter_index]) {
  5.3710 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3711 +    }
  5.3712 +}
  5.3713 +
  5.3714 +static void SDLCALL
  5.3715 +SDL_Downsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3716 +{
  5.3717 +#ifdef DEBUG_CONVERT
  5.3718 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 6 channels.\n", cvt->rate_incr);
  5.3719 +#endif
  5.3720 +
  5.3721 +    const int srcsize = cvt->len_cvt - 384;
  5.3722 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3723 +    register int eps = 0;
  5.3724 +    Sint32 *dst = (Sint32 *) cvt->buf;
  5.3725 +    const Sint32 *src = (Sint32 *) cvt->buf;
  5.3726 +    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  5.3727 +    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  5.3728 +    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  5.3729 +    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
  5.3730 +    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
  5.3731 +    Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
  5.3732 +    Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
  5.3733 +    Sint32 last_sample0 = sample0;
  5.3734 +    Sint32 last_sample1 = sample1;
  5.3735 +    Sint32 last_sample2 = sample2;
  5.3736 +    Sint32 last_sample3 = sample3;
  5.3737 +    Sint32 last_sample4 = sample4;
  5.3738 +    Sint32 last_sample5 = sample5;
  5.3739 +    while (dst != target) {
  5.3740 +        src += 6;
  5.3741 +        eps += dstsize;
  5.3742 +        if ((eps << 1) >= srcsize) {
  5.3743 +            dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  5.3744 +            dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  5.3745 +            dst[2] = ((Sint32) SDL_SwapBE32(sample2));
  5.3746 +            dst[3] = ((Sint32) SDL_SwapBE32(sample3));
  5.3747 +            dst[4] = ((Sint32) SDL_SwapBE32(sample4));
  5.3748 +            dst[5] = ((Sint32) SDL_SwapBE32(sample5));
  5.3749 +            dst += 6;
  5.3750 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3751 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3752 +            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  5.3753 +            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  5.3754 +            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  5.3755 +            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  5.3756 +            last_sample0 = sample0;
  5.3757 +            last_sample1 = sample1;
  5.3758 +            last_sample2 = sample2;
  5.3759 +            last_sample3 = sample3;
  5.3760 +            last_sample4 = sample4;
  5.3761 +            last_sample5 = sample5;
  5.3762 +            eps -= srcsize;
  5.3763 +        }
  5.3764 +    }
  5.3765 +    cvt->len_cvt = dstsize;
  5.3766 +    if (cvt->filters[++cvt->filter_index]) {
  5.3767 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3768 +    }
  5.3769 +}
  5.3770 +
  5.3771 +static void SDLCALL
  5.3772 +SDL_Upsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3773 +{
  5.3774 +#ifdef DEBUG_CONVERT
  5.3775 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 8 channels.\n", cvt->rate_incr);
  5.3776 +#endif
  5.3777 +
  5.3778 +    const int srcsize = cvt->len_cvt - 512;
  5.3779 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3780 +    register int eps = 0;
  5.3781 +    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
  5.3782 +    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
  5.3783 +    const Sint32 *target = ((const Sint32 *) cvt->buf) - 8;
  5.3784 +    Sint32 sample7 = ((Sint32) SDL_SwapBE32(src[7]));
  5.3785 +    Sint32 sample6 = ((Sint32) SDL_SwapBE32(src[6]));
  5.3786 +    Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
  5.3787 +    Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
  5.3788 +    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
  5.3789 +    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
  5.3790 +    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  5.3791 +    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  5.3792 +    Sint32 last_sample7 = sample7;
  5.3793 +    Sint32 last_sample6 = sample6;
  5.3794 +    Sint32 last_sample5 = sample5;
  5.3795 +    Sint32 last_sample4 = sample4;
  5.3796 +    Sint32 last_sample3 = sample3;
  5.3797 +    Sint32 last_sample2 = sample2;
  5.3798 +    Sint32 last_sample1 = sample1;
  5.3799 +    Sint32 last_sample0 = sample0;
  5.3800 +    while (dst != target) {
  5.3801 +        dst[7] = ((Sint32) SDL_SwapBE32(sample7));
  5.3802 +        dst[6] = ((Sint32) SDL_SwapBE32(sample6));
  5.3803 +        dst[5] = ((Sint32) SDL_SwapBE32(sample5));
  5.3804 +        dst[4] = ((Sint32) SDL_SwapBE32(sample4));
  5.3805 +        dst[3] = ((Sint32) SDL_SwapBE32(sample3));
  5.3806 +        dst[2] = ((Sint32) SDL_SwapBE32(sample2));
  5.3807 +        dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  5.3808 +        dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  5.3809 +        dst -= 8;
  5.3810 +        eps += srcsize;
  5.3811 +        if ((eps << 1) >= dstsize) {
  5.3812 +            src -= 8;
  5.3813 +            sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
  5.3814 +            sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
  5.3815 +            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  5.3816 +            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  5.3817 +            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  5.3818 +            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  5.3819 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3820 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3821 +            last_sample7 = sample7;
  5.3822 +            last_sample6 = sample6;
  5.3823 +            last_sample5 = sample5;
  5.3824 +            last_sample4 = sample4;
  5.3825 +            last_sample3 = sample3;
  5.3826 +            last_sample2 = sample2;
  5.3827 +            last_sample1 = sample1;
  5.3828 +            last_sample0 = sample0;
  5.3829 +            eps -= dstsize;
  5.3830 +        }
  5.3831 +    }
  5.3832 +    cvt->len_cvt = dstsize;
  5.3833 +    if (cvt->filters[++cvt->filter_index]) {
  5.3834 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3835 +    }
  5.3836 +}
  5.3837 +
  5.3838 +static void SDLCALL
  5.3839 +SDL_Downsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3840 +{
  5.3841 +#ifdef DEBUG_CONVERT
  5.3842 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 8 channels.\n", cvt->rate_incr);
  5.3843 +#endif
  5.3844 +
  5.3845 +    const int srcsize = cvt->len_cvt - 512;
  5.3846 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3847 +    register int eps = 0;
  5.3848 +    Sint32 *dst = (Sint32 *) cvt->buf;
  5.3849 +    const Sint32 *src = (Sint32 *) cvt->buf;
  5.3850 +    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  5.3851 +    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
  5.3852 +    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
  5.3853 +    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
  5.3854 +    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
  5.3855 +    Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
  5.3856 +    Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
  5.3857 +    Sint32 sample6 = ((Sint32) SDL_SwapBE32(src[6]));
  5.3858 +    Sint32 sample7 = ((Sint32) SDL_SwapBE32(src[7]));
  5.3859 +    Sint32 last_sample0 = sample0;
  5.3860 +    Sint32 last_sample1 = sample1;
  5.3861 +    Sint32 last_sample2 = sample2;
  5.3862 +    Sint32 last_sample3 = sample3;
  5.3863 +    Sint32 last_sample4 = sample4;
  5.3864 +    Sint32 last_sample5 = sample5;
  5.3865 +    Sint32 last_sample6 = sample6;
  5.3866 +    Sint32 last_sample7 = sample7;
  5.3867 +    while (dst != target) {
  5.3868 +        src += 8;
  5.3869 +        eps += dstsize;
  5.3870 +        if ((eps << 1) >= srcsize) {
  5.3871 +            dst[0] = ((Sint32) SDL_SwapBE32(sample0));
  5.3872 +            dst[1] = ((Sint32) SDL_SwapBE32(sample1));
  5.3873 +            dst[2] = ((Sint32) SDL_SwapBE32(sample2));
  5.3874 +            dst[3] = ((Sint32) SDL_SwapBE32(sample3));
  5.3875 +            dst[4] = ((Sint32) SDL_SwapBE32(sample4));
  5.3876 +            dst[5] = ((Sint32) SDL_SwapBE32(sample5));
  5.3877 +            dst[6] = ((Sint32) SDL_SwapBE32(sample6));
  5.3878 +            dst[7] = ((Sint32) SDL_SwapBE32(sample7));
  5.3879 +            dst += 8;
  5.3880 +            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
  5.3881 +            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
  5.3882 +            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
  5.3883 +            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
  5.3884 +            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
  5.3885 +            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
  5.3886 +            sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
  5.3887 +            sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
  5.3888 +            last_sample0 = sample0;
  5.3889 +            last_sample1 = sample1;
  5.3890 +            last_sample2 = sample2;
  5.3891 +            last_sample3 = sample3;
  5.3892 +            last_sample4 = sample4;
  5.3893 +            last_sample5 = sample5;
  5.3894 +            last_sample6 = sample6;
  5.3895 +            last_sample7 = sample7;
  5.3896 +            eps -= srcsize;
  5.3897 +        }
  5.3898 +    }
  5.3899 +    cvt->len_cvt = dstsize;
  5.3900 +    if (cvt->filters[++cvt->filter_index]) {
  5.3901 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3902 +    }
  5.3903 +}
  5.3904 +
  5.3905 +static void SDLCALL
  5.3906 +SDL_Upsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3907 +{
  5.3908 +#ifdef DEBUG_CONVERT
  5.3909 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 1 channels.\n", cvt->rate_incr);
  5.3910 +#endif
  5.3911 +
  5.3912 +    const int srcsize = cvt->len_cvt - 64;
  5.3913 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3914 +    register int eps = 0;
  5.3915 +    float *dst = ((float *) (cvt->buf + dstsize)) - 1;
  5.3916 +    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
  5.3917 +    const float *target = ((const float *) cvt->buf) - 1;
  5.3918 +    float sample0 = SDL_SwapFloatLE(src[0]);
  5.3919 +    float last_sample0 = sample0;
  5.3920 +    while (dst != target) {
  5.3921 +        dst[0] = SDL_SwapFloatLE(sample0);
  5.3922 +        dst--;
  5.3923 +        eps += srcsize;
  5.3924 +        if ((eps << 1) >= dstsize) {
  5.3925 +            src--;
  5.3926 +            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  5.3927 +            last_sample0 = sample0;
  5.3928 +            eps -= dstsize;
  5.3929 +        }
  5.3930 +    }
  5.3931 +    cvt->len_cvt = dstsize;
  5.3932 +    if (cvt->filters[++cvt->filter_index]) {
  5.3933 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3934 +    }
  5.3935 +}
  5.3936 +
  5.3937 +static void SDLCALL
  5.3938 +SDL_Downsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3939 +{
  5.3940 +#ifdef DEBUG_CONVERT
  5.3941 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 1 channels.\n", cvt->rate_incr);
  5.3942 +#endif
  5.3943 +
  5.3944 +    const int srcsize = cvt->len_cvt - 64;
  5.3945 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3946 +    register int eps = 0;
  5.3947 +    float *dst = (float *) cvt->buf;
  5.3948 +    const float *src = (float *) cvt->buf;
  5.3949 +    const float *target = (const float *) (cvt->buf + dstsize);
  5.3950 +    float sample0 = SDL_SwapFloatLE(src[0]);
  5.3951 +    float last_sample0 = sample0;
  5.3952 +    while (dst != target) {
  5.3953 +        src++;
  5.3954 +        eps += dstsize;
  5.3955 +        if ((eps << 1) >= srcsize) {
  5.3956 +            dst[0] = SDL_SwapFloatLE(sample0);
  5.3957 +            dst++;
  5.3958 +            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  5.3959 +            last_sample0 = sample0;
  5.3960 +            eps -= srcsize;
  5.3961 +        }
  5.3962 +    }
  5.3963 +    cvt->len_cvt = dstsize;
  5.3964 +    if (cvt->filters[++cvt->filter_index]) {
  5.3965 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.3966 +    }
  5.3967 +}
  5.3968 +
  5.3969 +static void SDLCALL
  5.3970 +SDL_Upsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.3971 +{
  5.3972 +#ifdef DEBUG_CONVERT
  5.3973 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 2 channels.\n", cvt->rate_incr);
  5.3974 +#endif
  5.3975 +
  5.3976 +    const int srcsize = cvt->len_cvt - 128;
  5.3977 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.3978 +    register int eps = 0;
  5.3979 +    float *dst = ((float *) (cvt->buf + dstsize)) - 2;
  5.3980 +    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
  5.3981 +    const float *target = ((const float *) cvt->buf) - 2;
  5.3982 +    float sample1 = SDL_SwapFloatLE(src[1]);
  5.3983 +    float sample0 = SDL_SwapFloatLE(src[0]);
  5.3984 +    float last_sample1 = sample1;
  5.3985 +    float last_sample0 = sample0;
  5.3986 +    while (dst != target) {
  5.3987 +        dst[1] = SDL_SwapFloatLE(sample1);
  5.3988 +        dst[0] = SDL_SwapFloatLE(sample0);
  5.3989 +        dst -= 2;
  5.3990 +        eps += srcsize;
  5.3991 +        if ((eps << 1) >= dstsize) {
  5.3992 +            src -= 2;
  5.3993 +            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
  5.3994 +            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  5.3995 +            last_sample1 = sample1;
  5.3996 +            last_sample0 = sample0;
  5.3997 +            eps -= dstsize;
  5.3998 +        }
  5.3999 +    }
  5.4000 +    cvt->len_cvt = dstsize;
  5.4001 +    if (cvt->filters[++cvt->filter_index]) {
  5.4002 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4003 +    }
  5.4004 +}
  5.4005 +
  5.4006 +static void SDLCALL
  5.4007 +SDL_Downsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4008 +{
  5.4009 +#ifdef DEBUG_CONVERT
  5.4010 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 2 channels.\n", cvt->rate_incr);
  5.4011 +#endif
  5.4012 +
  5.4013 +    const int srcsize = cvt->len_cvt - 128;
  5.4014 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4015 +    register int eps = 0;
  5.4016 +    float *dst = (float *) cvt->buf;
  5.4017 +    const float *src = (float *) cvt->buf;
  5.4018 +    const float *target = (const float *) (cvt->buf + dstsize);
  5.4019 +    float sample0 = SDL_SwapFloatLE(src[0]);
  5.4020 +    float sample1 = SDL_SwapFloatLE(src[1]);
  5.4021 +    float last_sample0 = sample0;
  5.4022 +    float last_sample1 = sample1;
  5.4023 +    while (dst != target) {
  5.4024 +        src += 2;
  5.4025 +        eps += dstsize;
  5.4026 +        if ((eps << 1) >= srcsize) {
  5.4027 +            dst[0] = SDL_SwapFloatLE(sample0);
  5.4028 +            dst[1] = SDL_SwapFloatLE(sample1);
  5.4029 +            dst += 2;
  5.4030 +            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4031 +            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
  5.4032 +            last_sample0 = sample0;
  5.4033 +            last_sample1 = sample1;
  5.4034 +            eps -= srcsize;
  5.4035 +        }
  5.4036 +    }
  5.4037 +    cvt->len_cvt = dstsize;
  5.4038 +    if (cvt->filters[++cvt->filter_index]) {
  5.4039 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4040 +    }
  5.4041 +}
  5.4042 +
  5.4043 +static void SDLCALL
  5.4044 +SDL_Upsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4045 +{
  5.4046 +#ifdef DEBUG_CONVERT
  5.4047 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 4 channels.\n", cvt->rate_incr);
  5.4048 +#endif
  5.4049 +
  5.4050 +    const int srcsize = cvt->len_cvt - 256;
  5.4051 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4052 +    register int eps = 0;
  5.4053 +    float *dst = ((float *) (cvt->buf + dstsize)) - 4;
  5.4054 +    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
  5.4055 +    const float *target = ((const float *) cvt->buf) - 4;
  5.4056 +    float sample3 = SDL_SwapFloatLE(src[3]);
  5.4057 +    float sample2 = SDL_SwapFloatLE(src[2]);
  5.4058 +    float sample1 = SDL_SwapFloatLE(src[1]);
  5.4059 +    float sample0 = SDL_SwapFloatLE(src[0]);
  5.4060 +    float last_sample3 = sample3;
  5.4061 +    float last_sample2 = sample2;
  5.4062 +    float last_sample1 = sample1;
  5.4063 +    float last_sample0 = sample0;
  5.4064 +    while (dst != target) {
  5.4065 +        dst[3] = SDL_SwapFloatLE(sample3);
  5.4066 +        dst[2] = SDL_SwapFloatLE(sample2);
  5.4067 +        dst[1] = SDL_SwapFloatLE(sample1);
  5.4068 +        dst[0] = SDL_SwapFloatLE(sample0);
  5.4069 +        dst -= 4;
  5.4070 +        eps += srcsize;
  5.4071 +        if ((eps << 1) >= dstsize) {
  5.4072 +            src -= 4;
  5.4073 +            sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
  5.4074 +            sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
  5.4075 +            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
  5.4076 +            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4077 +            last_sample3 = sample3;
  5.4078 +            last_sample2 = sample2;
  5.4079 +            last_sample1 = sample1;
  5.4080 +            last_sample0 = sample0;
  5.4081 +            eps -= dstsize;
  5.4082 +        }
  5.4083 +    }
  5.4084 +    cvt->len_cvt = dstsize;
  5.4085 +    if (cvt->filters[++cvt->filter_index]) {
  5.4086 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4087 +    }
  5.4088 +}
  5.4089 +
  5.4090 +static void SDLCALL
  5.4091 +SDL_Downsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4092 +{
  5.4093 +#ifdef DEBUG_CONVERT
  5.4094 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 4 channels.\n", cvt->rate_incr);
  5.4095 +#endif
  5.4096 +
  5.4097 +    const int srcsize = cvt->len_cvt - 256;
  5.4098 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4099 +    register int eps = 0;
  5.4100 +    float *dst = (float *) cvt->buf;
  5.4101 +    const float *src = (float *) cvt->buf;
  5.4102 +    const float *target = (const float *) (cvt->buf + dstsize);
  5.4103 +    float sample0 = SDL_SwapFloatLE(src[0]);
  5.4104 +    float sample1 = SDL_SwapFloatLE(src[1]);
  5.4105 +    float sample2 = SDL_SwapFloatLE(src[2]);
  5.4106 +    float sample3 = SDL_SwapFloatLE(src[3]);
  5.4107 +    float last_sample0 = sample0;
  5.4108 +    float last_sample1 = sample1;
  5.4109 +    float last_sample2 = sample2;
  5.4110 +    float last_sample3 = sample3;
  5.4111 +    while (dst != target) {
  5.4112 +        src += 4;
  5.4113 +        eps += dstsize;
  5.4114 +        if ((eps << 1) >= srcsize) {
  5.4115 +            dst[0] = SDL_SwapFloatLE(sample0);
  5.4116 +            dst[1] = SDL_SwapFloatLE(sample1);
  5.4117 +            dst[2] = SDL_SwapFloatLE(sample2);
  5.4118 +            dst[3] = SDL_SwapFloatLE(sample3);
  5.4119 +            dst += 4;
  5.4120 +            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4121 +            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
  5.4122 +            sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
  5.4123 +            sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
  5.4124 +            last_sample0 = sample0;
  5.4125 +            last_sample1 = sample1;
  5.4126 +            last_sample2 = sample2;
  5.4127 +            last_sample3 = sample3;
  5.4128 +            eps -= srcsize;
  5.4129 +        }
  5.4130 +    }
  5.4131 +    cvt->len_cvt = dstsize;
  5.4132 +    if (cvt->filters[++cvt->filter_index]) {
  5.4133 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4134 +    }
  5.4135 +}
  5.4136 +
  5.4137 +static void SDLCALL
  5.4138 +SDL_Upsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4139 +{
  5.4140 +#ifdef DEBUG_CONVERT
  5.4141 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 6 channels.\n", cvt->rate_incr);
  5.4142 +#endif
  5.4143 +
  5.4144 +    const int srcsize = cvt->len_cvt - 384;
  5.4145 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4146 +    register int eps = 0;
  5.4147 +    float *dst = ((float *) (cvt->buf + dstsize)) - 6;
  5.4148 +    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
  5.4149 +    const float *target = ((const float *) cvt->buf) - 6;
  5.4150 +    float sample5 = SDL_SwapFloatLE(src[5]);
  5.4151 +    float sample4 = SDL_SwapFloatLE(src[4]);
  5.4152 +    float sample3 = SDL_SwapFloatLE(src[3]);
  5.4153 +    float sample2 = SDL_SwapFloatLE(src[2]);
  5.4154 +    float sample1 = SDL_SwapFloatLE(src[1]);
  5.4155 +    float sample0 = SDL_SwapFloatLE(src[0]);
  5.4156 +    float last_sample5 = sample5;
  5.4157 +    float last_sample4 = sample4;
  5.4158 +    float last_sample3 = sample3;
  5.4159 +    float last_sample2 = sample2;
  5.4160 +    float last_sample1 = sample1;
  5.4161 +    float last_sample0 = sample0;
  5.4162 +    while (dst != target) {
  5.4163 +        dst[5] = SDL_SwapFloatLE(sample5);
  5.4164 +        dst[4] = SDL_SwapFloatLE(sample4);
  5.4165 +        dst[3] = SDL_SwapFloatLE(sample3);
  5.4166 +        dst[2] = SDL_SwapFloatLE(sample2);
  5.4167 +        dst[1] = SDL_SwapFloatLE(sample1);
  5.4168 +        dst[0] = SDL_SwapFloatLE(sample0);
  5.4169 +        dst -= 6;
  5.4170 +        eps += srcsize;
  5.4171 +        if ((eps << 1) >= dstsize) {
  5.4172 +            src -= 6;
  5.4173 +            sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
  5.4174 +            sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
  5.4175 +            sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
  5.4176 +            sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
  5.4177 +            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
  5.4178 +            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4179 +            last_sample5 = sample5;
  5.4180 +            last_sample4 = sample4;
  5.4181 +            last_sample3 = sample3;
  5.4182 +            last_sample2 = sample2;
  5.4183 +            last_sample1 = sample1;
  5.4184 +            last_sample0 = sample0;
  5.4185 +            eps -= dstsize;
  5.4186 +        }
  5.4187 +    }
  5.4188 +    cvt->len_cvt = dstsize;
  5.4189 +    if (cvt->filters[++cvt->filter_index]) {
  5.4190 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4191 +    }
  5.4192 +}
  5.4193 +
  5.4194 +static void SDLCALL
  5.4195 +SDL_Downsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4196 +{
  5.4197 +#ifdef DEBUG_CONVERT
  5.4198 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 6 channels.\n", cvt->rate_incr);
  5.4199 +#endif
  5.4200 +
  5.4201 +    const int srcsize = cvt->len_cvt - 384;
  5.4202 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4203 +    register int eps = 0;
  5.4204 +    float *dst = (float *) cvt->buf;
  5.4205 +    const float *src = (float *) cvt->buf;
  5.4206 +    const float *target = (const float *) (cvt->buf + dstsize);
  5.4207 +    float sample0 = SDL_SwapFloatLE(src[0]);
  5.4208 +    float sample1 = SDL_SwapFloatLE(src[1]);
  5.4209 +    float sample2 = SDL_SwapFloatLE(src[2]);
  5.4210 +    float sample3 = SDL_SwapFloatLE(src[3]);
  5.4211 +    float sample4 = SDL_SwapFloatLE(src[4]);
  5.4212 +    float sample5 = SDL_SwapFloatLE(src[5]);
  5.4213 +    float last_sample0 = sample0;
  5.4214 +    float last_sample1 = sample1;
  5.4215 +    float last_sample2 = sample2;
  5.4216 +    float last_sample3 = sample3;
  5.4217 +    float last_sample4 = sample4;
  5.4218 +    float last_sample5 = sample5;
  5.4219 +    while (dst != target) {
  5.4220 +        src += 6;
  5.4221 +        eps += dstsize;
  5.4222 +        if ((eps << 1) >= srcsize) {
  5.4223 +            dst[0] = SDL_SwapFloatLE(sample0);
  5.4224 +            dst[1] = SDL_SwapFloatLE(sample1);
  5.4225 +            dst[2] = SDL_SwapFloatLE(sample2);
  5.4226 +            dst[3] = SDL_SwapFloatLE(sample3);
  5.4227 +            dst[4] = SDL_SwapFloatLE(sample4);
  5.4228 +            dst[5] = SDL_SwapFloatLE(sample5);
  5.4229 +            dst += 6;
  5.4230 +            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4231 +            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
  5.4232 +            sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
  5.4233 +            sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
  5.4234 +            sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
  5.4235 +            sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
  5.4236 +            last_sample0 = sample0;
  5.4237 +            last_sample1 = sample1;
  5.4238 +            last_sample2 = sample2;
  5.4239 +            last_sample3 = sample3;
  5.4240 +            last_sample4 = sample4;
  5.4241 +            last_sample5 = sample5;
  5.4242 +            eps -= srcsize;
  5.4243 +        }
  5.4244 +    }
  5.4245 +    cvt->len_cvt = dstsize;
  5.4246 +    if (cvt->filters[++cvt->filter_index]) {
  5.4247 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4248 +    }
  5.4249 +}
  5.4250 +
  5.4251 +static void SDLCALL
  5.4252 +SDL_Upsample_F32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4253 +{
  5.4254 +#ifdef DEBUG_CONVERT
  5.4255 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 8 channels.\n", cvt->rate_incr);
  5.4256 +#endif
  5.4257 +
  5.4258 +    const int srcsize = cvt->len_cvt - 512;
  5.4259 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4260 +    register int eps = 0;
  5.4261 +    float *dst = ((float *) (cvt->buf + dstsize)) - 8;
  5.4262 +    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
  5.4263 +    const float *target = ((const float *) cvt->buf) - 8;
  5.4264 +    float sample7 = SDL_SwapFloatLE(src[7]);
  5.4265 +    float sample6 = SDL_SwapFloatLE(src[6]);
  5.4266 +    float sample5 = SDL_SwapFloatLE(src[5]);
  5.4267 +    float sample4 = SDL_SwapFloatLE(src[4]);
  5.4268 +    float sample3 = SDL_SwapFloatLE(src[3]);
  5.4269 +    float sample2 = SDL_SwapFloatLE(src[2]);
  5.4270 +    float sample1 = SDL_SwapFloatLE(src[1]);
  5.4271 +    float sample0 = SDL_SwapFloatLE(src[0]);
  5.4272 +    float last_sample7 = sample7;
  5.4273 +    float last_sample6 = sample6;
  5.4274 +    float last_sample5 = sample5;
  5.4275 +    float last_sample4 = sample4;
  5.4276 +    float last_sample3 = sample3;
  5.4277 +    float last_sample2 = sample2;
  5.4278 +    float last_sample1 = sample1;
  5.4279 +    float last_sample0 = sample0;
  5.4280 +    while (dst != target) {
  5.4281 +        dst[7] = SDL_SwapFloatLE(sample7);
  5.4282 +        dst[6] = SDL_SwapFloatLE(sample6);
  5.4283 +        dst[5] = SDL_SwapFloatLE(sample5);
  5.4284 +        dst[4] = SDL_SwapFloatLE(sample4);
  5.4285 +        dst[3] = SDL_SwapFloatLE(sample3);
  5.4286 +        dst[2] = SDL_SwapFloatLE(sample2);
  5.4287 +        dst[1] = SDL_SwapFloatLE(sample1);
  5.4288 +        dst[0] = SDL_SwapFloatLE(sample0);
  5.4289 +        dst -= 8;
  5.4290 +        eps += srcsize;
  5.4291 +        if ((eps << 1) >= dstsize) {
  5.4292 +            src -= 8;
  5.4293 +            sample7 = (float) ((((double) SDL_SwapFloatLE(src[7])) + ((double) last_sample7)) * 0.5);
  5.4294 +            sample6 = (float) ((((double) SDL_SwapFloatLE(src[6])) + ((double) last_sample6)) * 0.5);
  5.4295 +            sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
  5.4296 +            sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
  5.4297 +            sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
  5.4298 +            sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
  5.4299 +            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
  5.4300 +            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4301 +            last_sample7 = sample7;
  5.4302 +            last_sample6 = sample6;
  5.4303 +            last_sample5 = sample5;
  5.4304 +            last_sample4 = sample4;
  5.4305 +            last_sample3 = sample3;
  5.4306 +            last_sample2 = sample2;
  5.4307 +            last_sample1 = sample1;
  5.4308 +            last_sample0 = sample0;
  5.4309 +            eps -= dstsize;
  5.4310 +        }
  5.4311 +    }
  5.4312 +    cvt->len_cvt = dstsize;
  5.4313 +    if (cvt->filters[++cvt->filter_index]) {
  5.4314 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4315 +    }
  5.4316 +}
  5.4317 +
  5.4318 +static void SDLCALL
  5.4319 +SDL_Downsample_F32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4320 +{
  5.4321 +#ifdef DEBUG_CONVERT
  5.4322 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 8 channels.\n", cvt->rate_incr);
  5.4323 +#endif
  5.4324 +
  5.4325 +    const int srcsize = cvt->len_cvt - 512;
  5.4326 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4327 +    register int eps = 0;
  5.4328 +    float *dst = (float *) cvt->buf;
  5.4329 +    const float *src = (float *) cvt->buf;
  5.4330 +    const float *target = (const float *) (cvt->buf + dstsize);
  5.4331 +    float sample0 = SDL_SwapFloatLE(src[0]);
  5.4332 +    float sample1 = SDL_SwapFloatLE(src[1]);
  5.4333 +    float sample2 = SDL_SwapFloatLE(src[2]);
  5.4334 +    float sample3 = SDL_SwapFloatLE(src[3]);
  5.4335 +    float sample4 = SDL_SwapFloatLE(src[4]);
  5.4336 +    float sample5 = SDL_SwapFloatLE(src[5]);
  5.4337 +    float sample6 = SDL_SwapFloatLE(src[6]);
  5.4338 +    float sample7 = SDL_SwapFloatLE(src[7]);
  5.4339 +    float last_sample0 = sample0;
  5.4340 +    float last_sample1 = sample1;
  5.4341 +    float last_sample2 = sample2;
  5.4342 +    float last_sample3 = sample3;
  5.4343 +    float last_sample4 = sample4;
  5.4344 +    float last_sample5 = sample5;
  5.4345 +    float last_sample6 = sample6;
  5.4346 +    float last_sample7 = sample7;
  5.4347 +    while (dst != target) {
  5.4348 +        src += 8;
  5.4349 +        eps += dstsize;
  5.4350 +        if ((eps << 1) >= srcsize) {
  5.4351 +            dst[0] = SDL_SwapFloatLE(sample0);
  5.4352 +            dst[1] = SDL_SwapFloatLE(sample1);
  5.4353 +            dst[2] = SDL_SwapFloatLE(sample2);
  5.4354 +            dst[3] = SDL_SwapFloatLE(sample3);
  5.4355 +            dst[4] = SDL_SwapFloatLE(sample4);
  5.4356 +            dst[5] = SDL_SwapFloatLE(sample5);
  5.4357 +            dst[6] = SDL_SwapFloatLE(sample6);
  5.4358 +            dst[7] = SDL_SwapFloatLE(sample7);
  5.4359 +            dst += 8;
  5.4360 +            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4361 +            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
  5.4362 +            sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
  5.4363 +            sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
  5.4364 +            sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
  5.4365 +            sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
  5.4366 +            sample6 = (float) ((((double) SDL_SwapFloatLE(src[6])) + ((double) last_sample6)) * 0.5);
  5.4367 +            sample7 = (float) ((((double) SDL_SwapFloatLE(src[7])) + ((double) last_sample7)) * 0.5);
  5.4368 +            last_sample0 = sample0;
  5.4369 +            last_sample1 = sample1;
  5.4370 +            last_sample2 = sample2;
  5.4371 +            last_sample3 = sample3;
  5.4372 +            last_sample4 = sample4;
  5.4373 +            last_sample5 = sample5;
  5.4374 +            last_sample6 = sample6;
  5.4375 +            last_sample7 = sample7;
  5.4376 +            eps -= srcsize;
  5.4377 +        }
  5.4378 +    }
  5.4379 +    cvt->len_cvt = dstsize;
  5.4380 +    if (cvt->filters[++cvt->filter_index]) {
  5.4381 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4382 +    }
  5.4383 +}
  5.4384 +
  5.4385 +static void SDLCALL
  5.4386 +SDL_Upsample_F32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4387 +{
  5.4388 +#ifdef DEBUG_CONVERT
  5.4389 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 1 channels.\n", cvt->rate_incr);
  5.4390 +#endif
  5.4391 +
  5.4392 +    const int srcsize = cvt->len_cvt - 64;
  5.4393 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4394 +    register int eps = 0;
  5.4395 +    float *dst = ((float *) (cvt->buf + dstsize)) - 1;
  5.4396 +    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
  5.4397 +    const float *target = ((const float *) cvt->buf) - 1;
  5.4398 +    float sample0 = SDL_SwapFloatBE(src[0]);
  5.4399 +    float last_sample0 = sample0;
  5.4400 +    while (dst != target) {
  5.4401 +        dst[0] = SDL_SwapFloatBE(sample0);
  5.4402 +        dst--;
  5.4403 +        eps += srcsize;
  5.4404 +        if ((eps << 1) >= dstsize) {
  5.4405 +            src--;
  5.4406 +            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4407 +            last_sample0 = sample0;
  5.4408 +            eps -= dstsize;
  5.4409 +        }
  5.4410 +    }
  5.4411 +    cvt->len_cvt = dstsize;
  5.4412 +    if (cvt->filters[++cvt->filter_index]) {
  5.4413 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4414 +    }
  5.4415 +}
  5.4416 +
  5.4417 +static void SDLCALL
  5.4418 +SDL_Downsample_F32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4419 +{
  5.4420 +#ifdef DEBUG_CONVERT
  5.4421 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 1 channels.\n", cvt->rate_incr);
  5.4422 +#endif
  5.4423 +
  5.4424 +    const int srcsize = cvt->len_cvt - 64;
  5.4425 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4426 +    register int eps = 0;
  5.4427 +    float *dst = (float *) cvt->buf;
  5.4428 +    const float *src = (float *) cvt->buf;
  5.4429 +    const float *target = (const float *) (cvt->buf + dstsize);
  5.4430 +    float sample0 = SDL_SwapFloatBE(src[0]);
  5.4431 +    float last_sample0 = sample0;
  5.4432 +    while (dst != target) {
  5.4433 +        src++;
  5.4434 +        eps += dstsize;
  5.4435 +        if ((eps << 1) >= srcsize) {
  5.4436 +            dst[0] = SDL_SwapFloatBE(sample0);
  5.4437 +            dst++;
  5.4438 +            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4439 +            last_sample0 = sample0;
  5.4440 +            eps -= srcsize;
  5.4441 +        }
  5.4442 +    }
  5.4443 +    cvt->len_cvt = dstsize;
  5.4444 +    if (cvt->filters[++cvt->filter_index]) {
  5.4445 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4446 +    }
  5.4447 +}
  5.4448 +
  5.4449 +static void SDLCALL
  5.4450 +SDL_Upsample_F32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4451 +{
  5.4452 +#ifdef DEBUG_CONVERT
  5.4453 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 2 channels.\n", cvt->rate_incr);
  5.4454 +#endif
  5.4455 +
  5.4456 +    const int srcsize = cvt->len_cvt - 128;
  5.4457 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4458 +    register int eps = 0;
  5.4459 +    float *dst = ((float *) (cvt->buf + dstsize)) - 2;
  5.4460 +    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
  5.4461 +    const float *target = ((const float *) cvt->buf) - 2;
  5.4462 +    float sample1 = SDL_SwapFloatBE(src[1]);
  5.4463 +    float sample0 = SDL_SwapFloatBE(src[0]);
  5.4464 +    float last_sample1 = sample1;
  5.4465 +    float last_sample0 = sample0;
  5.4466 +    while (dst != target) {
  5.4467 +        dst[1] = SDL_SwapFloatBE(sample1);
  5.4468 +        dst[0] = SDL_SwapFloatBE(sample0);
  5.4469 +        dst -= 2;
  5.4470 +        eps += srcsize;
  5.4471 +        if ((eps << 1) >= dstsize) {
  5.4472 +            src -= 2;
  5.4473 +            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
  5.4474 +            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4475 +            last_sample1 = sample1;
  5.4476 +            last_sample0 = sample0;
  5.4477 +            eps -= dstsize;
  5.4478 +        }
  5.4479 +    }
  5.4480 +    cvt->len_cvt = dstsize;
  5.4481 +    if (cvt->filters[++cvt->filter_index]) {
  5.4482 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4483 +    }
  5.4484 +}
  5.4485 +
  5.4486 +static void SDLCALL
  5.4487 +SDL_Downsample_F32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4488 +{
  5.4489 +#ifdef DEBUG_CONVERT
  5.4490 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 2 channels.\n", cvt->rate_incr);
  5.4491 +#endif
  5.4492 +
  5.4493 +    const int srcsize = cvt->len_cvt - 128;
  5.4494 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4495 +    register int eps = 0;
  5.4496 +    float *dst = (float *) cvt->buf;
  5.4497 +    const float *src = (float *) cvt->buf;
  5.4498 +    const float *target = (const float *) (cvt->buf + dstsize);
  5.4499 +    float sample0 = SDL_SwapFloatBE(src[0]);
  5.4500 +    float sample1 = SDL_SwapFloatBE(src[1]);
  5.4501 +    float last_sample0 = sample0;
  5.4502 +    float last_sample1 = sample1;
  5.4503 +    while (dst != target) {
  5.4504 +        src += 2;
  5.4505 +        eps += dstsize;
  5.4506 +        if ((eps << 1) >= srcsize) {
  5.4507 +            dst[0] = SDL_SwapFloatBE(sample0);
  5.4508 +            dst[1] = SDL_SwapFloatBE(sample1);
  5.4509 +            dst += 2;
  5.4510 +            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4511 +            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
  5.4512 +            last_sample0 = sample0;
  5.4513 +            last_sample1 = sample1;
  5.4514 +            eps -= srcsize;
  5.4515 +        }
  5.4516 +    }
  5.4517 +    cvt->len_cvt = dstsize;
  5.4518 +    if (cvt->filters[++cvt->filter_index]) {
  5.4519 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4520 +    }
  5.4521 +}
  5.4522 +
  5.4523 +static void SDLCALL
  5.4524 +SDL_Upsample_F32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4525 +{
  5.4526 +#ifdef DEBUG_CONVERT
  5.4527 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 4 channels.\n", cvt->rate_incr);
  5.4528 +#endif
  5.4529 +
  5.4530 +    const int srcsize = cvt->len_cvt - 256;
  5.4531 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4532 +    register int eps = 0;
  5.4533 +    float *dst = ((float *) (cvt->buf + dstsize)) - 4;
  5.4534 +    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
  5.4535 +    const float *target = ((const float *) cvt->buf) - 4;
  5.4536 +    float sample3 = SDL_SwapFloatBE(src[3]);
  5.4537 +    float sample2 = SDL_SwapFloatBE(src[2]);
  5.4538 +    float sample1 = SDL_SwapFloatBE(src[1]);
  5.4539 +    float sample0 = SDL_SwapFloatBE(src[0]);
  5.4540 +    float last_sample3 = sample3;
  5.4541 +    float last_sample2 = sample2;
  5.4542 +    float last_sample1 = sample1;
  5.4543 +    float last_sample0 = sample0;
  5.4544 +    while (dst != target) {
  5.4545 +        dst[3] = SDL_SwapFloatBE(sample3);
  5.4546 +        dst[2] = SDL_SwapFloatBE(sample2);
  5.4547 +        dst[1] = SDL_SwapFloatBE(sample1);
  5.4548 +        dst[0] = SDL_SwapFloatBE(sample0);
  5.4549 +        dst -= 4;
  5.4550 +        eps += srcsize;
  5.4551 +        if ((eps << 1) >= dstsize) {
  5.4552 +            src -= 4;
  5.4553 +            sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
  5.4554 +            sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
  5.4555 +            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
  5.4556 +            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4557 +            last_sample3 = sample3;
  5.4558 +            last_sample2 = sample2;
  5.4559 +            last_sample1 = sample1;
  5.4560 +            last_sample0 = sample0;
  5.4561 +            eps -= dstsize;
  5.4562 +        }
  5.4563 +    }
  5.4564 +    cvt->len_cvt = dstsize;
  5.4565 +    if (cvt->filters[++cvt->filter_index]) {
  5.4566 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4567 +    }
  5.4568 +}
  5.4569 +
  5.4570 +static void SDLCALL
  5.4571 +SDL_Downsample_F32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4572 +{
  5.4573 +#ifdef DEBUG_CONVERT
  5.4574 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 4 channels.\n", cvt->rate_incr);
  5.4575 +#endif
  5.4576 +
  5.4577 +    const int srcsize = cvt->len_cvt - 256;
  5.4578 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4579 +    register int eps = 0;
  5.4580 +    float *dst = (float *) cvt->buf;
  5.4581 +    const float *src = (float *) cvt->buf;
  5.4582 +    const float *target = (const float *) (cvt->buf + dstsize);
  5.4583 +    float sample0 = SDL_SwapFloatBE(src[0]);
  5.4584 +    float sample1 = SDL_SwapFloatBE(src[1]);
  5.4585 +    float sample2 = SDL_SwapFloatBE(src[2]);
  5.4586 +    float sample3 = SDL_SwapFloatBE(src[3]);
  5.4587 +    float last_sample0 = sample0;
  5.4588 +    float last_sample1 = sample1;
  5.4589 +    float last_sample2 = sample2;
  5.4590 +    float last_sample3 = sample3;
  5.4591 +    while (dst != target) {
  5.4592 +        src += 4;
  5.4593 +        eps += dstsize;
  5.4594 +        if ((eps << 1) >= srcsize) {
  5.4595 +            dst[0] = SDL_SwapFloatBE(sample0);
  5.4596 +            dst[1] = SDL_SwapFloatBE(sample1);
  5.4597 +            dst[2] = SDL_SwapFloatBE(sample2);
  5.4598 +            dst[3] = SDL_SwapFloatBE(sample3);
  5.4599 +            dst += 4;
  5.4600 +            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4601 +            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
  5.4602 +            sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
  5.4603 +            sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
  5.4604 +            last_sample0 = sample0;
  5.4605 +            last_sample1 = sample1;
  5.4606 +            last_sample2 = sample2;
  5.4607 +            last_sample3 = sample3;
  5.4608 +            eps -= srcsize;
  5.4609 +        }
  5.4610 +    }
  5.4611 +    cvt->len_cvt = dstsize;
  5.4612 +    if (cvt->filters[++cvt->filter_index]) {
  5.4613 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4614 +    }
  5.4615 +}
  5.4616 +
  5.4617 +static void SDLCALL
  5.4618 +SDL_Upsample_F32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4619 +{
  5.4620 +#ifdef DEBUG_CONVERT
  5.4621 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 6 channels.\n", cvt->rate_incr);
  5.4622 +#endif
  5.4623 +
  5.4624 +    const int srcsize = cvt->len_cvt - 384;
  5.4625 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4626 +    register int eps = 0;
  5.4627 +    float *dst = ((float *) (cvt->buf + dstsize)) - 6;
  5.4628 +    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
  5.4629 +    const float *target = ((const float *) cvt->buf) - 6;
  5.4630 +    float sample5 = SDL_SwapFloatBE(src[5]);
  5.4631 +    float sample4 = SDL_SwapFloatBE(src[4]);
  5.4632 +    float sample3 = SDL_SwapFloatBE(src[3]);
  5.4633 +    float sample2 = SDL_SwapFloatBE(src[2]);
  5.4634 +    float sample1 = SDL_SwapFloatBE(src[1]);
  5.4635 +    float sample0 = SDL_SwapFloatBE(src[0]);
  5.4636 +    float last_sample5 = sample5;
  5.4637 +    float last_sample4 = sample4;
  5.4638 +    float last_sample3 = sample3;
  5.4639 +    float last_sample2 = sample2;
  5.4640 +    float last_sample1 = sample1;
  5.4641 +    float last_sample0 = sample0;
  5.4642 +    while (dst != target) {
  5.4643 +        dst[5] = SDL_SwapFloatBE(sample5);
  5.4644 +        dst[4] = SDL_SwapFloatBE(sample4);
  5.4645 +        dst[3] = SDL_SwapFloatBE(sample3);
  5.4646 +        dst[2] = SDL_SwapFloatBE(sample2);
  5.4647 +        dst[1] = SDL_SwapFloatBE(sample1);
  5.4648 +        dst[0] = SDL_SwapFloatBE(sample0);
  5.4649 +        dst -= 6;
  5.4650 +        eps += srcsize;
  5.4651 +        if ((eps << 1) >= dstsize) {
  5.4652 +            src -= 6;
  5.4653 +            sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
  5.4654 +            sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
  5.4655 +            sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
  5.4656 +            sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
  5.4657 +            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
  5.4658 +            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4659 +            last_sample5 = sample5;
  5.4660 +            last_sample4 = sample4;
  5.4661 +            last_sample3 = sample3;
  5.4662 +            last_sample2 = sample2;
  5.4663 +            last_sample1 = sample1;
  5.4664 +            last_sample0 = sample0;
  5.4665 +            eps -= dstsize;
  5.4666 +        }
  5.4667 +    }
  5.4668 +    cvt->len_cvt = dstsize;
  5.4669 +    if (cvt->filters[++cvt->filter_index]) {
  5.4670 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4671 +    }
  5.4672 +}
  5.4673 +
  5.4674 +static void SDLCALL
  5.4675 +SDL_Downsample_F32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4676 +{
  5.4677 +#ifdef DEBUG_CONVERT
  5.4678 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 6 channels.\n", cvt->rate_incr);
  5.4679 +#endif
  5.4680 +
  5.4681 +    const int srcsize = cvt->len_cvt - 384;
  5.4682 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4683 +    register int eps = 0;
  5.4684 +    float *dst = (float *) cvt->buf;
  5.4685 +    const float *src = (float *) cvt->buf;
  5.4686 +    const float *target = (const float *) (cvt->buf + dstsize);
  5.4687 +    float sample0 = SDL_SwapFloatBE(src[0]);
  5.4688 +    float sample1 = SDL_SwapFloatBE(src[1]);
  5.4689 +    float sample2 = SDL_SwapFloatBE(src[2]);
  5.4690 +    float sample3 = SDL_SwapFloatBE(src[3]);
  5.4691 +    float sample4 = SDL_SwapFloatBE(src[4]);
  5.4692 +    float sample5 = SDL_SwapFloatBE(src[5]);
  5.4693 +    float last_sample0 = sample0;
  5.4694 +    float last_sample1 = sample1;
  5.4695 +    float last_sample2 = sample2;
  5.4696 +    float last_sample3 = sample3;
  5.4697 +    float last_sample4 = sample4;
  5.4698 +    float last_sample5 = sample5;
  5.4699 +    while (dst != target) {
  5.4700 +        src += 6;
  5.4701 +        eps += dstsize;
  5.4702 +        if ((eps << 1) >= srcsize) {
  5.4703 +            dst[0] = SDL_SwapFloatBE(sample0);
  5.4704 +            dst[1] = SDL_SwapFloatBE(sample1);
  5.4705 +            dst[2] = SDL_SwapFloatBE(sample2);
  5.4706 +            dst[3] = SDL_SwapFloatBE(sample3);
  5.4707 +            dst[4] = SDL_SwapFloatBE(sample4);
  5.4708 +            dst[5] = SDL_SwapFloatBE(sample5);
  5.4709 +            dst += 6;
  5.4710 +            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4711 +            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
  5.4712 +            sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
  5.4713 +            sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
  5.4714 +            sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
  5.4715 +            sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
  5.4716 +            last_sample0 = sample0;
  5.4717 +            last_sample1 = sample1;
  5.4718 +            last_sample2 = sample2;
  5.4719 +            last_sample3 = sample3;
  5.4720 +            last_sample4 = sample4;
  5.4721 +            last_sample5 = sample5;
  5.4722 +            eps -= srcsize;
  5.4723 +        }
  5.4724 +    }
  5.4725 +    cvt->len_cvt = dstsize;
  5.4726 +    if (cvt->filters[++cvt->filter_index]) {
  5.4727 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4728 +    }
  5.4729 +}
  5.4730 +
  5.4731 +static void SDLCALL
  5.4732 +SDL_Upsample_F32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4733 +{
  5.4734 +#ifdef DEBUG_CONVERT
  5.4735 +    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 8 channels.\n", cvt->rate_incr);
  5.4736 +#endif
  5.4737 +
  5.4738 +    const int srcsize = cvt->len_cvt - 512;
  5.4739 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4740 +    register int eps = 0;
  5.4741 +    float *dst = ((float *) (cvt->buf + dstsize)) - 8;
  5.4742 +    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
  5.4743 +    const float *target = ((const float *) cvt->buf) - 8;
  5.4744 +    float sample7 = SDL_SwapFloatBE(src[7]);
  5.4745 +    float sample6 = SDL_SwapFloatBE(src[6]);
  5.4746 +    float sample5 = SDL_SwapFloatBE(src[5]);
  5.4747 +    float sample4 = SDL_SwapFloatBE(src[4]);
  5.4748 +    float sample3 = SDL_SwapFloatBE(src[3]);
  5.4749 +    float sample2 = SDL_SwapFloatBE(src[2]);
  5.4750 +    float sample1 = SDL_SwapFloatBE(src[1]);
  5.4751 +    float sample0 = SDL_SwapFloatBE(src[0]);
  5.4752 +    float last_sample7 = sample7;
  5.4753 +    float last_sample6 = sample6;
  5.4754 +    float last_sample5 = sample5;
  5.4755 +    float last_sample4 = sample4;
  5.4756 +    float last_sample3 = sample3;
  5.4757 +    float last_sample2 = sample2;
  5.4758 +    float last_sample1 = sample1;
  5.4759 +    float last_sample0 = sample0;
  5.4760 +    while (dst != target) {
  5.4761 +        dst[7] = SDL_SwapFloatBE(sample7);
  5.4762 +        dst[6] = SDL_SwapFloatBE(sample6);
  5.4763 +        dst[5] = SDL_SwapFloatBE(sample5);
  5.4764 +        dst[4] = SDL_SwapFloatBE(sample4);
  5.4765 +        dst[3] = SDL_SwapFloatBE(sample3);
  5.4766 +        dst[2] = SDL_SwapFloatBE(sample2);
  5.4767 +        dst[1] = SDL_SwapFloatBE(sample1);
  5.4768 +        dst[0] = SDL_SwapFloatBE(sample0);
  5.4769 +        dst -= 8;
  5.4770 +        eps += srcsize;
  5.4771 +        if ((eps << 1) >= dstsize) {
  5.4772 +            src -= 8;
  5.4773 +            sample7 = (float) ((((double) SDL_SwapFloatBE(src[7])) + ((double) last_sample7)) * 0.5);
  5.4774 +            sample6 = (float) ((((double) SDL_SwapFloatBE(src[6])) + ((double) last_sample6)) * 0.5);
  5.4775 +            sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
  5.4776 +            sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
  5.4777 +            sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
  5.4778 +            sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
  5.4779 +            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
  5.4780 +            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4781 +            last_sample7 = sample7;
  5.4782 +            last_sample6 = sample6;
  5.4783 +            last_sample5 = sample5;
  5.4784 +            last_sample4 = sample4;
  5.4785 +            last_sample3 = sample3;
  5.4786 +            last_sample2 = sample2;
  5.4787 +            last_sample1 = sample1;
  5.4788 +            last_sample0 = sample0;
  5.4789 +            eps -= dstsize;
  5.4790 +        }
  5.4791 +    }
  5.4792 +    cvt->len_cvt = dstsize;
  5.4793 +    if (cvt->filters[++cvt->filter_index]) {
  5.4794 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4795 +    }
  5.4796 +}
  5.4797 +
  5.4798 +static void SDLCALL
  5.4799 +SDL_Downsample_F32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4800 +{
  5.4801 +#ifdef DEBUG_CONVERT
  5.4802 +    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 8 channels.\n", cvt->rate_incr);
  5.4803 +#endif
  5.4804 +
  5.4805 +    const int srcsize = cvt->len_cvt - 512;
  5.4806 +    const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
  5.4807 +    register int eps = 0;
  5.4808 +    float *dst = (float *) cvt->buf;
  5.4809 +    const float *src = (float *) cvt->buf;
  5.4810 +    const float *target = (const float *) (cvt->buf + dstsize);
  5.4811 +    float sample0 = SDL_SwapFloatBE(src[0]);
  5.4812 +    float sample1 = SDL_SwapFloatBE(src[1]);
  5.4813 +    float sample2 = SDL_SwapFloatBE(src[2]);
  5.4814 +    float sample3 = SDL_SwapFloatBE(src[3]);
  5.4815 +    float sample4 = SDL_SwapFloatBE(src[4]);
  5.4816 +    float sample5 = SDL_SwapFloatBE(src[5]);
  5.4817 +    float sample6 = SDL_SwapFloatBE(src[6]);
  5.4818 +    float sample7 = SDL_SwapFloatBE(src[7]);
  5.4819 +    float last_sample0 = sample0;
  5.4820 +    float last_sample1 = sample1;
  5.4821 +    float last_sample2 = sample2;
  5.4822 +    float last_sample3 = sample3;
  5.4823 +    float last_sample4 = sample4;
  5.4824 +    float last_sample5 = sample5;
  5.4825 +    float last_sample6 = sample6;
  5.4826 +    float last_sample7 = sample7;
  5.4827 +    while (dst != target) {
  5.4828 +        src += 8;
  5.4829 +        eps += dstsize;
  5.4830 +        if ((eps << 1) >= srcsize) {
  5.4831 +            dst[0] = SDL_SwapFloatBE(sample0);
  5.4832 +            dst[1] = SDL_SwapFloatBE(sample1);
  5.4833 +            dst[2] = SDL_SwapFloatBE(sample2);
  5.4834 +            dst[3] = SDL_SwapFloatBE(sample3);
  5.4835 +            dst[4] = SDL_SwapFloatBE(sample4);
  5.4836 +            dst[5] = SDL_SwapFloatBE(sample5);
  5.4837 +            dst[6] = SDL_SwapFloatBE(sample6);
  5.4838 +            dst[7] = SDL_SwapFloatBE(sample7);
  5.4839 +            dst += 8;
  5.4840 +            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
  5.4841 +            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
  5.4842 +            sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
  5.4843 +            sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
  5.4844 +            sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
  5.4845 +            sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
  5.4846 +            sample6 = (float) ((((double) SDL_SwapFloatBE(src[6])) + ((double) last_sample6)) * 0.5);
  5.4847 +            sample7 = (float) ((((double) SDL_SwapFloatBE(src[7])) + ((double) last_sample7)) * 0.5);
  5.4848 +            last_sample0 = sample0;
  5.4849 +            last_sample1 = sample1;
  5.4850 +            last_sample2 = sample2;
  5.4851 +            last_sample3 = sample3;
  5.4852 +            last_sample4 = sample4;
  5.4853 +            last_sample5 = sample5;
  5.4854 +            last_sample6 = sample6;
  5.4855 +            last_sample7 = sample7;
  5.4856 +            eps -= srcsize;
  5.4857 +        }
  5.4858 +    }
  5.4859 +    cvt->len_cvt = dstsize;
  5.4860 +    if (cvt->filters[++cvt->filter_index]) {
  5.4861 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4862 +    }
  5.4863 +}
  5.4864 +
  5.4865 +
  5.4866 +#if !LESS_RESAMPLERS
  5.4867 +
  5.4868 +static void SDLCALL
  5.4869 +SDL_Upsample_U8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4870 +{
  5.4871 +#ifdef DEBUG_CONVERT
  5.4872 +    fprintf(stderr, "Upsample (x2) AUDIO_U8, 1 channels.\n");
  5.4873 +#endif
  5.4874 +
  5.4875 +    const int srcsize = cvt->len_cvt;
  5.4876 +    const int dstsize = cvt->len_cvt * 2;
  5.4877 +    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1;
  5.4878 +    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
  5.4879 +    const Uint8 *target = ((const Uint8 *) cvt->buf) - 1;
  5.4880 +    Sint16 last_sample0 = (Sint16) src[0];
  5.4881 +    while (dst != target) {
  5.4882 +        const Sint16 sample0 = (Sint16) src[0];
  5.4883 +        src--;
  5.4884 +        dst[1] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.4885 +        dst[0] = (Uint8) sample0;
  5.4886 +        last_sample0 = sample0;
  5.4887 +        dst -= 2;
  5.4888 +    }
  5.4889 +
  5.4890 +    cvt->len_cvt = dstsize;
  5.4891 +    if (cvt->filters[++cvt->filter_index]) {
  5.4892 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4893 +    }
  5.4894 +}
  5.4895 +
  5.4896 +static void SDLCALL
  5.4897 +SDL_Downsample_U8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4898 +{
  5.4899 +#ifdef DEBUG_CONVERT
  5.4900 +    fprintf(stderr, "Downsample (x2) AUDIO_U8, 1 channels.\n");
  5.4901 +#endif
  5.4902 +
  5.4903 +    const int srcsize = cvt->len_cvt;
  5.4904 +    const int dstsize = cvt->len_cvt / 2;
  5.4905 +    Uint8 *dst = (Uint8 *) cvt->buf;
  5.4906 +    const Uint8 *src = (Uint8 *) cvt->buf;
  5.4907 +    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
  5.4908 +    Sint16 last_sample0 = (Sint16) src[0];
  5.4909 +    while (dst != target) {
  5.4910 +        const Sint16 sample0 = (Sint16) src[0];
  5.4911 +        src += 2;
  5.4912 +        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.4913 +        last_sample0 = sample0;
  5.4914 +        dst++;
  5.4915 +    }
  5.4916 +
  5.4917 +    cvt->len_cvt = dstsize;
  5.4918 +    if (cvt->filters[++cvt->filter_index]) {
  5.4919 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4920 +    }
  5.4921 +}
  5.4922 +
  5.4923 +static void SDLCALL
  5.4924 +SDL_Upsample_U8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4925 +{
  5.4926 +#ifdef DEBUG_CONVERT
  5.4927 +    fprintf(stderr, "Upsample (x4) AUDIO_U8, 1 channels.\n");
  5.4928 +#endif
  5.4929 +
  5.4930 +    const int srcsize = cvt->len_cvt;
  5.4931 +    const int dstsize = cvt->len_cvt * 4;
  5.4932 +    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1;
  5.4933 +    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
  5.4934 +    const Uint8 *target = ((const Uint8 *) cvt->buf) - 1;
  5.4935 +    Sint16 last_sample0 = (Sint16) src[0];
  5.4936 +    while (dst != target) {
  5.4937 +        const Sint16 sample0 = (Sint16) src[0];
  5.4938 +        src--;
  5.4939 +        dst[3] = (Uint8) sample0;
  5.4940 +        dst[2] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
  5.4941 +        dst[1] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.4942 +        dst[0] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
  5.4943 +        last_sample0 = sample0;
  5.4944 +        dst -= 4;
  5.4945 +    }
  5.4946 +
  5.4947 +    cvt->len_cvt = dstsize;
  5.4948 +    if (cvt->filters[++cvt->filter_index]) {
  5.4949 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4950 +    }
  5.4951 +}
  5.4952 +
  5.4953 +static void SDLCALL
  5.4954 +SDL_Downsample_U8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4955 +{
  5.4956 +#ifdef DEBUG_CONVERT
  5.4957 +    fprintf(stderr, "Downsample (x4) AUDIO_U8, 1 channels.\n");
  5.4958 +#endif
  5.4959 +
  5.4960 +    const int srcsize = cvt->len_cvt;
  5.4961 +    const int dstsize = cvt->len_cvt / 4;
  5.4962 +    Uint8 *dst = (Uint8 *) cvt->buf;
  5.4963 +    const Uint8 *src = (Uint8 *) cvt->buf;
  5.4964 +    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
  5.4965 +    Sint16 last_sample0 = (Sint16) src[0];
  5.4966 +    while (dst != target) {
  5.4967 +        const Sint16 sample0 = (Sint16) src[0];
  5.4968 +        src += 4;
  5.4969 +        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.4970 +        last_sample0 = sample0;
  5.4971 +        dst++;
  5.4972 +    }
  5.4973 +
  5.4974 +    cvt->len_cvt = dstsize;
  5.4975 +    if (cvt->filters[++cvt->filter_index]) {
  5.4976 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.4977 +    }
  5.4978 +}
  5.4979 +
  5.4980 +static void SDLCALL
  5.4981 +SDL_Upsample_U8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.4982 +{
  5.4983 +#ifdef DEBUG_CONVERT
  5.4984 +    fprintf(stderr, "Upsample (x2) AUDIO_U8, 2 channels.\n");
  5.4985 +#endif
  5.4986 +
  5.4987 +    const int srcsize = cvt->len_cvt;
  5.4988 +    const int dstsize = cvt->len_cvt * 2;
  5.4989 +    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2;
  5.4990 +    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
  5.4991 +    const Uint8 *target = ((const Uint8 *) cvt->buf) - 2;
  5.4992 +    Sint16 last_sample1 = (Sint16) src[1];
  5.4993 +    Sint16 last_sample0 = (Sint16) src[0];
  5.4994 +    while (dst != target) {
  5.4995 +        const Sint16 sample1 = (Sint16) src[1];
  5.4996 +        const Sint16 sample0 = (Sint16) src[0];
  5.4997 +        src -= 2;
  5.4998 +        dst[3] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.4999 +        dst[2] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5000 +        dst[1] = (Uint8) sample1;
  5.5001 +        dst[0] = (Uint8) sample0;
  5.5002 +        last_sample1 = sample1;
  5.5003 +        last_sample0 = sample0;
  5.5004 +        dst -= 4;
  5.5005 +    }
  5.5006 +
  5.5007 +    cvt->len_cvt = dstsize;
  5.5008 +    if (cvt->filters[++cvt->filter_index]) {
  5.5009 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5010 +    }
  5.5011 +}
  5.5012 +
  5.5013 +static void SDLCALL
  5.5014 +SDL_Downsample_U8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5015 +{
  5.5016 +#ifdef DEBUG_CONVERT
  5.5017 +    fprintf(stderr, "Downsample (x2) AUDIO_U8, 2 channels.\n");
  5.5018 +#endif
  5.5019 +
  5.5020 +    const int srcsize = cvt->len_cvt;
  5.5021 +    const int dstsize = cvt->len_cvt / 2;
  5.5022 +    Uint8 *dst = (Uint8 *) cvt->buf;
  5.5023 +    const Uint8 *src = (Uint8 *) cvt->buf;
  5.5024 +    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
  5.5025 +    Sint16 last_sample0 = (Sint16) src[0];
  5.5026 +    Sint16 last_sample1 = (Sint16) src[1];
  5.5027 +    while (dst != target) {
  5.5028 +        const Sint16 sample0 = (Sint16) src[0];
  5.5029 +        const Sint16 sample1 = (Sint16) src[1];
  5.5030 +        src += 4;
  5.5031 +        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5032 +        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.5033 +        last_sample0 = sample0;
  5.5034 +        last_sample1 = sample1;
  5.5035 +        dst += 2;
  5.5036 +    }
  5.5037 +
  5.5038 +    cvt->len_cvt = dstsize;
  5.5039 +    if (cvt->filters[++cvt->filter_index]) {
  5.5040 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5041 +    }
  5.5042 +}
  5.5043 +
  5.5044 +static void SDLCALL
  5.5045 +SDL_Upsample_U8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5046 +{
  5.5047 +#ifdef DEBUG_CONVERT
  5.5048 +    fprintf(stderr, "Upsample (x4) AUDIO_U8, 2 channels.\n");
  5.5049 +#endif
  5.5050 +
  5.5051 +    const int srcsize = cvt->len_cvt;
  5.5052 +    const int dstsize = cvt->len_cvt * 4;
  5.5053 +    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2;
  5.5054 +    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
  5.5055 +    const Uint8 *target = ((const Uint8 *) cvt->buf) - 2;
  5.5056 +    Sint16 last_sample1 = (Sint16) src[1];
  5.5057 +    Sint16 last_sample0 = (Sint16) src[0];
  5.5058 +    while (dst != target) {
  5.5059 +        const Sint16 sample1 = (Sint16) src[1];
  5.5060 +        const Sint16 sample0 = (Sint16) src[0];
  5.5061 +        src -= 2;
  5.5062 +        dst[7] = (Uint8) sample1;
  5.5063 +        dst[6] = (Uint8) sample0;
  5.5064 +        dst[5] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
  5.5065 +        dst[4] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
  5.5066 +        dst[3] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.5067 +        dst[2] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5068 +        dst[1] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
  5.5069 +        dst[0] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
  5.5070 +        last_sample1 = sample1;
  5.5071 +        last_sample0 = sample0;
  5.5072 +        dst -= 8;
  5.5073 +    }
  5.5074 +
  5.5075 +    cvt->len_cvt = dstsize;
  5.5076 +    if (cvt->filters[++cvt->filter_index]) {
  5.5077 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5078 +    }
  5.5079 +}
  5.5080 +
  5.5081 +static void SDLCALL
  5.5082 +SDL_Downsample_U8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5083 +{
  5.5084 +#ifdef DEBUG_CONVERT
  5.5085 +    fprintf(stderr, "Downsample (x4) AUDIO_U8, 2 channels.\n");
  5.5086 +#endif
  5.5087 +
  5.5088 +    const int srcsize = cvt->len_cvt;
  5.5089 +    const int dstsize = cvt->len_cvt / 4;
  5.5090 +    Uint8 *dst = (Uint8 *) cvt->buf;
  5.5091 +    const Uint8 *src = (Uint8 *) cvt->buf;
  5.5092 +    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
  5.5093 +    Sint16 last_sample0 = (Sint16) src[0];
  5.5094 +    Sint16 last_sample1 = (Sint16) src[1];
  5.5095 +    while (dst != target) {
  5.5096 +        const Sint16 sample0 = (Sint16) src[0];
  5.5097 +        const Sint16 sample1 = (Sint16) src[1];
  5.5098 +        src += 8;
  5.5099 +        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5100 +        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.5101 +        last_sample0 = sample0;
  5.5102 +        last_sample1 = sample1;
  5.5103 +        dst += 2;
  5.5104 +    }
  5.5105 +
  5.5106 +    cvt->len_cvt = dstsize;
  5.5107 +    if (cvt->filters[++cvt->filter_index]) {
  5.5108 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5109 +    }
  5.5110 +}
  5.5111 +
  5.5112 +static void SDLCALL
  5.5113 +SDL_Upsample_U8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5114 +{
  5.5115 +#ifdef DEBUG_CONVERT
  5.5116 +    fprintf(stderr, "Upsample (x2) AUDIO_U8, 4 channels.\n");
  5.5117 +#endif
  5.5118 +
  5.5119 +    const int srcsize = cvt->len_cvt;
  5.5120 +    const int dstsize = cvt->len_cvt * 2;
  5.5121 +    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4;
  5.5122 +    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
  5.5123 +    const Uint8 *target = ((const Uint8 *) cvt->buf) - 4;
  5.5124 +    Sint16 last_sample3 = (Sint16) src[3];
  5.5125 +    Sint16 last_sample2 = (Sint16) src[2];
  5.5126 +    Sint16 last_sample1 = (Sint16) src[1];
  5.5127 +    Sint16 last_sample0 = (Sint16) src[0];
  5.5128 +    while (dst != target) {
  5.5129 +        const Sint16 sample3 = (Sint16) src[3];
  5.5130 +        const Sint16 sample2 = (Sint16) src[2];
  5.5131 +        const Sint16 sample1 = (Sint16) src[1];
  5.5132 +        const Sint16 sample0 = (Sint16) src[0];
  5.5133 +        src -= 4;
  5.5134 +        dst[7] = (Uint8) ((sample3 + last_sample3) >> 1);
  5.5135 +        dst[6] = (Uint8) ((sample2 + last_sample2) >> 1);
  5.5136 +        dst[5] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.5137 +        dst[4] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5138 +        dst[3] = (Uint8) sample3;
  5.5139 +        dst[2] = (Uint8) sample2;
  5.5140 +        dst[1] = (Uint8) sample1;
  5.5141 +        dst[0] = (Uint8) sample0;
  5.5142 +        last_sample3 = sample3;
  5.5143 +        last_sample2 = sample2;
  5.5144 +        last_sample1 = sample1;
  5.5145 +        last_sample0 = sample0;
  5.5146 +        dst -= 8;
  5.5147 +    }
  5.5148 +
  5.5149 +    cvt->len_cvt = dstsize;
  5.5150 +    if (cvt->filters[++cvt->filter_index]) {
  5.5151 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5152 +    }
  5.5153 +}
  5.5154 +
  5.5155 +static void SDLCALL
  5.5156 +SDL_Downsample_U8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5157 +{
  5.5158 +#ifdef DEBUG_CONVERT
  5.5159 +    fprintf(stderr, "Downsample (x2) AUDIO_U8, 4 channels.\n");
  5.5160 +#endif
  5.5161 +
  5.5162 +    const int srcsize = cvt->len_cvt;
  5.5163 +    const int dstsize = cvt->len_cvt / 2;
  5.5164 +    Uint8 *dst = (Uint8 *) cvt->buf;
  5.5165 +    const Uint8 *src = (Uint8 *) cvt->buf;
  5.5166 +    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
  5.5167 +    Sint16 last_sample0 = (Sint16) src[0];
  5.5168 +    Sint16 last_sample1 = (Sint16) src[1];
  5.5169 +    Sint16 last_sample2 = (Sint16) src[2];
  5.5170 +    Sint16 last_sample3 = (Sint16) src[3];
  5.5171 +    while (dst != target) {
  5.5172 +        const Sint16 sample0 = (Sint16) src[0];
  5.5173 +        const Sint16 sample1 = (Sint16) src[1];
  5.5174 +        const Sint16 sample2 = (Sint16) src[2];
  5.5175 +        const Sint16 sample3 = (Sint16) src[3];
  5.5176 +        src += 8;
  5.5177 +        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5178 +        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.5179 +        dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
  5.5180 +        dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
  5.5181 +        last_sample0 = sample0;
  5.5182 +        last_sample1 = sample1;
  5.5183 +        last_sample2 = sample2;
  5.5184 +        last_sample3 = sample3;
  5.5185 +        dst += 4;
  5.5186 +    }
  5.5187 +
  5.5188 +    cvt->len_cvt = dstsize;
  5.5189 +    if (cvt->filters[++cvt->filter_index]) {
  5.5190 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5191 +    }
  5.5192 +}
  5.5193 +
  5.5194 +static void SDLCALL
  5.5195 +SDL_Upsample_U8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5196 +{
  5.5197 +#ifdef DEBUG_CONVERT
  5.5198 +    fprintf(stderr, "Upsample (x4) AUDIO_U8, 4 channels.\n");
  5.5199 +#endif
  5.5200 +
  5.5201 +    const int srcsize = cvt->len_cvt;
  5.5202 +    const int dstsize = cvt->len_cvt * 4;
  5.5203 +    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4;
  5.5204 +    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
  5.5205 +    const Uint8 *target = ((const Uint8 *) cvt->buf) - 4;
  5.5206 +    Sint16 last_sample3 = (Sint16) src[3];
  5.5207 +    Sint16 last_sample2 = (Sint16) src[2];
  5.5208 +    Sint16 last_sample1 = (Sint16) src[1];
  5.5209 +    Sint16 last_sample0 = (Sint16) src[0];
  5.5210 +    while (dst != target) {
  5.5211 +        const Sint16 sample3 = (Sint16) src[3];
  5.5212 +        const Sint16 sample2 = (Sint16) src[2];
  5.5213 +        const Sint16 sample1 = (Sint16) src[1];
  5.5214 +        const Sint16 sample0 = (Sint16) src[0];
  5.5215 +        src -= 4;
  5.5216 +        dst[15] = (Uint8) sample3;
  5.5217 +        dst[14] = (Uint8) sample2;
  5.5218 +        dst[13] = (Uint8) sample1;
  5.5219 +        dst[12] = (Uint8) sample0;
  5.5220 +        dst[11] = (Uint8) (((3 * sample3) + last_sample3) >> 2);
  5.5221 +        dst[10] = (Uint8) (((3 * sample2) + last_sample2) >> 2);
  5.5222 +        dst[9] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
  5.5223 +        dst[8] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
  5.5224 +        dst[7] = (Uint8) ((sample3 + last_sample3) >> 1);
  5.5225 +        dst[6] = (Uint8) ((sample2 + last_sample2) >> 1);
  5.5226 +        dst[5] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.5227 +        dst[4] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5228 +        dst[3] = (Uint8) ((sample3 + (3 * last_sample3)) >> 2);
  5.5229 +        dst[2] = (Uint8) ((sample2 + (3 * last_sample2)) >> 2);
  5.5230 +        dst[1] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
  5.5231 +        dst[0] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
  5.5232 +        last_sample3 = sample3;
  5.5233 +        last_sample2 = sample2;
  5.5234 +        last_sample1 = sample1;
  5.5235 +        last_sample0 = sample0;
  5.5236 +        dst -= 16;
  5.5237 +    }
  5.5238 +
  5.5239 +    cvt->len_cvt = dstsize;
  5.5240 +    if (cvt->filters[++cvt->filter_index]) {
  5.5241 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5242 +    }
  5.5243 +}
  5.5244 +
  5.5245 +static void SDLCALL
  5.5246 +SDL_Downsample_U8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5247 +{
  5.5248 +#ifdef DEBUG_CONVERT
  5.5249 +    fprintf(stderr, "Downsample (x4) AUDIO_U8, 4 channels.\n");
  5.5250 +#endif
  5.5251 +
  5.5252 +    const int srcsize = cvt->len_cvt;
  5.5253 +    const int dstsize = cvt->len_cvt / 4;
  5.5254 +    Uint8 *dst = (Uint8 *) cvt->buf;
  5.5255 +    const Uint8 *src = (Uint8 *) cvt->buf;
  5.5256 +    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
  5.5257 +    Sint16 last_sample0 = (Sint16) src[0];
  5.5258 +    Sint16 last_sample1 = (Sint16) src[1];
  5.5259 +    Sint16 last_sample2 = (Sint16) src[2];
  5.5260 +    Sint16 last_sample3 = (Sint16) src[3];
  5.5261 +    while (dst != target) {
  5.5262 +        const Sint16 sample0 = (Sint16) src[0];
  5.5263 +        const Sint16 sample1 = (Sint16) src[1];
  5.5264 +        const Sint16 sample2 = (Sint16) src[2];
  5.5265 +        const Sint16 sample3 = (Sint16) src[3];
  5.5266 +        src += 16;
  5.5267 +        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5268 +        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.5269 +        dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
  5.5270 +        dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
  5.5271 +        last_sample0 = sample0;
  5.5272 +        last_sample1 = sample1;
  5.5273 +        last_sample2 = sample2;
  5.5274 +        last_sample3 = sample3;
  5.5275 +        dst += 4;
  5.5276 +    }
  5.5277 +
  5.5278 +    cvt->len_cvt = dstsize;
  5.5279 +    if (cvt->filters[++cvt->filter_index]) {
  5.5280 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5281 +    }
  5.5282 +}
  5.5283 +
  5.5284 +static void SDLCALL
  5.5285 +SDL_Upsample_U8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5286 +{
  5.5287 +#ifdef DEBUG_CONVERT
  5.5288 +    fprintf(stderr, "Upsample (x2) AUDIO_U8, 6 channels.\n");
  5.5289 +#endif
  5.5290 +
  5.5291 +    const int srcsize = cvt->len_cvt;
  5.5292 +    const int dstsize = cvt->len_cvt * 2;
  5.5293 +    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6;
  5.5294 +    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
  5.5295 +    const Uint8 *target = ((const Uint8 *) cvt->buf) - 6;
  5.5296 +    Sint16 last_sample5 = (Sint16) src[5];
  5.5297 +    Sint16 last_sample4 = (Sint16) src[4];
  5.5298 +    Sint16 last_sample3 = (Sint16) src[3];
  5.5299 +    Sint16 last_sample2 = (Sint16) src[2];
  5.5300 +    Sint16 last_sample1 = (Sint16) src[1];
  5.5301 +    Sint16 last_sample0 = (Sint16) src[0];
  5.5302 +    while (dst != target) {
  5.5303 +        const Sint16 sample5 = (Sint16) src[5];
  5.5304 +        const Sint16 sample4 = (Sint16) src[4];
  5.5305 +        const Sint16 sample3 = (Sint16) src[3];
  5.5306 +        const Sint16 sample2 = (Sint16) src[2];
  5.5307 +        const Sint16 sample1 = (Sint16) src[1];
  5.5308 +        const Sint16 sample0 = (Sint16) src[0];
  5.5309 +        src -= 6;
  5.5310 +        dst[11] = (Uint8) ((sample5 + last_sample5) >> 1);
  5.5311 +        dst[10] = (Uint8) ((sample4 + last_sample4) >> 1);
  5.5312 +        dst[9] = (Uint8) ((sample3 + last_sample3) >> 1);
  5.5313 +        dst[8] = (Uint8) ((sample2 + last_sample2) >> 1);
  5.5314 +        dst[7] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.5315 +        dst[6] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5316 +        dst[5] = (Uint8) sample5;
  5.5317 +        dst[4] = (Uint8) sample4;
  5.5318 +        dst[3] = (Uint8) sample3;
  5.5319 +        dst[2] = (Uint8) sample2;
  5.5320 +        dst[1] = (Uint8) sample1;
  5.5321 +        dst[0] = (Uint8) sample0;
  5.5322 +        last_sample5 = sample5;
  5.5323 +        last_sample4 = sample4;
  5.5324 +        last_sample3 = sample3;
  5.5325 +        last_sample2 = sample2;
  5.5326 +        last_sample1 = sample1;
  5.5327 +        last_sample0 = sample0;
  5.5328 +        dst -= 12;
  5.5329 +    }
  5.5330 +
  5.5331 +    cvt->len_cvt = dstsize;
  5.5332 +    if (cvt->filters[++cvt->filter_index]) {
  5.5333 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5334 +    }
  5.5335 +}
  5.5336 +
  5.5337 +static void SDLCALL
  5.5338 +SDL_Downsample_U8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5339 +{
  5.5340 +#ifdef DEBUG_CONVERT
  5.5341 +    fprintf(stderr, "Downsample (x2) AUDIO_U8, 6 channels.\n");
  5.5342 +#endif
  5.5343 +
  5.5344 +    const int srcsize = cvt->len_cvt;
  5.5345 +    const int dstsize = cvt->len_cvt / 2;
  5.5346 +    Uint8 *dst = (Uint8 *) cvt->buf;
  5.5347 +    const Uint8 *src = (Uint8 *) cvt->buf;
  5.5348 +    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
  5.5349 +    Sint16 last_sample0 = (Sint16) src[0];
  5.5350 +    Sint16 last_sample1 = (Sint16) src[1];
  5.5351 +    Sint16 last_sample2 = (Sint16) src[2];
  5.5352 +    Sint16 last_sample3 = (Sint16) src[3];
  5.5353 +    Sint16 last_sample4 = (Sint16) src[4];
  5.5354 +    Sint16 last_sample5 = (Sint16) src[5];
  5.5355 +    while (dst != target) {
  5.5356 +        const Sint16 sample0 = (Sint16) src[0];
  5.5357 +        const Sint16 sample1 = (Sint16) src[1];
  5.5358 +        const Sint16 sample2 = (Sint16) src[2];
  5.5359 +        const Sint16 sample3 = (Sint16) src[3];
  5.5360 +        const Sint16 sample4 = (Sint16) src[4];
  5.5361 +        const Sint16 sample5 = (Sint16) src[5];
  5.5362 +        src += 12;
  5.5363 +        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5364 +        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.5365 +        dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
  5.5366 +        dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
  5.5367 +        dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
  5.5368 +        dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
  5.5369 +        last_sample0 = sample0;
  5.5370 +        last_sample1 = sample1;
  5.5371 +        last_sample2 = sample2;
  5.5372 +        last_sample3 = sample3;
  5.5373 +        last_sample4 = sample4;
  5.5374 +        last_sample5 = sample5;
  5.5375 +        dst += 6;
  5.5376 +    }
  5.5377 +
  5.5378 +    cvt->len_cvt = dstsize;
  5.5379 +    if (cvt->filters[++cvt->filter_index]) {
  5.5380 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5381 +    }
  5.5382 +}
  5.5383 +
  5.5384 +static void SDLCALL
  5.5385 +SDL_Upsample_U8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5386 +{
  5.5387 +#ifdef DEBUG_CONVERT
  5.5388 +    fprintf(stderr, "Upsample (x4) AUDIO_U8, 6 channels.\n");
  5.5389 +#endif
  5.5390 +
  5.5391 +    const int srcsize = cvt->len_cvt;
  5.5392 +    const int dstsize = cvt->len_cvt * 4;
  5.5393 +    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6;
  5.5394 +    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
  5.5395 +    const Uint8 *target = ((const Uint8 *) cvt->buf) - 6;
  5.5396 +    Sint16 last_sample5 = (Sint16) src[5];
  5.5397 +    Sint16 last_sample4 = (Sint16) src[4];
  5.5398 +    Sint16 last_sample3 = (Sint16) src[3];
  5.5399 +    Sint16 last_sample2 = (Sint16) src[2];
  5.5400 +    Sint16 last_sample1 = (Sint16) src[1];
  5.5401 +    Sint16 last_sample0 = (Sint16) src[0];
  5.5402 +    while (dst != target) {
  5.5403 +        const Sint16 sample5 = (Sint16) src[5];
  5.5404 +        const Sint16 sample4 = (Sint16) src[4];
  5.5405 +        const Sint16 sample3 = (Sint16) src[3];
  5.5406 +        const Sint16 sample2 = (Sint16) src[2];
  5.5407 +        const Sint16 sample1 = (Sint16) src[1];
  5.5408 +        const Sint16 sample0 = (Sint16) src[0];
  5.5409 +        src -= 6;
  5.5410 +        dst[23] = (Uint8) sample5;
  5.5411 +        dst[22] = (Uint8) sample4;
  5.5412 +        dst[21] = (Uint8) sample3;
  5.5413 +        dst[20] = (Uint8) sample2;
  5.5414 +        dst[19] = (Uint8) sample1;
  5.5415 +        dst[18] = (Uint8) sample0;
  5.5416 +        dst[17] = (Uint8) (((3 * sample5) + last_sample5) >> 2);
  5.5417 +        dst[16] = (Uint8) (((3 * sample4) + last_sample4) >> 2);
  5.5418 +        dst[15] = (Uint8) (((3 * sample3) + last_sample3) >> 2);
  5.5419 +        dst[14] = (Uint8) (((3 * sample2) + last_sample2) >> 2);
  5.5420 +        dst[13] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
  5.5421 +        dst[12] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
  5.5422 +        dst[11] = (Uint8) ((sample5 + last_sample5) >> 1);
  5.5423 +        dst[10] = (Uint8) ((sample4 + last_sample4) >> 1);
  5.5424 +        dst[9] = (Uint8) ((sample3 + last_sample3) >> 1);
  5.5425 +        dst[8] = (Uint8) ((sample2 + last_sample2) >> 1);
  5.5426 +        dst[7] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.5427 +        dst[6] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5428 +        dst[5] = (Uint8) ((sample5 + (3 * last_sample5)) >> 2);
  5.5429 +        dst[4] = (Uint8) ((sample4 + (3 * last_sample4)) >> 2);
  5.5430 +        dst[3] = (Uint8) ((sample3 + (3 * last_sample3)) >> 2);
  5.5431 +        dst[2] = (Uint8) ((sample2 + (3 * last_sample2)) >> 2);
  5.5432 +        dst[1] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
  5.5433 +        dst[0] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
  5.5434 +        last_sample5 = sample5;
  5.5435 +        last_sample4 = sample4;
  5.5436 +        last_sample3 = sample3;
  5.5437 +        last_sample2 = sample2;
  5.5438 +        last_sample1 = sample1;
  5.5439 +        last_sample0 = sample0;
  5.5440 +        dst -= 24;
  5.5441 +    }
  5.5442 +
  5.5443 +    cvt->len_cvt = dstsize;
  5.5444 +    if (cvt->filters[++cvt->filter_index]) {
  5.5445 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5446 +    }
  5.5447 +}
  5.5448 +
  5.5449 +static void SDLCALL
  5.5450 +SDL_Downsample_U8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5451 +{
  5.5452 +#ifdef DEBUG_CONVERT
  5.5453 +    fprintf(stderr, "Downsample (x4) AUDIO_U8, 6 channels.\n");
  5.5454 +#endif
  5.5455 +
  5.5456 +    const int srcsize = cvt->len_cvt;
  5.5457 +    const int dstsize = cvt->len_cvt / 4;
  5.5458 +    Uint8 *dst = (Uint8 *) cvt->buf;
  5.5459 +    const Uint8 *src = (Uint8 *) cvt->buf;
  5.5460 +    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
  5.5461 +    Sint16 last_sample0 = (Sint16) src[0];
  5.5462 +    Sint16 last_sample1 = (Sint16) src[1];
  5.5463 +    Sint16 last_sample2 = (Sint16) src[2];
  5.5464 +    Sint16 last_sample3 = (Sint16) src[3];
  5.5465 +    Sint16 last_sample4 = (Sint16) src[4];
  5.5466 +    Sint16 last_sample5 = (Sint16) src[5];
  5.5467 +    while (dst != target) {
  5.5468 +        const Sint16 sample0 = (Sint16) src[0];
  5.5469 +        const Sint16 sample1 = (Sint16) src[1];
  5.5470 +        const Sint16 sample2 = (Sint16) src[2];
  5.5471 +        const Sint16 sample3 = (Sint16) src[3];
  5.5472 +        const Sint16 sample4 = (Sint16) src[4];
  5.5473 +        const Sint16 sample5 = (Sint16) src[5];
  5.5474 +        src += 24;
  5.5475 +        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5476 +        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.5477 +        dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
  5.5478 +        dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
  5.5479 +        dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
  5.5480 +        dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
  5.5481 +        last_sample0 = sample0;
  5.5482 +        last_sample1 = sample1;
  5.5483 +        last_sample2 = sample2;
  5.5484 +        last_sample3 = sample3;
  5.5485 +        last_sample4 = sample4;
  5.5486 +        last_sample5 = sample5;
  5.5487 +        dst += 6;
  5.5488 +    }
  5.5489 +
  5.5490 +    cvt->len_cvt = dstsize;
  5.5491 +    if (cvt->filters[++cvt->filter_index]) {
  5.5492 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5493 +    }
  5.5494 +}
  5.5495 +
  5.5496 +static void SDLCALL
  5.5497 +SDL_Upsample_U8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5498 +{
  5.5499 +#ifdef DEBUG_CONVERT
  5.5500 +    fprintf(stderr, "Upsample (x2) AUDIO_U8, 8 channels.\n");
  5.5501 +#endif
  5.5502 +
  5.5503 +    const int srcsize = cvt->len_cvt;
  5.5504 +    const int dstsize = cvt->len_cvt * 2;
  5.5505 +    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8;
  5.5506 +    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
  5.5507 +    const Uint8 *target = ((const Uint8 *) cvt->buf) - 8;
  5.5508 +    Sint16 last_sample7 = (Sint16) src[7];
  5.5509 +    Sint16 last_sample6 = (Sint16) src[6];
  5.5510 +    Sint16 last_sample5 = (Sint16) src[5];
  5.5511 +    Sint16 last_sample4 = (Sint16) src[4];
  5.5512 +    Sint16 last_sample3 = (Sint16) src[3];
  5.5513 +    Sint16 last_sample2 = (Sint16) src[2];
  5.5514 +    Sint16 last_sample1 = (Sint16) src[1];
  5.5515 +    Sint16 last_sample0 = (Sint16) src[0];
  5.5516 +    while (dst != target) {
  5.5517 +        const Sint16 sample7 = (Sint16) src[7];
  5.5518 +        const Sint16 sample6 = (Sint16) src[6];
  5.5519 +        const Sint16 sample5 = (Sint16) src[5];
  5.5520 +        const Sint16 sample4 = (Sint16) src[4];
  5.5521 +        const Sint16 sample3 = (Sint16) src[3];
  5.5522 +        const Sint16 sample2 = (Sint16) src[2];
  5.5523 +        const Sint16 sample1 = (Sint16) src[1];
  5.5524 +        const Sint16 sample0 = (Sint16) src[0];
  5.5525 +        src -= 8;
  5.5526 +        dst[15] = (Uint8) ((sample7 + last_sample7) >> 1);
  5.5527 +        dst[14] = (Uint8) ((sample6 + last_sample6) >> 1);
  5.5528 +        dst[13] = (Uint8) ((sample5 + last_sample5) >> 1);
  5.5529 +        dst[12] = (Uint8) ((sample4 + last_sample4) >> 1);
  5.5530 +        dst[11] = (Uint8) ((sample3 + last_sample3) >> 1);
  5.5531 +        dst[10] = (Uint8) ((sample2 + last_sample2) >> 1);
  5.5532 +        dst[9] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.5533 +        dst[8] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5534 +        dst[7] = (Uint8) sample7;
  5.5535 +        dst[6] = (Uint8) sample6;
  5.5536 +        dst[5] = (Uint8) sample5;
  5.5537 +        dst[4] = (Uint8) sample4;
  5.5538 +        dst[3] = (Uint8) sample3;
  5.5539 +        dst[2] = (Uint8) sample2;
  5.5540 +        dst[1] = (Uint8) sample1;
  5.5541 +        dst[0] = (Uint8) sample0;
  5.5542 +        last_sample7 = sample7;
  5.5543 +        last_sample6 = sample6;
  5.5544 +        last_sample5 = sample5;
  5.5545 +        last_sample4 = sample4;
  5.5546 +        last_sample3 = sample3;
  5.5547 +        last_sample2 = sample2;
  5.5548 +        last_sample1 = sample1;
  5.5549 +        last_sample0 = sample0;
  5.5550 +        dst -= 16;
  5.5551 +    }
  5.5552 +
  5.5553 +    cvt->len_cvt = dstsize;
  5.5554 +    if (cvt->filters[++cvt->filter_index]) {
  5.5555 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5556 +    }
  5.5557 +}
  5.5558 +
  5.5559 +static void SDLCALL
  5.5560 +SDL_Downsample_U8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5561 +{
  5.5562 +#ifdef DEBUG_CONVERT
  5.5563 +    fprintf(stderr, "Downsample (x2) AUDIO_U8, 8 channels.\n");
  5.5564 +#endif
  5.5565 +
  5.5566 +    const int srcsize = cvt->len_cvt;
  5.5567 +    const int dstsize = cvt->len_cvt / 2;
  5.5568 +    Uint8 *dst = (Uint8 *) cvt->buf;
  5.5569 +    const Uint8 *src = (Uint8 *) cvt->buf;
  5.5570 +    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
  5.5571 +    Sint16 last_sample0 = (Sint16) src[0];
  5.5572 +    Sint16 last_sample1 = (Sint16) src[1];
  5.5573 +    Sint16 last_sample2 = (Sint16) src[2];
  5.5574 +    Sint16 last_sample3 = (Sint16) src[3];
  5.5575 +    Sint16 last_sample4 = (Sint16) src[4];
  5.5576 +    Sint16 last_sample5 = (Sint16) src[5];
  5.5577 +    Sint16 last_sample6 = (Sint16) src[6];
  5.5578 +    Sint16 last_sample7 = (Sint16) src[7];
  5.5579 +    while (dst != target) {
  5.5580 +        const Sint16 sample0 = (Sint16) src[0];
  5.5581 +        const Sint16 sample1 = (Sint16) src[1];
  5.5582 +        const Sint16 sample2 = (Sint16) src[2];
  5.5583 +        const Sint16 sample3 = (Sint16) src[3];
  5.5584 +        const Sint16 sample4 = (Sint16) src[4];
  5.5585 +        const Sint16 sample5 = (Sint16) src[5];
  5.5586 +        const Sint16 sample6 = (Sint16) src[6];
  5.5587 +        const Sint16 sample7 = (Sint16) src[7];
  5.5588 +        src += 16;
  5.5589 +        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5590 +        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.5591 +        dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
  5.5592 +        dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
  5.5593 +        dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
  5.5594 +        dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
  5.5595 +        dst[6] = (Uint8) ((sample6 + last_sample6) >> 1);
  5.5596 +        dst[7] = (Uint8) ((sample7 + last_sample7) >> 1);
  5.5597 +        last_sample0 = sample0;
  5.5598 +        last_sample1 = sample1;
  5.5599 +        last_sample2 = sample2;
  5.5600 +        last_sample3 = sample3;
  5.5601 +        last_sample4 = sample4;
  5.5602 +        last_sample5 = sample5;
  5.5603 +        last_sample6 = sample6;
  5.5604 +        last_sample7 = sample7;
  5.5605 +        dst += 8;
  5.5606 +    }
  5.5607 +
  5.5608 +    cvt->len_cvt = dstsize;
  5.5609 +    if (cvt->filters[++cvt->filter_index]) {
  5.5610 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5611 +    }
  5.5612 +}
  5.5613 +
  5.5614 +static void SDLCALL
  5.5615 +SDL_Upsample_U8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5616 +{
  5.5617 +#ifdef DEBUG_CONVERT
  5.5618 +    fprintf(stderr, "Upsample (x4) AUDIO_U8, 8 channels.\n");
  5.5619 +#endif
  5.5620 +
  5.5621 +    const int srcsize = cvt->len_cvt;
  5.5622 +    const int dstsize = cvt->len_cvt * 4;
  5.5623 +    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8;
  5.5624 +    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
  5.5625 +    const Uint8 *target = ((const Uint8 *) cvt->buf) - 8;
  5.5626 +    Sint16 last_sample7 = (Sint16) src[7];
  5.5627 +    Sint16 last_sample6 = (Sint16) src[6];
  5.5628 +    Sint16 last_sample5 = (Sint16) src[5];
  5.5629 +    Sint16 last_sample4 = (Sint16) src[4];
  5.5630 +    Sint16 last_sample3 = (Sint16) src[3];
  5.5631 +    Sint16 last_sample2 = (Sint16) src[2];
  5.5632 +    Sint16 last_sample1 = (Sint16) src[1];
  5.5633 +    Sint16 last_sample0 = (Sint16) src[0];
  5.5634 +    while (dst != target) {
  5.5635 +        const Sint16 sample7 = (Sint16) src[7];
  5.5636 +        const Sint16 sample6 = (Sint16) src[6];
  5.5637 +        const Sint16 sample5 = (Sint16) src[5];
  5.5638 +        const Sint16 sample4 = (Sint16) src[4];
  5.5639 +        const Sint16 sample3 = (Sint16) src[3];
  5.5640 +        const Sint16 sample2 = (Sint16) src[2];
  5.5641 +        const Sint16 sample1 = (Sint16) src[1];
  5.5642 +        const Sint16 sample0 = (Sint16) src[0];
  5.5643 +        src -= 8;
  5.5644 +        dst[31] = (Uint8) sample7;
  5.5645 +        dst[30] = (Uint8) sample6;
  5.5646 +        dst[29] = (Uint8) sample5;
  5.5647 +        dst[28] = (Uint8) sample4;
  5.5648 +        dst[27] = (Uint8) sample3;
  5.5649 +        dst[26] = (Uint8) sample2;
  5.5650 +        dst[25] = (Uint8) sample1;
  5.5651 +        dst[24] = (Uint8) sample0;
  5.5652 +        dst[23] = (Uint8) (((3 * sample7) + last_sample7) >> 2);
  5.5653 +        dst[22] = (Uint8) (((3 * sample6) + last_sample6) >> 2);
  5.5654 +        dst[21] = (Uint8) (((3 * sample5) + last_sample5) >> 2);
  5.5655 +        dst[20] = (Uint8) (((3 * sample4) + last_sample4) >> 2);
  5.5656 +        dst[19] = (Uint8) (((3 * sample3) + last_sample3) >> 2);
  5.5657 +        dst[18] = (Uint8) (((3 * sample2) + last_sample2) >> 2);
  5.5658 +        dst[17] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
  5.5659 +        dst[16] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
  5.5660 +        dst[15] = (Uint8) ((sample7 + last_sample7) >> 1);
  5.5661 +        dst[14] = (Uint8) ((sample6 + last_sample6) >> 1);
  5.5662 +        dst[13] = (Uint8) ((sample5 + last_sample5) >> 1);
  5.5663 +        dst[12] = (Uint8) ((sample4 + last_sample4) >> 1);
  5.5664 +        dst[11] = (Uint8) ((sample3 + last_sample3) >> 1);
  5.5665 +        dst[10] = (Uint8) ((sample2 + last_sample2) >> 1);
  5.5666 +        dst[9] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.5667 +        dst[8] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5668 +        dst[7] = (Uint8) ((sample7 + (3 * last_sample7)) >> 2);
  5.5669 +        dst[6] = (Uint8) ((sample6 + (3 * last_sample6)) >> 2);
  5.5670 +        dst[5] = (Uint8) ((sample5 + (3 * last_sample5)) >> 2);
  5.5671 +        dst[4] = (Uint8) ((sample4 + (3 * last_sample4)) >> 2);
  5.5672 +        dst[3] = (Uint8) ((sample3 + (3 * last_sample3)) >> 2);
  5.5673 +        dst[2] = (Uint8) ((sample2 + (3 * last_sample2)) >> 2);
  5.5674 +        dst[1] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
  5.5675 +        dst[0] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
  5.5676 +        last_sample7 = sample7;
  5.5677 +        last_sample6 = sample6;
  5.5678 +        last_sample5 = sample5;
  5.5679 +        last_sample4 = sample4;
  5.5680 +        last_sample3 = sample3;
  5.5681 +        last_sample2 = sample2;
  5.5682 +        last_sample1 = sample1;
  5.5683 +        last_sample0 = sample0;
  5.5684 +        dst -= 32;
  5.5685 +    }
  5.5686 +
  5.5687 +    cvt->len_cvt = dstsize;
  5.5688 +    if (cvt->filters[++cvt->filter_index]) {
  5.5689 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5690 +    }
  5.5691 +}
  5.5692 +
  5.5693 +static void SDLCALL
  5.5694 +SDL_Downsample_U8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5695 +{
  5.5696 +#ifdef DEBUG_CONVERT
  5.5697 +    fprintf(stderr, "Downsample (x4) AUDIO_U8, 8 channels.\n");
  5.5698 +#endif
  5.5699 +
  5.5700 +    const int srcsize = cvt->len_cvt;
  5.5701 +    const int dstsize = cvt->len_cvt / 4;
  5.5702 +    Uint8 *dst = (Uint8 *) cvt->buf;
  5.5703 +    const Uint8 *src = (Uint8 *) cvt->buf;
  5.5704 +    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
  5.5705 +    Sint16 last_sample0 = (Sint16) src[0];
  5.5706 +    Sint16 last_sample1 = (Sint16) src[1];
  5.5707 +    Sint16 last_sample2 = (Sint16) src[2];
  5.5708 +    Sint16 last_sample3 = (Sint16) src[3];
  5.5709 +    Sint16 last_sample4 = (Sint16) src[4];
  5.5710 +    Sint16 last_sample5 = (Sint16) src[5];
  5.5711 +    Sint16 last_sample6 = (Sint16) src[6];
  5.5712 +    Sint16 last_sample7 = (Sint16) src[7];
  5.5713 +    while (dst != target) {
  5.5714 +        const Sint16 sample0 = (Sint16) src[0];
  5.5715 +        const Sint16 sample1 = (Sint16) src[1];
  5.5716 +        const Sint16 sample2 = (Sint16) src[2];
  5.5717 +        const Sint16 sample3 = (Sint16) src[3];
  5.5718 +        const Sint16 sample4 = (Sint16) src[4];
  5.5719 +        const Sint16 sample5 = (Sint16) src[5];
  5.5720 +        const Sint16 sample6 = (Sint16) src[6];
  5.5721 +        const Sint16 sample7 = (Sint16) src[7];
  5.5722 +        src += 32;
  5.5723 +        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
  5.5724 +        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
  5.5725 +        dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
  5.5726 +        dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
  5.5727 +        dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
  5.5728 +        dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
  5.5729 +        dst[6] = (Uint8) ((sample6 + last_sample6) >> 1);
  5.5730 +        dst[7] = (Uint8) ((sample7 + last_sample7) >> 1);
  5.5731 +        last_sample0 = sample0;
  5.5732 +        last_sample1 = sample1;
  5.5733 +        last_sample2 = sample2;
  5.5734 +        last_sample3 = sample3;
  5.5735 +        last_sample4 = sample4;
  5.5736 +        last_sample5 = sample5;
  5.5737 +        last_sample6 = sample6;
  5.5738 +        last_sample7 = sample7;
  5.5739 +        dst += 8;
  5.5740 +    }
  5.5741 +
  5.5742 +    cvt->len_cvt = dstsize;
  5.5743 +    if (cvt->filters[++cvt->filter_index]) {
  5.5744 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5745 +    }
  5.5746 +}
  5.5747 +
  5.5748 +static void SDLCALL
  5.5749 +SDL_Upsample_S8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5750 +{
  5.5751 +#ifdef DEBUG_CONVERT
  5.5752 +    fprintf(stderr, "Upsample (x2) AUDIO_S8, 1 channels.\n");
  5.5753 +#endif
  5.5754 +
  5.5755 +    const int srcsize = cvt->len_cvt;
  5.5756 +    const int dstsize = cvt->len_cvt * 2;
  5.5757 +    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1;
  5.5758 +    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
  5.5759 +    const Sint8 *target = ((const Sint8 *) cvt->buf) - 1;
  5.5760 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.5761 +    while (dst != target) {
  5.5762 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.5763 +        src--;
  5.5764 +        dst[1] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.5765 +        dst[0] = (Sint8) sample0;
  5.5766 +        last_sample0 = sample0;
  5.5767 +        dst -= 2;
  5.5768 +    }
  5.5769 +
  5.5770 +    cvt->len_cvt = dstsize;
  5.5771 +    if (cvt->filters[++cvt->filter_index]) {
  5.5772 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5773 +    }
  5.5774 +}
  5.5775 +
  5.5776 +static void SDLCALL
  5.5777 +SDL_Downsample_S8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5778 +{
  5.5779 +#ifdef DEBUG_CONVERT
  5.5780 +    fprintf(stderr, "Downsample (x2) AUDIO_S8, 1 channels.\n");
  5.5781 +#endif
  5.5782 +
  5.5783 +    const int srcsize = cvt->len_cvt;
  5.5784 +    const int dstsize = cvt->len_cvt / 2;
  5.5785 +    Sint8 *dst = (Sint8 *) cvt->buf;
  5.5786 +    const Sint8 *src = (Sint8 *) cvt->buf;
  5.5787 +    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
  5.5788 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.5789 +    while (dst != target) {
  5.5790 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.5791 +        src += 2;
  5.5792 +        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.5793 +        last_sample0 = sample0;
  5.5794 +        dst++;
  5.5795 +    }
  5.5796 +
  5.5797 +    cvt->len_cvt = dstsize;
  5.5798 +    if (cvt->filters[++cvt->filter_index]) {
  5.5799 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5800 +    }
  5.5801 +}
  5.5802 +
  5.5803 +static void SDLCALL
  5.5804 +SDL_Upsample_S8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5805 +{
  5.5806 +#ifdef DEBUG_CONVERT
  5.5807 +    fprintf(stderr, "Upsample (x4) AUDIO_S8, 1 channels.\n");
  5.5808 +#endif
  5.5809 +
  5.5810 +    const int srcsize = cvt->len_cvt;
  5.5811 +    const int dstsize = cvt->len_cvt * 4;
  5.5812 +    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1;
  5.5813 +    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
  5.5814 +    const Sint8 *target = ((const Sint8 *) cvt->buf) - 1;
  5.5815 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.5816 +    while (dst != target) {
  5.5817 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.5818 +        src--;
  5.5819 +        dst[3] = (Sint8) sample0;
  5.5820 +        dst[2] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
  5.5821 +        dst[1] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.5822 +        dst[0] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
  5.5823 +        last_sample0 = sample0;
  5.5824 +        dst -= 4;
  5.5825 +    }
  5.5826 +
  5.5827 +    cvt->len_cvt = dstsize;
  5.5828 +    if (cvt->filters[++cvt->filter_index]) {
  5.5829 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5830 +    }
  5.5831 +}
  5.5832 +
  5.5833 +static void SDLCALL
  5.5834 +SDL_Downsample_S8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5835 +{
  5.5836 +#ifdef DEBUG_CONVERT
  5.5837 +    fprintf(stderr, "Downsample (x4) AUDIO_S8, 1 channels.\n");
  5.5838 +#endif
  5.5839 +
  5.5840 +    const int srcsize = cvt->len_cvt;
  5.5841 +    const int dstsize = cvt->len_cvt / 4;
  5.5842 +    Sint8 *dst = (Sint8 *) cvt->buf;
  5.5843 +    const Sint8 *src = (Sint8 *) cvt->buf;
  5.5844 +    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
  5.5845 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.5846 +    while (dst != target) {
  5.5847 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.5848 +        src += 4;
  5.5849 +        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.5850 +        last_sample0 = sample0;
  5.5851 +        dst++;
  5.5852 +    }
  5.5853 +
  5.5854 +    cvt->len_cvt = dstsize;
  5.5855 +    if (cvt->filters[++cvt->filter_index]) {
  5.5856 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5857 +    }
  5.5858 +}
  5.5859 +
  5.5860 +static void SDLCALL
  5.5861 +SDL_Upsample_S8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5862 +{
  5.5863 +#ifdef DEBUG_CONVERT
  5.5864 +    fprintf(stderr, "Upsample (x2) AUDIO_S8, 2 channels.\n");
  5.5865 +#endif
  5.5866 +
  5.5867 +    const int srcsize = cvt->len_cvt;
  5.5868 +    const int dstsize = cvt->len_cvt * 2;
  5.5869 +    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2;
  5.5870 +    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
  5.5871 +    const Sint8 *target = ((const Sint8 *) cvt->buf) - 2;
  5.5872 +    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
  5.5873 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.5874 +    while (dst != target) {
  5.5875 +        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
  5.5876 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.5877 +        src -= 2;
  5.5878 +        dst[3] = (Sint8) ((sample1 + last_sample1) >> 1);
  5.5879 +        dst[2] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.5880 +        dst[1] = (Sint8) sample1;
  5.5881 +        dst[0] = (Sint8) sample0;
  5.5882 +        last_sample1 = sample1;
  5.5883 +        last_sample0 = sample0;
  5.5884 +        dst -= 4;
  5.5885 +    }
  5.5886 +
  5.5887 +    cvt->len_cvt = dstsize;
  5.5888 +    if (cvt->filters[++cvt->filter_index]) {
  5.5889 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5890 +    }
  5.5891 +}
  5.5892 +
  5.5893 +static void SDLCALL
  5.5894 +SDL_Downsample_S8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5895 +{
  5.5896 +#ifdef DEBUG_CONVERT
  5.5897 +    fprintf(stderr, "Downsample (x2) AUDIO_S8, 2 channels.\n");
  5.5898 +#endif
  5.5899 +
  5.5900 +    const int srcsize = cvt->len_cvt;
  5.5901 +    const int dstsize = cvt->len_cvt / 2;
  5.5902 +    Sint8 *dst = (Sint8 *) cvt->buf;
  5.5903 +    const Sint8 *src = (Sint8 *) cvt->buf;
  5.5904 +    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
  5.5905 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.5906 +    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
  5.5907 +    while (dst != target) {
  5.5908 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.5909 +        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
  5.5910 +        src += 4;
  5.5911 +        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.5912 +        dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
  5.5913 +        last_sample0 = sample0;
  5.5914 +        last_sample1 = sample1;
  5.5915 +        dst += 2;
  5.5916 +    }
  5.5917 +
  5.5918 +    cvt->len_cvt = dstsize;
  5.5919 +    if (cvt->filters[++cvt->filter_index]) {
  5.5920 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5921 +    }
  5.5922 +}
  5.5923 +
  5.5924 +static void SDLCALL
  5.5925 +SDL_Upsample_S8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5926 +{
  5.5927 +#ifdef DEBUG_CONVERT
  5.5928 +    fprintf(stderr, "Upsample (x4) AUDIO_S8, 2 channels.\n");
  5.5929 +#endif
  5.5930 +
  5.5931 +    const int srcsize = cvt->len_cvt;
  5.5932 +    const int dstsize = cvt->len_cvt * 4;
  5.5933 +    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2;
  5.5934 +    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
  5.5935 +    const Sint8 *target = ((const Sint8 *) cvt->buf) - 2;
  5.5936 +    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
  5.5937 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.5938 +    while (dst != target) {
  5.5939 +        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
  5.5940 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.5941 +        src -= 2;
  5.5942 +        dst[7] = (Sint8) sample1;
  5.5943 +        dst[6] = (Sint8) sample0;
  5.5944 +        dst[5] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
  5.5945 +        dst[4] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
  5.5946 +        dst[3] = (Sint8) ((sample1 + last_sample1) >> 1);
  5.5947 +        dst[2] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.5948 +        dst[1] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
  5.5949 +        dst[0] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
  5.5950 +        last_sample1 = sample1;
  5.5951 +        last_sample0 = sample0;
  5.5952 +        dst -= 8;
  5.5953 +    }
  5.5954 +
  5.5955 +    cvt->len_cvt = dstsize;
  5.5956 +    if (cvt->filters[++cvt->filter_index]) {
  5.5957 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5958 +    }
  5.5959 +}
  5.5960 +
  5.5961 +static void SDLCALL
  5.5962 +SDL_Downsample_S8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5963 +{
  5.5964 +#ifdef DEBUG_CONVERT
  5.5965 +    fprintf(stderr, "Downsample (x4) AUDIO_S8, 2 channels.\n");
  5.5966 +#endif
  5.5967 +
  5.5968 +    const int srcsize = cvt->len_cvt;
  5.5969 +    const int dstsize = cvt->len_cvt / 4;
  5.5970 +    Sint8 *dst = (Sint8 *) cvt->buf;
  5.5971 +    const Sint8 *src = (Sint8 *) cvt->buf;
  5.5972 +    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
  5.5973 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.5974 +    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
  5.5975 +    while (dst != target) {
  5.5976 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.5977 +        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
  5.5978 +        src += 8;
  5.5979 +        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.5980 +        dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
  5.5981 +        last_sample0 = sample0;
  5.5982 +        last_sample1 = sample1;
  5.5983 +        dst += 2;
  5.5984 +    }
  5.5985 +
  5.5986 +    cvt->len_cvt = dstsize;
  5.5987 +    if (cvt->filters[++cvt->filter_index]) {
  5.5988 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.5989 +    }
  5.5990 +}
  5.5991 +
  5.5992 +static void SDLCALL
  5.5993 +SDL_Upsample_S8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.5994 +{
  5.5995 +#ifdef DEBUG_CONVERT
  5.5996 +    fprintf(stderr, "Upsample (x2) AUDIO_S8, 4 channels.\n");
  5.5997 +#endif
  5.5998 +
  5.5999 +    const int srcsize = cvt->len_cvt;
  5.6000 +    const int dstsize = cvt->len_cvt * 2;
  5.6001 +    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4;
  5.6002 +    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
  5.6003 +    const Sint8 *target = ((const Sint8 *) cvt->buf) - 4;
  5.6004 +    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
  5.6005 +    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
  5.6006 +    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
  5.6007 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.6008 +    while (dst != target) {
  5.6009 +        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
  5.6010 +        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
  5.6011 +        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
  5.6012 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.6013 +        src -= 4;
  5.6014 +        dst[7] = (Sint8) ((sample3 + last_sample3) >> 1);
  5.6015 +        dst[6] = (Sint8) ((sample2 + last_sample2) >> 1);
  5.6016 +        dst[5] = (Sint8) ((sample1 + last_sample1) >> 1);
  5.6017 +        dst[4] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.6018 +        dst[3] = (Sint8) sample3;
  5.6019 +        dst[2] = (Sint8) sample2;
  5.6020 +        dst[1] = (Sint8) sample1;
  5.6021 +        dst[0] = (Sint8) sample0;
  5.6022 +        last_sample3 = sample3;
  5.6023 +        last_sample2 = sample2;
  5.6024 +        last_sample1 = sample1;
  5.6025 +        last_sample0 = sample0;
  5.6026 +        dst -= 8;
  5.6027 +    }
  5.6028 +
  5.6029 +    cvt->len_cvt = dstsize;
  5.6030 +    if (cvt->filters[++cvt->filter_index]) {
  5.6031 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.6032 +    }
  5.6033 +}
  5.6034 +
  5.6035 +static void SDLCALL
  5.6036 +SDL_Downsample_S8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.6037 +{
  5.6038 +#ifdef DEBUG_CONVERT
  5.6039 +    fprintf(stderr, "Downsample (x2) AUDIO_S8, 4 channels.\n");
  5.6040 +#endif
  5.6041 +
  5.6042 +    const int srcsize = cvt->len_cvt;
  5.6043 +    const int dstsize = cvt->len_cvt / 2;
  5.6044 +    Sint8 *dst = (Sint8 *) cvt->buf;
  5.6045 +    const Sint8 *src = (Sint8 *) cvt->buf;
  5.6046 +    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
  5.6047 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.6048 +    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
  5.6049 +    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
  5.6050 +    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
  5.6051 +    while (dst != target) {
  5.6052 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.6053 +        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
  5.6054 +        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
  5.6055 +        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
  5.6056 +        src += 8;
  5.6057 +        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.6058 +        dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
  5.6059 +        dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
  5.6060 +        dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
  5.6061 +        last_sample0 = sample0;
  5.6062 +        last_sample1 = sample1;
  5.6063 +        last_sample2 = sample2;
  5.6064 +        last_sample3 = sample3;
  5.6065 +        dst += 4;
  5.6066 +    }
  5.6067 +
  5.6068 +    cvt->len_cvt = dstsize;
  5.6069 +    if (cvt->filters[++cvt->filter_index]) {
  5.6070 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.6071 +    }
  5.6072 +}
  5.6073 +
  5.6074 +static void SDLCALL
  5.6075 +SDL_Upsample_S8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.6076 +{
  5.6077 +#ifdef DEBUG_CONVERT
  5.6078 +    fprintf(stderr, "Upsample (x4) AUDIO_S8, 4 channels.\n");
  5.6079 +#endif
  5.6080 +
  5.6081 +    const int srcsize = cvt->len_cvt;
  5.6082 +    const int dstsize = cvt->len_cvt * 4;
  5.6083 +    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4;
  5.6084 +    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
  5.6085 +    const Sint8 *target = ((const Sint8 *) cvt->buf) - 4;
  5.6086 +    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
  5.6087 +    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
  5.6088 +    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
  5.6089 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.6090 +    while (dst != target) {
  5.6091 +        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
  5.6092 +        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
  5.6093 +        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
  5.6094 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.6095 +        src -= 4;
  5.6096 +        dst[15] = (Sint8) sample3;
  5.6097 +        dst[14] = (Sint8) sample2;
  5.6098 +        dst[13] = (Sint8) sample1;
  5.6099 +        dst[12] = (Sint8) sample0;
  5.6100 +        dst[11] = (Sint8) (((3 * sample3) + last_sample3) >> 2);
  5.6101 +        dst[10] = (Sint8) (((3 * sample2) + last_sample2) >> 2);
  5.6102 +        dst[9] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
  5.6103 +        dst[8] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
  5.6104 +        dst[7] = (Sint8) ((sample3 + last_sample3) >> 1);
  5.6105 +        dst[6] = (Sint8) ((sample2 + last_sample2) >> 1);
  5.6106 +        dst[5] = (Sint8) ((sample1 + last_sample1) >> 1);
  5.6107 +        dst[4] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.6108 +        dst[3] = (Sint8) ((sample3 + (3 * last_sample3)) >> 2);
  5.6109 +        dst[2] = (Sint8) ((sample2 + (3 * last_sample2)) >> 2);
  5.6110 +        dst[1] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
  5.6111 +        dst[0] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
  5.6112 +        last_sample3 = sample3;
  5.6113 +        last_sample2 = sample2;
  5.6114 +        last_sample1 = sample1;
  5.6115 +        last_sample0 = sample0;
  5.6116 +        dst -= 16;
  5.6117 +    }
  5.6118 +
  5.6119 +    cvt->len_cvt = dstsize;
  5.6120 +    if (cvt->filters[++cvt->filter_index]) {
  5.6121 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.6122 +    }
  5.6123 +}
  5.6124 +
  5.6125 +static void SDLCALL
  5.6126 +SDL_Downsample_S8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.6127 +{
  5.6128 +#ifdef DEBUG_CONVERT
  5.6129 +    fprintf(stderr, "Downsample (x4) AUDIO_S8, 4 channels.\n");
  5.6130 +#endif
  5.6131 +
  5.6132 +    const int srcsize = cvt->len_cvt;
  5.6133 +    const int dstsize = cvt->len_cvt / 4;
  5.6134 +    Sint8 *dst = (Sint8 *) cvt->buf;
  5.6135 +    const Sint8 *src = (Sint8 *) cvt->buf;
  5.6136 +    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
  5.6137 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.6138 +    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
  5.6139 +    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
  5.6140 +    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
  5.6141 +    while (dst != target) {
  5.6142 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.6143 +        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
  5.6144 +        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
  5.6145 +        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
  5.6146 +        src += 16;
  5.6147 +        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.6148 +        dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
  5.6149 +        dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
  5.6150 +        dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
  5.6151 +        last_sample0 = sample0;
  5.6152 +        last_sample1 = sample1;
  5.6153 +        last_sample2 = sample2;
  5.6154 +        last_sample3 = sample3;
  5.6155 +        dst += 4;
  5.6156 +    }
  5.6157 +
  5.6158 +    cvt->len_cvt = dstsize;
  5.6159 +    if (cvt->filters[++cvt->filter_index]) {
  5.6160 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.6161 +    }
  5.6162 +}
  5.6163 +
  5.6164 +static void SDLCALL
  5.6165 +SDL_Upsample_S8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.6166 +{
  5.6167 +#ifdef DEBUG_CONVERT
  5.6168 +    fprintf(stderr, "Upsample (x2) AUDIO_S8, 6 channels.\n");
  5.6169 +#endif
  5.6170 +
  5.6171 +    const int srcsize = cvt->len_cvt;
  5.6172 +    const int dstsize = cvt->len_cvt * 2;
  5.6173 +    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6;
  5.6174 +    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
  5.6175 +    const Sint8 *target = ((const Sint8 *) cvt->buf) - 6;
  5.6176 +    Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
  5.6177 +    Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
  5.6178 +    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
  5.6179 +    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
  5.6180 +    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
  5.6181 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.6182 +    while (dst != target) {
  5.6183 +        const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
  5.6184 +        const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
  5.6185 +        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
  5.6186 +        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
  5.6187 +        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
  5.6188 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.6189 +        src -= 6;
  5.6190 +        dst[11] = (Sint8) ((sample5 + last_sample5) >> 1);
  5.6191 +        dst[10] = (Sint8) ((sample4 + last_sample4) >> 1);
  5.6192 +        dst[9] = (Sint8) ((sample3 + last_sample3) >> 1);
  5.6193 +        dst[8] = (Sint8) ((sample2 + last_sample2) >> 1);
  5.6194 +        dst[7] = (Sint8) ((sample1 + last_sample1) >> 1);
  5.6195 +        dst[6] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.6196 +        dst[5] = (Sint8) sample5;
  5.6197 +        dst[4] = (Sint8) sample4;
  5.6198 +        dst[3] = (Sint8) sample3;
  5.6199 +        dst[2] = (Sint8) sample2;
  5.6200 +        dst[1] = (Sint8) sample1;
  5.6201 +        dst[0] = (Sint8) sample0;
  5.6202 +        last_sample5 = sample5;
  5.6203 +        last_sample4 = sample4;
  5.6204 +        last_sample3 = sample3;
  5.6205 +        last_sample2 = sample2;
  5.6206 +        last_sample1 = sample1;
  5.6207 +        last_sample0 = sample0;
  5.6208 +        dst -= 12;
  5.6209 +    }
  5.6210 +
  5.6211 +    cvt->len_cvt = dstsize;
  5.6212 +    if (cvt->filters[++cvt->filter_index]) {
  5.6213 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.6214 +    }
  5.6215 +}
  5.6216 +
  5.6217 +static void SDLCALL
  5.6218 +SDL_Downsample_S8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.6219 +{
  5.6220 +#ifdef DEBUG_CONVERT
  5.6221 +    fprintf(stderr, "Downsample (x2) AUDIO_S8, 6 channels.\n");
  5.6222 +#endif
  5.6223 +
  5.6224 +    const int srcsize = cvt->len_cvt;
  5.6225 +    const int dstsize = cvt->len_cvt / 2;
  5.6226 +    Sint8 *dst = (Sint8 *) cvt->buf;
  5.6227 +    const Sint8 *src = (Sint8 *) cvt->buf;
  5.6228 +    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
  5.6229 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.6230 +    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
  5.6231 +    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
  5.6232 +    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
  5.6233 +    Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
  5.6234 +    Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
  5.6235 +    while (dst != target) {
  5.6236 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.6237 +        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
  5.6238 +        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
  5.6239 +        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
  5.6240 +        const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
  5.6241 +        const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
  5.6242 +        src += 12;
  5.6243 +        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.6244 +        dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
  5.6245 +        dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
  5.6246 +        dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
  5.6247 +        dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
  5.6248 +        dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
  5.6249 +        last_sample0 = sample0;
  5.6250 +        last_sample1 = sample1;
  5.6251 +        last_sample2 = sample2;
  5.6252 +        last_sample3 = sample3;
  5.6253 +        last_sample4 = sample4;
  5.6254 +        last_sample5 = sample5;
  5.6255 +        dst += 6;
  5.6256 +    }
  5.6257 +
  5.6258 +    cvt->len_cvt = dstsize;
  5.6259 +    if (cvt->filters[++cvt->filter_index]) {
  5.6260 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.6261 +    }
  5.6262 +}
  5.6263 +
  5.6264 +static void SDLCALL
  5.6265 +SDL_Upsample_S8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.6266 +{
  5.6267 +#ifdef DEBUG_CONVERT
  5.6268 +    fprintf(stderr, "Upsample (x4) AUDIO_S8, 6 channels.\n");
  5.6269 +#endif
  5.6270 +
  5.6271 +    const int srcsize = cvt->len_cvt;
  5.6272 +    const int dstsize = cvt->len_cvt * 4;
  5.6273 +    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6;
  5.6274 +    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
  5.6275 +    const Sint8 *target = ((const Sint8 *) cvt->buf) - 6;
  5.6276 +    Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
  5.6277 +    Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
  5.6278 +    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
  5.6279 +    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
  5.6280 +    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
  5.6281 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.6282 +    while (dst != target) {
  5.6283 +        const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
  5.6284 +        const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
  5.6285 +        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
  5.6286 +        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
  5.6287 +        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
  5.6288 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.6289 +        src -= 6;
  5.6290 +        dst[23] = (Sint8) sample5;
  5.6291 +        dst[22] = (Sint8) sample4;
  5.6292 +        dst[21] = (Sint8) sample3;
  5.6293 +        dst[20] = (Sint8) sample2;
  5.6294 +        dst[19] = (Sint8) sample1;
  5.6295 +        dst[18] = (Sint8) sample0;
  5.6296 +        dst[17] = (Sint8) (((3 * sample5) + last_sample5) >> 2);
  5.6297 +        dst[16] = (Sint8) (((3 * sample4) + last_sample4) >> 2);
  5.6298 +        dst[15] = (Sint8) (((3 * sample3) + last_sample3) >> 2);
  5.6299 +        dst[14] = (Sint8) (((3 * sample2) + last_sample2) >> 2);
  5.6300 +        dst[13] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
  5.6301 +        dst[12] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
  5.6302 +        dst[11] = (Sint8) ((sample5 + last_sample5) >> 1);
  5.6303 +        dst[10] = (Sint8) ((sample4 + last_sample4) >> 1);
  5.6304 +        dst[9] = (Sint8) ((sample3 + last_sample3) >> 1);
  5.6305 +        dst[8] = (Sint8) ((sample2 + last_sample2) >> 1);
  5.6306 +        dst[7] = (Sint8) ((sample1 + last_sample1) >> 1);
  5.6307 +        dst[6] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.6308 +        dst[5] = (Sint8) ((sample5 + (3 * last_sample5)) >> 2);
  5.6309 +        dst[4] = (Sint8) ((sample4 + (3 * last_sample4)) >> 2);
  5.6310 +        dst[3] = (Sint8) ((sample3 + (3 * last_sample3)) >> 2);
  5.6311 +        dst[2] = (Sint8) ((sample2 + (3 * last_sample2)) >> 2);
  5.6312 +        dst[1] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
  5.6313 +        dst[0] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
  5.6314 +        last_sample5 = sample5;
  5.6315 +        last_sample4 = sample4;
  5.6316 +        last_sample3 = sample3;
  5.6317 +        last_sample2 = sample2;
  5.6318 +        last_sample1 = sample1;
  5.6319 +        last_sample0 = sample0;
  5.6320 +        dst -= 24;
  5.6321 +    }
  5.6322 +
  5.6323 +    cvt->len_cvt = dstsize;
  5.6324 +    if (cvt->filters[++cvt->filter_index]) {
  5.6325 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.6326 +    }
  5.6327 +}
  5.6328 +
  5.6329 +static void SDLCALL
  5.6330 +SDL_Downsample_S8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.6331 +{
  5.6332 +#ifdef DEBUG_CONVERT
  5.6333 +    fprintf(stderr, "Downsample (x4) AUDIO_S8, 6 channels.\n");
  5.6334 +#endif
  5.6335 +
  5.6336 +    const int srcsize = cvt->len_cvt;
  5.6337 +    const int dstsize = cvt->len_cvt / 4;
  5.6338 +    Sint8 *dst = (Sint8 *) cvt->buf;
  5.6339 +    const Sint8 *src = (Sint8 *) cvt->buf;
  5.6340 +    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
  5.6341 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.6342 +    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
  5.6343 +    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
  5.6344 +    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
  5.6345 +    Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
  5.6346 +    Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
  5.6347 +    while (dst != target) {
  5.6348 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.6349 +        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
  5.6350 +        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
  5.6351 +        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
  5.6352 +        const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
  5.6353 +        const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
  5.6354 +        src += 24;
  5.6355 +        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
  5.6356 +        dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
  5.6357 +        dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
  5.6358 +        dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
  5.6359 +        dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
  5.6360 +        dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
  5.6361 +        last_sample0 = sample0;
  5.6362 +        last_sample1 = sample1;
  5.6363 +        last_sample2 = sample2;
  5.6364 +        last_sample3 = sample3;
  5.6365 +        last_sample4 = sample4;
  5.6366 +        last_sample5 = sample5;
  5.6367 +        dst += 6;
  5.6368 +    }
  5.6369 +
  5.6370 +    cvt->len_cvt = dstsize;
  5.6371 +    if (cvt->filters[++cvt->filter_index]) {
  5.6372 +        cvt->filters[cvt->filter_index] (cvt, format);
  5.6373 +    }
  5.6374 +}
  5.6375 +
  5.6376 +static void SDLCALL
  5.6377 +SDL_Upsample_S8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  5.6378 +{
  5.6379 +#ifdef DEBUG_CONVERT
  5.6380 +    fprintf(stderr, "Upsample (x2) AUDIO_S8, 8 channels.\n");
  5.6381 +#endif
  5.6382 +
  5.6383 +    const int srcsize = cvt->len_cvt;
  5.6384 +    const int dstsize = cvt->len_cvt * 2;
  5.6385 +    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8;
  5.6386 +    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
  5.6387 +    const Sint8 *target = ((const Sint8 *) cvt->buf) - 8;
  5.6388 +    Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
  5.6389 +    Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
  5.6390 +    Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
  5.6391 +    Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
  5.6392 +    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
  5.6393 +    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
  5.6394 +    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
  5.6395 +    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
  5.6396 +    while (dst != target) {
  5.6397 +        const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
  5.6398 +        const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
  5.6399 +        const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
  5.6400 +        const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
  5.6401 +        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
  5.6402 +        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
  5.6403 +        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
  5.6404 +        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
  5.6405 +        src -= 8;
  5.6406 +        dst[15] = (Sint8) ((sample7 + last_sample7) >> 1);
  5.6407 +        dst[14] = (Sint8) ((sample6 + last_sample6) >> 1);
  5.6408 +        dst[13] = (Sint8) ((sample5 + last_sample5) >> 1);
  5.6409 +        dst[12] = (Sint8) ((sample4 + last_sample4) >> 1);
  5.6410 +        dst[11] = (Sint8) ((sample3 + last_sample3) >> 1);