zenilib: zenilib/jni/external/sdl/src/audio/SDL_audiocvt.c File Reference

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Macros | Functions
SDL_audiocvt.c File Reference
`#include "SDL_config.h"`
`#include "SDL_audio.h"`
`#include "SDL_audio_c.h"`
`#include "SDL_assert.h"`

Go to the source code of this file.

## Macros

#define | dup_chans_1_to_2(type)
#define | strip_chans_6_to_2(type)
#define | strip_chans_6_to_4(type)

## Functions

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 int | SDL_BuildAudioResampleCVT (SDL_AudioCVT *cvt, int dst_channels, int src_rate, int dst_rate)
static int | SDL_BuildAudioTypeCVT (SDL_AudioCVT *cvt, SDL_AudioFormat src_fmt, SDL_AudioFormat dst_fmt)
int | SDL_ConvertAudio (SDL_AudioCVT *cvt)
static void SDLCALL | SDL_ConvertMono (SDL_AudioCVT *cvt, SDL_AudioFormat format)
static void SDLCALL | SDL_ConvertStereo (SDL_AudioCVT *cvt, SDL_AudioFormat format)
static void SDLCALL | SDL_ConvertStrip (SDL_AudioCVT *cvt, SDL_AudioFormat format)
static void SDLCALL | SDL_ConvertStrip_2 (SDL_AudioCVT *cvt, SDL_AudioFormat format)
static void SDLCALL | SDL_ConvertSurround (SDL_AudioCVT *cvt, SDL_AudioFormat format)
static void SDLCALL | SDL_ConvertSurround_4 (SDL_AudioCVT *cvt, SDL_AudioFormat format)
static int | SDL_FindFrequencyMultiple (const int src_rate, const int dst_rate)
static SDL_AudioFilter | SDL_HandTunedResampleCVT (SDL_AudioCVT *cvt, int dst_channels, int src_rate, int dst_rate)
static SDL_AudioFilter | SDL_HandTunedTypeCVT (SDL_AudioFormat src_fmt, SDL_AudioFormat dst_fmt)

## Macro Definition Documentation

#define dup_chans_1_to_2 | ( |  | type | ) |

Value:
{ \
const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
type *dst = (type *) (cvt->buf + cvt->len_cvt * 2); \
for (i = cvt->len_cvt / sizeof(type); i; --i) { \
src -= 1; \
dst -= 2; \
dst[0] = dst[1] = *src; \
} \
}
type
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Definition: gl2ext.h:845
dst
GLenum GLenum dst
Definition: glew.h:2396
for
for(;;)
Definition: glslang_tab.cpp:4773
const
#define const
Definition: zconf.h:91
src
GLenum src
Definition: glew.h:2396
i
int i
Definition: pngrutil.c:1377

Referenced by SDL_ConvertStereo().

#define strip_chans_6_to_2 | ( |  | type | ) |

Value:
{ \
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; \
} \
}
type
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Definition: gl2ext.h:845
dst
GLenum GLenum dst
Definition: glew.h:2396
for
for(;;)
Definition: glslang_tab.cpp:4773
sizeof
sizeof(FT_AutofitterRec)
const
#define const
Definition: zconf.h:91
src
GLenum src
Definition: glew.h:2396
i
int i
Definition: pngrutil.c:1377

Referenced by SDL_ConvertStrip().

#define strip_chans_6_to_4 | ( |  | type | ) |

Value:
{ \
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; \
} \
}
type
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
Definition: gl2ext.h:845
dst
GLenum GLenum dst
Definition: glew.h:2396
for
for(;;)
Definition: glslang_tab.cpp:4773
sizeof
sizeof(FT_AutofitterRec)
const
#define const
Definition: zconf.h:91
src
GLenum src
Definition: glew.h:2396
i
int i
Definition: pngrutil.c:1377

Referenced by SDL_ConvertStrip_2().

## Function Documentation

