21 #include "../SDL_internal.h"
33 #include "../SDL_dataqueue.h"
36 #define DEBUG_AUDIOSTREAM 0
39 #define HAVE_SSE3_INTRINSICS 1
42 #if HAVE_SSE3_INTRINSICS
47 float *
dst = (
float *) cvt->
buf;
56 if ((((
size_t)
dst) & 15) == 0) {
58 const __m128 divby2 = _mm_set1_ps(0.5f);
60 _mm_store_ps(
dst, _mm_mul_ps(_mm_hadd_ps(_mm_load_ps(
src), _mm_load_ps(
src+4)), divby2));
82 float *
dst = (
float *) cvt->
buf;
104 float *
dst = (
float *) cvt->
buf;
113 const float front_center_distributed =
src[2] * 0.5f;
114 dst[0] = (
src[0] + front_center_distributed +
src[4]) / 2.5f;
115 dst[1] = (
src[1] + front_center_distributed +
src[5]) / 2.5f;
129 float *
dst = (
float *) cvt->
buf;
152 float *
dst = (
float *) cvt->
buf;
160 const float surround_left_distributed =
src[6] * 0.5f;
161 const float surround_right_distributed =
src[7] * 0.5f;
162 dst[0] = (
src[0] + surround_left_distributed) / 1.5f;
163 dst[1] = (
src[1] + surround_right_distributed) / 1.5f;
166 dst[4] = (
src[4] + surround_left_distributed) / 1.5f;
167 dst[5] = (
src[5] + surround_right_distributed) / 1.5f;
182 float *
dst = (
float *) cvt->
buf;
192 const float front_center_distributed =
src[2] * 0.5f;
193 dst[0] = (
src[0] + front_center_distributed) / 1.5f;
194 dst[1] = (
src[1] + front_center_distributed) / 1.5f;
211 const float *
src = (
const float *) (cvt->
buf + cvt->
len_cvt);
218 for (
i = cvt->
len_cvt / sizeof (
float);
i; --
i) {
237 const float *
src = (
const float *) (cvt->
buf + cvt->
len_cvt);
243 for (
i = cvt->
len_cvt / (
sizeof(
float) * 2);
i; --
i) {
248 ce = (lf + rf) * 0.5f;
250 dst[0] = lf + (lf - ce);
251 dst[1] = rf + (rf - ce);
270 float lf, rf, lb, rb, ce;
271 const float *
src = (
const float *) (cvt->
buf + cvt->
len_cvt);
278 for (
i = cvt->
len_cvt / (
sizeof(
float) * 4);
i; --
i) {
285 ce = (lf + rf) * 0.5f;
287 dst[0] = lf + (lf - ce);
288 dst[1] = rf + (rf - ce);
306 const float *
src = (
const float *) (cvt->
buf + cvt->
len_cvt);
314 for (
i = cvt->
len_cvt / (
sizeof(
float) * 2);
i; --
i) {
336 float lf, rf, lb, rb, ls, rs;
338 const float *
src = (
const float *) (cvt->
buf + cvt->
len_cvt);
345 for (
i = cvt->
len_cvt / (
sizeof(
float) * 6);
i; --
i) {
352 ls = (lf + lb) * 0.5f;
353 rs = (rf + rb) * 0.5f;
379 #define RESAMPLER_ZERO_CROSSINGS 5
380 #define RESAMPLER_BITS_PER_SAMPLE 16
381 #define RESAMPLER_SAMPLES_PER_ZERO_CROSSING (1 << ((RESAMPLER_BITS_PER_SAMPLE / 2) + 1))
382 #define RESAMPLER_FILTER_SIZE ((RESAMPLER_SAMPLES_PER_ZERO_CROSSING * RESAMPLER_ZERO_CROSSINGS) + 1)
388 const double xdiv2 =
x / 2.0;
395 if (diff < 1.0e-21f) {
410 const int lenm1 = tablelen - 1;
411 const int lenm1div2 = lenm1 / 2;
415 for (
i = 1;
i < tablelen;
i++) {
417 table[tablelen -
i] = (float) kaiser;
420 for (
i = 1;
i < tablelen;
i++) {
439 const double dB = 80.0;
440 const double beta = 0.1102 * (dB - 8.7);
474 if (inrate == outrate) {
476 }
else if (inrate > outrate) {
485 const float *lpadding,
const float *rpadding,
486 const float *inbuf,
const int inbuflen,
487 float *outbuf,
const int outbuflen)
489 const double finrate = (double) inrate;
490 const double outtimeincr = 1.0 / ((float) outrate);
491 const double ratio = ((float) outrate) / ((float) inrate);
493 const int framelen = chans * (
int)
sizeof (
float);
494 const int inframes = inbuflen / framelen;
495 const int wantedoutframes = (
int) ((inbuflen / framelen) * ratio);
496 const int maxoutframes = outbuflen / framelen;
497 const int outframes =
SDL_min(wantedoutframes, maxoutframes);
499 double outtime = 0.0;
502 for (
i = 0;
i < outframes;
i++) {
503 const int srcindex = (
int) (outtime * inrate);
504 const double intime = ((double) srcindex) / finrate;
505 const double innexttime = ((double) (srcindex + 1)) / finrate;
506 const double interpolation1 = 1.0 - ((innexttime - outtime) / (innexttime - intime));
508 const double interpolation2 = 1.0 - interpolation1;
511 for (chan = 0; chan < chans; chan++) {
512 float outsample = 0.0f;
517 const int srcframe = srcindex -
j;
519 const float insample = (srcframe < 0) ? lpadding[((paddinglen + srcframe) * chans) + chan] : inbuf[(srcframe * chans) + chan];
524 const int srcframe = srcindex + 1 +
j;
526 const float insample = (srcframe >= inframes) ? rpadding[((srcframe - inframes) * chans) + chan] : inbuf[(srcframe * chans) + chan];
529 *(
dst++) = outsample;
532 outtime += outtimeincr;
535 return outframes * chans *
sizeof (float);
546 return SDL_SetError(
"No buffer allocated for conversion");
565 printf(
"Converting byte order\n");
569 #define CASESWAP(b) \
571 Uint##b *ptr = (Uint##b *) cvt->buf; \
573 for (i = cvt->len_cvt / sizeof (*ptr); i; --i, ++ptr) { \
574 *ptr = SDL_Swap##b(*ptr); \
585 default:
SDL_assert(!
"unhandled byteswap datatype!");
break;
627 const Uint16 dst_bitsize = 32;
636 default:
SDL_assert(!
"Unexpected audio format!");
break;
640 return SDL_SetError(
"No conversion from source format to float available");
646 if (src_bitsize < dst_bitsize) {
647 const int mult = (dst_bitsize / src_bitsize);
650 }
else if (src_bitsize > dst_bitsize) {
651 cvt->
len_ratio /= (src_bitsize / dst_bitsize);
667 const Uint16 src_bitsize = 32;
675 default:
SDL_assert(!
"Unexpected audio format!");
break;
679 return SDL_SetError(
"No conversion from float to format 0x%.4x available", dst_fmt);
685 if (src_bitsize < dst_bitsize) {
686 const int mult = (dst_bitsize / src_bitsize);
689 }
else if (src_bitsize > dst_bitsize) {
690 cvt->
len_ratio /= (src_bitsize / dst_bitsize);
713 const float *
src = (
const float *) cvt->
buf;
714 const int srclen = cvt->
len_cvt;
718 float *
dst = (
float *) (cvt->
buf + srclen);
719 const int dstlen = (cvt->
len * cvt->
len_mult) - srclen;
725 paddingsamples = requestedpadding * chans;
732 padding = (
float *)
SDL_calloc(paddingsamples ? paddingsamples : 1,
sizeof (
float));
753 #define RESAMPLER_FUNCS(chans) \
754 static void SDLCALL \
755 SDL_ResampleCVT_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) { \
756 SDL_ResampleCVT(cvt, chans, format); \
763 #undef RESAMPLER_FUNCS
768 switch (dst_channels) {
769 case 1:
return SDL_ResampleCVT_c1;
770 case 2:
return SDL_ResampleCVT_c2;
771 case 4:
return SDL_ResampleCVT_c4;
772 case 6:
return SDL_ResampleCVT_c6;
773 case 8:
return SDL_ResampleCVT_c8;
782 const int src_rate,
const int dst_rate)
786 if (src_rate == dst_rate) {
792 return SDL_SetError(
"No conversion available for these rates");
813 if (src_rate < dst_rate) {
814 const double mult = ((double) dst_rate) / ((double) src_rate);
818 cvt->
len_ratio /= ((double) src_rate) / ((double) dst_rate);
897 }
else if (src_rate <= 0) {
898 return SDL_SetError(
"Source rate is equal to or less than zero");
899 }
else if (dst_rate <= 0) {
900 return SDL_SetError(
"Destination rate is equal to or less than zero");
908 printf(
"Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
909 src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate);
920 cvt->
rate_incr = ((double) dst_rate) / ((double) src_rate);
940 if (src_rate == dst_rate && src_channels == dst_channels) {
941 if (src_fmt == dst_fmt) {
961 if (src_channels < dst_channels) {
964 if ((src_channels == 1) && (dst_channels > 1)) {
973 if ((src_channels == 2) && (dst_channels >= 6)) {
982 if ((src_channels == 4) && (dst_channels >= 6)) {
991 if ((src_channels == 6) && (dst_channels == 8)) {
1002 if ((src_channels == 2) && (dst_channels == 4)) {
1010 }
else if (src_channels > dst_channels) {
1014 if ((src_channels == 8) && (dst_channels <= 6)) {
1022 if ((src_channels == 6) && (dst_channels <= 2)) {
1030 if ((src_channels == 6) && (dst_channels == 4)) {
1038 if ((src_channels == 4) && (dst_channels <= 2)) {
1046 if ((src_channels == 2) && (dst_channels == 1)) {
1049 #if HAVE_SSE3_INTRINSICS
1051 filter = SDL_ConvertStereoToMono_SSE3;
1068 if (src_channels != dst_channels) {
1128 if (
stream->work_buffer_len >= newlen) {
1138 stream->work_buffer_len = newlen;
1145 #ifdef HAVE_LIBSAMPLERATE_H
1147 SDL_ResampleAudioStream_SRC(SDL_AudioStream *
stream,
const void *_inbuf,
const int inbuflen,
void *_outbuf,
const int outbuflen)
1149 const float *inbuf = (
const float *) _inbuf;
1150 float *outbuf = (
float *) _outbuf;
1151 const int framelen =
sizeof(float) *
stream->pre_resample_channels;
1152 SRC_STATE *
state = (SRC_STATE *)
stream->resampler_state;
1156 SDL_assert(inbuf != ((
const float *) outbuf));
1158 data.data_in = (
float *)inbuf;
1159 data.input_frames = inbuflen / framelen;
1160 data.input_frames_used = 0;
1162 data.data_out = outbuf;
1163 data.output_frames = outbuflen / framelen;
1165 data.end_of_input = 0;
1177 return data.output_frames_gen * (
sizeof(float) *
stream->pre_resample_channels);
1181 SDL_ResetAudioStreamResampler_SRC(SDL_AudioStream *
stream)
1183 SRC_src_reset((SRC_STATE *)
stream->resampler_state);
1187 SDL_CleanupAudioStreamResampler_SRC(SDL_AudioStream *
stream)
1189 SRC_STATE *
state = (SRC_STATE *)
stream->resampler_state;
1191 SRC_src_delete(
state);
1201 SetupLibSampleRateResampling(SDL_AudioStream *
stream)
1206 if (SRC_available) {
1214 SDL_CleanupAudioStreamResampler_SRC(
stream);
1219 stream->resampler_func = SDL_ResampleAudioStream_SRC;
1220 stream->reset_resampler_func = SDL_ResetAudioStreamResampler_SRC;
1221 stream->cleanup_resampler_func = SDL_CleanupAudioStreamResampler_SRC;
1231 const Uint8 *inbufend = ((
const Uint8 *) _inbuf) + inbuflen;
1232 const float *inbuf = (
const float *) _inbuf;
1233 float *outbuf = (
float *) _outbuf;
1234 const int chans = (
int)
stream->pre_resample_channels;
1235 const int inrate =
stream->src_rate;
1236 const int outrate =
stream->dst_rate;
1237 const int paddingsamples =
stream->resampler_padding_samples;
1238 const int paddingbytes = paddingsamples * sizeof (
float);
1239 float *lpadding = (
float *)
stream->resampler_state;
1240 const float *rpadding = (
const float *) inbufend;
1241 const int cpy =
SDL_min(inbuflen, paddingbytes);
1244 SDL_assert(inbuf != ((
const float *) outbuf));
1249 SDL_memcpy((lpadding + paddingsamples) - (cpy /
sizeof (
float)), inbufend - cpy, cpy);
1257 const int len =
stream->resampler_padding_samples;
1269 const Uint8 src_channels,
1272 const Uint8 dst_channels,
1275 const int packetlen = 4096;
1276 Uint8 pre_resample_channels;
1288 pre_resample_channels =
SDL_min(src_channels, dst_channels);
1292 retval->src_format = src_format;
1293 retval->src_channels = src_channels;
1294 retval->src_rate = src_rate;
1296 retval->dst_format = dst_format;
1297 retval->dst_channels = dst_channels;
1298 retval->dst_rate = dst_rate;
1299 retval->pre_resample_channels = pre_resample_channels;
1300 retval->packetlen = packetlen;
1301 retval->rate_incr = ((double) dst_rate) / ((double) src_rate);
1303 retval->resampler_padding = (
float *)
SDL_calloc(
retval->resampler_padding_samples ?
retval->resampler_padding_samples : 1, sizeof (
float));
1311 retval->staging_buffer_size = ((
retval->resampler_padding_samples /
retval->pre_resample_channels) *
retval->src_sample_frame_size);
1312 if (
retval->staging_buffer_size > 0) {
1322 if (src_rate == dst_rate) {
1324 if (
SDL_BuildAudioCVT(&
retval->cvt_after_resampling, src_format, src_channels, dst_rate, dst_format, dst_channels, dst_rate) < 0) {
1336 #ifdef HAVE_LIBSAMPLERATE_H
1337 SetupLibSampleRateResampling(
retval);
1340 if (!
retval->resampler_func) {
1342 if (!
retval->resampler_state) {
1383 int resamplebuflen = 0;
1384 int neededpaddingbytes;
1396 neededpaddingbytes =
stream->resampler_padding_samples *
sizeof (float);
1397 paddingbytes =
stream->first_run ? 0 : neededpaddingbytes;
1401 workbuflen = buflen;
1402 if (
stream->cvt_before_resampling.needed) {
1403 workbuflen *=
stream->cvt_before_resampling.len_mult;
1408 const int framesize =
stream->pre_resample_channels *
sizeof (float);
1409 const int frames = workbuflen / framesize;
1411 #if DEBUG_AUDIOSTREAM
1412 printf(
"AUDIOSTREAM: will resample %d bytes to %d (ratio=%.6f)\n", workbuflen, resamplebuflen,
stream->rate_incr);
1414 workbuflen += resamplebuflen;
1417 if (
stream->cvt_after_resampling.needed) {
1419 workbuflen *=
stream->cvt_after_resampling.len_mult;
1422 workbuflen += neededpaddingbytes;
1424 #if DEBUG_AUDIOSTREAM
1425 printf(
"AUDIOSTREAM: Putting %d bytes of preconverted audio, need %d byte work buffer\n", buflen, workbuflen);
1433 resamplebuf = workbuf;
1437 if (
stream->cvt_before_resampling.needed) {
1438 stream->cvt_before_resampling.buf = workbuf + paddingbytes;
1439 stream->cvt_before_resampling.len = buflen;
1443 buflen =
stream->cvt_before_resampling.len_cvt;
1445 #if DEBUG_AUDIOSTREAM
1446 printf(
"AUDIOSTREAM: After initial conversion we have %d bytes\n", buflen);
1458 buflen += paddingbytes;
1462 SDL_memcpy(
stream->resampler_padding, workbuf + (buflen - neededpaddingbytes), neededpaddingbytes);
1464 resamplebuf = workbuf + buflen;
1466 if (buflen > neededpaddingbytes) {
1467 buflen =
stream->resampler_func(
stream, workbuf, buflen - neededpaddingbytes, resamplebuf, resamplebuflen);
1472 #if DEBUG_AUDIOSTREAM
1473 printf(
"AUDIOSTREAM: After resampling we have %d bytes\n", buflen);
1477 if (
stream->cvt_after_resampling.needed && (buflen > 0)) {
1478 stream->cvt_after_resampling.buf = resamplebuf;
1479 stream->cvt_after_resampling.len = buflen;
1483 buflen =
stream->cvt_after_resampling.len_cvt;
1485 #if DEBUG_AUDIOSTREAM
1486 printf(
"AUDIOSTREAM: After final conversion we have %d bytes\n", buflen);
1490 #if DEBUG_AUDIOSTREAM
1491 printf(
"AUDIOSTREAM: Final output is %d bytes\n", buflen);
1495 const int maxbytes = *maxputbytes;
1496 if (buflen > maxbytes)
1498 *maxputbytes -= buflen;
1516 #if DEBUG_AUDIOSTREAM
1517 printf(
"AUDIOSTREAM: wants to put %d preconverted bytes\n", buflen);
1524 }
else if (
len == 0) {
1526 }
else if ((
len %
stream->src_sample_frame_size) != 0) {
1527 return SDL_SetError(
"Can't add partial sample frames");
1530 if (!
stream->cvt_before_resampling.needed &&
1532 !
stream->cvt_after_resampling.needed) {
1533 #if DEBUG_AUDIOSTREAM
1534 printf(
"AUDIOSTREAM: no conversion needed at all, queueing %d bytes.\n",
len);
1545 if (!
stream->staging_buffer_filled &&
len >=
stream->staging_buffer_size) {
1550 if ((
stream->staging_buffer_filled +
len) <
stream->staging_buffer_size) {
1557 amount = (
stream->staging_buffer_size -
stream->staging_buffer_filled);
1560 stream->staging_buffer_filled = 0;
1576 #if DEBUG_AUDIOSTREAM
1577 printf(
"AUDIOSTREAM: flushing! staging_buffer_filled=%d bytes\n",
stream->staging_buffer_filled);
1583 if (
stream->staging_buffer_filled > 0) {
1588 const int filled =
stream->staging_buffer_filled;
1589 int actual_input_frames = filled /
stream->src_sample_frame_size;
1591 actual_input_frames +=
stream->resampler_padding_samples /
stream->pre_resample_channels;
1593 if (actual_input_frames > 0) {
1595 int flush_remaining = ((
int)
SDL_ceil(actual_input_frames *
stream->rate_incr)) *
stream->dst_sample_frame_size;
1598 printf(
"AUDIOSTREAM: flushing with padding to get max %d bytes!\n", flush_remaining);
1616 stream->staging_buffer_filled = 0;
1626 #if DEBUG_AUDIOSTREAM
1627 printf(
"AUDIOSTREAM: want to get %d converted bytes\n",
len);
1634 }
else if (
len <= 0) {
1636 }
else if ((
len %
stream->dst_sample_frame_size) != 0) {
1637 return SDL_SetError(
"Can't request partial sample frames");
1657 if (
stream->reset_resampler_func) {
1661 stream->staging_buffer_filled = 0;
1670 if (
stream->cleanup_resampler_func) {
#define SDL_assert(condition)
#define SDL_AUDIO_ISBIGENDIAN(x)
#define SDL_AUDIOCVT_MAX_FILTERS
Upper limit of filters in SDL_AudioCVT.
Uint16 SDL_AudioFormat
Audio format flags.
void(* SDL_AudioFilter)(struct SDL_AudioCVT *cvt, SDL_AudioFormat format)
#define SDL_AUDIO_ISFLOAT(x)
#define SDL_AUDIO_MASK_ENDIAN
#define SDL_AUDIO_BITSIZE(x)
SDL_AudioFilter SDL_Convert_F32_to_U16
SDL_AudioFilter SDL_Convert_U16_to_F32
SDL_AudioFilter SDL_Convert_F32_to_S32
#define LOG_DEBUG_CONVERT(from, to)
SDL_AudioFilter SDL_Convert_F32_to_S16
SDL_AudioFilter SDL_Convert_F32_to_U8
SDL_AudioFilter SDL_Convert_F32_to_S8
SDL_AudioFilter SDL_Convert_S8_to_F32
void SDL_ChooseAudioConverters(void)
SDL_AudioFilter SDL_Convert_S32_to_F32
SDL_AudioFilter SDL_Convert_S16_to_F32
SDL_AudioFilter SDL_Convert_U8_to_F32
int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
static int SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat dst_fmt)
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)
static void SDL_Convert51To71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static void kaiser_and_sinc(float *table, float *diffs, const int tablelen, const double beta)
static int SDL_ResampleAudio(const int chans, const int inrate, const int outrate, const float *lpadding, const float *rpadding, const float *inbuf, const int inbuflen, float *outbuf, const int outbuflen)
void(* SDL_ResetAudioStreamResamplerFunc)(SDL_AudioStream *stream)
#define RESAMPLER_SAMPLES_PER_ZERO_CROSSING
static void SDL_Convert71To51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
void SDL_AudioStreamClear(SDL_AudioStream *stream)
int SDL_PrepareResampleFilter(void)
static Uint8 * EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen)
static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, int *maxputbytes)
#define RESAMPLER_FUNCS(chans)
static SDL_AudioFilter ChooseCVTResampler(const int dst_channels)
static SDL_bool SDL_SupportedAudioFormat(const SDL_AudioFormat fmt)
static int SDL_ResampleAudioStream(SDL_AudioStream *stream, const void *_inbuf, const int inbuflen, void *_outbuf, const int outbuflen)
#define DEBUG_AUDIOSTREAM
static int SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat src_fmt)
int SDL_AudioStreamFlush(SDL_AudioStream *stream)
void SDL_FreeResampleFilter(void)
static void SDL_ConvertStereoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static SDL_bool SDL_SupportedChannelCount(const int channels)
static void SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat format)
void(* SDL_CleanupAudioStreamResamplerFunc)(SDL_AudioStream *stream)
static void SDL_Convert51ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format)
static void SDL_ConvertStereoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static float * ResamplerFilterDifference
SDL_AudioStream * SDL_NewAudioStream(const SDL_AudioFormat src_format, const Uint8 src_channels, const int src_rate, const SDL_AudioFormat dst_format, const Uint8 dst_channels, const int dst_rate)
static void SDL_Convert51ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static int SDL_AddAudioCVTFilter(SDL_AudioCVT *cvt, const SDL_AudioFilter filter)
static void SDL_ResetAudioStreamResampler(SDL_AudioStream *stream)
static void SDL_ConvertStereoToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static double bessel(const double x)
static float * ResamplerFilter
static void SDL_CleanupAudioStreamResampler(SDL_AudioStream *stream)
static int ResamplerPadding(const int inrate, const int outrate)
int(* SDL_ResampleAudioStreamFunc)(SDL_AudioStream *stream, const void *inbuf, const int inbuflen, void *outbuf, const int outbuflen)
int SDL_ConvertAudio(SDL_AudioCVT *cvt)
static void SDL_ConvertQuadTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static int SDL_BuildAudioResampleCVT(SDL_AudioCVT *cvt, const int dst_channels, const int src_rate, const int dst_rate)
int SDL_AudioStreamAvailable(SDL_AudioStream *stream)
int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len)
void SDL_FreeAudioStream(SDL_AudioStream *stream)
static void SDL_ConvertMonoToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static void SDL_ConvertQuadToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
static SDL_SpinLock ResampleFilterSpinlock
#define RESAMPLER_FILTER_SIZE
SDL_DataQueue * SDL_NewDataQueue(const size_t _packetlen, const size_t initialslack)
size_t SDL_CountDataQueue(SDL_DataQueue *queue)
void SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack)
int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _len)
size_t SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
void SDL_FreeDataQueue(SDL_DataQueue *queue)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
#define SDL_OutOfMemory()
#define SDL_InvalidParamError(param)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLint GLint GLint x
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLsizei GLenum GLenum const void * table
#define SDL_MAX_SINT32
A signed 32-bit integer type.
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF ptr
int resampler_padding_samples
SDL_ResampleAudioStreamFunc resampler_func
int src_sample_frame_size
Uint8 pre_resample_channels
SDL_AudioCVT cvt_after_resampling
float * resampler_padding
SDL_AudioFormat src_format
SDL_ResetAudioStreamResamplerFunc reset_resampler_func
SDL_AudioFormat dst_format
SDL_AudioCVT cvt_before_resampling
int staging_buffer_filled
SDL_CleanupAudioStreamResamplerFunc cleanup_resampler_func
int dst_sample_frame_size
A structure to hold a set of audio conversion filters and buffers.
SDL_AudioFormat src_format
SDL_AudioFormat dst_format
SDL_AudioFilter filters[SDL_AUDIOCVT_MAX_FILTERS+1]
typedef int(__stdcall *FARPROC)()