blob: be3b7430aa60a1698f48cd3c42cfbd4df5aeb3cb [file] [log] [blame]
/* DO NOT EDIT! This file is generated by sdlgenaudiocvt.pl */
/*
Simple DirectMedia Layer
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../SDL_internal.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 0
#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/1)) * cvt->rate_incr) * 1;
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);
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/1)) * cvt->rate_incr) * 1;
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/2)) * cvt->rate_incr) * 2;
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);
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);