int SDL_BuildAudioCVT | ( | SDL_AudioCVT * | cvt,
|  | SDL_AudioFormat | src_format,
|  | Uint8 | src_channels,
|  | int | src_rate,
|  | SDL_AudioFormat | dst_format,
|  | Uint8 | dst_channels,
|  | int | dst_rate
| ) |  |

This function takes a source format and rate and a destination format and rate, and initializes the `cvt` structure with information needed by SDL_ConvertAudio() to convert a buffer of audio data from one format to the other.

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.

Definition at line 958 of file SDL_audiocvt.c.

References SDL_AudioCVT::buf, SDL_AudioCVT::dst_format, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, SDL_AudioCVT::len, SDL_AudioCVT::len_mult, SDL_AudioCVT::len_ratio, SDL_AudioCVT::needed, NULL, SDL_AudioCVT::rate_incr, SDL_AUDIO_BITSIZE, SDL_AUDIO_ISSIGNED, SDL_BuildAudioResampleCVT(), SDL_BuildAudioTypeCVT(), SDL_ConvertMono(), SDL_ConvertStereo(), SDL_ConvertStrip(), SDL_ConvertStrip_2(), SDL_ConvertSurround(), SDL_ConvertSurround_4(), SDL_InvalidParamError, SDL_SetError(), SDL_zerop, and SDL_AudioCVT::src_format.

Referenced by open_audio_device().

static int SDL_BuildAudioResampleCVT | ( | SDL_AudioCVT * | cvt,
|  | int | dst_channels,
|  | int | src_rate,
|  | int | dst_rate
| ) |  |

static

Definition at line 904 of file SDL_audiocvt.c.

References SDL_AudioRateFilters::channels, SDL_AudioCVT::dst_format, SDL_AudioRateFilters::filter, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, SDL_AudioRateFilters::fmt, i, int, SDL_AudioCVT::len_mult, SDL_AudioCVT::len_ratio, SDL_AudioRateFilters::multiple, NULL, sdl_audio_rate_filters, SDL_ceil(), SDL_FindFrequencyMultiple(), SDL_HandTunedResampleCVT(), SDL_SetError(), and SDL_AudioRateFilters::upsample.

Referenced by SDL_BuildAudioCVT().

static int SDL_BuildAudioTypeCVT | ( | SDL_AudioCVT * | cvt,
|  | SDL_AudioFormat | src_fmt,
|  | SDL_AudioFormat | dst_fmt
| ) |  |

static

Definition at line 816 of file SDL_audiocvt.c.

References SDL_AudioTypeFilters::dst_fmt, SDL_AudioTypeFilters::filter, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_mult, SDL_AudioCVT::len_ratio, NULL, SDL_AUDIO_BITSIZE, sdl_audio_type_filters, SDL_HandTunedTypeCVT(), SDL_SetError(), and SDL_AudioTypeFilters::src_fmt.

Referenced by SDL_BuildAudioCVT().

int SDL_ConvertAudio | ( | SDL_AudioCVT * | cvt | ) |

Once you have initialized the `cvt` structure using SDL_BuildAudioCVT(), created an audio buffer `cvt->buf`, and filled it with `cvt->len` bytes of audio data in the source format, this function will convert it in-place to the desired format.

The data conversion may expand the size of the audio data, so the buffer `cvt->buf` should be allocated after the `cvt` structure is initialized by SDL_BuildAudioCVT(), and should be `cvt->len*cvt->len_mult` bytes long.

Definition at line 774 of file SDL_audiocvt.c.

References SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, SDL_AudioCVT::len, SDL_AudioCVT::len_cvt, NULL, SDL_SetError(), and SDL_AudioCVT::src_format.

Referenced by SDL_RunAudio().

static void SDLCALL SDL_ConvertMono | ( | SDL_AudioCVT * | cvt,
|  | SDL_AudioFormat | format
| ) |  |

static

Definition at line 34 of file SDL_audiocvt.c.

