cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

SDL_audiotypecvt.c (619893B)


      1/* DO NOT EDIT!  This file is generated by sdlgenaudiocvt.pl */
      2/*
      3  Simple DirectMedia Layer
      4  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
      5
      6  This software is provided 'as-is', without any express or implied
      7  warranty.  In no event will the authors be held liable for any damages
      8  arising from the use of this software.
      9
     10  Permission is granted to anyone to use this software for any purpose,
     11  including commercial applications, and to alter it and redistribute it
     12  freely, subject to the following restrictions:
     13
     14  1. The origin of this software must not be misrepresented; you must not
     15     claim that you wrote the original software. If you use this software
     16     in a product, an acknowledgment in the product documentation would be
     17     appreciated but is not required.
     18  2. Altered source versions must be plainly marked as such, and must not be
     19     misrepresented as being the original software.
     20  3. This notice may not be removed or altered from any source distribution.
     21*/
     22
     23#include "../SDL_internal.h"
     24#include "SDL_audio.h"
     25#include "SDL_audio_c.h"
     26
     27#ifndef DEBUG_CONVERT
     28#define DEBUG_CONVERT 0
     29#endif
     30
     31
     32/* If you can guarantee your data and need space, you can eliminate code... */
     33
     34/* Just build the arbitrary resamplers if you're saving code space. */
     35#ifndef LESS_RESAMPLERS
     36#define LESS_RESAMPLERS 0
     37#endif
     38
     39/* Don't build any resamplers if you're REALLY saving code space. */
     40#ifndef NO_RESAMPLERS
     41#define NO_RESAMPLERS 0
     42#endif
     43
     44/* Don't build any type converters if you're saving code space. */
     45#ifndef NO_CONVERTERS
     46#define NO_CONVERTERS 0
     47#endif
     48
     49
     50/* *INDENT-OFF* */
     51
     52#define DIVBY127 0.0078740157480315f
     53#define DIVBY32767 3.05185094759972e-05f
     54#define DIVBY2147483647 4.6566128752458e-10f
     55
     56#if !NO_CONVERTERS
     57
     58static void SDLCALL
     59SDL_Convert_U8_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
     60{
     61    int i;
     62    const Uint8 *src;
     63    Sint8 *dst;
     64
     65#if DEBUG_CONVERT
     66    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S8.\n");
     67#endif
     68
     69    src = (const Uint8 *) cvt->buf;
     70    dst = (Sint8 *) cvt->buf;
     71    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, ++src, ++dst) {
     72        const Sint8 val = ((*src) ^ 0x80);
     73        *dst = ((Sint8) val);
     74    }
     75
     76    if (cvt->filters[++cvt->filter_index]) {
     77        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
     78    }
     79}
     80
     81static void SDLCALL
     82SDL_Convert_U8_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
     83{
     84    int i;
     85    const Uint8 *src;
     86    Uint16 *dst;
     87
     88#if DEBUG_CONVERT
     89    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_U16LSB.\n");
     90#endif
     91
     92    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
     93    dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
     94    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
     95        const Uint16 val = (((Uint16) *src) << 8);
     96        *dst = SDL_SwapLE16(val);
     97    }
     98
     99    cvt->len_cvt *= 2;
    100    if (cvt->filters[++cvt->filter_index]) {
    101        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
    102    }
    103}
    104
    105static void SDLCALL
    106SDL_Convert_U8_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    107{
    108    int i;
    109    const Uint8 *src;
    110    Sint16 *dst;
    111
    112#if DEBUG_CONVERT
    113    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S16LSB.\n");
    114#endif
    115
    116    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    117    dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    118    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    119        const Sint16 val = (((Sint16) ((*src) ^ 0x80)) << 8);
    120        *dst = ((Sint16) SDL_SwapLE16(val));
    121    }
    122
    123    cvt->len_cvt *= 2;
    124    if (cvt->filters[++cvt->filter_index]) {
    125        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
    126    }
    127}
    128
    129static void SDLCALL
    130SDL_Convert_U8_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    131{
    132    int i;
    133    const Uint8 *src;
    134    Uint16 *dst;
    135
    136#if DEBUG_CONVERT
    137    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_U16MSB.\n");
    138#endif
    139
    140    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    141    dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    142    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    143        const Uint16 val = (((Uint16) *src) << 8);
    144        *dst = SDL_SwapBE16(val);
    145    }
    146
    147    cvt->len_cvt *= 2;
    148    if (cvt->filters[++cvt->filter_index]) {
    149        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
    150    }
    151}
    152
    153static void SDLCALL
    154SDL_Convert_U8_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    155{
    156    int i;
    157    const Uint8 *src;
    158    Sint16 *dst;
    159
    160#if DEBUG_CONVERT
    161    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S16MSB.\n");
    162#endif
    163
    164    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    165    dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    166    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    167        const Sint16 val = (((Sint16) ((*src) ^ 0x80)) << 8);
    168        *dst = ((Sint16) SDL_SwapBE16(val));
    169    }
    170
    171    cvt->len_cvt *= 2;
    172    if (cvt->filters[++cvt->filter_index]) {
    173        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
    174    }
    175}
    176
    177static void SDLCALL
    178SDL_Convert_U8_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    179{
    180    int i;
    181    const Uint8 *src;
    182    Sint32 *dst;
    183
    184#if DEBUG_CONVERT
    185    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S32LSB.\n");
    186#endif
    187
    188    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    189    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
    190    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    191        const Sint32 val = (((Sint32) ((*src) ^ 0x80)) << 24);
    192        *dst = ((Sint32) SDL_SwapLE32(val));
    193    }
    194
    195    cvt->len_cvt *= 4;
    196    if (cvt->filters[++cvt->filter_index]) {
    197        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
    198    }
    199}
    200
    201static void SDLCALL
    202SDL_Convert_U8_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    203{
    204    int i;
    205    const Uint8 *src;
    206    Sint32 *dst;
    207
    208#if DEBUG_CONVERT
    209    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S32MSB.\n");
    210#endif
    211
    212    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    213    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
    214    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    215        const Sint32 val = (((Sint32) ((*src) ^ 0x80)) << 24);
    216        *dst = ((Sint32) SDL_SwapBE32(val));
    217    }
    218
    219    cvt->len_cvt *= 4;
    220    if (cvt->filters[++cvt->filter_index]) {
    221        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
    222    }
    223}
    224
    225static void SDLCALL
    226SDL_Convert_U8_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    227{
    228    int i;
    229    const Uint8 *src;
    230    float *dst;
    231
    232#if DEBUG_CONVERT
    233    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_F32LSB.\n");
    234#endif
    235
    236    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    237    dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
    238    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    239        const float val = ((((float) *src) * DIVBY127) - 1.0f);
    240        *dst = SDL_SwapFloatLE(val);
    241    }
    242
    243    cvt->len_cvt *= 4;
    244    if (cvt->filters[++cvt->filter_index]) {
    245        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
    246    }
    247}
    248
    249static void SDLCALL
    250SDL_Convert_U8_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    251{
    252    int i;
    253    const Uint8 *src;
    254    float *dst;
    255
    256#if DEBUG_CONVERT
    257    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_F32MSB.\n");
    258#endif
    259
    260    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    261    dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
    262    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    263        const float val = ((((float) *src) * DIVBY127) - 1.0f);
    264        *dst = SDL_SwapFloatBE(val);
    265    }
    266
    267    cvt->len_cvt *= 4;
    268    if (cvt->filters[++cvt->filter_index]) {
    269        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
    270    }
    271}
    272
    273static void SDLCALL
    274SDL_Convert_S8_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    275{
    276    int i;
    277    const Uint8 *src;
    278    Uint8 *dst;
    279
    280#if DEBUG_CONVERT
    281    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U8.\n");
    282#endif
    283
    284    src = (const Uint8 *) cvt->buf;
    285    dst = (Uint8 *) cvt->buf;
    286    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, ++src, ++dst) {
    287        const Uint8 val = ((((Sint8) *src)) ^ 0x80);
    288        *dst = val;
    289    }
    290
    291    if (cvt->filters[++cvt->filter_index]) {
    292        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
    293    }
    294}
    295
    296static void SDLCALL
    297SDL_Convert_S8_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    298{
    299    int i;
    300    const Uint8 *src;
    301    Uint16 *dst;
    302
    303#if DEBUG_CONVERT
    304    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U16LSB.\n");
    305#endif
    306
    307    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    308    dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    309    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    310        const Uint16 val = (((Uint16) ((((Sint8) *src)) ^ 0x80)) << 8);
    311        *dst = SDL_SwapLE16(val);
    312    }
    313
    314    cvt->len_cvt *= 2;
    315    if (cvt->filters[++cvt->filter_index]) {
    316        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
    317    }
    318}
    319
    320static void SDLCALL
    321SDL_Convert_S8_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    322{
    323    int i;
    324    const Uint8 *src;
    325    Sint16 *dst;
    326
    327#if DEBUG_CONVERT
    328    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S16LSB.\n");
    329#endif
    330
    331    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    332    dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    333    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    334        const Sint16 val = (((Sint16) ((Sint8) *src)) << 8);
    335        *dst = ((Sint16) SDL_SwapLE16(val));
    336    }
    337
    338    cvt->len_cvt *= 2;
    339    if (cvt->filters[++cvt->filter_index]) {
    340        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
    341    }
    342}
    343
    344static void SDLCALL
    345SDL_Convert_S8_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    346{
    347    int i;
    348    const Uint8 *src;
    349    Uint16 *dst;
    350
    351#if DEBUG_CONVERT
    352    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U16MSB.\n");
    353#endif
    354
    355    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    356    dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    357    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    358        const Uint16 val = (((Uint16) ((((Sint8) *src)) ^ 0x80)) << 8);
    359        *dst = SDL_SwapBE16(val);
    360    }
    361
    362    cvt->len_cvt *= 2;
    363    if (cvt->filters[++cvt->filter_index]) {
    364        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
    365    }
    366}
    367
    368static void SDLCALL
    369SDL_Convert_S8_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    370{
    371    int i;
    372    const Uint8 *src;
    373    Sint16 *dst;
    374
    375#if DEBUG_CONVERT
    376    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S16MSB.\n");
    377#endif
    378
    379    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    380    dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    381    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    382        const Sint16 val = (((Sint16) ((Sint8) *src)) << 8);
    383        *dst = ((Sint16) SDL_SwapBE16(val));
    384    }
    385
    386    cvt->len_cvt *= 2;
    387    if (cvt->filters[++cvt->filter_index]) {
    388        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
    389    }
    390}
    391
    392static void SDLCALL
    393SDL_Convert_S8_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    394{
    395    int i;
    396    const Uint8 *src;
    397    Sint32 *dst;
    398
    399#if DEBUG_CONVERT
    400    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S32LSB.\n");
    401#endif
    402
    403    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    404    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
    405    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    406        const Sint32 val = (((Sint32) ((Sint8) *src)) << 24);
    407        *dst = ((Sint32) SDL_SwapLE32(val));
    408    }
    409
    410    cvt->len_cvt *= 4;
    411    if (cvt->filters[++cvt->filter_index]) {
    412        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
    413    }
    414}
    415
    416static void SDLCALL
    417SDL_Convert_S8_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    418{
    419    int i;
    420    const Uint8 *src;
    421    Sint32 *dst;
    422
    423#if DEBUG_CONVERT
    424    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S32MSB.\n");
    425#endif
    426
    427    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    428    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
    429    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    430        const Sint32 val = (((Sint32) ((Sint8) *src)) << 24);
    431        *dst = ((Sint32) SDL_SwapBE32(val));
    432    }
    433
    434    cvt->len_cvt *= 4;
    435    if (cvt->filters[++cvt->filter_index]) {
    436        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
    437    }
    438}
    439
    440static void SDLCALL
    441SDL_Convert_S8_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    442{
    443    int i;
    444    const Uint8 *src;
    445    float *dst;
    446
    447#if DEBUG_CONVERT
    448    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_F32LSB.\n");
    449#endif
    450
    451    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    452    dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
    453    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    454        const float val = (((float) ((Sint8) *src)) * DIVBY127);
    455        *dst = SDL_SwapFloatLE(val);
    456    }
    457
    458    cvt->len_cvt *= 4;
    459    if (cvt->filters[++cvt->filter_index]) {
    460        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
    461    }
    462}
    463
    464static void SDLCALL
    465SDL_Convert_S8_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    466{
    467    int i;
    468    const Uint8 *src;
    469    float *dst;
    470
    471#if DEBUG_CONVERT
    472    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_F32MSB.\n");
    473#endif
    474
    475    src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
    476    dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
    477    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    478        const float val = (((float) ((Sint8) *src)) * DIVBY127);
    479        *dst = SDL_SwapFloatBE(val);
    480    }
    481
    482    cvt->len_cvt *= 4;
    483    if (cvt->filters[++cvt->filter_index]) {
    484        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
    485    }
    486}
    487
    488static void SDLCALL
    489SDL_Convert_U16LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    490{
    491    int i;
    492    const Uint16 *src;
    493    Uint8 *dst;
    494
    495#if DEBUG_CONVERT
    496    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_U8.\n");
    497#endif
    498
    499    src = (const Uint16 *) cvt->buf;
    500    dst = (Uint8 *) cvt->buf;
    501    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
    502        const Uint8 val = ((Uint8) (SDL_SwapLE16(*src) >> 8));
    503        *dst = val;
    504    }
    505
    506    cvt->len_cvt /= 2;
    507    if (cvt->filters[++cvt->filter_index]) {
    508        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
    509    }
    510}
    511
    512static void SDLCALL
    513SDL_Convert_U16LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    514{
    515    int i;
    516    const Uint16 *src;
    517    Sint8 *dst;
    518
    519#if DEBUG_CONVERT
    520    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S8.\n");
    521#endif
    522
    523    src = (const Uint16 *) cvt->buf;
    524    dst = (Sint8 *) cvt->buf;
    525    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
    526        const Sint8 val = ((Sint8) (((SDL_SwapLE16(*src)) ^ 0x8000) >> 8));
    527        *dst = ((Sint8) val);
    528    }
    529
    530    cvt->len_cvt /= 2;
    531    if (cvt->filters[++cvt->filter_index]) {
    532        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
    533    }
    534}
    535
    536static void SDLCALL
    537SDL_Convert_U16LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    538{
    539    int i;
    540    const Uint16 *src;
    541    Sint16 *dst;
    542
    543#if DEBUG_CONVERT
    544    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S16LSB.\n");
    545#endif
    546
    547    src = (const Uint16 *) cvt->buf;
    548    dst = (Sint16 *) cvt->buf;
    549    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
    550        const Sint16 val = ((SDL_SwapLE16(*src)) ^ 0x8000);
    551        *dst = ((Sint16) SDL_SwapLE16(val));
    552    }
    553
    554    if (cvt->filters[++cvt->filter_index]) {
    555        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
    556    }
    557}
    558
    559static void SDLCALL
    560SDL_Convert_U16LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    561{
    562    int i;
    563    const Uint16 *src;
    564    Uint16 *dst;
    565
    566#if DEBUG_CONVERT
    567    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_U16MSB.\n");
    568#endif
    569
    570    src = (const Uint16 *) cvt->buf;
    571    dst = (Uint16 *) cvt->buf;
    572    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
    573        const Uint16 val = SDL_SwapLE16(*src);
    574        *dst = SDL_SwapBE16(val);
    575    }
    576
    577    if (cvt->filters[++cvt->filter_index]) {
    578        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
    579    }
    580}
    581
    582static void SDLCALL
    583SDL_Convert_U16LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    584{
    585    int i;
    586    const Uint16 *src;
    587    Sint16 *dst;
    588
    589#if DEBUG_CONVERT
    590    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S16MSB.\n");
    591#endif
    592
    593    src = (const Uint16 *) cvt->buf;
    594    dst = (Sint16 *) cvt->buf;
    595    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
    596        const Sint16 val = ((SDL_SwapLE16(*src)) ^ 0x8000);
    597        *dst = ((Sint16) SDL_SwapBE16(val));
    598    }
    599
    600    if (cvt->filters[++cvt->filter_index]) {
    601        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
    602    }
    603}
    604
    605static void SDLCALL
    606SDL_Convert_U16LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    607{
    608    int i;
    609    const Uint16 *src;
    610    Sint32 *dst;
    611
    612#if DEBUG_CONVERT
    613    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S32LSB.\n");
    614#endif
    615
    616    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
    617    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    618    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
    619        const Sint32 val = (((Sint32) ((SDL_SwapLE16(*src)) ^ 0x8000)) << 16);
    620        *dst = ((Sint32) SDL_SwapLE32(val));
    621    }
    622
    623    cvt->len_cvt *= 2;
    624    if (cvt->filters[++cvt->filter_index]) {
    625        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
    626    }
    627}
    628
    629static void SDLCALL
    630SDL_Convert_U16LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    631{
    632    int i;
    633    const Uint16 *src;
    634    Sint32 *dst;
    635
    636#if DEBUG_CONVERT
    637    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S32MSB.\n");
    638#endif
    639
    640    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
    641    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    642    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
    643        const Sint32 val = (((Sint32) ((SDL_SwapLE16(*src)) ^ 0x8000)) << 16);
    644        *dst = ((Sint32) SDL_SwapBE32(val));
    645    }
    646
    647    cvt->len_cvt *= 2;
    648    if (cvt->filters[++cvt->filter_index]) {
    649        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
    650    }
    651}
    652
    653static void SDLCALL
    654SDL_Convert_U16LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    655{
    656    int i;
    657    const Uint16 *src;
    658    float *dst;
    659
    660#if DEBUG_CONVERT
    661    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_F32LSB.\n");
    662#endif
    663
    664    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
    665    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    666    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
    667        const float val = ((((float) SDL_SwapLE16(*src)) * DIVBY32767) - 1.0f);
    668        *dst = SDL_SwapFloatLE(val);
    669    }
    670
    671    cvt->len_cvt *= 2;
    672    if (cvt->filters[++cvt->filter_index]) {
    673        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
    674    }
    675}
    676
    677static void SDLCALL
    678SDL_Convert_U16LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    679{
    680    int i;
    681    const Uint16 *src;
    682    float *dst;
    683
    684#if DEBUG_CONVERT
    685    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_F32MSB.\n");
    686#endif
    687
    688    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
    689    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    690    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
    691        const float val = ((((float) SDL_SwapLE16(*src)) * DIVBY32767) - 1.0f);
    692        *dst = SDL_SwapFloatBE(val);
    693    }
    694
    695    cvt->len_cvt *= 2;
    696    if (cvt->filters[++cvt->filter_index]) {
    697        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
    698    }
    699}
    700
    701static void SDLCALL
    702SDL_Convert_S16LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    703{
    704    int i;
    705    const Uint16 *src;
    706    Uint8 *dst;
    707
    708#if DEBUG_CONVERT
    709    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U8.\n");
    710#endif
    711
    712    src = (const Uint16 *) cvt->buf;
    713    dst = (Uint8 *) cvt->buf;
    714    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
    715        const Uint8 val = ((Uint8) (((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000) >> 8));
    716        *dst = val;
    717    }
    718
    719    cvt->len_cvt /= 2;
    720    if (cvt->filters[++cvt->filter_index]) {
    721        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
    722    }
    723}
    724
    725static void SDLCALL
    726SDL_Convert_S16LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    727{
    728    int i;
    729    const Uint16 *src;
    730    Sint8 *dst;
    731
    732#if DEBUG_CONVERT
    733    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S8.\n");
    734#endif
    735
    736    src = (const Uint16 *) cvt->buf;
    737    dst = (Sint8 *) cvt->buf;
    738    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
    739        const Sint8 val = ((Sint8) (((Sint16) SDL_SwapLE16(*src)) >> 8));
    740        *dst = ((Sint8) val);
    741    }
    742
    743    cvt->len_cvt /= 2;
    744    if (cvt->filters[++cvt->filter_index]) {
    745        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
    746    }
    747}
    748
    749static void SDLCALL
    750SDL_Convert_S16LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    751{
    752    int i;
    753    const Uint16 *src;
    754    Uint16 *dst;
    755
    756#if DEBUG_CONVERT
    757    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U16LSB.\n");
    758#endif
    759
    760    src = (const Uint16 *) cvt->buf;
    761    dst = (Uint16 *) cvt->buf;
    762    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
    763        const Uint16 val = ((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000);
    764        *dst = SDL_SwapLE16(val);
    765    }
    766
    767    if (cvt->filters[++cvt->filter_index]) {
    768        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
    769    }
    770}
    771
    772static void SDLCALL
    773SDL_Convert_S16LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    774{
    775    int i;
    776    const Uint16 *src;
    777    Uint16 *dst;
    778
    779#if DEBUG_CONVERT
    780    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U16MSB.\n");
    781#endif
    782
    783    src = (const Uint16 *) cvt->buf;
    784    dst = (Uint16 *) cvt->buf;
    785    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
    786        const Uint16 val = ((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000);
    787        *dst = SDL_SwapBE16(val);
    788    }
    789
    790    if (cvt->filters[++cvt->filter_index]) {
    791        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
    792    }
    793}
    794
    795static void SDLCALL
    796SDL_Convert_S16LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    797{
    798    int i;
    799    const Uint16 *src;
    800    Sint16 *dst;
    801
    802#if DEBUG_CONVERT
    803    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S16MSB.\n");
    804#endif
    805
    806    src = (const Uint16 *) cvt->buf;
    807    dst = (Sint16 *) cvt->buf;
    808    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
    809        const Sint16 val = ((Sint16) SDL_SwapLE16(*src));
    810        *dst = ((Sint16) SDL_SwapBE16(val));
    811    }
    812
    813    if (cvt->filters[++cvt->filter_index]) {
    814        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
    815    }
    816}
    817
    818static void SDLCALL
    819SDL_Convert_S16LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    820{
    821    int i;
    822    const Uint16 *src;
    823    Sint32 *dst;
    824
    825#if DEBUG_CONVERT
    826    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S32LSB.\n");
    827#endif
    828
    829    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
    830    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    831    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
    832        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapLE16(*src))) << 16);
    833        *dst = ((Sint32) SDL_SwapLE32(val));
    834    }
    835
    836    cvt->len_cvt *= 2;
    837    if (cvt->filters[++cvt->filter_index]) {
    838        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
    839    }
    840}
    841
    842static void SDLCALL
    843SDL_Convert_S16LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    844{
    845    int i;
    846    const Uint16 *src;
    847    Sint32 *dst;
    848
    849#if DEBUG_CONVERT
    850    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S32MSB.\n");
    851#endif
    852
    853    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
    854    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    855    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
    856        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapLE16(*src))) << 16);
    857        *dst = ((Sint32) SDL_SwapBE32(val));
    858    }
    859
    860    cvt->len_cvt *= 2;
    861    if (cvt->filters[++cvt->filter_index]) {
    862        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
    863    }
    864}
    865
    866static void SDLCALL
    867SDL_Convert_S16LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    868{
    869    int i;
    870    const Uint16 *src;
    871    float *dst;
    872
    873#if DEBUG_CONVERT
    874    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_F32LSB.\n");
    875#endif
    876
    877    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
    878    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    879    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
    880        const float val = (((float) ((Sint16) SDL_SwapLE16(*src))) * DIVBY32767);
    881        *dst = SDL_SwapFloatLE(val);
    882    }
    883
    884    cvt->len_cvt *= 2;
    885    if (cvt->filters[++cvt->filter_index]) {
    886        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
    887    }
    888}
    889
    890static void SDLCALL
    891SDL_Convert_S16LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    892{
    893    int i;
    894    const Uint16 *src;
    895    float *dst;
    896
    897#if DEBUG_CONVERT
    898    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_F32MSB.\n");
    899#endif
    900
    901    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
    902    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
    903    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
    904        const float val = (((float) ((Sint16) SDL_SwapLE16(*src))) * DIVBY32767);
    905        *dst = SDL_SwapFloatBE(val);
    906    }
    907
    908    cvt->len_cvt *= 2;
    909    if (cvt->filters[++cvt->filter_index]) {
    910        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
    911    }
    912}
    913
    914static void SDLCALL
    915SDL_Convert_U16MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    916{
    917    int i;
    918    const Uint16 *src;
    919    Uint8 *dst;
    920
    921#if DEBUG_CONVERT
    922    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_U8.\n");
    923#endif
    924
    925    src = (const Uint16 *) cvt->buf;
    926    dst = (Uint8 *) cvt->buf;
    927    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
    928        const Uint8 val = ((Uint8) (SDL_SwapBE16(*src) >> 8));
    929        *dst = val;
    930    }
    931
    932    cvt->len_cvt /= 2;
    933    if (cvt->filters[++cvt->filter_index]) {
    934        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
    935    }
    936}
    937
    938static void SDLCALL
    939SDL_Convert_U16MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    940{
    941    int i;
    942    const Uint16 *src;
    943    Sint8 *dst;
    944
    945#if DEBUG_CONVERT
    946    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S8.\n");
    947#endif
    948
    949    src = (const Uint16 *) cvt->buf;
    950    dst = (Sint8 *) cvt->buf;
    951    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
    952        const Sint8 val = ((Sint8) (((SDL_SwapBE16(*src)) ^ 0x8000) >> 8));
    953        *dst = ((Sint8) val);
    954    }
    955
    956    cvt->len_cvt /= 2;
    957    if (cvt->filters[++cvt->filter_index]) {
    958        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
    959    }
    960}
    961
    962static void SDLCALL
    963SDL_Convert_U16MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    964{
    965    int i;
    966    const Uint16 *src;
    967    Uint16 *dst;
    968
    969#if DEBUG_CONVERT
    970    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_U16LSB.\n");
    971#endif
    972
    973    src = (const Uint16 *) cvt->buf;
    974    dst = (Uint16 *) cvt->buf;
    975    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
    976        const Uint16 val = SDL_SwapBE16(*src);
    977        *dst = SDL_SwapLE16(val);
    978    }
    979
    980    if (cvt->filters[++cvt->filter_index]) {
    981        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
    982    }
    983}
    984
    985static void SDLCALL
    986SDL_Convert_U16MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    987{
    988    int i;
    989    const Uint16 *src;
    990    Sint16 *dst;
    991
    992#if DEBUG_CONVERT
    993    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S16LSB.\n");
    994#endif
    995
    996    src = (const Uint16 *) cvt->buf;
    997    dst = (Sint16 *) cvt->buf;
    998    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
    999        const Sint16 val = ((SDL_SwapBE16(*src)) ^ 0x8000);
   1000        *dst = ((Sint16) SDL_SwapLE16(val));
   1001    }
   1002
   1003    if (cvt->filters[++cvt->filter_index]) {
   1004        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
   1005    }
   1006}
   1007
   1008static void SDLCALL
   1009SDL_Convert_U16MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1010{
   1011    int i;
   1012    const Uint16 *src;
   1013    Sint16 *dst;
   1014
   1015#if DEBUG_CONVERT
   1016    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S16MSB.\n");
   1017#endif
   1018
   1019    src = (const Uint16 *) cvt->buf;
   1020    dst = (Sint16 *) cvt->buf;
   1021    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   1022        const Sint16 val = ((SDL_SwapBE16(*src)) ^ 0x8000);
   1023        *dst = ((Sint16) SDL_SwapBE16(val));
   1024    }
   1025
   1026    if (cvt->filters[++cvt->filter_index]) {
   1027        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
   1028    }
   1029}
   1030
   1031static void SDLCALL
   1032SDL_Convert_U16MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1033{
   1034    int i;
   1035    const Uint16 *src;
   1036    Sint32 *dst;
   1037
   1038#if DEBUG_CONVERT
   1039    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S32LSB.\n");
   1040#endif
   1041
   1042    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   1043    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   1044    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   1045        const Sint32 val = (((Sint32) ((SDL_SwapBE16(*src)) ^ 0x8000)) << 16);
   1046        *dst = ((Sint32) SDL_SwapLE32(val));
   1047    }
   1048
   1049    cvt->len_cvt *= 2;
   1050    if (cvt->filters[++cvt->filter_index]) {
   1051        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
   1052    }
   1053}
   1054
   1055static void SDLCALL
   1056SDL_Convert_U16MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1057{
   1058    int i;
   1059    const Uint16 *src;
   1060    Sint32 *dst;
   1061
   1062#if DEBUG_CONVERT
   1063    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S32MSB.\n");
   1064#endif
   1065
   1066    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   1067    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   1068    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   1069        const Sint32 val = (((Sint32) ((SDL_SwapBE16(*src)) ^ 0x8000)) << 16);
   1070        *dst = ((Sint32) SDL_SwapBE32(val));
   1071    }
   1072
   1073    cvt->len_cvt *= 2;
   1074    if (cvt->filters[++cvt->filter_index]) {
   1075        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
   1076    }
   1077}
   1078
   1079static void SDLCALL
   1080SDL_Convert_U16MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1081{
   1082    int i;
   1083    const Uint16 *src;
   1084    float *dst;
   1085
   1086#if DEBUG_CONVERT
   1087    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_F32LSB.\n");
   1088#endif
   1089
   1090    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   1091    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   1092    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   1093        const float val = ((((float) SDL_SwapBE16(*src)) * DIVBY32767) - 1.0f);
   1094        *dst = SDL_SwapFloatLE(val);
   1095    }
   1096
   1097    cvt->len_cvt *= 2;
   1098    if (cvt->filters[++cvt->filter_index]) {
   1099        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
   1100    }
   1101}
   1102
   1103static void SDLCALL
   1104SDL_Convert_U16MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1105{
   1106    int i;
   1107    const Uint16 *src;
   1108    float *dst;
   1109
   1110#if DEBUG_CONVERT
   1111    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_F32MSB.\n");
   1112#endif
   1113
   1114    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   1115    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   1116    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   1117        const float val = ((((float) SDL_SwapBE16(*src)) * DIVBY32767) - 1.0f);
   1118        *dst = SDL_SwapFloatBE(val);
   1119    }
   1120
   1121    cvt->len_cvt *= 2;
   1122    if (cvt->filters[++cvt->filter_index]) {
   1123        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
   1124    }
   1125}
   1126
   1127static void SDLCALL
   1128SDL_Convert_S16MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1129{
   1130    int i;
   1131    const Uint16 *src;
   1132    Uint8 *dst;
   1133
   1134#if DEBUG_CONVERT
   1135    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U8.\n");
   1136#endif
   1137
   1138    src = (const Uint16 *) cvt->buf;
   1139    dst = (Uint8 *) cvt->buf;
   1140    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   1141        const Uint8 val = ((Uint8) (((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000) >> 8));
   1142        *dst = val;
   1143    }
   1144
   1145    cvt->len_cvt /= 2;
   1146    if (cvt->filters[++cvt->filter_index]) {
   1147        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
   1148    }
   1149}
   1150
   1151static void SDLCALL
   1152SDL_Convert_S16MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1153{
   1154    int i;
   1155    const Uint16 *src;
   1156    Sint8 *dst;
   1157
   1158#if DEBUG_CONVERT
   1159    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S8.\n");
   1160#endif
   1161
   1162    src = (const Uint16 *) cvt->buf;
   1163    dst = (Sint8 *) cvt->buf;
   1164    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   1165        const Sint8 val = ((Sint8) (((Sint16) SDL_SwapBE16(*src)) >> 8));
   1166        *dst = ((Sint8) val);
   1167    }
   1168
   1169    cvt->len_cvt /= 2;
   1170    if (cvt->filters[++cvt->filter_index]) {
   1171        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
   1172    }
   1173}
   1174
   1175static void SDLCALL
   1176SDL_Convert_S16MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1177{
   1178    int i;
   1179    const Uint16 *src;
   1180    Uint16 *dst;
   1181
   1182#if DEBUG_CONVERT
   1183    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U16LSB.\n");
   1184#endif
   1185
   1186    src = (const Uint16 *) cvt->buf;
   1187    dst = (Uint16 *) cvt->buf;
   1188    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   1189        const Uint16 val = ((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000);
   1190        *dst = SDL_SwapLE16(val);
   1191    }
   1192
   1193    if (cvt->filters[++cvt->filter_index]) {
   1194        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
   1195    }
   1196}
   1197
   1198static void SDLCALL
   1199SDL_Convert_S16MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1200{
   1201    int i;
   1202    const Uint16 *src;
   1203    Sint16 *dst;
   1204
   1205#if DEBUG_CONVERT
   1206    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S16LSB.\n");
   1207#endif
   1208
   1209    src = (const Uint16 *) cvt->buf;
   1210    dst = (Sint16 *) cvt->buf;
   1211    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   1212        const Sint16 val = ((Sint16) SDL_SwapBE16(*src));
   1213        *dst = ((Sint16) SDL_SwapLE16(val));
   1214    }
   1215
   1216    if (cvt->filters[++cvt->filter_index]) {
   1217        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
   1218    }
   1219}
   1220
   1221static void SDLCALL
   1222SDL_Convert_S16MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1223{
   1224    int i;
   1225    const Uint16 *src;
   1226    Uint16 *dst;
   1227
   1228#if DEBUG_CONVERT
   1229    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U16MSB.\n");
   1230#endif
   1231
   1232    src = (const Uint16 *) cvt->buf;
   1233    dst = (Uint16 *) cvt->buf;
   1234    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   1235        const Uint16 val = ((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000);
   1236        *dst = SDL_SwapBE16(val);
   1237    }
   1238
   1239    if (cvt->filters[++cvt->filter_index]) {
   1240        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
   1241    }
   1242}
   1243
   1244static void SDLCALL
   1245SDL_Convert_S16MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1246{
   1247    int i;
   1248    const Uint16 *src;
   1249    Sint32 *dst;
   1250
   1251#if DEBUG_CONVERT
   1252    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S32LSB.\n");
   1253#endif
   1254
   1255    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   1256    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   1257    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   1258        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapBE16(*src))) << 16);
   1259        *dst = ((Sint32) SDL_SwapLE32(val));
   1260    }
   1261
   1262    cvt->len_cvt *= 2;
   1263    if (cvt->filters[++cvt->filter_index]) {
   1264        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
   1265    }
   1266}
   1267
   1268static void SDLCALL
   1269SDL_Convert_S16MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1270{
   1271    int i;
   1272    const Uint16 *src;
   1273    Sint32 *dst;
   1274
   1275#if DEBUG_CONVERT
   1276    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S32MSB.\n");
   1277#endif
   1278
   1279    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   1280    dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   1281    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   1282        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapBE16(*src))) << 16);
   1283        *dst = ((Sint32) SDL_SwapBE32(val));
   1284    }
   1285
   1286    cvt->len_cvt *= 2;
   1287    if (cvt->filters[++cvt->filter_index]) {
   1288        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
   1289    }
   1290}
   1291
   1292static void SDLCALL
   1293SDL_Convert_S16MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1294{
   1295    int i;
   1296    const Uint16 *src;
   1297    float *dst;
   1298
   1299#if DEBUG_CONVERT
   1300    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_F32LSB.\n");
   1301#endif
   1302
   1303    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   1304    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   1305    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   1306        const float val = (((float) ((Sint16) SDL_SwapBE16(*src))) * DIVBY32767);
   1307        *dst = SDL_SwapFloatLE(val);
   1308    }
   1309
   1310    cvt->len_cvt *= 2;
   1311    if (cvt->filters[++cvt->filter_index]) {
   1312        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
   1313    }
   1314}
   1315
   1316static void SDLCALL
   1317SDL_Convert_S16MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1318{
   1319    int i;
   1320    const Uint16 *src;
   1321    float *dst;
   1322
   1323#if DEBUG_CONVERT
   1324    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_F32MSB.\n");
   1325#endif
   1326
   1327    src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   1328    dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
   1329    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   1330        const float val = (((float) ((Sint16) SDL_SwapBE16(*src))) * DIVBY32767);
   1331        *dst = SDL_SwapFloatBE(val);
   1332    }
   1333
   1334    cvt->len_cvt *= 2;
   1335    if (cvt->filters[++cvt->filter_index]) {
   1336        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
   1337    }
   1338}
   1339
   1340static void SDLCALL
   1341SDL_Convert_S32LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1342{
   1343    int i;
   1344    const Uint32 *src;
   1345    Uint8 *dst;
   1346
   1347#if DEBUG_CONVERT
   1348    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U8.\n");
   1349#endif
   1350
   1351    src = (const Uint32 *) cvt->buf;
   1352    dst = (Uint8 *) cvt->buf;
   1353    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1354        const Uint8 val = ((Uint8) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 24));
   1355        *dst = val;
   1356    }
   1357
   1358    cvt->len_cvt /= 4;
   1359    if (cvt->filters[++cvt->filter_index]) {
   1360        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
   1361    }
   1362}
   1363
   1364static void SDLCALL
   1365SDL_Convert_S32LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1366{
   1367    int i;
   1368    const Uint32 *src;
   1369    Sint8 *dst;
   1370
   1371#if DEBUG_CONVERT
   1372    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S8.\n");
   1373#endif
   1374
   1375    src = (const Uint32 *) cvt->buf;
   1376    dst = (Sint8 *) cvt->buf;
   1377    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1378        const Sint8 val = ((Sint8) (((Sint32) SDL_SwapLE32(*src)) >> 24));
   1379        *dst = ((Sint8) val);
   1380    }
   1381
   1382    cvt->len_cvt /= 4;
   1383    if (cvt->filters[++cvt->filter_index]) {
   1384        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
   1385    }
   1386}
   1387
   1388static void SDLCALL
   1389SDL_Convert_S32LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1390{
   1391    int i;
   1392    const Uint32 *src;
   1393    Uint16 *dst;
   1394
   1395#if DEBUG_CONVERT
   1396    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U16LSB.\n");
   1397#endif
   1398
   1399    src = (const Uint32 *) cvt->buf;
   1400    dst = (Uint16 *) cvt->buf;
   1401    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1402        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 16));
   1403        *dst = SDL_SwapLE16(val);
   1404    }
   1405
   1406    cvt->len_cvt /= 2;
   1407    if (cvt->filters[++cvt->filter_index]) {
   1408        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
   1409    }
   1410}
   1411
   1412static void SDLCALL
   1413SDL_Convert_S32LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1414{
   1415    int i;
   1416    const Uint32 *src;
   1417    Sint16 *dst;
   1418
   1419#if DEBUG_CONVERT
   1420    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S16LSB.\n");
   1421#endif
   1422
   1423    src = (const Uint32 *) cvt->buf;
   1424    dst = (Sint16 *) cvt->buf;
   1425    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1426        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapLE32(*src)) >> 16));
   1427        *dst = ((Sint16) SDL_SwapLE16(val));
   1428    }
   1429
   1430    cvt->len_cvt /= 2;
   1431    if (cvt->filters[++cvt->filter_index]) {
   1432        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
   1433    }
   1434}
   1435
   1436static void SDLCALL
   1437SDL_Convert_S32LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1438{
   1439    int i;
   1440    const Uint32 *src;
   1441    Uint16 *dst;
   1442
   1443#if DEBUG_CONVERT
   1444    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U16MSB.\n");
   1445#endif
   1446
   1447    src = (const Uint32 *) cvt->buf;
   1448    dst = (Uint16 *) cvt->buf;
   1449    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1450        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 16));
   1451        *dst = SDL_SwapBE16(val);
   1452    }
   1453
   1454    cvt->len_cvt /= 2;
   1455    if (cvt->filters[++cvt->filter_index]) {
   1456        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
   1457    }
   1458}
   1459
   1460static void SDLCALL
   1461SDL_Convert_S32LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1462{
   1463    int i;
   1464    const Uint32 *src;
   1465    Sint16 *dst;
   1466
   1467#if DEBUG_CONVERT
   1468    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S16MSB.\n");
   1469#endif
   1470
   1471    src = (const Uint32 *) cvt->buf;
   1472    dst = (Sint16 *) cvt->buf;
   1473    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1474        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapLE32(*src)) >> 16));
   1475        *dst = ((Sint16) SDL_SwapBE16(val));
   1476    }
   1477
   1478    cvt->len_cvt /= 2;
   1479    if (cvt->filters[++cvt->filter_index]) {
   1480        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
   1481    }
   1482}
   1483
   1484static void SDLCALL
   1485SDL_Convert_S32LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1486{
   1487    int i;
   1488    const Uint32 *src;
   1489    Sint32 *dst;
   1490
   1491#if DEBUG_CONVERT
   1492    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S32MSB.\n");
   1493#endif
   1494
   1495    src = (const Uint32 *) cvt->buf;
   1496    dst = (Sint32 *) cvt->buf;
   1497    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1498        const Sint32 val = ((Sint32) SDL_SwapLE32(*src));
   1499        *dst = ((Sint32) SDL_SwapBE32(val));
   1500    }
   1501
   1502    if (cvt->filters[++cvt->filter_index]) {
   1503        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
   1504    }
   1505}
   1506
   1507static void SDLCALL
   1508SDL_Convert_S32LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1509{
   1510    int i;
   1511    const Uint32 *src;
   1512    float *dst;
   1513
   1514#if DEBUG_CONVERT
   1515    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_F32LSB.\n");
   1516#endif
   1517
   1518    src = (const Uint32 *) cvt->buf;
   1519    dst = (float *) cvt->buf;
   1520    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1521        const float val = (((float) ((Sint32) SDL_SwapLE32(*src))) * DIVBY2147483647);
   1522        *dst = SDL_SwapFloatLE(val);
   1523    }
   1524
   1525    if (cvt->filters[++cvt->filter_index]) {
   1526        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
   1527    }
   1528}
   1529
   1530static void SDLCALL
   1531SDL_Convert_S32LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1532{
   1533    int i;
   1534    const Uint32 *src;
   1535    float *dst;
   1536
   1537#if DEBUG_CONVERT
   1538    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_F32MSB.\n");
   1539#endif
   1540
   1541    src = (const Uint32 *) cvt->buf;
   1542    dst = (float *) cvt->buf;
   1543    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1544        const float val = (((float) ((Sint32) SDL_SwapLE32(*src))) * DIVBY2147483647);
   1545        *dst = SDL_SwapFloatBE(val);
   1546    }
   1547
   1548    if (cvt->filters[++cvt->filter_index]) {
   1549        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
   1550    }
   1551}
   1552
   1553static void SDLCALL
   1554SDL_Convert_S32MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1555{
   1556    int i;
   1557    const Uint32 *src;
   1558    Uint8 *dst;
   1559
   1560#if DEBUG_CONVERT
   1561    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U8.\n");
   1562#endif
   1563
   1564    src = (const Uint32 *) cvt->buf;
   1565    dst = (Uint8 *) cvt->buf;
   1566    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1567        const Uint8 val = ((Uint8) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 24));
   1568        *dst = val;
   1569    }
   1570
   1571    cvt->len_cvt /= 4;
   1572    if (cvt->filters[++cvt->filter_index]) {
   1573        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
   1574    }
   1575}
   1576
   1577static void SDLCALL
   1578SDL_Convert_S32MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1579{
   1580    int i;
   1581    const Uint32 *src;
   1582    Sint8 *dst;
   1583
   1584#if DEBUG_CONVERT
   1585    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S8.\n");
   1586#endif
   1587
   1588    src = (const Uint32 *) cvt->buf;
   1589    dst = (Sint8 *) cvt->buf;
   1590    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1591        const Sint8 val = ((Sint8) (((Sint32) SDL_SwapBE32(*src)) >> 24));
   1592        *dst = ((Sint8) val);
   1593    }
   1594
   1595    cvt->len_cvt /= 4;
   1596    if (cvt->filters[++cvt->filter_index]) {
   1597        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
   1598    }
   1599}
   1600
   1601static void SDLCALL
   1602SDL_Convert_S32MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1603{
   1604    int i;
   1605    const Uint32 *src;
   1606    Uint16 *dst;
   1607
   1608#if DEBUG_CONVERT
   1609    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U16LSB.\n");
   1610#endif
   1611
   1612    src = (const Uint32 *) cvt->buf;
   1613    dst = (Uint16 *) cvt->buf;
   1614    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1615        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 16));
   1616        *dst = SDL_SwapLE16(val);
   1617    }
   1618
   1619    cvt->len_cvt /= 2;
   1620    if (cvt->filters[++cvt->filter_index]) {
   1621        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
   1622    }
   1623}
   1624
   1625static void SDLCALL
   1626SDL_Convert_S32MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1627{
   1628    int i;
   1629    const Uint32 *src;
   1630    Sint16 *dst;
   1631
   1632#if DEBUG_CONVERT
   1633    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S16LSB.\n");
   1634#endif
   1635
   1636    src = (const Uint32 *) cvt->buf;
   1637    dst = (Sint16 *) cvt->buf;
   1638    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1639        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapBE32(*src)) >> 16));
   1640        *dst = ((Sint16) SDL_SwapLE16(val));
   1641    }
   1642
   1643    cvt->len_cvt /= 2;
   1644    if (cvt->filters[++cvt->filter_index]) {
   1645        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
   1646    }
   1647}
   1648
   1649static void SDLCALL
   1650SDL_Convert_S32MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1651{
   1652    int i;
   1653    const Uint32 *src;
   1654    Uint16 *dst;
   1655
   1656#if DEBUG_CONVERT
   1657    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U16MSB.\n");
   1658#endif
   1659
   1660    src = (const Uint32 *) cvt->buf;
   1661    dst = (Uint16 *) cvt->buf;
   1662    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1663        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 16));
   1664        *dst = SDL_SwapBE16(val);
   1665    }
   1666
   1667    cvt->len_cvt /= 2;
   1668    if (cvt->filters[++cvt->filter_index]) {
   1669        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
   1670    }
   1671}
   1672
   1673static void SDLCALL
   1674SDL_Convert_S32MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1675{
   1676    int i;
   1677    const Uint32 *src;
   1678    Sint16 *dst;
   1679
   1680#if DEBUG_CONVERT
   1681    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S16MSB.\n");
   1682#endif
   1683
   1684    src = (const Uint32 *) cvt->buf;
   1685    dst = (Sint16 *) cvt->buf;
   1686    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1687        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapBE32(*src)) >> 16));
   1688        *dst = ((Sint16) SDL_SwapBE16(val));
   1689    }
   1690
   1691    cvt->len_cvt /= 2;
   1692    if (cvt->filters[++cvt->filter_index]) {
   1693        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
   1694    }
   1695}
   1696
   1697static void SDLCALL
   1698SDL_Convert_S32MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1699{
   1700    int i;
   1701    const Uint32 *src;
   1702    Sint32 *dst;
   1703
   1704#if DEBUG_CONVERT
   1705    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S32LSB.\n");
   1706#endif
   1707
   1708    src = (const Uint32 *) cvt->buf;
   1709    dst = (Sint32 *) cvt->buf;
   1710    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1711        const Sint32 val = ((Sint32) SDL_SwapBE32(*src));
   1712        *dst = ((Sint32) SDL_SwapLE32(val));
   1713    }
   1714
   1715    if (cvt->filters[++cvt->filter_index]) {
   1716        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
   1717    }
   1718}
   1719
   1720static void SDLCALL
   1721SDL_Convert_S32MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1722{
   1723    int i;
   1724    const Uint32 *src;
   1725    float *dst;
   1726
   1727#if DEBUG_CONVERT
   1728    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_F32LSB.\n");
   1729#endif
   1730
   1731    src = (const Uint32 *) cvt->buf;
   1732    dst = (float *) cvt->buf;
   1733    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1734        const float val = (((float) ((Sint32) SDL_SwapBE32(*src))) * DIVBY2147483647);
   1735        *dst = SDL_SwapFloatLE(val);
   1736    }
   1737
   1738    if (cvt->filters[++cvt->filter_index]) {
   1739        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
   1740    }
   1741}
   1742
   1743static void SDLCALL
   1744SDL_Convert_S32MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1745{
   1746    int i;
   1747    const Uint32 *src;
   1748    float *dst;
   1749
   1750#if DEBUG_CONVERT
   1751    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_F32MSB.\n");
   1752#endif
   1753
   1754    src = (const Uint32 *) cvt->buf;
   1755    dst = (float *) cvt->buf;
   1756    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
   1757        const float val = (((float) ((Sint32) SDL_SwapBE32(*src))) * DIVBY2147483647);
   1758        *dst = SDL_SwapFloatBE(val);
   1759    }
   1760
   1761    if (cvt->filters[++cvt->filter_index]) {
   1762        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
   1763    }
   1764}
   1765
   1766static void SDLCALL
   1767SDL_Convert_F32LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1768{
   1769    int i;
   1770    const float *src;
   1771    Uint8 *dst;
   1772
   1773#if DEBUG_CONVERT
   1774    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U8.\n");
   1775#endif
   1776
   1777    src = (const float *) cvt->buf;
   1778    dst = (Uint8 *) cvt->buf;
   1779    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   1780        const Uint8 val = ((Uint8) ((SDL_SwapFloatLE(*src) + 1.0f) * 127.0f));
   1781        *dst = val;
   1782    }
   1783
   1784    cvt->len_cvt /= 4;
   1785    if (cvt->filters[++cvt->filter_index]) {
   1786        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
   1787    }
   1788}
   1789
   1790static void SDLCALL
   1791SDL_Convert_F32LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1792{
   1793    int i;
   1794    const float *src;
   1795    Sint8 *dst;
   1796
   1797#if DEBUG_CONVERT
   1798    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S8.\n");
   1799#endif
   1800
   1801    src = (const float *) cvt->buf;
   1802    dst = (Sint8 *) cvt->buf;
   1803    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   1804        const Sint8 val = ((Sint8) (SDL_SwapFloatLE(*src) * 127.0f));
   1805        *dst = ((Sint8) val);
   1806    }
   1807
   1808    cvt->len_cvt /= 4;
   1809    if (cvt->filters[++cvt->filter_index]) {
   1810        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
   1811    }
   1812}
   1813
   1814static void SDLCALL
   1815SDL_Convert_F32LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1816{
   1817    int i;
   1818    const float *src;
   1819    Uint16 *dst;
   1820
   1821#if DEBUG_CONVERT
   1822    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U16LSB.\n");
   1823#endif
   1824
   1825    src = (const float *) cvt->buf;
   1826    dst = (Uint16 *) cvt->buf;
   1827    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   1828        const Uint16 val = ((Uint16) ((SDL_SwapFloatLE(*src) + 1.0f) * 32767.0f));
   1829        *dst = SDL_SwapLE16(val);
   1830    }
   1831
   1832    cvt->len_cvt /= 2;
   1833    if (cvt->filters[++cvt->filter_index]) {
   1834        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
   1835    }
   1836}
   1837
   1838static void SDLCALL
   1839SDL_Convert_F32LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1840{
   1841    int i;
   1842    const float *src;
   1843    Sint16 *dst;
   1844
   1845#if DEBUG_CONVERT
   1846    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S16LSB.\n");
   1847#endif
   1848
   1849    src = (const float *) cvt->buf;
   1850    dst = (Sint16 *) cvt->buf;
   1851    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   1852        const Sint16 val = ((Sint16) (SDL_SwapFloatLE(*src) * 32767.0f));
   1853        *dst = ((Sint16) SDL_SwapLE16(val));
   1854    }
   1855
   1856    cvt->len_cvt /= 2;
   1857    if (cvt->filters[++cvt->filter_index]) {
   1858        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
   1859    }
   1860}
   1861
   1862static void SDLCALL
   1863SDL_Convert_F32LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1864{
   1865    int i;
   1866    const float *src;
   1867    Uint16 *dst;
   1868
   1869#if DEBUG_CONVERT
   1870    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U16MSB.\n");
   1871#endif
   1872
   1873    src = (const float *) cvt->buf;
   1874    dst = (Uint16 *) cvt->buf;
   1875    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   1876        const Uint16 val = ((Uint16) ((SDL_SwapFloatLE(*src) + 1.0f) * 32767.0f));
   1877        *dst = SDL_SwapBE16(val);
   1878    }
   1879
   1880    cvt->len_cvt /= 2;
   1881    if (cvt->filters[++cvt->filter_index]) {
   1882        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
   1883    }
   1884}
   1885
   1886static void SDLCALL
   1887SDL_Convert_F32LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1888{
   1889    int i;
   1890    const float *src;
   1891    Sint16 *dst;
   1892
   1893#if DEBUG_CONVERT
   1894    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S16MSB.\n");
   1895#endif
   1896
   1897    src = (const float *) cvt->buf;
   1898    dst = (Sint16 *) cvt->buf;
   1899    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   1900        const Sint16 val = ((Sint16) (SDL_SwapFloatLE(*src) * 32767.0f));
   1901        *dst = ((Sint16) SDL_SwapBE16(val));
   1902    }
   1903
   1904    cvt->len_cvt /= 2;
   1905    if (cvt->filters[++cvt->filter_index]) {
   1906        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
   1907    }
   1908}
   1909
   1910static void SDLCALL
   1911SDL_Convert_F32LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1912{
   1913    int i;
   1914    const float *src;
   1915    Sint32 *dst;
   1916
   1917#if DEBUG_CONVERT
   1918    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S32LSB.\n");
   1919#endif
   1920
   1921    src = (const float *) cvt->buf;
   1922    dst = (Sint32 *) cvt->buf;
   1923    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   1924        const Sint32 val = ((Sint32) (SDL_SwapFloatLE(*src) * 2147483647.0));
   1925        *dst = ((Sint32) SDL_SwapLE32(val));
   1926    }
   1927
   1928    if (cvt->filters[++cvt->filter_index]) {
   1929        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
   1930    }
   1931}
   1932
   1933static void SDLCALL
   1934SDL_Convert_F32LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1935{
   1936    int i;
   1937    const float *src;
   1938    Sint32 *dst;
   1939
   1940#if DEBUG_CONVERT
   1941    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S32MSB.\n");
   1942#endif
   1943
   1944    src = (const float *) cvt->buf;
   1945    dst = (Sint32 *) cvt->buf;
   1946    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   1947        const Sint32 val = ((Sint32) (SDL_SwapFloatLE(*src) * 2147483647.0));
   1948        *dst = ((Sint32) SDL_SwapBE32(val));
   1949    }
   1950
   1951    if (cvt->filters[++cvt->filter_index]) {
   1952        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
   1953    }
   1954}
   1955
   1956static void SDLCALL
   1957SDL_Convert_F32LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1958{
   1959    int i;
   1960    const float *src;
   1961    float *dst;
   1962
   1963#if DEBUG_CONVERT
   1964    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_F32MSB.\n");
   1965#endif
   1966
   1967    src = (const float *) cvt->buf;
   1968    dst = (float *) cvt->buf;
   1969    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   1970        const float val = SDL_SwapFloatLE(*src);
   1971        *dst = SDL_SwapFloatBE(val);
   1972    }
   1973
   1974    if (cvt->filters[++cvt->filter_index]) {
   1975        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
   1976    }
   1977}
   1978
   1979static void SDLCALL
   1980SDL_Convert_F32MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   1981{
   1982    int i;
   1983    const float *src;
   1984    Uint8 *dst;
   1985
   1986#if DEBUG_CONVERT
   1987    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U8.\n");
   1988#endif
   1989
   1990    src = (const float *) cvt->buf;
   1991    dst = (Uint8 *) cvt->buf;
   1992    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   1993        const Uint8 val = ((Uint8) ((SDL_SwapFloatBE(*src) + 1.0f) * 127.0f));
   1994        *dst = val;
   1995    }
   1996
   1997    cvt->len_cvt /= 4;
   1998    if (cvt->filters[++cvt->filter_index]) {
   1999        cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
   2000    }
   2001}
   2002
   2003static void SDLCALL
   2004SDL_Convert_F32MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2005{
   2006    int i;
   2007    const float *src;
   2008    Sint8 *dst;
   2009
   2010#if DEBUG_CONVERT
   2011    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S8.\n");
   2012#endif
   2013
   2014    src = (const float *) cvt->buf;
   2015    dst = (Sint8 *) cvt->buf;
   2016    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   2017        const Sint8 val = ((Sint8) (SDL_SwapFloatBE(*src) * 127.0f));
   2018        *dst = ((Sint8) val);
   2019    }
   2020
   2021    cvt->len_cvt /= 4;
   2022    if (cvt->filters[++cvt->filter_index]) {
   2023        cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
   2024    }
   2025}
   2026
   2027static void SDLCALL
   2028SDL_Convert_F32MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2029{
   2030    int i;
   2031    const float *src;
   2032    Uint16 *dst;
   2033
   2034#if DEBUG_CONVERT
   2035    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U16LSB.\n");
   2036#endif
   2037
   2038    src = (const float *) cvt->buf;
   2039    dst = (Uint16 *) cvt->buf;
   2040    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   2041        const Uint16 val = ((Uint16) ((SDL_SwapFloatBE(*src) + 1.0f) * 32767.0f));
   2042        *dst = SDL_SwapLE16(val);
   2043    }
   2044
   2045    cvt->len_cvt /= 2;
   2046    if (cvt->filters[++cvt->filter_index]) {
   2047        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
   2048    }
   2049}
   2050
   2051static void SDLCALL
   2052SDL_Convert_F32MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2053{
   2054    int i;
   2055    const float *src;
   2056    Sint16 *dst;
   2057
   2058#if DEBUG_CONVERT
   2059    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S16LSB.\n");
   2060#endif
   2061
   2062    src = (const float *) cvt->buf;
   2063    dst = (Sint16 *) cvt->buf;
   2064    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   2065        const Sint16 val = ((Sint16) (SDL_SwapFloatBE(*src) * 32767.0f));
   2066        *dst = ((Sint16) SDL_SwapLE16(val));
   2067    }
   2068
   2069    cvt->len_cvt /= 2;
   2070    if (cvt->filters[++cvt->filter_index]) {
   2071        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
   2072    }
   2073}
   2074
   2075static void SDLCALL
   2076SDL_Convert_F32MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2077{
   2078    int i;
   2079    const float *src;
   2080    Uint16 *dst;
   2081
   2082#if DEBUG_CONVERT
   2083    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U16MSB.\n");
   2084#endif
   2085
   2086    src = (const float *) cvt->buf;
   2087    dst = (Uint16 *) cvt->buf;
   2088    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   2089        const Uint16 val = ((Uint16) ((SDL_SwapFloatBE(*src) + 1.0f) * 32767.0f));
   2090        *dst = SDL_SwapBE16(val);
   2091    }
   2092
   2093    cvt->len_cvt /= 2;
   2094    if (cvt->filters[++cvt->filter_index]) {
   2095        cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
   2096    }
   2097}
   2098
   2099static void SDLCALL
   2100SDL_Convert_F32MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2101{
   2102    int i;
   2103    const float *src;
   2104    Sint16 *dst;
   2105
   2106#if DEBUG_CONVERT
   2107    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S16MSB.\n");
   2108#endif
   2109
   2110    src = (const float *) cvt->buf;
   2111    dst = (Sint16 *) cvt->buf;
   2112    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   2113        const Sint16 val = ((Sint16) (SDL_SwapFloatBE(*src) * 32767.0f));
   2114        *dst = ((Sint16) SDL_SwapBE16(val));
   2115    }
   2116
   2117    cvt->len_cvt /= 2;
   2118    if (cvt->filters[++cvt->filter_index]) {
   2119        cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
   2120    }
   2121}
   2122
   2123static void SDLCALL
   2124SDL_Convert_F32MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2125{
   2126    int i;
   2127    const float *src;
   2128    Sint32 *dst;
   2129
   2130#if DEBUG_CONVERT
   2131    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S32LSB.\n");
   2132#endif
   2133
   2134    src = (const float *) cvt->buf;
   2135    dst = (Sint32 *) cvt->buf;
   2136    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   2137        const Sint32 val = ((Sint32) (SDL_SwapFloatBE(*src) * 2147483647.0));
   2138        *dst = ((Sint32) SDL_SwapLE32(val));
   2139    }
   2140
   2141    if (cvt->filters[++cvt->filter_index]) {
   2142        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
   2143    }
   2144}
   2145
   2146static void SDLCALL
   2147SDL_Convert_F32MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2148{
   2149    int i;
   2150    const float *src;
   2151    Sint32 *dst;
   2152
   2153#if DEBUG_CONVERT
   2154    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S32MSB.\n");
   2155#endif
   2156
   2157    src = (const float *) cvt->buf;
   2158    dst = (Sint32 *) cvt->buf;
   2159    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   2160        const Sint32 val = ((Sint32) (SDL_SwapFloatBE(*src) * 2147483647.0));
   2161        *dst = ((Sint32) SDL_SwapBE32(val));
   2162    }
   2163
   2164    if (cvt->filters[++cvt->filter_index]) {
   2165        cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
   2166    }
   2167}
   2168
   2169static void SDLCALL
   2170SDL_Convert_F32MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2171{
   2172    int i;
   2173    const float *src;
   2174    float *dst;
   2175
   2176#if DEBUG_CONVERT
   2177    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_F32LSB.\n");
   2178#endif
   2179
   2180    src = (const float *) cvt->buf;
   2181    dst = (float *) cvt->buf;
   2182    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
   2183        const float val = SDL_SwapFloatBE(*src);
   2184        *dst = SDL_SwapFloatLE(val);
   2185    }
   2186
   2187    if (cvt->filters[++cvt->filter_index]) {
   2188        cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
   2189    }
   2190}
   2191
   2192#endif  /* !NO_CONVERTERS */
   2193
   2194
   2195const SDL_AudioTypeFilters sdl_audio_type_filters[] =
   2196{
   2197#if !NO_CONVERTERS
   2198    { AUDIO_U8, AUDIO_S8, SDL_Convert_U8_to_S8 },
   2199    { AUDIO_U8, AUDIO_U16LSB, SDL_Convert_U8_to_U16LSB },
   2200    { AUDIO_U8, AUDIO_S16LSB, SDL_Convert_U8_to_S16LSB },
   2201    { AUDIO_U8, AUDIO_U16MSB, SDL_Convert_U8_to_U16MSB },
   2202    { AUDIO_U8, AUDIO_S16MSB, SDL_Convert_U8_to_S16MSB },
   2203    { AUDIO_U8, AUDIO_S32LSB, SDL_Convert_U8_to_S32LSB },
   2204    { AUDIO_U8, AUDIO_S32MSB, SDL_Convert_U8_to_S32MSB },
   2205    { AUDIO_U8, AUDIO_F32LSB, SDL_Convert_U8_to_F32LSB },
   2206    { AUDIO_U8, AUDIO_F32MSB, SDL_Convert_U8_to_F32MSB },
   2207    { AUDIO_S8, AUDIO_U8, SDL_Convert_S8_to_U8 },
   2208    { AUDIO_S8, AUDIO_U16LSB, SDL_Convert_S8_to_U16LSB },
   2209    { AUDIO_S8, AUDIO_S16LSB, SDL_Convert_S8_to_S16LSB },
   2210    { AUDIO_S8, AUDIO_U16MSB, SDL_Convert_S8_to_U16MSB },
   2211    { AUDIO_S8, AUDIO_S16MSB, SDL_Convert_S8_to_S16MSB },
   2212    { AUDIO_S8, AUDIO_S32LSB, SDL_Convert_S8_to_S32LSB },
   2213    { AUDIO_S8, AUDIO_S32MSB, SDL_Convert_S8_to_S32MSB },
   2214    { AUDIO_S8, AUDIO_F32LSB, SDL_Convert_S8_to_F32LSB },
   2215    { AUDIO_S8, AUDIO_F32MSB, SDL_Convert_S8_to_F32MSB },
   2216    { AUDIO_U16LSB, AUDIO_U8, SDL_Convert_U16LSB_to_U8 },
   2217    { AUDIO_U16LSB, AUDIO_S8, SDL_Convert_U16LSB_to_S8 },
   2218    { AUDIO_U16LSB, AUDIO_S16LSB, SDL_Convert_U16LSB_to_S16LSB },
   2219    { AUDIO_U16LSB, AUDIO_U16MSB, SDL_Convert_U16LSB_to_U16MSB },
   2220    { AUDIO_U16LSB, AUDIO_S16MSB, SDL_Convert_U16LSB_to_S16MSB },
   2221    { AUDIO_U16LSB, AUDIO_S32LSB, SDL_Convert_U16LSB_to_S32LSB },
   2222    { AUDIO_U16LSB, AUDIO_S32MSB, SDL_Convert_U16LSB_to_S32MSB },
   2223    { AUDIO_U16LSB, AUDIO_F32LSB, SDL_Convert_U16LSB_to_F32LSB },
   2224    { AUDIO_U16LSB, AUDIO_F32MSB, SDL_Convert_U16LSB_to_F32MSB },
   2225    { AUDIO_S16LSB, AUDIO_U8, SDL_Convert_S16LSB_to_U8 },
   2226    { AUDIO_S16LSB, AUDIO_S8, SDL_Convert_S16LSB_to_S8 },
   2227    { AUDIO_S16LSB, AUDIO_U16LSB, SDL_Convert_S16LSB_to_U16LSB },
   2228    { AUDIO_S16LSB, AUDIO_U16MSB, SDL_Convert_S16LSB_to_U16MSB },
   2229    { AUDIO_S16LSB, AUDIO_S16MSB, SDL_Convert_S16LSB_to_S16MSB },
   2230    { AUDIO_S16LSB, AUDIO_S32LSB, SDL_Convert_S16LSB_to_S32LSB },
   2231    { AUDIO_S16LSB, AUDIO_S32MSB, SDL_Convert_S16LSB_to_S32MSB },
   2232    { AUDIO_S16LSB, AUDIO_F32LSB, SDL_Convert_S16LSB_to_F32LSB },
   2233    { AUDIO_S16LSB, AUDIO_F32MSB, SDL_Convert_S16LSB_to_F32MSB },
   2234    { AUDIO_U16MSB, AUDIO_U8, SDL_Convert_U16MSB_to_U8 },
   2235    { AUDIO_U16MSB, AUDIO_S8, SDL_Convert_U16MSB_to_S8 },
   2236    { AUDIO_U16MSB, AUDIO_U16LSB, SDL_Convert_U16MSB_to_U16LSB },
   2237    { AUDIO_U16MSB, AUDIO_S16LSB, SDL_Convert_U16MSB_to_S16LSB },
   2238    { AUDIO_U16MSB, AUDIO_S16MSB, SDL_Convert_U16MSB_to_S16MSB },
   2239    { AUDIO_U16MSB, AUDIO_S32LSB, SDL_Convert_U16MSB_to_S32LSB },
   2240    { AUDIO_U16MSB, AUDIO_S32MSB, SDL_Convert_U16MSB_to_S32MSB },
   2241    { AUDIO_U16MSB, AUDIO_F32LSB, SDL_Convert_U16MSB_to_F32LSB },
   2242    { AUDIO_U16MSB, AUDIO_F32MSB, SDL_Convert_U16MSB_to_F32MSB },
   2243    { AUDIO_S16MSB, AUDIO_U8, SDL_Convert_S16MSB_to_U8 },
   2244    { AUDIO_S16MSB, AUDIO_S8, SDL_Convert_S16MSB_to_S8 },
   2245    { AUDIO_S16MSB, AUDIO_U16LSB, SDL_Convert_S16MSB_to_U16LSB },
   2246    { AUDIO_S16MSB, AUDIO_S16LSB, SDL_Convert_S16MSB_to_S16LSB },
   2247    { AUDIO_S16MSB, AUDIO_U16MSB, SDL_Convert_S16MSB_to_U16MSB },
   2248    { AUDIO_S16MSB, AUDIO_S32LSB, SDL_Convert_S16MSB_to_S32LSB },
   2249    { AUDIO_S16MSB, AUDIO_S32MSB, SDL_Convert_S16MSB_to_S32MSB },
   2250    { AUDIO_S16MSB, AUDIO_F32LSB, SDL_Convert_S16MSB_to_F32LSB },
   2251    { AUDIO_S16MSB, AUDIO_F32MSB, SDL_Convert_S16MSB_to_F32MSB },
   2252    { AUDIO_S32LSB, AUDIO_U8, SDL_Convert_S32LSB_to_U8 },
   2253    { AUDIO_S32LSB, AUDIO_S8, SDL_Convert_S32LSB_to_S8 },
   2254    { AUDIO_S32LSB, AUDIO_U16LSB, SDL_Convert_S32LSB_to_U16LSB },
   2255    { AUDIO_S32LSB, AUDIO_S16LSB, SDL_Convert_S32LSB_to_S16LSB },
   2256    { AUDIO_S32LSB, AUDIO_U16MSB, SDL_Convert_S32LSB_to_U16MSB },
   2257    { AUDIO_S32LSB, AUDIO_S16MSB, SDL_Convert_S32LSB_to_S16MSB },
   2258    { AUDIO_S32LSB, AUDIO_S32MSB, SDL_Convert_S32LSB_to_S32MSB },
   2259    { AUDIO_S32LSB, AUDIO_F32LSB, SDL_Convert_S32LSB_to_F32LSB },
   2260    { AUDIO_S32LSB, AUDIO_F32MSB, SDL_Convert_S32LSB_to_F32MSB },
   2261    { AUDIO_S32MSB, AUDIO_U8, SDL_Convert_S32MSB_to_U8 },
   2262    { AUDIO_S32MSB, AUDIO_S8, SDL_Convert_S32MSB_to_S8 },
   2263    { AUDIO_S32MSB, AUDIO_U16LSB, SDL_Convert_S32MSB_to_U16LSB },
   2264    { AUDIO_S32MSB, AUDIO_S16LSB, SDL_Convert_S32MSB_to_S16LSB },
   2265    { AUDIO_S32MSB, AUDIO_U16MSB, SDL_Convert_S32MSB_to_U16MSB },
   2266    { AUDIO_S32MSB, AUDIO_S16MSB, SDL_Convert_S32MSB_to_S16MSB },
   2267    { AUDIO_S32MSB, AUDIO_S32LSB, SDL_Convert_S32MSB_to_S32LSB },
   2268    { AUDIO_S32MSB, AUDIO_F32LSB, SDL_Convert_S32MSB_to_F32LSB },
   2269    { AUDIO_S32MSB, AUDIO_F32MSB, SDL_Convert_S32MSB_to_F32MSB },
   2270    { AUDIO_F32LSB, AUDIO_U8, SDL_Convert_F32LSB_to_U8 },
   2271    { AUDIO_F32LSB, AUDIO_S8, SDL_Convert_F32LSB_to_S8 },
   2272    { AUDIO_F32LSB, AUDIO_U16LSB, SDL_Convert_F32LSB_to_U16LSB },
   2273    { AUDIO_F32LSB, AUDIO_S16LSB, SDL_Convert_F32LSB_to_S16LSB },
   2274    { AUDIO_F32LSB, AUDIO_U16MSB, SDL_Convert_F32LSB_to_U16MSB },
   2275    { AUDIO_F32LSB, AUDIO_S16MSB, SDL_Convert_F32LSB_to_S16MSB },
   2276    { AUDIO_F32LSB, AUDIO_S32LSB, SDL_Convert_F32LSB_to_S32LSB },
   2277    { AUDIO_F32LSB, AUDIO_S32MSB, SDL_Convert_F32LSB_to_S32MSB },
   2278    { AUDIO_F32LSB, AUDIO_F32MSB, SDL_Convert_F32LSB_to_F32MSB },
   2279    { AUDIO_F32MSB, AUDIO_U8, SDL_Convert_F32MSB_to_U8 },
   2280    { AUDIO_F32MSB, AUDIO_S8, SDL_Convert_F32MSB_to_S8 },
   2281    { AUDIO_F32MSB, AUDIO_U16LSB, SDL_Convert_F32MSB_to_U16LSB },
   2282    { AUDIO_F32MSB, AUDIO_S16LSB, SDL_Convert_F32MSB_to_S16LSB },
   2283    { AUDIO_F32MSB, AUDIO_U16MSB, SDL_Convert_F32MSB_to_U16MSB },
   2284    { AUDIO_F32MSB, AUDIO_S16MSB, SDL_Convert_F32MSB_to_S16MSB },
   2285    { AUDIO_F32MSB, AUDIO_S32LSB, SDL_Convert_F32MSB_to_S32LSB },
   2286    { AUDIO_F32MSB, AUDIO_S32MSB, SDL_Convert_F32MSB_to_S32MSB },
   2287    { AUDIO_F32MSB, AUDIO_F32LSB, SDL_Convert_F32MSB_to_F32LSB },
   2288#endif  /* !NO_CONVERTERS */
   2289    { 0, 0, NULL }
   2290};
   2291
   2292
   2293#if !NO_RESAMPLERS
   2294
   2295static void SDLCALL
   2296SDL_Upsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2297{
   2298#if DEBUG_CONVERT
   2299    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 1 channels.\n", cvt->rate_incr);
   2300#endif
   2301
   2302    const int srcsize = cvt->len_cvt - 16;
   2303    const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
   2304    register int eps = 0;
   2305    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1;
   2306    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   2307    const Uint8 *target = ((const Uint8 *) cvt->buf);
   2308    Uint8 sample0 = src[0];
   2309    Uint8 last_sample0 = sample0;
   2310    while (dst >= target) {
   2311        dst[0] = sample0;
   2312        dst--;
   2313        eps += srcsize;
   2314        if ((eps << 1) >= dstsize) {
   2315            src--;
   2316            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   2317            last_sample0 = sample0;
   2318            eps -= dstsize;
   2319        }
   2320    }
   2321    cvt->len_cvt = dstsize;
   2322    if (cvt->filters[++cvt->filter_index]) {
   2323        cvt->filters[cvt->filter_index] (cvt, format);
   2324    }
   2325}
   2326
   2327static void SDLCALL
   2328SDL_Downsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2329{
   2330#if DEBUG_CONVERT
   2331    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 1 channels.\n", cvt->rate_incr);
   2332#endif
   2333
   2334    const int srcsize = cvt->len_cvt - 16;
   2335    const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
   2336    register int eps = 0;
   2337    Uint8 *dst = (Uint8 *) cvt->buf;
   2338    const Uint8 *src = (Uint8 *) cvt->buf;
   2339    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   2340    Uint8 sample0 = src[0];
   2341    Uint8 last_sample0 = sample0;
   2342    while (dst < target) {
   2343        src++;
   2344        eps += dstsize;
   2345        if ((eps << 1) >= srcsize) {
   2346            dst[0] = sample0;
   2347            dst++;
   2348            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   2349            last_sample0 = sample0;
   2350            eps -= srcsize;
   2351        }
   2352    }
   2353    cvt->len_cvt = dstsize;
   2354    if (cvt->filters[++cvt->filter_index]) {
   2355        cvt->filters[cvt->filter_index] (cvt, format);
   2356    }
   2357}
   2358
   2359static void SDLCALL
   2360SDL_Upsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2361{
   2362#if DEBUG_CONVERT
   2363    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 2 channels.\n", cvt->rate_incr);
   2364#endif
   2365
   2366    const int srcsize = cvt->len_cvt - 32;
   2367    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
   2368    register int eps = 0;
   2369    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2;
   2370    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
   2371    const Uint8 *target = ((const Uint8 *) cvt->buf);
   2372    Uint8 sample1 = src[1];
   2373    Uint8 sample0 = src[0];
   2374    Uint8 last_sample1 = sample1;
   2375    Uint8 last_sample0 = sample0;
   2376    while (dst >= target) {
   2377        dst[1] = sample1;
   2378        dst[0] = sample0;
   2379        dst -= 2;
   2380        eps += srcsize;
   2381        if ((eps << 1) >= dstsize) {
   2382            src -= 2;
   2383            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   2384            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   2385            last_sample1 = sample1;
   2386            last_sample0 = sample0;
   2387            eps -= dstsize;
   2388        }
   2389    }
   2390    cvt->len_cvt = dstsize;
   2391    if (cvt->filters[++cvt->filter_index]) {
   2392        cvt->filters[cvt->filter_index] (cvt, format);
   2393    }
   2394}
   2395
   2396static void SDLCALL
   2397SDL_Downsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2398{
   2399#if DEBUG_CONVERT
   2400    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 2 channels.\n", cvt->rate_incr);
   2401#endif
   2402
   2403    const int srcsize = cvt->len_cvt - 32;
   2404    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
   2405    register int eps = 0;
   2406    Uint8 *dst = (Uint8 *) cvt->buf;
   2407    const Uint8 *src = (Uint8 *) cvt->buf;
   2408    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   2409    Uint8 sample0 = src[0];
   2410    Uint8 sample1 = src[1];
   2411    Uint8 last_sample0 = sample0;
   2412    Uint8 last_sample1 = sample1;
   2413    while (dst < target) {
   2414        src += 2;
   2415        eps += dstsize;
   2416        if ((eps << 1) >= srcsize) {
   2417            dst[0] = sample0;
   2418            dst[1] = sample1;
   2419            dst += 2;
   2420            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   2421            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   2422            last_sample0 = sample0;
   2423            last_sample1 = sample1;
   2424            eps -= srcsize;
   2425        }
   2426    }
   2427    cvt->len_cvt = dstsize;
   2428    if (cvt->filters[++cvt->filter_index]) {
   2429        cvt->filters[cvt->filter_index] (cvt, format);
   2430    }
   2431}
   2432
   2433static void SDLCALL
   2434SDL_Upsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2435{
   2436#if DEBUG_CONVERT
   2437    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 4 channels.\n", cvt->rate_incr);
   2438#endif
   2439
   2440    const int srcsize = cvt->len_cvt - 64;
   2441    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   2442    register int eps = 0;
   2443    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4;
   2444    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
   2445    const Uint8 *target = ((const Uint8 *) cvt->buf);
   2446    Uint8 sample3 = src[3];
   2447    Uint8 sample2 = src[2];
   2448    Uint8 sample1 = src[1];
   2449    Uint8 sample0 = src[0];
   2450    Uint8 last_sample3 = sample3;
   2451    Uint8 last_sample2 = sample2;
   2452    Uint8 last_sample1 = sample1;
   2453    Uint8 last_sample0 = sample0;
   2454    while (dst >= target) {
   2455        dst[3] = sample3;
   2456        dst[2] = sample2;
   2457        dst[1] = sample1;
   2458        dst[0] = sample0;
   2459        dst -= 4;
   2460        eps += srcsize;
   2461        if ((eps << 1) >= dstsize) {
   2462            src -= 4;
   2463            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
   2464            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
   2465            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   2466            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   2467            last_sample3 = sample3;
   2468            last_sample2 = sample2;
   2469            last_sample1 = sample1;
   2470            last_sample0 = sample0;
   2471            eps -= dstsize;
   2472        }
   2473    }
   2474    cvt->len_cvt = dstsize;
   2475    if (cvt->filters[++cvt->filter_index]) {
   2476        cvt->filters[cvt->filter_index] (cvt, format);
   2477    }
   2478}
   2479
   2480static void SDLCALL
   2481SDL_Downsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2482{
   2483#if DEBUG_CONVERT
   2484    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 4 channels.\n", cvt->rate_incr);
   2485#endif
   2486
   2487    const int srcsize = cvt->len_cvt - 64;
   2488    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   2489    register int eps = 0;
   2490    Uint8 *dst = (Uint8 *) cvt->buf;
   2491    const Uint8 *src = (Uint8 *) cvt->buf;
   2492    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   2493    Uint8 sample0 = src[0];
   2494    Uint8 sample1 = src[1];
   2495    Uint8 sample2 = src[2];
   2496    Uint8 sample3 = src[3];
   2497    Uint8 last_sample0 = sample0;
   2498    Uint8 last_sample1 = sample1;
   2499    Uint8 last_sample2 = sample2;
   2500    Uint8 last_sample3 = sample3;
   2501    while (dst < target) {
   2502        src += 4;
   2503        eps += dstsize;
   2504        if ((eps << 1) >= srcsize) {
   2505            dst[0] = sample0;
   2506            dst[1] = sample1;
   2507            dst[2] = sample2;
   2508            dst[3] = sample3;
   2509            dst += 4;
   2510            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   2511            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   2512            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
   2513            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
   2514            last_sample0 = sample0;
   2515            last_sample1 = sample1;
   2516            last_sample2 = sample2;
   2517            last_sample3 = sample3;
   2518            eps -= srcsize;
   2519        }
   2520    }
   2521    cvt->len_cvt = dstsize;
   2522    if (cvt->filters[++cvt->filter_index]) {
   2523        cvt->filters[cvt->filter_index] (cvt, format);
   2524    }
   2525}
   2526
   2527static void SDLCALL
   2528SDL_Upsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2529{
   2530#if DEBUG_CONVERT
   2531    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 6 channels.\n", cvt->rate_incr);
   2532#endif
   2533
   2534    const int srcsize = cvt->len_cvt - 96;
   2535    const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
   2536    register int eps = 0;
   2537    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6;
   2538    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
   2539    const Uint8 *target = ((const Uint8 *) cvt->buf);
   2540    Uint8 sample5 = src[5];
   2541    Uint8 sample4 = src[4];
   2542    Uint8 sample3 = src[3];
   2543    Uint8 sample2 = src[2];
   2544    Uint8 sample1 = src[1];
   2545    Uint8 sample0 = src[0];
   2546    Uint8 last_sample5 = sample5;
   2547    Uint8 last_sample4 = sample4;
   2548    Uint8 last_sample3 = sample3;
   2549    Uint8 last_sample2 = sample2;
   2550    Uint8 last_sample1 = sample1;
   2551    Uint8 last_sample0 = sample0;
   2552    while (dst >= target) {
   2553        dst[5] = sample5;
   2554        dst[4] = sample4;
   2555        dst[3] = sample3;
   2556        dst[2] = sample2;
   2557        dst[1] = sample1;
   2558        dst[0] = sample0;
   2559        dst -= 6;
   2560        eps += srcsize;
   2561        if ((eps << 1) >= dstsize) {
   2562            src -= 6;
   2563            sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
   2564            sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
   2565            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
   2566            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
   2567            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   2568            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   2569            last_sample5 = sample5;
   2570            last_sample4 = sample4;
   2571            last_sample3 = sample3;
   2572            last_sample2 = sample2;
   2573            last_sample1 = sample1;
   2574            last_sample0 = sample0;
   2575            eps -= dstsize;
   2576        }
   2577    }
   2578    cvt->len_cvt = dstsize;
   2579    if (cvt->filters[++cvt->filter_index]) {
   2580        cvt->filters[cvt->filter_index] (cvt, format);
   2581    }
   2582}
   2583
   2584static void SDLCALL
   2585SDL_Downsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2586{
   2587#if DEBUG_CONVERT
   2588    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 6 channels.\n", cvt->rate_incr);
   2589#endif
   2590
   2591    const int srcsize = cvt->len_cvt - 96;
   2592    const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
   2593    register int eps = 0;
   2594    Uint8 *dst = (Uint8 *) cvt->buf;
   2595    const Uint8 *src = (Uint8 *) cvt->buf;
   2596    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   2597    Uint8 sample0 = src[0];
   2598    Uint8 sample1 = src[1];
   2599    Uint8 sample2 = src[2];
   2600    Uint8 sample3 = src[3];
   2601    Uint8 sample4 = src[4];
   2602    Uint8 sample5 = src[5];
   2603    Uint8 last_sample0 = sample0;
   2604    Uint8 last_sample1 = sample1;
   2605    Uint8 last_sample2 = sample2;
   2606    Uint8 last_sample3 = sample3;
   2607    Uint8 last_sample4 = sample4;
   2608    Uint8 last_sample5 = sample5;
   2609    while (dst < target) {
   2610        src += 6;
   2611        eps += dstsize;
   2612        if ((eps << 1) >= srcsize) {
   2613            dst[0] = sample0;
   2614            dst[1] = sample1;
   2615            dst[2] = sample2;
   2616            dst[3] = sample3;
   2617            dst[4] = sample4;
   2618            dst[5] = sample5;
   2619            dst += 6;
   2620            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   2621            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   2622            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
   2623            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
   2624            sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
   2625            sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
   2626            last_sample0 = sample0;
   2627            last_sample1 = sample1;
   2628            last_sample2 = sample2;
   2629            last_sample3 = sample3;
   2630            last_sample4 = sample4;
   2631            last_sample5 = sample5;
   2632            eps -= srcsize;
   2633        }
   2634    }
   2635    cvt->len_cvt = dstsize;
   2636    if (cvt->filters[++cvt->filter_index]) {
   2637        cvt->filters[cvt->filter_index] (cvt, format);
   2638    }
   2639}
   2640
   2641static void SDLCALL
   2642SDL_Upsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2643{
   2644#if DEBUG_CONVERT
   2645    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 8 channels.\n", cvt->rate_incr);
   2646#endif
   2647
   2648    const int srcsize = cvt->len_cvt - 128;
   2649    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   2650    register int eps = 0;
   2651    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8;
   2652    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
   2653    const Uint8 *target = ((const Uint8 *) cvt->buf);
   2654    Uint8 sample7 = src[7];
   2655    Uint8 sample6 = src[6];
   2656    Uint8 sample5 = src[5];
   2657    Uint8 sample4 = src[4];
   2658    Uint8 sample3 = src[3];
   2659    Uint8 sample2 = src[2];
   2660    Uint8 sample1 = src[1];
   2661    Uint8 sample0 = src[0];
   2662    Uint8 last_sample7 = sample7;
   2663    Uint8 last_sample6 = sample6;
   2664    Uint8 last_sample5 = sample5;
   2665    Uint8 last_sample4 = sample4;
   2666    Uint8 last_sample3 = sample3;
   2667    Uint8 last_sample2 = sample2;
   2668    Uint8 last_sample1 = sample1;
   2669    Uint8 last_sample0 = sample0;
   2670    while (dst >= target) {
   2671        dst[7] = sample7;
   2672        dst[6] = sample6;
   2673        dst[5] = sample5;
   2674        dst[4] = sample4;
   2675        dst[3] = sample3;
   2676        dst[2] = sample2;
   2677        dst[1] = sample1;
   2678        dst[0] = sample0;
   2679        dst -= 8;
   2680        eps += srcsize;
   2681        if ((eps << 1) >= dstsize) {
   2682            src -= 8;
   2683            sample7 = (Uint8) ((((Sint16) src[7]) + ((Sint16) last_sample7)) >> 1);
   2684            sample6 = (Uint8) ((((Sint16) src[6]) + ((Sint16) last_sample6)) >> 1);
   2685            sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
   2686            sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
   2687            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
   2688            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
   2689            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   2690            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   2691            last_sample7 = sample7;
   2692            last_sample6 = sample6;
   2693            last_sample5 = sample5;
   2694            last_sample4 = sample4;
   2695            last_sample3 = sample3;
   2696            last_sample2 = sample2;
   2697            last_sample1 = sample1;
   2698            last_sample0 = sample0;
   2699            eps -= dstsize;
   2700        }
   2701    }
   2702    cvt->len_cvt = dstsize;
   2703    if (cvt->filters[++cvt->filter_index]) {
   2704        cvt->filters[cvt->filter_index] (cvt, format);
   2705    }
   2706}
   2707
   2708static void SDLCALL
   2709SDL_Downsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2710{
   2711#if DEBUG_CONVERT
   2712    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 8 channels.\n", cvt->rate_incr);
   2713#endif
   2714
   2715    const int srcsize = cvt->len_cvt - 128;
   2716    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   2717    register int eps = 0;
   2718    Uint8 *dst = (Uint8 *) cvt->buf;
   2719    const Uint8 *src = (Uint8 *) cvt->buf;
   2720    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   2721    Uint8 sample0 = src[0];
   2722    Uint8 sample1 = src[1];
   2723    Uint8 sample2 = src[2];
   2724    Uint8 sample3 = src[3];
   2725    Uint8 sample4 = src[4];
   2726    Uint8 sample5 = src[5];
   2727    Uint8 sample6 = src[6];
   2728    Uint8 sample7 = src[7];
   2729    Uint8 last_sample0 = sample0;
   2730    Uint8 last_sample1 = sample1;
   2731    Uint8 last_sample2 = sample2;
   2732    Uint8 last_sample3 = sample3;
   2733    Uint8 last_sample4 = sample4;
   2734    Uint8 last_sample5 = sample5;
   2735    Uint8 last_sample6 = sample6;
   2736    Uint8 last_sample7 = sample7;
   2737    while (dst < target) {
   2738        src += 8;
   2739        eps += dstsize;
   2740        if ((eps << 1) >= srcsize) {
   2741            dst[0] = sample0;
   2742            dst[1] = sample1;
   2743            dst[2] = sample2;
   2744            dst[3] = sample3;
   2745            dst[4] = sample4;
   2746            dst[5] = sample5;
   2747            dst[6] = sample6;
   2748            dst[7] = sample7;
   2749            dst += 8;
   2750            sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
   2751            sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
   2752            sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
   2753            sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
   2754            sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
   2755            sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
   2756            sample6 = (Uint8) ((((Sint16) src[6]) + ((Sint16) last_sample6)) >> 1);
   2757            sample7 = (Uint8) ((((Sint16) src[7]) + ((Sint16) last_sample7)) >> 1);
   2758            last_sample0 = sample0;
   2759            last_sample1 = sample1;
   2760            last_sample2 = sample2;
   2761            last_sample3 = sample3;
   2762            last_sample4 = sample4;
   2763            last_sample5 = sample5;
   2764            last_sample6 = sample6;
   2765            last_sample7 = sample7;
   2766            eps -= srcsize;
   2767        }
   2768    }
   2769    cvt->len_cvt = dstsize;
   2770    if (cvt->filters[++cvt->filter_index]) {
   2771        cvt->filters[cvt->filter_index] (cvt, format);
   2772    }
   2773}
   2774
   2775static void SDLCALL
   2776SDL_Upsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2777{
   2778#if DEBUG_CONVERT
   2779    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 1 channels.\n", cvt->rate_incr);
   2780#endif
   2781
   2782    const int srcsize = cvt->len_cvt - 16;
   2783    const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
   2784    register int eps = 0;
   2785    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1;
   2786    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   2787    const Sint8 *target = ((const Sint8 *) cvt->buf);
   2788    Sint8 sample0 = ((Sint8) src[0]);
   2789    Sint8 last_sample0 = sample0;
   2790    while (dst >= target) {
   2791        dst[0] = ((Sint8) sample0);
   2792        dst--;
   2793        eps += srcsize;
   2794        if ((eps << 1) >= dstsize) {
   2795            src--;
   2796            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   2797            last_sample0 = sample0;
   2798            eps -= dstsize;
   2799        }
   2800    }
   2801    cvt->len_cvt = dstsize;
   2802    if (cvt->filters[++cvt->filter_index]) {
   2803        cvt->filters[cvt->filter_index] (cvt, format);
   2804    }
   2805}
   2806
   2807static void SDLCALL
   2808SDL_Downsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2809{
   2810#if DEBUG_CONVERT
   2811    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 1 channels.\n", cvt->rate_incr);
   2812#endif
   2813
   2814    const int srcsize = cvt->len_cvt - 16;
   2815    const int dstsize = (int) (((double)(cvt->len_cvt/1)) * cvt->rate_incr) * 1;
   2816    register int eps = 0;
   2817    Sint8 *dst = (Sint8 *) cvt->buf;
   2818    const Sint8 *src = (Sint8 *) cvt->buf;
   2819    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   2820    Sint8 sample0 = ((Sint8) src[0]);
   2821    Sint8 last_sample0 = sample0;
   2822    while (dst < target) {
   2823        src++;
   2824        eps += dstsize;
   2825        if ((eps << 1) >= srcsize) {
   2826            dst[0] = ((Sint8) sample0);
   2827            dst++;
   2828            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   2829            last_sample0 = sample0;
   2830            eps -= srcsize;
   2831        }
   2832    }
   2833    cvt->len_cvt = dstsize;
   2834    if (cvt->filters[++cvt->filter_index]) {
   2835        cvt->filters[cvt->filter_index] (cvt, format);
   2836    }
   2837}
   2838
   2839static void SDLCALL
   2840SDL_Upsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2841{
   2842#if DEBUG_CONVERT
   2843    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 2 channels.\n", cvt->rate_incr);
   2844#endif
   2845
   2846    const int srcsize = cvt->len_cvt - 32;
   2847    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
   2848    register int eps = 0;
   2849    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2;
   2850    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
   2851    const Sint8 *target = ((const Sint8 *) cvt->buf);
   2852    Sint8 sample1 = ((Sint8) src[1]);
   2853    Sint8 sample0 = ((Sint8) src[0]);
   2854    Sint8 last_sample1 = sample1;
   2855    Sint8 last_sample0 = sample0;
   2856    while (dst >= target) {
   2857        dst[1] = ((Sint8) sample1);
   2858        dst[0] = ((Sint8) sample0);
   2859        dst -= 2;
   2860        eps += srcsize;
   2861        if ((eps << 1) >= dstsize) {
   2862            src -= 2;
   2863            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
   2864            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   2865            last_sample1 = sample1;
   2866            last_sample0 = sample0;
   2867            eps -= dstsize;
   2868        }
   2869    }
   2870    cvt->len_cvt = dstsize;
   2871    if (cvt->filters[++cvt->filter_index]) {
   2872        cvt->filters[cvt->filter_index] (cvt, format);
   2873    }
   2874}
   2875
   2876static void SDLCALL
   2877SDL_Downsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2878{
   2879#if DEBUG_CONVERT
   2880    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 2 channels.\n", cvt->rate_incr);
   2881#endif
   2882
   2883    const int srcsize = cvt->len_cvt - 32;
   2884    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
   2885    register int eps = 0;
   2886    Sint8 *dst = (Sint8 *) cvt->buf;
   2887    const Sint8 *src = (Sint8 *) cvt->buf;
   2888    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   2889    Sint8 sample0 = ((Sint8) src[0]);
   2890    Sint8 sample1 = ((Sint8) src[1]);
   2891    Sint8 last_sample0 = sample0;
   2892    Sint8 last_sample1 = sample1;
   2893    while (dst < target) {
   2894        src += 2;
   2895        eps += dstsize;
   2896        if ((eps << 1) >= srcsize) {
   2897            dst[0] = ((Sint8) sample0);
   2898            dst[1] = ((Sint8) sample1);
   2899            dst += 2;
   2900            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   2901            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
   2902            last_sample0 = sample0;
   2903            last_sample1 = sample1;
   2904            eps -= srcsize;
   2905        }
   2906    }
   2907    cvt->len_cvt = dstsize;
   2908    if (cvt->filters[++cvt->filter_index]) {
   2909        cvt->filters[cvt->filter_index] (cvt, format);
   2910    }
   2911}
   2912
   2913static void SDLCALL
   2914SDL_Upsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2915{
   2916#if DEBUG_CONVERT
   2917    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 4 channels.\n", cvt->rate_incr);
   2918#endif
   2919
   2920    const int srcsize = cvt->len_cvt - 64;
   2921    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   2922    register int eps = 0;
   2923    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4;
   2924    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
   2925    const Sint8 *target = ((const Sint8 *) cvt->buf);
   2926    Sint8 sample3 = ((Sint8) src[3]);
   2927    Sint8 sample2 = ((Sint8) src[2]);
   2928    Sint8 sample1 = ((Sint8) src[1]);
   2929    Sint8 sample0 = ((Sint8) src[0]);
   2930    Sint8 last_sample3 = sample3;
   2931    Sint8 last_sample2 = sample2;
   2932    Sint8 last_sample1 = sample1;
   2933    Sint8 last_sample0 = sample0;
   2934    while (dst >= target) {
   2935        dst[3] = ((Sint8) sample3);
   2936        dst[2] = ((Sint8) sample2);
   2937        dst[1] = ((Sint8) sample1);
   2938        dst[0] = ((Sint8) sample0);
   2939        dst -= 4;
   2940        eps += srcsize;
   2941        if ((eps << 1) >= dstsize) {
   2942            src -= 4;
   2943            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
   2944            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
   2945            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
   2946            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   2947            last_sample3 = sample3;
   2948            last_sample2 = sample2;
   2949            last_sample1 = sample1;
   2950            last_sample0 = sample0;
   2951            eps -= dstsize;
   2952        }
   2953    }
   2954    cvt->len_cvt = dstsize;
   2955    if (cvt->filters[++cvt->filter_index]) {
   2956        cvt->filters[cvt->filter_index] (cvt, format);
   2957    }
   2958}
   2959
   2960static void SDLCALL
   2961SDL_Downsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   2962{
   2963#if DEBUG_CONVERT
   2964    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 4 channels.\n", cvt->rate_incr);
   2965#endif
   2966
   2967    const int srcsize = cvt->len_cvt - 64;
   2968    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   2969    register int eps = 0;
   2970    Sint8 *dst = (Sint8 *) cvt->buf;
   2971    const Sint8 *src = (Sint8 *) cvt->buf;
   2972    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   2973    Sint8 sample0 = ((Sint8) src[0]);
   2974    Sint8 sample1 = ((Sint8) src[1]);
   2975    Sint8 sample2 = ((Sint8) src[2]);
   2976    Sint8 sample3 = ((Sint8) src[3]);
   2977    Sint8 last_sample0 = sample0;
   2978    Sint8 last_sample1 = sample1;
   2979    Sint8 last_sample2 = sample2;
   2980    Sint8 last_sample3 = sample3;
   2981    while (dst < target) {
   2982        src += 4;
   2983        eps += dstsize;
   2984        if ((eps << 1) >= srcsize) {
   2985            dst[0] = ((Sint8) sample0);
   2986            dst[1] = ((Sint8) sample1);
   2987            dst[2] = ((Sint8) sample2);
   2988            dst[3] = ((Sint8) sample3);
   2989            dst += 4;
   2990            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   2991            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
   2992            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
   2993            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
   2994            last_sample0 = sample0;
   2995            last_sample1 = sample1;
   2996            last_sample2 = sample2;
   2997            last_sample3 = sample3;
   2998            eps -= srcsize;
   2999        }
   3000    }
   3001    cvt->len_cvt = dstsize;
   3002    if (cvt->filters[++cvt->filter_index]) {
   3003        cvt->filters[cvt->filter_index] (cvt, format);
   3004    }
   3005}
   3006
   3007static void SDLCALL
   3008SDL_Upsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3009{
   3010#if DEBUG_CONVERT
   3011    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 6 channels.\n", cvt->rate_incr);
   3012#endif
   3013
   3014    const int srcsize = cvt->len_cvt - 96;
   3015    const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
   3016    register int eps = 0;
   3017    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6;
   3018    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
   3019    const Sint8 *target = ((const Sint8 *) cvt->buf);
   3020    Sint8 sample5 = ((Sint8) src[5]);
   3021    Sint8 sample4 = ((Sint8) src[4]);
   3022    Sint8 sample3 = ((Sint8) src[3]);
   3023    Sint8 sample2 = ((Sint8) src[2]);
   3024    Sint8 sample1 = ((Sint8) src[1]);
   3025    Sint8 sample0 = ((Sint8) src[0]);
   3026    Sint8 last_sample5 = sample5;
   3027    Sint8 last_sample4 = sample4;
   3028    Sint8 last_sample3 = sample3;
   3029    Sint8 last_sample2 = sample2;
   3030    Sint8 last_sample1 = sample1;
   3031    Sint8 last_sample0 = sample0;
   3032    while (dst >= target) {
   3033        dst[5] = ((Sint8) sample5);
   3034        dst[4] = ((Sint8) sample4);
   3035        dst[3] = ((Sint8) sample3);
   3036        dst[2] = ((Sint8) sample2);
   3037        dst[1] = ((Sint8) sample1);
   3038        dst[0] = ((Sint8) sample0);
   3039        dst -= 6;
   3040        eps += srcsize;
   3041        if ((eps << 1) >= dstsize) {
   3042            src -= 6;
   3043            sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
   3044            sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
   3045            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
   3046            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
   3047            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
   3048            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   3049            last_sample5 = sample5;
   3050            last_sample4 = sample4;
   3051            last_sample3 = sample3;
   3052            last_sample2 = sample2;
   3053            last_sample1 = sample1;
   3054            last_sample0 = sample0;
   3055            eps -= dstsize;
   3056        }
   3057    }
   3058    cvt->len_cvt = dstsize;
   3059    if (cvt->filters[++cvt->filter_index]) {
   3060        cvt->filters[cvt->filter_index] (cvt, format);
   3061    }
   3062}
   3063
   3064static void SDLCALL
   3065SDL_Downsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3066{
   3067#if DEBUG_CONVERT
   3068    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 6 channels.\n", cvt->rate_incr);
   3069#endif
   3070
   3071    const int srcsize = cvt->len_cvt - 96;
   3072    const int dstsize = (int) (((double)(cvt->len_cvt/6)) * cvt->rate_incr) * 6;
   3073    register int eps = 0;
   3074    Sint8 *dst = (Sint8 *) cvt->buf;
   3075    const Sint8 *src = (Sint8 *) cvt->buf;
   3076    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   3077    Sint8 sample0 = ((Sint8) src[0]);
   3078    Sint8 sample1 = ((Sint8) src[1]);
   3079    Sint8 sample2 = ((Sint8) src[2]);
   3080    Sint8 sample3 = ((Sint8) src[3]);
   3081    Sint8 sample4 = ((Sint8) src[4]);
   3082    Sint8 sample5 = ((Sint8) src[5]);
   3083    Sint8 last_sample0 = sample0;
   3084    Sint8 last_sample1 = sample1;
   3085    Sint8 last_sample2 = sample2;
   3086    Sint8 last_sample3 = sample3;
   3087    Sint8 last_sample4 = sample4;
   3088    Sint8 last_sample5 = sample5;
   3089    while (dst < target) {
   3090        src += 6;
   3091        eps += dstsize;
   3092        if ((eps << 1) >= srcsize) {
   3093            dst[0] = ((Sint8) sample0);
   3094            dst[1] = ((Sint8) sample1);
   3095            dst[2] = ((Sint8) sample2);
   3096            dst[3] = ((Sint8) sample3);
   3097            dst[4] = ((Sint8) sample4);
   3098            dst[5] = ((Sint8) sample5);
   3099            dst += 6;
   3100            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   3101            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
   3102            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
   3103            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
   3104            sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
   3105            sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
   3106            last_sample0 = sample0;
   3107            last_sample1 = sample1;
   3108            last_sample2 = sample2;
   3109            last_sample3 = sample3;
   3110            last_sample4 = sample4;
   3111            last_sample5 = sample5;
   3112            eps -= srcsize;
   3113        }
   3114    }
   3115    cvt->len_cvt = dstsize;
   3116    if (cvt->filters[++cvt->filter_index]) {
   3117        cvt->filters[cvt->filter_index] (cvt, format);
   3118    }
   3119}
   3120
   3121static void SDLCALL
   3122SDL_Upsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3123{
   3124#if DEBUG_CONVERT
   3125    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 8 channels.\n", cvt->rate_incr);
   3126#endif
   3127
   3128    const int srcsize = cvt->len_cvt - 128;
   3129    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   3130    register int eps = 0;
   3131    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8;
   3132    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
   3133    const Sint8 *target = ((const Sint8 *) cvt->buf);
   3134    Sint8 sample7 = ((Sint8) src[7]);
   3135    Sint8 sample6 = ((Sint8) src[6]);
   3136    Sint8 sample5 = ((Sint8) src[5]);
   3137    Sint8 sample4 = ((Sint8) src[4]);
   3138    Sint8 sample3 = ((Sint8) src[3]);
   3139    Sint8 sample2 = ((Sint8) src[2]);
   3140    Sint8 sample1 = ((Sint8) src[1]);
   3141    Sint8 sample0 = ((Sint8) src[0]);
   3142    Sint8 last_sample7 = sample7;
   3143    Sint8 last_sample6 = sample6;
   3144    Sint8 last_sample5 = sample5;
   3145    Sint8 last_sample4 = sample4;
   3146    Sint8 last_sample3 = sample3;
   3147    Sint8 last_sample2 = sample2;
   3148    Sint8 last_sample1 = sample1;
   3149    Sint8 last_sample0 = sample0;
   3150    while (dst >= target) {
   3151        dst[7] = ((Sint8) sample7);
   3152        dst[6] = ((Sint8) sample6);
   3153        dst[5] = ((Sint8) sample5);
   3154        dst[4] = ((Sint8) sample4);
   3155        dst[3] = ((Sint8) sample3);
   3156        dst[2] = ((Sint8) sample2);
   3157        dst[1] = ((Sint8) sample1);
   3158        dst[0] = ((Sint8) sample0);
   3159        dst -= 8;
   3160        eps += srcsize;
   3161        if ((eps << 1) >= dstsize) {
   3162            src -= 8;
   3163            sample7 = (Sint8) ((((Sint16) ((Sint8) src[7])) + ((Sint16) last_sample7)) >> 1);
   3164            sample6 = (Sint8) ((((Sint16) ((Sint8) src[6])) + ((Sint16) last_sample6)) >> 1);
   3165            sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
   3166            sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
   3167            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
   3168            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
   3169            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
   3170            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   3171            last_sample7 = sample7;
   3172            last_sample6 = sample6;
   3173            last_sample5 = sample5;
   3174            last_sample4 = sample4;
   3175            last_sample3 = sample3;
   3176            last_sample2 = sample2;
   3177            last_sample1 = sample1;
   3178            last_sample0 = sample0;
   3179            eps -= dstsize;
   3180        }
   3181    }
   3182    cvt->len_cvt = dstsize;
   3183    if (cvt->filters[++cvt->filter_index]) {
   3184        cvt->filters[cvt->filter_index] (cvt, format);
   3185    }
   3186}
   3187
   3188static void SDLCALL
   3189SDL_Downsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3190{
   3191#if DEBUG_CONVERT
   3192    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 8 channels.\n", cvt->rate_incr);
   3193#endif
   3194
   3195    const int srcsize = cvt->len_cvt - 128;
   3196    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   3197    register int eps = 0;
   3198    Sint8 *dst = (Sint8 *) cvt->buf;
   3199    const Sint8 *src = (Sint8 *) cvt->buf;
   3200    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   3201    Sint8 sample0 = ((Sint8) src[0]);
   3202    Sint8 sample1 = ((Sint8) src[1]);
   3203    Sint8 sample2 = ((Sint8) src[2]);
   3204    Sint8 sample3 = ((Sint8) src[3]);
   3205    Sint8 sample4 = ((Sint8) src[4]);
   3206    Sint8 sample5 = ((Sint8) src[5]);
   3207    Sint8 sample6 = ((Sint8) src[6]);
   3208    Sint8 sample7 = ((Sint8) src[7]);
   3209    Sint8 last_sample0 = sample0;
   3210    Sint8 last_sample1 = sample1;
   3211    Sint8 last_sample2 = sample2;
   3212    Sint8 last_sample3 = sample3;
   3213    Sint8 last_sample4 = sample4;
   3214    Sint8 last_sample5 = sample5;
   3215    Sint8 last_sample6 = sample6;
   3216    Sint8 last_sample7 = sample7;
   3217    while (dst < target) {
   3218        src += 8;
   3219        eps += dstsize;
   3220        if ((eps << 1) >= srcsize) {
   3221            dst[0] = ((Sint8) sample0);
   3222            dst[1] = ((Sint8) sample1);
   3223            dst[2] = ((Sint8) sample2);
   3224            dst[3] = ((Sint8) sample3);
   3225            dst[4] = ((Sint8) sample4);
   3226            dst[5] = ((Sint8) sample5);
   3227            dst[6] = ((Sint8) sample6);
   3228            dst[7] = ((Sint8) sample7);
   3229            dst += 8;
   3230            sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
   3231            sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
   3232            sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
   3233            sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
   3234            sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
   3235            sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
   3236            sample6 = (Sint8) ((((Sint16) ((Sint8) src[6])) + ((Sint16) last_sample6)) >> 1);
   3237            sample7 = (Sint8) ((((Sint16) ((Sint8) src[7])) + ((Sint16) last_sample7)) >> 1);
   3238            last_sample0 = sample0;
   3239            last_sample1 = sample1;
   3240            last_sample2 = sample2;
   3241            last_sample3 = sample3;
   3242            last_sample4 = sample4;
   3243            last_sample5 = sample5;
   3244            last_sample6 = sample6;
   3245            last_sample7 = sample7;
   3246            eps -= srcsize;
   3247        }
   3248    }
   3249    cvt->len_cvt = dstsize;
   3250    if (cvt->filters[++cvt->filter_index]) {
   3251        cvt->filters[cvt->filter_index] (cvt, format);
   3252    }
   3253}
   3254
   3255static void SDLCALL
   3256SDL_Upsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3257{
   3258#if DEBUG_CONVERT
   3259    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 1 channels.\n", cvt->rate_incr);
   3260#endif
   3261
   3262    const int srcsize = cvt->len_cvt - 32;
   3263    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
   3264    register int eps = 0;
   3265    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
   3266    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   3267    const Uint16 *target = ((const Uint16 *) cvt->buf);
   3268    Uint16 sample0 = SDL_SwapLE16(src[0]);
   3269    Uint16 last_sample0 = sample0;
   3270    while (dst >= target) {
   3271        dst[0] = SDL_SwapLE16(sample0);
   3272        dst--;
   3273        eps += srcsize;
   3274        if ((eps << 1) >= dstsize) {
   3275            src--;
   3276            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   3277            last_sample0 = sample0;
   3278            eps -= dstsize;
   3279        }
   3280    }
   3281    cvt->len_cvt = dstsize;
   3282    if (cvt->filters[++cvt->filter_index]) {
   3283        cvt->filters[cvt->filter_index] (cvt, format);
   3284    }
   3285}
   3286
   3287static void SDLCALL
   3288SDL_Downsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3289{
   3290#if DEBUG_CONVERT
   3291    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 1 channels.\n", cvt->rate_incr);
   3292#endif
   3293
   3294    const int srcsize = cvt->len_cvt - 32;
   3295    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
   3296    register int eps = 0;
   3297    Uint16 *dst = (Uint16 *) cvt->buf;
   3298    const Uint16 *src = (Uint16 *) cvt->buf;
   3299    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   3300    Uint16 sample0 = SDL_SwapLE16(src[0]);
   3301    Uint16 last_sample0 = sample0;
   3302    while (dst < target) {
   3303        src++;
   3304        eps += dstsize;
   3305        if ((eps << 1) >= srcsize) {
   3306            dst[0] = SDL_SwapLE16(sample0);
   3307            dst++;
   3308            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   3309            last_sample0 = sample0;
   3310            eps -= srcsize;
   3311        }
   3312    }
   3313    cvt->len_cvt = dstsize;
   3314    if (cvt->filters[++cvt->filter_index]) {
   3315        cvt->filters[cvt->filter_index] (cvt, format);
   3316    }
   3317}
   3318
   3319static void SDLCALL
   3320SDL_Upsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3321{
   3322#if DEBUG_CONVERT
   3323    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 2 channels.\n", cvt->rate_incr);
   3324#endif
   3325
   3326    const int srcsize = cvt->len_cvt - 64;
   3327    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   3328    register int eps = 0;
   3329    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
   3330    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
   3331    const Uint16 *target = ((const Uint16 *) cvt->buf);
   3332    Uint16 sample1 = SDL_SwapLE16(src[1]);
   3333    Uint16 sample0 = SDL_SwapLE16(src[0]);
   3334    Uint16 last_sample1 = sample1;
   3335    Uint16 last_sample0 = sample0;
   3336    while (dst >= target) {
   3337        dst[1] = SDL_SwapLE16(sample1);
   3338        dst[0] = SDL_SwapLE16(sample0);
   3339        dst -= 2;
   3340        eps += srcsize;
   3341        if ((eps << 1) >= dstsize) {
   3342            src -= 2;
   3343            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   3344            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   3345            last_sample1 = sample1;
   3346            last_sample0 = sample0;
   3347            eps -= dstsize;
   3348        }
   3349    }
   3350    cvt->len_cvt = dstsize;
   3351    if (cvt->filters[++cvt->filter_index]) {
   3352        cvt->filters[cvt->filter_index] (cvt, format);
   3353    }
   3354}
   3355
   3356static void SDLCALL
   3357SDL_Downsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3358{
   3359#if DEBUG_CONVERT
   3360    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 2 channels.\n", cvt->rate_incr);
   3361#endif
   3362
   3363    const int srcsize = cvt->len_cvt - 64;
   3364    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   3365    register int eps = 0;
   3366    Uint16 *dst = (Uint16 *) cvt->buf;
   3367    const Uint16 *src = (Uint16 *) cvt->buf;
   3368    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   3369    Uint16 sample0 = SDL_SwapLE16(src[0]);
   3370    Uint16 sample1 = SDL_SwapLE16(src[1]);
   3371    Uint16 last_sample0 = sample0;
   3372    Uint16 last_sample1 = sample1;
   3373    while (dst < target) {
   3374        src += 2;
   3375        eps += dstsize;
   3376        if ((eps << 1) >= srcsize) {
   3377            dst[0] = SDL_SwapLE16(sample0);
   3378            dst[1] = SDL_SwapLE16(sample1);
   3379            dst += 2;
   3380            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   3381            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   3382            last_sample0 = sample0;
   3383            last_sample1 = sample1;
   3384            eps -= srcsize;
   3385        }
   3386    }
   3387    cvt->len_cvt = dstsize;
   3388    if (cvt->filters[++cvt->filter_index]) {
   3389        cvt->filters[cvt->filter_index] (cvt, format);
   3390    }
   3391}
   3392
   3393static void SDLCALL
   3394SDL_Upsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3395{
   3396#if DEBUG_CONVERT
   3397    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 4 channels.\n", cvt->rate_incr);
   3398#endif
   3399
   3400    const int srcsize = cvt->len_cvt - 128;
   3401    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   3402    register int eps = 0;
   3403    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
   3404    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
   3405    const Uint16 *target = ((const Uint16 *) cvt->buf);
   3406    Uint16 sample3 = SDL_SwapLE16(src[3]);
   3407    Uint16 sample2 = SDL_SwapLE16(src[2]);
   3408    Uint16 sample1 = SDL_SwapLE16(src[1]);
   3409    Uint16 sample0 = SDL_SwapLE16(src[0]);
   3410    Uint16 last_sample3 = sample3;
   3411    Uint16 last_sample2 = sample2;
   3412    Uint16 last_sample1 = sample1;
   3413    Uint16 last_sample0 = sample0;
   3414    while (dst >= target) {
   3415        dst[3] = SDL_SwapLE16(sample3);
   3416        dst[2] = SDL_SwapLE16(sample2);
   3417        dst[1] = SDL_SwapLE16(sample1);
   3418        dst[0] = SDL_SwapLE16(sample0);
   3419        dst -= 4;
   3420        eps += srcsize;
   3421        if ((eps << 1) >= dstsize) {
   3422            src -= 4;
   3423            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
   3424            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
   3425            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   3426            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   3427            last_sample3 = sample3;
   3428            last_sample2 = sample2;
   3429            last_sample1 = sample1;
   3430            last_sample0 = sample0;
   3431            eps -= dstsize;
   3432        }
   3433    }
   3434    cvt->len_cvt = dstsize;
   3435    if (cvt->filters[++cvt->filter_index]) {
   3436        cvt->filters[cvt->filter_index] (cvt, format);
   3437    }
   3438}
   3439
   3440static void SDLCALL
   3441SDL_Downsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3442{
   3443#if DEBUG_CONVERT
   3444    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 4 channels.\n", cvt->rate_incr);
   3445#endif
   3446
   3447    const int srcsize = cvt->len_cvt - 128;
   3448    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   3449    register int eps = 0;
   3450    Uint16 *dst = (Uint16 *) cvt->buf;
   3451    const Uint16 *src = (Uint16 *) cvt->buf;
   3452    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   3453    Uint16 sample0 = SDL_SwapLE16(src[0]);
   3454    Uint16 sample1 = SDL_SwapLE16(src[1]);
   3455    Uint16 sample2 = SDL_SwapLE16(src[2]);
   3456    Uint16 sample3 = SDL_SwapLE16(src[3]);
   3457    Uint16 last_sample0 = sample0;
   3458    Uint16 last_sample1 = sample1;
   3459    Uint16 last_sample2 = sample2;
   3460    Uint16 last_sample3 = sample3;
   3461    while (dst < target) {
   3462        src += 4;
   3463        eps += dstsize;
   3464        if ((eps << 1) >= srcsize) {
   3465            dst[0] = SDL_SwapLE16(sample0);
   3466            dst[1] = SDL_SwapLE16(sample1);
   3467            dst[2] = SDL_SwapLE16(sample2);
   3468            dst[3] = SDL_SwapLE16(sample3);
   3469            dst += 4;
   3470            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   3471            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   3472            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
   3473            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
   3474            last_sample0 = sample0;
   3475            last_sample1 = sample1;
   3476            last_sample2 = sample2;
   3477            last_sample3 = sample3;
   3478            eps -= srcsize;
   3479        }
   3480    }
   3481    cvt->len_cvt = dstsize;
   3482    if (cvt->filters[++cvt->filter_index]) {
   3483        cvt->filters[cvt->filter_index] (cvt, format);
   3484    }
   3485}
   3486
   3487static void SDLCALL
   3488SDL_Upsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3489{
   3490#if DEBUG_CONVERT
   3491    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 6 channels.\n", cvt->rate_incr);
   3492#endif
   3493
   3494    const int srcsize = cvt->len_cvt - 192;
   3495    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
   3496    register int eps = 0;
   3497    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
   3498    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
   3499    const Uint16 *target = ((const Uint16 *) cvt->buf);
   3500    Uint16 sample5 = SDL_SwapLE16(src[5]);
   3501    Uint16 sample4 = SDL_SwapLE16(src[4]);
   3502    Uint16 sample3 = SDL_SwapLE16(src[3]);
   3503    Uint16 sample2 = SDL_SwapLE16(src[2]);
   3504    Uint16 sample1 = SDL_SwapLE16(src[1]);
   3505    Uint16 sample0 = SDL_SwapLE16(src[0]);
   3506    Uint16 last_sample5 = sample5;
   3507    Uint16 last_sample4 = sample4;
   3508    Uint16 last_sample3 = sample3;
   3509    Uint16 last_sample2 = sample2;
   3510    Uint16 last_sample1 = sample1;
   3511    Uint16 last_sample0 = sample0;
   3512    while (dst >= target) {
   3513        dst[5] = SDL_SwapLE16(sample5);
   3514        dst[4] = SDL_SwapLE16(sample4);
   3515        dst[3] = SDL_SwapLE16(sample3);
   3516        dst[2] = SDL_SwapLE16(sample2);
   3517        dst[1] = SDL_SwapLE16(sample1);
   3518        dst[0] = SDL_SwapLE16(sample0);
   3519        dst -= 6;
   3520        eps += srcsize;
   3521        if ((eps << 1) >= dstsize) {
   3522            src -= 6;
   3523            sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
   3524            sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
   3525            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
   3526            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
   3527            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   3528            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   3529            last_sample5 = sample5;
   3530            last_sample4 = sample4;
   3531            last_sample3 = sample3;
   3532            last_sample2 = sample2;
   3533            last_sample1 = sample1;
   3534            last_sample0 = sample0;
   3535            eps -= dstsize;
   3536        }
   3537    }
   3538    cvt->len_cvt = dstsize;
   3539    if (cvt->filters[++cvt->filter_index]) {
   3540        cvt->filters[cvt->filter_index] (cvt, format);
   3541    }
   3542}
   3543
   3544static void SDLCALL
   3545SDL_Downsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3546{
   3547#if DEBUG_CONVERT
   3548    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 6 channels.\n", cvt->rate_incr);
   3549#endif
   3550
   3551    const int srcsize = cvt->len_cvt - 192;
   3552    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
   3553    register int eps = 0;
   3554    Uint16 *dst = (Uint16 *) cvt->buf;
   3555    const Uint16 *src = (Uint16 *) cvt->buf;
   3556    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   3557    Uint16 sample0 = SDL_SwapLE16(src[0]);
   3558    Uint16 sample1 = SDL_SwapLE16(src[1]);
   3559    Uint16 sample2 = SDL_SwapLE16(src[2]);
   3560    Uint16 sample3 = SDL_SwapLE16(src[3]);
   3561    Uint16 sample4 = SDL_SwapLE16(src[4]);
   3562    Uint16 sample5 = SDL_SwapLE16(src[5]);
   3563    Uint16 last_sample0 = sample0;
   3564    Uint16 last_sample1 = sample1;
   3565    Uint16 last_sample2 = sample2;
   3566    Uint16 last_sample3 = sample3;
   3567    Uint16 last_sample4 = sample4;
   3568    Uint16 last_sample5 = sample5;
   3569    while (dst < target) {
   3570        src += 6;
   3571        eps += dstsize;
   3572        if ((eps << 1) >= srcsize) {
   3573            dst[0] = SDL_SwapLE16(sample0);
   3574            dst[1] = SDL_SwapLE16(sample1);
   3575            dst[2] = SDL_SwapLE16(sample2);
   3576            dst[3] = SDL_SwapLE16(sample3);
   3577            dst[4] = SDL_SwapLE16(sample4);
   3578            dst[5] = SDL_SwapLE16(sample5);
   3579            dst += 6;
   3580            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   3581            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   3582            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
   3583            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
   3584            sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
   3585            sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
   3586            last_sample0 = sample0;
   3587            last_sample1 = sample1;
   3588            last_sample2 = sample2;
   3589            last_sample3 = sample3;
   3590            last_sample4 = sample4;
   3591            last_sample5 = sample5;
   3592            eps -= srcsize;
   3593        }
   3594    }
   3595    cvt->len_cvt = dstsize;
   3596    if (cvt->filters[++cvt->filter_index]) {
   3597        cvt->filters[cvt->filter_index] (cvt, format);
   3598    }
   3599}
   3600
   3601static void SDLCALL
   3602SDL_Upsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3603{
   3604#if DEBUG_CONVERT
   3605    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 8 channels.\n", cvt->rate_incr);
   3606#endif
   3607
   3608    const int srcsize = cvt->len_cvt - 256;
   3609    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   3610    register int eps = 0;
   3611    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
   3612    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
   3613    const Uint16 *target = ((const Uint16 *) cvt->buf);
   3614    Uint16 sample7 = SDL_SwapLE16(src[7]);
   3615    Uint16 sample6 = SDL_SwapLE16(src[6]);
   3616    Uint16 sample5 = SDL_SwapLE16(src[5]);
   3617    Uint16 sample4 = SDL_SwapLE16(src[4]);
   3618    Uint16 sample3 = SDL_SwapLE16(src[3]);
   3619    Uint16 sample2 = SDL_SwapLE16(src[2]);
   3620    Uint16 sample1 = SDL_SwapLE16(src[1]);
   3621    Uint16 sample0 = SDL_SwapLE16(src[0]);
   3622    Uint16 last_sample7 = sample7;
   3623    Uint16 last_sample6 = sample6;
   3624    Uint16 last_sample5 = sample5;
   3625    Uint16 last_sample4 = sample4;
   3626    Uint16 last_sample3 = sample3;
   3627    Uint16 last_sample2 = sample2;
   3628    Uint16 last_sample1 = sample1;
   3629    Uint16 last_sample0 = sample0;
   3630    while (dst >= target) {
   3631        dst[7] = SDL_SwapLE16(sample7);
   3632        dst[6] = SDL_SwapLE16(sample6);
   3633        dst[5] = SDL_SwapLE16(sample5);
   3634        dst[4] = SDL_SwapLE16(sample4);
   3635        dst[3] = SDL_SwapLE16(sample3);
   3636        dst[2] = SDL_SwapLE16(sample2);
   3637        dst[1] = SDL_SwapLE16(sample1);
   3638        dst[0] = SDL_SwapLE16(sample0);
   3639        dst -= 8;
   3640        eps += srcsize;
   3641        if ((eps << 1) >= dstsize) {
   3642            src -= 8;
   3643            sample7 = (Uint16) ((((Sint32) SDL_SwapLE16(src[7])) + ((Sint32) last_sample7)) >> 1);
   3644            sample6 = (Uint16) ((((Sint32) SDL_SwapLE16(src[6])) + ((Sint32) last_sample6)) >> 1);
   3645            sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
   3646            sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
   3647            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
   3648            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
   3649            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   3650            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   3651            last_sample7 = sample7;
   3652            last_sample6 = sample6;
   3653            last_sample5 = sample5;
   3654            last_sample4 = sample4;
   3655            last_sample3 = sample3;
   3656            last_sample2 = sample2;
   3657            last_sample1 = sample1;
   3658            last_sample0 = sample0;
   3659            eps -= dstsize;
   3660        }
   3661    }
   3662    cvt->len_cvt = dstsize;
   3663    if (cvt->filters[++cvt->filter_index]) {
   3664        cvt->filters[cvt->filter_index] (cvt, format);
   3665    }
   3666}
   3667
   3668static void SDLCALL
   3669SDL_Downsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3670{
   3671#if DEBUG_CONVERT
   3672    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 8 channels.\n", cvt->rate_incr);
   3673#endif
   3674
   3675    const int srcsize = cvt->len_cvt - 256;
   3676    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   3677    register int eps = 0;
   3678    Uint16 *dst = (Uint16 *) cvt->buf;
   3679    const Uint16 *src = (Uint16 *) cvt->buf;
   3680    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   3681    Uint16 sample0 = SDL_SwapLE16(src[0]);
   3682    Uint16 sample1 = SDL_SwapLE16(src[1]);
   3683    Uint16 sample2 = SDL_SwapLE16(src[2]);
   3684    Uint16 sample3 = SDL_SwapLE16(src[3]);
   3685    Uint16 sample4 = SDL_SwapLE16(src[4]);
   3686    Uint16 sample5 = SDL_SwapLE16(src[5]);
   3687    Uint16 sample6 = SDL_SwapLE16(src[6]);
   3688    Uint16 sample7 = SDL_SwapLE16(src[7]);
   3689    Uint16 last_sample0 = sample0;
   3690    Uint16 last_sample1 = sample1;
   3691    Uint16 last_sample2 = sample2;
   3692    Uint16 last_sample3 = sample3;
   3693    Uint16 last_sample4 = sample4;
   3694    Uint16 last_sample5 = sample5;
   3695    Uint16 last_sample6 = sample6;
   3696    Uint16 last_sample7 = sample7;
   3697    while (dst < target) {
   3698        src += 8;
   3699        eps += dstsize;
   3700        if ((eps << 1) >= srcsize) {
   3701            dst[0] = SDL_SwapLE16(sample0);
   3702            dst[1] = SDL_SwapLE16(sample1);
   3703            dst[2] = SDL_SwapLE16(sample2);
   3704            dst[3] = SDL_SwapLE16(sample3);
   3705            dst[4] = SDL_SwapLE16(sample4);
   3706            dst[5] = SDL_SwapLE16(sample5);
   3707            dst[6] = SDL_SwapLE16(sample6);
   3708            dst[7] = SDL_SwapLE16(sample7);
   3709            dst += 8;
   3710            sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   3711            sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   3712            sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
   3713            sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
   3714            sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
   3715            sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
   3716            sample6 = (Uint16) ((((Sint32) SDL_SwapLE16(src[6])) + ((Sint32) last_sample6)) >> 1);
   3717            sample7 = (Uint16) ((((Sint32) SDL_SwapLE16(src[7])) + ((Sint32) last_sample7)) >> 1);
   3718            last_sample0 = sample0;
   3719            last_sample1 = sample1;
   3720            last_sample2 = sample2;
   3721            last_sample3 = sample3;
   3722            last_sample4 = sample4;
   3723            last_sample5 = sample5;
   3724            last_sample6 = sample6;
   3725            last_sample7 = sample7;
   3726            eps -= srcsize;
   3727        }
   3728    }
   3729    cvt->len_cvt = dstsize;
   3730    if (cvt->filters[++cvt->filter_index]) {
   3731        cvt->filters[cvt->filter_index] (cvt, format);
   3732    }
   3733}
   3734
   3735static void SDLCALL
   3736SDL_Upsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3737{
   3738#if DEBUG_CONVERT
   3739    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 1 channels.\n", cvt->rate_incr);
   3740#endif
   3741
   3742    const int srcsize = cvt->len_cvt - 32;
   3743    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
   3744    register int eps = 0;
   3745    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
   3746    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   3747    const Sint16 *target = ((const Sint16 *) cvt->buf);
   3748    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
   3749    Sint16 last_sample0 = sample0;
   3750    while (dst >= target) {
   3751        dst[0] = ((Sint16) SDL_SwapLE16(sample0));
   3752        dst--;
   3753        eps += srcsize;
   3754        if ((eps << 1) >= dstsize) {
   3755            src--;
   3756            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   3757            last_sample0 = sample0;
   3758            eps -= dstsize;
   3759        }
   3760    }
   3761    cvt->len_cvt = dstsize;
   3762    if (cvt->filters[++cvt->filter_index]) {
   3763        cvt->filters[cvt->filter_index] (cvt, format);
   3764    }
   3765}
   3766
   3767static void SDLCALL
   3768SDL_Downsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3769{
   3770#if DEBUG_CONVERT
   3771    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 1 channels.\n", cvt->rate_incr);
   3772#endif
   3773
   3774    const int srcsize = cvt->len_cvt - 32;
   3775    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
   3776    register int eps = 0;
   3777    Sint16 *dst = (Sint16 *) cvt->buf;
   3778    const Sint16 *src = (Sint16 *) cvt->buf;
   3779    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   3780    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
   3781    Sint16 last_sample0 = sample0;
   3782    while (dst < target) {
   3783        src++;
   3784        eps += dstsize;
   3785        if ((eps << 1) >= srcsize) {
   3786            dst[0] = ((Sint16) SDL_SwapLE16(sample0));
   3787            dst++;
   3788            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   3789            last_sample0 = sample0;
   3790            eps -= srcsize;
   3791        }
   3792    }
   3793    cvt->len_cvt = dstsize;
   3794    if (cvt->filters[++cvt->filter_index]) {
   3795        cvt->filters[cvt->filter_index] (cvt, format);
   3796    }
   3797}
   3798
   3799static void SDLCALL
   3800SDL_Upsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3801{
   3802#if DEBUG_CONVERT
   3803    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 2 channels.\n", cvt->rate_incr);
   3804#endif
   3805
   3806    const int srcsize = cvt->len_cvt - 64;
   3807    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   3808    register int eps = 0;
   3809    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
   3810    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
   3811    const Sint16 *target = ((const Sint16 *) cvt->buf);
   3812    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
   3813    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
   3814    Sint16 last_sample1 = sample1;
   3815    Sint16 last_sample0 = sample0;
   3816    while (dst >= target) {
   3817        dst[1] = ((Sint16) SDL_SwapLE16(sample1));
   3818        dst[0] = ((Sint16) SDL_SwapLE16(sample0));
   3819        dst -= 2;
   3820        eps += srcsize;
   3821        if ((eps << 1) >= dstsize) {
   3822            src -= 2;
   3823            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   3824            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   3825            last_sample1 = sample1;
   3826            last_sample0 = sample0;
   3827            eps -= dstsize;
   3828        }
   3829    }
   3830    cvt->len_cvt = dstsize;
   3831    if (cvt->filters[++cvt->filter_index]) {
   3832        cvt->filters[cvt->filter_index] (cvt, format);
   3833    }
   3834}
   3835
   3836static void SDLCALL
   3837SDL_Downsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3838{
   3839#if DEBUG_CONVERT
   3840    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 2 channels.\n", cvt->rate_incr);
   3841#endif
   3842
   3843    const int srcsize = cvt->len_cvt - 64;
   3844    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   3845    register int eps = 0;
   3846    Sint16 *dst = (Sint16 *) cvt->buf;
   3847    const Sint16 *src = (Sint16 *) cvt->buf;
   3848    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   3849    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
   3850    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
   3851    Sint16 last_sample0 = sample0;
   3852    Sint16 last_sample1 = sample1;
   3853    while (dst < target) {
   3854        src += 2;
   3855        eps += dstsize;
   3856        if ((eps << 1) >= srcsize) {
   3857            dst[0] = ((Sint16) SDL_SwapLE16(sample0));
   3858            dst[1] = ((Sint16) SDL_SwapLE16(sample1));
   3859            dst += 2;
   3860            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   3861            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   3862            last_sample0 = sample0;
   3863            last_sample1 = sample1;
   3864            eps -= srcsize;
   3865        }
   3866    }
   3867    cvt->len_cvt = dstsize;
   3868    if (cvt->filters[++cvt->filter_index]) {
   3869        cvt->filters[cvt->filter_index] (cvt, format);
   3870    }
   3871}
   3872
   3873static void SDLCALL
   3874SDL_Upsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3875{
   3876#if DEBUG_CONVERT
   3877    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 4 channels.\n", cvt->rate_incr);
   3878#endif
   3879
   3880    const int srcsize = cvt->len_cvt - 128;
   3881    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   3882    register int eps = 0;
   3883    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
   3884    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
   3885    const Sint16 *target = ((const Sint16 *) cvt->buf);
   3886    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
   3887    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
   3888    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
   3889    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
   3890    Sint16 last_sample3 = sample3;
   3891    Sint16 last_sample2 = sample2;
   3892    Sint16 last_sample1 = sample1;
   3893    Sint16 last_sample0 = sample0;
   3894    while (dst >= target) {
   3895        dst[3] = ((Sint16) SDL_SwapLE16(sample3));
   3896        dst[2] = ((Sint16) SDL_SwapLE16(sample2));
   3897        dst[1] = ((Sint16) SDL_SwapLE16(sample1));
   3898        dst[0] = ((Sint16) SDL_SwapLE16(sample0));
   3899        dst -= 4;
   3900        eps += srcsize;
   3901        if ((eps << 1) >= dstsize) {
   3902            src -= 4;
   3903            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
   3904            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
   3905            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   3906            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   3907            last_sample3 = sample3;
   3908            last_sample2 = sample2;
   3909            last_sample1 = sample1;
   3910            last_sample0 = sample0;
   3911            eps -= dstsize;
   3912        }
   3913    }
   3914    cvt->len_cvt = dstsize;
   3915    if (cvt->filters[++cvt->filter_index]) {
   3916        cvt->filters[cvt->filter_index] (cvt, format);
   3917    }
   3918}
   3919
   3920static void SDLCALL
   3921SDL_Downsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3922{
   3923#if DEBUG_CONVERT
   3924    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 4 channels.\n", cvt->rate_incr);
   3925#endif
   3926
   3927    const int srcsize = cvt->len_cvt - 128;
   3928    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   3929    register int eps = 0;
   3930    Sint16 *dst = (Sint16 *) cvt->buf;
   3931    const Sint16 *src = (Sint16 *) cvt->buf;
   3932    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   3933    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
   3934    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
   3935    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
   3936    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
   3937    Sint16 last_sample0 = sample0;
   3938    Sint16 last_sample1 = sample1;
   3939    Sint16 last_sample2 = sample2;
   3940    Sint16 last_sample3 = sample3;
   3941    while (dst < target) {
   3942        src += 4;
   3943        eps += dstsize;
   3944        if ((eps << 1) >= srcsize) {
   3945            dst[0] = ((Sint16) SDL_SwapLE16(sample0));
   3946            dst[1] = ((Sint16) SDL_SwapLE16(sample1));
   3947            dst[2] = ((Sint16) SDL_SwapLE16(sample2));
   3948            dst[3] = ((Sint16) SDL_SwapLE16(sample3));
   3949            dst += 4;
   3950            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   3951            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   3952            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
   3953            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
   3954            last_sample0 = sample0;
   3955            last_sample1 = sample1;
   3956            last_sample2 = sample2;
   3957            last_sample3 = sample3;
   3958            eps -= srcsize;
   3959        }
   3960    }
   3961    cvt->len_cvt = dstsize;
   3962    if (cvt->filters[++cvt->filter_index]) {
   3963        cvt->filters[cvt->filter_index] (cvt, format);
   3964    }
   3965}
   3966
   3967static void SDLCALL
   3968SDL_Upsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3969{
   3970#if DEBUG_CONVERT
   3971    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 6 channels.\n", cvt->rate_incr);
   3972#endif
   3973
   3974    const int srcsize = cvt->len_cvt - 192;
   3975    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
   3976    register int eps = 0;
   3977    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
   3978    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
   3979    const Sint16 *target = ((const Sint16 *) cvt->buf);
   3980    Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
   3981    Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
   3982    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
   3983    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
   3984    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
   3985    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
   3986    Sint16 last_sample5 = sample5;
   3987    Sint16 last_sample4 = sample4;
   3988    Sint16 last_sample3 = sample3;
   3989    Sint16 last_sample2 = sample2;
   3990    Sint16 last_sample1 = sample1;
   3991    Sint16 last_sample0 = sample0;
   3992    while (dst >= target) {
   3993        dst[5] = ((Sint16) SDL_SwapLE16(sample5));
   3994        dst[4] = ((Sint16) SDL_SwapLE16(sample4));
   3995        dst[3] = ((Sint16) SDL_SwapLE16(sample3));
   3996        dst[2] = ((Sint16) SDL_SwapLE16(sample2));
   3997        dst[1] = ((Sint16) SDL_SwapLE16(sample1));
   3998        dst[0] = ((Sint16) SDL_SwapLE16(sample0));
   3999        dst -= 6;
   4000        eps += srcsize;
   4001        if ((eps << 1) >= dstsize) {
   4002            src -= 6;
   4003            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
   4004            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
   4005            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
   4006            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
   4007            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   4008            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   4009            last_sample5 = sample5;
   4010            last_sample4 = sample4;
   4011            last_sample3 = sample3;
   4012            last_sample2 = sample2;
   4013            last_sample1 = sample1;
   4014            last_sample0 = sample0;
   4015            eps -= dstsize;
   4016        }
   4017    }
   4018    cvt->len_cvt = dstsize;
   4019    if (cvt->filters[++cvt->filter_index]) {
   4020        cvt->filters[cvt->filter_index] (cvt, format);
   4021    }
   4022}
   4023
   4024static void SDLCALL
   4025SDL_Downsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4026{
   4027#if DEBUG_CONVERT
   4028    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 6 channels.\n", cvt->rate_incr);
   4029#endif
   4030
   4031    const int srcsize = cvt->len_cvt - 192;
   4032    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
   4033    register int eps = 0;
   4034    Sint16 *dst = (Sint16 *) cvt->buf;
   4035    const Sint16 *src = (Sint16 *) cvt->buf;
   4036    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   4037    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
   4038    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
   4039    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
   4040    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
   4041    Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
   4042    Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
   4043    Sint16 last_sample0 = sample0;
   4044    Sint16 last_sample1 = sample1;
   4045    Sint16 last_sample2 = sample2;
   4046    Sint16 last_sample3 = sample3;
   4047    Sint16 last_sample4 = sample4;
   4048    Sint16 last_sample5 = sample5;
   4049    while (dst < target) {
   4050        src += 6;
   4051        eps += dstsize;
   4052        if ((eps << 1) >= srcsize) {
   4053            dst[0] = ((Sint16) SDL_SwapLE16(sample0));
   4054            dst[1] = ((Sint16) SDL_SwapLE16(sample1));
   4055            dst[2] = ((Sint16) SDL_SwapLE16(sample2));
   4056            dst[3] = ((Sint16) SDL_SwapLE16(sample3));
   4057            dst[4] = ((Sint16) SDL_SwapLE16(sample4));
   4058            dst[5] = ((Sint16) SDL_SwapLE16(sample5));
   4059            dst += 6;
   4060            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   4061            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   4062            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
   4063            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
   4064            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
   4065            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
   4066            last_sample0 = sample0;
   4067            last_sample1 = sample1;
   4068            last_sample2 = sample2;
   4069            last_sample3 = sample3;
   4070            last_sample4 = sample4;
   4071            last_sample5 = sample5;
   4072            eps -= srcsize;
   4073        }
   4074    }
   4075    cvt->len_cvt = dstsize;
   4076    if (cvt->filters[++cvt->filter_index]) {
   4077        cvt->filters[cvt->filter_index] (cvt, format);
   4078    }
   4079}
   4080
   4081static void SDLCALL
   4082SDL_Upsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4083{
   4084#if DEBUG_CONVERT
   4085    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 8 channels.\n", cvt->rate_incr);
   4086#endif
   4087
   4088    const int srcsize = cvt->len_cvt - 256;
   4089    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   4090    register int eps = 0;
   4091    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
   4092    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
   4093    const Sint16 *target = ((const Sint16 *) cvt->buf);
   4094    Sint16 sample7 = ((Sint16) SDL_SwapLE16(src[7]));
   4095    Sint16 sample6 = ((Sint16) SDL_SwapLE16(src[6]));
   4096    Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
   4097    Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
   4098    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
   4099    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
   4100    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
   4101    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
   4102    Sint16 last_sample7 = sample7;
   4103    Sint16 last_sample6 = sample6;
   4104    Sint16 last_sample5 = sample5;
   4105    Sint16 last_sample4 = sample4;
   4106    Sint16 last_sample3 = sample3;
   4107    Sint16 last_sample2 = sample2;
   4108    Sint16 last_sample1 = sample1;
   4109    Sint16 last_sample0 = sample0;
   4110    while (dst >= target) {
   4111        dst[7] = ((Sint16) SDL_SwapLE16(sample7));
   4112        dst[6] = ((Sint16) SDL_SwapLE16(sample6));
   4113        dst[5] = ((Sint16) SDL_SwapLE16(sample5));
   4114        dst[4] = ((Sint16) SDL_SwapLE16(sample4));
   4115        dst[3] = ((Sint16) SDL_SwapLE16(sample3));
   4116        dst[2] = ((Sint16) SDL_SwapLE16(sample2));
   4117        dst[1] = ((Sint16) SDL_SwapLE16(sample1));
   4118        dst[0] = ((Sint16) SDL_SwapLE16(sample0));
   4119        dst -= 8;
   4120        eps += srcsize;
   4121        if ((eps << 1) >= dstsize) {
   4122            src -= 8;
   4123            sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
   4124            sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
   4125            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
   4126            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
   4127            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
   4128            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
   4129            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   4130            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   4131            last_sample7 = sample7;
   4132            last_sample6 = sample6;
   4133            last_sample5 = sample5;
   4134            last_sample4 = sample4;
   4135            last_sample3 = sample3;
   4136            last_sample2 = sample2;
   4137            last_sample1 = sample1;
   4138            last_sample0 = sample0;
   4139            eps -= dstsize;
   4140        }
   4141    }
   4142    cvt->len_cvt = dstsize;
   4143    if (cvt->filters[++cvt->filter_index]) {
   4144        cvt->filters[cvt->filter_index] (cvt, format);
   4145    }
   4146}
   4147
   4148static void SDLCALL
   4149SDL_Downsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4150{
   4151#if DEBUG_CONVERT
   4152    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 8 channels.\n", cvt->rate_incr);
   4153#endif
   4154
   4155    const int srcsize = cvt->len_cvt - 256;
   4156    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   4157    register int eps = 0;
   4158    Sint16 *dst = (Sint16 *) cvt->buf;
   4159    const Sint16 *src = (Sint16 *) cvt->buf;
   4160    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   4161    Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
   4162    Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
   4163    Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
   4164    Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
   4165    Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
   4166    Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
   4167    Sint16 sample6 = ((Sint16) SDL_SwapLE16(src[6]));
   4168    Sint16 sample7 = ((Sint16) SDL_SwapLE16(src[7]));
   4169    Sint16 last_sample0 = sample0;
   4170    Sint16 last_sample1 = sample1;
   4171    Sint16 last_sample2 = sample2;
   4172    Sint16 last_sample3 = sample3;
   4173    Sint16 last_sample4 = sample4;
   4174    Sint16 last_sample5 = sample5;
   4175    Sint16 last_sample6 = sample6;
   4176    Sint16 last_sample7 = sample7;
   4177    while (dst < target) {
   4178        src += 8;
   4179        eps += dstsize;
   4180        if ((eps << 1) >= srcsize) {
   4181            dst[0] = ((Sint16) SDL_SwapLE16(sample0));
   4182            dst[1] = ((Sint16) SDL_SwapLE16(sample1));
   4183            dst[2] = ((Sint16) SDL_SwapLE16(sample2));
   4184            dst[3] = ((Sint16) SDL_SwapLE16(sample3));
   4185            dst[4] = ((Sint16) SDL_SwapLE16(sample4));
   4186            dst[5] = ((Sint16) SDL_SwapLE16(sample5));
   4187            dst[6] = ((Sint16) SDL_SwapLE16(sample6));
   4188            dst[7] = ((Sint16) SDL_SwapLE16(sample7));
   4189            dst += 8;
   4190            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   4191            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   4192            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
   4193            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
   4194            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
   4195            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
   4196            sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
   4197            sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
   4198            last_sample0 = sample0;
   4199            last_sample1 = sample1;
   4200            last_sample2 = sample2;
   4201            last_sample3 = sample3;
   4202            last_sample4 = sample4;
   4203            last_sample5 = sample5;
   4204            last_sample6 = sample6;
   4205            last_sample7 = sample7;
   4206            eps -= srcsize;
   4207        }
   4208    }
   4209    cvt->len_cvt = dstsize;
   4210    if (cvt->filters[++cvt->filter_index]) {
   4211        cvt->filters[cvt->filter_index] (cvt, format);
   4212    }
   4213}
   4214
   4215static void SDLCALL
   4216SDL_Upsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4217{
   4218#if DEBUG_CONVERT
   4219    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 1 channels.\n", cvt->rate_incr);
   4220#endif
   4221
   4222    const int srcsize = cvt->len_cvt - 32;
   4223    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
   4224    register int eps = 0;
   4225    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
   4226    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   4227    const Uint16 *target = ((const Uint16 *) cvt->buf);
   4228    Uint16 sample0 = SDL_SwapBE16(src[0]);
   4229    Uint16 last_sample0 = sample0;
   4230    while (dst >= target) {
   4231        dst[0] = SDL_SwapBE16(sample0);
   4232        dst--;
   4233        eps += srcsize;
   4234        if ((eps << 1) >= dstsize) {
   4235            src--;
   4236            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   4237            last_sample0 = sample0;
   4238            eps -= dstsize;
   4239        }
   4240    }
   4241    cvt->len_cvt = dstsize;
   4242    if (cvt->filters[++cvt->filter_index]) {
   4243        cvt->filters[cvt->filter_index] (cvt, format);
   4244    }
   4245}
   4246
   4247static void SDLCALL
   4248SDL_Downsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4249{
   4250#if DEBUG_CONVERT
   4251    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 1 channels.\n", cvt->rate_incr);
   4252#endif
   4253
   4254    const int srcsize = cvt->len_cvt - 32;
   4255    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
   4256    register int eps = 0;
   4257    Uint16 *dst = (Uint16 *) cvt->buf;
   4258    const Uint16 *src = (Uint16 *) cvt->buf;
   4259    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   4260    Uint16 sample0 = SDL_SwapBE16(src[0]);
   4261    Uint16 last_sample0 = sample0;
   4262    while (dst < target) {
   4263        src++;
   4264        eps += dstsize;
   4265        if ((eps << 1) >= srcsize) {
   4266            dst[0] = SDL_SwapBE16(sample0);
   4267            dst++;
   4268            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   4269            last_sample0 = sample0;
   4270            eps -= srcsize;
   4271        }
   4272    }
   4273    cvt->len_cvt = dstsize;
   4274    if (cvt->filters[++cvt->filter_index]) {
   4275        cvt->filters[cvt->filter_index] (cvt, format);
   4276    }
   4277}
   4278
   4279static void SDLCALL
   4280SDL_Upsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4281{
   4282#if DEBUG_CONVERT
   4283    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 2 channels.\n", cvt->rate_incr);
   4284#endif
   4285
   4286    const int srcsize = cvt->len_cvt - 64;
   4287    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   4288    register int eps = 0;
   4289    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
   4290    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
   4291    const Uint16 *target = ((const Uint16 *) cvt->buf);
   4292    Uint16 sample1 = SDL_SwapBE16(src[1]);
   4293    Uint16 sample0 = SDL_SwapBE16(src[0]);
   4294    Uint16 last_sample1 = sample1;
   4295    Uint16 last_sample0 = sample0;
   4296    while (dst >= target) {
   4297        dst[1] = SDL_SwapBE16(sample1);
   4298        dst[0] = SDL_SwapBE16(sample0);
   4299        dst -= 2;
   4300        eps += srcsize;
   4301        if ((eps << 1) >= dstsize) {
   4302            src -= 2;
   4303            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   4304            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   4305            last_sample1 = sample1;
   4306            last_sample0 = sample0;
   4307            eps -= dstsize;
   4308        }
   4309    }
   4310    cvt->len_cvt = dstsize;
   4311    if (cvt->filters[++cvt->filter_index]) {
   4312        cvt->filters[cvt->filter_index] (cvt, format);
   4313    }
   4314}
   4315
   4316static void SDLCALL
   4317SDL_Downsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4318{
   4319#if DEBUG_CONVERT
   4320    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 2 channels.\n", cvt->rate_incr);
   4321#endif
   4322
   4323    const int srcsize = cvt->len_cvt - 64;
   4324    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   4325    register int eps = 0;
   4326    Uint16 *dst = (Uint16 *) cvt->buf;
   4327    const Uint16 *src = (Uint16 *) cvt->buf;
   4328    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   4329    Uint16 sample0 = SDL_SwapBE16(src[0]);
   4330    Uint16 sample1 = SDL_SwapBE16(src[1]);
   4331    Uint16 last_sample0 = sample0;
   4332    Uint16 last_sample1 = sample1;
   4333    while (dst < target) {
   4334        src += 2;
   4335        eps += dstsize;
   4336        if ((eps << 1) >= srcsize) {
   4337            dst[0] = SDL_SwapBE16(sample0);
   4338            dst[1] = SDL_SwapBE16(sample1);
   4339            dst += 2;
   4340            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   4341            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   4342            last_sample0 = sample0;
   4343            last_sample1 = sample1;
   4344            eps -= srcsize;
   4345        }
   4346    }
   4347    cvt->len_cvt = dstsize;
   4348    if (cvt->filters[++cvt->filter_index]) {
   4349        cvt->filters[cvt->filter_index] (cvt, format);
   4350    }
   4351}
   4352
   4353static void SDLCALL
   4354SDL_Upsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4355{
   4356#if DEBUG_CONVERT
   4357    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 4 channels.\n", cvt->rate_incr);
   4358#endif
   4359
   4360    const int srcsize = cvt->len_cvt - 128;
   4361    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   4362    register int eps = 0;
   4363    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
   4364    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
   4365    const Uint16 *target = ((const Uint16 *) cvt->buf);
   4366    Uint16 sample3 = SDL_SwapBE16(src[3]);
   4367    Uint16 sample2 = SDL_SwapBE16(src[2]);
   4368    Uint16 sample1 = SDL_SwapBE16(src[1]);
   4369    Uint16 sample0 = SDL_SwapBE16(src[0]);
   4370    Uint16 last_sample3 = sample3;
   4371    Uint16 last_sample2 = sample2;
   4372    Uint16 last_sample1 = sample1;
   4373    Uint16 last_sample0 = sample0;
   4374    while (dst >= target) {
   4375        dst[3] = SDL_SwapBE16(sample3);
   4376        dst[2] = SDL_SwapBE16(sample2);
   4377        dst[1] = SDL_SwapBE16(sample1);
   4378        dst[0] = SDL_SwapBE16(sample0);
   4379        dst -= 4;
   4380        eps += srcsize;
   4381        if ((eps << 1) >= dstsize) {
   4382            src -= 4;
   4383            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
   4384            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
   4385            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   4386            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   4387            last_sample3 = sample3;
   4388            last_sample2 = sample2;
   4389            last_sample1 = sample1;
   4390            last_sample0 = sample0;
   4391            eps -= dstsize;
   4392        }
   4393    }
   4394    cvt->len_cvt = dstsize;
   4395    if (cvt->filters[++cvt->filter_index]) {
   4396        cvt->filters[cvt->filter_index] (cvt, format);
   4397    }
   4398}
   4399
   4400static void SDLCALL
   4401SDL_Downsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4402{
   4403#if DEBUG_CONVERT
   4404    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 4 channels.\n", cvt->rate_incr);
   4405#endif
   4406
   4407    const int srcsize = cvt->len_cvt - 128;
   4408    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   4409    register int eps = 0;
   4410    Uint16 *dst = (Uint16 *) cvt->buf;
   4411    const Uint16 *src = (Uint16 *) cvt->buf;
   4412    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   4413    Uint16 sample0 = SDL_SwapBE16(src[0]);
   4414    Uint16 sample1 = SDL_SwapBE16(src[1]);
   4415    Uint16 sample2 = SDL_SwapBE16(src[2]);
   4416    Uint16 sample3 = SDL_SwapBE16(src[3]);
   4417    Uint16 last_sample0 = sample0;
   4418    Uint16 last_sample1 = sample1;
   4419    Uint16 last_sample2 = sample2;
   4420    Uint16 last_sample3 = sample3;
   4421    while (dst < target) {
   4422        src += 4;
   4423        eps += dstsize;
   4424        if ((eps << 1) >= srcsize) {
   4425            dst[0] = SDL_SwapBE16(sample0);
   4426            dst[1] = SDL_SwapBE16(sample1);
   4427            dst[2] = SDL_SwapBE16(sample2);
   4428            dst[3] = SDL_SwapBE16(sample3);
   4429            dst += 4;
   4430            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   4431            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   4432            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
   4433            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
   4434            last_sample0 = sample0;
   4435            last_sample1 = sample1;
   4436            last_sample2 = sample2;
   4437            last_sample3 = sample3;
   4438            eps -= srcsize;
   4439        }
   4440    }
   4441    cvt->len_cvt = dstsize;
   4442    if (cvt->filters[++cvt->filter_index]) {
   4443        cvt->filters[cvt->filter_index] (cvt, format);
   4444    }
   4445}
   4446
   4447static void SDLCALL
   4448SDL_Upsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4449{
   4450#if DEBUG_CONVERT
   4451    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 6 channels.\n", cvt->rate_incr);
   4452#endif
   4453
   4454    const int srcsize = cvt->len_cvt - 192;
   4455    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
   4456    register int eps = 0;
   4457    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
   4458    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
   4459    const Uint16 *target = ((const Uint16 *) cvt->buf);
   4460    Uint16 sample5 = SDL_SwapBE16(src[5]);
   4461    Uint16 sample4 = SDL_SwapBE16(src[4]);
   4462    Uint16 sample3 = SDL_SwapBE16(src[3]);
   4463    Uint16 sample2 = SDL_SwapBE16(src[2]);
   4464    Uint16 sample1 = SDL_SwapBE16(src[1]);
   4465    Uint16 sample0 = SDL_SwapBE16(src[0]);
   4466    Uint16 last_sample5 = sample5;
   4467    Uint16 last_sample4 = sample4;
   4468    Uint16 last_sample3 = sample3;
   4469    Uint16 last_sample2 = sample2;
   4470    Uint16 last_sample1 = sample1;
   4471    Uint16 last_sample0 = sample0;
   4472    while (dst >= target) {
   4473        dst[5] = SDL_SwapBE16(sample5);
   4474        dst[4] = SDL_SwapBE16(sample4);
   4475        dst[3] = SDL_SwapBE16(sample3);
   4476        dst[2] = SDL_SwapBE16(sample2);
   4477        dst[1] = SDL_SwapBE16(sample1);
   4478        dst[0] = SDL_SwapBE16(sample0);
   4479        dst -= 6;
   4480        eps += srcsize;
   4481        if ((eps << 1) >= dstsize) {
   4482            src -= 6;
   4483            sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
   4484            sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
   4485            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
   4486            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
   4487            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   4488            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   4489            last_sample5 = sample5;
   4490            last_sample4 = sample4;
   4491            last_sample3 = sample3;
   4492            last_sample2 = sample2;
   4493            last_sample1 = sample1;
   4494            last_sample0 = sample0;
   4495            eps -= dstsize;
   4496        }
   4497    }
   4498    cvt->len_cvt = dstsize;
   4499    if (cvt->filters[++cvt->filter_index]) {
   4500        cvt->filters[cvt->filter_index] (cvt, format);
   4501    }
   4502}
   4503
   4504static void SDLCALL
   4505SDL_Downsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4506{
   4507#if DEBUG_CONVERT
   4508    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 6 channels.\n", cvt->rate_incr);
   4509#endif
   4510
   4511    const int srcsize = cvt->len_cvt - 192;
   4512    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
   4513    register int eps = 0;
   4514    Uint16 *dst = (Uint16 *) cvt->buf;
   4515    const Uint16 *src = (Uint16 *) cvt->buf;
   4516    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   4517    Uint16 sample0 = SDL_SwapBE16(src[0]);
   4518    Uint16 sample1 = SDL_SwapBE16(src[1]);
   4519    Uint16 sample2 = SDL_SwapBE16(src[2]);
   4520    Uint16 sample3 = SDL_SwapBE16(src[3]);
   4521    Uint16 sample4 = SDL_SwapBE16(src[4]);
   4522    Uint16 sample5 = SDL_SwapBE16(src[5]);
   4523    Uint16 last_sample0 = sample0;
   4524    Uint16 last_sample1 = sample1;
   4525    Uint16 last_sample2 = sample2;
   4526    Uint16 last_sample3 = sample3;
   4527    Uint16 last_sample4 = sample4;
   4528    Uint16 last_sample5 = sample5;
   4529    while (dst < target) {
   4530        src += 6;
   4531        eps += dstsize;
   4532        if ((eps << 1) >= srcsize) {
   4533            dst[0] = SDL_SwapBE16(sample0);
   4534            dst[1] = SDL_SwapBE16(sample1);
   4535            dst[2] = SDL_SwapBE16(sample2);
   4536            dst[3] = SDL_SwapBE16(sample3);
   4537            dst[4] = SDL_SwapBE16(sample4);
   4538            dst[5] = SDL_SwapBE16(sample5);
   4539            dst += 6;
   4540            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   4541            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   4542            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
   4543            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
   4544            sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
   4545            sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
   4546            last_sample0 = sample0;
   4547            last_sample1 = sample1;
   4548            last_sample2 = sample2;
   4549            last_sample3 = sample3;
   4550            last_sample4 = sample4;
   4551            last_sample5 = sample5;
   4552            eps -= srcsize;
   4553        }
   4554    }
   4555    cvt->len_cvt = dstsize;
   4556    if (cvt->filters[++cvt->filter_index]) {
   4557        cvt->filters[cvt->filter_index] (cvt, format);
   4558    }
   4559}
   4560
   4561static void SDLCALL
   4562SDL_Upsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4563{
   4564#if DEBUG_CONVERT
   4565    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 8 channels.\n", cvt->rate_incr);
   4566#endif
   4567
   4568    const int srcsize = cvt->len_cvt - 256;
   4569    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   4570    register int eps = 0;
   4571    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
   4572    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
   4573    const Uint16 *target = ((const Uint16 *) cvt->buf);
   4574    Uint16 sample7 = SDL_SwapBE16(src[7]);
   4575    Uint16 sample6 = SDL_SwapBE16(src[6]);
   4576    Uint16 sample5 = SDL_SwapBE16(src[5]);
   4577    Uint16 sample4 = SDL_SwapBE16(src[4]);
   4578    Uint16 sample3 = SDL_SwapBE16(src[3]);
   4579    Uint16 sample2 = SDL_SwapBE16(src[2]);
   4580    Uint16 sample1 = SDL_SwapBE16(src[1]);
   4581    Uint16 sample0 = SDL_SwapBE16(src[0]);
   4582    Uint16 last_sample7 = sample7;
   4583    Uint16 last_sample6 = sample6;
   4584    Uint16 last_sample5 = sample5;
   4585    Uint16 last_sample4 = sample4;
   4586    Uint16 last_sample3 = sample3;
   4587    Uint16 last_sample2 = sample2;
   4588    Uint16 last_sample1 = sample1;
   4589    Uint16 last_sample0 = sample0;
   4590    while (dst >= target) {
   4591        dst[7] = SDL_SwapBE16(sample7);
   4592        dst[6] = SDL_SwapBE16(sample6);
   4593        dst[5] = SDL_SwapBE16(sample5);
   4594        dst[4] = SDL_SwapBE16(sample4);
   4595        dst[3] = SDL_SwapBE16(sample3);
   4596        dst[2] = SDL_SwapBE16(sample2);
   4597        dst[1] = SDL_SwapBE16(sample1);
   4598        dst[0] = SDL_SwapBE16(sample0);
   4599        dst -= 8;
   4600        eps += srcsize;
   4601        if ((eps << 1) >= dstsize) {
   4602            src -= 8;
   4603            sample7 = (Uint16) ((((Sint32) SDL_SwapBE16(src[7])) + ((Sint32) last_sample7)) >> 1);
   4604            sample6 = (Uint16) ((((Sint32) SDL_SwapBE16(src[6])) + ((Sint32) last_sample6)) >> 1);
   4605            sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
   4606            sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
   4607            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
   4608            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
   4609            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   4610            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   4611            last_sample7 = sample7;
   4612            last_sample6 = sample6;
   4613            last_sample5 = sample5;
   4614            last_sample4 = sample4;
   4615            last_sample3 = sample3;
   4616            last_sample2 = sample2;
   4617            last_sample1 = sample1;
   4618            last_sample0 = sample0;
   4619            eps -= dstsize;
   4620        }
   4621    }
   4622    cvt->len_cvt = dstsize;
   4623    if (cvt->filters[++cvt->filter_index]) {
   4624        cvt->filters[cvt->filter_index] (cvt, format);
   4625    }
   4626}
   4627
   4628static void SDLCALL
   4629SDL_Downsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4630{
   4631#if DEBUG_CONVERT
   4632    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 8 channels.\n", cvt->rate_incr);
   4633#endif
   4634
   4635    const int srcsize = cvt->len_cvt - 256;
   4636    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   4637    register int eps = 0;
   4638    Uint16 *dst = (Uint16 *) cvt->buf;
   4639    const Uint16 *src = (Uint16 *) cvt->buf;
   4640    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   4641    Uint16 sample0 = SDL_SwapBE16(src[0]);
   4642    Uint16 sample1 = SDL_SwapBE16(src[1]);
   4643    Uint16 sample2 = SDL_SwapBE16(src[2]);
   4644    Uint16 sample3 = SDL_SwapBE16(src[3]);
   4645    Uint16 sample4 = SDL_SwapBE16(src[4]);
   4646    Uint16 sample5 = SDL_SwapBE16(src[5]);
   4647    Uint16 sample6 = SDL_SwapBE16(src[6]);
   4648    Uint16 sample7 = SDL_SwapBE16(src[7]);
   4649    Uint16 last_sample0 = sample0;
   4650    Uint16 last_sample1 = sample1;
   4651    Uint16 last_sample2 = sample2;
   4652    Uint16 last_sample3 = sample3;
   4653    Uint16 last_sample4 = sample4;
   4654    Uint16 last_sample5 = sample5;
   4655    Uint16 last_sample6 = sample6;
   4656    Uint16 last_sample7 = sample7;
   4657    while (dst < target) {
   4658        src += 8;
   4659        eps += dstsize;
   4660        if ((eps << 1) >= srcsize) {
   4661            dst[0] = SDL_SwapBE16(sample0);
   4662            dst[1] = SDL_SwapBE16(sample1);
   4663            dst[2] = SDL_SwapBE16(sample2);
   4664            dst[3] = SDL_SwapBE16(sample3);
   4665            dst[4] = SDL_SwapBE16(sample4);
   4666            dst[5] = SDL_SwapBE16(sample5);
   4667            dst[6] = SDL_SwapBE16(sample6);
   4668            dst[7] = SDL_SwapBE16(sample7);
   4669            dst += 8;
   4670            sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
   4671            sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
   4672            sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
   4673            sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
   4674            sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
   4675            sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
   4676            sample6 = (Uint16) ((((Sint32) SDL_SwapBE16(src[6])) + ((Sint32) last_sample6)) >> 1);
   4677            sample7 = (Uint16) ((((Sint32) SDL_SwapBE16(src[7])) + ((Sint32) last_sample7)) >> 1);
   4678            last_sample0 = sample0;
   4679            last_sample1 = sample1;
   4680            last_sample2 = sample2;
   4681            last_sample3 = sample3;
   4682            last_sample4 = sample4;
   4683            last_sample5 = sample5;
   4684            last_sample6 = sample6;
   4685            last_sample7 = sample7;
   4686            eps -= srcsize;
   4687        }
   4688    }
   4689    cvt->len_cvt = dstsize;
   4690    if (cvt->filters[++cvt->filter_index]) {
   4691        cvt->filters[cvt->filter_index] (cvt, format);
   4692    }
   4693}
   4694
   4695static void SDLCALL
   4696SDL_Upsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4697{
   4698#if DEBUG_CONVERT
   4699    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 1 channels.\n", cvt->rate_incr);
   4700#endif
   4701
   4702    const int srcsize = cvt->len_cvt - 32;
   4703    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
   4704    register int eps = 0;
   4705    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
   4706    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   4707    const Sint16 *target = ((const Sint16 *) cvt->buf);
   4708    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
   4709    Sint16 last_sample0 = sample0;
   4710    while (dst >= target) {
   4711        dst[0] = ((Sint16) SDL_SwapBE16(sample0));
   4712        dst--;
   4713        eps += srcsize;
   4714        if ((eps << 1) >= dstsize) {
   4715            src--;
   4716            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   4717            last_sample0 = sample0;
   4718            eps -= dstsize;
   4719        }
   4720    }
   4721    cvt->len_cvt = dstsize;
   4722    if (cvt->filters[++cvt->filter_index]) {
   4723        cvt->filters[cvt->filter_index] (cvt, format);
   4724    }
   4725}
   4726
   4727static void SDLCALL
   4728SDL_Downsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4729{
   4730#if DEBUG_CONVERT
   4731    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 1 channels.\n", cvt->rate_incr);
   4732#endif
   4733
   4734    const int srcsize = cvt->len_cvt - 32;
   4735    const int dstsize = (int) (((double)(cvt->len_cvt/2)) * cvt->rate_incr) * 2;
   4736    register int eps = 0;
   4737    Sint16 *dst = (Sint16 *) cvt->buf;
   4738    const Sint16 *src = (Sint16 *) cvt->buf;
   4739    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   4740    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
   4741    Sint16 last_sample0 = sample0;
   4742    while (dst < target) {
   4743        src++;
   4744        eps += dstsize;
   4745        if ((eps << 1) >= srcsize) {
   4746            dst[0] = ((Sint16) SDL_SwapBE16(sample0));
   4747            dst++;
   4748            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   4749            last_sample0 = sample0;
   4750            eps -= srcsize;
   4751        }
   4752    }
   4753    cvt->len_cvt = dstsize;
   4754    if (cvt->filters[++cvt->filter_index]) {
   4755        cvt->filters[cvt->filter_index] (cvt, format);
   4756    }
   4757}
   4758
   4759static void SDLCALL
   4760SDL_Upsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4761{
   4762#if DEBUG_CONVERT
   4763    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 2 channels.\n", cvt->rate_incr);
   4764#endif
   4765
   4766    const int srcsize = cvt->len_cvt - 64;
   4767    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   4768    register int eps = 0;
   4769    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
   4770    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
   4771    const Sint16 *target = ((const Sint16 *) cvt->buf);
   4772    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
   4773    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
   4774    Sint16 last_sample1 = sample1;
   4775    Sint16 last_sample0 = sample0;
   4776    while (dst >= target) {
   4777        dst[1] = ((Sint16) SDL_SwapBE16(sample1));
   4778        dst[0] = ((Sint16) SDL_SwapBE16(sample0));
   4779        dst -= 2;
   4780        eps += srcsize;
   4781        if ((eps << 1) >= dstsize) {
   4782            src -= 2;
   4783            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   4784            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   4785            last_sample1 = sample1;
   4786            last_sample0 = sample0;
   4787            eps -= dstsize;
   4788        }
   4789    }
   4790    cvt->len_cvt = dstsize;
   4791    if (cvt->filters[++cvt->filter_index]) {
   4792        cvt->filters[cvt->filter_index] (cvt, format);
   4793    }
   4794}
   4795
   4796static void SDLCALL
   4797SDL_Downsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4798{
   4799#if DEBUG_CONVERT
   4800    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 2 channels.\n", cvt->rate_incr);
   4801#endif
   4802
   4803    const int srcsize = cvt->len_cvt - 64;
   4804    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   4805    register int eps = 0;
   4806    Sint16 *dst = (Sint16 *) cvt->buf;
   4807    const Sint16 *src = (Sint16 *) cvt->buf;
   4808    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   4809    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
   4810    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
   4811    Sint16 last_sample0 = sample0;
   4812    Sint16 last_sample1 = sample1;
   4813    while (dst < target) {
   4814        src += 2;
   4815        eps += dstsize;
   4816        if ((eps << 1) >= srcsize) {
   4817            dst[0] = ((Sint16) SDL_SwapBE16(sample0));
   4818            dst[1] = ((Sint16) SDL_SwapBE16(sample1));
   4819            dst += 2;
   4820            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   4821            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   4822            last_sample0 = sample0;
   4823            last_sample1 = sample1;
   4824            eps -= srcsize;
   4825        }
   4826    }
   4827    cvt->len_cvt = dstsize;
   4828    if (cvt->filters[++cvt->filter_index]) {
   4829        cvt->filters[cvt->filter_index] (cvt, format);
   4830    }
   4831}
   4832
   4833static void SDLCALL
   4834SDL_Upsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4835{
   4836#if DEBUG_CONVERT
   4837    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 4 channels.\n", cvt->rate_incr);
   4838#endif
   4839
   4840    const int srcsize = cvt->len_cvt - 128;
   4841    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   4842    register int eps = 0;
   4843    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
   4844    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
   4845    const Sint16 *target = ((const Sint16 *) cvt->buf);
   4846    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
   4847    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
   4848    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
   4849    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
   4850    Sint16 last_sample3 = sample3;
   4851    Sint16 last_sample2 = sample2;
   4852    Sint16 last_sample1 = sample1;
   4853    Sint16 last_sample0 = sample0;
   4854    while (dst >= target) {
   4855        dst[3] = ((Sint16) SDL_SwapBE16(sample3));
   4856        dst[2] = ((Sint16) SDL_SwapBE16(sample2));
   4857        dst[1] = ((Sint16) SDL_SwapBE16(sample1));
   4858        dst[0] = ((Sint16) SDL_SwapBE16(sample0));
   4859        dst -= 4;
   4860        eps += srcsize;
   4861        if ((eps << 1) >= dstsize) {
   4862            src -= 4;
   4863            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
   4864            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
   4865            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   4866            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   4867            last_sample3 = sample3;
   4868            last_sample2 = sample2;
   4869            last_sample1 = sample1;
   4870            last_sample0 = sample0;
   4871            eps -= dstsize;
   4872        }
   4873    }
   4874    cvt->len_cvt = dstsize;
   4875    if (cvt->filters[++cvt->filter_index]) {
   4876        cvt->filters[cvt->filter_index] (cvt, format);
   4877    }
   4878}
   4879
   4880static void SDLCALL
   4881SDL_Downsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4882{
   4883#if DEBUG_CONVERT
   4884    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 4 channels.\n", cvt->rate_incr);
   4885#endif
   4886
   4887    const int srcsize = cvt->len_cvt - 128;
   4888    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   4889    register int eps = 0;
   4890    Sint16 *dst = (Sint16 *) cvt->buf;
   4891    const Sint16 *src = (Sint16 *) cvt->buf;
   4892    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   4893    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
   4894    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
   4895    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
   4896    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
   4897    Sint16 last_sample0 = sample0;
   4898    Sint16 last_sample1 = sample1;
   4899    Sint16 last_sample2 = sample2;
   4900    Sint16 last_sample3 = sample3;
   4901    while (dst < target) {
   4902        src += 4;
   4903        eps += dstsize;
   4904        if ((eps << 1) >= srcsize) {
   4905            dst[0] = ((Sint16) SDL_SwapBE16(sample0));
   4906            dst[1] = ((Sint16) SDL_SwapBE16(sample1));
   4907            dst[2] = ((Sint16) SDL_SwapBE16(sample2));
   4908            dst[3] = ((Sint16) SDL_SwapBE16(sample3));
   4909            dst += 4;
   4910            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   4911            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   4912            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
   4913            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
   4914            last_sample0 = sample0;
   4915            last_sample1 = sample1;
   4916            last_sample2 = sample2;
   4917            last_sample3 = sample3;
   4918            eps -= srcsize;
   4919        }
   4920    }
   4921    cvt->len_cvt = dstsize;
   4922    if (cvt->filters[++cvt->filter_index]) {
   4923        cvt->filters[cvt->filter_index] (cvt, format);
   4924    }
   4925}
   4926
   4927static void SDLCALL
   4928SDL_Upsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4929{
   4930#if DEBUG_CONVERT
   4931    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 6 channels.\n", cvt->rate_incr);
   4932#endif
   4933
   4934    const int srcsize = cvt->len_cvt - 192;
   4935    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
   4936    register int eps = 0;
   4937    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
   4938    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
   4939    const Sint16 *target = ((const Sint16 *) cvt->buf);
   4940    Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
   4941    Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
   4942    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
   4943    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
   4944    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
   4945    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
   4946    Sint16 last_sample5 = sample5;
   4947    Sint16 last_sample4 = sample4;
   4948    Sint16 last_sample3 = sample3;
   4949    Sint16 last_sample2 = sample2;
   4950    Sint16 last_sample1 = sample1;
   4951    Sint16 last_sample0 = sample0;
   4952    while (dst >= target) {
   4953        dst[5] = ((Sint16) SDL_SwapBE16(sample5));
   4954        dst[4] = ((Sint16) SDL_SwapBE16(sample4));
   4955        dst[3] = ((Sint16) SDL_SwapBE16(sample3));
   4956        dst[2] = ((Sint16) SDL_SwapBE16(sample2));
   4957        dst[1] = ((Sint16) SDL_SwapBE16(sample1));
   4958        dst[0] = ((Sint16) SDL_SwapBE16(sample0));
   4959        dst -= 6;
   4960        eps += srcsize;
   4961        if ((eps << 1) >= dstsize) {
   4962            src -= 6;
   4963            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
   4964            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
   4965            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
   4966            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
   4967            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   4968            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   4969            last_sample5 = sample5;
   4970            last_sample4 = sample4;
   4971            last_sample3 = sample3;
   4972            last_sample2 = sample2;
   4973            last_sample1 = sample1;
   4974            last_sample0 = sample0;
   4975            eps -= dstsize;
   4976        }
   4977    }
   4978    cvt->len_cvt = dstsize;
   4979    if (cvt->filters[++cvt->filter_index]) {
   4980        cvt->filters[cvt->filter_index] (cvt, format);
   4981    }
   4982}
   4983
   4984static void SDLCALL
   4985SDL_Downsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4986{
   4987#if DEBUG_CONVERT
   4988    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 6 channels.\n", cvt->rate_incr);
   4989#endif
   4990
   4991    const int srcsize = cvt->len_cvt - 192;
   4992    const int dstsize = (int) (((double)(cvt->len_cvt/12)) * cvt->rate_incr) * 12;
   4993    register int eps = 0;
   4994    Sint16 *dst = (Sint16 *) cvt->buf;
   4995    const Sint16 *src = (Sint16 *) cvt->buf;
   4996    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   4997    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
   4998    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
   4999    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
   5000    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
   5001    Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
   5002    Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
   5003    Sint16 last_sample0 = sample0;
   5004    Sint16 last_sample1 = sample1;
   5005    Sint16 last_sample2 = sample2;
   5006    Sint16 last_sample3 = sample3;
   5007    Sint16 last_sample4 = sample4;
   5008    Sint16 last_sample5 = sample5;
   5009    while (dst < target) {
   5010        src += 6;
   5011        eps += dstsize;
   5012        if ((eps << 1) >= srcsize) {
   5013            dst[0] = ((Sint16) SDL_SwapBE16(sample0));
   5014            dst[1] = ((Sint16) SDL_SwapBE16(sample1));
   5015            dst[2] = ((Sint16) SDL_SwapBE16(sample2));
   5016            dst[3] = ((Sint16) SDL_SwapBE16(sample3));
   5017            dst[4] = ((Sint16) SDL_SwapBE16(sample4));
   5018            dst[5] = ((Sint16) SDL_SwapBE16(sample5));
   5019            dst += 6;
   5020            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   5021            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   5022            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
   5023            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
   5024            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
   5025            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
   5026            last_sample0 = sample0;
   5027            last_sample1 = sample1;
   5028            last_sample2 = sample2;
   5029            last_sample3 = sample3;
   5030            last_sample4 = sample4;
   5031            last_sample5 = sample5;
   5032            eps -= srcsize;
   5033        }
   5034    }
   5035    cvt->len_cvt = dstsize;
   5036    if (cvt->filters[++cvt->filter_index]) {
   5037        cvt->filters[cvt->filter_index] (cvt, format);
   5038    }
   5039}
   5040
   5041static void SDLCALL
   5042SDL_Upsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5043{
   5044#if DEBUG_CONVERT
   5045    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 8 channels.\n", cvt->rate_incr);
   5046#endif
   5047
   5048    const int srcsize = cvt->len_cvt - 256;
   5049    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   5050    register int eps = 0;
   5051    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
   5052    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
   5053    const Sint16 *target = ((const Sint16 *) cvt->buf);
   5054    Sint16 sample7 = ((Sint16) SDL_SwapBE16(src[7]));
   5055    Sint16 sample6 = ((Sint16) SDL_SwapBE16(src[6]));
   5056    Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
   5057    Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
   5058    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
   5059    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
   5060    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
   5061    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
   5062    Sint16 last_sample7 = sample7;
   5063    Sint16 last_sample6 = sample6;
   5064    Sint16 last_sample5 = sample5;
   5065    Sint16 last_sample4 = sample4;
   5066    Sint16 last_sample3 = sample3;
   5067    Sint16 last_sample2 = sample2;
   5068    Sint16 last_sample1 = sample1;
   5069    Sint16 last_sample0 = sample0;
   5070    while (dst >= target) {
   5071        dst[7] = ((Sint16) SDL_SwapBE16(sample7));
   5072        dst[6] = ((Sint16) SDL_SwapBE16(sample6));
   5073        dst[5] = ((Sint16) SDL_SwapBE16(sample5));
   5074        dst[4] = ((Sint16) SDL_SwapBE16(sample4));
   5075        dst[3] = ((Sint16) SDL_SwapBE16(sample3));
   5076        dst[2] = ((Sint16) SDL_SwapBE16(sample2));
   5077        dst[1] = ((Sint16) SDL_SwapBE16(sample1));
   5078        dst[0] = ((Sint16) SDL_SwapBE16(sample0));
   5079        dst -= 8;
   5080        eps += srcsize;
   5081        if ((eps << 1) >= dstsize) {
   5082            src -= 8;
   5083            sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
   5084            sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
   5085            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
   5086            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
   5087            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
   5088            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
   5089            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   5090            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   5091            last_sample7 = sample7;
   5092            last_sample6 = sample6;
   5093            last_sample5 = sample5;
   5094            last_sample4 = sample4;
   5095            last_sample3 = sample3;
   5096            last_sample2 = sample2;
   5097            last_sample1 = sample1;
   5098            last_sample0 = sample0;
   5099            eps -= dstsize;
   5100        }
   5101    }
   5102    cvt->len_cvt = dstsize;
   5103    if (cvt->filters[++cvt->filter_index]) {
   5104        cvt->filters[cvt->filter_index] (cvt, format);
   5105    }
   5106}
   5107
   5108static void SDLCALL
   5109SDL_Downsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5110{
   5111#if DEBUG_CONVERT
   5112    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 8 channels.\n", cvt->rate_incr);
   5113#endif
   5114
   5115    const int srcsize = cvt->len_cvt - 256;
   5116    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   5117    register int eps = 0;
   5118    Sint16 *dst = (Sint16 *) cvt->buf;
   5119    const Sint16 *src = (Sint16 *) cvt->buf;
   5120    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   5121    Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
   5122    Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
   5123    Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
   5124    Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
   5125    Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
   5126    Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
   5127    Sint16 sample6 = ((Sint16) SDL_SwapBE16(src[6]));
   5128    Sint16 sample7 = ((Sint16) SDL_SwapBE16(src[7]));
   5129    Sint16 last_sample0 = sample0;
   5130    Sint16 last_sample1 = sample1;
   5131    Sint16 last_sample2 = sample2;
   5132    Sint16 last_sample3 = sample3;
   5133    Sint16 last_sample4 = sample4;
   5134    Sint16 last_sample5 = sample5;
   5135    Sint16 last_sample6 = sample6;
   5136    Sint16 last_sample7 = sample7;
   5137    while (dst < target) {
   5138        src += 8;
   5139        eps += dstsize;
   5140        if ((eps << 1) >= srcsize) {
   5141            dst[0] = ((Sint16) SDL_SwapBE16(sample0));
   5142            dst[1] = ((Sint16) SDL_SwapBE16(sample1));
   5143            dst[2] = ((Sint16) SDL_SwapBE16(sample2));
   5144            dst[3] = ((Sint16) SDL_SwapBE16(sample3));
   5145            dst[4] = ((Sint16) SDL_SwapBE16(sample4));
   5146            dst[5] = ((Sint16) SDL_SwapBE16(sample5));
   5147            dst[6] = ((Sint16) SDL_SwapBE16(sample6));
   5148            dst[7] = ((Sint16) SDL_SwapBE16(sample7));
   5149            dst += 8;
   5150            sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
   5151            sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
   5152            sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
   5153            sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
   5154            sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
   5155            sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
   5156            sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
   5157            sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
   5158            last_sample0 = sample0;
   5159            last_sample1 = sample1;
   5160            last_sample2 = sample2;
   5161            last_sample3 = sample3;
   5162            last_sample4 = sample4;
   5163            last_sample5 = sample5;
   5164            last_sample6 = sample6;
   5165            last_sample7 = sample7;
   5166            eps -= srcsize;
   5167        }
   5168    }
   5169    cvt->len_cvt = dstsize;
   5170    if (cvt->filters[++cvt->filter_index]) {
   5171        cvt->filters[cvt->filter_index] (cvt, format);
   5172    }
   5173}
   5174
   5175static void SDLCALL
   5176SDL_Upsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5177{
   5178#if DEBUG_CONVERT
   5179    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 1 channels.\n", cvt->rate_incr);
   5180#endif
   5181
   5182    const int srcsize = cvt->len_cvt - 64;
   5183    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   5184    register int eps = 0;
   5185    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
   5186    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
   5187    const Sint32 *target = ((const Sint32 *) cvt->buf);
   5188    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
   5189    Sint32 last_sample0 = sample0;
   5190    while (dst >= target) {
   5191        dst[0] = ((Sint32) SDL_SwapLE32(sample0));
   5192        dst--;
   5193        eps += srcsize;
   5194        if ((eps << 1) >= dstsize) {
   5195            src--;
   5196            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5197            last_sample0 = sample0;
   5198            eps -= dstsize;
   5199        }
   5200    }
   5201    cvt->len_cvt = dstsize;
   5202    if (cvt->filters[++cvt->filter_index]) {
   5203        cvt->filters[cvt->filter_index] (cvt, format);
   5204    }
   5205}
   5206
   5207static void SDLCALL
   5208SDL_Downsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5209{
   5210#if DEBUG_CONVERT
   5211    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 1 channels.\n", cvt->rate_incr);
   5212#endif
   5213
   5214    const int srcsize = cvt->len_cvt - 64;
   5215    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   5216    register int eps = 0;
   5217    Sint32 *dst = (Sint32 *) cvt->buf;
   5218    const Sint32 *src = (Sint32 *) cvt->buf;
   5219    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
   5220    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
   5221    Sint32 last_sample0 = sample0;
   5222    while (dst < target) {
   5223        src++;
   5224        eps += dstsize;
   5225        if ((eps << 1) >= srcsize) {
   5226            dst[0] = ((Sint32) SDL_SwapLE32(sample0));
   5227            dst++;
   5228            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5229            last_sample0 = sample0;
   5230            eps -= srcsize;
   5231        }
   5232    }
   5233    cvt->len_cvt = dstsize;
   5234    if (cvt->filters[++cvt->filter_index]) {
   5235        cvt->filters[cvt->filter_index] (cvt, format);
   5236    }
   5237}
   5238
   5239static void SDLCALL
   5240SDL_Upsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5241{
   5242#if DEBUG_CONVERT
   5243    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 2 channels.\n", cvt->rate_incr);
   5244#endif
   5245
   5246    const int srcsize = cvt->len_cvt - 128;
   5247    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   5248    register int eps = 0;
   5249    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
   5250    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
   5251    const Sint32 *target = ((const Sint32 *) cvt->buf);
   5252    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
   5253    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
   5254    Sint32 last_sample1 = sample1;
   5255    Sint32 last_sample0 = sample0;
   5256    while (dst >= target) {
   5257        dst[1] = ((Sint32) SDL_SwapLE32(sample1));
   5258        dst[0] = ((Sint32) SDL_SwapLE32(sample0));
   5259        dst -= 2;
   5260        eps += srcsize;
   5261        if ((eps << 1) >= dstsize) {
   5262            src -= 2;
   5263            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   5264            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5265            last_sample1 = sample1;
   5266            last_sample0 = sample0;
   5267            eps -= dstsize;
   5268        }
   5269    }
   5270    cvt->len_cvt = dstsize;
   5271    if (cvt->filters[++cvt->filter_index]) {
   5272        cvt->filters[cvt->filter_index] (cvt, format);
   5273    }
   5274}
   5275
   5276static void SDLCALL
   5277SDL_Downsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5278{
   5279#if DEBUG_CONVERT
   5280    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 2 channels.\n", cvt->rate_incr);
   5281#endif
   5282
   5283    const int srcsize = cvt->len_cvt - 128;
   5284    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   5285    register int eps = 0;
   5286    Sint32 *dst = (Sint32 *) cvt->buf;
   5287    const Sint32 *src = (Sint32 *) cvt->buf;
   5288    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
   5289    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
   5290    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
   5291    Sint32 last_sample0 = sample0;
   5292    Sint32 last_sample1 = sample1;
   5293    while (dst < target) {
   5294        src += 2;
   5295        eps += dstsize;
   5296        if ((eps << 1) >= srcsize) {
   5297            dst[0] = ((Sint32) SDL_SwapLE32(sample0));
   5298            dst[1] = ((Sint32) SDL_SwapLE32(sample1));
   5299            dst += 2;
   5300            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5301            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   5302            last_sample0 = sample0;
   5303            last_sample1 = sample1;
   5304            eps -= srcsize;
   5305        }
   5306    }
   5307    cvt->len_cvt = dstsize;
   5308    if (cvt->filters[++cvt->filter_index]) {
   5309        cvt->filters[cvt->filter_index] (cvt, format);
   5310    }
   5311}
   5312
   5313static void SDLCALL
   5314SDL_Upsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5315{
   5316#if DEBUG_CONVERT
   5317    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 4 channels.\n", cvt->rate_incr);
   5318#endif
   5319
   5320    const int srcsize = cvt->len_cvt - 256;
   5321    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   5322    register int eps = 0;
   5323    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
   5324    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
   5325    const Sint32 *target = ((const Sint32 *) cvt->buf);
   5326    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
   5327    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
   5328    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
   5329    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
   5330    Sint32 last_sample3 = sample3;
   5331    Sint32 last_sample2 = sample2;
   5332    Sint32 last_sample1 = sample1;
   5333    Sint32 last_sample0 = sample0;
   5334    while (dst >= target) {
   5335        dst[3] = ((Sint32) SDL_SwapLE32(sample3));
   5336        dst[2] = ((Sint32) SDL_SwapLE32(sample2));
   5337        dst[1] = ((Sint32) SDL_SwapLE32(sample1));
   5338        dst[0] = ((Sint32) SDL_SwapLE32(sample0));
   5339        dst -= 4;
   5340        eps += srcsize;
   5341        if ((eps << 1) >= dstsize) {
   5342            src -= 4;
   5343            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
   5344            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
   5345            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   5346            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5347            last_sample3 = sample3;
   5348            last_sample2 = sample2;
   5349            last_sample1 = sample1;
   5350            last_sample0 = sample0;
   5351            eps -= dstsize;
   5352        }
   5353    }
   5354    cvt->len_cvt = dstsize;
   5355    if (cvt->filters[++cvt->filter_index]) {
   5356        cvt->filters[cvt->filter_index] (cvt, format);
   5357    }
   5358}
   5359
   5360static void SDLCALL
   5361SDL_Downsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5362{
   5363#if DEBUG_CONVERT
   5364    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 4 channels.\n", cvt->rate_incr);
   5365#endif
   5366
   5367    const int srcsize = cvt->len_cvt - 256;
   5368    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   5369    register int eps = 0;
   5370    Sint32 *dst = (Sint32 *) cvt->buf;
   5371    const Sint32 *src = (Sint32 *) cvt->buf;
   5372    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
   5373    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
   5374    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
   5375    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
   5376    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
   5377    Sint32 last_sample0 = sample0;
   5378    Sint32 last_sample1 = sample1;
   5379    Sint32 last_sample2 = sample2;
   5380    Sint32 last_sample3 = sample3;
   5381    while (dst < target) {
   5382        src += 4;
   5383        eps += dstsize;
   5384        if ((eps << 1) >= srcsize) {
   5385            dst[0] = ((Sint32) SDL_SwapLE32(sample0));
   5386            dst[1] = ((Sint32) SDL_SwapLE32(sample1));
   5387            dst[2] = ((Sint32) SDL_SwapLE32(sample2));
   5388            dst[3] = ((Sint32) SDL_SwapLE32(sample3));
   5389            dst += 4;
   5390            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5391            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   5392            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
   5393            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
   5394            last_sample0 = sample0;
   5395            last_sample1 = sample1;
   5396            last_sample2 = sample2;
   5397            last_sample3 = sample3;
   5398            eps -= srcsize;
   5399        }
   5400    }
   5401    cvt->len_cvt = dstsize;
   5402    if (cvt->filters[++cvt->filter_index]) {
   5403        cvt->filters[cvt->filter_index] (cvt, format);
   5404    }
   5405}
   5406
   5407static void SDLCALL
   5408SDL_Upsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5409{
   5410#if DEBUG_CONVERT
   5411    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 6 channels.\n", cvt->rate_incr);
   5412#endif
   5413
   5414    const int srcsize = cvt->len_cvt - 384;
   5415    const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
   5416    register int eps = 0;
   5417    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
   5418    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
   5419    const Sint32 *target = ((const Sint32 *) cvt->buf);
   5420    Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
   5421    Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
   5422    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
   5423    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
   5424    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
   5425    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
   5426    Sint32 last_sample5 = sample5;
   5427    Sint32 last_sample4 = sample4;
   5428    Sint32 last_sample3 = sample3;
   5429    Sint32 last_sample2 = sample2;
   5430    Sint32 last_sample1 = sample1;
   5431    Sint32 last_sample0 = sample0;
   5432    while (dst >= target) {
   5433        dst[5] = ((Sint32) SDL_SwapLE32(sample5));
   5434        dst[4] = ((Sint32) SDL_SwapLE32(sample4));
   5435        dst[3] = ((Sint32) SDL_SwapLE32(sample3));
   5436        dst[2] = ((Sint32) SDL_SwapLE32(sample2));
   5437        dst[1] = ((Sint32) SDL_SwapLE32(sample1));
   5438        dst[0] = ((Sint32) SDL_SwapLE32(sample0));
   5439        dst -= 6;
   5440        eps += srcsize;
   5441        if ((eps << 1) >= dstsize) {
   5442            src -= 6;
   5443            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
   5444            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
   5445            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
   5446            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
   5447            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   5448            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5449            last_sample5 = sample5;
   5450            last_sample4 = sample4;
   5451            last_sample3 = sample3;
   5452            last_sample2 = sample2;
   5453            last_sample1 = sample1;
   5454            last_sample0 = sample0;
   5455            eps -= dstsize;
   5456        }
   5457    }
   5458    cvt->len_cvt = dstsize;
   5459    if (cvt->filters[++cvt->filter_index]) {
   5460        cvt->filters[cvt->filter_index] (cvt, format);
   5461    }
   5462}
   5463
   5464static void SDLCALL
   5465SDL_Downsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5466{
   5467#if DEBUG_CONVERT
   5468    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 6 channels.\n", cvt->rate_incr);
   5469#endif
   5470
   5471    const int srcsize = cvt->len_cvt - 384;
   5472    const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
   5473    register int eps = 0;
   5474    Sint32 *dst = (Sint32 *) cvt->buf;
   5475    const Sint32 *src = (Sint32 *) cvt->buf;
   5476    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
   5477    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
   5478    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
   5479    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
   5480    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
   5481    Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
   5482    Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
   5483    Sint32 last_sample0 = sample0;
   5484    Sint32 last_sample1 = sample1;
   5485    Sint32 last_sample2 = sample2;
   5486    Sint32 last_sample3 = sample3;
   5487    Sint32 last_sample4 = sample4;
   5488    Sint32 last_sample5 = sample5;
   5489    while (dst < target) {
   5490        src += 6;
   5491        eps += dstsize;
   5492        if ((eps << 1) >= srcsize) {
   5493            dst[0] = ((Sint32) SDL_SwapLE32(sample0));
   5494            dst[1] = ((Sint32) SDL_SwapLE32(sample1));
   5495            dst[2] = ((Sint32) SDL_SwapLE32(sample2));
   5496            dst[3] = ((Sint32) SDL_SwapLE32(sample3));
   5497            dst[4] = ((Sint32) SDL_SwapLE32(sample4));
   5498            dst[5] = ((Sint32) SDL_SwapLE32(sample5));
   5499            dst += 6;
   5500            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5501            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   5502            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
   5503            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
   5504            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
   5505            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
   5506            last_sample0 = sample0;
   5507            last_sample1 = sample1;
   5508            last_sample2 = sample2;
   5509            last_sample3 = sample3;
   5510            last_sample4 = sample4;
   5511            last_sample5 = sample5;
   5512            eps -= srcsize;
   5513        }
   5514    }
   5515    cvt->len_cvt = dstsize;
   5516    if (cvt->filters[++cvt->filter_index]) {
   5517        cvt->filters[cvt->filter_index] (cvt, format);
   5518    }
   5519}
   5520
   5521static void SDLCALL
   5522SDL_Upsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5523{
   5524#if DEBUG_CONVERT
   5525    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 8 channels.\n", cvt->rate_incr);
   5526#endif
   5527
   5528    const int srcsize = cvt->len_cvt - 512;
   5529    const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
   5530    register int eps = 0;
   5531    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
   5532    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
   5533    const Sint32 *target = ((const Sint32 *) cvt->buf);
   5534    Sint32 sample7 = ((Sint32) SDL_SwapLE32(src[7]));
   5535    Sint32 sample6 = ((Sint32) SDL_SwapLE32(src[6]));
   5536    Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
   5537    Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
   5538    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
   5539    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
   5540    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
   5541    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
   5542    Sint32 last_sample7 = sample7;
   5543    Sint32 last_sample6 = sample6;
   5544    Sint32 last_sample5 = sample5;
   5545    Sint32 last_sample4 = sample4;
   5546    Sint32 last_sample3 = sample3;
   5547    Sint32 last_sample2 = sample2;
   5548    Sint32 last_sample1 = sample1;
   5549    Sint32 last_sample0 = sample0;
   5550    while (dst >= target) {
   5551        dst[7] = ((Sint32) SDL_SwapLE32(sample7));
   5552        dst[6] = ((Sint32) SDL_SwapLE32(sample6));
   5553        dst[5] = ((Sint32) SDL_SwapLE32(sample5));
   5554        dst[4] = ((Sint32) SDL_SwapLE32(sample4));
   5555        dst[3] = ((Sint32) SDL_SwapLE32(sample3));
   5556        dst[2] = ((Sint32) SDL_SwapLE32(sample2));
   5557        dst[1] = ((Sint32) SDL_SwapLE32(sample1));
   5558        dst[0] = ((Sint32) SDL_SwapLE32(sample0));
   5559        dst -= 8;
   5560        eps += srcsize;
   5561        if ((eps << 1) >= dstsize) {
   5562            src -= 8;
   5563            sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
   5564            sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
   5565            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
   5566            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
   5567            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
   5568            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
   5569            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   5570            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5571            last_sample7 = sample7;
   5572            last_sample6 = sample6;
   5573            last_sample5 = sample5;
   5574            last_sample4 = sample4;
   5575            last_sample3 = sample3;
   5576            last_sample2 = sample2;
   5577            last_sample1 = sample1;
   5578            last_sample0 = sample0;
   5579            eps -= dstsize;
   5580        }
   5581    }
   5582    cvt->len_cvt = dstsize;
   5583    if (cvt->filters[++cvt->filter_index]) {
   5584        cvt->filters[cvt->filter_index] (cvt, format);
   5585    }
   5586}
   5587
   5588static void SDLCALL
   5589SDL_Downsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5590{
   5591#if DEBUG_CONVERT
   5592    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 8 channels.\n", cvt->rate_incr);
   5593#endif
   5594
   5595    const int srcsize = cvt->len_cvt - 512;
   5596    const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
   5597    register int eps = 0;
   5598    Sint32 *dst = (Sint32 *) cvt->buf;
   5599    const Sint32 *src = (Sint32 *) cvt->buf;
   5600    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
   5601    Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
   5602    Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
   5603    Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
   5604    Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
   5605    Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
   5606    Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
   5607    Sint32 sample6 = ((Sint32) SDL_SwapLE32(src[6]));
   5608    Sint32 sample7 = ((Sint32) SDL_SwapLE32(src[7]));
   5609    Sint32 last_sample0 = sample0;
   5610    Sint32 last_sample1 = sample1;
   5611    Sint32 last_sample2 = sample2;
   5612    Sint32 last_sample3 = sample3;
   5613    Sint32 last_sample4 = sample4;
   5614    Sint32 last_sample5 = sample5;
   5615    Sint32 last_sample6 = sample6;
   5616    Sint32 last_sample7 = sample7;
   5617    while (dst < target) {
   5618        src += 8;
   5619        eps += dstsize;
   5620        if ((eps << 1) >= srcsize) {
   5621            dst[0] = ((Sint32) SDL_SwapLE32(sample0));
   5622            dst[1] = ((Sint32) SDL_SwapLE32(sample1));
   5623            dst[2] = ((Sint32) SDL_SwapLE32(sample2));
   5624            dst[3] = ((Sint32) SDL_SwapLE32(sample3));
   5625            dst[4] = ((Sint32) SDL_SwapLE32(sample4));
   5626            dst[5] = ((Sint32) SDL_SwapLE32(sample5));
   5627            dst[6] = ((Sint32) SDL_SwapLE32(sample6));
   5628            dst[7] = ((Sint32) SDL_SwapLE32(sample7));
   5629            dst += 8;
   5630            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5631            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   5632            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
   5633            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
   5634            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
   5635            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
   5636            sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
   5637            sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
   5638            last_sample0 = sample0;
   5639            last_sample1 = sample1;
   5640            last_sample2 = sample2;
   5641            last_sample3 = sample3;
   5642            last_sample4 = sample4;
   5643            last_sample5 = sample5;
   5644            last_sample6 = sample6;
   5645            last_sample7 = sample7;
   5646            eps -= srcsize;
   5647        }
   5648    }
   5649    cvt->len_cvt = dstsize;
   5650    if (cvt->filters[++cvt->filter_index]) {
   5651        cvt->filters[cvt->filter_index] (cvt, format);
   5652    }
   5653}
   5654
   5655static void SDLCALL
   5656SDL_Upsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5657{
   5658#if DEBUG_CONVERT
   5659    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 1 channels.\n", cvt->rate_incr);
   5660#endif
   5661
   5662    const int srcsize = cvt->len_cvt - 64;
   5663    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   5664    register int eps = 0;
   5665    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
   5666    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
   5667    const Sint32 *target = ((const Sint32 *) cvt->buf);
   5668    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
   5669    Sint32 last_sample0 = sample0;
   5670    while (dst >= target) {
   5671        dst[0] = ((Sint32) SDL_SwapBE32(sample0));
   5672        dst--;
   5673        eps += srcsize;
   5674        if ((eps << 1) >= dstsize) {
   5675            src--;
   5676            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5677            last_sample0 = sample0;
   5678            eps -= dstsize;
   5679        }
   5680    }
   5681    cvt->len_cvt = dstsize;
   5682    if (cvt->filters[++cvt->filter_index]) {
   5683        cvt->filters[cvt->filter_index] (cvt, format);
   5684    }
   5685}
   5686
   5687static void SDLCALL
   5688SDL_Downsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5689{
   5690#if DEBUG_CONVERT
   5691    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 1 channels.\n", cvt->rate_incr);
   5692#endif
   5693
   5694    const int srcsize = cvt->len_cvt - 64;
   5695    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   5696    register int eps = 0;
   5697    Sint32 *dst = (Sint32 *) cvt->buf;
   5698    const Sint32 *src = (Sint32 *) cvt->buf;
   5699    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
   5700    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
   5701    Sint32 last_sample0 = sample0;
   5702    while (dst < target) {
   5703        src++;
   5704        eps += dstsize;
   5705        if ((eps << 1) >= srcsize) {
   5706            dst[0] = ((Sint32) SDL_SwapBE32(sample0));
   5707            dst++;
   5708            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5709            last_sample0 = sample0;
   5710            eps -= srcsize;
   5711        }
   5712    }
   5713    cvt->len_cvt = dstsize;
   5714    if (cvt->filters[++cvt->filter_index]) {
   5715        cvt->filters[cvt->filter_index] (cvt, format);
   5716    }
   5717}
   5718
   5719static void SDLCALL
   5720SDL_Upsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5721{
   5722#if DEBUG_CONVERT
   5723    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 2 channels.\n", cvt->rate_incr);
   5724#endif
   5725
   5726    const int srcsize = cvt->len_cvt - 128;
   5727    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   5728    register int eps = 0;
   5729    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
   5730    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
   5731    const Sint32 *target = ((const Sint32 *) cvt->buf);
   5732    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
   5733    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
   5734    Sint32 last_sample1 = sample1;
   5735    Sint32 last_sample0 = sample0;
   5736    while (dst >= target) {
   5737        dst[1] = ((Sint32) SDL_SwapBE32(sample1));
   5738        dst[0] = ((Sint32) SDL_SwapBE32(sample0));
   5739        dst -= 2;
   5740        eps += srcsize;
   5741        if ((eps << 1) >= dstsize) {
   5742            src -= 2;
   5743            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   5744            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5745            last_sample1 = sample1;
   5746            last_sample0 = sample0;
   5747            eps -= dstsize;
   5748        }
   5749    }
   5750    cvt->len_cvt = dstsize;
   5751    if (cvt->filters[++cvt->filter_index]) {
   5752        cvt->filters[cvt->filter_index] (cvt, format);
   5753    }
   5754}
   5755
   5756static void SDLCALL
   5757SDL_Downsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5758{
   5759#if DEBUG_CONVERT
   5760    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 2 channels.\n", cvt->rate_incr);
   5761#endif
   5762
   5763    const int srcsize = cvt->len_cvt - 128;
   5764    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   5765    register int eps = 0;
   5766    Sint32 *dst = (Sint32 *) cvt->buf;
   5767    const Sint32 *src = (Sint32 *) cvt->buf;
   5768    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
   5769    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
   5770    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
   5771    Sint32 last_sample0 = sample0;
   5772    Sint32 last_sample1 = sample1;
   5773    while (dst < target) {
   5774        src += 2;
   5775        eps += dstsize;
   5776        if ((eps << 1) >= srcsize) {
   5777            dst[0] = ((Sint32) SDL_SwapBE32(sample0));
   5778            dst[1] = ((Sint32) SDL_SwapBE32(sample1));
   5779            dst += 2;
   5780            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5781            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   5782            last_sample0 = sample0;
   5783            last_sample1 = sample1;
   5784            eps -= srcsize;
   5785        }
   5786    }
   5787    cvt->len_cvt = dstsize;
   5788    if (cvt->filters[++cvt->filter_index]) {
   5789        cvt->filters[cvt->filter_index] (cvt, format);
   5790    }
   5791}
   5792
   5793static void SDLCALL
   5794SDL_Upsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5795{
   5796#if DEBUG_CONVERT
   5797    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 4 channels.\n", cvt->rate_incr);
   5798#endif
   5799
   5800    const int srcsize = cvt->len_cvt - 256;
   5801    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   5802    register int eps = 0;
   5803    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
   5804    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
   5805    const Sint32 *target = ((const Sint32 *) cvt->buf);
   5806    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
   5807    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
   5808    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
   5809    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
   5810    Sint32 last_sample3 = sample3;
   5811    Sint32 last_sample2 = sample2;
   5812    Sint32 last_sample1 = sample1;
   5813    Sint32 last_sample0 = sample0;
   5814    while (dst >= target) {
   5815        dst[3] = ((Sint32) SDL_SwapBE32(sample3));
   5816        dst[2] = ((Sint32) SDL_SwapBE32(sample2));
   5817        dst[1] = ((Sint32) SDL_SwapBE32(sample1));
   5818        dst[0] = ((Sint32) SDL_SwapBE32(sample0));
   5819        dst -= 4;
   5820        eps += srcsize;
   5821        if ((eps << 1) >= dstsize) {
   5822            src -= 4;
   5823            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
   5824            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
   5825            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   5826            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5827            last_sample3 = sample3;
   5828            last_sample2 = sample2;
   5829            last_sample1 = sample1;
   5830            last_sample0 = sample0;
   5831            eps -= dstsize;
   5832        }
   5833    }
   5834    cvt->len_cvt = dstsize;
   5835    if (cvt->filters[++cvt->filter_index]) {
   5836        cvt->filters[cvt->filter_index] (cvt, format);
   5837    }
   5838}
   5839
   5840static void SDLCALL
   5841SDL_Downsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5842{
   5843#if DEBUG_CONVERT
   5844    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 4 channels.\n", cvt->rate_incr);
   5845#endif
   5846
   5847    const int srcsize = cvt->len_cvt - 256;
   5848    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   5849    register int eps = 0;
   5850    Sint32 *dst = (Sint32 *) cvt->buf;
   5851    const Sint32 *src = (Sint32 *) cvt->buf;
   5852    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
   5853    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
   5854    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
   5855    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
   5856    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
   5857    Sint32 last_sample0 = sample0;
   5858    Sint32 last_sample1 = sample1;
   5859    Sint32 last_sample2 = sample2;
   5860    Sint32 last_sample3 = sample3;
   5861    while (dst < target) {
   5862        src += 4;
   5863        eps += dstsize;
   5864        if ((eps << 1) >= srcsize) {
   5865            dst[0] = ((Sint32) SDL_SwapBE32(sample0));
   5866            dst[1] = ((Sint32) SDL_SwapBE32(sample1));
   5867            dst[2] = ((Sint32) SDL_SwapBE32(sample2));
   5868            dst[3] = ((Sint32) SDL_SwapBE32(sample3));
   5869            dst += 4;
   5870            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5871            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   5872            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
   5873            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
   5874            last_sample0 = sample0;
   5875            last_sample1 = sample1;
   5876            last_sample2 = sample2;
   5877            last_sample3 = sample3;
   5878            eps -= srcsize;
   5879        }
   5880    }
   5881    cvt->len_cvt = dstsize;
   5882    if (cvt->filters[++cvt->filter_index]) {
   5883        cvt->filters[cvt->filter_index] (cvt, format);
   5884    }
   5885}
   5886
   5887static void SDLCALL
   5888SDL_Upsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5889{
   5890#if DEBUG_CONVERT
   5891    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 6 channels.\n", cvt->rate_incr);
   5892#endif
   5893
   5894    const int srcsize = cvt->len_cvt - 384;
   5895    const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
   5896    register int eps = 0;
   5897    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
   5898    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
   5899    const Sint32 *target = ((const Sint32 *) cvt->buf);
   5900    Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
   5901    Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
   5902    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
   5903    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
   5904    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
   5905    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
   5906    Sint32 last_sample5 = sample5;
   5907    Sint32 last_sample4 = sample4;
   5908    Sint32 last_sample3 = sample3;
   5909    Sint32 last_sample2 = sample2;
   5910    Sint32 last_sample1 = sample1;
   5911    Sint32 last_sample0 = sample0;
   5912    while (dst >= target) {
   5913        dst[5] = ((Sint32) SDL_SwapBE32(sample5));
   5914        dst[4] = ((Sint32) SDL_SwapBE32(sample4));
   5915        dst[3] = ((Sint32) SDL_SwapBE32(sample3));
   5916        dst[2] = ((Sint32) SDL_SwapBE32(sample2));
   5917        dst[1] = ((Sint32) SDL_SwapBE32(sample1));
   5918        dst[0] = ((Sint32) SDL_SwapBE32(sample0));
   5919        dst -= 6;
   5920        eps += srcsize;
   5921        if ((eps << 1) >= dstsize) {
   5922            src -= 6;
   5923            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
   5924            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
   5925            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
   5926            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
   5927            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   5928            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5929            last_sample5 = sample5;
   5930            last_sample4 = sample4;
   5931            last_sample3 = sample3;
   5932            last_sample2 = sample2;
   5933            last_sample1 = sample1;
   5934            last_sample0 = sample0;
   5935            eps -= dstsize;
   5936        }
   5937    }
   5938    cvt->len_cvt = dstsize;
   5939    if (cvt->filters[++cvt->filter_index]) {
   5940        cvt->filters[cvt->filter_index] (cvt, format);
   5941    }
   5942}
   5943
   5944static void SDLCALL
   5945SDL_Downsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   5946{
   5947#if DEBUG_CONVERT
   5948    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 6 channels.\n", cvt->rate_incr);
   5949#endif
   5950
   5951    const int srcsize = cvt->len_cvt - 384;
   5952    const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
   5953    register int eps = 0;
   5954    Sint32 *dst = (Sint32 *) cvt->buf;
   5955    const Sint32 *src = (Sint32 *) cvt->buf;
   5956    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
   5957    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
   5958    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
   5959    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
   5960    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
   5961    Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
   5962    Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
   5963    Sint32 last_sample0 = sample0;
   5964    Sint32 last_sample1 = sample1;
   5965    Sint32 last_sample2 = sample2;
   5966    Sint32 last_sample3 = sample3;
   5967    Sint32 last_sample4 = sample4;
   5968    Sint32 last_sample5 = sample5;
   5969    while (dst < target) {
   5970        src += 6;
   5971        eps += dstsize;
   5972        if ((eps << 1) >= srcsize) {
   5973            dst[0] = ((Sint32) SDL_SwapBE32(sample0));
   5974            dst[1] = ((Sint32) SDL_SwapBE32(sample1));
   5975            dst[2] = ((Sint32) SDL_SwapBE32(sample2));
   5976            dst[3] = ((Sint32) SDL_SwapBE32(sample3));
   5977            dst[4] = ((Sint32) SDL_SwapBE32(sample4));
   5978            dst[5] = ((Sint32) SDL_SwapBE32(sample5));
   5979            dst += 6;
   5980            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   5981            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   5982            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
   5983            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
   5984            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
   5985            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
   5986            last_sample0 = sample0;
   5987            last_sample1 = sample1;
   5988            last_sample2 = sample2;
   5989            last_sample3 = sample3;
   5990            last_sample4 = sample4;
   5991            last_sample5 = sample5;
   5992            eps -= srcsize;
   5993        }
   5994    }
   5995    cvt->len_cvt = dstsize;
   5996    if (cvt->filters[++cvt->filter_index]) {
   5997        cvt->filters[cvt->filter_index] (cvt, format);
   5998    }
   5999}
   6000
   6001static void SDLCALL
   6002SDL_Upsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6003{
   6004#if DEBUG_CONVERT
   6005    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 8 channels.\n", cvt->rate_incr);
   6006#endif
   6007
   6008    const int srcsize = cvt->len_cvt - 512;
   6009    const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
   6010    register int eps = 0;
   6011    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
   6012    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
   6013    const Sint32 *target = ((const Sint32 *) cvt->buf);
   6014    Sint32 sample7 = ((Sint32) SDL_SwapBE32(src[7]));
   6015    Sint32 sample6 = ((Sint32) SDL_SwapBE32(src[6]));
   6016    Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
   6017    Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
   6018    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
   6019    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
   6020    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
   6021    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
   6022    Sint32 last_sample7 = sample7;
   6023    Sint32 last_sample6 = sample6;
   6024    Sint32 last_sample5 = sample5;
   6025    Sint32 last_sample4 = sample4;
   6026    Sint32 last_sample3 = sample3;
   6027    Sint32 last_sample2 = sample2;
   6028    Sint32 last_sample1 = sample1;
   6029    Sint32 last_sample0 = sample0;
   6030    while (dst >= target) {
   6031        dst[7] = ((Sint32) SDL_SwapBE32(sample7));
   6032        dst[6] = ((Sint32) SDL_SwapBE32(sample6));
   6033        dst[5] = ((Sint32) SDL_SwapBE32(sample5));
   6034        dst[4] = ((Sint32) SDL_SwapBE32(sample4));
   6035        dst[3] = ((Sint32) SDL_SwapBE32(sample3));
   6036        dst[2] = ((Sint32) SDL_SwapBE32(sample2));
   6037        dst[1] = ((Sint32) SDL_SwapBE32(sample1));
   6038        dst[0] = ((Sint32) SDL_SwapBE32(sample0));
   6039        dst -= 8;
   6040        eps += srcsize;
   6041        if ((eps << 1) >= dstsize) {
   6042            src -= 8;
   6043            sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
   6044            sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
   6045            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
   6046            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
   6047            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
   6048            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
   6049            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   6050            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   6051            last_sample7 = sample7;
   6052            last_sample6 = sample6;
   6053            last_sample5 = sample5;
   6054            last_sample4 = sample4;
   6055            last_sample3 = sample3;
   6056            last_sample2 = sample2;
   6057            last_sample1 = sample1;
   6058            last_sample0 = sample0;
   6059            eps -= dstsize;
   6060        }
   6061    }
   6062    cvt->len_cvt = dstsize;
   6063    if (cvt->filters[++cvt->filter_index]) {
   6064        cvt->filters[cvt->filter_index] (cvt, format);
   6065    }
   6066}
   6067
   6068static void SDLCALL
   6069SDL_Downsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6070{
   6071#if DEBUG_CONVERT
   6072    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 8 channels.\n", cvt->rate_incr);
   6073#endif
   6074
   6075    const int srcsize = cvt->len_cvt - 512;
   6076    const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
   6077    register int eps = 0;
   6078    Sint32 *dst = (Sint32 *) cvt->buf;
   6079    const Sint32 *src = (Sint32 *) cvt->buf;
   6080    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
   6081    Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
   6082    Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
   6083    Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
   6084    Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
   6085    Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
   6086    Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
   6087    Sint32 sample6 = ((Sint32) SDL_SwapBE32(src[6]));
   6088    Sint32 sample7 = ((Sint32) SDL_SwapBE32(src[7]));
   6089    Sint32 last_sample0 = sample0;
   6090    Sint32 last_sample1 = sample1;
   6091    Sint32 last_sample2 = sample2;
   6092    Sint32 last_sample3 = sample3;
   6093    Sint32 last_sample4 = sample4;
   6094    Sint32 last_sample5 = sample5;
   6095    Sint32 last_sample6 = sample6;
   6096    Sint32 last_sample7 = sample7;
   6097    while (dst < target) {
   6098        src += 8;
   6099        eps += dstsize;
   6100        if ((eps << 1) >= srcsize) {
   6101            dst[0] = ((Sint32) SDL_SwapBE32(sample0));
   6102            dst[1] = ((Sint32) SDL_SwapBE32(sample1));
   6103            dst[2] = ((Sint32) SDL_SwapBE32(sample2));
   6104            dst[3] = ((Sint32) SDL_SwapBE32(sample3));
   6105            dst[4] = ((Sint32) SDL_SwapBE32(sample4));
   6106            dst[5] = ((Sint32) SDL_SwapBE32(sample5));
   6107            dst[6] = ((Sint32) SDL_SwapBE32(sample6));
   6108            dst[7] = ((Sint32) SDL_SwapBE32(sample7));
   6109            dst += 8;
   6110            sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
   6111            sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
   6112            sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
   6113            sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
   6114            sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
   6115            sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
   6116            sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
   6117            sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
   6118            last_sample0 = sample0;
   6119            last_sample1 = sample1;
   6120            last_sample2 = sample2;
   6121            last_sample3 = sample3;
   6122            last_sample4 = sample4;
   6123            last_sample5 = sample5;
   6124            last_sample6 = sample6;
   6125            last_sample7 = sample7;
   6126            eps -= srcsize;
   6127        }
   6128    }
   6129    cvt->len_cvt = dstsize;
   6130    if (cvt->filters[++cvt->filter_index]) {
   6131        cvt->filters[cvt->filter_index] (cvt, format);
   6132    }
   6133}
   6134
   6135static void SDLCALL
   6136SDL_Upsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6137{
   6138#if DEBUG_CONVERT
   6139    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 1 channels.\n", cvt->rate_incr);
   6140#endif
   6141
   6142    const int srcsize = cvt->len_cvt - 64;
   6143    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   6144    register int eps = 0;
   6145    float *dst = ((float *) (cvt->buf + dstsize)) - 1;
   6146    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
   6147    const float *target = ((const float *) cvt->buf);
   6148    float sample0 = SDL_SwapFloatLE(src[0]);
   6149    float last_sample0 = sample0;
   6150    while (dst >= target) {
   6151        dst[0] = SDL_SwapFloatLE(sample0);
   6152        dst--;
   6153        eps += srcsize;
   6154        if ((eps << 1) >= dstsize) {
   6155            src--;
   6156            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
   6157            last_sample0 = sample0;
   6158            eps -= dstsize;
   6159        }
   6160    }
   6161    cvt->len_cvt = dstsize;
   6162    if (cvt->filters[++cvt->filter_index]) {
   6163        cvt->filters[cvt->filter_index] (cvt, format);
   6164    }
   6165}
   6166
   6167static void SDLCALL
   6168SDL_Downsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6169{
   6170#if DEBUG_CONVERT
   6171    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 1 channels.\n", cvt->rate_incr);
   6172#endif
   6173
   6174    const int srcsize = cvt->len_cvt - 64;
   6175    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   6176    register int eps = 0;
   6177    float *dst = (float *) cvt->buf;
   6178    const float *src = (float *) cvt->buf;
   6179    const float *target = (const float *) (cvt->buf + dstsize);
   6180    float sample0 = SDL_SwapFloatLE(src[0]);
   6181    float last_sample0 = sample0;
   6182    while (dst < target) {
   6183        src++;
   6184        eps += dstsize;
   6185        if ((eps << 1) >= srcsize) {
   6186            dst[0] = SDL_SwapFloatLE(sample0);
   6187            dst++;
   6188            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
   6189            last_sample0 = sample0;
   6190            eps -= srcsize;
   6191        }
   6192    }
   6193    cvt->len_cvt = dstsize;
   6194    if (cvt->filters[++cvt->filter_index]) {
   6195        cvt->filters[cvt->filter_index] (cvt, format);
   6196    }
   6197}
   6198
   6199static void SDLCALL
   6200SDL_Upsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6201{
   6202#if DEBUG_CONVERT
   6203    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 2 channels.\n", cvt->rate_incr);
   6204#endif
   6205
   6206    const int srcsize = cvt->len_cvt - 128;
   6207    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   6208    register int eps = 0;
   6209    float *dst = ((float *) (cvt->buf + dstsize)) - 2;
   6210    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
   6211    const float *target = ((const float *) cvt->buf);
   6212    float sample1 = SDL_SwapFloatLE(src[1]);
   6213    float sample0 = SDL_SwapFloatLE(src[0]);
   6214    float last_sample1 = sample1;
   6215    float last_sample0 = sample0;
   6216    while (dst >= target) {
   6217        dst[1] = SDL_SwapFloatLE(sample1);
   6218        dst[0] = SDL_SwapFloatLE(sample0);
   6219        dst -= 2;
   6220        eps += srcsize;
   6221        if ((eps << 1) >= dstsize) {
   6222            src -= 2;
   6223            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
   6224            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
   6225            last_sample1 = sample1;
   6226            last_sample0 = sample0;
   6227            eps -= dstsize;
   6228        }
   6229    }
   6230    cvt->len_cvt = dstsize;
   6231    if (cvt->filters[++cvt->filter_index]) {
   6232        cvt->filters[cvt->filter_index] (cvt, format);
   6233    }
   6234}
   6235
   6236static void SDLCALL
   6237SDL_Downsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6238{
   6239#if DEBUG_CONVERT
   6240    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 2 channels.\n", cvt->rate_incr);
   6241#endif
   6242
   6243    const int srcsize = cvt->len_cvt - 128;
   6244    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   6245    register int eps = 0;
   6246    float *dst = (float *) cvt->buf;
   6247    const float *src = (float *) cvt->buf;
   6248    const float *target = (const float *) (cvt->buf + dstsize);
   6249    float sample0 = SDL_SwapFloatLE(src[0]);
   6250    float sample1 = SDL_SwapFloatLE(src[1]);
   6251    float last_sample0 = sample0;
   6252    float last_sample1 = sample1;
   6253    while (dst < target) {
   6254        src += 2;
   6255        eps += dstsize;
   6256        if ((eps << 1) >= srcsize) {
   6257            dst[0] = SDL_SwapFloatLE(sample0);
   6258            dst[1] = SDL_SwapFloatLE(sample1);
   6259            dst += 2;
   6260            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
   6261            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
   6262            last_sample0 = sample0;
   6263            last_sample1 = sample1;
   6264            eps -= srcsize;
   6265        }
   6266    }
   6267    cvt->len_cvt = dstsize;
   6268    if (cvt->filters[++cvt->filter_index]) {
   6269        cvt->filters[cvt->filter_index] (cvt, format);
   6270    }
   6271}
   6272
   6273static void SDLCALL
   6274SDL_Upsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6275{
   6276#if DEBUG_CONVERT
   6277    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 4 channels.\n", cvt->rate_incr);
   6278#endif
   6279
   6280    const int srcsize = cvt->len_cvt - 256;
   6281    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   6282    register int eps = 0;
   6283    float *dst = ((float *) (cvt->buf + dstsize)) - 4;
   6284    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
   6285    const float *target = ((const float *) cvt->buf);
   6286    float sample3 = SDL_SwapFloatLE(src[3]);
   6287    float sample2 = SDL_SwapFloatLE(src[2]);
   6288    float sample1 = SDL_SwapFloatLE(src[1]);
   6289    float sample0 = SDL_SwapFloatLE(src[0]);
   6290    float last_sample3 = sample3;
   6291    float last_sample2 = sample2;
   6292    float last_sample1 = sample1;
   6293    float last_sample0 = sample0;
   6294    while (dst >= target) {
   6295        dst[3] = SDL_SwapFloatLE(sample3);
   6296        dst[2] = SDL_SwapFloatLE(sample2);
   6297        dst[1] = SDL_SwapFloatLE(sample1);
   6298        dst[0] = SDL_SwapFloatLE(sample0);
   6299        dst -= 4;
   6300        eps += srcsize;
   6301        if ((eps << 1) >= dstsize) {
   6302            src -= 4;
   6303            sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
   6304            sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
   6305            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
   6306            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
   6307            last_sample3 = sample3;
   6308            last_sample2 = sample2;
   6309            last_sample1 = sample1;
   6310            last_sample0 = sample0;
   6311            eps -= dstsize;
   6312        }
   6313    }
   6314    cvt->len_cvt = dstsize;
   6315    if (cvt->filters[++cvt->filter_index]) {
   6316        cvt->filters[cvt->filter_index] (cvt, format);
   6317    }
   6318}
   6319
   6320static void SDLCALL
   6321SDL_Downsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6322{
   6323#if DEBUG_CONVERT
   6324    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 4 channels.\n", cvt->rate_incr);
   6325#endif
   6326
   6327    const int srcsize = cvt->len_cvt - 256;
   6328    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   6329    register int eps = 0;
   6330    float *dst = (float *) cvt->buf;
   6331    const float *src = (float *) cvt->buf;
   6332    const float *target = (const float *) (cvt->buf + dstsize);
   6333    float sample0 = SDL_SwapFloatLE(src[0]);
   6334    float sample1 = SDL_SwapFloatLE(src[1]);
   6335    float sample2 = SDL_SwapFloatLE(src[2]);
   6336    float sample3 = SDL_SwapFloatLE(src[3]);
   6337    float last_sample0 = sample0;
   6338    float last_sample1 = sample1;
   6339    float last_sample2 = sample2;
   6340    float last_sample3 = sample3;
   6341    while (dst < target) {
   6342        src += 4;
   6343        eps += dstsize;
   6344        if ((eps << 1) >= srcsize) {
   6345            dst[0] = SDL_SwapFloatLE(sample0);
   6346            dst[1] = SDL_SwapFloatLE(sample1);
   6347            dst[2] = SDL_SwapFloatLE(sample2);
   6348            dst[3] = SDL_SwapFloatLE(sample3);
   6349            dst += 4;
   6350            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
   6351            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
   6352            sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
   6353            sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
   6354            last_sample0 = sample0;
   6355            last_sample1 = sample1;
   6356            last_sample2 = sample2;
   6357            last_sample3 = sample3;
   6358            eps -= srcsize;
   6359        }
   6360    }
   6361    cvt->len_cvt = dstsize;
   6362    if (cvt->filters[++cvt->filter_index]) {
   6363        cvt->filters[cvt->filter_index] (cvt, format);
   6364    }
   6365}
   6366
   6367static void SDLCALL
   6368SDL_Upsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6369{
   6370#if DEBUG_CONVERT
   6371    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 6 channels.\n", cvt->rate_incr);
   6372#endif
   6373
   6374    const int srcsize = cvt->len_cvt - 384;
   6375    const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
   6376    register int eps = 0;
   6377    float *dst = ((float *) (cvt->buf + dstsize)) - 6;
   6378    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
   6379    const float *target = ((const float *) cvt->buf);
   6380    float sample5 = SDL_SwapFloatLE(src[5]);
   6381    float sample4 = SDL_SwapFloatLE(src[4]);
   6382    float sample3 = SDL_SwapFloatLE(src[3]);
   6383    float sample2 = SDL_SwapFloatLE(src[2]);
   6384    float sample1 = SDL_SwapFloatLE(src[1]);
   6385    float sample0 = SDL_SwapFloatLE(src[0]);
   6386    float last_sample5 = sample5;
   6387    float last_sample4 = sample4;
   6388    float last_sample3 = sample3;
   6389    float last_sample2 = sample2;
   6390    float last_sample1 = sample1;
   6391    float last_sample0 = sample0;
   6392    while (dst >= target) {
   6393        dst[5] = SDL_SwapFloatLE(sample5);
   6394        dst[4] = SDL_SwapFloatLE(sample4);
   6395        dst[3] = SDL_SwapFloatLE(sample3);
   6396        dst[2] = SDL_SwapFloatLE(sample2);
   6397        dst[1] = SDL_SwapFloatLE(sample1);
   6398        dst[0] = SDL_SwapFloatLE(sample0);
   6399        dst -= 6;
   6400        eps += srcsize;
   6401        if ((eps << 1) >= dstsize) {
   6402            src -= 6;
   6403            sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
   6404            sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
   6405            sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
   6406            sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
   6407            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
   6408            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
   6409            last_sample5 = sample5;
   6410            last_sample4 = sample4;
   6411            last_sample3 = sample3;
   6412            last_sample2 = sample2;
   6413            last_sample1 = sample1;
   6414            last_sample0 = sample0;
   6415            eps -= dstsize;
   6416        }
   6417    }
   6418    cvt->len_cvt = dstsize;
   6419    if (cvt->filters[++cvt->filter_index]) {
   6420        cvt->filters[cvt->filter_index] (cvt, format);
   6421    }
   6422}
   6423
   6424static void SDLCALL
   6425SDL_Downsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6426{
   6427#if DEBUG_CONVERT
   6428    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 6 channels.\n", cvt->rate_incr);
   6429#endif
   6430
   6431    const int srcsize = cvt->len_cvt - 384;
   6432    const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
   6433    register int eps = 0;
   6434    float *dst = (float *) cvt->buf;
   6435    const float *src = (float *) cvt->buf;
   6436    const float *target = (const float *) (cvt->buf + dstsize);
   6437    float sample0 = SDL_SwapFloatLE(src[0]);
   6438    float sample1 = SDL_SwapFloatLE(src[1]);
   6439    float sample2 = SDL_SwapFloatLE(src[2]);
   6440    float sample3 = SDL_SwapFloatLE(src[3]);
   6441    float sample4 = SDL_SwapFloatLE(src[4]);
   6442    float sample5 = SDL_SwapFloatLE(src[5]);
   6443    float last_sample0 = sample0;
   6444    float last_sample1 = sample1;
   6445    float last_sample2 = sample2;
   6446    float last_sample3 = sample3;
   6447    float last_sample4 = sample4;
   6448    float last_sample5 = sample5;
   6449    while (dst < target) {
   6450        src += 6;
   6451        eps += dstsize;
   6452        if ((eps << 1) >= srcsize) {
   6453            dst[0] = SDL_SwapFloatLE(sample0);
   6454            dst[1] = SDL_SwapFloatLE(sample1);
   6455            dst[2] = SDL_SwapFloatLE(sample2);
   6456            dst[3] = SDL_SwapFloatLE(sample3);
   6457            dst[4] = SDL_SwapFloatLE(sample4);
   6458            dst[5] = SDL_SwapFloatLE(sample5);
   6459            dst += 6;
   6460            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
   6461            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
   6462            sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
   6463            sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
   6464            sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
   6465            sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
   6466            last_sample0 = sample0;
   6467            last_sample1 = sample1;
   6468            last_sample2 = sample2;
   6469            last_sample3 = sample3;
   6470            last_sample4 = sample4;
   6471            last_sample5 = sample5;
   6472            eps -= srcsize;
   6473        }
   6474    }
   6475    cvt->len_cvt = dstsize;
   6476    if (cvt->filters[++cvt->filter_index]) {
   6477        cvt->filters[cvt->filter_index] (cvt, format);
   6478    }
   6479}
   6480
   6481static void SDLCALL
   6482SDL_Upsample_F32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6483{
   6484#if DEBUG_CONVERT
   6485    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 8 channels.\n", cvt->rate_incr);
   6486#endif
   6487
   6488    const int srcsize = cvt->len_cvt - 512;
   6489    const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
   6490    register int eps = 0;
   6491    float *dst = ((float *) (cvt->buf + dstsize)) - 8;
   6492    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
   6493    const float *target = ((const float *) cvt->buf);
   6494    float sample7 = SDL_SwapFloatLE(src[7]);
   6495    float sample6 = SDL_SwapFloatLE(src[6]);
   6496    float sample5 = SDL_SwapFloatLE(src[5]);
   6497    float sample4 = SDL_SwapFloatLE(src[4]);
   6498    float sample3 = SDL_SwapFloatLE(src[3]);
   6499    float sample2 = SDL_SwapFloatLE(src[2]);
   6500    float sample1 = SDL_SwapFloatLE(src[1]);
   6501    float sample0 = SDL_SwapFloatLE(src[0]);
   6502    float last_sample7 = sample7;
   6503    float last_sample6 = sample6;
   6504    float last_sample5 = sample5;
   6505    float last_sample4 = sample4;
   6506    float last_sample3 = sample3;
   6507    float last_sample2 = sample2;
   6508    float last_sample1 = sample1;
   6509    float last_sample0 = sample0;
   6510    while (dst >= target) {
   6511        dst[7] = SDL_SwapFloatLE(sample7);
   6512        dst[6] = SDL_SwapFloatLE(sample6);
   6513        dst[5] = SDL_SwapFloatLE(sample5);
   6514        dst[4] = SDL_SwapFloatLE(sample4);
   6515        dst[3] = SDL_SwapFloatLE(sample3);
   6516        dst[2] = SDL_SwapFloatLE(sample2);
   6517        dst[1] = SDL_SwapFloatLE(sample1);
   6518        dst[0] = SDL_SwapFloatLE(sample0);
   6519        dst -= 8;
   6520        eps += srcsize;
   6521        if ((eps << 1) >= dstsize) {
   6522            src -= 8;
   6523            sample7 = (float) ((((double) SDL_SwapFloatLE(src[7])) + ((double) last_sample7)) * 0.5);
   6524            sample6 = (float) ((((double) SDL_SwapFloatLE(src[6])) + ((double) last_sample6)) * 0.5);
   6525            sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
   6526            sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
   6527            sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
   6528            sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
   6529            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
   6530            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
   6531            last_sample7 = sample7;
   6532            last_sample6 = sample6;
   6533            last_sample5 = sample5;
   6534            last_sample4 = sample4;
   6535            last_sample3 = sample3;
   6536            last_sample2 = sample2;
   6537            last_sample1 = sample1;
   6538            last_sample0 = sample0;
   6539            eps -= dstsize;
   6540        }
   6541    }
   6542    cvt->len_cvt = dstsize;
   6543    if (cvt->filters[++cvt->filter_index]) {
   6544        cvt->filters[cvt->filter_index] (cvt, format);
   6545    }
   6546}
   6547
   6548static void SDLCALL
   6549SDL_Downsample_F32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6550{
   6551#if DEBUG_CONVERT
   6552    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 8 channels.\n", cvt->rate_incr);
   6553#endif
   6554
   6555    const int srcsize = cvt->len_cvt - 512;
   6556    const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
   6557    register int eps = 0;
   6558    float *dst = (float *) cvt->buf;
   6559    const float *src = (float *) cvt->buf;
   6560    const float *target = (const float *) (cvt->buf + dstsize);
   6561    float sample0 = SDL_SwapFloatLE(src[0]);
   6562    float sample1 = SDL_SwapFloatLE(src[1]);
   6563    float sample2 = SDL_SwapFloatLE(src[2]);
   6564    float sample3 = SDL_SwapFloatLE(src[3]);
   6565    float sample4 = SDL_SwapFloatLE(src[4]);
   6566    float sample5 = SDL_SwapFloatLE(src[5]);
   6567    float sample6 = SDL_SwapFloatLE(src[6]);
   6568    float sample7 = SDL_SwapFloatLE(src[7]);
   6569    float last_sample0 = sample0;
   6570    float last_sample1 = sample1;
   6571    float last_sample2 = sample2;
   6572    float last_sample3 = sample3;
   6573    float last_sample4 = sample4;
   6574    float last_sample5 = sample5;
   6575    float last_sample6 = sample6;
   6576    float last_sample7 = sample7;
   6577    while (dst < target) {
   6578        src += 8;
   6579        eps += dstsize;
   6580        if ((eps << 1) >= srcsize) {
   6581            dst[0] = SDL_SwapFloatLE(sample0);
   6582            dst[1] = SDL_SwapFloatLE(sample1);
   6583            dst[2] = SDL_SwapFloatLE(sample2);
   6584            dst[3] = SDL_SwapFloatLE(sample3);
   6585            dst[4] = SDL_SwapFloatLE(sample4);
   6586            dst[5] = SDL_SwapFloatLE(sample5);
   6587            dst[6] = SDL_SwapFloatLE(sample6);
   6588            dst[7] = SDL_SwapFloatLE(sample7);
   6589            dst += 8;
   6590            sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
   6591            sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
   6592            sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
   6593            sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
   6594            sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
   6595            sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
   6596            sample6 = (float) ((((double) SDL_SwapFloatLE(src[6])) + ((double) last_sample6)) * 0.5);
   6597            sample7 = (float) ((((double) SDL_SwapFloatLE(src[7])) + ((double) last_sample7)) * 0.5);
   6598            last_sample0 = sample0;
   6599            last_sample1 = sample1;
   6600            last_sample2 = sample2;
   6601            last_sample3 = sample3;
   6602            last_sample4 = sample4;
   6603            last_sample5 = sample5;
   6604            last_sample6 = sample6;
   6605            last_sample7 = sample7;
   6606            eps -= srcsize;
   6607        }
   6608    }
   6609    cvt->len_cvt = dstsize;
   6610    if (cvt->filters[++cvt->filter_index]) {
   6611        cvt->filters[cvt->filter_index] (cvt, format);
   6612    }
   6613}
   6614
   6615static void SDLCALL
   6616SDL_Upsample_F32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6617{
   6618#if DEBUG_CONVERT
   6619    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 1 channels.\n", cvt->rate_incr);
   6620#endif
   6621
   6622    const int srcsize = cvt->len_cvt - 64;
   6623    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   6624    register int eps = 0;
   6625    float *dst = ((float *) (cvt->buf + dstsize)) - 1;
   6626    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
   6627    const float *target = ((const float *) cvt->buf);
   6628    float sample0 = SDL_SwapFloatBE(src[0]);
   6629    float last_sample0 = sample0;
   6630    while (dst >= target) {
   6631        dst[0] = SDL_SwapFloatBE(sample0);
   6632        dst--;
   6633        eps += srcsize;
   6634        if ((eps << 1) >= dstsize) {
   6635            src--;
   6636            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
   6637            last_sample0 = sample0;
   6638            eps -= dstsize;
   6639        }
   6640    }
   6641    cvt->len_cvt = dstsize;
   6642    if (cvt->filters[++cvt->filter_index]) {
   6643        cvt->filters[cvt->filter_index] (cvt, format);
   6644    }
   6645}
   6646
   6647static void SDLCALL
   6648SDL_Downsample_F32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6649{
   6650#if DEBUG_CONVERT
   6651    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 1 channels.\n", cvt->rate_incr);
   6652#endif
   6653
   6654    const int srcsize = cvt->len_cvt - 64;
   6655    const int dstsize = (int) (((double)(cvt->len_cvt/4)) * cvt->rate_incr) * 4;
   6656    register int eps = 0;
   6657    float *dst = (float *) cvt->buf;
   6658    const float *src = (float *) cvt->buf;
   6659    const float *target = (const float *) (cvt->buf + dstsize);
   6660    float sample0 = SDL_SwapFloatBE(src[0]);
   6661    float last_sample0 = sample0;
   6662    while (dst < target) {
   6663        src++;
   6664        eps += dstsize;
   6665        if ((eps << 1) >= srcsize) {
   6666            dst[0] = SDL_SwapFloatBE(sample0);
   6667            dst++;
   6668            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
   6669            last_sample0 = sample0;
   6670            eps -= srcsize;
   6671        }
   6672    }
   6673    cvt->len_cvt = dstsize;
   6674    if (cvt->filters[++cvt->filter_index]) {
   6675        cvt->filters[cvt->filter_index] (cvt, format);
   6676    }
   6677}
   6678
   6679static void SDLCALL
   6680SDL_Upsample_F32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6681{
   6682#if DEBUG_CONVERT
   6683    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 2 channels.\n", cvt->rate_incr);
   6684#endif
   6685
   6686    const int srcsize = cvt->len_cvt - 128;
   6687    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   6688    register int eps = 0;
   6689    float *dst = ((float *) (cvt->buf + dstsize)) - 2;
   6690    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
   6691    const float *target = ((const float *) cvt->buf);
   6692    float sample1 = SDL_SwapFloatBE(src[1]);
   6693    float sample0 = SDL_SwapFloatBE(src[0]);
   6694    float last_sample1 = sample1;
   6695    float last_sample0 = sample0;
   6696    while (dst >= target) {
   6697        dst[1] = SDL_SwapFloatBE(sample1);
   6698        dst[0] = SDL_SwapFloatBE(sample0);
   6699        dst -= 2;
   6700        eps += srcsize;
   6701        if ((eps << 1) >= dstsize) {
   6702            src -= 2;
   6703            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
   6704            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
   6705            last_sample1 = sample1;
   6706            last_sample0 = sample0;
   6707            eps -= dstsize;
   6708        }
   6709    }
   6710    cvt->len_cvt = dstsize;
   6711    if (cvt->filters[++cvt->filter_index]) {
   6712        cvt->filters[cvt->filter_index] (cvt, format);
   6713    }
   6714}
   6715
   6716static void SDLCALL
   6717SDL_Downsample_F32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6718{
   6719#if DEBUG_CONVERT
   6720    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 2 channels.\n", cvt->rate_incr);
   6721#endif
   6722
   6723    const int srcsize = cvt->len_cvt - 128;
   6724    const int dstsize = (int) (((double)(cvt->len_cvt/8)) * cvt->rate_incr) * 8;
   6725    register int eps = 0;
   6726    float *dst = (float *) cvt->buf;
   6727    const float *src = (float *) cvt->buf;
   6728    const float *target = (const float *) (cvt->buf + dstsize);
   6729    float sample0 = SDL_SwapFloatBE(src[0]);
   6730    float sample1 = SDL_SwapFloatBE(src[1]);
   6731    float last_sample0 = sample0;
   6732    float last_sample1 = sample1;
   6733    while (dst < target) {
   6734        src += 2;
   6735        eps += dstsize;
   6736        if ((eps << 1) >= srcsize) {
   6737            dst[0] = SDL_SwapFloatBE(sample0);
   6738            dst[1] = SDL_SwapFloatBE(sample1);
   6739            dst += 2;
   6740            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
   6741            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
   6742            last_sample0 = sample0;
   6743            last_sample1 = sample1;
   6744            eps -= srcsize;
   6745        }
   6746    }
   6747    cvt->len_cvt = dstsize;
   6748    if (cvt->filters[++cvt->filter_index]) {
   6749        cvt->filters[cvt->filter_index] (cvt, format);
   6750    }
   6751}
   6752
   6753static void SDLCALL
   6754SDL_Upsample_F32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6755{
   6756#if DEBUG_CONVERT
   6757    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 4 channels.\n", cvt->rate_incr);
   6758#endif
   6759
   6760    const int srcsize = cvt->len_cvt - 256;
   6761    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   6762    register int eps = 0;
   6763    float *dst = ((float *) (cvt->buf + dstsize)) - 4;
   6764    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
   6765    const float *target = ((const float *) cvt->buf);
   6766    float sample3 = SDL_SwapFloatBE(src[3]);
   6767    float sample2 = SDL_SwapFloatBE(src[2]);
   6768    float sample1 = SDL_SwapFloatBE(src[1]);
   6769    float sample0 = SDL_SwapFloatBE(src[0]);
   6770    float last_sample3 = sample3;
   6771    float last_sample2 = sample2;
   6772    float last_sample1 = sample1;
   6773    float last_sample0 = sample0;
   6774    while (dst >= target) {
   6775        dst[3] = SDL_SwapFloatBE(sample3);
   6776        dst[2] = SDL_SwapFloatBE(sample2);
   6777        dst[1] = SDL_SwapFloatBE(sample1);
   6778        dst[0] = SDL_SwapFloatBE(sample0);
   6779        dst -= 4;
   6780        eps += srcsize;
   6781        if ((eps << 1) >= dstsize) {
   6782            src -= 4;
   6783            sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
   6784            sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
   6785            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
   6786            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
   6787            last_sample3 = sample3;
   6788            last_sample2 = sample2;
   6789            last_sample1 = sample1;
   6790            last_sample0 = sample0;
   6791            eps -= dstsize;
   6792        }
   6793    }
   6794    cvt->len_cvt = dstsize;
   6795    if (cvt->filters[++cvt->filter_index]) {
   6796        cvt->filters[cvt->filter_index] (cvt, format);
   6797    }
   6798}
   6799
   6800static void SDLCALL
   6801SDL_Downsample_F32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6802{
   6803#if DEBUG_CONVERT
   6804    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 4 channels.\n", cvt->rate_incr);
   6805#endif
   6806
   6807    const int srcsize = cvt->len_cvt - 256;
   6808    const int dstsize = (int) (((double)(cvt->len_cvt/16)) * cvt->rate_incr) * 16;
   6809    register int eps = 0;
   6810    float *dst = (float *) cvt->buf;
   6811    const float *src = (float *) cvt->buf;
   6812    const float *target = (const float *) (cvt->buf + dstsize);
   6813    float sample0 = SDL_SwapFloatBE(src[0]);
   6814    float sample1 = SDL_SwapFloatBE(src[1]);
   6815    float sample2 = SDL_SwapFloatBE(src[2]);
   6816    float sample3 = SDL_SwapFloatBE(src[3]);
   6817    float last_sample0 = sample0;
   6818    float last_sample1 = sample1;
   6819    float last_sample2 = sample2;
   6820    float last_sample3 = sample3;
   6821    while (dst < target) {
   6822        src += 4;
   6823        eps += dstsize;
   6824        if ((eps << 1) >= srcsize) {
   6825            dst[0] = SDL_SwapFloatBE(sample0);
   6826            dst[1] = SDL_SwapFloatBE(sample1);
   6827            dst[2] = SDL_SwapFloatBE(sample2);
   6828            dst[3] = SDL_SwapFloatBE(sample3);
   6829            dst += 4;
   6830            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
   6831            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
   6832            sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
   6833            sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
   6834            last_sample0 = sample0;
   6835            last_sample1 = sample1;
   6836            last_sample2 = sample2;
   6837            last_sample3 = sample3;
   6838            eps -= srcsize;
   6839        }
   6840    }
   6841    cvt->len_cvt = dstsize;
   6842    if (cvt->filters[++cvt->filter_index]) {
   6843        cvt->filters[cvt->filter_index] (cvt, format);
   6844    }
   6845}
   6846
   6847static void SDLCALL
   6848SDL_Upsample_F32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6849{
   6850#if DEBUG_CONVERT
   6851    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 6 channels.\n", cvt->rate_incr);
   6852#endif
   6853
   6854    const int srcsize = cvt->len_cvt - 384;
   6855    const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
   6856    register int eps = 0;
   6857    float *dst = ((float *) (cvt->buf + dstsize)) - 6;
   6858    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
   6859    const float *target = ((const float *) cvt->buf);
   6860    float sample5 = SDL_SwapFloatBE(src[5]);
   6861    float sample4 = SDL_SwapFloatBE(src[4]);
   6862    float sample3 = SDL_SwapFloatBE(src[3]);
   6863    float sample2 = SDL_SwapFloatBE(src[2]);
   6864    float sample1 = SDL_SwapFloatBE(src[1]);
   6865    float sample0 = SDL_SwapFloatBE(src[0]);
   6866    float last_sample5 = sample5;
   6867    float last_sample4 = sample4;
   6868    float last_sample3 = sample3;
   6869    float last_sample2 = sample2;
   6870    float last_sample1 = sample1;
   6871    float last_sample0 = sample0;
   6872    while (dst >= target) {
   6873        dst[5] = SDL_SwapFloatBE(sample5);
   6874        dst[4] = SDL_SwapFloatBE(sample4);
   6875        dst[3] = SDL_SwapFloatBE(sample3);
   6876        dst[2] = SDL_SwapFloatBE(sample2);
   6877        dst[1] = SDL_SwapFloatBE(sample1);
   6878        dst[0] = SDL_SwapFloatBE(sample0);
   6879        dst -= 6;
   6880        eps += srcsize;
   6881        if ((eps << 1) >= dstsize) {
   6882            src -= 6;
   6883            sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
   6884            sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
   6885            sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
   6886            sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
   6887            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
   6888            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
   6889            last_sample5 = sample5;
   6890            last_sample4 = sample4;
   6891            last_sample3 = sample3;
   6892            last_sample2 = sample2;
   6893            last_sample1 = sample1;
   6894            last_sample0 = sample0;
   6895            eps -= dstsize;
   6896        }
   6897    }
   6898    cvt->len_cvt = dstsize;
   6899    if (cvt->filters[++cvt->filter_index]) {
   6900        cvt->filters[cvt->filter_index] (cvt, format);
   6901    }
   6902}
   6903
   6904static void SDLCALL
   6905SDL_Downsample_F32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6906{
   6907#if DEBUG_CONVERT
   6908    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 6 channels.\n", cvt->rate_incr);
   6909#endif
   6910
   6911    const int srcsize = cvt->len_cvt - 384;
   6912    const int dstsize = (int) (((double)(cvt->len_cvt/24)) * cvt->rate_incr) * 24;
   6913    register int eps = 0;
   6914    float *dst = (float *) cvt->buf;
   6915    const float *src = (float *) cvt->buf;
   6916    const float *target = (const float *) (cvt->buf + dstsize);
   6917    float sample0 = SDL_SwapFloatBE(src[0]);
   6918    float sample1 = SDL_SwapFloatBE(src[1]);
   6919    float sample2 = SDL_SwapFloatBE(src[2]);
   6920    float sample3 = SDL_SwapFloatBE(src[3]);
   6921    float sample4 = SDL_SwapFloatBE(src[4]);
   6922    float sample5 = SDL_SwapFloatBE(src[5]);
   6923    float last_sample0 = sample0;
   6924    float last_sample1 = sample1;
   6925    float last_sample2 = sample2;
   6926    float last_sample3 = sample3;
   6927    float last_sample4 = sample4;
   6928    float last_sample5 = sample5;
   6929    while (dst < target) {
   6930        src += 6;
   6931        eps += dstsize;
   6932        if ((eps << 1) >= srcsize) {
   6933            dst[0] = SDL_SwapFloatBE(sample0);
   6934            dst[1] = SDL_SwapFloatBE(sample1);
   6935            dst[2] = SDL_SwapFloatBE(sample2);
   6936            dst[3] = SDL_SwapFloatBE(sample3);
   6937            dst[4] = SDL_SwapFloatBE(sample4);
   6938            dst[5] = SDL_SwapFloatBE(sample5);
   6939            dst += 6;
   6940            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
   6941            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
   6942            sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
   6943            sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
   6944            sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
   6945            sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
   6946            last_sample0 = sample0;
   6947            last_sample1 = sample1;
   6948            last_sample2 = sample2;
   6949            last_sample3 = sample3;
   6950            last_sample4 = sample4;
   6951            last_sample5 = sample5;
   6952            eps -= srcsize;
   6953        }
   6954    }
   6955    cvt->len_cvt = dstsize;
   6956    if (cvt->filters[++cvt->filter_index]) {
   6957        cvt->filters[cvt->filter_index] (cvt, format);
   6958    }
   6959}
   6960
   6961static void SDLCALL
   6962SDL_Upsample_F32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   6963{
   6964#if DEBUG_CONVERT
   6965    fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 8 channels.\n", cvt->rate_incr);
   6966#endif
   6967
   6968    const int srcsize = cvt->len_cvt - 512;
   6969    const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
   6970    register int eps = 0;
   6971    float *dst = ((float *) (cvt->buf + dstsize)) - 8;
   6972    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
   6973    const float *target = ((const float *) cvt->buf);
   6974    float sample7 = SDL_SwapFloatBE(src[7]);
   6975    float sample6 = SDL_SwapFloatBE(src[6]);
   6976    float sample5 = SDL_SwapFloatBE(src[5]);
   6977    float sample4 = SDL_SwapFloatBE(src[4]);
   6978    float sample3 = SDL_SwapFloatBE(src[3]);
   6979    float sample2 = SDL_SwapFloatBE(src[2]);
   6980    float sample1 = SDL_SwapFloatBE(src[1]);
   6981    float sample0 = SDL_SwapFloatBE(src[0]);
   6982    float last_sample7 = sample7;
   6983    float last_sample6 = sample6;
   6984    float last_sample5 = sample5;
   6985    float last_sample4 = sample4;
   6986    float last_sample3 = sample3;
   6987    float last_sample2 = sample2;
   6988    float last_sample1 = sample1;
   6989    float last_sample0 = sample0;
   6990    while (dst >= target) {
   6991        dst[7] = SDL_SwapFloatBE(sample7);
   6992        dst[6] = SDL_SwapFloatBE(sample6);
   6993        dst[5] = SDL_SwapFloatBE(sample5);
   6994        dst[4] = SDL_SwapFloatBE(sample4);
   6995        dst[3] = SDL_SwapFloatBE(sample3);
   6996        dst[2] = SDL_SwapFloatBE(sample2);
   6997        dst[1] = SDL_SwapFloatBE(sample1);
   6998        dst[0] = SDL_SwapFloatBE(sample0);
   6999        dst -= 8;
   7000        eps += srcsize;
   7001        if ((eps << 1) >= dstsize) {
   7002            src -= 8;
   7003            sample7 = (float) ((((double) SDL_SwapFloatBE(src[7])) + ((double) last_sample7)) * 0.5);
   7004            sample6 = (float) ((((double) SDL_SwapFloatBE(src[6])) + ((double) last_sample6)) * 0.5);
   7005            sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
   7006            sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
   7007            sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
   7008            sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
   7009            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
   7010            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
   7011            last_sample7 = sample7;
   7012            last_sample6 = sample6;
   7013            last_sample5 = sample5;
   7014            last_sample4 = sample4;
   7015            last_sample3 = sample3;
   7016            last_sample2 = sample2;
   7017            last_sample1 = sample1;
   7018            last_sample0 = sample0;
   7019            eps -= dstsize;
   7020        }
   7021    }
   7022    cvt->len_cvt = dstsize;
   7023    if (cvt->filters[++cvt->filter_index]) {
   7024        cvt->filters[cvt->filter_index] (cvt, format);
   7025    }
   7026}
   7027
   7028static void SDLCALL
   7029SDL_Downsample_F32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7030{
   7031#if DEBUG_CONVERT
   7032    fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 8 channels.\n", cvt->rate_incr);
   7033#endif
   7034
   7035    const int srcsize = cvt->len_cvt - 512;
   7036    const int dstsize = (int) (((double)(cvt->len_cvt/32)) * cvt->rate_incr) * 32;
   7037    register int eps = 0;
   7038    float *dst = (float *) cvt->buf;
   7039    const float *src = (float *) cvt->buf;
   7040    const float *target = (const float *) (cvt->buf + dstsize);
   7041    float sample0 = SDL_SwapFloatBE(src[0]);
   7042    float sample1 = SDL_SwapFloatBE(src[1]);
   7043    float sample2 = SDL_SwapFloatBE(src[2]);
   7044    float sample3 = SDL_SwapFloatBE(src[3]);
   7045    float sample4 = SDL_SwapFloatBE(src[4]);
   7046    float sample5 = SDL_SwapFloatBE(src[5]);
   7047    float sample6 = SDL_SwapFloatBE(src[6]);
   7048    float sample7 = SDL_SwapFloatBE(src[7]);
   7049    float last_sample0 = sample0;
   7050    float last_sample1 = sample1;
   7051    float last_sample2 = sample2;
   7052    float last_sample3 = sample3;
   7053    float last_sample4 = sample4;
   7054    float last_sample5 = sample5;
   7055    float last_sample6 = sample6;
   7056    float last_sample7 = sample7;
   7057    while (dst < target) {
   7058        src += 8;
   7059        eps += dstsize;
   7060        if ((eps << 1) >= srcsize) {
   7061            dst[0] = SDL_SwapFloatBE(sample0);
   7062            dst[1] = SDL_SwapFloatBE(sample1);
   7063            dst[2] = SDL_SwapFloatBE(sample2);
   7064            dst[3] = SDL_SwapFloatBE(sample3);
   7065            dst[4] = SDL_SwapFloatBE(sample4);
   7066            dst[5] = SDL_SwapFloatBE(sample5);
   7067            dst[6] = SDL_SwapFloatBE(sample6);
   7068            dst[7] = SDL_SwapFloatBE(sample7);
   7069            dst += 8;
   7070            sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
   7071            sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
   7072            sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
   7073            sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
   7074            sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
   7075            sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
   7076            sample6 = (float) ((((double) SDL_SwapFloatBE(src[6])) + ((double) last_sample6)) * 0.5);
   7077            sample7 = (float) ((((double) SDL_SwapFloatBE(src[7])) + ((double) last_sample7)) * 0.5);
   7078            last_sample0 = sample0;
   7079            last_sample1 = sample1;
   7080            last_sample2 = sample2;
   7081            last_sample3 = sample3;
   7082            last_sample4 = sample4;
   7083            last_sample5 = sample5;
   7084            last_sample6 = sample6;
   7085            last_sample7 = sample7;
   7086            eps -= srcsize;
   7087        }
   7088    }
   7089    cvt->len_cvt = dstsize;
   7090    if (cvt->filters[++cvt->filter_index]) {
   7091        cvt->filters[cvt->filter_index] (cvt, format);
   7092    }
   7093}
   7094
   7095
   7096#if !LESS_RESAMPLERS
   7097
   7098static void SDLCALL
   7099SDL_Upsample_U8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7100{
   7101#if DEBUG_CONVERT
   7102    fprintf(stderr, "Upsample (x2) AUDIO_U8, 1 channels.\n");
   7103#endif
   7104
   7105    const int dstsize = cvt->len_cvt * 2;
   7106    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1 * 2;
   7107    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   7108    const Uint8 *target = ((const Uint8 *) cvt->buf);
   7109    Sint16 last_sample0 = (Sint16) src[0];
   7110    while (dst >= target) {
   7111        const Sint16 sample0 = (Sint16) src[0];
   7112        src--;
   7113        dst[1] = (Uint8) ((sample0 + last_sample0) >> 1);
   7114        dst[0] = (Uint8) sample0;
   7115        last_sample0 = sample0;
   7116        dst -= 2;
   7117    }
   7118
   7119    cvt->len_cvt = dstsize;
   7120    if (cvt->filters[++cvt->filter_index]) {
   7121        cvt->filters[cvt->filter_index] (cvt, format);
   7122    }
   7123}
   7124
   7125static void SDLCALL
   7126SDL_Downsample_U8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7127{
   7128#if DEBUG_CONVERT
   7129    fprintf(stderr, "Downsample (x2) AUDIO_U8, 1 channels.\n");
   7130#endif
   7131
   7132    const int dstsize = cvt->len_cvt / 2;
   7133    Uint8 *dst = (Uint8 *) cvt->buf;
   7134    const Uint8 *src = (Uint8 *) cvt->buf;
   7135    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   7136    Sint16 last_sample0 = (Sint16) src[0];
   7137    while (dst < target) {
   7138        const Sint16 sample0 = (Sint16) src[0];
   7139        src += 2;
   7140        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
   7141        last_sample0 = sample0;
   7142        dst++;
   7143    }
   7144
   7145    cvt->len_cvt = dstsize;
   7146    if (cvt->filters[++cvt->filter_index]) {
   7147        cvt->filters[cvt->filter_index] (cvt, format);
   7148    }
   7149}
   7150
   7151static void SDLCALL
   7152SDL_Upsample_U8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7153{
   7154#if DEBUG_CONVERT
   7155    fprintf(stderr, "Upsample (x4) AUDIO_U8, 1 channels.\n");
   7156#endif
   7157
   7158    const int dstsize = cvt->len_cvt * 4;
   7159    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1 * 4;
   7160    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   7161    const Uint8 *target = ((const Uint8 *) cvt->buf);
   7162    Sint16 last_sample0 = (Sint16) src[0];
   7163    while (dst >= target) {
   7164        const Sint16 sample0 = (Sint16) src[0];
   7165        src--;
   7166        dst[3] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
   7167        dst[2] = (Uint8) ((sample0 + last_sample0) >> 1);
   7168        dst[1] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
   7169        dst[0] = (Uint8) sample0;
   7170        last_sample0 = sample0;
   7171        dst -= 4;
   7172    }
   7173
   7174    cvt->len_cvt = dstsize;
   7175    if (cvt->filters[++cvt->filter_index]) {
   7176        cvt->filters[cvt->filter_index] (cvt, format);
   7177    }
   7178}
   7179
   7180static void SDLCALL
   7181SDL_Downsample_U8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7182{
   7183#if DEBUG_CONVERT
   7184    fprintf(stderr, "Downsample (x4) AUDIO_U8, 1 channels.\n");
   7185#endif
   7186
   7187    const int dstsize = cvt->len_cvt / 4;
   7188    Uint8 *dst = (Uint8 *) cvt->buf;
   7189    const Uint8 *src = (Uint8 *) cvt->buf;
   7190    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   7191    Sint16 last_sample0 = (Sint16) src[0];
   7192    while (dst < target) {
   7193        const Sint16 sample0 = (Sint16) src[0];
   7194        src += 4;
   7195        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
   7196        last_sample0 = sample0;
   7197        dst++;
   7198    }
   7199
   7200    cvt->len_cvt = dstsize;
   7201    if (cvt->filters[++cvt->filter_index]) {
   7202        cvt->filters[cvt->filter_index] (cvt, format);
   7203    }
   7204}
   7205
   7206static void SDLCALL
   7207SDL_Upsample_U8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7208{
   7209#if DEBUG_CONVERT
   7210    fprintf(stderr, "Upsample (x2) AUDIO_U8, 2 channels.\n");
   7211#endif
   7212
   7213    const int dstsize = cvt->len_cvt * 2;
   7214    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2 * 2;
   7215    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
   7216    const Uint8 *target = ((const Uint8 *) cvt->buf);
   7217    Sint16 last_sample1 = (Sint16) src[1];
   7218    Sint16 last_sample0 = (Sint16) src[0];
   7219    while (dst >= target) {
   7220        const Sint16 sample1 = (Sint16) src[1];
   7221        const Sint16 sample0 = (Sint16) src[0];
   7222        src -= 2;
   7223        dst[3] = (Uint8) ((sample1 + last_sample1) >> 1);
   7224        dst[2] = (Uint8) ((sample0 + last_sample0) >> 1);
   7225        dst[1] = (Uint8) sample1;
   7226        dst[0] = (Uint8) sample0;
   7227        last_sample1 = sample1;
   7228        last_sample0 = sample0;
   7229        dst -= 4;
   7230    }
   7231
   7232    cvt->len_cvt = dstsize;
   7233    if (cvt->filters[++cvt->filter_index]) {
   7234        cvt->filters[cvt->filter_index] (cvt, format);
   7235    }
   7236}
   7237
   7238static void SDLCALL
   7239SDL_Downsample_U8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7240{
   7241#if DEBUG_CONVERT
   7242    fprintf(stderr, "Downsample (x2) AUDIO_U8, 2 channels.\n");
   7243#endif
   7244
   7245    const int dstsize = cvt->len_cvt / 2;
   7246    Uint8 *dst = (Uint8 *) cvt->buf;
   7247    const Uint8 *src = (Uint8 *) cvt->buf;
   7248    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   7249    Sint16 last_sample0 = (Sint16) src[0];
   7250    Sint16 last_sample1 = (Sint16) src[1];
   7251    while (dst < target) {
   7252        const Sint16 sample0 = (Sint16) src[0];
   7253        const Sint16 sample1 = (Sint16) src[1];
   7254        src += 4;
   7255        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
   7256        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
   7257        last_sample0 = sample0;
   7258        last_sample1 = sample1;
   7259        dst += 2;
   7260    }
   7261
   7262    cvt->len_cvt = dstsize;
   7263    if (cvt->filters[++cvt->filter_index]) {
   7264        cvt->filters[cvt->filter_index] (cvt, format);
   7265    }
   7266}
   7267
   7268static void SDLCALL
   7269SDL_Upsample_U8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7270{
   7271#if DEBUG_CONVERT
   7272    fprintf(stderr, "Upsample (x4) AUDIO_U8, 2 channels.\n");
   7273#endif
   7274
   7275    const int dstsize = cvt->len_cvt * 4;
   7276    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2 * 4;
   7277    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
   7278    const Uint8 *target = ((const Uint8 *) cvt->buf);
   7279    Sint16 last_sample1 = (Sint16) src[1];
   7280    Sint16 last_sample0 = (Sint16) src[0];
   7281    while (dst >= target) {
   7282        const Sint16 sample1 = (Sint16) src[1];
   7283        const Sint16 sample0 = (Sint16) src[0];
   7284        src -= 2;
   7285        dst[7] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
   7286        dst[6] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
   7287        dst[5] = (Uint8) ((sample1 + last_sample1) >> 1);
   7288        dst[4] = (Uint8) ((sample0 + last_sample0) >> 1);
   7289        dst[3] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
   7290        dst[2] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
   7291        dst[1] = (Uint8) sample1;
   7292        dst[0] = (Uint8) sample0;
   7293        last_sample1 = sample1;
   7294        last_sample0 = sample0;
   7295        dst -= 8;
   7296    }
   7297
   7298    cvt->len_cvt = dstsize;
   7299    if (cvt->filters[++cvt->filter_index]) {
   7300        cvt->filters[cvt->filter_index] (cvt, format);
   7301    }
   7302}
   7303
   7304static void SDLCALL
   7305SDL_Downsample_U8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7306{
   7307#if DEBUG_CONVERT
   7308    fprintf(stderr, "Downsample (x4) AUDIO_U8, 2 channels.\n");
   7309#endif
   7310
   7311    const int dstsize = cvt->len_cvt / 4;
   7312    Uint8 *dst = (Uint8 *) cvt->buf;
   7313    const Uint8 *src = (Uint8 *) cvt->buf;
   7314    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   7315    Sint16 last_sample0 = (Sint16) src[0];
   7316    Sint16 last_sample1 = (Sint16) src[1];
   7317    while (dst < target) {
   7318        const Sint16 sample0 = (Sint16) src[0];
   7319        const Sint16 sample1 = (Sint16) src[1];
   7320        src += 8;
   7321        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
   7322        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
   7323        last_sample0 = sample0;
   7324        last_sample1 = sample1;
   7325        dst += 2;
   7326    }
   7327
   7328    cvt->len_cvt = dstsize;
   7329    if (cvt->filters[++cvt->filter_index]) {
   7330        cvt->filters[cvt->filter_index] (cvt, format);
   7331    }
   7332}
   7333
   7334static void SDLCALL
   7335SDL_Upsample_U8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7336{
   7337#if DEBUG_CONVERT
   7338    fprintf(stderr, "Upsample (x2) AUDIO_U8, 4 channels.\n");
   7339#endif
   7340
   7341    const int dstsize = cvt->len_cvt * 2;
   7342    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4 * 2;
   7343    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
   7344    const Uint8 *target = ((const Uint8 *) cvt->buf);
   7345    Sint16 last_sample3 = (Sint16) src[3];
   7346    Sint16 last_sample2 = (Sint16) src[2];
   7347    Sint16 last_sample1 = (Sint16) src[1];
   7348    Sint16 last_sample0 = (Sint16) src[0];
   7349    while (dst >= target) {
   7350        const Sint16 sample3 = (Sint16) src[3];
   7351        const Sint16 sample2 = (Sint16) src[2];
   7352        const Sint16 sample1 = (Sint16) src[1];
   7353        const Sint16 sample0 = (Sint16) src[0];
   7354        src -= 4;
   7355        dst[7] = (Uint8) ((sample3 + last_sample3) >> 1);
   7356        dst[6] = (Uint8) ((sample2 + last_sample2) >> 1);
   7357        dst[5] = (Uint8) ((sample1 + last_sample1) >> 1);
   7358        dst[4] = (Uint8) ((sample0 + last_sample0) >> 1);
   7359        dst[3] = (Uint8) sample3;
   7360        dst[2] = (Uint8) sample2;
   7361        dst[1] = (Uint8) sample1;
   7362        dst[0] = (Uint8) sample0;
   7363        last_sample3 = sample3;
   7364        last_sample2 = sample2;
   7365        last_sample1 = sample1;
   7366        last_sample0 = sample0;
   7367        dst -= 8;
   7368    }
   7369
   7370    cvt->len_cvt = dstsize;
   7371    if (cvt->filters[++cvt->filter_index]) {
   7372        cvt->filters[cvt->filter_index] (cvt, format);
   7373    }
   7374}
   7375
   7376static void SDLCALL
   7377SDL_Downsample_U8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7378{
   7379#if DEBUG_CONVERT
   7380    fprintf(stderr, "Downsample (x2) AUDIO_U8, 4 channels.\n");
   7381#endif
   7382
   7383    const int dstsize = cvt->len_cvt / 2;
   7384    Uint8 *dst = (Uint8 *) cvt->buf;
   7385    const Uint8 *src = (Uint8 *) cvt->buf;
   7386    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   7387    Sint16 last_sample0 = (Sint16) src[0];
   7388    Sint16 last_sample1 = (Sint16) src[1];
   7389    Sint16 last_sample2 = (Sint16) src[2];
   7390    Sint16 last_sample3 = (Sint16) src[3];
   7391    while (dst < target) {
   7392        const Sint16 sample0 = (Sint16) src[0];
   7393        const Sint16 sample1 = (Sint16) src[1];
   7394        const Sint16 sample2 = (Sint16) src[2];
   7395        const Sint16 sample3 = (Sint16) src[3];
   7396        src += 8;
   7397        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
   7398        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
   7399        dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
   7400        dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
   7401        last_sample0 = sample0;
   7402        last_sample1 = sample1;
   7403        last_sample2 = sample2;
   7404        last_sample3 = sample3;
   7405        dst += 4;
   7406    }
   7407
   7408    cvt->len_cvt = dstsize;
   7409    if (cvt->filters[++cvt->filter_index]) {
   7410        cvt->filters[cvt->filter_index] (cvt, format);
   7411    }
   7412}
   7413
   7414static void SDLCALL
   7415SDL_Upsample_U8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7416{
   7417#if DEBUG_CONVERT
   7418    fprintf(stderr, "Upsample (x4) AUDIO_U8, 4 channels.\n");
   7419#endif
   7420
   7421    const int dstsize = cvt->len_cvt * 4;
   7422    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4 * 4;
   7423    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
   7424    const Uint8 *target = ((const Uint8 *) cvt->buf);
   7425    Sint16 last_sample3 = (Sint16) src[3];
   7426    Sint16 last_sample2 = (Sint16) src[2];
   7427    Sint16 last_sample1 = (Sint16) src[1];
   7428    Sint16 last_sample0 = (Sint16) src[0];
   7429    while (dst >= target) {
   7430        const Sint16 sample3 = (Sint16) src[3];
   7431        const Sint16 sample2 = (Sint16) src[2];
   7432        const Sint16 sample1 = (Sint16) src[1];
   7433        const Sint16 sample0 = (Sint16) src[0];
   7434        src -= 4;
   7435        dst[15] = (Uint8) ((sample3 + (3 * last_sample3)) >> 2);
   7436        dst[14] = (Uint8) ((sample2 + (3 * last_sample2)) >> 2);
   7437        dst[13] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
   7438        dst[12] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
   7439        dst[11] = (Uint8) ((sample3 + last_sample3) >> 1);
   7440        dst[10] = (Uint8) ((sample2 + last_sample2) >> 1);
   7441        dst[9] = (Uint8) ((sample1 + last_sample1) >> 1);
   7442        dst[8] = (Uint8) ((sample0 + last_sample0) >> 1);
   7443        dst[7] = (Uint8) (((3 * sample3) + last_sample3) >> 2);
   7444        dst[6] = (Uint8) (((3 * sample2) + last_sample2) >> 2);
   7445        dst[5] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
   7446        dst[4] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
   7447        dst[3] = (Uint8) sample3;
   7448        dst[2] = (Uint8) sample2;
   7449        dst[1] = (Uint8) sample1;
   7450        dst[0] = (Uint8) sample0;
   7451        last_sample3 = sample3;
   7452        last_sample2 = sample2;
   7453        last_sample1 = sample1;
   7454        last_sample0 = sample0;
   7455        dst -= 16;
   7456    }
   7457
   7458    cvt->len_cvt = dstsize;
   7459    if (cvt->filters[++cvt->filter_index]) {
   7460        cvt->filters[cvt->filter_index] (cvt, format);
   7461    }
   7462}
   7463
   7464static void SDLCALL
   7465SDL_Downsample_U8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7466{
   7467#if DEBUG_CONVERT
   7468    fprintf(stderr, "Downsample (x4) AUDIO_U8, 4 channels.\n");
   7469#endif
   7470
   7471    const int dstsize = cvt->len_cvt / 4;
   7472    Uint8 *dst = (Uint8 *) cvt->buf;
   7473    const Uint8 *src = (Uint8 *) cvt->buf;
   7474    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   7475    Sint16 last_sample0 = (Sint16) src[0];
   7476    Sint16 last_sample1 = (Sint16) src[1];
   7477    Sint16 last_sample2 = (Sint16) src[2];
   7478    Sint16 last_sample3 = (Sint16) src[3];
   7479    while (dst < target) {
   7480        const Sint16 sample0 = (Sint16) src[0];
   7481        const Sint16 sample1 = (Sint16) src[1];
   7482        const Sint16 sample2 = (Sint16) src[2];
   7483        const Sint16 sample3 = (Sint16) src[3];
   7484        src += 16;
   7485        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
   7486        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
   7487        dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
   7488        dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
   7489        last_sample0 = sample0;
   7490        last_sample1 = sample1;
   7491        last_sample2 = sample2;
   7492        last_sample3 = sample3;
   7493        dst += 4;
   7494    }
   7495
   7496    cvt->len_cvt = dstsize;
   7497    if (cvt->filters[++cvt->filter_index]) {
   7498        cvt->filters[cvt->filter_index] (cvt, format);
   7499    }
   7500}
   7501
   7502static void SDLCALL
   7503SDL_Upsample_U8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7504{
   7505#if DEBUG_CONVERT
   7506    fprintf(stderr, "Upsample (x2) AUDIO_U8, 6 channels.\n");
   7507#endif
   7508
   7509    const int dstsize = cvt->len_cvt * 2;
   7510    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6 * 2;
   7511    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
   7512    const Uint8 *target = ((const Uint8 *) cvt->buf);
   7513    Sint16 last_sample5 = (Sint16) src[5];
   7514    Sint16 last_sample4 = (Sint16) src[4];
   7515    Sint16 last_sample3 = (Sint16) src[3];
   7516    Sint16 last_sample2 = (Sint16) src[2];
   7517    Sint16 last_sample1 = (Sint16) src[1];
   7518    Sint16 last_sample0 = (Sint16) src[0];
   7519    while (dst >= target) {
   7520        const Sint16 sample5 = (Sint16) src[5];
   7521        const Sint16 sample4 = (Sint16) src[4];
   7522        const Sint16 sample3 = (Sint16) src[3];
   7523        const Sint16 sample2 = (Sint16) src[2];
   7524        const Sint16 sample1 = (Sint16) src[1];
   7525        const Sint16 sample0 = (Sint16) src[0];
   7526        src -= 6;
   7527        dst[11] = (Uint8) ((sample5 + last_sample5) >> 1);
   7528        dst[10] = (Uint8) ((sample4 + last_sample4) >> 1);
   7529        dst[9] = (Uint8) ((sample3 + last_sample3) >> 1);
   7530        dst[8] = (Uint8) ((sample2 + last_sample2) >> 1);
   7531        dst[7] = (Uint8) ((sample1 + last_sample1) >> 1);
   7532        dst[6] = (Uint8) ((sample0 + last_sample0) >> 1);
   7533        dst[5] = (Uint8) sample5;
   7534        dst[4] = (Uint8) sample4;
   7535        dst[3] = (Uint8) sample3;
   7536        dst[2] = (Uint8) sample2;
   7537        dst[1] = (Uint8) sample1;
   7538        dst[0] = (Uint8) sample0;
   7539        last_sample5 = sample5;
   7540        last_sample4 = sample4;
   7541        last_sample3 = sample3;
   7542        last_sample2 = sample2;
   7543        last_sample1 = sample1;
   7544        last_sample0 = sample0;
   7545        dst -= 12;
   7546    }
   7547
   7548    cvt->len_cvt = dstsize;
   7549    if (cvt->filters[++cvt->filter_index]) {
   7550        cvt->filters[cvt->filter_index] (cvt, format);
   7551    }
   7552}
   7553
   7554static void SDLCALL
   7555SDL_Downsample_U8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7556{
   7557#if DEBUG_CONVERT
   7558    fprintf(stderr, "Downsample (x2) AUDIO_U8, 6 channels.\n");
   7559#endif
   7560
   7561    const int dstsize = cvt->len_cvt / 2;
   7562    Uint8 *dst = (Uint8 *) cvt->buf;
   7563    const Uint8 *src = (Uint8 *) cvt->buf;
   7564    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   7565    Sint16 last_sample0 = (Sint16) src[0];
   7566    Sint16 last_sample1 = (Sint16) src[1];
   7567    Sint16 last_sample2 = (Sint16) src[2];
   7568    Sint16 last_sample3 = (Sint16) src[3];
   7569    Sint16 last_sample4 = (Sint16) src[4];
   7570    Sint16 last_sample5 = (Sint16) src[5];
   7571    while (dst < target) {
   7572        const Sint16 sample0 = (Sint16) src[0];
   7573        const Sint16 sample1 = (Sint16) src[1];
   7574        const Sint16 sample2 = (Sint16) src[2];
   7575        const Sint16 sample3 = (Sint16) src[3];
   7576        const Sint16 sample4 = (Sint16) src[4];
   7577        const Sint16 sample5 = (Sint16) src[5];
   7578        src += 12;
   7579        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
   7580        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
   7581        dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
   7582        dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
   7583        dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
   7584        dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
   7585        last_sample0 = sample0;
   7586        last_sample1 = sample1;
   7587        last_sample2 = sample2;
   7588        last_sample3 = sample3;
   7589        last_sample4 = sample4;
   7590        last_sample5 = sample5;
   7591        dst += 6;
   7592    }
   7593
   7594    cvt->len_cvt = dstsize;
   7595    if (cvt->filters[++cvt->filter_index]) {
   7596        cvt->filters[cvt->filter_index] (cvt, format);
   7597    }
   7598}
   7599
   7600static void SDLCALL
   7601SDL_Upsample_U8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7602{
   7603#if DEBUG_CONVERT
   7604    fprintf(stderr, "Upsample (x4) AUDIO_U8, 6 channels.\n");
   7605#endif
   7606
   7607    const int dstsize = cvt->len_cvt * 4;
   7608    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6 * 4;
   7609    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
   7610    const Uint8 *target = ((const Uint8 *) cvt->buf);
   7611    Sint16 last_sample5 = (Sint16) src[5];
   7612    Sint16 last_sample4 = (Sint16) src[4];
   7613    Sint16 last_sample3 = (Sint16) src[3];
   7614    Sint16 last_sample2 = (Sint16) src[2];
   7615    Sint16 last_sample1 = (Sint16) src[1];
   7616    Sint16 last_sample0 = (Sint16) src[0];
   7617    while (dst >= target) {
   7618        const Sint16 sample5 = (Sint16) src[5];
   7619        const Sint16 sample4 = (Sint16) src[4];
   7620        const Sint16 sample3 = (Sint16) src[3];
   7621        const Sint16 sample2 = (Sint16) src[2];
   7622        const Sint16 sample1 = (Sint16) src[1];
   7623        const Sint16 sample0 = (Sint16) src[0];
   7624        src -= 6;
   7625        dst[23] = (Uint8) ((sample5 + (3 * last_sample5)) >> 2);
   7626        dst[22] = (Uint8) ((sample4 + (3 * last_sample4)) >> 2);
   7627        dst[21] = (Uint8) ((sample3 + (3 * last_sample3)) >> 2);
   7628        dst[20] = (Uint8) ((sample2 + (3 * last_sample2)) >> 2);
   7629        dst[19] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
   7630        dst[18] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
   7631        dst[17] = (Uint8) ((sample5 + last_sample5) >> 1);
   7632        dst[16] = (Uint8) ((sample4 + last_sample4) >> 1);
   7633        dst[15] = (Uint8) ((sample3 + last_sample3) >> 1);
   7634        dst[14] = (Uint8) ((sample2 + last_sample2) >> 1);
   7635        dst[13] = (Uint8) ((sample1 + last_sample1) >> 1);
   7636        dst[12] = (Uint8) ((sample0 + last_sample0) >> 1);
   7637        dst[11] = (Uint8) (((3 * sample5) + last_sample5) >> 2);
   7638        dst[10] = (Uint8) (((3 * sample4) + last_sample4) >> 2);
   7639        dst[9] = (Uint8) (((3 * sample3) + last_sample3) >> 2);
   7640        dst[8] = (Uint8) (((3 * sample2) + last_sample2) >> 2);
   7641        dst[7] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
   7642        dst[6] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
   7643        dst[5] = (Uint8) sample5;
   7644        dst[4] = (Uint8) sample4;
   7645        dst[3] = (Uint8) sample3;
   7646        dst[2] = (Uint8) sample2;
   7647        dst[1] = (Uint8) sample1;
   7648        dst[0] = (Uint8) sample0;
   7649        last_sample5 = sample5;
   7650        last_sample4 = sample4;
   7651        last_sample3 = sample3;
   7652        last_sample2 = sample2;
   7653        last_sample1 = sample1;
   7654        last_sample0 = sample0;
   7655        dst -= 24;
   7656    }
   7657
   7658    cvt->len_cvt = dstsize;
   7659    if (cvt->filters[++cvt->filter_index]) {
   7660        cvt->filters[cvt->filter_index] (cvt, format);
   7661    }
   7662}
   7663
   7664static void SDLCALL
   7665SDL_Downsample_U8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7666{
   7667#if DEBUG_CONVERT
   7668    fprintf(stderr, "Downsample (x4) AUDIO_U8, 6 channels.\n");
   7669#endif
   7670
   7671    const int dstsize = cvt->len_cvt / 4;
   7672    Uint8 *dst = (Uint8 *) cvt->buf;
   7673    const Uint8 *src = (Uint8 *) cvt->buf;
   7674    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   7675    Sint16 last_sample0 = (Sint16) src[0];
   7676    Sint16 last_sample1 = (Sint16) src[1];
   7677    Sint16 last_sample2 = (Sint16) src[2];
   7678    Sint16 last_sample3 = (Sint16) src[3];
   7679    Sint16 last_sample4 = (Sint16) src[4];
   7680    Sint16 last_sample5 = (Sint16) src[5];
   7681    while (dst < target) {
   7682        const Sint16 sample0 = (Sint16) src[0];
   7683        const Sint16 sample1 = (Sint16) src[1];
   7684        const Sint16 sample2 = (Sint16) src[2];
   7685        const Sint16 sample3 = (Sint16) src[3];
   7686        const Sint16 sample4 = (Sint16) src[4];
   7687        const Sint16 sample5 = (Sint16) src[5];
   7688        src += 24;
   7689        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
   7690        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
   7691        dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
   7692        dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
   7693        dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
   7694        dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
   7695        last_sample0 = sample0;
   7696        last_sample1 = sample1;
   7697        last_sample2 = sample2;
   7698        last_sample3 = sample3;
   7699        last_sample4 = sample4;
   7700        last_sample5 = sample5;
   7701        dst += 6;
   7702    }
   7703
   7704    cvt->len_cvt = dstsize;
   7705    if (cvt->filters[++cvt->filter_index]) {
   7706        cvt->filters[cvt->filter_index] (cvt, format);
   7707    }
   7708}
   7709
   7710static void SDLCALL
   7711SDL_Upsample_U8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7712{
   7713#if DEBUG_CONVERT
   7714    fprintf(stderr, "Upsample (x2) AUDIO_U8, 8 channels.\n");
   7715#endif
   7716
   7717    const int dstsize = cvt->len_cvt * 2;
   7718    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8 * 2;
   7719    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
   7720    const Uint8 *target = ((const Uint8 *) cvt->buf);
   7721    Sint16 last_sample7 = (Sint16) src[7];
   7722    Sint16 last_sample6 = (Sint16) src[6];
   7723    Sint16 last_sample5 = (Sint16) src[5];
   7724    Sint16 last_sample4 = (Sint16) src[4];
   7725    Sint16 last_sample3 = (Sint16) src[3];
   7726    Sint16 last_sample2 = (Sint16) src[2];
   7727    Sint16 last_sample1 = (Sint16) src[1];
   7728    Sint16 last_sample0 = (Sint16) src[0];
   7729    while (dst >= target) {
   7730        const Sint16 sample7 = (Sint16) src[7];
   7731        const Sint16 sample6 = (Sint16) src[6];
   7732        const Sint16 sample5 = (Sint16) src[5];
   7733        const Sint16 sample4 = (Sint16) src[4];
   7734        const Sint16 sample3 = (Sint16) src[3];
   7735        const Sint16 sample2 = (Sint16) src[2];
   7736        const Sint16 sample1 = (Sint16) src[1];
   7737        const Sint16 sample0 = (Sint16) src[0];
   7738        src -= 8;
   7739        dst[15] = (Uint8) ((sample7 + last_sample7) >> 1);
   7740        dst[14] = (Uint8) ((sample6 + last_sample6) >> 1);
   7741        dst[13] = (Uint8) ((sample5 + last_sample5) >> 1);
   7742        dst[12] = (Uint8) ((sample4 + last_sample4) >> 1);
   7743        dst[11] = (Uint8) ((sample3 + last_sample3) >> 1);
   7744        dst[10] = (Uint8) ((sample2 + last_sample2) >> 1);
   7745        dst[9] = (Uint8) ((sample1 + last_sample1) >> 1);
   7746        dst[8] = (Uint8) ((sample0 + last_sample0) >> 1);
   7747        dst[7] = (Uint8) sample7;
   7748        dst[6] = (Uint8) sample6;
   7749        dst[5] = (Uint8) sample5;
   7750        dst[4] = (Uint8) sample4;
   7751        dst[3] = (Uint8) sample3;
   7752        dst[2] = (Uint8) sample2;
   7753        dst[1] = (Uint8) sample1;
   7754        dst[0] = (Uint8) sample0;
   7755        last_sample7 = sample7;
   7756        last_sample6 = sample6;
   7757        last_sample5 = sample5;
   7758        last_sample4 = sample4;
   7759        last_sample3 = sample3;
   7760        last_sample2 = sample2;
   7761        last_sample1 = sample1;
   7762        last_sample0 = sample0;
   7763        dst -= 16;
   7764    }
   7765
   7766    cvt->len_cvt = dstsize;
   7767    if (cvt->filters[++cvt->filter_index]) {
   7768        cvt->filters[cvt->filter_index] (cvt, format);
   7769    }
   7770}
   7771
   7772static void SDLCALL
   7773SDL_Downsample_U8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7774{
   7775#if DEBUG_CONVERT
   7776    fprintf(stderr, "Downsample (x2) AUDIO_U8, 8 channels.\n");
   7777#endif
   7778
   7779    const int dstsize = cvt->len_cvt / 2;
   7780    Uint8 *dst = (Uint8 *) cvt->buf;
   7781    const Uint8 *src = (Uint8 *) cvt->buf;
   7782    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   7783    Sint16 last_sample0 = (Sint16) src[0];
   7784    Sint16 last_sample1 = (Sint16) src[1];
   7785    Sint16 last_sample2 = (Sint16) src[2];
   7786    Sint16 last_sample3 = (Sint16) src[3];
   7787    Sint16 last_sample4 = (Sint16) src[4];
   7788    Sint16 last_sample5 = (Sint16) src[5];
   7789    Sint16 last_sample6 = (Sint16) src[6];
   7790    Sint16 last_sample7 = (Sint16) src[7];
   7791    while (dst < target) {
   7792        const Sint16 sample0 = (Sint16) src[0];
   7793        const Sint16 sample1 = (Sint16) src[1];
   7794        const Sint16 sample2 = (Sint16) src[2];
   7795        const Sint16 sample3 = (Sint16) src[3];
   7796        const Sint16 sample4 = (Sint16) src[4];
   7797        const Sint16 sample5 = (Sint16) src[5];
   7798        const Sint16 sample6 = (Sint16) src[6];
   7799        const Sint16 sample7 = (Sint16) src[7];
   7800        src += 16;
   7801        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
   7802        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
   7803        dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
   7804        dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
   7805        dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
   7806        dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
   7807        dst[6] = (Uint8) ((sample6 + last_sample6) >> 1);
   7808        dst[7] = (Uint8) ((sample7 + last_sample7) >> 1);
   7809        last_sample0 = sample0;
   7810        last_sample1 = sample1;
   7811        last_sample2 = sample2;
   7812        last_sample3 = sample3;
   7813        last_sample4 = sample4;
   7814        last_sample5 = sample5;
   7815        last_sample6 = sample6;
   7816        last_sample7 = sample7;
   7817        dst += 8;
   7818    }
   7819
   7820    cvt->len_cvt = dstsize;
   7821    if (cvt->filters[++cvt->filter_index]) {
   7822        cvt->filters[cvt->filter_index] (cvt, format);
   7823    }
   7824}
   7825
   7826static void SDLCALL
   7827SDL_Upsample_U8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7828{
   7829#if DEBUG_CONVERT
   7830    fprintf(stderr, "Upsample (x4) AUDIO_U8, 8 channels.\n");
   7831#endif
   7832
   7833    const int dstsize = cvt->len_cvt * 4;
   7834    Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8 * 4;
   7835    const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
   7836    const Uint8 *target = ((const Uint8 *) cvt->buf);
   7837    Sint16 last_sample7 = (Sint16) src[7];
   7838    Sint16 last_sample6 = (Sint16) src[6];
   7839    Sint16 last_sample5 = (Sint16) src[5];
   7840    Sint16 last_sample4 = (Sint16) src[4];
   7841    Sint16 last_sample3 = (Sint16) src[3];
   7842    Sint16 last_sample2 = (Sint16) src[2];
   7843    Sint16 last_sample1 = (Sint16) src[1];
   7844    Sint16 last_sample0 = (Sint16) src[0];
   7845    while (dst >= target) {
   7846        const Sint16 sample7 = (Sint16) src[7];
   7847        const Sint16 sample6 = (Sint16) src[6];
   7848        const Sint16 sample5 = (Sint16) src[5];
   7849        const Sint16 sample4 = (Sint16) src[4];
   7850        const Sint16 sample3 = (Sint16) src[3];
   7851        const Sint16 sample2 = (Sint16) src[2];
   7852        const Sint16 sample1 = (Sint16) src[1];
   7853        const Sint16 sample0 = (Sint16) src[0];
   7854        src -= 8;
   7855        dst[31] = (Uint8) ((sample7 + (3 * last_sample7)) >> 2);
   7856        dst[30] = (Uint8) ((sample6 + (3 * last_sample6)) >> 2);
   7857        dst[29] = (Uint8) ((sample5 + (3 * last_sample5)) >> 2);
   7858        dst[28] = (Uint8) ((sample4 + (3 * last_sample4)) >> 2);
   7859        dst[27] = (Uint8) ((sample3 + (3 * last_sample3)) >> 2);
   7860        dst[26] = (Uint8) ((sample2 + (3 * last_sample2)) >> 2);
   7861        dst[25] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
   7862        dst[24] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
   7863        dst[23] = (Uint8) ((sample7 + last_sample7) >> 1);
   7864        dst[22] = (Uint8) ((sample6 + last_sample6) >> 1);
   7865        dst[21] = (Uint8) ((sample5 + last_sample5) >> 1);
   7866        dst[20] = (Uint8) ((sample4 + last_sample4) >> 1);
   7867        dst[19] = (Uint8) ((sample3 + last_sample3) >> 1);
   7868        dst[18] = (Uint8) ((sample2 + last_sample2) >> 1);
   7869        dst[17] = (Uint8) ((sample1 + last_sample1) >> 1);
   7870        dst[16] = (Uint8) ((sample0 + last_sample0) >> 1);
   7871        dst[15] = (Uint8) (((3 * sample7) + last_sample7) >> 2);
   7872        dst[14] = (Uint8) (((3 * sample6) + last_sample6) >> 2);
   7873        dst[13] = (Uint8) (((3 * sample5) + last_sample5) >> 2);
   7874        dst[12] = (Uint8) (((3 * sample4) + last_sample4) >> 2);
   7875        dst[11] = (Uint8) (((3 * sample3) + last_sample3) >> 2);
   7876        dst[10] = (Uint8) (((3 * sample2) + last_sample2) >> 2);
   7877        dst[9] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
   7878        dst[8] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
   7879        dst[7] = (Uint8) sample7;
   7880        dst[6] = (Uint8) sample6;
   7881        dst[5] = (Uint8) sample5;
   7882        dst[4] = (Uint8) sample4;
   7883        dst[3] = (Uint8) sample3;
   7884        dst[2] = (Uint8) sample2;
   7885        dst[1] = (Uint8) sample1;
   7886        dst[0] = (Uint8) sample0;
   7887        last_sample7 = sample7;
   7888        last_sample6 = sample6;
   7889        last_sample5 = sample5;
   7890        last_sample4 = sample4;
   7891        last_sample3 = sample3;
   7892        last_sample2 = sample2;
   7893        last_sample1 = sample1;
   7894        last_sample0 = sample0;
   7895        dst -= 32;
   7896    }
   7897
   7898    cvt->len_cvt = dstsize;
   7899    if (cvt->filters[++cvt->filter_index]) {
   7900        cvt->filters[cvt->filter_index] (cvt, format);
   7901    }
   7902}
   7903
   7904static void SDLCALL
   7905SDL_Downsample_U8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7906{
   7907#if DEBUG_CONVERT
   7908    fprintf(stderr, "Downsample (x4) AUDIO_U8, 8 channels.\n");
   7909#endif
   7910
   7911    const int dstsize = cvt->len_cvt / 4;
   7912    Uint8 *dst = (Uint8 *) cvt->buf;
   7913    const Uint8 *src = (Uint8 *) cvt->buf;
   7914    const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
   7915    Sint16 last_sample0 = (Sint16) src[0];
   7916    Sint16 last_sample1 = (Sint16) src[1];
   7917    Sint16 last_sample2 = (Sint16) src[2];
   7918    Sint16 last_sample3 = (Sint16) src[3];
   7919    Sint16 last_sample4 = (Sint16) src[4];
   7920    Sint16 last_sample5 = (Sint16) src[5];
   7921    Sint16 last_sample6 = (Sint16) src[6];
   7922    Sint16 last_sample7 = (Sint16) src[7];
   7923    while (dst < target) {
   7924        const Sint16 sample0 = (Sint16) src[0];
   7925        const Sint16 sample1 = (Sint16) src[1];
   7926        const Sint16 sample2 = (Sint16) src[2];
   7927        const Sint16 sample3 = (Sint16) src[3];
   7928        const Sint16 sample4 = (Sint16) src[4];
   7929        const Sint16 sample5 = (Sint16) src[5];
   7930        const Sint16 sample6 = (Sint16) src[6];
   7931        const Sint16 sample7 = (Sint16) src[7];
   7932        src += 32;
   7933        dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
   7934        dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
   7935        dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
   7936        dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
   7937        dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
   7938        dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
   7939        dst[6] = (Uint8) ((sample6 + last_sample6) >> 1);
   7940        dst[7] = (Uint8) ((sample7 + last_sample7) >> 1);
   7941        last_sample0 = sample0;
   7942        last_sample1 = sample1;
   7943        last_sample2 = sample2;
   7944        last_sample3 = sample3;
   7945        last_sample4 = sample4;
   7946        last_sample5 = sample5;
   7947        last_sample6 = sample6;
   7948        last_sample7 = sample7;
   7949        dst += 8;
   7950    }
   7951
   7952    cvt->len_cvt = dstsize;
   7953    if (cvt->filters[++cvt->filter_index]) {
   7954        cvt->filters[cvt->filter_index] (cvt, format);
   7955    }
   7956}
   7957
   7958static void SDLCALL
   7959SDL_Upsample_S8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7960{
   7961#if DEBUG_CONVERT
   7962    fprintf(stderr, "Upsample (x2) AUDIO_S8, 1 channels.\n");
   7963#endif
   7964
   7965    const int dstsize = cvt->len_cvt * 2;
   7966    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1 * 2;
   7967    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   7968    const Sint8 *target = ((const Sint8 *) cvt->buf);
   7969    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   7970    while (dst >= target) {
   7971        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   7972        src--;
   7973        dst[1] = (Sint8) ((sample0 + last_sample0) >> 1);
   7974        dst[0] = (Sint8) sample0;
   7975        last_sample0 = sample0;
   7976        dst -= 2;
   7977    }
   7978
   7979    cvt->len_cvt = dstsize;
   7980    if (cvt->filters[++cvt->filter_index]) {
   7981        cvt->filters[cvt->filter_index] (cvt, format);
   7982    }
   7983}
   7984
   7985static void SDLCALL
   7986SDL_Downsample_S8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   7987{
   7988#if DEBUG_CONVERT
   7989    fprintf(stderr, "Downsample (x2) AUDIO_S8, 1 channels.\n");
   7990#endif
   7991
   7992    const int dstsize = cvt->len_cvt / 2;
   7993    Sint8 *dst = (Sint8 *) cvt->buf;
   7994    const Sint8 *src = (Sint8 *) cvt->buf;
   7995    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   7996    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   7997    while (dst < target) {
   7998        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   7999        src += 2;
   8000        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
   8001        last_sample0 = sample0;
   8002        dst++;
   8003    }
   8004
   8005    cvt->len_cvt = dstsize;
   8006    if (cvt->filters[++cvt->filter_index]) {
   8007        cvt->filters[cvt->filter_index] (cvt, format);
   8008    }
   8009}
   8010
   8011static void SDLCALL
   8012SDL_Upsample_S8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8013{
   8014#if DEBUG_CONVERT
   8015    fprintf(stderr, "Upsample (x4) AUDIO_S8, 1 channels.\n");
   8016#endif
   8017
   8018    const int dstsize = cvt->len_cvt * 4;
   8019    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1 * 4;
   8020    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
   8021    const Sint8 *target = ((const Sint8 *) cvt->buf);
   8022    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8023    while (dst >= target) {
   8024        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8025        src--;
   8026        dst[3] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
   8027        dst[2] = (Sint8) ((sample0 + last_sample0) >> 1);
   8028        dst[1] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
   8029        dst[0] = (Sint8) sample0;
   8030        last_sample0 = sample0;
   8031        dst -= 4;
   8032    }
   8033
   8034    cvt->len_cvt = dstsize;
   8035    if (cvt->filters[++cvt->filter_index]) {
   8036        cvt->filters[cvt->filter_index] (cvt, format);
   8037    }
   8038}
   8039
   8040static void SDLCALL
   8041SDL_Downsample_S8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8042{
   8043#if DEBUG_CONVERT
   8044    fprintf(stderr, "Downsample (x4) AUDIO_S8, 1 channels.\n");
   8045#endif
   8046
   8047    const int dstsize = cvt->len_cvt / 4;
   8048    Sint8 *dst = (Sint8 *) cvt->buf;
   8049    const Sint8 *src = (Sint8 *) cvt->buf;
   8050    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   8051    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8052    while (dst < target) {
   8053        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8054        src += 4;
   8055        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
   8056        last_sample0 = sample0;
   8057        dst++;
   8058    }
   8059
   8060    cvt->len_cvt = dstsize;
   8061    if (cvt->filters[++cvt->filter_index]) {
   8062        cvt->filters[cvt->filter_index] (cvt, format);
   8063    }
   8064}
   8065
   8066static void SDLCALL
   8067SDL_Upsample_S8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8068{
   8069#if DEBUG_CONVERT
   8070    fprintf(stderr, "Upsample (x2) AUDIO_S8, 2 channels.\n");
   8071#endif
   8072
   8073    const int dstsize = cvt->len_cvt * 2;
   8074    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2 * 2;
   8075    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
   8076    const Sint8 *target = ((const Sint8 *) cvt->buf);
   8077    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8078    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8079    while (dst >= target) {
   8080        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8081        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8082        src -= 2;
   8083        dst[3] = (Sint8) ((sample1 + last_sample1) >> 1);
   8084        dst[2] = (Sint8) ((sample0 + last_sample0) >> 1);
   8085        dst[1] = (Sint8) sample1;
   8086        dst[0] = (Sint8) sample0;
   8087        last_sample1 = sample1;
   8088        last_sample0 = sample0;
   8089        dst -= 4;
   8090    }
   8091
   8092    cvt->len_cvt = dstsize;
   8093    if (cvt->filters[++cvt->filter_index]) {
   8094        cvt->filters[cvt->filter_index] (cvt, format);
   8095    }
   8096}
   8097
   8098static void SDLCALL
   8099SDL_Downsample_S8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8100{
   8101#if DEBUG_CONVERT
   8102    fprintf(stderr, "Downsample (x2) AUDIO_S8, 2 channels.\n");
   8103#endif
   8104
   8105    const int dstsize = cvt->len_cvt / 2;
   8106    Sint8 *dst = (Sint8 *) cvt->buf;
   8107    const Sint8 *src = (Sint8 *) cvt->buf;
   8108    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   8109    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8110    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8111    while (dst < target) {
   8112        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8113        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8114        src += 4;
   8115        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
   8116        dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
   8117        last_sample0 = sample0;
   8118        last_sample1 = sample1;
   8119        dst += 2;
   8120    }
   8121
   8122    cvt->len_cvt = dstsize;
   8123    if (cvt->filters[++cvt->filter_index]) {
   8124        cvt->filters[cvt->filter_index] (cvt, format);
   8125    }
   8126}
   8127
   8128static void SDLCALL
   8129SDL_Upsample_S8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8130{
   8131#if DEBUG_CONVERT
   8132    fprintf(stderr, "Upsample (x4) AUDIO_S8, 2 channels.\n");
   8133#endif
   8134
   8135    const int dstsize = cvt->len_cvt * 4;
   8136    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2 * 4;
   8137    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
   8138    const Sint8 *target = ((const Sint8 *) cvt->buf);
   8139    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8140    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8141    while (dst >= target) {
   8142        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8143        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8144        src -= 2;
   8145        dst[7] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
   8146        dst[6] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
   8147        dst[5] = (Sint8) ((sample1 + last_sample1) >> 1);
   8148        dst[4] = (Sint8) ((sample0 + last_sample0) >> 1);
   8149        dst[3] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
   8150        dst[2] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
   8151        dst[1] = (Sint8) sample1;
   8152        dst[0] = (Sint8) sample0;
   8153        last_sample1 = sample1;
   8154        last_sample0 = sample0;
   8155        dst -= 8;
   8156    }
   8157
   8158    cvt->len_cvt = dstsize;
   8159    if (cvt->filters[++cvt->filter_index]) {
   8160        cvt->filters[cvt->filter_index] (cvt, format);
   8161    }
   8162}
   8163
   8164static void SDLCALL
   8165SDL_Downsample_S8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8166{
   8167#if DEBUG_CONVERT
   8168    fprintf(stderr, "Downsample (x4) AUDIO_S8, 2 channels.\n");
   8169#endif
   8170
   8171    const int dstsize = cvt->len_cvt / 4;
   8172    Sint8 *dst = (Sint8 *) cvt->buf;
   8173    const Sint8 *src = (Sint8 *) cvt->buf;
   8174    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   8175    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8176    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8177    while (dst < target) {
   8178        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8179        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8180        src += 8;
   8181        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
   8182        dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
   8183        last_sample0 = sample0;
   8184        last_sample1 = sample1;
   8185        dst += 2;
   8186    }
   8187
   8188    cvt->len_cvt = dstsize;
   8189    if (cvt->filters[++cvt->filter_index]) {
   8190        cvt->filters[cvt->filter_index] (cvt, format);
   8191    }
   8192}
   8193
   8194static void SDLCALL
   8195SDL_Upsample_S8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8196{
   8197#if DEBUG_CONVERT
   8198    fprintf(stderr, "Upsample (x2) AUDIO_S8, 4 channels.\n");
   8199#endif
   8200
   8201    const int dstsize = cvt->len_cvt * 2;
   8202    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4 * 2;
   8203    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
   8204    const Sint8 *target = ((const Sint8 *) cvt->buf);
   8205    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
   8206    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
   8207    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8208    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8209    while (dst >= target) {
   8210        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
   8211        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
   8212        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8213        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8214        src -= 4;
   8215        dst[7] = (Sint8) ((sample3 + last_sample3) >> 1);
   8216        dst[6] = (Sint8) ((sample2 + last_sample2) >> 1);
   8217        dst[5] = (Sint8) ((sample1 + last_sample1) >> 1);
   8218        dst[4] = (Sint8) ((sample0 + last_sample0) >> 1);
   8219        dst[3] = (Sint8) sample3;
   8220        dst[2] = (Sint8) sample2;
   8221        dst[1] = (Sint8) sample1;
   8222        dst[0] = (Sint8) sample0;
   8223        last_sample3 = sample3;
   8224        last_sample2 = sample2;
   8225        last_sample1 = sample1;
   8226        last_sample0 = sample0;
   8227        dst -= 8;
   8228    }
   8229
   8230    cvt->len_cvt = dstsize;
   8231    if (cvt->filters[++cvt->filter_index]) {
   8232        cvt->filters[cvt->filter_index] (cvt, format);
   8233    }
   8234}
   8235
   8236static void SDLCALL
   8237SDL_Downsample_S8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8238{
   8239#if DEBUG_CONVERT
   8240    fprintf(stderr, "Downsample (x2) AUDIO_S8, 4 channels.\n");
   8241#endif
   8242
   8243    const int dstsize = cvt->len_cvt / 2;
   8244    Sint8 *dst = (Sint8 *) cvt->buf;
   8245    const Sint8 *src = (Sint8 *) cvt->buf;
   8246    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   8247    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8248    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8249    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
   8250    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
   8251    while (dst < target) {
   8252        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8253        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8254        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
   8255        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
   8256        src += 8;
   8257        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
   8258        dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
   8259        dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
   8260        dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
   8261        last_sample0 = sample0;
   8262        last_sample1 = sample1;
   8263        last_sample2 = sample2;
   8264        last_sample3 = sample3;
   8265        dst += 4;
   8266    }
   8267
   8268    cvt->len_cvt = dstsize;
   8269    if (cvt->filters[++cvt->filter_index]) {
   8270        cvt->filters[cvt->filter_index] (cvt, format);
   8271    }
   8272}
   8273
   8274static void SDLCALL
   8275SDL_Upsample_S8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8276{
   8277#if DEBUG_CONVERT
   8278    fprintf(stderr, "Upsample (x4) AUDIO_S8, 4 channels.\n");
   8279#endif
   8280
   8281    const int dstsize = cvt->len_cvt * 4;
   8282    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4 * 4;
   8283    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
   8284    const Sint8 *target = ((const Sint8 *) cvt->buf);
   8285    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
   8286    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
   8287    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8288    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8289    while (dst >= target) {
   8290        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
   8291        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
   8292        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8293        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8294        src -= 4;
   8295        dst[15] = (Sint8) ((sample3 + (3 * last_sample3)) >> 2);
   8296        dst[14] = (Sint8) ((sample2 + (3 * last_sample2)) >> 2);
   8297        dst[13] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
   8298        dst[12] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
   8299        dst[11] = (Sint8) ((sample3 + last_sample3) >> 1);
   8300        dst[10] = (Sint8) ((sample2 + last_sample2) >> 1);
   8301        dst[9] = (Sint8) ((sample1 + last_sample1) >> 1);
   8302        dst[8] = (Sint8) ((sample0 + last_sample0) >> 1);
   8303        dst[7] = (Sint8) (((3 * sample3) + last_sample3) >> 2);
   8304        dst[6] = (Sint8) (((3 * sample2) + last_sample2) >> 2);
   8305        dst[5] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
   8306        dst[4] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
   8307        dst[3] = (Sint8) sample3;
   8308        dst[2] = (Sint8) sample2;
   8309        dst[1] = (Sint8) sample1;
   8310        dst[0] = (Sint8) sample0;
   8311        last_sample3 = sample3;
   8312        last_sample2 = sample2;
   8313        last_sample1 = sample1;
   8314        last_sample0 = sample0;
   8315        dst -= 16;
   8316    }
   8317
   8318    cvt->len_cvt = dstsize;
   8319    if (cvt->filters[++cvt->filter_index]) {
   8320        cvt->filters[cvt->filter_index] (cvt, format);
   8321    }
   8322}
   8323
   8324static void SDLCALL
   8325SDL_Downsample_S8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8326{
   8327#if DEBUG_CONVERT
   8328    fprintf(stderr, "Downsample (x4) AUDIO_S8, 4 channels.\n");
   8329#endif
   8330
   8331    const int dstsize = cvt->len_cvt / 4;
   8332    Sint8 *dst = (Sint8 *) cvt->buf;
   8333    const Sint8 *src = (Sint8 *) cvt->buf;
   8334    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   8335    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8336    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8337    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
   8338    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
   8339    while (dst < target) {
   8340        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8341        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8342        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
   8343        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
   8344        src += 16;
   8345        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
   8346        dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
   8347        dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
   8348        dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
   8349        last_sample0 = sample0;
   8350        last_sample1 = sample1;
   8351        last_sample2 = sample2;
   8352        last_sample3 = sample3;
   8353        dst += 4;
   8354    }
   8355
   8356    cvt->len_cvt = dstsize;
   8357    if (cvt->filters[++cvt->filter_index]) {
   8358        cvt->filters[cvt->filter_index] (cvt, format);
   8359    }
   8360}
   8361
   8362static void SDLCALL
   8363SDL_Upsample_S8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8364{
   8365#if DEBUG_CONVERT
   8366    fprintf(stderr, "Upsample (x2) AUDIO_S8, 6 channels.\n");
   8367#endif
   8368
   8369    const int dstsize = cvt->len_cvt * 2;
   8370    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6 * 2;
   8371    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
   8372    const Sint8 *target = ((const Sint8 *) cvt->buf);
   8373    Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
   8374    Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
   8375    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
   8376    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
   8377    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8378    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8379    while (dst >= target) {
   8380        const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
   8381        const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
   8382        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
   8383        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
   8384        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8385        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8386        src -= 6;
   8387        dst[11] = (Sint8) ((sample5 + last_sample5) >> 1);
   8388        dst[10] = (Sint8) ((sample4 + last_sample4) >> 1);
   8389        dst[9] = (Sint8) ((sample3 + last_sample3) >> 1);
   8390        dst[8] = (Sint8) ((sample2 + last_sample2) >> 1);
   8391        dst[7] = (Sint8) ((sample1 + last_sample1) >> 1);
   8392        dst[6] = (Sint8) ((sample0 + last_sample0) >> 1);
   8393        dst[5] = (Sint8) sample5;
   8394        dst[4] = (Sint8) sample4;
   8395        dst[3] = (Sint8) sample3;
   8396        dst[2] = (Sint8) sample2;
   8397        dst[1] = (Sint8) sample1;
   8398        dst[0] = (Sint8) sample0;
   8399        last_sample5 = sample5;
   8400        last_sample4 = sample4;
   8401        last_sample3 = sample3;
   8402        last_sample2 = sample2;
   8403        last_sample1 = sample1;
   8404        last_sample0 = sample0;
   8405        dst -= 12;
   8406    }
   8407
   8408    cvt->len_cvt = dstsize;
   8409    if (cvt->filters[++cvt->filter_index]) {
   8410        cvt->filters[cvt->filter_index] (cvt, format);
   8411    }
   8412}
   8413
   8414static void SDLCALL
   8415SDL_Downsample_S8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8416{
   8417#if DEBUG_CONVERT
   8418    fprintf(stderr, "Downsample (x2) AUDIO_S8, 6 channels.\n");
   8419#endif
   8420
   8421    const int dstsize = cvt->len_cvt / 2;
   8422    Sint8 *dst = (Sint8 *) cvt->buf;
   8423    const Sint8 *src = (Sint8 *) cvt->buf;
   8424    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   8425    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8426    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8427    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
   8428    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
   8429    Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
   8430    Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
   8431    while (dst < target) {
   8432        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8433        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8434        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
   8435        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
   8436        const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
   8437        const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
   8438        src += 12;
   8439        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
   8440        dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
   8441        dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
   8442        dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
   8443        dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
   8444        dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
   8445        last_sample0 = sample0;
   8446        last_sample1 = sample1;
   8447        last_sample2 = sample2;
   8448        last_sample3 = sample3;
   8449        last_sample4 = sample4;
   8450        last_sample5 = sample5;
   8451        dst += 6;
   8452    }
   8453
   8454    cvt->len_cvt = dstsize;
   8455    if (cvt->filters[++cvt->filter_index]) {
   8456        cvt->filters[cvt->filter_index] (cvt, format);
   8457    }
   8458}
   8459
   8460static void SDLCALL
   8461SDL_Upsample_S8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8462{
   8463#if DEBUG_CONVERT
   8464    fprintf(stderr, "Upsample (x4) AUDIO_S8, 6 channels.\n");
   8465#endif
   8466
   8467    const int dstsize = cvt->len_cvt * 4;
   8468    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6 * 4;
   8469    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
   8470    const Sint8 *target = ((const Sint8 *) cvt->buf);
   8471    Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
   8472    Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
   8473    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
   8474    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
   8475    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8476    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8477    while (dst >= target) {
   8478        const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
   8479        const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
   8480        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
   8481        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
   8482        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8483        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8484        src -= 6;
   8485        dst[23] = (Sint8) ((sample5 + (3 * last_sample5)) >> 2);
   8486        dst[22] = (Sint8) ((sample4 + (3 * last_sample4)) >> 2);
   8487        dst[21] = (Sint8) ((sample3 + (3 * last_sample3)) >> 2);
   8488        dst[20] = (Sint8) ((sample2 + (3 * last_sample2)) >> 2);
   8489        dst[19] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
   8490        dst[18] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
   8491        dst[17] = (Sint8) ((sample5 + last_sample5) >> 1);
   8492        dst[16] = (Sint8) ((sample4 + last_sample4) >> 1);
   8493        dst[15] = (Sint8) ((sample3 + last_sample3) >> 1);
   8494        dst[14] = (Sint8) ((sample2 + last_sample2) >> 1);
   8495        dst[13] = (Sint8) ((sample1 + last_sample1) >> 1);
   8496        dst[12] = (Sint8) ((sample0 + last_sample0) >> 1);
   8497        dst[11] = (Sint8) (((3 * sample5) + last_sample5) >> 2);
   8498        dst[10] = (Sint8) (((3 * sample4) + last_sample4) >> 2);
   8499        dst[9] = (Sint8) (((3 * sample3) + last_sample3) >> 2);
   8500        dst[8] = (Sint8) (((3 * sample2) + last_sample2) >> 2);
   8501        dst[7] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
   8502        dst[6] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
   8503        dst[5] = (Sint8) sample5;
   8504        dst[4] = (Sint8) sample4;
   8505        dst[3] = (Sint8) sample3;
   8506        dst[2] = (Sint8) sample2;
   8507        dst[1] = (Sint8) sample1;
   8508        dst[0] = (Sint8) sample0;
   8509        last_sample5 = sample5;
   8510        last_sample4 = sample4;
   8511        last_sample3 = sample3;
   8512        last_sample2 = sample2;
   8513        last_sample1 = sample1;
   8514        last_sample0 = sample0;
   8515        dst -= 24;
   8516    }
   8517
   8518    cvt->len_cvt = dstsize;
   8519    if (cvt->filters[++cvt->filter_index]) {
   8520        cvt->filters[cvt->filter_index] (cvt, format);
   8521    }
   8522}
   8523
   8524static void SDLCALL
   8525SDL_Downsample_S8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8526{
   8527#if DEBUG_CONVERT
   8528    fprintf(stderr, "Downsample (x4) AUDIO_S8, 6 channels.\n");
   8529#endif
   8530
   8531    const int dstsize = cvt->len_cvt / 4;
   8532    Sint8 *dst = (Sint8 *) cvt->buf;
   8533    const Sint8 *src = (Sint8 *) cvt->buf;
   8534    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   8535    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8536    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8537    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
   8538    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
   8539    Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
   8540    Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
   8541    while (dst < target) {
   8542        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8543        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8544        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
   8545        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
   8546        const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
   8547        const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
   8548        src += 24;
   8549        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
   8550        dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
   8551        dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
   8552        dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
   8553        dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
   8554        dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
   8555        last_sample0 = sample0;
   8556        last_sample1 = sample1;
   8557        last_sample2 = sample2;
   8558        last_sample3 = sample3;
   8559        last_sample4 = sample4;
   8560        last_sample5 = sample5;
   8561        dst += 6;
   8562    }
   8563
   8564    cvt->len_cvt = dstsize;
   8565    if (cvt->filters[++cvt->filter_index]) {
   8566        cvt->filters[cvt->filter_index] (cvt, format);
   8567    }
   8568}
   8569
   8570static void SDLCALL
   8571SDL_Upsample_S8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8572{
   8573#if DEBUG_CONVERT
   8574    fprintf(stderr, "Upsample (x2) AUDIO_S8, 8 channels.\n");
   8575#endif
   8576
   8577    const int dstsize = cvt->len_cvt * 2;
   8578    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8 * 2;
   8579    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
   8580    const Sint8 *target = ((const Sint8 *) cvt->buf);
   8581    Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
   8582    Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
   8583    Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
   8584    Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
   8585    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
   8586    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
   8587    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8588    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8589    while (dst >= target) {
   8590        const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
   8591        const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
   8592        const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
   8593        const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
   8594        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
   8595        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
   8596        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8597        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8598        src -= 8;
   8599        dst[15] = (Sint8) ((sample7 + last_sample7) >> 1);
   8600        dst[14] = (Sint8) ((sample6 + last_sample6) >> 1);
   8601        dst[13] = (Sint8) ((sample5 + last_sample5) >> 1);
   8602        dst[12] = (Sint8) ((sample4 + last_sample4) >> 1);
   8603        dst[11] = (Sint8) ((sample3 + last_sample3) >> 1);
   8604        dst[10] = (Sint8) ((sample2 + last_sample2) >> 1);
   8605        dst[9] = (Sint8) ((sample1 + last_sample1) >> 1);
   8606        dst[8] = (Sint8) ((sample0 + last_sample0) >> 1);
   8607        dst[7] = (Sint8) sample7;
   8608        dst[6] = (Sint8) sample6;
   8609        dst[5] = (Sint8) sample5;
   8610        dst[4] = (Sint8) sample4;
   8611        dst[3] = (Sint8) sample3;
   8612        dst[2] = (Sint8) sample2;
   8613        dst[1] = (Sint8) sample1;
   8614        dst[0] = (Sint8) sample0;
   8615        last_sample7 = sample7;
   8616        last_sample6 = sample6;
   8617        last_sample5 = sample5;
   8618        last_sample4 = sample4;
   8619        last_sample3 = sample3;
   8620        last_sample2 = sample2;
   8621        last_sample1 = sample1;
   8622        last_sample0 = sample0;
   8623        dst -= 16;
   8624    }
   8625
   8626    cvt->len_cvt = dstsize;
   8627    if (cvt->filters[++cvt->filter_index]) {
   8628        cvt->filters[cvt->filter_index] (cvt, format);
   8629    }
   8630}
   8631
   8632static void SDLCALL
   8633SDL_Downsample_S8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8634{
   8635#if DEBUG_CONVERT
   8636    fprintf(stderr, "Downsample (x2) AUDIO_S8, 8 channels.\n");
   8637#endif
   8638
   8639    const int dstsize = cvt->len_cvt / 2;
   8640    Sint8 *dst = (Sint8 *) cvt->buf;
   8641    const Sint8 *src = (Sint8 *) cvt->buf;
   8642    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   8643    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8644    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8645    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
   8646    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
   8647    Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
   8648    Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
   8649    Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
   8650    Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
   8651    while (dst < target) {
   8652        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8653        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8654        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
   8655        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
   8656        const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
   8657        const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
   8658        const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
   8659        const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
   8660        src += 16;
   8661        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
   8662        dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
   8663        dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
   8664        dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
   8665        dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
   8666        dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
   8667        dst[6] = (Sint8) ((sample6 + last_sample6) >> 1);
   8668        dst[7] = (Sint8) ((sample7 + last_sample7) >> 1);
   8669        last_sample0 = sample0;
   8670        last_sample1 = sample1;
   8671        last_sample2 = sample2;
   8672        last_sample3 = sample3;
   8673        last_sample4 = sample4;
   8674        last_sample5 = sample5;
   8675        last_sample6 = sample6;
   8676        last_sample7 = sample7;
   8677        dst += 8;
   8678    }
   8679
   8680    cvt->len_cvt = dstsize;
   8681    if (cvt->filters[++cvt->filter_index]) {
   8682        cvt->filters[cvt->filter_index] (cvt, format);
   8683    }
   8684}
   8685
   8686static void SDLCALL
   8687SDL_Upsample_S8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8688{
   8689#if DEBUG_CONVERT
   8690    fprintf(stderr, "Upsample (x4) AUDIO_S8, 8 channels.\n");
   8691#endif
   8692
   8693    const int dstsize = cvt->len_cvt * 4;
   8694    Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8 * 4;
   8695    const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
   8696    const Sint8 *target = ((const Sint8 *) cvt->buf);
   8697    Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
   8698    Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
   8699    Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
   8700    Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
   8701    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
   8702    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
   8703    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8704    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8705    while (dst >= target) {
   8706        const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
   8707        const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
   8708        const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
   8709        const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
   8710        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
   8711        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
   8712        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8713        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8714        src -= 8;
   8715        dst[31] = (Sint8) ((sample7 + (3 * last_sample7)) >> 2);
   8716        dst[30] = (Sint8) ((sample6 + (3 * last_sample6)) >> 2);
   8717        dst[29] = (Sint8) ((sample5 + (3 * last_sample5)) >> 2);
   8718        dst[28] = (Sint8) ((sample4 + (3 * last_sample4)) >> 2);
   8719        dst[27] = (Sint8) ((sample3 + (3 * last_sample3)) >> 2);
   8720        dst[26] = (Sint8) ((sample2 + (3 * last_sample2)) >> 2);
   8721        dst[25] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
   8722        dst[24] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
   8723        dst[23] = (Sint8) ((sample7 + last_sample7) >> 1);
   8724        dst[22] = (Sint8) ((sample6 + last_sample6) >> 1);
   8725        dst[21] = (Sint8) ((sample5 + last_sample5) >> 1);
   8726        dst[20] = (Sint8) ((sample4 + last_sample4) >> 1);
   8727        dst[19] = (Sint8) ((sample3 + last_sample3) >> 1);
   8728        dst[18] = (Sint8) ((sample2 + last_sample2) >> 1);
   8729        dst[17] = (Sint8) ((sample1 + last_sample1) >> 1);
   8730        dst[16] = (Sint8) ((sample0 + last_sample0) >> 1);
   8731        dst[15] = (Sint8) (((3 * sample7) + last_sample7) >> 2);
   8732        dst[14] = (Sint8) (((3 * sample6) + last_sample6) >> 2);
   8733        dst[13] = (Sint8) (((3 * sample5) + last_sample5) >> 2);
   8734        dst[12] = (Sint8) (((3 * sample4) + last_sample4) >> 2);
   8735        dst[11] = (Sint8) (((3 * sample3) + last_sample3) >> 2);
   8736        dst[10] = (Sint8) (((3 * sample2) + last_sample2) >> 2);
   8737        dst[9] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
   8738        dst[8] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
   8739        dst[7] = (Sint8) sample7;
   8740        dst[6] = (Sint8) sample6;
   8741        dst[5] = (Sint8) sample5;
   8742        dst[4] = (Sint8) sample4;
   8743        dst[3] = (Sint8) sample3;
   8744        dst[2] = (Sint8) sample2;
   8745        dst[1] = (Sint8) sample1;
   8746        dst[0] = (Sint8) sample0;
   8747        last_sample7 = sample7;
   8748        last_sample6 = sample6;
   8749        last_sample5 = sample5;
   8750        last_sample4 = sample4;
   8751        last_sample3 = sample3;
   8752        last_sample2 = sample2;
   8753        last_sample1 = sample1;
   8754        last_sample0 = sample0;
   8755        dst -= 32;
   8756    }
   8757
   8758    cvt->len_cvt = dstsize;
   8759    if (cvt->filters[++cvt->filter_index]) {
   8760        cvt->filters[cvt->filter_index] (cvt, format);
   8761    }
   8762}
   8763
   8764static void SDLCALL
   8765SDL_Downsample_S8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8766{
   8767#if DEBUG_CONVERT
   8768    fprintf(stderr, "Downsample (x4) AUDIO_S8, 8 channels.\n");
   8769#endif
   8770
   8771    const int dstsize = cvt->len_cvt / 4;
   8772    Sint8 *dst = (Sint8 *) cvt->buf;
   8773    const Sint8 *src = (Sint8 *) cvt->buf;
   8774    const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   8775    Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
   8776    Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
   8777    Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
   8778    Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
   8779    Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
   8780    Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
   8781    Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
   8782    Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
   8783    while (dst < target) {
   8784        const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
   8785        const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
   8786        const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
   8787        const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
   8788        const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
   8789        const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
   8790        const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
   8791        const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
   8792        src += 32;
   8793        dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
   8794        dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
   8795        dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
   8796        dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
   8797        dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
   8798        dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
   8799        dst[6] = (Sint8) ((sample6 + last_sample6) >> 1);
   8800        dst[7] = (Sint8) ((sample7 + last_sample7) >> 1);
   8801        last_sample0 = sample0;
   8802        last_sample1 = sample1;
   8803        last_sample2 = sample2;
   8804        last_sample3 = sample3;
   8805        last_sample4 = sample4;
   8806        last_sample5 = sample5;
   8807        last_sample6 = sample6;
   8808        last_sample7 = sample7;
   8809        dst += 8;
   8810    }
   8811
   8812    cvt->len_cvt = dstsize;
   8813    if (cvt->filters[++cvt->filter_index]) {
   8814        cvt->filters[cvt->filter_index] (cvt, format);
   8815    }
   8816}
   8817
   8818static void SDLCALL
   8819SDL_Upsample_U16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8820{
   8821#if DEBUG_CONVERT
   8822    fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 1 channels.\n");
   8823#endif
   8824
   8825    const int dstsize = cvt->len_cvt * 2;
   8826    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1 * 2;
   8827    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   8828    const Uint16 *target = ((const Uint16 *) cvt->buf);
   8829    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   8830    while (dst >= target) {
   8831        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   8832        src--;
   8833        dst[1] = (Uint16) ((sample0 + last_sample0) >> 1);
   8834        dst[0] = (Uint16) sample0;
   8835        last_sample0 = sample0;
   8836        dst -= 2;
   8837    }
   8838
   8839    cvt->len_cvt = dstsize;
   8840    if (cvt->filters[++cvt->filter_index]) {
   8841        cvt->filters[cvt->filter_index] (cvt, format);
   8842    }
   8843}
   8844
   8845static void SDLCALL
   8846SDL_Downsample_U16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8847{
   8848#if DEBUG_CONVERT
   8849    fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 1 channels.\n");
   8850#endif
   8851
   8852    const int dstsize = cvt->len_cvt / 2;
   8853    Uint16 *dst = (Uint16 *) cvt->buf;
   8854    const Uint16 *src = (Uint16 *) cvt->buf;
   8855    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   8856    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   8857    while (dst < target) {
   8858        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   8859        src += 2;
   8860        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
   8861        last_sample0 = sample0;
   8862        dst++;
   8863    }
   8864
   8865    cvt->len_cvt = dstsize;
   8866    if (cvt->filters[++cvt->filter_index]) {
   8867        cvt->filters[cvt->filter_index] (cvt, format);
   8868    }
   8869}
   8870
   8871static void SDLCALL
   8872SDL_Upsample_U16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8873{
   8874#if DEBUG_CONVERT
   8875    fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 1 channels.\n");
   8876#endif
   8877
   8878    const int dstsize = cvt->len_cvt * 4;
   8879    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1 * 4;
   8880    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   8881    const Uint16 *target = ((const Uint16 *) cvt->buf);
   8882    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   8883    while (dst >= target) {
   8884        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   8885        src--;
   8886        dst[3] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
   8887        dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
   8888        dst[1] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
   8889        dst[0] = (Uint16) sample0;
   8890        last_sample0 = sample0;
   8891        dst -= 4;
   8892    }
   8893
   8894    cvt->len_cvt = dstsize;
   8895    if (cvt->filters[++cvt->filter_index]) {
   8896        cvt->filters[cvt->filter_index] (cvt, format);
   8897    }
   8898}
   8899
   8900static void SDLCALL
   8901SDL_Downsample_U16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8902{
   8903#if DEBUG_CONVERT
   8904    fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 1 channels.\n");
   8905#endif
   8906
   8907    const int dstsize = cvt->len_cvt / 4;
   8908    Uint16 *dst = (Uint16 *) cvt->buf;
   8909    const Uint16 *src = (Uint16 *) cvt->buf;
   8910    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   8911    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   8912    while (dst < target) {
   8913        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   8914        src += 4;
   8915        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
   8916        last_sample0 = sample0;
   8917        dst++;
   8918    }
   8919
   8920    cvt->len_cvt = dstsize;
   8921    if (cvt->filters[++cvt->filter_index]) {
   8922        cvt->filters[cvt->filter_index] (cvt, format);
   8923    }
   8924}
   8925
   8926static void SDLCALL
   8927SDL_Upsample_U16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8928{
   8929#if DEBUG_CONVERT
   8930    fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 2 channels.\n");
   8931#endif
   8932
   8933    const int dstsize = cvt->len_cvt * 2;
   8934    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2 * 2;
   8935    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
   8936    const Uint16 *target = ((const Uint16 *) cvt->buf);
   8937    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   8938    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   8939    while (dst >= target) {
   8940        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   8941        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   8942        src -= 2;
   8943        dst[3] = (Uint16) ((sample1 + last_sample1) >> 1);
   8944        dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
   8945        dst[1] = (Uint16) sample1;
   8946        dst[0] = (Uint16) sample0;
   8947        last_sample1 = sample1;
   8948        last_sample0 = sample0;
   8949        dst -= 4;
   8950    }
   8951
   8952    cvt->len_cvt = dstsize;
   8953    if (cvt->filters[++cvt->filter_index]) {
   8954        cvt->filters[cvt->filter_index] (cvt, format);
   8955    }
   8956}
   8957
   8958static void SDLCALL
   8959SDL_Downsample_U16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8960{
   8961#if DEBUG_CONVERT
   8962    fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 2 channels.\n");
   8963#endif
   8964
   8965    const int dstsize = cvt->len_cvt / 2;
   8966    Uint16 *dst = (Uint16 *) cvt->buf;
   8967    const Uint16 *src = (Uint16 *) cvt->buf;
   8968    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   8969    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   8970    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   8971    while (dst < target) {
   8972        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   8973        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   8974        src += 4;
   8975        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
   8976        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
   8977        last_sample0 = sample0;
   8978        last_sample1 = sample1;
   8979        dst += 2;
   8980    }
   8981
   8982    cvt->len_cvt = dstsize;
   8983    if (cvt->filters[++cvt->filter_index]) {
   8984        cvt->filters[cvt->filter_index] (cvt, format);
   8985    }
   8986}
   8987
   8988static void SDLCALL
   8989SDL_Upsample_U16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   8990{
   8991#if DEBUG_CONVERT
   8992    fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 2 channels.\n");
   8993#endif
   8994
   8995    const int dstsize = cvt->len_cvt * 4;
   8996    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2 * 4;
   8997    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
   8998    const Uint16 *target = ((const Uint16 *) cvt->buf);
   8999    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9000    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9001    while (dst >= target) {
   9002        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9003        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9004        src -= 2;
   9005        dst[7] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
   9006        dst[6] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
   9007        dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
   9008        dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
   9009        dst[3] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
   9010        dst[2] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
   9011        dst[1] = (Uint16) sample1;
   9012        dst[0] = (Uint16) sample0;
   9013        last_sample1 = sample1;
   9014        last_sample0 = sample0;
   9015        dst -= 8;
   9016    }
   9017
   9018    cvt->len_cvt = dstsize;
   9019    if (cvt->filters[++cvt->filter_index]) {
   9020        cvt->filters[cvt->filter_index] (cvt, format);
   9021    }
   9022}
   9023
   9024static void SDLCALL
   9025SDL_Downsample_U16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9026{
   9027#if DEBUG_CONVERT
   9028    fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 2 channels.\n");
   9029#endif
   9030
   9031    const int dstsize = cvt->len_cvt / 4;
   9032    Uint16 *dst = (Uint16 *) cvt->buf;
   9033    const Uint16 *src = (Uint16 *) cvt->buf;
   9034    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   9035    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9036    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9037    while (dst < target) {
   9038        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9039        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9040        src += 8;
   9041        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
   9042        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
   9043        last_sample0 = sample0;
   9044        last_sample1 = sample1;
   9045        dst += 2;
   9046    }
   9047
   9048    cvt->len_cvt = dstsize;
   9049    if (cvt->filters[++cvt->filter_index]) {
   9050        cvt->filters[cvt->filter_index] (cvt, format);
   9051    }
   9052}
   9053
   9054static void SDLCALL
   9055SDL_Upsample_U16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9056{
   9057#if DEBUG_CONVERT
   9058    fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 4 channels.\n");
   9059#endif
   9060
   9061    const int dstsize = cvt->len_cvt * 2;
   9062    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4 * 2;
   9063    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
   9064    const Uint16 *target = ((const Uint16 *) cvt->buf);
   9065    Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9066    Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9067    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9068    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9069    while (dst >= target) {
   9070        const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9071        const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9072        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9073        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9074        src -= 4;
   9075        dst[7] = (Uint16) ((sample3 + last_sample3) >> 1);
   9076        dst[6] = (Uint16) ((sample2 + last_sample2) >> 1);
   9077        dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
   9078        dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
   9079        dst[3] = (Uint16) sample3;
   9080        dst[2] = (Uint16) sample2;
   9081        dst[1] = (Uint16) sample1;
   9082        dst[0] = (Uint16) sample0;
   9083        last_sample3 = sample3;
   9084        last_sample2 = sample2;
   9085        last_sample1 = sample1;
   9086        last_sample0 = sample0;
   9087        dst -= 8;
   9088    }
   9089
   9090    cvt->len_cvt = dstsize;
   9091    if (cvt->filters[++cvt->filter_index]) {
   9092        cvt->filters[cvt->filter_index] (cvt, format);
   9093    }
   9094}
   9095
   9096static void SDLCALL
   9097SDL_Downsample_U16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9098{
   9099#if DEBUG_CONVERT
   9100    fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 4 channels.\n");
   9101#endif
   9102
   9103    const int dstsize = cvt->len_cvt / 2;
   9104    Uint16 *dst = (Uint16 *) cvt->buf;
   9105    const Uint16 *src = (Uint16 *) cvt->buf;
   9106    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   9107    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9108    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9109    Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9110    Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9111    while (dst < target) {
   9112        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9113        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9114        const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9115        const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9116        src += 8;
   9117        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
   9118        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
   9119        dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
   9120        dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
   9121        last_sample0 = sample0;
   9122        last_sample1 = sample1;
   9123        last_sample2 = sample2;
   9124        last_sample3 = sample3;
   9125        dst += 4;
   9126    }
   9127
   9128    cvt->len_cvt = dstsize;
   9129    if (cvt->filters[++cvt->filter_index]) {
   9130        cvt->filters[cvt->filter_index] (cvt, format);
   9131    }
   9132}
   9133
   9134static void SDLCALL
   9135SDL_Upsample_U16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9136{
   9137#if DEBUG_CONVERT
   9138    fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 4 channels.\n");
   9139#endif
   9140
   9141    const int dstsize = cvt->len_cvt * 4;
   9142    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4 * 4;
   9143    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
   9144    const Uint16 *target = ((const Uint16 *) cvt->buf);
   9145    Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9146    Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9147    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9148    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9149    while (dst >= target) {
   9150        const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9151        const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9152        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9153        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9154        src -= 4;
   9155        dst[15] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
   9156        dst[14] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
   9157        dst[13] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
   9158        dst[12] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
   9159        dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
   9160        dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
   9161        dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
   9162        dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
   9163        dst[7] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
   9164        dst[6] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
   9165        dst[5] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
   9166        dst[4] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
   9167        dst[3] = (Uint16) sample3;
   9168        dst[2] = (Uint16) sample2;
   9169        dst[1] = (Uint16) sample1;
   9170        dst[0] = (Uint16) sample0;
   9171        last_sample3 = sample3;
   9172        last_sample2 = sample2;
   9173        last_sample1 = sample1;
   9174        last_sample0 = sample0;
   9175        dst -= 16;
   9176    }
   9177
   9178    cvt->len_cvt = dstsize;
   9179    if (cvt->filters[++cvt->filter_index]) {
   9180        cvt->filters[cvt->filter_index] (cvt, format);
   9181    }
   9182}
   9183
   9184static void SDLCALL
   9185SDL_Downsample_U16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9186{
   9187#if DEBUG_CONVERT
   9188    fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 4 channels.\n");
   9189#endif
   9190
   9191    const int dstsize = cvt->len_cvt / 4;
   9192    Uint16 *dst = (Uint16 *) cvt->buf;
   9193    const Uint16 *src = (Uint16 *) cvt->buf;
   9194    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   9195    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9196    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9197    Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9198    Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9199    while (dst < target) {
   9200        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9201        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9202        const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9203        const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9204        src += 16;
   9205        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
   9206        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
   9207        dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
   9208        dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
   9209        last_sample0 = sample0;
   9210        last_sample1 = sample1;
   9211        last_sample2 = sample2;
   9212        last_sample3 = sample3;
   9213        dst += 4;
   9214    }
   9215
   9216    cvt->len_cvt = dstsize;
   9217    if (cvt->filters[++cvt->filter_index]) {
   9218        cvt->filters[cvt->filter_index] (cvt, format);
   9219    }
   9220}
   9221
   9222static void SDLCALL
   9223SDL_Upsample_U16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9224{
   9225#if DEBUG_CONVERT
   9226    fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 6 channels.\n");
   9227#endif
   9228
   9229    const int dstsize = cvt->len_cvt * 2;
   9230    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6 * 2;
   9231    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
   9232    const Uint16 *target = ((const Uint16 *) cvt->buf);
   9233    Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9234    Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9235    Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9236    Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9237    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9238    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9239    while (dst >= target) {
   9240        const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9241        const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9242        const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9243        const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9244        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9245        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9246        src -= 6;
   9247        dst[11] = (Uint16) ((sample5 + last_sample5) >> 1);
   9248        dst[10] = (Uint16) ((sample4 + last_sample4) >> 1);
   9249        dst[9] = (Uint16) ((sample3 + last_sample3) >> 1);
   9250        dst[8] = (Uint16) ((sample2 + last_sample2) >> 1);
   9251        dst[7] = (Uint16) ((sample1 + last_sample1) >> 1);
   9252        dst[6] = (Uint16) ((sample0 + last_sample0) >> 1);
   9253        dst[5] = (Uint16) sample5;
   9254        dst[4] = (Uint16) sample4;
   9255        dst[3] = (Uint16) sample3;
   9256        dst[2] = (Uint16) sample2;
   9257        dst[1] = (Uint16) sample1;
   9258        dst[0] = (Uint16) sample0;
   9259        last_sample5 = sample5;
   9260        last_sample4 = sample4;
   9261        last_sample3 = sample3;
   9262        last_sample2 = sample2;
   9263        last_sample1 = sample1;
   9264        last_sample0 = sample0;
   9265        dst -= 12;
   9266    }
   9267
   9268    cvt->len_cvt = dstsize;
   9269    if (cvt->filters[++cvt->filter_index]) {
   9270        cvt->filters[cvt->filter_index] (cvt, format);
   9271    }
   9272}
   9273
   9274static void SDLCALL
   9275SDL_Downsample_U16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9276{
   9277#if DEBUG_CONVERT
   9278    fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 6 channels.\n");
   9279#endif
   9280
   9281    const int dstsize = cvt->len_cvt / 2;
   9282    Uint16 *dst = (Uint16 *) cvt->buf;
   9283    const Uint16 *src = (Uint16 *) cvt->buf;
   9284    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   9285    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9286    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9287    Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9288    Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9289    Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9290    Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9291    while (dst < target) {
   9292        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9293        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9294        const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9295        const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9296        const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9297        const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9298        src += 12;
   9299        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
   9300        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
   9301        dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
   9302        dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
   9303        dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
   9304        dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
   9305        last_sample0 = sample0;
   9306        last_sample1 = sample1;
   9307        last_sample2 = sample2;
   9308        last_sample3 = sample3;
   9309        last_sample4 = sample4;
   9310        last_sample5 = sample5;
   9311        dst += 6;
   9312    }
   9313
   9314    cvt->len_cvt = dstsize;
   9315    if (cvt->filters[++cvt->filter_index]) {
   9316        cvt->filters[cvt->filter_index] (cvt, format);
   9317    }
   9318}
   9319
   9320static void SDLCALL
   9321SDL_Upsample_U16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9322{
   9323#if DEBUG_CONVERT
   9324    fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 6 channels.\n");
   9325#endif
   9326
   9327    const int dstsize = cvt->len_cvt * 4;
   9328    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6 * 4;
   9329    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
   9330    const Uint16 *target = ((const Uint16 *) cvt->buf);
   9331    Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9332    Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9333    Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9334    Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9335    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9336    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9337    while (dst >= target) {
   9338        const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9339        const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9340        const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9341        const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9342        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9343        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9344        src -= 6;
   9345        dst[23] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
   9346        dst[22] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
   9347        dst[21] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
   9348        dst[20] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
   9349        dst[19] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
   9350        dst[18] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
   9351        dst[17] = (Uint16) ((sample5 + last_sample5) >> 1);
   9352        dst[16] = (Uint16) ((sample4 + last_sample4) >> 1);
   9353        dst[15] = (Uint16) ((sample3 + last_sample3) >> 1);
   9354        dst[14] = (Uint16) ((sample2 + last_sample2) >> 1);
   9355        dst[13] = (Uint16) ((sample1 + last_sample1) >> 1);
   9356        dst[12] = (Uint16) ((sample0 + last_sample0) >> 1);
   9357        dst[11] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
   9358        dst[10] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
   9359        dst[9] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
   9360        dst[8] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
   9361        dst[7] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
   9362        dst[6] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
   9363        dst[5] = (Uint16) sample5;
   9364        dst[4] = (Uint16) sample4;
   9365        dst[3] = (Uint16) sample3;
   9366        dst[2] = (Uint16) sample2;
   9367        dst[1] = (Uint16) sample1;
   9368        dst[0] = (Uint16) sample0;
   9369        last_sample5 = sample5;
   9370        last_sample4 = sample4;
   9371        last_sample3 = sample3;
   9372        last_sample2 = sample2;
   9373        last_sample1 = sample1;
   9374        last_sample0 = sample0;
   9375        dst -= 24;
   9376    }
   9377
   9378    cvt->len_cvt = dstsize;
   9379    if (cvt->filters[++cvt->filter_index]) {
   9380        cvt->filters[cvt->filter_index] (cvt, format);
   9381    }
   9382}
   9383
   9384static void SDLCALL
   9385SDL_Downsample_U16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9386{
   9387#if DEBUG_CONVERT
   9388    fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 6 channels.\n");
   9389#endif
   9390
   9391    const int dstsize = cvt->len_cvt / 4;
   9392    Uint16 *dst = (Uint16 *) cvt->buf;
   9393    const Uint16 *src = (Uint16 *) cvt->buf;
   9394    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   9395    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9396    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9397    Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9398    Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9399    Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9400    Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9401    while (dst < target) {
   9402        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9403        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9404        const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9405        const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9406        const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9407        const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9408        src += 24;
   9409        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
   9410        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
   9411        dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
   9412        dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
   9413        dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
   9414        dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
   9415        last_sample0 = sample0;
   9416        last_sample1 = sample1;
   9417        last_sample2 = sample2;
   9418        last_sample3 = sample3;
   9419        last_sample4 = sample4;
   9420        last_sample5 = sample5;
   9421        dst += 6;
   9422    }
   9423
   9424    cvt->len_cvt = dstsize;
   9425    if (cvt->filters[++cvt->filter_index]) {
   9426        cvt->filters[cvt->filter_index] (cvt, format);
   9427    }
   9428}
   9429
   9430static void SDLCALL
   9431SDL_Upsample_U16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9432{
   9433#if DEBUG_CONVERT
   9434    fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 8 channels.\n");
   9435#endif
   9436
   9437    const int dstsize = cvt->len_cvt * 2;
   9438    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8 * 2;
   9439    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
   9440    const Uint16 *target = ((const Uint16 *) cvt->buf);
   9441    Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
   9442    Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
   9443    Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9444    Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9445    Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9446    Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9447    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9448    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9449    while (dst >= target) {
   9450        const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
   9451        const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
   9452        const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9453        const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9454        const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9455        const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9456        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9457        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9458        src -= 8;
   9459        dst[15] = (Uint16) ((sample7 + last_sample7) >> 1);
   9460        dst[14] = (Uint16) ((sample6 + last_sample6) >> 1);
   9461        dst[13] = (Uint16) ((sample5 + last_sample5) >> 1);
   9462        dst[12] = (Uint16) ((sample4 + last_sample4) >> 1);
   9463        dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
   9464        dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
   9465        dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
   9466        dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
   9467        dst[7] = (Uint16) sample7;
   9468        dst[6] = (Uint16) sample6;
   9469        dst[5] = (Uint16) sample5;
   9470        dst[4] = (Uint16) sample4;
   9471        dst[3] = (Uint16) sample3;
   9472        dst[2] = (Uint16) sample2;
   9473        dst[1] = (Uint16) sample1;
   9474        dst[0] = (Uint16) sample0;
   9475        last_sample7 = sample7;
   9476        last_sample6 = sample6;
   9477        last_sample5 = sample5;
   9478        last_sample4 = sample4;
   9479        last_sample3 = sample3;
   9480        last_sample2 = sample2;
   9481        last_sample1 = sample1;
   9482        last_sample0 = sample0;
   9483        dst -= 16;
   9484    }
   9485
   9486    cvt->len_cvt = dstsize;
   9487    if (cvt->filters[++cvt->filter_index]) {
   9488        cvt->filters[cvt->filter_index] (cvt, format);
   9489    }
   9490}
   9491
   9492static void SDLCALL
   9493SDL_Downsample_U16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9494{
   9495#if DEBUG_CONVERT
   9496    fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 8 channels.\n");
   9497#endif
   9498
   9499    const int dstsize = cvt->len_cvt / 2;
   9500    Uint16 *dst = (Uint16 *) cvt->buf;
   9501    const Uint16 *src = (Uint16 *) cvt->buf;
   9502    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   9503    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9504    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9505    Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9506    Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9507    Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9508    Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9509    Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
   9510    Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
   9511    while (dst < target) {
   9512        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9513        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9514        const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9515        const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9516        const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9517        const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9518        const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
   9519        const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
   9520        src += 16;
   9521        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
   9522        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
   9523        dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
   9524        dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
   9525        dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
   9526        dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
   9527        dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
   9528        dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
   9529        last_sample0 = sample0;
   9530        last_sample1 = sample1;
   9531        last_sample2 = sample2;
   9532        last_sample3 = sample3;
   9533        last_sample4 = sample4;
   9534        last_sample5 = sample5;
   9535        last_sample6 = sample6;
   9536        last_sample7 = sample7;
   9537        dst += 8;
   9538    }
   9539
   9540    cvt->len_cvt = dstsize;
   9541    if (cvt->filters[++cvt->filter_index]) {
   9542        cvt->filters[cvt->filter_index] (cvt, format);
   9543    }
   9544}
   9545
   9546static void SDLCALL
   9547SDL_Upsample_U16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9548{
   9549#if DEBUG_CONVERT
   9550    fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 8 channels.\n");
   9551#endif
   9552
   9553    const int dstsize = cvt->len_cvt * 4;
   9554    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8 * 4;
   9555    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
   9556    const Uint16 *target = ((const Uint16 *) cvt->buf);
   9557    Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
   9558    Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
   9559    Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9560    Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9561    Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9562    Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9563    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9564    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9565    while (dst >= target) {
   9566        const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
   9567        const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
   9568        const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9569        const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9570        const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9571        const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9572        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9573        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9574        src -= 8;
   9575        dst[31] = (Uint16) ((sample7 + (3 * last_sample7)) >> 2);
   9576        dst[30] = (Uint16) ((sample6 + (3 * last_sample6)) >> 2);
   9577        dst[29] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
   9578        dst[28] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
   9579        dst[27] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
   9580        dst[26] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
   9581        dst[25] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
   9582        dst[24] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
   9583        dst[23] = (Uint16) ((sample7 + last_sample7) >> 1);
   9584        dst[22] = (Uint16) ((sample6 + last_sample6) >> 1);
   9585        dst[21] = (Uint16) ((sample5 + last_sample5) >> 1);
   9586        dst[20] = (Uint16) ((sample4 + last_sample4) >> 1);
   9587        dst[19] = (Uint16) ((sample3 + last_sample3) >> 1);
   9588        dst[18] = (Uint16) ((sample2 + last_sample2) >> 1);
   9589        dst[17] = (Uint16) ((sample1 + last_sample1) >> 1);
   9590        dst[16] = (Uint16) ((sample0 + last_sample0) >> 1);
   9591        dst[15] = (Uint16) (((3 * sample7) + last_sample7) >> 2);
   9592        dst[14] = (Uint16) (((3 * sample6) + last_sample6) >> 2);
   9593        dst[13] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
   9594        dst[12] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
   9595        dst[11] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
   9596        dst[10] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
   9597        dst[9] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
   9598        dst[8] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
   9599        dst[7] = (Uint16) sample7;
   9600        dst[6] = (Uint16) sample6;
   9601        dst[5] = (Uint16) sample5;
   9602        dst[4] = (Uint16) sample4;
   9603        dst[3] = (Uint16) sample3;
   9604        dst[2] = (Uint16) sample2;
   9605        dst[1] = (Uint16) sample1;
   9606        dst[0] = (Uint16) sample0;
   9607        last_sample7 = sample7;
   9608        last_sample6 = sample6;
   9609        last_sample5 = sample5;
   9610        last_sample4 = sample4;
   9611        last_sample3 = sample3;
   9612        last_sample2 = sample2;
   9613        last_sample1 = sample1;
   9614        last_sample0 = sample0;
   9615        dst -= 32;
   9616    }
   9617
   9618    cvt->len_cvt = dstsize;
   9619    if (cvt->filters[++cvt->filter_index]) {
   9620        cvt->filters[cvt->filter_index] (cvt, format);
   9621    }
   9622}
   9623
   9624static void SDLCALL
   9625SDL_Downsample_U16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9626{
   9627#if DEBUG_CONVERT
   9628    fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 8 channels.\n");
   9629#endif
   9630
   9631    const int dstsize = cvt->len_cvt / 4;
   9632    Uint16 *dst = (Uint16 *) cvt->buf;
   9633    const Uint16 *src = (Uint16 *) cvt->buf;
   9634    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   9635    Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9636    Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9637    Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9638    Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9639    Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9640    Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9641    Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
   9642    Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
   9643    while (dst < target) {
   9644        const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
   9645        const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
   9646        const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
   9647        const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
   9648        const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
   9649        const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
   9650        const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
   9651        const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
   9652        src += 32;
   9653        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
   9654        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
   9655        dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
   9656        dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
   9657        dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
   9658        dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
   9659        dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
   9660        dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
   9661        last_sample0 = sample0;
   9662        last_sample1 = sample1;
   9663        last_sample2 = sample2;
   9664        last_sample3 = sample3;
   9665        last_sample4 = sample4;
   9666        last_sample5 = sample5;
   9667        last_sample6 = sample6;
   9668        last_sample7 = sample7;
   9669        dst += 8;
   9670    }
   9671
   9672    cvt->len_cvt = dstsize;
   9673    if (cvt->filters[++cvt->filter_index]) {
   9674        cvt->filters[cvt->filter_index] (cvt, format);
   9675    }
   9676}
   9677
   9678static void SDLCALL
   9679SDL_Upsample_S16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9680{
   9681#if DEBUG_CONVERT
   9682    fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 1 channels.\n");
   9683#endif
   9684
   9685    const int dstsize = cvt->len_cvt * 2;
   9686    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1 * 2;
   9687    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   9688    const Sint16 *target = ((const Sint16 *) cvt->buf);
   9689    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9690    while (dst >= target) {
   9691        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9692        src--;
   9693        dst[1] = (Sint16) ((sample0 + last_sample0) >> 1);
   9694        dst[0] = (Sint16) sample0;
   9695        last_sample0 = sample0;
   9696        dst -= 2;
   9697    }
   9698
   9699    cvt->len_cvt = dstsize;
   9700    if (cvt->filters[++cvt->filter_index]) {
   9701        cvt->filters[cvt->filter_index] (cvt, format);
   9702    }
   9703}
   9704
   9705static void SDLCALL
   9706SDL_Downsample_S16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9707{
   9708#if DEBUG_CONVERT
   9709    fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 1 channels.\n");
   9710#endif
   9711
   9712    const int dstsize = cvt->len_cvt / 2;
   9713    Sint16 *dst = (Sint16 *) cvt->buf;
   9714    const Sint16 *src = (Sint16 *) cvt->buf;
   9715    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   9716    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9717    while (dst < target) {
   9718        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9719        src += 2;
   9720        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
   9721        last_sample0 = sample0;
   9722        dst++;
   9723    }
   9724
   9725    cvt->len_cvt = dstsize;
   9726    if (cvt->filters[++cvt->filter_index]) {
   9727        cvt->filters[cvt->filter_index] (cvt, format);
   9728    }
   9729}
   9730
   9731static void SDLCALL
   9732SDL_Upsample_S16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9733{
   9734#if DEBUG_CONVERT
   9735    fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 1 channels.\n");
   9736#endif
   9737
   9738    const int dstsize = cvt->len_cvt * 4;
   9739    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1 * 4;
   9740    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
   9741    const Sint16 *target = ((const Sint16 *) cvt->buf);
   9742    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9743    while (dst >= target) {
   9744        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9745        src--;
   9746        dst[3] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
   9747        dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
   9748        dst[1] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
   9749        dst[0] = (Sint16) sample0;
   9750        last_sample0 = sample0;
   9751        dst -= 4;
   9752    }
   9753
   9754    cvt->len_cvt = dstsize;
   9755    if (cvt->filters[++cvt->filter_index]) {
   9756        cvt->filters[cvt->filter_index] (cvt, format);
   9757    }
   9758}
   9759
   9760static void SDLCALL
   9761SDL_Downsample_S16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9762{
   9763#if DEBUG_CONVERT
   9764    fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 1 channels.\n");
   9765#endif
   9766
   9767    const int dstsize = cvt->len_cvt / 4;
   9768    Sint16 *dst = (Sint16 *) cvt->buf;
   9769    const Sint16 *src = (Sint16 *) cvt->buf;
   9770    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   9771    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9772    while (dst < target) {
   9773        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9774        src += 4;
   9775        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
   9776        last_sample0 = sample0;
   9777        dst++;
   9778    }
   9779
   9780    cvt->len_cvt = dstsize;
   9781    if (cvt->filters[++cvt->filter_index]) {
   9782        cvt->filters[cvt->filter_index] (cvt, format);
   9783    }
   9784}
   9785
   9786static void SDLCALL
   9787SDL_Upsample_S16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9788{
   9789#if DEBUG_CONVERT
   9790    fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 2 channels.\n");
   9791#endif
   9792
   9793    const int dstsize = cvt->len_cvt * 2;
   9794    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2 * 2;
   9795    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
   9796    const Sint16 *target = ((const Sint16 *) cvt->buf);
   9797    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
   9798    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9799    while (dst >= target) {
   9800        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
   9801        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9802        src -= 2;
   9803        dst[3] = (Sint16) ((sample1 + last_sample1) >> 1);
   9804        dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
   9805        dst[1] = (Sint16) sample1;
   9806        dst[0] = (Sint16) sample0;
   9807        last_sample1 = sample1;
   9808        last_sample0 = sample0;
   9809        dst -= 4;
   9810    }
   9811
   9812    cvt->len_cvt = dstsize;
   9813    if (cvt->filters[++cvt->filter_index]) {
   9814        cvt->filters[cvt->filter_index] (cvt, format);
   9815    }
   9816}
   9817
   9818static void SDLCALL
   9819SDL_Downsample_S16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9820{
   9821#if DEBUG_CONVERT
   9822    fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 2 channels.\n");
   9823#endif
   9824
   9825    const int dstsize = cvt->len_cvt / 2;
   9826    Sint16 *dst = (Sint16 *) cvt->buf;
   9827    const Sint16 *src = (Sint16 *) cvt->buf;
   9828    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   9829    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9830    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
   9831    while (dst < target) {
   9832        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9833        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
   9834        src += 4;
   9835        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
   9836        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
   9837        last_sample0 = sample0;
   9838        last_sample1 = sample1;
   9839        dst += 2;
   9840    }
   9841
   9842    cvt->len_cvt = dstsize;
   9843    if (cvt->filters[++cvt->filter_index]) {
   9844        cvt->filters[cvt->filter_index] (cvt, format);
   9845    }
   9846}
   9847
   9848static void SDLCALL
   9849SDL_Upsample_S16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9850{
   9851#if DEBUG_CONVERT
   9852    fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 2 channels.\n");
   9853#endif
   9854
   9855    const int dstsize = cvt->len_cvt * 4;
   9856    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2 * 4;
   9857    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
   9858    const Sint16 *target = ((const Sint16 *) cvt->buf);
   9859    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
   9860    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9861    while (dst >= target) {
   9862        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
   9863        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9864        src -= 2;
   9865        dst[7] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
   9866        dst[6] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
   9867        dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
   9868        dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
   9869        dst[3] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
   9870        dst[2] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
   9871        dst[1] = (Sint16) sample1;
   9872        dst[0] = (Sint16) sample0;
   9873        last_sample1 = sample1;
   9874        last_sample0 = sample0;
   9875        dst -= 8;
   9876    }
   9877
   9878    cvt->len_cvt = dstsize;
   9879    if (cvt->filters[++cvt->filter_index]) {
   9880        cvt->filters[cvt->filter_index] (cvt, format);
   9881    }
   9882}
   9883
   9884static void SDLCALL
   9885SDL_Downsample_S16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9886{
   9887#if DEBUG_CONVERT
   9888    fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 2 channels.\n");
   9889#endif
   9890
   9891    const int dstsize = cvt->len_cvt / 4;
   9892    Sint16 *dst = (Sint16 *) cvt->buf;
   9893    const Sint16 *src = (Sint16 *) cvt->buf;
   9894    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   9895    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9896    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
   9897    while (dst < target) {
   9898        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9899        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
   9900        src += 8;
   9901        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
   9902        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
   9903        last_sample0 = sample0;
   9904        last_sample1 = sample1;
   9905        dst += 2;
   9906    }
   9907
   9908    cvt->len_cvt = dstsize;
   9909    if (cvt->filters[++cvt->filter_index]) {
   9910        cvt->filters[cvt->filter_index] (cvt, format);
   9911    }
   9912}
   9913
   9914static void SDLCALL
   9915SDL_Upsample_S16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9916{
   9917#if DEBUG_CONVERT
   9918    fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 4 channels.\n");
   9919#endif
   9920
   9921    const int dstsize = cvt->len_cvt * 2;
   9922    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4 * 2;
   9923    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
   9924    const Sint16 *target = ((const Sint16 *) cvt->buf);
   9925    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
   9926    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
   9927    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
   9928    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9929    while (dst >= target) {
   9930        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
   9931        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
   9932        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
   9933        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9934        src -= 4;
   9935        dst[7] = (Sint16) ((sample3 + last_sample3) >> 1);
   9936        dst[6] = (Sint16) ((sample2 + last_sample2) >> 1);
   9937        dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
   9938        dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
   9939        dst[3] = (Sint16) sample3;
   9940        dst[2] = (Sint16) sample2;
   9941        dst[1] = (Sint16) sample1;
   9942        dst[0] = (Sint16) sample0;
   9943        last_sample3 = sample3;
   9944        last_sample2 = sample2;
   9945        last_sample1 = sample1;
   9946        last_sample0 = sample0;
   9947        dst -= 8;
   9948    }
   9949
   9950    cvt->len_cvt = dstsize;
   9951    if (cvt->filters[++cvt->filter_index]) {
   9952        cvt->filters[cvt->filter_index] (cvt, format);
   9953    }
   9954}
   9955
   9956static void SDLCALL
   9957SDL_Downsample_S16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9958{
   9959#if DEBUG_CONVERT
   9960    fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 4 channels.\n");
   9961#endif
   9962
   9963    const int dstsize = cvt->len_cvt / 2;
   9964    Sint16 *dst = (Sint16 *) cvt->buf;
   9965    const Sint16 *src = (Sint16 *) cvt->buf;
   9966    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   9967    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9968    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
   9969    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
   9970    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
   9971    while (dst < target) {
   9972        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
   9973        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
   9974        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
   9975        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
   9976        src += 8;
   9977        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
   9978        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
   9979        dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
   9980        dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
   9981        last_sample0 = sample0;
   9982        last_sample1 = sample1;
   9983        last_sample2 = sample2;
   9984        last_sample3 = sample3;
   9985        dst += 4;
   9986    }
   9987
   9988    cvt->len_cvt = dstsize;
   9989    if (cvt->filters[++cvt->filter_index]) {
   9990        cvt->filters[cvt->filter_index] (cvt, format);
   9991    }
   9992}
   9993
   9994static void SDLCALL
   9995SDL_Upsample_S16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   9996{
   9997#if DEBUG_CONVERT
   9998    fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 4 channels.\n");
   9999#endif
  10000
  10001    const int dstsize = cvt->len_cvt * 4;
  10002    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4 * 4;
  10003    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
  10004    const Sint16 *target = ((const Sint16 *) cvt->buf);
  10005    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10006    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10007    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10008    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10009    while (dst >= target) {
  10010        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10011        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10012        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10013        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10014        src -= 4;
  10015        dst[15] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
  10016        dst[14] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
  10017        dst[13] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
  10018        dst[12] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
  10019        dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
  10020        dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
  10021        dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
  10022        dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
  10023        dst[7] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
  10024        dst[6] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
  10025        dst[5] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
  10026        dst[4] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
  10027        dst[3] = (Sint16) sample3;
  10028        dst[2] = (Sint16) sample2;
  10029        dst[1] = (Sint16) sample1;
  10030        dst[0] = (Sint16) sample0;
  10031        last_sample3 = sample3;
  10032        last_sample2 = sample2;
  10033        last_sample1 = sample1;
  10034        last_sample0 = sample0;
  10035        dst -= 16;
  10036    }
  10037
  10038    cvt->len_cvt = dstsize;
  10039    if (cvt->filters[++cvt->filter_index]) {
  10040        cvt->filters[cvt->filter_index] (cvt, format);
  10041    }
  10042}
  10043
  10044static void SDLCALL
  10045SDL_Downsample_S16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10046{
  10047#if DEBUG_CONVERT
  10048    fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 4 channels.\n");
  10049#endif
  10050
  10051    const int dstsize = cvt->len_cvt / 4;
  10052    Sint16 *dst = (Sint16 *) cvt->buf;
  10053    const Sint16 *src = (Sint16 *) cvt->buf;
  10054    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  10055    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10056    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10057    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10058    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10059    while (dst < target) {
  10060        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10061        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10062        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10063        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10064        src += 16;
  10065        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
  10066        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
  10067        dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
  10068        dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
  10069        last_sample0 = sample0;
  10070        last_sample1 = sample1;
  10071        last_sample2 = sample2;
  10072        last_sample3 = sample3;
  10073        dst += 4;
  10074    }
  10075
  10076    cvt->len_cvt = dstsize;
  10077    if (cvt->filters[++cvt->filter_index]) {
  10078        cvt->filters[cvt->filter_index] (cvt, format);
  10079    }
  10080}
  10081
  10082static void SDLCALL
  10083SDL_Upsample_S16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10084{
  10085#if DEBUG_CONVERT
  10086    fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 6 channels.\n");
  10087#endif
  10088
  10089    const int dstsize = cvt->len_cvt * 2;
  10090    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6 * 2;
  10091    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
  10092    const Sint16 *target = ((const Sint16 *) cvt->buf);
  10093    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10094    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10095    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10096    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10097    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10098    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10099    while (dst >= target) {
  10100        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10101        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10102        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10103        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10104        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10105        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10106        src -= 6;
  10107        dst[11] = (Sint16) ((sample5 + last_sample5) >> 1);
  10108        dst[10] = (Sint16) ((sample4 + last_sample4) >> 1);
  10109        dst[9] = (Sint16) ((sample3 + last_sample3) >> 1);
  10110        dst[8] = (Sint16) ((sample2 + last_sample2) >> 1);
  10111        dst[7] = (Sint16) ((sample1 + last_sample1) >> 1);
  10112        dst[6] = (Sint16) ((sample0 + last_sample0) >> 1);
  10113        dst[5] = (Sint16) sample5;
  10114        dst[4] = (Sint16) sample4;
  10115        dst[3] = (Sint16) sample3;
  10116        dst[2] = (Sint16) sample2;
  10117        dst[1] = (Sint16) sample1;
  10118        dst[0] = (Sint16) sample0;
  10119        last_sample5 = sample5;
  10120        last_sample4 = sample4;
  10121        last_sample3 = sample3;
  10122        last_sample2 = sample2;
  10123        last_sample1 = sample1;
  10124        last_sample0 = sample0;
  10125        dst -= 12;
  10126    }
  10127
  10128    cvt->len_cvt = dstsize;
  10129    if (cvt->filters[++cvt->filter_index]) {
  10130        cvt->filters[cvt->filter_index] (cvt, format);
  10131    }
  10132}
  10133
  10134static void SDLCALL
  10135SDL_Downsample_S16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10136{
  10137#if DEBUG_CONVERT
  10138    fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 6 channels.\n");
  10139#endif
  10140
  10141    const int dstsize = cvt->len_cvt / 2;
  10142    Sint16 *dst = (Sint16 *) cvt->buf;
  10143    const Sint16 *src = (Sint16 *) cvt->buf;
  10144    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  10145    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10146    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10147    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10148    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10149    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10150    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10151    while (dst < target) {
  10152        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10153        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10154        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10155        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10156        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10157        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10158        src += 12;
  10159        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
  10160        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
  10161        dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
  10162        dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
  10163        dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
  10164        dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
  10165        last_sample0 = sample0;
  10166        last_sample1 = sample1;
  10167        last_sample2 = sample2;
  10168        last_sample3 = sample3;
  10169        last_sample4 = sample4;
  10170        last_sample5 = sample5;
  10171        dst += 6;
  10172    }
  10173
  10174    cvt->len_cvt = dstsize;
  10175    if (cvt->filters[++cvt->filter_index]) {
  10176        cvt->filters[cvt->filter_index] (cvt, format);
  10177    }
  10178}
  10179
  10180static void SDLCALL
  10181SDL_Upsample_S16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10182{
  10183#if DEBUG_CONVERT
  10184    fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 6 channels.\n");
  10185#endif
  10186
  10187    const int dstsize = cvt->len_cvt * 4;
  10188    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6 * 4;
  10189    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
  10190    const Sint16 *target = ((const Sint16 *) cvt->buf);
  10191    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10192    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10193    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10194    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10195    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10196    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10197    while (dst >= target) {
  10198        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10199        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10200        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10201        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10202        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10203        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10204        src -= 6;
  10205        dst[23] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
  10206        dst[22] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
  10207        dst[21] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
  10208        dst[20] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
  10209        dst[19] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
  10210        dst[18] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
  10211        dst[17] = (Sint16) ((sample5 + last_sample5) >> 1);
  10212        dst[16] = (Sint16) ((sample4 + last_sample4) >> 1);
  10213        dst[15] = (Sint16) ((sample3 + last_sample3) >> 1);
  10214        dst[14] = (Sint16) ((sample2 + last_sample2) >> 1);
  10215        dst[13] = (Sint16) ((sample1 + last_sample1) >> 1);
  10216        dst[12] = (Sint16) ((sample0 + last_sample0) >> 1);
  10217        dst[11] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
  10218        dst[10] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
  10219        dst[9] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
  10220        dst[8] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
  10221        dst[7] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
  10222        dst[6] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
  10223        dst[5] = (Sint16) sample5;
  10224        dst[4] = (Sint16) sample4;
  10225        dst[3] = (Sint16) sample3;
  10226        dst[2] = (Sint16) sample2;
  10227        dst[1] = (Sint16) sample1;
  10228        dst[0] = (Sint16) sample0;
  10229        last_sample5 = sample5;
  10230        last_sample4 = sample4;
  10231        last_sample3 = sample3;
  10232        last_sample2 = sample2;
  10233        last_sample1 = sample1;
  10234        last_sample0 = sample0;
  10235        dst -= 24;
  10236    }
  10237
  10238    cvt->len_cvt = dstsize;
  10239    if (cvt->filters[++cvt->filter_index]) {
  10240        cvt->filters[cvt->filter_index] (cvt, format);
  10241    }
  10242}
  10243
  10244static void SDLCALL
  10245SDL_Downsample_S16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10246{
  10247#if DEBUG_CONVERT
  10248    fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 6 channels.\n");
  10249#endif
  10250
  10251    const int dstsize = cvt->len_cvt / 4;
  10252    Sint16 *dst = (Sint16 *) cvt->buf;
  10253    const Sint16 *src = (Sint16 *) cvt->buf;
  10254    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  10255    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10256    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10257    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10258    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10259    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10260    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10261    while (dst < target) {
  10262        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10263        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10264        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10265        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10266        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10267        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10268        src += 24;
  10269        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
  10270        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
  10271        dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
  10272        dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
  10273        dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
  10274        dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
  10275        last_sample0 = sample0;
  10276        last_sample1 = sample1;
  10277        last_sample2 = sample2;
  10278        last_sample3 = sample3;
  10279        last_sample4 = sample4;
  10280        last_sample5 = sample5;
  10281        dst += 6;
  10282    }
  10283
  10284    cvt->len_cvt = dstsize;
  10285    if (cvt->filters[++cvt->filter_index]) {
  10286        cvt->filters[cvt->filter_index] (cvt, format);
  10287    }
  10288}
  10289
  10290static void SDLCALL
  10291SDL_Upsample_S16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10292{
  10293#if DEBUG_CONVERT
  10294    fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 8 channels.\n");
  10295#endif
  10296
  10297    const int dstsize = cvt->len_cvt * 2;
  10298    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8 * 2;
  10299    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
  10300    const Sint16 *target = ((const Sint16 *) cvt->buf);
  10301    Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
  10302    Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
  10303    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10304    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10305    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10306    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10307    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10308    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10309    while (dst >= target) {
  10310        const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
  10311        const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
  10312        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10313        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10314        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10315        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10316        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10317        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10318        src -= 8;
  10319        dst[15] = (Sint16) ((sample7 + last_sample7) >> 1);
  10320        dst[14] = (Sint16) ((sample6 + last_sample6) >> 1);
  10321        dst[13] = (Sint16) ((sample5 + last_sample5) >> 1);
  10322        dst[12] = (Sint16) ((sample4 + last_sample4) >> 1);
  10323        dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
  10324        dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
  10325        dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
  10326        dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
  10327        dst[7] = (Sint16) sample7;
  10328        dst[6] = (Sint16) sample6;
  10329        dst[5] = (Sint16) sample5;
  10330        dst[4] = (Sint16) sample4;
  10331        dst[3] = (Sint16) sample3;
  10332        dst[2] = (Sint16) sample2;
  10333        dst[1] = (Sint16) sample1;
  10334        dst[0] = (Sint16) sample0;
  10335        last_sample7 = sample7;
  10336        last_sample6 = sample6;
  10337        last_sample5 = sample5;
  10338        last_sample4 = sample4;
  10339        last_sample3 = sample3;
  10340        last_sample2 = sample2;
  10341        last_sample1 = sample1;
  10342        last_sample0 = sample0;
  10343        dst -= 16;
  10344    }
  10345
  10346    cvt->len_cvt = dstsize;
  10347    if (cvt->filters[++cvt->filter_index]) {
  10348        cvt->filters[cvt->filter_index] (cvt, format);
  10349    }
  10350}
  10351
  10352static void SDLCALL
  10353SDL_Downsample_S16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10354{
  10355#if DEBUG_CONVERT
  10356    fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 8 channels.\n");
  10357#endif
  10358
  10359    const int dstsize = cvt->len_cvt / 2;
  10360    Sint16 *dst = (Sint16 *) cvt->buf;
  10361    const Sint16 *src = (Sint16 *) cvt->buf;
  10362    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  10363    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10364    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10365    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10366    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10367    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10368    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10369    Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
  10370    Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
  10371    while (dst < target) {
  10372        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10373        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10374        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10375        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10376        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10377        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10378        const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
  10379        const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
  10380        src += 16;
  10381        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
  10382        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
  10383        dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
  10384        dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
  10385        dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
  10386        dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
  10387        dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
  10388        dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
  10389        last_sample0 = sample0;
  10390        last_sample1 = sample1;
  10391        last_sample2 = sample2;
  10392        last_sample3 = sample3;
  10393        last_sample4 = sample4;
  10394        last_sample5 = sample5;
  10395        last_sample6 = sample6;
  10396        last_sample7 = sample7;
  10397        dst += 8;
  10398    }
  10399
  10400    cvt->len_cvt = dstsize;
  10401    if (cvt->filters[++cvt->filter_index]) {
  10402        cvt->filters[cvt->filter_index] (cvt, format);
  10403    }
  10404}
  10405
  10406static void SDLCALL
  10407SDL_Upsample_S16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10408{
  10409#if DEBUG_CONVERT
  10410    fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 8 channels.\n");
  10411#endif
  10412
  10413    const int dstsize = cvt->len_cvt * 4;
  10414    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8 * 4;
  10415    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
  10416    const Sint16 *target = ((const Sint16 *) cvt->buf);
  10417    Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
  10418    Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
  10419    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10420    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10421    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10422    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10423    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10424    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10425    while (dst >= target) {
  10426        const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
  10427        const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
  10428        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10429        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10430        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10431        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10432        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10433        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10434        src -= 8;
  10435        dst[31] = (Sint16) ((sample7 + (3 * last_sample7)) >> 2);
  10436        dst[30] = (Sint16) ((sample6 + (3 * last_sample6)) >> 2);
  10437        dst[29] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
  10438        dst[28] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
  10439        dst[27] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
  10440        dst[26] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
  10441        dst[25] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
  10442        dst[24] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
  10443        dst[23] = (Sint16) ((sample7 + last_sample7) >> 1);
  10444        dst[22] = (Sint16) ((sample6 + last_sample6) >> 1);
  10445        dst[21] = (Sint16) ((sample5 + last_sample5) >> 1);
  10446        dst[20] = (Sint16) ((sample4 + last_sample4) >> 1);
  10447        dst[19] = (Sint16) ((sample3 + last_sample3) >> 1);
  10448        dst[18] = (Sint16) ((sample2 + last_sample2) >> 1);
  10449        dst[17] = (Sint16) ((sample1 + last_sample1) >> 1);
  10450        dst[16] = (Sint16) ((sample0 + last_sample0) >> 1);
  10451        dst[15] = (Sint16) (((3 * sample7) + last_sample7) >> 2);
  10452        dst[14] = (Sint16) (((3 * sample6) + last_sample6) >> 2);
  10453        dst[13] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
  10454        dst[12] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
  10455        dst[11] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
  10456        dst[10] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
  10457        dst[9] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
  10458        dst[8] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
  10459        dst[7] = (Sint16) sample7;
  10460        dst[6] = (Sint16) sample6;
  10461        dst[5] = (Sint16) sample5;
  10462        dst[4] = (Sint16) sample4;
  10463        dst[3] = (Sint16) sample3;
  10464        dst[2] = (Sint16) sample2;
  10465        dst[1] = (Sint16) sample1;
  10466        dst[0] = (Sint16) sample0;
  10467        last_sample7 = sample7;
  10468        last_sample6 = sample6;
  10469        last_sample5 = sample5;
  10470        last_sample4 = sample4;
  10471        last_sample3 = sample3;
  10472        last_sample2 = sample2;
  10473        last_sample1 = sample1;
  10474        last_sample0 = sample0;
  10475        dst -= 32;
  10476    }
  10477
  10478    cvt->len_cvt = dstsize;
  10479    if (cvt->filters[++cvt->filter_index]) {
  10480        cvt->filters[cvt->filter_index] (cvt, format);
  10481    }
  10482}
  10483
  10484static void SDLCALL
  10485SDL_Downsample_S16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10486{
  10487#if DEBUG_CONVERT
  10488    fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 8 channels.\n");
  10489#endif
  10490
  10491    const int dstsize = cvt->len_cvt / 4;
  10492    Sint16 *dst = (Sint16 *) cvt->buf;
  10493    const Sint16 *src = (Sint16 *) cvt->buf;
  10494    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  10495    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10496    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10497    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10498    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10499    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10500    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10501    Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
  10502    Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
  10503    while (dst < target) {
  10504        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
  10505        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
  10506        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
  10507        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
  10508        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
  10509        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
  10510        const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
  10511        const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
  10512        src += 32;
  10513        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
  10514        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
  10515        dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
  10516        dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
  10517        dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
  10518        dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
  10519        dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
  10520        dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
  10521        last_sample0 = sample0;
  10522        last_sample1 = sample1;
  10523        last_sample2 = sample2;
  10524        last_sample3 = sample3;
  10525        last_sample4 = sample4;
  10526        last_sample5 = sample5;
  10527        last_sample6 = sample6;
  10528        last_sample7 = sample7;
  10529        dst += 8;
  10530    }
  10531
  10532    cvt->len_cvt = dstsize;
  10533    if (cvt->filters[++cvt->filter_index]) {
  10534        cvt->filters[cvt->filter_index] (cvt, format);
  10535    }
  10536}
  10537
  10538static void SDLCALL
  10539SDL_Upsample_U16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10540{
  10541#if DEBUG_CONVERT
  10542    fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 1 channels.\n");
  10543#endif
  10544
  10545    const int dstsize = cvt->len_cvt * 2;
  10546    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1 * 2;
  10547    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  10548    const Uint16 *target = ((const Uint16 *) cvt->buf);
  10549    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10550    while (dst >= target) {
  10551        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10552        src--;
  10553        dst[1] = (Uint16) ((sample0 + last_sample0) >> 1);
  10554        dst[0] = (Uint16) sample0;
  10555        last_sample0 = sample0;
  10556        dst -= 2;
  10557    }
  10558
  10559    cvt->len_cvt = dstsize;
  10560    if (cvt->filters[++cvt->filter_index]) {
  10561        cvt->filters[cvt->filter_index] (cvt, format);
  10562    }
  10563}
  10564
  10565static void SDLCALL
  10566SDL_Downsample_U16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10567{
  10568#if DEBUG_CONVERT
  10569    fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 1 channels.\n");
  10570#endif
  10571
  10572    const int dstsize = cvt->len_cvt / 2;
  10573    Uint16 *dst = (Uint16 *) cvt->buf;
  10574    const Uint16 *src = (Uint16 *) cvt->buf;
  10575    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  10576    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10577    while (dst < target) {
  10578        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10579        src += 2;
  10580        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
  10581        last_sample0 = sample0;
  10582        dst++;
  10583    }
  10584
  10585    cvt->len_cvt = dstsize;
  10586    if (cvt->filters[++cvt->filter_index]) {
  10587        cvt->filters[cvt->filter_index] (cvt, format);
  10588    }
  10589}
  10590
  10591static void SDLCALL
  10592SDL_Upsample_U16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10593{
  10594#if DEBUG_CONVERT
  10595    fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 1 channels.\n");
  10596#endif
  10597
  10598    const int dstsize = cvt->len_cvt * 4;
  10599    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1 * 4;
  10600    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  10601    const Uint16 *target = ((const Uint16 *) cvt->buf);
  10602    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10603    while (dst >= target) {
  10604        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10605        src--;
  10606        dst[3] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
  10607        dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
  10608        dst[1] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
  10609        dst[0] = (Uint16) sample0;
  10610        last_sample0 = sample0;
  10611        dst -= 4;
  10612    }
  10613
  10614    cvt->len_cvt = dstsize;
  10615    if (cvt->filters[++cvt->filter_index]) {
  10616        cvt->filters[cvt->filter_index] (cvt, format);
  10617    }
  10618}
  10619
  10620static void SDLCALL
  10621SDL_Downsample_U16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10622{
  10623#if DEBUG_CONVERT
  10624    fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 1 channels.\n");
  10625#endif
  10626
  10627    const int dstsize = cvt->len_cvt / 4;
  10628    Uint16 *dst = (Uint16 *) cvt->buf;
  10629    const Uint16 *src = (Uint16 *) cvt->buf;
  10630    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  10631    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10632    while (dst < target) {
  10633        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10634        src += 4;
  10635        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
  10636        last_sample0 = sample0;
  10637        dst++;
  10638    }
  10639
  10640    cvt->len_cvt = dstsize;
  10641    if (cvt->filters[++cvt->filter_index]) {
  10642        cvt->filters[cvt->filter_index] (cvt, format);
  10643    }
  10644}
  10645
  10646static void SDLCALL
  10647SDL_Upsample_U16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10648{
  10649#if DEBUG_CONVERT
  10650    fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 2 channels.\n");
  10651#endif
  10652
  10653    const int dstsize = cvt->len_cvt * 2;
  10654    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2 * 2;
  10655    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
  10656    const Uint16 *target = ((const Uint16 *) cvt->buf);
  10657    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10658    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10659    while (dst >= target) {
  10660        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10661        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10662        src -= 2;
  10663        dst[3] = (Uint16) ((sample1 + last_sample1) >> 1);
  10664        dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
  10665        dst[1] = (Uint16) sample1;
  10666        dst[0] = (Uint16) sample0;
  10667        last_sample1 = sample1;
  10668        last_sample0 = sample0;
  10669        dst -= 4;
  10670    }
  10671
  10672    cvt->len_cvt = dstsize;
  10673    if (cvt->filters[++cvt->filter_index]) {
  10674        cvt->filters[cvt->filter_index] (cvt, format);
  10675    }
  10676}
  10677
  10678static void SDLCALL
  10679SDL_Downsample_U16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10680{
  10681#if DEBUG_CONVERT
  10682    fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 2 channels.\n");
  10683#endif
  10684
  10685    const int dstsize = cvt->len_cvt / 2;
  10686    Uint16 *dst = (Uint16 *) cvt->buf;
  10687    const Uint16 *src = (Uint16 *) cvt->buf;
  10688    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  10689    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10690    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10691    while (dst < target) {
  10692        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10693        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10694        src += 4;
  10695        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
  10696        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
  10697        last_sample0 = sample0;
  10698        last_sample1 = sample1;
  10699        dst += 2;
  10700    }
  10701
  10702    cvt->len_cvt = dstsize;
  10703    if (cvt->filters[++cvt->filter_index]) {
  10704        cvt->filters[cvt->filter_index] (cvt, format);
  10705    }
  10706}
  10707
  10708static void SDLCALL
  10709SDL_Upsample_U16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10710{
  10711#if DEBUG_CONVERT
  10712    fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 2 channels.\n");
  10713#endif
  10714
  10715    const int dstsize = cvt->len_cvt * 4;
  10716    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2 * 4;
  10717    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
  10718    const Uint16 *target = ((const Uint16 *) cvt->buf);
  10719    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10720    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10721    while (dst >= target) {
  10722        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10723        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10724        src -= 2;
  10725        dst[7] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
  10726        dst[6] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
  10727        dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
  10728        dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
  10729        dst[3] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
  10730        dst[2] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
  10731        dst[1] = (Uint16) sample1;
  10732        dst[0] = (Uint16) sample0;
  10733        last_sample1 = sample1;
  10734        last_sample0 = sample0;
  10735        dst -= 8;
  10736    }
  10737
  10738    cvt->len_cvt = dstsize;
  10739    if (cvt->filters[++cvt->filter_index]) {
  10740        cvt->filters[cvt->filter_index] (cvt, format);
  10741    }
  10742}
  10743
  10744static void SDLCALL
  10745SDL_Downsample_U16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10746{
  10747#if DEBUG_CONVERT
  10748    fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 2 channels.\n");
  10749#endif
  10750
  10751    const int dstsize = cvt->len_cvt / 4;
  10752    Uint16 *dst = (Uint16 *) cvt->buf;
  10753    const Uint16 *src = (Uint16 *) cvt->buf;
  10754    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  10755    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10756    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10757    while (dst < target) {
  10758        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10759        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10760        src += 8;
  10761        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
  10762        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
  10763        last_sample0 = sample0;
  10764        last_sample1 = sample1;
  10765        dst += 2;
  10766    }
  10767
  10768    cvt->len_cvt = dstsize;
  10769    if (cvt->filters[++cvt->filter_index]) {
  10770        cvt->filters[cvt->filter_index] (cvt, format);
  10771    }
  10772}
  10773
  10774static void SDLCALL
  10775SDL_Upsample_U16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10776{
  10777#if DEBUG_CONVERT
  10778    fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 4 channels.\n");
  10779#endif
  10780
  10781    const int dstsize = cvt->len_cvt * 2;
  10782    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4 * 2;
  10783    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
  10784    const Uint16 *target = ((const Uint16 *) cvt->buf);
  10785    Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
  10786    Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
  10787    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10788    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10789    while (dst >= target) {
  10790        const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
  10791        const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
  10792        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10793        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10794        src -= 4;
  10795        dst[7] = (Uint16) ((sample3 + last_sample3) >> 1);
  10796        dst[6] = (Uint16) ((sample2 + last_sample2) >> 1);
  10797        dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
  10798        dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
  10799        dst[3] = (Uint16) sample3;
  10800        dst[2] = (Uint16) sample2;
  10801        dst[1] = (Uint16) sample1;
  10802        dst[0] = (Uint16) sample0;
  10803        last_sample3 = sample3;
  10804        last_sample2 = sample2;
  10805        last_sample1 = sample1;
  10806        last_sample0 = sample0;
  10807        dst -= 8;
  10808    }
  10809
  10810    cvt->len_cvt = dstsize;
  10811    if (cvt->filters[++cvt->filter_index]) {
  10812        cvt->filters[cvt->filter_index] (cvt, format);
  10813    }
  10814}
  10815
  10816static void SDLCALL
  10817SDL_Downsample_U16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10818{
  10819#if DEBUG_CONVERT
  10820    fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 4 channels.\n");
  10821#endif
  10822
  10823    const int dstsize = cvt->len_cvt / 2;
  10824    Uint16 *dst = (Uint16 *) cvt->buf;
  10825    const Uint16 *src = (Uint16 *) cvt->buf;
  10826    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  10827    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10828    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10829    Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
  10830    Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
  10831    while (dst < target) {
  10832        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10833        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10834        const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
  10835        const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
  10836        src += 8;
  10837        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
  10838        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
  10839        dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
  10840        dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
  10841        last_sample0 = sample0;
  10842        last_sample1 = sample1;
  10843        last_sample2 = sample2;
  10844        last_sample3 = sample3;
  10845        dst += 4;
  10846    }
  10847
  10848    cvt->len_cvt = dstsize;
  10849    if (cvt->filters[++cvt->filter_index]) {
  10850        cvt->filters[cvt->filter_index] (cvt, format);
  10851    }
  10852}
  10853
  10854static void SDLCALL
  10855SDL_Upsample_U16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10856{
  10857#if DEBUG_CONVERT
  10858    fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 4 channels.\n");
  10859#endif
  10860
  10861    const int dstsize = cvt->len_cvt * 4;
  10862    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4 * 4;
  10863    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
  10864    const Uint16 *target = ((const Uint16 *) cvt->buf);
  10865    Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
  10866    Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
  10867    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10868    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10869    while (dst >= target) {
  10870        const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
  10871        const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
  10872        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10873        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10874        src -= 4;
  10875        dst[15] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
  10876        dst[14] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
  10877        dst[13] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
  10878        dst[12] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
  10879        dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
  10880        dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
  10881        dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
  10882        dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
  10883        dst[7] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
  10884        dst[6] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
  10885        dst[5] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
  10886        dst[4] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
  10887        dst[3] = (Uint16) sample3;
  10888        dst[2] = (Uint16) sample2;
  10889        dst[1] = (Uint16) sample1;
  10890        dst[0] = (Uint16) sample0;
  10891        last_sample3 = sample3;
  10892        last_sample2 = sample2;
  10893        last_sample1 = sample1;
  10894        last_sample0 = sample0;
  10895        dst -= 16;
  10896    }
  10897
  10898    cvt->len_cvt = dstsize;
  10899    if (cvt->filters[++cvt->filter_index]) {
  10900        cvt->filters[cvt->filter_index] (cvt, format);
  10901    }
  10902}
  10903
  10904static void SDLCALL
  10905SDL_Downsample_U16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10906{
  10907#if DEBUG_CONVERT
  10908    fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 4 channels.\n");
  10909#endif
  10910
  10911    const int dstsize = cvt->len_cvt / 4;
  10912    Uint16 *dst = (Uint16 *) cvt->buf;
  10913    const Uint16 *src = (Uint16 *) cvt->buf;
  10914    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  10915    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10916    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10917    Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
  10918    Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
  10919    while (dst < target) {
  10920        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10921        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10922        const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
  10923        const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
  10924        src += 16;
  10925        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
  10926        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
  10927        dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
  10928        dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
  10929        last_sample0 = sample0;
  10930        last_sample1 = sample1;
  10931        last_sample2 = sample2;
  10932        last_sample3 = sample3;
  10933        dst += 4;
  10934    }
  10935
  10936    cvt->len_cvt = dstsize;
  10937    if (cvt->filters[++cvt->filter_index]) {
  10938        cvt->filters[cvt->filter_index] (cvt, format);
  10939    }
  10940}
  10941
  10942static void SDLCALL
  10943SDL_Upsample_U16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10944{
  10945#if DEBUG_CONVERT
  10946    fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 6 channels.\n");
  10947#endif
  10948
  10949    const int dstsize = cvt->len_cvt * 2;
  10950    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6 * 2;
  10951    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
  10952    const Uint16 *target = ((const Uint16 *) cvt->buf);
  10953    Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
  10954    Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
  10955    Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
  10956    Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
  10957    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10958    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10959    while (dst >= target) {
  10960        const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
  10961        const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
  10962        const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
  10963        const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
  10964        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  10965        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  10966        src -= 6;
  10967        dst[11] = (Uint16) ((sample5 + last_sample5) >> 1);
  10968        dst[10] = (Uint16) ((sample4 + last_sample4) >> 1);
  10969        dst[9] = (Uint16) ((sample3 + last_sample3) >> 1);
  10970        dst[8] = (Uint16) ((sample2 + last_sample2) >> 1);
  10971        dst[7] = (Uint16) ((sample1 + last_sample1) >> 1);
  10972        dst[6] = (Uint16) ((sample0 + last_sample0) >> 1);
  10973        dst[5] = (Uint16) sample5;
  10974        dst[4] = (Uint16) sample4;
  10975        dst[3] = (Uint16) sample3;
  10976        dst[2] = (Uint16) sample2;
  10977        dst[1] = (Uint16) sample1;
  10978        dst[0] = (Uint16) sample0;
  10979        last_sample5 = sample5;
  10980        last_sample4 = sample4;
  10981        last_sample3 = sample3;
  10982        last_sample2 = sample2;
  10983        last_sample1 = sample1;
  10984        last_sample0 = sample0;
  10985        dst -= 12;
  10986    }
  10987
  10988    cvt->len_cvt = dstsize;
  10989    if (cvt->filters[++cvt->filter_index]) {
  10990        cvt->filters[cvt->filter_index] (cvt, format);
  10991    }
  10992}
  10993
  10994static void SDLCALL
  10995SDL_Downsample_U16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  10996{
  10997#if DEBUG_CONVERT
  10998    fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 6 channels.\n");
  10999#endif
  11000
  11001    const int dstsize = cvt->len_cvt / 2;
  11002    Uint16 *dst = (Uint16 *) cvt->buf;
  11003    const Uint16 *src = (Uint16 *) cvt->buf;
  11004    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  11005    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  11006    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  11007    Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
  11008    Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
  11009    Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
  11010    Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
  11011    while (dst < target) {
  11012        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  11013        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  11014        const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
  11015        const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
  11016        const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
  11017        const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
  11018        src += 12;
  11019        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
  11020        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
  11021        dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
  11022        dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
  11023        dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
  11024        dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
  11025        last_sample0 = sample0;
  11026        last_sample1 = sample1;
  11027        last_sample2 = sample2;
  11028        last_sample3 = sample3;
  11029        last_sample4 = sample4;
  11030        last_sample5 = sample5;
  11031        dst += 6;
  11032    }
  11033
  11034    cvt->len_cvt = dstsize;
  11035    if (cvt->filters[++cvt->filter_index]) {
  11036        cvt->filters[cvt->filter_index] (cvt, format);
  11037    }
  11038}
  11039
  11040static void SDLCALL
  11041SDL_Upsample_U16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11042{
  11043#if DEBUG_CONVERT
  11044    fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 6 channels.\n");
  11045#endif
  11046
  11047    const int dstsize = cvt->len_cvt * 4;
  11048    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6 * 4;
  11049    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
  11050    const Uint16 *target = ((const Uint16 *) cvt->buf);
  11051    Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
  11052    Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
  11053    Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
  11054    Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
  11055    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  11056    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  11057    while (dst >= target) {
  11058        const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
  11059        const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
  11060        const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
  11061        const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
  11062        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  11063        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  11064        src -= 6;
  11065        dst[23] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
  11066        dst[22] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
  11067        dst[21] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
  11068        dst[20] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
  11069        dst[19] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
  11070        dst[18] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
  11071        dst[17] = (Uint16) ((sample5 + last_sample5) >> 1);
  11072        dst[16] = (Uint16) ((sample4 + last_sample4) >> 1);
  11073        dst[15] = (Uint16) ((sample3 + last_sample3) >> 1);
  11074        dst[14] = (Uint16) ((sample2 + last_sample2) >> 1);
  11075        dst[13] = (Uint16) ((sample1 + last_sample1) >> 1);
  11076        dst[12] = (Uint16) ((sample0 + last_sample0) >> 1);
  11077        dst[11] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
  11078        dst[10] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
  11079        dst[9] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
  11080        dst[8] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
  11081        dst[7] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
  11082        dst[6] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
  11083        dst[5] = (Uint16) sample5;
  11084        dst[4] = (Uint16) sample4;
  11085        dst[3] = (Uint16) sample3;
  11086        dst[2] = (Uint16) sample2;
  11087        dst[1] = (Uint16) sample1;
  11088        dst[0] = (Uint16) sample0;
  11089        last_sample5 = sample5;
  11090        last_sample4 = sample4;
  11091        last_sample3 = sample3;
  11092        last_sample2 = sample2;
  11093        last_sample1 = sample1;
  11094        last_sample0 = sample0;
  11095        dst -= 24;
  11096    }
  11097
  11098    cvt->len_cvt = dstsize;
  11099    if (cvt->filters[++cvt->filter_index]) {
  11100        cvt->filters[cvt->filter_index] (cvt, format);
  11101    }
  11102}
  11103
  11104static void SDLCALL
  11105SDL_Downsample_U16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11106{
  11107#if DEBUG_CONVERT
  11108    fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 6 channels.\n");
  11109#endif
  11110
  11111    const int dstsize = cvt->len_cvt / 4;
  11112    Uint16 *dst = (Uint16 *) cvt->buf;
  11113    const Uint16 *src = (Uint16 *) cvt->buf;
  11114    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  11115    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  11116    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  11117    Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
  11118    Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
  11119    Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
  11120    Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
  11121    while (dst < target) {
  11122        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  11123        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  11124        const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
  11125        const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
  11126        const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
  11127        const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
  11128        src += 24;
  11129        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
  11130        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
  11131        dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
  11132        dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
  11133        dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
  11134        dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
  11135        last_sample0 = sample0;
  11136        last_sample1 = sample1;
  11137        last_sample2 = sample2;
  11138        last_sample3 = sample3;
  11139        last_sample4 = sample4;
  11140        last_sample5 = sample5;
  11141        dst += 6;
  11142    }
  11143
  11144    cvt->len_cvt = dstsize;
  11145    if (cvt->filters[++cvt->filter_index]) {
  11146        cvt->filters[cvt->filter_index] (cvt, format);
  11147    }
  11148}
  11149
  11150static void SDLCALL
  11151SDL_Upsample_U16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11152{
  11153#if DEBUG_CONVERT
  11154    fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 8 channels.\n");
  11155#endif
  11156
  11157    const int dstsize = cvt->len_cvt * 2;
  11158    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8 * 2;
  11159    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
  11160    const Uint16 *target = ((const Uint16 *) cvt->buf);
  11161    Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
  11162    Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
  11163    Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
  11164    Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
  11165    Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
  11166    Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
  11167    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  11168    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  11169    while (dst >= target) {
  11170        const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
  11171        const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
  11172        const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
  11173        const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
  11174        const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
  11175        const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
  11176        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  11177        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  11178        src -= 8;
  11179        dst[15] = (Uint16) ((sample7 + last_sample7) >> 1);
  11180        dst[14] = (Uint16) ((sample6 + last_sample6) >> 1);
  11181        dst[13] = (Uint16) ((sample5 + last_sample5) >> 1);
  11182        dst[12] = (Uint16) ((sample4 + last_sample4) >> 1);
  11183        dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
  11184        dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
  11185        dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
  11186        dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
  11187        dst[7] = (Uint16) sample7;
  11188        dst[6] = (Uint16) sample6;
  11189        dst[5] = (Uint16) sample5;
  11190        dst[4] = (Uint16) sample4;
  11191        dst[3] = (Uint16) sample3;
  11192        dst[2] = (Uint16) sample2;
  11193        dst[1] = (Uint16) sample1;
  11194        dst[0] = (Uint16) sample0;
  11195        last_sample7 = sample7;
  11196        last_sample6 = sample6;
  11197        last_sample5 = sample5;
  11198        last_sample4 = sample4;
  11199        last_sample3 = sample3;
  11200        last_sample2 = sample2;
  11201        last_sample1 = sample1;
  11202        last_sample0 = sample0;
  11203        dst -= 16;
  11204    }
  11205
  11206    cvt->len_cvt = dstsize;
  11207    if (cvt->filters[++cvt->filter_index]) {
  11208        cvt->filters[cvt->filter_index] (cvt, format);
  11209    }
  11210}
  11211
  11212static void SDLCALL
  11213SDL_Downsample_U16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11214{
  11215#if DEBUG_CONVERT
  11216    fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 8 channels.\n");
  11217#endif
  11218
  11219    const int dstsize = cvt->len_cvt / 2;
  11220    Uint16 *dst = (Uint16 *) cvt->buf;
  11221    const Uint16 *src = (Uint16 *) cvt->buf;
  11222    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  11223    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  11224    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  11225    Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
  11226    Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
  11227    Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
  11228    Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
  11229    Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
  11230    Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
  11231    while (dst < target) {
  11232        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  11233        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  11234        const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
  11235        const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
  11236        const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
  11237        const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
  11238        const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
  11239        const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
  11240        src += 16;
  11241        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
  11242        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
  11243        dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
  11244        dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
  11245        dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
  11246        dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
  11247        dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
  11248        dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
  11249        last_sample0 = sample0;
  11250        last_sample1 = sample1;
  11251        last_sample2 = sample2;
  11252        last_sample3 = sample3;
  11253        last_sample4 = sample4;
  11254        last_sample5 = sample5;
  11255        last_sample6 = sample6;
  11256        last_sample7 = sample7;
  11257        dst += 8;
  11258    }
  11259
  11260    cvt->len_cvt = dstsize;
  11261    if (cvt->filters[++cvt->filter_index]) {
  11262        cvt->filters[cvt->filter_index] (cvt, format);
  11263    }
  11264}
  11265
  11266static void SDLCALL
  11267SDL_Upsample_U16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11268{
  11269#if DEBUG_CONVERT
  11270    fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 8 channels.\n");
  11271#endif
  11272
  11273    const int dstsize = cvt->len_cvt * 4;
  11274    Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8 * 4;
  11275    const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
  11276    const Uint16 *target = ((const Uint16 *) cvt->buf);
  11277    Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
  11278    Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
  11279    Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
  11280    Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
  11281    Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
  11282    Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
  11283    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  11284    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  11285    while (dst >= target) {
  11286        const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
  11287        const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
  11288        const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
  11289        const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
  11290        const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
  11291        const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
  11292        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  11293        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  11294        src -= 8;
  11295        dst[31] = (Uint16) ((sample7 + (3 * last_sample7)) >> 2);
  11296        dst[30] = (Uint16) ((sample6 + (3 * last_sample6)) >> 2);
  11297        dst[29] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
  11298        dst[28] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
  11299        dst[27] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
  11300        dst[26] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
  11301        dst[25] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
  11302        dst[24] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
  11303        dst[23] = (Uint16) ((sample7 + last_sample7) >> 1);
  11304        dst[22] = (Uint16) ((sample6 + last_sample6) >> 1);
  11305        dst[21] = (Uint16) ((sample5 + last_sample5) >> 1);
  11306        dst[20] = (Uint16) ((sample4 + last_sample4) >> 1);
  11307        dst[19] = (Uint16) ((sample3 + last_sample3) >> 1);
  11308        dst[18] = (Uint16) ((sample2 + last_sample2) >> 1);
  11309        dst[17] = (Uint16) ((sample1 + last_sample1) >> 1);
  11310        dst[16] = (Uint16) ((sample0 + last_sample0) >> 1);
  11311        dst[15] = (Uint16) (((3 * sample7) + last_sample7) >> 2);
  11312        dst[14] = (Uint16) (((3 * sample6) + last_sample6) >> 2);
  11313        dst[13] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
  11314        dst[12] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
  11315        dst[11] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
  11316        dst[10] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
  11317        dst[9] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
  11318        dst[8] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
  11319        dst[7] = (Uint16) sample7;
  11320        dst[6] = (Uint16) sample6;
  11321        dst[5] = (Uint16) sample5;
  11322        dst[4] = (Uint16) sample4;
  11323        dst[3] = (Uint16) sample3;
  11324        dst[2] = (Uint16) sample2;
  11325        dst[1] = (Uint16) sample1;
  11326        dst[0] = (Uint16) sample0;
  11327        last_sample7 = sample7;
  11328        last_sample6 = sample6;
  11329        last_sample5 = sample5;
  11330        last_sample4 = sample4;
  11331        last_sample3 = sample3;
  11332        last_sample2 = sample2;
  11333        last_sample1 = sample1;
  11334        last_sample0 = sample0;
  11335        dst -= 32;
  11336    }
  11337
  11338    cvt->len_cvt = dstsize;
  11339    if (cvt->filters[++cvt->filter_index]) {
  11340        cvt->filters[cvt->filter_index] (cvt, format);
  11341    }
  11342}
  11343
  11344static void SDLCALL
  11345SDL_Downsample_U16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11346{
  11347#if DEBUG_CONVERT
  11348    fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 8 channels.\n");
  11349#endif
  11350
  11351    const int dstsize = cvt->len_cvt / 4;
  11352    Uint16 *dst = (Uint16 *) cvt->buf;
  11353    const Uint16 *src = (Uint16 *) cvt->buf;
  11354    const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
  11355    Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
  11356    Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
  11357    Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
  11358    Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
  11359    Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
  11360    Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
  11361    Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
  11362    Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
  11363    while (dst < target) {
  11364        const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
  11365        const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
  11366        const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
  11367        const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
  11368        const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
  11369        const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
  11370        const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
  11371        const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
  11372        src += 32;
  11373        dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
  11374        dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
  11375        dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
  11376        dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
  11377        dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
  11378        dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
  11379        dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
  11380        dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
  11381        last_sample0 = sample0;
  11382        last_sample1 = sample1;
  11383        last_sample2 = sample2;
  11384        last_sample3 = sample3;
  11385        last_sample4 = sample4;
  11386        last_sample5 = sample5;
  11387        last_sample6 = sample6;
  11388        last_sample7 = sample7;
  11389        dst += 8;
  11390    }
  11391
  11392    cvt->len_cvt = dstsize;
  11393    if (cvt->filters[++cvt->filter_index]) {
  11394        cvt->filters[cvt->filter_index] (cvt, format);
  11395    }
  11396}
  11397
  11398static void SDLCALL
  11399SDL_Upsample_S16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11400{
  11401#if DEBUG_CONVERT
  11402    fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 1 channels.\n");
  11403#endif
  11404
  11405    const int dstsize = cvt->len_cvt * 2;
  11406    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1 * 2;
  11407    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  11408    const Sint16 *target = ((const Sint16 *) cvt->buf);
  11409    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11410    while (dst >= target) {
  11411        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11412        src--;
  11413        dst[1] = (Sint16) ((sample0 + last_sample0) >> 1);
  11414        dst[0] = (Sint16) sample0;
  11415        last_sample0 = sample0;
  11416        dst -= 2;
  11417    }
  11418
  11419    cvt->len_cvt = dstsize;
  11420    if (cvt->filters[++cvt->filter_index]) {
  11421        cvt->filters[cvt->filter_index] (cvt, format);
  11422    }
  11423}
  11424
  11425static void SDLCALL
  11426SDL_Downsample_S16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11427{
  11428#if DEBUG_CONVERT
  11429    fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 1 channels.\n");
  11430#endif
  11431
  11432    const int dstsize = cvt->len_cvt / 2;
  11433    Sint16 *dst = (Sint16 *) cvt->buf;
  11434    const Sint16 *src = (Sint16 *) cvt->buf;
  11435    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  11436    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11437    while (dst < target) {
  11438        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11439        src += 2;
  11440        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
  11441        last_sample0 = sample0;
  11442        dst++;
  11443    }
  11444
  11445    cvt->len_cvt = dstsize;
  11446    if (cvt->filters[++cvt->filter_index]) {
  11447        cvt->filters[cvt->filter_index] (cvt, format);
  11448    }
  11449}
  11450
  11451static void SDLCALL
  11452SDL_Upsample_S16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11453{
  11454#if DEBUG_CONVERT
  11455    fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 1 channels.\n");
  11456#endif
  11457
  11458    const int dstsize = cvt->len_cvt * 4;
  11459    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1 * 4;
  11460    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
  11461    const Sint16 *target = ((const Sint16 *) cvt->buf);
  11462    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11463    while (dst >= target) {
  11464        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11465        src--;
  11466        dst[3] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
  11467        dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
  11468        dst[1] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
  11469        dst[0] = (Sint16) sample0;
  11470        last_sample0 = sample0;
  11471        dst -= 4;
  11472    }
  11473
  11474    cvt->len_cvt = dstsize;
  11475    if (cvt->filters[++cvt->filter_index]) {
  11476        cvt->filters[cvt->filter_index] (cvt, format);
  11477    }
  11478}
  11479
  11480static void SDLCALL
  11481SDL_Downsample_S16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11482{
  11483#if DEBUG_CONVERT
  11484    fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 1 channels.\n");
  11485#endif
  11486
  11487    const int dstsize = cvt->len_cvt / 4;
  11488    Sint16 *dst = (Sint16 *) cvt->buf;
  11489    const Sint16 *src = (Sint16 *) cvt->buf;
  11490    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  11491    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11492    while (dst < target) {
  11493        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11494        src += 4;
  11495        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
  11496        last_sample0 = sample0;
  11497        dst++;
  11498    }
  11499
  11500    cvt->len_cvt = dstsize;
  11501    if (cvt->filters[++cvt->filter_index]) {
  11502        cvt->filters[cvt->filter_index] (cvt, format);
  11503    }
  11504}
  11505
  11506static void SDLCALL
  11507SDL_Upsample_S16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11508{
  11509#if DEBUG_CONVERT
  11510    fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 2 channels.\n");
  11511#endif
  11512
  11513    const int dstsize = cvt->len_cvt * 2;
  11514    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2 * 2;
  11515    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
  11516    const Sint16 *target = ((const Sint16 *) cvt->buf);
  11517    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11518    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11519    while (dst >= target) {
  11520        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11521        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11522        src -= 2;
  11523        dst[3] = (Sint16) ((sample1 + last_sample1) >> 1);
  11524        dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
  11525        dst[1] = (Sint16) sample1;
  11526        dst[0] = (Sint16) sample0;
  11527        last_sample1 = sample1;
  11528        last_sample0 = sample0;
  11529        dst -= 4;
  11530    }
  11531
  11532    cvt->len_cvt = dstsize;
  11533    if (cvt->filters[++cvt->filter_index]) {
  11534        cvt->filters[cvt->filter_index] (cvt, format);
  11535    }
  11536}
  11537
  11538static void SDLCALL
  11539SDL_Downsample_S16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11540{
  11541#if DEBUG_CONVERT
  11542    fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 2 channels.\n");
  11543#endif
  11544
  11545    const int dstsize = cvt->len_cvt / 2;
  11546    Sint16 *dst = (Sint16 *) cvt->buf;
  11547    const Sint16 *src = (Sint16 *) cvt->buf;
  11548    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  11549    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11550    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11551    while (dst < target) {
  11552        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11553        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11554        src += 4;
  11555        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
  11556        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
  11557        last_sample0 = sample0;
  11558        last_sample1 = sample1;
  11559        dst += 2;
  11560    }
  11561
  11562    cvt->len_cvt = dstsize;
  11563    if (cvt->filters[++cvt->filter_index]) {
  11564        cvt->filters[cvt->filter_index] (cvt, format);
  11565    }
  11566}
  11567
  11568static void SDLCALL
  11569SDL_Upsample_S16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11570{
  11571#if DEBUG_CONVERT
  11572    fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 2 channels.\n");
  11573#endif
  11574
  11575    const int dstsize = cvt->len_cvt * 4;
  11576    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2 * 4;
  11577    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
  11578    const Sint16 *target = ((const Sint16 *) cvt->buf);
  11579    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11580    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11581    while (dst >= target) {
  11582        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11583        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11584        src -= 2;
  11585        dst[7] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
  11586        dst[6] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
  11587        dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
  11588        dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
  11589        dst[3] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
  11590        dst[2] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
  11591        dst[1] = (Sint16) sample1;
  11592        dst[0] = (Sint16) sample0;
  11593        last_sample1 = sample1;
  11594        last_sample0 = sample0;
  11595        dst -= 8;
  11596    }
  11597
  11598    cvt->len_cvt = dstsize;
  11599    if (cvt->filters[++cvt->filter_index]) {
  11600        cvt->filters[cvt->filter_index] (cvt, format);
  11601    }
  11602}
  11603
  11604static void SDLCALL
  11605SDL_Downsample_S16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11606{
  11607#if DEBUG_CONVERT
  11608    fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 2 channels.\n");
  11609#endif
  11610
  11611    const int dstsize = cvt->len_cvt / 4;
  11612    Sint16 *dst = (Sint16 *) cvt->buf;
  11613    const Sint16 *src = (Sint16 *) cvt->buf;
  11614    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  11615    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11616    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11617    while (dst < target) {
  11618        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11619        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11620        src += 8;
  11621        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
  11622        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
  11623        last_sample0 = sample0;
  11624        last_sample1 = sample1;
  11625        dst += 2;
  11626    }
  11627
  11628    cvt->len_cvt = dstsize;
  11629    if (cvt->filters[++cvt->filter_index]) {
  11630        cvt->filters[cvt->filter_index] (cvt, format);
  11631    }
  11632}
  11633
  11634static void SDLCALL
  11635SDL_Upsample_S16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11636{
  11637#if DEBUG_CONVERT
  11638    fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 4 channels.\n");
  11639#endif
  11640
  11641    const int dstsize = cvt->len_cvt * 2;
  11642    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4 * 2;
  11643    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
  11644    const Sint16 *target = ((const Sint16 *) cvt->buf);
  11645    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11646    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11647    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11648    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11649    while (dst >= target) {
  11650        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11651        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11652        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11653        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11654        src -= 4;
  11655        dst[7] = (Sint16) ((sample3 + last_sample3) >> 1);
  11656        dst[6] = (Sint16) ((sample2 + last_sample2) >> 1);
  11657        dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
  11658        dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
  11659        dst[3] = (Sint16) sample3;
  11660        dst[2] = (Sint16) sample2;
  11661        dst[1] = (Sint16) sample1;
  11662        dst[0] = (Sint16) sample0;
  11663        last_sample3 = sample3;
  11664        last_sample2 = sample2;
  11665        last_sample1 = sample1;
  11666        last_sample0 = sample0;
  11667        dst -= 8;
  11668    }
  11669
  11670    cvt->len_cvt = dstsize;
  11671    if (cvt->filters[++cvt->filter_index]) {
  11672        cvt->filters[cvt->filter_index] (cvt, format);
  11673    }
  11674}
  11675
  11676static void SDLCALL
  11677SDL_Downsample_S16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11678{
  11679#if DEBUG_CONVERT
  11680    fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 4 channels.\n");
  11681#endif
  11682
  11683    const int dstsize = cvt->len_cvt / 2;
  11684    Sint16 *dst = (Sint16 *) cvt->buf;
  11685    const Sint16 *src = (Sint16 *) cvt->buf;
  11686    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  11687    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11688    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11689    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11690    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11691    while (dst < target) {
  11692        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11693        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11694        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11695        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11696        src += 8;
  11697        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
  11698        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
  11699        dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
  11700        dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
  11701        last_sample0 = sample0;
  11702        last_sample1 = sample1;
  11703        last_sample2 = sample2;
  11704        last_sample3 = sample3;
  11705        dst += 4;
  11706    }
  11707
  11708    cvt->len_cvt = dstsize;
  11709    if (cvt->filters[++cvt->filter_index]) {
  11710        cvt->filters[cvt->filter_index] (cvt, format);
  11711    }
  11712}
  11713
  11714static void SDLCALL
  11715SDL_Upsample_S16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11716{
  11717#if DEBUG_CONVERT
  11718    fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 4 channels.\n");
  11719#endif
  11720
  11721    const int dstsize = cvt->len_cvt * 4;
  11722    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4 * 4;
  11723    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
  11724    const Sint16 *target = ((const Sint16 *) cvt->buf);
  11725    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11726    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11727    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11728    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11729    while (dst >= target) {
  11730        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11731        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11732        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11733        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11734        src -= 4;
  11735        dst[15] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
  11736        dst[14] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
  11737        dst[13] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
  11738        dst[12] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
  11739        dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
  11740        dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
  11741        dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
  11742        dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
  11743        dst[7] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
  11744        dst[6] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
  11745        dst[5] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
  11746        dst[4] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
  11747        dst[3] = (Sint16) sample3;
  11748        dst[2] = (Sint16) sample2;
  11749        dst[1] = (Sint16) sample1;
  11750        dst[0] = (Sint16) sample0;
  11751        last_sample3 = sample3;
  11752        last_sample2 = sample2;
  11753        last_sample1 = sample1;
  11754        last_sample0 = sample0;
  11755        dst -= 16;
  11756    }
  11757
  11758    cvt->len_cvt = dstsize;
  11759    if (cvt->filters[++cvt->filter_index]) {
  11760        cvt->filters[cvt->filter_index] (cvt, format);
  11761    }
  11762}
  11763
  11764static void SDLCALL
  11765SDL_Downsample_S16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11766{
  11767#if DEBUG_CONVERT
  11768    fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 4 channels.\n");
  11769#endif
  11770
  11771    const int dstsize = cvt->len_cvt / 4;
  11772    Sint16 *dst = (Sint16 *) cvt->buf;
  11773    const Sint16 *src = (Sint16 *) cvt->buf;
  11774    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  11775    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11776    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11777    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11778    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11779    while (dst < target) {
  11780        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11781        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11782        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11783        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11784        src += 16;
  11785        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
  11786        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
  11787        dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
  11788        dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
  11789        last_sample0 = sample0;
  11790        last_sample1 = sample1;
  11791        last_sample2 = sample2;
  11792        last_sample3 = sample3;
  11793        dst += 4;
  11794    }
  11795
  11796    cvt->len_cvt = dstsize;
  11797    if (cvt->filters[++cvt->filter_index]) {
  11798        cvt->filters[cvt->filter_index] (cvt, format);
  11799    }
  11800}
  11801
  11802static void SDLCALL
  11803SDL_Upsample_S16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11804{
  11805#if DEBUG_CONVERT
  11806    fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 6 channels.\n");
  11807#endif
  11808
  11809    const int dstsize = cvt->len_cvt * 2;
  11810    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6 * 2;
  11811    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
  11812    const Sint16 *target = ((const Sint16 *) cvt->buf);
  11813    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  11814    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  11815    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11816    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11817    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11818    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11819    while (dst >= target) {
  11820        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  11821        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  11822        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11823        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11824        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11825        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11826        src -= 6;
  11827        dst[11] = (Sint16) ((sample5 + last_sample5) >> 1);
  11828        dst[10] = (Sint16) ((sample4 + last_sample4) >> 1);
  11829        dst[9] = (Sint16) ((sample3 + last_sample3) >> 1);
  11830        dst[8] = (Sint16) ((sample2 + last_sample2) >> 1);
  11831        dst[7] = (Sint16) ((sample1 + last_sample1) >> 1);
  11832        dst[6] = (Sint16) ((sample0 + last_sample0) >> 1);
  11833        dst[5] = (Sint16) sample5;
  11834        dst[4] = (Sint16) sample4;
  11835        dst[3] = (Sint16) sample3;
  11836        dst[2] = (Sint16) sample2;
  11837        dst[1] = (Sint16) sample1;
  11838        dst[0] = (Sint16) sample0;
  11839        last_sample5 = sample5;
  11840        last_sample4 = sample4;
  11841        last_sample3 = sample3;
  11842        last_sample2 = sample2;
  11843        last_sample1 = sample1;
  11844        last_sample0 = sample0;
  11845        dst -= 12;
  11846    }
  11847
  11848    cvt->len_cvt = dstsize;
  11849    if (cvt->filters[++cvt->filter_index]) {
  11850        cvt->filters[cvt->filter_index] (cvt, format);
  11851    }
  11852}
  11853
  11854static void SDLCALL
  11855SDL_Downsample_S16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11856{
  11857#if DEBUG_CONVERT
  11858    fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 6 channels.\n");
  11859#endif
  11860
  11861    const int dstsize = cvt->len_cvt / 2;
  11862    Sint16 *dst = (Sint16 *) cvt->buf;
  11863    const Sint16 *src = (Sint16 *) cvt->buf;
  11864    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  11865    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11866    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11867    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11868    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11869    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  11870    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  11871    while (dst < target) {
  11872        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11873        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11874        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11875        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11876        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  11877        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  11878        src += 12;
  11879        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
  11880        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
  11881        dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
  11882        dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
  11883        dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
  11884        dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
  11885        last_sample0 = sample0;
  11886        last_sample1 = sample1;
  11887        last_sample2 = sample2;
  11888        last_sample3 = sample3;
  11889        last_sample4 = sample4;
  11890        last_sample5 = sample5;
  11891        dst += 6;
  11892    }
  11893
  11894    cvt->len_cvt = dstsize;
  11895    if (cvt->filters[++cvt->filter_index]) {
  11896        cvt->filters[cvt->filter_index] (cvt, format);
  11897    }
  11898}
  11899
  11900static void SDLCALL
  11901SDL_Upsample_S16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11902{
  11903#if DEBUG_CONVERT
  11904    fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 6 channels.\n");
  11905#endif
  11906
  11907    const int dstsize = cvt->len_cvt * 4;
  11908    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6 * 4;
  11909    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
  11910    const Sint16 *target = ((const Sint16 *) cvt->buf);
  11911    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  11912    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  11913    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11914    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11915    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11916    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11917    while (dst >= target) {
  11918        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  11919        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  11920        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11921        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11922        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11923        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11924        src -= 6;
  11925        dst[23] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
  11926        dst[22] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
  11927        dst[21] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
  11928        dst[20] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
  11929        dst[19] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
  11930        dst[18] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
  11931        dst[17] = (Sint16) ((sample5 + last_sample5) >> 1);
  11932        dst[16] = (Sint16) ((sample4 + last_sample4) >> 1);
  11933        dst[15] = (Sint16) ((sample3 + last_sample3) >> 1);
  11934        dst[14] = (Sint16) ((sample2 + last_sample2) >> 1);
  11935        dst[13] = (Sint16) ((sample1 + last_sample1) >> 1);
  11936        dst[12] = (Sint16) ((sample0 + last_sample0) >> 1);
  11937        dst[11] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
  11938        dst[10] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
  11939        dst[9] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
  11940        dst[8] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
  11941        dst[7] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
  11942        dst[6] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
  11943        dst[5] = (Sint16) sample5;
  11944        dst[4] = (Sint16) sample4;
  11945        dst[3] = (Sint16) sample3;
  11946        dst[2] = (Sint16) sample2;
  11947        dst[1] = (Sint16) sample1;
  11948        dst[0] = (Sint16) sample0;
  11949        last_sample5 = sample5;
  11950        last_sample4 = sample4;
  11951        last_sample3 = sample3;
  11952        last_sample2 = sample2;
  11953        last_sample1 = sample1;
  11954        last_sample0 = sample0;
  11955        dst -= 24;
  11956    }
  11957
  11958    cvt->len_cvt = dstsize;
  11959    if (cvt->filters[++cvt->filter_index]) {
  11960        cvt->filters[cvt->filter_index] (cvt, format);
  11961    }
  11962}
  11963
  11964static void SDLCALL
  11965SDL_Downsample_S16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  11966{
  11967#if DEBUG_CONVERT
  11968    fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 6 channels.\n");
  11969#endif
  11970
  11971    const int dstsize = cvt->len_cvt / 4;
  11972    Sint16 *dst = (Sint16 *) cvt->buf;
  11973    const Sint16 *src = (Sint16 *) cvt->buf;
  11974    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  11975    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11976    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11977    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11978    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11979    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  11980    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  11981    while (dst < target) {
  11982        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  11983        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  11984        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  11985        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  11986        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  11987        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  11988        src += 24;
  11989        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
  11990        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
  11991        dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
  11992        dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
  11993        dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
  11994        dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
  11995        last_sample0 = sample0;
  11996        last_sample1 = sample1;
  11997        last_sample2 = sample2;
  11998        last_sample3 = sample3;
  11999        last_sample4 = sample4;
  12000        last_sample5 = sample5;
  12001        dst += 6;
  12002    }
  12003
  12004    cvt->len_cvt = dstsize;
  12005    if (cvt->filters[++cvt->filter_index]) {
  12006        cvt->filters[cvt->filter_index] (cvt, format);
  12007    }
  12008}
  12009
  12010static void SDLCALL
  12011SDL_Upsample_S16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12012{
  12013#if DEBUG_CONVERT
  12014    fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 8 channels.\n");
  12015#endif
  12016
  12017    const int dstsize = cvt->len_cvt * 2;
  12018    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8 * 2;
  12019    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
  12020    const Sint16 *target = ((const Sint16 *) cvt->buf);
  12021    Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
  12022    Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
  12023    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  12024    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  12025    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  12026    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  12027    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  12028    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  12029    while (dst >= target) {
  12030        const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
  12031        const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
  12032        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  12033        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  12034        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  12035        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  12036        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  12037        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  12038        src -= 8;
  12039        dst[15] = (Sint16) ((sample7 + last_sample7) >> 1);
  12040        dst[14] = (Sint16) ((sample6 + last_sample6) >> 1);
  12041        dst[13] = (Sint16) ((sample5 + last_sample5) >> 1);
  12042        dst[12] = (Sint16) ((sample4 + last_sample4) >> 1);
  12043        dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
  12044        dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
  12045        dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
  12046        dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
  12047        dst[7] = (Sint16) sample7;
  12048        dst[6] = (Sint16) sample6;
  12049        dst[5] = (Sint16) sample5;
  12050        dst[4] = (Sint16) sample4;
  12051        dst[3] = (Sint16) sample3;
  12052        dst[2] = (Sint16) sample2;
  12053        dst[1] = (Sint16) sample1;
  12054        dst[0] = (Sint16) sample0;
  12055        last_sample7 = sample7;
  12056        last_sample6 = sample6;
  12057        last_sample5 = sample5;
  12058        last_sample4 = sample4;
  12059        last_sample3 = sample3;
  12060        last_sample2 = sample2;
  12061        last_sample1 = sample1;
  12062        last_sample0 = sample0;
  12063        dst -= 16;
  12064    }
  12065
  12066    cvt->len_cvt = dstsize;
  12067    if (cvt->filters[++cvt->filter_index]) {
  12068        cvt->filters[cvt->filter_index] (cvt, format);
  12069    }
  12070}
  12071
  12072static void SDLCALL
  12073SDL_Downsample_S16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12074{
  12075#if DEBUG_CONVERT
  12076    fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 8 channels.\n");
  12077#endif
  12078
  12079    const int dstsize = cvt->len_cvt / 2;
  12080    Sint16 *dst = (Sint16 *) cvt->buf;
  12081    const Sint16 *src = (Sint16 *) cvt->buf;
  12082    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  12083    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  12084    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  12085    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  12086    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  12087    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  12088    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  12089    Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
  12090    Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
  12091    while (dst < target) {
  12092        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  12093        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  12094        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  12095        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  12096        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  12097        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  12098        const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
  12099        const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
  12100        src += 16;
  12101        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
  12102        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
  12103        dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
  12104        dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
  12105        dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
  12106        dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
  12107        dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
  12108        dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
  12109        last_sample0 = sample0;
  12110        last_sample1 = sample1;
  12111        last_sample2 = sample2;
  12112        last_sample3 = sample3;
  12113        last_sample4 = sample4;
  12114        last_sample5 = sample5;
  12115        last_sample6 = sample6;
  12116        last_sample7 = sample7;
  12117        dst += 8;
  12118    }
  12119
  12120    cvt->len_cvt = dstsize;
  12121    if (cvt->filters[++cvt->filter_index]) {
  12122        cvt->filters[cvt->filter_index] (cvt, format);
  12123    }
  12124}
  12125
  12126static void SDLCALL
  12127SDL_Upsample_S16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12128{
  12129#if DEBUG_CONVERT
  12130    fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 8 channels.\n");
  12131#endif
  12132
  12133    const int dstsize = cvt->len_cvt * 4;
  12134    Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8 * 4;
  12135    const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
  12136    const Sint16 *target = ((const Sint16 *) cvt->buf);
  12137    Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
  12138    Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
  12139    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  12140    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  12141    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  12142    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  12143    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  12144    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  12145    while (dst >= target) {
  12146        const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
  12147        const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
  12148        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  12149        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  12150        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  12151        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  12152        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  12153        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  12154        src -= 8;
  12155        dst[31] = (Sint16) ((sample7 + (3 * last_sample7)) >> 2);
  12156        dst[30] = (Sint16) ((sample6 + (3 * last_sample6)) >> 2);
  12157        dst[29] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
  12158        dst[28] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
  12159        dst[27] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
  12160        dst[26] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
  12161        dst[25] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
  12162        dst[24] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
  12163        dst[23] = (Sint16) ((sample7 + last_sample7) >> 1);
  12164        dst[22] = (Sint16) ((sample6 + last_sample6) >> 1);
  12165        dst[21] = (Sint16) ((sample5 + last_sample5) >> 1);
  12166        dst[20] = (Sint16) ((sample4 + last_sample4) >> 1);
  12167        dst[19] = (Sint16) ((sample3 + last_sample3) >> 1);
  12168        dst[18] = (Sint16) ((sample2 + last_sample2) >> 1);
  12169        dst[17] = (Sint16) ((sample1 + last_sample1) >> 1);
  12170        dst[16] = (Sint16) ((sample0 + last_sample0) >> 1);
  12171        dst[15] = (Sint16) (((3 * sample7) + last_sample7) >> 2);
  12172        dst[14] = (Sint16) (((3 * sample6) + last_sample6) >> 2);
  12173        dst[13] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
  12174        dst[12] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
  12175        dst[11] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
  12176        dst[10] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
  12177        dst[9] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
  12178        dst[8] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
  12179        dst[7] = (Sint16) sample7;
  12180        dst[6] = (Sint16) sample6;
  12181        dst[5] = (Sint16) sample5;
  12182        dst[4] = (Sint16) sample4;
  12183        dst[3] = (Sint16) sample3;
  12184        dst[2] = (Sint16) sample2;
  12185        dst[1] = (Sint16) sample1;
  12186        dst[0] = (Sint16) sample0;
  12187        last_sample7 = sample7;
  12188        last_sample6 = sample6;
  12189        last_sample5 = sample5;
  12190        last_sample4 = sample4;
  12191        last_sample3 = sample3;
  12192        last_sample2 = sample2;
  12193        last_sample1 = sample1;
  12194        last_sample0 = sample0;
  12195        dst -= 32;
  12196    }
  12197
  12198    cvt->len_cvt = dstsize;
  12199    if (cvt->filters[++cvt->filter_index]) {
  12200        cvt->filters[cvt->filter_index] (cvt, format);
  12201    }
  12202}
  12203
  12204static void SDLCALL
  12205SDL_Downsample_S16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12206{
  12207#if DEBUG_CONVERT
  12208    fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 8 channels.\n");
  12209#endif
  12210
  12211    const int dstsize = cvt->len_cvt / 4;
  12212    Sint16 *dst = (Sint16 *) cvt->buf;
  12213    const Sint16 *src = (Sint16 *) cvt->buf;
  12214    const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
  12215    Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  12216    Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  12217    Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  12218    Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  12219    Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  12220    Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  12221    Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
  12222    Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
  12223    while (dst < target) {
  12224        const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
  12225        const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
  12226        const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
  12227        const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
  12228        const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
  12229        const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
  12230        const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
  12231        const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
  12232        src += 32;
  12233        dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
  12234        dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
  12235        dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
  12236        dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
  12237        dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
  12238        dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
  12239        dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
  12240        dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
  12241        last_sample0 = sample0;
  12242        last_sample1 = sample1;
  12243        last_sample2 = sample2;
  12244        last_sample3 = sample3;
  12245        last_sample4 = sample4;
  12246        last_sample5 = sample5;
  12247        last_sample6 = sample6;
  12248        last_sample7 = sample7;
  12249        dst += 8;
  12250    }
  12251
  12252    cvt->len_cvt = dstsize;
  12253    if (cvt->filters[++cvt->filter_index]) {
  12254        cvt->filters[cvt->filter_index] (cvt, format);
  12255    }
  12256}
  12257
  12258static void SDLCALL
  12259SDL_Upsample_S32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12260{
  12261#if DEBUG_CONVERT
  12262    fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 1 channels.\n");
  12263#endif
  12264
  12265    const int dstsize = cvt->len_cvt * 2;
  12266    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1 * 2;
  12267    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
  12268    const Sint32 *target = ((const Sint32 *) cvt->buf);
  12269    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12270    while (dst >= target) {
  12271        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12272        src--;
  12273        dst[1] = (Sint32) ((sample0 + last_sample0) >> 1);
  12274        dst[0] = (Sint32) sample0;
  12275        last_sample0 = sample0;
  12276        dst -= 2;
  12277    }
  12278
  12279    cvt->len_cvt = dstsize;
  12280    if (cvt->filters[++cvt->filter_index]) {
  12281        cvt->filters[cvt->filter_index] (cvt, format);
  12282    }
  12283}
  12284
  12285static void SDLCALL
  12286SDL_Downsample_S32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12287{
  12288#if DEBUG_CONVERT
  12289    fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 1 channels.\n");
  12290#endif
  12291
  12292    const int dstsize = cvt->len_cvt / 2;
  12293    Sint32 *dst = (Sint32 *) cvt->buf;
  12294    const Sint32 *src = (Sint32 *) cvt->buf;
  12295    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  12296    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12297    while (dst < target) {
  12298        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12299        src += 2;
  12300        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  12301        last_sample0 = sample0;
  12302        dst++;
  12303    }
  12304
  12305    cvt->len_cvt = dstsize;
  12306    if (cvt->filters[++cvt->filter_index]) {
  12307        cvt->filters[cvt->filter_index] (cvt, format);
  12308    }
  12309}
  12310
  12311static void SDLCALL
  12312SDL_Upsample_S32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12313{
  12314#if DEBUG_CONVERT
  12315    fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 1 channels.\n");
  12316#endif
  12317
  12318    const int dstsize = cvt->len_cvt * 4;
  12319    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1 * 4;
  12320    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
  12321    const Sint32 *target = ((const Sint32 *) cvt->buf);
  12322    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12323    while (dst >= target) {
  12324        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12325        src--;
  12326        dst[3] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
  12327        dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
  12328        dst[1] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
  12329        dst[0] = (Sint32) sample0;
  12330        last_sample0 = sample0;
  12331        dst -= 4;
  12332    }
  12333
  12334    cvt->len_cvt = dstsize;
  12335    if (cvt->filters[++cvt->filter_index]) {
  12336        cvt->filters[cvt->filter_index] (cvt, format);
  12337    }
  12338}
  12339
  12340static void SDLCALL
  12341SDL_Downsample_S32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12342{
  12343#if DEBUG_CONVERT
  12344    fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 1 channels.\n");
  12345#endif
  12346
  12347    const int dstsize = cvt->len_cvt / 4;
  12348    Sint32 *dst = (Sint32 *) cvt->buf;
  12349    const Sint32 *src = (Sint32 *) cvt->buf;
  12350    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  12351    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12352    while (dst < target) {
  12353        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12354        src += 4;
  12355        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  12356        last_sample0 = sample0;
  12357        dst++;
  12358    }
  12359
  12360    cvt->len_cvt = dstsize;
  12361    if (cvt->filters[++cvt->filter_index]) {
  12362        cvt->filters[cvt->filter_index] (cvt, format);
  12363    }
  12364}
  12365
  12366static void SDLCALL
  12367SDL_Upsample_S32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12368{
  12369#if DEBUG_CONVERT
  12370    fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 2 channels.\n");
  12371#endif
  12372
  12373    const int dstsize = cvt->len_cvt * 2;
  12374    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2 * 2;
  12375    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
  12376    const Sint32 *target = ((const Sint32 *) cvt->buf);
  12377    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12378    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12379    while (dst >= target) {
  12380        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12381        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12382        src -= 2;
  12383        dst[3] = (Sint32) ((sample1 + last_sample1) >> 1);
  12384        dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
  12385        dst[1] = (Sint32) sample1;
  12386        dst[0] = (Sint32) sample0;
  12387        last_sample1 = sample1;
  12388        last_sample0 = sample0;
  12389        dst -= 4;
  12390    }
  12391
  12392    cvt->len_cvt = dstsize;
  12393    if (cvt->filters[++cvt->filter_index]) {
  12394        cvt->filters[cvt->filter_index] (cvt, format);
  12395    }
  12396}
  12397
  12398static void SDLCALL
  12399SDL_Downsample_S32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12400{
  12401#if DEBUG_CONVERT
  12402    fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 2 channels.\n");
  12403#endif
  12404
  12405    const int dstsize = cvt->len_cvt / 2;
  12406    Sint32 *dst = (Sint32 *) cvt->buf;
  12407    const Sint32 *src = (Sint32 *) cvt->buf;
  12408    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  12409    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12410    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12411    while (dst < target) {
  12412        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12413        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12414        src += 4;
  12415        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  12416        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  12417        last_sample0 = sample0;
  12418        last_sample1 = sample1;
  12419        dst += 2;
  12420    }
  12421
  12422    cvt->len_cvt = dstsize;
  12423    if (cvt->filters[++cvt->filter_index]) {
  12424        cvt->filters[cvt->filter_index] (cvt, format);
  12425    }
  12426}
  12427
  12428static void SDLCALL
  12429SDL_Upsample_S32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12430{
  12431#if DEBUG_CONVERT
  12432    fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 2 channels.\n");
  12433#endif
  12434
  12435    const int dstsize = cvt->len_cvt * 4;
  12436    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2 * 4;
  12437    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
  12438    const Sint32 *target = ((const Sint32 *) cvt->buf);
  12439    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12440    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12441    while (dst >= target) {
  12442        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12443        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12444        src -= 2;
  12445        dst[7] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
  12446        dst[6] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
  12447        dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
  12448        dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
  12449        dst[3] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
  12450        dst[2] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
  12451        dst[1] = (Sint32) sample1;
  12452        dst[0] = (Sint32) sample0;
  12453        last_sample1 = sample1;
  12454        last_sample0 = sample0;
  12455        dst -= 8;
  12456    }
  12457
  12458    cvt->len_cvt = dstsize;
  12459    if (cvt->filters[++cvt->filter_index]) {
  12460        cvt->filters[cvt->filter_index] (cvt, format);
  12461    }
  12462}
  12463
  12464static void SDLCALL
  12465SDL_Downsample_S32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12466{
  12467#if DEBUG_CONVERT
  12468    fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 2 channels.\n");
  12469#endif
  12470
  12471    const int dstsize = cvt->len_cvt / 4;
  12472    Sint32 *dst = (Sint32 *) cvt->buf;
  12473    const Sint32 *src = (Sint32 *) cvt->buf;
  12474    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  12475    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12476    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12477    while (dst < target) {
  12478        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12479        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12480        src += 8;
  12481        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  12482        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  12483        last_sample0 = sample0;
  12484        last_sample1 = sample1;
  12485        dst += 2;
  12486    }
  12487
  12488    cvt->len_cvt = dstsize;
  12489    if (cvt->filters[++cvt->filter_index]) {
  12490        cvt->filters[cvt->filter_index] (cvt, format);
  12491    }
  12492}
  12493
  12494static void SDLCALL
  12495SDL_Upsample_S32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12496{
  12497#if DEBUG_CONVERT
  12498    fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 4 channels.\n");
  12499#endif
  12500
  12501    const int dstsize = cvt->len_cvt * 2;
  12502    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4 * 2;
  12503    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
  12504    const Sint32 *target = ((const Sint32 *) cvt->buf);
  12505    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12506    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12507    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12508    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12509    while (dst >= target) {
  12510        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12511        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12512        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12513        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12514        src -= 4;
  12515        dst[7] = (Sint32) ((sample3 + last_sample3) >> 1);
  12516        dst[6] = (Sint32) ((sample2 + last_sample2) >> 1);
  12517        dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
  12518        dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
  12519        dst[3] = (Sint32) sample3;
  12520        dst[2] = (Sint32) sample2;
  12521        dst[1] = (Sint32) sample1;
  12522        dst[0] = (Sint32) sample0;
  12523        last_sample3 = sample3;
  12524        last_sample2 = sample2;
  12525        last_sample1 = sample1;
  12526        last_sample0 = sample0;
  12527        dst -= 8;
  12528    }
  12529
  12530    cvt->len_cvt = dstsize;
  12531    if (cvt->filters[++cvt->filter_index]) {
  12532        cvt->filters[cvt->filter_index] (cvt, format);
  12533    }
  12534}
  12535
  12536static void SDLCALL
  12537SDL_Downsample_S32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12538{
  12539#if DEBUG_CONVERT
  12540    fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 4 channels.\n");
  12541#endif
  12542
  12543    const int dstsize = cvt->len_cvt / 2;
  12544    Sint32 *dst = (Sint32 *) cvt->buf;
  12545    const Sint32 *src = (Sint32 *) cvt->buf;
  12546    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  12547    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12548    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12549    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12550    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12551    while (dst < target) {
  12552        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12553        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12554        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12555        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12556        src += 8;
  12557        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  12558        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  12559        dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
  12560        dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
  12561        last_sample0 = sample0;
  12562        last_sample1 = sample1;
  12563        last_sample2 = sample2;
  12564        last_sample3 = sample3;
  12565        dst += 4;
  12566    }
  12567
  12568    cvt->len_cvt = dstsize;
  12569    if (cvt->filters[++cvt->filter_index]) {
  12570        cvt->filters[cvt->filter_index] (cvt, format);
  12571    }
  12572}
  12573
  12574static void SDLCALL
  12575SDL_Upsample_S32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12576{
  12577#if DEBUG_CONVERT
  12578    fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 4 channels.\n");
  12579#endif
  12580
  12581    const int dstsize = cvt->len_cvt * 4;
  12582    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4 * 4;
  12583    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
  12584    const Sint32 *target = ((const Sint32 *) cvt->buf);
  12585    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12586    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12587    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12588    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12589    while (dst >= target) {
  12590        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12591        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12592        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12593        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12594        src -= 4;
  12595        dst[15] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
  12596        dst[14] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
  12597        dst[13] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
  12598        dst[12] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
  12599        dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
  12600        dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
  12601        dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
  12602        dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
  12603        dst[7] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
  12604        dst[6] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
  12605        dst[5] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
  12606        dst[4] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
  12607        dst[3] = (Sint32) sample3;
  12608        dst[2] = (Sint32) sample2;
  12609        dst[1] = (Sint32) sample1;
  12610        dst[0] = (Sint32) sample0;
  12611        last_sample3 = sample3;
  12612        last_sample2 = sample2;
  12613        last_sample1 = sample1;
  12614        last_sample0 = sample0;
  12615        dst -= 16;
  12616    }
  12617
  12618    cvt->len_cvt = dstsize;
  12619    if (cvt->filters[++cvt->filter_index]) {
  12620        cvt->filters[cvt->filter_index] (cvt, format);
  12621    }
  12622}
  12623
  12624static void SDLCALL
  12625SDL_Downsample_S32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12626{
  12627#if DEBUG_CONVERT
  12628    fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 4 channels.\n");
  12629#endif
  12630
  12631    const int dstsize = cvt->len_cvt / 4;
  12632    Sint32 *dst = (Sint32 *) cvt->buf;
  12633    const Sint32 *src = (Sint32 *) cvt->buf;
  12634    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  12635    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12636    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12637    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12638    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12639    while (dst < target) {
  12640        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12641        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12642        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12643        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12644        src += 16;
  12645        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  12646        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  12647        dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
  12648        dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
  12649        last_sample0 = sample0;
  12650        last_sample1 = sample1;
  12651        last_sample2 = sample2;
  12652        last_sample3 = sample3;
  12653        dst += 4;
  12654    }
  12655
  12656    cvt->len_cvt = dstsize;
  12657    if (cvt->filters[++cvt->filter_index]) {
  12658        cvt->filters[cvt->filter_index] (cvt, format);
  12659    }
  12660}
  12661
  12662static void SDLCALL
  12663SDL_Upsample_S32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12664{
  12665#if DEBUG_CONVERT
  12666    fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 6 channels.\n");
  12667#endif
  12668
  12669    const int dstsize = cvt->len_cvt * 2;
  12670    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6 * 2;
  12671    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
  12672    const Sint32 *target = ((const Sint32 *) cvt->buf);
  12673    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  12674    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  12675    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12676    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12677    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12678    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12679    while (dst >= target) {
  12680        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  12681        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  12682        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12683        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12684        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12685        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12686        src -= 6;
  12687        dst[11] = (Sint32) ((sample5 + last_sample5) >> 1);
  12688        dst[10] = (Sint32) ((sample4 + last_sample4) >> 1);
  12689        dst[9] = (Sint32) ((sample3 + last_sample3) >> 1);
  12690        dst[8] = (Sint32) ((sample2 + last_sample2) >> 1);
  12691        dst[7] = (Sint32) ((sample1 + last_sample1) >> 1);
  12692        dst[6] = (Sint32) ((sample0 + last_sample0) >> 1);
  12693        dst[5] = (Sint32) sample5;
  12694        dst[4] = (Sint32) sample4;
  12695        dst[3] = (Sint32) sample3;
  12696        dst[2] = (Sint32) sample2;
  12697        dst[1] = (Sint32) sample1;
  12698        dst[0] = (Sint32) sample0;
  12699        last_sample5 = sample5;
  12700        last_sample4 = sample4;
  12701        last_sample3 = sample3;
  12702        last_sample2 = sample2;
  12703        last_sample1 = sample1;
  12704        last_sample0 = sample0;
  12705        dst -= 12;
  12706    }
  12707
  12708    cvt->len_cvt = dstsize;
  12709    if (cvt->filters[++cvt->filter_index]) {
  12710        cvt->filters[cvt->filter_index] (cvt, format);
  12711    }
  12712}
  12713
  12714static void SDLCALL
  12715SDL_Downsample_S32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12716{
  12717#if DEBUG_CONVERT
  12718    fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 6 channels.\n");
  12719#endif
  12720
  12721    const int dstsize = cvt->len_cvt / 2;
  12722    Sint32 *dst = (Sint32 *) cvt->buf;
  12723    const Sint32 *src = (Sint32 *) cvt->buf;
  12724    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  12725    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12726    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12727    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12728    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12729    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  12730    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  12731    while (dst < target) {
  12732        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12733        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12734        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12735        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12736        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  12737        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  12738        src += 12;
  12739        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  12740        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  12741        dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
  12742        dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
  12743        dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
  12744        dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
  12745        last_sample0 = sample0;
  12746        last_sample1 = sample1;
  12747        last_sample2 = sample2;
  12748        last_sample3 = sample3;
  12749        last_sample4 = sample4;
  12750        last_sample5 = sample5;
  12751        dst += 6;
  12752    }
  12753
  12754    cvt->len_cvt = dstsize;
  12755    if (cvt->filters[++cvt->filter_index]) {
  12756        cvt->filters[cvt->filter_index] (cvt, format);
  12757    }
  12758}
  12759
  12760static void SDLCALL
  12761SDL_Upsample_S32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12762{
  12763#if DEBUG_CONVERT
  12764    fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 6 channels.\n");
  12765#endif
  12766
  12767    const int dstsize = cvt->len_cvt * 4;
  12768    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6 * 4;
  12769    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
  12770    const Sint32 *target = ((const Sint32 *) cvt->buf);
  12771    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  12772    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  12773    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12774    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12775    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12776    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12777    while (dst >= target) {
  12778        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  12779        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  12780        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12781        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12782        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12783        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12784        src -= 6;
  12785        dst[23] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
  12786        dst[22] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
  12787        dst[21] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
  12788        dst[20] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
  12789        dst[19] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
  12790        dst[18] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
  12791        dst[17] = (Sint32) ((sample5 + last_sample5) >> 1);
  12792        dst[16] = (Sint32) ((sample4 + last_sample4) >> 1);
  12793        dst[15] = (Sint32) ((sample3 + last_sample3) >> 1);
  12794        dst[14] = (Sint32) ((sample2 + last_sample2) >> 1);
  12795        dst[13] = (Sint32) ((sample1 + last_sample1) >> 1);
  12796        dst[12] = (Sint32) ((sample0 + last_sample0) >> 1);
  12797        dst[11] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
  12798        dst[10] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
  12799        dst[9] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
  12800        dst[8] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
  12801        dst[7] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
  12802        dst[6] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
  12803        dst[5] = (Sint32) sample5;
  12804        dst[4] = (Sint32) sample4;
  12805        dst[3] = (Sint32) sample3;
  12806        dst[2] = (Sint32) sample2;
  12807        dst[1] = (Sint32) sample1;
  12808        dst[0] = (Sint32) sample0;
  12809        last_sample5 = sample5;
  12810        last_sample4 = sample4;
  12811        last_sample3 = sample3;
  12812        last_sample2 = sample2;
  12813        last_sample1 = sample1;
  12814        last_sample0 = sample0;
  12815        dst -= 24;
  12816    }
  12817
  12818    cvt->len_cvt = dstsize;
  12819    if (cvt->filters[++cvt->filter_index]) {
  12820        cvt->filters[cvt->filter_index] (cvt, format);
  12821    }
  12822}
  12823
  12824static void SDLCALL
  12825SDL_Downsample_S32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12826{
  12827#if DEBUG_CONVERT
  12828    fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 6 channels.\n");
  12829#endif
  12830
  12831    const int dstsize = cvt->len_cvt / 4;
  12832    Sint32 *dst = (Sint32 *) cvt->buf;
  12833    const Sint32 *src = (Sint32 *) cvt->buf;
  12834    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  12835    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12836    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12837    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12838    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12839    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  12840    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  12841    while (dst < target) {
  12842        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12843        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12844        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12845        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12846        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  12847        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  12848        src += 24;
  12849        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  12850        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  12851        dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
  12852        dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
  12853        dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
  12854        dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
  12855        last_sample0 = sample0;
  12856        last_sample1 = sample1;
  12857        last_sample2 = sample2;
  12858        last_sample3 = sample3;
  12859        last_sample4 = sample4;
  12860        last_sample5 = sample5;
  12861        dst += 6;
  12862    }
  12863
  12864    cvt->len_cvt = dstsize;
  12865    if (cvt->filters[++cvt->filter_index]) {
  12866        cvt->filters[cvt->filter_index] (cvt, format);
  12867    }
  12868}
  12869
  12870static void SDLCALL
  12871SDL_Upsample_S32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12872{
  12873#if DEBUG_CONVERT
  12874    fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 8 channels.\n");
  12875#endif
  12876
  12877    const int dstsize = cvt->len_cvt * 2;
  12878    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8 * 2;
  12879    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
  12880    const Sint32 *target = ((const Sint32 *) cvt->buf);
  12881    Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
  12882    Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
  12883    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  12884    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  12885    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12886    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12887    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12888    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12889    while (dst >= target) {
  12890        const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
  12891        const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
  12892        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  12893        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  12894        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12895        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12896        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12897        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12898        src -= 8;
  12899        dst[15] = (Sint32) ((sample7 + last_sample7) >> 1);
  12900        dst[14] = (Sint32) ((sample6 + last_sample6) >> 1);
  12901        dst[13] = (Sint32) ((sample5 + last_sample5) >> 1);
  12902        dst[12] = (Sint32) ((sample4 + last_sample4) >> 1);
  12903        dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
  12904        dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
  12905        dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
  12906        dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
  12907        dst[7] = (Sint32) sample7;
  12908        dst[6] = (Sint32) sample6;
  12909        dst[5] = (Sint32) sample5;
  12910        dst[4] = (Sint32) sample4;
  12911        dst[3] = (Sint32) sample3;
  12912        dst[2] = (Sint32) sample2;
  12913        dst[1] = (Sint32) sample1;
  12914        dst[0] = (Sint32) sample0;
  12915        last_sample7 = sample7;
  12916        last_sample6 = sample6;
  12917        last_sample5 = sample5;
  12918        last_sample4 = sample4;
  12919        last_sample3 = sample3;
  12920        last_sample2 = sample2;
  12921        last_sample1 = sample1;
  12922        last_sample0 = sample0;
  12923        dst -= 16;
  12924    }
  12925
  12926    cvt->len_cvt = dstsize;
  12927    if (cvt->filters[++cvt->filter_index]) {
  12928        cvt->filters[cvt->filter_index] (cvt, format);
  12929    }
  12930}
  12931
  12932static void SDLCALL
  12933SDL_Downsample_S32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12934{
  12935#if DEBUG_CONVERT
  12936    fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 8 channels.\n");
  12937#endif
  12938
  12939    const int dstsize = cvt->len_cvt / 2;
  12940    Sint32 *dst = (Sint32 *) cvt->buf;
  12941    const Sint32 *src = (Sint32 *) cvt->buf;
  12942    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  12943    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12944    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12945    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12946    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12947    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  12948    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  12949    Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
  12950    Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
  12951    while (dst < target) {
  12952        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  12953        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  12954        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  12955        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  12956        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  12957        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  12958        const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
  12959        const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
  12960        src += 16;
  12961        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  12962        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  12963        dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
  12964        dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
  12965        dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
  12966        dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
  12967        dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
  12968        dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
  12969        last_sample0 = sample0;
  12970        last_sample1 = sample1;
  12971        last_sample2 = sample2;
  12972        last_sample3 = sample3;
  12973        last_sample4 = sample4;
  12974        last_sample5 = sample5;
  12975        last_sample6 = sample6;
  12976        last_sample7 = sample7;
  12977        dst += 8;
  12978    }
  12979
  12980    cvt->len_cvt = dstsize;
  12981    if (cvt->filters[++cvt->filter_index]) {
  12982        cvt->filters[cvt->filter_index] (cvt, format);
  12983    }
  12984}
  12985
  12986static void SDLCALL
  12987SDL_Upsample_S32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  12988{
  12989#if DEBUG_CONVERT
  12990    fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 8 channels.\n");
  12991#endif
  12992
  12993    const int dstsize = cvt->len_cvt * 4;
  12994    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8 * 4;
  12995    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
  12996    const Sint32 *target = ((const Sint32 *) cvt->buf);
  12997    Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
  12998    Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
  12999    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  13000    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  13001    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  13002    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  13003    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  13004    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  13005    while (dst >= target) {
  13006        const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
  13007        const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
  13008        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  13009        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  13010        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  13011        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  13012        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  13013        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  13014        src -= 8;
  13015        dst[31] = (Sint32) ((sample7 + (3 * last_sample7)) >> 2);
  13016        dst[30] = (Sint32) ((sample6 + (3 * last_sample6)) >> 2);
  13017        dst[29] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
  13018        dst[28] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
  13019        dst[27] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
  13020        dst[26] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
  13021        dst[25] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
  13022        dst[24] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
  13023        dst[23] = (Sint32) ((sample7 + last_sample7) >> 1);
  13024        dst[22] = (Sint32) ((sample6 + last_sample6) >> 1);
  13025        dst[21] = (Sint32) ((sample5 + last_sample5) >> 1);
  13026        dst[20] = (Sint32) ((sample4 + last_sample4) >> 1);
  13027        dst[19] = (Sint32) ((sample3 + last_sample3) >> 1);
  13028        dst[18] = (Sint32) ((sample2 + last_sample2) >> 1);
  13029        dst[17] = (Sint32) ((sample1 + last_sample1) >> 1);
  13030        dst[16] = (Sint32) ((sample0 + last_sample0) >> 1);
  13031        dst[15] = (Sint32) (((3 * sample7) + last_sample7) >> 2);
  13032        dst[14] = (Sint32) (((3 * sample6) + last_sample6) >> 2);
  13033        dst[13] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
  13034        dst[12] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
  13035        dst[11] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
  13036        dst[10] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
  13037        dst[9] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
  13038        dst[8] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
  13039        dst[7] = (Sint32) sample7;
  13040        dst[6] = (Sint32) sample6;
  13041        dst[5] = (Sint32) sample5;
  13042        dst[4] = (Sint32) sample4;
  13043        dst[3] = (Sint32) sample3;
  13044        dst[2] = (Sint32) sample2;
  13045        dst[1] = (Sint32) sample1;
  13046        dst[0] = (Sint32) sample0;
  13047        last_sample7 = sample7;
  13048        last_sample6 = sample6;
  13049        last_sample5 = sample5;
  13050        last_sample4 = sample4;
  13051        last_sample3 = sample3;
  13052        last_sample2 = sample2;
  13053        last_sample1 = sample1;
  13054        last_sample0 = sample0;
  13055        dst -= 32;
  13056    }
  13057
  13058    cvt->len_cvt = dstsize;
  13059    if (cvt->filters[++cvt->filter_index]) {
  13060        cvt->filters[cvt->filter_index] (cvt, format);
  13061    }
  13062}
  13063
  13064static void SDLCALL
  13065SDL_Downsample_S32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13066{
  13067#if DEBUG_CONVERT
  13068    fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 8 channels.\n");
  13069#endif
  13070
  13071    const int dstsize = cvt->len_cvt / 4;
  13072    Sint32 *dst = (Sint32 *) cvt->buf;
  13073    const Sint32 *src = (Sint32 *) cvt->buf;
  13074    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  13075    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  13076    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  13077    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  13078    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  13079    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  13080    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  13081    Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
  13082    Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
  13083    while (dst < target) {
  13084        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
  13085        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
  13086        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
  13087        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
  13088        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
  13089        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
  13090        const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
  13091        const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
  13092        src += 32;
  13093        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  13094        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  13095        dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
  13096        dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
  13097        dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
  13098        dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
  13099        dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
  13100        dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
  13101        last_sample0 = sample0;
  13102        last_sample1 = sample1;
  13103        last_sample2 = sample2;
  13104        last_sample3 = sample3;
  13105        last_sample4 = sample4;
  13106        last_sample5 = sample5;
  13107        last_sample6 = sample6;
  13108        last_sample7 = sample7;
  13109        dst += 8;
  13110    }
  13111
  13112    cvt->len_cvt = dstsize;
  13113    if (cvt->filters[++cvt->filter_index]) {
  13114        cvt->filters[cvt->filter_index] (cvt, format);
  13115    }
  13116}
  13117
  13118static void SDLCALL
  13119SDL_Upsample_S32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13120{
  13121#if DEBUG_CONVERT
  13122    fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 1 channels.\n");
  13123#endif
  13124
  13125    const int dstsize = cvt->len_cvt * 2;
  13126    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1 * 2;
  13127    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
  13128    const Sint32 *target = ((const Sint32 *) cvt->buf);
  13129    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13130    while (dst >= target) {
  13131        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13132        src--;
  13133        dst[1] = (Sint32) ((sample0 + last_sample0) >> 1);
  13134        dst[0] = (Sint32) sample0;
  13135        last_sample0 = sample0;
  13136        dst -= 2;
  13137    }
  13138
  13139    cvt->len_cvt = dstsize;
  13140    if (cvt->filters[++cvt->filter_index]) {
  13141        cvt->filters[cvt->filter_index] (cvt, format);
  13142    }
  13143}
  13144
  13145static void SDLCALL
  13146SDL_Downsample_S32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13147{
  13148#if DEBUG_CONVERT
  13149    fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 1 channels.\n");
  13150#endif
  13151
  13152    const int dstsize = cvt->len_cvt / 2;
  13153    Sint32 *dst = (Sint32 *) cvt->buf;
  13154    const Sint32 *src = (Sint32 *) cvt->buf;
  13155    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  13156    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13157    while (dst < target) {
  13158        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13159        src += 2;
  13160        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  13161        last_sample0 = sample0;
  13162        dst++;
  13163    }
  13164
  13165    cvt->len_cvt = dstsize;
  13166    if (cvt->filters[++cvt->filter_index]) {
  13167        cvt->filters[cvt->filter_index] (cvt, format);
  13168    }
  13169}
  13170
  13171static void SDLCALL
  13172SDL_Upsample_S32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13173{
  13174#if DEBUG_CONVERT
  13175    fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 1 channels.\n");
  13176#endif
  13177
  13178    const int dstsize = cvt->len_cvt * 4;
  13179    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1 * 4;
  13180    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
  13181    const Sint32 *target = ((const Sint32 *) cvt->buf);
  13182    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13183    while (dst >= target) {
  13184        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13185        src--;
  13186        dst[3] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
  13187        dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
  13188        dst[1] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
  13189        dst[0] = (Sint32) sample0;
  13190        last_sample0 = sample0;
  13191        dst -= 4;
  13192    }
  13193
  13194    cvt->len_cvt = dstsize;
  13195    if (cvt->filters[++cvt->filter_index]) {
  13196        cvt->filters[cvt->filter_index] (cvt, format);
  13197    }
  13198}
  13199
  13200static void SDLCALL
  13201SDL_Downsample_S32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13202{
  13203#if DEBUG_CONVERT
  13204    fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 1 channels.\n");
  13205#endif
  13206
  13207    const int dstsize = cvt->len_cvt / 4;
  13208    Sint32 *dst = (Sint32 *) cvt->buf;
  13209    const Sint32 *src = (Sint32 *) cvt->buf;
  13210    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  13211    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13212    while (dst < target) {
  13213        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13214        src += 4;
  13215        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  13216        last_sample0 = sample0;
  13217        dst++;
  13218    }
  13219
  13220    cvt->len_cvt = dstsize;
  13221    if (cvt->filters[++cvt->filter_index]) {
  13222        cvt->filters[cvt->filter_index] (cvt, format);
  13223    }
  13224}
  13225
  13226static void SDLCALL
  13227SDL_Upsample_S32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13228{
  13229#if DEBUG_CONVERT
  13230    fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 2 channels.\n");
  13231#endif
  13232
  13233    const int dstsize = cvt->len_cvt * 2;
  13234    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2 * 2;
  13235    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
  13236    const Sint32 *target = ((const Sint32 *) cvt->buf);
  13237    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13238    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13239    while (dst >= target) {
  13240        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13241        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13242        src -= 2;
  13243        dst[3] = (Sint32) ((sample1 + last_sample1) >> 1);
  13244        dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
  13245        dst[1] = (Sint32) sample1;
  13246        dst[0] = (Sint32) sample0;
  13247        last_sample1 = sample1;
  13248        last_sample0 = sample0;
  13249        dst -= 4;
  13250    }
  13251
  13252    cvt->len_cvt = dstsize;
  13253    if (cvt->filters[++cvt->filter_index]) {
  13254        cvt->filters[cvt->filter_index] (cvt, format);
  13255    }
  13256}
  13257
  13258static void SDLCALL
  13259SDL_Downsample_S32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13260{
  13261#if DEBUG_CONVERT
  13262    fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 2 channels.\n");
  13263#endif
  13264
  13265    const int dstsize = cvt->len_cvt / 2;
  13266    Sint32 *dst = (Sint32 *) cvt->buf;
  13267    const Sint32 *src = (Sint32 *) cvt->buf;
  13268    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  13269    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13270    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13271    while (dst < target) {
  13272        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13273        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13274        src += 4;
  13275        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  13276        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  13277        last_sample0 = sample0;
  13278        last_sample1 = sample1;
  13279        dst += 2;
  13280    }
  13281
  13282    cvt->len_cvt = dstsize;
  13283    if (cvt->filters[++cvt->filter_index]) {
  13284        cvt->filters[cvt->filter_index] (cvt, format);
  13285    }
  13286}
  13287
  13288static void SDLCALL
  13289SDL_Upsample_S32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13290{
  13291#if DEBUG_CONVERT
  13292    fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 2 channels.\n");
  13293#endif
  13294
  13295    const int dstsize = cvt->len_cvt * 4;
  13296    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2 * 4;
  13297    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
  13298    const Sint32 *target = ((const Sint32 *) cvt->buf);
  13299    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13300    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13301    while (dst >= target) {
  13302        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13303        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13304        src -= 2;
  13305        dst[7] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
  13306        dst[6] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
  13307        dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
  13308        dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
  13309        dst[3] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
  13310        dst[2] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
  13311        dst[1] = (Sint32) sample1;
  13312        dst[0] = (Sint32) sample0;
  13313        last_sample1 = sample1;
  13314        last_sample0 = sample0;
  13315        dst -= 8;
  13316    }
  13317
  13318    cvt->len_cvt = dstsize;
  13319    if (cvt->filters[++cvt->filter_index]) {
  13320        cvt->filters[cvt->filter_index] (cvt, format);
  13321    }
  13322}
  13323
  13324static void SDLCALL
  13325SDL_Downsample_S32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13326{
  13327#if DEBUG_CONVERT
  13328    fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 2 channels.\n");
  13329#endif
  13330
  13331    const int dstsize = cvt->len_cvt / 4;
  13332    Sint32 *dst = (Sint32 *) cvt->buf;
  13333    const Sint32 *src = (Sint32 *) cvt->buf;
  13334    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  13335    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13336    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13337    while (dst < target) {
  13338        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13339        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13340        src += 8;
  13341        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  13342        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  13343        last_sample0 = sample0;
  13344        last_sample1 = sample1;
  13345        dst += 2;
  13346    }
  13347
  13348    cvt->len_cvt = dstsize;
  13349    if (cvt->filters[++cvt->filter_index]) {
  13350        cvt->filters[cvt->filter_index] (cvt, format);
  13351    }
  13352}
  13353
  13354static void SDLCALL
  13355SDL_Upsample_S32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13356{
  13357#if DEBUG_CONVERT
  13358    fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 4 channels.\n");
  13359#endif
  13360
  13361    const int dstsize = cvt->len_cvt * 2;
  13362    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4 * 2;
  13363    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
  13364    const Sint32 *target = ((const Sint32 *) cvt->buf);
  13365    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13366    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13367    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13368    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13369    while (dst >= target) {
  13370        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13371        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13372        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13373        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13374        src -= 4;
  13375        dst[7] = (Sint32) ((sample3 + last_sample3) >> 1);
  13376        dst[6] = (Sint32) ((sample2 + last_sample2) >> 1);
  13377        dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
  13378        dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
  13379        dst[3] = (Sint32) sample3;
  13380        dst[2] = (Sint32) sample2;
  13381        dst[1] = (Sint32) sample1;
  13382        dst[0] = (Sint32) sample0;
  13383        last_sample3 = sample3;
  13384        last_sample2 = sample2;
  13385        last_sample1 = sample1;
  13386        last_sample0 = sample0;
  13387        dst -= 8;
  13388    }
  13389
  13390    cvt->len_cvt = dstsize;
  13391    if (cvt->filters[++cvt->filter_index]) {
  13392        cvt->filters[cvt->filter_index] (cvt, format);
  13393    }
  13394}
  13395
  13396static void SDLCALL
  13397SDL_Downsample_S32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13398{
  13399#if DEBUG_CONVERT
  13400    fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 4 channels.\n");
  13401#endif
  13402
  13403    const int dstsize = cvt->len_cvt / 2;
  13404    Sint32 *dst = (Sint32 *) cvt->buf;
  13405    const Sint32 *src = (Sint32 *) cvt->buf;
  13406    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  13407    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13408    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13409    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13410    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13411    while (dst < target) {
  13412        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13413        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13414        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13415        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13416        src += 8;
  13417        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  13418        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  13419        dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
  13420        dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
  13421        last_sample0 = sample0;
  13422        last_sample1 = sample1;
  13423        last_sample2 = sample2;
  13424        last_sample3 = sample3;
  13425        dst += 4;
  13426    }
  13427
  13428    cvt->len_cvt = dstsize;
  13429    if (cvt->filters[++cvt->filter_index]) {
  13430        cvt->filters[cvt->filter_index] (cvt, format);
  13431    }
  13432}
  13433
  13434static void SDLCALL
  13435SDL_Upsample_S32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13436{
  13437#if DEBUG_CONVERT
  13438    fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 4 channels.\n");
  13439#endif
  13440
  13441    const int dstsize = cvt->len_cvt * 4;
  13442    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4 * 4;
  13443    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
  13444    const Sint32 *target = ((const Sint32 *) cvt->buf);
  13445    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13446    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13447    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13448    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13449    while (dst >= target) {
  13450        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13451        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13452        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13453        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13454        src -= 4;
  13455        dst[15] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
  13456        dst[14] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
  13457        dst[13] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
  13458        dst[12] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
  13459        dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
  13460        dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
  13461        dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
  13462        dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
  13463        dst[7] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
  13464        dst[6] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
  13465        dst[5] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
  13466        dst[4] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
  13467        dst[3] = (Sint32) sample3;
  13468        dst[2] = (Sint32) sample2;
  13469        dst[1] = (Sint32) sample1;
  13470        dst[0] = (Sint32) sample0;
  13471        last_sample3 = sample3;
  13472        last_sample2 = sample2;
  13473        last_sample1 = sample1;
  13474        last_sample0 = sample0;
  13475        dst -= 16;
  13476    }
  13477
  13478    cvt->len_cvt = dstsize;
  13479    if (cvt->filters[++cvt->filter_index]) {
  13480        cvt->filters[cvt->filter_index] (cvt, format);
  13481    }
  13482}
  13483
  13484static void SDLCALL
  13485SDL_Downsample_S32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13486{
  13487#if DEBUG_CONVERT
  13488    fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 4 channels.\n");
  13489#endif
  13490
  13491    const int dstsize = cvt->len_cvt / 4;
  13492    Sint32 *dst = (Sint32 *) cvt->buf;
  13493    const Sint32 *src = (Sint32 *) cvt->buf;
  13494    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  13495    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13496    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13497    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13498    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13499    while (dst < target) {
  13500        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13501        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13502        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13503        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13504        src += 16;
  13505        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  13506        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  13507        dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
  13508        dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
  13509        last_sample0 = sample0;
  13510        last_sample1 = sample1;
  13511        last_sample2 = sample2;
  13512        last_sample3 = sample3;
  13513        dst += 4;
  13514    }
  13515
  13516    cvt->len_cvt = dstsize;
  13517    if (cvt->filters[++cvt->filter_index]) {
  13518        cvt->filters[cvt->filter_index] (cvt, format);
  13519    }
  13520}
  13521
  13522static void SDLCALL
  13523SDL_Upsample_S32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13524{
  13525#if DEBUG_CONVERT
  13526    fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 6 channels.\n");
  13527#endif
  13528
  13529    const int dstsize = cvt->len_cvt * 2;
  13530    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6 * 2;
  13531    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
  13532    const Sint32 *target = ((const Sint32 *) cvt->buf);
  13533    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13534    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13535    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13536    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13537    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13538    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13539    while (dst >= target) {
  13540        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13541        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13542        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13543        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13544        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13545        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13546        src -= 6;
  13547        dst[11] = (Sint32) ((sample5 + last_sample5) >> 1);
  13548        dst[10] = (Sint32) ((sample4 + last_sample4) >> 1);
  13549        dst[9] = (Sint32) ((sample3 + last_sample3) >> 1);
  13550        dst[8] = (Sint32) ((sample2 + last_sample2) >> 1);
  13551        dst[7] = (Sint32) ((sample1 + last_sample1) >> 1);
  13552        dst[6] = (Sint32) ((sample0 + last_sample0) >> 1);
  13553        dst[5] = (Sint32) sample5;
  13554        dst[4] = (Sint32) sample4;
  13555        dst[3] = (Sint32) sample3;
  13556        dst[2] = (Sint32) sample2;
  13557        dst[1] = (Sint32) sample1;
  13558        dst[0] = (Sint32) sample0;
  13559        last_sample5 = sample5;
  13560        last_sample4 = sample4;
  13561        last_sample3 = sample3;
  13562        last_sample2 = sample2;
  13563        last_sample1 = sample1;
  13564        last_sample0 = sample0;
  13565        dst -= 12;
  13566    }
  13567
  13568    cvt->len_cvt = dstsize;
  13569    if (cvt->filters[++cvt->filter_index]) {
  13570        cvt->filters[cvt->filter_index] (cvt, format);
  13571    }
  13572}
  13573
  13574static void SDLCALL
  13575SDL_Downsample_S32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13576{
  13577#if DEBUG_CONVERT
  13578    fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 6 channels.\n");
  13579#endif
  13580
  13581    const int dstsize = cvt->len_cvt / 2;
  13582    Sint32 *dst = (Sint32 *) cvt->buf;
  13583    const Sint32 *src = (Sint32 *) cvt->buf;
  13584    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  13585    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13586    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13587    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13588    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13589    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13590    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13591    while (dst < target) {
  13592        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13593        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13594        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13595        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13596        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13597        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13598        src += 12;
  13599        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  13600        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  13601        dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
  13602        dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
  13603        dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
  13604        dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
  13605        last_sample0 = sample0;
  13606        last_sample1 = sample1;
  13607        last_sample2 = sample2;
  13608        last_sample3 = sample3;
  13609        last_sample4 = sample4;
  13610        last_sample5 = sample5;
  13611        dst += 6;
  13612    }
  13613
  13614    cvt->len_cvt = dstsize;
  13615    if (cvt->filters[++cvt->filter_index]) {
  13616        cvt->filters[cvt->filter_index] (cvt, format);
  13617    }
  13618}
  13619
  13620static void SDLCALL
  13621SDL_Upsample_S32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13622{
  13623#if DEBUG_CONVERT
  13624    fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 6 channels.\n");
  13625#endif
  13626
  13627    const int dstsize = cvt->len_cvt * 4;
  13628    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6 * 4;
  13629    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
  13630    const Sint32 *target = ((const Sint32 *) cvt->buf);
  13631    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13632    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13633    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13634    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13635    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13636    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13637    while (dst >= target) {
  13638        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13639        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13640        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13641        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13642        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13643        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13644        src -= 6;
  13645        dst[23] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
  13646        dst[22] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
  13647        dst[21] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
  13648        dst[20] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
  13649        dst[19] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
  13650        dst[18] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
  13651        dst[17] = (Sint32) ((sample5 + last_sample5) >> 1);
  13652        dst[16] = (Sint32) ((sample4 + last_sample4) >> 1);
  13653        dst[15] = (Sint32) ((sample3 + last_sample3) >> 1);
  13654        dst[14] = (Sint32) ((sample2 + last_sample2) >> 1);
  13655        dst[13] = (Sint32) ((sample1 + last_sample1) >> 1);
  13656        dst[12] = (Sint32) ((sample0 + last_sample0) >> 1);
  13657        dst[11] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
  13658        dst[10] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
  13659        dst[9] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
  13660        dst[8] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
  13661        dst[7] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
  13662        dst[6] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
  13663        dst[5] = (Sint32) sample5;
  13664        dst[4] = (Sint32) sample4;
  13665        dst[3] = (Sint32) sample3;
  13666        dst[2] = (Sint32) sample2;
  13667        dst[1] = (Sint32) sample1;
  13668        dst[0] = (Sint32) sample0;
  13669        last_sample5 = sample5;
  13670        last_sample4 = sample4;
  13671        last_sample3 = sample3;
  13672        last_sample2 = sample2;
  13673        last_sample1 = sample1;
  13674        last_sample0 = sample0;
  13675        dst -= 24;
  13676    }
  13677
  13678    cvt->len_cvt = dstsize;
  13679    if (cvt->filters[++cvt->filter_index]) {
  13680        cvt->filters[cvt->filter_index] (cvt, format);
  13681    }
  13682}
  13683
  13684static void SDLCALL
  13685SDL_Downsample_S32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13686{
  13687#if DEBUG_CONVERT
  13688    fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 6 channels.\n");
  13689#endif
  13690
  13691    const int dstsize = cvt->len_cvt / 4;
  13692    Sint32 *dst = (Sint32 *) cvt->buf;
  13693    const Sint32 *src = (Sint32 *) cvt->buf;
  13694    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  13695    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13696    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13697    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13698    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13699    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13700    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13701    while (dst < target) {
  13702        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13703        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13704        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13705        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13706        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13707        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13708        src += 24;
  13709        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  13710        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  13711        dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
  13712        dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
  13713        dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
  13714        dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
  13715        last_sample0 = sample0;
  13716        last_sample1 = sample1;
  13717        last_sample2 = sample2;
  13718        last_sample3 = sample3;
  13719        last_sample4 = sample4;
  13720        last_sample5 = sample5;
  13721        dst += 6;
  13722    }
  13723
  13724    cvt->len_cvt = dstsize;
  13725    if (cvt->filters[++cvt->filter_index]) {
  13726        cvt->filters[cvt->filter_index] (cvt, format);
  13727    }
  13728}
  13729
  13730static void SDLCALL
  13731SDL_Upsample_S32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13732{
  13733#if DEBUG_CONVERT
  13734    fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 8 channels.\n");
  13735#endif
  13736
  13737    const int dstsize = cvt->len_cvt * 2;
  13738    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8 * 2;
  13739    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
  13740    const Sint32 *target = ((const Sint32 *) cvt->buf);
  13741    Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
  13742    Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
  13743    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13744    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13745    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13746    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13747    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13748    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13749    while (dst >= target) {
  13750        const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
  13751        const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
  13752        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13753        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13754        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13755        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13756        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13757        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13758        src -= 8;
  13759        dst[15] = (Sint32) ((sample7 + last_sample7) >> 1);
  13760        dst[14] = (Sint32) ((sample6 + last_sample6) >> 1);
  13761        dst[13] = (Sint32) ((sample5 + last_sample5) >> 1);
  13762        dst[12] = (Sint32) ((sample4 + last_sample4) >> 1);
  13763        dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
  13764        dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
  13765        dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
  13766        dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
  13767        dst[7] = (Sint32) sample7;
  13768        dst[6] = (Sint32) sample6;
  13769        dst[5] = (Sint32) sample5;
  13770        dst[4] = (Sint32) sample4;
  13771        dst[3] = (Sint32) sample3;
  13772        dst[2] = (Sint32) sample2;
  13773        dst[1] = (Sint32) sample1;
  13774        dst[0] = (Sint32) sample0;
  13775        last_sample7 = sample7;
  13776        last_sample6 = sample6;
  13777        last_sample5 = sample5;
  13778        last_sample4 = sample4;
  13779        last_sample3 = sample3;
  13780        last_sample2 = sample2;
  13781        last_sample1 = sample1;
  13782        last_sample0 = sample0;
  13783        dst -= 16;
  13784    }
  13785
  13786    cvt->len_cvt = dstsize;
  13787    if (cvt->filters[++cvt->filter_index]) {
  13788        cvt->filters[cvt->filter_index] (cvt, format);
  13789    }
  13790}
  13791
  13792static void SDLCALL
  13793SDL_Downsample_S32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13794{
  13795#if DEBUG_CONVERT
  13796    fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 8 channels.\n");
  13797#endif
  13798
  13799    const int dstsize = cvt->len_cvt / 2;
  13800    Sint32 *dst = (Sint32 *) cvt->buf;
  13801    const Sint32 *src = (Sint32 *) cvt->buf;
  13802    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  13803    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13804    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13805    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13806    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13807    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13808    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13809    Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
  13810    Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
  13811    while (dst < target) {
  13812        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13813        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13814        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13815        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13816        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13817        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13818        const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
  13819        const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
  13820        src += 16;
  13821        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  13822        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  13823        dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
  13824        dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
  13825        dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
  13826        dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
  13827        dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
  13828        dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
  13829        last_sample0 = sample0;
  13830        last_sample1 = sample1;
  13831        last_sample2 = sample2;
  13832        last_sample3 = sample3;
  13833        last_sample4 = sample4;
  13834        last_sample5 = sample5;
  13835        last_sample6 = sample6;
  13836        last_sample7 = sample7;
  13837        dst += 8;
  13838    }
  13839
  13840    cvt->len_cvt = dstsize;
  13841    if (cvt->filters[++cvt->filter_index]) {
  13842        cvt->filters[cvt->filter_index] (cvt, format);
  13843    }
  13844}
  13845
  13846static void SDLCALL
  13847SDL_Upsample_S32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13848{
  13849#if DEBUG_CONVERT
  13850    fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 8 channels.\n");
  13851#endif
  13852
  13853    const int dstsize = cvt->len_cvt * 4;
  13854    Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8 * 4;
  13855    const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
  13856    const Sint32 *target = ((const Sint32 *) cvt->buf);
  13857    Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
  13858    Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
  13859    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13860    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13861    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13862    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13863    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13864    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13865    while (dst >= target) {
  13866        const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
  13867        const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
  13868        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13869        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13870        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13871        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13872        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13873        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13874        src -= 8;
  13875        dst[31] = (Sint32) ((sample7 + (3 * last_sample7)) >> 2);
  13876        dst[30] = (Sint32) ((sample6 + (3 * last_sample6)) >> 2);
  13877        dst[29] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
  13878        dst[28] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
  13879        dst[27] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
  13880        dst[26] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
  13881        dst[25] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
  13882        dst[24] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
  13883        dst[23] = (Sint32) ((sample7 + last_sample7) >> 1);
  13884        dst[22] = (Sint32) ((sample6 + last_sample6) >> 1);
  13885        dst[21] = (Sint32) ((sample5 + last_sample5) >> 1);
  13886        dst[20] = (Sint32) ((sample4 + last_sample4) >> 1);
  13887        dst[19] = (Sint32) ((sample3 + last_sample3) >> 1);
  13888        dst[18] = (Sint32) ((sample2 + last_sample2) >> 1);
  13889        dst[17] = (Sint32) ((sample1 + last_sample1) >> 1);
  13890        dst[16] = (Sint32) ((sample0 + last_sample0) >> 1);
  13891        dst[15] = (Sint32) (((3 * sample7) + last_sample7) >> 2);
  13892        dst[14] = (Sint32) (((3 * sample6) + last_sample6) >> 2);
  13893        dst[13] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
  13894        dst[12] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
  13895        dst[11] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
  13896        dst[10] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
  13897        dst[9] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
  13898        dst[8] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
  13899        dst[7] = (Sint32) sample7;
  13900        dst[6] = (Sint32) sample6;
  13901        dst[5] = (Sint32) sample5;
  13902        dst[4] = (Sint32) sample4;
  13903        dst[3] = (Sint32) sample3;
  13904        dst[2] = (Sint32) sample2;
  13905        dst[1] = (Sint32) sample1;
  13906        dst[0] = (Sint32) sample0;
  13907        last_sample7 = sample7;
  13908        last_sample6 = sample6;
  13909        last_sample5 = sample5;
  13910        last_sample4 = sample4;
  13911        last_sample3 = sample3;
  13912        last_sample2 = sample2;
  13913        last_sample1 = sample1;
  13914        last_sample0 = sample0;
  13915        dst -= 32;
  13916    }
  13917
  13918    cvt->len_cvt = dstsize;
  13919    if (cvt->filters[++cvt->filter_index]) {
  13920        cvt->filters[cvt->filter_index] (cvt, format);
  13921    }
  13922}
  13923
  13924static void SDLCALL
  13925SDL_Downsample_S32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13926{
  13927#if DEBUG_CONVERT
  13928    fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 8 channels.\n");
  13929#endif
  13930
  13931    const int dstsize = cvt->len_cvt / 4;
  13932    Sint32 *dst = (Sint32 *) cvt->buf;
  13933    const Sint32 *src = (Sint32 *) cvt->buf;
  13934    const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
  13935    Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13936    Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13937    Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13938    Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13939    Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13940    Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13941    Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
  13942    Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
  13943    while (dst < target) {
  13944        const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
  13945        const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
  13946        const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
  13947        const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
  13948        const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
  13949        const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
  13950        const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
  13951        const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
  13952        src += 32;
  13953        dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
  13954        dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
  13955        dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
  13956        dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
  13957        dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
  13958        dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
  13959        dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
  13960        dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
  13961        last_sample0 = sample0;
  13962        last_sample1 = sample1;
  13963        last_sample2 = sample2;
  13964        last_sample3 = sample3;
  13965        last_sample4 = sample4;
  13966        last_sample5 = sample5;
  13967        last_sample6 = sample6;
  13968        last_sample7 = sample7;
  13969        dst += 8;
  13970    }
  13971
  13972    cvt->len_cvt = dstsize;
  13973    if (cvt->filters[++cvt->filter_index]) {
  13974        cvt->filters[cvt->filter_index] (cvt, format);
  13975    }
  13976}
  13977
  13978static void SDLCALL
  13979SDL_Upsample_F32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  13980{
  13981#if DEBUG_CONVERT
  13982    fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 1 channels.\n");
  13983#endif
  13984
  13985    const int dstsize = cvt->len_cvt * 2;
  13986    float *dst = ((float *) (cvt->buf + dstsize)) - 1 * 2;
  13987    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
  13988    const float *target = ((const float *) cvt->buf);
  13989    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  13990    while (dst >= target) {
  13991        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  13992        src--;
  13993        dst[1] = (float) ((sample0 + last_sample0) * 0.5);
  13994        dst[0] = (float) sample0;
  13995        last_sample0 = sample0;
  13996        dst -= 2;
  13997    }
  13998
  13999    cvt->len_cvt = dstsize;
  14000    if (cvt->filters[++cvt->filter_index]) {
  14001        cvt->filters[cvt->filter_index] (cvt, format);
  14002    }
  14003}
  14004
  14005static void SDLCALL
  14006SDL_Downsample_F32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14007{
  14008#if DEBUG_CONVERT
  14009    fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 1 channels.\n");
  14010#endif
  14011
  14012    const int dstsize = cvt->len_cvt / 2;
  14013    float *dst = (float *) cvt->buf;
  14014    const float *src = (float *) cvt->buf;
  14015    const float *target = (const float *) (cvt->buf + dstsize);
  14016    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14017    while (dst < target) {
  14018        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14019        src += 2;
  14020        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  14021        last_sample0 = sample0;
  14022        dst++;
  14023    }
  14024
  14025    cvt->len_cvt = dstsize;
  14026    if (cvt->filters[++cvt->filter_index]) {
  14027        cvt->filters[cvt->filter_index] (cvt, format);
  14028    }
  14029}
  14030
  14031static void SDLCALL
  14032SDL_Upsample_F32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14033{
  14034#if DEBUG_CONVERT
  14035    fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 1 channels.\n");
  14036#endif
  14037
  14038    const int dstsize = cvt->len_cvt * 4;
  14039    float *dst = ((float *) (cvt->buf + dstsize)) - 1 * 4;
  14040    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
  14041    const float *target = ((const float *) cvt->buf);
  14042    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14043    while (dst >= target) {
  14044        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14045        src--;
  14046        dst[3] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
  14047        dst[2] = (float) ((sample0 + last_sample0) * 0.5);
  14048        dst[1] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
  14049        dst[0] = (float) sample0;
  14050        last_sample0 = sample0;
  14051        dst -= 4;
  14052    }
  14053
  14054    cvt->len_cvt = dstsize;
  14055    if (cvt->filters[++cvt->filter_index]) {
  14056        cvt->filters[cvt->filter_index] (cvt, format);
  14057    }
  14058}
  14059
  14060static void SDLCALL
  14061SDL_Downsample_F32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14062{
  14063#if DEBUG_CONVERT
  14064    fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 1 channels.\n");
  14065#endif
  14066
  14067    const int dstsize = cvt->len_cvt / 4;
  14068    float *dst = (float *) cvt->buf;
  14069    const float *src = (float *) cvt->buf;
  14070    const float *target = (const float *) (cvt->buf + dstsize);
  14071    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14072    while (dst < target) {
  14073        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14074        src += 4;
  14075        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  14076        last_sample0 = sample0;
  14077        dst++;
  14078    }
  14079
  14080    cvt->len_cvt = dstsize;
  14081    if (cvt->filters[++cvt->filter_index]) {
  14082        cvt->filters[cvt->filter_index] (cvt, format);
  14083    }
  14084}
  14085
  14086static void SDLCALL
  14087SDL_Upsample_F32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14088{
  14089#if DEBUG_CONVERT
  14090    fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 2 channels.\n");
  14091#endif
  14092
  14093    const int dstsize = cvt->len_cvt * 2;
  14094    float *dst = ((float *) (cvt->buf + dstsize)) - 2 * 2;
  14095    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
  14096    const float *target = ((const float *) cvt->buf);
  14097    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14098    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14099    while (dst >= target) {
  14100        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14101        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14102        src -= 2;
  14103        dst[3] = (float) ((sample1 + last_sample1) * 0.5);
  14104        dst[2] = (float) ((sample0 + last_sample0) * 0.5);
  14105        dst[1] = (float) sample1;
  14106        dst[0] = (float) sample0;
  14107        last_sample1 = sample1;
  14108        last_sample0 = sample0;
  14109        dst -= 4;
  14110    }
  14111
  14112    cvt->len_cvt = dstsize;
  14113    if (cvt->filters[++cvt->filter_index]) {
  14114        cvt->filters[cvt->filter_index] (cvt, format);
  14115    }
  14116}
  14117
  14118static void SDLCALL
  14119SDL_Downsample_F32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14120{
  14121#if DEBUG_CONVERT
  14122    fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 2 channels.\n");
  14123#endif
  14124
  14125    const int dstsize = cvt->len_cvt / 2;
  14126    float *dst = (float *) cvt->buf;
  14127    const float *src = (float *) cvt->buf;
  14128    const float *target = (const float *) (cvt->buf + dstsize);
  14129    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14130    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14131    while (dst < target) {
  14132        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14133        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14134        src += 4;
  14135        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  14136        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  14137        last_sample0 = sample0;
  14138        last_sample1 = sample1;
  14139        dst += 2;
  14140    }
  14141
  14142    cvt->len_cvt = dstsize;
  14143    if (cvt->filters[++cvt->filter_index]) {
  14144        cvt->filters[cvt->filter_index] (cvt, format);
  14145    }
  14146}
  14147
  14148static void SDLCALL
  14149SDL_Upsample_F32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14150{
  14151#if DEBUG_CONVERT
  14152    fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 2 channels.\n");
  14153#endif
  14154
  14155    const int dstsize = cvt->len_cvt * 4;
  14156    float *dst = ((float *) (cvt->buf + dstsize)) - 2 * 4;
  14157    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
  14158    const float *target = ((const float *) cvt->buf);
  14159    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14160    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14161    while (dst >= target) {
  14162        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14163        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14164        src -= 2;
  14165        dst[7] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
  14166        dst[6] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
  14167        dst[5] = (float) ((sample1 + last_sample1) * 0.5);
  14168        dst[4] = (float) ((sample0 + last_sample0) * 0.5);
  14169        dst[3] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
  14170        dst[2] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
  14171        dst[1] = (float) sample1;
  14172        dst[0] = (float) sample0;
  14173        last_sample1 = sample1;
  14174        last_sample0 = sample0;
  14175        dst -= 8;
  14176    }
  14177
  14178    cvt->len_cvt = dstsize;
  14179    if (cvt->filters[++cvt->filter_index]) {
  14180        cvt->filters[cvt->filter_index] (cvt, format);
  14181    }
  14182}
  14183
  14184static void SDLCALL
  14185SDL_Downsample_F32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14186{
  14187#if DEBUG_CONVERT
  14188    fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 2 channels.\n");
  14189#endif
  14190
  14191    const int dstsize = cvt->len_cvt / 4;
  14192    float *dst = (float *) cvt->buf;
  14193    const float *src = (float *) cvt->buf;
  14194    const float *target = (const float *) (cvt->buf + dstsize);
  14195    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14196    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14197    while (dst < target) {
  14198        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14199        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14200        src += 8;
  14201        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  14202        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  14203        last_sample0 = sample0;
  14204        last_sample1 = sample1;
  14205        dst += 2;
  14206    }
  14207
  14208    cvt->len_cvt = dstsize;
  14209    if (cvt->filters[++cvt->filter_index]) {
  14210        cvt->filters[cvt->filter_index] (cvt, format);
  14211    }
  14212}
  14213
  14214static void SDLCALL
  14215SDL_Upsample_F32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14216{
  14217#if DEBUG_CONVERT
  14218    fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 4 channels.\n");
  14219#endif
  14220
  14221    const int dstsize = cvt->len_cvt * 2;
  14222    float *dst = ((float *) (cvt->buf + dstsize)) - 4 * 2;
  14223    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
  14224    const float *target = ((const float *) cvt->buf);
  14225    double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
  14226    double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
  14227    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14228    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14229    while (dst >= target) {
  14230        const double sample3 = (double) SDL_SwapFloatLE(src[3]);
  14231        const double sample2 = (double) SDL_SwapFloatLE(src[2]);
  14232        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14233        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14234        src -= 4;
  14235        dst[7] = (float) ((sample3 + last_sample3) * 0.5);
  14236        dst[6] = (float) ((sample2 + last_sample2) * 0.5);
  14237        dst[5] = (float) ((sample1 + last_sample1) * 0.5);
  14238        dst[4] = (float) ((sample0 + last_sample0) * 0.5);
  14239        dst[3] = (float) sample3;
  14240        dst[2] = (float) sample2;
  14241        dst[1] = (float) sample1;
  14242        dst[0] = (float) sample0;
  14243        last_sample3 = sample3;
  14244        last_sample2 = sample2;
  14245        last_sample1 = sample1;
  14246        last_sample0 = sample0;
  14247        dst -= 8;
  14248    }
  14249
  14250    cvt->len_cvt = dstsize;
  14251    if (cvt->filters[++cvt->filter_index]) {
  14252        cvt->filters[cvt->filter_index] (cvt, format);
  14253    }
  14254}
  14255
  14256static void SDLCALL
  14257SDL_Downsample_F32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14258{
  14259#if DEBUG_CONVERT
  14260    fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 4 channels.\n");
  14261#endif
  14262
  14263    const int dstsize = cvt->len_cvt / 2;
  14264    float *dst = (float *) cvt->buf;
  14265    const float *src = (float *) cvt->buf;
  14266    const float *target = (const float *) (cvt->buf + dstsize);
  14267    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14268    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14269    double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
  14270    double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
  14271    while (dst < target) {
  14272        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14273        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14274        const double sample2 = (double) SDL_SwapFloatLE(src[2]);
  14275        const double sample3 = (double) SDL_SwapFloatLE(src[3]);
  14276        src += 8;
  14277        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  14278        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  14279        dst[2] = (float) ((sample2 + last_sample2) * 0.5);
  14280        dst[3] = (float) ((sample3 + last_sample3) * 0.5);
  14281        last_sample0 = sample0;
  14282        last_sample1 = sample1;
  14283        last_sample2 = sample2;
  14284        last_sample3 = sample3;
  14285        dst += 4;
  14286    }
  14287
  14288    cvt->len_cvt = dstsize;
  14289    if (cvt->filters[++cvt->filter_index]) {
  14290        cvt->filters[cvt->filter_index] (cvt, format);
  14291    }
  14292}
  14293
  14294static void SDLCALL
  14295SDL_Upsample_F32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14296{
  14297#if DEBUG_CONVERT
  14298    fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 4 channels.\n");
  14299#endif
  14300
  14301    const int dstsize = cvt->len_cvt * 4;
  14302    float *dst = ((float *) (cvt->buf + dstsize)) - 4 * 4;
  14303    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
  14304    const float *target = ((const float *) cvt->buf);
  14305    double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
  14306    double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
  14307    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14308    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14309    while (dst >= target) {
  14310        const double sample3 = (double) SDL_SwapFloatLE(src[3]);
  14311        const double sample2 = (double) SDL_SwapFloatLE(src[2]);
  14312        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14313        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14314        src -= 4;
  14315        dst[15] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
  14316        dst[14] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
  14317        dst[13] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
  14318        dst[12] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
  14319        dst[11] = (float) ((sample3 + last_sample3) * 0.5);
  14320        dst[10] = (float) ((sample2 + last_sample2) * 0.5);
  14321        dst[9] = (float) ((sample1 + last_sample1) * 0.5);
  14322        dst[8] = (float) ((sample0 + last_sample0) * 0.5);
  14323        dst[7] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
  14324        dst[6] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
  14325        dst[5] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
  14326        dst[4] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
  14327        dst[3] = (float) sample3;
  14328        dst[2] = (float) sample2;
  14329        dst[1] = (float) sample1;
  14330        dst[0] = (float) sample0;
  14331        last_sample3 = sample3;
  14332        last_sample2 = sample2;
  14333        last_sample1 = sample1;
  14334        last_sample0 = sample0;
  14335        dst -= 16;
  14336    }
  14337
  14338    cvt->len_cvt = dstsize;
  14339    if (cvt->filters[++cvt->filter_index]) {
  14340        cvt->filters[cvt->filter_index] (cvt, format);
  14341    }
  14342}
  14343
  14344static void SDLCALL
  14345SDL_Downsample_F32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14346{
  14347#if DEBUG_CONVERT
  14348    fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 4 channels.\n");
  14349#endif
  14350
  14351    const int dstsize = cvt->len_cvt / 4;
  14352    float *dst = (float *) cvt->buf;
  14353    const float *src = (float *) cvt->buf;
  14354    const float *target = (const float *) (cvt->buf + dstsize);
  14355    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14356    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14357    double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
  14358    double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
  14359    while (dst < target) {
  14360        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14361        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14362        const double sample2 = (double) SDL_SwapFloatLE(src[2]);
  14363        const double sample3 = (double) SDL_SwapFloatLE(src[3]);
  14364        src += 16;
  14365        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  14366        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  14367        dst[2] = (float) ((sample2 + last_sample2) * 0.5);
  14368        dst[3] = (float) ((sample3 + last_sample3) * 0.5);
  14369        last_sample0 = sample0;
  14370        last_sample1 = sample1;
  14371        last_sample2 = sample2;
  14372        last_sample3 = sample3;
  14373        dst += 4;
  14374    }
  14375
  14376    cvt->len_cvt = dstsize;
  14377    if (cvt->filters[++cvt->filter_index]) {
  14378        cvt->filters[cvt->filter_index] (cvt, format);
  14379    }
  14380}
  14381
  14382static void SDLCALL
  14383SDL_Upsample_F32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14384{
  14385#if DEBUG_CONVERT
  14386    fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 6 channels.\n");
  14387#endif
  14388
  14389    const int dstsize = cvt->len_cvt * 2;
  14390    float *dst = ((float *) (cvt->buf + dstsize)) - 6 * 2;
  14391    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
  14392    const float *target = ((const float *) cvt->buf);
  14393    double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
  14394    double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
  14395    double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
  14396    double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
  14397    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14398    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14399    while (dst >= target) {
  14400        const double sample5 = (double) SDL_SwapFloatLE(src[5]);
  14401        const double sample4 = (double) SDL_SwapFloatLE(src[4]);
  14402        const double sample3 = (double) SDL_SwapFloatLE(src[3]);
  14403        const double sample2 = (double) SDL_SwapFloatLE(src[2]);
  14404        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14405        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14406        src -= 6;
  14407        dst[11] = (float) ((sample5 + last_sample5) * 0.5);
  14408        dst[10] = (float) ((sample4 + last_sample4) * 0.5);
  14409        dst[9] = (float) ((sample3 + last_sample3) * 0.5);
  14410        dst[8] = (float) ((sample2 + last_sample2) * 0.5);
  14411        dst[7] = (float) ((sample1 + last_sample1) * 0.5);
  14412        dst[6] = (float) ((sample0 + last_sample0) * 0.5);
  14413        dst[5] = (float) sample5;
  14414        dst[4] = (float) sample4;
  14415        dst[3] = (float) sample3;
  14416        dst[2] = (float) sample2;
  14417        dst[1] = (float) sample1;
  14418        dst[0] = (float) sample0;
  14419        last_sample5 = sample5;
  14420        last_sample4 = sample4;
  14421        last_sample3 = sample3;
  14422        last_sample2 = sample2;
  14423        last_sample1 = sample1;
  14424        last_sample0 = sample0;
  14425        dst -= 12;
  14426    }
  14427
  14428    cvt->len_cvt = dstsize;
  14429    if (cvt->filters[++cvt->filter_index]) {
  14430        cvt->filters[cvt->filter_index] (cvt, format);
  14431    }
  14432}
  14433
  14434static void SDLCALL
  14435SDL_Downsample_F32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14436{
  14437#if DEBUG_CONVERT
  14438    fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 6 channels.\n");
  14439#endif
  14440
  14441    const int dstsize = cvt->len_cvt / 2;
  14442    float *dst = (float *) cvt->buf;
  14443    const float *src = (float *) cvt->buf;
  14444    const float *target = (const float *) (cvt->buf + dstsize);
  14445    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14446    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14447    double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
  14448    double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
  14449    double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
  14450    double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
  14451    while (dst < target) {
  14452        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14453        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14454        const double sample2 = (double) SDL_SwapFloatLE(src[2]);
  14455        const double sample3 = (double) SDL_SwapFloatLE(src[3]);
  14456        const double sample4 = (double) SDL_SwapFloatLE(src[4]);
  14457        const double sample5 = (double) SDL_SwapFloatLE(src[5]);
  14458        src += 12;
  14459        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  14460        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  14461        dst[2] = (float) ((sample2 + last_sample2) * 0.5);
  14462        dst[3] = (float) ((sample3 + last_sample3) * 0.5);
  14463        dst[4] = (float) ((sample4 + last_sample4) * 0.5);
  14464        dst[5] = (float) ((sample5 + last_sample5) * 0.5);
  14465        last_sample0 = sample0;
  14466        last_sample1 = sample1;
  14467        last_sample2 = sample2;
  14468        last_sample3 = sample3;
  14469        last_sample4 = sample4;
  14470        last_sample5 = sample5;
  14471        dst += 6;
  14472    }
  14473
  14474    cvt->len_cvt = dstsize;
  14475    if (cvt->filters[++cvt->filter_index]) {
  14476        cvt->filters[cvt->filter_index] (cvt, format);
  14477    }
  14478}
  14479
  14480static void SDLCALL
  14481SDL_Upsample_F32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14482{
  14483#if DEBUG_CONVERT
  14484    fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 6 channels.\n");
  14485#endif
  14486
  14487    const int dstsize = cvt->len_cvt * 4;
  14488    float *dst = ((float *) (cvt->buf + dstsize)) - 6 * 4;
  14489    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
  14490    const float *target = ((const float *) cvt->buf);
  14491    double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
  14492    double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
  14493    double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
  14494    double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
  14495    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14496    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14497    while (dst >= target) {
  14498        const double sample5 = (double) SDL_SwapFloatLE(src[5]);
  14499        const double sample4 = (double) SDL_SwapFloatLE(src[4]);
  14500        const double sample3 = (double) SDL_SwapFloatLE(src[3]);
  14501        const double sample2 = (double) SDL_SwapFloatLE(src[2]);
  14502        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14503        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14504        src -= 6;
  14505        dst[23] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
  14506        dst[22] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
  14507        dst[21] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
  14508        dst[20] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
  14509        dst[19] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
  14510        dst[18] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
  14511        dst[17] = (float) ((sample5 + last_sample5) * 0.5);
  14512        dst[16] = (float) ((sample4 + last_sample4) * 0.5);
  14513        dst[15] = (float) ((sample3 + last_sample3) * 0.5);
  14514        dst[14] = (float) ((sample2 + last_sample2) * 0.5);
  14515        dst[13] = (float) ((sample1 + last_sample1) * 0.5);
  14516        dst[12] = (float) ((sample0 + last_sample0) * 0.5);
  14517        dst[11] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
  14518        dst[10] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
  14519        dst[9] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
  14520        dst[8] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
  14521        dst[7] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
  14522        dst[6] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
  14523        dst[5] = (float) sample5;
  14524        dst[4] = (float) sample4;
  14525        dst[3] = (float) sample3;
  14526        dst[2] = (float) sample2;
  14527        dst[1] = (float) sample1;
  14528        dst[0] = (float) sample0;
  14529        last_sample5 = sample5;
  14530        last_sample4 = sample4;
  14531        last_sample3 = sample3;
  14532        last_sample2 = sample2;
  14533        last_sample1 = sample1;
  14534        last_sample0 = sample0;
  14535        dst -= 24;
  14536    }
  14537
  14538    cvt->len_cvt = dstsize;
  14539    if (cvt->filters[++cvt->filter_index]) {
  14540        cvt->filters[cvt->filter_index] (cvt, format);
  14541    }
  14542}
  14543
  14544static void SDLCALL
  14545SDL_Downsample_F32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14546{
  14547#if DEBUG_CONVERT
  14548    fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 6 channels.\n");
  14549#endif
  14550
  14551    const int dstsize = cvt->len_cvt / 4;
  14552    float *dst = (float *) cvt->buf;
  14553    const float *src = (float *) cvt->buf;
  14554    const float *target = (const float *) (cvt->buf + dstsize);
  14555    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14556    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14557    double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
  14558    double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
  14559    double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
  14560    double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
  14561    while (dst < target) {
  14562        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14563        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14564        const double sample2 = (double) SDL_SwapFloatLE(src[2]);
  14565        const double sample3 = (double) SDL_SwapFloatLE(src[3]);
  14566        const double sample4 = (double) SDL_SwapFloatLE(src[4]);
  14567        const double sample5 = (double) SDL_SwapFloatLE(src[5]);
  14568        src += 24;
  14569        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  14570        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  14571        dst[2] = (float) ((sample2 + last_sample2) * 0.5);
  14572        dst[3] = (float) ((sample3 + last_sample3) * 0.5);
  14573        dst[4] = (float) ((sample4 + last_sample4) * 0.5);
  14574        dst[5] = (float) ((sample5 + last_sample5) * 0.5);
  14575        last_sample0 = sample0;
  14576        last_sample1 = sample1;
  14577        last_sample2 = sample2;
  14578        last_sample3 = sample3;
  14579        last_sample4 = sample4;
  14580        last_sample5 = sample5;
  14581        dst += 6;
  14582    }
  14583
  14584    cvt->len_cvt = dstsize;
  14585    if (cvt->filters[++cvt->filter_index]) {
  14586        cvt->filters[cvt->filter_index] (cvt, format);
  14587    }
  14588}
  14589
  14590static void SDLCALL
  14591SDL_Upsample_F32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14592{
  14593#if DEBUG_CONVERT
  14594    fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 8 channels.\n");
  14595#endif
  14596
  14597    const int dstsize = cvt->len_cvt * 2;
  14598    float *dst = ((float *) (cvt->buf + dstsize)) - 8 * 2;
  14599    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
  14600    const float *target = ((const float *) cvt->buf);
  14601    double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
  14602    double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
  14603    double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
  14604    double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
  14605    double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
  14606    double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
  14607    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14608    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14609    while (dst >= target) {
  14610        const double sample7 = (double) SDL_SwapFloatLE(src[7]);
  14611        const double sample6 = (double) SDL_SwapFloatLE(src[6]);
  14612        const double sample5 = (double) SDL_SwapFloatLE(src[5]);
  14613        const double sample4 = (double) SDL_SwapFloatLE(src[4]);
  14614        const double sample3 = (double) SDL_SwapFloatLE(src[3]);
  14615        const double sample2 = (double) SDL_SwapFloatLE(src[2]);
  14616        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14617        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14618        src -= 8;
  14619        dst[15] = (float) ((sample7 + last_sample7) * 0.5);
  14620        dst[14] = (float) ((sample6 + last_sample6) * 0.5);
  14621        dst[13] = (float) ((sample5 + last_sample5) * 0.5);
  14622        dst[12] = (float) ((sample4 + last_sample4) * 0.5);
  14623        dst[11] = (float) ((sample3 + last_sample3) * 0.5);
  14624        dst[10] = (float) ((sample2 + last_sample2) * 0.5);
  14625        dst[9] = (float) ((sample1 + last_sample1) * 0.5);
  14626        dst[8] = (float) ((sample0 + last_sample0) * 0.5);
  14627        dst[7] = (float) sample7;
  14628        dst[6] = (float) sample6;
  14629        dst[5] = (float) sample5;
  14630        dst[4] = (float) sample4;
  14631        dst[3] = (float) sample3;
  14632        dst[2] = (float) sample2;
  14633        dst[1] = (float) sample1;
  14634        dst[0] = (float) sample0;
  14635        last_sample7 = sample7;
  14636        last_sample6 = sample6;
  14637        last_sample5 = sample5;
  14638        last_sample4 = sample4;
  14639        last_sample3 = sample3;
  14640        last_sample2 = sample2;
  14641        last_sample1 = sample1;
  14642        last_sample0 = sample0;
  14643        dst -= 16;
  14644    }
  14645
  14646    cvt->len_cvt = dstsize;
  14647    if (cvt->filters[++cvt->filter_index]) {
  14648        cvt->filters[cvt->filter_index] (cvt, format);
  14649    }
  14650}
  14651
  14652static void SDLCALL
  14653SDL_Downsample_F32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14654{
  14655#if DEBUG_CONVERT
  14656    fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 8 channels.\n");
  14657#endif
  14658
  14659    const int dstsize = cvt->len_cvt / 2;
  14660    float *dst = (float *) cvt->buf;
  14661    const float *src = (float *) cvt->buf;
  14662    const float *target = (const float *) (cvt->buf + dstsize);
  14663    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14664    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14665    double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
  14666    double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
  14667    double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
  14668    double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
  14669    double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
  14670    double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
  14671    while (dst < target) {
  14672        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14673        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14674        const double sample2 = (double) SDL_SwapFloatLE(src[2]);
  14675        const double sample3 = (double) SDL_SwapFloatLE(src[3]);
  14676        const double sample4 = (double) SDL_SwapFloatLE(src[4]);
  14677        const double sample5 = (double) SDL_SwapFloatLE(src[5]);
  14678        const double sample6 = (double) SDL_SwapFloatLE(src[6]);
  14679        const double sample7 = (double) SDL_SwapFloatLE(src[7]);
  14680        src += 16;
  14681        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  14682        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  14683        dst[2] = (float) ((sample2 + last_sample2) * 0.5);
  14684        dst[3] = (float) ((sample3 + last_sample3) * 0.5);
  14685        dst[4] = (float) ((sample4 + last_sample4) * 0.5);
  14686        dst[5] = (float) ((sample5 + last_sample5) * 0.5);
  14687        dst[6] = (float) ((sample6 + last_sample6) * 0.5);
  14688        dst[7] = (float) ((sample7 + last_sample7) * 0.5);
  14689        last_sample0 = sample0;
  14690        last_sample1 = sample1;
  14691        last_sample2 = sample2;
  14692        last_sample3 = sample3;
  14693        last_sample4 = sample4;
  14694        last_sample5 = sample5;
  14695        last_sample6 = sample6;
  14696        last_sample7 = sample7;
  14697        dst += 8;
  14698    }
  14699
  14700    cvt->len_cvt = dstsize;
  14701    if (cvt->filters[++cvt->filter_index]) {
  14702        cvt->filters[cvt->filter_index] (cvt, format);
  14703    }
  14704}
  14705
  14706static void SDLCALL
  14707SDL_Upsample_F32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14708{
  14709#if DEBUG_CONVERT
  14710    fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 8 channels.\n");
  14711#endif
  14712
  14713    const int dstsize = cvt->len_cvt * 4;
  14714    float *dst = ((float *) (cvt->buf + dstsize)) - 8 * 4;
  14715    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
  14716    const float *target = ((const float *) cvt->buf);
  14717    double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
  14718    double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
  14719    double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
  14720    double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
  14721    double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
  14722    double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
  14723    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14724    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14725    while (dst >= target) {
  14726        const double sample7 = (double) SDL_SwapFloatLE(src[7]);
  14727        const double sample6 = (double) SDL_SwapFloatLE(src[6]);
  14728        const double sample5 = (double) SDL_SwapFloatLE(src[5]);
  14729        const double sample4 = (double) SDL_SwapFloatLE(src[4]);
  14730        const double sample3 = (double) SDL_SwapFloatLE(src[3]);
  14731        const double sample2 = (double) SDL_SwapFloatLE(src[2]);
  14732        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14733        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14734        src -= 8;
  14735        dst[31] = (float) ((sample7 + (3.0 * last_sample7)) * 0.25);
  14736        dst[30] = (float) ((sample6 + (3.0 * last_sample6)) * 0.25);
  14737        dst[29] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
  14738        dst[28] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
  14739        dst[27] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
  14740        dst[26] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
  14741        dst[25] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
  14742        dst[24] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
  14743        dst[23] = (float) ((sample7 + last_sample7) * 0.5);
  14744        dst[22] = (float) ((sample6 + last_sample6) * 0.5);
  14745        dst[21] = (float) ((sample5 + last_sample5) * 0.5);
  14746        dst[20] = (float) ((sample4 + last_sample4) * 0.5);
  14747        dst[19] = (float) ((sample3 + last_sample3) * 0.5);
  14748        dst[18] = (float) ((sample2 + last_sample2) * 0.5);
  14749        dst[17] = (float) ((sample1 + last_sample1) * 0.5);
  14750        dst[16] = (float) ((sample0 + last_sample0) * 0.5);
  14751        dst[15] = (float) (((3.0 * sample7) + last_sample7) * 0.25);
  14752        dst[14] = (float) (((3.0 * sample6) + last_sample6) * 0.25);
  14753        dst[13] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
  14754        dst[12] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
  14755        dst[11] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
  14756        dst[10] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
  14757        dst[9] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
  14758        dst[8] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
  14759        dst[7] = (float) sample7;
  14760        dst[6] = (float) sample6;
  14761        dst[5] = (float) sample5;
  14762        dst[4] = (float) sample4;
  14763        dst[3] = (float) sample3;
  14764        dst[2] = (float) sample2;
  14765        dst[1] = (float) sample1;
  14766        dst[0] = (float) sample0;
  14767        last_sample7 = sample7;
  14768        last_sample6 = sample6;
  14769        last_sample5 = sample5;
  14770        last_sample4 = sample4;
  14771        last_sample3 = sample3;
  14772        last_sample2 = sample2;
  14773        last_sample1 = sample1;
  14774        last_sample0 = sample0;
  14775        dst -= 32;
  14776    }
  14777
  14778    cvt->len_cvt = dstsize;
  14779    if (cvt->filters[++cvt->filter_index]) {
  14780        cvt->filters[cvt->filter_index] (cvt, format);
  14781    }
  14782}
  14783
  14784static void SDLCALL
  14785SDL_Downsample_F32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14786{
  14787#if DEBUG_CONVERT
  14788    fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 8 channels.\n");
  14789#endif
  14790
  14791    const int dstsize = cvt->len_cvt / 4;
  14792    float *dst = (float *) cvt->buf;
  14793    const float *src = (float *) cvt->buf;
  14794    const float *target = (const float *) (cvt->buf + dstsize);
  14795    double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
  14796    double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
  14797    double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
  14798    double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
  14799    double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
  14800    double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
  14801    double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
  14802    double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
  14803    while (dst < target) {
  14804        const double sample0 = (double) SDL_SwapFloatLE(src[0]);
  14805        const double sample1 = (double) SDL_SwapFloatLE(src[1]);
  14806        const double sample2 = (double) SDL_SwapFloatLE(src[2]);
  14807        const double sample3 = (double) SDL_SwapFloatLE(src[3]);
  14808        const double sample4 = (double) SDL_SwapFloatLE(src[4]);
  14809        const double sample5 = (double) SDL_SwapFloatLE(src[5]);
  14810        const double sample6 = (double) SDL_SwapFloatLE(src[6]);
  14811        const double sample7 = (double) SDL_SwapFloatLE(src[7]);
  14812        src += 32;
  14813        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  14814        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  14815        dst[2] = (float) ((sample2 + last_sample2) * 0.5);
  14816        dst[3] = (float) ((sample3 + last_sample3) * 0.5);
  14817        dst[4] = (float) ((sample4 + last_sample4) * 0.5);
  14818        dst[5] = (float) ((sample5 + last_sample5) * 0.5);
  14819        dst[6] = (float) ((sample6 + last_sample6) * 0.5);
  14820        dst[7] = (float) ((sample7 + last_sample7) * 0.5);
  14821        last_sample0 = sample0;
  14822        last_sample1 = sample1;
  14823        last_sample2 = sample2;
  14824        last_sample3 = sample3;
  14825        last_sample4 = sample4;
  14826        last_sample5 = sample5;
  14827        last_sample6 = sample6;
  14828        last_sample7 = sample7;
  14829        dst += 8;
  14830    }
  14831
  14832    cvt->len_cvt = dstsize;
  14833    if (cvt->filters[++cvt->filter_index]) {
  14834        cvt->filters[cvt->filter_index] (cvt, format);
  14835    }
  14836}
  14837
  14838static void SDLCALL
  14839SDL_Upsample_F32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14840{
  14841#if DEBUG_CONVERT
  14842    fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 1 channels.\n");
  14843#endif
  14844
  14845    const int dstsize = cvt->len_cvt * 2;
  14846    float *dst = ((float *) (cvt->buf + dstsize)) - 1 * 2;
  14847    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
  14848    const float *target = ((const float *) cvt->buf);
  14849    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  14850    while (dst >= target) {
  14851        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  14852        src--;
  14853        dst[1] = (float) ((sample0 + last_sample0) * 0.5);
  14854        dst[0] = (float) sample0;
  14855        last_sample0 = sample0;
  14856        dst -= 2;
  14857    }
  14858
  14859    cvt->len_cvt = dstsize;
  14860    if (cvt->filters[++cvt->filter_index]) {
  14861        cvt->filters[cvt->filter_index] (cvt, format);
  14862    }
  14863}
  14864
  14865static void SDLCALL
  14866SDL_Downsample_F32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14867{
  14868#if DEBUG_CONVERT
  14869    fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 1 channels.\n");
  14870#endif
  14871
  14872    const int dstsize = cvt->len_cvt / 2;
  14873    float *dst = (float *) cvt->buf;
  14874    const float *src = (float *) cvt->buf;
  14875    const float *target = (const float *) (cvt->buf + dstsize);
  14876    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  14877    while (dst < target) {
  14878        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  14879        src += 2;
  14880        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  14881        last_sample0 = sample0;
  14882        dst++;
  14883    }
  14884
  14885    cvt->len_cvt = dstsize;
  14886    if (cvt->filters[++cvt->filter_index]) {
  14887        cvt->filters[cvt->filter_index] (cvt, format);
  14888    }
  14889}
  14890
  14891static void SDLCALL
  14892SDL_Upsample_F32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14893{
  14894#if DEBUG_CONVERT
  14895    fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 1 channels.\n");
  14896#endif
  14897
  14898    const int dstsize = cvt->len_cvt * 4;
  14899    float *dst = ((float *) (cvt->buf + dstsize)) - 1 * 4;
  14900    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
  14901    const float *target = ((const float *) cvt->buf);
  14902    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  14903    while (dst >= target) {
  14904        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  14905        src--;
  14906        dst[3] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
  14907        dst[2] = (float) ((sample0 + last_sample0) * 0.5);
  14908        dst[1] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
  14909        dst[0] = (float) sample0;
  14910        last_sample0 = sample0;
  14911        dst -= 4;
  14912    }
  14913
  14914    cvt->len_cvt = dstsize;
  14915    if (cvt->filters[++cvt->filter_index]) {
  14916        cvt->filters[cvt->filter_index] (cvt, format);
  14917    }
  14918}
  14919
  14920static void SDLCALL
  14921SDL_Downsample_F32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14922{
  14923#if DEBUG_CONVERT
  14924    fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 1 channels.\n");
  14925#endif
  14926
  14927    const int dstsize = cvt->len_cvt / 4;
  14928    float *dst = (float *) cvt->buf;
  14929    const float *src = (float *) cvt->buf;
  14930    const float *target = (const float *) (cvt->buf + dstsize);
  14931    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  14932    while (dst < target) {
  14933        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  14934        src += 4;
  14935        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  14936        last_sample0 = sample0;
  14937        dst++;
  14938    }
  14939
  14940    cvt->len_cvt = dstsize;
  14941    if (cvt->filters[++cvt->filter_index]) {
  14942        cvt->filters[cvt->filter_index] (cvt, format);
  14943    }
  14944}
  14945
  14946static void SDLCALL
  14947SDL_Upsample_F32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14948{
  14949#if DEBUG_CONVERT
  14950    fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 2 channels.\n");
  14951#endif
  14952
  14953    const int dstsize = cvt->len_cvt * 2;
  14954    float *dst = ((float *) (cvt->buf + dstsize)) - 2 * 2;
  14955    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
  14956    const float *target = ((const float *) cvt->buf);
  14957    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  14958    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  14959    while (dst >= target) {
  14960        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  14961        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  14962        src -= 2;
  14963        dst[3] = (float) ((sample1 + last_sample1) * 0.5);
  14964        dst[2] = (float) ((sample0 + last_sample0) * 0.5);
  14965        dst[1] = (float) sample1;
  14966        dst[0] = (float) sample0;
  14967        last_sample1 = sample1;
  14968        last_sample0 = sample0;
  14969        dst -= 4;
  14970    }
  14971
  14972    cvt->len_cvt = dstsize;
  14973    if (cvt->filters[++cvt->filter_index]) {
  14974        cvt->filters[cvt->filter_index] (cvt, format);
  14975    }
  14976}
  14977
  14978static void SDLCALL
  14979SDL_Downsample_F32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14980{
  14981#if DEBUG_CONVERT
  14982    fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 2 channels.\n");
  14983#endif
  14984
  14985    const int dstsize = cvt->len_cvt / 2;
  14986    float *dst = (float *) cvt->buf;
  14987    const float *src = (float *) cvt->buf;
  14988    const float *target = (const float *) (cvt->buf + dstsize);
  14989    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  14990    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  14991    while (dst < target) {
  14992        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  14993        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  14994        src += 4;
  14995        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  14996        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  14997        last_sample0 = sample0;
  14998        last_sample1 = sample1;
  14999        dst += 2;
  15000    }
  15001
  15002    cvt->len_cvt = dstsize;
  15003    if (cvt->filters[++cvt->filter_index]) {
  15004        cvt->filters[cvt->filter_index] (cvt, format);
  15005    }
  15006}
  15007
  15008static void SDLCALL
  15009SDL_Upsample_F32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  15010{
  15011#if DEBUG_CONVERT
  15012    fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 2 channels.\n");
  15013#endif
  15014
  15015    const int dstsize = cvt->len_cvt * 4;
  15016    float *dst = ((float *) (cvt->buf + dstsize)) - 2 * 4;
  15017    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
  15018    const float *target = ((const float *) cvt->buf);
  15019    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  15020    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  15021    while (dst >= target) {
  15022        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  15023        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  15024        src -= 2;
  15025        dst[7] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
  15026        dst[6] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
  15027        dst[5] = (float) ((sample1 + last_sample1) * 0.5);
  15028        dst[4] = (float) ((sample0 + last_sample0) * 0.5);
  15029        dst[3] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
  15030        dst[2] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
  15031        dst[1] = (float) sample1;
  15032        dst[0] = (float) sample0;
  15033        last_sample1 = sample1;
  15034        last_sample0 = sample0;
  15035        dst -= 8;
  15036    }
  15037
  15038    cvt->len_cvt = dstsize;
  15039    if (cvt->filters[++cvt->filter_index]) {
  15040        cvt->filters[cvt->filter_index] (cvt, format);
  15041    }
  15042}
  15043
  15044static void SDLCALL
  15045SDL_Downsample_F32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  15046{
  15047#if DEBUG_CONVERT
  15048    fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 2 channels.\n");
  15049#endif
  15050
  15051    const int dstsize = cvt->len_cvt / 4;
  15052    float *dst = (float *) cvt->buf;
  15053    const float *src = (float *) cvt->buf;
  15054    const float *target = (const float *) (cvt->buf + dstsize);
  15055    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  15056    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  15057    while (dst < target) {
  15058        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  15059        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  15060        src += 8;
  15061        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  15062        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  15063        last_sample0 = sample0;
  15064        last_sample1 = sample1;
  15065        dst += 2;
  15066    }
  15067
  15068    cvt->len_cvt = dstsize;
  15069    if (cvt->filters[++cvt->filter_index]) {
  15070        cvt->filters[cvt->filter_index] (cvt, format);
  15071    }
  15072}
  15073
  15074static void SDLCALL
  15075SDL_Upsample_F32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  15076{
  15077#if DEBUG_CONVERT
  15078    fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 4 channels.\n");
  15079#endif
  15080
  15081    const int dstsize = cvt->len_cvt * 2;
  15082    float *dst = ((float *) (cvt->buf + dstsize)) - 4 * 2;
  15083    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
  15084    const float *target = ((const float *) cvt->buf);
  15085    double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
  15086    double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
  15087    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  15088    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  15089    while (dst >= target) {
  15090        const double sample3 = (double) SDL_SwapFloatBE(src[3]);
  15091        const double sample2 = (double) SDL_SwapFloatBE(src[2]);
  15092        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  15093        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  15094        src -= 4;
  15095        dst[7] = (float) ((sample3 + last_sample3) * 0.5);
  15096        dst[6] = (float) ((sample2 + last_sample2) * 0.5);
  15097        dst[5] = (float) ((sample1 + last_sample1) * 0.5);
  15098        dst[4] = (float) ((sample0 + last_sample0) * 0.5);
  15099        dst[3] = (float) sample3;
  15100        dst[2] = (float) sample2;
  15101        dst[1] = (float) sample1;
  15102        dst[0] = (float) sample0;
  15103        last_sample3 = sample3;
  15104        last_sample2 = sample2;
  15105        last_sample1 = sample1;
  15106        last_sample0 = sample0;
  15107        dst -= 8;
  15108    }
  15109
  15110    cvt->len_cvt = dstsize;
  15111    if (cvt->filters[++cvt->filter_index]) {
  15112        cvt->filters[cvt->filter_index] (cvt, format);
  15113    }
  15114}
  15115
  15116static void SDLCALL
  15117SDL_Downsample_F32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  15118{
  15119#if DEBUG_CONVERT
  15120    fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 4 channels.\n");
  15121#endif
  15122
  15123    const int dstsize = cvt->len_cvt / 2;
  15124    float *dst = (float *) cvt->buf;
  15125    const float *src = (float *) cvt->buf;
  15126    const float *target = (const float *) (cvt->buf + dstsize);
  15127    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  15128    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  15129    double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
  15130    double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
  15131    while (dst < target) {
  15132        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  15133        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  15134        const double sample2 = (double) SDL_SwapFloatBE(src[2]);
  15135        const double sample3 = (double) SDL_SwapFloatBE(src[3]);
  15136        src += 8;
  15137        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  15138        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  15139        dst[2] = (float) ((sample2 + last_sample2) * 0.5);
  15140        dst[3] = (float) ((sample3 + last_sample3) * 0.5);
  15141        last_sample0 = sample0;
  15142        last_sample1 = sample1;
  15143        last_sample2 = sample2;
  15144        last_sample3 = sample3;
  15145        dst += 4;
  15146    }
  15147
  15148    cvt->len_cvt = dstsize;
  15149    if (cvt->filters[++cvt->filter_index]) {
  15150        cvt->filters[cvt->filter_index] (cvt, format);
  15151    }
  15152}
  15153
  15154static void SDLCALL
  15155SDL_Upsample_F32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  15156{
  15157#if DEBUG_CONVERT
  15158    fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 4 channels.\n");
  15159#endif
  15160
  15161    const int dstsize = cvt->len_cvt * 4;
  15162    float *dst = ((float *) (cvt->buf + dstsize)) - 4 * 4;
  15163    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
  15164    const float *target = ((const float *) cvt->buf);
  15165    double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
  15166    double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
  15167    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  15168    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  15169    while (dst >= target) {
  15170        const double sample3 = (double) SDL_SwapFloatBE(src[3]);
  15171        const double sample2 = (double) SDL_SwapFloatBE(src[2]);
  15172        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  15173        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  15174        src -= 4;
  15175        dst[15] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
  15176        dst[14] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
  15177        dst[13] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
  15178        dst[12] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
  15179        dst[11] = (float) ((sample3 + last_sample3) * 0.5);
  15180        dst[10] = (float) ((sample2 + last_sample2) * 0.5);
  15181        dst[9] = (float) ((sample1 + last_sample1) * 0.5);
  15182        dst[8] = (float) ((sample0 + last_sample0) * 0.5);
  15183        dst[7] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
  15184        dst[6] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
  15185        dst[5] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
  15186        dst[4] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
  15187        dst[3] = (float) sample3;
  15188        dst[2] = (float) sample2;
  15189        dst[1] = (float) sample1;
  15190        dst[0] = (float) sample0;
  15191        last_sample3 = sample3;
  15192        last_sample2 = sample2;
  15193        last_sample1 = sample1;
  15194        last_sample0 = sample0;
  15195        dst -= 16;
  15196    }
  15197
  15198    cvt->len_cvt = dstsize;
  15199    if (cvt->filters[++cvt->filter_index]) {
  15200        cvt->filters[cvt->filter_index] (cvt, format);
  15201    }
  15202}
  15203
  15204static void SDLCALL
  15205SDL_Downsample_F32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  15206{
  15207#if DEBUG_CONVERT
  15208    fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 4 channels.\n");
  15209#endif
  15210
  15211    const int dstsize = cvt->len_cvt / 4;
  15212    float *dst = (float *) cvt->buf;
  15213    const float *src = (float *) cvt->buf;
  15214    const float *target = (const float *) (cvt->buf + dstsize);
  15215    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  15216    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  15217    double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
  15218    double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
  15219    while (dst < target) {
  15220        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  15221        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  15222        const double sample2 = (double) SDL_SwapFloatBE(src[2]);
  15223        const double sample3 = (double) SDL_SwapFloatBE(src[3]);
  15224        src += 16;
  15225        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  15226        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  15227        dst[2] = (float) ((sample2 + last_sample2) * 0.5);
  15228        dst[3] = (float) ((sample3 + last_sample3) * 0.5);
  15229        last_sample0 = sample0;
  15230        last_sample1 = sample1;
  15231        last_sample2 = sample2;
  15232        last_sample3 = sample3;
  15233        dst += 4;
  15234    }
  15235
  15236    cvt->len_cvt = dstsize;
  15237    if (cvt->filters[++cvt->filter_index]) {
  15238        cvt->filters[cvt->filter_index] (cvt, format);
  15239    }
  15240}
  15241
  15242static void SDLCALL
  15243SDL_Upsample_F32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  15244{
  15245#if DEBUG_CONVERT
  15246    fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 6 channels.\n");
  15247#endif
  15248
  15249    const int dstsize = cvt->len_cvt * 2;
  15250    float *dst = ((float *) (cvt->buf + dstsize)) - 6 * 2;
  15251    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
  15252    const float *target = ((const float *) cvt->buf);
  15253    double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
  15254    double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
  15255    double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
  15256    double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
  15257    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  15258    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  15259    while (dst >= target) {
  15260        const double sample5 = (double) SDL_SwapFloatBE(src[5]);
  15261        const double sample4 = (double) SDL_SwapFloatBE(src[4]);
  15262        const double sample3 = (double) SDL_SwapFloatBE(src[3]);
  15263        const double sample2 = (double) SDL_SwapFloatBE(src[2]);
  15264        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  15265        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  15266        src -= 6;
  15267        dst[11] = (float) ((sample5 + last_sample5) * 0.5);
  15268        dst[10] = (float) ((sample4 + last_sample4) * 0.5);
  15269        dst[9] = (float) ((sample3 + last_sample3) * 0.5);
  15270        dst[8] = (float) ((sample2 + last_sample2) * 0.5);
  15271        dst[7] = (float) ((sample1 + last_sample1) * 0.5);
  15272        dst[6] = (float) ((sample0 + last_sample0) * 0.5);
  15273        dst[5] = (float) sample5;
  15274        dst[4] = (float) sample4;
  15275        dst[3] = (float) sample3;
  15276        dst[2] = (float) sample2;
  15277        dst[1] = (float) sample1;
  15278        dst[0] = (float) sample0;
  15279        last_sample5 = sample5;
  15280        last_sample4 = sample4;
  15281        last_sample3 = sample3;
  15282        last_sample2 = sample2;
  15283        last_sample1 = sample1;
  15284        last_sample0 = sample0;
  15285        dst -= 12;
  15286    }
  15287
  15288    cvt->len_cvt = dstsize;
  15289    if (cvt->filters[++cvt->filter_index]) {
  15290        cvt->filters[cvt->filter_index] (cvt, format);
  15291    }
  15292}
  15293
  15294static void SDLCALL
  15295SDL_Downsample_F32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  15296{
  15297#if DEBUG_CONVERT
  15298    fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 6 channels.\n");
  15299#endif
  15300
  15301    const int dstsize = cvt->len_cvt / 2;
  15302    float *dst = (float *) cvt->buf;
  15303    const float *src = (float *) cvt->buf;
  15304    const float *target = (const float *) (cvt->buf + dstsize);
  15305    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  15306    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  15307    double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
  15308    double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
  15309    double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
  15310    double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
  15311    while (dst < target) {
  15312        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  15313        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  15314        const double sample2 = (double) SDL_SwapFloatBE(src[2]);
  15315        const double sample3 = (double) SDL_SwapFloatBE(src[3]);
  15316        const double sample4 = (double) SDL_SwapFloatBE(src[4]);
  15317        const double sample5 = (double) SDL_SwapFloatBE(src[5]);
  15318        src += 12;
  15319        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  15320        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  15321        dst[2] = (float) ((sample2 + last_sample2) * 0.5);
  15322        dst[3] = (float) ((sample3 + last_sample3) * 0.5);
  15323        dst[4] = (float) ((sample4 + last_sample4) * 0.5);
  15324        dst[5] = (float) ((sample5 + last_sample5) * 0.5);
  15325        last_sample0 = sample0;
  15326        last_sample1 = sample1;
  15327        last_sample2 = sample2;
  15328        last_sample3 = sample3;
  15329        last_sample4 = sample4;
  15330        last_sample5 = sample5;
  15331        dst += 6;
  15332    }
  15333
  15334    cvt->len_cvt = dstsize;
  15335    if (cvt->filters[++cvt->filter_index]) {
  15336        cvt->filters[cvt->filter_index] (cvt, format);
  15337    }
  15338}
  15339
  15340static void SDLCALL
  15341SDL_Upsample_F32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  15342{
  15343#if DEBUG_CONVERT
  15344    fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 6 channels.\n");
  15345#endif
  15346
  15347    const int dstsize = cvt->len_cvt * 4;
  15348    float *dst = ((float *) (cvt->buf + dstsize)) - 6 * 4;
  15349    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
  15350    const float *target = ((const float *) cvt->buf);
  15351    double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
  15352    double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
  15353    double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
  15354    double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
  15355    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  15356    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  15357    while (dst >= target) {
  15358        const double sample5 = (double) SDL_SwapFloatBE(src[5]);
  15359        const double sample4 = (double) SDL_SwapFloatBE(src[4]);
  15360        const double sample3 = (double) SDL_SwapFloatBE(src[3]);
  15361        const double sample2 = (double) SDL_SwapFloatBE(src[2]);
  15362        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  15363        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  15364        src -= 6;
  15365        dst[23] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
  15366        dst[22] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
  15367        dst[21] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
  15368        dst[20] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
  15369        dst[19] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
  15370        dst[18] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
  15371        dst[17] = (float) ((sample5 + last_sample5) * 0.5);
  15372        dst[16] = (float) ((sample4 + last_sample4) * 0.5);
  15373        dst[15] = (float) ((sample3 + last_sample3) * 0.5);
  15374        dst[14] = (float) ((sample2 + last_sample2) * 0.5);
  15375        dst[13] = (float) ((sample1 + last_sample1) * 0.5);
  15376        dst[12] = (float) ((sample0 + last_sample0) * 0.5);
  15377        dst[11] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
  15378        dst[10] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
  15379        dst[9] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
  15380        dst[8] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
  15381        dst[7] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
  15382        dst[6] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
  15383        dst[5] = (float) sample5;
  15384        dst[4] = (float) sample4;
  15385        dst[3] = (float) sample3;
  15386        dst[2] = (float) sample2;
  15387        dst[1] = (float) sample1;
  15388        dst[0] = (float) sample0;
  15389        last_sample5 = sample5;
  15390        last_sample4 = sample4;
  15391        last_sample3 = sample3;
  15392        last_sample2 = sample2;
  15393        last_sample1 = sample1;
  15394        last_sample0 = sample0;
  15395        dst -= 24;
  15396    }
  15397
  15398    cvt->len_cvt = dstsize;
  15399    if (cvt->filters[++cvt->filter_index]) {
  15400        cvt->filters[cvt->filter_index] (cvt, format);
  15401    }
  15402}
  15403
  15404static void SDLCALL
  15405SDL_Downsample_F32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  15406{
  15407#if DEBUG_CONVERT
  15408    fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 6 channels.\n");
  15409#endif
  15410
  15411    const int dstsize = cvt->len_cvt / 4;
  15412    float *dst = (float *) cvt->buf;
  15413    const float *src = (float *) cvt->buf;
  15414    const float *target = (const float *) (cvt->buf + dstsize);
  15415    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  15416    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  15417    double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
  15418    double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
  15419    double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
  15420    double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
  15421    while (dst < target) {
  15422        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  15423        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  15424        const double sample2 = (double) SDL_SwapFloatBE(src[2]);
  15425        const double sample3 = (double) SDL_SwapFloatBE(src[3]);
  15426        const double sample4 = (double) SDL_SwapFloatBE(src[4]);
  15427        const double sample5 = (double) SDL_SwapFloatBE(src[5]);
  15428        src += 24;
  15429        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  15430        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  15431        dst[2] = (float) ((sample2 + last_sample2) * 0.5);
  15432        dst[3] = (float) ((sample3 + last_sample3) * 0.5);
  15433        dst[4] = (float) ((sample4 + last_sample4) * 0.5);
  15434        dst[5] = (float) ((sample5 + last_sample5) * 0.5);
  15435        last_sample0 = sample0;
  15436        last_sample1 = sample1;
  15437        last_sample2 = sample2;
  15438        last_sample3 = sample3;
  15439        last_sample4 = sample4;
  15440        last_sample5 = sample5;
  15441        dst += 6;
  15442    }
  15443
  15444    cvt->len_cvt = dstsize;
  15445    if (cvt->filters[++cvt->filter_index]) {
  15446        cvt->filters[cvt->filter_index] (cvt, format);
  15447    }
  15448}
  15449
  15450static void SDLCALL
  15451SDL_Upsample_F32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  15452{
  15453#if DEBUG_CONVERT
  15454    fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 8 channels.\n");
  15455#endif
  15456
  15457    const int dstsize = cvt->len_cvt * 2;
  15458    float *dst = ((float *) (cvt->buf + dstsize)) - 8 * 2;
  15459    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
  15460    const float *target = ((const float *) cvt->buf);
  15461    double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
  15462    double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
  15463    double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
  15464    double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
  15465    double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
  15466    double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
  15467    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  15468    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  15469    while (dst >= target) {
  15470        const double sample7 = (double) SDL_SwapFloatBE(src[7]);
  15471        const double sample6 = (double) SDL_SwapFloatBE(src[6]);
  15472        const double sample5 = (double) SDL_SwapFloatBE(src[5]);
  15473        const double sample4 = (double) SDL_SwapFloatBE(src[4]);
  15474        const double sample3 = (double) SDL_SwapFloatBE(src[3]);
  15475        const double sample2 = (double) SDL_SwapFloatBE(src[2]);
  15476        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  15477        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  15478        src -= 8;
  15479        dst[15] = (float) ((sample7 + last_sample7) * 0.5);
  15480        dst[14] = (float) ((sample6 + last_sample6) * 0.5);
  15481        dst[13] = (float) ((sample5 + last_sample5) * 0.5);
  15482        dst[12] = (float) ((sample4 + last_sample4) * 0.5);
  15483        dst[11] = (float) ((sample3 + last_sample3) * 0.5);
  15484        dst[10] = (float) ((sample2 + last_sample2) * 0.5);
  15485        dst[9] = (float) ((sample1 + last_sample1) * 0.5);
  15486        dst[8] = (float) ((sample0 + last_sample0) * 0.5);
  15487        dst[7] = (float) sample7;
  15488        dst[6] = (float) sample6;
  15489        dst[5] = (float) sample5;
  15490        dst[4] = (float) sample4;
  15491        dst[3] = (float) sample3;
  15492        dst[2] = (float) sample2;
  15493        dst[1] = (float) sample1;
  15494        dst[0] = (float) sample0;
  15495        last_sample7 = sample7;
  15496        last_sample6 = sample6;
  15497        last_sample5 = sample5;
  15498        last_sample4 = sample4;
  15499        last_sample3 = sample3;
  15500        last_sample2 = sample2;
  15501        last_sample1 = sample1;
  15502        last_sample0 = sample0;
  15503        dst -= 16;
  15504    }
  15505
  15506    cvt->len_cvt = dstsize;
  15507    if (cvt->filters[++cvt->filter_index]) {
  15508        cvt->filters[cvt->filter_index] (cvt, format);
  15509    }
  15510}
  15511
  15512static void SDLCALL
  15513SDL_Downsample_F32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  15514{
  15515#if DEBUG_CONVERT
  15516    fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 8 channels.\n");
  15517#endif
  15518
  15519    const int dstsize = cvt->len_cvt / 2;
  15520    float *dst = (float *) cvt->buf;
  15521    const float *src = (float *) cvt->buf;
  15522    const float *target = (const float *) (cvt->buf + dstsize);
  15523    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  15524    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  15525    double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
  15526    double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
  15527    double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
  15528    double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
  15529    double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
  15530    double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
  15531    while (dst < target) {
  15532        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  15533        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  15534        const double sample2 = (double) SDL_SwapFloatBE(src[2]);
  15535        const double sample3 = (double) SDL_SwapFloatBE(src[3]);
  15536        const double sample4 = (double) SDL_SwapFloatBE(src[4]);
  15537        const double sample5 = (double) SDL_SwapFloatBE(src[5]);
  15538        const double sample6 = (double) SDL_SwapFloatBE(src[6]);
  15539        const double sample7 = (double) SDL_SwapFloatBE(src[7]);
  15540        src += 16;
  15541        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  15542        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  15543        dst[2] = (float) ((sample2 + last_sample2) * 0.5);
  15544        dst[3] = (float) ((sample3 + last_sample3) * 0.5);
  15545        dst[4] = (float) ((sample4 + last_sample4) * 0.5);
  15546        dst[5] = (float) ((sample5 + last_sample5) * 0.5);
  15547        dst[6] = (float) ((sample6 + last_sample6) * 0.5);
  15548        dst[7] = (float) ((sample7 + last_sample7) * 0.5);
  15549        last_sample0 = sample0;
  15550        last_sample1 = sample1;
  15551        last_sample2 = sample2;
  15552        last_sample3 = sample3;
  15553        last_sample4 = sample4;
  15554        last_sample5 = sample5;
  15555        last_sample6 = sample6;
  15556        last_sample7 = sample7;
  15557        dst += 8;
  15558    }
  15559
  15560    cvt->len_cvt = dstsize;
  15561    if (cvt->filters[++cvt->filter_index]) {
  15562        cvt->filters[cvt->filter_index] (cvt, format);
  15563    }
  15564}
  15565
  15566static void SDLCALL
  15567SDL_Upsample_F32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  15568{
  15569#if DEBUG_CONVERT
  15570    fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 8 channels.\n");
  15571#endif
  15572
  15573    const int dstsize = cvt->len_cvt * 4;
  15574    float *dst = ((float *) (cvt->buf + dstsize)) - 8 * 4;
  15575    const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
  15576    const float *target = ((const float *) cvt->buf);
  15577    double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
  15578    double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
  15579    double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
  15580    double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
  15581    double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
  15582    double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
  15583    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  15584    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  15585    while (dst >= target) {
  15586        const double sample7 = (double) SDL_SwapFloatBE(src[7]);
  15587        const double sample6 = (double) SDL_SwapFloatBE(src[6]);
  15588        const double sample5 = (double) SDL_SwapFloatBE(src[5]);
  15589        const double sample4 = (double) SDL_SwapFloatBE(src[4]);
  15590        const double sample3 = (double) SDL_SwapFloatBE(src[3]);
  15591        const double sample2 = (double) SDL_SwapFloatBE(src[2]);
  15592        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  15593        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  15594        src -= 8;
  15595        dst[31] = (float) ((sample7 + (3.0 * last_sample7)) * 0.25);
  15596        dst[30] = (float) ((sample6 + (3.0 * last_sample6)) * 0.25);
  15597        dst[29] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
  15598        dst[28] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
  15599        dst[27] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
  15600        dst[26] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
  15601        dst[25] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
  15602        dst[24] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
  15603        dst[23] = (float) ((sample7 + last_sample7) * 0.5);
  15604        dst[22] = (float) ((sample6 + last_sample6) * 0.5);
  15605        dst[21] = (float) ((sample5 + last_sample5) * 0.5);
  15606        dst[20] = (float) ((sample4 + last_sample4) * 0.5);
  15607        dst[19] = (float) ((sample3 + last_sample3) * 0.5);
  15608        dst[18] = (float) ((sample2 + last_sample2) * 0.5);
  15609        dst[17] = (float) ((sample1 + last_sample1) * 0.5);
  15610        dst[16] = (float) ((sample0 + last_sample0) * 0.5);
  15611        dst[15] = (float) (((3.0 * sample7) + last_sample7) * 0.25);
  15612        dst[14] = (float) (((3.0 * sample6) + last_sample6) * 0.25);
  15613        dst[13] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
  15614        dst[12] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
  15615        dst[11] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
  15616        dst[10] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
  15617        dst[9] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
  15618        dst[8] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
  15619        dst[7] = (float) sample7;
  15620        dst[6] = (float) sample6;
  15621        dst[5] = (float) sample5;
  15622        dst[4] = (float) sample4;
  15623        dst[3] = (float) sample3;
  15624        dst[2] = (float) sample2;
  15625        dst[1] = (float) sample1;
  15626        dst[0] = (float) sample0;
  15627        last_sample7 = sample7;
  15628        last_sample6 = sample6;
  15629        last_sample5 = sample5;
  15630        last_sample4 = sample4;
  15631        last_sample3 = sample3;
  15632        last_sample2 = sample2;
  15633        last_sample1 = sample1;
  15634        last_sample0 = sample0;
  15635        dst -= 32;
  15636    }
  15637
  15638    cvt->len_cvt = dstsize;
  15639    if (cvt->filters[++cvt->filter_index]) {
  15640        cvt->filters[cvt->filter_index] (cvt, format);
  15641    }
  15642}
  15643
  15644static void SDLCALL
  15645SDL_Downsample_F32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  15646{
  15647#if DEBUG_CONVERT
  15648    fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 8 channels.\n");
  15649#endif
  15650
  15651    const int dstsize = cvt->len_cvt / 4;
  15652    float *dst = (float *) cvt->buf;
  15653    const float *src = (float *) cvt->buf;
  15654    const float *target = (const float *) (cvt->buf + dstsize);
  15655    double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
  15656    double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
  15657    double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
  15658    double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
  15659    double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
  15660    double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
  15661    double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
  15662    double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
  15663    while (dst < target) {
  15664        const double sample0 = (double) SDL_SwapFloatBE(src[0]);
  15665        const double sample1 = (double) SDL_SwapFloatBE(src[1]);
  15666        const double sample2 = (double) SDL_SwapFloatBE(src[2]);
  15667        const double sample3 = (double) SDL_SwapFloatBE(src[3]);
  15668        const double sample4 = (double) SDL_SwapFloatBE(src[4]);
  15669        const double sample5 = (double) SDL_SwapFloatBE(src[5]);
  15670        const double sample6 = (double) SDL_SwapFloatBE(src[6]);
  15671        const double sample7 = (double) SDL_SwapFloatBE(src[7]);
  15672        src += 32;
  15673        dst[0] = (float) ((sample0 + last_sample0) * 0.5);
  15674        dst[1] = (float) ((sample1 + last_sample1) * 0.5);
  15675        dst[2] = (float) ((sample2 + last_sample2) * 0.5);
  15676        dst[3] = (float) ((sample3 + last_sample3) * 0.5);
  15677        dst[4] = (float) ((sample4 + last_sample4) * 0.5);
  15678        dst[5] = (float) ((sample5 + last_sample5) * 0.5);
  15679        dst[6] = (float) ((sample6 + last_sample6) * 0.5);
  15680        dst[7] = (float) ((sample7 + last_sample7) * 0.5);
  15681        last_sample0 = sample0;
  15682        last_sample1 = sample1;
  15683        last_sample2 = sample2;
  15684        last_sample3 = sample3;
  15685        last_sample4 = sample4;
  15686        last_sample5 = sample5;
  15687        last_sample6 = sample6;
  15688        last_sample7 = sample7;
  15689        dst += 8;
  15690    }
  15691
  15692    cvt->len_cvt = dstsize;
  15693    if (cvt->filters[++cvt->filter_index]) {
  15694        cvt->filters[cvt->filter_index] (cvt, format);
  15695    }
  15696}
  15697
  15698#endif  /* !LESS_RESAMPLERS */
  15699#endif  /* !NO_RESAMPLERS */
  15700
  15701
  15702const SDL_AudioRateFilters sdl_audio_rate_filters[] =
  15703{
  15704#if !NO_RESAMPLERS
  15705    { AUDIO_U8, 1, 0, 0, SDL_Downsample_U8_1c },
  15706    { AUDIO_U8, 1, 1, 0, SDL_Upsample_U8_1c },
  15707    { AUDIO_U8, 2, 0, 0, SDL_Downsample_U8_2c },
  15708    { AUDIO_U8, 2, 1, 0, SDL_Upsample_U8_2c },
  15709    { AUDIO_U8, 4, 0, 0, SDL_Downsample_U8_4c },
  15710    { AUDIO_U8, 4, 1, 0, SDL_Upsample_U8_4c },
  15711    { AUDIO_U8, 6, 0, 0, SDL_Downsample_U8_6c },
  15712    { AUDIO_U8, 6, 1, 0, SDL_Upsample_U8_6c },
  15713    { AUDIO_U8, 8, 0, 0, SDL_Downsample_U8_8c },
  15714    { AUDIO_U8, 8, 1, 0, SDL_Upsample_U8_8c },
  15715    { AUDIO_S8, 1, 0, 0, SDL_Downsample_S8_1c },
  15716    { AUDIO_S8, 1, 1, 0, SDL_Upsample_S8_1c },
  15717    { AUDIO_S8, 2, 0, 0, SDL_Downsample_S8_2c },
  15718    { AUDIO_S8, 2, 1, 0, SDL_Upsample_S8_2c },
  15719    { AUDIO_S8, 4, 0, 0, SDL_Downsample_S8_4c },
  15720    { AUDIO_S8, 4, 1, 0, SDL_Upsample_S8_4c },
  15721    { AUDIO_S8, 6, 0, 0, SDL_Downsample_S8_6c },
  15722    { AUDIO_S8, 6, 1, 0, SDL_Upsample_S8_6c },
  15723    { AUDIO_S8, 8, 0, 0, SDL_Downsample_S8_8c },
  15724    { AUDIO_S8, 8, 1, 0, SDL_Upsample_S8_8c },
  15725    { AUDIO_U16LSB, 1, 0, 0, SDL_Downsample_U16LSB_1c },
  15726    { AUDIO_U16LSB, 1, 1, 0, SDL_Upsample_U16LSB_1c },
  15727    { AUDIO_U16LSB, 2, 0, 0, SDL_Downsample_U16LSB_2c },
  15728    { AUDIO_U16LSB, 2, 1, 0, SDL_Upsample_U16LSB_2c },
  15729    { AUDIO_U16LSB, 4, 0, 0, SDL_Downsample_U16LSB_4c },
  15730    { AUDIO_U16LSB, 4, 1, 0, SDL_Upsample_U16LSB_4c },
  15731    { AUDIO_U16LSB, 6, 0, 0, SDL_Downsample_U16LSB_6c },
  15732    { AUDIO_U16LSB, 6, 1, 0, SDL_Upsample_U16LSB_6c },
  15733    { AUDIO_U16LSB, 8, 0, 0, SDL_Downsample_U16LSB_8c },
  15734    { AUDIO_U16LSB, 8, 1, 0, SDL_Upsample_U16LSB_8c },
  15735    { AUDIO_S16LSB, 1, 0, 0, SDL_Downsample_S16LSB_1c },
  15736    { AUDIO_S16LSB, 1, 1, 0, SDL_Upsample_S16LSB_1c },
  15737    { AUDIO_S16LSB, 2, 0, 0, SDL_Downsample_S16LSB_2c },
  15738    { AUDIO_S16LSB, 2, 1, 0, SDL_Upsample_S16LSB_2c },
  15739    { AUDIO_S16LSB, 4, 0, 0, SDL_Downsample_S16LSB_4c },
  15740    { AUDIO_S16LSB, 4, 1, 0, SDL_Upsample_S16LSB_4c },
  15741    { AUDIO_S16LSB, 6, 0, 0, SDL_Downsample_S16LSB_6c },
  15742    { AUDIO_S16LSB, 6, 1, 0, SDL_Upsample_S16LSB_6c },
  15743    { AUDIO_S16LSB, 8, 0, 0, SDL_Downsample_S16LSB_8c },
  15744    { AUDIO_S16LSB, 8, 1, 0, SDL_Upsample_S16LSB_8c },
  15745    { AUDIO_U16MSB, 1, 0, 0, SDL_Downsample_U16MSB_1c },
  15746    { AUDIO_U16MSB, 1, 1, 0, SDL_Upsample_U16MSB_1c },
  15747    { AUDIO_U16MSB, 2, 0, 0, SDL_Downsample_U16MSB_2c },
  15748    { AUDIO_U16MSB, 2, 1, 0, SDL_Upsample_U16MSB_2c },
  15749    { AUDIO_U16MSB, 4, 0, 0, SDL_Downsample_U16MSB_4c },
  15750    { AUDIO_U16MSB, 4, 1, 0, SDL_Upsample_U16MSB_4c },
  15751    { AUDIO_U16MSB, 6, 0, 0, SDL_Downsample_U16MSB_6c },
  15752    { AUDIO_U16MSB, 6, 1, 0, SDL_Upsample_U16MSB_6c },
  15753    { AUDIO_U16MSB, 8, 0, 0, SDL_Downsample_U16MSB_8c },
  15754    { AUDIO_U16MSB, 8, 1, 0, SDL_Upsample_U16MSB_8c },
  15755    { AUDIO_S16MSB, 1, 0, 0, SDL_Downsample_S16MSB_1c },
  15756    { AUDIO_S16MSB, 1, 1, 0, SDL_Upsample_S16MSB_1c },
  15757    { AUDIO_S16MSB, 2, 0, 0, SDL_Downsample_S16MSB_2c },
  15758    { AUDIO_S16MSB, 2, 1, 0, SDL_Upsample_S16MSB_2c },
  15759    { AUDIO_S16MSB, 4, 0, 0, SDL_Downsample_S16MSB_4c },
  15760    { AUDIO_S16MSB, 4, 1, 0, SDL_Upsample_S16MSB_4c },
  15761    { AUDIO_S16MSB, 6, 0, 0, SDL_Downsample_S16MSB_6c },
  15762    { AUDIO_S16MSB, 6, 1, 0, SDL_Upsample_S16MSB_6c },
  15763    { AUDIO_S16MSB, 8, 0, 0, SDL_Downsample_S16MSB_8c },
  15764    { AUDIO_S16MSB, 8, 1, 0, SDL_Upsample_S16MSB_8c },
  15765    { AUDIO_S32LSB, 1, 0, 0, SDL_Downsample_S32LSB_1c },
  15766    { AUDIO_S32LSB, 1, 1, 0, SDL_Upsample_S32LSB_1c },
  15767    { AUDIO_S32LSB, 2, 0, 0, SDL_Downsample_S32LSB_2c },
  15768    { AUDIO_S32LSB, 2, 1, 0, SDL_Upsample_S32LSB_2c },
  15769    { AUDIO_S32LSB, 4, 0, 0, SDL_Downsample_S32LSB_4c },
  15770    { AUDIO_S32LSB, 4, 1, 0, SDL_Upsample_S32LSB_4c },
  15771    { AUDIO_S32LSB, 6, 0, 0, SDL_Downsample_S32LSB_6c },
  15772    { AUDIO_S32LSB, 6, 1, 0, SDL_Upsample_S32LSB_6c },
  15773    { AUDIO_S32LSB, 8, 0, 0, SDL_Downsample_S32LSB_8c },
  15774    { AUDIO_S32LSB, 8, 1, 0, SDL_Upsample_S32LSB_8c },
  15775    { AUDIO_S32MSB, 1, 0, 0, SDL_Downsample_S32MSB_1c },
  15776    { AUDIO_S32MSB, 1, 1, 0, SDL_Upsample_S32MSB_1c },
  15777    { AUDIO_S32MSB, 2, 0, 0, SDL_Downsample_S32MSB_2c },
  15778    { AUDIO_S32MSB, 2, 1, 0, SDL_Upsample_S32MSB_2c },
  15779    { AUDIO_S32MSB, 4, 0, 0, SDL_Downsample_S32MSB_4c },
  15780    { AUDIO_S32MSB, 4, 1, 0, SDL_Upsample_S32MSB_4c },
  15781    { AUDIO_S32MSB, 6, 0, 0, SDL_Downsample_S32MSB_6c },
  15782    { AUDIO_S32MSB, 6, 1, 0, SDL_Upsample_S32MSB_6c },
  15783    { AUDIO_S32MSB, 8, 0, 0, SDL_Downsample_S32MSB_8c },
  15784    { AUDIO_S32MSB, 8, 1, 0, SDL_Upsample_S32MSB_8c },
  15785    { AUDIO_F32LSB, 1, 0, 0, SDL_Downsample_F32LSB_1c },
  15786    { AUDIO_F32LSB, 1, 1, 0, SDL_Upsample_F32LSB_1c },
  15787    { AUDIO_F32LSB, 2, 0, 0, SDL_Downsample_F32LSB_2c },
  15788    { AUDIO_F32LSB, 2, 1, 0, SDL_Upsample_F32LSB_2c },
  15789    { AUDIO_F32LSB, 4, 0, 0, SDL_Downsample_F32LSB_4c },
  15790    { AUDIO_F32LSB, 4, 1, 0, SDL_Upsample_F32LSB_4c },
  15791    { AUDIO_F32LSB, 6, 0, 0, SDL_Downsample_F32LSB_6c },
  15792    { AUDIO_F32LSB, 6, 1, 0, SDL_Upsample_F32LSB_6c },
  15793    { AUDIO_F32LSB, 8, 0, 0, SDL_Downsample_F32LSB_8c },
  15794    { AUDIO_F32LSB, 8, 1, 0, SDL_Upsample_F32LSB_8c },
  15795    { AUDIO_F32MSB, 1, 0, 0, SDL_Downsample_F32MSB_1c },
  15796    { AUDIO_F32MSB, 1, 1, 0, SDL_Upsample_F32MSB_1c },
  15797    { AUDIO_F32MSB, 2, 0, 0, SDL_Downsample_F32MSB_2c },
  15798    { AUDIO_F32MSB, 2, 1, 0, SDL_Upsample_F32MSB_2c },
  15799    { AUDIO_F32MSB, 4, 0, 0, SDL_Downsample_F32MSB_4c },
  15800    { AUDIO_F32MSB, 4, 1, 0, SDL_Upsample_F32MSB_4c },
  15801    { AUDIO_F32MSB, 6, 0, 0, SDL_Downsample_F32MSB_6c },
  15802    { AUDIO_F32MSB, 6, 1, 0, SDL_Upsample_F32MSB_6c },
  15803    { AUDIO_F32MSB, 8, 0, 0, SDL_Downsample_F32MSB_8c },
  15804    { AUDIO_F32MSB, 8, 1, 0, SDL_Upsample_F32MSB_8c },
  15805#if !LESS_RESAMPLERS
  15806    { AUDIO_U8, 1, 0, 2, SDL_Downsample_U8_1c_x2 },
  15807    { AUDIO_U8, 1, 1, 2, SDL_Upsample_U8_1c_x2 },
  15808    { AUDIO_U8, 1, 0, 4, SDL_Downsample_U8_1c_x4 },
  15809    { AUDIO_U8, 1, 1, 4, SDL_Upsample_U8_1c_x4 },
  15810    { AUDIO_U8, 2, 0, 2, SDL_Downsample_U8_2c_x2 },
  15811    { AUDIO_U8, 2, 1, 2, SDL_Upsample_U8_2c_x2 },
  15812    { AUDIO_U8, 2, 0, 4, SDL_Downsample_U8_2c_x4 },
  15813    { AUDIO_U8, 2, 1, 4, SDL_Upsample_U8_2c_x4 },
  15814    { AUDIO_U8, 4, 0, 2, SDL_Downsample_U8_4c_x2 },
  15815    { AUDIO_U8, 4, 1, 2, SDL_Upsample_U8_4c_x2 },
  15816    { AUDIO_U8, 4, 0, 4, SDL_Downsample_U8_4c_x4 },
  15817    { AUDIO_U8, 4, 1, 4, SDL_Upsample_U8_4c_x4 },
  15818    { AUDIO_U8, 6, 0, 2, SDL_Downsample_U8_6c_x2 },
  15819    { AUDIO_U8, 6, 1, 2, SDL_Upsample_U8_6c_x2 },
  15820    { AUDIO_U8, 6, 0, 4, SDL_Downsample_U8_6c_x4 },
  15821    { AUDIO_U8, 6, 1, 4, SDL_Upsample_U8_6c_x4 },
  15822    { AUDIO_U8, 8, 0, 2, SDL_Downsample_U8_8c_x2 },
  15823    { AUDIO_U8, 8, 1, 2, SDL_Upsample_U8_8c_x2 },
  15824    { AUDIO_U8, 8, 0, 4, SDL_Downsample_U8_8c_x4 },
  15825    { AUDIO_U8, 8, 1, 4, SDL_Upsample_U8_8c_x4 },
  15826    { AUDIO_S8, 1, 0, 2, SDL_Downsample_S8_1c_x2 },
  15827    { AUDIO_S8, 1, 1, 2, SDL_Upsample_S8_1c_x2 },
  15828    { AUDIO_S8, 1, 0, 4, SDL_Downsample_S8_1c_x4 },
  15829    { AUDIO_S8, 1, 1, 4, SDL_Upsample_S8_1c_x4 },
  15830    { AUDIO_S8, 2, 0, 2, SDL_Downsample_S8_2c_x2 },
  15831    { AUDIO_S8, 2, 1, 2, SDL_Upsample_S8_2c_x2 },
  15832    { AUDIO_S8, 2, 0, 4, SDL_Downsample_S8_2c_x4 },
  15833    { AUDIO_S8, 2, 1, 4, SDL_Upsample_S8_2c_x4 },
  15834    { AUDIO_S8, 4, 0, 2, SDL_Downsample_S8_4c_x2 },
  15835    { AUDIO_S8, 4, 1, 2, SDL_Upsample_S8_4c_x2 },
  15836    { AUDIO_S8, 4, 0, 4, SDL_Downsample_S8_4c_x4 },
  15837    { AUDIO_S8, 4, 1, 4, SDL_Upsample_S8_4c_x4 },
  15838    { AUDIO_S8, 6, 0, 2, SDL_Downsample_S8_6c_x2 },
  15839    { AUDIO_S8, 6, 1, 2, SDL_Upsample_S8_6c_x2 },
  15840    { AUDIO_S8, 6, 0, 4, SDL_Downsample_S8_6c_x4 },
  15841    { AUDIO_S8, 6, 1, 4, SDL_Upsample_S8_6c_x4 },
  15842    { AUDIO_S8, 8, 0, 2, SDL_Downsample_S8_8c_x2 },
  15843    { AUDIO_S8, 8, 1, 2, SDL_Upsample_S8_8c_x2 },
  15844    { AUDIO_S8, 8, 0, 4, SDL_Downsample_S8_8c_x4 },
  15845    { AUDIO_S8, 8, 1, 4, SDL_Upsample_S8_8c_x4 },
  15846    { AUDIO_U16LSB, 1, 0, 2, SDL_Downsample_U16LSB_1c_x2 },
  15847    { AUDIO_U16LSB, 1, 1, 2, SDL_Upsample_U16LSB_1c_x2 },
  15848    { AUDIO_U16LSB, 1, 0, 4, SDL_Downsample_U16LSB_1c_x4 },
  15849    { AUDIO_U16LSB, 1, 1, 4, SDL_Upsample_U16LSB_1c_x4 },
  15850    { AUDIO_U16LSB, 2, 0, 2, SDL_Downsample_U16LSB_2c_x2 },
  15851    { AUDIO_U16LSB, 2, 1, 2, SDL_Upsample_U16LSB_2c_x2 },
  15852    { AUDIO_U16LSB, 2, 0, 4, SDL_Downsample_U16LSB_2c_x4 },
  15853    { AUDIO_U16LSB, 2, 1, 4, SDL_Upsample_U16LSB_2c_x4 },
  15854    { AUDIO_U16LSB, 4, 0, 2, SDL_Downsample_U16LSB_4c_x2 },
  15855    { AUDIO_U16LSB, 4, 1, 2, SDL_Upsample_U16LSB_4c_x2 },
  15856    { AUDIO_U16LSB, 4, 0, 4, SDL_Downsample_U16LSB_4c_x4 },
  15857    { AUDIO_U16LSB, 4, 1, 4, SDL_Upsample_U16LSB_4c_x4 },
  15858    { AUDIO_U16LSB, 6, 0, 2, SDL_Downsample_U16LSB_6c_x2 },
  15859    { AUDIO_U16LSB, 6, 1, 2, SDL_Upsample_U16LSB_6c_x2 },
  15860    { AUDIO_U16LSB, 6, 0, 4, SDL_Downsample_U16LSB_6c_x4 },
  15861    { AUDIO_U16LSB, 6, 1, 4, SDL_Upsample_U16LSB_6c_x4 },
  15862    { AUDIO_U16LSB, 8, 0, 2, SDL_Downsample_U16LSB_8c_x2 },
  15863    { AUDIO_U16LSB, 8, 1, 2, SDL_Upsample_U16LSB_8c_x2 },
  15864    { AUDIO_U16LSB, 8, 0, 4, SDL_Downsample_U16LSB_8c_x4 },
  15865    { AUDIO_U16LSB, 8, 1, 4, SDL_Upsample_U16LSB_8c_x4 },
  15866    { AUDIO_S16LSB, 1, 0, 2, SDL_Downsample_S16LSB_1c_x2 },
  15867    { AUDIO_S16LSB, 1, 1, 2, SDL_Upsample_S16LSB_1c_x2 },
  15868    { AUDIO_S16LSB, 1, 0, 4, SDL_Downsample_S16LSB_1c_x4 },
  15869    { AUDIO_S16LSB, 1, 1, 4, SDL_Upsample_S16LSB_1c_x4 },
  15870    { AUDIO_S16LSB, 2, 0, 2, SDL_Downsample_S16LSB_2c_x2 },
  15871    { AUDIO_S16LSB, 2, 1, 2, SDL_Upsample_S16LSB_2c_x2 },
  15872    { AUDIO_S16LSB, 2, 0, 4, SDL_Downsample_S16LSB_2c_x4 },
  15873    { AUDIO_S16LSB, 2, 1, 4, SDL_Upsample_S16LSB_2c_x4 },
  15874    { AUDIO_S16LSB, 4, 0, 2, SDL_Downsample_S16LSB_4c_x2 },
  15875    { AUDIO_S16LSB, 4, 1, 2, SDL_Upsample_S16LSB_4c_x2 },
  15876    { AUDIO_S16LSB, 4, 0, 4, SDL_Downsample_S16LSB_4c_x4 },
  15877    { AUDIO_S16LSB, 4, 1, 4, SDL_Upsample_S16LSB_4c_x4 },
  15878    { AUDIO_S16LSB, 6, 0, 2, SDL_Downsample_S16LSB_6c_x2 },
  15879    { AUDIO_S16LSB, 6, 1, 2, SDL_Upsample_S16LSB_6c_x2 },
  15880    { AUDIO_S16LSB, 6, 0, 4, SDL_Downsample_S16LSB_6c_x4 },
  15881    { AUDIO_S16LSB, 6, 1, 4, SDL_Upsample_S16LSB_6c_x4 },
  15882    { AUDIO_S16LSB, 8, 0, 2, SDL_Downsample_S16LSB_8c_x2 },
  15883    { AUDIO_S16LSB, 8, 1, 2, SDL_Upsample_S16LSB_8c_x2 },
  15884    { AUDIO_S16LSB, 8, 0, 4, SDL_Downsample_S16LSB_8c_x4 },
  15885    { AUDIO_S16LSB, 8, 1, 4, SDL_Upsample_S16LSB_8c_x4 },
  15886    { AUDIO_U16MSB, 1, 0, 2, SDL_Downsample_U16MSB_1c_x2 },
  15887    { AUDIO_U16MSB, 1, 1, 2, SDL_Upsample_U16MSB_1c_x2 },
  15888    { AUDIO_U16MSB, 1, 0, 4, SDL_Downsample_U16MSB_1c_x4 },
  15889    { AUDIO_U16MSB, 1, 1, 4, SDL_Upsample_U16MSB_1c_x4 },
  15890    { AUDIO_U16MSB, 2, 0, 2, SDL_Downsample_U16MSB_2c_x2 },
  15891    { AUDIO_U16MSB, 2, 1, 2, SDL_Upsample_U16MSB_2c_x2 },
  15892    { AUDIO_U16MSB, 2, 0, 4, SDL_Downsample_U16MSB_2c_x4 },
  15893    { AUDIO_U16MSB, 2, 1, 4, SDL_Upsample_U16MSB_2c_x4 },
  15894    { AUDIO_U16MSB, 4, 0, 2, SDL_Downsample_U16MSB_4c_x2 },
  15895    { AUDIO_U16MSB, 4, 1, 2, SDL_Upsample_U16MSB_4c_x2 },
  15896    { AUDIO_U16MSB, 4, 0, 4, SDL_Downsample_U16MSB_4c_x4 },
  15897    { AUDIO_U16MSB, 4, 1, 4, SDL_Upsample_U16MSB_4c_x4 },
  15898    { AUDIO_U16MSB, 6, 0, 2, SDL_Downsample_U16MSB_6c_x2 },
  15899    { AUDIO_U16MSB, 6, 1, 2, SDL_Upsample_U16MSB_6c_x2 },
  15900    { AUDIO_U16MSB, 6, 0, 4, SDL_Downsample_U16MSB_6c_x4 },
  15901    { AUDIO_U16MSB, 6, 1, 4, SDL_Upsample_U16MSB_6c_x4 },
  15902    { AUDIO_U16MSB, 8, 0, 2, SDL_Downsample_U16MSB_8c_x2 },
  15903    { AUDIO_U16MSB, 8, 1, 2, SDL_Upsample_U16MSB_8c_x2 },
  15904    { AUDIO_U16MSB, 8, 0, 4, SDL_Downsample_U16MSB_8c_x4 },
  15905    { AUDIO_U16MSB, 8, 1, 4, SDL_Upsample_U16MSB_8c_x4 },
  15906    { AUDIO_S16MSB, 1, 0, 2, SDL_Downsample_S16MSB_1c_x2 },
  15907    { AUDIO_S16MSB, 1, 1, 2, SDL_Upsample_S16MSB_1c_x2 },
  15908    { AUDIO_S16MSB, 1, 0, 4, SDL_Downsample_S16MSB_1c_x4 },
  15909    { AUDIO_S16MSB, 1, 1, 4, SDL_Upsample_S16MSB_1c_x4 },
  15910    { AUDIO_S16MSB, 2, 0, 2, SDL_Downsample_S16MSB_2c_x2 },
  15911    { AUDIO_S16MSB, 2, 1, 2, SDL_Upsample_S16MSB_2c_x2 },
  15912    { AUDIO_S16MSB, 2, 0, 4, SDL_Downsample_S16MSB_2c_x4 },
  15913    { AUDIO_S16MSB, 2, 1, 4, SDL_Upsample_S16MSB_2c_x4 },
  15914    { AUDIO_S16MSB, 4, 0, 2, SDL_Downsample_S16MSB_4c_x2 },
  15915    { AUDIO_S16MSB, 4, 1, 2, SDL_Upsample_S16MSB_4c_x2 },
  15916    { AUDIO_S16MSB, 4, 0, 4, SDL_Downsample_S16MSB_4c_x4 },
  15917    { AUDIO_S16MSB, 4, 1, 4, SDL_Upsample_S16MSB_4c_x4 },
  15918    { AUDIO_S16MSB, 6, 0, 2, SDL_Downsample_S16MSB_6c_x2 },
  15919    { AUDIO_S16MSB, 6, 1, 2, SDL_Upsample_S16MSB_6c_x2 },
  15920    { AUDIO_S16MSB, 6, 0, 4, SDL_Downsample_S16MSB_6c_x4 },
  15921    { AUDIO_S16MSB, 6, 1, 4, SDL_Upsample_S16MSB_6c_x4 },
  15922    { AUDIO_S16MSB, 8, 0, 2, SDL_Downsample_S16MSB_8c_x2 },
  15923    { AUDIO_S16MSB, 8, 1, 2, SDL_Upsample_S16MSB_8c_x2 },
  15924    { AUDIO_S16MSB, 8, 0, 4, SDL_Downsample_S16MSB_8c_x4 },
  15925    { AUDIO_S16MSB, 8, 1, 4, SDL_Upsample_S16MSB_8c_x4 },
  15926    { AUDIO_S32LSB, 1, 0, 2, SDL_Downsample_S32LSB_1c_x2 },
  15927    { AUDIO_S32LSB, 1, 1, 2, SDL_Upsample_S32LSB_1c_x2 },
  15928    { AUDIO_S32LSB, 1, 0, 4, SDL_Downsample_S32LSB_1c_x4 },
  15929    { AUDIO_S32LSB, 1, 1, 4, SDL_Upsample_S32LSB_1c_x4 },
  15930    { AUDIO_S32LSB, 2, 0, 2, SDL_Downsample_S32LSB_2c_x2 },
  15931    { AUDIO_S32LSB, 2, 1, 2, SDL_Upsample_S32LSB_2c_x2 },
  15932    { AUDIO_S32LSB, 2, 0, 4, SDL_Downsample_S32LSB_2c_x4 },
  15933    { AUDIO_S32LSB, 2, 1, 4, SDL_Upsample_S32LSB_2c_x4 },
  15934    { AUDIO_S32LSB, 4, 0, 2, SDL_Downsample_S32LSB_4c_x2 },
  15935    { AUDIO_S32LSB, 4, 1, 2, SDL_Upsample_S32LSB_4c_x2 },
  15936    { AUDIO_S32LSB, 4, 0, 4, SDL_Downsample_S32LSB_4c_x4 },
  15937    { AUDIO_S32LSB, 4, 1, 4, SDL_Upsample_S32LSB_4c_x4 },
  15938    { AUDIO_S32LSB, 6, 0, 2, SDL_Downsample_S32LSB_6c_x2 },
  15939    { AUDIO_S32LSB, 6, 1, 2, SDL_Upsample_S32LSB_6c_x2 },
  15940    { AUDIO_S32LSB, 6, 0, 4, SDL_Downsample_S32LSB_6c_x4 },
  15941    { AUDIO_S32LSB, 6, 1, 4, SDL_Upsample_S32LSB_6c_x4 },
  15942    { AUDIO_S32LSB, 8, 0, 2, SDL_Downsample_S32LSB_8c_x2 },
  15943    { AUDIO_S32LSB, 8, 1, 2, SDL_Upsample_S32LSB_8c_x2 },
  15944    { AUDIO_S32LSB, 8, 0, 4, SDL_Downsample_S32LSB_8c_x4 },
  15945    { AUDIO_S32LSB, 8, 1, 4, SDL_Upsample_S32LSB_8c_x4 },
  15946    { AUDIO_S32MSB, 1, 0, 2, SDL_Downsample_S32MSB_1c_x2 },
  15947    { AUDIO_S32MSB, 1, 1, 2, SDL_Upsample_S32MSB_1c_x2 },
  15948    { AUDIO_S32MSB, 1, 0, 4, SDL_Downsample_S32MSB_1c_x4 },
  15949    { AUDIO_S32MSB, 1, 1, 4, SDL_Upsample_S32MSB_1c_x4 },
  15950    { AUDIO_S32MSB, 2, 0, 2, SDL_Downsample_S32MSB_2c_x2 },
  15951    { AUDIO_S32MSB, 2, 1, 2, SDL_Upsample_S32MSB_2c_x2 },
  15952    { AUDIO_S32MSB, 2, 0, 4, SDL_Downsample_S32MSB_2c_x4 },
  15953    { AUDIO_S32MSB, 2, 1, 4, SDL_Upsample_S32MSB_2c_x4 },
  15954    { AUDIO_S32MSB, 4, 0, 2, SDL_Downsample_S32MSB_4c_x2 },
  15955    { AUDIO_S32MSB, 4, 1, 2, SDL_Upsample_S32MSB_4c_x2 },
  15956    { AUDIO_S32MSB, 4, 0, 4, SDL_Downsample_S32MSB_4c_x4 },
  15957    { AUDIO_S32MSB, 4, 1, 4, SDL_Upsample_S32MSB_4c_x4 },
  15958    { AUDIO_S32MSB, 6, 0, 2, SDL_Downsample_S32MSB_6c_x2 },
  15959    { AUDIO_S32MSB, 6, 1, 2, SDL_Upsample_S32MSB_6c_x2 },
  15960    { AUDIO_S32MSB, 6, 0, 4, SDL_Downsample_S32MSB_6c_x4 },
  15961    { AUDIO_S32MSB, 6, 1, 4, SDL_Upsample_S32MSB_6c_x4 },
  15962    { AUDIO_S32MSB, 8, 0, 2, SDL_Downsample_S32MSB_8c_x2 },
  15963    { AUDIO_S32MSB, 8, 1, 2, SDL_Upsample_S32MSB_8c_x2 },
  15964    { AUDIO_S32MSB, 8, 0, 4, SDL_Downsample_S32MSB_8c_x4 },
  15965    { AUDIO_S32MSB, 8, 1, 4, SDL_Upsample_S32MSB_8c_x4 },
  15966    { AUDIO_F32LSB, 1, 0, 2, SDL_Downsample_F32LSB_1c_x2 },
  15967    { AUDIO_F32LSB, 1, 1, 2, SDL_Upsample_F32LSB_1c_x2 },
  15968    { AUDIO_F32LSB, 1, 0, 4, SDL_Downsample_F32LSB_1c_x4 },
  15969    { AUDIO_F32LSB, 1, 1, 4, SDL_Upsample_F32LSB_1c_x4 },
  15970    { AUDIO_F32LSB, 2, 0, 2, SDL_Downsample_F32LSB_2c_x2 },
  15971    { AUDIO_F32LSB, 2, 1, 2, SDL_Upsample_F32LSB_2c_x2 },
  15972    { AUDIO_F32LSB, 2, 0, 4, SDL_Downsample_F32LSB_2c_x4 },
  15973    { AUDIO_F32LSB, 2, 1, 4, SDL_Upsample_F32LSB_2c_x4 },
  15974    { AUDIO_F32LSB, 4, 0, 2, SDL_Downsample_F32LSB_4c_x2 },
  15975    { AUDIO_F32LSB, 4, 1, 2, SDL_Upsample_F32LSB_4c_x2 },
  15976    { AUDIO_F32LSB, 4, 0, 4, SDL_Downsample_F32LSB_4c_x4 },
  15977    { AUDIO_F32LSB, 4, 1, 4, SDL_Upsample_F32LSB_4c_x4 },
  15978    { AUDIO_F32LSB, 6, 0, 2, SDL_Downsample_F32LSB_6c_x2 },
  15979    { AUDIO_F32LSB, 6, 1, 2, SDL_Upsample_F32LSB_6c_x2 },
  15980    { AUDIO_F32LSB, 6, 0, 4, SDL_Downsample_F32LSB_6c_x4 },
  15981    { AUDIO_F32LSB, 6, 1, 4, SDL_Upsample_F32LSB_6c_x4 },
  15982    { AUDIO_F32LSB, 8, 0, 2, SDL_Downsample_F32LSB_8c_x2 },
  15983    { AUDIO_F32LSB, 8, 1, 2, SDL_Upsample_F32LSB_8c_x2 },
  15984    { AUDIO_F32LSB, 8, 0, 4, SDL_Downsample_F32LSB_8c_x4 },
  15985    { AUDIO_F32LSB, 8, 1, 4, SDL_Upsample_F32LSB_8c_x4 },
  15986    { AUDIO_F32MSB, 1, 0, 2, SDL_Downsample_F32MSB_1c_x2 },
  15987    { AUDIO_F32MSB, 1, 1, 2, SDL_Upsample_F32MSB_1c_x2 },
  15988    { AUDIO_F32MSB, 1, 0, 4, SDL_Downsample_F32MSB_1c_x4 },
  15989    { AUDIO_F32MSB, 1, 1, 4, SDL_Upsample_F32MSB_1c_x4 },
  15990    { AUDIO_F32MSB, 2, 0, 2, SDL_Downsample_F32MSB_2c_x2 },
  15991    { AUDIO_F32MSB, 2, 1, 2, SDL_Upsample_F32MSB_2c_x2 },
  15992    { AUDIO_F32MSB, 2, 0, 4, SDL_Downsample_F32MSB_2c_x4 },
  15993    { AUDIO_F32MSB, 2, 1, 4, SDL_Upsample_F32MSB_2c_x4 },
  15994    { AUDIO_F32MSB, 4, 0, 2, SDL_Downsample_F32MSB_4c_x2 },
  15995    { AUDIO_F32MSB, 4, 1, 2, SDL_Upsample_F32MSB_4c_x2 },
  15996    { AUDIO_F32MSB, 4, 0, 4, SDL_Downsample_F32MSB_4c_x4 },
  15997    { AUDIO_F32MSB, 4, 1, 4, SDL_Upsample_F32MSB_4c_x4 },
  15998    { AUDIO_F32MSB, 6, 0, 2, SDL_Downsample_F32MSB_6c_x2 },
  15999    { AUDIO_F32MSB, 6, 1, 2, SDL_Upsample_F32MSB_6c_x2 },
  16000    { AUDIO_F32MSB, 6, 0, 4, SDL_Downsample_F32MSB_6c_x4 },
  16001    { AUDIO_F32MSB, 6, 1, 4, SDL_Upsample_F32MSB_6c_x4 },
  16002    { AUDIO_F32MSB, 8, 0, 2, SDL_Downsample_F32MSB_8c_x2 },
  16003    { AUDIO_F32MSB, 8, 1, 2, SDL_Upsample_F32MSB_8c_x2 },
  16004    { AUDIO_F32MSB, 8, 0, 4, SDL_Downsample_F32MSB_8c_x4 },
  16005    { AUDIO_F32MSB, 8, 1, 4, SDL_Upsample_F32MSB_8c_x4 },
  16006#endif  /* !LESS_RESAMPLERS */
  16007#endif  /* !NO_RESAMPLERS */
  16008    { 0, 0, 0, 0, NULL }
  16009};
  16010
  16011/* 390 converters generated. */
  16012
  16013/* *INDENT-ON* */
  16014
  16015/* vi: set ts=4 sw=4 expandtab: */