summaryrefslogtreecommitdiff
path: root/macosx/plugins/Common/SDL/src/audio
diff options
context:
space:
mode:
authorSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-08-22 20:05:38 +0000
committerSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-08-22 20:05:38 +0000
commit9628a367530657e7fefb17be0a125dbe3f5d7614 (patch)
treebaceff9a417edb789ad675372d364bb33aea82c4 /macosx/plugins/Common/SDL/src/audio
parent105868aa85053f9597d6099e8d25d6ef8e0f992a (diff)
downloadpcsxr-9628a367530657e7fefb17be0a125dbe3f5d7614.tar.gz
Use SDL2.framework from /Library/Frameworks on OS X instead of miniSDL.
Remove SDL code on OS X's plug-ins subdirectory. git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@86848 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/plugins/Common/SDL/src/audio')
-rw-r--r--macosx/plugins/Common/SDL/src/audio/SDL_audio.c1121
-rw-r--r--macosx/plugins/Common/SDL/src/audio/SDL_audio_c.h56
-rw-r--r--macosx/plugins/Common/SDL/src/audio/SDL_audiocvt.c1080
-rw-r--r--macosx/plugins/Common/SDL/src/audio/SDL_audiomem.h26
-rw-r--r--macosx/plugins/Common/SDL/src/audio/SDL_audiotypecvt.c16216
-rw-r--r--macosx/plugins/Common/SDL/src/audio/SDL_mixer.c313
-rw-r--r--macosx/plugins/Common/SDL/src/audio/SDL_sysaudio.h129
-rw-r--r--macosx/plugins/Common/SDL/src/audio/SDL_wave.c636
-rw-r--r--macosx/plugins/Common/SDL/src/audio/SDL_wave.h65
-rw-r--r--macosx/plugins/Common/SDL/src/audio/macosx/SDL_coreaudio.c596
-rw-r--r--macosx/plugins/Common/SDL/src/audio/macosx/SDL_coreaudio.h43
11 files changed, 0 insertions, 20281 deletions
diff --git a/macosx/plugins/Common/SDL/src/audio/SDL_audio.c b/macosx/plugins/Common/SDL/src/audio/SDL_audio.c
deleted file mode 100644
index 1aac56df..00000000
--- a/macosx/plugins/Common/SDL/src/audio/SDL_audio.c
+++ /dev/null
@@ -1,1121 +0,0 @@
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2010 Sam Lantinga
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Sam Lantinga
- slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* Allow access to a raw mixing buffer */
-
-#include "SDL.h"
-#include "SDL_audio.h"
-#include "SDL_audio_c.h"
-#include "SDL_audiomem.h"
-#include "SDL_sysaudio.h"
-
-#define _THIS SDL_AudioDevice *_this
-
-static SDL_AudioDriver current_audio;
-static SDL_AudioDevice *open_devices[16];
-
-/* !!! FIXME: These are wordy and unlocalized... */
-#define DEFAULT_OUTPUT_DEVNAME "System audio output device"
-#define DEFAULT_INPUT_DEVNAME "System audio capture device"
-
-
-/*
- * Not all of these will be compiled and linked in, but it's convenient
- * to have a complete list here and saves yet-another block of #ifdefs...
- * Please see bootstrap[], below, for the actual #ifdef mess.
- */
-
-extern AudioBootStrap COREAUDIO_bootstrap;
-
-/* Available audio drivers */
-static const AudioBootStrap *const bootstrap[] = {
- &COREAUDIO_bootstrap, NULL
-};
-
-static SDL_AudioDevice *
-get_audio_device(SDL_AudioDeviceID id)
-{
- id--;
- if ((id >= SDL_arraysize(open_devices)) || (open_devices[id] == NULL)) {
- SDL_SetError("Invalid audio device ID");
- return NULL;
- }
-
- return open_devices[id];
-}
-
-
-/* stubs for audio drivers that don't need a specific entry point... */
-static int
-SDL_AudioDetectDevices_Default(int iscapture)
-{
- return -1;
-}
-
-static void
-SDL_AudioThreadInit_Default(_THIS)
-{ /* no-op. */
-}
-
-static void
-SDL_AudioWaitDevice_Default(_THIS)
-{ /* no-op. */
-}
-
-static void
-SDL_AudioPlayDevice_Default(_THIS)
-{ /* no-op. */
-}
-
-static Uint8 *
-SDL_AudioGetDeviceBuf_Default(_THIS)
-{
- return NULL;
-}
-
-static void
-SDL_AudioWaitDone_Default(_THIS)
-{ /* no-op. */
-}
-
-static void
-SDL_AudioCloseDevice_Default(_THIS)
-{ /* no-op. */
-}
-
-static void
-SDL_AudioDeinitialize_Default(void)
-{ /* no-op. */
-}
-
-static int
-SDL_AudioOpenDevice_Default(_THIS, const char *devname, int iscapture)
-{
- return 0;
-}
-
-static const char *
-SDL_AudioGetDeviceName_Default(int index, int iscapture)
-{
- SDL_SetError("No such device");
- return NULL;
-}
-
-static void
-SDL_AudioLockDevice_Default(SDL_AudioDevice * device)
-{
- if (device->thread && (SDL_ThreadID() == device->threadid)) {
- return;
- }
- SDL_mutexP(device->mixer_lock);
-}
-
-static void
-SDL_AudioUnlockDevice_Default(SDL_AudioDevice * device)
-{
- if (device->thread && (SDL_ThreadID() == device->threadid)) {
- return;
- }
- SDL_mutexV(device->mixer_lock);
-}
-
-
-static void
-finalize_audio_entry_points(void)
-{
- /*
- * Fill in stub functions for unused driver entry points. This lets us
- * blindly call them without having to check for validity first.
- */
-
-#define FILL_STUB(x) \
- if (current_audio.impl.x == NULL) { \
- current_audio.impl.x = SDL_Audio##x##_Default; \
- }
- FILL_STUB(DetectDevices);
- FILL_STUB(GetDeviceName);
- FILL_STUB(OpenDevice);
- FILL_STUB(ThreadInit);
- FILL_STUB(WaitDevice);
- FILL_STUB(PlayDevice);
- FILL_STUB(GetDeviceBuf);
- FILL_STUB(WaitDone);
- FILL_STUB(CloseDevice);
- FILL_STUB(LockDevice);
- FILL_STUB(UnlockDevice);
- FILL_STUB(Deinitialize);
-#undef FILL_STUB
-}
-
-/* Streaming functions (for when the input and output buffer sizes are different) */
-/* Write [length] bytes from buf into the streamer */
-static void
-SDL_StreamWrite(SDL_AudioStreamer * stream, Uint8 * buf, int length)
-{
- int i;
-
- for (i = 0; i < length; ++i) {
- stream->buffer[stream->write_pos] = buf[i];
- ++stream->write_pos;
- }
-}
-
-/* Read [length] bytes out of the streamer into buf */
-static void
-SDL_StreamRead(SDL_AudioStreamer * stream, Uint8 * buf, int length)
-{
- int i;
-
- for (i = 0; i < length; ++i) {
- buf[i] = stream->buffer[stream->read_pos];
- ++stream->read_pos;
- }
-}
-
-static int
-SDL_StreamLength(SDL_AudioStreamer * stream)
-{
- return (stream->write_pos - stream->read_pos) % stream->max_len;
-}
-
-/* Initialize the stream by allocating the buffer and setting the read/write heads to the beginning */
-#if 0
-static int
-SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence)
-{
- /* First try to allocate the buffer */
- stream->buffer = (Uint8 *) SDL_malloc(max_len);
- if (stream->buffer == NULL) {
- return -1;
- }
-
- stream->max_len = max_len;
- stream->read_pos = 0;
- stream->write_pos = 0;
-
- /* Zero out the buffer */
- SDL_memset(stream->buffer, silence, max_len);
-
- return 0;
-}
-#endif
-
-/* Deinitialize the stream simply by freeing the buffer */
-static void
-SDL_StreamDeinit(SDL_AudioStreamer * stream)
-{
- if (stream->buffer != NULL) {
- SDL_free(stream->buffer);
- }
-}
-
-/* The general mixing thread function */
-int SDLCALL
-SDL_RunAudio(void *devicep)
-{
- SDL_AudioDevice *device = (SDL_AudioDevice *) devicep;
- Uint8 *stream;
- int stream_len;
- void *udata;
- void (SDLCALL * fill) (void *userdata, Uint8 * stream, int len);
- int silence;
- Uint32 delay;
-
- /* For streaming when the buffer sizes don't match up */
- Uint8 *istream;
- int istream_len = 0;
-
- /* Perform any thread setup */
- device->threadid = SDL_ThreadID();
- current_audio.impl.ThreadInit(device);
-
- /* Set up the mixing function */
- fill = device->spec.callback;
- udata = device->spec.userdata;
-
- /* By default do not stream */
- device->use_streamer = 0;
-
- if (device->convert.needed) {
- if (device->convert.src_format == AUDIO_U8) {
- silence = 0x80;
- } else {
- silence = 0;
- }
-
-#if 0 /* !!! FIXME: I took len_div out of the structure. Use rate_incr instead? */
- /* If the result of the conversion alters the length, i.e. resampling is being used, use the streamer */
- if (device->convert.len_mult != 1 || device->convert.len_div != 1) {
- /* The streamer's maximum length should be twice whichever is larger: spec.size or len_cvt */
- stream_max_len = 2 * device->spec.size;
- if (device->convert.len_mult > device->convert.len_div) {
- stream_max_len *= device->convert.len_mult;
- stream_max_len /= device->convert.len_div;
- }
- if (SDL_StreamInit(&device->streamer, stream_max_len, silence) <
- 0)
- return -1;
- device->use_streamer = 1;
-
- /* istream_len should be the length of what we grab from the callback and feed to conversion,
- so that we get close to spec_size. I.e. we want device.spec_size = istream_len * u / d
- */
- istream_len =
- device->spec.size * device->convert.len_div /
- device->convert.len_mult;
- }
-#endif
-
- /* stream_len = device->convert.len; */
- stream_len = device->spec.size;
- } else {
- silence = device->spec.silence;
- stream_len = device->spec.size;
- }
-
- /* Calculate the delay while paused */
- delay = ((device->spec.samples * 1000) / device->spec.freq);
-
- /* Determine if the streamer is necessary here */
- if (device->use_streamer == 1) {
- /* This code is almost the same as the old code. The difference is, instead of reading
- directly from the callback into "stream", then converting and sending the audio off,
- we go: callback -> "istream" -> (conversion) -> streamer -> stream -> device.
- However, reading and writing with streamer are done separately:
- - We only call the callback and write to the streamer when the streamer does not
- contain enough samples to output to the device.
- - We only read from the streamer and tell the device to play when the streamer
- does have enough samples to output.
- This allows us to perform resampling in the conversion step, where the output of the
- resampling process can be any number. We will have to see what a good size for the
- stream's maximum length is, but I suspect 2*max(len_cvt, stream_len) is a good figure.
- */
- while (device->enabled) {
-
- if (device->paused) {
- SDL_Delay(delay);
- continue;
- }
-
- /* Only read in audio if the streamer doesn't have enough already (if it does not have enough samples to output) */
- if (SDL_StreamLength(&device->streamer) < stream_len) {
- /* Set up istream */
- if (device->convert.needed) {
- if (device->convert.buf) {
- istream = device->convert.buf;
- } else {
- continue;
- }
- } else {
-/* FIXME: Ryan, this is probably wrong. I imagine we don't want to get
- * a device buffer both here and below in the stream output.
- */
- istream = current_audio.impl.GetDeviceBuf(device);
- if (istream == NULL) {
- istream = device->fake_stream;
- }
- }
-
- /* Read from the callback into the _input_ stream */
- SDL_mutexP(device->mixer_lock);
- (*fill) (udata, istream, istream_len);
- SDL_mutexV(device->mixer_lock);
-
- /* Convert the audio if necessary and write to the streamer */
- if (device->convert.needed) {
- SDL_ConvertAudio(&device->convert);
- if (istream == NULL) {
- istream = device->fake_stream;
- }
- /*SDL_memcpy(istream, device->convert.buf, device->convert.len_cvt); */
- SDL_StreamWrite(&device->streamer, device->convert.buf,
- device->convert.len_cvt);
- } else {
- SDL_StreamWrite(&device->streamer, istream, istream_len);
- }
- }
-
- /* Only output audio if the streamer has enough to output */
- if (SDL_StreamLength(&device->streamer) >= stream_len) {
- /* Set up the output stream */
- if (device->convert.needed) {
- if (device->convert.buf) {
- stream = device->convert.buf;
- } else {
- continue;
- }
- } else {
- stream = current_audio.impl.GetDeviceBuf(device);
- if (stream == NULL) {
- stream = device->fake_stream;
- }
- }
-
- /* Now read from the streamer */
- SDL_StreamRead(&device->streamer, stream, stream_len);
-
- /* Ready current buffer for play and change current buffer */
- if (stream != device->fake_stream) {
- current_audio.impl.PlayDevice(device);
- /* Wait for an audio buffer to become available */
- current_audio.impl.WaitDevice(device);
- } else {
- SDL_Delay(delay);
- }
- }
-
- }
- } else {
- /* Otherwise, do not use the streamer. This is the old code. */
-
- /* Loop, filling the audio buffers */
- while (device->enabled) {
-
- if (device->paused) {
- SDL_Delay(delay);
- continue;
- }
-
- /* Fill the current buffer with sound */
- if (device->convert.needed) {
- if (device->convert.buf) {
- stream = device->convert.buf;
- } else {
- continue;
- }
- } else {
- stream = current_audio.impl.GetDeviceBuf(device);
- if (stream == NULL) {
- stream = device->fake_stream;
- }
- }
-
- SDL_mutexP(device->mixer_lock);
- (*fill) (udata, stream, stream_len);
- SDL_mutexV(device->mixer_lock);
-
- /* Convert the audio if necessary */
- if (device->convert.needed) {
- SDL_ConvertAudio(&device->convert);
- stream = current_audio.impl.GetDeviceBuf(device);
- if (stream == NULL) {
- stream = device->fake_stream;
- }
- SDL_memcpy(stream, device->convert.buf,
- device->convert.len_cvt);
- }
-
- /* Ready current buffer for play and change current buffer */
- if (stream != device->fake_stream) {
- current_audio.impl.PlayDevice(device);
- /* Wait for an audio buffer to become available */
- current_audio.impl.WaitDevice(device);
- } else {
- SDL_Delay(delay);
- }
- }
- }
-
- /* Wait for the audio to drain.. */
- current_audio.impl.WaitDone(device);
-
- /* If necessary, deinit the streamer */
- if (device->use_streamer == 1)
- SDL_StreamDeinit(&device->streamer);
-
- return (0);
-}
-
-
-static SDL_AudioFormat
-SDL_ParseAudioFormat(const char *string)
-{
-#define CHECK_FMT_STRING(x) if (SDL_strcmp(string, #x) == 0) return AUDIO_##x
- CHECK_FMT_STRING(U8);
- CHECK_FMT_STRING(S8);
- CHECK_FMT_STRING(U16LSB);
- CHECK_FMT_STRING(S16LSB);
- CHECK_FMT_STRING(U16MSB);
- CHECK_FMT_STRING(S16MSB);
- CHECK_FMT_STRING(U16SYS);
- CHECK_FMT_STRING(S16SYS);
- CHECK_FMT_STRING(U16);
- CHECK_FMT_STRING(S16);
- CHECK_FMT_STRING(S32LSB);
- CHECK_FMT_STRING(S32MSB);
- CHECK_FMT_STRING(S32SYS);
- CHECK_FMT_STRING(S32);
- CHECK_FMT_STRING(F32LSB);
- CHECK_FMT_STRING(F32MSB);
- CHECK_FMT_STRING(F32SYS);
- CHECK_FMT_STRING(F32);
-#undef CHECK_FMT_STRING
- return 0;
-}
-
-int
-SDL_GetNumAudioDrivers(void)
-{
- return (SDL_arraysize(bootstrap) - 1);
-}
-
-const char *
-SDL_GetAudioDriver(int index)
-{
- if (index >= 0 && index < SDL_GetNumAudioDrivers()) {
- return (bootstrap[index]->name);
- }
- return (NULL);
-}
-
-int
-SDL_AudioInit(const char *driver_name)
-{
- int i = 0;
- int initialized = 0;
- int tried_to_init = 0;
-
- if (SDL_WasInit(SDL_INIT_AUDIO)) {
- SDL_AudioQuit(); /* shutdown driver if already running. */
- }
-
- SDL_memset(&current_audio, '\0', sizeof(current_audio));
- SDL_memset(open_devices, '\0', sizeof(open_devices));
-
- /* Select the proper audio driver */
- if (driver_name == NULL) {
- driver_name = SDL_getenv("SDL_AUDIODRIVER");
- }
-
- for (i = 0; (!initialized) && (bootstrap[i]); ++i) {
- /* make sure we should even try this driver before doing so... */
- const AudioBootStrap *backend = bootstrap[i];
- if (((driver_name) && (SDL_strcasecmp(backend->name, driver_name))) ||
- ((!driver_name) && (backend->demand_only))) {
- continue;
- }
-
- tried_to_init = 1;
- SDL_memset(&current_audio, 0, sizeof(current_audio));
- current_audio.name = backend->name;
- current_audio.desc = backend->desc;
- initialized = backend->init(&current_audio.impl);
- }
-
- if (!initialized) {
- /* specific drivers will set the error message if they fail... */
- if (!tried_to_init) {
- if (driver_name) {
- SDL_SetError("Audio target '%s' not available", driver_name);
- } else {
- SDL_SetError("No available audio device");
- }
- }
-
- SDL_memset(&current_audio, 0, sizeof(current_audio));
- return (-1); /* No driver was available, so fail. */
- }
-
- finalize_audio_entry_points();
-
- return (0);
-}
-
-/*
- * Get the current audio driver name
- */
-const char *
-SDL_GetCurrentAudioDriver()
-{
- return current_audio.name;
-}
-
-
-int
-SDL_GetNumAudioDevices(int iscapture)
-{
- if (!SDL_WasInit(SDL_INIT_AUDIO)) {
- return -1;
- }
- if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) {
- return 0;
- }
-
- if ((iscapture) && (current_audio.impl.OnlyHasDefaultInputDevice)) {
- return 1;
- }
-
- if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) {
- return 1;
- }
-
- return current_audio.impl.DetectDevices(iscapture);
-}
-
-
-const char *
-SDL_GetAudioDeviceName(int index, int iscapture)
-{
- if (!SDL_WasInit(SDL_INIT_AUDIO)) {
- SDL_SetError("Audio subsystem is not initialized");
- return NULL;
- }
-
- if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) {
- SDL_SetError("No capture support");
- return NULL;
- }
-
- if (index < 0) {
- SDL_SetError("No such device");
- return NULL;
- }
-
- if ((iscapture) && (current_audio.impl.OnlyHasDefaultInputDevice)) {
- return DEFAULT_INPUT_DEVNAME;
- }
-
- if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) {
- return DEFAULT_OUTPUT_DEVNAME;
- }
-
- return current_audio.impl.GetDeviceName(index, iscapture);
-}
-
-
-static void
-close_audio_device(SDL_AudioDevice * device)
-{
- device->enabled = 0;
- if (device->thread != NULL) {
- SDL_WaitThread(device->thread, NULL);
- }
- if (device->mixer_lock != NULL) {
- SDL_DestroyMutex(device->mixer_lock);
- }
- if (device->fake_stream != NULL) {
- SDL_FreeAudioMem(device->fake_stream);
- }
- if (device->convert.needed) {
- SDL_FreeAudioMem(device->convert.buf);
- }
- if (device->opened) {
- current_audio.impl.CloseDevice(device);
- device->opened = 0;
- }
- SDL_FreeAudioMem(device);
-}
-
-
-/*
- * Sanity check desired AudioSpec for SDL_OpenAudio() in (orig).
- * Fills in a sanitized copy in (prepared).
- * Returns non-zero if okay, zero on fatal parameters in (orig).
- */
-static int
-prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared)
-{
- SDL_memcpy(prepared, orig, sizeof(SDL_AudioSpec));
-
- if (orig->callback == NULL) {
- SDL_SetError("SDL_OpenAudio() passed a NULL callback");
- return 0;
- }
-
- if (orig->freq == 0) {
- const char *env = SDL_getenv("SDL_AUDIO_FREQUENCY");
- if ((!env) || ((prepared->freq = SDL_atoi(env)) == 0)) {
- prepared->freq = 22050; /* a reasonable default */
- }
- }
-
- if (orig->format == 0) {
- const char *env = SDL_getenv("SDL_AUDIO_FORMAT");
- if ((!env) || ((prepared->format = SDL_ParseAudioFormat(env)) == 0)) {
- prepared->format = AUDIO_S16; /* a reasonable default */
- }
- }
-
- switch (orig->channels) {
- case 0:{
- const char *env = SDL_getenv("SDL_AUDIO_CHANNELS");
- if ((!env) || ((prepared->channels = (Uint8) SDL_atoi(env)) == 0)) {
- prepared->channels = 2; /* a reasonable default */
- }
- break;
- }
- case 1: /* Mono */
- case 2: /* Stereo */
- case 4: /* surround */
- case 6: /* surround with center and lfe */
- break;
- default:
- SDL_SetError("Unsupported number of audio channels.");
- return 0;
- }
-
- if (orig->samples == 0) {
- const char *env = SDL_getenv("SDL_AUDIO_SAMPLES");
- if ((!env) || ((prepared->samples = (Uint16) SDL_atoi(env)) == 0)) {
- /* Pick a default of ~46 ms at desired frequency */
- /* !!! FIXME: remove this when the non-Po2 resampling is in. */
- const int samples = (prepared->freq / 1000) * 46;
- int power2 = 1;
- while (power2 < samples) {
- power2 *= 2;
- }
- prepared->samples = power2;
- }
- }
-
- /* Calculate the silence and size of the audio specification */
- SDL_CalculateAudioSpec(prepared);
-
- return 1;
-}
-
-
-static SDL_AudioDeviceID
-open_audio_device(const char *devname, int iscapture,
- const SDL_AudioSpec * desired, SDL_AudioSpec * obtained,
- int allowed_changes, int min_id)
-{
- SDL_AudioDeviceID id = 0;
- SDL_AudioSpec _obtained;
- SDL_AudioDevice *device;
- SDL_bool build_cvt;
- int i = 0;
-
- if (!SDL_WasInit(SDL_INIT_AUDIO)) {
- SDL_SetError("Audio subsystem is not initialized");
- return 0;
- }
-
- if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) {
- SDL_SetError("No capture support");
- return 0;
- }
-
- if (!obtained) {
- obtained = &_obtained;
- }
- if (!prepare_audiospec(desired, obtained)) {
- return 0;
- }
-
- /* If app doesn't care about a specific device, let the user override. */
- if (devname == NULL) {
- devname = SDL_getenv("SDL_AUDIO_DEVICE_NAME");
- }
-
- /*
- * Catch device names at the high level for the simple case...
- * This lets us have a basic "device enumeration" for systems that
- * don't have multiple devices, but makes sure the device name is
- * always NULL when it hits the low level.
- *
- * Also make sure that the simple case prevents multiple simultaneous
- * opens of the default system device.
- */
-
- if ((iscapture) && (current_audio.impl.OnlyHasDefaultInputDevice)) {
- if ((devname) && (SDL_strcmp(devname, DEFAULT_INPUT_DEVNAME) != 0)) {
- SDL_SetError("No such device");
- return 0;
- }
- devname = NULL;
-
- for (i = 0; i < SDL_arraysize(open_devices); i++) {
- if ((open_devices[i]) && (open_devices[i]->iscapture)) {
- SDL_SetError("Audio device already open");
- return 0;
- }
- }
- }
-
- if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) {
- if ((devname) && (SDL_strcmp(devname, DEFAULT_OUTPUT_DEVNAME) != 0)) {
- SDL_SetError("No such device");
- return 0;
- }
- devname = NULL;
-
- for (i = 0; i < SDL_arraysize(open_devices); i++) {
- if ((open_devices[i]) && (!open_devices[i]->iscapture)) {
- SDL_SetError("Audio device already open");
- return 0;
- }
- }
- }
-
- device = (SDL_AudioDevice *) SDL_AllocAudioMem(sizeof(SDL_AudioDevice));
- if (device == NULL) {
- SDL_OutOfMemory();
- return 0;
- }
- SDL_memset(device, '\0', sizeof(SDL_AudioDevice));
- device->spec = *obtained;
- device->enabled = 1;
- device->paused = 1;
- device->iscapture = iscapture;
-
- /* Create a semaphore for locking the sound buffers */
- if (!current_audio.impl.SkipMixerLock) {
- device->mixer_lock = SDL_CreateMutex();
- if (device->mixer_lock == NULL) {
- close_audio_device(device);
- SDL_SetError("Couldn't create mixer lock");
- return 0;
- }
- }
-
- if (!current_audio.impl.OpenDevice(device, devname, iscapture)) {
- close_audio_device(device);
- return 0;
- }
- device->opened = 1;
-
- /* Allocate a fake audio memory buffer */
- device->fake_stream = (Uint8 *)SDL_AllocAudioMem(device->spec.size);
- if (device->fake_stream == NULL) {
- close_audio_device(device);
- SDL_OutOfMemory();
- return 0;
- }
-
- /* If the audio driver changes the buffer size, accept it */
- if (device->spec.samples != obtained->samples) {
- obtained->samples = device->spec.samples;
- SDL_CalculateAudioSpec(obtained);
- }
-
- /* See if we need to do any conversion */
- build_cvt = SDL_FALSE;
- if (obtained->freq != device->spec.freq) {
- if (allowed_changes & SDL_AUDIO_ALLOW_FREQUENCY_CHANGE) {
- obtained->freq = device->spec.freq;
- } else {
- build_cvt = SDL_TRUE;
- }
- }
- if (obtained->format != device->spec.format) {
- if (allowed_changes & SDL_AUDIO_ALLOW_FORMAT_CHANGE) {
- obtained->format = device->spec.format;
- } else {
- build_cvt = SDL_TRUE;
- }
- }
- if (obtained->channels != device->spec.channels) {
- if (allowed_changes & SDL_AUDIO_ALLOW_CHANNELS_CHANGE) {
- obtained->channels = device->spec.channels;
- } else {
- build_cvt = SDL_TRUE;
- }
- }
- if (build_cvt) {
- /* Build an audio conversion block */
- if (SDL_BuildAudioCVT(&device->convert,
- obtained->format, obtained->channels,
- obtained->freq,
- device->spec.format, device->spec.channels,
- device->spec.freq) < 0) {
- close_audio_device(device);
- return 0;
- }
- if (device->convert.needed) {
- device->convert.len = (int) (((double) obtained->size) /
- device->convert.len_ratio);
-
- device->convert.buf =
- (Uint8 *) SDL_AllocAudioMem(device->convert.len *
- device->convert.len_mult);
- if (device->convert.buf == NULL) {
- close_audio_device(device);
- SDL_OutOfMemory();
- return 0;
- }
- }
- }
-
- /* Find an available device ID and store the structure... */
- for (id = min_id - 1; id < SDL_arraysize(open_devices); id++) {
- if (open_devices[id] == NULL) {
- open_devices[id] = device;
- break;
- }
- }
-
- if (id == SDL_arraysize(open_devices)) {
- SDL_SetError("Too many open audio devices");
- close_audio_device(device);
- return 0;
- }
-
- /* Start the audio thread if necessary */
- if (!current_audio.impl.ProvidesOwnCallbackThread) {
- /* Start the audio thread */
-/* !!! FIXME: this is nasty. */
-#if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
-#undef SDL_CreateThread
- device->thread = SDL_CreateThread(SDL_RunAudio, device, NULL, NULL);
-#else
- device->thread = SDL_CreateThread(SDL_RunAudio, device);
-#endif
- if (device->thread == NULL) {
- SDL_CloseAudioDevice(id + 1);
- SDL_SetError("Couldn't create audio thread");
- return 0;
- }
- }
-
- return id + 1;
-}
-
-
-int
-SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained)
-{
- SDL_AudioDeviceID id = 0;
-
- /* Start up the audio driver, if necessary. This is legacy behaviour! */
- if (!SDL_WasInit(SDL_INIT_AUDIO)) {
- if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
- return (-1);
- }
- }
-
- /* SDL_OpenAudio() is legacy and can only act on Device ID #1. */
- if (open_devices[0] != NULL) {
- SDL_SetError("Audio device is already opened");
- return (-1);
- }
-
- if (obtained) {
- id = open_audio_device(NULL, 0, desired, obtained,
- SDL_AUDIO_ALLOW_ANY_CHANGE, 1);
- } else {
- id = open_audio_device(NULL, 0, desired, desired, 0, 1);
- }
- if (id > 1) { /* this should never happen in theory... */
- SDL_CloseAudioDevice(id);
- SDL_SetError("Internal error"); /* MUST be Device ID #1! */
- return (-1);
- }
-
- return ((id == 0) ? -1 : 0);
-}
-
-SDL_AudioDeviceID
-SDL_OpenAudioDevice(const char *device, int iscapture,
- const SDL_AudioSpec * desired, SDL_AudioSpec * obtained,
- int allowed_changes)
-{
- return open_audio_device(device, iscapture, desired, obtained,
- allowed_changes, 2);
-}
-
-SDL_AudioStatus
-SDL_GetAudioDeviceStatus(SDL_AudioDeviceID devid)
-{
- SDL_AudioDevice *device = get_audio_device(devid);
- SDL_AudioStatus status = SDL_AUDIO_STOPPED;
- if (device && device->enabled) {
- if (device->paused) {
- status = SDL_AUDIO_PAUSED;
- } else {
- status = SDL_AUDIO_PLAYING;
- }
- }
- return (status);
-}
-
-
-SDL_AudioStatus
-SDL_GetAudioStatus(void)
-{
- return SDL_GetAudioDeviceStatus(1);
-}
-
-void
-SDL_PauseAudioDevice(SDL_AudioDeviceID devid, int pause_on)
-{
- SDL_AudioDevice *device = get_audio_device(devid);
- if (device) {
- device->paused = pause_on;
- }
-}
-
-void
-SDL_PauseAudio(int pause_on)
-{
- SDL_PauseAudioDevice(1, pause_on);
-}
-
-
-void
-SDL_LockAudioDevice(SDL_AudioDeviceID devid)
-{
- /* Obtain a lock on the mixing buffers */
- SDL_AudioDevice *device = get_audio_device(devid);
- if (device) {
- current_audio.impl.LockDevice(device);
- }
-}
-
-void
-SDL_LockAudio(void)
-{
- SDL_LockAudioDevice(1);
-}
-
-void
-SDL_UnlockAudioDevice(SDL_AudioDeviceID devid)
-{
- /* Obtain a lock on the mixing buffers */
- SDL_AudioDevice *device = get_audio_device(devid);
- if (device) {
- current_audio.impl.UnlockDevice(device);
- }
-}
-
-void
-SDL_UnlockAudio(void)
-{
- SDL_UnlockAudioDevice(1);
-}
-
-void
-SDL_CloseAudioDevice(SDL_AudioDeviceID devid)
-{
- SDL_AudioDevice *device = get_audio_device(devid);
- if (device) {
- close_audio_device(device);
- open_devices[devid - 1] = NULL;
- }
-}
-
-void
-SDL_CloseAudio(void)
-{
- SDL_CloseAudioDevice(1);
-}
-
-void
-SDL_AudioQuit(void)
-{
- SDL_AudioDeviceID i;
- for (i = 0; i < SDL_arraysize(open_devices); i++) {
- SDL_CloseAudioDevice(i);
- }
-
- /* Free the driver data */
- current_audio.impl.Deinitialize();
- SDL_memset(&current_audio, '\0', sizeof(current_audio));
- SDL_memset(open_devices, '\0', sizeof(open_devices));
-}
-
-#define NUM_FORMATS 10
-static int format_idx;
-static int format_idx_sub;
-static SDL_AudioFormat format_list[NUM_FORMATS][NUM_FORMATS] = {
- {AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB,
- AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB},
- {AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB,
- AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB},
- {AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S32LSB,
- AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8},
- {AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S32MSB,
- AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8},
- {AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S32LSB,
- AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8},
- {AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_S32MSB,
- AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8},
- {AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_S16LSB,
- AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8},
- {AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_S16MSB,
- AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8},
- {AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S16LSB,
- AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8},
- {AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_S16MSB,
- AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8},
-};
-
-SDL_AudioFormat
-SDL_FirstAudioFormat(SDL_AudioFormat format)
-{
- for (format_idx = 0; format_idx < NUM_FORMATS; ++format_idx) {
- if (format_list[format_idx][0] == format) {
- break;
- }
- }
- format_idx_sub = 0;
- return (SDL_NextAudioFormat());
-}
-
-SDL_AudioFormat
-SDL_NextAudioFormat(void)
-{
- if ((format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS)) {
- return (0);
- }
- return (format_list[format_idx][format_idx_sub++]);
-}
-
-void
-SDL_CalculateAudioSpec(SDL_AudioSpec * spec)
-{
- switch (spec->format) {
- case AUDIO_U8:
- spec->silence = 0x80;
- break;
- default:
- spec->silence = 0x00;
- break;
- }
- spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8;
- spec->size *= spec->channels;
- spec->size *= spec->samples;
-}
-
-
-/*
- * Moved here from SDL_mixer.c, since it relies on internals of an opened
- * audio device (and is deprecated, by the way!).
- */
-void
-SDL_MixAudio(Uint8 * dst, const Uint8 * src, Uint32 len, int volume)
-{
- /* Mix the user-level audio format */
- SDL_AudioDevice *device = get_audio_device(1);
- if (device != NULL) {
- SDL_AudioFormat format;
- if (device->convert.needed) {
- format = device->convert.src_format;
- } else {
- format = device->spec.format;
- }
- SDL_MixAudioFormat(dst, src, format, len, volume);
- }
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/macosx/plugins/Common/SDL/src/audio/SDL_audio_c.h b/macosx/plugins/Common/SDL/src/audio/SDL_audio_c.h
deleted file mode 100644
index b85b4a5b..00000000
--- a/macosx/plugins/Common/SDL/src/audio/SDL_audio_c.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2010 Sam Lantinga
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Sam Lantinga
- slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* Functions and variables exported from SDL_audio.c for SDL_sysaudio.c */
-
-/* Functions to get a list of "close" audio formats */
-extern SDL_AudioFormat SDL_FirstAudioFormat(SDL_AudioFormat format);
-extern SDL_AudioFormat SDL_NextAudioFormat(void);
-
-/* Function to calculate the size and silence for a SDL_AudioSpec */
-extern void SDL_CalculateAudioSpec(SDL_AudioSpec * spec);
-
-/* The actual mixing thread function */
-extern int SDLCALL SDL_RunAudio(void *audiop);
-
-/* this is used internally to access some autogenerated code. */
-typedef struct
-{
- SDL_AudioFormat src_fmt;
- SDL_AudioFormat dst_fmt;
- SDL_AudioFilter filter;
-} SDL_AudioTypeFilters;
-extern const SDL_AudioTypeFilters sdl_audio_type_filters[];
-
-/* this is used internally to access some autogenerated code. */
-typedef struct
-{
- SDL_AudioFormat fmt;
- int channels;
- int upsample;
- int multiple;
- SDL_AudioFilter filter;
-} SDL_AudioRateFilters;
-extern const SDL_AudioRateFilters sdl_audio_rate_filters[];
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/macosx/plugins/Common/SDL/src/audio/SDL_audiocvt.c b/macosx/plugins/Common/SDL/src/audio/SDL_audiocvt.c
deleted file mode 100644
index e8568e1d..00000000
--- a/macosx/plugins/Common/SDL/src/audio/SDL_audiocvt.c
+++ /dev/null
@@ -1,1080 +0,0 @@
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2010 Sam Lantinga
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Sam Lantinga
- slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* Functions for audio drivers to perform runtime conversion of audio format */
-
-#include "SDL_audio.h"
-#include "SDL_audio_c.h"
-
-/* #define DEBUG_CONVERT */
-
-/* !!! FIXME */
-#ifndef assert
-#define assert(x)
-#endif
-
-/* Effectively mix right and left channels into a single channel */
-static void SDLCALL
-SDL_ConvertMono(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- Sint32 sample;
-
-#ifdef DEBUG_CONVERT
- fprintf(stderr, "Converting to mono\n");
-#endif
- switch (format & (SDL_AUDIO_MASK_SIGNED | SDL_AUDIO_MASK_BITSIZE)) {
- case AUDIO_U8:
- {
- Uint8 *src, *dst;
-
- src = cvt->buf;
- dst = cvt->buf;
- for (i = cvt->len_cvt / 2; i; --i) {
- sample = src[0] + src[1];
- *dst = (Uint8) (sample / 2);
- src += 2;
- dst += 1;
- }
- }
- break;
-
- case AUDIO_S8:
- {
- Sint8 *src, *dst;
-
- src = (Sint8 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / 2; i; --i) {
- sample = src[0] + src[1];
- *dst = (Sint8) (sample / 2);
- src += 2;
- dst += 1;
- }
- }
- break;
-
- case AUDIO_U16:
- {
- Uint8 *src, *dst;
-
- src = cvt->buf;
- dst = cvt->buf;
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 4; i; --i) {
- sample = (Uint16) ((src[0] << 8) | src[1]) +
- (Uint16) ((src[2] << 8) | src[3]);
- sample /= 2;
- dst[1] = (sample & 0xFF);
- sample >>= 8;
- dst[0] = (sample & 0xFF);
- src += 4;
- dst += 2;
- }
- } else {
- for (i = cvt->len_cvt / 4; i; --i) {
- sample = (Uint16) ((src[1] << 8) | src[0]) +
- (Uint16) ((src[3] << 8) | src[2]);
- sample /= 2;
- dst[0] = (sample & 0xFF);
- sample >>= 8;
- dst[1] = (sample & 0xFF);
- src += 4;
- dst += 2;
- }
- }
- }
- break;
-
- case AUDIO_S16:
- {
- Uint8 *src, *dst;
-
- src = cvt->buf;
- dst = cvt->buf;
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 4; i; --i) {
- sample = (Sint16) ((src[0] << 8) | src[1]) +
- (Sint16) ((src[2] << 8) | src[3]);
- sample /= 2;
- dst[1] = (sample & 0xFF);
- sample >>= 8;
- dst[0] = (sample & 0xFF);
- src += 4;
- dst += 2;
- }
- } else {
- for (i = cvt->len_cvt / 4; i; --i) {
- sample = (Sint16) ((src[1] << 8) | src[0]) +
- (Sint16) ((src[3] << 8) | src[2]);
- sample /= 2;
- dst[0] = (sample & 0xFF);
- sample >>= 8;
- dst[1] = (sample & 0xFF);
- src += 4;
- dst += 2;
- }
- }
- }
- break;
-
- case AUDIO_S32:
- {
- const Uint32 *src = (const Uint32 *) cvt->buf;
- Uint32 *dst = (Uint32 *) cvt->buf;
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 8; i; --i, src += 2) {
- const Sint64 added =
- (((Sint64) (Sint32) SDL_SwapBE32(src[0])) +
- ((Sint64) (Sint32) SDL_SwapBE32(src[1])));
- *(dst++) = SDL_SwapBE32((Uint32) ((Sint32) (added / 2)));
- }
- } else {
- for (i = cvt->len_cvt / 8; i; --i, src += 2) {
- const Sint64 added =
- (((Sint64) (Sint32) SDL_SwapLE32(src[0])) +
- ((Sint64) (Sint32) SDL_SwapLE32(src[1])));
- *(dst++) = SDL_SwapLE32((Uint32) ((Sint32) (added / 2)));
- }
- }
- }
- break;
-
- case AUDIO_F32:
- {
- const float *src = (const float *) cvt->buf;
- float *dst = (float *) cvt->buf;
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 8; i; --i, src += 2) {
- const float src1 = SDL_SwapFloatBE(src[0]);
- const float src2 = SDL_SwapFloatBE(src[1]);
- const double added = ((double) src1) + ((double) src2);
- const float halved = (float) (added * 0.5);
- *(dst++) = SDL_SwapFloatBE(halved);
- }
- } else {
- for (i = cvt->len_cvt / 8; i; --i, src += 2) {
- const float src1 = SDL_SwapFloatLE(src[0]);
- const float src2 = SDL_SwapFloatLE(src[1]);
- const double added = ((double) src1) + ((double) src2);
- const float halved = (float) (added * 0.5);
- *(dst++) = SDL_SwapFloatLE(halved);
- }
- }
- }
- break;
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-
-/* Discard top 4 channels */
-static void SDLCALL
-SDL_ConvertStrip(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
-
-#ifdef DEBUG_CONVERT
- fprintf(stderr, "Converting down from 6 channels to stereo\n");
-#endif
-
-#define strip_chans_6_to_2(type) \
- { \
- const type *src = (const type *) cvt->buf; \
- type *dst = (type *) cvt->buf; \
- for (i = cvt->len_cvt / (sizeof (type) * 6); i; --i) { \
- dst[0] = src[0]; \
- dst[1] = src[1]; \
- src += 6; \
- dst += 2; \
- } \
- }
-
- /* this function only cares about typesize, and data as a block of bits. */
- switch (SDL_AUDIO_BITSIZE(format)) {
- case 8:
- strip_chans_6_to_2(Uint8);
- break;
- case 16:
- strip_chans_6_to_2(Uint16);
- break;
- case 32:
- strip_chans_6_to_2(Uint32);
- break;
- }
-
-#undef strip_chans_6_to_2
-
- cvt->len_cvt /= 3;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-
-/* Discard top 2 channels of 6 */
-static void SDLCALL
-SDL_ConvertStrip_2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
-
-#ifdef DEBUG_CONVERT
- fprintf(stderr, "Converting 6 down to quad\n");
-#endif
-
-#define strip_chans_6_to_4(type) \
- { \
- const type *src = (const type *) cvt->buf; \
- type *dst = (type *) cvt->buf; \
- for (i = cvt->len_cvt / (sizeof (type) * 6); i; --i) { \
- dst[0] = src[0]; \
- dst[1] = src[1]; \
- dst[2] = src[2]; \
- dst[3] = src[3]; \
- src += 6; \
- dst += 4; \
- } \
- }
-
- /* this function only cares about typesize, and data as a block of bits. */
- switch (SDL_AUDIO_BITSIZE(format)) {
- case 8:
- strip_chans_6_to_4(Uint8);
- break;
- case 16:
- strip_chans_6_to_4(Uint16);
- break;
- case 32:
- strip_chans_6_to_4(Uint32);
- break;
- }
-
-#undef strip_chans_6_to_4
-
- cvt->len_cvt /= 6;
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-/* Duplicate a mono channel to both stereo channels */
-static void SDLCALL
-SDL_ConvertStereo(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
-
-#ifdef DEBUG_CONVERT
- fprintf(stderr, "Converting to stereo\n");
-#endif
-
-#define dup_chans_1_to_2(type) \
- { \
- const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
- type *dst = (type *) (cvt->buf + cvt->len_cvt * 2); \
- for (i = cvt->len_cvt / 2; i; --i, --src) { \
- const type val = *src; \
- dst -= 2; \
- dst[0] = dst[1] = val; \
- } \
- }
-
- /* this function only cares about typesize, and data as a block of bits. */
- switch (SDL_AUDIO_BITSIZE(format)) {
- case 8:
- dup_chans_1_to_2(Uint8);
- break;
- case 16:
- dup_chans_1_to_2(Uint16);
- break;
- case 32:
- dup_chans_1_to_2(Uint32);
- break;
- }
-
-#undef dup_chans_1_to_2
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-
-/* Duplicate a stereo channel to a pseudo-5.1 stream */
-static void SDLCALL
-SDL_ConvertSurround(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
-
-#ifdef DEBUG_CONVERT
- fprintf(stderr, "Converting stereo to surround\n");
-#endif
-
- switch (format & (SDL_AUDIO_MASK_SIGNED | SDL_AUDIO_MASK_BITSIZE)) {
- case AUDIO_U8:
- {
- Uint8 *src, *dst, lf, rf, ce;
-
- src = (Uint8 *) (cvt->buf + cvt->len_cvt);
- dst = (Uint8 *) (cvt->buf + cvt->len_cvt * 3);
- for (i = cvt->len_cvt; i; --i) {
- dst -= 6;
- src -= 2;
- lf = src[0];
- rf = src[1];
- ce = (lf / 2) + (rf / 2);
- dst[0] = lf;
- dst[1] = rf;
- dst[2] = lf - ce;
- dst[3] = rf - ce;
- dst[4] = ce;
- dst[5] = ce;
- }
- }
- break;
-
- case AUDIO_S8:
- {
- Sint8 *src, *dst, lf, rf, ce;
-
- src = (Sint8 *) cvt->buf + cvt->len_cvt;
- dst = (Sint8 *) cvt->buf + cvt->len_cvt * 3;
- for (i = cvt->len_cvt; i; --i) {
- dst -= 6;
- src -= 2;
- lf = src[0];
- rf = src[1];
- ce = (lf / 2) + (rf / 2);
- dst[0] = lf;
- dst[1] = rf;
- dst[2] = lf - ce;
- dst[3] = rf - ce;
- dst[4] = ce;
- dst[5] = ce;
- }
- }
- break;
-
- case AUDIO_U16:
- {
- Uint8 *src, *dst;
- Uint16 lf, rf, ce, lr, rr;
-
- src = cvt->buf + cvt->len_cvt;
- dst = cvt->buf + cvt->len_cvt * 3;
-
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 12;
- src -= 4;
- lf = (Uint16) ((src[0] << 8) | src[1]);
- rf = (Uint16) ((src[2] << 8) | src[3]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[1] = (lf & 0xFF);
- dst[0] = ((lf >> 8) & 0xFF);
- dst[3] = (rf & 0xFF);
- dst[2] = ((rf >> 8) & 0xFF);
-
- dst[1 + 4] = (lr & 0xFF);
- dst[0 + 4] = ((lr >> 8) & 0xFF);
- dst[3 + 4] = (rr & 0xFF);
- dst[2 + 4] = ((rr >> 8) & 0xFF);
-
- dst[1 + 8] = (ce & 0xFF);
- dst[0 + 8] = ((ce >> 8) & 0xFF);
- dst[3 + 8] = (ce & 0xFF);
- dst[2 + 8] = ((ce >> 8) & 0xFF);
- }
- } else {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 12;
- src -= 4;
- lf = (Uint16) ((src[1] << 8) | src[0]);
- rf = (Uint16) ((src[3] << 8) | src[2]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[0] = (lf & 0xFF);
- dst[1] = ((lf >> 8) & 0xFF);
- dst[2] = (rf & 0xFF);
- dst[3] = ((rf >> 8) & 0xFF);
-
- dst[0 + 4] = (lr & 0xFF);
- dst[1 + 4] = ((lr >> 8) & 0xFF);
- dst[2 + 4] = (rr & 0xFF);
- dst[3 + 4] = ((rr >> 8) & 0xFF);
-
- dst[0 + 8] = (ce & 0xFF);
- dst[1 + 8] = ((ce >> 8) & 0xFF);
- dst[2 + 8] = (ce & 0xFF);
- dst[3 + 8] = ((ce >> 8) & 0xFF);
- }
- }
- }
- break;
-
- case AUDIO_S16:
- {
- Uint8 *src, *dst;
- Sint16 lf, rf, ce, lr, rr;
-
- src = cvt->buf + cvt->len_cvt;
- dst = cvt->buf + cvt->len_cvt * 3;
-
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 12;
- src -= 4;
- lf = (Sint16) ((src[0] << 8) | src[1]);
- rf = (Sint16) ((src[2] << 8) | src[3]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[1] = (lf & 0xFF);
- dst[0] = ((lf >> 8) & 0xFF);
- dst[3] = (rf & 0xFF);
- dst[2] = ((rf >> 8) & 0xFF);
-
- dst[1 + 4] = (lr & 0xFF);
- dst[0 + 4] = ((lr >> 8) & 0xFF);
- dst[3 + 4] = (rr & 0xFF);
- dst[2 + 4] = ((rr >> 8) & 0xFF);
-
- dst[1 + 8] = (ce & 0xFF);
- dst[0 + 8] = ((ce >> 8) & 0xFF);
- dst[3 + 8] = (ce & 0xFF);
- dst[2 + 8] = ((ce >> 8) & 0xFF);
- }
- } else {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 12;
- src -= 4;
- lf = (Sint16) ((src[1] << 8) | src[0]);
- rf = (Sint16) ((src[3] << 8) | src[2]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[0] = (lf & 0xFF);
- dst[1] = ((lf >> 8) & 0xFF);
- dst[2] = (rf & 0xFF);
- dst[3] = ((rf >> 8) & 0xFF);
-
- dst[0 + 4] = (lr & 0xFF);
- dst[1 + 4] = ((lr >> 8) & 0xFF);
- dst[2 + 4] = (rr & 0xFF);
- dst[3 + 4] = ((rr >> 8) & 0xFF);
-
- dst[0 + 8] = (ce & 0xFF);
- dst[1 + 8] = ((ce >> 8) & 0xFF);
- dst[2 + 8] = (ce & 0xFF);
- dst[3 + 8] = ((ce >> 8) & 0xFF);
- }
- }
- }
- break;
-
- case AUDIO_S32:
- {
- Sint32 lf, rf, ce;
- const Uint32 *src = (const Uint32 *) cvt->buf + cvt->len_cvt;
- Uint32 *dst = (Uint32 *) cvt->buf + cvt->len_cvt * 3;
-
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 8; i; --i) {
- dst -= 6;
- src -= 2;
- lf = (Sint32) SDL_SwapBE32(src[0]);
- rf = (Sint32) SDL_SwapBE32(src[1]);
- ce = (lf / 2) + (rf / 2);
- dst[0] = SDL_SwapBE32((Uint32) lf);
- dst[1] = SDL_SwapBE32((Uint32) rf);
- dst[2] = SDL_SwapBE32((Uint32) (lf - ce));
- dst[3] = SDL_SwapBE32((Uint32) (rf - ce));
- dst[4] = SDL_SwapBE32((Uint32) ce);
- dst[5] = SDL_SwapBE32((Uint32) ce);
- }
- } else {
- for (i = cvt->len_cvt / 8; i; --i) {
- dst -= 6;
- src -= 2;
- lf = (Sint32) SDL_SwapLE32(src[0]);
- rf = (Sint32) SDL_SwapLE32(src[1]);
- ce = (lf / 2) + (rf / 2);
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = SDL_SwapLE32((Uint32) (lf - ce));
- dst[3] = SDL_SwapLE32((Uint32) (rf - ce));
- dst[4] = SDL_SwapLE32((Uint32) ce);
- dst[5] = SDL_SwapLE32((Uint32) ce);
- }
- }
- }
- break;
-
- case AUDIO_F32:
- {
- float lf, rf, ce;
- const float *src = (const float *) cvt->buf + cvt->len_cvt;
- float *dst = (float *) cvt->buf + cvt->len_cvt * 3;
-
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 8; i; --i) {
- dst -= 6;
- src -= 2;
- lf = SDL_SwapFloatBE(src[0]);
- rf = SDL_SwapFloatBE(src[1]);
- ce = (lf * 0.5f) + (rf * 0.5f);
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = SDL_SwapFloatBE(lf - ce);
- dst[3] = SDL_SwapFloatBE(rf - ce);
- dst[4] = dst[5] = SDL_SwapFloatBE(ce);
- }
- } else {
- for (i = cvt->len_cvt / 8; i; --i) {
- dst -= 6;
- src -= 2;
- lf = SDL_SwapFloatLE(src[0]);
- rf = SDL_SwapFloatLE(src[1]);
- ce = (lf * 0.5f) + (rf * 0.5f);
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = SDL_SwapFloatLE(lf - ce);
- dst[3] = SDL_SwapFloatLE(rf - ce);
- dst[4] = dst[5] = SDL_SwapFloatLE(ce);
- }
- }
- }
- break;
-
- }
- cvt->len_cvt *= 3;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-
-/* Duplicate a stereo channel to a pseudo-4.0 stream */
-static void SDLCALL
-SDL_ConvertSurround_4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
-
-#ifdef DEBUG_CONVERT
- fprintf(stderr, "Converting stereo to quad\n");
-#endif
-
- switch (format & (SDL_AUDIO_MASK_SIGNED | SDL_AUDIO_MASK_BITSIZE)) {
- case AUDIO_U8:
- {
- Uint8 *src, *dst, lf, rf, ce;
-
- src = (Uint8 *) (cvt->buf + cvt->len_cvt);
- dst = (Uint8 *) (cvt->buf + cvt->len_cvt * 2);
- for (i = cvt->len_cvt; i; --i) {
- dst -= 4;
- src -= 2;
- lf = src[0];
- rf = src[1];
- ce = (lf / 2) + (rf / 2);
- dst[0] = lf;
- dst[1] = rf;
- dst[2] = lf - ce;
- dst[3] = rf - ce;
- }
- }
- break;
-
- case AUDIO_S8:
- {
- Sint8 *src, *dst, lf, rf, ce;
-
- src = (Sint8 *) cvt->buf + cvt->len_cvt;
- dst = (Sint8 *) cvt->buf + cvt->len_cvt * 2;
- for (i = cvt->len_cvt; i; --i) {
- dst -= 4;
- src -= 2;
- lf = src[0];
- rf = src[1];
- ce = (lf / 2) + (rf / 2);
- dst[0] = lf;
- dst[1] = rf;
- dst[2] = lf - ce;
- dst[3] = rf - ce;
- }
- }
- break;
-
- case AUDIO_U16:
- {
- Uint8 *src, *dst;
- Uint16 lf, rf, ce, lr, rr;
-
- src = cvt->buf + cvt->len_cvt;
- dst = cvt->buf + cvt->len_cvt * 2;
-
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 8;
- src -= 4;
- lf = (Uint16) ((src[0] << 8) | src[1]);
- rf = (Uint16) ((src[2] << 8) | src[3]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[1] = (lf & 0xFF);
- dst[0] = ((lf >> 8) & 0xFF);
- dst[3] = (rf & 0xFF);
- dst[2] = ((rf >> 8) & 0xFF);
-
- dst[1 + 4] = (lr & 0xFF);
- dst[0 + 4] = ((lr >> 8) & 0xFF);
- dst[3 + 4] = (rr & 0xFF);
- dst[2 + 4] = ((rr >> 8) & 0xFF);
- }
- } else {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 8;
- src -= 4;
- lf = (Uint16) ((src[1] << 8) | src[0]);
- rf = (Uint16) ((src[3] << 8) | src[2]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[0] = (lf & 0xFF);
- dst[1] = ((lf >> 8) & 0xFF);
- dst[2] = (rf & 0xFF);
- dst[3] = ((rf >> 8) & 0xFF);
-
- dst[0 + 4] = (lr & 0xFF);
- dst[1 + 4] = ((lr >> 8) & 0xFF);
- dst[2 + 4] = (rr & 0xFF);
- dst[3 + 4] = ((rr >> 8) & 0xFF);
- }
- }
- }
- break;
-
- case AUDIO_S16:
- {
- Uint8 *src, *dst;
- Sint16 lf, rf, ce, lr, rr;
-
- src = cvt->buf + cvt->len_cvt;
- dst = cvt->buf + cvt->len_cvt * 2;
-
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 8;
- src -= 4;
- lf = (Sint16) ((src[0] << 8) | src[1]);
- rf = (Sint16) ((src[2] << 8) | src[3]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[1] = (lf & 0xFF);
- dst[0] = ((lf >> 8) & 0xFF);
- dst[3] = (rf & 0xFF);
- dst[2] = ((rf >> 8) & 0xFF);
-
- dst[1 + 4] = (lr & 0xFF);
- dst[0 + 4] = ((lr >> 8) & 0xFF);
- dst[3 + 4] = (rr & 0xFF);
- dst[2 + 4] = ((rr >> 8) & 0xFF);
- }
- } else {
- for (i = cvt->len_cvt / 4; i; --i) {
- dst -= 8;
- src -= 4;
- lf = (Sint16) ((src[1] << 8) | src[0]);
- rf = (Sint16) ((src[3] << 8) | src[2]);
- ce = (lf / 2) + (rf / 2);
- rr = lf - ce;
- lr = rf - ce;
- dst[0] = (lf & 0xFF);
- dst[1] = ((lf >> 8) & 0xFF);
- dst[2] = (rf & 0xFF);
- dst[3] = ((rf >> 8) & 0xFF);
-
- dst[0 + 4] = (lr & 0xFF);
- dst[1 + 4] = ((lr >> 8) & 0xFF);
- dst[2 + 4] = (rr & 0xFF);
- dst[3 + 4] = ((rr >> 8) & 0xFF);
- }
- }
- }
- break;
-
- case AUDIO_S32:
- {
- const Uint32 *src = (const Uint32 *) (cvt->buf + cvt->len_cvt);
- Uint32 *dst = (Uint32 *) (cvt->buf + cvt->len_cvt * 2);
- Sint32 lf, rf, ce;
-
- if (SDL_AUDIO_ISBIGENDIAN(format)) {
- for (i = cvt->len_cvt / 8; i; --i) {
- dst -= 4;
- src -= 2;
- lf = (Sint32) SDL_SwapBE32(src[0]);
- rf = (Sint32) SDL_SwapBE32(src[1]);
- ce = (lf / 2) + (rf / 2);
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = SDL_SwapBE32((Uint32) (lf - ce));
- dst[3] = SDL_SwapBE32((Uint32) (rf - ce));
- }
- } else {
- for (i = cvt->len_cvt / 8; i; --i) {
- dst -= 4;
- src -= 2;
- lf = (Sint32) SDL_SwapLE32(src[0]);
- rf = (Sint32) SDL_SwapLE32(src[1]);
- ce = (lf / 2) + (rf / 2);
- dst[0] = src[0];
- dst[1] = src[1];
- dst[2] = SDL_SwapLE32((Uint32) (lf - ce));
- dst[3] = SDL_SwapLE32((Uint32) (rf - ce));
- }
- }
- }
- break;
- }
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-
-int
-SDL_ConvertAudio(SDL_AudioCVT * cvt)
-{
- /* !!! FIXME: (cvt) should be const; stack-copy it here. */
- /* !!! FIXME: (actually, we can't...len_cvt needs to be updated. Grr.) */
-
- /* Make sure there's data to convert */
- if (cvt->buf == NULL) {
- SDL_SetError("No buffer allocated for conversion");
- return (-1);
- }
- /* Return okay if no conversion is necessary */
- cvt->len_cvt = cvt->len;
- if (cvt->filters[0] == NULL) {
- return (0);
- }
-
- /* Set up the conversion and go! */
- cvt->filter_index = 0;
- cvt->filters[0] (cvt, cvt->src_format);
- return (0);
-}
-
-
-static SDL_AudioFilter
-SDL_HandTunedTypeCVT(SDL_AudioFormat src_fmt, SDL_AudioFormat dst_fmt)
-{
- /*
- * Fill in any future conversions that are specialized to a
- * processor, platform, compiler, or library here.
- */
-
- return NULL; /* no specialized converter code available. */
-}
-
-
-/*
- * Find a converter between two data types. We try to select a hand-tuned
- * asm/vectorized/optimized function first, and then fallback to an
- * autogenerated function that is customized to convert between two
- * specific data types.
- */
-static int
-SDL_BuildAudioTypeCVT(SDL_AudioCVT * cvt,
- SDL_AudioFormat src_fmt, SDL_AudioFormat dst_fmt)
-{
- if (src_fmt != dst_fmt) {
- const Uint16 src_bitsize = SDL_AUDIO_BITSIZE(src_fmt);
- const Uint16 dst_bitsize = SDL_AUDIO_BITSIZE(dst_fmt);
- SDL_AudioFilter filter = SDL_HandTunedTypeCVT(src_fmt, dst_fmt);
-
- /* No hand-tuned converter? Try the autogenerated ones. */
- if (filter == NULL) {
- int i;
- for (i = 0; sdl_audio_type_filters[i].filter != NULL; i++) {
- const SDL_AudioTypeFilters *filt = &sdl_audio_type_filters[i];
- if ((filt->src_fmt == src_fmt) && (filt->dst_fmt == dst_fmt)) {
- filter = filt->filter;
- break;
- }
- }
-
- if (filter == NULL) {
- SDL_SetError("No conversion available for these formats");
- return -1;
- }
- }
-
- /* Update (cvt) with filter details... */
- cvt->filters[cvt->filter_index++] = filter;
- if (src_bitsize < dst_bitsize) {
- const int mult = (dst_bitsize / src_bitsize);
- cvt->len_mult *= mult;
- cvt->len_ratio *= mult;
- } else if (src_bitsize > dst_bitsize) {
- cvt->len_ratio /= (src_bitsize / dst_bitsize);
- }
-
- return 1; /* added a converter. */
- }
-
- return 0; /* no conversion necessary. */
-}
-
-
-static SDL_AudioFilter
-SDL_HandTunedResampleCVT(SDL_AudioCVT * cvt, int dst_channels,
- int src_rate, int dst_rate)
-{
- /*
- * Fill in any future conversions that are specialized to a
- * processor, platform, compiler, or library here.
- */
-
- return NULL; /* no specialized converter code available. */
-}
-
-static int
-SDL_FindFrequencyMultiple(const int src_rate, const int dst_rate)
-{
- int retval = 0;
-
- /* If we only built with the arbitrary resamplers, ignore multiples. */
-#if !LESS_RESAMPLERS
- int lo, hi;
- int div;
-
- assert(src_rate != 0);
- assert(dst_rate != 0);
- assert(src_rate != dst_rate);
-
- if (src_rate < dst_rate) {
- lo = src_rate;
- hi = dst_rate;
- } else {
- lo = dst_rate;
- hi = src_rate;
- }
-
- /* zero means "not a supported multiple" ... we only do 2x and 4x. */
- if ((hi % lo) != 0)
- return 0; /* not a multiple. */
-
- div = hi / lo;
- retval = ((div == 2) || (div == 4)) ? div : 0;
-#endif
-
- return retval;
-}
-
-static int
-SDL_BuildAudioResampleCVT(SDL_AudioCVT * cvt, int dst_channels,
- int src_rate, int dst_rate)
-{
- if (src_rate != dst_rate) {
- SDL_AudioFilter filter = SDL_HandTunedResampleCVT(cvt, dst_channels,
- src_rate, dst_rate);
-
- /* No hand-tuned converter? Try the autogenerated ones. */
- if (filter == NULL) {
- int i;
- const int upsample = (src_rate < dst_rate) ? 1 : 0;
- const int multiple =
- SDL_FindFrequencyMultiple(src_rate, dst_rate);
-
- for (i = 0; sdl_audio_rate_filters[i].filter != NULL; i++) {
- const SDL_AudioRateFilters *filt = &sdl_audio_rate_filters[i];
- if ((filt->fmt == cvt->dst_format) &&
- (filt->channels == dst_channels) &&
- (filt->upsample == upsample) &&
- (filt->multiple == multiple)) {
- filter = filt->filter;
- break;
- }
- }
-
- if (filter == NULL) {
- SDL_SetError("No conversion available for these rates");
- return -1;
- }
- }
-
- /* Update (cvt) with filter details... */
- cvt->filters[cvt->filter_index++] = filter;
- if (src_rate < dst_rate) {
- const double mult = ((double) dst_rate) / ((double) src_rate);
- cvt->len_mult *= (int) SDL_ceil(mult);
- cvt->len_ratio *= mult;
- } else {
- cvt->len_ratio /= ((double) src_rate) / ((double) dst_rate);
- }
-
- return 1; /* added a converter. */
- }
-
- return 0; /* no conversion necessary. */
-}
-
-
-/* Creates a set of audio filters to convert from one format to another.
- Returns -1 if the format conversion is not supported, 0 if there's
- no conversion needed, or 1 if the audio filter is set up.
-*/
-
-int
-SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
- SDL_AudioFormat src_fmt, Uint8 src_channels, int src_rate,
- SDL_AudioFormat dst_fmt, Uint8 dst_channels, int dst_rate)
-{
- /*
- * !!! FIXME: reorder filters based on which grow/shrink the buffer.
- * !!! FIXME: ideally, we should do everything that shrinks the buffer
- * !!! FIXME: first, so we don't have to process as many bytes in a given
- * !!! FIXME: filter and abuse the CPU cache less. This might not be as
- * !!! FIXME: good in practice as it sounds in theory, though.
- */
-
- /* there are no unsigned types over 16 bits, so catch this up front. */
- if ((SDL_AUDIO_BITSIZE(src_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(src_fmt))) {
- SDL_SetError("Invalid source format");
- return -1;
- }
- if ((SDL_AUDIO_BITSIZE(dst_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(dst_fmt))) {
- SDL_SetError("Invalid destination format");
- return -1;
- }
-
- /* prevent possible divisions by zero, etc. */
- if ((src_rate == 0) || (dst_rate == 0)) {
- SDL_SetError("Source or destination rate is zero");
- return -1;
- }
-#ifdef DEBUG_CONVERT
- printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
- src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate);
-#endif
-
- /* Start off with no conversion necessary */
- SDL_zerop(cvt);
- cvt->src_format = src_fmt;
- cvt->dst_format = dst_fmt;
- cvt->needed = 0;
- cvt->filter_index = 0;
- cvt->filters[0] = NULL;
- cvt->len_mult = 1;
- cvt->len_ratio = 1.0;
- cvt->rate_incr = ((double) dst_rate) / ((double) src_rate);
-
- /* Convert data types, if necessary. Updates (cvt). */
- if (SDL_BuildAudioTypeCVT(cvt, src_fmt, dst_fmt) == -1) {
- return -1; /* shouldn't happen, but just in case... */
- }
-
- /* Channel conversion */
- if (src_channels != dst_channels) {
- if ((src_channels == 1) && (dst_channels > 1)) {
- cvt->filters[cvt->filter_index++] = SDL_ConvertStereo;
- cvt->len_mult *= 2;
- src_channels = 2;
- cvt->len_ratio *= 2;
- }
- if ((src_channels == 2) && (dst_channels == 6)) {
- cvt->filters[cvt->filter_index++] = SDL_ConvertSurround;
- src_channels = 6;
- cvt->len_mult *= 3;
- cvt->len_ratio *= 3;
- }
- if ((src_channels == 2) && (dst_channels == 4)) {
- cvt->filters[cvt->filter_index++] = SDL_ConvertSurround_4;
- src_channels = 4;
- cvt->len_mult *= 2;
- cvt->len_ratio *= 2;
- }
- while ((src_channels * 2) <= dst_channels) {
- cvt->filters[cvt->filter_index++] = SDL_ConvertStereo;
- cvt->len_mult *= 2;
- src_channels *= 2;
- cvt->len_ratio *= 2;
- }
- if ((src_channels == 6) && (dst_channels <= 2)) {
- cvt->filters[cvt->filter_index++] = SDL_ConvertStrip;
- src_channels = 2;
- cvt->len_ratio /= 3;
- }
- if ((src_channels == 6) && (dst_channels == 4)) {
- cvt->filters[cvt->filter_index++] = SDL_ConvertStrip_2;
- src_channels = 4;
- cvt->len_ratio /= 2;
- }
- /* This assumes that 4 channel audio is in the format:
- Left {front/back} + Right {front/back}
- so converting to L/R stereo works properly.
- */
- while (((src_channels % 2) == 0) &&
- ((src_channels / 2) >= dst_channels)) {
- cvt->filters[cvt->filter_index++] = SDL_ConvertMono;
- src_channels /= 2;
- cvt->len_ratio /= 2;
- }
- if (src_channels != dst_channels) {
- /* Uh oh.. */ ;
- }
- }
-
- /* Do rate conversion, if necessary. Updates (cvt). */
- if (SDL_BuildAudioResampleCVT(cvt, dst_channels, src_rate, dst_rate) ==
- -1) {
- return -1; /* shouldn't happen, but just in case... */
- }
-
- /* Set up the filter information */
- if (cvt->filter_index != 0) {
- cvt->needed = 1;
- cvt->src_format = src_fmt;
- cvt->dst_format = dst_fmt;
- cvt->len = 0;
- cvt->buf = NULL;
- cvt->filters[cvt->filter_index] = NULL;
- }
- return (cvt->needed);
-}
-
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/macosx/plugins/Common/SDL/src/audio/SDL_audiomem.h b/macosx/plugins/Common/SDL/src/audio/SDL_audiomem.h
deleted file mode 100644
index 41eb9379..00000000
--- a/macosx/plugins/Common/SDL/src/audio/SDL_audiomem.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2010 Sam Lantinga
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Sam Lantinga
- slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#define SDL_AllocAudioMem SDL_malloc
-#define SDL_FreeAudioMem SDL_free
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/macosx/plugins/Common/SDL/src/audio/SDL_audiotypecvt.c b/macosx/plugins/Common/SDL/src/audio/SDL_audiotypecvt.c
deleted file mode 100644
index 4b2d06d9..00000000
--- a/macosx/plugins/Common/SDL/src/audio/SDL_audiotypecvt.c
+++ /dev/null
@@ -1,16216 +0,0 @@
-/* DO NOT EDIT! This file is generated by sdlgenaudiocvt.pl */
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2010 Sam Lantinga
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Sam Lantinga
- slouken@libsdl.org
-*/
-
-#include "SDL_config.h"
-#include "SDL_audio.h"
-#include "SDL_audio_c.h"
-
-#ifndef DEBUG_CONVERT
-#define DEBUG_CONVERT 0
-#endif
-
-
-/* If you can guarantee your data and need space, you can eliminate code... */
-
-/* Just build the arbitrary resamplers if you're saving code space. */
-#ifndef LESS_RESAMPLERS
-#define LESS_RESAMPLERS 1
-#endif
-
-/* Don't build any resamplers if you're REALLY saving code space. */
-#ifndef NO_RESAMPLERS
-#define NO_RESAMPLERS 0
-#endif
-
-/* Don't build any type converters if you're saving code space. */
-#ifndef NO_CONVERTERS
-#define NO_CONVERTERS 0
-#endif
-
-
-/* *INDENT-OFF* */
-
-#define DIVBY127 0.0078740157480315f
-#define DIVBY32767 3.05185094759972e-05f
-#define DIVBY2147483647 4.6566128752458e-10f
-
-#if !NO_CONVERTERS
-
-static void SDLCALL
-SDL_Convert_U8_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S8.\n");
-#endif
-
- src = (const Uint8 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, ++src, ++dst) {
- const Sint8 val = ((*src) ^ 0x80);
- *dst = ((Sint8) val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_U16LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Uint16 val = (((Uint16) *src) << 8);
- *dst = SDL_SwapLE16(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S16LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint16 val = (((Sint16) ((*src) ^ 0x80)) << 8);
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_U16MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Uint16 val = (((Uint16) *src) << 8);
- *dst = SDL_SwapBE16(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S16MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint16 val = (((Sint16) ((*src) ^ 0x80)) << 8);
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S32LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((*src) ^ 0x80)) << 24);
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S32MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((*src) ^ 0x80)) << 24);
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_F32LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const float val = ((((float) *src) * DIVBY127) - 1.0f);
- *dst = SDL_SwapFloatLE(val);
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U8_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U8 to AUDIO_F32MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const float val = ((((float) *src) * DIVBY127) - 1.0f);
- *dst = SDL_SwapFloatBE(val);
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U8.\n");
-#endif
-
- src = (const Uint8 *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, ++src, ++dst) {
- const Uint8 val = ((((Sint8) *src)) ^ 0x80);
- *dst = val;
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U16LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Uint16 val = (((Uint16) ((((Sint8) *src)) ^ 0x80)) << 8);
- *dst = SDL_SwapLE16(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S16LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint16 val = (((Sint16) ((Sint8) *src)) << 8);
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U16MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Uint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Uint16 val = (((Uint16) ((((Sint8) *src)) ^ 0x80)) << 8);
- *dst = SDL_SwapBE16(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S16MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint16 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint16 val = (((Sint16) ((Sint8) *src)) << 8);
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S32LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((Sint8) *src)) << 24);
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S32MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((Sint8) *src)) << 24);
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_F32LSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const float val = (((float) ((Sint8) *src)) * DIVBY127);
- *dst = SDL_SwapFloatLE(val);
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S8_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint8 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S8 to AUDIO_F32MSB.\n");
-#endif
-
- src = ((const Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 4)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
- const float val = (((float) ((Sint8) *src)) * DIVBY127);
- *dst = SDL_SwapFloatBE(val);
- }
-
- cvt->len_cvt *= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_U8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) (SDL_SwapLE16(*src) >> 8));
- *dst = val;
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (((SDL_SwapLE16(*src)) ^ 0x8000) >> 8));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S16LSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint16 val = ((SDL_SwapLE16(*src)) ^ 0x8000);
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_U16MSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint16 val = SDL_SwapLE16(*src);
- *dst = SDL_SwapBE16(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S16MSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint16 val = ((SDL_SwapLE16(*src)) ^ 0x8000);
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((SDL_SwapLE16(*src)) ^ 0x8000)) << 16);
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((SDL_SwapLE16(*src)) ^ 0x8000)) << 16);
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_F32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = ((((float) SDL_SwapLE16(*src)) * DIVBY32767) - 1.0f);
- *dst = SDL_SwapFloatLE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_F32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = ((((float) SDL_SwapLE16(*src)) * DIVBY32767) - 1.0f);
- *dst = SDL_SwapFloatBE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) (((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000) >> 8));
- *dst = val;
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (((Sint16) SDL_SwapLE16(*src)) >> 8));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U16LSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint16 val = ((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000);
- *dst = SDL_SwapLE16(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U16MSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint16 val = ((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000);
- *dst = SDL_SwapBE16(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S16MSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) SDL_SwapLE16(*src));
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((Sint16) SDL_SwapLE16(*src))) << 16);
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((Sint16) SDL_SwapLE16(*src))) << 16);
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_F32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = (((float) ((Sint16) SDL_SwapLE16(*src))) * DIVBY32767);
- *dst = SDL_SwapFloatLE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_F32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = (((float) ((Sint16) SDL_SwapLE16(*src))) * DIVBY32767);
- *dst = SDL_SwapFloatBE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_U8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) (SDL_SwapBE16(*src) >> 8));
- *dst = val;
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (((SDL_SwapBE16(*src)) ^ 0x8000) >> 8));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_U16LSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint16 val = SDL_SwapBE16(*src);
- *dst = SDL_SwapLE16(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S16LSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint16 val = ((SDL_SwapBE16(*src)) ^ 0x8000);
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S16MSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint16 val = ((SDL_SwapBE16(*src)) ^ 0x8000);
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((SDL_SwapBE16(*src)) ^ 0x8000)) << 16);
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((SDL_SwapBE16(*src)) ^ 0x8000)) << 16);
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_F32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = ((((float) SDL_SwapBE16(*src)) * DIVBY32767) - 1.0f);
- *dst = SDL_SwapFloatLE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_U16MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_F32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = ((((float) SDL_SwapBE16(*src)) * DIVBY32767) - 1.0f);
- *dst = SDL_SwapFloatBE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) (((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000) >> 8));
- *dst = val;
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S8.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (((Sint16) SDL_SwapBE16(*src)) >> 8));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U16LSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint16 val = ((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000);
- *dst = SDL_SwapLE16(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S16LSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) SDL_SwapBE16(*src));
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U16MSB.\n");
-#endif
-
- src = (const Uint16 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
- const Uint16 val = ((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000);
- *dst = SDL_SwapBE16(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((Sint16) SDL_SwapBE16(*src))) << 16);
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((Sint32 *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const Sint32 val = (((Sint32) ((Sint16) SDL_SwapBE16(*src))) << 16);
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_F32LSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = (((float) ((Sint16) SDL_SwapBE16(*src))) * DIVBY32767);
- *dst = SDL_SwapFloatLE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S16MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint16 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_F32MSB.\n");
-#endif
-
- src = ((const Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- dst = ((float *) (cvt->buf + cvt->len_cvt * 2)) - 1;
- for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
- const float val = (((float) ((Sint16) SDL_SwapBE16(*src))) * DIVBY32767);
- *dst = SDL_SwapFloatBE(val);
- }
-
- cvt->len_cvt *= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U8.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 24));
- *dst = val;
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S8.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (((Sint32) SDL_SwapLE32(*src)) >> 24));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U16LSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 16));
- *dst = SDL_SwapLE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S16LSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (((Sint32) SDL_SwapLE32(*src)) >> 16));
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U16MSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 16));
- *dst = SDL_SwapBE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S16MSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (((Sint32) SDL_SwapLE32(*src)) >> 16));
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S32MSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint32 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint32 val = ((Sint32) SDL_SwapLE32(*src));
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_F32LSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (float *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const float val = (((float) ((Sint32) SDL_SwapLE32(*src))) * DIVBY2147483647);
- *dst = SDL_SwapFloatLE(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_F32MSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (float *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const float val = (((float) ((Sint32) SDL_SwapLE32(*src))) * DIVBY2147483647);
- *dst = SDL_SwapFloatBE(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U8.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 24));
- *dst = val;
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S8.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (((Sint32) SDL_SwapBE32(*src)) >> 24));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U16LSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 16));
- *dst = SDL_SwapLE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S16LSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (((Sint32) SDL_SwapBE32(*src)) >> 16));
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U16MSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 16));
- *dst = SDL_SwapBE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S16MSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (((Sint32) SDL_SwapBE32(*src)) >> 16));
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S32LSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (Sint32 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const Sint32 val = ((Sint32) SDL_SwapBE32(*src));
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_F32LSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (float *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const float val = (((float) ((Sint32) SDL_SwapBE32(*src))) * DIVBY2147483647);
- *dst = SDL_SwapFloatLE(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_S32MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const Uint32 *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_F32MSB.\n");
-#endif
-
- src = (const Uint32 *) cvt->buf;
- dst = (float *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
- const float val = (((float) ((Sint32) SDL_SwapBE32(*src))) * DIVBY2147483647);
- *dst = SDL_SwapFloatBE(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U8.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) ((SDL_SwapFloatLE(*src) + 1.0f) * 127.0f));
- *dst = val;
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S8.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (SDL_SwapFloatLE(*src) * 127.0f));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U16LSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) ((SDL_SwapFloatLE(*src) + 1.0f) * 32767.0f));
- *dst = SDL_SwapLE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S16LSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (SDL_SwapFloatLE(*src) * 32767.0f));
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U16MSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) ((SDL_SwapFloatLE(*src) + 1.0f) * 32767.0f));
- *dst = SDL_SwapBE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S16MSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (SDL_SwapFloatLE(*src) * 32767.0f));
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S32LSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint32 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint32 val = ((Sint32) (SDL_SwapFloatLE(*src) * 2147483647.0));
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S32MSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint32 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint32 val = ((Sint32) (SDL_SwapFloatLE(*src) * 2147483647.0));
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_F32MSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (float *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const float val = SDL_SwapFloatLE(*src);
- *dst = SDL_SwapFloatBE(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Uint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U8.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Uint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Uint8 val = ((Uint8) ((SDL_SwapFloatBE(*src) + 1.0f) * 127.0f));
- *dst = val;
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint8 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S8.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint8 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint8 val = ((Sint8) (SDL_SwapFloatBE(*src) * 127.0f));
- *dst = ((Sint8) val);
- }
-
- cvt->len_cvt /= 4;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S8);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U16LSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) ((SDL_SwapFloatBE(*src) + 1.0f) * 32767.0f));
- *dst = SDL_SwapLE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S16LSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (SDL_SwapFloatBE(*src) * 32767.0f));
- *dst = ((Sint16) SDL_SwapLE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Uint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U16MSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Uint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Uint16 val = ((Uint16) ((SDL_SwapFloatBE(*src) + 1.0f) * 32767.0f));
- *dst = SDL_SwapBE16(val);
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_U16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint16 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S16MSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint16 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint16 val = ((Sint16) (SDL_SwapFloatBE(*src) * 32767.0f));
- *dst = ((Sint16) SDL_SwapBE16(val));
- }
-
- cvt->len_cvt /= 2;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S16MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S32LSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint32 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint32 val = ((Sint32) (SDL_SwapFloatBE(*src) * 2147483647.0));
- *dst = ((Sint32) SDL_SwapLE32(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32LSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- Sint32 *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S32MSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (Sint32 *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const Sint32 val = ((Sint32) (SDL_SwapFloatBE(*src) * 2147483647.0));
- *dst = ((Sint32) SDL_SwapBE32(val));
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_S32MSB);
- }
-}
-
-static void SDLCALL
-SDL_Convert_F32MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
- int i;
- const float *src;
- float *dst;
-
-#if DEBUG_CONVERT
- fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_F32LSB.\n");
-#endif
-
- src = (const float *) cvt->buf;
- dst = (float *) cvt->buf;
- for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
- const float val = SDL_SwapFloatBE(*src);
- *dst = SDL_SwapFloatLE(val);
- }
-
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
- }
-}
-
-#endif /* !NO_CONVERTERS */
-
-
-const SDL_AudioTypeFilters sdl_audio_type_filters[] =
-{
-#if !NO_CONVERTERS
- { AUDIO_U8, AUDIO_S8, SDL_Convert_U8_to_S8 },
- { AUDIO_U8, AUDIO_U16LSB, SDL_Convert_U8_to_U16LSB },
- { AUDIO_U8, AUDIO_S16LSB, SDL_Convert_U8_to_S16LSB },
- { AUDIO_U8, AUDIO_U16MSB, SDL_Convert_U8_to_U16MSB },
- { AUDIO_U8, AUDIO_S16MSB, SDL_Convert_U8_to_S16MSB },
- { AUDIO_U8, AUDIO_S32LSB, SDL_Convert_U8_to_S32LSB },
- { AUDIO_U8, AUDIO_S32MSB, SDL_Convert_U8_to_S32MSB },
- { AUDIO_U8, AUDIO_F32LSB, SDL_Convert_U8_to_F32LSB },
- { AUDIO_U8, AUDIO_F32MSB, SDL_Convert_U8_to_F32MSB },
- { AUDIO_S8, AUDIO_U8, SDL_Convert_S8_to_U8 },
- { AUDIO_S8, AUDIO_U16LSB, SDL_Convert_S8_to_U16LSB },
- { AUDIO_S8, AUDIO_S16LSB, SDL_Convert_S8_to_S16LSB },
- { AUDIO_S8, AUDIO_U16MSB, SDL_Convert_S8_to_U16MSB },
- { AUDIO_S8, AUDIO_S16MSB, SDL_Convert_S8_to_S16MSB },
- { AUDIO_S8, AUDIO_S32LSB, SDL_Convert_S8_to_S32LSB },
- { AUDIO_S8, AUDIO_S32MSB, SDL_Convert_S8_to_S32MSB },
- { AUDIO_S8, AUDIO_F32LSB, SDL_Convert_S8_to_F32LSB },
- { AUDIO_S8, AUDIO_F32MSB, SDL_Convert_S8_to_F32MSB },
- { AUDIO_U16LSB, AUDIO_U8, SDL_Convert_U16LSB_to_U8 },
- { AUDIO_U16LSB, AUDIO_S8, SDL_Convert_U16LSB_to_S8 },
- { AUDIO_U16LSB, AUDIO_S16LSB, SDL_Convert_U16LSB_to_S16LSB },
- { AUDIO_U16LSB, AUDIO_U16MSB, SDL_Convert_U16LSB_to_U16MSB },
- { AUDIO_U16LSB, AUDIO_S16MSB, SDL_Convert_U16LSB_to_S16MSB },
- { AUDIO_U16LSB, AUDIO_S32LSB, SDL_Convert_U16LSB_to_S32LSB },
- { AUDIO_U16LSB, AUDIO_S32MSB, SDL_Convert_U16LSB_to_S32MSB },
- { AUDIO_U16LSB, AUDIO_F32LSB, SDL_Convert_U16LSB_to_F32LSB },
- { AUDIO_U16LSB, AUDIO_F32MSB, SDL_Convert_U16LSB_to_F32MSB },
- { AUDIO_S16LSB, AUDIO_U8, SDL_Convert_S16LSB_to_U8 },
- { AUDIO_S16LSB, AUDIO_S8, SDL_Convert_S16LSB_to_S8 },
- { AUDIO_S16LSB, AUDIO_U16LSB, SDL_Convert_S16LSB_to_U16LSB },
- { AUDIO_S16LSB, AUDIO_U16MSB, SDL_Convert_S16LSB_to_U16MSB },
- { AUDIO_S16LSB, AUDIO_S16MSB, SDL_Convert_S16LSB_to_S16MSB },
- { AUDIO_S16LSB, AUDIO_S32LSB, SDL_Convert_S16LSB_to_S32LSB },
- { AUDIO_S16LSB, AUDIO_S32MSB, SDL_Convert_S16LSB_to_S32MSB },
- { AUDIO_S16LSB, AUDIO_F32LSB, SDL_Convert_S16LSB_to_F32LSB },
- { AUDIO_S16LSB, AUDIO_F32MSB, SDL_Convert_S16LSB_to_F32MSB },
- { AUDIO_U16MSB, AUDIO_U8, SDL_Convert_U16MSB_to_U8 },
- { AUDIO_U16MSB, AUDIO_S8, SDL_Convert_U16MSB_to_S8 },
- { AUDIO_U16MSB, AUDIO_U16LSB, SDL_Convert_U16MSB_to_U16LSB },
- { AUDIO_U16MSB, AUDIO_S16LSB, SDL_Convert_U16MSB_to_S16LSB },
- { AUDIO_U16MSB, AUDIO_S16MSB, SDL_Convert_U16MSB_to_S16MSB },
- { AUDIO_U16MSB, AUDIO_S32LSB, SDL_Convert_U16MSB_to_S32LSB },
- { AUDIO_U16MSB, AUDIO_S32MSB, SDL_Convert_U16MSB_to_S32MSB },
- { AUDIO_U16MSB, AUDIO_F32LSB, SDL_Convert_U16MSB_to_F32LSB },
- { AUDIO_U16MSB, AUDIO_F32MSB, SDL_Convert_U16MSB_to_F32MSB },
- { AUDIO_S16MSB, AUDIO_U8, SDL_Convert_S16MSB_to_U8 },
- { AUDIO_S16MSB, AUDIO_S8, SDL_Convert_S16MSB_to_S8 },
- { AUDIO_S16MSB, AUDIO_U16LSB, SDL_Convert_S16MSB_to_U16LSB },
- { AUDIO_S16MSB, AUDIO_S16LSB, SDL_Convert_S16MSB_to_S16LSB },
- { AUDIO_S16MSB, AUDIO_U16MSB, SDL_Convert_S16MSB_to_U16MSB },
- { AUDIO_S16MSB, AUDIO_S32LSB, SDL_Convert_S16MSB_to_S32LSB },
- { AUDIO_S16MSB, AUDIO_S32MSB, SDL_Convert_S16MSB_to_S32MSB },
- { AUDIO_S16MSB, AUDIO_F32LSB, SDL_Convert_S16MSB_to_F32LSB },
- { AUDIO_S16MSB, AUDIO_F32MSB, SDL_Convert_S16MSB_to_F32MSB },
- { AUDIO_S32LSB, AUDIO_U8, SDL_Convert_S32LSB_to_U8 },
- { AUDIO_S32LSB, AUDIO_S8, SDL_Convert_S32LSB_to_S8 },
- { AUDIO_S32LSB, AUDIO_U16LSB, SDL_Convert_S32LSB_to_U16LSB },
- { AUDIO_S32LSB, AUDIO_S16LSB, SDL_Convert_S32LSB_to_S16LSB },
- { AUDIO_S32LSB, AUDIO_U16MSB, SDL_Convert_S32LSB_to_U16MSB },
- { AUDIO_S32LSB, AUDIO_S16MSB, SDL_Convert_S32LSB_to_S16MSB },
- { AUDIO_S32LSB, AUDIO_S32MSB, SDL_Convert_S32LSB_to_S32MSB },
- { AUDIO_S32LSB, AUDIO_F32LSB, SDL_Convert_S32LSB_to_F32LSB },
- { AUDIO_S32LSB, AUDIO_F32MSB, SDL_Convert_S32LSB_to_F32MSB },
- { AUDIO_S32MSB, AUDIO_U8, SDL_Convert_S32MSB_to_U8 },
- { AUDIO_S32MSB, AUDIO_S8, SDL_Convert_S32MSB_to_S8 },
- { AUDIO_S32MSB, AUDIO_U16LSB, SDL_Convert_S32MSB_to_U16LSB },
- { AUDIO_S32MSB, AUDIO_S16LSB, SDL_Convert_S32MSB_to_S16LSB },
- { AUDIO_S32MSB, AUDIO_U16MSB, SDL_Convert_S32MSB_to_U16MSB },
- { AUDIO_S32MSB, AUDIO_S16MSB, SDL_Convert_S32MSB_to_S16MSB },
- { AUDIO_S32MSB, AUDIO_S32LSB, SDL_Convert_S32MSB_to_S32LSB },
- { AUDIO_S32MSB, AUDIO_F32LSB, SDL_Convert_S32MSB_to_F32LSB },
- { AUDIO_S32MSB, AUDIO_F32MSB, SDL_Convert_S32MSB_to_F32MSB },
- { AUDIO_F32LSB, AUDIO_U8, SDL_Convert_F32LSB_to_U8 },
- { AUDIO_F32LSB, AUDIO_S8, SDL_Convert_F32LSB_to_S8 },
- { AUDIO_F32LSB, AUDIO_U16LSB, SDL_Convert_F32LSB_to_U16LSB },
- { AUDIO_F32LSB, AUDIO_S16LSB, SDL_Convert_F32LSB_to_S16LSB },
- { AUDIO_F32LSB, AUDIO_U16MSB, SDL_Convert_F32LSB_to_U16MSB },
- { AUDIO_F32LSB, AUDIO_S16MSB, SDL_Convert_F32LSB_to_S16MSB },
- { AUDIO_F32LSB, AUDIO_S32LSB, SDL_Convert_F32LSB_to_S32LSB },
- { AUDIO_F32LSB, AUDIO_S32MSB, SDL_Convert_F32LSB_to_S32MSB },
- { AUDIO_F32LSB, AUDIO_F32MSB, SDL_Convert_F32LSB_to_F32MSB },
- { AUDIO_F32MSB, AUDIO_U8, SDL_Convert_F32MSB_to_U8 },
- { AUDIO_F32MSB, AUDIO_S8, SDL_Convert_F32MSB_to_S8 },
- { AUDIO_F32MSB, AUDIO_U16LSB, SDL_Convert_F32MSB_to_U16LSB },
- { AUDIO_F32MSB, AUDIO_S16LSB, SDL_Convert_F32MSB_to_S16LSB },
- { AUDIO_F32MSB, AUDIO_U16MSB, SDL_Convert_F32MSB_to_U16MSB },
- { AUDIO_F32MSB, AUDIO_S16MSB, SDL_Convert_F32MSB_to_S16MSB },
- { AUDIO_F32MSB, AUDIO_S32LSB, SDL_Convert_F32MSB_to_S32LSB },
- { AUDIO_F32MSB, AUDIO_S32MSB, SDL_Convert_F32MSB_to_S32MSB },
- { AUDIO_F32MSB, AUDIO_F32LSB, SDL_Convert_F32MSB_to_F32LSB },
-#endif /* !NO_CONVERTERS */
- { 0, 0, NULL }
-};
-
-
-#if !NO_RESAMPLERS
-
-static void SDLCALL
-SDL_Upsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 16;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint8 *target = ((const Uint8 *) cvt->buf) - 1;
- Uint8 sample0 = src[0];
- Uint8 last_sample0 = sample0;
- while (dst > target) {
- dst[0] = sample0;
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 16;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Uint8 sample0 = src[0];
- Uint8 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = sample0;
- dst++;
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint8 *target = ((const Uint8 *) cvt->buf) - 2;
- Uint8 sample1 = src[1];
- Uint8 sample0 = src[0];
- Uint8 last_sample1 = sample1;
- Uint8 last_sample0 = sample0;
- while (dst > target) {
- dst[1] = sample1;
- dst[0] = sample0;
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Uint8 sample0 = src[0];
- Uint8 sample1 = src[1];
- Uint8 last_sample0 = sample0;
- Uint8 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = sample0;
- dst[1] = sample1;
- dst += 2;
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint8 *target = ((const Uint8 *) cvt->buf) - 4;
- Uint8 sample3 = src[3];
- Uint8 sample2 = src[2];
- Uint8 sample1 = src[1];
- Uint8 sample0 = src[0];
- Uint8 last_sample3 = sample3;
- Uint8 last_sample2 = sample2;
- Uint8 last_sample1 = sample1;
- Uint8 last_sample0 = sample0;
- while (dst > target) {
- dst[3] = sample3;
- dst[2] = sample2;
- dst[1] = sample1;
- dst[0] = sample0;
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
- sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Uint8 sample0 = src[0];
- Uint8 sample1 = src[1];
- Uint8 sample2 = src[2];
- Uint8 sample3 = src[3];
- Uint8 last_sample0 = sample0;
- Uint8 last_sample1 = sample1;
- Uint8 last_sample2 = sample2;
- Uint8 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = sample0;
- dst[1] = sample1;
- dst[2] = sample2;
- dst[3] = sample3;
- dst += 4;
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
- sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 96;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint8 *target = ((const Uint8 *) cvt->buf) - 6;
- Uint8 sample5 = src[5];
- Uint8 sample4 = src[4];
- Uint8 sample3 = src[3];
- Uint8 sample2 = src[2];
- Uint8 sample1 = src[1];
- Uint8 sample0 = src[0];
- Uint8 last_sample5 = sample5;
- Uint8 last_sample4 = sample4;
- Uint8 last_sample3 = sample3;
- Uint8 last_sample2 = sample2;
- Uint8 last_sample1 = sample1;
- Uint8 last_sample0 = sample0;
- while (dst > target) {
- dst[5] = sample5;
- dst[4] = sample4;
- dst[3] = sample3;
- dst[2] = sample2;
- dst[1] = sample1;
- dst[0] = sample0;
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
- sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
- sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
- sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 96;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Uint8 sample0 = src[0];
- Uint8 sample1 = src[1];
- Uint8 sample2 = src[2];
- Uint8 sample3 = src[3];
- Uint8 sample4 = src[4];
- Uint8 sample5 = src[5];
- Uint8 last_sample0 = sample0;
- Uint8 last_sample1 = sample1;
- Uint8 last_sample2 = sample2;
- Uint8 last_sample3 = sample3;
- Uint8 last_sample4 = sample4;
- Uint8 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = sample0;
- dst[1] = sample1;
- dst[2] = sample2;
- dst[3] = sample3;
- dst[4] = sample4;
- dst[5] = sample5;
- dst += 6;
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
- sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
- sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
- sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint8 *target = ((const Uint8 *) cvt->buf) - 8;
- Uint8 sample7 = src[7];
- Uint8 sample6 = src[6];
- Uint8 sample5 = src[5];
- Uint8 sample4 = src[4];
- Uint8 sample3 = src[3];
- Uint8 sample2 = src[2];
- Uint8 sample1 = src[1];
- Uint8 sample0 = src[0];
- Uint8 last_sample7 = sample7;
- Uint8 last_sample6 = sample6;
- Uint8 last_sample5 = sample5;
- Uint8 last_sample4 = sample4;
- Uint8 last_sample3 = sample3;
- Uint8 last_sample2 = sample2;
- Uint8 last_sample1 = sample1;
- Uint8 last_sample0 = sample0;
- while (dst > target) {
- dst[7] = sample7;
- dst[6] = sample6;
- dst[5] = sample5;
- dst[4] = sample4;
- dst[3] = sample3;
- dst[2] = sample2;
- dst[1] = sample1;
- dst[0] = sample0;
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Uint8) ((((Sint16) src[7]) + ((Sint16) last_sample7)) >> 1);
- sample6 = (Uint8) ((((Sint16) src[6]) + ((Sint16) last_sample6)) >> 1);
- sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
- sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
- sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
- sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Uint8 sample0 = src[0];
- Uint8 sample1 = src[1];
- Uint8 sample2 = src[2];
- Uint8 sample3 = src[3];
- Uint8 sample4 = src[4];
- Uint8 sample5 = src[5];
- Uint8 sample6 = src[6];
- Uint8 sample7 = src[7];
- Uint8 last_sample0 = sample0;
- Uint8 last_sample1 = sample1;
- Uint8 last_sample2 = sample2;
- Uint8 last_sample3 = sample3;
- Uint8 last_sample4 = sample4;
- Uint8 last_sample5 = sample5;
- Uint8 last_sample6 = sample6;
- Uint8 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = sample0;
- dst[1] = sample1;
- dst[2] = sample2;
- dst[3] = sample3;
- dst[4] = sample4;
- dst[5] = sample5;
- dst[6] = sample6;
- dst[7] = sample7;
- dst += 8;
- sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
- sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
- sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
- sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
- sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
- sample6 = (Uint8) ((((Sint16) src[6]) + ((Sint16) last_sample6)) >> 1);
- sample7 = (Uint8) ((((Sint16) src[7]) + ((Sint16) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 16;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint8 *target = ((const Sint8 *) cvt->buf) - 1;
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 last_sample0 = sample0;
- while (dst > target) {
- dst[0] = ((Sint8) sample0);
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 16;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint8) sample0);
- dst++;
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint8 *target = ((const Sint8 *) cvt->buf) - 2;
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 last_sample1 = sample1;
- Sint8 last_sample0 = sample0;
- while (dst > target) {
- dst[1] = ((Sint8) sample1);
- dst[0] = ((Sint8) sample0);
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 last_sample0 = sample0;
- Sint8 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint8) sample0);
- dst[1] = ((Sint8) sample1);
- dst += 2;
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint8 *target = ((const Sint8 *) cvt->buf) - 4;
- Sint8 sample3 = ((Sint8) src[3]);
- Sint8 sample2 = ((Sint8) src[2]);
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 last_sample3 = sample3;
- Sint8 last_sample2 = sample2;
- Sint8 last_sample1 = sample1;
- Sint8 last_sample0 = sample0;
- while (dst > target) {
- dst[3] = ((Sint8) sample3);
- dst[2] = ((Sint8) sample2);
- dst[1] = ((Sint8) sample1);
- dst[0] = ((Sint8) sample0);
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
- sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 sample2 = ((Sint8) src[2]);
- Sint8 sample3 = ((Sint8) src[3]);
- Sint8 last_sample0 = sample0;
- Sint8 last_sample1 = sample1;
- Sint8 last_sample2 = sample2;
- Sint8 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint8) sample0);
- dst[1] = ((Sint8) sample1);
- dst[2] = ((Sint8) sample2);
- dst[3] = ((Sint8) sample3);
- dst += 4;
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
- sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 96;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint8 *target = ((const Sint8 *) cvt->buf) - 6;
- Sint8 sample5 = ((Sint8) src[5]);
- Sint8 sample4 = ((Sint8) src[4]);
- Sint8 sample3 = ((Sint8) src[3]);
- Sint8 sample2 = ((Sint8) src[2]);
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 last_sample5 = sample5;
- Sint8 last_sample4 = sample4;
- Sint8 last_sample3 = sample3;
- Sint8 last_sample2 = sample2;
- Sint8 last_sample1 = sample1;
- Sint8 last_sample0 = sample0;
- while (dst > target) {
- dst[5] = ((Sint8) sample5);
- dst[4] = ((Sint8) sample4);
- dst[3] = ((Sint8) sample3);
- dst[2] = ((Sint8) sample2);
- dst[1] = ((Sint8) sample1);
- dst[0] = ((Sint8) sample0);
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
- sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
- sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
- sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 96;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 sample2 = ((Sint8) src[2]);
- Sint8 sample3 = ((Sint8) src[3]);
- Sint8 sample4 = ((Sint8) src[4]);
- Sint8 sample5 = ((Sint8) src[5]);
- Sint8 last_sample0 = sample0;
- Sint8 last_sample1 = sample1;
- Sint8 last_sample2 = sample2;
- Sint8 last_sample3 = sample3;
- Sint8 last_sample4 = sample4;
- Sint8 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint8) sample0);
- dst[1] = ((Sint8) sample1);
- dst[2] = ((Sint8) sample2);
- dst[3] = ((Sint8) sample3);
- dst[4] = ((Sint8) sample4);
- dst[5] = ((Sint8) sample5);
- dst += 6;
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
- sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
- sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
- sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint8 *target = ((const Sint8 *) cvt->buf) - 8;
- Sint8 sample7 = ((Sint8) src[7]);
- Sint8 sample6 = ((Sint8) src[6]);
- Sint8 sample5 = ((Sint8) src[5]);
- Sint8 sample4 = ((Sint8) src[4]);
- Sint8 sample3 = ((Sint8) src[3]);
- Sint8 sample2 = ((Sint8) src[2]);
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 last_sample7 = sample7;
- Sint8 last_sample6 = sample6;
- Sint8 last_sample5 = sample5;
- Sint8 last_sample4 = sample4;
- Sint8 last_sample3 = sample3;
- Sint8 last_sample2 = sample2;
- Sint8 last_sample1 = sample1;
- Sint8 last_sample0 = sample0;
- while (dst > target) {
- dst[7] = ((Sint8) sample7);
- dst[6] = ((Sint8) sample6);
- dst[5] = ((Sint8) sample5);
- dst[4] = ((Sint8) sample4);
- dst[3] = ((Sint8) sample3);
- dst[2] = ((Sint8) sample2);
- dst[1] = ((Sint8) sample1);
- dst[0] = ((Sint8) sample0);
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Sint8) ((((Sint16) ((Sint8) src[7])) + ((Sint16) last_sample7)) >> 1);
- sample6 = (Sint8) ((((Sint16) ((Sint8) src[6])) + ((Sint16) last_sample6)) >> 1);
- sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
- sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
- sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
- sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint8 sample0 = ((Sint8) src[0]);
- Sint8 sample1 = ((Sint8) src[1]);
- Sint8 sample2 = ((Sint8) src[2]);
- Sint8 sample3 = ((Sint8) src[3]);
- Sint8 sample4 = ((Sint8) src[4]);
- Sint8 sample5 = ((Sint8) src[5]);
- Sint8 sample6 = ((Sint8) src[6]);
- Sint8 sample7 = ((Sint8) src[7]);
- Sint8 last_sample0 = sample0;
- Sint8 last_sample1 = sample1;
- Sint8 last_sample2 = sample2;
- Sint8 last_sample3 = sample3;
- Sint8 last_sample4 = sample4;
- Sint8 last_sample5 = sample5;
- Sint8 last_sample6 = sample6;
- Sint8 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint8) sample0);
- dst[1] = ((Sint8) sample1);
- dst[2] = ((Sint8) sample2);
- dst[3] = ((Sint8) sample3);
- dst[4] = ((Sint8) sample4);
- dst[5] = ((Sint8) sample5);
- dst[6] = ((Sint8) sample6);
- dst[7] = ((Sint8) sample7);
- dst += 8;
- sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
- sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
- sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
- sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
- sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
- sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
- sample6 = (Sint8) ((((Sint16) ((Sint8) src[6])) + ((Sint16) last_sample6)) >> 1);
- sample7 = (Sint8) ((((Sint16) ((Sint8) src[7])) + ((Sint16) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 last_sample0 = sample0;
- while (dst > target) {
- dst[0] = SDL_SwapLE16(sample0);
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapLE16(sample0);
- dst++;
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 2;
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst > target) {
- dst[1] = SDL_SwapLE16(sample1);
- dst[0] = SDL_SwapLE16(sample0);
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapLE16(sample0);
- dst[1] = SDL_SwapLE16(sample1);
- dst += 2;
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 4;
- Uint16 sample3 = SDL_SwapLE16(src[3]);
- Uint16 sample2 = SDL_SwapLE16(src[2]);
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 last_sample3 = sample3;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst > target) {
- dst[3] = SDL_SwapLE16(sample3);
- dst[2] = SDL_SwapLE16(sample2);
- dst[1] = SDL_SwapLE16(sample1);
- dst[0] = SDL_SwapLE16(sample0);
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 sample2 = SDL_SwapLE16(src[2]);
- Uint16 sample3 = SDL_SwapLE16(src[3]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapLE16(sample0);
- dst[1] = SDL_SwapLE16(sample1);
- dst[2] = SDL_SwapLE16(sample2);
- dst[3] = SDL_SwapLE16(sample3);
- dst += 4;
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 6;
- Uint16 sample5 = SDL_SwapLE16(src[5]);
- Uint16 sample4 = SDL_SwapLE16(src[4]);
- Uint16 sample3 = SDL_SwapLE16(src[3]);
- Uint16 sample2 = SDL_SwapLE16(src[2]);
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 last_sample5 = sample5;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst > target) {
- dst[5] = SDL_SwapLE16(sample5);
- dst[4] = SDL_SwapLE16(sample4);
- dst[3] = SDL_SwapLE16(sample3);
- dst[2] = SDL_SwapLE16(sample2);
- dst[1] = SDL_SwapLE16(sample1);
- dst[0] = SDL_SwapLE16(sample0);
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 sample2 = SDL_SwapLE16(src[2]);
- Uint16 sample3 = SDL_SwapLE16(src[3]);
- Uint16 sample4 = SDL_SwapLE16(src[4]);
- Uint16 sample5 = SDL_SwapLE16(src[5]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapLE16(sample0);
- dst[1] = SDL_SwapLE16(sample1);
- dst[2] = SDL_SwapLE16(sample2);
- dst[3] = SDL_SwapLE16(sample3);
- dst[4] = SDL_SwapLE16(sample4);
- dst[5] = SDL_SwapLE16(sample5);
- dst += 6;
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 8;
- Uint16 sample7 = SDL_SwapLE16(src[7]);
- Uint16 sample6 = SDL_SwapLE16(src[6]);
- Uint16 sample5 = SDL_SwapLE16(src[5]);
- Uint16 sample4 = SDL_SwapLE16(src[4]);
- Uint16 sample3 = SDL_SwapLE16(src[3]);
- Uint16 sample2 = SDL_SwapLE16(src[2]);
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 last_sample7 = sample7;
- Uint16 last_sample6 = sample6;
- Uint16 last_sample5 = sample5;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst > target) {
- dst[7] = SDL_SwapLE16(sample7);
- dst[6] = SDL_SwapLE16(sample6);
- dst[5] = SDL_SwapLE16(sample5);
- dst[4] = SDL_SwapLE16(sample4);
- dst[3] = SDL_SwapLE16(sample3);
- dst[2] = SDL_SwapLE16(sample2);
- dst[1] = SDL_SwapLE16(sample1);
- dst[0] = SDL_SwapLE16(sample0);
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Uint16) ((((Sint32) SDL_SwapLE16(src[7])) + ((Sint32) last_sample7)) >> 1);
- sample6 = (Uint16) ((((Sint32) SDL_SwapLE16(src[6])) + ((Sint32) last_sample6)) >> 1);
- sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapLE16(src[0]);
- Uint16 sample1 = SDL_SwapLE16(src[1]);
- Uint16 sample2 = SDL_SwapLE16(src[2]);
- Uint16 sample3 = SDL_SwapLE16(src[3]);
- Uint16 sample4 = SDL_SwapLE16(src[4]);
- Uint16 sample5 = SDL_SwapLE16(src[5]);
- Uint16 sample6 = SDL_SwapLE16(src[6]);
- Uint16 sample7 = SDL_SwapLE16(src[7]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample5 = sample5;
- Uint16 last_sample6 = sample6;
- Uint16 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapLE16(sample0);
- dst[1] = SDL_SwapLE16(sample1);
- dst[2] = SDL_SwapLE16(sample2);
- dst[3] = SDL_SwapLE16(sample3);
- dst[4] = SDL_SwapLE16(sample4);
- dst[5] = SDL_SwapLE16(sample5);
- dst[6] = SDL_SwapLE16(sample6);
- dst[7] = SDL_SwapLE16(sample7);
- dst += 8;
- sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- sample6 = (Uint16) ((((Sint32) SDL_SwapLE16(src[6])) + ((Sint32) last_sample6)) >> 1);
- sample7 = (Uint16) ((((Sint32) SDL_SwapLE16(src[7])) + ((Sint32) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 last_sample0 = sample0;
- while (dst > target) {
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst++;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst > target) {
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst += 2;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 4;
- Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
- Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 last_sample3 = sample3;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst > target) {
- dst[3] = ((Sint16) SDL_SwapLE16(sample3));
- dst[2] = ((Sint16) SDL_SwapLE16(sample2));
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
- Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst[2] = ((Sint16) SDL_SwapLE16(sample2));
- dst[3] = ((Sint16) SDL_SwapLE16(sample3));
- dst += 4;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 6;
- Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
- Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
- Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
- Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 last_sample5 = sample5;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst > target) {
- dst[5] = ((Sint16) SDL_SwapLE16(sample5));
- dst[4] = ((Sint16) SDL_SwapLE16(sample4));
- dst[3] = ((Sint16) SDL_SwapLE16(sample3));
- dst[2] = ((Sint16) SDL_SwapLE16(sample2));
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
- Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
- Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
- Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst[2] = ((Sint16) SDL_SwapLE16(sample2));
- dst[3] = ((Sint16) SDL_SwapLE16(sample3));
- dst[4] = ((Sint16) SDL_SwapLE16(sample4));
- dst[5] = ((Sint16) SDL_SwapLE16(sample5));
- dst += 6;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 8;
- Sint16 sample7 = ((Sint16) SDL_SwapLE16(src[7]));
- Sint16 sample6 = ((Sint16) SDL_SwapLE16(src[6]));
- Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
- Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
- Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
- Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 last_sample7 = sample7;
- Sint16 last_sample6 = sample6;
- Sint16 last_sample5 = sample5;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst > target) {
- dst[7] = ((Sint16) SDL_SwapLE16(sample7));
- dst[6] = ((Sint16) SDL_SwapLE16(sample6));
- dst[5] = ((Sint16) SDL_SwapLE16(sample5));
- dst[4] = ((Sint16) SDL_SwapLE16(sample4));
- dst[3] = ((Sint16) SDL_SwapLE16(sample3));
- dst[2] = ((Sint16) SDL_SwapLE16(sample2));
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
- sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
- Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
- Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
- Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
- Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
- Sint16 sample6 = ((Sint16) SDL_SwapLE16(src[6]));
- Sint16 sample7 = ((Sint16) SDL_SwapLE16(src[7]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample5 = sample5;
- Sint16 last_sample6 = sample6;
- Sint16 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapLE16(sample0));
- dst[1] = ((Sint16) SDL_SwapLE16(sample1));
- dst[2] = ((Sint16) SDL_SwapLE16(sample2));
- dst[3] = ((Sint16) SDL_SwapLE16(sample3));
- dst[4] = ((Sint16) SDL_SwapLE16(sample4));
- dst[5] = ((Sint16) SDL_SwapLE16(sample5));
- dst[6] = ((Sint16) SDL_SwapLE16(sample6));
- dst[7] = ((Sint16) SDL_SwapLE16(sample7));
- dst += 8;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
- sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 last_sample0 = sample0;
- while (dst > target) {
- dst[0] = SDL_SwapBE16(sample0);
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapBE16(sample0);
- dst++;
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 2;
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst > target) {
- dst[1] = SDL_SwapBE16(sample1);
- dst[0] = SDL_SwapBE16(sample0);
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapBE16(sample0);
- dst[1] = SDL_SwapBE16(sample1);
- dst += 2;
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 4;
- Uint16 sample3 = SDL_SwapBE16(src[3]);
- Uint16 sample2 = SDL_SwapBE16(src[2]);
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 last_sample3 = sample3;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst > target) {
- dst[3] = SDL_SwapBE16(sample3);
- dst[2] = SDL_SwapBE16(sample2);
- dst[1] = SDL_SwapBE16(sample1);
- dst[0] = SDL_SwapBE16(sample0);
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 sample2 = SDL_SwapBE16(src[2]);
- Uint16 sample3 = SDL_SwapBE16(src[3]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapBE16(sample0);
- dst[1] = SDL_SwapBE16(sample1);
- dst[2] = SDL_SwapBE16(sample2);
- dst[3] = SDL_SwapBE16(sample3);
- dst += 4;
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 6;
- Uint16 sample5 = SDL_SwapBE16(src[5]);
- Uint16 sample4 = SDL_SwapBE16(src[4]);
- Uint16 sample3 = SDL_SwapBE16(src[3]);
- Uint16 sample2 = SDL_SwapBE16(src[2]);
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 last_sample5 = sample5;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst > target) {
- dst[5] = SDL_SwapBE16(sample5);
- dst[4] = SDL_SwapBE16(sample4);
- dst[3] = SDL_SwapBE16(sample3);
- dst[2] = SDL_SwapBE16(sample2);
- dst[1] = SDL_SwapBE16(sample1);
- dst[0] = SDL_SwapBE16(sample0);
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 sample2 = SDL_SwapBE16(src[2]);
- Uint16 sample3 = SDL_SwapBE16(src[3]);
- Uint16 sample4 = SDL_SwapBE16(src[4]);
- Uint16 sample5 = SDL_SwapBE16(src[5]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapBE16(sample0);
- dst[1] = SDL_SwapBE16(sample1);
- dst[2] = SDL_SwapBE16(sample2);
- dst[3] = SDL_SwapBE16(sample3);
- dst[4] = SDL_SwapBE16(sample4);
- dst[5] = SDL_SwapBE16(sample5);
- dst += 6;
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 8;
- Uint16 sample7 = SDL_SwapBE16(src[7]);
- Uint16 sample6 = SDL_SwapBE16(src[6]);
- Uint16 sample5 = SDL_SwapBE16(src[5]);
- Uint16 sample4 = SDL_SwapBE16(src[4]);
- Uint16 sample3 = SDL_SwapBE16(src[3]);
- Uint16 sample2 = SDL_SwapBE16(src[2]);
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 last_sample7 = sample7;
- Uint16 last_sample6 = sample6;
- Uint16 last_sample5 = sample5;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample0 = sample0;
- while (dst > target) {
- dst[7] = SDL_SwapBE16(sample7);
- dst[6] = SDL_SwapBE16(sample6);
- dst[5] = SDL_SwapBE16(sample5);
- dst[4] = SDL_SwapBE16(sample4);
- dst[3] = SDL_SwapBE16(sample3);
- dst[2] = SDL_SwapBE16(sample2);
- dst[1] = SDL_SwapBE16(sample1);
- dst[0] = SDL_SwapBE16(sample0);
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Uint16) ((((Sint32) SDL_SwapBE16(src[7])) + ((Sint32) last_sample7)) >> 1);
- sample6 = (Uint16) ((((Sint32) SDL_SwapBE16(src[6])) + ((Sint32) last_sample6)) >> 1);
- sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Uint16 sample0 = SDL_SwapBE16(src[0]);
- Uint16 sample1 = SDL_SwapBE16(src[1]);
- Uint16 sample2 = SDL_SwapBE16(src[2]);
- Uint16 sample3 = SDL_SwapBE16(src[3]);
- Uint16 sample4 = SDL_SwapBE16(src[4]);
- Uint16 sample5 = SDL_SwapBE16(src[5]);
- Uint16 sample6 = SDL_SwapBE16(src[6]);
- Uint16 sample7 = SDL_SwapBE16(src[7]);
- Uint16 last_sample0 = sample0;
- Uint16 last_sample1 = sample1;
- Uint16 last_sample2 = sample2;
- Uint16 last_sample3 = sample3;
- Uint16 last_sample4 = sample4;
- Uint16 last_sample5 = sample5;
- Uint16 last_sample6 = sample6;
- Uint16 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapBE16(sample0);
- dst[1] = SDL_SwapBE16(sample1);
- dst[2] = SDL_SwapBE16(sample2);
- dst[3] = SDL_SwapBE16(sample3);
- dst[4] = SDL_SwapBE16(sample4);
- dst[5] = SDL_SwapBE16(sample5);
- dst[6] = SDL_SwapBE16(sample6);
- dst[7] = SDL_SwapBE16(sample7);
- dst += 8;
- sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
- sample6 = (Uint16) ((((Sint32) SDL_SwapBE16(src[6])) + ((Sint32) last_sample6)) >> 1);
- sample7 = (Uint16) ((((Sint32) SDL_SwapBE16(src[7])) + ((Sint32) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 last_sample0 = sample0;
- while (dst > target) {
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 32;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst++;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst > target) {
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst += 2;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 4;
- Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
- Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 last_sample3 = sample3;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst > target) {
- dst[3] = ((Sint16) SDL_SwapBE16(sample3));
- dst[2] = ((Sint16) SDL_SwapBE16(sample2));
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
- Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst[2] = ((Sint16) SDL_SwapBE16(sample2));
- dst[3] = ((Sint16) SDL_SwapBE16(sample3));
- dst += 4;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 6;
- Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
- Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
- Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
- Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 last_sample5 = sample5;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst > target) {
- dst[5] = ((Sint16) SDL_SwapBE16(sample5));
- dst[4] = ((Sint16) SDL_SwapBE16(sample4));
- dst[3] = ((Sint16) SDL_SwapBE16(sample3));
- dst[2] = ((Sint16) SDL_SwapBE16(sample2));
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 192;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
- Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
- Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
- Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst[2] = ((Sint16) SDL_SwapBE16(sample2));
- dst[3] = ((Sint16) SDL_SwapBE16(sample3));
- dst[4] = ((Sint16) SDL_SwapBE16(sample4));
- dst[5] = ((Sint16) SDL_SwapBE16(sample5));
- dst += 6;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 8;
- Sint16 sample7 = ((Sint16) SDL_SwapBE16(src[7]));
- Sint16 sample6 = ((Sint16) SDL_SwapBE16(src[6]));
- Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
- Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
- Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
- Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 last_sample7 = sample7;
- Sint16 last_sample6 = sample6;
- Sint16 last_sample5 = sample5;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample0 = sample0;
- while (dst > target) {
- dst[7] = ((Sint16) SDL_SwapBE16(sample7));
- dst[6] = ((Sint16) SDL_SwapBE16(sample6));
- dst[5] = ((Sint16) SDL_SwapBE16(sample5));
- dst[4] = ((Sint16) SDL_SwapBE16(sample4));
- dst[3] = ((Sint16) SDL_SwapBE16(sample3));
- dst[2] = ((Sint16) SDL_SwapBE16(sample2));
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
- sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
- Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
- Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
- Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
- Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
- Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
- Sint16 sample6 = ((Sint16) SDL_SwapBE16(src[6]));
- Sint16 sample7 = ((Sint16) SDL_SwapBE16(src[7]));
- Sint16 last_sample0 = sample0;
- Sint16 last_sample1 = sample1;
- Sint16 last_sample2 = sample2;
- Sint16 last_sample3 = sample3;
- Sint16 last_sample4 = sample4;
- Sint16 last_sample5 = sample5;
- Sint16 last_sample6 = sample6;
- Sint16 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint16) SDL_SwapBE16(sample0));
- dst[1] = ((Sint16) SDL_SwapBE16(sample1));
- dst[2] = ((Sint16) SDL_SwapBE16(sample2));
- dst[3] = ((Sint16) SDL_SwapBE16(sample3));
- dst[4] = ((Sint16) SDL_SwapBE16(sample4));
- dst[5] = ((Sint16) SDL_SwapBE16(sample5));
- dst[6] = ((Sint16) SDL_SwapBE16(sample6));
- dst[7] = ((Sint16) SDL_SwapBE16(sample7));
- dst += 8;
- sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
- sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
- sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
- sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
- sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
- sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
- sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
- sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 last_sample0 = sample0;
- while (dst > target) {
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst++;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 2;
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst > target) {
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst += 2;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 4;
- Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
- Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 last_sample3 = sample3;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst > target) {
- dst[3] = ((Sint32) SDL_SwapLE32(sample3));
- dst[2] = ((Sint32) SDL_SwapLE32(sample2));
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
- Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst[2] = ((Sint32) SDL_SwapLE32(sample2));
- dst[3] = ((Sint32) SDL_SwapLE32(sample3));
- dst += 4;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 6;
- Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
- Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
- Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
- Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 last_sample5 = sample5;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst > target) {
- dst[5] = ((Sint32) SDL_SwapLE32(sample5));
- dst[4] = ((Sint32) SDL_SwapLE32(sample4));
- dst[3] = ((Sint32) SDL_SwapLE32(sample3));
- dst[2] = ((Sint32) SDL_SwapLE32(sample2));
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
- Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
- Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
- Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst[2] = ((Sint32) SDL_SwapLE32(sample2));
- dst[3] = ((Sint32) SDL_SwapLE32(sample3));
- dst[4] = ((Sint32) SDL_SwapLE32(sample4));
- dst[5] = ((Sint32) SDL_SwapLE32(sample5));
- dst += 6;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 8;
- Sint32 sample7 = ((Sint32) SDL_SwapLE32(src[7]));
- Sint32 sample6 = ((Sint32) SDL_SwapLE32(src[6]));
- Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
- Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
- Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
- Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 last_sample7 = sample7;
- Sint32 last_sample6 = sample6;
- Sint32 last_sample5 = sample5;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst > target) {
- dst[7] = ((Sint32) SDL_SwapLE32(sample7));
- dst[6] = ((Sint32) SDL_SwapLE32(sample6));
- dst[5] = ((Sint32) SDL_SwapLE32(sample5));
- dst[4] = ((Sint32) SDL_SwapLE32(sample4));
- dst[3] = ((Sint32) SDL_SwapLE32(sample3));
- dst[2] = ((Sint32) SDL_SwapLE32(sample2));
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
- sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
- Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
- Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
- Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
- Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
- Sint32 sample6 = ((Sint32) SDL_SwapLE32(src[6]));
- Sint32 sample7 = ((Sint32) SDL_SwapLE32(src[7]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample5 = sample5;
- Sint32 last_sample6 = sample6;
- Sint32 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapLE32(sample0));
- dst[1] = ((Sint32) SDL_SwapLE32(sample1));
- dst[2] = ((Sint32) SDL_SwapLE32(sample2));
- dst[3] = ((Sint32) SDL_SwapLE32(sample3));
- dst[4] = ((Sint32) SDL_SwapLE32(sample4));
- dst[5] = ((Sint32) SDL_SwapLE32(sample5));
- dst[6] = ((Sint32) SDL_SwapLE32(sample6));
- dst[7] = ((Sint32) SDL_SwapLE32(sample7));
- dst += 8;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
- sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 last_sample0 = sample0;
- while (dst > target) {
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst++;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 2;
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst > target) {
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst += 2;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 4;
- Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
- Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 last_sample3 = sample3;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst > target) {
- dst[3] = ((Sint32) SDL_SwapBE32(sample3));
- dst[2] = ((Sint32) SDL_SwapBE32(sample2));
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
- Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst[2] = ((Sint32) SDL_SwapBE32(sample2));
- dst[3] = ((Sint32) SDL_SwapBE32(sample3));
- dst += 4;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 6;
- Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
- Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
- Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
- Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 last_sample5 = sample5;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst > target) {
- dst[5] = ((Sint32) SDL_SwapBE32(sample5));
- dst[4] = ((Sint32) SDL_SwapBE32(sample4));
- dst[3] = ((Sint32) SDL_SwapBE32(sample3));
- dst[2] = ((Sint32) SDL_SwapBE32(sample2));
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
- Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
- Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
- Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst[2] = ((Sint32) SDL_SwapBE32(sample2));
- dst[3] = ((Sint32) SDL_SwapBE32(sample3));
- dst[4] = ((Sint32) SDL_SwapBE32(sample4));
- dst[5] = ((Sint32) SDL_SwapBE32(sample5));
- dst += 6;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 8;
- Sint32 sample7 = ((Sint32) SDL_SwapBE32(src[7]));
- Sint32 sample6 = ((Sint32) SDL_SwapBE32(src[6]));
- Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
- Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
- Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
- Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 last_sample7 = sample7;
- Sint32 last_sample6 = sample6;
- Sint32 last_sample5 = sample5;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample0 = sample0;
- while (dst > target) {
- dst[7] = ((Sint32) SDL_SwapBE32(sample7));
- dst[6] = ((Sint32) SDL_SwapBE32(sample6));
- dst[5] = ((Sint32) SDL_SwapBE32(sample5));
- dst[4] = ((Sint32) SDL_SwapBE32(sample4));
- dst[3] = ((Sint32) SDL_SwapBE32(sample3));
- dst[2] = ((Sint32) SDL_SwapBE32(sample2));
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
- sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
- Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
- Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
- Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
- Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
- Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
- Sint32 sample6 = ((Sint32) SDL_SwapBE32(src[6]));
- Sint32 sample7 = ((Sint32) SDL_SwapBE32(src[7]));
- Sint32 last_sample0 = sample0;
- Sint32 last_sample1 = sample1;
- Sint32 last_sample2 = sample2;
- Sint32 last_sample3 = sample3;
- Sint32 last_sample4 = sample4;
- Sint32 last_sample5 = sample5;
- Sint32 last_sample6 = sample6;
- Sint32 last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = ((Sint32) SDL_SwapBE32(sample0));
- dst[1] = ((Sint32) SDL_SwapBE32(sample1));
- dst[2] = ((Sint32) SDL_SwapBE32(sample2));
- dst[3] = ((Sint32) SDL_SwapBE32(sample3));
- dst[4] = ((Sint32) SDL_SwapBE32(sample4));
- dst[5] = ((Sint32) SDL_SwapBE32(sample5));
- dst[6] = ((Sint32) SDL_SwapBE32(sample6));
- dst[7] = ((Sint32) SDL_SwapBE32(sample7));
- dst += 8;
- sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
- sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
- sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
- sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
- sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
- sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
- sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
- sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 1;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
- const float *target = ((const float *) cvt->buf) - 1;
- float sample0 = SDL_SwapFloatLE(src[0]);
- float last_sample0 = sample0;
- while (dst > target) {
- dst[0] = SDL_SwapFloatLE(sample0);
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatLE(sample0);
- dst++;
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
- const float *target = ((const float *) cvt->buf) - 2;
- float sample1 = SDL_SwapFloatLE(src[1]);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst > target) {
- dst[1] = SDL_SwapFloatLE(sample1);
- dst[0] = SDL_SwapFloatLE(sample0);
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float sample1 = SDL_SwapFloatLE(src[1]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatLE(sample0);
- dst[1] = SDL_SwapFloatLE(sample1);
- dst += 2;
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
- const float *target = ((const float *) cvt->buf) - 4;
- float sample3 = SDL_SwapFloatLE(src[3]);
- float sample2 = SDL_SwapFloatLE(src[2]);
- float sample1 = SDL_SwapFloatLE(src[1]);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float last_sample3 = sample3;
- float last_sample2 = sample2;
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst > target) {
- dst[3] = SDL_SwapFloatLE(sample3);
- dst[2] = SDL_SwapFloatLE(sample2);
- dst[1] = SDL_SwapFloatLE(sample1);
- dst[0] = SDL_SwapFloatLE(sample0);
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float sample1 = SDL_SwapFloatLE(src[1]);
- float sample2 = SDL_SwapFloatLE(src[2]);
- float sample3 = SDL_SwapFloatLE(src[3]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- float last_sample2 = sample2;
- float last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatLE(sample0);
- dst[1] = SDL_SwapFloatLE(sample1);
- dst[2] = SDL_SwapFloatLE(sample2);
- dst[3] = SDL_SwapFloatLE(sample3);
- dst += 4;
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 6;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
- const float *target = ((const float *) cvt->buf) - 6;
- float sample5 = SDL_SwapFloatLE(src[5]);
- float sample4 = SDL_SwapFloatLE(src[4]);
- float sample3 = SDL_SwapFloatLE(src[3]);
- float sample2 = SDL_SwapFloatLE(src[2]);
- float sample1 = SDL_SwapFloatLE(src[1]);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float last_sample5 = sample5;
- float last_sample4 = sample4;
- float last_sample3 = sample3;
- float last_sample2 = sample2;
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst > target) {
- dst[5] = SDL_SwapFloatLE(sample5);
- dst[4] = SDL_SwapFloatLE(sample4);
- dst[3] = SDL_SwapFloatLE(sample3);
- dst[2] = SDL_SwapFloatLE(sample2);
- dst[1] = SDL_SwapFloatLE(sample1);
- dst[0] = SDL_SwapFloatLE(sample0);
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float sample1 = SDL_SwapFloatLE(src[1]);
- float sample2 = SDL_SwapFloatLE(src[2]);
- float sample3 = SDL_SwapFloatLE(src[3]);
- float sample4 = SDL_SwapFloatLE(src[4]);
- float sample5 = SDL_SwapFloatLE(src[5]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- float last_sample2 = sample2;
- float last_sample3 = sample3;
- float last_sample4 = sample4;
- float last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatLE(sample0);
- dst[1] = SDL_SwapFloatLE(sample1);
- dst[2] = SDL_SwapFloatLE(sample2);
- dst[3] = SDL_SwapFloatLE(sample3);
- dst[4] = SDL_SwapFloatLE(sample4);
- dst[5] = SDL_SwapFloatLE(sample5);
- dst += 6;
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
- sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 8;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
- const float *target = ((const float *) cvt->buf) - 8;
- float sample7 = SDL_SwapFloatLE(src[7]);
- float sample6 = SDL_SwapFloatLE(src[6]);
- float sample5 = SDL_SwapFloatLE(src[5]);
- float sample4 = SDL_SwapFloatLE(src[4]);
- float sample3 = SDL_SwapFloatLE(src[3]);
- float sample2 = SDL_SwapFloatLE(src[2]);
- float sample1 = SDL_SwapFloatLE(src[1]);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float last_sample7 = sample7;
- float last_sample6 = sample6;
- float last_sample5 = sample5;
- float last_sample4 = sample4;
- float last_sample3 = sample3;
- float last_sample2 = sample2;
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst > target) {
- dst[7] = SDL_SwapFloatLE(sample7);
- dst[6] = SDL_SwapFloatLE(sample6);
- dst[5] = SDL_SwapFloatLE(sample5);
- dst[4] = SDL_SwapFloatLE(sample4);
- dst[3] = SDL_SwapFloatLE(sample3);
- dst[2] = SDL_SwapFloatLE(sample2);
- dst[1] = SDL_SwapFloatLE(sample1);
- dst[0] = SDL_SwapFloatLE(sample0);
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (float) ((((double) SDL_SwapFloatLE(src[7])) + ((double) last_sample7)) * 0.5);
- sample6 = (float) ((((double) SDL_SwapFloatLE(src[6])) + ((double) last_sample6)) * 0.5);
- sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatLE(src[0]);
- float sample1 = SDL_SwapFloatLE(src[1]);
- float sample2 = SDL_SwapFloatLE(src[2]);
- float sample3 = SDL_SwapFloatLE(src[3]);
- float sample4 = SDL_SwapFloatLE(src[4]);
- float sample5 = SDL_SwapFloatLE(src[5]);
- float sample6 = SDL_SwapFloatLE(src[6]);
- float sample7 = SDL_SwapFloatLE(src[7]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- float last_sample2 = sample2;
- float last_sample3 = sample3;
- float last_sample4 = sample4;
- float last_sample5 = sample5;
- float last_sample6 = sample6;
- float last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatLE(sample0);
- dst[1] = SDL_SwapFloatLE(sample1);
- dst[2] = SDL_SwapFloatLE(sample2);
- dst[3] = SDL_SwapFloatLE(sample3);
- dst[4] = SDL_SwapFloatLE(sample4);
- dst[5] = SDL_SwapFloatLE(sample5);
- dst[6] = SDL_SwapFloatLE(sample6);
- dst[7] = SDL_SwapFloatLE(sample7);
- dst += 8;
- sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
- sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
- sample6 = (float) ((((double) SDL_SwapFloatLE(src[6])) + ((double) last_sample6)) * 0.5);
- sample7 = (float) ((((double) SDL_SwapFloatLE(src[7])) + ((double) last_sample7)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 1;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
- const float *target = ((const float *) cvt->buf) - 1;
- float sample0 = SDL_SwapFloatBE(src[0]);
- float last_sample0 = sample0;
- while (dst > target) {
- dst[0] = SDL_SwapFloatBE(sample0);
- dst--;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src--;
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 1 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 64;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float last_sample0 = sample0;
- while (dst < target) {
- src++;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatBE(sample0);
- dst++;
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample0 = sample0;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
- const float *target = ((const float *) cvt->buf) - 2;
- float sample1 = SDL_SwapFloatBE(src[1]);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst > target) {
- dst[1] = SDL_SwapFloatBE(sample1);
- dst[0] = SDL_SwapFloatBE(sample0);
- dst -= 2;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 2;
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 2 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 128;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float sample1 = SDL_SwapFloatBE(src[1]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- while (dst < target) {
- src += 2;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatBE(sample0);
- dst[1] = SDL_SwapFloatBE(sample1);
- dst += 2;
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
- const float *target = ((const float *) cvt->buf) - 4;
- float sample3 = SDL_SwapFloatBE(src[3]);
- float sample2 = SDL_SwapFloatBE(src[2]);
- float sample1 = SDL_SwapFloatBE(src[1]);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float last_sample3 = sample3;
- float last_sample2 = sample2;
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst > target) {
- dst[3] = SDL_SwapFloatBE(sample3);
- dst[2] = SDL_SwapFloatBE(sample2);
- dst[1] = SDL_SwapFloatBE(sample1);
- dst[0] = SDL_SwapFloatBE(sample0);
- dst -= 4;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 4;
- sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 4 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 256;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float sample1 = SDL_SwapFloatBE(src[1]);
- float sample2 = SDL_SwapFloatBE(src[2]);
- float sample3 = SDL_SwapFloatBE(src[3]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- float last_sample2 = sample2;
- float last_sample3 = sample3;
- while (dst < target) {
- src += 4;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatBE(sample0);
- dst[1] = SDL_SwapFloatBE(sample1);
- dst[2] = SDL_SwapFloatBE(sample2);
- dst[3] = SDL_SwapFloatBE(sample3);
- dst += 4;
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 6;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
- const float *target = ((const float *) cvt->buf) - 6;
- float sample5 = SDL_SwapFloatBE(src[5]);
- float sample4 = SDL_SwapFloatBE(src[4]);
- float sample3 = SDL_SwapFloatBE(src[3]);
- float sample2 = SDL_SwapFloatBE(src[2]);
- float sample1 = SDL_SwapFloatBE(src[1]);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float last_sample5 = sample5;
- float last_sample4 = sample4;
- float last_sample3 = sample3;
- float last_sample2 = sample2;
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst > target) {
- dst[5] = SDL_SwapFloatBE(sample5);
- dst[4] = SDL_SwapFloatBE(sample4);
- dst[3] = SDL_SwapFloatBE(sample3);
- dst[2] = SDL_SwapFloatBE(sample2);
- dst[1] = SDL_SwapFloatBE(sample1);
- dst[0] = SDL_SwapFloatBE(sample0);
- dst -= 6;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 6;
- sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 6 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 384;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float sample1 = SDL_SwapFloatBE(src[1]);
- float sample2 = SDL_SwapFloatBE(src[2]);
- float sample3 = SDL_SwapFloatBE(src[3]);
- float sample4 = SDL_SwapFloatBE(src[4]);
- float sample5 = SDL_SwapFloatBE(src[5]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- float last_sample2 = sample2;
- float last_sample3 = sample3;
- float last_sample4 = sample4;
- float last_sample5 = sample5;
- while (dst < target) {
- src += 6;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatBE(sample0);
- dst[1] = SDL_SwapFloatBE(sample1);
- dst[2] = SDL_SwapFloatBE(sample2);
- dst[3] = SDL_SwapFloatBE(sample3);
- dst[4] = SDL_SwapFloatBE(sample4);
- dst[5] = SDL_SwapFloatBE(sample5);
- dst += 6;
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
- sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = ((float *) (cvt->buf + dstsize)) - 8;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
- const float *target = ((const float *) cvt->buf) - 8;
- float sample7 = SDL_SwapFloatBE(src[7]);
- float sample6 = SDL_SwapFloatBE(src[6]);
- float sample5 = SDL_SwapFloatBE(src[5]);
- float sample4 = SDL_SwapFloatBE(src[4]);
- float sample3 = SDL_SwapFloatBE(src[3]);
- float sample2 = SDL_SwapFloatBE(src[2]);
- float sample1 = SDL_SwapFloatBE(src[1]);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float last_sample7 = sample7;
- float last_sample6 = sample6;
- float last_sample5 = sample5;
- float last_sample4 = sample4;
- float last_sample3 = sample3;
- float last_sample2 = sample2;
- float last_sample1 = sample1;
- float last_sample0 = sample0;
- while (dst > target) {
- dst[7] = SDL_SwapFloatBE(sample7);
- dst[6] = SDL_SwapFloatBE(sample6);
- dst[5] = SDL_SwapFloatBE(sample5);
- dst[4] = SDL_SwapFloatBE(sample4);
- dst[3] = SDL_SwapFloatBE(sample3);
- dst[2] = SDL_SwapFloatBE(sample2);
- dst[1] = SDL_SwapFloatBE(sample1);
- dst[0] = SDL_SwapFloatBE(sample0);
- dst -= 8;
- eps += srcsize;
- if ((eps << 1) >= dstsize) {
- src -= 8;
- sample7 = (float) ((((double) SDL_SwapFloatBE(src[7])) + ((double) last_sample7)) * 0.5);
- sample6 = (float) ((((double) SDL_SwapFloatBE(src[6])) + ((double) last_sample6)) * 0.5);
- sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- eps -= dstsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 8 channels.\n", cvt->rate_incr);
-#endif
-
- const int srcsize = cvt->len_cvt - 512;
- const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
- register int eps = 0;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- float sample0 = SDL_SwapFloatBE(src[0]);
- float sample1 = SDL_SwapFloatBE(src[1]);
- float sample2 = SDL_SwapFloatBE(src[2]);
- float sample3 = SDL_SwapFloatBE(src[3]);
- float sample4 = SDL_SwapFloatBE(src[4]);
- float sample5 = SDL_SwapFloatBE(src[5]);
- float sample6 = SDL_SwapFloatBE(src[6]);
- float sample7 = SDL_SwapFloatBE(src[7]);
- float last_sample0 = sample0;
- float last_sample1 = sample1;
- float last_sample2 = sample2;
- float last_sample3 = sample3;
- float last_sample4 = sample4;
- float last_sample5 = sample5;
- float last_sample6 = sample6;
- float last_sample7 = sample7;
- while (dst < target) {
- src += 8;
- eps += dstsize;
- if ((eps << 1) >= srcsize) {
- dst[0] = SDL_SwapFloatBE(sample0);
- dst[1] = SDL_SwapFloatBE(sample1);
- dst[2] = SDL_SwapFloatBE(sample2);
- dst[3] = SDL_SwapFloatBE(sample3);
- dst[4] = SDL_SwapFloatBE(sample4);
- dst[5] = SDL_SwapFloatBE(sample5);
- dst[6] = SDL_SwapFloatBE(sample6);
- dst[7] = SDL_SwapFloatBE(sample7);
- dst += 8;
- sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
- sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
- sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
- sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
- sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
- sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
- sample6 = (float) ((((double) SDL_SwapFloatBE(src[6])) + ((double) last_sample6)) * 0.5);
- sample7 = (float) ((((double) SDL_SwapFloatBE(src[7])) + ((double) last_sample7)) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- eps -= srcsize;
- }
- }
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-
-#if !LESS_RESAMPLERS
-
-static void SDLCALL
-SDL_Upsample_U8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U8, 1 channels.\n");
-#endif
-
- //const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint8 *target = ((const Uint8 *) cvt->buf) - 1;
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst > target) {
- const Sint16 sample0 = (Sint16) src[0];
- src--;
- dst[1] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[0] = (Uint8) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U8, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- src += 2;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U8, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint8 *target = ((const Uint8 *) cvt->buf) - 1;
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst > target) {
- const Sint16 sample0 = (Sint16) src[0];
- src--;
- dst[3] = (Uint8) sample0;
- dst[2] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[0] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U8, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- src += 4;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U8, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint8 *target = ((const Uint8 *) cvt->buf) - 2;
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst > target) {
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 2;
- dst[3] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) sample1;
- dst[0] = (Uint8) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U8, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- src += 4;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U8, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint8 *target = ((const Uint8 *) cvt->buf) - 2;
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst > target) {
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 2;
- dst[7] = (Uint8) sample1;
- dst[6] = (Uint8) sample0;
- dst[5] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U8, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- src += 8;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U8, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint8 *target = ((const Uint8 *) cvt->buf) - 4;
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst > target) {
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 4;
- dst[7] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[6] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[5] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[4] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[3] = (Uint8) sample3;
- dst[2] = (Uint8) sample2;
- dst[1] = (Uint8) sample1;
- dst[0] = (Uint8) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U8, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample3 = (Sint16) src[3];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample3 = (Sint16) src[3];
- src += 8;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U8, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint8 *target = ((const Uint8 *) cvt->buf) - 4;
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst > target) {
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 4;
- dst[15] = (Uint8) sample3;
- dst[14] = (Uint8) sample2;
- dst[13] = (Uint8) sample1;
- dst[12] = (Uint8) sample0;
- dst[11] = (Uint8) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Uint8) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[6] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[5] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[4] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[3] = (Uint8) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Uint8) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U8, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample3 = (Sint16) src[3];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample3 = (Sint16) src[3];
- src += 16;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U8, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint8 *target = ((const Uint8 *) cvt->buf) - 6;
- Sint16 last_sample5 = (Sint16) src[5];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst > target) {
- const Sint16 sample5 = (Sint16) src[5];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 6;
- dst[11] = (Uint8) ((sample5 + last_sample5) >> 1);
- dst[10] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[9] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[8] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[7] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[6] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[5] = (Uint8) sample5;
- dst[4] = (Uint8) sample4;
- dst[3] = (Uint8) sample3;
- dst[2] = (Uint8) sample2;
- dst[1] = (Uint8) sample1;
- dst[0] = (Uint8) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U8, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample5 = (Sint16) src[5];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample5 = (Sint16) src[5];
- src += 12;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U8, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint8 *target = ((const Uint8 *) cvt->buf) - 6;
- Sint16 last_sample5 = (Sint16) src[5];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst > target) {
- const Sint16 sample5 = (Sint16) src[5];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 6;
- dst[23] = (Uint8) sample5;
- dst[22] = (Uint8) sample4;
- dst[21] = (Uint8) sample3;
- dst[20] = (Uint8) sample2;
- dst[19] = (Uint8) sample1;
- dst[18] = (Uint8) sample0;
- dst[17] = (Uint8) (((3 * sample5) + last_sample5) >> 2);
- dst[16] = (Uint8) (((3 * sample4) + last_sample4) >> 2);
- dst[15] = (Uint8) (((3 * sample3) + last_sample3) >> 2);
- dst[14] = (Uint8) (((3 * sample2) + last_sample2) >> 2);
- dst[13] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
- dst[12] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
- dst[11] = (Uint8) ((sample5 + last_sample5) >> 1);
- dst[10] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[9] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[8] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[7] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[6] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[5] = (Uint8) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Uint8) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Uint8) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Uint8) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U8, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample5 = (Sint16) src[5];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample5 = (Sint16) src[5];
- src += 24;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U8, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint8 *target = ((const Uint8 *) cvt->buf) - 8;
- Sint16 last_sample7 = (Sint16) src[7];
- Sint16 last_sample6 = (Sint16) src[6];
- Sint16 last_sample5 = (Sint16) src[5];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst > target) {
- const Sint16 sample7 = (Sint16) src[7];
- const Sint16 sample6 = (Sint16) src[6];
- const Sint16 sample5 = (Sint16) src[5];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 8;
- dst[15] = (Uint8) ((sample7 + last_sample7) >> 1);
- dst[14] = (Uint8) ((sample6 + last_sample6) >> 1);
- dst[13] = (Uint8) ((sample5 + last_sample5) >> 1);
- dst[12] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[11] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[10] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[9] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[8] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[7] = (Uint8) sample7;
- dst[6] = (Uint8) sample6;
- dst[5] = (Uint8) sample5;
- dst[4] = (Uint8) sample4;
- dst[3] = (Uint8) sample3;
- dst[2] = (Uint8) sample2;
- dst[1] = (Uint8) sample1;
- dst[0] = (Uint8) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U8, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample5 = (Sint16) src[5];
- Sint16 last_sample6 = (Sint16) src[6];
- Sint16 last_sample7 = (Sint16) src[7];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample5 = (Sint16) src[5];
- const Sint16 sample6 = (Sint16) src[6];
- const Sint16 sample7 = (Sint16) src[7];
- src += 16;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
- dst[6] = (Uint8) ((sample6 + last_sample6) >> 1);
- dst[7] = (Uint8) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U8, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8;
- const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint8 *target = ((const Uint8 *) cvt->buf) - 8;
- Sint16 last_sample7 = (Sint16) src[7];
- Sint16 last_sample6 = (Sint16) src[6];
- Sint16 last_sample5 = (Sint16) src[5];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample0 = (Sint16) src[0];
- while (dst > target) {
- const Sint16 sample7 = (Sint16) src[7];
- const Sint16 sample6 = (Sint16) src[6];
- const Sint16 sample5 = (Sint16) src[5];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample0 = (Sint16) src[0];
- src -= 8;
- dst[31] = (Uint8) sample7;
- dst[30] = (Uint8) sample6;
- dst[29] = (Uint8) sample5;
- dst[28] = (Uint8) sample4;
- dst[27] = (Uint8) sample3;
- dst[26] = (Uint8) sample2;
- dst[25] = (Uint8) sample1;
- dst[24] = (Uint8) sample0;
- dst[23] = (Uint8) (((3 * sample7) + last_sample7) >> 2);
- dst[22] = (Uint8) (((3 * sample6) + last_sample6) >> 2);
- dst[21] = (Uint8) (((3 * sample5) + last_sample5) >> 2);
- dst[20] = (Uint8) (((3 * sample4) + last_sample4) >> 2);
- dst[19] = (Uint8) (((3 * sample3) + last_sample3) >> 2);
- dst[18] = (Uint8) (((3 * sample2) + last_sample2) >> 2);
- dst[17] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
- dst[16] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
- dst[15] = (Uint8) ((sample7 + last_sample7) >> 1);
- dst[14] = (Uint8) ((sample6 + last_sample6) >> 1);
- dst[13] = (Uint8) ((sample5 + last_sample5) >> 1);
- dst[12] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[11] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[10] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[9] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[8] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[7] = (Uint8) ((sample7 + (3 * last_sample7)) >> 2);
- dst[6] = (Uint8) ((sample6 + (3 * last_sample6)) >> 2);
- dst[5] = (Uint8) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Uint8) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Uint8) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Uint8) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U8, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Uint8 *dst = (Uint8 *) cvt->buf;
- const Uint8 *src = (Uint8 *) cvt->buf;
- const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) src[0];
- Sint16 last_sample1 = (Sint16) src[1];
- Sint16 last_sample2 = (Sint16) src[2];
- Sint16 last_sample3 = (Sint16) src[3];
- Sint16 last_sample4 = (Sint16) src[4];
- Sint16 last_sample5 = (Sint16) src[5];
- Sint16 last_sample6 = (Sint16) src[6];
- Sint16 last_sample7 = (Sint16) src[7];
- while (dst < target) {
- const Sint16 sample0 = (Sint16) src[0];
- const Sint16 sample1 = (Sint16) src[1];
- const Sint16 sample2 = (Sint16) src[2];
- const Sint16 sample3 = (Sint16) src[3];
- const Sint16 sample4 = (Sint16) src[4];
- const Sint16 sample5 = (Sint16) src[5];
- const Sint16 sample6 = (Sint16) src[6];
- const Sint16 sample7 = (Sint16) src[7];
- src += 32;
- dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
- dst[6] = (Uint8) ((sample6 + last_sample6) >> 1);
- dst[7] = (Uint8) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S8, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint8 *target = ((const Sint8 *) cvt->buf) - 1;
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst > target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src--;
- dst[1] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[0] = (Sint8) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S8, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src += 2;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S8, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint8 *target = ((const Sint8 *) cvt->buf) - 1;
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst > target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src--;
- dst[3] = (Sint8) sample0;
- dst[2] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[0] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S8, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src += 4;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S8, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint8 *target = ((const Sint8 *) cvt->buf) - 2;
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst > target) {
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 2;
- dst[3] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) sample1;
- dst[0] = (Sint8) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S8, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- src += 4;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S8, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint8 *target = ((const Sint8 *) cvt->buf) - 2;
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst > target) {
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 2;
- dst[7] = (Sint8) sample1;
- dst[6] = (Sint8) sample0;
- dst[5] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S8, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- src += 8;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S8, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint8 *target = ((const Sint8 *) cvt->buf) - 4;
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst > target) {
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 4;
- dst[7] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[6] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[5] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint8) sample3;
- dst[2] = (Sint8) sample2;
- dst[1] = (Sint8) sample1;
- dst[0] = (Sint8) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S8, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- src += 8;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S8, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint8 *target = ((const Sint8 *) cvt->buf) - 4;
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst > target) {
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 4;
- dst[15] = (Sint8) sample3;
- dst[14] = (Sint8) sample2;
- dst[13] = (Sint8) sample1;
- dst[12] = (Sint8) sample0;
- dst[11] = (Sint8) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Sint8) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[6] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[5] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint8) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Sint8) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S8, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- src += 16;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S8, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint8 *target = ((const Sint8 *) cvt->buf) - 6;
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst > target) {
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 6;
- dst[11] = (Sint8) ((sample5 + last_sample5) >> 1);
- dst[10] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[9] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[8] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[7] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[6] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[5] = (Sint8) sample5;
- dst[4] = (Sint8) sample4;
- dst[3] = (Sint8) sample3;
- dst[2] = (Sint8) sample2;
- dst[1] = (Sint8) sample1;
- dst[0] = (Sint8) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S8, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- src += 12;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S8, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint8 *target = ((const Sint8 *) cvt->buf) - 6;
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst > target) {
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 6;
- dst[23] = (Sint8) sample5;
- dst[22] = (Sint8) sample4;
- dst[21] = (Sint8) sample3;
- dst[20] = (Sint8) sample2;
- dst[19] = (Sint8) sample1;
- dst[18] = (Sint8) sample0;
- dst[17] = (Sint8) (((3 * sample5) + last_sample5) >> 2);
- dst[16] = (Sint8) (((3 * sample4) + last_sample4) >> 2);
- dst[15] = (Sint8) (((3 * sample3) + last_sample3) >> 2);
- dst[14] = (Sint8) (((3 * sample2) + last_sample2) >> 2);
- dst[13] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
- dst[12] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
- dst[11] = (Sint8) ((sample5 + last_sample5) >> 1);
- dst[10] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[9] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[8] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[7] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[6] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[5] = (Sint8) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Sint8) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Sint8) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Sint8) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S8, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- src += 24;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S8, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint8 *target = ((const Sint8 *) cvt->buf) - 8;
- Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
- Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst > target) {
- const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
- const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 8;
- dst[15] = (Sint8) ((sample7 + last_sample7) >> 1);
- dst[14] = (Sint8) ((sample6 + last_sample6) >> 1);
- dst[13] = (Sint8) ((sample5 + last_sample5) >> 1);
- dst[12] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[11] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint8) sample7;
- dst[6] = (Sint8) sample6;
- dst[5] = (Sint8) sample5;
- dst[4] = (Sint8) sample4;
- dst[3] = (Sint8) sample3;
- dst[2] = (Sint8) sample2;
- dst[1] = (Sint8) sample1;
- dst[0] = (Sint8) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S8, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
- Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
- const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
- src += 16;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint8) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint8) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S8, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8;
- const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint8 *target = ((const Sint8 *) cvt->buf) - 8;
- Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
- Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- while (dst > target) {
- const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
- const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- src -= 8;
- dst[31] = (Sint8) sample7;
- dst[30] = (Sint8) sample6;
- dst[29] = (Sint8) sample5;
- dst[28] = (Sint8) sample4;
- dst[27] = (Sint8) sample3;
- dst[26] = (Sint8) sample2;
- dst[25] = (Sint8) sample1;
- dst[24] = (Sint8) sample0;
- dst[23] = (Sint8) (((3 * sample7) + last_sample7) >> 2);
- dst[22] = (Sint8) (((3 * sample6) + last_sample6) >> 2);
- dst[21] = (Sint8) (((3 * sample5) + last_sample5) >> 2);
- dst[20] = (Sint8) (((3 * sample4) + last_sample4) >> 2);
- dst[19] = (Sint8) (((3 * sample3) + last_sample3) >> 2);
- dst[18] = (Sint8) (((3 * sample2) + last_sample2) >> 2);
- dst[17] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
- dst[16] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
- dst[15] = (Sint8) ((sample7 + last_sample7) >> 1);
- dst[14] = (Sint8) ((sample6 + last_sample6) >> 1);
- dst[13] = (Sint8) ((sample5 + last_sample5) >> 1);
- dst[12] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[11] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint8) ((sample7 + (3 * last_sample7)) >> 2);
- dst[6] = (Sint8) ((sample6 + (3 * last_sample6)) >> 2);
- dst[5] = (Sint8) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Sint8) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Sint8) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Sint8) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S8, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint8 *dst = (Sint8 *) cvt->buf;
- const Sint8 *src = (Sint8 *) cvt->buf;
- const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
- Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
- Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
- Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
- Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
- Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
- Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
- Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
- Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
- while (dst < target) {
- const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
- const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
- const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
- const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
- const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
- const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
- const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
- const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
- src += 32;
- dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint8) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint8) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst > target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src--;
- dst[1] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[0] = (Uint16) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src += 2;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst > target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src--;
- dst[3] = (Uint16) sample0;
- dst[2] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src += 4;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 2;
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst > target) {
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 2;
- dst[3] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- src += 4;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 2;
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst > target) {
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 2;
- dst[7] = (Uint16) sample1;
- dst[6] = (Uint16) sample0;
- dst[5] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- src += 8;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 4;
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst > target) {
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 4;
- dst[7] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[6] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- src += 8;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 4;
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst > target) {
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 4;
- dst[15] = (Uint16) sample3;
- dst[14] = (Uint16) sample2;
- dst[13] = (Uint16) sample1;
- dst[12] = (Uint16) sample0;
- dst[11] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[6] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- src += 16;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 6;
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst > target) {
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 6;
- dst[11] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[10] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[9] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[8] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[7] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[6] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[5] = (Uint16) sample5;
- dst[4] = (Uint16) sample4;
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- src += 12;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 6;
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst > target) {
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 6;
- dst[23] = (Uint16) sample5;
- dst[22] = (Uint16) sample4;
- dst[21] = (Uint16) sample3;
- dst[20] = (Uint16) sample2;
- dst[19] = (Uint16) sample1;
- dst[18] = (Uint16) sample0;
- dst[17] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
- dst[16] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
- dst[15] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
- dst[14] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
- dst[13] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[12] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[11] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[10] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[9] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[8] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[7] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[6] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[5] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- src += 24;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 8;
- Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
- Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst > target) {
- const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
- const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 8;
- dst[15] = (Uint16) ((sample7 + last_sample7) >> 1);
- dst[14] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[13] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[12] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Uint16) sample7;
- dst[6] = (Uint16) sample6;
- dst[5] = (Uint16) sample5;
- dst[4] = (Uint16) sample4;
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
- Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
- const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
- src += 16;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 8;
- Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
- Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- while (dst > target) {
- const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
- const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- src -= 8;
- dst[31] = (Uint16) sample7;
- dst[30] = (Uint16) sample6;
- dst[29] = (Uint16) sample5;
- dst[28] = (Uint16) sample4;
- dst[27] = (Uint16) sample3;
- dst[26] = (Uint16) sample2;
- dst[25] = (Uint16) sample1;
- dst[24] = (Uint16) sample0;
- dst[23] = (Uint16) (((3 * sample7) + last_sample7) >> 2);
- dst[22] = (Uint16) (((3 * sample6) + last_sample6) >> 2);
- dst[21] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
- dst[20] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
- dst[19] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
- dst[18] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
- dst[17] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[16] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[15] = (Uint16) ((sample7 + last_sample7) >> 1);
- dst[14] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[13] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[12] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Uint16) ((sample7 + (3 * last_sample7)) >> 2);
- dst[6] = (Uint16) ((sample6 + (3 * last_sample6)) >> 2);
- dst[5] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
- Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
- Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
- const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
- const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
- src += 32;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst > target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src--;
- dst[1] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[0] = (Sint16) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src += 2;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst > target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src--;
- dst[3] = (Sint16) sample0;
- dst[2] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src += 4;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst > target) {
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 2;
- dst[3] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- src += 4;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst > target) {
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 2;
- dst[7] = (Sint16) sample1;
- dst[6] = (Sint16) sample0;
- dst[5] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- src += 8;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 4;
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst > target) {
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 4;
- dst[7] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[6] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- src += 8;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 4;
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst > target) {
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 4;
- dst[15] = (Sint16) sample3;
- dst[14] = (Sint16) sample2;
- dst[13] = (Sint16) sample1;
- dst[12] = (Sint16) sample0;
- dst[11] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[6] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- src += 16;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 6;
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst > target) {
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 6;
- dst[11] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[10] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[9] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[8] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[7] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[6] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[5] = (Sint16) sample5;
- dst[4] = (Sint16) sample4;
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- src += 12;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 6;
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst > target) {
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 6;
- dst[23] = (Sint16) sample5;
- dst[22] = (Sint16) sample4;
- dst[21] = (Sint16) sample3;
- dst[20] = (Sint16) sample2;
- dst[19] = (Sint16) sample1;
- dst[18] = (Sint16) sample0;
- dst[17] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
- dst[16] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
- dst[15] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
- dst[14] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
- dst[13] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[12] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[11] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[10] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[9] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[8] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[7] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[6] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[5] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- src += 24;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 8;
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst > target) {
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 8;
- dst[15] = (Sint16) ((sample7 + last_sample7) >> 1);
- dst[14] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[13] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[12] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint16) sample7;
- dst[6] = (Sint16) sample6;
- dst[5] = (Sint16) sample5;
- dst[4] = (Sint16) sample4;
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- src += 16;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 8;
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- while (dst > target) {
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- src -= 8;
- dst[31] = (Sint16) sample7;
- dst[30] = (Sint16) sample6;
- dst[29] = (Sint16) sample5;
- dst[28] = (Sint16) sample4;
- dst[27] = (Sint16) sample3;
- dst[26] = (Sint16) sample2;
- dst[25] = (Sint16) sample1;
- dst[24] = (Sint16) sample0;
- dst[23] = (Sint16) (((3 * sample7) + last_sample7) >> 2);
- dst[22] = (Sint16) (((3 * sample6) + last_sample6) >> 2);
- dst[21] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
- dst[20] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
- dst[19] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
- dst[18] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
- dst[17] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[16] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[15] = (Sint16) ((sample7 + last_sample7) >> 1);
- dst[14] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[13] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[12] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint16) ((sample7 + (3 * last_sample7)) >> 2);
- dst[6] = (Sint16) ((sample6 + (3 * last_sample6)) >> 2);
- dst[5] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
- src += 32;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst > target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src--;
- dst[1] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[0] = (Uint16) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src += 2;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst > target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src--;
- dst[3] = (Uint16) sample0;
- dst[2] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src += 4;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 2;
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst > target) {
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 2;
- dst[3] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- src += 4;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 2;
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst > target) {
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 2;
- dst[7] = (Uint16) sample1;
- dst[6] = (Uint16) sample0;
- dst[5] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- src += 8;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 4;
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst > target) {
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 4;
- dst[7] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[6] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- src += 8;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 4;
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst > target) {
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 4;
- dst[15] = (Uint16) sample3;
- dst[14] = (Uint16) sample2;
- dst[13] = (Uint16) sample1;
- dst[12] = (Uint16) sample0;
- dst[11] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[6] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- src += 16;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 6;
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst > target) {
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 6;
- dst[11] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[10] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[9] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[8] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[7] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[6] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[5] = (Uint16) sample5;
- dst[4] = (Uint16) sample4;
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- src += 12;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 6;
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst > target) {
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 6;
- dst[23] = (Uint16) sample5;
- dst[22] = (Uint16) sample4;
- dst[21] = (Uint16) sample3;
- dst[20] = (Uint16) sample2;
- dst[19] = (Uint16) sample1;
- dst[18] = (Uint16) sample0;
- dst[17] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
- dst[16] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
- dst[15] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
- dst[14] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
- dst[13] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[12] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[11] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[10] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[9] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[8] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[7] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[6] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[5] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- src += 24;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 8;
- Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
- Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst > target) {
- const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
- const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 8;
- dst[15] = (Uint16) ((sample7 + last_sample7) >> 1);
- dst[14] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[13] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[12] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Uint16) sample7;
- dst[6] = (Uint16) sample6;
- dst[5] = (Uint16) sample5;
- dst[4] = (Uint16) sample4;
- dst[3] = (Uint16) sample3;
- dst[2] = (Uint16) sample2;
- dst[1] = (Uint16) sample1;
- dst[0] = (Uint16) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
- Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
- const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
- src += 16;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_U16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
- const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Uint16 *target = ((const Uint16 *) cvt->buf) - 8;
- Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
- Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- while (dst > target) {
- const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
- const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- src -= 8;
- dst[31] = (Uint16) sample7;
- dst[30] = (Uint16) sample6;
- dst[29] = (Uint16) sample5;
- dst[28] = (Uint16) sample4;
- dst[27] = (Uint16) sample3;
- dst[26] = (Uint16) sample2;
- dst[25] = (Uint16) sample1;
- dst[24] = (Uint16) sample0;
- dst[23] = (Uint16) (((3 * sample7) + last_sample7) >> 2);
- dst[22] = (Uint16) (((3 * sample6) + last_sample6) >> 2);
- dst[21] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
- dst[20] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
- dst[19] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
- dst[18] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
- dst[17] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
- dst[16] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
- dst[15] = (Uint16) ((sample7 + last_sample7) >> 1);
- dst[14] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[13] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[12] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Uint16) ((sample7 + (3 * last_sample7)) >> 2);
- dst[6] = (Uint16) ((sample6 + (3 * last_sample6)) >> 2);
- dst[5] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_U16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Uint16 *dst = (Uint16 *) cvt->buf;
- const Uint16 *src = (Uint16 *) cvt->buf;
- const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
- Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
- Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
- Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
- Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
- Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
- Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
- Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
- while (dst < target) {
- const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
- const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
- const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
- const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
- const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
- const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
- const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
- const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
- src += 32;
- dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst > target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src--;
- dst[1] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[0] = (Sint16) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src += 2;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst > target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src--;
- dst[3] = (Sint16) sample0;
- dst[2] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src += 4;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst > target) {
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 2;
- dst[3] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- src += 4;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst > target) {
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 2;
- dst[7] = (Sint16) sample1;
- dst[6] = (Sint16) sample0;
- dst[5] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- src += 8;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 4;
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst > target) {
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 4;
- dst[7] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[6] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- src += 8;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 4;
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst > target) {
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 4;
- dst[15] = (Sint16) sample3;
- dst[14] = (Sint16) sample2;
- dst[13] = (Sint16) sample1;
- dst[12] = (Sint16) sample0;
- dst[11] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[6] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- src += 16;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 6;
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst > target) {
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 6;
- dst[11] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[10] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[9] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[8] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[7] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[6] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[5] = (Sint16) sample5;
- dst[4] = (Sint16) sample4;
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- src += 12;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 6;
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst > target) {
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 6;
- dst[23] = (Sint16) sample5;
- dst[22] = (Sint16) sample4;
- dst[21] = (Sint16) sample3;
- dst[20] = (Sint16) sample2;
- dst[19] = (Sint16) sample1;
- dst[18] = (Sint16) sample0;
- dst[17] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
- dst[16] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
- dst[15] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
- dst[14] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
- dst[13] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[12] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[11] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[10] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[9] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[8] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[7] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[6] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[5] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- src += 24;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 8;
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst > target) {
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 8;
- dst[15] = (Sint16) ((sample7 + last_sample7) >> 1);
- dst[14] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[13] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[12] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint16) sample7;
- dst[6] = (Sint16) sample6;
- dst[5] = (Sint16) sample5;
- dst[4] = (Sint16) sample4;
- dst[3] = (Sint16) sample3;
- dst[2] = (Sint16) sample2;
- dst[1] = (Sint16) sample1;
- dst[0] = (Sint16) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- src += 16;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
- const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint16 *target = ((const Sint16 *) cvt->buf) - 8;
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- while (dst > target) {
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- src -= 8;
- dst[31] = (Sint16) sample7;
- dst[30] = (Sint16) sample6;
- dst[29] = (Sint16) sample5;
- dst[28] = (Sint16) sample4;
- dst[27] = (Sint16) sample3;
- dst[26] = (Sint16) sample2;
- dst[25] = (Sint16) sample1;
- dst[24] = (Sint16) sample0;
- dst[23] = (Sint16) (((3 * sample7) + last_sample7) >> 2);
- dst[22] = (Sint16) (((3 * sample6) + last_sample6) >> 2);
- dst[21] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
- dst[20] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
- dst[19] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
- dst[18] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
- dst[17] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
- dst[16] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
- dst[15] = (Sint16) ((sample7 + last_sample7) >> 1);
- dst[14] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[13] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[12] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint16) ((sample7 + (3 * last_sample7)) >> 2);
- dst[6] = (Sint16) ((sample6 + (3 * last_sample6)) >> 2);
- dst[5] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint16 *dst = (Sint16 *) cvt->buf;
- const Sint16 *src = (Sint16 *) cvt->buf;
- const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
- Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- while (dst < target) {
- const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
- const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
- const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
- const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
- const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
- const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
- const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
- const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
- src += 32;
- dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst > target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src--;
- dst[1] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[0] = (Sint32) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src += 2;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst > target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src--;
- dst[3] = (Sint32) sample0;
- dst[2] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src += 4;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 2;
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst > target) {
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 2;
- dst[3] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- src += 4;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 2;
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst > target) {
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 2;
- dst[7] = (Sint32) sample1;
- dst[6] = (Sint32) sample0;
- dst[5] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- src += 8;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 4;
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst > target) {
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 4;
- dst[7] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[6] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- src += 8;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 4;
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst > target) {
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 4;
- dst[15] = (Sint32) sample3;
- dst[14] = (Sint32) sample2;
- dst[13] = (Sint32) sample1;
- dst[12] = (Sint32) sample0;
- dst[11] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[6] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- src += 16;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 6;
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst > target) {
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 6;
- dst[11] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[10] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[9] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[8] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[7] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[6] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[5] = (Sint32) sample5;
- dst[4] = (Sint32) sample4;
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- src += 12;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 6;
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst > target) {
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 6;
- dst[23] = (Sint32) sample5;
- dst[22] = (Sint32) sample4;
- dst[21] = (Sint32) sample3;
- dst[20] = (Sint32) sample2;
- dst[19] = (Sint32) sample1;
- dst[18] = (Sint32) sample0;
- dst[17] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
- dst[16] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
- dst[15] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
- dst[14] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
- dst[13] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[12] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[11] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[10] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[9] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[8] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[7] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[6] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[5] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- src += 24;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 8;
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst > target) {
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 8;
- dst[15] = (Sint32) ((sample7 + last_sample7) >> 1);
- dst[14] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[13] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[12] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint32) sample7;
- dst[6] = (Sint32) sample6;
- dst[5] = (Sint32) sample5;
- dst[4] = (Sint32) sample4;
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- src += 16;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 8;
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- while (dst > target) {
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- src -= 8;
- dst[31] = (Sint32) sample7;
- dst[30] = (Sint32) sample6;
- dst[29] = (Sint32) sample5;
- dst[28] = (Sint32) sample4;
- dst[27] = (Sint32) sample3;
- dst[26] = (Sint32) sample2;
- dst[25] = (Sint32) sample1;
- dst[24] = (Sint32) sample0;
- dst[23] = (Sint32) (((3 * sample7) + last_sample7) >> 2);
- dst[22] = (Sint32) (((3 * sample6) + last_sample6) >> 2);
- dst[21] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
- dst[20] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
- dst[19] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
- dst[18] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
- dst[17] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[16] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[15] = (Sint32) ((sample7 + last_sample7) >> 1);
- dst[14] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[13] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[12] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint32) ((sample7 + (3 * last_sample7)) >> 2);
- dst[6] = (Sint32) ((sample6 + (3 * last_sample6)) >> 2);
- dst[5] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
- src += 32;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst > target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src--;
- dst[1] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[0] = (Sint32) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src += 2;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst > target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src--;
- dst[3] = (Sint32) sample0;
- dst[2] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[1] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src += 4;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 2;
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst > target) {
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 2;
- dst[3] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- src += 4;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 2;
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst > target) {
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 2;
- dst[7] = (Sint32) sample1;
- dst[6] = (Sint32) sample0;
- dst[5] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[4] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[3] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- src += 8;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 4;
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst > target) {
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 4;
- dst[7] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[6] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- src += 8;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 4;
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst > target) {
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 4;
- dst[15] = (Sint32) sample3;
- dst[14] = (Sint32) sample2;
- dst[13] = (Sint32) sample1;
- dst[12] = (Sint32) sample0;
- dst[11] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
- dst[10] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
- dst[9] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[8] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[7] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[6] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[3] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- src += 16;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 6;
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst > target) {
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 6;
- dst[11] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[10] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[9] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[8] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[7] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[6] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[5] = (Sint32) sample5;
- dst[4] = (Sint32) sample4;
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- src += 12;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 6;
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst > target) {
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 6;
- dst[23] = (Sint32) sample5;
- dst[22] = (Sint32) sample4;
- dst[21] = (Sint32) sample3;
- dst[20] = (Sint32) sample2;
- dst[19] = (Sint32) sample1;
- dst[18] = (Sint32) sample0;
- dst[17] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
- dst[16] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
- dst[15] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
- dst[14] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
- dst[13] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[12] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[11] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[10] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[9] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[8] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[7] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[6] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[5] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- src += 24;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 8;
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst > target) {
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 8;
- dst[15] = (Sint32) ((sample7 + last_sample7) >> 1);
- dst[14] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[13] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[12] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint32) sample7;
- dst[6] = (Sint32) sample6;
- dst[5] = (Sint32) sample5;
- dst[4] = (Sint32) sample4;
- dst[3] = (Sint32) sample3;
- dst[2] = (Sint32) sample2;
- dst[1] = (Sint32) sample1;
- dst[0] = (Sint32) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- src += 16;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_S32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
- const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
- const Sint32 *target = ((const Sint32 *) cvt->buf) - 8;
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- while (dst > target) {
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- src -= 8;
- dst[31] = (Sint32) sample7;
- dst[30] = (Sint32) sample6;
- dst[29] = (Sint32) sample5;
- dst[28] = (Sint32) sample4;
- dst[27] = (Sint32) sample3;
- dst[26] = (Sint32) sample2;
- dst[25] = (Sint32) sample1;
- dst[24] = (Sint32) sample0;
- dst[23] = (Sint32) (((3 * sample7) + last_sample7) >> 2);
- dst[22] = (Sint32) (((3 * sample6) + last_sample6) >> 2);
- dst[21] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
- dst[20] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
- dst[19] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
- dst[18] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
- dst[17] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
- dst[16] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
- dst[15] = (Sint32) ((sample7 + last_sample7) >> 1);
- dst[14] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[13] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[12] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[7] = (Sint32) ((sample7 + (3 * last_sample7)) >> 2);
- dst[6] = (Sint32) ((sample6 + (3 * last_sample6)) >> 2);
- dst[5] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
- dst[4] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
- dst[3] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
- dst[2] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
- dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
- dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_S32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- Sint32 *dst = (Sint32 *) cvt->buf;
- const Sint32 *src = (Sint32 *) cvt->buf;
- const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
- Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- while (dst < target) {
- const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
- const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
- const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
- const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
- const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
- const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
- const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
- const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
- src += 32;
- dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
- dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
- dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
- dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
- dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
- dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
- dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
- dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 1;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
- const float *target = ((const float *) cvt->buf) - 1;
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst > target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src--;
- dst[1] = (float) ((sample0 + last_sample0) * 0.5);
- dst[0] = (float) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src += 2;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 1;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
- const float *target = ((const float *) cvt->buf) - 1;
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst > target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src--;
- dst[3] = (float) sample0;
- dst[2] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[1] = (float) ((sample0 + last_sample0) * 0.5);
- dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src += 4;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
- const float *target = ((const float *) cvt->buf) - 2;
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst > target) {
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 2;
- dst[3] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- src += 4;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
- const float *target = ((const float *) cvt->buf) - 2;
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst > target) {
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 2;
- dst[7] = (float) sample1;
- dst[6] = (float) sample0;
- dst[5] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[4] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[3] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- src += 8;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
- const float *target = ((const float *) cvt->buf) - 4;
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst > target) {
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 4;
- dst[7] = (float) ((sample3 + last_sample3) * 0.5);
- dst[6] = (float) ((sample2 + last_sample2) * 0.5);
- dst[5] = (float) ((sample1 + last_sample1) * 0.5);
- dst[4] = (float) ((sample0 + last_sample0) * 0.5);
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- src += 8;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
- const float *target = ((const float *) cvt->buf) - 4;
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst > target) {
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 4;
- dst[15] = (float) sample3;
- dst[14] = (float) sample2;
- dst[13] = (float) sample1;
- dst[12] = (float) sample0;
- dst[11] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
- dst[10] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
- dst[9] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[8] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[7] = (float) ((sample3 + last_sample3) * 0.5);
- dst[6] = (float) ((sample2 + last_sample2) * 0.5);
- dst[5] = (float) ((sample1 + last_sample1) * 0.5);
- dst[4] = (float) ((sample0 + last_sample0) * 0.5);
- dst[3] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
- dst[2] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
- dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- src += 16;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 6;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
- const float *target = ((const float *) cvt->buf) - 6;
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst > target) {
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 6;
- dst[11] = (float) ((sample5 + last_sample5) * 0.5);
- dst[10] = (float) ((sample4 + last_sample4) * 0.5);
- dst[9] = (float) ((sample3 + last_sample3) * 0.5);
- dst[8] = (float) ((sample2 + last_sample2) * 0.5);
- dst[7] = (float) ((sample1 + last_sample1) * 0.5);
- dst[6] = (float) ((sample0 + last_sample0) * 0.5);
- dst[5] = (float) sample5;
- dst[4] = (float) sample4;
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- src += 12;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 6;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
- const float *target = ((const float *) cvt->buf) - 6;
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst > target) {
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 6;
- dst[23] = (float) sample5;
- dst[22] = (float) sample4;
- dst[21] = (float) sample3;
- dst[20] = (float) sample2;
- dst[19] = (float) sample1;
- dst[18] = (float) sample0;
- dst[17] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
- dst[16] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
- dst[15] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
- dst[14] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
- dst[13] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[12] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[11] = (float) ((sample5 + last_sample5) * 0.5);
- dst[10] = (float) ((sample4 + last_sample4) * 0.5);
- dst[9] = (float) ((sample3 + last_sample3) * 0.5);
- dst[8] = (float) ((sample2 + last_sample2) * 0.5);
- dst[7] = (float) ((sample1 + last_sample1) * 0.5);
- dst[6] = (float) ((sample0 + last_sample0) * 0.5);
- dst[5] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
- dst[4] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
- dst[3] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
- dst[2] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
- dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- src += 24;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 8;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
- const float *target = ((const float *) cvt->buf) - 8;
- double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
- double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst > target) {
- const double sample7 = (double) SDL_SwapFloatLE(src[7]);
- const double sample6 = (double) SDL_SwapFloatLE(src[6]);
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 8;
- dst[15] = (float) ((sample7 + last_sample7) * 0.5);
- dst[14] = (float) ((sample6 + last_sample6) * 0.5);
- dst[13] = (float) ((sample5 + last_sample5) * 0.5);
- dst[12] = (float) ((sample4 + last_sample4) * 0.5);
- dst[11] = (float) ((sample3 + last_sample3) * 0.5);
- dst[10] = (float) ((sample2 + last_sample2) * 0.5);
- dst[9] = (float) ((sample1 + last_sample1) * 0.5);
- dst[8] = (float) ((sample0 + last_sample0) * 0.5);
- dst[7] = (float) sample7;
- dst[6] = (float) sample6;
- dst[5] = (float) sample5;
- dst[4] = (float) sample4;
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
- double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- const double sample6 = (double) SDL_SwapFloatLE(src[6]);
- const double sample7 = (double) SDL_SwapFloatLE(src[7]);
- src += 16;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- dst[6] = (float) ((sample6 + last_sample6) * 0.5);
- dst[7] = (float) ((sample7 + last_sample7) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 8;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
- const float *target = ((const float *) cvt->buf) - 8;
- double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
- double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- while (dst > target) {
- const double sample7 = (double) SDL_SwapFloatLE(src[7]);
- const double sample6 = (double) SDL_SwapFloatLE(src[6]);
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- src -= 8;
- dst[31] = (float) sample7;
- dst[30] = (float) sample6;
- dst[29] = (float) sample5;
- dst[28] = (float) sample4;
- dst[27] = (float) sample3;
- dst[26] = (float) sample2;
- dst[25] = (float) sample1;
- dst[24] = (float) sample0;
- dst[23] = (float) (((3.0 * sample7) + last_sample7) * 0.25);
- dst[22] = (float) (((3.0 * sample6) + last_sample6) * 0.25);
- dst[21] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
- dst[20] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
- dst[19] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
- dst[18] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
- dst[17] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[16] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[15] = (float) ((sample7 + last_sample7) * 0.5);
- dst[14] = (float) ((sample6 + last_sample6) * 0.5);
- dst[13] = (float) ((sample5 + last_sample5) * 0.5);
- dst[12] = (float) ((sample4 + last_sample4) * 0.5);
- dst[11] = (float) ((sample3 + last_sample3) * 0.5);
- dst[10] = (float) ((sample2 + last_sample2) * 0.5);
- dst[9] = (float) ((sample1 + last_sample1) * 0.5);
- dst[8] = (float) ((sample0 + last_sample0) * 0.5);
- dst[7] = (float) ((sample7 + (3.0 * last_sample7)) * 0.25);
- dst[6] = (float) ((sample6 + (3.0 * last_sample6)) * 0.25);
- dst[5] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
- dst[4] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
- dst[3] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
- dst[2] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
- dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
- double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
- double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatLE(src[0]);
- const double sample1 = (double) SDL_SwapFloatLE(src[1]);
- const double sample2 = (double) SDL_SwapFloatLE(src[2]);
- const double sample3 = (double) SDL_SwapFloatLE(src[3]);
- const double sample4 = (double) SDL_SwapFloatLE(src[4]);
- const double sample5 = (double) SDL_SwapFloatLE(src[5]);
- const double sample6 = (double) SDL_SwapFloatLE(src[6]);
- const double sample7 = (double) SDL_SwapFloatLE(src[7]);
- src += 32;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- dst[6] = (float) ((sample6 + last_sample6) * 0.5);
- dst[7] = (float) ((sample7 + last_sample7) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 1;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
- const float *target = ((const float *) cvt->buf) - 1;
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst > target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src--;
- dst[1] = (float) ((sample0 + last_sample0) * 0.5);
- dst[0] = (float) sample0;
- last_sample0 = sample0;
- dst -= 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src += 2;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 1;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
- const float *target = ((const float *) cvt->buf) - 1;
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst > target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src--;
- dst[3] = (float) sample0;
- dst[2] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[1] = (float) ((sample0 + last_sample0) * 0.5);
- dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 1 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src += 4;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- last_sample0 = sample0;
- dst++;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
- const float *target = ((const float *) cvt->buf) - 2;
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst > target) {
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 2;
- dst[3] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- src += 4;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 2;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
- const float *target = ((const float *) cvt->buf) - 2;
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst > target) {
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 2;
- dst[7] = (float) sample1;
- dst[6] = (float) sample0;
- dst[5] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[4] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[3] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 2 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- src += 8;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- dst += 2;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
- const float *target = ((const float *) cvt->buf) - 4;
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst > target) {
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 4;
- dst[7] = (float) ((sample3 + last_sample3) * 0.5);
- dst[6] = (float) ((sample2 + last_sample2) * 0.5);
- dst[5] = (float) ((sample1 + last_sample1) * 0.5);
- dst[4] = (float) ((sample0 + last_sample0) * 0.5);
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- src += 8;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 4;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
- const float *target = ((const float *) cvt->buf) - 4;
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst > target) {
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 4;
- dst[15] = (float) sample3;
- dst[14] = (float) sample2;
- dst[13] = (float) sample1;
- dst[12] = (float) sample0;
- dst[11] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
- dst[10] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
- dst[9] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[8] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[7] = (float) ((sample3 + last_sample3) * 0.5);
- dst[6] = (float) ((sample2 + last_sample2) * 0.5);
- dst[5] = (float) ((sample1 + last_sample1) * 0.5);
- dst[4] = (float) ((sample0 + last_sample0) * 0.5);
- dst[3] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
- dst[2] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
- dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 4 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- src += 16;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- dst += 4;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 6;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
- const float *target = ((const float *) cvt->buf) - 6;
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst > target) {
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 6;
- dst[11] = (float) ((sample5 + last_sample5) * 0.5);
- dst[10] = (float) ((sample4 + last_sample4) * 0.5);
- dst[9] = (float) ((sample3 + last_sample3) * 0.5);
- dst[8] = (float) ((sample2 + last_sample2) * 0.5);
- dst[7] = (float) ((sample1 + last_sample1) * 0.5);
- dst[6] = (float) ((sample0 + last_sample0) * 0.5);
- dst[5] = (float) sample5;
- dst[4] = (float) sample4;
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 12;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- src += 12;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 6;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
- const float *target = ((const float *) cvt->buf) - 6;
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst > target) {
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 6;
- dst[23] = (float) sample5;
- dst[22] = (float) sample4;
- dst[21] = (float) sample3;
- dst[20] = (float) sample2;
- dst[19] = (float) sample1;
- dst[18] = (float) sample0;
- dst[17] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
- dst[16] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
- dst[15] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
- dst[14] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
- dst[13] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[12] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[11] = (float) ((sample5 + last_sample5) * 0.5);
- dst[10] = (float) ((sample4 + last_sample4) * 0.5);
- dst[9] = (float) ((sample3 + last_sample3) * 0.5);
- dst[8] = (float) ((sample2 + last_sample2) * 0.5);
- dst[7] = (float) ((sample1 + last_sample1) * 0.5);
- dst[6] = (float) ((sample0 + last_sample0) * 0.5);
- dst[5] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
- dst[4] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
- dst[3] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
- dst[2] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
- dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 24;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 6 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- src += 24;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- dst += 6;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 2;
- float *dst = ((float *) (cvt->buf + dstsize)) - 8;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
- const float *target = ((const float *) cvt->buf) - 8;
- double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
- double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst > target) {
- const double sample7 = (double) SDL_SwapFloatBE(src[7]);
- const double sample6 = (double) SDL_SwapFloatBE(src[6]);
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 8;
- dst[15] = (float) ((sample7 + last_sample7) * 0.5);
- dst[14] = (float) ((sample6 + last_sample6) * 0.5);
- dst[13] = (float) ((sample5 + last_sample5) * 0.5);
- dst[12] = (float) ((sample4 + last_sample4) * 0.5);
- dst[11] = (float) ((sample3 + last_sample3) * 0.5);
- dst[10] = (float) ((sample2 + last_sample2) * 0.5);
- dst[9] = (float) ((sample1 + last_sample1) * 0.5);
- dst[8] = (float) ((sample0 + last_sample0) * 0.5);
- dst[7] = (float) sample7;
- dst[6] = (float) sample6;
- dst[5] = (float) sample5;
- dst[4] = (float) sample4;
- dst[3] = (float) sample3;
- dst[2] = (float) sample2;
- dst[1] = (float) sample1;
- dst[0] = (float) sample0;
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 16;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 2;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
- double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- const double sample6 = (double) SDL_SwapFloatBE(src[6]);
- const double sample7 = (double) SDL_SwapFloatBE(src[7]);
- src += 16;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- dst[6] = (float) ((sample6 + last_sample6) * 0.5);
- dst[7] = (float) ((sample7 + last_sample7) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Upsample_F32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt * 4;
- float *dst = ((float *) (cvt->buf + dstsize)) - 8;
- const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
- const float *target = ((const float *) cvt->buf) - 8;
- double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
- double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- while (dst > target) {
- const double sample7 = (double) SDL_SwapFloatBE(src[7]);
- const double sample6 = (double) SDL_SwapFloatBE(src[6]);
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- src -= 8;
- dst[31] = (float) sample7;
- dst[30] = (float) sample6;
- dst[29] = (float) sample5;
- dst[28] = (float) sample4;
- dst[27] = (float) sample3;
- dst[26] = (float) sample2;
- dst[25] = (float) sample1;
- dst[24] = (float) sample0;
- dst[23] = (float) (((3.0 * sample7) + last_sample7) * 0.25);
- dst[22] = (float) (((3.0 * sample6) + last_sample6) * 0.25);
- dst[21] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
- dst[20] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
- dst[19] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
- dst[18] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
- dst[17] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
- dst[16] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
- dst[15] = (float) ((sample7 + last_sample7) * 0.5);
- dst[14] = (float) ((sample6 + last_sample6) * 0.5);
- dst[13] = (float) ((sample5 + last_sample5) * 0.5);
- dst[12] = (float) ((sample4 + last_sample4) * 0.5);
- dst[11] = (float) ((sample3 + last_sample3) * 0.5);
- dst[10] = (float) ((sample2 + last_sample2) * 0.5);
- dst[9] = (float) ((sample1 + last_sample1) * 0.5);
- dst[8] = (float) ((sample0 + last_sample0) * 0.5);
- dst[7] = (float) ((sample7 + (3.0 * last_sample7)) * 0.25);
- dst[6] = (float) ((sample6 + (3.0 * last_sample6)) * 0.25);
- dst[5] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
- dst[4] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
- dst[3] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
- dst[2] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
- dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
- dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
- last_sample7 = sample7;
- last_sample6 = sample6;
- last_sample5 = sample5;
- last_sample4 = sample4;
- last_sample3 = sample3;
- last_sample2 = sample2;
- last_sample1 = sample1;
- last_sample0 = sample0;
- dst -= 32;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-static void SDLCALL
-SDL_Downsample_F32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
-{
-#if DEBUG_CONVERT
- fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 8 channels.\n");
-#endif
-
- const int srcsize = cvt->len_cvt;
- const int dstsize = cvt->len_cvt / 4;
- float *dst = (float *) cvt->buf;
- const float *src = (float *) cvt->buf;
- const float *target = (const float *) (cvt->buf + dstsize);
- double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
- double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
- double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
- double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
- double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
- double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
- double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
- double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
- while (dst < target) {
- const double sample0 = (double) SDL_SwapFloatBE(src[0]);
- const double sample1 = (double) SDL_SwapFloatBE(src[1]);
- const double sample2 = (double) SDL_SwapFloatBE(src[2]);
- const double sample3 = (double) SDL_SwapFloatBE(src[3]);
- const double sample4 = (double) SDL_SwapFloatBE(src[4]);
- const double sample5 = (double) SDL_SwapFloatBE(src[5]);
- const double sample6 = (double) SDL_SwapFloatBE(src[6]);
- const double sample7 = (double) SDL_SwapFloatBE(src[7]);
- src += 32;
- dst[0] = (float) ((sample0 + last_sample0) * 0.5);
- dst[1] = (float) ((sample1 + last_sample1) * 0.5);
- dst[2] = (float) ((sample2 + last_sample2) * 0.5);
- dst[3] = (float) ((sample3 + last_sample3) * 0.5);
- dst[4] = (float) ((sample4 + last_sample4) * 0.5);
- dst[5] = (float) ((sample5 + last_sample5) * 0.5);
- dst[6] = (float) ((sample6 + last_sample6) * 0.5);
- dst[7] = (float) ((sample7 + last_sample7) * 0.5);
- last_sample0 = sample0;
- last_sample1 = sample1;
- last_sample2 = sample2;
- last_sample3 = sample3;
- last_sample4 = sample4;
- last_sample5 = sample5;
- last_sample6 = sample6;
- last_sample7 = sample7;
- dst += 8;
- }
-
- cvt->len_cvt = dstsize;
- if (cvt->filters[++cvt->filter_index]) {
- cvt->filters[cvt->filter_index] (cvt, format);
- }
-}
-
-#endif /* !LESS_RESAMPLERS */
-#endif /* !NO_RESAMPLERS */
-
-
-const SDL_AudioRateFilters sdl_audio_rate_filters[] =
-{
-#if !NO_RESAMPLERS
- { AUDIO_U8, 1, 0, 0, SDL_Downsample_U8_1c },
- { AUDIO_U8, 1, 1, 0, SDL_Upsample_U8_1c },
- { AUDIO_U8, 2, 0, 0, SDL_Downsample_U8_2c },
- { AUDIO_U8, 2, 1, 0, SDL_Upsample_U8_2c },
- { AUDIO_U8, 4, 0, 0, SDL_Downsample_U8_4c },
- { AUDIO_U8, 4, 1, 0, SDL_Upsample_U8_4c },
- { AUDIO_U8, 6, 0, 0, SDL_Downsample_U8_6c },
- { AUDIO_U8, 6, 1, 0, SDL_Upsample_U8_6c },
- { AUDIO_U8, 8, 0, 0, SDL_Downsample_U8_8c },
- { AUDIO_U8, 8, 1, 0, SDL_Upsample_U8_8c },
- { AUDIO_S8, 1, 0, 0, SDL_Downsample_S8_1c },
- { AUDIO_S8, 1, 1, 0, SDL_Upsample_S8_1c },
- { AUDIO_S8, 2, 0, 0, SDL_Downsample_S8_2c },
- { AUDIO_S8, 2, 1, 0, SDL_Upsample_S8_2c },
- { AUDIO_S8, 4, 0, 0, SDL_Downsample_S8_4c },
- { AUDIO_S8, 4, 1, 0, SDL_Upsample_S8_4c },
- { AUDIO_S8, 6, 0, 0, SDL_Downsample_S8_6c },
- { AUDIO_S8, 6, 1, 0, SDL_Upsample_S8_6c },
- { AUDIO_S8, 8, 0, 0, SDL_Downsample_S8_8c },
- { AUDIO_S8, 8, 1, 0, SDL_Upsample_S8_8c },
- { AUDIO_U16LSB, 1, 0, 0, SDL_Downsample_U16LSB_1c },
- { AUDIO_U16LSB, 1, 1, 0, SDL_Upsample_U16LSB_1c },
- { AUDIO_U16LSB, 2, 0, 0, SDL_Downsample_U16LSB_2c },
- { AUDIO_U16LSB, 2, 1, 0, SDL_Upsample_U16LSB_2c },
- { AUDIO_U16LSB, 4, 0, 0, SDL_Downsample_U16LSB_4c },
- { AUDIO_U16LSB, 4, 1, 0, SDL_Upsample_U16LSB_4c },
- { AUDIO_U16LSB, 6, 0, 0, SDL_Downsample_U16LSB_6c },
- { AUDIO_U16LSB, 6, 1, 0, SDL_Upsample_U16LSB_6c },
- { AUDIO_U16LSB, 8, 0, 0, SDL_Downsample_U16LSB_8c },
- { AUDIO_U16LSB, 8, 1, 0, SDL_Upsample_U16LSB_8c },
- { AUDIO_S16LSB, 1, 0, 0, SDL_Downsample_S16LSB_1c },
- { AUDIO_S16LSB, 1, 1, 0, SDL_Upsample_S16LSB_1c },
- { AUDIO_S16LSB, 2, 0, 0, SDL_Downsample_S16LSB_2c },
- { AUDIO_S16LSB, 2, 1, 0, SDL_Upsample_S16LSB_2c },
- { AUDIO_S16LSB, 4, 0, 0, SDL_Downsample_S16LSB_4c },
- { AUDIO_S16LSB, 4, 1, 0, SDL_Upsample_S16LSB_4c },
- { AUDIO_S16LSB, 6, 0, 0, SDL_Downsample_S16LSB_6c },
- { AUDIO_S16LSB, 6, 1, 0, SDL_Upsample_S16LSB_6c },
- { AUDIO_S16LSB, 8, 0, 0, SDL_Downsample_S16LSB_8c },
- { AUDIO_S16LSB, 8, 1, 0, SDL_Upsample_S16LSB_8c },
- { AUDIO_U16MSB, 1, 0, 0, SDL_Downsample_U16MSB_1c },
- { AUDIO_U16MSB, 1, 1, 0, SDL_Upsample_U16MSB_1c },
- { AUDIO_U16MSB, 2, 0, 0, SDL_Downsample_U16MSB_2c },
- { AUDIO_U16MSB, 2, 1, 0, SDL_Upsample_U16MSB_2c },
- { AUDIO_U16MSB, 4, 0, 0, SDL_Downsample_U16MSB_4c },
- { AUDIO_U16MSB, 4, 1, 0, SDL_Upsample_U16MSB_4c },
- { AUDIO_U16MSB, 6, 0, 0, SDL_Downsample_U16MSB_6c },
- { AUDIO_U16MSB, 6, 1, 0, SDL_Upsample_U16MSB_6c },
- { AUDIO_U16MSB, 8, 0, 0, SDL_Downsample_U16MSB_8c },
- { AUDIO_U16MSB, 8, 1, 0, SDL_Upsample_U16MSB_8c },
- { AUDIO_S16MSB, 1, 0, 0, SDL_Downsample_S16MSB_1c },
- { AUDIO_S16MSB, 1, 1, 0, SDL_Upsample_S16MSB_1c },
- { AUDIO_S16MSB, 2, 0, 0, SDL_Downsample_S16MSB_2c },
- { AUDIO_S16MSB, 2, 1, 0, SDL_Upsample_S16MSB_2c },
- { AUDIO_S16MSB, 4, 0, 0, SDL_Downsample_S16MSB_4c },
- { AUDIO_S16MSB, 4, 1, 0, SDL_Upsample_S16MSB_4c },
- { AUDIO_S16MSB, 6, 0, 0, SDL_Downsample_S16MSB_6c },
- { AUDIO_S16MSB, 6, 1, 0, SDL_Upsample_S16MSB_6c },
- { AUDIO_S16MSB, 8, 0, 0, SDL_Downsample_S16MSB_8c },
- { AUDIO_S16MSB, 8, 1, 0, SDL_Upsample_S16MSB_8c },
- { AUDIO_S32LSB, 1, 0, 0, SDL_Downsample_S32LSB_1c },
- { AUDIO_S32LSB, 1, 1, 0, SDL_Upsample_S32LSB_1c },
- { AUDIO_S32LSB, 2, 0, 0, SDL_Downsample_S32LSB_2c },
- { AUDIO_S32LSB, 2, 1, 0, SDL_Upsample_S32LSB_2c },
- { AUDIO_S32LSB, 4, 0, 0, SDL_Downsample_S32LSB_4c },
- { AUDIO_S32LSB, 4, 1, 0, SDL_Upsample_S32LSB_4c },
- { AUDIO_S32LSB, 6, 0, 0, SDL_Downsample_S32LSB_6c },
- { AUDIO_S32LSB, 6, 1, 0, SDL_Upsample_S32LSB_6c },
- { AUDIO_S32LSB, 8, 0, 0, SDL_Downsample_S32LSB_8c },
- { AUDIO_S32LSB, 8, 1, 0, SDL_Upsample_S32LSB_8c },
- { AUDIO_S32MSB, 1, 0, 0, SDL_Downsample_S32MSB_1c },
- { AUDIO_S32MSB, 1, 1, 0, SDL_Upsample_S32MSB_1c },
- { AUDIO_S32MSB, 2, 0, 0, SDL_Downsample_S32MSB_2c },
- { AUDIO_S32MSB, 2, 1, 0, SDL_Upsample_S32MSB_2c },
- { AUDIO_S32MSB, 4, 0, 0, SDL_Downsample_S32MSB_4c },
- { AUDIO_S32MSB, 4, 1, 0, SDL_Upsample_S32MSB_4c },
- { AUDIO_S32MSB, 6, 0, 0, SDL_Downsample_S32MSB_6c },
- { AUDIO_S32MSB, 6, 1, 0, SDL_Upsample_S32MSB_6c },
- { AUDIO_S32MSB, 8, 0, 0, SDL_Downsample_S32MSB_8c },
- { AUDIO_S32MSB, 8, 1, 0, SDL_Upsample_S32MSB_8c },
- { AUDIO_F32LSB, 1, 0, 0, SDL_Downsample_F32LSB_1c },
- { AUDIO_F32LSB, 1, 1, 0, SDL_Upsample_F32LSB_1c },
- { AUDIO_F32LSB, 2, 0, 0, SDL_Downsample_F32LSB_2c },
- { AUDIO_F32LSB, 2, 1, 0, SDL_Upsample_F32LSB_2c },
- { AUDIO_F32LSB, 4, 0, 0, SDL_Downsample_F32LSB_4c },
- { AUDIO_F32LSB, 4, 1, 0, SDL_Upsample_F32LSB_4c },
- { AUDIO_F32LSB, 6, 0, 0, SDL_Downsample_F32LSB_6c },
- { AUDIO_F32LSB, 6, 1, 0, SDL_Upsample_F32LSB_6c },
- { AUDIO_F32LSB, 8, 0, 0, SDL_Downsample_F32LSB_8c },
- { AUDIO_F32LSB, 8, 1, 0, SDL_Upsample_F32LSB_8c },
- { AUDIO_F32MSB, 1, 0, 0, SDL_Downsample_F32MSB_1c },
- { AUDIO_F32MSB, 1, 1, 0, SDL_Upsample_F32MSB_1c },
- { AUDIO_F32MSB, 2, 0, 0, SDL_Downsample_F32MSB_2c },
- { AUDIO_F32MSB, 2, 1, 0, SDL_Upsample_F32MSB_2c },
- { AUDIO_F32MSB, 4, 0, 0, SDL_Downsample_F32MSB_4c },
- { AUDIO_F32MSB, 4, 1, 0, SDL_Upsample_F32MSB_4c },
- { AUDIO_F32MSB, 6, 0, 0, SDL_Downsample_F32MSB_6c },
- { AUDIO_F32MSB, 6, 1, 0, SDL_Upsample_F32MSB_6c },
- { AUDIO_F32MSB, 8, 0, 0, SDL_Downsample_F32MSB_8c },
- { AUDIO_F32MSB, 8, 1, 0, SDL_Upsample_F32MSB_8c },
-#if !LESS_RESAMPLERS
- { AUDIO_U8, 1, 0, 2, SDL_Downsample_U8_1c_x2 },
- { AUDIO_U8, 1, 1, 2, SDL_Upsample_U8_1c_x2 },
- { AUDIO_U8, 1, 0, 4, SDL_Downsample_U8_1c_x4 },
- { AUDIO_U8, 1, 1, 4, SDL_Upsample_U8_1c_x4 },
- { AUDIO_U8, 2, 0, 2, SDL_Downsample_U8_2c_x2 },
- { AUDIO_U8, 2, 1, 2, SDL_Upsample_U8_2c_x2 },
- { AUDIO_U8, 2, 0, 4, SDL_Downsample_U8_2c_x4 },
- { AUDIO_U8, 2, 1, 4, SDL_Upsample_U8_2c_x4 },
- { AUDIO_U8, 4, 0, 2, SDL_Downsample_U8_4c_x2 },
- { AUDIO_U8, 4, 1, 2, SDL_Upsample_U8_4c_x2 },
- { AUDIO_U8, 4, 0, 4, SDL_Downsample_U8_4c_x4 },
- { AUDIO_U8, 4, 1, 4, SDL_Upsample_U8_4c_x4 },
- { AUDIO_U8, 6, 0, 2, SDL_Downsample_U8_6c_x2 },
- { AUDIO_U8, 6, 1, 2, SDL_Upsample_U8_6c_x2 },
- { AUDIO_U8, 6, 0, 4, SDL_Downsample_U8_6c_x4 },
- { AUDIO_U8, 6, 1, 4, SDL_Upsample_U8_6c_x4 },
- { AUDIO_U8, 8, 0, 2, SDL_Downsample_U8_8c_x2 },
- { AUDIO_U8, 8, 1, 2, SDL_Upsample_U8_8c_x2 },
- { AUDIO_U8, 8, 0, 4, SDL_Downsample_U8_8c_x4 },
- { AUDIO_U8, 8, 1, 4, SDL_Upsample_U8_8c_x4 },
- { AUDIO_S8, 1, 0, 2, SDL_Downsample_S8_1c_x2 },
- { AUDIO_S8, 1, 1, 2, SDL_Upsample_S8_1c_x2 },
- { AUDIO_S8, 1, 0, 4, SDL_Downsample_S8_1c_x4 },
- { AUDIO_S8, 1, 1, 4, SDL_Upsample_S8_1c_x4 },
- { AUDIO_S8, 2, 0, 2, SDL_Downsample_S8_2c_x2 },
- { AUDIO_S8, 2, 1, 2, SDL_Upsample_S8_2c_x2 },
- { AUDIO_S8, 2, 0, 4, SDL_Downsample_S8_2c_x4 },
- { AUDIO_S8, 2, 1, 4, SDL_Upsample_S8_2c_x4 },
- { AUDIO_S8, 4, 0, 2, SDL_Downsample_S8_4c_x2 },
- { AUDIO_S8, 4, 1, 2, SDL_Upsample_S8_4c_x2 },
- { AUDIO_S8, 4, 0, 4, SDL_Downsample_S8_4c_x4 },
- { AUDIO_S8, 4, 1, 4, SDL_Upsample_S8_4c_x4 },
- { AUDIO_S8, 6, 0, 2, SDL_Downsample_S8_6c_x2 },
- { AUDIO_S8, 6, 1, 2, SDL_Upsample_S8_6c_x2 },
- { AUDIO_S8, 6, 0, 4, SDL_Downsample_S8_6c_x4 },
- { AUDIO_S8, 6, 1, 4, SDL_Upsample_S8_6c_x4 },
- { AUDIO_S8, 8, 0, 2, SDL_Downsample_S8_8c_x2 },
- { AUDIO_S8, 8, 1, 2, SDL_Upsample_S8_8c_x2 },
- { AUDIO_S8, 8, 0, 4, SDL_Downsample_S8_8c_x4 },
- { AUDIO_S8, 8, 1, 4, SDL_Upsample_S8_8c_x4 },
- { AUDIO_U16LSB, 1, 0, 2, SDL_Downsample_U16LSB_1c_x2 },
- { AUDIO_U16LSB, 1, 1, 2, SDL_Upsample_U16LSB_1c_x2 },
- { AUDIO_U16LSB, 1, 0, 4, SDL_Downsample_U16LSB_1c_x4 },
- { AUDIO_U16LSB, 1, 1, 4, SDL_Upsample_U16LSB_1c_x4 },
- { AUDIO_U16LSB, 2, 0, 2, SDL_Downsample_U16LSB_2c_x2 },
- { AUDIO_U16LSB, 2, 1, 2, SDL_Upsample_U16LSB_2c_x2 },
- { AUDIO_U16LSB, 2, 0, 4, SDL_Downsample_U16LSB_2c_x4 },
- { AUDIO_U16LSB, 2, 1, 4, SDL_Upsample_U16LSB_2c_x4 },
- { AUDIO_U16LSB, 4, 0, 2, SDL_Downsample_U16LSB_4c_x2 },
- { AUDIO_U16LSB, 4, 1, 2, SDL_Upsample_U16LSB_4c_x2 },
- { AUDIO_U16LSB, 4, 0, 4, SDL_Downsample_U16LSB_4c_x4 },
- { AUDIO_U16LSB, 4, 1, 4, SDL_Upsample_U16LSB_4c_x4 },
- { AUDIO_U16LSB, 6, 0, 2, SDL_Downsample_U16LSB_6c_x2 },
- { AUDIO_U16LSB, 6, 1, 2, SDL_Upsample_U16LSB_6c_x2 },
- { AUDIO_U16LSB, 6, 0, 4, SDL_Downsample_U16LSB_6c_x4 },
- { AUDIO_U16LSB, 6, 1, 4, SDL_Upsample_U16LSB_6c_x4 },
- { AUDIO_U16LSB, 8, 0, 2, SDL_Downsample_U16LSB_8c_x2 },
- { AUDIO_U16LSB, 8, 1, 2, SDL_Upsample_U16LSB_8c_x2 },
- { AUDIO_U16LSB, 8, 0, 4, SDL_Downsample_U16LSB_8c_x4 },
- { AUDIO_U16LSB, 8, 1, 4, SDL_Upsample_U16LSB_8c_x4 },
- { AUDIO_S16LSB, 1, 0, 2, SDL_Downsample_S16LSB_1c_x2 },
- { AUDIO_S16LSB, 1, 1, 2, SDL_Upsample_S16LSB_1c_x2 },
- { AUDIO_S16LSB, 1, 0, 4, SDL_Downsample_S16LSB_1c_x4 },
- { AUDIO_S16LSB, 1, 1, 4, SDL_Upsample_S16LSB_1c_x4 },
- { AUDIO_S16LSB, 2, 0, 2, SDL_Downsample_S16LSB_2c_x2 },
- { AUDIO_S16LSB, 2, 1, 2, SDL_Upsample_S16LSB_2c_x2 },
- { AUDIO_S16LSB, 2, 0, 4, SDL_Downsample_S16LSB_2c_x4 },
- { AUDIO_S16LSB, 2, 1, 4, SDL_Upsample_S16LSB_2c_x4 },
- { AUDIO_S16LSB, 4, 0, 2, SDL_Downsample_S16LSB_4c_x2 },
- { AUDIO_S16LSB, 4, 1, 2, SDL_Upsample_S16LSB_4c_x2 },
- { AUDIO_S16LSB, 4, 0, 4, SDL_Downsample_S16LSB_4c_x4 },
- { AUDIO_S16LSB, 4, 1, 4, SDL_Upsample_S16LSB_4c_x4 },
- { AUDIO_S16LSB, 6, 0, 2, SDL_Downsample_S16LSB_6c_x2 },
- { AUDIO_S16LSB, 6, 1, 2, SDL_Upsample_S16LSB_6c_x2 },
- { AUDIO_S16LSB, 6, 0, 4, SDL_Downsample_S16LSB_6c_x4 },
- { AUDIO_S16LSB, 6, 1, 4, SDL_Upsample_S16LSB_6c_x4 },
- { AUDIO_S16LSB, 8, 0, 2, SDL_Downsample_S16LSB_8c_x2 },
- { AUDIO_S16LSB, 8, 1, 2, SDL_Upsample_S16LSB_8c_x2 },
- { AUDIO_S16LSB, 8, 0, 4, SDL_Downsample_S16LSB_8c_x4 },
- { AUDIO_S16LSB, 8, 1, 4, SDL_Upsample_S16LSB_8c_x4 },
- { AUDIO_U16MSB, 1, 0, 2, SDL_Downsample_U16MSB_1c_x2 },
- { AUDIO_U16MSB, 1, 1, 2, SDL_Upsample_U16MSB_1c_x2 },
- { AUDIO_U16MSB, 1, 0, 4, SDL_Downsample_U16MSB_1c_x4 },
- { AUDIO_U16MSB, 1, 1, 4, SDL_Upsample_U16MSB_1c_x4 },
- { AUDIO_U16MSB, 2, 0, 2, SDL_Downsample_U16MSB_2c_x2 },
- { AUDIO_U16MSB, 2, 1, 2, SDL_Upsample_U16MSB_2c_x2 },
- { AUDIO_U16MSB, 2, 0, 4, SDL_Downsample_U16MSB_2c_x4 },
- { AUDIO_U16MSB, 2, 1, 4, SDL_Upsample_U16MSB_2c_x4 },
- { AUDIO_U16MSB, 4, 0, 2, SDL_Downsample_U16MSB_4c_x2 },
- { AUDIO_U16MSB, 4, 1, 2, SDL_Upsample_U16MSB_4c_x2 },
- { AUDIO_U16MSB, 4, 0, 4, SDL_Downsample_U16MSB_4c_x4 },
- { AUDIO_U16MSB, 4, 1, 4, SDL_Upsample_U16MSB_4c_x4 },
- { AUDIO_U16MSB, 6, 0, 2, SDL_Downsample_U16MSB_6c_x2 },
- { AUDIO_U16MSB, 6, 1, 2, SDL_Upsample_U16MSB_6c_x2 },
- { AUDIO_U16MSB, 6, 0, 4, SDL_Downsample_U16MSB_6c_x4 },
- { AUDIO_U16MSB, 6, 1, 4, SDL_Upsample_U16MSB_6c_x4 },
- { AUDIO_U16MSB, 8, 0, 2, SDL_Downsample_U16MSB_8c_x2 },
- { AUDIO_U16MSB, 8, 1, 2, SDL_Upsample_U16MSB_8c_x2 },
- { AUDIO_U16MSB, 8, 0, 4, SDL_Downsample_U16MSB_8c_x4 },
- { AUDIO_U16MSB, 8, 1, 4, SDL_Upsample_U16MSB_8c_x4 },
- { AUDIO_S16MSB, 1, 0, 2, SDL_Downsample_S16MSB_1c_x2 },
- { AUDIO_S16MSB, 1, 1, 2, SDL_Upsample_S16MSB_1c_x2 },
- { AUDIO_S16MSB, 1, 0, 4, SDL_Downsample_S16MSB_1c_x4 },
- { AUDIO_S16MSB, 1, 1, 4, SDL_Upsample_S16MSB_1c_x4 },
- { AUDIO_S16MSB, 2, 0, 2, SDL_Downsample_S16MSB_2c_x2 },
- { AUDIO_S16MSB, 2, 1, 2, SDL_Upsample_S16MSB_2c_x2 },
- { AUDIO_S16MSB, 2, 0, 4, SDL_Downsample_S16MSB_2c_x4 },
- { AUDIO_S16MSB, 2, 1, 4, SDL_Upsample_S16MSB_2c_x4 },
- { AUDIO_S16MSB, 4, 0, 2, SDL_Downsample_S16MSB_4c_x2 },
- { AUDIO_S16MSB, 4, 1, 2, SDL_Upsample_S16MSB_4c_x2 },
- { AUDIO_S16MSB, 4, 0, 4, SDL_Downsample_S16MSB_4c_x4 },
- { AUDIO_S16MSB, 4, 1, 4, SDL_Upsample_S16MSB_4c_x4 },
- { AUDIO_S16MSB, 6, 0, 2, SDL_Downsample_S16MSB_6c_x2 },
- { AUDIO_S16MSB, 6, 1, 2, SDL_Upsample_S16MSB_6c_x2 },
- { AUDIO_S16MSB, 6, 0, 4, SDL_Downsample_S16MSB_6c_x4 },
- { AUDIO_S16MSB, 6, 1, 4, SDL_Upsample_S16MSB_6c_x4 },
- { AUDIO_S16MSB, 8, 0, 2, SDL_Downsample_S16MSB_8c_x2 },
- { AUDIO_S16MSB, 8, 1, 2, SDL_Upsample_S16MSB_8c_x2 },
- { AUDIO_S16MSB, 8, 0, 4, SDL_Downsample_S16MSB_8c_x4 },
- { AUDIO_S16MSB, 8, 1, 4, SDL_Upsample_S16MSB_8c_x4 },
- { AUDIO_S32LSB, 1, 0, 2, SDL_Downsample_S32LSB_1c_x2 },
- { AUDIO_S32LSB, 1, 1, 2, SDL_Upsample_S32LSB_1c_x2 },
- { AUDIO_S32LSB, 1, 0, 4, SDL_Downsample_S32LSB_1c_x4 },
- { AUDIO_S32LSB, 1, 1, 4, SDL_Upsample_S32LSB_1c_x4 },
- { AUDIO_S32LSB, 2, 0, 2, SDL_Downsample_S32LSB_2c_x2 },
- { AUDIO_S32LSB, 2, 1, 2, SDL_Upsample_S32LSB_2c_x2 },
- { AUDIO_S32LSB, 2, 0, 4, SDL_Downsample_S32LSB_2c_x4 },
- { AUDIO_S32LSB, 2, 1, 4, SDL_Upsample_S32LSB_2c_x4 },
- { AUDIO_S32LSB, 4, 0, 2, SDL_Downsample_S32LSB_4c_x2 },
- { AUDIO_S32LSB, 4, 1, 2, SDL_Upsample_S32LSB_4c_x2 },
- { AUDIO_S32LSB, 4, 0, 4, SDL_Downsample_S32LSB_4c_x4 },
- { AUDIO_S32LSB, 4, 1, 4, SDL_Upsample_S32LSB_4c_x4 },
- { AUDIO_S32LSB, 6, 0, 2, SDL_Downsample_S32LSB_6c_x2 },
- { AUDIO_S32LSB, 6, 1, 2, SDL_Upsample_S32LSB_6c_x2 },
- { AUDIO_S32LSB, 6, 0, 4, SDL_Downsample_S32LSB_6c_x4 },
- { AUDIO_S32LSB, 6, 1, 4, SDL_Upsample_S32LSB_6c_x4 },
- { AUDIO_S32LSB, 8, 0, 2, SDL_Downsample_S32LSB_8c_x2 },
- { AUDIO_S32LSB, 8, 1, 2, SDL_Upsample_S32LSB_8c_x2 },
- { AUDIO_S32LSB, 8, 0, 4, SDL_Downsample_S32LSB_8c_x4 },
- { AUDIO_S32LSB, 8, 1, 4, SDL_Upsample_S32LSB_8c_x4 },
- { AUDIO_S32MSB, 1, 0, 2, SDL_Downsample_S32MSB_1c_x2 },
- { AUDIO_S32MSB, 1, 1, 2, SDL_Upsample_S32MSB_1c_x2 },
- { AUDIO_S32MSB, 1, 0, 4, SDL_Downsample_S32MSB_1c_x4 },
- { AUDIO_S32MSB, 1, 1, 4, SDL_Upsample_S32MSB_1c_x4 },
- { AUDIO_S32MSB, 2, 0, 2, SDL_Downsample_S32MSB_2c_x2 },
- { AUDIO_S32MSB, 2, 1, 2, SDL_Upsample_S32MSB_2c_x2 },
- { AUDIO_S32MSB, 2, 0, 4, SDL_Downsample_S32MSB_2c_x4 },
- { AUDIO_S32MSB, 2, 1, 4, SDL_Upsample_S32MSB_2c_x4 },
- { AUDIO_S32MSB, 4, 0, 2, SDL_Downsample_S32MSB_4c_x2 },
- { AUDIO_S32MSB, 4, 1, 2, SDL_Upsample_S32MSB_4c_x2 },
- { AUDIO_S32MSB, 4, 0, 4, SDL_Downsample_S32MSB_4c_x4 },
- { AUDIO_S32MSB, 4, 1, 4, SDL_Upsample_S32MSB_4c_x4 },
- { AUDIO_S32MSB, 6, 0, 2, SDL_Downsample_S32MSB_6c_x2 },
- { AUDIO_S32MSB, 6, 1, 2, SDL_Upsample_S32MSB_6c_x2 },
- { AUDIO_S32MSB, 6, 0, 4, SDL_Downsample_S32MSB_6c_x4 },
- { AUDIO_S32MSB, 6, 1, 4, SDL_Upsample_S32MSB_6c_x4 },
- { AUDIO_S32MSB, 8, 0, 2, SDL_Downsample_S32MSB_8c_x2 },
- { AUDIO_S32MSB, 8, 1, 2, SDL_Upsample_S32MSB_8c_x2 },
- { AUDIO_S32MSB, 8, 0, 4, SDL_Downsample_S32MSB_8c_x4 },
- { AUDIO_S32MSB, 8, 1, 4, SDL_Upsample_S32MSB_8c_x4 },
- { AUDIO_F32LSB, 1, 0, 2, SDL_Downsample_F32LSB_1c_x2 },
- { AUDIO_F32LSB, 1, 1, 2, SDL_Upsample_F32LSB_1c_x2 },
- { AUDIO_F32LSB, 1, 0, 4, SDL_Downsample_F32LSB_1c_x4 },
- { AUDIO_F32LSB, 1, 1, 4, SDL_Upsample_F32LSB_1c_x4 },
- { AUDIO_F32LSB, 2, 0, 2, SDL_Downsample_F32LSB_2c_x2 },
- { AUDIO_F32LSB, 2, 1, 2, SDL_Upsample_F32LSB_2c_x2 },
- { AUDIO_F32LSB, 2, 0, 4, SDL_Downsample_F32LSB_2c_x4 },
- { AUDIO_F32LSB, 2, 1, 4, SDL_Upsample_F32LSB_2c_x4 },
- { AUDIO_F32LSB, 4, 0, 2, SDL_Downsample_F32LSB_4c_x2 },
- { AUDIO_F32LSB, 4, 1, 2, SDL_Upsample_F32LSB_4c_x2 },
- { AUDIO_F32LSB, 4, 0, 4, SDL_Downsample_F32LSB_4c_x4 },
- { AUDIO_F32LSB, 4, 1, 4, SDL_Upsample_F32LSB_4c_x4 },
- { AUDIO_F32LSB, 6, 0, 2, SDL_Downsample_F32LSB_6c_x2 },
- { AUDIO_F32LSB, 6, 1, 2, SDL_Upsample_F32LSB_6c_x2 },
- { AUDIO_F32LSB, 6, 0, 4, SDL_Downsample_F32LSB_6c_x4 },
- { AUDIO_F32LSB, 6, 1, 4, SDL_Upsample_F32LSB_6c_x4 },
- { AUDIO_F32LSB, 8, 0, 2, SDL_Downsample_F32LSB_8c_x2 },
- { AUDIO_F32LSB, 8, 1, 2, SDL_Upsample_F32LSB_8c_x2 },
- { AUDIO_F32LSB, 8, 0, 4, SDL_Downsample_F32LSB_8c_x4 },
- { AUDIO_F32LSB, 8, 1, 4, SDL_Upsample_F32LSB_8c_x4 },
- { AUDIO_F32MSB, 1, 0, 2, SDL_Downsample_F32MSB_1c_x2 },
- { AUDIO_F32MSB, 1, 1, 2, SDL_Upsample_F32MSB_1c_x2 },
- { AUDIO_F32MSB, 1, 0, 4, SDL_Downsample_F32MSB_1c_x4 },
- { AUDIO_F32MSB, 1, 1, 4, SDL_Upsample_F32MSB_1c_x4 },
- { AUDIO_F32MSB, 2, 0, 2, SDL_Downsample_F32MSB_2c_x2 },
- { AUDIO_F32MSB, 2, 1, 2, SDL_Upsample_F32MSB_2c_x2 },
- { AUDIO_F32MSB, 2, 0, 4, SDL_Downsample_F32MSB_2c_x4 },
- { AUDIO_F32MSB, 2, 1, 4, SDL_Upsample_F32MSB_2c_x4 },
- { AUDIO_F32MSB, 4, 0, 2, SDL_Downsample_F32MSB_4c_x2 },
- { AUDIO_F32MSB, 4, 1, 2, SDL_Upsample_F32MSB_4c_x2 },
- { AUDIO_F32MSB, 4, 0, 4, SDL_Downsample_F32MSB_4c_x4 },
- { AUDIO_F32MSB, 4, 1, 4, SDL_Upsample_F32MSB_4c_x4 },
- { AUDIO_F32MSB, 6, 0, 2, SDL_Downsample_F32MSB_6c_x2 },
- { AUDIO_F32MSB, 6, 1, 2, SDL_Upsample_F32MSB_6c_x2 },
- { AUDIO_F32MSB, 6, 0, 4, SDL_Downsample_F32MSB_6c_x4 },
- { AUDIO_F32MSB, 6, 1, 4, SDL_Upsample_F32MSB_6c_x4 },
- { AUDIO_F32MSB, 8, 0, 2, SDL_Downsample_F32MSB_8c_x2 },
- { AUDIO_F32MSB, 8, 1, 2, SDL_Upsample_F32MSB_8c_x2 },
- { AUDIO_F32MSB, 8, 0, 4, SDL_Downsample_F32MSB_8c_x4 },
- { AUDIO_F32MSB, 8, 1, 4, SDL_Upsample_F32MSB_8c_x4 },
-#endif /* !LESS_RESAMPLERS */
-#endif /* !NO_RESAMPLERS */
- { 0, 0, 0, 0, NULL }
-};
-
-/* 390 converters generated. */
-
-/* *INDENT-ON* */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/macosx/plugins/Common/SDL/src/audio/SDL_mixer.c b/macosx/plugins/Common/SDL/src/audio/SDL_mixer.c
deleted file mode 100644
index 04a6f2b1..00000000
--- a/macosx/plugins/Common/SDL/src/audio/SDL_mixer.c
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2010 Sam Lantinga
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Sam Lantinga
- slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* This provides the default mixing callback for the SDL audio routines */
-
-#include "SDL_audio.h"
-#include "SDL_sysaudio.h"
-
-/* This table is used to add two sound values together and pin
- * the value to avoid overflow. (used with permission from ARDI)
- * Changed to use 0xFE instead of 0xFF for better sound quality.
- */
-static const Uint8 mix8[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03,
- 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
- 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
- 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
- 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
- 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
- 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
- 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B,
- 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
- 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71,
- 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C,
- 0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92,
- 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D,
- 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8,
- 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
- 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE,
- 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9,
- 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4,
- 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
- 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA,
- 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5,
- 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
- 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE
-};
-
-/* The volume ranges from 0 - 128 */
-#define ADJUST_VOLUME(s, v) (s = (s*v)/SDL_MIX_MAXVOLUME)
-#define ADJUST_VOLUME_U8(s, v) (s = (((s-128)*v)/SDL_MIX_MAXVOLUME)+128)
-
-
-void
-SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
- Uint32 len, int volume)
-{
- if (volume == 0) {
- return;
- }
-
- switch (format) {
-
- case AUDIO_U8:
- {
- Uint8 src_sample;
-
- while (len--) {
- src_sample = *src;
- ADJUST_VOLUME_U8(src_sample, volume);
- *dst = mix8[*dst + src_sample];
- ++dst;
- ++src;
- }
- }
- break;
-
- case AUDIO_S8:
- {
- {
- Sint8 *dst8, *src8;
- Sint8 src_sample;
- int dst_sample;
- const int max_audioval = ((1 << (8 - 1)) - 1);
- const int min_audioval = -(1 << (8 - 1));
-
- src8 = (Sint8 *) src;
- dst8 = (Sint8 *) dst;
- while (len--) {
- src_sample = *src8;
- ADJUST_VOLUME(src_sample, volume);
- dst_sample = *dst8 + src_sample;
- if (dst_sample > max_audioval) {
- *dst8 = max_audioval;
- } else if (dst_sample < min_audioval) {
- *dst8 = min_audioval;
- } else {
- *dst8 = dst_sample;
- }
- ++dst8;
- ++src8;
- }
- }
- }
- break;
-
- case AUDIO_S16LSB:
- {
- {
- Sint16 src1, src2;
- int dst_sample;
- const int max_audioval = ((1 << (16 - 1)) - 1);
- const int min_audioval = -(1 << (16 - 1));
-
- len /= 2;
- while (len--) {
- src1 = ((src[1]) << 8 | src[0]);
- ADJUST_VOLUME(src1, volume);
- src2 = ((dst[1]) << 8 | dst[0]);
- src += 2;
- dst_sample = src1 + src2;
- if (dst_sample > max_audioval) {
- dst_sample = max_audioval;
- } else if (dst_sample < min_audioval) {
- dst_sample = min_audioval;
- }
- dst[0] = dst_sample & 0xFF;
- dst_sample >>= 8;
- dst[1] = dst_sample & 0xFF;
- dst += 2;
- }
- }
- }
- break;
-
- case AUDIO_S16MSB:
- {
- Sint16 src1, src2;
- int dst_sample;
- const int max_audioval = ((1 << (16 - 1)) - 1);
- const int min_audioval = -(1 << (16 - 1));
-
- len /= 2;
- while (len--) {
- src1 = ((src[0]) << 8 | src[1]);
- ADJUST_VOLUME(src1, volume);
- src2 = ((dst[0]) << 8 | dst[1]);
- src += 2;
- dst_sample = src1 + src2;
- if (dst_sample > max_audioval) {
- dst_sample = max_audioval;
- } else if (dst_sample < min_audioval) {
- dst_sample = min_audioval;
- }
- dst[1] = dst_sample & 0xFF;
- dst_sample >>= 8;
- dst[0] = dst_sample & 0xFF;
- dst += 2;
- }
- }
- break;
-
- case AUDIO_S32LSB:
- {
- const Uint32 *src32 = (Uint32 *) src;
- Uint32 *dst32 = (Uint32 *) dst;
- Sint64 src1, src2;
- Sint64 dst_sample;
- const Sint64 max_audioval = ((((Sint64) 1) << (32 - 1)) - 1);
- const Sint64 min_audioval = -(((Sint64) 1) << (32 - 1));
-
- len /= 4;
- while (len--) {
- src1 = (Sint64) ((Sint32) SDL_SwapLE32(*src32));
- src32++;
- ADJUST_VOLUME(src1, volume);
- src2 = (Sint64) ((Sint32) SDL_SwapLE32(*dst32));
- dst_sample = src1 + src2;
- if (dst_sample > max_audioval) {
- dst_sample = max_audioval;
- } else if (dst_sample < min_audioval) {
- dst_sample = min_audioval;
- }
- *(dst32++) = SDL_SwapLE32((Uint32) ((Sint32) dst_sample));
- }
- }
- break;
-
- case AUDIO_S32MSB:
- {
- const Uint32 *src32 = (Uint32 *) src;
- Uint32 *dst32 = (Uint32 *) dst;
- Sint64 src1, src2;
- Sint64 dst_sample;
- const Sint64 max_audioval = ((((Sint64) 1) << (32 - 1)) - 1);
- const Sint64 min_audioval = -(((Sint64) 1) << (32 - 1));
-
- len /= 4;
- while (len--) {
- src1 = (Sint64) ((Sint32) SDL_SwapBE32(*src32));
- src32++;
- ADJUST_VOLUME(src1, volume);
- src2 = (Sint64) ((Sint32) SDL_SwapBE32(*dst32));
- dst_sample = src1 + src2;
- if (dst_sample > max_audioval) {
- dst_sample = max_audioval;
- } else if (dst_sample < min_audioval) {
- dst_sample = min_audioval;
- }
- *(dst32++) = SDL_SwapBE32((Uint32) ((Sint32) dst_sample));
- }
- }
- break;
-
- case AUDIO_F32LSB:
- {
- const float fmaxvolume = 1.0f / ((float) SDL_MIX_MAXVOLUME);
- const float fvolume = (float) volume;
- const float *src32 = (float *) src;
- float *dst32 = (float *) dst;
- float src1, src2;
- double dst_sample;
- /* !!! FIXME: are these right? */
- const double max_audioval = 3.402823466e+38F;
- const double min_audioval = -3.402823466e+38F;
-
- len /= 4;
- while (len--) {
- src1 = ((SDL_SwapFloatLE(*src32) * fvolume) * fmaxvolume);
- src2 = SDL_SwapFloatLE(*dst32);
- src32++;
-
- dst_sample = ((double) src1) + ((double) src2);
- if (dst_sample > max_audioval) {
- dst_sample = max_audioval;
- } else if (dst_sample < min_audioval) {
- dst_sample = min_audioval;
- }
- *(dst32++) = SDL_SwapFloatLE((float) dst_sample);
- }
- }
- break;
-
- case AUDIO_F32MSB:
- {
- const float fmaxvolume = 1.0f / ((float) SDL_MIX_MAXVOLUME);
- const float fvolume = (float) volume;
- const float *src32 = (float *) src;
- float *dst32 = (float *) dst;
- float src1, src2;
- double dst_sample;
- /* !!! FIXME: are these right? */
- const double max_audioval = 3.402823466e+38F;
- const double min_audioval = -3.402823466e+38F;
-
- len /= 4;
- while (len--) {
- src1 = ((SDL_SwapFloatBE(*src32) * fvolume) * fmaxvolume);
- src2 = SDL_SwapFloatBE(*dst32);
- src32++;
-
- dst_sample = ((double) src1) + ((double) src2);
- if (dst_sample > max_audioval) {
- dst_sample = max_audioval;
- } else if (dst_sample < min_audioval) {
- dst_sample = min_audioval;
- }
- *(dst32++) = SDL_SwapFloatBE((float) dst_sample);
- }
- }
- break;
-
- default: /* If this happens... FIXME! */
- SDL_SetError("SDL_MixAudio(): unknown audio format");
- return;
- }
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/macosx/plugins/Common/SDL/src/audio/SDL_sysaudio.h b/macosx/plugins/Common/SDL/src/audio/SDL_sysaudio.h
deleted file mode 100644
index 5e4795f3..00000000
--- a/macosx/plugins/Common/SDL/src/audio/SDL_sysaudio.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2010 Sam Lantinga
-
- This library is SDL_free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Sam Lantinga
- slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#ifndef _SDL_sysaudio_h
-#define _SDL_sysaudio_h
-
-#include "SDL_mutex.h"
-#include "SDL_thread.h"
-
-/* The SDL audio driver */
-typedef struct SDL_AudioDevice SDL_AudioDevice;
-#define _THIS SDL_AudioDevice *_this
-
-typedef struct SDL_AudioDriverImpl
-{
- int (*DetectDevices) (int iscapture);
- const char *(*GetDeviceName) (int index, int iscapture);
- int (*OpenDevice) (_THIS, const char *devname, int iscapture);
- void (*ThreadInit) (_THIS); /* Called by audio thread at start */
- void (*WaitDevice) (_THIS);
- void (*PlayDevice) (_THIS);
- Uint8 *(*GetDeviceBuf) (_THIS);
- void (*WaitDone) (_THIS);
- void (*CloseDevice) (_THIS);
- void (*LockDevice) (_THIS);
- void (*UnlockDevice) (_THIS);
- void (*Deinitialize) (void);
-
- /* Some flags to push duplicate code into the core and reduce #ifdefs. */
- int ProvidesOwnCallbackThread:1;
- int SkipMixerLock:1;
- int HasCaptureSupport:1;
- int OnlyHasDefaultOutputDevice:1;
- int OnlyHasDefaultInputDevice:1;
-} SDL_AudioDriverImpl;
-
-
-typedef struct SDL_AudioDriver
-{
- /* * * */
- /* The name of this audio driver */
- const char *name;
-
- /* * * */
- /* The description of this audio driver */
- const char *desc;
-
- SDL_AudioDriverImpl impl;
-} SDL_AudioDriver;
-
-
-/* Streamer */
-typedef struct
-{
- Uint8 *buffer;
- int max_len; /* the maximum length in bytes */
- int read_pos, write_pos; /* the position of the write and read heads in bytes */
-} SDL_AudioStreamer;
-
-
-/* Define the SDL audio driver structure */
-struct SDL_AudioDevice
-{
- /* * * */
- /* Data common to all devices */
-
- /* The current audio specification (shared with audio thread) */
- SDL_AudioSpec spec;
-
- /* An audio conversion block for audio format emulation */
- SDL_AudioCVT convert;
-
- /* The streamer, if sample rate conversion necessitates it */
- int use_streamer;
- SDL_AudioStreamer streamer;
-
- /* Current state flags */
- int iscapture;
- int enabled;
- int paused;
- int opened;
-
- /* Fake audio buffer for when the audio hardware is busy */
- Uint8 *fake_stream;
-
- /* A semaphore for locking the mixing buffers */
- SDL_mutex *mixer_lock;
-
- /* A thread to feed the audio device */
- SDL_Thread *thread;
- SDL_threadID threadid;
-
- /* * * */
- /* Data private to this driver */
- struct SDL_PrivateAudioData *hidden;
-};
-#undef _THIS
-
-typedef struct AudioBootStrap
-{
- const char *name;
- const char *desc;
- int (*init) (SDL_AudioDriverImpl * impl);
- int demand_only:1; /* 1==request explicitly, or it won't be available. */
-} AudioBootStrap;
-
-#endif /* _SDL_sysaudio_h */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/macosx/plugins/Common/SDL/src/audio/SDL_wave.c b/macosx/plugins/Common/SDL/src/audio/SDL_wave.c
deleted file mode 100644
index 0f395c56..00000000
--- a/macosx/plugins/Common/SDL/src/audio/SDL_wave.c
+++ /dev/null
@@ -1,636 +0,0 @@
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2010 Sam Lantinga
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Sam Lantinga
- slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* Microsoft WAVE file loading routines */
-
-#include "SDL_audio.h"
-#include "SDL_wave.h"
-
-
-static int ReadChunk(SDL_RWops * src, Chunk * chunk);
-
-struct MS_ADPCM_decodestate
-{
- Uint8 hPredictor;
- Uint16 iDelta;
- Sint16 iSamp1;
- Sint16 iSamp2;
-};
-static struct MS_ADPCM_decoder
-{
- WaveFMT wavefmt;
- Uint16 wSamplesPerBlock;
- Uint16 wNumCoef;
- Sint16 aCoeff[7][2];
- /* * * */
- struct MS_ADPCM_decodestate state[2];
-} MS_ADPCM_state;
-
-static int
-InitMS_ADPCM(WaveFMT * format)
-{
- Uint8 *rogue_feel;
- Uint16 extra_info;
- int i;
-
- /* Set the rogue pointer to the MS_ADPCM specific data */
- MS_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding);
- MS_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels);
- MS_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency);
- MS_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate);
- MS_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign);
- MS_ADPCM_state.wavefmt.bitspersample =
- SDL_SwapLE16(format->bitspersample);
- rogue_feel = (Uint8 *) format + sizeof(*format);
- if (sizeof(*format) == 16) {
- extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]);
- rogue_feel += sizeof(Uint16);
- }
- MS_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1] << 8) | rogue_feel[0]);
- rogue_feel += sizeof(Uint16);
- MS_ADPCM_state.wNumCoef = ((rogue_feel[1] << 8) | rogue_feel[0]);
- rogue_feel += sizeof(Uint16);
- if (MS_ADPCM_state.wNumCoef != 7) {
- SDL_SetError("Unknown set of MS_ADPCM coefficients");
- return (-1);
- }
- for (i = 0; i < MS_ADPCM_state.wNumCoef; ++i) {
- MS_ADPCM_state.aCoeff[i][0] = ((rogue_feel[1] << 8) | rogue_feel[0]);
- rogue_feel += sizeof(Uint16);
- MS_ADPCM_state.aCoeff[i][1] = ((rogue_feel[1] << 8) | rogue_feel[0]);
- rogue_feel += sizeof(Uint16);
- }
- return (0);
-}
-
-static Sint32
-MS_ADPCM_nibble(struct MS_ADPCM_decodestate *state,
- Uint8 nybble, Sint16 * coeff)
-{
- const Sint32 max_audioval = ((1 << (16 - 1)) - 1);
- const Sint32 min_audioval = -(1 << (16 - 1));
- const Sint32 adaptive[] = {
- 230, 230, 230, 230, 307, 409, 512, 614,
- 768, 614, 512, 409, 307, 230, 230, 230
- };
- Sint32 new_sample, delta;
-
- new_sample = ((state->iSamp1 * coeff[0]) +
- (state->iSamp2 * coeff[1])) / 256;
- if (nybble & 0x08) {
- new_sample += state->iDelta * (nybble - 0x10);
- } else {
- new_sample += state->iDelta * nybble;
- }
- if (new_sample < min_audioval) {
- new_sample = min_audioval;
- } else if (new_sample > max_audioval) {
- new_sample = max_audioval;
- }
- delta = ((Sint32) state->iDelta * adaptive[nybble]) / 256;
- if (delta < 16) {
- delta = 16;
- }
- state->iDelta = (Uint16) delta;
- state->iSamp2 = state->iSamp1;
- state->iSamp1 = (Sint16) new_sample;
- return (new_sample);
-}
-
-static int
-MS_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len)
-{
- struct MS_ADPCM_decodestate *state[2];
- Uint8 *freeable, *encoded, *decoded;
- Sint32 encoded_len, samplesleft;
- Sint8 nybble, stereo;
- Sint16 *coeff[2];
- Sint32 new_sample;
-
- /* Allocate the proper sized output buffer */
- encoded_len = *audio_len;
- encoded = *audio_buf;
- freeable = *audio_buf;
- *audio_len = (encoded_len / MS_ADPCM_state.wavefmt.blockalign) *
- MS_ADPCM_state.wSamplesPerBlock *
- MS_ADPCM_state.wavefmt.channels * sizeof(Sint16);
- *audio_buf = (Uint8 *) SDL_malloc(*audio_len);
- if (*audio_buf == NULL) {
- SDL_Error(SDL_ENOMEM);
- return (-1);
- }
- decoded = *audio_buf;
-
- /* Get ready... Go! */
- stereo = (MS_ADPCM_state.wavefmt.channels == 2);
- state[0] = &MS_ADPCM_state.state[0];
- state[1] = &MS_ADPCM_state.state[stereo];
- while (encoded_len >= MS_ADPCM_state.wavefmt.blockalign) {
- /* Grab the initial information for this block */
- state[0]->hPredictor = *encoded++;
- if (stereo) {
- state[1]->hPredictor = *encoded++;
- }
- state[0]->iDelta = ((encoded[1] << 8) | encoded[0]);
- encoded += sizeof(Sint16);
- if (stereo) {
- state[1]->iDelta = ((encoded[1] << 8) | encoded[0]);
- encoded += sizeof(Sint16);
- }
- state[0]->iSamp1 = ((encoded[1] << 8) | encoded[0]);
- encoded += sizeof(Sint16);
- if (stereo) {
- state[1]->iSamp1 = ((encoded[1] << 8) | encoded[0]);
- encoded += sizeof(Sint16);
- }
- state[0]->iSamp2 = ((encoded[1] << 8) | encoded[0]);
- encoded += sizeof(Sint16);
- if (stereo) {
- state[1]->iSamp2 = ((encoded[1] << 8) | encoded[0]);
- encoded += sizeof(Sint16);
- }
- coeff[0] = MS_ADPCM_state.aCoeff[state[0]->hPredictor];
- coeff[1] = MS_ADPCM_state.aCoeff[state[1]->hPredictor];
-
- /* Store the two initial samples we start with */
- decoded[0] = state[0]->iSamp2 & 0xFF;
- decoded[1] = state[0]->iSamp2 >> 8;
- decoded += 2;
- if (stereo) {
- decoded[0] = state[1]->iSamp2 & 0xFF;
- decoded[1] = state[1]->iSamp2 >> 8;
- decoded += 2;
- }
- decoded[0] = state[0]->iSamp1 & 0xFF;
- decoded[1] = state[0]->iSamp1 >> 8;
- decoded += 2;
- if (stereo) {
- decoded[0] = state[1]->iSamp1 & 0xFF;
- decoded[1] = state[1]->iSamp1 >> 8;
- decoded += 2;
- }
-
- /* Decode and store the other samples in this block */
- samplesleft = (MS_ADPCM_state.wSamplesPerBlock - 2) *
- MS_ADPCM_state.wavefmt.channels;
- while (samplesleft > 0) {
- nybble = (*encoded) >> 4;
- new_sample = MS_ADPCM_nibble(state[0], nybble, coeff[0]);
- decoded[0] = new_sample & 0xFF;
- new_sample >>= 8;
- decoded[1] = new_sample & 0xFF;
- decoded += 2;
-
- nybble = (*encoded) & 0x0F;
- new_sample = MS_ADPCM_nibble(state[1], nybble, coeff[1]);
- decoded[0] = new_sample & 0xFF;
- new_sample >>= 8;
- decoded[1] = new_sample & 0xFF;
- decoded += 2;
-
- ++encoded;
- samplesleft -= 2;
- }
- encoded_len -= MS_ADPCM_state.wavefmt.blockalign;
- }
- SDL_free(freeable);
- return (0);
-}
-
-struct IMA_ADPCM_decodestate
-{
- Sint32 sample;
- Sint8 index;
-};
-static struct IMA_ADPCM_decoder
-{
- WaveFMT wavefmt;
- Uint16 wSamplesPerBlock;
- /* * * */
- struct IMA_ADPCM_decodestate state[2];
-} IMA_ADPCM_state;
-
-static int
-InitIMA_ADPCM(WaveFMT * format)
-{
- Uint8 *rogue_feel;
- Uint16 extra_info;
-
- /* Set the rogue pointer to the IMA_ADPCM specific data */
- IMA_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding);
- IMA_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels);
- IMA_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency);
- IMA_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate);
- IMA_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign);
- IMA_ADPCM_state.wavefmt.bitspersample =
- SDL_SwapLE16(format->bitspersample);
- rogue_feel = (Uint8 *) format + sizeof(*format);
- if (sizeof(*format) == 16) {
- extra_info = ((rogue_feel[1] << 8) | rogue_feel[0]);
- rogue_feel += sizeof(Uint16);
- }
- IMA_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1] << 8) | rogue_feel[0]);
- return (0);
-}
-
-static Sint32
-IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state, Uint8 nybble)
-{
- const Sint32 max_audioval = ((1 << (16 - 1)) - 1);
- const Sint32 min_audioval = -(1 << (16 - 1));
- const int index_table[16] = {
- -1, -1, -1, -1,
- 2, 4, 6, 8,
- -1, -1, -1, -1,
- 2, 4, 6, 8
- };
- const Sint32 step_table[89] = {
- 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31,
- 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130,
- 143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408,
- 449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282,
- 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327,
- 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630,
- 9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350,
- 22385, 24623, 27086, 29794, 32767
- };
- Sint32 delta, step;
-
- /* Compute difference and new sample value */
- step = step_table[state->index];
- delta = step >> 3;
- if (nybble & 0x04)
- delta += step;
- if (nybble & 0x02)
- delta += (step >> 1);
- if (nybble & 0x01)
- delta += (step >> 2);
- if (nybble & 0x08)
- delta = -delta;
- state->sample += delta;
-
- /* Update index value */
- state->index += index_table[nybble];
- if (state->index > 88) {
- state->index = 88;
- } else if (state->index < 0) {
- state->index = 0;
- }
-
- /* Clamp output sample */
- if (state->sample > max_audioval) {
- state->sample = max_audioval;
- } else if (state->sample < min_audioval) {
- state->sample = min_audioval;
- }
- return (state->sample);
-}
-
-/* Fill the decode buffer with a channel block of data (8 samples) */
-static void
-Fill_IMA_ADPCM_block(Uint8 * decoded, Uint8 * encoded,
- int channel, int numchannels,
- struct IMA_ADPCM_decodestate *state)
-{
- int i;
- Sint8 nybble;
- Sint32 new_sample;
-
- decoded += (channel * 2);
- for (i = 0; i < 4; ++i) {
- nybble = (*encoded) & 0x0F;
- new_sample = IMA_ADPCM_nibble(state, nybble);
- decoded[0] = new_sample & 0xFF;
- new_sample >>= 8;
- decoded[1] = new_sample & 0xFF;
- decoded += 2 * numchannels;
-
- nybble = (*encoded) >> 4;
- new_sample = IMA_ADPCM_nibble(state, nybble);
- decoded[0] = new_sample & 0xFF;
- new_sample >>= 8;
- decoded[1] = new_sample & 0xFF;
- decoded += 2 * numchannels;
-
- ++encoded;
- }
-}
-
-static int
-IMA_ADPCM_decode(Uint8 ** audio_buf, Uint32 * audio_len)
-{
- struct IMA_ADPCM_decodestate *state;
- Uint8 *freeable, *encoded, *decoded;
- Sint32 encoded_len, samplesleft;
- unsigned int c, channels;
-
- /* Check to make sure we have enough variables in the state array */
- channels = IMA_ADPCM_state.wavefmt.channels;
- if (channels > SDL_arraysize(IMA_ADPCM_state.state)) {
- SDL_SetError("IMA ADPCM decoder can only handle %d channels",
- SDL_arraysize(IMA_ADPCM_state.state));
- return (-1);
- }
- state = IMA_ADPCM_state.state;
-
- /* Allocate the proper sized output buffer */
- encoded_len = *audio_len;
- encoded = *audio_buf;
- freeable = *audio_buf;
- *audio_len = (encoded_len / IMA_ADPCM_state.wavefmt.blockalign) *
- IMA_ADPCM_state.wSamplesPerBlock *
- IMA_ADPCM_state.wavefmt.channels * sizeof(Sint16);
- *audio_buf = (Uint8 *) SDL_malloc(*audio_len);
- if (*audio_buf == NULL) {
- SDL_Error(SDL_ENOMEM);
- return (-1);
- }
- decoded = *audio_buf;
-
- /* Get ready... Go! */
- while (encoded_len >= IMA_ADPCM_state.wavefmt.blockalign) {
- /* Grab the initial information for this block */
- for (c = 0; c < channels; ++c) {
- /* Fill the state information for this block */
- state[c].sample = ((encoded[1] << 8) | encoded[0]);
- encoded += 2;
- if (state[c].sample & 0x8000) {
- state[c].sample -= 0x10000;
- }
- state[c].index = *encoded++;
- /* Reserved byte in buffer header, should be 0 */
- if (*encoded++ != 0) {
- /* Uh oh, corrupt data? Buggy code? */ ;
- }
-
- /* Store the initial sample we start with */
- decoded[0] = (Uint8) (state[c].sample & 0xFF);
- decoded[1] = (Uint8) (state[c].sample >> 8);
- decoded += 2;
- }
-
- /* Decode and store the other samples in this block */
- samplesleft = (IMA_ADPCM_state.wSamplesPerBlock - 1) * channels;
- while (samplesleft > 0) {
- for (c = 0; c < channels; ++c) {
- Fill_IMA_ADPCM_block(decoded, encoded,
- c, channels, &state[c]);
- encoded += 4;
- samplesleft -= 8;
- }
- decoded += (channels * 8 * 2);
- }
- encoded_len -= IMA_ADPCM_state.wavefmt.blockalign;
- }
- SDL_free(freeable);
- return (0);
-}
-
-SDL_AudioSpec *
-SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
- SDL_AudioSpec * spec, Uint8 ** audio_buf, Uint32 * audio_len)
-{
- int was_error;
- Chunk chunk;
- int lenread;
- int IEEE_float_encoded, MS_ADPCM_encoded, IMA_ADPCM_encoded;
- int samplesize;
-
- /* WAV magic header */
- Uint32 RIFFchunk;
- Uint32 wavelen = 0;
- Uint32 WAVEmagic;
- Uint32 headerDiff = 0;
-
- /* FMT chunk */
- WaveFMT *format = NULL;
-
- /* Make sure we are passed a valid data source */
- was_error = 0;
- if (src == NULL) {
- was_error = 1;
- goto done;
- }
-
- /* Check the magic header */
- RIFFchunk = SDL_ReadLE32(src);
- wavelen = SDL_ReadLE32(src);
- if (wavelen == WAVE) { /* The RIFFchunk has already been read */
- WAVEmagic = wavelen;
- wavelen = RIFFchunk;
- RIFFchunk = RIFF;
- } else {
- WAVEmagic = SDL_ReadLE32(src);
- }
- if ((RIFFchunk != RIFF) || (WAVEmagic != WAVE)) {
- SDL_SetError("Unrecognized file type (not WAVE)");
- was_error = 1;
- goto done;
- }
- headerDiff += sizeof(Uint32); /* for WAVE */
-
- /* Read the audio data format chunk */
- chunk.data = NULL;
- do {
- if (chunk.data != NULL) {
- SDL_free(chunk.data);
- chunk.data = NULL;
- }
- lenread = ReadChunk(src, &chunk);
- if (lenread < 0) {
- was_error = 1;
- goto done;
- }
- /* 2 Uint32's for chunk header+len, plus the lenread */
- headerDiff += lenread + 2 * sizeof(Uint32);
- } while ((chunk.magic == FACT) || (chunk.magic == LIST));
-
- /* Decode the audio data format */
- format = (WaveFMT *) chunk.data;
- if (chunk.magic != FMT) {
- SDL_SetError("Complex WAVE files not supported");
- was_error = 1;
- goto done;
- }
- IEEE_float_encoded = MS_ADPCM_encoded = IMA_ADPCM_encoded = 0;
- switch (SDL_SwapLE16(format->encoding)) {
- case PCM_CODE:
- /* We can understand this */
- break;
- case IEEE_FLOAT_CODE:
- IEEE_float_encoded = 1;
- /* We can understand this */
- break;
- case MS_ADPCM_CODE:
- /* Try to understand this */
- if (InitMS_ADPCM(format) < 0) {
- was_error = 1;
- goto done;
- }
- MS_ADPCM_encoded = 1;
- break;
- case IMA_ADPCM_CODE:
- /* Try to understand this */
- if (InitIMA_ADPCM(format) < 0) {
- was_error = 1;
- goto done;
- }
- IMA_ADPCM_encoded = 1;
- break;
- case MP3_CODE:
- SDL_SetError("MPEG Layer 3 data not supported",
- SDL_SwapLE16(format->encoding));
- was_error = 1;
- goto done;
- default:
- SDL_SetError("Unknown WAVE data format: 0x%.4x",
- SDL_SwapLE16(format->encoding));
- was_error = 1;
- goto done;
- }
- SDL_memset(spec, 0, (sizeof *spec));
- spec->freq = SDL_SwapLE32(format->frequency);
-
- if (IEEE_float_encoded) {
- if ((SDL_SwapLE16(format->bitspersample)) != 32) {
- was_error = 1;
- } else {
- spec->format = AUDIO_F32;
- }
- } else {
- switch (SDL_SwapLE16(format->bitspersample)) {
- case 4:
- if (MS_ADPCM_encoded || IMA_ADPCM_encoded) {
- spec->format = AUDIO_S16;
- } else {
- was_error = 1;
- }
- break;
- case 8:
- spec->format = AUDIO_U8;
- break;
- case 16:
- spec->format = AUDIO_S16;
- break;
- case 32:
- spec->format = AUDIO_S32;
- break;
- default:
- was_error = 1;
- break;
- }
- }
-
- if (was_error) {
- SDL_SetError("Unknown %d-bit PCM data format",
- SDL_SwapLE16(format->bitspersample));
- goto done;
- }
- spec->channels = (Uint8) SDL_SwapLE16(format->channels);
- spec->samples = 4096; /* Good default buffer size */
-
- /* Read the audio data chunk */
- *audio_buf = NULL;
- do {
- if (*audio_buf != NULL) {
- SDL_free(*audio_buf);
- *audio_buf = NULL;
- }
- lenread = ReadChunk(src, &chunk);
- if (lenread < 0) {
- was_error = 1;
- goto done;
- }
- *audio_len = lenread;
- *audio_buf = chunk.data;
- if (chunk.magic != DATA)
- headerDiff += lenread + 2 * sizeof(Uint32);
- } while (chunk.magic != DATA);
- headerDiff += 2 * sizeof(Uint32); /* for the data chunk and len */
-
- if (MS_ADPCM_encoded) {
- if (MS_ADPCM_decode(audio_buf, audio_len) < 0) {
- was_error = 1;
- goto done;
- }
- }
- if (IMA_ADPCM_encoded) {
- if (IMA_ADPCM_decode(audio_buf, audio_len) < 0) {
- was_error = 1;
- goto done;
- }
- }
-
- /* Don't return a buffer that isn't a multiple of samplesize */
- samplesize = ((SDL_AUDIO_BITSIZE(spec->format)) / 8) * spec->channels;
- *audio_len &= ~(samplesize - 1);
-
- done:
- if (format != NULL) {
- SDL_free(format);
- }
- if (src) {
- if (freesrc) {
- SDL_RWclose(src);
- } else {
- /* seek to the end of the file (given by the RIFF chunk) */
- SDL_RWseek(src, wavelen - chunk.length - headerDiff, RW_SEEK_CUR);
- }
- }
- if (was_error) {
- spec = NULL;
- }
- return (spec);
-}
-
-/* Since the WAV memory is allocated in the shared library, it must also
- be freed here. (Necessary under Win32, VC++)
- */
-void
-SDL_FreeWAV(Uint8 * audio_buf)
-{
- if (audio_buf != NULL) {
- SDL_free(audio_buf);
- }
-}
-
-static int
-ReadChunk(SDL_RWops * src, Chunk * chunk)
-{
- chunk->magic = SDL_ReadLE32(src);
- chunk->length = SDL_ReadLE32(src);
- chunk->data = (Uint8 *) SDL_malloc(chunk->length);
- if (chunk->data == NULL) {
- SDL_Error(SDL_ENOMEM);
- return (-1);
- }
- if (SDL_RWread(src, chunk->data, chunk->length, 1) != 1) {
- SDL_Error(SDL_EFREAD);
- SDL_free(chunk->data);
- chunk->data = NULL;
- return (-1);
- }
- return (chunk->length);
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/macosx/plugins/Common/SDL/src/audio/SDL_wave.h b/macosx/plugins/Common/SDL/src/audio/SDL_wave.h
deleted file mode 100644
index 3ecea82e..00000000
--- a/macosx/plugins/Common/SDL/src/audio/SDL_wave.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2010 Sam Lantinga
-
- This library is SDL_free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Sam Lantinga
- slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* WAVE files are little-endian */
-
-/*******************************************/
-/* Define values for Microsoft WAVE format */
-/*******************************************/
-#define RIFF 0x46464952 /* "RIFF" */
-#define WAVE 0x45564157 /* "WAVE" */
-#define FACT 0x74636166 /* "fact" */
-#define LIST 0x5453494c /* "LIST" */
-#define FMT 0x20746D66 /* "fmt " */
-#define DATA 0x61746164 /* "data" */
-#define PCM_CODE 0x0001
-#define MS_ADPCM_CODE 0x0002
-#define IEEE_FLOAT_CODE 0x0003
-#define IMA_ADPCM_CODE 0x0011
-#define MP3_CODE 0x0055
-#define WAVE_MONO 1
-#define WAVE_STEREO 2
-
-/* Normally, these three chunks come consecutively in a WAVE file */
-typedef struct WaveFMT
-{
-/* Not saved in the chunk we read:
- Uint32 FMTchunk;
- Uint32 fmtlen;
-*/
- Uint16 encoding;
- Uint16 channels; /* 1 = mono, 2 = stereo */
- Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */
- Uint32 byterate; /* Average bytes per second */
- Uint16 blockalign; /* Bytes per sample block */
- Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */
-} WaveFMT;
-
-/* The general chunk found in the WAVE file */
-typedef struct Chunk
-{
- Uint32 magic;
- Uint32 length;
- Uint8 *data;
-} Chunk;
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/macosx/plugins/Common/SDL/src/audio/macosx/SDL_coreaudio.c b/macosx/plugins/Common/SDL/src/audio/macosx/SDL_coreaudio.c
deleted file mode 100644
index 1e18ba44..00000000
--- a/macosx/plugins/Common/SDL/src/audio/macosx/SDL_coreaudio.c
+++ /dev/null
@@ -1,596 +0,0 @@
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2010 Sam Lantinga
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Sam Lantinga
- slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include <CoreAudio/CoreAudio.h>
-#include <CoreServices/CoreServices.h>
-#include <AudioUnit/AudioUnit.h>
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= 1050
-#include <AudioUnit/AUNTComponent.h>
-#endif
-
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "../SDL_sysaudio.h"
-#include "SDL_coreaudio.h"
-
-#define DEBUG_COREAUDIO 0
-
-typedef struct COREAUDIO_DeviceList
-{
- AudioDeviceID id;
- const char *name;
-} COREAUDIO_DeviceList;
-
-static COREAUDIO_DeviceList *inputDevices = NULL;
-static int inputDeviceCount = 0;
-static COREAUDIO_DeviceList *outputDevices = NULL;
-static int outputDeviceCount = 0;
-
-static void
-free_device_list(COREAUDIO_DeviceList ** devices, int *devCount)
-{
- if (*devices) {
- int i = *devCount;
- while (i--)
- SDL_free((void *) (*devices)[i].name);
- SDL_free(*devices);
- *devices = NULL;
- }
- *devCount = 0;
-}
-
-
-static void
-build_device_list(int iscapture, COREAUDIO_DeviceList ** devices,
- int *devCount)
-{
- OSStatus result = noErr;
- UInt32 size = 0;
- AudioObjectPropertyAddress propaddr;
- AudioObjectID *devs = NULL;
- UInt32 i = 0;
- UInt32 max = 0;
-
- free_device_list(devices, devCount);
-
- propaddr.mSelector = kAudioHardwarePropertyDevices;
- propaddr.mScope = kAudioObjectPropertyScopeGlobal;
- propaddr.mElement = kAudioObjectPropertyElementMaster;
-
- result = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &propaddr, 0, NULL, &size);
-
- if (result != kAudioHardwareNoError)
- return;
-
- devs = (AudioDeviceID *) alloca(size);
- if (devs == NULL)
- return;
-
- max = size / sizeof(AudioDeviceID);
- *devices = (COREAUDIO_DeviceList *) SDL_malloc(max * sizeof(**devices));
- if (*devices == NULL)
- return;
-
- result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propaddr, 0, NULL, &size, devs);
- if (result != kAudioHardwareNoError)
- return;
-
- for (i = 0; i < max; i++) {
- CFStringRef cfstr = NULL;
- char *ptr = NULL;
- AudioObjectID dev = devs[i];
- AudioBufferList *buflist = NULL;
- int usable = 0;
- CFIndex len = 0;
-
- propaddr.mSelector = kAudioDevicePropertyStreamConfiguration;
- propaddr.mScope = iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
- propaddr.mElement = kAudioObjectPropertyElementMaster;
-
- result = AudioObjectGetPropertyDataSize(dev, &propaddr, 0, NULL, &size);
- if (result != noErr)
- continue;
-
- buflist = (AudioBufferList *) SDL_malloc(size);
- if (buflist == NULL)
- continue;
-
- result = AudioObjectGetPropertyData(dev, &propaddr, 0, NULL, &size, buflist);
-
- if (result == noErr) {
- UInt32 j;
- for (j = 0; j < buflist->mNumberBuffers; j++) {
- if (buflist->mBuffers[j].mNumberChannels > 0) {
- usable = 1;
- break;
- }
- }
- }
-
- SDL_free(buflist);
-
- if (!usable)
- continue;
-
- size = sizeof(CFStringRef);
- propaddr.mSelector = kAudioDevicePropertyDeviceNameCFString;
- propaddr.mScope = iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
- propaddr.mElement = kAudioObjectPropertyElementMaster;
-
- result = AudioObjectGetPropertyData(dev, &propaddr, 0, NULL, &size, &cfstr);
-
- if (result != kAudioHardwareNoError)
- continue;
-
- len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cfstr),
- kCFStringEncodingUTF8);
-
- ptr = (char *) SDL_malloc(len + 1);
- usable = ((ptr != NULL) &&
- (CFStringGetCString
- (cfstr, ptr, len + 1, kCFStringEncodingUTF8)));
-
- CFRelease(cfstr);
-
- if (usable) {
- len = strlen(ptr);
- /* Some devices have whitespace at the end...trim it. */
- while ((len > 0) && (ptr[len - 1] == ' ')) {
- len--;
- }
- usable = (len > 0);
- }
-
- if (!usable) {
- SDL_free(ptr);
- } else {
- ptr[len] = '\0';
-
-#if DEBUG_COREAUDIO
- printf("COREAUDIO: Found %s device #%d: '%s' (devid %d)\n",
- ((iscapture) ? "capture" : "output"),
- (int) *devCount, ptr, (int) dev);
-#endif
-
- (*devices)[*devCount].id = dev;
- (*devices)[*devCount].name = ptr;
- (*devCount)++;
- }
- }
-}
-
-static inline void
-build_device_lists(void)
-{
- build_device_list(0, &outputDevices, &outputDeviceCount);
- build_device_list(1, &inputDevices, &inputDeviceCount);
-}
-
-
-static inline void
-free_device_lists(void)
-{
- free_device_list(&outputDevices, &outputDeviceCount);
- free_device_list(&inputDevices, &inputDeviceCount);
-}
-
-
-static int
-find_device_id(const char *devname, int iscapture, AudioDeviceID * id)
-{
- int i = ((iscapture) ? inputDeviceCount : outputDeviceCount);
- COREAUDIO_DeviceList *devs = ((iscapture) ? inputDevices : outputDevices);
- while (i--) {
- if (SDL_strcmp(devname, devs->name) == 0) {
- *id = devs->id;
- return 1;
- }
- devs++;
- }
-
- return 0;
-}
-
-
-static int
-COREAUDIO_DetectDevices(int iscapture)
-{
- if (iscapture) {
- build_device_list(1, &inputDevices, &inputDeviceCount);
- return inputDeviceCount;
- } else {
- build_device_list(0, &outputDevices, &outputDeviceCount);
- return outputDeviceCount;
- }
-
- return 0; /* shouldn't ever hit this. */
-}
-
-
-static const char *
-COREAUDIO_GetDeviceName(int index, int iscapture)
-{
- if ((iscapture) && (index < inputDeviceCount)) {
- return inputDevices[index].name;
- } else if ((!iscapture) && (index < outputDeviceCount)) {
- return outputDevices[index].name;
- }
-
- SDL_SetError("No such device");
- return NULL;
-}
-
-
-static void
-COREAUDIO_Deinitialize(void)
-{
- free_device_lists();
-}
-
-
-/* The CoreAudio callback */
-static OSStatus
-outputCallback(void *inRefCon,
- AudioUnitRenderActionFlags * ioActionFlags,
- const AudioTimeStamp * inTimeStamp,
- UInt32 inBusNumber, UInt32 inNumberFrames,
- AudioBufferList * ioData)
-{
- SDL_AudioDevice *this = (SDL_AudioDevice *) inRefCon;
- AudioBuffer *abuf;
- UInt32 remaining, len;
- void *ptr;
- UInt32 i;
-
- /* Only do anything if audio is enabled and not paused */
- if (!this->enabled || this->paused) {
- for (i = 0; i < ioData->mNumberBuffers; i++) {
- abuf = &ioData->mBuffers[i];
- SDL_memset(abuf->mData, this->spec.silence, abuf->mDataByteSize);
- }
- return 0;
- }
-
- /* No SDL conversion should be needed here, ever, since we accept
- any input format in OpenAudio, and leave the conversion to CoreAudio.
- */
- /*
- assert(!this->convert.needed);
- assert(this->spec.channels == ioData->mNumberChannels);
- */
-
- for (i = 0; i < ioData->mNumberBuffers; i++) {
- abuf = &ioData->mBuffers[i];
- remaining = abuf->mDataByteSize;
- ptr = abuf->mData;
- while (remaining > 0) {
- if (this->hidden->bufferOffset >= this->hidden->bufferSize) {
- /* Generate the data */
- SDL_memset(this->hidden->buffer, this->spec.silence,
- this->hidden->bufferSize);
- SDL_mutexP(this->mixer_lock);
- (*this->spec.callback)(this->spec.userdata,
- this->hidden->buffer, this->hidden->bufferSize);
- SDL_mutexV(this->mixer_lock);
- this->hidden->bufferOffset = 0;
- }
-
- len = this->hidden->bufferSize - this->hidden->bufferOffset;
- if (len > remaining)
- len = remaining;
- SDL_memcpy(ptr, (char *)this->hidden->buffer +
- this->hidden->bufferOffset, len);
- ptr = (char *)ptr + len;
- remaining -= len;
- this->hidden->bufferOffset += len;
- }
- }
-
- return 0;
-}
-
-static OSStatus
-inputCallback(void *inRefCon,
- AudioUnitRenderActionFlags * ioActionFlags,
- const AudioTimeStamp * inTimeStamp,
- UInt32 inBusNumber, UInt32 inNumberFrames,
- AudioBufferList * ioData)
-{
- //err = AudioUnitRender(afr->fAudioUnit, ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, afr->fAudioBuffer);
- // !!! FIXME: write me!
- return noErr;
-}
-
-
-static void
-COREAUDIO_CloseDevice(_THIS)
-{
- if (this->hidden != NULL) {
- if (this->hidden->audioUnitOpened) {
- OSStatus result = noErr;
- AURenderCallbackStruct callback;
- const AudioUnitElement output_bus = 0;
- const AudioUnitElement input_bus = 1;
- const int iscapture = this->iscapture;
- const AudioUnitElement bus =
- ((iscapture) ? input_bus : output_bus);
- const AudioUnitScope scope =
- ((iscapture) ? kAudioUnitScope_Output :
- kAudioUnitScope_Input);
-
- /* stop processing the audio unit */
- result = AudioOutputUnitStop(this->hidden->audioUnit);
-
- /* Remove the input callback */
- SDL_memset(&callback, '\0', sizeof(AURenderCallbackStruct));
- result = AudioUnitSetProperty(this->hidden->audioUnit,
- kAudioUnitProperty_SetRenderCallback,
- scope, bus, &callback,
- sizeof(callback));
-
- CloseComponent(this->hidden->audioUnit);
- this->hidden->audioUnitOpened = 0;
- }
- SDL_free(this->hidden->buffer);
- SDL_free(this->hidden);
- this->hidden = NULL;
- }
-}
-
-
-#define CHECK_RESULT(msg) \
- if (result != noErr) { \
- COREAUDIO_CloseDevice(this); \
- SDL_SetError("CoreAudio error (%s): %d", msg, (int) result); \
- return 0; \
- }
-
-static int
-find_device_by_name(_THIS, const char *devname, int iscapture)
-{
- AudioObjectID devid = 0;
- AudioObjectPropertyAddress devaddr;
- OSStatus result = noErr;
- UInt32 size = 0;
- UInt32 alive = 0;
- pid_t pid = 0;
-
- if (devname == NULL) {
- size = sizeof(devid);
- AudioObjectPropertyAddress propaddr;
- propaddr.mSelector = ((iscapture) ? kAudioHardwarePropertyDefaultInputDevice : kAudioHardwarePropertyDefaultOutputDevice);
- propaddr.mScope = kAudioObjectPropertyScopeGlobal;
- propaddr.mElement = kAudioObjectPropertyElementMaster;
-
- result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propaddr, 0, NULL, &size, &devid);
- CHECK_RESULT("AudioObjectGetPropertyData (default device)");
- } else {
- if (!find_device_id(devname, iscapture, &devid)) {
- SDL_SetError("CoreAudio: No such audio device.");
- return 0;
- }
- }
-
- size = sizeof(alive);
- devaddr.mSelector = kAudioDevicePropertyDeviceIsAlive;
- devaddr.mScope = iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
- devaddr.mElement = kAudioObjectPropertyElementMaster;
-
- result = AudioObjectGetPropertyData(devid, &devaddr, 0, NULL, &size, &alive);
-
- CHECK_RESULT
- ("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)");
-
- if (!alive) {
- SDL_SetError("CoreAudio: requested device exists, but isn't alive.");
- return 0;
- }
-
- size = sizeof(pid);
- devaddr.mSelector = kAudioDevicePropertyHogMode;
- devaddr.mScope = iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput;
- devaddr.mElement = kAudioObjectPropertyElementMaster;
-
- result = AudioObjectGetPropertyData(devid, &devaddr, 0, NULL, &size, &pid);
-
- /* some devices don't support this property, so errors are fine here. */
- if ((result == noErr) && (pid != -1)) {
- SDL_SetError("CoreAudio: requested device is being hogged.");
- return 0;
- }
-
- this->hidden->deviceID = devid;
- return 1;
-}
-
-
-static int
-prepare_audiounit(_THIS, const char *devname, int iscapture,
- const AudioStreamBasicDescription * strdesc)
-{
- OSStatus result = noErr;
- AURenderCallbackStruct callback;
- ComponentDescription desc;
- Component comp = NULL;
- const AudioUnitElement output_bus = 0;
- const AudioUnitElement input_bus = 1;
- const AudioUnitElement bus = ((iscapture) ? input_bus : output_bus);
- const AudioUnitScope scope = ((iscapture) ? kAudioUnitScope_Output :
- kAudioUnitScope_Input);
-
- if (!find_device_by_name(this, devname, iscapture)) {
- SDL_SetError("Couldn't find requested CoreAudio device");
- return 0;
- }
-
- SDL_memset(&desc, '\0', sizeof(ComponentDescription));
- desc.componentType = kAudioUnitType_Output;
- desc.componentSubType = kAudioUnitSubType_DefaultOutput;
- desc.componentManufacturer = kAudioUnitManufacturer_Apple;
-
- comp = FindNextComponent(NULL, &desc);
- if (comp == NULL) {
- SDL_SetError("Couldn't find requested CoreAudio component");
- return 0;
- }
-
- /* Open & initialize the audio unit */
- result = OpenAComponent(comp, &this->hidden->audioUnit);
- CHECK_RESULT("OpenAComponent");
-
- this->hidden->audioUnitOpened = 1;
-
- result = AudioUnitSetProperty(this->hidden->audioUnit,
- kAudioOutputUnitProperty_CurrentDevice,
- kAudioUnitScope_Global, 0,
- &this->hidden->deviceID,
- sizeof(AudioDeviceID));
- CHECK_RESULT
- ("AudioUnitSetProperty (kAudioOutputUnitProperty_CurrentDevice)");
-
- /* Set the data format of the audio unit. */
- result = AudioUnitSetProperty(this->hidden->audioUnit,
- kAudioUnitProperty_StreamFormat,
- scope, bus, strdesc, sizeof(*strdesc));
- CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)");
-
- /* Set the audio callback */
- SDL_memset(&callback, '\0', sizeof(AURenderCallbackStruct));
- callback.inputProc = ((iscapture) ? inputCallback : outputCallback);
- callback.inputProcRefCon = this;
- result = AudioUnitSetProperty(this->hidden->audioUnit,
- kAudioUnitProperty_SetRenderCallback,
- scope, bus, &callback, sizeof(callback));
- CHECK_RESULT
- ("AudioUnitSetProperty (kAudioUnitProperty_SetRenderCallback)");
-
- /* Calculate the final parameters for this audio specification */
- SDL_CalculateAudioSpec(&this->spec);
-
- /* Allocate a sample buffer */
- this->hidden->bufferOffset = this->hidden->bufferSize = this->spec.size;
- this->hidden->buffer = SDL_malloc(this->hidden->bufferSize);
-
- result = AudioUnitInitialize(this->hidden->audioUnit);
- CHECK_RESULT("AudioUnitInitialize");
-
- /* Finally, start processing of the audio unit */
- result = AudioOutputUnitStart(this->hidden->audioUnit);
- CHECK_RESULT("AudioOutputUnitStart");
-
- /* We're running! */
- return 1;
-}
-
-
-static int
-COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
-{
- AudioStreamBasicDescription strdesc;
- SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
- int valid_datatype = 0;
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- SDL_OutOfMemory();
- return (0);
- }
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
-
- /* Setup a AudioStreamBasicDescription with the requested format */
- SDL_memset(&strdesc, '\0', sizeof(AudioStreamBasicDescription));
- strdesc.mFormatID = kAudioFormatLinearPCM;
- strdesc.mFormatFlags = kLinearPCMFormatFlagIsPacked;
- strdesc.mChannelsPerFrame = this->spec.channels;
- strdesc.mSampleRate = this->spec.freq;
- strdesc.mFramesPerPacket = 1;
-
- while ((!valid_datatype) && (test_format)) {
- this->spec.format = test_format;
- /* Just a list of valid SDL formats, so people don't pass junk here. */
- switch (test_format) {
- case AUDIO_U8:
- case AUDIO_S8:
- case AUDIO_U16LSB:
- case AUDIO_S16LSB:
- case AUDIO_U16MSB:
- case AUDIO_S16MSB:
- case AUDIO_S32LSB:
- case AUDIO_S32MSB:
- case AUDIO_F32LSB:
- case AUDIO_F32MSB:
- valid_datatype = 1;
- strdesc.mBitsPerChannel = SDL_AUDIO_BITSIZE(this->spec.format);
- if (SDL_AUDIO_ISBIGENDIAN(this->spec.format))
- strdesc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
-
- if (SDL_AUDIO_ISFLOAT(this->spec.format))
- strdesc.mFormatFlags |= kLinearPCMFormatFlagIsFloat;
- else if (SDL_AUDIO_ISSIGNED(this->spec.format))
- strdesc.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger;
- break;
- }
- }
-
- if (!valid_datatype) { /* shouldn't happen, but just in case... */
- COREAUDIO_CloseDevice(this);
- SDL_SetError("Unsupported audio format");
- return 0;
- }
-
- strdesc.mBytesPerFrame =
- strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8;
- strdesc.mBytesPerPacket =
- strdesc.mBytesPerFrame * strdesc.mFramesPerPacket;
-
- if (!prepare_audiounit(this, devname, iscapture, &strdesc)) {
- COREAUDIO_CloseDevice(this);
- return 0; /* prepare_audiounit() will call SDL_SetError()... */
- }
-
- return 1; /* good to go. */
-}
-
-static int
-COREAUDIO_Init(SDL_AudioDriverImpl * impl)
-{
- /* Set the function pointers */
- impl->DetectDevices = COREAUDIO_DetectDevices;
- impl->GetDeviceName = COREAUDIO_GetDeviceName;
- impl->OpenDevice = COREAUDIO_OpenDevice;
- impl->CloseDevice = COREAUDIO_CloseDevice;
- impl->Deinitialize = COREAUDIO_Deinitialize;
- impl->ProvidesOwnCallbackThread = 1;
-
- build_device_lists(); /* do an initial check for devices... */
-
- return 1; /* this audio target is available. */
-}
-
-AudioBootStrap COREAUDIO_bootstrap = {
- "coreaudio", "Mac OS X CoreAudio", COREAUDIO_Init, 0
-};
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/macosx/plugins/Common/SDL/src/audio/macosx/SDL_coreaudio.h b/macosx/plugins/Common/SDL/src/audio/macosx/SDL_coreaudio.h
deleted file mode 100644
index 3ad7ee9f..00000000
--- a/macosx/plugins/Common/SDL/src/audio/macosx/SDL_coreaudio.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2010 Sam Lantinga
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
- Sam Lantinga
- slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#ifndef _SDL_coreaudio_h
-#define _SDL_coreaudio_h
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-struct SDL_PrivateAudioData
-{
- AudioUnit audioUnit;
- int audioUnitOpened;
- void *buffer;
- UInt32 bufferOffset;
- UInt32 bufferSize;
- AudioDeviceID deviceID;
-};
-
-#endif /* _SDL_coreaudio_h */
-/* vi: set ts=4 sw=4 expandtab: */