References AUDIO_F32, AUDIO_S16, AUDIO_S32, AUDIO_S8, AUDIO_U16, AUDIO_U8, SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, SDL_AUDIO_ISBIGENDIAN, SDL_AUDIO_MASK_BITSIZE, SDL_AUDIO_MASK_SIGNED, SDL_SwapBE32, SDL_SwapFloatBE, SDL_SwapFloatLE, and SDL_SwapLE32.

Referenced by SDL_BuildAudioCVT().

static void SDLCALL SDL_ConvertStereo | ( | SDL_AudioCVT * | cvt,
|  | SDL_AudioFormat | format
| ) |  |

static

Definition at line 283 of file SDL_audiocvt.c.

References dup_chans_1_to_2, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, and SDL_AUDIO_BITSIZE.

Referenced by SDL_BuildAudioCVT().

static void SDLCALL SDL_ConvertStrip | ( | SDL_AudioCVT * | cvt,
|  | SDL_AudioFormat | format
| ) |  |

static

Definition at line 193 of file SDL_audiocvt.c.

References SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, SDL_AUDIO_BITSIZE, and strip_chans_6_to_2.

Referenced by SDL_BuildAudioCVT().

static void SDLCALL SDL_ConvertStrip_2 | ( | SDL_AudioCVT * | cvt,
|  | SDL_AudioFormat | format
| ) |  |

static

Definition at line 237 of file SDL_audiocvt.c.

References SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, SDL_AUDIO_BITSIZE, and strip_chans_6_to_4.

Referenced by SDL_BuildAudioCVT().

static void SDLCALL SDL_ConvertSurround | ( | SDL_AudioCVT * | cvt,
|  | SDL_AudioFormat | format
| ) |  |

static

Definition at line 326 of file SDL_audiocvt.c.

References AUDIO_F32, AUDIO_S16, AUDIO_S32, AUDIO_S8, AUDIO_U16, AUDIO_U8, SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, SDL_AUDIO_ISBIGENDIAN, SDL_AUDIO_MASK_BITSIZE, SDL_AUDIO_MASK_SIGNED, SDL_SwapBE32, SDL_SwapFloatBE, SDL_SwapFloatLE, and SDL_SwapLE32.

Referenced by SDL_BuildAudioCVT().

static void SDLCALL SDL_ConvertSurround_4 | ( | SDL_AudioCVT * | cvt,
|  | SDL_AudioFormat | format
| ) |  |

static

Definition at line 583 of file SDL_audiocvt.c.

References AUDIO_S16, AUDIO_S32, AUDIO_S8, AUDIO_U16, AUDIO_U8, SDL_AudioCVT::buf, SDL_AudioCVT::filter_index, SDL_AudioCVT::filters, i, SDL_AudioCVT::len_cvt, SDL_AUDIO_ISBIGENDIAN, SDL_AUDIO_MASK_BITSIZE, SDL_AUDIO_MASK_SIGNED, SDL_SwapBE32, and SDL_SwapLE32.

Referenced by SDL_BuildAudioCVT().

static int SDL_FindFrequencyMultiple | ( | const int | src_rate,
|  | const int | dst_rate
| ) |  |

static

Definition at line 871 of file SDL_audiocvt.c.

References cordic::hi, cordic::lo, and SDL_assert.

Referenced by SDL_BuildAudioResampleCVT().

static SDL_AudioFilter SDL_HandTunedResampleCVT | ( | SDL_AudioCVT * | cvt,
|  | int | dst_channels,
|  | int | src_rate,
|  | int | dst_rate
| ) |  |

static

Definition at line 859 of file SDL_audiocvt.c.

References NULL.

Referenced by SDL_BuildAudioResampleCVT().

static SDL_AudioFilter SDL_HandTunedTypeCVT | ( | SDL_AudioFormat | src_fmt,
|  | SDL_AudioFormat | dst_fmt
| ) |  |

static

Definition at line 798 of file SDL_audiocvt.c.

References NULL.

Referenced by SDL_BuildAudioTypeCVT().